Skip to content

Commit

Permalink
add chat_highlight_words.patch
Browse files Browse the repository at this point in the history
closes #22
  • Loading branch information
sauerbraten committed Jun 8, 2021
1 parent d488c7f commit 1da09b1
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 12 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 <cn>` command to check if a player is currently dead (only works when you are spectating)

<div align="center"><img alt="gamehud with player state" src="https://i.imgur.com/eDzdrWp.png" /></div>
<div align="center"><img alt="gamehud with player state" src="https://i.imgur.com/8kfmhSK.gif" /></div>

### [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 <word>` 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

Expand Down
61 changes: 61 additions & 0 deletions patches/chat_highlight_words.patch
Original file line number Diff line number Diff line change
@@ -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<const char *> 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);
12 changes: 2 additions & 10 deletions patches/zenmode.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/engine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/fpsgame/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,10 @@ namespace game

ICOMMAND(servcmd, "C", (char *cmd), addmsg(N_SERVCMD, "rs", cmd));

SVARP(chathighlightsound, "free/itempick");
vector<const char *> chathighlightwords;
ICOMMAND(addchathighlightword, "s", (char *text), chathighlightwords.add(newstring(text)));

static void sendposition(fpsent *d, packetbuf &q)
{
putint(q, N_POS);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/iengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1da09b1

Please sign in to comment.