Filter:   InfoImg
download network.h
Language: C++
LOC: 31
Project Info
Ultima Online Project(uop)
Server: SourceForge
Type: cvs
SourceForge\u\uop\uop\uop\
   acinclude.m4
   aclocal.m4
   action.cc
   action.h
   animation.cc
   animation.h
   artexport.cc
   artfactory.cc
   artfactory.h
   audio.cc
   audio.h
   btree.cc
   btree.h
   cache.h
   cliloc.cc
   cliloc.h
   config.h.in
   configure.in
   cvs2cl.pl
   entity.cc
   entity.h
   gumps.cc
   gumps.h
   interface.cc
   interface.h
   interfacegumps.cc
   interfacegumps.h
   interfacehandler.cc
   interfacehandler.h
   intrface.def
   Makefile.am
   Makefile.in
   message.cc
   message.h
   musicmap.def
   network.cc
   network.h
   patchhandler.cc
   patchhandler.h
   readable.pl
   serverhandler.cc
   serverhandler.h
   sprite.cc
   sprite.h
   stamp-h.in
   texthandler.cc
   texthandler.h
   tiledata.cc
   tiledata.h
   unreadable.pl
   uop.cc
   uop.cfg
   uop.dox
   uop.h
   uopconfig.cc
   uopconfig.h
   uosprite.h
   uostub.pl
   world.cc
   world.h

#ifndef __NETWORK_H__
#define __NETWORK_H__

#include <SDL/SDL_types.h>
#include <SDL/SDL_net.h>
#include "btree.h"
#include <string>


// For easy packet parsing
#define GET_UINT32(x) (SDL_SwapBE32(*(Uint32*)(x)))
#define GET_UINT16(x) (SDL_SwapBE16(*(Uint16*)(x)))
#define GET_UINT8(x) (*(Uint8*)(x))
#define GET_SINT8(x) (*(Sint8*)(x))

class Network
{
public:
  Network();
  ~Network();
  void connect(string &host,Uint16 port);
  void connect(Uint32 ip,Uint16 port);
  void disconnect();
  int ready();
  int read(Uint8 *pvOut,int len);
  void write(Uint8 *pvIn,int len);

  TCPsocket uo;			/**< Our socket to the server */
  bool readCrypto;		/**< whether or not we're decompressing */
private:

  bTree tree,			/**< The big bTree for decompression */
	*readCur;		/**< Current location in the bTree */
  SDLNet_SocketSet sockets;	/**< Socket Set for testing activity */
  int readBits;			/**< Current bit read */
  Uint16 readValue;		/**< Current value read */
};

#endif