ran codeclean against files
This commit is contained in:
parent
9e7fddeac9
commit
8bd9bc98a5
178 changed files with 1597 additions and 1597 deletions
|
@ -301,7 +301,7 @@ One way to contribute is to find an unassigned bug in the
|
|||
and fix the bug.
|
||||
If you wish to work on something else, you should probably
|
||||
explain on the
|
||||
<a href="http://wesnoth.whitevine.net/forum/phpBB2/">forum</a>
|
||||
<a href="http://www.wesnoth.org/forum/phpBB2/">forum</a>
|
||||
what you wish to do before doing any actual development.
|
||||
Do make sure you have read the projects
|
||||
<a href="http://wesnoth.slack.it/?CodingStandards">coding standards</a>.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -168,7 +168,7 @@ std::vector<std::string> get_text() {
|
|||
|
||||
"_" N_("+English (GB) Translation"),
|
||||
"- ott",
|
||||
|
||||
|
||||
"_" N_("+Estonian Translation"),
|
||||
"- Mart Tõnso",
|
||||
|
||||
|
@ -224,7 +224,7 @@ std::vector<std::string> get_text() {
|
|||
"- Federico Tomassetti",
|
||||
"- isazi",
|
||||
"- RokStar",
|
||||
|
||||
|
||||
"_" N_("+Japanese Translation"),
|
||||
"- Naoki Iimura",
|
||||
"- Nobuhito Okada",
|
||||
|
@ -264,10 +264,10 @@ std::vector<std::string> get_text() {
|
|||
|
||||
"_" N_("+Serbian Translation"),
|
||||
"- Srecko Toroman (FreeCraft)",
|
||||
|
||||
|
||||
"_" N_("+Slovak Translation"),
|
||||
"- Viliam Bur",
|
||||
|
||||
|
||||
"_" N_("+Slovenian Translation"),
|
||||
"- Jaka Kranjc (lynx)",
|
||||
|
||||
|
@ -284,11 +284,11 @@ std::vector<std::string> get_text() {
|
|||
"- Stefan Bergström (tephlon)",
|
||||
"- Susanna Björverud (sanna)",
|
||||
"- wint3r",
|
||||
|
||||
|
||||
"_" N_("+Turkish Translation"),
|
||||
"- İhsan Akın",
|
||||
"- Selim Farsakoğlu",
|
||||
|
||||
|
||||
"_" N_("+Contributors"),
|
||||
"- Frédéric Wagner",
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -72,15 +72,15 @@ private:
|
|||
// check_victory, but shouldn't be passed to that function as parameters,
|
||||
// since it is called from a variety of places.
|
||||
namespace victory_conditions
|
||||
{
|
||||
{
|
||||
bool when_enemies_defeated = true;
|
||||
|
||||
void set_victory_when_enemies_defeated(bool on)
|
||||
void set_victory_when_enemies_defeated(bool on)
|
||||
{
|
||||
when_enemies_defeated = on;
|
||||
}
|
||||
|
||||
bool victory_when_enemies_defeated()
|
||||
bool victory_when_enemies_defeated()
|
||||
{
|
||||
return when_enemies_defeated;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ std::string recruit_unit(const gamemap& map, int side,
|
|||
|
||||
if(need_castle && map.on_board(recruit_location)) {
|
||||
castle_cost_calculator calc(map);
|
||||
const paths::route& rt = a_star_search(u->first, recruit_location, 100.0, &calc, map.x(), map.y());
|
||||
const paths::route& rt = a_star_search(u->first, recruit_location, 100.0, &calc, map.x(), map.y());
|
||||
if(rt.steps.empty() || units.find(recruit_location) != units.end() ||
|
||||
!map.is_castle(recruit_location)) {
|
||||
recruit_location = gamemap::location();
|
||||
|
@ -175,7 +175,7 @@ std::string recruit_unit(const gamemap& map, int side,
|
|||
((*ran_results)["checksum"], 0);
|
||||
if((*ran_results)["checksum"].empty() || rc != cs.checksum()) {
|
||||
ERR_NW << "SYNC: In recruit " << new_unit.type().id() <<
|
||||
": has checksum " << cs.checksum() <<
|
||||
": has checksum " << cs.checksum() <<
|
||||
" while datasource has checksum " <<
|
||||
rc << "\n";
|
||||
|
||||
|
@ -355,9 +355,9 @@ battle_stats evaluate_battle_stats(const gamemap& map,
|
|||
}
|
||||
|
||||
static const std::string plague_string("plague");
|
||||
res.attacker_plague = !d->second.type().not_living() &&
|
||||
(res.attacker_special.substr(0,6) == plague_string) &&
|
||||
strcmp(d->second.type().undead_variation().c_str(),"null") &&
|
||||
res.attacker_plague = !d->second.type().not_living() &&
|
||||
(res.attacker_special.substr(0,6) == plague_string) &&
|
||||
strcmp(d->second.type().undead_variation().c_str(),"null") &&
|
||||
!map.is_village(defender);
|
||||
if(res.attacker_special.size()>8){ //plague(type) used
|
||||
res.attacker_plague_type=res.attacker_special.substr(7,res.attacker_special.size()-8);
|
||||
|
@ -426,7 +426,7 @@ battle_stats evaluate_battle_stats(const gamemap& map,
|
|||
|
||||
const int base_damage = defend.damage();
|
||||
const int resistance_modifier = a->second.damage_against(defend);
|
||||
|
||||
|
||||
if (strings) {
|
||||
std::stringstream str_base;
|
||||
str_base << _("base damage") << COLUMN_SEPARATOR << base_damage;
|
||||
|
@ -504,7 +504,7 @@ battle_stats evaluate_battle_stats(const gamemap& map,
|
|||
res.amount_defender_drains = 0;
|
||||
}
|
||||
|
||||
res.defender_plague = !a->second.type().not_living() &&
|
||||
res.defender_plague = !a->second.type().not_living() &&
|
||||
(res.defender_special.substr(0,6) == plague_string) &&
|
||||
strcmp(a->second.type().undead_variation().c_str(),"null") &&
|
||||
!map.is_village(attacker);
|
||||
|
@ -555,7 +555,7 @@ battle_stats evaluate_battle_stats(const gamemap& map,
|
|||
int leader_bonus = 0;
|
||||
if (under_leadership(units,attacker,&leader_bonus).valid()) {
|
||||
bonus += leader_bonus;
|
||||
|
||||
|
||||
if (strings) {
|
||||
std::stringstream str;
|
||||
str << _("leadership") << EMPTY_COLUMN << '+' << leader_bonus << '%';
|
||||
|
@ -672,7 +672,7 @@ static std::string unit_dump(std::pair< gamemap::location, unit > const &u)
|
|||
return s.str();
|
||||
}
|
||||
|
||||
void attack(display& gui, const gamemap& map,
|
||||
void attack(display& gui, const gamemap& map,
|
||||
std::vector<team>& teams,
|
||||
gamemap::location attacker,
|
||||
gamemap::location defender,
|
||||
|
@ -825,15 +825,15 @@ void attack(display& gui, const gamemap& map,
|
|||
|
||||
//plague units make new units on the target hex
|
||||
if(stats.attacker_plague) {
|
||||
a = units.find(attacker_loc);
|
||||
a = units.find(attacker_loc);
|
||||
game_data::unit_type_map::const_iterator reanimitor;
|
||||
LOG_NG<<"trying to reanimate "<<stats.attacker_plague_type<<std::endl;
|
||||
reanimitor = info.unit_types.find(stats.attacker_plague_type);
|
||||
LOG_NG<<"found unit type:"<<reanimitor->second.id()<<std::endl;
|
||||
|
||||
|
||||
if(reanimitor != info.unit_types.end()) {
|
||||
unit newunit=unit(&reanimitor->second,a->second.side(),true,true);
|
||||
//apply variation
|
||||
//apply variation
|
||||
if(strcmp(undead_variation.c_str(),"null")){
|
||||
config mod;
|
||||
config& variation=mod.add_child("effect");
|
||||
|
@ -965,7 +965,7 @@ void attack(display& gui, const gamemap& map,
|
|||
d->second.heal(stats.amount_defender_drains);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(dies) {//defender kills attacker
|
||||
defenderxp = game_config::kill_experience*a->second.type().level();
|
||||
if(a->second.type().level() == 0)
|
||||
|
@ -991,12 +991,12 @@ void attack(display& gui, const gamemap& map,
|
|||
|
||||
//plague units make new units on the target hex.
|
||||
if(stats.defender_plague) {
|
||||
d = units.find(defender_loc);
|
||||
d = units.find(defender_loc);
|
||||
game_data::unit_type_map::const_iterator reanimitor;
|
||||
LOG_NG<<"trying to reanimate "<<stats.defender_plague_type<<std::endl;
|
||||
reanimitor = info.unit_types.find(stats.defender_plague_type);
|
||||
LOG_NG<<"found unit type:"<<reanimitor->second.id()<<std::endl;
|
||||
|
||||
|
||||
if(reanimitor != info.unit_types.end()) {
|
||||
unit newunit=unit(&reanimitor->second,d->second.side(),true,true);
|
||||
//apply variation
|
||||
|
@ -1296,7 +1296,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
|||
|
||||
for(i = units.begin(); i != units.end(); ++i) {
|
||||
if(i->second.side() == side) {
|
||||
if(i->second.hitpoints() < i->second.max_hitpoints() ||
|
||||
if(i->second.hitpoints() < i->second.max_hitpoints() ||
|
||||
i->second.poisoned()){
|
||||
if(i->second.is_resting()) {
|
||||
const std::map<gamemap::location,int>::iterator u =
|
||||
|
@ -1394,7 +1394,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
|||
if(h->second <= 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(h->second < 0) {
|
||||
if(show_healing) {
|
||||
sound::play_sound("groan.wav");
|
||||
|
@ -1455,7 +1455,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
|||
|
||||
disp.draw_tile(i->second.x,i->second.y);
|
||||
}
|
||||
|
||||
|
||||
disp.draw_tile(loc.x,loc.y);
|
||||
disp.update_display();
|
||||
}
|
||||
|
@ -1627,7 +1627,7 @@ bool clear_shroud_loc(const gamemap& map, team& tm,
|
|||
//returns true iff some shroud is cleared
|
||||
//seen_units will return new units that have been seen by this unit
|
||||
//if known_units is NULL, seen_units can be NULL and will not be changed
|
||||
bool clear_shroud_unit(const gamemap& map,
|
||||
bool clear_shroud_unit(const gamemap& map,
|
||||
const gamestatus& status,
|
||||
const game_data& gamedata,
|
||||
const unit_map& units, const gamemap::location& loc,
|
||||
|
@ -1676,7 +1676,7 @@ bool clear_shroud_unit(const gamemap& map,
|
|||
}
|
||||
|
||||
void recalculate_fog(const gamemap& map, const gamestatus& status,
|
||||
const game_data& gamedata, const unit_map& units,
|
||||
const game_data& gamedata, const unit_map& units,
|
||||
std::vector<team>& teams, int team) {
|
||||
|
||||
teams[team].refog();
|
||||
|
@ -1694,7 +1694,7 @@ void recalculate_fog(const gamemap& map, const gamestatus& status,
|
|||
}
|
||||
}
|
||||
|
||||
bool clear_shroud(display& disp, const gamestatus& status,
|
||||
bool clear_shroud(display& disp, const gamestatus& status,
|
||||
const gamemap& map, const game_data& gamedata,
|
||||
const unit_map& units, std::vector<team>& teams, int team)
|
||||
{
|
||||
|
@ -1723,7 +1723,7 @@ bool clear_shroud(display& disp, const gamestatus& status,
|
|||
return result;
|
||||
}
|
||||
|
||||
size_t move_unit(display* disp, const game_data& gamedata,
|
||||
size_t move_unit(display* disp, const game_data& gamedata,
|
||||
const gamestatus& status, const gamemap& map,
|
||||
unit_map& units, std::vector<team>& teams,
|
||||
std::vector<gamemap::location> route,
|
||||
|
@ -1750,7 +1750,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
team& team = teams[team_num];
|
||||
const bool check_shroud = should_clear_shroud && team.auto_shroud_updates() &&
|
||||
(team.uses_shroud() || team.uses_fog());
|
||||
|
||||
|
||||
//if we use shroud/fog of war, count out the units we can currently see
|
||||
std::set<gamemap::location> known_units;
|
||||
if(check_shroud) {
|
||||
|
@ -1772,7 +1772,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
const gamemap::TERRAIN terrain = map[step->x][step->y];
|
||||
|
||||
const unit_map::const_iterator enemy_unit = units.find(*step);
|
||||
|
||||
|
||||
const int mv = u.movement_cost(map,terrain);
|
||||
if(discovered_unit || continue_move == false && seen_units.empty() == false ||
|
||||
mv > moves_left || enemy_unit != units.end() && team.is_enemy(enemy_unit->second.side())) {
|
||||
|
@ -1855,7 +1855,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
} else {
|
||||
u.set_interrupted_move(gamemap::location());
|
||||
}
|
||||
|
||||
|
||||
if(steps.size() < 2) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1968,7 +1968,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
|
||||
std::stringstream msg;
|
||||
msg << gettext(msg_id);
|
||||
|
||||
|
||||
if(steps.size() < route.size()) {
|
||||
//see if the "Continue Move" action has an associated hotkey
|
||||
const hotkey::hotkey_item& hk = hotkey::get_hotkey(hotkey::HOTKEY_CONTINUE_MOVE);
|
||||
|
@ -1998,7 +1998,7 @@ bool unit_can_move(const gamemap::location& loc, const unit_map& units,
|
|||
{
|
||||
const unit_map::const_iterator u_it = units.find(loc);
|
||||
wassert(u_it != units.end());
|
||||
|
||||
|
||||
const unit& u = u_it->second;
|
||||
const team& current_team = teams[u.side()-1];
|
||||
|
||||
|
@ -2021,7 +2021,7 @@ bool unit_can_move(const gamemap::location& loc, const unit_map& units,
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(u.movement_cost(map,map[locs[n].x][locs[n].y]) <= u.movement_left()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -2051,7 +2051,7 @@ void apply_shroud_changes(undo_list& undos, display* disp, const gamestatus& sta
|
|||
//we're not really going to mutate the unit, just temporarily
|
||||
//set its moves to maximum, but then switch them back
|
||||
const unit_movement_resetter move_resetter(const_cast<unit&>(un->affected_unit));
|
||||
|
||||
|
||||
std::vector<gamemap::location>::const_iterator step;
|
||||
for(step = un->route.begin(); step != un->route.end(); ++step) {
|
||||
//we have to swap out any unit that is already in the hex, so we can put our
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -187,8 +187,8 @@ typedef std::deque<undo_action> undo_list;
|
|||
//steps. If the unit cannot make it completely along the path this turn,
|
||||
//a goto order will be set. If move_recorder is not NULL, the move will
|
||||
//be recorded in it. If undos is not NULL, undo information will be added.
|
||||
size_t move_unit(display* disp, const game_data& gamedata,
|
||||
const gamestatus& status, const gamemap& map,
|
||||
size_t move_unit(display* disp, const game_data& gamedata,
|
||||
const gamestatus& status, const gamemap& map,
|
||||
unit_map& units, std::vector<team>& teams,
|
||||
std::vector<gamemap::location> steps,
|
||||
replay* move_recorder, undo_list* undos,
|
||||
|
@ -217,7 +217,7 @@ bool unit_can_move(const gamemap::location& loc, const unit_map& units,
|
|||
const gamemap& map, const std::vector<team>& teams);
|
||||
|
||||
|
||||
namespace victory_conditions {
|
||||
namespace victory_conditions {
|
||||
void set_victory_when_enemies_defeated(bool on);
|
||||
bool victory_when_enemies_defeated();
|
||||
}
|
||||
|
|
34
src/ai.cpp
34
src/ai.cpp
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -105,7 +105,7 @@ protected:
|
|||
int choose_weapon(const location& attacker, const location& defender) {
|
||||
const unit_map::const_iterator att = get_info().units.find(attacker);
|
||||
wassert(att != get_info().units.end());
|
||||
|
||||
|
||||
const std::vector<attack_type>& attacks = att->second.attacks();
|
||||
|
||||
int best_attack_rating = -1;
|
||||
|
@ -214,7 +214,7 @@ bool ai::recruit_usage(const std::string& usage)
|
|||
user_interact();
|
||||
|
||||
const int min_gold = 0;
|
||||
|
||||
|
||||
log_scope2(ai, "recruiting troops");
|
||||
LOG_AI << "recruiting " << usage << "\n";
|
||||
|
||||
|
@ -303,7 +303,7 @@ bool ai_interface::recruit(const std::string& unit_name, location loc)
|
|||
return true;
|
||||
} else {
|
||||
const team_data data = calculate_team_data(current_team(),info_.team_num,info_.units);
|
||||
LOG_AI <<
|
||||
LOG_AI <<
|
||||
"recruit UNconfirmed: team=" << (info_.team_num) <<
|
||||
" units=" << data.units <<
|
||||
" gold=" << data.gold <<
|
||||
|
@ -530,7 +530,7 @@ bool ai::multistep_move_possible(location from, location to, location via, std::
|
|||
const paths unit_paths(map_,state_,gameinfo_,units_,via,teams_,false,false);
|
||||
|
||||
LOG_AI << "found " << unit_paths.routes.size() << " moves for temp leader\n";
|
||||
|
||||
|
||||
//see if this leader could make it back to the keep
|
||||
if(unit_paths.routes.count(to) != 0) {
|
||||
LOG_AI << "can make it back to the keep\n";
|
||||
|
@ -609,7 +609,7 @@ bool ai::attack_close(const gamemap::location& loc) const
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,7 @@ void ai_interface::calculate_possible_moves(std::map<location,paths>& res, move_
|
|||
}
|
||||
|
||||
//we can't see where invisible enemy units might move
|
||||
if(enemy && un_it->second.invisible(info_.map.underlying_terrain(info_.map.get_terrain(un_it->first)),
|
||||
if(enemy && un_it->second.invisible(info_.map.underlying_terrain(info_.map.get_terrain(un_it->first)),
|
||||
info_.state.get_time_of_day().lawful_bonus,un_it->first,info_.units,info_.teams)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ bool ai::get_villages(std::map<gamemap::location,paths>& possible_moves, const m
|
|||
if(owned && !current_team().is_enemy(n+1)) {
|
||||
want_village = false;
|
||||
}
|
||||
|
||||
|
||||
if(owned) {
|
||||
break;
|
||||
}
|
||||
|
@ -1179,7 +1179,7 @@ bool ai::get_healing(std::map<gamemap::location,paths>& possible_moves, const mo
|
|||
LOG_AI << "chose village " << dst << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
++it.first;
|
||||
}
|
||||
|
||||
|
@ -1358,7 +1358,7 @@ bool ai::move_to_targets(std::map<gamemap::location,paths>& possible_moves, move
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const location arrived_at = move_unit(move.first,move.second,possible_moves);
|
||||
|
||||
|
@ -1373,7 +1373,7 @@ bool ai::move_to_targets(std::map<gamemap::location,paths>& possible_moves, move
|
|||
|
||||
//if we're going to attack someone
|
||||
if(u_it != units_.end() && u_it->second.stone() == false && weapon != -1) {
|
||||
attack_enemy(move.second,target,weapon);
|
||||
attack_enemy(move.second,target,weapon);
|
||||
}
|
||||
|
||||
//don't allow any other units to move onto the tile our unit
|
||||
|
@ -1536,7 +1536,7 @@ void ai::analyze_potential_recruit_movements()
|
|||
LOG_AI << "targets: " << targets.size() << "\n";
|
||||
|
||||
std::map<std::string,int> best_scores;
|
||||
|
||||
|
||||
for(std::set<std::string>::const_iterator i = recruits.begin(); i != recruits.end(); ++i) {
|
||||
const game_data::unit_type_map::const_iterator info = gameinfo_.unit_types.find(*i);
|
||||
if(info == gameinfo_.unit_types.end()) {
|
||||
|
@ -1702,7 +1702,7 @@ void ai::move_leader_to_goals(const move_map& enemy_srcdst, const move_map& enem
|
|||
}
|
||||
|
||||
LOG_AI << "Doing recruitment before goals\n";
|
||||
|
||||
|
||||
do_recruitment();
|
||||
|
||||
shortest_path_calculator calc(leader->second, current_team(), units_, teams_, map_, state_);
|
||||
|
@ -1716,7 +1716,7 @@ void ai::move_leader_to_goals(const move_map& enemy_srcdst, const move_map& enem
|
|||
|
||||
std::map<gamemap::location,paths> possible_moves;
|
||||
possible_moves.insert(std::pair<gamemap::location,paths>(leader->first,leader_paths));
|
||||
|
||||
|
||||
gamemap::location loc;
|
||||
for(std::vector<gamemap::location>::const_iterator itor = route.steps.begin(); itor != route.steps.end(); ++itor) {
|
||||
if(leader_paths.routes.count(*itor) == 1 && power_projection(*itor,enemy_srcdst,enemy_dstsrc) < double(leader->second.hitpoints()/2)) {
|
||||
|
@ -1799,7 +1799,7 @@ void ai::move_leader_after_recruit(const move_map& enemy_dstsrc)
|
|||
//which we might be able to reach in two turns.
|
||||
if(map_.is_village(i->first) && current_team().owns_village(i->first) &&
|
||||
int(distance_between(i->first,leader->first)) <= leader->second.total_movement()*2) {
|
||||
|
||||
|
||||
int current_distance = distance_between(i->first,leader->first);
|
||||
location current_loc;
|
||||
|
||||
|
@ -1885,7 +1885,7 @@ bool ai::leader_can_reach_keep() const
|
|||
|
||||
//find where the leader can move
|
||||
const paths leader_paths(map_,state_,gameinfo_,units_,leader->first,teams_,false,false);
|
||||
|
||||
|
||||
|
||||
return leader_paths.routes.count(start_pos) > 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -172,7 +172,7 @@ void ai::do_attack_analysis(
|
|||
best_vulnerability = vulnerability/surround_bonus;
|
||||
best_support = support*surround_bonus;
|
||||
}
|
||||
|
||||
|
||||
if(cur_position != -1) {
|
||||
units.erase(units.begin() + i);
|
||||
|
||||
|
@ -280,7 +280,7 @@ int ai::choose_weapon(const location& att, const location& def,
|
|||
const unit_map::const_iterator d_itor = units_.find(def);
|
||||
int d_hitpoints = d_itor->second.hitpoints();
|
||||
int a_hitpoints = itor->second.hitpoints();
|
||||
|
||||
|
||||
for(size_t a = 0; a != attacks.size(); ++a) {
|
||||
const battle_stats stats = evaluate_battle_stats(map_, att, def, a, units_,
|
||||
state_, terrain);
|
||||
|
@ -479,7 +479,7 @@ void ai::attack_analysis::analyze(const gamemap& map, unit_map& units, int num_s
|
|||
} else if(atthp == 0) {
|
||||
avg_losses += cost;
|
||||
}
|
||||
|
||||
|
||||
//if the attacker moved onto a village, reward it for doing so
|
||||
else if(on_village) {
|
||||
atthp += game_config::cure_amount*2; //double reward to emphasize getting onto villages
|
||||
|
@ -572,7 +572,7 @@ double ai::attack_analysis::rating(double aggression, ai& ai_obj) const
|
|||
if(uses_leader && ai_obj.leader_can_reach_keep() && ai_obj.current_team().gold() > 20) {
|
||||
value -= double(ai_obj.current_team().gold())*0.5;
|
||||
}
|
||||
|
||||
|
||||
//prefer to attack already damaged targets
|
||||
value += ((target_starting_damage/3 + avg_damage_inflicted) - (1.0-aggression)*avg_damage_taken)/10.0;
|
||||
|
||||
|
@ -630,7 +630,7 @@ std::vector<ai::attack_analysis> ai::analyze_targets(
|
|||
|
||||
//attack anyone who is on the enemy side, and who is not invisible or turned to stone
|
||||
if(current_team().is_enemy(j->second.side()) && j->second.stone() == false &&
|
||||
j->second.invisible(map_.underlying_terrain(map_[j->first.x][j->first.y]),
|
||||
j->second.invisible(map_.underlying_terrain(map_[j->first.x][j->first.y]),
|
||||
state_.get_time_of_day().lawful_bonus,j->first,
|
||||
units_,teams_) == false) {
|
||||
location adjacent[6];
|
||||
|
@ -678,7 +678,7 @@ double ai::power_projection(const gamemap::location& loc, const move_map& srcdst
|
|||
typedef move_map::const_iterator Itor;
|
||||
typedef std::pair<Itor,Itor> Range;
|
||||
Range its = dstsrc.equal_range(locs[i]);
|
||||
|
||||
|
||||
gamemap::location* const beg_used = used_locs;
|
||||
gamemap::location* end_used = used_locs + num_used_locs;
|
||||
|
||||
|
@ -706,7 +706,7 @@ double ai::power_projection(const gamemap::location& loc, const move_map& srcdst
|
|||
} else if(un.type().alignment() == unit_type::CHAOTIC) {
|
||||
tod_modifier = -lawful_bonus;
|
||||
}
|
||||
|
||||
|
||||
const double hp = double(un.hitpoints())/
|
||||
double(un.max_hitpoints());
|
||||
int most_damage = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -28,7 +28,7 @@ struct move_cost_calculator : cost_calculator
|
|||
{
|
||||
move_cost_calculator(const unit& u, const gamemap& map,
|
||||
const game_data& data,
|
||||
const unit_map& units,
|
||||
const unit_map& units,
|
||||
const gamemap::location& loc,
|
||||
const ai::move_map& dstsrc,
|
||||
const ai::move_map& enemy_dstsrc)
|
||||
|
@ -502,13 +502,13 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
u->second.movement_left() <= 0 || u->second.is_guardian() || u->second.incapacitated()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
user_interact();
|
||||
|
||||
|
||||
const move_cost_calculator calc(u->second, map_, gameinfo_, units_, u->first, dstsrc, enemy_dstsrc);
|
||||
const double locStopValue = minimum(best_target->value / best_rating, 100.0);
|
||||
paths::route cur_route = a_star_search(u->first, best_target->loc, locStopValue, &calc, map_.x(), map_.y());
|
||||
|
||||
|
||||
if (cur_route.move_left < locStopValue)
|
||||
{
|
||||
// if this unit can move to that location this turn, it has a very very low cost
|
||||
|
@ -521,7 +521,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
++locRange.first;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double rating = best_target->value/maximum<int>(1,cur_route.move_left);
|
||||
|
||||
//for 'support' targets, they are rated much higher if we can get there within two turns,
|
||||
|
@ -585,7 +585,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
const int distance = distance_between(*i,best_target->loc);
|
||||
const int defense = best->second.defense_modifier(map_,map_.get_terrain(*i));
|
||||
const double vulnerability = power_projection(*i,enemy_srcdst,enemy_dstsrc);
|
||||
|
||||
|
||||
if(best_loc.valid() == false || defense < best_defense || defense == best_defense && vulnerability < best_vulnerability) {
|
||||
best_loc = *i;
|
||||
best_defense = defense;
|
||||
|
@ -617,7 +617,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
//target is dangerous, and whether we need to group some units to move in unison toward the target
|
||||
//if any point along the path is too dangerous for our single unit, then we hold back
|
||||
for(std::vector<location>::const_iterator i = best_route.steps.begin(); i != best_route.steps.end() && movement > 0; ++i) {
|
||||
|
||||
|
||||
const double threat = power_projection(*i,enemy_srcdst,enemy_dstsrc);
|
||||
if(threat >= double(best->second.hitpoints()) && threat > power_projection(*i,fullmove_srcdst,fullmove_dstsrc) ||
|
||||
i >= best_route.steps.end()-2 && unit_at_target != units_.end() && current_team().is_enemy(unit_at_target->second.side())) {
|
||||
|
@ -695,7 +695,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
targets.push_back(target(*j,value*4.0,target::MASS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return std::pair<location,location>(loc,best_loc);
|
||||
}
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
|
|||
}
|
||||
|
||||
LOG_AI << "Moving to " << its.first->first.x + 1 << "," << its.first->first.y + 1 << "\n";
|
||||
|
||||
|
||||
return std::pair<location,location>(its.first->second,its.first->first);
|
||||
} else {
|
||||
LOG_AI << "dangerous!\n";
|
||||
|
|
|
@ -25,7 +25,7 @@ template<typename T, typename T_void_value>
|
|||
const T animated<T,T_void_value>::void_value_ = T_void_value()();
|
||||
|
||||
template<typename T, typename T_void_value>
|
||||
animated<T,T_void_value>::animated() :
|
||||
animated<T,T_void_value>::animated() :
|
||||
starting_frame_time_(INT_MAX),
|
||||
ending_frame_time_(INT_MIN),
|
||||
started_(false),
|
||||
|
@ -37,7 +37,7 @@ animated<T,T_void_value>::animated() :
|
|||
{}
|
||||
|
||||
template<typename T, typename T_void_value>
|
||||
animated<T,T_void_value>::animated(const std::string &cfg, const string_initializer& init):
|
||||
animated<T,T_void_value>::animated(const std::string &cfg, const string_initializer& init):
|
||||
starting_frame_time_(INT_MAX),
|
||||
started_(false),
|
||||
no_current_frame_(true),
|
||||
|
@ -67,7 +67,7 @@ animated<T,T_void_value>::animated(const std::string &cfg, const string_initiali
|
|||
frames_.push_back(frame(current_time, init(str)));
|
||||
current_time += time;
|
||||
}
|
||||
|
||||
|
||||
starting_frame_time_ = 0;
|
||||
ending_frame_time_ = current_time;
|
||||
}
|
||||
|
@ -115,11 +115,11 @@ void animated<T,T_void_value>::update_current_frame_internal()
|
|||
// std::cerr << "--- updating frame ---\n";
|
||||
if(does_not_change_)
|
||||
return;
|
||||
|
||||
|
||||
frame_changed_ = false;
|
||||
// Always update current_time_, for the animation_time functions to work.
|
||||
current_time_ = SDL_GetTicks() * acceleration_;
|
||||
if(!started_)
|
||||
if(!started_)
|
||||
return;
|
||||
|
||||
if(frames_.empty()) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
class string_initializer
|
||||
{
|
||||
public:
|
||||
virtual T operator()(const std::string& s) const { return T(s); }
|
||||
virtual T operator()(const std::string& s) const { return T(s); }
|
||||
};
|
||||
|
||||
animated();
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
int get_animation_time() const;
|
||||
int get_frame_time() const;
|
||||
const T& get_current_frame() const;
|
||||
|
||||
|
||||
private:
|
||||
struct frame
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
|
||||
T* data() { return a; }
|
||||
const T* data() const { return a; }
|
||||
|
||||
|
||||
private:
|
||||
T a[N];
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -20,7 +20,7 @@ poss_a_star_node* SingletonPOSS_AStarNode = NULL;
|
|||
void a_star_node::initNode(const gamemap::location& pos, const gamemap::location& dst,
|
||||
double cost, a_star_node* parent,
|
||||
const std::set<gamemap::location>* teleports)
|
||||
{
|
||||
{
|
||||
isInCloseList = false;
|
||||
loc = pos;
|
||||
nodeParent = parent;
|
||||
|
@ -43,17 +43,17 @@ void a_star_node::initNode(const gamemap::location& pos, const gamemap::location
|
|||
if(srch + dsth + 1.0 < h) {
|
||||
h = srch + dsth + 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
poss_a_star_node::poss_a_star_node(void) :
|
||||
capacity(0), curIndex(0)
|
||||
{
|
||||
nbElemByPage = size_t((4096 - 24) / sizeof(a_star_node));
|
||||
nbElemByPage = size_t((4096 - 24) / sizeof(a_star_node));
|
||||
wassert(nbElemByPage > 0);
|
||||
addPage();
|
||||
SingletonPOSS_AStarNode = this;
|
||||
}
|
||||
addPage();
|
||||
SingletonPOSS_AStarNode = this;
|
||||
}
|
||||
|
||||
void poss_a_star_node::addPage(void)
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ void poss_a_star_node::addPage(void)
|
|||
locPageAStarNode = new a_star_node[nbElemByPage];
|
||||
vectPageAStarNode.push_back(locPageAStarNode);
|
||||
capacity += nbElemByPage;
|
||||
}
|
||||
}
|
||||
|
||||
a_star_node* poss_a_star_node::getAStarNode(void)
|
||||
{
|
||||
|
@ -71,16 +71,16 @@ a_star_node* poss_a_star_node::getAStarNode(void)
|
|||
wassert(curIndex <= capacity);
|
||||
//---------------------------------------------------
|
||||
a_star_node* locPageAStarNode;
|
||||
|
||||
|
||||
if (curIndex == capacity)
|
||||
addPage();
|
||||
|
||||
const size_t locIndexPage = curIndex / nbElemByPage;
|
||||
const size_t locIndexInsidePage = curIndex % nbElemByPage;
|
||||
const size_t locIndexPage = curIndex / nbElemByPage;
|
||||
const size_t locIndexInsidePage = curIndex % nbElemByPage;
|
||||
++curIndex;
|
||||
|
||||
assertParanoAstar(locIndexPage < vectPageAStarNode.size());
|
||||
locPageAStarNode = vectPageAStarNode[locIndexPage];
|
||||
locPageAStarNode = vectPageAStarNode[locIndexPage];
|
||||
assertParanoAstar(locIndexInsidePage < nbElemByPage);
|
||||
return (&(locPageAStarNode[locIndexInsidePage]));
|
||||
}
|
||||
|
@ -93,13 +93,13 @@ void poss_a_star_node::reduce(void)
|
|||
delete[] (*iter);
|
||||
vectPageAStarNode.resize(1);
|
||||
capacity = nbElemByPage;
|
||||
}
|
||||
curIndex = 0;
|
||||
}
|
||||
curIndex = 0;
|
||||
//----------------- POST_CONDITIONS -----------------
|
||||
wassert(capacity == nbElemByPage);
|
||||
wassert(vectPageAStarNode.size() == 1);
|
||||
//---------------------------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
void a_star_world::resize_IFN(const size_t parWidth, const size_t parHeight)
|
||||
{
|
||||
|
@ -121,23 +121,23 @@ void a_star_world::clear(void)
|
|||
a_star_node* locNode = NULL;
|
||||
std::fill(_vectAStarNode.begin(), _vectAStarNode.end(), locNode);
|
||||
_nbNode = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool a_star_world::empty(void)
|
||||
{
|
||||
{
|
||||
return (_nbNode == 0);
|
||||
}
|
||||
|
||||
bool a_star_world::reallyEmpty(void)
|
||||
{
|
||||
for (vect_a_star_node::iterator iter = _vectAStarNode.begin(); iter != _vectAStarNode.end(); ++iter)
|
||||
{
|
||||
for (vect_a_star_node::iterator iter = _vectAStarNode.begin(); iter != _vectAStarNode.end(); ++iter)
|
||||
{
|
||||
if (*iter != NULL)
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
void a_star_world::erase(gamemap::location const &loc)
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ void a_star_world::erase(gamemap::location const &loc)
|
|||
}
|
||||
|
||||
a_star_node* a_star_world::getNodeFromLocation(gamemap::location const &loc, bool& isCreated)
|
||||
{
|
||||
{
|
||||
//----------------- PRE_CONDITIONS ------------------
|
||||
wassert(loc.valid());
|
||||
//---------------------------------------------------
|
||||
|
@ -164,7 +164,7 @@ a_star_node* a_star_world::getNodeFromLocation(gamemap::location const &loc, boo
|
|||
isCreated = true;
|
||||
wassert(SingletonPOSS_AStarNode != NULL);
|
||||
node = SingletonPOSS_AStarNode->getAStarNode();
|
||||
_vectAStarNode[index] = node;
|
||||
_vectAStarNode[index] = node;
|
||||
++_nbNode;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -29,16 +29,16 @@ See the COPYING file for more details.
|
|||
struct a_star_node
|
||||
{
|
||||
public:
|
||||
double g, h; // g: already traveled time, h: estimated time still to travel
|
||||
double g, h; // g: already traveled time, h: estimated time still to travel
|
||||
gamemap::location loc;
|
||||
a_star_node* nodeParent;
|
||||
bool isInCloseList;
|
||||
|
||||
|
||||
void initNode( const gamemap::location& pos, const gamemap::location& dst,
|
||||
double cost, a_star_node* parent,
|
||||
const std::set<gamemap::location>* teleports);
|
||||
const std::set<gamemap::location>* teleports);
|
||||
|
||||
inline double heuristic(const gamemap::location& src, const gamemap::location& dst)
|
||||
inline double heuristic(const gamemap::location& src, const gamemap::location& dst)
|
||||
{
|
||||
return distance_between(src, dst);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
poss_a_star_node(void);
|
||||
void addPage(void);
|
||||
a_star_node* getAStarNode(void);
|
||||
void reduce(void);
|
||||
void reduce(void);
|
||||
};
|
||||
|
||||
class a_star_world
|
||||
|
@ -66,7 +66,7 @@ class a_star_world
|
|||
protected:
|
||||
typedef std::vector<a_star_node*> vect_a_star_node;
|
||||
|
||||
vect_a_star_node _vectAStarNode;
|
||||
vect_a_star_node _vectAStarNode;
|
||||
size_t _width;
|
||||
|
||||
public:
|
||||
|
@ -75,10 +75,10 @@ public:
|
|||
void resize_IFN(const size_t parWidth, const size_t parHeight);
|
||||
void clear(void);
|
||||
void erase(gamemap::location const &loc);
|
||||
a_star_node* getNodeFromLocation(gamemap::location const &loc, bool& isCreated);
|
||||
a_star_node* getNodeFromLocation(gamemap::location const &loc, bool& isCreated);
|
||||
bool empty(void);
|
||||
bool reallyEmpty(void);
|
||||
a_star_world(void) : _width(0), _nbNode(0) {};
|
||||
a_star_world(void) : _width(0), _nbNode(0) {};
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
134
src/builder.cpp
134
src/builder.cpp
|
@ -53,19 +53,19 @@ image::locator locator_string_initializer::operator()(const std::string &s) cons
|
|||
const int terrain_builder::rule_image::TILEWIDTH = 72;
|
||||
const int terrain_builder::rule_image::UNITPOS = 36 + 18;
|
||||
|
||||
terrain_builder::rule_image::rule_image(int layer, bool global_image) :
|
||||
terrain_builder::rule_image::rule_image(int layer, bool global_image) :
|
||||
position(HORIZONTAL), layer(layer),
|
||||
basex(0), basey(0), global_image(global_image)
|
||||
{}
|
||||
|
||||
terrain_builder::rule_image::rule_image(int x, int y, bool global_image) :
|
||||
terrain_builder::rule_image::rule_image(int x, int y, bool global_image) :
|
||||
position(VERTICAL), layer(0),
|
||||
basex(x), basey(y), global_image(global_image)
|
||||
{}
|
||||
|
||||
terrain_builder::tile::tile() : last_tod("invalid_tod")
|
||||
{
|
||||
memset(adjacents, 0, sizeof(adjacents));
|
||||
memset(adjacents, 0, sizeof(adjacents));
|
||||
}
|
||||
|
||||
void terrain_builder::tile::add_image_to_cache(const std::string &tod, ordered_ri_list::const_iterator itor) const
|
||||
|
@ -85,26 +85,26 @@ void terrain_builder::tile::add_image_to_cache(const std::string &tod, ordered_r
|
|||
}
|
||||
}
|
||||
|
||||
void terrain_builder::tile::rebuild_cache(const std::string &tod) const
|
||||
void terrain_builder::tile::rebuild_cache(const std::string &tod) const
|
||||
{
|
||||
images_background.clear();
|
||||
images_foreground.clear();
|
||||
|
||||
ordered_ri_list::const_iterator itor;
|
||||
for(itor = horizontal_images.begin(); itor != horizontal_images.end(); ++itor) {
|
||||
if (itor->first <= 0)
|
||||
if (itor->first <= 0)
|
||||
add_image_to_cache(tod, itor);
|
||||
}
|
||||
for(itor = vertical_images.begin(); itor != vertical_images.end(); ++itor) {
|
||||
add_image_to_cache(tod, itor);
|
||||
}
|
||||
for(itor = horizontal_images.begin(); itor != horizontal_images.end(); ++itor) {
|
||||
if (itor->first > 0)
|
||||
if (itor->first > 0)
|
||||
add_image_to_cache(tod, itor);
|
||||
}
|
||||
}
|
||||
|
||||
void terrain_builder::tile::clear()
|
||||
void terrain_builder::tile::clear()
|
||||
{
|
||||
flags.clear();
|
||||
horizontal_images.clear();
|
||||
|
@ -125,21 +125,21 @@ bool terrain_builder::tilemap::on_map(const gamemap::location &loc) const
|
|||
{
|
||||
if(loc.x < -1 || loc.y < -1 || loc.x > x_ || loc.y > y_)
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
terrain_builder::tile& terrain_builder::tilemap::operator[](const gamemap::location &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
|
||||
{
|
||||
wassert(on_map(loc));
|
||||
|
||||
|
||||
return map_[(loc.x+1) + (loc.y+1)*(x_+2)];
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ terrain_builder::terrain_builder(const config& cfg, const config& level, const g
|
|||
}
|
||||
|
||||
const terrain_builder::imagelist *terrain_builder::get_terrain_at(const gamemap::location &loc,
|
||||
const std::string &tod, ADJACENT_TERRAIN_TYPE terrain_type) const
|
||||
const std::string &tod, ADJACENT_TERRAIN_TYPE terrain_type) const
|
||||
{
|
||||
if(!tile_map_.on_map(loc))
|
||||
return NULL;
|
||||
|
@ -169,7 +169,7 @@ const terrain_builder::imagelist *terrain_builder::get_terrain_at(const gamemap:
|
|||
if(!tile_at.images_background.empty())
|
||||
return &tile_at.images_background;
|
||||
}
|
||||
|
||||
|
||||
if(terrain_type == ADJACENT_FOREGROUND) {
|
||||
if(!tile_at.images_foreground.empty())
|
||||
return &tile_at.images_foreground;
|
||||
|
@ -204,7 +204,7 @@ bool terrain_builder::update_animation(const gamemap::location &loc)
|
|||
return changed;
|
||||
}
|
||||
|
||||
// TODO: rename this function
|
||||
// TODO: rename this function
|
||||
void terrain_builder::rebuild_terrain(const gamemap::location &loc)
|
||||
{
|
||||
if (tile_map_.on_map(loc)) {
|
||||
|
@ -242,7 +242,7 @@ bool terrain_builder::rule_valid(const building_rule &rule)
|
|||
|
||||
for(constraint = rule.constraints.begin();
|
||||
constraint != rule.constraints.end(); ++constraint) {
|
||||
for(image = constraint->second.images.begin();
|
||||
for(image = constraint->second.images.begin();
|
||||
image != constraint->second.images.end();
|
||||
++image) {
|
||||
|
||||
|
@ -268,7 +268,7 @@ bool terrain_builder::start_animation(building_rule &rule)
|
|||
for(constraint = rule.constraints.begin();
|
||||
constraint != rule.constraints.end(); ++constraint) {
|
||||
|
||||
for(image = constraint->second.images.begin();
|
||||
for(image = constraint->second.images.begin();
|
||||
image != constraint->second.images.end();
|
||||
++image) {
|
||||
|
||||
|
@ -295,7 +295,7 @@ bool terrain_builder::start_animation(building_rule &rule)
|
|||
|
||||
terrain_builder::terrain_constraint terrain_builder::rotate(const terrain_builder::terrain_constraint &constraint, int angle)
|
||||
{
|
||||
static const struct { int ii; int ij; int ji; int jj; } rotations[6] =
|
||||
static const struct { int ii; int ij; int ji; int jj; } rotations[6] =
|
||||
{ { 1, 0, 0, 1 }, { 1, 1, -1, 0 }, { 0, 1, -1, -1 },
|
||||
{ -1, 0, 0, -1 }, { -1, -1, 1, 0 }, { 0, -1, 1, 1 } };
|
||||
|
||||
|
@ -319,17 +319,17 @@ terrain_builder::terrain_constraint terrain_builder::rotate(const terrain_builde
|
|||
//
|
||||
// (demonstration left as an exercise for the reader)
|
||||
//
|
||||
// So we have
|
||||
// So we have
|
||||
//
|
||||
// r = [[ 1/2 -3/4 ]
|
||||
// [ 1 1/2 ]]
|
||||
//
|
||||
// And the following array contains I(2), r, r^2, r^3, r^4, r^5 (with
|
||||
// r^3 == -I(2)), which are the successive rotations.
|
||||
static const struct {
|
||||
static const struct {
|
||||
double xx;
|
||||
double xy;
|
||||
double yx;
|
||||
double yx;
|
||||
double yy;
|
||||
} xyrotations[6] = {
|
||||
{ 1., 0., 0., 1. },
|
||||
|
@ -342,16 +342,16 @@ terrain_builder::terrain_constraint terrain_builder::rotate(const terrain_builde
|
|||
|
||||
wassert(angle >= 0);
|
||||
|
||||
angle %= 6;
|
||||
angle %= 6;
|
||||
terrain_constraint ret = constraint;
|
||||
|
||||
// Vector i is going from n to s, vector j is going from ne to sw.
|
||||
int vi = ret.loc.y - ret.loc.x/2;
|
||||
int vj = ret.loc.x;
|
||||
|
||||
|
||||
int ri = rotations[angle].ii * vi + rotations[angle].ij * vj;
|
||||
int rj = rotations[angle].ji * vi + rotations[angle].jj * vj;
|
||||
|
||||
|
||||
ret.loc.x = rj;
|
||||
ret.loc.y = ri + (rj >= 0 ? rj/2 : (rj-1)/2);
|
||||
|
||||
|
@ -382,7 +382,7 @@ terrain_builder::terrain_constraint terrain_builder::rotate(const terrain_builde
|
|||
void terrain_builder::replace_token(std::string &s, const std::string &token, const std::string &replacement)
|
||||
{
|
||||
size_t pos;
|
||||
|
||||
|
||||
if(token.empty()) {
|
||||
ERR_NG << "empty token in replace_token\n";
|
||||
return;
|
||||
|
@ -419,10 +419,10 @@ void terrain_builder::replace_token(terrain_builder::building_rule &rule, const
|
|||
{
|
||||
constraint_set::iterator cons;
|
||||
|
||||
for(cons = rule.constraints.begin(); cons != rule.constraints.end(); ++cons) {
|
||||
for(cons = rule.constraints.begin(); cons != rule.constraints.end(); ++cons) {
|
||||
//Transforms attributes
|
||||
std::vector<std::string>::iterator flag;
|
||||
|
||||
|
||||
for(flag = cons->second.set_flag.begin(); flag != cons->second.set_flag.end(); flag++) {
|
||||
replace_token(*flag, token, replacement);
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ void terrain_builder::replace_token(terrain_builder::building_rule &rule, const
|
|||
//replace_token(rule.images, token, replacement);
|
||||
}
|
||||
|
||||
terrain_builder::building_rule terrain_builder::rotate_rule(const terrain_builder::building_rule &rule,
|
||||
terrain_builder::building_rule terrain_builder::rotate_rule(const terrain_builder::building_rule &rule,
|
||||
int angle, const std::vector<std::string>& rot)
|
||||
{
|
||||
building_rule ret;
|
||||
|
@ -473,7 +473,7 @@ terrain_builder::building_rule terrain_builder::rotate_rule(const terrain_builde
|
|||
if(!(miny & 1) && (minx & 1) && (minx > 0))
|
||||
miny -= 2;
|
||||
|
||||
for(cons2 = tmp_cons.begin(); cons2 != tmp_cons.end(); ++cons2) {
|
||||
for(cons2 = tmp_cons.begin(); cons2 != tmp_cons.end(); ++cons2) {
|
||||
//Adjusts positions
|
||||
cons2->second.loc += gamemap::location(-minx, -((miny-1)/2));
|
||||
ret.constraints[cons2->second.loc] = cons2->second;
|
||||
|
@ -498,8 +498,8 @@ void terrain_builder::add_images_from_config(rule_imagelist& images, const confi
|
|||
|
||||
const std::string &name = (**img)["name"];
|
||||
|
||||
if((**img)["position"].empty() ||
|
||||
(**img)["position"] == "horizontal") {
|
||||
if((**img)["position"].empty() ||
|
||||
(**img)["position"] == "horizontal") {
|
||||
|
||||
const int layer = atoi((**img)["layer"].c_str());
|
||||
images.push_back(rule_image(layer, global));
|
||||
|
@ -514,7 +514,7 @@ void terrain_builder::add_images_from_config(rule_imagelist& images, const confi
|
|||
basey = atoi(base[1].c_str());
|
||||
}
|
||||
images.push_back(rule_image(basex - dx, basey - dy, global));
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Adds the main (default) variant of the image, if present
|
||||
|
@ -535,7 +535,7 @@ void terrain_builder::add_images_from_config(rule_imagelist& images, const confi
|
|||
}
|
||||
|
||||
void terrain_builder::add_constraints(
|
||||
terrain_builder::constraint_set& constraints,
|
||||
terrain_builder::constraint_set& constraints,
|
||||
const gamemap::location& loc,
|
||||
const std::string& type, const config& global_images)
|
||||
{
|
||||
|
@ -545,10 +545,10 @@ void terrain_builder::add_constraints(
|
|||
}
|
||||
|
||||
if(!type.empty())
|
||||
constraints[loc].terrain_types = type;
|
||||
|
||||
constraints[loc].terrain_types = type;
|
||||
|
||||
int x = loc.x * rule_image::TILEWIDTH * 3 / 4;
|
||||
int y = loc.y * rule_image::TILEWIDTH + (loc.x % 2) *
|
||||
int y = loc.y * rule_image::TILEWIDTH + (loc.x % 2) *
|
||||
rule_image::TILEWIDTH / 2;
|
||||
add_images_from_config(constraints[loc].images, global_images, true, x, y);
|
||||
|
||||
|
@ -585,7 +585,7 @@ void terrain_builder::parse_mapstring(const std::string &mapstring,
|
|||
|
||||
const std::vector<std::string> &lines = utils::split(mapstring, '\n', 0);
|
||||
std::vector<std::string>::const_iterator line = lines.begin();
|
||||
|
||||
|
||||
//Strips trailing empty lines
|
||||
while (line != lines.end() && std::find_if(line->begin(), line->end(), utils::notspace) == line->end()) {
|
||||
line++;
|
||||
|
@ -593,7 +593,7 @@ void terrain_builder::parse_mapstring(const std::string &mapstring,
|
|||
//Break if there only are blank lines
|
||||
if(line == lines.end())
|
||||
return;
|
||||
|
||||
|
||||
//If the strings starts with a space, the first line is an odd line,
|
||||
//else it is an even one
|
||||
if((*line)[0] == ' ')
|
||||
|
@ -613,7 +613,7 @@ void terrain_builder::parse_mapstring(const std::string &mapstring,
|
|||
while(lpos < line->size()) {
|
||||
std::string types = line->substr(lpos, 4);
|
||||
utils::strip(types);
|
||||
|
||||
|
||||
//If there are numbers in the types string, consider it
|
||||
//is an anchor
|
||||
if(types[0] == '.') {
|
||||
|
@ -650,7 +650,7 @@ void terrain_builder::add_rotated_rules(building_ruleset& rules, building_rule&
|
|||
add_rule(rules, tpl);
|
||||
} else {
|
||||
const std::vector<std::string>& rot = utils::split(rotations, ',');
|
||||
|
||||
|
||||
for(size_t angle = 0; angle < rot.size(); angle++) {
|
||||
building_rule rule = rotate_rule(tpl, angle, rot);
|
||||
add_rule(rules, rule);
|
||||
|
@ -661,7 +661,7 @@ void terrain_builder::add_rotated_rules(building_ruleset& rules, building_rule&
|
|||
void terrain_builder::parse_config(const config &cfg)
|
||||
{
|
||||
log_scope("terrain_builder::parse_config");
|
||||
|
||||
|
||||
//Parses the list of building rules (BRs)
|
||||
const config::child_list& brs = cfg.get_children("terrain_graphics");
|
||||
|
||||
|
@ -672,19 +672,19 @@ void terrain_builder::parse_config(const config &cfg)
|
|||
|
||||
if(!((**br)["x"].empty() || (**br)["y"].empty()))
|
||||
pbr.location_constraints = gamemap::location(atoi((**br)["x"].c_str()), atoi((**br)["y"].c_str()));
|
||||
|
||||
|
||||
pbr.probability = (**br)["probability"].empty() ? -1 : atoi((**br)["probability"].c_str());
|
||||
pbr.precedence = (**br)["precedence"].empty() ? 0 : atoi((**br)["precedence"].c_str());
|
||||
|
||||
//Mapping anchor indices to anchor locations.
|
||||
|
||||
//Mapping anchor indices to anchor locations.
|
||||
anchormap anchors;
|
||||
|
||||
|
||||
// Parse the map= , if there is one (and fill the anchors list)
|
||||
parse_mapstring((**br)["map"], pbr, anchors, **br);
|
||||
|
||||
// Parses the terrain constraints (TCs)
|
||||
config::child_list tcs((*br)->get_children("tile"));
|
||||
|
||||
|
||||
for(config::child_list::const_iterator tc = tcs.begin(); tc != tcs.end(); tc++) {
|
||||
//Adds the terrain constraint to the current built
|
||||
//terrain's list of terrain constraints, if it does not
|
||||
|
@ -692,10 +692,10 @@ void terrain_builder::parse_config(const config &cfg)
|
|||
gamemap::location loc;
|
||||
if((**tc)["x"].size()) {
|
||||
loc.x = atoi((**tc)["x"].c_str());
|
||||
}
|
||||
}
|
||||
if((**tc)["y"].size()) {
|
||||
loc.y = atoi((**tc)["y"].c_str());
|
||||
}
|
||||
}
|
||||
if(!(**tc)["loc"].empty()) {
|
||||
std::vector<std::string> sloc = utils::split((**tc)["loc"]);
|
||||
if(sloc.size() == 2) {
|
||||
|
@ -715,27 +715,27 @@ void terrain_builder::parse_config(const config &cfg)
|
|||
|
||||
std::pair<anchormap::const_iterator, anchormap::const_iterator> range =
|
||||
anchors.equal_range(pos);
|
||||
|
||||
|
||||
for(; range.first != range.second; range.first++) {
|
||||
loc = range.first->second;
|
||||
add_constraints(pbr.constraints, loc, **tc, **br);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::string global_set_flag = (**br)["set_flag"];
|
||||
const std::string global_no_flag = (**br)["no_flag"];
|
||||
const std::string global_has_flag = (**br)["has_flag"];
|
||||
|
||||
|
||||
for(constraint_set::iterator constraint = pbr.constraints.begin(); constraint != pbr.constraints.end();
|
||||
constraint++) {
|
||||
|
||||
|
||||
if(global_set_flag.size())
|
||||
constraint->second.set_flag.push_back(global_set_flag);
|
||||
|
||||
|
||||
if(global_no_flag.size())
|
||||
constraint->second.no_flag.push_back(global_no_flag);
|
||||
|
||||
|
||||
if(global_has_flag.size())
|
||||
constraint->second.has_flag.push_back(global_has_flag);
|
||||
|
||||
|
@ -750,7 +750,7 @@ void terrain_builder::parse_config(const config &cfg)
|
|||
|
||||
#if 0
|
||||
std::cerr << "Built terrain rules: \n";
|
||||
|
||||
|
||||
building_ruleset::const_iterator rule;
|
||||
for(rule = building_rules_.begin(); rule != building_rules_.end(); ++rule) {
|
||||
std::cerr << ">> New rule: image_background = " /* << rule->second.image_background << " , image_foreground = "<< rule->second.image_foreground */ << "\n";
|
||||
|
@ -761,14 +761,14 @@ void terrain_builder::parse_config(const config &cfg)
|
|||
<< "), terrain types = " << constraint->second.terrain_types << "\n";
|
||||
|
||||
std::vector<std::string>::const_iterator flag;
|
||||
|
||||
|
||||
for(flag = constraint->second.set_flag.begin(); flag != constraint->second.set_flag.end(); ++flag) {
|
||||
std::cerr << ">>>>>> Set_flag: " << *flag << "\n";
|
||||
}
|
||||
|
||||
for(flag = constraint->second.no_flag.begin(); flag != constraint->second.no_flag.end(); ++flag) {
|
||||
std::cerr << ">>>>>> No_flag: " << *flag << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -882,7 +882,7 @@ void terrain_builder::apply_rule(const terrain_builder::building_rule &rule, con
|
|||
}
|
||||
|
||||
// Sets flags
|
||||
for(std::vector<std::string>::const_iterator itor = constraint->second.set_flag.begin();
|
||||
for(std::vector<std::string>::const_iterator itor = constraint->second.set_flag.begin();
|
||||
itor != constraint->second.set_flag.end(); itor++) {
|
||||
btile.flags.insert(*itor);
|
||||
}
|
||||
|
@ -897,12 +897,12 @@ int terrain_builder::get_constraint_adjacents(const building_rule& rule, const g
|
|||
gamemap::location adj[6];
|
||||
int i;
|
||||
get_adjacent_tiles(loc, adj);
|
||||
|
||||
|
||||
for(i = 0; i < 6; ++i) {
|
||||
if(rule.constraints.find(adj[i]) != rule.constraints.end()) {
|
||||
res++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -910,7 +910,7 @@ int terrain_builder::get_constraint_adjacents(const building_rule& rule, const g
|
|||
//this constraint may possibly match. INT_MAX means "I don't know / all of them".
|
||||
int terrain_builder::get_constraint_size(const building_rule& rule, const terrain_constraint& constraint, bool& border)
|
||||
{
|
||||
const std::string &types = constraint.terrain_types;
|
||||
const std::string &types = constraint.terrain_types;
|
||||
|
||||
if(types.empty())
|
||||
return INT_MAX;
|
||||
|
@ -941,7 +941,7 @@ int terrain_builder::get_constraint_size(const building_rule& rule, const terrai
|
|||
}
|
||||
if(border == true)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int constraint_size = 0;
|
||||
|
||||
|
@ -981,7 +981,7 @@ void terrain_builder::build_terrains()
|
|||
tile_map_[loc].adjacents[i+1] = map_.get_terrain(adj[i]);
|
||||
|
||||
//determines if this tile is a border tile
|
||||
if(map_.get_terrain(adj[i]) != t)
|
||||
if(map_.get_terrain(adj[i]) != t)
|
||||
border = true;
|
||||
}
|
||||
if(border)
|
||||
|
@ -991,7 +991,7 @@ void terrain_builder::build_terrains()
|
|||
|
||||
int rule_index = 0;
|
||||
building_ruleset::const_iterator rule;
|
||||
|
||||
|
||||
for(rule = building_rules_.begin(); rule != building_rules_.end(); ++rule) {
|
||||
|
||||
if (rule->second.location_constraints.valid()) {
|
||||
|
@ -1010,7 +1010,7 @@ void terrain_builder::build_terrains()
|
|||
|
||||
for(constraint = rule->second.constraints.begin();
|
||||
constraint != rule->second.constraints.end(); ++constraint) {
|
||||
|
||||
|
||||
bool border;
|
||||
|
||||
int size = get_constraint_size(rule->second, constraint->second, border);
|
||||
|
@ -1041,7 +1041,7 @@ void terrain_builder::build_terrains()
|
|||
adjacent_types[i] = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(smallest_constraint_size != INT_MAX) {
|
||||
const std::string &types = smallest_constraint->second.terrain_types;
|
||||
|
@ -1055,10 +1055,10 @@ void terrain_builder::build_terrains()
|
|||
} else {
|
||||
locations = &terrain_by_type_[*c];
|
||||
}
|
||||
|
||||
|
||||
for(std::vector<gamemap::location>::const_iterator itor = locations->begin();
|
||||
itor != locations->end(); ++itor) {
|
||||
|
||||
|
||||
if(biggest_constraint_adjacent > 0) {
|
||||
const gamemap::location pos = (*itor - loc) + aloc;
|
||||
if(!tile_map_.on_map(pos))
|
||||
|
@ -1066,7 +1066,7 @@ void terrain_builder::build_terrains()
|
|||
|
||||
const gamemap::TERRAIN *adjacents = tile_map_[pos].adjacents;
|
||||
int i;
|
||||
|
||||
|
||||
for(i = 0; i < 7; ++i) {
|
||||
if(!terrain_matches(adjacents[i], adjacent_types[i])) {
|
||||
break;
|
||||
|
|
|
@ -28,7 +28,7 @@ class config;
|
|||
* The class terrain_builder is constructed from a config object, and a gamemap
|
||||
* object. On construction, it parses the configuration and extracts the list
|
||||
* of [terrain_graphics] rules. Each terrain_graphics rule attachs one or more
|
||||
* images to a specific terrain pattern.
|
||||
* images to a specific terrain pattern.
|
||||
* It then applies the rules loaded from the configuration to the current map,
|
||||
* and calculates the list of images that must be associated to each hex of the
|
||||
* map.
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
* changed, and must be redrawn.
|
||||
*
|
||||
* @param loc the location to update
|
||||
*
|
||||
*
|
||||
* @return true: this tile must be redrawn.
|
||||
*/
|
||||
bool update_animation(const gamemap::location &loc);
|
||||
|
@ -205,9 +205,9 @@ public:
|
|||
struct terrain_constraint
|
||||
{
|
||||
terrain_constraint() : loc() {};
|
||||
|
||||
|
||||
terrain_constraint(gamemap::location loc) : loc(loc) {};
|
||||
|
||||
|
||||
gamemap::location loc;
|
||||
std::string terrain_types;
|
||||
std::vector<std::string> set_flag;
|
||||
|
@ -229,7 +229,7 @@ public:
|
|||
typedef std::multimap<int, const rule_image*> ordered_ri_list;
|
||||
|
||||
/** Contructor for the tile() structure */
|
||||
tile();
|
||||
tile();
|
||||
|
||||
/** Adds an image, extracted from an ordered rule_image list,
|
||||
* to the background or foreground image cache.
|
||||
|
@ -252,7 +252,7 @@ public:
|
|||
|
||||
/** Clears all data in this tile, and resets the cache */
|
||||
void clear();
|
||||
|
||||
|
||||
/** The list of flags present in this tile */
|
||||
std::set<std::string> flags;
|
||||
|
||||
|
@ -277,7 +277,7 @@ public:
|
|||
*/
|
||||
mutable imagelist images_background;
|
||||
/**
|
||||
* The time-of-day to which the image caches correspond.
|
||||
* The time-of-day to which the image caches correspond.
|
||||
*/
|
||||
mutable std::string last_tod;
|
||||
|
||||
|
@ -286,7 +286,7 @@ public:
|
|||
* this tile.
|
||||
*/
|
||||
gamemap::TERRAIN adjacents[7];
|
||||
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -327,7 +327,7 @@ private:
|
|||
*/
|
||||
int precedence;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The map of "tile" structures corresponding to the level map.
|
||||
*/
|
||||
|
@ -352,7 +352,7 @@ private:
|
|||
* a const variant of operator[]
|
||||
*/
|
||||
const tile &operator[] (const gamemap::location &loc) const;
|
||||
|
||||
|
||||
/**
|
||||
* Tests if a location is on the map
|
||||
*
|
||||
|
@ -361,7 +361,7 @@ private:
|
|||
* @return true if loc is on the map, false otherwise.
|
||||
*/
|
||||
bool on_map(const gamemap::location &loc) const;
|
||||
|
||||
|
||||
/**
|
||||
* Resets the whole tile map
|
||||
*/
|
||||
|
@ -380,7 +380,7 @@ private:
|
|||
* of [terrain_graphics] rules.
|
||||
*/
|
||||
typedef std::multimap<int, building_rule> building_ruleset;
|
||||
|
||||
|
||||
/**
|
||||
* Tests for validity of a rule. A rule is considered valid if all its
|
||||
* images are present. This method is used, when building the ruleset,
|
||||
|
@ -392,7 +392,7 @@ private:
|
|||
*/
|
||||
bool rule_valid(const building_rule &rule);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Starts the animation on a rule.
|
||||
*
|
||||
* @param rule The rule on which ot start animations
|
||||
|
@ -427,7 +427,7 @@ private:
|
|||
* @param token The token to substitute
|
||||
* @param replacement The replacement string
|
||||
*/
|
||||
void replace_token(std::string &s, const std::string &token,
|
||||
void replace_token(std::string &s, const std::string &token,
|
||||
const std::string& replacement);
|
||||
|
||||
/**
|
||||
|
@ -439,7 +439,7 @@ private:
|
|||
* @param token The token to substitute
|
||||
* @param replacement The replacement string
|
||||
*/
|
||||
void replace_token(rule_image_variant &variant, const std::string &token,
|
||||
void replace_token(rule_image_variant &variant, const std::string &token,
|
||||
const std::string& replacement);
|
||||
|
||||
/**
|
||||
|
@ -450,10 +450,10 @@ private:
|
|||
* @param token The token to substitute
|
||||
* @param replacement The replacement string
|
||||
*/
|
||||
void replace_token(rule_image &image, const std::string &token,
|
||||
void replace_token(rule_image &image, const std::string &token,
|
||||
const std::string& replacement);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Replaces, in a given rule_imagelist, a token with its value. The
|
||||
* actual substitution is done in all rule_images contained in the
|
||||
* rule_imagelist.
|
||||
|
@ -465,7 +465,7 @@ private:
|
|||
void replace_token(rule_imagelist &, const std::string &token,
|
||||
const std::string& replacement);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Replaces, in a given building_rule, a token with its value. The
|
||||
* actual substitution is done in the rule_imagelists contained in all
|
||||
* constraints of the building_rule, and in the flags (has_flag,
|
||||
|
@ -479,7 +479,7 @@ private:
|
|||
void replace_token(building_rule &s, const std::string &token,
|
||||
const std::string& replacement);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Rotates a template rule to a given angle, and returns the rotated
|
||||
* rule.
|
||||
*
|
||||
|
@ -488,7 +488,7 @@ private:
|
|||
* <code>@Rn</code>, n being a number from 0 to 5.
|
||||
* * The rule contains the rotations=r0,r1,r2,r3,r4,r5, with r0 to r5
|
||||
* being strings describing the 6 different positions, typically, n,
|
||||
* ne, se, s, sw, and nw (buy may be anything else.)
|
||||
* ne, se, s, sw, and nw (buy may be anything else.)
|
||||
*
|
||||
* A template rule will generate 6 rules, which are similar to the
|
||||
* template, except that:
|
||||
|
@ -506,7 +506,7 @@ private:
|
|||
*
|
||||
* * On the rule rotated 2pi/3, those will be replaced by r2, r3, r4,
|
||||
* r5, r0, r1 and so on.
|
||||
*
|
||||
*
|
||||
*/
|
||||
building_rule rotate_rule(const building_rule &rule, int angle, const
|
||||
std::vector<std::string>& angle_name);
|
||||
|
@ -560,7 +560,7 @@ private:
|
|||
void add_constraints(constraint_set& constraints,
|
||||
const gamemap::location &loc, const config &cfg,
|
||||
const config& global_images);
|
||||
|
||||
|
||||
typedef std::multimap<int, gamemap::location> anchormap;
|
||||
|
||||
/**
|
||||
|
@ -634,7 +634,7 @@ private:
|
|||
* already checked, only flags and probability will be
|
||||
* checked.
|
||||
*/
|
||||
bool rule_matches(const building_rule &rule, const gamemap::location &loc,
|
||||
bool rule_matches(const building_rule &rule, const gamemap::location &loc,
|
||||
int rule_index, bool check_loc);
|
||||
|
||||
/**
|
||||
|
@ -682,7 +682,7 @@ private:
|
|||
* constraint may match. INT_MAX means "all of them" or "unable
|
||||
* to determine"
|
||||
*/
|
||||
int get_constraint_size(const building_rule& rule, const terrain_constraint& constraint,
|
||||
int get_constraint_size(const building_rule& rule, const terrain_constraint& constraint,
|
||||
bool& border);
|
||||
|
||||
/**
|
||||
|
@ -690,7 +690,7 @@ private:
|
|||
* from the gamemap and the building_rules_.
|
||||
*/
|
||||
void build_terrains();
|
||||
|
||||
|
||||
/**
|
||||
* A reference to the gamemap class used in the current level.
|
||||
*/
|
||||
|
|
|
@ -158,7 +158,7 @@ void campaign_server::run()
|
|||
|
||||
//erase the campaign
|
||||
write_file((*campaign)["filename"],"");
|
||||
|
||||
|
||||
const config::child_list& campaigns_list = campaigns().get_children("campaign");
|
||||
const size_t index = std::find(campaigns_list.begin(),campaigns_list.end(),campaign) - campaigns_list.begin();
|
||||
campaigns().remove_child("campaign",index);
|
||||
|
|
|
@ -131,7 +131,7 @@ void cave_map_generator::generate_chambers()
|
|||
if(chance != "" && (rand()%100) < atoi(chance.c_str())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
const std::string& xpos = (**i)["x"];
|
||||
const std::string& ypos = (**i)["y"];
|
||||
|
||||
|
@ -269,7 +269,7 @@ struct passage_path_calculator : cost_calculator
|
|||
passage_path_calculator(const std::vector<std::vector<gamemap::TERRAIN> >& mapdata, gamemap::TERRAIN wall, double laziness, size_t windiness)
|
||||
: map_(mapdata), wall_(wall), laziness_(laziness), windiness_(windiness)
|
||||
{}
|
||||
|
||||
|
||||
virtual double cost(const gamemap::location& loc, const double so_far, const bool is_dest) const;
|
||||
private:
|
||||
const std::vector<std::vector<gamemap::TERRAIN> >& map_;
|
||||
|
@ -305,15 +305,15 @@ void cave_map_generator::place_passage(const passage& p)
|
|||
|
||||
const size_t windiness = atoi(p.cfg["windiness"].c_str());
|
||||
const double laziness = maximum<double>(1.0,atof(p.cfg["laziness"].c_str()));
|
||||
|
||||
|
||||
passage_path_calculator calc(map_,wall_,laziness,windiness);
|
||||
|
||||
|
||||
const paths::route rt = a_star_search(p.src, p.dst, 10000.0, &calc, width_, height_);
|
||||
|
||||
const size_t width = maximum<size_t>(1,atoi(p.cfg["width"].c_str()));
|
||||
|
||||
const size_t jagged = atoi(p.cfg["jagged"].c_str());
|
||||
|
||||
|
||||
for(std::vector<gamemap::location>::const_iterator i = rt.steps.begin(); i != rt.steps.end(); ++i) {
|
||||
std::set<gamemap::location> locs;
|
||||
build_chamber(*i,locs,width,jagged);
|
||||
|
|
|
@ -42,7 +42,7 @@ private:
|
|||
void place_items(const chamber& c, config::all_children_iterator i1, config::all_children_iterator i2);
|
||||
|
||||
void place_passage(const passage& p);
|
||||
|
||||
|
||||
bool on_board(const gamemap::location& loc) const;
|
||||
void set_terrain(gamemap::location loc, gamemap::TERRAIN t);
|
||||
void place_castle(const std::string& side, gamemap::location loc);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2005 by Philippe Plantier <ayin@anathas.org>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2005 by Philippe Plantier <ayin@anathas.org>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
#define CLIPBOARD_FUNCS_DEFINED
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <unistd.h>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
/**
|
||||
The following are two classes which wrap the SDL's interface to X, including
|
||||
The following are two classes which wrap the SDL's interface to X, including
|
||||
locking/unlocking, and which manage the atom internment. They exist mainly to make
|
||||
the actual clipboard code somewhat readable
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ private:
|
|||
{
|
||||
acquireCount_ = 0;
|
||||
acquire();
|
||||
|
||||
|
||||
//Intern some atoms;
|
||||
const char* atoms[] = {
|
||||
"CLIPBOARD",
|
||||
|
@ -34,17 +34,17 @@ private:
|
|||
"WESNOTH_PASTE",
|
||||
"TARGETS"
|
||||
};
|
||||
|
||||
|
||||
XInternAtoms(dpy(), (char**)atoms, 6, false, atomTable_);
|
||||
|
||||
|
||||
release();
|
||||
}
|
||||
|
||||
|
||||
static XHelper* s_instance_;
|
||||
|
||||
|
||||
SDL_SysWMinfo wmInf_;
|
||||
|
||||
Atom atomTable_[6];
|
||||
|
||||
Atom atomTable_[6];
|
||||
int acquireCount_;
|
||||
public:
|
||||
static XHelper* instance()
|
||||
|
@ -59,53 +59,53 @@ public:
|
|||
{
|
||||
return atomTable_[0];
|
||||
}
|
||||
|
||||
|
||||
Atom XA_TEXT()
|
||||
{
|
||||
return atomTable_[1];
|
||||
}
|
||||
|
||||
|
||||
Atom XA_COMPOUND_TEXT()
|
||||
{
|
||||
return atomTable_[2];
|
||||
}
|
||||
|
||||
|
||||
Atom UTF8_STRING()
|
||||
{
|
||||
return atomTable_[3];
|
||||
}
|
||||
|
||||
|
||||
Atom WES_PASTE()
|
||||
{
|
||||
return atomTable_[4];
|
||||
}
|
||||
|
||||
|
||||
Atom XA_TARGETS()
|
||||
{
|
||||
return atomTable_[5];
|
||||
}
|
||||
|
||||
|
||||
Display* dpy()
|
||||
{
|
||||
return wmInf_.info.x11.display;
|
||||
}
|
||||
|
||||
|
||||
Window window()
|
||||
{
|
||||
return wmInf_.info.x11.window;
|
||||
}
|
||||
|
||||
|
||||
void acquire(void)
|
||||
{
|
||||
++acquireCount_;
|
||||
if (acquireCount_ == 1) {
|
||||
SDL_VERSION (&wmInf_.version);
|
||||
SDL_GetWMInfo(&wmInf_);
|
||||
|
||||
|
||||
wmInf_.info.x11.lock_func();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void release(void)
|
||||
{
|
||||
--acquireCount_;
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
{
|
||||
XHelper::instance()->acquire();
|
||||
}
|
||||
|
||||
|
||||
~UseX()
|
||||
{
|
||||
XHelper::instance()->release();
|
||||
|
@ -137,23 +137,23 @@ public:
|
|||
|
||||
/**
|
||||
Note: unfortunately, SDL does not keep track of event timestamps.
|
||||
This means we are forced to use CurrentTime in many spots and are
|
||||
unable to perform many safety checks. Hence, the code below is
|
||||
This means we are forced to use CurrentTime in many spots and are
|
||||
unable to perform many safety checks. Hence, the code below is
|
||||
not compliant to the ICCCM, and may ocassionally suffer from
|
||||
race conditions if an X client is connected to the server over
|
||||
a slow/high-latency link. This implementation is also very minimal.
|
||||
The text is assumed to be reasonably small as INCR transactions are not
|
||||
race conditions if an X client is connected to the server over
|
||||
a slow/high-latency link. This implementation is also very minimal.
|
||||
The text is assumed to be reasonably small as INCR transactions are not
|
||||
supported. MULTIPLE is not supported either.
|
||||
|
||||
We provide UTF8_STRING, COMPOUND_TEXT, and TEXT, and
|
||||
|
||||
We provide UTF8_STRING, COMPOUND_TEXT, and TEXT, and
|
||||
try to grab all of them, plus STRING (which is latin1).
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
We primarily. keep a copy of the string to response to data requests,
|
||||
We primarily. keep a copy of the string to response to data requests,
|
||||
but it also has an another function: in case we're both the source
|
||||
and destination, we just copy it accross; this is so that we
|
||||
and destination, we just copy it accross; this is so that we
|
||||
don't have to handle SelectionRequest events while waiting for SelectionNotify.
|
||||
To make this work, however, this gets cleared when we loose CLIPBOARD
|
||||
*/
|
||||
|
@ -165,11 +165,11 @@ void handle_system_event(const SDL_Event& event)
|
|||
XEvent& xev = event.syswm.msg->event.xevent;
|
||||
if (xev.type == SelectionRequest) {
|
||||
UseX x11;
|
||||
|
||||
|
||||
//Since wesnoth does not notify us of selections,
|
||||
//we set both selection + clipboard when copying.
|
||||
if ((xev.xselectionrequest.owner == x11->window()) &&
|
||||
((xev.xselectionrequest.selection == XA_PRIMARY) ||
|
||||
((xev.xselectionrequest.selection == XA_PRIMARY) ||
|
||||
(xev.xselectionrequest.selection == x11->XA_CLIPBOARD()))) {
|
||||
XEvent responseEvent;
|
||||
responseEvent.xselection.type = SelectionNotify;
|
||||
|
@ -179,48 +179,48 @@ void handle_system_event(const SDL_Event& event)
|
|||
responseEvent.xselection.target = xev.xselectionrequest.target;
|
||||
responseEvent.xselection.property = None; //nothing available, by default
|
||||
responseEvent.xselection.time = xev.xselectionrequest.time;
|
||||
|
||||
|
||||
//std::cout<<"Request for target:"<<XGetAtomName(x11->dpy(), xev.xselectionrequest.target)<<"\n";
|
||||
|
||||
|
||||
//### presently don't handle XA_STRING as it must be latin1
|
||||
|
||||
|
||||
if (xev.xselectionrequest.target == x11->XA_TARGETS()) {
|
||||
responseEvent.xselection.property = xev.xselectionrequest.property;
|
||||
|
||||
|
||||
Atom supported[] = {
|
||||
x11->XA_TEXT(),
|
||||
x11->XA_COMPOUND_TEXT(),
|
||||
x11->UTF8_STRING(),
|
||||
x11->XA_TARGETS()
|
||||
};
|
||||
|
||||
|
||||
XChangeProperty(x11->dpy(), responseEvent.xselection.requestor,
|
||||
xev.xselectionrequest.property, XA_ATOM, 32, PropModeReplace,
|
||||
(unsigned char*)supported, 4);
|
||||
}
|
||||
|
||||
|
||||
//The encoding of XA_TEXT and XA_COMPOUND_TEXT is not specified
|
||||
//by the ICCCM... So we assume wesnoth native/utf-8 for simplicity.
|
||||
//modern apps are going to use UTF8_STRING anyway
|
||||
if (xev.xselectionrequest.target == x11->XA_TEXT() ||
|
||||
xev.xselectionrequest.target == x11->XA_COMPOUND_TEXT() ||
|
||||
xev.xselectionrequest.target == x11->XA_COMPOUND_TEXT() ||
|
||||
xev.xselectionrequest.target == x11->UTF8_STRING()) {
|
||||
responseEvent.xselection.property = xev.xselectionrequest.property;
|
||||
|
||||
|
||||
XChangeProperty(x11->dpy(), responseEvent.xselection.requestor,
|
||||
xev.xselectionrequest.property,
|
||||
xev.xselectionrequest.target, 8, PropModeReplace,
|
||||
xev.xselectionrequest.target, 8, PropModeReplace,
|
||||
(const unsigned char*) clipboard_string.c_str(), clipboard_string.length());
|
||||
}
|
||||
|
||||
|
||||
XSendEvent(x11->dpy(), xev.xselectionrequest.requestor, False, NoEventMask,
|
||||
&responseEvent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (xev.type == SelectionClear) {
|
||||
UseX x11;
|
||||
|
||||
|
||||
if (xev.xselectionclear.selection == x11->XA_CLIPBOARD())
|
||||
clipboard_string = ""; //We no longer own the clipboard, don't try in-process C&P
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ void copy_to_clipboard(const std::string& text)
|
|||
clipboard_string = text;
|
||||
|
||||
UseX x11;
|
||||
|
||||
|
||||
XSetSelectionOwner(x11->dpy(), XA_PRIMARY, x11->window(), CurrentTime);
|
||||
XSetSelectionOwner(x11->dpy(), x11->XA_CLIPBOARD(), x11->window(), CurrentTime);
|
||||
}
|
||||
|
@ -255,17 +255,17 @@ void copy_to_clipboard(const std::string& text)
|
|||
static bool try_grab_target(Atom target, std::string& ret)
|
||||
{
|
||||
UseX x11;
|
||||
|
||||
|
||||
//Cleanup previous data
|
||||
XDeleteProperty(x11->dpy(), x11->window(), x11->WES_PASTE());
|
||||
XSync (x11->dpy(), False);
|
||||
|
||||
|
||||
//std::cout<<"We request target:"<<XGetAtomName(x11->dpy(), target)<<"\n";
|
||||
|
||||
|
||||
//Request information
|
||||
XConvertSelection(x11->dpy(), x11->XA_CLIPBOARD(), target,
|
||||
XConvertSelection(x11->dpy(), x11->XA_CLIPBOARD(), target,
|
||||
x11->WES_PASTE(), x11->window(), CurrentTime);
|
||||
|
||||
|
||||
//Wait (with timeout) for a response SelectionNotify
|
||||
for (int attempt = 0; attempt < 15; attempt++) {
|
||||
if (XPending(x11->dpy())) {
|
||||
|
@ -279,20 +279,20 @@ static bool try_grab_target(Atom target, std::string& ret)
|
|||
//The size
|
||||
unsigned long length = 0;
|
||||
unsigned char* data;
|
||||
|
||||
|
||||
//these 3 XGetWindowProperty returns but we don't use
|
||||
Atom typeRet;
|
||||
int formatRet;
|
||||
unsigned long remaining;
|
||||
|
||||
|
||||
// std::cout<<"Grab:"<<XGetAtomName(x11->dpy(), target)<<"\n";
|
||||
|
||||
|
||||
//Grab the text out of the property
|
||||
XGetWindowProperty(x11->dpy(), x11->window(),
|
||||
selectNotify.xselection.property,
|
||||
0, 65535/4, True, target,
|
||||
0, 65535/4, True, target,
|
||||
&typeRet, &formatRet, &length, &remaining, &data);
|
||||
|
||||
|
||||
if (data && length) {
|
||||
ret = (char*)data;
|
||||
XFree(data);
|
||||
|
@ -303,10 +303,10 @@ static bool try_grab_target(Atom target, std::string& ret)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
|
||||
//Timed out -- return empty string
|
||||
return false;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ ucs2_string copy_ucs2_from_clipboard()
|
|||
if(!clipboard_string.empty())
|
||||
return utils::utf8_string_to_ucs2_string(clipboard_string);
|
||||
utf8_string text;
|
||||
|
||||
|
||||
UseX x11;
|
||||
if(try_grab_target(x11->UTF8_STRING(), text))
|
||||
return utils::utf8_string_to_ucs2_string(text);
|
||||
|
@ -335,22 +335,22 @@ std::string copy_from_clipboard()
|
|||
return clipboard_string; //in-wesnoth copy-paste
|
||||
|
||||
std::string ret;
|
||||
|
||||
|
||||
UseX x11;
|
||||
|
||||
|
||||
if (try_grab_target(x11->UTF8_STRING(), ret))
|
||||
return ret;
|
||||
|
||||
|
||||
if (try_grab_target(x11->XA_COMPOUND_TEXT(), ret))
|
||||
return ret;
|
||||
|
||||
|
||||
if (try_grab_target(x11->XA_TEXT(), ret))
|
||||
return ret;
|
||||
|
||||
|
||||
if (try_grab_target(XA_STRING, ret)) //acroread only provides this
|
||||
return ret;
|
||||
|
||||
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ void copy_ucs2_to_clipboard(const ucs2_string& text)
|
|||
first = ++last;
|
||||
} while(last != text.end());
|
||||
str.push_back('\0');
|
||||
|
||||
|
||||
HGLOBAL hglb = GlobalAlloc(GMEM_MOVEABLE, str.size() * sizeof(Uint16));
|
||||
if(hglb == NULL) {
|
||||
CloseClipboard();
|
||||
|
@ -422,7 +422,7 @@ void copy_to_clipboard(const std::string& text)
|
|||
str.append("\r\n");
|
||||
first = ++last;
|
||||
} while(last != text.end());
|
||||
|
||||
|
||||
const HGLOBAL hglb = GlobalAlloc(GMEM_MOVEABLE, (str.size() + 1) * sizeof(TCHAR));
|
||||
if(hglb == NULL) {
|
||||
CloseClipboard();
|
||||
|
@ -452,7 +452,7 @@ ucs2_string copy_ucs2_from_clipboard()
|
|||
CloseClipboard();
|
||||
return ucs2_string();
|
||||
}
|
||||
|
||||
|
||||
//convert newlines
|
||||
ucs2_string str;
|
||||
while(*buffer != '\0') {
|
||||
|
@ -471,7 +471,7 @@ std::string copy_from_clipboard()
|
|||
return "";
|
||||
if(!OpenClipboard(NULL))
|
||||
return "";
|
||||
|
||||
|
||||
HGLOBAL hglb = GetClipboardData(CF_TEXT);
|
||||
if(hglb == NULL) {
|
||||
CloseClipboard();
|
||||
|
@ -482,11 +482,11 @@ std::string copy_from_clipboard()
|
|||
CloseClipboard();
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
//convert newlines
|
||||
std::string str(buffer);
|
||||
str.erase(std::remove(str.begin(),str.end(),'\r'),str.end());
|
||||
|
||||
|
||||
GlobalUnlock(hglb);
|
||||
CloseClipboard();
|
||||
return str;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Copyright (C) 2005 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
|
@ -198,7 +198,7 @@ void config::remove_child(const std::string& key, size_t index)
|
|||
child_list& v = children[key];
|
||||
//wassert(index < v.size());
|
||||
if(index >= v.size()) {
|
||||
ERR_CF << "Error: attempting to delete non-existing child: "
|
||||
ERR_CF << "Error: attempting to delete non-existing child: "
|
||||
<< key << "[" << index << "]\n";
|
||||
return;
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ config config::get_diff(const config& c) const
|
|||
//get the two child lists. 'b' has to be modified to look like 'a'
|
||||
const child_list& a = itor_a != children.end() ? itor_a->second : dummy;
|
||||
const child_list& b = itor_b != c.children.end() ? itor_b->second : dummy;
|
||||
|
||||
|
||||
size_t ndeletes = 0;
|
||||
size_t ai = 0, bi = 0;
|
||||
while(ai != a.size() || bi != b.size()) {
|
||||
|
@ -423,7 +423,7 @@ config config::get_diff(const config& c) const
|
|||
|
||||
++ndeletes;
|
||||
++bi;
|
||||
}
|
||||
}
|
||||
|
||||
//if b has less elements than a, then we assume this element is an
|
||||
//element that needs inserting
|
||||
|
@ -481,7 +481,7 @@ void config::apply_diff(const config& diff)
|
|||
if(item.first->empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
const child_map::iterator itor = children.find(*item.first);
|
||||
if(itor == children.end() || index >= itor->second.size()) {
|
||||
throw error("error in diff: could not find element '" + *item.first + "'");
|
||||
|
@ -518,7 +518,7 @@ void config::reset_translation() const
|
|||
}
|
||||
|
||||
for(child_map::const_iterator list = children.begin(); list != children.end(); ++list) {
|
||||
for(child_list::const_iterator child = list->second.begin();
|
||||
for(child_list::const_iterator child = list->second.begin();
|
||||
child != list->second.end(); ++child) {
|
||||
(*child)->reset_translation();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -47,7 +47,7 @@ SDL_Cursor* create_cursor(surface surf)
|
|||
SDL_GetRGBA(pixels[y*nsurf->w + x],nsurf->format,&r,&g,&b,&a);
|
||||
|
||||
const size_t index = y*cursor_width + x;
|
||||
|
||||
|
||||
const size_t shift = 7 - (index%8);
|
||||
|
||||
const Uint8 trans = (a < 128 ? 0 : 1) << shift;
|
||||
|
@ -208,7 +208,7 @@ void undraw(surface screen)
|
|||
if(use_colour_cursors() == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(cursor_buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -111,7 +111,7 @@ void advance_unit(const game_data& info,
|
|||
bool animate_unit_advancement(const game_data& info,unit_map& units, gamemap::location loc, display& gui, size_t choice)
|
||||
{
|
||||
const command_disabler cmd_disabler;
|
||||
|
||||
|
||||
std::map<gamemap::location,unit>::iterator u = units.find(loc);
|
||||
if(u == units.end() || u->second.advances() == false) {
|
||||
return false;
|
||||
|
@ -123,10 +123,10 @@ bool animate_unit_advancement(const game_data& info,unit_map& units, gamemap::lo
|
|||
if(choice >= options.size() + mod_options.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//when the unit advances, it fades to white, and then switches to the
|
||||
//new unit, then fades back to the normal colour
|
||||
|
||||
|
||||
if(!gui.update_locked()) {
|
||||
for(double intensity = 1.0; intensity >= 0.0; intensity -= 0.05) {
|
||||
gui.set_advancing_unit(loc,intensity);
|
||||
|
@ -368,7 +368,7 @@ void save_preview_pane::draw_contents()
|
|||
str << "\n" << _("#(Invalid)");
|
||||
} else if (!campaign_type.empty()) {
|
||||
str << "\n";
|
||||
|
||||
|
||||
if(campaign_type == "scenario") {
|
||||
str << _("Campaign");
|
||||
} else if(campaign_type == "multiplayer") {
|
||||
|
@ -380,7 +380,7 @@ void save_preview_pane::draw_contents()
|
|||
}
|
||||
|
||||
str << "\n";
|
||||
|
||||
|
||||
if(summary["snapshot"] == "no" && summary["replay"] == "yes") {
|
||||
str << _("replay");
|
||||
} else if (!summary["turn"].empty()) {
|
||||
|
@ -433,7 +433,7 @@ std::string format_time_summary(time_t t)
|
|||
//save is from a different year
|
||||
format_string = _("%b %d %y");
|
||||
}
|
||||
|
||||
|
||||
char buf[40];
|
||||
const size_t res = strftime(buf,sizeof(buf),format_string,&save_time);
|
||||
if(res == 0) {
|
||||
|
@ -728,7 +728,7 @@ void unit_preview_pane::draw_contents()
|
|||
|
||||
details << _("HP: ") << u.hitpoints()
|
||||
<< "/" << u.max_hitpoints() << "\n";
|
||||
|
||||
|
||||
if(u.can_advance() == false) {
|
||||
details << _("XP: ") << u.experience() << "/-";
|
||||
} else {
|
||||
|
@ -740,7 +740,7 @@ void unit_preview_pane::draw_contents()
|
|||
|
||||
details << _("XP: ") << u.experience() << "/" << u.max_experience();
|
||||
}
|
||||
|
||||
|
||||
if(weapons_) {
|
||||
details << "\n"
|
||||
<< _("Moves: ") << u.movement_left() << "/"
|
||||
|
@ -761,9 +761,9 @@ void unit_preview_pane::draw_contents()
|
|||
<< (at_it->range() == attack_type::SHORT_RANGE ? _("melee") : _("ranged"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const std::string text = details.str();
|
||||
|
||||
|
||||
const std::vector<std::string> lines = utils::split(text, '\n');
|
||||
|
||||
SDL_Rect cur_area = area;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -40,7 +40,7 @@ void show_objectives(display& disp, const config& level, const std::string& obje
|
|||
|
||||
// Ask user if I should really save the game and what name I should use
|
||||
// returns 0 iff user wants to save the game
|
||||
int get_save_name(display & disp, const std::string& caption,
|
||||
int get_save_name(display & disp, const std::string& caption,
|
||||
const std::string& message, std::string* name,
|
||||
gui::DIALOG_TYPE dialog_type=gui::YES_NO);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -173,7 +173,7 @@ void display::new_turn()
|
|||
if(cur_ticks < wanted_ticks) {
|
||||
SDL_Delay(wanted_ticks - cur_ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tod_hex_mask1.assign(NULL);
|
||||
|
@ -267,10 +267,10 @@ gamemap::location display::pixel_position_to_hex(int x, int y, gamemap::location
|
|||
const int x_mod = x % tesselation_x_size;
|
||||
const int y_base = y / tesselation_y_size;
|
||||
const int y_mod = y % tesselation_y_size;
|
||||
|
||||
|
||||
int x_modifier = 0;
|
||||
int y_modifier = 0;
|
||||
|
||||
|
||||
if (y_mod < tesselation_y_size / 2) {
|
||||
if ((x_mod * 2 + y_mod) < (s / 2)) {
|
||||
x_modifier = -1;
|
||||
|
@ -282,7 +282,7 @@ gamemap::location display::pixel_position_to_hex(int x, int y, gamemap::location
|
|||
x_modifier = 1;
|
||||
y_modifier = -1;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if ((x_mod * 2 - (y_mod - s / 2)) < 0) {
|
||||
x_modifier = -1;
|
||||
|
@ -297,7 +297,7 @@ gamemap::location display::pixel_position_to_hex(int x, int y, gamemap::location
|
|||
}
|
||||
|
||||
const gamemap::location res(x_base + x_modifier, y_base + y_modifier);
|
||||
|
||||
|
||||
if(nearest_hex != NULL) {
|
||||
const int centerx = (get_location_x(res) - map_area().x + xpos_) + hex_size()/2;
|
||||
const int centery = (get_location_y(res) - map_area().y + ypos_) + hex_size()/2;
|
||||
|
@ -370,10 +370,10 @@ void display::get_visible_hex_bounds(gamemap::location &topleft, gamemap::locati
|
|||
const int tile_width = hex_width();
|
||||
|
||||
topleft.x = xpos_ / tile_width;
|
||||
topleft.y = (ypos_ - (is_odd(topleft.x) ? zoom_/2 : 0)) / zoom_;
|
||||
topleft.y = (ypos_ - (is_odd(topleft.x) ? zoom_/2 : 0)) / zoom_;
|
||||
|
||||
bottomright.x = (xpos_ + rect.w) / tile_width;
|
||||
bottomright.y = ((ypos_ + rect.h) - (is_odd(bottomright.x) ? zoom_/2 : 0)) / zoom_;
|
||||
bottomright.y = ((ypos_ + rect.h) - (is_odd(bottomright.x) ? zoom_/2 : 0)) / zoom_;
|
||||
|
||||
if(topleft.x > -1)
|
||||
topleft.x--;
|
||||
|
@ -655,7 +655,7 @@ void draw_label(CVideo& video, surface target, const theme::label& label)
|
|||
const std::string& text = label.text();
|
||||
const std::string& icon = label.icon();
|
||||
SDL_Rect& loc = label.location(screen_area());
|
||||
|
||||
|
||||
if(icon.empty() == false) {
|
||||
surface surf(image::get_image(icon,image::UNSCALED));
|
||||
if(!surf.null()) {
|
||||
|
@ -680,7 +680,7 @@ void draw_label(CVideo& video, surface target, const theme::label& label)
|
|||
}
|
||||
|
||||
void display::draw(bool update,bool force)
|
||||
{
|
||||
{
|
||||
bool changed = false;
|
||||
//log_scope("Drawing");
|
||||
invalidate_animations();
|
||||
|
@ -697,7 +697,7 @@ void display::draw(bool update,bool force)
|
|||
for(std::vector<theme::label>::const_iterator i = labels.begin(); i != labels.end(); ++i) {
|
||||
draw_label(video(),screen,*i);
|
||||
}
|
||||
|
||||
|
||||
//invalidate the reports so they are redrawn
|
||||
std::fill(reports_,reports_+sizeof(reports_)/sizeof(*reports_),reports::report());
|
||||
invalidateGameStatus_ = true;
|
||||
|
@ -711,7 +711,7 @@ void display::draw(bool update,bool force)
|
|||
gamemap::location bottomright;
|
||||
get_visible_hex_bounds(topleft, bottomright);
|
||||
for(int x = topleft.x; x <= bottomright.x; ++x)
|
||||
for(int y = topleft.y; y <= bottomright.y; ++y)
|
||||
for(int y = topleft.y; y <= bottomright.y; ++y)
|
||||
draw_tile(x,y);
|
||||
invalidateAll_ = false;
|
||||
|
||||
|
@ -809,7 +809,7 @@ void display::draw_sidebar()
|
|||
if(invalidateUnit_) {
|
||||
//we display the unit the mouse is over if it is over a unit
|
||||
//otherwise we display the unit that is selected
|
||||
std::map<gamemap::location,unit>::const_iterator i =
|
||||
std::map<gamemap::location,unit>::const_iterator i =
|
||||
find_visible_unit(units_,mouseoverHex_,
|
||||
map_,
|
||||
status_.get_time_of_day().lawful_bonus,
|
||||
|
@ -842,7 +842,7 @@ void display::draw_game_status()
|
|||
|
||||
for(size_t r = reports::STATUS_REPORTS_BEGIN; r != reports::STATUS_REPORTS_END; ++r) {
|
||||
draw_report(reports::TYPE(r));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void display::draw_image_for_report(surface& img, SDL_Rect& rect)
|
||||
|
@ -1024,7 +1024,7 @@ void display::draw_unit_details(int x, int y, const gamemap::location& loc,
|
|||
|
||||
std::string status = _("healthy");
|
||||
if(map_.on_board(loc) &&
|
||||
u.invisible(map_.underlying_terrain(map_[loc.x][loc.y]),
|
||||
u.invisible(map_.underlying_terrain(map_[loc.x][loc.y]),
|
||||
status_.get_time_of_day().lawful_bonus,loc,
|
||||
units_,teams_)) {
|
||||
status = font::GOOD_TEXT + _("invisible");
|
||||
|
@ -1061,7 +1061,7 @@ void display::draw_unit_details(int x, int y, const gamemap::location& loc,
|
|||
|
||||
details << _("HP: ") << u.hitpoints()
|
||||
<< "/" << u.max_hitpoints() << "\n";
|
||||
|
||||
|
||||
if(u.can_advance() == false) {
|
||||
details << _("XP: ") << u.experience() << "/-";
|
||||
} else {
|
||||
|
@ -1073,7 +1073,7 @@ void display::draw_unit_details(int x, int y, const gamemap::location& loc,
|
|||
|
||||
details << _("XP: ") << u.experience() << "/" << u.max_experience();
|
||||
}
|
||||
|
||||
|
||||
details << "\n"
|
||||
<< _("Moves: ") << u.movement_left() << "/"
|
||||
<< u.total_movement()
|
||||
|
@ -1094,7 +1094,7 @@ void display::draw_unit_details(int x, int y, const gamemap::location& loc,
|
|||
<< (at_it->range() == attack_type::SHORT_RANGE ?
|
||||
_("melee") :
|
||||
_("ranged"));
|
||||
|
||||
|
||||
details << "\n\n";
|
||||
}
|
||||
|
||||
|
@ -1146,9 +1146,9 @@ void display::draw_minimap(int x, int y, int w, int h)
|
|||
int map_w = map_.x(), map_h = map_.y();
|
||||
|
||||
for(unit_map::const_iterator u = units_.begin(); u != units_.end(); ++u) {
|
||||
if(fogged(u->first.x,u->first.y) ||
|
||||
if(fogged(u->first.x,u->first.y) ||
|
||||
(teams_[currentTeam_].is_enemy(u->second.side()) &&
|
||||
u->second.invisible(map_.underlying_terrain(map_[u->first.x][u->first.y]),
|
||||
u->second.invisible(map_.underlying_terrain(map_[u->first.x][u->first.y]),
|
||||
status_.get_time_of_day().lawful_bonus,u->first,
|
||||
units_,teams_)))
|
||||
continue;
|
||||
|
@ -1217,7 +1217,7 @@ void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
|
|||
if(it == units_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SDL_Rect clip_rect = map_area();
|
||||
|
||||
if(xpos > clip_rect.x + clip_rect.w || ypos > clip_rect.y + clip_rect.h ||
|
||||
|
@ -1277,7 +1277,7 @@ void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
|
|||
if(highlight_ratio == ftofxp(1.0))
|
||||
highlight_ratio = it->second.alpha();
|
||||
|
||||
if(u.invisible(map_.underlying_terrain(map_[x][y]),
|
||||
if(u.invisible(map_.underlying_terrain(map_[x][y]),
|
||||
status_.get_time_of_day().lawful_bonus,loc,
|
||||
units_,teams_) &&
|
||||
highlight_ratio > ftofxp(0.5)) {
|
||||
|
@ -1325,8 +1325,8 @@ void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
|
|||
}
|
||||
|
||||
if(unit_image == NULL || fogged(x,y) ||
|
||||
(teams_[currentTeam_].is_enemy(it->second.side()) &&
|
||||
it->second.invisible(map_.underlying_terrain(map_[x][y]),
|
||||
(teams_[currentTeam_].is_enemy(it->second.side()) &&
|
||||
it->second.invisible(map_.underlying_terrain(map_[x][y]),
|
||||
status_.get_time_of_day().lawful_bonus,loc,
|
||||
units_,teams_))) {
|
||||
return;
|
||||
|
@ -1476,7 +1476,7 @@ void display::draw_tile(int x, int y, surface unit_image, fixed_t alpha, Uint32
|
|||
return;
|
||||
|
||||
draw_halo_on_tile(x,y);
|
||||
|
||||
|
||||
const gamemap::location loc(x,y);
|
||||
int xpos = int(get_location_x(loc));
|
||||
int ypos = int(get_location_y(loc));
|
||||
|
@ -1541,7 +1541,7 @@ void display::draw_tile(int x, int y, surface unit_image, fixed_t alpha, Uint32
|
|||
overlays.first != overlays.second; ++overlays.first) {
|
||||
|
||||
surface overlay_surface(image::get_image(overlays.first->second.image,image_type));
|
||||
|
||||
|
||||
//note that dstrect can be changed by SDL_BlitSurface and so a
|
||||
//new instance should be initialized to pass to each call to
|
||||
//SDL_BlitSurface
|
||||
|
@ -1577,7 +1577,7 @@ void display::draw_tile(int x, int y, surface unit_image, fixed_t alpha, Uint32
|
|||
SDL_BlitSurface(fog_surface,NULL,dst,&dstrect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!shrouded(x,y)) {
|
||||
draw_terrain_on_tile(x,y,image_type,ADJACENT_FOGSHROUD);
|
||||
}
|
||||
|
@ -1717,7 +1717,7 @@ void display::draw_footstep(const gamemap::location& loc, int xloc, int yloc)
|
|||
}
|
||||
|
||||
const std::string& str = text.str();
|
||||
|
||||
|
||||
if(str.empty() == false) {
|
||||
const SDL_Rect& rect = map_area();
|
||||
|
||||
|
@ -1762,8 +1762,8 @@ const std::string& get_angle_direction(size_t n)
|
|||
std::vector<std::string> display::get_fog_shroud_graphics(const gamemap::location& loc)
|
||||
{
|
||||
std::vector<std::string> res;
|
||||
|
||||
gamemap::location adjacent[6];
|
||||
|
||||
gamemap::location adjacent[6];
|
||||
get_adjacent_tiles(loc,adjacent);
|
||||
int tiles[6];
|
||||
static const int terrain_types[] = { gamemap::FOGGED, gamemap::VOID_TERRAIN, 0 };
|
||||
|
@ -1871,7 +1871,7 @@ std::vector<surface> display::get_terrain_images(int x, int y, image::TYPE image
|
|||
res.push_back(surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1994,7 +1994,7 @@ void display::draw_unit(int x, int y, surface image,
|
|||
|
||||
if(submerge_height != surf->h) {
|
||||
surf.assign(adjust_surface_alpha(surf,ftofxp(0.2)));
|
||||
|
||||
|
||||
srcrect.y = submerge_height;
|
||||
srcrect.h = surf->h-submerge_height;
|
||||
y += submerge_height;
|
||||
|
@ -2077,7 +2077,7 @@ void display::invalidate_animations()
|
|||
|
||||
for(size_t i = 0; i < flags_.size(); ++i) {
|
||||
flags_[i].update_current_frame();
|
||||
if(flags_[i].frame_changed())
|
||||
if(flags_[i].frame_changed())
|
||||
animate_flags = true;
|
||||
}
|
||||
|
||||
|
@ -2244,8 +2244,8 @@ void display::enable_menu(const std::string& item, bool enable)
|
|||
{
|
||||
for(std::vector<theme::menu>::const_iterator menu = theme_.menus().begin();
|
||||
menu != theme_.menus().end(); ++menu) {
|
||||
|
||||
std::vector<std::string>::const_iterator hasitem =
|
||||
|
||||
std::vector<std::string>::const_iterator hasitem =
|
||||
std::find(menu->items().begin(), menu->items().end(), item);
|
||||
|
||||
if(hasitem != menu->items().end()) {
|
||||
|
@ -2321,7 +2321,7 @@ void display::add_chat_message(const std::string& speaker, int side, const std::
|
|||
if(side >= 1) {
|
||||
speaker_colour = team::get_side_colour(side);
|
||||
}
|
||||
|
||||
|
||||
SDL_Color message_colour = chat_message_colour;
|
||||
std::stringstream str;
|
||||
std::stringstream message_str;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -144,12 +144,12 @@ public:
|
|||
//location of the hex that this pixel corresponds to. Returns an
|
||||
//invalid location is the mouse isn't over any valid location.
|
||||
gamemap::location hex_clicked_on(int x, int y, gamemap::location::DIRECTION* nearest_hex=NULL, gamemap::location::DIRECTION* second_nearest_hex=NULL);
|
||||
|
||||
|
||||
//given x,y co-ordinates of a pixel on the map, will return the
|
||||
//location of the hex that this pixel corresponds to. Returns an
|
||||
//invalid location is the mouse isn't over any valid location.
|
||||
gamemap::location pixel_position_to_hex(int x, int y, gamemap::location::DIRECTION* nearest_hex=NULL, gamemap::location::DIRECTION* second_nearest_hex=NULL);
|
||||
|
||||
|
||||
//given x,y co-ordinates of the mouse, will return the location of the
|
||||
//hex in the minimap that the mouse is currently over, or an invalid
|
||||
//location if the mouse isn't over the minimap.
|
||||
|
@ -331,7 +331,7 @@ public:
|
|||
//submerged: the amount of the unit out of 1.0 that is submerged
|
||||
// (presumably under water) and thus shouldn't be drawn
|
||||
void draw_unit(int x, int y, surface image,
|
||||
bool upside_down=false,fixed_t alpha=ftofxp(1.0),
|
||||
bool upside_down=false,fixed_t alpha=ftofxp(1.0),
|
||||
Uint32 blendto=0, double blend_ratio=0,
|
||||
double submerged=0.0,
|
||||
surface ellipse_back=surface(NULL),
|
||||
|
@ -341,7 +341,7 @@ public:
|
|||
void rebuild_terrain(const gamemap::location &location);
|
||||
//rebuild all dynamic terrain.
|
||||
void rebuild_all();
|
||||
|
||||
|
||||
//Add a location to highlight. Note that this has nothing to do with
|
||||
//selecting hexes, it is pure highlighting. These hexes will be
|
||||
//highlighted slightly darker than the currently selected hex.
|
||||
|
@ -459,7 +459,7 @@ private:
|
|||
|
||||
theme theme_;
|
||||
terrain_builder builder_;
|
||||
|
||||
|
||||
void create_buttons();
|
||||
std::vector<gui::button> buttons_;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -81,7 +81,7 @@ config map_editor::prefs_;
|
|||
config map_editor::hotkeys_;
|
||||
// Do not init the l_button_func_ to DRAW, since it should be changed in
|
||||
// the constructor to update the report the first time.
|
||||
map_editor::LEFT_BUTTON_FUNC map_editor::l_button_func_ = PASTE;
|
||||
map_editor::LEFT_BUTTON_FUNC map_editor::l_button_func_ = PASTE;
|
||||
gamemap::TERRAIN map_editor::old_fg_terrain_;
|
||||
gamemap::TERRAIN map_editor::old_bg_terrain_;
|
||||
int map_editor::old_brush_size_;
|
||||
|
@ -214,7 +214,7 @@ void map_editor::handle_mouse_button_event(const SDL_MouseButtonEvent &event,
|
|||
const SDL_Rect& rect = gui_.map_area();
|
||||
const int centerx = (rect.x + rect.w) / 2;
|
||||
const int centery = (rect.y + rect.h) / 2;
|
||||
|
||||
|
||||
const int xdisp = mousex - centerx;
|
||||
const int ydisp = mousey - centery;
|
||||
gui_.scroll(xdisp, ydisp);
|
||||
|
@ -224,13 +224,13 @@ void map_editor::handle_mouse_button_event(const SDL_MouseButtonEvent &event,
|
|||
if (point_in_rect(mousex, mousey, gui_.map_area())) {
|
||||
const int speed = preferences::scroll_speed() *
|
||||
(button == SDL_BUTTON_WHEELUP ? -1 : 1);
|
||||
|
||||
|
||||
const int centerx = gui_.mapx() / 2;
|
||||
const int centery = gui_.y() / 2;
|
||||
|
||||
|
||||
const int xdisp = abs(centerx - mousex);
|
||||
const int ydisp = abs(centery - mousey);
|
||||
|
||||
|
||||
if(xdisp > ydisp)
|
||||
gui_.scroll(speed,0);
|
||||
else
|
||||
|
@ -297,7 +297,7 @@ void map_editor::right_click(const gamemap::location hex_clicked ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void map_editor::edit_save_as() {
|
||||
const std::string default_dir =
|
||||
|
@ -335,8 +335,8 @@ void map_editor::perform_set_starting_pos() {
|
|||
_("Which player should start here?"),
|
||||
gui::OK_CANCEL, &players);
|
||||
if (res >= 0) {
|
||||
res++;
|
||||
if (res == num_players) res = 0;
|
||||
res++;
|
||||
if (res == num_players) res = 0;
|
||||
set_starting_position(res, selected_hex_);
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ void map_editor::edit_quit() {
|
|||
void map_editor::edit_new_map() {
|
||||
const std::string map = new_map_dialog(gui_, palette_.selected_bg_terrain(),
|
||||
changed_since_save(), game_config_);
|
||||
if (map != "") {
|
||||
if (map != "") {
|
||||
num_operations_since_save_ = 0;
|
||||
clear_undo_actions();
|
||||
throw new_map_exception(map);
|
||||
|
@ -988,7 +988,7 @@ void map_editor::right_button_down(const int mousex, const int mousey) {
|
|||
// TODO evaluate if this is what is the smartest thing to do.
|
||||
draw_on_mouseover_hexes(palette_.selected_bg_terrain());
|
||||
}
|
||||
|
||||
|
||||
void map_editor::middle_button_down(const int mousex, const int mousey) {
|
||||
const gamemap::location& minimap_loc = gui_.minimap_location_on(mousex,mousey);
|
||||
const gamemap::location hex = gui_.hex_clicked_on(mousex, mousey);
|
||||
|
@ -1218,7 +1218,7 @@ void map_editor::main_loop() {
|
|||
const int y = menu_loc.y + menu_loc.h + 1;
|
||||
show_menu(m->items(), x, y, false);
|
||||
}
|
||||
|
||||
|
||||
if(key_[SDLK_UP] || mousey == 0) {
|
||||
gui_.scroll(0,-scroll_speed);
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ void map_editor::main_loop() {
|
|||
if(key_[SDLK_RIGHT] || mousex == gui_.x()-1) {
|
||||
gui_.scroll(scroll_speed,0);
|
||||
}
|
||||
|
||||
|
||||
if (l_button_down) {
|
||||
left_button_down(mousex, mousey);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -35,22 +35,22 @@ class map_editor : public events::handler,
|
|||
public:
|
||||
map_editor(display &gui, gamemap &map, config &theme, config &game_config);
|
||||
virtual ~map_editor();
|
||||
|
||||
|
||||
/// Enter the main loop. The loop runs until set_abort() is called
|
||||
/// to set an abort mode which makes the loop exit.
|
||||
void main_loop();
|
||||
|
||||
/// Set the filename that map should be saved as.
|
||||
|
||||
/// Set the filename that map should be saved as.
|
||||
void set_file_to_save_as(const std::string);
|
||||
|
||||
/// How to abort the map editor.
|
||||
/// DONT_ABORT is set during normal operation.
|
||||
/// When ABORT_NORMALLY is set, the editor asks for confirmation and
|
||||
/// if save is desired before it exits.
|
||||
/// if save is desired before it exits.
|
||||
/// When ABORT_HARD is set, the editor exists without asking any
|
||||
/// questions or saving.
|
||||
enum ABORT_MODE {DONT_ABORT, ABORT_NORMALLY, ABORT_HARD};
|
||||
|
||||
|
||||
/// Set the abort flag, which indicates if the editor should exit in
|
||||
/// some way after the current iteration of the main loop.
|
||||
void set_abort(const ABORT_MODE abort=ABORT_NORMALLY);
|
||||
|
@ -69,14 +69,14 @@ public:
|
|||
/// the map. Show a message if the load failed. Throw
|
||||
/// load_map_exception if the file could not be loaded.
|
||||
std::string load_map(const std::string filename);
|
||||
|
||||
|
||||
virtual void handle_event(const SDL_Event &event);
|
||||
|
||||
|
||||
/// Handle a keyboard event. mousex and mousey is the current
|
||||
/// position of the mouse.
|
||||
void handle_keyboard_event(const SDL_KeyboardEvent &event,
|
||||
const int mousex, const int mousey);
|
||||
|
||||
|
||||
/// Handle a mouse button event. mousex and mousey is the current
|
||||
/// position of the mouse.
|
||||
void handle_mouse_button_event(const SDL_MouseButtonEvent &event,
|
||||
|
@ -85,10 +85,10 @@ public:
|
|||
/// Return true if the map has changed since the last time it was
|
||||
/// saved.
|
||||
bool changed_since_save() const;
|
||||
|
||||
|
||||
/// Recalculate layout and redraw everything.
|
||||
void redraw_everything();
|
||||
|
||||
|
||||
// Methods inherited from command_executor. Used to perform
|
||||
// operations on menu/hotkey commands.
|
||||
virtual void toggle_grid();
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
void perform_set_starting_pos();
|
||||
|
||||
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command) const;
|
||||
|
||||
|
||||
/// Exception thrown when new map is to be loaded.
|
||||
struct new_map_exception {
|
||||
new_map_exception(const std::string &map, const std::string filename="")
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
const std::string new_map;
|
||||
const std::string new_filename;
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
/// What to perform while the left button is held down.
|
||||
enum LEFT_BUTTON_HELD_FUNC {DRAW_TERRAIN, ADD_SELECTION, REMOVE_SELECTION,
|
||||
|
@ -146,42 +146,42 @@ private:
|
|||
|
||||
/// Handle a left click on the location.
|
||||
void left_click(const gamemap::location loc);
|
||||
|
||||
|
||||
/// Called in every iteration when the right mouse button is held
|
||||
/// down. Note that this differs from a click.
|
||||
void right_button_down(const int mousex, const int mousey);
|
||||
|
||||
/// Handle a right click on the location.
|
||||
void right_click(const gamemap::location loc);
|
||||
|
||||
|
||||
/// Called in every iteration when the middle mouse button is held
|
||||
/// down. Note that this differs from a click.
|
||||
void middle_button_down(const int mousex, const int mousey);
|
||||
|
||||
|
||||
/// Confirm that exiting is desired and ask for saving of the map.
|
||||
/// Return true if exit is confirmed and the save is successful or not
|
||||
/// wanted. Return false if exit is cancelled or the requested save
|
||||
/// failed.
|
||||
bool confirm_exit_and_save();
|
||||
|
||||
|
||||
/// Set the starting position for the given player to the location
|
||||
/// given.
|
||||
void set_starting_position(const int player, const gamemap::location loc);
|
||||
|
||||
|
||||
/// Display a menu with given items and at the given location.
|
||||
void show_menu(const std::vector<std::string>& items_arg, const int xloc,
|
||||
const int yloc, const bool context_menu=false);
|
||||
|
||||
|
||||
/// Pass the command onto the hotkey handling system. Quit requests
|
||||
/// are intercepted because the editor does not want the default
|
||||
/// behavior of those.
|
||||
void execute_command(const hotkey::HOTKEY_COMMAND command);
|
||||
|
||||
|
||||
/// Draw terrain at a location. The operation is saved in the undo
|
||||
/// stack. Update the map to reflect the change.
|
||||
void draw_terrain(const gamemap::TERRAIN terrain,
|
||||
const gamemap::location hex);
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// NOTE: after any terrain has changed, one of the invalidate //
|
||||
|
@ -243,7 +243,7 @@ private:
|
|||
map_undo_action &undo_action);
|
||||
void terrain_changed(const std::set<gamemap::location> &hexes,
|
||||
map_undo_action &undo_action);
|
||||
|
||||
|
||||
/// Save an action so that it may be undone. Add an operation to the
|
||||
/// number done since save.
|
||||
void save_undo_action(const map_undo_action &action);
|
||||
|
@ -324,7 +324,7 @@ private:
|
|||
static gamemap::TERRAIN old_fg_terrain_, old_bg_terrain_;
|
||||
static int old_brush_size_;
|
||||
bool all_hexes_selected_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -86,7 +86,7 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
|
|||
|
||||
width_rect.x = text_right - width_rect.w;
|
||||
height_rect.x = text_right - height_rect.w;
|
||||
|
||||
|
||||
width_rect.y = ypos + title_rect.h + vertical_margin*2;
|
||||
height_rect.y = width_rect.y + width_rect.h + vertical_margin;
|
||||
|
||||
|
@ -98,7 +98,7 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
|
|||
new_map_button.set_location(xpos + horz_margin,height_rect.y + height_rect.h + vertical_margin);
|
||||
random_map_button.set_location(xpos + horz_margin,ypos + height - random_map_button.height()-14*2-vertical_margin);
|
||||
random_map_setting_button.set_location(random_map_button.location().x + random_map_button.width() + horz_margin,
|
||||
ypos + height - random_map_setting_button.height()
|
||||
ypos + height - random_map_setting_button.height()
|
||||
- 14*2 - vertical_margin);
|
||||
cancel_button.set_location(xpos + width - cancel_button.width() - horz_margin,
|
||||
ypos + height - cancel_button.height()-14);
|
||||
|
@ -123,7 +123,7 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
|
|||
height_slider.set_max(map_max_height);
|
||||
height_slider.set_value(map_height);
|
||||
|
||||
static util::scoped_ptr<map_generator> random_map_generator(NULL);
|
||||
static util::scoped_ptr<map_generator> random_map_generator(NULL);
|
||||
if (random_map_generator == NULL) {
|
||||
// Initialize the map generator if this is the first call,
|
||||
// otherwise keep the settings and such.
|
||||
|
@ -173,7 +173,7 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
|
|||
if ((confirmation_needed
|
||||
&& confirm_modification_disposal(disp))
|
||||
|| !confirmation_needed) {
|
||||
|
||||
|
||||
const std::string map =
|
||||
random_map_generator.get()->create_map(std::vector<std::string>());
|
||||
if (map == "") {
|
||||
|
@ -199,17 +199,17 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
|
|||
width_label,width_rect.x,width_rect.y);
|
||||
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,
|
||||
height_label,height_rect.x,height_rect.y);
|
||||
|
||||
|
||||
std::stringstream width_str;
|
||||
width_str << map_width;
|
||||
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
|
||||
slider_right+horz_margin,width_rect.y);
|
||||
|
||||
|
||||
std::stringstream height_str;
|
||||
height_str << map_height;
|
||||
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
|
||||
slider_right+horz_margin,height_rect.y);
|
||||
|
||||
|
||||
}
|
||||
|
||||
new_map_button.set_dirty();
|
||||
|
@ -236,7 +236,7 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
|
|||
void preferences_dialog(display &disp, config &prefs) {
|
||||
const events::event_context dialog_events_context;
|
||||
const gui::dialog_manager dialog_mgr;
|
||||
|
||||
|
||||
const int width = 600;
|
||||
const int height = 200;
|
||||
const int xpos = disp.x()/2 - width/2;
|
||||
|
@ -326,7 +326,7 @@ void preferences_dialog(display &disp, config &prefs) {
|
|||
scroll_slider.set_dirty();
|
||||
|
||||
font::draw_text(&disp.video(),clip_rect,14,font::NORMAL_COLOUR,scroll_label,
|
||||
scroll_rect.x,scroll_rect.y);
|
||||
scroll_rect.x,scroll_rect.y);
|
||||
|
||||
update_rect(screen_area());
|
||||
|
||||
|
@ -400,7 +400,7 @@ resize_dialog(display &disp, const unsigned curr_w, const unsigned curr_h) {
|
|||
|
||||
width_rect.x = text_right - width_rect.w;
|
||||
height_rect.x = text_right - height_rect.w;
|
||||
|
||||
|
||||
width_rect.y = ypos + title_rect.h + vertical_margin*2;
|
||||
height_rect.y = width_rect.y + width_rect.h + vertical_margin;
|
||||
|
||||
|
@ -409,7 +409,7 @@ resize_dialog(display &disp, const unsigned curr_w, const unsigned curr_h) {
|
|||
|
||||
cancel_button.set_location(xpos + width - cancel_button.width() - horz_margin,
|
||||
ypos + height - cancel_button.height()-14);
|
||||
|
||||
|
||||
ok_button.set_location(xpos + width - cancel_button.width() - horz_margin
|
||||
- ok_button.width() - button_padding,
|
||||
ypos + height - ok_button.height()-14);
|
||||
|
@ -452,17 +452,17 @@ resize_dialog(display &disp, const unsigned curr_w, const unsigned curr_h) {
|
|||
width_label,width_rect.x,width_rect.y);
|
||||
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,
|
||||
height_label,height_rect.x,height_rect.y);
|
||||
|
||||
|
||||
std::stringstream width_str;
|
||||
width_str << map_width;
|
||||
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
|
||||
slider_right+horz_margin,width_rect.y);
|
||||
|
||||
|
||||
std::stringstream height_str;
|
||||
height_str << map_height;
|
||||
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
|
||||
slider_right+horz_margin,height_rect.y);
|
||||
|
||||
|
||||
}
|
||||
if (ok_button.pressed()) {
|
||||
return std::make_pair((unsigned)map_width, (unsigned)map_height);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -36,7 +36,7 @@ struct size_specs {
|
|||
|
||||
/// Adjust the internal size specifications to fit the display.
|
||||
void adjust_sizes(const display &disp, size_specs &sizes);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -51,25 +51,25 @@ int main(int argc, char** argv)
|
|||
continue;
|
||||
}
|
||||
|
||||
if(val == "--help" || val == "-h") {
|
||||
std::cout << "usage: " << argv[0]
|
||||
<< " [options] [map]\n"
|
||||
<< " -f, --fullscreen Runs the game in full-screen\n"
|
||||
<< " -h, --help Prints this message and exits\n"
|
||||
<< " --path Prints the name of the game data directory and exits\n"
|
||||
<< " -w, --windowed Runs the game in windowed mode\n"
|
||||
<< " -v, --version Prints the game's version number and exits\n"
|
||||
<< " --resolution Set the resolution of the window\n"
|
||||
<< " --datadir Select the data directory to use\n";
|
||||
return 0;
|
||||
} else if(val == "--version" || val == "-v") {
|
||||
std::cout << "Battle for Wesnoth " << game_config::version
|
||||
<< "\n";
|
||||
return 0;
|
||||
} else if(val == "--path") {
|
||||
std::cout << game_config::path
|
||||
<< "\n";
|
||||
return 0;
|
||||
if(val == "--help" || val == "-h") {
|
||||
std::cout << "usage: " << argv[0]
|
||||
<< " [options] [map]\n"
|
||||
<< " -f, --fullscreen Runs the game in full-screen\n"
|
||||
<< " -h, --help Prints this message and exits\n"
|
||||
<< " --path Prints the name of the game data directory and exits\n"
|
||||
<< " -w, --windowed Runs the game in windowed mode\n"
|
||||
<< " -v, --version Prints the game's version number and exits\n"
|
||||
<< " --resolution Set the resolution of the window\n"
|
||||
<< " --datadir Select the data directory to use\n";
|
||||
return 0;
|
||||
} else if(val == "--version" || val == "-v") {
|
||||
std::cout << "Battle for Wesnoth " << game_config::version
|
||||
<< "\n";
|
||||
return 0;
|
||||
} else if(val == "--path") {
|
||||
std::cout << game_config::path
|
||||
<< "\n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,47 +156,47 @@ int main(int argc, char** argv)
|
|||
image::set_wm_icon();
|
||||
int video_flags = preferences::fullscreen() ? FULL_SCREEN : 0;
|
||||
std::pair<int,int> resolution = preferences::resolution();
|
||||
|
||||
|
||||
std::cerr << "checking mode possible...\n";
|
||||
const int bpp = video.modePossible(resolution.first,resolution.second,16,video_flags);
|
||||
|
||||
|
||||
std::cerr << bpp << "\n";
|
||||
|
||||
|
||||
if(bpp == 0) {
|
||||
//Video mode not supported, maybe from bad prefs.
|
||||
std::cerr << "The video mode, " << resolution.first
|
||||
<< "x" << resolution.second << "x16 "
|
||||
<< "is not supported\nAttempting 1024x768x16...\n";
|
||||
|
||||
|
||||
//Attempt 1024x768.
|
||||
resolution.first = 1024;
|
||||
resolution.second = 768;
|
||||
|
||||
|
||||
int bpp = video.modePossible(resolution.first,resolution.second,16,video_flags);
|
||||
|
||||
|
||||
if(bpp == 0) {
|
||||
//Attempt 1024x768.
|
||||
resolution.first = 1024;
|
||||
resolution.second = 768;
|
||||
std::cerr << "1024x768x16 is not possible.\nAttempting 800x600x16...\n";
|
||||
|
||||
|
||||
resolution.first = 800;
|
||||
resolution.second = 600;
|
||||
|
||||
|
||||
bpp = video.modePossible(resolution.first,resolution.second,16,video_flags);
|
||||
}
|
||||
|
||||
|
||||
if(bpp == 0) {
|
||||
//couldn't do 1024x768 or 800x600
|
||||
|
||||
|
||||
std::cerr << "The required video mode, " << resolution.first
|
||||
<< "x" << resolution.second << "x16 "
|
||||
<< "is not supported\n";
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::cerr << "setting mode to " << resolution.first << "x" << resolution.second << "\n";
|
||||
const int res = video.setMode(resolution.first,resolution.second,bpp,video_flags);
|
||||
video.setBpp(bpp);
|
||||
|
@ -244,7 +244,7 @@ int main(int argc, char** argv)
|
|||
mapdata += "gggggggggggggggggggg\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
srand(time(NULL));
|
||||
bool done = false;
|
||||
gamestatus status(cfg, 0);
|
||||
|
@ -269,7 +269,7 @@ int main(int argc, char** argv)
|
|||
const config dummy_cfg;
|
||||
display gui(units, video, map, status, teams,
|
||||
*theme_cfg, cfg, dummy_cfg);
|
||||
|
||||
|
||||
map_editor::map_editor editor(gui, map, *theme_cfg, cfg);
|
||||
editor.set_file_to_save_as(filename);
|
||||
editor.main_loop();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -321,11 +321,11 @@ void terrain_palette::update_report() {
|
|||
}
|
||||
|
||||
// void terrain_palette::bg_backup() {
|
||||
// restorer_ = surface_restorer(&gui_.video(), get_rect());
|
||||
// restorer_ = surface_restorer(&gui_.video(), get_rect());
|
||||
// }
|
||||
|
||||
// void terrain_palette::bg_restore() {
|
||||
// restorer_.restore();
|
||||
// restorer_.restore();
|
||||
// }
|
||||
|
||||
brush_bar::brush_bar(display &gui, const size_specs &sizes)
|
||||
|
@ -348,7 +348,7 @@ void brush_bar::select_brush_size(int new_size) {
|
|||
assert(new_size > 0 && new_size <= total_brush_);
|
||||
selected_ = new_size - 1;
|
||||
}
|
||||
|
||||
|
||||
void brush_bar::left_mouse_click(const int mousex, const int mousey) {
|
||||
int index = selected_index(mousex, mousey);
|
||||
if(index >= 0) {
|
||||
|
@ -418,7 +418,7 @@ void brush_bar::draw(bool force) {
|
|||
dstrect.w = image->w;
|
||||
dstrect.h = image->h;
|
||||
SDL_BlitSurface(image, NULL, screen, &dstrect);
|
||||
const Uint32 color = (unsigned)i == selected_brush_size() ?
|
||||
const Uint32 color = (unsigned)i == selected_brush_size() ?
|
||||
SDL_MapRGB(screen->format,0xFF,0x00,0x00) :
|
||||
SDL_MapRGB(screen->format,0x00,0x00,0x00);
|
||||
draw_rectangle(dstrect.x, dstrect.y, image->w, image->h, color, screen);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -47,8 +47,8 @@ public:
|
|||
gamemap::TERRAIN selected_fg_terrain() const;
|
||||
/// Return the currently selected background terrain.
|
||||
gamemap::TERRAIN selected_bg_terrain() const;
|
||||
|
||||
|
||||
|
||||
|
||||
/// Select a foreground terrain.
|
||||
void select_fg_terrain(gamemap::TERRAIN);
|
||||
void select_bg_terrain(gamemap::TERRAIN);
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
virtual void draw();
|
||||
virtual void handle_event(const SDL_Event& event);
|
||||
void set_dirty(bool dirty=true);
|
||||
|
||||
|
||||
|
||||
/// Return the number of terrains in the palette.
|
||||
size_t num_terrains() const;
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
brush_bar(display &gui, const size_specs &sizes);
|
||||
|
||||
/// Return the size of currently selected brush.
|
||||
unsigned int selected_brush_size();
|
||||
unsigned int selected_brush_size();
|
||||
|
||||
/// Select a brush size.
|
||||
void select_brush_size(int new_size);
|
||||
|
@ -123,12 +123,12 @@ private:
|
|||
/// To be called when a mouse click occurs. Check if the coordinates
|
||||
/// is a terrain that may be chosen, select the terrain if that is
|
||||
/// the case.
|
||||
void left_mouse_click(const int mousex, const int mousey);
|
||||
void left_mouse_click(const int mousex, const int mousey);
|
||||
|
||||
/// Return the index of the brush that is at coordinates (x, y) in the
|
||||
/// panel.
|
||||
int selected_index(const int x, const int y) const;
|
||||
|
||||
|
||||
const size_specs &size_specs_;
|
||||
display &gui_;
|
||||
unsigned int selected_;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -39,7 +39,7 @@ const std::map<gamemap::location,gamemap::TERRAIN>& map_undo_action::redo_terrai
|
|||
const std::set<gamemap::location> map_undo_action::undo_selection() const {
|
||||
return old_selection_;
|
||||
}
|
||||
|
||||
|
||||
const std::set<gamemap::location> map_undo_action::redo_selection() const {
|
||||
return new_selection_;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -28,10 +28,10 @@ namespace map_editor {
|
|||
class map_undo_action {
|
||||
public:
|
||||
map_undo_action();
|
||||
|
||||
const std::map<gamemap::location,gamemap::TERRAIN>& undo_terrains() const;
|
||||
const std::map<gamemap::location,gamemap::TERRAIN>& redo_terrains() const;
|
||||
|
||||
|
||||
const std::map<gamemap::location,gamemap::TERRAIN>& undo_terrains() const;
|
||||
const std::map<gamemap::location,gamemap::TERRAIN>& redo_terrains() const;
|
||||
|
||||
const std::set<gamemap::location> undo_selection() const;
|
||||
const std::set<gamemap::location> redo_selection() const;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
const std::map<gamemap::location, int>& undo_starting_locations() const;
|
||||
const std::map<gamemap::location, int>& redo_starting_locations() const;
|
||||
|
||||
|
||||
void add_terrain(const gamemap::TERRAIN& old_tr,
|
||||
const gamemap::TERRAIN& new_tr,
|
||||
const gamemap::location& lc);
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
/// Return true if a terrain change has been saved in this undo
|
||||
/// action.
|
||||
bool terrain_set() const;
|
||||
|
||||
|
||||
void set_selection(const std::set<gamemap::location> &old_selection,
|
||||
const std::set<gamemap::location> &new_selection);
|
||||
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
void add_starting_location(const int old_side, const int new_side,
|
||||
const gamemap::location &old_loc,
|
||||
const gamemap::location &new_loc);
|
||||
|
||||
|
||||
/// Return true if starting locations have been saved in this undo
|
||||
/// action.
|
||||
bool starting_location_set() const;
|
||||
|
@ -85,9 +85,9 @@ private:
|
|||
std::map<gamemap::location,int> new_starting_locations_;
|
||||
bool starting_locations_set_;
|
||||
};
|
||||
|
||||
|
||||
typedef std::deque<map_undo_action> map_undo_list;
|
||||
|
||||
|
||||
/// Add an undo action to the undo stack. Resize the stack if it gets
|
||||
/// larger than the maximum size. Add an operation to the number done
|
||||
/// since save. If keep_selection is true, it indicates that the
|
||||
|
@ -111,7 +111,7 @@ map_undo_action pop_redo_action();
|
|||
|
||||
/// Clear all stored information about performed actions.
|
||||
void clear_undo_actions();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -23,7 +23,7 @@
|
|||
#include <set>
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
// Grow the map, represented by lines, one step. If grow_height is
|
||||
// true, the height is increased and every other column is shifted
|
||||
// one step downwards. Otherwise the map is increased in width one
|
||||
|
@ -268,6 +268,6 @@ bool valid_mapdata(const std::string &data, const config &cfg) {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -94,7 +94,7 @@ bool context::remove_handler(handler* ptr)
|
|||
} else {
|
||||
focused_handler = -1;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ bool has_focus(const handler* ptr)
|
|||
}
|
||||
|
||||
const int index = event_contexts.back().focused_handler;
|
||||
|
||||
|
||||
//if no-one has focus at the moment, this handler obviously wants
|
||||
//focus, so give it to it.
|
||||
if(index == -1) {
|
||||
|
@ -244,7 +244,7 @@ void pump()
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case SDL_MOUSEMOTION: {
|
||||
//always make sure a cursor is displayed if the
|
||||
//mouse moves or if the user clicks
|
||||
|
@ -287,7 +287,7 @@ void pump()
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#if defined(_X11) && !defined(__APPLE__)
|
||||
case SDL_SYSWMEVENT: {
|
||||
//clipboard support for X11
|
||||
|
|
|
@ -47,7 +47,7 @@ int show_file_chooser_dialog(display &disp, std::string &filename,
|
|||
fc.set_width(width - left_padding - right_padding);
|
||||
fc.set_height(height - top_padding - bot_padding);
|
||||
fc.set_dirty(true);
|
||||
|
||||
|
||||
events::raise_draw_event();
|
||||
disp.flip();
|
||||
disp.invalidate_all();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -96,7 +96,7 @@ namespace {
|
|||
}
|
||||
else LOG_FS << "skipping invalid entry\n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -151,7 +151,7 @@ void get_files_in_dir(const std::string& directory,
|
|||
else
|
||||
#endif
|
||||
{
|
||||
|
||||
|
||||
//if we have a path to find directories in, then convert relative
|
||||
//pathnames to be rooted on the wesnoth path
|
||||
if(!directory.empty() && directory[0] != '/' && !game_config::path.empty()){
|
||||
|
@ -738,12 +738,12 @@ const std::vector<std::string>& get_binary_paths(const std::string& type)
|
|||
}
|
||||
|
||||
std::vector<std::string>& res = binary_paths_cache[type];
|
||||
|
||||
|
||||
init_binary_paths();
|
||||
|
||||
for(std::set<std::string>::const_iterator i = binary_paths.begin(); i != binary_paths.end(); ++i) {
|
||||
res.push_back(get_user_data_dir() + "/" + *i + type + "/");
|
||||
|
||||
|
||||
if(!game_config::path.empty()) {
|
||||
res.push_back(game_config::path + "/" + *i + type + "/");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
70
src/font.cpp
70
src/font.cpp
|
@ -1,8 +1,8 @@
|
|||
/* $Id$ */
|
||||
/* vim:set encoding=utf-8: */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -83,10 +83,10 @@ struct text_chunk
|
|||
text_chunk(subset_id subset, std::string const & text) : subset(subset), text(text) {}
|
||||
text_chunk(subset_id subset, ucs2_string const & ucs2_text) : subset(subset), ucs2_text(ucs2_text) {}
|
||||
text_chunk(subset_id subset, std::string const & text, ucs2_string const & ucs2_text) : subset(subset), text(text), ucs2_text(ucs2_text) {}
|
||||
|
||||
|
||||
bool operator==(text_chunk const & t) const { return subset == t.subset && ucs2_text == t.ucs2_text; }
|
||||
bool operator!=(text_chunk const & t) const { return !operator==(t); }
|
||||
|
||||
|
||||
subset_id subset;
|
||||
//FIXME if we don't need the utf8 here remove it
|
||||
std::string text;
|
||||
|
@ -115,8 +115,8 @@ std::vector<text_chunk> split_text(std::string const & utf8_text) {
|
|||
current_chunk.subset = font_map[size_t(*ch)];
|
||||
}
|
||||
for(utils::utf8_iterator end = utils::utf8_iterator::end(utf8_text); ch != end; ++ch) {
|
||||
if(size_t(*ch) < font_map.size() &&
|
||||
font_map[size_t(*ch)] >= 0 &&
|
||||
if(size_t(*ch) < font_map.size() &&
|
||||
font_map[size_t(*ch)] >= 0 &&
|
||||
font_map[size_t(*ch)] != current_chunk.subset) {
|
||||
//null-terminate ucs2_text so we can pass it to SDL_ttf later
|
||||
current_chunk.ucs2_text.push_back(0);
|
||||
|
@ -240,7 +240,7 @@ struct font_style_setter
|
|||
//according to the SDL_ttf documentation, combinations of
|
||||
//styles may cause SDL_ttf to segfault. We work around this
|
||||
//here by disallowing combinations of styles
|
||||
|
||||
|
||||
if((style&TTF_STYLE_UNDERLINE) != 0) {
|
||||
//style = TTF_STYLE_NORMAL; //TTF_STYLE_UNDERLINE;
|
||||
style = TTF_STYLE_UNDERLINE;
|
||||
|
@ -249,7 +249,7 @@ struct font_style_setter
|
|||
} else if((style&TTF_STYLE_ITALIC) != 0) {
|
||||
//style = TTF_STYLE_NORMAL; //TTF_STYLE_ITALIC;
|
||||
style = TTF_STYLE_ITALIC;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TTF_SetFontStyle(font_, style);
|
||||
|
@ -303,7 +303,7 @@ void set_font_list(const std::vector<subset_descriptor>& fontlist)
|
|||
font_names.push_back(itor->name);
|
||||
|
||||
std::vector<std::pair<size_t,size_t> >::const_iterator cp_range;
|
||||
for(cp_range = itor->present_codepoints.begin();
|
||||
for(cp_range = itor->present_codepoints.begin();
|
||||
cp_range != itor->present_codepoints.end(); ++cp_range) {
|
||||
|
||||
size_t cp_max = maximum<size_t>(cp_range->first, cp_range->second);
|
||||
|
@ -311,7 +311,7 @@ void set_font_list(const std::vector<subset_descriptor>& fontlist)
|
|||
font_map.resize(cp_max+1, -1);
|
||||
}
|
||||
for(size_t cp = cp_range->first; cp <= cp_range->second; ++cp) {
|
||||
if(font_map[cp] < 0)
|
||||
if(font_map[cp] < 0)
|
||||
font_map[cp] = subset;
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ public:
|
|||
std::vector<surface> const & get_surfaces() const;
|
||||
|
||||
bool operator==(text_surface const &t) const {
|
||||
return hash_ == t.hash_ && font_size_ == t.font_size_
|
||||
return hash_ == t.hash_ && font_size_ == t.font_size_
|
||||
&& color_ == t.color_ && style_ == t.style_ && str_ == t.str_;
|
||||
}
|
||||
bool operator!=(text_surface const &t) const { return !operator==(t); }
|
||||
|
@ -399,8 +399,8 @@ void text_surface::measure() const
|
|||
{
|
||||
w_ = 0;
|
||||
h_ = 0;
|
||||
|
||||
for(std::vector<text_chunk>::iterator itor = chunks_.begin();
|
||||
|
||||
for(std::vector<text_chunk>::iterator itor = chunks_.begin();
|
||||
itor != chunks_.end(); ++itor) {
|
||||
|
||||
TTF_Font* ttfont = get_font(font_id(itor->subset, font_size_));
|
||||
|
@ -414,7 +414,7 @@ void text_surface::measure() const
|
|||
if(itor->ucs2_text.back() != 0) {
|
||||
itor->ucs2_text.push_back(0);
|
||||
}
|
||||
|
||||
|
||||
TTF_SizeUNICODE(ttfont, (Uint16 const *)&(itor->ucs2_text.front()), &w, &h);
|
||||
w_ += w;
|
||||
h_ = maximum<int>(h_, h);
|
||||
|
@ -434,7 +434,7 @@ size_t text_surface::width() const
|
|||
size_t text_surface::height() const
|
||||
{
|
||||
if (h_ == -1) {
|
||||
if(chunks_.empty())
|
||||
if(chunks_.empty())
|
||||
chunks_ = split_text(str_);
|
||||
measure();
|
||||
}
|
||||
|
@ -453,13 +453,13 @@ std::vector<surface> const &text_surface::get_surfaces() const
|
|||
if(width() > max_text_line_width)
|
||||
return surfs_;
|
||||
|
||||
for(std::vector<text_chunk>::const_iterator itor = chunks_.begin();
|
||||
for(std::vector<text_chunk>::const_iterator itor = chunks_.begin();
|
||||
itor != chunks_.end(); ++itor) {
|
||||
TTF_Font* ttfont = get_font(font_id(itor->subset, font_size_));
|
||||
if (ttfont == NULL)
|
||||
continue;
|
||||
font_style_setter const style_setter(ttfont, style_);
|
||||
|
||||
|
||||
surface s = surface(TTF_RenderUNICODE_Blended(ttfont, (Uint16 const *)&(itor->ucs2_text.front()), color_));
|
||||
if(!s.null())
|
||||
surfs_.push_back(s);
|
||||
|
@ -639,7 +639,7 @@ surface get_rendered_text(const std::string& str, int size, const SDL_Color& col
|
|||
//length restriction and small font size.
|
||||
SDL_Rect measure_ucs2_text_line(ucs2_string::const_iterator first, ucs2_string::const_iterator last, int font_size, int style) {
|
||||
wassert(last - first >= 0);
|
||||
|
||||
|
||||
SDL_Rect rect;
|
||||
rect.w = 0;
|
||||
rect.h = 0;
|
||||
|
@ -654,7 +654,7 @@ SDL_Rect measure_ucs2_text_line(ucs2_string::const_iterator first, ucs2_string::
|
|||
if(*first < font_map.size() && font_map[*first] >= 0) {
|
||||
current_font = font_map[*first];
|
||||
}
|
||||
|
||||
|
||||
for(;first != last; ++first) {
|
||||
if(*first < font_map.size() && font_map[*first] >= 0 && font_map[*first] != current_font) {
|
||||
TTF_Font* ttfont = get_font(font_id(current_font, font_size));
|
||||
|
@ -665,16 +665,16 @@ SDL_Rect measure_ucs2_text_line(ucs2_string::const_iterator first, ucs2_string::
|
|||
continue;
|
||||
}
|
||||
*(chunk_itor++) = 0;
|
||||
|
||||
|
||||
font_style_setter const style_setter(ttfont, style);
|
||||
|
||||
TTF_SizeUNICODE(ttfont, (Uint16 const *)&chunk.front(), (int*)&rect.x, (int*)&rect.y);
|
||||
|
||||
rect.w += rect.x;
|
||||
rect.h = maximum<Sint16>(rect.h, rect.y);
|
||||
|
||||
|
||||
chunk_itor = chunk.begin();
|
||||
|
||||
|
||||
current_font = font_map[*first];
|
||||
}
|
||||
*(chunk_itor++) = *first;
|
||||
|
@ -736,7 +736,7 @@ SDL_Rect draw_text_line(surface gui_surface, const SDL_Rect& area, int size,
|
|||
if(line_width(text, size) > area.w) {
|
||||
tooltips::add_tooltip(dest,text);
|
||||
}
|
||||
|
||||
|
||||
if(dest.x + dest.w > area.x + area.w) {
|
||||
dest.w = area.x + area.w - dest.x;
|
||||
}
|
||||
|
@ -764,13 +764,13 @@ SDL_Rect draw_text_line(CVideo* gui, const SDL_Rect& area, int size,
|
|||
int x, int y, bool use_tooltips, int style)
|
||||
{
|
||||
surface surface;
|
||||
|
||||
|
||||
if(gui == NULL) {
|
||||
surface = NULL;
|
||||
} else {
|
||||
surface = gui->getSurface();
|
||||
}
|
||||
|
||||
|
||||
return draw_text_line(surface, area, size, colour, text, x, y, use_tooltips, style);
|
||||
}
|
||||
|
||||
|
@ -866,7 +866,7 @@ std::string remove_first_space(const std::string& text)
|
|||
if (text.length() > 0 && text[0] == ' ') {
|
||||
return text.substr(1);
|
||||
}
|
||||
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -959,7 +959,7 @@ inline bool no_break_before(wchar_t ch)
|
|||
ch == 0x30e3 || ch == 0x30e5 || ch == 0x30e7 || ch == 0x30ee || ch == 0x30f5 ||
|
||||
ch == 0x30f6 || ch == 0x30fb || ch == 0x30fc || ch == 0x30fd || ch == 0x30fe ||
|
||||
ch == 0xff01 || ch == 0xff09 || ch == 0xff0c || ch == 0xff0e || ch == 0xff1a ||
|
||||
ch == 0xff1b || ch == 0xff1f || ch == 0xff3d || ch == 0xff5d;
|
||||
ch == 0xff1b || ch == 0xff1f || ch == 0xff3d || ch == 0xff5d;
|
||||
}
|
||||
|
||||
inline bool break_before(wchar_t ch)
|
||||
|
@ -967,7 +967,7 @@ inline bool break_before(wchar_t ch)
|
|||
if(no_break_before(ch))
|
||||
return false;
|
||||
|
||||
return ch == ' ' ||
|
||||
return ch == ' ' ||
|
||||
// CKJ characters
|
||||
(ch >= 0x3000 && ch < 0xa000) ||
|
||||
(ch >= 0xf900 && ch < 0xfb00) ||
|
||||
|
@ -979,7 +979,7 @@ inline bool break_after(wchar_t ch)
|
|||
if(no_break_after(ch))
|
||||
return false;
|
||||
|
||||
return ch == ' ' ||
|
||||
return ch == ' ' ||
|
||||
// CKJ characters
|
||||
(ch >= 0x3000 && ch < 0xa000) ||
|
||||
(ch >= 0xf900 && ch < 0xfb00) ||
|
||||
|
@ -1028,7 +1028,7 @@ std::string word_wrap_text(const std::string& unwrapped_text, int font_size, int
|
|||
*ch != ' ' && *ch != '\n'; ++ch) {
|
||||
|
||||
if(!current_word.empty() &&
|
||||
break_before(*ch) &&
|
||||
break_before(*ch) &&
|
||||
!no_break_after(previous))
|
||||
break;
|
||||
|
||||
|
@ -1097,12 +1097,12 @@ std::string word_wrap_text(const std::string& unwrapped_text, int font_size, int
|
|||
std::string make_text_ellipsis(const std::string &text, int font_size, int max_width)
|
||||
{
|
||||
static const std::string ellipsis = "...";
|
||||
|
||||
|
||||
if(line_width(text, font_size) <= max_width)
|
||||
return text;
|
||||
if(line_width(ellipsis, font_size) > max_width)
|
||||
return "";
|
||||
|
||||
|
||||
std::string current_substring;
|
||||
|
||||
utils::utf8_iterator itor(text);
|
||||
|
@ -1115,7 +1115,7 @@ std::string make_text_ellipsis(const std::string &text, int font_size, int max_w
|
|||
if (line_width(tmp, font_size) > max_width) {
|
||||
return current_substring + ellipsis;
|
||||
}
|
||||
|
||||
|
||||
current_substring.append(itor.substr().first, itor.substr().second);
|
||||
}
|
||||
|
||||
|
@ -1472,12 +1472,12 @@ void undraw_floating_labels(surface screen)
|
|||
}
|
||||
|
||||
namespace {
|
||||
bool add_font_to_fontlist(config* fonts_config, std::vector<font::subset_descriptor>& fontlist, const std::string& name)
|
||||
bool add_font_to_fontlist(config* fonts_config, std::vector<font::subset_descriptor>& fontlist, const std::string& name)
|
||||
{
|
||||
config* font = fonts_config->find_child("font", "name", name);
|
||||
if(font == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
fontlist.push_back(font::subset_descriptor());
|
||||
fontlist.back().name = name;
|
||||
std::vector<std::string> ranges = utils::split((*font)["codepoints"]);
|
||||
|
|
14
src/font.hpp
14
src/font.hpp
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -71,7 +71,7 @@ const int
|
|||
SIZE_PLUS = relative_size(16),
|
||||
SIZE_LARGE = relative_size(18),
|
||||
SIZE_XLARGE = relative_size(24)
|
||||
;
|
||||
;
|
||||
//function to draw text on the screen. The text will be clipped to area.
|
||||
//If the text runs outside of area horizontally, an ellipsis will be displayed
|
||||
//at the end of it. If use_tooltips is true, then text with an ellipsis will
|
||||
|
@ -104,7 +104,7 @@ SDL_Rect measure_ucs2_text_line(ucs2_string::const_iterator first, ucs2_string::
|
|||
|
||||
// Returns the maximum height of a font, in pixels
|
||||
int get_max_height(int size);
|
||||
|
||||
|
||||
bool is_format_char(char c);
|
||||
|
||||
///
|
||||
|
@ -130,7 +130,7 @@ std::string word_wrap_text(const std::string& unwrapped_text, int font_size, int
|
|||
/// If the text excedes the specified max width, end it with an ellipsis (...)
|
||||
///
|
||||
std::string make_text_ellipsis(const std::string& text, int font_size, int max_width);
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// Draw text on the screen. This method makes sure that the text
|
||||
|
@ -140,7 +140,7 @@ std::string make_text_ellipsis(const std::string& text, int font_size, int max_w
|
|||
/// but it doesn't support special markup or tooltips.
|
||||
///
|
||||
/// @return a bounding rectangle of the text.
|
||||
///
|
||||
///
|
||||
SDL_Rect draw_wrapped_text(CVideo* gui, const SDL_Rect& area, int font_size,
|
||||
const SDL_Color& colour, const std::string& text,
|
||||
int x, int y, int max_width);
|
||||
|
@ -171,7 +171,7 @@ enum LABEL_SCROLL_MODE { ANCHOR_LABEL_SCREEN, ANCHOR_LABEL_MAP };
|
|||
int add_floating_label(const std::string& text, int font_size, const SDL_Color& colour,
|
||||
double xpos, double ypos, double xmove, double ymove, int lifetime,
|
||||
const SDL_Rect& clip_rect, ALIGN alignment=CENTER_ALIGN,
|
||||
const SDL_Color* bg_colour=NULL, int border_size=0,
|
||||
const SDL_Color* bg_colour=NULL, int border_size=0,
|
||||
LABEL_SCROLL_MODE scroll_mode=ANCHOR_LABEL_SCREEN);
|
||||
|
||||
/// moves the floating label given by 'handle' by (xmove,ymove)
|
||||
|
|
334
src/game.cpp
334
src/game.cpp
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -270,16 +270,16 @@ bool game_controller::init_video()
|
|||
std::cerr << bpp << "\n";
|
||||
|
||||
if(bpp == 0) {
|
||||
//Video mode not supported, maybe from bad prefs.
|
||||
std::cerr << "Video mode " << resolution.first
|
||||
<< "x" << resolution.second << "x16 "
|
||||
<< "is not supported - attempting 1024x768x16...\n";
|
||||
|
||||
//Attempt 1024x768.
|
||||
resolution.first = 1024;
|
||||
resolution.second = 768;
|
||||
//Video mode not supported, maybe from bad prefs.
|
||||
std::cerr << "Video mode " << resolution.first
|
||||
<< "x" << resolution.second << "x16 "
|
||||
<< "is not supported - attempting 1024x768x16...\n";
|
||||
|
||||
bpp = video_.modePossible(resolution.first,resolution.second,16,video_flags);
|
||||
//Attempt 1024x768.
|
||||
resolution.first = 1024;
|
||||
resolution.second = 768;
|
||||
|
||||
bpp = video_.modePossible(resolution.first,resolution.second,16,video_flags);
|
||||
|
||||
if(bpp == 0) {
|
||||
std::cerr << "1024x768x16 not available - attempting 800x600x16...\n";
|
||||
|
@ -310,8 +310,8 @@ bool game_controller::init_video()
|
|||
}
|
||||
#endif
|
||||
|
||||
if(bpp == 0) {
|
||||
//couldn't do 1024x768 or 800x600
|
||||
if(bpp == 0) {
|
||||
//couldn't do 1024x768 or 800x600
|
||||
|
||||
std::cerr << "The required video mode, " << resolution.first
|
||||
<< "x" << resolution.second << "x16 "
|
||||
|
@ -436,158 +436,158 @@ bool game_controller::play_multiplayer_mode()
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string era = "era_default";
|
||||
std::string scenario = "multiplayer_test";
|
||||
std::map<int,std::string> side_types, side_controllers, side_algorithms;
|
||||
std::map<int,string_map> side_parameters;
|
||||
std::string era = "era_default";
|
||||
std::string scenario = "multiplayer_test";
|
||||
std::map<int,std::string> side_types, side_controllers, side_algorithms;
|
||||
std::map<int,string_map> side_parameters;
|
||||
|
||||
size_t sides_counted = 0;
|
||||
size_t sides_counted = 0;
|
||||
|
||||
for(++arg_; arg_ < argc_; ++arg_) {
|
||||
const std::string val(argv_[arg_]);
|
||||
if(val.empty()) {
|
||||
continue;
|
||||
}
|
||||
for(++arg_; arg_ < argc_; ++arg_) {
|
||||
const std::string val(argv_[arg_]);
|
||||
if(val.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<std::string> name_value = utils::split(val, '=');
|
||||
if(name_value.size() > 2) {
|
||||
std::cerr << "invalid argument '" << val << "'\n";
|
||||
return false;
|
||||
} else if(name_value.size() == 2) {
|
||||
const std::string name = name_value.front();
|
||||
const std::string value = name_value.back();
|
||||
std::vector<std::string> name_value = utils::split(val, '=');
|
||||
if(name_value.size() > 2) {
|
||||
std::cerr << "invalid argument '" << val << "'\n";
|
||||
return false;
|
||||
} else if(name_value.size() == 2) {
|
||||
const std::string name = name_value.front();
|
||||
const std::string value = name_value.back();
|
||||
|
||||
const std::string name_head = name.substr(0,name.size()-1);
|
||||
const char name_tail = name[name.size()-1];
|
||||
const bool last_digit = isdigit(name_tail) ? true:false;
|
||||
const size_t side = name_tail - '0';
|
||||
const std::string name_head = name.substr(0,name.size()-1);
|
||||
const char name_tail = name[name.size()-1];
|
||||
const bool last_digit = isdigit(name_tail) ? true:false;
|
||||
const size_t side = name_tail - '0';
|
||||
|
||||
if(last_digit && side > sides_counted) {
|
||||
std::cerr << "counted sides: " << side << "\n";
|
||||
sides_counted = side;
|
||||
}
|
||||
if(last_digit && side > sides_counted) {
|
||||
std::cerr << "counted sides: " << side << "\n";
|
||||
sides_counted = side;
|
||||
}
|
||||
|
||||
if(name == "--scenario") {
|
||||
scenario = value;
|
||||
} else if(name == "--era") {
|
||||
era = value;
|
||||
} else if(last_digit && name_head == "--controller") {
|
||||
side_controllers[side] = value;
|
||||
} else if(last_digit && name_head == "--algorithm") {
|
||||
side_algorithms[side] = value;
|
||||
} else if(last_digit && name_head == "--side") {
|
||||
side_types[side] = value;
|
||||
} else if(last_digit && name_head == "--parm") {
|
||||
const std::vector<std::string> name_value = utils::split(value, ':');
|
||||
if(name_value.size() != 2) {
|
||||
std::cerr << "argument to '" << name << "' must be in the format name:value\n";
|
||||
return false;
|
||||
}
|
||||
if(name == "--scenario") {
|
||||
scenario = value;
|
||||
} else if(name == "--era") {
|
||||
era = value;
|
||||
} else if(last_digit && name_head == "--controller") {
|
||||
side_controllers[side] = value;
|
||||
} else if(last_digit && name_head == "--algorithm") {
|
||||
side_algorithms[side] = value;
|
||||
} else if(last_digit && name_head == "--side") {
|
||||
side_types[side] = value;
|
||||
} else if(last_digit && name_head == "--parm") {
|
||||
const std::vector<std::string> name_value = utils::split(value, ':');
|
||||
if(name_value.size() != 2) {
|
||||
std::cerr << "argument to '" << name << "' must be in the format name:value\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
side_parameters[side][name_value.front()] = name_value.back();
|
||||
} else {
|
||||
std::cerr << "unrecognized option: '" << name << "'\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
side_parameters[side][name_value.front()] = name_value.back();
|
||||
} else {
|
||||
std::cerr << "unrecognized option: '" << name << "'\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const config* const lvl = game_config_.find_child("multiplayer","id",scenario);
|
||||
if(lvl == NULL) {
|
||||
std::cerr << "Could not find scenario '" << scenario << "'\n";
|
||||
return false;
|
||||
}
|
||||
const config* const lvl = game_config_.find_child("multiplayer","id",scenario);
|
||||
if(lvl == NULL) {
|
||||
std::cerr << "Could not find scenario '" << scenario << "'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
state_.campaign_type = "multiplayer";
|
||||
state_.scenario = "";
|
||||
state_.snapshot = config();
|
||||
state_.campaign_type = "multiplayer";
|
||||
state_.scenario = "";
|
||||
state_.snapshot = config();
|
||||
|
||||
config level = *lvl;
|
||||
std::vector<config*> story;
|
||||
config level = *lvl;
|
||||
std::vector<config*> story;
|
||||
|
||||
const config* const era_cfg = game_config_.find_child("era","id",era);
|
||||
if(era_cfg == NULL) {
|
||||
std::cerr << "Could not find era '" << era << "'\n";
|
||||
return false;
|
||||
}
|
||||
const config* const era_cfg = game_config_.find_child("era","id",era);
|
||||
if(era_cfg == NULL) {
|
||||
std::cerr << "Could not find era '" << era << "'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
const config* const side = era_cfg->child("multiplayer_side");
|
||||
if(side == NULL) {
|
||||
std::cerr << "Could not find multiplayer side\n";
|
||||
return false;
|
||||
}
|
||||
const config* const side = era_cfg->child("multiplayer_side");
|
||||
if(side == NULL) {
|
||||
std::cerr << "Could not find multiplayer side\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
while(level.get_children("side").size() < sides_counted) {
|
||||
std::cerr << "now adding side...\n";
|
||||
level.add_child("side");
|
||||
}
|
||||
while(level.get_children("side").size() < sides_counted) {
|
||||
std::cerr << "now adding side...\n";
|
||||
level.add_child("side");
|
||||
}
|
||||
|
||||
int side_num = 1;
|
||||
for(config::child_itors itors = level.child_range("side"); itors.first != itors.second; ++itors.first, ++side_num) {
|
||||
std::map<int,std::string>::const_iterator type = side_types.find(side_num),
|
||||
controller = side_controllers.find(side_num),
|
||||
algorithm = side_algorithms.find(side_num);
|
||||
int side_num = 1;
|
||||
for(config::child_itors itors = level.child_range("side"); itors.first != itors.second; ++itors.first, ++side_num) {
|
||||
std::map<int,std::string>::const_iterator type = side_types.find(side_num),
|
||||
controller = side_controllers.find(side_num),
|
||||
algorithm = side_algorithms.find(side_num);
|
||||
|
||||
const config* side = type == side_types.end() ?
|
||||
era_cfg->find_child("multiplayer_side", "random_faction", "yes") :
|
||||
era_cfg->find_child("multiplayer_side", "id", type->second);
|
||||
const config* side = type == side_types.end() ?
|
||||
era_cfg->find_child("multiplayer_side", "random_faction", "yes") :
|
||||
era_cfg->find_child("multiplayer_side", "id", type->second);
|
||||
|
||||
if (side == NULL) {
|
||||
unknown_side_id:
|
||||
std::string side_name = (type == side_types.end() ? "default" : type->second);
|
||||
std::cerr << "Could not find side '" << side_name << "' for side " << side_num << "\n";
|
||||
return false;
|
||||
}
|
||||
std::string side_name = (type == side_types.end() ? "default" : type->second);
|
||||
std::cerr << "Could not find side '" << side_name << "' for side " << side_num << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((*side)["random_faction"] == "yes") {
|
||||
const config::child_list& eras = era_cfg->get_children("multiplayer_side");
|
||||
for(int i = 0; i != 100 && (*side)["random_faction"] == "yes"; ++i) {
|
||||
side = eras[rand()%eras.size()];
|
||||
}
|
||||
if ((*side)["random_faction"] == "yes")
|
||||
goto unknown_side_id;
|
||||
}
|
||||
if ((*side)["random_faction"] == "yes")
|
||||
goto unknown_side_id;
|
||||
}
|
||||
|
||||
char buf[20];
|
||||
sprintf(buf,"%d",side_num);
|
||||
(*itors.first)->values["side"] = buf;
|
||||
char buf[20];
|
||||
sprintf(buf,"%d",side_num);
|
||||
(*itors.first)->values["side"] = buf;
|
||||
|
||||
(*itors.first)->values["canrecruit"] = "1";
|
||||
(*itors.first)->values["canrecruit"] = "1";
|
||||
|
||||
for(string_map::const_iterator i = side->values.begin(); i != side->values.end(); ++i) {
|
||||
(*itors.first)->values[i->first] = i->second;
|
||||
}
|
||||
for(string_map::const_iterator i = side->values.begin(); i != side->values.end(); ++i) {
|
||||
(*itors.first)->values[i->first] = i->second;
|
||||
}
|
||||
|
||||
if(controller != side_controllers.end()) {
|
||||
(*itors.first)->values["controller"] = controller->second;
|
||||
}
|
||||
if(controller != side_controllers.end()) {
|
||||
(*itors.first)->values["controller"] = controller->second;
|
||||
}
|
||||
|
||||
if(algorithm != side_algorithms.end()) {
|
||||
(*itors.first)->values["ai_algorithm"] = algorithm->second;
|
||||
}
|
||||
if(algorithm != side_algorithms.end()) {
|
||||
(*itors.first)->values["ai_algorithm"] = algorithm->second;
|
||||
}
|
||||
|
||||
config& ai_params = (*itors.first)->add_child("ai");
|
||||
config& ai_params = (*itors.first)->add_child("ai");
|
||||
|
||||
//now add in any arbitrary parameters given to the side
|
||||
for(string_map::const_iterator j = side_parameters[side_num].begin(); j != side_parameters[side_num].end(); ++j) {
|
||||
(*itors.first)->values[j->first] = j->second;
|
||||
ai_params[j->first] = j->second;
|
||||
}
|
||||
}
|
||||
//now add in any arbitrary parameters given to the side
|
||||
for(string_map::const_iterator j = side_parameters[side_num].begin(); j != side_parameters[side_num].end(); ++j) {
|
||||
(*itors.first)->values[j->first] = j->second;
|
||||
ai_params[j->first] = j->second;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
::play_game(disp(),state_,game_config_,units_data_,video_);
|
||||
//play_level(units_data_,game_config_,&level,video_,state_,story);
|
||||
} catch(game::error& e) {
|
||||
std::cerr << "caught error: '" << e.message << "'\n";
|
||||
} catch(game::load_game_exception& e) {
|
||||
//the user's trying to load a game, so go into the normal title screen loop and load one
|
||||
loaded_game_ = e.game;
|
||||
loaded_game_show_replay_ = e.show_replay;
|
||||
//play_level(units_data_,game_config_,&level,video_,state_,story);
|
||||
} catch(game::error& e) {
|
||||
std::cerr << "caught error: '" << e.message << "'\n";
|
||||
} catch(game::load_game_exception& e) {
|
||||
//the user's trying to load a game, so go into the normal title screen loop and load one
|
||||
loaded_game_ = e.game;
|
||||
loaded_game_show_replay_ = e.show_replay;
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cerr << "caught unknown error playing level...\n";
|
||||
}
|
||||
} catch(...) {
|
||||
std::cerr << "caught unknown error playing level...\n";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ bool game_controller::load_game()
|
|||
std::string error_log;
|
||||
read_save_file(game,cfg,&error_log);
|
||||
if(!error_log.empty()) {
|
||||
gui::show_error_message(disp(),
|
||||
gui::show_error_message(disp(),
|
||||
_("Warning: The file you have tried to load is corrupt. Loading anyway.\n") +
|
||||
error_log);
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ bool game_controller::load_game()
|
|||
refresh_game_cfg();
|
||||
|
||||
state_ = read_game(units_data_,&cfg);
|
||||
|
||||
|
||||
if(state_.version != game_config::version) {
|
||||
const int res = gui::show_dialog(disp(),NULL,"",
|
||||
_("This save is from a different version of the game. Do you want to try to load it?"),
|
||||
|
@ -659,7 +659,7 @@ bool game_controller::load_game()
|
|||
} catch(io_exception&) {
|
||||
gui::show_error_message(disp(), _("File I/O Error while reading the game"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
recorder = replay(state_.replay_data);
|
||||
recorder.start_replay();
|
||||
recorder.set_skip(0);
|
||||
|
@ -794,7 +794,7 @@ bool game_controller::new_campaign()
|
|||
}
|
||||
|
||||
state_.campaign_define = campaign["define"];
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -898,7 +898,7 @@ void game_controller::download_campaigns()
|
|||
for(config::child_list::const_iterator i = cmps.begin(); i != cmps.end(); ++i) {
|
||||
const std::string& name = (**i)["name"];
|
||||
campaigns.push_back(name);
|
||||
|
||||
|
||||
if(std::count(publish_options.begin(),publish_options.end(),name) != 0) {
|
||||
delete_options.push_back(name);
|
||||
}
|
||||
|
@ -926,7 +926,7 @@ void game_controller::download_campaigns()
|
|||
|
||||
//add negative sizes to reverse the sort order
|
||||
sizes.push_back(-atoi((**i)["size"].c_str()));
|
||||
|
||||
|
||||
options.push_back(IMAGE_PREFIX + (**i)["icon"].str() + COLUMN_SEPARATOR +
|
||||
title + COLUMN_SEPARATOR +
|
||||
version + COLUMN_SEPARATOR +
|
||||
|
@ -934,7 +934,7 @@ void game_controller::download_campaigns()
|
|||
(**i)["downloads"].str() + COLUMN_SEPARATOR +
|
||||
format_file_size((**i)["size"]));
|
||||
}
|
||||
|
||||
|
||||
options.push_back(heading.str());
|
||||
|
||||
for(std::vector<std::string>::const_iterator j = publish_options.begin(); j != publish_options.end(); ++j) {
|
||||
|
@ -1053,7 +1053,7 @@ void game_controller::upload_campaign(const std::string& campaign, network::conn
|
|||
|
||||
std::cerr << "uploading campaign...\n";
|
||||
network::send_data(data,sock);
|
||||
|
||||
|
||||
sock = network::receive_data(data,sock,5000);
|
||||
if(!sock) {
|
||||
gui::show_error_message(disp(), _("Connection timed out"));
|
||||
|
@ -1125,18 +1125,18 @@ bool game_controller::play_multiplayer()
|
|||
return false;
|
||||
|
||||
preferences::set_login(login);
|
||||
|
||||
|
||||
try {
|
||||
defines_map_.clear();
|
||||
defines_map_[state_.campaign_define] = preproc_define();
|
||||
refresh_game_cfg();
|
||||
|
||||
|
||||
if(res >= 2) {
|
||||
std::vector<std::string> chat;
|
||||
config game_data;
|
||||
|
||||
const mp::controller cntr = (res == 2 ?
|
||||
mp::CNTR_NETWORK :
|
||||
const mp::controller cntr = (res == 2 ?
|
||||
mp::CNTR_NETWORK :
|
||||
(res == 3 ? mp::CNTR_LOCAL : mp::CNTR_COMPUTER ));
|
||||
const bool is_server = res == 2;
|
||||
|
||||
|
@ -1242,7 +1242,7 @@ void game_controller::read_game_cfg(preproc_map& defines, config& cfg, bool use_
|
|||
const std::string fname_checksum = fname + ".checksum";
|
||||
|
||||
file_tree_checksum dir_checksum;
|
||||
|
||||
|
||||
if(use_cache) {
|
||||
try {
|
||||
if(file_exists(fname_checksum)) {
|
||||
|
@ -1273,14 +1273,14 @@ void game_controller::read_game_cfg(preproc_map& defines, config& cfg, bool use_
|
|||
}
|
||||
|
||||
std::cerr << "no valid cache found. Writing cache to '" << fname << "'\n";
|
||||
|
||||
|
||||
//read the file and then write to the cache
|
||||
scoped_istream stream = preprocess_file("data/game.cfg", &defines);
|
||||
|
||||
std::string error_log;
|
||||
read(cfg, *stream, &error_log);
|
||||
if(!error_log.empty()) {
|
||||
gui::show_error_message(disp(),
|
||||
gui::show_error_message(disp(),
|
||||
_("Warning: Errors occurred while loading game configuration files: '") +
|
||||
error_log);
|
||||
|
||||
|
@ -1346,7 +1346,7 @@ void game_controller::play_game(RELOAD_GAME_DATA reload)
|
|||
if(defines_map_.count("NORMAL")) {
|
||||
defines_map_["MEDIUM"] = preproc_define();
|
||||
}
|
||||
|
||||
|
||||
refresh_game_cfg();
|
||||
}
|
||||
|
||||
|
@ -1382,16 +1382,16 @@ int play_game(int argc, char** argv)
|
|||
continue;
|
||||
}
|
||||
|
||||
if(val == "--help" || val == "-h") {
|
||||
std::cout << "usage: " << argv[0]
|
||||
<< " [options] [data-directory]\n"
|
||||
<< " -d, --debug Shows debugging information in-game\n"
|
||||
<< " -f, --fullscreen Runs the game in full-screen\n"
|
||||
<< " -h, --help Prints this message and exits\n"
|
||||
<< " --path Prints the name of the game data directory and exits\n"
|
||||
<< " -t, --test Runs the game in a small example scenario\n"
|
||||
<< " -w, --windowed Runs the game in windowed mode\n"
|
||||
<< " -v, --version Prints the game's version number and exits\n"
|
||||
if(val == "--help" || val == "-h") {
|
||||
std::cout << "usage: " << argv[0]
|
||||
<< " [options] [data-directory]\n"
|
||||
<< " -d, --debug Shows debugging information in-game\n"
|
||||
<< " -f, --fullscreen Runs the game in full-screen\n"
|
||||
<< " -h, --help Prints this message and exits\n"
|
||||
<< " --path Prints the name of the game data directory and exits\n"
|
||||
<< " -t, --test Runs the game in a small example scenario\n"
|
||||
<< " -w, --windowed Runs the game in windowed mode\n"
|
||||
<< " -v, --version Prints the game's version number and exits\n"
|
||||
<< " --log-error=\"domain1,domain2,...\", --log-warning=..., --log-info=...\n"
|
||||
<< " Set the severity level of the debug domains\n"
|
||||
<< " \"all\" can be used to match any debug domain\n"
|
||||
|
@ -1402,15 +1402,15 @@ int play_game(int argc, char** argv)
|
|||
<< " --decompress file1 file2 Uncompresses the binary-WML file file2 into\n"
|
||||
<< " the text-WML file file2\n"
|
||||
;
|
||||
return 0;
|
||||
} else if(val == "--version" || val == "-v") {
|
||||
std::cout << _("Battle for Wesnoth") << " " << game_config::version
|
||||
<< "\n";
|
||||
return 0;
|
||||
} else if(val == "--path") {
|
||||
std::cout << game_config::path
|
||||
<< "\n";
|
||||
return 0;
|
||||
return 0;
|
||||
} else if(val == "--version" || val == "-v") {
|
||||
std::cout << _("Battle for Wesnoth") << " " << game_config::version
|
||||
<< "\n";
|
||||
return 0;
|
||||
} else if(val == "--path") {
|
||||
std::cout << game_config::path
|
||||
<< "\n";
|
||||
return 0;
|
||||
} else if(val == "--nosound") {
|
||||
use_sound = false;
|
||||
} else if (val.substr(0, 6) == "--log-") {
|
||||
|
@ -1613,7 +1613,7 @@ int play_game(int argc, char** argv)
|
|||
about::show_about(game.disp());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
game.play_game(should_reload);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -56,11 +56,11 @@ namespace game_config
|
|||
|
||||
std::string dot_image = "misc/dot.png";
|
||||
std::string cross_image = "misc/cross.png";
|
||||
|
||||
|
||||
std::vector<std::string> foot_left_nw, foot_left_n, foot_right_nw, foot_right_n;
|
||||
|
||||
std::string observer_image;
|
||||
|
||||
|
||||
std::string unchecked_menu_image = "buttons/checkbox.png";
|
||||
std::string checked_menu_image = "buttons/checkbox-pressed.png";
|
||||
|
||||
|
@ -136,7 +136,7 @@ namespace game_config
|
|||
missile_ne_image = v["missile_ne_image"];
|
||||
|
||||
terrain_mask_image = v["terrain_mask_image"];
|
||||
|
||||
|
||||
observer_image = v["observer_image"];
|
||||
|
||||
download_campaign_image = v["download_campaign_image"];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -40,7 +40,7 @@ namespace game_config
|
|||
extern std::string game_icon, game_title, game_logo, title_music, map_image, rightside_image, rightside_image_bot,
|
||||
moved_energy_image, unmoved_energy_image, partmoved_energy_image,
|
||||
enemy_energy_image,ally_energy_image,flag_image,
|
||||
dot_image,cross_image,
|
||||
dot_image,cross_image,
|
||||
missile_n_image,missile_ne_image,terrain_mask_image,observer_image,download_campaign_image,
|
||||
checked_menu_image,unchecked_menu_image;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Copyright (C) 2005 by Yann Dirson <ydirson@altern.org>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -64,7 +64,7 @@ bool conditional_passed(const std::map<gamemap::location,unit>* units,
|
|||
//an 'or' statement means that if the contained statements are true,
|
||||
//then it automatically passes
|
||||
const vconfig::child_list& or_statements = cond.get_children("or");
|
||||
for(vconfig::child_list::const_iterator or_it = or_statements.begin();
|
||||
for(vconfig::child_list::const_iterator or_it = or_statements.begin();
|
||||
or_it != or_statements.end(); ++or_it) {
|
||||
if(conditional_passed(units,*or_it)) {
|
||||
return true;
|
||||
|
@ -173,7 +173,7 @@ std::deque<queued_event> events_queue;
|
|||
class event_handler
|
||||
{
|
||||
public:
|
||||
event_handler(const config& cfg) :
|
||||
event_handler(const config& cfg) :
|
||||
name_(cfg["name"]),
|
||||
first_time_only_(cfg["first_time_only"] != "no"),
|
||||
disabled_(false),
|
||||
|
@ -200,12 +200,12 @@ public:
|
|||
return cfg_.get_children("filter");
|
||||
}
|
||||
|
||||
const vconfig::child_list second_arg_filters()
|
||||
const vconfig::child_list second_arg_filters()
|
||||
{
|
||||
return cfg_.get_children("filter_second");
|
||||
}
|
||||
|
||||
bool handle_event(const queued_event& event_info,
|
||||
bool handle_event(const queued_event& event_info,
|
||||
const vconfig cfg = vconfig());
|
||||
|
||||
private:
|
||||
|
@ -234,7 +234,7 @@ std::multimap<std::string,event_handler> events_map;
|
|||
|
||||
//this function handles all the different types of actions that can be triggered
|
||||
//by an event.
|
||||
bool event_handler::handle_event_command(const queued_event& event_info,
|
||||
bool event_handler::handle_event_command(const queued_event& event_info,
|
||||
const std::string& cmd, const vconfig cfg, bool& mutated)
|
||||
{
|
||||
log_scope2(engine, "handle_event_command");
|
||||
|
@ -269,19 +269,19 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
screen->invalidate_all();
|
||||
}
|
||||
|
||||
|
||||
//teleport a unit from one location to another
|
||||
else if(cmd == "teleport") {
|
||||
|
||||
|
||||
unit_map::iterator u = units->find(event_info.loc1);
|
||||
|
||||
//search for a valid unit filter, and if we have one, look for the matching unit
|
||||
const vconfig filter = cfg.child("filter");
|
||||
if(!filter.null()) {
|
||||
if(!filter.null()) {
|
||||
for(u = units->begin(); u != units->end(); ++u){
|
||||
if(game_events::unit_matches_filter(u, filter))
|
||||
break;
|
||||
|
@ -533,7 +533,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//provide a means of specifying win/loss conditions:
|
||||
// [event]
|
||||
// name=prestart
|
||||
|
@ -581,7 +581,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
}
|
||||
|
||||
t_string win_string = cfg["victory_string"];
|
||||
if(win_string.empty())
|
||||
if(win_string.empty())
|
||||
win_string = t_string(N_("Victory:"), "wesnoth");
|
||||
t_string lose_string = cfg["defeat_string"];
|
||||
if(lose_string.empty())
|
||||
|
@ -591,7 +591,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
t_string lose_objectives;
|
||||
|
||||
const vconfig::child_list objectives = cfg.get_children("objective");
|
||||
for(vconfig::child_list::const_iterator obj_it = objectives.begin();
|
||||
for(vconfig::child_list::const_iterator obj_it = objectives.begin();
|
||||
obj_it != objectives.end(); ++obj_it) {
|
||||
|
||||
const t_string description = (*obj_it)["description"];
|
||||
|
@ -681,7 +681,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
|
||||
// random generation works as follows:
|
||||
// random=[comma delimited list]
|
||||
// Each element in the list will be considered a separate choice,
|
||||
// Each element in the list will be considered a separate choice,
|
||||
// unless it contains "..". In this case, it must be a numerical
|
||||
// range. (i.e. -1..-10, 0..100, -10..10, etc)
|
||||
const std::string& random = cfg["random"];
|
||||
|
@ -690,20 +690,20 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
std::vector<std::string> words;
|
||||
std::vector<std::pair<size_t,size_t> > ranges;
|
||||
int num_choices = 0;
|
||||
std::string::size_type pos = 0, pos2 = std::string::npos, tmp;
|
||||
std::string::size_type pos = 0, pos2 = std::string::npos, tmp;
|
||||
std::stringstream ss(std::stringstream::in|std::stringstream::out);
|
||||
while (pos2 != random.length()) {
|
||||
pos = pos2+1;
|
||||
pos2 = random.find(",", pos);
|
||||
|
||||
if (pos2 == std::string::npos)
|
||||
if (pos2 == std::string::npos)
|
||||
pos2 = random.length();
|
||||
|
||||
word = random.substr(pos, pos2-pos);
|
||||
words.push_back(word);
|
||||
tmp = word.find("..");
|
||||
|
||||
|
||||
|
||||
|
||||
if (tmp == std::string::npos) {
|
||||
// treat this element as a string
|
||||
ranges.push_back(std::pair<int, int>(0,0));
|
||||
|
@ -732,7 +732,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
}
|
||||
|
||||
size_t choice = get_random() % num_choices;
|
||||
tmp = 0;
|
||||
tmp = 0;
|
||||
for(size_t i = 0; i < ranges.size(); i++) {
|
||||
tmp += (ranges[i].second - ranges[i].first) + 1;
|
||||
if (tmp > choice) {
|
||||
|
@ -1102,7 +1102,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(speaker == units->end() && cfg["speaker"] != "narrator") {
|
||||
//no matching unit found, so the dialog can't come up
|
||||
//continue onto the next message
|
||||
|
@ -1161,7 +1161,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
int option_chosen = -1;
|
||||
|
||||
LOG_DP << "showing dialog...\n";
|
||||
|
||||
|
||||
//if we're not replaying, or if we are replaying and there is no choice
|
||||
//to be made, show the dialog.
|
||||
if(get_replay_source().at_end() || options.empty()) {
|
||||
|
@ -1200,7 +1200,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
//implement the consequences of the choice
|
||||
if(options.empty() == false) {
|
||||
wassert(size_t(option_chosen) < menu_items.size());
|
||||
|
||||
|
||||
vconfig::child_list events = option_events[option_chosen];
|
||||
for(vconfig::child_list::const_iterator itor = events.begin();
|
||||
itor != events.end(); ++itor) {
|
||||
|
@ -1459,7 +1459,7 @@ bool event_handler::handle_event(const queued_event& event_info, const vconfig c
|
|||
|
||||
const std::pair<const std::string*,const config*> item = *i;
|
||||
|
||||
// If the user pressed escape, we skip any message that doesn't
|
||||
// If the user pressed escape, we skip any message that doesn't
|
||||
// require them to make a choice.
|
||||
if ((skip_messages) && (*item.first == "message")) {
|
||||
if ((item.second)->get_children("option").size() == 0) {
|
||||
|
@ -1470,7 +1470,7 @@ bool event_handler::handle_event(const queued_event& event_info, const vconfig c
|
|||
if (!handle_event_command(event_info, *item.first, vconfig(item.second), mutated)) {
|
||||
skip_messages = true;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
skip_messages = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -374,7 +374,7 @@ void write_game(const game_state& game, config& cfg, WRITE_GAME_MODE mode)
|
|||
if(game.replay_data.child("replay") == NULL) {
|
||||
cfg.add_child("replay",game.replay_data);
|
||||
}
|
||||
|
||||
|
||||
cfg.add_child("snapshot",game.snapshot);
|
||||
cfg.add_child("replay_start",game.starting_pos);
|
||||
cfg.add_child("statistics",statistics::write_stats());
|
||||
|
@ -414,7 +414,7 @@ bool save_game_exists(const std::string& name)
|
|||
{
|
||||
std::string fname = name;
|
||||
std::replace(fname.begin(),fname.end(),' ','_');
|
||||
|
||||
|
||||
return file_exists(get_saves_dir() + "/" + fname);
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ void load_game(const game_data& data, const std::string& name, game_state& state
|
|||
|
||||
config cfg;
|
||||
read_save_file(name,cfg,error_log);
|
||||
|
||||
|
||||
state = read_game(data,&cfg);
|
||||
}
|
||||
|
||||
|
@ -554,7 +554,7 @@ void extract_summary_data_from_save(const game_state& state, config& out)
|
|||
|
||||
out["replay"] = has_replay ? "yes" : "no";
|
||||
out["snapshot"] = has_snapshot ? "yes" : "no";
|
||||
|
||||
|
||||
out["campaign_type"] = state.campaign_type;
|
||||
out["scenario"] = state.scenario;
|
||||
out["difficulty"] = state.difficulty;
|
||||
|
@ -632,7 +632,7 @@ void game_state::get_variable_internal(const std::string& key, config& cfg,
|
|||
t_string** varout, config** cfgout)
|
||||
{
|
||||
//we get the variable from the [variables] section of the game state. Variables may
|
||||
//be in the format
|
||||
//be in the format
|
||||
const std::string::const_iterator itor = std::find(key.begin(),key.end(),'.');
|
||||
if(itor != key.end()) {
|
||||
std::string element(key.begin(),itor);
|
||||
|
@ -675,7 +675,7 @@ void game_state::get_variable_internal(const std::string& key, config& cfg,
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while(cfg.get_children(element).size() <= index) {
|
||||
cfg.add_child(element);
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ void game_state::get_variable_internal(const std::string& key, config& cfg,
|
|||
if(cfgout != NULL) {
|
||||
*cfgout = cfg.get_children(element)[index];
|
||||
}
|
||||
|
||||
|
||||
get_variable_internal(sub_key,*cfg.get_children(element)[index],varout,cfgout);
|
||||
} else {
|
||||
if(varout != NULL) {
|
||||
|
@ -699,7 +699,7 @@ t_string& game_state::get_variable(const std::string& key)
|
|||
if(res != NULL) {
|
||||
return *res;
|
||||
}
|
||||
|
||||
|
||||
static t_string empty_string;
|
||||
return empty_string;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
std::string current_image_;
|
||||
|
||||
bool reverse_;
|
||||
|
||||
|
||||
int origx_, origy_, x_, y_;
|
||||
double origzoom_, zoom_;
|
||||
surface surf_, buffer_;
|
||||
|
|
140
src/help.cpp
140
src/help.cpp
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -58,7 +58,7 @@ struct section;
|
|||
typedef std::vector<section *> section_list;
|
||||
|
||||
/// Generate a topic text on the fly.
|
||||
class topic_generator
|
||||
class topic_generator
|
||||
{
|
||||
unsigned count;
|
||||
friend class topic_text;
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
/// The text displayed in a topic. It is generated on the fly with the information
|
||||
/// contained in generator_.
|
||||
class topic_text
|
||||
class topic_text
|
||||
{
|
||||
mutable std::vector< std::string > parsed_text_;
|
||||
mutable topic_generator *generator_;
|
||||
|
@ -124,10 +124,10 @@ struct section {
|
|||
bool operator==(const section &) const;
|
||||
/// Comparison on the ID.
|
||||
bool operator<(const section &) const;
|
||||
|
||||
|
||||
/// Allocate memory for and add the section.
|
||||
void add_section(const section &s);
|
||||
|
||||
|
||||
void clear();
|
||||
std::string title, id;
|
||||
topic_list topics;
|
||||
|
@ -137,7 +137,7 @@ struct section {
|
|||
|
||||
/// To be used as a function object to locate sections and topics
|
||||
/// with a specified ID.
|
||||
class has_id
|
||||
class has_id
|
||||
{
|
||||
public:
|
||||
has_id(const std::string &id) : id_(id) {}
|
||||
|
@ -149,26 +149,26 @@ private:
|
|||
};
|
||||
|
||||
/// To be used as a function object when sorting topic lists on the title.
|
||||
class title_less
|
||||
class title_less
|
||||
{
|
||||
public:
|
||||
bool operator()(const topic &t1, const topic &t2) { return t1.title < t2.title; }
|
||||
};
|
||||
|
||||
struct delete_section
|
||||
struct delete_section
|
||||
{
|
||||
void operator()(section *s) { delete s; }
|
||||
};
|
||||
|
||||
struct create_section
|
||||
struct create_section
|
||||
{
|
||||
section *operator()(const section *s) { return new section(*s); }
|
||||
section *operator()(const section &s) { return new section(s); }
|
||||
};
|
||||
|
||||
|
||||
/// The menu to the left in the help browser, where topics can be
|
||||
/// navigated through and chosen.
|
||||
class help_menu : public gui::menu
|
||||
class help_menu : public gui::menu
|
||||
{
|
||||
public:
|
||||
help_menu(CVideo &video, const section &toplevel, int max_height=-1);
|
||||
|
@ -201,7 +201,7 @@ private:
|
|||
/// Regenerate what items are visible by checking what sections are
|
||||
/// expanded.
|
||||
void update_visible_items(const section &top_level, unsigned starting_level=0);
|
||||
|
||||
|
||||
/// Return true if the section is expanded.
|
||||
bool expanded(const section &sec);
|
||||
|
||||
|
@ -222,14 +222,14 @@ private:
|
|||
|
||||
/// Draw the currently visible items.
|
||||
void display_visible_items();
|
||||
|
||||
|
||||
/// Internal recursive thingie. did_expand will be true if any
|
||||
/// section was expanded, otherwise untouched.
|
||||
bool select_topic_internal(const topic &t, const section &sec);
|
||||
|
||||
std::vector<visible_item> visible_items_;
|
||||
const section &toplevel_;
|
||||
std::set<const section*> expanded_;
|
||||
std::set<const section*> expanded_;
|
||||
surface_restorer restorer_;
|
||||
SDL_Rect rect_;
|
||||
topic const *chosen_topic_;
|
||||
|
@ -237,14 +237,14 @@ private:
|
|||
};
|
||||
|
||||
/// Thrown when the help system fails to parse something.
|
||||
struct parse_error
|
||||
struct parse_error
|
||||
{
|
||||
parse_error(const std::string& msg) : message(msg) {}
|
||||
std::string message;
|
||||
};
|
||||
|
||||
/// The area where the content is shown in the help browser.
|
||||
class help_text_area : public gui::scrollarea
|
||||
class help_text_area : public gui::scrollarea
|
||||
{
|
||||
public:
|
||||
help_text_area(CVideo &video, const section &toplevel);
|
||||
|
@ -283,11 +283,11 @@ private:
|
|||
surface surf;
|
||||
|
||||
// If this item contains text, this will contain that text.
|
||||
std::string text;
|
||||
std::string text;
|
||||
|
||||
// If this item contains a cross-reference, this is the id
|
||||
// of the referenced topic.
|
||||
std::string ref_to;
|
||||
std::string ref_to;
|
||||
|
||||
// If this item is floating, that is, if things should be filled
|
||||
// around it.
|
||||
|
@ -295,7 +295,7 @@ private:
|
|||
bool box;
|
||||
ALIGNMENT align;
|
||||
};
|
||||
|
||||
|
||||
/// Function object to find an item at the specified coordinates.
|
||||
class item_at {
|
||||
public:
|
||||
|
@ -344,7 +344,7 @@ private:
|
|||
|
||||
/// Return the width that remain on the line the current input point is at.
|
||||
int get_remaining_width();
|
||||
|
||||
|
||||
/// Return the least x coordinate at which something of the
|
||||
/// specified height can be drawn at the specified y coordinate
|
||||
/// without interfering with floating images.
|
||||
|
@ -437,7 +437,7 @@ std::vector<topic> generate_terrains_topics();
|
|||
|
||||
/// Parse a help config, return the top level section. Return an empty
|
||||
/// section if cfg is NULL.
|
||||
section parse_config(const config *cfg);
|
||||
section parse_config(const config *cfg);
|
||||
/// Recursive function used by parse_config.
|
||||
void parse_config_internal(const config *help_cfg, const config *section_cfg,
|
||||
section &sec, int level=0);
|
||||
|
@ -498,13 +498,13 @@ namespace {
|
|||
const game_data *game_info = NULL;
|
||||
gamemap *map = NULL;
|
||||
// The default toplevel.
|
||||
help::section toplevel;
|
||||
help::section toplevel;
|
||||
// All sections and topics not referenced from the default toplevel.
|
||||
help::section hidden_sections;
|
||||
help::section hidden_sections;
|
||||
|
||||
int last_num_encountered_units = -1;
|
||||
int last_num_encountered_terrains = -1;
|
||||
|
||||
|
||||
config dummy_cfg;
|
||||
std::vector<std::string> empty_string_vector;
|
||||
const int max_section_level = 15;
|
||||
|
@ -518,8 +518,8 @@ namespace {
|
|||
const std::string closed_section_img = "help/closed_section.png";
|
||||
const std::string open_section_img = "help/open_section.png";
|
||||
// The topic to open by default when opening the help dialog.
|
||||
const std::string default_show_topic = "introduction_topic";
|
||||
|
||||
const std::string default_show_topic = "introduction_topic";
|
||||
|
||||
/// Return true if the id is valid for user defined topics and
|
||||
/// sections. Some IDs are special, such as toplevel and may not be
|
||||
/// be defined in the config.
|
||||
|
@ -572,7 +572,7 @@ namespace {
|
|||
ss << "<jump>amount=" << amount << "</jump>";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
std::string bold(const std::string &s)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
@ -585,7 +585,7 @@ namespace {
|
|||
// that create a table. The table spec contains a vector with
|
||||
// vectors with pairs. The pairs are the markup string that should
|
||||
// be in a cell, and the width of that cell.
|
||||
std::string generate_table(const table_spec &tab, const unsigned int spacing=font::relative_size(20))
|
||||
std::string generate_table(const table_spec &tab, const unsigned int spacing=font::relative_size(20))
|
||||
{
|
||||
table_spec::const_iterator row_it;
|
||||
std::vector<std::pair<std::string, unsigned> >::const_iterator col_it;
|
||||
|
@ -628,7 +628,7 @@ namespace {
|
|||
}
|
||||
|
||||
// Return the width for the image with filename.
|
||||
unsigned image_width(const std::string &filename)
|
||||
unsigned image_width(const std::string &filename)
|
||||
{
|
||||
image::locator loc(filename);
|
||||
surface surf(image::get_image(loc, image::UNSCALED));
|
||||
|
@ -775,7 +775,7 @@ bool topic_is_referenced(const std::string &topic_id, const config &cfg)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void parse_config_internal(const config *help_cfg, const config *section_cfg,
|
||||
section &sec, int level)
|
||||
{
|
||||
|
@ -843,9 +843,9 @@ void parse_config_internal(const config *help_cfg, const config *section_cfg,
|
|||
std::copy(generated_topics.begin(), generated_topics.end(),
|
||||
std::back_inserter(sec.topics));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
section parse_config(const config *cfg)
|
||||
section parse_config(const config *cfg)
|
||||
{
|
||||
section sec;
|
||||
if (cfg != NULL) {
|
||||
|
@ -856,7 +856,7 @@ section parse_config(const config *cfg)
|
|||
}
|
||||
|
||||
|
||||
std::vector<section> generate_sections(const std::string &generator)
|
||||
std::vector<section> generate_sections(const std::string &generator)
|
||||
{
|
||||
std::vector<section> empty_vec;
|
||||
if (generator == "") {
|
||||
|
@ -900,7 +900,7 @@ std::string generate_topic_text(const std::string &generator)
|
|||
return empty_string;
|
||||
}
|
||||
|
||||
topic_text::~topic_text()
|
||||
topic_text::~topic_text()
|
||||
{
|
||||
if (generator_ && --generator_->count == 0)
|
||||
delete generator_;
|
||||
|
@ -920,7 +920,7 @@ topic_text &topic_text::operator=(topic_generator *g)
|
|||
return *this;
|
||||
}
|
||||
|
||||
topic_text::operator std::vector< std::string > const &() const
|
||||
topic_text::operator std::vector< std::string > const &() const
|
||||
{
|
||||
if (generator_) {
|
||||
parsed_text_ = parse_text((*generator_)());
|
||||
|
@ -961,7 +961,7 @@ std::vector<topic> generate_weapon_special_topics()
|
|||
const size_t colon_pos = description.find(':');
|
||||
if (colon_pos != std::string::npos) {
|
||||
// Remove the first colon and the following newline.
|
||||
description.erase(0, colon_pos + 2);
|
||||
description.erase(0, colon_pos + 2);
|
||||
}
|
||||
topic t(lang_special, "weaponspecial_" + special, description);
|
||||
topics.push_back(t);
|
||||
|
@ -998,7 +998,7 @@ std::vector<topic> generate_ability_topics()
|
|||
const size_t colon_pos = description.find(':');
|
||||
if (colon_pos != std::string::npos) {
|
||||
// Remove the first colon and the following newline.
|
||||
description.erase(0, colon_pos + 2);
|
||||
description.erase(0, colon_pos + 2);
|
||||
}
|
||||
topic t(lang_ability, id, description);
|
||||
topics.push_back(t);
|
||||
|
@ -1006,7 +1006,7 @@ std::vector<topic> generate_ability_topics()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return topics;
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ public:
|
|||
advance_it != advance_end; ++advance_it) {
|
||||
std::string unit_id = *advance_it;
|
||||
std::map<std::string,unit_type>::const_iterator new_type = game_info->unit_types.find(unit_id);
|
||||
if(new_type != game_info->unit_types.end()) {
|
||||
if(new_type != game_info->unit_types.end()) {
|
||||
std::string lang_unit = new_type->second.language_name();
|
||||
std::string ref_id = std::string("unit_") + new_type->second.id();
|
||||
ss << "<ref>dst='" << escape(ref_id) << "' text='" << escape(lang_unit)
|
||||
|
@ -1212,7 +1212,7 @@ public:
|
|||
std::stringstream str;
|
||||
str << "<ref>text='" << escape(name) << "' dst='"
|
||||
<< escape(std::string("terrain_") + terrain) << "'</ref>";
|
||||
row.push_back(std::make_pair(str.str(),
|
||||
row.push_back(std::make_pair(str.str(),
|
||||
font::line_width(name,
|
||||
normal_font_size)));
|
||||
|
||||
|
@ -1319,7 +1319,7 @@ struct terrain_topic_generator: topic_generator
|
|||
}
|
||||
};
|
||||
|
||||
std::vector<topic> generate_terrains_topics()
|
||||
std::vector<topic> generate_terrains_topics()
|
||||
{
|
||||
std::vector<topic> res;
|
||||
std::vector<gamemap::TERRAIN> show_info_about;
|
||||
|
@ -1418,8 +1418,8 @@ section::~section()
|
|||
std::for_each(sections.begin(), sections.end(), delete_section());
|
||||
}
|
||||
|
||||
section::section(const section &sec)
|
||||
: title(sec.title), id(sec.id), topics(sec.topics)
|
||||
section::section(const section &sec)
|
||||
: title(sec.title), id(sec.id), topics(sec.topics)
|
||||
{
|
||||
std::transform(sec.sections.begin(), sec.sections.end(),
|
||||
std::back_inserter(sections), create_section());
|
||||
|
@ -1434,7 +1434,7 @@ section& section::operator=(const section &sec)
|
|||
std::back_inserter(sections), create_section());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool section::operator==(const section &sec) const
|
||||
{
|
||||
|
@ -1446,7 +1446,7 @@ bool section::operator<(const section &sec) const
|
|||
return id < sec.id;
|
||||
}
|
||||
|
||||
void section::add_section(const section &s)
|
||||
void section::add_section(const section &s)
|
||||
{
|
||||
sections.push_back(new section(s));
|
||||
}
|
||||
|
@ -1460,7 +1460,7 @@ void section::clear()
|
|||
|
||||
help_menu::help_menu(CVideo &video, section const &toplevel, int max_height)
|
||||
: gui::menu(video, empty_string_vector, true, max_height),
|
||||
toplevel_(toplevel), chosen_topic_(NULL), selected_item_(&toplevel, "")
|
||||
toplevel_(toplevel), chosen_topic_(NULL), selected_item_(&toplevel, "")
|
||||
{
|
||||
update_visible_items(toplevel_);
|
||||
display_visible_items();
|
||||
|
@ -1473,19 +1473,19 @@ bool help_menu::expanded(const section &sec)
|
|||
return expanded_.find(&sec) != expanded_.end();
|
||||
}
|
||||
|
||||
void help_menu::expand(const section &sec)
|
||||
void help_menu::expand(const section &sec)
|
||||
{
|
||||
if (sec.id != "toplevel") {
|
||||
expanded_.insert(&sec);
|
||||
}
|
||||
}
|
||||
|
||||
void help_menu::contract(const section &sec)
|
||||
void help_menu::contract(const section &sec)
|
||||
{
|
||||
expanded_.erase(&sec);
|
||||
}
|
||||
|
||||
void help_menu::update_visible_items(const section &sec, unsigned level)
|
||||
void help_menu::update_visible_items(const section &sec, unsigned level)
|
||||
{
|
||||
if (level == 0) {
|
||||
// Clear if this is the top level, otherwise append items.
|
||||
|
@ -1507,7 +1507,7 @@ void help_menu::update_visible_items(const section &sec, unsigned level)
|
|||
}
|
||||
|
||||
|
||||
std::string help_menu::get_string_to_show(const section &sec, const unsigned level)
|
||||
std::string help_menu::get_string_to_show(const section &sec, const unsigned level)
|
||||
{
|
||||
std::stringstream to_show;
|
||||
std::string pad_string;
|
||||
|
@ -1595,7 +1595,7 @@ const topic *help_menu::chosen_topic()
|
|||
chosen_topic_ = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void help_menu::display_visible_items()
|
||||
{
|
||||
std::vector<std::string> menu_items;
|
||||
|
@ -1620,7 +1620,7 @@ bool help_menu::visible_item::operator==(const section &_sec) const
|
|||
return sec != NULL && *sec == _sec;
|
||||
}
|
||||
|
||||
bool help_menu::visible_item::operator==(const topic &_t) const
|
||||
bool help_menu::visible_item::operator==(const topic &_t) const
|
||||
{
|
||||
return t != NULL && *t == _t;
|
||||
}
|
||||
|
@ -1646,14 +1646,14 @@ void help_text_area::set_inner_location(SDL_Rect const &rect)
|
|||
set_items();
|
||||
}
|
||||
|
||||
void help_text_area::show_topic(const topic &t)
|
||||
void help_text_area::show_topic(const topic &t)
|
||||
{
|
||||
shown_topic_ = &t;
|
||||
set_items();
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
help_text_area::item::item(surface surface, int x, int y, const std::string _text,
|
||||
const std::string reference_to, bool _floating,
|
||||
bool _box, ALIGNMENT alignment)
|
||||
|
@ -1895,7 +1895,7 @@ void help_text_area::handle_format_cfg(const config &cfg)
|
|||
|
||||
void help_text_area::add_text_item(const std::string text, const std::string ref_dst,
|
||||
int _font_size, bool bold, bool italic,
|
||||
SDL_Color text_color)
|
||||
SDL_Color text_color)
|
||||
{
|
||||
const int font_size = _font_size < 0 ? normal_font_size : _font_size;
|
||||
if (text.empty())
|
||||
|
@ -1951,7 +1951,7 @@ void help_text_area::add_text_item(const std::string text, const std::string ref
|
|||
s = remove_first_space(s);
|
||||
}
|
||||
add_text_item(s, ref_dst, _font_size, bold, italic, text_color);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2066,8 +2066,8 @@ void help_text_area::add_item(const item &itm)
|
|||
contents_height_ = maximum<int>(contents_height_, itm.rect.y + itm.rect.h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
help_text_area::ALIGNMENT help_text_area::str_to_align(const std::string &s)
|
||||
{
|
||||
const std::string cmp_str = to_lower(s);
|
||||
|
@ -2084,7 +2084,7 @@ help_text_area::ALIGNMENT help_text_area::str_to_align(const std::string &s)
|
|||
msg << "Invalid alignment string: '" << s << "'";
|
||||
throw parse_error(msg.str());
|
||||
}
|
||||
|
||||
|
||||
void help_text_area::down_one_line()
|
||||
{
|
||||
adjust_last_row();
|
||||
|
@ -2172,7 +2172,7 @@ help_browser::help_browser(display &disp, const section &toplevel)
|
|||
text_area_(disp.video(), toplevel), toplevel_(toplevel), ref_cursor_(false),
|
||||
back_button_(disp.video(), _("< Back"), gui::button::TYPE_PRESS),
|
||||
forward_button_(disp.video(), _("Forward >"), gui::button::TYPE_PRESS),
|
||||
shown_topic_(NULL)
|
||||
shown_topic_(NULL)
|
||||
{
|
||||
// Hide the buttons at first since we do not have any forward or
|
||||
// back topics at this point. They will be unhidden when history
|
||||
|
@ -2183,7 +2183,7 @@ help_browser::help_browser(display &disp, const section &toplevel)
|
|||
set_measurements(font::relative_size(400), font::relative_size(500));
|
||||
}
|
||||
|
||||
void help_browser::adjust_layout()
|
||||
void help_browser::adjust_layout()
|
||||
{
|
||||
const int menu_buttons_padding = font::relative_size(10);
|
||||
const int menu_y = location().y;
|
||||
|
@ -2194,7 +2194,7 @@ void help_browser::adjust_layout()
|
|||
const int menu_w = 250;
|
||||
#endif
|
||||
const int menu_h = height() - back_button_.height() - menu_buttons_padding;
|
||||
|
||||
|
||||
const int menu_text_area_padding = font::relative_size(10);
|
||||
const int text_area_y = location().y;
|
||||
const int text_area_x = menu_x + menu_w + menu_text_area_padding;
|
||||
|
@ -2254,7 +2254,7 @@ void help_browser::process_event()
|
|||
}
|
||||
|
||||
void help_browser::move_in_history(std::deque<const topic *> &from,
|
||||
std::deque<const topic *> &to)
|
||||
std::deque<const topic *> &to)
|
||||
{
|
||||
if (!from.empty()) {
|
||||
const topic *to_show = from.back();
|
||||
|
@ -2293,7 +2293,7 @@ void help_browser::handle_event(const SDL_Event &event)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.type == SDL_MOUSEMOTION) {
|
||||
update_cursor();
|
||||
}
|
||||
|
@ -2332,7 +2332,7 @@ const topic *find_topic(const section &sec, const std::string &id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const section *find_section(const section &sec, const std::string &id)
|
||||
const section *find_section(const section &sec, const std::string &id)
|
||||
{
|
||||
section_list::const_iterator sit =
|
||||
std::find_if(sec.sections.begin(), sec.sections.end(), has_id(id));
|
||||
|
@ -2512,7 +2512,7 @@ bool get_bool(const std::string &s)
|
|||
return false;
|
||||
}
|
||||
|
||||
SDL_Color string_to_color(const std::string &s)
|
||||
SDL_Color string_to_color(const std::string &s)
|
||||
{
|
||||
const std::string cmp_str = to_lower(s);
|
||||
if (cmp_str == "green") {
|
||||
|
@ -2574,8 +2574,8 @@ std::string escape(const std::string &s)
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string get_first_word(const std::string &s)
|
||||
|
||||
std::string get_first_word(const std::string &s)
|
||||
{
|
||||
if (s == "") {
|
||||
return s;
|
||||
|
@ -2652,7 +2652,7 @@ void show_help(display &disp, const section &toplevel_sec, const std::string sho
|
|||
// of the screen.
|
||||
if (yloc <= -1 || xloc <= -1) {
|
||||
xloc = scr->w / 2 - width / 2;
|
||||
yloc = scr->h / 2 - height / 2;
|
||||
yloc = scr->h / 2 - height / 2;
|
||||
}
|
||||
std::vector<gui::button*> buttons_ptr;
|
||||
gui::button close_button_(disp.video(), _("Close"));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -117,7 +117,7 @@ hotkey::hotkey_item null_hotkey_;
|
|||
|
||||
namespace hotkey {
|
||||
|
||||
hotkey_item::hotkey_item(HOTKEY_COMMAND id, const std::string& command, const std::string& description, bool hidden)
|
||||
hotkey_item::hotkey_item(HOTKEY_COMMAND id, const std::string& command, const std::string& description, bool hidden)
|
||||
: id_(id), command_(command), description_(description), keycode_(0),
|
||||
shift_(false), ctrl_(false), alt_(false), cmd_(false), hidden_(hidden)
|
||||
{
|
||||
|
@ -146,10 +146,10 @@ void hotkey_item::load_from_config(const config& cfg)
|
|||
cmd_ = (cfg["cmd"] == "yes");
|
||||
}
|
||||
|
||||
std::string hotkey_item::get_name() const
|
||||
std::string hotkey_item::get_name() const
|
||||
{
|
||||
if (keycode_ != 0) {
|
||||
std::stringstream str;
|
||||
std::stringstream str;
|
||||
if (alt_)
|
||||
str << "alt+";
|
||||
if (ctrl_)
|
||||
|
@ -180,10 +180,10 @@ void hotkey_item::set_key(int keycode, bool shift, bool ctrl, bool alt, bool cmd
|
|||
cmd_ = cmd;
|
||||
}
|
||||
|
||||
manager::manager()
|
||||
manager::manager()
|
||||
{
|
||||
for (int i = 0; hotkey_list_[i].command; ++i) {
|
||||
hotkeys_.push_back(hotkey_item(hotkey_list_[i].id, hotkey_list_[i].command,
|
||||
hotkeys_.push_back(hotkey_item(hotkey_list_[i].id, hotkey_list_[i].command,
|
||||
"", hotkey_list_[i].hidden));
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ void save_hotkeys(config& cfg)
|
|||
}
|
||||
}
|
||||
|
||||
hotkey_item& get_hotkey(HOTKEY_COMMAND id)
|
||||
hotkey_item& get_hotkey(HOTKEY_COMMAND id)
|
||||
{
|
||||
std::vector<hotkey_item>::iterator itor;
|
||||
|
||||
|
@ -250,7 +250,7 @@ hotkey_item& get_hotkey(HOTKEY_COMMAND id)
|
|||
return *itor;
|
||||
}
|
||||
|
||||
hotkey_item& get_hotkey(const std::string& command)
|
||||
hotkey_item& get_hotkey(const std::string& command)
|
||||
{
|
||||
std::vector<hotkey_item>::iterator itor;
|
||||
|
||||
|
@ -272,17 +272,17 @@ hotkey_item& get_hotkey(int keycode, bool shift, bool ctrl, bool alt, bool cmd,
|
|||
|
||||
for (itor = hotkeys_.begin(); itor != hotkeys_.end(); ++itor) {
|
||||
if(mods) {
|
||||
if(itor->get_keycode() == keycode
|
||||
if(itor->get_keycode() == keycode
|
||||
&& (shift == itor->get_shift() || shift == true)
|
||||
&& (ctrl == itor->get_ctrl() || ctrl == true)
|
||||
&& (alt == itor->get_alt() || alt == true)
|
||||
&& (cmd == itor->get_cmd() || cmd == true))
|
||||
break;
|
||||
} else {
|
||||
if(itor->get_keycode() == keycode
|
||||
&& shift == itor->get_shift()
|
||||
&& ctrl == itor->get_ctrl()
|
||||
&& alt == itor->get_alt()
|
||||
if(itor->get_keycode() == keycode
|
||||
&& shift == itor->get_shift()
|
||||
&& ctrl == itor->get_ctrl()
|
||||
&& alt == itor->get_alt()
|
||||
&& cmd == itor->get_cmd())
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -28,7 +28,7 @@ class display;
|
|||
namespace hotkey {
|
||||
|
||||
enum HOTKEY_COMMAND {
|
||||
HOTKEY_CYCLE_UNITS,HOTKEY_CYCLE_BACK_UNITS, HOTKEY_UNIT_HOLD_POSITION,
|
||||
HOTKEY_CYCLE_UNITS,HOTKEY_CYCLE_BACK_UNITS, HOTKEY_UNIT_HOLD_POSITION,
|
||||
HOTKEY_END_UNIT_TURN, HOTKEY_LEADER,
|
||||
HOTKEY_UNDO, HOTKEY_REDO,
|
||||
HOTKEY_ZOOM_IN, HOTKEY_ZOOM_OUT, HOTKEY_ZOOM_DEFAULT,
|
||||
|
@ -45,7 +45,7 @@ enum HOTKEY_COMMAND {
|
|||
|
||||
//editing specific commands
|
||||
HOTKEY_EDIT_SET_TERRAIN,
|
||||
HOTKEY_EDIT_QUIT, HOTKEY_EDIT_SAVE_MAP,
|
||||
HOTKEY_EDIT_QUIT, HOTKEY_EDIT_SAVE_MAP,
|
||||
HOTKEY_EDIT_SAVE_AS, HOTKEY_EDIT_SET_START_POS,
|
||||
HOTKEY_EDIT_NEW_MAP, HOTKEY_EDIT_LOAD_MAP, HOTKEY_EDIT_FLOOD_FILL,
|
||||
HOTKEY_EDIT_FILL_SELECTION, HOTKEY_EDIT_CUT, HOTKEY_EDIT_COPY,
|
||||
|
@ -53,7 +53,7 @@ enum HOTKEY_COMMAND {
|
|||
HOTKEY_EDIT_FLIP, HOTKEY_EDIT_SELECT_ALL, HOTKEY_EDIT_DRAW,
|
||||
HOTKEY_EDIT_REFRESH,
|
||||
HOTKEY_USER_CMD,
|
||||
HOTKEY_NULL
|
||||
HOTKEY_NULL
|
||||
};
|
||||
|
||||
class hotkey_item {
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
bool get_ctrl() const { return ctrl_; };
|
||||
bool get_shift() const { return shift_; };
|
||||
bool get_cmd() const { return cmd_; };
|
||||
|
||||
|
||||
// Return "name" of hotkey for example :"ctrl+alt+g"
|
||||
std::string get_name() const;
|
||||
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
virtual ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command) const { return ACTION_STATELESS; }
|
||||
//Returns the appropriate menu image. Checkable items will get a checked/unchecked image.
|
||||
std::string get_menu_image(hotkey::HOTKEY_COMMAND command) const;
|
||||
|
||||
|
||||
virtual bool can_execute_command(HOTKEY_COMMAND command) const = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ void locator::init_index()
|
|||
}
|
||||
}
|
||||
|
||||
locator::locator() :
|
||||
locator::locator() :
|
||||
index_(-1)
|
||||
{
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ locator::locator(const locator &a):
|
|||
{
|
||||
}
|
||||
|
||||
locator::locator(const char *filename) :
|
||||
locator::locator(const char *filename) :
|
||||
val_(filename)
|
||||
{
|
||||
init_index();
|
||||
|
@ -169,7 +169,7 @@ locator::value::value(const std::string& filename, const gamemap::location& loc)
|
|||
{
|
||||
}
|
||||
|
||||
bool locator::value::operator==(const value& a) const
|
||||
bool locator::value::operator==(const value& a) const
|
||||
{
|
||||
if(a.type_ != type_) {
|
||||
return false;
|
||||
|
@ -226,18 +226,18 @@ surface locator::load_image_sub_file() const
|
|||
{
|
||||
const surface mother_surface(get_image(val_.filename_, UNSCALED, NO_ADJUST_COLOUR));
|
||||
const surface mask(get_image(game_config::terrain_mask_image, UNSCALED, NO_ADJUST_COLOUR));
|
||||
|
||||
|
||||
if(mother_surface == NULL)
|
||||
return surface(NULL);
|
||||
if(mask == NULL)
|
||||
return surface(NULL);
|
||||
|
||||
SDL_Rect srcrect = {
|
||||
|
||||
SDL_Rect srcrect = {
|
||||
((tile_size*3) / 4) * val_.loc_.x,
|
||||
tile_size * val_.loc_.y + (tile_size/2) * (val_.loc_.x % 2),
|
||||
tile_size, tile_size
|
||||
tile_size * val_.loc_.y + (tile_size/2) * (val_.loc_.x % 2),
|
||||
tile_size, tile_size
|
||||
};
|
||||
|
||||
|
||||
surface tmp(cut_surface(mother_surface, srcrect));
|
||||
surface surf(mask_surface(tmp, mask));
|
||||
|
||||
|
@ -435,11 +435,11 @@ surface get_scaled(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
|||
surface res(get_image(i_locator, UNMASKED, adj));
|
||||
|
||||
// Adjusts colour if necessary.
|
||||
if(adj == ADJUST_COLOUR && (red_adjust != 0 ||
|
||||
if(adj == ADJUST_COLOUR && (red_adjust != 0 ||
|
||||
green_adjust != 0 || blue_adjust != 0)) {
|
||||
res = surface(adjust_surface_colour(res,
|
||||
red_adjust, green_adjust, blue_adjust));
|
||||
}
|
||||
}
|
||||
|
||||
const surface mask(get_image(image_mask,UNMASKED,NO_ADJUST_COLOUR));
|
||||
if(mask != NULL) {
|
||||
|
@ -455,7 +455,7 @@ surface get_scaled(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
|||
surface get_greyed(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
{
|
||||
surface image(get_image(i_locator, SCALED, adj));
|
||||
|
||||
|
||||
return surface(greyscale_image(image));
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ surface get_image(const image::locator& i_locator, TYPE type, COLOUR_ADJUSTMENT
|
|||
default:
|
||||
return surface(NULL);
|
||||
}
|
||||
|
||||
|
||||
if(i_locator.in_cache(*imap))
|
||||
return i_locator.locate_in_cache(*imap);
|
||||
|
||||
|
@ -605,7 +605,7 @@ locator get_alternative(const image::locator &i_locator, const std::string &alt)
|
|||
default:
|
||||
wassert(false);
|
||||
}
|
||||
|
||||
|
||||
i_locator.add_to_cache(alternative_images_, res);
|
||||
|
||||
return res;
|
||||
|
@ -622,7 +622,7 @@ bool exists(const image::locator& i_locator)
|
|||
{
|
||||
typedef image::locator loc;
|
||||
loc::type type = i_locator.get_type();
|
||||
if (type != loc::FILE && type != loc::SUB_FILE)
|
||||
if (type != loc::FILE && type != loc::SUB_FILE)
|
||||
return false;
|
||||
|
||||
// the insertion will fail if there is already an element in the cache
|
||||
|
@ -663,7 +663,7 @@ surface getMinimap(int w, int h, const gamemap& map, const team* tm)
|
|||
for(int x = 0; x != map.x(); ++x) {
|
||||
|
||||
surface surf(NULL);
|
||||
|
||||
|
||||
const gamemap::location loc(x,y);
|
||||
if(map.on_board(loc)) {
|
||||
const bool shrouded = tm != NULL && tm->shrouded(x,y);
|
||||
|
@ -696,7 +696,7 @@ surface getMinimap(int w, int h, const gamemap& map, const team* tm)
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace image {
|
|||
value(const char *filename);
|
||||
value(const std::string& filename);
|
||||
value(const std::string& filename, const gamemap::location& loc);
|
||||
|
||||
|
||||
bool operator==(const value& a) const;
|
||||
bool operator<(const value& a) const;
|
||||
|
||||
|
@ -75,11 +75,11 @@ namespace image {
|
|||
// const int get_index() const { return index_; };
|
||||
|
||||
// returns true if the locator does not correspond to any
|
||||
// actual image
|
||||
// actual image
|
||||
bool is_void() const { return val_.type_ == NONE; }
|
||||
// loads the image it is pointing to from the disk
|
||||
surface load_from_disk() const;
|
||||
|
||||
|
||||
#if 0
|
||||
// returns true if the locator already was stored in the given
|
||||
// cache
|
||||
|
@ -118,7 +118,7 @@ namespace image {
|
|||
|
||||
///the image manager is responsible for setting up images, and destroying
|
||||
///all images when the program exits. It should probably
|
||||
///be created once for the life of the program
|
||||
///be created once for the life of the program
|
||||
struct manager
|
||||
{
|
||||
manager();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -222,11 +222,11 @@ bool show_intro_part(display &disp, const config& part,
|
|||
bool skip = false, last_key = true;
|
||||
|
||||
int xpos = textx, ypos = texty;
|
||||
|
||||
|
||||
//the maximum position that text can reach before wrapping
|
||||
const int max_xpos = next_button.location().x - 10;
|
||||
size_t height = 0;
|
||||
|
||||
|
||||
for(;;) {
|
||||
if(itor != utils::utf8_iterator::end(story)) {
|
||||
if(*itor == ' ') {
|
||||
|
@ -269,7 +269,7 @@ bool show_intro_part(display &disp, const config& part,
|
|||
|
||||
if(rect.h > height)
|
||||
height = rect.h;
|
||||
xpos += rect.w;
|
||||
xpos += rect.w;
|
||||
update_rect(rect);
|
||||
|
||||
++itor;
|
||||
|
@ -301,7 +301,7 @@ bool show_intro_part(display &disp, const config& part,
|
|||
if(!skip || itor == utils::utf8_iterator::end(story))
|
||||
SDL_Delay(20);
|
||||
}
|
||||
|
||||
|
||||
draw_solid_tinted_rectangle(0,0,video.getx()-1,video.gety()-1,0,0,0,1.0,
|
||||
video.getSurface());
|
||||
|
||||
|
@ -319,7 +319,7 @@ void the_end(display &disp)
|
|||
|
||||
const std::string text = _("The End");
|
||||
const size_t font_size = font::SIZE_XLARGE;
|
||||
|
||||
|
||||
area = font::text_area(text,font_size);
|
||||
area.x = screen_area().w/2 - area.w/2;
|
||||
area.y = screen_area().h/2 - area.h/2;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* $Id$ */
|
||||
/* vim:set encoding=utf-8: */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -135,7 +135,7 @@ static void wesnoth_setlocale(int category, std::string const &slocale)
|
|||
std::cerr << "setenv LANGUAGE failed: " << strerror(errno);
|
||||
if(setenv ("LC_ALL", locale, 1) == -1)
|
||||
std::cerr << "setenv LC_ALL failed: " << strerror(errno);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
const std::string env = "LANG=" + slocale;
|
||||
|
@ -194,7 +194,7 @@ bool set_language(const language_def& locale)
|
|||
|
||||
config* langp = cfg.child("language");
|
||||
if (langp == NULL) {
|
||||
std::cerr << "No [language] block found in english.cfg\n";
|
||||
std::cerr << "No [language] block found in english.cfg\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -216,8 +216,8 @@ const language_def& get_locale()
|
|||
if(prefs_locale.empty() == false) {
|
||||
wesnoth_setlocale(LC_MESSAGES, prefs_locale);
|
||||
for(int i = 0; known_languages[i].language[0] != '\0'; i++) {
|
||||
if (prefs_locale == known_languages[i].localename)
|
||||
return known_languages[i];
|
||||
if (prefs_locale == known_languages[i].localename)
|
||||
return known_languages[i];
|
||||
}
|
||||
std::cerr << "locale not found in known array; defaulting to system locale\n";
|
||||
return known_languages[0];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -29,7 +29,7 @@ struct language_def
|
|||
language_def(const std::string& name, const std::string& lang) : localename(name), language(lang)
|
||||
{}
|
||||
std::string localename;
|
||||
std::string language;
|
||||
std::string language;
|
||||
bool operator== (const language_def&);
|
||||
};
|
||||
extern language_def known_languages[];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -60,7 +60,7 @@ void leader_list_manager::update_leader_list(int side_index)
|
|||
if(!side["leader"].empty()) {
|
||||
leaders_ = utils::split(side["leader"]);
|
||||
}
|
||||
|
||||
|
||||
const std::string default_leader = side["type"];
|
||||
size_t default_index = 0;
|
||||
|
||||
|
@ -80,7 +80,7 @@ void leader_list_manager::update_leader_list(int side_index)
|
|||
std::vector<std::string> leader_strings;
|
||||
|
||||
for(itor = leaders_.begin(); itor != leaders_.end(); ++itor) {
|
||||
|
||||
|
||||
const game_data::unit_type_map& utypes = data_->unit_types;
|
||||
|
||||
//const std::string name = data_->unit_types->find(*itor).language_name();
|
||||
|
@ -112,7 +112,7 @@ void leader_list_manager::set_leader(const std::string& leader)
|
|||
int leader_index = 0;
|
||||
for(std::vector<std::string>::const_iterator itor = leaders_.begin();
|
||||
itor != leaders_.end(); ++itor) {
|
||||
if (leader == *itor)
|
||||
if (leader == *itor)
|
||||
combo_->set_selected(leader_index);
|
||||
++leader_index;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
14
src/map.cpp
14
src/map.cpp
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -148,10 +148,10 @@ gamemap::location gamemap::location::operator+(const gamemap::location& a) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
gamemap::location& gamemap::location::operator+=(const gamemap::location &a)
|
||||
gamemap::location& gamemap::location::operator+=(const gamemap::location &a)
|
||||
{
|
||||
bool parity = (x & 1) != 0;
|
||||
|
||||
|
||||
x += a.x;
|
||||
y += a.y;
|
||||
|
||||
|
@ -343,7 +343,7 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, const int xpos,
|
|||
startingPositions_[pos - m.startingPositions_] = *pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int gamemap::x() const { return tiles_.size(); }
|
||||
|
@ -366,7 +366,7 @@ gamemap::TERRAIN gamemap::get_terrain(const gamemap::location& loc) const
|
|||
//if not on the board, decide based on what surrounding terrain is
|
||||
TERRAIN items[6];
|
||||
int nitems = 0;
|
||||
|
||||
|
||||
location adj[6];
|
||||
get_adjacent_tiles(loc,adj);
|
||||
for(int n = 0; n != 6; ++n) {
|
||||
|
@ -482,7 +482,7 @@ void gamemap::set_terrain(const gamemap::location& loc, gamemap::TERRAIN ter)
|
|||
location adj[6];
|
||||
get_adjacent_tiles(loc,adj);
|
||||
|
||||
for(int n = 0; n < 6; ++n)
|
||||
for(int n = 0; n < 6; ++n)
|
||||
remove_from_border_cache(adj[n]);
|
||||
}
|
||||
|
||||
|
|
10
src/map.hpp
10
src/map.hpp
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -65,9 +65,9 @@ public:
|
|||
void write(config& cfg) const;
|
||||
|
||||
inline bool valid() const { return x >= 0 && y >= 0; }
|
||||
|
||||
|
||||
inline bool valid(const int parWidth, const int parHeight) const
|
||||
{
|
||||
{
|
||||
return ((x >= 0) && (y >= 0) && (x < parWidth) && (y < parHeight));
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
|
||||
//shortcut to get_terrain_info(get_terrain(loc))
|
||||
const terrain_type& get_terrain_info(const location &loc) const;
|
||||
|
||||
|
||||
//gets the list of terrains
|
||||
const std::vector<TERRAIN>& get_terrain_list() const;
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ bool generate_river_internal(const height_map& heights, terrain_map& terrain, in
|
|||
if(on_map && !river.empty() && heights[x][y] > heights[river.back().x][river.back().y] + river_uphill) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//if we're at the end of the river
|
||||
if(!on_map || terrain[x][y] == 'c' || terrain[x][y] == 's') {
|
||||
LOG_NG << "generating river...\n";
|
||||
|
@ -229,7 +229,7 @@ bool generate_river_internal(const height_map& heights, terrain_map& terrain, in
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
location current_loc(x,y);
|
||||
location adj[6];
|
||||
get_adjacent_tiles(current_loc,adj);
|
||||
|
@ -440,7 +440,7 @@ int rank_castle_location(int x, int y, const is_valid_terrain& valid_terrain, in
|
|||
}
|
||||
|
||||
int surrounding_ranking = 0;
|
||||
|
||||
|
||||
for(int xpos = x-5; xpos <= x+5; ++xpos) {
|
||||
for(int ypos = y-5; ypos <= y+5; ++ypos) {
|
||||
if(valid_terrain(xpos,ypos)) {
|
||||
|
@ -491,7 +491,7 @@ gamemap::location place_village(const std::vector<std::vector<gamemap::TERRAIN>
|
|||
return best_loc;
|
||||
}
|
||||
|
||||
std::string generate_name(const unit_race& name_generator, const std::string& id,
|
||||
std::string generate_name(const unit_race& name_generator, const std::string& id,
|
||||
std::string* base_name=NULL,
|
||||
utils::string_map* additional_symbols=NULL)
|
||||
{
|
||||
|
@ -627,7 +627,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
|
|||
//the map, same for roads, etc etc)
|
||||
width *= 3;
|
||||
height *= 3;
|
||||
|
||||
|
||||
LOG_NG << "generating height map...\n";
|
||||
//generate the height of everything.
|
||||
const height_map heights = generate_height_map(width,height,iterations,hill_size,island_size,island_off_center);
|
||||
|
@ -687,7 +687,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
|
|||
const int y = rand()%height;
|
||||
if(heights[x][y] > atoi(cfg["min_lake_height"].c_str())) {
|
||||
const std::vector<location> river = generate_river(heights,terrain,x,y,atoi(cfg["river_frequency"].c_str()));
|
||||
|
||||
|
||||
if(river.empty() == false && labels != NULL) {
|
||||
std::string base_name;
|
||||
LOG_NG << "generating name for river...\n";
|
||||
|
@ -952,12 +952,12 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
|
|||
if(last == adj[0] && next == adj[3] || last == adj[3] && next == adj[0]) {
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
|
||||
//if we are going south west-north east
|
||||
else if(last == adj[1] && next == adj[4] || last == adj[4] && next == adj[1]) {
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
|
||||
//if we are going south east-north west
|
||||
else if(last == adj[2] && next == adj[5] || last == adj[5] && next == adj[2]) {
|
||||
direction = 2;
|
||||
|
@ -1048,7 +1048,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
|
|||
//first we work out the size of the x and y distance between villages
|
||||
const size_t tiles_per_village = ((width*height)/9)/nvillages;
|
||||
size_t village_x = 1, village_y = 1;
|
||||
|
||||
|
||||
//alternate between incrementing the x and y value. When they are high enough
|
||||
//to equal or exceed the tiles_per_village, then we have them to the value
|
||||
//we want them at.
|
||||
|
@ -1061,18 +1061,18 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
|
|||
}
|
||||
|
||||
std::set<std::string> used_names;
|
||||
|
||||
|
||||
for(size_t vx = 0; vx < width; vx += village_x) {
|
||||
LOG_NG << "village at " << vx << "\n";
|
||||
for(size_t vy = rand()%village_y; vy < height; vy += village_y) {
|
||||
|
||||
|
||||
const size_t add_x = rand()%3;
|
||||
const size_t add_y = rand()%3;
|
||||
const size_t x = (vx + add_x) - 1;
|
||||
const size_t y = (vy + add_y) - 1;
|
||||
|
||||
|
||||
const gamemap::location res = place_village(terrain,x,y,2,cfg);
|
||||
|
||||
|
||||
if(res.x >= width/3 && res.x < (width*2)/3 && res.y >= height/3 && res.y < (height*2)/3) {
|
||||
const std::string str(1,terrain[res.x][res.y]);
|
||||
const config* const child = cfg.find_child("village","terrain",str);
|
||||
|
@ -1116,7 +1116,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
|
|||
name_type = "village_name_lake";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
const gamemap::TERRAIN terr = terrain[adj[n].x+width/3][adj[n].y+height/3];
|
||||
|
||||
if(std::count(field.begin(),field.end(),terr) > 0) {
|
||||
|
|
|
@ -111,7 +111,7 @@ void default_map_generator::user_config(display& disp)
|
|||
hillsize_rect.x = text_right - hillsize_rect.w;
|
||||
villages_rect.x = text_right - villages_rect.w;
|
||||
landform_rect.x = text_right - landform_rect.w;
|
||||
|
||||
|
||||
const int vertical_margin = 20;
|
||||
players_rect.y = ypos + vertical_margin*2;
|
||||
width_rect.y = players_rect.y + players_rect.h + vertical_margin;
|
||||
|
@ -138,7 +138,7 @@ void default_map_generator::user_config(display& disp)
|
|||
const int max_width = 100;
|
||||
const int max_height = 100;
|
||||
const int extra_size_per_player = 2;
|
||||
|
||||
|
||||
slider_rect.y = width_rect.y;
|
||||
gui::slider width_slider(screen);
|
||||
width_slider.set_location(slider_rect);
|
||||
|
@ -250,7 +250,7 @@ void default_map_generator::user_config(display& disp)
|
|||
height_str << height_;
|
||||
font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,height_str.str(),
|
||||
slider_right+horz_margin,height_rect.y);
|
||||
|
||||
|
||||
std::stringstream villages_str;
|
||||
villages_str << nvillages_ << _("/1000 tiles");
|
||||
font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,villages_str.str(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -34,9 +34,9 @@ void scroll_dec() { --scrollamount_; }
|
|||
|
||||
// Scrolling DOWN or RIGHT
|
||||
void scroll_inc() { ++scrollamount_; }
|
||||
|
||||
|
||||
// Reducing scroll amount
|
||||
void scroll_reduce() {
|
||||
void scroll_reduce() {
|
||||
if(scrollamount_ > 0) {
|
||||
--scrollamount_;
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -103,14 +103,14 @@ server_type open_connection(display& disp, const std::string& original_host)
|
|||
const int pos = h.find_first_of(":");
|
||||
std::string host;
|
||||
unsigned int port;
|
||||
|
||||
if(pos == -1) {
|
||||
|
||||
if(pos == -1) {
|
||||
host = h;
|
||||
port = 15000;
|
||||
} else {
|
||||
} else {
|
||||
host = h.substr(0, pos);
|
||||
port = lexical_cast_default<unsigned int>(h.substr(pos + 1), 15000);
|
||||
}
|
||||
}
|
||||
|
||||
// shown_hosts is used to prevent the client being locked in a redirect
|
||||
// loop.
|
||||
|
@ -142,7 +142,7 @@ server_type open_connection(display& disp, const std::string& original_host)
|
|||
const std::string errorstring = vgettext("The server requires version '$version1' while you are using version '$version2'", i18n_symbols);
|
||||
throw network::error(errorstring);
|
||||
}
|
||||
|
||||
|
||||
// Check for "redirect" messages
|
||||
if(data.child("redirect")) {
|
||||
config* redirect = data.child("redirect");
|
||||
|
@ -181,7 +181,7 @@ server_type open_connection(display& disp, const std::string& original_host)
|
|||
|
||||
std::string login = preferences::login();
|
||||
|
||||
if(!first_time) {
|
||||
if(!first_time) {
|
||||
const int res = gui::show_dialog(disp, NULL, "",
|
||||
_("You must log in to this server"), gui::OK_CANCEL,
|
||||
NULL, NULL, _("Login: "), &login);
|
||||
|
@ -242,7 +242,7 @@ void enter_wait_mode(display& disp, const config& game_config, game_data& data,
|
|||
|
||||
{
|
||||
mp::wait ui(disp, game_config, data, chat, gamelist);
|
||||
|
||||
|
||||
ui.join_game(observe);
|
||||
|
||||
run_lobby_loop(disp, ui);
|
||||
|
@ -267,14 +267,14 @@ void enter_wait_mode(display& disp, const config& game_config, game_data& data,
|
|||
}
|
||||
}
|
||||
|
||||
void enter_connect_mode(display& disp, const config& game_config, game_data& data,
|
||||
void enter_connect_mode(display& disp, const config& game_config, game_data& data,
|
||||
mp::chat& chat, config& gamelist, const mp::create::parameters& params,
|
||||
mp::controller default_controller, bool is_server)
|
||||
{
|
||||
mp::ui::result res;
|
||||
game_state state;
|
||||
const network::manager net_manager;
|
||||
const network::server_manager serv_manager(15000, is_server ?
|
||||
const network::server_manager serv_manager(15000, is_server ?
|
||||
network::server_manager::TRY_CREATE_SERVER :
|
||||
network::server_manager::NO_SERVER);
|
||||
network_game_manager m;
|
||||
|
@ -289,7 +289,7 @@ void enter_connect_mode(display& disp, const config& game_config, game_data& dat
|
|||
res = ui.get_result();
|
||||
|
||||
// start_game() updates the parameters to reflect game start,
|
||||
// so it must be called before get_level()
|
||||
// so it must be called before get_level()
|
||||
if (res == mp::ui::PLAY) {
|
||||
ui.start_game();
|
||||
state = ui.get_state();
|
||||
|
@ -330,7 +330,7 @@ void enter_create_mode(display& disp, const config& game_config, game_data& data
|
|||
}
|
||||
}
|
||||
|
||||
void enter_lobby_mode(display& disp, const config& game_config, game_data& data, mp::chat& chat, config& gamelist)
|
||||
void enter_lobby_mode(display& disp, const config& game_config, game_data& data, mp::chat& chat, config& gamelist)
|
||||
{
|
||||
mp::ui::result res;
|
||||
|
||||
|
@ -364,7 +364,7 @@ void enter_lobby_mode(display& disp, const config& game_config, game_data& data,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
namespace mp {
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace mp {
|
|||
|
||||
/** Starts a multiplayer game in server mode, or in single-user mode.
|
||||
*
|
||||
* @param disp The global display
|
||||
* @param disp The global display
|
||||
* @param game_config The global, top-level WML configuration for the game
|
||||
* @param data The global game data (unit types, etc)
|
||||
* @param default_controller The default controller type
|
||||
|
@ -38,12 +38,12 @@ void start_server(display& disp, const config& game_config, game_data& data,
|
|||
|
||||
/** Starts a multiplayer game in client mode.
|
||||
*
|
||||
* @param disp The global display
|
||||
* @param disp The global display
|
||||
* @param game_config The global, top-level WML configuration for the game
|
||||
* @param data The global game data (unit types, etc)
|
||||
* @param host The host to connect to.
|
||||
*/
|
||||
void start_client(display& disp, const config& game_config, game_data& data,
|
||||
void start_client(display& disp, const config& game_config, game_data& data,
|
||||
const std::string host);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -51,7 +51,7 @@ connect::side::side(connect& parent, const config& cfg, int index) :
|
|||
player_number_(parent.video(), lexical_cast_default<std::string>(index+1, ""),
|
||||
font::SIZE_LARGE, font::LOBBY_COLOUR),
|
||||
combo_controller_(parent.disp(), parent.player_types_),
|
||||
orig_controller_(parent.video(), cfg["description"], font::SIZE_SMALL),
|
||||
orig_controller_(parent.video(), cfg["description"], font::SIZE_SMALL),
|
||||
combo_faction_(parent.disp(), parent.player_factions_),
|
||||
combo_leader_(parent.disp(), std::vector<std::string>()),
|
||||
combo_team_(parent.disp(), parent.player_teams_),
|
||||
|
@ -72,7 +72,7 @@ connect::side::side(connect& parent, const config& cfg, int index) :
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
slider_gold_.set_min(20);
|
||||
slider_gold_.set_max(1000);
|
||||
slider_gold_.set_increment(25);
|
||||
|
@ -121,7 +121,7 @@ connect::side::side(connect& parent, const config& cfg, int index) :
|
|||
if(leader_type.empty()) {
|
||||
leader_name_pseudolist.push_back("-");
|
||||
} else {
|
||||
game_data::unit_type_map::const_iterator leader_name =
|
||||
game_data::unit_type_map::const_iterator leader_name =
|
||||
parent_->game_data_.unit_types.find(leader_type);
|
||||
if(leader_name == parent_->game_data_.unit_types.end()) {
|
||||
leader_name_pseudolist.push_back("-");
|
||||
|
@ -137,8 +137,8 @@ connect::side::side(connect& parent, const config& cfg, int index) :
|
|||
}
|
||||
|
||||
connect::side::side(const side& a) :
|
||||
parent_(a.parent_), cfg_(a.cfg_),
|
||||
index_(a.index_), id_(a.id_), save_id_(a.save_id_),
|
||||
parent_(a.parent_), cfg_(a.cfg_),
|
||||
index_(a.index_), id_(a.id_), save_id_(a.save_id_),
|
||||
controller_(a.controller_),
|
||||
faction_(a.faction_), team_(a.team_), colour_(a.colour_),
|
||||
gold_(a.gold_), leader_(a.leader_), /* taken_(a.taken_), */
|
||||
|
@ -146,14 +146,14 @@ connect::side::side(const side& a) :
|
|||
orig_controller_(a.orig_controller_),
|
||||
combo_faction_(a.combo_faction_), combo_leader_(a.combo_leader_),
|
||||
combo_team_(a.combo_team_), combo_colour_(a.combo_colour_),
|
||||
slider_gold_(a.slider_gold_), label_gold_(a.label_gold_),
|
||||
slider_gold_(a.slider_gold_), label_gold_(a.label_gold_),
|
||||
enabled_(a.enabled_), changed_(a.changed_), llm_(a.llm_)
|
||||
{
|
||||
llm_.set_combo(enabled_ ? &combo_leader_ : NULL);
|
||||
}
|
||||
|
||||
void connect::side::add_widgets_to_scrollpane(gui::scrollpane& pane, int pos)
|
||||
{
|
||||
{
|
||||
pane.add_widget(&player_number_, 0, 5 + pos);
|
||||
pane.add_widget(&combo_controller_, 20, 5 + pos);
|
||||
pane.add_widget(&orig_controller_, 20 + (combo_controller_.width() - orig_controller_.width()) / 2, 35 + pos + (combo_leader_.height() - orig_controller_.height()) / 2);
|
||||
|
@ -173,7 +173,7 @@ void connect::side::process_event()
|
|||
} else if (combo_controller_.selected() < CNTR_LAST) {
|
||||
// If the current side corresponds to an existing user,
|
||||
// we must kick it!
|
||||
|
||||
|
||||
if(id_ == preferences::login()) {
|
||||
update_controller_ui(); // Cannot kick game creator
|
||||
} else {
|
||||
|
@ -208,7 +208,7 @@ void connect::side::process_event()
|
|||
}
|
||||
|
||||
if(!enabled_)
|
||||
return;
|
||||
return;
|
||||
|
||||
if (combo_faction_.changed() && combo_faction_.selected() >= 0) {
|
||||
faction_ = combo_faction_.selected();
|
||||
|
@ -383,12 +383,12 @@ void connect::side::update_user_list()
|
|||
update_controller_ui();
|
||||
}
|
||||
|
||||
const std::string& connect::side::get_id() const
|
||||
const std::string& connect::side::get_id() const
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
void connect::side::set_id(const std::string& id)
|
||||
void connect::side::set_id(const std::string& id)
|
||||
{
|
||||
connected_user_list::iterator i = parent_->find_player(id);
|
||||
if (i != parent_->users_.end()) {
|
||||
|
@ -398,7 +398,7 @@ void connect::side::set_id(const std::string& id)
|
|||
update_ui();
|
||||
}
|
||||
|
||||
const std::string& connect::side::get_save_id() const
|
||||
const std::string& connect::side::get_save_id() const
|
||||
{
|
||||
return save_id_;
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ void connect::side::import_network_user(const config& data)
|
|||
llm_.update_leader_list(faction_);
|
||||
llm_.set_leader(data["leader"]);
|
||||
}
|
||||
|
||||
|
||||
update_ui();
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ void connect::side::resolve_random()
|
|||
|
||||
// Builds the list of sides which aren't random
|
||||
std::vector<int> nonrandom_sides;
|
||||
for(config::child_iterator itor = parent_->era_sides_.begin();
|
||||
for(config::child_iterator itor = parent_->era_sides_.begin();
|
||||
itor != parent_->era_sides_.end(); ++itor) {
|
||||
if((**itor)["random_faction"] != "yes") {
|
||||
nonrandom_sides.push_back(itor - parent_->era_sides_.begin());
|
||||
|
@ -456,7 +456,7 @@ void connect::side::resolve_random()
|
|||
}
|
||||
|
||||
if (llm_.get_leader() == "random") {
|
||||
// Choose a random leader type.
|
||||
// Choose a random leader type.
|
||||
const config& fact = *parent_->era_sides_[faction_];
|
||||
std::vector<std::string> types = utils::split(fact["leader"]);
|
||||
if (!types.empty()) {
|
||||
|
@ -471,7 +471,7 @@ void connect::side::resolve_random()
|
|||
}
|
||||
|
||||
connect::connect(display& disp, const config& game_config, const game_data& data,
|
||||
chat& c, config& gamelist, const create::parameters& params,
|
||||
chat& c, config& gamelist, const create::parameters& params,
|
||||
mp::controller default_controller) :
|
||||
mp::ui(disp, game_config, c, gamelist),
|
||||
|
||||
|
@ -510,7 +510,7 @@ connect::connect(display& disp, const config& game_config, const game_data& data
|
|||
// Adds the current user as default user.
|
||||
users_.push_back(connected_user(preferences::login(), CNTR_LOCAL, 0));
|
||||
update_user_combos();
|
||||
if(sides_.empty()) {
|
||||
if(sides_.empty()) {
|
||||
throw config::error(_("The scenario is invalid because it has no sides."));
|
||||
}
|
||||
|
||||
|
@ -583,7 +583,7 @@ const game_state& connect::get_state()
|
|||
void connect::start_game()
|
||||
{
|
||||
// Resolves the "random faction" and "random message"
|
||||
for (side_list::iterator itor = sides_.begin(); itor != sides_.end();
|
||||
for (side_list::iterator itor = sides_.begin(); itor != sides_.end();
|
||||
++itor) {
|
||||
|
||||
itor->resolve_random();
|
||||
|
@ -865,11 +865,11 @@ void connect::load_game()
|
|||
set_result(QUIT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::string error_log;
|
||||
::load_game(game_data_, game, state_, &error_log);
|
||||
if(!error_log.empty()) {
|
||||
gui::show_error_message(disp(),
|
||||
gui::show_error_message(disp(),
|
||||
_("The file you have tried to load is corrupt: '") +
|
||||
error_log);
|
||||
set_result(QUIT);
|
||||
|
@ -941,7 +941,7 @@ void connect::update_level()
|
|||
{
|
||||
// Import all sides into the level
|
||||
level_.clear_children("side");
|
||||
for(side_list::const_iterator itor = sides_.begin(); itor != sides_.end();
|
||||
for(side_list::const_iterator itor = sides_.begin(); itor != sides_.end();
|
||||
++itor) {
|
||||
|
||||
level_.add_child("side", itor->get_config());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
// The mp::connect widget owning this mp::connect::side. Used
|
||||
// in the constructor, must be first.
|
||||
connect* parent_;
|
||||
connect* parent_;
|
||||
|
||||
config cfg_;
|
||||
|
||||
|
@ -129,8 +129,8 @@ public:
|
|||
typedef std::vector<side> side_list;
|
||||
|
||||
|
||||
connect(display& disp, const config& game_config, const game_data& data,
|
||||
chat& c, config& gamelist, const create::parameters& params,
|
||||
connect(display& disp, const config& game_config, const game_data& data,
|
||||
chat& c, config& gamelist, const create::parameters& params,
|
||||
mp::controller default_controller);
|
||||
|
||||
virtual void process_event();
|
||||
|
@ -164,13 +164,13 @@ private:
|
|||
|
||||
// Updates the level_ variable to reflect the sides in the sides_ vector
|
||||
void update_level();
|
||||
|
||||
|
||||
// Updates the level, and send a diff to the clients
|
||||
void update_and_send_diff();
|
||||
|
||||
// Returns true if there still are sides available for this game
|
||||
bool sides_available();
|
||||
|
||||
|
||||
// Updates the state of the player list, the launch button and of the
|
||||
// start game label, to reflect the actual state.
|
||||
void update_playerlist_state(bool silent=true);
|
||||
|
@ -209,7 +209,7 @@ private:
|
|||
// team_name list and "Team" prefix
|
||||
std::vector<std::string> team_names_;
|
||||
const std::string team_prefix_;
|
||||
|
||||
|
||||
side_list sides_;
|
||||
connected_user_list users_;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -129,7 +129,7 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
|
|||
} else {
|
||||
era_combo_.set_selected(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
utils::string_map i18n_symbols;
|
||||
i18n_symbols["login"] = preferences::login();
|
||||
|
@ -154,7 +154,7 @@ create::~create()
|
|||
preferences::set_turns(turns_slider_.value());
|
||||
}
|
||||
|
||||
create::parameters& create::get_parameters()
|
||||
create::parameters& create::get_parameters()
|
||||
{
|
||||
const config::child_list& era_list = game_config().get_children("era");
|
||||
const int turns = turns_slider_.value() < turns_slider_.max_value() ?
|
||||
|
@ -371,9 +371,9 @@ void create::hide_children(bool hide)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void create::layout_children(const SDL_Rect& rect)
|
||||
{
|
||||
{
|
||||
ui::layout_children(rect);
|
||||
SDL_Rect ca = client_area();
|
||||
|
||||
|
@ -401,7 +401,7 @@ void create::layout_children(const SDL_Rect& rect)
|
|||
minimap_rect_ = mmrect;
|
||||
ypos += minimap_width + border_size;
|
||||
|
||||
num_players_label_.set_location(xpos, ypos);
|
||||
num_players_label_.set_location(xpos, ypos);
|
||||
ypos += num_players_label_.height() + border_size;
|
||||
|
||||
regenerate_map_.set_location(xpos, ypos);
|
||||
|
@ -468,7 +468,7 @@ void create::layout_children(const SDL_Rect& rect)
|
|||
#endif
|
||||
|
||||
// Buttons
|
||||
right_button->set_location(ca.x + ca.w - right_button->width(),
|
||||
right_button->set_location(ca.x + ca.w - right_button->width(),
|
||||
ca.y + ca.h - right_button->height());
|
||||
left_button->set_location(right_button->location().x - left_button->width() -
|
||||
gui::ButtonHPadding, ca.y + ca.h - left_button->height());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -78,7 +78,7 @@ bool lobby::lobby_sorter::less(int column, const gui::menu::item& row1, const gu
|
|||
}
|
||||
|
||||
return mapsize1 < mapsize2;
|
||||
|
||||
|
||||
} else if(column == STATUS_COLUMN) {
|
||||
const int nslots1 = atoi(game1["slots"].c_str());
|
||||
const int nslots2 = atoi(game2["slots"].c_str());
|
||||
|
@ -193,7 +193,7 @@ void lobby::gamelist_updated(bool silent)
|
|||
if(turn != "") {
|
||||
str << COLUMN_SEPARATOR << _("Turn") << " " << turn;
|
||||
} else if(slots != "") {
|
||||
str << COLUMN_SEPARATOR << slots << " " <<
|
||||
str << COLUMN_SEPARATOR << slots << " " <<
|
||||
ngettext(_("Vacant Slot"), _("Vacant Slots"), nslots);
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ void lobby::process_event()
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(create_game_.pressed()) {
|
||||
set_result(CREATE);
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2005
|
||||
Copyright (C) 2005
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -104,7 +104,7 @@ chat::chat()
|
|||
void chat::add_message(const std::string& user, const std::string& message)
|
||||
{
|
||||
message_history_.push_back(msg(user, message));
|
||||
|
||||
|
||||
while (message_history_.size() > 1024) {
|
||||
message_history_.pop_front();
|
||||
|
||||
|
@ -117,11 +117,11 @@ void chat::init_textbox(gui::textbox& textbox)
|
|||
{
|
||||
std::string s;
|
||||
|
||||
for(msg_hist::const_iterator itor = message_history_.begin();
|
||||
for(msg_hist::const_iterator itor = message_history_.begin();
|
||||
itor != message_history_.end(); ++itor) {
|
||||
s.append(format_message(*itor));
|
||||
}
|
||||
|
||||
|
||||
textbox.set_text(s);
|
||||
last_update_ = message_history_.size();
|
||||
textbox.scroll_to_bottom();
|
||||
|
@ -131,7 +131,7 @@ void chat::update_textbox(gui::textbox& textbox)
|
|||
{
|
||||
std::string s;
|
||||
|
||||
for(msg_hist::const_iterator itor = message_history_.begin() + last_update_;
|
||||
for(msg_hist::const_iterator itor = message_history_.begin() + last_update_;
|
||||
itor != message_history_.end(); ++itor) {
|
||||
s.append(format_message(*itor));
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ void ui::process_network()
|
|||
|
||||
if(sock) {
|
||||
process_network_data(data, sock);
|
||||
}
|
||||
}
|
||||
} catch(network::error& e) {
|
||||
process_network_error(e);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ void ui::draw_contents()
|
|||
|
||||
surface background(image::get_image("misc/lobby.png",image::UNSCALED));
|
||||
background = scale_surface(background, video().getx(), video().gety());
|
||||
if(background == NULL)
|
||||
if(background == NULL)
|
||||
return;
|
||||
SDL_BlitSurface(background, NULL, video().getSurface(), NULL);
|
||||
update_whole_screen();
|
||||
|
@ -297,7 +297,7 @@ void ui::handle_key_event(const SDL_KeyboardEvent& event)
|
|||
chat_.update_textbox(chat_textbox_);
|
||||
|
||||
}
|
||||
|
||||
|
||||
network::send_data(data);
|
||||
entry_textbox_.clear();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
private:
|
||||
struct msg {
|
||||
msg(const std::string& user, const std::string& message) :
|
||||
msg(const std::string& user, const std::string& message) :
|
||||
user(user), message(message) {};
|
||||
std::string user;
|
||||
std::string message;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -39,7 +39,7 @@ wait::leader_preview_pane::leader_preview_pane(display& disp, const game_data* d
|
|||
const config::child_list& side_list) :
|
||||
gui::preview_pane(disp.video()),
|
||||
side_list_(side_list),
|
||||
leader_combo_(disp, std::vector<std::string>()),
|
||||
leader_combo_(disp, std::vector<std::string>()),
|
||||
leaders_(side_list, data, &leader_combo_),
|
||||
selection_(0), data_(data)
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ void wait::leader_preview_pane::draw_contents()
|
|||
SDL_Rect image_rect = {area.x,area.y,0,0};
|
||||
|
||||
surface unit_image(image::get_image(image, image::UNSCALED));
|
||||
|
||||
|
||||
if(!unit_image.null()) {
|
||||
image_rect.w = unit_image->w;
|
||||
image_rect.h = unit_image->h;
|
||||
|
@ -163,12 +163,12 @@ void wait::process_event()
|
|||
void wait::join_game(bool observe)
|
||||
{
|
||||
for(;;) {
|
||||
network::connection data_res = gui::network_data_dialog(disp(),
|
||||
network::connection data_res = gui::network_data_dialog(disp(),
|
||||
_("Getting game data..."), level_);
|
||||
check_response(data_res, level_);
|
||||
|
||||
//if we have got valid side data
|
||||
if(level_.child("gamelist") == NULL)
|
||||
if(level_.child("gamelist") == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ void wait::join_game(bool observe)
|
|||
const config* era = level_.child("era");
|
||||
if(era == NULL)
|
||||
throw network::error(_("Era not available"));
|
||||
const config::child_list& possible_sides =
|
||||
const config::child_list& possible_sides =
|
||||
era->get_children("multiplayer_side");
|
||||
if(possible_sides.empty()) {
|
||||
set_result(QUIT);
|
||||
|
@ -215,13 +215,13 @@ void wait::join_game(bool observe)
|
|||
|
||||
std::vector<std::string> choices;
|
||||
for(config::child_list::const_iterator side =
|
||||
possible_sides.begin(); side !=
|
||||
possible_sides.begin(); side !=
|
||||
possible_sides.end(); ++side) {
|
||||
choices.push_back((**side)["name"]);
|
||||
}
|
||||
|
||||
std::vector<gui::preview_pane* > preview_panes;
|
||||
leader_preview_pane leader_selector(disp(), &game_data_,
|
||||
leader_preview_pane leader_selector(disp(), &game_data_,
|
||||
possible_sides);
|
||||
preview_panes.push_back(&leader_selector);
|
||||
|
||||
|
@ -250,7 +250,7 @@ const game_state& wait::get_state()
|
|||
return state_;
|
||||
}
|
||||
|
||||
void wait::start_game()
|
||||
void wait::start_game()
|
||||
{
|
||||
config const * const stats = level_.child("statistics");
|
||||
if(stats != NULL) {
|
||||
|
@ -310,7 +310,7 @@ void wait::process_network_data(const config& data, const network::connection so
|
|||
<< level_.get_children("side").size() << ","
|
||||
<< data.get_children("side").size() << "\n";
|
||||
generate_menu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wait::generate_menu()
|
||||
|
@ -358,7 +358,7 @@ void wait::generate_menu()
|
|||
// Dumps the "image" part of the faction name, if any,
|
||||
// to replace it by a picture of the actual leader
|
||||
if(side_name.str()[0] == font::IMAGE) {
|
||||
std::string::size_type p =
|
||||
std::string::size_type p =
|
||||
side_name.str().find_first_of(COLUMN_SEPARATOR);
|
||||
if(p != std::string::npos && p < side_name.size()) {
|
||||
side_name = IMAGE_PREFIX + leader_image + COLUMN_SEPARATOR + side_name.str().substr(p+1);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C)
|
||||
Copyright (C)
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@ -46,7 +46,7 @@ private:
|
|||
class leader_preview_pane : public gui::preview_pane
|
||||
{
|
||||
public:
|
||||
leader_preview_pane(display& disp, const game_data* data,
|
||||
leader_preview_pane(display& disp, const game_data* data,
|
||||
const config::child_list& side_list);
|
||||
|
||||
bool show_above() const;
|
||||
|
|
|
@ -24,7 +24,7 @@ struct manager {
|
|||
|
||||
private:
|
||||
bool free_;
|
||||
|
||||
|
||||
manager(const manager&);
|
||||
void operator=(const manager&);
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ private:
|
|||
struct server_manager {
|
||||
|
||||
//parameter to pass to the constructor.
|
||||
|
||||
|
||||
enum CREATE_SERVER { MUST_CREATE_SERVER, //will throw exception on failure
|
||||
TRY_CREATE_SERVER, //will swallow failure
|
||||
NO_SERVER }; //won't try to create a server at all
|
||||
|
|
|
@ -325,7 +325,7 @@ void close_socket(TCPsocket sock)
|
|||
}
|
||||
|
||||
const socket_state_map::iterator lock_it = sockets_locked.find(sock);
|
||||
|
||||
|
||||
if(lock_it == sockets_locked.end() || lock_it->second != SOCKET_LOCKED) {
|
||||
if(lock_it != sockets_locked.end()) {
|
||||
sockets_locked.erase(lock_it);
|
||||
|
|
110
src/pathfind.cpp
110
src/pathfind.cpp
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -29,14 +29,14 @@ class gamestatus;
|
|||
|
||||
typedef std::vector<gamemap::location> vector_location;
|
||||
typedef std::vector<a_star_node*> vector_a_star_node;
|
||||
typedef std::set<gamemap::location> set_location;
|
||||
typedef std::set<gamemap::location> set_location;
|
||||
|
||||
bool compare_strict_sup_a_star_node(const a_star_node* node1, const a_star_node* node2) {
|
||||
return node1->g + node1->h > node2->g + node2->h;
|
||||
return node1->g + node1->h > node2->g + node2->h;
|
||||
}
|
||||
|
||||
bool compare_sup_equal_a_star_node(const a_star_node* node1, const a_star_node* node2) {
|
||||
return node1->g + node1->h >= node2->g + node2->h;
|
||||
return node1->g + node1->h >= node2->g + node2->h;
|
||||
}
|
||||
|
||||
void a_star_init(gamemap::location const &src, gamemap::location const &dst,
|
||||
|
@ -47,12 +47,12 @@ void a_star_init(gamemap::location const &src, gamemap::location const &dst,
|
|||
{
|
||||
a_star_node* locStartNode = NULL;
|
||||
bool locIsCreated = false;
|
||||
|
||||
|
||||
aStarGameWorld.resize_IFN(parWidth, parHeight);
|
||||
wassert(aStarGameWorld.empty());
|
||||
locStartNode = aStarGameWorld.getNodeFromLocation(src, locIsCreated);
|
||||
wassert(locIsCreated);
|
||||
locStartNode->initNode(src, dst, 0.0, NULL, teleports);
|
||||
locStartNode->initNode(src, dst, 0.0, NULL, teleports);
|
||||
|
||||
const size_t locValueH = size_t(locStartNode->h);
|
||||
size_t locAllocSize;
|
||||
|
@ -62,9 +62,9 @@ void a_star_init(gamemap::location const &src, gamemap::location const &dst,
|
|||
else if (locValueH > 128)
|
||||
locAllocSize = 128;
|
||||
else
|
||||
locAllocSize = locValueH;
|
||||
locAllocSize = locValueH;
|
||||
openList.reserve(locAllocSize);
|
||||
openList.push_back(locStartNode);
|
||||
openList.push_back(locStartNode);
|
||||
|
||||
if (locValueH < 32)
|
||||
locAllocSize = 32;
|
||||
|
@ -72,16 +72,16 @@ void a_star_init(gamemap::location const &src, gamemap::location const &dst,
|
|||
locAllocSize = 256;
|
||||
else
|
||||
locAllocSize = locValueH;
|
||||
|
||||
if (teleports != NULL)
|
||||
|
||||
if (teleports != NULL)
|
||||
parNbTeleport = teleports->size();
|
||||
else
|
||||
parNbTeleport = 0;
|
||||
|
||||
vectLocation.reserve(parNbTeleport + 6);
|
||||
vectLocation.resize(parNbTeleport + 6);
|
||||
vectLocation.resize(parNbTeleport + 6);
|
||||
|
||||
if (parNbTeleport > 0)
|
||||
if (parNbTeleport > 0)
|
||||
{
|
||||
gamemap::location* locLocation;
|
||||
|
||||
|
@ -90,7 +90,7 @@ void a_star_init(gamemap::location const &src, gamemap::location const &dst,
|
|||
locLocation->x = (*it).x;
|
||||
locLocation->y = (*it).y;
|
||||
++locLocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,18 +100,18 @@ void a_star_sort_and_merge(vector_a_star_node& openList, const size_t locNbAdded
|
|||
|
||||
#ifdef _PARANO_ASTAR_
|
||||
for (vector_a_star_node::iterator iter = openList.begin(); iter != openList.end(); ++iter)
|
||||
wassert((*iter)->isInCloseList == false);
|
||||
wassert((*iter)->isInCloseList == false);
|
||||
if (openList.size() > locNbAdded) {
|
||||
for (vector_a_star_node::iterator iter = openList.begin() + 1; iter != openList.end() - locNbAdded; ++iter)
|
||||
{
|
||||
vector_a_star_node::iterator iterPrev = iter - 1;
|
||||
vector_a_star_node::iterator iterPrev = iter - 1;
|
||||
wassert(compare_sup_equal_a_star_node(*iterPrev, *iter));
|
||||
}
|
||||
}
|
||||
if (locNbAdded > 0) {
|
||||
for (vector_a_star_node::iterator iter = openList.end() - locNbAdded + 1; iter != openList.end(); ++iter)
|
||||
{
|
||||
vector_a_star_node::iterator iterPrev = iter - 1;
|
||||
vector_a_star_node::iterator iterPrev = iter - 1;
|
||||
wassert(compare_sup_equal_a_star_node(*iterPrev, *iter));
|
||||
}
|
||||
}
|
||||
|
@ -124,8 +124,8 @@ void a_star_sort_and_merge(vector_a_star_node& openList, const size_t locNbAdded
|
|||
vector_a_star_node::iterator iter;
|
||||
for (iter = openList.begin() + 1; iter != openList.end(); ++iter)
|
||||
{
|
||||
vector_a_star_node::iterator iterPrev = iter - 1;
|
||||
wassert(compare_sup_equal_a_star_node(*iterPrev, *iter));
|
||||
vector_a_star_node::iterator iterPrev = iter - 1;
|
||||
wassert(compare_sup_equal_a_star_node(*iterPrev, *iter));
|
||||
}
|
||||
for (iter = openList.begin(); iter != openList.end(); ++iter)
|
||||
wassert((*iter)->isInCloseList == false);
|
||||
|
@ -142,9 +142,9 @@ void a_star_explore_neighbours(gamemap::location const &dst, const double stop_a
|
|||
a_star_node* parCurNode, const size_t parNbTeleport)
|
||||
{
|
||||
//----------------- PRE_CONDITIONS ------------------
|
||||
wassert(parCurNode != NULL);
|
||||
wassert(parCurNode != NULL);
|
||||
//---------------------------------------------------
|
||||
|
||||
|
||||
typedef std::pair<vector_a_star_node::iterator, vector_a_star_node::iterator> pair_node_iter;
|
||||
|
||||
a_star_node* locNextNode;
|
||||
|
@ -154,7 +154,7 @@ void a_star_explore_neighbours(gamemap::location const &dst, const double stop_a
|
|||
bool locIsCreated = false;
|
||||
const double locCostFather = parCurNode->g;
|
||||
|
||||
get_adjacent_tiles(parCurNode->loc, &vectLocation[0]);
|
||||
get_adjacent_tiles(parCurNode->loc, &vectLocation[0]);
|
||||
|
||||
if ((parNbTeleport > 0) && (teleports->count(parCurNode->loc) > 0))
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ void a_star_explore_neighbours(gamemap::location const &dst, const double stop_a
|
|||
{
|
||||
wassert(vectLocation.size() >= 6);
|
||||
locSize = 6;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i != locSize; ++i)
|
||||
{
|
||||
|
@ -180,9 +180,9 @@ void a_star_explore_neighbours(gamemap::location const &dst, const double stop_a
|
|||
if (locIsCreated)
|
||||
{
|
||||
locNextNode->initNode(locLocation, dst, locCost, parCurNode, teleports);
|
||||
if (locNextNode->g + locNextNode->h < stop_at) {
|
||||
if (locNextNode->g + locNextNode->h < stop_at) {
|
||||
openList.push_back(locNextNode);
|
||||
++locNbAdded;
|
||||
++locNbAdded;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -194,12 +194,12 @@ void a_star_explore_neighbours(gamemap::location const &dst, const double stop_a
|
|||
{
|
||||
// If this path is better that the previous for this node
|
||||
if (locCost < locNextNode->g)
|
||||
{
|
||||
{
|
||||
if (locNextNode->isInCloseList) {
|
||||
locNextNode->isInCloseList = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
locPlace = std::equal_range(openList.begin(), openList.end() - locNbAdded, locNextNode, compare_strict_sup_a_star_node);
|
||||
assertParanoAstar(*(std::find(locPlace.first, locPlace.second, locNextNode)) == locNextNode);
|
||||
openList.erase(std::find(locPlace.first, locPlace.second, locNextNode));
|
||||
|
@ -207,14 +207,14 @@ void a_star_explore_neighbours(gamemap::location const &dst, const double stop_a
|
|||
openList.push_back(locNextNode);
|
||||
++locNbAdded;
|
||||
locNextNode->g = locCost;
|
||||
locNextNode->nodeParent = parCurNode;
|
||||
locNextNode->nodeParent = parCurNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
paths::route a_star_search( gamemap::location const &src, gamemap::location const &dst,
|
||||
double stop_at, cost_calculator const *costCalculator, const size_t parWidth,
|
||||
double stop_at, cost_calculator const *costCalculator, const size_t parWidth,
|
||||
const size_t parHeight, std::set<gamemap::location> const *teleports)
|
||||
{
|
||||
//----------------- PRE_CONDITIONS ------------------
|
||||
|
@ -224,22 +224,22 @@ paths::route a_star_search( gamemap::location const &src, gamemap::location cons
|
|||
wassert(dst.valid());
|
||||
wassert(costCalculator != NULL);
|
||||
wassert(stop_at <= costCalculator->getNoPathValue());
|
||||
//---------------------------------------------------
|
||||
static a_star_world aStarGameWorld;
|
||||
//---------------------------------------------------
|
||||
static a_star_world aStarGameWorld;
|
||||
static poss_a_star_node POSS_AStarNode;
|
||||
|
||||
vector_a_star_node openList;
|
||||
|
||||
vector_a_star_node openList;
|
||||
vector_location vectLocation;
|
||||
paths::route locRoute;
|
||||
size_t locNbTeleport;
|
||||
size_t locNbAdded;
|
||||
size_t locNbTeleport;
|
||||
size_t locNbAdded;
|
||||
a_star_node* locDestNode = NULL;
|
||||
a_star_node* locCurNode = NULL;
|
||||
|
||||
wassert(openList.empty());
|
||||
|
||||
wassert(openList.empty());
|
||||
wassert(aStarGameWorld.empty());
|
||||
assertParanoAstar(aStarGameWorld.reallyEmpty());
|
||||
|
||||
assertParanoAstar(aStarGameWorld.reallyEmpty());
|
||||
|
||||
LOG_PF << "A* search: " << src << " -> " << dst << '\n';
|
||||
|
||||
if ( (src.valid(int(parWidth), int(parHeight)) == false) ||
|
||||
|
@ -249,26 +249,26 @@ paths::route a_star_search( gamemap::location const &src, gamemap::location cons
|
|||
LOG_PF << "aborted A* search because Start or Dest is invalid\n";
|
||||
locRoute.move_left = int(costCalculator->getNoPathValue());
|
||||
return (locRoute);
|
||||
}
|
||||
}
|
||||
|
||||
a_star_init(src, dst, openList, aStarGameWorld, parWidth, parHeight, vectLocation, teleports, locNbTeleport);
|
||||
|
||||
while (!openList.empty())
|
||||
while (!openList.empty())
|
||||
{
|
||||
locCurNode = openList.back();
|
||||
wassert(locCurNode != NULL);
|
||||
|
||||
wassert(locCurNode != NULL);
|
||||
|
||||
//if we have found a solution
|
||||
if (locCurNode->loc == dst)
|
||||
{
|
||||
locDestNode = locCurNode;
|
||||
|
||||
locDestNode = locCurNode;
|
||||
|
||||
LOG_PF << "found solution; calculating it...\n";
|
||||
while (locCurNode != NULL)
|
||||
{
|
||||
locRoute.steps.push_back(locCurNode->loc);
|
||||
locCurNode = locCurNode->nodeParent;
|
||||
}
|
||||
}
|
||||
std::reverse(locRoute.steps.begin(), locRoute.steps.end());
|
||||
locRoute.move_left = int(locDestNode->g);
|
||||
|
||||
|
@ -282,18 +282,18 @@ paths::route a_star_search( gamemap::location const &src, gamemap::location cons
|
|||
openList.pop_back();
|
||||
|
||||
wassert(locCurNode->isInCloseList == false);
|
||||
locCurNode->isInCloseList = true ;
|
||||
|
||||
locCurNode->isInCloseList = true ;
|
||||
|
||||
locNbAdded = 0;
|
||||
a_star_explore_neighbours(dst, stop_at, costCalculator, parWidth, parHeight, teleports, vectLocation,
|
||||
openList, aStarGameWorld, locNbAdded, locCurNode, locNbTeleport);
|
||||
|
||||
a_star_sort_and_merge(openList, locNbAdded);
|
||||
}
|
||||
|
||||
|
||||
LOG_PF << "aborted a* search\n";
|
||||
locRoute.move_left = int(costCalculator->getNoPathValue());
|
||||
|
||||
|
||||
label_AStarSearch_end:
|
||||
openList.clear();
|
||||
POSS_AStarNode.reduce();
|
||||
|
@ -302,7 +302,7 @@ label_AStarSearch_end:
|
|||
//----------------- POST_CONDITIONS -----------------
|
||||
wassert(openList.empty());
|
||||
wassert(aStarGameWorld.empty());
|
||||
assertParanoAstar(aStarGameWorld.reallyEmpty());
|
||||
assertParanoAstar(aStarGameWorld.reallyEmpty());
|
||||
//---------------------------------------------------
|
||||
return (locRoute);
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ void get_tiles_radius(const gamemap& map, const std::vector<gamemap::location>&
|
|||
}
|
||||
}
|
||||
|
||||
bool enemy_zoc(const gamemap& map, const gamestatus& status,
|
||||
bool enemy_zoc(const gamemap& map, const gamestatus& status,
|
||||
const std::map<gamemap::location,unit>& units,
|
||||
const std::vector<team>& teams,
|
||||
const gamemap::location& loc, const team& current_team, int side)
|
||||
|
@ -589,7 +589,7 @@ shortest_path_calculator::shortest_path_calculator(const unit& u, const team& t,
|
|||
const std::vector<team>& teams,
|
||||
const gamemap& map,
|
||||
const gamestatus& status)
|
||||
: unit_(u), team_(t), units_(units), teams_(teams),
|
||||
: unit_(u), team_(t), units_(units), teams_(teams),
|
||||
map_(map), status_(status)
|
||||
{
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ double shortest_path_calculator::cost(const gamemap::location& loc, const double
|
|||
if (enemy_unit != units_.end() && team_.is_enemy(enemy_unit->second.side()))
|
||||
return (getNoPathValue());
|
||||
|
||||
if ((isDst == false) && (unit_.type().is_skirmisher() == false))
|
||||
if ((isDst == false) && (unit_.type().is_skirmisher() == false))
|
||||
{
|
||||
gamemap::location adj[6];
|
||||
get_adjacent_tiles(loc,adj);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -51,7 +51,7 @@ gamemap::location find_vacant_tile(const gamemap& map,
|
|||
VACANT_TILE_TYPE vacancy=VACANT_ANY);
|
||||
|
||||
//function which determines if a given location is an enemy zone of control
|
||||
bool enemy_zoc(const gamemap& map,const gamestatus& status,
|
||||
bool enemy_zoc(const gamemap& map,const gamestatus& status,
|
||||
const std::map<gamemap::location,unit>& units,
|
||||
const std::vector<team>& teams,
|
||||
const gamemap::location& loc,const team& current_team,int side);
|
||||
|
@ -66,7 +66,7 @@ struct cost_calculator
|
|||
//object which contains all the possible locations a unit can move to, with
|
||||
//associated best routes to those locations.
|
||||
struct paths
|
||||
{
|
||||
{
|
||||
paths() {}
|
||||
|
||||
//construct a list of paths for the unit at loc.
|
||||
|
@ -75,7 +75,7 @@ struct paths
|
|||
//additional_turns: if 0, paths for how far the unit can move this turn
|
||||
//will be calculated. If 1, paths for how far the unit can move by the
|
||||
//end of next turn will be calculated, and so forth.
|
||||
paths(const gamemap& map, const gamestatus& status,
|
||||
paths(const gamemap& map, const gamestatus& status,
|
||||
const game_data& gamedata,
|
||||
const std::map<gamemap::location,unit>& units,
|
||||
const gamemap::location& loc, std::vector<team>& teams,
|
||||
|
@ -90,7 +90,7 @@ struct paths
|
|||
};
|
||||
|
||||
typedef std::map<gamemap::location,route> routes_map;
|
||||
routes_map routes;
|
||||
routes_map routes;
|
||||
};
|
||||
|
||||
paths::route a_star_search(gamemap::location const &src, gamemap::location const &dst,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003-2005 by David White <davidnwhite@optusnet.com.au>
|
||||
Copyright (C) 2003-2005 by David White <davidnwhite@comcast.net>
|
||||
Copyright (C) 2005 by Philippe Plantier <ayin@anathas.org>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
|
@ -32,9 +32,9 @@
|
|||
|
||||
namespace {
|
||||
|
||||
struct player_controller
|
||||
struct player_controller
|
||||
{
|
||||
player_controller()
|
||||
player_controller()
|
||||
{}
|
||||
|
||||
player_controller(const std::string& controller, const std::string& description) :
|
||||
|
@ -50,7 +50,7 @@ typedef std::map<std::string, player_controller> controller_map;
|
|||
}
|
||||
|
||||
LEVEL_RESULT play_game(display& disp, game_state& state, const config& game_config,
|
||||
const game_data& units_data, CVideo& video,
|
||||
const game_data& units_data, CVideo& video,
|
||||
io_type_t io_type)
|
||||
{
|
||||
std::string type = state.campaign_type;
|
||||
|
@ -91,7 +91,7 @@ LEVEL_RESULT play_game(display& disp, game_state& state, const config& game_conf
|
|||
|
||||
if(io_type == IO_SERVER) {
|
||||
const config::child_list& sides_list = scenario->get_children("side");
|
||||
for(config::child_list::const_iterator side = sides_list.begin();
|
||||
for(config::child_list::const_iterator side = sides_list.begin();
|
||||
side != sides_list.end(); ++side) {
|
||||
std::string id = (**side)["save_id"];
|
||||
if(id.empty())
|
||||
|
@ -110,7 +110,7 @@ LEVEL_RESULT play_game(display& disp, game_state& state, const config& game_conf
|
|||
}
|
||||
|
||||
const config::child_list& sides_list = starting_pos.get_children("side");
|
||||
for(config::child_list::const_iterator side = sides_list.begin();
|
||||
for(config::child_list::const_iterator side = sides_list.begin();
|
||||
side != sides_list.end(); ++side) {
|
||||
if((**side)["controller"] == "network" &&
|
||||
(**side)["description"] == preferences::login()) {
|
||||
|
@ -196,7 +196,7 @@ LEVEL_RESULT play_game(display& disp, game_state& state, const config& game_conf
|
|||
config cfg;
|
||||
do {
|
||||
cfg.clear();
|
||||
network::connection data_res = gui::network_data_dialog(disp,
|
||||
network::connection data_res = gui::network_data_dialog(disp,
|
||||
_("Downloading next level..."), cfg);
|
||||
if(!data_res)
|
||||
throw network::error(_("Connection timed out"));
|
||||
|
@ -223,14 +223,14 @@ LEVEL_RESULT play_game(display& disp, game_state& state, const config& game_conf
|
|||
|
||||
// Tweaks sides to adapt controllers and descriptions.
|
||||
const config::child_list& sides_list = starting_pos.get_children("side");
|
||||
for(config::child_list::const_iterator side = sides_list.begin();
|
||||
for(config::child_list::const_iterator side = sides_list.begin();
|
||||
side != sides_list.end(); ++side) {
|
||||
|
||||
|
||||
std::string id = (**side)["save_id"];
|
||||
if(id.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
controller_map::const_iterator ctr = controllers.find(id);
|
||||
if(ctr != controllers.end()) {
|
||||
(**side)["description"] = ctr->second.description;
|
||||
|
@ -270,7 +270,7 @@ LEVEL_RESULT play_game(display& disp, game_state& state, const config& game_conf
|
|||
_("Name:"),
|
||||
&state.label);
|
||||
|
||||
|
||||
|
||||
if(should_save == 0) {
|
||||
try {
|
||||
save_game(state);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003-2005 by David White <davidnwhite@optusnet.com.au>
|
||||
Copyright (C) 2003-2005 by David White <davidnwhite@comcast.net>
|
||||
Copyright (C) 2005 by Philippe Plantier <ayin@anathas.org>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org
|
||||
|
||||
|
@ -32,7 +32,7 @@ enum io_type_t {
|
|||
LEVEL_RESULT play_game(display& disp, game_state& state, const config& game_config,
|
||||
const game_data& units_data, CVideo& video,
|
||||
io_type_t io_type=IO_NONE);
|
||||
|
||||
|
||||
|
||||
#endif // PLAYCAMPAIGN_H_INCLUDED
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -146,14 +146,14 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
if((*level)["scenario_generation"] != "") {
|
||||
LOG_NG << "randomly generating scenario...\n";
|
||||
const cursor::setter cursor_setter(cursor::WAIT);
|
||||
|
||||
|
||||
static config scenario;
|
||||
scenario = random_generate_scenario((*level)["scenario_generation"],level->child("generator"));
|
||||
level = &scenario;
|
||||
|
||||
state_of_game.starting_pos = scenario;
|
||||
}
|
||||
|
||||
|
||||
std::string map_data = (*level)["map_data"];
|
||||
if(map_data == "" && (*level)["map"] != "") {
|
||||
map_data = read_map((*level)["map"]);
|
||||
|
@ -323,11 +323,11 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
std::copy(player->can_recruit.begin(),player->can_recruit.end(),
|
||||
std::inserter(teams.back().recruits(),teams.back().recruits().end()));
|
||||
}
|
||||
|
||||
|
||||
if(player != NULL) {
|
||||
player->can_recruit = teams.back().recruits();
|
||||
}
|
||||
|
||||
|
||||
//if there are additional starting units on this side
|
||||
const config::child_list& starting_units = (*ui)->get_children("unit");
|
||||
for(config::child_list::const_iterator su = starting_units.begin(); su != starting_units.end(); ++su) {
|
||||
|
@ -364,10 +364,10 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
LOG_NG << *it << std::endl;
|
||||
}
|
||||
LOG_NG << "Added all recruitable units\n";
|
||||
std::copy(recruitable.begin(), recruitable.end(),
|
||||
std::copy(recruitable.begin(), recruitable.end(),
|
||||
std::inserter(enc_units, enc_units.begin()));
|
||||
}
|
||||
|
||||
|
||||
// Add all units that exist at the start to the encountered units so
|
||||
// that information about them are displayed to the user in the help
|
||||
// system.
|
||||
|
@ -423,7 +423,7 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
LOG_NG << "b... " << (SDL_GetTicks() - ticks) << "\n";
|
||||
|
||||
//this *needs* to be created before the show_intro and show_map_scene
|
||||
//as that functions use the manager state_of_game
|
||||
//as that functions use the manager state_of_game
|
||||
game_events::manager events_manager(*level,gui,map,units,teams,
|
||||
state_of_game,status,gameinfo);
|
||||
|
||||
|
@ -472,10 +472,10 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
//if a team is specified whose turn it is, it means we're loading a game
|
||||
//instead of starting a fresh one
|
||||
const bool loading_game = lvl["playing_team"].empty() == false;
|
||||
|
||||
|
||||
gui.begin_game();
|
||||
gui.adjust_colours(0,0,0);
|
||||
|
||||
|
||||
LOG_NG << "scrolling... " << (SDL_GetTicks() - ticks) << "\n";
|
||||
if(first_human_team != -1) {
|
||||
LOG_NG << "b " << (SDL_GetTicks() - ticks) << "\n";
|
||||
|
@ -487,12 +487,12 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
LOG_NG << "done scrolling... " << (SDL_GetTicks() - ticks) << "\n";
|
||||
|
||||
bool replaying = (recorder.at_end() == false);
|
||||
|
||||
|
||||
int first_player = atoi(lvl["playing_team"].c_str());
|
||||
if(first_player < 0 || first_player >= int(teams.size())) {
|
||||
first_player = 0;
|
||||
}
|
||||
|
||||
|
||||
if(!loading_game) {
|
||||
game_events::fire("prestart");
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
}
|
||||
|
||||
std::deque<config> data_backlog;
|
||||
|
||||
|
||||
LOG_NG << "starting main loop\n" << (SDL_GetTicks() - ticks) << "\n";
|
||||
for(bool first_time = true; true; first_time = false, first_player = 0) {
|
||||
if(first_time) {
|
||||
|
@ -707,7 +707,7 @@ redo_turn:
|
|||
gui.recalculate_minimap();
|
||||
gui.invalidate_all();
|
||||
}
|
||||
|
||||
|
||||
game_events::pump();
|
||||
|
||||
check_victory(units,teams);
|
||||
|
@ -715,7 +715,7 @@ redo_turn:
|
|||
|
||||
//time has run out
|
||||
if(!status.next_turn()) {
|
||||
|
||||
|
||||
if(non_interactive()) {
|
||||
std::cout << "time over (draw)\n";
|
||||
}
|
||||
|
@ -860,7 +860,7 @@ redo_turn:
|
|||
gui::show_dialog(gui, NULL, _("Victory"),
|
||||
_("You have emerged victorious!"), gui::OK_ONLY);
|
||||
|
||||
if (state_of_game.players.size() > 0 && has_next_scenario ||
|
||||
if (state_of_game.players.size() > 0 && has_next_scenario ||
|
||||
state_of_game.campaign_type == "test")
|
||||
gui::show_dialog(gui, NULL, _("Scenario Report"), report.str(), gui::OK_ONLY);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
|
||||
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
|
||||
Copyright (C) 2003 by David White <davidnwhite@comcast.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
|
@ -110,7 +110,7 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
unit_map::const_iterator ui = units.find(*g);
|
||||
turn_data.move_unit_to_loc(ui,ui->second.get_goto(),false);
|
||||
}
|
||||
|
||||
|
||||
turn_data.start_interactive_turn();
|
||||
|
||||
while(!turn_data.turn_over()) {
|
||||
|
@ -141,7 +141,7 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
}
|
||||
|
||||
turn_info::turn_info(const game_data& gameinfo, game_state& state_of_game,
|
||||
const gamestatus& status, const config& terrain_config,
|
||||
const gamestatus& status, const config& terrain_config,
|
||||
const config& level, CKey& key, display& gui, gamemap& map,
|
||||
std::vector<team>& teams, int team_num, unit_map& units,
|
||||
TURN_MODE mode, floating_textbox& textbox,
|
||||
|
@ -188,7 +188,7 @@ void turn_info::turn_slice()
|
|||
const bool use_left_right = (textbox_.active() == false);
|
||||
if(use_left_right && key_[SDLK_LEFT] || mousex < scroll_threshold)
|
||||
gui_.scroll(-preferences::scroll_speed(),0);
|
||||
|
||||
|
||||
if(use_left_right && key_[SDLK_RIGHT] || mousex > gui_.x()-scroll_threshold)
|
||||
gui_.scroll(preferences::scroll_speed(),0);
|
||||
|
||||
|
@ -347,7 +347,7 @@ void turn_info::mouse_motion(int x, int y)
|
|||
current_paths_ = paths();
|
||||
gui_.set_paths(NULL);
|
||||
}
|
||||
|
||||
|
||||
const gamemap::location& dest = attack_from.valid() ? attack_from : new_hex;
|
||||
const unit_map::const_iterator dest_un = find_unit(dest);
|
||||
if(dest == selected_hex_ || dest_un != units_.end()) {
|
||||
|
@ -355,9 +355,9 @@ void turn_info::mouse_motion(int x, int y)
|
|||
gui_.set_route(NULL);
|
||||
} else if(!current_paths_.routes.empty() && map_.on_board(selected_hex_) &&
|
||||
map_.on_board(new_hex)) {
|
||||
|
||||
|
||||
unit_map::const_iterator un = find_unit(selected_hex_);
|
||||
|
||||
|
||||
if((new_hex != last_hex_ || attack_from.valid()) && un != units_.end() && !un->second.stone()) {
|
||||
const shortest_path_calculator calc(un->second,current_team,
|
||||
visible_units(),teams_,map_,status_);
|
||||
|
@ -436,7 +436,7 @@ class simple_attack_rating
|
|||
public:
|
||||
simple_attack_rating() : attacker_weapon_rating_(0), defender_weapon_rating_(0) {}
|
||||
|
||||
simple_attack_rating(const battle_stats& stats) :
|
||||
simple_attack_rating(const battle_stats& stats) :
|
||||
attacker_weapon_rating_(stats.chance_to_hit_defender *
|
||||
stats.damage_defender_takes * stats.nattacks),
|
||||
defender_weapon_rating_(stats.chance_to_hit_attacker *
|
||||
|
@ -448,7 +448,7 @@ public:
|
|||
if(attacker_weapon_rating_ < a.attacker_weapon_rating_)
|
||||
return true;
|
||||
|
||||
//if both weapons are the same but
|
||||
//if both weapons are the same but
|
||||
//ours makes the enemy retaliate for more damage, it's worse
|
||||
else if(attacker_weapon_rating_ == a.attacker_weapon_rating_ &&
|
||||
defender_weapon_rating_ > a.defender_weapon_rating_)
|
||||
|
@ -737,7 +737,7 @@ bool turn_info::move_unit_along_current_route(bool check_shroud)
|
|||
|
||||
selected_hex_ = gamemap::location();
|
||||
gui_.select_hex(gamemap::location());
|
||||
|
||||
|
||||
gui_.set_route(NULL);
|
||||
gui_.set_paths(NULL);
|
||||
current_paths_ = paths();
|
||||
|
@ -758,10 +758,10 @@ bool turn_info::move_unit_along_current_route(bool check_shroud)
|
|||
selected_hex_ = dst;
|
||||
gui_.select_hex(dst);
|
||||
}
|
||||
|
||||
|
||||
current_route_.steps.clear();
|
||||
show_attack_options(u);
|
||||
|
||||
|
||||
if(current_paths_.routes.empty() == false) {
|
||||
current_paths_.routes[dst] = paths::route();
|
||||
selected_hex_ = dst;
|
||||
|
@ -1085,7 +1085,7 @@ bool turn_info::can_execute_command(hotkey::HOTKEY_COMMAND command) const
|
|||
if (i == units_.end()) return false;
|
||||
return i->second.move_interrupted();
|
||||
}
|
||||
|
||||
|
||||
case hotkey::HOTKEY_DELAY_SHROUD:
|
||||
return !browse_ && (current_team().uses_fog() || current_team().uses_shroud());
|
||||
case hotkey::HOTKEY_UPDATE_SHROUD:
|
||||
|
@ -1133,7 +1133,7 @@ namespace {
|
|||
private:
|
||||
const turn_info& info_;
|
||||
};
|
||||
|
||||
|
||||
struct not_in_context_menu {
|
||||
not_in_context_menu(const turn_info& info) : info_(info) {}
|
||||
bool operator()(const std::string& str) const {
|
||||
|
@ -1171,7 +1171,7 @@ void turn_info::show_menu(const std::vector<std::string>& items_arg, int xloc, i
|
|||
has_image = true;
|
||||
str << IMAGE_PREFIX << img << COLUMN_SEPARATOR;
|
||||
}
|
||||
|
||||
|
||||
str << hk.get_description() << COLUMN_SEPARATOR << hk.get_name();
|
||||
|
||||
menu.push_back(str.str());
|
||||
|
@ -1200,7 +1200,7 @@ bool turn_info::unit_in_cycle(unit_map::const_iterator it) const
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void turn_info::cycle_units()
|
||||
|
@ -1312,7 +1312,7 @@ void turn_info::end_turn()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ask for confirmation if units still have movement left
|
||||
if(preferences::yellow_confirm() && partmoved_units) {
|
||||
const int res = gui::show_dialog(gui_,NULL,"",_("Some units have movement left. Do you really want to end your turn?"),gui::YES_NO);
|
||||
|
@ -1372,7 +1372,7 @@ void turn_info::unit_hold_position()
|
|||
un->second.set_user_end_turn(true);
|
||||
cycle_units();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void turn_info::end_unit_turn()
|
||||
|
@ -1440,16 +1440,16 @@ void turn_info::undo()
|
|||
LOG_STREAM(err, engine) << "Illegal 'undo' found. Possible abuse of [allow_undo]?\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(map_.is_village(route.front())) {
|
||||
get_village(route.front(),teams_,action.original_village_owner,units_);
|
||||
}
|
||||
|
||||
|
||||
action.starting_moves = u->second.movement_left();
|
||||
|
||||
|
||||
unit un = u->second;
|
||||
un.set_goto(gamemap::location());
|
||||
|
||||
|
||||
gui_.hide_unit(u->first,true);
|
||||
unit_display::move_unit(gui_,map_,route,un,status_.get_time_of_day(),units_,teams_);
|
||||
gui_.hide_unit(gamemap::location());
|
||||
|
@ -1527,12 +1527,12 @@ void turn_info::redo()
|
|||
wassert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
action.starting_moves = u->second.movement_left();
|
||||
|
||||
|
||||
unit un = u->second;
|
||||
un.set_goto(gamemap::location());
|
||||
|
||||
|
||||
gui_.hide_unit(u->first,true);
|
||||
unit_display::move_unit(gui_,map_,route,un,status_.get_time_of_day(),units_,teams_);
|
||||
gui_.hide_unit(gamemap::location());
|
||||
|
@ -1540,13 +1540,13 @@ void turn_info::redo()
|
|||
units_.erase(u);
|
||||
un.set_movement(starting_moves);
|
||||
units_.insert(std::pair<gamemap::location,unit>(route.back(),un));
|
||||
|
||||
|
||||
if(map_.is_village(route.back())) {
|
||||
get_village(route.back(),teams_,un.side()-1,units_);
|
||||
}
|
||||
|
||||
|
||||
gui_.draw_tile(route.back().x,route.back().y);
|
||||
|
||||
|
||||
recorder.add_movement(route.front(),route.back());
|
||||
}
|
||||
gui_.invalidate_unit();
|
||||
|
@ -1608,7 +1608,7 @@ void turn_info::save_game(const std::string& message, gui::DIALOG_TYPE dialog_ty
|
|||
{
|
||||
std::stringstream stream;
|
||||
|
||||
const std::string ellipsed_name = font::make_text_ellipsis(state_of_game_.label,
|
||||
const std::string ellipsed_name = font::make_text_ellipsis(state_of_game_.label,
|
||||
font::SIZE_NORMAL, 200);
|
||||
stream << ellipsed_name << " " << _("Turn")
|
||||
<< " " << status_.turn();
|
||||
|
@ -2104,7 +2104,7 @@ void turn_info::recall()
|
|||
|
||||
undo_stack_.push_back(undo_action(un,loc,res));
|
||||
redo_stack_.clear();
|
||||
|
||||
|
||||
recall_list.erase(recall_list.begin()+res);
|
||||
gui_.invalidate_game_status();
|
||||
}
|
||||
|
@ -2237,7 +2237,7 @@ void turn_info::unit_list()
|
|||
std::vector<gamemap::location> locations_list;
|
||||
std::vector<unit> units_list;
|
||||
for(unit_map::const_iterator i = units_.begin(); i != units_.end(); ++i) {
|
||||
if(i->second.side() != (gui_.viewing_team()+1))
|
||||
if(i->second.side() != (gui_.viewing_team()+1))
|
||||
continue;
|
||||
|
||||
std::stringstream row;
|
||||
|
@ -2433,9 +2433,9 @@ void turn_info::do_search(const std::string& new_search)
|
|||
{
|
||||
if(new_search.empty() == false && new_search != last_search_)
|
||||
last_search_ = new_search;
|
||||
|
||||
|
||||
if(last_search_.empty()) return;
|
||||
|
||||
|
||||
bool found = false;
|
||||
gamemap::location loc = last_search_hit_;
|
||||
//If this is a location search, just center on that location.
|
||||
|
@ -2458,7 +2458,7 @@ void turn_info::do_search(const std::string& new_search)
|
|||
loc.x = (loc.x + 1) % map_.x();
|
||||
if(loc.x == 0)
|
||||
loc.y = (loc.y + 1) % map_.y();
|
||||
|
||||
|
||||
//Search label
|
||||
const std::string label = gui_.labels().get_label(loc);
|
||||
if(label.empty() == false) {
|
||||
|
@ -2518,7 +2518,7 @@ void turn_info::do_command(const std::string& str)
|
|||
}
|
||||
} else if (teams_[index].is_ai()) {
|
||||
teams_[index].make_human();
|
||||
}
|
||||
}
|
||||
} else if (cmd == "theme") {
|
||||
int action = 0;
|
||||
std::vector<std::string> options=theme::get_known_themes();
|
||||
|
@ -2526,7 +2526,7 @@ void turn_info::do_command(const std::string& str)
|
|||
action = gui::show_dialog(gui_,NULL,"",current_theme,gui::OK_CANCEL,&options);
|
||||
if(action >-1){
|
||||
preferences::set_theme(options[action]);
|
||||
//it would be preferable for the new theme to take effect
|
||||
//it would be preferable for the new theme to take effect
|
||||
//immediately, however, this will have to do for now.
|
||||
gui::show_dialog(gui_,NULL,"",_("New theme will take effect on next new or loaded game."),gui::MESSAGE);
|
||||
}
|
||||
|
@ -2644,12 +2644,12 @@ bool turn_info::enemies_visible() const
|
|||
// If we aren't using fog/shroud, this is easy :)
|
||||
if(current_team().uses_fog() == false && current_team().uses_shroud() == false)
|
||||
return true;
|
||||
|
||||
|
||||
//See if any enemies are visible
|
||||
for(unit_map::const_iterator u = units_.begin(); u != units_.end(); ++u)
|
||||
if(current_team().is_enemy(u->second.side()) && !gui_.fogged(u->first.x,u->first.y))
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2657,7 +2657,7 @@ bool turn_info::enemies_visible() const
|
|||
void turn_info::show_enemy_moves(bool ignore_units)
|
||||
{
|
||||
all_paths_ = paths();
|
||||
|
||||
|
||||
// Compute enemy movement positions
|
||||
for(unit_map::iterator u = units_.begin(); u != units_.end(); ++u) {
|
||||
if(current_team().is_enemy(u->second.side()) && !gui_.fogged(u->first.x,u->first.y) && !u->second.stone()) {
|
||||
|
@ -2668,7 +2668,7 @@ void turn_info::show_enemy_moves(bool ignore_units)
|
|||
units.insert(*u);
|
||||
const paths& path = paths(map_,status_,gameinfo_,ignore_units?units:units_,
|
||||
u->first,teams_,is_skirmisher,teleports);
|
||||
|
||||
|
||||
for (paths::routes_map::const_iterator route = path.routes.begin(); route != path.routes.end(); ++route) {
|
||||
// map<...>::operator[](const key_type& key) inserts key into
|
||||
// the map with a default instance of value_type
|
||||
|
@ -2676,7 +2676,7 @@ void turn_info::show_enemy_moves(bool ignore_units)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gui_.set_paths(&all_paths_);
|
||||
}
|
||||
|
||||
|
@ -2689,7 +2689,7 @@ void turn_info::toggle_shroud_updates() {
|
|||
|
||||
bool turn_info::clear_shroud()
|
||||
{
|
||||
bool cleared = current_team().auto_shroud_updates() &&
|
||||
bool cleared = current_team().auto_shroud_updates() &&
|
||||
::clear_shroud(gui_,status_,map_,gameinfo_,units_,teams_,team_num_-1);
|
||||
enemies_visible_ = enemies_visible();
|
||||
return cleared;
|
||||
|
@ -2959,7 +2959,7 @@ void turn_info::tab_textbox()
|
|||
|
||||
if(last_space == std::string::npos) {
|
||||
beginning = true;
|
||||
semiword = text;
|
||||
semiword = text;
|
||||
}else{
|
||||
beginning = false;
|
||||
semiword.assign(text,last_space+1,text.size());
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue