Browse Source

Removed useless check for creation of faction. Enabled faction creation check for both Increase/Decrease.

Devn00b 2 years ago
parent
commit
7455c6ea99
2 changed files with 19 additions and 11 deletions
  1. 7 2
      EQ2/source/WorldServer/Factions.cpp
  2. 12 9
      EQ2/source/WorldServer/zoneserver.cpp

+ 7 - 2
EQ2/source/WorldServer/Factions.cpp

@@ -19,10 +19,12 @@
 */
 #include "Factions.h"
 #include "client.h"
+#include "Player.h"
 
 extern MasterFactionList master_faction_list;
 extern ConfigReader configReader;
 
+
 PlayerFaction::PlayerFaction(){
 	MFactionUpdateNeeded.SetName("PlayerFaction::MFactionUpdateNeeded");
 }
@@ -115,8 +117,11 @@ EQ2Packet* PlayerFaction::FactionUpdate(int16 version){
 sint32 PlayerFaction::GetFactionValue(int32 faction_id){
 	if(faction_id <= 10)
 		return 0;
-	if(faction_values.count(faction_id) == 0)
-		return master_faction_list.GetDefaultFactionValue(faction_id); //faction_values[faction_id] = master_faction_list.GetDefaultFactionValue(faction_id);
+
+	//devn00b: This always seems to return 1, even if the player infact has no faction. since we handle this via a check in zoneserver.cpp (processfaction)
+	//if(faction_values.count(faction_id) == 0)
+	//return master_faction_list.GetDefaultFactionValue(faction_id); //faction_values[faction_id] = master_faction_list.GetDefaultFactionValue(faction_id);
+
 	return faction_values[faction_id];
 }
 

+ 12 - 9
EQ2/source/WorldServer/zoneserver.cpp

@@ -4291,17 +4291,19 @@ void ZoneServer::ProcessFaction(Spawn* spawn, Client* client)
 		vector<int32>* factions = 0;
 		Player* player = client->GetPlayer();
 
+		bool hasfaction = database.VerifyFactionID(player->GetCharacterID(), spawn->GetFactionID());
+		//if 0 they dont have an entry in the db for this faction. if one they do and we can skip it.
+		if(hasfaction == 0) {
+			//Find out the default for this faction
+			sint32 defaultfaction = master_faction_list.GetDefaultFactionValue(spawn->GetFactionID());
+			//add the default faction for the player.
+			player->SetFactionValue(spawn->GetFactionID(), defaultfaction);
+			//save the character so the new default gets written to the db. 
+			client->Save();
+		}
+
 		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()); 
-			
-			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.
-				player->SetFactionValue(spawn->GetFactionID(), defaultfaction);
-			}
 
 			update_result = player->GetFactions()->DecreaseFaction(spawn->GetFactionID());
 			faction = master_faction_list.GetFaction(spawn->GetFactionID());
@@ -4321,6 +4323,7 @@ void ZoneServer::ProcessFaction(Spawn* spawn, Client* client)
 				{
 					if(player->GetFactions()->ShouldIncrease(*itr))
 					{
+
 						update_result = player->GetFactions()->IncreaseFaction(*itr);
 						faction = master_faction_list.GetFaction(*itr);