FIELD.H 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /***************************************************************************
  15. * *
  16. * Project Name : Westwood Auto Registration App *
  17. * *
  18. * File Name : FIELD.H *
  19. * *
  20. * Programmer : Philip W. Gorrow *
  21. * *
  22. * Start Date : 04/22/96 *
  23. * *
  24. * Last Update : April 22, 1996 [PWG] *
  25. * *
  26. * This module takes care of maintaining the field list used to process *
  27. * packets. *
  28. * *
  29. *-------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef __FIELD_H
  33. #define __FIELD_H
  34. #include <windows.h>
  35. #include <winsock.h>
  36. #define FIELD_HEADER_SIZE (sizeof(FieldClass) - (sizeof(void *) * 2))
  37. #define TYPE_CHAR 1
  38. #define TYPE_UNSIGNED_CHAR 2
  39. #define TYPE_SHORT 3
  40. #define TYPE_UNSIGNED_SHORT 4
  41. #define TYPE_LONG 5
  42. #define TYPE_UNSIGNED_LONG 6
  43. #define TYPE_STRING 7
  44. #define TYPE_CHUNK 20
  45. class PacketClass;
  46. class FieldClass {
  47. public:
  48. friend class PacketClass;
  49. //
  50. // Define constructors to be able to create all the different kinds
  51. // of fields.
  52. //
  53. FieldClass(void) {};
  54. FieldClass(char *id, char data);
  55. FieldClass(char *id, unsigned char data);
  56. FieldClass(char *id, short data);
  57. FieldClass(char *id, unsigned short data);
  58. FieldClass(char *id, long data);
  59. FieldClass(char *id, unsigned long data);
  60. FieldClass(char *id, char *data);
  61. FieldClass(char *id, void *data, int length);
  62. void Host_To_Net(void);
  63. void Net_To_Host(void);
  64. private:
  65. char ID[4]; // id value of this field
  66. unsigned short DataType; // id of the data type we are using
  67. unsigned short Size; // size of the data portion of this field
  68. void *Data; // pointer to the data portion of this field
  69. FieldClass *Next; // pointer to the next field in the field list
  70. };
  71. #endif