| 410 | } |
| 411 | |
| 412 | bool Script::SimulateBody() |
| 413 | { |
| 414 | #if SCRIPTS_DEBUGGING |
| 415 | if (GDebugger) |
| 416 | { |
| 417 | EnvDTE::Breakpoints* breakpoints = nullptr; |
| 418 | GDebugger->get_Breakpoints(&breakpoints); |
| 419 | long n = 0; |
| 420 | breakpoints->get_Count(&n); |
| 421 | for (long i = 0; i < n; i++) |
| 422 | { |
| 423 | VARIANT index; |
| 424 | index.vt = VT_I4; |
| 425 | index.lVal = i; |
| 426 | |
| 427 | EnvDTE::Breakpoint* breakpoint = nullptr; |
| 428 | breakpoints->Item(index, &breakpoint); |
| 429 | BSTR filename; |
| 430 | breakpoint->get_File(&filename); |
| 431 | } |
| 432 | } |
| 433 | #endif |
| 434 | |
| 435 | GameState* gstate = GWorld->GetGameState(); |
| 436 | gstate->VarSetLocal("_this", _argument, true); |
| 437 | // if simulate body takes too long, interrupt it |
| 438 | #if DIAG_DEBUG >= 10 |
| 439 | DWORD timeStart = Foundation::GlobalTickCount(); |
| 440 | #endif |
| 441 | int cntExecute = 0; |
| 442 | int maxExecute = _maxLinesAtOnce > 0 ? _maxLinesAtOnce : 100; |
| 443 | while (_currentLine < _lines.Size()) |
| 444 | { |
| 445 | ScriptLine& line = _lines[_currentLine]; |
| 446 | if (line.suspendUntil.GetLength() > 0) |
| 447 | { |
| 448 | _suspendedUntil = gstate->Evaluate(line.suspendUntil); |
| 449 | if (_time < _suspendedUntil) |
| 450 | { |
| 451 | break; |
| 452 | } |
| 453 | } |
| 454 | if (line.waitUntil.GetLength() > 0 && !gstate->EvaluateBool(line.waitUntil)) |
| 455 | { |
| 456 | break; |
| 457 | } |
| 458 | _currentLine++; |
| 459 | if ( |
| 460 | // empty condition is considered true |
| 461 | (line.condition.GetLength() == 0 || gstate->EvaluateBool(line.condition)) |
| 462 | // empty command is not executed |
| 463 | && line.statement.GetLength() > 0) |
| 464 | { |
| 465 | #if DIAG_DEBUG >= 20 |
| 466 | LOG_DEBUG(Script, "Execute {}", (const char*)line.statement); |
| 467 | #endif |
| 468 | gstate->Execute(line.statement); |
| 469 | _time = gstate->VarGet("_time"); |
nothing calls this directly
no test coverage detected