From 9c0758425f32e8b07e1d44d59a7264d535b78844 Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 9 Jun 2016 20:54:19 +1000 Subject: [PATCH] Wrap customizeentityforclient --- qcsrc/common/gamemodes/gamemode/nexball/nexball.qc | 14 +++++++------- .../gamemodes/gamemode/onslaught/onslaught.qc | 6 +++--- qcsrc/common/minigames/minigames.qc | 2 +- qcsrc/common/minigames/sv_minigames.qc | 6 +++--- qcsrc/common/minigames/sv_minigames.qh | 2 +- qcsrc/common/mutators/mutator/buffs/buffs.qc | 12 ++++++------ qcsrc/common/mutators/mutator/nades/nades.qc | 8 ++++---- .../mutators/mutator/waypoints/waypointsprites.qc | 6 +++--- .../mutators/mutator/waypoints/waypointsprites.qh | 2 +- qcsrc/lib/net.qh | 4 ++-- qcsrc/lib/self.qh | 4 ++++ qcsrc/server/cl_player.qc | 2 +- qcsrc/server/defs.qh | 1 - qcsrc/server/g_subs.qc | 4 ++-- qcsrc/server/g_subs.qh | 2 +- qcsrc/server/miscfunctions.qh | 1 - qcsrc/server/mutators/mutator/gamemode_ctf.qc | 12 ++++++------ qcsrc/server/portals.qc | 6 +++--- qcsrc/server/weapons/weaponsystem.qc | 5 ++--- 19 files changed, 50 insertions(+), 49 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 426cab70e..6c6bcac9e 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -609,8 +609,8 @@ spawnfunc(nexball_football) SpawnBall(this); } -float nb_Goal_Customize() -{SELFPARAM(); +float nb_Goal_Customize(entity this) +{ entity e, wp_owner; e = WaypointSprite_getviewentity(other); wp_owner = self.owner; @@ -629,7 +629,7 @@ void SpawnGoal(entity this) { entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (this.absmin + this.absmax) * 0.5, this, sprite, RADARICON_NONE); wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0.5 0'); - this.sprite.customizeentityforclient = nb_Goal_Customize; + setcefc(this.sprite, nb_Goal_Customize); } this.classname = "nexball_goal"; @@ -838,13 +838,13 @@ void W_Nexball_Attack2(entity actor) CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true); } -float ball_customize() -{SELFPARAM(); +float ball_customize(entity this) +{ if(!self.owner) { self.effects &= ~EF_FLAME; self.scale = 1; - self.customizeentityforclient = func_null; + setcefc(self, func_null); return true; } @@ -948,7 +948,7 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink) { // 'view ball' self.ballcarried.velocity = self.velocity; - self.ballcarried.customizeentityforclient = ball_customize; + setcefc(self.ballcarried, ball_customize); vector org = self.origin + self.view_ofs + v_forward * autocvar_g_nexball_viewmodel_offset.x + diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index 0870ed6bf..1b6433076 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -162,8 +162,8 @@ void FixSize(entity e); // CaptureShield Functions // ======================= -bool ons_CaptureShield_Customize() -{SELFPARAM(); +bool ons_CaptureShield_Customize(entity this) +{ entity e = WaypointSprite_getviewentity(other); if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, e.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return false; } @@ -209,7 +209,7 @@ void ons_CaptureShield_Spawn(entity generator, bool is_generator) shield.colormap = generator.colormap; shield.reset = ons_CaptureShield_Reset; settouch(shield, ons_CaptureShield_Touch); - shield.customizeentityforclient = ons_CaptureShield_Customize; + setcefc(shield, ons_CaptureShield_Customize); shield.effects = EF_ADDITIVE; shield.movetype = MOVETYPE_NOCLIP; shield.solid = SOLID_TRIGGER; diff --git a/qcsrc/common/minigames/minigames.qc b/qcsrc/common/minigames/minigames.qc index 71cf41a3a..0ccbc0e92 100644 --- a/qcsrc/common/minigames/minigames.qc +++ b/qcsrc/common/minigames/minigames.qc @@ -91,7 +91,7 @@ entity msle_spawn(entity minigame_session, string class_name) e.owner = minigame_session; e.minigame_autoclean = 1; #ifdef SVQC - e.customizeentityforclient = minigame_CheckSend; + setcefc(e, minigame_CheckSend); Net_LinkEntity(e, false, 0, minigame_SendEntity); #endif return e; diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index 18e1d3216..bde942616 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -112,8 +112,8 @@ void minigame_resend(entity minigame) } } -bool minigame_CheckSend() -{SELFPARAM(); +bool minigame_CheckSend(entity this) +{ entity e; for ( e = self.owner.minigame_players; e != world; e = e.list_next ) if ( e.minigame_players == other ) @@ -141,7 +141,7 @@ int minigame_addplayer(entity minigame_session, entity player) minigame_session.minigame_players = player_pointer; player.active_minigame = minigame_session; player.minigame_players = player_pointer; - player_pointer.customizeentityforclient = minigame_CheckSend; + setcefc(player_pointer, minigame_CheckSend); Net_LinkEntity(player_pointer, false, 0, minigame_SendEntity); if ( !IS_OBSERVER(player) && autocvar_sv_minigames_observer ) diff --git a/qcsrc/common/minigames/sv_minigames.qh b/qcsrc/common/minigames/sv_minigames.qh index 1e00fd1b3..60785c560 100644 --- a/qcsrc/common/minigames/sv_minigames.qh +++ b/qcsrc/common/minigames/sv_minigames.qh @@ -24,7 +24,7 @@ void end_minigames(); // Only sends entities to players who joined the minigame // Use on customizeentityforclient for gameplay entities -bool minigame_CheckSend(); +bool minigame_CheckSend(entity this); // Check for minigame impulses bool MinigameImpulse(entity this, int imp); diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index c450dc570..731b10ce9 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -92,8 +92,8 @@ REGISTER_MUTATOR(buffs, cvar("g_buffs")) } } -bool buffs_BuffModel_Customize() -{SELFPARAM(); +bool buffs_BuffModel_Customize(entity this) +{ entity player, myowner; bool same_team; @@ -132,7 +132,7 @@ void buffs_BuffModel_Spawn(entity player) player.buff_model.scale = 0.7; player.buff_model.pflags = PFLAGS_FULLDYNAMIC; player.buff_model.light_lev = 200; - player.buff_model.customizeentityforclient = buffs_BuffModel_Customize; + setcefc(player.buff_model, buffs_BuffModel_Customize); } vector buff_GlowColor(entity buff) @@ -389,8 +389,8 @@ void buff_Reset(entity this) buff_Respawn(this); } -float buff_Customize() -{SELFPARAM(); +float buff_Customize(entity this) +{ entity player = WaypointSprite_getviewentity(other); if(!this.buff_active || (this.team && DIFF_TEAM(player, this))) { @@ -432,7 +432,7 @@ void buff_Init(entity this) this.skin = buff.m_skin; this.effects = EF_FULLBRIGHT | EF_STARDUST | EF_NOSHADOW; this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY; - this.customizeentityforclient = buff_Customize; + setcefc(this, buff_Customize); //this.gravity = 100; this.color = buff.m_color; this.glowmod = buff_GlowColor(this); diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 4e339cea0..6fca6178f 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -865,7 +865,7 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) _nade.max_health = _nade.health; _nade.takedamage = DAMAGE_AIM; _nade.event_damage = nade_damage; - _nade.customizeentityforclient = func_null; + setcefc(_nade, func_null); _nade.exteriormodeltoclient = world; _nade.traileffectnum = 0; _nade.teleportable = true; @@ -930,8 +930,8 @@ MUTATOR_HOOKFUNCTION(nades, PutClientInServer) nades_RemoveBonus(self); } -float nade_customize() -{SELFPARAM(); +float nade_customize(entity this) +{ //if(IS_SPEC(other)) { return false; } if(other == self.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == self.exteriormodeltoclient)) { @@ -962,7 +962,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin setmodel(n, MDL_PROJECTILE_NADE); //setattachment(n, player, "bip01 l hand"); n.exteriormodeltoclient = player; - n.customizeentityforclient = nade_customize; + setcefc(n, nade_customize); n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], player.team).eent_eff_name); n.colormod = Nades_from(n.nade_type).m_color; n.realowner = nowner; diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 3e82db0b5..55136ddc5 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -963,8 +963,8 @@ float WaypointSprite_isteammate(entity e, entity e2) return e2 == e; } -float WaypointSprite_Customize() -{SELFPARAM(); +float WaypointSprite_Customize(entity this) +{ // this is not in SendEntity because it shall run every frame, not just every update // make spectators see what the player would see @@ -1022,7 +1022,7 @@ entity WaypointSprite_Spawn( setthink(wp, WaypointSprite_Think); wp.nextthink = time; wp.model1 = spr.netname; - wp.customizeentityforclient = WaypointSprite_Customize; + setcefc(wp, WaypointSprite_Customize); wp.waypointsprite_visible_for_player = WaypointSprite_visible_for_player; wp.reset2 = WaypointSprite_Reset; wp.cnt = icon.m_id; diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh index 385d9fa74..84f028c6e 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh @@ -168,7 +168,7 @@ entity WaypointSprite_getviewentity(entity e); float WaypointSprite_isteammate(entity e, entity e2); -float WaypointSprite_Customize(); +float WaypointSprite_Customize(entity this); bool WaypointSprite_SendEntity(entity this, entity to, float sendflags); diff --git a/qcsrc/lib/net.qh b/qcsrc/lib/net.qh index f0a9cc282..75644b3ad 100644 --- a/qcsrc/lib/net.qh +++ b/qcsrc/lib/net.qh @@ -136,9 +136,9 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); } .void() uncustomizeentityforclient; .float uncustomizeentityforclient_set; - void SetCustomizer(entity e, float() customizer, void() uncustomizer) + void SetCustomizer(entity e, bool(entity this) customizer, void() uncustomizer) { - e.customizeentityforclient = customizer; + setcefc(e, customizer); e.uncustomizeentityforclient = uncustomizer; e.uncustomizeentityforclient_set = !!uncustomizer; } diff --git a/qcsrc/lib/self.qh b/qcsrc/lib/self.qh index 50196a03a..c729a0c8b 100644 --- a/qcsrc/lib/self.qh +++ b/qcsrc/lib/self.qh @@ -72,6 +72,10 @@ SELFWRAP(touch, void, (entity this), (this)) SELFWRAP(predraw, void, (entity this), (this)) #define setpredraw(e, f) SELFWRAP_SET(predraw, e, f) +SELFWRAP(customizeentityforclient, bool, (entity this), (this)) +#define setcefc(e, f) SELFWRAP_SET(customizeentityforclient, e, f) +#define getcefc(e) SELFWRAP_GET(customizeentityforclient, e) + #ifndef MENUQC void adaptor_think2touch(entity this) { WITH(entity, other, NULL, gettouch(this)(this)); } void adaptor_think2use(entity this) { if (this.use) this.use(this, NULL, NULL); } diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 85044c274..42a301eaf 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -95,7 +95,7 @@ void CopyBody(entity this, float keepvelocity) clone.solid = this.solid; clone.ballistics_density = this.ballistics_density; clone.takedamage = this.takedamage; - clone.customizeentityforclient = this.customizeentityforclient; + setcefc(clone, getcefc(this)); clone.uncustomizeentityforclient = this.uncustomizeentityforclient; clone.uncustomizeentityforclient_set = this.uncustomizeentityforclient_set; if (keepvelocity == 1) diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index fd6bf7293..9f7026630 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -179,7 +179,6 @@ bool nJoinAllowed(entity this, entity ignore); float default_player_alpha; float default_weapon_alpha; -.float() customizeentityforclient; .float cvar_cl_handicap; .float cvar_cl_clippedspectating; .float cvar_cl_autoscreenshot; diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index cc4d2c60d..5d4f15616 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -234,8 +234,8 @@ vector findbetterlocation (vector org, float mindist) return org; } -float LOD_customize() -{SELFPARAM(); +float LOD_customize(entity this) +{ if(autocvar_loddebug) { int d = autocvar_loddebug; diff --git a/qcsrc/server/g_subs.qh b/qcsrc/server/g_subs.qh index 1b785c2f2..35d90ffee 100644 --- a/qcsrc/server/g_subs.qh +++ b/qcsrc/server/g_subs.qh @@ -138,7 +138,7 @@ float angc (float a1, float a2); .float loddistance1; .float loddistance2; -float LOD_customize(); +float LOD_customize(entity this); void LOD_uncustomize(); diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 2d52916b1..a5256c9ea 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -366,4 +366,3 @@ entity initialize_entity_first; float sound_allowed(float dest, entity e); void InitializeEntity(entity e, void(entity this) func, float order); -void SetCustomizer(entity e, float() customizer, void() uncustomizer); diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index bb949a49d..cbd527289 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -278,8 +278,8 @@ void ctf_CaptureShield_Update(entity player, bool wanted_status) } } -bool ctf_CaptureShield_Customize() -{SELFPARAM(); +bool ctf_CaptureShield_Customize(entity this) +{ if(!other.ctf_captureshielded) { return false; } if(CTF_SAMETEAM(self, other)) { return false; } @@ -305,7 +305,7 @@ void ctf_CaptureShield_Spawn(entity flag) shield.enemy = self; shield.team = self.team; settouch(shield, ctf_CaptureShield_Touch); - shield.customizeentityforclient = ctf_CaptureShield_Customize; + setcefc(shield, ctf_CaptureShield_Customize); shield.effects = EF_ADDITIVE; shield.movetype = MOVETYPE_NOCLIP; shield.solid = SOLID_TRIGGER; @@ -747,8 +747,8 @@ void ctf_CheckFlagReturn(entity flag, int returntype) } } -bool ctf_Stalemate_Customize() -{SELFPARAM(); +bool ctf_Stalemate_Customize(entity this) +{ // make spectators see what the player would see entity e, wp_owner; e = WaypointSprite_getviewentity(other); @@ -814,7 +814,7 @@ void ctf_CheckStalemate() { entity wp = WaypointSprite_Spawn(((ctf_oneflag) ? WP_FlagCarrier : WP_FlagCarrierEnemy), 0, 0, tmp_entity.owner, FLAG_WAYPOINT_OFFSET, world, 0, tmp_entity.owner, wps_enemyflagcarrier, true, RADARICON_FLAG); wp.colormod = WPCOLOR_ENEMYFC(tmp_entity.owner.team); - tmp_entity.owner.wps_enemyflagcarrier.customizeentityforclient = ctf_Stalemate_Customize; + setcefc(tmp_entity.owner.wps_enemyflagcarrier, ctf_Stalemate_Customize); } } diff --git a/qcsrc/server/portals.qc b/qcsrc/server/portals.qc index f0728b720..9c4b08647 100644 --- a/qcsrc/server/portals.qc +++ b/qcsrc/server/portals.qc @@ -494,8 +494,8 @@ void Portal_Think(entity this) Portal_Remove(this, 0); } -float Portal_Customize() -{SELFPARAM(); +float Portal_Customize(entity this) +{ if(IS_SPEC(other)) other = other.enemy; if(other == this.aiment) @@ -638,7 +638,7 @@ entity Portal_Spawn(entity own, vector org, vector ang) portal.health = autocvar_g_balance_portal_health; setmodel(portal, MDL_PORTAL); portal.savemodelindex = portal.modelindex; - portal.customizeentityforclient = Portal_Customize; + setcefc(portal, Portal_Customize); if(!Portal_FindSafeOrigin(portal)) { diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index d5a89b3a1..d6b155048 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -40,9 +40,8 @@ float W_WeaponSpeedFactor() } -bool CL_Weaponentity_CustomizeEntityForClient() +bool CL_Weaponentity_CustomizeEntityForClient(entity this) { - SELFPARAM(); this.viewmodelforclient = this.owner; if (IS_SPEC(other) && other.enemy == this.owner) this.viewmodelforclient = other; return true; @@ -169,7 +168,7 @@ void CL_SpawnWeaponentity(entity actor, .entity weaponentity) setthink(view, CL_Weaponentity_Think); view.nextthink = time; view.viewmodelforclient = actor; - view.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; + setcefc(view, CL_Weaponentity_CustomizeEntityForClient); if (weaponentity == weaponentities[0]) { -- 2.39.2