diff --git a/changelog.txt b/changelog.txt index 005945fd1..8c5523df6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 06/28/2016 == +Uleat: Fix for bot inventory save failure involving items with unlimited charges + == 06/13/2016 == Noudess: Changes personal faction earned min/max to -2000/2000 from -3000/1200 diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 6748300d4..163c8d6b9 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -595,8 +595,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv) if (charges == 0x7FFF) inst->SetCharges(-1); - else if (charges == 0 && - inst->IsStackable()) // Stackable items need a minimum charge of 1 remain moveable. + else if (charges == 0 && inst->IsStackable()) // Stackable items need a minimum charge of 1 remain moveable. inst->SetCharges(1); else inst->SetCharges(charges); diff --git a/common/version.h b/common/version.h index 2b621b1c3..93d3b1779 100644 --- a/common/version.h +++ b/common/version.h @@ -32,7 +32,7 @@ #define CURRENT_BINARY_DATABASE_VERSION 9096 #ifdef BOTS - #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9007 + #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9008 #else #define CURRENT_BINARY_BOTS_DATABASE_VERSION 0 // must be 0 #endif diff --git a/utils/sql/git/bots/bots_db_update_manifest.txt b/utils/sql/git/bots/bots_db_update_manifest.txt index cda433dc1..50677d60e 100644 --- a/utils/sql/git/bots/bots_db_update_manifest.txt +++ b/utils/sql/git/bots/bots_db_update_manifest.txt @@ -6,6 +6,7 @@ 9005|2016_04_08_bots_heal_rotations.sql|SHOW TABLES LIKE 'bot_heal_rotations'|empty| 9006|2016_04_12_bots_inventory_window.sql|SELECT `bot_command` FROM `bot_command_settings` WHERE `bot_command` LIKE 'inventorywindow'|empty| 9007|2016_06_23_bots_camel_case_name_rule.sql|SELECT * FROM `rule_values` WHERE `rule_name` LIKE 'Bots:AllowCamelCaseNames'|empty| +9008|2016_06_28_bots_inventory_charges_update.sql|SELECT * FROM `information_schema`.`COLUMNS` isc WHERE isc.`TABLE_SCHEMA` = DATABASE() AND isc.`TABLE_NAME` = 'bot_inventories' AND isc.`COLUMN_NAME` = 'inst_charges' AND isc.`DATA_TYPE` = 'tinyint'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/utils/sql/git/bots/required/2016_06_28_bots_inventory_charges_update.sql b/utils/sql/git/bots/required/2016_06_28_bots_inventory_charges_update.sql new file mode 100644 index 000000000..1315c3e9e --- /dev/null +++ b/utils/sql/git/bots/required/2016_06_28_bots_inventory_charges_update.sql @@ -0,0 +1 @@ +ALTER TABLE `bot_inventories` MODIFY COLUMN `inst_charges` SMALLINT(3) UNSIGNED NULL DEFAULT '0'; diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index 7a746c721..0fade9c9d 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -1079,8 +1079,10 @@ bool BotDatabase::LoadItems(const uint32 bot_id, Inventory& inventory_inst) continue; } - if (item_charges == 255) + if (item_charges == 0x7FFF) item_inst->SetCharges(-1); + else if (item_charges == 0 && item_inst->IsStackable()) // Stackable items need a minimum charge of 1 remain moveable. + item_inst->SetCharges(1); else item_inst->SetCharges(item_charges); @@ -1190,6 +1192,12 @@ bool BotDatabase::SaveItemBySlot(Bot* bot_inst, const uint32 slot_id, const Item for (int augment_iter = 0; augment_iter < EQEmu::legacy::ITEM_COMMON_SIZE; ++augment_iter) augment_id[augment_iter] = item_inst->GetAugmentItemID(augment_iter); + uint16 item_charges = 0; + if (item_inst->GetCharges() >= 0) + item_charges = item_inst->GetCharges(); + else + item_charges = 0x7FFF; + query = StringFormat( "INSERT INTO `bot_inventories` (" "`bot_id`," @@ -1230,7 +1238,7 @@ bool BotDatabase::SaveItemBySlot(Bot* bot_inst, const uint32 slot_id, const Item (unsigned long)bot_inst->GetBotID(), (unsigned long)slot_id, (unsigned long)item_inst->GetID(), - (unsigned long)item_inst->GetCharges(), + (unsigned long)item_charges, (unsigned long)item_inst->GetColor(), (unsigned long)(item_inst->IsAttuned() ? 1 : 0), item_inst->GetCustomDataString().c_str(),