Welcome to the Builder Academy

Question DG_Script Crash Issue

More
20 Sep 2019 17:10 #8430 by Sapphire
I am using an older copy of the CircleMud base, and was curious if the issue I am about to describe has been solved in the latest TBA, or if someone is able to point me to where in the code I might address a specific crash related issue I have discovered.

Issue: When running a script with a wait period, if the %actor% being targeted by the script is not present, but is at the main menu of the game, it crashes the mud.

To be more clear about this in examples: Here is a short trigger snippet.
Code:
Name: 'TRAP: Shield of Honor', VNum: [17092], RNum: [ 897] Trigger Intended Assignment: Objects Trigger Type: Get , Numeric Arg: 100, Arg list: None Commands: return 0 %send% %actor% THIEF! You cannot steal the Shield of Honor! %echoaround% %actor% Oops! %actor.name% just tried to grab the Shield of Honor... wait 1s %send% %actor% A blinding flash of silvery light engulfs you and suddenly you are sucked into a portal. %echoaround% %actor% A blinding flash of silvery light engulfs %actor.name% and %actor.heshe% is sucked into a magical portal. %teleport% %actor% 17098 wait 1 s %force% %actor% look %at% 17098 %echoaround% %actor% In a flash of light, %actor.name% is thrown violently from a portal & lies here with a dazed look on %actor.hisher% face. wait 1s %at% 17095 %echo% As quickly as it formed, the portal disappears back within the Shield of Honor. halt end

So, in this trigger for example, If by chance the player dies in that wait 1 s period, when the game goes to teleport that %actor%, it crashes. I've attempted identifiers such as if %actor%, and !%actor%, which solved it partially, but not totally. In instances where the arguments are placed, if a character is in game it works fine. If a character dies and disconnects immediately, the trigger ceases and does not crash. If a character dies and is at the main screen of the mud, it crashes. This got me thinking it has something to do with creating a way for the code to detect if a chars descriptor state is CON_PLAYING or not.

Has anyone looked at this, heard of this, have any ideas, etc? It's driving me nuts because I have a lot of triggers I want to use a wait period on to act upon a player, but I don't want to have an unstable mud.

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

More
20 Sep 2019 22:37 #8431 by thomas
Replied by thomas on topic DG_Script Crash Issue
This sounds like a reproducible crash to me. I haven't got a pc for testing it right now, but I'd suggest trying to trigger the bug while running through gdb. There's a post here somewhere about how that's done.

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

More
21 Sep 2019 04:17 #8432 by Sapphire
Replied by Sapphire on topic DG_Script Crash Issue
So, I see the error coming from Handler.c's char_from_room function as teleport is directly linked to it.

I made a workaround for the time being which I will simply apply to all dg_scripts acting upon a character at the main screen of the game. As of now, the fix works, but this is not a good fix. It just solves my stability for the time being. With the fix I will include below, it does not kick a player from the trigger trying to fire with a 'wait' argument sitting there, preparing to call on a player. This is an issue because if a player dies, comes back into game, they will still have that function called upon them. But you know... I weighed the cost. Stability or the rare instance where this will happen and a mortal might be upset...? Stability.

From dg_mobcmd.c

Original:
Code:
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; }

New:
Code:
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))) || ((vict == NULL || IN_ROOM(vict) == NOWHERE))) { mob_log(ch, "mteleport: victim (%s) does not exist",arg1); return; }

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

More
21 Sep 2019 08:06 #8433 by thomas
Replied by thomas on topic DG_Script Crash Issue
This is a bit weird - when you're at the main menu, you should fail the check in valid_dg_target() (which is called from get_char):
Code:
int valid_dg_target(struct char_data *ch, int bitvector) { if (IS_NPC(ch)) return TRUE; /* all npcs are allowed as targets */ else if (ch->desc && (STATE(ch->desc) != CON_PLAYING)) return FALSE; /* Only PC's who are playing can be targetted */ ...
I mean, on the main menu, you're not CON_PLAYING!?

And as such,
Code:
if (!(vict = get_char(arg1))) {
should be enough to filter you out...

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

More
21 Sep 2019 22:16 #8434 by thomas
Replied by thomas on topic DG_Script Crash Issue
I've tested your trigger with the latest tbamud code. This will no longer crash the system, so your version is apparently outdated.

Simple test trigger:
Code:
Name: 'test trigger', VNum: [ 3089], RNum: [ 762] Trigger Intended Assignment: Rooms Trigger Type: Enter , Numeric Arg: 100, Arg list: None Commands: wait 1s %echo% trigger started. %echo% forcing look %force% %actor% look %echoaround% %actor% local echo around %echo% waiting 5s wait 5s %echo% forcing look %force% %actor% look %echoaround% %actor% local echo around %at% 3046 %echoaround% %actor% non-local echo around %echo% done running
I attached it to a room, created a test character and transferred him to just outside the room. Then he entered:
Code:
458H 100M 82V (news) (motd) > Testchar has arrived. 458H 100M 82V (news) (motd) > Trigger started. Forcing look local echo around Waiting 5s 458H 100M 82V (news) (motd) > A death knight leaves north. 463H 100M 82V (news) (motd) > Forcing look local echo around non-local echo around Done running

Next, I summoned a death knight for killing the testchar:
Code:
463H 100M 82V (news) (motd) > Testchar has arrived. 463H 100M 82V (news) (motd) > Trigger started. Forcing look local echo around Waiting 5s 463H 100M 82V (news) (motd) > Testchar tries to hit a death knight who easily avoids the blow. 463H 100M 82V (news) (motd) > The cityguard jumps to the aid of a death knight! The cityguard slashes Testchar hard. Testchar is stunned, but will probably regain consciousness again. Testchar is slashed in two by a masterful stroke of the cityguard! Testchar is dead! R.I.P. [ Testchar killed by the cityguard at The Deserted Warehouse ] Your blood freezes as you hear Testchar's death cry. 463H 100M 82V (news) (motd) > Forcing look [ Room 3050 :: wforce: no target found ] [ Room 3050 :: no target found for wsend ] [ Room 3046 :: no target found for wsend ] Done running
As you see, all we get are a couple of log warnings.
The following user(s) said Thank You: Sapphire

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

More
07 Feb 2020 16:41 #8544 by Sapphire
Replied by Sapphire on topic DG_Script Crash Issue
I just realized, I never replied and said thank you. I applied your fix as soon as you sent it and it worked. Sorry for the 4 month delay, not intentional! Thanks!

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

Time to create page: 0.202 seconds