Homeworld Source

0 views
Skip to first unread message

Bazara Benavides

unread,
Aug 5, 2024, 1:23:29 AM8/5/24
to layposappcho
Insidethe Box serves as a forum for individuals involved in the production of Gearbox Software content to share personal motives, methods, process and results. Gearbox Software projects are created by a diverse range of individuals spanning a spectrum of different backgrounds, interests, objectives and world views. The views and opinions expressed in this article are those of the author and do not necessarily reflect the official policy or position of Gearbox Software or any of its individual members outside of the author.

Homeworld was released around the time we finished Opposing Force and I remember having played it a bit back then. Being somewhat of a packrat I still had my boxed copy of the game on a shelf in a closet at home. A month or so ago I dusted it off and it is now sitting on my desk at work. I had also worked for a while on shipping a real-time strategy game, Dominion: Storm Over Gift 3, at the company I worked for before coming to work at Gearbox. Getting involved with working on the Homeworlds would allow me to step back, for a little while, to what I did before working on first person shooters.


The source code for Homeworld that Brian had downloaded was released by original developer Relic Entertainment at the end of September in 2003, not long before they shipped Homeworld 2. Homeworld was released at the end of 1999 which means, at this point, the source code was over 13 years old. Compiling the code with the tools I had available was going to be a challenge.


Homeworld shipped using, it appears, Microsoft Visual Studio 97 as the main C/C++ compiler. I decided to go ahead and try to build the game with the most current Microsoft compiler to see what I would get. This did result in a number of warnings and errors due to the changes that compilers have gone through in the 13 or so years that have passed since this code was written.


I was eager to see the contents of the files I had only been able to see as a list in an Excel document. Given that the original game was in straight C code I imagined things would be quite different after the transition to C++. Given the issues I encountered compiling 13 year old code with a modern compiler I was interested in seeing how much would compile right out of the box. I fired up Visual Studio 2012 and got ready to open one of the projects in the Homeworld 2 source directory.


When writing code a programmer relies on the compiler to catch errors much the same way a writer relies on spelling and grammar checking in word processors (or a human editor reviewing the story). If the code compiles, we move on and might not notice the error until running the code produces obviously incorrect results. When dealing with massive amounts of code, and the occasional typo, the chance exists that some issues will go unnoticed.


The time came when the above issues were resolved, the compile succeeded, and it was time to try running the game. I was a little amazed that the first time I ran Homeworld 2 the front end menu came up with working mouse cursor and sound. I could navigate through the menus and everything was working fine. It was gratifying to see all those changes culminate in something I could see and hear. With all the changes I had made I expected the game to eventually crash, which it did when I tried to start a campaign or skirmish game.


That first crash, and the few that followed, were mostly related to two things. One goes back to what I mentioned about the changes that have been made when managing lists in C++. Some of those changes caused the way Homeworld 2 sometimes goes through lists of things to not work in the same way. The other change is that more checks have been added to compiled code to identify potential problems while the game is running. There were not that many areas where this was causing a problem so after a few more changes to the code I was up and running with the 1st mission of the game.


After feeling some amount of success from this accomplishment I decided to move on to compiling Homeworld. I now had some experience with the issues I might encounter migrating older code to the latest compiler. It was easy to imagine that the solutions to many of the compile errors I had seen in my prior attempt to build the code would be easier to take care of.


I started by creating a Visual Studio 2012 project for Homeworld. Builds for Homeworld were set up to be run from the command line, so I needed to create a project file from scratch. Luckily Homeworld is built as a single executable so it was very straight forward to drop all the source files into a project and to pull the compile options from their build script. Once I could compile it I did a build and worked on fixing the compile issues. Most of the issues were related to the warnings I mentioned above where Microsoft had made changes to conform to current standards.


The most challenging issue I ran across is one where I have to put a shout out in thanks to the mod community that had been working with this code after it was released. Campaign missions in Homeworld start as script files that are preprocessed through the Microsoft compiler (a step in compiling that replaces keywords in the file fed into it with replacement text defined in a common file that all mission scripts reference). The file created by this process is then fed into a utility (kas2c.exe) that converts the script into C source that is compiled in as part of the Homeworld executable. I was a little unclear on how this step should work, but after a few internet searches I tracked down forum posts that gave me the information I needed.


The results of running Homeworld for the first time were much the same as they were when running Homeworld 2. The UI and mouse came up, I could navigate through menus and sound was working. I started up the campaign and got a crash. The reasons for the crashes I encountered when running Homeworld were quite different than they were for Homeworld 2.


The next crash occurred when I would destroy a target drone in the 1st mission. Homeworld has a nice system set up for the way it calls code for the effects. They had to do a few creative things to make the system work properly in older versions of Windows. The modern error checking that happens at runtime I mentioned before had some issues with a couple of these workarounds. The solution to this one was to disable that particular error since the Homeworld code worked even though it was doing something the error checking thought was a problem.


The amount of time it took me and the number of changes I had to make to get Homeworld running was substantially shorter than it was to get Homeworld 2 running. This mostly speaks to the fact that C was pretty well set as far as standards go in 1999. C++, on the other hand, was still evolving rapidly. That and a substantially larger codebase made the process of porting Homeworld 2 a bit more involved.


It was interesting to step back in time while getting these two games up and running. I got to see a bit of history in the code and I got to reminisce a bit about some of the stages in that evolution. My first job after graduating college was doing object oriented development and C programming for Windows 2.0. After this most of the work I did was with C++ in Windows and Unix with a little bit of Objective C sprinkled in there for one or two projects.


It has also been interesting to see another approach to data driven development. At Gearbox we had always been migrating in that direction, but when a small group of us were working on Borderlands many years ago that methodology really moved forward here. Seeing the approach taken with using Lua script in creating the Homeworld 2 gameplay rules, constructs, and UI has been cool to see.


The flagship is you main unit, or character in the game. A flagship (or flag for short) can be equipped with various weapons and better sensor arrays (see the modules page) and it has multiple officer slots for its various compartments (see more on the officers page). The flag is the only ship in the game that cannot be permanently destroyed. When its hull reaches zero, it will be disabled and the player will get a prompt to jump back to a trading station for repairs. This means that you can use your flagship as a de facto tank to protect your weaker units


Frigates are an escort class unit that costs one escort slot. Although they have less health than a flagship or destroyer, they supplement a good amount of additional damage for your fleet. Two frigate will out damage a destroyer of the same tier and rarity.


Destroyers are tanky escort units that costs TWO escort slots, so you will need at least an T2 flagship with no other escort unit equipped. They have a lot of hull and armour, sometimes more than a flagship. They can act as a dedicated tank for you fleet and will be fine on its own for a long time. They deal mostly hull damage and a bit of armour damage. Although a destroyer has more health than two frigates combined, it'll have less damage in total.


Interceptors and bombers (also both known as fighters) are the smallest unit you can deploy from your flagship. Each squad takes up one squad slot, so for most flagships, you are able to deploy four units (unless you use a carrier flagship). Interceptors generally have quite a bit of hull damage, only lacking behind the assault corvettes. They also have a larger sensor radius then other squad types, so they can act as scouts for your fleet. Bombers however have the highest armour damage of all squads in the game. Interceptors are fast and agile, but have lower health then other squad types. Bombers are slower and less agile, but have a bit more tank.


Corvettes are the largest combat squads you can deploy, with a lot more tank than fighters, they are a less agile, slower but harder hitting variant of their smaller cousins. Assault corvettes have the most hull damage out of all squads, and pulsar corvettes have a good mix of hull and armour damage (although less armour damage than a bomber).

3a8082e126
Reply all
Reply to author
Forward
0 new messages