Skip to content

Commit

Permalink
- added validation of LevelCompatibility.Apply() signature
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Jul 3, 2019
1 parent bc88cee commit 73f4608
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/maploader/compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "actor.h"
#include "p_setup.h"
#include "maploader/maploader.h"
#include "types.h"

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -365,11 +366,21 @@ void MapLoader::SetCompatibilityParams(FName checksum)
if (cls->IsDescendantOf(RUNTIME_CLASS(DLevelCompatibility)))
{
PFunction *const func = dyn_cast<PFunction>(cls->FindSymbol("Apply", false));
if (func != nullptr)
if (func == nullptr)
{
VMValue param[] = { lc, checksum.GetIndex(), &Level->MapName };
VMCall(func->Variants[0].Implementation, param, 3, nullptr, 0);
Printf("Missing 'Apply' method in class '%s', level compatibility object ignored\n", cls->TypeName.GetChars());
continue;
}

auto argTypes = func->Variants[0].Proto->ArgumentTypes;
if (argTypes.Size() != 3 || argTypes[1] != TypeName || argTypes[2] != TypeString)
{
Printf("Wrong signature of 'Apply' method in class '%s', level compatibility object ignored\n", cls->TypeName.GetChars());
continue;
}

VMValue param[] = { lc, checksum.GetIndex(), &Level->MapName };
VMCall(func->Variants[0].Implementation, param, 3, nullptr, 0);
}
}
}
Expand Down

0 comments on commit 73f4608

Please sign in to comment.