Skip to content

Commit 19067f1

Browse files
committed
EventManager: Fix script event location not being updated due to cache
1 parent 8abbab3 commit 19067f1

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/EventManager.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,13 +1129,6 @@ void EventManager::executeScript(const std::string& filename, float x, float y)
11291129
while (script_file.next()) {
11301130
if (script_file.new_section && script_file.section == "event") {
11311131
Event tmp_evnt;
1132-
tmp_evnt.location.x = tmp_evnt.hotspot.x = static_cast<int>(x);
1133-
tmp_evnt.location.y = tmp_evnt.hotspot.y = static_cast<int>(y);
1134-
tmp_evnt.location.w = tmp_evnt.hotspot.w = 1;
1135-
tmp_evnt.location.h = tmp_evnt.hotspot.h = 1;
1136-
tmp_evnt.center.x = static_cast<float>(tmp_evnt.location.x) + 0.5f;
1137-
tmp_evnt.center.y = static_cast<float>(tmp_evnt.location.y) + 0.5f;
1138-
11391132
script_evnt.push(tmp_evnt);
11401133
}
11411134

@@ -1165,18 +1158,28 @@ void EventManager::executeScript(const std::string& filename, float x, float y)
11651158
}
11661159

11671160
while (!script_evnt.empty()) {
1161+
Event& evnt = script_evnt.front();
1162+
1163+
// set event location from x/y
1164+
evnt.location.x = evnt.hotspot.x = static_cast<int>(x);
1165+
evnt.location.y = evnt.hotspot.y = static_cast<int>(y);
1166+
evnt.location.w = evnt.hotspot.w = 1;
1167+
evnt.location.h = evnt.hotspot.h = 1;
1168+
evnt.center.x = static_cast<float>(evnt.location.x) + 0.5f;
1169+
evnt.center.y = static_cast<float>(evnt.location.y) + 0.5f;
1170+
11681171
// create StatBlocks if we need them
1169-
EventComponent *ec_power = script_evnt.front().getComponent(EventComponent::POWER);
1172+
EventComponent *ec_power = evnt.getComponent(EventComponent::POWER);
11701173
if (ec_power) {
1171-
ec_power->data[0].Int = mapr->addEventStatBlock(script_evnt.front());
1174+
ec_power->data[0].Int = mapr->addEventStatBlock(evnt);
11721175
}
11731176

1174-
if (script_evnt.front().delay.getDuration() > 0) {
1177+
if (evnt.delay.getDuration() > 0) {
11751178
// handle delayed events
1176-
mapr->delayed_events.push_back(script_evnt.front());
1179+
mapr->delayed_events.push_back(evnt);
11771180
}
1178-
else if (isActive(script_evnt.front())) {
1179-
executeEvent(script_evnt.front());
1181+
else if (isActive(evnt)) {
1182+
executeEvent(evnt);
11801183
}
11811184
script_evnt.pop();
11821185
}

src/Version.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/
3030

3131
#include <SDL.h>
3232

33-
Version VersionInfo::ENGINE(1, 14, 220);
33+
Version VersionInfo::ENGINE(1, 14, 221);
3434
Version VersionInfo::MIN(0, 0, 0);
3535
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);
3636

0 commit comments

Comments
 (0)