home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
The player is now a map object like any other. All actor contacts now lead to violenc...
[plomrogue]
/
src
/
map_objects.c
diff --git
a/src/map_objects.c
b/src/map_objects.c
index 7e2472d0da521abe19b873088e7cb96f36571563..e825755b86a991b1b823756038d1df0a4181ec89 100644
(file)
--- a/
src/map_objects.c
+++ b/
src/map_objects.c
@@
-78,9
+78,10
@@
extern void read_map_objects(struct World * world, FILE * file, char * line,
char * f_name = "read_map_objects()";
struct MapObj ** mo_ptr_ptr = &world->map_objs;
char * delim = " ";
char * f_name = "read_map_objects()";
struct MapObj ** mo_ptr_ptr = &world->map_objs;
char * delim = " ";
+ struct MapObj * mo;
while (try_fgets(line, linemax + 1, file, world, f_name))
{
while (try_fgets(line, linemax + 1, file, world, f_name))
{
-
struct MapObj *
mo = malloc(sizeof(struct MapObj));
+ mo = malloc(sizeof(struct MapObj));
mo->next = NULL;
mo->id = atoi(strtok(line, delim));
if (mo->id > world->map_obj_count)
mo->next = NULL;
mo->id = atoi(strtok(line, delim));
if (mo->id > world->map_obj_count)
@@
-94,6
+95,7
@@
extern void read_map_objects(struct World * world, FILE * file, char * line,
* mo_ptr_ptr = mo;
mo_ptr_ptr = &mo->next;
}
* mo_ptr_ptr = mo;
mo_ptr_ptr = &mo->next;
}
+ world->last_map_obj = mo;
}
}
@@
-108,8
+110,16
@@
extern void add_map_object(struct World * world, uint8_t type)
mo->type = mod->id;
mo->lifepoints = mod->lifepoints;
mo->pos = find_passable_pos(world->map);
mo->type = mod->id;
mo->lifepoints = mod->lifepoints;
mo->pos = find_passable_pos(world->map);
- mo->next = world->map_objs;
- world->map_objs = mo;
+ mo->next = NULL;
+ if (NULL == world->last_map_obj)
+ {
+ world->map_objs = mo;
+ }
+ else
+ {
+ world->last_map_obj->next = mo;
+ }
+ world->last_map_obj = mo;
}
}
@@
-137,6
+147,25
@@
extern void free_map_objects(struct MapObj * mo_start)
+extern struct MapObj * get_player(struct World * world)
+{
+ struct MapObj * ptr = world->map_objs;
+ while (1)
+ {
+ if (NULL == ptr)
+ {
+ return ptr;
+ }
+ if (0 == ptr->id)
+ {
+ return ptr;
+ }
+ ptr = ptr->next;
+ }
+}
+
+
+
extern struct MapObjDef * get_map_object_def(struct World * w, uint8_t id)
{
struct MapObjDef * mod = w->map_obj_defs;
extern struct MapObjDef * get_map_object_def(struct World * w, uint8_t id)
{
struct MapObjDef * mod = w->map_obj_defs;