mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- split up FBehavior constructor to better be able to weed out broken ACS modules.
Please note that this WILL break old savegames from mods which put ACS sources or unrelated data in the ACS namespace!
This commit is contained in:
parent
50a3f8a3d2
commit
97e63b1319
2 changed files with 30 additions and 11 deletions
|
@ -1409,7 +1409,17 @@ FBehavior *FBehavior::StaticLoadModule (int lumpnum, FileReader *fr, int len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FBehavior (lumpnum, fr, len);
|
FBehavior * behavior = new FBehavior ();
|
||||||
|
if (behavior->Init(lumpnum, fr, len))
|
||||||
|
{
|
||||||
|
return behavior;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete behavior;
|
||||||
|
Printf("%s: invalid ACS module", Wads.GetLumpFullName(lumpnum));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FBehavior::StaticCheckAllGood ()
|
bool FBehavior::StaticCheckAllGood ()
|
||||||
|
@ -1668,11 +1678,8 @@ static int ParseLocalArrayChunk(void *chunk, ACSLocalArrays *arrays, int offset)
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
FBehavior::FBehavior()
|
||||||
{
|
{
|
||||||
BYTE *object;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
NumScripts = 0;
|
NumScripts = 0;
|
||||||
NumFunctions = 0;
|
NumFunctions = 0;
|
||||||
NumArrays = 0;
|
NumArrays = 0;
|
||||||
|
@ -1684,11 +1691,21 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
||||||
Chunks = NULL;
|
Chunks = NULL;
|
||||||
Data = NULL;
|
Data = NULL;
|
||||||
Format = ACS_Unknown;
|
Format = ACS_Unknown;
|
||||||
LumpNum = lumpnum;
|
LumpNum = -1;
|
||||||
memset (MapVarStore, 0, sizeof(MapVarStore));
|
memset (MapVarStore, 0, sizeof(MapVarStore));
|
||||||
ModuleName[0] = 0;
|
ModuleName[0] = 0;
|
||||||
FunctionProfileData = NULL;
|
FunctionProfileData = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FBehavior::Init(int lumpnum, FileReader * fr, int len)
|
||||||
|
{
|
||||||
|
BYTE *object;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
LumpNum = lumpnum;
|
||||||
|
|
||||||
// Now that everything is set up, record this module as being among the loaded modules.
|
// Now that everything is set up, record this module as being among the loaded modules.
|
||||||
// We need to do this before resolving any imports, because an import might (indirectly)
|
// We need to do this before resolving any imports, because an import might (indirectly)
|
||||||
// need to resolve exports in this module. The only things that can be exported are
|
// need to resolve exports in this module. The only things that can be exported are
|
||||||
|
@ -1699,7 +1716,6 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
||||||
// 1. If not, corrupt modules cause memory leaks
|
// 1. If not, corrupt modules cause memory leaks
|
||||||
// 2. Corrupt modules won't be reported when a level is being loaded if this function quits before
|
// 2. Corrupt modules won't be reported when a level is being loaded if this function quits before
|
||||||
// adding it to the list.
|
// adding it to the list.
|
||||||
LibraryID = StaticModules.Push (this) << LIBRARYID_SHIFT;
|
|
||||||
|
|
||||||
if (fr == NULL) len = Wads.LumpLength (lumpnum);
|
if (fr == NULL) len = Wads.LumpLength (lumpnum);
|
||||||
|
|
||||||
|
@ -1711,7 +1727,7 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
||||||
// has 24 bytes if it is completely empty. An empty SPTR chunk adds 8 bytes.)
|
// has 24 bytes if it is completely empty. An empty SPTR chunk adds 8 bytes.)
|
||||||
if (len < 32)
|
if (len < 32)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
object = new BYTE[len];
|
object = new BYTE[len];
|
||||||
|
@ -1727,7 +1743,7 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
||||||
if (object[0] != 'A' || object[1] != 'C' || object[2] != 'S')
|
if (object[0] != 'A' || object[1] != 'C' || object[2] != 'S')
|
||||||
{
|
{
|
||||||
delete[] object;
|
delete[] object;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (object[3])
|
switch (object[3])
|
||||||
|
@ -1743,8 +1759,9 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
delete[] object;
|
delete[] object;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
LibraryID = StaticModules.Push (this) << LIBRARYID_SHIFT;
|
||||||
|
|
||||||
if (fr == NULL)
|
if (fr == NULL)
|
||||||
{
|
{
|
||||||
|
@ -2135,6 +2152,7 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
DPrintf ("Loaded %d scripts, %d functions\n", NumScripts, NumFunctions);
|
DPrintf ("Loaded %d scripts, %d functions\n", NumScripts, NumFunctions);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FBehavior::~FBehavior ()
|
FBehavior::~FBehavior ()
|
||||||
|
|
|
@ -283,8 +283,9 @@ enum ACSFormat { ACS_Old, ACS_Enhanced, ACS_LittleEnhanced, ACS_Unknown };
|
||||||
class FBehavior
|
class FBehavior
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FBehavior (int lumpnum, FileReader * fr=NULL, int len=0);
|
FBehavior ();
|
||||||
~FBehavior ();
|
~FBehavior ();
|
||||||
|
bool Init(int lumpnum, FileReader * fr = NULL, int len = 0);
|
||||||
|
|
||||||
bool IsGood ();
|
bool IsGood ();
|
||||||
BYTE *FindChunk (DWORD id) const;
|
BYTE *FindChunk (DWORD id) const;
|
||||||
|
|
Loading…
Reference in a new issue