Redit-Copy bug, and fix

Login to reply  Page: « < 1 of 1 > »
22 May 2010 - 14:392607
Redit-Copy bug, and fix
Tracked down a bug where if you redit a new room, and copy to it, the room you are currently in,
it will go into an infinite loop when you next act() in the new room. This is because the *people
variable also gets copied. So when you "goto <new room>" you are already IN that room, and it
sets your 'next_in_room' to yourself, and when it tries to do your poof_in via act(), it is in an
infinite loop here:

  for (; to; to = to->next_in_room) {
    if (!SENDOK(to) || (to == ch))
      continue;

as you are both to, and to->next_in_room.

Maybe adding to the act() function:
  for (; to; to = to->next_in_room) {
+    if(to == to->next_in_room)
+      break;
    if (!SENDOK(to) || (to == ch))
      continue;

Might prevent any other places that might accidently cause this to not freeze the game. I realize its more of a hack then fixing the problem, but *shrug*

I fixed this by adding the following to the redit_setup_exisiting() function in redit:

void redit_setup_existing(struct descriptor_data *d, int real_num)
{
  struct room_data *room;
  int counter;

  /* Build a copy of the room for editing. */
  CREATE(room, struct room_data, 1);

  *room = world[real_num];

+  /* Make new room people list be empty.                          */
+  /* Fixes bug where copying a room from within that room creates */
+  /* an infinite loop when you next act() in the new room (goto?) */
+  /* and you are your next_in_room          -- anderyu (10-05-22) */
+  room->people = NULL;
+
  /* Allocate space for all strings. */
  room->name = str_udup(world[real_num].name);
  room->description = str_udup(world[real_num].description);

If there is a more proper way to prevent this from being copied instead of just
resetting it after the fact I'm interested in that.

anderyu


__________________
I'm not racist, I hate everyone equally.
23 May 2010 - 23:522614
Good catch, thanks. Added for next release.


__________________
Rumble
The Builder Academy
tbamud.com 9091
Login to reply  Page: « < 1 of 1 > »