Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
field.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/***************************************************************************
20 * *
21 * Project Name : Westwood Auto Registration App *
22 * *
23 * File Name : FIELD.H *
24 * *
25 * Programmer : Philip W. Gorrow *
26 * *
27 * Start Date : 04/22/96 *
28 * *
29 * Last Update : April 22, 1996 [PWG] *
30 * *
31 * This module takes care of maintaining the field list used to process *
32 * packets. *
33 * *
34 *-------------------------------------------------------------------------*
35 * Functions: *
36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37
38#define FIELD_HEADER_SIZE (sizeof(FieldClass) - (sizeof(void *) * 2))
39
40#define TYPE_CHAR 1
41#define TYPE_UNSIGNED_CHAR 2
42#define TYPE_SHORT 3
43#define TYPE_UNSIGNED_SHORT 4
44#define TYPE_LONG 5
45#define TYPE_UNSIGNED_LONG 6
46#define TYPE_STRING 7
47#define TYPE_CHUNK 20
48
49class PacketClass;
50
52{
53 public:
55 //
56 // Define constructors to be able to create all the different kinds
57 // of fields.
58 //
59 FieldClass(void) {};
60 FieldClass(char *id, char data);
61 FieldClass(char *id, unsigned char data);
62 FieldClass(char *id, short data);
63 FieldClass(char *id, unsigned short data);
64 FieldClass(char *id, long data);
65 FieldClass(char *id, unsigned long data);
66 FieldClass(char *id, char *data);
67 FieldClass(char *id, void *data, int length);
68
70
71 // Change the field contents
72 void Set(char *id, char data);
73 void Set(char *id, unsigned char data);
74 void Set(char *id, short data);
75 void Set(char *id, unsigned short data);
76 void Set(char *id, long data);
77 void Set(char *id, unsigned long data);
78 void Set(char *id, char *data);
79 void Set(char *id, void *data, int length);
80
81 int Get_Type(void); // get the datatype of this field
82 unsigned short Get_Size(void) { return Size; }
83 void * Get_Data(void); // get the datatype of this field
84 char * Get_ID(void); // get the datatype of this field
85
86 void Host_To_Net(void);
87 void Net_To_Host(void);
88
89 private:
90
91 void Clear(void); // dealloc mem & zero safely
92
93 char ID[4]; // id value of this field
94 unsigned short DataType; // id of the data type we are using
95 unsigned short Size; // size of the data portion of this field
96 char *Data; // pointer to the data portion of this field
97 FieldClass *Next; // pointer to the next field in the field list
98};
99
100
101
int Get_Type(void)
Definition field.cpp:212
unsigned short Get_Size(void)
Definition field.h:82
void Net_To_Host(void)
Definition field.cpp:283
void Host_To_Net(void)
Definition field.cpp:237
void * Get_Data(void)
Definition field.cpp:217
friend PacketClass
Definition field.h:54
~FieldClass()
Definition field.cpp:206
FieldClass(void)
Definition field.h:59
char * Get_ID(void)
Definition field.cpp:222
void Set(char *id, char data)
Definition field.cpp:107