fixed bug where trying to move onto a tile occupied by an enemy...

...but under fog of war would allow one to see where enemy units are
under the fog
This commit is contained in:
Dave White 2004-09-11 02:55:46 +00:00
parent ee4971f43f
commit 680646b25e
11 changed files with 407 additions and 295 deletions

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -459,16 +459,14 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
if (etags --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
test -f $$subdir/TAGS && \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
@ -478,11 +476,9 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
@ -594,7 +590,7 @@ distcheck: dist
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(AMTAR) xf - ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac

15
aclocal.m4 vendored
View file

@ -1,4 +1,4 @@
# generated automatically by aclocal 1.8.5 -*- Autoconf -*-
# generated automatically by aclocal 1.8.3 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
# Free Software Foundation, Inc.
@ -40,7 +40,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.8"])
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.8.5])])
[AM_AUTOMAKE_VERSION([1.8.3])])
# AM_AUX_DIR_EXPAND
@ -266,14 +266,9 @@ AC_CACHE_CHECK([dependency style of $depcc],
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
# (even with -Werror). So we grep stderr for any message
# that says an option was ignored.
if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi

436
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -1148,16 +1148,14 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
if (etags --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
test -f $$subdir/TAGS && \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
@ -1167,11 +1165,9 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)

View file

@ -223,17 +223,9 @@ void turn_info::handle_event(const SDL_Event& event)
if(new_path_turns != path_turns_) {
path_turns_ = new_path_turns;
unit_map::iterator u = units_.find(selected_hex_);
if(u == units_.end() || gui_.fogged(u->first.x,u->first.y)) {
u = units_.find(last_hex_);
if(u != units_.end() && (u->second.side() == team_num_ || gui_.fogged(u->first.x,u->first.y))) {
u = units_.end();
}
} else if(u->second.side() != team_num_ || gui_.fogged(u->first.x,u->first.y)) {
u = units_.end();
}
const unit_map::iterator u = selected_unit();
if(u != units_.end()) {
if(u != units_.end() && u->second.side() == team_num_) {
const bool ignore_zocs = u->second.type().is_skirmisher();
const bool teleport = u->second.type().teleports();
current_paths_ = paths(map_,status_,gameinfo_,units_,u->first,
@ -304,8 +296,8 @@ void turn_info::mouse_motion(const SDL_MouseMotionEvent& event)
//see if we should show the normal cursor, the movement cursor, or
//the attack cursor
const unit_map::const_iterator selected_unit = units_.find(selected_hex_);
const unit_map::const_iterator mouseover_unit = units_.find(new_hex);
const unit_map::const_iterator selected_unit = find_unit(selected_hex_);
const unit_map::const_iterator mouseover_unit = find_unit(new_hex);
if(selected_unit != units_.end() && current_paths_.routes.count(new_hex)) {
if(mouseover_unit == units_.end()) {
cursor::set(cursor::MOVE);
@ -331,15 +323,12 @@ void turn_info::mouse_motion(const SDL_MouseMotionEvent& event)
!current_paths_.routes.empty() && map_.on_board(selected_hex_) &&
map_.on_board(new_hex)) {
unit_map::const_iterator un = find_visible_unit(units_,selected_hex_,map_,
status_.get_time_of_day().lawful_bonus,teams_,current_team);
const unit_map::const_iterator dest_un = find_visible_unit(units_,new_hex,map_,
status_.get_time_of_day().lawful_bonus,teams_,current_team);
unit_map::const_iterator un = find_unit(selected_hex_);
const unit_map::const_iterator dest_un = find_unit(new_hex);
if(un != units_.end() && dest_un == units_.end()) {
const shortest_path_calculator calc(un->second,current_team,
units_,teams_,map_,status_);
visible_units(),teams_,map_,status_);
const bool can_teleport = un->second.type().teleports();
const std::set<gamemap::location>* teleports = NULL;
@ -357,15 +346,13 @@ void turn_info::mouse_motion(const SDL_MouseMotionEvent& event)
current_route_.move_left = route_turns_to_complete(un->second,map_,current_route_);
if(!browse_)
if(!browse_) {
gui_.set_route(&current_route_);
}
}
}
unit_map::iterator un = find_visible_unit(units_,
new_hex,
map_,
status_.get_time_of_day().lawful_bonus,teams_,current_team);
unit_map::iterator un = find_unit(new_hex);
if(un != units_.end() && un->second.side() != team_num_ &&
current_paths_.routes.empty() && !gui_.fogged(un->first.x,un->first.y)) {
@ -554,9 +541,7 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event)
gamemap::location hex = gui_.hex_clicked_on(event.x,event.y);
unit_map::iterator u = find_visible_unit(units_,
selected_hex_, map_,
status_.get_time_of_day().lawful_bonus,teams_,current_team);
unit_map::iterator u = find_unit(selected_hex_);
//if the unit is selected and then itself clicked on,
//any goto command is cancelled
@ -570,8 +555,7 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event)
route = enemy_paths_ ? current_paths_.routes.end() :
current_paths_.routes.find(hex);
unit_map::iterator enemy = find_visible_unit(units_, hex, map_,
status_.get_time_of_day().lawful_bonus,teams_,current_team);
unit_map::iterator enemy = find_unit(hex);
//see if we're trying to attack an enemy
if(route != current_paths_.routes.end() && enemy != units_.end() &&
@ -782,9 +766,7 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event)
current_route_.steps.clear();
gui_.set_route(NULL);
const unit_map::iterator it = find_visible_unit(units_,
hex, map_,
status_.get_time_of_day().lawful_bonus,teams_,current_team);
const unit_map::iterator it = find_unit(hex);
if(it != units_.end() && it->second.side() == team_num_ && !gui_.fogged(it->first.x,it->first.y)) {
const bool ignore_zocs = it->second.type().is_skirmisher();
@ -802,7 +784,7 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event)
const gamemap::location go_to = u.get_goto();
if(map_.on_board(go_to)) {
const shortest_path_calculator calc(u,current_team,
units_,teams_,map_,status_);
visible_units(),teams_,map_,status_);
const std::set<gamemap::location>* teleports = NULL;
@ -845,7 +827,7 @@ void turn_info::move_unit_to_loc(const unit_map::const_iterator& ui, const gamem
assert(ui != units_.end());
unit u = ui->second;
const shortest_path_calculator calc(u,current_team(),units_,teams_,map_,status_);
const shortest_path_calculator calc(u,current_team(),visible_units(),teams_,map_,status_);
const std::set<gamemap::location>* teleports = NULL;
@ -1429,6 +1411,64 @@ void turn_info::save_game(const std::string& message, gui::DIALOG_TYPE dialog_ty
}
}
unit_map::const_iterator turn_info::find_unit(const gamemap::location& hex) const
{
if(gui_.fogged(hex.x,hex.y)) {
return units_.end();
}
return find_visible_unit(units_,hex,map_,status_.get_time_of_day().lawful_bonus,teams_,viewing_team());
}
unit_map::iterator turn_info::find_unit(const gamemap::location& hex)
{
if(gui_.fogged(hex.x,hex.y)) {
return units_.end();
}
return find_visible_unit(units_,hex,map_,status_.get_time_of_day().lawful_bonus,teams_,viewing_team());
}
unit_map::const_iterator turn_info::selected_unit() const
{
unit_map::const_iterator res = find_unit(selected_hex_);
if(res != units_.end()) {
return res;
} else {
return find_unit(last_hex_);
}
}
unit_map::iterator turn_info::selected_unit()
{
unit_map::iterator res = find_unit(selected_hex_);
if(res != units_.end()) {
return res;
} else {
return find_unit(last_hex_);
}
}
unit_map::const_iterator turn_info::current_unit() const
{
unit_map::const_iterator res = find_unit(last_hex_);
if(res != units_.end()) {
return res;
} else {
return find_unit(selected_hex_);
}
}
unit_map::iterator turn_info::current_unit()
{
unit_map::iterator res = find_unit(last_hex_);
if(res != units_.end()) {
return res;
} else {
return find_unit(selected_hex_);
}
}
void turn_info::write_game_snapshot(config& start) const
{
start.values = level_->values;
@ -2321,46 +2361,6 @@ void turn_info::continue_move()
move_unit_to_loc(i,i->second.get_interrupted_move(),true);
}
unit_map::iterator turn_info::current_unit()
{
unit_map::iterator i = units_.end();
if(gui_.fogged(last_hex_.x,last_hex_.y) == false){
i = find_visible_unit(units_,last_hex_,map_,
status_.get_time_of_day().lawful_bonus,teams_,current_team());
}
if(gui_.fogged(selected_hex_.x,selected_hex_.y) == false){
if(i == units_.end()) {
unit_map::iterator i = find_visible_unit(units_, selected_hex_,map_,
status_.get_time_of_day().lawful_bonus,teams_,current_team());
}
}
return i;
}
unit_map::const_iterator turn_info::current_unit() const
{
unit_map::const_iterator i = units_.end();
if(gui_.fogged(last_hex_.x,last_hex_.y)==false){
i = find_visible_unit(units_,
last_hex_, map_,
status_.get_time_of_day().lawful_bonus,teams_,teams_[team_num_-1]);
}
if(gui_.fogged(selected_hex_.x,selected_hex_.y)==false){
if(i == units_.end()) {
i = find_visible_unit(units_, selected_hex_,
map_,
status_.get_time_of_day().lawful_bonus,teams_,teams_[team_num_-1]);
}
}
return i;
}
turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg, network::connection from, std::deque<config>& backlog)
{
if(cfg.child("observer") != NULL) {
@ -2568,3 +2568,22 @@ void turn_info::enter_textbox()
close_textbox();
}
const unit_map& turn_info::visible_units() const
{
if(viewing_team().uses_shroud() == false && viewing_team().uses_fog() == false) {
std::cerr << "all units are visible...\n";
return units_;
}
visible_units_.clear();
for(unit_map::const_iterator i = units_.begin(); i != units_.end(); ++i) {
if(gui_.fogged(i->first.x,i->first.y) == false) {
visible_units_.insert(*i);
}
}
std::cerr << "number of visible units: " << visible_units_.size() << "\n";
return visible_units_;
}

View file

@ -120,6 +120,18 @@ private:
team& current_team() { return teams_[team_num_-1]; }
const team& current_team() const { return teams_[team_num_-1]; }
team& viewing_team() { return teams_[gui_.viewing_team()]; }
const team& viewing_team() const { return teams_[gui_.viewing_team()]; }
unit_map::const_iterator find_unit(const gamemap::location& hex) const;
unit_map::iterator find_unit(const gamemap::location& hex);
unit_map::const_iterator selected_unit() const;
unit_map::iterator selected_unit();
unit_map::iterator current_unit();
unit_map::const_iterator current_unit() const;
void write_game_snapshot(config& cfg) const;
bool unit_in_cycle(unit_map::const_iterator it) const;
@ -177,9 +189,6 @@ private:
bool clear_shroud();
void clear_undo_stack();
unit_map::iterator current_unit();
unit_map::const_iterator current_unit() const;
std::vector<std::string> create_unit_table(const statistics::stats::str_int_map& m);
bool enemies_visible() const;
@ -197,6 +206,9 @@ private:
std::vector<team>& teams_;
int team_num_;
unit_map& units_;
const unit_map& visible_units() const;
mutable unit_map visible_units_;
bool browse_;
bool allow_network_commands_;

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -510,11 +510,9 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -626,11 +626,9 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -491,11 +491,9 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)