more logging improvements
This commit is contained in:
parent
7a6bdc1495
commit
8fe4563efa
4 changed files with 38 additions and 32 deletions
|
@ -849,7 +849,7 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||
}
|
||||
refresh_bc();
|
||||
|
||||
LOG_NG << "getting attack statistics\n";
|
||||
DBG_NG << "getting attack statistics\n";
|
||||
statistics::attack_context attack_stats(a_->second, d_->second, a_stats_->chance_to_hit, d_stats_->chance_to_hit);
|
||||
|
||||
orig_attacks_ = a_stats_->num_blows;
|
||||
|
@ -869,7 +869,7 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||
LOG_NG << "Fight: (" << attacker << ") vs (" << defender << ") ATT: " << a_stats_->weapon->name() << " " << a_stats_->damage << "-" << a_stats_->num_blows << "(" << a_stats_->chance_to_hit << "%) vs DEF: " << (d_stats_->weapon ? d_stats_->weapon->name() : "none") << " " << d_stats_->damage << "-" << d_stats_->num_blows << "(" << d_stats_->chance_to_hit << "%)" << (defender_strikes_first ? " defender first-strike" : "") << "\n";
|
||||
|
||||
while(n_attacks_ > 0 || n_defends_ > 0) {
|
||||
LOG_NG << "start of attack loop...\n";
|
||||
DBG_NG << "start of attack loop...\n";
|
||||
abs_n_attack_++;
|
||||
|
||||
if(n_attacks_ > 0 && defender_strikes_first == false) {
|
||||
|
@ -992,7 +992,7 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||
refresh_bc();
|
||||
}
|
||||
|
||||
LOG_NG << "done attacking\n";
|
||||
DBG_NG << "done attacking\n";
|
||||
if(dies || hits) {
|
||||
int amount_drained = a_stats_->drains ? attacker_damage_ / 2 : 0;
|
||||
|
||||
|
@ -1102,7 +1102,7 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||
abs_n_defend_++;
|
||||
|
||||
if(n_defends_ > 0) {
|
||||
LOG_NG << "doing defender attack...\n";
|
||||
DBG_NG << "doing defender attack...\n";
|
||||
|
||||
const int ran_num = get_random();
|
||||
bool hits = (ran_num%100) < defender_cth_;
|
||||
|
@ -1623,7 +1623,7 @@ void check_victory(unit_map& units, std::vector<team>& teams)
|
|||
for(unit_map::const_iterator i = units.begin();
|
||||
i != units.end(); ++i) {
|
||||
if(i->second.can_recruit()) {
|
||||
LOG_NG << "seen leader for side " << i->second.side() << "\n";
|
||||
DBG_NG << "seen leader for side " << i->second.side() << "\n";
|
||||
seen_leaders.push_back(i->second.side());
|
||||
}
|
||||
}
|
||||
|
@ -1944,7 +1944,7 @@ size_t move_unit(game_display* disp, const game_data& gamedata,
|
|||
//or a uncaptured village (except if it was our plan to end there)
|
||||
if( units.count(*step) == 0 &&
|
||||
(!map.is_village(*step) || team.owns_village(*step) || step+1==route.end()) ) {
|
||||
LOG_NG << "checking for units from " << (step->x+1) << "," << (step->y+1) << "\n";
|
||||
DBG_NG << "checking for units from " << (step->x+1) << "," << (step->y+1) << "\n";
|
||||
|
||||
// Temporarily reset the unit's moves to full
|
||||
const unit_movement_resetter move_resetter(ui->second);
|
||||
|
@ -2115,12 +2115,12 @@ size_t move_unit(game_display* disp, const game_data& gamedata,
|
|||
// and whether they are allies or enemies, so calculate that out here
|
||||
int nfriends = 0, nenemies = 0;
|
||||
for(std::set<gamemap::location>::const_iterator i = seen_units.begin(); i != seen_units.end(); ++i) {
|
||||
LOG_NG << "processing unit at " << (i->x+1) << "," << (i->y+1) << "\n";
|
||||
DBG_NG << "processing unit at " << (i->x+1) << "," << (i->y+1) << "\n";
|
||||
const unit_map::const_iterator u = units.find(*i);
|
||||
|
||||
// Unit may have been removed by an event.
|
||||
if(u == units.end()) {
|
||||
LOG_NG << "was removed\n";
|
||||
DBG_NG << "was removed\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2130,7 +2130,7 @@ size_t move_unit(game_display* disp, const game_data& gamedata,
|
|||
++nfriends;
|
||||
}
|
||||
|
||||
LOG_NG << "processed...\n";
|
||||
DBG_NG << "processed...\n";
|
||||
team.see(u->second.side()-1);
|
||||
}
|
||||
|
||||
|
@ -2234,7 +2234,7 @@ void apply_shroud_changes(undo_list& undos, game_display* disp, const gamestatus
|
|||
6. fix up associated display stuff (done in a similar way to turn_info::undo())
|
||||
*/
|
||||
for(undo_list::iterator un = undos.begin(); un != undos.end(); ++un) {
|
||||
std::cout << "Turning an undo...\n";
|
||||
LOG_NG << "Turning an undo...\n";
|
||||
if(un->is_recall() || un->is_recruit()) continue;
|
||||
// We're not really going to mutate the unit, just temporarily
|
||||
// set its moves to maximum, but then switch them back.
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "widgets/button.hpp"
|
||||
#include "widgets/slider.hpp"
|
||||
|
||||
#define DBG_NG LOG_STREAM(debug, engine)
|
||||
|
||||
namespace {
|
||||
const size_t max_island = 10;
|
||||
const size_t max_coastal = 5;
|
||||
|
@ -344,12 +346,12 @@ std::string default_map_generator::generate_map(const std::vector<std::string>&
|
|||
const size_t island_radius = 50 + ((max_island - island_size_)*50)/(max_island - max_coastal);
|
||||
island_size = (island_radius*(width_/2))/100;
|
||||
} else if(island_size_ > 0) {
|
||||
std::cerr << "coastal...\n";
|
||||
DBG_NG << "coastal...\n";
|
||||
//the radius of the island should be up to twice the width of the map
|
||||
const size_t island_radius = 40 + ((max_coastal - island_size_)*40)/max_coastal;
|
||||
island_size = (island_radius*width_*2)/100;
|
||||
island_off_center = minimum<size_t>(width_,height_);
|
||||
std::cerr << "calculated coastal params...\n";
|
||||
DBG_NG << "calculated coastal params...\n";
|
||||
}
|
||||
|
||||
return default_generate_map(width_,height_,island_size,island_off_center,iterations,hill_size_,max_lakes,(nvillages_*width_*height_)/1000,castle_size_,nplayers_,link_castles_,labels,cfg_);
|
||||
|
@ -357,7 +359,7 @@ std::string default_map_generator::generate_map(const std::vector<std::string>&
|
|||
|
||||
config default_map_generator::create_scenario(const std::vector<std::string>& args)
|
||||
{
|
||||
std::cerr << "creating scenario...\n";
|
||||
DBG_NG << "creating scenario...\n";
|
||||
config res;
|
||||
|
||||
const config* const scenario = cfg_.child("scenario");
|
||||
|
@ -365,12 +367,12 @@ config default_map_generator::create_scenario(const std::vector<std::string>& ar
|
|||
res = *scenario;
|
||||
}
|
||||
|
||||
std::cerr << "got scenario data...\n";
|
||||
DBG_NG << "got scenario data...\n";
|
||||
|
||||
std::map<gamemap::location,std::string> labels;
|
||||
std::cerr << "generating map...\n";
|
||||
DBG_NG << "generating map...\n";
|
||||
res["map_data"] = generate_map(args,&labels);
|
||||
std::cerr << "done generating map..\n";
|
||||
DBG_NG << "done generating map..\n";
|
||||
|
||||
for(std::map<gamemap::location,std::string>::const_iterator i =
|
||||
labels.begin(); i != labels.end(); ++i) {
|
||||
|
|
|
@ -43,6 +43,9 @@
|
|||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#define ERR_NG LOG_STREAM(err, engine)
|
||||
#define LOG_NG LOG_STREAM(info, engine)
|
||||
|
||||
namespace {
|
||||
|
||||
static void remove_old_saves()
|
||||
|
@ -52,10 +55,10 @@ static void remove_old_saves()
|
|||
return;
|
||||
|
||||
std::vector<save_info> games = get_saves_list();
|
||||
std::cerr << "Removing old saves.\n";
|
||||
LOG_NG << "Removing old saves.\n";
|
||||
for (std::vector<save_info>::iterator i = games.begin(); i != games.end(); i++) {
|
||||
if (countdown-- < 0) {
|
||||
std::cerr << "Deleting savegame '" << i->name << "'\n";
|
||||
LOG_NG << "Deleting savegame '" << i->name << "'\n";
|
||||
delete_game(i->name);
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +851,7 @@ private:
|
|||
//do not bother retrying, since the user can just save the game
|
||||
}
|
||||
end = SDL_GetTicks();
|
||||
std::cerr << "Milliseconds to save " << savename << ": " << end - start << "\n";
|
||||
LOG_NG << "Milliseconds to save " << savename << ": " << end - start << "\n";
|
||||
|
||||
remove_old_saves();
|
||||
}
|
||||
|
@ -946,7 +949,7 @@ private:
|
|||
const std::map<std::string,unit_type>::const_iterator
|
||||
u_type = gameinfo_.unit_types.find(*it);
|
||||
if(u_type == gameinfo_.unit_types.end()) {
|
||||
LOG_STREAM(err, engine) << "could not find unit '" << *it << "'\n";
|
||||
ERR_NG << "could not find unit '" << *it << "'\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1070,7 +1073,7 @@ private:
|
|||
{
|
||||
player_info *player = gamestate_.get_player(teams_[team_num-1].save_id());
|
||||
if(!player) {
|
||||
LOG_STREAM(err, engine) << "cannot recall a unit for side " << team_num
|
||||
ERR_NG << "cannot recall a unit for side " << team_num
|
||||
<< ", which has no recall list!\n";
|
||||
return;
|
||||
}
|
||||
|
@ -1154,7 +1157,7 @@ private:
|
|||
i18n_symbols);
|
||||
gui::dialog(*gui_,"",msg.str()).show();
|
||||
} else {
|
||||
std::cerr << "recall index: " << res << "\n";
|
||||
LOG_NG << "recall index: " << res << "\n";
|
||||
unit& un = recall_list[res];
|
||||
gamemap::location loc = last_hex;
|
||||
recorder.add_recall(res,loc);
|
||||
|
@ -1197,7 +1200,7 @@ private:
|
|||
player_info* const player = gamestate_.get_player(teams_[team_num - 1].save_id());
|
||||
|
||||
if(player == NULL) {
|
||||
LOG_STREAM(err, engine) << "trying to undo a recall for side " << team_num
|
||||
ERR_NG << "trying to undo a recall for side " << team_num
|
||||
<< ", which has no recall list!\n";
|
||||
} else {
|
||||
// Undo a recall action
|
||||
|
@ -1249,7 +1252,7 @@ private:
|
|||
const unit_map::iterator u_end = units_.find(route.back());
|
||||
if(u == units_.end() || u_end != units_.end()) {
|
||||
//this can actually happen if the scenario designer has abused the [allow_undo] command
|
||||
LOG_STREAM(err, engine) << "Illegal 'undo' found. Possible abuse of [allow_undo]?\n";
|
||||
ERR_NG << "Illegal 'undo' found. Possible abuse of [allow_undo]?\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1310,7 +1313,7 @@ private:
|
|||
if(action.is_recall()) {
|
||||
player_info *player=gamestate_.get_player(teams_[team_num - 1].save_id());
|
||||
if(!player) {
|
||||
LOG_STREAM(err, engine) << "trying to redo a recall for side " << team_num
|
||||
ERR_NG << "trying to redo a recall for side " << team_num
|
||||
<< ", which has no recall list!\n";
|
||||
} else {
|
||||
// Redo recall
|
||||
|
@ -1344,7 +1347,7 @@ private:
|
|||
const std::set<std::string>& recruits = current_team.recruits();
|
||||
for(std::set<std::string>::const_iterator r = recruits.begin(); ; ++r) {
|
||||
if (r == recruits.end()) {
|
||||
LOG_STREAM(err, engine) << "trying to redo a recruit for side " << team_num
|
||||
ERR_NG << "trying to redo a recruit for side " << team_num
|
||||
<< ", which does not recruit type \"" << name << "\"\n";
|
||||
wassert(0);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#define DBG_DP LOG_STREAM(debug, display)
|
||||
#define LOG_DP LOG_STREAM(info, display)
|
||||
#define ERR_DP LOG_STREAM(err, display)
|
||||
|
||||
namespace {
|
||||
const int XDim = 1024;
|
||||
|
@ -110,7 +111,7 @@ static std::string resolve_rect(const std::string& rect_str) {
|
|||
resolved << "," << rect.y2;
|
||||
}
|
||||
|
||||
// std::cerr << "Rect " << rect_str << "\t: " << resolved.str() << "\n";
|
||||
// DBG_DP << "Rect " << rect_str << "\t: " << resolved.str() << "\n";
|
||||
|
||||
ref_rect = rect;
|
||||
return resolved.str();
|
||||
|
@ -126,7 +127,7 @@ static config& find_ref(const std::string& id, config& cfg, bool remove = false)
|
|||
for (config::child_list::const_iterator j = i->second.begin();
|
||||
j != i->second.end(); j++) {
|
||||
if ((**j)["id"] == id) {
|
||||
//std::cerr << "Found a " << *(*i).first << "\n";
|
||||
//DBG_DP << "Found a " << *(*i).first << "\n";
|
||||
if (remove) {
|
||||
const config* const res = cfg.find_child((*i).first,"id",id);
|
||||
const size_t index = std::find((*i).second.begin(), (*i).second.end(),
|
||||
|
@ -243,15 +244,15 @@ static void do_resolve_rects(const config& cfg, config& resolved_config, config*
|
|||
// override default reference rect with "ref" parameter if any
|
||||
if (!cfg["ref"].empty()) {
|
||||
if (resol_cfg == NULL) {
|
||||
std::cerr << "Use of ref= outside a [resolution] block\n";
|
||||
ERR_DP << "Use of ref= outside a [resolution] block\n";
|
||||
} else {
|
||||
//std::cerr << ">> Looking for " << cfg["ref"] << "\n";
|
||||
//DBG_DP << ">> Looking for " << cfg["ref"] << "\n";
|
||||
const config ref = find_ref (cfg["ref"], *resol_cfg);
|
||||
|
||||
if (ref["id"].empty()) {
|
||||
std::cerr << "Reference to non-existent rect id \"" << cfg["ref"] << "\"\n";
|
||||
ERR_DP << "Reference to non-existent rect id \"" << cfg["ref"] << "\"\n";
|
||||
} else if (ref["rect"].empty()) {
|
||||
std::cerr << "Reference to id \"" << cfg["ref"] <<
|
||||
ERR_DP << "Reference to id \"" << cfg["ref"] <<
|
||||
"\" which does not have a \"rect\"\n";
|
||||
} else {
|
||||
ref_rect = read_rect(ref);
|
||||
|
|
Loading…
Add table
Reference in a new issue