Skip to content

Commit

Permalink
fix null pointer exception in zenmode.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
sauerbraten committed Feb 27, 2021
1 parent 9e3d75a commit 1610d53
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This repository contains the source for my client mod, as well as the patches ap
- [Menu](#menu)
- [Building your own binary](#building-your-own-binary)
- [Using fresh upstream sources](#using-fresh-upstream-sources)
- [Debugging](#debugging)

## Patches

Expand Down Expand Up @@ -188,9 +189,9 @@ If you do not want to use the p1xbraten menus, execute `/usep1xbratenmenus 0`.

*You don't have to do this if you already followed the installation instructions above and just want to play!*

On Linux and macOS, just run `make install` **inside the src/ directory** (given you installed the usual Sauerbraten dependencies). On Windows, open src/vcpp/sauerbraten.vcxproj with Visual Studio and build in there.
On Linux and macOS, just run `make install` **inside the src/ directory** (given you installed the usual Sauerbraten dependencies). On Windows, open [src/vcpp/sauerbraten.vcxproj](./src/vcpp/sauerbraten.vcxproj) with Visual Studio and build in there.

This will put the resulting binary into the usual place inside this repo. To use it, you have to copy it over to the same place in your actual Sauerbraten installation. On Linux, the [./start.sh](./start.sh) script will launch the new binary from inside this repository, using the Sauerbraten files in $SAUER_DIR and `~/.p1xbraten` as user data directory.
This will put the resulting binary into the usual place inside this repo. To use it, you have to copy it over to the same place in your actual Sauerbraten installation. On Linux, the [start.sh](./start.sh) script will launch the new binary from inside this repository, using the Sauerbraten files in $SAUER_DIR and `~/.p1xbraten` as user data directory.

### Using fresh upstream sources

Expand All @@ -203,3 +204,14 @@ make install
```

`make` will copy the src/ directory from $SAUER_DIR, apply all patches and run `make` inside src/; `make install` will run `make install` inside src/.

### Debugging

On Linux, I replace `-O3` with `-g -rdynamic` in the [Makefile](./src/Makefile), and `exec` with `exec gdb --args` in [start.sh](./start.sh) to set up debugging. Then:

```
make clean && make && make install
./start.sh
```

In gdb, typing `run` starts p1xbraten.
2 changes: 1 addition & 1 deletion patches/zenmode.patch
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Index: src/fpsgame/client.cpp
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);
+ conoutf(CON_TEAMCHAT + (t->state==CS_SPECTATOR ? CON_NONZEN : 0), "\fs\f8[team]\fr %s: \f8%s", chatcolorname(t), text);
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/fpsgame/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1395,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 + (d->state==CS_SPECTATOR ? CON_NONZEN : 0), "\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;
}

Expand Down
1 change: 1 addition & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fi

if [ -x ${SAUER_BIN}/${SYSTEM_NAME}${MACHINE_NAME}client ]
then
#exec gdb --args ${SAUER_BIN}/${SYSTEM_NAME}${MACHINE_NAME}client ${SAUER_OPTIONS} "$@"
exec ${SAUER_BIN}/${SYSTEM_NAME}${MACHINE_NAME}client ${SAUER_OPTIONS} "$@"
else
echo "Your platform does not have a pre-compiled Sauerbraten client."
Expand Down

0 comments on commit 1610d53

Please sign in to comment.