made it so moves that do not reveal shroud/fow are undoable
This commit is contained in:
parent
a94de94784
commit
ca91c49140
7 changed files with 67 additions and 19 deletions
|
@ -46,7 +46,7 @@ Defeat:
|
||||||
controller=ai
|
controller=ai
|
||||||
recruitment_pattern=fighter
|
recruitment_pattern=fighter
|
||||||
recruit=Swordsman,Heavy Infantry,Pikeman,Red Mage
|
recruit=Swordsman,Heavy Infantry,Pikeman,Red Mage
|
||||||
gold=200
|
gold=300
|
||||||
team_name=good
|
team_name=good
|
||||||
[/side]
|
[/side]
|
||||||
[side]
|
[side]
|
||||||
|
@ -57,7 +57,7 @@ Defeat:
|
||||||
controller=ai
|
controller=ai
|
||||||
recruit=Troll,Troll Warrior,Blood Bat,Ogre,Wolf Rider
|
recruit=Troll,Troll Warrior,Blood Bat,Ogre,Wolf Rider
|
||||||
gold=150
|
gold=150
|
||||||
income=15
|
{INCOME 0 10 15}
|
||||||
[/side]
|
[/side]
|
||||||
|
|
||||||
[event]
|
[event]
|
||||||
|
|
|
@ -997,29 +997,35 @@ int combat_modifier(const gamestatus& status,
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void clear_shroud_loc(const gamemap& map, team& tm,
|
bool clear_shroud_loc(const gamemap& map, team& tm,
|
||||||
const gamemap::location& loc,
|
const gamemap::location& loc,
|
||||||
std::vector<gamemap::location>* cleared)
|
std::vector<gamemap::location>* cleared)
|
||||||
{
|
{
|
||||||
|
bool result = false;
|
||||||
static gamemap::location adj[7];
|
static gamemap::location adj[7];
|
||||||
get_adjacent_tiles(loc,adj);
|
get_adjacent_tiles(loc,adj);
|
||||||
adj[6] = loc;
|
adj[6] = loc;
|
||||||
for(int i = 0; i != 7; ++i) {
|
for(int i = 0; i != 7; ++i) {
|
||||||
if(map.on_board(adj[i])) {
|
if(map.on_board(adj[i])) {
|
||||||
if(tm.fogged(adj[i].x,adj[i].y)) {
|
if(tm.fogged(adj[i].x,adj[i].y)) {
|
||||||
tm.clear_shroud(adj[i].x,adj[i].y);
|
const bool res = tm.clear_shroud(adj[i].x,adj[i].y) ||
|
||||||
tm.clear_fog(adj[i].x,adj[i].y);
|
tm.clear_fog(adj[i].x,adj[i].y);
|
||||||
|
|
||||||
if(cleared != NULL) {
|
if(res && cleared != NULL) {
|
||||||
cleared->push_back(adj[i]);
|
cleared->push_back(adj[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result |= res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if known_units is not NULL, then the function will return true iff
|
//if known_units is not NULL, then the function will return true iff
|
||||||
//a new unit has been seen
|
//a new unit has been seen. Otherwise it will return true iff some shroud
|
||||||
|
//is cleared
|
||||||
bool clear_shroud_unit(const gamemap& map, const game_data& gamedata,
|
bool clear_shroud_unit(const gamemap& map, const game_data& gamedata,
|
||||||
const unit_map& units, const gamemap::location& loc,
|
const unit_map& units, const gamemap::location& loc,
|
||||||
std::vector<team>& teams, int team,
|
std::vector<team>& teams, int team,
|
||||||
|
@ -1048,7 +1054,11 @@ bool clear_shroud_unit(const gamemap& map, const game_data& gamedata,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if(known_units != NULL) {
|
||||||
|
return false; //no new units spotted
|
||||||
|
} else {
|
||||||
|
return cleared_locations.empty() == false; //we have revealed some tiles
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1059,9 +1069,24 @@ bool clear_shroud(display& disp, const gamemap& map, const game_data& gamedata,
|
||||||
if(teams[team].uses_shroud() == false && teams[team].uses_fog() == false)
|
if(teams[team].uses_shroud() == false && teams[team].uses_fog() == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
unit_map::const_iterator i;
|
||||||
|
for(i = units.begin(); i != units.end(); ++i) {
|
||||||
|
if(i->second.side() == team+1) {
|
||||||
|
|
||||||
|
//we're not really going to mutate the unit, just temporarily
|
||||||
|
//set its moves to maximum, but then switch them back
|
||||||
|
unit& mutable_unit = const_cast<unit&>(i->second);
|
||||||
|
const unit_movement_resetter move_resetter(mutable_unit);
|
||||||
|
|
||||||
|
result |= clear_shroud_unit(map,gamedata,units,i->first,teams,team,NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
teams[team].refog();
|
teams[team].refog();
|
||||||
|
|
||||||
for(unit_map::const_iterator i = units.begin(); i != units.end(); ++i) {
|
for(i = units.begin(); i != units.end(); ++i) {
|
||||||
if(i->second.side() == team+1) {
|
if(i->second.side() == team+1) {
|
||||||
|
|
||||||
//we're not really going to mutate the unit, just temporarily
|
//we're not really going to mutate the unit, just temporarily
|
||||||
|
@ -1075,7 +1100,7 @@ bool clear_shroud(display& disp, const gamemap& map, const game_data& gamedata,
|
||||||
|
|
||||||
disp.recalculate_minimap();
|
disp.recalculate_minimap();
|
||||||
|
|
||||||
return true;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t move_unit(display* disp, const game_data& gamedata, const gamemap& map,
|
size_t move_unit(display* disp, const game_data& gamedata, const gamemap& map,
|
||||||
|
|
|
@ -520,7 +520,12 @@ int play_game(int argc, char** argv)
|
||||||
continue;
|
continue;
|
||||||
} else if(res == gui::CHANGE_LANGUAGE) {
|
} else if(res == gui::CHANGE_LANGUAGE) {
|
||||||
|
|
||||||
const std::vector<std::string>& langs = get_languages(game_config);
|
std::vector<std::string> langs = get_languages(game_config);
|
||||||
|
|
||||||
|
const std::vector<std::string>::iterator current = std::find(langs.begin(),langs.end(),get_language());
|
||||||
|
if(current != langs.end())
|
||||||
|
*current = "*" + *current;
|
||||||
|
|
||||||
const int res = gui::show_dialog(disp,NULL,"",
|
const int res = gui::show_dialog(disp,NULL,"",
|
||||||
string_table["language_button"] + ":",
|
string_table["language_button"] + ":",
|
||||||
gui::OK_CANCEL,&langs);
|
gui::OK_CANCEL,&langs);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
CHARSET charset_used = CHARSET_LATIN1;
|
CHARSET charset_used = CHARSET_LATIN1;
|
||||||
|
std::string current_language;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHARSET charset() { return charset_used; }
|
CHARSET charset() { return charset_used; }
|
||||||
|
@ -61,6 +62,8 @@ bool internal_set_language(const std::string& locale, config& cfg)
|
||||||
for(config::child_list::const_iterator i = lang.begin(); i != lang.end(); ++i) {
|
for(config::child_list::const_iterator i = lang.begin(); i != lang.end(); ++i) {
|
||||||
if((**i)["id"] == locale || (**i)["language"] == locale) {
|
if((**i)["id"] == locale || (**i)["language"] == locale) {
|
||||||
|
|
||||||
|
current_language = (**i)["language"];
|
||||||
|
|
||||||
const std::string& enc = (**i)["encoding"];
|
const std::string& enc = (**i)["encoding"];
|
||||||
if(enc == "UTF-8") {
|
if(enc == "UTF-8") {
|
||||||
charset_used = CHARSET_UTF8;
|
charset_used = CHARSET_UTF8;
|
||||||
|
@ -94,6 +97,8 @@ bool set_language(const std::string& locale, config& cfg)
|
||||||
return internal_set_language(locale,cfg);
|
return internal_set_language(locale,cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& get_language() { return current_language; }
|
||||||
|
|
||||||
std::string get_locale()
|
std::string get_locale()
|
||||||
{
|
{
|
||||||
//TODO: Add in support for querying the locale on Windows
|
//TODO: Add in support for querying the locale on Windows
|
||||||
|
|
|
@ -44,6 +44,9 @@ std::vector<std::string> get_languages(config& cfg);
|
||||||
//or the 2-letter version, like 'en'.
|
//or the 2-letter version, like 'en'.
|
||||||
bool set_language(const std::string& locale, config& cfg);
|
bool set_language(const std::string& locale, config& cfg);
|
||||||
|
|
||||||
|
//function which returns the name of the language currently used
|
||||||
|
const std::string& get_language();
|
||||||
|
|
||||||
//function which attempts to query and return the locale on the system
|
//function which attempts to query and return the locale on the system
|
||||||
std::string get_locale();
|
std::string get_locale();
|
||||||
|
|
||||||
|
|
22
src/team.cpp
22
src/team.cpp
|
@ -430,10 +430,10 @@ bool team::shrouded(size_t x, size_t y) const
|
||||||
return !shroud_[x][y];
|
return !shroud_[x][y];
|
||||||
}
|
}
|
||||||
|
|
||||||
void team::clear_shroud(size_t x, size_t y)
|
bool team::clear_shroud(size_t x, size_t y)
|
||||||
{
|
{
|
||||||
if(info_.use_shroud == false)
|
if(info_.use_shroud == false)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if(x >= shroud_.size())
|
if(x >= shroud_.size())
|
||||||
shroud_.resize(x+1);
|
shroud_.resize(x+1);
|
||||||
|
@ -441,7 +441,12 @@ void team::clear_shroud(size_t x, size_t y)
|
||||||
if(y >= shroud_[x].size())
|
if(y >= shroud_[x].size())
|
||||||
shroud_[x].resize(y+1);
|
shroud_[x].resize(y+1);
|
||||||
|
|
||||||
shroud_[x][y] = true;
|
if(shroud_[x][y] == false) {
|
||||||
|
shroud_[x][y] = true;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool team::uses_fog() const
|
bool team::uses_fog() const
|
||||||
|
@ -466,10 +471,10 @@ bool team::fogged(size_t x, size_t y) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void team::clear_fog(size_t x, size_t y)
|
bool team::clear_fog(size_t x, size_t y)
|
||||||
{
|
{
|
||||||
if(info_.use_fog == false)
|
if(info_.use_fog == false)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if(x >= fog_.size())
|
if(x >= fog_.size())
|
||||||
fog_.resize(x+1);
|
fog_.resize(x+1);
|
||||||
|
@ -477,7 +482,12 @@ void team::clear_fog(size_t x, size_t y)
|
||||||
if(y >= fog_[x].size())
|
if(y >= fog_[x].size())
|
||||||
fog_[x].resize(y+1);
|
fog_[x].resize(y+1);
|
||||||
|
|
||||||
fog_[x][y] = true;
|
if(fog_[x][y] == false) {
|
||||||
|
fog_[x][y] = true;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void team::refog()
|
void team::refog()
|
||||||
|
|
|
@ -103,11 +103,11 @@ public:
|
||||||
|
|
||||||
bool uses_shroud() const;
|
bool uses_shroud() const;
|
||||||
bool shrouded(size_t x, size_t y) const;
|
bool shrouded(size_t x, size_t y) const;
|
||||||
void clear_shroud(size_t x, size_t y);
|
bool clear_shroud(size_t x, size_t y);
|
||||||
|
|
||||||
bool uses_fog() const;
|
bool uses_fog() const;
|
||||||
bool fogged(size_t x, size_t y) const;
|
bool fogged(size_t x, size_t y) const;
|
||||||
void clear_fog(size_t x, size_t y);
|
bool clear_fog(size_t x, size_t y);
|
||||||
void refog();
|
void refog();
|
||||||
|
|
||||||
const std::string& music() const;
|
const std::string& music() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue