182 Commits

Author SHA1 Message Date
Kawe Mazidjatari
c8c321e924 Server: use dedicated types for nucleus ID
This isn't a bug fix but a style fix as we should use NucleusID_t for anything that is a nucleus ID. This type is also of uint64.
2025-01-26 11:55:36 +01:00
Kawe Mazidjatari
18f2e27409 Engine: implement support for loading ui_mainmenu.rpak
For future updates, this allows for customizing the main menu to its full extend without modifying larger ui rpak files as we separate all title screen assets and put it into this new pak.
2025-01-09 17:08:47 +01:00
Kawe Mazidjatari
03dd7046a6 Engine: use correct format specifiers for edict_t
edict_t is an u16 and will always be as that is the type it uses in the engine itself.
2025-01-09 17:06:29 +01:00
Kawe Mazidjatari
eee6aed033 Engine: qualify functions as static where possible 2025-01-09 17:05:28 +01:00
Kawe Mazidjatari
c2deaaf3e8 DebugSurface: implement new texture streaming debug overlay
Implement a new imgui based texture streaming overlay. The old one typically clips out of the screen and cannot be explored.
2025-01-08 21:44:14 +01:00
Kawe Mazidjatari
6a8eb40930 Engine: light cleanup on CVEngineServer 2024-12-05 20:05:39 +01:00
Kawe Mazidjatari
8c85e1ec68 Revert "Engine: properly detect if we are in single player mode"
This reverts commit 9939d963efa13332a1b9c2cf0d53bd90bc772ed1. It turns out we actually should check on !g_pServer->IsActive() as we shouldn't restrict on our listen server. Development code heavily relies on this.
2024-12-05 20:05:13 +01:00
Kawe Mazidjatari
9939d963ef Engine: properly detect if we are in single player mode
This check is meant to drop the restrictions if we are in single player mode, we should however properly check in this by checking the actual game mode rather than if the listen server is running.
2024-12-05 15:57:48 +01:00
Kawe Mazidjatari
3209af9a6c Engine: large server host code refactor
This code was written at the start of the project before much of the engine was reverse engineered. There were some design problems where core server functions were shared with UI script.

A second problem was that not everything was properly synced between another; CServerHostManager held its own instance of the server name and server description, while the engine has actual convars to store these. So scripters weren't able to get the server name and server description if the server was a listen server and launched through the title screen.

The CServerHostManager class has been reworked to not keep a second instance, and the script functions for creating the servers have been reworked to always store the name and description in aforementioned convars.

Also moved the CreateServer and DestroyServer function to the UI namespace of scripts, and it is now only registered in UI context. The server should use GameRules_ChangeMap() to switch levels instead.

UI script also no longer registers core server functions, this was a design mistake and has been fully factored out in this patch.

The server script function 'SetClassVarSynced' has also been deprecated and removed, since calling this sends a netmsg to all connected clients, and running this once will not apply the new class var values to clients connecting afterwards. This should be managed through player.SetClassVar in the connect codecallbacks in scripts.
2024-12-05 15:53:40 +01:00
Kawe Mazidjatari
77851d9ad7 ImguiSystem: reset keydown state properly once window closes
In commit 1fd4c25cd0188f96c7d1fe7b0a8b072763eed032, an attempt was made to fix this by calling the message handler with WM_NULL, but WM_KILLFOCUS should've been passed instead, as Dear ImGui clears the keydown state with this message. WM_NULL does nothing.
2024-11-28 00:26:15 +01:00
Kawe Mazidjatari
c8e8bea154 Windows: remove extraneous code
PostMessage hooks are no longer needed as we properly handle the messages when the imgui window procedure is running. The g_nWindowRect global is also no longer necessary because we now properly update the CGame's window size members as of commit 7ec1e679fd2676cde8e286812a0f5bec454f7d92.
2024-11-24 14:52:31 +01:00
Kawe Mazidjatari
7ee1626233 Engine: add setters for game window rect 2024-11-24 14:45:02 +01:00
Kawe Mazidjatari
fd04eef1ce ImguiSystem: add method for checking if we have an active surface 2024-11-24 14:02:37 +01:00
Kawe Mazidjatari
c09e6d6948 Engine: expose Host_Error
Should be callable by other code.
2024-11-24 12:12:38 +01:00
Kawe Mazidjatari
ec77faeb97 Engine: fix incorrect function pointer for sigscan debugger 2024-11-24 12:07:43 +01:00
Kawe Mazidjatari
ab0ec34e80 Engine: fix underflow vulnerability in CL_CopyNewEntity
Code only checked upper bounds, this patch adds an additional lower bounds check.
2024-11-24 12:05:49 +01:00
Kawe Mazidjatari
2128b0ad04 Engine: properly handle under/overflows in CL_CopyExistingEntity
The engine expects the pbError parameter to be set when there is an error. Also call Host_Error to let the user know why we errored out.
2024-11-24 12:03:08 +01:00
Kawe Mazidjatari
10b466bde7 Engine: use new reverse engineered types for CL_CopyExistingEntity 2024-11-24 11:59:55 +01:00
Kawe Mazidjatari
ffbbbfc483 Engine: fully reverse engineer CEntityInfo & CEntityReadInfo 2024-11-24 11:55:53 +01:00
Kawe Mazidjatari
1fd4c25cd0 Engine: fix imgui regression causing inputs to be stuck
Holding a key while closing the panel will keep the message in the event queue, the next time one of the windows are opened, the message will be spammed. Send a null msg to clear it properly.
2024-11-24 00:40:44 +01:00
Kawe Mazidjatari
f212e96a96 Engine: decouple imgui window procedure from main
Light cleanup.
2024-11-20 17:12:42 +01:00
Kawe Mazidjatari
3eea52b199 RTech: rename pak fifo lock state pointer
Should be called g_bPakFifoLockAcquiredInMainThread, as the system has to account for the lock depth if the lock was acquired in the main thread.
2024-11-17 02:19:54 +01:00
Kawe Mazidjatari
d4d2244b93 Engine: inherit IEngineAPI through CTier1AppSystem
Must be inherited through CTier1AppSystem to match the game's interface. Removed extraneous IAppSystem virtual method declarations as they are no longer needed to pad the vftable out.
2024-11-15 15:24:55 +01:00
Kawe Mazidjatari
1e7bfcde2e AppFrameWork: adjust IAppSystem interface
In this engine, GetTier() doesn't exist, GetDependencies() however does exist (confirmed by the vftable for CInputStackSystem) and therefore we should adjust all interfaces to make it use this instead.
2024-11-15 14:58:57 +01:00
Kawe Mazidjatari
bc54931408 Engine: detour function CEngineAPI::OnStartup()
Allows for initializing SDK code before or after CEngineAPI::OnStartup().
2024-11-15 13:49:29 +01:00
Kawe Mazidjatari
f0fcb821a8 Engine: only call ImguiSystem message handler when imgui surface is active
Save even more performance by not calling the ImguiSystem message handler at all when the imgui surface isn't active; we don't need to track input movement at all when this isn't active. Also dropped the blockage of all window messages except 'WM_SETCURSOR', added a detailed comment as to why this is blocked.
2024-11-15 13:40:39 +01:00
Kawe Mazidjatari
36bee21784 Engine: set correct type for member variable
Member variable 'm_pInputContext_Maybe' is confirmed to be 'm_hInputContext', set correct type.
2024-11-15 13:38:02 +01:00
Kawe Mazidjatari
14e0c8f5e4 Engine: separate server and client offline configuration files
Dedicated server or Client only builds will warn to the console if something is trying to set a convar, or execute a concommand that doesn't exist. Dedicated server builds don't have client commands/convars, and visa versa.
2024-11-14 15:49:57 +01:00
Kawe Mazidjatari
3d5ddd2bed Client: update the "name" convar in "cl_setname" concommand callback
Update the name everywhere in code.
2024-11-14 15:44:27 +01:00
Kawe Mazidjatari
e8fe12b4fd Engine: fix heap buffer overflow
Should always leave 1 byte for the null terminator in the persona name buffer.
2024-11-14 15:26:40 +01:00
Kawe Mazidjatari
da6ffe9005 Engine: implement pak preloading
Some specific paks are loaded through code (common.rpak, ui.rpak. etc). We have implemented a system that also loads 2 common rpaks that are of our own (common_sdk.rpak and ui_sdk.rpak).

There is al additional syustem we had implemented earlier that allows you to mount rpaks during level load, which will get loaded before the actual level rpak, this is useful as when we port a map that has evolved slightly from its original one, only needing 20 new models, it makes more sense to load the original rpak + a new one that contains the 20 new models to save disk space.

This is also useful for mounting paks specific to mods for a certain map, however since we have some core mods (flowstate) we have to add it to the settings for for each level. These paks also get dropped and reloaded each time on level changes causing longer load times and more memory usage during level loads.

This system mounts paks after all common paks are loaded (from both the engine and sdk), and keeps them active just like the common paks throughout level changes until they are either manually unloaded, or the game has been closed.
2024-11-14 14:54:27 +01:00
Kawe Mazidjatari
46e2424bb2 Engine: increase default stringcmd quota to 32
16 was causing the clients to get kicked when they hover and moving their cursor over the characters in character select very fast. The scripts tell the server to update the view to other clients but unfortunately the system relies on string commands (ClientCommand) and is pending a rewrite to incorporate a proper RPC just like Server and UI has. For now we increase the limit to 32 as 32 is still outside the exploitable range when the game is ran without dev tools enabled.
2024-11-12 02:08:40 +01:00
Kawe Mazidjatari
a809b1f262 Server: remove exraneous client pointer check
CServer::GetClient() will never return NULL as it returns address of client in array. Removed extraneous checks as its misleading, and added const where possible.
2024-11-11 17:47:36 +01:00
Kawe Mazidjatari
43e162711e Core: add option to run the game fully offline
The game can now be ran fully offline by providing '-offline' to the command line arguments. The engine will auto execute 'system/autoexec_offline.cfg' which overrides other autoexecs to ensure the game runs offline. The system/autoexec_offline.cfg file only overrides the variables it sets.
2024-11-09 01:22:43 +01:00
Kawe Mazidjatari
a702323181 Pylon: add option to fully disable matchmaking server connection
Fully disable the system if pylon_matchmaking_enabled is false.
2024-11-09 01:19:23 +01:00
Kawe Mazidjatari
d0ec49cc52 RTech: fix resource leak
CustomPakData_t::numHandles was never decremented on unload, causing pakId == PAK_INVALID_HANDLE to be true and triggering the assert. Due to this, we either never unload resources properly on subsequent unloads and loads, or we would run out of pak slots as numHandles will reach MAX_CUSTOM_PAKS. Also added a comment explaining why this loop isn't ran in reverse.
2024-11-08 21:51:04 +01:00
Kawe Mazidjatari
046c37f160 Engine: improve level pak unload logic
Only handle level related paks and data when we are processing the level pak (the 4th pak in the list).
2024-10-07 11:17:16 +02:00
Kawe Mazidjatari
e925f4cb6e Engine: fix level pak unloading crash
Changing the load/unload system to FILO caused a crash when loading 3 level paks, either through request load or level settings, and then unloading them in reverse order. This is a regression caused when the pak loading and unloading system was reworked. Changing the system back to FIFO fixes the issue.
2024-10-07 11:07:06 +02:00
Kawe Mazidjatari
56b884c7ff Engine: remove duplicate forward declaration 2024-10-06 11:47:30 +02:00
Kawe Mazidjatari
04afde3a80 Common: rename netmsg function 2024-10-04 12:50:03 +02:00
Kawe Mazidjatari
432cb923cc Engine: fix compile error
Netmsg is defined as SVC_SetClassVar, not as SVC_SetClassSettingsVar. Rename was missed before submitting b11d7e3c9b1555673d6cb490e60eca19153195e9.
2024-09-28 12:28:28 +02:00
Kawe Mazidjatari
b11d7e3c9b Engine: add new netmsg 'SVC_SetClassVar'
Netmessage SVC_SetClassVar allows the server to change class settings securely on the client. This was implemented due to popular demand, and previous approaches using a combination of ClientCommands (Cbuf and NET_StringCmd) were deemed insecure and unreliable.
2024-09-25 20:08:28 +02:00
Kawe Mazidjatari
8abbed283e Engine: add implementation for registering new netmessages 2024-09-25 15:04:45 +02:00
Kawe Mazidjatari
10efa56c58 Engine: don't run NVIDIA Reflex if -gfx_disableLowLatency was specified
This command line argument should fully disable NVIDIA Reflex, AMD Anti-Lag 2 and PCL statistics.
2024-09-16 16:27:02 +02:00
Kawe Mazidjatari
0eb0d73ae1 Game: make AI utility class instance static
Static allocation instead of dynamic.
2024-09-16 14:15:15 +02:00
Kawe Mazidjatari
690272e8e1 Engine: fix compile error for dedicated server
NormalizeFrameRate should not be compiled for dedicated as g_pGame only exists on client builds.
2024-09-14 12:11:29 +02:00
Kawe Mazidjatari
720584be25 AMD: Implement Anti-Lag 2 SDK
AMD's equivalent of NVIDIA Reflex.
2024-09-14 11:57:18 +02:00
Kawe Mazidjatari
d399b486b6 NVIDIA: rename Reflex function prefixes
Prevent ambiguity when AMD Anti-Lag 2 is implemented.
2024-09-13 21:29:25 +02:00
Kawe Mazidjatari
d95d071afd Tier1: properly implement ConVar change callbacks
Change callbacks actually take a structure of 2 pointers, one being for the callback itself, and the other being 'userdata' which typically is used to sync the ConVar with VGUI slider elements. This issue was noticed after implementing the ADS scalars and attempting to hook them up to VGUI, only to find out it would crash due to this lacking detail. All change callback prototypes had to be adjusted.
2024-08-05 00:45:30 +02:00
Kawe Mazidjatari
1e667c8f30 Engine: use CThreadMutex for installed maps global
Use the type used by the engine instead of STD.
2024-08-03 11:03:39 +02:00