I wanna learn C++

There are plenty of free tutorials out there, but C++ is a tricky thing to learn if you've never done any programming before. You might want to consider finding a book to get you started on the subject. I say this because C++ is a difficult language to adapt to, even for programmers who are familiar with sister languages like C#. If you're coming to it new, it's a good idea to get a comprehensive look at it and its parts before trying to piece it together.

That's not to say tutorials aren't useful. It's just that they'll be best to use once you actually start modding files. I can't tell you how many times I've been halfway through a line of code and gone, "I just forgot how to do that!" That's when tutorials are gold.

As for recommendations, I am currently reading C++ Weekend Crash Course by Stephen R. Davis. While not perfect, most of what it contains is pretty relevant to the kinds of things you'll need to do to successfully mod Civ IV.

-isau
 
Cool. and useful. I've got a book here called "C by dissection" by some geezers (Al Kelley and Ira Pohl). the only problem is it's C, and not C++
 
C won't do, not if you want to learn enough to modify Civ4's DLL.

Look for tutorials on C++ Object Oriented Programming (OOP). In particular you want to make sure you understand classes and their member data, functions (methods) and relationships. A basic understanding of enumerated types will also be helpful as well as arrays and vectors.

I can't help with any that worked for me, I used books to teach myself some years ago.
 
Word of caution: if you've never programmed before, C++ can be somewhat daunting. It's a complex language with many oddities. Therefore, if you start from scratch, you probably won't be able to do any interesting modification to the Civ4 code for a while.

It's definitely worth it, though. Learning programming can be an amazingly rewarding experience.
 
thanks solver. I am wondering whether it would be worth learning the ins and outs of the language first. I had a look at a thread started by Kael called sample SDK code. I noticed that it looked somewhat similar to python at first glance, and theren't weren't many oddities (although again, at first glance :)). Would i be better of starting with those kind of samples?
 
C++ is huge... many seasoned programmers don't know the details of it!

I'd say you would first want to be comfortable with language basics such as loops, control flow and data types. For Civ4, you'll also want to have at least a general understanding of what classes are and how they work, and I'd also suggest reading something about pointers - Civ4 uses them extensively and they're often a source of confusion. Although whether you'd need them would depend on what you mod.
 
Also, a big part of learning to work the C++ in Civ IV involves figuring what the heck all those things are in the SDK. It takes a long time to get familiar with what all the files in there do, even once you get the C++ knowledge down. Here's a quick overview to get you started:

The first files you will (probably) want to look at are:

- CvPlayer - Contains all stuff related to an individual player. This includes human and AI players, altho the actual AI logic is handled elsewhere (in CvPLayerAI, which builds on class CvPlayer)

- CvTeam - Stuff related to the team. One of the things you'll need to become familiar with is the fact that every Civ player is always part of a team, even if it's a team of 1. There's lots of stuff that's on the Team level that's not immediately apparant, including all Victory conditions, espionage points, open borders agreements, and other such things.

- CvCity - Stuff that happens at the individual city level.

- CvUnit - Stuff that happens at the individual unit level. This refers to live units that are actually on the map. Be careful not to confuse it with the the class CvUnitInfos (or the other unit infos classes), which refer to static facts about the unit stored in XML files.

- CvGame - Stuff that pertains to the entire game that is currently in play.

- CvPlot - Stuff related to an individual plot on the map.

- CvInfos - While not actually a class, the CvInfos file is a good one to look through. There's a ton of stuff in it. An 'info' class means data loaded directly from XML that doesn't ever change in the live game. Examples of info classes are CivicInfos, TraitInfos, UnitInfos, ReligionInfos, etc.

-CvGameTextMgr - The central text manager that handles most of the long pieces of text that appear throughout the game. Handles the text that pops up on screen explaining civics, units, traits, etc.

Anything that starts with Cy is related to Python. You only have to fool with these if you need to share your SDK code with Python files. You will generally have to do this when you add features that will need to be displayed on the screens in the game (unless you can sneak the code into CvGameTextMgr, as I sometimes do).

-isau
 
Back
Top Bottom