Collaboration diagram for Operating States:
|
Files | |
| file | states.c |
| Implements a system to use and switch between the different major game operating states. | |
| file | states.h |
| Defines the different major game operating states. | |
Modules | |
| Battlefield Error State | |
| Implements the Battlefield Error state. | |
| Gameplay State | |
| Runs the backbone of the gameplay code. | |
| Menu States | |
| Implements the Root Menu and Network Options Menu. | |
| Splash State | |
| Implements the Splash Screen. | |
Data Structures | |
| struct | State_t |
| A set of function pointers to functions that implement an operating state. More... | |
Typedefs | |
| typedef int(*) | StateFunc () |
| The function prototype for all implementations of the different operating states. | |
Enumerations | |
| enum | STATE_CODES { STATE_ERROR = -2, STATE_QUIT, STATE_SPLASH, STATE_MENUROOT, STATE_MENUNAME, STATE_MENUNET, STATE_MENUCONN, STATE_SHOWOPTS, STATE_PLAY, STATE_BFLDERR, STATE_DISCONN, STATE_MAX, STATE_OK } |
| Enumerates the different operating states of the game. More... | |
Functions | |
| int | GetCurrentState () |
| Returns the program's current operating state as defined in the STATE_CODES enum. | |
| Bool | RunState () |
| Runs the state system. | |
| static int | Stub () |
| A stub implementation for unimplemented states. | |
Variables | |
| static int | currState = STATE_SPLASH |
| Stores the current operating state. | |
| static Bool | initalized = 0 |
| Tracks if the current state has been initalized. | |
| static struct State_t | stateImpls [STATE_MAX] |
| The list of functions used for the operation state implementations. | |
Each state includes an initialization, uninitialization, and run function. This provides for an intuitive operation, however an implementation with only one function per state would allow a slimmer state machine. In that case, the init and uninit functions would be whole states that normally finish in a single call. I think I'll do it that way next time.
| typedef int(*) StateFunc() |
| enum STATE_CODES |
Enumerates the different operating states of the game.
Each has its own input-output loop.
| int GetCurrentState | ( | ) |
Returns the program's current operating state as defined in the STATE_CODES enum.
Definition at line 80 of file states.c.
References currState.
| Bool RunState | ( | ) |
Runs the state system.
The order of events are:
Definition at line 84 of file states.c.
References currState, FALSE, State_t::init, initalized, State_t::run, STATE_MAX, STATE_OK, STATE_QUIT, stateImpls, TRUE, and State_t::uninit.
Referenced by main().
| static int Stub | ( | ) | [static] |
int currState = STATE_SPLASH [static] |
Stores the current operating state.
For internal use only.
Definition at line 40 of file states.c.
Referenced by GetCurrentState(), RunState(), and Stub().
Bool initalized = 0 [static] |
Tracks if the current state has been initalized.
For internal use only.
Definition at line 47 of file states.c.
Referenced by RunState().
struct State_t stateImpls[STATE_MAX] [static] |
Initial value:
{
{ SplashInit, SplashRun, SplashUninit },
{ MenuRootInit, MenuRun, MenuRootUninit },
{ NULL, Stub, NULL },
{ NULL, Stub, NULL },
{ NULL, Stub, NULL },
{ NULL, Stub, NULL },
{ GameInit, GameRun, GameUninit },
{ BfldErrInit, BfldErrRun, BfldErrUninit },
{ NULL, Stub, NULL }
}
For internal use only.
Definition at line 68 of file states.c.
Referenced by RunState().
1.5.2