Cavestory Mod API
GameDemo

Gameplay demoing. More...

enum  PXDEMO_EVENT_TYPE : unsigned char { PXDET_INVALID_EVENT = 0 , PXDET_SET_PLAYER_STATE = 1 , PXDET_SET_STAGE = 2 , PXDET_MAX_EVENTS }
 GameDemo Event Types. More...
 
CAVESTORY_MOD_API GAME_DEMO_STATEgRecordingDemo
 A pointer to the current recording demo. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Init (GAME_DEMO_STATE *pState)
 Initialize a GAME_DEMO_STATE object. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Free (GAME_DEMO_STATE *pState)
 Free a GAME_DEMO_STATE object. More...
 
CAVESTORY_MOD_API int CSM_GameDemo_Load (GAME_DEMO_STATE *pState, const char *pFileName)
 Load a game demo. More...
 
CAVESTORY_MOD_API int CSM_GameDemo_Save (GAME_DEMO_STATE *pState, const char *pFileName)
 Save a game demo. More...
 
CAVESTORY_MOD_API PXDEMO_PLAYER_STRUCTCSM_GameDemo_Players_Add (GAME_DEMO_STATE *pState, const char *pName, MYCHAR *pMC=NULL)
 Add a player to the demo state. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_Players_Remove (GAME_DEMO_STATE *pState, const char *pName)
 Remove a player from the demo state. More...
 
CAVESTORY_MOD_API PXDEMO_PLAYER_STRUCTCSM_GameDemo_Players_Find (GAME_DEMO_STATE *pState, const char *pName, int *pIndex=NULL)
 Find a player's object by name. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Events_Add (GAME_DEMO_STATE *pState, PXDEMO_EVENT_TYPE iType, int iFrameNo)
 Add an event to the demo. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_Events_Remove (GAME_DEMO_STATE *pState, PXDEMO_EVENT_TYPE iType, int iFrameNo, int iStartIndex=0)
 Remove an event from the demo. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Events_Find (GAME_DEMO_STATE *pState, PXDEMO_EVENT_TYPE iType, int iFrameNo, int iStartIndex=0, PXDEMO_FRAME_STRUCT **pFramePtr=NULL, int *pFrameIndex=NULL, int *pEventIndex=NULL)
 Find an event. More...
 
CAVESTORY_MOD_API PXDEMO_FRAME_STRUCTCSM_GameDemo_Frames_Add (GAME_DEMO_STATE *pState, int iFrameNo)
 Add af rame to the demo. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_Frames_Remove (GAME_DEMO_STATE *pState, int iFrameNo)
 Remove a frame from the demo. More...
 
CAVESTORY_MOD_API PXDEMO_FRAME_STRUCTCSM_GameDemo_Frames_Find (GAME_DEMO_STATE *pState, int iFrameNo, int *pIndex=NULL)
 Find a frame. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_LoadGameState (GAME_DEMO_STATE *pState)
 Load the game state of a demo. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Act (GAME_DEMO_STATE *pState)
 Act for a frame. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Put (GAME_DEMO_STATE *pState)
 Draw a demo's current game state. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_StartRecord ()
 Begin recording a demo.
 
CAVESTORY_MOD_API void CSM_GameDemo_StopRecord (GAME_DEMO_STATE *pState)
 Stop recording a demo. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_PlayerState (GAME_DEMO_STATE *pState, const char *pName, MYCHAR *pMC, int iKey, int iKeyTrg)
 Record a player's state. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_Stage (GAME_DEMO_STATE *pState)
 Record the current stage index. More...
 
CAVESTORY_MOD_API int CSM_GameDemo_Record_NewFrame (GAME_DEMO_STATE *pState)
 Increment the simulated frame count. More...
 

Detailed Description

Gameplay demoing.

Creating & loading gameplay demos

Enumeration Type Documentation

◆ PXDEMO_EVENT_TYPE

enum PXDEMO_EVENT_TYPE : unsigned char

GameDemo Event Types.

Enumerator
PXDET_INVALID_EVENT 

Invalid.

PXDET_SET_PLAYER_STATE 

Set the state of a player.

PXDET_SET_STAGE 

Transfer to a new stage.

PXDET_MAX_EVENTS 

How many events there can be.

Function Documentation

◆ CSM_GameDemo_Act()

CAVESTORY_MOD_API void CSM_GameDemo_Act ( GAME_DEMO_STATE pState)

Act for a frame.

Parameters
pStateThe demo to simulate the game with.

◆ CSM_GameDemo_Events_Add()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Events_Add ( GAME_DEMO_STATE pState,
PXDEMO_EVENT_TYPE  iType,
int  iFrameNo 
)

Add an event to the demo.

Parameters
pStateThe gamedemo state to manipulate.
iTypeThe type of event to allocate.
iFrameNoThe frame number to add the event to.
Returns
Returns a pointer to the newly allocated PXDEMO_EVENT_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Events_Find()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Events_Find ( GAME_DEMO_STATE pState,
PXDEMO_EVENT_TYPE  iType,
int  iFrameNo,
int  iStartIndex = 0,
PXDEMO_FRAME_STRUCT **  pFramePtr = NULL,
int *  pFrameIndex = NULL,
int *  pEventIndex = NULL 
)

Find an event.

Parameters
pStateThe gamedemo state to manipulate.
iTypeThe type of event to remove.
iFrameNoThe frame number the event should belong to.
iStartIndexThe starting index in the frame's event list.
pFramePtrA pointer to the variable that will hold the frame that holds the event. Can be NULL.
pFrameIndexA pointer to an int that will hold the index at which the frame was found at. Can be NULL.
pEventIndexA pointer to an int that will hold the index at which the event was found at. Can be NULL.
Returns
Returns a pointer to the specified event's PXDEMO_EVENT_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Events_Remove()

CAVESTORY_MOD_API bool CSM_GameDemo_Events_Remove ( GAME_DEMO_STATE pState,
PXDEMO_EVENT_TYPE  iType,
int  iFrameNo,
int  iStartIndex = 0 
)

Remove an event from the demo.

Parameters
pStateThe gamedemo state to manipulate.
iTypeThe type of event to remove.
iFrameNoThe frame number to remove the event from.
iStartIndexThe starting index in the frame's event list.
Returns
Returns true on success.

◆ CSM_GameDemo_Frames_Add()

CAVESTORY_MOD_API PXDEMO_FRAME_STRUCT* CSM_GameDemo_Frames_Add ( GAME_DEMO_STATE pState,
int  iFrameNo 
)

Add af rame to the demo.

Parameters
pStateThe gamedemo state to manipulate.
iFrameNoThe frame number.
Returns
Returns a pointer to the newly allocated PXDEMO_FRAME_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Frames_Find()

CAVESTORY_MOD_API PXDEMO_FRAME_STRUCT* CSM_GameDemo_Frames_Find ( GAME_DEMO_STATE pState,
int  iFrameNo,
int *  pIndex = NULL 
)

Find a frame.

Parameters
pStateThe gamedemo state to manipulate.
iFrameNoThe frame number to search for.
pIndexA pointer to an int that will hold the index at which the entry was found at. Can be NULL.
Returns
Returns a pointer to the specified frame's PXDEMO_FRAME_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Frames_Remove()

CAVESTORY_MOD_API bool CSM_GameDemo_Frames_Remove ( GAME_DEMO_STATE pState,
int  iFrameNo 
)

Remove a frame from the demo.

Parameters
pStateThe gamedemo state to manipulate.
iFrameNoThe frame number.
Returns
Returns true on success.

◆ CSM_GameDemo_Free()

CAVESTORY_MOD_API void CSM_GameDemo_Free ( GAME_DEMO_STATE pState)

Free a GAME_DEMO_STATE object.

This should be called after initializing the object.

Parameters
pStateThe state to free.

◆ CSM_GameDemo_Init()

CAVESTORY_MOD_API void CSM_GameDemo_Init ( GAME_DEMO_STATE pState)

Initialize a GAME_DEMO_STATE object.

Parameters
pStateThe state to initialize.

◆ CSM_GameDemo_Load()

CAVESTORY_MOD_API int CSM_GameDemo_Load ( GAME_DEMO_STATE pState,
const char *  pFileName 
)

Load a game demo.

Parameters
pStateThe state to load the demo into.
pFileNameThe name of the file to load into pState.
Returns
Returns 0 on success, otherwise returns a non-zero error code.

◆ CSM_GameDemo_LoadGameState()

CAVESTORY_MOD_API void CSM_GameDemo_LoadGameState ( GAME_DEMO_STATE pState)

Load the game state of a demo.

Parameters
pStateThe demo to simulate the game with.

◆ CSM_GameDemo_Players_Add()

CAVESTORY_MOD_API PXDEMO_PLAYER_STRUCT* CSM_GameDemo_Players_Add ( GAME_DEMO_STATE pState,
const char *  pName,
MYCHAR pMC = NULL 
)

Add a player to the demo state.

Parameters
pStateThe gamedemo state to manipulate.
pNameThe name of the client.
pMCA pointer to a MYCHAR structure to use for the player's state. Can be NULL.
Returns
Returns a pointer to newly allocated PXDEMO_PLAYER_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Players_Find()

CAVESTORY_MOD_API PXDEMO_PLAYER_STRUCT* CSM_GameDemo_Players_Find ( GAME_DEMO_STATE pState,
const char *  pName,
int *  pIndex = NULL 
)

Find a player's object by name.

Parameters
pStateThe gamedemo state to manipulate.
pNameThe name of the player to find.
pIndexA pointer to an int that will hold the index at which the entry was found at. Can be NULL.
Returns
Returns a pointer to the specified player's PXDEMO_PLAYER_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Players_Remove()

CAVESTORY_MOD_API bool CSM_GameDemo_Players_Remove ( GAME_DEMO_STATE pState,
const char *  pName 
)

Remove a player from the demo state.

Parameters
pStateThe gamedemo state to manipulate.
pNameThe name of the player to remove.
Returns
Returns true on success.

◆ CSM_GameDemo_Put()

CAVESTORY_MOD_API void CSM_GameDemo_Put ( GAME_DEMO_STATE pState)

Draw a demo's current game state.

Parameters
pStateThe demo to simulate the game with.

◆ CSM_GameDemo_Record_NewFrame()

CAVESTORY_MOD_API int CSM_GameDemo_Record_NewFrame ( GAME_DEMO_STATE pState)

Increment the simulated frame count.

Parameters
pStateThe gamedemo state.
Returns
Returns the current simulated frame number.

◆ CSM_GameDemo_Record_PlayerState()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_PlayerState ( GAME_DEMO_STATE pState,
const char *  pName,
MYCHAR pMC,
int  iKey,
int  iKeyTrg 
)

Record a player's state.

Parameters
pStateThe gamedemo state.
pNameThe name of the client.
pMCA pointer to the client's mychar.
iKeyThe player's current input flags.
iKeyTrgThe player's current input flags (trg).
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Record_Stage()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_Stage ( GAME_DEMO_STATE pState)

Record the current stage index.

Parameters
pStateThe gamedemo state.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Save()

CAVESTORY_MOD_API int CSM_GameDemo_Save ( GAME_DEMO_STATE pState,
const char *  pFileName 
)

Save a game demo.

Parameters
pStateThe state to save the demo into.
pFileNameThe output name of the file.
Returns
Returns 0 on success, otherwise returns a non-zero error code.

◆ CSM_GameDemo_StopRecord()

CAVESTORY_MOD_API void CSM_GameDemo_StopRecord ( GAME_DEMO_STATE pState)

Stop recording a demo.

Parameters
pStateA pointer to the state to hold the recorded gamestate.

Variable Documentation

◆ gRecordingDemo

CAVESTORY_MOD_API GAME_DEMO_STATE* gRecordingDemo
extern

A pointer to the current recording demo.

If NULL, then the game is not being recorded.