Added logging on area generation.

This commit is contained in:
Felix Ableitner 2013-05-26 20:57:37 +02:00
parent b9dc5b90d2
commit b47b323180
2 changed files with 28 additions and 2 deletions

View File

@ -19,6 +19,7 @@
#include "simplexnoise.h"
#include "../Pathfinder.h"
#include "../World.h"
#include "../util/Log.h"
/// Seed for usage with simplexnoise.h
uint8_t perm[512];
@ -81,9 +82,11 @@ Generator::generateCurrentAreaIfNeeded(const sf::Vector2f& position) {
closed.insert(current);
if (!mGenerated[current.x][current.y] && distance <= GENERATE_AREA_RANGE) {
mGenerated[current.x][current.y] = true;
generateTiles(sf::IntRect(current * GENERATE_AREA_SIZE -
sf::IntRect area(current * GENERATE_AREA_SIZE -
sf::Vector2i(GENERATE_AREA_SIZE, GENERATE_AREA_SIZE) / 2,
sf::Vector2i(GENERATE_AREA_SIZE, GENERATE_AREA_SIZE)));
sf::Vector2i(GENERATE_AREA_SIZE, GENERATE_AREA_SIZE));
LOG_I("Generating area " << area);
generateTiles(area);
}
if (mGenerated[current.x][current.y] && distance <= GENERATE_AREA_RANGE) {
if (closed.find(sf::Vector2i(current.x + 1, current.y)) == closed.end())

View File

@ -10,6 +10,9 @@
#include <iostream>
#include <SFML/System/Vector2.hpp>
#include <SFML/Graphics/Rect.hpp>
/**
* Logging functions for different levels.
*
@ -61,4 +64,24 @@ operator<<(std::ostream& os, const sf::Vector2i& vector) {
return os;
}
/**
* Adds an output operator specalization for sf::FloatRect
*/
inline std::ostream&
operator<<(std::ostream& os, const sf::FloatRect& rect) {
os << "(x: " << rect.left << ", y: " << rect.top << ", w: " <<
rect.width << ", h: " << rect.height << ")";
return os;
}
/**
* Adds an output operator specalization for sf::IntRect
*/
inline std::ostream&
operator<<(std::ostream& os, const sf::IntRect& rect) {
os << "(x: " << rect.left << ", y: " << rect.top << ", w: " <<
rect.width << ", h: " << rect.height << ")";
return os;
}
#endif /* DG_LOG_H_ */