From d295186378b4e96f19274b973710248b6160943e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Feb 2017 00:16:14 +0100 Subject: [PATCH] - made all fields of in_anim_t script-safe (except for the texture pointer which will have to be replaced by a Texture ID. --- src/wi_stuff.cpp | 55 +++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index ebc022df8d..5bb1786655 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -198,23 +198,29 @@ public: // (which is why I have renamed this one!) // - static const int MAX_ANIMATION_FRAMES = 20; struct in_anim_t { int type; // Made an int so I can use '|' int period; // period in tics between animations - int nanims; // number of animation frames yahpt_t loc; // location of animation int data; // ALWAYS: n/a, RANDOM: period deviation (<256) - FTexture * p[MAX_ANIMATION_FRAMES]; // actual graphics for frames of animations + TArray frames; // actual graphics for frames of animations // following must be initialized to zero before use! int nexttic; // next value of bcnt (used in conjunction with period) int ctr; // next frame number to animate int state; // used by RANDOM and LEVEL when animating - char levelname[9]; - char levelname2[9]; + FString LevelName; + FString LevelName2; + + void Reset() + { + type = period = loc.x = loc.y = data = nexttic = ctr = state = 0; + LevelName = ""; + LevelName2 = ""; + frames.Clear(); + } }; TArray lnodes; @@ -414,7 +420,7 @@ public: FScanner sc(lumpnum); while (sc.GetString()) { - memset(&an,0,sizeof(an)); + an.Reset(); int caseval = sc.MustMatchString(WI_Cmd); switch(caseval) { @@ -479,15 +485,13 @@ public: case 10: // IfTravelling an.type = ANIM_IFTRAVELLING; sc.MustGetString(); - strncpy(an.levelname2, sc.String, 8); - an.levelname2[8] = 0; + an.LevelName2 = sc.String; goto readanimation; case 11: // IfNotTravelling an.type = ANIM_IFTRAVELLING; sc.MustGetString(); - strncpy(an.levelname2, sc.String, 8); - an.levelname2[8] = 0; + an.LevelName2 = sc.String; goto readanimation; case 14: // NoAutostartMap @@ -496,8 +500,7 @@ public: readanimation: sc.MustGetString(); - strncpy(an.levelname, sc.String, 8); - an.levelname[8] = 0; + an.LevelName = sc.String; sc.MustGetString(); caseval=sc.MustMatchString(WI_Cmd); @@ -527,15 +530,14 @@ public: if (!sc.CheckString("{")) { sc.MustGetString(); - an.p[an.nanims++] = TexMan[sc.String]; + an.frames.Push(TexMan[sc.String]); } else { while (!sc.CheckString("}")) { sc.MustGetString(); - if (an.nanims= a->nexttic) { - if (++a->ctr >= a->nanims) + if (++a->ctr >= (int)a->frames.Size()) { if (a->data==0) a->ctr = 0; else a->ctr--; @@ -647,42 +650,42 @@ public: switch (a->type & ANIM_CONDITION) { case ANIM_IFVISITED: - li = FindLevelInfo(a->levelname); + li = FindLevelInfo(a->LevelName); if (li == NULL || !(li->flags & LEVEL_VISITED)) continue; break; case ANIM_IFNOTVISITED: - li = FindLevelInfo(a->levelname); + li = FindLevelInfo(a->LevelName); if (li == NULL || (li->flags & LEVEL_VISITED)) continue; break; // StatCount means 'leaving' - everything else means 'entering'! case ANIM_IFENTERING: - if (state == StatCount || strnicmp(a->levelname, wbs->next, 8)) continue; + if (state == StatCount || strnicmp(a->LevelName, wbs->next, 8)) continue; break; case ANIM_IFNOTENTERING: - if (state != StatCount && !strnicmp(a->levelname, wbs->next, 8)) continue; + if (state != StatCount && !strnicmp(a->LevelName, wbs->next, 8)) continue; break; case ANIM_IFLEAVING: - if (state != StatCount || strnicmp(a->levelname, wbs->current, 8)) continue; + if (state != StatCount || strnicmp(a->LevelName, wbs->current, 8)) continue; break; case ANIM_IFNOTLEAVING: - if (state == StatCount && !strnicmp(a->levelname, wbs->current, 8)) continue; + if (state == StatCount && !strnicmp(a->LevelName, wbs->current, 8)) continue; break; case ANIM_IFTRAVELLING: - if (strnicmp(a->levelname2, wbs->current, 8) || strnicmp(a->levelname, wbs->next, 8)) continue; + if (strnicmp(a->LevelName2, wbs->current, 8) || strnicmp(a->LevelName, wbs->next, 8)) continue; break; case ANIM_IFNOTTRAVELLING: - if (!strnicmp(a->levelname2, wbs->current, 8) && !strnicmp(a->levelname, wbs->next, 8)) continue; + if (!strnicmp(a->LevelName2, wbs->current, 8) && !strnicmp(a->LevelName, wbs->next, 8)) continue; break; } if (a->ctr >= 0) - screen->DrawTexture(a->p[a->ctr], a->loc.x, a->loc.y, + screen->DrawTexture(a->frames[a->ctr], a->loc.x, a->loc.y, DTA_VirtualWidthF, animwidth, DTA_VirtualHeightF, animheight, TAG_DONE); } }