views:

292

answers:

5

I have been a Half-Life lover for years. I have a BS in CS and have been informally programming since High-School. When I was still in college I tried to become a mod programmer for fun..using the first Half-Life engine...didn't work so good. So i figured after all my great college learrning :-) I would have more insight on how to tackle this problem and could finally do it. So here I am..finally out in the business world programming java...so I downloaded the HL2 SDk and started looking through the class structure. I feel like I did that last time I tried this...dazed and confused. Sorry about all the back ground.

So what is the best way to systematically learn the code structure? I know java and I know c++..i just dont know what any of the classes do...the comments are few and far between and the documentation seems meager. Any good approahces? I don't wanna start my own mod... I just wanna maybe be a spare-time mod programmer on some cool MOD one day...to keep the fun in learning programming along with the business side.

+3  A: 

You can start at the Valve Developer Wiki.

Majin Magu
A: 

I'd do what I do with any other vague system... set lots of breakpoints and get a feel for the structure by watching it function. Add your own comments/documentation as you go. Test your understanding by making small changes and see if you get expected results.

Dave Swersky
+1  A: 

I think the best way is to check out the source code of one of the few open source mods out there, Open Source Jail Break. It will help you at least get familiar with the code.

Beyond that, its just developer resources and forums.

Edit:Plan of Attack seems great too.

Also: This is a great list, including both general and specific topics.

Paperino
+6  A: 

the comments are few and far between and the documentation seems meager. Any good approahces?

Welcome to the wonder that is the Source SDK. No, it's not documented. Experiment, hack, place breakpoints and see what happens if you change bits of code.

There is a wiki you may find helpful in some cases, but it's filled in by the community, and not by Valve, which means that you won't find any actual documentation there, just explanations of how previous modders have hacked the engine.

Honestly, it sucks. The only way around it is to dive in. Try to achieve various changes to the game and don't be afraid to rip the existing code apart. It won't be pretty, but if it works, who's going to complain? Their code is pretty horrible, and most likely, yours will be too.

jalf
The build time for the engine is at least 30-40 minutes. That was one thing that discouraged me from playing around too much. My C++ is a little rusty, plus i never have dealt with really large builds,but do I have to rebuild the entire engine if I change a few classes or will it just recomplile the changed ones?
Egg
It depends on what you change. If you change a header file, everything that includes that header will have to recompile. If you change a .cpp file, only that file should need to be recompiled.
jalf
A: 

I've worked with the Source SDK for a little and made some modifications. Really you have to have a good understanding of C and C++. The Source SDK isn't modern C++ and is much more akin to C with classes than any real OOP.

The SDK is simply fashioned in that the major of code is comprised of entities, of which many you can ignore.

Also know that the SDK uses inheritance very heavily, so look to base classes for functionality that you may desire.

I'd say make a list of important files and classes that maybe relevant to what you want to do with the SDK. Then start sorting these files using virtual folders in VS (or real folders on the filesystem) and use the find in files option (or grep) to find your way around.

Some sample files: eiface.h - Engine interfaces gameinterface.cpp/.h - Lots of interfaces from external dlls for server cdll_client_int.cpp/.h - Lots of interfaces from external dlls for client *_gamerules.cpp/.h - Gamerules (determines logic of game) world.cpp - Entity that determines the map properties and loads the gamerules and other entities

Also try to use the Source SDK Base instead of the HL2MP Base for a mod. The former is a lot cleaner and easier to build off of.

Huur