TinyMUSH 3.3
TinyMUSH Server
|
Commands and functions for manipulating the command queue. More...
#include "config.h"
#include "constants.h"
#include "typedefs.h"
#include "macros.h"
#include "externs.h"
#include "prototypes.h"
#include <stdbool.h>
#include <string.h>
#include <limits.h>
Functions | |
int | a_Queue (dbref, int) |
void | s_Queue (dbref, int) |
int | QueueMax (dbref) |
void | delete_qentry (BQUE *qptr) |
Delete and free a queue entry. More... | |
int | add_to (dbref doer, dbref player, int am, int attrnum) |
Adjust an object's queue or semaphore count. More... | |
void | give_que (BQUE *tmp) |
Thread a queue block onto the high or low priority queue. More... | |
bool | que_want (BQUE *entry, dbref ptarg, dbref otarg) |
Do we want this queue entry? More... | |
int | halt_que (dbref player, dbref object) |
Remove all queued commands from a certain player. More... | |
void | remove_waitq (BQUE *qptr) |
Remove an entry from the wait queue. More... | |
void | do_halt_pid (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)), char *pidstr) |
Halt a single queue entry. More... | |
void | do_halt (dbref player, dbref cause, int key, char *target) |
Command interface to halt_que. More... | |
int | nfy_que (dbref player, dbref sem, int attr, int key, int count) |
Notify commands from the queue and perform or discard them. More... | |
void | do_notify (dbref player, dbref cause __attribute__((unused)), int key, char *what, char *count) |
Command interface to nfy_que. More... | |
int | qpid_next (void) |
Get the next available queue PID. More... | |
BQUE * | setup_que (dbref player, dbref cause, char *command, char *args[], int nargs, GDATA *gargs) |
Set up a queue entry. More... | |
void | wait_que (dbref player, dbref cause, int wait, dbref sem, int attr, char *command, char *args[], int nargs, GDATA *gargs) |
Add commands to the wait or semaphore queues. More... | |
void | do_wait_pid (dbref player, int key, char *pidstr, char *timestr) |
Adjust the wait time on an existing entry. More... | |
void | do_wait (dbref player, dbref cause, int key, char *event, char *cmd, char *cargs[], int ncargs) |
Command interface to wait_que. More... | |
int | que_next (void) |
Return the time in seconds until the next command should be run from the queue. More... | |
void | do_second (void) |
Check the wait and semaphore queues for commands to remove. More... | |
int | do_top (int ncmds) |
Execute the command at the top of the queue. More... | |
void | show_que (dbref player, int key, BQUE *queue, int *qtot, int *qent, int *qdel, dbref player_targ, dbref obj_targ, const char *header) |
tell player what commands they have pending in the queue More... | |
void | do_ps (dbref player, dbref cause __attribute__((unused)), int key, char *target) |
List queue. More... | |
void | do_queue (dbref player, dbref cause __attribute__((unused)), int key, char *arg) |
Queue management. More... | |
Variables | |
int | qpid_top = 1 |
Commands and functions for manipulating the command queue.
int add_to | ( | dbref | doer, |
dbref | player, | ||
int | am, | ||
int | attrnum | ||
) |
Adjust an object's queue or semaphore count.
doer | Dbref of doer |
player | DBref of player |
am | Attribute map |
attrnum | Attribute number |
void delete_qentry | ( | BQUE * | qptr | ) |
Delete and free a queue entry.
qptr | Queue entry |
void do_halt | ( | dbref | player, |
dbref | cause, | ||
int | key, | ||
char * | target | ||
) |
Command interface to halt_que.
player | DBref of player |
cause | DBref of cause |
key | Key |
target | Target to halt |
Figure out what to halt
void do_halt_pid | ( | dbref | player, |
dbref cause | __attribute__(unused), | ||
int key | __attribute__(unused), | ||
char * | pidstr | ||
) |
Halt a single queue entry.
player | DBref of player |
cause | DBref of cause |
key | Key |
pidstr | Pîd of the queue |
Changing the player to NOTHING will flag this as halted, but we may have to delete it from the wait queue as well as the semaphore queue.
void do_notify | ( | dbref | player, |
dbref cause | __attribute__(unused), | ||
int | key, | ||
char * | what, | ||
char * | count | ||
) |
Command interface to nfy_que.
player | DBref of player |
cause | DBref of cause |
key | Key |
what | Command |
count | Counter |
Do they have permission to set this attribute?
void do_ps | ( | dbref | player, |
dbref cause | __attribute__(unused), | ||
int | key, | ||
char * | target | ||
) |
List queue.
player | DBref of player |
cause | DBref of cause |
key | Key |
target | Target |
Figure out what to list the queue for
Go do it
Display stats
void do_queue | ( | dbref | player, |
dbref cause | __attribute__(unused), | ||
int | key, | ||
char * | arg | ||
) |
Queue management.
player | DBref of player |
cause | DBref of cause |
key | Key |
arg | Arguments |
Handle the wait queue
Handle the semaphore queue
void do_second | ( | void | ) |
Check the wait and semaphore queues for commands to remove.
move contents of low priority queue onto end of normal one this helps to keep objects from getting out of control since its affects on other objects happen only after one second this should allow @halt to be type before getting blown away by scrolling text
the point->waittime test would be 0 except the command is being put in the low priority queue to be done in one second anyway
Do the wait queue
Check the semaphore queue for expired timed-waits
< Skip if not timed-wait
int do_top | ( | int | ncmds | ) |
Execute the command at the top of the queue.
ncmds | Number of commands to execute |
Load scratch args
< gotta check this, as the value's * changed
void do_wait | ( | dbref | player, |
dbref | cause, | ||
int | key, | ||
char * | event, | ||
char * | cmd, | ||
char * | cargs[], | ||
int | ncargs | ||
) |
Command interface to wait_que.
player | DBref of player |
cause | DBref of cause |
key | Key |
event | Event |
cmd | Command |
cargs | Command arguments |
ncargs | Number of commands |
If arg1 is all numeric, do simple (non-sem) timed wait.
Semaphore wait with optional timeout
Get timeout, default 0
thing over-notified, run the command immediately
void do_wait_pid | ( | dbref | player, |
int | key, | ||
char * | pidstr, | ||
char * | timestr | ||
) |
Adjust the wait time on an existing entry.
player | DBref of player |
key | Key |
pidstr | PID of the entry |
timestr | Wait time |
The semaphore queue is unsorted, but the main wait queue is sorted. So we may have to go rethread.
void give_que | ( | BQUE * | tmp | ) |
Thread a queue block onto the high or low priority queue.
tmp | Queue Entry |
int halt_que | ( | dbref | player, |
dbref | object | ||
) |
Remove all queued commands from a certain player.
player | DBref of player |
object | DBref of object |
Player queue
Object queue
Wait queue
Semaphore queue
int nfy_que | ( | dbref | player, |
dbref | sem, | ||
int | attr, | ||
int | key, | ||
int | count | ||
) |
Notify commands from the queue and perform or discard them.
player | DBref of player |
sem | DBref of sem |
attr | Attributes |
key | Key |
count | Counter |
Either run or discard the command
If we've notified enough, exit
Update the sem waiters count
int qpid_next | ( | void | ) |
Get the next available queue PID.
int que_next | ( | void | ) |
Return the time in seconds until the next command should be run from the queue.
If there are commands in the player queue, we want to run them immediately.
If there are commands in the object queue, we want to run them after a one-second pause.
< Skip if no timeout
bool que_want | ( | BQUE * | entry, |
dbref | ptarg, | ||
dbref | otarg | ||
) |
Do we want this queue entry?
entry | Queue Entry |
ptarg | Player target |
otarg | Object target |
void remove_waitq | ( | BQUE * | qptr | ) |
Remove an entry from the wait queue.
qptr | Queue Entry |
Head of the queue. Just remove it and relink.
Go find it somewhere in the queue and take it out.
BQUE * setup_que | ( | dbref | player, |
dbref | cause, | ||
char * | command, | ||
char * | args[], | ||
int | nargs, | ||
GDATA * | gargs | ||
) |
Set up a queue entry.
player | DBref of player |
cause | DBref of cause |
command | Command |
args | Arguments |
nargs | Number of arguments |
gargs | Global registers |
Can we run commands at all?
make sure player can afford to do it
Wizards and their objs may queue up to db_top+1 cmds. Players are limited to QUEUE_QUOTA. -mnp
halt also means no command execution allowed
Generate a PID
We passed all the tests, calculate the length of the save string.
Create the queue entry and load the save string
Set up registers and whatnot
Load the rest of the queue block
void show_que | ( | dbref | player, |
int | key, | ||
BQUE * | queue, | ||
int * | qtot, | ||
int * | qent, | ||
int * | qdel, | ||
dbref | player_targ, | ||
dbref | obj_targ, | ||
const char * | header | ||
) |
tell player what commands they have pending in the queue
player | DBref of player |
key | Key |
queue | Queue Entry |
qtot | Queue Total |
qent | Queue Entries |
qdel | Queue Deleted |
player_targ | DBref of player target |
obj_targ | DBref of object target |
header | Header |
A minor shortcut. We can never timeout-wait on a non-Semaphore attribute.
void wait_que | ( | dbref | player, |
dbref | cause, | ||
int | wait, | ||
dbref | sem, | ||
int | attr, | ||
char * | command, | ||
char * | args[], | ||
int | nargs, | ||
GDATA * | gargs | ||
) |
Add commands to the wait or semaphore queues.
player | DBref of player |
cause | DBref of cause |
wait | Delay |
sem | Semaphores |
attr | Attributes |
command | Command |
args | Arguments |
nargs | Number of arguments |
gargs | Global registers |
Set wait time, and check for integer overflow
No semaphore, put on wait queue if wait value specified. Otherwise put on the normal queue.