Skip to content

Commit

Permalink
Some fixes for old compiler support.
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamyCecil committed Feb 5, 2024
1 parent 6045225 commit a4c6d06
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 33 deletions.
5 changes: 3 additions & 2 deletions Sources/Engine/Base/FileName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ void CTString::SetAbsolutePath(void)
}
}
// Remove certain path parts
for (INDEX iPart = 0; iPart < astrParts.Count(); ++iPart) {
INDEX iPart;
for (iPart = 0; iPart < astrParts.Count(); ++iPart) {
if (CTString("..") != astrParts[iPart]) {
continue;
}
Expand All @@ -152,7 +153,7 @@ void CTString::SetAbsolutePath(void)
}
// Set new content
strRemaining.Clear();
for (INDEX iPart = 0; iPart < astrParts.Count(); ++iPart) {
for (iPart = 0; iPart < astrParts.Count(); ++iPart) {
strRemaining += astrParts[iPart];
if (iPart < astrParts.Count() - 1) {
strRemaining += "\\";
Expand Down
11 changes: 11 additions & 0 deletions Sources/Engine/Base/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Base/ErrorReporting.h>

#if SE1_WIN
// [Cecil] Undefine debug operator
#ifndef NDEBUG
#undef new
#endif

#include <new.h>

// [Cecil] Redefine it again
#ifndef NDEBUG
#define new DEBUG_NEW_CT
#endif

#else
#include <new>
#endif
Expand Down
2 changes: 2 additions & 0 deletions Sources/Engine/Base/Shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ class ENGINE_API CShell {
// Declare a symbol in the shell.
void DeclareSymbol(const CTString &strDeclaration, void *pvValue);

#if !SE1_OLD_COMPILER
// [Cecil] Declare symbol of any type
template<typename Type> __forceinline
void DeclareSymbol(const CTString &strDeclaration, Type *pValue) {
DeclareSymbol(strDeclaration, (void *)pValue);
};
#endif

// Execute command(s).
void Execute(const CTString &strCommands);
Expand Down
4 changes: 2 additions & 2 deletions Sources/Engine/Base/StackDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ BOOL MSJExceptionHandler::GetLogicalAddress(
if ( !VirtualQuery( addr, &mbi, sizeof(mbi) ) )
return FALSE;

DWORD_PTR hMod = (DWORD_PTR)mbi.AllocationBase;
UINT_PTR hMod = (UINT_PTR)mbi.AllocationBase;

if ( !GetModuleFileNameA( (HMODULE)hMod, szModule, len ) )
return FALSE;
Expand All @@ -285,7 +285,7 @@ BOOL MSJExceptionHandler::GetLogicalAddress(

PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION( pNtHdr );

DWORD_PTR rva = (DWORD_PTR)addr - hMod; // RVA is offset from module load address
UINT_PTR rva = (UINT_PTR)addr - hMod; // RVA is offset from module load address

// Iterate through the section table, looking for the one that encompasses
// the linear address.
Expand Down
6 changes: 5 additions & 1 deletion Sources/Engine/Base/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sys/stat.h>
#include <fcntl.h>

#if SE1_WIN
#if SE1_WIN && !SE1_OLD_COMPILER
#include <io.h>
#include <DbgHelp.h>

#pragma comment(lib, "DbgHelp.lib")
#endif

#include <Engine/Base/Protection.h>
Expand Down Expand Up @@ -960,8 +962,10 @@ void CTFileStream::Create_t(const CTFileName &fnFileName,
// check that the file is not open
ASSERT(fstrm_pFile == NULL);

#if !SE1_OLD_COMPILER
// create the directory for the new file if it doesn't exist yet
MakeSureDirectoryPathExists(fnmFullFileName.ConstData());
#endif

// open file stream for writing (destroy file context if file existed before)
fstrm_pFile = fopen(fnmFullFileName.ConstData(), "wb+");
Expand Down
8 changes: 5 additions & 3 deletions Sources/Engine/Base/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,11 @@ typedef BSPCutter DOUBLEbspcutter3D;
template<class cType>
inline void Clear(cType &t) { t.Clear(); };

// [Cecil] Clear pointer of any type
template<class cType>
inline void Clear(cType *pt) {};
#if !SE1_OLD_COMPILER
// [Cecil] Clear pointer of any type
template<class cType>
inline void Clear(cType *pt) {};
#endif

// specific clearing functions for built-in types
inline void Clear(signed long int sli) {};
Expand Down
8 changes: 4 additions & 4 deletions Sources/Engine/Engine.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<LinkDLL>true</LinkDLL>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>zlib.lib;gdi32.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>zlib.lib;gdi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateMapFile>true</GenerateMapFile>
<IgnoreSpecificDefaultLibraries>libci.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>
Expand Down Expand Up @@ -178,7 +178,7 @@
<LinkDLL>true</LinkDLL>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>zlib.lib;gdi32.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>zlib.lib;gdi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateMapFile>true</GenerateMapFile>
<IgnoreSpecificDefaultLibraries>libci.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>
Expand Down Expand Up @@ -225,7 +225,7 @@
<LinkDLL>true</LinkDLL>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>zlib.lib;odbc32.lib;odbccp32.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>zlib.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateMapFile>true</GenerateMapFile>
<IgnoreSpecificDefaultLibraries>libci.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>
Expand Down Expand Up @@ -272,7 +272,7 @@
<LinkDLL>true</LinkDLL>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>zlib.lib;odbc32.lib;odbccp32.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>zlib.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateMapFile>true</GenerateMapFile>
<IgnoreSpecificDefaultLibraries>libci.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>
Expand Down
6 changes: 3 additions & 3 deletions Sources/Engine/GameAgent/GameAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ extern void GameAgent_EnumUpdate(void)
CNetworkSession &ns = *new CNetworkSession;
_pNetwork->ga_lhEnumeratedSessions.AddTail(ns.ns_lnNode);

long long tmPing = -1;
SQUAD tmPing = -1;
// find the request in the request array
for(INDEX i=0; i<ga_asrRequests.Count(); i++) {
CServerRequest &req = ga_asrRequests[i];
Expand Down Expand Up @@ -1158,7 +1158,7 @@ DWORD WINAPI _MS_Thread(LPVOID lpParam) {
strGameName = strActiveMod;
}

long long tmPing = -1;
SQUAD tmPing = -1;
// find the request in the request array
for(INDEX i=0; i<ga_asrRequests.Count(); i++) {
CServerRequest &req = ga_asrRequests[i];
Expand Down Expand Up @@ -1366,7 +1366,7 @@ DWORD WINAPI _LocalNet_Thread(LPVOID lpParam) {
strGameName = strActiveMod;
}

long long tmPing = -1;
SQUAD tmPing = -1;
// find the request in the request array
for(INDEX i=0; i<ga_asrRequests.Count(); i++) {
CServerRequest &req = ga_asrRequests[i];
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/GameAgent/GameAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CServerRequest {
public:
ULONG sr_ulAddress;
UWORD sr_iPort;
long long sr_tmRequestTime;
SQUAD sr_tmRequestTime;

public:
CServerRequest(void);
Expand Down
4 changes: 4 additions & 0 deletions Sources/Engine/Graphics/GfxLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ static HHOOK _hLLKeyHook = NULL;

LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam)
{
// [Cecil] NOTE: Is this code even needed?
#if !SE1_OLD_COMPILER
// By returning a non-zero value from the hook procedure, the
// message does not get passed to the target window
KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
Expand Down Expand Up @@ -359,6 +361,8 @@ LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam)
default:
break;
}
#endif // !SE1_OLD_COMPILER

return CallNextHookEx (_hLLKeyHook, nCode, wParam, lParam);
}

Expand Down
12 changes: 11 additions & 1 deletion Sources/Engine/Graphics/ViewPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,14 @@ LRESULT CALLBACK CViewPortCLASS_WindowProc(
// send it to parent
HWND hWndParent = GetParent(hWnd);
ASSERT(hWndParent!=NULL);

#if SE1_OLD_COMPILER
return CallWindowProc( (WNDPROC)GetWindowLong(hWndParent, GWL_WNDPROC),
hWndParent, Msg, wParam, lParam);
#else
return CallWindowProc( (WNDPROC)GetWindowLongPtr(hWndParent, GWLP_WNDPROC),
hWndParent, Msg, wParam, lParam);
#endif
}

// [Cecil] FIXME: For some reason it returns 0 on x64
Expand Down Expand Up @@ -184,7 +190,11 @@ void CViewPort::OpenCanvas(void)
0,0, // window size
vp_hWndParent,
NULL,
(HINSTANCE)GetWindowLongPtr(vp_hWndParent, GWLP_HINSTANCE),
#if SE1_OLD_COMPILER
(HINSTANCE)GetWindowLong(vp_hWndParent, GWL_HINSTANCE),
#else
(HINSTANCE)GetWindowLongPtr(vp_hWndParent, GWLP_HINSTANCE),
#endif
NULL);
ASSERT( vp_hWnd!=NULL);
#ifdef SE1_D3D
Expand Down
8 changes: 7 additions & 1 deletion Sources/Engine/Light/LayerMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Templates/DynamicArray.cpp>

// [Cecil] For no ASM in CLayerMixer::AddAmbientPoint()
#include <xmmintrin.h>
#if !SE1_OLD_COMPILER
#include <xmmintrin.h>
#endif

// asm shortcuts
#define O offset
Expand Down Expand Up @@ -268,6 +270,8 @@ static SLONG _slL2Row, _slDDL2oDU, _slDDL2oDV, _slDDL2oDUoDV, _slDL2oDURow, _slD
static SLONG _slLightMax, _slHotSpot, _slLightStep;
static ULONG *_pulLayer;

#if !SE1_USE_ASM

// [Cecil] Separate methods to avoid code duplication
static __forceinline void PrepareColorMMX(__m64 &mm7, const ULONG ulLightRGB) {
#if SE1_MMXINTOPT
Expand Down Expand Up @@ -358,6 +362,8 @@ static __forceinline void MixPixelMMX(ULONG &ulPixel, const SLONG slIntensity, c
#endif
};

#endif // !SE1_USE_ASM

// add one layer point light without diffusion and mask
void CLayerMixer::AddAmbientPoint(void)
{
Expand Down
6 changes: 3 additions & 3 deletions Sources/Engine/OS/OS.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ENGINE_API OS {

struct ENGINE_API Message {
// PeekMessage()
static BOOL Peek(MSG *lpMsg, OS::Window hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
static BOOL Peek(MSG *lpMsg, Window hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);

// TranslateMessage()
static void Translate(const MSG *lpMsg);
Expand All @@ -87,11 +87,11 @@ class ENGINE_API OS {
static void Dispatch(const MSG *lpMsg);
};

static BOOL IsIconic(OS::Window hWnd);
static BOOL IsIconic(Window hWnd);
static UWORD GetKeyState(int vKey);
static UWORD GetAsyncKeyState(int vKey);
static BOOL GetCursorPos(LPPOINT lpPoint);
static BOOL ScreenToClient(OS::Window hWnd, LPPOINT lpPoint);
static BOOL ScreenToClient(Window hWnd, LPPOINT lpPoint);
static int ShowCursor(BOOL bShow);
};

Expand Down
11 changes: 8 additions & 3 deletions Sources/Engine/Sound/SoundLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

#include "stdh.h"
#include "initguid.h"

// [Cecil] Windows-specific
#if SE1_WIN
#include <initguid.h>

#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "dxguid.lib")
#endif

#include <Engine/Sound/SoundLibrary.h>
#include <Engine/Base/Translation.h>
Expand All @@ -38,8 +45,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Templates/StaticArray.cpp>
#include <Engine/Templates/StaticStackArray.cpp>

#pragma comment(lib, "winmm.lib")

// pointer to global sound library object
CSoundLibrary *_pSound = NULL;

Expand Down
4 changes: 3 additions & 1 deletion Sources/Engine/Sound/SoundLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,

// [Cecil] Windows-specific
#if SE1_WIN
#include <initguid.h>
#if !SE1_OLD_COMPILER
#include <initguid.h>
#endif
#include <Engine/Sound/DSound.h>
#include <Engine/Sound/EAX.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Templates/BSP_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class BSPNode : public DOUBLEplane3D { // split plane

public:
/* Defualt constructor (for arrays only). */
inline BSPNode(void) : bn_ulPlaneTag(-1), bn_pbnBack(nullptr), bn_pbnFront(nullptr), bn_bnlLocation(BNL_ILLEGAL) {};
inline BSPNode(void) : bn_ulPlaneTag(-1), bn_pbnBack(NULL), bn_pbnFront(NULL), bn_bnlLocation(BNL_ILLEGAL) {};
/* Constructor for a leaf node. */
inline BSPNode(enum BSPNodeLocation bnl);
/* Constructor for a branch node. */
Expand Down
14 changes: 7 additions & 7 deletions Sources/SeriousSam/SeriousSam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,14 +1201,14 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
ZeroMemory(&cif,sizeof(STARTUPINFOA));
PROCESS_INFORMATION pi;

strcpy_s(strCmd,"SeriousSam.exe");
strcpy_s(strParam," +game ");
strcat_s(strParam,_fnmModToLoad.FileName());
strcpy(strCmd,"SeriousSam.exe");
strcpy(strParam," +game ");
strcat(strParam,_fnmModToLoad.FileName());
if (_strModServerJoin!="") {
strcat_s(strParam," +connect ");
strcat_s(strParam,_strModServerJoin);
strcat_s(strParam," +quickjoin");
}
strcat(strParam," +connect ");
strcat(strParam,_strModServerJoin);
strcat(strParam," +quickjoin");
}

if (CreateProcessA(strCmd,strParam,NULL,NULL,FALSE,CREATE_DEFAULT_ERROR_MODE,NULL,NULL,&cif,&pi) == FALSE)
{
Expand Down
5 changes: 5 additions & 0 deletions Sources/ThirdParty/libvorbis/include/vorbis/vorbisfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){
#ifdef __MINGW32__
return fseeko64(f,off,whence);
#elif defined (_WIN32)
// [Cecil] Old compiler support
#if defined(_MSC_VER) && _MSC_VER < 1600
#define _fseeki64 fseek
#endif

return _fseeki64(f,off,whence);
#else
return fseek(f,off,whence);
Expand Down

0 comments on commit a4c6d06

Please sign in to comment.