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;