Documentation: started documenting all the functions in src/server/entry.qc
This commit is contained in:
parent
3a280f70f9
commit
d4ce7cb8c2
2 changed files with 63 additions and 142 deletions
|
@ -413,6 +413,8 @@ CSQC_Parse_Event(void)
|
||||||
/** Console commands not protected by the engine get handled here.
|
/** Console commands not protected by the engine get handled here.
|
||||||
If we return FALSE this means the engine needs to handle
|
If we return FALSE this means the engine needs to handle
|
||||||
the command itself which can result in a 'unrecognized command' message in console.
|
the command itself which can result in a 'unrecognized command' message in console.
|
||||||
|
|
||||||
|
The server-side equivalent is `ConsoleCmd` (src/server/entry.qc)
|
||||||
*/
|
*/
|
||||||
float
|
float
|
||||||
CSQC_ConsoleCommand(string sCMD)
|
CSQC_ConsoleCommand(string sCMD)
|
||||||
|
|
|
@ -14,13 +14,7 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/** Called once every single tic on the server. */
|
||||||
=================
|
|
||||||
StartFrame
|
|
||||||
|
|
||||||
Called once every single frame.
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
StartFrame(void)
|
StartFrame(void)
|
||||||
{
|
{
|
||||||
|
@ -39,16 +33,11 @@ StartFrame(void)
|
||||||
Vote_Frame();
|
Vote_Frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called when the client-slot is being prepared for a player.
|
||||||
=================
|
|
||||||
ClientConnect
|
|
||||||
|
|
||||||
Called when the client-slot is being prepared for a player.
|
|
||||||
The client may not fully spawn into the world (yet), as they're still
|
The client may not fully spawn into the world (yet), as they're still
|
||||||
loading or receiving packets.
|
loading or receiving packets.
|
||||||
|
|
||||||
The 'self' global is the connecting client in question.
|
The `self` global is the connecting client in question.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ClientConnect(void)
|
ClientConnect(void)
|
||||||
|
@ -81,14 +70,9 @@ ClientConnect(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called when a player leaves the server. At the end of the function the
|
||||||
=================
|
client slot referred to by the `self` global will be cleared.
|
||||||
ClientDisconnect
|
|
||||||
|
|
||||||
Called when a player leaves the server. At the end of the function the
|
|
||||||
client slot referred to by the 'self' global will be cleared.
|
|
||||||
This means the fields will still be accessible inside of this function.
|
This means the fields will still be accessible inside of this function.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ClientDisconnect(void)
|
ClientDisconnect(void)
|
||||||
|
@ -101,13 +85,8 @@ ClientDisconnect(void)
|
||||||
pl.SetModelindex(0);
|
pl.SetModelindex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called by the `kill` console command.
|
||||||
=================
|
The `self` global is the client issuing the command.
|
||||||
ClientKill
|
|
||||||
|
|
||||||
Called by the 'kill' command.
|
|
||||||
The 'self' global is the client issueing the command.
|
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ClientKill(void)
|
ClientKill(void)
|
||||||
|
@ -116,13 +95,8 @@ ClientKill(void)
|
||||||
g_grMode.PlayerKill((NSClientPlayer)self);
|
g_grMode.PlayerKill((NSClientPlayer)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** This is run every frame on every spectator.
|
||||||
=================
|
The `self` global refers to one of any given amount of spectator.
|
||||||
SpectatorThink
|
|
||||||
|
|
||||||
Run every frame on every NSClientSpectator.
|
|
||||||
The 'self' global refers to one of any given amount of NSClientSpectators.
|
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SpectatorThink(void)
|
SpectatorThink(void)
|
||||||
|
@ -137,13 +111,8 @@ SpectatorThink(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called when a NSClientSpectator joins the server.
|
||||||
=================
|
The `self` global is the connecting NSClientSpectator in question.
|
||||||
SpectatorConnect
|
|
||||||
|
|
||||||
Called when a NSClientSpectator joins the server.
|
|
||||||
The 'self' global is the connecting NSClientSpectator in question.
|
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SpectatorConnect(void)
|
SpectatorConnect(void)
|
||||||
|
@ -152,14 +121,9 @@ SpectatorConnect(void)
|
||||||
spawnfunc_NSClientSpectator();
|
spawnfunc_NSClientSpectator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called when a NSClientSpectator leaves the server.
|
||||||
=================
|
The `self` global is the leaving NSClientSpectator in question.
|
||||||
SpectatorDisconnect
|
|
||||||
|
|
||||||
Called when a NSClientSpectator leaves the server.
|
|
||||||
The 'self' global is the leaving NSClientSpectator in question.
|
|
||||||
Attributes cleared when this function is done executing.
|
Attributes cleared when this function is done executing.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SpectatorDisconnect(void)
|
SpectatorDisconnect(void)
|
||||||
|
@ -167,16 +131,11 @@ SpectatorDisconnect(void)
|
||||||
Game_SpectatorDisconnect();
|
Game_SpectatorDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called when a player enters the game, having fully connected and loaded into
|
||||||
=================
|
|
||||||
PutClientInServer
|
|
||||||
|
|
||||||
Called when a player enters the game, having fully connected and loaded into
|
|
||||||
the session.
|
the session.
|
||||||
The 'self' global is the player in question.
|
The `self` global is the player in question.
|
||||||
The 'parmX' globals are also populated with any data carried over from
|
The 'parmX' globals are also populated with any data carried over from
|
||||||
past levels for the player in question.
|
past levels for the player in question.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
PutClientInServer(void)
|
PutClientInServer(void)
|
||||||
|
@ -195,14 +154,9 @@ PutClientInServer(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Run before game physics have taken place.
|
||||||
=================
|
The `self` global refers to a single client, as this function is called
|
||||||
PlayerPreThink
|
|
||||||
|
|
||||||
Run before physics have taken place.
|
|
||||||
The 'self' global refers to a single client, as this function is called
|
|
||||||
times the amount of players in a given game.
|
times the amount of players in a given game.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
PlayerPreThink(void)
|
PlayerPreThink(void)
|
||||||
|
@ -227,14 +181,9 @@ PlayerPreThink(void)
|
||||||
g_grMode.PlayerPreFrame((NSClientPlayer)self);
|
g_grMode.PlayerPreFrame((NSClientPlayer)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Run after game physics have taken place.
|
||||||
=================
|
The `self` global refers to a single client, as this function is called
|
||||||
PlayerPostThink
|
|
||||||
|
|
||||||
Run after physics have taken place.
|
|
||||||
The 'self' global refers to a single client, as this function is called
|
|
||||||
times the amount of players in a given game.
|
times the amount of players in a given game.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
PlayerPostThink(void)
|
PlayerPostThink(void)
|
||||||
|
@ -261,14 +210,9 @@ PlayerPostThink(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called when we spawn in a new map (both single and multiplayer) with no level
|
||||||
=================
|
|
||||||
SetNewParms
|
|
||||||
|
|
||||||
Called when we spawn in a new map (both single and multiplayer) with no level
|
|
||||||
change ever having taken place.
|
change ever having taken place.
|
||||||
The 'self' global does not refer to anything.
|
The `self` global does not refer to anything.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SetNewParms(void)
|
SetNewParms(void)
|
||||||
|
@ -279,17 +223,12 @@ SetNewParms(void)
|
||||||
g_grMode.LevelNewParms();
|
g_grMode.LevelNewParms();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called whenever a single-player level change is about to happen, carrying
|
||||||
=================
|
|
||||||
SetChangeParms
|
|
||||||
|
|
||||||
Called whenever a single-player level change is about to happen, carrying
|
|
||||||
over data from one level to the next. This is not called with the 'map' command.
|
over data from one level to the next. This is not called with the 'map' command.
|
||||||
|
|
||||||
The 'self' global refers to a client that's partaking in the level-change.
|
The `self` global refers to a client that's partaking in the level-change.
|
||||||
Make sure we're saving important fields/attributes in the 'parmX' globals
|
Make sure we're saving important fields/attributes in the 'parmX' globals
|
||||||
allocated for every client.
|
allocated for every client.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SetChangeParms(void)
|
SetChangeParms(void)
|
||||||
|
@ -300,15 +239,10 @@ SetChangeParms(void)
|
||||||
g_grMode.LevelChangeParms((NSClientPlayer)self);
|
g_grMode.LevelChangeParms((NSClientPlayer)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Run whenever an input packet by a client has been received.
|
||||||
=================
|
|
||||||
SV_RunClientCommand
|
|
||||||
|
|
||||||
Run whenever an input packet by a client has been received.
|
The `self` global is the entity having sent the input packet,
|
||||||
|
|
||||||
The 'self' global is the entity having sent the input packet,
|
|
||||||
with the input_X globals being set to the appropriate data.
|
with the input_X globals being set to the appropriate data.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SV_RunClientCommand(void)
|
SV_RunClientCommand(void)
|
||||||
|
@ -334,16 +268,11 @@ SV_RunClientCommand(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Any 'cmd' from the client get sent here and handled.
|
||||||
=================
|
|
||||||
SV_ParseClientCommand
|
|
||||||
|
|
||||||
Any 'cmd' from the client get sent here and handled.
|
|
||||||
Unlike ConsoleCommmand() if you want to let the server engine
|
Unlike ConsoleCommmand() if you want to let the server engine
|
||||||
take over, you need to pass the string 'cmd' over via clientcommand().
|
take over, you need to pass the string 'cmd' over via clientcommand().
|
||||||
|
|
||||||
Notable examples of client cmd's involve the chat system.
|
Notable examples of client cmd's involve the chat system.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SV_ParseClientCommand(string cmd)
|
SV_ParseClientCommand(string cmd)
|
||||||
|
@ -378,13 +307,9 @@ SV_ParseClientCommand(string cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called when the QC module gets loaded.
|
||||||
=================
|
No entities exist yet and we are unable to allocate any in here.
|
||||||
init
|
So avoid calling spawn() related functions here. */
|
||||||
|
|
||||||
Called when the QC module gets loaded. No entities exist yet.
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
init(float prevprogs)
|
init(float prevprogs)
|
||||||
{
|
{
|
||||||
|
@ -394,13 +319,8 @@ init(float prevprogs)
|
||||||
SurfData_Init();
|
SurfData_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Called inside initents() to make sure the entities have their Respawn()
|
||||||
=================
|
|
||||||
init_respawn
|
|
||||||
|
|
||||||
Called inside initents() to make sure the entities have their Respawn()
|
|
||||||
method called at the beginning of them having spawned.
|
method called at the beginning of them having spawned.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
init_respawn(void)
|
init_respawn(void)
|
||||||
|
@ -420,15 +340,11 @@ init_respawn(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
entity g_respawntimer;
|
entity g_respawntimer;
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
initents
|
|
||||||
|
|
||||||
???
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
.string skyname;
|
.string skyname;
|
||||||
|
|
||||||
|
/** Called by the engine when we're ready to spawn entities.
|
||||||
|
Before this, we are not able to spawn, touch or allocate any entity slots.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
initents(void)
|
initents(void)
|
||||||
{
|
{
|
||||||
|
@ -518,19 +434,14 @@ initents(void)
|
||||||
g_ents_initialized = TRUE;
|
g_ents_initialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
worldspawn
|
|
||||||
|
|
||||||
The first entity spawn function. You want to make sure to put anything in here
|
|
||||||
that'll affect subsequent initialization of map entities.
|
|
||||||
|
|
||||||
Any find() or similar function will not find any entity but 'world',
|
|
||||||
as they do not exist yet. Keep this in mind.
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
var int autocvar_sv_levelexec = 1;
|
var int autocvar_sv_levelexec = 1;
|
||||||
|
|
||||||
|
/** The first entity spawn function. You want to make sure to put anything in here
|
||||||
|
that'll affect subsequent initialization of map entities.
|
||||||
|
|
||||||
|
Keep in mind that any find() or similar function will not find any entity but 'world',
|
||||||
|
as they do not exist yet.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
worldspawn(void)
|
worldspawn(void)
|
||||||
{
|
{
|
||||||
|
@ -567,16 +478,14 @@ worldspawn(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Any command executed on the server (either tty, rcon or `sv`) gets
|
||||||
=================
|
|
||||||
ConsoleCmd
|
|
||||||
|
|
||||||
Any command executed on the server (either tty, rcon or 'sv') gets
|
|
||||||
sent here first.
|
sent here first.
|
||||||
|
|
||||||
When returning FALSE the server will interpret the command.
|
When returning FALSE the server will interpret the command.
|
||||||
Returning TRUE will mark the command as 'resolved'.
|
Returning TRUE will mark the command as 'resolved' and the engine
|
||||||
=================
|
will not attempt handling it.
|
||||||
|
|
||||||
|
The client-side equivalent is `CSQC_ConsoleCommand` (src/client/entry.qc)
|
||||||
*/
|
*/
|
||||||
float
|
float
|
||||||
ConsoleCmd(string cmd)
|
ConsoleCmd(string cmd)
|
||||||
|
@ -662,13 +571,8 @@ ConsoleCmd(string cmd)
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Returns TRUE if the server can pause the server when the 'pause' command
|
||||||
=================
|
|
||||||
SV_ShouldPause
|
|
||||||
|
|
||||||
Returns TRUE if the server should pause the game-logic when the 'pause' command
|
|
||||||
is being executed.
|
is being executed.
|
||||||
=================
|
|
||||||
*/
|
*/
|
||||||
float
|
float
|
||||||
SV_ShouldPause(float newstatus)
|
SV_ShouldPause(float newstatus)
|
||||||
|
@ -686,6 +590,12 @@ SV_ShouldPause(float newstatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define REEDICT 1
|
//#define REEDICT 1
|
||||||
|
|
||||||
|
/** Called by the engine when we're loading a savegame file.
|
||||||
|
|
||||||
|
This deals with the de and re-allocation of all map entities from
|
||||||
|
the passed file handle.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
SV_PerformLoad(float fh, float entcount, float playerslots)
|
SV_PerformLoad(float fh, float entcount, float playerslots)
|
||||||
{
|
{
|
||||||
|
@ -778,6 +688,10 @@ SV_PerformLoad(float fh, float entcount, float playerslots)
|
||||||
g_isloading = false;
|
g_isloading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called when we are saving our game. We only get passed a file handle
|
||||||
|
to work with and dump entity data as well as some global info directly
|
||||||
|
into it.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
SV_PerformSave(float fh, float entcount, float playerslots)
|
SV_PerformSave(float fh, float entcount, float playerslots)
|
||||||
{
|
{
|
||||||
|
@ -811,6 +725,11 @@ SV_PerformSave(float fh, float entcount, float playerslots)
|
||||||
print(sprintf("saved %i entities\n", num_saved));
|
print(sprintf("saved %i entities\n", num_saved));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called by the engine to check with us if a spawn function exists.
|
||||||
|
|
||||||
|
The `self` global refers to an already allocated entity, which we have
|
||||||
|
to remove in case we won't initialize it.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
CheckSpawn(void() spawnfunc)
|
CheckSpawn(void() spawnfunc)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue