ref: 4998dfa0083e28680e5baf722f4a8a95b355c479
parent: 9ed2cdc9f1106681a24acd0f12f2e20a8821d59b
parent: 008c7054a906f0da0fe96328d65775f545471375
author: Gabriel Ravier <[email protected]>
date: Wed May 8 06:43:53 EDT 2019
Merge branch 'master' of https://github.com/GabrielRavier/Cave-Story-Engine-2
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
# Exclude obj directory (object files for Makefile build)
/obj
-# Exclude the converted resource files
+# Exclude converted resource files
src/Resource
# Exclude .dat and .rec files in build directories (avoid Config.dat, 290.rec and others)
@@ -14,19 +14,19 @@
msvc2003/devilution/orig.asm
msvc2003/devilution/compare.asm
-# Exclude build output on Linux (exclude normally produced executable files)
+# Exclude build output on Linux (exclude normally produced executable files and out files)
build_en/CSE2
build_en/CSE2d
build_en/DoConfig
build_en/DoConfigd
-
build_jp/CSE2
build_jp/CSE2d
build_jp/DoConfig
build_jp/DoConfigd
+build_en/*.out
+build_jp/*.out
-
-# Exclude executables in the build folder (and .exe.manifest files)
+# Exclude PE executables in the build folder (and .exe.manifest files)
build_en/*.exe
build_en/*.exe.manifest
build_jp/*.exe
@@ -46,12 +46,3 @@
msvc2003/Release
msvc2003/Debug (Japanese)
msvc2003/Release (Japanese)
-
-# Exclude VS Code folder
-.vscode/*
-
-# Include generically useful files for VS Code users
-!.vscode/settings.json
-!.vscode/tasks.json
-!.vscode/launch.json
-!.vscode/extensions.json
--- a/msvc2003/devilution/comparer-config.toml
+++ b/msvc2003/devilution/comparer-config.toml
@@ -2127,6 +2127,14 @@
addr = 0x46EA90
[[func]]
+name = "LoadNpcTable"
+addr = 0x472400
+
+[[func]]
+name = "ReleaseNpcTable"
+addr = 0x472710
+
+[[func]]
name = "InitBossChar"
addr = 0x472740
--- a/src/NpcTbl.cpp
+++ b/src/NpcTbl.cpp
@@ -1,9 +1,12 @@
#include "NpcTbl.h"
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "WindowsWrapper.h"
+
#include "File.h"
#include "Generic.h"
#include "NpcAct.h"
@@ -10,51 +13,86 @@
NPC_TABLE *gNpcTable;
-bool LoadNpcTable(const char *path)
+BOOL LoadNpcTable(const char *path)
{
- const long size = GetFileSizeLong(path);
+ FILE *fp;
+ long n;
+ long num;
+ unsigned long size;
+
+ size = GetFileSizeLong(path);
if (size == -1)
- return false;
+ return FALSE;
- const long num = size / 0x18;
+ num = size / 0x18;
gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
if (gNpcTable == NULL)
- return false;
+ return FALSE;
- FILE *fp = fopen(path, "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
- return false;
+ {
+ free(gNpcTable);
+ gNpcTable = NULL;
+ return FALSE;
+ }
- for (long n = 0; n < num; n++) //bits
+#ifdef NONPORTABLE
+ 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);
+#else
+ for (n = 0; n < num; n++) //bits
gNpcTable[n].bits = File_ReadLE16(fp);
- for (long n = 0; n < num; n++) //life
+ for (n = 0; n < num; n++) //life
gNpcTable[n].life = File_ReadLE16(fp);
- for (long n = 0; n < num; n++) //surf
+ for (n = 0; n < num; n++) //surf
fread(&gNpcTable[n].surf, 1, 1, fp);
- for (long n = 0; n < num; n++) //destroy_voice
+ for (n = 0; n < num; n++) //destroy_voice
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
- for (long n = 0; n < num; n++) //hit_voice
+ for (n = 0; n < num; n++) //hit_voice
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
- for (long n = 0; n < num; n++) //size
+ for (n = 0; n < num; n++) //size
fread(&gNpcTable[n].size, 1, 1, fp);
- for (long n = 0; n < num; n++) //exp
+ for (n = 0; n < num; n++) //exp
gNpcTable[n].exp = File_ReadLE32(fp);
- for (long n = 0; n < num; n++) //damage
+ for (n = 0; n < num; n++) //damage
gNpcTable[n].damage = File_ReadLE32(fp);
- for (long n = 0; n < num; n++) //hit
+ for (n = 0; n < num; n++) //hit
fread(&gNpcTable[n].hit, 4, 1, fp);
- for (long n = 0; n < num; n++) //view
+ for (n = 0; n < num; n++) //view
fread(&gNpcTable[n].view, 4, 1, fp);
+#endif
fclose(fp);
- return true;
+ return TRUE;
}
void ReleaseNpcTable()
{
if (gNpcTable)
+ {
free(gNpcTable);
+ gNpcTable = NULL;
+ }
}
//Npc function table
--- a/src/NpcTbl.h
+++ b/src/NpcTbl.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "WindowsWrapper.h"
+
#include "Draw.h"
#include "NpChar.h"
@@ -29,7 +31,7 @@
extern NPC_TABLE *gNpcTable;
-bool LoadNpcTable(const char *path);
+BOOL LoadNpcTable(const char *path);
void ReleaseNpcTable();
//NPC Function table