diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 18d3740b31..c1790b1077 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -1,10 +1,12 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#include "../config/core.h" +#include "../common/core.h" +#include "../common/mapindex.h" #include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/strlib.h" -#include "mapindex.h" #include @@ -132,23 +134,26 @@ void mapindex_init(void) { int last_index = -1; int index; char map_name[MAP_NAME_LENGTH]; - char* mapindex_cfgfile[80] = { - "db/map_index.txt", - "db/import/map_index.txt" + char path[255]; + const char* mapindex_cfgfile[] = { + "map_index.txt", + DBIMPORT"/map_index.txt" }; int i; memset (&indexes, 0, sizeof (indexes)); mapindex_db = strdb_alloc(DB_OPT_DUP_KEY, MAP_NAME_LENGTH); - for( i = 0; i < 2; i++ ){ - if( ( fp = fopen(mapindex_cfgfile[i],"r") ) == NULL ){ + for( 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", mapindex_cfgfile[i]); + 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", mapindex_cfgfile[i]); + ShowWarning("Unable to read mapindex config file %s!\n", path ); break; } } diff --git a/src/common/mapindex.h b/src/common/mapindex.h index 2d9700c71f..2e4fb53dc6 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -4,9 +4,6 @@ #ifndef _MAPINDEX_H_ #define _MAPINDEX_H_ -//File in charge of assigning a numberic ID to each map in existance for space saving when passing map info between servers. -extern char mapindex_cfgfile[80]; - #define MAX_MAPINDEX 2000 //Some definitions for the mayor city maps.