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
This commit is contained in:
Lemongrass3110 2015-01-09 18:12:04 +01:00
parent f15f0d95d4
commit df16b6e905
2 changed files with 13 additions and 11 deletions

View File

@ -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;
}
}

View File

@ -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.