NET_HANDLE(ENT_CLIENT_AUXILIARYXHAIR, bool isnew)
{
+ int sf = ReadByte();
+
int axh_id = bound(0, ReadByte(), MAX_AXH);
- entity axh = AuxiliaryXhair[axh_id];
+ entity axh = AuxiliaryXhair[axh_id];
- if(axh == NULL || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
+ if(axh == NULL || wasfreed(axh))
{
- axh = spawn();
+ axh = new(auxiliary_crosshair);
axh.draw2d = func_null;
axh.drawmask = MASK_NORMAL;
axh.axh_drawflag = DRAWFLAG_ADDITIVE;
AuxiliaryXhair[axh_id] = axh;
}
- axh.origin_x = ReadCoord();
- axh.origin_y = ReadCoord();
- axh.origin_z = ReadCoord();
- axh.colormod_x = ReadByte() / 255;
- axh.colormod_y = ReadByte() / 255;
- axh.colormod_z = ReadByte() / 255;
+ if(sf & 2)
+ {
+ axh.origin_x = ReadCoord();
+ axh.origin_y = ReadCoord();
+ axh.origin_z = ReadCoord();
+ }
+
+ if(sf & 4)
+ {
+ axh.colormod_x = ReadByte() / 255;
+ axh.colormod_y = ReadByte() / 255;
+ axh.colormod_z = ReadByte() / 255;
+ }
+
axh.cnt = time;
axh.draw2d = AuxiliaryXhair_Draw2D;
if (isnew) IL_PUSH(g_drawables_2d, axh);
return = true;
// hud_id == 0 means we exited a vehicle, so stop alarm sound/s
- if(hud_id == 0)
+ // note: HUD_NORMAL is set to 0 currently too, but we'll check both just in case
+ if(hud_id == 0 || hud_id == HUD_NORMAL)
{
sound(this, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
sound(this, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
+
+ for(int i = 0; i < MAX_AXH; ++i)
+ {
+ entity axh = AuxiliaryXhair[i];
+
+ if(axh != NULL && !wasfreed(axh))
+ {
+ AuxiliaryXhair[i] = NULL;
+ remove(axh);
+ }
+ }
return;
}
bool SendAuxiliaryXhair(entity this, entity to, int sf)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
+ WriteByte(MSG_ENTITY, sf);
WriteByte(MSG_ENTITY, this.cnt);
- WriteCoord(MSG_ENTITY, this.origin_x);
- WriteCoord(MSG_ENTITY, this.origin_y);
- WriteCoord(MSG_ENTITY, this.origin_z);
+ if(sf & 2)
+ {
+ WriteCoord(MSG_ENTITY, this.origin_x);
+ WriteCoord(MSG_ENTITY, this.origin_y);
+ WriteCoord(MSG_ENTITY, this.origin_z);
+ }
- WriteByte(MSG_ENTITY, rint(this.colormod_x * 255));
- WriteByte(MSG_ENTITY, rint(this.colormod_y * 255));
- WriteByte(MSG_ENTITY, rint(this.colormod_z * 255));
+ if(sf & 4)
+ {
+ WriteByte(MSG_ENTITY, rint(this.colormod_x * 255));
+ WriteByte(MSG_ENTITY, rint(this.colormod_y * 255));
+ WriteByte(MSG_ENTITY, rint(this.colormod_z * 255));
+ }
return true;
}
+.vector axh_prevorigin;
+.vector axh_prevcolors;
+
void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
{
if(!IS_REAL_CLIENT(own))
if(axh == NULL || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist? Mario: because of sloppy code like this)
{
- axh = spawn();
- axh.cnt = axh_id;
- axh.drawonlytoclient = own;
- axh.owner = own;
+ axh = new(auxiliary_xhair);
+ axh.cnt = axh_id;
+ axh.drawonlytoclient = own;
+ axh.owner = own;
Net_LinkEntity(axh, false, 0, SendAuxiliaryXhair);
}
- setorigin(axh, loc);
- axh.colormod = clr;
- axh.SendFlags = 0x01;
- own.(AuxiliaryXhair[axh_id]) = axh;
+ if(loc != axh.axh_prevorigin)
+ {
+ setorigin(axh, loc);
+ axh.SendFlags |= 2;
+ }
+
+ if(clr != axh.axh_prevcolors)
+ {
+ axh.colormod = clr;
+ axh.SendFlags |= 4;
+ }
+
+ own.(AuxiliaryXhair[axh_id]) = axh; // set it anyway...?
}
void CSQCVehicleSetup(entity own, int vehicle_id)