VR-Forces 4.0.4 Class Documentation
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
DtHostilityManager Class Reference

This class keeps track of which forces are hostile to which other forces in the simulation. More...

List of all members.

Public Member Functions

 DtHostilityManager (DtSimManager *simManager)
virtual ~DtHostilityManager ()
virtual bool init ()
 Initializes the hostility manager defaults.
virtual void setDefaultHostility ()
 Sets the default starting hostility setup.
virtual bool addForce (DtString forceName, DtVector forceColor, bool includeInDialogs)
 Add a force to the force manager.
virtual bool removeForce (DtU8 force)
 Remove a force from the force manager.
virtual void setHostility (DtU8 force, DtU8 targetForce, bool hostile)
 Invokes hostility changed callbacks if the set actually results in a change.
virtual bool hostile (DtU8 force, DtU8 targetForce) const
 Whether force is hostile to targetForce.
virtual void hostileForces (DtU8 force, std::list< DtU8 > &forceList) const
 Adds all force types that are hostile to force to forceList.
virtual void friendlyForces (DtU8 force, std::list< DtU8 > &forceList) const
 Adds all force types that are friendly to force to forceList.
virtual int numForces () const
 Returns the number of forces currently in use (named)
virtual DtU8 nextAvailableForceId ()
 Returns the next available index for a new force.
virtual const
DtRwForceDescriptionList
forceDescriptionList ()
 Saves the force hostility info into a force-hostility list.
virtual bool readHostilityFile (const DtString &filename)
 Reads the Hostility matrix file to the specified name and adds all current hostility from the file.
virtual void setDataFromDescriptionList (const DtRwForceDescriptionList &l)
 Loads all of the force-hostility data from a force-hostility list.
virtual void addHostilityChangedCallback (DtHostitliyChangedCallbackFcn fcn, void *usr)
 Callbacks that are called any time the hostility matrix changes.
virtual void removeHostilityChangedCallback (DtHostitliyChangedCallbackFcn fcn, void *usr)
 Callbacks that are called any time the hostility matrix changes.
virtual void setName (DtU8 force, DtString forceName)
 Name for a specific force.
virtual DtString name (DtU8 force) const
 Name for a specific force.
virtual void setIncludeInDialogs (DtU8 force, bool includeInDialogs)
 Whether or not a specific force is included in VRF dialogs.
virtual bool includeInDialogs (DtU8 force)
 Whether or not a specific force is included in VRF dialogs.
virtual void setColor (DtU8 force, DtVector forceColor)
 Color for a specific force.
virtual DtVector color (DtU8 force)
 Color for a specific force.
virtual void setForceIsUsed (DtU8 force, bool forceIsUsed)
 Whether force at index is used.
virtual bool forceIsUsed (DtU8 force)
 Whether force at index is used.

Protected Types

typedef DtCallbackList< DtU8 >
::DtCallbackFunctionType 
DtHostitliyChangedCallbackFcn
typedef std::vector< boolDtBoolVector
 Typedefs to make list definitions easier.
typedef std::vector< DtBoolVectorDtBoolVectorVector
typedef std::vector< DtStringDtNameVector
typedef std::vector< DtVectorDtVectorVector

Protected Member Functions

virtual void registerInterfaceMessageCallbacks ()
 Message handlers.
virtual void clearMatrix ()
 Utility functions to use while reading data.

Protected Attributes

DtSimManagermySimManager
 Local members.
DtBoolVectorVector myHostilityMatrix
 Tracks which forces are hostile to which other forces.
DtNameVector myNameVector
DtBoolVector myIncludeInDialogsVector
DtVectorVector myColorVector
DtBoolVector myForceIsUsedVector
DtRwForceDescriptionList myForceDescriptionList
 A list to hold data going to the scenarios extra manager during a scenario save.
DtCallbackList< DtU8 > myHostilityChangedCallbackList

Private Member Functions

 DtHostilityManager (const DtHostilityManager &orig)
 Not implemented.
DtHostilityManageroperator= (const DtHostilityManager &orig)
 Not implemented.
virtual void processRequestHostilityMatrix (DtSimMessage *msg)
 Handles request for hostility matrix.
static void requestHostilityMatrixCallback (DtSimMessage *msg, void *usr)
 Handles request for hostility matrix.
virtual void processSetHostilityMatrix (DtSimMessage *msg)
 Sets the updated hostility matrix.
static void setHostilityMatrixCallback (DtSimMessage *msg, void *usr)
 Sets the updated hostility matrix.
virtual void processRequestForceHostility (DtSimMessage *msg)
 Handles request for hostility for specific force.
static void requestForceHostilityCallback (DtSimMessage *msg, void *usr)
 Handles request for hostility for specific force.
virtual void processSetForceHostility (DtSimMessage *msg)
 Sets updated hostility for a specific force.
static void setForceHostilityCallback (DtSimMessage *msg, void *usr)
 Sets updated hostility for a specific force.

Detailed Description

This class keeps track of which forces are hostile to which other forces in the simulation.

It maintains state for each force type, and which other forces types are considered hostile by that force. It can be queried for this data any time during the simulation. Supports force enumerations from 0 to 255.


Member Typedef Documentation

typedef DtCallbackList<DtU8>::DtCallbackFunctionType DtHostilityManager::DtHostitliyChangedCallbackFcn [protected]
typedef std::vector<bool> DtHostilityManager::DtBoolVector [protected]

Typedefs to make list definitions easier.

typedef std::vector<DtBoolVector> DtHostilityManager::DtBoolVectorVector [protected]
typedef std::vector<DtString> DtHostilityManager::DtNameVector [protected]
typedef std::vector<DtVector> DtHostilityManager::DtVectorVector [protected]

Constructor & Destructor Documentation

Not implemented.


Member Function Documentation

DtHostilityManager& DtHostilityManager::operator= ( const DtHostilityManager orig) [private]

Not implemented.

virtual bool DtHostilityManager::init ( ) [virtual]

Initializes the hostility manager defaults.

Registers messages to listen for changes to hostility. Registers with cgf for a post-scenario load callback

virtual void DtHostilityManager::setDefaultHostility ( ) [virtual]

Sets the default starting hostility setup.

This sets DtForceFriendly as hostile toward DtForceOpposing and DtForceOppising as hostile toward DtForceFriendly. All other relationships are friendly.

virtual bool DtHostilityManager::addForce ( DtString  forceName,
DtVector  forceColor,
bool  includeInDialogs 
) [virtual]

Add a force to the force manager.

virtual bool DtHostilityManager::removeForce ( DtU8  force) [virtual]

Remove a force from the force manager.

virtual void DtHostilityManager::setHostility ( DtU8  force,
DtU8  targetForce,
bool  hostile 
) [virtual]

Invokes hostility changed callbacks if the set actually results in a change.

Note:
Hostility is not necessarily reciprocal. Setting forceA to be hostile toward forceB does not set forceB to be hostile toward forceA.
virtual bool DtHostilityManager::hostile ( DtU8  force,
DtU8  targetForce 
) const [virtual]

Whether force is hostile to targetForce.

virtual void DtHostilityManager::hostileForces ( DtU8  force,
std::list< DtU8 > &  forceList 
) const [virtual]

Adds all force types that are hostile to force to forceList.

Note:
This may include force itself.
virtual void DtHostilityManager::friendlyForces ( DtU8  force,
std::list< DtU8 > &  forceList 
) const [virtual]

Adds all force types that are friendly to force to forceList.

Note:
This may include force itself.
virtual void DtHostilityManager::addHostilityChangedCallback ( DtHostitliyChangedCallbackFcn  fcn,
void *  usr 
) [virtual]

Callbacks that are called any time the hostility matrix changes.

The parameter provided indicates for which force this change is for. i.e. If Force 1 changes to be hostile to force 2, the callback is made with 1 as the parameter.

Callbacks that are called any time the hostility matrix changes.

The parameter provided indicates for which force this change is for. i.e. If Force 1 changes to be hostile to force 2, the callback is made with 1 as the parameter.

virtual void DtHostilityManager::setName ( DtU8  force,
DtString  forceName 
) [virtual]

Name for a specific force.

virtual DtString DtHostilityManager::name ( DtU8  force) const [virtual]

Name for a specific force.

virtual void DtHostilityManager::setIncludeInDialogs ( DtU8  force,
bool  includeInDialogs 
) [virtual]

Whether or not a specific force is included in VRF dialogs.

virtual bool DtHostilityManager::includeInDialogs ( DtU8  force) [virtual]

Whether or not a specific force is included in VRF dialogs.

virtual void DtHostilityManager::setColor ( DtU8  force,
DtVector  forceColor 
) [virtual]

Color for a specific force.

virtual DtVector DtHostilityManager::color ( DtU8  force) [virtual]

Color for a specific force.

virtual void DtHostilityManager::setForceIsUsed ( DtU8  force,
bool  forceIsUsed 
) [virtual]

Whether force at index is used.

virtual bool DtHostilityManager::forceIsUsed ( DtU8  force) [virtual]

Whether force at index is used.

virtual int DtHostilityManager::numForces ( ) const [virtual]

Returns the number of forces currently in use (named)

virtual DtU8 DtHostilityManager::nextAvailableForceId ( ) [virtual]

Returns the next available index for a new force.

Saves the force hostility info into a force-hostility list.

Used when saving a scenario, prior to writing out the .xtr file; the info is used to update the data in the scenario extras manager.

virtual bool DtHostilityManager::readHostilityFile ( const DtString filename) [virtual]

Reads the Hostility matrix file to the specified name and adds all current hostility from the file.

This does not replace force names, colors or the state of includeInDialogs. Currently used only for old scenarios, when there is an .hst file but no .xtr file, or when there is neither and the .mtl file in the SMS is read.

Loads all of the force-hostility data from a force-hostility list.

Used to load the data from info read by the scenario extras manager in scenarios with .xtr files. Takes data from a force-hostility list and saves it in local members

virtual void DtHostilityManager::registerInterfaceMessageCallbacks ( ) [protected, virtual]

Message handlers.

Registers for any interface messages that the manager listens to.

static void DtHostilityManager::requestHostilityMatrixCallback ( DtSimMessage msg,
void *  usr 
) [static, protected]

Handles request for hostility matrix.

virtual void DtHostilityManager::processRequestHostilityMatrix ( DtSimMessage msg) [protected, virtual]

Handles request for hostility matrix.

static void DtHostilityManager::setHostilityMatrixCallback ( DtSimMessage msg,
void *  usr 
) [static, protected]

Sets the updated hostility matrix.

virtual void DtHostilityManager::processSetHostilityMatrix ( DtSimMessage msg) [protected, virtual]

Sets the updated hostility matrix.

static void DtHostilityManager::requestForceHostilityCallback ( DtSimMessage msg,
void *  usr 
) [static, protected]

Handles request for hostility for specific force.

virtual void DtHostilityManager::processRequestForceHostility ( DtSimMessage msg) [protected, virtual]

Handles request for hostility for specific force.

static void DtHostilityManager::setForceHostilityCallback ( DtSimMessage msg,
void *  usr 
) [static, protected]

Sets updated hostility for a specific force.

virtual void DtHostilityManager::processSetForceHostility ( DtSimMessage msg) [protected, virtual]

Sets updated hostility for a specific force.

virtual void DtHostilityManager::clearMatrix ( ) [protected, virtual]

Utility functions to use while reading data.

Clears the hostility matrix; done before setting hostility relations from data read from a scenario or SMS file.


Member Data Documentation

Local members.

Tracks which forces are hostile to which other forces.

Each force has a vector which contains a boolean for each other force. The bool is set to true for any force that the first force is hostile to.

A list to hold data going to the scenarios extra manager during a scenario save.

Modified and returned by buildDescriptionList()


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

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)