From: Mario Date: Thu, 19 Feb 2015 09:53:12 +0000 (+1100) Subject: Walking through doors with high ping just got awesome X-Git-Tag: xonotic-v0.8.1~38^2~29 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=aae9cb6c8f84ebd4f329787926ececb0c134b47c Walking through doors with high ping just got awesome --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index afca059b16..791a6a0462 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -849,7 +849,6 @@ void CSQC_Ent_Update(float bIsNewEntity) case ENT_CLIENT_TARGET_PUSH: ent_target_push(); break; case ENT_CLIENT_CONVEYOR: ent_conveyor(); break; case ENT_CLIENT_DOOR: ent_door(); break; - case ENT_CLIENT_DOOR_TRIGGER: ent_door_trigger(); break; case ENT_CLIENT_PLAT: ent_plat(); break; case ENT_CLIENT_PLAT_TRIGGER: ent_plat_trigger(); break; case ENT_CLIENT_SWAMP: ent_swamp(); break; diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index d2c5d83ed6..95f94794bc 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -4,6 +4,79 @@ #include "../common/command/generic.qh" +void InitializeEntity(entity e, void(void) func, float order) +{ + entity prev, cur; + + if (!e || e.initialize_entity) + { + // make a proxy initializer entity + entity e_old; + e_old = e; + e = spawn(); + e.classname = "initialize_entity"; + e.enemy = e_old; + } + + e.initialize_entity = func; + e.initialize_entity_order = order; + + cur = initialize_entity_first; + prev = world; + for (;;) + { + if (!cur || cur.initialize_entity_order > order) + { + // insert between prev and cur + if (prev) + prev.initialize_entity_next = e; + else + initialize_entity_first = e; + e.initialize_entity_next = cur; + return; + } + prev = cur; + cur = cur.initialize_entity_next; + } +} +void InitializeEntitiesRun() +{ + entity startoflist; + startoflist = initialize_entity_first; + initialize_entity_first = world; + for (self = startoflist; self; self = self.initialize_entity_next) + { + //self.remove_except_protected_forbidden = 1; + } + for (self = startoflist; self; ) + { + entity e; + var void(void) func; + e = self.initialize_entity_next; + func = self.initialize_entity; + self.initialize_entity_order = 0; + self.initialize_entity = func_null; + self.initialize_entity_next = world; + //self.remove_except_protected_forbidden = 0; + if (self.classname == "initialize_entity") + { + entity e_old; + e_old = self.enemy; + remove(self); + self = e_old; + } + //dprint("Delayed initialization: ", self.classname, "\n"); + if(func) + func(); + else + { + eprint(self); + backtrace(strcat("Null function in: ", self.classname, "\n")); + } + self = e; + } +} + void defer_think() { entity oself; diff --git a/qcsrc/client/miscfunctions.qh b/qcsrc/client/miscfunctions.qh index 4289557551..142d00a238 100644 --- a/qcsrc/client/miscfunctions.qh +++ b/qcsrc/client/miscfunctions.qh @@ -5,6 +5,24 @@ entity players; entity teams; float team_count; // real teams +const int INITPRIO_FIRST = 0; +const int INITPRIO_GAMETYPE = 0; +const int INITPRIO_GAMETYPE_FALLBACK = 1; +const int INITPRIO_FINDTARGET = 10; +const int INITPRIO_DROPTOFLOOR = 20; +const int INITPRIO_SETLOCATION = 90; +const int INITPRIO_LINKDOORS = 91; +const int INITPRIO_LAST = 99; + +.void(void) initialize_entity; +.int initialize_entity_order; +.entity initialize_entity_next; +entity initialize_entity_first; + +void InitializeEntity(entity e, void(void) func, int order); + +void InitializeEntitiesRun(); + void AuditLists(); float RegisterPlayer(entity player); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index ee8ef320ae..f7be34504e 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1738,6 +1738,7 @@ void CSQC_UpdateView(float w, float h) UpdateDamage(); UpdateCrosshair(); UpdateHitsound(); + InitializeEntitiesRun(); if(NextFrameCommand) { diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 47d153c678..47f0381f52 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -108,7 +108,7 @@ const int ENT_CLIENT_TRIGGER_PUSH = 62; const int ENT_CLIENT_TARGET_PUSH = 63; const int ENT_CLIENT_CONVEYOR = 64; const int ENT_CLIENT_DOOR = 65; -const int ENT_CLIENT_DOOR_TRIGGER = 66; +// 66 const int ENT_CLIENT_PLAT = 67; const int ENT_CLIENT_PLAT_TRIGGER = 68; const int ENT_CLIENT_SWAMP = 69; diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 3b831a237c..d08fb84fbd 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -448,7 +448,7 @@ void door_trigger_touch() { if (other.health < 1) #ifdef SVQC - if (!(other.iscreature && !PHYS_DEAD(other))) + if (!((other.iscreature || (other.flags & FL_PROJECTILE)) && !PHYS_DEAD(other))) #elif defined(CSQC) if(!((IS_CLIENT(other) || other.classname == "csqcprojectile") && !PHYS_DEAD(other))) #endif @@ -469,32 +469,6 @@ void door_trigger_touch() door_use (); } -#ifdef SVQC - -float door_trigger_send(entity to, float sf) -{ - WriteByte(MSG_ENTITY, ENT_CLIENT_DOOR_TRIGGER); - - WriteShort(MSG_ENTITY, num_for_edict(self.owner)); - 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); - - return true; -} - -void door_trigger_link(entity trig) -{ - Net_LinkEntity(trig, false, 0, door_trigger_send); -} - void spawn_field(vector fmins, vector fmaxs) { entity trigger; @@ -505,41 +479,18 @@ void spawn_field(vector fmins, vector fmaxs) trigger.movetype = MOVETYPE_NONE; trigger.solid = SOLID_TRIGGER; trigger.owner = self; +#ifdef SVQC trigger.touch = door_trigger_touch; +#elif defined(CSQC) + trigger.trigger_touch = door_trigger_touch; + trigger.draw = trigger_draw_generic; + trigger.drawmask = MASK_NORMAL; +#endif setsize (trigger, t1 - '60 60 8', t2 + '60 60 8'); - door_trigger_link(trigger); } -#elif defined(CSQC) -void ent_door_trigger() -{ - float entnum = ReadShort(); - 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.owner = findfloat(world, sv_entnum, entnum); // if owner doesn't exist, it shouldn't matter much - self.classname = "doortriggerfield"; - self.movetype = MOVETYPE_NONE; - self.solid = SOLID_TRIGGER; - self.trigger_touch = door_trigger_touch; - self.draw = trigger_draw_generic; - self.drawmask = MASK_NORMAL; - self.move_time = time; -} - -#endif -#ifdef SVQC /* ============= LinkDoors @@ -569,13 +520,17 @@ bool LinkDoors_isconnected(entity e1, entity e2, entity pass) return true; } +#ifdef SVQC void door_link(); +#endif void LinkDoors() { entity t; vector cmins, cmaxs; +#ifdef SVQC door_link(); +#endif if (self.enemy) return; // already linked by another door @@ -589,6 +544,7 @@ void LinkDoors() return; if (self.items) return; + spawn_field(self.absmin, self.absmax); return; // don't want to link this door @@ -660,7 +616,7 @@ void LinkDoors() spawn_field(cmins, cmaxs); } - +#ifdef SVQC /*QUAKED spawnfunc_func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE if two doors touch, they are assumed to be connected and operate as a unit. @@ -699,9 +655,6 @@ float door_send(entity to, float sf) { WriteString(MSG_ENTITY, self.classname); WriteByte(MSG_ENTITY, self.spawnflags); - WriteShort(MSG_ENTITY, ((self.owner == self || !self.owner) ? -1 : num_for_edict(self.owner))); - WriteShort(MSG_ENTITY, ((self.enemy == self || !self.enemy) ? -1 : num_for_edict(self.enemy))); - WriteShort(MSG_ENTITY, num_for_edict(self)); WriteByte(MSG_ENTITY, self.scale); @@ -772,6 +725,7 @@ void door_link() FixSize(self); Net_LinkEntity(self, false, 0, door_send); } +#endif void door_init_startopen() { @@ -779,10 +733,10 @@ void door_init_startopen() self.pos2 = self.pos1; self.pos1 = self.origin; +#ifdef SVQC self.SendFlags |= SF_TRIGGER_UPDATE; -} - #endif +} void door_reset() { @@ -877,9 +831,6 @@ void ent_door() { self.classname = strzone(ReadString()); self.spawnflags = ReadByte(); - float myowner = ReadShort(); - float myenemy = ReadShort(); - self.sv_entnum = ReadShort(); self.scale = ReadByte(); @@ -933,10 +884,10 @@ void ent_door() self.use = door_use; self.blocked = door_blocked; - print(ftos(self.entnum), " ", ftos(self.sv_entnum), "\n"); + LinkDoors(); - self.owner = ((myowner == -1) ? self : findfloat(world, sv_entnum, myowner)); - self.enemy = ((myenemy == -1) ? self : findfloat(world, sv_entnum, myenemy)); + if(self.spawnflags & DOOR_START_OPEN) + door_init_startopen(); } if(sf & SF_TRIGGER_RESET) diff --git a/qcsrc/common/triggers/func/door.qh b/qcsrc/common/triggers/func/door.qh index cc508e8d98..b58091b0ad 100644 --- a/qcsrc/common/triggers/func/door.qh +++ b/qcsrc/common/triggers/func/door.qh @@ -11,7 +11,6 @@ const float SPAWNFLAGS_SILVER_KEY = 16; #ifdef CSQC // stuff for preload void ent_door(); -void ent_door_trigger(); // abused .float attack_finished_single;