Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
GameLogic Class Reference

#include <GameLogic.h>

Inherits SubsystemInterface, and Snapshot.

Inherited by W3DGameLogic.

Public Member Functions

 GameLogic (void)
 
virtual ~GameLogic ()
 
virtual void init (void)
 Initialize or re-initialize the instance.
 
virtual void reset (void)
 Reset the logic system.
 
virtual void update (void)
 update the world
 
void processCommandList (CommandList *list)
 process the command list
 
void prepareNewGame (Int gameMode, GameDifficulty diff, Int rankPoints)
 prepare for new game
 
void logicMessageDispatcher (GameMessage *msg, void *userData)
 Logic command list processing.
 
void registerObject (Object *obj)
 Given an object, register it with the GameLogic and give it a unique ID.
 
void addObjectToLookupTable (Object *obj)
 add object ID to hash lookup table
 
void removeObjectFromLookupTable (Object *obj)
 remove object ID from hash lookup table
 
void setWidth (Real width)
 Sets the width of the world.
 
Real getWidth (void)
 Returns the width of the world.
 
void setHeight (Real height)
 Sets the height of the world.
 
Real getHeight (void)
 Returns the height of the world.
 
Bool isInGameLogicUpdate (void) const
 
UnsignedInt getFrame (void)
 Returns the current simulation frame number.
 
UnsignedInt getCRC (Int mode=CRC_CACHED, AsciiString deepCRCFileName=AsciiString::TheEmptyString)
 Returns the CRC.
 
void setObjectIDCounter (ObjectID nextObjID)
 
ObjectID getObjectIDCounter (void)
 
void setBuildableStatusOverride (const ThingTemplate *tt, BuildableStatus bs)
 
Bool findBuildableStatusOverride (const ThingTemplate *tt, BuildableStatus &bs) const
 
void setControlBarOverride (const AsciiString &commandSetName, Int slot, ConstCommandButtonPtr commandButton)
 
Bool findControlBarOverride (const AsciiString &commandSetName, Int slot, ConstCommandButtonPtr &commandButton) const
 
Objectfriend_createObject (const ThingTemplate *thing, const ObjectStatusMaskType &objectStatusMask, Team *team)
 create an object given the thing template. (Only for use by ThingFactory.)
 
void destroyObject (Object *obj)
 Mark object as destroyed for later deletion.
 
ObjectfindObjectByID (ObjectID id)
 Given an ObjectID, return a pointer to the object.
 
ObjectgetFirstObject (void)
 Returns the "first" object in the world. When used with the object method "getNextObject()", all objects in the world can be iterated.
 
ObjectID allocateObjectID (void)
 Returns a new unique object id.
 
void startNewGame (Bool loadSaveGame)
 
void loadMapINI (AsciiString mapName)
 
void updateLoadProgress (Int progress)
 
void deleteLoadScreen (void)
 
void setLoadingMap (Bool loading)
 
void setLoadingSave (Bool loading)
 
void setClearingGameData (Bool clearing)
 
void setGameMode (Int mode)
 
Int getGameMode (void)
 
Bool isInGame (void)
 
Bool isInLanGame (void)
 
Bool isInSinglePlayerGame (void)
 
Bool isInSkirmishGame (void)
 
Bool isInReplayGame (void)
 
Bool isInInternetGame (void)
 
Bool isInShellGame (void)
 
Bool isInMultiplayerGame (void)
 
Bool isLoadingMap () const
 
Bool isLoadingSave () const
 
Bool isClearingGameData () const
 
void enableScoring (Bool score)
 
Bool isScoringEnabled () const
 
void setShowBehindBuildingMarkers (Bool b)
 
Bool getShowBehindBuildingMarkers () const
 
void setDrawIconUI (Bool b)
 
Bool getDrawIconUI () const
 
void setShowDynamicLOD (Bool b)
 
Bool getShowDynamicLOD () const
 
void setHulkMaxLifetimeOverride (Int b)
 
Int getHulkMaxLifetimeOverride () const
 
Bool isIntroMoviePlaying ()
 
void updateObjectsChangedTriggerAreas (void)
 
UnsignedInt getFrameObjectsChangedTriggerAreas (void)
 
void clearGameData (Bool showScoreScreen=TRUE)
 Clear the game data.
 
void closeWindows (void)
 
void sendObjectCreated (Object *obj)
 
void sendObjectDestroyed (Object *obj)
 
void bindObjectAndDrawable (Object *obj, Drawable *draw)
 
void setGamePaused (Bool paused, Bool pauseMusic=TRUE)
 
Bool isGamePaused (void)
 
Bool getInputEnabledMemory (void)
 
void processProgress (Int playerId, Int percentage)
 
void processProgressComplete (Int playerId)
 
Bool isProgressComplete (void)
 @TODO: Add check to account for timeouts
 
void timeOutGameStart (void)
 
void initTimeOutValues (void)
 
UnsignedInt getObjectCount (void)
 
Int getRankLevelLimit () const
 
void setRankLevelLimit (Int limit)
 
Int getRankPointsToAddAtGameStart () const
 
UnsignedShort getSuperweaponRestriction (void) const
 Get any optional limits on superweapons.
 
void setSuperweaponRestriction (void)
 
void selectObject (Object *obj, Bool createNewSelection, PlayerMaskType playerMask, Bool affectClient=FALSE)
 
void deselectObject (Object *obj, PlayerMaskType playerMask, Bool affectClient=FALSE)
 
void friend_awakenUpdateModule (Object *obj, UpdateModulePtr update, UnsignedInt whenToWakeUp)
 
- Public Member Functions inherited from SubsystemInterface
 SubsystemInterface ()
 
virtual ~SubsystemInterface ()
 
virtual void postProcessLoad ()
 
virtual void draw (void)
 
void UPDATE (void)
 
void DRAW (void)
 
AsciiString getName (void)
 
void setName (AsciiString name)
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 

Protected Member Functions

virtual void crc (Xfer *xfer)
 
virtual void xfer (Xfer *xfer)
 
virtual void loadPostProcess (void)
 

Additional Inherited Members

- Protected Attributes inherited from SubsystemInterface
AsciiString m_name
 

Detailed Description

The implementation of GameLogic

Definition at line 104 of file GameLogic.h.

Constructor & Destructor Documentation

◆ GameLogic()

GameLogic::GameLogic ( void )

GameLogic class constructor

Definition at line 223 of file GameLogic.cpp.

◆ ~GameLogic()

GameLogic::~GameLogic ( )
virtual

GameLogic class destructor, the destruction order should mirror the initialization order

Definition at line 330 of file GameLogic.cpp.

Member Function Documentation

◆ addObjectToLookupTable()

void GameLogic::addObjectToLookupTable ( Object * obj)

add object ID to hash lookup table

Add object ID to the lookup table

Definition at line 3851 of file GameLogic.cpp.

◆ allocateObjectID()

ObjectID GameLogic::allocateObjectID ( void )

Returns a new unique object id.

Return a new unique object id.

Todo
Find unused value in current object set

Definition at line 3840 of file GameLogic.cpp.

◆ bindObjectAndDrawable()

void GameLogic::bindObjectAndDrawable ( Object * obj,
Drawable * draw )

Definition at line 4149 of file GameLogic.cpp.

◆ clearGameData()

void GameLogic::clearGameData ( Bool showScoreScreen = TRUE)

Clear the game data.

Definition at line 247 of file GameLogicDispatch.cpp.

◆ closeWindows()

void GameLogic::closeWindows ( void )

Definition at line 226 of file GameLogicDispatch.cpp.

◆ crc()

void GameLogic::crc ( Xfer * xfer)
protectedvirtual

Light CRC

Implements Snapshot.

Definition at line 4476 of file GameLogic.cpp.

◆ deleteLoadScreen()

void GameLogic::deleteLoadScreen ( void )

Delete the load screen

Definition at line 1088 of file GameLogic.cpp.

◆ deselectObject()

void GameLogic::deselectObject ( Object * obj,
PlayerMaskType playerMask,
Bool affectClient = FALSE )

Definition at line 2670 of file GameLogic.cpp.

◆ destroyObject()

void GameLogic::destroyObject ( Object * obj)

Mark object as destroyed for later deletion.

Mark the object as destroyed, and place on list for deletion at the end of the next update. This is the only interface to destroy objects - objects cannot be directly deleted.

Definition at line 3959 of file GameLogic.cpp.

◆ enableScoring()

void GameLogic::enableScoring ( Bool score)
inline

Definition at line 190 of file GameLogic.h.

◆ findBuildableStatusOverride()

Bool GameLogic::findBuildableStatusOverride ( const ThingTemplate * tt,
BuildableStatus & bs ) const

Definition at line 4398 of file GameLogic.cpp.

◆ findControlBarOverride()

Bool GameLogic::findControlBarOverride ( const AsciiString & commandSetName,
Int slot,
ConstCommandButtonPtr & commandButton ) const

Definition at line 4422 of file GameLogic.cpp.

◆ findObjectByID()

Object * GameLogic::findObjectByID ( ObjectID id)
inline

Given an ObjectID, return a pointer to the object.

Definition at line 410 of file GameLogic.h.

◆ friend_awakenUpdateModule()

void GameLogic::friend_awakenUpdateModule ( Object * obj,
UpdateModulePtr update,
UnsignedInt whenToWakeUp )

Definition at line 2983 of file GameLogic.cpp.

◆ friend_createObject()

Object * GameLogic::friend_createObject ( const ThingTemplate * thing,
const ObjectStatusMaskType & statusBits,
Team * team )

create an object given the thing template. (Only for use by ThingFactory.)

create an object based on the thing template, the reason that this is here and not in the ThingFactory is so that we can mirror what the creation process is on the client side because clients have specific device dependent drawables (such as a W3DDrawable derived from Drawable). here we will allocate an object of the correct type based on thing template properties

if we want to have the thing manager actually contain the pools of object and drawable storage it seems OK to have it be friends with the GameLogic/Client for those purposes, or we could put the allocation pools in the GameLogic and GameClient themselves

Definition at line 3946 of file GameLogic.cpp.

◆ getCRC()

UnsignedInt GameLogic::getCRC ( Int mode = CRC_CACHED,
AsciiString deepCRCFileName = AsciiString::TheEmptyString )

Returns the CRC.

Definition at line 4012 of file GameLogic.cpp.

◆ getDrawIconUI()

Bool GameLogic::getDrawIconUI ( ) const
inline

Definition at line 197 of file GameLogic.h.

◆ getFirstObject()

Object * GameLogic::getFirstObject ( void )

Returns the "first" object in the world. When used with the object method "getNextObject()", all objects in the world can be iterated.

Return the first object in the world list

Definition at line 3832 of file GameLogic.cpp.

◆ getFrame()

UnsignedInt GameLogic::getFrame ( void )
inline

Returns the current simulation frame number.

Definition at line 397 of file GameLogic.h.

◆ getFrameObjectsChangedTriggerAreas()

UnsignedInt GameLogic::getFrameObjectsChangedTriggerAreas ( void )
inline

Definition at line 208 of file GameLogic.h.

◆ getGameMode()

Int GameLogic::getGameMode ( void )
inline

Definition at line 401 of file GameLogic.h.

◆ getHeight()

Real GameLogic::getHeight ( void )
inline

Returns the height of the world.

Definition at line 396 of file GameLogic.h.

◆ getHulkMaxLifetimeOverride()

Int GameLogic::getHulkMaxLifetimeOverride ( ) const
inline

Definition at line 203 of file GameLogic.h.

◆ getInputEnabledMemory()

Bool GameLogic::getInputEnabledMemory ( void )
inline

Definition at line 220 of file GameLogic.h.

◆ getObjectCount()

UnsignedInt GameLogic::getObjectCount ( void )

returns the total number of objects in the world

Definition at line 4363 of file GameLogic.cpp.

◆ getObjectIDCounter()

ObjectID GameLogic::getObjectIDCounter ( void )
inline

Definition at line 143 of file GameLogic.h.

◆ getRankLevelLimit()

Int GameLogic::getRankLevelLimit ( ) const
inline

Definition at line 229 of file GameLogic.h.

◆ getRankPointsToAddAtGameStart()

Int GameLogic::getRankPointsToAddAtGameStart ( ) const
inline

Definition at line 237 of file GameLogic.h.

◆ getShowBehindBuildingMarkers()

Bool GameLogic::getShowBehindBuildingMarkers ( ) const
inline

Definition at line 194 of file GameLogic.h.

◆ getShowDynamicLOD()

Bool GameLogic::getShowDynamicLOD ( ) const
inline

Definition at line 200 of file GameLogic.h.

◆ getSuperweaponRestriction()

UnsignedShort GameLogic::getSuperweaponRestriction ( void ) const
inline

Get any optional limits on superweapons.

Definition at line 408 of file GameLogic.h.

◆ getWidth()

Real GameLogic::getWidth ( void )
inline

Returns the width of the world.

Definition at line 394 of file GameLogic.h.

◆ init()

void GameLogic::init ( void )
virtual

Initialize or re-initialize the instance.

(re)initialize the instance.

Todo
Clear object and destroy lists

Implements SubsystemInterface.

Definition at line 374 of file GameLogic.cpp.

◆ initTimeOutValues()

void GameLogic::initTimeOutValues ( void )

Definition at line 4350 of file GameLogic.cpp.

◆ isClearingGameData()

Bool GameLogic::isClearingGameData ( ) const
inline

Definition at line 188 of file GameLogic.h.

◆ isGamePaused()

Bool GameLogic::isGamePaused ( void )

Return if the game is paused or not

Definition at line 4181 of file GameLogic.cpp.

◆ isInGame()

Bool GameLogic::isInGame ( void )
inline

Definition at line 399 of file GameLogic.h.

◆ isInGameLogicUpdate()

Bool GameLogic::isInGameLogicUpdate ( void ) const
inline

Definition at line 138 of file GameLogic.h.

◆ isInInternetGame()

Bool GameLogic::isInInternetGame ( void )
inline

Definition at line 406 of file GameLogic.h.

◆ isInLanGame()

Bool GameLogic::isInLanGame ( void )
inline

Definition at line 402 of file GameLogic.h.

◆ isInMultiplayerGame()

Bool GameLogic::isInMultiplayerGame ( void )
inline

Definition at line 404 of file GameLogic.h.

◆ isInReplayGame()

Bool GameLogic::isInReplayGame ( void )
inline

Definition at line 405 of file GameLogic.h.

◆ isInShellGame()

Bool GameLogic::isInShellGame ( void )
inline

Definition at line 407 of file GameLogic.h.

◆ isInSinglePlayerGame()

Bool GameLogic::isInSinglePlayerGame ( void )

Definition at line 299 of file GameLogic.cpp.

◆ isInSkirmishGame()

Bool GameLogic::isInSkirmishGame ( void )
inline

Definition at line 403 of file GameLogic.h.

◆ isIntroMoviePlaying()

Bool GameLogic::isIntroMoviePlaying ( )
Todo
remove this hack

Definition at line 2611 of file GameLogic.cpp.

◆ isLoadingMap()

Bool GameLogic::isLoadingMap ( ) const
inline

Definition at line 186 of file GameLogic.h.

◆ isLoadingSave()

Bool GameLogic::isLoadingSave ( ) const
inline

Definition at line 187 of file GameLogic.h.

◆ isProgressComplete()

Bool GameLogic::isProgressComplete ( void )

@TODO: Add check to account for timeouts

Definition at line 4294 of file GameLogic.cpp.

◆ isScoringEnabled()

Bool GameLogic::isScoringEnabled ( ) const
inline

Definition at line 191 of file GameLogic.h.

◆ loadMapINI()

void GameLogic::loadMapINI ( AsciiString mapName)

Definition at line 2391 of file GameLogic.cpp.

◆ loadPostProcess()

void GameLogic::loadPostProcess ( void )
protectedvirtual

Load post process entry point

Implements Snapshot.

Definition at line 5020 of file GameLogic.cpp.

◆ logicMessageDispatcher()

void GameLogic::logicMessageDispatcher ( GameMessage * msg,
void * userData )

Logic command list processing.

This message handles dispatches object command messages to the appropriate objects.

Todo
Rename this to "CommandProcessor", or similiar.
Todo
: multiplayer semantics

Definition at line 352 of file GameLogicDispatch.cpp.

◆ prepareNewGame()

void GameLogic::prepareNewGame ( Int gameMode,
GameDifficulty diff,
Int rankPoints )

prepare for new game

Prepare for a new game

Definition at line 310 of file GameLogicDispatch.cpp.

◆ processCommandList()

void GameLogic::processCommandList ( CommandList * list)

process the command list

Process the command list passed to the logic from the network

Definition at line 2540 of file GameLogic.cpp.

◆ processProgress()

void GameLogic::processProgress ( Int playerId,
Int percentage )

Definition at line 4263 of file GameLogic.cpp.

◆ processProgressComplete()

void GameLogic::processProgressComplete ( Int playerId)

Whenever we get a progress complete packet for a Net Game, Set a flag that that player is ready

Definition at line 4274 of file GameLogic.cpp.

◆ registerObject()

void GameLogic::registerObject ( Object * obj)

Given an object, register it with the GameLogic and give it a unique ID.

Given an object, register it with the GameLogic and give it a unique ID.

Definition at line 3887 of file GameLogic.cpp.

◆ removeObjectFromLookupTable()

void GameLogic::removeObjectFromLookupTable ( Object * obj)

remove object ID from hash lookup table

Remove object from the ID lookup table

Definition at line 3871 of file GameLogic.cpp.

◆ reset()

void GameLogic::reset ( void )
virtual

Reset the logic system.

Reset the game logic systems

Implements SubsystemInterface.

Definition at line 434 of file GameLogic.cpp.

◆ selectObject()

void GameLogic::selectObject ( Object * obj,
Bool createNewSelection,
PlayerMaskType playerMask,
Bool affectClient = FALSE )

Definition at line 2619 of file GameLogic.cpp.

◆ sendObjectCreated()

void GameLogic::sendObjectCreated ( Object * obj)

A new GameLogic object has been constructed, therefore create a corresponding drawable and bind them together.

Todo
COLIN ... shouldn't we have a check here for existing drawable!!!!!

Definition at line 4137 of file GameLogic.cpp.

◆ sendObjectDestroyed()

void GameLogic::sendObjectDestroyed ( Object * obj)

Send notification of object destruction.

Definition at line 4158 of file GameLogic.cpp.

◆ setBuildableStatusOverride()

void GameLogic::setBuildableStatusOverride ( const ThingTemplate * tt,
BuildableStatus bs )

Definition at line 4389 of file GameLogic.cpp.

◆ setClearingGameData()

void GameLogic::setClearingGameData ( Bool clearing)
inline

Definition at line 171 of file GameLogic.h.

◆ setControlBarOverride()

void GameLogic::setControlBarOverride ( const AsciiString & commandSetName,
Int slot,
ConstCommandButtonPtr commandButton )

Definition at line 4413 of file GameLogic.cpp.

◆ setDrawIconUI()

void GameLogic::setDrawIconUI ( Bool b)
inline

Definition at line 196 of file GameLogic.h.

◆ setGameMode()

void GameLogic::setGameMode ( Int mode)
inline

Definition at line 400 of file GameLogic.h.

◆ setGamePaused()

void GameLogic::setGamePaused ( Bool paused,
Bool pauseMusic = TRUE )

Definition at line 4188 of file GameLogic.cpp.

◆ setHeight()

void GameLogic::setHeight ( Real height)
inline

Sets the height of the world.

Definition at line 395 of file GameLogic.h.

◆ setHulkMaxLifetimeOverride()

void GameLogic::setHulkMaxLifetimeOverride ( Int b)
inline

Definition at line 202 of file GameLogic.h.

◆ setLoadingMap()

void GameLogic::setLoadingMap ( Bool loading)
inline

Definition at line 169 of file GameLogic.h.

◆ setLoadingSave()

void GameLogic::setLoadingSave ( Bool loading)
inline

Definition at line 170 of file GameLogic.h.

◆ setObjectIDCounter()

void GameLogic::setObjectIDCounter ( ObjectID nextObjID)
inline

Definition at line 142 of file GameLogic.h.

◆ setRankLevelLimit()

void GameLogic::setRankLevelLimit ( Int limit)
inline

Definition at line 230 of file GameLogic.h.

◆ setShowBehindBuildingMarkers()

void GameLogic::setShowBehindBuildingMarkers ( Bool b)
inline

Definition at line 193 of file GameLogic.h.

◆ setShowDynamicLOD()

void GameLogic::setShowDynamicLOD ( Bool b)
inline

Definition at line 199 of file GameLogic.h.

◆ setSuperweaponRestriction()

void GameLogic::setSuperweaponRestriction ( void )

◆ setWidth()

void GameLogic::setWidth ( Real width)
inline

Sets the width of the world.

Todo
Change this to refer to a Region3D as an extent of the world

Definition at line 393 of file GameLogic.h.

◆ startNewGame()

void GameLogic::startNewGame ( Bool loadingSaveGame)

Entry point for starting a new game, the engine is already in clean state at this point and ready to load up with all the data

Todo
: Here is where we would look at the game mode & play an intro movie or something.

< mark it so only a few select things are rendered during load

< mark it so only a few select things are rendered during load

Todo
: MDC add back in after demo

ShowControlBar(FALSE);

< mark to resume rendering as normal

Definition at line 1105 of file GameLogic.cpp.

◆ timeOutGameStart()

void GameLogic::timeOutGameStart ( void )

Definition at line 4342 of file GameLogic.cpp.

◆ update()

void GameLogic::update ( void )
virtual

update the world

Update all objects in the world by invoking their update() methods.

Todo
remove this hack
Todo
  • make sure this never happens during a network game. jba.

Implements SubsystemInterface.

Definition at line 3572 of file GameLogic.cpp.

◆ updateLoadProgress()

void GameLogic::updateLoadProgress ( Int progress)

Update the load screen progress

Definition at line 1077 of file GameLogic.cpp.

◆ updateObjectsChangedTriggerAreas()

void GameLogic::updateObjectsChangedTriggerAreas ( void )
inline

Definition at line 207 of file GameLogic.h.

◆ xfer()

void GameLogic::xfer ( Xfer * xfer)
protectedvirtual

Load/Save game logic to xfer Version Info: 1: Initial version 2: Added m_isScoringEnabled flag (BGC) 3: Added polygon triggers (CBD) 4: Added block markers around object data, no version checking is done and therefore this version breaks compatibility with previous versions. (CBD) 5: Added xfering the BuildAssistant's sell list. 9: Added m_rankPointsToAddAtGameStart, or else on a load game, your RestartGame button will forget your exp 10: xfer m_superweaponRestriction

Implements Snapshot.

Definition at line 4690 of file GameLogic.cpp.


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