From 051e92e4246634d256651903c8c097a89857fba8 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Wed, 26 Jun 2013 15:29:15 -0700 Subject: Hopefully don't crash --- src/map/atcommand.cpp | 30 +++---- src/map/battle.cpp | 2 - src/map/battle.hpp | 1 - src/map/clif.cpp | 239 +++++++++----------------------------------------- src/map/itemdb.cpp | 119 ------------------------- src/map/itemdb.hpp | 31 ------- src/map/map.hpp | 2 +- src/map/pc.cpp | 62 +------------ 8 files changed, 57 insertions(+), 429 deletions(-) diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 5bb4d5f..1926f83 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -666,7 +666,7 @@ int atcommand_charwarp(const int fd, dumb_ptr sd, "You are not authorised to warp someone to this map."); return -1; } - if (pl_sd->bl_m != nullptr && pl_sd->bl_m->flag.nowarp + if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, @@ -741,7 +741,7 @@ int atcommand_warp(const int fd, dumb_ptr sd, "You are not authorised to warp you to this map."); return -1; } - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, @@ -816,14 +816,14 @@ int atcommand_goto(const int fd, dumb_ptr sd, if ((pl_sd = map_nick2sd(character)) != NULL) { - if (pl_sd->bl_m != nullptr && pl_sd->bl_m->flag.nowarpto + if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you to the map of this player."); return -1; } - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, @@ -859,14 +859,14 @@ int atcommand_jump(const int fd, dumb_ptr sd, y = random_::in(1, 399); if (x > 0 && x < 800 && y > 0 && y < 800) { - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarpto + if (sd->bl_m && sd->bl_m->flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you to your actual map."); return -1; } - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, @@ -1274,7 +1274,7 @@ int atcommand_load(const int fd, dumb_ptr sd, "You are not authorised to warp you to your save map."); return -1; } - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, @@ -2517,14 +2517,14 @@ int atcommand_recall(const int fd, dumb_ptr sd, { if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarpto + if (sd->bl_m && sd->bl_m->flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map."); return -1; } - if (pl_sd->bl_m != nullptr && pl_sd->bl_m->flag.nowarp + if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, @@ -4156,7 +4156,7 @@ int atcommand_recallall(const int fd, dumb_ptr sd, { int count; - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarpto + if (sd->bl_m && sd->bl_m->flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, @@ -4176,7 +4176,7 @@ int atcommand_recallall(const int fd, dumb_ptr sd, && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level - if (pl_sd->bl_m != nullptr && pl_sd->bl_m->flag.nowarp + if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) count++; else @@ -4214,7 +4214,7 @@ int atcommand_partyrecall(const int fd, dumb_ptr sd, return -1; } - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarpto + if (sd->bl_m && sd->bl_m->flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, @@ -4235,7 +4235,7 @@ int atcommand_partyrecall(const int fd, dumb_ptr sd, && sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party_id) { - if (pl_sd->bl_m != nullptr && pl_sd->bl_m->flag.nowarp + if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) count++; else @@ -5931,14 +5931,14 @@ int atcommand_jump_iterate(const int fd, dumb_ptr sd, pl_sd = get_start(); } - if (pl_sd->bl_m != nullptr && pl_sd->bl_m->flag.nowarpto + if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you to the map of this player."); return -1; } - if (sd->bl_m != nullptr && sd->bl_m->flag.nowarp + if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 93ccef8..abef80b 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -2352,7 +2352,6 @@ int battle_config_read(const char *cfgName) battle_config.resurrection_exp = 0; battle_config.shop_exp = 0; battle_config.combo_delay_rate = 100; - battle_config.item_check = 1; battle_config.wedding_modifydisplay = 0; battle_config.natural_healhp_interval = 6000; battle_config.natural_healsp_interval = 8000; @@ -2533,7 +2532,6 @@ int battle_config_read(const char *cfgName) {"resurrection_exp", &battle_config.resurrection_exp}, {"shop_exp", &battle_config.shop_exp}, {"combo_delay_rate", &battle_config.combo_delay_rate}, - {"item_check", &battle_config.item_check}, {"wedding_modifydisplay", &battle_config.wedding_modifydisplay}, {"natural_healhp_interval", &battle_config.natural_healhp_interval}, {"natural_healsp_interval", &battle_config.natural_healsp_interval}, diff --git a/src/map/battle.hpp b/src/map/battle.hpp index 4e410ef..0f9b2d1 100644 --- a/src/map/battle.hpp +++ b/src/map/battle.hpp @@ -143,7 +143,6 @@ extern struct Battle_Config int resurrection_exp; int shop_exp; int combo_delay_rate; - int item_check; int wedding_modifydisplay; int natural_healhp_interval; int natural_healsp_interval; diff --git a/src/map/clif.cpp b/src/map/clif.cpp index fab8932..9f06bfc 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -517,17 +517,12 @@ int clif_charselectok(int id) static int clif_set009e(dumb_ptr fitem, uint8_t *buf) { - int view; - nullpo_ret(fitem); //009e .l .w .B .w .w .B .B .w WBUFW(buf, 0) = 0x9e; WBUFL(buf, 2) = fitem->bl_id; - if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) - WBUFW(buf, 6) = view; - else - WBUFW(buf, 6) = fitem->item_data.nameid; + WBUFW(buf, 6) = fitem->item_data.nameid; WBUFB(buf, 8) = fitem->item_data.identify; WBUFW(buf, 9) = fitem->bl_x; WBUFW(buf, 11) = fitem->bl_y; @@ -676,12 +671,7 @@ int clif_set0078(dumb_ptr sd, unsigned char *buf) if (sd->equip_index[EQUIP::WEAPON] >= 0 && sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]) { - if (sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]->view_id > 0) - WBUFW(buf, 18) = - sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]->view_id; - else - WBUFW(buf, 18) = - sd->status.inventory[sd->equip_index[EQUIP::WEAPON]].nameid; + WBUFW(buf, 18) = sd->status.inventory[sd->equip_index[EQUIP::WEAPON]].nameid; } else WBUFW(buf, 18) = 0; @@ -690,10 +680,7 @@ int clif_set0078(dumb_ptr sd, unsigned char *buf) && sd->equip_index[EQUIP::SHIELD] != sd->equip_index[EQUIP::WEAPON] && sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]) { - if (sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]->view_id > 0) - WBUFW(buf, 20) = sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]->view_id; - else - WBUFW(buf, 20) = sd->status.inventory[sd->equip_index[EQUIP::SHIELD]].nameid; + WBUFW(buf, 20) = sd->status.inventory[sd->equip_index[EQUIP::SHIELD]].nameid; } else WBUFW(buf, 20) = 0; @@ -740,10 +727,7 @@ int clif_set007b(dumb_ptr sd, unsigned char *buf) if (sd->equip_index[EQUIP::WEAPON] >= 0 && sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]) { - if (sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]->view_id > 0) - WBUFW(buf, 18) = sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]->view_id; - else - WBUFW(buf, 18) = sd->status.inventory[sd->equip_index[EQUIP::WEAPON]].nameid; + WBUFW(buf, 18) = sd->status.inventory[sd->equip_index[EQUIP::WEAPON]].nameid; } else WBUFW(buf, 18) = 0; @@ -751,10 +735,7 @@ int clif_set007b(dumb_ptr sd, unsigned char *buf) && sd->equip_index[EQUIP::SHIELD] != sd->equip_index[EQUIP::WEAPON] && sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]) { - if (sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]->view_id > 0) - WBUFW(buf, 20) = sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]->view_id; - else - WBUFW(buf, 20) = sd->status.inventory[sd->equip_index[EQUIP::SHIELD]].nameid; + WBUFW(buf, 20) = sd->status.inventory[sd->equip_index[EQUIP::SHIELD]].nameid; } else WBUFW(buf, 20) = 0; @@ -1204,10 +1185,7 @@ int clif_buylist(dumb_ptr sd, dumb_ptr nd) WFIFOL(fd, 4 + i * 11) = val; // base price WFIFOL(fd, 8 + i * 11) = val; // actual price WFIFOB(fd, 12 + i * 11) = uint8_t(id->type); - if (id->view_id > 0) - WFIFOW(fd, 13 + i * 11) = id->view_id; - else - WFIFOW(fd, 13 + i * 11) = nd->shop_items[i].nameid; + WFIFOW(fd, 13 + i * 11) = nd->shop_items[i].nameid; } WFIFOW(fd, 2) = i * 11 + 4; WFIFOSET(fd, WFIFOW(fd, 2)); @@ -1416,10 +1394,7 @@ int clif_additem(dumb_ptr sd, int n, int amount, PickupFail fa WFIFOW(fd, 0) = 0xa0; WFIFOW(fd, 2) = n + 2; WFIFOW(fd, 4) = amount; - if (sd->inventory_data[n]->view_id > 0) - WFIFOW(fd, 6) = sd->inventory_data[n]->view_id; - else - WFIFOW(fd, 6) = sd->status.inventory[n].nameid; + WFIFOW(fd, 6) = sd->status.inventory[n].nameid; WFIFOB(fd, 8) = sd->status.inventory[n].identify; if (sd->status.inventory[n].broken == 1) WFIFOB(fd, 9) = 1; // is weapon broken [Valaris] @@ -1437,27 +1412,10 @@ int clif_additem(dumb_ptr sd, int n, int amount, PickupFail fa } else { - int j; - if (sd->status.inventory[n].card[0] > 0 - && (j = itemdb_viewid(sd->status.inventory[n].card[0])) > 0) - WFIFOW(fd, 11) = j; - else - WFIFOW(fd, 11) = sd->status.inventory[n].card[0]; - if (sd->status.inventory[n].card[1] > 0 - && (j = itemdb_viewid(sd->status.inventory[n].card[1])) > 0) - WFIFOW(fd, 13) = j; - else - WFIFOW(fd, 13) = sd->status.inventory[n].card[1]; - if (sd->status.inventory[n].card[2] > 0 - && (j = itemdb_viewid(sd->status.inventory[n].card[2])) > 0) - WFIFOW(fd, 15) = j; - else - WFIFOW(fd, 15) = sd->status.inventory[n].card[2]; - if (sd->status.inventory[n].card[3] > 0 - && (j = itemdb_viewid(sd->status.inventory[n].card[3])) > 0) - WFIFOW(fd, 17) = j; - else - WFIFOW(fd, 17) = sd->status.inventory[n].card[3]; + WFIFOW(fd, 11) = sd->status.inventory[n].card[0]; + WFIFOW(fd, 13) = sd->status.inventory[n].card[1]; + WFIFOW(fd, 15) = sd->status.inventory[n].card[2]; + WFIFOW(fd, 17) = sd->status.inventory[n].card[3]; } WFIFOW(fd, 19) = uint16_t(pc_equippoint(sd, n)); WFIFOB(fd, 21) = uint8_t(sd->inventory_data[n]->type == ItemType::_7 @@ -1509,10 +1467,7 @@ int clif_itemlist(dumb_ptr sd) || itemdb_isequip2(sd->inventory_data[i])) continue; WFIFOW(fd, n * 18 + 4) = i + 2; - if (sd->inventory_data[i]->view_id > 0) - WFIFOW(fd, n * 18 + 6) = sd->inventory_data[i]->view_id; - else - WFIFOW(fd, n * 18 + 6) = sd->status.inventory[i].nameid; + WFIFOW(fd, n * 18 + 6) = sd->status.inventory[i].nameid; WFIFOB(fd, n * 18 + 8) = uint8_t(sd->inventory_data[i]->type); WFIFOB(fd, n * 18 + 9) = sd->status.inventory[i].identify; WFIFOW(fd, n * 18 + 10) = sd->status.inventory[i].amount; @@ -1558,10 +1513,7 @@ int clif_equiplist(dumb_ptr sd) || !itemdb_isequip2(sd->inventory_data[i])) continue; WFIFOW(fd, n * 20 + 4) = i + 2; - if (sd->inventory_data[i]->view_id > 0) - WFIFOW(fd, n * 20 + 6) = sd->inventory_data[i]->view_id; - else - WFIFOW(fd, n * 20 + 6) = sd->status.inventory[i].nameid; + WFIFOW(fd, n * 20 + 6) = sd->status.inventory[i].nameid; WFIFOB(fd, n * 20 + 8) = uint8_t( sd->inventory_data[i]->type == ItemType::_7 ? ItemType::WEAPON @@ -1585,27 +1537,10 @@ int clif_equiplist(dumb_ptr sd) } else { - int j; - if (sd->status.inventory[i].card[0] > 0 - && (j = itemdb_viewid(sd->status.inventory[i].card[0])) > 0) - WFIFOW(fd, n * 20 + 16) = j; - else - WFIFOW(fd, n * 20 + 16) = sd->status.inventory[i].card[0]; - if (sd->status.inventory[i].card[1] > 0 - && (j = itemdb_viewid(sd->status.inventory[i].card[1])) > 0) - WFIFOW(fd, n * 20 + 18) = j; - else - WFIFOW(fd, n * 20 + 18) = sd->status.inventory[i].card[1]; - if (sd->status.inventory[i].card[2] > 0 - && (j = itemdb_viewid(sd->status.inventory[i].card[2])) > 0) - WFIFOW(fd, n * 20 + 20) = j; - else - WFIFOW(fd, n * 20 + 20) = sd->status.inventory[i].card[2]; - if (sd->status.inventory[i].card[3] > 0 - && (j = itemdb_viewid(sd->status.inventory[i].card[3])) > 0) - WFIFOW(fd, n * 20 + 22) = j; - else - WFIFOW(fd, n * 20 + 22) = sd->status.inventory[i].card[3]; + WFIFOW(fd, n * 20 + 16) = sd->status.inventory[i].card[0]; + WFIFOW(fd, n * 20 + 18) = sd->status.inventory[i].card[1]; + WFIFOW(fd, n * 20 + 20) = sd->status.inventory[i].card[2]; + WFIFOW(fd, n * 20 + 22) = sd->status.inventory[i].card[3]; } n++; } @@ -1641,10 +1576,7 @@ int clif_storageitemlist(dumb_ptr sd, struct storage *stor) continue; WFIFOW(fd, n * 18 + 4) = i + 1; - if (id->view_id > 0) - WFIFOW(fd, n * 18 + 6) = id->view_id; - else - WFIFOW(fd, n * 18 + 6) = stor->storage_[i].nameid; + WFIFOW(fd, n * 18 + 6) = stor->storage_[i].nameid; WFIFOB(fd, n * 18 + 8) = uint8_t(id->type); WFIFOB(fd, n * 18 + 9) = stor->storage_[i].identify; WFIFOW(fd, n * 18 + 10) = stor->storage_[i].amount; @@ -1686,10 +1618,7 @@ int clif_storageequiplist(dumb_ptr sd, struct storage *stor) if (!itemdb_isequip2(id)) continue; WFIFOW(fd, n * 20 + 4) = i + 1; - if (id->view_id > 0) - WFIFOW(fd, n * 20 + 6) = id->view_id; - else - WFIFOW(fd, n * 20 + 6) = stor->storage_[i].nameid; + WFIFOW(fd, n * 20 + 6) = stor->storage_[i].nameid; WFIFOB(fd, n * 20 + 8) = uint8_t(id->type); WFIFOB(fd, n * 20 + 9) = stor->storage_[i].identify; WFIFOW(fd, n * 20 + 10) = uint16_t(id->equip); @@ -1710,27 +1639,10 @@ int clif_storageequiplist(dumb_ptr sd, struct storage *stor) } else { - int j; - if (stor->storage_[i].card[0] > 0 - && (j = itemdb_viewid(stor->storage_[i].card[0])) > 0) - WFIFOW(fd, n * 20 + 16) = j; - else - WFIFOW(fd, n * 20 + 16) = stor->storage_[i].card[0]; - if (stor->storage_[i].card[1] > 0 - && (j = itemdb_viewid(stor->storage_[i].card[1])) > 0) - WFIFOW(fd, n * 20 + 18) = j; - else - WFIFOW(fd, n * 20 + 18) = stor->storage_[i].card[1]; - if (stor->storage_[i].card[2] > 0 - && (j = itemdb_viewid(stor->storage_[i].card[2])) > 0) - WFIFOW(fd, n * 20 + 20) = j; - else - WFIFOW(fd, n * 20 + 20) = stor->storage_[i].card[2]; - if (stor->storage_[i].card[3] > 0 - && (j = itemdb_viewid(stor->storage_[i].card[3])) > 0) - WFIFOW(fd, n * 20 + 22) = j; - else - WFIFOW(fd, n * 20 + 22) = stor->storage_[i].card[3]; + WFIFOW(fd, n * 20 + 16) = stor->storage_[i].card[0]; + WFIFOW(fd, n * 20 + 18) = stor->storage_[i].card[1]; + WFIFOW(fd, n * 20 + 20) = stor->storage_[i].card[2]; + WFIFOW(fd, n * 20 + 22) = stor->storage_[i].card[3]; } n++; } @@ -1950,15 +1862,7 @@ int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, if (sd->equip_index[equip_point] >= 0 && sd->inventory_data[sd->equip_index[equip_point]]) { - if (sd-> - inventory_data[sd->equip_index[equip_point]]->view_id > 0) - WBUFW(buf, 7) = - sd->inventory_data[sd-> - equip_index[equip_point]]->view_id; - else - WBUFW(buf, 7) = - sd->status.inventory[sd-> - equip_index[equip_point]].nameid; + WBUFW(buf, 7) = sd->status.inventory[sd->equip_index[equip_point]].nameid; } else WBUFW(buf, 7) = 0; @@ -1974,12 +1878,7 @@ int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, if (sd->equip_index[EQUIP::WEAPON] >= 0 && sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]) { - if (sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]->view_id > 0) - WBUFW(buf, 7) = - sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]->view_id; - else - WBUFW(buf, 7) = - sd->status.inventory[sd->equip_index[EQUIP::WEAPON]].nameid; + WBUFW(buf, 7) = sd->status.inventory[sd->equip_index[EQUIP::WEAPON]].nameid; } else WBUFW(buf, 7) = 0; @@ -1988,12 +1887,7 @@ int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, && sd->equip_index[EQUIP::SHIELD] != sd->equip_index[EQUIP::WEAPON] && sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]) { - if (sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]->view_id > 0) - WBUFW(buf, 9) = - sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]->view_id; - else - WBUFW(buf, 9) = - sd->status.inventory[sd->equip_index[EQUIP::SHIELD]].nameid; + WBUFW(buf, 9) = sd->status.inventory[sd->equip_index[EQUIP::SHIELD]].nameid; } else WBUFW(buf, 9) = 0; @@ -2245,11 +2139,7 @@ int clif_useitemack(dumb_ptr sd, int index, int amount, WBUFW(buf, 0) = 0x1c8; WBUFW(buf, 2) = index + 2; - if (sd->inventory_data[index] - && sd->inventory_data[index]->view_id > 0) - WBUFW(buf, 4) = sd->inventory_data[index]->view_id; - else - WBUFW(buf, 4) = sd->status.inventory[index].nameid; + WBUFW(buf, 4) = sd->status.inventory[index].nameid; WBUFL(buf, 6) = sd->bl_id; WBUFW(buf, 10) = amount; WBUFB(buf, 12) = ok; @@ -2300,12 +2190,10 @@ int clif_tradestart(dumb_ptr sd, int type) int clif_tradeadditem(dumb_ptr sd, dumb_ptr tsd, int index, int amount) { - int fd, j; - nullpo_ret(sd); nullpo_ret(tsd); - fd = tsd->fd; + int fd = tsd->fd; WFIFOW(fd, 0) = 0xe9; WFIFOL(fd, 2) = amount; if (index == 0) @@ -2322,11 +2210,7 @@ int clif_tradeadditem(dumb_ptr sd, else { index -= 2; - if (sd->inventory_data[index] - && sd->inventory_data[index]->view_id > 0) - WFIFOW(fd, 6) = sd->inventory_data[index]->view_id; - else - WFIFOW(fd, 6) = sd->status.inventory[index].nameid; // type id + WFIFOW(fd, 6) = sd->status.inventory[index].nameid; // type id WFIFOB(fd, 8) = sd->status.inventory[index].identify; //identify flag if (sd->status.inventory[index].broken == 1) WFIFOB(fd, 9) = 1; // is broke weapon [Valaris] @@ -2344,30 +2228,10 @@ int clif_tradeadditem(dumb_ptr sd, } else { - if (sd->status.inventory[index].card[0] > 0 - && (j = - itemdb_viewid(sd->status.inventory[index].card[0])) > 0) - WFIFOW(fd, 11) = j; - else - WFIFOW(fd, 11) = sd->status.inventory[index].card[0]; - if (sd->status.inventory[index].card[1] > 0 - && (j = - itemdb_viewid(sd->status.inventory[index].card[1])) > 0) - WFIFOW(fd, 13) = j; - else - WFIFOW(fd, 13) = sd->status.inventory[index].card[1]; - if (sd->status.inventory[index].card[2] > 0 - && (j = - itemdb_viewid(sd->status.inventory[index].card[2])) > 0) - WFIFOW(fd, 15) = j; - else - WFIFOW(fd, 15) = sd->status.inventory[index].card[2]; - if (sd->status.inventory[index].card[3] > 0 - && (j = - itemdb_viewid(sd->status.inventory[index].card[3])) > 0) - WFIFOW(fd, 17) = j; - else - WFIFOW(fd, 17) = sd->status.inventory[index].card[3]; + WFIFOW(fd, 11) = sd->status.inventory[index].card[0]; + WFIFOW(fd, 13) = sd->status.inventory[index].card[1]; + WFIFOW(fd, 15) = sd->status.inventory[index].card[2]; + WFIFOW(fd, 17) = sd->status.inventory[index].card[3]; } } WFIFOSET(fd, clif_parse_func_table[0xe9].len); @@ -2477,12 +2341,10 @@ int clif_updatestorageamount(dumb_ptr sd, int clif_storageitemadded(dumb_ptr sd, struct storage *stor, int index, int amount) { - int fd, j; - nullpo_ret(sd); nullpo_ret(stor); - fd = sd->fd; + int fd = sd->fd; WFIFOW(fd, 0) = 0xf4; // Storage item added WFIFOW(fd, 2) = index + 1; // index WFIFOL(fd, 4) = amount; // amount @@ -2507,26 +2369,10 @@ int clif_storageitemadded(dumb_ptr sd, struct storage *stor, } else { - if (stor->storage_[index].card[0] > 0 - && (j = itemdb_viewid(stor->storage_[index].card[0])) > 0) - WFIFOW(fd, 13) = j; - else - WFIFOW(fd, 13) = stor->storage_[index].card[0]; - if (stor->storage_[index].card[1] > 0 - && (j = itemdb_viewid(stor->storage_[index].card[1])) > 0) - WFIFOW(fd, 15) = j; - else - WFIFOW(fd, 15) = stor->storage_[index].card[1]; - if (stor->storage_[index].card[2] > 0 - && (j = itemdb_viewid(stor->storage_[index].card[2])) > 0) - WFIFOW(fd, 17) = j; - else - WFIFOW(fd, 17) = stor->storage_[index].card[2]; - if (stor->storage_[index].card[3] > 0 - && (j = itemdb_viewid(stor->storage_[index].card[3])) > 0) - WFIFOW(fd, 19) = j; - else - WFIFOW(fd, 19) = stor->storage_[index].card[3]; + WFIFOW(fd, 13) = stor->storage_[index].card[0]; + WFIFOW(fd, 15) = stor->storage_[index].card[1]; + WFIFOW(fd, 17) = stor->storage_[index].card[2]; + WFIFOW(fd, 19) = stor->storage_[index].card[3]; } WFIFOSET(fd, clif_parse_func_table[0xf4].len); @@ -2765,19 +2611,14 @@ static void clif_getareachar_item(dumb_ptr sd, dumb_ptr fitem) { - int view, fd; - nullpo_retv(sd); nullpo_retv(fitem); - fd = sd->fd; + int fd = sd->fd; //009d .l .w .B .w .w .w .B .B WFIFOW(fd, 0) = 0x9d; WFIFOL(fd, 2) = fitem->bl_id; - if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) - WFIFOW(fd, 6) = view; - else - WFIFOW(fd, 6) = fitem->item_data.nameid; + WFIFOW(fd, 6) = fitem->item_data.nameid; WFIFOB(fd, 8) = fitem->item_data.identify; WFIFOW(fd, 9) = fitem->bl_x; WFIFOW(fd, 11) = fitem->bl_y; diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 329bab8..570b517 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -26,10 +26,6 @@ static void itemdb_read(void); static int itemdb_readdb(void); -static -int itemdb_read_itemavail(void); -static -int itemdb_read_noequip(void); /*========================================== * 名前で検索用 @@ -82,11 +78,6 @@ struct item_data *itemdb_search(int nameid) id->weight = 10; id->sex = 2; id->elv = 0; - id->flag.available = 0; - id->flag.value_notdc = 0; //一応・・・ - id->flag.value_notoc = 0; - id->flag.no_equip = 0; - id->view_id = 0; if (nameid > 500 && nameid < 600) id->type = ItemType::USE; @@ -235,10 +226,6 @@ int itemdb_readdb(void) id->wlv = atoi(str[14]); id->elv = atoi(str[15]); id->look = static_cast(atoi(str[16])); - id->flag.available = 1; - id->flag.value_notdc = 0; - id->flag.value_notoc = 0; - id->view_id = 0; id->use_script = NULL; id->equip_script = NULL; @@ -257,110 +244,6 @@ int itemdb_readdb(void) return 0; } -// Removed item_value_db, don't re-add! - -/*========================================== - * アイテム使用可能フラグのオーバーライド - *------------------------------------------ - */ -static -int itemdb_read_itemavail(void) -{ - FILE *fp; - char line[1024]; - int ln = 0; - int nameid, j, k; - - if ((fp = fopen_("db/item_avail.txt", "r")) == NULL) - { - PRINTF("can't read db/item_avail.txt\n"); - return -1; - } - - while (fgets(line, 1020, fp)) - { - struct item_data *id; - if (line[0] == '/' && line[1] == '/') - continue; - char *str[10] {}; - char *p; - for (j = 0, p = line; j < 2 && p; j++) - { - str[j] = p; - p = strchr(p, ','); - if (p) - *p++ = 0; - } - - if (str[0] == NULL) - continue; - - nameid = atoi(str[0]); - if (nameid < 0 || nameid >= 20000 || !(id = itemdb_exists(nameid))) - continue; - k = atoi(str[1]); - if (k > 0) - { - id->flag.available = 1; - id->view_id = k; - } - else - id->flag.available = 0; - ln++; - } - fclose_(fp); - PRINTF("read db/item_avail.txt done (count=%d)\n", ln); - return 0; -} - -/*========================================== - * 装備制限ファイル読み出し - *------------------------------------------ - */ -static -int itemdb_read_noequip(void) -{ - FILE *fp; - char line[1024]; - int ln = 0; - int nameid, j; - struct item_data *id; - - if ((fp = fopen_("db/item_noequip.txt", "r")) == NULL) - { - PRINTF("can't read db/item_noequip.txt\n"); - return -1; - } - while (fgets(line, 1020, fp)) - { - if (line[0] == '/' && line[1] == '/') - continue; - char *str[32] {}; - char *p; - for (j = 0, p = line; j < 2 && p; j++) - { - str[j] = p; - p = strchr(p, ','); - if (p) - *p++ = 0; - } - if (str[0] == NULL) - continue; - - nameid = atoi(str[0]); - if (nameid <= 0 || nameid >= 20000 || !(id = itemdb_exists(nameid))) - continue; - - id->flag.no_equip = atoi(str[1]); - - ln++; - - } - fclose_(fp); - PRINTF("read db/item_noequip.txt done (count=%d)\n", ln); - return 0; -} - /*========================================== * *------------------------------------------ @@ -420,8 +303,6 @@ static void itemdb_read(void) { itemdb_readdb(); - itemdb_read_itemavail(); - itemdb_read_noequip(); } /*========================================== diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp index 02da73a..17b2057 100644 --- a/src/map/itemdb.hpp +++ b/src/map/itemdb.hpp @@ -29,16 +29,6 @@ struct item_data int refine; std::unique_ptr use_script; std::unique_ptr equip_script; - struct - { - unsigned available:1; - unsigned value_notdc:1; - unsigned value_notoc:1; - unsigned no_equip:3; - unsigned no_drop:1; - unsigned no_use:1; - } flag; - int view_id; }; struct random_item_data @@ -76,32 +66,11 @@ int itemdb_wlv(int n) { return itemdb_search(n)->wlv; } -inline -bool itemdb_available(int n) -{ - return itemdb_exists(n) && itemdb_search(n)->flag.available; -} -inline -int itemdb_viewid(int n) -{ - return itemdb_search(n)->view_id; -} - inline int itemdb_value_sell(int n) { return itemdb_search(n)->value_sell; } -inline -int itemdb_value_notdc(int n) -{ - return itemdb_search(n)->flag.value_notdc; -} -inline -int itemdb_value_notoc(int n) -{ - return itemdb_search(n)->flag.value_notoc; -} int itemdb_isequip(int); int itemdb_isequip2(struct item_data *); diff --git a/src/map/map.hpp b/src/map/map.hpp index e315492..f0d0310 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -593,7 +593,7 @@ void map_log(const_string line); #define MAP_LOG_PC(sd, fmt, ...) \ MAP_LOG("PC%d %s:%d,%d " fmt, \ - sd->status.char_id, (sd->bl_m ? sd->bl_m->name_ : "undefined"), sd->bl_x, sd->bl_y, ## __VA_ARGS__) + sd->status.char_id, (sd->bl_m ? sd->bl_m->name_ : "undefined.gat"), sd->bl_x, sd->bl_y, ## __VA_ARGS__) // 床アイテム関連 void map_clearflooritem_timer(TimerData *, tick_t, int); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 5c713c7..08f873a 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -593,9 +593,6 @@ int pc_isequip(dumb_ptr sd, int n) if (item->elv > 0 && sd->status.base_level < item->elv) return 0; - if (sd->bl_m->flag.pvp - && (item->flag.no_equip == 1 || item->flag.no_equip == 3)) - return 0; return 1; } @@ -2227,11 +2224,6 @@ int pc_isUseitem(dumb_ptr sd, int n) return 0; if (itemdb_type(nameid) != ItemType::USE) return 0; - if (nameid == 601 - && (sd->bl_m->flag.noteleport)) - { - return 0; - } if (item->sex != 2 && sd->status.sex != item->sex) return 0; @@ -2271,29 +2263,6 @@ int pc_useitem(dumb_ptr sd, int n) return 0; } -/*========================================== - * カートアイテムを減らす - *------------------------------------------ - */ -static -int pc_cart_delitem(dumb_ptr sd, int n, int amount, int) -{ - nullpo_retr(1, sd); - - if (sd->status.cart[n].nameid == 0 || sd->status.cart[n].amount < amount) - return 1; - - sd->status.cart[n].amount -= amount; - sd->cart_weight -= itemdb_weight(sd->status.cart[n].nameid) * amount; - if (sd->status.cart[n].amount <= 0) - { - sd->status.cart[n] = item{}; - sd->cart_num--; - } - - return 0; -} - // // // @@ -2453,8 +2422,7 @@ int pc_can_reach(dumb_ptr sd, int x, int y) wpd.path_len = 0; wpd.path_pos = 0; wpd.path_half = 0; - return (path_search(&wpd, sd->bl_m, sd->bl_x, sd->bl_y, x, y, 0) != - -1) ? 1 : 0; + return (path_search(&wpd, sd->bl_m, sd->bl_x, sd->bl_y, x, y, 0) != -1); } // @@ -4685,7 +4653,6 @@ int pc_unequipinvyitem(dumb_ptr sd, int n, CalcStatus type) int pc_checkitem(dumb_ptr sd) { int i, j, k, id, calc_flag = 0; - struct item_data *it = NULL; nullpo_ret(sd); @@ -4694,14 +4661,6 @@ int pc_checkitem(dumb_ptr sd) { if ((id = sd->status.inventory[i].nameid) == 0) continue; - if (battle_config.item_check && !itemdb_available(id)) - { - if (battle_config.error_log) - PRINTF("illeagal item id %d in %d[%s] inventory.\n", id, - sd->bl_id, sd->status.name); - pc_delitem(sd, i, sd->status.inventory[i].amount, 3); - continue; - } if (i > j) { sd->status.inventory[j] = sd->status.inventory[i]; @@ -4719,14 +4678,6 @@ int pc_checkitem(dumb_ptr sd) { if ((id = sd->status.cart[i].nameid) == 0) continue; - if (battle_config.item_check && !itemdb_available(id)) - { - if (battle_config.error_log) - PRINTF("illeagal item id %d in %d[%s] cart.\n", id, - sd->bl_id, sd->status.name); - pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1); - continue; - } if (i > j) { sd->status.cart[j] = sd->status.cart[i]; @@ -4740,9 +4691,6 @@ int pc_checkitem(dumb_ptr sd) for (i = 0; i < MAX_INVENTORY; i++) { - - it = sd->inventory_data[i]; - if (sd->status.inventory[i].nameid == 0) continue; if (bool(sd->status.inventory[i].equip & ~pc_equippoint(sd, i))) @@ -4750,14 +4698,6 @@ int pc_checkitem(dumb_ptr sd) sd->status.inventory[i].equip = EPOS::ZERO; calc_flag = 1; } - //装備制限チェック - if (bool(sd->status.inventory[i].equip) - && sd->bl_m->flag.pvp - && (it->flag.no_equip == 1 || it->flag.no_equip == 3)) - { //PvP制限 - sd->status.inventory[i].equip = EPOS::ZERO; - calc_flag = 1; - } } pc_setequipindex(sd); -- cgit v1.2.3-60-g2f50