diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/itemdb.c | 86 | ||||
-rw-r--r-- | src/map/itemdb.h | 17 | ||||
-rw-r--r-- | src/map/map.c | 2 | ||||
-rw-r--r-- | src/map/pc.h | 3 | ||||
-rw-r--r-- | src/map/script.c | 6 |
5 files changed, 75 insertions, 39 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index cb845111d..859b19aac 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -296,8 +296,7 @@ static struct item_data* create_item_data(int nameid) /*========================================== * Loads (and creates if not found) an item from the db. *------------------------------------------*/ -struct item_data* itemdb_load(int nameid) -{ +struct item_data* itemdb_load(int nameid) { struct item_data *id; if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) @@ -967,7 +966,7 @@ void itemdb_re_split_atoi(char *str, int *atk, int *matk) { /*========================================== * processes one itemdb entry *------------------------------------------*/ -static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) { +int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) { /* +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+ | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | @@ -977,12 +976,12 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr */ int nameid; struct item_data* id; + unsigned char offset = 0; nameid = atoi(str[0]); - if( nameid <= 0 ) - { + if( nameid <= 0 ) { ShowWarning("itemdb_parse_dbrow: Invalid id %d in line %d of \"%s\", skipping.\n", nameid, line, source); - return false; + return 0; } //ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View @@ -1030,39 +1029,47 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr id->weight = atoi(str[6]); #ifdef RENEWAL - itemdb_re_split_atoi(str[7],&id->atk,&id->matk); + if( iMap->db_use_sqldbs ) { + id->atk = atoi(str[7]); + id->matk = atoi(str[8]); + offset += 1; + } else + itemdb_re_split_atoi(str[7],&id->atk,&id->matk); #else id->atk = atoi(str[7]); #endif - id->def = atoi(str[8]); - id->range = atoi(str[9]); - id->slot = atoi(str[10]); + id->def = atoi(str[8+offset]); + id->range = atoi(str[9+offset]); + id->slot = atoi(str[10+offset]); - if (id->slot > MAX_SLOTS) - { + if (id->slot > MAX_SLOTS) { ShowWarning("itemdb_parse_dbrow: Item %d (%s) specifies %d slots, but the server only supports up to %d. Using %d slots.\n", nameid, id->jname, id->slot, MAX_SLOTS, MAX_SLOTS); id->slot = MAX_SLOTS; } - itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11],NULL,0)); - id->class_upper = atoi(str[12]); - id->sex = atoi(str[13]); - id->equip = atoi(str[14]); + itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11+offset],NULL,0)); + id->class_upper = atoi(str[12+offset]); + id->sex = atoi(str[13+offset]); + id->equip = atoi(str[14+offset]); - if (!id->equip && itemdb_isequip2(id)) - { + if (!id->equip && itemdb_isequip2(id)) { ShowWarning("Item %d (%s) is an equipment with no equip-field! Making it an etc item.\n", nameid, id->jname); id->type = IT_ETC; } - id->wlv = cap_value(atoi(str[15]), REFINE_TYPE_ARMOR, REFINE_TYPE_MAX); + id->wlv = cap_value(atoi(str[15+offset]), REFINE_TYPE_ARMOR, REFINE_TYPE_MAX); #ifdef RENEWAL - itemdb_re_split_atoi(str[16],&id->elv,&id->elvmax); + if( iMap->db_use_sqldbs ) { + id->elv = atoi(str[16+offset]); + id->elvmax = atoi(str[17+offset]); + offset += 1; + } else + itemdb_re_split_atoi(str[16],&id->elv,&id->elvmax); #else id->elv = atoi(str[16]); #endif - id->flag.no_refine = atoi(str[17]) ? 0 : 1; //FIXME: verify this - id->look = atoi(str[18]); + id->flag.no_refine = atoi(str[17+offset]) ? 0 : 1; //FIXME: verify this + id->look = atoi(str[18+offset]); id->flag.available = 1; id->view_id = 0; @@ -1081,14 +1088,14 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr id->unequip_script = NULL; } - if (*str[19]) - id->script = parse_script(str[19], source, line, scriptopt); - if (*str[20]) - id->equip_script = parse_script(str[20], source, line, scriptopt); - if (*str[21]) - id->unequip_script = parse_script(str[21], source, line, scriptopt); + if (*str[19+offset]) + id->script = parse_script(str[19+offset], source, line, scriptopt); + if (*str[20+offset]) + id->equip_script = parse_script(str[20+offset], source, line, scriptopt); + if (*str[21+offset]) + id->unequip_script = parse_script(str[21+offset], source, line, scriptopt); - return true; + return id->nameid; } /*========================================== @@ -1205,7 +1212,7 @@ static int itemdb_readdb(void) } } - if (!itemdb_parse_dbrow(str, path, lines, 0)) + if (!itemdb->parse_dbrow(str, path, lines, 0)) continue; count++; @@ -1218,7 +1225,6 @@ static int itemdb_readdb(void) return 0; } - /*====================================== * item_db table reading *======================================*/ @@ -1234,7 +1240,7 @@ static int itemdb_read_sqldb(void) { int fi; for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi ) { - uint32 lines = 0, count = 0; + uint32 count = 0; // retrieve all rows from the item database if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) { @@ -1244,17 +1250,16 @@ static int itemdb_read_sqldb(void) { // process rows one by one while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) {// wrap the result into a TXT-compatible format - char* str[22]; + char* str[ITEMDB_SQL_COLUMNS]; char* dummy = ""; int i; - ++lines; - for( i = 0; i < 22; ++i ) { + for( i = 0; i < ITEMDB_SQL_COLUMNS; ++i ) { SQL->GetData(mmysql_handle, i, &str[i], NULL); if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } - if (!itemdb_parse_dbrow(str, item_db_name[fi], lines, SCRIPT_IGNORE_EXTERNAL_BRACKETS)) + if (!itemdb->parse_dbrow(str, item_db_name[fi], -(atoi(str[0])), SCRIPT_IGNORE_EXTERNAL_BRACKETS)) continue; ++count; } @@ -1471,3 +1476,12 @@ int do_init_itemdb(void) { return 0; } +/* incomplete */ +void itemdb_defaults(void) { + itemdb = &itemdb_s; + + itemdb->reload = itemdb_reload;//incomplet=e + /* */ + itemdb->parse_dbrow = itemdb_parse_dbrow; + itemdb->exists = itemdb_exists;//incomplete +} diff --git a/src/map/itemdb.h b/src/map/itemdb.h index ea478d135..44b455d80 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #ifndef _ITEMDB_H_ #define _ITEMDB_H_ @@ -239,4 +240,16 @@ void itemdb_reload(void); void do_final_itemdb(void); int do_init_itemdb(void); +/* incomplete */ +struct itemdb_interface { + void (*reload) (void); + /* */ + int (*parse_dbrow) (char** str, const char* source, int line, int scriptopt); + struct item_data* (*exists) (int nameid); +} itemdb_s; + +struct itemdb_interface *itemdb; + +void itemdb_defaults(void); + #endif /* _ITEMDB_H_ */ diff --git a/src/map/map.c b/src/map/map.c index 510f36109..84b4f6bd2 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5237,6 +5237,7 @@ void map_hp_symbols(void) { HPM->share(guild,"guild"); HPM->share(homun,"homun"); HPM->share(ircbot,"ircbot"); + HPM->share(itemdb,"itemdb"); HPM->share(logs,"logs"); HPM->share(script,"script"); HPM->share(searchstore,"searchstore"); @@ -5266,6 +5267,7 @@ void load_defaults(void) { homunculus_defaults(); instance_defaults(); ircbot_defaults(); + itemdb_defaults(); log_defaults(); npc_defaults(); script_defaults(); diff --git a/src/map/pc.h b/src/map/pc.h index cd2a45a6b..5c585af1c 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -497,6 +497,9 @@ struct map_session_data { int *queues; unsigned int queues_count; + /* Made Possible Thanks to Yommy~! */ + unsigned int cryptKey; + // temporary debugging of bug #3504 const char* delunit_prevfile; int delunit_prevline; diff --git a/src/map/script.c b/src/map/script.c index bc5959003..0ef12f74d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2045,7 +2045,11 @@ void script_error(const char* src, const char* file, int start_line, const char* StrBuf->Init(&buf); StrBuf->AppendStr(&buf, "\a\n"); - StrBuf->Printf(&buf, "script error on %s line %d\n", file, line); + if( line >= 0 ) + StrBuf->Printf(&buf, "script error on %s line %d\n", file, line); + else + StrBuf->Printf(&buf, "script error on %s item ID %d\n", file, -line); + StrBuf->Printf(&buf, " %s\n", error_msg); for(j = 0; j < 5; j++ ) { script_print_line(&buf, linestart[j], NULL, line + j - 5); |