Skip to content

Commit 8916aba

Browse files
pronvitlethosor
authored andcommitted
win64 fixes (partial)
cherry-picked from 2f734ae
1 parent 709111e commit 8916aba

9 files changed

Lines changed: 43 additions & 8 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ if(UNIX)
4848
endif()
4949

5050
if(WIN32)
51-
if((NOT MSVC) OR (NOT MSVC_VERSION STREQUAL 1600))
52-
message(SEND_ERROR "MSVC 2010 is required")
51+
if((NOT MSVC) OR (NOT MSVC_VERSION STREQUAL 1900))
52+
message(SEND_ERROR "MSVC 2015 is required")
5353
endif()
5454
endif()
5555

@@ -177,6 +177,7 @@ ELSEIF(MSVC)
177177
# for msvc, tell it to always use 8-byte pointers to member functions to avoid confusion
178178
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg /vmm /MP")
179179
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od")
180+
ADD_DEFINITIONS(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS)
180181
ENDIF()
181182

182183
# use shared libraries for protobuf

depends/lua/src/lobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static const char *l_str2d (const char *s, lua_Number *result) {
280280
endptr = l_str2dloc(s, result, mode); /* try to convert */
281281
if (endptr == NULL) { /* failed? may be a different locale */
282282
char buff[L_MAXLENNUM + 1];
283-
char *pdot = strchr(s, '.');
283+
char *pdot = (char*)strchr(s, '.');
284284
if (strlen(s) > L_MAXLENNUM || pdot == NULL)
285285
return NULL; /* string too long or no dot; fail */
286286
strcpy(buff, s); /* copy string to buffer */
@@ -394,7 +394,7 @@ static void pushstr (lua_State *L, const char *str, size_t l) {
394394

395395

396396
/*
397-
** this function handles only '%d', '%c', '%f', '%p', and '%s'
397+
** this function handles only '%d', '%c', '%f', '%p', and '%s'
398398
conventional formats, plus Lua-specific '%I' and '%U'
399399
*/
400400
const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {

depends/tthread/fast_mutex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ freely, subject to the following restrictions:
3939
// Check if we can support the assembly language level implementation (otherwise
4040
// revert to the system API)
4141
#if (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || \
42-
(defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))) || \
42+
(defined(_MSC_VER) && (defined(_M_IX86) /*|| defined(_M_X64)*/)) || \
4343
(defined(__GNUC__) && (defined(__ppc__)))
4444
#define _FAST_MUTEX_ASM_
4545
#else

library/DataStaticsFields.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ namespace df {
3030
NUMBER_IDENTITY_TRAITS(uint32_t);
3131
NUMBER_IDENTITY_TRAITS(int64_t);
3232
NUMBER_IDENTITY_TRAITS(uint64_t);
33+
#ifdef _WIN32
34+
NUMBER_IDENTITY_TRAITS(long);
35+
NUMBER_IDENTITY_TRAITS(unsigned long);
36+
#else
3337
NUMBER_IDENTITY_TRAITS(intptr_t);
3438
NUMBER_IDENTITY_TRAITS(uintptr_t);
39+
#endif
3540
NUMBER_IDENTITY_TRAITS(float);
3641
NUMBER_IDENTITY_TRAITS(double);
3742

library/Hooks-windows.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,22 @@ DFhackCExport uint32_t SDL_ThreadID(void)
726726
return _SDL_ThreadID();
727727
}
728728

729+
static char* (*_SDL_getenv)(const char *name) = 0;
730+
DFhackCExport char* SDL_getenv(const char *name)
731+
{
732+
if(!inited)
733+
FirstCall();
734+
return _SDL_getenv(name);
735+
}
736+
737+
static size_t (*_SDL_strlcat)(char *dst, const char *src, size_t maxlen) = 0;
738+
DFhackCExport size_t SDL_strlcat(char *dst, const char *src, size_t maxlen)
739+
{
740+
if(!inited)
741+
FirstCall();
742+
return _SDL_strlcat(dst, src, maxlen);
743+
}
744+
729745
// FIXME: this has to be thread-safe.
730746
bool FirstCall()
731747
{
@@ -813,6 +829,10 @@ bool FirstCall()
813829
_SDL_SemWait = (int (*)(void *))GetProcAddress(realSDLlib,"SDL_SemWait");
814830
_SDL_ThreadID = (uint32_t (*)(void))GetProcAddress(realSDLlib,"SDL_ThreadID");
815831

832+
// new in DF 0.43.05
833+
_SDL_getenv = (char* (*)(const char*))GetProcAddress(realSDLlib,"SDL_getenv");
834+
_SDL_strlcat = (size_t (*)(char*, const char*, size_t))GetProcAddress(realSDLlib,"SDL_strlcat");
835+
816836
_SDL_EnableUNICODE(1);
817837

818838
fprintf(stderr,"Initized HOOKS!\n");

library/VTableInterpose.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ using namespace DFHack;
8282
// multiple, but not virtual inheritance.
8383
struct MSVC_MPTR {
8484
void *method;
85-
intptr_t this_shift;
85+
uint32_t this_shift; // was intptr_t pre-0.43.05
8686
};
8787

8888
// Debug builds sometimes use additional thunks that
@@ -97,7 +97,11 @@ static uint32_t *follow_jmp(void *ptr)
9797
switch (*p)
9898
{
9999
case 0xE9: // jmp near rel32
100+
#ifdef DFHACK64
101+
p += 5 + *(int32_t*)(p+1) + 1;
102+
#else
100103
p += 5 + *(int32_t*)(p+1);
104+
#endif
101105
break;
102106
case 0xEB: // jmp short rel8
103107
p += 2 + *(int8_t*)(p+1);

library/include/DataIdentity.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,13 @@ namespace df
487487
NUMBER_IDENTITY_TRAITS(uint32_t);
488488
NUMBER_IDENTITY_TRAITS(int64_t);
489489
NUMBER_IDENTITY_TRAITS(uint64_t);
490+
#ifdef _WIN32
491+
NUMBER_IDENTITY_TRAITS(long);
492+
NUMBER_IDENTITY_TRAITS(unsigned long);
493+
#else
490494
NUMBER_IDENTITY_TRAITS(intptr_t);
491495
NUMBER_IDENTITY_TRAITS(uintptr_t);
496+
#endif
492497
NUMBER_IDENTITY_TRAITS(float);
493498
NUMBER_IDENTITY_TRAITS(double);
494499

library/include/VersionInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace DFHack
5353
std::map <std::string, uintptr_t> Addresses;
5454
std::map <std::string, uintptr_t> VTables;
5555
uintptr_t base;
56-
int rebase_delta;
56+
uintptr_t rebase_delta;
5757
std::string version;
5858
OSType OS;
5959
public:

plugins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ if (BUILD_SUPPORTED)
9191
DFHACK_PLUGIN(deramp deramp.cpp)
9292
DFHACK_PLUGIN(dig dig.cpp)
9393
DFHACK_PLUGIN(digFlood digFlood.cpp)
94-
add_subdirectory(diggingInvaders)
94+
# add_subdirectory(diggingInvaders)
9595
DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp LINK_LIBRARIES lua)
9696
DFHACK_PLUGIN(embark-tools embark-tools.cpp)
9797
DFHACK_PLUGIN(eventful eventful.cpp LINK_LIBRARIES lua)

0 commit comments

Comments
 (0)