| 18 | } |
| 19 | |
| 20 | void CGameEffectMoving::Update(CGameObject *parent) |
| 21 | { |
| 22 | if (LastMoveTime > g_Ticks) |
| 23 | { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | LastMoveTime = g_Ticks + MoveDelay; |
| 28 | |
| 29 | CGameEffect::Update(parent); |
| 30 | |
| 31 | CGameObject *obj = g_World->FindWorldObject(DestSerial); |
| 32 | |
| 33 | if (obj != nullptr) |
| 34 | { |
| 35 | obj = obj->GetTopObject(); |
| 36 | |
| 37 | if (obj != nullptr) |
| 38 | { |
| 39 | DestX = obj->GetX(); |
| 40 | DestY = obj->GetY(); |
| 41 | DestZ = obj->GetZ(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | int screenCenterX = g_RenderBounds.GameWindowCenterX; |
| 46 | int screenCenterY = g_RenderBounds.GameWindowCenterY; |
| 47 | |
| 48 | int playerX = g_Player->GetX(); |
| 49 | int playerY = g_Player->GetY(); |
| 50 | |
| 51 | int offsetX = m_X - playerX; |
| 52 | int offsetY = m_Y - playerY; |
| 53 | |
| 54 | int drawX = screenCenterX + (offsetX - offsetY) * 22; |
| 55 | int drawY = screenCenterY + (offsetX + offsetY) * 22; |
| 56 | |
| 57 | int realDrawX = drawX + OffsetX; |
| 58 | int realDrawY = drawY + OffsetY; |
| 59 | |
| 60 | int offsetDestX = DestX - playerX; |
| 61 | int offsetDestY = DestY - playerY; |
| 62 | |
| 63 | int drawDestX = screenCenterX + (offsetDestX - offsetDestY) * 22; |
| 64 | int drawDestY = screenCenterY + (offsetDestX + offsetDestY) * 22; |
| 65 | |
| 66 | int deltaXY[2] = { abs(drawDestX - realDrawX), abs(drawDestY - realDrawY) }; |
| 67 | |
| 68 | int x = 0; |
| 69 | |
| 70 | if (deltaXY[0] < deltaXY[1]) |
| 71 | { |
| 72 | x = 1; |
| 73 | |
| 74 | int temp = deltaXY[0]; |
| 75 | |
| 76 | deltaXY[0] = deltaXY[1]; |
| 77 | deltaXY[1] = temp; |
nothing calls this directly
no test coverage detected