mangler.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #ifndef __MANGLER_H__
  19. #define __MANGLER_H__
  20. // Packet should consist of a GlobalHeaderType followed by a GlobalPacketType with the fields set as
  21. // indicated.
  22. /*
  23. ********************************** Defines **********************************
  24. */
  25. // This is the number of additional ports to which to reply.
  26. #define BLITZ_SIZE 3
  27. #define MPLAYER_NAME_MAX 20
  28. #define SERIAL_MAX 23
  29. typedef unsigned char ForwardMaskType;
  30. typedef enum NetCommandType {
  31. NET_MANGLER_REQUEST = 43,
  32. NET_MANGLER_RESPONSE = 44
  33. } NetCommandType;
  34. /*
  35. ** One byte alignment.
  36. */
  37. #if !defined(__GNUC__)
  38. #pragma pack(push, 1)
  39. #define PACK
  40. #else
  41. #define PACK __attribute__ ((__packed__))
  42. #endif
  43. // size = 20 bytes
  44. struct ManglerData {
  45. unsigned int CRC PACK;
  46. unsigned short magic PACK;
  47. unsigned short packetID PACK;
  48. unsigned short MyMangledPortNumber PACK;
  49. unsigned short OriginalPortNumber PACK;
  50. unsigned char MyMangledAddress[4] PACK;
  51. unsigned char NetCommandType PACK;
  52. unsigned char BlitzMe PACK;
  53. unsigned short Padding PACK;
  54. };
  55. /*
  56. This is for older GCC versions that can't do byte-packing.
  57. Instead of declaring
  58. GlobalPacketType p;
  59. p.Command = NET_MANGLER_REQUEST;
  60. you would do something like this:
  61. GlobalPacketStruct p;
  62. Eval(&p, GPCommand, NetCommandType) = NET_MANGLER_REQUEST;
  63. */
  64. #define Eval(x, y, z) ( *((z *)(&((x)->payload[(y)]))) )
  65. #if !defined(__GNUC__)
  66. #pragma pack(pop)
  67. #endif
  68. #endif // __MANGLER_H__