]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Walking through doors with high ping just got awesome
authorMario <zacjardine@y7mail.com>
Thu, 19 Feb 2015 09:53:12 +0000 (20:53 +1100)
committerMario <zacjardine@y7mail.com>
Thu, 19 Feb 2015 09:53:12 +0000 (20:53 +1100)
qcsrc/client/main.qc
qcsrc/client/miscfunctions.qc
qcsrc/client/miscfunctions.qh
qcsrc/client/view.qc
qcsrc/common/constants.qh
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/door.qh

index afca059b16b08593169657151f2b2a3b08e3505e..791a6a04622692b688ff7cf5d6c42c15ba69c17c 100644 (file)
@@ -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;
index d2c5d83ed69f2f5cc985fb3539d579d361f4c031..95f94794bcba615d32060fa6e8cab67078316795 100644 (file)
@@ -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;
index 42895575518e5dfd188eb0339224ea1117d14007..142d00a23869f9ae5821c38234bfe15699677ff1 100644 (file)
@@ -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);
index ee8ef320ae4643740f8bb275f848b9436914462f..f7be34504e3c3cabe8f1634994177d9e0093852b 100644 (file)
@@ -1738,6 +1738,7 @@ void CSQC_UpdateView(float w, float h)
        UpdateDamage();
        UpdateCrosshair();
        UpdateHitsound();
+       InitializeEntitiesRun();
 
        if(NextFrameCommand)
        {
index 47d153c67863a722912cef27e076d961c744b58f..47f0381f520f10688fd7e0423b7a51e8f19124df 100644 (file)
@@ -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;
index 3b831a237cdc5e93a0e8019a8a311bec457bf867..d08fb84fbd9e5485153be196fc602340e308f4ef 100644 (file)
@@ -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)
index cc508e8d987d47c07ddd2a4d9f386324ba30e4dd..b58091b0ad8cd76a1ed330b63ce4c3d09e0da205 100644 (file)
@@ -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;