Browse Source

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

Devn00b 2 years ago
parent
commit
f02717f2f3

+ 1 - 3
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -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) {

+ 0 - 7
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -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);
-}

+ 0 - 1
EQ2/source/WorldServer/WorldDatabase.h

@@ -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();

+ 4 - 7
EQ2/source/WorldServer/zoneserver.cpp

@@ -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);