Welcome to the Builder Academy

Question Wierd crash - Need help to locate the problem from this GDB info

More
07 Apr 2018 14:19 - 07 Apr 2018 14:21 #7884 by thomas
Yes, there's the problem. And yes, we should be able to fix it.

At least I can extrapolate on how it fails.
Assume char X enters the room
X is not a thief, so he triggers the first if
The trigger waits a sec
... sends something to X
... and X's room
X quits (or rents out, or dies). X is now not in a room. But X is still online, so the trigger isn't stopped.
The trigger sends something to the room
... and attempts to move X
This fails, because X no longer is in the game (but at the menu, doing whatever).

So, how to fix this?
Either,
1) in the action functions (%force%, %teleport%, etc), checking if the player is in game before performing an action on them, or
2) when waking after waitstates, check that the player is actually a valid target

It turns out we have 1) in place in most such functions, but miss it in do_mteleport github.com/tbamud/tbamud/blob/master/src/dg_mobcmd.c#L624 :
Code:
} else { if (*arg1 == UID_CHAR) { if (!(vict = get_char(arg1))) { mob_log(ch, "mteleport: victim (%s) does not exist",arg1); return; } } else if (!(vict = get_char_vis(ch, arg1, NULL, FIND_CHAR_WORLD))) { mob_log(ch, "mteleport: victim (%s) does not exist",arg1); return; } - if (valid_dg_target(ch, DG_ALLOW_GODS)) { + if (valid_dg_target(vict, DG_ALLOW_GODS)) { char_from_room(vict); char_to_room(vict, target); enter_wtrigger(&world[IN_ROOM(ch)], ch, -1); } } }
Last edit: 07 Apr 2018 14:21 by thomas. Reason: better fix

Please Log in or Create an account to join the conversation.

More
07 Apr 2018 14:30 #7885 by JTP
So with:
- if (valid_dg_target(ch, DG_ALLOW_GODS)) {
+ if (valid_dg_target(vict, DG_ALLOW_GODS)) {

Below isnt needed after all ?


+ if (IN_ROOM(vict) == NOWHERE)
+ return;
+

Please Log in or Create an account to join the conversation.

More
07 Apr 2018 14:56 #7886 by thomas
correct. realized it immediately after pushing submit :S

Please Log in or Create an account to join the conversation.

More
07 Apr 2018 14:58 - 07 Apr 2018 14:59 #7887 by JTP
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);

That is still ch and ch or should also be vict ?
Last edit: 07 Apr 2018 14:59 by JTP.

Please Log in or Create an account to join the conversation.

More
07 Apr 2018 15:00 #7888 by thomas
Indeed, that should be vict also.

We're triggering an enter trigger in the new room we just sent vict to.

Please Log in or Create an account to join the conversation.

More
07 Apr 2018 15:06 #7889 by JTP
So the all option already had:
if (valid_dg_target(vict, DG_ALLOW_GODS)) {
char_from_room(vict);
char_to_room(vict, target);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1); <<<---but still ch and ch here.

And the else if:
if (valid_dg_target(ch, DG_ALLOW_GODS)) {
char_from_room(vict);
char_to_room(vict, target);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);


Alittle confusing...is the all part corrent then ?

Code:
if (!str_cmp(arg1, "all")) { if (target == IN_ROOM(ch)) { mob_log(ch, "mteleport all target is itself"); return; } for (vict = world[IN_ROOM(ch)].people; vict; vict = next_ch) { next_ch = vict->next_in_room; if (valid_dg_target(vict, DG_ALLOW_GODS)) { char_from_room(vict); char_to_room(vict, target); enter_wtrigger(&world[IN_ROOM(ch)], ch, -1); } } } else { if (*arg1 == UID_CHAR) { if (!(vict = get_char(arg1))) { mob_log(ch, "mteleport: victim (%s) does not exist",arg1); return; } } else if (!(vict = get_char_vis(ch, arg1, NULL, FIND_CHAR_WORLD))) { mob_log(ch, "mteleport: victim (%s) does not exist",arg1); return; } if (valid_dg_target(ch, DG_ALLOW_GODS)) { char_from_room(vict); char_to_room(vict, target); enter_wtrigger(&world[IN_ROOM(ch)], ch, -1); } } }

Please Log in or Create an account to join the conversation.

Time to create page: 0.265 seconds