While testing my do_dc bugfix, I've bumped into another bug,
this time in do_return().
Watch this log:
Start logging: 29.06.1999 22:54 by Krys
[...]
> switch janitor
Okay.
the janitor>
Krys appears with an ear-splitting bang.
the janitor>
Krys says, 'Zmey here, I've switched into your body'
the janitor> say ok, I'm returning
You say, 'ok, but I'm returning'
the janitor> return
You return to your original body.
> who
> help
> say
> dklsfjdklsf
> Help
> quit
>
#zap
#Connection terminated by user.
===
The fix is simple:
ACMD(do_return)
{
if (ch->desc && ch->desc->original) {
send_to_char("You return to your original body.\r\n", ch);
/* JE 2/22/95 */
/* if someone switched into your original body, disconnect them */
- if (ch->desc->original->desc)
+ if (ch->desc->original->desc) {
+ /*
+ * Zmey: here we put someone switched in our body to disconnect state
+ * but we must also NULL his pointer to our character, otherwise
+ * close_socket() will damage our character's pointer to our descriptor
+ * (which is assigned below in this function).
+ */
+ ch->desc->original->desc->character = NULL;
STATE(ch->desc->original->desc) = CON_DISCONNECT;
+ }
+ /* Now our descriptor points to our original body */
ch->desc->character = ch->desc->original;
ch->desc->original = NULL;
+ /* And our body's pointer to descriptor now points to our descriptor */
ch->desc->character->desc = ch->desc;
ch->desc = NULL;
}
}
Zmey // 3MoonsWorld (rmud.net.ru:4000)
+------------------------------------------------------------+
| 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