From: Freddy Date: Sun, 11 Mar 2018 14:40:12 +0000 (+0100) Subject: trigger_changelevel: replace magic number, whitelist fields X-Git-Tag: xonotic-v0.8.5~2176^2~23 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e37746c9fa46285913ccfde5836f0dd958b7241d;p=xonotic%2Fxonotic-data.pk3dir.git trigger_changelevel: replace magic number, whitelist fields also a bit of comments --- diff --git a/qcsrc/common/triggers/spawnflags.qh b/qcsrc/common/triggers/spawnflags.qh index 50008e182..37551f2c6 100644 --- a/qcsrc/common/triggers/spawnflags.qh +++ b/qcsrc/common/triggers/spawnflags.qh @@ -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); diff --git a/qcsrc/common/triggers/target/changelevel.qc b/qcsrc/common/triggers/target/changelevel.qc index 6c006d42a..114fd8718 100644 --- a/qcsrc/common/triggers/target/changelevel.qc +++ b/qcsrc/common/triggers/target/changelevel.qc @@ -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 diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index ec8c84563..9efefef96 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -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) \