Amulets & Armor  v1.02
Open Source Game
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Typedefs | Enumerations | Functions | Variables
CMDQUEUE

Queue of Packets and Commands for Networking. More...

Data Structures

struct  T_cmdQPacketStructTag
 
struct  T_cmdQStruct
 
struct  T_cmdQueueInfo
 

Typedefs

typedef struct
T_cmdQPacketStructTag 
T_cmdQPacketStruct
 
typedef T_cmdQActionRoutineT_comQActionList
 

Enumerations

enum  E_packetCommandType { PACKET_COMMAND_TYPE_LOSSLESS, PACKET_COMMAND_TYPE_LOSSFUL }
 

Functions

T_void CmdQClearAllPorts (T_void)
 
T_void CmdQFinish (T_void)
 
T_void CmdQForcedReceive (T_packetEitherShortOrLong *p_packet)
 
T_word16 CmdQGetActivePortNum (T_void)
 
T_void CmdQInitialize (T_void)
 
T_void CmdQRegisterClientCallbacks (T_cmdQActionRoutine *callbacks)
 
T_void CmdQSendLongPacket (T_packetLong *p_packet, T_word16 retryTime, T_word32 extraData, T_cmdQPacketCallback p_callback)
 
T_void CmdQSendPacket (T_packetEitherShortOrLong *p_packet, T_word16 retryTime, T_word32 extraData, T_cmdQPacketCallback p_callback)
 
T_void CmdQSendShortPacket (T_packetShort *p_packet, T_word16 retryTime, T_word32 extraData, T_cmdQPacketCallback p_callback)
 
T_void CmdQSetActivePortNum (T_word16 num)
 
T_void CmdQUpdateAllReceives (T_void)
 
T_void CmdQUpdateAllSends (T_void)
 
T_void ICmdQDiscardPacket (T_byte8 commandNum)
 
T_void ICmdQSendPacket (T_packetEitherShortOrLong *p_packet, T_word16 retryTime, T_word32 extraData, T_cmdQPacketCallback p_callback)
 
T_void ICmdQUpdateSendForPort (T_void)
 

Variables

T_word32 G_packetsAlloc = 0
 
T_word32 G_packetsFree = 0
 

Detailed Description

Queue of Packets and Commands for Networking.

The CmdQueue (or "Command Queue") is used to store up requests from the client to the server. As the commands are sent, an ACK packet must be received before the next one is processed. BUT, this isn't a linear list of commands, but a list per packet type allowing most commands to be handled in a mostly parallel format. Most of this is code has been replaced by the CSYNCPCK synchronized communication code and the rest is incorrectly implemented for a peer to peer network instead of a client/server network. MORE WORK GOES HERE!

See Also
http://www.amuletsandarmor.com/AALicense.txt

Typedef Documentation

Enumeration Type Documentation

Enumerator
PACKET_COMMAND_TYPE_LOSSLESS 
PACKET_COMMAND_TYPE_LOSSFUL 

Function Documentation

T_void CmdQClearAllPorts ( T_void  )

CmdQClearAllPorts goes through each port and clears out any packets that are waiting to be sent or are incoming. ACK packets are left alone.

NOTE: Make sure that this routine is only called when all communications are finalized.

T_void CmdQFinish ( T_void  )

CmdQFinish unallocates any memory or structures that are no longer need by the CmdQ module.

T_void CmdQForcedReceive ( T_packetEitherShortOrLong p_packet)

CmdQForcedReceive makes the command queue act like it just received the packet from the inport. All processing is the same.

NOTE: NEVER PASS AN ACK PACKET TO THIS ROUTINE. It does not properly work with them. Be sure to make a call to CmdQSetActivePortNum or else this routine will be unpredictable.

Parameters
p_packet– Packet being forced in
T_word16 CmdQGetActivePortNum ( T_void  )

CmdQGetActivePortNum returns the number of the active port being used.

Returns
Number of port.
T_void CmdQInitialize ( T_void  )

CmdQInitialize clears out all the variables that are necessary for the CmdQ module.

NOTE: This routine needs to be called AFTER all ports are opened.

T_void CmdQRegisterClientCallbacks ( T_cmdQActionRoutine callbacks)

These functions each take a pointer to an array of function pointers, with PACKET_COMMAND_MAX entries. ..ServerCallbacks sets this pointer as the list of server packet callbacks, and ..ClientCallbacks sets this as the list of client packet callbacks.

T_void CmdQSendLongPacket ( T_packetLong p_packet,
T_word16  retryTime,
T_word32  extraData,
T_cmdQPacketCallback  p_callback 
)

CmdQSendLongPacket prepares a long packet for sending and sends it over to ICmdQSendPacket for processing.

Parameters
p_packet– Packet to send
retryTime– How long to wait for acknowledgement before trying to send again.
extraData– Extra data for the callback routine.
p_callback– Routine to be called when either the packet is lost or sent.
T_void CmdQSendPacket ( T_packetEitherShortOrLong p_packet,
T_word16  retryTime,
T_word32  extraData,
T_cmdQPacketCallback  p_callback 
)

CmdQSendPacket sets up a short or long packet for sending (and does so by calling CmdQSendShortPacket or CmdQSendLongPacket).

NOTE: The packetLength field in the packet's header field MUST be set to either short or long.

Parameters
p_packet– Packet to send
retryTime– How long to wait for acknowledgement before trying to send again.
extraData– Extra data for the callback routine.
p_callback– Routine to be called when either the packet is lost or sent.
T_void CmdQSendShortPacket ( T_packetShort p_packet,
T_word16  retryTime,
T_word32  extraData,
T_cmdQPacketCallback  p_callback 
)

CmdQSendShortPacket prepares a short packet for sending and sends it over to ICmdQSendPacket for processing.

Parameters
p_packet– Packet to send
retryTime– How long to wait for acknowledgement before trying to send again.
extraData– Extra data for the callback routine.
p_callback– Routine to be called when either the packet is lost or sent.
T_void CmdQSetActivePortNum ( T_word16  num)

CmdQSetActivePortNum sets up the Cmd Queue module for the given port (and makes the given port the active communications port).

Parameters
num– Number of port to make active.
T_void CmdQUpdateAllReceives ( T_void  )

CmdQUpdateAllReceives goes through all the ports looking for data to take in. All data that is received is then processed and the appropriate action for the command is called.

If this is a lossful packet, always call the

callback routine.

T_void CmdQUpdateAllSends ( T_void  )

CmdQUpdateAllSends goes through all the ports and determines what data needs to be sent and what should wait.

T_void ICmdQDiscardPacket ( T_byte8  commandNum)

ICmdQDiscardPacket removes a packet from the given command queue in the current command queue list.

Parameters
commandNum– Command in command list to do a packet discard on.
T_void ICmdQSendPacket ( T_packetEitherShortOrLong p_packet,
T_word16  retryTime,
T_word32  extraData,
T_cmdQPacketCallback  p_callback 
)

ICmdQSendPacket does all the work of placing a packet in one of the active command queues and prepares it for sending out.

Parameters
p_packet– Packet to send
retryTime– How long to wait for acknowledgement before trying to send again.
extraData– Extra data for the callback routine.
p_callback– Routine to be called when either the packet is lost or sent.

Give the packet a unique packet ID

T_void ICmdQUpdateSendForPort ( T_void  )

ICmdQUpdateSendForPort updates the sending of all packets for this single port (the currently active port). Packets that need to be transferred are sent. Those that don't, don't. The amount of packets sent depends on the baud rate and the last time this routine was called for this port.

(It's always time to send an ACK.)

– IFF the packet is lossless...

Now, if we aren't checking the ACK queue, we need

to break after the first send. If we are, we

want to dump everything in the queue.

Variable Documentation

T_word32 G_packetsAlloc = 0
T_word32 G_packetsFree = 0