r/GlobalOffensive • u/-ZooL- 10 years coin • Jun 04 '19
Feedback Valve did very hacky implementations of the items over the years, causing Spaghetti code, here's a compilation of what's wrong.
6.2k
Upvotes
1.9k
u/Hazzalar99 Jun 04 '19
You lost me at hi
646
u/[deleted] Jun 04 '19
My only take is that even at professional level there is lot of sub-optimal code going around, so me getting a programming job is not as bad for the industry as I previously thought.
291
u/M3liora Jun 04 '19
Not surprising an almost 2 decade engine that was constantly updated by different programmers throughout it's life has so much spaghetti code.
Most of this however, leads to just sloppily readable code; it's not like there are major issues with this remainder code.
85
u/canyonsinc Complexity Jun 04 '19
Honestly, these seem like pretty minor issues, mostly qol improvements. Yea it's annoying, but fuck, do you realize how much this code has actually been worked on? I work on a 4 year old API that pales in comparison to the CSGO codebase, and it seems daunting to fix minor code blocksthat I even made from a few years ago. Typically, timelines are tight, budget is low, and you just gotta get shit out the door.
That said; valve, plz fix. ;)
41
u/pM-me_your_Triggers Godsent Jun 04 '19
There seems to be a pretty big misconception in this thread... OP is not actually looking at game code, they are looking at data files.
75
u/johnrox Jun 04 '19
Good find but one thing - I don’t think it’s fair to assume spaghetti code when you’re using their DTOs as the primary example. (Some) Valve’s code is open sourced, so it would be nice to see some investigation there too.
“As for valve loving duct tape” - I took a day or two to go through their socket code https://github.com/ValveSoftware/GameNetworkingSockets and felt it was well designed and pretty pleasant to read. I don’t like generalities of different codebases; however I personally feel Valve has some well written implementations at the lower levels that might change your opinion if you give them a read through!
773
u/EnemySnipa Jun 04 '19
Sounds like you know what you’re talking about +1
290
u/Mbiojf Jun 04 '19
I couldn't understand shit but I guess we can press F to fix valve?
23
u/GamerDJ guardian_elite Jun 05 '19 edited Jun 05 '19
Garbage thread.
Some of the people here think that the OP is some kind of in-depth analysis of actual code (that is not even close to public). These people probably didn't even read most of it, didn't understand a word, and clicked upvote the moment they saw code blocks full of text from a config file which is being mistaken for actual code.
Others think to themselves "oh I've done a coding before" then proceed to comment how they "kind of get it," or they "learned some [language]," and suddenly they see the light this thread bestows upon them due to their completely unrelated and likely very limited experience (or even just base familiarity) with "coding."
The rest took the OP at face value and are running with it, making assumptions about closed source software that nobody outside of the actual developers knows about. Now we have people who think this "issue" is killing their FPS, making their hits not register, hacking their computer, and clogging their toilet.
Unfortunately this thread has already been launched to the top by the same people commenting things like:
Not trying to flame OP, but it's frustrating to see things like this that will mislead people (even unintentionally) who don't know what's going on.
edit: a word
136
u/[deleted] Jun 04 '19 edited Jun 04 '19
Your complaints come from the point of view of a modder, which is justifiable. The way they're updating the game is making it harder to mod, but it's helping them ship new features without any major refactoring. I don't know how familiar you are with game development, but pretty much all games throw coding standards out the window when it comes time to ship. A game this old being supported for so long and receiving new features without any major engine upgrades or rewrites is impressive. I'm guessing that's what they're mostly interested in. Valve's corporate structure probably makes it hard to motivate anyone to do the dirty work of cleaning up an old codebase.
But saying that the code quality is poor, dirty, unreliable, etc kinda hurts your cause IMO. If you actually want them to fix it, you should argue that it will improve the modding community rather than just say their code sucks. Not only is talking shit about someone unlikely to motivate them, in Valve's case I doubt they care at all about the quality of the code as long as the game itself is solid; so if you tell them their code sucks, they won't see any value in that. Mod developers are a minority, and no player is going be directly affected by what the code looks like under the hood.
EDIT: an example/clarification:
I can guarantee you that their engineers have had that discussion internally already and made a decision on it. If they decided that it actually isn't so bad for them to deal with, then your entire argument is going to fall on deaf ears. The smart thing to assume (although it'd be smarter to not assume at all and ask them to clarify) is that they've thought about this already, and that the current state is a result of those discussions.
If that's the case, it's unlikely that you'll be able to convince them that they won't be able to manage their own code. What is possible is that you could convince them that the negative impact on the modding community will be greater than they may have thought.
14
u/Big_Stick01 Liquid Jun 04 '19
Eh.. if fixing it does nothing to actually make the game run better, or improve it from the client side, i could really care less about this being fixed. If it doesn't do any of the above, id almost prefer for them to not even attempt to fix it.
13
u/UhuPlast1 Jun 04 '19
Really, I think it's very easy to judge someone's else code from an outside perspective and not know why the decisions were made. Especially with legacy code. Nothing is perfect, you can't refactor your code endlessly. Therefore I really feel this post has a bit of a smug feeling to it.
27
u/Slithar Jun 04 '19
I don't understand why you call these files "Scripting files". They're obviously not scripts, but config files. These are not the problem, and certainly not the solution. It doesn't matter how garbage your configuration files are as long as your real codebase and parsing of them is on point. It does not look like it is, but implying from their poorly mantained cfgs that their actual C++ is bad from a OOP perspective is a fucking stretch. Really, config files just become objects in-game and we don't know what their classes are like, so I don't think we can really gleam much into their use of OOP.
Also, how did you come to the conclusion that any of what is in these configs is obsolete and/or unused? You literally can't.
30
u/[deleted] Jun 04 '19
I see the point of the post, but it seems kinda dumb.
Working in any game/software development team is gonna result in some bad code if you're working on a singular project for so long, with so many different people. I'm not gonna claim to know when they started work on the game or anything about how they work, but it's been out and receiving updates since August 2012.
I'm 99% confident in saying Valve know about the things that you mentioned, and posting it to Reddit isn't gonna achieve anything than having some morons think you're clever. I'd argue the issues you brought up are very minor in the grand scheme of things.
56
u/[deleted] Jun 04 '19
Just gonna pretend I understand what's going on. VALVE OMG FIX PLS
4
u/2h_company 1 Million Celebration Jun 04 '19
This is what happens when you have a very old and large code base that's being worked on by many engineers without any solid documentation over the years.
Note that it's still all data driven and working, which is impressive in its self. It's not consistent, but it's working.
4
u/SileAnimus de_inferno Jun 05 '19 edited Jun 05 '19
Good thing to note: The items didn't used to have all of the weapon stats inside. Each weapon used to be fully self contained in its own text file. Only the UPS/R8/A1S actually used the file to dictate their stats. It got changed around two years ago I think.
When they moved it from individual files into a single file for the weapon stats is when I killed off my rebalance mod.
7
u/[deleted] Jun 04 '19
I work in cgi and now own two cgi businesses. I've seen a lot of CGI posts like this that are super detailed and informative and get a huge ammount of upvotes. Then I read the text and it's complete garbage. I do a bit of coding and my business partner is a developer. Without having written the code yourself or seeing a project develop over time it's really at best, a total guess, to know of the code written is 'right' or 'wrong'. It's easy to look at things hollistically at the end and say this is wrong and stupid. However when the original brief is met, then a new change comes I to a new person with a budget and time constraint, the right answer to the update is almost never the right choice hollistically.
17
u/_Nanobyte 10 years coin Jun 04 '19
Thats what happens if something old (the engine) is told new tricks.
At one point someone has to swallow the bitter pill and cleanup to get it into the future.
Sometimes i look into my scripts and think "What idiot was writing this" and then my one week younger self hide under the bed while i rewrite the complete code :-|
9
u/PynTr Jun 04 '19
Should probably finish your college degree before you make yourself look like anymore of a dickhead.
3
u/[deleted] Jun 04 '19
runescape is entirely spaghetti
3
u/FCBfreak54 CS2 HYPE Jun 04 '19
Nice finds, but realistically.... find me any seven year old application without legacy code or bad practices, i won't wait up ;)
Just imagine the amounts of changes due to dependencies, DirectX alone has had over the years.
It is difficult to really make anything of the source code based of config files.. would be interesting to take a peek though
6
u/Becks9090 Jun 04 '19
Doesn't valve said long time ago that they know they have really messed up code in source engine? They also said if I remember correctly they need to rewrite whole source engine from sratch and they will call it source 2.
7
u/ortonas Jun 04 '19
I didn't know valve release CSGO source code. Where can I find it?
2
u/MaineGameBoy Jun 05 '19
Ah, source spaghetti has come for cs:go too?
2
u/Ather5125 Jun 05 '19
A lot of this will be hiddenpaths fault since they don't seem to be the most competent development studio out there
2
u/HaunTarL Jun 05 '19
r/madlad
2
u/veRGe1421 Jun 05 '19
where is classic offensive pls bby
2
u/Mentaxification clutch Jun 05 '19
as a mapmaker i just hope that they make stuff like weapon_axe spawnable in custom game modes some day
2
u/Distantexplorer 750k Celebration Jun 05 '19
If they cleaned up the backend of the game would their be any noticeable performance increases to users?
E: Lmao
2
u/3rd_Shift Jun 06 '19
You are going to be devastatingly embarrassed in a few years. You don't have enough information to criticize the coding practices of the CS:GO team and in a few years you may at least know enough to realize that.
5
u/Ocorn Jun 04 '19
Ure complaining about a config file.
Lol it's a config file.
Config files do not represent structure in source code. Only how the source can use certain values in the file. It's like a set of keys.
You dont know valve's engine and please stop acting like you do. Its laughable you post json configs and act like you know.
If you were smart you'd carefully make these suggestions in a cover letter and apply to valve as a dev.
3
u/Zoddom 10 years coin Jun 04 '19
Judging from a comment of an ex-dev, this applies to all of the code.
Tbh, the longer I play this game, the more I believe this. So many little (but sometimes gamebreaking) annoying bugs, that have been in the game for a long time.
3
u/Stokealona de_overpass Jun 04 '19
It's always a balance between getting the product to market and engineering the product nicely, which is why this is common across all software development industries. The classic you can have a perfectly engineered solution but if someone else beats you to market by a year then you're dead in the water.
I doubt anyone at Valve will agree that the cost of a major refactor is worth the minimal benefits, especially for the vast majority of the CS:GO players who simply wouldn't notice or care. Why would they invest time into this when it could be spent on features?
3
u/crashkid3000 guardian2 Jun 04 '19 edited Jun 04 '19
Also, I wanna add to that that some stats in items_game.txt and on the buy menu make no sense whatsoever. First, take a look at the
weapon_ak47_prefab's attributes that you can find below. You will notice that most stats not related to the accuracy of the weapon can be seen in the buy menu. And, well, some of the stuff in the items_game.txt and the buy menu doesn't make any sense at all:And, as promised, the atributes of the AK-47:
* "Spraying" is actually a defined proccess in the game, requiring a set ammount of bullets to be fired within some timeframe. Usually, the lower limit of bullets (i.e. when the minimal recovery time is used) is 0 (aka tap-firing) and the upper limit of bullets (when the maximum recovery time is used) is 5. It is possible to manipulate these numbers and, furthermore, the lower limit doesn't have to be a smaller number than the upper limit - think Negev for example.
6
u/Xavonium de_cache Jun 04 '19
we need 3kliksphilip to explain this one.
6
u/CrazyModder_mk1488 Jun 04 '19 edited Jun 04 '19
But wait... THERE'S MORE!
Danger Zone items' bugs/issues:
weapon_tablet
I'm not sure, if the next notes are features or issues, but... what do we got here?
weapon_bumpmine
OK, enough with Danger Zone stuff, let's take a look at the last thing for now:
Firearms
That's all for now.
4
u/jonajon91 de_canals Jun 04 '19
If there was any reason why valve would bother making a new counter strike game, it would be technical reasons like this.
I think if they did it properly, they could release a new game built well for future updates and it could actually be the last counterstrike.
4
u/wormi27z Natus Vincere Jun 04 '19
This would have been more useful as mail to Valve imo. Nothing to do with Reddit.
3
u/Troll3r_Man Vitality Jun 04 '19
I always watched your videos about csgo especially liked the c4 and the pipebomb
Really interesting and thorough post, I really hope it gets valve's attention. Thanks zool!
2
u/[deleted] Jun 04 '19
Pretty much all live games are massive spaghetti code. Full refactoring is not affordable in most cases, with bugs popping and content updates.
I'm still amazed at the CS:GO netcode being precise since forever. Props to all devs maintaining that.
2
u/immerc Jun 04 '19
I think you have a misconception about the meaning of the word "misconception".
2
u/aiden753 de_nuke Jun 05 '19
"weapon_tracers_assrifle" I didnt know there's an ass rifle in the game
2
u/silentz0r Jun 05 '19
Let's not forget Valve outsourced the development of the original csgo to some game dev studio and it's likely the root cause of everything you listed.
2
u/TotesMessenger Jun 05 '19 edited Jun 05 '19
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)
2
u/[deleted] Jun 05 '19 edited Jun 05 '19
But you haven’t shown us any actual code?
Edit: config files are not code
2
u/aliasdred FaZe Jun 04 '19
Inb4 devs see this, say " fuck it, community doesn't care about anything we do, its just complaining and then more complaining " then stop working on csgo altogether
1
u/tolkienfanatic Jun 04 '19
I see code review, I upvote.
1
u/[deleted] Jun 04 '19
You thought this was bad? I heard RuneScape is a whole lot more spagettti-ish.
1
u/jrsooner 10 years coin Jun 05 '19
Valve: "Whats a deadline?"
1
u/xtcxx Jun 05 '19
Plain text compresses well
1
u/brohanan Renegades Jun 05 '19
Yes
1
u/Catslayer_999 Jun 05 '19
Hackerman!
1
u/tarangk clutch Jun 05 '19
noob question but do game companies get their code security audited for critical vulnerabilities ?
1
u/YukiSG Jun 19 '19
I think Valves should hire you to go thru buggy code.
1
u/amsterdam_pro Jun 04 '19
Isn’t the items_game.txt system taken from TF2?
1
u/tedbradly Jun 04 '19
Are they able to update this, or do they have a strict API that must remain backward compatible? Sometimes shit gets out, and once it's out, it'll be there even if the software lasts 20 years. Ironically, the need to last 20 years is part of the reason to keep things reverse compatible, and being reverse compatible is what makes 20 year old APIs slowly decay.
Also, I'm a programmer, and I have no idea what any of that code means beyond representing an object through JSON.
1
u/EmilDrillz Jun 05 '19
hes a witch
-3
u/TheOneNotNamed 1 Million Celebration Jun 04 '19
Surely they know it already as they work on it. So kind of pointless to tell them to fix it lol.
-5
u/9TitaniuM6 Jun 04 '19
... simply wow!! Perfect... Just perfect... Is it possible that this things lead to lag or fps drops or any ingame render problem?
0
u/wilhueb Jun 04 '19
i mean for one thing, they should just switch to an actual file format for items_game. use json or xml or something standard, not your own proprietary format for not reason
also, it's been about two years since i've worked with items_game, but i remember there being multiple of a key, making parsing incredibly difficult
0
u/amalik87 Jun 05 '19
I have recently played a bunch of MM games, enjoyed myself thoroughly with my squad, and have no fucking idea what you are complaining about. Enjoy the game!
-1
u/Mraz565 Jun 04 '19
So when are you getting hired to fix it all?
-1
u/Kaesesalami Jun 04 '19
And I have to create a pull request for adding a single line of code and have it approved by at least 3 people. What about code review? This should have never happened at a company like Valve. Lacking quality is never acceptable. But they are currently working harder on the game like never before. Maybe they will find time for some good ol refactoring ;). I'm optimistic.
-1
u/Tick___Tock Jun 04 '19
the lack of colons in this json bothers me
-1
u/SunBurn008 Jun 04 '19
Uh so uh classic offensive on steam when Mr zool : )
-1
u/ImDonCheeto Liquid Jun 04 '19
I cant understand this post but its seems like you put a lot of effort into it so take my upvote!
-9
u/RealBTDan Jun 04 '19
Valve, you disgust me with that.
Good job on making this, ZooL.
0
u/[deleted] Jun 04 '19
Is this fixable? Or ??
0
u/[deleted] Jun 04 '19
slightly offtopic, but your smoke grenade | hyper beast needs to be implemented.
0
u/[deleted] Jun 04 '19
i think i'll save it first
0
u/Warranty_V0id MOUZ Jun 04 '19
There might be a good chance that someone already tried to clean it up. There is a well known web comic for that topic. https://www.monkeyuser.com/2017/refactor-man/
0
u/frostnxn 10 years coin Jun 04 '19
If valve talked: https://boyter.org/static/books/ChN6FVeWwAAwP_z.jpg
0
u/DukeBruno123 Jun 04 '19
Deadlines don't exist
0
u/RolandTheJabberwocky Jun 04 '19
*laughs in TF2 coding*
0
u/iDexCS Jun 04 '19
Hey ZooL ! I know your not 3Kliks but I recently re-tested to see if smoke particle done by bullet hitting wood crate/wall could show enemy behind a smoke
and for some reason it seem to have been fixed or something wrong with my client,
example when a smoke pop in Inferno in the middle of apps in the long part and you shoot towards the wood wall you can't see the particles behind the smoke anymore
Do you have any explanation on what happenned ?
0
u/akaBigWurm Jun 04 '19
LOL @ armchair developers
With an engine and code base this old the Spaghett is the main meal here, can't cut it out.
0
u/[deleted] Jun 04 '19
this guy open-closed principle's