objserial.h

Go to the documentation of this file.
00001 
00007 /*
00008 Copyright (C) 2001  The Exult Team
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifndef OBJSERIAL_H
00026 #define OBJSERIAL_H 1
00027 
00028 #include <string>
00029 #include "utils.h"
00030 #include "servemsg.h"
00031 
00032 class Serial_out
00033   {
00034   unsigned char *& buf;
00035 public:
00036   Serial_out(unsigned char *& b) : buf(b)
00037     {  }
00038   Serial_out& operator<<(int v)
00039     { Write4(buf, v); return *this; }
00040   Serial_out& operator<<(unsigned long v)
00041     { Write4(buf, v); return *this; }
00042   Serial_out& operator<<(short v)
00043     { Write2(buf, v); return *this; }
00044   Serial_out& operator<<(bool v)
00045     { *buf++ = (v ? 1 : 0); return *this; }
00046   Serial_out& operator<<(unsigned char c)
00047     { *buf++ = c; return *this; }
00048   Serial_out& operator<<(std::string& s);
00049   };
00050 
00051 /*
00052  *  Decode.
00053  */
00054 class Serial_in
00055   {
00056   unsigned char *& buf;
00057 public:
00058   Serial_in(unsigned char *& b) : buf(b)
00059     {  }
00060   Serial_in& operator<<(int& v)
00061     { v = Read4(buf); return *this; }
00062   Serial_in& operator<<(unsigned long& v)
00063     { v = Read4(buf); return *this; }
00064   Serial_in& operator<<(short& v)
00065     { v = Read2(buf); return *this; }
00066   Serial_in& operator<<(bool &v)
00067     { v = *buf++ ? true : false; return *this; }
00068   Serial_in& operator<<(unsigned char &c)
00069     { c = *buf++; return *this; }
00070   Serial_in& operator<<(std::string& s);
00071   };
00072 
00073 
00074 extern int Object_out
00075   (
00076   int fd,       // Socket.
00077   Exult_server::Msg_type id,  // Message id.
00078   unsigned long addr,   // Address.
00079   int tx, int ty, int tz,   // Absolute tile coords.
00080   int shape, int frame,
00081   int quality,
00082   std::string name
00083   );
00084 extern int Object_in
00085   (
00086   unsigned char *data,    // Data that was read.
00087   int datalen,      // Length of data.
00088   unsigned long& addr,    // Address.
00089   int& tx, int& ty, int& tz,  // Absolute tile coords.
00090   int& shape, int& frame,
00091   int& quality,
00092   std::string& name
00093   );
00094 
00095 extern int Egg_object_out
00096   (
00097   int fd,       // Socket.
00098   unsigned long addr,   // Address.
00099   int tx, int ty, int tz, // Absolute tile coords.
00100   int shape, int frame,
00101   int type,
00102   int criteria,
00103   int probability,
00104   int distance,
00105   bool nocturnal,
00106   bool once,
00107   bool hatched,
00108   bool auto_reset,
00109   int data1, int data2
00110   );
00111 extern int Egg_object_in
00112   (
00113   unsigned char *data,    // Data that was read.
00114   int datalen,      // Length of data.
00115   unsigned long& addr,    // Address.
00116   int& tx, int& ty, int& tz,  // Absolute tile coords.
00117   int& shape, int& frame,
00118   int& type,
00119   int& criteria,
00120   int& probability,
00121   int& distance,
00122   bool& nocturnal,
00123   bool& once,
00124   bool& hatched,
00125   bool& auto_reset,
00126   int& data1, int& data2
00127   );
00128 
00129 struct Serial_schedule      // For passing a schedule change.
00130   {
00131   short time;     // 0-7 (3-hour period).
00132   short type;     // Schedule type (mostly 0-31).
00133   int tx, ty;     // Tile to go to.
00134   };
00135 
00136 int Npc_actor_out
00137   (
00138   int fd,       // Socket.
00139   unsigned long addr,   // Address.
00140   int tx, int ty, int tz,   // Absolute tile coords.
00141   int shape, int frame, int face,
00142   std::string name,
00143   short npc_num,
00144   short ident,
00145   int usecode,
00146   int *properties,    // 12 entries.
00147   short attack_mode,
00148   short alignment,
00149   unsigned long oflags,   // Object flags.
00150   unsigned long siflags,    // Extra flags for SI.
00151   unsigned long type_flags, // Movement flags.
00152   short num_schedules,    // # of schedule changes.
00153   Serial_schedule *schedules  // Schedule changes.
00154   );
00155 int Npc_actor_in
00156   (
00157   unsigned char *data,    // Data that was read.
00158   int datalen,      // Length of data.
00159   unsigned long& addr,    // Address.
00160   int& tx, int& ty, int& tz,  // Absolute tile coords.
00161   int& shape, int& frame, int& face,
00162   std::string& name,
00163   short& npc_num,
00164   short& ident,
00165   int& usecode,
00166   int *properties,    // Must have room for 12.
00167   short& attack_mode,
00168   short& alignment,
00169   unsigned long& oflags,    // Object flags.
00170   unsigned long& siflags,   // Extra flags for SI.
00171   unsigned long& type_flags,  // Movement flags.
00172   short& num_schedules,   // # of schedule changes.
00173   Serial_schedule *schedules  // Schedule changes.  Room for 8.
00174   );
00175 
00176 extern int Game_info_out
00177   (
00178   int fd,       // Socket.
00179   int version,      // Server/client version.
00180   int edit_lift,      // Lift being edited.
00181   int hide_lift,      // Lift being hidden.
00182   bool map_editing,   // In 'map-editing' mode.
00183   bool tile_grid,     // Showing tile grid.
00184   bool map_modified,    // Map was changed.
00185   int edit_mode     // Mode we're in.
00186   );
00187 extern int Game_info_in
00188   (
00189   unsigned char *data,    // Data that was read.
00190   int datalen,      // Length of data.
00191   int& version,     // Server/client version.
00192   int& edit_lift,     // Lift being edited.
00193   int& hide_lift,     // Lift being hidden.
00194   bool& map_editing,    // In 'map-editing' mode.
00195   bool& tile_grid,    // Showing tile grid.
00196   bool& map_modified,   // Map was changed.
00197   int& edit_mode      // Mode we're in.
00198   );
00199 
00200 #endif
00201 
00202 
00203 
00204 

Generated on Mon Jul 9 14:42:50 2007 for ExultEngine by  doxygen 1.5.1