It is sometimes claimed that "Effect X is just two lines of code, surely Johan can do that easily." I thought I'd take a moment to pontificate on just what can be involved in two lines of code. Those of you who are programmers yourself can either nod and chuckle ruefully, or just ignore me; the rest of you 'orrible lot, sit up straight and pay attention!
First, of course, there's the question of just where those lines of code should be added. A game on the scale of CK contains humongous amounts of code; it is just plain impossible to keep in your head what all of it, or even a large part of it, does. Especially when coming back after a couple of months of coding something else. And if the part you are modifying was coded by someone else, finding what you want to modify can be a truly serious pain in the butt. Of course, all programmers comment their code so you can easily figure out what a given line does. Hah.
Searching through several thousand lines of source code (assuming you can narrow it down that much!) to find the particular subroutine you want can be a real pain. If you are lucky, it was given a descriptive name and good commenting. If you are several patches into the release cycle, the subroutine might do something entirely different from what its name suggests, but the name couldn't be changed because other parts of the code would have to be changed also - this sort of thing can ripple into a week of hunting down all the places that need to be changed. And if the coder who programmed it originally was in a hurry, or thinking about his girlfriend, or had one too many beers the night before - good luck with the descriptive name.
Assuming you can clear this hurdle, there's the actual programming. Here is where the "it's only two lines" has something going for it. Adding two lines really is pretty quick, once you've figured out what variable you need to change - and again, pray for descriptive names and good comments! Of course, you want to be sure you're not changing anything you need further down the subroutine, much less a global that isn't reset. (And Johan, that 'Initialising Globals' part of starting CK takes forever - bad designer, no cookie!) If you created an object, be sure to release the memory for it, or you'll create a subtle and elusive crashbug that won't manifest until the game has been played for quite some time, enough to call that particular code many times over and use up a lot of memory.
So, we've coded. Done, right? Oh no! Now we need to compile. It is to be hoped that your code is nice and modular, and changing one part of it only means recompiling one or two files. Bwah-hah-hah. In reality, as projects get big and crufty, the dependencies stretch out like an SP player grabbing the good bits of Europe. You are certainly looking at a coffee break's worth of compiling, which can easily stretch to half an hour. If you're in a central part of the code, overnight is not unheard of. You had better hope you didn't use the . operator when you meant ->, or some similarly trivial mistake.
As errors go, though, that kind of thing is pretty easy to catch - even a compiler, not exactly the most subtle of the beasts of the field, can do it. Logic errors are much more difficult. Suppose you forgot a de-reference, and are hitting the character instead of the character's father? And, incidentally, did you remember to test that the character's father actually exists? If not, you have a nice little crashbug on your hands. Better check that your test-of-existence actually tests for the existence of your target, and not his grandmother's uncle.
So you need to test your program. That takes time. At the very least, enough time to load up CK, set up the situation you want, and trigger the event. Then you need to check that it does what it's supposed to. In various circumstances, to be sure. Does it work with Moslems? With unmarried people? With bastards? It's surprising what kind of thing can make a difference in a vast project like CK. All kinds of things are coupled to each other and do unexpected things.
So you've tested the code, and it doesn't crash the game. At least not immediately. Let's run for a few hundred years, just to see if we've introduced any nice subtle memory leaks or other long-term effects.
Now, what about gameplay? Does it unbalance the character? Make him unreasonably powerful? Does it need to be tweaked? Better email your loyal legions of beta testers. It'll take a day or two for them to reply, of course.
Most important of all, is your change fun? Do howls of protest go up every time you mention it? Oh dear, better change it back, or at least nerf it a little. Now, where was that piece of code, again?
Only two lines. Sure.
First, of course, there's the question of just where those lines of code should be added. A game on the scale of CK contains humongous amounts of code; it is just plain impossible to keep in your head what all of it, or even a large part of it, does. Especially when coming back after a couple of months of coding something else. And if the part you are modifying was coded by someone else, finding what you want to modify can be a truly serious pain in the butt. Of course, all programmers comment their code so you can easily figure out what a given line does. Hah.
Searching through several thousand lines of source code (assuming you can narrow it down that much!) to find the particular subroutine you want can be a real pain. If you are lucky, it was given a descriptive name and good commenting. If you are several patches into the release cycle, the subroutine might do something entirely different from what its name suggests, but the name couldn't be changed because other parts of the code would have to be changed also - this sort of thing can ripple into a week of hunting down all the places that need to be changed. And if the coder who programmed it originally was in a hurry, or thinking about his girlfriend, or had one too many beers the night before - good luck with the descriptive name.
Assuming you can clear this hurdle, there's the actual programming. Here is where the "it's only two lines" has something going for it. Adding two lines really is pretty quick, once you've figured out what variable you need to change - and again, pray for descriptive names and good comments! Of course, you want to be sure you're not changing anything you need further down the subroutine, much less a global that isn't reset. (And Johan, that 'Initialising Globals' part of starting CK takes forever - bad designer, no cookie!) If you created an object, be sure to release the memory for it, or you'll create a subtle and elusive crashbug that won't manifest until the game has been played for quite some time, enough to call that particular code many times over and use up a lot of memory.
So, we've coded. Done, right? Oh no! Now we need to compile. It is to be hoped that your code is nice and modular, and changing one part of it only means recompiling one or two files. Bwah-hah-hah. In reality, as projects get big and crufty, the dependencies stretch out like an SP player grabbing the good bits of Europe. You are certainly looking at a coffee break's worth of compiling, which can easily stretch to half an hour. If you're in a central part of the code, overnight is not unheard of. You had better hope you didn't use the . operator when you meant ->, or some similarly trivial mistake.
As errors go, though, that kind of thing is pretty easy to catch - even a compiler, not exactly the most subtle of the beasts of the field, can do it. Logic errors are much more difficult. Suppose you forgot a de-reference, and are hitting the character instead of the character's father? And, incidentally, did you remember to test that the character's father actually exists? If not, you have a nice little crashbug on your hands. Better check that your test-of-existence actually tests for the existence of your target, and not his grandmother's uncle.
So you need to test your program. That takes time. At the very least, enough time to load up CK, set up the situation you want, and trigger the event. Then you need to check that it does what it's supposed to. In various circumstances, to be sure. Does it work with Moslems? With unmarried people? With bastards? It's surprising what kind of thing can make a difference in a vast project like CK. All kinds of things are coupled to each other and do unexpected things.
So you've tested the code, and it doesn't crash the game. At least not immediately. Let's run for a few hundred years, just to see if we've introduced any nice subtle memory leaks or other long-term effects.
Now, what about gameplay? Does it unbalance the character? Make him unreasonably powerful? Does it need to be tweaked? Better email your loyal legions of beta testers. It'll take a day or two for them to reply, of course.
Most important of all, is your change fun? Do howls of protest go up every time you mention it? Oh dear, better change it back, or at least nerf it a little. Now, where was that piece of code, again?
Only two lines. Sure.