Revert "Fix the ACS unarchival crash"

This reverts commit b3ac501ff1.
This commit is contained in:
Eidolon 2025-09-16 16:55:08 -05:00
parent 898f69c2bd
commit 129883970a
2 changed files with 6 additions and 9 deletions

View file

@ -225,24 +225,21 @@ void Environment::loadModule(ACSVM::Module *module)
size_t lumpLen = 0;
std::vector<ACSVM::Byte> data;
I_Assert(name->i >= 0 && name->i < nummapheaders);
const lumpnum_t lumpnum = mapheaderinfo[name->i]->lumpnum;
if (lumpnum == LUMPERROR)
if (name->i == (size_t)LUMPERROR)
{
// No lump given for module.
throw ACSVM::ReadError("invalid lump");
}
lumpLen = W_LumpLength(lumpnum);
lumpLen = W_LumpLength(name->i);
if (W_IsLumpWad(lumpnum) == true || lumpLen == 0)
if (W_IsLumpWad(name->i) == true || lumpLen == 0)
{
CONS_Debug(DBG_SETUP, "Attempting to load ACS module from the BEHAVIOR lump of map '%s'...\n", name->s->str);
// The lump given is a virtual resource.
// Try to grab a BEHAVIOR lump from inside of it.
virtres_t *vRes = vres_GetMap(lumpnum);
virtres_t *vRes = vres_GetMap(name->i);
auto _ = srb2::finally([vRes]() { vres_Free(vRes); });
virtlump_t *vLump = vres_Find(vRes, "BEHAVIOR");
@ -264,7 +261,7 @@ void Environment::loadModule(ACSVM::Module *module)
ACSVM::Byte *lump = static_cast<ACSVM::Byte *>(Z_Calloc(lumpLen, PU_STATIC, nullptr));
auto _ = srb2::finally([lump]() { Z_Free(lump); });
W_ReadLump(lumpnum, lump);
W_ReadLump(name->i, lump);
data.insert(data.begin(), lump, lump + lumpLen);
}

View file

@ -153,7 +153,7 @@ void ACS_LoadLevelScripts(size_t mapID)
ACSVM::ModuleName name = ACSVM::ModuleName(
env->getString( mapheaderinfo[mapID]->lumpname ),
nullptr,
mapID
mapheaderinfo[mapID]->lumpnum
);
modules.push_back(env->getModule(name));