]> git.rm.cloudns.org Git - xonotic/darkplaces.git/log
xonotic/darkplaces.git
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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).

11 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.

11 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>
11 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.

11 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.

11 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)

11 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...

11 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.

11 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>
11 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>
11 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>
11 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>
11 months agosys: commenting and tidying
bones_was_here [Tue, 2 Jan 2024 06:58:35 +0000 (16:58 +1000)]
sys: commenting and tidying

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
11 months agodeduplicate Sys_Shutdown()
bones_was_here [Tue, 2 Jan 2024 07:12:42 +0000 (17:12 +1000)]
deduplicate Sys_Shutdown()

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
11 months agodeduplicate Sys_Print()
bones_was_here [Tue, 2 Jan 2024 06:41:30 +0000 (16:41 +1000)]
deduplicate Sys_Print()

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
11 months agodeduplicate Sys_Error()
bones_was_here [Tue, 2 Jan 2024 06:21:27 +0000 (16:21 +1000)]
deduplicate Sys_Error()

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
11 months agodeduplicate Sys_ConsoleInput()
bones_was_here [Tue, 2 Jan 2024 09:31:51 +0000 (19:31 +1000)]
deduplicate Sys_ConsoleInput()

Fixes multiline stdin not working in the SDL client, but working in the
dedicated server.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
11 months agodeduplicate main()
bones_was_here [Mon, 1 Jan 2024 03:58:00 +0000 (13:58 +1000)]
deduplicate main()

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
11 months agocon: allow alias loops involving wait to be broken, eg with unalias or quit
bones_was_here [Sat, 30 Dec 2023 20:49:08 +0000 (06:49 +1000)]
con: allow alias loops involving wait to be broken, eg with unalias or quit

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
11 months agodemos: support curl/dlcache (down)loading at start of playback
bones_was_here [Fri, 29 Dec 2023 22:14:28 +0000 (08:14 +1000)]
demos: support curl/dlcache (down)loading at start of playback

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

Not sure why the hacky way broke but we can do it without hacks or
netcode special cases.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoMakefile: misc cleanups and fixes
bones_was_here [Tue, 26 Dec 2023 09:53:50 +0000 (19:53 +1000)]
Makefile: misc cleanups and fixes

Mostly removing cruft, deduplicating, consolidating.

Defaults to system default compiler instead of gcc.
Fixes parallel builds which were broken in
8a9f7e9e336cede20ec7da6bebc0f81a86ab79db by insufficient RTFM.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoMakefile: support explicit static linking of all configurable libraries
bones_was_here [Tue, 26 Dec 2023 07:45:26 +0000 (17:45 +1000)]
Makefile: support explicit static linking of all configurable libraries

Fixes a bug in df973c344562c8cadc2413d36dcaa03f8e9040c2 where
libd0_rijndael static linking only worked if
DP_LINK_CRYPTO_RIJNDAEL=static was read from the environment rather than
being passed as an override.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoMakefile: support explicit static linking of libd0
bones_was_here [Sun, 24 Dec 2023 12:04:02 +0000 (22:04 +1000)]
Makefile: support explicit static linking of libd0

Allows a kludge to be removed in Xonotic.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoMakefile: always run any clean targets before starting any build
bones_was_here [Sat, 23 Dec 2023 08:30:27 +0000 (18:30 +1000)]
Makefile: always run any clean targets before starting any build

Should fix occasional failures in Xonotic build system which specifies
multiple targets including clean and enables parallel jobs.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoMerge PR 'Apply default lightstyle to to lightmap when using q3bsp'
bones_was_here [Sat, 23 Dec 2023 08:02:54 +0000 (18:02 +1000)]
Merge PR 'Apply default lightstyle to to lightmap when using q3bsp'

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

Fixes https://github.com/DarkPlacesEngine/darkplaces/issues/100

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoREADME.md: add SDL version requirements
bones_was_here [Sat, 23 Dec 2023 07:01:06 +0000 (17:01 +1000)]
README.md: add SDL version requirements

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocbuf: improve some warns, minor cleanup
bones_was_here [Fri, 15 Dec 2023 22:36:22 +0000 (08:36 +1000)]
cbuf: improve some warns, minor cleanup

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocvar: use unsigned for flags and hashindex
bones_was_here [Thu, 21 Dec 2023 11:06:36 +0000 (21:06 +1000)]
cvar: use unsigned for flags and hashindex

Signed is too error-prone with bitwise operations.  The common pattern
of passing ~0 (all bits set) resulted in neededflags=-1 in a backtrace
on x86_64.

See also b8692b8cd73685794b59b0522e8caa4b9d9a2dac

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocvar: remove from the hash table when deleting (`unset` command)
bones_was_here [Thu, 21 Dec 2023 10:08:38 +0000 (20:08 +1000)]
cvar: remove from the hash table when deleting (`unset` command)

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

Refactors Cvar_FindVarLink() to return a hash link pointer pointer
instead of a cvar pointer to avoid passing extra pointer pointers.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoAdd Baker's fix for spplying default lightstyle to q3bsp
James O'Neill [Tue, 19 Dec 2023 15:48:59 +0000 (00:48 +0900)]
Add Baker's fix for spplying default lightstyle to q3bsp

12 months agocmd: Move cprint command to cl_screen
Cloudwalk [Thu, 14 Dec 2023 04:26:53 +0000 (23:26 -0500)]
cmd: Move cprint command to cl_screen

Client code doesn't belong in a common subsystem

Signed-off-by: Cloudwalk <cloudwalk@icculus.org>
12 months agonet_slist: reduce worst-case time until any given server first appears
bones_was_here [Tue, 12 Dec 2023 10:13:26 +0000 (20:13 +1000)]
net_slist: reduce worst-case time until any given server first appears

Fixes sending multiple queries to servers that happen to be early in the
list before sending any to servers late in the list, when
net_slist_maxtries > 1, which was a side-effect of making
net_slist_maxtries work as described in
fe2b222e32752c408fbe5ccf4ac3fb546f8ff41a.

Slightly reduces the total real time and CPU time to query all servers.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocvar: use better method of checking flags during registration
bones_was_here [Tue, 12 Dec 2023 06:17:54 +0000 (16:17 +1000)]
cvar: use better method of checking flags during registration

Should have done it this way in 3a58ad52e63635c93e95955f984fd6052156e56b

Also prevents callbacks for client-only cvars being registered on the
dedicated server.

Adds some debug prints.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocmd: always register server-only commands, don't register client-only commands on...
bones_was_here [Tue, 12 Dec 2023 04:33:48 +0000 (14:33 +1000)]
cmd: always register server-only commands, don't register client-only commands on dedicated server

Fixes the lack of the `heartbeat` command on dedicated and listen, and
the presence of commands like `toggleconsole` on dedicated.

Similar to 3a58ad52e63635c93e95955f984fd6052156e56b this might reveal a
few commands that aren't flagged correctly.

Changes the bitmask vars to the correct type.
Renames cmd_flags to cmd_flagsmask for consistency.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocmd: reinstate execution of aliases with the same name as a command
bones_was_here [Mon, 11 Dec 2023 12:02:55 +0000 (22:02 +1000)]
cmd: reinstate execution of aliases with the same name as a command

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

Based on the div0-stable version of Cmd_ExecuteString().

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocmd: misc cleanup
bones_was_here [Mon, 11 Dec 2023 15:31:04 +0000 (01:31 +1000)]
cmd: misc cleanup

Removes an unnecessary pointer stored in all the cbuf objects.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocmd: inline Cmd_Arg* helper funcs in all compilation units
bones_was_here [Mon, 11 Dec 2023 15:18:57 +0000 (01:18 +1000)]
cmd: inline Cmd_Arg* helper funcs in all compilation units

ea7ad935aa214b3a52eb7079110e992fbfe750ee should have done this.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocmd: add CON_WARN colour to various non-fatal cvar and command errors
bones_was_here [Sun, 10 Dec 2023 10:32:16 +0000 (20:32 +1000)]
cmd: add CON_WARN colour to various non-fatal cvar and command errors

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocbuf: recycle node after it executes, clear commands on Host_Error()
bones_was_here [Sat, 9 Dec 2023 07:49:56 +0000 (17:49 +1000)]
cbuf: recycle node after it executes, clear commands on Host_Error()

This reverts 626658074c8dd5c2288becd836103e2efdb9b741 which looks like a
potentially racy or non-threadsafe approach, and instead prevents
problems by clearing the command buffers if Host_Error() is called and
doesn't shut down DP.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agobuild: enable strict aliasing optimisations
bones_was_here [Fri, 8 Dec 2023 07:08:44 +0000 (17:08 +1000)]
build: enable strict aliasing optimisations

Extensive code quality improvements have been made since this was last
tried, and compilers are smarter with better warnings now.

This doesn't change the Xonotic pipeline gameplay hash so it's highly
unlikely to cause any subtle regressions.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoChange to the C99 standard method of testing for nan
bones_was_here [Fri, 8 Dec 2023 07:41:22 +0000 (17:41 +1000)]
Change to the C99 standard method of testing for nan

This fixes all remaining strict-aliasing rule warnings in GCC.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoclient: improve server connection status messages
bones_was_here [Fri, 1 Dec 2023 06:18:45 +0000 (16:18 +1000)]
client: improve server connection status messages

Always logs various errors and rejections that previously were only
visible with developer cvar(s) set.  Among other things this fixes
silent failure when trying to join a full server.
Includes IP address in more messages.

Uses CON_ERROR and CON_WARN colours for various errors and warns.

Moves status message generation to the code that sets the relevant
states.  This allows more information to be included, makes the code
easier to follow and reduces polling.

Fixes some cases where a message was always clobbered before it could be
displayed.

Merges the built-in menu and loading screen connection status generation
and buffering.

Simplifies challenge request retry counting.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoREADME.md: mention `make clean`, more specific build deps
bones_was_here [Fri, 24 Nov 2023 05:02:32 +0000 (15:02 +1000)]
README.md: mention `make clean`, more specific build deps

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoRename sv_gameplayfix_customstats to sv_qcstats, improve description
bones_was_here [Thu, 23 Nov 2023 19:45:12 +0000 (05:45 +1000)]
Rename sv_gameplayfix_customstats to sv_qcstats, improve description

It's an API change not a gameplay change.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agoSys_Sleep overhaul
bones_was_here [Sun, 26 Nov 2023 01:17:53 +0000 (11:17 +1000)]
Sys_Sleep overhaul

One function to rule them all, and in the darkplaces sleep threads.

Makes sub-millisecond accuracy available on Windows.
Increases the number of sockets we can monitor on Windows.
Improves Curl_Select() a little.
Updates flags of some timing-related cvars.

Cleans up disorganised and duplicate code.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocl_nettimesyncboundmode: use default if invalid
bones_was_here [Fri, 24 Nov 2023 05:18:57 +0000 (15:18 +1000)]
cl_nettimesyncboundmode: use default if invalid

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
12 months agocl_nolerp: use normal time synchronisation
bones_was_here [Tue, 21 Nov 2023 20:47:11 +0000 (06:47 +1000)]
cl_nolerp: use normal time synchronisation

Fixes constant packet discards on LAN and impossible pings online,
when FPS > ticrate.

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