]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Reset swamp status on respawn
authorMario <mario@smbclan.net>
Sat, 10 Aug 2019 12:44:45 +0000 (22:44 +1000)
committerMario <mario@smbclan.net>
Sat, 10 Aug 2019 12:44:45 +0000 (22:44 +1000)
qcsrc/common/mapobjects/misc/corner.qc
qcsrc/common/mapobjects/misc/dynlight.qc
qcsrc/common/mapobjects/trigger/magicear.qc
qcsrc/common/mapobjects/trigger/swamp.qc
qcsrc/common/mapobjects/trigger/swamp.qh
qcsrc/common/weapons/weapon/tuba.qh
qcsrc/server/client.qc

index a0f67b759b9981c72d7e2e27a5394479c111a275..729f7e236e697e2aaef3a696b2f8d3f94a694e31 100644 (file)
@@ -10,12 +10,26 @@ bool corner_send(entity this, entity to, int sf)
 
        WriteVector(MSG_ENTITY, this.origin);
 
-       WriteString(MSG_ENTITY, this.target);
-       WriteString(MSG_ENTITY, this.target2);
-       WriteString(MSG_ENTITY, this.target3);
-       WriteString(MSG_ENTITY, this.target4);
-       WriteString(MSG_ENTITY, this.targetname);
-       WriteByte(MSG_ENTITY, this.target_random);
+       sf = 0;
+       sf = BITSET(sf, BIT(0), this.target_random);
+
+       sf = BITSET(sf, BIT(1), this.target && this.target != "");
+       sf = BITSET(sf, BIT(2), this.target2 && this.target2 != "");
+       sf = BITSET(sf, BIT(3), this.target3 && this.target3 != "");
+       sf = BITSET(sf, BIT(4), this.target4 && this.target4 != "");
+       sf = BITSET(sf, BIT(5), this.targetname && this.targetname != "");
+
+       WriteByte(MSG_ENTITY, sf);
+       if(sf & BIT(1))
+               WriteString(MSG_ENTITY, this.target);
+       if(sf & BIT(2))
+               WriteString(MSG_ENTITY, this.target2);
+       if(sf & BIT(3))
+               WriteString(MSG_ENTITY, this.target3);
+       if(sf & BIT(4))
+               WriteString(MSG_ENTITY, this.target4);
+       if(sf & BIT(5))
+               WriteString(MSG_ENTITY, this.targetname);
 
        WriteByte(MSG_ENTITY, this.wait);
 
@@ -54,12 +68,14 @@ NET_HANDLE(ENT_CLIENT_CORNER, bool isnew)
        this.origin = ReadVector();
        setorigin(this, this.origin);
 
-       this.target = strzone(ReadString());
-       this.target2 = strzone(ReadString());
-       this.target3 = strzone(ReadString());
-       this.target4 = strzone(ReadString());
-       this.targetname = strzone(ReadString());
-       this.target_random = ReadByte();
+       int targbits = ReadByte();
+       this.target_random = (targbits & BIT(0));
+
+       this.target = ((targbits & BIT(1)) ? strzone(ReadString()) : string_null);
+       this.target2 = ((targbits & BIT(2)) ? strzone(ReadString()) : string_null);
+       this.target3 = ((targbits & BIT(3)) ? strzone(ReadString()) : string_null);
+       this.target4 = ((targbits & BIT(4)) ? strzone(ReadString()) : string_null);
+       this.targetname = ((targbits & BIT(5)) ? strzone(ReadString()) : string_null);
 
        this.wait = ReadByte();
 
index 7c70b8444e0fac5490ff7a0d5cf8882ef1dd59a7..6e9f02b874a2c51610282c881121da037dbfc2c5 100644 (file)
@@ -46,7 +46,7 @@ void dynlight_think(entity this)
 void dynlight_find_aiment(entity this)
 {
        entity targ;
-       if (!this.target)
+       if (!this.target || this.target == "")
                objerror (this, "dynlight: no target to follow");
 
        targ = find(NULL, targetname, this.target);
@@ -62,7 +62,7 @@ void dynlight_find_aiment(entity this)
 void dynlight_find_path(entity this)
 {
        entity targ;
-       if (!this.target)
+       if (!this.target || this.target == "")
                objerror (this, "dynlight: no target to follow");
 
        targ = find(NULL, targetname, this.target);
@@ -74,7 +74,7 @@ void dynlight_find_path(entity this)
 void dynlight_find_target(entity this)
 {
        entity targ;
-       if (!this.target)
+       if (!this.target || this.target == "")
                objerror (this, "dynlight: no target to follow");
 
        targ = find(NULL, targetname, this.target);
index 16118cb9d6e54906ea35f5634d095ad879f2a96f..7321fe23f996a4e50b885194fb3c98fd26e2d8a3 100644 (file)
@@ -1,7 +1,7 @@
 #include "magicear.qh"
 #ifdef SVQC
-float magicear_matched;
-float W_Tuba_HasPlayed(entity pl, .entity weaponentity, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo);
+#include <common/weapons/weapon/tuba.qh>
+bool magicear_matched;
 string trigger_magicear_processmessage(entity ear, entity source, float teamsay, entity privatesay, string msgin)
 {
        float domatch, dotrigger, matchstart, l;
index 0717f4beadd4eeb4aa0ae1c2a7cfcc94af38a0f9..f7d9df2900c4c8c40403ede1f45bc71ea3fcf326 100644 (file)
 
 /*
 *              t_swamp.c
-*              Adds spawnfunc_trigger_swamp and suppoart routines for xonotic 1.2.1+
+*              Adds spawnfunc_trigger_swamp and support routines for nexuiz 1.2.1+ and xonotic
 *              Author tZork (Jakob MG)
 *              jakob@games43.se
 *              2005 11 29
 */
 
-.float swamp_interval; //Hurt players in swamp with this interval
-.float swamp_slowdown; //Players in swamp get slowd down by this mutch 0-1 is slowdown 1-~ is speedup (!?)
-.float swamp_lifetime;  // holds the points remaining until slug dies (not quite health!) 
-.entity swampslug;
-
-#ifdef SVQC
-spawnfunc(trigger_swamp);
-#endif
-void swamp_touch(entity this, entity toucher);
-void swampslug_think(entity this);
-
 
 /*
 * Uses a entity calld swampslug to handle players in the swamp
@@ -46,7 +35,11 @@ void swampslug_think(entity this)
        //Slug dead? then remove curses.
        if(GetResource(this, RES_HEALTH) <= 0)
        {
-               this.owner.in_swamp = 0;
+               if(this.owner.swampslug == this)
+               {
+                       this.owner.in_swamp = false;
+                       this.owner.swampslug = NULL;
+               }
                delete(this);
                //centerprint(this.owner,"Killing slug...\n");
                return;
@@ -72,11 +65,12 @@ void swamp_touch(entity this, entity toucher)
        EXACTTRIGGER_TOUCH(this, toucher);
 
        // Chech if player alredy got a swampslug.
-       if(toucher.in_swamp != 1)
+       if(!toucher.in_swamp)
        {
                // If not attach one.
                //centerprint(toucher,"Entering swamp!\n");
-               toucher.swampslug = spawn();
+               if(!toucher.swampslug) // just incase
+                       toucher.swampslug = spawn();
                toucher.swampslug.swamp_lifetime = 2;
                setthink(toucher.swampslug, swampslug_think);
                toucher.swampslug.nextthink = time;
@@ -84,11 +78,11 @@ void swamp_touch(entity this, entity toucher)
                toucher.swampslug.dmg = this.dmg;
                toucher.swampslug.swamp_interval = this.swamp_interval;
                toucher.swamp_slowdown = this.swamp_slowdown;
-               toucher.in_swamp = 1;
+               toucher.in_swamp = true;
                return;
        }
 
-       //toucher.in_swamp = 1;
+       //toucher.in_swamp = true;
 
        //Revitalize players swampslug
        toucher.swampslug.swamp_lifetime = 2;
@@ -116,8 +110,8 @@ void swamp_link(entity this)
 }
 
 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
-Players gettin into the swamp will
-get slowd down and damaged
+Players in the swamp will be
+slowed down and damaged over time
 */
 spawnfunc(trigger_swamp)
 {
index f4df98378d544659b1c22f0c663919fb95f90c17..bfe860ed03af9561d2c4e37720adb873a4f83438 100644 (file)
@@ -2,7 +2,16 @@
 
 .float swamp_interval; //Hurt players in swamp with this interval
 .float swamp_slowdown; //Players in swamp get slowd down by this mutch 0-1 is slowdown 1-~ is speedup (!?)
-.entity swampslug;
 
-.float in_swamp;              // bool
+.bool in_swamp;
 .entity swampslug;            // Uses this to release from swamp ("untouch" fix)
+
+.float swamp_interval; //Hurt players in swamp with this interval
+.float swamp_slowdown; //Players in swamp get slowd down by this mutch 0-1 is slowdown 1-~ is speedup (!?)
+.float swamp_lifetime;  // holds the points remaining until slug dies (not quite health!)
+
+#ifdef SVQC
+spawnfunc(trigger_swamp);
+#endif
+void swamp_touch(entity this, entity toucher);
+void swampslug_think(entity this);
index f0cb6d2493a471c6724dc31e3ad701f34206d4b6..335326514d76fdfb85dbe49a43734737a11696dd 100644 (file)
@@ -51,3 +51,7 @@ classfield(Tuba) .float tuba_volume;
 classfield(Tuba) .float tuba_volume_initial;
 classfield(Tuba) .int tuba_instrument;
 #endif
+
+#ifdef SVQC
+bool W_Tuba_HasPlayed(entity pl, .entity weaponentity, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo);
+#endif
index f43785bbb2fce697784fb80c1511541d6466fa56..209958389b1fa0f5057f75c54dbec7e395991fc1 100644 (file)
@@ -40,6 +40,7 @@
 #include "../common/mapobjects/teleporters.qh"
 #include "../common/mapobjects/target/spawnpoint.qh"
 #include <common/mapobjects/trigger/counter.qh>
+#include <common/mapobjects/trigger/swamp.qh>
 
 #include "../common/vehicles/all.qh"
 
@@ -678,6 +679,9 @@ void PutPlayerInServer(entity this)
        if(this.conveyor)
                IL_REMOVE(g_conveyed, this);
        this.conveyor = NULL; // prevent conveyors at the previous location from moving a freshly spawned player
+       if(this.swampslug)
+               delete(this.swampslug);
+       this.in_swamp = false;
        STAT(HUD, this) = HUD_NORMAL;
 
        this.event_damage = PlayerDamage;