dotrigger = ((IS_PLAYER(source)) && (!IS_DEAD(source)) && ((ear.radius == 0) || (vdist(source.origin - ear.origin, <=, ear.radius))));
domatch = ((ear.spawnflags & 32) || dotrigger);
- if (!domatch)
+ if (!domatch) {
return msgin;
+ }
- if (!msgin)
- {
+ if (!msgin) {
// we are in TUBA mode!
- if (!(ear.spawnflags & 256))
+ if (!(ear.spawnflags & 256)) {
return msgin;
+ }
- for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
- {
+ for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) {
.entity weaponentity = weaponentities[slot];
- if(!W_Tuba_HasPlayed(source, weaponentity, ear.message, ear.movedir_x, !(ear.spawnflags & 512), ear.movedir_y, ear.movedir_z))
+ if (!W_Tuba_HasPlayed(source, weaponentity, ear.message, ear.movedir_x, !(ear.spawnflags & 512), ear.movedir_y, ear.movedir_z)) {
return msgin;
+ }
}
magicear_matched = true;
- if(dotrigger)
- {
+ if (dotrigger) {
savemessage = ear.message;
ear.message = string_null;
SUB_UseTargets(ear, source, NULL);
ear.message = savemessage;
}
- if(ear.netname != "")
+ if (ear.netname != "") {
return ear.netname;
+ }
return msgin;
}
- if(ear.spawnflags & 256) // ENOTUBA
+ if (ear.spawnflags & 256) { // ENOTUBA
return msgin;
+ }
- if(privatesay)
- {
- if(ear.spawnflags & 4)
+ if (privatesay) {
+ if (ear.spawnflags & 4) {
return msgin;
- }
- else
- {
- if(!teamsay)
- if(ear.spawnflags & 1)
+ }
+ } else {
+ if (!teamsay) {
+ if (ear.spawnflags & 1) {
return msgin;
- if(teamsay > 0)
- if(ear.spawnflags & 2)
+ }
+ }
+ if (teamsay > 0) {
+ if (ear.spawnflags & 2) {
return msgin;
- if(teamsay < 0)
- if(ear.spawnflags & 8)
+ }
+ }
+ if (teamsay < 0) {
+ if (ear.spawnflags & 8) {
return msgin;
+ }
+ }
}
matchstart = -1;
l = strlen(ear.message);
- if(ear.spawnflags & 128)
+ if (ear.spawnflags & 128) {
msg = msgin;
- else
+ } else {
msg = strdecolorize(msgin);
+ }
- if(substring(ear.message, 0, 1) == "*")
- {
- if(substring(ear.message, -1, 1) == "*")
- {
+ if (substring(ear.message, 0, 1) == "*") {
+ if (substring(ear.message, -1, 1) == "*") {
// two wildcards
// as we need multi-replacement here...
s = substring(ear.message, 1, -2);
l -= 2;
- if(strstrofs(msg, s, 0) >= 0)
+ if (strstrofs(msg, s, 0) >= 0) {
matchstart = -2; // we use strreplace on s
- }
- else
- {
+ }
+ } else {
// match at start
s = substring(ear.message, 1, -1);
l -= 1;
- if(substring(msg, -l, l) == s)
+ if (substring(msg, -l, l) == s) {
matchstart = strlen(msg) - l;
+ }
}
- }
- else
- {
- if(substring(ear.message, -1, 1) == "*")
- {
+ } else {
+ if (substring(ear.message, -1, 1) == "*") {
// match at end
s = substring(ear.message, 0, -2);
l -= 1;
- if(substring(msg, 0, l) == s)
+ if (substring(msg, 0, l) == s) {
matchstart = 0;
- }
- else
- {
+ }
+ } else {
// full match
s = ear.message;
- if(msg == ear.message)
+ if (msg == ear.message) {
matchstart = 0;
+ }
}
}
- if(matchstart == -1) // no match
+ if (matchstart == -1) { // no match
return msgin;
+ }
magicear_matched = true;
- if(dotrigger)
- {
+ if (dotrigger) {
savemessage = ear.message;
ear.message = string_null;
SUB_UseTargets(ear, source, NULL);
ear.message = savemessage;
}
- if(ear.spawnflags & 16)
- {
+ if (ear.spawnflags & 16) {
return ear.netname;
- }
- else if(ear.netname != "")
- {
- if(matchstart < 0)
+ } else if (ear.netname != "") {
+ if (matchstart < 0) {
return strreplace(s, ear.netname, msg);
- else
+ } else {
return strcat(
substring(msg, 0, matchstart),
ear.netname,
substring(msg, matchstart + l, -1)
);
- }
- else
+ }
+ } else {
return msgin;
+ }
}
entity magicears;
{
entity ear;
string msgout;
- for(ear = magicears; ear; ear = ear.enemy)
- {
+ for (ear = magicears; ear; ear = ear.enemy) {
msgout = trigger_magicear_processmessage(ear, source, teamsay, privatesay, msgin);
- if(!(ear.spawnflags & 64))
- if(magicear_matched)
- return msgout;
+ if (!(ear.spawnflags & 64)) {
+ if (magicear_matched) {
+ return msgout;
+ }
+ }
msgin = msgout;
}
return msgin;