diff options
-rw-r--r-- | src/map/atcommand.c | 6 | ||||
-rw-r--r-- | src/map/battle.c | 6 | ||||
-rw-r--r-- | src/map/battleground.c | 119 | ||||
-rw-r--r-- | src/map/battleground.h | 36 | ||||
-rw-r--r-- | src/map/buyingstore.c | 2 | ||||
-rw-r--r-- | src/map/clif.c | 26 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/itemdb.c | 246 | ||||
-rw-r--r-- | src/map/itemdb.h | 82 | ||||
-rw-r--r-- | src/map/map.c | 6 | ||||
-rw-r--r-- | src/map/mob.c | 4 | ||||
-rw-r--r-- | src/map/npc.c | 8 | ||||
-rw-r--r-- | src/map/pc.c | 28 | ||||
-rw-r--r-- | src/map/script.c | 56 | ||||
-rw-r--r-- | src/map/skill.c | 4 | ||||
-rw-r--r-- | src/map/storage.c | 4 | ||||
-rw-r--r-- | src/map/trade.c | 4 | ||||
-rw-r--r-- | src/map/unit.c | 2 |
18 files changed, 361 insertions, 280 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index f13ad0a4e..2466c2cca 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1157,7 +1157,7 @@ ACMD(item) item_id = item_data->nameid; get_count = number; //Check if it's stackable. - if (!itemdb_isstackable2(item_data)) + if (!itemdb->isstackable2(item_data)) get_count = 1; for (i = 0; i < number; i += get_count) { @@ -2138,7 +2138,7 @@ ACMD(produce) item_id = item_data->nameid; - if (itemdb_isequip2(item_data)) { + if (itemdb->isequip2(item_data)) { int flag = 0; if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE) attribute = ATTRIBUTE_NORMAL; @@ -7222,7 +7222,7 @@ ACMD(iteminfo) item_data = item_array[i]; sprintf(atcmd_output, msg_txt(1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s item_data->name,item_data->jname,item_data->slot,item_data->nameid, - itemdb_typename(item_data->type), + itemdb->typename(item_data->type), (item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script ); clif->message(fd, atcmd_output); diff --git a/src/map/battle.c b/src/map/battle.c index c0c4618fb..85fa2cb98 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2337,7 +2337,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block int hp = status_get_max_hp(src) * (10 + 2 * skill_lv) / 100, sp = status_get_max_sp(src) * (6 + skill_lv) / 100; if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE ) // ATK [((Caster consumed HP + SP) / 2) x Caster Base Level / 100] % - skillratio += -100 + hp+sp / 2; + skillratio += -100 + (hp+sp) / 2; else skillratio += -100 + (hp+sp) / 4; RE_LVL_DMOD(100); @@ -6028,8 +6028,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f int sbg_id = 0, tbg_id = 0; if( map[m].flag.battleground ) { - sbg_id = bg_team_get_id(s_bl); - tbg_id = bg_team_get_id(t_bl); + sbg_id = bg->team_get_id(s_bl); + tbg_id = bg->team_get_id(t_bl); } if( flag&(BCT_PARTY|BCT_ENEMY) ) { diff --git a/src/map/battleground.c b/src/map/battleground.c index eb91f0066..e72683880 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -26,13 +26,11 @@ #include <string.h> #include <stdio.h> -static DBMap* bg_team_db; // int bg_id -> struct battleground_data* -static unsigned int bg_team_counter = 0; // Next bg_id struct battleground_interface bg_s; struct battleground_data* bg_team_search(int bg_id) { // Search a BG Team using bg_id if( !bg_id ) return NULL; - return (struct battleground_data *)idb_get(bg_team_db, bg_id); + return (struct battleground_data *)idb_get(bg->team_db, bg_id); } struct map_session_data* bg_getavailablesd(struct battleground_data *bg) { @@ -46,28 +44,28 @@ int bg_team_delete(int bg_id) { // Deletes BG Team from db int i; struct map_session_data *sd; - struct battleground_data *bg = bg_team_search(bg_id); + struct battleground_data *bgd = bg->team_search(bg_id); if( bg == NULL ) return 0; for( i = 0; i < MAX_BG_MEMBERS; i++ ) { - if( (sd = bg->members[i].sd) == NULL ) + if( (sd = bgd->members[i].sd) == NULL ) continue; - bg_send_dot_remove(sd); + bg->send_dot_remove(sd); sd->bg_id = 0; } - idb_remove(bg_team_db, bg_id); + idb_remove(bg->team_db, bg_id); return 1; } int bg_team_warp(int bg_id, unsigned short mapindex, short x, short y) { // Warps a Team int i; - struct battleground_data *bg = bg_team_search(bg_id); + struct battleground_data *bgd = bg->team_search(bg_id); if( bg == NULL ) return 0; for( i = 0; i < MAX_BG_MEMBERS; i++ ) - if( bg->members[i].sd != NULL ) pc->setpos(bg->members[i].sd, mapindex, x, y, CLR_TELEPORT); + if( bgd->members[i].sd != NULL ) pc->setpos(bgd->members[i].sd, mapindex, x, y, CLR_TELEPORT); return 1; } @@ -81,33 +79,33 @@ int bg_send_dot_remove(struct map_session_data *sd) int bg_team_join(int bg_id, struct map_session_data *sd) { // Player joins team int i; - struct battleground_data *bg = bg_team_search(bg_id); + struct battleground_data *bgd = bg->team_search(bg_id); struct map_session_data *pl_sd; if( bg == NULL || sd == NULL || sd->bg_id ) return 0; - ARR_FIND(0, MAX_BG_MEMBERS, i, bg->members[i].sd == NULL); + ARR_FIND(0, MAX_BG_MEMBERS, i, bgd->members[i].sd == NULL); if( i == MAX_BG_MEMBERS ) return 0; // No free slots sd->bg_id = bg_id; - bg->members[i].sd = sd; - bg->members[i].x = sd->bl.x; - bg->members[i].y = sd->bl.y; + bgd->members[i].sd = sd; + bgd->members[i].x = sd->bl.x; + bgd->members[i].y = sd->bl.y; /* populate 'where i came from' */ if(map[sd->bl.m].flag.nosave || map[sd->bl.m].instance_id >= 0){ struct map_data *m=&map[sd->bl.m]; if(m->save.map) - memcpy(&bg->members[i].source,&m->save,sizeof(struct point)); + memcpy(&bgd->members[i].source,&m->save,sizeof(struct point)); else - memcpy(&bg->members[i].source,&sd->status.save_point,sizeof(struct point)); + memcpy(&bgd->members[i].source,&sd->status.save_point,sizeof(struct point)); } else - memcpy(&bg->members[i].source,&sd->status.last_point,sizeof(struct point)); - bg->count++; + memcpy(&bgd->members[i].source,&sd->status.last_point,sizeof(struct point)); + bgd->count++; guild->send_dot_remove(sd); for( i = 0; i < MAX_BG_MEMBERS; i++ ) { - if( (pl_sd = bg->members[i].sd) != NULL && pl_sd != sd ) + if( (pl_sd = bgd->members[i].sd) != NULL && pl_sd != sd ) clif->hpmeter_single(sd->fd, pl_sd->bl.id, pl_sd->battle_status.hp, pl_sd->battle_status.max_hp); } @@ -124,11 +122,11 @@ int bg_team_leave(struct map_session_data *sd, int flag) if( sd == NULL || !sd->bg_id ) return 0; - bg_send_dot_remove(sd); + bg->send_dot_remove(sd); bg_id = sd->bg_id; sd->bg_id = 0; - if( (bg_data = bg_team_search(bg_id)) == NULL ) + if( (bg_data = bg->team_search(bg_id)) == NULL ) return 0; ARR_FIND(0, MAX_BG_MEMBERS, i, bg_data->members[i].sd == sd); @@ -160,34 +158,34 @@ int bg_team_leave(struct map_session_data *sd, int flag) int bg_member_respawn(struct map_session_data *sd) { // Respawn after killed - struct battleground_data *bg; - if( sd == NULL || !pc_isdead(sd) || !sd->bg_id || (bg = bg_team_search(sd->bg_id)) == NULL ) + struct battleground_data *bgd; + if( sd == NULL || !pc_isdead(sd) || !sd->bg_id || (bgd = bg->team_search(sd->bg_id)) == NULL ) return 0; - if( bg->mapindex == 0 ) + if( bgd->mapindex == 0 ) return 0; // Respawn not handled by Core - pc->setpos(sd, bg->mapindex, bg->x, bg->y, CLR_OUTSIGHT); + pc->setpos(sd, bgd->mapindex, bgd->x, bgd->y, CLR_OUTSIGHT); iStatus->revive(&sd->bl, 1, 100); return 1; // Warped } int bg_create(unsigned short mapindex, short rx, short ry, const char *ev, const char *dev) { - struct battleground_data *bg; - bg_team_counter++; - - CREATE(bg, struct battleground_data, 1); - bg->bg_id = bg_team_counter; - bg->count = 0; - bg->mapindex = mapindex; - bg->x = rx; - bg->y = ry; - safestrncpy(bg->logout_event, ev, sizeof(bg->logout_event)); - safestrncpy(bg->die_event, dev, sizeof(bg->die_event)); - - memset(&bg->members, 0, sizeof(bg->members)); - idb_put(bg_team_db, bg_team_counter, bg); - - return bg->bg_id; + struct battleground_data *bgd; + bg->team_counter++; + + CREATE(bgd, struct battleground_data, 1); + bgd->bg_id = bg->team_counter; + bgd->count = 0; + bgd->mapindex = mapindex; + bgd->x = rx; + bgd->y = ry; + safestrncpy(bgd->logout_event, ev, sizeof(bgd->logout_event)); + safestrncpy(bgd->die_event, dev, sizeof(bgd->die_event)); + + memset(&bgd->members, 0, sizeof(bgd->members)); + idb_put(bg->team_db, bg->team_counter, bg); + + return bgd->bg_id; } int bg_team_get_id(struct block_list *bl) @@ -226,12 +224,12 @@ int bg_team_get_id(struct block_list *bl) int bg_send_message(struct map_session_data *sd, const char *mes, int len) { - struct battleground_data *bg; + struct battleground_data *bgd; nullpo_ret(sd); - if( sd->bg_id == 0 || (bg = bg_team_search(sd->bg_id)) == NULL ) + if( sd->bg_id == 0 || (bgd = bg->team_search(sd->bg_id)) == NULL ) return 0; - clif->bg_message(bg, sd->bl.id, sd->status.name, mes, len); + clif->bg_message(bgd, sd->bl.id, sd->status.name, mes, len); return 0; } @@ -257,7 +255,7 @@ int bg_send_xy_timer_sub(DBKey key, DBData *data, va_list ap) } int bg_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) { - bg_team_db->foreach(bg_team_db, bg_send_xy_timer_sub, tick); + bg->team_db->foreach(bg->team_db, bg->send_xy_timer_sub, tick); return 0; } void bg_config_read(void) { @@ -497,7 +495,7 @@ void bg_match_over(struct bg_arena *arena, bool canceled) { if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.arena ) { - bg_team_leave(sd, 0); + bg->team_leave(sd, 0); bg->queue_pc_cleanup(sd); } if( canceled ) @@ -570,7 +568,7 @@ void bg_queue_check(struct bg_arena *arena) { int count = script->hq[arena->queue_id].items; if( count == arena->max_players ) { if( arena->fillup_timer != INVALID_TIMER ) { - iTimer->delete_timer(arena->fillup_timer,bg_fillup_timer); + iTimer->delete_timer(arena->fillup_timer,bg->fillup_timer); arena->fillup_timer = INVALID_TIMER; } bg->queue_pregame(arena); @@ -765,16 +763,16 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ return BGQA_SUCCESS; } void do_init_battleground(void) { - bg_team_db = idb_alloc(DB_OPT_RELEASE_DATA); - iTimer->add_timer_func_list(bg_send_xy_timer, "bg_send_xy_timer"); - iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg_send_xy_timer, 0, 0, battle_config.bg_update_interval); + bg->team_db = idb_alloc(DB_OPT_RELEASE_DATA); + iTimer->add_timer_func_list(bg->send_xy_timer, "bg_send_xy_timer"); + iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg->send_xy_timer, 0, 0, battle_config.bg_update_interval); bg->config_read(); } void do_final_battleground(void) { int i; - bg_team_db->destroy(bg_team_db, NULL); + db_destroy(bg->team_db); for( i = 0; i < bg->arenas; i++ ) { if( bg->arena[i] ) @@ -793,6 +791,12 @@ void battleground_defaults(void) { bg->arena = NULL; bg->arenas = 0; /* */ + bg->team_db = NULL; + bg->team_counter = 0; + /* */ + bg->init = do_init_battleground; + bg->final = do_final_battleground; + /* */ bg->name2arena = bg_name2arena; bg->queue_add = bg_queue_add; bg->can_queue = bg_canqueue; @@ -805,6 +809,19 @@ void battleground_defaults(void) { bg->queue_ready_ack = bg_queue_ready_ack; bg->match_over = bg_match_over; bg->queue_check = bg_queue_check; + bg->team_search = bg_team_search; + bg->getavailablesd = bg_getavailablesd; + bg->team_delete = bg_team_delete; + bg->team_warp = bg_team_warp; + bg->send_dot_remove = bg_send_dot_remove; + bg->team_join = bg_team_join; + bg->team_leave = bg_team_leave; + bg->member_respawn = bg_member_respawn; + bg->create = bg_create; + bg->team_get_id = bg_team_get_id; + bg->send_message = bg_send_message; + bg->send_xy_timer_sub = bg_send_xy_timer_sub; + bg->send_xy_timer = bg_send_xy_timer; /* */ bg->config_read = bg_config_read; } diff --git a/src/map/battleground.h b/src/map/battleground.h index 1566e92b8..3edecf902 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -43,22 +43,6 @@ struct battleground_data { char die_event[EVENT_NAME_LENGTH]; }; -void do_init_battleground(void); -void do_final_battleground(void); - -struct battleground_data* bg_team_search(int bg_id); -int bg_send_dot_remove(struct map_session_data *sd); -int bg_team_get_id(struct block_list *bl); -struct map_session_data* bg_getavailablesd(struct battleground_data *bg); - -int bg_create(unsigned short mapindex, short rx, short ry, const char *ev, const char *dev); -int bg_team_join(int bg_id, struct map_session_data *sd); -int bg_team_delete(int bg_id); -int bg_team_leave(struct map_session_data *sd, int flag); -int bg_team_warp(int bg_id, unsigned short mapindex, short x, short y); -int bg_member_respawn(struct map_session_data *sd); -int bg_send_message(struct map_session_data *sd, const char *mes, int len); - struct bg_arena { char name[NAME_LENGTH]; unsigned char id; @@ -79,7 +63,6 @@ struct bg_arena { bool ongoing; }; -/* battleground.c interface (incomplete) */ struct battleground_interface { bool queue_on; /* */ @@ -89,6 +72,12 @@ struct battleground_interface { struct bg_arena **arena; unsigned char arenas; /* */ + DBMap *team_db; // int bg_id -> struct battleground_data* + unsigned int team_counter; // Next bg_id + /* */ + void (*init) (void); + void (*final) (void); + /* */ struct bg_arena *(*name2arena) (char *name); void (*queue_add) (struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type); enum BATTLEGROUNDS_QUEUE_ACK (*can_queue) (struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type); @@ -101,6 +90,19 @@ struct battleground_interface { void (*queue_ready_ack) (struct bg_arena *arena, struct map_session_data *sd, bool response); void (*match_over) (struct bg_arena *arena, bool canceled); void (*queue_check) (struct bg_arena *arena); + struct battleground_data* (*team_search) (int bg_id); + struct map_session_data* (*getavailablesd) (struct battleground_data *bg); + int (*team_delete) (int bg_id); + int (*team_warp) (int bg_id, unsigned short mapindex, short x, short y); + int (*send_dot_remove) (struct map_session_data *sd); + int (*team_join) (int bg_id, struct map_session_data *sd); + int (*team_leave) (struct map_session_data *sd, int flag); + int (*member_respawn) (struct map_session_data *sd); + int (*create) (unsigned short mapindex, short rx, short ry, const char *ev, const char *dev); + int (*team_get_id) (struct block_list *bl); + int (*send_message) (struct map_session_data *sd, const char *mes, int len); + int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap); + int (*send_xy_timer) (int tid, unsigned int tick, int id, intptr_t data); /* */ void (*config_read) (void); }; diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 73c50b0bf..5edf9a321 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -147,7 +147,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha break; } - if( !id->flag.buyingstore || !itemdb_cantrade_sub(id, pc->get_group_level(sd), pc->get_group_level(sd)) || ( idx = pc->search_inventory(sd, nameid) ) == -1 ) + if( !id->flag.buyingstore || !itemdb->cantrade_sub(id, pc->get_group_level(sd), pc->get_group_level(sd)) || ( idx = pc->search_inventory(sd, nameid) ) == -1 ) {// restrictions: allowed, no character-bound items and at least one must be owned break; } diff --git a/src/map/clif.c b/src/map/clif.c index da8af5543..f55dcdf08 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -339,7 +339,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target struct map_session_data *sd, *tsd; struct party_data *p = NULL; struct guild *g = NULL; - struct battleground_data *bg = NULL; + struct battleground_data *bgd = NULL; int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd; struct s_mapiterator* iter; @@ -545,9 +545,9 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target case BG_SAMEMAP_WOS: case BG: case BG_WOS: - if( sd && sd->bg_id && (bg = bg_team_search(sd->bg_id)) != NULL ) { + if( sd && sd->bg_id && (bgd = bg->team_search(sd->bg_id)) != NULL ) { for( i = 0; i < MAX_BG_MEMBERS; i++ ) { - if( (sd = bg->members[i].sd) == NULL || !(fd = sd->fd) ) + if( (sd = bgd->members[i].sd) == NULL || !(fd = sd->fd) ) continue; if( sd->bl.id == bl->id && (type == BG_WOS || type == BG_SAMEMAP_WOS || type == BG_AREA_WOS) ) continue; @@ -2326,7 +2326,7 @@ void clif_inventorylist(struct map_session_data *sd) { if( sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL ) continue; - if( !itemdb_isstackable2(sd->inventory_data[i]) ) + if( !itemdb->isstackable2(sd->inventory_data[i]) ) { //Non-stackable (Equippable) WBUFW(bufe,ne*se+4)=i+2; clif->item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc->equippoint(sd,i)); @@ -2415,7 +2415,7 @@ void clif_equiplist(struct map_session_data *sd) if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL) continue; - if(itemdb_isstackable2(sd->inventory_data[i])) + if(itemdb->isstackable2(sd->inventory_data[i])) continue; //Equippable WBUFW(buf,n*cmd+4)=i+2; @@ -2473,7 +2473,7 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items if( items[i].nameid <= 0 ) continue; id = itemdb->search(items[i].nameid); - if( !itemdb_isstackable2(id) ) + if( !itemdb->isstackable2(id) ) { //Equippable WBUFW(bufe,ne*cmd+4)=i+1; clif->item_sub(bufe, ne*cmd+6, &items[i], id, id->equip); @@ -2553,7 +2553,7 @@ void clif_cartlist(struct map_session_data *sd) if( sd->status.cart[i].nameid <= 0 ) continue; id = itemdb->search(sd->status.cart[i].nameid); - if( !itemdb_isstackable2(id) ) + if( !itemdb->isstackable2(id) ) { //Equippable WBUFW(bufe,ne*cmd+4)=i+2; clif->item_sub(bufe, ne*cmd+6, &sd->status.cart[i], id, id->equip); @@ -9012,7 +9012,7 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts { if (tsd->status.inventory[i].nameid <= 0 || tsd->inventory_data[i] == NULL) // Item doesn't exist continue; - if (!itemdb_isequip2(tsd->inventory_data[i])) // Is not equippable + if (!itemdb->isequip2(tsd->inventory_data[i])) // Is not equippable continue; // Inventory position @@ -13047,7 +13047,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) } if( sd->bg_id ) - bg_send_message(sd, text, textlen); + bg->send_message(sd, text, textlen); else guild->send_message(sd, text, textlen); } @@ -15920,11 +15920,11 @@ void clif_bg_xy_remove(struct map_session_data *sd) /// Notifies clients of a battleground message (ZC_BATTLEFIELD_CHAT). /// 02dc <packet len>.W <account id>.L <name>.24B <message>.?B -void clif_bg_message(struct battleground_data *bg, int src_id, const char *name, const char *mes, int len) +void clif_bg_message(struct battleground_data *bgd, int src_id, const char *name, const char *mes, int len) { struct map_session_data *sd; unsigned char *buf; - if( !bg->count || (sd = bg_getavailablesd(bg)) == NULL ) + if( !bgd->count || (sd = bg->getavailablesd(bgd)) == NULL ) return; buf = (unsigned char*)aMalloc((len + NAME_LENGTH + 8)*sizeof(unsigned char)); @@ -15966,7 +15966,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; } - bg_send_message(sd, text, textlen); + bg->send_message(sd, text, textlen); } @@ -17314,7 +17314,7 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) { get_count = qty; - if (!itemdb_isstackable2(data)) + if (!itemdb->isstackable2(data)) get_count = 1; pc->paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki] diff --git a/src/map/clif.h b/src/map/clif.h index 73d3611a2..35e3e75f3 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -826,7 +826,7 @@ struct clif_interface { void (*bg_hp) (struct map_session_data *sd); void (*bg_xy) (struct map_session_data *sd); void (*bg_xy_remove) (struct map_session_data *sd); - void (*bg_message) (struct battleground_data *bg, int src_id, const char *name, const char *mes, int len); + void (*bg_message) (struct battleground_data *bgd, int src_id, const char *name, const char *mes, int len); void (*bg_updatescore) (int16 m); void (*bg_updatescore_single) (struct map_session_data *sd); void (*sendbgemblem_area) (struct map_session_data *sd); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 7045bd358..c2a25c2d4 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -19,11 +19,6 @@ #include <stdlib.h> #include <string.h> -static struct item_data* itemdb_array[MAX_ITEMDB]; -static DBMap* itemdb_other;// int nameid -> struct item_data* - -struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex] - struct itemdb_interface itemdb_s; /** @@ -31,14 +26,14 @@ struct itemdb_interface itemdb_s; * name = item alias, so we should find items aliases first. if not found then look for "jname" (full name) * @see DBApply */ -static int itemdb_searchname_sub(DBKey key, DBData *data, va_list ap) +int itemdb_searchname_sub(DBKey key, DBData *data, va_list ap) { struct item_data *item = DB->data2ptr(data), **dst, **dst2; char *str; str=va_arg(ap,char *); dst=va_arg(ap,struct item_data **); dst2=va_arg(ap,struct item_data **); - if(item == &dummy_item) return 0; + if(item == &itemdb->dummy) return 0; //Absolute priority to Aegis code name. if (*dst != NULL) return 0; @@ -60,8 +55,8 @@ struct item_data* itemdb_searchname(const char *str) { struct item_data* item2=NULL; int i; - for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) { - item = itemdb_array[i]; + for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) { + item = itemdb->array[i]; if( item == NULL ) continue; @@ -75,7 +70,7 @@ struct item_data* itemdb_searchname(const char *str) { } item = NULL; - itemdb_other->foreach(itemdb_other,itemdb_searchname_sub,str,&item,&item2); + itemdb->other->foreach(itemdb->other,itemdb->searchname_sub,str,&item,&item2); return item?item:item2; } /* name to item data */ @@ -86,12 +81,12 @@ struct item_data* itemdb_name2id(const char *str) { /** * @see DBMatcher */ -static int itemdb_searchname_array_sub(DBKey key, DBData data, va_list ap) +int itemdb_searchname_array_sub(DBKey key, DBData data, va_list ap) { struct item_data *item = DB->data2ptr(&data); char *str; str=va_arg(ap,char *); - if (item == &dummy_item) + if (item == &itemdb->dummy) return 1; //Invalid item. if(stristr(item->jname,str)) return 0; @@ -112,9 +107,9 @@ int itemdb_searchname_array(struct item_data** data, int size, const char *str, int count=0; // Search in the array - for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) + for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) { - item = itemdb_array[i]; + item = itemdb->array[i]; if( item == NULL ) continue; @@ -133,7 +128,7 @@ int itemdb_searchname_array(struct item_data** data, int size, const char *str, DBData *db_data[MAX_SEARCH]; int db_count = 0; size -= count; - db_count = itemdb_other->getall(itemdb_other, (DBData**)&db_data, size, itemdb_searchname_array_sub, str); + db_count = itemdb->other->getall(itemdb->other, (DBData**)&db_data, size, itemdb->searchname_array_sub, str); for (i = 0; i < db_count; i++) data[count++] = DB->data2ptr(db_data[i]); count += db_count; @@ -190,7 +185,7 @@ void itemdb_package_item(struct map_session_data *sd, struct item_package *packa if( package->must_items[i].announce ) clif->package_announce(sd,package->must_items[i].id,package->id); - get_count = itemdb_isstackable(package->must_items[i].id) ? package->must_items[i].qty : 1; + get_count = itemdb->isstackable(package->must_items[i].id) ? package->must_items[i].qty : 1; it.amount = get_count == 1 ? 1 : get_count; @@ -231,7 +226,7 @@ void itemdb_package_item(struct map_session_data *sd, struct item_package *packa if( entry->announce ) clif->package_announce(sd,entry->id,package->id); - get_count = itemdb_isstackable(entry->id) ? entry->qty : 1; + get_count = itemdb->isstackable(entry->id) ? entry->qty : 1; it.amount = get_count == 1 ? 1 : get_count; @@ -274,10 +269,10 @@ struct item_data* itemdb_exists(int nameid) { struct item_data* item; - if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) - return itemdb_array[nameid]; - item = (struct item_data*)idb_get(itemdb_other,nameid); - if( item == &dummy_item ) + if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array) ) + return itemdb->array[nameid]; + item = (struct item_data*)idb_get(itemdb->other,nameid); + if( item == &itemdb->dummy ) return NULL;// dummy data, doesn't exist return item; } @@ -307,7 +302,7 @@ const char* itemdb_typename(int type) * Converts the jobid from the format in itemdb * to the format used by the map server. [Skotlex] *------------------------------------------*/ -static void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask) +void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask) { int i; bclass[0]= bclass[1]= bclass[2]= 0; @@ -373,19 +368,19 @@ static void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask) bclass[1] |= 1<<MAPID_NINJA; } -static void create_dummy_data(void) +void create_dummy_data(void) { - memset(&dummy_item, 0, sizeof(struct item_data)); - dummy_item.nameid=500; - dummy_item.weight=1; - dummy_item.value_sell=1; - dummy_item.type=IT_ETC; //Etc item - safestrncpy(dummy_item.name,"UNKNOWN_ITEM",sizeof(dummy_item.name)); - safestrncpy(dummy_item.jname,"UNKNOWN_ITEM",sizeof(dummy_item.jname)); - dummy_item.view_id=UNKNOWN_ITEM_ID; + memset(&itemdb->dummy, 0, sizeof(struct item_data)); + itemdb->dummy.nameid=500; + itemdb->dummy.weight=1; + itemdb->dummy.value_sell=1; + itemdb->dummy.type=IT_ETC; //Etc item + safestrncpy(itemdb->dummy.name,"UNKNOWN_ITEM",sizeof(itemdb->dummy.name)); + safestrncpy(itemdb->dummy.jname,"UNKNOWN_ITEM",sizeof(itemdb->dummy.jname)); + itemdb->dummy.view_id=UNKNOWN_ITEM_ID; } -static struct item_data* create_item_data(int nameid) +struct item_data* create_item_data(int nameid) { struct item_data *id; CREATE(id, struct item_data, 1); @@ -401,19 +396,19 @@ static struct item_data* create_item_data(int nameid) struct item_data* itemdb_load(int nameid) { struct item_data *id; - if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) + if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array) ) { - id = itemdb_array[nameid]; - if( id == NULL || id == &dummy_item ) - id = itemdb_array[nameid] = create_item_data(nameid); + id = itemdb->array[nameid]; + if( id == NULL || id == &itemdb->dummy ) + id = itemdb->array[nameid] = itemdb->create_item_data(nameid); return id; } - id = (struct item_data*)idb_get(itemdb_other, nameid); - if( id == NULL || id == &dummy_item ) + id = (struct item_data*)idb_get(itemdb->other, nameid); + if( id == NULL || id == &itemdb->dummy ) { - id = create_item_data(nameid); - idb_put(itemdb_other, nameid, id); + id = itemdb->create_item_data(nameid); + idb_put(itemdb->other, nameid, id); } return id; } @@ -424,16 +419,16 @@ struct item_data* itemdb_load(int nameid) { struct item_data* itemdb_search(int nameid) { struct item_data* id; - if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) - id = itemdb_array[nameid]; + if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array) ) + id = itemdb->array[nameid]; else - id = (struct item_data*)idb_get(itemdb_other, nameid); + id = (struct item_data*)idb_get(itemdb->other, nameid); if( id == NULL ) { ShowWarning("itemdb_search: Item ID %d does not exists in the item_db. Using dummy data.\n", nameid); - id = &dummy_item; - dummy_item.nameid = nameid; + id = &itemdb->dummy; + itemdb->dummy.nameid = nameid; } return id; } @@ -546,7 +541,7 @@ int itemdb_canauction_sub(struct item_data* item, int gmlv, int unused) { int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(struct item_data*, int, int)) { - struct item_data* item_data = itemdb_search(item->nameid); + struct item_data* item_data = itemdb->search(item->nameid); int i; if (!func(item_data, gmlv, gmlv2)) @@ -557,7 +552,7 @@ int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(stru for(i = 0; i < item_data->slot; i++) { if (!item->card[i]) continue; - if (!func(itemdb_search(item->card[i]), gmlv, gmlv2)) + if (!func(itemdb->search(item->card[i]), gmlv, gmlv2)) return 0; } return 1; @@ -594,7 +589,7 @@ int itemdb_isidentified2(struct item_data *data) { * Search by name for the override flags available items * (Give item another sprite) *------------------------------------------*/ -static bool itemdb_read_itemavail(char* str[], int columns, int current) +bool itemdb_read_itemavail(char* str[], int columns, int current) {// <nameid>,<sprite> int nameid, sprite; struct item_data *id; @@ -1202,7 +1197,7 @@ void itemdb_read_chains(void) { /*========================================== * Reads item trade restrictions [Skotlex] *------------------------------------------*/ -static bool itemdb_read_itemtrade(char* str[], int columns, int current) +bool itemdb_read_itemtrade(char* str[], int columns, int current) {// <nameid>,<mask>,<gm level> int nameid, flag, gmlv; struct item_data *id; @@ -1239,7 +1234,7 @@ static bool itemdb_read_itemtrade(char* str[], int columns, int current) /*========================================== * Reads item delay amounts [Paradox924X] *------------------------------------------*/ -static bool itemdb_read_itemdelay(char* str[], int columns, int current) +bool itemdb_read_itemdelay(char* str[], int columns, int current) {// <nameid>,<delay> int nameid, delay; struct item_data *id; @@ -1268,7 +1263,7 @@ static bool itemdb_read_itemdelay(char* str[], int columns, int current) /*================================================================== * Reads item stacking restrictions *----------------------------------------------------------------*/ -static bool itemdb_read_stack(char* fields[], int columns, int current) +bool itemdb_read_stack(char* fields[], int columns, int current) {// <item id>,<stack limit amount>,<type> unsigned short nameid, amount; unsigned int type; @@ -1282,7 +1277,7 @@ static bool itemdb_read_stack(char* fields[], int columns, int current) return false; } - if( !itemdb_isstackable2(id) ) + if( !itemdb->isstackable2(id) ) { ShowWarning("itemdb_read_stack: Item id '%hu' is not stackable.\n", nameid); return false; @@ -1307,7 +1302,7 @@ static bool itemdb_read_stack(char* fields[], int columns, int current) /// Reads items allowed to be sold in buying stores -static bool itemdb_read_buyingstore(char* fields[], int columns, int current) +bool itemdb_read_buyingstore(char* fields[], int columns, int current) {// <nameid> int nameid; struct item_data* id; @@ -1320,7 +1315,7 @@ static bool itemdb_read_buyingstore(char* fields[], int columns, int current) return false; } - if( !itemdb_isstackable2(id) ) + if( !itemdb->isstackable2(id) ) { ShowWarning("itemdb_read_buyingstore: Non-stackable item id %d cannot be enabled for buying store.\n", nameid); return false; @@ -1334,7 +1329,7 @@ static bool itemdb_read_buyingstore(char* fields[], int columns, int current) /******************************************* ** Item usage restriction (item_nouse.txt) ********************************************/ -static bool itemdb_read_nouse(char* fields[], int columns, int current) +bool itemdb_read_nouse(char* fields[], int columns, int current) {// <nameid>,<flag>,<override> int nameid, flag, override; struct item_data* id; @@ -1443,7 +1438,7 @@ void itemdb_read_combos() { struct item_data * id = NULL; int idx = 0; - if((retcount = itemdb_combo_split_atoi(str[0], items)) < 2) { + 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); continue; } @@ -1524,7 +1519,7 @@ void itemdb_read_combos() { /*====================================== * Applies gender restrictions according to settings. [Skotlex] *======================================*/ -static int itemdb_gendercheck(struct item_data *id) +int itemdb_gendercheck(struct item_data *id) { if (id->nameid == WEDDING_RING_M) //Grom Ring return 1; @@ -1588,7 +1583,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) } //ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View - id = itemdb_load(nameid); + id = itemdb->load(nameid); safestrncpy(id->name, str[1], sizeof(id->name)); safestrncpy(id->jname, str[2], sizeof(id->jname)); @@ -1637,7 +1632,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) id->matk = atoi(str[8]); offset += 1; } else - itemdb_re_split_atoi(str[7],&id->atk,&id->matk); + itemdb->re_split_atoi(str[7],&id->atk,&id->matk); #else id->atk = atoi(str[7]); #endif @@ -1650,12 +1645,12 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) id->slot = MAX_SLOTS; } - itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11+offset],NULL,0)); + 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; } @@ -1667,7 +1662,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) id->elvmax = atoi(str[17+offset]); offset += 1; } else - itemdb_re_split_atoi(str[16],&id->elv,&id->elvmax); + itemdb->re_split_atoi(str[16],&id->elv,&id->elvmax); #else id->elv = atoi(str[16]); #endif @@ -1676,7 +1671,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) id->flag.available = 1; id->view_id = 0; - id->sex = itemdb_gendercheck(id); //Apply gender filtering. + id->sex = itemdb->gendercheck(id); //Apply gender filtering. if (id->script) { script->free_code(id->script); @@ -1705,7 +1700,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) * Reading item from item db * item_db2 overwriting item_db *------------------------------------------*/ -static int itemdb_readdb(void) +int itemdb_readdb(void) { const char* filename[] = { DBPATH"item_db.txt", @@ -1831,7 +1826,7 @@ static int itemdb_readdb(void) /*====================================== * item_db table reading *======================================*/ -static int itemdb_read_sqldb(void) { +int itemdb_read_sqldb(void) { const char* item_db_name[] = { #ifdef RENEWAL @@ -1914,7 +1909,7 @@ int itemdb_uid_load() { } SQL->GetData(mmysql_handle, 0, &uid, NULL); - itemdb_unique_id(1, (uint64)strtoull(uid, NULL, 10)); + itemdb->unique_id(1, (uint64)strtoull(uid, NULL, 10)); SQL->FreeResult(mmysql_handle); return 0; @@ -1923,37 +1918,37 @@ int itemdb_uid_load() { /*==================================== * read all item-related databases *------------------------------------*/ -static void itemdb_read(void) { +void itemdb_read(void) { int i; DBData prev; if (iMap->db_use_sql_item_db) - itemdb_read_sqldb(); + itemdb->read_sqldb(); else - itemdb_readdb(); + itemdb->readdb(); - for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) { - if( itemdb_array[i] ) { - if( itemdb->names->put(itemdb->names,DB->str2key(itemdb_array[i]->name),DB->ptr2data(itemdb_array[i]),&prev) ) { + for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) { + if( itemdb->array[i] ) { + if( itemdb->names->put(itemdb->names,DB->str2key(itemdb->array[i]->name),DB->ptr2data(itemdb->array[i]),&prev) ) { struct item_data *data = DB->data2ptr(&prev); - ShowError("itemdb_read: duplicate AegisName '%s' in item ID %d and %d\n",itemdb_array[i]->name,itemdb_array[i]->nameid,data->nameid); + ShowError("itemdb_read: duplicate AegisName '%s' in item ID %d and %d\n",itemdb->array[i]->name,itemdb->array[i]->nameid,data->nameid); } } } - itemdb_read_combos(); + itemdb->read_combos(); itemdb->read_groups(); itemdb->read_chains(); itemdb->read_packages(); - sv->readdb(iMap->db_path, "item_avail.txt", ',', 2, 2, -1, &itemdb_read_itemavail); - sv->readdb(iMap->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade); - sv->readdb(iMap->db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay); - sv->readdb(iMap->db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack); - sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); - sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse); + sv->readdb(iMap->db_path, "item_avail.txt", ',', 2, 2, -1, itemdb->read_itemavail); + sv->readdb(iMap->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, itemdb->read_itemtrade); + sv->readdb(iMap->db_path, "item_delay.txt", ',', 2, 2, -1, itemdb->read_itemdelay); + sv->readdb(iMap->db_path, "item_stack.txt", ',', 3, 3, -1, itemdb->read_stack); + sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, itemdb->read_buyingstore); + sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, itemdb->read_nouse); - itemdb_uid_load(); + itemdb->uid_load(); } /*========================================== @@ -1961,7 +1956,7 @@ static void itemdb_read(void) { *------------------------------------------*/ /// Destroys the item_data. -static void destroy_item_data(struct item_data* self, int free_self) +void destroy_item_data(struct item_data* self, int free_self) { if( self == NULL ) return; @@ -1995,12 +1990,12 @@ static void destroy_item_data(struct item_data* self, int free_self) /** * @see DBApply */ -static int itemdb_final_sub(DBKey key, DBData *data, va_list ap) +int itemdb_final_sub(DBKey key, DBData *data, va_list ap) { struct item_data *id = DB->data2ptr(data); - if( id != &dummy_item ) - destroy_item_data(id, 1); + if( id != &itemdb->dummy ) + itemdb->destroy_item_data(id, 1); return 0; } @@ -2012,9 +2007,9 @@ void itemdb_reload(void) { int i,d,k; // clear the previous itemdb data - for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) - if( itemdb_array[i] ) - destroy_item_data(itemdb_array[i], 1); + for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) + if( itemdb->array[i] ) + itemdb->destroy_item_data(itemdb->array[i], 1); for( i = 0; i < itemdb->group_count; i++ ) { if( itemdb->groups[i].nameid ) @@ -2054,14 +2049,14 @@ void itemdb_reload(void) { itemdb->packages = NULL; itemdb->package_count = 0; - itemdb_other->clear(itemdb_other, itemdb_final_sub); + itemdb->other->clear(itemdb->other, itemdb->final_sub); - memset(itemdb_array, 0, sizeof(itemdb_array)); + memset(itemdb->array, 0, sizeof(itemdb->array)); db_clear(itemdb->names); // read new data - itemdb_read(); + itemdb->read(); //Epoque's awesome @reloaditemdb fix - thanks! [Ind] //- Fixes the need of a @reloadmobdb after a @reloaditemdb to re-link monster drop data @@ -2074,7 +2069,7 @@ void itemdb_reload(void) { struct item_data *id; if( !entry->dropitem[d].nameid ) continue; - id = itemdb_search(entry->dropitem[d].nameid); + id = itemdb->search(entry->dropitem[d].nameid); for (k = 0; k < MAX_SEARCH; k++) { if (id->mob[k].chance <= entry->dropitem[d].p) @@ -2132,9 +2127,9 @@ void itemdb_force_name_constants(void) { void do_final_itemdb(void) { int i; - for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) - if( itemdb_array[i] ) - destroy_item_data(itemdb_array[i], 1); + for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) + if( itemdb->array[i] ) + itemdb->destroy_item_data(itemdb->array[i], 1); for( i = 0; i < itemdb->group_count; i++ ) { if( itemdb->groups[i].nameid ) @@ -2165,26 +2160,25 @@ void do_final_itemdb(void) { if( itemdb->packages ) aFree(itemdb->packages); - itemdb_other->destroy(itemdb_other, itemdb_final_sub); - destroy_item_data(&dummy_item, 0); + itemdb->other->destroy(itemdb->other, itemdb->final_sub); + itemdb->destroy_item_data(&itemdb->dummy, 0); db_destroy(itemdb->names); } void do_init_itemdb(void) { - memset(itemdb_array, 0, sizeof(itemdb_array)); - itemdb_other = idb_alloc(DB_OPT_BASE); + memset(itemdb->array, 0, sizeof(itemdb->array)); + itemdb->other = idb_alloc(DB_OPT_BASE); itemdb->names = strdb_alloc(DB_OPT_BASE,ITEM_NAME_LENGTH); - create_dummy_data(); //Dummy data item. - itemdb_read(); + itemdb->create_dummy_data(); //Dummy data item. + itemdb->read(); clif->cashshop_load(); } -/* incomplete */ void itemdb_defaults(void) { itemdb = &itemdb_s; itemdb->init = do_init_itemdb; itemdb->final = do_final_itemdb; - itemdb->reload = itemdb_reload;//incomplete + itemdb->reload = itemdb_reload; itemdb->name_constants = itemdb_name_constants; itemdb->force_name_constants = itemdb_force_name_constants; /* */ @@ -2199,6 +2193,10 @@ void itemdb_defaults(void) { /* */ itemdb->names = NULL; /* */ + /* itemdb->array is cleared on itemdb->init() */ + itemdb->other = NULL; + memset(&itemdb->dummy, 0, sizeof(struct item_data)); + /* */ itemdb->read_groups = itemdb_read_groups; itemdb->read_chains = itemdb_read_chains; itemdb->read_packages = itemdb_read_packages; @@ -2212,9 +2210,49 @@ void itemdb_defaults(void) { itemdb->load = itemdb_load; itemdb->search = itemdb_search; itemdb->parse_dbrow = itemdb_parse_dbrow; - itemdb->exists = itemdb_exists;//incomplete + itemdb->exists = itemdb_exists; itemdb->in_group = itemdb_in_group; itemdb->group_item = itemdb_searchrandomid; itemdb->chain_item = itemdb_chain_item; itemdb->package_item = itemdb_package_item; + itemdb->searchname_sub = itemdb_searchname_sub; + itemdb->searchname_array_sub = itemdb_searchname_array_sub; + itemdb->searchrandomid = itemdb_searchrandomid; + itemdb->typename = itemdb_typename; + itemdb->jobid2mapid = itemdb_jobid2mapid; + itemdb->create_dummy_data = create_dummy_data; + itemdb->create_item_data = create_item_data; + itemdb->isequip = itemdb_isequip; + itemdb->isequip2 = itemdb_isequip2; + itemdb->isstackable = itemdb_isstackable; + itemdb->isstackable2 = itemdb_isstackable2; + itemdb->isdropable_sub = itemdb_isdropable_sub; + itemdb->cantrade_sub = itemdb_cantrade_sub; + itemdb->canpartnertrade_sub = itemdb_canpartnertrade_sub; + itemdb->cansell_sub = itemdb_cansell_sub; + itemdb->cancartstore_sub = itemdb_cancartstore_sub; + itemdb->canstore_sub = itemdb_canstore_sub; + itemdb->canguildstore_sub = itemdb_canguildstore_sub; + itemdb->canmail_sub = itemdb_canmail_sub; + itemdb->canauction_sub = itemdb_canauction_sub; + itemdb->isrestricted = itemdb_isrestricted; + itemdb->isidentified = itemdb_isidentified; + itemdb->isidentified2 = itemdb_isidentified2; + itemdb->read_itemavail = itemdb_read_itemavail; + itemdb->read_itemtrade = itemdb_read_itemtrade; + itemdb->read_itemdelay = itemdb_read_itemdelay; + itemdb->read_stack = itemdb_read_stack; + itemdb->read_buyingstore = itemdb_read_buyingstore; + itemdb->read_nouse = itemdb_read_nouse; + itemdb->combo_split_atoi = itemdb_combo_split_atoi; + itemdb->read_combos = itemdb_read_combos; + itemdb->gendercheck = itemdb_gendercheck; + itemdb->re_split_atoi = itemdb_re_split_atoi; + itemdb->readdb = itemdb_readdb; + itemdb->read_sqldb = itemdb_read_sqldb; + itemdb->unique_id = itemdb_unique_id; + itemdb->uid_load = itemdb_uid_load; + itemdb->read = itemdb_read; + itemdb->destroy_item_data = destroy_item_data; + itemdb->final_sub = itemdb_final_sub; } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 126ba6334..fe67ebbef 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -240,41 +240,21 @@ struct item_package { #define itemdb_iscashfood(id) ( (id) >= 12202 && (id) <= 12207 ) #define itemdb_is_GNbomb(n) (n >= 13260 && n <= 13267) #define itemdb_is_GNthrowable(n) (n >= 13268 && n <= 13290) -const char* itemdb_typename(int type); #define itemdb_value_buy(n) itemdb->search(n)->value_buy #define itemdb_value_sell(n) itemdb->search(n)->value_sell #define itemdb_canrefine(n) (!itemdb->search(n)->flag.no_refine) //Item trade restrictions [Skotlex] -int itemdb_isdropable_sub(struct item_data *, int, int); -int itemdb_cantrade_sub(struct item_data*, int, int); -int itemdb_canpartnertrade_sub(struct item_data*, int, int); -int itemdb_cansell_sub(struct item_data*,int, int); -int itemdb_cancartstore_sub(struct item_data*, int, int); -int itemdb_canstore_sub(struct item_data*, int, int); -int itemdb_canguildstore_sub(struct item_data*, int, int); -int itemdb_canmail_sub(struct item_data*, int, int); -int itemdb_canauction_sub(struct item_data*, int, int); -int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(struct item_data*, int, int)); -#define itemdb_isdropable(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_isdropable_sub) -#define itemdb_cantrade(item, gmlv, gmlv2) itemdb_isrestricted(item, gmlv, gmlv2, itemdb_cantrade_sub) -#define itemdb_canpartnertrade(item, gmlv, gmlv2) itemdb_isrestricted(item, gmlv, gmlv2, itemdb_canpartnertrade_sub) -#define itemdb_cansell(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_cansell_sub) -#define itemdb_cancartstore(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_cancartstore_sub) -#define itemdb_canstore(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_canstore_sub) -#define itemdb_canguildstore(item, gmlv) itemdb_isrestricted(item , gmlv, 0, itemdb_canguildstore_sub) -#define itemdb_canmail(item, gmlv) itemdb_isrestricted(item , gmlv, 0, itemdb_canmail_sub) -#define itemdb_canauction(item, gmlv) itemdb_isrestricted(item , gmlv, 0, itemdb_canauction_sub) +#define itemdb_isdropable(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->isdropable_sub) +#define itemdb_cantrade(item, gmlv, gmlv2) itemdb->isrestricted(item, gmlv, gmlv2, itemdb->cantrade_sub) +#define itemdb_canpartnertrade(item, gmlv, gmlv2) itemdb->isrestricted(item, gmlv, gmlv2, itemdb->canpartnertrade_sub) +#define itemdb_cansell(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->cansell_sub) +#define itemdb_cancartstore(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->cancartstore_sub) +#define itemdb_canstore(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->canstore_sub) +#define itemdb_canguildstore(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canguildstore_sub) +#define itemdb_canmail(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canmail_sub) +#define itemdb_canauction(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canauction_sub) -int itemdb_isequip(int); -int itemdb_isequip2(struct item_data *); -int itemdb_isidentified(int); -int itemdb_isidentified2(struct item_data *data); -int itemdb_isstackable(int); -int itemdb_isstackable2(struct item_data *); -uint64 itemdb_unique_id(int8 flag, int64 value); // Unique Item ID - -/* incomplete */ struct itemdb_interface { void (*init) (void); void (*final) (void); @@ -294,6 +274,10 @@ struct itemdb_interface { /* */ DBMap *names; /* */ + struct item_data *array[MAX_ITEMDB]; + DBMap *other;// int nameid -> struct item_data* + struct item_data dummy; //This is the default dummy item used for non-existant items. [Skotlex] + /* */ void (*read_groups) (void); void (*read_chains) (void); void (*read_packages) (void); @@ -312,6 +296,46 @@ struct itemdb_interface { int (*group_item) (struct item_group *group); int (*chain_item) (unsigned short chain_id, int *rate); void (*package_item) (struct map_session_data *sd, struct item_package *package); + int (*searchname_sub) (DBKey key, DBData *data, va_list ap); + int (*searchname_array_sub) (DBKey key, DBData data, va_list ap); + int (*searchrandomid) (struct item_group *group); + const char* (*typename) (int type); + void (*jobid2mapid) (unsigned int *bclass, unsigned int jobmask); + void (*create_dummy_data) (void); + struct item_data* (*create_item_data) (int nameid); + int (*isequip) (int nameid); + int (*isequip2) (struct item_data *data); + int (*isstackable) (int nameid); + int (*isstackable2) (struct item_data *data); + int (*isdropable_sub) (struct item_data *item, int gmlv, int unused); + int (*cantrade_sub) (struct item_data *item, int gmlv, int gmlv2); + int (*canpartnertrade_sub) (struct item_data *item, int gmlv, int gmlv2); + int (*cansell_sub) (struct item_data *item, int gmlv, int unused); + int (*cancartstore_sub) (struct item_data *item, int gmlv, int unused); + int (*canstore_sub) (struct item_data *item, int gmlv, int unused); + int (*canguildstore_sub) (struct item_data *item, int gmlv, int unused); + int (*canmail_sub) (struct item_data *item, int gmlv, int unused); + int (*canauction_sub) (struct item_data *item, int gmlv, int unused); + int (*isrestricted) (struct item *item, int gmlv, int gmlv2, int(*func)(struct item_data *, int, int)); + int (*isidentified) (int nameid); + int (*isidentified2) (struct item_data *data); + bool (*read_itemavail) (char *str[], int columns, int current); + bool (*read_itemtrade) (char *str[], int columns, int current); + bool (*read_itemdelay) (char *str[], int columns, int current); + bool (*read_stack) (char *fields[], int columns, int current); + bool (*read_buyingstore) (char *fields[], int columns, int current); + bool (*read_nouse) (char *fields[], int columns, int current); + int (*combo_split_atoi) (char *str, int *val); + void (*read_combos) (); + int (*gendercheck) (struct item_data *id); + void (*re_split_atoi) (char *str, int *atk, int *matk); + int (*readdb) (void); + int (*read_sqldb) (void); + uint64 (*unique_id) (int8 flag, int64 value); + int (*uid_load) (); + void (*read) (void); + void (*destroy_item_data) (struct item_data *self, int free_self); + int (*final_sub) (DBKey key, DBData *data, va_list ap); }; struct itemdb_interface *itemdb; diff --git a/src/map/map.c b/src/map/map.c index 5cc475ad7..a1c78f35b 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1540,7 +1540,7 @@ int map_quit(struct map_session_data *sd) { npc->event_dequeue(sd); if( sd->bg_id && !sd->bg_queue.arena ) /* TODO: dump this chunk after bg_queue is fully enabled */ - bg_team_leave(sd,1); + bg->team_leave(sd,1); skill->cooldown_save(sd); pc->itemcd_do(sd,false); @@ -4951,7 +4951,7 @@ void do_final(void) skill->final(); iStatus->do_final_status(); unit->final(); - do_final_battleground(); + bg->final(); iDuel->do_final_duel(); elemental->do_final_elemental(); do_final_maps(); @@ -5427,7 +5427,7 @@ int do_init(int argc, char *argv[]) quest->init(); npc->init(); unit->init(); - do_init_battleground(); + bg->init(); iDuel->do_init_duel(); vending->init(); diff --git a/src/map/mob.c b/src/map/mob.c index 3b3ff0797..146f82239 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1786,7 +1786,7 @@ struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) { memset(&drop->item_data, 0, sizeof(struct item)); drop->item_data.nameid = nameid; drop->item_data.amount = qty; - drop->item_data.identify = data ? itemdb_isidentified2(data) : itemdb_isidentified(nameid); + drop->item_data.identify = data ? itemdb->isidentified2(data) : itemdb->isidentified(nameid); drop->next = NULL; return drop; } @@ -2513,7 +2513,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) memset(&item,0,sizeof(item)); item.nameid=mdrop_id[i]; - item.identify= itemdb_isidentified2(data); + item.identify= itemdb->isidentified2(data); clif->mvp_item(mvp_sd,item.nameid); log_mvp[0] = item.nameid; diff --git a/src/map/npc.c b/src/map/npc.c index bb3a4b38e..13a625f07 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1296,7 +1296,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns if( j == nd->u.shop.count || nd->u.shop.shop_item[j].value <= 0 ) return 5; - if( !itemdb_isstackable(nameid) && amount > 1 ) + if( !itemdb->isstackable(nameid) && amount > 1 ) { ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); amount = item_list[i*2+0] = 1; @@ -1402,7 +1402,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po if( nd->u.shop.shop_item[i].value <= 0 ) return 5; - if(!itemdb_isstackable(nameid) && amount > 1) + if(!itemdb->isstackable(nameid) && amount > 1) { ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); @@ -1495,7 +1495,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) if( !itemdb->exists(nameid) ) return 3; // item no longer in itemdb - if( !itemdb_isstackable(nameid) && amount > 1 ) { + if( !itemdb->isstackable(nameid) && amount > 1 ) { //Exploit? You can't buy more than 1 of equipment types o.O ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); @@ -1605,7 +1605,7 @@ int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_li script->setarray_pc(sd, "@sold_nameid", i, (void*)(intptr_t)sd->status.inventory[idx].nameid, &key_nameid); script->setarray_pc(sd, "@sold_quantity", i, (void*)(intptr_t)item_list[i*2+1], &key_amount); - if( itemdb_isequip(sd->status.inventory[idx].nameid) ) + if( itemdb->isequip(sd->status.inventory[idx].nameid) ) {// process equipment based information into the arrays script->setarray_pc(sd, "@sold_refine", i, (void*)(intptr_t)sd->status.inventory[idx].refine, &key_refine); script->setarray_pc(sd, "@sold_attribute", i, (void*)(intptr_t)sd->status.inventory[idx].attribute, &key_attribute); diff --git a/src/map/pc.c b/src/map/pc.c index dc52c88e1..b8380a840 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -652,7 +652,7 @@ int pc_equippoint(struct map_session_data *sd,int n) if(!sd->inventory_data[n]) return 0; - if (!itemdb_isequip2(sd->inventory_data[n])) + if (!itemdb->isequip2(sd->inventory_data[n])) return 0; //Not equippable by players. ep = sd->inventory_data[n]->equip; @@ -3699,7 +3699,7 @@ int pc_checkadditem(struct map_session_data *sd,int nameid,int amount) data = itemdb->search(nameid); - if(!itemdb_isstackable2(data)) + if(!itemdb->isstackable2(data)) return ADDITEM_NEW; if( data->stack.inventory && amount > data->stack.amount ) @@ -3945,7 +3945,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l i = MAX_INVENTORY; - if( itemdb_isstackable2(data) && item_data->expire_time == 0 ) + if( itemdb->isstackable2(data) && item_data->expire_time == 0 ) { // Stackable | Non Rental for( i = 0; i < MAX_INVENTORY; i++ ) { @@ -3976,8 +3976,8 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l clif->additem(sd,i,amount,0); } #ifdef NSI_UNIQUE_ID - if( !itemdb_isstackable2(data) && !item_data->unique_id ) - sd->status.inventory[i].unique_id = itemdb_unique_id(0,0); + if( !itemdb->isstackable2(data) && !item_data->unique_id ) + sd->status.inventory[i].unique_id = itemdb->unique_id(0,0); #endif logs->pick_pc(sd, log_type, amount, &sd->status.inventory[i],sd->inventory_data[i]); @@ -4517,7 +4517,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun return 1; i = MAX_CART; - if( itemdb_isstackable2(data) && !item_data->expire_time ) + if( itemdb->isstackable2(data) && !item_data->expire_time ) { ARR_FIND( 0, MAX_CART, i, sd->status.cart[i].nameid == item_data->nameid && @@ -4731,7 +4731,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = itemid; tmp_item.amount = 1; - tmp_item.identify = itemdb_isidentified2(data); + tmp_item.identify = itemdb->isidentified2(data); flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER); //TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise? @@ -4908,7 +4908,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y skill->clear_unitgroup(&sd->bl); party->send_dot_remove(sd); //minimap dot fix [Kevin] guild->send_dot_remove(sd); - bg_send_dot_remove(sd); + bg->send_dot_remove(sd); if (sd->regen.state.gc) sd->regen.state.gc = 0; // make sure vending is allowed here @@ -6656,7 +6656,7 @@ void pc_respawn(struct map_session_data* sd, clr_type clrtype) { if( !pc_isdead(sd) ) return; // not applicable - if( sd->bg_id && bg_member_respawn(sd) ) + if( sd->bg_id && bg->member_respawn(sd) ) return; // member revived by battleground pc->setstand(sd); @@ -6761,9 +6761,9 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { pc->setparam(sd, SP_KILLERRID, src?src->id:0); if( sd->bg_id ) {/* TODO: purge when bgqueue is deemed ok */ - struct battleground_data *bg; - if( (bg = bg_team_search(sd->bg_id)) != NULL && bg->die_event[0] ) - npc->event(sd, bg->die_event, 0); + struct battleground_data *bgd; + if( (bgd = bg->team_search(sd->bg_id)) != NULL && bgd->die_event[0] ) + npc->event(sd, bgd->die_event, 0); } for( i = 0; i < sd->queues_count; i++ ) { @@ -7036,8 +7036,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { iTimer->add_timer(tick+1, pc_respawn_timer, sd->bl.id, 0); return 1|8; } else if( sd->bg_id ) { - struct battleground_data *bg = bg_team_search(sd->bg_id); - if( bg && bg->mapindex > 0 ) { // Respawn by BG + struct battleground_data *bgd = bg->team_search(sd->bg_id); + if( bgd && bgd->mapindex > 0 ) { // Respawn by BG iTimer->add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0); return 1|8; } diff --git a/src/map/script.c b/src/map/script.c index bf8e81cbd..7ac638848 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5759,7 +5759,7 @@ BUILDIN(checkweight) // item is already in inventory, but there is still space for the requested amount break; case ADDITEM_NEW: - if( itemdb_isstackable(nameid) ) {// stackable + if( itemdb->isstackable(nameid) ) {// stackable amount2++; if( slots < amount2 ) { script_pushint(st,0); @@ -5864,7 +5864,7 @@ BUILDIN(checkweight2) // item is already in inventory, but there is still space for the requested amount break; case ADDITEM_NEW: - if( itemdb_isstackable(nameid) ){// stackable + if( itemdb->isstackable(nameid) ){// stackable amount2++; if( slots < amount2 ) fail = 1; @@ -5932,7 +5932,7 @@ BUILDIN(getitem) if(!flag) it.identify=1; else - it.identify=itemdb_isidentified2(item_data); + it.identify=itemdb->isidentified2(item_data); if( script_hasdata(st,4) ) sd=iMap->id2sd(script_getnum(st,4)); // <Account ID> @@ -5943,7 +5943,7 @@ BUILDIN(getitem) return true; //Check if it's stackable. - if (!itemdb_isstackable(nameid)) + if (!itemdb->isstackable(nameid)) get_count = 1; else get_count = amount; @@ -6041,7 +6041,7 @@ BUILDIN(getitem2) item_tmp.card[3]=(short)c4; //Check if it's stackable. - if (!itemdb_isstackable(nameid)) + if (!itemdb->isstackable(nameid)) get_count = 1; else get_count = amount; @@ -6157,7 +6157,7 @@ BUILDIN(getnameditem) }else nameid = script->conv_num(st,data); - if(!itemdb->exists(nameid)/* || itemdb_isstackable(nameid)*/) + if(!itemdb->exists(nameid)/* || itemdb->isstackable(nameid)*/) { //Even though named stackable items "could" be risky, they are required for certain quests. script_pushint(st,0); return true; @@ -6275,7 +6275,7 @@ BUILDIN(makeitem) if(!flag) item_tmp.identify=1; else - item_tmp.identify=itemdb_isidentified2(item_data); + item_tmp.identify=itemdb->isidentified2(item_data); iMap->addflooritem(&item_tmp,amount,m,x,y,0,0,0,0); @@ -13220,7 +13220,7 @@ BUILDIN(autoequip) return false; } - if( !itemdb_isequip2(item_data) ) + if( !itemdb->isequip2(item_data) ) { ShowError("buildin_autoequip: Item '%d' cannot be equipped.\n", nameid); return false; @@ -15747,7 +15747,7 @@ BUILDIN(waitingroom2bg) ev = script_getstr(st,5); // Logout Event dev = script_getstr(st,6); // Die Event - if( (bg_id = bg_create(mapindex, x, y, ev, dev)) == 0 ) + if( (bg_id = bg->create(mapindex, x, y, ev, dev)) == 0 ) { // Creation failed script_pushint(st,0); return true; @@ -15756,7 +15756,7 @@ BUILDIN(waitingroom2bg) n = cd->users; for( i = 0; i < n && i < MAX_BG_MEMBERS; i++ ) { - if( (sd = cd->usersd[i]) != NULL && bg_team_join(bg_id, sd) ) + if( (sd = cd->usersd[i]) != NULL && bg->team_join(bg_id, sd) ) mapreg->setreg(reference_uid(script->add_str("$@arenamembers"), i), sd->bl.id); else mapreg->setreg(reference_uid(script->add_str("$@arenamembers"), i), 0); @@ -15790,7 +15790,7 @@ BUILDIN(waitingroom2bg_single) if( (sd = cd->usersd[0]) == NULL ) return true; - if( bg_team_join(bg_id, sd) ) + if( bg->team_join(bg_id, sd) ) { pc->setpos(sd, mapindex, x, y, CLR_TELEPORT); script_pushint(st,1); @@ -15803,15 +15803,15 @@ BUILDIN(waitingroom2bg_single) BUILDIN(bg_team_setxy) { - struct battleground_data *bg; + struct battleground_data *bgd; int bg_id; bg_id = script_getnum(st,2); - if( (bg = bg_team_search(bg_id)) == NULL ) + if( (bgd = bg->team_search(bg_id)) == NULL ) return true; - bg->x = script_getnum(st,3); - bg->y = script_getnum(st,4); + bgd->x = script_getnum(st,3); + bgd->y = script_getnum(st,4); return true; } @@ -15826,7 +15826,7 @@ BUILDIN(bg_warp) return true; // Invalid Map x = script_getnum(st,4); y = script_getnum(st,5); - bg_team_warp(bg_id, mapindex, x, y); + bg->team_warp(bg_id, mapindex, x, y); return true; } @@ -15873,14 +15873,14 @@ BUILDIN(bg_leave) if( sd == NULL || !sd->bg_id ) return true; - bg_team_leave(sd,0); + bg->team_leave(sd,0); return true; } BUILDIN(bg_destroy) { int bg_id = script_getnum(st,2); - bg_team_delete(bg_id); + bg->team_delete(bg_id); return true; } @@ -15890,13 +15890,13 @@ BUILDIN(bg_getareausers) int16 m, x0, y0, x1, y1; int bg_id; int i = 0, c = 0; - struct battleground_data *bg = NULL; + struct battleground_data *bgd = NULL; struct map_session_data *sd; bg_id = script_getnum(st,2); str = script_getstr(st,3); - if( (bg = bg_team_search(bg_id)) == NULL || (m = iMap->mapname2mapid(str)) < 0 ) + if( (bgd = bg->team_search(bg_id)) == NULL || (m = iMap->mapname2mapid(str)) < 0 ) { script_pushint(st,0); return true; @@ -15909,7 +15909,7 @@ BUILDIN(bg_getareausers) for( i = 0; i < MAX_BG_MEMBERS; i++ ) { - if( (sd = bg->members[i].sd) == NULL ) + if( (sd = bgd->members[i].sd) == NULL ) continue; if( sd->bl.m != m || sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1 ) continue; @@ -15938,11 +15938,11 @@ BUILDIN(bg_updatescore) BUILDIN(bg_get_data) { - struct battleground_data *bg; + struct battleground_data *bgd; int bg_id = script_getnum(st,2), type = script_getnum(st,3); - if( (bg = bg_team_search(bg_id)) == NULL ) + if( (bgd = bg->team_search(bg_id)) == NULL ) { script_pushint(st,0); return true; @@ -15950,7 +15950,7 @@ BUILDIN(bg_get_data) switch( type ) { - case 0: script_pushint(st, bg->count); break; + case 0: script_pushint(st, bgd->count); break; default: ShowError("script:bg_get_data: unknown data identifier %d\n", type); break; @@ -17037,9 +17037,9 @@ BUILDIN(getrandgroupitem) { nameid = itemdb->group_item(data->group); it.nameid = nameid; - it.identify = itemdb_isidentified(nameid); + it.identify = itemdb->isidentified(nameid); - if (!itemdb_isstackable(nameid)) + if (!itemdb->isstackable(nameid)) get_count = 1; else get_count = count; @@ -17545,7 +17545,7 @@ BUILDIN(bg_create_team) { x = script_getnum(st,3); y = script_getnum(st,4); - if( (bg_id = bg_create(mapindex, x, y, ev, dev)) == 0 ) { // Creation failed + if( (bg_id = bg->create(mapindex, x, y, ev, dev)) == 0 ) { // Creation failed script_pushint(st,-1); } else script_pushint(st,bg_id); @@ -17568,7 +17568,7 @@ BUILDIN(bg_join_team) { if( !sd ) script_pushint(st, 1); else - script_pushint(st,bg_team_join(team_id, sd)?0:1); + script_pushint(st,bg->team_join(team_id, sd)?0:1); return true; } diff --git a/src/map/skill.c b/src/map/skill.c index ecd672319..6ec9d2fec 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -15276,7 +15276,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, group->src_id = src->id; group->party_id = iStatus->get_party_id(src); group->guild_id = iStatus->get_guild_id(src); - group->bg_id = bg_team_get_id(src); + group->bg_id = bg->team_get_id(src); group->group_id = skill_get_new_group_id(); group->unit = (struct skill_unit *)aCalloc(count,sizeof(struct skill_unit)); group->unit_count = count; @@ -16125,7 +16125,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, }while( j>=0 && x>0 ); } - if( (equip = (itemdb_isequip(nameid) && skill_id != GN_CHANGEMATERIAL && skill_id != GN_MAKEBOMB )) ) + if( (equip = (itemdb->isequip(nameid) && skill_id != GN_CHANGEMATERIAL && skill_id != GN_MAKEBOMB )) ) wlv = itemdb_wlv(nameid); if(!equip) { switch(skill_id){ diff --git a/src/map/storage.c b/src/map/storage.c index 81d746cc8..2fe7607c3 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -152,7 +152,7 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo return 1; } - if( itemdb_isstackable2(data) ) + if( itemdb->isstackable2(data) ) {//Stackable for( i = 0; i < MAX_STORAGE; i++ ) { @@ -448,7 +448,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto return 1; } - if(itemdb_isstackable2(data)){ //Stackable + if(itemdb->isstackable2(data)){ //Stackable for(i=0;i<MAX_GUILD_STORAGE;i++){ if(compare_item(&stor->items[i], item_data)) { if( amount > MAX_AMOUNT - stor->items[i].amount || ( data->stack.guildstorage && amount > data->stack.amount - stor->items[i].amount ) ) diff --git a/src/map/trade.c b/src/map/trade.c index 9bf63c428..3134fa3e4 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -261,7 +261,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) data = itemdb->search(inventory[n].nameid); i = MAX_INVENTORY; - if (itemdb_isstackable2(data)) { //Stackable item. + if (itemdb->isstackable2(data)) { //Stackable item. for(i = 0; i < MAX_INVENTORY; i++) if (inventory2[i].nameid == inventory[n].nameid && inventory2[i].card[0] == inventory[n].card[0] && inventory2[i].card[1] == inventory[n].card[1] && @@ -292,7 +292,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) // search if it's possible to add item (for full inventory) data = itemdb->search(inventory2[n].nameid); i = MAX_INVENTORY; - if (itemdb_isstackable2(data)) { + if (itemdb->isstackable2(data)) { for(i = 0; i < MAX_INVENTORY; i++) if (inventory[i].nameid == inventory2[n].nameid && inventory[i].card[0] == inventory2[n].card[0] && inventory[i].card[1] == inventory2[n].card[1] && diff --git a/src/map/unit.c b/src/map/unit.c index ee9920e4b..0551baaea 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2185,7 +2185,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i } party->send_dot_remove(sd);//minimap dot fix [Kevin] guild->send_dot_remove(sd); - bg_send_dot_remove(sd); + bg->send_dot_remove(sd); if( map[bl->m].users <= 0 || sd->state.debug_remove_map ) {// this is only place where map users is decreased, if the mobs were removed too soon then this function was executed too many times [FlavioJS] |