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:
4ee05e4
)
Server: Make config file set number of objects' start appearances.
author
Christian Heller
<c.heller@plomlompom.de>
Wed, 9 Apr 2014 04:06:51 +0000
(06:06 +0200)
committer
Christian Heller
<c.heller@plomlompom.de>
Wed, 9 Apr 2014 04:06:51 +0000
(06:06 +0200)
README
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/map_objects.h
patch
|
blob
|
history
diff --git
a/README
b/README
index a944ceaac75398bcd0fb375016bae75213b0ec69..90fd601c82fc90052c4d9aa8b67182a6bcc170d1 100644
(file)
--- a/
README
+++ b/
README
@@
-126,6
+126,7
@@
SYMBOL z
LIFEPOINTS 3
CORPSE_ID 5
CONSUMABLE 0
LIFEPOINTS 3
CORPSE_ID 5
CONSUMABLE 0
+START_NUMBER 9
A line of "OBJECT" followed by a number starts it, and the number sets the
object type's internal id. The number after "CONSUMABLE" defines the object
A line of "OBJECT" followed by a number starts it, and the number sets the
object type's internal id. The number after "CONSUMABLE" defines the object
@@
-137,7
+138,8
@@
the id of the object type that objects of this type degrade to if their
hitpoints drop to zero if they start out as inanimate (what is not implemented
yet: or if they are inanimate, but are otherwise crushed). Note that the
"CORPSE_ID" must match the id of an object type defined in the file (before or
hitpoints drop to zero if they start out as inanimate (what is not implemented
yet: or if they are inanimate, but are otherwise crushed). Note that the
"CORPSE_ID" must match the id of an object type defined in the file (before or
-after, it may even be the same).
+after, it may even be the same). "START_NUMBER" sets the number of objects that
+are to appear of the given type on the map on game start.
All these definition block members must be present within their blocks, but only
"ACTION" / "OBJECT" / "MAP_TYPE" must be positioned at their respective blocks'
All these definition block members must be present within their blocks, but only
"ACTION" / "OBJECT" / "MAP_TYPE" must be positioned at their respective blocks'
diff --git
a/confserver/world
b/confserver/world
index 84e747d692253eefd884a70ae0e3850c8875f77b..16e86cb3a89d5938b25afa94f66cc9419d9e43a6 100644
(file)
--- a/
confserver/world
+++ b/
confserver/world
@@
-30,6
+30,7
@@
SYMBOL @
LIFEPOINTS 5
CORPSE_ID 5
CONSUMABLE 0
LIFEPOINTS 5
CORPSE_ID 5
CONSUMABLE 0
+START_NUMBER 1
OBJECT 1
NAME ANT
OBJECT 1
NAME ANT
@@
-37,6
+38,7
@@
SYMBOL a
LIFEPOINTS 1
CORPSE_ID 4
CONSUMABLE 0
LIFEPOINTS 1
CORPSE_ID 4
CONSUMABLE 0
+START_NUMBER 27
OBJECT 2
NAME ZOMBIE
OBJECT 2
NAME ZOMBIE
@@
-44,6
+46,7
@@
SYMBOL z
LIFEPOINTS 3
CORPSE_ID 5
CONSUMABLE 0
LIFEPOINTS 3
CORPSE_ID 5
CONSUMABLE 0
+START_NUMBER 9
OBJECT 3
NAME SHOGGOTH
OBJECT 3
NAME SHOGGOTH
@@
-51,6
+54,7
@@
SYMBOL S
LIFEPOINTS 9
CORPSE_ID 6
CONSUMABLE 0
LIFEPOINTS 9
CORPSE_ID 6
CONSUMABLE 0
+START_NUMBER 3
OBJECT 4
NAME DIRT
OBJECT 4
NAME DIRT
@@
-58,6
+62,7
@@
SYMBOL #
LIFEPOINTS 0
CORPSE_ID 4
CONSUMABLE 0
LIFEPOINTS 0
CORPSE_ID 4
CONSUMABLE 0
+START_NUMBER 9
OBJECT 5
NAME SKELETON
OBJECT 5
NAME SKELETON
@@
-65,6
+70,7
@@
SYMBOL %
LIFEPOINTS 0
CORPSE_ID 4
CONSUMABLE 0
LIFEPOINTS 0
CORPSE_ID 4
CONSUMABLE 0
+START_NUMBER 9
OBJECT 6
NAME 'MAGIC MEAT'
OBJECT 6
NAME 'MAGIC MEAT'
@@
-72,3
+78,4
@@
SYMBOL m
LIFEPOINTS 0
CORPSE_ID 4
CONSUMABLE 3
LIFEPOINTS 0
CORPSE_ID 4
CONSUMABLE 3
+START_NUMBER 1
diff --git
a/src/server/configfile.c
b/src/server/configfile.c
index 1eb516560ab21bb5fb623bfb85710af3b55164dc..ab368b0ea65ad1496caac6397a516c005679ff34 100644
(file)
--- a/
src/server/configfile.c
+++ b/
src/server/configfile.c
@@
-36,9
+36,10
@@
enum flag
SYMBOL_SET = 0x08,
LIFEPOINTS_SET = 0x10,
CONSUMABLE_SET = 0x20,
SYMBOL_SET = 0x08,
LIFEPOINTS_SET = 0x10,
CONSUMABLE_SET = 0x20,
+ START_N_SET = 0x40,
READY_ACT = NAME_SET | EFFORT_SET,
READY_OBJ = NAME_SET | CORPSE_ID_SET | SYMBOL_SET | LIFEPOINTS_SET
READY_ACT = NAME_SET | EFFORT_SET,
READY_OBJ = NAME_SET | CORPSE_ID_SET | SYMBOL_SET | LIFEPOINTS_SET
- | CONSUMABLE_SET,
+ | CONSUMABLE_SET
| START_N_SET
,
READY_MAP = HEIGHT_SET | WIDTH_SET | ORTH_SET | DIAG_SET
};
READY_MAP = HEIGHT_SET | WIDTH_SET | ORTH_SET | DIAG_SET
};
@@
-280,6
+281,8
@@
static uint8_t set_members(char * token0, char * token1, uint8_t * object_flags,
SYMBOL_SET, 'c', (char *) &mod->char_on_map)
|| parse_val(token0, token1, "EFFORT", action_flags,
EFFORT_SET, '8', (char *) &moa->effort)
SYMBOL_SET, 'c', (char *) &mod->char_on_map)
|| parse_val(token0, token1, "EFFORT", action_flags,
EFFORT_SET, '8', (char *) &moa->effort)
+ || parse_val(token0, token1, "START_NUMBER", object_flags,
+ START_N_SET, '8', (char *) &mod->start_n)
|| parse_val(token0, token1, "LIFEPOINTS", object_flags,
LIFEPOINTS_SET, '8', (char *) &mod->lifepoints)
|| parse_val(token0, token1, "CONSUMABLE", object_flags,
|| parse_val(token0, token1, "LIFEPOINTS", object_flags,
LIFEPOINTS_SET, '8', (char *) &mod->lifepoints)
|| parse_val(token0, token1, "CONSUMABLE", object_flags,
diff --git
a/src/server/init.c
b/src/server/init.c
index 9f2a4e9f7b35af10ce0e26a8bb236eb11366be31..2f6428e99c283e7fe192aa3e7399224bf63fd561 100644
(file)
--- a/
src/server/init.c
+++ b/
src/server/init.c
@@
-19,8
+19,7
@@
#include "../common/try_malloc.h" /* try_malloc() */
#include "cleanup.h" /* set_cleanup_flag() */
#include "map.h" /* init_map() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "cleanup.h" /* set_cleanup_flag() */
#include "map.h" /* init_map() */
-#include "map_objects.h" /* free_map_objects(), add_map_objects() */
-#include "rrand.h" /* rrand() */
+#include "map_objects.h" /* MapObjDef, free_map_objects(), add_map_objects() */
#include "run.h" /* obey_msg(), io_loop() */
#include "world.h" /* global world */
#include "run.h" /* obey_msg(), io_loop() */
#include "world.h" /* global world */
@@
-87,12
+86,11
@@
extern void remake_world(uint32_t seed)
free_map_objects(world.map_objs);
world.last_update_turn = 0;
init_map();
free_map_objects(world.map_objs);
world.last_update_turn = 0;
init_map();
- add_map_objects(0, 1);
- add_map_objects(1, 1 + rrand() % 27);
- add_map_objects(2, 1 + rrand() % 9);
- add_map_objects(3, 1 + rrand() % 3);
- add_map_objects(4, 1 + rrand() % 3);
- add_map_objects(5, 1 + rrand() % 3);
+ struct MapObjDef * mod;
+ for (mod = world.map_obj_defs; NULL != mod; mod = mod->next)
+ {
+ 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 0be0dfdf69992c85aca0deed1547fa7184288e94..1cc6706f4317f19f2ef757975940aca904c72c25 100644
(file)
--- a/
src/server/init.h
+++ b/
src/server/init.h
@@
-23,8
+23,7
@@
extern void setup_server_io();
* 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
* 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. How many map objects of what type
- * id are generated on the map is currently hard-coded.
+ * 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/map_objects.h
b/src/server/map_objects.h
index fdd11f91c9180cc4226e199ac3d1a0abba28cc8c..d18e3c259f4df1f422420dc77da12a34c4ee74e2 100644
(file)
--- a/
src/server/map_objects.h
+++ b/
src/server/map_objects.h
@@
-34,6
+34,7
@@
struct MapObjDef
uint8_t corpse_id; /* type to change map object into upon destruction */
uint8_t lifepoints; /* default start value for map object's .lifepoints */
uint8_t consumable; /* can be eaten if !0, for so much hitpoint win */
uint8_t corpse_id; /* type to change map object into upon destruction */
uint8_t lifepoints; /* default start value for map object's .lifepoints */
uint8_t consumable; /* can be eaten if !0, for so much hitpoint win */
+ uint8_t start_n; /* how many of these does the map start with? */
};
};