Skip to content
Permalink
Browse files

Immediately mark objects as destroyed in save

Obsoletes SHOW_FLAG_DESTROYED except as a flag in the save file.
  • Loading branch information
dscharrer committed Nov 11, 2013
1 parent 4ec4181 commit c116db5be0177c7f924f4ed42a30c067c9f628cb
Showing with 32 additions and 27 deletions.
  1. +2 −1 src/ai/Paths.cpp
  2. +17 −17 src/game/Entity.cpp
  3. +1 −1 src/game/Entity.h
  4. +1 −1 src/game/NPC.cpp
  5. +10 −3 src/scene/ChangeLevel.cpp
  6. +1 −4 src/script/ScriptEvent.cpp
@@ -208,13 +208,14 @@ void ARX_PATH_UpdateAllZoneInOutInside() {
for(long tt = 0; tt < f; tt++) {
long i = count;
Entity * io = entities[i];


if(count < entities.size()
&& io
&& io->ioflags & (IO_NPC | IO_ITEM)
&& io->show != SHOW_FLAG_MEGAHIDE
&& io->show != SHOW_FLAG_DESTROYED
) {
arx_assert(io->show != SHOW_FLAG_DESTROYED);
ARX_PATH * p = ARX_PATH_CheckInZone(io);
ARX_PATH * op = io->inzone;

@@ -63,6 +63,7 @@ ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.

#include "gui/Interface.h"

#include "scene/ChangeLevel.h"
#include "scene/GameSound.h"
#include "scene/Interactive.h"
#include "scene/Light.h"
@@ -315,18 +316,6 @@ void Entity::cleanReferences() {
}
gameFlags &= ~GFLAG_ISINTREATZONE;

if(obj) {
while(obj->nblinked) {
if(obj->linked[0].lgroup != -1 && obj->linked[0].obj) {
Entity * linked = obj->linked[0].io;
if(linked && ValidIOAddress(linked)) {
EERIE_LINKEDOBJ_UnLinkObjectFromObject(obj, linked->obj);
linked->destroy();
}
}
}
}

ARX_INTERACTIVE_DestroyDynamicInfo(this);

RemoveFromAllInventories(this);
@@ -347,13 +336,24 @@ void Entity::cleanReferences() {

void Entity::destroy() {

if(scriptload) {
delete this;
} else {
show = SHOW_FLAG_DESTROYED;
cleanReferences();
if(!scriptload) {
currentSavedGameStoreEntityDeletion(long_name());
}

if(obj) {
while(obj->nblinked) {
if(obj->linked[0].lgroup != -1 && obj->linked[0].obj) {
Entity * linked = obj->linked[0].io;
if(linked && ValidIOAddress(linked)) {
EERIE_LINKEDOBJ_UnLinkObjectFromObject(obj, linked->obj);
linked->destroy();
}
}
}
}

delete this;

}

void Entity::destroyOne() {
@@ -216,7 +216,7 @@ enum EntityVisilibity {
SHOW_FLAG_KILLED = 7, // Deprecated, use SHOW_FLAG_DESTROYED instead
SHOW_FLAG_MEGAHIDE = 8,
SHOW_FLAG_ON_PLAYER = 9,
SHOW_FLAG_DESTROYED = 255
SHOW_FLAG_DESTROYED = 255 // Only used in save files
};

struct AnimationBlendStatus {
@@ -976,13 +976,13 @@ void ARX_PHYSICS_Apply() {
ARX_NPC_ManagePoison(io);

if((io->ioflags & IO_ITEM)
&& (io->show != SHOW_FLAG_DESTROYED)
&& (io->gameFlags & GFLAG_GOREEXPLODE)
&& float(arxtime) - io->animBlend.lastanimtime > 300
&& io->obj
&& !io->obj->vertexlist.empty()
)
{
arx_assert(io->show != SHOW_FLAG_DESTROYED);
long cnt = (io->obj->vertexlist.size() << 12) + 1;

cnt = clamp(cnt, 2, 10);
@@ -262,13 +262,18 @@ bool currentSavedGameHasEntity(const std::string & ident) {
if(pSaveBlock) {
return pSaveBlock->hasFile(ident);
} else {
LogError << "Tried to access the current saved game state before a game was started";
ARX_DEAD_CODE();
return false;
}
}

void currentSavedGameStoreEntityDeletion(const std::string & idString) {

if(!pSaveBlock) {
ARX_DEAD_CODE();
return;
}

// Save a minimal entity save file containing just enough info so we know not to load it
ARX_CHANGELEVEL_IO_SAVE ais;
memset(&ais, 0, sizeof(ARX_CHANGELEVEL_IO_SAVE));
@@ -481,8 +486,7 @@ static bool ARX_CHANGELEVEL_Push_Index(long num) {
if(entities[i] != NULL
&& !(entities[i]->ioflags & IO_NOSAVE)
&& !IsInPlayerInventory(entities[i])
&& !IsPlayerEquipedWith(entities[i])
&& (entities[i]->show != SHOW_FLAG_DESTROYED)) {
&& !IsPlayerEquipedWith(entities[i])) {
ARX_CHANGELEVEL_IO_INDEX aii;
memset(&aii, 0, sizeof(aii));
strncpy(aii.filename,
@@ -881,6 +885,9 @@ static long ARX_CHANGELEVEL_Push_IO(const Entity * io, long level) {
return -1;
}

arx_assert(io->show != SHOW_FLAG_DESTROYED);
arx_assert(io->show != SHOW_FLAG_KILLED);

// Sets Savefile Name
string savefile = io->long_name();

@@ -180,10 +180,7 @@ static bool checkInteractiveObject(Entity * io, ScriptMessage msg, ScriptResult
return true;
}

if(io->show == SHOW_FLAG_DESTROYED) {
ret = ACCEPT;
return true;
}
arx_assert(io->show != SHOW_FLAG_DESTROYED);

if(io->ioflags & IO_FREEZESCRIPT) {
ret = (msg == SM_LOAD) ? ACCEPT : REFUSE;

0 comments on commit c116db5

Please sign in to comment.