Between me and a few people talking, we brought up the idea of being able to clear stacked commands on a SMAUG ( well, SWR, but for these purposes, same thing ). Now, as I follow the process, this happens: A person sends a command from their client to the host machine. This machine, using port info, routes it to the open file descriptor associated with the processes PID. When the mud reaches the point where it checks for new commands, it will try to read in from the appropriate file descriptor. If there is nothing there, it doesn't do anything, like the character was idling. If there is something there, then it read it in and adds it into d->inbuf, where it can later be processed by interpret.
Now, most of this that I cam going off of if in read_from_descriptor. The tricky part, I think, is that the mud checks if there is a pending command to finish before reading in the next one. So, for example, if their last command hasn't finished, because of a wait state for example, it will not read in from the file descriptor. No, I understand that this probably was intended to stop overflows of buffers, which makes sense.
Now, if someone has a wait state, for example, they can stack multiple commands, and these stay in the file descriptor, not the mud. So, what we want to do is check if a specific phrase has been entered ( "clear" by its self, for example ), and if so, flush the file descriptors buffer.
We have thought of a few ways, but not sure if/how they would work properly. One was to read everything in all at once, check through it for the clear command, and if its not there, write it all back, stripping off the begining line, of course, as this is the next command. If it is there, then just dispose of all of the infomation, effectively flushing it.
Another thought was to use fseek, or something similiar, to try to find the phrase, and use rewind to put it back if its not found, or everything after it is found.
Any thoughts, or maybe something like this has been done, and a lot more simply than described above? |