@@ -270,7 +270,7 @@ void TileGenerator::parseColorsStream(std::istream &in)
270
270
{
271
271
char line[128 ];
272
272
while (in.good ()) {
273
- in.getline (line, 128 );
273
+ in.getline (line, sizeof (line) );
274
274
275
275
for (char *p = line; *p; p++) {
276
276
if (*p != ' #' )
@@ -281,7 +281,7 @@ void TileGenerator::parseColorsStream(std::istream &in)
281
281
if (strlen (line) == 0 )
282
282
continue ;
283
283
284
- char name[64 + 1 ];
284
+ char name[64 + 1 ] = { 0 } ;
285
285
unsigned int r, g, b, a, t;
286
286
a = 255 ;
287
287
t = 0 ;
@@ -291,7 +291,7 @@ void TileGenerator::parseColorsStream(std::istream &in)
291
291
continue ;
292
292
}
293
293
294
- ColorEntry color = ColorEntry (r, g, b, a, t);
294
+ ColorEntry color (r, g, b, a, t);
295
295
m_colorMap[name] = color;
296
296
}
297
297
}
@@ -352,7 +352,7 @@ void TileGenerator::loadBlocks()
352
352
m_zMin = pos.z ;
353
353
if (pos.z > m_zMax)
354
354
m_zMax = pos.z ;
355
- m_positions.push_back (std::pair< int , int > (pos.x , pos.z ));
355
+ m_positions.push_back (std::make_pair (pos.x , pos.z ));
356
356
}
357
357
m_positions.sort ();
358
358
m_positions.unique ();
@@ -393,24 +393,24 @@ void TileGenerator::createImage()
393
393
image_height = (m_mapHeight * m_zoom) + m_yBorder;
394
394
image_height += (m_scales & SCALE_BOTTOM) ? scale_d : 0 ;
395
395
396
- if (image_width > 4096 || image_height > 4096 )
396
+ if (image_width > 4096 || image_height > 4096 ) {
397
397
std::cerr << " Warning: The width or height of the image to be created exceeds 4096 pixels!"
398
398
<< " (Dimensions: " << image_width << " x" << image_height << " )"
399
399
<< std::endl;
400
+ }
400
401
m_image = new Image (image_width, image_height);
401
402
m_image->drawFilledRect (0 , 0 , image_width, image_height, m_bgColor); // Background
402
403
}
403
404
404
405
void TileGenerator::renderMap ()
405
406
{
406
407
BlockDecoder blk;
407
- std::list<int > zlist = getZValueList ();
408
- for (std::list<int >::iterator zPosition = zlist.begin (); zPosition != zlist.end (); ++zPosition) {
409
- int zPos = *zPosition;
408
+ std::list<int16_t > zlist = getZValueList ();
409
+ for (int16_t zPos : zlist) {
410
410
std::map<int16_t , BlockList> blocks;
411
411
m_db->getBlocksOnZ (blocks, zPos);
412
- for (std::list<std::pair< int , int > >::const_iterator position = m_positions. begin (); position != m_positions. end (); ++position ) {
413
- if (position-> second != zPos)
412
+ for (const auto position : m_positions) {
413
+ if (position. second != zPos)
414
414
continue ;
415
415
416
416
m_readPixels.reset ();
@@ -423,14 +423,14 @@ void TileGenerator::renderMap()
423
423
}
424
424
}
425
425
426
- int xPos = position-> first ;
426
+ int16_t xPos = position. first ;
427
427
blocks[xPos].sort ();
428
428
const BlockList &blockStack = blocks[xPos];
429
- for (BlockList::const_iterator it = blockStack. begin (); it != blockStack. end (); ++it ) {
430
- const BlockPos &pos = it-> first ;
429
+ for (const auto & it : blockStack) {
430
+ const BlockPos &pos = it. first ;
431
431
432
432
blk.reset ();
433
- blk.decode (it-> second );
433
+ blk.decode (it. second );
434
434
if (blk.isEmpty ())
435
435
continue ;
436
436
renderMapBlock (blk, pos);
@@ -636,26 +636,26 @@ void TileGenerator::renderOrigin()
636
636
void TileGenerator::renderPlayers (const std::string &inputPath)
637
637
{
638
638
PlayerAttributes players (inputPath);
639
- for (PlayerAttributes::Players::iterator player = players. begin (); player != players. end (); ++player ) {
640
- if (player-> x < m_xMin * 16 || player-> x > m_xMax * 16 ||
641
- player-> z < m_zMin * 16 || player-> z > m_zMax * 16 )
639
+ for (auto & player : players) {
640
+ if (player. x < m_xMin * 16 || player. x > m_xMax * 16 ||
641
+ player. z < m_zMin * 16 || player. z > m_zMax * 16 )
642
642
continue ;
643
- if (player-> y < m_yMin || player-> y > m_yMax)
643
+ if (player. y < m_yMin || player. y > m_yMax)
644
644
continue ;
645
- int imageX = getImageX (player-> x , true ),
646
- imageY = getImageY (player-> z , true );
645
+ int imageX = getImageX (player. x , true ),
646
+ imageY = getImageY (player. z , true );
647
647
648
648
m_image->drawFilledRect (imageX - 1 , imageY, 3 , 1 , m_playerColor);
649
649
m_image->drawFilledRect (imageX, imageY - 1 , 1 , 3 , m_playerColor);
650
- m_image->drawText (imageX + 2 , imageY, player-> name , m_playerColor);
650
+ m_image->drawText (imageX + 2 , imageY, player. name , m_playerColor);
651
651
}
652
652
}
653
653
654
- inline std::list<int > TileGenerator::getZValueList () const
654
+ inline std::list<int16_t > TileGenerator::getZValueList () const
655
655
{
656
- std::list<int > zlist;
657
- for (std::list<std::pair< int , int > >::const_iterator position = m_positions. begin (); position != m_positions. end (); ++position )
658
- zlist.push_back (position-> second );
656
+ std::list<int16_t > zlist;
657
+ for (const auto position : m_positions)
658
+ zlist.push_back (position. second );
659
659
zlist.sort ();
660
660
zlist.unique ();
661
661
zlist.reverse ();
@@ -674,8 +674,8 @@ void TileGenerator::printUnknown()
674
674
if (m_unknownNodes.size () == 0 )
675
675
return ;
676
676
std::cerr << " Unknown nodes:" << std::endl;
677
- for (NameSet::iterator node = m_unknownNodes. begin (); node != m_unknownNodes. end (); ++node )
678
- std::cerr << " \t " << * node << std::endl;
677
+ for (const auto & node : m_unknownNodes)
678
+ std::cerr << " \t " << node << std::endl;
679
679
}
680
680
681
681
inline int TileGenerator::getImageX (int val, bool absolute) const
0 commit comments