Skip to content

Commit

Permalink
Builds for x64 on Visual Studio 2010. Still need to go through, evalu…
Browse files Browse the repository at this point in the history
…ate and fix all the 64-bit truncation warnings.
  • Loading branch information
penenin committed Aug 22, 2012
1 parent 458a14f commit 3eecc1d
Show file tree
Hide file tree
Showing 27 changed files with 190 additions and 49 deletions.
8 changes: 4 additions & 4 deletions NOLF2/ClientShellDLL/ClientShellShared/GameClientShell.cpp
Expand Up @@ -4603,9 +4603,9 @@ BOOL HookWindow()

// Get the window procedure
#ifdef STRICT
g_pfnMainWndProc = (WNDPROC)GetWindowLong(g_hMainWnd,GWL_WNDPROC);
g_pfnMainWndProc = (WNDPROC)GetWindowLongPtr(g_hMainWnd,GWLP_WNDPROC);
#else
g_pfnMainWndProc = (FARPROC)GetWindowLong(g_hMainWnd,GWL_WNDPROC);
g_pfnMainWndProc = (FARPROC)GetWindowLongPtr(g_hMainWnd,GWLP_WNDPROC);
#endif

if(!g_pfnMainWndProc)
Expand All @@ -4615,7 +4615,7 @@ BOOL HookWindow()
}

// Replace it with ours
if(!SetWindowLong(g_hMainWnd,GWL_WNDPROC,(LONG)HookedWindowProc))
if(!SetWindowLongPtr(g_hMainWnd,GWLP_WNDPROC, (LONG_PTR)HookedWindowProc))
{
TRACE("HookWindow - ERROR - could not set the window procedure!\n");
return FALSE;
Expand All @@ -4636,7 +4636,7 @@ void UnhookWindow()
{
if(g_pfnMainWndProc && g_hMainWnd)
{
SetWindowLong(g_hMainWnd, GWL_WNDPROC, (LONG)g_pfnMainWndProc);
SetWindowLongPtr(g_hMainWnd, GWLP_WNDPROC, (LONG_PTR)g_pfnMainWndProc);
g_hMainWnd = 0;
g_pfnMainWndProc = NULL;
}
Expand Down
5 changes: 2 additions & 3 deletions NOLF2/ClientShellDLL/ClientShellShared/PlayerMgr.cpp
Expand Up @@ -4865,8 +4865,7 @@ void CPlayerMgr::UpdateSoundFilters(uint8 nSoundFilterId)
{
#ifndef USE_EAX20_HARDWARE_FILTERS
return;
#endif // USE_EAX20_HARDWARE_FILTERS

#else
if (g_vtUseSoundFilters.GetFloat())
{
if ( m_nSoundFilterId != nSoundFilterId )
Expand Down Expand Up @@ -4931,7 +4930,7 @@ void CPlayerMgr::UpdateSoundFilters(uint8 nSoundFilterId)

}
}

#endif // USE_EAX20_HARDWARE_FILTERS
}


Expand Down
2 changes: 1 addition & 1 deletion NOLF2/ObjectDLL/ObjectShared/KeyFramer.cpp
Expand Up @@ -2509,7 +2509,7 @@ void KeyFramer::Load(ILTMessage_Read *pMsg, uint32 dwLoadFlags)
HOBJECT* hObjectArray = debug_newa(HOBJECT, nNumInList);

HOBJECT hObj = LTNULL;
for (int i=0; i < nNumInList; i++)
for (i=0; i < nNumInList; i++)
{
LOAD_HOBJECT(hObj);
if (hObj)
Expand Down
12 changes: 6 additions & 6 deletions NOLF2/Shared/UberAssert.h
Expand Up @@ -24,7 +24,7 @@
if ( !(exp) ) { \
if( UberAssert( __LINE__, __FILE__, #exp, description )) \
{ \
_asm { int 3 } \
__debugbreak(); \
} \
}

Expand All @@ -34,35 +34,35 @@
if ( !(exp) ) { \
if( UberAssert( __LINE__, __FILE__, #exp, desc, d1 )) \
{ \
_asm { int 3 } \
__debugbreak(); \
} \
}
#define UBER_ASSERT2( exp, desc, d1, d2 ) \
if ( !(exp) ) { \
if( UberAssert( __LINE__, __FILE__, #exp, desc, d1, d2 )) \
{ \
_asm { int 3 } \
__debugbreak(); \
} \
}
#define UBER_ASSERT3( exp, desc, d1, d2, d3 ) \
if ( !(exp) ) { \
if( UberAssert( __LINE__, __FILE__, #exp, desc, d1, d2, d3 )) \
{ \
_asm { int 3 } \
__debugbreak(); \
} \
}
#define UBER_ASSERT4( exp, desc, d1, d2, d3, d4 ) \
if ( !(exp) ) { \
if( UberAssert( __LINE__, __FILE__, #exp, desc, d1, d2, d3, d4 )) \
{ \
_asm { int 3 } \
__debugbreak(); \
} \
}
#define UBER_ASSERT5( exp, desc, d1, d2, d3, d4, d5 ) \
if ( !(exp) ) { \
if( UberAssert( __LINE__, __FILE__, #exp, desc, d1, d2, d3, d4, d5 )) \
{ \
_asm { int 3 } \
__debugbreak(); \
} \
}

Expand Down
20 changes: 19 additions & 1 deletion NOLF2/Shared/stacktrace.cpp
Expand Up @@ -37,7 +37,11 @@ static CSymbolEngine g_cSym ;
// If TRUE, the symbol engine has been initialized.
static BOOL g_bSymIsInit = FALSE ;

#ifdef _M_IX86
static DWORD __stdcall GetModBase ( HANDLE hProcess , DWORD dwAddr )
#else
static DWORD64 __stdcall GetModBase ( HANDLE hProcess , DWORD64 dwAddr )
#endif
{
// Check in the symbol engine first.
IMAGEHLP_MODULE stIHM ;
Expand Down Expand Up @@ -134,7 +138,11 @@ static DWORD ConvertAddress ( DWORD dwAddr , LPTSTR szOutBuff )
}

// Get the function.
#ifdef _M_IX86
DWORD dwDisp ;
#else
DWORD64 dwDisp ;
#endif
if ( 0 != g_cSym.SymGetSymFromAddr ( dwAddr , &dwDisp , pIHS ) )
{
pCurrPos += wsprintf ( pCurrPos , _T ( "%s() " ) , pIHS->Name);
Expand All @@ -147,7 +155,7 @@ static DWORD ConvertAddress ( DWORD dwAddr , LPTSTR szOutBuff )
stIHL.SizeOfStruct = sizeof ( IMAGEHLP_LINE ) ;

if ( 0 != g_cSym.SymGetLineFromAddr ( dwAddr ,
&dwDisp ,
(PDWORD)&dwDisp ,
&stIHL ) )
{
// Put this on the next line and indented a bit.
Expand Down Expand Up @@ -223,11 +231,21 @@ void DoStackTrace ( LPTSTR szString ,

stFrame.AddrPC.Mode = AddrModeFlat ;

#ifdef _M_IX86
dwMachine = IMAGE_FILE_MACHINE_I386 ;
stFrame.AddrPC.Offset = stCtx.Eip ;
stFrame.AddrStack.Offset = stCtx.Esp ;
#else
dwMachine = IMAGE_FILE_MACHINE_AMD64 ;
stFrame.AddrPC.Offset = stCtx.Rip ;
stFrame.AddrStack.Offset = stCtx.Rsp ;
#endif
stFrame.AddrStack.Mode = AddrModeFlat ;
#ifdef _M_IX86
stFrame.AddrFrame.Offset = stCtx.Ebp ;
#else
stFrame.AddrFrame.Offset = stCtx.Rbp ;
#endif
stFrame.AddrFrame.Mode = AddrModeFlat ;

// Loop for the first 512 stack elements.
Expand Down
28 changes: 27 additions & 1 deletion NOLF2/Shared/stacktrace.h
Expand Up @@ -59,6 +59,10 @@ DO_NOT_WORK_AROUND_SRCLINE_BUG - Define this to NOT work around the
lookups fail after the first lookup.
----------------------------------------------------------------------*/

#ifdef _M_X64
#define _IMAGEHLP64
#endif

#include "imagehlp.h"
#include <tchar.h>

Expand Down Expand Up @@ -213,12 +217,22 @@ struct CImageHlp_Line : public IMAGEHLP_LINE
} ;

// Typedefs for the new source and line functions.
#ifdef _M_IX86
typedef
BOOL (__stdcall *PFNSYMGETLINEFROMADDR)
( IN HANDLE hProcess ,
IN DWORD dwAddr ,
OUT PDWORD pdwDisplacement ,
OUT PIMAGEHLP_LINE Line ) ;
#else
typedef
BOOL (__stdcall *PFNSYMGETLINEFROMADDR)
( IN HANDLE hProcess ,
IN DWORD64 dwAddr ,
OUT PDWORD pdwDisplacement ,
OUT PIMAGEHLP_LINE64 Line ) ;
#endif

typedef
BOOL (__stdcall *PFNSYMGETLINEFROMNAME)
( IN HANDLE hProcess ,
Expand Down Expand Up @@ -472,9 +486,15 @@ public :
UserContext ) ) ;
}

#ifdef _M_IX86
BOOL SymGetSymFromAddr ( IN DWORD dwAddr ,
OUT PDWORD pdwDisplacement ,
OUT PIMAGEHLP_SYMBOL Symbol )
#else
BOOL SymGetSymFromAddr ( IN DWORD dwAddr ,
OUT PDWORD64 pdwDisplacement ,
OUT PIMAGEHLP_SYMBOL Symbol )
#endif
{
return ( ::SymGetSymFromAddr ( m_hProcess ,
dwAddr ,
Expand Down Expand Up @@ -659,9 +679,15 @@ public :
return ( :: SymSetSearchPath ( m_hProcess , SearchPath ) ) ;
}

#ifdef _M_IX86
BOOL SymRegisterCallback ( IN PSYMBOL_REGISTERED_CALLBACK
CallbackFunction,
IN PVOID UserContext )
IN PVOID UserContext )
#else
BOOL SymRegisterCallback ( IN PSYMBOL_REGISTERED_CALLBACK
CallbackFunction,
IN ULONG64 UserContext )
#endif
{
return ( ::SymRegisterCallback ( m_hProcess ,
CallbackFunction ,
Expand Down
2 changes: 1 addition & 1 deletion libs/WONAPI/WONMisc/MediaMetrix.cpp
Expand Up @@ -17,7 +17,7 @@ void CreateMediaMetrixEditControl(HWND theParent)
0, 0, 100, 50, // arbitrary size
theParent, // parent window
(HMENU) NULL, // edit control ID
(HINSTANCE) GetWindowLong(theParent, GWL_HINSTANCE),
(HINSTANCE) GetWindowLongPtr(theParent, GWLP_HINSTANCE),
NULL); // pointer not needed
}

Expand Down
4 changes: 2 additions & 2 deletions libs/ltmem/ltmemtrack.cpp
Expand Up @@ -174,8 +174,8 @@ void LTMemTrackAllocStart(unsigned int nLineNum, const char* sFileName, unsigned
g_curAllocInfo.m_sFileName[0] = '\0';
else
{
uint32 nStrLen = strlen(sFileName);
uint32 nOffset = 0;
size_t nStrLen = strlen(sFileName);
size_t nOffset = 0;
if (nStrLen >= CMEMTRACKFILENAMESIZE) nOffset = nStrLen - CMEMTRACKFILENAMESIZE + 1;
strncpy(g_curAllocInfo.m_sFileName, sFileName + nOffset, CMEMTRACKFILENAMESIZE);
g_curAllocInfo.m_sFileName[CMEMTRACKFILENAMESIZE-1] = '\0';
Expand Down
8 changes: 6 additions & 2 deletions runtime/client/CMakeLists.txt
Expand Up @@ -2,8 +2,12 @@ cmake_minimum_required (VERSION 2.8)
project (EXE_Lithtech)

add_definitions(-DDE_LOCAL_SERVERBIND -DDE_CLIENT_COMPILE -DDSNDMGR_NO_MFC -DDIRECTENGINE_COMPILE -DMODEL_SUPPORT_ABC)
link_directories("C:\\Program Files (x86)\\Microsoft DirectX SDK (February 2006)\\Lib\\x86")

if(CMAKE_CL_64)
link_directories("C:\\Program Files (x86)\\Microsoft DirectX SDK (February 2006)\\Lib\\x64")
else(CMAKE_CL_64)
link_directories("C:\\Program Files (x86)\\Microsoft DirectX SDK (February 2006)\\Lib\\x86")
endif(CMAKE_CL_64)

add_executable (EXE_Lithtech WIN32
../controlfilemgr/controlfilemgr.cpp
src/client_filemgr.cpp
Expand Down
4 changes: 2 additions & 2 deletions runtime/client/src/sys/win/customfontfilemgr.cpp
Expand Up @@ -22,8 +22,8 @@ define_holder(IClientFileMgr, client_filemgr);
static void BroadcastFontChangeMessage()
{
static const uint32 knTimeoutMS = 30;
DWORD nResult;
SendMessageTimeout(HWND_BROADCAST, WM_FONTCHANGE, (WPARAM)0, (LPARAM)0, SMTO_ABORTIFHUNG | SMTO_BLOCK, knTimeoutMS, &nResult);
PDWORD_PTR nResult;
SendMessageTimeout(HWND_BROADCAST, WM_FONTCHANGE, (WPARAM)0, (LPARAM)0, SMTO_ABORTIFHUNG | SMTO_BLOCK, knTimeoutMS, nResult);
}

//-------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions runtime/kernel/mem/src/de_memory.h
Expand Up @@ -24,8 +24,8 @@ uint32 dm_GetNumAllocations();
extern void* operator new(size_t size, void *ptr, char z);

// C dalloc/dfree functions.
void* dalloc(uint32 size);
void* dalloc_z(uint32 size); // Allocate and zero-init.
void* dalloc(size_t size);
void* dalloc_z(size_t size); // Allocate and zero-init.

void dfree(void *ptr);

Expand Down
4 changes: 2 additions & 2 deletions runtime/kernel/mem/src/sys/win/de_memory.cpp
Expand Up @@ -117,7 +117,7 @@ uint32 dm_GetNumAllocations()
return g_nAllocations;
}

void* dalloc(uint32 size)
void* dalloc(size_t size)
{
//[DLK] Removed to avoid allocation errors with D3DXEffectCompiler
/*
Expand Down Expand Up @@ -166,7 +166,7 @@ void* dalloc(uint32 size)
}


void* dalloc_z(uint32 size)
void* dalloc_z(size_t size)
{
void *ret;

Expand Down
2 changes: 1 addition & 1 deletion runtime/kernel/src/sys/win/client.cpp
Expand Up @@ -173,7 +173,7 @@ static bool StartClient(ClientGlob *pGlob)
}


static long WINAPI MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
static LRESULT WINAPI MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
ClientGlob *pGlob;
char messageString[256], fileName[_MAX_PATH + 1];
int i;
Expand Down
19 changes: 18 additions & 1 deletion runtime/render_a/src/sys/d3d/FixedPoint.h
Expand Up @@ -5,15 +5,32 @@
// The original code was written by Chris Hecker (checker@netcom.com). Additional
// modifications by Scott H. Pultz

#ifndef _M_IX86
#ifdef _MSC_VER
// From http://opensource.apple.com/source/JavaScriptCore/JavaScriptCore-621.1/wtf/MathExtras.h
inline float roundf(float num)
{
float integer = ceilf(num);
if (num > 0)
return integer - num > 0.5f ? integer - 1.0f : integer;
return integer - num >= 0.5f ? integer - 1.0f : integer;
}
inline long lroundf(float num) { return static_cast<long>(roundf(num)); }
#endif
#endif

inline int RoundFloatToInt(float f)
{
int nResult;

#ifdef _M_IX86
__asm
{
fld f
fistp nResult
}
#else
nResult = lroundf(f);
#endif
return nResult;
}

Expand Down
2 changes: 2 additions & 0 deletions runtime/render_a/src/sys/d3d/common_draw.h
Expand Up @@ -77,13 +77,15 @@ void d3d_IncrementFrameCode(RenderContext *pContext);

inline void d3d_SetFPState()
{
#ifdef _M_IX86
short control;

_asm {
fstcw control // Get FPU control word
and control, 0xfcff // PC field = 00 for single precision
fldcw control
}
#endif
}

#endif // __COMMON_DRAW_H__
Expand Down
4 changes: 2 additions & 2 deletions runtime/render_a/src/sys/d3d/common_stuff.h
Expand Up @@ -26,8 +26,8 @@ extern RenderStruct* g_pStruct;
extern uint32 g_ScreenWidth, g_ScreenHeight;
extern HWND g_hWnd;

void* dalloc(unsigned long size);
void* dalloc_z(unsigned long size);
void* dalloc(size_t size);
void* dalloc_z(size_t size);
void dfree(void *ptr);
void AddDebugMessage(uint32 debugLevel, const char *pMsg, ...);
void d3d_CreateConsoleVariables();
Expand Down
2 changes: 1 addition & 1 deletion runtime/shared/src/concommand.h
Expand Up @@ -102,7 +102,7 @@ struct ConsoleState
void (*ConsolePrint)(const char *pMsg, ...);

// Function to allocate/free memory.
void* (*Alloc)(uint32 size);
void* (*Alloc)(size_t size);
void (*Free)(void *ptr);

// Called when a variable is added.
Expand Down
2 changes: 1 addition & 1 deletion runtime/shared/src/dhashtable.cpp
Expand Up @@ -2,7 +2,7 @@
#include "bdefs.h"
#include "dhashtable.h"

extern void* dalloc(uint32 size);
extern void* dalloc(size_t size);
extern void dfree(void *ptr);


Expand Down

0 comments on commit 3eecc1d

Please sign in to comment.