ref: 96ca4f7c284ac20b297dc5572d1caa9cd09c71c2
parent: 77df6fcc4bef18ca74669d94e5fd98432c9c3e69
author: Tanguy Fautre <tanguy@fautre.com>
date: Mon Feb 10 15:16:52 EST 2020
Removed PLATFORM_DOS Removed more WIN32 build cruft. Fixed Release NDEBUG defined for all config as nDEBUG (WTF?) Fixed infinite loop when starting a new game.
--- a/Engine/Engine.vcxproj
+++ b/Engine/Engine.vcxproj
@@ -54,7 +54,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir)build\vcpkg.windows\installed\x86-windows-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>nDBGRECORD; nDEBUG; UDP_NETWORKING; WIN32; _LIB; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>nDBGRECORD; UDP_NETWORKING; WIN32; _LIB; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalOptions> /J</AdditionalOptions>
<PrecompiledHeader />
@@ -79,7 +79,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>$(SolutionDir)build\vcpkg.windows\installed\x86-windows-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>nDBGRECORD; nDEBUG; UDP_NETWORKING; WIN32; _LIB; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>nDBGRECORD; NDEBUG; UDP_NETWORKING; WIN32; _LIB; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<AdditionalOptions> /J</AdditionalOptions>
--- a/Engine/src/engine.c
+++ b/Engine/src/engine.c
@@ -3349,9 +3349,9 @@
walltype *w;
sectortype *sect;
-#if ((defined PLATFORM_DOS) || (defined WIN32))
+#ifdef WIN32
permissions = S_IWRITE;
-#elif (defined PLATFORM_UNIX)
+#elif
permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
#endif
--- a/Engine/src/mmulti.c
+++ b/Engine/src/mmulti.c
@@ -563,36 +563,6 @@
{
}
-#elif (defined PLATFORM_DOS)
-gcomtype *init_network_transport(char **ARGV, int argpos)
-{
- /*
- * How to talk to COMMIT is passed as a pointer to a block of memory
- * that COMMIT.EXE configures...
- */
- return((gcomtype *)atol(ARGV[argpos])); /* UGH! --ryan. */
-} /* init_network_transport */
-
-static union REGS regs;
-
-#pragma aux longcall =\
- "call eax",\
- parm [eax]
-
-void callcommit(void)
-{
- if (gcom->intnum&0xff00)
- longcall(gcom->longcalladdress);
- else
- int386(gcom->intnum,®s,®s);
-}
-
-void deinit_network_transport(gcomtype *gcom)
-{
- /* no-op, apparently. */
-}
-
-
#elif UDP_NETWORKING
#if WIN32
--- a/Engine/src/platform.h
+++ b/Engine/src/platform.h
@@ -5,8 +5,6 @@
#include "win32_compat.h"
#elif (defined PLATFORM_UNIX)
#include "unix_compat.h"
-#elif (defined PLATFORM_DOS)
- #include "doscmpat.h"
#elif (defined __APPLE__)
#include "macos_compat.h"
#else
--- a/Engine/src/win32_compat.h
+++ b/Engine/src/win32_compat.h
@@ -24,7 +24,7 @@
#include <unistd.h>
#else
#include <fcntl.h>
- #include <SYS\STAT.H>
+ #include <sys/stat.h>
#endif
#include <stdlib.h>
@@ -39,12 +39,10 @@
#undef FP_OFF
#endif
-#define FP_OFF(x) ((long) (x))
+// Horrible horrible macro: Watcom allowed memory pointer to be cast
+// to a 32bits integer. The code is unfortunately stuffed with this :( !
+#define FP_OFF(x) ((int32_t) (x))
-/* !!! This might be temporary. */
-#define printext16 printext256
-#define printext16_noupdate printext256_noupdate
-
#ifndef max
#define max(x, y) (((x) > (y)) ? (x) : (y))
#endif
@@ -68,7 +66,6 @@
#endif /* defined _MSC_VER */
#define snprintf _snprintf
-
#define strncasecmp strnicmp
#include <inttypes.h>
--- a/Game/Game.vcxproj
+++ b/Game/Game.vcxproj
@@ -65,7 +65,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>$(SolutionDir)build\vcpkg.windows\installed\x86-windows-static\include;..\Engine\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>nDBGRECORD; CHECK_XDUKE_REV; nDEBUG; WIN32; _CONSOLE; PLATFORM_WIN32; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>nDBGRECORD; CHECK_XDUKE_REV; NDEBUG; WIN32; _CONSOLE; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<AdditionalOptions> /J</AdditionalOptions>
@@ -95,7 +95,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir)build\vcpkg.windows\installed\x86-windows-static\include;..\Engine\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>nDBGRECORD; CHECK_XDUKE_REV; nDEBUG; WIN32; _CONSOLE; PLATFORM_WIN32; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>nDBGRECORD; CHECK_XDUKE_REV; WIN32; _CONSOLE; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalOptions> /J</AdditionalOptions>
@@ -153,6 +153,7 @@
<ClCompile Include="src\cvars.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="src\global.h" />
<ClInclude Include="src\_rts.h" />
<ClInclude Include="src\animlib.h" />
<ClInclude Include="src\config.h" />
--- a/Game/Game.vcxproj.filters
+++ b/Game/Game.vcxproj.filters
@@ -184,6 +184,9 @@
<ClInclude Include="src\cvars.h">
<Filter>Console Headers</Filter>
</ClInclude>
+ <ClInclude Include="src\global.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="chocolateDukeResources.rc" />
--- a/Game/chocolateDukeResources.rc
+++ b/Game/chocolateDukeResources.rc
@@ -2,10 +2,6 @@
#include <commctrl.h>
#include <richedit.h>
-
-
-
-
//
// Icon resources
//
--- a/Game/src/audiolib/dpmi.h
+++ b/Game/src/audiolib/dpmi.h
@@ -31,11 +31,7 @@
#ifndef __DPMI_H
#define __DPMI_H
-#ifdef _WIN32
-#include "../../../Engine/src/windows/inttypes.h"
-#else
#include <inttypes.h>
-#endif
enum DPMI_Errors
{
--- a/Game/src/audiolib/fx_man.h
+++ b/Game/src/audiolib/fx_man.h
@@ -32,11 +32,7 @@
#define __FX_MAN_H
#include "sndcards.h"
-#ifdef _WIN32
- #include "../../Engine/src/windows/inttypes.h"
-#else
- #include <inttypes.h>
-#endif
+#include <inttypes.h>
typedef struct
{
--- a/Game/src/config.c
+++ b/Game/src/config.c
@@ -24,11 +24,6 @@
*/
//-------------------------------------------------------------------------
-#if PLATFORM_DOS
-#include <conio.h>
-#include <dos.h>
-#endif
-
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -693,17 +688,14 @@
}
SCRIPT_GetNumber( scripthandle, "Sound Setup", "FXDevice",&FXDevice);
- #if !PLATFORM_DOS // reimplementation of ASS expects a "SoundScape".
- if (FXDevice != NumSoundCards)
- FXDevice = SoundScape;
- #endif
+ // reimplementation of ASS expects a "SoundScape".
+ if (FXDevice != NumSoundCards)
+ FXDevice = SoundScape;
SCRIPT_GetNumber( scripthandle, "Sound Setup", "MusicDevice",&MusicDevice);
- //#if !PLATFORM_DOS // reimplementation of ASS expects a "SoundScape".
// if (MusicDevice != NumSoundCards)
// MusicDevice = SoundScape;
- //#endif
// FIX_00015: Forced NumVoices=8, NumChannels=2, NumBits=16, MixRate=44100, ScreenMode = x(
// (ScreenMode has no meaning anymore)
--- a/Game/src/cvar_defs.h
+++ b/Game/src/cvar_defs.h
@@ -1,11 +1,7 @@
#ifndef _CVARDEFS_H_
#define _CVARDEFS_H_
-#ifdef _WIN32
- #include "../../Engine/src/windows/inttypes.h"
-#else
- #include <inttypes.h>
-#endif
+#include <inttypes.h>
void CVARDEFS_Init();
void CVARDEFS_Render();
--- a/Game/src/cvars.h
+++ b/Game/src/cvars.h
@@ -4,11 +4,7 @@
#define REGCONVAR(varname, varhelp, variable, function) CVAR_RegisterCvar(varname, varhelp, &variable, &function)
#define REGCONFUNC(varname, varhelp, function) CVAR_RegisterCvar(varname, varhelp, NULL, &function)
-#ifdef _WIN32
- #include "../../Engine/src/windows/inttypes.h"
-#else
- #include <inttypes.h>
-#endif
+#include <inttypes.h>
typedef void (*function_t) (void* binding);
--- a/Game/src/duke3d.h
+++ b/Game/src/duke3d.h
@@ -37,11 +37,7 @@
#include <malloc.h>
#endif
-#ifdef _WIN32
-#include "../../Engine/src/windows/inttypes.h"
-#else
#include <inttypes.h>
-#endif
#include <fcntl.h>
#include <time.h>
@@ -59,14 +55,6 @@
#endif
#endif
-#if PLATFORM_DOS
-#include <dos.h>
-#include <bios.h>
-#include <io.h>
-#define PATH_SEP_CHAR '\\'
-#define PATH_SEP_STR "\\"
-#endif
-
#if PLATFORM_UNIX
#include "dukeunix.h"
#endif
@@ -75,7 +63,7 @@
#include "dukeunix.h"
#endif
-#if PLATFORM_WIN32
+#if WIN32
#include "dukewin.h"
#endif
@@ -352,7 +340,7 @@
typedef struct
{
uint8_t *ptr;
- uint8_t lock;
+ volatile uint8_t lock; // tanguyf: if not volatile, the game can go into an infinite loop in optimised mode
int length, num;
} SAMPLE;
@@ -519,11 +507,6 @@
extern struct player_struct ps[MAXPLAYERS];
extern struct player_orig po[MAXPLAYERS];
extern struct user_defs ud;
-
-// ported build engine has this, too. --ryan.
-#if PLATFORM_DOS
-extern short int moustat;
-#endif
extern short int global_random;
extern int32_t scaredfallz;
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -116,38 +116,12 @@
uint8_t restorepalette,screencapt,nomorelogohack;
int sendmessagecommand = -1;
-#if PLATFORM_DOS
-task *TimerPtr=NULL;
-#endif
-
extern int32_t lastvisinc;
-// Build Engine port implements this. --ryan.
-#if PLATFORM_DOS
-static void timerhandler(task *unused)
-{
- totalclock++;
-}
-
-void inittimer()
-{
- TimerPtr = TS_ScheduleTask( timerhandler,TICRATE, 1, NULL );
- TS_Dispatch();
-}
-
-void uninittimer(void)
-{
- if (TimerPtr)
- TS_Terminate( TimerPtr );
- TimerPtr = NULL;
- TS_Shutdown();
-}
-#else
void timerhandler(void)
{
totalclock++;
}
-#endif
int gametext(int x,int y,char *t,uint8_t s,short dabits)
{
@@ -2471,11 +2445,7 @@
if(true)
{
if(*t == ' ' && *(t+1) == 0) *t = 0;
- #if PLATFORM_DOS // Is there a good reason for this? --ryan.
- printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- #else
printf("\n%s\n",t);
- #endif
}
// CTW END - MODIFICATION
}
@@ -7783,18 +7753,11 @@
if(networkmode == 255)
networkmode = 1;
-#ifdef PLATFORM_DOS
- puts("Checking music inits.");
- MusicStartup();
- puts("Checking sound inits.");
- SoundStartup();
-#else
/* SBF - wasn't sure if swapping them would harm anything. */
puts("Checking sound inits.");
SoundStartup();
puts("Checking music inits.");
MusicStartup();
-#endif
// AutoAim
if(nHostForceDisableAutoaim)
@@ -8008,7 +7971,7 @@
else
sprintf(groupfilefullpath, "%s", baseDir);
- printf("Searching '%d':\n\n",groupfilefullpath);
+ printf("Searching '%s':\n\n",groupfilefullpath);
hFind = FindFirstFile(groupfilefullpath,&FindFileData);
if ( hFind==INVALID_HANDLE_VALUE )
--- a/Game/src/global.c
+++ b/Game/src/global.c
@@ -76,11 +76,6 @@
struct weaponhit hittype[MAXSPRITES];
short spriteq[1024],spriteqloc,spriteqamount=64;
-// ported build engine has this, too. --ryan.
-#if PLATFORM_DOS
-short moustat = 0;
-#endif
-
struct animwalltype animwall[MAXANIMWALLS];
short numanimwalls;
int32_t *animateptr[MAXANIMATES], animategoal[MAXANIMATES], animatevel[MAXANIMATES], animatecnt;
@@ -301,11 +296,7 @@
#endif
}
-
-#if PLATFORM_DOS
- /* no-op. */
-
-#elif PLATFORM_WIN32
+#if WIN32
int _dos_findfirst(uint8_t *filename, int x, struct find_t *f)
{
int32_t rc = _findfirst(filename, &f->data);
@@ -430,8 +421,6 @@
#error please define for your platform.
#endif
-
-#if !PLATFORM_DOS
void _dos_getdate(struct dosdate_t *date)
{
time_t curtime = time(NULL);
@@ -450,9 +439,7 @@
date->dayofweek = tm->tm_wday + 1;
}
}
-#endif
-
int FindDistance2D(int ix, int iy)
{
int t;
@@ -557,7 +544,7 @@
filename[sizeof (filename) - 1] = '\0';
FixFilePath(filename);
-#if (defined PLATFORM_WIN32)
+#if (defined WIN32)
handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_APPEND );
#else
handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_APPEND , S_IREAD | S_IWRITE);
@@ -576,8 +563,8 @@
filename[sizeof (filename) - 1] = '\0';
FixFilePath(filename);
-#if( defined PLATFORM_WIN32)
- return(access(filename, 6) == 0);
+#if( defined WIN32)
+ return(access(filename, 6) == 0);
#else
return(access(filename, F_OK) == 0);
#endif
@@ -592,7 +579,7 @@
filename[sizeof (filename) - 1] = '\0';
FixFilePath(filename);
-#if (defined PLATFORM_WIN32)
+#if (defined WIN32)
handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC );
#else
handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC
--- a/Game/src/global.h
+++ b/Game/src/global.h
@@ -27,7 +27,7 @@
#endif
#endif
-#if PLATFORM_WIN32
+#if WIN32
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif
--- a/Game/src/sounds.c
+++ b/Game/src/sounds.c
@@ -24,10 +24,6 @@
*/
//-------------------------------------------------------------------------
-#if PLATFORM_DOS
-#include <conio.h>
-#endif
-
#include <stdio.h>
#include <string.h>
#include "../../Game/src/types.h"
--- a/Game/src/types.h
+++ b/Game/src/types.h
@@ -27,11 +27,7 @@
#ifndef _types_public
#define _types_public
-#ifdef _WIN32
- #include "../../Engine/src/windows/inttypes.h"
-#else
- #include <inttypes.h>
-#endif
+#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
--- a/Game/src/util_lib.h
+++ b/Game/src/util_lib.h
@@ -30,11 +30,7 @@
//
//***************************************************************************
-#ifdef _WIN32
- #include "../../Engine/src/windows/inttypes.h"
-#else
- #include <inttypes.h>
-#endif
+#include <inttypes.h>
#ifndef _util_lib_public
#define _util_lib_public