diff --git a/Makefile b/Makefile index ebd25ab..c00ea11 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ apply-patches: $(PATCH) < patches/decouple_framedrawing.patch $(PATCH) < patches/crosshaircolor.patch $(PATCH) < patches/win_builds.patch + $(PATCH) < patches/chat_highlight_words.patch $(PATCH) < patches/zenmode.patch $(PATCH) < patches/authservers.patch $(PATCH) < patches/serverlogging.patch diff --git a/README.md b/README.md index 7c6b469..1d2571a 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ This repository contains the source for my client mod, as well as the patches ap - [authservers.patch](#authserverspatch) - [serverlogging.patch](#serverloggingpatch) - [gamehud.patch](#gamehudpatch) + - [chat_highlight_words.patch](#chat_highlight_wordspatch) - [Installation](#installation) - [Windows](#windows) - [macOS](#macos) @@ -176,7 +177,13 @@ For example, you can put `addauthserver "p1x.pw" "p1x.pw" 28787 "m"` into your ` - adds a useful playerlist showing who's alive vs. dead when spectating in the lower right corner - adds `isdead ` command to check if a player is currently dead (only works when you are spectating) -
gamehud with player state
+
gamehud with player state
+ +### [chat_highlight_words.patch](./patches/chat_highlight_words.patch) + +- lets you define words that trigger a sound when they appear in chat or team chat +- adds `addchathighlightword ` command (for example, put `addchathighlightword pix` and `addchathighlightword p1x` into autoexec.cfg to receive a highlight on both spellings) +- adds `chathighlightsound` variable to set the sound to play (default: `free/itempick`) ## Installation diff --git a/patches/chat_highlight_words.patch b/patches/chat_highlight_words.patch new file mode 100644 index 0000000..bf13fd6 --- /dev/null +++ b/patches/chat_highlight_words.patch @@ -0,0 +1,61 @@ +Index: src/engine/main.cpp +=================================================================== +--- src/engine/main.cpp (revision 6502) ++++ src/engine/main.cpp (working copy) +@@ -909,12 +909,12 @@ + } + } + ++int focused = 0; + void checkinput() + { + if(interceptkeysym) clearinterceptkey(); + //int lasttype = 0, lastbut = 0; + bool mousemoved = false; +- int focused = 0; + while(pumpevents(events)) + { + SDL_Event &event = events.remove(); +Index: src/fpsgame/client.cpp +=================================================================== +--- src/fpsgame/client.cpp (revision 6502) ++++ src/fpsgame/client.cpp (working copy) +@@ -930,6 +930,10 @@ + + ICOMMAND(servcmd, "C", (char *cmd), addmsg(N_SERVCMD, "rs", cmd)); + ++ SVARP(chathighlightsound, "free/itempick"); ++ vector chathighlightwords; ++ ICOMMAND(addchathighlightword, "s", (char *text), chathighlightwords.add(newstring(text))); ++ + static void sendposition(fpsent *d, packetbuf &q) + { + putint(q, N_POS); +@@ -1330,6 +1334,7 @@ + if(d->state!=CS_DEAD && d->state!=CS_SPECTATOR) + particle_textcopy(d->abovehead(), text, PART_TEXT, 2000, 0x32FF64, 4.0f, -8); + conoutf(CON_CHAT, "%s:\f0 %s", chatcolorname(d), text); ++ if(!focused) loopv(chathighlightwords) if(strstr(text, chathighlightwords[i])) { playsoundname(chathighlightsound); break; } + break; + } + +@@ -1343,6 +1348,7 @@ + if(t->state!=CS_DEAD && t->state!=CS_SPECTATOR) + particle_textcopy(t->abovehead(), text, PART_TEXT, 2000, 0x6496FF, 4.0f, -8); + conoutf(CON_TEAMCHAT, "\fs\f8[team]\fr %s: \f8%s", chatcolorname(t), text); ++ if(!focused) loopv(chathighlightwords) if(strstr(text, chathighlightwords[i])) { playsoundname(chathighlightsound); break; } + break; + } + +Index: src/shared/iengine.h +=================================================================== +--- src/shared/iengine.h (revision 6502) ++++ src/shared/iengine.h (working copy) +@@ -248,6 +248,7 @@ + + // main + extern void fatal(const char *s, ...) PRINTFARGS(1, 2); ++extern int focused; // whether or not the application is in focus + + // rendertext + extern bool setfont(const char *name); diff --git a/patches/zenmode.patch b/patches/zenmode.patch index b9efe4a..8e6e2f7 100644 --- a/patches/zenmode.patch +++ b/patches/zenmode.patch @@ -78,24 +78,16 @@ Index: src/fpsgame/client.cpp void setteam(const char *arg1, const char *arg2) { int i = parseplayer(arg1); -@@ -1329,7 +1342,7 @@ - if(isignored(d->clientnum)) break; +@@ -1329,3 +1342,3 @@ if(d->state!=CS_DEAD && d->state!=CS_SPECTATOR) particle_textcopy(d->abovehead(), text, PART_TEXT, 2000, 0x32FF64, 4.0f, -8); - conoutf(CON_CHAT, "%s:\f0 %s", chatcolorname(d), text); + conoutf(CON_CHAT + (d->state==CS_SPECTATOR ? CON_NONZEN : 0), "%s:\f0 %s", chatcolorname(d), text); - break; - } - -@@ -1342,7 +1355,7 @@ - if(!t || isignored(t->clientnum)) break; +@@ -1342,3 +1355,3 @@ if(t->state!=CS_DEAD && t->state!=CS_SPECTATOR) particle_textcopy(t->abovehead(), text, PART_TEXT, 2000, 0x6496FF, 4.0f, -8); - conoutf(CON_TEAMCHAT, "\fs\f8[team]\fr %s: \f8%s", chatcolorname(t), text); + conoutf(CON_TEAMCHAT + (t->state==CS_SPECTATOR ? CON_NONZEN : 0), "\fs\f8[team]\fr %s: \f8%s", chatcolorname(t), text); - break; - } - @@ -1400,11 +1413,11 @@ if(d->name[0]) // already connected { diff --git a/src/engine/main.cpp b/src/engine/main.cpp index cec8a99..ffb3d48 100644 --- a/src/engine/main.cpp +++ b/src/engine/main.cpp @@ -909,12 +909,12 @@ static void checkmousemotion(int &dx, int &dy) } } +int focused = 0; void checkinput() { if(interceptkeysym) clearinterceptkey(); //int lasttype = 0, lastbut = 0; bool mousemoved = false; - int focused = 0; while(pumpevents(events)) { SDL_Event &event = events.remove(); diff --git a/src/fpsgame/client.cpp b/src/fpsgame/client.cpp index d5a2e28..26bf878 100644 --- a/src/fpsgame/client.cpp +++ b/src/fpsgame/client.cpp @@ -983,6 +983,10 @@ namespace game ICOMMAND(servcmd, "C", (char *cmd), addmsg(N_SERVCMD, "rs", cmd)); + SVARP(chathighlightsound, "free/itempick"); + vector chathighlightwords; + ICOMMAND(addchathighlightword, "s", (char *text), chathighlightwords.add(newstring(text))); + static void sendposition(fpsent *d, packetbuf &q) { putint(q, N_POS); @@ -1391,6 +1395,7 @@ namespace game if(d->state!=CS_DEAD && d->state!=CS_SPECTATOR) particle_textcopy(d->abovehead(), text, PART_TEXT, 2000, 0x32FF64, 4.0f, -8); conoutf(CON_CHAT + (d->state==CS_SPECTATOR ? CON_NONZEN : 0), "%s:\f0 %s", chatcolorname(d), text); + if(!focused) loopv(chathighlightwords) if(strstr(text, chathighlightwords[i])) { playsoundname(chathighlightsound); break; } break; } @@ -1404,6 +1409,7 @@ namespace game if(t->state!=CS_DEAD && t->state!=CS_SPECTATOR) particle_textcopy(t->abovehead(), text, PART_TEXT, 2000, 0x6496FF, 4.0f, -8); conoutf(CON_TEAMCHAT + (t->state==CS_SPECTATOR ? CON_NONZEN : 0), "\fs\f8[team]\fr %s: \f8%s", chatcolorname(t), text); + if(!focused) loopv(chathighlightwords) if(strstr(text, chathighlightwords[i])) { playsoundname(chathighlightsound); break; } break; } diff --git a/src/shared/iengine.h b/src/shared/iengine.h index 94c0de2..6531a72 100644 --- a/src/shared/iengine.h +++ b/src/shared/iengine.h @@ -253,6 +253,7 @@ extern void renderentring(const extentity &e, float radius, int axis = 0); // main extern void fatal(const char *s, ...) PRINTFARGS(1, 2); +extern int focused; // whether or not the application is in focus // rendertext extern bool setfont(const char *name);