@@ -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 }
0 commit comments