View Single Post
Old 03-05-2005, 11:44 AM   #3
Yui Unifex
Senior Member
 
Join Date: Apr 2002
Location: Florida
Posts: 323
Yui Unifex is on a distinguished road
Send a message via ICQ to Yui Unifex Send a message via AIM to Yui Unifex
Question

Dispatching tasks is a relatively simple thing to do. Basically, the mud needs to sleep until it is time to dispatch the next task, or it is interrupted by some occurrance like player input.

Determining the which task is next is easy with a priority queue. The C++ standard library contains a implementation you can pop right into your codebase. Using a simple list would mean you have to go through each and every task to determine which fires next. With a priority queue, you can simply ask when the top task needs to fire, and sleep until that time.

I don't think you should queue that sort of thing. In my opinion, only tasks that work on a time delay need be queued. I do not recommend you use global limits on your scheduler to restrict which commands may be issued in battle, since the limit would also restrict other commands issued to the server. Instead, I'd simply restrict commands to that player's turn in battle, or only allow players to execute a command that he has enough action points for. Action point regeneration would be a scheduled task.
Yui Unifex is offline   Reply With Quote