PDA

View Full Version : Can't run libcod



PureTryOut
17th April 2014, 11:17
Hi all,

First of all, i'm knew to all of this so please don't get mad at me ;)
Using Ubuntu 14.04 x64 I can not get libcod for Cod4 to compile/run.

Tried using the precompiled libraries:
Without using LD_LIBRARY_PATH it would not load libcod, it would just start without it.
Using LD_LIBRARY_PATH (and just guessing which directory I had to define, because I do not understand this bit and it isn't really explained well), it crashes with SEGMENTATION FAULT.

Then I tried compiling it myself to see if it fixes things.
Following the basic tutorial on Github (https://github.com/kungfooman/libcod) I got a lot of errors.
I have all of the requirements so that is not the problem.

./doit.sh base

##### COMPILE GSC_ASTAR.CPP #####
##### COMPILE GSC_MYSQL.CPP #####
gsc_mysql.cpp: In function ‘void gsc_mysql_free_result()’:
gsc_mysql.cpp:529:15: warning: NULL used in arithmetic [-Wpointer-arith]
if(result == NULL)
^
gsc_mysql.cpp: In function ‘int gsc_mysql_test_0()’:
gsc_mysql.cpp:880:55: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘my_ulonglong {aka long long unsigned int}’ [-Wformat=]
printf("affected rows: %d\n", mysql_affected_rows(my));
^
gsc_mysql.cpp:892:54: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘my_ulonglong {aka long long unsigned int}’ [-Wformat=]
printf("query-num rows: %d\n", mysql_num_rows(query));
^
gsc_mysql.cpp: In function ‘int gsc_mysql_test_1()’:
gsc_mysql.cpp:972:47: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("stmt->stmt_id = %d\n", stmt->stmt_id);
^
gsc_mysql.cpp:973:59: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("stmt->prefetch_rows = %d\n", stmt->prefetch_rows);
^
gsc_mysql.cpp:993:47: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("stmt->stmt_id = %d\n", stmt->stmt_id);
^
gsc_mysql.cpp:994:59: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("stmt->prefetch_rows = %d\n", stmt->prefetch_rows); // i dont know
^
gsc_mysql.cpp:1146:55: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘my_ulonglong {aka long long unsigned int}’ [-Wformat=]
printf("affected rows: %d\n", mysql_affected_rows(my));
^
gsc_mysql.cpp:1158:54: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘my_ulonglong {aka long long unsigned int}’ [-Wformat=]
printf("query-num rows: %d\n", mysql_num_rows(query));
^
##### COMPILE SERVER.CPP #####
cc1: warning: command line option ‘-std=gnu++11’ is valid for C++/ObjC++ but not for C [enabled by default]
server.c: In function ‘mythread’:
server.c:244:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘void **’ [-Wformat=]
sscanf(arg_from, "%x", &from); // prepare from-pointer
^
server.c:311:7: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘float **’ [-Wformat=]
sscanf(address, "%x", &ptr_float);
^
server.c:328:7: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘int **’ [-Wformat=]
sscanf(address, "%x", &ptr);
^
server.c:345:7: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘unsigned char **’ [-Wformat=]
sscanf(address, "%x", &ptr);
^
server.c:387:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘char **’ [-Wformat=]
sscanf(arg_from, "%x", &from);
^
server.c:388:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘char **’ [-Wformat=]
sscanf(arg_to, "%x", &to);
^
server.c:433:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘unsigned int **’ [-Wformat=]
sscanf(arg_address, "%x", &address);
^
server.c:460:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘void **’ [-Wformat=]
sscanf(arg_addr, "%x", &addr);
^
server.c: In function ‘cdecl_injected_shell’:
server.c:718:5: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘unsigned int **’ [-Wformat=]
sscanf(buffer, "%x", &address);
^
##### COMPILE GSC_MEMORY.CPP #####
##### COMPILE cracking.CPP #####
##### COMPILE GSC_MATH.CPP #####


./doit.sh cod4_1_7

##### COMPILE cod4_1_7 LIBCOD.CPP #####
In file included from gsc.hpp:47:0,
from libcod.cpp:8:
functions.hpp:29:3: warning: #warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL; [-Wcpp]
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
^
functions.hpp:101:3: warning: #warning static Cvar_VariableValue_t CvarVariableValue = NULL; [-Wcpp]
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
^
functions.hpp:113:3: warning: #warning static FS_ReadFile_t FS_ReadFile = NULL; [-Wcpp]
#warning static FS_ReadFile_t FS_ReadFile = NULL;
^
functions.hpp:126:3: warning: #warning static FS_LoadDir_t FS_LoadDir = NULL; [-Wcpp]
#warning static FS_LoadDir_t FS_LoadDir = NULL;
^
functions.hpp:137:3: warning: #warning static int hook_findMap_call = NULL; [-Wcpp]
#warning static int hook_findMap_call = NULL;
^
functions.hpp:148:3: warning: #warning static int hook_AuthorizeState_call = NULL; [-Wcpp]
#warning static int hook_AuthorizeState_call = NULL;
^
libcod.cpp:562:3: warning: #warning gametype_scripts_t gametype_scripts = (gametype_scripts_t)NULL; [-Wcpp]
#warning gametype_scripts_t gametype_scripts = (gametype_scripts_t)NULL;
^
libcod.cpp:574:3: warning: #warning codscript_load_function_t codscript_load_function = (codscript_load_function_t)NULL; [-Wcpp]
#warning codscript_load_function_t codscript_load_function = (codscript_load_function_t)NULL;
^
libcod.cpp:638:4: warning: #warning short ret = codscript_call_callback_entity(NULL, codecallback_playercommand, 1); [-Wcpp]
#warning short ret = codscript_call_callback_entity(NULL, codecallback_playercommand, 1);
^
libcod.cpp:1800:5: warning: #warning int *addressToDownloadPointer = NULL; [-Wcpp]
#warning int *addressToDownloadPointer = NULL;
^
libcod.cpp: In function ‘void printStackTrace()’:
libcod.cpp:212:27: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘void*’ [-Wformat=]
printf("%.8x ", array[i]);
^
libcod.cpp: In function ‘int hook_ClientCommand(int)’:
libcod.cpp:639:81: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
short ret = codscript_call_callback_entity(NULL, codecallback_playercommand, 1);
^
libcod.cpp: In function ‘ssize_t hook_recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*)’:
libcod.cpp:796:4: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘void*’ [-Wformat=]
);
^
libcod.cpp:797:38: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘void*’ [-Wformat=]
printf(">>>>>>>%s<<<<<<<<<\n", buf);
^
libcod.cpp: In function ‘pthread_t hook_pthread_self()’:
libcod.cpp:945:41: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
printf(" pthread_self() = %.8p\n", ret);
^
libcod.cpp:945:41: warning: format ‘%p’ expects argument of type ‘void*’, but argument 2 has type ‘int’ [-Wformat=]
libcod.cpp: In function ‘int hook_pthread_mutex_lock(pthread_mutex_t*)’:
libcod.cpp:959:56: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
printf(" pthread_mutex_lock(%.8p) = %d\n", mutex, ret);
^
libcod.cpp: In function ‘int hook_pthread_mutex_unlock(pthread_mutex_t*)’:
libcod.cpp:973:56: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
printf("pthread_mutex_unlock(%.8p) = %d\n", mutex, ret);
^
libcod.cpp: In function ‘int SV_AddServerCommand(int*, ...)’:
libcod.cpp:1280:43: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘int*’ [-Wformat=]
printf("client: %s, tmp=%s\n", client, "");
^
libcod.cpp: In function ‘void SV_SendServerCommand(int*, int, const char*, ...)’:
libcod.cpp:1459:66: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘int*’ [-Wformat=]
printf("client=%08x bla=%08p message=%s\n", client, bla, message);
^
libcod.cpp:1459:66: warning: '0' flag used with ‘%p’ gnu_printf format [-Wformat=]
libcod.cpp:1459:66: warning: format ‘%p’ expects argument of type ‘void*’, but argument 3 has type ‘int’ [-Wformat=]
libcod.cpp: In function ‘int BG_AnimationIndexForString(char*)’:
libcod.cpp:1553:65: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
if (debug) printf("tmp:%.8p , %.8p", (tmp + 0), INT(tmp + 4));
^
libcod.cpp:1553:65: warning: format ‘%p’ expects argument of type ‘void*’, but argument 2 has type ‘int’ [-Wformat=]
libcod.cpp:1553:65: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
libcod.cpp:1553:65: warning: format ‘%p’ expects argument of type ‘void*’, but argument 3 has type ‘int’ [-Wformat=]
libcod.cpp: In function ‘int BG_PlayAnimName(int, const char*, int, int, int, int)’:
libcod.cpp:1632:2: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
);
^
libcod.cpp:1632:2: warning: format ‘%p’ expects argument of type ‘void*’, but argument 2 has type ‘int’ [-Wformat=]
libcod.cpp:1632:2: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
libcod.cpp:1632:2: warning: format ‘%p’ expects argument of type ‘void*’, but argument 4 has type ‘int’ [-Wformat=]
libcod.cpp: In function ‘int BG_PlayAnim(int, int, int, int, int, int, int)’:
libcod.cpp:1641:3: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
);
^
libcod.cpp:1641:3: warning: format ‘%p’ expects argument of type ‘void*’, but argument 2 has type ‘int’ [-Wformat=]
libcod.cpp:1641:3: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
libcod.cpp:1641:3: warning: format ‘%p’ expects argument of type ‘void*’, but argument 4 has type ‘int’ [-Wformat=]
libcod.cpp:1641:3: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
libcod.cpp:1641:3: warning: format ‘%p’ expects argument of type ‘void*’, but argument 5 has type ‘int’ [-Wformat=]
libcod.cpp:1641:3: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
libcod.cpp:1641:3: warning: format ‘%p’ expects argument of type ‘void*’, but argument 6 has type ‘int’ [-Wformat=]
libcod.cpp:1641:3: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
libcod.cpp:1641:3: warning: format ‘%p’ expects argument of type ‘void*’, but argument 7 has type ‘int’ [-Wformat=]
libcod.cpp:1641:3: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
libcod.cpp:1641:3: warning: format ‘%p’ expects argument of type ‘void*’, but argument 8 has type ‘int’ [-Wformat=]
libcod.cpp: In function ‘void MSG_WriteBigString(int*, char*)’:
libcod.cpp:1665:74: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
printf("i=%d size_all=%d len=%d MSG=%.8p %s\n", i, size_all, len, MSG, s);
^
##### COMPILE cod4_1_7 GSC.CPP #####
In file included from gsc.hpp:47:0,
from gsc.cpp:1:
functions.hpp:29:3: warning: #warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL; [-Wcpp]
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
^
functions.hpp:101:3: warning: #warning static Cvar_VariableValue_t CvarVariableValue = NULL; [-Wcpp]
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
^
functions.hpp:113:3: warning: #warning static FS_ReadFile_t FS_ReadFile = NULL; [-Wcpp]
#warning static FS_ReadFile_t FS_ReadFile = NULL;
^
functions.hpp:126:3: warning: #warning static FS_LoadDir_t FS_LoadDir = NULL; [-Wcpp]
#warning static FS_LoadDir_t FS_LoadDir = NULL;
^
functions.hpp:137:3: warning: #warning static int hook_findMap_call = NULL; [-Wcpp]
#warning static int hook_findMap_call = NULL;
^
functions.hpp:148:3: warning: #warning static int hook_AuthorizeState_call = NULL; [-Wcpp]
#warning static int hook_AuthorizeState_call = NULL;
^
gsc.cpp:18:3: warning: #warning Scr_GetFunction_t Scr_GetFunction = (Scr_GetFunction_t)NULL; [-Wcpp]
#warning Scr_GetFunction_t Scr_GetFunction = (Scr_GetFunction_t)NULL;
^
gsc.cpp:19:3: warning: #warning Scr_GetMethod_t Scr_GetMethod = (Scr_GetMethod_t)NULL; [-Wcpp]
#warning Scr_GetMethod_t Scr_GetMethod = (Scr_GetMethod_t)NULL;
^
gsc.cpp: In function ‘void gsc_player_printf(int)’:
gsc.cpp:208:25: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
printf("id: %.8p\n", id);
^
gsc.cpp:208:25: warning: format ‘%p’ expects argument of type ‘void*’, but argument 2 has type ‘int’ [-Wformat=]
gsc.cpp: In function ‘int cdecl_injected_closer()’:
gsc.cpp:1628:83: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
printf("next:%.8p pack:%.8p dir:%.8p", search->next, search->pack, search->dir);
^
gsc.cpp:1628:83: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
gsc.cpp:1628:83: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
gsc.cpp:1741:2: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
);
^
gsc.cpp:1741:2: warning: format ‘%p’ expects argument of type ‘void*’, but argument 2 has type ‘int’ [-Wformat=]
gsc.cpp:1741:2: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
gsc.cpp:1741:2: warning: format ‘%p’ expects argument of type ‘void*’, but argument 3 has type ‘int’ [-Wformat=]
gsc.cpp:1741:2: warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
gsc.cpp:1741:2: warning: format ‘%p’ expects argument of type ‘void*’, but argument 4 has type ‘int’ [-Wformat=]
##### COMPILE cod4_1_7 GSC_PLAYER.CPP #####
In file included from gsc.hpp:47:0,
from gsc_player.hpp:14,
from gsc_player.cpp:1:
functions.hpp:29:3: warning: #warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL; [-Wcpp]
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
^
functions.hpp:101:3: warning: #warning static Cvar_VariableValue_t CvarVariableValue = NULL; [-Wcpp]
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
^
functions.hpp:113:3: warning: #warning static FS_ReadFile_t FS_ReadFile = NULL; [-Wcpp]
#warning static FS_ReadFile_t FS_ReadFile = NULL;
^
functions.hpp:126:3: warning: #warning static FS_LoadDir_t FS_LoadDir = NULL; [-Wcpp]
#warning static FS_LoadDir_t FS_LoadDir = NULL;
^
functions.hpp:137:3: warning: #warning static int hook_findMap_call = NULL; [-Wcpp]
#warning static int hook_findMap_call = NULL;
^
functions.hpp:148:3: warning: #warning static int hook_AuthorizeState_call = NULL; [-Wcpp]
#warning static int hook_AuthorizeState_call = NULL;
^
##### COMPILE cod4_1_7 GSC_UTILS.CPP #####
In file included from gsc.hpp:47:0,
from gsc_utils.hpp:14,
from gsc_utils.cpp:1:
functions.hpp:29:3: warning: #warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL; [-Wcpp]
#warning static Cmd_Argv_t Cmd_Argv = (Cmd_Argv_t)NULL;
^
functions.hpp:101:3: warning: #warning static Cvar_VariableValue_t CvarVariableValue = NULL; [-Wcpp]
#warning static Cvar_VariableValue_t CvarVariableValue = NULL;
^
functions.hpp:113:3: warning: #warning static FS_ReadFile_t FS_ReadFile = NULL; [-Wcpp]
#warning static FS_ReadFile_t FS_ReadFile = NULL;
^
functions.hpp:126:3: warning: #warning static FS_LoadDir_t FS_LoadDir = NULL; [-Wcpp]
#warning static FS_LoadDir_t FS_LoadDir = NULL;
^
functions.hpp:137:3: warning: #warning static int hook_findMap_call = NULL; [-Wcpp]
#warning static int hook_findMap_call = NULL;
^
functions.hpp:148:3: warning: #warning static int hook_AuthorizeState_call = NULL; [-Wcpp]
#warning static int hook_AuthorizeState_call = NULL;
^
gsc_utils.cpp: In function ‘void gsc_utils_rundll()’:
gsc_utils.cpp:310:63: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘void*’ [-Wformat=]
printf("dlopen(\"%s\") returned: %.8x\n", arg_library, handle);
^
gsc_utils.cpp:321:65: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘void (*)()’ [-Wformat=]
printf("function-name=%s -> address=%.8x\n", arg_function, func);
^
##### LINK libcod4_1_7.so #####

./doit.sh wrapper

##### WRAPPER: COMPILE wrapper_libcod2.cpp #####
cp: cannot stat ‘wrapper_libcod2.cpp’: No such file or directory
gcc: error: a.cpp: No such file or directory
gcc: fatal error: no input files
compilation terminated.
##### WRAPPER: LINK wrapper_libcod2.so #####
gcc: error: wrapper_libcod2.opp: No such file or directory
gcc: fatal error: no input files
compilation terminated.
cp: cannot stat ‘wrapper_libcod2.so’: No such file or directory





Can someone give me a detailed explanation of what I have to do to get this to run?
I've seen people pointing LD_LIBRARY_PATH to a mysql directory, but I have no such thing.
I only have libcod4_1_7.so and that's it. I hoped compiling it myself would give me more files and a clue what to do...

kung foo man
17th April 2014, 16:38
The actual crash happens here:



#if COD_VERSION == COD2_1_0
int * addressToDownloadPointer = (int *)0x0815D584;
#elif COD_VERSION == COD2_1_2
int * addressToDownloadPointer = (int *)0x0817C9E4;
#elif COD_VERSION == COD2_1_3
int * addressToDownloadPointer = (int *)0x0817DA04;
#else
#warning int *addressToDownloadPointer = NULL;
int *addressToDownloadPointer = NULL;
#endif

printf("> [INFO] value of download=%.8x\n", *addressToDownloadPointer);
SV_BeginDownload_f = (SV_BeginDownload_f_t)*addressToDownloadPointer;
*addressToDownloadPointer = (int)hook_SV_BeginDownload_f;


It needs an #if-case like:



#if COD_VERSION == COD2_1_0 || COD_VERSION == COD2_1_2 || COD_VERSION == COD2_1_3
printf("> [INFO] value of download=%.8x\n", *addressToDownloadPointer);
SV_BeginDownload_f = (SV_BeginDownload_f_t)*addressToDownloadPointer;
*addressToDownloadPointer = (int)hook_SV_BeginDownload_f;
#endif


I guess nobody saw it because most people just work with CoD2 here.

In past libcod got restructured alot and since CoD4 was out of view, nobody cared about it. Hence CoD4 would require the closer()-hack, though that "dirt" got cleaned up.

So most important to support CoD4 again is this:



#if COD_VERSION == COD2_1_0
Scr_GetFunction_t Scr_GetFunction = (Scr_GetFunction_t)0x8115824;
Scr_GetMethod_t Scr_GetMethod = (Scr_GetMethod_t)0x811595C;
#elif COD_VERSION == COD2_1_2
Scr_GetFunction_t Scr_GetFunction = (Scr_GetFunction_t)0x8117B56;
Scr_GetMethod_t Scr_GetMethod = (Scr_GetMethod_t)0x8117C8E;
#elif COD_VERSION == COD2_1_3
Scr_GetFunction_t Scr_GetFunction = (Scr_GetFunction_t)0x8117CB2;
Scr_GetMethod_t Scr_GetMethod = (Scr_GetMethod_t)0x8117DEA;
#else
#warning Scr_GetFunction_t Scr_GetFunction = (Scr_GetFunction_t)NULL;
#warning Scr_GetMethod_t Scr_GetMethod = (Scr_GetMethod_t)NULL;
Scr_GetFunction_t Scr_GetFunction = (Scr_GetFunction_t)NULL;
Scr_GetMethod_t Scr_GetMethod = (Scr_GetMethod_t)NULL;
#endif


I would be glad if somebody would provide those 2 addresses.

Since we use git, you could also checkout an old version. Or use the old precompiled CoD4 binary: http://killtube.org/downloads/libcod/

Old is bad, but might work for your purpose till somebody searched Scr_GetFunction/Scr_GetMethod for CoD4.


BTW, all these warnings (not errors) happen because the developers of gcc seem to lack real problems or just want to nit-pick on available code... they started to add more and more compile-warnings for code that worked for centuries by each new version of gcc. *slow clap*

Well, welcome on board :D

Mitch
18th April 2014, 08:20
It needs an #if-case like:



#if COD_VERSION == COD2_1_0 || COD_VERSION == COD2_1_2 || COD_VERSION == COD2_1_3
printf("> [INFO] value of download=%.8x\n", *addressToDownloadPointer);
SV_BeginDownload_f = (SV_BeginDownload_f_t)*addressToDownloadPointer;
*addressToDownloadPointer = (int)hook_SV_BeginDownload_f;
#endif



I tried to find the pointer to the download function, but it isn't the same as CoD2.



Old is bad, but might work for your purpose till somebody searched Scr_GetFunction/Scr_GetMethod for CoD4.


I think Scr_GetFunction should be 0x080BD238 and Scr_GetMethod should be 0x080BFEF4. But someone will need to test it first.

https://github.com/M-itch/libcod/commit/b5b63538a52f68a563d46bbe682577ded51d96df

Try this binary: http://znation.nl/libcod/libcod4_1_7.so

kung foo man
18th April 2014, 22:01
Ok, spend kinda the whole day fixing this lol

The addresses for Scr_GetFunction/Scr_GetMethod were correct, the addresses for cracking_hook_call crashed though. Since we don't really need them nonetheless, I've replace them with a dynamic hook for Scr_GetMethod (the CALL opcode was just hooked, so the original function could be "hooked" while make it still callable). The current version is callable also of course, but it unhooks itself and rehooks after the original function is done.

All code here: https://github.com/kungfooman/libcod/commit/e1f16ce5e10b7c9ac395a89d5baa374f1918d32b

Binaries tested/working: http://killtube.org/downloads/libcod/2014_04_18/


One strange thing is, setVelocity/addVelocity always worked (tested months ago for Surf gametype in CoD4), but now it had no effect at all (even added printf in gsc_player_velocity_add() to verify that everything worked well). MySQL on the other hand works (returns valid pointer).

Tested with this little function in _callbacksetup.gsc:



CodeCallback_PlayerConnect()
{
self endon("disconnect");
[[level.callbackPlayerConnect]]();
self thread testVelocity();
}

testVelocity() {
printf("Thread started for player.name=% mysql=%!\n", self.name, mysql_init());
while (isDefined(self)) {
if (self useButtonPressed()) {
printf(".");
self addVelocity((0,0,100));
}
wait 0.05;
}
}

PureTryOut
19th April 2014, 17:58
Thank you, both of you!
Your latest binary actually worked kung (although compiling still seems to fail which is a shame).

Now a silly question, is it possible to show the [PLUGIN LOADED] output etc, after the server has loaded the first map?
The console goes way to quickly to be able to see what is happening, and I had to quickly screenshot to see if it was loading or not.
I'm not able to scroll up otherwise it would not have been a problem.

php
19th April 2014, 18:05
start a screen with -L which creates a logfile in the directory then after you're done, exit as normal and check the logfile.

PureTryOut
19th April 2014, 18:15
Thanks that does the job!

kung foo man
19th April 2014, 18:17
Or just scroll up in putty... ^^

Or enter Scroll-Mode when screen: Hold CTRL, then press the 2 keys: a [

To fix the compile errors, we actually need to see the errors.
./doit.sh cod4_1_7 2>&1 > buildlog.txt

(or copy it from Putty in clipboard by just selecting the text)

IzNoGoD
19th April 2014, 21:03
Or just scroll up in putty... ^^

Or enter Scroll-Mode when screen: Hold CTRL, then press the 2 keys: a [


Just tested, its actually ctrl+a, then just [, without ctrl

PureTryOut
21st April 2014, 18:30
Well first of all I do not use Putty. I'm running Ubuntu 14.04 on my PC so I just ssh from the console.
Anyways I managed to enable scrolling in ssh sessions somehow, but I still can't see the first messages because it clears the console after the first few lines. Not much to do about it.
Also because of all the warning messages (unkown dvar some client side variable, I guess lazy coding on Inifity Ward's side?), I have to scroll pretty far.

Also kung, I tried your method of logging the build process, but it just gives me 5 lines:

##### COMPILE cod4_1_7 LIBCOD.CPP #####
##### COMPILE cod4_1_7 GSC.CPP #####
##### COMPILE cod4_1_7 GSC_PLAYER.CPP #####
##### COMPILE cod4_1_7 GSC_UTILS.CPP #####
##### LINK libcod4_1_7.so #####


The console output is pasted in my first post, just look there for the errors.

kung foo man
21st April 2014, 19:07
When the history buffer in normal Terminal is not big enough, just install GNU/Screen "screen":
apt-get install screen

With default history size it's possible to scroll all the way up (here at least ^^).

Hm, then the error output of the subprocesses isn't redirected. This should work:


./doit.sh base > test.txt 2>&1

./doit.sh base 2>&1 | tee > test.txt

PureTryOut
22nd April 2014, 09:19
Like I said, it's not that the history is too short, it just clears the screen (console command "clear") somehow.
Doesn't matter though now I know how to log screen sessions.

Anyways this seemed to work!
Error output:

##### COMPILE GSC_ASTAR.CPP #####
##### COMPILE GSC_MYSQL.CPP #####
gsc_mysql.cpp: In function ‘void gsc_mysql_free_result()’:
gsc_mysql.cpp:529:15: warning: NULL used in arithmetic [-Wpointer-arith]
if(result == NULL)
^
gsc_mysql.cpp: In function ‘int gsc_mysql_test_0()’:
gsc_mysql.cpp:880:55: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘my_ulonglong {aka long long unsigned int}’ [-Wformat=]
printf("affected rows: %d\n", mysql_affected_rows(my));
^
gsc_mysql.cpp:892:54: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘my_ulonglong {aka long long unsigned int}’ [-Wformat=]
printf("query-num rows: %d\n", mysql_num_rows(query));
^
gsc_mysql.cpp: In function ‘int gsc_mysql_test_1()’:
gsc_mysql.cpp:972:47: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("stmt->stmt_id = %d\n", stmt->stmt_id);
^
gsc_mysql.cpp:973:59: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("stmt->prefetch_rows = %d\n", stmt->prefetch_rows);
^
gsc_mysql.cpp:993:47: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("stmt->stmt_id = %d\n", stmt->stmt_id);
^
gsc_mysql.cpp:994:59: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("stmt->prefetch_rows = %d\n", stmt->prefetch_rows); // i dont know
^
gsc_mysql.cpp:1146:55: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘my_ulonglong {aka long long unsigned int}’ [-Wformat=]
printf("affected rows: %d\n", mysql_affected_rows(my));
^
gsc_mysql.cpp:1158:54: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘my_ulonglong {aka long long unsigned int}’ [-Wformat=]
printf("query-num rows: %d\n", mysql_num_rows(query));
^
##### COMPILE SERVER.CPP #####
cc1: warning: command line option ‘-std=gnu++11’ is valid for C++/ObjC++ but not for C [enabled by default]
server.c: In function ‘mythread’:
server.c:244:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘void **’ [-Wformat=]
sscanf(arg_from, "%x", &from); // prepare from-pointer
^
server.c:311:7: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘float **’ [-Wformat=]
sscanf(address, "%x", &ptr_float);
^
server.c:328:7: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘int **’ [-Wformat=]
sscanf(address, "%x", &ptr);
^
server.c:345:7: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘unsigned char **’ [-Wformat=]
sscanf(address, "%x", &ptr);
^
server.c:387:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘char **’ [-Wformat=]
sscanf(arg_from, "%x", &from);
^
server.c:388:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘char **’ [-Wformat=]
sscanf(arg_to, "%x", &to);
^
server.c:433:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘unsigned int **’ [-Wformat=]
sscanf(arg_address, "%x", &address);
^
server.c:460:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘void **’ [-Wformat=]
sscanf(arg_addr, "%x", &addr);
^
server.c: In function ‘cdecl_injected_shell’:
server.c:718:5: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘unsigned int **’ [-Wformat=]
sscanf(buffer, "%x", &address);
^
##### COMPILE GSC_MEMORY.CPP #####
##### COMPILE cracking.CPP #####
##### COMPILE GSC_MATH.CPP #####

Although it is the same output as in my first post, I hope this helps.

kung foo man
22nd April 2014, 16:27
There is no error at all, just warnings based on gcc nitpicking. Compilation/linking should work without problems.

If you dare, you can add warning-ignore-flags for these in doit.sh and tell us how to disable them on never gcc versions.

PureTryOut
22nd April 2014, 16:55
Ooh well it's fine then, thanks for your help!