Merge remote-tracking branch 'origin/new_level_refactor' into HEAD

This commit is contained in:
Rachael Alexanderson 2019-02-06 08:05:45 -05:00
commit 0590de3be2
3 changed files with 35 additions and 25 deletions

View File

@ -3247,7 +3247,7 @@ const char *FBehavior::LookupString (uint32_t index, bool forprint) const
token.Substitute(" ", ""); token.Substitute(" ", "");
token.Truncate(5); token.Truncate(5);
FStringf label("TXT_ACS_%s_%d_%.5s", Level->MapName.GetChars(), index, token); FStringf label("TXT_ACS_%s_%d_%.5s", Level->MapName.GetChars(), index, token.GetChars());
auto p = GStrings[label]; auto p = GStrings[label];
if (p) return p; if (p) return p;
} }

View File

@ -351,7 +351,7 @@ static FStrifeDialogueNode *ReadRetailNode (FLevelLocals *Level, const char *nam
if (name) if (name)
{ {
FStringf label("$TXT_DLG_%s_d%d_%s", name, int(pos), TokenFromString(speech.Dialogue)); FStringf label("$TXT_DLG_%s_d%d_%s", name, int(pos), TokenFromString(speech.Dialogue).GetChars());
node->Dialogue = label; node->Dialogue = label;
} }
else else
@ -435,7 +435,7 @@ static FStrifeDialogueNode *ReadTeaserNode (FLevelLocals *Level, const char *nam
// Convert the rest of the data to our own internal format. // Convert the rest of the data to our own internal format.
if (name) if (name)
{ {
FStringf label("$TXT_DLG_%s_d%d_%s", name, pos, TokenFromString(speech.Dialogue)); FStringf label("$TXT_DLG_%s_d%d_%s", name, pos, TokenFromString(speech.Dialogue).GetChars());
node->Dialogue = label; node->Dialogue = label;
} }
else else
@ -545,7 +545,7 @@ static void ParseReplies (const char *name, int pos, FStrifeDialogueReply **repl
if (name) if (name)
{ {
FStringf label("$TXT_RPLY%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->Reply)); FStringf label("$TXT_RPLY%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->Reply).GetChars());
reply->Reply = label; reply->Reply = label;
} }
else else
@ -569,7 +569,7 @@ static void ParseReplies (const char *name, int pos, FStrifeDialogueReply **repl
{ {
if (name) if (name)
{ {
FStringf label("$TXT_RYES%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->Yes)); FStringf label("$TXT_RYES%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->Yes).GetChars());
reply->QuickYes = label; reply->QuickYes = label;
} }
else else
@ -581,7 +581,7 @@ static void ParseReplies (const char *name, int pos, FStrifeDialogueReply **repl
{ {
if (name && strncmp(rsp->No, "NO. ", 4)) // All 'no' nodes starting with 'NO.' won't ever be shown and they all contain broken text. if (name && strncmp(rsp->No, "NO. ", 4)) // All 'no' nodes starting with 'NO.' won't ever be shown and they all contain broken text.
{ {
FStringf label("$TXT_RNO%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->No)); FStringf label("$TXT_RNO%d_%s_d%d_%s", j, name, pos, TokenFromString(rsp->No).GetChars());
reply->QuickNo = label; reply->QuickNo = label;
} }
else else

View File

@ -180,6 +180,11 @@ IMPLEMENT_CLASS(DPolyobjInterpolation, false, false)
int FInterpolator::CountInterpolations () int FInterpolator::CountInterpolations ()
{ {
int count = 0;
for (DInterpolation *probe = Head; probe != nullptr; probe = probe->Next)
{
count++;
}
return count; return count;
} }
@ -191,7 +196,7 @@ int FInterpolator::CountInterpolations ()
void FInterpolator::UpdateInterpolations() void FInterpolator::UpdateInterpolations()
{ {
for (DInterpolation *probe = Head; probe != NULL; probe = probe->Next) for (DInterpolation *probe = Head; probe != nullptr; probe = probe->Next)
{ {
probe->UpdateInterpolation (); probe->UpdateInterpolation ();
} }
@ -206,10 +211,9 @@ void FInterpolator::UpdateInterpolations()
void FInterpolator::AddInterpolation(DInterpolation *interp) void FInterpolator::AddInterpolation(DInterpolation *interp)
{ {
interp->Next = Head; interp->Next = Head;
if (Head != NULL) Head->Prev = interp; if (Head != nullptr) Head->Prev = interp;
interp->Prev = nullptr; interp->Prev = nullptr;
Head = interp; Head = interp;
count++;
} }
//========================================================================== //==========================================================================
@ -227,12 +231,11 @@ void FInterpolator::RemoveInterpolation(DInterpolation *interp)
} }
else else
{ {
if (interp->Prev != NULL) interp->Prev->Next = interp->Next; if (interp->Prev != nullptr) interp->Prev->Next = interp->Next;
if (interp->Next != NULL) interp->Next->Prev = interp->Prev; if (interp->Next != nullptr) interp->Next->Prev = interp->Prev;
} }
interp->Next = nullptr; interp->Next = nullptr;
interp->Prev = nullptr; interp->Prev = nullptr;
count--;
} }
//========================================================================== //==========================================================================
@ -252,7 +255,7 @@ void FInterpolator::DoInterpolations(double smoothratio)
didInterp = true; didInterp = true;
DInterpolation *probe = Head; DInterpolation *probe = Head;
while (probe != NULL) while (probe != nullptr)
{ {
DInterpolation *next = probe->Next; DInterpolation *next = probe->Next;
probe->Interpolate(smoothratio); probe->Interpolate(smoothratio);
@ -271,7 +274,7 @@ void FInterpolator::RestoreInterpolations()
if (didInterp) if (didInterp)
{ {
didInterp = false; didInterp = false;
for (DInterpolation *probe = Head; probe != NULL; probe = probe->Next) for (DInterpolation *probe = Head; probe != nullptr; probe = probe->Next)
{ {
probe->Restore(); probe->Restore();
} }
@ -297,6 +300,7 @@ void FInterpolator::ClearInterpolations()
probe->Destroy(); probe->Destroy();
probe = next; probe = next;
} }
} }
FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FInterpolator *def) FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FInterpolator *def)
@ -304,7 +308,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FIn
if (arc.BeginObject(key)) if (arc.BeginObject(key))
{ {
arc("head", rs.Head) arc("head", rs.Head)
("count", rs.count)
.EndObject(); .EndObject();
} }
return arc; return arc;
@ -365,8 +368,10 @@ void DInterpolation::UnlinkFromMap()
void DInterpolation::Serialize(FSerializer &arc) void DInterpolation::Serialize(FSerializer &arc)
{ {
Super::Serialize(arc); Super::Serialize(arc);
arc("refcount", refcount); arc("refcount", refcount)
arc("level", Level); ("next", Next)
("prev", Prev)
("level", Level);
} }
//========================================================================== //==========================================================================
@ -421,6 +426,7 @@ void DSectorPlaneInterpolation::UnlinkFromMap()
attached[i]->DelRef(); attached[i]->DelRef();
} }
attached.Reset(); attached.Reset();
Super::UnlinkFromMap();
} }
//========================================================================== //==========================================================================
@ -492,6 +498,7 @@ void DSectorPlaneInterpolation::Interpolate(double smoothratio)
if (refcount == 0 && oldheight == bakheight) if (refcount == 0 && oldheight == bakheight)
{ {
UnlinkFromMap();
Destroy(); Destroy();
} }
else else
@ -576,6 +583,7 @@ void DSectorScrollInterpolation::UnlinkFromMap()
} }
sector = nullptr; sector = nullptr;
} }
Super::UnlinkFromMap();
} }
//========================================================================== //==========================================================================
@ -675,6 +683,7 @@ void DWallScrollInterpolation::UnlinkFromMap()
side->textures[part].interpolation = nullptr; side->textures[part].interpolation = nullptr;
side = nullptr; side = nullptr;
} }
Super::UnlinkFromMap();
} }
//========================================================================== //==========================================================================
@ -773,6 +782,7 @@ void DPolyobjInterpolation::UnlinkFromMap()
{ {
poly->interpolation = nullptr; poly->interpolation = nullptr;
} }
Super::UnlinkFromMap();
} }
//========================================================================== //==========================================================================
@ -872,7 +882,7 @@ void DPolyobjInterpolation::Serialize(FSerializer &arc)
DInterpolation *side_t::SetInterpolation(int position) DInterpolation *side_t::SetInterpolation(int position)
{ {
if (textures[position].interpolation == NULL) if (textures[position].interpolation == nullptr)
{ {
textures[position].interpolation = Create<DWallScrollInterpolation>(this, position); textures[position].interpolation = Create<DWallScrollInterpolation>(this, position);
} }
@ -889,7 +899,7 @@ DInterpolation *side_t::SetInterpolation(int position)
void side_t::StopInterpolation(int position) void side_t::StopInterpolation(int position)
{ {
if (textures[position].interpolation != NULL) if (textures[position].interpolation != nullptr)
{ {
textures[position].interpolation->DelRef(); textures[position].interpolation->DelRef();
} }
@ -903,7 +913,7 @@ void side_t::StopInterpolation(int position)
DInterpolation *sector_t::SetInterpolation(int position, bool attach) DInterpolation *sector_t::SetInterpolation(int position, bool attach)
{ {
if (interpolations[position] == NULL) if (interpolations[position] == nullptr)
{ {
DInterpolation *interp; DInterpolation *interp;
switch (position) switch (position)
@ -925,7 +935,7 @@ DInterpolation *sector_t::SetInterpolation(int position, bool attach)
break; break;
default: default:
return NULL; return nullptr;
} }
interpolations[position] = interp; interpolations[position] = interp;
} }
@ -942,7 +952,7 @@ DInterpolation *sector_t::SetInterpolation(int position, bool attach)
DInterpolation *FPolyObj::SetInterpolation() DInterpolation *FPolyObj::SetInterpolation()
{ {
if (interpolation != NULL) if (interpolation != nullptr)
{ {
interpolation->AddRef(); interpolation->AddRef();
} }
@ -963,7 +973,7 @@ DInterpolation *FPolyObj::SetInterpolation()
void FPolyObj::StopInterpolation() void FPolyObj::StopInterpolation()
{ {
if (interpolation != NULL) if (interpolation != nullptr)
{ {
interpolation->DelRef(); interpolation->DelRef();
} }