Skip to content

Commit

Permalink
add zenmode.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
sauerbraten committed Feb 25, 2021
1 parent 6a847e1 commit 2e272df
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 11 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ apply-patches:
$(PATCH) < patches/decouple_framedrawing.patch
$(PATCH) < patches/crosshaircolor.patch
$(PATCH) < patches/win_builds.patch
$(PATCH) < patches/zenmode.patch
unix2dos src/vcpp/sauerbraten.nsi
unix2dos src/vcpp/sauerbraten.vcxproj

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This repository contains the source for my client mod, as well as the patches ap
- [tex_commands.patch](#tex_commandspatch)
- [decouple_framedrawing.patch](#decouple_framedrawingpatch)
- [crosshaircolor.patch](#crosshaircolorpatch)
- [zenmode.patch](#zenmodepatch)
- [Installation](#installation)
- [Windows](#windows)
- [macOS](#macos)
Expand Down Expand Up @@ -146,6 +147,13 @@ Using `maxfps` and `maxtps`, you can optimize for different goals:

- adds `crosshaircolor` variable to set a base crosshair color (for example, `/crosshaircolor 0 255 0` for pleasant green)

### [zenmode.patch](./patches/zenmode.patch)

- adds `zenmode` variable: if 1, hides non-essential console messages:
- server messages
- chat and team chat messages from spectators
- joins (all), leaves and renames (of spectators)

## Installation

The latest builds are always at https://github.com/sauerbraten/p1xbraten/releases/latest.
Expand Down
166 changes: 166 additions & 0 deletions patches/zenmode.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
NOTE: builds partly on top of modversion.patch

Index: src/engine/p1xbraten_version.cpp
===================================================================
--- src/engine/p1xbraten_version.cpp (nonexistent)
+++ src/engine/p1xbraten_version.cpp (working copy)
@@ -15,6 +15,12 @@
if(naturalsort(p1xbratenversion, version) == -1)
{
// we're newer, run migrations
+ if(naturalsort(p1xbratenversion, "3.0.0") == -1) {
+ // activate CON_NONZEN in all consoles
+ if(!(confilter&(1<<14))) confilter += 1<<14;
+ if(!(fullconfilter&(1<<14))) fullconfilter += 1<<14;
+ if(!(miniconfilter&(1<<14))) miniconfilter += 1<<14;
+ }
}
setsvar("p1xbratenversion", version);
lockversion();
Index: src/engine/console.cpp
===================================================================
--- src/engine/console.cpp (revision 6491)
+++ src/engine/console.cpp (working copy)
@@ -116,7 +116,8 @@
{
// shuffle backwards to fill if necessary
int idx = offset+i < numl ? offset+i : --offset;
- if(!(conlines[idx].type&filter)) continue;
+ int flags = conlines[idx].type & CON_FLAGS;
+ if((flags&filter)!=flags) continue;
char *line = conlines[idx].line;
int width, height;
text_bounds(line, width, height, conwidth);
@@ -127,7 +128,8 @@
loopi(numl)
{
int idx = offset + (dir > 0 ? numl-i-1 : i);
- if(!(conlines[idx].type&filter)) continue;
+ int flags = conlines[idx].type & CON_FLAGS;
+ if((flags&filter)!=flags) continue;
char *line = conlines[idx].line;
int width, height;
text_bounds(line, width, height, conwidth);
Index: src/fpsgame/ai.cpp
===================================================================
--- src/fpsgame/ai.cpp (revision 6491)
+++ src/fpsgame/ai.cpp (working copy)
@@ -149,7 +149,7 @@
if(!d->name[0])
{
if(aidebug) conoutf(CON_DEBUG, "%s assigned to %s at skill %d", colorname(d, name), o ? colorname(o) : "?", sk);
- else conoutf("\f0join:\f7 %s", colorname(d, name));
+ else conoutf(CON_INFO|CON_NONZEN, "\f0join:\f7 %s", colorname(d, name));
resetthisguy = true;
}
else
Index: src/fpsgame/client.cpp
===================================================================
--- src/fpsgame/client.cpp (revision 6491)
+++ src/fpsgame/client.cpp (working copy)
@@ -445,6 +445,19 @@
ICOMMAND(unignore, "s", (char *arg), unignore(parseplayer(arg)));
ICOMMAND(isignored, "s", (char *arg), intret(isignored(parseplayer(arg)) ? 1 : 0));

+ VARFP(zenmode, 0, 0, 1, {
+ if(zenmode)
+ {
+ if(miniconfilter&CON_NONZEN) miniconfilter -= CON_NONZEN;
+ if(confilter&CON_NONZEN) confilter -= CON_NONZEN;
+ }
+ else
+ {
+ if(!(miniconfilter&CON_NONZEN)) miniconfilter += CON_NONZEN;
+ if(!(confilter&CON_NONZEN)) confilter += CON_NONZEN;
+ }
+ });
+
void setteam(const char *arg1, const char *arg2)
{
int i = parseplayer(arg1);
@@ -1329,7 +1342,7 @@
if(isignored(d->clientnum)) break;
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;
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 + (d->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
{
if(strcmp(d->name, text) && !isignored(d->clientnum))
- conoutf("%s is now known as %s", colorname(d), colorname(d, text));
+ conoutf(d->state==CS_SPECTATOR ? CON_INFO|CON_NONZEN : 0, "%s is now known as %s", colorname(d), colorname(d, text));
}
else // new client
{
- conoutf("\f0join:\f7 %s", colorname(d, text));
+ conoutf(CON_INFO|CON_NONZEN, "\f0join:\f7 %s", colorname(d, text));
if(needclipboard >= 0) needclipboard++;
}
copystring(d->name, text, MAXNAMELEN+1);
@@ -1422,7 +1435,7 @@
if(!text[0]) copystring(text, "unnamed");
if(strcmp(text, d->name))
{
- if(!isignored(d->clientnum)) conoutf("%s is now known as %s", colorname(d), colorname(d, text));
+ if(!isignored(d->clientnum)) conoutf(d->state==CS_SPECTATOR ? CON_INFO|CON_NONZEN : 0, "%s is now known as %s", colorname(d), colorname(d, text));
copystring(d->name, text, MAXNAMELEN+1);
}
}
@@ -1771,7 +1784,7 @@

case N_SERVMSG:
getstring(text, p);
- conoutf("%s", text);
+ conoutf(CON_INFO|CON_NONZEN, "%s", text);
break;

case N_SENDDEMOLIST:
Index: src/fpsgame/fps.cpp
===================================================================
--- src/fpsgame/fps.cpp (revision 6491)
+++ src/fpsgame/fps.cpp (working copy)
@@ -575,7 +575,7 @@
unignore(cn);
fpsent *d = clients[cn];
if(!d) return;
- if(notify && d->name[0]) conoutf("\f4leave:\f7 %s", colorname(d));
+ if(notify && d->name[0]) conoutf(d->state==CS_SPECTATOR ? CON_INFO|CON_NONZEN : 0, "\f4leave:\f7 %s", colorname(d));
removeweapons(d);
removetrackedparticles(d);
removetrackeddynlights(d);
Index: src/fpsgame/game.h
===================================================================
--- src/fpsgame/game.h (revision 6491)
+++ src/fpsgame/game.h (working copy)
@@ -12,7 +12,8 @@
CON_GAMEINFO = 1<<10,
CON_FRAG_SELF = 1<<11,
CON_FRAG_OTHER = 1<<12,
- CON_TEAMKILL = 1<<13
+ CON_TEAMKILL = 1<<13,
+ CON_NONZEN = 1<<14
};

// network quantization scale
Index: src/shared/iengine.h
===================================================================
--- src/shared/iengine.h (revision 6491)
+++ src/shared/iengine.h (working copy)
@@ -201,3 +201,4 @@
+extern int confilter, fullconfilter, miniconfilter;

extern void conoutf(const char *s, ...) PRINTFARGS(1, 2);
extern void conoutf(int type, const char *s, ...) PRINTFARGS(2, 3);
6 changes: 4 additions & 2 deletions src/engine/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ int drawconlines(int conskip, int confade, int conwidth, int conheight, int cono
{
// shuffle backwards to fill if necessary
int idx = offset+i < numl ? offset+i : --offset;
if(!(conlines[idx].type&filter)) continue;
int flags = conlines[idx].type & CON_FLAGS;
if((flags&filter)!=flags) continue;
char *line = conlines[idx].line;
int width, height;
text_bounds(line, width, height, conwidth);
Expand All @@ -130,7 +131,8 @@ int drawconlines(int conskip, int confade, int conwidth, int conheight, int cono
loopi(numl)
{
int idx = offset + (dir > 0 ? numl-i-1 : i);
if(!(conlines[idx].type&filter)) continue;
int flags = conlines[idx].type & CON_FLAGS;
if((flags&filter)!=flags) continue;
char *line = conlines[idx].line;
int width, height;
text_bounds(line, width, height, conwidth);
Expand Down
6 changes: 6 additions & 0 deletions src/engine/p1xbraten_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ void migratep1xbraten()
if(naturalsort(p1xbratenversion, version) == -1)
{
// we're newer, run migrations
if(naturalsort(p1xbratenversion, "3.0.0") == -1) {
// activate CON_NONZEN in all consoles
if(!(confilter&(1<<14))) confilter += 1<<14;
if(!(fullconfilter&(1<<14))) fullconfilter += 1<<14;
if(!(miniconfilter&(1<<14))) miniconfilter += 1<<14;
}
}
setsvar("p1xbratenversion", version);
lockversion();
Expand Down
2 changes: 1 addition & 1 deletion src/fpsgame/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ namespace ai
if(!d->name[0])
{
if(aidebug) conoutf(CON_DEBUG, "%s assigned to %s at skill %d", colorname(d, name), o ? colorname(o) : "?", sk);
else conoutf("\f0join:\f7 %s", colorname(d, name));
else conoutf(CON_INFO|CON_NONZEN, "\f0join:\f7 %s", colorname(d, name));
resetthisguy = true;
}
else
Expand Down
25 changes: 19 additions & 6 deletions src/fpsgame/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,19 @@ namespace game
ICOMMAND(unignore, "s", (char *arg), unignore(parseplayer(arg)));
ICOMMAND(isignored, "s", (char *arg), intret(isignored(parseplayer(arg)) ? 1 : 0));

VARFP(zenmode, 0, 0, 1, {
if(zenmode)
{
if(miniconfilter&CON_NONZEN) miniconfilter -= CON_NONZEN;
if(confilter&CON_NONZEN) confilter -= CON_NONZEN;
}
else
{
if(!(miniconfilter&CON_NONZEN)) miniconfilter += CON_NONZEN;
if(!(confilter&CON_NONZEN)) confilter += CON_NONZEN;
}
});

void setteam(const char *arg1, const char *arg2)
{
int i = parseplayer(arg1);
Expand Down Expand Up @@ -1369,7 +1382,7 @@ namespace game
if(isignored(d->clientnum)) break;
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;
}

Expand All @@ -1382,7 +1395,7 @@ namespace game
if(!t || isignored(t->clientnum)) break;
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 + (d->state==CS_SPECTATOR ? CON_NONZEN : 0), "\fs\f8[team]\fr %s: \f8%s", chatcolorname(t), text);
break;
}

Expand Down Expand Up @@ -1440,11 +1453,11 @@ namespace game
if(d->name[0]) // already connected
{
if(strcmp(d->name, text) && !isignored(d->clientnum))
conoutf("%s is now known as %s", colorname(d), colorname(d, text));
conoutf(d->state==CS_SPECTATOR ? CON_INFO|CON_NONZEN : 0, "%s is now known as %s", colorname(d), colorname(d, text));
}
else // new client
{
conoutf("\f0join:\f7 %s", colorname(d, text));
conoutf(CON_INFO|CON_NONZEN, "\f0join:\f7 %s", colorname(d, text));
if(needclipboard >= 0) needclipboard++;
}
copystring(d->name, text, MAXNAMELEN+1);
Expand All @@ -1462,7 +1475,7 @@ namespace game
if(!text[0]) copystring(text, "unnamed");
if(strcmp(text, d->name))
{
if(!isignored(d->clientnum)) conoutf("%s is now known as %s", colorname(d), colorname(d, text));
if(!isignored(d->clientnum)) conoutf(d->state==CS_SPECTATOR ? CON_INFO|CON_NONZEN : 0, "%s is now known as %s", colorname(d), colorname(d, text));
copystring(d->name, text, MAXNAMELEN+1);
}
}
Expand Down Expand Up @@ -1834,7 +1847,7 @@ namespace game

case N_SERVMSG:
getstring(text, p);
conoutf("%s", text);
conoutf(CON_INFO|CON_NONZEN, "%s", text);
break;

case N_SENDDEMOLIST:
Expand Down
2 changes: 1 addition & 1 deletion src/fpsgame/fps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ namespace game
unignore(cn);
fpsent *d = clients[cn];
if(!d) return;
if(notify && d->name[0]) conoutf("\f4leave:\f7 %s", colorname(d));
if(notify && d->name[0]) conoutf(d->state==CS_SPECTATOR ? CON_INFO|CON_NONZEN : 0, "\f4leave:\f7 %s", colorname(d));
removeweapons(d);
removetrackedparticles(d);
removetrackeddynlights(d);
Expand Down
3 changes: 2 additions & 1 deletion src/fpsgame/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ enum
CON_GAMEINFO = 1<<10,
CON_FRAG_SELF = 1<<11,
CON_FRAG_OTHER = 1<<12,
CON_TEAMKILL = 1<<13
CON_TEAMKILL = 1<<13,
CON_NONZEN = 1<<14
};

// network quantization scale
Expand Down
1 change: 1 addition & 0 deletions src/shared/iengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ enum
};

extern int fullconsole;
extern int confilter, fullconfilter, miniconfilter;

extern void conoutf(const char *s, ...) PRINTFARGS(1, 2);
extern void conoutf(int type, const char *s, ...) PRINTFARGS(2, 3);
Expand Down

0 comments on commit 2e272df

Please sign in to comment.