Planeshift
Public Member Functions | Protected Attributes

FactionSet Class Reference

This class is a set of faction structures. More...

#include <factions.h>

List of all members.

Public Member Functions

bool CheckFaction (Faction *faction, int value)
 Check given faction.
 FactionSet (const char *csv_list, csHash< Faction *, int, CS::Memory::AllocatorMalloc > &factionset)
 Construct the faction set based on the comma delimited text.
float FindWeightedDiff (FactionSet *other)
int GetFaction (Faction *faction)
 Just get the number.
void GetFactionListCSV (csString &csv)
 Create a comma delimited string based on the current faction standings.
bool GetFactionStanding (int factionID, int &standing, float &weight)
csHash< FactionStanding *, int > & GetStandings ()
void UpdateFactionStanding (int factionID, int delta, bool setDirty=true, bool overwrite=false)
 Updates a faction standing.
 ~FactionSet ()

Protected Attributes

csHash< Faction *, int > * factions_by_id
 A list of all the factions in this set.
csHash< FactionStanding *, intfactionstandings
 A list of all the standings with each faction.

Detailed Description

This class is a set of faction structures.

It's designed for storing, updating and saving many faction scores per player in a compact way.

Definition at line 68 of file factions.h.


Constructor & Destructor Documentation

FactionSet::FactionSet ( const char *  csv_list,
csHash< Faction *, int, CS::Memory::AllocatorMalloc > &  factionset 
)

Construct the faction set based on the comma delimited text.

Parameters:
csv_listThe list of comma delimited factions. Faction,score.
factionsetThe global list of factions.
FactionSet::~FactionSet ( )

Member Function Documentation

bool FactionSet::CheckFaction ( Faction faction,
int  value 
)

Check given faction.

float FactionSet::FindWeightedDiff ( FactionSet other)
int FactionSet::GetFaction ( Faction faction)

Just get the number.

void FactionSet::GetFactionListCSV ( csString &  csv)

Create a comma delimited string based on the current faction standings.

Parameters:
csvThe destination for the constructed string.
bool FactionSet::GetFactionStanding ( int  factionID,
int standing,
float weight 
)
csHash<FactionStanding*, int>& FactionSet::GetStandings ( ) [inline]

Definition at line 109 of file factions.h.

void FactionSet::UpdateFactionStanding ( int  factionID,
int  delta,
bool  setDirty = true,
bool  overwrite = false 
)

Updates a faction standing.

If the factionID is not in the current list of standings a new standing is added.

Parameters:
factionIDThe ID of the faction to update.
deltaThe amount to change the faction score by. If the faction is not in the current list this will be the starting score.
setDirtydeclares if the variable should be set dirty when updated.
overwriteSets if the delta should overwrite the current value (true) or just be added to the current value (false)

Member Data Documentation

csHash<Faction*, int>* FactionSet::factions_by_id [protected]

A list of all the factions in this set.

Definition at line 75 of file factions.h.

A list of all the standings with each faction.

Definition at line 72 of file factions.h.


The documentation for this class was generated from the following file: