]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/chat.qc
Merge branch 'bones_was_here/warmup' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / chat.qc
index 2ed7fa1ed62528b69800e6e1b8ab7d267d5c51c0..41af1de57c1bae1b23c9bbf42111a3f4fcf29a51 100644 (file)
@@ -11,7 +11,9 @@
 #include <server/gamelog.qh>
 #include <server/main.qh>
 #include <server/mapvoting.qh>
-#include <server/miscfunctions.qh>
+#include <server/mutators/_mod.qh>
+#include <server/weapons/tracing.qh>
+#include <server/world.qh>
 
 /**
  * message "": do not say, just test flood control
@@ -29,7 +31,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                msgin = formatmessage(source, msgin);
 
        string colorstr;
-       if (!(IS_PLAYER(source) || source.caplayer))
+       if (!(IS_PLAYER(source) || INGAME(source)))
                colorstr = "^0"; // black for spectators
        else if(teamplay)
                colorstr = Team_ColorCode(source.team);
@@ -60,7 +62,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
 
        string namestr = "";
        if (source)
-               namestr = playername(source, autocvar_g_chat_teamcolors);
+               namestr = playername(source.netname, source.team, (autocvar_g_chat_teamcolors && IS_PLAYER(source)));
 
        string colorprefix = (strdecolorize(namestr) == namestr) ? "^3" : "^7";
 
@@ -93,7 +95,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                        privatemsgprefixlen = strlen(msgstr);
                        msgstr = strcat(msgstr, msgin);
                        cmsgstr = strcat(colorstr, colorprefix, namestr, "^3 tells you:\n^7", msgin);
-                       privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", playername(privatesay, autocvar_g_chat_teamcolors), ": ^7");
+                       privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", playername(privatesay.netname, privatesay.team, (autocvar_g_chat_teamcolors && IS_PLAYER(privatesay))), ": ^7");
                }
                else if(teamsay)
                {
@@ -206,7 +208,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
        {
                if(autocvar_g_chat_flood_notify_flooder)
                {
-                       sourcemsgstr = strcat(msgstr, "\n^3FLOOD CONTROL: ^7message too long, trimmed\n");
+                       sourcemsgstr = strcat(msgstr, "\n^3CHAT FLOOD CONTROL: ^7message too long, trimmed\n");
                        sourcecmsgstr = "";
                }
                else
@@ -222,14 +224,14 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                sourcecmsgstr = cmsgstr;
        }
 
-       if (!privatesay && source && !(IS_PLAYER(source) || source.caplayer) && !game_stopped
+       if (!privatesay && source && !(IS_PLAYER(source) || INGAME(source)) && !game_stopped
                && (teamsay || CHAT_NOSPECTATORS()))
        {
                teamsay = -1; // spectators
        }
 
        if(flood)
-               LOG_INFO("NOTE: ", playername(source, true), "^7 is flooding.");
+               LOG_INFO("NOTE: ", playername(source.netname, source.team, IS_PLAYER(source)), "^7 is flooding.");
 
        // build sourcemsgstr by cutting off a prefix and replacing it by the other one
        if(privatesay)
@@ -245,7 +247,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
        {
                if (autocvar_g_chat_flood_notify_flooder)
                {
-                       sprint(source, strcat("^3FLOOD CONTROL: ^7wait ^1", ftos(source.(flood_field) - time), "^3 seconds\n"));
+                       sprint(source, strcat("^3CHAT FLOOD CONTROL: ^7wait ^1", ftos(source.(flood_field) - time), "^3 seconds\n"));
                        ret = 0;
                }
                else
@@ -256,8 +258,8 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                ret = 1;
        }
 
-       if (privatesay && source && !(IS_PLAYER(source) || source.caplayer) && !game_stopped
-               && (IS_PLAYER(privatesay) || privatesay.caplayer) && CHAT_NOSPECTATORS())
+       if (privatesay && source && !(IS_PLAYER(source) || INGAME(source)) && !game_stopped
+               && (IS_PLAYER(privatesay) || INGAME(privatesay)) && CHAT_NOSPECTATORS())
        {
                ret = -1; // just hide the message completely
        }
@@ -302,7 +304,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                        dedicated_print(msgstr); // send to server console too
                        if(sourcecmsgstr != "")
                                centerprint(source, sourcecmsgstr);
-                       FOREACH_CLIENT((IS_PLAYER(it) || it.caplayer) && IS_REAL_CLIENT(it) && it != source && it.team == source.team && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), {
+                       FOREACH_CLIENT((IS_PLAYER(it) || INGAME(it)) && IS_REAL_CLIENT(it) && it != source && it.team == source.team && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), {
                                sprint(it, msgstr);
                                if(cmsgstr != "")
                                        centerprint(it, cmsgstr);
@@ -313,7 +315,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                {
                        sprint(source, sourcemsgstr);
                        dedicated_print(msgstr); // send to server console too
-                       FOREACH_CLIENT(!(IS_PLAYER(it) || it.caplayer) && IS_REAL_CLIENT(it) && it != source && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), {
+                       FOREACH_CLIENT(!(IS_PLAYER(it) || INGAME(it)) && IS_REAL_CLIENT(it) && it != source && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), {
                                sprint(it, msgstr);
                        });
                        event_log_msg = sprintf(":chat_spec:%d:%s", source.playerid, strreplace("\n", " ", msgin));
@@ -323,7 +325,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                        if (source) {
                                sprint(source, sourcemsgstr);
                                dedicated_print(msgstr); // send to server console too
-                               MX_Say(strcat(playername(source, true), "^7: ", msgin));
+                               MX_Say(strcat(playername(source.netname, source.team, IS_PLAYER(source)), "^7: ", msgin));
                        }
                        FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), {
                                sprint(it, msgstr);