void do_moves(dungeon_t *d) { pair_t next; character *c; /* Remove the PC when it is PC turn. Replace on next call. This allows * * use to completely uninit the heap when generating a new level without * * worrying about deleting the PC. */ if (pc_is_alive(d)) { heap_insert(&d->next_turn, d->pc); } while (pc_is_alive(d) && ((c = ((character *) heap_remove_min(&d->next_turn))) != d->pc)) { if (!character_is_alive(c)) { if (d->charmap[character_get_y(c)][character_get_x(c)] == c) { d->charmap[character_get_y(c)][character_get_x(c)] = NULL; } if (c != d->pc) { character_delete(c); } continue; } character_next_turn(c); npc_next_pos(d, c, next); move_character(d, c, next); heap_insert(&d->next_turn, c); } if (pc_is_alive(d) && c == d->pc) { character_next_turn(c); if(d->objmap[character_get_y(c)][character_get_x(c)]){ if(add_to_inventory(d, d->objmap[character_get_y(c)][character_get_x(c)]) == 0){ d->objmap[character_get_y(c)][character_get_x(c)] = NULL; } } } }
int hash_object(int actor_node, char *text) { /** public function - see header */ int socket=clients.client[actor_node].socket; int object_id=0; //extract data from text string if(sscanf(text, "%*s %i", &object_id)!=1){ send_text(socket, CHAT_SERVER, "%cyou need to use the format #OBJECT [object id]]", c_red3+127); return 0; } //put item in slot 0 add_to_inventory(actor_node, object_id, 1, 0); return 0; }