More-accurate NpcTbl.cpp variable arrangement

For some reason, the Linux debug data notes a 2000-line gap before
any declarations. Might be the SDL header or something.
This commit is contained in:
Clownacy 2020-01-07 20:58:46 +00:00
parent ce4373481b
commit 718cb714ee

View file

@ -9,67 +9,6 @@
#include "Generic.h" #include "Generic.h"
#include "NpcAct.h" #include "NpcAct.h"
NPC_TABLE *gNpcTable;
BOOL LoadNpcTable(const char *path)
{
FILE *fp;
int n;
int num;
size_t size;
size = GetFileSizeLong(path); // TODO - Investigate whether GetFileSizeLong actually returns an unsigned long or not
if (size == INVALID_FILE_SIZE)
return FALSE;
num = (int)(size / 0x18);
gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
if (gNpcTable == NULL)
return FALSE;
fp = fopen(path, "rb");
if (fp == NULL)
{
free(gNpcTable);
gNpcTable = NULL;
return FALSE;
}
for (n = 0; n < num; ++n) // bits
fread(&gNpcTable[n].bits, 2, 1, fp);
for (n = 0; n < num; ++n) // life
fread(&gNpcTable[n].life, 2, 1, fp);
for (n = 0; n < num; ++n) // surf
fread(&gNpcTable[n].surf, 1, 1, fp);
for (n = 0; n < num; ++n) // destroy_voice
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
for (n = 0; n < num; ++n) // hit_voice
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
for (n = 0; n < num; ++n) // size
fread(&gNpcTable[n].size, 1, 1, fp);
for (n = 0; n < num; ++n) // exp
fread(&gNpcTable[n].exp, 4, 1, fp);
for (n = 0; n < num; ++n) // damage
fread(&gNpcTable[n].damage, 4, 1, fp);
for (n = 0; n < num; ++n) // hit
fread(&gNpcTable[n].hit, 4, 1, fp);
for (n = 0; n < num; ++n) // view
fread(&gNpcTable[n].view, 4, 1, fp);
fclose(fp);
return TRUE;
}
void ReleaseNpcTable(void)
{
if (gNpcTable != NULL)
{
free(gNpcTable);
gNpcTable = NULL;
}
}
// Npc function table // Npc function table
const NPCFUNCTION gpNpcFuncTbl[361] = { const NPCFUNCTION gpNpcFuncTbl[361] = {
ActNpc000, ActNpc000,
@ -434,3 +373,64 @@ const NPCFUNCTION gpNpcFuncTbl[361] = {
ActNpc359, ActNpc359,
ActNpc360, ActNpc360,
}; };
NPC_TABLE *gNpcTable;
BOOL LoadNpcTable(const char *path)
{
FILE *fp;
int n;
size_t size;
int num;
size = GetFileSizeLong(path); // TODO - Investigate whether GetFileSizeLong actually returns an unsigned long or not
if (size == INVALID_FILE_SIZE)
return FALSE;
num = (int)(size / 0x18);
gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
if (gNpcTable == NULL)
return FALSE;
fp = fopen(path, "rb");
if (fp == NULL)
{
free(gNpcTable);
gNpcTable = NULL;
return FALSE;
}
for (n = 0; n < num; ++n) // bits
fread(&gNpcTable[n].bits, 2, 1, fp);
for (n = 0; n < num; ++n) // life
fread(&gNpcTable[n].life, 2, 1, fp);
for (n = 0; n < num; ++n) // surf
fread(&gNpcTable[n].surf, 1, 1, fp);
for (n = 0; n < num; ++n) // destroy_voice
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
for (n = 0; n < num; ++n) // hit_voice
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
for (n = 0; n < num; ++n) // size
fread(&gNpcTable[n].size, 1, 1, fp);
for (n = 0; n < num; ++n) // exp
fread(&gNpcTable[n].exp, 4, 1, fp);
for (n = 0; n < num; ++n) // damage
fread(&gNpcTable[n].damage, 4, 1, fp);
for (n = 0; n < num; ++n) // hit
fread(&gNpcTable[n].hit, 4, 1, fp);
for (n = 0; n < num; ++n) // view
fread(&gNpcTable[n].view, 4, 1, fp);
fclose(fp);
return TRUE;
}
void ReleaseNpcTable(void)
{
if (gNpcTable != NULL)
{
free(gNpcTable);
gNpcTable = NULL;
}
}