Just imagine, instead of using your flamethrower to spy check, you instead follow the person around and wait for them to pick up a health pack and then calculate to see if they got 1 HP too many.
@@Spacebugg eventually hes going to get a bug that makes him completely immune to both airblast and afterburn, while also making it so he looks like hes not on fire. You know this right?
You have no idea how the health from a small health pack being listed as "20.5%" "wrongfully" on the TF2 wiki has driven me mad with questions as to how a random .5 was added seemingly out of nowhere, holy shit thank you for this explanation now I can finally rest in peace somewhat I guess.
That's clever, but I think the emulated CPU of the VM will still use the instruction the compiler told it to use, which is mulss for a GNU/Linux executable. So you will get the same result as if you were running GNU/Linux natively. And yes, I will call it GNU/Linux rather than Linux because the GCC compiler written by GNU is actually relevant here.
Unless I completely missed the point and you actually meant to run a Windows server executable inside a Windows VM on a Linux-based hypervisor. Then it could work.
and i thought some year ago that they changed it from 41 to 40 intentionally ... but now knowing they "fixed" it by changing the server OS is marvelous
The way that TF2 seemingly conspires with the very fabric of computing to create ridiculous spychecks has me in love with the game. I don't play it, more like, adore how it has all that wackiness in both code and lore.
Your editing doesn’t get as much love as it should; it’s so clean, and it helps with understanding a lot. Thank you for putting lots of effort into editing!
the reason I know of this channel at all is because of the KILLER thumbnail / title combo of the "weird hitboxes lets you shoot through dudes sometimes" (paraphrased) video I kinda wish more of his thumbnails captured the same energy as that one, but nevertheless I'm more than content with the editing and content within the videos themselves.
For those wondering, MULSSSSSSSSSSS means Multiply Single Scalar. Single as in single precision. Precision being number of decimal points to the right.
Important to note that float->int conversions will always truncate the extra precision. Valve made the deliberate choice to round up here, when they should have used a round-to-nearest algorithm instead.
Would doing that use more processing power or time or something? Obviously nowadays the difference is probably microscopic on a newer processor, so I am thinking more about the impact it would have had on a processor built between 2003-2008. (I choose that large of a range because TF2 uses a variant if the HL2 engine, which came out in 2004.)
@@DragonBallZKaifan2 no, they did it because damage should be rounded up (else chip damage would be rounded to zero at far range) and they recycled the function
@@shigekax Fixed values would mean, they need to define the values for each possible combination of max-amount of resource and type of resource. With dozens of weapons that change max-health or max-ammo for each class, this would be near impossible to manage.
Words cannot describe how impressed I am that you found this. The "41 metal" problem has been bugging me for years, and I had just assumed it was caused by a million different parts of the spaghetti code working together in exactly the wrong way
Wouldn't call it an update, because running servers on Windows is just hell on earth. (In my opinion, running desktops also is) *But definitely worth it for the 1 extra ammo*
That’s not spaghetti code anymore, it’s more like a hydra that you have been trying to kill for the past decade and it has grown so many heads, they started to intertwine with each other and make the creature unable to do anything. You still can’t kill it tho
@@RustyNova yeah for me it’s just the fact that it’s been so long since the game release and people still discover new bugs and exploits every now and then. It’s kinda funny.
Tf2 tech in 2009: you can use your rocket launcher to get up on high places Tf2 tech in 2022: you can identify a disguised spy on a windows server by a computing irregularity which seems to add another point of health to the spy whenever he picks up a small hp kit
Someone might argue this means Valve only tested their game on Linux. While not technically incorrect, it's more likely they just didn't test it at all.
Actually these bots you find on TF2 today are actually all running Windows machines. You can pull up a statistics page of users on TF2 and OS Statistics and shows that 99% of these bots are running off Windows machines.
@@AzzieEquinox The software has always been on Windows. Things are ported. It's easier on Linux, but most people run Windows and cheat on Windows. I play TF2 on Linux, play. I'm not a bot.
As someone who has nothing todo with the game I find it a bit misleading that this is mentioned in the video without any note. Gives the impression that tf2 has been decompiled or source leaked.
Oh my goodness, I *always* noticed this and never knew why sometimes it was 41 instead of 40. Your videos have been such a treat as a veteran TF2 player for almost a decade now.
I know that TF2 is still a 32-bit binary on Windows, but I wouldn't have expected that Visual Studio 2015 (guessing from the linker version 14.00 for all binaries in the TF2 directory) still makes such heavy use of x87 instructions for that target by default.
@@juango500 I believe that refers to special floating point or other arithmetic instructions that used to be on their own chip. The 8087 math coprocessor. Now they're part of any regular x86 processor if I had to guess.
Yes, FMUL is the original instruction for floating-point multiplication that has existed since Intel's first math coprocessor. Those instructions use an intermediate format that has more precision than the output, which can give slightly different results. MULSS on the other hand uses the SSE vector registers, which strictly compute according to the requested format (single-precision in this case, what the second S stands for).
@@lychy645 Both 32-bit MSVC and GCC are pretty reluctant to use just SSE1 on scalar values unless you enable maximum optimizations (-Ofast for the latter). Maybe it's because the original processors only could crunch both halves of XMM registers in succession. Clang on the other hand emits MULSS for -march=pentium3 and higher even without an optimization level.
FMUL (Floating MULtiply) operates on the venerable extended-precision (80-bit) x87 FPU registers. MULSS (MULtiply Scalar Single-precision) is a single-precision (32-bit) instruction that's a part of the more recent (1999) SSE instruction set. In either case, the result is getting passed to the ceil() function to round it up, when perhaps it should be rounded to the nearest integer instead. The ceil function takes a double-precision (64-bit) argument, so the extended-precision value gets truncated, but it's still enough precision to foul up the calculation. So the real bug here is Valve rounding UP instead of just ROUNDING, but it could have been avoided if they checked the box in Microsoft Visual Studio that says the game doesn't have to run on a Pentium II from 1997.
@@TheToomykins Which function? You mean the ceiling function? Because that's nonsense. That's like saying hair stylists should wear welding masks because welders also wear welding masks, because if they didn't they'd burn out their retinas.
Just like with damage there are debuffs (metal_pickup_decreased) which decrease the amount you receive. It doesn't make sense to receive nothing, to play a sound and display +/- when you aren't actually receiving anything. And if you picked up 3 ammo packs which each should give you 43 ⅓ metal based on all your current buffs/debuffs, you would expect to have enough for a sentry, but if you rounded to the nearest you would only have 129. A bit contrived, but still, as a player I would rather have more of something than less of it.
Imagine being a Spy and getting confused how the fuck the enemy team knew you're a Spy despite not doing something suspicious at all. And it turns out it's due to a freaking health pack
This is like when one of the devs responsible for porting HL2 to VR, had some door stay closed rather than opening because a function returned something slightly different because of the switchover from x87 to SSE
My favorite part of this channel is how you go into depth about WHY specifically things work the way they do, not just that it happens. It's by far my favorite stuff to learn about.
Yet another game oddity I noticed but never gave a deeper thought to. Love how even when it isn't Source's fault TF2 manages to have spaghetti code Edit: Okay I'm just going to change the comment entirely
This is absolutely interesting, I wanted to listen the video in background while doing other things, but without even notice, I watched everything with fascination. As worker in the video-game industry, I'm really passionate and curious about those really tiny details, I will truly look for the rest of this channel!
I've always wondered this! Thankyou for sharing, It's a great breakdown of the differences between compilers and unintended consequences of them. I also like all the quality visual editing making things really clear, even the small detail of making the linux and windows code compiler images have slightly different lights from each other. Excellent video as always ♥
I had a map from a couple years ago, pd_meme_machine, that never crashed until it was ran on a specific server. I looked at every possibility for what could be causing it to just randomly crash the server. Closest I got to figuring it out is that it always worked on a Windows server, and crashed the Linux servers (or vise versa, I can’t remember lol). Possibly due to some weird number or rounding issue that was different on each OS, screwing with the game logic or physics. Cool video shounic!
Being a Linux user I found this video to be a really interesting look into the technical challenges of multiplying two numbers. It's ironic that the Windows compiler produced code that tried to be more precise during these calculations, but it actually made it worse.
It feels like you could almost make it work by specifying when to round up or to the nearest depending on the situation, but knowing how much of a monster the spaghetti code for TF2 is, that would probably introduce more problems...
As an engineer main, i remember that weird non-round number, 41, and i always wondered where that +1 metal went. Never woulda guessed it would be operating system dependent
Man I love the way you create your videos, your title already answers the exact topic for people who are experienced in programming. I'm currently a games programming student at university and when I read that title I was thinking "yep there's a floating point precision error somewhere cause I know for sure the health is a float cause I've had 0 HP before.", even though it's not the right term to use, I still think it's right, as one floating point result is different than the other on a different OS. Your titles, your editing and your explanation to the design of the game's programming leading to the problem is insane, and I envy you so much on how you write these. I wish I could do this..! Great content, loving it. :)
just want to say this right now, genuinely in love with this channel (for multiple reasons) but maybe the biggest is the fact that you are far more immune to the clickbait sin that plauges most of this platform nowadays. i can see this video in my recommended, read the title, then instantly know the answer for the most part, and if im interested to know more i can watch the short and to the point video that will explain it for me. anyone else could have easily called it "THIS WEIRD BUG GIVES YOU (41) METAL?!" and i would never - ever - care to click on it because nothing about that interests me really. but nope, far better title here.
Oh my god, I KNEW IT! I knew I wasn't crazy! I distinctly remember getting 41 ammo from small packs but never being able to replicate it, thought an update fixed it. Thank you for the explanation!
If I recall, Microsoft actually has or had language in their license agreement that says it's not for use on things such as life support systems or missile systems
I had similar problem with a custom shader that I wrote for Unity. People with Nvidia cards didn't have any issues, but people who were using AMD cards, float to integer casting would result a different value which caused one crucial function to break on AMD cards. This was likely because I had done the casting in a weird way and debugging it without owning an AMD card was a nightmare
When you think about it, the only reason it would need to run a calculation instead of just dictating a set value is because MvM exists. So thank MvM for your extra metal engies.
Actually, I just thought of something you could cover for a brief little video. A lot of custom models no longer work in TF2 anymore, mainly because at some point Valve made the game stop looking in models/weapons/c_models and instead made wholly new folders in models/workshop/weapons/c_models and models/workshop_partner/weapons/c_models. which means that to get the old models to work again, you not only have to change their folder structure, but you have to hex edit the .mdl file and change the file path at the top near the header to reflect the proper file path. Maybe some digging as to why Valve chose to basically duplicate the entirety of the weapon models (because the old models and texture paths are still there and still contain their various vmt, vtf, and .mdl related files despite no longer actually being used.)
At a machine level, addition and subtraction are equally as complex, multiplication is much more complex than both, and division is mountains above multiplication. Not only would dividing by 5 be technically a harder computational operation for the machine with no greater accuracy, I wouldn't be surprised if the compiler would try and convert it into multiplication anyway.
its the multiplier of the ammo pack. Small ammo pack has 0.2 multiplier, medium has 0.5, big has 1.0 multiplier. It would simply be harder in the code to implement the division instead, they couldn't use the formula x=multiplier*max_ammo anymore. and besides, they simply didnt know that would happen.
@@wojtekpolska1013 what i really don't understand is where the 0.20000000(29.....) comes from. If i define float n = 0.2, shouldn't it be an exact 0.2 ?
@@HaartieeTRUE It won't be because computers use binary, they cannot have 0.2, cannot comprehend it. It must be some combination of ones and zeroes at the bottom of it all. 0.2 is 1/5th, in binary it is similar to decimal 1/3rd.
It's crazy how this immediately brought my brain back to an almost decade old memory of picking up a weapon from 0 ammo on 2Fort balcony and thinking "huh that's weird why does it give 41 ammo it should be rounded"
Cool video, i think i've never seen the 41 metal thing, i'm pretty sure i'd notice such an ocd inducing thing Quick question, do you know what's the deal with the reloading and touching the resupply cabinet, when you do you end up with 1 fewer round in reserve. Stay safe m'man
You start the reload animation, you’re going to fill your clip, then you touch a resupply cabinet. Your reserve and your clip are both full, but the reload animation continues, so it subtracts 1 from your reserves and adds it to your clip. Since the clip size is capped, it doesn’t actually change, but the ammo from your reserves still got subtracted.
Just a note: the fmul text at 2:15 was really hard to read for me. If you could use a combination with different brightnesses it would help a lot. Thanks!
One extra metal or ammo in most weapons isn't anything special, but one extra hp and rocket can be a game changer, and its crazy to imagine that something like this scored someone a kill or a survived death.
I wonder if this might also be the reason why R6 gives 1 more bullet in reserves at the beginning of the round, rather than a multiple of the ammo count in your weapon.
The "0.2 cant be represented"-issue might make no sense at first, but its very similar to how we can't fully represent fractions like 1/3 in decimal: We have to approximate it as 0.333333..., eventually cutting it off. In binary, a similar effect happens at different fractions like 0.2: (1/5) in binary is "0.001100110011001100110011001100110011001100110..."; it goes on infinitely long until you cut it off and loose accuracy.
Seems that ppl in the comments still dont understand the video: 1. It is *not* Microsoft's nor Windows's nor Valve's fault. the fault is entirely of the compiler using the wrong instruction when interpreting the game code. 2. It does *not* give Windows users an advantage, nor a disadvantage to Linux users. Almost all TF2 servers are hosted on Linux (Valve official servers, and most online services that allow you to pay for a server to host a game). Within one server, the players all will get the same ammo & metal, no matter their OS. So on Linux server, *BOTH* Windows and Linux users will get 40 metal from small ammo pack, and on Windows server, both will get 41. It provides no advantage to anyone, the bug only comes in effect, when a Windows user hosts a server on their own PC (Windows Server is much less popular than Linux), and then everyone no matter their OS gets 41 metal.
It's also not the fault of the compiler (after all, not like the compiler knows which result you want). If you want to blame anyone, blame Valve for not thinking about floating point weirdness and just rounding manually.
Just imagine, instead of using your flamethrower to spy check, you instead follow the person around and wait for them to pick up a health pack and then calculate to see if they got 1 HP too many.
Peak optimization.
@SereneKerosene you never see it cum man
What did I do?
Being in windows…
@@Alexandritax Yes.
@@dubbynelson am I a bad spy?
Every conversation ends with spy getting another bug at this point.
YOU FOOL! YOU JUST GAVE HIM ANOTHER BUG BY POINTING IT OUT!
@@sythrus good. Very good.
-a pyro main
@@Spacebugg eventually hes going to get a bug that makes him completely immune to both airblast and afterburn, while also making it so he looks like hes not on fire. You know this right?
@@sythrus uhh... dead ringer and spycicle?
@@sythrus yes but just like some wise guy said
*I HAVE. A SHOTGUN.*
You have no idea how the health from a small health pack being listed as "20.5%" "wrongfully" on the TF2 wiki has driven me mad with questions as to how a random .5 was added seemingly out of nowhere, holy shit thank you for this explanation now I can finally rest in peace somewhat I guess.
But isn't it 20% though? I calculated it and 20.5 gives different results. Oh wait that must've been on a linux server
Nah that doesn't explain it at all
This video only applies to ammo packs, health only works on disguised spies
Sleep well
I felt that last sentence bro
@@Archimedes.5000 The video talked about health packs, too. TF2 Wiki probably just copied value from ammo pack page.
So, basically, I need to put my Linux-based server into a Windows VM? Sorry for the lag everyone, I need 1 extra metal.
That's clever, but I think the emulated CPU of the VM will still use the instruction the compiler told it to use, which is mulss for a GNU/Linux executable. So you will get the same result as if you were running GNU/Linux natively.
And yes, I will call it GNU/Linux rather than Linux because the GCC compiler written by GNU is actually relevant here.
*L E T S D O T H I S T E X A S S T Y L E*
Unless I completely missed the point and you actually meant to run a Windows server executable inside a Windows VM on a Linux-based hypervisor. Then it could work.
@@Ashpool37 There is no "point" lol this is just a stupid idea. But anyway, I meant the latter.
Running server under Wine doesn't do the same job without hurting the performance?
This pay to win deal with Microsoft is DISGUSTING. Valve should be ashamed.
It is server logic, not client
issa joke
"hey consumers, if you buy our product you get a whole extra bullet in your ammo packs!" switch now!
@@uis246 retarb moment
@@waffles4670 windows is free lol
and i thought some year ago that they changed it from 41 to 40 intentionally ... but now knowing they "fixed" it by changing the server OS is marvelous
I mean valve servers always ran Linux afaik
@@solsane5217 The Linux version was released in 2012 so I don't think so unless there was only the server software before.
@@ketchup901 There were no Valve servers in 2012. Valve servers only became a thing when they introduced Casual mode in 2016.
@@ketchup901 game client yes, but server binaries for linux were available always iirc
@@jeeBisOkay After searching, you do seem to be correct. They weren't in my country ¯\_(ツ)_/¯
The way that TF2 seemingly conspires with the very fabric of computing to create ridiculous spychecks has me in love with the game. I don't play it, more like, adore how it has all that wackiness in both code and lore.
Your editing doesn’t get as much love as it should; it’s so clean, and it helps with understanding a lot. Thank you for putting lots of effort into editing!
the reason I know of this channel at all is because of the KILLER thumbnail / title combo of the "weird hitboxes lets you shoot through dudes sometimes" (paraphrased) video
I kinda wish more of his thumbnails captured the same energy as that one, but nevertheless I'm more than content with the editing and content within the videos themselves.
Yeah the editing is phenomenal.
agreed
no
It reminds me of Marblr videos on overwatch explaining bugs, his editing kinda similar
As a compsci guy, I appreciated just how well you condensed the entire compiler/machine code segment. Very approachable!
Alternate title: how to find whether the server owner has windows or linux
Thanks for the idea
You can then run statistics and find out what percentage of tf2 community server hosters run Windows vs Linux, like a scientific study
For those wondering, MULSSSSSSSSSSS means Multiply Single Scalar. Single as in single precision. Precision being number of decimal points to the right.
And "scalar" is basically just fancy math speak for "number".
you forgot SSSSSSSSS
Important to note that float->int conversions will always truncate the extra precision. Valve made the deliberate choice to round up here, when they should have used a round-to-nearest algorithm instead.
Would doing that use more processing power or time or something? Obviously nowadays the difference is probably microscopic on a newer processor, so I am thinking more about the impact it would have had on a processor built between 2003-2008. (I choose that large of a range because TF2 uses a variant if the HL2 engine, which came out in 2004.)
@@DragonBallZKaifan2 no, they did it because damage should be rounded up (else chip damage would be rounded to zero at far range) and they recycled the function
They also could have used fixed values
@@shigekax Fixed values would mean, they need to define the values for each possible combination of max-amount of resource and type of resource. With dozens of weapons that change max-health or max-ammo for each class, this would be near impossible to manage.
@@GreenScrapBot and that's where we get to fixed point numbers
Words cannot describe how impressed I am that you found this. The "41 metal" problem has been bugging me for years, and I had just assumed it was caused by a million different parts of the spaghetti code working together in exactly the wrong way
Looks like Dane's going to have to update Uncletopia to Windows. Can't be missing that 1 metal.
Uncletopia is a Reddity suck fest anyways
Wouldn't call it an update, because running servers on Windows is just hell on earth. (In my opinion, running desktops also is)
*But definitely worth it for the 1 extra ammo*
@unsubtract even if the performance improved it would be a step backwards lol
@unsubtract But it's worth it for 1 more metal
so this is why we're infested with bots, linux users are upset over the less metal
I mean bots love metal. Makes sense
I am :rage:
what?
REALLY upset
Everyone knows we, the Linux users are METAL AF.
(Just joking, I'm more of an EDM guy)
That’s not spaghetti code anymore, it’s more like a hydra that you have been trying to kill for the past decade and it has grown so many heads, they started to intertwine with each other and make the creature unable to do anything.
You still can’t kill it tho
Nah. It's just that's just a very unlucky case. The dev isn't to blame here. Easy to fix too
What, again that annoying "sPaGhEtTi" forced meme?
@@RustyNova yeah for me it’s just the fact that it’s been so long since the game release and people still discover new bugs and exploits every now and then. It’s kinda funny.
This is the best analogy for tf2's code I've ever heard
@@SU76M what are you
Tf2 tech in 2009: you can use your rocket launcher to get up on high places
Tf2 tech in 2022: you can identify a disguised spy on a windows server by a computing irregularity which seems to add another point of health to the spy whenever he picks up a small hp kit
that bug was in since 2007
Someone might argue this means Valve only tested their game on Linux. While not technically incorrect, it's more likely they just didn't test it at all.
well, you see, the extra bullet is supposed to be used for ending the windows user's life in case they get surrounded by bots (who all run on linux)
Actually these bots you find on TF2 today are actually all running Windows machines. You can pull up a statistics page of users on TF2 and OS Statistics and shows that 99% of these bots are running off Windows machines.
@@Alkaris what are the 1% on?
Temple OS?
@@Commrade-DOGE Mac..
@@Alkaris The cheat software they use only runs on Linux. Unless they made a windows version that I don't know about.
@@AzzieEquinox The software has always been on Windows. Things are ported.
It's easier on Linux, but most people run Windows and cheat on Windows. I play TF2 on Linux, play. I'm not a bot.
MULSSSS
I have no idea how you manage to keep finding things, AND make it entertaining for us to watch. You're becoming kind of legend! Thanks!
mulhissssssss.... mulhissssssss....mulhissssssss....mulhissssssss....
"This is TF2's code."
_Dear god..._
"There's more."
*_NO._*
As someone who has nothing todo with the game I find it a bit misleading that this is mentioned in the video without any note. Gives the impression that tf2 has been decompiled or source leaked.
@@ChillerDragon It was source leaked a few years back
@@fus132 ah I see thanks. But I assume that’s not the code shown in the video is it?
Oh my goodness, I *always* noticed this and never knew why sometimes it was 41 instead of 40. Your videos have been such a treat as a veteran TF2 player for almost a decade now.
“This is TF2’s code, basically the recipe for TF2.”
Nah man, that’s the recipe for spaghetti
spaghetti fortress 2
"HOW DID YOU KNOW I WAS A SPY?!"
"you got one too much hp from the small health pack"
To quote the infinite wisdom of Valve programmers: use an EPSILON damnit!!
I know that TF2 is still a 32-bit binary on Windows, but I wouldn't have expected that Visual Studio 2015 (guessing from the linker version 14.00 for all binaries in the TF2 directory) still makes such heavy use of x87 instructions for that target by default.
x87?
@@juango500 I believe that refers to special floating point or other arithmetic instructions that used to be on their own chip. The 8087 math coprocessor. Now they're part of any regular x86 processor if I had to guess.
Yes, FMUL is the original instruction for floating-point multiplication that has existed since Intel's first math coprocessor. Those instructions use an intermediate format that has more precision than the output, which can give slightly different results.
MULSS on the other hand uses the SSE vector registers, which strictly compute according to the requested format (single-precision in this case, what the second S stands for).
I dont understand, /arch:SSE makes use of fmul but /arch:SSE2 makes use of mulss
@@lychy645 Both 32-bit MSVC and GCC are pretty reluctant to use just SSE1 on scalar values unless you enable maximum optimizations (-Ofast for the latter). Maybe it's because the original processors only could crunch both halves of XMM registers in succession.
Clang on the other hand emits MULSS for -march=pentium3 and higher even without an optimization level.
FMUL (Floating MULtiply) operates on the venerable extended-precision (80-bit) x87 FPU registers. MULSS (MULtiply Scalar Single-precision) is a single-precision (32-bit) instruction that's a part of the more recent (1999) SSE instruction set.
In either case, the result is getting passed to the ceil() function to round it up, when perhaps it should be rounded to the nearest integer instead.
The ceil function takes a double-precision (64-bit) argument, so the extended-precision value gets truncated, but it's still enough precision to foul up the calculation.
So the real bug here is Valve rounding UP instead of just ROUNDING, but it could have been avoided if they checked the box in Microsoft Visual Studio that says the game doesn't have to run on a Pentium II from 1997.
they used ceil because the same function is used for damage, and as such chip damage could do 0 damage if not ceiled.
@@TheToomykins Which function? You mean the ceiling function? Because that's nonsense. That's like saying hair stylists should wear welding masks because welders also wear welding masks, because if they didn't they'd burn out their retinas.
@@TheToomykins Which function is that?
Just like with damage there are debuffs (metal_pickup_decreased) which decrease the amount you receive. It doesn't make sense to receive nothing, to play a sound and display +/- when you aren't actually receiving anything. And if you picked up 3 ammo packs which each should give you 43 ⅓ metal based on all your current buffs/debuffs, you would expect to have enough for a sentry, but if you rounded to the nearest you would only have 129. A bit contrived, but still, as a player I would rather have more of something than less of it.
@D M My guess is that they used the default options and didn't bother with compiler optimization, which in itself is a bit strange.
I remember at one point in time you could get 1 more health from small health kits as well, but I don't know when that was patched
Imagine being a Spy and getting confused how the fuck the enemy team knew you're a Spy despite not doing something suspicious at all. And it turns out it's due to a freaking health pack
"We're going to be here for 2 hours if I explain everything"
*video is only 4 minutes long*
Hello operator, I would like to report a ROBERY!
This is like when one of the devs responsible for porting HL2 to VR, had some door stay closed rather than opening because a function returned something slightly different because of the switchover from x87 to SSE
x87?
@@nuclearbomb9483 the new instructions that were added in the 8087 processor
The 87th instructions is to make your computer restart and install updates
@@nuclearbomb9483 The old, 32-bit way to work with floating point numbers. SSE is used in 64-bit mode.
@@Selicre nope
My favorite part of this channel is how you go into depth about WHY specifically things work the way they do, not just that it happens.
It's by far my favorite stuff to learn about.
I only just now noticed that I got 1 extra metal/ammo whenever I played via private. That is so weird, thank you Shoe-Nick for blessing us.
Yet another game oddity I noticed but never gave a deeper thought to. Love how even when it isn't Source's fault TF2 manages to have spaghetti code
Edit: Okay I'm just going to change the comment entirely
This is also microsoft's spaghetti
Source Spaghetti is slowly getting more and more closer to being classified as an actual SCP
@@uis246 its not microsoft's or windows's or valve's fault. it's fault is entirely of the compiler using the wrong instruction.
Source Spaghetti is slowly turning into a Source Pile of Snakes
it's the fault of the way how computer computes numbers, this is way to deeper than you expect
AS OF THE 64 BIT UPDATE, THIS HAS BEEN PATCHED!
Small med and ammo kits now give exactly 20% on windows servers!
I swear, if I get rumbled as spy on a windows server just because someone used the health bar trick...
One day Shounic is going to go rogue and use his intimate knowledge to shape tf2 to whatever he wills it to be.
This is absolutely interesting, I wanted to listen the video in background while doing other things, but without even notice, I watched everything with fascination. As worker in the video-game industry, I'm really passionate and curious about those really tiny details, I will truly look for the rest of this channel!
For those who are curious: fmul is shorthand for "function multiply" and mulss is shorthand for "multiply some shit"
not float multiply?
and multiply single scalar?
@@jomo_sh hes just joking
I've always wondered this! Thankyou for sharing, It's a great breakdown of the differences between compilers and unintended consequences of them. I also like all the quality visual editing making things really clear, even the small detail of making the linux and windows code compiler images have slightly different lights from each other. Excellent video as always ♥
This is completely broken, will totally change the engineer meta. Need Heavy Update ASAP 😂😂
*"Windows, that's scary"* -Gaben
My thoughts exactly, Gabe... *My thoughts exactly*
Gaben was part of the team that coded the first version of windows, so if he can't figure it out, no one can.
@@iliakatster I'm pretty sure even Windows engineers get frustrated at Windows tbh
And that`s the real reason why SteamOS is linux based
Instructions unclear. Windows is a spy?
Goddamn linux, that 1 metal could have helped win the match
it’s msvc’s fault
(but really it’s valve’s fault)
I had a map from a couple years ago, pd_meme_machine, that never crashed until it was ran on a specific server. I looked at every possibility for what could be causing it to just randomly crash the server. Closest I got to figuring it out is that it always worked on a Windows server, and crashed the Linux servers (or vise versa, I can’t remember lol). Possibly due to some weird number or rounding issue that was different on each OS, screwing with the game logic or physics. Cool video shounic!
Being a Linux user I found this video to be a really interesting look into the technical challenges of multiplying two numbers.
It's ironic that the Windows compiler produced code that tried to be more precise during these calculations, but it actually made it worse.
Because it always rounds up instead of rounding to the nearest. *headshaking*
It feels like you could almost make it work by specifying when to round up or to the nearest depending on the situation, but knowing how much of a monster the spaghetti code for TF2 is, that would probably introduce more problems...
Держись
Just a great video, great explanation, great editing. Easy to understand with the comparison of both compilers. Thank you and congrats! ^.^
Gaben helped code windows, only he knows the true horrors that lie beneath its surface
this is a compiler problem
@@nbhjbhyvgbhyuvbhuynnjbhu MSVC is a Microsoft product too. No wonder its wonky
@@nbhjbhyvgbhyuvbhuynnjbhu
'code windows' and the compiler isn't part of windows?
@@cewla3348 no? compilers are just programs like any other. it's not a 'part of windows'
@@cewla3348no, its a program for windows
Very good job on the video shounic!
As an engineer main, i remember that weird non-round number, 41, and i always wondered where that +1 metal went. Never woulda guessed it would be operating system dependent
Man I love the way you create your videos, your title already answers the exact topic for people who are experienced in programming. I'm currently a games programming student at university and when I read that title I was thinking "yep there's a floating point precision error somewhere cause I know for sure the health is a float cause I've had 0 HP before.", even though it's not the right term to use, I still think it's right, as one floating point result is different than the other on a different OS.
Your titles, your editing and your explanation to the design of the game's programming leading to the problem is insane, and I envy you so much on how you write these. I wish I could do this..!
Great content, loving it. :)
just want to say this right now, genuinely in love with this channel (for multiple reasons) but maybe the biggest is the fact that you are far more immune to the clickbait sin that plauges most of this platform nowadays. i can see this video in my recommended, read the title, then instantly know the answer for the most part, and if im interested to know more i can watch the short and to the point video that will explain it for me. anyone else could have easily called it "THIS WEIRD BUG GIVES YOU (41) METAL?!" and i would never - ever - care to click on it because nothing about that interests me really. but nope, far better title here.
I eat people
Oh my god, I KNEW IT! I knew I wasn't crazy!
I distinctly remember getting 41 ammo from small packs but never being able to replicate it, thought an update fixed it.
Thank you for the explanation!
Really holding out for dx8 and crit glow bug and why it happens :( Love this vid as always!
IIRC it's not really a bug so much as the DX8 renderer not supporting what makes the crit glow possible. I could be wrong though!
0:58 the screen going red I thought for a second I was about to actually be here for two hours
Now imagine this wasn't just a game but a nuclear missile launch system.
Oh man, now I'm imagining all of the world's nukes are running on Windows machines... I feel so much less safe now...
@@matthewrease2376 You better be glad they aren't. Now we just need to make sure it isn't running on anything else.
@@SliceJosiah apple is pulling all the strings
@@devihcra 😳 That too...
If I recall, Microsoft actually has or had language in their license agreement that says it's not for use on things such as life support systems or missile systems
can't wait to see the TF2 wiki now show about this
also 4:04 poor spy mains can't catch a break
I had similar problem with a custom shader that I wrote for Unity.
People with Nvidia cards didn't have any issues, but people who were using AMD cards, float to integer casting would result a different value which caused one crucial function to break on AMD cards.
This was likely because I had done the casting in a weird way and debugging it without owning an AMD card was a nightmare
A moment of appreciation for you shounic, your thumbnails are in my opinion some of the best on the site.
When you think about it, the only reason it would need to run a calculation instead of just dictating a set value is because MvM exists. So thank MvM for your extra metal engies.
which is completely ridiculous given that MvM gamecode doesn't belong in base game.
@@krowta2062 not relevant whatsoever.
Actually, I just thought of something you could cover for a brief little video. A lot of custom models no longer work in TF2 anymore, mainly because at some point Valve made the game stop looking in models/weapons/c_models and instead made wholly new folders in models/workshop/weapons/c_models and models/workshop_partner/weapons/c_models. which means that to get the old models to work again, you not only have to change their folder structure, but you have to hex edit the .mdl file and change the file path at the top near the header to reflect the proper file path. Maybe some digging as to why Valve chose to basically duplicate the entirety of the weapon models (because the old models and texture paths are still there and still contain their various vmt, vtf, and .mdl related files despite no longer actually being used.)
Flipping awesome, I'm guessing this is why level 3 sentries sometimes get 217 health
The ending clip is always so funny. Loved the vid!
I always thought it was weird that I would get 41 metal when playing offline. Now I understand why.
I will never not be fascinated by your random, very strange tf2 trivia.
The Gaben closer is somewhat relevant in this case. Gaben _did_ worked on the first 3 versions of Windows.
no please do stay here for hours and explain everything, i love these videos
4:31 I can agree, windows is terrifying
Wow, even computers take a look at the absolute spaghetti that is TF2 code and say “Nope, this is too complicated and confusing for me”.
"This is what I get for working at Microsoft."
-GabeN a.k.a God himself
love the fact you used differing teams to differ between linux and windows examples, small touch but very helpful
As the only person who plays everything on Linux, this is a personal attack.
this is serverside, not client, so unless you're running the game locally it shouldn't affect you
Nah bother, you ain't the only one ✊
L
Hello homie
This channel doesn’t clickbait - It catches your attention with a ridiculous-sounding titles, but then explains it
So true quesion is; why valve selected x0.2 instead of /5.
Latter one should give much accurate number.
because Valve obviously...
At a machine level, addition and subtraction are equally as complex, multiplication is much more complex than both, and division is mountains above multiplication. Not only would dividing by 5 be technically a harder computational operation for the machine with no greater accuracy, I wouldn't be surprised if the compiler would try and convert it into multiplication anyway.
its the multiplier of the ammo pack.
Small ammo pack has 0.2 multiplier, medium has 0.5, big has 1.0 multiplier.
It would simply be harder in the code to implement the division instead, they couldn't use the formula x=multiplier*max_ammo anymore. and besides, they simply didnt know that would happen.
@@wojtekpolska1013 what i really don't understand is where the 0.20000000(29.....) comes from. If i define float n = 0.2, shouldn't it be an exact 0.2 ?
@@HaartieeTRUE It won't be because computers use binary, they cannot have 0.2, cannot comprehend it. It must be some combination of ones and zeroes at the bottom of it all. 0.2 is 1/5th, in binary it is similar to decimal 1/3rd.
It's crazy how this immediately brought my brain back to an almost decade old memory of picking up a weapon from 0 ammo on 2Fort balcony and thinking "huh that's weird why does it give 41 ammo it should be rounded"
Cool video, i think i've never seen the 41 metal thing, i'm pretty sure i'd notice such an ocd inducing thing
Quick question, do you know what's the deal with the reloading and touching the resupply cabinet, when you do you end up with 1 fewer round in reserve.
Stay safe m'man
You start the reload animation, you’re going to fill your clip, then you touch a resupply cabinet. Your reserve and your clip are both full, but the reload animation continues, so it subtracts 1 from your reserves and adds it to your clip. Since the clip size is capped, it doesn’t actually change, but the ammo from your reserves still got subtracted.
I hate it when that happens, I'm pretty sure 1 less ammo is fine and I can just pick an enemy's ammopack but I can't stand seeing it almost full
@@shieldlesscap6124 is correct. I've fixed that in TF2 Classic for what it's worth.
THE CLARITY! The clarity of your explanation is unchallengeable by anything I've seen before. And I don't say that lightly.
I'm using Linux as my daily driver, so when I host a server, it's the same as valve server :P
So this is why i get 41 metal when i play Engineer on my own local server with RC2Bots alone!
Thanks Chief, the mystery case solved!
Just a note: the fmul text at 2:15 was really hard to read for me. If you could use a combination with different brightnesses it would help a lot. Thanks!
skill issue
@@jomo_sh This reply is actually pretty valuable, since with it we know have a perfect textbook example to use when explaining what ableism is.
@@aro2866 yeah like your inability to take a joke
THANK YOU for finally explaining this
Also sick they released batsaber for engi
these animations are really good. does anyone have tutorials for this kind of stuff?
Thank you for releasing the best of information
i think shounic knows tf2's spaghetti code better then the developers at this point
He should take over after the last tf2 developer dies.
One extra metal or ammo in most weapons isn't anything special, but one extra hp and rocket can be a game changer, and its crazy to imagine that something like this scored someone a kill or a survived death.
we can't let windows be better than linux in any way tho
Someone should make a mod which increases the metal gain to 42 only if you're on Linux
@@kodicraft yes we need to do it
I wonder if this might also be the reason why R6 gives 1 more bullet in reserves at the beginning of the round, rather than a multiple of the ammo count in your weapon.
Windows is a direct upgrade to Linux confirmed.
no it is not
@@BoneMareOh In games, it is.
@@UberSpah tf you on about. most games run better on linux
@@BoneMareOhsure it runs better but the very second you install Linux you become a femboy
@@Norim_ thats a lie. you become a femboy (or trans) and then install linux
Tbh, I wouldn't mind being here for 2 hours listening to you explain everything
Can we get the 2hr version?
I genuinely burst out laughing when I was recommended this because of the sheer order of magnitude of spaghetti.
mulsssssssssssssss
I don’t care about anything else I’m just scared that engineer touched a bat saber with his bare hands.
All this big talk about how Valve loves Linux and then this gets discovered...
/s just to make sure everyone gets the joke.
"That's what I get for working at Microsoft..."
/s means /serious I thought?
@@arandomcommenter412 'Sarcasm', not 'serious'
unfunny joke
Tone indicators in 2022 funny moments comp
Always enjoy your videos. Good job!
By "Linux compiler" and "Windows compiler", do you mean GCC and MSVC respectively?
Valve uses MSVC for windows and GCC for linux.
@@lonec1777 Thanks.
The "0.2 cant be represented"-issue might make no sense at first, but its very similar to how we can't fully represent fractions like 1/3 in decimal: We have to approximate it as 0.333333..., eventually cutting it off. In binary, a similar effect happens at different fractions like 0.2: (1/5) in binary is "0.001100110011001100110011001100110011001100110..."; it goes on infinitely long until you cut it off and loose accuracy.
0.2 is 1/5th, not 2/5ths
@@godlyvex5543 what a blunder
@@leumasme make sure you add an extra zero at the start of the fractional expansion, the way you have it written is still 2/5ths
Im literally gay rn
Great video, as always! :)
Seems that ppl in the comments still dont understand the video:
1. It is *not* Microsoft's nor Windows's nor Valve's fault. the fault is entirely of the compiler using the wrong instruction when interpreting the game code.
2. It does *not* give Windows users an advantage, nor a disadvantage to Linux users. Almost all TF2 servers are hosted on Linux (Valve official servers, and most online services that allow you to pay for a server to host a game). Within one server, the players all will get the same ammo & metal, no matter their OS. So on Linux server, *BOTH* Windows and Linux users will get 40 metal from small ammo pack, and on Windows server, both will get 41.
It provides no advantage to anyone, the bug only comes in effect, when a Windows user hosts a server on their own PC (Windows Server is much less popular than Linux), and then everyone no matter their OS gets 41 metal.
It is Valve's fault, though. The issue is that the code that handles this is told to round up decimal numbers. Nothing to do with the compiler.
It's also not the fault of the compiler (after all, not like the compiler knows which result you want). If you want to blame anyone, blame Valve for not thinking about floating point weirdness and just rounding manually.
Woosh
saying that it's Microsoft Visual C++'s fault and not Microsoft's fault is... a curious distinction.
Linus Torvalds spotted openly weeping at this development