Decompile mapLocalVariablesInit

This commit is contained in:
Alexander Batalov 2022-09-15 18:19:50 +03:00
parent d72a74f6c3
commit 0adc65054c
1 changed files with 25 additions and 10 deletions

View File

@ -53,6 +53,7 @@ static void isoWindowRefreshRectMapper(Rect* rect);
static int mapGlobalVariablesInit(int count);
static void mapGlobalVariablesFree();
static int mapGlobalVariablesLoad(File* stream);
static int mapLocalVariablesInit(int count);
static void mapLocalVariablesFree();
static void _map_place_dude_and_mouse();
static void _square_reset();
@ -833,18 +834,13 @@ static int mapLoad(File* stream)
goto err;
}
error = "Error loading local vars";
mapLocalVariablesFree();
if (gMapHeader.localVariablesCount != 0) {
gMapLocalVars = (int*)internal_malloc(sizeof(*gMapLocalVars) * gMapHeader.localVariablesCount);
if (gMapLocalVars == NULL) {
error = "Error allocating local vars";
// NOTE: Uninline.
if (mapLocalVariablesInit(gMapHeader.localVariablesCount) != 0) {
goto err;
}
gMapLocalVarsLength = gMapHeader.localVariablesCount;
}
error = "Error loading local vars";
if (fileReadInt32List(stream, gMapLocalVars, gMapLocalVarsLength) != 0) {
goto err;
}
@ -1539,6 +1535,25 @@ static int mapGlobalVariablesLoad(File* stream)
return 0;
}
// NOTE: Inlined.
//
// 0x484080
static int mapLocalVariablesInit(int count)
{
mapLocalVariablesFree();
if (count != 0) {
gMapLocalVars = (int*)internal_malloc(sizeof(*gMapLocalVars) * count);
if (gMapLocalVars == NULL) {
return -1;
}
}
gMapLocalVarsLength = count;
return 0;
}
// 0x4840D4
static void mapLocalVariablesFree()
{