| 5258 | } |
| 5259 | |
| 5260 | void TextSourceScript::parseScriptInMapGeneration(Entity& src) |
| 5261 | { |
| 5262 | std::string script = getScriptFromEntity(src); |
| 5263 | |
| 5264 | size_t foundScriptTag = script.find("@script"); |
| 5265 | if ( foundScriptTag != std::string::npos ) |
| 5266 | { |
| 5267 | if ( (foundScriptTag + strlen("@script")) < script.length() |
| 5268 | && script.at(foundScriptTag + strlen("@script")) == ' ' ) |
| 5269 | { |
| 5270 | script.erase(foundScriptTag, strlen("@script") + 1); // trailing space. |
| 5271 | } |
| 5272 | else |
| 5273 | { |
| 5274 | script.erase(foundScriptTag, strlen("@script")); |
| 5275 | } |
| 5276 | textSourceScript.setScriptType(src.textSourceIsScript, textSourceScript.SCRIPT_NORMAL); |
| 5277 | textSourceScript.setTriggerType(src.textSourceIsScript, textSourceScript.TRIGGER_POWER); |
| 5278 | } |
| 5279 | if ( src.textSourceIsScript == NO_SCRIPT ) |
| 5280 | { |
| 5281 | return; |
| 5282 | } |
| 5283 | |
| 5284 | if ( script.find("@triggerif=") != std::string::npos ) |
| 5285 | { |
| 5286 | int result = textSourceProcessScriptTag(script, "@triggerif=", src); |
| 5287 | if ( result != k_ScriptError ) |
| 5288 | { |
| 5289 | textSourceScript.setTriggerType(src.textSourceIsScript, static_cast<ScriptTriggeredBy>(result)); |
| 5290 | } |
| 5291 | } |
| 5292 | |
| 5293 | if ( script.find("@attachto=") != std::string::npos ) |
| 5294 | { |
| 5295 | int attachTo = textSourceProcessScriptTag(script, "@attachto=", src); |
| 5296 | if ( attachTo == k_ScriptError ) |
| 5297 | { |
| 5298 | return; |
| 5299 | } |
| 5300 | textSourceScript.setScriptType(src.textSourceIsScript, textSourceScript.SCRIPT_ATTACHED); |
| 5301 | int x1 = static_cast<int>(src.x / 16); // default to just whatever this script is sitting on. |
| 5302 | int x2 = static_cast<int>(src.x / 16); |
| 5303 | int y1 = static_cast<int>(src.y / 16); |
| 5304 | int y2 = static_cast<int>(src.y / 16); |
| 5305 | // offset for generated dungeons |
| 5306 | x1 += src.mapGenerationRoomX; |
| 5307 | x2 += src.mapGenerationRoomX; |
| 5308 | y1 += src.mapGenerationRoomY; |
| 5309 | y2 += src.mapGenerationRoomY; |
| 5310 | if ( script.find("@attachrange=") != std::string::npos ) |
| 5311 | { |
| 5312 | int result = textSourceProcessScriptTag(script, "@attachrange=", src); |
| 5313 | if ( result != k_ScriptError ) |
| 5314 | { |
| 5315 | x1 = result & 0xFF; |
| 5316 | x2 = (result >> 8) & 0xFF; |
| 5317 | y1 = (result >> 16) & 0xFF; |
no test coverage detected