void HPM_HP_load(void) { #include HPM_POINTS_INCLUDE int i, len = ARRAYLENGTH(HookingPoints), idx = 0; memset(&HPMHooks,0,sizeof(struct HPMHooksCore)); hp_db = strdb_alloc(DB_OPT_BASE|DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, HookingPointsLenMax); for(i = 0; i < len; i++) { struct HookingPointData *hpd = NULL; CREATE(hpd, struct HookingPointData, 1); memcpy(hpd, &HookingPoints[i], sizeof(struct HookingPointData)); hpd->idx = idx; idx += 2; strdb_put(hp_db, HookingPoints[i].name, hpd); HPMHooks.data.total++; } #include HPM_SOURCES_INCLUDE }
void mapindex_init(void) { FILE *fp; char line[1024]; int last_index = -1; int index; char map_name[MAP_NAME_LENGTH]; if( ( fp = fopen(mapindex_cfgfile,"r") ) == NULL ){ ShowFatalError("Unable to read mapindex config file %s!\n", mapindex_cfgfile); exit(EXIT_FAILURE); //Server can't really run without this file. } memset (&indexes, 0, sizeof (indexes)); mapindex_db = strdb_alloc(DB_OPT_DUP_KEY, MAP_NAME_LENGTH); while(fgets(line, sizeof(line), fp)) { if(line[0] == '/' && line[1] == '/') continue; switch (sscanf(line, "%11s\t%d", map_name, &index)) { case 1: //Map with no ID given, auto-assign index = last_index+1; case 2: //Map with ID given mapindex_addmap(index,map_name); break; default: continue; } last_index = index; } fclose(fp); if( !strdb_iget(mapindex_db, MAP_DEFAULT) ) { ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! Update MAP_DEFAULT in mapindex.h!\n",MAP_DEFAULT); } }
void mapindex_init(void) { FILE *fp; char line[1024]; int last_index = -1; int index; char map_name[MAP_NAME_LENGTH]; char path[255]; const char* mapindex_cfgfile[] = { "map_index.txt", DBIMPORT"/map_index.txt" }; memset (&indexes, 0, sizeof (indexes)); mapindex_db = strdb_alloc(DB_OPT_DUP_KEY, MAP_NAME_LENGTH); for( size_t i = 0; i < ARRAYLENGTH(mapindex_cfgfile); i++ ){ sprintf( path, "%s/%s", db_path, mapindex_cfgfile[i] ); if( ( fp = fopen( path, "r" ) ) == NULL ){ // It is only fatal if it is the main file if( i == 0 ){ ShowFatalError("Unable to read mapindex config file %s!\n", path ); exit(EXIT_FAILURE); //Server can't really run without this file. }else{ ShowWarning("Unable to read mapindex config file %s!\n", path ); break; } } while(fgets(line, sizeof(line), fp)) { if(line[0] == '/' && line[1] == '/') continue; switch (sscanf(line, "%11s\t%d", map_name, &index)) { case 1: //Map with no ID given, auto-assign index = last_index+1; case 2: //Map with ID given mapindex_addmap(index,map_name); break; default: continue; } last_index = index; } fclose(fp); } }
raconf raconf_parse(const char *file_name){ struct raconf *rc; rc = aCalloc(1, sizeof(struct raconf) ); if(rc == NULL){ ShowFatalError("raconf_parse: failed to allocate memory for new handle\n"); return NULL; } rc->db = strdb_alloc(DB_OPT_BASE | DB_OPT_DUP_KEY, 98); // if(configParse(rc, file_name) != true){ ShowError("Failed to Parse Configuration file '%s'\n", file_name); } return rc; }//end: raconf_parse()
void do_init_channel(void) { channel_db = strdb_alloc(DB_OPT_RELEASE_DATA, NAME_LENGTH); memset(server_channel, 0, sizeof(server_channel)); sv_readdb(db_path, "channel_db.txt", ',', 5, 5, -1, &channel_read_channeldb); }