52 Commits

Author SHA1 Message Date
Kawe Mazidjatari
9113b36bfd Core: fix typo's in function comment headers
Small typo's, fixed to retain consistency.
2024-09-04 01:09:09 +02:00
Kawe Mazidjatari
291ce4488a Client: fix push/pop style var mismatch
Since the table was taken out of the child instance in commit 245ff565042870e0cded7a2ec3dcc868a00414af, we should no longer handle the window and frame separately. Car count must now be counted together.
2024-08-21 02:26:48 +02:00
Kawe Mazidjatari
245ff56504 Client: freeze server list detail columns
Keep the details column in display when scrolling.
2024-08-18 23:32:16 +02:00
Kawe Mazidjatari
5223ac8631 RTech: refactor playlists reloading/caching
Mutex is technically no longer needed as imgui now draws in main and gets buffer swapped / rendered in the render thread just like the rest of the game. But the mutex was still in because of the shared script function 'Script_GetAvailablePlaylists' that can be used on the server. Both the 'playlist_reload' and 'downloadPlaylists' commands will now join the active server job if ran to prevent crashing in the engine or sdk when ran during the game.

There was also a performance difference between 'playlist_reload' and 'downloadPlaylists' while the commands are identical. There was a bug where the 'playlist_reload' one called 'Playlists_SDKInit' twice. This has also been fixed in this commit.
2024-08-03 12:06:42 +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
Kawe Mazidjatari
044528b9b1 Game: properly load shared global vars for game dll's
Properly load it from CServerGameDLL::DLLInit (and new in this commit, the client's shared globals from CHLClient::Init), this way we can also avoid the double dereference which improves performance. Also performed an architectural change where anything outside Game DLL code uses the shared interface pointer instead of the objects directly.
2024-07-31 22:18:33 +02:00
Kawe Mazidjatari
fea8603258 ImGui: add shortcut button for reparsing all scripts
The "Reparse all scripts" button reparses every script file, and reloads/reconnects the game.
2024-07-01 00:25:31 +02:00
Kawe Mazidjatari
bec5d2746f ImGui: use cached value for clamped window width
Remove extraneous indirection.
2024-05-26 22:22:46 +02:00
Kawe Mazidjatari
cc248abc59 ImGui: increase base64 key buf size
Make buffer size as large as that of the engine itself (used to represent the string in class CNetKey).
2024-04-17 21:22:13 +02:00
Kawe Mazidjatari
5c3f06f192 ImGui: improve browser modal QOL
Hitting enter will now also submit the request.
2024-04-17 21:19:53 +02:00
Kawe Mazidjatari
20c8bf6a0c ImGui: fix server modal token input bug
The string buffer was moved to the stack on a recent refactor, but the data must persist even outside the function scope. Moved back to class in form of a buffer.
2024-04-17 21:18:51 +02:00
Kawe Mazidjatari
58d7c8f7a5 ImGui: update default server browser width
As of the recent layout changes, buttons and widgets looks the sharpest on this width; default to this width instead.
2024-04-17 20:53:50 +02:00
Kawe Mazidjatari
e657d62aee ImGui: fix logger not fading in/out with alpha
m_fadeAlpha should also be applied on the color logger.
2024-04-05 19:38:10 +02:00
Kawe Mazidjatari
a75219825d ImGui: fix console scrollbar feedback loop bug
Make use of newly added flag "ImGuiWindowFlags_OverlayHorizontalScrollbar" as per commit 60e4514b7b5c56db89102a3d66ef28a14118b8fd. Also removed flag "ImGuiWindowFlags_AlwaysVerticalScrollbar", only show the vertical scrollbar when its visible. Enabled code that takes the scrollbar into account in function CTextLogger::EnsureCursorVisible().
2024-04-04 16:13:39 +02:00
Kawe Mazidjatari
f9559b609d ImGui: fix server visibility bug
If host status is set to offline after the server is launched, the browser would continue to broadcast the server. This patch makes sure that if the visibility has been set to offline, the server would no longer be broadcasted to the master server.
2024-03-10 01:59:57 +01:00
Kawe Mazidjatari
63237361e9 NetworkSystem: fix numerous issues
This patch splits host logic from CServerListManager. CServerListManager is actually meant for the client to manage the server list to which the client could connect to. The hosting logic has been moved to the new CServerHostManager class.

Previously, we stored all the hosting details in CServerListManager, with connection criteria in CPylon, this data has been moved over to CServerHostManager as well.

Previously, we also needed a mutex to access the server host data, function HostState_KeepAlive() has been refactored to the point this mutex is no longer necessary as the only threaded process is the actual request, the rest is being applied in the main thread. We also now only construct a NetGameServer_t struct if we actually plan to host.

Access to CPylon::m_Language is now also protected by a mutex, as the change callback of cvar 'language' and the threaded method 'CPylon::QueryServer()' are competing for access.
2024-03-10 01:57:04 +01:00
Kawe Mazidjatari
1908efce96 ImGui: constify local variable 2024-03-07 22:36:00 +01:00
Kawe Mazidjatari
8912ceb30c ImGui: properly attach autocomplete suggest window to console
Make sure the autocomplete suggest window is always behind the console window with nothing in between. Previously, the server browser or modal panel ended up between the autocomplete suggest window and console window if the console was focused after the browser was invoked and moved partially on top of the console.
2024-03-07 22:35:13 +01:00
Kawe Mazidjatari
17385d6f1d ImGui: add render frame stage and scope mutex 2024-03-07 22:32:24 +01:00
Kawe Mazidjatari
67aab9650a ImGui: remove extraneous window flag
No flags needed here, just pass ImGuiWindowFlags_None.
2024-03-03 14:43:00 +01:00
Kawe Mazidjatari
2d40486881 ImGui: make imgui flags constants instead 2024-03-03 14:42:22 +01:00
Kawe Mazidjatari
f7e7d1fb7a ImGui: fix server browser list clipper and pass filter bug
Filter results first before clipping them.
2024-03-03 14:40:57 +01:00
Kawe Mazidjatari
229a6491c7 ImGui: always rebuild summary text on input text change
This fixes corner case bugs like selecting currently entered text, and deleting it at once. If we happen to show a ConVar's value, and do the mentioned action, it wouldn't clear it as "if (iData->BufTextLen)" won't satisfy.
2024-03-02 01:57:16 +01:00
Kawe Mazidjatari
94a2de05d7 ImGui: move summary text above input text
The pass filter has some features (including, or excluding with the '-' prefix), but this isn't very clear. Added the original 'usage' text back, which caused the following issue: the summary text (showing how many history items, or the currently selected convar's current value/default value) would clip outside the console window on ConVar's that had larger string values, like URL's. The summary text has been moved to just above the input text field to fix this issue. This patch also contains some slight improvement to styling of the console.
2024-03-02 01:54:04 +01:00
Kawe Mazidjatari
06a4587ab7 ImGui: pad last button in server browser correctly
Previously, it would clip with the resize handle due to commit eda8048a982f88611710bcded1d2245e9d42d95e
2024-03-02 01:47:11 +01:00
Kawe Mazidjatari
5f41c4e9f1 ImGui: clip server listings if they exceed rect
Use ImGuiListClipper to clip anything not visible.
2024-03-02 01:45:41 +01:00
Kawe Mazidjatari
0b8017d3e6 ImGui: don't use textures for autocomplete if the loading failed
Otherwise the indices will be incorrect and will cause undefined behavior.
2024-03-01 14:06:09 +01:00
Kawe Mazidjatari
7f36220448 ImGui: console and browser code style refactor
Made the style of the code more consistent. Not much logic-wise had changed during the refactor, but there are some.

Console:
* Removed m_bSuggestUpdate and the logic bound to it, this var was never set and the logic was never used. This was the initial workaround for resetting the autocomplete selection pos to kPark (-1), but this is currently done in a more mature way, but the old code was never removed
* CreateSuggestionsFromPartial() (previously, FindFromPartial()) would break if a ConCommand/ConVar was found that was already added in the list. Although this is an engine/sdk level bug, we shouldn't stop iterating there. Added an assert instead and made the loop continue.
* Removed member m_bCopyToClipBoard, this was used to check if the copy button was pressed, to copy the text the next frame. The copy now happens directly in the site of the Copy button which is a better approach.
* Due to the changes with removing m_bCopyToClipBoard, the mutex for m_colorTextLogger is now released right after rendering the color text to fully minimize blocking time between other threads.

Browser:
* Moved ImGui::Begin() call from RunFrame() to DrawSurface(), it fits better there and we can now also return false if the frame didn't render.
* Improved the "Broadcasting" text formatting when server browser is hosting and broadcasting without a server token (public server).

Both:
* Added virtual Shutdown() method.
2024-03-01 13:39:06 +01:00
Kawe Mazidjatari
06b2226bbc ImGui: make config singleton static
Avoid indirection, also deduplicate common style var assignments.
2024-02-29 22:31:43 +01:00
Kawe Mazidjatari
f3ee2e3e90 ImGui: improve autocomplete window size
Use convars to determine the size, by default the width is the same size as the input text bar. The height has also been increased with 90f (shows 12 elements now, this fits perfectly when the game is launched with default options). Also properly clamp the autocomplete window
2024-02-29 22:26:44 +01:00
Kawe Mazidjatari
eda8048a98 ImGui:: correctly calculate item width
Fixed bug where changing the server browser causes the alignment of the buttons with the right side border to mess up.
2024-02-29 16:02:18 +01:00
Kawe Mazidjatari
4578401f33 ImGui: fix console input suggestions bug
Don't draw the suggestions window if the console has been collapsed.
2024-02-29 13:19:10 +01:00
Kawe Mazidjatari
8f09ac1b86 ImGui: cleanup and improvement to surface implementation
* Properly run fade in-out animations
* Make common methods/members shared
* Remove extraneous SDK thread
2024-02-29 13:18:18 +01:00
Kawe Mazidjatari
f9ed276cbd ImGui: reset horizontal scroll position when command has been submitted
Small UX improvement.
2024-02-29 01:00:24 +01:00
Kawe Mazidjatari
88c8727af1 ImGui: add 'ImGuiWindowFlags_NoNavInputs' to console logger
Prevent the logging view area from moving within the console window.
2024-02-28 23:54:10 +01:00
Kawe Mazidjatari
3f74b4a2b6 ImGui: heavy optimizations to text logger (WIP)
This code originated from an imgui code editor, where it would make sense to have per-character colors. But for the console, we only ever do 1 color per line. Just store the string and one color instance, this also allows us to just take the string instead of manually reconstructing it which is very slow. The code now also only stores 32bits for color (per line) instead of 128 bits (ImVec4) as we only ever need to convert it once.

As a result, a bunch of rendering code could be dropped, and the pass filter is now also very fast as we don't need to reconstruct the string to check for the filter, we just pass a char* in which doesn't cost any perf.
2024-02-28 19:16:31 +01:00
Kawe Mazidjatari
420cb7a68d Engine: make task queue singleton static
Compile it as static object & renamed to more correct names. Also made the integral type for frame delay an unsigned int instead
2024-02-28 00:43:57 +01:00
Kawe Mazidjatari
3e3bc79adf ImguiSystem: properly implement ImGui and fix several bugs
Moved implementation to dedicated class 'CImguiSystem' with the following changes:

* Added mutex for ImGui_ImplWin32_WndProcHandler(), the window proc is ran from a different thread than CImguiSystem::SampleFrame() is being called from. Needs a mutex as both functions interact with the input queue list.

* Added init stages for debugging and preventing the system from running certain parts of the code if a certain stage hasn't been reached yet.

* NULL out ImGuiContext::ConfigNavWindowingKeyNext , we don't need any nav window shortcuts as users don't need then in-game, and it also interferes with certain key binds some users have.

* CImguiSystem::SampleFrame() (previously ImguiSystem_SampleFrame()), is now being called from CMaterialSystem::SwapBuffers(), as that function is called from the main thread while also getting updated during level loads/etc, so instead of switching between 2 static buffers for as long as the levels are being loaded, we imgui updates properly too and directly swap afterwards.

* Removed hack in CGame::WindowProc() where we would only run windowproc if we aren't shutting the game down. This was needed as there was a chance of a crash at some rare cases, but this was simply due to a missing mutex which has been addressed and fixed as of this commit.

* Lock mutex during init and shutdown.
2024-02-27 17:43:18 +01:00
Kawe Mazidjatari
94857cf783 Console: fix max console lines bug
We must check on con_max_lines + 1 since the first line is a dummy.
2024-02-25 20:21:17 +01:00
Kawe Mazidjatari
e967cb374b Engine: render ImGui in main thread and fix many threading bugs
ImGui drawing code now takes place in the main thread, a snapshot of the render data is created in CMaterialSystem::SwapBuffers(), and is being rendered in the render thread right before SpinPresent().

The reason why this was necessary, is because ConVar::GetString() isn't thread safe if its not marked FCVAR_MATERIAL_SYSTEM_THREAD or FCVAR_ACCESSIBLE_FROM_THREADS, and we used it for the console suggestions window, which iterates over every ConVar, accessible from threads or not.

This is overall also a better code architecture.

This change also forced changes in the ImGui server browser window, which contained a bunch of threading bugs too.

Engine changes:
- g_pCVar is no longer exported, as this wasn't necessary in the end.
- g_ThreadMainThreadID and g_ThreadServerFrameThreadID are now exported from the game executable, as these are required as soon as the DLL is loaded.
2024-02-25 20:12:56 +01:00
Kawe Mazidjatari
7f6846a315 Upgrade Dear ImGui to 1.90.4 2024-02-25 01:47:46 +01:00
Kawe Mazidjatari
6828901815 Tier1: static construction of ConVar objects during link time
Fully implemented ConVar class so we could statically construct all SDK convars, this avoids a level of indirection, and allows for creating ConVar's everywhere in the project.

This patch also removed the settings tab of the ImGui server browser, as it has threading issues, while it technically never caused a crash yet, it has been removed as there was no point keeping it vs the work required to make it thread save (it only managed 2 convars which are perfectly manageable through cfg's or the in-game console).

Also temporarily disabled the creation of ConVar's in the mod system due to a memory leak, we would allocate and register a convar based on details parsed out of a mod file definition, but never unregister and free it.
2024-02-24 02:15:09 +01:00
Kawe Mazidjatari
3d36c87b08 Statically construct all ConCommand
Properly implement the ConCommandBase and ConCommand classes so we could statically construct all ConCommand objects in the global scope of each translation unit, this way we don't need to put them in a global file and deal with preprocessor directives to compile then in/out for certain projects.
2024-02-23 00:12:06 +01:00
Kawe Mazidjatari
39d16fa4d7 NetworkSystem: rename NetGameServer_t member vars 2024-01-29 23:00:15 +01:00
Kawe Mazidjatari
8911bfa81a GameUI: cleanup and fix race condition
* Use CThreadFastMutex instead
* Rename ISurface to IDebugSurface to prevent a potential name collision with VGUI's ISurface iface if we ever add it
* Fix race condition when setting CPylon::m_HostIP from materialsystem thread, this has been dispatched to the main thread
* Marked 'pylon_matchmaking_hostname' FCVAR_MATERIAL_SYSTEM_THREAD as we use it in the server browser panel.
2024-01-21 23:06:26 +01:00
Kawe Mazidjatari
1361bfb172 Make singletons use static memory
Avoid heap memory allocation and a level of indirection. This allows the compiler to optimize the program even more. No logic has been changed in this patch.
2024-01-21 21:29:23 +01:00
Kawe Mazidjatari
cd82e22ea3 Tier1: move KeyValues class to Tier1
The KeyValues class belongs here. Also reimplemented most loading methods for KeyValues, and adjusted the VPK building code to account for it. Pointers to the engine's implementation of KeyValues have been moved to a separate header ('keyvalues_iface.h'), as this allows external tools code to utilize the standalone KeyValues class implementation. Playlist utilities are completely separated from the KeyValues header; these have nothing to do with KeyValues other than manipulating a global KeyValues object for the playlists, and thus have been named as such and moved to rtech/playlists.
2024-01-12 00:52:07 +01:00
Kawe Mazidjatari
e825a1e7a8 IDetour: remove extraneous pointer assignments
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
2024-01-02 15:21:36 +01:00
Kawe Mazidjatari
b9a24b30af Change JSON field types send to master server
They were all strings; changed them to what made most sense for each field type. Changes:
"hidden": string -> bool
"port": string -> int
"checksum": string -> uint
"playerCount": string -> int
"maxPlayers": string -> int
2023-10-15 10:47:19 +02:00
Kawe Mazidjatari
f5eb2a2e08 Bugfix: don't print summaries of hidden cvars 2023-10-15 10:41:17 +02:00