Rise
The Vieneo Province
renderer.cpp
Go to the documentation of this file.
1 #include "renderer.h"
2 #include "Viewscreen.h"
3 
4 #include <fcntl.h> // For _O_RDWR, _O_BINARY, _O_RDONLY, O_TEXT
5 #include <sys/stat.h> // For _S_IWRITE, _S_IREAD
6 #include <SDKmisc.h>
7 
8 #include "../resource.h"
9 #include "../MathUtilities.h"
10 
11 float renderer::timepassed = 0.0f;
12 
14 {
15  viewscreen = ptr;
16  logger = ptr->logger;
17 }
18 
19 void renderer::LoadTextures(IDirect3DDevice9* pd3dDevice, short* stage, short* instage)
20 {
21  logger->AddToCallStack("renderer::LoadTextures");
22 
23  short t;
24 
25  D3DXMATRIX matScale;
26  D3DXMatrixScaling(&matScale, viewscreen->gameclass->displayscale, viewscreen->gameclass->displayscale, 1.0f);
27  viewscreen->m_spriteVector->SetTransform(&matScale);
28 
29  CDXUTTextHelper txtHelper(viewscreen->m_pFont, viewscreen->m_spriteVector, 20);
30  txtHelper.Begin();
31  txtHelper.SetInsertionPos(5, 5);
32  txtHelper.SetForegroundColor(0xFFFF00FF);
33 
34  if (*stage >= 0)
35  {
36 #ifdef _WIN64
37 #ifdef _DEBUG
38  txtHelper.DrawTextLine(L"Welcome to Rise: The Vieneo Province! (64-bit debug)");
39 #else
40  txtHelper.DrawTextLine(L"Welcome to Rise: The Vieneo Province! (64-bit)");
41 #endif
42 #else
43 #ifdef _DEBUG
44  txtHelper.DrawTextLine(L"Welcome to Rise: The Vieneo Province! (32-bit debug)");
45 #else
46  txtHelper.DrawTextLine(L"Welcome to Rise: The Vieneo Province! (32-bit)");
47 #endif
48 #endif
49 
50  if (*stage == 0)
51  {
52 #ifdef _WIN64
53 #ifdef _DEBUG
54  sprintf_s(msg, sizeof(msg), "Welcome to Rise: The Vieneo Province! (64-bit debug)");
55 #else
56  sprintf_s(msg, sizeof(msg), "Welcome to Rise: The Vieneo Province! (64-bit)");
57 #endif
58 #else
59 #ifdef _DEBUG
60  sprintf_s(msg, sizeof(msg), "Welcome to Rise: The Vieneo Province! (32-bit debug)");
61 #else
62  sprintf_s(msg, sizeof(msg), "Welcome to Rise: The Vieneo Province! (32-bit)");
63 #endif
64 #endif
65  *instage = -1;
66  }
67  }
68 
69  if (*stage < 29)
70  txtHelper.DrawFormattedTextLine(L"Resources loading... (%i MB free)", pd3dDevice->GetAvailableTextureMem() / 2048000);
71  else
72  txtHelper.DrawFormattedTextLine(L"Resources loaded successfully! (%i MB free)", pd3dDevice->GetAvailableTextureMem() / 2048000);
73 
74  if (*stage >= 1)
75  {
86  {
87  txtHelper.DrawTextLine(L"Game controller support enabled...");
88  if (*stage == 1)
89  {
90  logger->Log("Game controller support enabled...");
91  *instage = -1;
92  }
93  }
94  else
95  {
96  txtHelper.DrawTextLine(L"No game controllers configured!");
97  if (*stage == 1)
98  {
99  logger->Log("No game controllers configured!", Logger::Level::Warn);
100  *instage = -1;
101  }
102  }
103 
114  {
115  txtHelper.DrawTextLine(L"Force feedback support enabled...");
116  if (*stage == 1)
117  {
118  logger->Log("Force feedback support enabled...");
119  *instage = -1;
120  }
121  }
122 
124  {
125  txtHelper.DrawTextLine(L"Device supports advanced occlusion effects...");
126  if (*stage == 1)
127  {
128  logger->Log("Device supports advanced occlusion effects...");
129  *instage = -1;
130  }
131  }
132  else
133  {
134  txtHelper.DrawTextLine(L"Sorry, no support for advanced occlusion effects!");
135  if (*stage == 1)
136  {
137  logger->Log("Sorry, no support for advanced occlusion effects!", Logger::Level::Warn);
138  *instage = -1;
139  }
140  }
141 
142  if (*stage == 1)
143  {
144  D3DCAPS9 caps;
145  pd3dDevice->GetDeviceCaps(&caps);
146  if (!(caps.FVFCaps & D3DFVFCAPS_PSIZE))
147  {
148  sprintf_s(msg, sizeof(msg), "Sorry, no support for advanced particle effects!");
149  viewscreen->m_bPsize = false;
150  logger->Log(msg, Logger::Level::Warn);
151  }
152  else
153  {
154  sprintf_s(msg, sizeof(msg), "Device has compatible particle effects support...");
155  viewscreen->m_bPsize = true;
156  logger->Log(msg);
157  }
158  }
159 
160  // Test for vs 1.1 and ps 2.0
161  txtHelper.DrawTextLine(L"Device has compatible vertex and pixel shaders!");
162  if (*stage == 1)
163  {
164  logger->Log("Device has compatible vertex and pixel shaders!");
165  }
166  } // stage 1
167 
168  if (*stage >= 2)
169  {
170  if (*stage > 2)
171  txtHelper.DrawTextLine(L"Celestial textures loaded!");
172  if (*stage == 2 && *instage == 1)
173  {
174  txtHelper.DrawTextLine(L"Celestial textures loading (Iomere)...");
175  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\World2a1.dds",
176  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
177  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
178  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsWorld2a1)))
179  {
180  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\World2a1.dds\"! (%x)", hr);
181  logger->Log(msg, Logger::Level::Fatal);
182  }
183  else
184  viewscreen->gameclass->AddTrackedResource("m_pddsWorld2a1"); // managed
185  *instage = -1;
186  }
187  if (*stage == 2 && *instage == 0)
188  {
189  txtHelper.DrawTextLine(L"Celestial textures loading (Yonmara)...");
190  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\sunmap.dds",
191  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
192  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
193  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsSunTexture)))
194  {
195  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\sunmap.dds\"! (%x)", hr);
196  logger->Log(msg, Logger::Level::Fatal);
197  }
198  else
199  viewscreen->gameclass->AddTrackedResource("m_pddsSunTexture"); // managed
200  logger->Log("M -> Celestial textures loaded...");
201  *instage = 1;
202  }
203  }
204 
205  if (*stage >= 3)
206  {
207  if (*stage > 3)
208  txtHelper.DrawTextLine(L"Vehicle textures loaded!");
209  if (*stage == 3)
210  {
211  (*instage)++; // start at 1
212 
213  txtHelper.DrawFormattedTextLine(L"Vehicle textures loading (%i/%i)...", *instage, shiptextureC);
214 
215  if (*instage == shiptextureC) // while less than shiptextureC
216  {
217  *instage = -1;
218  logger->Log("Vehicle textures loaded...");
219  }
220  else
221  {
222  WCHAR hullfile[199], lightfile[199];
223  t = *instage;
224  // Defaults
225  hullfile[0] = lightfile[0] = 0;
226  switch (t)
227  {
228  // E-10
229  case 1: wcscpy_s(hullfile, 199, L"textures\\Ships\\BOW.dds");
230  wcscpy_s(lightfile, 199, L"textures\\Ships\\BOWLIGHT.dds");
231  break;
232  case 2: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-cargohold-b.dds");
233  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-cargohold-bLIGHT.dds");
234  break;
235  case 3: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-cockpit-a1.dds");
236  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-cockpit-a1LIGHT.dds");
237  break;
238  case 4: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-bow-a-b.dds");
239  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-bow-a-bLIGHT.dds");
240  break;
241  case 5: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-docking module-a-b.dds");
242  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-docking module-a-bLIGHT.dds");
243  break;
244  case 6: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-landing pad pod.dds");
245  break;
246  case 7: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-engineering-b1.dds");
247  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-engineering-b1LIGHT.dds");
248  break;
249  case 8: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-port engine boom.dds");
250  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-port engine boomLIGHT.dds");
251  break;
252  case 9: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-starboard engine boom.dds");
253  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-starboard engine boomLIGHT.dds");
254  break;
255  case 10: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-oval wing.dds");
256  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-oval wingLIGHT.dds");
257  break;
258  case 11: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-engine pod mount.dds");
259  break;
260  case 12: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-engine pod.dds");
261  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-engine podLIGHT.dds");
262  break;
263  case 13: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-engine pod pylon-port.dds");
264  break;
265  case 14: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-engine pod pylon-starboard.dds");
266  break;
267  case 15: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-tailfin.dds");
268  break;
269  case 16: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-engine pod wing.dds");
270  break;
271  case 17: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-engineering-a1.dds");
272  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-engineering-a1LIGHT.dds");
273  break;
274  case 18: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-access module-b1.dds");
275  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-access module-b1LIGHT.dds");
276  break;
277  case 19: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-landing pad-2.dds");
278  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-landing pad-2LIGHT.dds");
279  break;
280  case 20: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-landing pad-1.dds");
281  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-landing pad-1LIGHT.dds");
282  break;
283  case 21: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-tailfin-flap.dds");
284  break;
285  case 22: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-PLATE.dds");
286  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-PLATELIGHT.dds");
287  break;
288  case 23: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-oval wing-flap.dds");
289  break;
290  case 24: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-ramp.dds");
291  wcscpy_s(lightfile, 199, L"textures\\Ships\\e10-rampLIGHT.dds");
292  break;
293  case 25: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-engine pod wing-flap.dds");
294  break;
295  // DIHV
296  case 26: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\command.dds");
297  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\commandLIGHT.dds");
298  break;
299  case 27: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\DIHVengine.dds");
300  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\DIHVengineLIGHT.dds");
301  break;
302  case 28: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\nosecone.dds");
303  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\noseconeLIGHT.dds");
304  break;
305  case 29: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\connectring1.dds");
306  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\connectring1LIGHT.dds");
307  break;
308  case 30: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\towpackage.dds");
309  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\towpackageLIGHT.dds");
310  break;
311  case 31: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\cargonode.dds");
312  break;
313  case 32: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\cargohall.dds");
314  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\cargohallLIGHT.dds");
315  break;
316  case 33: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\cargocontainer.dds");
317  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\cargocontainerLIGHT.dds");
318  break;
319  case 34: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\hallcap.dds");
320  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\hallcapLIGHT.dds");
321  break;
322  case 35: wcscpy_s(hullfile, 199, L"textures\\Large Ships\\DIHV-PLATE.dds");
323  wcscpy_s(lightfile, 199, L"textures\\Large Ships\\DIHV-PLATELIGHT.dds");
324  break;
325  // PODS (AFT LOADER)
326  case 36: wcscpy_s(hullfile, 199, L"textures\\Containers\\cargo-standard-ext.dds");
327  break;
328  case 37: wcscpy_s(hullfile, 199, L"textures\\Containers\\tank-fuel-dynamic.dds");
329  wcscpy_s(lightfile, 199, L"textures\\Containers\\tank-fuel-dynamicLIGHT.dds");
330  break;
331  // PODS (AUX FUEL)
332  case 38: wcscpy_s(hullfile, 199, L"textures\\Containers\\fuel-standard-ext.dds");
333  break;
334  case 39: wcscpy_s(hullfile, 199, L"textures\\Containers\\tank-fuel.dds");
335  break;
336  case 40: wcscpy_s(hullfile, 199, L"textures\\Containers\\tank-cap.dds");
337  break;
338  // PODS (TOP LOADER)
339  case 41: wcscpy_s(hullfile, 199, L"textures\\Containers\\cargo-toploader-ext.dds");
340  break;
341  // PODS (MUNITIONS)
342  case 42: wcscpy_s(hullfile, 199, L"textures\\Containers\\munitions-standard-ext.dds");
343  break;
344  // MuVER
345  case 43: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-glass-1.dds");
346  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\GV-glass-1LIGHT.dds");
347  break;
348  case 44: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-construction-1.dds");
349  break;
350  case 45: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-guts-1.dds");
351  break;
352  case 46: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-mirrors-1.dds");
353  break;
354  case 47: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-lights-1.dds");
355  // using the day map as the light map
356  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\GV-lights-1.dds");
357  break;
358  case 48: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-lockers-1.dds");
359  break;
360  case 49: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-mod-1.dds");
361  break;
362  case 50: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-galanovo-1.dds");
363  break;
364  case 51: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-galanovo-2.dds");
365  break;
366  case 52: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-stripped-1.dds");
367  break;
368  case 53: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-bumpers-1.dds");
369  break;
370  case 54: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-suspension-1.dds");
371  break;
372  case 55: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-tires-1.dds");
373  break;
374  case 56: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\licensePlateStd.dds");
375  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\licensePlateStdLIGHT.dds");
376  break;
377  // Prowler
378  case 57: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-cockpit.dds");
379  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-cockpitLIGHT.dds");
380  break;
381  case 58: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-intake.dds");
382  break;
383  case 59: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-aerodyn.dds");
384  break;
385  case 60: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-landing toe.dds");
386  break;
387  case 61: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-wing-port-flap1.dds");
388  break;
389  case 62: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-wing-port-flap2.dds");
390  break;
391  case 63: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-wing-starboard-flap1.dds");
392  break;
393  case 64: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-wing-starboard-flap2.dds");
394  break;
395  case 65: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-thruster.dds");
396  break;
397  case 66: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-equipment cowl.dds");
398  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-equipment cowlLIGHT.dds");
399  break;
400  case 67: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-landing pod.dds");
401  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-landing podLIGHT.dds");
402  break;
403  case 68: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-landing leg-4x14.dds");
404  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-landing leg-4x14LIGHT.dds");
405  break;
406  case 69: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-wing-port.dds");
407  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-wing-portLIGHT.dds");
408  break;
409  case 70: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-wing-starboard.dds");
410  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-wing-starboardLIGHT.dds");
411  break;
412  case 71: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-weapons pod.dds");
413  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-weapons podLIGHT.dds");
414  break;
415  case 72: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-corridor.dds");
416  break;
417  case 73: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-crewcabin.dds");
418  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-crewcabinLIGHT.dds");
419  break;
420  case 74: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-engineering.dds");
421  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-engineeringLIGHT.dds");
422  break;
423  case 75: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-equipment wedge.dds");
424  break;
425  case 76: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-propulsion unit.dds");
426  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-propulsion unitLIGHT.dds");
427  break;
428  case 77: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-drive coil-port.dds");
429  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-drive coil-portLIGHT.dds");
430  break;
431  case 78: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-drive coil-starboard.dds");
432  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-drive coil-starboardLIGHT.dds");
433  break;
434  case 79: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-docking module.dds");
435  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-docking moduleLIGHT.dds");
436  break;
437  case 80: wcscpy_s(hullfile, 199, L"textures\\Cities\\WEP-source1.dds");
438  break;
439  case 81: wcscpy_s(hullfile, 199, L"textures\\Ships\\p13-police rack.dds");
440  wcscpy_s(lightfile, 199, L"textures\\Ships\\p13-police rackLIGHT.dds");
441  break;
442  // A-4 (aka T-8) (aka A-3)
443  case 82: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-cockpit.dds");
444  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-cockpitLIGHT.dds");
445  break;
446  case 83: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-landing pod.dds");
447  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-landing podLIGHT.dds");
448  break;
449  case 84: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-wing1.dds");
450  break;
451  case 85: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-wing1flap.dds");
452  break;
453  case 86: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-landing leg2.dds");
454  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-landing leg2LIGHT.dds");
455  break;
456  case 87: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-wingmount.dds");
457  break;
458  case 88: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-braceshaft2.dds");
459  break;
460  case 89: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-wing1hinge.dds");
461  break;
462  case 90: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-corridor.dds");
463  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-corridorLIGHT.dds");
464  break;
465  case 91: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-fuselage2.dds");
466  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-fuselage2LIGHT.dds");
467  break;
468  case 92: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-cargoslope1.dds");
469  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-cargoslope1LIGHT.dds");
470  break;
471  case 93: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-cargobay1.dds");
472  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-cargobay1LIGHT.dds");
473  break;
474  case 94: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-cargoslope1hatch.dds");
475  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-cargoslope1hatchLIGHT.dds");
476  break;
477  case 95: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-aerodyn.dds");
478  break;
479  case 96: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-wing1-angle45.dds");
480  break;
481  case 97: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-wing1-angle45flap.dds");
482  break;
483  case 98: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-tailfin.dds");
484  break;
485  case 99: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-tailfin-flap.dds");
486  break;
487  case 100: wcscpy_s(hullfile, 199, L"textures\\Ships\\a3-enginepod.dds");
488  wcscpy_s(lightfile, 199, L"textures\\Ships\\a3-enginepodLIGHT.dds");
489  break;
490  // C-2 Dasher
491  // T-1 Stratoranger (THIS IS GONE NOW SO THESE MAY BE USED BY SUBSEQUENT MODELS)
492  case 101: wcscpy_s(hullfile, 199, L"textures\\Ships\\e10-access ramp-2.dds"); // this guy is definitely used by a subsequent model so he will move
493  break;
494  case 102: wcscpy_s(hullfile, 199, L"textures\\Ships\\LANDING LEG1.dds"); // this guy is definitely gone! delete the file from Textures\\Ships
495  break;
496  // T-120 Steerhead
497  case 103: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-1.dds");
498  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\GV-1LIGHT.dds");
499  break;
500  case 104: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\lightmod1.dds");
501  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\lightmod1.dds");
502  break;
503  case 105: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\cargo2.dds");
504  break;
505  // E-11
506  case 106: wcscpy_s(hullfile, 199, L"textures\\Ships\\BODY-BOTTOM.dds");
507  break;
508  case 107: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-ramp.dds");
509  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-rampLIGHT.dds");
510  break;
511  case 108: wcscpy_s(hullfile, 199, L"textures\\Ships\\DOOR-DOCK.dds");
512  wcscpy_s(lightfile, 199, L"textures\\Ships\\DOOR-DOCKLIGHT.dds");
513  break;
514  case 109: wcscpy_s(hullfile, 199, L"textures\\Ships\\BOOM.dds");
515  wcscpy_s(lightfile, 199, L"textures\\Ships\\BOOMLIGHT.dds");
516  break;
517  case 110: wcscpy_s(hullfile, 199, L"textures\\Ships\\BOW-BOTTOM.dds");
518  wcscpy_s(lightfile, 199, L"textures\\Ships\\BOW-BOTTOMLIGHT.dds");
519  break;
520  case 111: wcscpy_s(hullfile, 199, L"textures\\Ships\\EXHAUST.dds");
521  break;
522  case 112: wcscpy_s(hullfile, 199, L"textures\\Ships\\WING.dds");
523  wcscpy_s(lightfile, 199, L"textures\\Ships\\WINGLIGHT.dds");
524  break;
525  case 113: wcscpy_s(hullfile, 199, L"textures\\Ships\\ENGINE.dds");
526  wcscpy_s(lightfile, 199, L"textures\\Ships\\ENGINELIGHT.dds");
527  break;
528  case 114: wcscpy_s(hullfile, 199, L"textures\\Ships\\PAD-REAR.dds");
529  wcscpy_s(lightfile, 199, L"textures\\Ships\\PAD-REARLIGHT.dds");
530  break;
531  case 115: wcscpy_s(hullfile, 199, L"textures\\Ships\\BODY.dds");
532  wcscpy_s(lightfile, 199, L"textures\\Ships\\BODYLIGHT.dds");
533  break;
534  case 116: wcscpy_s(hullfile, 199, L"textures\\Ships\\DOCKCOVER.dds");
535  wcscpy_s(lightfile, 199, L"textures\\Ships\\DOCKCOVERLIGHT.dds");
536  break;
537  case 117: wcscpy_s(hullfile, 199, L"textures\\Ships\\BODYCOVER.dds");
538  break;
539  case 118: wcscpy_s(hullfile, 199, L"textures\\Ships\\CORECOVER.dds");
540  break;
541  case 119: wcscpy_s(hullfile, 199, L"textures\\Ships\\PAD-FRONT.dds");
542  wcscpy_s(lightfile, 199, L"textures\\Ships\\PAD-FRONTLIGHT.dds");
543  break;
544  case 120: wcscpy_s(hullfile, 199, L"textures\\Ships\\FLAPS.dds");
545  break;
546  case 121: wcscpy_s(hullfile, 199, L"textures\\Ships\\e11-PLATE.dds");
547  wcscpy_s(lightfile, 199, L"textures\\Ships\\e11-PLATELIGHT.dds");
548  break;
549  case 122: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-door-standard.dds");
550  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-door-standardLIGHT.dds");
551  break;
552  case 123: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-wall-lockers.dds");
553  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-wall-lockersLIGHT.dds");
554  break;
555  case 124: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-wall-standard.dds");
556  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-wall-standardLIGHT.dds");
557  break;
558  case 125: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-wall-supportangle.dds");
559  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-wall-supportangleLIGHT.dds");
560  break;
561  case 126: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-wall-weaponrack.dds");
562  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-wall-weaponrackLIGHT.dds");
563  break;
564  case 127: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-ceiling.dds");
565  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-ceilingLIGHT.dds");
566  break;
567  case 128: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-conveyor.dds");
568  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-conveyorLIGHT.dds");
569  break;
570  case 129: wcscpy_s(hullfile, 199, L"textures\\Ships\\eva-wall-standard.dds");
571  wcscpy_s(lightfile, 199, L"textures\\Ships\\eva-wall-standardLIGHT.dds");
572  break;
573  // BeishtKione
574  case 130: wcscpy_s(hullfile, 199, L"textures\\Holidays\\BeishtKione_BaseColor1.dds");
575  break;
576  // NEW C-2A Dasher
577  case 131: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\Glass.dds");
578  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\GlassLIGHT.dds");
579  break;
580  case 132: wcscpy_s(hullfile, 199, L"textures\\Cockpits\\door-front.dds");
581  break; // This is part of the wiper which is visible inside and outside
582  case 133: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\body.dds");
583  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\bodyLIGHT.dds");
584  break;
585  case 134: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\undercarriage.dds");
586  break;
587  case 135: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\back1.dds");
588  break;
589  case 136: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\tread1.dds");
590  break;
591  case 137: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\face1.dds");
592  break;
593  // W-6 Manx
594  case 138: wcscpy_s(hullfile, 199, L"textures\\Ships\\Manx_Diff.dds");
595  wcscpy_s(lightfile, 199, L"textures\\Ships\\Manx_DiffLIGHT.dds");
596  break;
597  case 139: wcscpy_s(hullfile, 199, L"textures\\Ships\\name plate.dds");
598  wcscpy_s(lightfile, 199, L"textures\\Ships\\name plateLIGHT.dds");
599  break;
600  // T-19 Stratomaster
601  case 140: wcscpy_s(hullfile, 199, L"textures\\Ships\\painted-default.dds");
602  break;
603  case 141: wcscpy_s(hullfile, 199, L"textures\\Ships\\painted-windshield.dds");
604  wcscpy_s(lightfile, 199, L"textures\\Ships\\painted-windshieldLIGHT.dds");
605  break;
606  case 142: wcscpy_s(hullfile, 199, L"textures\\Ships\\stainless1-bare.dds");
607  break;
608  case 143: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-ramp1.dds");
609  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-ramp1.dds");
610  break;
611  case 144: wcscpy_s(hullfile, 199, L"textures\\Ships\\cabin-wall-storage.dds");
612  wcscpy_s(lightfile, 199, L"textures\\Ships\\cabin-wall-storage.dds");
613  break;
614  case 145: wcscpy_s(hullfile, 199, L"textures\\Ships\\gear.dds");
615  wcscpy_s(lightfile, 199, L"textures\\Ships\\gear.dds");
616  break;
617  case 146: wcscpy_s(hullfile, 199, L"textures\\Ships\\cabin-floor-carpet.dds");
618  wcscpy_s(lightfile, 199, L"textures\\Ships\\cabin-floor-carpet.dds");
619  break;
620  case 147: wcscpy_s(hullfile, 199, L"textures\\Ships\\painted-wing-upper.dds");
621  wcscpy_s(lightfile, 199, L"textures\\Ships\\painted-wing-upperLIGHT.dds");
622  break;
623  case 148: wcscpy_s(hullfile, 199, L"textures\\Ships\\painted-wing-lower.dds");
624  break;
625  case 149: wcscpy_s(hullfile, 199, L"textures\\Ships\\engine-zefferfiche-turbine.dds");
626  break;
627  case 150: wcscpy_s(hullfile, 199, L"textures\\Ships\\painted-flaps-upper.dds");
628  break;
629  case 151: wcscpy_s(hullfile, 199, L"textures\\Ships\\painted-flaps-lower.dds");
630  break;
631  case 152: wcscpy_s(hullfile, 199, L"textures\\Ships\\lights.dds");
632  wcscpy_s(lightfile, 199, L"textures\\Ships\\lights.dds");
633  break;
634  case 153: wcscpy_s(hullfile, 199, L"textures\\Ships\\dynamic-stratomaster.dds");
635  break;
636  case 154: wcscpy_s(hullfile, 199, L"textures\\Ships\\substructure-standard.dds");
637  wcscpy_s(lightfile, 199, L"textures\\Ships\\substructure-standard.dds");
638  break;
639  case 155: wcscpy_s(hullfile, 199, L"textures\\Ships\\cabin-wall-standard.dds");
640  wcscpy_s(lightfile, 199, L"textures\\Ships\\cabin-wall-standard.dds");
641  break;
642  case 156: wcscpy_s(hullfile, 199, L"textures\\Ships\\cabin-wall-filler.dds");
643  wcscpy_s(lightfile, 199, L"textures\\Ships\\cabin-wall-filler.dds");
644  break;
645  case 157: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-conveyor1.dds");
646  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-conveyor1.dds");
647  break;
648  case 158: wcscpy_s(hullfile, 199, L"textures\\Ships\\cabin-ceiling.dds");
649  wcscpy_s(lightfile, 199, L"textures\\Ships\\cabin-ceiling.dds");
650  break;
651  case 159: wcscpy_s(hullfile, 199, L"textures\\Ships\\cabin-wall-weaponrack.dds");
652  wcscpy_s(lightfile, 199, L"textures\\Ships\\cabin-wall-weaponrack.dds");
653  break;
654  case 160: wcscpy_s(hullfile, 199, L"textures\\Ships\\painted-engine.dds");
655  break;
656  case 161: wcscpy_s(hullfile, 199, L"textures\\Ships\\wheels-standard.dds");
657  wcscpy_s(lightfile, 199, L"textures\\Ships\\wheels-standard.dds");
658  break;
659  case 162: wcscpy_s(hullfile, 199, L"textures\\Ships\\cargobay-door-standard1.dds");
660  wcscpy_s(lightfile, 199, L"textures\\Ships\\cargobay-door-standard1.dds");
661  break;
662  // Spacesuit and floating man
663  case 163: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\ARM-RU.dds");
664  break;
665  case 164: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\ARM-RL.dds");
666  break;
667  case 165: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\HAND-R-leisure.dds");
668  break;
669  case 166: wcscpy_s(hullfile, 199, L"textures\\Holidays\\TORSO.dds");
670  break;
671  case 167: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\HIPS.dds");
672  break;
673  case 168: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\LEG-RU.dds");
674  break;
675  case 169: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\LEG-RL.dds");
676  break;
677  case 170: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\FOOT-R.dds");
678  break;
679  case 171: wcscpy_s(hullfile, 199, L"textures\\Holidays\\HELMET.dds");
680  break;
681  case 172: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\NECK.dds");
682  break;
683  case 173: wcscpy_s(hullfile, 199, L"textures\\Holidays\\ears-floatingman1.dds");
684  break;
685  case 174: wcscpy_s(hullfile, 199, L"textures\\Holidays\\head-floatingman1.dds");
686  break;
687  case 175: wcscpy_s(hullfile, 199, L"textures\\Holidays\\nose-floatingman1.dds");
688  break;
689  case 176: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\HELMET-INNER.dds");
690  break;
691  case 177: wcscpy_s(hullfile, 199, L"textures\\People\\Spacesuit\\ARM-LL-fieldstandard.dds");
692  wcscpy_s(lightfile, 199, L"textures\\People\\Spacesuit\\ARM-LL-fieldstandardLIGHT.dds");
693  break;
694  case 178: wcscpy_s(hullfile, 199, L"textures\\Holidays\\HELMET-GLASS.dds");
695  break;
696  // Passenger PODS
697  case 179: wcscpy_s(hullfile, 199, L"textures\\Containers\\passenger-ext.dds");
698  wcscpy_s(lightfile, 199, L"textures\\Containers\\passenger-extLIGHT.dds");
699  break;
700  // Construction PODS
701  case 180: wcscpy_s(hullfile, 199, L"textures\\Containers\\construction-ext.dds");
702  //not supported yet ... these are never "on"
703  //wcscpy_s(lightfile, 199, L"textures\\Containers\\construction-extLIGHT.dds");
704  break;
705  // Mammoth
706  case 181: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\window-bridge.dds");
707  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\window-bridgeLIGHT.dds");
708  break;
709  case 182: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\conveyorramp.dds");
710  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\conveyorramp.dds");
711  break;
712  case 183: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\int-hydraulic.dds");
713  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\int-hydraulic.dds");
714  break;
715  case 184: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\int-liftarm.dds");
716  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\int-liftarm.dds");
717  break;
718  case 185: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\int-wall-cargo.dds");
719  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\int-wall-cargo.dds");
720  break;
721  case 186: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\body-nose.dds");
722  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\body-noseLIGHT.dds");
723  break;
724  case 187: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\body-common.dds");
725  break;
726  case 188: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\dynamic-mammoth.dds");
727  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\dynamic-mammothLIGHT.dds");
728  break;
729  case 189: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\lift.dds");
730  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\liftLIGHT.dds");
731  break;
732  case 190: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\guts-hydraulic.dds");
733  break;
734  case 191: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\door1.dds");
735  break;
736  case 192: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\ramp-outer.dds");
737  break;
738  case 193: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\lights-common.dds");
739  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\lights-commonLIGHT.dds");
740  break;
741  case 194: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\conveyor.dds");
742  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\conveyor.dds");
743  break;
744  case 195: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\int-column-cargo.dds");
745  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\int-column-cargo.dds");
746  break;
747  case 196: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\body-windowed.dds");
748  wcscpy_s(lightfile, 199, L"textures\\Vehicles\\body-windowedLIGHT.dds");
749  break;
750  case 197: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\body-bottom.dds");
751  break;
752  case 198: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\sleeve.dds");
753  break;
754  case 199: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\face-toothandnail.dds");
755  break;
756  case 200: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\tread-toothandnail.dds");
757  break;
758  case 201: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\deck.dds");
759  break;
760  case 202: wcscpy_s(hullfile, 199, L"textures\\Animations\\Thrust.dds");
761  break;
762  case 203: wcscpy_s(hullfile, 199, L"textures\\Animations\\Afterburner.dds");
763  break;
764  // The new 2007 (2020) Steerhead
765  case 204: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-SKINS-stainless.dds");
766  break;
767  case 205: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-SKINS-flaps.dds");
768  break;
769  case 206: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-SKINS-techbed.dds");
770  break;
771  case 207: wcscpy_s(hullfile, 199, L"textures\\Vehicles\\GV-SKINS-underbed.dds");
772  break;
773  }
774 
775 #ifndef skipVehicles
776  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, hullfile,
777  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3, // needs to be dxt3 to support alpha trim
778  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
779  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsShipTexture[t])))
780  {
781  sprintf_s(msg, sizeof(msg), "Could not load \"%S\"! (%x)", hullfile, hr);
782  logger->Log(msg, Logger::Level::Fatal);
783  }
784  else
785  {
786  sprintf_s(msg, sizeof(msg), "m_pddsShipTexture[%i]", t);
788  }
789  if (lightfile[0] != 0)
790  {
791  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, lightfile,
792  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
793  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
794  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsShipLights[t])))
795  {
796  sprintf_s(msg, sizeof(msg), "Could not load \"%S\"! (%x)", lightfile, hr);
797  logger->Log(msg, Logger::Level::Fatal);
798  }
799  else
800  {
801  sprintf_s(msg, sizeof(msg), "m_pddsShipLights[%i]", t);
803  }
804  }
805 #else
806  *instage = -1;
807 #endif
808  } // instage loop
809  } // stage ==3
810  } // stage >=3
811 
812  if (*stage >= 4)
813  {
814  if (*stage > 4)
815  txtHelper.DrawTextLine(L"City grids loaded!");
816  if (*stage == 4)
817  {
818  (*instage)++; // start at 1
819 
820  txtHelper.DrawFormattedTextLine(L"City grids loading (%i/%i)...", *instage, RTStextureC);
821 
822  if (*instage == RTStextureC) // while less than RTStextureC
823  {
824  *instage = -1;
825  logger->Log("City grids loaded...");
826  }
827  else
828  {
829  t = *instage;
830  WCHAR hullfile[199], lightfile[199];
831  hullfile[0] = lightfile[0] = 0;
832  switch (t)
833  {
834  case 1: swprintf_s(hullfile, 199, L"Textures\\RTS\\f1a.dds");
835  break;
836  case 2: swprintf_s(hullfile, 199, L"Textures\\RTS\\f1b.dds");
837  break;
838  case 3: swprintf_s(hullfile, 199, L"Textures\\RTS\\f1c.dds");
839  break;
840  case 4: swprintf_s(hullfile, 199, L"Textures\\RTS\\f2a.dds");
841  break;
842  case 5: swprintf_s(hullfile, 199, L"Textures\\RTS\\f2b.dds");
843  break;
844  case 6: swprintf_s(hullfile, 199, L"Textures\\RTS\\f2c.dds");
845  break;
846  case 7: swprintf_s(hullfile, 199, L"Textures\\RTS\\f3a.dds");
847  break;
848  case 8: swprintf_s(hullfile, 199, L"Textures\\RTS\\f3b.dds");
849  break;
850  case 9: swprintf_s(hullfile, 199, L"Textures\\RTS\\f4a.dds");
851  break;
852  case 10: swprintf_s(hullfile, 199, L"Textures\\RTS\\f4b.dds");
853  break;
854  case 11: swprintf_s(hullfile, 199, L"Textures\\RTS\\f5a.dds");
855  break;
856  case 12: swprintf_s(hullfile, 199, L"Textures\\RTS\\f6a.dds");
857  break;
858  case 13: swprintf_s(hullfile, 199, L"Textures\\RTS\\f6b.dds");
859  break;
860  case 14: swprintf_s(hullfile, 199, L"Textures\\RTS\\f6c.dds");
861  break;
862  case 15: swprintf_s(hullfile, 199, L"Textures\\RTS\\f6d.dds");
863  break;
864  case 16: swprintf_s(hullfile, 199, L"Textures\\RTS\\f6e.dds");
865  break;
866  case 17: swprintf_s(hullfile, 199, L"Textures\\RTS\\f7a.dds");
867  break;
868  case 18: swprintf_s(hullfile, 199, L"Textures\\RTS\\f7b.dds");
869  break;
870  case 19: swprintf_s(hullfile, 199, L"Textures\\RTS\\f7c.dds");
871  break;
872  case 20: swprintf_s(hullfile, 199, L"Textures\\RTS\\f8a.dds");
873  break;
874  case 21: swprintf_s(hullfile, 199, L"Textures\\RTS\\f8b.dds");
875  break;
876  case 22: swprintf_s(hullfile, 199, L"Textures\\RTS\\f8c.dds");
877  break;
878  case 23: swprintf_s(hullfile, 199, L"Textures\\RTS\\f9a.dds");
879  break;
880  case 24: swprintf_s(hullfile, 199, L"Textures\\RTS\\f9b.dds");
881  break;
882  case 25: swprintf_s(hullfile, 199, L"Textures\\RTS\\f10a.dds");
883  break;
884  case 26: swprintf_s(hullfile, 199, L"Textures\\RTS\\f10b.dds");
885  break;
886  case 27: swprintf_s(hullfile, 199, L"Textures\\RTS\\f10c.dds");
887  break;
888  case 28: swprintf_s(hullfile, 199, L"Textures\\RTS\\f10d.dds");
889  break;
890  case 29: swprintf_s(hullfile, 199, L"Textures\\RTS\\f11a.dds");
891  break;
892  case 30: swprintf_s(hullfile, 199, L"Textures\\RTS\\f33_Exit-above.dds");
893  swprintf_s(lightfile, 199, L"Textures\\RTS\\f33_Exit-aboveLIGHT.dds");
894  break;
895  case 31: swprintf_s(hullfile, 199, L"Textures\\RTS\\f12b.dds");
896  break;
897  case 32: swprintf_s(hullfile, 199, L"Textures\\RTS\\f33_Exit-below.dds");
898  swprintf_s(lightfile, 199, L"Textures\\RTS\\f33_Exit-belowLIGHT.dds");
899  break;
900  case 33: swprintf_s(hullfile, 199, L"Textures\\RTS\\f13b.dds");
901  break;
902  case 34: swprintf_s(hullfile, 199, L"Textures\\RTS\\f31_Exit-above.dds");
903  swprintf_s(lightfile, 199, L"Textures\\RTS\\f31_Exit-aboveLIGHT.dds");
904  break;
905  case 35: swprintf_s(hullfile, 199, L"Textures\\RTS\\f14b.dds");
906  break;
907  case 36: swprintf_s(hullfile, 199, L"Textures\\RTS\\f15a.dds");
908  swprintf_s(lightfile, 199, L"Textures\\RTS\\f15aLIGHT.dds");
909  break;
910  case 37: swprintf_s(hullfile, 199, L"Textures\\RTS\\f15b.dds");
911  swprintf_s(lightfile, 199, L"Textures\\RTS\\f15bLIGHT.dds");
912  break;
913  case 38: swprintf_s(hullfile, 199, L"Textures\\RTS\\f15c.dds");
914  swprintf_s(lightfile, 199, L"Textures\\RTS\\f15cLIGHT.dds");
915  break;
916  case 39: swprintf_s(hullfile, 199, L"Textures\\RTS\\f15d.dds");
917  swprintf_s(lightfile, 199, L"Textures\\RTS\\f15dLIGHT.dds");
918  break;
919  case 40: swprintf_s(hullfile, 199, L"Textures\\RTS\\f15e.dds");
920  swprintf_s(lightfile, 199, L"Textures\\RTS\\f15eLIGHT.dds");
921  break;
922  case 41: swprintf_s(hullfile, 199, L"Textures\\RTS\\f31_Exit-above-above.dds");
923  swprintf_s(lightfile, 199, L"Textures\\RTS\\f31_Exit-above-aboveLIGHT.dds");
924  break;
925  case 42: swprintf_s(hullfile, 199, L"Textures\\RTS\\f17.dds");
926  break;
927  case 43: swprintf_s(hullfile, 199, L"Textures\\RTS\\f18.dds");
928  break;
929  case 44: swprintf_s(hullfile, 199, L"Textures\\RTS\\f19.dds");
930  break;
931  case 45: swprintf_s(hullfile, 199, L"Textures\\RTS\\f20.dds");
932  break;
933  case 46: swprintf_s(hullfile, 199, L"Textures\\RTS\\f21.dds");
934  break;
935  case 47: swprintf_s(hullfile, 199, L"Textures\\RTS\\f22.dds");
936  break;
937  case 48: swprintf_s(hullfile, 199, L"Textures\\RTS\\f23.dds");
938  break;
939  case 49: swprintf_s(hullfile, 199, L"Textures\\RTS\\f24.dds");
940  break;
941  case 50: swprintf_s(hullfile, 199, L"Textures\\RTS\\f25.dds");
942  swprintf_s(lightfile, 199, L"Textures\\RTS\\f25LIGHT.dds");
943  break;
944  case 51: swprintf_s(hullfile, 199, L"Textures\\RTS\\f26.dds");
945  break;
946  case 52: swprintf_s(hullfile, 199, L"Textures\\RTS\\f27.dds");
947  break;
948  case 53: swprintf_s(hullfile, 199, L"Textures\\RTS\\f28.dds");
949  break;
950  case 54: swprintf_s(hullfile, 199, L"Textures\\RTS\\f29.dds");
951  break;
952  case 55: swprintf_s(hullfile, 199, L"Textures\\RTS\\f30.dds");
953  break;
954  case 56: swprintf_s(hullfile, 199, L"Textures\\RTS\\f15f.dds");
955  swprintf_s(lightfile, 199, L"Textures\\RTS\\f15fLIGHT.dds");
956  break;
957  case 57: swprintf_s(hullfile, 199, L"Textures\\RTS\\f15g.dds");
958  swprintf_s(lightfile, 199, L"Textures\\RTS\\f15gLIGHT.dds");
959  break;
960  case 58: swprintf_s(hullfile, 199, L"Textures\\RTS\\f31.dds");
961  swprintf_s(lightfile, 199, L"Textures\\RTS\\f31LIGHT.dds");
962  break;
963  case 59: swprintf_s(hullfile, 199, L"Textures\\RTS\\f32x.dds");
964  break;
965  case 60: swprintf_s(hullfile, 199, L"Textures\\RTS\\f33.dds");
966  swprintf_s(lightfile, 199, L"Textures\\RTS\\f33LIGHT.dds");
967  break;
968  case 61: swprintf_s(hullfile, 199, L"Textures\\RTS\\f34.dds");
969  swprintf_s(lightfile, 199, L"Textures\\RTS\\f34LIGHT.dds");
970  break;
971  case 62: swprintf_s(hullfile, 199, L"Textures\\RTS\\city2playerN.dds");
972  break;
973  case 63: swprintf_s(hullfile, 199, L"Textures\\RTS\\city2playerS.dds");
974  break;
975  case 64: swprintf_s(hullfile, 199, L"Textures\\RTS\\f3218.dds");
976  swprintf_s(lightfile, 199, L"Textures\\RTS\\f32LIGHT.dds");
977  break;
978  case 65: swprintf_s(hullfile, 199, L"Textures\\RTS\\f3236.dds");
979  swprintf_s(lightfile, 199, L"Textures\\RTS\\f32LIGHT.dds");
980  break;
981  case 66: swprintf_s(hullfile, 199, L"Textures\\RTS\\f31aim.dds");
982  swprintf_s(lightfile, 199, L"Textures\\RTS\\f31LIGHT.dds");
983  break;
984  case 67: swprintf_s(hullfile, 199, L"Textures\\RTS\\f31stripe1.dds");
985  swprintf_s(lightfile, 199, L"Textures\\RTS\\f31LIGHT.dds");
986  break;
987  case 68: swprintf_s(hullfile, 199, L"Textures\\RTS\\f31stripe2.dds");
988  swprintf_s(lightfile, 199, L"Textures\\RTS\\f31LIGHT.dds");
989  break;
990  case 69: swprintf_s(hullfile, 199, L"Textures\\RTS\\f31stripe3.dds");
991  swprintf_s(lightfile, 199, L"Textures\\RTS\\f31LIGHT.dds");
992  break;
993  case 70: swprintf_s(hullfile, 199, L"Textures\\RTS\\f8bpark.dds");
994  break;
995  case 71: swprintf_s(hullfile, 199, L"Textures\\RTS\\f9bpark.dds");
996  break;
997  //case 72: strcat_s(tempfile, MAX_PATH, "PolarCompassQuadrant");
998  // break;
999  case 73: swprintf_s(hullfile, 199, L"Textures\\RTS\\f31_Exit-above-above-NOSTRIPE.dds");
1000  swprintf_s(lightfile, 199, L"Textures\\RTS\\f31_Exit-above-aboveLIGHT.dds");
1001  break;
1002  }
1003 #ifndef skipRTS
1004  if (hullfile[0] != 0)
1005  {
1006  if (FAILED(hr = D3DXCreateTextureFromFileExW(pd3dDevice, hullfile,
1007  1440, 1440, // have to specify the size because they are not power-of-two
1008  D3DX_DEFAULT, 0,
1009  D3DFMT_FROM_FILE, // mix of DXT1 and DXT3
1010  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1011  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsRTSTexture[t])))
1012  {
1013  sprintf_s(msg, sizeof(msg), "Could not load \"%S\"! (%x)", hullfile, hr);
1014  logger->Log(msg, Logger::Level::Fatal);
1015  }
1016  else
1017  {
1018  sprintf_s(msg, sizeof(msg), "m_pddsRTSTexture[%i]", t);
1020  }
1021  }
1022  if (lightfile[0] != 0)
1023  {
1024  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, lightfile,
1025  1440, 1440, // have to specify the size because they are not power-of-two
1026  D3DX_DEFAULT, 0, D3DFMT_DXT1,
1027  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1028  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsRTSLights[t])))
1029  {
1030  sprintf_s(msg, sizeof(msg), "Could not load \"%S\"! (%x)", lightfile, hr);
1031  logger->Log(msg, Logger::Level::Fatal);
1032  }
1033  else
1034  {
1035  sprintf_s(msg, sizeof(msg), "m_pddsRTSLights[%i]", t);
1037  }
1038  }
1039 #else
1040  *instage = -1;
1041 #endif
1042  } // instage loop
1043  } // stage==4
1044  } // stage>=4
1045 
1046  if (*stage >= 5)
1047  {
1048  if (*stage > 5)
1049  txtHelper.DrawTextLine(L"Buildings loaded!");
1050  if (*stage == 5)
1051  {
1052  (*instage)++; // start at 1
1053 
1054  txtHelper.DrawFormattedTextLine(L"Building loading (%i/%i)...", *instage, citytextureC + 1);
1055 
1056  if (*instage == citytextureC)
1057  {
1058  *instage = -1;
1059  logger->Log("Buildings loaded...");
1060  }
1061  else
1062  {
1063  WCHAR hullfile[199], lightfile[199];
1064  // Defaults
1065  hullfile[0] = lightfile[0] = 0;
1066  D3DFORMAT format = D3DFMT_DXT1;
1067  switch (*instage)
1068  {
1069  // Deois financial district
1070  case 1: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_3_cap.dds");
1071  wcscpy_s(lightfile, 199, L"textures\\cities\\g_3_capLIGHT.dds");
1072  break;
1073  case 2: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_hangar1.dds");
1074  wcscpy_s(lightfile, 199, L"textures\\cities\\b_hangar1LIGHT.dds");
1075  break;
1076  case 3: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAoffice.dds");
1077  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAofficeLIGHT.dds");
1078  break;
1079  case 4: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAhotel2.dds");
1080  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAhotel2LIGHT.dds");
1081  break;
1082  case 5: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAoffice2.dds");
1083  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAoffice2LIGHT.dds");
1084  break;
1085  case 6: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAhotel1.dds");
1086  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAhotel1LIGHT.dds");
1087  break;
1088  case 7: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAoffice3.dds");
1089  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAoffice3LIGHT.dds");
1090  break;
1091  case 8: wcscpy_s(hullfile, 199, L"textures\\Cities\\tmis.dds");
1092  wcscpy_s(lightfile, 199, L"textures\\cities\\tmisLIGHT.dds");
1093  break;
1094  case 9: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAoffice4.dds");
1095  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAoffice4LIGHT.dds");
1096  break;
1097  case 10: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAoffice6.dds");
1098  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAoffice6LIGHT.dds");
1099  break;
1100  case 11: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAoffice5.dds");
1101  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAoffice5LIGHT.dds");
1102  break;
1103  case 12: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAoffice7.dds");
1104  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAoffice7LIGHT.dds");
1105  break;
1106  case 13: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_1_mid.dds");
1107  wcscpy_s(lightfile, 199, L"textures\\cities\\r_1_midLIGHT.dds");
1108  break;
1109  case 14: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_flat.dds");
1110  wcscpy_s(lightfile, 199, L"textures\\cities\\b_flatLIGHT.dds");
1111  break;
1112  case 15: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAoffice8.dds");
1113  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAoffice8LIGHT.dds");
1114  break;
1115  case 16: wcscpy_s(hullfile, 199, L"textures\\Cities\\landing_fnd.dds");
1116  wcscpy_s(lightfile, 199, L"textures\\cities\\landing_fndLIGHT.dds");
1117  break;
1118  case 17: wcscpy_s(hullfile, 199, L"textures\\Cities\\landing_cap.dds");
1119  wcscpy_s(lightfile, 199, L"textures\\cities\\landing_capLIGHT.dds");
1120  break;
1121  case 18: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_1_fnd.dds");
1122  wcscpy_s(lightfile, 199, L"textures\\cities\\r_1_fndLIGHT.dds");
1123  break;
1124  case 19: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_1_fnd.dds");
1125  wcscpy_s(lightfile, 199, L"textures\\cities\\b_1_fndLIGHT.dds");
1126  break;
1127  case 20: wcscpy_s(hullfile, 199, L"textures\\Cities\\landing_flat.dds");
1128  break;
1129  case 21: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_3_fnd.dds");
1130  wcscpy_s(lightfile, 199, L"textures\\cities\\g_3_fndLIGHT.dds");
1131  break;
1132  case 22: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_hangar_flatunder.dds");
1133  wcscpy_s(lightfile, 199, L"textures\\cities\\b_hangar_flatunderLIGHT.dds");
1134  break;
1135  case 23: wcscpy_s(hullfile, 199, L"textures\\Cities\\t_to_r.dds");
1136  wcscpy_s(lightfile, 199, L"textures\\cities\\t_to_rLIGHT.dds");
1137  break;
1138  case 24: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_to_t.dds");
1139  wcscpy_s(lightfile, 199, L"textures\\cities\\r_to_tLIGHT.dds");
1140  break;
1141  case 25: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_to_b.dds");
1142  wcscpy_s(lightfile, 199, L"textures\\cities\\g_to_bLIGHT.dds");
1143  break;
1144  case 26: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_1_flat.dds");
1145  wcscpy_s(lightfile, 199, L"textures\\cities\\r_1_flatLIGHT.dds");
1146  break;
1147  case 27: wcscpy_s(hullfile, 199, L"textures\\Cities\\comm_fnd.dds");
1148  wcscpy_s(lightfile, 199, L"textures\\cities\\comm_fndLIGHT.dds");
1149  break;
1150  case 28: wcscpy_s(hullfile, 199, L"textures\\Cities\\comm_mid.dds");
1151  wcscpy_s(lightfile, 199, L"textures\\cities\\comm_midLIGHT.dds");
1152  break;
1153  case 29: wcscpy_s(hullfile, 199, L"textures\\Cities\\comm_cap.dds");
1154  wcscpy_s(lightfile, 199, L"textures\\cities\\comm_capLIGHT.dds");
1155  break;
1156  case 30: wcscpy_s(hullfile, 199, L"textures\\Cities\\generalgrey_cap.dds");
1157  break;
1158  case 31: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_to_g.dds");
1159  wcscpy_s(lightfile, 199, L"textures\\cities\\b_to_gLIGHT.dds");
1160  break;
1161  case 32: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_2_cap.dds");
1162  wcscpy_s(lightfile, 199, L"textures\\cities\\b_2_capLIGHT.dds");
1163  break;
1164  case 33: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_1_mid.dds");
1165  wcscpy_s(lightfile, 199, L"textures\\cities\\b_1_midLIGHT.dds");
1166  break;
1167  case 34: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_to_r.dds");
1168  wcscpy_s(lightfile, 199, L"textures\\cities\\b_to_rLIGHT.dds");
1169  break;
1170  case 35: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_2_fnd.dds");
1171  wcscpy_s(lightfile, 199, L"textures\\cities\\g_2_fndLIGHT.dds");
1172  break;
1173  case 36: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_2_mid.dds");
1174  wcscpy_s(lightfile, 199, L"textures\\cities\\g_2_midLIGHT.dds");
1175  break;
1176  case 37: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_to_b.dds");
1177  wcscpy_s(lightfile, 199, L"textures\\cities\\r_to_bLIGHT.dds");
1178  break;
1179  case 38: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_2_mid.dds");
1180  wcscpy_s(lightfile, 199, L"textures\\cities\\b_2_midLIGHT.dds");
1181  break;
1182  case 39: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_3_mid.dds");
1183  wcscpy_s(lightfile, 199, L"textures\\cities\\b_3_midLIGHT.dds");
1184  break;
1185  case 40: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_3_fnd.dds");
1186  wcscpy_s(lightfile, 199, L"textures\\cities\\b_3_fndLIGHT.dds");
1187  break;
1188  case 41: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_3_cap.dds");
1189  wcscpy_s(lightfile, 199, L"textures\\cities\\b_3_capLIGHT.dds");
1190  break;
1191  case 42: wcscpy_s(hullfile, 199, L"textures\\Cities\\b_1_cap.dds");
1192  wcscpy_s(lightfile, 199, L"textures\\cities\\b_1_capLIGHT.dds");
1193  break;
1194  case 43: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_1_cap.dds");
1195  wcscpy_s(lightfile, 199, L"textures\\cities\\g_1_capLIGHT.dds");
1196  break;
1197  case 44: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_flat.dds");
1198  wcscpy_s(lightfile, 199, L"textures\\cities\\g_flatLIGHT.dds");
1199  break;
1200  case 45: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_1_mid.dds");
1201  wcscpy_s(lightfile, 199, L"textures\\cities\\g_1_midLIGHT.dds");
1202  break;
1203  case 46: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_3_mid.dds");
1204  wcscpy_s(lightfile, 199, L"textures\\cities\\g_3_midLIGHT.dds");
1205  break;
1206  case 47: wcscpy_s(hullfile, 199, L"textures\\Cities\\CITY-texture-b2.dds");
1207  break;
1208  case 48: wcscpy_s(hullfile, 199, L"textures\\Cities\\CITY-texture-g3.dds");
1209  break;
1210  case 49: wcscpy_s(hullfile, 199, L"textures\\Cities\\CITY-wall-b2.dds");
1211  wcscpy_s(lightfile, 199, L"textures\\cities\\CITY-wall-b2LIGHT.dds");
1212  break;
1213  case 50: wcscpy_s(hullfile, 199, L"textures\\Cities\\CITY-wall-g3.dds");
1214  wcscpy_s(lightfile, 199, L"textures\\cities\\CITY-wall-g3LIGHT.dds");
1215  break;
1216  case 51: wcscpy_s(hullfile, 199, L"textures\\Cities\\CITY-texture-g1.dds");
1217  break;
1218  case 52: wcscpy_s(hullfile, 199, L"textures\\Cities\\CITY-wall-g2.dds");
1219  wcscpy_s(lightfile, 199, L"textures\\cities\\CITY-wall-g2LIGHT.dds");
1220  break;
1221  case 53: wcscpy_s(hullfile, 199, L"textures\\Cities\\CITY-wall-g1.dds");
1222  wcscpy_s(lightfile, 199, L"textures\\cities\\CITY-wall-g1LIGHT.dds");
1223  break;
1224  case 54: wcscpy_s(hullfile, 199, L"textures\\Cities\\sign-FLEET_gnd.dds");
1225  wcscpy_s(lightfile, 199, L"textures\\cities\\sign-FLEET_gndLIGHT.dds");
1226  break;
1227  // Deois Industrial District
1228  case 55: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_2_fnd.dds");
1229  wcscpy_s(lightfile, 199, L"textures\\cities\\r_2_fndLIGHT.dds");
1230  break;
1231  case 56: wcscpy_s(hullfile, 199, L"textures\\Cities\\ir_fnd.dds");
1232  wcscpy_s(lightfile, 199, L"textures\\Cities\\ir_fndLIGHT.dds");
1233  break;
1234  case 57: wcscpy_s(hullfile, 199, L"textures\\Cities\\ircap1.dds");
1235  wcscpy_s(lightfile, 199, L"textures\\Cities\\ircap1LIGHT.dds");
1236  break;
1237  case 58: wcscpy_s(hullfile, 199, L"textures\\Cities\\igcap2.dds");
1238  wcscpy_s(lightfile, 199, L"textures\\Cities\\igcap2LIGHT.dds");
1239  break;
1240  case 59: wcscpy_s(hullfile, 199, L"textures\\Cities\\igcap1.dds");
1241  wcscpy_s(lightfile, 199, L"textures\\Cities\\igcap1LIGHT.dds");
1242  break;
1243  case 60: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibf-tank.dds");
1244  wcscpy_s(lightfile, 199, L"textures\\cities\\ibf-tankLIGHT.dds");
1245  break;
1246  case 61: wcscpy_s(hullfile, 199, L"textures\\Cities\\r-tank-tower8.dds");
1247  wcscpy_s(lightfile, 199, L"textures\\cities\\r-tank-tower8LIGHT.dds");
1248  break;
1249  case 62: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-materialstorage.dds");
1250  wcscpy_s(lightfile, 199, L"textures\\cities\\c-materialstorageLIGHT.dds");
1251  break;
1252  case 63: wcscpy_s(hullfile, 199, L"textures\\Cities\\R.dds");
1253  wcscpy_s(lightfile, 199, L"textures\\cities\\RLIGHT.dds");
1254  break;
1255  case 64: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_2_flat.dds");
1256  wcscpy_s(lightfile, 199, L"textures\\cities\\r_2_flatLIGHT.dds");
1257  break;
1258  case 65: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_2_mid.dds");
1259  wcscpy_s(lightfile, 199, L"textures\\cities\\r_2_midLIGHT.dds");
1260  break;
1261  case 66: wcscpy_s(hullfile, 199, L"textures\\Cities\\r-tank.dds");
1262  wcscpy_s(lightfile, 199, L"textures\\cities\\r-tankLIGHT.dds");
1263  break;
1264  case 67: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibg-production.dds");
1265  wcscpy_s(lightfile, 199, L"textures\\cities\\ibg-productionLIGHT.dds");
1266  break;
1267  case 68: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibg-processor.dds");
1268  wcscpy_s(lightfile, 199, L"textures\\cities\\ibg-processorLIGHT.dds");
1269  break;
1270  case 69: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibg-assembly.dds");
1271  wcscpy_s(lightfile, 199, L"textures\\cities\\ibg-assemblyLIGHT.dds");
1272  break;
1273  case 70: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibg-warehouse.dds");
1274  wcscpy_s(lightfile, 199, L"textures\\cities\\ibg-warehouseLIGHT.dds");
1275  break;
1276  case 71: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-separator.dds");
1277  wcscpy_s(lightfile, 199, L"textures\\cities\\c-separatorLIGHT.dds");
1278  break;
1279  case 72: wcscpy_s(hullfile, 199, L"textures\\Cities\\ib.dds");
1280  wcscpy_s(lightfile, 199, L"textures\\cities\\ibLIGHT.dds");
1281  break;
1282  case 73: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-materialobliteration.dds");
1283  wcscpy_s(lightfile, 199, L"textures\\cities\\c-materialobliterationLIGHT.dds");
1284  break;
1285  case 74: wcscpy_s(hullfile, 199, L"textures\\Cities\\ig.dds");
1286  wcscpy_s(lightfile, 199, L"textures\\Cities\\igLIGHT.dds");
1287  break;
1288  case 75: wcscpy_s(hullfile, 199, L"textures\\Cities\\igs.dds");
1289  wcscpy_s(lightfile, 199, L"textures\\Cities\\igsLIGHT.dds");
1290  break;
1291  case 76: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibe.dds");
1292  wcscpy_s(lightfile, 199, L"textures\\cities\\ibeLIGHT.dds");
1293  break;
1294  case 77: wcscpy_s(hullfile, 199, L"textures\\Cities\\igscap1.dds");
1295  wcscpy_s(lightfile, 199, L"textures\\Cities\\igscap1LIGHT.dds");
1296  break;
1297  case 78: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibb-1.dds");
1298  wcscpy_s(lightfile, 199, L"textures\\cities\\ibb-1LIGHT.dds");
1299  break;
1300  case 79: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibb-2.dds");
1301  wcscpy_s(lightfile, 199, L"textures\\cities\\ibb-2LIGHT.dds");
1302  break;
1303  case 80: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibb-3.dds");
1304  wcscpy_s(lightfile, 199, L"textures\\cities\\ibb-3LIGHT.dds");
1305  break;
1306  case 81: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibf-distillery.dds");
1307  wcscpy_s(lightfile, 199, L"textures\\cities\\ibf-distilleryLIGHT.dds");
1308  break;
1309  case 82: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibf-overpass1.dds");
1310  wcscpy_s(lightfile, 199, L"textures\\Cities\\ibf-overpass1LIGHT.dds");
1311  break;
1312  case 83: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibf-processor.dds");
1313  wcscpy_s(lightfile, 199, L"textures\\cities\\ibf-processorLIGHT.dds");
1314  break;
1315  case 84: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibf-refiner.dds");
1316  wcscpy_s(lightfile, 199, L"textures\\cities\\ibf-refinerLIGHT.dds");
1317  break;
1318  case 85: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibf-tankcap.dds");
1319  wcscpy_s(lightfile, 199, L"textures\\Cities\\ibf-tankcapLIGHT.dds");
1320  break;
1321  case 86: wcscpy_s(hullfile, 199, L"textures\\Cities\\ibsf-fueltank.dds");
1322  wcscpy_s(lightfile, 199, L"textures\\cities\\ibsf-fueltankLIGHT.dds");
1323  break;
1324  case 87: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-repairgarage.dds");
1325  wcscpy_s(lightfile, 199, L"textures\\cities\\c-repairgarageLIGHT.dds");
1326  break;
1327  case 88: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-equipmentstorage.dds");
1328  wcscpy_s(lightfile, 199, L"textures\\cities\\c-equipmentstorageLIGHT.dds");
1329  break;
1330  // Deois City Center
1331  case 89: wcscpy_s(hullfile, 199, L"textures\\Cities\\tank-water.dds");
1332  wcscpy_s(lightfile, 199, L"textures\\cities\\tank-waterLIGHT.dds");
1333  break;
1334  case 90: wcscpy_s(hullfile, 199, L"textures\\Cities\\arch_post.dds");
1335  wcscpy_s(lightfile, 199, L"textures\\cities\\arch_postLIGHT.dds");
1336  break;
1337  case 91: wcscpy_s(hullfile, 199, L"textures\\Cities\\arch.dds");
1338  wcscpy_s(lightfile, 199, L"textures\\Cities\\archLIGHT.dds");
1339  break;
1340  case 92: wcscpy_s(hullfile, 199, L"textures\\Cities\\g_2_cap.dds");
1341  wcscpy_s(lightfile, 199, L"textures\\Cities\\g_2_capLIGHT.dds");
1342  break;
1343  // Deois Transit District
1344  case 93: wcscpy_s(hullfile, 199, L"textures\\Cities\\r_1_land.dds");
1345  wcscpy_s(lightfile, 199, L"textures\\cities\\r_1_landLIGHT.dds");
1346  break;
1347  case 94: wcscpy_s(hullfile, 199, L"textures\\Cities\\tower-control.dds");
1348  break;
1349  // Deois Port District
1350  case 95: wcscpy_s(hullfile, 199, L"textures\\Cities\\concrete2.dds");
1351  break;
1352  case 96: wcscpy_s(hullfile, 199, L"textures\\Cities\\concrete1-window.dds");
1353  wcscpy_s(lightfile, 199, L"textures\\Cities\\concrete1-windowLIGHT.dds");
1354  break;
1355  case 97: wcscpy_s(hullfile, 199, L"textures\\Cities\\concrete1.dds");
1356  break;
1357  case 98: wcscpy_s(hullfile, 199, L"textures\\Cities\\glassy1-panel.dds");
1358  wcscpy_s(lightfile, 199, L"textures\\Cities\\glassy1-panelLIGHT.dds");
1359  break;
1360  case 99: wcscpy_s(hullfile, 199, L"textures\\Cities\\steel1-corrugated.dds");
1361  break;
1362  case 100: wcscpy_s(hullfile, 199, L"textures\\Cities\\steel1-smooth.dds");
1363  break;
1364  case 101: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAcasino1.dds");
1365  wcscpy_s(lightfile, 199, L"textures\\Cities\\AAAcasino1LIGHT.dds");
1366  break;
1367  case 102: wcscpy_s(hullfile, 199, L"textures\\Cities\\CITY-wall-airport.dds");
1368  break;
1369  case 103: wcscpy_s(hullfile, 199, L"textures\\Cities\\concrete1-groove.dds");
1370  break;
1371  // House1
1372  case 104: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-house1_foot.dds");
1373  wcscpy_s(lightfile, 199, L"textures\\cities\\c-house1_footLIGHT.dds");
1374  break;
1375  case 105: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-house1.dds");
1376  wcscpy_s(lightfile, 199, L"textures\\cities\\c-house1LIGHT.dds");
1377  break;
1378  // Mining1
1379  case 106: wcscpy_s(hullfile, 199, L"textures\\Cities\\mining-com_fnd.dds");
1380  wcscpy_s(lightfile, 199, L"textures\\cities\\mining-com_fndLIGHT.dds");
1381  break;
1382  case 107: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-residence.dds");
1383  wcscpy_s(lightfile, 199, L"textures\\cities\\c-residenceLIGHT.dds");
1384  break;
1385  case 108: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-lzcorner.dds");
1386  wcscpy_s(lightfile, 199, L"textures\\cities\\c-lzcornerLIGHT.dds");
1387  break;
1388  case 109: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAFOUNDATION.dds");
1389  break;
1390  case 110: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAFOUNDATION-LF.dds");
1391  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAFOUNDATION-LFLIGHT.dds");
1392  break;
1393  case 111: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-extractor.dds");
1394  wcscpy_s(lightfile, 199, L"textures\\cities\\c-extractorLIGHT.dds");
1395  break;
1396  case 112: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-biosupport.dds");
1397  wcscpy_s(lightfile, 199, L"textures\\cities\\c-biosupportLIGHT.dds");
1398  break;
1399  case 113: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-powerplant.dds");
1400  wcscpy_s(lightfile, 199, L"textures\\cities\\c-powerplantLIGHT.dds");
1401  break;
1402  case 114: wcscpy_s(hullfile, 199, L"textures\\Cities\\mining-com.dds");
1403  wcscpy_s(lightfile, 199, L"textures\\cities\\mining-comLIGHT.dds");
1404  break;
1405  case 115: wcscpy_s(hullfile, 199, L"textures\\Cities\\WEP-source1.dds");
1406  break;
1407  case 116: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-watertower.dds");
1408  wcscpy_s(lightfile, 199, L"textures\\cities\\c-watertowerLIGHT.dds");
1409  break;
1410  case 117: wcscpy_s(hullfile, 199, L"textures\\Cities\\WEP-tower1.dds");
1411  break;
1412  // Farm1
1413  case 118: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-silo.dds");
1414  wcscpy_s(lightfile, 199, L"textures\\cities\\c-siloLIGHT.dds");
1415  break;
1416  case 119: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-greenhouse1.dds");
1417  wcscpy_s(lightfile, 199, L"textures\\cities\\c-greenhouse1LIGHT.dds");
1418  break;
1419  case 120: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-greenhouse2.dds");
1420  wcscpy_s(lightfile, 199, L"textures\\cities\\c-greenhouse2LIGHT.dds");
1421  break;
1422  case 121: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-greenhouse3.dds");
1423  wcscpy_s(lightfile, 199, L"textures\\cities\\c-greenhouse3LIGHT.dds");
1424  break;
1425  // Township
1426  case 122: wcscpy_s(hullfile, 199, L"textures\\Cities\\AAAcasino2.dds");
1427  wcscpy_s(lightfile, 199, L"textures\\cities\\AAAcasino2LIGHT.dds");
1428  break;
1429  case 123: wcscpy_s(hullfile, 199, L"textures\\Cities\\c-powerproduction.dds");
1430  wcscpy_s(lightfile, 199, L"textures\\cities\\c-powerproductionLIGHT.dds");
1431  break;
1432  case 138: wcscpy_s(hullfile, 199, L"textures\\Cities\\CCCtownblock10-park.dds");
1433  break;
1434  // Prison
1435  case 124: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-plat_cap.dds");
1436  wcscpy_s(lightfile, 199, L"textures\\cities\\sea-plat_capLIGHT.dds");
1437  break;
1438  case 125: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-bldwall3.dds");
1439  wcscpy_s(lightfile, 199, L"textures\\cities\\sea-bldwall3LIGHT.dds");
1440  break;
1441  case 126: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-bldwall1.dds");
1442  wcscpy_s(lightfile, 199, L"textures\\cities\\sea-bldwall1LIGHT.dds");
1443  break;
1444  case 127: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-bldroofA.dds");
1445  break;
1446  case 128: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-bldroofB.dds");
1447  break;
1448  case 129: wcscpy_s(hullfile, 199, L"textures\\Cities\\roverstreet-segment.dds");
1449  wcscpy_s(lightfile, 199, L"textures\\cities\\roverstreet-segmentLIGHT.dds");
1450  break;
1451  case 130: wcscpy_s(hullfile, 199, L"textures\\Cities\\arch_walk10.dds");
1452  wcscpy_s(lightfile, 199, L"textures\\cities\\arch_walk10LIGHT.dds");
1453  break;
1454  case 131: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-legs_trns.dds");
1455  break;
1456  case 132: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-legs_fnd.dds");
1457  break;
1458  case 133: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-legs.dds");
1459  break;
1460  case 134: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-plat.dds");
1461  wcscpy_s(lightfile, 199, L"textures\\cities\\sea-platLIGHT.dds");
1462  break;
1463  case 135: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-platwall1.dds");
1464  wcscpy_s(lightfile, 199, L"textures\\cities\\sea-platwall1LIGHT.dds");
1465  break;
1466  case 136: wcscpy_s(hullfile, 199, L"textures\\Cities\\sea-bldwall2.dds");
1467  break;
1468  case 137: wcscpy_s(hullfile, 199, L"textures\\RTS\\f15d.dds");
1469  wcscpy_s(lightfile, 199, L"textures\\RTS\\f15dLIGHT.dds");
1470  break;
1471  // O-4 ruins
1472  case 139: wcscpy_s(hullfile, 199, L"textures\\Cities\\TOWER.dds");
1473  break;
1474  case 140: wcscpy_s(hullfile, 199, L"textures\\Cities\\ROOF-1.dds");
1475  break;
1476  case 141: wcscpy_s(hullfile, 199, L"textures\\Cities\\ARM-skin-3.dds");
1477  break;
1478  case 142: wcscpy_s(hullfile, 199, L"textures\\Cities\\ALCOVE.dds");
1479  break;
1480  case 143: wcscpy_s(hullfile, 199, L"textures\\Cities\\COLUMN.dds");
1481  break;
1482  case 144: wcscpy_s(hullfile, 199, L"textures\\Cities\\ARM2.dds");
1483  break;
1484  case 145: wcscpy_s(hullfile, 199, L"textures\\Cities\\GUTS3.dds");
1485  break;
1486  case 146: wcscpy_s(hullfile, 199, L"textures\\Cities\\ARM-skin-2.dds");
1487  break;
1488  case 147: wcscpy_s(hullfile, 199, L"textures\\Cities\\ARM.dds");
1489  break;
1490  case 148: wcscpy_s(hullfile, 199, L"textures\\Cities\\CLAMP.dds");
1491  break;
1492  case 149: wcscpy_s(hullfile, 199, L"textures\\Cities\\BOX.dds");
1493  break;
1494  case 150: wcscpy_s(hullfile, 199, L"textures\\Cities\\WALL1-caution.dds");
1495  break;
1496  case 151: wcscpy_s(hullfile, 199, L"textures\\Cities\\COLUMN2.dds");
1497  break;
1498  case 152: wcscpy_s(hullfile, 199, L"textures\\Cities\\WALL1-lit.dds");
1499  break;
1500  case 153: wcscpy_s(hullfile, 199, L"textures\\Cities\\DOORFRAME.dds");
1501  break;
1502  case 154: wcscpy_s(hullfile, 199, L"textures\\Cities\\WALL2-dark.dds");
1503  break;
1504  case 155: wcscpy_s(hullfile, 199, L"textures\\Cities\\WALL2-caution.dds");
1505  break;
1506  case 156: wcscpy_s(hullfile, 199, L"textures\\Cities\\BOX-int2.dds");
1507  break;
1508  case 157: wcscpy_s(hullfile, 199, L"textures\\Cities\\BOX-int.dds");
1509  break;
1510  case 158: wcscpy_s(hullfile, 199, L"textures\\Cities\\GUTS1.dds");
1511  break;
1512  case 159: wcscpy_s(hullfile, 199, L"textures\\Cities\\GUTS2.dds");
1513  break;
1514  case 160: wcscpy_s(hullfile, 199, L"textures\\Cities\\DISH-int.dds");
1515  break;
1516  case 161: wcscpy_s(hullfile, 199, L"textures\\Cities\\DISH-ext.dds");
1517  break;
1518  case 162: wcscpy_s(hullfile, 199, L"textures\\Cities\\ARM-skin.dds");
1519  break;
1520  case 163: wcscpy_s(hullfile, 199, L"textures\\Cities\\TANK.dds");
1521  break;
1522  case 164: wcscpy_s(hullfile, 199, L"textures\\Cities\\dome4.dds");
1523  format = D3DFMT_DXT3;
1524  break;
1525  // Airfield
1526  case 165: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\terminal1.dds");
1527  wcscpy_s(lightfile, 199, L"textures\\Colonies\\Airfield\\terminal1LIGHT.dds");
1528  break;
1529  case 166: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\gravel2.dds");
1530  break;
1531  case 167: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\power1.dds");
1532  wcscpy_s(lightfile, 199, L"textures\\Colonies\\Airfield\\power1LIGHT.dds");
1533  break;
1534  case 168: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\steel1-corrugated.dds");
1535  break;
1536  case 169: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\hotel1.dds");
1537  wcscpy_s(lightfile, 199, L"textures\\Colonies\\Airfield\\hotel1LIGHT.dds");
1538  break;
1539  case 170: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\hangar1.dds");
1540  wcscpy_s(lightfile, 199, L"textures\\Colonies\\Airfield\\hangar1LIGHT.dds");
1541  break;
1542  case 171: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\hangardoor1.dds");
1543  break;
1544  case 172: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\warehouse1.dds");
1545  wcscpy_s(lightfile, 199, L"textures\\Colonies\\Airfield\\warehouse1LIGHT.dds");
1546  break;
1547  case 173: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\garage1.dds");
1548  wcscpy_s(lightfile, 199, L"textures\\Colonies\\Airfield\\garage1LIGHT.dds");
1549  break;
1550  case 174: wcscpy_s(hullfile, 199, L"textures\\Colonies\\Airfield\\steel2-corrugated.dds");
1551  break;
1552  }
1553 #ifndef skipBuildings
1554  if (hullfile[0] != 0)
1555  {
1556  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, hullfile,
1557  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, format,
1558  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1559  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsCityTexture[*instage])))
1560  {
1561  sprintf_s(msg, sizeof(msg), "Could not load \"%S\": 0x%x", hullfile, hr);
1562  logger->Log(msg, Logger::Level::Fatal);
1563  }
1564  else
1565  {
1566  sprintf_s(msg, sizeof(msg), "m_pddsCityTexture[%i]", *instage);
1568  viewscreen->gameclass->TouchFile(hullfile);
1569  }
1570  }
1571 
1572  if (lightfile[0] != 0)
1573  {
1574  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, lightfile,
1575  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_DXT1,
1576  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1577  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsCityLights[*instage])))
1578  {
1579  sprintf_s(msg, sizeof(msg), "Could not load \"%S\": 0x%x", hullfile, hr);
1580  logger->Log(msg, Logger::Level::Fatal);
1581  }
1582  else
1583  {
1584  sprintf_s(msg, sizeof(msg), "m_pddsCityLights[%i]", *instage);
1586  viewscreen->gameclass->TouchFile(lightfile);
1587  }
1588  }
1589 #else
1590  *instage = -1;
1591 #endif
1592  } // instage loop
1593  } // stage==5
1594  } // stage>=5
1595 
1596  if (*stage >= 6)
1597  {
1598  if (*stage > 6)
1599  txtHelper.DrawTextLine(L"Orbital facilities loaded!");
1600  if (*stage == 6)
1601  {
1602  (*instage)++; // start at 1
1603 
1604  txtHelper.DrawFormattedTextLine(L"Orbital facilities loading (%i/%i)...", *instage, docktextureC);
1605 
1606  if (*instage == docktextureC) // while less than docktextureC
1607  {
1608  *instage = -1;
1609  logger->Log("Orbital facilities loaded...");
1610  }
1611  else
1612  {
1613  WCHAR hullfile[199], lightfile[199];
1614  t = *instage;
1615  // Defaults
1616  hullfile[0] = lightfile[0] = 0;
1617  switch (t)
1618  {
1619  // Cutter's Port CPOC
1620  case 1: wcscpy_s(hullfile, 199, L"textures\\Docks\\Stationnode.dds");
1621  wcscpy_s(lightfile, 199, L"textures\\Docks\\StationnodeLIGHT.dds");
1622  break;
1623  case 2: wcscpy_s(hullfile, 199, L"textures\\Docks\\Node-ang45.dds");
1624  break;
1625  case 3: wcscpy_s(hullfile, 199, L"textures\\Docks\\Corridor1-ang45.dds");
1626  wcscpy_s(lightfile, 199, L"textures\\Docks\\Corridor1-ang45LIGHT.dds");
1627  break;
1628  case 4: wcscpy_s(hullfile, 199, L"textures\\Docks\\Big-Tank_cap.dds");
1629  wcscpy_s(lightfile, 199, L"textures\\Docks\\Big-Tank_capLIGHT.dds");
1630  break;
1631  case 5: wcscpy_s(hullfile, 199, L"textures\\Docks\\Big-Tank_section1.dds");
1632  wcscpy_s(lightfile, 199, L"textures\\Docks\\Big-Tank_section1LIGHT.dds");
1633  break;
1634  case 6: wcscpy_s(hullfile, 199, L"textures\\Docks\\Big-Tank_section2.dds");
1635  wcscpy_s(lightfile, 199, L"textures\\Docks\\Big-Tank_section2LIGHT.dds");
1636  break;
1637  case 7: wcscpy_s(hullfile, 199, L"textures\\Docks\\Tank.dds");
1638  wcscpy_s(lightfile, 199, L"textures\\Docks\\TankLIGHT.dds");
1639  break;
1640  case 8: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-ATI.dds");
1641  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-ATI.dds");
1642  break;
1643  case 9: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-BIGREDWIRE.dds");
1644  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-BIGREDWIRE.dds");
1645  break;
1646  case 10: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-JVC.dds");
1647  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-JVC.dds");
1648  break;
1649  case 11: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-KOSS.dds");
1650  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-KOSS.dds");
1651  break;
1652  case 12: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-LOCKHEED.dds");
1653  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-LOCKHEED.dds");
1654  break;
1655  case 13: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-TECHROFORM.dds");
1656  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-TECHROFORM.dds");
1657  break;
1658  case 14: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-VERBATIM.dds");
1659  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-VERBATIM.dds");
1660  break;
1661  case 15: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-45-CUTTER'S.dds");
1662  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-45-CUTTER'SLIGHT.dds");
1663  break;
1664  case 16: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-MINOLTA.dds");
1665  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-MINOLTA.dds");
1666  break;
1667  case 17: wcscpy_s(hullfile, 199, L"textures\\Docks\\Office-body1.dds");
1668  wcscpy_s(lightfile, 199, L"textures\\Docks\\Office-body1LIGHT.dds");
1669  break;
1670  case 18: wcscpy_s(hullfile, 199, L"textures\\Docks\\Office-int1.dds");
1671  wcscpy_s(lightfile, 199, L"textures\\Docks\\Office-int1LIGHT.dds");
1672  break;
1673  case 19: wcscpy_s(hullfile, 199, L"textures\\Docks\\Gangway.dds");
1674  wcscpy_s(lightfile, 199, L"textures\\Docks\\GangwayLIGHT.dds");
1675  break;
1676  case 20: wcscpy_s(hullfile, 199, L"textures\\Docks\\Joint.dds");
1677  wcscpy_s(lightfile, 199, L"textures\\Docks\\JointLIGHT.dds");
1678  break;
1679  case 21: wcscpy_s(hullfile, 199, L"textures\\Docks\\Reactor.dds");
1680  wcscpy_s(lightfile, 199, L"textures\\Docks\\ReactorLIGHT.dds");
1681  break;
1682  case 22: wcscpy_s(hullfile, 199, L"textures\\Docks\\Brace.dds");
1683  wcscpy_s(lightfile, 199, L"textures\\Docks\\BraceLIGHT.dds");
1684  break;
1685  case 23: wcscpy_s(hullfile, 199, L"textures\\Docks\\Communications.dds");
1686  wcscpy_s(lightfile, 199, L"textures\\Docks\\CommunicationsLIGHT.dds");
1687  break;
1688  case 24: wcscpy_s(hullfile, 199, L"textures\\Docks\\Xition2.dds");
1689  wcscpy_s(lightfile, 199, L"textures\\Docks\\Xition2LIGHT.dds");
1690  break;
1691  case 25: wcscpy_s(hullfile, 199, L"textures\\Docks\\Panel1.dds");
1692  wcscpy_s(lightfile, 199, L"textures\\Docks\\Panel1LIGHT.dds");
1693  break;
1694  case 26: wcscpy_s(hullfile, 199, L"textures\\Docks\\Office-fnd1.dds");
1695  wcscpy_s(lightfile, 199, L"textures\\Docks\\Office-fnd1LIGHT.dds");
1696  break;
1697  case 27: wcscpy_s(hullfile, 199, L"textures\\Docks\\Office-cap1.dds");
1698  wcscpy_s(lightfile, 199, L"textures\\Docks\\Office-cap1LIGHT.dds");
1699  break;
1700  case 28: wcscpy_s(hullfile, 199, L"textures\\Docks\\Office-fnd2.dds");
1701  wcscpy_s(lightfile, 199, L"textures\\Docks\\Office-fnd2LIGHT.dds");
1702  break;
1703  case 29: wcscpy_s(hullfile, 199, L"textures\\Docks\\Xition1.dds");
1704  wcscpy_s(lightfile, 199, L"textures\\Docks\\Xition1LIGHT.dds");
1705  break;
1706  case 30: wcscpy_s(hullfile, 199, L"textures\\Docks\\Riser2.dds");
1707  wcscpy_s(lightfile, 199, L"textures\\Docks\\Riser2LIGHT.dds");
1708  break;
1709  case 31: wcscpy_s(hullfile, 199, L"textures\\Docks\\Interface.dds");
1710  wcscpy_s(lightfile, 199, L"textures\\Docks\\InterfaceLIGHT.dds");
1711  break;
1712  case 32: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-rectangle.dds");
1713  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-rectangleLIGHT.dds");
1714  break;
1715  case 33: wcscpy_s(hullfile, 199, L"textures\\Docks\\Corridor1.dds");
1716  wcscpy_s(lightfile, 199, L"textures\\Docks\\Corridor1LIGHT.dds");
1717  break;
1718  case 34: wcscpy_s(hullfile, 199, L"textures\\Cities\\WEP-source1.dds");
1719  break;
1720  case 35: wcscpy_s(hullfile, 199, L"textures\\Docks\\Lounge.dds");
1721  wcscpy_s(lightfile, 199, L"textures\\Docks\\LoungeLIGHT.dds");
1722  break;
1723  case 36: wcscpy_s(hullfile, 199, L"textures\\Docks\\Riser1.dds");
1724  wcscpy_s(lightfile, 199, L"textures\\Docks\\Riser1LIGHT.dds");
1725  break;
1726  case 37: wcscpy_s(hullfile, 199, L"textures\\Docks\\Office-cap2.dds");
1727  wcscpy_s(lightfile, 199, L"textures\\Docks\\Office-cap2LIGHT.dds");
1728  break;
1729  // Easydock TAC
1730  case 38: wcscpy_s(hullfile, 199, L"textures\\Docks\\ring-ad.dds");
1731  wcscpy_s(lightfile, 199, L"textures\\Docks\\ring-adLIGHT.dds");
1732  break;
1733  case 39: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZStationnode.dds");
1734  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZStationnodeLIGHT.dds");
1735  break;
1736  case 40: wcscpy_s(hullfile, 199, L"textures\\Docks\\Bracenode.dds");
1737  break;
1738  case 41: wcscpy_s(hullfile, 199, L"textures\\Docks\\braceshaft.dds");
1739  break;
1740  case 42: wcscpy_s(hullfile, 199, L"textures\\Docks\\Braceshaft1.dds");
1741  wcscpy_s(lightfile, 199, L"textures\\Docks\\Braceshaft1LIGHT.dds");
1742  break;
1743  case 43: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZBig-Tank_cap.dds");
1744  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZBig-Tank_capLIGHT.dds");
1745  break;
1746  case 44: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZBig-Tank_section1.dds");
1747  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZBig-Tank_section1LIGHT.dds");
1748  break;
1749  case 45: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-square.dds");
1750  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-squareLIGHT.dds");
1751  break;
1752  case 46: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZTank.dds");
1753  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZTankLIGHT.dds");
1754  break;
1755  case 47: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZOffice-body1.dds");
1756  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZOffice-body1LIGHT.dds");
1757  break;
1758  case 48: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZOffice-int1.dds");
1759  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZOffice-int1LIGHT.dds");
1760  break;
1761  case 49: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZJoint.dds");
1762  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZJointLIGHT.dds");
1763  break;
1764  case 50: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZGangway.dds");
1765  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZGangwayLIGHT.dds");
1766  break;
1767  case 51: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZReactor.dds");
1768  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZReactorLIGHT.dds");
1769  break;
1770  case 52: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZXition2.dds");
1771  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZXition2LIGHT.dds");
1772  break;
1773  case 53: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZXition1.dds");
1774  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZXition1LIGHT.dds");
1775  break;
1776  case 54: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZOffice-fnd1.dds");
1777  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZOffice-fnd1LIGHT.dds");
1778  break;
1779  case 55: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZOffice-cap1.dds");
1780  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZOffice-cap1LIGHT.dds");
1781  break;
1782  case 56: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZOffice-fnd2.dds");
1783  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZOffice-fnd2LIGHT.dds");
1784  break;
1785  case 57: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZRiser2.dds");
1786  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZRiser2LIGHT.dds");
1787  break;
1788  case 58: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-EZDOCK.dds");
1789  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-EZDOCKLIGHT.dds");
1790  break;
1791  case 59: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZInterface.dds");
1792  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZInterfaceLIGHT.dds");
1793  break;
1794  case 60: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZCorridor1.dds");
1795  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZCorridor1LIGHT.dds");
1796  break;
1797  case 61: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZRiser1.dds");
1798  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZRiser1LIGHT.dds");
1799  break;
1800  case 62: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZLounge.dds");
1801  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZLoungeLIGHT.dds");
1802  break;
1803  case 63: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZOffice-cap2.dds");
1804  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZOffice-cap2LIGHT.dds");
1805  break;
1806  // Sentry Station YSP
1807  case 64: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZNode-ang45.dds");
1808  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZNode-ang45LIGHT.dds");
1809  break;
1810  case 65: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZCorridor1-ang45.dds");
1811  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZCorridor1-ang45LIGHT.dds");
1812  break;
1813  case 66: wcscpy_s(hullfile, 199, L"textures\\Docks\\Sign-YSP.dds");
1814  wcscpy_s(lightfile, 199, L"textures\\Docks\\Sign-YSP.dds");
1815  break;
1816  case 67: wcscpy_s(hullfile, 199, L"textures\\Docks\\EZPanel1.dds");
1817  wcscpy_s(lightfile, 199, L"textures\\Docks\\EZPanel1LIGHT.dds");
1818  break;
1819  }
1820 #ifndef skipDocks
1821  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, hullfile,
1822  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
1823  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1824  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsDockTexture[t])))
1825  {
1826  sprintf_s(msg, sizeof(msg), "Could not load \"%S\" (%i)! (%x)", hullfile, t, hr);
1827  logger->Log(msg, Logger::Level::Fatal);
1828  }
1829  else
1830  {
1831  sprintf_s(msg, sizeof(msg), "m_pddsDockTexture[%i]", t);
1833  }
1834  if (lightfile[0] != 0)
1835  {
1836  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, lightfile,
1837  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
1838  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1839  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsDockLights[t])))
1840  {
1841  sprintf_s(msg, sizeof(msg), "Could not load \"%S\" (%i)! (%x)", lightfile, t, hr);
1842  logger->Log(msg, Logger::Level::Fatal);
1843  }
1844  }
1845  else
1846  {
1847  sprintf_s(msg, sizeof(msg), "m_pddsDockLights[%i]", t);
1849  }
1850 #else
1851  *instage = -1;
1852 #endif
1853  } // instage loop
1854  } // stage ==6
1855  } // stage >=6
1856 
1857  if (*stage >= 7)
1858  {
1859  if (*stage > 7)
1860  txtHelper.DrawTextLine(L"Landforms loaded!");
1861  if (*stage == 7)
1862  {
1863  // start at 0
1864 
1865  txtHelper.DrawFormattedTextLine(L"Landforms loading (%i/%i)...", *instage + 1, landformtextureC);
1866 
1867  if (*instage == landformtextureC) // while less than terraintextureC
1868  {
1869  *instage = -1;
1870  logger->Log("Landforms loaded...");
1871  }
1872  else
1873  {
1874 #ifndef skipTerrain
1875  t = *instage;
1876  WCHAR filemsg[199];
1877  swprintf_s(filemsg, 199, L"Textures\\Terrain\\Landform_%02i.png", t);
1878  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
1879  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_L8,
1880  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1881  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsLandform[t])))
1882  {
1883  sprintf_s(msg, sizeof(msg), "Could not load \"%S\"! (%x)", filemsg, hr);
1884  logger->Log(msg, Logger::Level::Fatal);
1885  }
1886  else
1887  {
1888  sprintf_s(msg, sizeof(msg), "m_pddsLandform[%i]", t);
1890  }
1891  (*instage)++;
1892 #else
1893  *instage = -1;
1894 #endif
1895  } // instage loop
1896  } // stage==7
1897  } // stage>=7
1898 
1899  if (*stage >= 8)
1900  {
1901  if (*stage > 8)
1902  txtHelper.DrawTextLine(L"Runway and road layers loaded!");
1903  if (*stage == 8 && *instage == 0)
1904  {
1905  txtHelper.DrawTextLine(L"Marston Mats loading (1)...");
1906  if (FAILED(hr = D3DXCreateTextureFromFileExW(pd3dDevice, L"Textures\\RTS\\Marston1.dds",
1907  57, 28, D3DX_DEFAULT, 0, D3DFMT_DXT3,
1908  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1909  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsMarston1)))
1910  {
1911  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\RTS\\Marston1.dds\"! (%x)", hr);
1912  logger->Log(msg, Logger::Level::Fatal);
1913  }
1914  else
1915  viewscreen->gameclass->AddTrackedResource("m_pddsMarston1"); // managed
1916  *instage = 1;
1917  }
1918  else if (*stage == 8 && *instage == 1)
1919  {
1920  txtHelper.DrawTextLine(L"Runway edge light loading (1)...");
1921  if (FAILED(hr = D3DXCreateTextureFromFileExW(pd3dDevice, L"Textures\\RTS\\RunwayEdgeLight.dds",
1922  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_DXT1,
1923  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1924  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsRunwayEdgeLight1)))
1925  {
1926  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\RTS\\RunwayEdgeLight.dds\"! (%x)", hr);
1927  logger->Log(msg, Logger::Level::Fatal);
1928  }
1929  else
1930  viewscreen->gameclass->AddTrackedResource("m_pddsRunwayEdgeLight1"); // managed
1931  *instage = 2;
1932  }
1933  else if (*stage == 8 && *instage == 2)
1934  {
1935  txtHelper.DrawTextLine(L"Road texture loading (1)...");
1936  if (FAILED(hr = D3DXCreateTextureFromFileExW(pd3dDevice, L"Textures\\RTS\\Road.dds",
1937  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_DXT5,
1938  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1939  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsRoad)))
1940  {
1941  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\RTS\\Road.dds\"! (%x)", hr);
1942  logger->Log(msg, Logger::Level::Fatal);
1943  }
1944  else
1945  viewscreen->gameclass->AddTrackedResource("m_pddsRoad"); // managed
1946  *instage = 3;
1947  }
1948  else if (*stage == 8 && *instage == 3)
1949  {
1950  txtHelper.DrawTextLine(L"Intersection texture loading (1)...");
1951  if (FAILED(hr = D3DXCreateTextureFromFileExW(pd3dDevice, L"Textures\\RTS\\Intersection.dds",
1952  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_DXT5,
1953  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1954  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsIntersection)))
1955  {
1956  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\RTS\\Intersection.dds\"! (%x)", hr);
1957  logger->Log(msg, Logger::Level::Fatal);
1958  }
1959  else
1960  viewscreen->gameclass->AddTrackedResource("m_pddsIntersection"); // managed
1961  *instage = -1;
1962  }
1963  }
1964 
1965  if (*stage >= 9)
1966  {
1967  if (*stage > 9)
1968  txtHelper.DrawTextLine(L"Landform transitions loaded!");
1969  if (*stage == 9)
1970  {
1971  // start at 0
1972 
1973  txtHelper.DrawFormattedTextLine(L"Landform transitions loading (%i/%i)...", *instage + 1, transitiontextureC);
1974 
1975  if (*instage == transitiontextureC) // while less than terraintextureC
1976  {
1977  *instage = -1;
1978  logger->Log("Landform transitions loaded...");
1979  }
1980  else
1981  {
1982 #ifndef skipTerrain
1983  t = *instage;
1984  WCHAR filemsg[199];
1985  swprintf_s(filemsg, 199, L"Textures\\Terrain\\Transition_%02i.png", t + 1);
1986  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
1987  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_L8,
1988  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
1989  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsTransition[t])))
1990  {
1991  sprintf_s(msg, sizeof(msg), "Could not load \"%S\"! (%x)", filemsg, hr);
1992  logger->Log(msg, Logger::Level::Fatal);
1993  }
1994  else
1995  {
1996  sprintf_s(msg, sizeof(msg), "m_pddsTransition[%i]", t);
1998  }
1999  (*instage)++;
2000 #else
2001  *instage = -1;
2002 #endif
2003  } // instage loop
2004  } // stage==9
2005  } // stage>=9
2006 
2007  if (*stage >= 10)
2008  {
2009  if (*stage == 10)
2010  {
2011  // start at 0
2012 
2013  txtHelper.DrawFormattedTextLine(L"Cloud effects loading (%i/%i)...", *instage, elmoAnimateC);
2014 
2015  if (*instage == elmoAnimateC) // while less than elmoAnimateC
2016  {
2017  *instage = -1;
2018  logger->Log("Cloud effects loaded...");
2019  }
2020  else
2021  {
2022  t = *instage;
2023  WCHAR filemsg[199];
2024  swprintf_s(filemsg, 199, L"Textures\\Clouds\\Elmo%i.dds", t + 1);
2025  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
2026  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2027  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2028  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsElmo[t])))
2029  {
2030  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\Elmo%i.dds\"! (%x)", t + 1, hr);
2031  logger->Log(msg, Logger::Level::Fatal);
2032  }
2033  else
2034  {
2035  sprintf_s(msg, sizeof(msg), "m_pddsElmo[%i]", t);
2037  }
2038  (*instage)++;
2039  }
2040  }
2041  }
2042 
2043  if (*stage >= 11)
2044  {
2045  if (*stage > 11)
2046  txtHelper.DrawTextLine(L"Cloud layers loaded!");
2047  if (*stage == 11 && *instage == 2)
2048  {
2049  txtHelper.DrawTextLine(L"Cloud layers loading (tops)...");
2050  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\cloudbase.dds",
2051  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_L8,
2052  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2053  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsCloudBaseMap)))
2054  {
2055  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\cloudbase.dds\"! (%x)", hr);
2056  logger->Log(msg, Logger::Level::Fatal);
2057  }
2058  else
2059  viewscreen->gameclass->AddTrackedResource("m_pddsCloudBaseMap"); // managed
2060  *instage = -1;
2061  }
2062  if (*stage == 11 && *instage == 1)
2063  {
2064  txtHelper.DrawTextLine(L"Cloud layers loading (base detail)...");
2065  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\clouddetailbelow.dds",
2066  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_L8,
2067  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2068  D3DX_FILTER_BOX, 0, NULL, NULL,
2070  {
2071  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\clouddetailbelow.dds\"! (%x)", hr);
2072  logger->Log(msg, Logger::Level::Fatal);
2073  }
2074  else
2075  viewscreen->gameclass->AddTrackedResource("m_pddsCloudDetailBelow"); // managed
2076  *instage = 2;
2077  }
2078  if (*stage == 11 && *instage == 0)
2079  {
2080  txtHelper.DrawTextLine(L"Cloud layers loading (tops detail)...");
2081  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\clouddetailabove.dds",
2082  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_L8,
2083  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2084  D3DX_FILTER_BOX, 0, NULL, NULL,
2086  {
2087  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\clouddetailabove.dds\"! (%x)", hr);
2088  logger->Log(msg, Logger::Level::Fatal);
2089  }
2090  else
2091  viewscreen->gameclass->AddTrackedResource("m_pddsCloudDetailAbove"); // managed
2092  *instage = 1;
2093  }
2094  }
2095 
2096  if (*stage >= 12)
2097  {
2098  if (*stage > 12)
2099  txtHelper.DrawTextLine(L"Holiday effects loaded!");
2100  if (*stage == 12 && *instage == 0)
2101  {
2102  txtHelper.DrawTextLine(L"Holiday effects loading...");
2103  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Holidays\\halloween.dds",
2104  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2105  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2106  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsHolidayTexture)))
2107  {
2108  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Holidays\\halloween.dds\"! (%x)", hr);
2109  logger->Log(msg, Logger::Level::Fatal);
2110  }
2111  else
2112  viewscreen->gameclass->AddTrackedResource("m_pddsHolidayTexture"); // managed
2113  *instage = -1;
2114  }
2115  }
2116 
2117  if (*stage >= 13)
2118  {
2119  if (*stage > 13)
2120  txtHelper.DrawTextLine(L"Weapons loaded!");
2121  if (*stage == 13)
2122  {
2123  // start at 0
2124 
2125  txtHelper.DrawFormattedTextLine(L"Weapons loading (%i/%i)...", *instage, weaponanimateC);
2126 
2127  if (*instage == weaponanimateC) // while less than weaponanimateC
2128  {
2129  *instage = -1;
2130  logger->Log("Weapons loaded...");
2131  }
2132  else
2133  {
2134 #ifndef skipAnimations
2135  t = *instage;
2136  WCHAR filemsg[199];
2137  swprintf_s(filemsg, 199, L"Textures\\Weapons\\weapon%i.dds", t + 1);
2138  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
2139  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2140  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2141  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsWeapon[t])))
2142  {
2143  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Weapons\\weapon%i.dds\"! (%x)", t + 1, hr);
2144  logger->Log(msg, Logger::Level::Fatal);
2145  }
2146  else
2147  {
2148  sprintf_s(msg, sizeof(msg), "m_pddsWeapon[%i]", t);
2150  }
2151  swprintf_s(filemsg, 199, L"Textures\\Weapons\\Sinker\\sinker%04i.dds", t + 1);
2152  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
2153  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2154  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2155  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsSinker[t])))
2156  {
2157  sprintf_s(msg, sizeof(msg), "Could not load \"Weapons\\Sinker\\sinker%04i.dds\"! (%x)", t + 1, hr);
2158  logger->Log(msg, Logger::Level::Fatal);
2159  }
2160  else
2161  {
2162  sprintf_s(msg, sizeof(msg), "m_pddsSinker[%i]", t);
2164  }
2165  (*instage)++;
2166 #else
2167  *instage = -1;
2168 #endif
2169  } // instage loop
2170  } // stage==13
2171  } // stage>=13
2172 
2173  if (*stage >= 14)
2174  {
2175  if (*stage == 14)
2176  {
2177  txtHelper.DrawTextLine(L"Explosions loading (Blast)...");
2178 
2179 #ifndef skipAnimations
2180  if (FAILED(hr = D3DXCreateVolumeTextureFromFileExW(pd3dDevice, L"Textures\\Explosions\\blast.dds",
2181  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2182  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2183  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsBlastX)))
2184  {
2185  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Explosions\\blast.dds\"! (%x)", hr);
2186  logger->Log(msg, Logger::Level::Fatal);
2187  }
2188  else
2189  viewscreen->gameclass->AddTrackedResource("m_pddsBlastX"); // managed
2190  logger->Log("Explosions (Blast) loaded...");
2191 #endif
2192  *instage = -1;
2193  } // stage==14
2194  } // stage>=14
2195 
2196  if (*stage >= 15)
2197  {
2198  if (*stage == 15)
2199  {
2200  txtHelper.DrawTextLine(L"Explosions loading (Fuzer)...");
2201 
2202 #ifndef skipAnimations
2203  if (FAILED(hr = D3DXCreateVolumeTextureFromFileExW(pd3dDevice, L"Textures\\Explosions\\fuzer.dds",
2204  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2205  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2206  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsFuzerX)))
2207  {
2208  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Explosions\\fuzer.dds\"! (%x)", hr);
2209  logger->Log(msg, Logger::Level::Fatal);
2210  }
2211  else
2212  viewscreen->gameclass->AddTrackedResource("m_pddsFuzerX"); // managed
2213  logger->Log("Explosions (Fuzer) loaded...");
2214 #endif
2215  *instage = -1;
2216  } // stage==15
2217  } // stage>=15
2218 
2219  if (*stage >= 16)
2220  {
2221  if (*stage > 16)
2222  txtHelper.DrawTextLine(L"Explosions loaded!");
2223  if (*stage == 16)
2224  {
2225  txtHelper.DrawTextLine(L"Explosions loading (Sinker)...");
2226 
2227 #ifndef skipAnimations
2228  if (FAILED(hr = D3DXCreateVolumeTextureFromFileExW(pd3dDevice, L"Textures\\Explosions\\sinker.dds",
2229  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2230  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2231  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsSinkerX)))
2232  {
2233  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Explosions\\sinker.dds\"! (%x)", hr);
2234  logger->Log(msg, Logger::Level::Fatal);
2235  }
2236  else
2237  viewscreen->gameclass->AddTrackedResource("m_pddsSinkerX"); // managed
2238  logger->Log("Explosions (Sinker) loaded...");
2239 #endif
2240  *instage = -1;
2241  } // stage==16
2242  } // stage>=16
2243 
2244 #ifdef smoketestC
2245  for (t = 0; t < smoketrailC; t++)
2246  {
2247  sprintf_s(msg, sizeof(msg), "Textures\\Animations\\Smoke\\smoketest%04i.png", t + 1);
2248  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, Lmsg,
2249  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_A8R8G8B8,
2250  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2251  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &m_pddsSmoke[t])))
2252  {
2253  sprintf_s(msg, sizeof(msg), "Could not load \"Animations\\Smoke\\smoketest%04i.png\"! (%x)", t + 1, hr);
2254  Trace(msg, Logger::Level::Fatal);
2255  }
2256  else
2257  {
2258  sprintf_s(msg, sizeof(msg), "m_pddsSmoke[%i]", t);
2260  }
2261  }
2262 #endif
2263 
2264  if (*stage == 17)
2265  {
2266  *instage = -1;
2267 #ifndef skipAnimations
2268  if (FAILED(hr = D3DXCreateVolumeTextureFromFileExW(pd3dDevice, L"Textures\\Animations\\Reentry.dds",
2269  512, 512, 64, 1, 0, D3DFMT_DXT1,
2270  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2271  D3DX_FILTER_NONE, 0, nullptr, nullptr, &viewscreen->m_pddsReentry)))
2272  {
2273  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Animations\\Reentry.dds\"! (%x)", hr);
2274  logger->Log(msg, Logger::Level::Fatal);
2275  }
2276  else
2277  viewscreen->gameclass->AddTrackedResource("m_pddsReentry"); // managed
2278 #endif
2279  }
2280 
2281  if (*stage >= 18)
2282  {
2283  if (*stage == 18)
2284  {
2285  // start at 0
2286 
2287  txtHelper.DrawFormattedTextLine(L"Animations loading (DIHV (%i/%i))...", *instage, dihvanimateC);
2288 
2289  if (*instage == dihvanimateC) // while less than dihvanimateC
2290  {
2291  *instage = -1;
2292  logger->Log("Animations (DIHV) loaded...");
2293  }
2294  else
2295  {
2296 #ifndef skipAnimations
2297  t = *instage;
2298  WCHAR filemsg[199];
2299  swprintf_s(filemsg, 199, L"Textures\\Animations\\DIHV\\dihvexit%04i.dds", t + 1);
2300  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
2301  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2302  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2303  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsDIHV[t])))
2304  {
2305  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Animations\\DIHV\\dihvexit%04i.dds\"! (%x)", t + 1, hr);
2306  logger->Log(msg, Logger::Level::Fatal);
2307  }
2308  else
2309  {
2310  sprintf_s(msg, sizeof(msg), "m_pddsDIHV[%i]", t);
2312  }
2313  (*instage)++;
2314 #else
2315  *instage = -1;
2316 #endif
2317  } // instage loop
2318  } // stage==18
2319  } // stage>=18
2320 
2321  if (*stage >= 19)
2322  {
2323  if (*stage == 19)
2324  {
2325  // start at 0
2326 
2327  txtHelper.DrawFormattedTextLine(L"Animations loading (Caridac (%i/%i))...", *instage, heartanimateC);
2328 
2329  if (*instage == heartanimateC) // while less than heartanimateC
2330  {
2331  *instage = -1;
2332  logger->Log("Animations (Cardiac) loaded...");
2333  }
2334  else
2335  {
2336 #ifndef skipAnimations
2337  t = *instage;
2338  WCHAR filemsg[199];
2339  swprintf_s(filemsg, 199, L"Textures\\Animations\\Cardiac\\HEART%i.dds", t + 1);
2340  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
2341  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2342  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2343  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsHeart[t])))
2344  {
2345  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Animations\\Cardiac\\HEART%i.dds\"! (%x)", t + 1, hr);
2346  logger->Log(msg, Logger::Level::Fatal);
2347  }
2348  else
2349  {
2350  sprintf_s(msg, sizeof(msg), "m_pddsHeart[%i]", t);
2352  }
2353  (*instage)++;
2354 #else
2355  *instage = -1;
2356 #endif
2357  } // instage loop
2358  } // stage==19
2359  } // stage>=19
2360 
2361  if (*stage >= 20)
2362  {
2363  if (*stage > 20)
2364  txtHelper.DrawTextLine(L"Water normal loaded!");
2365  if (*stage == 20 && *instage == 0)
2366  {
2367  txtHelper.DrawTextLine(L"Water normal loading...");
2368  if (FAILED(hr = D3DXCreateTextureFromFileExW(pd3dDevice, L"Textures\\Terrain\\Water_Normal.png",
2369  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_R8G8B8,
2370  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2371  D3DX_FILTER_BOX, 0, NULL, NULL, &viewscreen->m_pddsWaterNormal)))
2372  {
2373  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Terrain\\Water_Normal.png\"! (%x)", hr);
2374  logger->Log(msg, Logger::Level::Fatal);
2375  }
2376  else
2377  viewscreen->gameclass->AddTrackedResource("m_pddsWaterNormal"); // managed
2378  *instage = -1;
2379  }
2380  }
2381 
2382  if (*stage == 21)
2383  *stage = 23;
2384 
2385  if (*stage >= 23)
2386  {
2387  if (*stage == 23)
2388  {
2389  // start at 0
2390 
2391  txtHelper.DrawFormattedTextLine(L"Animations loading (Fireworks_1 (%i/%i))...", *instage, firework1C);
2392 
2393  if (*instage == firework1C) // while less than firework1C
2394  {
2395  *instage = -1;
2396  logger->Log("Animations (Fireworks 1/3) loaded...");
2397  }
2398  else
2399  {
2400 #ifndef skipAnimations
2401  t = *instage;
2402  WCHAR filemsg[199];
2403  swprintf_s(filemsg, 199, L"Textures\\Animations\\Fireworks\\fw1%04i.dds", t + 1);
2404  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
2405  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2406  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2407  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsFirework1[t])))
2408  {
2409  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Animations\\Fireworks\\fw1%04i.dds\"! (%x)", t + 1, hr);
2410  logger->Log(msg, Logger::Level::Fatal);
2411  }
2412  else
2413  {
2414  sprintf_s(msg, sizeof(msg), "m_pddsFirework1[%i]", t);
2416  }
2417  (*instage)++;
2418 #else
2419  *instage = -1;
2420 #endif
2421  } // instage loop
2422  } // stage==23
2423  } // stage>=23
2424 
2425  if (*stage >= 24)
2426  {
2427  if (*stage == 24)
2428  {
2429  // start at 0
2430 
2431  txtHelper.DrawFormattedTextLine(L"Animations loading (Fireworks_2 (%i/%i))...", *instage, firework2C);
2432 
2433  if (*instage == firework2C) // while less than firework2C
2434  {
2435  *instage = -1;
2436  logger->Log("Animations (Fireworks 2/3) loaded...");
2437  }
2438  else
2439  {
2440 #ifndef skipAnimations
2441  t = *instage;
2442  WCHAR filemsg[199];
2443  swprintf_s(filemsg, 199, L"Textures\\Animations\\Fireworks\\fw2%04i.dds", t + 1);
2444  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
2445  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2446  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2447  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsFirework2[t])))
2448  {
2449  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Animations\\Fireworks\\fw2%04i.dds\"! (%x)", t + 1, hr);
2450  logger->Log(msg, Logger::Level::Fatal);
2451  }
2452  else
2453  {
2454  sprintf_s(msg, sizeof(msg), "m_pddsFirework2[%i]", t);
2456  }
2457  (*instage)++;
2458 #else
2459  *instage = -1;
2460 #endif
2461  } // instage loop
2462  } // stage==24
2463  } // stage>=24
2464 
2465  if (*stage >= 25)
2466  {
2467  if (*stage > 25)
2468  txtHelper.DrawTextLine(L"Animations loaded!");
2469  if (*stage == 25)
2470  {
2471  // start at 0
2472 
2473  txtHelper.DrawFormattedTextLine(L"Animations loading (Fireworks_3 (%i/%i))...", *instage, firework3C);
2474 
2475  if (*instage == firework3C) // while less than firework3C
2476  {
2477  *instage = -1;
2478  logger->Log("Animations (Fireworks 3/3) loaded...");
2479  }
2480  else
2481  {
2482 #ifndef skipAnimations
2483  t = *instage;
2484  WCHAR filemsg[199];
2485  swprintf_s(filemsg, 199, L"Textures\\Animations\\Fireworks\\fw3%04i.dds", t + 2);
2486  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, filemsg,
2487  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2488  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2489  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsFirework3[t])))
2490  {
2491  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Animations\\Fireworks\\fw3%04i.dds\"! (%x)", t + 2, hr);
2492  logger->Log(msg, Logger::Level::Fatal);
2493  }
2494  else
2495  {
2496  sprintf_s(msg, sizeof(msg), "m_pddsFirework3[%i]", t);
2498  }
2499  (*instage)++;
2500 #else
2501  *instage = -1;
2502 #endif
2503  } // instage loop
2504  } // stage==25
2505  } // stage>=25
2506 
2507  if (*stage >= 26)
2508  {
2509  if (*stage > 26)
2510  txtHelper.DrawTextLine(L"Instruments loaded!");
2511  if (*stage == 26 && *instage == 10)
2512  {
2513  /*txtHelper.DrawTextLine(L"Instruments loading (Arrow)...");
2514  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Instruments\\arrow.dds",
2515  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_L8,
2516  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2517  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsArrow)))
2518  {
2519  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Instruments\\arrow.dds\"! (%x)", hr);
2520  logger->Log(msg, Logger::Level::Fatal);
2521  }
2522  else
2523  viewscreen->gameclass->AddTrackedResource("m_pddsArrow"); // managed */
2524  *instage = -1;
2525  }
2526  if (*stage == 26 && *instage == 9)
2527  {
2528  txtHelper.DrawTextLine(L"Instruments loading (Interlace)...");
2529  if (FAILED(hr = D3DXCreateTextureFromResourceEx(pd3dDevice, DXUTGetHINSTANCE(),
2530  MAKEINTRESOURCE(IDB_BITMAP1),
2531  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_L8,
2532  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2533  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsInterlace[0])))
2534  {
2535  sprintf_s(msg, sizeof(msg), "Could not load resource IDB_BITMAP1! (%x)", hr);
2536  logger->Log(msg, Logger::Level::Fatal);
2537  }
2538  else
2539  viewscreen->gameclass->AddTrackedResource("m_pddsInterlace[0]"); // managed
2540  if (FAILED(hr = D3DXCreateTextureFromResourceEx(pd3dDevice, DXUTGetHINSTANCE(),
2541  MAKEINTRESOURCE(IDB_BITMAP2),
2542  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_L8,
2543  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2544  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsInterlace[1])))
2545  {
2546  sprintf_s(msg, sizeof(msg), "Could not load resource IDB_BITMAP2! (%x)", hr);
2547  logger->Log(msg, Logger::Level::Fatal);
2548  }
2549  else
2550  viewscreen->gameclass->AddTrackedResource("m_pddsInterlace[1]"); // managed
2551  *instage = 10;
2552  }
2553  if (*stage == 26 && *instage == 8)
2554  {
2555  /*txtHelper.DrawTextLine(L"Instruments loading (Vbug)...");
2556  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Instruments\\vector.dds",
2557  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_L8,
2558  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2559  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsVector)))
2560  {
2561  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Instruments\\vector.dds\"! (%x)", hr);
2562  logger->Log(msg, Logger::Level::Fatal);
2563  }
2564  else
2565  viewscreen->gameclass->AddTrackedResource("m_pddsVector"); // managed */
2566  *instage = 9;
2567  }
2568  if (*stage == 26 && *instage == 7)
2569  {
2570  txtHelper.DrawTextLine(L"Instruments loading (sunglasses)...");
2571  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Inventory\\Burbank-Sun_02.png",
2572  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_A8R8G8B8,
2573  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2574  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsSunglasses)))
2575  {
2576  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Inventory\\Burbank-Sun_02.png\"! (%x)", hr);
2577  logger->Log(msg, Logger::Level::Fatal);
2578  }
2579  else
2580  viewscreen->gameclass->AddTrackedResource("m_pddsSunglasses"); // managed
2581  *instage = 8;
2582  }
2583  if (*stage == 26 && *instage == 6)
2584  {
2585  txtHelper.DrawTextLine(L"Instruments loading (binoculars)...");
2586  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Inventory\\Binoculars.dds",
2587  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2588  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2589  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsBinoculars)))
2590  {
2591  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Inventory\\Binoculars.dds\"! (%x)", hr);
2592  logger->Log(msg, Logger::Level::Fatal);
2593  }
2594  else
2595  viewscreen->gameclass->AddTrackedResource("m_pddsBinoculars"); // managed
2596 
2597  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Inventory\\Binoculars-compass.dds",
2598  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2599  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2600  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsBinocularsCompass)))
2601  {
2602  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Inventory\\Binoculars-compass.dds\"! (%x)", hr);
2603  logger->Log(msg, Logger::Level::Fatal);
2604  }
2605  else
2606  viewscreen->gameclass->AddTrackedResource("m_pddsBinocularsCompass"); // managed
2607 
2608  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Inventory\\Binoculars-arrow.dds",
2609  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2610  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2611  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsBinocularsArrow)))
2612  {
2613  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Inventory\\Binoculars-arrow.dds\"! (%x)", hr);
2614  logger->Log(msg, Logger::Level::Fatal);
2615  }
2616  else
2617  viewscreen->gameclass->AddTrackedResource("m_pddsBinocularsArrow"); // managed
2618  *instage = 7;
2619  }
2620  if (*stage == 26 && *instage == 5)
2621  {
2622  *instage = 6;
2623  }
2624  if (*stage == 26 && *instage == 4)
2625  {
2626  *instage = 5;
2627  }
2628  if (*stage == 26 && *instage == 3)
2629  {
2630  *instage = 4;
2631  }
2632  if (*stage == 26 && *instage == 2)
2633  {
2634  *instage = 3;
2635  }
2636  if (*stage == 26 && *instage == 1)
2637  {
2638  *instage = 2;
2639  }
2640  if (*stage == 26 && *instage == 0)
2641  {
2642  *instage = 1;
2643  }
2644  } // stage>=26
2645 
2646  if (*stage >= 27)
2647  {
2648  if (*stage > 27)
2649  txtHelper.DrawTextLine(L"Additional effects loaded!");
2650  if (*stage == 27 && *instage == 9)
2651  {
2652  *instage = -1;
2653  }
2654  if (*stage == 27 && *instage == 8)
2655  {
2656  txtHelper.DrawTextLine(L"Additional effects loading (Lightning_1)...");
2657  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\lightningbelow.dds",
2658  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2659  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2660  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsLightningBelow[0])))
2661  {
2662  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\lightningbelow.dds\"! (%x)", hr);
2663  logger->Log(msg, Logger::Level::Fatal);
2664  }
2665  else
2666  viewscreen->gameclass->AddTrackedResource("m_pddsLightningBelow[0]"); // managed
2667  *instage = 9;
2668  }
2669  if (*stage == 27 && *instage == 7)
2670  {
2671  txtHelper.DrawTextLine(L"Additional effects loading (Lightning_2)...");
2672  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\lightningbelow1.dds",
2673  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2674  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2675  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsLightningBelow[1])))
2676  {
2677  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\lightningbelow1.dds\"! (%x)", hr);
2678  logger->Log(msg, Logger::Level::Fatal);
2679  }
2680  else
2681  viewscreen->gameclass->AddTrackedResource("m_pddsLightningBelow[1]"); // managed
2682  *instage = 8;
2683  }
2684  if (*stage == 27 && *instage == 6)
2685  {
2686  txtHelper.DrawTextLine(L"Additional effects loading (Lightning_3)...");
2687  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\lightningbelow2.dds",
2688  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT1,
2689  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2690  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsLightningBelow[2])))
2691  {
2692  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\lightningbelow2.dds\"! (%x)", hr);
2693  logger->Log(msg, Logger::Level::Fatal);
2694  }
2695  else
2696  viewscreen->gameclass->AddTrackedResource("m_pddsLightningBelow[2]"); // managed
2697  *instage = 7;
2698  }
2699  if (*stage == 27 && *instage == 5)
2700  {
2701  txtHelper.DrawTextLine(L"Additional effects loading (Lightning_4)...");
2702  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\lightningtoground.dds",
2703  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2704  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2705  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsLightningAbove[0])))
2706  {
2707  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\lightningtoground.dds\"! (%x)", hr);
2708  logger->Log(msg, Logger::Level::Fatal);
2709  }
2710  else
2711  viewscreen->gameclass->AddTrackedResource("m_pddsLightningAbove[0]"); // managed
2712  *instage = 6;
2713  }
2714  if (*stage == 27 && *instage == 4)
2715  {
2716  txtHelper.DrawTextLine(L"Additional effects loading (Lightning_5)...");
2717  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\lightningtosky.dds",
2718  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2719  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2720  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsLightningAbove[1])))
2721  {
2722  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\lightningtosky.dds\"! (%x)", hr);
2723  logger->Log(msg, Logger::Level::Fatal);
2724  }
2725  else
2726  viewscreen->gameclass->AddTrackedResource("m_pddsLightningAbove[1]"); // managed
2727  *instage = 5;
2728  }
2729  if (*stage == 27 && *instage == 3)
2730  {
2731  txtHelper.DrawTextLine(L"Additional effects loading (Lightning_6)...");
2732  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\Clouds\\lightningincloud.dds",
2733  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2734  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2735  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsLightningAbove[2])))
2736  {
2737  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Clouds\\lightningincloud.dds\"! (%x)", hr);
2738  logger->Log(msg, Logger::Level::Fatal);
2739  }
2740  else
2741  viewscreen->gameclass->AddTrackedResource("m_pddsLightningAbove[2]"); // managed
2742  *instage = 4;
2743  }
2744  if (*stage == 27 && *instage == 2)
2745  {
2746  txtHelper.DrawTextLine(L"Additional effects loading (AA Ramp)...");
2747  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\atmosphere.dds",
2748  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_A8R8G8B8,
2749  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2750  D3DX_FILTER_NONE, 0, NULL, NULL, &viewscreen->m_pddsAtmosphere)))
2751  {
2752  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\atmosphere.dds\"! (%x)", hr);
2753  logger->Log(msg, Logger::Level::Fatal);
2754  }
2755  else
2756  viewscreen->gameclass->AddTrackedResource("m_pddsAtmosphere"); // managed
2757  *instage = 3;
2758  }
2759 
2760 #ifdef treetestC
2761  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\treetest.dds",
2762  D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_DXT3,
2763  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2764  D3DX_FILTER_NONE, 0, NULL, NULL, &game->m_pddsTree)))
2765  {
2766  sprintf_s(msg, sizeof(msg), "Could not load \"treetest.dds\"! (%x)", hr);
2767  Trace(msg, Logger::Level::Fatal);
2768  }
2769  else
2770  game->gameclass->AddTrackedResource("m_pddsTree"); // managed
2771 #endif
2772 
2773  if (*stage == 27 && *instage == 1)
2774  {
2775  txtHelper.DrawTextLine(L"Additional effects loading (Flare)...");
2776  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\pointsprite.dds",
2777  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_DXT1,
2778  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2779  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsStarTexture)))
2780  {
2781  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\pointsprite.dds\"! (%x)", hr);
2782  logger->Log(msg, Logger::Level::Fatal);
2783  }
2784  else
2785  viewscreen->gameclass->AddTrackedResource("m_pddsStarTexture"); // managed
2786  *instage = 2;
2787  }
2788  if (*stage == 27 && *instage == 0)
2789  {
2790  txtHelper.DrawTextLine(L"Additional effects loading (Font)...");
2791  if (FAILED(hr = D3DXCreateTextureFromFileEx(pd3dDevice, L"Textures\\fonts\\hull.dds",
2792  D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_DXT1,
2793  D3DPOOL_MANAGED, D3DX_FILTER_NONE,
2794  D3DX_FILTER_BOX | D3DX_FILTER_MIRROR, 0, NULL, NULL, &viewscreen->m_pddsLetters)))
2795  {
2796  sprintf_s(msg, sizeof(msg), "Could not load \"Textures\\Fonts\\hull.dds\"! (%x)", hr);
2797  logger->Log(msg, Logger::Level::Fatal);
2798  }
2799  else
2800  viewscreen->gameclass->AddTrackedResource("m_pddsLetters"); // managed
2801  *instage = 1;
2802  }
2803  } // stage>=27
2804 
2805  if (*stage == 28)
2806  *stage = 29;
2807 
2808  if (*stage >= 29)
2809  {
2810  if (*stage == 29)
2811  {
2812  *instage = -1; // to next stage
2813  DXUTGetGlobalTimer()->GetElapsedTime();
2814 
2815  if (playerships[0].docked && playerships[0].reference < REF_INANOTHER)
2816  {
2817  logger->Log("Was out of docking area with dock status positive, cleared...");
2818  playerships[0].docked = false;
2819  }
2820  else if (playerships[0].docked)
2821  {
2822  logger->Log("Docking status was nominally docked, proceeding to unlock...");
2823  }
2824  else
2825  {
2826  logger->Log("Docking status was nominally undocked, proceeding to unlock...");
2827  }
2828 
2829 
2830  logger->Log("Docking status was unlocked successfully...");
2831 
2832  } // stage==29
2833  } // stage>=29
2834 
2835  if (*stage >= 30)
2836  {
2837  if (*stage > 30)
2838  {
2839  txtHelper.DrawTextLine(L"Initialized ground data!");
2840  txtHelper.DrawTextLine(L"Press SPACE BAR to continue...");
2841  g_bEnabled = true;
2842  }
2843 
2844  if (*stage == 30)
2845  {
2846  txtHelper.DrawFormattedTextLine(L"Initializing ground data (%.0f to timeout)...", 30.0f - timepassed);
2847 
2848  // If below middle of cloud deck, wait for terrain packet
2849  if (playerships[0].reference == REF_ONGROUND || playerships[0].reference == REF_APNMODE ||
2850  (playerships[0].reference == REF_INANOTHER && (playerships[playerships[0].inarray].reference == REF_ONGROUND || playerships[playerships[0].inarray].reference == REF_APNMODE)) ||
2851  playerships[0].reference == REF_BUILDING || playerships[0].reference == REF_SIMBAY) // unless we add a hook for reference change in addition to aboveClouds and cube we need to do for windowless environment or sim bay
2852  {
2853  if (timepassed == 0.0f)
2854  {
2855  sprintf_s(msg, sizeof(msg), "Built-in packet hold (%f)", D3DXVec3Length(&playerships[0].position));
2856  logger->Log(msg);
2857  }
2858 
2860  {
2861  *instage = -1;
2862  logger->Log("Built-in packet hold expired successfully!");
2863  }
2864  else if (!viewscreen->ptrGrid->dataPending)
2865  {
2867 
2869 
2870  logger->Log("renderer::LoadTextures is RWG now...");
2871  }
2872 
2874  if (timepassed > 30.0f)
2875  logger->Log("Built-in packet hold failed after 30 seconds!", Logger::Level::Fatal);
2876  }
2877  else
2878  {
2879  logger->Log("Built-in packet hold was not required...");
2880  *instage = -1;
2881  }
2882  } // stage==30
2883  } // stage>=30
2884 
2885  txtHelper.End();
2886 
2887  logger->AddToCallStack("renderer::LoadTextures DONE");
2888 }
2889 
2890 void renderer::RenderDocks(IDirect3DDevice9* pd3dDevice, const D3DXVECTOR3* Xsunlight)
2891 {
2892  logger->AddToCallStack("renderer::RenderDocks");
2893 
2894  D3DXMATRIX matrixTemp;
2895  D3DXVECTOR3 result;
2896  D3DXVECTOR3 vieneohit;
2897  D3DXMATRIX matrixWorld;
2898 
2899  // Must run loop first to determine distances
2900  // @todo should be in framemove
2901  float distcompare = FLT_MAX;
2902  viewscreen->dockTexture = 0;
2903  for (t = 0; t < maxdockC; t++)
2904  {
2905  if (allobjects[t].distance < (allobjects[t].bound*1000.0f)) // In visual range
2906  {
2907  if (allobjects[t].distance < distcompare)
2908  {
2909  distcompare = allobjects[t].distance;
2910  viewscreen->dockTexture = t + 1; // CP is 1, Easydock is 2, starts as 0
2911  // DO NOT ZERO OUT SINCE WE DUMP FRAMEMOVE BIGGER THAN A SECOND
2912  }
2913  }
2914  }
2915 
2917  {
2918  // Docks ------------------------------------------------------------------------------------
2919  V(viewscreen->gameclass->graphics->g_pEffect->Begin(NULL, 0));
2920  V(viewscreen->gameclass->graphics->g_pEffect->BeginPass(6)); // docks
2921 
2922 
2923  t = viewscreen->dockTexture - 1;
2924  // Fix those who are beyond clipping plane
2925  result.x = -allobjects[t].matrixWorld._41;
2926  result.y = -allobjects[t].matrixWorld._42;
2927  result.z = -allobjects[t].matrixWorld._43;
2928  float f_temp = D3DXVec3Length(&result);
2929  if (f_temp > cutplaneC)
2930  {
2931  f_temp = cutplaneC / f_temp; // If it is 2x as far, this value is 0.5f
2932 
2933  // Scale apparent scale in matrix
2934  D3DXMatrixScaling(&matrixTemp, f_temp, f_temp, f_temp);
2935  D3DXMatrixMultiply(&allobjects[t].matrixWorld, &matrixTemp, &allobjects[t].matrixWorld);
2936 
2937  // Scale location in matrix
2938  D3DXVec3Scale(&result, &result, 1.0f - f_temp);
2939  D3DXMatrixTranslation(&matrixTemp, result.x, result.y, result.z);
2940  D3DXMatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
2941  }
2942 
2943 
2944  // Ambient light adjustment and disabling of the diffuse light after sunset
2945  D3DXVECTOR4 radiosity = D3DXVECTOR4(0, 0, 0, 0);
2946  if (!playerships[0].simulator && viewscreen->ptrWeather->shadow > 0.0f)
2947  {
2948  // Reflection of light from surface (radiosity)
2949  D3DXVec3Scale(&vieneohit, Xsunlight, radiusC); // Where it hits Vieneo
2950  D3DXVec3Subtract(&result, &allobjects[t].position, &vieneohit); // Vector from surface point to this object
2951  D3DXVec3Normalize(&result, &result);
2952  radiosity.x = result.x; radiosity.y = result.y; radiosity.z = -result.z;
2953  radiosity.w = D3DXVec3Dot(&result, Xsunlight); // cos of angle between the two
2954  radiosity.w = 1.0f - radiosity.w; // Compliment, not comparing to surface normal you know
2955  radiosity.w /= powf(D3DXVec3Length(&allobjects[t].position) / radiusC, 2.0f);
2956  }
2957  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("Radiosity", &radiosity));
2958 
2959 
2960  // Adjust diffuse by shadow
2961  D3DXVECTOR4 Sunlight;
2962  Sunlight.x = -viewscreen->sunlight.Direction.x; Sunlight.y = -viewscreen->sunlight.Direction.y; Sunlight.z = -viewscreen->sunlight.Direction.z;
2963  Sunlight.w = viewscreen->ptrWeather->shadow;
2964  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("Sunlight", &Sunlight));
2965 
2966 
2967  pd3dDevice->SetStreamSource(0, polyobjects[1].VB, 0, sizeof(D3DVERTEX));
2968 
2969 
2970 
2971  short oldtexture = -1;
2972  for (s = 0; s < allobjects[t].components; s++)
2973  {
2974  D3DXMatrixRotationYawPitchRoll(&matrixWorld, allobjects[t].componentarray[s].nominalypr.x, allobjects[t].componentarray[s].nominalypr.y, allobjects[t].componentarray[s].nominalypr.z);
2975 
2976  // Extensions
2977  D3DXVec3Scale(&result, &allobjects[t].componentarray[s].extendby, allobjects[t].componentarray[s].extended);
2978  D3DXVec3Add(&result, &allobjects[t].componentarray[s].nominalxyz, &result);
2979 
2980  D3DXMatrixTranslation(&matrixTemp, result.x, result.y, result.z);
2981  D3DXMatrixMultiply(&matrixWorld, &matrixWorld, &matrixTemp);
2982  D3DXMatrixMultiply(&matrixWorld, &matrixWorld, &allobjects[t].matrixWorld);
2983 
2984  // D3DXMatrixScaling( &matrixTemp, allobjects[t].bound, allobjects[t].bound, allobjects[t].bound );
2985  // D3DXMatrixMultiply( &matrixWorld, &matrixTemp, &matrixWorld );
2986 
2987  D3DXMATRIX mWorldViewProj;
2988  if (playerships[0].simulator)
2989  mWorldViewProj = matrixWorld * viewscreen->matrixView * viewscreen->matrixProjSim;
2990  else
2991  mWorldViewProj = matrixWorld * viewscreen->matrixLook * viewscreen->matrixProj;
2992  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
2993  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorld", &matrixWorld));
2994 
2995  D3DXVECTOR4 clouduv;
2996  // Texture assignment
2997  oldtexture = allobjects[t].componentarray[s].texture;
2998  V(viewscreen->gameclass->graphics->g_pEffect->SetTexture("ColorMap", viewscreen->m_pddsDockTexture[oldtexture]));
2999 
3000  if (viewscreen->m_pddsDockLights[oldtexture] && allobjects[t].powered)
3001  {
3002  V(viewscreen->gameclass->graphics->g_pEffect->SetTexture("ColorMap2", viewscreen->m_pddsDockLights[oldtexture]));
3003  clouduv.y = 1.0f;
3004  }
3005  else
3006  {
3007  clouduv.y = 0.0f;
3008  }
3009 
3010  if (allobjects[t].componentarray[s].type == 40 && allobjects[t].powered) // Scrolling signage
3011  {
3012  clouduv.z = allobjects[t].componentarray[s].extended;
3013  }
3014  else
3015  {
3016  clouduv.z = -1.0f;
3017  }
3018  // else if (allobjects[t].componentarray[s].type==3) // transparency
3019  // pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
3020 
3021 
3022  clouduv.w = allobjects[t].componentarray[s].type;
3023  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("clouduv", &clouduv));
3024  V(viewscreen->gameclass->graphics->g_pEffect->CommitChanges());
3025 
3026  pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, allobjects[t].componentarray[s].startvertex, allobjects[t].componentarray[s].primitives);
3027 
3028  } // end of component loop
3029 
3030  // Restore
3031  V(viewscreen->gameclass->graphics->g_pEffect->EndPass());
3032  V(viewscreen->gameclass->graphics->g_pEffect->End());
3033 
3034  // Docks ------------------------------------------------------------------------------------
3035 
3036  } // end of to draw
3037 
3038 
3039  // @todo should be in framemove
3041  {
3044 
3045  if (viewscreen->dockTexture > 0)
3046  {
3047  int handle = -1;
3048  switch (viewscreen->dockTexture)
3049  {
3050  case 1: _sopen_s(&handle, "Meshes\\cutters.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
3051  break;
3052  case 2: _sopen_s(&handle, "Meshes\\easydock.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
3053  break;
3054  case 3: _sopen_s(&handle, "Meshes\\sentry station 12.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
3055  break;
3056  }
3057  if (handle == -1)
3058  {
3059  char msg[99];
3060  char strerr[99];
3061  strerror_s(strerr, 99, errno);
3062  sprintf_s(msg, sizeof(msg), "Could not load dock (DAW file %i) number %i: %s", viewscreen->dockTexture, 1, strerr);
3063  logger->Log(msg, Logger::Level::Fatal);
3064  }
3065 
3066  char msg[99];
3067  // Vertices -----------------------------------------------------------------------------
3068  _lseek(handle, 0L, SEEK_SET);
3069  _read(handle, &polyobjects[1].vertices, 2);
3071 
3072  sprintf_s(msg, sizeof(msg), "Loading file (%i vertices) for polygon object number %i...", polyobjects[1].vertices, 1);
3073  logger->Log(msg);
3074 
3075  if (polyobjects[1].vertices > dockvertC)
3076  {
3077  sprintf_s(msg, sizeof(msg), "Failure, out-of-bounds number of vertices %i/%i maximum", polyobjects[1].vertices, dockvertC);
3078  logger->Log(msg, Logger::Level::Fatal);
3079  }
3080 
3081  D3DVERTEX* vtx;
3082 
3083  // Lock the vertex buffer
3084  V(polyobjects[1].VB->Lock(0, 0, reinterpret_cast<void**>(&vtx), D3DLOCK_DISCARD));
3085 
3086  D3DXVECTOR3 tempnormal;
3087 
3088  for (s = 0; s < polyobjects[1].vertices; s++)
3089  {
3090  _lseek(handle, 2L + s * 32L + 0L, SEEK_SET);
3091  _read(handle, &tempnormal, 12);
3092  (*vtx).x = tempnormal.x;
3093  (*vtx).y = tempnormal.y;
3094  (*vtx).z = tempnormal.z;
3095 
3096  _lseek(handle, 2L + s * 32L + 12L, SEEK_SET);
3097  _read(handle, &tempnormal, 12);
3098  (*vtx).nx = tempnormal.x;
3099  (*vtx).ny = tempnormal.y;
3100  (*vtx).nz = tempnormal.z;
3101  _lseek(handle, 2L + s * 32L + 24L, SEEK_SET);
3102  _read(handle, &tempnormal.x, 4);
3103  _read(handle, &tempnormal.y, 4);
3104  (*vtx).tu = tempnormal.x;
3105  (*vtx).tv = tempnormal.y;
3106  vtx++;
3107  }
3108 
3109  V(polyobjects[1].VB->Unlock());
3110 
3111 
3112  t = 1;
3113  short numberOfEffects;
3114  _read(handle, &numberOfEffects, 2);
3115  sprintf_s(msg, sizeof(msg), "RenderDocks loading %i light(s) for polygon object number %i...", numberOfEffects, t);
3116  logger->Log(msg);
3117  polyobjects[t].effects.clear();
3118  for (s = 0; s < numberOfEffects; s++)
3119  {
3120  s_light_effect lightEffect;
3121  _read(handle, &lightEffect.position, 12);
3122  _read(handle, &lightEffect.normal, 12);
3123  DWORD diffuse;
3124  _read(handle, &diffuse, 4);
3125  lightEffect.diffuse = diffuse;
3126  _read(handle, &lightEffect.sequencing, 4);
3127  _read(handle, &lightEffect.speed, 4); // unused
3128  _read(handle, &lightEffect.power, 4);
3129  _read(handle, &lightEffect.attachto, 2); // unused
3130  lightEffect.primitive = 0;
3131  sprintf_s(msg, sizeof(msg), "\tx%f y%f z%f nx%f ny%f nz%f %x p%f", lightEffect.position.x, lightEffect.position.y, lightEffect.position.z, lightEffect.normal.x, lightEffect.normal.y, lightEffect.normal.z, (DWORD)lightEffect.diffuse, lightEffect.power);
3132  logger->Log(msg);
3133  polyobjects[t].effects.emplace_back(lightEffect);
3134  }
3135 
3136  _close(handle);
3137  }
3138  sprintf_s(msg, sizeof(msg), "Dock DAW/DIX library number changed to %i...", viewscreen->dockTexture);
3139  logger->Log(msg);
3140  }
3141 
3142  logger->AddToCallStack("renderer::RenderDocks END");
3143 }
3144 
3145 void renderer::RenderBuildings(IDirect3DDevice9* pd3dDevice, double* fTime, bool drawTransparancy)
3146 {
3147  if (drawTransparancy)
3148  logger->AddToCallStack("renderer::RenderBuildings TRUE");
3149  else
3150  logger->AddToCallStack("renderer::RenderBuildings FALSE");
3151 
3152  D3DXMATRIX matrixTemp;
3153  D3DXMATRIX matrixWorld;
3154 
3155  // Don't have to exclude these by distance because they are only painted on their associated grid areas
3156  pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS); // for field crops
3157  //pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, drawTransparancy); // for field crops
3158 #ifdef _DEBUG
3159  //DWORD pValue;
3160  //pd3dDevice->GetRenderState(D3DRS_STENCILFUNC, &pValue); //greater
3161  //pd3dDevice->GetRenderState(D3DRS_STENCILREF, &pValue); // 3
3162  //pd3dDevice->GetRenderState(D3DRS_STENCILENABLE, &pValue); // enabled
3163  //pd3dDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &pValue); // for field crops
3164  //pd3dDevice->GetRenderState(D3DRS_ZENABLE, &pValue); // for field crops
3165 #endif
3166 
3167  D3DXVECTOR4 temp4;
3168  // 0.81639451247543304392886672218378 magnitude
3169  // mag should be 0.082352941176470588235294117647059
3170  // @todo can't do it this way ... we would need a "specular" property passed in to augment the light
3171  //temp4.x = max(viewscreen->ptrWeather->bcllight.r, 0.0853626f*buildzone[sortme[t].buildzone].specular);
3172  //temp4.y = max(viewscreen->ptrWeather->bcllight.g, 0.0980091f*buildzone[sortme[t].buildzone].specular);
3173  //temp4.z = max(viewscreen->ptrWeather->bcllight.b, 0.1011710f*buildzone[sortme[t].buildzone].specular);
3174  // we are 208 average (times 0.5 is 104), should be 21
3175  temp4.x = viewscreen->alphascreen.r;
3176  temp4.y = viewscreen->alphascreen.g;
3177  temp4.z = viewscreen->alphascreen.b;
3178  temp4.w = viewscreen->ptrWeather->fFogEndHorizon;
3179  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("ambient", &temp4));
3180 
3181 
3182  short oldtexture = -1;
3183 
3184  D3DXMATRIX matTemp;
3185 
3186  V(viewscreen->gameclass->graphics->g_pEffect->Begin(NULL, 0));
3187 
3188  for (t = 0; t < buildingVBC; t++) // go through all build zones, only draw ones that are visible
3189  {
3190  if (sortme[t].dist < 99.0f)
3191  {
3192  BUILDZONE buildzone1 = buildzone[sortme[t].buildzone];
3193  VECTOR2SHORT actual;
3194  actual.u = buildzone1.u - viewscreen->ptrGrid->tcp.u;
3195  actual.v = buildzone1.v - viewscreen->ptrGrid->tcp.v;
3196 
3197  // This is the rotated TCP
3198  temp.x = static_cast<float>(actual.u);
3199  temp.y = static_cast<float>(actual.v);
3200  D3DXVec2TransformNormal(&temp, &temp, &viewscreen->matGridRot);
3201  u = static_cast<short>(temp.x) + 31;
3202  v = static_cast<short>(temp.y) + 31;
3203  actual.u += 31;
3204  actual.v += 31;
3205  if (u > 15 && u < 48 && v > 15 && v < 48 && viewscreen->gridvisible[u][v])
3206  {
3207  D3DXVECTOR4 clouduv;
3208  clouduv.x = 0.0f; // UNUSED
3209  clouduv.y = 0.0f; // UNUSED
3210  clouduv.w = powf(1.0f - viewscreen->sunlight.Diffuse.a, 2.0f); // light blend
3211  clouduv.z = buildzone[sortme[t].buildzone].emissive * clouduv.w; // emissive
3212  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("clouduv", &clouduv));
3213 
3214 
3215  if (!gridarray[actual.u][actual.v].powered)
3216  {
3217  V(viewscreen->gameclass->graphics->g_pEffect->SetTexture("ColorMap2", nullptr));
3218  }
3219 
3220  V(pd3dDevice->SetStreamSource(0, buildzone1.VB, 0, sizeof(D3DVERTEX)));
3221  D3DXMatrixTranslation(&matrixTemp,
3222  static_cast<float>(playerships[0].precisionx + static_cast<double>(buildzone1.terpos.x)),
3223  static_cast<float>(playerships[0].precisiony + static_cast<double>(buildzone1.terpos.y)),
3224  static_cast<float>(playerships[0].precisionz + static_cast<double>(buildzone1.terpos.z)));
3225 
3226  D3DXMATRIX mWorldViewProj;
3227  if (playerships[0].simulator)
3228  mWorldViewProj = matrixTemp * viewscreen->matrixView * viewscreen->matrixProjSim;
3229  else
3230  mWorldViewProj = matrixTemp * viewscreen->matrixLook * viewscreen->matrixProj;
3231  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
3232  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorld", &matrixTemp));
3233 
3234  for (short r = 0; r < buildzone1.components; r++)
3235  {
3236  const s_mesh_component mesh_component = buildzone1.componentarray[r];
3237  // skip the control tower in the Deois Port district when we are inside
3238  if (viewscreen->gameclass->GUI->player[ourcockpit.ourplyrC].bldg == 2 && buildzone1.type == PlotType::DeoisPort && mesh_component.type == 94)
3239  continue;
3240  // this is specifically for the domes at the township colonies
3241  if ((!drawTransparancy && (mesh_component.texture == 164 || mesh_component.type == 57)) ||
3242  (drawTransparancy && (mesh_component.texture != 164 && mesh_component.type != 57)))
3243  continue;
3244 
3245  if (oldtexture != mesh_component.texture)
3246  {
3247  oldtexture = mesh_component.texture;
3248 
3249  viewscreen->gameclass->graphics->g_pEffect->SetTexture("ColorMap", viewscreen->m_pddsCityTexture[oldtexture]);
3250  if (gridarray[actual.u][actual.v].powered)
3251  viewscreen->gameclass->graphics->g_pEffect->SetTexture("ColorMap2", viewscreen->m_pddsCityLights[oldtexture]);
3252  else
3253  viewscreen->gameclass->graphics->g_pEffect->SetTexture("ColorMap2", nullptr);
3254  }
3255 
3256  if (mesh_component.texture == 164 || mesh_component.type == 57) // transparency
3257  {
3258  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
3259  pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
3260  pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
3261  }
3262 
3263  if (mesh_component.type == 8) // algae fields
3264  {
3266 
3267  // we need the bias to be higher when the item is closer
3268  // so -0.001 when it is 0.5km, -0.00001 works great at like 1k+?
3269 
3270  //float bias = min(0.7f, max(0.2f, sortme[t].dist)); // 0.5km and 1km
3271  //bias = bias - 0.2f; // 0-0.5km
3272  //bias = bias / 0.5f; // 0-1 scalar
3273  //bias = 100.0f*(1.0f - bias); // 100-0 scalar
3274  //bias = (bias * -0.00001f) - 0.00001f;
3275 
3276 
3277  float bias = -0.00001f; // -0.001 works good but makes things further away look obviously sorted wrong
3278  pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS, *reinterpret_cast<DWORD*>(&bias));
3279  //float bias2 = 0.001f;
3280  //pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, *((DWORD*)&bias2));
3281  }
3282 
3283  if (fabs(temp.x) < 2 && fabs(temp.y) < 2)
3284  {
3285  V(viewscreen->gameclass->graphics->g_pEffect->BeginPass(2)); // close buildings
3286  }
3287  else
3288  {
3289  V(viewscreen->gameclass->graphics->g_pEffect->BeginPass(3)); // far buildings
3290  }
3291 
3292  if (mesh_component.type == 78) // guns
3293  {
3294  // tried WT WU WT on side
3295  // tried TW WU WT PERFECT!
3296 
3297  // Undo location
3298  D3DXMATRIX undomat;
3299  D3DXMatrixTranslation(&matTemp,
3300  mesh_component.nominalxyz.x + mesh_component.nominalCG.x,
3301  mesh_component.nominalxyz.y + mesh_component.nominalCG.y - 0.0034822f,
3302  mesh_component.nominalxyz.z + mesh_component.nominalCG.z);
3303  D3DXMatrixMultiply(&undomat, &matTemp, &buildzone1.matrixBase);
3304  D3DXMatrixInverse(&matTemp, nullptr, &undomat);
3305 
3306  // rotate
3307  D3DXMatrixRotationZ(&matrixWorld, sinf(static_cast<float>(*fTime)));
3308  matrixWorld = matTemp * matrixWorld;
3309  // redo location
3310  matrixWorld = matrixWorld * undomat;
3311  // apply view
3312  matrixWorld = matrixWorld * matrixTemp;
3313 
3314  if (playerships[0].simulator)
3315  mWorldViewProj = matrixWorld * viewscreen->matrixView * viewscreen->matrixProjSim;
3316  else
3317  mWorldViewProj = matrixWorld * viewscreen->matrixLook * viewscreen->matrixProj;
3318  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
3319  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorld", &matrixWorld));
3320  }
3321 
3322  // sprintf_s(msg, sizeof(msg), "Narrow down 2116" );
3323  // _write(logfile, msg, strlen(msg));
3324 
3325 
3326  V(pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, mesh_component.startvertex, mesh_component.primitives));
3327 
3328  V(viewscreen->gameclass->graphics->g_pEffect->EndPass());
3329 
3330  if (mesh_component.texture == 164 || mesh_component.type == 57) // transparency
3331  {
3332  V(pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false));
3333  }
3334 
3335  if (mesh_component.type == 78)
3336  {
3337  D3DXMATRIX mWorldViewProj1;
3338  if (playerships[0].simulator)
3339  mWorldViewProj1 = matrixTemp * viewscreen->matrixView * viewscreen->matrixProjSim;
3340  else
3341  mWorldViewProj1 = matrixTemp * viewscreen->matrixLook * viewscreen->matrixProj;
3342  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj1));
3343  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorld", &matrixTemp));
3344  }
3345 
3346  if (mesh_component.type == 8) // algae fields
3347  {
3348  V(pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS, 0));
3349  }
3350  }
3351  }
3352  else
3353  {
3354  sortme[t].dist = 99.9f; // to restrict lights later
3355  }
3356  }
3357  }
3358 
3359 
3360  // sprintf_s(msg, sizeof(msg), "Narrow down 2117" );
3361  // _write(logfile, msg, strlen(msg));
3362 
3363  //pd3dDevice->SetRenderState(D3DRS_STENCILREF, 4); // 4
3364 
3365  V(viewscreen->gameclass->graphics->g_pEffect->End());
3366 
3367  //D3DXVECTOR4 ambient;
3368  //ambient.x = viewscreen->alphascreen.r; ambient.y = viewscreen->alphascreen.g; ambient.z = viewscreen->alphascreen.b;
3369  //ambient.w = viewscreen->ptrWeather->fFogEndHorizon;
3370  //V(viewscreen->gameclass->graphics->g_pEffect->SetVector("ambient", &ambient));
3371 
3372  logger->AddToCallStack("renderer::RenderBuildings END");
3373 }
3374 
3375 void renderer::RenderShips(IDirect3DDevice9* pd3dDevice, const D3DXVECTOR3* Xsunlight)
3376 {
3377  logger->AddToCallStack("renderer::RenderShips");
3378 
3379  D3DXVECTOR3 result;
3380  D3DXVECTOR3 vieneohit;
3381 
3382  V(viewscreen->gameclass->graphics->g_pEffect->Begin(NULL, 0));
3383 
3384  for (t = 1; t < MAX_SCAN; t++) // ships loop
3385  {
3386  // DIHV animation
3387  if (g_bAboveClouds && playerships[t].type == VehicleType::DIHV && dihvanimate > -1 && dihvanimate < 64)
3388  {
3389  pd3dDevice->SetFVF(D3DFVF_NOPSIZE);
3390 
3391  // at 100km it is 256... closer than that we all die
3392  float f_temp = 256.0f*233.0f / playerships[t].distance;
3393  if (f_temp > 256.0f)
3394  f_temp = 256.0f;
3395 
3396  pd3dDevice->SetRenderState(D3DRS_POINTSIZE, *reinterpret_cast<DWORD*>(&f_temp));
3397 
3398  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
3399  pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
3400  pd3dDevice->SetRenderState(D3DRS_LIGHTING, false);
3401  pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
3402  pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false); // so it doesn't block sun flare
3403 
3404  pd3dDevice->SetTransform(D3DTS_WORLD, &playerships[t].matrixWorld);
3405  pd3dDevice->SetStreamSource(0, viewscreen->m_avRunningLights, 0, sizeof(D3DNOPSIZE));
3406  pd3dDevice->SetTexture(0, viewscreen->m_pddsDIHV[dihvanimate]);
3407 
3408  pd3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, 1);
3409 
3410  pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
3411  pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS);
3412  pd3dDevice->SetRenderState(D3DRS_LIGHTING, true);
3413  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
3414  pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
3415 
3416  pd3dDevice->SetFVF(D3DFVF_VERTEX);
3417  }
3418 
3419  if (!playerships[t].drawflag) continue;
3420  if (playerships[t].cloaking == 0.0f) continue;
3421 
3422  D3DXVECTOR4 features;
3423  features.x = playerships[t].cloaking;
3424  features.y = 0.0f; // unused
3425  features.z = 0.0f; // unused
3426  features.w = 0.0f; //g_bNightVision?1.0f:0.0f;
3427  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("Features", &features));
3428 
3429  if (g_bAboveClouds)
3430  {
3431  // Adjust diffuse by shadow
3432  D3DXVECTOR4 Sunlight;
3433  Sunlight.x = -viewscreen->sunlight.Direction.x; Sunlight.y = -viewscreen->sunlight.Direction.y; Sunlight.z = -viewscreen->sunlight.Direction.z;
3434  Sunlight.w = viewscreen->ptrWeather->shadow;
3435  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("Sunlight", &Sunlight));
3436  }
3437  else
3438  {
3439  D3DXVECTOR4 temp4;
3440  temp4.x = viewscreen->alphascreen.r;
3441  temp4.y = viewscreen->alphascreen.g;
3442  temp4.z = viewscreen->alphascreen.b;
3443  temp4.w = viewscreen->ptrWeather->fFogEndHorizon;
3444  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("ambient", &temp4));
3445  }
3446 
3447  const D3DXCOLOR trimcolor = playerships[t].trimcolor;
3448  D3DXVECTOR4 trimvec = D3DXVECTOR4(trimcolor.r, trimcolor.g, trimcolor.b, 0); // w unused
3449  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("Tangent", &trimvec));
3450 
3451  if (playerships[t].distance < (playerships[t].bound*1000.0f))
3452  {
3453  if (g_bAboveClouds) // if we are above clouds
3454  {
3455  D3DXVECTOR4 radiosity = D3DXVECTOR4(0, 0, 0, 0);
3456  // Block light from sun by Vieneo
3457  if (viewscreen->ptrWeather->shadow > 0.0f)
3458  {
3459  // radiosity
3460  D3DXVec3Scale(&vieneohit, Xsunlight, radiusC); // Where it hits Vieneo
3461  D3DXVec3Subtract(&result, &playerships[t].position, &vieneohit); // Vector from surface point to this object
3462  D3DXVec3Normalize(&result, &result);
3463  radiosity.x = result.x; radiosity.y = result.y; radiosity.z = result.z;
3464  radiosity.w = fabsf(D3DXVec3Dot(&result, Xsunlight)); // cos of angle between the two
3465  radiosity.w = 1.0f - radiosity.w; // Compliment, not comparing to surface normal ya know
3466  radiosity.w /= powf(D3DXVec3Length(&playerships[t].position) / radiusC, 2.0f);
3467  }
3468  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("Radiosity", &radiosity));
3469 
3470  V(viewscreen->gameclass->graphics->g_pEffect->BeginPass(5)); // above cloud vehicles
3471  }
3472  else // below clouds
3473  {
3474  V(viewscreen->gameclass->graphics->g_pEffect->BeginPass(4)); // below cloud vehicles
3475  }
3476 
3477  V(pd3dDevice->SetStreamSource(0, polyobjects[playerships[t].VB].VB, 0, sizeof(D3DVERTEX)));
3478 
3480  {
3481  V(viewscreen->gameclass->graphics->g_pEffect->SetTexture("AlphaMap", viewscreen->m_pddsHullDynamicTexture[t]));
3482  }
3483 
3484  short oldtexture = -1;
3485  for (s = 0; s < playerships[t].components; s++)
3486  {
3487  if (playerships[t].componentarray[s].visible)
3488  {
3489  D3DXMATRIX mWorldViewProj;
3490  if (playerships[0].simulator)
3492  else
3494  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorldViewProj", &mWorldViewProj));
3495  V(viewscreen->gameclass->graphics->g_pEffect->SetMatrix("matWorld", &playerships[t].componentarray[s].matWorld));
3496 
3497 
3498  // Texture assignment
3499  if (oldtexture != playerships[t].componentarray[s].texture)
3500  {
3501  oldtexture = playerships[t].componentarray[s].texture;
3502 
3503  V(viewscreen->gameclass->graphics->g_pEffect->SetTexture("ColorMap", viewscreen->m_pddsShipTexture[oldtexture]));
3504 
3505  if (viewscreen->m_pddsShipLights[oldtexture])
3506  {
3507  V(viewscreen->gameclass->graphics->g_pEffect->SetTexture("ColorMap2", viewscreen->m_pddsShipLights[oldtexture]));
3508  }
3509  }
3510 
3511 
3512  bool showlight;
3513  if (playerships[t].componentarray[s].type == 31) // cockpit interior viewed from outside
3514  showlight = playerships[t].domelight && playerships[t].logolight;
3515  else if (playerships[t].componentarray[s].type == 43) // headlights
3516  showlight = playerships[t].headlight && playerships[t].logolight;
3517  else if (playerships[t].componentarray[s].type == 44) // brakelights
3518  showlight = playerships[t].brakelight && playerships[t].logolight;
3519  else
3520  showlight = playerships[t].logolight;
3521 
3522  // display control
3523  D3DXVECTOR4 clouduv;
3524  clouduv.x = 0.0f; // unused/reserved in makeship
3525  if (viewscreen->m_pddsShipLights[oldtexture] && showlight && playerships[t].componentarray[s].useLightMap)
3526  clouduv.y = 1.0f;
3527  else
3528  clouduv.y = 0.0f;
3529  if (playerships[t].componentarray[s].type == 4) // monitor on floating man's arm
3530  clouduv.z = viewscreen->flicker ? 0.9f : 1.0f;
3531  else
3532  clouduv.z = playerships[t].componentarray[s].speedRetract;
3533  clouduv.w = playerships[t].componentarray[s].type;
3534  V(viewscreen->gameclass->graphics->g_pEffect->SetVector("clouduv", &clouduv));
3535 
3536  V(viewscreen->gameclass->graphics->g_pEffect->CommitChanges());
3537 
3538  V(pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, playerships[t].componentarray[s].startvertex, playerships[t].componentarray[s].primitives));
3539  }
3540  }
3541 
3542  V(viewscreen->gameclass->graphics->g_pEffect->EndPass());
3543 
3544  } // End of distance<bound and cloaking>0.0f
3545  } // End of ships loop
3546 
3547  V(viewscreen->gameclass->graphics->g_pEffect->End());
3548 
3549  logger->AddToCallStack("renderer::RenderShips DONE");
3550 }
3551 
3552 void renderer::RenderLights(IDirect3DDevice9* pd3dDevice, const double* f_time)
3553 {
3554  logger->AddToCallStack("renderer::RenderLights");
3555 
3556  float f_temp;
3557  D3DXVECTOR3 result;
3558  D3DXMATRIX matrixTemp;
3559 
3560  // Should be able to make a userVB to store all the lights and distant objects (farspher)
3561 
3562 
3563 
3564  // START OF RUNNING LIGHTS SECTION
3565 
3566  pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
3567  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
3568  pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
3569  pd3dDevice->SetRenderState(D3DRS_LIGHTING, false);
3570  pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false);
3571 
3572  pd3dDevice->SetFVF(D3DFVF_NOPSIZE);
3573  pd3dDevice->SetStreamSource(0, viewscreen->m_avRunningLights, 0, sizeof(D3DNOPSIZE));
3574 
3575  pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
3576  pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
3577  pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
3578 
3579  pd3dDevice->SetTexture(0, viewscreen->m_pddsStarTexture);
3580  pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
3581  //pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
3582  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
3583  //pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
3584 
3585 
3586  for (t = 1; t < MAX_SCAN; t++) // ships loop, not including us
3587  {
3588  if (!playerships[t].drawflag) continue;
3589 
3590  D3DXVECTOR3 look = playerships[t].position - playerships[0].position;
3591  const float dist = D3DXVec3Length(&look);
3592  float alphafog;
3593  if (f_MSL < 63.0f)
3594  {
3595  alphafog = Clamp((viewscreen->ptrWeather->fFogEndHorizon - dist * 0.5f) / (viewscreen->ptrWeather->fFogEndHorizon), 0, 1);
3596  if (alphafog == 0.0f) continue;
3597  }
3598  else
3599  alphafog = 1.0f;
3600 
3601  // normalize
3602  look /= dist;
3603 
3604  D3DXVECTOR3 theirnorm;
3605  float psize;
3606 
3607  pd3dDevice->SetTransform(D3DTS_WORLD, &playerships[t].matrixWorld);
3608 
3609  if (playerships[t].distance >= (playerships[t].bound*1000.0f)) // 38km
3610  {
3611  if (playerships[t].distance < (playerships[t].bound*10000.0f)) // 380km
3612  {
3613  // Light level should be based on line from (ourpos-theirpos) (dot) xsunlight
3614  // make a black spec, it still shows against white backdrop
3615  // dim as they get further away
3616  const float shadow = viewscreen->ptrWeather->shadow * (1.0f - playerships[t].distance / (playerships[t].bound*10000.0f));
3617 
3618  if (g_bAboveClouds)
3619  tempcolor.r = tempcolor.g = tempcolor.b = shadow;
3620  else
3621  tempcolor = viewscreen->sunlight.Diffuse;
3622  tempcolor.a = alphafog;
3623 
3624  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
3625  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
3626  pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
3627  pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, tempcolor);
3628  // psize=1.0f;
3629  pd3dDevice->SetRenderState(D3DRS_POINTSIZE, 1);//*((DWORD*)&psize) );
3630 
3631  pd3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, 1);
3632 
3633  pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false);
3634  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
3635  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); // texture
3636  }
3637  }
3638  else if (playerships[t].logolight) // for running lights
3639  {
3640  float bonehead = 64.0f / powf(playerships[t].distance, 0.75f) * viewscreen->gameclass->displayscale * D3DXToRadian(115.0f) / g_fFOV;
3641  f_temp = playerships[t].bound / 0.034726f;
3642  if (f_temp > 2.0f)
3643  f_temp = 2.0f; // limit size, DIHV looked silly
3644  bonehead *= f_temp;
3645 
3646 
3647  for (s = 0; s < static_cast<short>(polyobjects[playerships[t].VB].effects.size()); s++)
3648  {
3649  bool skip = false;
3651  if (effect.power == 1.5f) // rotating light
3652  {
3653  if (playerships[t].type == VehicleType::P13)
3654  {
3655  if (!playerships[t].police || !playerships[t].specialight)
3656  skip = true;
3657  }
3658  if (!skip)
3659  {
3660  result.x = -1.0f; result.y = 0.0f; result.z = 0.0f; // nose
3661  D3DXMatrixRotationAxis(&matrixTemp,
3662  &effect.normal,
3663  D3DX_TAU*fmodf(static_cast<float>(*f_time)*50.0f, effect.speed) / effect.speed);
3664  D3DXVec3TransformNormal(&result, &result, &matrixTemp);
3665  }
3666  }
3667  else
3668  result = effect.normal;
3669 
3670  if (!skip)
3671  {
3672  effect.diffuse.r *= alphafog;
3673  effect.diffuse.g *= alphafog;
3674  effect.diffuse.b *= alphafog;
3675  effect.diffuse.a = alphafog;
3676  pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, effect.diffuse);
3677 
3678  D3DXVec3TransformNormal(&theirnorm, &result, &playerships[t].matrixWorld);
3679  D3DXVec3Normalize(&theirnorm, &theirnorm);
3680  f_temp = D3DXVec3Dot(&theirnorm, &look);
3681  if (f_temp < 0.0f)
3682  f_temp = 0.0f;
3683  psize = bonehead;
3684 
3685  if (effect.power == 1.0f) // bulb
3686  psize *= f_temp;
3687  else if (effect.power == 0.5f || // strobe
3688  effect.power == 1.5f) // rotating
3689  {
3690  if (f_temp > 0.0f)
3691  psize *= f_temp * 2.0f;
3692  else
3693  skip = true;
3694  }
3695  else if (effect.power == 2.0f) // beam
3696  psize *= 4.0f*powf(f_temp, 8.0f);
3697 
3698  // fluctuate based on distance
3699  // psize=256, 0/anything is 0, psize*=1
3700  // psize=4, .988 times 0 to 1 is 0 to .988, psize*= 1.0f to 0.12f
3701  float tempfloat = playerships[t].distance / (playerships[t].bound*1000.0f);
3702  tempfloat = 1.0f - (tempfloat*0.5f) + tempfloat * RandomFloat();
3703  psize *= tempfloat;
3704 
3705  if (psize > 256.0f)
3706  psize = 256.0f;
3707 
3708  }
3709  if (psize >= 4.0f && !skip)
3710  {
3711  if (effect.power == 2.0f) // landing light
3712  {
3713  if (playerships[t].headlight)
3714  {
3715  pd3dDevice->SetRenderState(D3DRS_POINTSIZE, *reinterpret_cast<DWORD*>(&psize));
3716  pd3dDevice->DrawPrimitive(D3DPT_POINTLIST, effect.primitive, 1);
3717  }
3718  }
3719  else if (effect.sequencing & playerships[t].compare)
3720  {
3721  pd3dDevice->SetRenderState(D3DRS_POINTSIZE, *reinterpret_cast<DWORD*>(&psize));
3722  pd3dDevice->DrawPrimitive(D3DPT_POINTLIST, effect.primitive, 1);
3723  }
3724  }
3725 
3726  /*
3727  const float density = viewscreen->ptrPropulsion->staticDensity * playerships[t].cloaking;
3728  if (playerships[t].headlight && playerships[t].logolight && density > 0.005f)
3729  {
3730  //pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false);
3731  //pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
3732  //pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
3733  //pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
3734 
3736  //const float amblevel = powf(1.0f - viewscreen->sunlight.Diffuse.a, 2.0f); // diffuse is 1.0 at high noon
3737  //pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); // texture*tfactor
3738  //pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); // set the tfactor
3739  //pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); // set the tfactor
3740  //pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); // tfactor
3741  //pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR); // the color
3742 
3743  pd3dDevice->SetFVF(D3DFVF_SKYDOME);
3744  pd3dDevice->SetStreamSource(0, viewscreen->m_avCone, 0, sizeof(D3DSKYDOME));
3745  pd3dDevice->SetTexture(0, nullptr);
3746  //pd3dDevice->SetRenderState(D3DRS_LIGHTING, false);
3747 
3748  // headlights - will need to be based on ship type
3749  for (s = 0; s < polyobjects[playerships[t].VB].effects.size(); s++)
3750  {
3751  if (polyobjects[playerships[t].VB].effects[s].power == 2.0f) // headlight beam
3752  {
3753  tempcolor = polyobjects[playerships[t].VB].effects[s].diffuse;
3754  tempcolor.a = 0.5f;// amblevel;
3755  pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, tempcolor);
3757  // result.x=0.0f; result.y=0.0f; result.z=1.0f;
3758  // D3DXMatrixLookAtLH(&matrixTemp, &polyobjects[playerships[t].VB].effect[s].position, &polyobjects[playerships[t].VB].effect[s].normal, &result );
3759  // D3DXMatrixInverse(&matrixTemp, NULL, &matrixTemp);
3760  D3DXMATRIX matrixTemp;
3761  D3DXMatrixIdentity(&matrixTemp);
3762  matrixTemp._41 += polyobjects[playerships[t].VB].effects[s].position.x;
3763  matrixTemp._42 += polyobjects[playerships[t].VB].effects[s].position.y;
3764  matrixTemp._43 += polyobjects[playerships[t].VB].effects[s].position.z;
3765  D3DXMATRIX matRotate;
3766  D3DXMatrixRotationZ(&matRotate, -D3DX_HALFPI);
3767  D3DXMatrixMultiply(&matrixTemp, &matRotate, &matrixTemp);
3768  D3DXMatrixMultiply(&matrixTemp, &matrixTemp, &playerships[t].matrixWorld);
3769  pd3dDevice->SetTransform(D3DTS_WORLD, &matrixTemp);
3770  pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 72);
3772  // D3DXMatrixRotationZ( &matrixTemp, -D3DX_PI*0.5f );
3773  // matrixTemp._41-=42.0f*0.0003f; matrixTemp._42+=4.5f*0.0003f; matrixTemp._43-=0.75f*0.0003f;
3774  // D3DXMatrixMultiply( &matrixTemp, &matrixTemp, &playerships[t].matrixWorld );
3775  // pd3dDevice->SetTransform( D3DTS_WORLD, &matrixTemp );
3776  // pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 72 );
3777  }
3778  }
3779 
3780  //pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
3781  //pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
3783  //pd3dDevice->SetRenderState(D3DRS_LIGHTING, true);
3784  //pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
3785  //pd3dDevice->SetFVF(D3DFVF_VERTEX);
3787  //pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
3788  pd3dDevice->SetFVF(D3DFVF_NOPSIZE);
3789  pd3dDevice->SetStreamSource(0, viewscreen->m_avRunningLights, 0, sizeof(D3DNOPSIZE));
3790  pd3dDevice->SetTexture(0, viewscreen->m_pddsStarTexture);
3791  }
3792  */
3793  }
3794  }
3795  }
3796 
3797 
3798  if (g_bAboveClouds)
3799  {
3800  // docks
3801  for (t = 0; t < maxdockC; t++) // matrices for docks
3802  {
3803  if (allobjects[t].distance < (allobjects[t].bound*1000.0f))
3804  {
3805  if (allobjects[t].powered)
3806  {
3807  // should get darker and smaller further away and brighter outside
3808  f_temp = 64.0f / powf(allobjects[t].distance, 0.75f);
3809  if (f_temp > 256.0f)
3810  f_temp = 256.0f;
3811  pd3dDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&f_temp));
3812  // pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );
3813  // pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
3814  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
3815 
3816  for (s = 0; s < (short)polyobjects[1].effects.size(); s++)
3817  {
3818  if (polyobjects[1].effects.at(s).sequencing & allobjects[t].compare)
3819  {
3820  matrixTemp = allobjects[t].matrixWorld;
3821  matrixTemp._41 += polyobjects[1].effects.at(s).position.x;
3822  matrixTemp._42 += polyobjects[1].effects.at(s).position.y;
3823  matrixTemp._43 += polyobjects[1].effects.at(s).position.z;
3824  pd3dDevice->SetTransform(D3DTS_WORLD, &matrixTemp);
3825  pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, polyobjects[1].effects.at(s).diffuse);
3826  pd3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, 1);
3827  }
3828  }
3829  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
3830  // pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
3831  // pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
3832  }
3833  }
3834  else
3835  {
3836  pd3dDevice->SetTransform(D3DTS_WORLD, &allobjects[t].matrixWorld);
3837  D3DXVECTOR3 look = allobjects[t].position - playerships[0].position;
3838  D3DXVec3Normalize(&look, &look);
3839 
3841 
3842  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
3843  pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
3844  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
3845  pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, tempcolor);
3846  float psize = 16.0f;
3847  pd3dDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
3848 
3849  pd3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, 1);
3850 
3851  pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false);
3852  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); // texture
3853  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
3854  }
3855  }
3856  }
3857  else
3858  {
3859  // pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
3860  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
3861 
3862  for (t = 0; t < buildingVBC; t++) // go through all build zones, only draw ones that are visible
3863  {
3864  BUILDZONE buildzone1 = buildzone[sortme[t].buildzone];
3865  //if (sortedBuilding.dist < 46.0f) // this includes even the gridvisible and patch data thanks to rndrctys.cpp
3866  {
3867  for (size_t r = 0; r < buildzone1.effects.size(); r++)
3868  {
3869  s_light_effect effect = buildzone1.effects.at(r);
3870  if (effect.sequencing & citystuff.compare[buildzone1.type])
3871  {
3872  D3DXVECTOR3 diff = playerships[0].position + effect.position;
3873  const float dist = D3DXVec3Length(&diff);
3874  const float alphafog = Clamp((viewscreen->ptrWeather->fFogEndHorizon - dist * 0.5f) / viewscreen->ptrWeather->fFogEndHorizon, 0, 1);
3875  if (alphafog == 0.0f) continue;
3876 
3877  // we used to use precision position but the little offset makes the lights look more realistic, flickery
3878  D3DXMatrixTranslation(&matrixTemp, diff.x, diff.y, diff.z);
3879  pd3dDevice->SetTransform(D3DTS_WORLD, &matrixTemp);
3880 
3881  const float psize = 64.0f / powf(dist, 0.75f) * viewscreen->gameclass->displayscale * D3DXToRadian(115.0f) / g_fFOV;
3882 
3883  effect.diffuse.r *= alphafog;
3884  effect.diffuse.g *= alphafog;
3885  effect.diffuse.b *= alphafog;
3886  pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, effect.diffuse);
3887 
3888  if (effect.power == 1.5f) // rotating light
3889  {
3890  D3DXVec3Normalize(&result, &buildzone1.terpos); // plumb
3891  // result.x=-1.0f; result.y=0.0f; result.z=0.0f; // nose
3892  D3DXMatrixRotationAxis(&matrixTemp,
3893  &result,
3894  D3DX_TAU*fmodf(static_cast<float>(*f_time), 8.888f) / 8.888f); // rotating beacon is only one
3895  D3DXVec3TransformNormal(&result, &effect.normal, &matrixTemp);
3896  }
3897  else
3898  result = effect.normal;
3899 
3900 
3901 
3902 
3903  diff /= dist; // normalize
3904  f_temp = -D3DXVec3Dot(&result, &diff);
3905  if (effect.power != 1.5f)
3906  f_temp += 0.5f; // should be able to see from ground level 30�
3907  if (f_temp < 0.0f)
3908  f_temp = 0.0f;
3909  else if (f_temp > 1.0f)
3910  f_temp = 1.0f;
3911 
3912  if (effect.power == 1.0f) // bulb
3913  f_temp = psize * f_temp;
3914  else if (effect.power == 0.5f) // strobe
3915  {
3916  if (f_temp > 0.0f)
3917  f_temp = psize * 2.0f; // all directions
3918  }
3919  else if (effect.power == 1.5f) // rotating
3920  {
3921  if (f_temp > 0.0f)
3922  f_temp = psize * 4.0f*powf(f_temp, 16.0f);
3923  }
3924  else if (effect.power == 2.0f) // beam
3925  f_temp = psize * 4.0f*powf(f_temp, 8.0f);
3926 
3927  if (f_temp > 0.0f)
3928  {
3929  if (f_temp > 256.0f)
3930  f_temp = 256.0f;
3931  // Tried just casting float to DWORD but didn't work
3932  pd3dDevice->SetRenderState(D3DRS_POINTSIZE, *reinterpret_cast<DWORD*>(&f_temp));
3933  pd3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, 1);
3934  }
3935  }
3936  }
3937  }
3938  }
3939  }
3940 
3941 
3942  /*
3943  // set it as a dot
3944  float f_temp2=1.0f;
3945  pd3dDevice->SetRenderState( D3DRS_POINTSIZE, *((DWORD*)&f_temp2) );
3946  pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
3947 
3948  for (t=1; t<maxshipC; t++) // ships loop
3949  {
3950  if (playerships[t].online && playerships[t].active &&
3951  playerships[t].distance<(playerships[t].bound*1000.0f))
3952  {
3953 
3954  pd3dDevice->SetTransform( D3DTS_WORLD, &playerships[t].matrixWorld );
3955 
3956  if (playerships[t].distance>(playerships[t].bound*210.5f)) // 8km
3957  exclude=true;
3958  else
3959  exclude=false;
3960 
3961  // for (s=0; s<polyobjects[playerships[t].VB].number_of_effects; s++)
3962  s=0;
3963  {
3964  if ( polyobjects[playerships[t].VB].effect[s].sequencing & playerships[t].compare )
3965  {
3966  if (!exclude && m_bDeviceSupportsVizQuery) // ifcap set query
3967  m_pLightActualVizQuery[t]->Issue( D3DISSUE_BEGIN );
3968 
3969  // draw the point
3970  pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, polyobjects[playerships[t].VB].effect[s].primitive, 1 );
3971 
3972  if (!exclude && m_bDeviceSupportsVizQuery) // ifcap end query
3973  m_pLightActualVizQuery[t]->Issue( D3DISSUE_END );
3974  }
3975  }
3976  }
3977  }
3978  */
3979 
3980  // pd3dDevice->SetRenderState( D3DRS_DEPTHBIAS, 0 );
3981 
3982 
3983  // pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DISABLE );
3984  pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS);
3985  pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
3986  pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
3987  // pd3dDevice->SetRenderState( D3DRS_LIGHTING, true ); // return with it off
3988  pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); // hull texture
3989  pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); // hull texture
3990  pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE); // hull texture
3991  // END OF RUNNING LIGHTS SECTION
3992 
3993  logger->AddToCallStack("renderer::RenderLights END");
3994 }
#define radiusC
Definition: globals.h:88
void CalculateCubeAndTcp()
Definition: grid.cpp:79
D3DXVECTOR3 position
Definition: globals.h:354
InputConfig inputConfigLeftToeBrake
Definition: config.h:35
D3DXMATRIX matWorld
Definition: globals.h:428
short s
Definition: renderer.h:43
#define firework3C
Definition: globals.h:51
#define firework1C
Definition: globals.h:49
Ssorter sortme[buildingVBC]
Definition: globals.cpp:166
bool forceFeedback
Definition: InputConfig.h:16
Scockpit ourcockpit
Definition: globals.cpp:176
D3DLIGHT9 sunlight
Definition: Viewscreen.h:217
LPDIRECT3DTEXTURE9 m_pddsWeapon[weaponanimateC]
Definition: Viewscreen.h:136
bool powered
Definition: globals.h:297
VECTOR2SHORT tcp
Definition: grid.h:34
s_mesh_component * componentarray
Definition: globals.h:497
ID3DXEffect * g_pEffect
Definition: Graphics.h:30
#define heartanimateC
Definition: globals.h:53
unsigned char primitive
Definition: globals.h:353
LPDIRECT3DTEXTURE9 m_pddsTransition[transitiontextureC]
Definition: Viewscreen.h:192
LPD3DXFONT m_pFont
Definition: Viewscreen.h:46
short oldDockTexture
Definition: Viewscreen.h:268
short dihvanimate
Definition: globals.cpp:71
#define transitiontextureC
Definition: globals.h:37
Config config
Definition: GameClass.h:102
#define landformtextureC
Definition: globals.h:36
bool g_bAboveClouds
Definition: globals.cpp:22
LPDIRECT3DTEXTURE9 m_pddsCityTexture[citytextureC]
Definition: Viewscreen.h:188
D3DXVECTOR3 position
Definition: globals.h:549
LPDIRECT3DTEXTURE9 m_pddsFirework1[firework1C]
Definition: Viewscreen.h:141
void RenderShips(IDirect3DDevice9 *pd3dDevice, const D3DXVECTOR3 *Xsunlight)
Definition: renderer.cpp:3375
Logger * logger
Definition: renderer.h:38
LPDIRECT3DTEXTURE9 m_pddsDockTexture[docktextureC]
Definition: Viewscreen.h:184
#define citytextureC
Definition: globals.h:42
GameClass * gameclass
Definition: Viewscreen.h:292
unsigned char type
Definition: globals.h:406
LPDIRECT3DTEXTURE9 m_pddsSinker[weaponanimateC]
Definition: Viewscreen.h:137
LPDIRECT3DTEXTURE9 m_pddsWorld2a1
Definition: Viewscreen.h:124
D3DXMATRIX matrixLook
Definition: Viewscreen.h:220
LPDIRECT3DTEXTURE9 m_pddsIntersection
Definition: Viewscreen.h:198
void RenderDocks(IDirect3DDevice9 *pd3dDevice, const D3DXVECTOR3 *Xsunlight)
Definition: renderer.cpp:2890
LPDIRECT3DTEXTURE9 m_pddsCloudBaseMap
Definition: Viewscreen.h:125
D3DXVECTOR3 terpos
Definition: globals.h:449
LPDIRECT3DTEXTURE9 m_pddsHolidayTexture
Definition: Viewscreen.h:134
LPDIRECT3DTEXTURE9 m_pddsCityLights[citytextureC]
Definition: Viewscreen.h:189
#define dockvertC
Definition: globals.h:58
unsigned long compare
Definition: globals.h:505
double precisiony
Definition: globals.h:550
short v
Definition: globals.h:451
s_network_objects playerships[MAX_SCAN]
Definition: globals.cpp:174
float speedRetract
Definition: globals.h:412
LPDIRECT3DTEXTURE9 m_pddsWaterNormal
Definition: Viewscreen.h:193
#define shiptextureC
Definition: globals.h:38
D3DXCOLOR alphascreen
Definition: Viewscreen.h:231
float g_fFOV
Definition: globals.cpp:129
#define dihvanimateC
Definition: globals.h:52
D3DXMATRIX matrixBase
Definition: globals.h:450
LPDIRECT3DTEXTURE9 m_pddsSunglasses
Definition: Viewscreen.h:131
InputConfig inputConfigGas
Definition: config.h:33
std::vector< s_light_effect > effects
Definition: globals.h:447
float extended
Definition: globals.h:427
short u
Definition: renderer.h:32
bool m_bDeviceSupportsVizQuery
Definition: Viewscreen.h:224
LPD3DXSPRITE m_spriteVector
Definition: Viewscreen.h:214
InputConfig inputConfigRoll
Definition: config.h:27
s_city_stuff citystuff
Definition: globals.cpp:172
LPDIRECT3DTEXTURE9 m_pddsMarston1
Definition: Viewscreen.h:195
D3DXMATRIX matrixProj
Definition: Viewscreen.h:219
LPDIRECT3DTEXTURE9 m_pddsLightningAbove[3]
Definition: Viewscreen.h:177
LPDIRECT3DVERTEXBUFFER9 VB
Definition: globals.h:366
#define weaponanimateC
Definition: globals.h:44
weather * ptrWeather
Definition: Viewscreen.h:287
D3DXVECTOR3 nominalCG
Definition: globals.h:419
LPDIRECT3DVOLUMETEXTURE9 m_pddsReentry
Definition: Viewscreen.h:150
LPDIRECT3DTEXTURE9 m_pddsRunwayEdgeLight1
Definition: Viewscreen.h:196
std::vector< s_light_effect > effects
Definition: globals.h:367
LPDIRECT3DTEXTURE9 m_pddsFirework2[firework2C]
Definition: Viewscreen.h:142
LPDIRECT3DTEXTURE9 m_pddsElmo[elmoAnimateC]
Definition: Viewscreen.h:144
InputConfig inputConfigThrustLeft
Definition: config.h:29
unsigned long sequencing
Definition: globals.h:356
InputConfig inputConfigThrustRight
Definition: config.h:30
D3DXVECTOR3 nominalypr
Definition: globals.h:417
float fFogEndHorizon
Definition: weather.h:74
char msg[199]
Definition: renderer.h:40
s_mesh_component * componentarray
Definition: globals.h:578
bool g_bEnabled
Definition: globals.cpp:149
bool useLightMap
Definition: globals.h:411
short polygons
Definition: globals.h:365
#define cutplaneC
Definition: globals.h:19
LPDIRECT3DTEXTURE9 m_pddsLandform[landformtextureC]
Definition: Viewscreen.h:191
LPDIRECT3DTEXTURE9 m_pddsCloudDetailBelow
Definition: Viewscreen.h:127
s_universe_object allobjects[maxstarC]
Definition: globals.cpp:170
s_mesh_component * componentarray
Definition: globals.h:457
LPDIRECT3DTEXTURE9 m_pddsDockLights[docktextureC]
Definition: Viewscreen.h:185
D3DXCOLOR diffuse
Definition: globals.h:355
short v
Definition: renderer.h:32
D3DXMATRIX matrixWorld
Definition: globals.h:491
short attachto
Definition: globals.h:358
void RenderLights(IDirect3DDevice9 *pd3dDevice, const double *fTime)
Definition: renderer.cpp:3552
#define elmoAnimateC
Definition: globals.h:45
short dockTextureStage
Definition: Viewscreen.h:268
LPDIRECT3DVOLUMETEXTURE9 m_pddsFuzerX
Definition: Viewscreen.h:138
float f_MSL
Definition: globals.cpp:36
static float timepassed
Definition: renderer.h:46
short dockTexture
Definition: Viewscreen.h:268
SPlayerData player[MAX_ONLINEPLAYERS]
Definition: gui.h:765
float Clamp(float val, float min, float max)
Definition: MathUtilities.h:3
D3DXVECTOR3 nominalxyz
Definition: globals.h:416
#define docktextureC
Definition: globals.h:40
InputConfig inputConfigPitch
Definition: config.h:26
LPDIRECT3DTEXTURE9 m_pddsLetters
Definition: Viewscreen.h:174
D3DXVECTOR2 temp
Definition: renderer.h:34
unsigned long compare[PlotType::PlotTypeEnum]
Definition: globals.h:523
renderer(Viewscreen *ptr)
Definition: renderer.cpp:13
D3DXMATRIX matrixProjSim
Definition: Viewscreen.h:219
BUILDZONE buildzone[buildingVBC]
Definition: globals.cpp:165
LPDIRECT3DTEXTURE9 m_pddsSunTexture
Definition: Viewscreen.h:132
InputConfig inputConfigBrake
Definition: config.h:34
LPDIRECT3DVOLUMETEXTURE9 m_pddsSinkerX
Definition: Viewscreen.h:139
short t
Definition: renderer.h:43
LPDIRECT3DTEXTURE9 m_pddsShipLights[shiptextureC]
Definition: Viewscreen.h:183
Graphics * graphics
Definition: GameClass.h:109
void RenderBuildings(IDirect3DDevice9 *pd3dDevice, double *fTime, bool drawTransparancy)
Definition: renderer.cpp:3145
short buildzone
Definition: globals.h:467
#define RTStextureC
Definition: globals.h:43
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition: Logger.cpp:11
grid * ptrGrid
Definition: Viewscreen.h:279
unsigned long compare
Definition: globals.h:552
s_polygon_object polyobjects[maxpolyC]
Definition: globals.cpp:160
const GUID MYGUID_NULL
Definition: Guids.h:3
short vertices
Definition: globals.h:365
short r
Definition: renderer.h:43
InputConfig inputConfigRightToeBrake
Definition: config.h:36
LPDIRECT3DTEXTURE9 m_pddsBinoculars
Definition: Viewscreen.h:128
#define firework2C
Definition: globals.h:50
PlotType type
Definition: globals.h:452
LPDIRECT3DTEXTURE9 m_pddsShipTexture[shiptextureC]
Definition: Viewscreen.h:182
LPDIRECT3DTEXTURE9 m_pddsBinocularsCompass
Definition: Viewscreen.h:129
bool m_bPsize
Definition: Viewscreen.h:224
#define maxdockC
Definition: globals.h:25
#define buildingVBC
Definition: globals.h:54
Viewscreen * viewscreen
Definition: renderer.h:37
float emissive
Definition: globals.h:453
LPDIRECT3DVOLUMETEXTURE9 m_pddsBlastX
Definition: Viewscreen.h:140
D3DXMATRIX matrixView
Definition: Viewscreen.h:220
bool dataReady
Definition: grid.h:29
LPDIRECT3DTEXTURE9 m_pddsAtmosphere
Definition: Viewscreen.h:178
LPDIRECT3DTEXTURE9 m_pddsRoad
Definition: Viewscreen.h:197
HMI * GUI
Definition: GameClass.h:110
short ourplyrC
Definition: globals.h:659
void RequestWholeGrid()
Definition: grid.cpp:145
UINT startvertex
Definition: globals.h:408
float power
Definition: globals.h:357
float speed
Definition: globals.h:357
void AddTrackedResource(const char *name, _D3DPOOL pool=D3DPOOL_MANAGED)
Definition: GameClass.cpp:2702
unsigned short components
Definition: globals.h:496
LOCALGRID2 gridarray[64][64]
Definition: globals.cpp:153
LPDIRECT3DTEXTURE9 m_pddsCloudDetailAbove
Definition: Viewscreen.h:126
float displayscale
Definition: GameClass.h:128
LPDIRECT3DVERTEXBUFFER9 VB
Definition: globals.h:444
LPDIRECT3DTEXTURE9 m_pddsRTSTexture[RTStextureC]
Definition: Viewscreen.h:186
LPDIRECT3DTEXTURE9 m_pddsLightningBelow[3]
Definition: Viewscreen.h:176
float shadow
Definition: weather.h:80
#define D3DFVF_VERTEX
Definition: globals.h:101
D3DXMATRIX matGridRot
Definition: Viewscreen.h:221
LPDIRECT3DTEXTURE9 m_pddsInterlace[2]
Definition: Viewscreen.h:167
LPDIRECT3DTEXTURE9 m_pddsDIHV[dihvanimateC]
Definition: Viewscreen.h:148
LPDIRECT3DTEXTURE9 m_pddsHeart[heartanimateC]
Definition: Viewscreen.h:149
unsigned short components
Definition: globals.h:456
InputConfig inputConfigYaw
Definition: config.h:28
void AddToCallStack(const char *msg)
Definition: Logger.cpp:86
float dist
Definition: globals.h:466
D3DXVECTOR3 normal
Definition: globals.h:354
LPDIRECT3DTEXTURE9 m_pddsRTSLights[RTStextureC]
Definition: Viewscreen.h:187
D3DXVECTOR3 position
Definition: globals.h:493
#define IDB_BITMAP2
Definition: resource.h:36
LPDIRECT3DVERTEXBUFFER9 m_avRunningLights
Definition: Viewscreen.h:107
HRESULT hr
Definition: renderer.h:49
float RandomFloat()
Definition: MathUtilities.h:98
#define IDB_BITMAP1
Definition: resource.h:35
InputConfig inputConfigSteer
Definition: config.h:32
Logger * logger
Definition: Viewscreen.h:293
double precisionz
Definition: globals.h:550
void LoadTextures(IDirect3DDevice9 *pd3dDevice, short *stage, short *instage)
Definition: renderer.cpp:19
char dataPending
Definition: grid.h:31
static void TouchFile(const WCHAR *str)
Definition: GameClass.cpp:143
LPDIRECT3DTEXTURE9 m_pddsBinocularsArrow
Definition: Viewscreen.h:130
LPDIRECT3DTEXTURE9 m_pddsHullDynamicTexture[MAX_SCAN]
Definition: Viewscreen.h:209
LPDIRECT3DTEXTURE9 m_pddsFirework3[firework3C]
Definition: Viewscreen.h:143
#define D3DFVF_NOPSIZE
Definition: globals.h:107
short u
Definition: globals.h:451
D3DXCOLOR tempcolor
Definition: renderer.h:41
unsigned short components
Definition: globals.h:577
char flicker
Definition: Viewscreen.h:269
LPDIRECT3DTEXTURE9 m_pddsStarTexture
Definition: Viewscreen.h:133
float FrameElapsedTime
Definition: GameClass.h:119