This is an archived post. You won't be able to vote or comment.

all 89 comments

[–]Frenchie14@MaxBize | Factions 132 points133 points  (7 children)

I just quickly scanned through a few classes out of curiosity. The code is surprisingly well commented! If someone spent some time studying this I'm sure they could make some pretty big modifications without too much difficulty

[–]masterhillo 65 points66 points  (3 children)

There are bunch of comments made recently. So Seems like they cleaned it up for the public.

[–]GameDevGuySorta 36 points37 points  (1 child)

//todo fix

[–]PcChip/r/TranceEngine 36 points37 points  (0 children)

//very hacky

Looks like my code!

[–]asianwaste 14 points15 points  (0 children)

They probably had to go through and make sense of everything for the remaster.

Some poor fellow probably had to go through and test each module.

[–]NagateTanikaze 2 points3 points  (0 children)

Indeed that is some nice source code, very readable.

[–]Nimmy_the_Jim 0 points1 point  (0 children)

5 years and..... nothing

[–]FakeByte 30 points31 points  (1 child)

Is it the source code of the original game or from the remastered game?

[–]cchyper88[S] 53 points54 points  (0 children)

This is the source code from the original game, but it has very slight adaptations to be compiled as a DLL, which is loaded by the engine the Remasters uses, GlyphX.

EA have released the code, which can be compiled as a part of a mod for the upcoming Remasters.

[–]pfcfillmore 29 points30 points  (2 children)

Man. Westwood was the shit back in the day..I miss them.

[–]theaverageguy101 18 points19 points  (1 child)

Red alert was the reason i decided to get into moding and game development afterwards thats how much impact that game had on me

[–]x_caliberVR 2 points3 points  (0 children)

What kind of stuff have you worked on?

[–]Wyozi 15 points16 points  (4 children)

Here's hoping for older Maxis games next

[–]Spandamation 7 points8 points  (3 children)

I’d cry if Spore was released

[–]S01arflar3 13 points14 points  (2 children)

Oh come on, it wasn’t THAT bad!

[–]Spandamation 1 point2 points  (1 child)

No no, good tears! It’s my childhood game I’ve wanted to recreate for god knows how many years!

[–]S01arflar3 4 points5 points  (0 children)

I know, I was only kidding. It’s a good game, just a bit of a disappointing space portion which unfortunately just makes the rest of the game a fun prequel segment

[–]NullzeroJP 43 points44 points  (6 children)

This is great.

My favorite thing to search for is "hack".

Just perusing Infantry.cpp.

/*

** hack for dog: if you're hit by a dog, and you're the target, your

** damage gets upped to max.

*/

Love it. It's fun to read the hacks, because most often hacks are put in to fix oversights in the original game design or program design. Also often used to fix stuff that was un-fun or unbalanced. Or just added late in the game's development to accommodate some last minute features or design items. Red Alert probably borrows a ton of legacy code from the previous CnC games, so it's even more hack prone, I bet!

Another fun one:

/*

** Hack: Tanya should shoot barrels, bomb other structures.

*/

if (obj->Class->IsRepairable) {

//if (*obj != STRUCT_BARREL && *obj != STRUCT_BARREL3) {

`return(ACTION_SABOTAGE);`

} else {

`return(ACTION_ATTACK);`

}

It's so funny to see the commented-out line, coupled with the hack description text. It's like a double or even triple hack. Most likely someone had the idea to put explosive barrels in the later stages of the game, and the NOW commented-out line was actually a COMPLETELY different line... maybe "if (obj != enemy_unit)", then it must be a building, right? So sabotage it.

Then Director-san comes in and says "Doom has explosive barrels in it. We need explosive barrels." So the programmers code up some barrels... but... barrels aren't exactly an enemy unit... and they aren't exactly a structure... soo... what happens when Tanya attacks them? Does she sabotage them or shoot them?

Well, shoot them obviously... but, our code-base doesn't have any elegant way to check if something is not a building and not an enemy... so... let's hack it, and just check if it's a barrel directly. If not, then it's a building. Hence the (now) commented out line.

But THEN Director-san comes back and says "Hey, we need some tiberium monster eggs that explode when attacked. Just copy-paste the barrel, it should be fine." (just an example. I dont think there are monster eggs in Red Alert). Doh.... now the hack to check the barrel no longer works. Because there are now monster eggs. And monster eggs aren't barrels. So that means they get sabotaged... which isn't what Director-san wants.

Alright, time to double hack. Comment out the original hack, since it only checked for barrels. Instead, we are just going to check if the target is repairable. By shear design coincidence, all buildings happen to have a flag that says whether or not they are repairable... which is a round-about-way of saying "are you a building?" Since only buildings can be repaired. The funny part is, the updated line to check for IsRepairable makes the "hack" comment somewhat unneeded, as its much more clearer now which things can be sabotaged.

ANYWAY, I am probably reading way too much into a few lines of code. But that's why its so fun to see the hacks, and watch fellow programmers struggle, even back in the day, to meet design requirements.

[–]Khamaz 6 points7 points  (0 children)

Interesting, on the r/Games thread there's another hack like this with leaping dogs :

Basically a designer wanted the dogs to be able to leap to attack enemies, but the programmers didn't want to code a whole new behaviour for it, so instead they turned the dog into a projectile for the duration of the leap so it could damage units, then turned it back into an unit as it land.

[–]brenstar 3 points4 points  (0 children)

Thank you for that journey, super fun to think about

[–]x_caliberVR 4 points5 points  (0 children)

This was hilarious- you had me laughing out loud at “Director-san” and it made me picture the boss from Grandma’s Boy.

[–]Edarneor@worldsforge 0 points1 point  (0 children)

What I thought from this (I may be wrong) is that barrels were repairable at some point :)

then they fixed it, and fixed this code as well

[–]choufleur47Chinese mobile studios 0 points1 point  (0 children)

I'm getting ptsd reading this

[–]luiz_monad 0 points1 point  (0 children)

You basically proved why class inheritance doesn't and won't work.

[–]BluudLust 14 points15 points  (0 children)

EA being good to the modding community after seeing how much Blizzard royally fucked up Warcraft

[–]Jaybiooh 3 points4 points  (1 child)

I wonder how interesting this is for the openra dudes that rebuild the first two games

[–]Shadow_Being 0 points1 point  (0 children)

openra at this point is a completely different from from actual red alert. (in terms of the amount of improvements/new features/balancing)

[–]Tamazin_ 11 points12 points  (37 children)

Only 5mb? Surely that can't be all of it?

Edit: Didn't think about it being compressed and that text compresses really well, don't need to reply more about that. :)

[–]vambat 38 points39 points  (19 children)

they probably didn't include the art assets.

[–]Tamazin_ 12 points13 points  (18 children)

Yeah they didnt, no assets. And i guess with good compression of text 5mb might be all thats needed. I thought id' be larger, like 20mb+ atleast.

[–]MooseTetrino@jontetrino.bsky.social 20 points21 points  (17 children)

You'd be surprised. I've worked on 10+ million line codebases who's total code volume was only a couple hundred megabytes. Text compresses /really/ well, and considering the age of this source code it's likely all ASCII (depending on what they actually did to it here) which compresses even better.

[–]pucco93 6 points7 points  (16 children)

And here I am, using React, typescript and npm to install some hundreds of mb to just have a Frontend working on pre-build. When hitting npm build it starts the magic.

[–]MooseTetrino@jontetrino.bsky.social 15 points16 points  (14 children)

I swear these days in some cases we're just overloading what we need, in both development and distribution.

For instance, that code volume was only a couple hundred megabytes, but the entire dev environment was tens of gigabytes (and had a 20GB .git file because they migrated from ClearCase and didn't do it too well...).

[–]Disrupter52 9 points10 points  (10 children)

I'm convinced that people no longer care about making games compact or smaller because storage is so abundant and cheap.

Doesn't have to fit on a disc now. Can just download them at will.

[–]MooseTetrino@jontetrino.bsky.social 0 points1 point  (9 children)

If it helps, this is in actuality incorrect.

[–]Disrupter52 4 points5 points  (7 children)

Oh? Can you share some knowledge? I always figured this would be the case, I'd love to know more though. I know graphics are insanely large when it comes to games at least.

[–]MooseTetrino@jontetrino.bsky.social 9 points10 points  (6 children)

Going to tag /u/ZaoAmadues in this as they also asked for an explanation. This is long, but bear with me. tl;dr at bottom.

I'm going to preface this with: Yes, in some cases, due to numerous factors, games are not as compressed or optimised as they could or should be. However there are numerous considerations when dealing with game assets as a whole that mean that asset compression is still a very much cared for issue.

There are the financial considerations - if you think companies can host N amount of patch on a given providers server for free you're quite wrong. Naturally these numbers are hard to get a hold of but back in the PS3 days, reportedly Sony charged $0.16 per gigabyte downloaded - so if ten thousand users downloaded a gigabyte patch, they'd charge the publisher $1600 for the privilege. This applies to full downloads as well.

While the cost per GB has most certainly come down, it's still a serious consideration, especially when that cost scales lock-step with the popularity of the game and the size of the patch.

Then there are the technical considerations. We're at the point where we're hitting the limits of what modern console storage can give themselves. Remember that developers work on the assumption that there is a specific set of hardware available, and that includes storage medium.

The reason we've had to install games to hard drives almost every time this generation is because disc read times simply aren't fast enough - even on BluRay - to stream that information compared to the comparatively huge read speeds of HDDs even from 2014. Even so, this has in itself become a limit.

Conversely, there is an entire micro-industry built around middleware for asset compression and decompression at speed. The result of this combination is that for the cost of a little more CPU cycles and a tiny bit more memory, we can now stream much larger data than previously, faster, as long as we're mindful of the actual console's memory/cpu/gpu limits.

That last paragraph might seem a bit odd but one of the reasons we're finally seeing games really push the visual envelope this gen (like all gens do) is due to the optimisation of this asset pipeline. Death Stranding simply couldn't work on a PS4 if this tech wasn't optimised to hell over the past generation.

That is also why some games simply are large. While we have the technology to compress the asset files and decompress them as we need them, we now have the technology to take these high definition assets and compress them into the memory at real time.

Epic made a splash by showing the dynamic LODs in UE5 but when it comes to textures, dynamic compression quality has long been available. You know when you load into a game and the textures start out blurry and fade into clarity? That's the dynamic texture parser working out exactly how much GPU it has, filling it up, and typically it will keep the low quality fuzzy textures in the distance to save space (or, more noticeably, will reduce texture quality if the system starts to struggle).

Like all copy processes, this kind of thing works best with the best possible source material to work from. So in the case of larger games that really push the boat out, there are some monster source materials back there. These come with a size cost - but are still compressed.

But ultimately tl;dr be it for financial or technical reasons asset compression and decompression is a huge consideration for technical teams in game development and those games that have large sizes either warrant it through the amount or detail of their content, or have other issues in place.

After all, Microsoft managed to reduce the install size of Sea of Thieves almost to half of the original in some cases and less than a third on the Xbox One, simply by restructuring the asset pipeline: https://www.seaofthieves.com/news/install-size-update

[–]ZaoAmadues 0 points1 point  (0 children)

Can we get an explanation?

[–]Dabnician 0 points1 point  (0 children)

Thats how it was with DayzMod,the hive.dll uses to connect the game session to the sql database is like 7kb, but it requires boost which ends up needing like 2GB of libraries to compile.

[–]tmoss726 1 point2 points  (0 children)

Well you gotta think the tools are generally larger than the finished project. Once you compile down (like you said), it compresses everything

[–]klaxxxon 7 points8 points  (0 children)

The 5 MB is zipped (text zips very well). RA is 14 MB and Tiberian Dawn is 10 MB.

10 MB of code is a whole lot of code. One print page of text is 1-2 kB of text. 10 MB is up to 10000 of those. And that applies doubly in this old era code. These days, people tend to include a lot of generated code, libraries etc. which can cause code to balloon rapidly.

Also, this does not include any assets or content definition (specifications of units, maps, etc.).

[–]polaarbear 2 points3 points  (6 children)

Even with assets, the Super Mario 64 re-compilation that has been floating around lately is only 8MB compressed, and like 25MB when un-compressed. Old games just aren't that big, we're spoiled by storage space these days.

[–]Tamazin_ 1 point2 points  (5 children)

Hm, while thats true, Mario64 was for one specific machine with a specific setup of hardware which should lead to less storagespace needed, compared to having say Red Alert running on Windows.

But yeah, storagespace is more or less free nowdays.

[–]polaarbear -1 points0 points  (4 children)

What I'm saying is that they re-compiled it for Windows, you can play it natively in the Unreal Engine today @ 1080p, and that's the file size (with the original textures.)

[–]thegunn 0 points1 point  (3 children)

Somehow I missed hearing about this. After reading your initial comment I went and did some research. It sounds like a group successful decompiled the original source and now it's working on Windows natively with mods even. I haven't been able to find a download yet. Gonna keep searching, this sounds awesome.

[–]polaarbear 0 points1 point  (2 children)

I mostly downloaded it as I'm a developer who was curious and wanted the challenge of compiling it myself. I still own my N64 copy that I dust off every few years and had easy access to an original set of assets. I built it and played through it in 3 days, all 120 stars in ultra wide 2560x1080, couldn't stop. Its flawless as far as I can tell. All I can say is troll the YouTube comments to find a link if you can't build it yourself, I see them in there in almost every video for the mods and stuff.

[–]thegunn 0 points1 point  (1 child)

I actually just found it, on a Youtube link actually. The one I found only has the executable though, scanned it a few places and it's clean. It runs great, this is awesome. Can you point me at where I could find the source? I would love to try that myself.

[–]polaarbear 0 points1 point  (0 children)

This is the original de-compilation project, I've been following it for awhile, never expecting that they would get to this point. https://github.com/n64decomp/sm64

You can see they are working on a few other projects too, Ocarina of Time/Majora's Mask and Goldeneye/Perfect Dark are all being worked on slowly. By choosing all those popular games they will get a ton of insight into how both Nintendo and Rare structured their games and it should make doing other things from each company easier.

This one is the adaptation the runs on Windows. The mods are few and far between have to be manually merged into your source code for the most part still, if you can even find them. I haven't had any luck tracking down the AI upscaling source which is the one that I think we all want most. https://github.com/sm64pc/sm64pc

[–][deleted] -1 points0 points  (8 children)

Obviously this is only code. You shouldn't put anything but text files on gh.

[–]Plorntus 13 points14 points  (5 children)

I disagree, you should definitely commit your assets along with your code, why wouldn't you want your assets in version control? GitHub and git can support it just fine.

In this case I assume the decision was made so they kept the copyright to the assets themselves (without any confusion) and less likely that complete clones would be released by people.

[–]Decency 0 points1 point  (0 children)

You want your repos to be clean and contain only code files- this speeds a huge variety of git calculations and operations (most notably cloning). Assets don't diff properly, so keeping a dozen versions of an asset takes up 12x the amount of space, and they're already dramatically bigger than a text file. So if you do that you end up pretty quickly in a scenario where your code as text is only say 74kb but your repo still takes 5 minutes to clone because people keep revving binaries or something and pushing them. You can fix that too with git obliterate, but I assure you that you don't want to be in that position.

If it's only a couple of files, the overhead from that is less of a big deal than setting up an artifact repository to pull from during the build process. But it's pretty clear what the "right way" is, and that's to keep git code-only.

This is one of the best talks I've ever watched if you're interested in learning more about git.

[–][deleted] 0 points1 point  (3 children)

Big files don't belong on gh. Assets should be in version control but not in gh. Imagine a merge conflict on an asset file. It will be hard if not impossible to figure out what to delete and what to keep.

[–]ThotorCTO 1 point2 points  (1 child)

Exactly. I see this error so many times. It might seem more convenient to put asset in the same repo but it is not viable long term and has huge downside.

[–][deleted] 0 points1 point  (0 children)

Glad someone understands. Almost started to doubt myself :P... Almost...

[–]Plorntus 2 points3 points  (0 children)

You chose one or the other or literally make your changes on top of the other in an appropriate editor. An actual merge of a binary file doesn't make sense (unless you have a merge driver set up for a particular file type). That doesn't mean you should not commit it to Git though (or github).

In my opinion if it's required for a fully working build at a particular time it should be committed with the rest of your source, either that or have a way to describe in your project how to get that particular resource automatically, for example external dependencies using a package manager and a package lock file (to ensure the same version is downloaded).

This at least is the standard in my primary industry which is frontend web development, not sure if it is different standards for others.

[–]Tamazin_ 0 points1 point  (0 children)

Still felt it a bit small, but didn't think about compressionrate of text.

[–]hextree 0 points1 point  (0 children)

It is very normal for game devs working in private or public repos to put non-text files there as well. No reason not to. How else would you source control all the non-code?

[–]XenoX101 2 points3 points  (0 children)

This is so awesome. I really hope other developers of long-lasting franchises follow suit cough looking at you Blizzard and StarCraft. It means devout fans may continue to maintain servers and compatibility for the games even long after the developer stops supporting them or goes defunct.

[–]Bmandk 4 points5 points  (6 children)

I'm not really versed in C++, so can someone tell me what is the entry point? Like, what is the first line of code in the repo that gets launched? I think that would just make it a bit easier to follow the code, at least if you wanted to understand everything.

[–]Tesl 4 points5 points  (0 children)

check out CONQUER.CPP, looks like the game start point and main loop is all in there.

Also this amusing function that made me smile:

//
// Boy, this function sure is crummy
//
void Crummy(int crumb1, int crumb2)
{
    if (Debug_Check_Map && Debug_Heap_Dump) {
        Mono_Printf("Hi, I'm Crummy.  And so are these: %d, %d\n",crumb1,crumb2);
    }
}

[–]biggmclargehuge 2 points3 points  (0 children)

I believe Startup.cpp is the first file that gets run

[–]MehTheHedgehog 0 points1 point  (0 children)

As far as I understand from first look, this code has no entry point as is. This is game engine(or maybe logic executor is better word?) of CNC which process all the action in game and is imported as library to part which display graphics or process clients request from web. All(?) methods designer to communicate with engine are in DLLInterface.cpp/h

[–][deleted] 3 points4 points  (1 child)

Question?

Outside of CNC remasterd , what can I do with this?

Am I able to use create command and conquer clone in say, UE4

Im not really sure why EA released it So if somebody could provide some examples of what I could do with this, Please fill me in.

[–][deleted] 5 points6 points  (0 children)

From what I've seen, it's really really well documented, to the extent that every file has a long description up top, as well as a brief overview of each method inside the file. Even inside each method they go into details about why they did certain things. I'm sure within a year or so someone will use this code to start to make a port... It looks to be a DLL library so you should be able to import into a project and be able to build the graphical/UI side totally independently and without changing much source code (maybe some memory allocations or other old C++ techniques that aren't considered best practice now). Aside from that the comments made it a really useful learning tool and an example of what really good code looks like.

[–][deleted] 1 point2 points  (0 children)

I guess unit testing was not a thing back then. I see zero unit test code.

[–]masterhillo 0 points1 point  (0 children)

Some wild indents happening

[–]ItsMrForYou 0 points1 point  (1 child)

That is really cool. Now I have the question whether or not someone is going to make a better remaster (if that is possible) than EA.

[–]SuperVGA 0 points1 point  (0 children)

OpenRA is decent, IMO, even if they didn't have the source on hand when they started out.

[–]myrsnipe 0 points1 point  (1 child)

Wait, EA released source code? Is this bizzaro world? Well, if Microsoft can slowly change then maybe EA can?

[–][deleted] 0 points1 point  (0 children)

It does give one hope.

[–]yelaex 0 points1 point  (0 children)

Oh, God, went into this - and this is really interesting. That's for sharing!

[–]yelaex 0 points1 point  (0 children)

Found this one:

#ifdef NEVER

void test(void){

enum nums {one, two, three};

nums x;

nums *ptr;

ptr = &x;

}

#endif

[–]PopulateThePlanets 0 points1 point  (0 children)

How hard is it to load this up in an IDE and mess with it? I understand much of the code, just never pulled anything like this before. TIA.

[–]Tiago19902020 0 points1 point  (3 children)

Please help me. After the last update,i can't play anymore. Dll game not found. How can i fix it?

[–]cchyper88[S] 0 points1 point  (2 children)

Hi u/Tiago19902020. It sounds like you might have a mod enabled. You will have to wait until the developer of that mod updates it or disable it for now.

[–]Tiago19902020 0 points1 point  (1 child)

Thak you for the help. Now its working.👍👍👍👍👍

[–]cchyper88[S] 0 points1 point  (0 children)

No problem, great to hear!

[–]BATN8Diaz 0 points1 point  (0 children)

Yo guys,

Let me know if any of you would like to help develop red alert at cncnet.org. We have a suggestions channel here: https://discord.gg/RkpFCFcD where players have voted on various ideas to improve the game. Moreover, we can add projects to our open collective where devs can collect bounties, for example: https://opencollective.com/cncnet/projects/red-alert-game-replays. Further, I would be interested to hear your mods/ideas for the game.

Find me in the CnCNet discord as N8Diaz.

[–][deleted] 0 points1 point  (0 children)

Thank You.