I have written up a bit of code that is supposed to delete a room. It works ok sometimes, but other times it doesn't work at all. Sometimes it just does nothing, and sometimes it crashes the game. Here's the code - I know, it's awful... BTW, num_of_rooms is an external integer which is the number of rooms at startup... void DeleteRoom( int room, struct char_data *ch) { int i, y; temp = NULL; if (is_room(room) == FALSE) { sprintf(buf, "Room #%d doesn't exist.\r\n", room); send_to_char(buf, ch); return; } num_of_rooms--; CREATE(temp, struct room_data, num_of_rooms); for(i = 0, y = 0; i < num_of_rooms; i++, y++) { if (world[i].number != room) temp[y] = world[i]; else y--; } CREATE(world, struct room_data, num_of_rooms); for(i = 0; i < num_of_rooms; i++) world[i] = temp[i]; sprintf(buf, "Room #%d deleted.\r\n", room); send_to_char(buf, ch); } int is_room( int room_num ) { int i, found = FALSE; for(i = 0; i < num_of_rooms; i++) { if (world[i].number == room_num) found = TRUE; } return found; } Any help would be appreciated, Cheers, ---- Andrew Ritchie, object@alphalink.com.au +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST