Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 01-27-2005, 10:33 PM   #1
Xerihae
Senior Member
 
Xerihae's Avatar
 
Join Date: Oct 2002
Name: Chris
Location: Wolverhampton, UK
Posts: 358
Xerihae will become famous soon enough
Someone raised this question on a forum I read and while I don't actively work on MUDs any more it piqued my curiosity enough to give it a try...

Working on a stock ROM 2.4b6 base.

Basically, someone suggested a clear command, so that you could clear your input buffer. Useful if you've spammed a bunch of directions but get attacked, or are in a fight and have spammed a bunch of skills in but suddenly get double-teamed.

The command itself is easy, but having little experience with the input/output handlers I am having trouble getting the command put forward to the top of the input list. A quick example:

Bash
Bash
Bash
Clear

I type the first three bashes quickly, but after the first one I want to cancel the other two so I type clear. The command would have to be moved to the top of the list, ahead of the two other bashes, so it would be the next executed.

Maybe this is simple stuff to some of you but it's giving me a headache. I guess that's what I get for trying to code after a year/18 months of not really doing any.

Any solutions greatly appreciated!
Xerihae is offline   Reply With Quote
Old 01-27-2005, 11:20 PM   #2
Tezcatlipoca
Member
 
Join Date: Feb 2003
Posts: 46
Tezcatlipoca is an unknown quantity at this point
It depends on how the input is handled initially. If the input is simply left in the streambuffer until the program is ready to accept another command from the user, then the first step is to make sure that that buffer is cleaned as soon as new input is sent.

This information should then be placed in a queue, statement by statement (the command statement ending with a \n\r). This queue would then be manipulatable enough to perform functions such as "clear" on. (A clear would probably consist of simply going through and freeing the memory currently in the buffer, and nulling out the pointers to those char strings).

It's important to have it in this form before you implement the clear however, since in order for the "clear" command to work, it can't be implemented as an actual command. Instead, as the data arrives, the new "statement" would have to be checked. If it says clear, immediately clear your buffer. If not, then add the contents to the buffer. When the client is ready to accept a new command, simply pop the next command off the queue.
More simply, you're just adding another level to your command interpretation.
Where-as before you had (probably):

Input from TCP protocol --> Application streambuffer --> command recognition --> command execution/error message

You now have:

Input from TCP protocol --> Application streambuffer (dumped upon arrival of full statement) --> pre-processing to check for "clear" --> entry command queue (or clear of queue) --> command recognition --> command execution/error message


We perform a similar process on user input, only we implement more layers between the buffer and command execution then even this model. Thus we've separated commands into "realtime" commands and "gametime" commands: those commands that need to be executed immediately (such as command-queue processing commands), and those that  need to wait until character is ready to execute a new command (following the completion of the last action usually).
Tezcatlipoca is offline   Reply With Quote
Reply


Thread Tools


Input Handler - Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for Player Input Taliena Advertising for Players 0 09-29-2002 08:45 PM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 10:52 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2014