home
·
contact
·
privacy
projects
/
plomrogue
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b8783b7
)
Check for existence of server config files.
author
Christian Heller
<c.heller@plomlompom.de>
Tue, 28 Jan 2014 06:10:31 +0000
(07:10 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Tue, 28 Jan 2014 06:10:31 +0000
(07:10 +0100)
src/server/main.c
patch
|
blob
|
history
src/server/map_object_actions.c
patch
|
blob
|
history
src/server/map_object_actions.h
patch
|
blob
|
history
src/server/map_objects.c
patch
|
blob
|
history
src/server/map_objects.h
patch
|
blob
|
history
src/server/world.h
patch
|
blob
|
history
diff --git
a/src/server/main.c
b/src/server/main.c
index 09ce530dea96033af7c0fec03829bb72b2fdf74e..0384ada9cda8e7519a18b5345828b466f5e417f7 100644
(file)
--- a/
src/server/main.c
+++ b/
src/server/main.c
@@
-41,12
+41,20
@@
int main(int argc, char ** argv)
exit_err(-1 == test, printf_err);
}
}
exit_err(-1 == test, printf_err);
}
}
+ world.path_map_obj_defs = "confserver/defs";
+ world.path_map_obj_acts = "confserver/map_object_actions";
world.path_in = "server/in";
world.path_out = "server/out";
world.path_record = "record";
world.tmp_suffix = "_tmp";
set_err_try_fgets_delim("%%\n");
world.path_in = "server/in";
world.path_out = "server/out";
world.path_record = "record";
world.tmp_suffix = "_tmp";
set_err_try_fgets_delim("%%\n");
+ /* Check existence of config files. */
+ char * err_mod = "No map object definitions file.";
+ char * err_moa = "No map object actions file.";
+ exit_err(access(world.path_map_obj_defs, F_OK), err_mod);
+ exit_err(access(world.path_map_obj_acts, F_OK), err_moa);
+
/* Treat world.path_in file as server process lock file. */
char * err = "Found pre-existing input fifo file. This indicates another "
"roguelike-server may be running. It should be killed first.";
/* Treat world.path_in file as server process lock file. */
char * err = "Found pre-existing input fifo file. This indicates another "
"roguelike-server may be running. It should be killed first.";
@@
-57,8
+65,8
@@
int main(int argc, char ** argv)
set_cleanup_flag(CLEANUP_FIFO);
/* Init from config files map object (action) definitions. */
set_cleanup_flag(CLEANUP_FIFO);
/* Init from config files map object (action) definitions. */
- init_map_object_defs(
"confserver/defs"
);
- init_map_object_actions(
"confserver/map_object_actions"
);
+ init_map_object_defs();
+ init_map_object_actions();
/* Enter play or replay mode loops, then leave properly. */
run_game();
/* Enter play or replay mode loops, then leave properly. */
run_game();
diff --git
a/src/server/map_object_actions.c
b/src/server/map_object_actions.c
index 476ba91e26b2c09fff5c46e0e0746183eaaaf2f6..561a2e2bf39a5899c6d1e2e54ac4dd6486ac1160 100644
(file)
--- a/
src/server/map_object_actions.c
+++ b/
src/server/map_object_actions.c
@@
-219,10
+219,10
@@
static void playerbonus_use(uint8_t no_object, uint8_t wrong_object)
-extern void init_map_object_actions(
char * path
)
+extern void init_map_object_actions()
{
char * f_name = "init_map_object_actions()";
{
char * f_name = "init_map_object_actions()";
- FILE * file = try_fopen(
path
, "r", f_name);
+ FILE * file = try_fopen(
world.path_map_obj_acts
, "r", f_name);
uint16_t linemax = textfile_sizes(file, NULL);
char line[linemax + 1];
struct MapObjAct ** moa_ptr_ptr = &world.map_obj_acts;
uint16_t linemax = textfile_sizes(file, NULL);
char line[linemax + 1];
struct MapObjAct ** moa_ptr_ptr = &world.map_obj_acts;
diff --git
a/src/server/map_object_actions.h
b/src/server/map_object_actions.h
index ae015e62f957abfff614d9b571b2d3356b04773a..983f1aabc35efaa9af04ac3705f17abc204620c8 100644
(file)
--- a/
src/server/map_object_actions.h
+++ b/
src/server/map_object_actions.h
@@
-24,8
+24,8
@@
struct MapObjAct
-/* Init MapObjAct chain at world.map_obj_acts
from file at "path"
. */
-extern void init_map_object_actions(
char * path
);
+/* Init MapObjAct chain at world.map_obj_acts. */
+extern void init_map_object_actions();
/* Free MapObjAct * chain starting at "moa". */
extern void free_map_object_actions(struct MapObjAct * moa);
/* Free MapObjAct * chain starting at "moa". */
extern void free_map_object_actions(struct MapObjAct * moa);
diff --git
a/src/server/map_objects.c
b/src/server/map_objects.c
index 05cfc9a841dfe6e5039c146b3de996f3ffaaafca..0401c76b4339f959b312a81950bef4125bd92182 100644
(file)
--- a/
src/server/map_objects.c
+++ b/
src/server/map_objects.c
@@
-101,13
+101,13
@@
static void add_map_object(uint8_t type)
-extern void init_map_object_defs(
char * filename
)
+extern void init_map_object_defs()
{
char * f_name = "init_map_object_defs()";
char * context = "Failed reading map object definitions file. ";
char * err_toolarge = "Value is too large.";
char * err_uniq = "Declaration of ID already used.";
{
char * f_name = "init_map_object_defs()";
char * context = "Failed reading map object definitions file. ";
char * err_toolarge = "Value is too large.";
char * err_uniq = "Declaration of ID already used.";
- FILE * file = try_fopen(
filename
, "r", f_name);
+ FILE * file = try_fopen(
world.path_map_obj_defs
, "r", f_name);
uint16_t linemax = textfile_sizes(file, NULL);
struct MapObjDef ** last_mod_ptr_ptr = &world.map_obj_defs;
char line[linemax + 1];
uint16_t linemax = textfile_sizes(file, NULL);
struct MapObjDef ** last_mod_ptr_ptr = &world.map_obj_defs;
char line[linemax + 1];
diff --git
a/src/server/map_objects.h
b/src/server/map_objects.h
index d5dc5b33f111f1f31d7a18b4a6692f96c69e6fe0..0796c3c02d4db02f476922ee5bb88d7622607b69 100644
(file)
--- a/
src/server/map_objects.h
+++ b/
src/server/map_objects.h
@@
-37,8
+37,8
@@
struct MapObjDef
-/* Initialize map object definitions chain
from file at path "filename"
. */
-extern void init_map_object_defs(
char * filename
);
+/* Initialize map object definitions chain. */
+extern void init_map_object_defs();
/* Free map object definitions chain starting at "mod_start". */
extern void free_map_object_defs(struct MapObjDef * mod_start);
/* Free map object definitions chain starting at "mod_start". */
extern void free_map_object_defs(struct MapObjDef * mod_start);
diff --git
a/src/server/world.h
b/src/server/world.h
index 56a5f282fa8592218846b3540616e3be190f8e67..3bea1f1cf4ce7a9e7084c2f3662515c7df6fbd95 100644
(file)
--- a/
src/server/world.h
+++ b/
src/server/world.h
@@
-24,6
+24,8
@@
struct World
char * path_in; /* Fifo to receive command messages. */
char * path_out; /* File to write the game state as visible to clients.*/
char * path_record; /* Record file from which to read the game history. */
char * path_in; /* Fifo to receive command messages. */
char * path_out; /* File to write the game state as visible to clients.*/
char * path_record; /* Record file from which to read the game history. */
+ char * path_map_obj_defs; /* path for map object definitions config file */
+ char * path_map_obj_acts; /* path for map object actions config file */
char * tmp_suffix; /* Appended to paths of files for their tmp versions. */
char * queue; /* Stores un-processed messages received via input fifo. */
uint32_t queue_size;/* Length of .queue sequence of \0-terminated strings.*/
char * tmp_suffix; /* Appended to paths of files for their tmp versions. */
char * queue; /* Stores un-processed messages received via input fifo. */
uint32_t queue_size;/* Length of .queue sequence of \0-terminated strings.*/