1 /** 2 * @file msg.h 3 * 4 * Interface of function for sending and reciving network messages. 5 */ 6 #ifndef __MSG_H__ 7 #define __MSG_H__ 8 9 DEVILUTION_BEGIN_NAMESPACE 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 #pragma pack(push, 1) 16 typedef struct TCmd { 17 Uint8 bCmd; 18 } TCmd; 19 20 typedef struct TCmdLoc { 21 Uint8 bCmd; 22 Uint8 x; 23 Uint8 y; 24 } TCmdLoc; 25 26 typedef struct TCmdLocParam1 { 27 Uint8 bCmd; 28 Uint8 x; 29 Uint8 y; 30 Uint16 wParam1; 31 } TCmdLocParam1; 32 33 typedef struct TCmdLocParam2 { 34 Uint8 bCmd; 35 Uint8 x; 36 Uint8 y; 37 Uint16 wParam1; 38 Uint16 wParam2; 39 } TCmdLocParam2; 40 41 typedef struct TCmdLocParam3 { 42 Uint8 bCmd; 43 Uint8 x; 44 Uint8 y; 45 Uint16 wParam1; 46 Uint16 wParam2; 47 Uint16 wParam3; 48 } TCmdLocParam3; 49 50 typedef struct TCmdParam1 { 51 Uint8 bCmd; 52 Uint16 wParam1; 53 } TCmdParam1; 54 55 typedef struct TCmdParam2 { 56 Uint8 bCmd; 57 Uint16 wParam1; 58 Uint16 wParam2; 59 } TCmdParam2; 60 61 typedef struct TCmdParam3 { 62 Uint8 bCmd; 63 Uint16 wParam1; 64 Uint16 wParam2; 65 Uint16 wParam3; 66 } TCmdParam3; 67 68 typedef struct TCmdGolem { 69 Uint8 bCmd; 70 Uint8 _mx; 71 Uint8 _my; 72 Uint8 _mdir; 73 Sint8 _menemy; 74 Sint32 _mhitpoints; 75 Uint8 _currlevel; 76 } TCmdGolem; 77 78 typedef struct TCmdQuest { 79 Uint8 bCmd; 80 Uint8 q; 81 Uint8 qstate; 82 Uint8 qlog; 83 Uint8 qvar1; 84 } TCmdQuest; 85 86 typedef struct TCmdGItem { 87 Uint8 bCmd; 88 Uint8 bMaster; 89 Uint8 bPnum; 90 Uint8 bCursitem; 91 Uint8 bLevel; 92 Uint8 x; 93 Uint8 y; 94 Uint16 wIndx; 95 Uint16 wCI; 96 Sint32 dwSeed; 97 Uint8 bId; 98 Uint8 bDur; 99 Uint8 bMDur; 100 Uint8 bCh; 101 Uint8 bMCh; 102 Uint16 wValue; 103 Uint32 dwBuff; 104 Sint32 dwTime; 105 Uint16 wToHit; 106 Uint16 wMaxDam; 107 Uint8 bMinStr; 108 Uint8 bMinMag; 109 Uint8 bMinDex; 110 Sint16 bAC; 111 } TCmdGItem; 112 113 typedef struct TCmdPItem { 114 Uint8 bCmd; 115 Uint8 x; 116 Uint8 y; 117 Uint16 wIndx; 118 Uint16 wCI; 119 Sint32 dwSeed; 120 Uint8 bId; 121 Uint8 bDur; 122 Uint8 bMDur; 123 Uint8 bCh; 124 Uint8 bMCh; 125 Uint16 wValue; 126 Uint32 dwBuff; 127 Uint16 wToHit; 128 Uint16 wMaxDam; 129 Uint8 bMinStr; 130 Uint8 bMinMag; 131 Uint8 bMinDex; 132 Sint16 bAC; 133 } TCmdPItem; 134 135 typedef struct TCmdChItem { 136 Uint8 bCmd; 137 Uint8 bLoc; 138 Uint16 wIndx; 139 Uint16 wCI; 140 Sint32 dwSeed; 141 Uint8 bId; 142 Uint32 dwBuff; 143 } TCmdChItem; 144 145 typedef struct TCmdDelItem { 146 Uint8 bCmd; 147 Uint8 bLoc; 148 } TCmdDelItem; 149 150 typedef struct TCmdDamage { 151 Uint8 bCmd; 152 Uint8 bPlr; 153 Uint32 dwDam; 154 } TCmdDamage; 155 156 typedef struct TCmdMonDamage { 157 Uint8 bCmd; 158 Uint16 wMon; 159 Uint32 dwDam; 160 } TCmdMonDamage; 161 162 typedef struct TCmdPlrInfoHdr { 163 Uint8 bCmd; 164 Uint16 wOffset; 165 Uint16 wBytes; 166 } TCmdPlrInfoHdr; 167 168 typedef struct TCmdString { 169 Uint8 bCmd; 170 char str[MAX_SEND_STR_LEN]; 171 } TCmdString; 172 173 typedef struct TFakeCmdPlr { 174 Uint8 bCmd; 175 Uint8 bPlr; 176 } TFakeCmdPlr; 177 178 typedef struct TFakeDropPlr { 179 Uint8 bCmd; 180 Uint8 bPlr; 181 Uint32 dwReason; 182 } TFakeDropPlr; 183 184 typedef struct TSyncHeader { 185 Uint8 bCmd; 186 Uint8 bLevel; 187 Uint16 wLen; 188 Uint8 bObjId; 189 Uint8 bObjCmd; 190 Uint8 bItemI; 191 Uint8 bItemX; 192 Uint8 bItemY; 193 Uint16 wItemIndx; 194 Uint16 wItemCI; 195 Uint32 dwItemSeed; 196 Uint8 bItemId; 197 Uint8 bItemDur; 198 Uint8 bItemMDur; 199 Uint8 bItemCh; 200 Uint8 bItemMCh; 201 Uint16 wItemVal; 202 Uint32 dwItemBuff; 203 Uint8 bPInvLoc; 204 Uint16 wPInvIndx; 205 Uint16 wPInvCI; 206 Uint32 dwPInvSeed; 207 Uint8 bPInvId; 208 Uint16 wToHit; 209 Uint16 wMaxDam; 210 Uint8 bMinStr; 211 Uint8 bMinMag; 212 Uint8 bMinDex; 213 Uint8 bAC; 214 } TSyncHeader; 215 216 typedef struct TSyncMonster { 217 Uint8 _mndx; 218 Uint8 _mx; 219 Uint8 _my; 220 Uint8 _menemy; 221 Uint8 _mdelta; 222 } TSyncMonster; 223 224 typedef struct TPktHdr { 225 Uint8 px; 226 Uint8 py; 227 Uint8 targx; 228 Uint8 targy; 229 Sint32 php; 230 Sint32 pmhp; 231 Uint8 bstr; 232 Uint8 bmag; 233 Uint8 bdex; 234 Uint16 wCheck; 235 Uint16 wLen; 236 } TPktHdr; 237 238 typedef struct TPkt { 239 TPktHdr hdr; 240 Uint8 body[493]; 241 } TPkt; 242 243 typedef struct DMonsterStr { 244 Uint8 _mx; 245 Uint8 _my; 246 Uint8 _mdir; 247 Uint8 _menemy; 248 Uint8 _mactive; 249 Sint32 _mhitpoints; 250 } DMonsterStr; 251 252 typedef struct DObjectStr { 253 Uint8 bCmd; 254 } DObjectStr; 255 256 typedef struct DLevel { 257 TCmdPItem item[MAXITEMS]; 258 DObjectStr object[MAXOBJECTS]; 259 DMonsterStr monster[MAXMONSTERS]; 260 } DLevel; 261 262 typedef struct LocalLevel { 263 Uint8 automapsv[DMAXX][DMAXY]; 264 } LocalLevel; 265 266 typedef struct DPortal { 267 Uint8 x; 268 Uint8 y; 269 Uint8 level; 270 Uint8 ltype; 271 Uint8 setlvl; 272 } DPortal; 273 274 typedef struct MultiQuests { 275 Uint8 qstate; 276 Uint8 qlog; 277 Uint8 qvar1; 278 } MultiQuests; 279 280 typedef struct DJunk { 281 DPortal portal[MAXPORTAL]; 282 MultiQuests quests[MAXMULTIQUESTS]; 283 } DJunk; 284 #pragma pack(pop) 285 286 #pragma pack(push, 1) 287 typedef struct TMegaPkt { 288 struct TMegaPkt *pNext; 289 Uint32 dwSpaceLeft; 290 Uint8 data[32000]; 291 } TMegaPkt; 292 #pragma pack(pop) 293 294 typedef struct TBuffer { 295 Uint32 dwNextWriteOffset; 296 Uint8 bData[4096]; 297 } TBuffer; 298 299 extern BOOL deltaload; 300 extern BYTE gbBufferMsgs; 301 extern int dwRecCount; 302 303 void msg_send_drop_pkt(int pnum, int reason); 304 BOOL msg_wait_resync(); 305 void run_delta_info(); 306 void DeltaExportData(int pnum); 307 void delta_init(); 308 void delta_kill_monster(int mi, BYTE x, BYTE y, BYTE bLevel); 309 void delta_monster_hp(int mi, int hp, BYTE bLevel); 310 void delta_sync_monster(const TSyncMonster *pSync, BYTE bLevel); 311 BOOL delta_portal_inited(int i); 312 BOOL delta_quest_inited(int i); 313 void DeltaAddItem(int ii); 314 void DeltaSaveLevel(); 315 void DeltaLoadLevel(); 316 void NetSendCmd(BOOL bHiPri, BYTE bCmd); 317 void NetSendCmdGolem(BYTE mx, BYTE my, BYTE dir, BYTE menemy, int hp, BYTE cl); 318 void NetSendCmdLoc(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y); 319 void NetSendCmdLocParam1(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y, WORD wParam1); 320 void NetSendCmdLocParam2(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y, WORD wParam1, WORD wParam2); 321 void NetSendCmdLocParam3(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y, WORD wParam1, WORD wParam2, WORD wParam3); 322 void NetSendCmdParam1(BOOL bHiPri, BYTE bCmd, WORD wParam1); 323 void NetSendCmdParam2(BOOL bHiPri, BYTE bCmd, WORD wParam1, WORD wParam2); 324 void NetSendCmdParam3(BOOL bHiPri, BYTE bCmd, WORD wParam1, WORD wParam2, WORD wParam3); 325 void NetSendCmdQuest(BOOL bHiPri, BYTE q); 326 void NetSendCmdGItem(BOOL bHiPri, BYTE bCmd, BYTE mast, BYTE pnum, BYTE ii); 327 void NetSendCmdPItem(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y); 328 void NetSendCmdChItem(BOOL bHiPri, BYTE bLoc); 329 void NetSendCmdDelItem(BOOL bHiPri, BYTE bLoc); 330 void NetSendCmdDItem(BOOL bHiPri, int ii); 331 void NetSendCmdDamage(BOOL bHiPri, BYTE bPlr, DWORD dwDam); 332 void NetSendCmdMonDmg(BOOL bHiPri, WORD bMon, DWORD dwDam); 333 void NetSendCmdString(int pmask, const char *pszStr); 334 void delta_close_portal(int pnum); 335 DWORD ParseCmd(int pnum, TCmd *pCmd); 336 337 #ifdef __cplusplus 338 } 339 #endif 340 341 DEVILUTION_END_NAMESPACE 342 343 #endif /* __MSG_H__ */ 344