From: <wel...@us...> - 2009-07-28 21:17:28
|
Revision: 4145 http://planeshift.svn.sourceforge.net/planeshift/?rev=4145&view=rev Author: weltall2 Date: 2009-07-28 21:17:15 +0000 (Tue, 28 Jul 2009) Log Message: ----------- improved even more the faction life events and added a missing file Modified Paths: -------------- trunk/src/common/rpgrules/factions.h trunk/src/server/bulkobjects/pscharacter.cpp trunk/src/server/cachemanager.cpp trunk/src/server/cachemanager.h Modified: trunk/src/common/rpgrules/factions.h =================================================================== --- trunk/src/common/rpgrules/factions.h 2009-07-28 19:08:55 UTC (rev 4144) +++ trunk/src/common/rpgrules/factions.h 2009-07-28 21:17:15 UTC (rev 4145) @@ -30,6 +30,9 @@ { int value; ///< Value from which this life event is attribuited csString event_description; ///< The text of this life event + + bool operator== (FactionLifeEvent OtherEvt) const { return value == OtherEvt.value; } + bool operator< (FactionLifeEvent OtherEvt) const { return value < OtherEvt.value; } }; /** An ingame faction group. @@ -41,8 +44,8 @@ csString description; int id; float weight; - csHash<FactionLifeEvent*, int> PositiveFactionEvents; ///< Stores the Positive faction values life events - csHash<FactionLifeEvent*, int> NegativeFactionEvents; ///< Stores the Negative faction values life events + csArray<FactionLifeEvent> PositiveFactionEvents; ///< Stores the Positive faction values life events + csArray<FactionLifeEvent> NegativeFactionEvents; ///< Stores the Negative faction values life events }; Modified: trunk/src/server/bulkobjects/pscharacter.cpp =================================================================== --- trunk/src/server/bulkobjects/pscharacter.cpp 2009-07-28 19:08:55 UTC (rev 4144) +++ trunk/src/server/bulkobjects/pscharacter.cpp 2009-07-28 21:17:15 UTC (rev 4145) @@ -3591,7 +3591,7 @@ int score = 0; //used to store the current score if(standing->score >= 0) //positive factions { - csArray<FactionLifeEvent>::Iterator scoreIter = standing->faction->PositiveFactionEvents.GetIterator(); + csArray<FactionLifeEvent>::ReverseIterator scoreIter = standing->faction->PositiveFactionEvents.GetReverseIterator(); score = standing->score; while (scoreIter.HasNext()) { @@ -3605,7 +3605,7 @@ } else //negative factions { - csArray<FactionLifeEvent>::Iterator scoreIter = standing->faction->NegativeFactionEvents.GetIterator(); + csArray<FactionLifeEvent>::ReverseIterator scoreIter = standing->faction->NegativeFactionEvents.GetReverseIterator(); score = abs(standing->score); //we store values as positive to make things easier and faster so take the //absolute value while (scoreIter.HasNext()) Modified: trunk/src/server/cachemanager.cpp =================================================================== --- trunk/src/server/cachemanager.cpp 2009-07-28 19:08:55 UTC (rev 4144) +++ trunk/src/server/cachemanager.cpp 2009-07-28 21:17:15 UTC (rev 4145) @@ -2323,7 +2323,7 @@ return true; } -bool CacheManager::PreloadFactionCharacterEvents(const char* script, Faction* faction) +void CacheManager::PreloadFactionCharacterEvents(const char* script, Faction* faction) { csString factionCharacterEvents = script; while(factionCharacterEvents.Length()) @@ -2356,7 +2356,9 @@ //prepare for the next line factionCharacterEvents = factionCharacterEvents.Slice(cutpos2+1); } - return true; + //sort the entries. It's needed to have a faster runtime access. + faction->PositiveFactionEvents.Sort(); + faction->NegativeFactionEvents.Sort(); } bool CacheManager::PreloadFactions() @@ -2374,6 +2376,7 @@ f->name = result_factions[x]["faction_name"]; f->description = result_factions[x]["faction_description"]; f->weight = atof( result_factions[x]["faction_weight"] ); + // Parses the script for factions dynamic life events and populates the arrays for it // used to store the script to be parsed to generate dynamic life events PreloadFactionCharacterEvents(result_factions[x]["faction_character"], f); Modified: trunk/src/server/cachemanager.h =================================================================== --- trunk/src/server/cachemanager.h 2009-07-28 19:08:55 UTC (rev 4144) +++ trunk/src/server/cachemanager.h 2009-07-28 21:17:15 UTC (rev 4145) @@ -413,7 +413,7 @@ bool PreloadItemCategories(); bool PreloadWays(); ///preloads the character events script for a faction - bool PreloadFactionCharacterEvents(const char* script, Faction* faction); + void PreloadFactionCharacterEvents(const char* script, Faction* faction); bool PreloadFactions(); bool PreloadScripts(); bool PreloadSpells(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |