Spring cleaning part one.

This commit is contained in:
Marco Cawthorne 2022-05-11 12:49:04 -07:00
parent a039a69dd3
commit 25c54af62c
Signed by: eukara
GPG key ID: C196CD8BA993248A
89 changed files with 573 additions and 2078 deletions

View file

@ -15,7 +15,7 @@
*/ */
void void
Player_PreDraw(base_player pl, int thirdperson) Player_PreDraw(NSClientPlayer pl, int thirdperson)
{ {
/* Handle the flashlights... */ /* Handle the flashlights... */
if (pl.gflags & GF_FLASHLIGHT) { if (pl.gflags & GF_FLASHLIGHT) {

View file

@ -16,21 +16,21 @@
class GameRules:CGameRules class GameRules:CGameRules
{ {
virtual void(base_player) PlayerConnect; virtual void(NSClientPlayer) PlayerConnect;
virtual void(base_player) PlayerDisconnect; virtual void(NSClientPlayer) PlayerDisconnect;
virtual void(base_player) PlayerKill; virtual void(NSClientPlayer) PlayerKill;
virtual void(base_player) PlayerPostFrame; virtual void(NSClientPlayer) PlayerPostFrame;
virtual void(base_player) LevelDecodeParms; virtual void(NSClientPlayer) LevelDecodeParms;
virtual void(base_player) LevelChangeParms; virtual void(NSClientPlayer) LevelChangeParms;
virtual void(void) LevelNewParms; virtual void(void) LevelNewParms;
}; };
class SingleplayerRules:GameRules class SingleplayerRules:GameRules
{ {
/* client */ /* client */
virtual void(base_player) PlayerSpawn; virtual void(NSClientPlayer) PlayerSpawn;
virtual void(base_player) PlayerDeath; virtual void(NSClientPlayer) PlayerDeath;
}; };
class MultiplayerRules:GameRules class MultiplayerRules:GameRules
@ -41,7 +41,7 @@ class MultiplayerRules:GameRules
virtual void(void) FrameStart; virtual void(void) FrameStart;
/* client */ /* client */
virtual void(base_player) PlayerSpawn; virtual void(NSClientPlayer) PlayerSpawn;
virtual void(base_player) PlayerDeath; virtual void(NSClientPlayer) PlayerDeath;
virtual float(base_player, string) ConsoleCommand; virtual float(NSClientPlayer, string) ConsoleCommand;
}; };

View file

@ -17,7 +17,7 @@
var int autocvar_sv_playerkeepalive = TRUE; var int autocvar_sv_playerkeepalive = TRUE;
void void
GameRules::LevelDecodeParms(base_player pp) GameRules::LevelDecodeParms(NSClientPlayer pp)
{ {
player pl = (player)pp; player pl = (player)pp;
g_landmarkpos[0] = parm1; g_landmarkpos[0] = parm1;
@ -41,7 +41,7 @@ GameRules::LevelDecodeParms(base_player pp)
} }
void void
GameRules::LevelChangeParms(base_player pp) GameRules::LevelChangeParms(NSClientPlayer pp)
{ {
player pl = (player)pp; player pl = (player)pp;
parm1 = g_landmarkpos[0]; parm1 = g_landmarkpos[0];
@ -72,19 +72,19 @@ GameRules::LevelNewParms(void)
/* we check what fields have changed over the course of the frame and network /* we check what fields have changed over the course of the frame and network
* only the ones that have actually changed */ * only the ones that have actually changed */
void void
GameRules::PlayerPostFrame(base_player pl) GameRules::PlayerPostFrame(NSClientPlayer pl)
{ {
} }
void void
GameRules::PlayerConnect(base_player pl) GameRules::PlayerConnect(NSClientPlayer pl)
{ {
if (Plugin_PlayerConnect(pl) == FALSE) if (Plugin_PlayerConnect(pl) == FALSE)
bprint(PRINT_HIGH, sprintf("%s connected\n", pl.netname)); bprint(PRINT_HIGH, sprintf("%s connected\n", pl.netname));
} }
void void
GameRules::PlayerDisconnect(base_player pl) GameRules::PlayerDisconnect(NSClientPlayer pl)
{ {
if (Plugin_PlayerDisconnect(pl) == FALSE) if (Plugin_PlayerDisconnect(pl) == FALSE)
bprint(PRINT_HIGH, sprintf("%s disconnected\n", pl.netname)); bprint(PRINT_HIGH, sprintf("%s disconnected\n", pl.netname));
@ -99,7 +99,7 @@ GameRules::PlayerDisconnect(base_player pl)
} }
void void
GameRules::PlayerKill(base_player pl) GameRules::PlayerKill(NSClientPlayer pl)
{ {
Damage_Apply(pl, pl, pl.health, WEAPON_NONE, DMG_SKIP_ARMOR); Damage_Apply(pl, pl, pl.health, WEAPON_NONE, DMG_SKIP_ARMOR);
} }

View file

@ -26,7 +26,7 @@ MultiplayerRules::FrameStart(void)
} }
void void
MultiplayerRules::PlayerDeath(base_player pl) MultiplayerRules::PlayerDeath(NSClientPlayer pl)
{ {
Plugin_PlayerObituary(g_dmg_eAttacker, g_dmg_eTarget, g_dmg_iWeapon, g_dmg_iHitBody, g_dmg_iDamage); Plugin_PlayerObituary(g_dmg_eAttacker, g_dmg_eTarget, g_dmg_iWeapon, g_dmg_iHitBody, g_dmg_iDamage);
@ -61,7 +61,7 @@ MultiplayerRules::PlayerDeath(base_player pl)
} }
void void
MultiplayerRules::PlayerSpawn(base_player pp) MultiplayerRules::PlayerSpawn(NSClientPlayer pp)
{ {
player pl = (player)pp; player pl = (player)pp;
/* this is where the mods want to deviate */ /* this is where the mods want to deviate */
@ -99,7 +99,7 @@ MultiplayerRules::PlayerSpawn(base_player pp)
} }
float float
MultiplayerRules::ConsoleCommand(base_player pp, string cmd) MultiplayerRules::ConsoleCommand(NSClientPlayer pp, string cmd)
{ {
tokenize(cmd); tokenize(cmd);

View file

@ -15,7 +15,7 @@
*/ */
void void
SingleplayerRules::PlayerDeath(base_player pl) SingleplayerRules::PlayerDeath(NSClientPlayer pl)
{ {
pl.movetype = MOVETYPE_NONE; pl.movetype = MOVETYPE_NONE;
pl.solid = SOLID_NOT; pl.solid = SOLID_NOT;
@ -31,7 +31,7 @@ SingleplayerRules::PlayerDeath(base_player pl)
} }
void void
SingleplayerRules::PlayerSpawn(base_player pl) SingleplayerRules::PlayerSpawn(NSClientPlayer pl)
{ {
pl.classname = "player"; pl.classname = "player";
pl.health = pl.max_health = 100; pl.health = pl.max_health = 100;

View file

@ -29,7 +29,7 @@ item_pickup::Touch(entity eToucher)
} }
/* don't remove if AddItem fails */ /* don't remove if AddItem fails */
if (Weapons_AddItem((base_player)eToucher, id, m_iClip) == FALSE) { if (Weapons_AddItem((NSClientPlayer)eToucher, id, m_iClip) == FALSE) {
return; return;
} }

View file

@ -42,7 +42,7 @@ enumflags
PLAYER_UNUSED7 PLAYER_UNUSED7
}; };
class player:base_player class player:NSClientPlayer
{ {
PREDICTED_INT(mode_tempstate); PREDICTED_INT(mode_tempstate);
@ -68,7 +68,7 @@ player::ReceiveEntity
void void
player::ReceiveEntity(float new, float fl) player::ReceiveEntity(float new, float fl)
{ {
base_player::ReceiveEntity(new, fl); NSClientPlayer::ReceiveEntity(new, fl);
setorigin(this, origin); setorigin(this, origin);
} }
@ -83,7 +83,7 @@ so we can roll them back later.
void void
player::PredictPreFrame(void) player::PredictPreFrame(void)
{ {
base_player::PredictPreFrame(); NSClientPlayer::PredictPreFrame();
} }
/* /*
@ -96,14 +96,14 @@ Where we roll back our values to the ones last sent/verified by the server.
void void
player::PredictPostFrame(void) player::PredictPostFrame(void)
{ {
base_player::PredictPostFrame(); NSClientPlayer::PredictPostFrame();
} }
#else #else
void void
player::EvaluateEntity(void) player::EvaluateEntity(void)
{ {
base_player::EvaluateEntity(); NSClientPlayer::EvaluateEntity();
} }
/* /*
@ -132,7 +132,7 @@ player::SendEntity(entity ePEnt, float fChanged)
WriteFloat(MSG_ENTITY, fChanged); WriteFloat(MSG_ENTITY, fChanged);
/* the generic client attributes */ /* the generic client attributes */
base_player::SendEntity(ePEnt, fChanged); NSClientPlayer::SendEntity(ePEnt, fChanged);
return (1); return (1);
} }
#endif #endif

View file

@ -72,7 +72,7 @@ vector Weapons_GetCameraPos(player pl);
void Weapons_ViewAnimation(player pl, int); void Weapons_ViewAnimation(player pl, int);
void Weapons_ViewPunchAngle(player pl, vector); void Weapons_ViewPunchAngle(player pl, vector);
int Weapons_IsPresent(player, int); int Weapons_IsPresent(player, int);
void Weapons_UpdateAmmo(base_player, int, int, int); void Weapons_UpdateAmmo(NSClientPlayer, int, int, int);
int Weapons_GetAnimation(player pl); int Weapons_GetAnimation(player pl);
void Weapons_EnableModel(void); void Weapons_EnableModel(void);
void Weapons_DisableModel(void); void Weapons_DisableModel(void);

View file

@ -436,7 +436,7 @@ Sets .a_ammoX fields and clamps them so they can be networked as a single byte.
================= =================
*/ */
void void
Weapons_UpdateAmmo(base_player pl, int a1, int a2, int a3) Weapons_UpdateAmmo(NSClientPlayer pl, int a1, int a2, int a3)
{ {
/* no change */ /* no change */
if (a1 == -1) if (a1 == -1)

View file

@ -207,8 +207,8 @@ bot::CheckRoute(void)
/* we're inside the radius */ /* we're inside the radius */
if (flDist <= flRadius) { if (flDist <= flRadius) {
dprint(sprintf("^2bot::^3CheckRoute^7: " \ NSLog("^2bot::^3CheckRoute^7: " \
"%s reached node\n", this.targetname)); "%s reached node\n", this.targetname);
m_iCurNode--; m_iCurNode--;
/* if we're inside an actual node (not a virtual one */ /* if we're inside an actual node (not a virtual one */
@ -314,8 +314,8 @@ bot::RunAI(void)
if (!m_iNodes && autocvar_bot_aimless == 0) { if (!m_iNodes && autocvar_bot_aimless == 0) {
CreateObjective(); CreateObjective();
dprint(sprintf("bot::RunAI: %s is calculating first bot route\n", NSLog("bot::RunAI: %s is calculating first bot route",
this.netname)); this.netname);
/* our route probably has not been processed yet */ /* our route probably has not been processed yet */
if (!m_iNodes) { if (!m_iNodes) {

View file

@ -51,7 +51,7 @@ DetailTex_Parse(string maptex, string detailtex, float xscale, float yscale)
xscale *= autocvar(r_detailtextures_xscale, 1.0, "X scale multiplier for detail tex"); xscale *= autocvar(r_detailtextures_xscale, 1.0, "X scale multiplier for detail tex");
yscale *= autocvar(r_detailtextures_yscale, 1.0, "Y scale multiplier for detail tex"); yscale *= autocvar(r_detailtextures_yscale, 1.0, "Y scale multiplier for detail tex");
dprint(sprintf("DETAIL: %s %s %f %f\n", maptex, detailtex, xscale, yscale)); NSLog("DETAIL: %s %s %f %f", maptex, detailtex, xscale, yscale);
#if 1 #if 1
shaderforname(strcat(maptex, "_detail"), sprintf(g_detail_shader, detailtex, xscale, yscale)); shaderforname(strcat(maptex, "_detail"), sprintf(g_detail_shader, detailtex, xscale, yscale));

View file

@ -318,8 +318,8 @@ EFX_UpdateListener(void)
} }
g_flEFXTime += clframetime; g_flEFXTime += clframetime;
#else #else
dprint(sprintf("EFX_UpdateListener: Changed style to %s (%i)\n", NSLog("EFX_UpdateListener: Changed style to %s (%i)",
g_efx_name[g_iEFX], g_iEFX)); g_efx_name[g_iEFX], g_iEFX);
old_dsp = g_iEFX; old_dsp = g_iEFX;
setup_reverb(12, &g_efx[g_iEFX], sizeof(reverbinfo_t)); setup_reverb(12, &g_efx[g_iEFX], sizeof(reverbinfo_t));

View file

@ -147,8 +147,8 @@ void
CSQC_UpdateView(float w, float h, float focus) CSQC_UpdateView(float w, float h, float focus)
{ {
player pl = __NULL__; player pl = __NULL__;
base_client cl = __NULL__; NSClient cl = __NULL__;
spectator spec; NSClientSpectator spec;
int s; int s;
entity c; entity c;
@ -208,14 +208,14 @@ CSQC_UpdateView(float w, float h, float focus)
pSeat->m_ePlayer = self = findfloat(world, entnum, player_localentnum); pSeat->m_ePlayer = self = findfloat(world, entnum, player_localentnum);
pl = (player)self; pl = (player)self;
cl = (base_client)self; cl = (NSClient)self;
/* player slot not present */ /* player slot not present */
if (!self) { if (!self) {
continue; continue;
} }
/* this needs to be moved into a base_client method */ /* this needs to be moved into a NSClient method */
#if 1 #if 1
cl.PreFrame(); cl.PreFrame();
@ -259,7 +259,7 @@ CSQC_UpdateView(float w, float h, float focus)
pl.viewzoom = oldzoom; pl.viewzoom = oldzoom;
} else if (Client_IsSpectator(pl)) { } else if (Client_IsSpectator(pl)) {
spec = (spectator)self; spec = (NSClientSpectator)self;
if (spec.spec_mode == SPECMODE_FIRSTPERSON || spec.spec_mode == SPECMODE_THIRDPERSON) { if (spec.spec_mode == SPECMODE_FIRSTPERSON || spec.spec_mode == SPECMODE_THIRDPERSON) {
c = findfloat(world, ::entnum, spec.spec_ent); c = findfloat(world, ::entnum, spec.spec_ent);
@ -277,7 +277,7 @@ CSQC_UpdateView(float w, float h, float focus)
#endif #endif
addentities(MASK_ENGINE); addentities(MASK_ENGINE);
/* ideally move this into a base_player method */ /* ideally move this into a NSClientPlayer method */
#if 1 #if 1
if (pSeat->m_flCameraTime > time || pSeat->m_flCameraTime == -1) { if (pSeat->m_flCameraTime > time || pSeat->m_flCameraTime == -1) {
view_angles = pSeat->m_vecCameraAngle; view_angles = pSeat->m_vecCameraAngle;
@ -307,7 +307,7 @@ CSQC_UpdateView(float w, float h, float focus)
Shake_Update(pl); Shake_Update(pl);
setproperty(VF_ANGLES, view_angles + pl.punchangle); setproperty(VF_ANGLES, view_angles + pl.punchangle);
} else if (Client_IsSpectator(pl)) { } else if (Client_IsSpectator(pl)) {
spec = (spectator)self; spec = (NSClientSpectator)self;
switch (spec.spec_mode) { switch (spec.spec_mode) {
case SPECMODE_THIRDPERSON: case SPECMODE_THIRDPERSON:
makevectors(view_angles); makevectors(view_angles);
@ -364,7 +364,7 @@ CSQC_UpdateView(float w, float h, float focus)
View_DrawViewModel(); View_DrawViewModel();
} else { } else {
if (Client_IsSpectator(pl)) { if (Client_IsSpectator(pl)) {
spec = (spectator)self; spec = (NSClientSpectator)self;
/* 0 means world */ /* 0 means world */
if (spec.spec_ent) { if (spec.spec_ent) {
@ -437,7 +437,7 @@ CSQC_UpdateView(float w, float h, float focus)
} }
} }
/* move this into base_client methods */ /* move this into NSClient methods */
#if 1 #if 1
cl.PostFrame(); cl.PostFrame();
#endif #endif
@ -527,7 +527,7 @@ CSQC_Input_Frame(void)
me = pSeat->m_ePlayer; me = pSeat->m_ePlayer;
if (me.classname == "player" || me.classname == "spectator") { if (me.classname == "player" || me.classname == "spectator") {
base_client pl = (base_client)me; NSClient pl = (NSClient)me;
pl.ClientInputFrame(); pl.ClientInputFrame();
} }
} }

View file

@ -48,13 +48,13 @@ player::predraw(void)
/* make sure we're enabling shadow rendering on us */ /* make sure we're enabling shadow rendering on us */
effects &= ~EF_NOSHADOW; effects &= ~EF_NOSHADOW;
base_client cl = (base_client)pSeat->m_ePlayer; NSClient cl = (NSClient)pSeat->m_ePlayer;
RenderFire(); RenderFire();
/* it's either us or us spectating */ /* it's either us or us spectating */
if (Client_IsSpectator(cl)) { if (Client_IsSpectator(cl)) {
spectator spec = (spectator)pSeat->m_ePlayer; NSClientSpectator spec = (NSClientSpectator)pSeat->m_ePlayer;
if (entnum == spec.spec_ent && spec.spec_mode == SPECMODE_FIRSTPERSON) { if (entnum == spec.spec_ent && spec.spec_mode == SPECMODE_FIRSTPERSON) {
this_us = 1; this_us = 1;
} }

View file

@ -102,7 +102,7 @@ Propagate our pmove state to whatever the current frame before its stomped on
================= =================
*/ */
void void
Predict_SpectatorPreFrame(spectator pl) Predict_SpectatorPreFrame(NSClientSpectator pl)
{ {
} }
@ -116,6 +116,6 @@ Rewind our pmove state back to before we started predicting.
================= =================
*/ */
void void
Predict_SpectatorPostFrame(spectator pl) Predict_SpectatorPostFrame(NSClientSpectator pl)
{ {
} }

View file

@ -1,17 +1,17 @@
/* Returns if the specified client is a spectator, doesn't matter if real or fake */ /* Returns if the specified client is a NSClientSpectator, doesn't matter if real or fake */
float Client_IsSpectator(base_client); float Client_IsSpectator(NSClient);
/* Returns if we're a permanent spectator, USE THIS if you want to access spectator class attributes */ /* Returns if we're a permanent NSClientSpectator, USE THIS if you want to access NSClientSpectator class attributes */
float Client_IsRealSpectator(base_client cl); float Client_IsRealSpectator(NSClient cl);
/* Returns if we're a fake spectator, in case you need to be certain */ /* Returns if we're a fake NSClientSpectator, in case you need to be certain */
float Client_IsFakeSpectator(base_client cl); float Client_IsFakeSpectator(NSClient cl);
/* Return if the specified client is dead. If they're a spectator they're always alive. */ /* Return if the specified client is dead. If they're a NSClientSpectator they're always alive. */
float Client_IsDead(base_client); float Client_IsDead(NSClient);
/* Returns if the specified client is a playable client class */ /* Returns if the specified client is a playable client class */
float Client_IsPlayer(base_client cl); float Client_IsPlayer(NSClient cl);
/* Are we in an intermission? (Match ending screen) */ /* Are we in an intermission? (Match ending screen) */
float Client_InIntermission(void); float Client_InIntermission(void);

View file

@ -1,6 +1,6 @@
float float
Client_IsSpectator(base_client cl) Client_IsSpectator(NSClient cl)
{ {
if (cl.IsRealSpectator() || cl.IsFakeSpectator()) if (cl.IsRealSpectator() || cl.IsFakeSpectator())
return true; return true;
@ -9,25 +9,25 @@ Client_IsSpectator(base_client cl)
} }
float float
Client_IsRealSpectator(base_client cl) Client_IsRealSpectator(NSClient cl)
{ {
return cl.IsRealSpectator(); return cl.IsRealSpectator();
} }
float float
Client_IsFakeSpectator(base_client cl) Client_IsFakeSpectator(NSClient cl)
{ {
return cl.IsFakeSpectator(); return cl.IsFakeSpectator();
} }
float float
Client_IsDead(base_client cl) Client_IsDead(NSClient cl)
{ {
return cl.IsDead(); return cl.IsDead();
} }
float float
Client_IsPlayer(base_client cl) Client_IsPlayer(NSClient cl)
{ {
return cl.IsPlayer(); return cl.IsPlayer();
} }

View file

@ -130,11 +130,11 @@ View_DrawViewModel(void)
entity m_eMuzzleflashL = pSeat->m_eMuzzleflashL; entity m_eMuzzleflashL = pSeat->m_eMuzzleflashL;
player pl = __NULL__; player pl = __NULL__;
base_client cl = (base_client)pSeat->m_ePlayer; NSClient cl = (NSClient)pSeat->m_ePlayer;
/* it's either us or us spectating */ /* it's either us or us spectating */
if (Client_IsSpectator(cl)) { if (Client_IsSpectator(cl)) {
spectator spec = (spectator)self; NSClientSpectator spec = (NSClientSpectator)self;
pl = (player)findfloat(world, ::entnum, spec.spec_ent); pl = (player)findfloat(world, ::entnum, spec.spec_ent);
if (spec.spec_mode != SPECMODE_FIRSTPERSON) if (spec.spec_mode != SPECMODE_FIRSTPERSON)

View file

@ -50,6 +50,7 @@ server/func_rotating.qc
server/func_rot_button.qc server/func_rot_button.qc
server/func_physbox.qc server/func_physbox.qc
server/func_plat.qc server/func_plat.qc
server/func_platrot.qc
server/func_pendulum.qc server/func_pendulum.qc
server/func_vehicle.qc server/func_vehicle.qc
server/func_vehiclecontrols.qc server/func_vehiclecontrols.qc

View file

@ -91,22 +91,22 @@ env_render::Trigger(entity act, int state)
(e = find(e, ::targetname, target));) { (e = find(e, ::targetname, target));) {
NSRenderableEntity trigger = (NSRenderableEntity)e; NSRenderableEntity trigger = (NSRenderableEntity)e;
dprint(sprintf("^2env_render::^3Trigger^7: with spawnflags %d\n", spawnflags)); NSLog("^2env_render::^3Trigger^7: with spawnflags %d", spawnflags);
dprint(sprintf("\tTarget: %s\n", target)); NSLog("\tTarget: %s", target);
if (!HasSpawnFlags(SF_NORENDERMODE)) { if (!HasSpawnFlags(SF_NORENDERMODE)) {
dprint(sprintf("\tMode change from %d to %d\n", trigger.m_iRenderMode, m_iRenderMode)); NSLog("\tMode change from %d to %d", trigger.m_iRenderMode, m_iRenderMode);
trigger.SetRenderMode(m_iRenderMode); trigger.SetRenderMode(m_iRenderMode);
} }
if (!HasSpawnFlags(SF_NORENDERCOLOR)) { if (!HasSpawnFlags(SF_NORENDERCOLOR)) {
dprint(sprintf("\tColor change from %v to %v\n", trigger.m_vecRenderColor, m_vecRenderColor)); NSLog("\tColor change from %v to %v", trigger.m_vecRenderColor, m_vecRenderColor);
trigger.SetRenderColor(m_vecRenderColor); trigger.SetRenderColor(m_vecRenderColor);
} }
if (!HasSpawnFlags(SF_NORENDERAMT)) { if (!HasSpawnFlags(SF_NORENDERAMT)) {
dprint(sprintf("\tAmt change from %d to %d\n", trigger.m_flRenderAmt, m_flRenderAmt)); NSLog("\tAmt change from %d to %d", trigger.m_flRenderAmt, m_flRenderAmt);
trigger.SetRenderAmt(m_flRenderAmt); trigger.SetRenderAmt(m_flRenderAmt);
} }
if (!HasSpawnFlags(SF_NORENDERFX)) { if (!HasSpawnFlags(SF_NORENDERFX)) {
dprint(sprintf("\tFX change from %d to %d\n", trigger.m_iRenderFX, m_iRenderFX)); NSLog("\tFX change from %d to %d", trigger.m_iRenderFX, m_iRenderFX);
trigger.SetRenderFX(m_iRenderFX); trigger.SetRenderFX(m_iRenderFX);
} }
} }

View file

@ -349,7 +349,7 @@ func_door_rotating::RotToDest(vector vDestAngle, void(void) func)
float flTravelLength, flTravelTime; float flTravelLength, flTravelTime;
if (!m_flSpeed) { if (!m_flSpeed) {
dprint(sprintf("^1func_door_rotating::^3RotToDest^7: No speed defined for %s!", targetname)); NSLog("^1func_door_rotating::^3RotToDest^7: No speed defined for %s!", targetname);
func_door_rotating::Respawn(); func_door_rotating::Respawn();
return; return;
} }

View file

@ -90,7 +90,7 @@ func_guntarget::Move(void)
node = (path_corner)find(world, ::targetname, target); node = (path_corner)find(world, ::targetname, target);
if (!node) { if (!node) {
dprint(sprintf("^1func_guntarget::^3Move^7: Path node for %s not found!\n", targetname)); NSLog("^1func_guntarget::^3Move^7: Path node for %s not found!", targetname);
return; return;
} }
@ -115,7 +115,7 @@ func_guntarget::NextPath(void)
{ {
path_corner node; path_corner node;
dprint(sprintf("^2func_guntarget::^3NextPath^7: Talking to current target %s... ", target)); NSLog("^2func_guntarget::^3NextPath^7: Talking to current target %s... ", target);
node = (path_corner)find(world, ::targetname, target); node = (path_corner)find(world, ::targetname, target);
if (!node) { if (!node) {

View file

@ -0,0 +1,241 @@
/*
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*QUAKED func_platrot (0 .5 .8) ?
A vertically moving platform that rotates.
-------- KEYS --------
"targetname" : Name
"noise1" : Sound when moving
"noise2" : Sound when stopped
"speed" : Speed of rotation in u/s
"height" : Vertical travel distance
"rotation" : Rotation amount, in degrees
-------- NOTES --------
-------- HISTORY --------
This entity was introduced in Half-Life (1998).
*/
enumflags
{
FNCPLAT_TRIGGER,
};
enum
{
PLATSTATE_RAISED,
PLATSTATE_LOWERED,
PLATSTATE_UP,
PLATSTATE_DOWN
};
class func_platrot:NSRenderableEntity
{
int m_iState;
float m_flSpeed;
float m_flHeight;
string m_strNoise1;
string m_strNoise2;
float m_flRotation;
void(void) func_platrot;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) ArrivedUp;
virtual void(void) ArrivedDown;
virtual void(vector, vector, void(void)) Move;
virtual void(void) MoveToggle;
virtual void(void) Respawn;
virtual void(entity) Touch;
virtual void(string, string) SpawnKey;
};
void
func_platrot::Save(float handle)
{
SaveInt(handle, "state", m_iState);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "height", m_flHeight);
SaveString(handle, "noise1", m_strNoise1);
SaveString(handle, "noise2", m_strNoise2);
SaveFloat(handle, "rotation", m_flRotation);
super::Save(handle);
}
void
func_platrot::Restore(string strKey, string strValue)
{
switch (strKey) {
case "state":
m_iState = ReadInt(strValue);
break;
case "spped":
m_flSpeed = ReadFloat(strValue);
break;
case "height":
m_flHeight = ReadFloat(strValue);
break;
case "noise1":
m_strNoise1 = ReadString(strValue);
break;
case "noise2":
m_strNoise2 = ReadString(strValue);
break;
case "rotation":
m_flRotation = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
func_platrot::ArrivedUp(void)
{
avelocity = velocity = [0,0,0];
m_iState = PLATSTATE_RAISED;
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
if (m_strNoise2)
sound(this, CHAN_WEAPON, m_strNoise2, 1.0f, ATTN_NORM);
}
void
func_platrot::ArrivedDown(void)
{
avelocity = velocity = [0,0,0];
m_iState = PLATSTATE_LOWERED;
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
if (m_strNoise2)
sound(this, CHAN_WEAPON, m_strNoise2, 1.0f, ATTN_NORM);
}
void
func_platrot::Move(vector vecDest, vector vecADest, void() vFunc)
{
vector vecDifference, vecADifference;
float flTravel, fTravelTime;
m_iState = PLATSTATE_DOWN;
vecDifference = (vecDest - origin);
vecADifference = vecADest - angles;
flTravel = vlen(vecDifference);
fTravelTime = (flTravel / m_flSpeed);
think = vFunc;
if (fTravelTime < 0.1) {
velocity = [0,0,0];
nextthink = ltime + 0.1f;
return;
}
avelocity = (vecADifference * (1.0f / fTravelTime));
velocity = (vecDifference * (1.0f / fTravelTime));
nextthink = (ltime + fTravelTime);
if (m_strNoise1)
sound(this, CHAN_VOICE, m_strNoise1, 1.0f, ATTN_NORM);
}
void
func_platrot::MoveToggle(void)
{
if (m_iState == PLATSTATE_RAISED) {
Move(GetSpawnOrigin() - [0,0,m_flHeight], GetSpawnAngles() + [0, m_flRotation, 0], ArrivedDown);
} else if (m_iState == PLATSTATE_LOWERED) {
Move(GetSpawnOrigin(), GetSpawnAngles(), ArrivedUp);
}
}
void
func_platrot::Trigger(entity act, int state)
{
if (HasSpawnFlags(FNCPLAT_TRIGGER))
return;
switch (state) {
case TRIG_OFF:
Move(GetSpawnOrigin() - [0,0,m_flHeight], GetSpawnAngles() + [0, m_flRotation, 0], ArrivedDown);
break;
case TRIG_ON:
Move(GetSpawnOrigin(), GetSpawnAngles(), ArrivedUp);
break;
default:
MoveToggle();
}
}
void
func_platrot::Touch(entity eToucher)
{
if (eToucher.movetype != MOVETYPE_WALK) {
return;
}
MoveToggle();
}
void
func_platrot::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
m_iState = PLATSTATE_RAISED;
think = __NULL__;
nextthink = 0.0f;
}
void
func_platrot::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "height":
m_flHeight = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "noise1":
m_strNoise1 = strValue;
break;
case "noise2":
m_strNoise2 = strValue;
break;
case "rotation":
m_flRotation = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_platrot::func_platrot(void)
{
m_flSpeed = 100.0f;
super::NSRenderableEntity();
}

View file

@ -133,7 +133,7 @@ func_recharge::OnPlayerUse(void)
return; return;
} }
base_player pl = (base_player)eActivator; NSClientPlayer pl = (NSClientPlayer)eActivator;
if (pl.armor >= 100) { if (pl.armor >= 100) {
eActivator.flags &= ~FL_USE_RELEASED; eActivator.flags &= ~FL_USE_RELEASED;
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM); sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);

View file

@ -213,7 +213,7 @@ void
func_tank::customphysics(void) func_tank::customphysics(void)
{ {
if (m_eDriver && m_eDriver.health <= 0) if (m_eDriver && m_eDriver.health <= 0)
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
if (m_eDriver) { if (m_eDriver) {
vector endorg; vector endorg;
@ -223,7 +223,7 @@ func_tank::customphysics(void)
PlayerUpdateFlags(); PlayerUpdateFlags();
if (vlen(m_eDriver.origin - origin) > 128) if (vlen(m_eDriver.origin - origin) > 128)
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
} }
} }
@ -273,7 +273,7 @@ func_tank::Respawn(void)
SetAngles(GetSpawnAngles()); SetAngles(GetSpawnAngles());
if (m_eDriver) if (m_eDriver)
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
} }
void void

View file

@ -54,9 +54,9 @@ func_tankcontrols::OnPlayerUse(void)
if (tank) { if (tank) {
if (!tank.m_eDriver) if (!tank.m_eDriver)
tank.PlayerEnter((base_player)eActivator); tank.PlayerEnter((NSClientPlayer)eActivator);
else if (tank.m_eDriver == eActivator) else if (tank.m_eDriver == eActivator)
tank.PlayerLeave((base_player)eActivator); tank.PlayerLeave((NSClientPlayer)eActivator);
} }
} }

View file

@ -313,7 +313,7 @@ func_vehicle::customphysics(void)
{ {
/* eject the dead */ /* eject the dead */
if (m_eDriver && m_eDriver.health <= 0) { if (m_eDriver && m_eDriver.health <= 0) {
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
} }
if (m_eDriver) { if (m_eDriver) {
@ -429,9 +429,9 @@ func_vehicle::OnPlayerUse(void)
return; return;
if (m_eDriver == eActivator) { if (m_eDriver == eActivator) {
PlayerLeave((base_player)eActivator); PlayerLeave((NSClientPlayer)eActivator);
} else if (!m_eDriver) { } else if (!m_eDriver) {
PlayerEnter((base_player)eActivator); PlayerEnter((NSClientPlayer)eActivator);
} }
} }
@ -509,7 +509,7 @@ func_vehicle::Respawn(void)
PlayerUse = OnPlayerUse; PlayerUse = OnPlayerUse;
if (m_eDriver) if (m_eDriver)
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
} }
void void

View file

@ -100,8 +100,8 @@ game_player_equip::SpawnUnit(string cname, vector org)
unit.nextthink = time; unit.nextthink = time;
unit.real_owner = this; unit.real_owner = this;
setorigin(unit, org); setorigin(unit, org);
dprint(sprintf("^2game_player_equip::^3Trigger^7: Spawning %s\n", NSLog("^2game_player_equip::^3Trigger^7: Spawning %s",
cname)); cname);
} }
void void

View file

@ -157,7 +157,7 @@ logic_auto::Processing(void)
UseOutput(this, m_strOnBackgroundMap); UseOutput(this, m_strOnBackgroundMap);
if (HasSpawnFlags(1)) { if (HasSpawnFlags(1)) {
dprint(sprintf("^2logic_auto::^3think^7: %s triggerer removed self\n", target)); NSLog("^2logic_auto::^3think^7: %s triggerer removed self", target);
remove(this); remove(this);
} }
} }

View file

@ -180,7 +180,7 @@ monstermaker::Spawner(void)
unit.think = monstermaker_spawnunit; unit.think = monstermaker_spawnunit;
unit.nextthink = time + 0.1f; unit.nextthink = time + 0.1f;
unit.real_owner = this; unit.real_owner = this;
dprint(sprintf("^2monstermaker::^3Trigger^7: Spawning %s\n", m_strMonster)); NSLog("^2monstermaker::^3Trigger^7: Spawning %s", m_strMonster);
setorigin(unit, origin); setorigin(unit, origin);
unit.angles = angles; unit.angles = angles;
m_iMonsterSpawned++; m_iMonsterSpawned++;
@ -194,7 +194,7 @@ monstermaker::Spawner(void)
unit.spawnflags |= MSF_MONSTERCLIP; unit.spawnflags |= MSF_MONSTERCLIP;
} }
} else { } else {
print(sprintf("^1monstermaker::^3Trigger^7: cannot call spawnfunction for %s\n", m_strMonster)); NSLog("^1monstermaker::^3Trigger^7: cannot call spawnfunction for %s", m_strMonster);
remove(this); remove(this);
return; return;
} }

View file

@ -195,8 +195,8 @@ multi_manager::Trigger(entity act, int state)
entity eFind = find(world, ::targetname, wow.target); entity eFind = find(world, ::targetname, wow.target);
dprint(sprintf("^2%s::^3Trigger^7: %s (%s)\n", NSLog("^2%s::^3Trigger^7: %s (%s)",
this.classname, wow.target, eFind.classname)); this.classname, wow.target, eFind.classname);
m_iValue = TRUE; m_iValue = TRUE;
UseTargets(wow.m_eActivator, TRIG_TOGGLE, 0.0f); UseTargets(wow.m_eActivator, TRIG_TOGGLE, 0.0f);

View file

@ -111,12 +111,12 @@ void
multisource::Trigger(entity act, int unused) multisource::Trigger(entity act, int unused)
{ {
if (QueryTargets() == FALSE) { if (QueryTargets() == FALSE) {
dprint(sprintf("[^1MULTISOURCE^7] %s is inactive.\n", targetname)); NSLog("[^1MULTISOURCE^7] %s is inactive.", targetname);
m_iValue = FALSE; m_iValue = FALSE;
return; return;
} }
dprint(sprintf("[^1MULTISOURCE^7] %s is now active.\n", targetname)); NSLog("[^1MULTISOURCE^7] %s is now active.", targetname);
m_iValue = TRUE; m_iValue = TRUE;
UseTargets(act, TRIG_TOGGLE, m_flDelay); UseTargets(act, TRIG_TOGGLE, m_flDelay);
} }

View file

@ -34,13 +34,13 @@ class player_weaponstrip:NSPointTrigger
void void
player_weaponstrip::Trigger(entity act, int unused) player_weaponstrip::Trigger(entity act, int unused)
{ {
base_player pl; NSClientPlayer pl;
if (!(act.flags & FL_CLIENT)) { if (!(act.flags & FL_CLIENT)) {
return; return;
} }
pl = (base_player)act; pl = (NSClientPlayer)act;
for (int i = 1; i < Weapon_GetCount(); i++) { for (int i = 1; i < Weapon_GetCount(); i++) {
pl.g_items &= ~Weapon_GetBitID(i); pl.g_items &= ~Weapon_GetBitID(i);

View file

@ -79,7 +79,7 @@ prop_door_rotating::Turn(vector vecDest, void(void) vFunc)
float flTravelLength, flTravelTime; float flTravelLength, flTravelTime;
if (!m_flSpeed) { if (!m_flSpeed) {
dprint(sprintf("^1prop_door_rotating::^3RotToDest^7: No speed defined for %s!", targetname)); NSLog("^1prop_door_rotating::^3RotToDest^7: No speed defined for %s!", targetname);
prop_door_rotating::Respawn(); prop_door_rotating::Respawn();
return; return;
} }

View file

@ -116,7 +116,7 @@ scripted_sentence::Trigger(entity act, int unused)
return; return;
} }
dprint(sprintf("^2scripted_sentence::^3Trigger^7: %s on %s\n", m_strSentence, m_strSpeaker)); NSLog("^2scripted_sentence::^3Trigger^7: %s on %s", m_strSentence, m_strSpeaker);
NSTalkMonster npc = (NSTalkMonster)spe; NSTalkMonster npc = (NSTalkMonster)spe;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);

View file

@ -170,9 +170,9 @@ scripted_sequence::RunOnEntity(entity targ)
if (!HasSpawnFlags(SSFL_REPEATABLE)) if (!HasSpawnFlags(SSFL_REPEATABLE))
m_iEnabled = FALSE; m_iEnabled = FALSE;
dprint(sprintf("\tName: %s\n", targetname)); NSLog("\tName: %s", targetname);
dprint(sprintf("\tTarget: %s\n", m_strMonster)); NSLog("\tTarget: %s", m_strMonster);
dprint(sprintf("\tStarted: %f\n", time)); NSLog("\tStarted: %f", time);
/* if we're told an anim, we better have it... or else. */ /* if we're told an anim, we better have it... or else. */
if (m_strActionAnim) { if (m_strActionAnim) {
@ -185,7 +185,7 @@ scripted_sequence::RunOnEntity(entity targ)
/* entity to trigger after sequence ends */ /* entity to trigger after sequence ends */
if (target) { if (target) {
dprint(sprintf("\tTrigger when finished: %s\n", target)); NSLog("\tTrigger when finished: %s", target);
f.m_strRouteEnded = target; f.m_strRouteEnded = target;
f.m_ssLast = this; f.m_ssLast = this;
m_iValue = FALSE; /* will be marked as used once triggered */ m_iValue = FALSE; /* will be marked as used once triggered */
@ -228,20 +228,20 @@ scripted_sequence::RunOnEntity(entity targ)
if (m_strActionAnim) { if (m_strActionAnim) {
duration = frameduration(f.modelindex, f.m_flSequenceEnd); duration = frameduration(f.modelindex, f.m_flSequenceEnd);
f.nextthink = time + duration; f.nextthink = time + duration;
dprint(sprintf( NSLog(
"\tAnimation: %s Duration: %f seconds (modelindex %d, frame %d)\n", "\tAnimation: %s Duration: %f seconds (modelindex %d, frame %d)\n",
m_strActionAnim, m_strActionAnim,
duration, duration,
f.modelindex, f.modelindex,
f.m_flSequenceEnd f.m_flSequenceEnd
)); );
} else { } else {
f.nextthink = time; f.nextthink = time;
dprint(sprintf( NSLog(
"\t^1WARNING: %s skipping animation on script type %i\n", "\t^1WARNING: %s skipping animation on script type %i\n",
f.targetname, f.targetname,
m_iMove m_iMove
)); );
} }
f.m_iSequenceState = SEQUENCESTATE_ENDING; f.m_iSequenceState = SEQUENCESTATE_ENDING;
@ -251,7 +251,7 @@ scripted_sequence::RunOnEntity(entity targ)
else else
f.think = NSMonster::FreeStateMoved; f.think = NSMonster::FreeStateMoved;
dprint(sprintf("\tEnding: %f\n", f.nextthink)); NSLog("\tEnding: %f", f.nextthink);
/* make sure we're forgetting about enemies and attack states in sequence */ /* make sure we're forgetting about enemies and attack states in sequence */
f.m_eEnemy = __NULL__; f.m_eEnemy = __NULL__;
@ -264,7 +264,7 @@ scripted_sequence::Trigger(entity act, int unused)
{ {
NSMonster f; NSMonster f;
dprint(sprintf("^2scripted_sequence::^3Trigger^7: with spawnflags %d\n", spawnflags)); NSLog("^2scripted_sequence::^3Trigger^7: with spawnflags %d", spawnflags);
f = (NSMonster)find(world, ::targetname, m_strMonster); f = (NSMonster)find(world, ::targetname, m_strMonster);
/* target doesn't exist/hasn't spawned */ /* target doesn't exist/hasn't spawned */
@ -291,7 +291,7 @@ scripted_sequence::InitIdle(void)
{ {
NSMonster f; NSMonster f;
dprint(sprintf("^2scripted_sequence::^3InitIdle^7: with spawnflags %d\n", spawnflags)); NSLog("^2scripted_sequence::^3InitIdle^7: with spawnflags %d", spawnflags);
f = (NSMonster)find(world, ::targetname, m_strMonster); f = (NSMonster)find(world, ::targetname, m_strMonster);
/* target doesn't exist/hasn't spawned */ /* target doesn't exist/hasn't spawned */
@ -307,7 +307,7 @@ scripted_sequence::InitIdle(void)
/* cancel out. this trigger is broken. */ /* cancel out. this trigger is broken. */
if (!f) { if (!f) {
dprint(sprintf("^1scripted_sequence::^3InitIdle^7: Unknown target %s\n", m_strMonster)); NSLog("^1scripted_sequence::^3InitIdle^7: Unknown target %s", m_strMonster);
return; return;
} }
} }

View file

@ -73,8 +73,8 @@ target_cdaudio::Touch(entity eToucher)
return; return;
} }
dprint(sprintf("^2target_cdaudio::^3Trigger^7: CD Track %i requested\n", NSLog("^2target_cdaudio::^3Trigger^7: CD Track %i requested",
m_iCDTrack)); m_iCDTrack);
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_MUSICTRACK); WriteByte(MSG_MULTICAST, EV_MUSICTRACK);

View file

@ -89,7 +89,7 @@ trigger_auto::Processing(void)
UseTargets(this, m_iTriggerState, m_flDelay); UseTargets(this, m_iTriggerState, m_flDelay);
if (HasSpawnFlags(1)) { if (HasSpawnFlags(1)) {
dprint(sprintf("^2trigger_auto::^3think^7: %s triggerer removed self\n", target)); NSLog("^2trigger_auto::^3think^7: %s triggerer removed self", target);
remove(this); remove(this);
} }
} }

View file

@ -70,8 +70,8 @@ trigger_autosave::Touch(entity eToucher)
msg_entity = this; msg_entity = this;
multicast(origin, MULTICAST_ALL); multicast(origin, MULTICAST_ALL);
dprint(sprintf("^2trigger_autosave::^3Touch^7: %s called autosave\n", NSLog("^2trigger_autosave::^3Touch^7: %s called autosave",
eToucher.netname)); eToucher.netname);
localcmd("save autosave\n"); localcmd("save autosave\n");

View file

@ -65,8 +65,8 @@ trigger_cdaudio::Trigger(entity act, int unused)
return; return;
} }
dprint(sprintf("^2trigger_cdaudio::^3Trigger^7: CD Track %i requested\n", NSLog("^2trigger_cdaudio::^3Trigger^7: CD Track %i requested",
m_iCDTrack)); m_iCDTrack);
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_MUSICTRACK); WriteByte(MSG_MULTICAST, EV_MUSICTRACK);

View file

@ -153,8 +153,8 @@ trigger_changelevel::Change(void)
/* standard level change */ /* standard level change */
if (!m_strLandmark) { if (!m_strLandmark) {
dprint(sprintf("^2trigger_changelevel::^3Change^7: Change to `%s`\n", NSLog("^2trigger_changelevel::^3Change^7: Change to `%s`",
m_strMap)); m_strMap);
parm_string = m_strChangeTarget; parm_string = m_strChangeTarget;
changelevel(m_strMap); changelevel(m_strMap);
return; return;
@ -185,7 +185,7 @@ trigger_changelevel::Change(void)
info_landmark lm = (info_landmark)e; info_landmark lm = (info_landmark)e;
/* found it */ /* found it */
if (lm.targetname == m_strLandmark) { if (lm.targetname == m_strLandmark) {
dprint(sprintf("^2trigger_changelevel::^3Change^7: Found landmark for %s\n", m_strLandmark)); NSLog("^2trigger_changelevel::^3Change^7: Found landmark for %s", m_strLandmark);
g_landmarkpos = m_activator.origin - lm.origin; g_landmarkpos = m_activator.origin - lm.origin;
changelevel(m_strMap, m_strLandmark); changelevel(m_strMap, m_strLandmark);
break; break;
@ -285,7 +285,7 @@ Landmark_GetSpot(void)
info_landmark lm = (info_landmark)e; info_landmark lm = (info_landmark)e;
/* found it */ /* found it */
if (lm.targetname == startspot) { if (lm.targetname == startspot) {
dprint(sprintf("^3Landmark_GetSpot^7: Found landmark for %s\n", startspot)); NSLog("^3Landmark_GetSpot^7: Found landmark for %s", startspot);
return lm.origin + g_landmarkpos; return lm.origin + g_landmarkpos;
} }
} }

View file

@ -204,8 +204,8 @@ trigger_hurt::Touch(entity eToucher)
Damage_Apply(eToucher, this, m_iDamage, 0, type); Damage_Apply(eToucher, this, m_iDamage, 0, type);
dprint(sprintf("^2trigger_hurt::^3Touch^7: Hurting '%s' with %i\n", NSLog("^2trigger_hurt::^3Touch^7: Hurting '%s' with %i",
eToucher.netname, m_iDamage)); eToucher.netname, m_iDamage);
/* shut it down if used once */ /* shut it down if used once */
if (HasSpawnFlags(SF_HURT_ONCE)) { if (HasSpawnFlags(SF_HURT_ONCE)) {

View file

@ -112,7 +112,7 @@ trigger_look::Touch(entity eToucher)
/* find the looktarget */ /* find the looktarget */
lt = find(world, ::targetname, m_strLookTarget); lt = find(world, ::targetname, m_strLookTarget);
if (!lt) { if (!lt) {
dprint(sprintf("^1trigger_look:Touch^7: Invalid m_strLookTarget %s!\n", m_strLookTarget)); NSLog("^1trigger_look:Touch^7: Invalid m_strLookTarget %s!", m_strLookTarget);
remove(this); remove(this);
return; return;
} }

View file

@ -57,8 +57,8 @@ trigger_teleport::Touch(entity eToucher)
if (eTarget) { if (eTarget) {
vector endpos = eTarget.origin + [0,0,16]; vector endpos = eTarget.origin + [0,0,16];
setorigin(eToucher, endpos); setorigin(eToucher, endpos);
dprint(sprintf("^2trigger_teleport::^3Touch^7: Teleported '%s' to `%v`\n", NSLog("^2trigger_teleport::^3Touch^7: Teleported '%s' to `%v`",
eToucher.netname, endpos)); eToucher.netname, endpos);
} else { } else {
print(sprintf("^2trigger_teleport::^3Touch^7: Failed to teleport '%s'\n", print(sprintf("^2trigger_teleport::^3Touch^7: Failed to teleport '%s'\n",
eToucher.netname)); eToucher.netname));

View file

@ -105,12 +105,12 @@ NSIO::CreateOutput(string outmsg)
new_minion.m_iOldCount = new_minion.m_iCount; new_minion.m_iOldCount = new_minion.m_iCount;
/* print final debug output */ /* print final debug output */
dprint(sprintf("^2%s::CreateOutput report:\n", classname)); NSLog("^2%s::CreateOutput report:", classname);
dprint(sprintf("Target: %s\n", new_minion.m_strTarget)); NSLog("Target: %s", new_minion.m_strTarget);
dprint(sprintf("Input: %s\n", new_minion.m_strInput)); NSLog("Input: %s", new_minion.m_strInput);
dprint(sprintf("Data Message: %s\n", new_minion.m_strData)); NSLog("Data Message: %s", new_minion.m_strData);
dprint(sprintf("Delay: %f\n", new_minion.m_flDelay)); NSLog("Delay: %f", new_minion.m_flDelay);
dprint(sprintf("Uses: %i\n\n", new_minion.m_iCount)); NSLog("Uses: %i\n", new_minion.m_iCount);
} }
/* return the name that'll act as the trigger for all outputs */ /* return the name that'll act as the trigger for all outputs */
@ -315,8 +315,8 @@ NSIO::SpawnKey(string strKey, string strValue)
break; break;
#endif #endif
default: default:
dprint(sprintf("^3%s^7::SpawnKey:: Unknown key '%s' with value '%s'\n", NSLog("^3%s^7::SpawnKey:: Unknown key '%s' with value '%s'",
classname, strKey, strValue)); classname, strKey, strValue);
break; break;
} }
} }
@ -341,4 +341,4 @@ NSIO::NSIO(void)
m_strOnUser3 = CreateOutput(m_strOnUser3); m_strOnUser3 = CreateOutput(m_strOnUser3);
m_strOnUser4 = CreateOutput(m_strOnUser4); m_strOnUser4 = CreateOutput(m_strOnUser4);
#endif #endif
} }

View file

@ -158,7 +158,7 @@ NSMonster::AlertNearby(void)
if (vlen(origin - w.origin) > 512) if (vlen(origin - w.origin) > 512)
continue; continue;
//dprint(sprintf("Alert! %s get %s\n", w.classname, m_eEnemy.classname)); //NSLog("Alert! %s get %s", w.classname, m_eEnemy.classname);
NSMonster f = (NSMonster)w; NSMonster f = (NSMonster)w;
/* we shouldn't override this when they already got a target */ /* we shouldn't override this when they already got a target */
@ -310,14 +310,14 @@ NSMonster::AttackRanged(void)
void void
NSMonster::AttackDraw(void) NSMonster::AttackDraw(void)
{ {
dprint(sprintf("^1%s::AttackDraw: Not defined!\n", classname)); NSLog("^1%s::AttackDraw: Not defined!", classname);
m_flAttackThink = time + 0.5f; m_flAttackThink = time + 0.5f;
} }
void void
NSMonster::AttackHolster(void) NSMonster::AttackHolster(void)
{ {
dprint(sprintf("^1%s::AttackHolster: Not defined!\n", classname)); NSLog("^1%s::AttackHolster: Not defined!", classname);
m_flAttackThink = time + 0.5f; m_flAttackThink = time + 0.5f;
} }
@ -398,8 +398,8 @@ NSMonster::CheckRoute(void)
flDist = floor(vlen(evenpos - origin)); flDist = floor(vlen(evenpos - origin));
if (flDist < 8) { if (flDist < 8) {
dprint(sprintf("^2NSMonster::^3CheckRoute^7: " \ NSLog("^2NSMonster::^3CheckRoute^7: " \
"%s reached node\n", this.targetname)); "%s reached node\n", this.targetname);
m_iCurNode--; m_iCurNode--;
velocity = [0,0,0]; /* clamp friction */ velocity = [0,0,0]; /* clamp friction */
@ -419,7 +419,7 @@ NSMonster::CheckRoute(void)
if (m_iCurNode < -1) { if (m_iCurNode < -1) {
ClearRoute(); ClearRoute();
dprint(sprintf("^2NSMonster::^3CheckRoute^7: %s reached end\n", this.targetname)); NSLog("^2NSMonster::^3CheckRoute^7: %s reached end", this.targetname);
/* mark that we've ended a sequence, if we're in one and que anim */ /* mark that we've ended a sequence, if we're in one and que anim */
if (m_iSequenceState == SEQUENCESTATE_ACTIVE) { if (m_iSequenceState == SEQUENCESTATE_ACTIVE) {
@ -428,12 +428,12 @@ NSMonster::CheckRoute(void)
m_iSequenceState = SEQUENCESTATE_ENDING; m_iSequenceState = SEQUENCESTATE_ENDING;
think = (m_iSequenceFlags & SSFL_NOSCRIPTMOVE) ? FreeState : FreeStateMoved; think = (m_iSequenceFlags & SSFL_NOSCRIPTMOVE) ? FreeState : FreeStateMoved;
nextthink = time + duration; nextthink = time + duration;
dprint(sprintf("^2NSMonster::^3CheckRoute^7: %s overriding anim for %f seconds (modelindex %d, frame %d)\n", this.targetname, duration, modelindex, m_flSequenceEnd)); NSLog("^2NSMonster::^3CheckRoute^7: %s overriding anim for %f seconds (modelindex %d, frame %d)", this.targetname, duration, modelindex, m_flSequenceEnd);
} else { } else {
/* we still need to trigger targets */ /* we still need to trigger targets */
think = (m_iSequenceFlags & SSFL_NOSCRIPTMOVE) ? FreeState : FreeStateMoved; think = (m_iSequenceFlags & SSFL_NOSCRIPTMOVE) ? FreeState : FreeStateMoved;
nextthink = time; nextthink = time;
dprint(sprintf("^2NSMonster::^3CheckRoute^7: %s has no anim, finished sequence.\n", this.targetname)); NSLog("^2NSMonster::^3CheckRoute^7: %s has no anim, finished sequence.", this.targetname);
} }
} }
} }

View file

@ -714,7 +714,7 @@ NSTalkMonster::ProcessWordQue(void)
SentenceSample(m_pSentenceQue[m_iSentencePos].m_strSnd); SentenceSample(m_pSentenceQue[m_iSentencePos].m_strSnd);
dprint(sprintf("^2NSEntity::^3ProcessWordQue^7: Speaking %s\n", m_pSentenceQue[m_iSentencePos].m_strSnd)); NSLog("^2NSEntity::^3ProcessWordQue^7: Speaking %s", m_pSentenceQue[m_iSentencePos].m_strSnd);
m_iSentencePos++; m_iSentencePos++;
if (m_iSentencePos == m_iSentenceCount) { if (m_iSentencePos == m_iSentenceCount) {
@ -908,14 +908,14 @@ NSTalkMonster_ParseSentence(void)
if (ent) { if (ent) {
if (ent.classname != "NSTalkMonster" && ent.classname != "ambient_generic") if (ent.classname != "NSTalkMonster" && ent.classname != "ambient_generic")
dprint(sprintf("^3 NSTalkMonster_ParseSentence ^7: Entity %d not a NSTalkMonster!\n", e)); NSLog("^3 NSTalkMonster_ParseSentence ^7: Entity %d not a NSTalkMonster!", e);
else { else {
targ = (NSTalkMonster)ent; targ = (NSTalkMonster)ent;
targ.Sentence(sentence); targ.Sentence(sentence);
dprint(sprintf("^3 NSTalkMonster_ParseSentence ^7: Entity %d saying %s\n", e, sentence)); NSLog("^3 NSTalkMonster_ParseSentence ^7: Entity %d saying %s", e, sentence);
} }
} else { } else {
dprint(sprintf("^3 NSTalkMonster_ParseSentence ^7: Entity %d not in PVS\n", e)); NSLog("^3 NSTalkMonster_ParseSentence ^7: Entity %d not in PVS", e);
} }
} }

View file

@ -19,8 +19,8 @@
void void
NSTrigger::Trigger(entity act, int state) NSTrigger::Trigger(entity act, int state)
{ {
dprint(sprintf("^2%s::^3Input^7: Triggerd by %s with no consequence\n", NSLog("^2%s::^3Input^7: Triggerd by %s with no consequence",
this.classname, act.classname)); this.classname, act.classname);
} }
void void
@ -35,8 +35,8 @@ NSTrigger::UseTargets(entity act, int state, float fDelay)
return; return;
if (fDelay > 0.0f) { if (fDelay > 0.0f) {
dprint(sprintf("^2%s::^3UseTargets^7: Triggering `%s`\n", NSLog("^2%s::^3UseTargets^7: Triggering `%s`",
this.classname, target)); this.classname, target);
NSTrigger eTimer = spawn(NSTrigger); NSTrigger eTimer = spawn(NSTrigger);
eTimer.owner = act; eTimer.owner = act;
@ -48,10 +48,10 @@ NSTrigger::UseTargets(entity act, int state, float fDelay)
for (entity f = world; (f = find(f, ::targetname, target));) { for (entity f = world; (f = find(f, ::targetname, target));) {
NSTrigger trigger = (NSTrigger)f; NSTrigger trigger = (NSTrigger)f;
dprint(sprintf("^2%s::^3UseTargets^7:" \ NSLog("^2%s::^3UseTargets^7:" \
"Triggering %s `%s` from %s\n", \ "Triggering %s `%s` from %s\n", \
this.classname, f.classname, \ this.classname, f.classname, \
trigger.targetname, act.classname)); trigger.targetname, act.classname);
if (trigger.Trigger != __NULL__) { if (trigger.Trigger != __NULL__) {
trigger.Trigger(act, state); trigger.Trigger(act, state);
@ -91,7 +91,7 @@ NSTrigger::GetMaster(void)
/* default to success */ /* default to success */
if (!m_strMaster) { if (!m_strMaster) {
/*dprint(sprintf("^2%s::^3GetMaster^7: No master, return success\n", /*NSLog("^2%s::^3GetMaster^7: No master, return success",
this.classname));*/ this.classname));*/
return (1); return (1);
} }
@ -100,17 +100,17 @@ NSTrigger::GetMaster(void)
/* we couldn't find it, so let's not even bother going further */ /* we couldn't find it, so let's not even bother going further */
if (!t) { if (!t) {
dprint(sprintf("^2%s::^3GetMaster^7: Invalid master (%s), return success\n", NSLog("^2%s::^3GetMaster^7: Invalid master (%s), return success",
this.classname, m_strMaster)); this.classname, m_strMaster);
return (1); return (1);
} }
if (t.GetValue() == 1) if (t.GetValue() == 1)
dprint(sprintf("^2%s::^3GetMaster^7: %s learns %s ^2POSITIVE\n", NSLog("^2%s::^3GetMaster^7: %s learns %s ^2POSITIVE",
this.classname, targetname, m_strMaster)); this.classname, targetname, m_strMaster);
else else
dprint(sprintf("^2%s::^3GetMaster^7: %s learns %s ^1NEGATIVE\n", NSLog("^2%s::^3GetMaster^7: %s learns %s ^1NEGATIVE",
this.classname, targetname, m_strMaster)); this.classname, targetname, m_strMaster);
return t.GetValue(); return t.GetValue();
} }

View file

@ -55,8 +55,8 @@ class NSVehicle:NSSurfacePropEntity
virtual entity(void) GetDriver; virtual entity(void) GetDriver;
virtual void(void) PlayerUpdateFlags; virtual void(void) PlayerUpdateFlags;
virtual void(void) PlayerAlign; virtual void(void) PlayerAlign;
virtual void(base_player) PlayerEnter; virtual void(NSClientPlayer) PlayerEnter;
virtual void(base_player) PlayerLeave; virtual void(NSClientPlayer) PlayerLeave;
virtual void() PlayerInput; virtual void() PlayerInput;
virtual float(void) DriverAnimation; virtual float(void) DriverAnimation;
@ -84,15 +84,3 @@ enumflags
#ifdef CLIENT #ifdef CLIENT
void basevehicle_readentity(float isnew); void basevehicle_readentity(float isnew);
#endif #endif
/* vehicle hakku */
class CBaseVehicle:NSVehicle
{
void(void) CBaseVehicle;
};
void
CBaseVehicle::CBaseVehicle(void)
{
NSVehicle::NSVehicle();
}

View file

@ -55,9 +55,9 @@ NSVehicle::DriverRelink(void)
if (!driver_entnum) if (!driver_entnum)
m_eDriver = __NULL__; m_eDriver = __NULL__;
else { else {
base_player pl; NSClientPlayer pl;
m_eDriver = findentity(world, ::entnum, driver_entnum); m_eDriver = findentity(world, ::entnum, driver_entnum);
pl = (base_player)m_eDriver; pl = (NSClientPlayer)m_eDriver;
pl.vehicle = this; pl.vehicle = this;
} }
} }
@ -354,7 +354,7 @@ NSVehicle::PlayerAlign(void)
} }
void void
NSVehicle::PlayerEnter(base_player pl) NSVehicle::PlayerEnter(NSClientPlayer pl)
{ {
vector offs; vector offs;
@ -379,7 +379,7 @@ NSVehicle::PlayerEnter(base_player pl)
} }
void void
NSVehicle::PlayerLeave(base_player pl) NSVehicle::PlayerLeave(NSClientPlayer pl)
{ {
if (!pl) if (!pl)
return; return;

View file

@ -148,8 +148,8 @@ ambient_generic::Restore(string strKey, string strValue)
void void
ambient_generic::UseNormal(entity act, int state) ambient_generic::UseNormal(entity act, int state)
{ {
dprint(sprintf("Sound once: %S Volume: %f; Radius: %d; Pitch: %d\n", \ NSLog("Sound once: %S Volume: %f; Radius: %d; Pitch: %d", \
m_strActivePath, m_flVolume, m_flRadius, m_flPitch)); m_strActivePath, m_flVolume, m_flRadius, m_flPitch);
if (substring(m_strActivePath, 0, 1) == "!") { if (substring(m_strActivePath, 0, 1) == "!") {
string seq = Sentences_GetSamples(m_strActivePath); string seq = Sentences_GetSamples(m_strActivePath);
@ -171,13 +171,13 @@ void
ambient_generic::UseLoop(entity act, int state) ambient_generic::UseLoop(entity act, int state)
{ {
if (m_bToggle == TRUE) { if (m_bToggle == TRUE) {
dprint(sprintf("^2ambient_generic::^3UseLoop^7: %s stops `%s`\n", NSLog("^2ambient_generic::^3UseLoop^7: %s stops `%s`",
target, m_strActivePath)); target, m_strActivePath);
m_strActivePath = "common/null.wav"; m_strActivePath = "common/null.wav";
} else { } else {
m_strActivePath = m_strSpawnPath; m_strActivePath = m_strSpawnPath;
dprint(sprintf("^2ambient_generic::^3UseLoop^7: %s plays `%s`\n", NSLog("^2ambient_generic::^3UseLoop^7: %s plays `%s`",
target, m_strActivePath)); target, m_strActivePath);
} }
m_bToggle = 1 - m_bToggle; m_bToggle = 1 - m_bToggle;
@ -307,7 +307,7 @@ ambient_generic::ReceiveEntity(float isnew, float flChanged)
if (flChanged & AMBIENT_ENABLED) if (flChanged & AMBIENT_ENABLED)
m_bLoops = readbyte(); m_bLoops = readbyte();
dprint(sprintf("Sound received: %S Volume: %f; Radius: %d; Pitch: %d\n", m_strActivePath, m_flVolume, m_flRadius, m_flPitch)); NSLog("Sound received: %S Volume: %f; Radius: %d; Pitch: %d", m_strActivePath, m_flVolume, m_flRadius, m_flPitch);
if (m_bLoops == true) if (m_bLoops == true)

View file

@ -297,7 +297,7 @@ func_tankmortar::PlayerInput(void)
{ {
#ifdef SERVER #ifdef SERVER
if (m_eDriver && m_eDriver.health <= 0) if (m_eDriver && m_eDriver.health <= 0)
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
#else #else
print("foooo\n"); print("foooo\n");
#endif #endif
@ -368,7 +368,7 @@ func_tankmortar::Respawn(void)
SetAngles(GetSpawnAngles()); SetAngles(GetSpawnAngles());
if (m_eDriver) if (m_eDriver)
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
} }
void void

View file

@ -548,7 +548,7 @@ prop_vehicle_driveable::RunVehiclePhysics(void)
#if SERVER #if SERVER
/* eject the dead */ /* eject the dead */
if (m_eDriver && m_eDriver.health <= 0) { if (m_eDriver && m_eDriver.health <= 0) {
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
} }
#endif #endif
@ -645,10 +645,10 @@ prop_vehicle_driveable::OnPlayerUse(void)
return; return;
if (m_eDriver == eActivator) { if (m_eDriver == eActivator) {
PlayerLeave((base_player)eActivator); PlayerLeave((NSClientPlayer)eActivator);
setorigin(eActivator, GetExitPos()); setorigin(eActivator, GetExitPos());
} else if (!m_eDriver) { } else if (!m_eDriver) {
PlayerEnter((base_player)eActivator); PlayerEnter((NSClientPlayer)eActivator);
m_vecPlayerPos = [0,0,0]; m_vecPlayerPos = [0,0,0];
} }
m_flUseTime = time + 2.0f; m_flUseTime = time + 2.0f;
@ -677,7 +677,7 @@ prop_vehicle_driveable::Respawn(void)
setsize( this, [-50,-50,0], [50,50,64]); setsize( this, [-50,-50,0], [50,50,64]);
if (m_eDriver) if (m_eDriver)
PlayerLeave((base_player)m_eDriver); PlayerLeave((NSClientPlayer)m_eDriver);
SendFlags = -1; SendFlags = -1;
} }

View file

@ -19,6 +19,14 @@
var int autocvar_menu_intro = TRUE; var int autocvar_menu_intro = TRUE;
var int autocvar__menu_singleplayer; var int autocvar__menu_singleplayer;
void
_NSLog(string msg)
{
if (cvar("g_developer"))
print(sprintf("%f %s\n", time, msg));
}
#define NSLog(x, ...) _NSLog(sprintf(x, __VA_ARGS__))
#define KEY_UNKNOWN -1 #define KEY_UNKNOWN -1
#define KEY_GAME 0 #define KEY_GAME 0
#define KEY_MENU 2 #define KEY_MENU 2

View file

@ -765,16 +765,16 @@ games_init_2(void)
games[id].steambg = 0; games[id].steambg = 0;
if (games_check_manifest(id, gamedirname) == 1) { if (games_check_manifest(id, gamedirname) == 1) {
dprint(sprintf("[MENU] Found manifest for %s\n", gamedirname)); NSLog("[MENU] Found manifest for %s", gamedirname);
games[id].info_type = GAMEINFO_MANIFEST; games[id].info_type = GAMEINFO_MANIFEST;
} else if (games_check_gtxt(id, gamedirname) == 1) { } else if (games_check_gtxt(id, gamedirname) == 1) {
dprint(sprintf("[MENU] Found gameinfo for %s\n", gamedirname)); NSLog("[MENU] Found gameinfo for %s", gamedirname);
games[id].info_type = GAMEINFO_GITXT; games[id].info_type = GAMEINFO_GITXT;
} else if (games_check_liblist(id, gamedirname) == 1) { } else if (games_check_liblist(id, gamedirname) == 1) {
dprint(sprintf("[MENU] Found liblist for %s\n", gamedirname)); NSLog("[MENU] Found liblist for %s", gamedirname);
games[id].info_type = GAMEINFO_LIBLIST; games[id].info_type = GAMEINFO_LIBLIST;
} else { } else {
dprint(sprintf("[MENU] Found nothing for %s\n", gamedirname)); NSLog("[MENU] Found nothing for %s", gamedirname);
games[id].info_type = GAMEINFO_NONE; games[id].info_type = GAMEINFO_NONE;
} }
@ -827,16 +827,16 @@ games_init(void)
#ifndef WEBMENU #ifndef WEBMENU
if (games_check_manifest(id, gamedirname) == 1) { if (games_check_manifest(id, gamedirname) == 1) {
dprint(sprintf("[MENU] Found manifest for %s\n", gamedirname)); NSLog("[MENU] Found manifest for %s", gamedirname);
games[id].info_type = GAMEINFO_MANIFEST; games[id].info_type = GAMEINFO_MANIFEST;
} else if (games_check_gtxt(id, gamedirname) == 1) { } else if (games_check_gtxt(id, gamedirname) == 1) {
dprint(sprintf("[MENU] Found gameinfo for %s\n", gamedirname)); NSLog("[MENU] Found gameinfo for %s", gamedirname);
games[id].info_type = GAMEINFO_GITXT; games[id].info_type = GAMEINFO_GITXT;
} else if (games_check_liblist(id, gamedirname) == 1) { } else if (games_check_liblist(id, gamedirname) == 1) {
dprint(sprintf("[MENU] Found liblist for %s\n", gamedirname)); NSLog("[MENU] Found liblist for %s", gamedirname);
games[id].info_type = GAMEINFO_LIBLIST; games[id].info_type = GAMEINFO_LIBLIST;
} else { } else {
dprint(sprintf("[MENU] Found nothing for %s\n", gamedirname)); NSLog("[MENU] Found nothing for %s", gamedirname);
games[id].info_type = GAMEINFO_NONE; games[id].info_type = GAMEINFO_NONE;
} }
#endif #endif

View file

@ -136,10 +136,10 @@ inet_refreshframe(void)
inet_lbServers_Game.AddEntry(gethostcachestring(srv_fldGame, i)); inet_lbServers_Game.AddEntry(gethostcachestring(srv_fldGame, i));
inet_lbServers_Players.AddEntry(players); inet_lbServers_Players.AddEntry(players);
inet_lbServers_Addresses.AddEntry(address); inet_lbServers_Addresses.AddEntry(address);
dprint(sprintf("Adding %s to the Internet server list\n", address)); NSLog("Adding %s to the Internet server list", address);
added++; added++;
} }
dprint(sprintf("Added %i Internet servers.\n", added)); NSLog("Added %i Internet servers.", added);
inet_sbServers.SetMax(added); inet_sbServers.SetMax(added);
} }

View file

@ -37,7 +37,7 @@ Master_GetTotalServers(void)
int a = gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT); int a = gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT);
if (a) { if (a) {
dprint(sprintf("Master reports a total of %i servers.\n", a)); NSLog("Master reports a total of %i servers.", a);
} }
return gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT); return gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT);
} }
@ -76,7 +76,7 @@ Master_RefreshCache(void)
int a = gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT); int a = gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT);
if (a) { if (a) {
dprint(sprintf("Master reports a total of %i servers.\n", a)); NSLog("Master reports a total of %i servers.", a);
} }
} }
@ -92,7 +92,7 @@ Master_UpdateCache(void)
int a = gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT); int a = gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT);
if (a) { if (a) {
dprint(sprintf("Master reports a total of %i servers.\n", a)); NSLog("Master reports a total of %i servers.", a);
} }
} }

View file

@ -40,7 +40,7 @@ Music_ParseTrack(string parm)
track = stof(parm); track = stof(parm);
path = Music_GetPath(track); path = Music_GetPath(track);
dprint(sprintf("^2Music_ParseTrack:^7 Single track %i from %s\n", track, path)); NSLog("^2Music_ParseTrack:^7 Single track %i from %s", track, path);
localcmd(sprintf("music %s -\n", path)); localcmd(sprintf("music %s -\n", path));
} }
@ -53,7 +53,7 @@ Music_ParseLoop(string parm)
track = stof(parm); track = stof(parm);
path = Music_GetPath(track); path = Music_GetPath(track);
dprint(sprintf("^2Music_ParseLoop:^7 Looping track %i from %s\n", track, path)); NSLog("^2Music_ParseLoop:^7 Looping track %i from %s", track, path);
localcmd(sprintf("music %s\n", path)); localcmd(sprintf("music %s\n", path));
} }

View file

@ -20,7 +20,7 @@ TCP_Connect(tcpinfo_t *in, string path)
in.m_fSocket = fopen(path, -1); in.m_fSocket = fopen(path, -1);
if (in.m_fSocket < 0) { if (in.m_fSocket < 0) {
dprint(sprintf("^1TCP_Connect^7: Unable to access %s\n", path)); print(sprintf("^1TCP_Connect^7: Unable to access %s\n", path));
} else { } else {
/* we got at least this far */ /* we got at least this far */
in.m_iState = STATE_CONNECTING; in.m_iState = STATE_CONNECTING;

View file

@ -91,7 +91,7 @@ ChatLoadFile(string filename)
c = tokenizebyseparator(g_table[i].sample, ";"); c = tokenizebyseparator(g_table[i].sample, ";");
for (int x = 0; x < c; x++) { for (int x = 0; x < c; x++) {
precache_sound(argv(x)); precache_sound(argv(x));
dprint(sprintf("[CHATSOUNDS] Caching: %s\n", argv(x))); print(sprintf("[CHATSOUNDS] Caching: %s\n", argv(x)));
} }
i++; i++;
} }

View file

@ -69,7 +69,7 @@ ClientConnect(void)
} }
if (g_ents_initialized) if (g_ents_initialized)
g_grMode.PlayerConnect((base_player)self); g_grMode.PlayerConnect((NSClientPlayer)self);
for (entity a = world; (a = find(a, ::classname, "player"));) for (entity a = world; (a = find(a, ::classname, "player"));)
playercount++; playercount++;
@ -97,7 +97,7 @@ void
ClientDisconnect(void) ClientDisconnect(void)
{ {
if (g_ents_initialized) if (g_ents_initialized)
g_grMode.PlayerDisconnect((base_player)self); g_grMode.PlayerDisconnect((NSClientPlayer)self);
/* this will hide/remove the player from other clients */ /* this will hide/remove the player from other clients */
player pl = (player)self; player pl = (player)self;
@ -116,15 +116,15 @@ void
ClientKill(void) ClientKill(void)
{ {
if (g_ents_initialized) if (g_ents_initialized)
g_grMode.PlayerKill((base_player)self); g_grMode.PlayerKill((NSClientPlayer)self);
} }
/* /*
================= =================
SpectatorThink SpectatorThink
Run every frame on every spectator. Run every frame on every NSClientSpectator.
The 'self' global refers to one of any given amount of spectators. The 'self' global refers to one of any given amount of NSClientSpectators.
================= =================
*/ */
void void
@ -133,7 +133,7 @@ SpectatorThink(void)
Game_SpectatorThink(); Game_SpectatorThink();
if (self.classname == "spectator") { if (self.classname == "spectator") {
spectator spec = (spectator)self; NSClientSpectator spec = (NSClientSpectator)self;
spec.PreFrame(); spec.PreFrame();
spec.PostFrame(); spec.PostFrame();
return; return;
@ -144,23 +144,23 @@ SpectatorThink(void)
================= =================
SpectatorConnect SpectatorConnect
Called when a spectator joins the server. Called when a NSClientSpectator joins the server.
The 'self' global is the connecting spectator in question. The 'self' global is the connecting NSClientSpectator in question.
================= =================
*/ */
void void
SpectatorConnect(void) SpectatorConnect(void)
{ {
Game_SpectatorConnect(); Game_SpectatorConnect();
spawnfunc_spectator(); spawnfunc_NSClientSpectator();
} }
/* /*
================= =================
SpectatorDisconnect SpectatorDisconnect
Called when a spectator leaves the server. Called when a NSClientSpectator leaves the server.
The 'self' global is the leaving spectator in question. 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.
================= =================
*/ */
@ -185,9 +185,9 @@ void
PutClientInServer(void) PutClientInServer(void)
{ {
if (g_ents_initialized) if (g_ents_initialized)
g_grMode.PlayerSpawn((base_player)self); g_grMode.PlayerSpawn((NSClientPlayer)self);
Plugin_PlayerEntered((base_player)self); Plugin_PlayerEntered((NSClientPlayer)self);
/* activate all game_playerspawn entities */ /* activate all game_playerspawn entities */
for (entity a = world; (a = find(a, ::targetname, "game_playerspawn"));) { for (entity a = world; (a = find(a, ::targetname, "game_playerspawn"));) {
@ -211,7 +211,7 @@ void
PlayerPreThink(void) PlayerPreThink(void)
{ {
if (self.classname == "spectator") { if (self.classname == "spectator") {
//spectator spec = (spectator)self; //NSClientSpectator spec = (NSClientSpectator)self;
//spec.PreFrame(); //spec.PreFrame();
return; return;
} }
@ -227,7 +227,7 @@ PlayerPreThink(void)
#endif #endif
if (g_ents_initialized) if (g_ents_initialized)
g_grMode.PlayerPreFrame((base_player)self); g_grMode.PlayerPreFrame((NSClientPlayer)self);
} }
/* /*
@ -259,7 +259,7 @@ PlayerPostThink(void)
if (g_ents_initialized) { if (g_ents_initialized) {
player pl = (player)self; player pl = (player)self;
g_grMode.PlayerPostFrame((base_player)self); g_grMode.PlayerPostFrame((NSClientPlayer)self);
pl.EvaluateEntity(); pl.EvaluateEntity();
} }
} }
@ -300,7 +300,7 @@ SetChangeParms(void)
print("--------- Setting Level-Change Parameters ----------\n"); print("--------- Setting Level-Change Parameters ----------\n");
if (g_ents_initialized) if (g_ents_initialized)
g_grMode.LevelChangeParms((base_player)self); g_grMode.LevelChangeParms((NSClientPlayer)self);
} }
/* /*
@ -317,7 +317,7 @@ void
SV_RunClientCommand(void) SV_RunClientCommand(void)
{ {
if (self.classname == "spectator") { if (self.classname == "spectator") {
spectator spec = (spectator)self; NSClientSpectator spec = (NSClientSpectator)self;
spec.RunClientCommand(); spec.RunClientCommand();
} }
@ -365,7 +365,7 @@ SV_ParseClientCommand(string cmd)
if (self.classname != "player") if (self.classname != "player")
break; break;
ClientKill(); ClientKill();
spawnfunc_spectator(); spawnfunc_NSClientSpectator();
break; break;
case "play": case "play":
if (self.classname != "spectator") if (self.classname != "spectator")

View file

@ -15,7 +15,7 @@
*/ */
void Footsteps_Init(void); void Footsteps_Init(void);
void Footsteps_HLBSP(base_player target); void Footsteps_HLBSP(NSClientPlayer target);
void Footsteps_VVBSP(base_player target); void Footsteps_VVBSP(NSClientPlayer target);
void Footsteps_Default(base_player target); void Footsteps_Default(NSClientPlayer target);
void Footsteps_Update(void); void Footsteps_Update(void);

View file

@ -73,7 +73,7 @@ to specify materials.
================= =================
*/ */
void void
Footsteps_HLBSP(base_player target) Footsteps_HLBSP(NSClientPlayer target)
{ {
string mat_name = ""; string mat_name = "";
string tex_name = ""; string tex_name = "";
@ -154,7 +154,7 @@ Modern BSP format which uses surfaceflags to specify materials on surfaces.
================= =================
*/ */
void void
Footsteps_VVBSP(base_player target) Footsteps_VVBSP(NSClientPlayer target)
{ {
string mat_name = ""; string mat_name = "";
@ -234,7 +234,7 @@ materials for.
================= =================
*/ */
void void
Footsteps_Default(base_player target) Footsteps_Default(NSClientPlayer target)
{ {
string mat_name = ""; string mat_name = "";
@ -262,12 +262,12 @@ Run every frame for each player, plays material based footsteps
void void
Footsteps_Update(void) Footsteps_Update(void)
{ {
base_player pl; NSClientPlayer pl;
if (self.classname != "player") if (self.classname != "player")
return; return;
pl = (base_player)self; pl = (NSClientPlayer)self;
if (pl.movetype == MOVETYPE_WALK) { if (pl.movetype == MOVETYPE_WALK) {
if ((pl.velocity[0] == 0 && pl.velocity[1] == 0) || pl.step_time > time) { if ((pl.velocity[0] == 0 && pl.velocity[1] == 0) || pl.step_time > time) {

View file

@ -26,22 +26,22 @@ class CGameRules
/* logic */ /* logic */
virtual void(void) FrameStart; virtual void(void) FrameStart;
virtual float(base_player,string) ConsoleCommand; virtual float(NSClientPlayer,string) ConsoleCommand;
/* client */ /* client */
virtual void(base_player) PlayerConnect; virtual void(NSClientPlayer) PlayerConnect;
virtual void(base_player) PlayerDisconnect; virtual void(NSClientPlayer) PlayerDisconnect;
virtual void(base_player) PlayerKill; virtual void(NSClientPlayer) PlayerKill;
virtual void(base_player) PlayerSpawn; virtual void(NSClientPlayer) PlayerSpawn;
virtual void(base_player) PlayerPreFrame; virtual void(NSClientPlayer) PlayerPreFrame;
virtual void(base_player) PlayerPostFrame; virtual void(NSClientPlayer) PlayerPostFrame;
virtual void(base_player) PlayerDeath; virtual void(NSClientPlayer) PlayerDeath;
virtual void(base_player) PlayerPain; virtual void(NSClientPlayer) PlayerPain;
virtual bool(base_player) PlayerCanAttack; virtual bool(NSClientPlayer) PlayerCanAttack;
/* level transitions */ /* level transitions */
virtual void(void) LevelNewParms; virtual void(void) LevelNewParms;
virtual void(base_player) LevelChangeParms; virtual void(NSClientPlayer) LevelChangeParms;
/* Entities/Item manipulation */ /* Entities/Item manipulation */
virtual int(int) MaxItemPerSlot; virtual int(int) MaxItemPerSlot;
@ -59,9 +59,9 @@ class CGameRules
virtual float(void) IsTeamPlay; virtual float(void) IsTeamPlay;
/* spectator */ /* spectator */
/*virtual void(base_player) SpectatorConnect; /*virtual void(NSClientPlayer) SpectatorConnect;
virtual void(base_player) SpectatorDisconnect; virtual void(NSClientPlayer) SpectatorDisconnect;
virtual void(base_player) SpectatorThink;*/ virtual void(NSClientPlayer) SpectatorThink;*/
}; };
/* our currently running mode */ /* our currently running mode */

View file

@ -30,51 +30,51 @@ CGameRules::FrameStart(void)
//print("StartFrame!\n"); //print("StartFrame!\n");
} }
float float
CGameRules::ConsoleCommand(base_player pl, string cmd) CGameRules::ConsoleCommand(NSClientPlayer pl, string cmd)
{ {
return (0); return (0);
} }
/* client */ /* client */
void void
CGameRules::PlayerConnect(base_player pl) CGameRules::PlayerConnect(NSClientPlayer pl)
{ {
//print("ClientConnect!\n"); //print("ClientConnect!\n");
} }
void void
CGameRules::PlayerDisconnect(base_player pl) CGameRules::PlayerDisconnect(NSClientPlayer pl)
{ {
//print("ClientDisconnect!\n"); //print("ClientDisconnect!\n");
} }
void void
CGameRules::PlayerKill(base_player pl) CGameRules::PlayerKill(NSClientPlayer pl)
{ {
//print("PlayerKill!\n"); //print("PlayerKill!\n");
} }
void void
CGameRules::PlayerDeath(base_player pl) CGameRules::PlayerDeath(NSClientPlayer pl)
{ {
//print("PlayerDeath!\n"); //print("PlayerDeath!\n");
pl.Death(); pl.Death();
} }
void void
CGameRules::PlayerPain(base_player pl) CGameRules::PlayerPain(NSClientPlayer pl)
{ {
//print("ClientKill!\n"); //print("ClientKill!\n");
pl.Pain(); pl.Pain();
} }
void void
CGameRules::PlayerSpawn(base_player pl) CGameRules::PlayerSpawn(NSClientPlayer pl)
{ {
//print("PutClientInServer!\n"); //print("PutClientInServer!\n");
} }
void void
CGameRules::PlayerPreFrame(base_player pl) CGameRules::PlayerPreFrame(NSClientPlayer pl)
{ {
//print("PlayerPreThink!\n"); //print("PlayerPreThink!\n");
} }
void void
CGameRules::PlayerPostFrame(base_player pl) CGameRules::PlayerPostFrame(NSClientPlayer pl)
{ {
//print("PlayerPostThink!\n"); //print("PlayerPostThink!\n");
} }
@ -86,7 +86,7 @@ CGameRules::LevelNewParms(void)
//print("LevelNewParms!\n"); //print("LevelNewParms!\n");
} }
void void
CGameRules::LevelChangeParms(base_player pl) CGameRules::LevelChangeParms(NSClientPlayer pl)
{ {
//print("LevelChangeParms!\n"); //print("LevelChangeParms!\n");
} }
@ -230,7 +230,7 @@ CGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type)
/* only clients have armor */ /* only clients have armor */
if (eTarget.flags & FL_CLIENT) { if (eTarget.flags & FL_CLIENT) {
base_player tp = (base_player)t; NSClientPlayer tp = (NSClientPlayer)t;
/* don't allow any damage */ /* don't allow any damage */
if (PlayerCanAttack(tp) == false) { if (PlayerCanAttack(tp) == false) {
@ -414,7 +414,7 @@ Gamerules_IsTeamPlay(void)
} }
bool bool
CGameRules::PlayerCanAttack(base_player bp) CGameRules::PlayerCanAttack(NSClientPlayer bp)
{ {
return true; return true;
} }

View file

@ -33,17 +33,17 @@ Event_ServerModelEvent(float flTimeStamp, int iCode, string strData)
NSEntity trigger = (NSEntity)f; NSEntity trigger = (NSEntity)f;
if (trigger.Trigger != __NULL__) { if (trigger.Trigger != __NULL__) {
trigger.Trigger(self, TRIG_TOGGLE); trigger.Trigger(self, TRIG_TOGGLE);
dprint(sprintf("^2%s^7::^3ModelEvent^7: " \ NSLog("^2%s^7::^3ModelEvent^7: " \
"Calling trigger '%s'\n", "Calling trigger '%s'\n",
self.classname, strData)); self.classname, strData);
} }
} }
break; break;
case 1004: case 1004:
break; break;
default: default:
dprint(sprintf("^3[SERVER]^7 Unknown model-event code " \ NSLog("^3[SERVER]^7 Unknown model-event code " \
"%i with data %s\n", iCode, strData)); "%i with data %s\n", iCode, strData);
break; break;
} }
} }

View file

@ -23,7 +23,7 @@ void Plugin_Shutdown(void);
void Plugin_InitEnts(void); void Plugin_InitEnts(void);
int Plugin_RunClientCommand(void); int Plugin_RunClientCommand(void);
string Plugin_ParseClientCommand(string); string Plugin_ParseClientCommand(string);
int Plugin_PlayerConnect(base_player); int Plugin_PlayerConnect(NSClientPlayer);
int Plugin_PlayerDisconnect(base_player); int Plugin_PlayerDisconnect(NSClientPlayer);
int Plugin_PlayerEntered(base_player); int Plugin_PlayerEntered(NSClientPlayer);
void Plugin_PlayerObituary(entity, entity, int, bodyType_t, int); void Plugin_PlayerObituary(entity, entity, int, bodyType_t, int);

View file

@ -214,7 +214,7 @@ Called whenever a new client connect to the game
================= =================
*/ */
int int
Plugin_PlayerConnect(base_player cl) Plugin_PlayerConnect(NSClientPlayer cl)
{ {
int rval; int rval;
int tval; int tval;
@ -249,7 +249,7 @@ Called whenever a client leaves the game
================= =================
*/ */
int int
Plugin_PlayerDisconnect(base_player cl) Plugin_PlayerDisconnect(NSClientPlayer cl)
{ {
int rval; int rval;
int tval; int tval;
@ -284,7 +284,7 @@ Called when a player has fully connected and entered the server
================= =================
*/ */
int int
Plugin_PlayerEntered(base_player cl) Plugin_PlayerEntered(NSClientPlayer cl)
{ {
int rval; int rval;
int tval; int tval;

View file

@ -98,7 +98,7 @@ Sentences_GetSamples(string word)
/* check if the word is present at all */ /* check if the word is present at all */
for (int i = 0; i < g_sentences_count; i++) { for (int i = 0; i < g_sentences_count; i++) {
if (g_sentences[i] == word) { if (g_sentences[i] == word) {
dprint(sprintf("^3Sentences_GetSamples^7: Found %s\n", word)); NSLog("^3Sentences_GetSamples^7: Found %s", word);
return word; return word;
} }
} }
@ -115,7 +115,7 @@ Sentences_GetSamples(string word)
/* if we've got one, choose a random sample of them */ /* if we've got one, choose a random sample of them */
if (gc) { if (gc) {
int r = floor(random(0, gc)); int r = floor(random(0, gc));
dprint(sprintf("^3Sentences_GetSamples^7: Choosing %s%i\n", word, r)); NSLog("^3Sentences_GetSamples^7: Choosing %s%i", word, r);
return sprintf("%s%i", word, r); return sprintf("%s%i", word, r);
} }

View file

@ -14,6 +14,6 @@
* 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.
*/ */
void Spawn_ObserverCam(base_player); void Spawn_ObserverCam(NSClientPlayer);
float Spawn_PlayerRange(entity); float Spawn_PlayerRange(entity);
entity Spawn_SelectRandom(string); entity Spawn_SelectRandom(string);

View file

@ -22,7 +22,7 @@ Find a spawnpoint for spectators and set origin and angle of the 'pl' target.
================= =================
*/ */
void void
Spawn_ObserverCam(base_player pl) Spawn_ObserverCam(NSClientPlayer pl)
{ {
entity eTarget; entity eTarget;
entity eCamera = find(world, ::classname, "trigger_camera"); entity eCamera = find(world, ::classname, "trigger_camera");

View file

@ -14,14 +14,14 @@
* 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.
*/ */
void Weapons_PickupNotify(base_player pl, int w); void Weapons_PickupNotify(NSClientPlayer pl, int w);
void Weapons_RefreshAmmo(base_player pl); void Weapons_RefreshAmmo(NSClientPlayer pl);
void Weapons_SwitchBest(base_player pl, optional float skip); void Weapons_SwitchBest(NSClientPlayer pl, optional float skip);
int Weapons_AddItem(base_player pl, int w, int startammo); int Weapons_AddItem(NSClientPlayer pl, int w, int startammo);
void Weapons_RemoveItem(base_player pl, int w); void Weapons_RemoveItem(NSClientPlayer pl, int w);
void Weapons_InitItem(int w); void Weapons_InitItem(int w);
void Weapons_UpdateAmmo(base_player pl, int a1, int a2, int a3); void Weapons_UpdateAmmo(NSClientPlayer pl, int a1, int a2, int a3);
void Weapons_ReloadWeapon(base_player pl, .int mag, .int ammo, int max); void Weapons_ReloadWeapon(NSClientPlayer pl, .int mag, .int ammo, int max);
void Weapon_DropCurrentWeapon(base_player pl); void Weapon_DropCurrentWeapon(NSClientPlayer pl);
int Weapon_GetCount(); int Weapon_GetCount();
int Weapon_GetBitID(int); int Weapon_GetBitID(int);

View file

@ -51,7 +51,7 @@ Tells the client if we picked up a NEW weapon item.
================= =================
*/ */
void void
Weapons_PickupNotify(base_player pl, int w) Weapons_PickupNotify(NSClientPlayer pl, int w)
{ {
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_WEAPON_PICKUP); WriteByte(MSG_MULTICAST, EV_WEAPON_PICKUP);
@ -68,7 +68,7 @@ Just calls updateammo() when available... maybe a bit redundant.
================= =================
*/ */
void void
Weapons_RefreshAmmo(base_player pl) Weapons_RefreshAmmo(NSClientPlayer pl)
{ {
if (g_weapons[pl.activeweapon].updateammo != __NULL__) { if (g_weapons[pl.activeweapon].updateammo != __NULL__) {
g_weapons[pl.activeweapon].updateammo((player)pl); g_weapons[pl.activeweapon].updateammo((player)pl);
@ -83,7 +83,7 @@ Switch to the 'best' weapon according to our weight system.
================= =================
*/ */
void void
Weapons_SwitchBest(base_player pl, optional float skip = 0) Weapons_SwitchBest(NSClientPlayer pl, optional float skip = 0)
{ {
entity oldself = self; entity oldself = self;
self = pl; self = pl;
@ -120,7 +120,7 @@ returns TRUE if weapon pickup gets removed from this world
================= =================
*/ */
int int
Weapons_AddItem(base_player pl, int w, int startammo) Weapons_AddItem(NSClientPlayer pl, int w, int startammo)
{ {
int value; int value;
@ -202,7 +202,7 @@ Makes sure the item bit of g_items is reliably unset without errors.
================= =================
*/ */
void void
Weapons_RemoveItem(base_player pl, int w) Weapons_RemoveItem(NSClientPlayer pl, int w)
{ {
if (pl.activeweapon == w) if (pl.activeweapon == w)
pl.activeweapon = WEAPON_NONE; pl.activeweapon = WEAPON_NONE;
@ -236,7 +236,7 @@ Manipulates the .mag and .ammo field pointer with some basic reload logic.
================= =================
*/ */
void void
Weapons_ReloadWeapon(base_player pl, .int mag, .int ammo, int max) Weapons_ReloadWeapon(NSClientPlayer pl, .int mag, .int ammo, int max)
{ {
int iNeed = max - pl.(mag); int iNeed = max - pl.(mag);
int iHave = pl.(ammo); int iHave = pl.(ammo);
@ -256,7 +256,7 @@ Weapon_DropCurrentWeapon
================= =================
*/ */
void void
Weapon_DropCurrentWeapon(base_player pl) Weapon_DropCurrentWeapon(NSClientPlayer pl)
{ {
static void DropWeapon_Enable(void) static void DropWeapon_Enable(void)

View file

@ -1,38 +0,0 @@
/* both base_player and base_spectator are based off this class */
class
base_client:NSSurfacePropEntity
{
vector origin_net;
vector velocity_net;
NSXRSpace m_xrSpace;
NSXRInput m_xrInputHead;
NSXRInput m_xrInputLeft;
NSXRInput m_xrInputRight;
void(void) base_client;
/* final input handling of the client */
virtual void(void) ClientInput;
virtual void(void) PreFrame;
virtual void(void) PostFrame;
virtual bool(void) IsFakeSpectator;
virtual bool(void) IsRealSpectator;
virtual bool(void) IsDead;
virtual bool(void) IsPlayer;
virtual void(void) OnRemoveEntity;
#ifdef CLIENT
/* gives the chance to override input variables before networking */
virtual void(void) ClientInputFrame;
/* our camera when we're dead */
virtual void(void) UpdateDeathcam;
/* run every frame before renderscene() */
virtual float(void) predraw;
#endif
};

View file

@ -1,84 +0,0 @@
void
base_client::OnRemoveEntity(void)
{
XR_Shutdown(this);
}
void
base_client::ClientInput(void)
{
}
void
base_client::PreFrame(void)
{
}
void
base_client::PostFrame(void)
{
}
bool
base_client::IsFakeSpectator(void)
{
return (false);
}
bool
base_client::IsRealSpectator(void)
{
return (false);
}
bool
base_client::IsDead(void)
{
return (false);
}
bool
base_client::IsPlayer(void)
{
return (false);
}
#ifdef CLIENT
void
base_client::ClientInputFrame(void)
{
}
void
base_client::UpdateDeathcam(void)
{
/* death cam */
view_angles[2] = 45.0f;
setproperty(VF_ORIGIN, pSeat->m_vecPredictedOrigin);
setproperty(VF_CL_VIEWANGLES, view_angles);
setproperty(VF_ANGLES, view_angles);
}
float
base_client::predraw(void)
{
return (PREDRAW_NEXT);
}
#endif
void
base_client::base_client(void)
{
XR_Init(this);
}
float
Client_InIntermission(void)
{
#ifdef CLIENT
return g_iIntermission;
#else
return (float)g_grMode.InIntermission();
#endif
}

View file

@ -32,6 +32,13 @@
#define ATTR_CHANGED(x) (x ##_net != x) #define ATTR_CHANGED(x) (x ##_net != x)
#define VEC_CHANGED(x,y) (x ##_net[y] != x[y]) #define VEC_CHANGED(x,y) (x ##_net[y] != x[y])
void
_NSLog(string msg)
{
print(sprintf("%f %s\n", time, msg));
}
#define NSLog(x, ...) _NSLog(sprintf(x, __VA_ARGS__))
#include "sound.h" #include "sound.h"
#ifdef CLIENT #ifdef CLIENT
@ -42,9 +49,9 @@
#include "../gs-entbase/shared/baseentity.h" #include "../gs-entbase/shared/baseentity.h"
#include "../xr/defs.h" #include "../xr/defs.h"
#include "client.h" #include "NSClient.h"
#include "spectator.h" #include "NSClientSpectator.h"
#include "player.h" #include "NSClientPlayer.h"
#include "damage.h" #include "damage.h"
#include "flags.h" #include "flags.h"
#include "entities.h" #include "entities.h"
@ -73,13 +80,6 @@
#define printf(x, ...) print(sprintf(x, ...)) #define printf(x, ...) print(sprintf(x, ...))
void
_NSLog(string msg)
{
print(sprintf("%f %s\n", time, msg));
}
#define NSLog(x, ...) _NSLog(sprintf(x, ...))
const vector VEC_HULL_MIN = [-16,-16,-36]; const vector VEC_HULL_MIN = [-16,-16,-36];
const vector VEC_HULL_MAX = [16,16,36]; const vector VEC_HULL_MAX = [16,16,36];
const vector VEC_CHULL_MIN = [-16,-16,-18]; const vector VEC_CHULL_MIN = [-16,-16,-18];
@ -184,9 +184,9 @@ __wrap string
precache_model(string m) precache_model(string m)
{ {
#ifdef CLIENT #ifdef CLIENT
dprint(sprintf("^3Client precaching model ^7%s\n", m)); NSLog("^3Client precaching model ^7%s\n", m);
#else #else
dprint(sprintf("^3Server precaching model ^7%s\n", m)); NSLog("^3Server precaching model ^7%s\n", m);
#endif #endif
return prior(m); return prior(m);
} }
@ -291,4 +291,4 @@ string Util_FixModel(string mdl)
mdl = substring(mdl, 1, -1); mdl = substring(mdl, 1, -1);
return mdl; return mdl;
} }

View file

@ -1,11 +1,11 @@
#includelist #includelist
client.qc NSClient.qc
spectator.qc NSClientSpectator.qc
pmove.qc pmove.qc
pmove_custom.qc pmove_custom.qc
sound.qc sound.qc
math.qc math.qc
player.qc NSClientPlayer.qc
player_pmove.qc player_pmove.qc
propdata.qc propdata.qc
surfaceproperties.qc surfaceproperties.qc

View file

@ -215,9 +215,9 @@ const int CONTENTBIT_SKY = 0x80000000i; /* Q1BSP only! */
* prefixes and limit our material-name to 12 chars for everything to be * prefixes and limit our material-name to 12 chars for everything to be
* identified correctly */ * identified correctly */
string string
Materials_FixName(string tex_name) Materials_FixName(string old_name)
{ {
dprint(sprintf("^3Materials_FixName^7: %s > ", tex_name)); string tex_name = old_name;
/* strip the first 2 chars when they're frame/random indicators */ /* strip the first 2 chars when they're frame/random indicators */
if (str2chr(tex_name, 0) == '-') if (str2chr(tex_name, 0) == '-')
@ -234,7 +234,7 @@ Materials_FixName(string tex_name)
/* limit to 12 chars! */ /* limit to 12 chars! */
tex_name = substring(tex_name, 0, 12); tex_name = substring(tex_name, 0, 12);
dprint(sprintf("%s\n", tex_name)); NSLog("%s > %s", old_name, tex_name);
return tex_name; return tex_name;
} }

View file

@ -1,122 +0,0 @@
/*
* Copyright (c) 2016-2021 Marco Cawthorne <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class
base_player:spectator
{
#ifdef SERVER
PREDICTED_INT_N(weaponframe);
#else
PREDICTED_INT(weaponframe);
PREDICTED_FLOAT(vehicle_entnum);
#endif
PREDICTED_FLOAT(health);
PREDICTED_FLOAT(armor);
PREDICTED_FLOAT_N(colormap);
PREDICTED_FLOAT_N(gflags);
PREDICTED_FLOAT(viewzoom);
PREDICTED_VECTOR_N(view_ofs);
PREDICTED_VECTOR(v_angle);
PREDICTED_FLOAT_N(pmove_flags);
PREDICTED_FLOAT(w_attack_next);
PREDICTED_FLOAT(w_idle_next);
PREDICTED_FLOAT(teleport_time);
PREDICTED_FLOAT(weapontime);
PREDICTED_VECTOR(punchangle);
/* We can't use the default .items field, because FTE will assume
* effects of some bits. Such as invisibility, quad, etc.
* also, modders probably want 32 bits for items. */
PREDICTED_INT(g_items);
PREDICTED_FLOAT(activeweapon);
/* vehicle info */
PREDICTED_ENT(vehicle);
/* these are NOT networked */
int a_ammo1;
int a_ammo2;
int a_ammo3;
/* any mods that use hooks */
entity hook;
void(void) base_player;
virtual void(void) ClientInput;
virtual void(void) PreFrame;
virtual void(void) PostFrame;
virtual void(float) Physics_Fall;
virtual void(void) Physics_Crouch;
virtual void(void) Physics_Jump;
virtual void(float) Physics_CheckJump;
virtual void(void) Physics_SetViewParms;
virtual void(void) Physics_WaterJump;
virtual void(void) Physics_WaterMove;
virtual float(void) Physics_MaxSpeed;
virtual void(void) Physics_InputPreMove;
virtual void(void) Physics_InputPostMove;
virtual void(void) Physics_Run;
virtual bool(void) IsFakeSpectator;
virtual bool(void) IsRealSpectator;
virtual bool(void) IsDead;
virtual bool(void) IsPlayer;
#ifdef CLIENT
int sequence;
/* external weapon model */
entity p_model;
int p_hand_bone;
int p_model_bone;
float lastweapon;
virtual void(void) VehicleRelink;
virtual void(void) OnRemoveEntity;
virtual void(float, float) ReceiveEntity;
virtual void(void) PredictPreFrame;
virtual void(void) PredictPostFrame;
virtual void(void) ClientInputFrame;
#else
int voted;
int step;
float step_time;
float underwater_time;
float underwater_dmg;
float pain_time;
entity last_used;
virtual void(float) Save;
virtual void(string,string) Restore;
virtual void(void) Respawn;
virtual void(void) EvaluateEntity;
virtual float(entity, float) SendEntity;
virtual void(void) Death;
virtual void(void) MakePlayer;
virtual void(void) MakeTempSpectator;
virtual void(void) InputUse_Down;
virtual void(void) InputUse_Up;
#endif
};

View file

@ -1,951 +0,0 @@
/*
* Copyright (c) 2016-2021 Marco Cawthorne <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
bool
base_player::IsRealSpectator(void)
{
return (false);
}
bool
base_player::IsDead(void)
{
if (health > 0)
return (false);
else
return (true);
}
bool
base_player::IsPlayer(void)
{
return (false);
}
bool
base_player::IsFakeSpectator(void)
{
if (GetFlags() & FL_FAKESPEC)
return (true);
return (false);
}
void
base_player::PreFrame(void)
{
#ifdef CLIENT
/* this is where a game/mod would decide to add more prediction rollback
* information. */
PredictPreFrame();
if (vehicle) {
NSVehicle veh = (NSVehicle)vehicle;
veh.PredictPreFrame();
}
/* run physics code for all the input frames which we've not heard back
* from yet. This continues on in Player_ReceiveEntity! */
for (int i = sequence + 1; i <= clientcommandframe; i++) {
float flSuccess = getinputstate(i);
if (flSuccess == FALSE) {
continue;
}
/* don't do partial frames, aka incomplete input packets */
if (input_timelength == 0) {
break;
}
if (i==clientcommandframe){
CSQC_Input_Frame();
}
/* this global is for our shared random number seed */
input_sequence = i;
/* run our custom physics */
Physics_Run();
}
#endif
}
void
base_player::PostFrame(void)
{
#ifdef CLIENT
/* give the game/mod a chance to roll back its values too */
PredictPostFrame();
setorigin(this, origin); /* update bounds */
if (vehicle) {
NSVehicle veh = (NSVehicle)vehicle;
veh.PredictPostFrame();
setorigin(veh, veh.origin);
}
#endif
}
void
base_player::ClientInput(void)
{
XR_InputFrame(this);
if (!Client_InIntermission() && IsFakeSpectator()) {
spectator::ClientInput();
SpectatorTrackPlayer();
return;
}
/* allow vehicles to prevent weapon logic from happening */
if (vehicle) {
NSVehicle veh = (NSVehicle)vehicle;
if (veh.PlayerInput)
veh.PlayerInput();
}
/* weapon/item logic of what the player controls */
Game_Input((player)this);
}
#ifdef CLIENT
void
base_player::VehicleRelink(void)
{
if (!vehicle_entnum)
vehicle = __NULL__;
else
vehicle = findentity(world, ::entnum, vehicle_entnum);
}
void
base_player::OnRemoveEntity(void)
{
if (p_model)
remove(p_model);
super::OnRemoveEntity();
}
/*
=================
base_player::ClientInputFrame
This is basically CSQC_Input_Frame! So games can override this as they please.
=================
*/
void
base_player::ClientInputFrame(void)
{
if (IsFakeSpectator()) {
spectator::ClientInputFrame();
return;
}
/* If we are inside a VGUI, don't let the client do stuff outside */
if (VGUI_Active()) {
input_impulse = 0;
input_buttons = 0;
return;
}
/* background maps have no input */
if (serverkeyfloat("background") == 1)
return;
if (pSeat->m_iInputAttack2 == TRUE) {
input_buttons |= INPUT_BUTTON3;
}
if (pSeat->m_iInputReload == TRUE) {
input_buttons |= INPUT_BUTTON4;
}
if (pSeat->m_iInputUse == TRUE) {
input_buttons |= INPUT_BUTTON5;
}
if (pSeat->m_iInputDuck == TRUE) {
input_buttons |= INPUT_BUTTON8;
}
/* The HUD needs more time */
if (pSeat->m_iHUDWeaponSelected) {
if ((input_buttons & INPUT_BUTTON0))
HUD_DrawWeaponSelect_Trigger();
else if ((input_buttons & INPUT_BUTTON3))
pSeat->m_iHUDWeaponSelected = pSeat->m_flHUDWeaponSelectTime = 0;
pSeat->m_flInputBlockTime = time + 0.2;
}
/* prevent accidental input packets */
if (pSeat->m_flInputBlockTime > time) {
input_buttons &= ~INPUT_BUTTON0;
input_buttons &= ~INPUT_BUTTON3;
pSeat->m_iInputAttack2 = FALSE;
return;
}
/* some input overrides for XR */
if (XR_Available(this)) {
if (pSeat->m_bMoveForward) {
input_movevalues[0] = 100;
}
if (pSeat->m_iInputAttack) {
input_buttons |= INPUT_BUTTON0;
}
}
/* compat*/
if (input_impulse == 201) {
sendevent("Spraylogo", "");
}
if (pSeat->m_flCameraTime > time) {
/* TODO: Supress the changing of view_angles/input_angles. */
}
}
/*
=================
base_player::ReceiveEntity
Receive the generic client attributes from the server.
If you want to override this, do not call this
at the top of player::ReceiveEntity
=================
*/
void
base_player::ReceiveEntity(float new, float fl)
{
/* store which input sequence we're on, this helps us
* later when we run prediction again between last/latest
* servercommandframe */
sequence = servercommandframe;
/* HACK: we need to make this more reliable */
if (fl == UPDATE_ALL) {
/* we respawned */
gravity = 1.0f;
}
if (fl & PLAYER_MODELINDEX) {
modelindex = readshort();
}
if (fl & PLAYER_ORIGIN) {
origin[0] = readcoord();
origin[1] = readcoord();
}
if (fl & PLAYER_ORIGIN_Z)
origin[2] = readcoord();
if (fl & PLAYER_ANGLES_X) {
v_angle[0] = readshort() / (32767 / 360);
v_angle[1] = readshort() / (32767 / 360);
v_angle[2] = readshort() / (32767 / 360);
}
if (fl & PLAYER_ANGLES_Y) {
angles[0] = readshort() / (32767 / 360);
angles[1] = readshort() / (32767 / 360);
angles[2] = readshort() / (32767 / 360);
}
if (fl & PLAYER_COLORMAP)
colormap = readbyte();
if (fl & PLAYER_VELOCITY) {
velocity[0] = readcoord();
velocity[1] = readcoord();
}
if (fl & PLAYER_VELOCITY_Z)
velocity[2] = readcoord();
if (fl & PLAYER_FLAGS) {
flags = readfloat();
gflags = readfloat();
pmove_flags = readfloat();
/* mainly used for other players receiving us */
if (flags & FL_CROUCHING)
setsize(self, PHY_HULL_CROUCHED_MIN, PHY_HULL_CROUCHED_MAX);
else
setsize(self, PHY_HULL_MIN, PHY_HULL_MAX);
}
if (fl & PLAYER_WEAPON) {
activeweapon = readbyte();
weaponframe = (int)readbyte();
}
if (fl & PLAYER_ITEMS)
g_items = (__variant)readfloat();
if (fl & PLAYER_HEALTH)
health = readbyte();
if (fl & PLAYER_ARMOR)
armor = readbyte();
if (fl & PLAYER_MOVETYPE) {
movetype = readbyte();
solid = readbyte();
}
if (fl & PLAYER_VIEWOFS)
view_ofs[2] = readfloat();
/* TO OPTIMISE */
teleport_time = readfloat();
viewzoom = readfloat();
weapontime = readfloat();
w_attack_next = readfloat();
w_idle_next = readfloat();
punchangle[0] = readfloat();
punchangle[1] = readfloat();
punchangle[2] = readfloat();
vehicle_entnum = readentitynum();
VehicleRelink();
/* FIXME: Make this temp spec only */
spec_ent = readbyte();
spec_mode = readbyte();
spec_flags = readbyte();
PredictPreFrame();
}
/*
=================
base_player::PredictPreFrame
Save the state of the last server-confirmed attributes.
If you want to override this, do not call this
at the top of player::PredictPreFrame
=================
*/
void
base_player::PredictPreFrame(void)
{
/* base player attributes/fields we're going to roll back */
SAVE_STATE(modelindex);
SAVE_STATE(origin);
SAVE_STATE(angles);
SAVE_STATE(v_angle);
SAVE_STATE(colormap);
SAVE_STATE(velocity);
SAVE_STATE(flags);
SAVE_STATE(gflags);
SAVE_STATE(pmove_flags);
SAVE_STATE(activeweapon);
SAVE_STATE(g_items);
SAVE_STATE(health);
SAVE_STATE(armor);
SAVE_STATE(movetype);
SAVE_STATE(solid);
SAVE_STATE(view_ofs);
/* TO OPTIMISE */
SAVE_STATE(teleport_time);
SAVE_STATE(viewzoom);
SAVE_STATE(weaponframe);
SAVE_STATE(weapontime);
SAVE_STATE(w_attack_next);
SAVE_STATE(w_idle_next);
SAVE_STATE(punchangle);
SAVE_STATE(vehicle_entnum);
SAVE_STATE(spec_ent);
SAVE_STATE(spec_mode);
SAVE_STATE(spec_flags);
}
/*
=================
base_player::PredictPostFrame
After running prediction on the client, roll back the values
to the server's confirmed saved attributes from PredictPreFrame.
If you want to override this, do not call this
at the top of player::PredictPostFrame
=================
*/
void
base_player::PredictPostFrame(void)
{
/* finally roll the values back */
ROLL_BACK(modelindex);
ROLL_BACK(origin);
ROLL_BACK(angles);
ROLL_BACK(v_angle);
ROLL_BACK(colormap);
ROLL_BACK(velocity);
ROLL_BACK(flags);
ROLL_BACK(gflags);
ROLL_BACK(pmove_flags);
ROLL_BACK(activeweapon);
ROLL_BACK(g_items);
ROLL_BACK(health);
ROLL_BACK(armor);
ROLL_BACK(movetype);
ROLL_BACK(solid);
ROLL_BACK(view_ofs);
/* TO OPTIMISE */
ROLL_BACK(teleport_time);
ROLL_BACK(viewzoom);
ROLL_BACK(weaponframe);
ROLL_BACK(weapontime);
ROLL_BACK(w_attack_next);
ROLL_BACK(w_idle_next);
ROLL_BACK(punchangle);
ROLL_BACK(vehicle_entnum);
ROLL_BACK(spec_ent);
ROLL_BACK(spec_mode);
ROLL_BACK(spec_flags);
}
#else
void
base_player::Save(float handle)
{
SaveFloat(handle, "health", health);
SaveFloat(handle, "armor", armor);
SaveFloat(handle, "modelindex", modelindex);
SaveVector(handle, "origin", origin);
SaveVector(handle, "velocity", velocity);
SaveVector(handle, "angles", angles);
SaveFloat(handle, "colormap", colormap);
SaveFloat(handle, "flags", flags);
SaveFloat(handle, "gflags", gflags);
SaveFloat(handle, "viewzoom", viewzoom);
SaveVector(handle, "view_ofs", view_ofs);
SaveVector(handle, "v_angle", v_angle);
SaveVector(handle, "punchangle", punchangle);
SaveFloat(handle, "movetype", movetype);
SaveFloat(handle, "pmove_flags", pmove_flags);
SaveFloat(handle, "w_attack_next", w_attack_next);
SaveFloat(handle, "w_idle_next", w_idle_next);
SaveFloat(handle, "teleport_time", teleport_time);
SaveInt(handle, "weaponframe", weaponframe);
SaveFloat(handle, "weapontime", weapontime);
SaveInt(handle, "g_items", g_items);
SaveFloat(handle, "activeweapon", activeweapon);
SaveFloat(handle, "vehicle", num_for_edict(vehicle));
}
void
base_player::Restore(string strKey, string strValue)
{
switch (strKey) {
case "health":
health = ReadFloat(strValue);
break;
case "armor":
armor = ReadFloat(strValue);
break;
case "modelindex":
modelindex = ReadFloat(strValue);
break;
case "origin":
origin = ReadVector(strValue);
break;
case "velocity":
velocity = ReadVector(strValue);
break;
case "angles":
angles = ReadVector(strValue);
break;
case "colormap":
colormap = ReadFloat(strValue);
break;
case "flags":
flags = ReadFloat(strValue);
break;
case "gflags":
gflags = ReadFloat(strValue);
break;
case "view_ofs":
view_ofs = ReadVector(strValue);
break;
case "v_angle":
v_angle = ReadVector(strValue);
break;
case "punchangle":
punchangle = ReadVector(strValue);
break;
case "movetype":
movetype = ReadFloat(strValue);
break;
case "pmove_flags":
pmove_flags = ReadFloat(strValue);
break;
case "w_attack_next":
w_attack_next = ReadFloat(strValue);
break;
case "w_idle_next":
w_idle_next = ReadFloat(strValue);
break;
case "teleport_time":
teleport_time = ReadFloat(strValue);
break;
case "weaponframe":
weaponframe = ReadInt(strValue);
break;
case "weapontime":
weapontime = ReadFloat(strValue);
break;
case "g_items":
g_items = ReadInt(strValue);
break;
case "activeweapon":
activeweapon = ReadFloat(strValue);
break;
case "vehicle":
vehicle = edict_num(ReadFloat(strValue));
break;
default:
super::Restore(strKey, strValue);
}
}
/*
=================
base_player::Respawn
it'd be pretty unfortunate if 'sv respawn_ents' or something called this
=================
*/
void
base_player::Respawn(void)
{
/* make sure nothing happens here */
}
/*
=================
base_player::MakeTempSpectator
This is what dead players in round matches become, or when we spawn
for the first time before selecting a loadout or something.
=================
*/
void
base_player::MakeTempSpectator(void)
{
classname = "player";
flags = FL_CLIENT;
SetModelindex(0);
SetSolid(SOLID_NOT);
SetMovetype(MOVETYPE_NOCLIP);
SetTakedamage(DAMAGE_NO);
maxspeed = 250;
flags |= FL_FAKESPEC;
max_health = health = 0;
armor = 0;
g_items = 0;
activeweapon = 0;
effects = 0;
alpha = 0.0f;
}
/*
=================
base_player::MakeDead
Sets all the appropriate attributes to make sure we're dead
=================
*/
void
base_player::Death(void)
{
classname = "player";
health = max_health = 0;
armor = 0;
g_items = 0;
activeweapon = 0;
effects = 0;
alpha = 1.0f;
SetModelindex(0);
SetMovetype(MOVETYPE_NONE);
SetSolid(SOLID_NOT);
SetTakedamage(DAMAGE_NO);
viewzoom = 1.0;
view_ofs = [0,0,0];
vehicle = __NULL__;
SetVelocity([0,0,0]);
SetGravity(1.0f);
customphysics = Empty;
iBleeds = FALSE;
forceinfokey(this, "*deaths", ftos(deaths));
setsize(this, [0,0,0], [0,0,0]);
}
/*
=================
base_player::MakePlayer
True participating player, can walk around and everything.
=================
*/
void
base_player::MakePlayer(void)
{
classname = "player";
flags = FL_CLIENT;
health = max_health = 100;
armor = 0;
g_items = 0;
activeweapon = 0;
effects = 0;
alpha = 1.0f;
SetSolid(SOLID_SLIDEBOX);
SetMovetype(MOVETYPE_WALK);
SetTakedamage(DAMAGE_YES);
SetVelocity([0,0,0]);
viewzoom = 1.0;
vehicle = __NULL__;
SetGravity(1.0f);
SendFlags = UPDATE_ALL;
customphysics = Empty;
iBleeds = TRUE;
forceinfokey(this, "*deaths", ftos(deaths));
SetSize(VEC_HULL_MIN, VEC_HULL_MAX);
}
/*
=================
base_player::EvaluateEntity
Check which attributes have changed and flag the ones that did.
If you want to override this, do not call this
at the top of player::EvaluateEntity
=================
*/
void
base_player::EvaluateEntity(void)
{
SetSendFlags(PLAYER_KEEPALIVE);
if (ATTR_CHANGED(modelindex))
SetSendFlags(PLAYER_MODELINDEX);
if (VEC_CHANGED(origin, 0))
SetSendFlags(PLAYER_ORIGIN);
if (VEC_CHANGED(origin, 1))
SetSendFlags(PLAYER_ORIGIN);
if (VEC_CHANGED(origin, 2))
SetSendFlags(PLAYER_ORIGIN_Z);
if (VEC_CHANGED(v_angle, 0) || VEC_CHANGED(v_angle, 1) || VEC_CHANGED(v_angle, 2))
SetSendFlags(PLAYER_ANGLES_X);
if (VEC_CHANGED(angles, 0) || VEC_CHANGED(angles, 1) || VEC_CHANGED(angles, 2))
SetSendFlags(PLAYER_ANGLES_Y);
if (ATTR_CHANGED(colormap))
SetSendFlags(PLAYER_COLORMAP);
if (VEC_CHANGED(velocity, 0))
SetSendFlags(PLAYER_VELOCITY);
if (VEC_CHANGED(velocity, 1))
SetSendFlags(PLAYER_VELOCITY);
if (VEC_CHANGED(velocity, 2))
SetSendFlags(PLAYER_VELOCITY_Z);
if (ATTR_CHANGED(flags))
SetSendFlags(PLAYER_FLAGS);
if (ATTR_CHANGED(gflags))
SetSendFlags(PLAYER_FLAGS);
if (ATTR_CHANGED(pmove_flags))
SetSendFlags(PLAYER_FLAGS);
if (ATTR_CHANGED(weaponframe))
SetSendFlags(PLAYER_WEAPON);
if (ATTR_CHANGED(activeweapon))
SetSendFlags(PLAYER_WEAPON);
if (ATTR_CHANGED(g_items))
SetSendFlags(PLAYER_ITEMS);
if (ATTR_CHANGED(health))
SetSendFlags(PLAYER_HEALTH);
if (ATTR_CHANGED(armor))
SetSendFlags(PLAYER_ARMOR);
if (ATTR_CHANGED(movetype))
SetSendFlags(PLAYER_MOVETYPE);
if (ATTR_CHANGED(solid))
SetSendFlags(PLAYER_MOVETYPE);
if (ATTR_CHANGED(view_ofs))
SetSendFlags(PLAYER_VIEWOFS);
SAVE_STATE(modelindex);
SAVE_STATE(origin);
SAVE_STATE(angles);
SAVE_STATE(colormap);
SAVE_STATE(velocity);
SAVE_STATE(flags);
SAVE_STATE(gflags);
SAVE_STATE(pmove_flags);
SAVE_STATE(activeweapon);
SAVE_STATE(g_items);
SAVE_STATE(health);
SAVE_STATE(armor);
SAVE_STATE(movetype);
SAVE_STATE(solid);
SAVE_STATE(view_ofs);
/* TO OPTIMISE */
SAVE_STATE(teleport_time);
SAVE_STATE(viewzoom);
SAVE_STATE(weaponframe);
SAVE_STATE(weapontime);
SAVE_STATE(w_attack_next);
SAVE_STATE(w_idle_next);
SAVE_STATE(punchangle);
SAVE_STATE(vehicle);
/* FIXME: Make this temp spec only */
SAVE_STATE(spec_ent);
SAVE_STATE(spec_mode);
SAVE_STATE(spec_flags);
}
/*
=================
base_player::SendEntity
Network any attributes that have been flagged for networking.
If you want to override this, do not call this
at the top of player::SendEntity
=================
*/
float
base_player::SendEntity(entity ePEnt, float fChanged)
{
/* really trying to get our moneys worth with 23 bits of mantissa */
if (fChanged & PLAYER_MODELINDEX) {
WriteShort(MSG_ENTITY, modelindex);
}
/* if origin[0] changes, it's very likely [1] changes too, since
* we rarely ever walk in a straight line on the world grid */
if (fChanged & PLAYER_ORIGIN) {
WriteCoord(MSG_ENTITY, origin[0]);
WriteCoord(MSG_ENTITY, origin[1]);
}
/* the height doesn't change as much */
if (fChanged & PLAYER_ORIGIN_Z)
WriteCoord(MSG_ENTITY, origin[2]);
if (fChanged & PLAYER_ANGLES_X) {
WriteShort(MSG_ENTITY, v_angle[0] * 32767 / 360);
WriteShort(MSG_ENTITY, v_angle[1] * 32767 / 360);
WriteShort(MSG_ENTITY, v_angle[2] * 32767 / 360);
}
if (fChanged & PLAYER_ANGLES_Y) {
WriteShort(MSG_ENTITY, angles[0] * 32767 / 360);
WriteShort(MSG_ENTITY, angles[1] * 32767 / 360);
WriteShort(MSG_ENTITY, angles[2] * 32767 / 360);
}
if (fChanged & PLAYER_COLORMAP)
WriteByte(MSG_ENTITY, colormap);
/* similar as with origin, we separate x/y from z */
if (fChanged & PLAYER_VELOCITY) {
WriteCoord(MSG_ENTITY, velocity[0]);
WriteCoord(MSG_ENTITY, velocity[1]);
}
if (fChanged & PLAYER_VELOCITY_Z)
WriteCoord(MSG_ENTITY, velocity[2]);
if (fChanged & PLAYER_FLAGS) {
WriteFloat(MSG_ENTITY, flags);
WriteFloat(MSG_ENTITY, gflags);
WriteFloat(MSG_ENTITY, pmove_flags);
}
if (fChanged & PLAYER_WEAPON) {
WriteByte(MSG_ENTITY, activeweapon);
WriteByte(MSG_ENTITY, weaponframe);
}
/* g_items is a proper integer, so we can't let WriteFloat truncate it (hence __variant) */
if (fChanged & PLAYER_ITEMS)
WriteFloat(MSG_ENTITY, (__variant)g_items);
/* only got byte precision, clamp to avoid weird values on the client-side */
if (fChanged & PLAYER_HEALTH)
WriteByte(MSG_ENTITY, bound(0, health, 255));
if (fChanged & PLAYER_ARMOR)
WriteByte(MSG_ENTITY, bound(0, armor, 255));
if (fChanged & PLAYER_MOVETYPE) {
WriteByte(MSG_ENTITY, movetype);
WriteByte(MSG_ENTITY, solid);
}
/* the view_ofs[0] and [1] are rarely changed */
if (fChanged & PLAYER_VIEWOFS)
WriteFloat(MSG_ENTITY, view_ofs[2]);
/* TO OPTIMISE */
WriteFloat(MSG_ENTITY, teleport_time);
WriteFloat(MSG_ENTITY, viewzoom);
WriteFloat(MSG_ENTITY, weapontime);
WriteFloat(MSG_ENTITY, w_attack_next);
WriteFloat(MSG_ENTITY, w_idle_next);
WriteFloat(MSG_ENTITY, punchangle[0]);
WriteFloat(MSG_ENTITY, punchangle[1]);
WriteFloat(MSG_ENTITY, punchangle[2]);
if (vehicle)
WriteEntity(MSG_ENTITY, vehicle);
else
WriteEntity(MSG_ENTITY, __NULL__);
/* FIXME: Make this fake spectator only. */
WriteByte(MSG_ENTITY, spec_ent);
WriteByte(MSG_ENTITY, spec_mode);
WriteByte(MSG_ENTITY, spec_flags);
return (1);
}
/*
====================
_base_player_useworkaround
A wrapper to cleanly reset 'self' as to not mess up the QC VM
====================
*/
void
_base_player_useworkaround(entity eTarget)
{
eActivator = self;
entity eOldSelf = self;
self = eTarget;
self.PlayerUse();
self = eOldSelf;
}
/*
====================
_base_player_useworkaround
A wrapper to cleanly reset 'self' as to not mess up the QC VM
====================
*/
void
_base_player_unuseworkaround(entity eTarget)
{
eActivator = self;
entity eOldSelf = self;
self = eTarget;
if (self.PlayerUseUnpressed)
self.PlayerUseUnpressed();
self = eOldSelf;
}
/*
=================
base_player:: InputUse_Down
Called when we hold down the +use button for the first time,
looks for an entity that has the .PlayerUse field set to a function and calls it.
=================
*/
void
base_player::InputUse_Down(void)
{
if (health <= 0) {
return;
} else if (!(flags & FL_USE_RELEASED)) {
return;
}
vector vecSource;
entity eRad;
bool found_use = false;
makevectors(v_angle);
vecSource = origin + view_ofs;
traceline(vecSource, vecSource + (v_forward * 64), MOVE_EVERYTHING, this);
/* first see if we traced something head-on, else we'll findradius something */
if (trace_ent.PlayerUse) {
found_use = true;
eRad = trace_ent;
} else {
/* find anything in a 8 unit radius, including certain non-solids (func_door, func_rot_button etc. */
eRad = findradius(trace_endpos, 8);
/* loop through our chain and just pick the first valid one */
while (eRad) {
if (eRad.PlayerUse) {
found_use = true;
break;
}
eRad = eRad.chain;
}
}
/* TODO: maybe eRad will return something in the future that'll suppress a successfull use? */
if (eRad && found_use == true) {
flags &= ~FL_USE_RELEASED;
_base_player_useworkaround(eRad);
last_used = eRad;
/* Some entities want to support Use spamming */
if (!(flags & FL_USE_RELEASED)) {
sound(this, CHAN_ITEM, "common/wpn_select.wav", 0.25, ATTN_IDLE);
}
} else {
sound(this, CHAN_ITEM, "common/wpn_denyselect.wav", 0.25, ATTN_IDLE);
flags &= ~FL_USE_RELEASED;
}
}
/*
=================
base_player:: InputUse_Down
Called when we let go of the +use button
=================
*/
void
base_player::InputUse_Up(void)
{
if (!(flags & FL_USE_RELEASED)) {
_base_player_unuseworkaround(last_used);
last_used = world;
flags |= FL_USE_RELEASED;
}
}
#endif
void
base_player::base_player(void)
{
super::spectator();
vehicle = __NULL__;
}

View file

@ -3,7 +3,7 @@ vector saved_input_movevalues;
int saved_input_buttons; int saved_input_buttons;
void void
base_player::Physics_Fall(float flDownforce) NSClientPlayer::Physics_Fall(float flDownforce)
{ {
if (flDownforce > 580) { if (flDownforce > 580) {
#ifdef SERVER #ifdef SERVER
@ -21,7 +21,7 @@ base_player::Physics_Fall(float flDownforce)
} }
void void
base_player::Physics_Crouch(void) NSClientPlayer::Physics_Crouch(void)
{ {
int iFixCrouch = FALSE; int iFixCrouch = FALSE;
if (input_buttons & INPUT_BUTTON8) { if (input_buttons & INPUT_BUTTON8) {
@ -58,7 +58,7 @@ base_player::Physics_Crouch(void)
void void
base_player::Physics_Jump(void) NSClientPlayer::Physics_Jump(void)
{ {
/* climb out of substances when underwater */ /* climb out of substances when underwater */
if (waterlevel >= 2) { if (waterlevel >= 2) {
@ -77,7 +77,7 @@ base_player::Physics_Jump(void)
/* check if we're elligible to jump */ /* check if we're elligible to jump */
void void
base_player::Physics_CheckJump(float premove) NSClientPlayer::Physics_CheckJump(float premove)
{ {
/* unset jump-key whenever it's not set */ /* unset jump-key whenever it's not set */
if (!(input_buttons & INPUT_BUTTON2)) { if (!(input_buttons & INPUT_BUTTON2)) {
@ -107,7 +107,7 @@ base_player::Physics_CheckJump(float premove)
/* establish the right size and camera position */ /* establish the right size and camera position */
void void
base_player::Physics_SetViewParms(void) NSClientPlayer::Physics_SetViewParms(void)
{ {
if (flags & FL_CROUCHING) { if (flags & FL_CROUCHING) {
mins = PHY_HULL_CROUCHED_MIN; mins = PHY_HULL_CROUCHED_MIN;
@ -122,7 +122,7 @@ base_player::Physics_SetViewParms(void)
} }
void void
base_player::Physics_WaterJump(void) NSClientPlayer::Physics_WaterJump(void)
{ {
vector vStart; vector vStart;
vector vEnd; vector vEnd;
@ -152,7 +152,7 @@ base_player::Physics_WaterJump(void)
/* handle your time underwater */ /* handle your time underwater */
void void
base_player::Physics_WaterMove(void) NSClientPlayer::Physics_WaterMove(void)
{ {
if (movetype == MOVETYPE_NOCLIP) { if (movetype == MOVETYPE_NOCLIP) {
return; return;
@ -219,13 +219,13 @@ base_player::Physics_WaterMove(void)
} }
float float
base_player::Physics_MaxSpeed(void) NSClientPlayer::Physics_MaxSpeed(void)
{ {
return (flags & FL_CROUCHING) ? 135 : 270; return (flags & FL_CROUCHING) ? 135 : 270;
} }
void void
base_player::Physics_InputPreMove(void) NSClientPlayer::Physics_InputPreMove(void)
{ {
NSVehicle veh = (NSVehicle)vehicle; NSVehicle veh = (NSVehicle)vehicle;
@ -256,7 +256,7 @@ base_player::Physics_InputPreMove(void)
/* timers get processed here after physics are run */ /* timers get processed here after physics are run */
void void
base_player::Physics_InputPostMove(void) NSClientPlayer::Physics_InputPostMove(void)
{ {
float punch; float punch;
/* timers, these are predicted and shared across client and server */ /* timers, these are predicted and shared across client and server */
@ -279,7 +279,7 @@ base_player::Physics_InputPostMove(void)
/* the main physics routine, the head */ /* the main physics routine, the head */
void void
base_player::Physics_Run(void) NSClientPlayer::Physics_Run(void)
{ {
float flFallVel = (flags & FL_ONGROUND) ? 0 : -velocity[2]; float flFallVel = (flags & FL_ONGROUND) ? 0 : -velocity[2];

View file

@ -227,7 +227,7 @@ PropData_ForModel(string modelname)
fh = fopen(strcat(modelname, ".propdata"), FILE_READ); fh = fopen(strcat(modelname, ".propdata"), FILE_READ);
if (fh < 0) { if (fh < 0) {
g_propdata_count--; g_propdata_count--;
dprint(sprintf("Can't find propdata for model %s\n", modelname)); NSLog("Can't find propdata for model %s", modelname);
return -1; return -1;
} }
while ((line = fgets(fh))) { while ((line = fgets(fh))) {

View file

@ -277,7 +277,7 @@ Sound_Precache(string shader)
cache = (int)hash_get(g_hashsounds, shader, -1); cache = (int)hash_get(g_hashsounds, shader, -1);
if (cache >= 0) { if (cache >= 0) {
dprint(sprintf("^1Sound_Precache: shader %s already precached\n", shader)); NSLog("^1Sound_Precache: shader %s already precached", shader);
return cache; return cache;
} }
} }

View file

@ -1,65 +0,0 @@
typedef enumflags
{
SPECFL_ORIGIN,
SPECFL_VELOCITY,
SPECFL_TARGET,
SPECFL_MODE,
SPECFL_FLAGS
} spectatorFlags_t;
typedef enum
{
SPECMODE_FREE,
SPECMODE_THIRDPERSON,
SPECMODE_FIRSTPERSON,
SPECMODE_OVERVIEW
} spectatorMode_t;
typedef enumflags
{
SPECFLAG_BUTTON_RELEASED,
};
class spectator:base_client
{
PREDICTED_FLOAT(spec_ent);
PREDICTED_FLOAT(spec_flags);
spectatorMode_t spec_mode; spectatorMode_t spec_mode_net;
vector spec_org;
int sequence;
void(void) spectator;
virtual void(void) ClientInput;
virtual void(void) InputNext;
virtual void(void) InputPrevious;
virtual void(void) InputMode;
virtual void(void) WarpToTarget;
virtual void(void) PreFrame;
virtual void(void) PostFrame;
virtual void(void) SpectatorTrackPlayer;
virtual bool(void) IsFakeSpectator;
virtual bool(void) IsRealSpectator;
virtual bool(void) IsDead;
virtual bool(void) IsPlayer;
#ifdef SERVER
virtual void(void) EvaluateEntity;
virtual float(entity, float) SendEntity;
virtual void(void) RunClientCommand;
#else
virtual void(void) ClientInputFrame;
virtual void(float,float) ReceiveEntity;
virtual float(void) predraw;
#endif
};
#ifdef CLIENT
void Spectator_ReadEntity(float new);
#endif

View file

@ -1,483 +0,0 @@
/*
* Copyright (c) 2016-2021 Marco Cawthorne <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
bool
spectator::IsRealSpectator(void)
{
return (true);
}
bool
spectator::IsDead(void)
{
return (false);
}
bool
spectator::IsPlayer(void)
{
return (false);
}
bool
spectator::IsFakeSpectator(void)
{
return (false);
}
void
spectator::ClientInput(void)
{
if (input_buttons & INPUT_BUTTON0) {
InputNext();
} else if (input_buttons & INPUT_BUTTON3) {
InputPrevious();
} else if (input_buttons & INPUT_BUTTON2) {
InputMode();
} else {
spec_flags &= ~SPECFLAG_BUTTON_RELEASED;
}
input_buttons = 0;
//crossprint(sprintf("%d %d %d\n", spec_ent, spec_mode, spec_flags));
}
void
spectator::WarpToTarget(void)
{
entity b = edict_num(spec_ent);
setorigin(this, b.origin);
}
#ifdef SERVER
float
spectator::SendEntity(entity ePVSent, float flChangedFlags)
{
if (this != ePVSent) {
return (0);
}
if (clienttype(ePVSent) != CLIENTTYPE_REAL) {
return (0);
}
WriteByte(MSG_ENTITY, ENT_SPECTATOR);
WriteFloat(MSG_ENTITY, flChangedFlags);
if (flChangedFlags & SPECFL_ORIGIN) {
WriteCoord(MSG_ENTITY, origin[0]);
WriteCoord(MSG_ENTITY, origin[1]);
WriteCoord(MSG_ENTITY, origin[2]);
}
if (flChangedFlags & SPECFL_VELOCITY) {
WriteFloat(MSG_ENTITY, velocity[0]);
WriteFloat(MSG_ENTITY, velocity[1]);
WriteFloat(MSG_ENTITY, velocity[2]);
}
if (flChangedFlags & SPECFL_TARGET)
WriteByte(MSG_ENTITY, spec_ent);
if (flChangedFlags & SPECFL_MODE)
WriteByte(MSG_ENTITY, spec_mode);
if (flChangedFlags & SPECFL_FLAGS)
WriteByte(MSG_ENTITY, spec_flags);
return (1);
}
void
spectator::RunClientCommand(void)
{
runstandardplayerphysics(this);
ClientInput();
}
#else
void
spectator::ClientInputFrame(void)
{
/* If we are inside a VGUI, don't let the client do stuff outside */
if (VGUI_Active()) {
input_impulse = 0;
input_buttons = 0;
return;
}
/* background maps have no input */
if (serverkeyfloat("background") == 1)
return;
}
void
spectator::ReceiveEntity(float new, float fl)
{
if (new == FALSE) {
/* Go through all the physics code between the last received frame
* and the newest frame and keep the changes this time around instead
* of rolling back, because we'll apply the new server-verified values
* right after anyway. */
/* FIXME: splitscreen */
if (entnum == player_localentnum) {
/* FIXME: splitscreen */
pSeat = &g_seats[0];
for (int i = sequence+1; i <= servercommandframe; i++) {
/* ...maybe the input state is too old? */
if (!getinputstate(i)) {
break;
}
input_sequence = i;
runstandardplayerphysics(this);
ClientInput();
}
/* any differences in things that are read below are now
* officially from prediction misses. */
}
}
/* seed for our prediction table */
sequence = servercommandframe;
if (fl & SPECFL_ORIGIN) {
origin[0] = readcoord();
origin[1] = readcoord();
origin[2] = readcoord();
}
if (fl & SPECFL_VELOCITY) {
velocity[0] = readfloat();
velocity[1] = readfloat();
velocity[2] = readfloat();
}
if (fl & SPECFL_TARGET)
spec_ent = readbyte();
if (fl & SPECFL_MODE)
spec_mode = readbyte();
if (fl & SPECFL_FLAGS)
spec_flags = readbyte();
};
float
spectator::predraw(void)
{
addentity(this);
return (PREDRAW_NEXT);
}
#endif
void
spectator::InputNext(void)
{
if (spec_flags & SPECFLAG_BUTTON_RELEASED)
return;
#if 0
float max_edict;
max_edict = serverkeyfloat("sv_playerslots");
spec_ent++;
if (spec_ent > max_edict)
spec_ent = 1;
print(sprintf("edict: %d\n", spec_ent));
#else
float max_edict;
float sep = spec_ent;
float best = 0;
base_client cl;
max_edict = serverkeyfloat("sv_playerslots");
for (float i = 1; i <= max_edict; i++) {
entity f;
if (i <= sep && best == 0) {
f = edict_num(i);
if (f && f.classname == "player" && f != this) {
cl = (base_client)f;
if (!cl.IsFakeSpectator())
best = i;
}
}
if (i > sep) {
f = edict_num(i);
if (f && f.classname == "player" && f != this) {
cl = (base_client)f;
if (!cl.IsFakeSpectator()) {
best = i;
break;
}
}
}
}
if (best == 0)
return;
spec_ent = best;
#endif
spec_flags |= SPECFLAG_BUTTON_RELEASED;
WarpToTarget();
if (spec_mode == SPECMODE_FREE)
spec_mode = SPECMODE_THIRDPERSON;
}
void
spectator::InputPrevious(void)
{
if (spec_flags & SPECFLAG_BUTTON_RELEASED)
return;
#if 0
float max_edict;
max_edict = serverkeyfloat("sv_playerslots");
spec_ent--;
if (spec_ent < 1)
spec_ent = max_edict;
#else
float max_edict;
float sep = spec_ent;
float best = 0;
base_client cl;
max_edict = serverkeyfloat("sv_playerslots");
for (float i = max_edict; i > 0; i--) {
entity f;
/* remember the first valid one here */
if (i >= sep && best == 0) {
f = edict_num(i);
if (f && f.classname == "player") {
cl = (base_client)f;
if (!cl.IsFakeSpectator())
best = i;
}
}
/* find the first good one and take it */
if (i < sep) {
f = edict_num(i);
if (f && f.classname == "player") {
cl = (base_client)f;
if (!cl.IsFakeSpectator()) {
best = i;
break;
}
}
}
}
if (best == 0)
return;
spec_ent = best;
#endif
spec_flags |= SPECFLAG_BUTTON_RELEASED;
WarpToTarget();
if (spec_mode == SPECMODE_FREE)
spec_mode = SPECMODE_THIRDPERSON;
}
void
spectator::InputMode(void)
{
if (spec_flags & SPECFLAG_BUTTON_RELEASED)
return;
base_client f;
#ifdef CLIENT
f = (base_client)findfloat(world, ::entnum, spec_ent);
#else
f = (base_client)edict_num(spec_ent);
#endif
if (f == this || f.classname != "player")
spec_mode = SPECMODE_FREE;
else {
spec_mode++;
if (spec_mode > SPECMODE_FIRSTPERSON)
spec_mode = SPECMODE_FREE;
}
spec_flags |= SPECFLAG_BUTTON_RELEASED;
}
void
spectator::PreFrame(void)
{
#ifdef CLIENT
/* base player attributes/fields we're going to roll back */
SAVE_STATE(origin);
SAVE_STATE(velocity);
SAVE_STATE(spec_ent);
SAVE_STATE(spec_mode);
SAVE_STATE(spec_flags);
/* run physics code for all the input frames which we've not heard back
* from yet. This continues on in Player_ReceiveEntity! */
for (int i = sequence + 1; i <= clientcommandframe; i++) {
float flSuccess = getinputstate(i);
if (flSuccess == FALSE) {
continue;
}
if (i==clientcommandframe){
CSQC_Input_Frame();
}
/* don't do partial frames, aka incomplete input packets */
if (input_timelength == 0) {
break;
}
/* this global is for our shared random number seed */
input_sequence = i;
/* run our custom physics */
runstandardplayerphysics(this);
ClientInput();
}
#endif
SpectatorTrackPlayer();
}
void
spectator::SpectatorTrackPlayer(void)
{
if (spec_mode == SPECMODE_THIRDPERSON || spec_mode == SPECMODE_FIRSTPERSON ) {
base_client b;
#ifdef CLIENT
b = (base_client)findfloat(world, ::entnum, spec_ent);
#else
b = (base_client)edict_num(spec_ent);
#endif
if (b && b.classname == "player")
if (b.IsFakeSpectator()) {
b = 0;
spec_mode = SPECMODE_FREE;
InputNext();
}
/* if the ent is dead... or not available in this current frame
just warp to the last 'good' one */
if (b) {
setorigin(this, b.origin);
spec_org = b.origin;
} else {
setorigin(this, spec_org);
}
}
}
#ifdef SERVER
void
spectator::EvaluateEntity(void)
{
/* check for which values have changed in this frame
and announce to network said changes */
if (origin != origin_net)
SetSendFlags(SPECFL_ORIGIN);
if (velocity != velocity_net)
SetSendFlags(SPECFL_VELOCITY);
if (spec_ent != spec_ent_net)
SetSendFlags(SPECFL_TARGET);
if (spec_mode != spec_mode_net)
SetSendFlags(SPECFL_MODE);
if (spec_flags != spec_flags_net)
SetSendFlags(SPECFL_FLAGS);
SAVE_STATE(origin);
SAVE_STATE(velocity);
SAVE_STATE(spec_ent);
SAVE_STATE(spec_mode);
SAVE_STATE(spec_flags);
}
#endif
void
spectator::PostFrame(void)
{
#ifdef CLIENT
ROLL_BACK(origin);
ROLL_BACK(velocity);
ROLL_BACK(spec_ent);
ROLL_BACK(spec_mode);
ROLL_BACK(spec_flags);
#endif
}
void
spectator::spectator(void)
{
super::base_client();
modelindex = 0;
flags = FL_CLIENT;
SetSolid(SOLID_NOT);
SetMovetype(MOVETYPE_NOCLIP);
think = __NULL__;
nextthink = 0.0f;
maxspeed = 250;
spec_ent = 0;
spec_mode = 0;
}
#ifdef CLIENT
void
Spectator_ReadEntity(float new)
{
spectator spec = (spectator)self;
if (new || self.classname != "spectator") {
spawnfunc_spectator();
spec.classname = "spectator";
spec.solid = SOLID_NOT;
spec.drawmask = MASK_ENGINE;
spec.customphysics = Empty;
setsize(spec, [0,0,0], [0,0,0]);
}
float flags = readfloat();
spec.ReceiveEntity(new, flags);
}
#endif

View file

@ -152,7 +152,7 @@ int CUIList::GetOffset(void)
void CUIList::SetItemCount (int iCount) void CUIList::SetItemCount (int iCount)
{ {
if (!m_iItemCount) { if (!m_iItemCount) {
dprint(sprintf("CUIList: Initialized with a maximum of %i entries\n", iCount)); NSLog("CUIList: Initialized with a maximum of %i entries", iCount);
m_iItemCount = iCount; m_iItemCount = iCount;
m_strItems = memalloc(iCount * sizeof(string)); m_strItems = memalloc(iCount * sizeof(string));
} }

View file

@ -48,7 +48,7 @@ void CUIListBox::SetSize (vector vecSize)
void CUIListBox::SetItemCount (int iCount) void CUIListBox::SetItemCount (int iCount)
{ {
if (!m_iItemCount) { if (!m_iItemCount) {
dprint(sprintf("CUIListBox: Initialized with a maximum of %i entries\n", iCount)); NSLog("CUIListBox: Initialized with a maximum of %i entries", iCount);
m_iItemCount = iCount; m_iItemCount = iCount;
m_strItems = memalloc(iCount * sizeof(string)); m_strItems = memalloc(iCount * sizeof(string));
} }

View file

@ -140,7 +140,7 @@ NSXRInput::SetParentSpace(NSXRSpace xrSpace)
void void
NSXRInput::PrintInfo(void) NSXRInput::PrintInfo(void)
{ {
string deviceType; string deviceType = "UNKNOWN";
switch (m_inputType) { switch (m_inputType) {
case XR_INPUT_HEAD: case XR_INPUT_HEAD:

View file

@ -30,7 +30,7 @@
void void
XR_Init(entity ePlayer) XR_Init(entity ePlayer)
{ {
base_client pl = (base_client)ePlayer; NSClient pl = (NSClient)ePlayer;
print("--------- Initializing XR ----------\n"); print("--------- Initializing XR ----------\n");
pl.m_xrSpace = spawn(NSXRSpace); pl.m_xrSpace = spawn(NSXRSpace);
@ -50,7 +50,7 @@ XR_Init(entity ePlayer)
void void
XR_Shutdown(entity ePlayer) XR_Shutdown(entity ePlayer)
{ {
base_client pl = (base_client)ePlayer; NSClient pl = (NSClient)ePlayer;
remove(pl.m_xrInputHead); remove(pl.m_xrInputHead);
remove(pl.m_xrInputLeft); remove(pl.m_xrInputLeft);
remove(pl.m_xrInputRight); remove(pl.m_xrInputRight);
@ -61,7 +61,7 @@ XR_Shutdown(entity ePlayer)
void void
XR_UpdateView(entity ePlayer) XR_UpdateView(entity ePlayer)
{ {
base_client pl = (base_client)ePlayer; NSClient pl = (NSClient)ePlayer;
/* not yet ready */ /* not yet ready */
if (!pl.m_xrSpace) if (!pl.m_xrSpace)
@ -88,7 +88,7 @@ XR_UpdateView(entity ePlayer)
void void
XR_InputFrame(entity ePlayer) XR_InputFrame(entity ePlayer)
{ {
base_client pl = (base_client)ePlayer; NSClient pl = (NSClient)ePlayer;
/* not yet ready */ /* not yet ready */
if (!pl.m_xrSpace) if (!pl.m_xrSpace)
@ -118,8 +118,8 @@ XR_InputFrame(entity ePlayer)
bool bool
XR_Available(entity ePlayer) XR_Available(entity ePlayer)
{ {
base_client pl = (base_client)ePlayer; NSClient pl = (NSClient)ePlayer;
/* we only care about the HMD... otherwise why even bother? */ /* we only care about the HMD... otherwise why even bother? */
return pl.m_xrInputHead.IsAvailable(); return pl.m_xrInputHead.IsAvailable();
} }