James O'Neill [Sun, 21 Apr 2024 14:44:09 +0000 (23:44 +0900)]
Merge PR 'Add support for a "give a" command to give player armour'
Allows the command `give a #` to give the player armour, just like the
other `give` commands. Based on the example code provided by Baker7.
Fixes #132 .
See https://github.com/DarkPlacesEngine/darkplaces/pull/136
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Sat, 20 Apr 2024 19:28:02 +0000 (05:28 +1000)]
menu: update video settings
Adds display selection, desktop fullscreen, adaptive vsync, 1600x900
resolution, and improves refresh rate configuration in the built-in
Quake menu.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Sun, 14 Apr 2024 14:38:33 +0000 (00:38 +1000)]
vid: overhaul modesetting
Implements hardware refresh rate modesetting, this wasn't implemented
yet for SDL2 (although it was partially supported in
c03b106680122333189e42294c4fb3c385307631).
Implements colour depth modesetting but leaves it disabled because
almost all display hardware supports 24bpp only.
Properly integrates desktopfullscreen and display selection into the
modesetting design.
Changes the modesetting design to better suit SDL2 (see comments),
using the code for immediately applying cvar changes in the startup path
too.
Disables immediate-apply of display cvar changes when hardware
modesetting is active and the player is accessing a menu, because
traditional menu designs don't support it: they make players scroll
through a list of resolutions, setting the cvars at each step.
Enables modesetting on Linux: turns out it does still work in SDL2 even
though exclusive fullscreen support was removed. SDL2 replaced
exclusive fullscreen with desktopfullscreen combined with an xrandr
modeset (behaves like desktopfullscreen IF the mode is the same
as the desktop one).
Replaces the 640x480 modesetting fallback with desktopfullscreen, should
be nicer and should always work (the old fallback is still there but
should never be reached).
Adds a debug print of all modes supported by the display (at startup).
Updates modesetting console prints.
Works around an SDL bug when increasing hardware resolution.
Works around an SDL bug where it doesn't set the error string in
SDL_GetClosestDisplayMode() so SDL_GetError would return some unrelated
message.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 15 Apr 2024 23:01:37 +0000 (09:01 +1000)]
vid: remove cvar vid_userefreshrate
It's unnecessary and other Quake engines don't have it.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 15 Apr 2024 20:06:54 +0000 (06:06 +1000)]
vid: clean up some globals
Fixes vid_stick_mouse assuming window width and height couldn't change
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 15 Apr 2024 21:35:28 +0000 (07:35 +1000)]
vid: refactor VID_Mode() calling
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 15 Apr 2024 20:46:54 +0000 (06:46 +1000)]
vid: consolidate mode structures
This uses a viddef_mode_t `vid.mode` in the global viddef_t `vid`
instead of having a separate declaration of each var there, makes
copying it more efficient.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 15 Apr 2024 01:21:18 +0000 (11:21 +1000)]
vid: refactor modesetting fallbacks
Moves setting of cvars from VID_Mode into VID_Restart_f because we only
need to do it if a vid_restart fails after changes were made, during
normal startup the only source of config changes is the fallbacks cvar
array which already sets them as they're tested.
This avoids unnecessary clobbering and callbacks under normal
circumstances and makes vid_restart code more self-contained.
Refers to cvars by pointer instead of string for robustness.
Removes persistent storage of last known good mode, it's only needed in
VID_Restart_f and it would be verbose and error-prone to keep it updated
as well as the current mode when applying cvar changes and SDL events.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Thu, 11 Apr 2024 17:55:08 +0000 (03:55 +1000)]
build: minor adjustments
VS2019: get more of the targets to build (needed to specify modern C
standard for all of them, and SDK "10.0" seems to mean "use latest
version installed").
VS2019: improve README.md instructions.
Makefile: fix PEDANTIC=1 test builds and warning spam.
sys: properly fix warnings related to SDL's wrapping of main() for all
platforms.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
James O'Neill [Fri, 12 Apr 2024 12:53:38 +0000 (21:53 +0900)]
Merge PR 'Make particles solid squares when cl_particles_quake is set to 2'
This creates a new function, CL_NewQuakeParticle, that is used instead of CL_NewParticle when cl_particles_quake is enabled. The function calls CL_NewParticle with a some hardcoded defaults to make the particle texture a disc, or solid square, based on the value of cl_particles_quake.
Improves particle function documentation.
See https://github.com/DarkPlacesEngine/darkplaces/pull/137
Closes https://gitlab.com/xonotic/darkplaces/-/issues/308
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Thu, 11 Apr 2024 14:50:16 +0000 (00:50 +1000)]
build: get Visual Studio 2019 to compile
Adds basic instructions to README.md
Updates SDL2 NuGet package.
Updates .gitignore to exclude all generated build objects and the
downloaded NuGet packages (VS downloads them automatically if missing,
seems better than storing old versions here).
Removes files from legacy VS versions.
The resulting build isn't usable for playing (see README.md).
Maybe someone who uses this platform can fix it.
Closes https://github.com/DarkPlacesEngine/darkplaces/issues/129
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Wed, 10 Apr 2024 19:39:17 +0000 (05:39 +1000)]
vid: apply vid_width and vid_height cvar changes immediately
This uses an SDL feature to avoid a bogus hardware modesets (eg when one
cvar is changed before the other).
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Wed, 10 Apr 2024 18:45:38 +0000 (04:45 +1000)]
vid: [Windows] enable vid_ignore_taskbar by default
When this Windows-specific cvar is disabled, a strange horizontal offset
of the window occurs, at least on Windows 20 22H2.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Wed, 10 Apr 2024 18:44:34 +0000 (04:44 +1000)]
vid: misc updates to comments, console prints, func naming
The bug where SDL returns incorrect display layout after hotplug events
doesn't seem to occur on Windows 10 22H2.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Wed, 10 Apr 2024 15:35:45 +0000 (01:35 +1000)]
vid: don't overwrite vid_width and vid_height when using vid_desktopfullscreen
This allows the player's windowed mode preferences to be saved by
default.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Wed, 10 Apr 2024 13:06:09 +0000 (23:06 +1000)]
vid: enable vid_resizable by default
It works well and is convenient.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Wed, 10 Apr 2024 13:02:44 +0000 (23:02 +1000)]
vid: [Windows] don't r_restart for window resize events
This workaround was added for SDL 1.2 and is no longer necessary.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Wed, 10 Apr 2024 12:58:26 +0000 (22:58 +1000)]
vid: [Windows] fix disabling of OS DPI scaling
d33a1d0ffb434270de498c386271e484f90e6716 didn't actually work cos I
hadn't found where the good SDL documentation was, and didn't have a
high DPI Windows test machine.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Tue, 9 Apr 2024 16:27:45 +0000 (02:27 +1000)]
sys: [Linux] remove/replace obsolete timing and sleep syscalls, slightly improve timing
Uses CLOCK_MONOTONIC_RAW on Linux, this is unaffected by synchronisation
adjustments and is used by SDL_GetPerformanceCounter() (we'll use it
directly to support dedicated servers without SDL).
Removes gettimeofday() and usleep() which were marked obsolete and
removed in POSIX.1-2008 so the old comment // FIXME improve this check
was impossible to address. The gettimeofday() replacement is very well
tested now (sys_useclockgettime 1 is default even in div0-stable).
Removes host_maxwait as the problems it worked around were fixed.
Tidies up a little.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Tue, 9 Apr 2024 14:25:39 +0000 (00:25 +1000)]
sys: [Windows] use more precise timing and sleeping
Achieved sleep behaviour is still worse than on Linux, but it's now the
best Windows can do.
Enables sys_usequeryperformancecounter by default. Most modern games use
this. Very old machines or Windows VMs may benefit from disabling it.
Fixes sys_usequeryperformancecounter issue where if enabled at startup,
timer precision was only 15.625ms.
Removes workaround for compilers that don't support 64 bit integers.
Updates documentation.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 8 Apr 2024 00:41:52 +0000 (10:41 +1000)]
sys: [Windows] fix spinning instead of sleeping
For
231beb2c234914f942166eb152c44e55b5b01f86 I tested incorrectly, using
Task Manager inside the VM which reports low CPU load even when spinning.
DP's `status` command showed the correct result.
Changes the default path from select() to: usleep() on POSIX, Sleep() on
Windows.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Sun, 7 Apr 2024 15:15:14 +0000 (01:15 +1000)]
PRVM: minimise impact of GC on benchmark results
Previously GC could cost hundreds of FPS in certain Xonotic tests
because the CPU workload increased as the FPS did.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Sat, 6 Apr 2024 20:16:17 +0000 (06:16 +1000)]
Fix CSQC garbage collection crash, support GC in CSQC_SIMPLE mode
Caused by a "typo" in
3f9fdd41aec12c0832ed07f2ba0239383a3801d4
Closes https://github.com/DarkPlacesEngine/darkplaces/issues/161
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Thu, 4 Apr 2024 10:46:16 +0000 (20:46 +1000)]
Remove CF_ARCHIVE bit from r_q1bsp_lightmap_updates_enabled
Disabling this breaks rendering so it doesn't make sense to leave it
enabled after testing.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Tue, 2 Apr 2024 14:35:20 +0000 (00:35 +1000)]
Implement CSQC_SIMPLE aka hud-only CSQC, improve compatibility
This should match the behaviours of engines with minimal CSQC support,
allowing DP to run any csprogs made for them.
Fixes https://github.com/DarkPlacesEngine/darkplaces/issues/108
Updates dpdefs to include compatible parameter names.
Adds VM-specific code for checking required functions during QC program
loading.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Tue, 2 Apr 2024 07:57:03 +0000 (17:57 +1000)]
README.md: various doc adjustments
GitHub happy splits `-rogue` over two lines...
OS X Carbon is long gone (along with GLX and WGL).
bones_was_here [Tue, 2 Apr 2024 07:03:40 +0000 (17:03 +1000)]
menuqc: declare localcmd() and deduplicate it
It's awkward having a different name for the same builtin in a different
VM, Xonotic was working around it (for code sharing) with a macro.
bones_was_here [Mon, 1 Apr 2024 12:40:00 +0000 (22:40 +1000)]
Clarify documentation of gamedirs, add to README.md
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 1 Apr 2024 11:37:16 +0000 (21:37 +1000)]
Revert "fs: save files in the correct place when gamedir(s) are in use"
This reverts commit
5db369bea3d0cdd3dbd3b5b8038a399f0dbf84b6.
Closes https://github.com/DarkPlacesEngine/darkplaces/issues/150
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
James O'Neill [Mon, 18 Mar 2024 12:06:22 +0000 (21:06 +0900)]
Fix r_glsl_dumpshader segfault
In
05bc75558afbdf80289fddf9a330dd7382a07d0d only i should have been
changed to unsigned to prevent the warning.
Fixes https://github.com/DarkPlacesEngine/darkplaces/issues/145
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Sun, 31 Mar 2024 19:21:01 +0000 (05:21 +1000)]
PRVM: fix null ptr deref in VM_getkeybind()
Breaking commit was
26a665ff43052862131df3c63785f91861989fc8
Fixes https://github.com/DarkPlacesEngine/darkplaces/issues/133
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Tue, 12 Mar 2024 14:22:14 +0000 (00:22 +1000)]
vid_vsync: work around Wayland-specific init bug
Fixes https://gitlab.com/xonotic/darkplaces/-/issues/413
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 11 Mar 2024 23:29:15 +0000 (09:29 +1000)]
NudgeOutOfSolid: fix moving entities out of the world in complex cases
Renames a var for clarity.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 11 Mar 2024 18:13:28 +0000 (04:13 +1000)]
map command: recognise Q3BSP variants IBSP47 and IBSP48
Quake Live and Iron Grip, already supported by the loader.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
bones_was_here [Mon, 11 Mar 2024 17:36:42 +0000 (03:36 +1000)]
Underwater sound filter: an optimisation from terencehill
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
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>
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>
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
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
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>
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>
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>
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>
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>
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>
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.
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>
James O'Neill [Fri, 1 Mar 2024 09:18:42 +0000 (18:18 +0900)]
Force C syntax for qc and qh files on Github
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>