summaryrefslogtreecommitdiff
path: root/src/map/npc.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-01-25 09:43:09 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-01-25 10:14:44 -0800
commit34f0540da418b01dd4d49f6ecf72569d3cfecfdf (patch)
treebf7c4623b0d794e4db8c72b0906bb40807d62ba8 /src/map/npc.cpp
parent9a4c3a44476f3306a8deed8a836e8fbc25ceb55f (diff)
downloadtmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.gz
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.bz2
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.xz
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.zip
Implement unified config parsing (mostly)
Diffstat (limited to 'src/map/npc.cpp')
-rw-r--r--src/map/npc.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index f5a1f21..4a116b2 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -15,6 +15,7 @@
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
+#include "../common/config_parse.hpp"
#include "../common/db.hpp"
#include "../common/extract.hpp"
#include "../common/nullpo.hpp"
@@ -1711,8 +1712,9 @@ void npc_free(dumb_ptr<npc_data> nd)
* npc初期化
*------------------------------------------
*/
-int do_init_npc(void)
+bool do_init_npc(void)
{
+ bool rv = true;
// other fields unused
ev_tm_b.tm_min = -1;
ev_tm_b.tm_hour = -1;
@@ -1725,7 +1727,8 @@ int do_init_npc(void)
if (!fp.is_open())
{
PRINTF("file not found : %s\n", nsl);
- exit(1);
+ rv = false;
+ continue;
}
PRINTF("\rLoading NPCs [%d]: %-54s", npc_id - START_NPC_NUM,
nsl);
@@ -1737,14 +1740,13 @@ int do_init_npc(void)
ZString w4z;
lines++;
- if (!zline)
- continue;
- if (zline.startswith("//"))
+ if (is_comment(zline))
continue;
if (!extract(zline, record<'|', 3>(&w1, &w2, &w3, &w4x)) || !w1 || !w2 || !w3)
{
FPRINTF(stderr, "%s:%d: Broken script line: %s\n", nsl, lines, zline);
+ rv = false;
continue;
}
if (&*w4x.end() == &*zline.end())
@@ -1762,6 +1764,7 @@ int do_init_npc(void)
{
// "mapname" is not assigned to this server
FPRINTF(stderr, "%s:%d: Map not found: %s\n", nsl, lines, mapname);
+ rv = false;
continue;
}
}
@@ -1801,6 +1804,7 @@ int do_init_npc(void)
else
{
PRINTF("odd script line: %s\n", zline);
+ script_errors++;
}
}
fflush(stdout);
@@ -1811,8 +1815,7 @@ int do_init_npc(void)
if (script_errors)
{
PRINTF("Cowardly refusing to continue after %d errors\n", script_errors);
- abort();
+ rv = false;
}
-
- return 0;
+ return rv;
}