+extern void init_map_object_actions()
+{
+ char * f_name = "init_map_object_actions()";
+
+ char * path = "config/map_object_actions";
+ FILE * file = try_fopen(path, "r", f_name);
+ uint16_t linemax = get_linemax(file, f_name);
+ char line[linemax + 1];
+
+ struct MapObjAct ** moa_ptr_ptr = &world.map_obj_acts;
+ char * delim = " ";
+ while (fgets(line, linemax + 1, file))
+ {
+ if ('\n' == line[0] || 0 == line[0])
+ {
+ break;
+ }
+ struct MapObjAct * moa = try_malloc(sizeof(struct MapObjAct), f_name);
+ moa->id = atoi(strtok(line, delim));
+ moa->effort = atoi(strtok(NULL, delim));
+ char * funcname = strtok(NULL, "\n");
+ uint8_t len_name = strlen(funcname) + 1;
+ moa->name = try_malloc(len_name, f_name);
+ memcpy(moa->name, funcname, len_name);
+ if (!( try_func_name(moa, "move", actor_move)
+ || try_func_name(moa, "pick_up", actor_pick)
+ || try_func_name(moa, "drop", actor_drop)
+ || try_func_name(moa, "use", actor_use)))
+ {
+ moa->func = actor_wait;
+ }
+ moa->next = NULL;
+ * moa_ptr_ptr = moa;
+ moa_ptr_ptr = &moa->next;
+ }
+ try_fclose(file, f_name);
+}
+
+
+
+extern void free_map_object_actions(struct MapObjAct * moa)
+{
+ if (NULL == moa)
+ {
+ return;
+ }
+ free(moa->name);
+ free_map_object_actions(moa->next);
+ free(moa);
+}
+
+
+
+extern void actor_wait(struct MapObj * mo)
+{
+ if (mo == get_player())
+ {
+ playerbonus_wait();
+ }
+}
+
+
+
+extern void actor_move(struct MapObj * mo)
+{
+ char d = mo->arg;
+ struct yx_uint16 target = mv_yx_in_dir(d, mo->pos);
+ struct MapObj * other_mo;
+ for (other_mo = world.map_objs; other_mo != 0; other_mo = other_mo->next)
+ {
+ if (0 == other_mo->lifepoints || other_mo == mo)
+ {
+ continue;
+ }
+ if (yx_uint16_cmp(&target, &other_mo->pos))
+ {
+ actor_hits_actor(mo, other_mo);
+ return;
+ }
+ }
+ uint8_t passable = is_passable(world.map, target);
+ if (passable)
+ {
+ set_object_position(mo, target);
+ }
+ if (mo == get_player())
+ {
+ playerbonus_move(d, passable);
+ }
+}
+
+
+
+extern void actor_drop(struct MapObj * mo)
+{
+ uint8_t owns_none = (NULL == mo->owns);
+ if (!owns_none)
+ {
+ uint8_t select = mo->arg;
+ struct MapObj * owned = mo->owns;
+ uint8_t i = 0;
+ for (; i != select; i++, owned = owned->next);
+ own_map_object(&world.map_objs, &mo->owns, owned->id);
+ }
+ if (mo == get_player())
+ {
+ playerbonus_drop(owns_none);
+ }
+}
+
+
+
+extern void actor_pick(struct MapObj * mo)