All pastes #2054698 Raw Edit

Anonymous

public text v1 · immutable
#2054698 ·published 2011-05-06 22:11 UTC
rendered paste body
Index: PlayerCorpse.cpp
===================================================================
--- PlayerCorpse.cpp	(revision 1886)
+++ PlayerCorpse.cpp	(working copy)
@@ -68,7 +68,7 @@
 	safe_delete(outapp);
 }
 
-Corpse* Corpse::LoadFromDBData(int32 in_dbid, int32 in_charid, char* in_charname, uchar* in_data, int32 in_datasize, float in_x, float in_y, float in_z, float in_heading, char* timeofdeath, bool rezzed, bool wasAtGraveyard) {
+Corpse* Corpse::LoadFromDBData(int32 in_dbid, int32 in_charid, char* in_charname, uchar* in_data, int32 in_datasize, float in_x, float in_y, float in_z, float in_heading, char* timeofdeath, bool rezzed, bool wasAtGraveyard, sint32 baserace) {
 	if (in_datasize < sizeof(classic_db::DBPlayerCorpse_Struct)) {
 		cout << "Corpse::LoadFromDBData: Corrupt data: in_datasize < sizeof(DBPlayerCorpse_Struct)" << endl;
 		return 0;
@@ -116,7 +116,7 @@
 				RealRace = dbpc->race;
 		}
 
-		Corpse* pc = new Corpse(in_dbid, in_charid, in_charname, &itemlist, dbpcs->copper, dbpcs->silver, dbpcs->gold, dbpcs->plat, in_x, in_y, in_z, in_heading, dbpcs->size, dbpcs->gender, RealRace, dbpcs->class_, dbpcs->deity, dbpcs->level, dbpcs->texture, dbpcs->helmtexture, dbpcs->exp, wasAtGraveyard);
+		Corpse* pc = new Corpse(in_dbid, in_charid, in_charname, &itemlist, dbpcs->copper, dbpcs->silver, dbpcs->gold, dbpcs->plat, in_x, in_y, in_z, in_heading, dbpcs->size, dbpcs->gender, RealRace, dbpcs->class_, dbpcs->deity, dbpcs->level, dbpcs->texture, dbpcs->helmtexture, dbpcs->exp, wasAtGraveyard, baserace);
 		if (dbpcs->locked)
 			pc->Lock();
 
@@ -339,6 +339,7 @@
 	platinum		= 0;
 	strcpy(orgname, pp->name);
 	strcpy(name, pp->name);
+	SetBaseRace(0);
 	
 	//become_npc was not being initialized which led to some pretty funky things with newly created corpses
 	become_npc = false;
@@ -381,6 +382,8 @@
 		client->Save();
 	} //end "not leaving naked corpses"
 	
+
+	SetBaseRace(client->GetBaseRace());
 	Rezzed(false);
 	Save();
 }
@@ -412,7 +415,7 @@
 
 // To be called from LoadFromDBData
 // Mongrel: added see_invis and see_invis_undead
-Corpse::Corpse(int32 in_dbid, int32 in_charid, char* in_charname, ItemList* in_itemlist, int32 in_copper, int32 in_silver, int32 in_gold, int32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, int8 in_gender, int16 in_race, int8 in_class, int8 in_deity, int8 in_level, int8 in_texture, int8 in_helmtexture,int32 in_rezexp, bool wasAtGraveyard)
+Corpse::Corpse(int32 in_dbid, int32 in_charid, char* in_charname, ItemList* in_itemlist, int32 in_copper, int32 in_silver, int32 in_gold, int32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, int8 in_gender, int16 in_race, int8 in_class, int8 in_deity, int8 in_level, int8 in_texture, int8 in_helmtexture,int32 in_rezexp, bool wasAtGraveyard, sint32 baserace)
  : Mob("Unnamed_Corpse","",0,0,in_gender, in_race, in_class, BT_Humanoid, in_deity, in_level,0, in_size, 0, in_heading, in_x, in_y, in_z,0,in_texture,in_helmtexture,
 	 0,0,0,0,0,0,0,0,0,
 	 0,0,0,0,0,0,0,0,0,0,0,0xff,
@@ -450,6 +453,7 @@
 	for (int i=0; i<MAX_LOOTERS; i++)
 		looters[i] = 0;
 	SetPKItem(0);
+	SetBaseRace(baserace);
 }
 
 Corpse::~Corpse() {
@@ -544,7 +548,7 @@
 	dbpc->crc = CRC32::Generate(&((uchar*) dbpc)[4], tmpsize - 4);
 
 	if (dbid == 0)
-		dbid = database.CreatePlayerCorpse(charid, orgname, zone->GetZoneID(), zone->GetInstanceID(), (uchar*) dbpc, tmpsize, x_pos, y_pos, z_pos, heading);
+		dbid = database.CreatePlayerCorpse(charid, orgname, zone->GetZoneID(), zone->GetInstanceID(), (uchar*) dbpc, tmpsize, x_pos, y_pos, z_pos, heading, baserace);
 	else
 		dbid = database.UpdatePlayerCorpse(dbid, charid, orgname, zone->GetZoneID(), zone->GetInstanceID(), (uchar*) dbpc, tmpsize, x_pos, y_pos, z_pos, heading,Rezzed());
 	safe_delete_array(dbpc);
@@ -1018,7 +1022,7 @@
 	else if(GetPKItem()==-1 || GetPKItem()==1)
 		item_data = GetItem(lootitem->slot_id - 22); //dont allow them to loot entire bags of items as pvp reward
 	else
-		item_data = GetItem(lootitem->slot_id - 22, bag_item_data);
+	item_data = GetItem(lootitem->slot_id - 22, bag_item_data);
 
 	if (GetPKItem()<=1 && item_data != 0)
 	{
@@ -1443,7 +1447,7 @@
 	return dbid;
 }
 
-int32 ZoneDatabase::CreatePlayerCorpse(int32 charid, const char* charname, int32 zoneid, int16 instanceid, uchar* data, int32 datasize, float x, float y, float z, float heading) {
+int32 ZoneDatabase::CreatePlayerCorpse(int32 charid, const char* charname, int32 zoneid, int16 instanceid, uchar* data, int32 datasize, float x, float y, float z, float heading, sint32 baserace) {
 	char errbuf[MYSQL_ERRMSG_SIZE];
     char* query = new char[256+(datasize*2)];
 	char* end = query;
@@ -1456,7 +1460,7 @@
 	*end++ = '\'';
 	end += DoEscapeString(end, (char*)data, datasize);
 	*end++ = '\'';
-	end += sprintf(end,", charname='%s', zoneid=%u, instanceid=%u, charid=%d, x=%1.1f, y=%1.1f, z=%1.1f, heading=%1.1f, timeofdeath=Now(), IsBurried=0", charname, zoneid, instanceid, charid, x, y, z, heading);
+	end += sprintf(end,", charname='%s', zoneid=%u, instanceid=%u, charid=%d, x=%1.1f, y=%1.1f, z=%1.1f, heading=%1.1f, timeofdeath=Now(), baserace=%i, IsBurried=0", charname, zoneid, instanceid, charid, x, y, z, heading, baserace);
 	
     if (!RunQuery(query, (int32) (end - query), errbuf, 0, &affected_rows, &last_insert_id)) {
 		safe_delete_array(query);
@@ -1507,11 +1511,11 @@
 	Corpse* NewCorpse = 0;
 	unsigned long* lengths;
 	
-	if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, charname, data, timeofdeath, rezzed FROM player_corpses WHERE charid='%u' AND IsBurried=1 ORDER BY timeofdeath LIMIT 1", char_id), errbuf, &result)) {
+	if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, charname, data, timeofdeath, rezzed, baserace FROM player_corpses WHERE charid='%u' AND IsBurried=1 ORDER BY timeofdeath LIMIT 1", char_id), errbuf, &result)) {
 		row = mysql_fetch_row(result);
 		lengths = mysql_fetch_lengths(result);
 		if(row) {
-			NewCorpse = Corpse::LoadFromDBData(atoi(row[0]), char_id, row[1], (uchar*) row[2], lengths[2], dest_x, dest_y, dest_z, dest_heading, row[3],atoi(row[4])==1, false);
+			NewCorpse = Corpse::LoadFromDBData(atoi(row[0]), char_id, row[1], (uchar*) row[2], lengths[2], dest_x, dest_y, dest_z, dest_heading, row[3],atoi(row[4])==1, false, atoi(row[5]));
 			if(NewCorpse) {
 				entity_list.AddCorpse(NewCorpse);
 				if(!UnburyPlayerCorpse(NewCorpse->GetDBID(), dest_zoneid, dest_instanceid, dest_x, dest_y, dest_z, dest_heading))
@@ -1550,14 +1554,14 @@
 
 	safe_delete_array(query);
 		
-	if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, charname, data, timeofdeath, rezzed FROM player_corpses WHERE charid='%u'"
+	if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, charname, data, timeofdeath, rezzed, baserace FROM player_corpses WHERE charid='%u'"
 						     "ORDER BY timeofdeath", char_id), errbuf, &result))
 	{
 		while((row = mysql_fetch_row(result)))
 		{
 			lengths = mysql_fetch_lengths(result);
 			NewCorpse = Corpse::LoadFromDBData(atoi(row[0]), char_id, row[1], (uchar*) row[2], lengths[2], dest_x, dest_y,
-							   dest_z, dest_heading, row[3],atoi(row[4])==1, false);
+							   dest_z, dest_heading, row[3],atoi(row[4])==1, false, atoi(row[5]) );
 			if(NewCorpse) {
 				entity_list.AddCorpse(NewCorpse);
 				NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS));
@@ -1609,10 +1613,10 @@
 	Corpse* NewCorpse = 0;
 	unsigned long* lengths;
 	
-	if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, charid, charname, x, y, z, heading, data, timeofdeath, rezzed, WasAtGraveyard FROM player_corpses WHERE id='%u'", player_corpse_id), errbuf, &result)) {
+	if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, charid, charname, x, y, z, heading, data, timeofdeath, rezzed, WasAtGraveyard, baserace FROM player_corpses WHERE id='%u'", player_corpse_id), errbuf, &result)) {
 		row = mysql_fetch_row(result);
 		lengths = mysql_fetch_lengths(result);
-		NewCorpse = Corpse::LoadFromDBData(atoi(row[0]), atoi(row[1]), row[2], (uchar*) row[7], lengths[7], atof(row[3]), atoi(row[4]), atoi(row[5]), atoi(row[6]), row[8],atoi(row[9])==1, atoi(row[10]));
+		NewCorpse = Corpse::LoadFromDBData(atoi(row[0]), atoi(row[1]), row[2], (uchar*) row[7], lengths[7], atof(row[3]), atoi(row[4]), atoi(row[5]), atoi(row[6]), row[8],atoi(row[9])==1, atoi(row[10]),atoi(row[11]) );
 		entity_list.AddCorpse(NewCorpse);
 		mysql_free_result(result);
 	}
@@ -1636,15 +1640,15 @@
 	unsigned long* lengths;
 
 	if(!RuleB(Zone, EnableShadowrest))
-		query_length = MakeAnyLenString(&query, "SELECT id, charid, charname, x, y, z, heading, data, timeofdeath, rezzed, WasAtGraveyard FROM player_corpses WHERE zoneid='%u' AND instanceid='%u'", iZoneID, iInstanceID);
+		query_length = MakeAnyLenString(&query, "SELECT id, charid, charname, x, y, z, heading, data, timeofdeath, rezzed, WasAtGraveyard, bacerace FROM player_corpses WHERE zoneid='%u' AND instanceid='%u'", iZoneID, iInstanceID);
 	else
-		query_length = MakeAnyLenString(&query, "SELECT id, charid, charname, x, y, z, heading, data, timeofdeath, rezzed, 0 FROM player_corpses WHERE zoneid='%u' AND instanceid='%u' AND IsBurried=0", iZoneID, iInstanceID);
+		query_length = MakeAnyLenString(&query, "SELECT id, charid, charname, x, y, z, heading, data, timeofdeath, rezzed, 0, baserace FROM player_corpses WHERE zoneid='%u' AND instanceid='%u' AND IsBurried=0", iZoneID, iInstanceID);
 
 	if (RunQuery(query, query_length, errbuf, &result)) {
 		safe_delete_array(query);
 		while ((row = mysql_fetch_row(result))) {
 			lengths = mysql_fetch_lengths(result);
-			entity_list.AddCorpse(Corpse::LoadFromDBData(atoi(row[0]), atoi(row[1]), row[2], (uchar*) row[7], lengths[7], atof(row[3]), atoi(row[4]), atoi(row[5]), atoi(row[6]), row[8],atoi(row[9])==1, atoi(row[10])));
+			entity_list.AddCorpse(Corpse::LoadFromDBData(atoi(row[0]), atoi(row[1]), row[2], (uchar*) row[7], lengths[7], atof(row[3]), atoi(row[4]), atoi(row[5]), atoi(row[6]), row[8],atoi(row[9])==1, atoi(row[10]), atoi(row[11]) ));
 		}
 		mysql_free_result(result);
 	}
Index: PlayerCorpse.h
===================================================================
--- PlayerCorpse.h	(revision 1886)
+++ PlayerCorpse.h	(working copy)
@@ -31,11 +31,11 @@
 public:
 	static void SendEndLootErrorPacket(Client* client);
 	static void SendLootReqErrorPacket(Client* client, int8 response = 2);
-	static Corpse* LoadFromDBData(int32 in_corpseid, int32 in_charid, char* in_charname, uchar* in_data, int32 in_datasize, float in_x, float in_y, float in_z, float in_heading, char* timeofdeath, bool rezzed = false, bool wasAtGraveyard = false);
+	static Corpse* LoadFromDBData(int32 in_corpseid, int32 in_charid, char* in_charname, uchar* in_data, int32 in_datasize, float in_x, float in_y, float in_z, float in_heading, char* timeofdeath, bool rezzed = false, bool wasAtGraveyard = false, sint32 baserace = 0);
 
 	Corpse(NPC* in_npc, ItemList* in_itemlist, int32 in_npctypeid, const NPCType** in_npctypedata, int32 in_decaytime = 600000);
 	Corpse(Client* client, sint32 in_rezexp);
-	Corpse(int32 in_corpseid, int32 in_charid, char* in_charname, ItemList* in_itemlist, int32 in_copper, int32 in_silver, int32 in_gold, int32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, int8 in_gender, int16 in_race, int8 in_class, int8 in_deity, int8 in_level, int8 in_texture, int8 in_helmtexture,int32 in_rezexp, bool wasAtGraveyard = false);
+	Corpse(int32 in_corpseid, int32 in_charid, char* in_charname, ItemList* in_itemlist, int32 in_copper, int32 in_silver, int32 in_gold, int32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, int8 in_gender, int16 in_race, int8 in_class, int8 in_deity, int8 in_level, int8 in_texture, int8 in_helmtexture,int32 in_rezexp, bool wasAtGraveyard = false, sint32 baserace = 0);
 	~Corpse();
 
 	//abstract virtual function implementations requird by base abstract class
@@ -97,6 +97,8 @@
 	void	CompleteRezz();
 	void	SetPKItem(sint32 id) { pkitem = id; }
 	sint32	GetPKItem() { return pkitem; }
+	void	SetBaseRace(sint32 id) { baserace = id; }
+	sint32	GetBaseRace() { return baserace; }
 	bool CanMobLoot(int charid);
 	void AllowMobLoot(Mob *them, int8 slot);
 	void AddLooter(Mob *who);
@@ -117,6 +119,7 @@
 	bool		pIsChanged;
 	bool		pLocked;
 	sint32		pkitem;
+	sint32		baserace;
 	int32		dbid;
 	int32		charid;
 	ItemList	itemlist;
Index: zonedb.h
===================================================================
--- zonedb.h	(revision 1886)
+++ zonedb.h	(working copy)
@@ -148,7 +148,7 @@
 	 * Corpses
 	 */
 	bool	GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes);
-	int32	CreatePlayerCorpse(int32 charid, const char* charname, int32 zoneid, int16 instanceid, uchar* data, int32 datasize, float x, float y, float z, float heading);
+	int32	CreatePlayerCorpse(int32 charid, const char* charname, int32 zoneid, int16 instanceid, uchar* data, int32 datasize, float x, float y, float z, float heading, sint32 baserace);
 	int32	UpdatePlayerCorpse(int32 dbid, int32 charid, const char* charname, int32 zoneid, int16 instanceid, uchar* data, int32 datasize, float x, float y, float z, float heading, bool rezzed = false);
 	bool	BuryPlayerCorpse(int32 dbid);
 	bool	DeletePlayerCorpse(int32 dbid);