Added wassert(), a assert()-like function forcing a crash.
Replaced every assert() with wassert()
This commit is contained in:
parent
46c0883151
commit
a1214b626d
40 changed files with 143 additions and 121 deletions
|
@ -90,6 +90,7 @@ wesnoth_SOURCES = about.cpp \
|
|||
unit_display.cpp \
|
||||
unit_types.cpp \
|
||||
video.cpp \
|
||||
wassert.cpp \
|
||||
widgets/button.cpp \
|
||||
widgets/combo.cpp \
|
||||
widgets/label.cpp \
|
||||
|
@ -171,6 +172,7 @@ wesnoth_SOURCES = about.cpp \
|
|||
unit_types.hpp \
|
||||
util.hpp \
|
||||
video.hpp \
|
||||
wassert.hpp \
|
||||
widgets/button.hpp \
|
||||
widgets/combo.hpp \
|
||||
widgets/label.hpp \
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "statistics.hpp"
|
||||
#include "unit_display.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
#include "widgets/menu.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
@ -204,8 +205,8 @@ battle_stats evaluate_battle_stats(const gamemap& map,
|
|||
const std::map<gamemap::location,unit>::iterator a = units.find(attacker);
|
||||
const std::map<gamemap::location,unit>::iterator d = units.find(defender);
|
||||
|
||||
assert(a != units.end());
|
||||
assert(d != units.end());
|
||||
wassert(a != units.end());
|
||||
wassert(d != units.end());
|
||||
|
||||
const gamemap::TERRAIN attacker_terrain = attacker_terrain_override ?
|
||||
attacker_terrain_override : map[attacker.x][attacker.y];
|
||||
|
@ -217,7 +218,7 @@ battle_stats evaluate_battle_stats(const gamemap& map,
|
|||
const std::vector<attack_type>& attacker_attacks = a->second.attacks();
|
||||
const std::vector<attack_type>& defender_attacks = d->second.attacks();
|
||||
|
||||
assert((unsigned)attack_with < attacker_attacks.size());
|
||||
wassert((unsigned)attack_with < attacker_attacks.size());
|
||||
const attack_type& attack = attacker_attacks[attack_with];
|
||||
res.attacker_special = attack.special();
|
||||
|
||||
|
@ -1107,7 +1108,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
|||
if(!gets_healed[j])
|
||||
continue;
|
||||
|
||||
assert(units.find(adjacent[j]) != units.end());
|
||||
wassert(units.find(adjacent[j]) != units.end());
|
||||
|
||||
healed_units[adjacent[j]]
|
||||
= minimum(max_healing[adjacent[j]],
|
||||
|
@ -1155,7 +1156,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
|||
|
||||
const gamemap::location& loc = h->first;
|
||||
|
||||
assert(units.count(loc) == 1);
|
||||
wassert(units.count(loc) == 1);
|
||||
|
||||
unit& u = units.find(loc)->second;
|
||||
|
||||
|
@ -1176,7 +1177,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
|||
//iterate over any units that are healing this unit, and make them
|
||||
//enter their healing frame
|
||||
for(healer_itor i = healer_itors.first; i != healer_itors.second; ++i) {
|
||||
assert(units.count(i->second));
|
||||
wassert(units.count(i->second));
|
||||
unit& healer = units.find(i->second)->second;
|
||||
|
||||
const std::string& halo_image = healer.type().image_halo_healing();
|
||||
|
@ -1279,7 +1280,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
|||
|
||||
if(show_healing) {
|
||||
for(healer_itor i = healer_itors.first; i != healer_itors.second; ++i) {
|
||||
assert(units.count(i->second));
|
||||
wassert(units.count(i->second));
|
||||
unit& healer = units.find(i->second)->second;
|
||||
healer.set_healing(false);
|
||||
|
||||
|
@ -1351,7 +1352,7 @@ void check_victory(std::map<gamemap::location,unit>& units,
|
|||
for(size_t n = 0; n != seen_leaders.size(); ++n) {
|
||||
const size_t side = seen_leaders[n]-1;
|
||||
|
||||
assert(side < teams.size());
|
||||
wassert(side < teams.size());
|
||||
|
||||
for(size_t m = n+1; m != seen_leaders.size(); ++m) {
|
||||
if(side < teams.size() && teams[side].is_enemy(seen_leaders[m])) {
|
||||
|
@ -1574,14 +1575,14 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
replay* move_recorder, undo_list* undo_stack,
|
||||
gamemap::location *next_unit, bool continue_move, bool should_clear_shroud)
|
||||
{
|
||||
assert(route.empty() == false);
|
||||
wassert(route.empty() == false);
|
||||
|
||||
//stop the user from issuing any commands while the unit is moving
|
||||
const command_disabler disable_commands;
|
||||
|
||||
unit_map::iterator ui = units.find(route.front());
|
||||
|
||||
assert(ui != units.end());
|
||||
wassert(ui != units.end());
|
||||
|
||||
ui->second.set_goto(gamemap::location());
|
||||
|
||||
|
@ -1680,7 +1681,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
steps.pop_back();
|
||||
}
|
||||
|
||||
assert(steps.size() <= route.size());
|
||||
wassert(steps.size() <= route.size());
|
||||
|
||||
if (next_unit != NULL)
|
||||
*next_unit = steps.back();
|
||||
|
@ -1756,7 +1757,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
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";
|
||||
const unit_map::const_iterator u = units.find(*i);
|
||||
assert(u != units.end());
|
||||
wassert(u != units.end());
|
||||
if(team.is_enemy(u->second.side())) {
|
||||
++nenemies;
|
||||
} else {
|
||||
|
@ -1818,7 +1819,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
game_events::fire("sighted",*seen,steps.back());
|
||||
}
|
||||
|
||||
assert(steps.size() <= route.size());
|
||||
wassert(steps.size() <= route.size());
|
||||
|
||||
return steps.size();
|
||||
}
|
||||
|
@ -1827,7 +1828,7 @@ bool unit_can_move(const gamemap::location& loc, const unit_map& units,
|
|||
const gamemap& map, const std::vector<team>& teams)
|
||||
{
|
||||
const unit_map::const_iterator u_it = units.find(loc);
|
||||
assert(u_it != units.end());
|
||||
wassert(u_it != units.end());
|
||||
|
||||
const unit& u = u_it->second;
|
||||
const team& current_team = teams[u.side()-1];
|
||||
|
|
11
src/ai.cpp
11
src/ai.cpp
|
@ -32,6 +32,7 @@
|
|||
#include "statistics.hpp"
|
||||
#include "unit_display.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -103,7 +104,7 @@ private:
|
|||
|
||||
int choose_weapon(const location& attacker, const location& defender) {
|
||||
const unit_map::const_iterator att = get_info().units.find(attacker);
|
||||
assert(att != get_info().units.end());
|
||||
wassert(att != get_info().units.end());
|
||||
|
||||
const std::vector<attack_type>& attacks = att->second.attacks();
|
||||
|
||||
|
@ -349,7 +350,7 @@ gamemap::location ai_interface::move_unit(location from, location to, std::map<l
|
|||
//stop the user from issuing any commands while the unit is moving
|
||||
const command_disabler disable_commands;
|
||||
|
||||
assert(info_.units.find(to) == info_.units.end() || from == to);
|
||||
wassert(info_.units.find(to) == info_.units.end() || from == to);
|
||||
|
||||
info_.disp.select_hex(from);
|
||||
info_.disp.update_display();
|
||||
|
@ -358,7 +359,7 @@ gamemap::location ai_interface::move_unit(location from, location to, std::map<l
|
|||
unit_map::iterator u_it = info_.units.find(from);
|
||||
if(u_it == info_.units.end()) {
|
||||
lg::err(lg::ai) << "Could not find unit at " << from.x << ", " << from.y << "\n";
|
||||
assert(false);
|
||||
wassert(false);
|
||||
return location();
|
||||
}
|
||||
|
||||
|
@ -1275,7 +1276,7 @@ bool ai::move_to_targets(std::map<gamemap::location,paths>& possible_moves, move
|
|||
LOG_AI << "choosing move...\n";
|
||||
std::pair<location,location> move = choose_move(targets,srcdst,dstsrc,enemy_srcdst,enemy_dstsrc);
|
||||
for(std::vector<target>::const_iterator ittg = targets.begin(); ittg != targets.end(); ++ittg) {
|
||||
assert(map_.on_board(ittg->loc));
|
||||
wassert(map_.on_board(ittg->loc));
|
||||
}
|
||||
|
||||
if(move.first.valid() == false) {
|
||||
|
@ -1621,7 +1622,7 @@ void ai::do_recruitment()
|
|||
const std::vector<std::string>& options = current_team().recruitment_pattern();
|
||||
|
||||
if(options.empty()) {
|
||||
assert(false);
|
||||
wassert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#include "log.hpp"
|
||||
#include "pathfind.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
@ -67,7 +67,7 @@ void ai::do_attack_analysis(
|
|||
double rating_to_beat = cur_rating;
|
||||
|
||||
if(!cur_analysis.movements.empty()) {
|
||||
assert(cur_analysis.movements.size() < 6);
|
||||
wassert(cur_analysis.movements.size() < 6);
|
||||
double& best_res = best_results[cur_analysis.movements.size()-1];
|
||||
rating_to_beat = best_res = maximum(best_res,cur_rating);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void ai::do_attack_analysis(
|
|||
const location current_unit = units[i];
|
||||
|
||||
const unit_map::const_iterator unit_itor = units_.find(current_unit);
|
||||
assert(unit_itor != units_.end());
|
||||
wassert(unit_itor != units_.end());
|
||||
|
||||
//see if the unit has the backstab ability -- units with backstab
|
||||
//will want to try to have a friendly unit opposite the position they move to
|
||||
|
@ -251,7 +251,7 @@ int ai::choose_weapon(const location& att, const location& def,
|
|||
const std::set<battle_type>::const_iterator cache_itor = weapon_choice_cache.find(battle);
|
||||
|
||||
if(cache_itor != weapon_choice_cache.end()) {
|
||||
assert(*cache_itor == battle);
|
||||
wassert(*cache_itor == battle);
|
||||
|
||||
++cache_hits;
|
||||
cur_stats = cache_itor->stats;
|
||||
|
@ -261,7 +261,7 @@ int ai::choose_weapon(const location& att, const location& def,
|
|||
<< "/" << itor->second.attacks().size() << "\n";
|
||||
}
|
||||
|
||||
assert(size_t(cache_itor->weapon) < itor->second.attacks().size());
|
||||
wassert(size_t(cache_itor->weapon) < itor->second.attacks().size());
|
||||
return cache_itor->weapon;
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ int ai::choose_weapon(const location& att, const location& def,
|
|||
int current_choice = -1;
|
||||
double current_rating = 0.0;
|
||||
const std::vector<attack_type>& attacks = itor->second.attacks();
|
||||
assert(!attacks.empty());
|
||||
wassert(!attacks.empty());
|
||||
|
||||
const unit_map::const_iterator d_itor = units_.find(def);
|
||||
int d_hitpoints = d_itor->second.hitpoints();
|
||||
|
@ -297,7 +297,7 @@ int ai::choose_weapon(const location& att, const location& def,
|
|||
}
|
||||
}
|
||||
|
||||
assert(size_t(current_choice) < attacks.size());
|
||||
wassert(size_t(current_choice) < attacks.size());
|
||||
|
||||
battle.stats = cur_stats;
|
||||
battle.weapon = current_choice;
|
||||
|
@ -311,7 +311,7 @@ void ai::attack_analysis::analyze(const gamemap& map, unit_map& units, int num_s
|
|||
const ai::move_map& enemy_dstsrc, const ai::move_map& enemy_srcdst)
|
||||
{
|
||||
const unit_map::const_iterator defend_it = units.find(target);
|
||||
assert(defend_it != units.end());
|
||||
wassert(defend_it != units.end());
|
||||
|
||||
//see if the target is a threat to our leader or an ally's leader
|
||||
gamemap::location adj[6];
|
||||
|
@ -354,7 +354,7 @@ void ai::attack_analysis::analyze(const gamemap& map, unit_map& units, int num_s
|
|||
battle_stats bat_stats;
|
||||
const int weapon = ai_obj.choose_weapon(m->first,target, bat_stats, map[m->second.x][m->second.y],true);
|
||||
|
||||
assert(weapon != -1);
|
||||
wassert(weapon != -1);
|
||||
weapons.push_back(weapon);
|
||||
|
||||
stats.push_back(bat_stats);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "log.hpp"
|
||||
#include "map.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -67,7 +68,7 @@ struct move_cost_calculator : cost_calculator
|
|||
if(units_.count(loc))
|
||||
res *= 4.0;
|
||||
|
||||
assert(res > 0);
|
||||
wassert(res > 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ std::vector<ai::target> ai::find_targets(unit_map::const_iterator leader, const
|
|||
}
|
||||
}
|
||||
|
||||
assert(threats.empty() == false);
|
||||
wassert(threats.empty() == false);
|
||||
|
||||
const double value = threat/double(threats.size());
|
||||
for(std::set<gamemap::location>::const_iterator i = threats.begin(); i != threats.end(); ++i) {
|
||||
|
@ -122,7 +123,7 @@ std::vector<ai::target> ai::find_targets(unit_map::const_iterator leader, const
|
|||
if(has_leader && current_team().village_value() > 0.0) {
|
||||
const std::vector<location>& villages = map_.villages();
|
||||
for(std::vector<location>::const_iterator t = villages.begin(); t != villages.end(); ++t) {
|
||||
assert(map_.on_board(*t));
|
||||
wassert(map_.on_board(*t));
|
||||
bool get_village = true;
|
||||
for(size_t i = 0; i != teams_.size(); ++i) {
|
||||
if(!current_team().is_enemy(i+1) && teams_[i].owns_village(*t)) {
|
||||
|
@ -145,7 +146,7 @@ std::vector<ai::target> ai::find_targets(unit_map::const_iterator leader, const
|
|||
|
||||
//is an enemy leader
|
||||
if(u->second.can_recruit() && current_team().is_enemy(u->second.side())) {
|
||||
assert(map_.on_board(u->first));
|
||||
wassert(map_.on_board(u->first));
|
||||
targets.push_back(target(u->first,current_team().leader_value(),target::LEADER));
|
||||
}
|
||||
|
||||
|
@ -177,7 +178,7 @@ std::vector<ai::target> ai::find_targets(unit_map::const_iterator leader, const
|
|||
}
|
||||
}
|
||||
|
||||
assert(new_values.size() == targets.size());
|
||||
wassert(new_values.size() == targets.size());
|
||||
for(size_t n = 0; n != new_values.size(); ++n) {
|
||||
LOG_AI << "target value: " << targets[n].value << " -> " << new_values[n] << "\n";
|
||||
targets[n].value = new_values[n];
|
||||
|
@ -385,7 +386,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
|
||||
std::vector<target>::const_iterator ittg;
|
||||
for(ittg = targets.begin(); ittg != targets.end(); ++ittg) {
|
||||
assert(map_.on_board(ittg->loc));
|
||||
wassert(map_.on_board(ittg->loc));
|
||||
}
|
||||
|
||||
paths::route best_route;
|
||||
|
@ -423,7 +424,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
|
||||
user_interact();
|
||||
|
||||
assert(map_.on_board(tg->loc));
|
||||
wassert(map_.on_board(tg->loc));
|
||||
const paths::route cur_route = a_star_search(u->first,tg->loc,
|
||||
minimum(tg->value/best_rating,500.0), &cost_calc);
|
||||
|
||||
|
@ -532,10 +533,10 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
|
||||
LOG_AI << "best unit: " << (best->first.x+1) << "," << (best->first.y+1) << "\n";
|
||||
|
||||
assert(best_target >= targets.begin() && best_target < targets.end());
|
||||
wassert(best_target >= targets.begin() && best_target < targets.end());
|
||||
|
||||
for(ittg = targets.begin(); ittg != targets.end(); ++ittg) {
|
||||
assert(map_.on_board(ittg->loc));
|
||||
wassert(map_.on_board(ittg->loc));
|
||||
}
|
||||
|
||||
//if our target is a position to support, then we
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "log.hpp"
|
||||
#include "terrain.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#define ERR_NG lg::err(lg::engine)
|
||||
|
||||
|
@ -122,14 +123,14 @@ bool terrain_builder::tilemap::on_map(const gamemap::location &loc) const
|
|||
|
||||
terrain_builder::tile& terrain_builder::tilemap::operator[](const gamemap::location &loc)
|
||||
{
|
||||
assert(on_map(loc));
|
||||
wassert(on_map(loc));
|
||||
|
||||
return map_[(loc.x+1) + (loc.y+1)*(x_+2)];
|
||||
}
|
||||
|
||||
const terrain_builder::tile& terrain_builder::tilemap::operator[] (const gamemap::location &loc) const
|
||||
{
|
||||
assert(on_map(loc));
|
||||
wassert(on_map(loc));
|
||||
|
||||
return map_[(loc.x+1) + (loc.y+1)*(x_+2)];
|
||||
}
|
||||
|
@ -331,7 +332,7 @@ terrain_builder::terrain_constraint terrain_builder::rotate(const terrain_builde
|
|||
{ 1./2. , 3./4., -1., 1./2. },
|
||||
};
|
||||
|
||||
assert(angle >= 0);
|
||||
wassert(angle >= 0);
|
||||
|
||||
angle %= 6;
|
||||
terrain_constraint ret = constraint;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "log.hpp"
|
||||
#include "pathfind.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#define LOG_NG lg::info(lg::engine)
|
||||
|
||||
|
@ -188,7 +189,7 @@ void cave_map_generator::generate_chambers()
|
|||
if(itor == chamber_ids_.end())
|
||||
continue;
|
||||
|
||||
assert(itor->second < chambers_.size());
|
||||
wassert(itor->second < chambers_.size());
|
||||
|
||||
passages_.push_back(passage(new_chamber.center,chambers_[itor->second].center,**p));
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "global.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
@ -29,6 +28,7 @@
|
|||
#include "gettext.hpp"
|
||||
#include "log.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
#include "wesconfig.h"
|
||||
|
||||
#define ERR_CF lg::err(lg::config)
|
||||
|
@ -500,7 +500,7 @@ void config::read(const std::string& data,
|
|||
case ELEMENT_NAME:
|
||||
if(c == ']') {
|
||||
if(value == "end" || value.empty() == false && value[0] == '/') {
|
||||
assert(!elements.empty());
|
||||
wassert(!elements.empty());
|
||||
|
||||
if(value[0] == '/' &&
|
||||
std::string("/" + element_names.top()) != value) {
|
||||
|
@ -832,7 +832,7 @@ std::string config::write() const
|
|||
res.resize(write_size());
|
||||
|
||||
const std::string::iterator i = write_internal(res.begin());
|
||||
assert(i == res.end());
|
||||
wassert(i == res.end());
|
||||
if(i != res.end()) {
|
||||
ERR_CF << "size of config buffer: " << (i - res.begin()) << "/" << res.size() << "\n";
|
||||
}
|
||||
|
@ -1176,7 +1176,7 @@ void config::remove_child(const std::string& key, size_t index)
|
|||
|
||||
//remove from the child map
|
||||
child_list& v = children[key];
|
||||
assert(index < v.size());
|
||||
wassert(index < v.size());
|
||||
config* const res = v[index];
|
||||
v.erase(v.begin()+index);
|
||||
delete res;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#ifndef CONFIG_HPP_INCLUDED
|
||||
#define CONFIG_HPP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "replay.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
#include "widgets/menu.hpp"
|
||||
#include "widgets/progressbar.hpp"
|
||||
|
||||
|
@ -214,7 +215,7 @@ gui::dialog_button_action::RESULT delete_save::button_pressed(int menu_selection
|
|||
NULL,NULL,"",NULL,-1,NULL,&options);
|
||||
|
||||
//see if the user doesn't want to be asked this again
|
||||
assert(options.empty() == false);
|
||||
wassert(options.empty() == false);
|
||||
if(options.front().checked) {
|
||||
preferences::set_ask_delete_saves(false);
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
#include "tooltips.hpp"
|
||||
#include "unit_display.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include "SDL_image.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
@ -1149,7 +1149,7 @@ void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
|
|||
}
|
||||
}
|
||||
|
||||
assert(energy_file != NULL);
|
||||
wassert(energy_file != NULL);
|
||||
if(energy_file == NULL) {
|
||||
ERR_DP << "energy file is NULL\n";
|
||||
return;
|
||||
|
@ -2001,7 +2001,7 @@ void display::write_overlays(config& cfg) const
|
|||
|
||||
void display::set_team(size_t team)
|
||||
{
|
||||
assert(team < teams_.size());
|
||||
wassert(team < teams_.size());
|
||||
currentTeam_ = team;
|
||||
|
||||
labels().recalculate_shroud();
|
||||
|
@ -2009,7 +2009,7 @@ void display::set_team(size_t team)
|
|||
|
||||
void display::set_playing_team(size_t team)
|
||||
{
|
||||
assert(team < teams_.size());
|
||||
wassert(team < teams_.size());
|
||||
activeTeam_ = team;
|
||||
invalidate_game_status();
|
||||
}
|
||||
|
@ -2055,7 +2055,7 @@ void display::set_grid(bool grid)
|
|||
|
||||
void display::debug_highlight(const gamemap::location& loc, double amount)
|
||||
{
|
||||
assert(game_config::debug);
|
||||
wassert(game_config::debug);
|
||||
debugHighlights_[loc] += amount;
|
||||
}
|
||||
|
||||
|
@ -2106,7 +2106,7 @@ const theme::menu* display::menu_pressed()
|
|||
for(std::vector<gui::button>::iterator i = buttons_.begin(); i != buttons_.end(); ++i) {
|
||||
if(i->pressed()) {
|
||||
const size_t index = i - buttons_.begin();
|
||||
assert(index < theme_.menus().size());
|
||||
wassert(index < theme_.menus().size());
|
||||
return &theme_.menus()[index];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "../reports.hpp"
|
||||
#include "../language.hpp"
|
||||
#include "../util.hpp"
|
||||
#include "../wassert.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace map_editor {
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include "mouse.hpp"
|
||||
#include "preferences.hpp"
|
||||
#include "video.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <deque>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
@ -141,7 +141,7 @@ event_context::event_context(bool create) : create_(create)
|
|||
event_context::~event_context()
|
||||
{
|
||||
if(create_) {
|
||||
assert(event_contexts.empty() == false);
|
||||
wassert(event_contexts.empty() == false);
|
||||
|
||||
event_contexts.pop_back();
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ handler::handler() : unicode_(SDL_EnableUNICODE(1))
|
|||
|
||||
handler::~handler()
|
||||
{
|
||||
assert(event_contexts.empty() == false);
|
||||
wassert(event_contexts.empty() == false);
|
||||
|
||||
for(std::deque<context>::reverse_iterator i = event_contexts.rbegin(); i != event_contexts.rend(); ++i) {
|
||||
if(i->remove_handler(this)) {
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "unit_types.hpp"
|
||||
#include "unit.hpp"
|
||||
#include "video.hpp"
|
||||
#include "wassert.hpp"
|
||||
#include "widgets/button.hpp"
|
||||
#include "widgets/menu.hpp"
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "sound.hpp"
|
||||
#include "unit_display.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <deque>
|
||||
|
@ -1010,7 +1011,7 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
|
|||
|
||||
//implement the consequences of the choice
|
||||
if(options.empty() == false) {
|
||||
assert(size_t(option_chosen) < menu_items.size());
|
||||
wassert(size_t(option_chosen) < menu_items.size());
|
||||
|
||||
for(config::const_child_itors events = option_events[option_chosen];
|
||||
events.first != events.second; ++events.first) {
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include "preferences.hpp"
|
||||
#include "sdl_utils.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
|
||||
namespace halo
|
||||
|
@ -55,7 +55,7 @@ effect::effect(int xpos, int ypos, const std::string& img, ORIENTATION orientati
|
|||
: images_(img), reverse_(orientation == REVERSE), origx_(xpos), origy_(ypos), x_(xpos), y_(ypos),
|
||||
origzoom_(disp->zoom()), zoom_(disp->zoom()), surf_(NULL), buffer_(NULL), rect_(empty_rect)
|
||||
{
|
||||
assert(disp != NULL);
|
||||
wassert(disp != NULL);
|
||||
// std::cerr << "Constructing halo sequence from image " << img << "\n";
|
||||
|
||||
set_location(xpos,ypos);
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
#include "show_dialog.hpp"
|
||||
#include "unit.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
#include "widgets/button.hpp"
|
||||
#include "widgets/menu.hpp"
|
||||
#include "widgets/scrollbar.hpp"
|
||||
#include "widgets/widget.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
@ -1204,7 +1204,7 @@ public:
|
|||
preferences::encountered_terrains().begin(),
|
||||
terrain_end = preferences::encountered_terrains().end();
|
||||
terrain_it != terrain_end; terrain_it++) {
|
||||
assert(terrain_it->size() > 0);
|
||||
wassert(terrain_it->size() > 0);
|
||||
const gamemap::TERRAIN terrain = (*terrain_it)[0];
|
||||
if (terrain == gamemap::FOGGED || terrain == gamemap::VOID_TERRAIN)
|
||||
continue;
|
||||
|
@ -1258,7 +1258,7 @@ std::vector<topic> generate_unit_topics() {
|
|||
} else if (desc_type == FULL_DESCRIPTION) {
|
||||
unit_topic.text = new unit_topic_generator(type);
|
||||
} else {
|
||||
assert(false);
|
||||
wassert(false);
|
||||
}
|
||||
topics.push_back(unit_topic);
|
||||
}
|
||||
|
@ -1327,7 +1327,7 @@ std::vector<topic> generate_terrains_topics() {
|
|||
preferences::encountered_terrains().begin();
|
||||
terrain_it != preferences::encountered_terrains().end();
|
||||
terrain_it++) {
|
||||
assert(terrain_it->size() > 0);
|
||||
wassert(terrain_it->size() > 0);
|
||||
const gamemap::TERRAIN terrain = (*terrain_it)[0];
|
||||
show_info_about.push_back(terrain);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "sdl_utils.hpp"
|
||||
#include "team.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include "SDL_image.h"
|
||||
|
||||
|
@ -246,7 +247,7 @@ surface locator::load_from_disk() const
|
|||
default:
|
||||
return surface(NULL);
|
||||
}
|
||||
assert(false);
|
||||
wassert(false);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -595,7 +596,7 @@ locator get_alternative(const image::locator &i_locator, const std::string &alt)
|
|||
res = locator(alternative, i_locator.get_loc());
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
wassert(false);
|
||||
}
|
||||
|
||||
i_locator.add_to_cache(alternative_images_, res);
|
||||
|
@ -691,7 +692,7 @@ surface getMinimap(int w, int h, const gamemap& map, const team* tm)
|
|||
surf = surface(adjust_surface_colour(surf,-50,-50,-50));
|
||||
}
|
||||
|
||||
assert(surf != NULL);
|
||||
wassert(surf != NULL);
|
||||
|
||||
SDL_Rect maprect = {x*scale*3/4,y*scale + (is_odd(x) ? scale/2 : 0),0,0};
|
||||
SDL_BlitSurface(surf, NULL, minimap, &maprect);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "log.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include "map.hpp"
|
||||
#include "pathfind.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
@ -155,7 +155,7 @@ gamemap::location gamemap::location::get_direction(
|
|||
case SOUTH_WEST: return gamemap::location(x-1,y+is_odd(x));
|
||||
case NORTH_WEST: return gamemap::location(x-1,y-is_even(x));
|
||||
default:
|
||||
assert(false);
|
||||
wassert(false);
|
||||
return gamemap::location();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "scoped_resource.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -485,7 +486,7 @@ void play_multiplayer_client(display& disp, game_data& units_data, config& cfg,
|
|||
leader = leader_selector.get_selected_leader();
|
||||
}
|
||||
|
||||
assert(choice < possible_sides.size());
|
||||
wassert(choice < possible_sides.size());
|
||||
|
||||
const config& chosen_side = *possible_sides[choice];
|
||||
team_name = response["name"] = chosen_side["name"];
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "replay.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
#include "widgets/textbox.hpp"
|
||||
#include "widgets/button.hpp"
|
||||
#include "widgets/combo.hpp"
|
||||
|
@ -146,7 +147,7 @@ int mp_connect::load_map(const std::string& era, config& scenario_data, int num_
|
|||
(*level_ptr)["turns"] = turns.str();
|
||||
}
|
||||
|
||||
assert(level_ptr != NULL);
|
||||
wassert(level_ptr != NULL);
|
||||
|
||||
if(scenario_data["era"].empty()) {
|
||||
era_ = era;
|
||||
|
@ -414,8 +415,11 @@ void mp_connect::set_area(const SDL_Rect& rect)
|
|||
scroll_pane_.set_location(scroll_pane_rect);
|
||||
config::child_iterator sd;
|
||||
|
||||
std::cerr << "Getting here :P" << std::endl;
|
||||
|
||||
for(sd = sides.first; sd != sides.second; ++sd) {
|
||||
const int side_num = sd - sides.first;
|
||||
std::cerr << "Side num: " << side_num << std::endl;
|
||||
|
||||
//Player number
|
||||
player_numbers_.push_back(gui::label(*disp_, (*sd)->values["side"],
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "show_dialog.hpp"
|
||||
#include "statistics.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "wassert.hpp"
|
||||
#include "widgets/button.hpp"
|
||||
#include "widgets/menu.hpp"
|
||||
#include "widgets/textbox.hpp"
|
||||
|
@ -215,7 +216,7 @@ RESULT enter(display& disp, config& game_data, const config& terrain_data, dialo
|
|||
}
|
||||
|
||||
if(games_menu.selection() >= 0 && games_menu.selection() < int(game_vacant_slots.size())) {
|
||||
assert(game_vacant_slots.size() == game_observers.size());
|
||||
wassert(game_vacant_slots.size() == game_observers.size());
|
||||
|
||||
join_game.hide(!game_vacant_slots[games_menu.selection()]);
|
||||
observe_game.hide(!game_observers[games_menu.selection()]);
|
||||
|
@ -319,7 +320,7 @@ RESULT enter(display& disp, config& game_data, const config& terrain_data, dialo
|
|||
if(games_available && (observe || join_game.pressed() || double_click)) {
|
||||
const size_t index = size_t(games_menu.selection());
|
||||
const config::const_child_itors i = gamelist->child_range("game");
|
||||
assert(index < size_t(i.second - i.first));
|
||||
wassert(index < size_t(i.second - i.first));
|
||||
const std::string& id = (**(i.first+index))["id"];
|
||||
|
||||
config response;
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
#include "network.hpp"
|
||||
#include "network_worker.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include "SDL_net.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <queue>
|
||||
#include <iostream>
|
||||
|
@ -372,7 +372,7 @@ void disconnect(connection s)
|
|||
{
|
||||
if(s == 0) {
|
||||
while(sockets.empty() == false) {
|
||||
assert(sockets.back() != 0);
|
||||
wassert(sockets.back() != 0);
|
||||
disconnect(sockets.back());
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ connection receive_data(config& cfg, connection connection_num, int timeout)
|
|||
}
|
||||
|
||||
const schema_map::iterator schema = schemas.find(*i);
|
||||
assert(schema != schemas.end());
|
||||
wassert(schema != schemas.end());
|
||||
|
||||
cfg.read_compressed(buffer,schema->second.incoming);
|
||||
|
||||
|
@ -587,7 +587,7 @@ void send_data(const config& cfg, connection connection_num, size_t max_size, SE
|
|||
}
|
||||
|
||||
const schema_map::iterator schema = schemas.find(connection_num);
|
||||
assert(schema != schemas.end());
|
||||
wassert(schema != schemas.end());
|
||||
|
||||
const std::string& value = cfg.write_compressed(schema->second.outgoing);
|
||||
|
||||
|
@ -600,7 +600,7 @@ void send_data(const config& cfg, connection connection_num, size_t max_size, SE
|
|||
buf.back() = 0;
|
||||
|
||||
const connection_map::iterator info = connections.find(connection_num);
|
||||
assert(info != connections.end());
|
||||
wassert(info != connections.end());
|
||||
|
||||
network_worker_pool::queue_data(info->second.sock,buf);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "network_worker.hpp"
|
||||
#include "network.hpp"
|
||||
#include "thread.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
@ -52,7 +52,7 @@ int process_queue(void* data)
|
|||
buffer_set::iterator itor = bufs.begin(), itor_end = bufs.end();
|
||||
for(; itor != itor_end; ++itor) {
|
||||
socket_state_map::iterator lock_it = sockets_locked.find((*itor)->sock);
|
||||
assert(lock_it != sockets_locked.end());
|
||||
wassert(lock_it != sockets_locked.end());
|
||||
if(lock_it->second == SOCKET_READY) {
|
||||
lock_it->second = SOCKET_LOCKED;
|
||||
break;
|
||||
|
@ -95,7 +95,7 @@ int process_queue(void* data)
|
|||
{
|
||||
const threading::lock lock(*global_mutex);
|
||||
socket_state_map::iterator lock_it = sockets_locked.find(sent_buf->sock);
|
||||
assert(lock_it != sockets_locked.end());
|
||||
wassert(lock_it != sockets_locked.end());
|
||||
lock_it->second = result;
|
||||
if(result == SOCKET_ERROR) {
|
||||
++socket_errors;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "log.hpp"
|
||||
#include "pathfind.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
@ -87,10 +88,10 @@ paths::route a_star_search(gamemap::location const &src, gamemap::location const
|
|||
std::vector<location> locs;
|
||||
while(!open_list.empty()) {
|
||||
|
||||
assert(open_list.size() == open_list_ordered.size());
|
||||
wassert(open_list.size() == open_list_ordered.size());
|
||||
|
||||
const list_map::iterator lowest_in_open = open_list.find(open_list_ordered.begin()->second);
|
||||
assert(lowest_in_open != open_list.end());
|
||||
wassert(lowest_in_open != open_list.end());
|
||||
|
||||
//move the lowest element from the open list to the closed list
|
||||
closed_list.erase(lowest_in_open->first);
|
||||
|
@ -120,7 +121,7 @@ paths::route a_star_search(gamemap::location const &src, gamemap::location const
|
|||
list_map::const_iterator itor = open_list.find(loc);
|
||||
if(itor == open_list.end()) {
|
||||
itor = closed_list.find(loc);
|
||||
assert(itor != closed_list.end());
|
||||
wassert(itor != closed_list.end());
|
||||
}
|
||||
|
||||
loc = itor->second.parent;
|
||||
|
@ -130,7 +131,7 @@ paths::route a_star_search(gamemap::location const &src, gamemap::location const
|
|||
rt.steps.push_back(dst);
|
||||
rt.move_left = int(lowest_gcost + obj->cost(dst, lowest_gcost));
|
||||
|
||||
assert(rt.steps.front() == src);
|
||||
wassert(rt.steps.front() == src);
|
||||
|
||||
LOG_PF << "exiting a* search (solved)\n";
|
||||
|
||||
|
@ -454,7 +455,7 @@ int route_turns_to_complete(const unit& u, const gamemap& map,
|
|||
int turns = 0, movement = u.movement_left();
|
||||
for(std::vector<gamemap::location>::const_iterator i = rt.steps.begin()+1;
|
||||
i != rt.steps.end(); ++i) {
|
||||
assert(map.on_board(*i));
|
||||
wassert(map.on_board(*i));
|
||||
const int move_cost = u.movement_cost(map,map[i->x][i->y]);
|
||||
movement -= move_cost;
|
||||
if(movement < 0) {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "unit.hpp"
|
||||
#include "unit_display.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
#include "widgets/menu.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
@ -731,7 +732,7 @@ bool turn_info::move_unit_along_current_route(bool check_shroud)
|
|||
|
||||
redo_stack_.clear();
|
||||
|
||||
assert(moves <= steps.size());
|
||||
wassert(moves <= steps.size());
|
||||
const gamemap::location& dst = steps[moves-1];
|
||||
const unit_map::const_iterator u = units_.find(dst);
|
||||
|
||||
|
@ -946,7 +947,7 @@ gamemap::location turn_info::current_unit_attacks_from(const gamemap::location&
|
|||
|
||||
void turn_info::move_unit_to_loc(const unit_map::const_iterator& ui, const gamemap::location& target, bool continue_move)
|
||||
{
|
||||
assert(ui != units_.end());
|
||||
wassert(ui != units_.end());
|
||||
|
||||
unit u = ui->second;
|
||||
const shortest_path_calculator calc(u,current_team(),visible_units(),teams_,map_,status_);
|
||||
|
@ -965,7 +966,7 @@ void turn_info::move_unit_to_loc(const unit_map::const_iterator& ui, const gamem
|
|||
if(route.steps.empty())
|
||||
return;
|
||||
|
||||
assert(route.steps.front() == ui->first);
|
||||
wassert(route.steps.front() == ui->first);
|
||||
|
||||
route.move_left = route_turns_to_complete(ui->second,map_,route);
|
||||
gui_.set_route(&route);
|
||||
|
@ -1429,7 +1430,7 @@ void turn_info::redo()
|
|||
std::vector<gamemap::location> route = action.route;
|
||||
const unit_map::iterator u = units_.find(route.front());
|
||||
if(u == units_.end()) {
|
||||
assert(false);
|
||||
wassert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1797,7 +1798,7 @@ void turn_info::do_recruit(const std::string& name)
|
|||
|
||||
const std::map<std::string,unit_type>::const_iterator
|
||||
u_type = gameinfo_.unit_types.find(name);
|
||||
assert(u_type != gameinfo_.unit_types.end());
|
||||
wassert(u_type != gameinfo_.unit_types.end());
|
||||
|
||||
if(u_type->second.cost() > current_team.gold()) {
|
||||
gui::show_dialog(gui_,NULL,"",
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "statistics.hpp"
|
||||
#include "unit_display.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
@ -499,13 +500,13 @@ int replay::get_random()
|
|||
|
||||
const config* replay::get_random_results() const
|
||||
{
|
||||
assert(random_ != NULL);
|
||||
wassert(random_ != NULL);
|
||||
return random_->child("results");
|
||||
}
|
||||
|
||||
void replay::set_random_results(const config& cfg)
|
||||
{
|
||||
assert(random_ != NULL);
|
||||
wassert(random_ != NULL);
|
||||
random_->clear_children("results");
|
||||
random_->add_child("results",cfg);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "game_config.hpp"
|
||||
#include "language.hpp"
|
||||
#include "reports.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
@ -25,8 +25,8 @@ namespace reports {
|
|||
|
||||
const std::string& report_name(TYPE type)
|
||||
{
|
||||
assert(sizeof(report_names)/sizeof(*report_names) == NUM_REPORTS);
|
||||
assert(type < NUM_REPORTS);
|
||||
wassert(sizeof(report_names)/sizeof(*report_names) == NUM_REPORTS);
|
||||
wassert(type < NUM_REPORTS);
|
||||
|
||||
return report_names[type];
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "show_dialog.hpp"
|
||||
#include "util.hpp"
|
||||
#include "video.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
bool point_in_rect(int x, int y, const SDL_Rect& rect)
|
||||
{
|
||||
|
@ -549,7 +550,7 @@ surface cut_surface(surface surf, const SDL_Rect& r)
|
|||
Uint8* line_dest = dest + y * rpitch;
|
||||
size_t size = r.w + r.x <= surf->w ? r.w : surf->w - r.x;
|
||||
|
||||
assert(rpitch >= r.w * rbpp);
|
||||
wassert(rpitch >= r.w * rbpp);
|
||||
memcpy(line_dest, line_src, size * rbpp);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "game.hpp"
|
||||
#include "../util.hpp"
|
||||
#include "../wassert.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
int game::id_num = 1;
|
||||
|
@ -13,7 +13,7 @@ game::game(const player_map& info) : player_info_(&info), id_(id_num++), started
|
|||
|
||||
bool game::is_owner(network::connection player) const
|
||||
{
|
||||
assert(!players_.empty());
|
||||
wassert(!players_.empty());
|
||||
return player == players_.front();
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ bool game::is_member(network::connection player) const
|
|||
|
||||
bool game::is_needed(network::connection player) const
|
||||
{
|
||||
assert(!players_.empty());
|
||||
wassert(!players_.empty());
|
||||
return player == players_.front();
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ void game::start_game()
|
|||
|
||||
bool game::take_side(network::connection player, const config& cfg)
|
||||
{
|
||||
assert(is_member(player));
|
||||
wassert(is_member(player));
|
||||
|
||||
const std::string& side = cfg["side"];
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../game_config.hpp"
|
||||
#include "../network.hpp"
|
||||
#include "../util.hpp"
|
||||
#include "../wassert.hpp"
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
|
@ -13,7 +14,6 @@
|
|||
#include "player.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
@ -441,7 +441,7 @@ void server::run()
|
|||
config* const message = data.child("message");
|
||||
if(message != NULL) {
|
||||
const player_map::const_iterator p = players_.find(sock);
|
||||
assert(p != players_.end());
|
||||
wassert(p != players_.end());
|
||||
(*message)["sender"] = p->second.name();
|
||||
|
||||
truncate_message((*message)["message"]);
|
||||
|
@ -621,7 +621,7 @@ void server::run()
|
|||
|
||||
//delete the game's description
|
||||
config* const gamelist = initial_response_.child("gamelist");
|
||||
assert(gamelist != NULL);
|
||||
wassert(gamelist != NULL);
|
||||
const config::child_itors vg = gamelist->child_range("game");
|
||||
|
||||
const config::child_iterator desc = std::find(vg.first,vg.second,g->description());
|
||||
|
@ -709,7 +709,7 @@ void server::run()
|
|||
//force the description to be correct to prevent
|
||||
//spoofing of messages
|
||||
const player_map::const_iterator pl = players_.find(sock);
|
||||
assert(pl != players_.end());
|
||||
wassert(pl != players_.end());
|
||||
(*speak)["description"] = pl->second.name();
|
||||
|
||||
if((*speak)["team_name"] == "") {
|
||||
|
@ -799,7 +799,7 @@ void server::delete_game(std::vector<game>::iterator i)
|
|||
|
||||
//delete the game's configuration
|
||||
config* const gamelist = initial_response_.child("gamelist");
|
||||
assert(gamelist != NULL);
|
||||
wassert(gamelist != NULL);
|
||||
const config::child_itors vg = gamelist->child_range("game");
|
||||
const config::child_list::iterator g = std::find(vg.first,vg.second,i->description());
|
||||
if(g != vg.second) {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "widgets/button.hpp"
|
||||
#include "widgets/menu.hpp"
|
||||
#include "widgets/textbox.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include "SDL_ttf.h"
|
||||
|
||||
|
@ -874,7 +875,7 @@ int show_dialog(display& disp, surface image,
|
|||
(*options)[n].checked = check_buttons[n].checked();
|
||||
} else if(pressed) {
|
||||
const size_t options_size = options == NULL ? 0 : options->size();
|
||||
assert(action_buttons != NULL && action_buttons->size() > n - options_size);
|
||||
wassert(action_buttons != NULL && action_buttons->size() > n - options_size);
|
||||
|
||||
const dialog_button_action::RESULT res = (*action_buttons)[n - options_size].handler->button_pressed(menu_.selection());
|
||||
if(res == dialog_button_action::DELETE_ITEM) {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "replay.hpp"
|
||||
#include "team.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
@ -221,7 +222,7 @@ void team::team_info::write(config& cfg) const
|
|||
case HUMAN: cfg["controller"] = "human"; break;
|
||||
case NETWORK: cfg["controller"] = "network"; break;
|
||||
case EMPTY: cfg["controller"] = "null"; break;
|
||||
default: assert(false);
|
||||
default: wassert(false);
|
||||
}
|
||||
|
||||
sprintf(buf,"%d",villages_per_scout);
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "config.hpp"
|
||||
#include "map.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#include "terrain.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "sdl_utils.hpp"
|
||||
#include "theme.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
@ -284,7 +285,7 @@ SDL_Rect& theme::object::location(const SDL_Rect& screen) const
|
|||
relative_loc_.w = (loc_.w*screen.w)/XDim;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
wassert(false);
|
||||
}
|
||||
|
||||
switch(yanchor_) {
|
||||
|
@ -305,7 +306,7 @@ SDL_Rect& theme::object::location(const SDL_Rect& screen) const
|
|||
relative_loc_.h = (loc_.h*screen.h)/YDim;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
wassert(false);
|
||||
}
|
||||
|
||||
relative_loc_.x = minimum<int>(relative_loc_.x,screen.w);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "replay.hpp"
|
||||
#include "unit.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
@ -606,7 +607,7 @@ void unit::read(const game_data& data, const config& cfg)
|
|||
else
|
||||
throw gamestatus::load_game_failed("Unit not found: '" + cfg["type"] + "'");
|
||||
|
||||
assert(type_ != NULL);
|
||||
wassert(type_ != NULL);
|
||||
|
||||
const std::string& gender = preferences::show_unit_genders() ? cfg["gender"] : "";
|
||||
if(gender == "male") {
|
||||
|
@ -1219,7 +1220,7 @@ int unit::upkeep() const
|
|||
case UPKEEP_FREE: return 0;
|
||||
case UPKEEP_LOYAL: return minimum<int>(1,type().level());
|
||||
case UPKEEP_FULL_PRICE: return type().level();
|
||||
default: assert(false); return 0;
|
||||
default: wassert(false); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "sound.hpp"
|
||||
#include "unit_display.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#define LOG_DP lg::info(lg::display)
|
||||
|
||||
|
@ -316,7 +317,7 @@ bool unit_attack_ranged(display& disp, unit_map& units,
|
|||
unit_map::iterator leader = units.end();
|
||||
if(leader_loc.valid()) {
|
||||
leader = units.find(leader_loc);
|
||||
assert(leader != units.end());
|
||||
wassert(leader != units.end());
|
||||
leader->second.set_leading(true);
|
||||
}
|
||||
|
||||
|
@ -627,12 +628,12 @@ bool unit_attack(display& disp, unit_map& units, const gamemap& map,
|
|||
log_scope("unit_attack");
|
||||
|
||||
const unit_map::iterator att = units.find(a);
|
||||
assert(att != units.end());
|
||||
wassert(att != units.end());
|
||||
|
||||
unit& attacker = att->second;
|
||||
|
||||
const unit_map::iterator def = units.find(b);
|
||||
assert(def != units.end());
|
||||
wassert(def != units.end());
|
||||
|
||||
if(b.x > a.x) {
|
||||
att->second.set_facing_left(true);
|
||||
|
@ -664,7 +665,7 @@ bool unit_attack(display& disp, unit_map& units, const gamemap& map,
|
|||
if(leader_loc.valid()){
|
||||
LOG_DP << "found leader at " << (leader_loc.x+1) << "," << (leader_loc.y+1) << "\n";
|
||||
leader = units.find(leader_loc);
|
||||
assert(leader != units.end());
|
||||
wassert(leader != units.end());
|
||||
leader->second.set_leading(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#include "log.hpp"
|
||||
#include "unit_types.hpp"
|
||||
#include "util.hpp"
|
||||
#include "wassert.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -227,7 +227,7 @@ bool attack_type::slow() const
|
|||
|
||||
const unit_animation& attack_type::animation() const
|
||||
{
|
||||
assert(animation_.empty() == false);
|
||||
wassert(animation_.empty() == false);
|
||||
return animation_[rand()%animation_.size()];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue