X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fconveyor.qc;h=b8980a1561aae5f40f5f013233901ec4e0bb1e34;hb=8cbf0e84432e075e617f43c037c645ea9846eba0;hp=4f5a7d6ea591f50b5ffbbf9bca9a3cb6874874a1;hpb=120ad19fdf46b7096a0f90b940e590f1909ad22c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/func/conveyor.qc b/qcsrc/common/triggers/func/conveyor.qc index 4f5a7d6ea..b8980a156 100644 --- a/qcsrc/common/triggers/func/conveyor.qc +++ b/qcsrc/common/triggers/func/conveyor.qc @@ -1,48 +1,50 @@ -void conveyor_think() -{SELFPARAM(); +REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR) + +void conveyor_think(entity this) +{ #ifdef CSQC // TODO: check if this is what is causing the glitchiness when switching between them - float dt = time - self.move_time; - self.move_time = time; + float dt = time - this.move_time; + this.move_time = time; if(dt <= 0) { return; } #endif entity e; - // set myself as current conveyor where possible - for(e = world; (e = findentity(e, conveyor, self)); ) + // set mythis as current conveyor where possible + for(e = world; (e = findentity(e, conveyor, this)); ) e.conveyor = world; - if(self.state) + if(this.state) { - for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain) + for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain) if(!e.conveyor.state) if(isPushable(e)) { vector emin = e.absmin; vector emax = e.absmax; - if(self.solid == SOLID_BSP) + if(this.solid == SOLID_BSP) { emin -= '1 1 1'; emax += '1 1 1'; } - if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick - if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate - e.conveyor = self; + if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick + if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate + e.conveyor = this; } - for(e = world; (e = findentity(e, conveyor, self)); ) + for(e = world; (e = findentity(e, conveyor, this)); ) { if(IS_CLIENT(e)) // doing it via velocity has quite some advantages continue; // done in SV_PlayerPhysics continue; - setorigin(e, e.origin + self.movedir * PHYS_INPUT_FRAMETIME); + setorigin(e, e.origin + this.movedir * PHYS_INPUT_FRAMETIME); move_out_of_solid(e); #ifdef SVQC UpdateCSQCProjectile(e); #endif /* // stupid conveyor code - tracebox(e.origin, e.mins, e.maxs, e.origin + self.movedir * sys_frametime, MOVE_NORMAL, e); + tracebox(e.origin, e.mins, e.maxs, e.origin + this.movedir * sys_frametime, MOVE_NORMAL, e); if(trace_fraction > 0) setorigin(e, trace_endpos); */ @@ -50,148 +52,151 @@ void conveyor_think() } #ifdef SVQC - self.nextthink = time; + this.nextthink = time; #endif } #ifdef SVQC -void conveyor_use() -{SELFPARAM(); - self.state = !self.state; +void conveyor_use(entity this, entity actor, entity trigger) +{ + this.state = !this.state; - self.SendFlags |= 2; + this.SendFlags |= 2; } -void conveyor_reset() -{SELFPARAM(); - self.state = (self.spawnflags & 1); +void conveyor_reset(entity this) +{ + this.state = (this.spawnflags & 1); - self.SendFlags |= 2; + this.SendFlags |= 2; } -bool conveyor_send(entity to, int sf) -{SELFPARAM(); - WriteByte(MSG_ENTITY, ENT_CLIENT_CONVEYOR); +bool conveyor_send(entity this, entity to, int sf) +{ + WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR); WriteByte(MSG_ENTITY, sf); if(sf & 1) { - WriteByte(MSG_ENTITY, self.warpzone_isboxy); - WriteCoord(MSG_ENTITY, self.origin_x); - WriteCoord(MSG_ENTITY, self.origin_y); - WriteCoord(MSG_ENTITY, self.origin_z); - - WriteCoord(MSG_ENTITY, self.mins_x); - WriteCoord(MSG_ENTITY, self.mins_y); - WriteCoord(MSG_ENTITY, self.mins_z); - WriteCoord(MSG_ENTITY, self.maxs_x); - WriteCoord(MSG_ENTITY, self.maxs_y); - WriteCoord(MSG_ENTITY, self.maxs_z); - - WriteCoord(MSG_ENTITY, self.movedir_x); - WriteCoord(MSG_ENTITY, self.movedir_y); - WriteCoord(MSG_ENTITY, self.movedir_z); - - WriteByte(MSG_ENTITY, self.speed); - WriteByte(MSG_ENTITY, self.state); - - WriteString(MSG_ENTITY, self.targetname); - WriteString(MSG_ENTITY, self.target); + WriteByte(MSG_ENTITY, this.warpzone_isboxy); + WriteCoord(MSG_ENTITY, this.origin_x); + WriteCoord(MSG_ENTITY, this.origin_y); + WriteCoord(MSG_ENTITY, this.origin_z); + + WriteCoord(MSG_ENTITY, this.mins_x); + WriteCoord(MSG_ENTITY, this.mins_y); + WriteCoord(MSG_ENTITY, this.mins_z); + WriteCoord(MSG_ENTITY, this.maxs_x); + WriteCoord(MSG_ENTITY, this.maxs_y); + WriteCoord(MSG_ENTITY, this.maxs_z); + + WriteCoord(MSG_ENTITY, this.movedir_x); + WriteCoord(MSG_ENTITY, this.movedir_y); + WriteCoord(MSG_ENTITY, this.movedir_z); + + WriteByte(MSG_ENTITY, this.speed); + WriteByte(MSG_ENTITY, this.state); + + WriteString(MSG_ENTITY, this.targetname); + WriteString(MSG_ENTITY, this.target); } if(sf & 2) - WriteByte(MSG_ENTITY, self.state); + WriteByte(MSG_ENTITY, this.state); return true; } -void conveyor_init() -{SELFPARAM(); - if (!self.speed) - self.speed = 200; - self.movedir = self.movedir * self.speed; - self.think = conveyor_think; - self.nextthink = time; +void conveyor_init(entity this) +{ + if (!this.speed) this.speed = 200; + this.movedir *= this.speed; + setthink(this, conveyor_think); + this.nextthink = time; IFTARGETED { - self.use = conveyor_use; - self.reset = conveyor_reset; - conveyor_reset(); + this.use = conveyor_use; + this.reset = conveyor_reset; + this.reset(this); } else - self.state = 1; + this.state = 1; - FixSize(self); + FixSize(this); - Net_LinkEntity(self, 0, false, conveyor_send); + Net_LinkEntity(this, 0, false, conveyor_send); - self.SendFlags |= 1; + this.SendFlags |= 1; } -void spawnfunc_trigger_conveyor() +spawnfunc(trigger_conveyor) { - SetMovedir(); + SetMovedir(this); EXACTTRIGGER_INIT; - conveyor_init(); + conveyor_init(this); } -void spawnfunc_func_conveyor() -{SELFPARAM(); - SetMovedir(); - InitMovingBrushTrigger(); - self.movetype = MOVETYPE_NONE; - conveyor_init(); +spawnfunc(func_conveyor) +{ + SetMovedir(this); + InitMovingBrushTrigger(this); + this.movetype = MOVETYPE_NONE; + conveyor_init(this); } #elif defined(CSQC) -void conveyor_init() -{SELFPARAM(); - self.draw = conveyor_think; - self.drawmask = MASK_NORMAL; +void conveyor_draw(entity this) { conveyor_think(this); } - self.movetype = MOVETYPE_NONE; - self.model = ""; - self.solid = SOLID_TRIGGER; - self.move_origin = self.origin; - self.move_time = time; +void conveyor_init(entity this) +{ + this.draw = conveyor_draw; + this.drawmask = MASK_NORMAL; + + this.movetype = MOVETYPE_NONE; + this.model = ""; + this.solid = SOLID_TRIGGER; + this.move_origin = this.origin; + this.move_time = time; } -void ent_conveyor() -{SELFPARAM(); - float sf = ReadByte(); +NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew) +{ + int sf = ReadByte(); if(sf & 1) { - self.warpzone_isboxy = ReadByte(); - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); - - self.mins_x = ReadCoord(); - self.mins_y = ReadCoord(); - self.mins_z = ReadCoord(); - self.maxs_x = ReadCoord(); - self.maxs_y = ReadCoord(); - self.maxs_z = ReadCoord(); - setsize(self, self.mins, self.maxs); - - self.movedir_x = ReadCoord(); - self.movedir_y = ReadCoord(); - self.movedir_z = ReadCoord(); - - self.speed = ReadByte(); - self.state = ReadByte(); - - self.targetname = strzone(ReadString()); - self.target = strzone(ReadString()); - - conveyor_init(); + this.warpzone_isboxy = ReadByte(); + this.origin_x = ReadCoord(); + this.origin_y = ReadCoord(); + this.origin_z = ReadCoord(); + setorigin(this, this.origin); + + this.mins_x = ReadCoord(); + this.mins_y = ReadCoord(); + this.mins_z = ReadCoord(); + this.maxs_x = ReadCoord(); + this.maxs_y = ReadCoord(); + this.maxs_z = ReadCoord(); + setsize(this, this.mins, this.maxs); + + this.movedir_x = ReadCoord(); + this.movedir_y = ReadCoord(); + this.movedir_z = ReadCoord(); + + this.speed = ReadByte(); + this.state = ReadByte(); + + this.targetname = strzone(ReadString()); + this.target = strzone(ReadString()); + + conveyor_init(this); } if(sf & 2) - self.state = ReadByte(); + this.state = ReadByte(); + + return true; } #endif