2
2
This file is part of Warzone 2100.
3
3
Copyright (C) 1999-2004 Eidos Interactive
4
Copyright (C) 2005-2007 Warzone Resurrection Project
4
Copyright (C) 2005-2009 Warzone Resurrection Project
6
6
Warzone 2100 is free software; you can redistribute it and/or modify
7
7
it under the terms of the GNU General Public License as published by
24
24
#include <string.h>
26
26
/* Warzone src and library headers */
27
#include "lib/framework/endian_hack.h"
28
#include "lib/framework/file.h"
29
#include "lib/framework/frameint.h"
30
#include "lib/framework/physfs_ext.h"
27
31
#include "lib/framework/strres.h"
28
#include "lib/framework/frameint.h"
29
32
#include "lib/framework/tagfile.h"
30
#include "lib/framework/file.h"
31
#include "lib/framework/physfs_ext.h"
33
34
#include "lib/gamelib/gtime.h"
34
35
#include "lib/ivis_common/ivisdef.h"
500
502
&& PHYSFS_write(fileHandle, serializeDesc->host, 1, 16) == 16
501
503
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwMaxPlayers)
502
504
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwCurrentPlayers)
503
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwUser1)
504
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwUser2)
505
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwUser3)
506
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwUser4));
505
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwUserFlags[0])
506
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwUserFlags[1])
507
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwUserFlags[2])
508
&& PHYSFS_writeSBE32(fileHandle, serializeDesc->dwUserFlags[3]));
509
511
static bool deserializeSessionDesc(PHYSFS_file* fileHandle, SESSIONDESC* serializeDesc)
513
515
&& PHYSFS_read(fileHandle, serializeDesc->host, 1, 16) == 16
514
516
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwMaxPlayers)
515
517
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwCurrentPlayers)
516
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwUser1)
517
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwUser2)
518
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwUser3)
519
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwUser4));
518
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwUserFlags[0])
519
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwUserFlags[1])
520
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwUserFlags[2])
521
&& PHYSFS_readSBE32(fileHandle, &serializeDesc->dwUserFlags[3]));
522
524
static bool serializeGameStruct(PHYSFS_file* fileHandle, const GAMESTRUCT* serializeGame)
1469
1471
#define SAVE_COMP_PROGRAM 8
1470
1472
#define SAVE_COMP_WEAPON 9
1474
typedef struct _path_point
1479
#define TRAVELSIZE 100
1472
1481
typedef struct _save_move_control
1474
1483
UBYTE Status; // Inactive, Navigating or moving point to point status
2140
2148
static BOOL loadSaveDroidInitV2(char *pFileData, UDWORD filesize,UDWORD quantity);
2142
2150
static BOOL loadSaveDroidInit(char *pFileData, UDWORD filesize);
2143
static DROID_TEMPLATE *FindDroidTemplate(char *name,UDWORD player);
2151
static DROID_TEMPLATE *FindDroidTemplate(const char * const name);
2145
2153
static BOOL loadSaveDroid(char *pFileData, UDWORD filesize, DROID **ppsCurrentDroidLists);
2146
2154
static BOOL loadSaveDroidV11(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD version, DROID **ppsCurrentDroidLists);
2212
2220
//adjust the name depending on type of save game and whether resourceNames are used
2213
2221
static BOOL getSaveObjectName(char *pName);
2222
static bool gameLoad(const char* fileName);
2215
2224
/* set the global scroll values to use for the save game */
2216
2225
static void setMapScroll(void);
2379
2381
memset(asReArmUpgrade, 0, MAX_PLAYERS * sizeof(REARM_UPGRADE));
2381
2383
//initialise the upgrade structures
2382
memset(asWeaponUpgrade, 0, MAX_PLAYERS * NUM_WEAPON_SUBCLASS * sizeof(WEAPON_UPGRADE));
2384
memset(asWeaponUpgrade, 0, MAX_PLAYERS * WSC_NUM_WEAPON_SUBCLASSES * sizeof(WEAPON_UPGRADE));
2383
2385
memset(asSensorUpgrade, 0, MAX_PLAYERS * sizeof(SENSOR_UPGRADE));
2384
2386
memset(asECMUpgrade, 0, MAX_PLAYERS * sizeof(ECM_UPGRADE));
2385
2387
memset(asRepairUpgrade, 0, MAX_PLAYERS * sizeof(REPAIR_UPGRADE));
2629
2630
if (gameType != GTYPE_SCENARIO_EXPAND
2630
2631
|| UserSaveGame)
2632
LOADBARCALLBACK(); // loadingScreenCallback();
2633
2633
//load in the terrain type map
2634
2634
aFileName[fileExten] = '\0';
2635
2635
strcat(aFileName, "ttypes.ttp");
2696
2695
//load in the templates
2697
LOADBARCALLBACK(); // loadingScreenCallback();
2698
2696
aFileName[fileExten] = '\0';
2699
2697
strcat(aFileName, "templ.bjo");
2700
2698
/* Load in the chosen file data */
2756
2752
// reload the objects that were in the mission list
2757
LOADBARCALLBACK(); // loadingScreenCallback();
2758
2753
//load in the features -do before the structures
2759
2754
aFileName[fileExten] = '\0';
2760
2755
strcat(aFileName, "mfeat.bjo");
2849
LOADBARCALLBACK(); // loadingScreenCallback();
2850
2842
//load in the flag list file
2851
2843
aFileName[fileExten] = '\0';
2852
2844
strcat(aFileName, "mflagstate.bjo");
2928
2918
if ((gameType == GTYPE_SAVE_START) ||
2929
2919
(gameType == GTYPE_SAVE_MIDMISSION))
2931
LOADBARCALLBACK(); // loadingScreenCallback();
2932
2921
//load in the research list file
2933
2922
aFileName[fileExten] = '\0';
2934
2923
strcat(aFileName, "resstate.bjo");
2954
2943
if(IsScenario==true)
2956
LOADBARCALLBACK(); // loadingScreenCallback();
2957
2945
//load in the droid initialisation file
2958
2946
aFileName[fileExten] = '\0';
2959
2947
strcat(aFileName, "dinit.bjo");
3072
LOADBARCALLBACK(); // loadingScreenCallback();
3073
3057
//load in the features -do before the structures
3074
3058
aFileName[fileExten] = '\0';
3075
3059
strcat(aFileName, "feat.bjo");
3092
3076
//load droid templates moved from here to BEFORE any structures loaded in
3094
3078
//load in the structures
3095
LOADBARCALLBACK(); // loadingScreenCallback();
3096
3079
initStructLimits();
3097
3080
aFileName[fileExten] = '\0';
3098
3081
strcat(aFileName, "struct.bjo");
3125
3107
if ((gameType == GTYPE_SAVE_START) ||
3126
3108
(gameType == GTYPE_SAVE_MIDMISSION))
3128
LOADBARCALLBACK(); // loadingScreenCallback();
3129
3110
//load in the component list file
3130
3111
aFileName[fileExten] = '\0';
3131
3112
strcat(aFileName, "compl.bjo");
3150
LOADBARCALLBACK(); // loadingScreenCallback();
3151
3131
//load in the structure type list file
3152
3132
aFileName[fileExten] = '\0';
3153
3133
strcat(aFileName, "strtype.bjo");
3345
3312
setCurrentStructQuantity(true);
3349
LOADBARCALLBACK(); // loadingScreenCallback();
3351
3315
//check that delivery points haven't been put down in invalid location
3352
3316
checkDeliveryPoints(saveGameVersion);
3354
3318
if ((gameType == GTYPE_SAVE_START) ||
3355
3319
(gameType == GTYPE_SAVE_MIDMISSION))
3357
LOADBARCALLBACK(); // loadingScreenCallback();
3358
3321
for(pl=0;pl<MAX_PLAYERS;pl++) // ajl. must do for every player to stop multiplay/pc players going gaga.
3360
3323
//reverse the structure lists so the Research Facilities are in the same order as when saved
3361
3324
reverseTemplateList((DROID_TEMPLATE**)&apsDroidTemplates[pl]);
3364
LOADBARCALLBACK(); // loadingScreenCallback();
3365
3327
for(pl=0;pl<MAX_PLAYERS;pl++)
3367
3329
//reverse the droid lists so selections occur in the same order
3368
3330
reverseObjectList((BASE_OBJECT**)&apsLimboDroids[pl]);
3371
LOADBARCALLBACK(); // loadingScreenCallback();
3372
3333
for(pl=0;pl<MAX_PLAYERS;pl++)
3374
3335
//reverse the droid lists so selections occur in the same order
3375
3336
reverseObjectList((BASE_OBJECT**)&apsDroidLists[pl]);
3378
LOADBARCALLBACK(); // loadingScreenCallback();
3379
3339
for(pl=0;pl<MAX_PLAYERS;pl++)
3381
3341
//reverse the droid lists so selections occur in the same order
3382
3342
reverseObjectList((BASE_OBJECT**)&mission.apsDroidLists[pl]);
3385
LOADBARCALLBACK(); // loadingScreenCallback();
3386
3345
for(pl=0;pl<MAX_PLAYERS;pl++)
3388
3347
//reverse the struct lists so selections occur in the same order
3389
3348
reverseObjectList((BASE_OBJECT**)&mission.apsStructLists[pl]);
3392
LOADBARCALLBACK(); // loadingScreenCallback();
3393
3351
for(pl=0;pl<MAX_PLAYERS;pl++)
3395
3353
//reverse the droid lists so selections occur in the same order
3396
3354
reverseObjectList((BASE_OBJECT**)&apsFeatureLists[pl]);
3399
LOADBARCALLBACK(); // loadingScreenCallback();
3400
3357
for(pl=0;pl<MAX_PLAYERS;pl++)
3402
3359
//reverse the droid lists so selections occur in the same order
3541
3494
UDWORD fileExtension;
3542
3495
DROID *psDroid, *psNext;
3544
ASSERT(aFileName && strlen(aFileName) > 4, "Bad savegame filename");
3545
if (!aFileName || strlen(aFileName) < 4)
3497
ASSERT_OR_RETURN(false, aFileName && strlen(aFileName) > 4, "Bad savegame filename");
3550
3499
debug(LOG_WZ, "saveGame: %s", aFileName);
3977
3929
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwFlags);
3978
3930
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwMaxPlayers);
3979
3931
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwCurrentPlayers);
3980
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUser1);
3981
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUser2);
3982
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUser3);
3983
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUser4);
3932
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUserFlags[0]);
3933
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUserFlags[1]);
3934
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUserFlags[2]);
3935
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUserFlags[3]);
3985
3937
for(i = 0; i < MAX_PLAYERS; i++)
3986
3938
endian_udword(&psSaveGame->sNetPlay.players[i].dpid);
4119
4071
if (PHYSFS_read(fileHandle, &saveGame, sizeof(SAVE_GAME_V14), 1) != 1)
4121
4073
debug(LOG_ERROR, "getCampaignV: error while reading file: %s", PHYSFS_getLastError());
4235
4187
if (PHYSFS_read(fileHandle, &saveGame, sizeof(saveGame), 1) != 1)
4237
4189
debug(LOG_ERROR, "gameLoadV7: error while reading file: %s", PHYSFS_getLastError());
4314
4266
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V10), 1) != 1)
4316
4268
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4323
4275
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V11), 1) != 1)
4325
4277
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4332
4284
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V12), 1) != 1)
4334
4286
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4341
4293
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V14), 1) != 1)
4343
4295
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4350
4302
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V15), 1) != 1)
4352
4304
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4359
4311
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V16), 1) != 1)
4361
4313
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4368
4320
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V17), 1) != 1)
4370
4322
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4377
4329
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V18), 1) != 1)
4379
4331
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4386
4338
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V19), 1) != 1)
4388
4340
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4395
4347
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V20), 1) != 1)
4397
4349
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4404
4356
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V22), 1) != 1)
4406
4358
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4413
4365
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V24), 1) != 1)
4415
4367
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4422
4374
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V27), 1) != 1)
4424
4376
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4431
4383
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V29), 1) != 1)
4433
4385
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4440
4392
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V30), 1) != 1)
4442
4394
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4449
4401
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V31), 1) != 1)
4451
4403
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4458
4410
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V33), 1) != 1)
4460
4412
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4467
4419
if (PHYSFS_read(fileHandle, &saveGameData, sizeof(SAVE_GAME_V34), 1) != 1)
4469
4421
debug(LOG_ERROR, "gameLoadV: error while reading file (with version number %u): %s", version, PHYSFS_getLastError());
4476
4428
if (!deserializeSaveGameData(fileHandle, &saveGameData))
4478
4430
debug(LOG_ERROR, "gameLoadV: error while reading data from file for deserialization (with version number %u): %s", version, PHYSFS_getLastError());
4485
4437
debug(LOG_ERROR, "gameLoadV: out of range version number (%u) for savegame", version);
4880
4832
saveGame.GameType = saveType;
4882
4834
//save the current level so we can load up the STARTING point of the mission
4883
if (strlen(aLevelName) > MAX_LEVEL_SIZE)
4886
"writeGameFile:Unable to save level name - too long (max20) - %s",
4835
ASSERT_OR_RETURN(false, strlen(aLevelName) < MAX_LEVEL_SIZE, "Unable to save level name - too long (max %d) - %s",
4836
(int)MAX_LEVEL_SIZE, aLevelName);
4891
4837
sstrcpy(saveGame.levelName, aLevelName);
4893
4839
//save out the players power
5135
5081
debug( LOG_ERROR, "This droid cannot be built - %s", pDroidInit->name );
5142
if(NumberOfSkippedDroids) {
5088
if(NumberOfSkippedDroids)
5143
5090
debug( LOG_ERROR, "unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", NumberOfSkippedDroids );
5150
5097
// -----------------------------------------------------------------------------------------
5151
DROID_TEMPLATE *FindDroidTemplate(char *name,UDWORD player)
5098
DROID_TEMPLATE *FindDroidTemplate(const char * const name)
5153
5100
UDWORD TempPlayer;
5154
5101
DROID_TEMPLATE *Template;
5157
//get the name from the resource associated with it
5158
if (!strresGetIDNum(psStringRes, name, &id))
5103
// get the name from the resource associated with it
5104
const char * const nameStr = strresGetString(psStringRes, name);
5160
5107
debug( LOG_ERROR, "Cannot find resource for template - %s", name );
5164
//get the string from the id
5165
name = strresGetString(psStringRes, id);
5167
5111
for(TempPlayer=0; TempPlayer<MAX_PLAYERS; TempPlayer++) {
5168
5112
Template = apsDroidTemplates[TempPlayer];
5170
5114
while(Template) {
5172
//if(strcmp(name,Template->pName)==0) {
5173
if(strcmp(name,Template->aName)==0) {
5116
//if(strcmp(nameStr,Template->pName)==0) {
5117
if(strcmp(nameStr,Template->aName)==0) {
5174
5118
return Template;
5176
5120
Template = Template->psNext;
5291
5235
for (i=0; i < psSaveDroid->numWeaps; i++)
5293
5237
int weapon = getCompFromName(COMP_WEAPON, psSaveDroid->asWeaps[i].name);
5296
ASSERT(false, "This component does not exist : %s", psSaveDroid->asWeaps[i].name );
5238
ASSERT_OR_RETURN(false, weapon >= 0, "This component does not exist : %s", psSaveDroid->asWeaps[i].name);
5299
5239
psTemplate->asWeaps[i] = weapon;
5317
5257
if (psDroid->asWeaps[i].nStat > 0)
5319
5259
//only one weapon now
5320
psDroid->asWeaps[i].hitPoints = psSaveDroid->asWeaps[i].hitPoints;
5321
5260
psDroid->asWeaps[i].ammo = psSaveDroid->asWeaps[i].ammo;
5322
5261
psDroid->asWeaps[i].lastFired = psSaveDroid->asWeaps[i].lastFired;
5344
5283
for (i=0; i < psDroid->numWeaps; i++)
5346
psDroid->turretRotation[i] = psSaveDroid->turretRotation;
5347
psDroid->turretPitch[i] = psSaveDroid->turretPitch;
5285
psDroid->asWeaps[i].rotation = psSaveDroid->turretRotation;
5286
psDroid->asWeaps[i].pitch = psSaveDroid->turretPitch;
5387
5326
debug( LOG_ERROR, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name );
5391
5329
break;//continue;
5393
5331
psTemplate->asParts[i] = (UDWORD)compInc;
5397
//ignore this record
5398
ASSERT( found,"buildUnitFromSavedUnit; failed to find weapon" );
5333
ASSERT_OR_RETURN(NULL, found, "Failed to find weapon");
5401
5334
psTemplate->numWeaps = psSaveDroid->numWeaps;
5403
5336
if (psSaveDroid->numWeaps > 0)
5405
5338
for(i = 0;i < psTemplate->numWeaps;i++)
5407
5340
int weapon = getCompFromName(COMP_WEAPON, psSaveDroid->asWeaps[i].name);
5410
ASSERT(false, "This component does not exist : %s", psSaveDroid->asWeaps[i].name );
5341
ASSERT_OR_RETURN(NULL, weapon >= 0, "This component does not exist : %s", psSaveDroid->asWeaps[i].name);
5413
5342
psTemplate->asWeaps[i] = weapon;
5441
5370
psSaveDroid->player, false);
5446
ASSERT( false,"buildUnitFromSavedUnit; failed to build unit" );
5373
ASSERT_OR_RETURN(NULL, psDroid, "Failed to build unit");
5451
5375
//copy the droid's weapon stats
5452
5376
for (i=0; i < psDroid->numWeaps; i++)
5454
5378
if (psDroid->asWeaps[i].nStat > 0)
5456
psDroid->asWeaps[i].hitPoints = psSaveDroid->asWeaps[i].hitPoints;
5457
5380
psDroid->asWeaps[i].ammo = psSaveDroid->asWeaps[i].ammo;
5458
5381
psDroid->asWeaps[i].lastFired = psSaveDroid->asWeaps[i].lastFired;
5484
5407
//Watermelon:make it back-compatible with older versions of save
5485
5408
for (i=0; i < psDroid->numWeaps; i++)
5487
psDroid->turretRotation[i] = psSaveDroid->turretRotation;
5488
psDroid->turretPitch[i] = psSaveDroid->turretPitch;
5410
psDroid->asWeaps[i].rotation = psSaveDroid->turretRotation;
5411
psDroid->asWeaps[i].pitch = psSaveDroid->turretPitch;
5491
5414
if (version >= VERSION_12)//version 12
5598
5521
// Copy over the endian neutral stuff (all UBYTE)
5599
5522
psSaveDroid->sMove.Status = psDroid->sMove.Status;
5600
5523
psSaveDroid->sMove.Position = psDroid->sMove.Position;
5601
psSaveDroid->sMove.numPoints = psDroid->sMove.numPoints;
5602
memcpy(&psSaveDroid->sMove.asPath, &psDroid->sMove.asPath, sizeof(psSaveDroid->sMove.asPath));
5524
psSaveDroid->sMove.numPoints = MIN(psDroid->sMove.numPoints, TRAVELSIZE);
5525
memcpy(&psSaveDroid->sMove.asPath, psDroid->sMove.asPath,
5526
MIN(sizeof(psSaveDroid->sMove.asPath), sizeof(*psDroid->sMove.asPath) * psDroid->sMove.numPoints));
5604
5528
// Little endian SDWORDs
5605
5529
psSaveDroid->sMove.DestinationX = PHYSFS_swapSLE32(psDroid->sMove.DestinationX);
5666
5590
psDroid->sMove.Status = psSaveDroid->sMove.Status;
5667
5591
psDroid->sMove.Position = psSaveDroid->sMove.Position;
5668
5592
psDroid->sMove.numPoints = psSaveDroid->sMove.numPoints;
5669
memcpy(&psDroid->sMove.asPath, &psSaveDroid->sMove.asPath, sizeof(psSaveDroid->sMove.asPath));
5593
psDroid->sMove.asPath = malloc(sizeof(*psDroid->sMove.asPath) * psDroid->sMove.numPoints);
5594
memcpy(psDroid->sMove.asPath, &psSaveDroid->sMove.asPath, sizeof(*psDroid->sMove.asPath) * psDroid->sMove.numPoints);
5671
5596
// Little endian SDWORDs
5672
5597
psDroid->sMove.DestinationX = PHYSFS_swapSLE32(psSaveDroid->sMove.DestinationX);
5665
// Recreate path-finding jobs
5666
if (psDroid->sMove.Status == MOVEWAITROUTE)
5668
psDroid->sMove.Status = MOVEINACTIVE;
5669
fpathDroidRoute(psDroid, psDroid->sMove.DestinationX, psDroid->sMove.DestinationY);
5670
psDroid->sMove.Status = MOVEWAITROUTE;
5741
5674
// -----------------------------------------------------------------------------------------
5786
5719
else if (compInc < 0)
5789
debug( LOG_ERROR, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name );
5721
ASSERT(compInc >= 0, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name);
5793
5723
break;//continue;
5795
5725
psTemplate->asParts[i] = (UDWORD)compInc;
5799
//ignore this record
5800
ASSERT( found,"buildUnitFromSavedUnit; failed to find weapon" );
5727
ASSERT_OR_RETURN(NULL, found, "Failed to find weapon");
5803
5728
psTemplate->numWeaps = psSaveDroid->numWeaps;
5804
5729
if (psSaveDroid->numWeaps > 0)
5806
5731
for(i = 0;i < psTemplate->numWeaps;i++)
5808
5733
int weapon = getCompFromName(COMP_WEAPON, psSaveDroid->asWeaps[i].name);
5811
ASSERT(false, "This component does not exist : %s", psSaveDroid->asWeaps[i].name );
5734
ASSERT_OR_RETURN(NULL, weapon >= 0, "This component does not exist : %s", psSaveDroid->asWeaps[i].name);
5814
5735
psTemplate->asWeaps[i] = weapon;
5844
5765
psSaveDroid->player, false);
5849
ASSERT( false,"buildUnitFromSavedUnit; failed to build unit" );
5768
ASSERT_OR_RETURN(NULL, psDroid, "Failed to build unit");
5853
5770
turnOffMultiMsg(false);
5859
5776
if (psDroid->asWeaps[i].nStat > 0)
5861
psDroid->asWeaps[i].hitPoints = psSaveDroid->asWeaps[i].hitPoints;
5862
5778
psDroid->asWeaps[i].ammo = psSaveDroid->asWeaps[i].ammo;
5863
5779
psDroid->asWeaps[i].lastFired = psSaveDroid->asWeaps[i].lastFired;
5891
5807
if (version >= VERSION_24)
5893
psDroid->turretRotation[i] = psSaveDroid->turretRotation[i];
5894
psDroid->turretPitch[i] = psSaveDroid->turretPitch[i];
5809
psDroid->asWeaps[i].rotation = psSaveDroid->turretRotation[i];
5810
psDroid->asWeaps[i].pitch = psSaveDroid->turretPitch[i];
5898
psDroid->turretRotation[i] = psSaveDroid->turretRotation[0];
5899
psDroid->turretPitch[i] = psSaveDroid->turretPitch[0];
5814
psDroid->asWeaps[i].rotation = psSaveDroid->turretRotation[0];
5815
psDroid->asWeaps[i].pitch = psSaveDroid->turretPitch[0];
6164
6080
endian_udword(&psSaveDroid->burnDamage);
6165
6081
for(i = 0; i < TEMP_DROID_MAXPROGS; i++) {
6166
6082
/* SAVE_WEAPON_V19 */
6167
endian_udword(&psSaveDroid->asWeaps[i].hitPoints);
6168
6083
endian_udword(&psSaveDroid->asWeaps[i].ammo);
6169
6084
endian_udword(&psSaveDroid->asWeaps[i].lastFired);
6220
6135
if (NumberOfSkippedDroids>0)
6222
6137
debug( LOG_ERROR, "unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", NumberOfSkippedDroids );
6226
6141
ppsCurrentDroidLists = NULL;//ensure it always gets set
6317
6232
endian_udword(&psSaveDroid->burnDamage);
6318
6233
for(i = 0; i < TEMP_DROID_MAXPROGS; i++) {
6319
6234
/* SAVE_WEAPON_V19 */
6320
endian_udword(&psSaveDroid->asWeaps[i].hitPoints);
6321
6235
endian_udword(&psSaveDroid->asWeaps[i].ammo);
6322
6236
endian_udword(&psSaveDroid->asWeaps[i].lastFired);
6375
6289
if (NumberOfSkippedDroids>0)
6377
6291
debug( LOG_ERROR, "unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", NumberOfSkippedDroids );
6381
6295
ppsCurrentDroidLists = NULL;//ensure it always gets set
6479
6393
endian_udword(&psSaveDroid->burnDamage);
6480
6394
for(i = 0; i < TEMP_DROID_MAXPROGS; i++) {
6481
6395
/* SAVE_WEAPON */
6482
endian_udword(&psSaveDroid->asWeaps[i].hitPoints);
6483
6396
endian_udword(&psSaveDroid->asWeaps[i].ammo);
6484
6397
endian_udword(&psSaveDroid->asWeaps[i].lastFired);
6539
6452
if (NumberOfSkippedDroids>0)
6541
6454
debug( LOG_ERROR, "unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", NumberOfSkippedDroids );
6545
6458
ppsCurrentDroidLists = NULL;//ensure it always gets set
6557
6470
the translated name - old versions of save games should load because
6558
6471
templates are loaded from Access AND the save game so they should all
6560
ASSERT(strlen(psCurr->aName) + 1 < sizeof(psSaveDroid->name), "Truncation of droid name occurred! Max droid length (without truncation while saving) is %zu", sizeof(psSaveDroid->name) - 1);
6561
6474
sstrcpy(psSaveDroid->name, psCurr->aName);
6563
6476
// not interested in first comp - COMP_UNKNOWN
6583
6496
if (getNameFromComp(COMP_WEAPON, psSaveDroid->asWeaps[i].name, psCurr->asWeaps[i].nStat))
6586
psSaveDroid->asWeaps[i].hitPoints = psCurr->asWeaps[i].hitPoints;
6587
6499
psSaveDroid->asWeaps[i].ammo = psCurr->asWeaps[i].ammo;
6588
6500
psSaveDroid->asWeaps[i].lastFired = psCurr->asWeaps[i].lastFired;
6602
6514
//Watermelon:endian_udword for new save format
6603
6515
for(i = 0;i < psCurr->numWeaps;i++)
6605
psSaveDroid->turretRotation[i] = psCurr->turretRotation[i];
6606
psSaveDroid->turretPitch[i] = psCurr->turretPitch[i];
6517
psSaveDroid->turretRotation[i] = psCurr->asWeaps[i].rotation;
6518
psSaveDroid->turretPitch[i] = psCurr->asWeaps[i].pitch;
6609
6521
psSaveDroid->order = psCurr->order;
6709
6621
endian_udword(&psSaveDroid->body);
6710
6622
endian_udword(&psSaveDroid->saveType);
6711
6623
for(i = 0; i < TEMP_DROID_MAXPROGS; i++) {
6712
endian_udword(&psSaveDroid->asWeaps[i].hitPoints);
6713
6624
endian_udword(&psSaveDroid->asWeaps[i].ammo);
6714
6625
endian_udword(&psSaveDroid->asWeaps[i].lastFired);
7041
6951
|| map_coord(psSaveStructure->x) > mapWidth - TOO_NEAR_EDGE)
7043
6953
debug( LOG_ERROR, "Structure %s, x coord too near the edge of the map. id - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id );
7047
6957
if (map_coord(psSaveStructure->y) < TOO_NEAR_EDGE
7048
6958
|| map_coord(psSaveStructure->y) > mapHeight - TOO_NEAR_EDGE)
7050
6960
debug( LOG_ERROR, "Structure %s, y coord too near the edge of the map. id - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id );
7055
6965
psStructure = buildStructure(psStats, psSaveStructure->x, psSaveStructure->y,
7056
6966
psSaveStructure->player,true);
7059
ASSERT( false, "loadSaveStructure:Unable to create structure" );
6967
ASSERT_OR_RETURN(false, psStructure, "Unable to create structure");
7063
6969
/*The original code here didn't work and so the scriptwriters worked
7064
6970
round it by using the module ID - so making it work now will screw up
7330
7236
|| map_coord(psSaveStructure->x) > mapWidth - TOO_NEAR_EDGE)
7332
7238
debug( LOG_ERROR, "Structure %s, x coord too near the edge of the map. id - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id );
7336
7242
if (map_coord(psSaveStructure->y) < TOO_NEAR_EDGE
7337
7243
|| map_coord(psSaveStructure->y) > mapHeight - TOO_NEAR_EDGE)
7339
7245
debug( LOG_ERROR, "Structure %s, y coord too near the edge of the map. id - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id );
7344
psStructure = buildStructure(psStats, psSaveStructure->x, psSaveStructure->y,
7345
psSaveStructure->player,true);
7348
ASSERT( false, "loadSaveStructure:Unable to create structure" );
7250
psStructure = buildStructure(psStats, psSaveStructure->x, psSaveStructure->y, psSaveStructure->player,true);
7251
ASSERT_OR_RETURN(false, psStructure, "Unable to create structure");
7352
7253
/*The original code here didn't work and so the scriptwriters worked
7353
7254
round it by using the module ID - so making it work now will screw up
7771
7671
|| map_coord(psSaveStructure->x) > mapWidth - TOO_NEAR_EDGE)
7773
7673
debug( LOG_ERROR, "Structure %s, x coord too near the edge of the map. id - %d", getSaveStructNameV((SAVE_STRUCTURE*)psSaveStructure), psSaveStructure->id );
7777
7677
if (map_coord(psSaveStructure->y) < TOO_NEAR_EDGE
7778
7678
|| map_coord(psSaveStructure->y) > mapHeight - TOO_NEAR_EDGE)
7780
7680
debug( LOG_ERROR, "Structure %s, y coord too near the edge of the map. id - %d", getSaveStructNameV((SAVE_STRUCTURE*)psSaveStructure), psSaveStructure->id );
7785
psStructure = buildStructure(psStats, psSaveStructure->x, psSaveStructure->y,
7786
psSaveStructure->player,true);
7789
ASSERT( false, "loadSaveStructure:Unable to create structure" );
7685
psStructure = buildStructure(psStats, psSaveStructure->x, psSaveStructure->y, psSaveStructure->player, true);
7686
ASSERT_OR_RETURN(false, psStructure, "Unable to create structure");
7793
7688
/*The original code here didn't work and so the scriptwriters worked
7794
7689
round it by using the module ID - so making it work now will screw up
8599
8494
pFeature = buildFeature(psStats, psSaveFeature->x, psSaveFeature->y,true);
8600
8495
//will be added to the top of the linked list
8601
8496
//pFeature = apsFeatureLists[0];
8604
ASSERT( false, "loadSaveFeature:Unable to create feature" );
8497
ASSERT_OR_RETURN(false, pFeature, "Unable to create feature");
8607
8498
//restore values
8608
8499
pFeature->id = psSaveFeature->id;
8609
8500
pFeature->direction = psSaveFeature->direction;
8703
8593
pFeature = buildFeature(psStats, psSaveFeature->x, psSaveFeature->y,true);
8704
8594
//will be added to the top of the linked list
8705
8595
//pFeature = apsFeatureLists[0];
8708
ASSERT( false, "loadSaveFeature:Unable to create feature" );
8596
ASSERT_OR_RETURN(false, pFeature, "Unable to create feature");
8711
8597
//restore values
8712
8598
pFeature->id = psSaveFeature->id;
8713
8599
pFeature->direction = psSaveFeature->direction;
9384
9263
for(psCurr = apsDroidTemplates[player]; psCurr != NULL; psCurr = psCurr->psNext)
9386
ASSERT(strlen(psCurr->aName) + 1 < sizeof(psSaveTemplate->name), "Truncation of droid name occurred! Max droid length (without truncation while saving) is %zu", sizeof(psSaveTemplate->name) - 1);
9387
9265
sstrcpy(psSaveTemplate->name, psCurr->aName);
9389
9267
psSaveTemplate->ref = psCurr->ref;
9475
9352
// Load the terrain type mapping
9476
9353
pType = (UWORD *)(pFileData + TILETYPE_HEADER_SIZE);
9477
9354
endian_uword(pType);
9355
if (psHeader->quantity >= MAX_TILE_TEXTURES)
9357
// Workaround for fugly map editor bug, since we can't fix the map editor
9358
psHeader->quantity = MAX_TILE_TEXTURES - 1;
9478
9360
for(i = 0; i < psHeader->quantity; i++)
9480
if (i >= MAX_TILE_TEXTURES)
9482
debug( LOG_ERROR, "loadTerrainTypeMap: too many types" );
9487
9362
if (*pType > TER_MAX)
9489
9364
debug( LOG_ERROR, "loadTerrainTypeMap: terrain type out of range" );
9729
9604
char *pFileData;
9730
9605
SAVE_COMPLIST *psSaveCompList;
9731
9606
UDWORD fileSize, totalComp, player, i;
9732
COMP_BASE_STATS *psStats;
9607
COMPONENT_STATS *psStats;
9734
9609
// Calculate the file size
9735
9610
totalComp = (numBodyStats + numWeaponStats + numConstructStats + numECMStats +
9761
9636
for(i = 0; i < numBodyStats; i++)
9763
psStats = (COMP_BASE_STATS *)(asBodyStats + i);
9638
psStats = (COMPONENT_STATS *)(asBodyStats + i);
9765
9640
strcpy(psSaveCompList->name, psStats->pName);
9772
9647
for(i = 0; i < numWeaponStats; i++)
9774
psStats = (COMP_BASE_STATS *)(asWeaponStats + i);
9649
psStats = (COMPONENT_STATS *)(asWeaponStats + i);
9776
9651
strcpy(psSaveCompList->name, psStats->pName);
9783
9658
for(i = 0; i < numConstructStats; i++)
9785
psStats = (COMP_BASE_STATS *)(asConstructStats + i);
9660
psStats = (COMPONENT_STATS *)(asConstructStats + i);
9787
9662
strcpy(psSaveCompList->name, psStats->pName);
9794
9669
for(i = 0; i < numECMStats; i++)
9796
psStats = (COMP_BASE_STATS *)(asECMStats + i);
9671
psStats = (COMPONENT_STATS *)(asECMStats + i);
9798
9673
strcpy(psSaveCompList->name, psStats->pName);
9805
9680
for(i = 0; i < numPropulsionStats; i++)
9807
psStats = (COMP_BASE_STATS *)(asPropulsionStats + i);
9682
psStats = (COMPONENT_STATS *)(asPropulsionStats + i);
9809
9684
strcpy(psSaveCompList->name, psStats->pName);
9816
9691
for(i = 0; i < numSensorStats; i++)
9818
psStats = (COMP_BASE_STATS *)(asSensorStats + i);
9693
psStats = (COMPONENT_STATS *)(asSensorStats + i);
9820
9695
strcpy(psSaveCompList->name, psStats->pName);
9827
9702
for(i = 0; i < numRepairStats; i++)
9829
psStats = (COMP_BASE_STATS *)(asRepairStats + i);
9704
psStats = (COMPONENT_STATS *)(asRepairStats + i);
9831
9706
strcpy(psSaveCompList->name, psStats->pName);
9838
9713
for(i = 0; i < numBrainStats; i++)
9840
psStats = (COMP_BASE_STATS *)(asBrainStats + i);
9715
psStats = (COMPONENT_STATS *)(asBrainStats + i);
9842
9717
strcpy(psSaveCompList->name, psStats->pName);
11627
11504
// write the event state to a file on disk
11628
11505
static BOOL writeScriptState(char *pFileName)
11507
static const int32_t current_event_version = 4;
11630
11509
char *pBuffer;
11631
11510
UDWORD fileSize;
11633
if (!eventSaveState(3, &pBuffer, &fileSize))
11512
if (!eventSaveState(current_event_version, &pBuffer, &fileSize))
11635
11514
return false;
11659
11538
if (!loadFileToBuffer(pFileName, pFileData, FILE_LOAD_BUFFER_SIZE, &fileSize))
11661
11540
debug( LOG_ERROR, "loadScriptState: couldn't load %s", pFileName );
11663
11542
return false;
11771
11650
// -----------------------------------------------------------------------------------------
11774
//======================================================
11775
//draws stuff into our newer bitmap.
11776
BOOL plotStructurePreview16(char *backDropSprite, UBYTE scale, UDWORD offX, UDWORD offY)
11654
* \param[out] backDropSprite The premade map texture.
11655
* \param scale Scale of the map texture.
11656
* \param offX,offY X and Y offset for map
11657
* \param[out] playeridpos Will contain the position on the map where the player's HQ are located.
11659
* Reads the current map and colours the map preview for any structures
11660
* present. Additionally we load the player's HQ location into playeridpos so
11661
* we know the player's starting location.
11663
BOOL plotStructurePreview16(char *backDropSprite, UBYTE scale, UDWORD offX, UDWORD offY,Vector2i playeridpos[])
11778
11665
SAVE_STRUCTURE sSave; // close eyes now.
11779
11666
SAVE_STRUCTURE *psSaveStructure = &sSave; // assumes save_struct is larger than all previous ones...
11879
11768
endian_udword(&psSaveStructure2->burnStart);
11880
11769
endian_udword(&psSaveStructure2->burnDamage);
11882
xx = map_coord(psSaveStructure2->x);
11883
yy = map_coord(psSaveStructure2->y);
11771
// we are specifically looking for the HQ, and it seems this is the only way to
11772
// find it via parsing map.
11773
// We store the coordinates of the structure, into a array for as many players as are on the map.
11774
// all map versions follow this pattern, and I will not comment the other routines.
11884
11775
playerid = psSaveStructure2->player;
11776
if(strncmp(psSaveStructure2->name,"A0CommandCentre",15) == 0 )
11779
xx = playeridpos[playerid].x = map_coord(psSaveStructure2->x);
11780
yy = playeridpos[playerid].y = map_coord(psSaveStructure2->y);
11785
xx = map_coord(psSaveStructure2->x);
11786
yy = map_coord(psSaveStructure2->y);
11886
11789
else if (psHeader->version < VERSION_14)
11913
11816
endian_udword(&psSaveStructure12->player);
11914
11817
endian_udword(&psSaveStructure12->burnStart);
11915
11818
endian_udword(&psSaveStructure12->burnDamage);
11917
xx = map_coord(psSaveStructure12->x);
11918
yy = map_coord(psSaveStructure12->y);
11919
11819
playerid = psSaveStructure12->player;
11821
if(strncmp(psSaveStructure12->name,"A0CommandCentre",15) == 0 )
11824
xx = playeridpos[playerid].x = map_coord(psSaveStructure12->x);
11825
yy = playeridpos[playerid].y = map_coord(psSaveStructure12->y);
11830
xx = map_coord(psSaveStructure12->x);
11831
yy = map_coord(psSaveStructure12->y);
11921
11834
else if (psHeader->version <= VERSION_14)
11949
11862
endian_udword(&psSaveStructure14->player);
11950
11863
endian_udword(&psSaveStructure14->burnStart);
11951
11864
endian_udword(&psSaveStructure14->burnDamage);
11953
xx = map_coord(psSaveStructure14->x);
11954
yy = map_coord(psSaveStructure14->y);
11955
11865
playerid = psSaveStructure14->player;
11867
if(strncmp(psSaveStructure14->name,"A0CommandCentre",15) == 0 )
11870
xx = playeridpos[playerid].x = map_coord(psSaveStructure14->x);
11871
yy = playeridpos[playerid].y = map_coord(psSaveStructure14->y);
11876
xx = map_coord(psSaveStructure14->x);
11877
yy = map_coord(psSaveStructure14->y);
11957
11880
else if (psHeader->version <= VERSION_16)
11986
11909
endian_udword(&psSaveStructure15->player);
11987
11910
endian_udword(&psSaveStructure15->burnStart);
11988
11911
endian_udword(&psSaveStructure15->burnDamage);
11990
xx = map_coord(psSaveStructure15->x);
11991
yy = map_coord(psSaveStructure15->y);
11992
11912
playerid = psSaveStructure15->player;
11914
if(strncmp(psSaveStructure15->name,"A0CommandCentre",15) == 0 )
11917
xx = playeridpos[playerid].x = map_coord(psSaveStructure15->x);
11918
yy = playeridpos[playerid].y = map_coord(psSaveStructure15->y);
11923
xx = map_coord(psSaveStructure15->x);
11924
yy = map_coord(psSaveStructure15->y);
11994
11927
else if (psHeader->version <= VERSION_19)
12025
11958
endian_udword(&psSaveStructure17->player);
12026
11959
endian_udword(&psSaveStructure17->burnStart);
12027
11960
endian_udword(&psSaveStructure17->burnDamage);
12029
xx = map_coord(psSaveStructure17->x);
12030
yy = map_coord(psSaveStructure17->y);
12031
11961
playerid = psSaveStructure17->player;
11963
if(strncmp(psSaveStructure17->name,"A0CommandCentre",15) == 0 )
11966
xx = playeridpos[playerid].x = map_coord(psSaveStructure17->x);
11967
yy = playeridpos[playerid].y = map_coord(psSaveStructure17->y);
11972
xx = map_coord(psSaveStructure17->x);
11973
yy = map_coord(psSaveStructure17->y);
12033
11976
else if (psHeader->version <= VERSION_20)
12061
12004
endian_udword(&psSaveStructure20->player);
12062
12005
endian_udword(&psSaveStructure20->burnStart);
12063
12006
endian_udword(&psSaveStructure20->burnDamage);
12065
xx = map_coord(psSaveStructure20->x);
12066
yy = map_coord(psSaveStructure20->y);
12067
12007
playerid = psSaveStructure20->player;
12009
if(strncmp(psSaveStructure20->name,"A0CommandCentre",15) == 0 )
12012
xx = playeridpos[playerid].x = map_coord(psSaveStructure20->x);
12013
yy = playeridpos[playerid].y = map_coord(psSaveStructure20->y);
12018
xx = map_coord(psSaveStructure20->x);
12019
yy = map_coord(psSaveStructure20->y);
12100
12053
endian_udword(&psSaveStructure->player);
12101
12054
endian_udword(&psSaveStructure->burnStart);
12102
12055
endian_udword(&psSaveStructure->burnDamage);
12104
xx = map_coord(psSaveStructure->x);
12105
yy = map_coord(psSaveStructure->y);
12106
12056
playerid = psSaveStructure->player;
12058
if(strncmp(psSaveStructure->name,"A0CommandCentre",15) == 0 )
12061
xx = playeridpos[playerid].x = map_coord(psSaveStructure->x);
12062
yy = playeridpos[playerid].y = map_coord(psSaveStructure->y);
12067
xx = map_coord(psSaveStructure->x);
12068
yy = map_coord(psSaveStructure->y);
12108
12071
// if human player, then use clan color. If AI, then use something else.
12109
12072
if( isHumanPlayer(playerid) )
12122
12084
color = WZCOL_MAP_PREVIEW_AIPLAYER ;
12088
{ // This shows where the HQ is on the map in a special color.
12089
// We could do the same for anything else (oil/whatever) also.
12090
// Possible future enhancement?
12096
// and now we blit the color to the texture
12125
12097
for(x = (xx*scale);x < (xx*scale)+scale ;x++)
12127
12099
for(y = (yy*scale);y< (yy*scale)+scale ;y++)
12129
backDropSprite[3 * (((offY + y) * BACKDROP_HACK_WIDTH) + x + offX)] = color.byte.r;
12101
backDropSprite[3 * (((offY + y) * BACKDROP_HACK_WIDTH) + x + offX)] = color.byte.r;
12130
12102
backDropSprite[3 * (((offY + y) * BACKDROP_HACK_WIDTH) + x + offX) + 1] = color.byte.g;
12131
12103
backDropSprite[3 * (((offY + y) * BACKDROP_HACK_WIDTH) + x + offX) + 2] = color.byte.b;
12108
// NOTE: would do fallback if FBO is not available here.