View Single Post
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-14-2010 , 01:15   Re: [Stock] Auto Exec Config File
Reply With Quote #9

Connor -

In Galileo I had to alter the config loading code because some people were getting "segmentation fault" errors when it was loading the config like the way you have it setup in your code. Changing it to the following seemed to fix it, if I recall correctly. I can't recall what the problem was (too big maybe?) nor how I determined that this fixed it. I just have a vague memory that it did.

Code:
config_load() {     // we are loading the config like this in order to avoid the     // "segmentation fault" error that some servers get when trying     // to exec the config file // this is the old, easy, awesome way of loading the config file //  server_cmd("exec %s/galileo.cfg", DIR_CONFIGS); //  server_exec();     new configFilename[256];     formatex(configFilename, sizeof(configFilename)-1, "%s/galileo.cfg", DIR_CONFIGS);     new file = fopen(configFilename, "rt");     if (file)     {         new buffer[512], cvar[32], value[480];                 while (!feof(file))         {             fgets(file, buffer, sizeof(buffer)-1);             trim(buffer);                         if (buffer[0] && !equal(buffer, "//", 2) && !equal(buffer, ";", 1))             {                 strbreak(buffer, cvar, sizeof(cvar)-1, value, sizeof(value)-1);                 if (value[0] == 0 || isalpha(value[0]))                 {                     set_cvar_string(cvar, value);                 }                 else if (contain(value, "."))                 {                     set_cvar_float(cvar, floatstr(value));                 }                 else                 {                     set_cvar_num(cvar, str_to_num(value));                 }             }         }         fclose(file);     }     else     {         log_error(AMX_ERR_NOTFOUND, "%L", LANG_SERVER, "GAL_CONFIG_FILEMISSING", configFilename);     } }

Thought you might be interested. Take it for what it's worth.
__________________
Brad is offline