]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
trigger_changelevel: replace magic number, whitelist fields
authorFreddy <schro.sb@gmail.com>
Sun, 11 Mar 2018 14:40:12 +0000 (15:40 +0100)
committerFreddy <schro.sb@gmail.com>
Sun, 11 Mar 2018 14:40:12 +0000 (15:40 +0100)
also a bit of comments

qcsrc/common/triggers/spawnflags.qh
qcsrc/common/triggers/target/changelevel.qc
qcsrc/lib/spawnfunc.qh

index 50008e182501ec8200e744bf7bccd3ae9b6009dc..37551f2c6c95fc75e13bfeb9fd7dad0670519e27 100644 (file)
@@ -80,6 +80,9 @@ const int LASER_INVERT_TEAM = BIT(3);
 const int PLAT_LOW_TRIGGER = BIT(0);
 const int PLAT_CRUSH = BIT(2);
 
+// changelevel
+const int CHANGELEVEL_MULTIPLAYER = BIT(1);
+
 // teleport
 const int TELEPORT_FLAG_SOUND = BIT(0);
 const int TELEPORT_FLAG_PARTICLES = BIT(1);
index 6c006d42a91610e70cd3984bc076cdc61312885c..114fd871818a14e4ea3df07f52584aa88802ec65 100644 (file)
@@ -5,7 +5,7 @@
 
 void target_changelevel_use(entity this, entity actor, entity trigger)
 {
-       if(this.spawnflags & 2)
+       if(this.spawnflags & CHANGELEVEL_MULTIPLAYER)
        {
                // simply don't react if a non-player triggers it
                if(!IS_PLAYER(actor)) { return; }
@@ -33,10 +33,23 @@ void target_changelevel_use(entity this, entity actor, entity trigger)
                localcmd(strcat("changelevel ", this.chmap, "\n"));
 }
 
+/*target_changelevel
+Target to change/end level
+KEYS:
+chmap: map to switch to, leave empty for endmatch
+gametype: gametype for the next map
+count: fraction of real players that need to trigger this entity for levelchange
+SPAWNFLAGS:
+CHANGELEVEL_MULTIPLAYER: multiplayer support
+*/
+
 spawnfunc(target_changelevel)
 {
        this.use = target_changelevel_use;
 
-       if(!this.count) { this.count = 0.7; }
+       if(!this.count)
+       {
+               this.count = 0.7;
+       }
 }
 #endif
index ec8c84563672e4b39c8df629f38831ee3ccf0c35..9efefef96bd5c8ce1cf203976563b5ce46ed4c47 100644 (file)
@@ -163,6 +163,7 @@ noref bool require_spawnfunc_prefix;
                FIELD_SCALAR(fld, bgmscriptsustain) \
                FIELD_SCALAR(fld, bgmscript) \
                FIELD_SCALAR(fld, button0) \
+               FIELD_SCALAR(fld, chmap) \
                FIELD_SCALAR(fld, cnt) \
                FIELD_SCALAR(fld, colormap) \
                FIELD_SCALAR(fld, count) \
@@ -186,6 +187,7 @@ noref bool require_spawnfunc_prefix;
                FIELD_SCALAR(fld, fog) \
                FIELD_SCALAR(fld, frags) \
                FIELD_SCALAR(fld, frame) \
+               FIELD_SCALAR(fld, gametype) \
                FIELD_SCALAR(fld, gametypefilter) \
                FIELD_SCALAR(fld, geomtype) \
                FIELD_SCALAR(fld, gravity) \