Skip to content

Commit

Permalink
add crosshaircolor.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
sauerbraten committed Feb 21, 2021
1 parent ba30ed1 commit 3f00a24
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ apply-patches:
$(PATCH) < patches/include_p1xbraten_menus.patch
$(PATCH) < patches/tex_commands.patch
$(PATCH) < patches/decouple_framedrawing.patch
$(PATCH) < patches/crosshaircolor.patch
unix2dos src/vcpp/sauerbraten.vcxproj

gzip-menus:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This repository contains the source for my client mod, as well as the patches ap
- [listteams.patch](#listteamspatch)
- [tex_commands.patch](#tex_commandspatch)
- [decouple_framedrawing.patch](#decouple_framedrawingpatch)
- [crosshaircolor.patch](#crosshaircolorpatch)
- [Installation](#installation)
- [Windows](#windows)
- [macOS](#macos)
Expand Down Expand Up @@ -141,6 +142,10 @@ Using `maxfps` and `maxtps`, you can optimize for different goals:
- to use fewer resources and save laptop battery, use `/maxfps 0`, `/maxtps 100` and `/vsync 1`
- for lowest consistent latency, use `/maxfps 0`, `/vsync 0`, then set `maxtps` to the highest value that gives you a stable fps counter on your system, then `/vsync 1`

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

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

## Installation

The latest builds are always at https://github.com/sauerbraten/p1xbraten/releases/latest.
Expand Down
26 changes: 26 additions & 0 deletions patches/crosshaircolor.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Index: src/engine/rendergl.cpp
===================================================================
--- src/engine/rendergl.cpp (revision 6490)
+++ src/engine/rendergl.cpp (working copy)
@@ -2079,6 +2098,7 @@
VARP(cursorsize, 0, 30, 50);
VARP(crosshairfx, 0, 1, 1);
VARP(crosshaircolors, 0, 1, 1);
+HVARP(crosshaircolor, 0, 0xFFFFFF, 0xFFFFFF);

#define MAXCROSSHAIRS 4
static Texture *crosshairs[MAXCROSSHAIRS] = { NULL, NULL, NULL, NULL };
@@ -2138,10 +2158,11 @@
}
else
{
- int index = game::selectcrosshair(color);
+ vec chcolor = vec::hexcolor(crosshaircolor);
+ int index = game::selectcrosshair(chcolor);
if(index < 0) return;
if(!crosshairfx) index = 0;
- if(!crosshairfx || !crosshaircolors) color = vec(1, 1, 1);
+ color = crosshairfx && crosshaircolors ? chcolor : vec::hexcolor(crosshaircolor);
crosshair = crosshairs[index];
if(!crosshair)
{
6 changes: 4 additions & 2 deletions src/engine/rendergl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,7 @@ VARP(crosshairsize, 0, 15, 50);
VARP(cursorsize, 0, 30, 50);
VARP(crosshairfx, 0, 1, 1);
VARP(crosshaircolors, 0, 1, 1);
HVARP(crosshaircolor, 0, 0xFFFFFF, 0xFFFFFF);

#define MAXCROSSHAIRS 4
static Texture *crosshairs[MAXCROSSHAIRS] = { NULL, NULL, NULL, NULL };
Expand Down Expand Up @@ -2157,10 +2158,11 @@ void drawcrosshair(int w, int h)
}
else
{
int index = game::selectcrosshair(color);
vec chcolor = vec::hexcolor(crosshaircolor);
int index = game::selectcrosshair(chcolor);
if(index < 0) return;
if(!crosshairfx) index = 0;
if(!crosshairfx || !crosshaircolors) color = vec(1, 1, 1);
color = crosshairfx && crosshaircolors ? chcolor : vec::hexcolor(crosshaircolor);
crosshair = crosshairs[index];
if(!crosshair)
{
Expand Down

0 comments on commit 3f00a24

Please sign in to comment.