}
}
struct NextAndId ** nai_ptr_ptr = start;
- for (; NULL != * nai_ptr_ptr; nai_ptr_ptr = &(*nai_ptr_ptr)->next);
+ for (; * nai_ptr_ptr; nai_ptr_ptr = &(*nai_ptr_ptr)->next);
*nai_ptr_ptr = nai;
return nai;
}
+extern void add_thing_to_memory_map(struct Thing * t, uint8_t type,
+ uint8_t y, uint8_t x)
+{
+ struct ThingInMemory * tm=try_malloc(sizeof(struct ThingInMemory),__func__);
+ tm->type = type;
+ tm->pos.y = y;
+ tm->pos.x = x;
+ tm->next = t->t_mem;
+ t->t_mem = tm;
+}
+
+
+
extern void free_thing_actions(struct ThingAction * ta)
{
- if (NULL == ta)
+ if (!ta)
{
return;
}
extern void free_thing_types(struct ThingType * tt)
{
- if (NULL == tt)
+ if (!tt)
{
return;
}
extern void free_things(struct Thing * t)
{
- if (NULL == t)
+ if (!t)
{
return;
}
free_things(t->owns);
free_things(t->next);
free(t->fov_map);
+ free(t->mem_map);
+ free_things_in_memory(t->t_mem);
free(t);
if (t == world.things) /* So add_things()' NULL-delimited thing */
{ /* iteration loop does not iterate over */
+extern void free_things_in_memory(struct ThingInMemory * tm)
+{
+ if (!tm)
+ {
+ return;
+ }
+ free_things_in_memory(tm->next);
+ free(tm);
+}
+
+
+
extern struct ThingAction * get_thing_action(uint8_t id)
{
struct ThingAction * ta = world.thing_actions;
- for (; NULL != ta && id != ta->id; ta = ta->next);
+ for (; ta && id != ta->id; ta = ta->next);
return ta;
}
extern struct ThingType * get_thing_type(uint8_t id)
{
struct ThingType * tt = world.thing_types;
- for (; NULL != tt && id != tt->id; tt = tt->next);
+ for (; tt && id != tt->id; tt = tt->next);
return tt;
}
extern uint8_t get_thing_action_id_by_name(char * name)
{
struct ThingAction * ta = world.thing_actions;
- while (NULL != ta)
+ while (ta)
{
if (0 == strcmp(ta->name, name))
{
{
while (1)
{
- if (NULL == ptr || id == ptr->id)
+ if (!ptr || id == ptr->id)
{
return ptr;
}
if (deep)
{
struct Thing * owned_thing = get_thing(ptr->owns, id, 1);
- if (NULL != owned_thing)
+ if (owned_thing)
{
return ptr;
}
penult->next = t->next;
}
struct Thing ** t_ptr_ptr = target;
- for (; NULL != * t_ptr_ptr; t_ptr_ptr = &(*t_ptr_ptr)->next);
+ for (; * t_ptr_ptr; t_ptr_ptr = &(*t_ptr_ptr)->next);
* t_ptr_ptr = t;
t->next = NULL;
}
{
t->pos = pos;
struct Thing * owned = t->owns;
- for (; owned != NULL; set_thing_position(owned, pos), owned = owned->next);
+ for (; owned; set_thing_position(owned, pos), owned = owned->next);
}