home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
confserver/defs -> confserver/map_objects; fixed debug values in there.
[plomrogue]
/
src
/
server
/
map_objects.c
diff --git
a/src/server/map_objects.c
b/src/server/map_objects.c
index 0401c76b4339f959b312a81950bef4125bd92182..f60cefeb3092b7df42c3b5c8c7a3ea7c78330a4c 100644
(file)
--- a/
src/server/map_objects.c
+++ b/
src/server/map_objects.c
@@
-10,16
+10,16
@@
* reset_err_try_fgets_counter()
*/
#include "../common/readwrite.h" /* try_fopen(), try_fclose(), try_fgetc(),
* reset_err_try_fgets_counter()
*/
#include "../common/readwrite.h" /* try_fopen(), try_fclose(), try_fgetc(),
- * textfile_
sizes
()
+ * textfile_
width
()
*/
#include "../common/rexit.h" /* exit_err(), exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
*/
#include "../common/rexit.h" /* exit_err(), exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
-#include "../common/yx_uint
16.h" /* yx_uint16
struct */
+#include "../common/yx_uint
8.h" /* yx_uint8
struct */
#include "cleanup.h" /* set_cleanup_flag() */
#include "map.h" /* is_passable() */
#include "rrand.h" /* rrand() */
#include "world.h" /* global world */
#include "cleanup.h" /* set_cleanup_flag() */
#include "map.h" /* is_passable() */
#include "rrand.h" /* rrand() */
#include "world.h" /* global world */
-#include "yx_uint
16.h" /* yx_uint16
_cmp() */
+#include "yx_uint
8.h" /* yx_uint8
_cmp() */
@@
-27,7
+27,7
@@
static struct MapObj * get_map_object(struct MapObj * ptr, uint8_t id);
/* Return random passable (as by is_passable()) position on world.map. */
static struct MapObj * get_map_object(struct MapObj * ptr, uint8_t id);
/* Return random passable (as by is_passable()) position on world.map. */
-static struct yx_uint
16
find_passable_pos();
+static struct yx_uint
8
find_passable_pos();
/* Add object of "type" to map on random position. Don't place actor on actor.*/
static void add_map_object(uint8_t type);
/* Add object of "type" to map on random position. Don't place actor on actor.*/
static void add_map_object(uint8_t type);
@@
-53,9
+53,9
@@
static struct MapObj * get_map_object(struct MapObj * ptr, uint8_t id)
-static struct yx_uint
16
find_passable_pos()
+static struct yx_uint
8
find_passable_pos()
{
{
- struct yx_uint
16
pos;
+ struct yx_uint
8
pos;
for (pos.y = pos.x = 0; 0 == is_passable(pos);)
{
pos.y = rrand() % world.map.size.y;
for (pos.y = pos.x = 0; 0 == is_passable(pos);)
{
pos.y = rrand() % world.map.size.y;
@@
-77,12
+77,12
@@
static void add_map_object(uint8_t type)
mo->lifepoints = mod->lifepoints;
while (1)
{
mo->lifepoints = mod->lifepoints;
while (1)
{
- struct yx_uint
16
pos = find_passable_pos(world.map);
+ struct yx_uint
8
pos = find_passable_pos(world.map);
struct MapObj * mo_ptr;
uint8_t clear = 1;
for (mo_ptr = world.map_objs; mo_ptr != NULL; mo_ptr = mo_ptr->next)
{
struct MapObj * mo_ptr;
uint8_t clear = 1;
for (mo_ptr = world.map_objs; mo_ptr != NULL; mo_ptr = mo_ptr->next)
{
- if (yx_uint
16
_cmp(&pos, &mo_ptr->pos) && 0 != mo_ptr->lifepoints)
+ if (yx_uint
8
_cmp(&pos, &mo_ptr->pos) && 0 != mo_ptr->lifepoints)
{
clear = 0;
break;
{
clear = 0;
break;
@@
-108,7
+108,7
@@
extern void init_map_object_defs()
char * err_toolarge = "Value is too large.";
char * err_uniq = "Declaration of ID already used.";
FILE * file = try_fopen(world.path_map_obj_defs, "r", f_name);
char * err_toolarge = "Value is too large.";
char * err_uniq = "Declaration of ID already used.";
FILE * file = try_fopen(world.path_map_obj_defs, "r", f_name);
- uint
16_t linemax = textfile_sizes(file, NULL
);
+ uint
32_t linemax = textfile_width(file
);
struct MapObjDef ** last_mod_ptr_ptr = &world.map_obj_defs;
char line[linemax + 1];
reset_err_try_fgets_counter();
struct MapObjDef ** last_mod_ptr_ptr = &world.map_obj_defs;
char line[linemax + 1];
reset_err_try_fgets_counter();
@@
-142,6
+142,9
@@
extern void init_map_object_defs()
line[strlen(line) - 1] = '\0';
mod->name = try_malloc(strlen(line) + 1, f_name);
memcpy(mod->name, line, strlen(line) + 1);
line[strlen(line) - 1] = '\0';
mod->name = try_malloc(strlen(line) + 1, f_name);
memcpy(mod->name, line, strlen(line) + 1);
+ err_try_fgets(line, linemax, file, context, "0nfi");
+ err_line(atoi(line) > UINT8_MAX, line, context, err_toolarge);
+ mod->consumable = atoi(line);
* last_mod_ptr_ptr = mod;
last_mod_ptr_ptr = &mod->next;
err_try_fgets(line, linemax, file, context, "d");
* last_mod_ptr_ptr = mod;
last_mod_ptr_ptr = &mod->next;
err_try_fgets(line, linemax, file, context, "d");
@@
-244,7
+247,7
@@
extern struct MapObjDef * get_map_object_def(uint8_t id)
-extern void set_object_position(struct MapObj * mo, struct yx_uint
16
pos)
+extern void set_object_position(struct MapObj * mo, struct yx_uint
8
pos)
{
mo->pos = pos;
struct MapObj * owned = mo->owns;
{
mo->pos = pos;
struct MapObj * owned = mo->owns;