To follow up on the previous thing: the malloc() the the non-function space (outside of any function) returns a NULL-pointer.
The libcod code doesnt check for that, and as a result, the code will crash.
Printable View
To follow up on the previous thing: the malloc() the the non-function space (outside of any function) returns a NULL-pointer.
The libcod code doesnt check for that, and as a result, the code will crash.
Better fix which follows http://stackoverflow.com/questions/1...h-file-scope-c
PHP Code:
#define MAX_WEAPON_IGNORE_SIZE 20
#define MAX_WEAPON_NAME_SIZE 32
char* defaultweapon_mp;
char ignoredWeapons[MAX_WEAPON_IGNORE_SIZE][MAX_WEAPON_NAME_SIZE];
int ignoredWeaponCount = 0;
void gsc_utils_init() {
if(defaultweapon_mp == NULL)
defaultweapon_mp = (char*)malloc(sizeof(char) * MAX_WEAPON_NAME_SIZE);
if(defaultweapon_mp == NULL)
printf("Failed to malloc defaultweapon_mp\n");
strcpy(defaultweapon_mp, (char*)"defaultweapon_mp");
defaultweapon_mp[strlen(defaultweapon_mp)] = '\0';
}
void gsc_utils_free() {
free(defaultweapon_mp);
}
So it does now compile without any problems.
However, when I use the this script to setup mysql
https://killtube.org/showthread.php?...ll=1#post13719
I get this error
However, when I open gsc.ccpCode:unknown function: (file 'maps/mp/gametypes/_mysql.gsc', line 136)
mysql_close(mysql);
*
What can be the problem?Code:#if COMPILE_MYSQL == 1
{"mysql_init" , gsc_mysql_init , 0},
{"mysql_real_connect" , gsc_mysql_real_connect , 0},
{"mysql_close" , gsc_mysql_close , 0},
{"mysql_query" , gsc_mysql_query , 0},
{"mysql_errno" , gsc_mysql_errno , 0},
{"mysql_error" , gsc_mysql_error , 0},
{"mysql_affected_rows" , gsc_mysql_affected_rows , 0},
{"mysql_store_result" , gsc_mysql_store_result , 0},
{"mysql_num_rows" , gsc_mysql_num_rows , 0},
{"mysql_num_fields" , gsc_mysql_num_fields , 0},
{"mysql_field_seek" , gsc_mysql_field_seek , 0},
{"mysql_fetch_field" , gsc_mysql_fetch_field , 0},
{"mysql_fetch_row" , gsc_mysql_fetch_row , 0},
{"mysql_free_result" , gsc_mysql_free_result , 0},
{"mysql_real_escape_string", gsc_mysql_real_escape_string, 0},
{"mysql_async_create_query", gsc_mysql_async_create_query, 0},
{"mysql_async_create_query_nosave", gsc_mysql_async_create_query_nosave, 0},
{"mysql_async_getdone_list", gsc_mysql_async_getdone_list, 0},
{"mysql_async_getresult_and_free", gsc_mysql_async_getresult_and_free, 0},
{"mysql_async_initializer" , gsc_mysql_async_initializer , 0},
{"mysql_reuse_connection" , gsc_mysql_reuse_connection , 0},
#endif
Sorry for double post.
I added the fix of Iznogod to the github of Kungfooman and I can connect to my database :)
Thanks for all the help !