[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Stacking timers again.
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Stacking timers again.

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


Pages: 1 2  

Posted by Spike   (27 posts)  [Biography] bio
Date Wed 29 Jun 2005 03:50 AM (UTC)
Message
Hey guys,

I'v done alot..more then I think I should be able to considering my knowlege (or lack there of) on coding princables. Hense why I find my self in the prediciment I am in now I'm still stuck on having it so I can stack timers (via add_timer). I have timers that cant be escaped via, CANNOT_ABORT in the right area or somthing like that. But the timers will not stack IE, the timer that was running in a command a second ago would finish and execute but nothing would happen after if you typed the commands twice or more.

I'm probably not being clear, basicly what I have been trying to do is have it so I can type somthing like.

dig
dig
dig

And given I have it so dig is uninterrupptable, the following digs would stack so that when the first one is up the second one would start, and so on.

This small snippet I belive said it would allow timer stacking but I do not see how:

http://www.auricmud.com/snippets/timedelayedcommand.c

Can anyone lend any input into my problem?



Thank you
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Thu 30 Jun 2005 07:46 AM (UTC)
Message
I'm not sure I quite understand what's going on. Could you be a little more specific? If I'm understanding correctly, the timer will happen once, but no stacking occurs beyond the first one. So you can type dig twice and get two digs, but typing three or thirty is the same as two.

As for the timer snippet, that seems to be something else entirely: time-delayed commands, not queuing up commands waiting for previous ones to finish.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Spike   (27 posts)  [Biography] bio
Date Reply #2 on Thu 30 Jun 2005 08:17 PM (UTC)
Message
No no..if I spam dig and change it so dig can be cancelled it simply ignores the other commands. I want it so dig can be spammed..and the commands get stuck in que. So if someone stupidly typed dig 15 times...they would dig...it would finish and go to the next dig...it would finish and go to the next...all 15 times.



Thanks
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #3 on Thu 30 Jun 2005 09:47 PM (UTC)
Message
So you're saying that if you make it cancellable, it doesn't queue them up?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Spike   (27 posts)  [Biography] bio
Date Reply #4 on Fri 01 Jul 2005 03:41 AM (UTC)
Message
If I remove the sub_timer_cannot_abort or whatever I set the state to..it just exits out of the timer.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #5 on Fri 01 Jul 2005 06:04 PM (UTC)
Message
I'm afraid I'm not understanding. Either you'll have to be more precise or you'll have to show some code and explain what exactly you're talking about.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Spike   (27 posts)  [Biography] bio
Date Reply #6 on Fri 01 Jul 2005 07:40 PM (UTC)
Message
Hrmm I dont know how I can be more clear.

To put it to basics, If you type dig you begin digging with the code like this:

case SUB_TIMER_DO_ABORT:
DISPOSE( ch->alloc_ptr );
ch->substate = SUB_NONE;
send_to_char( "You stop digging...\n\r", ch );
act( AT_PLAIN, "$n stops digging...", ch, NULL, NULL, TO_ROOM );
return;
}


If you type anything you stop digging, thats not what I want I want it so you can type things and not stop digging..that I can do. I do that by changing
ch->substate = SUB_NONE; to ch->substate = SUB_TIMER_CANT_ABORT; Now if you type dig multiple times while it's currently digging it just ignores you when you time dig after that till it's complete. I dont want it to ignore the commands that come after it.

So if I spam dig five times, it causes the player to be stuck digging 5 times with no way to stop till the 5 times are up. So in game it would like like this:

Player types:

dig
dig
dig
dig
dig

and from there on they will be stuck digging till all 5 digs are up.

You start digging.
-timer-
You have found nothing!
You start digging.
-timer-
You have found nothing!

Etc, Etc I hope I explained it better this time. It's as explained as I can get it.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #7 on Fri 01 Jul 2005 07:52 PM (UTC)
Message
Well, that code you posted isn't the code that starts the digging. In fact it's quite the opposite; it's the code that stops the digging if the player types something while the dig is in progress.

There are a number of ways of doing this. Some are very simple but not very powerful (e.g. they limit you to only queuing up dig.) Others are more complex but also more powerful.

I'd suggest starting simple. The first thing to ask is: do you truly understand the existing timer/substate system? The reason I've been prodding you with all these questions is to see how well you grasp that. You'll need to fully understand it before you even attempt to move on.

Where in the code do you end up at the end of a dig? That part is where you'll want to check if another dig is waiting, and if so, start the timer process again. (This is one of the simpler and much less powerful ways of handling things.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Spike   (27 posts)  [Biography] bio
Date Reply #8 on Fri 01 Jul 2005 08:06 PM (UTC)
Message
Hrmm I understand the actual timer part just fine, bad wording on my part I guess. My problem was I thought while set to CANNOT_ABORT it pretty , much ignores the following digs.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #9 on Fri 01 Jul 2005 08:14 PM (UTC)
Message
Well, obviously it'll ignore the rest. You have to actually queue them up, it won't do it on its own. Look at this code from interp.c:
Quote:
    /* check for a timer delayed command (search, dig, detrap, etc) */
    if ( (timer=get_timerptr(ch, TIMER_DO_FUN)) != NULL )
    {
	int tempsub;

	tempsub = ch->substate;
	ch->substate = SUB_TIMER_DO_ABORT;
	(timer->do_fun)(ch,"");
	if ( char_died(ch) )
	    return;
	if ( ch->substate != SUB_TIMER_CANT_ABORT )
	{
	    ch->substate = tempsub;
	    extract_timer( ch, timer );
	}
	else
	{
	    ch->substate = tempsub;
	    return;
	}
    }
So somewhere in all of this, you're going to have to queue up commands. What you're doing is not letting the dig abort, fine, but where is it going to queue the next commands? When the code realizes it can't abort, it returns: look at the code I posted.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Spike   (27 posts)  [Biography] bio
Date Reply #10 on Fri 01 Jul 2005 09:41 PM (UTC)
Message
And here is where you lose me, heh I dont understand anything up untill this point.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #11 on Fri 01 Jul 2005 09:48 PM (UTC)
Message
Well, can you describe to me how you think these timers and substates work? Be as precise as possible - the more I understand about your perception, the more I can help you.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Spike   (27 posts)  [Biography] bio
Date Reply #12 on Fri 01 Jul 2005 10:13 PM (UTC)
Message
To be honest I understand how they work as in how to use them, and little past that, it appears it simply adds a timer to the charecter via linked list.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #13 on Fri 01 Jul 2005 11:38 PM (UTC)
Message
What happens, then, when you're waiting on the timer, and the player types dig again? Where does the code go? Describe the sequence of function calls that a) starts the timer, b) interrupts the timer, c) finishes executing the timer normally. You'll need to look at that and understand it to figure out how to start stacking up timers.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Spike   (27 posts)  [Biography] bio
Date Reply #14 on Sat 02 Jul 2005 03:42 AM (UTC)
Message
Thats where I'm lost I can track whats happening through adding the timer within the command, but past that I'm lost. I imagin it has somthing to do with interp.c past that, thats why I'm here asking for help.
[Go to top] 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.


11,390 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] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]