// CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
// The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
-void CSQC_Ent_Update(bool isnew)
-{ENGINE_EVENT();
+void CSQC_Ent_Update(entity this, bool isnew)
+{
this.sourceLoc = __FILE__ ":" STR(__LINE__);
int t = ReadByte();
// TODO possibly set more stuff to defaults
}
// CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
-void CSQC_Ent_Remove()
-{ENGINE_EVENT();
+void CSQC_Ent_Remove(entity this)
+{
if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
if (wasfreed(this))
{
int lasthud;
float vh_notice_time;
void WaypointSprite_Load();
-void CSQC_UpdateView(float w, float h)
-{ENGINE_EVENT();
+void CSQC_UpdateView(entity this, float w, float h)
+{
TC(int, w); TC(int, h);
entity e;
float fov;
FOREACH_CLIENT(IS_PLAYER(it), {
it.ons_roundlost = false;
it.ons_deathloc = '0 0 0';
- WITHSELF(it, PutClientInServer());
+ PutClientInServer(it);
});
return false;
}
}
#if defined(SVQC)
-void SV_PlayerPhysics()
+void SV_PlayerPhysics(entity this)
#elif defined(CSQC)
void CSQC_ClientMovement_PlayerMove_Frame(entity this)
#endif
{
-#ifdef SVQC
- ENGINE_EVENT();
-#endif
PM_Main(this);
}
#include "macro.qh"
#if NDEBUG
- #define TC(T, sym) MACRO_BEGIN MACRO_END
+ #define TC(T, sym) MACRO_BEGIN MACRO_END
#else
- #define TC(T, sym) MACRO_BEGIN \
- if (!is_##T(sym)) { \
- LOG_WARNINGF("Type check failed: " #sym " :: " #T); \
- isnt_##T(sym); \
- } \
- MACRO_END
+ #define TC(T, sym) MACRO_BEGIN \
+ if (!is_##T(sym)) { \
+ LOG_WARNINGF("Type check failed: " #sym " :: " #T); \
+ isnt_##T(sym); \
+ } \
+ MACRO_END
#endif
-#define is_float( this) (true || ftoe(this))
-#define isnt_float( this)
-#define is_vector( this) (true || vtos(this))
-#define isnt_vector( this)
-#define is_string( this) (true || stof(this))
-#define isnt_string( this)
-#define is_entity( this) (true || etof(this))
-#define isnt_entity( this)
-bool is_int( float this) { return this == floor(this); }
-void isnt_int( float this) { print(ftos(this)); }
-bool is_bool( float this) { return this == true || this == false; }
-void isnt_bool( float this) { print(ftos(this)); }
+#define is_float(this) (true || ftoe(this))
+#define isnt_float(this)
+#define is_vector(this) (true || vtos(this))
+#define isnt_vector(this)
+#define is_string(this) (true || stof(this))
+#define isnt_string(this)
+#define is_entity(this) (true || etof(this))
+#define isnt_entity(this)
+bool is_int(float this) { return this == floor(this); }
+void isnt_int(float this) { print(ftos(this)); }
+bool is_bool(float this) { return this == true || this == false; }
+void isnt_bool(float this) { print(ftos(this)); }
#include "warpzone/mathlib.qc"
#include "yenc.qh"
#include "matrix/_mod.inc"
+
+#ifdef MENUQC
+ void _m_init();
+ void m_init() { if (_m_init) _m_init(); }
+ #define m_init _m_init
+
+ void _m_shutdown();
+ void m_shutdown() { if (_m_shutdown) _m_shutdown(); }
+ #define m_shutdown _m_shutdown
+
+ void _m_draw(float width, float height);
+ void m_draw(float width, float height) { if (_m_draw) _m_draw(width, height); }
+ #define m_draw _m_draw
+
+ void _m_keydown(int keynr, int ascii);
+ void m_keydown(int keynr, int ascii) { if (_m_keydown) _m_keydown(keynr, ascii); }
+ #define m_keydown _m_keydown
+
+ void _m_toggle(int mode);
+ void m_toggle(int mode) { if (_m_toggle) _m_toggle(mode); }
+ #define m_toggle _m_toggle
+#endif
+
+#ifdef SVQC
+ void _main();
+ void main() { if (_main) _main(); }
+ #define main _main
+
+ void _SV_Shutdown();
+ void SV_Shutdown() { if (_SV_Shutdown) _SV_Shutdown(); }
+ #define SV_Shutdown _SV_Shutdown
+
+ void _StartFrame();
+ void StartFrame() { if (_StartFrame) _StartFrame(); }
+ #define StartFrame _StartFrame
+
+ void _SetNewParms();
+ void SetNewParms() { if (_SetNewParms) _SetNewParms(); }
+ #define SetNewParms _SetNewParms
+
+ void _SetChangeParms(entity this);
+ void SetChangeParms() { ENGINE_EVENT(); if (_SetChangeParms) _SetChangeParms(this); }
+ #define SetChangeParms _SetChangeParms
+
+ void _ClientConnect(entity this);
+ void ClientConnect() { ENGINE_EVENT(); if (_ClientConnect) _ClientConnect(this); }
+ #define ClientConnect _ClientConnect
+
+ void _ClientDisconnect(entity this);
+ void ClientDisconnect() { ENGINE_EVENT(); if (_ClientDisconnect) _ClientDisconnect(this); }
+ #define ClientDisconnect _ClientDisconnect
+
+ void _PutClientInServer(entity this);
+ void PutClientInServer() { ENGINE_EVENT(); if (_PutClientInServer) _PutClientInServer(this); }
+ #define PutClientInServer _PutClientInServer
+
+ void _ClientKill(entity this);
+ void ClientKill() { ENGINE_EVENT(); if (_ClientKill) _ClientKill(this); }
+ #define ClientKill _ClientKill
+
+ void _PlayerPreThink(entity this);
+ void PlayerPreThink() { ENGINE_EVENT(); if (_PlayerPreThink) _PlayerPreThink(this); }
+ #define PlayerPreThink _PlayerPreThink
+
+ void _PlayerPostThink(entity this);
+ void PlayerPostThink() { ENGINE_EVENT(); if (_PlayerPostThink) _PlayerPostThink(this); }
+ #define PlayerPostThink _PlayerPostThink
+
+ void _SV_PlayerPhysics(entity this);
+ void SV_PlayerPhysics() { ENGINE_EVENT(); if (_SV_PlayerPhysics) _SV_PlayerPhysics(this); }
+ #define SV_PlayerPhysics _SV_PlayerPhysics
+
+ void _SV_OnEntityPreSpawnFunction(entity this);
+ void SV_OnEntityPreSpawnFunction()
+ {
+ ENGINE_EVENT();
+ if (_SV_OnEntityPreSpawnFunction) _SV_OnEntityPreSpawnFunction(this);
+ }
+ #define SV_OnEntityPreSpawnFunction _SV_OnEntityPreSpawnFunction
+
+ void _SV_ChangeTeam(entity this, int _color);
+ void SV_ChangeTeam(int _color) { ENGINE_EVENT(); if (_SV_ChangeTeam) _SV_ChangeTeam(this, _color); }
+ #define SV_ChangeTeam _SV_ChangeTeam
+
+ void _SV_ParseClientCommand(entity this, string command);
+ void SV_ParseClientCommand(string command)
+ {
+ ENGINE_EVENT();
+ if (_SV_ParseClientCommand) _SV_ParseClientCommand(this, command);
+ }
+ #define SV_ParseClientCommand _SV_ParseClientCommand
+#endif
+
+#ifdef CSQC
+ void _CSQC_Init();
+ void CSQC_Init() { if (_CSQC_Init) _CSQC_Init(); }
+ #define CSQC_Init _CSQC_Init
+
+ void _CSQC_Shutdown();
+ void CSQC_Shutdown() { if (_CSQC_Shutdown) _CSQC_Shutdown(); }
+ #define CSQC_Shutdown _CSQC_Shutdown
+
+ void _CSQC_UpdateView(entity this, float w, float h);
+ void CSQC_UpdateView(float w, float h) { ENGINE_EVENT(); if (_CSQC_UpdateView) _CSQC_UpdateView(this, w, h); }
+ #define CSQC_UpdateView _CSQC_UpdateView
+
+ bool _CSQC_InputEvent(int inputType, float nPrimary, float nSecondary);
+ bool CSQC_InputEvent(int inputType, float nPrimary, float nSecondary)
+ {
+ return _CSQC_InputEvent ? _CSQC_InputEvent(inputType, nPrimary, nSecondary) : false;
+ }
+ #define CSQC_InputEvent _CSQC_InputEvent
+
+ bool _CSQC_ConsoleCommand(string s);
+ bool CSQC_ConsoleCommand(string s) { return _CSQC_ConsoleCommand ? _CSQC_ConsoleCommand(s) : false; }
+ #define CSQC_ConsoleCommand _CSQC_ConsoleCommand
+
+ void _CSQC_Ent_Update(entity this, bool isNew);
+ void CSQC_Ent_Update(bool isNew) { ENGINE_EVENT(); if (_CSQC_Ent_Update) _CSQC_Ent_Update(this, isNew); }
+ #define CSQC_Ent_Update _CSQC_Ent_Update
+
+ void _CSQC_Ent_Remove(entity this);
+ void CSQC_Ent_Remove() { ENGINE_EVENT(); if (_CSQC_Ent_Remove) _CSQC_Ent_Remove(this); }
+ #define CSQC_Ent_Remove _CSQC_Ent_Remove
+#endif
+#undef ENGINE_EVENT
{
currentbots = currentbots + 1;
bot_setnameandstuff(bot);
- WITHSELF(bot, ClientConnect());
- WITHSELF(bot, PutClientInServer());
+ ClientConnect(bot);
+ PutClientInServer(bot);
}
return bot;
}
// Commands code
.int bot_exec_status;
-void SV_ParseClientCommand(string s);
float bot_cmd_cc(entity this)
{
- WITHSELF(this, SV_ParseClientCommand(bot_cmd.bot_cmd_parm_string));
+ SV_ParseClientCommand(this, bot_cmd.bot_cmd_parm_string);
return CMD_STATUS_FINISHED;
}
STATIC_METHOD(Client, Add, void(Client this, int _team))
{
- WITHSELF(this, ClientConnect());
+ ClientConnect(this);
TRANSMUTE(Player, this);
this.frame = 12; // 7
this.team = _team;
- WITHSELF(this, PutClientInServer());
+ PutClientInServer(this);
}
void PutObserverInServer(entity this);
-void ClientDisconnect();
STATIC_METHOD(Client, Remove, void(Client this))
{
TRANSMUTE(Observer, this);
- WITHSELF(this, PutClientInServer());
- WITHSELF(this, ClientDisconnect());
+ PutClientInServer(this);
+ ClientDisconnect(this);
}
void send_CSQC_teamnagger() {
/** Called when a client spawns in the server */
-void PutClientInServer()
-{ENGINE_EVENT();
+void PutClientInServer(entity this)
+{
if (IS_BOT_CLIENT(this)) {
TRANSMUTE(Player, this);
} else if (IS_REAL_CLIENT(this)) {
SetChangeParms
=============
*/
-void SetChangeParms ()
-{ENGINE_EVENT();
+void SetChangeParms (entity this)
+{
// save parms for level change
parm1 = this.parm_idlesince - time;
PutObserverInServer(this);
}
else
- WITHSELF(this, SV_ChangeTeam(this.killindicator_teamchange - 1));
+ SV_ChangeTeam(this, this.killindicator_teamchange - 1);
this.killindicator_teamchange = 0;
}
}
-void ClientKill ()
-{ENGINE_EVENT();
+void ClientKill (entity this)
+{
if(gameover) return;
if(this.player_blocked) return;
if(STAT(FROZEN, this)) return;
Called when a client connects to the server
=============
*/
-void ClientConnect()
-{ENGINE_EVENT();
+void ClientConnect(entity this)
+{
if (Ban_MaybeEnforceBanOnce(this)) return;
assert(!IS_CLIENT(this), return);
this.flags |= FL_CLIENT;
*/
.entity chatbubbleentity;
void ReadyCount();
-void ClientDisconnect()
-{ENGINE_EVENT();
+void ClientDisconnect(entity this)
+{
assert(IS_CLIENT(this), return);
PlayerStats_GameReport_FinalizePlayer(this);
CopyBody(this, 1);
this.effects |= EF_NODRAW; // prevent another CopyBody
- WITHSELF(this, PutClientInServer());
+ PutClientInServer(this);
}
void play_countdown(entity this, float finished, Sound samp)
Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN);
- WITHSELF(this, PutClientInServer());
+ PutClientInServer(this);
if(IS_PLAYER(this)) { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), this.netname); }
}
TRANSMUTE(Spectator, this);
} else {
TRANSMUTE(Observer, this);
- WITHSELF(this, PutClientInServer());
+ PutClientInServer(this);
}
this.impulse = 0;
} else if(this.impulse == 12 || this.impulse == 16 || this.impulse == 19 || (this.impulse >= 220 && this.impulse <= 229)) {
TRANSMUTE(Spectator, this);
} else {
TRANSMUTE(Observer, this);
- WITHSELF(this, PutClientInServer());
+ PutClientInServer(this);
}
this.impulse = 0;
} else if (PHYS_INPUT_BUTTON_ATCK2(this)) {
this.flags &= ~FL_JUMPRELEASED;
TRANSMUTE(Observer, this);
- WITHSELF(this, PutClientInServer());
+ PutClientInServer(this);
} else {
if(!SpectateUpdate(this))
PutObserverInServer(this);
.float usekeypressed;
.float last_vehiclecheck;
.int items_added;
-void PlayerPreThink ()
-{ENGINE_EVENT();
+void PlayerPreThink (entity this)
+{
WarpZone_PlayerPhysics_FixVAngle(this);
STAT(GAMESTARTTIME, this) = game_starttime;
=============
*/
.float idlekick_lasttimeleft;
-void PlayerPostThink ()
-{ENGINE_EVENT();
+void PlayerPostThink (entity this)
+{
if (sv_maxidle > 0)
if (frametime) // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
if (IS_REAL_CLIENT(this))
PlayerScore_Clear(caller);
Kill_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CPID_PREVENT_JOIN);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && caller.team != -1) ? APP_TEAM_ENT(caller, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), caller.netname);
- WITHSELF(caller, PutClientInServer());
+ PutClientInServer(caller);
}
else
{
// ======================================
// If this function exists, server game code parses clientcommand before the engine code gets it.
-void SV_ParseClientCommand(string command)
-{ENGINE_EVENT();
+void SV_ParseClientCommand(entity this, string command)
+{
// If invalid UTF-8, don't even parse it
string command2 = "";
float len = strlen(command);
it.velocity = '0 0 0';
it.avelocity = '0 0 0';
it.movement = '0 0 0';
- WITHSELF(it, PutClientInServer());
+ PutClientInServer(it);
}
}
));
{
TRANSMUTE(Player, it);
it.caplayer = 1;
- WITHSELF(it, PutClientInServer());
+ PutClientInServer(it);
}
});
return true;
{
total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
- WITHSELF(it, PutClientInServer());
+ PutClientInServer(it);
if(domination_roundbased)
it.player_blocked = 1;
if(IS_REAL_CLIENT(it))
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
it.killcount = 0;
it.freezetag_frozen_timeout = -1;
- WITHSELF(it, PutClientInServer());
+ PutClientInServer(it);
it.freezetag_frozen_timeout = 0;
));
freezetag_count_alive_players();
PLAYERDEMO_FIELDS(this, playerdemo_read_)
{
time = this.playerdemo_time;
- WITHSELF(this, PlayerPreThink());
+ PlayerPreThink(this);
// not running physics though... this is just so we can run weapon stuff
- WITHSELF(this, PlayerPostThink());
+ PlayerPostThink(this);
}
this.playerdemo_time = stof(fgets(this.playerdemo_fh));
if(this.playerdemo_time == 0)
{
// TODO: if move is more than 50ms, split it into two moves (this matches QWSV behavior and the client prediction)
FOREACH_ENTITY_CLASS(STR_PLAYER, IS_FAKE_CLIENT(it), PM_Main(it));
- FOREACH_ENTITY_CLASS(STR_PLAYER, IS_FAKE_CLIENT(it), WITHSELF(it, PlayerPreThink()));
+ FOREACH_ENTITY_CLASS(STR_PLAYER, IS_FAKE_CLIENT(it), PlayerPreThink(it));
execute_next_frame();
if (autocvar_sv_autopause && !server_is_dedicated) Pause_TryPause(true);
MUTATOR_CALLHOOK(SV_StartFrame);
FOREACH_CLIENT(true, GlobalStats_update(it));
- FOREACH_ENTITY_CLASS(STR_PLAYER, IS_FAKE_CLIENT(it), WITHSELF(it, PlayerPostThink()));
+ FOREACH_ENTITY_CLASS(STR_PLAYER, IS_FAKE_CLIENT(it), PlayerPostThink(it));
}
.vector originjitter;
.string gametypefilter;
.string cvarfilter;
bool DoesQ3ARemoveThisEntity(entity this);
-void SV_OnEntityPreSpawnFunction()
-{ENGINE_EVENT();
+void SV_OnEntityPreSpawnFunction(entity this)
+{
__spawnfunc_expecting = true;
__spawnfunc_expect = this;
if (this)
}
//void() ctf_playerchanged;
-void SV_ChangeTeam(float _color)
-{ENGINE_EVENT();
+void SV_ChangeTeam(entity this, float _color)
+{
float scolor, dcolor, steam, dteam; //, dbotcount, scount, dcount;
// in normal deathmatch we can just apply the color and we're done
int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam);
//void() ctf_playerchanged;
-void SV_ChangeTeam(float _color);
void ShufflePlayerOutOfTeam (float source_team);