- cleanup of voxel init code.

The voxreserve array was never properly set up so it is gone now.
nextvoxid now gets set right before loading .def files.
This commit is contained in:
Christoph Oelckers 2022-12-08 18:42:42 +01:00
parent 8a789b9015
commit c34756e5f2
6 changed files with 12 additions and 16 deletions

View file

@ -855,21 +855,20 @@ static int lastvoxid = -1;
void parseDefineVoxel(FScanner& sc, FScriptPosition& pos)
{
sc.MustGetString();
while (nextvoxid < MAXVOXELS && voxreserve[nextvoxid]) nextvoxid++;
if (nextvoxid == MAXVOXELS)
if (tbuild->nextvoxid == MAXVOXELS)
{
pos.Message(MSG_ERROR, "Maximum number of voxels (%d) already defined.", MAXVOXELS);
return;
}
if (voxDefine(nextvoxid, sc.String))
if (voxDefine(tbuild->nextvoxid, sc.String))
{
pos.Message(MSG_ERROR, "Unable to load voxel file \"%s\"", sc.String);
return;
}
lastvoxid = nextvoxid++;
lastvoxid = tbuild->nextvoxid++;
}
//===========================================================================
@ -908,20 +907,18 @@ void parseVoxel(FScanner& sc, FScriptPosition& pos)
if (!sc.GetString(fn)) return;
while (nextvoxid < MAXVOXELS && voxreserve[nextvoxid]) nextvoxid++;
if (nextvoxid == MAXVOXELS)
if (tbuild->nextvoxid == MAXVOXELS)
{
pos.Message(MSG_ERROR, "Maximum number of voxels (%d) already defined.", MAXVOXELS);
error = true;
}
else if (voxDefine(nextvoxid, fn))
else if (voxDefine(tbuild->nextvoxid, fn))
{
pos.Message(MSG_ERROR, "Unable to load voxel file \"%s\"", fn.GetChars());
error = true;
}
int lastvoxid = nextvoxid++;
int lastvoxid = tbuild->nextvoxid++;
if (sc.StartBraces(&blockend)) return;
while (!sc.FoundEndBrace(blockend))

View file

@ -22,9 +22,6 @@ extern float voxscale[];
extern voxmodel_t* voxmodels[MAXVOXELS];
extern FixedBitArray<MAXVOXELS> voxrotate;
inline int32_t nextvoxid;
inline FixedBitArray<MAXVOXELS>voxreserve;
void voxInit();
void voxClear();
int voxDefine(int voxindex, const char* filename);

View file

@ -100,6 +100,11 @@ CCMD(tilecrc)
static void LoadDefinitions(TilesetBuildInfo& info)
{
for (unsigned i = 0; i < info.tile.Size(); i++)
{
if (info.tile[i].extinfo.tiletovox > info.nextvoxid) info.nextvoxid = info.tile[i].extinfo.tiletovox;
}
info.nextvoxid++;
const char* defsfile = G_DefFile();
FString razedefsfile = defsfile;
razedefsfile.Substitute(".def", "-raze.def");

View file

@ -22,6 +22,7 @@ struct TilesetBuildInfo
TArray<TileBuildDesc> tile;
unsigned maxtileofart;
TArray <std::pair<FName, int>> aliases;
int32_t nextvoxid;
void addName(const char* name, int index)
{
aliases.Push(std::make_pair(name, index));

View file

@ -86,7 +86,6 @@ void GameInterface::LoadTextureInfo(TilesetBuildInfo& info)
{
info.tile[i].extinfo.tiletovox = voxindex;
}
if (nextvoxid <= voxindex) nextvoxid = voxindex + 1;
}
}
hFile = fileSystem.OpenFileReader("SHADE.DAT");

View file

@ -220,9 +220,6 @@ void LoadKVXFromScript(TilesetBuildInfo& info, const char* filename)
{
info.tile[lTile].extinfo.tiletovox = lNumber;
}
if (lNumber >= nextvoxid) // JBF: so voxels in the def file append to the list
nextvoxid = lNumber + 1;
}
while (script_p < scriptend_p);