Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
packet.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 : PACKET.H *
24 * *
25 * Programmer : Philip W. Gorrow *
26 * *
27 * Start Date : 04/19/96 *
28 * *
29 * Last Update : April 19, 1996 [PWG] *
30 * *
31 * This header defines the functions for the PacketClass. The packet *
32 * class is used to create a linked list of field entries which can be *
33 * converted to a linear packet in a COMMS API compatible format. *
34 * *
35 * Packets can be created empty and then have fields added to them or can *
36 * be created from an existing linear packet. *
37 * *
38 *-------------------------------------------------------------------------*
39 * Functions: *
40 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
41
42#include "field.h"
43#include <wlib/wstypes.h>
44
45
47{
48 public:
49
50 PacketClass(short id = 0)
51 {
52 Size = 0;
53 ID = id;
54 Head = 0;
55 }
56 PacketClass(char *cur_buf);
58
59 //
60 // This function allows us to add a field to the start of the list. As the field is just
61 // a big linked list it makes no difference which end we add a member to.
62 //
63 void Add_Field(FieldClass *field);
64
65 //
66 // These conveniance functions allow us to add a field directly to the list without
67 // having to worry about newing one first.
68 //
69 void Add_Field(char *field, char data) {Add_Field(new FieldClass(field, data));};
70 void Add_Field(char *field, unsigned char data) {Add_Field(new FieldClass(field, data));};
71 void Add_Field(char *field, short data) {Add_Field(new FieldClass(field, data));};
72 void Add_Field(char *field, unsigned short data) {Add_Field(new FieldClass(field, data));};
73 void Add_Field(char *field, long data) {Add_Field(new FieldClass(field, data));};
74 void Add_Field(char *field, unsigned long data) {Add_Field(new FieldClass(field, data));};
75 void Add_Field(char *field, char *data) {Add_Field(new FieldClass(field, data));};
76 void Add_Field(char *field, void *data, int length) {Add_Field(new FieldClass(field, data, length));};
77
78 //
79 // These functions search for a field of a given name in the list and
80 // return the data via a reference value.
81 //
82 FieldClass *Find_Field(char *id);
83
84 bit8 Get_Field(char *id, int &data);
85 bit8 Get_Field(char *id, char &data);
86 bit8 Get_Field(char *id, unsigned char &data);
87 bit8 Get_Field(char *id, short &data);
88 bit8 Get_Field(char *id, unsigned short &data);
89 bit8 Get_Field(char *id, long &data);
90 bit8 Get_Field(char *id, unsigned long &data);
91 bit8 Get_Field(char *id, unsigned &data);
92 bit8 Get_Field(char *id, char *data);
93 bit8 Get_Field(char *id, void *data, int &length);
94 unsigned short Get_Field_Size(char* id);
95
96 // gks 9/25/2000
97 FieldClass *Get_Field_At(int position);
98 int Get_Num_Fields();
99
100 char *Create_Comms_Packet(int &size);
101
102 private:
103 unsigned short Size;
104 short ID;
105 FieldClass *Head;
106 FieldClass *Current;
107};
108
char bit8
Definition wstypes.h:61
void Add_Field(char *field, short data)
Definition packet.h:71
FieldClass * Find_Field(char *id)
Definition packet.cpp:264
void Add_Field(FieldClass *field)
Definition packet.cpp:87
void Add_Field(char *field, long data)
Definition packet.h:73
char * Create_Comms_Packet(int &size)
Definition packet.cpp:183
bit8 Get_Field(char *id, int &data)
Definition packet.cpp:419
void Add_Field(char *field, char *data)
Definition packet.h:75
void Add_Field(char *field, char data)
Definition packet.h:69
void Add_Field(char *field, void *data, int length)
Definition packet.h:76
PacketClass(short id=0)
Definition packet.h:50
void Add_Field(char *field, unsigned char data)
Definition packet.h:70
unsigned short Get_Field_Size(char *id)
Definition packet.cpp:514
FieldClass * Get_Field_At(int position)
Definition packet.cpp:275
void Add_Field(char *field, unsigned short data)
Definition packet.h:72
void Add_Field(char *field, unsigned long data)
Definition packet.h:74
int Get_Num_Fields()
Definition packet.cpp:287