Skip to content

Commit

Permalink
ChangeLevel: Remove global variable Gaids
Browse files Browse the repository at this point in the history
This is no longer needed as all referenced entities are now resolved
immediately when loading the referring entity.

Fixes: issue #375
  • Loading branch information
dscharrer committed Apr 17, 2017
1 parent 35f8f96 commit 4a51277
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions src/scene/ChangeLevel.cpp
Expand Up @@ -129,8 +129,6 @@ static long CONVERT_CREATED = 0;
long DONT_WANT_PLAYER_INZONE = 0;
static SaveBlock * g_currentSavedGame = NULL;

static ARX_CHANGELEVEL_INVENTORY_DATA_SAVE ** Gaids = NULL;

static Entity * convertToValidIO(const std::string & idString) {

CONVERT_CREATED = 0;
Expand Down Expand Up @@ -1969,11 +1967,6 @@ static Entity * ARX_CHANGELEVEL_Pop_IO(const std::string & idString, EntityInsta
LogError << "CHANGELEVEL Error: Unable to load " << idString;
} else {

EntityHandle Gaids_Number = io->index();
Gaids[Gaids_Number.handleData()] = new ARX_CHANGELEVEL_INVENTORY_DATA_SAVE;

memset(Gaids[Gaids_Number.handleData()], 0, sizeof(ARX_CHANGELEVEL_INVENTORY_DATA_SAVE));

// The current entity should be visible at this point to preven infinite loops while resolving
// related entities.
arx_assert(entities.getById(idString) == io->index());
Expand Down Expand Up @@ -2438,33 +2431,6 @@ static void ARX_CHANGELEVEL_PopAllIO(ARX_CHANGELEVEL_INDEX * asi, ARX_CHANGELEVE

static void ARX_CHANGELEVEL_PopAllIO_FINISH(bool reloadflag, bool firstTime) {

bool * treated = new bool[MAX_IO_SAVELOAD];
memset(treated, 0, sizeof(unsigned char)*MAX_IO_SAVELOAD);

long converted = 1;
while(converted) {
converted = 0;

for(size_t it = 1; it < MAX_IO_SAVELOAD && it < entities.size(); it++) {
const EntityHandle handle = EntityHandle(it);
Entity * io = entities[handle];

if(!io || treated[it]) {
continue;
}

treated[it] = true;

const ARX_CHANGELEVEL_INVENTORY_DATA_SAVE * aids = Gaids[it];
if(!aids) {
continue;
}

}
}

delete[] treated;

if(reloadflag) {

for(size_t i = 0; i < entities.size(); i++) {
Expand Down Expand Up @@ -2577,36 +2543,19 @@ static void ARX_CHANGELEVEL_Pop_Globals() {
free(dat);
}

static void ReleaseGaids() {

for(size_t i = 0; i < entities.size(); i++) {
delete Gaids[i];
}

delete[] Gaids, Gaids = NULL;
}

static void ARX_CHANGELEVEL_PopLevel_Abort(ARX_CHANGELEVEL_IO_INDEX * idx_io) {

arxtime.resume();

delete[] idx_io;

ReleaseGaids();
FORBID_SCRIPT_IO_CREATION = 0;
}

static bool ARX_CHANGELEVEL_PopLevel(long instance, bool reloadflag) {

LogDebug("Before ARX_CHANGELEVEL_PopLevel Alloc'n'Free");

if(Gaids) {
ReleaseGaids();
}

Gaids = new ARX_CHANGELEVEL_INVENTORY_DATA_SAVE *[MAX_IO_SAVELOAD];
memset(Gaids, 0, sizeof(*Gaids) * MAX_IO_SAVELOAD);

ARX_CHANGELEVEL_INDEX asi;

LogDebug("After ARX_CHANGELEVEL_PopLevel Alloc'n'Free");
Expand Down Expand Up @@ -2711,8 +2660,6 @@ static bool ARX_CHANGELEVEL_PopLevel(long instance, bool reloadflag) {
progressBarAdvance(15.f);
LoadLevelScreen();

ReleaseGaids();

progressBarAdvance(3.f);
LoadLevelScreen();

Expand Down

0 comments on commit 4a51277

Please sign in to comment.