PDA

View Full Version : COMMITTED: Faction Values


joligario
01-13-2010, 09:16 PM
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:
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:
DELETE FROM faction_values WHERE current_value = 0;

Derision
01-18-2010, 02:57 PM
This is in Rev1118. I don't pretend to understand the intricacies of how faction values are handled, but this change seemed to make sense to me.