Browse Source

Add function descriptions

gravgun
mittorn 6 years ago
parent
commit
474ed21423
  1. 170
      dlls/coop.cpp
  2. 536
      dlls/gravgunmod.cpp
  3. 6
      dlls/gravgunmod.h

170
dlls/coop.cpp

@ -85,7 +85,13 @@ cvar_t materials_txt = { "materials_txt", "sound/materials.txt", FCVAR_SERVER };
cvar_t sentences_txt = { "sentences_txt", "sound/sentences.txt", FCVAR_SERVER }; cvar_t sentences_txt = { "sentences_txt", "sound/sentences.txt", FCVAR_SERVER };
void COOP_CheckpointMenu( CBasePlayer *pPlayer ); void COOP_CheckpointMenu( CBasePlayer *pPlayer );
/*
=========================
COOP_WriteState
Write COOP state to file
=========================
*/
void COOP_WriteState( const char *path ) void COOP_WriteState( const char *path )
{ {
FILE *f = fopen( path, "wb" ); FILE *f = fopen( path, "wb" );
@ -110,6 +116,13 @@ void COOP_WriteState( const char *path )
fclose( f ); fclose( f );
} }
/*
=========================
COOP_ReadState
Read COOP state from file
=========================
*/
bool COOP_ReadState( const char *path ) bool COOP_ReadState( const char *path )
{ {
FILE *f = fopen( path, "rb" ); FILE *f = fopen( path, "rb" );
@ -167,6 +180,13 @@ bool COOP_ReadState( const char *path )
return true; return true;
} }
/*
=========================
COOP_AutoSave
Helper for trigger_autosave
=========================
*/
void COOP_AutoSave( void ) void COOP_AutoSave( void )
{ {
strncpy( g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO2], g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO1], 31 ); strncpy( g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO2], g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO1], 31 );
@ -175,6 +195,13 @@ void COOP_AutoSave( void )
GGM_Save( g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO1] ); GGM_Save( g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO1] );
} }
/*
=========================
COOP_MapStartSave
Create save when reaching new map
=========================
*/
void COOP_MapStartSave( void ) void COOP_MapStartSave( void )
{ {
char szSavename[32] = ""; char szSavename[32] = "";
@ -190,7 +217,13 @@ void COOP_MapStartSave( void )
SERVER_COMMAND( UTIL_VarArgs( "wait;wait;ggm_save %s\n", g_CoopState.p.rgszSaveSlots[COOP_SAVE_START1] ) ); SERVER_COMMAND( UTIL_VarArgs( "wait;wait;ggm_save %s\n", g_CoopState.p.rgszSaveSlots[COOP_SAVE_START1] ) );
} }
/*
=========================
COOP_FindLandmark
return info_landmark pointer
=========================
*/
edict_t *COOP_FindLandmark( const char *pLandmarkName ) edict_t *COOP_FindLandmark( const char *pLandmarkName )
{ {
edict_t *pentLandmark; edict_t *pentLandmark;
@ -291,7 +324,13 @@ void UTIL_CoopPrintMessage( const char *format, ... )
UTIL_ClientPrintAll( HUD_PRINTTALK, string ); UTIL_ClientPrintAll( HUD_PRINTTALK, string );
} }
/*
=========================
COOP_CleanSpawnPoint
Move all players near specified origin to prevent stucking
=========================
*/
void UTIL_CleanSpawnPoint( Vector origin, float dist ) void UTIL_CleanSpawnPoint( Vector origin, float dist )
{ {
CBaseEntity *ent = NULL; CBaseEntity *ent = NULL;
@ -308,7 +347,13 @@ void UTIL_CleanSpawnPoint( Vector origin, float dist )
} }
} }
/*
=========================
COOP_FixupSpawnPoint
Trace and fix origin to prevent stuch (unused)
=========================
*/
Vector COOP_FixupSpawnPoint( Vector vecOrigin, bool fDuck ) Vector COOP_FixupSpawnPoint( Vector vecOrigin, bool fDuck )
{ {
int i = 0; int i = 0;
@ -327,6 +372,13 @@ Vector COOP_FixupSpawnPoint( Vector vecOrigin, bool fDuck )
return vecOrigin; return vecOrigin;
} }
/*
=========================
UTIL_BecomeSpectator
Set noclip and invisibility
=========================
*/
void UTIL_BecomeSpectator( CBasePlayer *pPlayer ) void UTIL_BecomeSpectator( CBasePlayer *pPlayer )
{ {
//pPlayer->m_bDoneFirstSpawn = true; //pPlayer->m_bDoneFirstSpawn = true;
@ -345,6 +397,13 @@ void UTIL_BecomeSpectator( CBasePlayer *pPlayer )
return; return;
} }
/*
=========================
UTIL_SpawnPlayer
Spawn player which is marked as spectator
=========================
*/
void UTIL_SpawnPlayer( CBasePlayer *pPlayer ) void UTIL_SpawnPlayer( CBasePlayer *pPlayer )
{ {
//pPlayer->StopObserver(); //pPlayer->StopObserver();
@ -363,11 +422,26 @@ void UTIL_SpawnPlayer( CBasePlayer *pPlayer )
} }
/*
=========================
COOP_GiveDefaultWeapons
Give each item in weapon list
=========================
*/
void COOP_GiveDefaultWeapons(CBasePlayer *pPlayer) void COOP_GiveDefaultWeapons(CBasePlayer *pPlayer)
{ {
for(int i = 0; i < g_CoopState.p.iWeaponCount;i++) for(int i = 0; i < g_CoopState.p.iWeaponCount;i++)
pPlayer->GiveNamedItem(g_CoopState.p.rgszWeapons[i]); pPlayer->GiveNamedItem(g_CoopState.p.rgszWeapons[i]);
} }
/*
=========================
COOP_AddDefaultWeapon
Write weapon name to weapon list
=========================
*/
void COOP_AddDefaultWeapon( const char *classname ) void COOP_AddDefaultWeapon( const char *classname )
{ {
int i; int i;
@ -393,6 +467,13 @@ void COOP_AddDefaultWeapon( const char *classname )
} }
/*
=========================
COOP_MarkTriggers
Setup trigger_changelevel color and direction
=========================
*/
void COOP_MarkTriggers( void ) void COOP_MarkTriggers( void )
{ {
CBaseEntity *pTrigger = NULL; CBaseEntity *pTrigger = NULL;
@ -416,6 +497,14 @@ void COOP_MarkTriggers( void )
} }
} }
/*
=========================
COOP_ProcessTransition
Process landmark transition
return false to start new game
=========================
*/
bool COOP_ProcessTransition( void ) bool COOP_ProcessTransition( void )
{ {
bool fAddCurrent = true; bool fAddCurrent = true;
@ -480,6 +569,14 @@ bool COOP_ProcessTransition( void )
return true; return true;
} }
/*
=========================
COOP_SetupLandmarkTransition
set cross-level state
=========================
*/
void COOP_SetupLandmarkTransition( const char *szNextMap, const char *szNextSpot, Vector vecLandmarkOffset, struct GGMPosition *pPos ) void COOP_SetupLandmarkTransition( const char *szNextMap, const char *szNextSpot, Vector vecLandmarkOffset, struct GGMPosition *pPos )
{ {
g_CoopState.landmarkTransition.fLoading = false; g_CoopState.landmarkTransition.fLoading = false;
@ -496,6 +593,13 @@ void COOP_SetupLandmarkTransition( const char *szNextMap, const char *szNextSpot
static float g_flDupCheck; static float g_flDupCheck;
/*
=========================
COOP_PlayerSpawn
handle load fix. return true to refuse state change
=========================
*/
bool COOP_PlayerSpawn( CBasePlayer *pPlayer ) bool COOP_PlayerSpawn( CBasePlayer *pPlayer )
{ {
if( !g_CoopState.landmarkTransition.fLoading ) if( !g_CoopState.landmarkTransition.fLoading )
@ -507,6 +611,13 @@ bool COOP_PlayerSpawn( CBasePlayer *pPlayer )
return false; return false;
} }
/*
=========================
COOP_ServerActivate
Handle landmark transition, load or game restart
=========================
*/
void COOP_ServerActivate( void ) void COOP_ServerActivate( void )
{ {
if( !mp_coop.value ) if( !mp_coop.value )
@ -591,6 +702,13 @@ void COOP_ServerActivate( void )
} }
/*
=========================
COOP_GetOrigin
Compute origin by landmarks
=========================
*/
bool COOP_GetOrigin( Vector *pvecNewOrigin, const Vector &vecOrigin, const char *pszMapName ) bool COOP_GetOrigin( Vector *pvecNewOrigin, const Vector &vecOrigin, const char *pszMapName )
{ {
if( !mp_coop.value ) if( !mp_coop.value )
@ -614,6 +732,13 @@ bool COOP_GetOrigin( Vector *pvecNewOrigin, const Vector &vecOrigin, const char
return false; return false;
} }
/*
=========================
COOP_NewCheckpoint
Check if player allowed to make checkpoint and create it
=========================
*/
void COOP_NewCheckpoint( entvars_t *pevPlayer ) void COOP_NewCheckpoint( entvars_t *pevPlayer )
{ {
if( !pevPlayer->netname || pevPlayer->health <= 0 ) if( !pevPlayer->netname || pevPlayer->health <= 0 )
@ -625,7 +750,13 @@ void COOP_NewCheckpoint( entvars_t *pevPlayer )
UTIL_CoopPrintMessage("New checkpoint by %s!\n", STRING( pevPlayer->netname ) ); UTIL_CoopPrintMessage("New checkpoint by %s!\n", STRING( pevPlayer->netname ) );
} }
/*
=========================
COOP_PlayerDeath
Show checkpoints menu for dead player
=========================
*/
bool COOP_PlayerDeath( CBasePlayer *pPlayer ) bool COOP_PlayerDeath( CBasePlayer *pPlayer )
{ {
static bool st_fSkipNext; static bool st_fSkipNext;
@ -649,6 +780,13 @@ bool COOP_PlayerDeath( CBasePlayer *pPlayer )
return false; return false;
} }
/*
=========================
COOP_SetDefaultSpawnPosition
Set position got from landmark transition
=========================
*/
bool COOP_SetDefaultSpawnPosition( CBasePlayer *pPlayer ) bool COOP_SetDefaultSpawnPosition( CBasePlayer *pPlayer )
{ {
if( !g_CoopState.p.fSaved ) if( !g_CoopState.p.fSaved )
@ -656,6 +794,13 @@ bool COOP_SetDefaultSpawnPosition( CBasePlayer *pPlayer )
return GGM_RestorePosition( pPlayer, &g_CoopState.p.savedPos ); return GGM_RestorePosition( pPlayer, &g_CoopState.p.savedPos );
} }
/*
=========================
UTIL_CoopGetPlayerTrain
Check if player on global platform and return pointer
=========================
*/
CBaseEntity *UTIL_CoopGetPlayerTrain( CBaseEntity *pPlayer) CBaseEntity *UTIL_CoopGetPlayerTrain( CBaseEntity *pPlayer)
{ {
CBaseEntity *train = NULL; CBaseEntity *train = NULL;
@ -686,7 +831,13 @@ CBaseEntity *UTIL_CoopGetPlayerTrain( CBaseEntity *pPlayer)
return train; return train;
} }
/*
=========================
COOP_ConfirmMenu
Check blue triggers and ask for changelevel confirmation
=========================
*/
bool COOP_ConfirmMenu( CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2, char *mapname ) bool COOP_ConfirmMenu( CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2, char *mapname )
{ {
if( mp_coop_strongcheckpoints.value ) if( mp_coop_strongcheckpoints.value )
@ -705,6 +856,13 @@ bool COOP_ConfirmMenu(CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2
return true; return true;
} }
/*
=========================
COOP_CheckPointMenu
Build and show checkpoint menu for player
=========================
*/
void COOP_CheckpointMenu( CBasePlayer *pPlayer ) void COOP_CheckpointMenu( CBasePlayer *pPlayer )
{ {
int i; int i;
@ -732,6 +890,11 @@ void COOP_CheckpointMenu( CBasePlayer *pPlayer )
m.Show(); m.Show();
} }
/*
=========================
COOP_ClientCommand
=========================
*/
bool COOP_ClientCommand( edict_t *pEntity ) bool COOP_ClientCommand( edict_t *pEntity )
{ {
const char *pcmd = CMD_ARGV(0); const char *pcmd = CMD_ARGV(0);
@ -887,6 +1050,13 @@ bool COOP_ClientCommand( edict_t *pEntity )
return false; return false;
} }
/*
=========================
COOP_RegisterCVars
Register console vars and commands for COOP
=========================
*/
void COOP_RegisterCVars() void COOP_RegisterCVars()
{ {
CVAR_REGISTER( &mp_coop ); CVAR_REGISTER( &mp_coop );

536
dlls/gravgunmod.cpp

File diff suppressed because it is too large Load Diff

6
dlls/gravgunmod.h

@ -119,7 +119,8 @@ struct GGMPosition
bool fDuck; bool fDuck;
}; };
// login records are persistent // login record
// this maps pair of nickname and uid to registration
struct GGMLogin struct GGMLogin
{ {
struct GGMLogin *pNext; struct GGMLogin *pNext;
@ -156,6 +157,7 @@ struct GGMTempState
bool fIsTempBanned; // prevent some actions bool fIsTempBanned; // prevent some actions
}; };
// state which every spawned player has
struct GGMPlayerState struct GGMPlayerState
{ {
struct GGMPlayerState *pNext; struct GGMPlayerState *pNext;
@ -167,7 +169,7 @@ struct GGMPlayerState
char szUID[33]; char szUID[33];
}; };
// player ggm data. additional struct for CBasePlayer
struct GGMData struct GGMData
{ {
float flSpawnTime; float flSpawnTime;

Loading…
Cancel
Save