Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
gamemaps.cpp
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/* $Header: /Commando/Code/Tools/max2w3d/gamemaps.cpp 5 10/28/97 6:08p Greg_h $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando / G 3D engine *
25 * *
26 * File Name : GAMEMAPS.CPP *
27 * *
28 * Programmer : Greg Hjelstrom *
29 * *
30 * Start Date : 06/26/97 *
31 * *
32 * Last Update : June 26, 1997 [GH] *
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * GameMapsClass::ClassID -- Returns the ClassID for GameMapsClass *
37 * GameMapsClass::AssignController -- Assigns a controller to one of the Sub-Anims *
38 * GameMapsClass::NotifyRefChanged -- Max is notifying GameMapsClass that a reference has cha*
39 * GameMapsClass::Clone -- Create a clone of the GameMapsClass *
40 * GameMapsClass::Save -- Saves the GameMapsClass data into a MAX file *
41 * GameMapsClass::Load -- Loads GameMapsClass data from a MAX file *
42 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
43
44
45#include "gamemaps.h"
46
47
48/*****************************************************************
49*
50* Chunk ID's for saving data in the MAX file.
51*
52*****************************************************************/
53#define GAMEMAPS_ONOFF_CHUNK 0x0000
54#define GAMEMAPS_AMT0_CHUNK 0x0001
55#define GAMEMAPS_AMT1_CHUNK 0x0002
56#define GAMEMAPS_AMT2_CHUNK 0x0003
57#define GAMEMAPS_AMT3_CHUNK 0x0004
58#define GAMEMAPS_AMT4_CHUNK 0x0005
59#define GAMEMAPS_AMT5_CHUNK 0x0006
60#define GAMEMAPS_AMT6_CHUNK 0x0007
61#define GAMEMAPS_AMT7_CHUNK 0x0008
62#define GAMEMAPS_AMT8_CHUNK 0x0009
63#define GAMEMAPS_AMT9_CHUNK 0x000A
64#define GAMEMAPS_AMTA_CHUNK 0x000B
65
66
67/*****************************************************************
68*
69* A PostLoadCallback which does nothing...
70*
71*****************************************************************/
72class GameMapsPostLoad : public PostLoadCallback
73{
74public:
77 void proc(ILoad *iload) { delete this; }
78};
79
80
81/*****************************************************************
82*
83* GameMapsClass Class Desriptor
84*
85*****************************************************************/
86static Class_ID _GameMapsClassID(0x36d23f7b, 0x79ce63e1);
87
88class GameMapsClassDesc : public ClassDesc
89{
90 public:
91 int IsPublic() { return 0; }
92 void * Create(BOOL loading) { return new GameMapsClass(NULL); }
93 const TCHAR * ClassName() { return _T("GameMaps"); }
94 SClass_ID SuperClassID() { return REF_MAKER_CLASS_ID; }
95 Class_ID ClassID() { return _GameMapsClassID; }
96 const TCHAR* Category() { return _T(""); }
97};
98
99static GameMapsClassDesc _GameMapsCD;
100
101ClassDesc * Get_Game_Maps_Desc() { return &_GameMapsCD; }
102
103
104/***********************************************************************************************
105 * GameMapsClass::ClassID -- Returns the ClassID for GameMapsClass *
106 * *
107 * INPUT: *
108 * *
109 * OUTPUT: *
110 * *
111 * WARNINGS: *
112 * *
113 * HISTORY: *
114 * 06/26/1997 GH : Created. *
115 *=============================================================================================*/
117{
118 return _GameMapsClassID;
119}
120
121/***********************************************************************************************
122 * GameMapsClass::AssignController -- Assigns a controller to one of the Sub-Anims *
123 * *
124 * INPUT: *
125 * *
126 * OUTPUT: *
127 * *
128 * WARNINGS: *
129 * *
130 * HISTORY: *
131 * 06/26/1997 GH : Created. *
132 *=============================================================================================*/
133BOOL GameMapsClass::AssignController(Animatable *control,int subAnim)
134{
135 ReplaceReference(SubNumToRefNum(subAnim),(ReferenceTarget *)control);
136 return TRUE;
137}
138
139/***********************************************************************************************
140 * GameMapsClass::NotifyRefChanged -- Max is notifying GameMapsClass that a reference has chan *
141 * *
142 * INPUT: *
143 * *
144 * OUTPUT: *
145 * *
146 * WARNINGS: *
147 * *
148 * HISTORY: *
149 * 06/26/1997 GH : Created. *
150 *=============================================================================================*/
152(
153 Interval changeInt,
154 RefTargetHandle hTarget,
155 PartID & partID,
156 RefMessage message
157)
158{
159 switch (message) {
160 case REFMSG_GET_PARAM_DIM: {
161 GetParamDim *gpd = (GetParamDim*)partID;
162 break;
163 }
164 case REFMSG_GET_PARAM_NAME: {
165 GetParamName *gpn = (GetParamName*)partID;
166 return REF_STOP;
167 }
168 }
169 return(REF_SUCCEED);
170}
171
172/***********************************************************************************************
173 * GameMapsClass::Clone -- Create a clone of the GameMapsClass *
174 * *
175 * INPUT: *
176 * *
177 * OUTPUT: *
178 * *
179 * WARNINGS: *
180 * *
181 * HISTORY: *
182 * 06/26/1997 GH : Created. *
183 *=============================================================================================*/
184RefTargetHandle GameMapsClass::Clone(RemapDir &remap)
185{
187
188 for (int i=0; i<NTEXMAPS; i++) {
189 tm->TextureSlot[i].MapOn = TextureSlot[i].MapOn;
190 tm->TextureSlot[i].Map = NULL;
191
192 if (TextureSlot[i].Map) {
193 tm->ReplaceReference(i,remap.CloneRef(TextureSlot[i].Map));
194 }
195 }
196
197 return tm;
198}
199
200
201/***********************************************************************************************
202 * GameMapsClass::Save -- Saves the GameMapsClass data into a MAX file *
203 * *
204 * INPUT: *
205 * *
206 * OUTPUT: *
207 * *
208 * WARNINGS: *
209 * *
210 * HISTORY: *
211 * 06/26/1997 GH : Created. *
212 *=============================================================================================*/
213IOResult GameMapsClass::Save(ISave * isave)
214{
215 ULONG nb,f=0;
216
217 isave->BeginChunk(GAMEMAPS_ONOFF_CHUNK);
218 for (int i=0; i<NTEXMAPS; i++) {
219 if (TextureSlot[i].MapOn) f|= (1<<i);
220 }
221 isave->Write(&f,sizeof(f),&nb);
222 isave->EndChunk();
223
224 for (i=0; i<NTEXMAPS; i++) {
225 if (TextureSlot[i].Amount != 1.0f) {
226 isave->BeginChunk(GAMEMAPS_AMT0_CHUNK + i);
227 isave->Write(&(TextureSlot[i].Amount),sizeof(float),&nb);
228 isave->EndChunk();
229 }
230 }
231 return IO_OK;
232}
233
234
235/***********************************************************************************************
236 * GameMapsClass::Load -- Loads GameMapsClass data from a MAX file *
237 * *
238 * INPUT: *
239 * *
240 * OUTPUT: *
241 * *
242 * WARNINGS: *
243 * *
244 * HISTORY: *
245 * 06/26/1997 GH : Created. *
246 *=============================================================================================*/
247IOResult GameMapsClass::Load(ILoad * iload)
248{
249 ULONG nb;
250 int id;
251 IOResult res;
252
253 while (IO_OK==(res=iload->OpenChunk())) {
254
255 switch (id = iload->CurChunkID()) {
257 {
258 ULONG f;
259 res = iload->Read(&f,sizeof(f), &nb);
260 for (int i=0; i<NTEXMAPS; i++)
261 (*this)[i].MapOn = (f&(1<<i))?1:0;
262 }
263 break;
264
275 int index = id - GAMEMAPS_AMT0_CHUNK;
276 res = iload->Read(&(TextureSlot[index].Amount),sizeof(float),&nb);
277 break;
278 }
279
280 iload->CloseChunk();
281 if (res!=IO_OK) {
282 return res;
283 }
284 }
285 return IO_OK;
286}
287
#define NULL
Definition BaseType.h:92
#define TRUE
Definition BaseType.h:109
unsigned long ULONG
Definition bittype.h:64
#define BOOL
Definition Wnd_File.h:57
const TCHAR * Category()
Definition gamemaps.cpp:96
void * Create(BOOL loading)
Definition gamemaps.cpp:92
Class_ID ClassID()
Definition gamemaps.cpp:95
const TCHAR * ClassName()
Definition gamemaps.cpp:93
SClass_ID SuperClassID()
Definition gamemaps.cpp:94
RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message)
Definition gamemaps.cpp:152
IOResult Load(ILoad *iload)
Definition gamemaps.cpp:247
BOOL AssignController(Animatable *control, int subAnim)
Definition gamemaps.cpp:133
int SubNumToRefNum(int subNum)
Definition gamemaps.h:103
TexmapSlotClass TextureSlot[NTEXMAPS]
Definition gamemaps.h:87
IOResult Save(ISave *isave)
Definition gamemaps.cpp:213
RefTargetHandle Clone(RemapDir &remap)
Definition gamemaps.cpp:184
Class_ID ClassID()
Definition gamemaps.cpp:116
GameMapsPostLoad(GameMapsClass *b)
Definition gamemaps.cpp:76
void proc(ILoad *iload)
Definition gamemaps.cpp:77
GameMapsClass * tm
Definition gamemaps.cpp:75
Texmap * Map
Definition gamemaps.h:60
#define GAMEMAPS_AMT1_CHUNK
Definition gamemaps.cpp:55
ClassDesc * Get_Game_Maps_Desc()
Definition gamemaps.cpp:101
#define GAMEMAPS_AMT3_CHUNK
Definition gamemaps.cpp:57
#define GAMEMAPS_AMT8_CHUNK
Definition gamemaps.cpp:62
#define GAMEMAPS_AMT2_CHUNK
Definition gamemaps.cpp:56
#define GAMEMAPS_AMT5_CHUNK
Definition gamemaps.cpp:59
#define GAMEMAPS_AMT4_CHUNK
Definition gamemaps.cpp:58
#define GAMEMAPS_AMTA_CHUNK
Definition gamemaps.cpp:64
#define GAMEMAPS_ONOFF_CHUNK
Definition gamemaps.cpp:53
#define GAMEMAPS_AMT0_CHUNK
Definition gamemaps.cpp:54
#define GAMEMAPS_AMT7_CHUNK
Definition gamemaps.cpp:61
#define GAMEMAPS_AMT9_CHUNK
Definition gamemaps.cpp:63