FIELD.H 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. ** Command & Conquer Red Alert(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. * *
  20. * Project Name : Westwood Auto Registration App *
  21. * *
  22. * File Name : FIELD.H *
  23. * *
  24. * Programmer : Philip W. Gorrow *
  25. * *
  26. * Start Date : 04/22/96 *
  27. * *
  28. * Last Update : April 22, 1996 [PWG] *
  29. * *
  30. * This module takes care of maintaining the field list used to process *
  31. * packets. *
  32. * *
  33. *-------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef __FIELD_H
  37. #define __FIELD_H
  38. #include <windows.h>
  39. #include <winsock.h>
  40. #define FIELD_HEADER_SIZE (sizeof(FieldClass) - (sizeof(void *) * 2))
  41. #define TYPE_CHAR 1
  42. #define TYPE_UNSIGNED_CHAR 2
  43. #define TYPE_SHORT 3
  44. #define TYPE_UNSIGNED_SHORT 4
  45. #define TYPE_LONG 5
  46. #define TYPE_UNSIGNED_LONG 6
  47. #define TYPE_STRING 7
  48. #define TYPE_CHUNK 20
  49. class PacketClass;
  50. class FieldClass {
  51. public:
  52. friend class PacketClass;
  53. //
  54. // Define constructors to be able to create all the different kinds
  55. // of fields.
  56. //
  57. FieldClass(void) {};
  58. FieldClass(char *id, char data);
  59. FieldClass(char *id, unsigned char data);
  60. FieldClass(char *id, short data);
  61. FieldClass(char *id, unsigned short data);
  62. FieldClass(char *id, long data);
  63. FieldClass(char *id, unsigned long data);
  64. FieldClass(char *id, char *data);
  65. FieldClass(char *id, void *data, int length);
  66. void Host_To_Net(void);
  67. void Net_To_Host(void);
  68. private:
  69. char ID[4]; // id value of this field
  70. unsigned short DataType; // id of the data type we are using
  71. unsigned short Size; // size of the data portion of this field
  72. void *Data; // pointer to the data portion of this field
  73. FieldClass *Next; // pointer to the next field in the field list
  74. };
  75. #endif