diff --git a/zone/corpse.cpp b/zone/corpse.cpp index a84b4161e..a95b279ea 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -183,19 +183,18 @@ Corpse::Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NP break; } } - if(IsEmpty()) - { + if(IsEmpty()) { corpse_decay_timer.SetTimer(RuleI(NPC,EmptyNPCCorpseDecayTimeMS)+1000); } - if(in_npc->HasPrivateCorpse()) - { + if(in_npc->HasPrivateCorpse()) { corpse_delay_timer.SetTimer(corpse_decay_timer.GetRemainingTime() + 1000); } // Added By Hogie -- End - for (int i=0; irezzexp = 0; } @@ -262,13 +261,16 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( PlayerProfile_Struct *pp = &client->GetPP(); ItemInst *item; + /* Check if Zone has Graveyard First */ if(!zone->HasGraveyard()) { corpse_graveyard_timer.Disable(); } memset(item_tint, 0, sizeof(item_tint)); - for (i=0; i < MAX_LOOTERS; i++) - looters[i] = 0; + + for (i = 0; i < MAX_LOOTERS; i++){ + allowed_looters[i] = 0; + } is_corpse_changed = true; rezzexp = in_rezexp; @@ -283,14 +285,16 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( silver = 0; gold = 0; platinum = 0; + strcpy(orgname, pp->name); strcpy(name, pp->name); - //become_npc was not being initialized which led to some pretty funky things with newly created corpses + /* become_npc was not being initialized which led to some pretty funky things with newly created corpses */ become_npc = false; SetPKItem(0); + /* Check Rule to see if we can leave corpses */ if(!RuleB(Character, LeaveNakedCorpses) || RuleB(Character, LeaveCorpses) && GetLevel() >= RuleI(Character, DeathItemLossLevel)) { @@ -405,16 +409,13 @@ std::list Corpse::MoveItemToCorpse(Client *client, ItemInst *item, int16 returnlist.push_back(equipslot); // Qualified bag slot iterations. processing bag slots that don't exist is probably not a good idea. - if(item->IsType(ItemClassContainer) && ((equipslot >= EmuConstants::GENERAL_BEGIN && equipslot <= MainCursor))) // Limit the bag check to inventory and cursor slots. - { - for(bagindex = SUB_BEGIN; bagindex <= EmuConstants::ITEM_CONTAINER_SIZE; bagindex++) - { + if(item->IsType(ItemClassContainer) && ((equipslot >= EmuConstants::GENERAL_BEGIN && equipslot <= MainCursor))) { + for(bagindex = SUB_BEGIN; bagindex <= EmuConstants::ITEM_CONTAINER_SIZE; bagindex++) { // For empty bags in cursor queue, slot was previously being resolved as SLOT_INVALID (-1) interior_slot = Inventory::CalcSlotId(equipslot, bagindex); interior_item = client->GetInv().GetItem(interior_slot); - if(interior_item) - { + if(interior_item) { AddItem(interior_item->GetItem()->ID, interior_item->GetCharges(), interior_slot, interior_item->GetAugmentItemID(0), interior_item->GetAugmentItemID(1), interior_item->GetAugmentItemID(2), interior_item->GetAugmentItemID(3), interior_item->GetAugmentItemID(4)); returnlist.push_back(Inventory::CalcSlotId(equipslot, bagindex)); client->DeleteItemInInventory(interior_slot, 0, true, false); @@ -485,13 +486,13 @@ in_helmtexture, loot_cooldown_timer(10) { - //we really should be loading the decay timer here... LoadPlayerCorpseDecayTime(in_dbid); if(!zone->HasGraveyard() || wasAtGraveyard) corpse_graveyard_timer.Disable(); memset(item_tint, 0, sizeof(item_tint)); + is_corpse_changed = false; is_player_corpse = true; is_locked = false; @@ -509,8 +510,10 @@ in_helmtexture, this->gold = in_gold; this->platinum = in_plat; rezzexp = in_rezexp; - for (int i=0; iCountItems(); uint32 tmpsize = sizeof(PlayerCorpse_Struct) + (tmp * sizeof(player_lootitem::ServerLootItem_Struct)); - std::cout << "tmp: " << tmp << std::endl; - std::cout << "tmpsize: " << tmpsize << std::endl; - PlayerCorpse_Struct* dbpc = (PlayerCorpse_Struct*) new uchar[tmpsize]; memset(dbpc, 0, tmpsize); dbpc->itemcount = tmp; @@ -594,9 +596,11 @@ bool Corpse::Save() { memcpy((char*)&dbpc->items[x++], (char*)item, sizeof(ServerLootItem_Struct)); } + /* Create New Corpse*/ if (corpse_db_id == 0) { corpse_db_id = database.SaveCharacterCorpse(char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, x_pos, y_pos, z_pos, heading); } + /* Update Corpse Data */ else{ corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, x_pos, y_pos, z_pos, heading, IsRezzed()); } @@ -661,23 +665,20 @@ ServerLootItem_Struct* Corpse::GetItem(uint16 lootslot, ServerLootItem_Struct** cur = itemlist.begin(); end = itemlist.end(); for(; cur != end; ++cur) { - if((*cur)->lootslot == lootslot) - { + if((*cur)->lootslot == lootslot) { sitem = *cur; break; } } - if (sitem && bag_item_data && Inventory::SupportsContainers(sitem->equip_slot)) - { + if (sitem && bag_item_data && Inventory::SupportsContainers(sitem->equip_slot)) { int16 bagstart = Inventory::CalcSlotId(sitem->equip_slot, SUB_BEGIN); cur = itemlist.begin(); end = itemlist.end(); for(; cur != end; ++cur) { sitem2 = *cur; - if(sitem2->equip_slot >= bagstart && sitem2->equip_slot < bagstart + 10) - { + if(sitem2->equip_slot >= bagstart && sitem2->equip_slot < bagstart + 10) { bag_item_data[sitem2->equip_slot - bagstart] = sitem2; } } @@ -692,8 +693,7 @@ uint32 Corpse::GetWornItem(int16 equipSlot) const { end = itemlist.end(); for(; cur != end; ++cur) { ServerLootItem_Struct* item = *cur; - if (item->equip_slot == equipSlot) - { + if (item->equip_slot == equipSlot) { return item->item_id; } } @@ -710,8 +710,7 @@ void Corpse::RemoveItem(uint16 lootslot) { end = itemlist.end(); for(; cur != end; ++cur) { ServerLootItem_Struct* sitem = *cur; - if (sitem->lootslot == lootslot) - { + if (sitem->lootslot == lootslot) { RemoveItem(sitem); return; } @@ -725,8 +724,7 @@ void Corpse::RemoveItem(ServerLootItem_Struct* item_data){ end = itemlist.end(); for(; cur != end; ++cur) { ServerLootItem_Struct* sitem = *cur; - if (sitem == item_data) - { + if (sitem == item_data) { is_corpse_changed = true; itemlist.erase(cur); @@ -769,7 +767,7 @@ bool Corpse::Process() { if(corpse_delay_timer.Check()) { for (int i=0; iIsClient()) return; - looters[slot] = them->CastToClient()->CharacterID(); + allowed_looters[slot] = them->CastToClient()->CharacterID(); } // @merth: this function needs some work @@ -1390,8 +1388,8 @@ uint32 Corpse::GetEquipmentColor(uint8 material_slot) const { void Corpse::AddLooter(Mob* who) { for (int i=0; iCastToClient()->CharacterID(); + if (allowed_looters[i] == 0) { + allowed_looters[i] = who->CastToClient()->CharacterID(); break; } } diff --git a/zone/corpse.h b/zone/corpse.h index c292823bd..f365dd041 100644 --- a/zone/corpse.h +++ b/zone/corpse.h @@ -26,13 +26,12 @@ class NPC; #define MAX_LOOTERS 72 -class Corpse : public Mob -{ +class Corpse : public Mob { public: + static void SendEndLootErrorPacket(Client* client); static void SendLootReqErrorPacket(Client* client, uint8 response = 2); - Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NPCType** in_npctypedata, uint32 in_decaytime = 600000); Corpse(Client* client, int32 in_rezexp); Corpse(uint32 in_corpseid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture, uint32 in_rezexp, bool wasAtGraveyard = false); @@ -137,7 +136,7 @@ private: bool rez; bool can_rez; bool become_npc; - int looters[MAX_LOOTERS]; // People allowed to loot the corpse, character id + int allowed_looters[MAX_LOOTERS]; // People allowed to loot the corpse, character id Timer corpse_decay_timer; Timer corpse_res_timer; Timer corpse_delay_timer; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 2fb47eb28..a1b7779a8 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3320,115 +3320,50 @@ bool ZoneDatabase::GetFactionIdsForNPC(uint32 nfl_id, std::list