| 39 | started=false; |
| 40 | } |
| 41 | void FollowTest::update() |
| 42 | { |
| 43 | if (running == false) return; |
| 44 | if (fail) |
| 45 | { |
| 46 | running = false; |
| 47 | return; |
| 48 | } |
| 49 | int thisFrame = Broodwar->getFrameCount(); |
| 50 | BWAssert(thisFrame==nextFrame); |
| 51 | nextFrame++; |
| 52 | Broodwar->setScreenPosition(unit->getPosition() - Position(320,240)); |
| 53 | |
| 54 | if (unit->getDistance(target)>32*15 && started==false) |
| 55 | { |
| 56 | BWAssertF(unit->follow(target),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;}); |
| 57 | BWAssertF(unit->getOrder()==Orders::Follow,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;}); |
| 58 | BWAssertF(unit->getTarget()==target,{fail=true;return;}); |
| 59 | started=true; |
| 60 | startFrame=Broodwar->getFrameCount(); |
| 61 | } |
| 62 | |
| 63 | if (started) |
| 64 | { |
| 65 | if (thisFrame<startFrame+50) |
| 66 | { |
| 67 | BWAssertF(unit->getOrder()==Orders::Follow,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;}); |
| 68 | BWAssertF(unit->getTarget()==target || unit->getOrderTarget()==target,{fail=true;return;}); |
| 69 | } |
| 70 | else if (thisFrame==startFrame+50) |
| 71 | { |
| 72 | BWAssertF(unit->stop(),{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;}); |
| 73 | BWAssertF(unit->isIdle()==true,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;}); |
| 74 | } |
| 75 | else if (thisFrame<startFrame+100) |
| 76 | { |
| 77 | } |
| 78 | else if (thisFrame<startFrame+200) |
| 79 | { |
| 80 | BWAssertF(unit->isIdle()==true,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;}); |
| 81 | BWAssertF(unit->isMoving()==false || unit->isBraking(),{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;}); |
| 82 | running = false; |
| 83 | } |
| 84 | else if (thisFrame==startFrame+200) |
| 85 | { |
| 86 | running = false; |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | void FollowTest::stop() |
| 92 | { |
nothing calls this directly
no test coverage detected