- changed thinker initialization to occur in a Construct function instead of the constructor itself.

This was done to ensure that this code only runs when the thinker itself is fully set up.
With a constructor there is no control about such things, if some common initialization needs to be done it has to be in the base constructor, but that makes the entire approach chosen here to ensure proper linking into the thinker chains impossible.
ZDoom originally did it that way, which resulted in a very inflexible system and required some awful hacks to let the serializer work with it - the corresponding bSerialOverride flag is now gone.

The only thinker class still having a constructor is DFraggleThinker, because it contains non-serializable data that needs to be initialized in a piece of code that always runs, regardless of whether the object is created explicitly or from a savegame.
This commit is contained in:
Christoph Oelckers 2019-01-27 13:08:54 +01:00
commit e7aa10b5c8
37 changed files with 234 additions and 326 deletions

View file

@ -43,11 +43,13 @@ IMPLEMENT_POINTERS_START(DFlashFader)
IMPLEMENT_POINTER(ForWho)
IMPLEMENT_POINTERS_END
DFlashFader::DFlashFader (float r1, float g1, float b1, float a1,
void DFlashFader::Construct (float r1, float g1, float b1, float a1,
float r2, float g2, float b2, float a2,
float time, AActor *who, bool terminate)
: TotalTics ((int)(time*TICRATE)), RemainingTics(TotalTics), ForWho (who)
{
TotalTics = (int)(time*TICRATE);
RemainingTics = TotalTics;
ForWho = who;
Blends[0][0]=r1; Blends[0][1]=g1; Blends[0][2]=b1; Blends[0][3]=a1;
Blends[1][0]=r2; Blends[1][1]=g2; Blends[1][2]=b2; Blends[1][3]=a2;
Terminate = terminate;