Changing corpse loading structure

This commit is contained in:
Akkadius 2014-11-22 18:43:23 -06:00
parent 111fb84041
commit d1b0564698
3 changed files with 69 additions and 41 deletions

View File

@ -63,36 +63,62 @@ void Corpse::SendLootReqErrorPacket(Client* client, uint8 response) {
safe_delete(outapp); safe_delete(outapp);
} }
Corpse* Corpse::LoadFromDBData(uint32 in_dbid, uint32 in_charid, char* in_charname, PlayerCorpse_Struct* pcs, float in_x, float in_y, float in_z, float in_heading, char* time_of_death, bool rezzed, bool was_at_graveyard) { Corpse* Corpse::LoadFromDBData(uint32 in_dbid, uint32 in_charid, char* in_charname, float in_x, float in_y, float in_z, float in_heading, char* time_of_death, bool rezzed, bool was_at_graveyard) {
PlayerCorpse_Struct pcs;
database.LoadCharacterCorpseData(in_dbid, &pcs);
/* Load Items */ /* Load Items */
ItemList itemlist; ItemList itemlist;
ServerLootItem_Struct* tmp = 0; ServerLootItem_Struct* tmp = 0;
for (unsigned int i = 0; i < pcs->itemcount; i++) { for (unsigned int i = 0; i < pcs.itemcount; i++) {
tmp = new ServerLootItem_Struct; tmp = new ServerLootItem_Struct;
memcpy(tmp, &pcs->items[i], sizeof(player_lootitem::ServerLootItem_Struct)); memcpy(tmp, &pcs.items[i], sizeof(player_lootitem::ServerLootItem_Struct));
tmp->equipSlot = CorpseToServerSlot(tmp->equipSlot); tmp->equipSlot = CorpseToServerSlot(tmp->equipSlot);
itemlist.push_back(tmp); itemlist.push_back(tmp);
} }
/* Create Corpse Entity */ /* Create Corpse Entity */
Corpse* pc = new Corpse(in_dbid, in_charid, in_charname, &itemlist, pcs->copper, pcs->silver, pcs->gold, pcs->plat, in_x, in_y, in_z, in_heading, pcs->size, pcs->gender, pcs->race, pcs->class_, pcs->deity, pcs->level, pcs->texture, pcs->helmtexture, pcs->exp, was_at_graveyard); Corpse* pc = new Corpse(
if (pcs->locked) in_dbid,
in_charid,
in_charname,
&itemlist,
pcs.copper,
pcs.silver,
pcs.gold,
pcs.plat,
in_x,
in_y,
in_z,
in_heading,
pcs.size,
pcs.gender,
pcs.race,
pcs.class_,
pcs.deity,
pcs.level,
pcs.texture,
pcs.helmtexture,
pcs.exp,
was_at_graveyard
);
if (pcs.locked)
pc->Lock(); pc->Lock();
/* Load Item Tints */ /* Load Item Tints */
memcpy(pc->item_tint, pcs->item_tint, sizeof(pc->item_tint)); memcpy(pc->item_tint, pcs.item_tint, sizeof(pc->item_tint));
/* Load Physical Appearance */ /* Load Physical Appearance */
pc->haircolor = pcs->haircolor; pc->haircolor = pcs.haircolor;
pc->beardcolor = pcs->beardcolor; pc->beardcolor = pcs.beardcolor;
pc->eyecolor1 = pcs->eyecolor1; pc->eyecolor1 = pcs.eyecolor1;
pc->eyecolor2 = pcs->eyecolor2; pc->eyecolor2 = pcs.eyecolor2;
pc->hairstyle = pcs->hairstyle; pc->hairstyle = pcs.hairstyle;
pc->luclinface = pcs->face; pc->luclinface = pcs.face;
pc->beard = pcs->beard; pc->beard = pcs.beard;
pc->drakkin_heritage = pcs->drakkin_heritage; pc->drakkin_heritage = pcs.drakkin_heritage;
pc->drakkin_tattoo = pcs->drakkin_tattoo; pc->drakkin_tattoo = pcs.drakkin_tattoo;
pc->drakkin_details = pcs->drakkin_details; pc->drakkin_details = pcs.drakkin_details;
pc->IsRezzed(rezzed); pc->IsRezzed(rezzed);
pc->become_npc = false; pc->become_npc = false;

View File

@ -30,13 +30,14 @@ class Corpse : public Mob
{ {
public: public:
static void SendEndLootErrorPacket(Client* client); static void SendEndLootErrorPacket(Client* client);
static void SendLootReqErrorPacket(Client* client, uint8 response = 2); static void SendLootReqErrorPacket(Client* client, uint8 response = 2);
static Corpse* LoadFromDBData(uint32 in_corpseid, uint32 in_charid, char* in_charname, PlayerCorpse_Struct* pcs, float in_x, float in_y, float in_z, float in_heading, char* time_of_death, bool rezzed = false, bool wasAtGraveyard = false);
Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NPCType** in_npctypedata, uint32 in_decaytime = 600000); 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(Client* client, int32 in_rezexp);
Corpse(uint32 in_corpseid, uint32 in_charid, 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); Corpse(uint32 in_corpseid, uint32 in_charid, 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);
~Corpse(); ~Corpse();
static Corpse* LoadFromDBData(uint32 in_dbid, uint32 in_charid, char* in_charname, float in_x, float in_y, float in_z, float in_heading, char* time_of_death, bool rezzed, bool was_at_graveyard);
//abstract virtual function implementations requird by base abstract class //abstract virtual function implementations requird by base abstract class
virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, SkillUseTypes attack_skill) { return true; } virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, SkillUseTypes attack_skill) { return true; }

View File

@ -3884,9 +3884,18 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
PlayerCorpse_Struct pcs; NewCorpse = Corpse::LoadFromDBData(
database.LoadCharacterCorpseData(atoi(row[0]), &pcs); atoi(row[0]), // uint32 in_dbid
NewCorpse = Corpse::LoadFromDBData(atoi(row[0]), char_id, row[1], &pcs, dest_x, dest_y, dest_z, dest_heading, row[2], atoi(row[3]) == 1, false); char_id, // uint32 in_charid
row[1], // char* in_charname
dest_x, // float in_x
dest_y, // float in_y
dest_z, // float in_z
dest_heading, // float in_heading
row[2], // char* time_of_death
atoi(row[3]) == 1, // bool rezzed
false // bool was_at_graveyard
);
if (NewCorpse) { if (NewCorpse) {
entity_list.AddCorpse(NewCorpse); entity_list.AddCorpse(NewCorpse);
NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS));
@ -3917,18 +3926,17 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id
results = QueryDatabase(query); results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
PlayerCorpse_Struct pcs; NewCorpse = Corpse::LoadFromDBData(
database.LoadCharacterCorpseData(atoi(row[0]), &pcs); atoi(row[0]),
NewCorpse = Corpse::LoadFromDBData(atoi(row[0]),
char_id, char_id,
row[1], row[1],
&pcs,
dest_x, dest_x,
dest_y, dest_y,
dest_z, dest_z,
dest_heading, dest_heading,
row[2], row[2],
atoi(row[3]) == 1, false); atoi(row[3]) == 1,
false);
if (NewCorpse) { if (NewCorpse) {
entity_list.AddCorpse(NewCorpse); entity_list.AddCorpse(NewCorpse);
NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS));
@ -3963,18 +3971,15 @@ Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) {
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
PlayerCorpse_Struct pcs;
database.LoadCharacterCorpseData(atoi(row[0]), &pcs);
NewCorpse = Corpse::LoadFromDBData( NewCorpse = Corpse::LoadFromDBData(
atoi(row[0]), // id uint32 in_dbid atoi(row[0]), // id uint32 in_dbid
atoi(row[1]), // charid uint32 in_charid atoi(row[1]), // charid uint32 in_charid
row[2], // charname char* in_charname row[2], // char_name
&pcs, // PlayerCorpse_Struct* pcs
atof(row[3]), // x float in_x atof(row[3]), // x float in_x
atof(row[4]), // y float in_y atof(row[4]), // y float in_y
atof(row[5]), // z float in_z atof(row[5]), // z float in_z
atof(row[6]), // heading float in_heading atof(row[6]), // heading float in_heading
row[7], // time_of_death char* time_of_death row[7], // time_of_death char* time_of_death
atoi(row[8]) == 1, // is_rezzed bool rezzed atoi(row[8]) == 1, // is_rezzed bool rezzed
atoi(row[9]) // was_at_graveyard bool was_at_graveyard atoi(row[9]) // was_at_graveyard bool was_at_graveyard
); );
@ -3992,22 +3997,18 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) {
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
PlayerCorpse_Struct pcs; entity_list.AddCorpse(
database.LoadCharacterCorpseData(atoi(row[0]), &pcs);
entity_list.AddCorpse(
Corpse::LoadFromDBData( Corpse::LoadFromDBData(
atoi(row[0]), // id uint32 in_dbid atoi(row[0]), // id uint32 in_dbid
atoi(row[1]), // charid uint32 in_charid atoi(row[1]), // charid uint32 in_charid
row[2], // charname char* in_charname row[2], // PlayerCorpse_tSruct* pcs
&pcs, // PlayerCorpse_tSruct* pcs atof(row[3]), // x float in_x
atof(row[3]), // x float in_x
atof(row[4]), // y float in_y atof(row[4]), // y float in_y
atof(row[5]), // z float in_z atof(row[5]), // z float in_z
atof(row[6]), // heading float in_heading atof(row[6]), // heading float in_heading
row[7], // time_of_death char* time_of_death row[7], // time_of_death char* time_of_death
atoi(row[8]) == 1, // is_rezzed bool rezzed atoi(row[8]) == 1, // is_rezzed bool rezzed
atoi(row[9]) atoi(row[9]))
)
); );
} }