Atrinik Client 2.5
Data Structures | Typedefs | Enumerations | Functions | Variables
client/client.c File Reference
#include <global.h>

Go to the source code of this file.

Data Structures

struct  CmdMapping

Typedefs

typedef void(* CmdProc )(unsigned char *, int len)

Enumerations

enum  {
  BINARY_CMD_COMC = 1, BINARY_CMD_MAP2, BINARY_CMD_DRAWINFO, BINARY_CMD_DRAWINFO2,
  BINARY_CMD_FILE_UPD, BINARY_CMD_ITEMX, BINARY_CMD_SOUND, BINARY_CMD_TARGET,
  BINARY_CMD_UPITEM, BINARY_CMD_DELITEM, BINARY_CMD_STATS, BINARY_CMD_IMAGE,
  BINARY_CMD_FACE1, BINARY_CMD_ANIM, BINARY_CMD_SKILLRDY, BINARY_CMD_PLAYER,
  BINARY_CMD_MAPSTATS, BINARY_CMD_SPELL_LIST, BINARY_CMD_SKILL_LIST, BINARY_CMD_CLEAR,
  BINARY_CMD_ADDME_SUC, BINARY_CMD_ADDME_FAIL, BINARY_CMD_VERSION, BINARY_CMD_BYE,
  BINARY_CMD_SETUP, BINARY_CMD_QUERY, BINARY_CMD_DATA, BINARY_CMD_NEW_CHAR,
  BINARY_CMD_ITEMY, BINARY_CMD_BOOK, BINARY_CMD_PARTY, BINARY_CMD_QUICKSLOT,
  BINARY_CMD_SHOP, BINARY_CMD_QLIST, BINARY_CMD_REGION_MAP, BINARY_CMD_READY,
  BINARY_CMD_KEEPALIVE, BINAR_CMD
}

Functions

void DoClient ()
void SockList_Init (SockList *sl)
void SockList_AddChar (SockList *sl, char c)
void SockList_AddShort (SockList *sl, uint16 data)
void SockList_AddInt (SockList *sl, uint32 data)
void SockList_AddString (SockList *sl, char *data)
void SockList_AddStringTerminated (SockList *sl, char *data)
int GetInt_String (const unsigned char *data)
sint64 GetInt64_String (const unsigned char *data)
short GetShort_String (const unsigned char *data)
char * GetString_String (uint8 *data, int *pos, char *dest, size_t dest_size)
int cs_write_string (char *buf, size_t len)
void check_animation_status (int anum)

Variables

Client_Player cpl
ClientSocket csocket
struct CmdMapping commands []

Detailed Description

Client interface main routine.

This file sets up a few global variables, connects to the server, tells it what kind of pictures it wants, adds the client and enters the main event loop (event_loop()) checks the tcp socket for input and then polls for x events. This should be fixed since you can just block on both filedescriptors.

The DoClient function receives a message (an ArgList), unpacks it, and in a slow for loop dispatches the command to the right function through the commands table. ArgLists are essentially like RPC things, only they don't require going through RPCgen, and it's easy to get variable length lists. They are just lists of longs, strings, characters, and byte arrays that can be converted to a machine independent format.

Definition in file client.c.


Typedef Documentation

typedef void(* CmdProc)(unsigned char *, int len)

Used for socket commands

Definition at line 53 of file client.c.


Function Documentation

void check_animation_status ( int  anum)

Check animation status.

Parameters:
anumAnimation ID.

Definition at line 358 of file client.c.

int cs_write_string ( char *  buf,
size_t  len 
)

Takes a string of data, and writes it out to the socket.

Parameters:
fdFile descriptor to send the string to.
bufThe string.
lenLength of the string.
Returns:
0 on success, -1 on failure.

Definition at line 345 of file client.c.

void DoClient ( )

Do client. The main loop for commands. From this, the data and commands from server are received.

Definition at line 156 of file client.c.

sint64 GetInt64_String ( const unsigned char *  data)

64-bit version of GetInt_String().

Parameters:
dataThe string.
Returns:
Integer from the string.

Definition at line 297 of file client.c.

int GetInt_String ( const unsigned char *  data)

Does the reverse of SockList_AddInt, but on strings instead.

Parameters:
dataThe string.
Returns:
Integer from the string.

Definition at line 288 of file client.c.

short GetShort_String ( const unsigned char *  data)

Does the reverse of SockList_AddShort, but on strings instead.

Parameters:
dataThe string.
Returns:
Short integer from the string.

Definition at line 310 of file client.c.

char* GetString_String ( uint8 data,
int *  pos,
char *  dest,
size_t  dest_size 
)

Construct a string from data packet.

Parameters:
dataData packet.
[out]posPosition in the data packet.
destWill contain the string from data packet.
dest_sizeSize of 'dest'.
Returns:
'dest'.

Definition at line 322 of file client.c.

void SockList_AddChar ( SockList sl,
char  c 
)

Add character to socket list.

Parameters:
slSocket list.
cCharacter to add.

Definition at line 223 of file client.c.

void SockList_AddInt ( SockList sl,
uint32  data 
)

Add integer to socket list.

Parameters:
slSocket list.
dataInteger data.

Definition at line 243 of file client.c.

void SockList_AddShort ( SockList sl,
uint16  data 
)

Add short integer to socket list.

Parameters:
slSocket list.
dataShort integer data.

Definition at line 233 of file client.c.

void SockList_AddString ( SockList sl,
char *  data 
)

Add an unterminated string.

Parameters:
slSockList instance to add to.
dataThe string to add.

Definition at line 255 of file client.c.

void SockList_AddStringTerminated ( SockList sl,
char *  data 
)

Add a NULL terminated string.

Parameters:
slSockList instance to add to.
dataThe string to add.

Definition at line 270 of file client.c.

void SockList_Init ( SockList sl)

Init socket list, setting the list's len to 0 and buf to NULL.

Parameters:
slSocket list.

Definition at line 213 of file client.c.


Variable Documentation

struct CmdMapping commands[]

Structure of all the socket commands

Definition at line 106 of file client.c.

Client player structure with things like stats, damage, etc

Definition at line 47 of file client.c.

Client socket

Definition at line 50 of file client.c.