If there are no differences between structs and classes, why do you have to use a different method of initializing the variables? For structs, something as simple as "Example x = {5, 5, 2} where x is an object of the struct Example" can be used to initialize the three member variables in a struct, but to do the same with a class, you need to use a constructor? Or am I missing something?
Well for modding, what would you describe something like multitek.txt where you can modify values and those have an effect ingame? Aren't those values member variables of some class or they just regular variables?That's a data file. How it gets loaded into memory and the structure of the program is a completely different question. I would choose to store the tech info as members of a struct (or class), and have an array of such structs. The tech data will be present throughout the level, and is of likely variable size, so it's more likely to be stored in a data structure on the heap, rather than local or global variables. Consider for a moment how you would store that data as non-member variables? It almost doesn't make sense when you consider how much data is being loaded. You would need a lot of variables to store that much data. Trying to store the data without a systematic way of putting it into data structures would be a nightmare.
What do you mean by hooks in the code (I understand the concept, but have no idea how one would code a "hook" in); I ask because I'm very interested in making a game moddable as it really helps to extend the life of a game?Pointers.
Okay, a better question with modding in mind. How can modding be supported without making the game unstable by having the presence of mods? I ask because a game like Fallout or Elder Scrolls gets more unstable as more mods are added. And as that is one of the big games for offering modding support, how does one avoid game instability with added mods. Generally if mods conflict or lack dependencies the game crashes to desktop immediately, but why do the mods cause instability otherwise?That's largely due to their sloppy plugin loader implementation which has always (ever since TES3) required third party workarounds like merged patches made with e.g. Wrye Mash or TES5Edit, mod load order sorting utilities like BOSS, etc. Mods introducing tons of extra global scripts can potentially cause issues, changing vanilla scripts can possibly break things, and with the complex open world environments of those games it can be hard to test for all the edge cases. Probably the biggest thing to worry about here is extra memory use, as the game will crash if it exceeds 4 GB (or 2.5 GB pre-TES5 without using a 4 GB LARGEADDRESSAWARE flag patcher). I've played extremely heavily modded Skyrim and it was pretty stable, but you have to jump through the hoops of making a merged patch and properly sorting the mod load order to get it that way.
struct TechInfo
{
int techId;
int category;
int lab;
int cost;
// ...
};
TechInfo fixedArray[1024];
TechInfo *dynamicArray = new TechInfo[size];
but it won't be sufficient if I want to make a more complex RTS
I'm going to make a new Outpost using Unity! Then I'm going to sell it and we'll all make a lot of money! And I know what I'm talking about because I made a mod for StarCraft 2 and it was 30,000 lines of code! -squee-
Finally, those who wish to live in reality don't dream don't adapt and don't play video games :P
If you pressed the reset button and killed off the entire planet, you would rule the world, as you'd be the only one left. XD
Living in reality simply means I know my limits, I know my skills and I know what's doable and what's fantasy.Do you really know your limits leeor_net? Do you really know your ... outer limits? :D