Skip to content

Commit

Permalink
Paths: Remove zone enter script event hack
Browse files Browse the repository at this point in the history
The current zone of an entity is *not* stored in save files, meaning
that after loading a save zone enter script events are re-sent for
all entities already in the zone. This hack was supposed to prevent
that for two specific zones on the dwarven forge level.

The ingot_maker and mauld_user zones are used to detect ingredients
placed in the apparatus for smelting ores into metal bars or bars into
items respectively. When an appropriate entity enters these zones
the ID is stored in variables on the controlling lever entity to decide
if enough ingredients are present, which output entity to produce and
which input entities to destroy. These variables are only changed if
they are not already set to an entity so re-running the zone enter
events for entities already in the zone should have no effect.

Further, the current zone is updated for at most  10 to 50 entities,
varying depending on framerate. This especially means that there is no
guarantee that any given entity will have its zone updated in the first
frame after loading and thus suppressed by this hack.

Thus the hack to suppress these script events for the two zones is not
only not needed with the Arx Fatalis 1.21 scripts but also ineffective.

Fixes: issue #505
  • Loading branch information
dscharrer committed Jul 6, 2018
1 parent e649091 commit d665c48
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/ai/Paths.cpp
Expand Up @@ -155,22 +155,16 @@ static void EntityEnteringCurrentZone(Entity * io, ARX_PATH * current) {

io->inzone_show = io->show;

if(JUST_RELOADED && (current->name == "ingot_maker" || current->name == "mauld_user")) {
ARX_DEAD_CODE(); // TODO remove JUST_RELOADED global
} else {

SendIOScriptEvent(NULL, io, SM_ENTERZONE, current->name);

if(!current->controled.empty()) {
EntityHandle t = entities.getById(current->controled);
if(t != EntityHandle()) {
ScriptParameters parameters;
parameters.push_back(io->idString());
parameters.push_back(current->name);
SendIOScriptEvent(NULL, entities[t], SM_CONTROLLEDZONE_ENTER, parameters);
}
SendIOScriptEvent(NULL, io, SM_ENTERZONE, current->name);

if(!current->controled.empty()) {
EntityHandle t = entities.getById(current->controled);
if(t != EntityHandle()) {
ScriptParameters parameters;
parameters.push_back(io->idString());
parameters.push_back(current->name);
SendIOScriptEvent(NULL, entities[t], SM_CONTROLLEDZONE_ENTER, parameters);
}

}

}
Expand Down

0 comments on commit d665c48

Please sign in to comment.