// player connected
if (!e)
{
- playerslots[i] = e = new(playerslot);
- make_pure(e);
+ playerslots[i] = e = new_pure(playerslot);
}
e.sv_entnum = i;
e.ping = 0;
void TrueAim_Init();
void PostInit()
{
- entity playerchecker = new(playerchecker);
- make_pure(playerchecker);
+ entity playerchecker = new_pure(playerchecker);
playerchecker.think = Playerchecker_Think;
playerchecker.nextthink = time + 0.2;
o = playerslots[this.sv_entnum];
if (!o)
{
- o = playerslots[this.sv_entnum] = new(playerslot);
- make_pure(o);
+ o = playerslots[this.sv_entnum] = new_pure(playerslot);
}
this.owner = o;
o.sv_entnum = this.sv_entnum;
return teamslots[num];
if (!add)
return world;
- entity tm = new(team);
- make_pure(tm);
+ entity tm = new_pure(team);
tm.team = Team;
teamslots[num] = tm;
RegisterTeam(tm);
shownames_ent = LL_NEW();
for (int i = 0; i < maxclients; ++i)
{
- entity e = new(shownames_tag);
- make_pure(e);
+ entity e = new_pure(shownames_tag);
e.sv_entnum = i + 1;
LL_PUSH(shownames_ent, e);
}
entity viewmodel;
STATIC_INIT(viewmodel) {
viewmodel = new(viewmodel);
- make_pure(viewmodel);
}
entity porto;
void Porto_Init()
{
- porto = new(porto);
- make_pure(porto);
+ porto = new_pure(porto);
porto.draw = Porto_Draw;
porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
}
void TrueAim_Init()
{
- trueaim = new(trueaim);
- make_pure(trueaim);
- trueaim.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
- trueaim_rifle = new(trueaim_rifle);
- make_pure(trueaim_rifle);
- trueaim_rifle.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
+ (trueaim = new_pure(trueaim)).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
+ (trueaim_rifle = new_pure(trueaim_rifle)).dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
}
float EnemyHitCheck()
REGISTER_NET_TEMP(net_debug)
#endif
+#ifdef SVQC
+
+#include <server/command/all.qh>
+
+#endif
+
#ifdef CSQC
NET_HANDLE(net_debug, bool isNew)
{
WriteByte(channel, is_pure(this));
vector o = this.origin;
if (o == '0 0 0') // brushes
- o = (this.absmin + this.absmax) / 2;
+ o = (this.absmin + this.absmax) / 2;
+ if (this.tag_entity)
+ o += this.tag_entity.origin;
WriteCoord(channel, o.x); WriteCoord(channel, o.y); WriteCoord(channel, o.z);
WriteString(channel, this.classname);
WriteString(channel, this.sourceLoc);
if (e.origin) continue;
}
if (autocvar_debugdraw == 5)
- {
- if (!e.debug) continue;
- }
+ {
+ if (!e.debug) continue;
+ }
else if (autocvar_debugdraw > 5)
{
bool flag = true;
if (autocvar_debugdraw < 2) continue;
rgb.y = 1;
}
- vector pos = project_3d_to_2d(e.origin);
+ vector o = e.origin;
+ if (e.tag_entity)
+ o += e.tag_entity.origin;
+ vector pos = project_3d_to_2d(o);
if (pos.z < 0) continue;
pos.z = 0;
pos.y += ofs * sz;
for (entity e = NULL; (e = findfloat(e, debug, 0)) && rem > 0; )
{
if (autocvar_debugdraw < 2 && is_pure(e)) continue;
- debug_send(e, nextent(NULL), 0);
+ debug_send(e, caller, 0);
e.debug = true;
--rem;
}
e.draw2d = Trace_draw2d;
}
#endif
+
+#ifdef SVQC
+SERVER_COMMAND(find, "Search through entities for matching classname")
+{
+ switch (request)
+ {
+ case CMD_REQUEST_COMMAND:
+ {
+ for (entity client = NULL; (client = find(client, classname, argv(1))); )
+ LOG_INFO(etos(client), "\n");
+ return;
+ }
+
+ default:
+ LOG_INFO("Incorrect parameters for ^2find^7\n");
+ case CMD_REQUEST_USAGE:
+ {
+ LOG_INFO("\nUsage:^3 sv_cmd find classname\n");
+ LOG_INFO(" Where 'classname' is the classname to search for.\n");
+ return;
+ }
+ }
+}
+
+SERVER_COMMAND(findat, "Search through entities for matching origin")
+{
+ switch (request)
+ {
+ case CMD_REQUEST_COMMAND:
+ {
+ vector match = stov(argv(1));
+ FOREACH_ENTITY_ORDERED(it.origin == match, LAMBDA(LOG_INFOF("%i\n", it)));
+ return;
+ }
+
+ default:
+ LOG_INFO("Incorrect parameters for ^2findat^7\n");
+ case CMD_REQUEST_USAGE:
+ {
+ LOG_INFO("\nUsage:^3 sv_cmd findat \"0 0 0\"\n");
+ return;
+ }
+ }
+}
+#endif
{
if(!eff) { return; }
if(!eff.eent_eff_trail && !eff_cnt) { return; } // effect has no count!
- entity net_eff = new(net_effect);
- make_pure(net_eff);
+ entity net_eff = new_pure(net_effect);
net_eff.owner = eff;
//net_eff.eent_broadcast = broadcast;
net_eff.m_id = eff.m_id;
deathtype |= 0x8000;
e = new(damageinfo);
- make_pure(e);
setorigin(e, org);
e.projectiledeathtype = deathtype;
e.dmg = coredamage;
}
e = new(damage);
- make_pure(e);
setmodel(e, MDL_Null); // necessary to attach and read origin
setattachment(e, self, gettaginfo_name); // attach to the given bone
e.owner = self;
i += 1;
ENTCS_NETPROPS(X);
#undef X
+ setorigin(this, this.origin); // relink
}
void entcs_attach(entity player)
{
entity e = player.entcs = new(entcs_sender);
- make_pure(e);
e.owner = player;
e.think = entcs_think;
e.nextthink = time;
void Inventory_new(entity e)
{
- Inventory inv = new(Inventory), bak = new(Inventory);
- make_pure(inv); make_pure(bak);
+ Inventory inv = new_pure(Inventory), bak = new_pure(Inventory);
inv.inventory = bak;
inv.drawonlytoclient = e;
Net_LinkEntity((inv.owner = e).inventory = inv, false, 0, Inventory_Send);
void name##_hud_status(vector, vector); \
int name##_client_event(entity, string, ...); \
REGISTER_INIT_POST(MINIGAME_##name) { \
- make_pure(this); \
this.netname = strzone(strtolower(#name)); \
this.message = nicename; \
this.minigame_hud_board = name##_hud_board; \
REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
int name##_server_event(entity, string, ...); \
REGISTER_INIT_POST(MINIGAME_##name) { \
- make_pure(this); \
this.netname = strzone(strtolower(#name)); \
this.message = nicename; \
this.minigame_event = name##_server_event; \
)
{
entity wp = new(sprite_waypoint);
- make_pure(wp);
wp.teleport_time = time + _lifetime;
wp.fade_time = _lifetime;
wp.exteriormodeltoclient = ref;
}
void cl_notice_read()
{
- entity _notice = new(sv_notice);
- make_pure(_notice);
+ entity _notice = new_pure(sv_notice);
_notice.netname = strzone(ReadString());
_notice.alpha = ReadLong() + time;
_notice.skin = ReadByte();
}
else
{
- entity net_notif = new(net_notification);
- make_pure(net_notif);
+ entity net_notif = new_pure(net_notification);
net_notif.owner = notif;
net_notif.nent_broadcast = broadcast;
net_notif.nent_client = client;
auto = true; \
__chan = fabs(__chan); \
entity tmp = __e = new(csqc_autochannel); \
- make_pure(tmp); \
tmp.think = SUB_Remove_self; \
tmp.nextthink = time + soundlength(__samp); \
} \
LL_EACH(TargetMusic_list, it.count == id, LAMBDA(e = it; break));
if (!e)
{
- LL_PUSH(TargetMusic_list, e = new(TargetMusic));
- make_pure(e);
+ LL_PUSH(TargetMusic_list, e = new_pure(TargetMusic));
e.count = id;
}
if(e.noise != noi)
spawnfunc(target_push) { target_push_init(this); }
spawnfunc(info_notnull) { target_push_init(this); }
-spawnfunc(target_position) { make_pure(this); target_push_init(this); }
+spawnfunc(target_position) { target_push_init(this); }
#elif defined(CSQC)
NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew)
{
- make_pure(this);
self.classname = "push_target";
self.cnt = ReadByte();
self.targetname = strzone(ReadString());
if(created_saved_value != -1)
{
// creating a new entity to keep track of this cvar
- entity e = new(saved_cvar_value);
- make_pure(e);
+ entity e = new_pure(saved_cvar_value);
e.netname = strzone(tmp_cvar);
e.message = strzone(cvar_string(tmp_cvar));
created_saved_value = 1;
if (!this.weaponchild)
{
this.weaponchild = new(weaponchild);
- make_pure(this.weaponchild);
#ifdef CSQC
this.weaponchild.drawmask = MASK_NORMAL;
this.weaponchild.renderflags |= RF_VIEWMODEL;
sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
- entity meleetemp = new(meleetemp);
- make_pure(meleetemp);
+ entity meleetemp = new_pure(meleetemp);
meleetemp.owner = meleetemp.realowner = actor;
meleetemp.think = W_Shockwave_Melee_Think;
meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready);
- entity meleetemp = new(meleetemp);
- make_pure(meleetemp);
+ entity meleetemp = new_pure(meleetemp);
meleetemp.realowner = actor;
meleetemp.think = W_Shotgun_Melee_Think;
meleetemp.nextthink = time + WEP_CVAR_SEC(shotgun, melee_delay) * W_WeaponRateFactor();
*/
void defer(entity this, float fdelay, void() func)
{
- entity e = new(deferred);
- make_pure(e);
+ entity e = new_pure(deferred);
e.owner = this;
e.use = func;
e.think = defer_think;
.vector origin;
.bool pure_data;
-/** deprecated, use new_pure or NEW(class) */
+/** @deprecated, use new_pure or NEW(class) */
#define make_pure(e) \
MACRO_BEGIN \
{ \
#define SPAWN_PURE 0
#endif
+// pure entities: need no .origin
#if SPAWN_PURE
entity spawn_pure() = #600;
#else
STATIC_INIT(clearentity)
{
_clearentity_ent = new_pure(clearentity);
- make_pure(_clearentity_ent);
}
void clearentity(entity e)
{
entity Sort_Spawn()
{
- entity sort = new(sortlist);
- make_pure(sort);
+ entity sort = new_pure(sortlist);
sort.sort_next = NULL;
sort.chain = sort;
return sort;
// attempts to close will result in a reading handle
// create a writing end that does nothing yet
- e = new(url_single_fopen_file);
- make_pure(e);
+ e = new_pure(url_single_fopen_file);
e.url_url = strzone(url);
e.url_fh = URL_FH_CURL;
e.url_wbuf = buf_create();
// Make a dummy handle object (no buffers at
// all). Wait for data to come from the
// server, then call the callback
- e = new(url_single_fopen_file);
- make_pure(e);
+ e = new_pure(url_single_fopen_file);
e.url_url = strzone(url);
e.url_fh = URL_FH_CURL;
e.url_rbuf = -1;
{
case FILE_WRITE:
case FILE_APPEND:
- e = new(url_single_fopen_stdout);
- make_pure(e);
+ e = new_pure(url_single_fopen_stdout);
e.url_fh = URL_FH_STDOUT;
e.url_ready = rdy;
e.url_ready_pass = pass;
}
else
{
- e = new(url_single_fopen_file);
- make_pure(e);
+ e = new_pure(url_single_fopen_file);
e.url_fh = fh;
e.url_ready = rdy;
e.url_ready_pass = pass;
return;
}
- entity me = new(url_multi);
- make_pure(me);
+ entity me = new_pure(url_multi);
me.url_url = strzone(url);
me.url_attempt = 0;
me.url_mode = mode;
{
if(!WarpZone_trace_transform)
{
- WarpZone_trace_transform = new(warpzone_trace_transform);
- make_pure(WarpZone_trace_transform);
+ WarpZone_trace_transform = new_pure(warpzone_trace_transform);
}
WarpZone_Accumulator_Clear(WarpZone_trace_transform);
}
if(!self.bot_cmd_current)
{
- self.bot_cmd_current = new(bot_cmd);
+ self.bot_cmd_current = new_pure(bot_cmd);
self.bot_cmd_current.is_bot_cmd = true;
}
}
w = new(waypoint);
- make_pure(w);
w.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
w.wpflags = f;
setorigin(w, (m1 + m2) * 0.5);
void ClientData_Attach(entity this)
{
- Net_LinkEntity(this.clientdata = new(clientdata), false, 0, ClientData_Send);
- make_pure(this.clientdata);
+ Net_LinkEntity(this.clientdata = new_pure(clientdata), false, 0, ClientData_Send);
self.clientdata.drawonlytoclient = this;
self.clientdata.owner = this;
}
this.revival_time = 0;
this.air_finished = time + 12;
- entity spawnevent = new(spawnevent);
- make_pure(spawnevent);
+ entity spawnevent = new_pure(spawnevent);
spawnevent.owner = this;
Net_LinkEntity(spawnevent, false, 0.5, SpawnEvent_Send);
void ClientInit_Spawn()
{SELFPARAM();
- entity e = new(clientinit);
- make_pure(e);
+ entity e = new_pure(clientinit);
e.think = ClientInit_CheckUpdate;
Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
}
}
-void GameCommand_find(float request, float argc) // is this even needed? We have prvm_edicts command and such ANYWAY
-{
- switch (request)
- {
- case CMD_REQUEST_COMMAND:
- {
- entity client;
-
- for (client = world; (client = find(client, classname, argv(1))); )
- LOG_INFO(etos(client), "\n");
-
- return;
- }
-
- default:
- LOG_INFO("Incorrect parameters for ^2find^7\n");
- case CMD_REQUEST_USAGE:
- {
- LOG_INFO("\nUsage:^3 sv_cmd find classname\n");
- LOG_INFO(" Where 'classname' is the classname to search for.\n");
- return;
- }
- }
-}
-
void GameCommand_gametype(float request, float argc)
{
switch (request)
SERVER_COMMAND(delrec, "Delete race time record for a map") { GameCommand_delrec(request, arguments); }
SERVER_COMMAND(effectindexdump, "Dump list of effects from code and effectinfo.txt") { GameCommand_effectindexdump(request); }
SERVER_COMMAND(extendmatchtime, "Increase the timelimit value incrementally") { GameCommand_extendmatchtime(request); }
-SERVER_COMMAND(find, "Search through entities for matching classname") { GameCommand_find(request, arguments); }
SERVER_COMMAND(gametype, "Simple command to change the active gametype") { GameCommand_gametype(request, arguments); }
SERVER_COMMAND(gettaginfo, "Get specific information about a weapon model") { GameCommand_gettaginfo(request, arguments); }
SERVER_COMMAND(gotomap, "Simple command to switch to another map") { GameCommand_gotomap(request, arguments); }
void Nagger_Init()
{
- Net_LinkEntity(nagger = new(nagger), false, 0, Nagger_SendEntity);
- make_pure(nagger);
+ Net_LinkEntity(nagger = new_pure(nagger), false, 0, Nagger_SendEntity);
}
void Nagger_VoteChanged()
// initiate the restart-countdown-announcer entity
if (autocvar_sv_ready_restart_after_countdown)
{
- entity restart_timer = new(restart_timer);
- make_pure(restart_timer);
+ entity restart_timer = new_pure(restart_timer);
restart_timer.think = ReadyRestart_think;
restart_timer.nextthink = game_starttime;
}
}
void PingPLReport_Spawn()
{
- pingplreport = new(pingplreport);
- make_pure(pingplreport);
+ pingplreport = new_pure(pingplreport);
pingplreport.think = PingPLReport_Think;
pingplreport.nextthink = time;
}
}
void RandomSeed_Spawn()
{SELFPARAM();
- randomseed = new(randomseed);
- make_pure(randomseed);
+ randomseed = new_pure(randomseed);
randomseed.think = RandomSeed_Think;
Net_LinkEntity(randomseed, false, 0, RandomSeed_Send);
void TeamScore_Spawn(float t, string name)
{
- entity ts = new(csqc_score_team);
- make_pure(ts);
+ entity ts = new_pure(csqc_score_team);
ts.netname = name; // not used yet, FIXME
ts.team = t;
Net_LinkEntity(ts, false, 0, TeamScore_SendEntity);
}
else
{
- scores_initialized = new(ent_client_scoreinfo);
- make_pure(scores_initialized);
+ scores_initialized = new_pure(ent_client_scoreinfo);
Net_LinkEntity(scores_initialized, false, 0, ScoreInfo_SendEntity);
}
if(teams >= 1)
{
if(player.scorekeeper)
error("player already has a scorekeeper");
- entity sk = new(scorekeeper);
- make_pure(sk);
+ entity sk = new_pure(scorekeeper);
sk.owner = player;
Net_LinkEntity(sk, false, 0, PlayerScore_SendEntity);
player.scorekeeper = sk;
// init/free
void accuracy_init(entity e)
{
- entity a = e.accuracy = new(accuracy);
- make_pure(a);
+ entity a = e.accuracy = new_pure(accuracy);
a.owner = e;
a.drawonlytoclient = e;
Net_LinkEntity(a, false, 0, accuracy_send);
void CL_SpawnWeaponentity(entity actor, .entity weaponentity)
{
entity view = actor.(weaponentity) = new(weaponentity);
- make_pure(view);
view.solid = SOLID_NOT;
view.owner = actor;
setmodel(view, MDL_Null); // precision set when changed
if (weaponentity == weaponentities[0])
{
entity exterior = actor.exteriorweaponentity = new(exteriorweaponentity);
- make_pure(exterior);
exterior.solid = SOLID_NOT;
exterior.owner = actor;
setorigin(exterior, '0 0 0');