There's a lot of code that loops over CHAR_DATAs in various containers with code like:
for (auto *ch = blah; ch; ch = ch->next) {...}
Some code takes defensive action "what if the the ch is removed/deleted/moved...
CHAR_DATA *ch_next;
for (auto *ch = blah; ch; ch = ch_next) {
ch_next = ch->next;
...maybe do stuff that deletes `ch` or moves it out of the room or whatever...
}
This is "ok" but:
Users have to remember which pattern to use, which is "safe" vs "I'm sure nothing will go away"...
probably a general iteration solution can make this easier
Some code paths remove more than one char.
In the first case, some smart iteration will make this "go away" (mostly).
In the second case, smart iteration may be able to be taught (I have ideas)...
The second case can probably happen when:
CHAR_DATA list is TheMoog -> TheMoog's pet -> nullptr
There's a lot of code that loops over CHAR_DATAs in various containers with code like:
Some code takes defensive action "what if the the
ch
is removed/deleted/moved...This is "ok" but:
In the first case, some smart iteration will make this "go away" (mostly).
In the second case, smart iteration may be able to be taught (I have ideas)...
The second case can probably happen when:
TheMoog -> TheMoog's pet -> nullptr
This code runs
do_quit
the character and their pet are removedch_next
is invalid (it will point at the pet that's been removed)