Odamex
Setting the Standard in Multiplayer Doom
common/d_protocol.h
Go to the documentation of this file.
00001 // Emacs style mode select   -*- C++ -*- 
00002 //-----------------------------------------------------------------------------
00003 //
00004 // $Id: d_protocol.h 1788 2010-08-24 04:42:57Z russellrice $
00005 //
00006 // Copyright (C) 1998-2006 by Randy Heit (ZDoom).
00007 // Copyright (C) 2006-2010 by The Odamex Team.
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // DESCRIPTION:
00020 //      Event Protocol
00021 //
00022 //-----------------------------------------------------------------------------
00023 
00024 
00025 #ifndef __D_PROTOCOL_H__
00026 #define __D_PROTOCOL_H__
00027 
00028 #include "doomstat.h"
00029 #include "doomtype.h"
00030 #include "doomdef.h"
00031 #include "m_fixed.h"
00032 #include "farchive.h"
00033 
00034 #define FORM_ID         (('F'<<24)|('O'<<16)|('R'<<8)|('M'))
00035 #define ZDEM_ID         (('Z'<<24)|('D'<<16)|('E'<<8)|('M'))
00036 #define ZDHD_ID         (('Z'<<24)|('D'<<16)|('H'<<8)|('D'))
00037 #define VARS_ID         (('V'<<24)|('A'<<16)|('R'<<8)|('S'))
00038 #define UINF_ID         (('U'<<24)|('I'<<16)|('N'<<8)|('F'))
00039 #define BODY_ID         (('B'<<24)|('O'<<16)|('D'<<8)|('Y'))
00040 
00041 #define ANGLE2SHORT(x)  ((((x)/360) & 65535)
00042 #define SHORT2ANGLE(x)  ((x)*360)
00043 
00044 
00045 struct zdemoheader_s {
00046         byte    demovermajor;
00047         byte    demoverminor;
00048         byte    minvermajor;
00049         byte    minverminor;
00050         byte    map[8];
00051         unsigned int rngseed;
00052         byte    consoleplayer;
00053 };
00054 
00055 #define DEM_BAD                         0
00056 // Bad command
00057 
00058 #define DEM_USERCMD                     1
00059 // Player movement
00060 
00061 struct usercmd_s {
00062         byte    msec;                   // not sure how to use this yet...
00063         byte    buttons;
00064         short   pitch;                  // up/down. currently just a y-sheering amount
00065         short   yaw;                    // left/right   // If you haven't guessed, I just
00066         short   roll;                   // tilt                 // ripped these from Quake2's usercmd.
00067         short   forwardmove;
00068         short   sidemove;
00069         short   upmove;
00070         byte    impulse;
00071         byte    use;
00072         
00073         usercmd_s() : msec(0), buttons(0), pitch(0), yaw(0), roll(0), forwardmove(0), sidemove(0), upmove(0), impulse(0), use(0) {}
00074 };
00075 typedef struct usercmd_s usercmd_t;
00076 
00077 FArchive &operator<< (FArchive &arc, usercmd_t &cmd);
00078 FArchive &operator>> (FArchive &arc, usercmd_t &cmd);
00079 
00080 // When transmitted, the above message is preceded by a byte
00081 // indicating which fields are actually present in the message.
00082 // (buttons is always sent)
00083 #define UCMDF_BUTTONS           0x01
00084 #define UCMDF_PITCH                     0x02
00085 #define UCMDF_YAW                       0x04
00086 #define UCMDF_FORWARDMOVE       0x08
00087 #define UCMDF_SIDEMOVE          0x10
00088 #define UCMDF_UPMOVE            0x20
00089 #define UCMDF_IMPULSE           0x40
00090 #define UCMDF_MORE                      0x80    // If set, the next byte contains more flags:
00091 // flags byte 2
00092 #define UCMDF_ROLL                      0x01
00093 #define UCMDF_USE                       0x02
00094 
00095 #define DEM_USERCMDCLONE        2
00096 // Use previous DEM_USERCMD for the next (x+1) commands
00097 
00098 //#define DEM_STUFFTEXT         3
00099 // This message is a string for the console to execute
00100 
00101 #define DEM_MUSICCHANGE         4
00102 // This message is a string containing the name of the new music
00103 
00104 #define DEM_PRINT                       5
00105 // Prints a string at the top of the screen
00106 
00107 #define DEM_CENTERPRINT         6
00108 // Prints a string in the middle of the screen
00109 
00110 #define DEM_STOP                        7
00111 // Stop demo playback
00112 
00113 #define DEM_UINFCHANGED         8
00114 // User info changed
00115 
00116 #define DEM_SINFCHANGED         9
00117 // Server info changed
00118 
00119 #define DEM_GENERICCHEAT        10
00120 // Byte 1: Cheat to apply
00121 
00122 #define CHT_GOD                         0
00123 #define CHT_NOCLIP                      1
00124 #define CHT_NOTARGET            2
00125 #define CHT_CHAINSAW            3
00126 #define CHT_IDKFA                       4
00127 #define CHT_IDFA                        5
00128 #define CHT_BEHOLDV                     6
00129 #define CHT_BEHOLDS                     7
00130 #define CHT_BEHOLDI                     8
00131 #define CHT_BEHOLDR                     9
00132 #define CHT_BEHOLDA                     10
00133 #define CHT_BEHOLDL                     11
00134 #define CHT_IDDQD                       12      // Same as CHT_GOD but sets health
00135 #define CHT_MASSACRE            13
00136 #define CHT_CHASECAM            14
00137 #define CHT_FLY                         15
00138 
00139 #define DEM_GIVECHEAT           11
00140 // String: arguments to give command
00141 
00142 #define DEM_SAY                         12
00143 // Byte: who to talk to, String: message to display
00144 
00145 #define DEM_DROPPLAYER          13
00146 // Currently unused
00147 
00148 #define DEM_CHANGEMAP           14
00149 // String: map to change to
00150 
00151 #define DEM_SUICIDE                     15
00152 // The player wants to die
00153 
00154 #define DEM_ADDBOT                      16
00155 // Byte: playernumber, String: userinfo key/value pairs for the bot
00156 
00157 #define DEM_KILLBOTS            17
00158 
00159 int UnpackUserCmd (usercmd_t *ucmd, byte **stream);
00160 int PackUserCmd (usercmd_t *ucmd, byte **stream);
00161 
00162 struct ticcmd_t;
00163 
00164 int ReadByte (byte **stream);
00165 int ReadWord (byte **stream);
00166 int ReadLong (byte **stream);
00167 const char *ReadString (byte **stream);
00168 void WriteByte (byte val, byte **stream);
00169 void WriteWord (short val, byte **stream);
00170 void WriteLong (int val, byte **stream);
00171 void WriteString (const char *string, byte **stream);
00172 
00173 #endif //__D_PROTOCOL_H__
00174 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends