Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ MPSLEEP code Behavior

MPSLEEP code Behavior

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Olcerin   USA  (4 posts)  Bio
Date Fri 02 May 2003 04:36 AM (UTC)
Message
I have been coding SMAUG (and C for that matter), for a relatively short time, so if my subject is an old one excuse me.

I had put MPSLEEP V 1.00 by Rasmus Brosboel snippet onto the mud sometime back and am now fighting to figure out why mob progs that have the mpsleep command in them skip ELSE statements entirely. This is not the case when the same program is run as an ENTRY on a room, rather than a GREET on a mob.

I understand from chatting with some folks on I3 that MPSLEEP is notoriously buggy in behavior, so I am posting to ask if anyone has already fought this same fight I'm having, and if so if they could save me some time and frustration by sharing the wealth, or at least point me in the right direction on this. The odd use of arrays and BOOLs and such makes it really difficult for someone at my current level of coding to make much sense at all of mud_prog_driver, much less fix anything in it. LOL

Thanks
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #1 on Sat 03 May 2003 09:56 AM (UTC)
Message
Afraid most of us cant really do much to help you without either the code posted here or (preferably) a link to where you got the snipet so we can download it and disect it for probable causes to your problem. FYI, the problem with buggy snipets is true for all codebases and particularly so for smaug. Also posting one of the actual progs thats giving your problems would help as well.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Olcerin   USA  (4 posts)  Bio
Date Reply #2 on Tue 06 May 2003 11:58 AM (UTC)
Message
The mpsleep snippet I refer to, I d/l'd
here: http://www.geocities.com/knytehawk/smaug/index.html

However the same code is found in many other places such as kyndig's, and others as well. There are mentions of it in several spots in the smaug mailings lists but no real discussion of known bugs that I found.

A very, very strange development in my valiant battle with the demon bugs. My friend running red hat 8.0 on his linux box ran the mud as it is on the linux 7.2 mud server we're on, and there are no problems with the mud progs whatsoever. So, what I'm figuring on doing is fresh install everything back to stock, then drop my src and systemm folder in and see if the progs work. After that I'll put in the area and player files and check again.

I have no idea how it'd be possible for it to work on his box, but not work on the mud server, but the above is all I can think of to try as far as that goes.

After the complicated mud prog that didn't work that discovered our friendly kludgemonster, I made a "test prog" while trying to work it out. I put it
here:
>greet_prog 100
if level($n) > 5
if ispc($n)
mpecho you are a pc
mpsleep 10
mpechoat $n else comming up
mpsleep 5
mpechoat $n else now!
else
mpsleep 1
mpsleep 1
mpsleep 5
mpechoat $n you are here!
mpsleep 2
mpsleep 3
mpecho you aren't a pc!
endif
endif
What that results in after triggered is the entire thing running, skipping the else:
Some god abandoned a newly created Test mob here.
you are a pc


else comming up


else now!


you are here!


you aren't a pc!

As far as digging into the code, I appreciate even the idea someone would take the time. First though, let me do this fresh install thing (however absurd it may seem), and see if that does anything, so as not to waste anyones time.
I really was posting here more hoping that someone had notes or fixes from this already than hunting for someone to fix the thing for me if they hadn't :)

Thanks
Olcerin,
"I'm not lazy...just don't ask any of my friends..."
Top

Posted by Olcerin   USA  (4 posts)  Bio
Date Reply #3 on Tue 06 May 2003 01:30 PM (UTC)
Message
Got it.. the big kahuna saint of coders led my noobie eyes right to it after posting that last post. I'm posting here in case someone wants to use that mpsleep(when it works it's awesome btw). Fix this or it'll skip ELSE statements in mudprogs that contain the command, and was screwing up nested if's a bit that didn't have ELSE's on occasion, too.
I guess the formatting of the board here might screw up the code indents, but I wanted to share this. This code is in the snippet, to go into mud_prog.c :

for (count = 0; count < MAX_IFS; count++)
{
/* for (count2 = 0; count2 < DO_ELSE; count2++) */
/* line above the culprit to replace */
for (count2 = 0; count2 <= DO_ELSE; count2++)
/* line above what to replace it with */
ifstate[count][count2] =
current_mpsleep->ifstate[count][count2];
}

Oh, and hey thanks again for replying, I'm new to this board and the ones I've frequented before are pretty hot and cold about ever getting an answer, so I appreciate it.
Sorry about wasting anyones time who looked into it any.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #4 on Tue 02 Aug 2005 05:00 AM (UTC)
Message
Does anyone have any more issues like this? I am having one even with the fix above.
>custom_prog rock
if ovnuminv(4727) < 1
  say Insert 100 yen first if you want to play!
else
  mea $n You hit the rock button.
  mer $n $n hits the rock button.
  mpsleep 12
  mpecho R.P.C Robot makes a fist, raises it up, then bangs it down in the air once.
  say One!
  mpsleep 12
  mpecho R.P.C Robot makes a fist, raises it up, then bangs it down in the air again.
  say Two!
  mpsleep 12
  if rand(50)
    mpecho R.P.C Robot makes a fist, raises it up, then brings it down making a rock with its fist.
    say It's a tie!
    say Let's try again. Press Rock, Paper, or Scissors.
  else
    if rand(50)
      mpecho R.P.C Robot makes a fist, raises it up, then brings it down making a paper with its hand.
      say Paper beats rock! You lose!
      say Insert 100 yen if you want to try play again.
      mpjunk start
      mpjunk all.wins
    else
      mpecho R.P.C Robot makes a fist, raises it up, then brings it down making a scissors with two fingers.
      say Rock beats scissors! You win!
      mpoload 4728
      say If you want to try for higher prizes, press ROCK, PAPER, or SCISSORS to play another round. But if you lose, you'll lose everything! Otherwise press CASH IN to cash in your wins. Remember that the more times you win the higher the reward!
    endif
  endif
endif


You hit the rock button.
R.P.C Robot makes a fist, raises it up, then bangs it down in the air once.
R.P.C Robot says 'One!'
R.P.C Robot makes a fist, raises it up, then bangs it down in the air again.
R.P.C Robot says 'Two!'
R.P.C Robot makes a fist, raises it up, then brings it down making a rock with its fist.
R.P.C Robot says 'It's a tie!'
R.P.C Robot says 'Let's try again. Press Rock, Paper, or Scissors.'

The above has no waits/sleeps, it all happens at once. Why aren't the mpsleeps going through...

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #5 on Wed 03 Aug 2005 05:11 AM (UTC)
Message
I have had many, MANY problems with else statements with MPSLEEP. I am seriously considering ripping out the old stuff and just redoing it myself. On a largish mud that I code on (50+ players) I can't count how many crashes just from MPSLEEP progs. If I do re-do it, I'll post it around.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #6 on Wed 03 Aug 2005 02:51 PM (UTC)
Message
You get crashes from mpsleep? That's something I've never gotten. I suppose I'm lucky.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #7 on Wed 03 Aug 2005 08:25 PM (UTC)
Message
While I don't have a very active mud (not public, I work on it when I have time), I've never had a problem with MPSLEEP.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #8 on Wed 03 Aug 2005 09:39 PM (UTC)
Message
Hm, could you test out the prog I posted perhaps then? Let me know if it works.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #9 on Thu 04 Aug 2005 06:23 AM (UTC)
Message
Ok, modified it to make it a room prog with no rewards. This is the prog I made:

>speech_prog Rock
mea $n You hit the rock button.
mer $n $n hits the rock button.
mpsleep 12
mpecho One!
mpsleep 12
mpecho Two!
mpsleep 12

if rand(50)
  mpecho Rock! Tie!
else
  if rand(50)
   mpecho Paper! Paper beats Rock! Loser!
  else
   mpecho Scissors! Rock beats scissors! You win!
  endif
endif


And this is what resulted (i tried it twice):
--
[Hp:32700/32700] [Mv:30000/30000] (Align:0) say rock
You say: rock
You hit the rock button.

[Hp:32700/32700] [Mv:30000/30000] (Align:0)
One!

[Hp:32700/32700] [Mv:30000/30000] (Align:0)
Two!

[Hp:32700/32700] [Mv:30000/30000] (Align:0)
Paper! Paper beats Rock! Loser!

[Hp:32700/32700] [Mv:30000/30000] (Align:0)


[Hp:32700/32700] [Mv:30000/30000] (Align:0) say rock
You say: rock
You hit the rock button.

[Hp:32700/32700] [Mv:30000/30000] (Align:0)
One!

[Hp:32700/32700] [Mv:30000/30000] (Align:0)
Two!

[Hp:32700/32700] [Mv:30000/30000] (Align:0)
Rock! Tie!

--

Looks alright to me I guess. There were correct pauses each time. My MPSLEEP currently came with SWFotE 2.0, and I applied the fix posted above (change the < to <=) for both instance's that required it.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #10 on Thu 04 Aug 2005 07:14 AM (UTC)

Amended on Thu 04 Aug 2005 08:46 AM (UTC) by Nick Cash

Message
It does appear mobs are a bit more touchy, however. The following prog did not work per se.

>greet_prog 100
if isnpc($n)
mpecho you are a pc
mpsleep 10
mpecho woot
mpsleep 5
mpecho else now!
else
mpsleep 1
mpecho w
mpsleep 1
mpecho oo
mpsleep 1
mpecho t
mpsleep 5
mpecho you are here!
mpsleep 5
say you arent a pc!
endif


I am certainly not an npc and the else didn't work at all. I guess I'll have to look at this a bit more...

[EDIT]
While messing around with this, I've found something strange I think. If it finds the if false then it records it and moves on, but still (obviously) read the commands in between. Mpsleep is not an mpcommand, it is an ifcheck (in mine anyway).

It still records the mpsleep's for the if, which is quite wrong, and possibly screws things up. Not really sure, but I know it definitely shouldnt be happening. Perhaps moving the mpsleep stuff to functions would be better.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #11 on Thu 04 Aug 2005 10:30 AM (UTC)
Message
Alright, figured it out finally. The only reason its skipping else statements is because its set to ignore them. Apparently when the ifstate block is copied into the mpsleep ifstate it doesnt carry the last DO_ELSE, which is vital.

If you are like me, your mpsleep struct looks similar to this:

struct mpsleep_data
{
 MPSLEEP_DATA * next;
 MPSLEEP_DATA * prev;

 int timer; /* Pulses to sleep */
 mp_types type; /* Mob, Room or Obj prog */
 ROOM_INDEX_DATA *room; /* Room when type is MP_ROOM */

 /* mprog_driver state variables */
 int ignorelevel;
 int iflevel;
 bool ifstate[MAX_IFS][DO_ELSE];

 /* mprog_driver arguments */
 char * com_list;
 CHAR_DATA * mob;
 CHAR_DATA * actor;
 OBJ_DATA * obj;
 void * vo;
 bool single_step;
};


Take a close look at the ifstate array. Notice whats wrong? No? Ok. DO_ELSE is set to 3. This means its only recording IN_IF, IN_ELSE, and DO_IF. No DO_ELSE, which means we will ignore the else statement. Simple fix should be changing that line to this:

 bool ifstate[MAX_IFS][DO_ELSE+1];


That seems to have fixed the problem for me. In any event, you may be having uneeded pauses because the mpsleep's from your if may still execute when you don't want them to. You can fix this by doing:

 if (!str_prefix("mpsleep", cmnd) )
 {
   if ( (ifstate[iflevel][IN_IF] == TRUE && ifstate[iflevel][DO_IF] == FALSE) ||     // if we are in an if/else and we
        (ifstate[iflevel][IN_ELSE] == TRUE && ifstate[iflevel][DO_ELSE] == FALSE) )  // dont want to execute, dont..
   {
   }
  else
  {

Everything within the if should be contained in the new else statement. Don't forget to add the ending brace. Alternatively you could add a ! and make it just an if. Personally I don't care and I feel like going to sleep now...

Lemme know if it works for you! :)

PS: Make sure you applied the original fix too

~Nick Cash
http://www.nick-cash.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #12 on Thu 04 Aug 2005 02:40 PM (UTC)

Amended on Thu 04 Aug 2005 02:46 PM (UTC) by Zeno

Message
I don't see why that first prog worked for you. I also have the fix applied.
 for (count = 0; count < MAX_IFS; count++)
 {
 for (count2 = 0; count2 <= DO_ELSE; count2++)
 ifstate[count][count2] =
 current_mpsleep->ifstate[count][count2];
 }


Did I miss something?

I will edit when I try your fix.

[EDIT] Applied your fix, the prog I pasted still does not pause at all.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by USER007   (124 posts)  Bio
Date Reply #13 on Thu 04 Aug 2005 04:28 PM (UTC)

Amended on Thu 04 Aug 2005 04:30 PM (UTC) by USER007

Message
I decided to test it out too and pasted the same progs to a mob.


Name: ATM.  Vnum: 10009.
Short description: An ATM machine.
Long  description: An ATM machine is stationed here.
Hp: 100/100.  Mana: 5000/5000.  Move: 100/100. 
Lv: 1.  Class: 7.  Align: 0.  AC: 100.  Gold: 0.  Exp: 0.
>greet_prog 100
if isnpc($n)
mpecho you are a pc
mpsleep 10
mpecho woot
mpsleep 5
mpecho else now!
else
mpsleep 1
mpecho w
mpsleep 1
mpecho oo
mpsleep 1
mpecho t
mpsleep 5
mpecho you are here!
mpsleep 5
say you arent a pc!
endif

>speech_prog Rock
mea $n You hit the rock button.
mer $n $n hits the rock button.
mpsleep 12
mpecho One!
mpsleep 12
mpecho Two!
mpsleep 12
if rand(50)
  mpecho Rock! Tie!
else
  if rand(50)
   mpecho Paper! Paper beats Rock! Loser!
  else
   mpecho Scissors! Rock beats scissors! You win!
  endif
endif


And these are my results.

First prog:
A demon creature arrives from the west.
you are a pc

<Hp [100] Mana [740] Move [1,097]>
woot

<Hp [100] Mana [740] Move [1,097]>
else now!

<Hp [100] Mana [740] Move [1,097]>
Anavel arrives from the west.

<Hp [100] Mana [740] Move [1,097]>
w
oo
t

<Hp [100] Mana [740] Move [1,097]>
you are here!

<Hp [100] Mana [740] Move [1,097]>
An ATM machine says 'you arent a pc!'

<Hp [100] Mana [740] Move [1,097]>

Second prog:
Anavel says 'rock'
Anavel hits the rock button.

<Hp [100] Mana [740] Move [1,097]>
One!

<Hp [100] Mana [740] Move [1,097]>
Two!

<Hp [100] Mana [740] Move [1,097]>
Paper! Paper beats Rock! Loser!

<Hp [100] Mana [740] Move [1,097]>
You say 'rock'
You hit the rock button.

<Hp [100] Mana [740] Move [1,097]>
One!

<Hp [100] Mana [740] Move [1,097]>
Two!

<Hp [100] Mana [740] Move [1,097]>
Rock! Tie!

I haven't changed anything in the mpsleep
code except adding the fixes from this thread.
I've also never gotten a crash from using
mpsleep. Hope this helps somehow...
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #14 on Thu 04 Aug 2005 07:48 PM (UTC)

Amended on Thu 04 Aug 2005 07:57 PM (UTC) by Nick Cash

Message
I'm not sure what you could have missed Zeno. There were (I think) 3 instances for me to apply the above fix (< to <=), and then my fix and everything seemed alright. Maybe our distrobutions are different, or perhaps you installed it wrong?

I don't really know. Perhaps you could download the SWFotE 2.0 code, apply the fix, and disect it to see how yours is different.

By the way Greven, I have never had it crash except a brief time when I tried a few things. If have played with yours much you probably call strcpy on a null com_list. Thats where all of my issues came from later.

Anavel, did the prog's have the correct pauses? It looks like the room prog worked fine but that there was still an issue with the mob greet prog. I'll test mine again and see how it goes.

~Nick Cash
http://www.nick-cash.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


59,728 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.