Browse Source

More fixes in minimap

Eduardo Bart 8 years ago
parent
commit
a0b2504f11
1 changed files with 8 additions and 12 deletions
  1. 8
    12
      src/client/minimap.cpp

+ 8
- 12
src/client/minimap.cpp View File

@@ -106,21 +106,17 @@ void Minimap::draw(const Rect& screenRect, const Position& mapCenter, float scal
106 106
     g_painter->drawFilledRect(screenRect);
107 107
     g_painter->resetColor();
108 108
     g_painter->setClipRect(screenRect);
109
-    g_painter->translate(screenRect.topLeft());
110 109
 
111
-    Point p = getBlockOffset(mapRect.topLeft() - Point(1,1));
112
-    g_painter->translate(-(mapRect.topLeft() - p)*scale);
113
-
114
-    Size wantedSize = mapRect.size() * scale;
115
-    Point off = Point(wantedSize.toPoint() - screenRect.size().toPoint())/2;
116
-    g_painter->translate(-off);
110
+    Point blockOff = getBlockOffset(mapRect.topLeft());
111
+    Point off = Point((mapRect.size() * scale).toPoint() - screenRect.size().toPoint())/2;
112
+    Point start = screenRect.topLeft() -(mapRect.topLeft() - blockOff)*scale - off;
117 113
 
118
-    for(int y = p.y, ys = 0;y<=mapRect.bottom()+1;y += MMBLOCK_SIZE, ys += MMBLOCK_SIZE*scale) {
119
-        if(y < 0 || y >= 65536 - MMBLOCK_SIZE)
114
+    for(int y = blockOff.y, ys = start.y;ys<screenRect.bottom();y += MMBLOCK_SIZE, ys += MMBLOCK_SIZE*scale) {
115
+        if(y < 0 || y >= 65536)
120 116
             continue;
121 117
 
122
-        for(int x = p.x, xs = 0;x<=mapRect.right()+1;x += MMBLOCK_SIZE, xs += MMBLOCK_SIZE*scale) {
123
-            if(x < 0 || x >= 65536 - MMBLOCK_SIZE)
118
+        for(int x = blockOff.x, xs = start.x;xs<screenRect.right();x += MMBLOCK_SIZE, xs += MMBLOCK_SIZE*scale) {
119
+            if(x < 0 || x >= 65536)
124 120
                 continue;
125 121
 
126 122
             Position blockPos(x, y, mapCenter.z);
@@ -182,7 +178,7 @@ Rect Minimap::calcMapRect(const Rect& screenRect, const Position& mapCenter, flo
182 178
             h++;
183 179
         scale *= 2;
184 180
     } while(w > 8192 || h > 8192);
185
-    Rect mapRect(0,0,h,w);
181
+    Rect mapRect(0,0,w,h);
186 182
     mapRect.moveCenter(Point(mapCenter.x, mapCenter.y));
187 183
     return mapRect;
188 184
 }

Loading…
Cancel
Save