--- deliantra/server/include/newserver.h 2006/09/19 22:05:55 1.13 +++ deliantra/server/include/newserver.h 2006/12/14 21:46:34 1.25 @@ -29,7 +29,6 @@ newclient.h */ - #ifndef NEWSERVER_H #define NEWSERVER_H @@ -41,9 +40,9 @@ struct MapCell { - tag_t player; // this is, unfortunately, very wasteful of memory space, but pretty bandwidth-efficient + UUID player; // this is, unfortunately, very wasteful of memory space, but pretty bandwidth-efficient int count; /* This is really darkness in the map1 command */ - short faces[MAP_LAYERS]; + uint16 faces[MAP_LAYERS]; uint16 smooth[MAP_LAYERS]; unsigned char stat_hp; // health of something in this space, or 0 unsigned char flags; @@ -78,10 +77,7 @@ * are using. */ -enum Sock_Status { Ns_Avail, Ns_Add, Ns_Dead, Ns_Old }; - -/* Reserver 0 for neither of these being set */ -enum Old_Mode { Old_Listen = 1, Old_Player = 2 }; +enum Sock_Status { Ns_Add, Ns_Dead }; /* Only one map mode can actually be used, so lets make it a switch * instead of having a bunch of different fields that needed to @@ -101,58 +97,76 @@ }; /* how many times we are allowed to give the wrong password before being kicked. */ -# define MAX_PASSWORD_FAILURES 5 +#define MAX_PASSWORD_FAILURES 5 -struct NewSocket +ACC_CLASS (client_socket) // should become player when newsocket is a baseclass of player +struct client_socket : zero_initialised, attachable_base { enum Sock_Status status; - int fd; + int ACC (RW, fd); + unsigned int inbuf_len; // number of bytes valid in inbuf struct Map lastmap; size_t faces_sent_len; /* This is the number of elements allocated in faces_sent[] */ uint8 *faces_sent; /* This is a bitmap on sent face status */ uint8 anims_sent[MAXANIMNUM]; struct statsinfo stats; - /* If we get an incomplete packet, this is used to hold the data. */ - SockList inbuf; - char *host; /* Which host it is connected from (ip address) */ - uint8 password_fails; /* how many times the player has failed to give the right password */ + + char *ACC (RW, host); /* Which host it is connected from (ip address) */ + uint8 ACC (RW, password_fails); /* how many times the player has failed to give the right password */ Buffer outputbuffer; /* For undeliverable data */ - uint32 facecache:1; /* If true, client is caching images */ - uint32 sent_scroll:1; - uint32 sound:1; /* does the client want sound */ - uint32 exp64:1; /* Client wants 64 bit exp data, as well as skill data */ - uint32 newmapcmd:1; /* Send newmap command when entering new map SMACFIGGEN */ - uint32 plugincmd:1; /* CF+ extend the protocol through a plug-in */ - uint32 mapinfocmd:1; /* CF+ return map info and send map change info */ - uint32 extcmd:1; /* CF+ call into extensions/plugins */ - uint32 extmap:1; /* CF+ extend map comamnd with extra data */ - uint32 buggy_mapscroll:1; /* CF+ client crashes on large mapscrolls */ - uint32 darkness:1; /* True if client wants darkness information */ - uint32 image2:1; /* Client wants image2/face2 commands */ - uint32 update_look:1; /* If true, we need to send the look window */ - uint32 can_write:1; /* Can we write to this socket? */ - uint32 has_readable_type:1; /* If true client accept additional text information - used to arrange text in books, scrolls, or scripted dialogs */ - uint32 monitor_spells:1; /* Client wishes to be informed when their spell list changes */ - uint32 supported_readables; /* each bit is a readable supported by client */ - uint32 cs_version, sc_version; /* versions of the client */ + + bool ACC (RW, facecache); /* If true, client is caching images */ + bool ACC (RW, sent_scroll); + bool ACC (RW, sound); /* does the client want sound */ + bool ACC (RW, exp64); /* Client wants 64 bit exp data, as well as skill data */ + bool ACC (RW, newmapcmd); /* Send newmap command when entering new map SMACFIGGEN */ + bool ACC (RW, plugincmd); /* CF+ extend the protocol through a plug-in */ + bool ACC (RW, mapinfocmd); /* CF+ return map info and send map change info */ + bool ACC (RW, extcmd); /* CF+ call into extensions/plugins */ + bool ACC (RW, extmap); /* CF+ extend map comamnd with extra data */ + bool ACC (RW, buggy_mapscroll); /* CF+ client crashes on large mapscrolls */ + bool ACC (RW, darkness); /* True if client wants darkness information */ + bool ACC (RW, image2); /* Client wants image2/face2 commands */ + bool ACC (RW, update_look); /* If true, we need to send the look window */ + bool ACC (RW, has_readable_type); /* If true client accept additional text information */ + /* used to arrange text in books, scrolls, or scripted dialogs */ + bool ACC (RW, monitor_spells); /* Client wishes to be informed when their spell list changes */ + bool ACC (RW, ext_mapinfos); /* If true client accept additionnal info on maps */ + /* Below are flags for extedend infos to pass to client + * with S->C mapextended command */ + bool ACC (RW, EMI_smooth); /* Send smooth in extendmapinfos */ + + uint32 ACC (RW, supported_readables); /* each bit is a readable supported by client */ + uint32 ACC (RW, cs_version), ACC (RW, sc_version); /* versions of the client */ enum MapMode mapmode; /* Type of map commands the client wants. */ - uint16 look_position; /* start of drawing of look window */ - uint8 mapx, mapy; /* How large a map the client wants */ - uint8 itemcmd; /* What version of the 'item' protocol command to use */ - uint8 faceset; /* Set the client is using, default 0 */ - uint32 ext_mapinfos:1; /* If true client accept additionnal info on maps */ - /* Below are flags for extedend infos to pass to client - * with S->C mapextended command */ - uint32 EMI_smooth:1; /* Send smooth in extendmapinfos */ - - maptile *current_map; // CF+ last/current player map - int current_x, current_y; // CF+ last/current map position - char client[64]; // CF+ client name/version - - /* Below here is information only relevant for old sockets */ - char *comment; /* name or listen comment */ - enum Old_Mode old_mode; + uint16 ACC (RW, look_position); /* start of drawing of look window */ + uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */ + uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */ + uint8 ACC (RW, faceset); /* Set the client is using, default 0 */ + + maptile *ACC (RW, current_map); // CF+ last/current player map + int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position + char ACC (RW, client)[64]; // CF+ client name/version + + /* If we get an incomplete packet, this is used to hold the data. */ + uint8 inbuf[MAXSOCKBUF]; + player *pl;//TODO should not be here, preferably + + iow socket_ev; void socket_cb (iow &w, int got); + + client_socket (int fd, const char *from_ip); + ~client_socket (); + + int read_packet (); // returns length of packet or 0 + void skip_packet (int len); // we have processed the packet, skip it + + void flush (); + void write_outputbuffer (); + void send (void *buf_, int len); + + void send_packet (const char *buf); + void send_packet (const char *buf, int len); + void send_packet (packet &sl); }; #define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\ @@ -195,19 +209,14 @@ #define FACE_TYPES 1 #define PNG_FACE_INDEX 0 -struct Socket_Info -{ - struct timeval timeout; /* Timeout for select */ - int max_filedescriptor; /* max filedescriptor on the system */ - int nconns; /* Number of connections */ - int allocated_sockets; /* number of allocated in init_sockets */ -}; - -extern Socket_Info socket_info; - #define VERSION_CS 1023 /* version >= 1023 understand setup cmd */ #define VERSION_SC 1027 #define VERSION_INFO "Crossfire+ Server" +typedef unordered_vector sockvec; + +extern sockvec client_sockets; +extern int nrofpixmaps; //TODO: hrmpf, should go + #endif