}
void CSQCPlayer_AnimDecide_PostUpdate(bool isnew)
{SELFPARAM();
- self.csqcmodel_isdead = !!(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
+ self.csqcmodel_isdead = boolean(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
}
int CSQCPlayer_FallbackFrame(int f)
{SELFPARAM();
self.teleport_time = 0;
}
- InterpolateOrigin_Do();
+ InterpolateOrigin_Do(this);
int s = W_GetGunAlignment(world);
self.HookSilent = (sf & 0x80);
self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
- InterpolateOrigin_Undo();
+ InterpolateOrigin_Undo(self);
if(sf & 1)
{
self.velocity_z = ReadCoord();
}
- InterpolateOrigin_Note();
+ InterpolateOrigin_Note(this);
if(bIsNew || !self.teleport_time)
{
if((hud_panel_radar_rotation == 0 && !hud_panel_radar_maximized) || (hud_panel_radar_maximized_rotation == 0 && hud_panel_radar_maximized))
{
// max-min distance must fit the radar in any rotation
- bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
+ bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen(vec2(mi_scale)));
}
else
{
float drawframetime;
vector view_origin, view_forward, view_right, view_up;
-float button_zoom;
-float spectatorbutton_zoom;
-float button_attack2;
+bool button_zoom;
+bool spectatorbutton_zoom;
+bool button_attack2;
int activeweapon;
int switchingweapon;
{
int sendflags = ReadByte();
- InterpolateOrigin_Undo();
+ InterpolateOrigin_Undo(self);
self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
self.classname = "radarlink";
return = true;
- InterpolateOrigin_Note();
+ InterpolateOrigin_Note(this);
}
#include "../common/debug.qh"
#include "../common/mapinfo.qh"
#include "../common/gamemodes/all.qh"
+#include "../common/physics.qh"
#include "../common/stats.qh"
#include "../common/triggers/target/music.qh"
#include "../common/teams.qh"
wcross_color = stov(autocvar_crosshair_dot_color);
CROSSHAIR_DRAW(wcross_resolution * autocvar_crosshair_dot_size, "gfx/crosshairdot.tga", f * autocvar_crosshair_dot_alpha);
- // FIXME why don't we use wcross_alpha here?cl_notice_run();
+ // FIXME why don't we use wcross_alpha here?
wcross_color = wcross_color_old;
}
}
float oldr_useportalculling;
float oldr_useinfinitefarclip;
-const int BUTTON_3 = 4;
-const int BUTTON_4 = 8;
-float cl_notice_run();
+void cl_notice_run();
float prev_myteam;
int lasthud;
float vh_notice_time;
else
view_quality = 1;
- button_attack2 = (input_buttons & BUTTON_3);
- button_zoom = (input_buttons & BUTTON_4);
+ button_attack2 = PHYS_INPUT_BUTTON_ATCK2(self);
+ button_zoom = PHYS_INPUT_BUTTON_ZOOM(self);
vf_size = getpropertyvec(VF_SIZE);
vf_min = getpropertyvec(VF_MIN);
}
}
- InterpolateOrigin_Do();
+ InterpolateOrigin_Do(self);
self.saved = self.(fld);
int f;
var .vector fld;
- InterpolateOrigin_Undo();
+ InterpolateOrigin_Undo(self);
self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
if(self.bgmscriptangular)
return = true;
- InterpolateOrigin_Note();
+ InterpolateOrigin_Note(this);
self.saved = self.(fld);
}
else
{
- InterpolateOrigin_Do();
+ InterpolateOrigin_Do(self);
}
if (self.count & 0x80)
}
if (!(self.count & 0x80))
- InterpolateOrigin_Undo();
+ InterpolateOrigin_Undo(self);
if (f & 1)
{
}
if (!(self.count & 0x80))
- InterpolateOrigin_Note();
+ InterpolateOrigin_Note(this);
self.classname = "csqcprojectile";
self.draw = Projectile_Draw;
CSQCModel_Hook_PostUpdate(isnew, isplayer, islocalplayer);
#define CSQCMODEL_HOOK_PREDRAW \
CSQCModel_Hook_PreDraw(isplayer);
-#define CSQCPLAYER_HOOK_POSTCAMERASETUP \
- CSQCPlayer_SetViewLocation();
+#define CSQCPLAYER_HOOK_POSTCAMERASETUP() \
+ CSQCPlayer_SetViewLocation()
// force updates of player entities that often even if unchanged
#ifndef CSQCPLAYER_FORCE_UPDATES
SELFPARAM();
this.nextthink = time;
entity e = CSQCModel_server2csqc(this.sv_entnum + 1);
- bool exists = !!e;
+ bool exists = e != NULL;
if (exists)
{
this.has_origin = true;
this.think = entcs_think;
this.nextthink = time;
}
- InterpolateOrigin_Undo();
+ InterpolateOrigin_Undo(this);
int sf = ReadShort();
this.has_sv_origin = false;
this.m_entcs_private = boolean(sf & 1);
#undef X
entcs_receiver[this.sv_entnum] = this;
this.iflags |= IFLAG_ORIGIN;
- InterpolateOrigin_Note();
+ InterpolateOrigin_Note(this);
return true;
}
// Whether the minigame menu panel is open
bool HUD_MinigameMenu_IsOpened()
{
- return !!HUD_MinigameMenu_entries;
+ return HUD_MinigameMenu_entries != NULL;
}
// Close the minigame menu panel
self.draw2d = Draw_WaypointSprite;
- InterpolateOrigin_Undo();
+ InterpolateOrigin_Undo(self);
self.iflags |= IFLAG_ORIGIN;
if (sendflags & 0x80)
self.helpme += servertime;
}
- InterpolateOrigin_Note();
+ InterpolateOrigin_Note(this);
self.entremove = Ent_RemoveWaypointSprite;
}
if (autocvar_cl_hidewaypoints)
return; // fixed waypoint
- InterpolateOrigin_Do();
+ InterpolateOrigin_Do(self);
float t = GetPlayerColor(player_localnum) + 1;
#ifdef SVQC
void sv_notice_join_think()
-{SELFPARAM();
- //NextLevel();
- float argc = tokenizebyseparator(autocvar_sv_join_notices, "|");
- if(argc > 0)
- {
- float i;
- for(i = argc - 1; i >= 0; --i)
- sv_notice_to(self.owner, argv(i), autocvar_sv_join_notices_time, false);
- }
- remove(self);
+{
+ SELFPARAM();
+ int argc = tokenizebyseparator(autocvar_sv_join_notices, "|");
+ if (argc <= 0) return;
+ for (int i = 0; i < argc; ++i)
+ sv_notice_to(this, argv(i), autocvar_sv_join_notices_time, false);
}
-void sv_notice_join()
-{SELFPARAM();
+void sv_notice_join(entity _to)
+{
// to-do: make sv_join_notices support per-entry times
- if(autocvar_sv_join_notices == "")
- return;
-
- entity n = spawn();
- n.owner = self;
- n.think = sv_notice_join_think;
- n.nextthink = time + 1;
+ if (autocvar_sv_join_notices == "") return;
+ defer(_to, 1, sv_notice_join_think);
}
void sv_notice_to(entity _to, string _notice, float _howlong, float _modal)
cl_notice_read();
return true;
}
+entity cl_notices;
+STATIC_INIT(cl_notice)
+{
+ cl_notices = LL_NEW();
+}
void cl_notice_read()
{
- //float _done;
- //float _modal;
entity _notice = new(sv_notice);
+ make_pure(_notice);
_notice.netname = strzone(ReadString());
_notice.alpha = ReadLong() + time;
_notice.skin = ReadByte();
+ LL_PUSH(cl_notices, _notice);
}
-float cl_notice_run()
+void cl_notice_run()
{
- entity _notes;
- string _notice;
- float m = false;
-
- _notes = findchain(classname, "sv_notice");
- if(!_notes)
- return false;
+ bool flag = false;
+ LL_EACH(cl_notices, it.alpha > time, LAMBDA(flag = true; break));
+ if (!flag) return;
const int M1 = 30;
const int M2 = 10;
- vector v1, v2 = '0 0 0', v3;
- v1 = '1 1 0' * M1;
- v2_x = vid_conwidth - (2 * M1);
- v2_y = vid_conheight - (2 * M1);
-
+ vector v1 = '1 1 0' * M1;
+ vector v2 = '0 0 0';
+ v2.x = vid_conwidth - (2 * M1);
+ v2.y = vid_conheight - (2 * M1);
drawfill(v1, v2, '0 0 0', 0.5, DRAWFLAG_NORMAL);
+
v1 = '1 1 0' * (M1 + M2);
- v2_x = vid_conwidth - (2 * (M1 + M2));
- v2_y = vid_conheight - (2 * (M1 + M2));
+ v2.x = vid_conwidth - (2 * (M1 + M2));
+ v2.y = vid_conheight - (2 * (M1 + M2));
drawfill(v1, v2, '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
- v3 = v1 + '10 10 0';
- #define OUT(s,z) drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3_y += z + 4
+ vector v3 = v1 + '10 10 0';
+ #define OUT(s, z) do { drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3.y += z + 4; } while (0)
OUT(_("^1Server notices:"), 32);
-
- //drawcolorcodedstring(v1 + '5 5 0', "^1Server notices:", '32 32 0', 1, DRAWFLAG_NORMAL);
- while(_notes)
- {
-
- _notice = sprintf(_("^7%s (^3%d sec left)"), _notes.netname , rint(_notes.alpha - time));
- OUT(_notice, 16);
-
- if(_notes.skin)
- m = true;
-
- if(_notes.alpha <= time)
- {
- _notes.think = SUB_Remove_self;
- _notes.nextthink = time;
- }
-
- _notes = _notes.chain;
- }
-
+ LL_EACH(cl_notices, it.alpha > time, LAMBDA(
+ string s = sprintf(_("^7%s (^3%d sec left)"), it.netname , rint(it.alpha - time));
+ OUT(s, 16);
+ ));
#undef OUT
-
- return m;
}
#endif // CSQC
void sv_notice_to(entity _to, string _notice, float _howlong, float _modal);
void sv_notice_toall(string _notice, float _howlong, float _modal);
-void sv_notice_join();
+void sv_notice_join(entity _to);
#endif
#ifdef CSQC
#undef X
}
-void PM_ClientMovement_UpdateStatus(bool ground)
-{SELFPARAM();
+void PM_ClientMovement_UpdateStatus(entity this, bool ground)
+{
// make sure player is not stuck
PM_ClientMovement_Unstick(this);
// set crouched
- if (PHYS_INPUT_BUTTON_CROUCH(self))
+ if (PHYS_INPUT_BUTTON_CROUCH(this))
{
- // wants to crouch, this always works..
- if (!IS_DUCKED(self))
- SET_DUCKED(self);
+ // wants to crouch, this always works
+ if (!IS_DUCKED(this)) SET_DUCKED(this);
}
else
{
- // wants to stand, if currently crouching we need to check for a
- // low ceiling first
- if (IS_DUCKED(self))
+ // wants to stand, if currently crouching we need to check for a low ceiling first
+ if (IS_DUCKED(this))
{
- tracebox(self.origin, PL_MIN, PL_MAX, self.origin, MOVE_NORMAL, self);
- if (!trace_startsolid)
- UNSET_DUCKED(self);
+ tracebox(this.origin, PL_MIN, PL_MAX, this.origin, MOVE_NORMAL, this);
+ if (!trace_startsolid) UNSET_DUCKED(this);
}
}
// set onground
- vector origin1 = self.origin + '0 0 1';
- vector origin2 = self.origin - '0 0 1';
+ vector origin1 = this.origin + '0 0 1';
+ vector origin2 = this.origin - '0 0 1';
- if(ground)
+ if (ground)
{
- tracebox(origin1, self.mins, self.maxs, origin2, MOVE_NORMAL, self);
- if (trace_fraction < 1.0 && trace_plane_normal_z > 0.7)
+ tracebox(origin1, this.mins, this.maxs, origin2, MOVE_NORMAL, this);
+ if (trace_fraction < 1.0 && trace_plane_normal.z > 0.7)
{
- SET_ONGROUND(self);
+ SET_ONGROUND(this);
// this code actually "predicts" an impact; so let's clip velocity first
- float f = self.velocity * trace_plane_normal;
- self.velocity -= f * trace_plane_normal;
+ this.velocity -= this.velocity * trace_plane_normal * trace_plane_normal;
}
else
- UNSET_ONGROUND(self);
+ UNSET_ONGROUND(this);
}
// set watertype/waterlevel
- origin1 = self.origin;
- origin1_z += self.mins_z + 1;
- self.waterlevel = WATERLEVEL_NONE;
+ origin1 = this.origin;
+ origin1.z += this.mins_z + 1;
+ this.waterlevel = WATERLEVEL_NONE;
int thepoint = pointcontents(origin1);
- self.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
+ this.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
- if(self.watertype)
+ if (this.watertype)
{
- self.waterlevel = WATERLEVEL_WETFEET;
- origin1_z = self.origin_z + (self.mins_z + self.maxs_z) * 0.5;
+ this.waterlevel = WATERLEVEL_WETFEET;
+ origin1.z = this.origin.z + (this.mins.z + this.maxs.z) * 0.5;
thepoint = pointcontents(origin1);
- if(thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
+ if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
{
- self.waterlevel = WATERLEVEL_SWIMMING;
- origin1_z = self.origin_z + 22;
+ this.waterlevel = WATERLEVEL_SWIMMING;
+ origin1.z = this.origin.z + 22;
thepoint = pointcontents(origin1);
- if(thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
- self.waterlevel = WATERLEVEL_SUBMERGED;
+ if (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
+ this.waterlevel = WATERLEVEL_SUBMERGED;
}
}
- if(IS_ONGROUND(self) || self.velocity_z <= 0 || pmove_waterjumptime <= 0)
+ if (IS_ONGROUND(this) || this.velocity.z <= 0 || pmove_waterjumptime <= 0)
pmove_waterjumptime = 0;
}
vector trace3_plane_normal = '0 0 0';
- PM_ClientMovement_UpdateStatus(false);
+ PM_ClientMovement_UpdateStatus(this, false);
primalvelocity = self.velocity;
for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (self.velocity * self.velocity) > 0; bump++)
{
#endif
}
-void PM_walk(float buttons_prev, float maxspd_mod)
-{SELFPARAM();
- if (!WAS_ONGROUND(self))
+void PM_walk(entity this, float maxspd_mod)
+{
+ if (!WAS_ONGROUND(this))
{
#ifdef SVQC
if (autocvar_speedmeter)
- LOG_TRACE(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
+ LOG_TRACE(strcat("landing velocity: ", vtos(this.velocity), " (abs: ", ftos(vlen(this.velocity)), ")\n"));
#endif
- if (self.lastground < time - 0.3)
- self.velocity *= (1 - PHYS_FRICTION_ONLAND);
+ if (this.lastground < time - 0.3)
+ this.velocity *= (1 - PHYS_FRICTION_ONLAND);
#ifdef SVQC
- if (self.jumppadcount > 1)
- LOG_TRACE(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
- self.jumppadcount = 0;
+ if (this.jumppadcount > 1)
+ LOG_TRACE(strcat(ftos(this.jumppadcount), "x jumppad combo\n"));
+ this.jumppadcount = 0;
#endif
}
// walking
- makevectors(self.v_angle.y * '0 1 0');
- vector wishvel = v_forward * self.movement.x
- + v_right * self.movement.y;
+ makevectors(this.v_angle.y * '0 1 0');
+ const vector wishvel = v_forward * this.movement.x
+ + v_right * this.movement.y;
// acceleration
- vector wishdir = normalize(wishvel);
+ const vector wishdir = normalize(wishvel);
float wishspeed = vlen(wishvel);
-
- wishspeed = min(wishspeed, PHYS_MAXSPEED(self) * maxspd_mod);
- if (IS_DUCKED(self))
- wishspeed *= 0.5;
+ wishspeed = min(wishspeed, PHYS_MAXSPEED(this) * maxspd_mod);
+ if (IS_DUCKED(this)) wishspeed *= 0.5;
// apply edge friction
- float f = vlen(vec2(self.velocity));
- if (f > 0)
+ const float f2 = vlen2(vec2(this.velocity));
+ if (f2 > 0)
{
- float realfriction;
trace_dphitq3surfaceflags = 0;
- tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
+ tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
// TODO: apply edge friction
// apply ground friction
- if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
- realfriction = PHYS_FRICTION_SLICK;
- else
- realfriction = PHYS_FRICTION;
+ const int realfriction = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
+ ? PHYS_FRICTION_SLICK
+ : PHYS_FRICTION;
+ float f = sqrt(f2);
f = 1 - PHYS_INPUT_TIMELENGTH * realfriction * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
f = max(0, f);
- self.velocity *= f;
+ this.velocity *= f;
/*
Mathematical analysis time!
v >= PHYS_STOPSPEED * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION)
*/
}
- float addspeed = wishspeed - self.velocity * wishdir;
+ const float addspeed = wishspeed - this.velocity * wishdir;
if (addspeed > 0)
{
- float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
- self.velocity += accelspeed * wishdir;
+ const float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
+ this.velocity += accelspeed * wishdir;
}
- float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
+ const float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(this) * PHYS_INPUT_TIMELENGTH;
if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
- self.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
- if (self.velocity * self.velocity)
+ this.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
+ if (vdist(this.velocity, >, 0))
PM_ClientMovement_Move();
if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
- if (!IS_ONGROUND(self) || !GAMEPLAYFIX_NOGRAVITYONGROUND)
- self.velocity_z -= g * 0.5;
+ if (!IS_ONGROUND(this) || !GAMEPLAYFIX_NOGRAVITYONGROUND)
+ this.velocity_z -= g * 0.5;
}
void PM_air(float buttons_prev, float maxspd_mod)
return true;
}
-void PM_Main()
-{SELFPARAM();
- int buttons = PHYS_INPUT_BUTTON_MASK(self);
+void PM_Main(entity this)
+{
+ int buttons = PHYS_INPUT_BUTTON_MASK(this);
#ifdef CSQC
- self.items = getstati(STAT_ITEMS, 0, 24);
+ this.items = getstati(STAT_ITEMS, 0, 24);
- self.movement = PHYS_INPUT_MOVEVALUES(self);
+ this.movement = PHYS_INPUT_MOVEVALUES(this);
- vector oldv_angle = self.v_angle;
- vector oldangles = self.angles; // we need to save these, as they're abused by other code
- self.v_angle = PHYS_INPUT_ANGLES(self);
- self.angles = PHYS_WORLD_ANGLES(self);
+ vector oldv_angle = this.v_angle;
+ vector oldangles = this.angles; // we need to save these, as they're abused by other code
+ this.v_angle = PHYS_INPUT_ANGLES(this);
+ this.angles = PHYS_WORLD_ANGLES(this);
- self.team = myteam + 1; // is this correct?
- if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump
- UNSET_JUMP_HELD(self); // canjump = true
+ this.team = myteam + 1; // is this correct?
+ if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump
+ UNSET_JUMP_HELD(this); // canjump = true
pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
- PM_ClientMovement_UpdateStatus(true);
+ PM_ClientMovement_UpdateStatus(this, true);
#endif
#ifdef SVQC
Physics_UpdateStats(maxspeed_mod);
- if (self.PlayerPhysplug)
- if (self.PlayerPhysplug())
+ if (this.PlayerPhysplug)
+ if (this.PlayerPhysplug())
return;
#endif
#ifdef SVQC
if (sv_maxidle > 0)
{
- if (buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old)
- self.parm_idlesince = time;
+ if (buttons != this.buttons_old || this.movement != this.movement_old || this.v_angle != this.v_angle_old)
+ this.parm_idlesince = time;
}
#endif
- int buttons_prev = self.buttons_old;
- self.buttons_old = buttons;
- self.movement_old = self.movement;
- self.v_angle_old = self.v_angle;
+ int buttons_prev = this.buttons_old;
+ this.buttons_old = buttons;
+ this.movement_old = this.movement;
+ this.v_angle_old = this.v_angle;
PM_check_nickspam();
PM_check_punch();
#ifdef SVQC
- if (IS_BOT_CLIENT(self))
+ if (IS_BOT_CLIENT(this))
{
if (playerdemo_read())
return;
bot_think();
}
-
- if (IS_PLAYER(self))
-#endif
- {
- bool not_allowed_to_move = false;
-#ifdef SVQC
- if (time < game_starttime)
- not_allowed_to_move = true;
#endif
- if (not_allowed_to_move)
- {
- self.velocity = '0 0 0';
- self.movetype = MOVETYPE_NONE;
#ifdef SVQC
- self.disableclientprediction = 2;
-#endif
+ if (IS_PLAYER(this))
+ {
+ const bool allowed_to_move = (time >= game_starttime);
+ if (!allowed_to_move)
+ {
+ this.velocity = '0 0 0';
+ this.movetype = MOVETYPE_NONE;
+ this.disableclientprediction = 2;
}
-#ifdef SVQC
- else if (self.disableclientprediction == 2)
+ else if (this.disableclientprediction == 2)
{
- if (self.movetype == MOVETYPE_NONE)
- self.movetype = MOVETYPE_WALK;
- self.disableclientprediction = 0;
+ if (this.movetype == MOVETYPE_NONE)
+ this.movetype = MOVETYPE_WALK;
+ this.disableclientprediction = 0;
}
-#endif
}
+#endif
#ifdef SVQC
- if (self.movetype == MOVETYPE_NONE)
+ if (this.movetype == MOVETYPE_NONE)
return;
// when we get here, disableclientprediction cannot be 2
- self.disableclientprediction = 0;
+ this.disableclientprediction = 0;
#endif
viewloc_PlayerPhysics();
maxspeed_mod = 1;
- if (self.in_swamp)
- maxspeed_mod *= self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
+ if (this.in_swamp)
+ maxspeed_mod *= this.swamp_slowdown; //cvar("g_balance_swamp_moverate");
// conveyors: first fix velocity
- if (self.conveyor.state)
- self.velocity -= self.conveyor.movedir;
+ if (this.conveyor.state)
+ this.velocity -= this.conveyor.movedir;
#ifdef SVQC
MUTATOR_CALLHOOK(PlayerPhysics);
// }
#ifdef SVQC
- if (!IS_PLAYER(self))
+ if (!IS_PLAYER(this))
{
maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
- if (!self.spectatorspeed)
- self.spectatorspeed = maxspeed_mod;
- if (self.impulse && self.impulse <= 19 || (self.impulse >= 200 && self.impulse <= 209) || (self.impulse >= 220 && self.impulse <= 229))
+ if (!this.spectatorspeed)
+ this.spectatorspeed = maxspeed_mod;
+ if (this.impulse && this.impulse <= 19 || (this.impulse >= 200 && this.impulse <= 209) || (this.impulse >= 220 && this.impulse <= 229))
{
- if (self.lastclassname != "player")
+ if (this.lastclassname != "player")
{
- if (self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209))
- self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
- else if (self.impulse == 11)
- self.spectatorspeed = maxspeed_mod;
- else if (self.impulse == 12 || self.impulse == 16 || self.impulse == 19 || (self.impulse >= 220 && self.impulse <= 229))
- self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
- else if (self.impulse >= 1 && self.impulse <= 9)
- self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
+ if (this.impulse == 10 || this.impulse == 15 || this.impulse == 18 || (this.impulse >= 200 && this.impulse <= 209))
+ this.spectatorspeed = bound(1, this.spectatorspeed + 0.5, 5);
+ else if (this.impulse == 11)
+ this.spectatorspeed = maxspeed_mod;
+ else if (this.impulse == 12 || this.impulse == 16 || this.impulse == 19 || (this.impulse >= 220 && this.impulse <= 229))
+ this.spectatorspeed = bound(1, this.spectatorspeed - 0.5, 5);
+ else if (this.impulse >= 1 && this.impulse <= 9)
+ this.spectatorspeed = 1 + 0.5 * (this.impulse - 1);
} // otherwise just clear
- self.impulse = 0;
+ this.impulse = 0;
}
- maxspeed_mod = self.spectatorspeed;
+ maxspeed_mod = this.spectatorspeed;
}
- float spd = max(PHYS_MAXSPEED(self), PHYS_MAXAIRSPEED(self)) * maxspeed_mod;
- if(self.speed != spd)
+ float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
+ if(this.speed != spd)
{
- self.speed = spd;
+ this.speed = spd;
string temps = ftos(spd);
- stuffcmd(self, strcat("cl_forwardspeed ", temps, "\n"));
- stuffcmd(self, strcat("cl_backspeed ", temps, "\n"));
- stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
- stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
+ stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
+ stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
+ stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
+ stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
}
- if(self.stat_jumpspeedcap_min != PHYS_JUMPSPEEDCAP_MIN)
+ if(this.stat_jumpspeedcap_min != PHYS_JUMPSPEEDCAP_MIN)
{
- self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
- stuffcmd(self, strcat("cl_jumpspeedcap_min ", PHYS_JUMPSPEEDCAP_MIN, "\n"));
+ this.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
+ stuffcmd(this, strcat("cl_jumpspeedcap_min ", PHYS_JUMPSPEEDCAP_MIN, "\n"));
}
- if(self.stat_jumpspeedcap_max != PHYS_JUMPSPEEDCAP_MAX)
+ if(this.stat_jumpspeedcap_max != PHYS_JUMPSPEEDCAP_MAX)
{
- self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MAX;
- stuffcmd(self, strcat("cl_jumpspeedcap_max ", PHYS_JUMPSPEEDCAP_MAX, "\n"));
+ this.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MAX;
+ stuffcmd(this, strcat("cl_jumpspeedcap_max ", PHYS_JUMPSPEEDCAP_MAX, "\n"));
}
#endif
- if(PHYS_DEAD(self))
+ if(PHYS_DEAD(this))
{
// handle water here
- vector midpoint = ((self.absmin + self.absmax) * 0.5);
+ vector midpoint = ((this.absmin + this.absmax) * 0.5);
if(pointcontents(midpoint) == CONTENT_WATER)
{
- self.velocity = self.velocity * 0.5;
+ this.velocity = this.velocity * 0.5;
// do we want this?
//if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER)
- //{ self.velocity_z = 70; }
+ //{ this.velocity_z = 70; }
}
goto end;
}
#ifdef SVQC
- if (!self.fixangle && !g_bugrigs)
- self.angles = '0 1 0' * self.v_angle.y;
+ if (!this.fixangle && !g_bugrigs)
+ this.angles = '0 1 0' * this.v_angle.y;
#endif
PM_check_hitground();
- if(IsFlying(self))
- self.wasFlying = 1;
+ if(IsFlying(this))
+ this.wasFlying = 1;
- if (IS_PLAYER(self))
+ if (IS_PLAYER(this))
CheckPlayerJump();
- if (self.flags & FL_WATERJUMP)
+ if (this.flags & FL_WATERJUMP)
{
- self.velocity_x = self.movedir_x;
- self.velocity_y = self.movedir_y;
- if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
+ this.velocity_x = this.movedir.x;
+ this.velocity_y = this.movedir.y;
+ if (time > this.teleport_time || this.waterlevel == WATERLEVEL_NONE)
{
- self.flags &= ~FL_WATERJUMP;
- self.teleport_time = 0;
+ this.flags &= ~FL_WATERJUMP;
+ this.teleport_time = 0;
}
}
#ifdef SVQC
- else if (g_bugrigs && IS_PLAYER(self))
+ else if (g_bugrigs && IS_PLAYER(this))
RaceCarPhysics();
#endif
- else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, self))
+ else if (this.movetype == MOVETYPE_NOCLIP || this.movetype == MOVETYPE_FLY || this.movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, this))
PM_fly(maxspeed_mod);
- else if (self.waterlevel >= WATERLEVEL_SWIMMING)
+ else if (this.waterlevel >= WATERLEVEL_SWIMMING)
PM_swim(maxspeed_mod);
- else if (time < self.ladder_time)
+ else if (time < this.ladder_time)
PM_ladder(maxspeed_mod);
- else if (ITEMS_STAT(self) & IT_USING_JETPACK)
+ else if (ITEMS_STAT(this) & IT_USING_JETPACK)
PM_jetpack(maxspeed_mod);
- else if (IS_ONGROUND(self))
- PM_walk(buttons_prev, maxspeed_mod);
+ else if (IS_ONGROUND(this))
+ PM_walk(this, maxspeed_mod);
else
PM_air(buttons_prev, maxspeed_mod);
PM_check_vortex();
:end
- if (IS_ONGROUND(self))
- self.lastground = time;
+ if (IS_ONGROUND(this))
+ this.lastground = time;
// conveyors: then break velocity again
- if(self.conveyor.state)
- self.velocity += self.conveyor.movedir;
+ if(this.conveyor.state)
+ this.velocity += this.conveyor.movedir;
- self.lastflags = self.flags;
+ this.lastflags = this.flags;
- self.lastclassname = self.classname;
+ this.lastclassname = this.classname;
#ifdef CSQC
- self.v_angle = oldv_angle;
- self.angles = oldangles;
+ this.v_angle = oldv_angle;
+ this.angles = oldangles;
#endif
}
-#ifdef SVQC
+#if defined(SVQC)
void SV_PlayerPhysics()
#elif defined(CSQC)
-void CSQC_ClientMovement_PlayerMove_Frame()
+void CSQC_ClientMovement_PlayerMove_Frame(entity this)
#endif
-{SELFPARAM();
- PM_Main();
-
+{
+#ifdef SVQC
+ SELFPARAM();
+#endif
+ PM_Main(this);
#ifdef CSQC
- self.pmove_flags =
- ((self.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
- (!(self.flags & FL_JUMPRELEASED) ? 0 : PMF_JUMP_HELD) |
- ((self.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
+ this.pmove_flags =
+ ((this.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
+ (!(this.flags & FL_JUMPRELEASED) ? PMF_JUMP_HELD : 0) |
+ ((this.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
#endif
}
#define PHYS_INPUT_MOVEVALUES(s) input_movevalues
- #define PHYS_INPUT_BUTTON_MASK(s) (input_buttons | 128 * (input_movevalues_x < 0) | 256 * (input_movevalues_x > 0) | 512 * (input_movevalues_y < 0) | 1024 * (input_movevalues_y > 0))
- #define PHYS_INPUT_BUTTON_ATCK(s) !!(input_buttons & 1)
- #define PHYS_INPUT_BUTTON_JUMP(s) !!(input_buttons & 2)
- #define PHYS_INPUT_BUTTON_ATCK2(s) !!(input_buttons & 4)
- #define PHYS_INPUT_BUTTON_ZOOM(s) !!(input_buttons & 8)
- #define PHYS_INPUT_BUTTON_CROUCH(s) !!(input_buttons & 16)
- #define PHYS_INPUT_BUTTON_HOOK(s) !!(input_buttons & 32)
- #define PHYS_INPUT_BUTTON_USE(s) !!(input_buttons & 64)
- #define PHYS_INPUT_BUTTON_BACKWARD(s) !!(input_buttons & 128)
- #define PHYS_INPUT_BUTTON_FORWARD(s) !!(input_buttons & 256)
- #define PHYS_INPUT_BUTTON_LEFT(s) !!(input_buttons & 512)
- #define PHYS_INPUT_BUTTON_RIGHT(s) !!(input_buttons & 1024)
- #define PHYS_INPUT_BUTTON_JETPACK(s) !!(input_buttons & 4096)
+ #define PHYS_INPUT_BUTTON_MASK(s) (input_buttons | BIT(7) * (input_movevalues.x < 0) | BIT(8) * (input_movevalues.x > 0) | BIT(9) * (input_movevalues.y < 0) | BIT(10) * (input_movevalues.y > 0))
+ #define PHYS_INPUT_BUTTON_ATCK(s) boolean(input_buttons & BIT(0))
+ #define PHYS_INPUT_BUTTON_JUMP(s) boolean(input_buttons & BIT(1))
+ #define PHYS_INPUT_BUTTON_ATCK2(s) boolean(input_buttons & BIT(2))
+ #define PHYS_INPUT_BUTTON_ZOOM(s) boolean(input_buttons & BIT(3))
+ #define PHYS_INPUT_BUTTON_CROUCH(s) boolean(input_buttons & BIT(4))
+ #define PHYS_INPUT_BUTTON_HOOK(s) boolean(input_buttons & BIT(5))
+ #define PHYS_INPUT_BUTTON_USE(s) boolean(input_buttons & BIT(6))
+ #define PHYS_INPUT_BUTTON_BACKWARD(s) boolean(input_buttons & BIT(7))
+ #define PHYS_INPUT_BUTTON_FORWARD(s) boolean(input_buttons & BIT(8))
+ #define PHYS_INPUT_BUTTON_LEFT(s) boolean(input_buttons & BIT(9))
+ #define PHYS_INPUT_BUTTON_RIGHT(s) boolean(input_buttons & BIT(10))
+ #define PHYS_INPUT_BUTTON_JETPACK(s) boolean(input_buttons & BIT(12))
#define PHYS_DEAD(s) s.csqcmodel_isdead
- #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE !!(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
+ #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
#define GAMEPLAYFIX_NOGRAVITYONGROUND cvar("sv_gameplayfix_nogravityonground")
#define GAMEPLAYFIX_Q2AIRACCELERATE cvar("sv_gameplayfix_q2airaccelerate")
#define GAMEPLAYFIX_EASIERWATERJUMP getstati(STAT_GAMEPLAYFIX_EASIERWATERJUMP)
#define GAMEPLAYFIX_UNSTICKPLAYERS getstati(STAT_GAMEPLAYFIX_UNSTICKPLAYERS)
#define GAMEPLAYFIX_STEPDOWN getstati(STAT_GAMEPLAYFIX_STEPDOWN)
- #define IS_DUCKED(s) !!(s.flags & FL_DUCKED)
+ #define IS_DUCKED(s) boolean(s.flags & FL_DUCKED)
#define SET_DUCKED(s) s.flags |= FL_DUCKED
#define UNSET_DUCKED(s) s.flags &= ~FL_DUCKED
#define SET_JUMP_HELD(s) s.flags &= ~FL_JUMPRELEASED
#define UNSET_JUMP_HELD(s) s.flags |= FL_JUMPRELEASED
- #define IS_ONGROUND(s) !!(s.flags & FL_ONGROUND)
+ #define IS_ONGROUND(s) boolean(s.flags & FL_ONGROUND)
#define SET_ONGROUND(s) s.flags |= FL_ONGROUND
#define UNSET_ONGROUND(s) s.flags &= ~FL_ONGROUND
- #define WAS_ONGROUND(s) !!(s.lastflags & FL_ONGROUND)
+ #define WAS_ONGROUND(s) boolean(s.lastflags & FL_ONGROUND)
#define ITEMS_STAT(s) (s).items
#define BUFFS_STAT(s) getstati(STAT_BUFFS)
#define SET_JUMP_HELD(s) s.flags &= ~FL_JUMPRELEASED
#define UNSET_JUMP_HELD(s) s.flags |= FL_JUMPRELEASED
- #define IS_ONGROUND(s) !!(s.flags & FL_ONGROUND)
+ #define IS_ONGROUND(s) boolean(s.flags & FL_ONGROUND)
#define SET_ONGROUND(s) s.flags |= FL_ONGROUND
#define UNSET_ONGROUND(s) s.flags &= ~FL_ONGROUND
- #define WAS_ONGROUND(s) !!((s).lastflags & FL_ONGROUND)
+ #define WAS_ONGROUND(s) boolean((s).lastflags & FL_ONGROUND)
#define ITEMS_STAT(s) s.items
#define BUFFS_STAT(s) (s).buffs
{
if(!self.state)
return;
- InterpolateOrigin_Do();
+ InterpolateOrigin_Do(self);
if(self.count & 0x80)
{
if(self.count & 0x10)
NET_HANDLE(ENT_CLIENT_LASER, bool isnew)
{
- InterpolateOrigin_Undo();
+ InterpolateOrigin_Undo(self);
// 30 bytes, or 13 bytes for just moving
int f = ReadByte();
return = true;
- InterpolateOrigin_Note();
+ InterpolateOrigin_Note(this);
self.draw = Draw_Laser;
}
#endif
}
#elif defined(CSQC)
+entity TargetMusic_list;
+STATIC_INIT(TargetMusic_list)
+{
+ TargetMusic_list = LL_NEW();
+}
+
void TargetMusic_Advance()
{
// run AFTER all the thinks!
- entity best, e;
- float vol, vol0;
- best = music_default;
- if(music_target && time < music_target.lifetime)
- best = music_target;
- if(music_trigger)
- best = music_trigger;
- for(e = world; (e = findfloat(e, enttype, NET_ENT_CLIENT_TRIGGER_MUSIC.m_id)); ) if(e.noise)
- {
- vol0 = e.lastvol;
- if(getsoundtime(e, CH_BGM_SINGLE) < 0)
- {
- vol0 = -1;
- }
- if(e == best)
+ entity best = music_default;
+ if (music_target && time < music_target.lifetime) best = music_target;
+ if (music_trigger) best = music_trigger;
+ LL_EACH(TargetMusic_list, it.noise, LAMBDA(
+ const float vol0 = (getsoundtime(it, CH_BGM_SINGLE) >= 0) ? it.lastvol : -1;
+ if (it == best)
{
// increase volume
- if(e.fade_time > 0)
- e.state = bound(0, e.state + frametime / e.fade_time, 1);
- else
- e.state = 1;
+ it.state = (it.fade_time > 0) ? bound(0, it.state + frametime / it.fade_time, 1) : 1;
}
else
{
// decrease volume
- if(e.fade_rate > 0)
- e.state = bound(0, e.state - frametime / e.fade_rate, 1);
- else
- e.state = 0;
+ it.state = (it.fade_rate > 0) ? bound(0, it.state - frametime / it.fade_rate, 1) : 0;
}
- vol = e.state * e.volume * autocvar_bgmvolume;
- if(vol != vol0)
+ const float vol = it.state * it.volume * autocvar_bgmvolume;
+ if (vol != vol0)
{
if(vol0 < 0)
- _sound(e, CH_BGM_SINGLE, e.noise, vol, ATTEN_NONE); // restart
+ _sound(it, CH_BGM_SINGLE, it.noise, vol, ATTEN_NONE); // restart
else
- _sound(e, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
- e.lastvol = vol;
+ _sound(it, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
+ it.lastvol = vol;
}
- }
+ ));
music_trigger = world;
-
- if(best)
- bgmtime = getsoundtime(best, CH_BGM_SINGLE);
- else
- bgmtime = gettime(GETTIME_CDTRACK);
+ bgmtime = (best) ? getsoundtime(best, CH_BGM_SINGLE) : gettime(GETTIME_CDTRACK);
}
NET_HANDLE(TE_CSQC_TARGET_MUSIC, bool isNew)
void Net_TargetMusic()
{
- int id = ReadShort();
- float vol = ReadByte() / 255.0;
- float fai = ReadByte() / 16.0;
- float fao = ReadByte() / 16.0;
- float tim = ReadByte();
- string noi = ReadString();
+ const int id = ReadShort();
+ const float vol = ReadByte() / 255.0;
+ const float fai = ReadByte() / 16.0;
+ const float fao = ReadByte() / 16.0;
+ const float tim = ReadByte();
+ const string noi = ReadString();
- entity e;
- for(e = world; (e = findfloat(e, enttype, NET_ENT_CLIENT_TRIGGER_MUSIC.m_id)); )
- {
- if(e.count == id)
- break;
- }
- if(!e)
+ entity e = NULL;
+ LL_EACH(TargetMusic_list, it.count == id, LAMBDA(e = it; break));
+ if (!e)
{
- e = spawn();
- e.enttype = NET_ENT_CLIENT_TRIGGER_MUSIC.m_id;
+ LL_PUSH(TargetMusic_list, e = new(TargetMusic));
+ make_pure(e);
e.count = id;
}
if(e.noise != noi)
}
trigger_push_link();
- defer(0.1, trigger_push_updatelink);
+ defer(self, 0.1, trigger_push_updatelink);
#endif
}
case ANIM_PAIN:
if(self.frame != ANIM_PAIN)
- defer(0.25, walker_setnoanim);
+ defer(self, 0.25, walker_setnoanim);
break;
case ANIM_MELEE:
if(self.frame != ANIM_MELEE)
{
- defer(0.41, walker_setnoanim);
- defer(0.21, walker_melee_do_dmg);
+ defer(self, 0.41, walker_setnoanim);
+ defer(self, 0.21, walker_melee_do_dmg);
}
movelib_beak_simple((autocvar_g_turrets_unit_walker_speed_stop));
string get_model_parameters_desc;
float get_model_parameters(string mod, float skn); // call with string_null to clear; skin -1 means mod is the filename of the txt file and is to be split
-vector vec2(vector v);
-
#ifndef MENUQC
vector NearestPointOnBox(entity box, vector org);
#endif
#define normal_or_gentle(normal, gentle) (GENTLE ? ((gentle != "") ? gentle : normal) : normal)
#endif
-vector vec3(float x, float y, float z);
-
#ifndef MENUQC
vector animfixfps(entity e, vector a, vector b);
#endif
//if(!PHYS_INPUT_BUTTON_CROUCH(self) && !IS_DUCKED(self))
#ifdef SVQC
//self.BUTTON_CROUCH = (oldmovement_x < 0);
- if(oldmovement_x < 0)
+ if (oldmovement.x < 0)
self.BUTTON_CROUCH = true;
#elif defined(CSQC)
- if(oldmovement_x < 0) { input_buttons |= 16; self.flags |= FL_DUCKED; } //else { input_buttons &= ~16; self.flags &= ~FL_DUCKED; }
+ if (oldmovement.x < 0)
+ {
+ input_buttons |= BIT(4);
+ self.flags |= FL_DUCKED;
+ }
+ //else { input_buttons &= ~16; self.flags &= ~FL_DUCKED; }
#endif
}
}
void viewloc_SetViewLocation()
{
entity view = CSQCModel_server2csqc(player_localentnum);
- if(!view) { return; }
+ if (!view) return;
//NOTE: the "cam_" cvars sould probably be changed out with a spawnflag or an entity key. I have it like this for my testing -- Player_2
if(view.viewloc && !wasfreed(view.viewloc) && view.viewloc.enemy && view.viewloc.goalentity)
{
if(!self.beam_usevieworigin)
{
- InterpolateOrigin_Do();
+ InterpolateOrigin_Do(self);
}
// origin = beam starting origin
// self.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
self.iflags = IFLAG_ORIGIN;
- InterpolateOrigin_Undo();
+ InterpolateOrigin_Undo(self);
}
if(sf & ARC_SF_START) // starting location
if(!self.beam_usevieworigin)
{
- InterpolateOrigin_Note();
+ InterpolateOrigin_Note(this);
}
return true;
}
// we don't do this for the local player as that one is already handled
// by CSQCPlayer_SetCamera()
- if(!CSQCPlayer_IsLocalPlayer())
- InterpolateOrigin_Do();
+ if (!CSQCPlayer_IsLocalPlayer(this)) InterpolateOrigin_Do(this);
CSQCModel_InterpolateAnimation_Do();
{ CSQCMODEL_HOOK_PREUPDATE }
- CSQCPlayer_PreUpdate();
- InterpolateOrigin_Undo();
+ CSQCPlayer_PreUpdate(this);
+ InterpolateOrigin_Undo(this);
CSQCModel_InterpolateAnimation_PreNote(sf);
#define CSQCMODEL_IF(cond) if(cond) {
}
CSQCModel_InterpolateAnimation_Note(sf);
- InterpolateOrigin_Note();
- CSQCPlayer_PostUpdate();
+ InterpolateOrigin_Note(this);
+ CSQCPlayer_PostUpdate(this);
{ CSQCMODEL_HOOK_POSTUPDATE }
#ifdef CSQCMODEL_SUPPORT_GETTAGINFO_BEFORE_DRAW
- InterpolateOrigin_Do();
+ InterpolateOrigin_Do(this);
CSQCModel_InterpolateAnimation_Do();
#endif
vector CSQCPlayer_GetPredictionErrorO()
{
- if(time >= csqcplayer_predictionerrortime)
- return '0 0 0';
+ if (time >= csqcplayer_predictionerrortime) return '0 0 0';
return csqcplayer_predictionerroro * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor;
}
vector CSQCPlayer_GetPredictionErrorV()
{
- if(time >= csqcplayer_predictionerrortime)
- return '0 0 0';
+ if (time >= csqcplayer_predictionerrortime) return '0 0 0';
return csqcplayer_predictionerrorv * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor;
}
csqcplayer_predictionerrortime = time + 1.0 / csqcplayer_predictionerrorfactor;
}
-void CSQCPlayer_Unpredict()
-{SELFPARAM();
- if(csqcplayer_status == CSQCPLAYERSTATUS_UNPREDICTED)
- return;
- if(csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED)
- error("Cannot unpredict in current status");
- self.origin = csqcplayer_origin;
- self.velocity = csqcplayer_velocity;
- csqcplayer_moveframe = csqcplayer_sequence+1; //+1 because the recieved frame has the move already done (server side)
- self.flags = player_pmflags;
+void CSQCPlayer_Unpredict(entity this)
+{
+ if (csqcplayer_status == CSQCPLAYERSTATUS_UNPREDICTED) return;
+ if (csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED) LOG_FATALF("Cannot unpredict in current status (%d)\n", csqcplayer_status);
+ this.origin = csqcplayer_origin;
+ this.velocity = csqcplayer_velocity;
+ csqcplayer_moveframe = csqcplayer_sequence + 1; // + 1 because the recieved frame has the move already done (server side)
+ this.flags = player_pmflags;
}
-void CSQCPlayer_SetMinsMaxs()
-{SELFPARAM();
- if(self.flags & FL_DUCKED)
+void CSQCPlayer_SetMinsMaxs(entity this)
+{
+ if (this.flags & FL_DUCKED)
{
- self.mins = PL_CROUCH_MIN;
- self.maxs = PL_CROUCH_MAX;
- self.view_ofs = PL_CROUCH_VIEW_OFS;
+ this.mins = PL_CROUCH_MIN;
+ this.maxs = PL_CROUCH_MAX;
+ this.view_ofs = PL_CROUCH_VIEW_OFS;
}
else
{
- self.mins = PL_MIN;
- self.maxs = PL_MAX;
- self.view_ofs = PL_VIEW_OFS;
+ this.mins = PL_MIN;
+ this.maxs = PL_MAX;
+ this.view_ofs = PL_VIEW_OFS;
}
}
-void CSQCPlayer_SavePrediction()
-{SELFPARAM();
- player_pmflags = self.flags;
- csqcplayer_origin = self.origin;
- csqcplayer_velocity = self.velocity;
+void CSQCPlayer_SavePrediction(entity this)
+{
+ player_pmflags = this.flags;
+ csqcplayer_origin = this.origin;
+ csqcplayer_velocity = this.velocity;
csqcplayer_sequence = servercommandframe;
csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
}
-void CSQC_ClientMovement_PlayerMove_Frame();
+void CSQC_ClientMovement_PlayerMove_Frame(entity this);
-void PM_Movement_Move()
-{SELFPARAM();
- runstandardplayerphysics(self);
+void PM_Movement_Move(entity this)
+{
+ runstandardplayerphysics(this);
#ifdef CSQC
- self.flags =
- ((self.pmove_flags & PMF_DUCKED) ? FL_DUCKED : 0) |
- (!(self.pmove_flags & PMF_JUMP_HELD) ? FL_JUMPRELEASED : 0) |
- ((self.pmove_flags & PMF_ONGROUND) ? FL_ONGROUND : 0);
+ this.flags =
+ ((this.pmove_flags & PMF_DUCKED) ? FL_DUCKED : 0) |
+ (!(this.pmove_flags & PMF_JUMP_HELD) ? FL_JUMPRELEASED : 0) |
+ ((this.pmove_flags & PMF_ONGROUND) ? FL_ONGROUND : 0);
#endif
}
-void CSQCPlayer_Physics()
+void CSQCPlayer_Physics(entity this)
{
- switch(autocvar_cl_movement)
+ switch (autocvar_cl_movement)
{
- case 1: CSQC_ClientMovement_PlayerMove_Frame(); break;
- case 2: PM_Movement_Move(); break;
+ case 1: CSQC_ClientMovement_PlayerMove_Frame(this); break;
+ case 2: PM_Movement_Move(this); break;
}
}
-void CSQCPlayer_PredictTo(float endframe, float apply_error)
-{SELFPARAM();
- CSQCPlayer_Unpredict();
- if(apply_error)
+void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error)
+{
+ CSQCPlayer_Unpredict(this);
+ if (apply_error)
{
- self.origin += CSQCPlayer_GetPredictionErrorO();
- self.velocity += CSQCPlayer_GetPredictionErrorV();
+ this.origin += CSQCPlayer_GetPredictionErrorO();
+ this.velocity += CSQCPlayer_GetPredictionErrorV();
}
- CSQCPlayer_SetMinsMaxs();
+ CSQCPlayer_SetMinsMaxs(this);
csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
}
#endif
- if(csqcplayer_moveframe >= endframe)
+ if (csqcplayer_moveframe >= endframe)
{
getinputstate(csqcplayer_moveframe - 1);
}
{
do
{
- if (!getinputstate(csqcplayer_moveframe))
- break;
- CSQCPlayer_Physics();
- CSQCPlayer_SetMinsMaxs();
- csqcplayer_moveframe++;
+ if (!getinputstate(csqcplayer_moveframe)) break;
+ CSQCPlayer_Physics(this);
+ CSQCPlayer_SetMinsMaxs(this);
+ ++csqcplayer_moveframe;
}
- while(csqcplayer_moveframe < endframe);
+ while (csqcplayer_moveframe < endframe);
}
- //add in anything that was applied after (for low packet rate protocols)
+ // add in anything that was applied after (for low packet rate protocols)
input_angles = view_angles;
}
-bool CSQCPlayer_IsLocalPlayer()
-{SELFPARAM();
- return (self == csqcplayer);
+bool CSQCPlayer_IsLocalPlayer(entity this)
+{
+ return (this == csqcplayer);
}
void CSQCPlayer_SetViewLocation()
viewloc_SetViewLocation();
}
+/** Called once per CSQC_UpdateView() */
void CSQCPlayer_SetCamera()
-{SELFPARAM();
- vector v0;
- v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
-
- if(csqcplayer)
+{
+ const vector v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
+ const float vh = getstati(STAT_VIEWHEIGHT);
+ const vector pl_viewofs = PL_VIEW_OFS;
+ const vector pl_viewofs_crouch = PL_CROUCH_VIEW_OFS;
+ const entity e = csqcplayer;
+ if (e)
{
- setself(csqcplayer);
-
- if(servercommandframe == 0 || clientcommandframe == 0)
+ if (servercommandframe == 0 || clientcommandframe == 0)
{
- InterpolateOrigin_Do();
- self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+ InterpolateOrigin_Do(e);
+ e.view_ofs = '0 0 1' * vh;
// get crouch state from the server
- if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z)
- self.flags &= ~FL_DUCKED;
- else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z)
- self.flags |= FL_DUCKED;
+ if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
+ else if (vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
// get onground state from the server
- if(pmove_onground)
- self.flags |= FL_ONGROUND;
- else
- self.flags &= ~FL_ONGROUND;
+ e.flags = BITSET(e.flags, FL_ONGROUND, pmove_onground);
- CSQCPlayer_SetMinsMaxs();
+ CSQCPlayer_SetMinsMaxs(e);
// override it back just in case
- self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+ e.view_ofs = '0 0 1' * vh;
// set velocity
- self.velocity = v0;
+ e.velocity = v0;
}
else
{
- float flg = self.iflags;
- self.iflags &= ~(IFLAG_ORIGIN | IFLAG_ANGLES);
- InterpolateOrigin_Do();
- self.iflags = flg;
+ const int flg = e.iflags; e.iflags &= ~(IFLAG_ORIGIN | IFLAG_ANGLES);
+ InterpolateOrigin_Do(e);
+ e.iflags = flg;
- if(csqcplayer_status == CSQCPLAYERSTATUS_FROMSERVER)
+ if (csqcplayer_status == CSQCPLAYERSTATUS_FROMSERVER)
{
- vector o, v;
- o = self.origin;
- v = v0;
+ const vector o = e.origin;
csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
- CSQCPlayer_PredictTo(servercommandframe + 1, false);
- CSQCPlayer_SetPredictionError(self.origin - o, self.velocity - v, pmove_onground - !!(self.flags & FL_ONGROUND));
- self.origin = o;
- self.velocity = v;
+ CSQCPlayer_PredictTo(e, servercommandframe + 1, false);
+ CSQCPlayer_SetPredictionError(e.origin - o, e.velocity - v0, pmove_onground - boolean(e.flags & FL_ONGROUND));
+ e.origin = o;
+ e.velocity = v0;
// get crouch state from the server
- if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z)
- self.flags &= ~FL_DUCKED;
- else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z)
- self.flags |= FL_DUCKED;
+ if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
+ else if(vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
// get onground state from the server
- if(pmove_onground)
- self.flags |= FL_ONGROUND;
- else
- self.flags &= ~FL_ONGROUND;
+ e.flags = BITSET(e.flags, FL_ONGROUND, pmove_onground);
- CSQCPlayer_SavePrediction();
+ CSQCPlayer_SavePrediction(e);
}
- CSQCPlayer_PredictTo(clientcommandframe + 1, true);
+ CSQCPlayer_PredictTo(e, clientcommandframe + 1, true);
#ifdef CSQCMODEL_SERVERSIDE_CROUCH
// get crouch state from the server (LAG)
- if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z)
- self.flags &= ~FL_DUCKED;
- else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z)
- self.flags |= FL_DUCKED;
+ if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
+ else if (vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
#endif
+ CSQCPlayer_SetMinsMaxs(e);
- CSQCPlayer_SetMinsMaxs();
-
- self.angles_y = input_angles.y;
+ e.angles_y = input_angles.y;
}
// relink
- setorigin(self, self.origin);
-
- setself(this);
- }
-
- entity view = CSQCModel_server2csqc(player_localentnum);
-
- if(view && view != csqcplayer)
- {
- WITH(entity, self, view, InterpolateOrigin_Do());
- view.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+ setorigin(e, e.origin);
}
- if(view)
+ const entity view = CSQCModel_server2csqc(player_localentnum);
+ if (view)
{
+ if (view != csqcplayer)
+ {
+ InterpolateOrigin_Do(view);
+ view.view_ofs = '0 0 1' * vh;
+ }
int refdefflags = 0;
-
- if(view.csqcmodel_teleported)
- refdefflags |= REFDEFFLAG_TELEPORTED;
-
- if(input_buttons & 4)
- refdefflags |= REFDEFFLAG_JUMPING;
-
+ if (view.csqcmodel_teleported) refdefflags |= REFDEFFLAG_TELEPORTED;
+ if (input_buttons & BIT(1)) refdefflags |= REFDEFFLAG_JUMPING;
// note: these two only work in WIP2, but are harmless in WIP1
- if(getstati(STAT_HEALTH) <= 0)
- refdefflags |= REFDEFFLAG_DEAD;
-
- if(intermission)
- refdefflags |= REFDEFFLAG_INTERMISSION;
-
+ if (getstati(STAT_HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD;
+ if (intermission) refdefflags |= REFDEFFLAG_INTERMISSION;
V_CalcRefdef(view, refdefflags);
}
else
// FIXME by CSQC spec we have to do this:
// but it breaks chase cam
/*
- setproperty(VF_ORIGIN, pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT));
+ setproperty(VF_ORIGIN, pmove_org + '0 0 1' * vh);
setproperty(VF_ANGLES, view_angles);
*/
}
-
- { CSQCPLAYER_HOOK_POSTCAMERASETUP }
+ CSQCPLAYER_HOOK_POSTCAMERASETUP();
}
void CSQCPlayer_Remove()
{
- csqcplayer = world;
+ csqcplayer = NULL;
cvar_settemp("cl_movement_replay", "1");
}
-float CSQCPlayer_PreUpdate()
-{SELFPARAM();
- if(self != csqcplayer)
- return 0;
- if(csqcplayer_status != CSQCPLAYERSTATUS_FROMSERVER)
- CSQCPlayer_Unpredict();
- return 1;
+bool CSQCPlayer_PreUpdate(entity this)
+{
+ if (this != csqcplayer) return false;
+ if (csqcplayer_status != CSQCPLAYERSTATUS_FROMSERVER) CSQCPlayer_Unpredict(this);
+ return true;
}
-float CSQCPlayer_PostUpdate()
-{SELFPARAM();
- if(self.entnum != player_localnum + 1)
- return 0;
- csqcplayer = self;
+bool CSQCPlayer_PostUpdate(entity this)
+{
+ if (this.entnum != player_localnum + 1) return false;
+ csqcplayer = this;
csqcplayer_status = CSQCPLAYERSTATUS_FROMSERVER;
cvar_settemp("cl_movement_replay", "0");
- self.entremove = CSQCPlayer_Remove;
- return 1;
+ this.entremove = CSQCPlayer_Remove;
+ return true;
}
const int FL_DUCKED = 524288;
void CSQCPlayer_SetCamera();
-float CSQCPlayer_PreUpdate();
-float CSQCPlayer_PostUpdate();
-float CSQCPlayer_IsLocalPlayer();
+float CSQCPlayer_PreUpdate(entity this);
+float CSQCPlayer_PostUpdate(entity this);
+float CSQCPlayer_IsLocalPlayer(entity this);
#endif
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\
IN THE SOFTWARE.\
-";
+"; // "
.vector glowmod;
.vector view_ofs;
*/
#include "interpolate.qh"
-#if defined(CSQC)
-// #include "../../client/defs.qh"
-// #include "../warpzone/anglestransform.qh"
-// #include "../../client/autocvars.qh"
-// #include "cl_model.qh"
-#elif defined(MENUQC)
-#elif defined(SVQC)
-#endif
-
+// 1 = old, 2 = new
.vector iorigin1, iorigin2;
.vector ivelocity1, ivelocity2;
.vector iforward1, iforward2;
.vector ivup1, ivup2;
.float itime1, itime2;
void InterpolateOrigin_Reset()
-{SELFPARAM();
+{
+ SELFPARAM();
self.iflags &= ~IFLAG_INTERNALMASK;
self.itime1 = self.itime2 = 0;
}
-void InterpolateOrigin_Note()
-{SELFPARAM();
- float dt;
- int f0;
-
- dt = time - self.itime2;
+void InterpolateOrigin_Note(entity this)
+{
+ float dt = time - this.itime2;
- f0 = self.iflags;
- if(self.iflags & IFLAG_PREVALID)
- self.iflags |= IFLAG_VALID;
- else
- self.iflags |= IFLAG_PREVALID;
+ int f0 = this.iflags;
+ if (this.iflags & IFLAG_PREVALID) this.iflags |= IFLAG_VALID;
+ else this.iflags |= IFLAG_PREVALID;
- if(self.iflags & IFLAG_ORIGIN)
+ if (this.iflags & IFLAG_ORIGIN)
{
- self.iorigin1 = self.iorigin2;
- self.iorigin2 = self.origin;
+ this.iorigin1 = this.iorigin2;
+ this.iorigin2 = this.origin;
}
- if(self.iflags & IFLAG_AUTOANGLES)
- if(self.iorigin2 != self.iorigin1)
- self.angles = vectoangles(self.iorigin2 - self.iorigin1);
+ if (this.iflags & IFLAG_AUTOANGLES
+ && this.iorigin2
+ != this.iorigin1) this.angles = vectoangles(this.iorigin2 - this.iorigin1);
- if(self.iflags & IFLAG_AUTOVELOCITY)
- if(self.itime2 != self.itime1)
- self.velocity = (self.iorigin2 - self.iorigin1) * (1.0 / (self.itime2 - self.itime1));
+ if (this.iflags & IFLAG_AUTOVELOCITY
+ && this.itime2
+ != this.itime1) this.velocity = (this.iorigin2 - this.iorigin1) * (1.0 / (this.itime2 - this.itime1));
- if(self.iflags & IFLAG_ANGLES)
+ if (this.iflags & IFLAG_ANGLES)
{
- fixedmakevectors(self.angles);
- if(f0 & IFLAG_VALID)
+ fixedmakevectors(this.angles);
+ if (f0 & IFLAG_VALID)
{
- self.iforward1 = self.iforward2;
- self.iup1 = self.iup2;
+ this.iforward1 = this.iforward2;
+ this.iup1 = this.iup2;
}
else
{
- self.iforward1 = v_forward;
- self.iup1 = v_up;
+ this.iforward1 = v_forward;
+ this.iup1 = v_up;
}
- self.iforward2 = v_forward;
- self.iup2 = v_up;
+ this.iforward2 = v_forward;
+ this.iup2 = v_up;
}
- if(self.iflags & IFLAG_V_ANGLE)
+ if (this.iflags & IFLAG_V_ANGLE)
{
- fixedmakevectors(self.v_angle);
- if(f0 & IFLAG_VALID)
+ fixedmakevectors(this.v_angle);
+ if (f0 & IFLAG_VALID)
{
- self.ivforward1 = self.ivforward2;
- self.ivup1 = self.ivup2;
+ this.ivforward1 = this.ivforward2;
+ this.ivup1 = this.ivup2;
}
else
{
- self.ivforward1 = v_forward;
- self.ivup1 = v_up;
+ this.ivforward1 = v_forward;
+ this.ivup1 = v_up;
}
- self.ivforward2 = v_forward;
- self.ivup2 = v_up;
+ this.ivforward2 = v_forward;
+ this.ivup2 = v_up;
}
- else if(self.iflags & IFLAG_V_ANGLE_X)
+ else if (this.iflags & IFLAG_V_ANGLE_X)
{
- self.ivforward1_x = self.ivforward2_x;
- self.ivforward2_x = self.v_angle.x;
+ this.ivforward1_x = this.ivforward2_x;
+ this.ivforward2_x = this.v_angle.x;
}
- if(self.iflags & IFLAG_VELOCITY)
+ if (this.iflags & IFLAG_VELOCITY)
{
- self.ivelocity1 = self.ivelocity2;
- self.ivelocity2 = self.velocity;
+ this.ivelocity1 = this.ivelocity2;
+ this.ivelocity2 = this.velocity;
}
- if(self.iflags & IFLAG_TELEPORTED)
+ if (this.iflags & IFLAG_TELEPORTED)
{
- self.iflags &= ~IFLAG_TELEPORTED;
- self.itime1 = self.itime2 = time; // don't lerp
+ this.iflags &= ~IFLAG_TELEPORTED;
+ this.itime1 = this.itime2 = time; // don't lerp
}
- else if(vlen(self.iorigin2 - self.iorigin1) > 1000)
+ else if (vdist(this.iorigin2 - this.iorigin1, >, 1000))
{
- self.itime1 = self.itime2 = time; // don't lerp
+ this.itime1 = this.itime2 = time; // don't lerp
}
- else if((self.iflags & IFLAG_VELOCITY) && (vlen(self.ivelocity2 - self.ivelocity1) > 1000))
+ else if ((this.iflags & IFLAG_VELOCITY) && vdist(this.ivelocity2 - this.ivelocity1, >, 1000))
{
- self.itime1 = self.itime2 = time; // don't lerp
+ this.itime1 = this.itime2 = time; // don't lerp
}
- else if(dt >= 0.2)
+ else if (dt >= 0.2)
{
- self.itime1 = self.itime2 = time;
+ this.itime1 = this.itime2 = time;
}
else
{
- self.itime1 = serverprevtime;
- self.itime2 = time;
+ this.itime1 = serverprevtime;
+ this.itime2 = time;
}
}
-void InterpolateOrigin_Do()
-{SELFPARAM();
- vector forward, up;
- if(self.itime1 && self.itime2 && self.itime1 != self.itime2)
+
+/** set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time */
+void InterpolateOrigin_Do(entity this)
+{
+ if (this.itime1 && this.itime2 && this.itime1 != this.itime2)
{
- float f;
- f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1 + autocvar_cl_lerpexcess);
- if(self.iflags & IFLAG_ORIGIN)
- setorigin(self, (1 - f) * self.iorigin1 + f * self.iorigin2);
- if(self.iflags & IFLAG_ANGLES)
+ float f = bound(0, (time - this.itime1) / (this.itime2 - this.itime1), 1 + autocvar_cl_lerpexcess);
+ float f_1 = 1 - f;
+ if (this.iflags & IFLAG_ORIGIN) setorigin(this, f_1 * this.iorigin1 + f * this.iorigin2);
+ if (this.iflags & IFLAG_ANGLES)
{
- forward = (1 - f) * self.iforward1 + f * self.iforward2;
- up = (1 - f) * self.iup1 + f * self.iup2;
- self.angles = fixedvectoangles2(forward, up);
+ vector forward = f_1 * this.iforward1 + f * this.iforward2;
+ vector up = f_1 * this.iup1 + f * this.iup2;
+ this.angles = fixedvectoangles2(forward, up);
}
- if(self.iflags & IFLAG_V_ANGLE)
+ if (this.iflags & IFLAG_V_ANGLE)
{
- forward = (1 - f) * self.ivforward1 + f * self.ivforward2;
- up = (1 - f) * self.ivup1 + f * self.ivup2;
- self.v_angle = fixedvectoangles2(forward, up);
+ vector forward = f_1 * this.ivforward1 + f * this.ivforward2;
+ vector up = f_1 * this.ivup1 + f * this.ivup2;
+ this.v_angle = fixedvectoangles2(forward, up);
}
- else if(self.iflags & IFLAG_V_ANGLE_X)
- self.v_angle_x = (1 - f) * self.ivforward1_x + f * self.ivforward2_x;
- if(self.iflags & IFLAG_VELOCITY)
- self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2;
+ else if (this.iflags & IFLAG_V_ANGLE_X)
+ {
+ this.v_angle_x = f_1 * this.ivforward1.x + f * this.ivforward2.x;
+ }
+ if (this.iflags & IFLAG_VELOCITY) this.velocity = f_1 * this.ivelocity1 + f * this.ivelocity2;
}
}
-void InterpolateOrigin_Undo()
-{SELFPARAM();
- if(self.iflags & IFLAG_ORIGIN)
- setorigin(self, self.iorigin2);
- if(self.iflags & IFLAG_ANGLES)
- self.angles = fixedvectoangles2(self.iforward2, self.iup2);
- if(self.iflags & IFLAG_V_ANGLE)
- self.v_angle = fixedvectoangles2(self.ivforward2, self.ivup2);
- else if(self.iflags & IFLAG_V_ANGLE_X)
- self.v_angle_x = self.ivforward2_x;
- if(self.iflags & IFLAG_VELOCITY)
- self.velocity = self.ivelocity2;
-}
+/** snap origin to iorigin2 (actual origin) */
+void InterpolateOrigin_Undo(entity this)
+{
+ if (this.iflags & IFLAG_ORIGIN) setorigin(this, this.iorigin2);
+ if (this.iflags & IFLAG_ANGLES) this.angles = fixedvectoangles2(this.iforward2, this.iup2);
+ if (this.iflags & IFLAG_V_ANGLE) this.v_angle = fixedvectoangles2(this.ivforward2, this.ivup2);
+ else if (this.iflags & IFLAG_V_ANGLE_X) this.v_angle_x = this.ivforward2_x;
+ if (this.iflags & IFLAG_VELOCITY) this.velocity = this.ivelocity2;
+}
const int IFLAG_INTERNALMASK = IFLAG_VALID | IFLAG_PREVALID;
// call this BEFORE reading an entity update
-void InterpolateOrigin_Undo();
+void InterpolateOrigin_Undo(entity this);
// call this AFTER receiving an entity update
-void InterpolateOrigin_Note();
+void InterpolateOrigin_Note(entity this);
// call this when the entity got teleported, before InterpolateOrigin_Note
void InterpolateOrigin_Reset();
// call this BEFORE drawing
-void InterpolateOrigin_Do();
+void InterpolateOrigin_Do(entity this);
// in case we interpolate that:
.vector v_angle;
void defer_think()
{
SELFPARAM();
- self.think = SUB_Remove_self;
- self.nextthink = time;
- WITH(entity, self, self.owner, self.use());
+ this.think = SUB_Remove_self;
+ this.nextthink = time;
+ WITH(entity, self, this.owner, this.use());
}
/*
Execute func() after time + fdelay.
self when func is executed = self when defer is called
*/
- void defer(float fdelay, void() func)
+ void defer(entity this, float fdelay, void() func)
{
- SELFPARAM();
-
entity e = new(deferred);
make_pure(e);
e.owner = this;
#define LL_NEW() NEW(LinkedList)
+#define LL_EMPTY(ll) (ll.ll_head == NULL)
+
/**
* Push to tail
*/
#ifndef VECTOR_H
#define VECTOR_H
+noref vector _vlen2;
+#define vlen2(v) \
+ (_vlen2 = (v), \
+ _vlen2.x * _vlen2.x \
+ + _vlen2.y * _vlen2.y \
+ + _vlen2.z * _vlen2.z)
+
+noref float _vdist_f;
+/** Vector distance comparison, avoids sqrt() */
+#define vdist(v, cmp, f) (vlen2(v) cmp (_vdist_f = (f), _vdist_f * _vdist_f))
+/*
+#define vdist(v, cmp, f) (vlen(v) cmp (f))
+*/
+
#define cross(a, b) ((a) >< (b))
/*
vector cross(vector a, vector b)
return v;
}
-float vlen2d(vector v)
-{
- return sqrt(v.x * v.x + v.y * v.y);
-}
-
float vlen_maxnorm2d(vector v)
{
return max(v.x, v.y, -v.x, -v.y);
float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { return smins.x >= bmins.x && smaxs.x <= bmaxs.x && smins.y >= bmins.y && smaxs.y <= bmaxs.y && smins.z >= bmins.z && smaxs.z <= bmaxs.z; }
-vector vec2(vector v)
-{
- v.z = 0;
- return v;
-}
+noref vector _vec2;
+#define vec2(v) (_vec2 = (v), _vec2.z = 0, _vec2)
-vector vec3(float x, float y, float z)
-{
- vector v;
- v.x = x;
- v.y = y;
- v.z = z;
- return v;
-}
+noref vector _vec3;
+#define vec3(x, y, z) (_vec3_x = (x), _vec3_y = (y), _vec3_z = (z), _vec3)
vector rotate(vector v, float a)
{
return r;
}
-vector yinvert(vector v)
-{
- v.y = 1 - v.y;
- return v;
-}
+noref vector _yinvert;
+#define yinvert(v) (_yinvert = (v), _yinvert.y = 1 - _yinvert.y, _yinvert)
#ifndef MENUQC
vector get_corner_position(entity box, int corner)
#include "anglestransform.qh"
-#ifdef POSITIVE_PITCH_IS_DOWN
-vector fixedvectoangles(vector a)
-{
- vector ang;
- ang = vectoangles(a);
- ang.x = -ang.x;
- return ang;
-}
-vector fixedvectoangles2(vector a, vector b)
-{
- vector ang;
- ang = vectoangles2(a, b);
- ang.x = -ang.x;
- return ang;
-}
-#else
-void fixedmakevectors(vector a)
-{
- // a makevectors that actually inverts vectoangles
- a.x = -a.x;
- makevectors(a);
-}
-#endif
-
// angles transforms
// angles in fixedmakevectors/fixedvectoangles space
vector AnglesTransform_Apply(vector transform, vector v)
return t;
}
-#ifdef POSITIVE_PITCH_IS_DOWN
+#if POSITIVE_PITCH_IS_DOWN
vector AnglesTransform_ApplyToAngles(vector transform, vector v)
{
v.x = -v.x;
#ifndef LIB_WARPZONE_ANGLETRANSFORM_H
#define LIB_WARPZONE_ANGLETRANSFORM_H
-#define POSITIVE_PITCH_IS_DOWN
+#ifndef POSITIVE_PITCH_IS_DOWN
+#define POSITIVE_PITCH_IS_DOWN 1
+#endif
-#ifdef POSITIVE_PITCH_IS_DOWN
-#define fixedmakevectors makevectors
-vector fixedvectoangles(vector a);
-vector fixedvectoangles2(vector a, vector b);
+#if POSITIVE_PITCH_IS_DOWN
+ #define fixedmakevectors makevectors
+ noref vector _fixedvectoangles;
+ #define fixedvectoangles(a) (_fixedvectoangles = vectoangles(a), _fixedvectoangles.x *= -1, _fixedvectoangles)
+ noref vector _fixedvectoangles2;
+ #define fixedvectoangles2(a, b) (_fixedvectoangles2 = vectoangles2(a, b), _fixedvectoangles2.x *= -1, _fixedvectoangles2)
#else
-void fixedmakevectors(vector a);
-#define fixedvectoangles2 vectoangles2
-#define fixedvectoangles vectoangles
+ void fixedmakevectors(vector a)
+ {
+ // a makevectors that actually inverts vectoangles
+ a.x = -a.x;
+ makevectors(a);
+ }
+ #define fixedvectoangles2 vectoangles2
+ #define fixedvectoangles vectoangles
#endif
vector AnglesTransform_Apply(vector transform, vector v);
float n;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Quality preset:")));
- n = 5 + 2 * !!cvar("developer");
+ n = 5 + 2 * boolean(cvar("developer"));
if(cvar("developer"))
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^OMG!")), '1 0 1', "exec effects-omg.cfg", 0));
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^Low")), '0 0 0', "exec effects-low.cfg", 0));
float teams, nTeams;
teams = cvar("_teams_available");
nTeams = 0;
- me.team1.disabled = !(teams & 1); nTeams += !!(teams & 1);
- me.team2.disabled = !(teams & 2); nTeams += !!(teams & 2);
- me.team3.disabled = !(teams & 4); nTeams += !!(teams & 4);
- me.team4.disabled = !(teams & 8); nTeams += !!(teams & 8);
+ me.team1.disabled = !(teams & 1); nTeams += boolean(teams & 1);
+ me.team2.disabled = !(teams & 2); nTeams += boolean(teams & 2);
+ me.team3.disabled = !(teams & 4); nTeams += boolean(teams & 4);
+ me.team4.disabled = !(teams & 8); nTeams += boolean(teams & 8);
}
void XonoticTeamSelectDialog_fill(entity me)
{
if(me.cvarName)
{
- me.checked = !!cvar(me.cvarName);
+ me.checked = boolean(cvar(me.cvarName));
}
else
{
}
// Keep pressing keys raised by the "presskey" command
- ispressingkey = !!bot_presskeys();
+ ispressingkey = boolean(bot_presskeys());
// Handle conditions
if (!(bot_cmd.bot_cmd_type==BOT_CMD_FI||bot_cmd.bot_cmd_type==BOT_CMD_ELSE))
self.model_randomizer = random();
if(IS_REAL_CLIENT(self))
- sv_notice_join();
+ sv_notice_join(self);
for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
WITH(entity, self, e, e.init_for_player(this));
}
else
{
- float missing_teams_mask = (!!p1) + (!!p2) * 2;
- if(kh_teams >= 3) missing_teams_mask += (!!p3) * 4;
- if(kh_teams >= 4) missing_teams_mask += (!!p4) * 8;
+ float missing_teams_mask = boolean(p1) + boolean(p2) * 2;
+ if(kh_teams >= 3) missing_teams_mask += boolean(p3) * 4;
+ if(kh_teams >= 4) missing_teams_mask += boolean(p4) * 8;
if(prev_missing_teams_mask != missing_teams_mask)
{
Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
*/
// PLAYERS use different math
-#ifndef POSITIVE_PITCH_IS_DOWN
+#if !(POSITIVE_PITCH_IS_DOWN)
ang.x = -ang.x;
#endif
//print("GOOD path: ", vtos(ang), "\n");
}
-#ifndef POSITIVE_PITCH_IS_DOWN
+#if !(POSITIVE_PITCH_IS_DOWN)
ang.x = -ang.x;
#endif
ang.z = vangle.z;
other.race_checkpoint = race_NextCheckpoint(self.race_checkpoint);
other.race_started = 1;
- race_SendTime(other, self.race_checkpoint, other.race_movetime, !!other.race_laptime);
+ race_SendTime(other, self.race_checkpoint, other.race_movetime, boolean(other.race_laptime));
if(!self.race_checkpoint) // start line
{
}
self.netname = "";
- self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
- self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
- self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * !!(self.items & ITEM_Strength.m_itemid), "strength");
- self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * !!(self.items & ITEM_Shield.m_itemid), "invincible");
- self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * !!(self.items & IT_SUPERWEAPON), "superweapons");
- self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & ITEM_Jetpack.m_itemid), "jetpack");
- self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
+ self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
+ self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
+ self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * boolean(self.items & ITEM_Strength.m_itemid), "strength");
+ self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * boolean(self.items & ITEM_Shield.m_itemid), "invincible");
+ self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * boolean(self.items & IT_SUPERWEAPON), "superweapons");
+ self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_Jetpack.m_itemid), "jetpack");
+ self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");