Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
mangler.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef __MANGLER_H__
20#define __MANGLER_H__
21
22// Packet should consist of a GlobalHeaderType followed by a GlobalPacketType with the fields set as
23// indicated.
24
25
26/*
27********************************** Defines **********************************
28*/
29
30// This is the number of additional ports to which to reply.
31#define BLITZ_SIZE 3
32
33#define MPLAYER_NAME_MAX 20
34#define SERIAL_MAX 23
35typedef unsigned char ForwardMaskType;
40
41/*
42** One byte alignment.
43*/
44#if !defined(__GNUC__)
45#pragma pack(push, 1)
46#define PACK
47#else
48#define PACK __attribute__ ((__packed__))
49#endif
50
51// size = 20 bytes
52struct ManglerData {
53 unsigned int CRC PACK;
54 unsigned short magic PACK;
55 unsigned short packetID PACK;
56 unsigned short MyMangledPortNumber PACK;
57 unsigned short OriginalPortNumber PACK;
58 unsigned char MyMangledAddress[4] PACK;
59 unsigned char NetCommandType PACK;
60 unsigned char BlitzMe PACK;
61 unsigned short Padding PACK;
62};
63
64/*
65 This is for older GCC versions that can't do byte-packing.
66 Instead of declaring
67 GlobalPacketType p;
68 p.Command = NET_MANGLER_REQUEST;
69 you would do something like this:
70 GlobalPacketStruct p;
71 Eval(&p, GPCommand, NetCommandType) = NET_MANGLER_REQUEST;
72*/
73#define Eval(x, y, z) ( *((z *)(&((x)->payload[(y)]))) )
74
75#if !defined(__GNUC__)
76#pragma pack(pop)
77#endif
78
79#endif // __MANGLER_H__
NetCommandType
unsigned char ForwardMaskType
Definition mangler.h:35
@ NET_MANGLER_RESPONSE
Definition mangler.h:38
@ NET_MANGLER_REQUEST
Definition mangler.h:37
unsigned int CRC PACK
Definition mangler.h:53
unsigned char MyMangledAddress[4]
unsigned short MyMangledPortNumber
unsigned short OriginalPortNumber
unsigned int CRC
unsigned char NetCommandType
unsigned short magic
unsigned short Padding
unsigned char BlitzMe