made it so moves that do not reveal shroud/fow are undoable

This commit is contained in:
uid68803 2004-01-08 19:42:18 +00:00
parent a94de94784
commit ca91c49140
7 changed files with 67 additions and 19 deletions

View file

@ -46,7 +46,7 @@ Defeat:
controller=ai
recruitment_pattern=fighter
recruit=Swordsman,Heavy Infantry,Pikeman,Red Mage
gold=200
gold=300
team_name=good
[/side]
[side]
@ -57,7 +57,7 @@ Defeat:
controller=ai
recruit=Troll,Troll Warrior,Blood Bat,Ogre,Wolf Rider
gold=150
income=15
{INCOME 0 10 15}
[/side]
[event]

View file

@ -997,29 +997,35 @@ int combat_modifier(const gamestatus& status,
namespace {
void clear_shroud_loc(const gamemap& map, team& tm,
bool clear_shroud_loc(const gamemap& map, team& tm,
const gamemap::location& loc,
std::vector<gamemap::location>* cleared)
{
bool result = false;
static gamemap::location adj[7];
get_adjacent_tiles(loc,adj);
adj[6] = loc;
for(int i = 0; i != 7; ++i) {
if(map.on_board(adj[i])) {
if(tm.fogged(adj[i].x,adj[i].y)) {
tm.clear_shroud(adj[i].x,adj[i].y);
tm.clear_fog(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);
if(cleared != NULL) {
if(res && cleared != NULL) {
cleared->push_back(adj[i]);
}
result |= res;
}
}
}
return result;
}
//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,
const unit_map& units, const gamemap::location& loc,
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)
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();
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) {
//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();
return true;
return result;
}
size_t move_unit(display* disp, const game_data& gamedata, const gamemap& map,

View file

@ -520,7 +520,12 @@ int play_game(int argc, char** argv)
continue;
} 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,"",
string_table["language_button"] + ":",
gui::OK_CANCEL,&langs);

View file

@ -22,6 +22,7 @@
namespace {
CHARSET charset_used = CHARSET_LATIN1;
std::string current_language;
}
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) {
if((**i)["id"] == locale || (**i)["language"] == locale) {
current_language = (**i)["language"];
const std::string& enc = (**i)["encoding"];
if(enc == "UTF-8") {
charset_used = CHARSET_UTF8;
@ -94,6 +97,8 @@ bool set_language(const std::string& locale, config& cfg)
return internal_set_language(locale,cfg);
}
const std::string& get_language() { return current_language; }
std::string get_locale()
{
//TODO: Add in support for querying the locale on Windows

View file

@ -44,6 +44,9 @@ std::vector<std::string> get_languages(config& cfg);
//or the 2-letter version, like 'en'.
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
std::string get_locale();

View file

@ -430,10 +430,10 @@ bool team::shrouded(size_t x, size_t y) const
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)
return;
return false;
if(x >= shroud_.size())
shroud_.resize(x+1);
@ -441,7 +441,12 @@ void team::clear_shroud(size_t x, size_t y)
if(y >= shroud_[x].size())
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
@ -466,10 +471,10 @@ bool team::fogged(size_t x, size_t y) const
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)
return;
return false;
if(x >= fog_.size())
fog_.resize(x+1);
@ -477,7 +482,12 @@ void team::clear_fog(size_t x, size_t y)
if(y >= fog_[x].size())
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()

View file

@ -103,11 +103,11 @@ public:
bool uses_shroud() 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 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();
const std::string& music() const;