Clean-up NpcTbl.cpp
Also added a TODO
This commit is contained in:
parent
5987a5a8d7
commit
696df90d19
2 changed files with 21 additions and 22 deletions
|
@ -14,15 +14,15 @@ NPC_TABLE *gNpcTable;
|
||||||
BOOL LoadNpcTable(const char *path)
|
BOOL LoadNpcTable(const char *path)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
long n;
|
int n;
|
||||||
long num;
|
int num;
|
||||||
long size;
|
size_t size;
|
||||||
|
|
||||||
size = GetFileSizeLong(path);
|
size = GetFileSizeLong(path); // TODO - Investigate whether GetFileSizeLong actually returns an unsigned long or not
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
num = size / 0x18;
|
num = (int)(size / 0x18);
|
||||||
|
|
||||||
gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
|
gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
|
||||||
if (gNpcTable == NULL)
|
if (gNpcTable == NULL)
|
||||||
|
@ -36,34 +36,34 @@ BOOL LoadNpcTable(const char *path)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = 0; n < num; n++) // bits
|
for (n = 0; n < num; ++n) // bits
|
||||||
fread(&gNpcTable[n].bits, 2, 1, fp);
|
fread(&gNpcTable[n].bits, 2, 1, fp);
|
||||||
for (n = 0; n < num; n++) // life
|
for (n = 0; n < num; ++n) // life
|
||||||
fread(&gNpcTable[n].life, 2, 1, fp);
|
fread(&gNpcTable[n].life, 2, 1, fp);
|
||||||
for (n = 0; n < num; n++) // surf
|
for (n = 0; n < num; ++n) // surf
|
||||||
fread(&gNpcTable[n].surf, 1, 1, fp);
|
fread(&gNpcTable[n].surf, 1, 1, fp);
|
||||||
for (n = 0; n < num; n++) // destroy_voice
|
for (n = 0; n < num; ++n) // destroy_voice
|
||||||
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
|
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
|
||||||
for (n = 0; n < num; n++) // hit_voice
|
for (n = 0; n < num; ++n) // hit_voice
|
||||||
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
|
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
|
||||||
for (n = 0; n < num; n++) // size
|
for (n = 0; n < num; ++n) // size
|
||||||
fread(&gNpcTable[n].size, 1, 1, fp);
|
fread(&gNpcTable[n].size, 1, 1, fp);
|
||||||
for (n = 0; n < num; n++) // exp
|
for (n = 0; n < num; ++n) // exp
|
||||||
fread(&gNpcTable[n].exp, 4, 1, fp);
|
fread(&gNpcTable[n].exp, 4, 1, fp);
|
||||||
for (n = 0; n < num; n++) // damage
|
for (n = 0; n < num; ++n) // damage
|
||||||
fread(&gNpcTable[n].damage, 4, 1, fp);
|
fread(&gNpcTable[n].damage, 4, 1, fp);
|
||||||
for (n = 0; n < num; n++) // hit
|
for (n = 0; n < num; ++n) // hit
|
||||||
fread(&gNpcTable[n].hit, 4, 1, fp);
|
fread(&gNpcTable[n].hit, 4, 1, fp);
|
||||||
for (n = 0; n < num; n++) // view
|
for (n = 0; n < num; ++n) // view
|
||||||
fread(&gNpcTable[n].view, 4, 1, fp);
|
fread(&gNpcTable[n].view, 4, 1, fp);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseNpcTable()
|
void ReleaseNpcTable(void)
|
||||||
{
|
{
|
||||||
if (gNpcTable)
|
if (gNpcTable != NULL)
|
||||||
{
|
{
|
||||||
free(gNpcTable);
|
free(gNpcTable);
|
||||||
gNpcTable = NULL;
|
gNpcTable = NULL;
|
||||||
|
@ -71,8 +71,7 @@ void ReleaseNpcTable()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Npc function table
|
// Npc function table
|
||||||
NPCFUNCTION gpNpcFuncTbl[361] =
|
const NPCFUNCTION gpNpcFuncTbl[361] = {
|
||||||
{
|
|
||||||
ActNpc000,
|
ActNpc000,
|
||||||
ActNpc001,
|
ActNpc001,
|
||||||
ActNpc002,
|
ActNpc002,
|
||||||
|
|
|
@ -29,8 +29,8 @@ struct NPC_TABLE
|
||||||
extern NPC_TABLE *gNpcTable;
|
extern NPC_TABLE *gNpcTable;
|
||||||
|
|
||||||
BOOL LoadNpcTable(const char *path);
|
BOOL LoadNpcTable(const char *path);
|
||||||
void ReleaseNpcTable();
|
void ReleaseNpcTable(void);
|
||||||
|
|
||||||
//NPC Function table
|
// NPC Function table
|
||||||
typedef void (*NPCFUNCTION)(NPCHAR*);
|
typedef void (*NPCFUNCTION)(NPCHAR*);
|
||||||
extern NPCFUNCTION gpNpcFuncTbl[];
|
extern const NPCFUNCTION gpNpcFuncTbl[];
|
||||||
|
|
Loading…
Add table
Reference in a new issue