Removed database call from faction discovery replaced with native delayed write function. Faction will appear in database on next character save.

This commit is contained in:
Devn00b 2022-04-17 11:01:21 -07:00
parent 5a8eaf5ae7
commit f02717f2f3
4 changed files with 5 additions and 18 deletions

View file

@ -12730,9 +12730,7 @@ int EQ2Emu_lua_ChangeFaction(lua_State* state) {
//they do not have the faction. Lets get the default value and feed it in.
sint32 defaultfaction = master_faction_list.GetDefaultFactionValue(faction_id);
//add the default faction for the player.
database.AddDefaultFaction(player->GetCharacterID(), faction_id, defaultfaction);
//load the clients factions. without this it gets reset to -100 on character save.
database.LoadPlayerFactions(client);
player->SetFactionValue(faction_id, defaultfaction);
}
if(increase >= 0) {

View file

@ -7946,10 +7946,3 @@ bool WorldDatabase::VerifyFactionID(int32 char_id, int32 faction_id) {
return true;
}
//devn00b: handle adding default faction value to the db when a player discovers it
void WorldDatabase::AddDefaultFaction(int32 char_id, int32 faction_id, sint32 faction_value) {
Query query;
//TODO: there is probably a better way to do this rather than writing to the db. I'll figure it out at some point.
query.RunQuery2(Q_INSERT, "insert into character_factions (char_id, faction_id, faction_level ) values (%u,%u,%i)",char_id, faction_id, faction_value);
//query.RunQuery2(Q_INSERT, "update character_factions set faction_level = %i where char_id=%u and faction_id=%u", faction_value, char_id, faction_id);
}

View file

@ -223,7 +223,6 @@ public:
bool LoadPlayerFactions(Client* client);
void SavePlayerFactions(Client* client);
bool VerifyFactionID(int32 char_id, int32 faction_id);
void AddDefaultFaction(int32 char_id, int32 faction_id, sint32 faction_value);
void LoadSpawnScriptData();
void LoadZoneScriptData();
int32 LoadSpellScriptData();

View file

@ -4294,14 +4294,13 @@ void ZoneServer::ProcessFaction(Spawn* spawn, Client* client)
if(player->GetFactions()->ShouldDecrease(spawn->GetFactionID()))
{
//make sure the player has discovered the faction before we do anything with it, otherwise add it.
bool hasfaction = database.VerifyFactionID(player->GetCharacterID(),spawn->GetFactionID());
bool hasfaction = database.VerifyFactionID(player->GetCharacterID(), spawn->GetFactionID());
database.VerifyFactionID(player->GetCharacterID(),spawn->GetFactionID());
if(hasfaction == 0) {
//they do not have the faction. Lets get the default value and feed it in.
sint32 defaultfaction = master_faction_list.GetDefaultFactionValue(spawn->GetFactionID());
//add the default faction for the player.
database.AddDefaultFaction(player->GetCharacterID(), spawn->GetFactionID(), defaultfaction);
//load the clients factions. without this it gets reset to -100 on character save.
database.LoadPlayerFactions(client);
player->SetFactionValue(spawn->GetFactionID(), defaultfaction);
}
update_result = player->GetFactions()->DecreaseFaction(spawn->GetFactionID());
@ -4349,9 +4348,7 @@ void ZoneServer::ProcessFaction(Spawn* spawn, Client* client)
//they do not have the faction. Lets get the default value and feed it in.
sint32 defaultfaction = master_faction_list.GetDefaultFactionValue(spawn->GetFactionID());
//add the default faction for the player.
database.AddDefaultFaction(player->GetCharacterID(), spawn->GetFactionID(), defaultfaction);
//load the clients factions. without this it gets reset to -100 on character save.
database.LoadPlayerFactions(client);
player->SetFactionValue(spawn->GetFactionID(), defaultfaction);
}
update_result = player->GetFactions()->DecreaseFaction(*itr);