I like to code when I'm bored, and I'm bored and sniffing around the source code again. I don't mean to condescend. I just wonder if there is a specific cause.
Why is it all just plain 'C' (I prefer C++, and despise C#)?
Everything seems to be done from global functions. Why not in classes? For example:
Example one:
Having spells done not though a constant function call, but a function pointer that has one argument passed by reference. The compiled code deferences a function pointer regardless, the only difference being one pointer is a constant that's "compiled on" the other called from RAM. Also, instead of having to copy a object or pointer for each argument, only one pointer is passed to the class that points to a structure that holds all the needed information.
Pros:
1. A spell call becomes modular and standardised.
2.As the argument is passed by reference, a literal object maybe given or a deference pointer. Used as a literal object, and the compiler takes care of deference, and as a reference is a pointer the time needed to pass a object by reference is the same as the time needed to pass a pointer.
3. A standardised super class or structure that holds a large block of information may seem inefficient, but the information has to be stored somewhere anyway, it's now just grouped in a easy to access way by pointer.
Examples two:
A virtual base class (A interface class) that's inherited by a spell class.
Pros:
1. A spell object becomes standard and self contained with a standard interface for all classes, that maybe expanded by inheriting another interface class.
2. The only needed input would be where a object where the object is applied.
3. Only as much memory as needed is allocated to a spell.
Cons:
1. The class is partially or fully virtual. A single static function pointer array for each class is created, and one addition pointer is deference each time a virtual function is called. (Once for the array, and once for the standard function call.)
Why plain C, and why not encapsulated?
Moderator: Board moderators
-
- Luser
- Posts: 19
- Joined: Sun Aug 10, 2008 12:17 am
-
- Luser
- Posts: 19
- Joined: Sun Aug 10, 2008 12:17 am
Scratch that, I just spend the last two hours probing the possibility of bringing Crossfire up to C++ specs. The code is reasonably well written, simple, and easy to add to, It's a finely built watch. However, changing it's like working on said watch with a sledge hammer when it's made of thin glass and not bigger then a mouse. 
Better question: Can/Will the main 'Crossfire' project be C++?

Better question: Can/Will the main 'Crossfire' project be C++?
For interested people, I replied on the other thread, see http://forum.metalforge.net/viewtopic.php?p=11588#11588