wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src actions.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src actions.cpp
Date: Sun, 19 Sep 2004 07:59:43 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/09/19 11:53:39

Modified files:
        src            : actions.cpp 

Log message:
        Switched to the new logging system. It's slowly becomming a lot nicer.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/actions.cpp.diff?tr1=1.154&tr2=1.155&r1=text&r2=text

Patches:
Index: wesnoth/src/actions.cpp
diff -u wesnoth/src/actions.cpp:1.154 wesnoth/src/actions.cpp:1.155
--- wesnoth/src/actions.cpp:1.154       Tue Aug 31 02:02:37 2004
+++ wesnoth/src/actions.cpp     Sun Sep 19 11:53:39 2004
@@ -1,4 +1,4 @@
-/* $Id: actions.cpp,v 1.154 2004/08/31 02:02:37 Sirp Exp $ */
+/* $Id: actions.cpp,v 1.155 2004/09/19 11:53:39 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -36,6 +36,9 @@
 #include <string>
 #include <sstream>
 
+#define LOG_NG lg::info(lg::engine)
+#define ERR_NW lg::err(lg::network)
+
 struct castle_cost_calculator
 {
        castle_cost_calculator(const gamemap& map) : map_(map)
@@ -77,7 +80,7 @@
 {
        const command_disabler disable_commands(disp);
 
-       std::cerr << "recruiting unit for side " << side << "\n";
+       LOG_NG << "recruiting unit for side " << side << "\n";
        typedef std::map<gamemap::location,unit> units_map;
 
        //find the unit that can recruit
@@ -93,7 +96,7 @@
                return _("You don't have a leader to recruit with.");
 
        if(map.is_keep(u->first) == false) {
-               std::cerr << "Leader not on start: leader is on " << 
(u->first.x+1) << "," << (u->first.y+1) << "\n";
+               LOG_NG << "Leader not on start: leader is on " << 
(u->first.x+1) << "," << (u->first.y+1) << "\n";
                return _("You must have your leader on a keep to recruit or 
recall units.");
        }
 
@@ -130,7 +133,7 @@
        units.insert(std::pair<gamemap::location,unit>(
                                                        
recruit_location,new_unit));
 
-       std::cerr << "firing recruit event\n";
+       LOG_NG << "firing recruit event\n";
        game_events::fire("recruit",recruit_location);
 
        if(show) {
@@ -585,7 +588,7 @@
        static const std::string poison_string("poison");
 
        while(stats.nattacks > 0 || stats.ndefends > 0) {
-               std::cerr << "start of attack loop...\n";
+               LOG_NG << "start of attack loop...\n";
 
                if(stats.nattacks > 0 && stats.defender_strikes_first == false) 
{
                        const int ran_num = get_random();
@@ -600,24 +603,29 @@
                                const int results_damage = 
atoi((*ran_results)["damage"].c_str());
 
                                if(results_chance != 
stats.chance_to_hit_defender) {
-                                       std::cerr << "SYNC ERROR: In attack " 
<< a->second.type().name() << " vs "
-                                                 << d->second.type().name() << 
": chance to hit defender is inconsistent. Data source: "
-                                                         << results_chance << 
"; Calculation: " << stats.chance_to_hit_defender
-                                                         << " (over-riding 
game calculations with data source results)\n";
+                                       ERR_NW << "SYNC: In attack " << 
a->second.type().name() << " vs "
+                                               << d->second.type().name()
+                                               << ": chance to hit defender is 
inconsistent. Data source: "
+                                               << results_chance << "; 
Calculation: " << stats.chance_to_hit_defender
+                                               << " (over-riding game 
calculations with data source results)\n";
                                        hits = results_hits;
                                } else if(hits != results_hits) {
-                                       std::cerr << "SYNC ERROR: In attack " 
<< a->second.type().name() << " vs "
-                                                 << d->second.type().name() << 
": the data source says the hit was "
-                                                         << (results_hits ? 
"successful" : "unsuccessful") << ", while in-game calculations say the hit was 
"
-                                                         << (hits ? 
"successful" : "unsuccessful")
-                                                         << " random number: " 
<< ran_num << " = " << (ran_num%100) << "/" << results_chance
-                                                         << " (over-riding 
game calculations with data source results)\n";
+                                       ERR_NW << "SYNC: In attack " << 
a->second.type().name() << " vs "
+                                               << d->second.type().name() << 
": the data source says the hit was "
+                                               << (results_hits ? "successful" 
: "unsuccessful")
+                                               << ", while in-game 
calculations say the hit was "
+                                               << (hits ? "successful" : 
"unsuccessful")
+                                               << " random number: " << 
ran_num << " = "
+                                               << (ran_num%100) << "/" << 
results_chance
+                                               << " (over-riding game 
calculations with data source results)\n";
                                        hits = results_hits;
                                } else if(results_damage != 
stats.damage_defender_takes) {
-                                       std::cerr << "SYNC ERROR: In attack " 
<< a->second.type().name() << " vs "
-                                                 << d->second.type().name() << 
": the data source says the hit did "
-                                                         << results_damage << 
" damage, while in-game calculations show the hit doing "
-                                                         << 
stats.damage_defender_takes << " damage (over-riding game calculations with 
data source results)\n";
+                                       ERR_NW << "SYNC: In attack " << 
a->second.type().name() << " vs "
+                                               << d->second.type().name() << 
": the data source says the hit did "
+                                               << results_damage
+                                               << " damage, while in-game 
calculations show the hit doing "
+                                               << stats.damage_defender_takes
+                                               << " damage (over-riding game 
calculations with data source results)\n";
                                        stats.damage_defender_takes = 
results_damage;
                                }
                        }
@@ -626,13 +634,13 @@
                                            hits ? stats.damage_defender_takes 
: 0,
                                                        
a->second.attacks()[attack_with]);
 
-                       std::cerr << "done attacking\n";
+                       LOG_NG << "done attacking\n";
 
                        attack_stats.attack_result(hits ? (dies ? 
statistics::attack_context::KILLS : statistics::attack_context::HITS)
                                                   : 
statistics::attack_context::MISSES);
 
                        if(ran_results == NULL) {
-                               log_scope("setting random results");
+                               log_scope2(engine, "setting random results");
                                config cfg;
                                cfg["hits"] = (hits ? "yes" : "no");
                                cfg["dies"] = (dies ? "yes" : "no");
@@ -644,10 +652,12 @@
                        } else {
                                const bool results_dies = 
(*ran_results)["dies"] == "yes";
                                if(results_dies != dies) {
-                                       std::cerr << "SYNC ERROR: In attack" << 
a->second.type().name() << " vs "
-                                                 << d->second.type().name() << 
": the data source the unit "
-                                                         << (results_dies ? 
"perished" : "survived") << " while in-game calculations show the unit "
-                                                         << (dies ? "perished" 
: "survived") << " (over-riding game calculations with data source results)\n";
+                                       ERR_NW << "SYNC: In attack" << 
a->second.type().name() << " vs "
+                                               << d->second.type().name() << 
": the data source the unit "
+                                               << (results_dies ? "perished" : 
"survived")
+                                               << " while in-game calculations 
show the unit "
+                                               << (dies ? "perished" : 
"survived")
+                                               << " (over-riding game 
calculations with data source results)\n";
                                        dies = results_dies;
                                }
                        }
@@ -674,7 +684,7 @@
                                gamemap::location loc = d->first;
                                gamemap::location attacker_loc = a->first;
                                const int defender_side = d->second.side();
-                               std::cerr << "firing die event\n";
+                               LOG_NG << "firing die event\n";
                                game_events::fire("die",loc,a->first);
                                d = units.end();
                                a = units.end();
@@ -729,7 +739,7 @@
                stats.defender_strikes_first = false;
 
                if(stats.ndefends > 0) {
-                       std::cerr << "doing defender attack...\n";
+                       LOG_NG << "doing defender attack...\n";
 
                        const int ran_num = get_random();
                        bool hits = (ran_num%100) < 
stats.chance_to_hit_attacker;
@@ -743,24 +753,29 @@
                                const int results_damage = 
atoi((*ran_results)["damage"].c_str());
 
                                if(results_chance != 
stats.chance_to_hit_attacker) {
-                                       std::cerr << "SYNC ERROR: In defend " 
<< a->second.type().name() << " vs "
-                                                 << d->second.type().name() << 
": chance to hit attacker is inconsistent. Data source: "
-                                                         << results_chance << 
"; Calculation: " << stats.chance_to_hit_attacker
-                                                         << " (over-riding 
game calculations with data source results)\n";
+                                       ERR_NW << "SYNC: In defend " << 
a->second.type().name() << " vs "
+                                               << d->second.type().name()
+                                               << ": chance to hit attacker is 
inconsistent. Data source: "
+                                               << results_chance << "; 
Calculation: " << stats.chance_to_hit_attacker
+                                               << " (over-riding game 
calculations with data source results)\n";
                                        hits = results_hits;
                                } else if(hits != results_hits) {
-                                       std::cerr << "SYNC ERROR: In defend " 
<< a->second.type().name() << " vs "
-                                                 << d->second.type().name() << 
": the data source says the hit was "
-                                                         << (results_hits ? 
"successful" : "unsuccessful") << ", while in-game calculations say the hit was 
"
-                                                         << (hits ? 
"successful" : "unsuccessful")
-                                                         << " random number: " 
<< ran_num << " = " << (ran_num%100) << "/" << results_chance
-                                                         << " (over-riding 
game calculations with data source results)\n";
+                                       ERR_NW << "SYNC: In defend " << 
a->second.type().name() << " vs "
+                                               << d->second.type().name() << 
": the data source says the hit was "
+                                               << (results_hits ? "successful" 
: "unsuccessful")
+                                               << ", while in-game 
calculations say the hit was "
+                                               << (hits ? "successful" : 
"unsuccessful")
+                                               << " random number: " << 
ran_num << " = " << (ran_num%100) << "/"
+                                               << results_chance
+                                               << " (over-riding game 
calculations with data source results)\n";
                                        hits = results_hits;
                                } else if(results_damage != 
stats.damage_attacker_takes) {
-                                       std::cerr << "SYNC ERROR: In defend " 
<< a->second.type().name() << " vs "
-                                                 << d->second.type().name() << 
": the data source says the hit did "
-                                                         << results_damage << 
" damage, while in-game calculations show the hit doing "
-                                                         << 
stats.damage_attacker_takes << " damage (over-riding game calculations with 
data source results)\n";
+                                       ERR_NW << "SYNC: In defend " << 
a->second.type().name() << " vs "
+                                               << d->second.type().name() << 
": the data source says the hit did "
+                                               << results_damage
+                                               << " damage, while in-game 
calculations show the hit doing "
+                                               << stats.damage_attacker_takes
+                                               << " damage (over-riding game 
calculations with data source results)\n";
                                        stats.damage_attacker_takes = 
results_damage;
                                }
                        }
@@ -783,10 +798,12 @@
                        } else {
                                const bool results_dies = 
(*ran_results)["dies"] == "yes";
                                if(results_dies != dies) {
-                                       std::cerr << "SYNC ERROR: In defend" << 
a->second.type().name() << " vs "
-                                                 << d->second.type().name() << 
": the data source the unit "
-                                                         << (results_dies ? 
"perished" : "survived") << " while in-game calculations show the unit "
-                                                         << (dies ? "perished" 
: "survived") << " (over-riding game calculations with data source results)\n";
+                                       ERR_NW << "SYNC: In defend" << 
a->second.type().name() << " vs "
+                                               << d->second.type().name() << 
": the data source the unit "
+                                               << (results_dies ? "perished" : 
"survived")
+                                               << " while in-game calculations 
show the unit "
+                                               << (dies ? "perished" : 
"survived")
+                                               << " (over-riding game 
calculations with data source results)\n";
                                        dies = results_dies;
                                }
                        }
@@ -1174,7 +1191,8 @@
 
                const int DelayAmount = 50;
 
-               std::cerr << "unit is poisoned? " << (u.has_flag("poisoned") ? 
"yes" : "no") << "," << h->second << "," << max_healing[h->first] << "\n";
+               LOG_NG << "unit is poisoned? " << (u.has_flag("poisoned") ? 
"yes" : "no") << ","
+                       << h->second << "," << max_healing[h->first] << "\n";
 
                if(u.has_flag("poisoned") && h->second > 0) {
 
@@ -1307,7 +1325,7 @@
        for(std::map<gamemap::location,unit>::const_iterator i = units.begin();
            i != units.end(); ++i) {
                if(i->second.can_recruit()) {
-                       std::cerr << "seen leader for side " << 
i->second.side() << "\n";
+                       LOG_NG << "seen leader for side " << i->second.side() 
<< "\n";
                        seen_leaders.push_back(i->second.side());
                }
        }
@@ -1357,7 +1375,7 @@
                        std::cout << "\n";
                }
 
-               std::cerr << "throwing end level exception...\n";
+               LOG_NG << "throwing end level exception...\n";
                throw end_level_exception(found_human ? VICTORY : DEFEAT);
        }
 
@@ -1604,7 +1622,7 @@
                //which case we should stop immediately.
                if(check_shroud) {
                        if(units.count(*step) == 0 && !map.is_village(*step)) {
-                               std::cerr << "checking for units from " << 
(step->x+1) << "," << (step->y+1) << "\n";
+                               LOG_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);
@@ -1725,7 +1743,7 @@
                        //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) {
-                               std::cerr << "processing unit at " << (i->x+1) 
<< "," << (i->y+1) << "\n";
+                               LOG_NG << "processing unit at " << (i->x+1) << 
"," << (i->y+1) << "\n";
                                const unit_map::const_iterator u = 
units.find(*i);
                                assert(u != units.end());
                                if(team.is_enemy(u->second.side())) {
@@ -1734,7 +1752,7 @@
                                        ++nfriends;
                                }
 
-                               std::cerr << "processed...\n";
+                               LOG_NG << "processed...\n";
                        }
 
                        char* msg_id;
@@ -1780,10 +1798,8 @@
                                        msg << '\n' << _("(press $hotkey to 
continue)");
                                }
                        }
-                       std::cerr << "formatting string...\n";
                        const std::string message = 
config::interpolate_variables_into_string(msg.str(),&symbols);
 
-                       std::cerr << "displaying label...\n";
                        font::add_floating_label(message,24,font::BAD_COLOUR,
                                                 
disp->map_area().w/2,disp->map_area().h/3,
                                                                         
0.0,0.0,100,disp->map_area(),font::CENTER_ALIGN);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]