]> git.xonotic.org Git - xonotic/darkplaces.git/log
xonotic/darkplaces.git
2 months agoMerge PR 'Muffle sounds when the player is under water'
bones_was_here [Sun, 10 Mar 2024 16:23:03 +0000 (02:23 +1000)]
Merge PR 'Muffle sounds when the player is under water'

See https://github.com/DarkPlacesEngine/darkplaces/pull/140

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoUnderwater sound filter: simplify code, improve cvar description
bones_was_here [Sun, 10 Mar 2024 16:10:57 +0000 (02:10 +1000)]
Underwater sound filter: simplify code, improve cvar description

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoUnderwater sound filter: fix warning and code style, add function docstring
James O'Neill [Mon, 4 Mar 2024 03:24:07 +0000 (12:24 +0900)]
Underwater sound filter: fix warning and code style, add function docstring

2 months agoAdd underwater sound filter
Daft Mugi [Thu, 29 Feb 2024 10:37:37 +0000 (04:37 -0600)]
Add underwater sound filter

Enabled by default. Use 'snd_waterfx 0' to disable it.

Adapted code from Ironwail so that it works in this engine.

Cherry-picked from daftmugi/wrath-darkplaces

2 months agoREADME.md: add a section about downloading and running DP
bones_was_here [Fri, 8 Mar 2024 02:28:33 +0000 (12:28 +1000)]
README.md: add a section about downloading and running DP

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoMerge PR 'Use Github actions to compile Linux builds'
bones_was_here [Fri, 8 Mar 2024 02:05:37 +0000 (12:05 +1000)]
Merge PR 'Use Github actions to compile Linux builds'

See https://github.com/DarkPlacesEngine/darkplaces/pull/142

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoNew Github workflow file
James O'Neill [Mon, 4 Mar 2024 12:04:12 +0000 (21:04 +0900)]
New Github workflow file

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agosys: allow the platform to handle crashes after DP does
bones_was_here [Thu, 7 Mar 2024 20:31:33 +0000 (06:31 +1000)]
sys: allow the platform to handle crashes after DP does

As suggested by divVerent in chat.
In SDL builds (including when using -dedicated on the cmdline) the OS
handler runs after the user clicks OK on the SDL dialog.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoWork around incomplete C11 support in Microsoft's stddef.h
bones_was_here [Thu, 7 Mar 2024 19:27:14 +0000 (05:27 +1000)]
Work around incomplete C11 support in Microsoft's stddef.h

Closes https://github.com/DarkPlacesEngine/darkplaces/issues/126

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoMake the Sys_Error() message more informative
bones_was_here [Thu, 7 Mar 2024 18:32:06 +0000 (04:32 +1000)]
Make the Sys_Error() message more informative

Re: 24550510e6ff331c1749707df7fad608f618bdd3 as discussed in chat, there
was a good reason to change this word: it indicates DP deliberately
stopped execution, whereas "Error" is generic (most problems that can
happen on a computer are some form of error).  Also "Engine Error"
makes it sound like there's a bug in DP, which isn't necessarily the
case: there are several scenarios where user error can trigger this.
This message was already different from Quake's "Quake Error".

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoRevert renamings from 591877ee0c64958303dcbb4f2af3d343a420cf6a
Cloudwalk [Sat, 2 Mar 2024 17:06:12 +0000 (12:06 -0500)]
Revert renamings from 591877ee0c64958303dcbb4f2af3d343a420cf6a

Pragmatically speaking, absent any good reason otherwise, naming conventions for functions like Sys_Error should remain consistent with Quake for developer sanity.

2 months agoMerge PR 'Force C syntax for qc and qh files on Github'
bones_was_here [Fri, 1 Mar 2024 09:33:45 +0000 (19:33 +1000)]
Merge PR 'Force C syntax for qc and qh files on Github'

See https://github.com/DarkPlacesEngine/darkplaces/pull/135

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoForce C syntax for qc and qh files on Github
James O'Neill [Fri, 1 Mar 2024 09:18:42 +0000 (18:18 +0900)]
Force C syntax for qc and qh files on Github

2 months agosys: prevent loops in signal handlers
bones_was_here [Mon, 26 Feb 2024 18:53:26 +0000 (04:53 +1000)]
sys: prevent loops in signal handlers

Fixes https://gitlab.com/xonotic/xonotic/-/issues/377

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoREADME: add some build notes
bones_was_here [Mon, 26 Feb 2024 15:39:23 +0000 (01:39 +1000)]
README: add some build notes

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agorcon: return the error message when authentication fails
bones_was_here [Mon, 26 Feb 2024 14:55:11 +0000 (00:55 +1000)]
rcon: return the error message when authentication fails

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoCLVM: remove more cruft
bones_was_here [Mon, 26 Feb 2024 11:54:39 +0000 (21:54 +1000)]
CLVM: remove more cruft

These macros were functional originally (see
715bf430b1612f5a4527968b683db80de14f10f9) but are redundant now.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoCLVM: remove cruft
bones_was_here [Mon, 26 Feb 2024 11:40:17 +0000 (21:40 +1000)]
CLVM: remove cruft

Having more than one var tracking one state can lead to bugs.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoPRVM: update program loading messages
bones_was_here [Mon, 26 Feb 2024 10:54:08 +0000 (20:54 +1000)]
PRVM: update program loading messages

This was missed in cfee52a1ec9db338098789cae89ae5cf1f7a6fbf

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoPRVM: refactor error handling
bones_was_here [Sun, 11 Feb 2024 13:54:39 +0000 (23:54 +1000)]
PRVM: refactor error handling

Cleans up PRVM_Crash() calling and removes redundant code.
Directs menu errors to stderr instead of stdout.
Aborts if a loop is detected in MVM_error_cmd(), matching Host_Error().
Prevents QC's CSQC_Shutdown() being called when CSQC crashes.
Makes cvar prvm_errordump ignore MENUQC crashes.
Improves some messages and comments.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoPRVM: don't break csqc when menuqc has a problem
bones_was_here [Sun, 25 Feb 2024 22:27:35 +0000 (08:27 +1000)]
PRVM: don't break csqc when menuqc has a problem

Fixes a regression in 3d84db99ed9d8234809d237512f44cfa6d7ce1a0 caused by
moving this line such that it executes even for MVM errors. We don't
need it because it's done by Host_Error->CL_DisconnectEx->CL_VM_ShutDown

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
2 months agoMVM: fix endless loop when a command causes an error
bones_was_here [Sun, 25 Feb 2024 22:34:08 +0000 (08:34 +1000)]
MVM: fix endless loop when a command causes an error

7e1f7d12f57c064a6855d9850d28387ca6092c45 should have included this.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoFix changing of player name during a game
bones_was_here [Fri, 9 Feb 2024 08:12:34 +0000 (18:12 +1000)]
Fix changing of player name during a game

Name changes applied when connecting or when the map changed, but not
during the game.
I broke it in 74b49d6e5412af206448119963e0a4b3617e8ca4 by not
noticing the user-visible name of the cvar is used to determine which
command (if any) is sent.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoFix two memory allocation issues
bones_was_here [Fri, 9 Feb 2024 09:14:59 +0000 (19:14 +1000)]
Fix two memory allocation issues

In fa06dd40f48b20d738b6bd604758c81defd76cfd I misunderstood the
subdivision code, causing sentinel2 to be written past the end of the
buffer... somehow many maps and games worked fine despite this. This
commit reverts the bad line from that commit.

A very old (div0-stable) bug when loading Q1BSP meant we didn't allocate
enough texture memory when a "sky" texture name wasn't all lowercase,
causing a crash when loading custom map e2m9.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoCLVM: set mapname global correctly (matching SVVM)
bones_was_here [Fri, 9 Feb 2024 07:09:14 +0000 (17:09 +1000)]
CLVM: set mapname global correctly (matching SVVM)

This is an old bug but the code Nexuiz and Xonotic used to work around
it still gives correct results when the prefix and suffix are already
stripped.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agochangelevel: start a map even if none is running
bones_was_here [Fri, 9 Feb 2024 06:53:14 +0000 (16:53 +1000)]
changelevel: start a map even if none is running

Implements https://gitlab.com/xonotic/darkplaces/-/issues/408

Although the original implementation of this convenience
688396cea66f09e7ce20d3e3b077261dd1d3db7e labeled it as a hack, it was
robust, simple and worked fine in div0-stable, so removing it in
cb11bdeed238603b11d8dac4908cfdbabe298079 was a regression.

Also removes some redundant string copying.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoserver: always use correct case for map names
bones_was_here [Thu, 8 Feb 2024 20:21:05 +0000 (06:21 +1000)]
server: always use correct case for map names

Previously whatever was typed in as the map/changelevel argument was
used even if it didn't match the case of the filename in the pak, which
meant QC could see multiple instances of the same map that differed only
by case, causing problems for gameplay stats.

Now DP will always use the same case as the real .bsp filename for the
`mapname` globals, and the sv_world* and cl_world* cvars, and the server
status and getinfo/getstatus responses.  This matches the behaviour of
QC code which retrieved the name from the VFS, such as the `gotomap` and
voting code in Nexuiz and Xonotic.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agorcon: rewrite variable expansion support, related fixes
bones_was_here [Wed, 7 Feb 2024 16:21:51 +0000 (02:21 +1000)]
rcon: rewrite variable expansion support, related fixes

Fixes https://gitlab.com/xonotic/darkplaces/-/issues/407
In 48d83538ef13596d4569d46ae66467b63b945546 I broke the return of the
rcon command output to the client.

Fixes unterminated string warnings on the server when the
rcon_password feature of multiple space-delimited passwords is used.
Fixes possibility of the cbuf to use more memory than its intended
maximum.

In the client you can send the variable such that the server will
expand it (not the client) like this: rcon echo $$sv_worldmessage

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agosnd: fix a hard-to-repro segfault when joining a server
bones_was_here [Wed, 7 Feb 2024 15:11:27 +0000 (01:11 +1000)]
snd: fix a hard-to-repro segfault when joining a server

Closes https://gitlab.com/xonotic/darkplaces/-/issues/356

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoSVVM: Fix segfault during shutdown, improve previous commit
bones_was_here [Wed, 7 Feb 2024 14:19:05 +0000 (00:19 +1000)]
SVVM: Fix segfault during shutdown, improve previous commit

In 30c47b1aff3ac28359c469a40c44ee700c80e814 a bug in SVVM_reset_cmd was
revealed because that code never ran before that commit:
sometimes the server segfaulted at end of match because SVVM_reset_cmd
called QC code even though SVVM_reset_cmd would only be called by
PRVM_Prog_Reset after it had freed the tempstring memory... so if QC
created a tempstring, crash.

This commit refactors the SV VM shutdown to be consistent with the CL
and MENU shutdown by moving the QC SV_Shutdown() call into a separate
func that (optionally) resets the VM afterwards.  As per
30c47b1aff3ac28359c469a40c44ee700c80e814 we MUST reset when stopping a
server to avoid crashes later, but we can still skip it when changing
map (like in previous versions).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoRemove a bit of cruft left in Cvar_RestoreInitState()
bones_was_here [Tue, 6 Feb 2024 16:16:07 +0000 (02:16 +1000)]
Remove a bit of cruft left in Cvar_RestoreInitState()

A leftover from debugging 32c99c7b0a58545b273fa713d81d6bbfb3b8ebe6

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoXonotic: don't hide config problems during startup
bones_was_here [Tue, 6 Feb 2024 14:37:31 +0000 (00:37 +1000)]
Xonotic: don't hide config problems during startup

Hiding problems is only desirable for games that will never be patched.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoElvis has left the building
bones_was_here [Tue, 6 Feb 2024 13:25:08 +0000 (23:25 +1000)]
Elvis has left the building

Apparently MICROS~1 still doesn't support this (clang and gcc do).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPRVM: clarify tempstring messages
bones_was_here [Tue, 6 Feb 2024 11:55:10 +0000 (21:55 +1000)]
PRVM: clarify tempstring messages

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoSVVM: fully shut down when stopping a server to avoid segfaulting later
bones_was_here [Tue, 6 Feb 2024 11:22:06 +0000 (21:22 +1000)]
SVVM: fully shut down when stopping a server to avoid segfaulting later

Fixes segfaults when functions that check if the progs is loaded (to
avoid crashing) are called after stopping a server.
Example repro: load a map, disconnect, `set sv_cheats 0`.

Fixes wrong SV_Shutdown order: SV_DropClient must be done before
shutting down SVQC because it calls SVQC functions.

Deduplicates SVQC shutdown.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agofs: fix Quake expansions getting unloaded when adding a gamedir
bones_was_here [Tue, 6 Feb 2024 09:31:45 +0000 (19:31 +1000)]
fs: fix Quake expansions getting unloaded when adding a gamedir

It would switch back to Quake (from eg Rogue) even when the gamedir
being added didn't match any from a supported Quake expansion/mod.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agofs: save files in the correct place when gamedir(s) are in use
bones_was_here [Mon, 5 Feb 2024 22:59:24 +0000 (08:59 +1000)]
fs: save files in the correct place when gamedir(s) are in use

As per the description of the `gamedir` command, it's expected that a
gamedir can be added without needing to re-add the primary
(gamedirname1) or secondary/mod (gamedirname2) as the last gamedir just
to ensure that files still get saved there as usual.

Closes https://gitlab.com/xonotic/darkplaces/-/issues/210

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agosv_cheats: fix two segfaults when setting it to 0
bones_was_here [Mon, 5 Feb 2024 20:38:45 +0000 (06:38 +1000)]
sv_cheats: fix two segfaults when setting it to 0

Assuming the SVQC program is always running crashes when it's not.

Testing if the edict pointer is NULL isn't a valid way to stop at the
end of the client slots, which caused this to crash when Xonotic SVQC
was running.

See 1814b2df58302baa47df6718b09465265dfc7e5c

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agocvar: fix many bugs in gamedir, loadconfig, unset, cvar_resettodefaults* commands
bones_was_here [Sun, 4 Feb 2024 16:18:03 +0000 (02:18 +1000)]
cvar: fix many bugs in gamedir, loadconfig, unset, cvar_resettodefaults* commands

Fixes a segfault when Cvar_RestoreInitState() deleted cvars (null ptr deref).

Fixes an infinite loop in Host_LoadConfig_f() due to calling Cbuf_Execute()
from inside Cbuf_Execute() via Host_AddConfigText().

Fixes `unset` being able to delete autocvars while they're in use by QC.
Fixes Cvar_RestoreInitState() not updating autocvars when necessary.

Fixes Cvar_RestoreInitState() not calling cvar callbacks.

Fixes Cvar_RestoreInitState() sometimes restoring such that .string
doesn't match .value, or such that .defstring is wrong.  This was caused
by Cvar_SaveInitState() saving only string pointers and not strings.

Fixes CF_READONLY cvars like gl_info_* getting restored/reset. It
doesn't make sense for any of these to be changed by code outside their
own subsystems.

Fixes Xonotic menu QC errors caused by Host_LoadConfig_f deleting cvars
before calling QC's m_shutdown().

Deduplicates and simplifies cvar deletion code, see also
05a5ed884366d3a1c8e211168efc19b61867cfca

Saves a little memory by storing only minimal init state data for
Cvar_RestoreInitState(), and by relaxing alignment requirements in
_Mem_strdup().

Improves some warns and docs and tidies up a little.

Removes `vid_restart` from `gamedir`, it usually isn't needed because
current DP applies many vid_ cvar changes without it, and because of
the ubiquity of flat panel displays.

Fixes https://gitlab.com/xonotic/darkplaces/-/issues/354

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agorender: merge R_View_UpdateWithScissor() and R_View_Update()
bones_was_here [Thu, 1 Feb 2024 10:05:07 +0000 (20:05 +1000)]
render: merge R_View_UpdateWithScissor() and R_View_Update()

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoFix some mingw warnings
bones_was_here [Tue, 30 Jan 2024 12:07:39 +0000 (22:07 +1000)]
Fix some mingw warnings

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoWork around Microsoft's broken vsnprintf implementation
bones_was_here [Tue, 30 Jan 2024 11:38:52 +0000 (21:38 +1000)]
Work around Microsoft's broken vsnprintf implementation

Microsoft's documentation says it has supported %zu (C99 standard format
for size_t) for some years but trying to use it causes crashes at least
on older versions of Windows.

Makes dpsnprintf and dpvsnprintf documentation more accessible (these
funcs have different return behaviour than the C standard ones).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agomeshentities: don't pass a NULL ptr to memset
bones_was_here [Fri, 26 Jan 2024 08:29:54 +0000 (18:29 +1000)]
meshentities: don't pass a NULL ptr to memset

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoZYM: fix misaligned memory access
bones_was_here [Mon, 29 Jan 2024 13:54:05 +0000 (23:54 +1000)]
ZYM: fix misaligned memory access

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPSK/PSA: fix misaligned memory access
bones_was_here [Mon, 29 Jan 2024 13:23:43 +0000 (23:23 +1000)]
PSK/PSA: fix misaligned memory access

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoQ2BSP: fix misaligned memory access
bones_was_here [Fri, 26 Jan 2024 10:10:14 +0000 (20:10 +1000)]
Q2BSP: fix misaligned memory access

Fixes a small overallocation (sizeof(int *) instead of int).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoQ1BSP: fix misaligned memory access
bones_was_here [Fri, 26 Jan 2024 09:36:24 +0000 (19:36 +1000)]
Q1BSP: fix misaligned memory access

Fixes a small overallocation (sizeof(int *) instead of int).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agosprite: fix misaligned memory access while loading
bones_was_here [Mon, 29 Jan 2024 08:27:48 +0000 (18:27 +1000)]
sprite: fix misaligned memory access while loading

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoDPM: fix misaligned memory access
bones_was_here [Fri, 26 Jan 2024 07:20:53 +0000 (17:20 +1000)]
DPM: fix misaligned memory access

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoMD3: fix misaligned memory access
bones_was_here [Fri, 26 Jan 2024 06:58:50 +0000 (16:58 +1000)]
MD3: fix misaligned memory access

The memory subdivision was ordered such that this format likely had no
issues on a 32-bit machine but on 64-bit the alignment requirement of
texture_t increases to 8 bytes, invoking undefined behaviour.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoIQM: fix misaligned memory access while loading
bones_was_here [Fri, 26 Jan 2024 04:38:36 +0000 (14:38 +1000)]
IQM: fix misaligned memory access while loading

Parsing uses the memcpy approach (already used for the header), slower
than direct reads via hard-coded offsets but more readable and robust.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoIQM: fix misaligned memory access
bones_was_here [Mon, 29 Jan 2024 06:40:48 +0000 (16:40 +1000)]
IQM: fix misaligned memory access

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoUpdate and micro-optimise memory allocation
bones_was_here [Thu, 25 Jan 2024 06:25:48 +0000 (16:25 +1000)]
Update and micro-optimise memory allocation

The max alignment requirement no longer needs to be hard-coded.
We were allocating slightly more than necessary for alignment padding.
Makes a (currently unused) macro more useful and robust.
Fixes bitfield data type.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPRVM: Fix a hack in LNO file loading
bones_was_here [Fri, 26 Jan 2024 08:16:48 +0000 (18:16 +1000)]
PRVM: Fix a hack in LNO file loading

This caused misaligned memory access.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoFix signed int overflows and tidy nearby documentation
bones_was_here [Tue, 23 Jan 2024 22:10:40 +0000 (08:10 +1000)]
Fix signed int overflows and tidy nearby documentation

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agor_shadow: work around a realtime world light crash
bones_was_here [Tue, 23 Jan 2024 01:00:01 +0000 (11:00 +1000)]
r_shadow: work around a realtime world light crash

Fudges a bit more memory to support edge cases, prints a warn instead of
crashing if it's not enough.

see https://github.com/DarkPlacesEngine/darkplaces/issues/119
and 46964b3848eb7471d2f0e2284ae389b4b53337c1

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoMakefile: optimise debug builds somewhat
bones_was_here [Tue, 23 Jan 2024 05:43:48 +0000 (15:43 +1000)]
Makefile: optimise debug builds somewhat

Also fixes warning spam in debug builds.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agosys: refactor the clean shutdown process
bones_was_here [Mon, 22 Jan 2024 21:58:45 +0000 (07:58 +1000)]
sys: refactor the clean shutdown process

After all the other refactors finally we can clean this up.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agosys: improve error and crash handling
bones_was_here [Sun, 21 Jan 2024 21:52:26 +0000 (07:52 +1000)]
sys: improve error and crash handling

Renames Sys_Error to Sys_Abort (now using the Engine Abort message) for
clarity (as distinct from the non-fatal Host_Error).

Includes the engine version in the Crash and Abort SDL dialogs.

Linux: includes the glibc backtrace in the Engine Crash SDL dialog.
Fixes CTRL+C not working while the SDL dialog is open.

Fixes a double Sys_Error/Sys_Abort when memory corruption was detected.

Windows: omits colours when printing a Crash to stderr (not supported).

Makes signal handling (mostly) POSIX async-signal-safe.

Fixes a slight bug in PRVM_ShortStackTrace().

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPRVM: fix a use of strlcpy on an unterminated source
bones_was_here [Sun, 21 Jan 2024 18:03:51 +0000 (04:03 +1000)]
PRVM: fix a use of strlcpy on an unterminated source

This code is used when starting a QC program in a non-English language.
See also 3727057b879ccfeaa434537f41a302f047e8cfae

Also renames the dp_ustr2stp() parameter ssize to slen for clarity.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoRefactor InfoString_GetValue() calling
bones_was_here [Sun, 21 Jan 2024 10:30:23 +0000 (20:30 +1000)]
Refactor InfoString_GetValue() calling

Returning the number of bytes written is more useful.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agocvar: add some missing registrations
bones_was_here [Sat, 20 Jan 2024 18:14:05 +0000 (04:14 +1000)]
cvar: add some missing registrations

Closes https://gitlab.com/xonotic/darkplaces/-/issues/405

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agodedicated server: ignore mod_bsp_portalize for faster map changes
bones_was_here [Sat, 20 Jan 2024 17:59:01 +0000 (03:59 +1000)]
dedicated server: ignore mod_bsp_portalize for faster map changes

These portals are only used by renderer features.
Closes https://gitlab.com/xonotic/darkplaces/-/issues/243

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoMisc data type and comment fixes
bones_was_here [Tue, 9 Jan 2024 05:57:57 +0000 (15:57 +1000)]
Misc data type and comment fixes

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agosys: optimise printing to stdout
bones_was_here [Tue, 9 Jan 2024 05:46:37 +0000 (15:46 +1000)]
sys: optimise printing to stdout

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agocom_msg: optimise string and byte sequence reading
bones_was_here [Wed, 17 Jan 2024 21:08:16 +0000 (07:08 +1000)]
com_msg: optimise string and byte sequence reading

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPRVM: optimise tempstring creation
bones_was_here [Tue, 19 Dec 2023 13:19:21 +0000 (23:19 +1000)]
PRVM: optimise tempstring creation

No need for strlen in PRVM_SetTempString(), usually we already have that
information.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPRVM: optimise string arguments
bones_was_here [Sun, 21 Jan 2024 06:30:06 +0000 (16:30 +1000)]
PRVM: optimise string arguments

Adds a warning for when QC tries to create a string that's too long
(previously this caused silent truncation).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPRVM: rename VM_STRINGTEMP_LENGTH to VM_TEMPSTRING_MAXSIZE
bones_was_here [Thu, 18 Jan 2024 06:34:36 +0000 (16:34 +1000)]
PRVM: rename VM_STRINGTEMP_LENGTH to VM_TEMPSTRING_MAXSIZE

For clarity and consistency

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPRVM: disallow changing read-only cvars
bones_was_here [Thu, 18 Jan 2024 05:43:15 +0000 (15:43 +1000)]
PRVM: disallow changing read-only cvars

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoPRVM: fix some incorrect warning messages
bones_was_here [Thu, 11 Jan 2024 23:08:05 +0000 (09:08 +1000)]
PRVM: fix some incorrect warning messages

Closes https://gitlab.com/xonotic/darkplaces/-/issues/379

See 2322e173520b68ae6ca217024a47dfb8bbc12473

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoprvm_leaktest: fix trace string truncation
bones_was_here [Wed, 20 Dec 2023 07:40:04 +0000 (17:40 +1000)]
prvm_leaktest: fix trace string truncation

This was caught by the new warnings.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoFix worldmessage string truncation
bones_was_here [Fri, 29 Dec 2023 09:35:25 +0000 (19:35 +1000)]
Fix worldmessage string truncation

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agoFix uses of strlcpy on unterminated source strings
bones_was_here [Mon, 18 Dec 2023 09:24:15 +0000 (19:24 +1000)]
Fix uses of strlcpy on unterminated source strings

BSD strlcpy() keeps reading until a \0 or a segfault, even after it
stops writing. In these cases the source was part of a longer string so
it wouldn't have crashed.
These were caught by the new warning.

The +1 on the source sizes copied an extra char that would be changed to
\0 and is now redundant because the real dest and src sizes are always
passed to a purpose-written func.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agocom: replace BSD strlcpy and strlcat
bones_was_here [Wed, 13 Dec 2023 07:16:24 +0000 (17:16 +1000)]
com: replace BSD strlcpy and strlcat

Compared to BSD strlcpy and strlcat, dp_strlcpy and dp_strlcat are
faster, never crash, and have a more useful return (DP didn't use the
strlcpy return at all), see included docs.

Adds dp_stpecpy() for efficient chain copying and dp_ustr2stp() for
copying measured byte sequences (unterminated strings) to strings.

Replaces the only use of the strlcat() return with dp_stpecpy().

Updates the forbidden string functions list.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agocom: rename BSD strlcpy and strlcat
bones_was_here [Fri, 15 Dec 2023 10:16:15 +0000 (20:16 +1000)]
com: rename BSD strlcpy and strlcat

The C standard reserves str* and mem* for the implementation.
Checking for BSD or OS X is not a robust way to determine if libc
provides these (eg glibc may implement them).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agocom: detect truncation or error in dpvsnprintf()
bones_was_here [Mon, 15 Jan 2024 00:41:06 +0000 (10:41 +1000)]
com: detect truncation or error in dpvsnprintf()

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
3 months agosys: attempt to placate Microsoft's compiler
bones_was_here [Wed, 10 Jan 2024 03:09:58 +0000 (13:09 +1000)]
sys: attempt to placate Microsoft's compiler

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agosys: write significant engine and QC errors to stderr
bones_was_here [Thu, 4 Jan 2024 14:41:43 +0000 (00:41 +1000)]
sys: write significant engine and QC errors to stderr

A server configured with -nostdout or sys_stdout 0 will now be able to
report bugs.

Retrieves stdio stream FDs instead of assuming they're always 0,1,2.
Fixes some comment!=code discrepancies.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agosys: make stdout/stderr configurable during runtime
bones_was_here [Wed, 3 Jan 2024 16:58:15 +0000 (02:58 +1000)]
sys: make stdout/stderr configurable during runtime

Adds cvar sys_stdout which offers the same behaviours as the -nostdout
and -stderr cmdline options and is initialised by them if they're passed.
Makes -noterminal cmdline option a synonym for -nostdout, previously it
was effectively the same but less efficient.

Platforms with the fcntl() syscall (ie non-Windows):
Changes to non-blocking stdout/stderr by default to prevent stutters and
halts in certain scenarios.
Adds cvar sys_stdout_blocks for enabling blocking stdout/stderr if
required.

Retrieves stdio stream FDs instead of assuming they're always 0,1,2.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agofont: fix missing text in r_speeds (etc)
bones_was_here [Thu, 4 Jan 2024 17:39:56 +0000 (03:39 +1000)]
font: fix missing text in r_speeds (etc)

This bug was introduced in 5468c81f47e6644d938e3cfedd21567b2936cd72

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agoRemove deprecated r_font_use_alpha_textures cvar
bones_was_here [Thu, 4 Jan 2024 01:59:19 +0000 (11:59 +1000)]
Remove deprecated r_font_use_alpha_textures cvar

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agoMerge PR 'Fix several long-lasting font rendering problems'
bones_was_here [Thu, 4 Jan 2024 01:47:58 +0000 (11:47 +1000)]
Merge PR 'Fix several long-lasting font rendering problems'

See https://github.com/DarkPlacesEngine/darkplaces/pull/67

Fixes https://github.com/DarkPlacesEngine/darkplaces/issues/49
Fixes https://github.com/DarkPlacesEngine/darkplaces/issues/65
Closes https://github.com/DarkPlacesEngine/darkplaces/issues/66

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agoreload a dp_font only when its cmdline changes, to prevent unnecessary reloads; intro...
NaitLee [Sat, 30 Dec 2023 12:40:34 +0000 (20:40 +0800)]
reload a dp_font only when its cmdline changes, to prevent unnecessary reloads; introduce cvar `r_font_always_reload`

Signed-off-by: NaitLee <naitli@foxmail.com>
4 months agouncomment code that prevents memory leak in LoadFont; better English
NaitLee [Sat, 16 Sep 2023 06:17:35 +0000 (14:17 +0800)]
uncomment code that prevents memory leak in LoadFont; better English

Signed-off-by: NaitLee <naitli@foxmail.com>
4 months agofix wrong outchar given when merging incmaps;
NaitLee [Sat, 8 Jul 2023 06:43:56 +0000 (14:43 +0800)]
fix wrong outchar given when merging incmaps;
remove bad code, deprecate broken features

Signed-off-by: NaitLee <naitli@foxmail.com>
4 months agoUse `%p` for `mapstart` pointer in `dpsnprintf`,
NaitLee [Mon, 30 Jan 2023 17:00:18 +0000 (01:00 +0800)]
Use `%p` for `mapstart` pointer in `dpsnprintf`,
Leave notes to `map_identifier` format change

Signed-off-by: NaitLee <naitli@foxmail.com>
4 months agoFix several long-lasting font rendering problems:
NaitLee [Sun, 29 Jan 2023 08:51:37 +0000 (16:51 +0800)]
Fix several long-lasting font rendering problems:
Fix resources waste of fontmap usage worst-cases;
Fix memory waste of improperly designed `struct ft2_font_map_s`;
Deprecate `r_font_diskcache`

Signed-off-by: NaitLee <naitli@foxmail.com>
4 months agoHandle rsurface.texture == NULL here (not sure if it can happen).
Rudolf Polzer [Wed, 3 Jan 2024 20:06:16 +0000 (12:06 -0800)]
Handle rsurface.texture == NULL here (not sure if it can happen).

4 months agoBring back a very simple r_showsurfaces 3.
Rudolf Polzer [Wed, 3 Jan 2024 20:01:01 +0000 (12:01 -0800)]
Bring back a very simple r_showsurfaces 3.

Sadly I don't quite understand r_showsurfaces 2 enough to bring it back, so
we've got a gap now.

4 months agocmd: read only one line per frame from stdin
bones_was_here [Wed, 3 Jan 2024 03:29:39 +0000 (13:29 +1000)]
cmd: read only one line per frame from stdin

Prioritising the ordering of new commands with respect to existing
commands, over the ordering of pasted commands that include `wait`.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agor_viewfbo 0: fix restoring GL_Scissor values at the end of skybox render.
Rudolf Polzer [Wed, 3 Jan 2024 14:20:45 +0000 (06:20 -0800)]
r_viewfbo 0: fix restoring GL_Scissor values at the end of skybox render.

Fixes wrong handling of viewsize with r_viewfbo 0.

4 months agor_viewfbo 0: factor out motion blur.
Rudolf Polzer [Wed, 3 Jan 2024 13:19:42 +0000 (05:19 -0800)]
r_viewfbo 0: factor out motion blur.

Motion blur doesn't NEED the blending pass.

4 months agor_viewfbo 0: skip the postprocessing/blending pass if there is nothing to blend.
Rudolf Polzer [Tue, 2 Jan 2024 20:48:07 +0000 (12:48 -0800)]
r_viewfbo 0: skip the postprocessing/blending pass if there is nothing to blend.

May save some fps on low-end systems.

NOTE: Had to make sure that 2D rendering does not enable depth test,
as in r_skipblend mode, the main framebuffer Z values are written to as
part of regular 3D rendering. There appear to be no behavioral changes
from this, but we need to be careful here.

r_viewfbo 1 disables this logic (it differs in no other way from r_viewfbo 0)

4 months agoR_BlendView: fix motion blur with viewsize != 100.
Rudolf Polzer [Wed, 3 Jan 2024 14:53:40 +0000 (06:53 -0800)]
R_BlendView: fix motion blur with viewsize != 100.

OpenGL is only upside down if the render target isn't a FBO...

4 months agoR_BlendView: fix motion blur by using the correct FBO for it.
Rudolf Polzer [Tue, 2 Jan 2024 19:19:28 +0000 (11:19 -0800)]
R_BlendView: fix motion blur by using the correct FBO for it.

Motion blur has to be applied to the view FBO, not the (optional) screen FBO.
Especially as the code generating runs before even writing to the screen FBO.

4 months agorcon: support variable expansion in received commands
bones_was_here [Tue, 2 Jan 2024 23:35:09 +0000 (09:35 +1000)]
rcon: support variable expansion in received commands

How to send such a command without the client expanding it is currently
left as an exercise for the reader...

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agohost: log graceful shutdown (config, history)
bones_was_here [Tue, 2 Jan 2024 13:21:15 +0000 (23:21 +1000)]
host: log graceful shutdown (config, history)

Stopping demo recording should already get a message.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agosys: implement signal handling on all platforms
bones_was_here [Mon, 1 Jan 2024 12:55:45 +0000 (22:55 +1000)]
sys: implement signal handling on all platforms

Prints a stack trace when crashing if using glibc.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
4 months agocmd: fix stdin command ordering and related stuff
bones_was_here [Sun, 31 Dec 2023 20:55:03 +0000 (06:55 +1000)]
cmd: fix stdin command ordering and related stuff

Fixes bug introduced in d217d6b9ba9012bc374ac0d44d48422b7b13b755 where
multiline stdin execution order was reversed.

Retrieves FD of stdin stream rather than assuming it will always be 0.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>