From dedbb3f6c8546e9920940d4b5e79bdb784355dbf Mon Sep 17 00:00:00 2001 From: Uleat Date: Sat, 14 Feb 2015 20:52:20 -0500 Subject: [PATCH] Implemented higher bandolier and potion belt counts --- changelog.txt | 1 + common/eq_dictionary.cpp | 63 ------------------------------- common/eq_dictionary.h | 11 ++---- common/patches/rof.cpp | 39 ++++++++----------- common/patches/rof2.cpp | 75 ++++++++++++++++--------------------- common/patches/sod.cpp | 32 +++++++++++++--- common/patches/sof.cpp | 32 +++++++++++++--- common/patches/titanium.cpp | 30 +++++++++++++-- common/patches/uf.cpp | 32 +++++++++++++--- zone/client_packet.cpp | 5 +-- zone/zonedb.cpp | 47 ++++++++++++++--------- 11 files changed, 188 insertions(+), 179 deletions(-) diff --git a/changelog.txt b/changelog.txt index 6d50f235e..c04647bbc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ demonstar55: (RoF2) Send the bard focus effects, note custom servers will need t == 02/14/2015 == Trevius: (RoF2) Bazaar is now partially functional. RoF2 clients can start/end trader mode and other clients can purchase from them. No other functionality yet. +Uleat: Implemented higher bandolier and potion belt counts for clients that support it..you will still need to activate them through the proper aa's, etc... == 02/12/2015 == Akkadius: Implement zone based gravity, required SQL DB change diff --git a/common/eq_dictionary.cpp b/common/eq_dictionary.cpp index a87ae569a..a6a0d806d 100644 --- a/common/eq_dictionary.cpp +++ b/common/eq_dictionary.cpp @@ -919,66 +919,3 @@ bool EQLimits::CoinHasWeight(ClientVersion clientVersion) return local[static_cast(ValidateMobClientVersion(clientVersion))]; } - -uint32 EQLimits::BandoliersCount(ClientVersion clientVersion) -{ - static const uint32 local[CLIENT_VERSION_COUNT] = { -/*Unknown*/ NOT_USED, -/*62*/ NOT_USED, -/*Titanium*/ EmuConstants::BANDOLIERS_SIZE, -/*SoF*/ EmuConstants::BANDOLIERS_SIZE, -/*SoD*/ EmuConstants::BANDOLIERS_SIZE, -/*Underfoot*/ EmuConstants::BANDOLIERS_SIZE, -/*RoF*/ EmuConstants::BANDOLIERS_SIZE, -/*RoF2*/ EmuConstants::BANDOLIERS_SIZE, - -/*NPC*/ NOT_USED, -/*Merc*/ NOT_USED, -/*Bot*/ NOT_USED, -/*Pet*/ NOT_USED - }; - - return local[static_cast(ValidateMobClientVersion(clientVersion))]; -} - -uint32 EQLimits::BandolierSize(ClientVersion clientVersion) -{ - static const uint32 local[CLIENT_VERSION_COUNT] = { -/*Unknown*/ NOT_USED, -/*62*/ NOT_USED, -/*Titanium*/ EmuConstants::BANDOLIER_ITEM_COUNT, -/*SoF*/ EmuConstants::BANDOLIER_ITEM_COUNT, -/*SoD*/ EmuConstants::BANDOLIER_ITEM_COUNT, -/*Underfoot*/ EmuConstants::BANDOLIER_ITEM_COUNT, -/*RoF*/ EmuConstants::BANDOLIER_ITEM_COUNT, -/*RoF2*/ EmuConstants::BANDOLIER_ITEM_COUNT, - -/*NPC*/ NOT_USED, -/*Merc*/ NOT_USED, -/*Bot*/ NOT_USED, -/*Pet*/ NOT_USED - }; - - return local[static_cast(ValidateMobClientVersion(clientVersion))]; -} - -uint32 EQLimits::PotionBeltSize(ClientVersion clientVersion) -{ - static const uint32 local[CLIENT_VERSION_COUNT] = { -/*Unknown*/ NOT_USED, -/*62*/ NOT_USED, -/*Titanium*/ EmuConstants::POTION_BELT_ITEM_COUNT, -/*SoF*/ EmuConstants::POTION_BELT_ITEM_COUNT, -/*SoD*/ EmuConstants::POTION_BELT_ITEM_COUNT, -/*Underfoot*/ EmuConstants::POTION_BELT_ITEM_COUNT, -/*RoF*/ EmuConstants::POTION_BELT_ITEM_COUNT, -/*RoF2*/ EmuConstants::POTION_BELT_ITEM_COUNT, - -/*NPC*/ NOT_USED, -/*Merc*/ NOT_USED, -/*Bot*/ NOT_USED, -/*Pet*/ NOT_USED - }; - - return local[static_cast(ValidateMobClientVersion(clientVersion))]; -} diff --git a/common/eq_dictionary.h b/common/eq_dictionary.h index 501fd52cf..16586f356 100644 --- a/common/eq_dictionary.h +++ b/common/eq_dictionary.h @@ -142,11 +142,11 @@ public: static const uint16 ITEM_CONTAINER_SIZE = Titanium::consts::ITEM_CONTAINER_SIZE; // BANDOLIERS_SIZE sets maximum limit..active limit will need to be handled by the appropriate AA or spell (or item?) - static const size_t BANDOLIERS_SIZE = Titanium::consts::BANDOLIERS_SIZE; // number of bandolier instances - static const size_t BANDOLIER_ITEM_COUNT = Titanium::consts::BANDOLIER_ITEM_COUNT; // number of equipment slots in bandolier instance + static const size_t BANDOLIERS_SIZE = RoF2::consts::BANDOLIERS_SIZE; // number of bandolier instances + static const size_t BANDOLIER_ITEM_COUNT = RoF2::consts::BANDOLIER_ITEM_COUNT; // number of equipment slots in bandolier instance // POTION_BELT_SIZE sets maximum limit..active limit will need to be handled by the appropriate AA or spell (or item?) - static const size_t POTION_BELT_ITEM_COUNT = Titanium::consts::POTION_BELT_ITEM_COUNT; + static const size_t POTION_BELT_ITEM_COUNT = RoF2::consts::POTION_BELT_ITEM_COUNT; static const size_t TEXT_LINK_BODY_LENGTH = RoF2::consts::TEXT_LINK_BODY_LENGTH; }; @@ -186,11 +186,6 @@ public: // player profile static bool CoinHasWeight(ClientVersion clientVersion); - - static uint32 BandoliersCount(ClientVersion clientVersion); - static uint32 BandolierSize(ClientVersion clientVersion); - - static uint32 PotionBeltSize(ClientVersion clientVersion); }; #endif /* EQ_DICTIONARY_H */ diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 86382e7b5..ed943db97 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -2288,32 +2288,25 @@ namespace RoF outapp->WriteUInt32(consts::BANDOLIERS_SIZE); - for (uint32 r = 0; r < EmuConstants::BANDOLIERS_SIZE; r++) - { + // Copy bandoliers where server and client indexes converge + for (uint32 r = 0; r < EmuConstants::BANDOLIERS_SIZE && r < consts::BANDOLIERS_SIZE; ++r) { outapp->WriteString(emu->bandoliers[r].Name); - - for (uint32 j = 0; j < EmuConstants::BANDOLIER_ITEM_COUNT; ++j) - { + for (uint32 j = 0; j < consts::BANDOLIER_ITEM_COUNT; ++j) { // Will need adjusting if 'server != client' is ever true outapp->WriteString(emu->bandoliers[r].Items[j].Name); outapp->WriteUInt32(emu->bandoliers[r].Items[j].ID); - if (emu->bandoliers[r].Items[j].Icon) - { + if (emu->bandoliers[r].Items[j].Icon) { outapp->WriteSInt32(emu->bandoliers[r].Items[j].Icon); } - else - { + else { // If no icon, it must send -1 or Treasure Chest Icon (836) is displayed outapp->WriteSInt32(-1); } } } - - for (uint32 r = 0; r < consts::BANDOLIERS_SIZE - EmuConstants::BANDOLIERS_SIZE; r++) - { + // Nullify bandoliers where server and client indexes diverge, with a client bias + for (uint32 r = EmuConstants::BANDOLIERS_SIZE; r < consts::BANDOLIERS_SIZE; ++r) { outapp->WriteString(""); - - for (uint32 j = 0; j < EmuConstants::BANDOLIER_ITEM_COUNT; ++j) - { + for (uint32 j = 0; j < consts::BANDOLIER_ITEM_COUNT; ++j) { // Will need adjusting if 'server != client' is ever true outapp->WriteString(""); outapp->WriteUInt32(0); outapp->WriteSInt32(-1); @@ -2322,22 +2315,20 @@ namespace RoF outapp->WriteUInt32(consts::POTION_BELT_ITEM_COUNT); - for (uint32 r = 0; r < EmuConstants::POTION_BELT_ITEM_COUNT; r++) - { + // Copy potion belt where server and client indexes converge + for (uint32 r = 0; r < EmuConstants::POTION_BELT_ITEM_COUNT && r < consts::POTION_BELT_ITEM_COUNT; ++r) { outapp->WriteString(emu->potionbelt.Items[r].Name); outapp->WriteUInt32(emu->potionbelt.Items[r].ID); - if (emu->potionbelt.Items[r].Icon) - { + if (emu->potionbelt.Items[r].Icon) { outapp->WriteSInt32(emu->potionbelt.Items[r].Icon); } - else - { + else { + // If no icon, it must send -1 or Treasure Chest Icon (836) is displayed outapp->WriteSInt32(-1); } } - - for (uint32 r = 0; r < consts::POTION_BELT_ITEM_COUNT - EmuConstants::POTION_BELT_ITEM_COUNT; r++) - { + // Nullify potion belt where server and client indexes diverge, with a client bias + for (uint32 r = EmuConstants::POTION_BELT_ITEM_COUNT; r < consts::POTION_BELT_ITEM_COUNT; ++r) { outapp->WriteString(""); outapp->WriteUInt32(0); outapp->WriteSInt32(-1); diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index ba06c2742..e6f4775ac 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -2362,56 +2362,47 @@ namespace RoF2 outapp->WriteUInt32(consts::BANDOLIERS_SIZE); - for (uint32 r = 0; r < EmuConstants::BANDOLIERS_SIZE; r++) - { + // Copy bandoliers where server and client indexes converge + for (uint32 r = 0; r < EmuConstants::BANDOLIERS_SIZE && r < consts::BANDOLIERS_SIZE; ++r) { outapp->WriteString(emu->bandoliers[r].Name); - - for (uint32 j = 0; j < EmuConstants::BANDOLIER_ITEM_COUNT; ++j) - { + for (uint32 j = 0; j < consts::BANDOLIER_ITEM_COUNT; ++j) { // Will need adjusting if 'server != client' is ever true outapp->WriteString(emu->bandoliers[r].Items[j].Name); outapp->WriteUInt32(emu->bandoliers[r].Items[j].ID); - if (emu->bandoliers[r].Items[j].Icon) - { + if (emu->bandoliers[r].Items[j].Icon) { outapp->WriteSInt32(emu->bandoliers[r].Items[j].Icon); - } - else - { - // If no icon, it must send -1 or Treasure Chest Icon (836) is displayed - outapp->WriteSInt32(-1); - } - } - } - - for (uint32 r = 0; r < consts::BANDOLIERS_SIZE - EmuConstants::BANDOLIERS_SIZE; r++) - { - outapp->WriteString(""); - - for (uint32 j = 0; j < consts::BANDOLIER_ITEM_COUNT; ++j) - { - outapp->WriteString(""); - outapp->WriteUInt32(0); - outapp->WriteSInt32(-1); - } - } - + } + else { + // If no icon, it must send -1 or Treasure Chest Icon (836) is displayed + outapp->WriteSInt32(-1); + } + } + } + // Nullify bandoliers where server and client indexes diverge, with a client bias + for (uint32 r = EmuConstants::BANDOLIERS_SIZE; r < consts::BANDOLIERS_SIZE; ++r) { + outapp->WriteString(""); + for (uint32 j = 0; j < consts::BANDOLIER_ITEM_COUNT; ++j) { // Will need adjusting if 'server != client' is ever true + outapp->WriteString(""); + outapp->WriteUInt32(0); + outapp->WriteSInt32(-1); + } + } + outapp->WriteUInt32(consts::POTION_BELT_ITEM_COUNT); - - for (uint32 r = 0; r < EmuConstants::POTION_BELT_ITEM_COUNT; r++) - { + + // Copy potion belt where server and client indexes converge + for (uint32 r = 0; r < EmuConstants::POTION_BELT_ITEM_COUNT && r < consts::POTION_BELT_ITEM_COUNT; ++r) { outapp->WriteString(emu->potionbelt.Items[r].Name); outapp->WriteUInt32(emu->potionbelt.Items[r].ID); - if (emu->potionbelt.Items[r].Icon) - { + if (emu->potionbelt.Items[r].Icon) { outapp->WriteSInt32(emu->potionbelt.Items[r].Icon); - } - else - { - outapp->WriteSInt32(-1); - } - } - - for (uint32 r = 0; r < consts::POTION_BELT_ITEM_COUNT - EmuConstants::POTION_BELT_ITEM_COUNT; r++) - { + } + else { + // If no icon, it must send -1 or Treasure Chest Icon (836) is displayed + outapp->WriteSInt32(-1); + } + } + // Nullify potion belt where server and client indexes diverge, with a client bias + for (uint32 r = EmuConstants::POTION_BELT_ITEM_COUNT; r < consts::POTION_BELT_ITEM_COUNT; ++r) { outapp->WriteString(""); outapp->WriteUInt32(0); outapp->WriteSInt32(-1); diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 81cb49f1a..b1ae218ed 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -1606,26 +1606,46 @@ namespace SoD OUT(endurance); OUT(aapoints_spent); OUT(aapoints); + // OUT(unknown06160[4]); - //NOTE: new client supports 20 bandoliers, our internal rep - //only supports 4.. - for (r = 0; r < 4; r++) { + + // Copy bandoliers where server and client indexes converge + for (r = 0; r < EmuConstants::BANDOLIERS_SIZE && r < consts::BANDOLIERS_SIZE; ++r) { OUT_str(bandoliers[r].Name); - uint32 k; - for (k = 0; k < consts::BANDOLIER_ITEM_COUNT; k++) { + for (uint32 k = 0; k < consts::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true OUT(bandoliers[r].Items[k].ID); OUT(bandoliers[r].Items[k].Icon); OUT_str(bandoliers[r].Items[k].Name); } } + // Nullify bandoliers where server and client indexes diverge, with a client bias + for (r = EmuConstants::BANDOLIERS_SIZE; r < consts::BANDOLIERS_SIZE; ++r) { + eq->bandoliers[r].Name[0] = '\0'; + for (uint32 k = 0; k < consts::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true + eq->bandoliers[r].Items[k].ID = 0; + eq->bandoliers[r].Items[k].Icon = 0; + eq->bandoliers[r].Items[k].Name[0] = '\0'; + } + } + // OUT(unknown07444[5120]); - for (r = 0; r < consts::POTION_BELT_ITEM_COUNT; r++) { + + // Copy potion belt where server and client indexes converge + for (r = 0; r < EmuConstants::POTION_BELT_ITEM_COUNT && r < consts::POTION_BELT_ITEM_COUNT; ++r) { OUT(potionbelt.Items[r].ID); OUT(potionbelt.Items[r].Icon); OUT_str(potionbelt.Items[r].Name); } + // Nullify potion belt where server and client indexes diverge, with a client bias + for (r = EmuConstants::POTION_BELT_ITEM_COUNT; r < consts::POTION_BELT_ITEM_COUNT; ++r) { + eq->potionbelt.Items[r].ID = 0; + eq->potionbelt.Items[r].Icon = 0; + eq->potionbelt.Items[r].Name[0] = '\0'; + } + // OUT(unknown12852[8]); // OUT(unknown12864[76]); + OUT_str(name); OUT_str(last_name); OUT(guild_id); diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 01b6abb55..4ba534ac7 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -1264,26 +1264,46 @@ namespace SoF OUT(endurance); OUT(aapoints_spent); OUT(aapoints); + // OUT(unknown06160[4]); - //NOTE: new client supports 20 bandoliers, our internal rep - //only supports 4.. - for (r = 0; r < 4; r++) { + + // Copy bandoliers where server and client indexes converge + for (r = 0; r < EmuConstants::BANDOLIERS_SIZE && r < consts::BANDOLIERS_SIZE; ++r) { OUT_str(bandoliers[r].Name); - uint32 k; - for (k = 0; k < consts::BANDOLIER_ITEM_COUNT; k++) { + for (uint32 k = 0; k < consts::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true OUT(bandoliers[r].Items[k].ID); OUT(bandoliers[r].Items[k].Icon); OUT_str(bandoliers[r].Items[k].Name); } } + // Nullify bandoliers where server and client indexes diverge, with a client bias + for (r = EmuConstants::BANDOLIERS_SIZE; r < consts::BANDOLIERS_SIZE; ++r) { + eq->bandoliers[r].Name[0] = '\0'; + for (uint32 k = 0; k < consts::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true + eq->bandoliers[r].Items[k].ID = 0; + eq->bandoliers[r].Items[k].Icon = 0; + eq->bandoliers[r].Items[k].Name[0] = '\0'; + } + } + // OUT(unknown07444[5120]); - for (r = 0; r < consts::POTION_BELT_ITEM_COUNT; r++) { + + // Copy potion belt where server and client indexes converge + for (r = 0; r < EmuConstants::POTION_BELT_ITEM_COUNT && r < consts::POTION_BELT_ITEM_COUNT; ++r) { OUT(potionbelt.Items[r].ID); OUT(potionbelt.Items[r].Icon); OUT_str(potionbelt.Items[r].Name); } + // Nullify potion belt where server and client indexes diverge, with a client bias + for (r = EmuConstants::POTION_BELT_ITEM_COUNT; r < consts::POTION_BELT_ITEM_COUNT; ++r) { + eq->potionbelt.Items[r].ID = 0; + eq->potionbelt.Items[r].Icon = 0; + eq->potionbelt.Items[r].Name[0] = '\0'; + } + // OUT(unknown12852[8]); // OUT(unknown12864[76]); + OUT_str(name); OUT_str(last_name); OUT(guild_id); diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index b242a48b7..d048f0e5d 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -922,24 +922,46 @@ namespace Titanium OUT(endurance); OUT(aapoints_spent); OUT(aapoints); + // OUT(unknown06160[4]); - for (r = 0; r < consts::BANDOLIERS_SIZE; r++) { + + // Copy bandoliers where server and client indexes converge + for (r = 0; r < EmuConstants::BANDOLIERS_SIZE && r < consts::BANDOLIERS_SIZE; ++r) { OUT_str(bandoliers[r].Name); - uint32 k; - for (k = 0; k < consts::BANDOLIER_ITEM_COUNT; k++) { + for (uint32 k = 0; k < consts::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true OUT(bandoliers[r].Items[k].ID); OUT(bandoliers[r].Items[k].Icon); OUT_str(bandoliers[r].Items[k].Name); } } + // Nullify bandoliers where server and client indexes diverge, with a client bias + for (r = EmuConstants::BANDOLIERS_SIZE; r < consts::BANDOLIERS_SIZE; ++r) { + eq->bandoliers[r].Name[0] = '\0'; + for (uint32 k = 0; k < consts::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true + eq->bandoliers[r].Items[k].ID = 0; + eq->bandoliers[r].Items[k].Icon = 0; + eq->bandoliers[r].Items[k].Name[0] = '\0'; + } + } + // OUT(unknown07444[5120]); - for (r = 0; r < consts::POTION_BELT_ITEM_COUNT; r++) { + + // Copy potion belt where server and client indexes converge + for (r = 0; r < EmuConstants::POTION_BELT_ITEM_COUNT && r < consts::POTION_BELT_ITEM_COUNT; ++r) { OUT(potionbelt.Items[r].ID); OUT(potionbelt.Items[r].Icon); OUT_str(potionbelt.Items[r].Name); } + // Nullify potion belt where server and client indexes diverge, with a client bias + for (r = EmuConstants::POTION_BELT_ITEM_COUNT; r < consts::POTION_BELT_ITEM_COUNT; ++r) { + eq->potionbelt.Items[r].ID = 0; + eq->potionbelt.Items[r].Icon = 0; + eq->potionbelt.Items[r].Name[0] = '\0'; + } + // OUT(unknown12852[8]); // OUT(unknown12864[76]); + OUT_str(name); OUT_str(last_name); OUT(guild_id); diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index 5827c652c..991b35aa4 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -1868,26 +1868,46 @@ namespace UF OUT(endurance); OUT(aapoints_spent); OUT(aapoints); + // OUT(unknown06160[4]); - //NOTE: new client supports 20 bandoliers, our internal rep - //only supports 4.. - for (r = 0; r < 4; r++) { + + // Copy bandoliers where server and client indexes converge + for (r = 0; r < EmuConstants::BANDOLIERS_SIZE && r < consts::BANDOLIERS_SIZE; ++r) { OUT_str(bandoliers[r].Name); - uint32 k; - for (k = 0; k < consts::BANDOLIER_ITEM_COUNT; k++) { + for (uint32 k = 0; k < consts::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true OUT(bandoliers[r].Items[k].ID); OUT(bandoliers[r].Items[k].Icon); OUT_str(bandoliers[r].Items[k].Name); } } + // Nullify bandoliers where server and client indexes diverge, with a client bias + for (r = EmuConstants::BANDOLIERS_SIZE; r < consts::BANDOLIERS_SIZE; ++r) { + eq->bandoliers[r].Name[0] = '\0'; + for (uint32 k = 0; k < consts::BANDOLIER_ITEM_COUNT; ++k) { // Will need adjusting if 'server != client' is ever true + eq->bandoliers[r].Items[k].ID = 0; + eq->bandoliers[r].Items[k].Icon = 0; + eq->bandoliers[r].Items[k].Name[0] = '\0'; + } + } + // OUT(unknown07444[5120]); - for (r = 0; r < consts::POTION_BELT_ITEM_COUNT; r++) { + + // Copy potion belt where server and client indexes converge + for (r = 0; r < EmuConstants::POTION_BELT_ITEM_COUNT && r < consts::POTION_BELT_ITEM_COUNT; ++r) { OUT(potionbelt.Items[r].ID); OUT(potionbelt.Items[r].Icon); OUT_str(potionbelt.Items[r].Name); } + // Nullify potion belt where server and client indexes diverge, with a client bias + for (r = EmuConstants::POTION_BELT_ITEM_COUNT; r < consts::POTION_BELT_ITEM_COUNT; ++r) { + eq->potionbelt.Items[r].ID = 0; + eq->potionbelt.Items[r].Icon = 0; + eq->potionbelt.Items[r].Name[0] = '\0'; + } + // OUT(unknown12852[8]); // OUT(unknown12864[76]); + OUT_str(name); OUT_str(last_name); OUT(guild_id); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 97b927352..3fa28c891 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3171,7 +3171,6 @@ void Client::Handle_OP_AutoFire(const EQApplicationPacket *app) void Client::Handle_OP_Bandolier(const EQApplicationPacket *app) { - // Although there are three different structs for OP_Bandolier, they are all the same size. // if (app->size != sizeof(BandolierCreate_Struct)) { @@ -3195,7 +3194,7 @@ void Client::Handle_OP_Bandolier(const EQApplicationPacket *app) SetBandolier(app); break; default: - Log.Out(Logs::General, Logs::None, "Uknown Bandolier action %i", bs->Action); + Log.Out(Logs::General, Logs::None, "Unknown Bandolier action %i", bs->Action); break; } } @@ -10452,7 +10451,7 @@ void Client::Handle_OP_PotionBelt(const EQApplicationPacket *app) else { m_pp.potionbelt.Items[mptbs->SlotNumber].ID = 0; m_pp.potionbelt.Items[mptbs->SlotNumber].Icon = 0; - strncpy(m_pp.potionbelt.Items[mptbs->SlotNumber].Name, "\0", 1); + m_pp.potionbelt.Items[mptbs->SlotNumber].Name[0] = '\0'; } } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index d409e270a..d9e564e29 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1177,20 +1177,37 @@ bool ZoneDatabase::LoadCharacterMaterialColor(uint32 character_id, PlayerProfile bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Struct* pp) { - std::string query = StringFormat("SELECT `bandolier_id`, `bandolier_slot`, `item_id`, `icon`, `bandolier_name` FROM `character_bandolier` WHERE `id` = %u LIMIT 16", character_id); + std::string query = StringFormat("SELECT `bandolier_id`, `bandolier_slot`, `item_id`, `icon`, `bandolier_name` FROM `character_bandolier` WHERE `id` = %u LIMIT %u", + character_id, EmuConstants::BANDOLIERS_SIZE); auto results = database.QueryDatabase(query); int i = 0; int r = 0; int si = 0; - for (i = 0; i < EmuConstants::BANDOLIERS_SIZE; i++) - for (int si = 0; si < EmuConstants::BANDOLIER_ITEM_COUNT; si++) + for (i = 0; i < EmuConstants::BANDOLIERS_SIZE; i++) { + pp->bandoliers[i].Name[0] = '\0'; + for (int si = 0; si < EmuConstants::BANDOLIER_ITEM_COUNT; si++) { + pp->bandoliers[i].Items[si].ID = 0; pp->bandoliers[i].Items[si].Icon = 0; + pp->bandoliers[i].Items[si].Name[0] = '\0'; + } + } for (auto row = results.begin(); row != results.end(); ++row) { r = 0; i = atoi(row[r]); /* Bandolier ID */ r++; si = atoi(row[r]); /* Bandolier Slot */ r++; - pp->bandoliers[i].Items[si].ID = atoi(row[r]); r++; - pp->bandoliers[i].Items[si].Icon = atoi(row[r]); r++; + + const Item_Struct* item_data = database.GetItem(atoi(row[r])); + if (item_data) { + pp->bandoliers[i].Items[si].ID = item_data->ID; r++; + pp->bandoliers[i].Items[si].Icon = atoi(row[r]); r++; // Must use db value in case an Ornamentation is assigned + strncpy(pp->bandoliers[i].Items[si].Name, item_data->Name, 64); + } + else { + pp->bandoliers[i].Items[si].ID = 0; r++; + pp->bandoliers[i].Items[si].Icon = 0; r++; + pp->bandoliers[i].Items[si].Name[0] = '\0'; + } strcpy(pp->bandoliers[i].Name, row[r]); r++; - si++; + + si++; // What is this for!? } return true; } @@ -1216,25 +1233,21 @@ bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struc bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp) { - std::string query = StringFormat("SELECT `potion_id`, `item_id`, `icon` FROM `character_potionbelt` WHERE `id` = %u LIMIT 4", character_id); + std::string query = StringFormat("SELECT `potion_id`, `item_id`, `icon` FROM `character_potionbelt` WHERE `id` = %u LIMIT %u", + character_id, EmuConstants::POTION_BELT_ITEM_COUNT); auto results = database.QueryDatabase(query); int i = 0; for (i = 0; i < EmuConstants::POTION_BELT_ITEM_COUNT; i++){ pp->potionbelt.Items[i].Icon = 0; pp->potionbelt.Items[i].ID = 0; - strncpy(pp->potionbelt.Items[i].Name, "\0", 1); + pp->potionbelt.Items[i].Name[0] = '\0'; } for (auto row = results.begin(); row != results.end(); ++row) { - i = atoi(row[0]); /* Potion belt slot number */ - uint32 item_id = atoi(row[1]); - const Item_Struct *item = database.GetItem(item_id); - - if(!item) - continue; - - pp->potionbelt.Items[i].ID = item_id; + const Item_Struct *item_data = database.GetItem(atoi(row[1])); + if (item_data == nullptr) { continue; } + pp->potionbelt.Items[i].ID = item_data->ID; pp->potionbelt.Items[i].Icon = atoi(row[2]); - strncpy(pp->potionbelt.Items[i].Name, item->Name, 64); + strncpy(pp->potionbelt.Items[i].Name, item_data->Name, 64); } return true;