Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Cybran briefing audio playback issue and do a coop release #117

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 1 addition & 58 deletions init_coop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,63 +19,6 @@ LOG("Client version: " .. tostring(ClientVersion))
LOG("Game version: " .. tostring(GameVersion))
LOG("Game type: " .. tostring(GameType))

-------------------------------------------------------------------------------
--#region Adjust process affinity and prioritity

-- The rendering thread appears to pin itself to the first computing unit of
-- a computer. The first computing unit is often also used by othersoftware,
-- including the OS. Through empirical research the framerate of the game is a
-- lot more consistent when we do not give it access to the first computing
-- unit.

-- That is what this section helps us do. The game functions best when it has
-- at least four computing units available. If we detect someone has 6 or more
-- computing units then we take the game off the first compute unit.

-- Note that we can not make the distinction between real computing units and
-- computing units that originate from technology such as hyperthreading.

local SetProcessPriority = rawget(_G, "SetProcessPriority")
local GetProcessAffinityMask = rawget(_G, "GetProcessAffinityMask")
local SetProcessAffinityMask = rawget(_G, "SetProcessAffinityMask")

if SetProcessPriority and GetProcessAffinityMask and SetProcessAffinityMask then

-- priority values can be found at:
-- - https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setpriorityclass
local success = SetProcessPriority(0x00000080)
if success then
LOG("Process - priority set to: 'high'")
else
LOG("Process - Failed to adjust process priority, this may impact your framerate")
end

-- affinity values acts like a bit mask, we retrieve the mask and shift it if we think there are sufficient computing units
local success, processAffinityMask, systemAffinityMask = GetProcessAffinityMask();
if success then
-- system has 6 (logical) threads or more, skip first two computing units
if systemAffinityMask >= 63 then
processAffinityMask = systemAffinityMask & (systemAffinityMask << 2)
end

-- update the afinity mask
if processAffinityMask != systemAffinityMask then
local success = SetProcessAffinityMask(processAffinityMask);
if success then
LOG("Process - affinity set to: " .. tostring(processAffinityMask))
else
LOG("Process - Failed to adjust the process affinity, this may impact your framerate")
end
end
else
LOG("Process - Failed to retrieve the process affinity, this may impact your framerate")
end
else
LOG("Process - Failed to find process priority and affinity related functions, this may impact your framerate")
end

--#endregion


-- upvalued performance
local dofile = dofile
Expand Down Expand Up @@ -679,4 +622,4 @@ MountDirectory(SHGetFolderPath('LOCAL_APPDATA') .. 'Gas Powered Games/Supreme Co
MountDirectory(fa_path .. "/movies", '/movies')
MountDirectory(fa_path .. "/sounds", '/sounds')
MountDirectory(fa_path .. "/maps", '/maps')
MountDirectory(fa_path .. "/fonts", '/fonts')
MountDirectory(fa_path .. "/fonts", '/fonts')