summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-09-25 09:07:33 -0300
committershennetsind <ind@henn.et>2013-09-25 09:07:33 -0300
commit13afb7e0bf35bacc9c90c7dffe34120ddd2fd099 (patch)
tree180c739ac69aceab8ce4cc6151030539a32ac8c3 /src/map/itemdb.c
parent1114eb3da58b078258a824424fef687a1ccee90c (diff)
parent66979ef89363c03e3cc02d63feb5248836daff4e (diff)
downloadhercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.gz
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.bz2
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.xz
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Conflicts: src/map/chrif.c src/map/clif.c src/map/homunculus.c src/map/pet.c src/map/script.c src/map/skill.c src/map/status.c All clear.
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c68
1 files changed, 30 insertions, 38 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index c2a25c2d4..2398ba04c 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -1379,13 +1379,13 @@ void itemdb_read_combos() {
uint32 lines = 0, count = 0;
char line[1024];
- char path[256];
+ char filepath[256];
FILE* fp;
- sprintf(path, "%s/%s", iMap->db_path, DBPATH"item_combo_db.txt");
+ sprintf(filepath, "%s/%s", iMap->db_path, DBPATH"item_combo_db.txt");
- if ((fp = fopen(path, "r")) == NULL) {
- ShowError("itemdb_read_combos: File not found \"%s\".\n", path);
+ if ((fp = fopen(filepath, "r")) == NULL) {
+ ShowError("itemdb_read_combos: File not found \"%s\".\n", filepath);
return;
}
@@ -1407,10 +1407,9 @@ void itemdb_read_combos() {
if (*p == '\0')
continue;// empty line
- if (!strchr(p,','))
- {
+ if (!strchr(p,',')) {
/* is there even a single column? */
- ShowError("itemdb_read_combos: Insufficient columns in line %d of \"%s\", skipping.\n", lines, path);
+ ShowError("itemdb_read_combos: Insufficient columns in line %d of \"%s\", skipping.\n", lines, filepath);
continue;
}
@@ -1424,13 +1423,13 @@ void itemdb_read_combos() {
p++;
if (str[1][0] != '{') {
- ShowError("itemdb_read_combos(#1): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, path);
+ ShowError("itemdb_read_combos(#1): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, filepath);
continue;
}
/* no ending key anywhere (missing \}\) */
if ( str[1][strlen(str[1])-1] != '}' ) {
- ShowError("itemdb_read_combos(#2): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, path);
+ ShowError("itemdb_read_combos(#2): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, filepath);
continue;
} else {
int items[MAX_ITEMS_PER_COMBO];
@@ -1439,14 +1438,14 @@ void itemdb_read_combos() {
int idx = 0;
if((retcount = itemdb->combo_split_atoi(str[0], items)) < 2) {
- ShowError("itemdb_read_combos: line %d of \"%s\" doesn't have enough items to make for a combo (min:2), skipping.\n", lines, path);
+ ShowError("itemdb_read_combos: line %d of \"%s\" doesn't have enough items to make for a combo (min:2), skipping.\n", lines, filepath);
continue;
}
/* validate */
for(v = 0; v < retcount; v++) {
if( !itemdb->exists(items[v]) ) {
- ShowError("itemdb_read_combos: line %d of \"%s\" contains unknown item ID %d, skipping.\n", lines, path,items[v]);
+ ShowError("itemdb_read_combos: line %d of \"%s\" contains unknown item ID %d, skipping.\n", lines, filepath,items[v]);
break;
}
}
@@ -1470,7 +1469,7 @@ void itemdb_read_combos() {
id->combos[idx]->nameid = aMalloc( retcount * sizeof(unsigned short) );
id->combos[idx]->count = retcount;
- id->combos[idx]->script = script->parse(str[1], path, lines, 0);
+ id->combos[idx]->script = script->parse(str[1], filepath, lines, 0);
id->combos[idx]->id = count;
id->combos[idx]->isRef = false;
/* populate ->nameid field */
@@ -1712,13 +1711,13 @@ int itemdb_readdb(void)
uint32 lines = 0, count = 0;
char line[1024];
- char path[256];
+ char filepath[256];
FILE* fp;
- sprintf(path, "%s/%s", iMap->db_path, filename[fi]);
- fp = fopen(path, "r");
+ sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]);
+ fp = fopen(filepath, "r");
if( fp == NULL ) {
- ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", path);
+ ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", filepath);
continue;
}
@@ -1737,8 +1736,7 @@ int itemdb_readdb(void)
++p;
if( *p == '\0' )
continue;// empty line
- for( i = 0; i < 19; ++i )
- {
+ for( i = 0; i < 19; ++i ) {
str[i] = p;
p = strchr(p,',');
if( p == NULL )
@@ -1747,48 +1745,42 @@ int itemdb_readdb(void)
++p;
}
- if( p == NULL )
- {
- ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ if( p == NULL ) {
+ ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0]));
continue;
}
// Script
- if( *p != '{' )
- {
- ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ if( *p != '{' ) {
+ ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0]));
continue;
}
str[19] = p;
p = strstr(p+1,"},");
- if( p == NULL )
- {
- ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ if( p == NULL ) {
+ ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0]));
continue;
}
p[1] = '\0';
p += 2;
// OnEquip_Script
- if( *p != '{' )
- {
- ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ if( *p != '{' ) {
+ ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0]));
continue;
}
str[20] = p;
p = strstr(p+1,"},");
- if( p == NULL )
- {
- ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ if( p == NULL ) {
+ ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0]));
continue;
}
p[1] = '\0';
p += 2;
// OnUnequip_Script (last column)
- if( *p != '{' )
- {
- ShowError("itemdb_readdb: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ if( *p != '{' ) {
+ ShowError("itemdb_readdb: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0]));
continue;
}
str[21] = p;
@@ -1805,12 +1797,12 @@ int itemdb_readdb(void)
}
if( lcurly != rcurly ) {
- ShowError("itemdb_readdb: Mismatching curly braces in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ ShowError("itemdb_readdb: Mismatching curly braces in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0]));
continue;
}
}
- if (!itemdb->parse_dbrow(str, path, lines, 0))
+ if (!itemdb->parse_dbrow(str, filepath, lines, 0))
continue;
count++;