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:
87aec00
)
Server: Make config file define to which map object type player belongs.
author
Christian Heller
<c.heller@plomlompom.de>
Mon, 14 Apr 2014 03:38:11 +0000
(
05:38
+0200)
committer
Christian Heller
<c.heller@plomlompom.de>
Mon, 14 Apr 2014 03:38:11 +0000
(
05:38
+0200)
TODO
patch
|
blob
|
history
confserver/world
patch
|
blob
|
history
src/server/configfile.c
patch
|
blob
|
history
src/server/init.c
patch
|
blob
|
history
src/server/init.h
patch
|
blob
|
history
src/server/world.h
patch
|
blob
|
history
diff --git
a/TODO
b/TODO
index 58a6a6b60e95bdfb8fe4c1e355c7a1035d995fdb..e80f6d7de8231ccb04415f9f07fcc60b2d9a5339 100644
(file)
--- a/
TODO
+++ b/
TODO
@@
-20,8
+20,6
@@
SERVER:
- why does an MapObjAct id of 0 fail?
- why does an MapObjAct id of 0 fail?
-- make config file define to which map object type the player belongs
-
CLIENT:
- enable toggling of window borders
CLIENT:
- enable toggling of window borders
diff --git
a/confserver/world
b/confserver/world
index 16e86cb3a89d5938b25afa94f66cc9419d9e43a6..aeae5bd7c35c72e1c636730110d6566023208a57 100644
(file)
--- a/
confserver/world
+++ b/
confserver/world
@@
-4,6
+4,8
@@
WIDTH 64
DIST_ORTHOGONAL 5
DIST_DIAGONAL 7
DIST_ORTHOGONAL 5
DIST_DIAGONAL 7
+PLAYER_TYPE 0
+
ACTION 1
NAME wait
EFFORT 1
ACTION 1
NAME wait
EFFORT 1
diff --git
a/src/server/configfile.c
b/src/server/configfile.c
index ab368b0ea65ad1496caac6397a516c005679ff34..aad3b7417e6f53823f91258dcd38759f5603d07a 100644
(file)
--- a/
src/server/configfile.c
+++ b/
src/server/configfile.c
@@
-15,8
+15,8
@@
#include "cleanup.h" /* set_cleanup_flag(), CLEANUP_MAP_OBJ_DEFS,
* CLEANUP_MAP_OBJ_ACTS
*/
#include "cleanup.h" /* set_cleanup_flag(), CLEANUP_MAP_OBJ_DEFS,
* CLEANUP_MAP_OBJ_ACTS
*/
-#include "map_object_actions.h" /*
struct
MapObjAct */
-#include "map_objects.h" /*
struct MapObj
, struct MapObjDef */
+#include "map_object_actions.h" /* MapObjAct */
+#include "map_objects.h" /*
MapObj, MapObjDef
, struct MapObjDef */
#include "world.h" /* world global */
#include "world.h" /* world global */
@@
-92,6
+92,9
@@
static void write_if_entry(struct EntryHead ** entry,
*/
static void test_corpse_ids();
*/
static void test_corpse_ids();
+/* If "token0" matches "comparand", set world.player_type to int in "token1". */
+static uint8_t set_player_type(char * token0, char * comparand, char * token1);
+
/* Try to read tokens as members for the definition currently edited, which may
* be "mod" or "moa" or that of world.map. What member of which of the three is
* set depends on which of the flags has EDIT_STARTED set and on the key name in
/* Try to read tokens as members for the definition currently edited, which may
* be "mod" or "moa" or that of world.map. What member of which of the three is
* set depends on which of the flags has EDIT_STARTED set and on the key name in
@@
-119,6
+122,7
@@
static void tokens_into_entries(char * token0, char * token1)
char * str_act = "ACTION";
char * str_obj = "OBJECT";
char * str_map = "MAP_TYPE";
char * str_act = "ACTION";
char * str_obj = "OBJECT";
char * str_map = "MAP_TYPE";
+ char * str_player = "PLAYER_TYPE";
static struct MapObjAct ** moa_p_p = &world.map_obj_acts;
static struct MapObjDef ** mod_p_p = &world.map_obj_defs;
static uint8_t action_flags = READY_ACT;
static struct MapObjAct ** moa_p_p = &world.map_obj_acts;
static struct MapObjDef ** mod_p_p = &world.map_obj_defs;
static uint8_t action_flags = READY_ACT;
@@
-127,7
+131,7
@@
static void tokens_into_entries(char * token0, char * token1)
static struct EntryHead * moa = NULL;
static struct EntryHead * mod = NULL;
if (!token0 || !strcmp(token0, str_act) || !strcmp(token0, str_obj)
static struct EntryHead * moa = NULL;
static struct EntryHead * mod = NULL;
if (!token0 || !strcmp(token0, str_act) || !strcmp(token0, str_obj)
- || !strcmp(token0, str_map))
+ || !strcmp(token0, str_map)
|| !strcmp(token0, str_player)
)
{
parse_and_reduce_to_readyflag(&action_flags, READY_ACT);
parse_and_reduce_to_readyflag(&object_flags, READY_OBJ);
{
parse_and_reduce_to_readyflag(&action_flags, READY_ACT);
parse_and_reduce_to_readyflag(&object_flags, READY_OBJ);
@@
-145,6
+149,7
@@
static void tokens_into_entries(char * token0, char * token1)
sizeof(struct MapObjDef),(struct EntryHead**) &mod,
(struct EntryHead *) world.map_obj_defs)
|| start_map(token0, str_map, &map_flags)
sizeof(struct MapObjDef),(struct EntryHead**) &mod,
(struct EntryHead *) world.map_obj_defs)
|| start_map(token0, str_map, &map_flags)
+ || set_player_type(token0, str_player, token1)
|| set_members(token0, token1, &object_flags, &action_flags,
&map_flags, (struct MapObjDef *)mod,
(struct MapObjAct *) moa)))
|| set_members(token0, token1, &object_flags, &action_flags,
&map_flags, (struct MapObjDef *)mod,
(struct MapObjAct *) moa)))
@@
-244,9
+249,9
@@
static uint8_t set_map_members(char * token0, char * token1, uint8_t * map_flags
return 1;
}
else if ( parse_val(token0, token1, "DIST_ORTHOGONAL", map_flags,
return 1;
}
else if ( parse_val(token0, token1, "DIST_ORTHOGONAL", map_flags,
- ORTH_SET, '8', (char *) &world.map.dist_orthogonal)
+
ORTH_SET, '8', (char *) &world.map.dist_orthogonal)
|| parse_val(token0, token1, "DIST_DIAGONAL", map_flags,
|| parse_val(token0, token1, "DIST_DIAGONAL", map_flags,
- DIAG_SET, '8', (char *) &world.map.dist_diagonal))
+
DIAG_SET, '8', (char *) &world.map.dist_diagonal))
{
err_line(0 == atoi(token1), "Value must not be zero.");
return 1;
{
err_line(0 == atoi(token1), "Value must not be zero.");
return 1;
@@
-256,6
+261,19
@@
static uint8_t set_map_members(char * token0, char * token1, uint8_t * map_flags
+static uint8_t set_player_type(char * token0, char * comparand, char * token1)
+{
+ if (strcmp(token0, comparand))
+ {
+ return 0;
+ }
+ parsetest_int(token1, '8');
+ world.player_type = atoi(token1);
+ return 1;
+}
+
+
+
static uint8_t set_members(char * token0, char * token1, uint8_t * object_flags,
uint8_t * action_flags, uint8_t * map_flags,
struct MapObjDef * mod, struct MapObjAct * moa)
static uint8_t set_members(char * token0, char * token1, uint8_t * object_flags,
uint8_t * action_flags, uint8_t * map_flags,
struct MapObjDef * mod, struct MapObjAct * moa)
@@
-314,6
+332,17
@@
extern void read_config_file()
{
parse_file(world.path_config, tokens_into_entries);
exit_err(!world.map.size.y, "Map not defined in config file.");
{
parse_file(world.path_config, tokens_into_entries);
exit_err(!world.map.size.y, "Map not defined in config file.");
+ uint8_t player_type_is_valid = 0;
+ struct MapObjDef * mod;
+ for (mod = world.map_obj_defs; NULL != mod; mod = mod->next)
+ {
+ if (world.player_type == mod->id)
+ {
+ player_type_is_valid = 1;
+ break;
+ }
+ }
+ exit_err(!player_type_is_valid, "No valid map object type set for player.");
set_cleanup_flag(CLEANUP_MAP_OBJECT_ACTS | CLEANUP_MAP_OBJECT_DEFS);
test_corpse_ids();
}
set_cleanup_flag(CLEANUP_MAP_OBJECT_ACTS | CLEANUP_MAP_OBJECT_DEFS);
test_corpse_ids();
}
diff --git
a/src/server/init.c
b/src/server/init.c
index 2f6428e99c283e7fe192aa3e7399224bf63fd561..89eea4f8844d1ee64f9ee243a2002ce67b8f1728 100644
(file)
--- a/
src/server/init.c
+++ b/
src/server/init.c
@@
-89,7
+89,18
@@
extern void remake_world(uint32_t seed)
struct MapObjDef * mod;
for (mod = world.map_obj_defs; NULL != mod; mod = mod->next)
{
struct MapObjDef * mod;
for (mod = world.map_obj_defs; NULL != mod; mod = mod->next)
{
- add_map_objects(mod->id, mod->start_n);
+ if (world.player_type == mod->id)
+ {
+ add_map_objects(mod->id, mod->start_n);
+ break;
+ }
+ }
+ for (mod = world.map_obj_defs; NULL != mod; mod = mod->next)
+ {
+ if (world.player_type != mod->id)
+ {
+ add_map_objects(mod->id, mod->start_n);
+ }
}
set_cleanup_flag(CLEANUP_MAP_OBJECTS);
if (world.turn)
}
set_cleanup_flag(CLEANUP_MAP_OBJECTS);
if (world.turn)
diff --git
a/src/server/init.h
b/src/server/init.h
index 1cc6706f4317f19f2ef757975940aca904c72c25..f99126c88aaadc5c06f73673dd568d1a5f0ea852 100644
(file)
--- a/
src/server/init.h
+++ b/
src/server/init.h
@@
-21,9
+21,9
@@
extern void setup_server_io();
* i.e. if called after iterating through an already established game world.
*
* Map object (action) definitions read in from server config directory are not
* i.e. if called after iterating through an already established game world.
*
* Map object (action) definitions read in from server config directory are not
- * affected.
world.last_update_turn is set to 0 and world.turn to 1, so that
- *
io_round()'s criteria for updating the output file are triggered even when
- * this function is called during a round 1.
+ * affected.
The map is populated accordingly. world.last_update_turn is set to
+ *
0 and world.turn to 1, so that io_round()'s criteria for updating the output
+ *
file are triggered even when
this function is called during a round 1.
*/
extern void remake_world(uint32_t seed);
*/
extern void remake_world(uint32_t seed);
diff --git
a/src/server/world.h
b/src/server/world.h
index dcd672aa38c1de2cf1abad5954fb9a6562828b3b..ed019f2fb25742f9e64b944d9eef71b3ac723119 100644
(file)
--- a/
src/server/world.h
+++ b/
src/server/world.h
@@
-37,6
+37,7
@@
struct World
uint16_t replay; /* Turn up to which to replay game. No replay if zero. */
uint16_t turn; /* Current game turn. */
uint16_t last_update_turn; /* Last turn the .path_out file was updated. */
uint16_t replay; /* Turn up to which to replay game. No replay if zero. */
uint16_t turn; /* Current game turn. */
uint16_t last_update_turn; /* Last turn the .path_out file was updated. */
+ uint8_t player_type; /* Map object type that player will start as. */
uint8_t is_verbose; /* Should server send debugging info to stdout? */
uint8_t map_obj_count; /* Counts map objects generated so far. */
};
uint8_t is_verbose; /* Should server send debugging info to stdout? */
uint8_t map_obj_count; /* Counts map objects generated so far. */
};