Skip to content

Instantly share code, notes, and snippets.

@nosoop
Created April 15, 2022 07:59
Show Gist options
  • Save nosoop/e4d83bdb6ac9409a638aaef2ae38f48f to your computer and use it in GitHub Desktop.
Save nosoop/e4d83bdb6ac9409a638aaef2ae38f48f to your computer and use it in GitHub Desktop.

This patch is a fix for the bug observed in this video.

Requires Source Scramble and its manager plugin.

tf2.fix_ammo_gain_windows.patch.txt goes into addons/sourcemod/configs/sourcescramble and tf2.fix_ammo_gain_windows.txt goes into addons/sourcemod/gamedata.

"Patches"
{
"tf2.fix_ammo_gain_windows" "PackRatios::WindowsFix"
}
"Games"
{
"tf"
{
"MemPatches"
{
"PackRatios::WindowsFix"
{
"signature" "PackRatios"
"windows"
{
// changes the small pack ratio scalar from 0x3E4CCCCD to 0x3E4CCCCC
// 0x3E4CCCCD = 0.20000000298023224 : has issues with rounding precision on double-precision multiply operations (which is what MSVC does)
// 0x3E4CCCCC = 0.19999998807907104
// source: https://babbage.cs.qc.cuny.edu/ieee-754.old/32bit.html
// the game rounds the result up, so having it be slightly less than 0.2 is preferable
"offset" "0h"
"patch" "\xCC\xCC\x4C\x3E\x00\x00\x00\x3F\x00\x00\x80\x3F"
}
}
}
"Signatures"
{
"PackRatios"
{
// just grab the array from memory lol
"library" "server"
"windows" "\xCD\xCC\x4C\x3E\x00\x00\x00\x3F\x00\x00\x80\x3F"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment