]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into des/chat_clientref_exp des/chat_clientref_exp
authorDes <xon@damianv.com.ar>
Sun, 1 Sep 2024 21:35:26 +0000 (18:35 -0300)
committerDes <xon@damianv.com.ar>
Sun, 1 Sep 2024 21:39:18 +0000 (18:39 -0300)
1  2 
qcsrc/server/chat.qc

index 26185ac1ffa8d720f8f79ac37d79db5afe369133,154644a37e882afc09bf3f95e3486a0f6f132ca6..b18ff7822ed6b23c6c8bed1f6d3375da7c568246
@@@ -541,52 -549,27 +554,52 @@@ string formatmessage(entity this, strin
  
                .entity weaponentity = weaponentities[0]; // TODO: unhardcode
  
 +#define ON_SLASH() MACRO_BEGIN warn_slash = false; if(escape_token != "\\") break; MACRO_END
 +#define NO_SLASH() MACRO_BEGIN if(escape_token == "\\") break; MACRO_END
 +// TODO: remove warn_slash before next release (xonotic-v0.9.0)
 +// this is only to warn users of backslash expansions for anything other than '\%', '\\' and '\n'
 +              if(escape_token == "\\")
 +                      warn_slash = true;
 +              else
 +                      warn_slash = false;
                switch(escape)
                {
 -                      case "%": replacement = "%"; break;
 -                      case "\\":replacement = "\\"; break;
 -                      case "n": replacement = "\n"; break;
 -                      case "a": replacement = ftos(floor(GetResource(this, RES_ARMOR))); break;
 -                      case "h": replacement = PlayerHealth(this); break;
 -                      case "l": replacement = NearestLocation(this.origin); break;
 -                      case "y": replacement = NearestLocation(cursor); break;
 -                      case "d": replacement = NearestLocation(this.death_origin); break;
 -                      case "o": replacement = vtos(this.origin); break;
 -                      case "O": replacement = sprintf("'%f %f %f'", this.origin.x, this.origin.y, this.origin.z); break;
 -                      case "w": replacement = WeaponNameFromWeaponentity(this, weaponentity); break;
 -                      case "W": replacement = AmmoNameFromWeaponentity(this, weaponentity); break;
 -                      case "x": replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break;
 -                      case "s": replacement = ftos(vlen(this.velocity - this.velocity_z * '0 0 1')); break;
 -                      case "S": replacement = ftos(vlen(this.velocity)); break;
 -                      case "t": replacement = seconds_tostring(ceil(max(0, autocvar_timelimit * 60 + game_starttime - time))); break;
 -                      case "T": replacement = seconds_tostring(floor(time - game_starttime)); break;
 +                      case "%":             replacement = "%"; warn_slash = false; break;
 +                      case "\\":ON_SLASH(); replacement = "\\"; break;
 +                      case "n": ON_SLASH(); replacement = "\n"; break;
 +                      case "a": NO_SLASH(); replacement = ftos(floor(GetResource(this, RES_ARMOR))); break;
 +                      case "h": NO_SLASH(); replacement = PlayerHealth(this); break;
 +                      case "l": NO_SLASH(); replacement = NearestLocation(this.origin); break;
 +                      case "y": NO_SLASH(); replacement = NearestLocation(cursor); break;
 +                      case "d": NO_SLASH(); replacement = NearestLocation(this.death_origin); break;
 +                      case "o": NO_SLASH(); replacement = vtos(this.origin); break;
 +                      case "O": NO_SLASH(); replacement = sprintf("'%f %f %f'", this.origin.x, this.origin.y, this.origin.z); break;
 +                      case "w": NO_SLASH(); replacement = WeaponNameFromWeaponentity(this, weaponentity); break;
-                       case "W": NO_SLASH(); replacement = GetAmmoName(this.(weaponentity).m_weapon.ammo_type); break;
++                      case "W": NO_SLASH(); replacement = AmmoNameFromWeaponentity(this, weaponentity); break;
 +                      case "x": NO_SLASH(); replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break;
 +                      case "s": NO_SLASH(); replacement = ftos(vlen(this.velocity - this.velocity_z * '0 0 1')); break;
 +                      case "S": NO_SLASH(); replacement = ftos(vlen(this.velocity)); break;
 +                      case "t": NO_SLASH(); replacement = seconds_tostring(ceil(max(0, autocvar_timelimit * 60 + game_starttime - time))); break;
 +                      case "T": NO_SLASH(); replacement = seconds_tostring(floor(time - game_starttime)); break;
 +                      case "1":
 +                      case "2":
 +                      case "3":
 +                      case "4":
 +                      case "5":
 +                      case "6":
 +                      case "7":
 +                      case "8":
 +                      case "9":
 +                      {
 +                              NO_SLASH();
 +                              while (msglen > p+escapesize  && IS_DIGIT(substring(msg,p+escapesize,1))) escapesize = escapesize + 1;
 +                              replacement = GetFilteredEntity(substring(msg, p + 1, escapesize)).netname;
 +                              break;
 +                      }
                        default:
                        {
 +                              warn_slash = false; // too noisy
 +                              NO_SLASH();
                                MUTATOR_CALLHOOK(FormatMessage, this, escape, replacement, msg);
                                replacement = M_ARGV(2, string);
                                break;