Curious if we have anyone who has mastered FNEW and added new, complex classes to the DLL. I can get a basic class (that is to say, the class only contains a constructor and primitive types) instantiated and working, but once I start to expand the class beyond that, it all goes to hell and the pointer is immediately invalidated. I Googled and searched this site for any mentions of FNEW or adding a new class and only found two real discussions on it: One where Drawmeus asked about it and responded to himself by saying, "This is hard"; and another that was only tangentially related and the answer didn't have anything to do with FNEW.
Specifically, I added a dummy class to CvPlayer in a separate header file:
CvPlayer.h
In CvPlayer.cpp::gameStartInit(). Using c_eCiv5GamePlayDLL didn't seem to work, so I use c_eMPoolTypeUserStart + 0x500 to avoid conflicts.
This all goes well; dummyClass is instantiated, dummyInt is initially set to 1 and gets changed to 2 when gameStartInit runs and the pointer's reference persists after this. As soon as I add a dummy struct like the one below to the class, it refuses to instantiate properly. I've tried instantiating the struct with FNEW as well and it exhibits the same behavior.
I'm at a complete loss, and without being able to figure this out, the project I'm working on isn't worth continuing.
Specifically, I added a dummy class to CvPlayer in a separate header file:
Code:
class Dummy
{
public:
int dummyInt;
Dummy();
};
Dummy::Dummy()
{
dummyInt = 1;
}
CvPlayer.h
Code:
Dummy* dummyClass;
In CvPlayer.cpp::gameStartInit(). Using c_eCiv5GamePlayDLL didn't seem to work, so I use c_eMPoolTypeUserStart + 0x500 to avoid conflicts.
Code:
dummyClass = FNEW(Dummy(), c_eMPoolTypeUserStart + 0x500, 0);
dummyClass->dummyInt = 2;
This all goes well; dummyClass is instantiated, dummyInt is initially set to 1 and gets changed to 2 when gameStartInit runs and the pointer's reference persists after this. As soon as I add a dummy struct like the one below to the class, it refuses to instantiate properly. I've tried instantiating the struct with FNEW as well and it exhibits the same behavior.
Code:
struct dummyStruct
{
int dummyStructInt;
};
dummyStruct newDummyStruct;
Code:
Dummy::Dummy()
{
dummyInt = 1;
newDummyStruct.dummyStructInt = 2;
}
I'm at a complete loss, and without being able to figure this out, the project I'm working on isn't worth continuing.