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.
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>
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>
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>
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>
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>
com_list: Require type explicitly. Remove Q_typeof as typeof and decltype are unavailable in MSVC
zone: Use the generic linked list
zone: Pass __FILE__ and __LINE__ to Mem_strdup Made it a macro for _Mem_strdup which is what Mem_strdup was. We have to call _Mem_Alloc directly to pass __FILE__ and __LINE__ to that function.
zone: Do a straight malloc on non-Windows
Fix a few warnings in VS2019. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13071 d7cf8633-e32d-0410-b094-e92efae38249
zone: Print only memstats with the memstats command. Fixes dependence on the renderer to compile zone.c git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12993 d7cf8633-e32d-0410-b094-e92efae38249
quakedef: Add darkplaces.h and include it in as many files as I can. Split up and clean up quakedef.h A client and server agnostic master definitions file is nice to have and this may speed up compile times and make refactoring easier later on. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12972 d7cf8633-e32d-0410-b094-e92efae38249
Unify the command and cvar flags, under the CF_ prefix. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12923 d7cf8633-e32d-0410-b094-e92efae38249
Rename qboolean to qbool git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12920 d7cf8633-e32d-0410-b094-e92efae38249
zone: Fix backed file alloc for BSD. Check for -1 in addition to NULL on mmap data (David CARLIER) https://gitlab.com/xonotic/darkplaces/-/merge_requests/55 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12815 d7cf8633-e32d-0410-b094-e92efae38249
Comply with ISO C11. Engine will now compile with -pedantic, w/o extra warnings But don't actually use -std=c11 because computed gotos is a gcc extension that makes the QCVM 30 percent faster in all situations. c11 obviously disables gcc extensions. But this is a nice thing to achieve as far as portability is concerned. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12756 d7cf8633-e32d-0410-b094-e92efae38249
Initial implementation of command flag system This should reduce code duplication and allows other cool things. This is part of the solution to a bug where "stuffcmds" stopped working because of changes to the initialization order in Host_Init. More work needs to be done but this should be fine for now. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12668 d7cf8633-e32d-0410-b094-e92efae38249
cvars are now instanced in &cvars_all as a tracking mechanism, there is also &cvars_null if one wishes for no expansion to occur (e.g. client commands received on the server are very untrusted). cvars now have CVAR_CLIENT and CVAR_SERVER flags, dedicated server can only see CVAR_SERVER variables whereas client can see both because it could start a server. cvars created via VMs will have the corresponding flag set (client vm and menu vm can see both CVAR_CLIENT and CVAR_SERVER, server vm can only see CVAR_SERVER - may cause issues with singleplayer mods, we'll see). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12501 d7cf8633-e32d-0410-b094-e92efae38249
Split the global cmd interpreter into 4 separate ones for specific uses (client console, server console, client commands received from server, server commands received from clients), this is intended to make clients more robust against malicious servers by restricting which commands make sense. This also hides some network protocol implementation details from the console command interpreter, and makes the command list a lot shorter in dedicated servers. Changed Cbuf_LockThreadMutex/Cbuf_UnlockThreadMutex to Cbuf_Lock/Cbuf_Unlock and they now use a spinlock internally. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12500 d7cf8633-e32d-0410-b094-e92efae38249