Contagious spell...

Posted by Vir on Tue 30 Nov 2004 12:26 PM — 5 posts, 18,631 views.

#0
Just to get it outta the way, I'm using:
SmaugWiz 2.02 on Win98, PII 350

Ok, so I wrote spell_plague and it seems to be working except for 1 thing. I want this spell to be contagious, so I opened update.c and added the following just above the ifcheck for IsPoisoned().

if ( ch->IsPlagued() )
{
CCharacter *victim, *v_next;
int retcode;

for ( victim = ch->GetInRoom()->first_person;
victim;
victim = v_next; )
{
v_next = ch->GetNextInRoom();

if ( !victim->IsNpc() )
{
retcode = spell_plague(gsn_plague, LEVEL_AVATAR, ch, victim);
}
}
}

The GSN and the IsPlagued() function are all set up correctly. The spell works just fine if nobody else is in the room. It does damage on each tick perfectly, displays the damage messages just fine. But as soon as somebody else is in the room over a tick, the MUD goes into an endless loop.

Problem is, it isn't the loop. I replaced the spell_plague(gsn_plague, ... line with victim->SendText("Ping.\n\r"); and it no longer crashed.

I have also tried pulling the code from inside spell_plague out and inserting it, as well as just doing victim->SetPlagued() which simply sets the AFF_PLAGUE bit. Both those ways, it goes into an endless loop again.

What am I doing wrong? :)
#1
Sorry, this line:

if ( !victim->IsNpc() )

should read:

if ( !victim->IsNpc() && !victim->IsPlagued() )
#2
Right. Well. I'm an idiot.

shoulda been victim->GetNextInRoom() instead of ch->GetNextInRoom()

*sigh*

Sorry all. Hehe.
#3
Hi all,
I am legally blind and am using a screen reader, somehow the post new thread button isn't accessible.
So, this is unrelated to this discussion.
I have run into a serious problem with the Unknown Regions codebase.
I use to have a shell, now I am limited to using cygwin.
The problem is that when using cygwin after taking steps to make the codebase compatible with cygwin, the log directory gets filled with empty log files.
The process list shows that sleep is running, so it must be crashing.
I got the following output from GDB.



Program received signal SIGSEGV, Segmentation fault.
0x6108db8e in cygwin1!aclcheck () from /usr/bin/cygwin1.dll
(gdb)
I will eventually get a shell, I stopped paying for an account on mudmagic because I got tired of paying $16 a month before I had a playable mud.

Thanks in advance for your help.
USA #4
Hi Rosko,

What do you get when you type "bt" in gdb? That will give you a backtrace of the function calls, which will let you see which functions called which starting from main and hopefully, will show where the crash is occurring. What you're seeing is a library failure due to a bad system call. Are you compiling with debugging information on, by the way? That should be a flag like -g2, -g3, -ggdb in your makefile.