Explorar o código

follow up

Mapindex now also uses the common variable db_path and the DBIMPORT define
Also removed the global mapindex configuration variable from the header file
Lemongrass3110 %!s(int64=10) %!d(string=hai) anos
pai
achega
df16b6e905
Modificáronse 2 ficheiros con 13 adicións e 11 borrados
  1. 13 8
      src/common/mapindex.c
  2. 0 3
      src/common/mapindex.h

+ 13 - 8
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 <stdlib.h>
 
@@ -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;
 			}
 		}

+ 0 - 3
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.