diff --git a/common/dbcore.cpp b/common/dbcore.cpp index 9e12f64aa..3c44544c2 100644 --- a/common/dbcore.cpp +++ b/common/dbcore.cpp @@ -105,6 +105,15 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl; + /* Implement Logging at the Root*/ + + std::cout << "\n[MYSQL ERR] " << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << "\n\n" << query << "\n" << std::endl; + /* Write to log file */ + std::ofstream log("eqemu_query_error_log.txt", std::ios_base::app | std::ios_base::out); + log << "[MYSQL ERR] " << mysql_error(&mysql) << "\n" << query << "\n"; + log.close(); + + return MySQLRequestResult(nullptr, 0, 0, 0, 0, (uint32)mysql_errno(&mysql), errorBuffer); } @@ -127,17 +136,6 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo MySQLRequestResult requestResult(res, (uint32)mysql_affected_rows(&mysql), rowCount, (uint32)mysql_field_count(&mysql), (uint32)mysql_insert_id(&mysql)); - /* Implement Logging at the Root*/ - if (requestResult.ErrorMessage() != ""){ - std::cout << "\n[MYSQL ERR] " << requestResult.ErrorMessage() << "\n\n" << query << "\n" << std::endl; - /* Write to log file */ - std::ofstream log("eqemu_query_error_log.txt", std::ios_base::app | std::ios_base::out); - log << "[MYSQL ERR] " << requestResult.ErrorMessage() << "\n" << query << "\n"; - log.close(); - } - - - #if DEBUG_MYSQL_QUERIES >= 1 if (requestResult.Success()) { diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index f62517f46..62a166c67 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -5211,7 +5211,7 @@ struct MercenaryMerchantResponse_Struct { struct ServerLootItem_Struct { uint32 item_id; // uint32 item_id; int16 equip_slot; // int16 equip_slot; - uint8 charges; // uint8 charges; + uint16 charges; // uint8 charges; uint16 lootslot; // uint16 lootslot; uint32 aug_1; // uint32 aug_1; uint32 aug_2; // uint32 aug_2; diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 21efd4030..e3e7c1360 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -636,8 +636,6 @@ ServerLootItem_Struct* Corpse::GetItem(uint16 lootslot, ServerLootItem_Struct** } } - std::cout << "sitem EQUIPSLOT: " << sitem->equip_slot << std::endl; - return sitem; } @@ -991,7 +989,7 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { if (RuleB(Character, CheckCursorEmptyWhenLooting) && !client->GetInv().CursorEmpty()) { client->Message(13, "You may not loot an item while you have an item on your cursor."); SendEndLootErrorPacket(client); - //unlock corpse for others + /* Unlock corpse for others */ if (this->BeingLootedBy = client->GetID()) { BeingLootedBy = 0xFFFFFFFF; } @@ -1036,14 +1034,12 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { item_data = GetItem(lootitem->slot_id - EmuConstants::CORPSE_BEGIN, bag_item_data); } - std::cout << "ITEM_DATA EQUIP SLOT: " << item_data->equip_slot << std::endl; - if (GetPKItem()<=1 && item_data != 0) { item = database.GetItem(item_data->item_id); } if (item != 0) { - if (item_data){ + if (item_data){ inst = database.CreateItem(item, item_data ? item_data->charges : 0, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5); } else { @@ -1115,21 +1111,20 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { /* Remove it from Corpse */ if (item_data){ - RemoveItem(item_data->lootslot); - std::cout << "CORPSE DB ID: " << this->corpse_db_id << std::endl; - std::cout << "CORPSE EQUIP SLOT: " << item_data->equip_slot << std::endl; - std::cout << "ITEM SLOT: " << item->Slots << std::endl; - database.DeleteItemOffCharacterCorpse(this->corpse_db_id, item_data->equip_slot, item->ID); + /* Delete needs to be before RemoveItem because its deletes the pointer for item_data/bag_item_data */ + database.DeleteItemOffCharacterCorpse(this->corpse_db_id, item_data->equip_slot, item_data->item_id); + /* Delete Item Instance */ + RemoveItem(item_data->lootslot); } /* Remove Bag Contents */ if (item->ItemClass == ItemClassContainer && (GetPKItem() != -1 || GetPKItem() != 1)) { for (int i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++) { if (bag_item_data[i]) { - RemoveItem(bag_item_data[i]); - std::cout << "CORPSE BAG DB ID: " << this->corpse_db_id << std::endl; - std::cout << "CORPSE BAG EQUIP SLOT: " << item_data->equip_slot << std::endl; - database.DeleteItemOffCharacterCorpse(this->corpse_db_id, item_data->equip_slot, item->ID); + /* Delete needs to be before RemoveItem because its deletes the pointer for item_data/bag_item_data */ + database.DeleteItemOffCharacterCorpse(this->corpse_db_id, bag_item_data[i]->equip_slot, bag_item_data[i]->item_id); + /* Delete Item Instance */ + RemoveItem(bag_item_data[i]); } } } @@ -1138,9 +1133,7 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { SetPKItem(0); } - //now send messages to all interested parties - - //creates a link for the item + /* Send message with item link to groups and such */ char *link = 0, *link2 = 0; //just like a db query :-) client->MakeItemLink(link2, inst); MakeAnyLenString(&link, "%c" "%s" "%s" "%c", @@ -1170,10 +1163,12 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { return; } - if (IsPlayerCorpse()) + if (IsPlayerCorpse()){ client->SendItemLink(inst); - else + } + else{ client->SendItemLink(inst, true); + } safe_delete(inst); } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 29f37e099..a79273322 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3763,10 +3763,11 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct corpse_id ); auto results = QueryDatabase(query); + std::cout << query << std::endl; uint16 i = 0; for (auto row = results.begin(); row != results.end(); ++row) { pcs->locked = atoi(row[i++]); // is_locked, - pcs->exp = atoi(row[i++]); // exp, + pcs->exp = atoll(row[i++]); // exp, pcs->size = atoi(row[i++]); // size, pcs->level = atoi(row[i++]); // `level`, pcs->race = atoi(row[i++]); // race, @@ -3775,10 +3776,10 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct pcs->deity = atoi(row[i++]); // deity, pcs->texture = atoi(row[i++]); // texture, pcs->helmtexture = atoi(row[i++]); // helm_texture, - pcs->copper = atoi(row[i++]); // copper, - pcs->silver = atoi(row[i++]); // silver, - pcs->gold = atoi(row[i++]); // gold, - pcs->plat = atoi(row[i++]); // platinum, + pcs->copper = atoll(row[i++]); // copper, + pcs->silver = atoll(row[i++]); // silver, + pcs->gold = atoll(row[i++]); // gold, + pcs->plat = atoll(row[i++]); // platinum, pcs->haircolor = atoi(row[i++]); // hair_color, pcs->beardcolor = atoi(row[i++]); // beard_color, pcs->eyecolor1 = atoi(row[i++]); // eye_color_1, @@ -3786,18 +3787,18 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct pcs->hairstyle = atoi(row[i++]); // hair_style, pcs->face = atoi(row[i++]); // face, pcs->beard = atoi(row[i++]); // beard, - pcs->drakkin_heritage = atoi(row[i++]); // drakkin_heritage, - pcs->drakkin_tattoo = atoi(row[i++]); // drakkin_tattoo, - pcs->drakkin_details = atoi(row[i++]); // drakkin_details, - pcs->item_tint[0].color = atoi(row[i++]); // wc_1, - pcs->item_tint[1].color = atoi(row[i++]); // wc_2, - pcs->item_tint[2].color = atoi(row[i++]); // wc_3, - pcs->item_tint[3].color = atoi(row[i++]); // wc_4, - pcs->item_tint[4].color = atoi(row[i++]); // wc_5, - pcs->item_tint[5].color = atoi(row[i++]); // wc_6, - pcs->item_tint[6].color = atoi(row[i++]); // wc_7, - pcs->item_tint[7].color = atoi(row[i++]); // wc_8, - pcs->item_tint[8].color = atoi(row[i++]); // wc_9 + pcs->drakkin_heritage = atoll(row[i++]); // drakkin_heritage, + pcs->drakkin_tattoo = atoll(row[i++]); // drakkin_tattoo, + pcs->drakkin_details = atoll(row[i++]); // drakkin_details, + pcs->item_tint[0].color = atoll(row[i++]); // wc_1, + pcs->item_tint[1].color = atoll(row[i++]); // wc_2, + pcs->item_tint[2].color = atoll(row[i++]); // wc_3, + pcs->item_tint[3].color = atoll(row[i++]); // wc_4, + pcs->item_tint[4].color = atoll(row[i++]); // wc_5, + pcs->item_tint[5].color = atoll(row[i++]); // wc_6, + pcs->item_tint[6].color = atoll(row[i++]); // wc_7, + pcs->item_tint[7].color = atoll(row[i++]); // wc_8, + pcs->item_tint[8].color = atoll(row[i++]); // wc_9 } query = StringFormat( "SELECT \n" @@ -3813,12 +3814,13 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct "FROM \n" "character_corpse_items \n" "WHERE `corpse_id` = %u\n" - "ORDER BY `equip_slot`", + // "ORDER BY `equip_slot`" + , corpse_id ); results = QueryDatabase(query); - i = 0; - + + i = 0; pcs->itemcount = results.RowCount(); uint16 r = 0; for (auto row = results.begin(); row != results.end(); ++row) { @@ -4009,9 +4011,7 @@ bool ZoneDatabase::ClearCorpseItems(uint32 db_id){ bool ZoneDatabase::DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id){ std::string query = StringFormat("DELETE FROM `character_corpse_items` WHERE `corpse_id` = %u AND equip_slot = %u AND item_id = %u", db_id, equip_slot, item_id); auto results = QueryDatabase(query); - std::cout << "QUERY: " << query << std::endl; if (results.Success() && results.RowsAffected() != 0){ - std::cout << "Item Delete Successfully" << std::endl; return true; } return false; diff --git a/zone/zonedump.h b/zone/zonedump.h index 14f9b5d0a..6d7e67b04 100644 --- a/zone/zonedump.h +++ b/zone/zonedump.h @@ -132,7 +132,7 @@ namespace player_lootitem { struct ServerLootItem_Struct { uint32 item_id; int16 equip_slot; - uint8 charges; + uint16 charges; uint16 lootslot; uint32 aug_1; uint32 aug_2;