Adding a new class to the SDK

phungus420

Deity
Joined
Mar 1, 2003
Messages
6,296
I'd like to remove all the hardcoding from RevDCM. I think the best way to do this is to create a new derivative class of CvGame, CvGameRevolution, and probably something similar for CvPlayer and CvCity (but I'd do that later, right now the core stuff in CvGame is what I'm interested in). How do I account for adding two new files (the header and implemenation files) in the makefile? I'm sure I'll have other questions related to this later, but for now I'm just not sure how to add new files to the project.
 
You'll also need to change wherever CvGame is created with "new CvGame(...)". But to answer your question you need to list the .cpp file in the XXXOBJS definitions (release and debug) and create a target for the .obj file by copying one of the others. Oh, are you using Danny's makefile or one based on Refar's?
 
One approach is to add many new data objects to an existing class. A second approach, as you suggest, is to create a subclass with its own h/cpp files. What is the benefit of the second approach? I can't think of any mod which has made a subclass. There are mods which have added new data objects, such as the spell class in FFH and probably many other examples; but that is different.
 
Also IIRC CvPlayerAI extends CvPlayer, so you'll also need to change CvPlayerAI's superclass. I have no idea what this will do to the EXE which is bound to certain class names AFAICT.
 
Hmmm. Well if the Exe is an issue for using a derivative class (especially for CvGame), then that's that I guess. I could just create an entirely new class, CvRevolution, and work with that. May be a bit more complicated as alot of the stuff I'd like to implement would more logically work as a derivative of CvGame, but you gotta do what's practical sometimes.

Also RevDCM uses the new speed makefile. Saves me quite a bit of time actually, used to take litterally 2 and a half hours to compile, now it's closer to 20 minutes.

Edit:
On an unrelated note, there are actually some asserts in the exe that fire and can tell you what's going wrong if you have a debugger attached. Just had this happen and the debugger actually pointed to the variable and the "runtime exception message" made it quite clear I had flubbed a float & int variable.
 
I'd like to remove all the hardcoding from RevDCM. I think the best way to do this is to create a new derivative class of CvGame, CvGameRevolution, and probably something similar for CvPlayer and CvCity (but I'd do that later, right now the core stuff in CvGame is what I'm interested in). How do I account for adding two new files (the header and implemenation files) in the makefile? I'm sure I'll have other questions related to this later, but for now I'm just not sure how to add new files to the project.

I'm not sure I see the point of this new class. What revolution hardcoding remains?

Also IIRC CvPlayerAI extends CvPlayer, so you'll also need to change CvPlayerAI's superclass. I have no idea what this will do to the EXE which is bound to certain class names AFAICT.

Wrong way around. CvPlayer is an extension of CvPlayerAI. All of the AI classes are the main class, and the non-AI classes are extensions of them. Nvm, I was mistaken.
 
Top Bottom