From 7deb4d5e789e53227f1bd1086f4be5c4adcb1176 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Wed, 18 Feb 2015 18:28:46 -0500 Subject: [PATCH] Fix potion belt loading --- zone/zonedb.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 07a3df930..685fbd3ca 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1231,20 +1231,24 @@ bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struc return true; } -bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp) +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 %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++){ + 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; pp->potionbelt.Items[i].Name[0] = '\0'; } for (auto row = results.begin(); row != results.end(); ++row) { + i = atoi(row[0]); const Item_Struct *item_data = database.GetItem(atoi(row[1])); - if (item_data == nullptr) { continue; } + if (!item_data) + continue; pp->potionbelt.Items[i].ID = item_data->ID; pp->potionbelt.Items[i].Icon = atoi(row[2]); strncpy(pp->potionbelt.Items[i].Name, item_data->Name, 64);