11#include " ./canvas.h"
22#include " VERSION"
3- #include " fmt/color.h"
43#include " png.h"
5- #include < vector>
64
75size_t Canvas::_get_line (const uint8_t *data, uint8_t *buffer, size_t bufSize,
86 uint64_t y) const {
@@ -159,32 +157,32 @@ void IsometricCanvas::setColors(const Colors::Palette &colors) {
159157 brightnessLookup[y] = -100 + 200 * float (y) / 255 ;
160158}
161159
162- void IsometricCanvas::setMap (const Terrain ::Coordinates &_map) {
160+ void IsometricCanvas::setMap (const World ::Coordinates &_map) {
163161 map = _map;
164162
165163 sizeX = map.maxX - map.minX + 1 ;
166164 sizeZ = map.maxZ - map.minZ + 1 ;
167165
168166 switch (map.orientation ) {
169- case NW:
167+ case Map:: NW:
170168 offsetX = map.minX & 0x0f ;
171169 offsetZ = map.minZ & 0x0f ;
172170 break ;
173- case NE:
171+ case Map:: NE:
174172 offsetX = 15 - (map.maxX & 0x0f );
175173 offsetZ = map.minZ & 0x0f ;
176174 break ;
177- case SW:
175+ case Map:: SW:
178176 offsetX = map.minX & 0x0f ;
179177 offsetZ = 15 - (map.maxZ & 0x0f );
180178 break ;
181- case SE:
179+ case Map:: SE:
182180 offsetX = 15 - (map.maxX & 0x0f );
183181 offsetZ = 15 - (map.maxZ & 0x0f );
184182 break ;
185183 }
186184
187- if (map.orientation == NE || map.orientation == SW) {
185+ if (map.orientation == Map:: NE || map.orientation == Map:: SW) {
188186 std::swap (sizeX, sizeZ);
189187 std::swap (offsetX, offsetZ);
190188 }
@@ -217,21 +215,21 @@ void IsometricCanvas::setMap(const Terrain::Coordinates &_map) {
217215// y, they come out as the real coordinates.
218216void IsometricCanvas::orientChunk (int32_t &x, int32_t &z) {
219217 switch (map.orientation ) {
220- case NW:
218+ case Map:: NW:
221219 x = (map.minX >> 4 ) + x;
222220 z = (map.minZ >> 4 ) + z;
223221 break ;
224- case SW:
222+ case Map:: SW:
225223 std::swap (x, z);
226224 x = (map.minX >> 4 ) + x;
227225 z = (map.maxZ >> 4 ) - z;
228226 break ;
229- case NE:
227+ case Map:: NE:
230228 std::swap (x, z);
231229 x = (map.maxX >> 4 ) - x;
232230 z = (map.minZ >> 4 ) + z;
233231 break ;
234- case SE:
232+ case Map:: SE:
235233 x = (map.maxX >> 4 ) - x;
236234 z = (map.maxZ >> 4 ) - z;
237235 break ;
@@ -244,7 +242,7 @@ void IsometricCanvas::renderTerrain(Terrain::Data &world) {
244242 nXChunks = CHUNK (map.maxX ) - CHUNK (map.minX ) + 1 ;
245243 nZChunks = CHUNK (map.maxZ ) - CHUNK (map.minZ ) + 1 ;
246244
247- if (map.orientation == NE || map.orientation == SW)
245+ if (map.orientation == Map:: NE || map.orientation == Map:: SW)
248246 std::swap (nXChunks, nZChunks);
249247
250248 // world is supposed to have the SAME set of coordinates as the canvas
@@ -312,17 +310,17 @@ void IsometricCanvas::renderChunk(Terrain::Data &terrain) {
312310// plane ?
313311inline void IsometricCanvas::orientSection (uint8_t &x, uint8_t &z) {
314312 switch (map.orientation ) {
315- case NW:
313+ case Map:: NW:
316314 return ;
317- case NE:
315+ case Map:: NE:
318316 std::swap (x, z);
319317 x = 15 - x;
320318 return ;
321- case SW:
319+ case Map:: SW:
322320 std::swap (x, z);
323321 z = 15 - z;
324322 return ;
325- case SE:
323+ case Map:: SE:
326324 x = 15 - x;
327325 z = 15 - z;
328326 return ;
@@ -568,8 +566,8 @@ const Colors::Block *IsometricCanvas::nextBlock() {
568566bool compare (const Canvas &p1, const Canvas &p2) {
569567 // This method is used to order a list of maps. The ordering is done by the
570568 // distance to the top-right corner of the map in North Western orientation.
571- Terrain ::Coordinates c1 = p1.map .orient (Orientation ::NW);
572- Terrain ::Coordinates c2 = p2.map .orient (Orientation ::NW);
569+ World ::Coordinates c1 = p1.map .orient (Map ::NW);
570+ World ::Coordinates c2 = p2.map .orient (Map ::NW);
573571
574572 return (c1.minX + c1.minZ ) > (c2.minX + c2.minZ );
575573}
0 commit comments