Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::Windows Servers

Support::Windows Servers Support forum for Windows EQEMu users.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #27  
Old 10-03-2015, 10:26 AM
AdrianD
Discordant
 
Join Date: Dec 2013
Posts: 297
Default

A little more progress on the pet thing.

The entire delete/save process (creating a new blank entry in table `character_pet_info`) for the DB in one spot. This eliminates running a couple unneeded queries from using the <SavePetInfo> function.

The pet window still appears on client. I don't know if this is avoidable by doing the norent check somewhere earlier in the process. It's not a big deal unless there is a cleaner/more efficient way to do this.

\client_process.cpp
Code:
	bool deletenorent = database.NoRentExpired(GetName());
	if (deletenorent) { //client was offline for more than 30 minutes, delete no rent items
		if (RuleB(Inventory, TransformSummonedBags))
			DisenchantSummonedBags(false);
		RemoveNoRent(false);

// added 9/30/15 no rent check (updated 10/3/15)
		if (!RuleB(Pets, PetLogPersistence))
		{
			SetPet(0);

			database.DeletePetInfo(this);
		}
	}
\zonedb.cpp
Code:
void ZoneDatabase::DeletePetInfo(Client *client)
{
	std::string query = StringFormat("DELETE FROM `character_pet_info` WHERE `char_id` = %u AND `pet` = 0", client->CharacterID());
	auto results = database.QueryDatabase(query);
	if (!results.Success())
		return;

	query = StringFormat("DELETE FROM `character_pet_buffs` WHERE `char_id` = %u AND `pet` = 0", client->CharacterID());
	results = database.QueryDatabase(query);
	if (!results.Success())
		return;

	query = StringFormat("DELETE FROM `character_pet_inventory` WHERE `char_id` = %u AND `pet` = 0", client->CharacterID());
	results = database.QueryDatabase(query);
	if (!results.Success())
		return;

	PetInfo *petinfo = client->GetPetInfo(0);

	memset(petinfo, 0, sizeof(struct PetInfo));

	int pet = 0;

	query = StringFormat("INSERT INTO `character_pet_info` "
		"(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`) "
		"VALUES (%u, %u, '%s', %i, %u, %u, %u, %f) "
		"ON DUPLICATE KEY UPDATE `petname` = '%s', `petpower` = %i, `spell_id` = %u, "
		"`hp` = %u, `mana` = %u, `size` = %f",
		client->CharacterID(), pet, petinfo->Name, petinfo->petpower, petinfo->SpellID,
		petinfo->HP, petinfo->Mana, petinfo->size, // and now the ON DUPLICATE ENTRIES
		petinfo->Name, petinfo->petpower, petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size);
	results = database.QueryDatabase(query);
	if (!results.Success())
		return;
	query.clear();
}
As an aside: While going through this process I noticed some queries are ran anywhere between 2-6 times from this maybe? <database.QueryDatabase(query);>

I understand my tinkering may have caused some of this but, I'm curious to know the purpose of this.

Thanks

EDIT:

Not sure if I mentioned this before. I had to add the line below when I created the item in \zonedb.cpp. Can't take it for granted.

\zonedb.h
Code:
	void DeletePetInfo(Client *c);
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:30 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3