View Single Post
  #1  
Old 01-13-2010, 09:16 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,490
Default COMMITTED: Faction Values

Issue: faction_values table size can become exponential with a large player base

Discussion: Server writes all values for faction changes to the database; even those that have no faction adjustment (0 faction). Example: KOS (id:366) does not need +/- adjustments when you kill an NPC on faction KOS. However, when a PC kills that NPC, the server sets a new faction value which turns out to be 0.

Recommendation: Remove all current entries with zero faction adjustment as the server already accounts for 0. Prevent the server from adding faction values of 0.

Code Modifications:
Code:
Index: faction.cpp
===================================================================
--- faction.cpp	(revision 1098)
+++ faction.cpp	(working copy)
@@ -841,7 +841,11 @@
 		safe_delete_array(query);
 		return false;
 	}
-	
+
+	if (value == 0) {
+		return true;
+	}
+
 	if (!RunQuery(query, MakeAnyLenString(&query, 
 		"INSERT INTO faction_values (char_id,faction_id,current_value) VALUES (%i,%i,%i)", 
 		char_id, faction_id,value), errbuf, 0, &affected_rows)) {
Optional SQL Code:
Code:
DELETE FROM faction_values WHERE current_value = 0;

Last edited by Derision; 01-17-2010 at 05:43 PM.. Reason: Stickied for review by me
Reply With Quote