ok, so i managed to get it to write the last error message to the file, but i want it to list all before the last aswell
Code:
uint32_t totalWarnings = g_config.getNumber(ConfigManager::CONSOLE_SPAWN_WARNING);
static uint8_t qtdWarnings = 0;
if (qtdWarnings < totalWarnings){ //we stop spamming the screen with errors after the last message
Tile* tile = g_game.getTile(_pos);
if(!tile || tile->isMoveableBlocking()){
ofstream myfile("spawn_errors.txt");
if (myfile.is_open())
{
myfile << _name << " - position : " << _pos << "." << std::endl;
myfile.close();
}
else {
cout << "Unable to open file";
}
std::cout << "Warning: [Spawn::addMonster] Position " << _pos << " is not valid. Could not place " << _name << "." << std::endl;
qtdWarnings++;
if (qtdWarnings == totalWarnings){
std::cout << "Too many monsters at invalid positions. We will skip informing you of further errors." << std::endl;
}
}
}