1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00

- (linux) replaced Genius with VCAI

- gcc set to c++0x mode
- most of gcc warnings fixed
- replaced boost::assign with initialization lists (if available in compiler)
- new cheat code: vcmiarmenelos - build everything
- updated linux readme
- minor fixes, applied patch for #98
This commit is contained in:
Ivan Savenko 2012-02-16 17:10:58 +00:00
parent 7a66c1bf2b
commit 0c3e88226f
25 changed files with 1315 additions and 621 deletions

View File

@ -1 +1 @@
SUBDIRS = StupidAI EmptyAI GeniusAI
SUBDIRS = StupidAI EmptyAI VCAI

View File

@ -237,7 +237,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = StupidAI EmptyAI GeniusAI
SUBDIRS = StupidAI EmptyAI VCAI
all: all-recursive
.SUFFIXES:

13
AI/VCAI/Makefile.am Normal file
View File

@ -0,0 +1,13 @@
vcmiaidir = $(VCMI_AI_LIBS_DIR)
BUILT_SOURCES = StdInc.h.gch
StdInc.h.gch: StdInc.h
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
vcmiai_LTLIBRARIES = libVCAI.la
libVCAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
libVCAI_la_CXXFLAGS = -DVCMI_DLL
libVCAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
libVCAI_la_SOURCES = \
main.cpp \
VCAI.cpp \
VCAI.h

615
AI/VCAI/Makefile.in Normal file
View File

@ -0,0 +1,615 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = AI/VCAI
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/aclocal/m4/ax_boost_base.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_filesystem.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_iostreams.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_program_options.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_system.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_thread.m4 \
$(top_srcdir)/aclocal/m4/ax_compiler_vendor.m4 \
$(top_srcdir)/aclocal/m4/libtool.m4 \
$(top_srcdir)/aclocal/m4/ltoptions.m4 \
$(top_srcdir)/aclocal/m4/ltsugar.m4 \
$(top_srcdir)/aclocal/m4/ltversion.m4 \
$(top_srcdir)/aclocal/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(vcmiaidir)"
LTLIBRARIES = $(vcmiai_LTLIBRARIES)
libVCAI_la_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la
am_libVCAI_la_OBJECTS = libVCAI_la-main.lo libVCAI_la-VCAI.lo
libVCAI_la_OBJECTS = $(am_libVCAI_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
libVCAI_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libVCAI_la_CXXFLAGS) \
$(CXXFLAGS) $(libVCAI_la_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_$(V))
am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
am__v_CXX_0 = @echo " CXX " $@;
AM_V_at = $(am__v_at_$(V))
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
am__v_at_0 = @
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_$(V))
am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
am__v_CXXLD_0 = @echo " CXXLD " $@;
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_$(V))
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
am__v_CC_0 = @echo " CC " $@;
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_$(V))
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
am__v_CCLD_0 = @echo " CCLD " $@;
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libVCAI_la_SOURCES)
DIST_SOURCES = $(libVCAI_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
BOOST_FILESYSTEM_LIB = @BOOST_FILESYSTEM_LIB@
BOOST_IOSTREAMS_LIB = @BOOST_IOSTREAMS_LIB@
BOOST_LDFLAGS = @BOOST_LDFLAGS@
BOOST_PROGRAM_OPTIONS_LIB = @BOOST_PROGRAM_OPTIONS_LIB@
BOOST_SYSTEM_LIB = @BOOST_SYSTEM_LIB@
BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FFMPEG_CXXFLAGS = @FFMPEG_CXXFLAGS@
FFMPEG_LIBS = @FFMPEG_LIBS@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_CXXFLAGS = @SDL_CXXFLAGS@
SDL_LIBS = @SDL_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VCMI_AI_LIBS_DIR = @VCMI_AI_LIBS_DIR@
VCMI_SCRIPTING_LIBS_DIR = @VCMI_SCRIPTING_LIBS_DIR@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
vcmiaidir = $(VCMI_AI_LIBS_DIR)
BUILT_SOURCES = StdInc.h.gch
vcmiai_LTLIBRARIES = libVCAI.la
libVCAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
libVCAI_la_CXXFLAGS = -DVCMI_DLL
libVCAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
libVCAI_la_SOURCES = \
main.cpp \
VCAI.cpp \
VCAI.h
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu AI/VCAI/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu AI/VCAI/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-vcmiaiLTLIBRARIES: $(vcmiai_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(vcmiaidir)" || $(MKDIR_P) "$(DESTDIR)$(vcmiaidir)"
@list='$(vcmiai_LTLIBRARIES)'; test -n "$(vcmiaidir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(vcmiaidir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(vcmiaidir)"; \
}
uninstall-vcmiaiLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(vcmiai_LTLIBRARIES)'; test -n "$(vcmiaidir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(vcmiaidir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(vcmiaidir)/$$f"; \
done
clean-vcmiaiLTLIBRARIES:
-test -z "$(vcmiai_LTLIBRARIES)" || rm -f $(vcmiai_LTLIBRARIES)
@list='$(vcmiai_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libVCAI.la: $(libVCAI_la_OBJECTS) $(libVCAI_la_DEPENDENCIES)
$(AM_V_CXXLD)$(libVCAI_la_LINK) -rpath $(vcmiaidir) $(libVCAI_la_OBJECTS) $(libVCAI_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libVCAI_la-VCAI.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libVCAI_la-main.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
libVCAI_la-main.lo: main.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libVCAI_la_CXXFLAGS) $(CXXFLAGS) -MT libVCAI_la-main.lo -MD -MP -MF $(DEPDIR)/libVCAI_la-main.Tpo -c -o libVCAI_la-main.lo `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libVCAI_la-main.Tpo $(DEPDIR)/libVCAI_la-main.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='main.cpp' object='libVCAI_la-main.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libVCAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libVCAI_la-main.lo `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
libVCAI_la-VCAI.lo: VCAI.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libVCAI_la_CXXFLAGS) $(CXXFLAGS) -MT libVCAI_la-VCAI.lo -MD -MP -MF $(DEPDIR)/libVCAI_la-VCAI.Tpo -c -o libVCAI_la-VCAI.lo `test -f 'VCAI.cpp' || echo '$(srcdir)/'`VCAI.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libVCAI_la-VCAI.Tpo $(DEPDIR)/libVCAI_la-VCAI.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='VCAI.cpp' object='libVCAI_la-VCAI.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libVCAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libVCAI_la-VCAI.lo `test -f 'VCAI.cpp' || echo '$(srcdir)/'`VCAI.cpp
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(vcmiaidir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-generic clean-libtool clean-vcmiaiLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-vcmiaiLTLIBRARIES
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-vcmiaiLTLIBRARIES
.MAKE: all check install install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-vcmiaiLTLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip install-vcmiaiLTLIBRARIES installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-vcmiaiLTLIBRARIES
StdInc.h.gch: StdInc.h
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -91,17 +91,19 @@ struct AILogger
struct Tab
{
Tab()
{
logger.lvl++;
}
~Tab()
{
logger.lvl--;
}
Tab();
~Tab();
};
} logger;
AILogger::Tab::Tab()
{
logger.lvl++;
}
AILogger::Tab::~Tab()
{
logger.lvl--;
}
struct TimeCheck
{
@ -134,7 +136,7 @@ void erase_if(Range &vec, Predicate pred)
struct AtScopeExit
{
boost::function<void()> foo;
AtScopeExit(const boost::function<void()> &FOO) : foo(FOO)
AtScopeExit(const boost::function<void()> &FOO) : foo(FOO)
{}
~AtScopeExit()
{
@ -195,7 +197,7 @@ std::map<const CGObjectInstance *, ObjInfo> helperObjInfo;
template <typename Container, typename Item>
bool remove_if_present(Container &c, const Item &item)
{
Container::iterator i = std::find(c.begin(), c.end(), item);
auto i = std::find(c.begin(), c.end(), item);
if(i != c.end())
{
c.erase(i);
@ -206,7 +208,7 @@ bool remove_if_present(Container &c, const Item &item)
}
template <typename Container, typename Pred>
void erase(Container &c, Pred &pred)
void erase(Container &c, Pred pred)
{
c.erase(boost::remove_if(c, pred), c.end());
}
@ -275,7 +277,7 @@ ui64 evaluateDanger(crint3 tile)
if(t->visitable)
objectDanger = evaluateDanger(t->visitableObjects.front());
int3 guardPos = cb->guardingCreaturePosition(tile);
if(guardPos.x >= 0 && guardPos != tile)
guardDanger = evaluateDanger(guardPos);
@ -366,11 +368,11 @@ void VCAI::heroMoved(const TryMoveHero & details)
LOG_ENTRY;
if(details.result == TryMoveHero::TELEPORTATION)
{
const TerrainTile *t1 = cb->getTile(CGHeroInstance::convertPosition(details.start, false)),
const TerrainTile *t1 = cb->getTile(CGHeroInstance::convertPosition(details.start, false)),
*t2 = cb->getTile(CGHeroInstance::convertPosition(details.end, false));
if(t1->visitable && t2->visitable)
{
const CGObjectInstance *o1 = t1->visitableObjects.front(),
const CGObjectInstance *o1 = t1->visitableObjects.front(),
*o2 = t2->visitableObjects.front();
if(o1->ID == Obj::SUBTERRANEAN_GATE && o2->ID == Obj::SUBTERRANEAN_GATE)
@ -379,7 +381,7 @@ void VCAI::heroMoved(const TryMoveHero & details)
knownSubterraneanGates[o2] = o1;
}
}
}
}
@ -716,7 +718,7 @@ void VCAI::init(CCallback * CB)
LOG_ENTRY;
playerID = myCb->getMyColor();
myCb->waitTillRealize = true;
retreiveVisitableObjs(visitableObjs);
}
@ -877,12 +879,12 @@ void VCAI::recruitCreatures(const CGTownInstance * t)
{
for(int i = 0; i < t->creatures.size(); i++)
{
if(!t->creatures[i].second.size())
if(!t->creatures[i].second.size())
continue;
int count = t->creatures[i].first;
int creID = t->creatures[i].second.back();
const CCreature *c = VLC->creh->creatures[creID];
// const CCreature *c = VLC->creh->creatures[creID];
// if(containsSavedRes(c->cost))
// continue;
@ -897,7 +899,7 @@ void VCAI::recruitCreatures(const CGTownInstance * t)
void VCAI::buildStructure(const CGTownInstance * t)
{
//TODO make *real* town development system
const int buildings[] = {5, 11, 14, 16, 0, 12, 7, 8, 9, 13, 30, 31, 32, 33, 34, 35, 36, 37, 38,
const int buildings[] = {5, 11, 14, 16, 0, 12, 7, 8, 9, 13, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 1, 2, 3, 4, 17, 18, 19, 21, 22, 23};
for(int i = 0; i < ARRAY_COUNT(buildings); i++)
{
@ -906,7 +908,7 @@ void VCAI::buildStructure(const CGTownInstance * t)
const CBuilding *b = VLC->buildh->buildings[t->subID][buildings[i]];
int canBuild = cb->canBuildStructure(t, buildings[i]);
int canBuild = cb->canBuildStructure(t, buildings[i]);
if(canBuild == EBuildingState::ALLOWED)
{
if(!containsSavedRes(b->resources))
@ -946,7 +948,7 @@ bool isSafeToVisit(const CGHeroInstance *h, crint3 tile)
else
return false;
}
return true; //there's no danger
}
@ -980,7 +982,7 @@ void VCAI::wander(const CGHeroInstance * h)
while(1)
{
auto dests = getPossibleDestinations(h);
if(!dests.size())
if(!dests.size())
{
auto compareReinforcements = [h](const CGTownInstance *lhs, const CGTownInstance *rhs) -> bool
{
@ -999,7 +1001,7 @@ void VCAI::wander(const CGHeroInstance * h)
townsNotReachable.push_back(t);
}
}
// towns.erase(boost::remove_if(towns, [=](const CGTownInstance *t) -> bool
// towns.erase(boost::remove_if(towns, [=](const CGTownInstance *t) -> bool
// {
// return !!t->visitingHero || !isReachable(t) || !howManyReinforcementsCanGet(h,t) || vstd::contains(townVisitsThisWeek[h], t);
// }),towns.end());
@ -1114,9 +1116,13 @@ void VCAI::retreiveVisitableObjs(std::vector<const CGObjectInstance *> &out, boo
for(int j = 0; j < cb->getMapSize().y; j++)
for(int k = 0; k < cb->getMapSize().z; k++)
if(const TerrainTile *t = cb->getTile(int3(i,j,k), false))
{
BOOST_FOREACH(const CGObjectInstance *obj, t->visitableObjects)
{
if(includeOwned || obj->tempOwner != playerID)
out.push_back(obj);
}
}
}
std::vector<const CGObjectInstance *> VCAI::getFlaggedObjects() const
@ -1195,7 +1201,11 @@ public:
{
}
const char *what() const OVERRIDE
virtual ~cannotFulfillGoalException() throw ()
{
};
const char *what() const throw () OVERRIDE
{
return msg.c_str();
}
@ -1239,7 +1249,7 @@ bool VCAI::moveHeroToTile(int3 dst, const CGHeroInstance * h)
// {
// int3 afterEndPos = path.nodes[i-2].coord;
// if(afterEndPos.z != endpos.z)
//
//
// }
//tlog0 << "Moving " << h->name << " from " << h->getPosition() << " to " << endpos << std::endl;
cb->moveHero(h,CGHeroInstance::convertPosition(endpos, true));
@ -1367,7 +1377,7 @@ void VCAI::tryRealize(CGoal g)
}
}
break;
case COLLECT_RES:
if(const CGObjectInstance *obj = cb->getObj(g.objid, false))
{
@ -1425,7 +1435,7 @@ std::vector<const CGHeroInstance *> VCAI::getUnblockedHeroes() const
std::vector<const CGHeroInstance *> ret = cb->getHeroesInfo();
BOOST_FOREACH(const CGHeroInstance *h, blockedHeroes)
remove_if_present(ret, h);
return ret;
}
@ -1448,7 +1458,7 @@ void VCAI::endTurn()
tlog1 << "Not having turn at the end of turn???\n";
}
do
do
{
cb->endTurn();
} while(status.haveTurn()); //for some reasons, our request may fail -> stop requesting end of turn only after we've received a confirmation that it's over
@ -1507,7 +1517,7 @@ void VCAI::performTypicalActions()
buildArmyIn(t);
if(!ai->primaryHero() ||
t->getArmyStrength() > ai->primaryHero()->getArmyStrength() * 2 && !isAccessibleForHero(t->visitablePos(), ai->primaryHero()))
(t->getArmyStrength() > ai->primaryHero()->getArmyStrength() * 2 && !isAccessibleForHero(t->visitablePos(), ai->primaryHero())))
{
recruitHero(t);
buildArmyIn(t);
@ -1546,7 +1556,7 @@ int3 VCAI::explorationBestNeighbour(int3 hpos, int radius, const CGHeroInstance
for(auto i = dstToRevealedTiles.begin(); i != dstToRevealedTiles.end(); i++)
{
const CGPathNode *pn = cb->getPathInfo(i->first);
const TerrainTile *t = cb->getTile(i->first);
//const TerrainTile *t = cb->getTile(i->first);
if(best->second < i->second && i->second && pn->reachable() && pn->accessible == CGPathNode::ACCESSIBLE)
best = i;
}
@ -1754,7 +1764,7 @@ int3 whereToExplore(const CGHeroInstance *h)
}
catch(cannotFulfillGoalException &e)
{
std::vector<std::vector<int3> > tiles; //tiles[distance_to_fow], metryka taksówkowa
std::vector<std::vector<int3> > tiles; //tiles[distance_to_fow], metryka taksówkowa
try
{
return ai->explorationNewPoint(radius, h, tiles);
@ -1788,7 +1798,7 @@ TSubgoal CGoal::whatToDoToAchieve()
{
const CVictoryCondition &vc = cb->getMapHeader()->victoryCondition;
EVictoryConditionType::EVictoryConditionType cond = vc.condition;
if(!vc.appliesToAI)
{
//TODO deduce victory from human loss condition
@ -1819,11 +1829,11 @@ TSubgoal CGoal::whatToDoToAchieve()
else
{
auto towns = cb->getTownsInfo();
towns.erase(boost::remove_if(towns,
[](const CGTownInstance *t) -> bool
towns.erase(boost::remove_if(towns,
[](const CGTownInstance *t) -> bool
{
return vstd::contains(t->forbiddenBuildings, EBuilding::GRAIL);
}),
}),
towns.end());
boost::sort(towns, isCloser);
if(towns.size())
@ -1850,7 +1860,7 @@ TSubgoal CGoal::whatToDoToAchieve()
return CGoal(GET_OBJ).setobjid(vc.ID);
case EVictoryConditionType::GATHERRESOURCE:
return CGoal(COLLECT_RES).setresID(vc.ID).setvalue(vc.count);
//TODO mines? piles? marketplace?
//TODO mines? piles? marketplace?
//save?
break;
case EVictoryConditionType::GATHERTROOP:
@ -1919,7 +1929,7 @@ TSubgoal CGoal::whatToDoToAchieve()
if(tileToHit == tile)
{
tlog1 << boost::format("Very strange, tile to hit is %s and tile is also %s, while hero %s is at %s\n")
tlog1 << boost::format("Very strange, tile to hit is %s and tile is also %s, while hero %s is at %s\n")
% tileToHit % tile % h->name % h->visitablePos();
throw cannotFulfillGoalException("Retreiving first tile to hit failed (probably)!");
}
@ -1935,7 +1945,7 @@ TSubgoal CGoal::whatToDoToAchieve()
{
if(cb->getHeroesInfo().empty())
return CGoal(RECRUIT_HERO);
auto hs = cb->getHeroesInfo();
assert(hs.size());
erase(hs, [](const CGHeroInstance *h)
@ -1973,7 +1983,7 @@ TSubgoal CGoal::whatToDoToAchieve()
{
if(!cb->isVisible(tile))
return CGoal(EXPLORE);
if(hero && !ai->isAccessibleForHero(tile, hero))
hero = NULL;
@ -2019,12 +2029,12 @@ TSubgoal CGoal::whatToDoToAchieve()
case BUILD_STRUCTURE:
//TODO check res
//look for town
//look for town
//prerequisites?
I_AM_ELEMENTAR;
case COLLECT_RES:
{
std::vector<const IMarket*> markets;
std::vector<const CGObjectInstance*> visObjs;
@ -2035,7 +2045,7 @@ TSubgoal CGoal::whatToDoToAchieve()
{
if(obj->ID == GameConstants::TOWNI_TYPE && obj->tempOwner == ai->playerID && m->allowsTrade(EMarketMode::RESOURCE_RESOURCE))
markets.push_back(m);
else if(obj->ID == Obj::TRADING_POST) //TODO a moze po prostu test na pozwalanie handlu?
else if(obj->ID == Obj::TRADING_POST) //TODO a moze po prostu test na pozwalanie handlu?
markets.push_back(m);
}
}
@ -2045,7 +2055,7 @@ TSubgoal CGoal::whatToDoToAchieve()
return m1->getMarketEfficiency() < m2->getMarketEfficiency();
});
markets.erase(boost::remove_if(markets, [](const IMarket *market) -> bool
markets.erase(boost::remove_if(markets, [](const IMarket *market) -> bool
{
return !(market->o->ID == GameConstants::TOWNI_TYPE && market->o->tempOwner == ai->playerID)
&& !ai->isAccessible(market->o->visitablePos());
@ -2101,7 +2111,7 @@ TSubgoal CGoal::whatToDoToAchieve()
ai->retreiveVisitableObjs(objs);
erase_if(objs, [&](const CGObjectInstance *obj)
{
return obj->ID != GameConstants::TOWNI_TYPE && obj->ID != GameConstants::HEROI_TYPE //not town/hero
return (obj->ID != GameConstants::TOWNI_TYPE && obj->ID != GameConstants::HEROI_TYPE) //not town/hero
|| cb->getPlayerRelations(ai->playerID, obj->tempOwner) != 0; //not enemy
});
@ -2158,7 +2168,7 @@ bool CGoal::invalid() const
bool CGoal::isBlockedBorderGate(int3 tileToHit)
{
return cb->getTile(tileToHit)->topVisitableID() == Obj::BORDER_GATE
return cb->getTile(tileToHit)->topVisitableID() == Obj::BORDER_GATE
&& cb->getPathInfo(tileToHit)->accessible != CGPathNode::ACCESSIBLE;
}
@ -2168,7 +2178,7 @@ SectorMap::SectorMap()
// sector.resize(sizes.x);
// BOOST_FOREACH(auto &i, sector)
// i.resize(sizes.y);
//
//
// BOOST_FOREACH(auto &i, sector)
// BOOST_FOREACH(auto &j, i)
// j.resize(sizes.z, 0);
@ -2215,8 +2225,8 @@ void SectorMap::clear()
bool canBeEmbarkmentPoint(const TerrainTile *t)
{
//tile must be free of with unoccupied boat
return !t->blocked
|| t->visitableObjects.size() == 1 && t->topVisitableID() == Obj::BOAT;
return !t->blocked
|| (t->visitableObjects.size() == 1 && t->topVisitableID() == Obj::BOAT);
}
void SectorMap::exploreNewSector(crint3 pos, int num)
@ -2285,7 +2295,7 @@ void SectorMap::write(crstring fname)
int3 SectorMap::firstTileToGet(const CGHeroInstance *h, crint3 dst)
{
int sourceSector = retreiveTile(h->visitablePos()),
int sourceSector = retreiveTile(h->visitablePos()),
destinationSector = retreiveTile(dst);
if(sourceSector != destinationSector)
@ -2365,7 +2375,7 @@ int3 SectorMap::firstTileToGet(const CGHeroInstance *h, crint3 dst)
shipyards.push_back(shipyard);
}
shipyards.erase(boost::remove_if(shipyards, [=](const IShipyard *shipyard) -> bool
shipyards.erase(boost::remove_if(shipyards, [=](const IShipyard *shipyard) -> bool
{
return shipyard->state() != 0 || retreiveTile(shipyard->bestLocation()) != sectorToReach->id;
}),shipyards.end());
@ -2464,7 +2474,7 @@ void SectorMap::makeParentBFS(crint3 source)
ui8 &sec = retreiveTile(curPos);
assert(sec == mySector); //consider only tiles from the same sector
const TerrainTile *t = cb->getTile(curPos);
//const TerrainTile *t = cb->getTile(curPos);
foreach_neighbour(curPos, [&](crint3 neighPos)
{
if(retreiveTile(neighPos) == mySector && !vstd::contains(parent, neighPos))

View File

@ -37,14 +37,14 @@ public:
enum EGoals
{
INVALID = -1,
WIN, DO_NOT_LOSE, CONQUER, BUILD, EXPLORE,
RECRUIT_HERO,
WIN, DO_NOT_LOSE, CONQUER, BUILD, EXPLORE,
RECRUIT_HERO,
BUILD_STRUCTURE, //if hero set, then in visited town
COLLECT_RES,
OBJECT_GOALS_BEGIN,
GET_OBJ, //visit or defeat or collect the object
GET_ART_TYPE,
//BUILD_STRUCTURE,
@ -54,7 +54,7 @@ enum EGoals
//VISIT_OBJ, //hero + tile
VISIT_TILE, //tile, in conjunction with hero elementar; assumes tile is reachable
CLEAR_WAY_TO,
CLEAR_WAY_TO,
DIG_AT_TILE //elementar with hero on tile
};
@ -77,7 +77,7 @@ struct CGoal
virtual TSubgoal whatToDoToAchieve();
bool isBlockedBorderGate(int3 tileToHit);
CGoal(EGoals goal = INVALID) : goalType(goal)
CGoal(EGoals goal = INVALID) : goalType(goal)
{
priority = 0;
isElementar = false;
@ -98,8 +98,8 @@ struct CGoal
int objid; SETTER(int, objid)
int aid; SETTER(int, aid)
int3 tile; SETTER(int3, tile)
const CGHeroInstance *hero; SETTER(const CGHeroInstance *, hero)
const CGTownInstance *town; SETTER(const CGTownInstance *, town)
const CGHeroInstance *hero; SETTER(CGHeroInstance *, hero)
const CGTownInstance *town; SETTER(CGTownInstance *, town)
int bid; SETTER(int, bid)
};
@ -114,16 +114,16 @@ struct SectorMap
std::vector<int3> tiles;
std::vector<int3> embarkmentPoints; //tiles of other sectors onto which we can (dis)embark
bool water; //all tiles of sector are land or water
Sector()
{
Sector()
{
id = -1;
}
};
bool valid; //some kind of lazy eval
std::map<int3, int3> parent;
std::vector<std::vector<std::vector<unsigned char>>> sector;
//std::vector<std::vector<std::vector<unsigned char>>> pathfinderSector;
std::vector<std::vector<std::vector<unsigned char>>> sector;
//std::vector<std::vector<std::vector<unsigned char>>> pathfinderSector;
std::map<int, Sector> infoOnSectors;
@ -144,7 +144,7 @@ struct CIssueCommand : CGoal
{
boost::function<bool()> command;
CIssueCommand(boost::function<bool()> _command) : command(_command), CGoal(ISSUE_COMMAND) {}
CIssueCommand(boost::function<bool()> _command): CGoal(ISSUE_COMMAND), command(_command) {}
};
class VCAI : public CAdventureAI
@ -264,7 +264,7 @@ public:
const CGObjectInstance *lookForArt(int aid) const;
bool isAccessible(const int3 &pos);
const CGHeroInstance *getHeroWithGrail() const;
const CGObjectInstance *getUnvisitedObj(const boost::function<bool(const CGObjectInstance *)> &predicate);
bool isAccessibleForHero(const int3 & pos, const CGHeroInstance * h) const;
@ -277,7 +277,7 @@ public:
};
template<int id>
template<int id>
bool objWithID(const CGObjectInstance *obj)
{
return obj->ID == id;

View File

@ -1,7 +1,7 @@
#pragma once
// Standard include file
// Contents:
// Contents:
// Includes C/C++ libraries, STL libraries, IOStream and String libraries
// Includes the most important boost headers
// Defines the import + export, override and exception handling macros
@ -109,6 +109,12 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
#define DLL_LINKAGE DLL_IMPORT
#endif
//defining available c++11 features
//initialization lists - only gcc-4.4 or later
#if defined(__GNUC__) && ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 ))
#define CPP11_USE_INITIALIZERS_LIST
#endif
//a normal std::map with a const operator[] for sanity
template<typename KeyT, typename ValT>
@ -119,10 +125,10 @@ public:
{
return find(key)->second;
}
ValT & operator[](KeyT key)
ValT & operator[](KeyT key)
{
return static_cast<std::map<KeyT, ValT> &>(*this)[key];
}
}
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<std::map<KeyT, ValT> &>(*this);
@ -133,35 +139,35 @@ namespace vstd
{
//returns true if container c contains item i
template <typename Container, typename Item>
bool contains(const Container & c, const Item &i)
bool contains(const Container & c, const Item &i)
{
return std::find(c.begin(),c.end(),i) != c.end();
}
//returns true if map c contains item i
template <typename V, typename Item, typename Item2>
bool contains(const std::map<Item,V> & c, const Item2 &i)
bool contains(const std::map<Item,V> & c, const Item2 &i)
{
return c.find(i)!=c.end();
}
//returns true if bmap c contains item i
template <typename V, typename Item, typename Item2>
bool contains(const bmap<Item,V> & c, const Item2 &i)
bool contains(const bmap<Item,V> & c, const Item2 &i)
{
return c.find(i)!=c.end();
}
//returns true if unordered set c contains item i
template <typename Item>
bool contains(const boost::unordered_set<Item> & c, const Item &i)
bool contains(const boost::unordered_set<Item> & c, const Item &i)
{
return c.find(i)!=c.end();
}
//returns position of first element in vector c equal to s, if there is no such element, -1 is returned
template <typename T1, typename T2>
int find_pos(const std::vector<T1> & c, const T2 &s)
int find_pos(const std::vector<T1> & c, const T2 &s)
{
for(size_t i=0; i < c.size(); ++i)
if(c[i] == s)
@ -171,7 +177,7 @@ namespace vstd
//Func(T1,T2) must say if these elements matches
template <typename T1, typename T2, typename Func>
int find_pos(const std::vector<T1> & c, const T2 &s, const Func &f)
int find_pos(const std::vector<T1> & c, const T2 &s, const Func &f)
{
for(size_t i=0; i < c.size(); ++i)
if(f(c[i],s))
@ -181,7 +187,7 @@ namespace vstd
//returns iterator to the given element if present in container, end() if not
template <typename Container, typename Item>
typename Container::iterator find(Container & c, const Item &i)
typename Container::iterator find(Container & c, const Item &i)
{
return std::find(c.begin(),c.end(),i);
}
@ -195,7 +201,7 @@ namespace vstd
//removes element i from container c, returns false if c does not contain i
template <typename Container, typename Item>
typename Container::size_type operator-=(Container &c, const Item &i)
typename Container::size_type operator-=(Container &c, const Item &i)
{
typename Container::iterator itr = find(c,i);
if(itr == c.end())
@ -206,7 +212,7 @@ namespace vstd
//assigns greater of (a, b) to a and returns maximum of (a, b)
template <typename t1, typename t2>
t1 &amax(t1 &a, const t2 &b)
t1 &amax(t1 &a, const t2 &b)
{
if(a >= b)
return a;
@ -232,7 +238,7 @@ namespace vstd
//makes a to fit the range <b, c>
template <typename t1, typename t2, typename t3>
t1 &abetween(t1 &a, const t2 &b, const t3 &c)
t1 &abetween(t1 &a, const t2 &b, const t3 &c)
{
amax(a,b);
amin(a,c);
@ -241,18 +247,18 @@ namespace vstd
//checks if a is between b and c
template <typename t1, typename t2, typename t3>
bool isbetween(const t1 &a, const t2 &b, const t3 &c)
bool isbetween(const t1 &a, const t2 &b, const t3 &c)
{
return a > b && a < c;
}
//checks if a is within b and c
template <typename t1, typename t2, typename t3>
bool iswithin(const t1 &a, const t2 &b, const t3 &c)
bool iswithin(const t1 &a, const t2 &b, const t3 &c)
{
return a >= b && a <= c;
}
template <typename t1, typename t2>
struct assigner
{
@ -267,7 +273,7 @@ namespace vstd
op1 = op2;
}
};
// Assigns value a2 to a1. The point of time of the real operation can be controlled
// with the () operator.
template <typename t1, typename t2>
@ -277,8 +283,8 @@ namespace vstd
}
//deleted pointer and sets it to NULL
template <typename T>
void clear_pointer(T* &ptr)
template <typename T>
void clear_pointer(T* &ptr)
{
delete ptr;
ptr = NULL;
@ -287,7 +293,7 @@ namespace vstd
using vstd::operator-=;
// can be used for counting arrays
template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N];
template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N];
#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr)))
//for explicit overrides

View File

@ -29,17 +29,14 @@ To compile, at least the following packages (and their development counterparts)
On Ubuntu 9.04 or later, run:
sudo apt-get install g++ libsdl1.2debian-all libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev zlib1g-dev libavformat-dev libswscale-dev libboost-dev libboost-filesystem-dev libboost-iostreams-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev
Create a directory /YOUR_INSTALL_PATH/vcmi (such as
/usr/local/share/games/vcmi) that will contain the game data files. The /vcmi at the end is necessary.
Create a directory /YOUR_INSTALL_PATH/vcmi (default is usually /usr/local/share/vcmi)
that will contain the game data files. The /vcmi at the end is necessary.
Then run configure:
./configure
Or if you're installing to custom path:
./configure --datadir=/YOUR_INSTALL_PATH/ --bindir=/YOUR_INSTALL_PATH/vcmi --libdir=/YOUR_INSTALL_PATH/
On linux, by default, gcc is used. You can also use icc or clang by prefixing the
configure command:
CXX=clang ./configure ...
CXX=icc ./configure ...
Then build vcmi:
make
@ -63,7 +60,7 @@ Install Heroes 3 and Wog. Then move all the installed files into
Once both programs are installed, you can install VCMI.
Download the windows VCMI release (at time of writing:
http://forum.vcmi.eu/dload.php?action=download&id=21)
http://forum.vcmi.eu/dload.php?action=download&id=23)
and extract it in a private directory. Populate /YOUR_INSTALL_PATH/vcmi:
mv sprites /YOUR_INSTALL_PATH/vcmi/Sprites
@ -77,19 +74,20 @@ If you also have the original linux version of Heroes, you can also install the
III. Installing VCMI
Since VCMI is still in development, there's no install procedure, although something like this will work:
DESTDIR=/path/to/heroes3 make install
make install
You also need to update configuration files:
cp /PATH/TO/SOURCE/config /path/to/heroes3
cp /PATH_TO_SOURCE/config /YOUR_INSTALL_PATH/vcmi
For development puposes, it's better to use links. Go
to /YOUR_INSTALL_PATH/vcmi, and type:
ln -s /PATH_TO_VCMI/client/vcmiclient
ln -s /PATH_TO_VCMI/server/vcmiserver
ln -s /PATH_TO_VCMI/config
ln -s /PATH_TO_VCMI/AI/GeniusAI/.libs/GeniusAI.so
ln -s /PATH_TO_VCMI/AI/StupidAI/.libs/StupidAI.so
ln -s /PATH_TO_SOURCE/client/vcmiclient
ln -s /PATH_TO_SOURCE/server/vcmiserver
ln -s /PATH_TO_SOURCE/config
ln -s /PATH_TO_SOURCE/lib/.libs/libvcmi.so
ln -s /PATH_TO_SOURCE/AI/VCAI/.libs/VCAI.so
ln -s /PATH_TO_SOURCE/AI/StupidAI/.libs/StupidAI.so
And start ./vcmiclient

View File

@ -451,7 +451,7 @@ struct ScriptScanner : boost::static_visitor<>
break;
}
}
}
};
@ -757,7 +757,7 @@ struct HEPerformer : StandardReceiverVisitor<const CGHeroInstance *>
else
throw EScriptExecError("Setting stack count is not implemented!");
}
else
else
throw EScriptExecError("Slot number must be an evaluable i-exp");
}
//todo else if(14 params)
@ -819,7 +819,7 @@ struct StringFormatter
// startpos is the first digit
// digits will be converted to number and returned
// ADDITIVE on digitsUsed
int getNum()
int getNum()
{
int toAdd = 0;
int numStart = percentPos + 2;
@ -847,7 +847,7 @@ struct StringFormatter
break;
if(percentPos + 1 >= msg.size()) //at least one character after % is required
throw EScriptExecError("Formatting error: % at the end of string!");
throw EScriptExecError("Formatting error: % at the end of string!");
charsToReplace++; //the sign after % is consumed
switch(msg[percentPos+1])
@ -961,7 +961,7 @@ struct MAPerformer : StandardReceiverVisitor<TUnusedType>
break;
}
}
};
void MA_PPerformer::operator()( TIexp const& cmp ) const
@ -1197,7 +1197,7 @@ struct VRPerformer : StandardReceiverVisitor<IexpValStr>
break;
case 'S': //setting variable
{
performOptionTakingOneParamter<VR_SPerformer>(trig.params);
performOptionTakingOneParamter<VR_SPerformer>(trig.params);
}
break;
case 'T': //random variables
@ -1290,7 +1290,7 @@ struct ERMExpDispatch : boost::static_visitor<>
}
void operator()(Treceiver const& trig) const
{
HLP helper;
HLP helper;
//check condition
if(trig.condition.is_initialized())
{
@ -1650,7 +1650,7 @@ IexpValStr ERMInterpreter::getVar(std::string toFollow, boost::optional<int> ini
{
throw EIexpProblem(std::string("Symbol ") + cr + " is not allowed in this context!");
}
}
ret.name = toFollow;
@ -1914,7 +1914,7 @@ struct ConditionDisemboweler : boost::static_visitor<bool>
default:
throw EScriptExecError("Wrong type of left iexp!");
}
//we should never reach this place
return false;//we should never reach this place
}
bool operator()(int const & flag) const
{
@ -2392,9 +2392,15 @@ void ERMInterpreter::heroVisit(const CGHeroInstance *visitor, const CGObjectInst
return;
setCurrentlyVisitedObj(visitedObj->pos);
TIDPattern tip;
#ifdef CPP11_USE_INITIALIZERS_LIST
tip[1] = {visitedObj->ID};
tip[2] = {visitedObj->ID, visitedObj->subID};
tip[3] = {visitedObj->pos.x, visitedObj->pos.y, visitedObj->pos.z};
#else
tip[1] = list_of(visitedObj->ID);
tip[2] = list_of(visitedObj->ID)(visitedObj->subID);
tip[3] = list_of(visitedObj->pos.x)(visitedObj->pos.y)(visitedObj->pos.z);
#endif
executeTriggerType(VERMInterpreter::TriggerType("OB"), start, tip);
}
@ -2525,7 +2531,7 @@ struct VNodeEvaluator : boost::static_visitor<VOption>
return boost::apply_visitor(_SbackquoteEval(), exp.children[1]);
else
throw EVermScriptExecError("backquote special form takes only one argument");
}
else if(opt.text == "if")
{
@ -2717,7 +2723,7 @@ VOption ERMInterpreter::eval( VOption line, Environment * env /*= NULL*/ )
{
// if(line.children.isNil())
// return;
//
//
// VOption & car = line.children.car().getAsItem();
tlog1 << "\tevaluating ";
printVOption(line);
@ -2819,7 +2825,7 @@ namespace VERMInterpreter
{
children.cdr() = VNode(children);
}
if(modifierList[g] == "`")
{
children.car() = VSymbol("backquote");
@ -3067,7 +3073,7 @@ namespace VERMInterpreter
}
else
throw EVermScriptExecError("Incompatible types in = special function");
}
break;
case ADD:

View File

@ -89,12 +89,12 @@ void CBattleInterface::addNewAnim(CBattleAnimation * anim)
}
CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, const SDL_Rect & myRect, CPlayerInterface * att, CPlayerInterface * defen)
: queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
activeStack(NULL), stackToActivate(NULL), mouseHoveredStack(-1), lastMouseHoveredStackAnimationTime(-1), previouslyHoveredHex(-1),
: queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
activeStack(NULL), stackToActivate(NULL), mouseHoveredStack(-1), lastMouseHoveredStackAnimationTime(-1), previouslyHoveredHex(-1),
currentlyHoveredHex(-1), attackingHex(-1), tacticianInterface(NULL), stackCanCastSpell(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(NULL),
siegeH(NULL), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0), bfield(GameConstants::BFIELD_SIZE),
givenCommand(NULL), myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL)
{
OBJ_CONSTRUCTION;
@ -107,7 +107,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
if(attackerInt && attackerInt->cb->battleGetTacticDist()) //hotseat -> check tactics for both players (defender may be local human)
tacticianInterface = attackerInt;
else if(defenderInt && defenderInt->cb->battleGetTacticDist())
else if(defenderInt && defenderInt->cb->battleGetTacticDist())
tacticianInterface = defenderInt;
tacticsMode = tacticianInterface; //if we found interface of player with tactics, then enter tactics mode
@ -174,7 +174,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
std::vector< std::string > & backref = graphics->battleBacks[ curInt->cb->battleGetBattlefieldType() ];
background = BitmapHandler::loadBitmap(backref[ rand() % backref.size()], false );
}
//preparing menu background
//graphics->blueToPlayersAdv(menu, hero1->tempOwner);
@ -182,7 +182,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
amountNormal = BitmapHandler::loadBitmap("CMNUMWIN.BMP");
CSDL_Ext::alphaTransform(amountNormal);
transformPalette(amountNormal, 0.59, 0.19, 0.93);
amountPositive = BitmapHandler::loadBitmap("CMNUMWIN.BMP");
CSDL_Ext::alphaTransform(amountPositive);
transformPalette(amountPositive, 0.18, 1.00, 0.18);
@ -203,7 +203,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
bOptions = new CAdventureMapButton (CGI->generaltexth->zelp[381].first, CGI->generaltexth->zelp[381].second, boost::bind(&CBattleInterface::bOptionsf,this), 3 + pos.x, 561 + pos.y, "icm003.def", SDLK_o);
bSurrender = new CAdventureMapButton (CGI->generaltexth->zelp[379].first, CGI->generaltexth->zelp[379].second, boost::bind(&CBattleInterface::bSurrenderf,this), 54 + pos.x, 561 + pos.y, "icm001.def", SDLK_s);
bFlee = new CAdventureMapButton (CGI->generaltexth->zelp[380].first, CGI->generaltexth->zelp[380].second, boost::bind(&CBattleInterface::bFleef,this), 105 + pos.x, 561 + pos.y, "icm002.def", SDLK_r);
bFlee->block(!curInt->cb->battleCanFlee());
bFlee->block(!curInt->cb->battleCanFlee());
bSurrender->block(curInt->cb->battleGetSurrenderCost() < 0);
bAutofight = new CAdventureMapButton (CGI->generaltexth->zelp[382].first, CGI->generaltexth->zelp[382].second, boost::bind(&CBattleInterface::bAutofightf,this), 157 + pos.x, 561 + pos.y, "icm004.def", SDLK_a);
bSpell = new CAdventureMapButton (CGI->generaltexth->zelp[385].first, CGI->generaltexth->zelp[385].second, boost::bind(&CBattleInterface::bSpellf,this), 645 + pos.x, 561 + pos.y, "icm005.def", SDLK_c);
@ -362,7 +362,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
int channel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds);
CCS->soundh->setCallback(channel, boost::bind(&CMusicHandler::playMusicFromSet, CCS->musich, CCS->musich->battleMusics, -1));
memset(stackCountOutsideHexes, 1, GameConstants::BFIELD_SIZE * sizeof(bool)); //initialize array with trues
memset(stackCountOutsideHexes, 1, GameConstants::BFIELD_SIZE * sizeof(bool)); //initialize array with trues
}
CBattleInterface::~CBattleInterface()
@ -411,9 +411,9 @@ CBattleInterface::~CBattleInterface()
curInt->battleInt = NULL;
//TODO: play AI tracks if battle was during AI turn
//if (!curInt->makingTurn)
//if (!curInt->makingTurn)
//CCS->musich->playMusicFromSet(CCS->musich->aiMusics, -1);
if(adventureInt && adventureInt->selection)
{
int terrain = LOCPLINT->cb->getTile(adventureInt->selection->visitablePos())->tertype;
@ -525,7 +525,7 @@ void CBattleInterface::show(SDL_Surface * to)
++animCount;
if(!to) //"evaluating" to
to = screen;
SDL_Rect buf;
SDL_GetClipRect(to, &buf);
SDL_SetClipRect(to, &pos);
@ -588,7 +588,7 @@ void CBattleInterface::show(SDL_Surface * to)
else if(settings["battle"]["mouseShadow"].Bool()) //when not casting spell
{//TODO: do not check it every frame
if (activeStack) //highlight all attackable hexes
{
{
std::set<BattleHex> set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex);
BOOST_FOREACH(BattleHex hex, set)
{
@ -607,7 +607,7 @@ void CBattleInterface::show(SDL_Surface * to)
}
}
SDL_SetClipRect(to, &buf); //restoring previous clip_rect
//prevents blitting outside this window
@ -622,7 +622,7 @@ void CBattleInterface::show(SDL_Surface * to)
BattleHex position = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getMaxBlocked(obstacles[b].pos);
hexToObstacle.insert(std::make_pair(position, b));
}
////showing units //a lot of work...
std::vector<const CStack *> stackAliveByHex[GameConstants::BFIELD_SIZE];
//double loop because dead stacks should be printed first
@ -711,11 +711,11 @@ void CBattleInterface::show(SDL_Surface * to)
// xMove => 0: left side, 1: right side
// xMoveDir => 0: decrement, 1: increment, alters every second hex line either xMin or xMax depending on xMove
int xMin, xMax, yMin, yMax, xMove, xMoveDir = 0;
switch (i)
{
// display units shown at the upper left side
case 0:
case 0:
xMin = 0;
yMin = 0;
xMax = 11;
@ -756,11 +756,11 @@ void CBattleInterface::show(SDL_Surface * to)
if (runNum > 0)
{
if (xMin == xMax)
xMax = xMin = ((runNum % 2) == 0) ? (xMin + (xMoveDir == 0 ? -1 : 1)) : xMin;
xMax = xMin = ((runNum % 2) == 0) ? (xMin + (xMoveDir == 0 ? -1 : 1)) : xMin;
else if (xMove == 1)
xMax = ((runNum % 2) == 0) ? (xMax + (xMoveDir == 0 ? -1 : 1)) : xMax;
xMax = ((runNum % 2) == 0) ? (xMax + (xMoveDir == 0 ? -1 : 1)) : xMax;
else if (xMove == 0)
xMin = ((runNum % 2) == 0) ? (xMin + (xMoveDir == 0 ? -1 : 1)) : xMin;
xMin = ((runNum % 2) == 0) ? (xMin + (xMoveDir == 0 ? -1 : 1)) : xMin;
}
for (int k = xMin; k <= xMax; k++)
@ -775,7 +775,7 @@ void CBattleInterface::show(SDL_Surface * to)
}
}
}
for(size_t b = 0; b < flyingStacks.size(); ++b) //showing flying stacks
showAliveStack(flyingStacks[b], to);
@ -799,7 +799,7 @@ void CBattleInterface::show(SDL_Surface * to)
//showing menu background and console
blitAt(menu, pos.x, 556 + pos.y, to);
if(tacticsMode)
{
btactNext->showAll(to);
@ -864,7 +864,7 @@ void CBattleInterface::showAliveStacks(std::vector<const CStack *> *aliveStacks,
if (hex == 16)
if(defendingHero)
defendingHero->show(to);
for(size_t v = 0; v < aliveStacks[hex].size(); ++v)
{
const CStack *s = aliveStacks[hex][v];
@ -1217,20 +1217,20 @@ void CBattleInterface::setBattleCursor(const int myNumber)
// Exclude directions which cannot be attacked from.
// Check to the left.
if (myNumber%GameConstants::BFIELD_WIDTH <= 1 || !vstd::contains(occupyableHexes, myNumber - 1))
if (myNumber%GameConstants::BFIELD_WIDTH <= 1 || !vstd::contains(occupyableHexes, myNumber - 1))
{
sectorCursor[0] = -1;
}
// Check top left, top right as well as above for 2-hex creatures.
if (myNumber/GameConstants::BFIELD_WIDTH == 0)
if (myNumber/GameConstants::BFIELD_WIDTH == 0)
{
sectorCursor[1] = -1;
sectorCursor[2] = -1;
aboveAttackable = false;
}
else
}
else
{
if (doubleWide)
if (doubleWide)
{
bool attackRow[4] = {true, true, true, true};
@ -1269,8 +1269,8 @@ void CBattleInterface::setBattleCursor(const int myNumber)
sectorCursor[4] = -1;
sectorCursor[5] = -1;
belowAttackable = false;
}
else
}
else
{
if (doubleWide)
{
@ -1291,8 +1291,8 @@ void CBattleInterface::setBattleCursor(const int myNumber)
belowAttackable = false;
if (!(attackRow[2] && attackRow[3]))
sectorCursor[4] = -1;
}
else
}
else
{
if (!vstd::contains(occupyableHexes, myNumber + GameConstants::BFIELD_WIDTH + zigzagCorrection))
sectorCursor[4] = -1;
@ -1303,7 +1303,7 @@ void CBattleInterface::setBattleCursor(const int myNumber)
// Determine index from sector.
int cursorIndex;
if (doubleWide)
if (doubleWide)
{
sectorCursor.insert(sectorCursor.begin() + 5, belowAttackable ? 13 : -1);
sectorCursor.insert(sectorCursor.begin() + 2, aboveAttackable ? 14 : -1);
@ -1318,8 +1318,8 @@ void CBattleInterface::setBattleCursor(const int myNumber)
cursorIndex = 6;
else
cursorIndex = (int) sector + 2;
}
else
}
else
{
cursorIndex = sector;
}
@ -1387,7 +1387,7 @@ void CBattleInterface::bSurrenderf()
if(cost >= 0)
{
const CGHeroInstance *opponent = curInt->cb->battleGetFightingHero(1);
std::string enemyHeroName = opponent ? opponent->name : "#ENEMY#"; //TODO: should surrendering without enemy hero be enabled?
std::string enemyHeroName = opponent ? opponent->name : "#ENEMY#"; //TODO: should surrendering without enemy hero be enabled?
std::string surrenderMessage = boost::str(boost::format(CGI->generaltexth->allTexts[32]) % enemyHeroName % cost); //%s states: "I will accept your surrender and grant you and your troops safe passage for the price of %d gold."
curInt->showYesNoDialog(surrenderMessage, std::vector<CComponent*>(), boost::bind(&CBattleInterface::reallySurrender,this), 0, false);
}
@ -1508,7 +1508,7 @@ void CBattleInterface::newStack(const CStack * stack)
if(stack->position < 0) //turret
{
const CCreature & turretCreature = *CGI->creh->creatures[ CGI->creh->factionToTurretCreature[siegeH->town->town->typeID] ];
creAnims[stack->ID] = new CCreatureAnimation(turretCreature.animDefName);
creAnims[stack->ID] = new CCreatureAnimation(turretCreature.animDefName);
// Turret positions are read out of the /config/wall_pos.txt
int posID = 0;
@ -1533,7 +1533,7 @@ void CBattleInterface::newStack(const CStack * stack)
}
else
{
creAnims[stack->ID] = new CCreatureAnimation(stack->getCreature()->animDefName);
creAnims[stack->ID] = new CCreatureAnimation(stack->getCreature()->animDefName);
}
creAnims[stack->ID]->setType(CCreatureAnim::HOLDING);
creAnims[stack->ID]->pos = Rect(coords.x, coords.y, creAnims[stack->ID]->fullWidth, creAnims[stack->ID]->fullHeight);
@ -1623,7 +1623,7 @@ void CBattleInterface::newRound(int number)
//bSpell->block(!curInt->cb->battleCanCastSpell());
//don't unlock spellbook - this should be done when we have axctive creature
}
void CBattleInterface::giveCommand(ui8 action, BattleHex tile, ui32 stack, si32 additional)
@ -1712,7 +1712,7 @@ const CGHeroInstance * CBattleInterface::getActiveHero()
{
return attackingHeroInstance;
}
return defendingHeroInstance;
}
@ -1727,7 +1727,7 @@ void CBattleInterface::hexLclicked(int whichOne)
}
if( ((whichOne%GameConstants::BFIELD_WIDTH)!=0 && (whichOne%GameConstants::BFIELD_WIDTH)!=(GameConstants::BFIELD_WIDTH-1)) //if player is trying to attack enemey unit or move creature stack
|| (actSt->hasBonusOfType(Bonus::CATAPULT) && !spellDestSelectMode || dest ) //enemy's first aid tent can stand there and we want to shoot it
|| ((actSt->hasBonusOfType(Bonus::CATAPULT) && !spellDestSelectMode) || dest ) //enemy's first aid tent can stand there and we want to shoot it
)
{
if(!myTurn)
@ -1970,7 +1970,7 @@ void CBattleInterface::hexLclicked(int whichOne)
if(attackFromHex >= 0) //we can be in this line when unreachable creature is L - clicked (as of revision 1308)
{
giveCommand(BattleAction::WALK_AND_ATTACK, attackFromHex, activeStack->ID, whichOne);
CCS->curh->changeGraphic(1, 6); //cursor should be changed
}
@ -2052,7 +2052,7 @@ void CBattleInterface::battleFinished(const BattleResult& br)
void CBattleInterface::displayBattleFinished()
{
CCS->curh->changeGraphic(0,0);
SDL_Rect temp_rect = genRect(561, 470, (screen->w - 800)/2 + 165, (screen->h - 600)/2 + 19);
resWindow = new CBattleResultWindow(*bresult, temp_rect, this);
GH.pushInt(resWindow);
@ -2115,7 +2115,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
//displaying animation
CDefEssential * animDef = CDefHandler::giveDefEss(animToDisplay);
int steps = sqrt(static_cast<double>((destcoord.x - srccoord.x)*(destcoord.x - srccoord.x) + (destcoord.y - srccoord.y) * (destcoord.y - srccoord.y))) / 40;
if(steps <= 0)
steps = 1;
@ -2214,7 +2214,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
text = CGI->generaltexth->allTexts[551];
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->nameSing);
}
//The %s shrivel with age, and lose %d hit points."
//The %s shrivel with age, and lose %d hit points."
TBonusListPtr bl = curInt->cb->battleGetStackByID(*sc->affectedCres.begin(), false)->getBonuses(Selector::type(Bonus::STACK_HEALTH));
bl->remove_if(Selector::source(Bonus::SPELL_EFFECT, 75));
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bl->totalValue()/2));
@ -2256,7 +2256,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
text = "";
break;
default:
text = CGI->generaltexth->allTexts[565]; //The %s casts %s
text = CGI->generaltexth->allTexts[565]; //The %s casts %s
boost::algorithm::replace_first(text, "%s", CGI->creh->creatures[sc->attackerType]->namePl); //casting stack
}
if (plural)
@ -2344,7 +2344,7 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
sprintf(txt, CGI->generaltexth->allTexts[txtid].c_str(), (stack->count != 1) ? stack->getCreature()->namePl.c_str() : stack->getCreature()->nameSing.c_str(), val);
console->addText(txt);
}
}
@ -2433,7 +2433,7 @@ void CBattleInterface::castThisSpell(int spellID)
}
else
{
CCS->curh->changeGraphic(3, 0);
GH.fakeMouseMove();//update cursor
}
}
@ -2561,8 +2561,8 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
if(creAnims.find(ID) == creAnims.end()) //eg. for summoned but not yet handled stacks
return;
const CCreature *creature = stack->getCreature();
SDL_Rect unitRect = {creAnims[ID]->pos.x, creAnims[ID]->pos.y, creAnims[ID]->fullWidth, creAnims[ID]->fullHeight};
SDL_Rect unitRect = {creAnims[ID]->pos.x, creAnims[ID]->pos.y, int16_t(creAnims[ID]->fullWidth), int16_t(creAnims[ID]->fullHeight)};
int animType = creAnims[ID]->getType();
int affectingSpeed = getAnimSpeed();
@ -2613,7 +2613,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
incrementFrame = false;
}
}
// Increment always when moving, never if stack died
creAnims[ID]->nextFrame(to, unitRect.x, unitRect.y, creDir[ID], animCount, incrementFrame, activeStack && ID==activeStack->ID, ID==mouseHoveredStack, &unitRect);
@ -2683,9 +2683,16 @@ void CBattleInterface::showPieceOfWall(SDL_Surface * to, int hex, const std::vec
return;
using namespace boost::assign;
#ifdef CPP11_USE_INITIALIZERS_LIST
//note - std::list<int> must be specified to avoid type deduction by gcc (may not work in other compilers)
static const std::map<int, std::list<int> > hexToPart = {
{12, std::list<int>{8, 1, 7}}, {45, std::list<int>{12, 6}},
{101, std::list<int>{10}}, {118, std::list<int>{2}},
{165, std::list<int>{11}}, {186, std::list<int>{3}}};
#else
static const std::map<int, std::list<int> > hexToPart = map_list_of<int, std::list<int> >(12, list_of<int>(8)(1)(7))(45, list_of<int>(12)(6))
/*gate (78, list_of<int>(9))*/(101, list_of<int>(10))(118, list_of<int>(2))(165, list_of<int>(11))(186, list_of<int>(3));
(101, list_of<int>(10))(118, list_of<int>(2))(165, list_of<int>(11))(186, list_of<int>(3));
#endif
std::map<int, std::list<int> >::const_iterator it = hexToPart.find(hex);
if(it != hexToPart.end())
{
@ -2797,7 +2804,7 @@ void CBattleInterface::printConsoleAttacked( const CStack * defender, int dmg, i
}
else //killed == 1
{
sprintf(tabh + end, CGI->generaltexth->allTexts[378].c_str(),
sprintf(tabh + end, CGI->generaltexth->allTexts[378].c_str(),
multiple ? CGI->generaltexth->allTexts[42].c_str() : defender->getCreature()->nameSing.c_str()); // creature perishes
}
}
@ -2828,7 +2835,7 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
dst.w = idToProjectile[it->creID]->ourImages[it->frameNum].bitmap->w;
dst.x = it->x;
dst.y = it->y;
// The equation below calculates the center pos of the canon, but we need the top left pos
// of it for drawing
if (it->catapultInfo)
@ -2883,7 +2890,7 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
}
void CBattleInterface::endAction(const BattleAction* action)
{
{
//if((action->actionType==2 || (action->actionType==6 && action->destinationTile!=cb->battleGetPos(action->stackNumber)))) //activating interface when move is finished
// {
// activate();
@ -2989,7 +2996,7 @@ void CBattleInterface::startAction(const BattleAction* action)
assert(action->actionType == BattleAction::HERO_SPELL); //only cast spell is valid action without acting stack number
}
if(action->actionType == BattleAction::WALK
if(action->actionType == BattleAction::WALK
|| (action->actionType == BattleAction::WALK_AND_ATTACK && action->destinationTile != stack->position))
{
moveStarted = true;
@ -3162,14 +3169,14 @@ std::string CBattleInterface::SiegeHelper::getSiegeName(ui16 what, ui16 additInf
}
}
/// What: 1. background wall, 2. keep, 3. bottom tower, 4. bottom wall, 5. wall below gate,
/// 6. wall over gate, 7. upper wall, 8. upper tower, 9. gate, 10. gate arch, 11. bottom static wall, 12. upper static wall, 13. moat, 14. mlip,
/// What: 1. background wall, 2. keep, 3. bottom tower, 4. bottom wall, 5. wall below gate,
/// 6. wall over gate, 7. upper wall, 8. upper tower, 9. gate, 10. gate arch, 11. bottom static wall, 12. upper static wall, 13. moat, 14. mlip,
/// 15. keep turret cover, 16. lower turret cover, 17. upper turret cover
/// Positions are loaded from the config file: /config/wall_pos.txt
void CBattleInterface::SiegeHelper::printPartOfWall(SDL_Surface * to, int what)
{
Point pos = Point(-1, -1);
if (what >= 1 && what <= 17)
{
pos.x = graphics->wallPositions[town->town->typeID][what - 1].x + owner->pos.x;

View File

@ -465,7 +465,7 @@ CCastleBuildings::CCastleBuildings(const CGTownInstance* Town):
std::map<int, Structure*>::iterator structure;
structure = CGI->townh->structures[town->subID].find(*building);
if(structure != CGI->townh->structures[town->subID].end())
if(structure != CGI->townh->structures[town->subID].end() && structure->second)
{
if(structure->second->group<0) // no group - just add it
buildings.push_back(new CBuildingRect(this, town, structure->second));

View File

@ -86,7 +86,7 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, int Type, boost::func
for(TResources::nziterator i(upgradeCost); i.valid(); i++)
{
BLOCK_CAPTURING;
upgResCost.push_back(new CComponent(CComponent::resource, i->resType, i->resVal));
upgResCost.push_back(new CComponent(CComponent::resource, i->resType, i->resVal));
}
if(LOCPLINT->cb->getResourceAmount().canAfford(upgradeCost))
@ -137,7 +137,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
BonusList bl, blTemp;
blTemp = (*(stackNode->getBonuses(Selector::durationType(Bonus::PERMANENT))));
while (blTemp.size())
{
@ -243,10 +243,10 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
expmin = CGI->creh->expRanks[tier][9];
int expmax = CGI->creh->expRanks[tier][10];
number = expmax - expmin;
boost::replace_first (expText, "%i", boost::lexical_cast<std::string>(number)); //Experience after Rank 10
number = (stack->count * (expmax - expmin)) / expmin;
boost::replace_first (expText, "%i", boost::lexical_cast<std::string>(number)); //Maximum New Recruits to remain at Rank 10 if at Maximum Experience
boost::replace_first (expText, "%i", boost::lexical_cast<std::string>(number)); //Experience after Rank 10
number = (stack->count * (expmax - expmin)) / expmin;
boost::replace_first (expText, "%i", boost::lexical_cast<std::string>(number)); //Maximum New Recruits to remain at Rank 10 if at Maximum Experience
expArea = new LRClickableAreaWTextComp(Rect(334, 49, 160, 44),CComponent::experience);
expArea->text = expText;
expArea->bonusValue = 0; //TDO: some specific value or no number at all
@ -279,10 +279,10 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
std::string spellText;
if (effect < graphics->spellEffectsPics->ourImages.size()) //not all effects have graphics (for eg. Acid Breath)
{
spellText = CGI->generaltexth->allTexts[610]; //"%s, duration: %d rounds."
spellText = CGI->generaltexth->allTexts[610]; //"%s, duration: %d rounds."
boost::replace_first (spellText, "%s", CGI->spellh->spells[effect]->name);
int duration = battleStack->getBonus(Selector::source(Bonus::SPELL_EFFECT,effect))->turnsRemain;
boost::replace_first (spellText, "%d", boost::lexical_cast<std::string>(duration));
boost::replace_first (spellText, "%d", boost::lexical_cast<std::string>(duration));
blitAt(graphics->spellEffectsPics->ourImages[effect + 1].bitmap, 20 + 52 * printed, 184, *bitmap);
spellEffects.push_back(new LRClickableAreaWText(Rect(20 + 52 * printed, 184, 50, 38), spellText, spellText));
if (++printed >= 10) //we can fit only 10 effects
@ -370,7 +370,7 @@ void CCreatureWindow::showAll(SDL_Surface * to)
//TODO
int dmgMultiply = 1;
if(heroOwner && stackNode->hasBonusOfType(Bonus::SIEGE_WEAPON))
dmgMultiply += heroOwner->Attack();
dmgMultiply += heroOwner->Attack();
printLine(3, CGI->generaltexth->allTexts[199], stackNode->getMinDamage() * dmgMultiply, stackNode->getMaxDamage() * dmgMultiply, true);
printLine(4, CGI->generaltexth->allTexts[388], c->valOfBonuses(Bonus::STACK_HEALTH), stackNode->valOfBonuses(Bonus::STACK_HEALTH));
@ -401,7 +401,7 @@ void CCreatureWindow::scrollArt(int dir)
void CCreatureWindow::passArtifactToHero()
{
creatureArtifact->artType;
//creatureArtifact->artType; //FIXME
}
void CCreatureWindow::clickRight(tribool down, bool previousState)
@ -494,7 +494,7 @@ CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, boost
for(TResources::nziterator i(upgradeCost); i.valid(); i++)
{
BLOCK_CAPTURING;
upgResCost.push_back(new CComponent(CComponent::resource, i->resType, i->resVal));
upgResCost.push_back(new CComponent(CComponent::resource, i->resType, i->resVal));
}
CFunctionList<void()> onUpgrade;
@ -519,14 +519,14 @@ CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, boost
boost::function<void()> dialog = boost::bind(&CPlayerInterface::showYesNoDialog,
LOCPLINT,
CGI->generaltexth->allTexts[12],
CGI->generaltexth->allTexts[12],
std::vector<CComponent*>(),
onDismiss, 0, true);
dismiss = new CAdventureMapButton("", CGI->generaltexth->zelp[445].second, dialog, 21, 237, "IVIEWCR2",SDLK_d);
}
ok = new CAdventureMapButton("", CGI->generaltexth->zelp[445].second,
ok = new CAdventureMapButton("", CGI->generaltexth->zelp[445].second,
boost::bind(&CCreInfoWindow::close,this), 216, 237, "IOKAY.DEF", SDLK_RETURN);
}
}
@ -596,7 +596,7 @@ void CCreInfoWindow::init(const CCreature *creature, const CBonusSystemNode *sta
//TODO
int dmgMultiply = 1;
if(heroOwner && stackNode->hasBonusOfType(Bonus::SIEGE_WEAPON))
dmgMultiply += heroOwner->Attack();
dmgMultiply += heroOwner->Attack();
printLine(3, CGI->generaltexth->allTexts[199], stackNode->getMinDamage() * dmgMultiply, stackNode->getMaxDamage() * dmgMultiply, true);
printLine(4, CGI->generaltexth->allTexts[388], creature->valOfBonuses(Bonus::STACK_HEALTH), stackNode->valOfBonuses(Bonus::STACK_HEALTH));

View File

@ -96,7 +96,7 @@ void CDefHandler::openFromMemory(ui8 *table, const std::string & name)
p += 13;
}
for (ui32 j=0; j<totalInBlock; j++)
{
{
SEntries[totalEntries+j].offset = read_le_u32(p);
p += 4;
}
@ -133,22 +133,20 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPal
{
SDL_Surface * ret=NULL;
ui32 BaseOffset,
ui32 BaseOffset,
SpriteWidth, SpriteHeight, //format of sprite
TotalRowLength, // length of read segment
add, FullHeight,FullWidth,
RowAdd, //, NextSpriteOffset; //TODO use me
prSize,
RowAdd,
defType2;
int LeftMargin, RightMargin, TopMargin, BottomMargin;
ui8 SegmentType;//, BL, BR; //TODO use me
ui8 SegmentType;
BaseOffset = SEntries[SIndex].offset;
SSpriteDef sd = * reinterpret_cast<const SSpriteDef *>(FDef + BaseOffset);
//prSize = SDL_SwapLE32(sd.prSize); //TODO use me
defType2 = SDL_SwapLE32(sd.defType2);
FullWidth = SDL_SwapLE32(sd.FullWidth);
FullHeight = SDL_SwapLE32(sd.FullHeight);
@ -165,7 +163,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPal
SpriteWidth+=LeftMargin;
if(RightMargin<0)
SpriteWidth+=RightMargin;
// Note: this looks bogus because we allocate only FullWidth, not FullWidth+add
add = 4 - FullWidth%4;
if (add==4)
@ -209,7 +207,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPal
memcpy(reinterpret_cast<char*>(ret->pixels)+ftcp, &FDef[BaseOffset], SpriteWidth);
ftcp += SpriteWidth;
BaseOffset += SpriteWidth;
if (RightMargin>0)
ftcp += RightMargin;
}

View File

@ -63,7 +63,7 @@ namespace po = boost::program_options;
std::string NAME_AFFIX = "client";
std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name
CGuiHandler GH;
static CClient *client;
static CClient *client=NULL;
SDL_Surface *screen = NULL, //main screen surface
*screen2 = NULL,//and hlp surface (used to store not-active interfaces layer)
*screenBuf = screen; //points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
@ -742,9 +742,8 @@ void startGame(StartInfo * options, CConnection *serv/* = NULL*/)
else
setResolution = true;
client = new CClient;
client = new CClient;
CPlayerInterface::howManyPeople = 0;
switch(options->mode) //new game
{
@ -760,7 +759,7 @@ void startGame(StartInfo * options, CConnection *serv/* = NULL*/)
break;
}
client->connectionHandler = new boost::thread(&CClient::run, client);
client->connectionHandler = new boost::thread(&CClient::run, client);
}
void requestChangingResolution()

View File

@ -62,7 +62,7 @@ void CAudioBase::setVolume(ui32 percent)
{
if (percent > 100)
percent = 100;
volume = percent;
}
@ -179,7 +179,7 @@ void CSoundHandler::initCreaturesSounds(const std::vector<ConstTransitivePtr< CC
CBattleSounds.resize(creatures.size());
if (!config["creature_sounds"].isNull()) {
BOOST_FOREACH(const JsonNode &node, config["creature_sounds"].Vector()) {
const JsonNode *value;
int id;
@ -213,7 +213,7 @@ void CSoundHandler::initCreaturesSounds(const std::vector<ConstTransitivePtr< CC
#undef GET_SOUND_VALUE
}
}
//commented to avoid spurious warnings
/*
// Find creatures without sounds
@ -328,19 +328,31 @@ CMusicHandler::CMusicHandler():
{
listener(boost::bind(&CMusicHandler::onVolumeChange, this, _1));
// Map music IDs
#define VCMI_MUSIC_ID(x) ( musicBase::x ,
#define VCMI_MUSIC_FILE(y) y )
musics = map_list_of
VCMI_MUSIC_LIST;
#undef VCMI_MUSIC_NAME
#undef VCMI_MUSIC_FILE
#ifdef CPP11_USE_INITIALIZERS_LIST
#define VCMI_MUSIC_ID(x) { musicBase::x ,
#define VCMI_MUSIC_FILE(y) y },
musics = { VCMI_MUSIC_LIST};
#undef VCMI_MUSIC_NAME
#undef VCMI_MUSIC_FILE
#else
#define VCMI_MUSIC_ID(x) ( musicBase::x ,
#define VCMI_MUSIC_FILE(y) y )
musics = map_list_of
VCMI_MUSIC_LIST;
#undef VCMI_MUSIC_NAME
#undef VCMI_MUSIC_FILE
#endif
// Vectors for helper
aiMusics += musicBase::AITheme0, musicBase::AITheme1, musicBase::AITheme2;
battleMusics += musicBase::combat1, musicBase::combat2,
battleMusics += musicBase::combat1, musicBase::combat2,
musicBase::combat3, musicBase::combat4;
townMusics += musicBase::castleTown, musicBase::rampartTown,
musicBase::towerTown, musicBase::infernoTown,
musicBase::necroTown, musicBase::dungeonTown,

View File

@ -240,7 +240,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
if(tile.objects[i].first->id == details.id)
ho = dynamic_cast<const CGHeroInstance *>(tile.objects[i].first);
if(!ho) //still nothing...
if(!ho) //still nothing...
return;
}
@ -354,7 +354,7 @@ void CPlayerInterface::heroKilled(const CGHeroInstance* hero)
{
boost::unique_lock<boost::recursive_mutex> un(*pim);
wanderingHeroes -= hero;
if(vstd::contains(paths, hero))
if(vstd::contains(paths, hero))
paths.erase(hero);
adventureInt->heroList.updateHList(hero);
@ -382,7 +382,7 @@ SDL_Surface * CPlayerInterface::infoWin(const CGObjectInstance * specific) //spe
switch(specific->ID)
{
case GameConstants::HEROI_TYPE:
case GameConstants::HEROI_TYPE:
{
InfoAboutHero iah;
bool gotInfo = LOCPLINT->cb->getHeroInfo(specific, iah);
@ -452,7 +452,7 @@ void CPlayerInterface::receivedResource(int type, int val)
boost::unique_lock<boost::recursive_mutex> un(*pim);
if(CMarketplaceWindow *mw = dynamic_cast<CMarketplaceWindow *>(GH.topInt()))
mw->resourceChanged(type, val);
GH.totalRedraw();
}
@ -854,7 +854,7 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba)
const CStack * attacked = cb->battleGetStackByID(i->stackAttacked);
battleInt->displayEffect(73, attacked->position);
}
}
const CStack * attacker = cb->battleGetStackByID(ba->stackAttacking);
@ -896,6 +896,7 @@ void CPlayerInterface::yourTacticPhase(int distance)
void CPlayerInterface::showComp(CComponent comp)
{
waitWhileDialog();//Fix for mantis #98
boost::unique_lock<boost::recursive_mutex> un(*pim);
CCS->soundh->playSoundFromSet(CCS->soundh->pickupSounds);
@ -915,7 +916,7 @@ void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector
{
waitWhileDialog();
boost::unique_lock<boost::recursive_mutex> un(*pim);
stopMovement();
CInfoWindow *temp = CInfoWindow::create(text, playerID, &components);
temp->setDelComps(delComps);
@ -944,7 +945,7 @@ void CPlayerInterface::showBlockingDialog( const std::string &text, const std::v
{
waitWhileDialog();
boost::unique_lock<boost::recursive_mutex> un(*pim);
stopMovement();
CCS->soundh->playSound(static_cast<soundBase::soundID>(soundID));
@ -1145,11 +1146,11 @@ bool CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
{
adventureInt->sleepWake.clickLeft(true, false);
adventureInt->sleepWake.clickLeft(false, true);
//could've just called
//could've just called
//adventureInt->fsleepWake();
//but no authentic button click/sound ;-)
}
int i = 1;
//evil...
eventsM.unlock();
@ -1190,7 +1191,7 @@ bool CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
{
newTerrain = cb->getTile(CGHeroInstance::convertPosition(path.nodes[i].coord, false))->tertype;
if (newTerrain != currentTerrain)
if (newTerrain != currentTerrain)
{
CCS->soundh->stopSound(sh);
sh = CCS->soundh->playSound(CCS->soundh->horseSounds[newTerrain], -1);
@ -1222,7 +1223,7 @@ bool CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
if (adventureInt)
{
// (i == 0) means hero went through all the path
adventureInt->updateMoveHero(h, (i != 0));
adventureInt->updateMoveHero(h, (i != 0));
adventureInt->updateNextHero(h);
}
return result;
@ -1298,7 +1299,7 @@ void CPlayerInterface::showArtifactAssemblyDialog (ui32 artifactID, ui32 assembl
text += CGI->generaltexth->allTexts[733];
}
showYesNoDialog(text, scs, onYes, onNo, true);
showYesNoDialog(text, scs, onYes, onNo, true);
}
void CPlayerInterface::requestRealized( PackageApplied *pa )
@ -1354,13 +1355,13 @@ void CPlayerInterface::recreateHeroTownList()
newWanderingHeroes += allHeroes[j];
allHeroes -= allHeroes[j];
}
//all the rest of new heroes go the end of the list
//all the rest of new heroes go the end of the list
wanderingHeroes.clear();
wanderingHeroes = newWanderingHeroes;
newWanderingHeroes.clear();
for (int i = 0; i < allHeroes.size(); i++)
if (!allHeroes[i]->inTownGarrison)
wanderingHeroes += allHeroes[i];
wanderingHeroes += allHeroes[i];
std::vector<const CGTownInstance*> newTowns;
std::vector<const CGTownInstance*> allTowns = cb->getTownsInfo();
@ -1463,7 +1464,7 @@ void CPlayerInterface::update()
if(terminate_cond.get())
return;
//make sure that gamestate won't change when GUI objects may obtain its parts on event processing or drawing request
boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());
@ -1983,15 +1984,15 @@ void CPlayerInterface::gameOver(ui8 player, bool victory )
requestStoppingClient();
}
cb->unregisterMyInterface(); //we already won/lost, nothing else matters
}
else
{
if(!victory && cb->getPlayerStatus(playerID) == PlayerState::INGAME) //enemy has lost
{
std::string txt = CGI->generaltexth->allTexts[5]; //%s has been vanquished!
boost::algorithm::replace_first(txt, "%s", CGI->generaltexth->capColors[player]);
showInfoDialog(txt,std::vector<CComponent*>(1, new CComponent(CComponent::flag, player, 0)));
{
std::string txt = CGI->generaltexth->allTexts[5]; //%s has been vanquished!
boost::algorithm::replace_first(txt, "%s", CGI->generaltexth->capColors[player]);
showInfoDialog(txt,std::vector<CComponent*>(1, new CComponent(CComponent::flag, player, 0)));
}
}
}
@ -2056,7 +2057,7 @@ CGPath * CPlayerInterface::getAndVerifyPath(const CGHeroInstance * h)
}
else
{
assert(h->getPosition(false) == path.startPos());
assert(h->getPosition(false) == path.startPos());
//update the hero path in case of something has changed on map
if(LOCPLINT->cb->getPath2(path.endPos(), path))
return &path;

View File

@ -4836,7 +4836,7 @@ void CArtifactsOfHero::markPossibleSlots(const CArtifactInstance* art)
BOOST_FOREACH(CArtifactsOfHero *aoh, commonInfo->participants)
BOOST_FOREACH(CArtPlace *place, aoh->artWorn)
place->marked = art->canBePutAt(ArtifactLocation(aoh->curHero, place->slotID), true);
if (CHeroWindow* chw = dynamic_cast<CHeroWindow*>(GH.topInt()))
{
//FIXME: garrison window has two rows of cretaures :?
@ -4847,10 +4847,10 @@ void CArtifactsOfHero::markPossibleSlots(const CArtifactInstance* art)
g->highlight = true;
}
}
else if(CExchangeWindow* cew = dynamic_cast<CExchangeWindow*>(GH.topInt()))
/*else if(CExchangeWindow* cew = dynamic_cast<CExchangeWindow*>(GH.topInt()))
{
//TODO
}
}*/
safeRedraw();
}

View File

@ -40,14 +40,14 @@
{ \
if(vstd::contains(cl->playerint,player)) \
cl->playerint[player]->function(__VA_ARGS__); \
}while(0)
}while(0)
#define INTERFACE_CALL_IF_PRESENT(player,function,...) \
do \
{ \
CALL_ONLY_THAT_INTERFACE(player, function, __VA_ARGS__);\
CALL_IN_PRIVILAGED_INTS(function, __VA_ARGS__); \
} while(0)
} while(0)
#define CALL_ONLY_THT_BATTLE_INTERFACE(player,function, ...) \
do \
@ -295,7 +295,7 @@ void RemoveBonus::applyCl( CClient *cl )
break;
case PLAYER:
{
const PlayerState *p = GS(cl)->getPlayer(id);
//const PlayerState *p = GS(cl)->getPlayer(id);
INTERFACE_CALL_IF_PRESENT(id, playerBonusChanged, bonus, false);
}
break;
@ -446,15 +446,15 @@ void SetHeroesInTown::applyCl( CClient *cl )
// void SetHeroArtifacts::applyCl( CClient *cl )
// {
// tlog1 << "SetHeroArtifacts :(\n";
// //
// //
// // CGHeroInstance *h = GS(cl)->getHero(hid);
// // CGameInterface *player = (vstd::contains(cl->playerint,h->tempOwner) ? cl->playerint[h->tempOwner] : NULL);
// // if(!player)
// // return;
//
//
// //h->recreateArtBonuses();
// //player->heroArtifactSetChanged(h);
//
//
// // BOOST_FOREACH(Bonus bonus, gained)
// // {
// // player->heroBonusChanged(h,bonus,true);
@ -475,7 +475,7 @@ void HeroRecruited::applyCl( CClient *cl )
CGI->mh->initHeroDef(h);
CGI->mh->printObject(h);
if(vstd::contains(cl->playerint,h->tempOwner))
{
cl->playerint[h->tempOwner]->heroCreated(h);
@ -500,7 +500,7 @@ void GiveHero::applyFirstCl( CClient *cl )
void InfoWindow::applyCl( CClient *cl )
{
std::vector<Component*> comps;
for(size_t i=0;i<components.size();i++)
for(size_t i=0;i<components.size();i++)
{
comps.push_back(&components[i]);
}
@ -778,7 +778,7 @@ void ShowInInfobox::applyCl(CClient *cl)
void AdvmapSpellCast::applyCl(CClient *cl)
{
cl->invalidatePaths();
//consider notifying other interfaces that see hero?
//consider notifying other interfaces that see hero?
INTERFACE_CALL_IF_PRESENT(caster->getOwner(),advmapSpellCast, caster, spellID);
}
@ -902,7 +902,7 @@ void TradeComponents::applyCl(CClient *cl)
break;
case 221: //Trading Post
break;
default:
default:
tlog2 << "Shop type not supported! \n";
}
}

View File

@ -17,7 +17,7 @@
*
*/
SDL_Color Colors::createColor(int r, int g, int b, int a /*= 0*/)
SDL_Color Colors::createColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a /*= 0*/)
{
SDL_Color temp = {r, g, b, a};
return temp;
@ -47,8 +47,8 @@ STRONG_INLINE void ColorPutter<bpp, incrementPtr>::PutColorAlphaSwitch(Uint8 *&p
PutColor(ptr, R, G, B);
return;
case 128: // optimized
PutColor(ptr, ((Uint16)R + (Uint16)ptr[2]) >> 1,
((Uint16)G + (Uint16)ptr[1]) >> 1,
PutColor(ptr, ((Uint16)R + (Uint16)ptr[2]) >> 1,
((Uint16)G + (Uint16)ptr[1]) >> 1,
((Uint16)B + (Uint16)ptr[0]) >> 1);
return;
default:
@ -60,8 +60,8 @@ STRONG_INLINE void ColorPutter<bpp, incrementPtr>::PutColorAlphaSwitch(Uint8 *&p
template<int bpp, int incrementPtr>
STRONG_INLINE void ColorPutter<bpp, incrementPtr>::PutColor(Uint8 *&ptr, const Uint8 & R, const Uint8 & G, const Uint8 & B, const Uint8 & A)
{
PutColor(ptr, ((((Uint32)ptr[2]-(Uint32)R)*(Uint32)A) >> 8 ) + (Uint32)R,
((((Uint32)ptr[1]-(Uint32)G)*(Uint32)A) >> 8 ) + (Uint32)G,
PutColor(ptr, ((((Uint32)ptr[2]-(Uint32)R)*(Uint32)A) >> 8 ) + (Uint32)R,
((((Uint32)ptr[1]-(Uint32)G)*(Uint32)A) >> 8 ) + (Uint32)G,
((((Uint32)ptr[0]-(Uint32)B)*(Uint32)A) >> 8 ) + (Uint32)B);
}
@ -103,7 +103,7 @@ template<int bpp, int incrementPtr>
STRONG_INLINE void ColorPutter<bpp, incrementPtr>::PutColorRow(Uint8 *&ptr, const SDL_Color & Color, size_t count)
{
Uint32 pixel = ((Uint32)Color.b << 0 ) + ((Uint32)Color.g << 8) + ((Uint32)Color.r << 16);
for (size_t i=0; i<count; i++)
{
memcpy(ptr, &pixel, bpp);
@ -159,7 +159,7 @@ STRONG_INLINE void ColorPutter<2, incrementPtr>::PutColor(Uint8 *&ptr, const Uin
g8 = (g5 << (8 - gbit)) | (g5 >> (2*gbit - 8)),
b8 = (b5 << (8 - bbit)) | (b5 >> (2*bbit - 8));
PutColor(ptr,
PutColor(ptr,
(((r8-R)*A) >> 8) + R,
(((g8-G)*A) >> 8) + G,
(((b8-B)*A) >> 8) + B);
@ -182,7 +182,7 @@ STRONG_INLINE void ColorPutter<2, incrementPtr>::PutColorRow(Uint8 *&ptr, const
{
//drop least significant bits of 24 bpp encoded color
Uint16 pixel = (Color.b>>3) + ((Color.g>>2) << 5) + ((Color.r>>3) << 11);
for (size_t i=0; i<count; i++)
{
memcpy(ptr, &pixel, 2);
@ -715,7 +715,7 @@ void CSDL_Ext::blitWithRotateClipVal( SDL_Surface *src,SDL_Rect srcRect, SDL_Sur
blitWithRotateClip<bpp>(src, &srcRect, dst, &dstRect, rotation);
}
template<int bpp>
template<int bpp>
void CSDL_Ext::blitWithRotateClipWithAlpha(SDL_Surface *src,SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect, ui8 rotation)//srcRect is not used, works with 8bpp sources and 24bpp dests
{
static void (*blitWithRotate[])(const SDL_Surface *, const SDL_Rect *, SDL_Surface *, const SDL_Rect *) = {blitWithRotate1WithAlpha<bpp>, blitWithRotate2WithAlpha<bpp>, blitWithRotate3WithAlpha<bpp>};
@ -730,7 +730,7 @@ void CSDL_Ext::blitWithRotateClipWithAlpha(SDL_Surface *src,SDL_Rect * srcRect,
}
}
template<int bpp>
template<int bpp>
void CSDL_Ext::blitWithRotateClipValWithAlpha( SDL_Surface *src,SDL_Rect srcRect, SDL_Surface * dst, SDL_Rect dstRect, ui8 rotation )
{
blitWithRotateClipWithAlpha<bpp>(src, &srcRect, dst, &dstRect, rotation);
@ -777,13 +777,13 @@ void CSDL_Ext::blitWithRotate3(const SDL_Surface *src, const SDL_Rect * srcRect,
Uint8 *sp = (Uint8 *)src->pixels + (src->h - srcRect->h - srcRect->y)*src->pitch + (src->w - srcRect->w - srcRect->x);
Uint8 *dporg = (Uint8 *)dst->pixels +(dstRect->y + dstRect->h - 1)*dst->pitch + (dstRect->x+dstRect->w)*bpp;
const SDL_Color * const colors = src->format->palette->colors;
for(int i=dstRect->h; i>0; i--, dporg -= dst->pitch)
{
Uint8 *dp = dporg;
for(int j=dstRect->w; j>0; j--, sp++)
ColorPutter<bpp, -1>::PutColor(dp, colors[*sp]);
sp += src->w - dstRect->w;
}
}
@ -1056,7 +1056,7 @@ void CSDL_Ext::setPlayerColor(SDL_Surface * sur, ui8 player)
return;
if(sur->format->BitsPerPixel==8)
{
SDL_Color *color = (player == 255
SDL_Color *color = (player == 255
? graphics->neutralColor
: &graphics->playerColors[player]);
SDL_SetColors(sur, color, 5, 1);
@ -1212,29 +1212,29 @@ void CSDL_Ext::applyEffect( SDL_Surface * surf, const SDL_Rect * rect, int mode
{
ui8 * pixels = (ui8*)surf->pixels + yp * surf->pitch + xp * surf->format->BytesPerPixel;
int b = pixels[0];
int g = pixels[1];
int r = pixels[2];
int b = pixels[0];
int g = pixels[1];
int r = pixels[2];
int gry = (r + g + b) / 3;
r = g = b = gry;
r = r + (sepiaDepth * 2);
g = g + sepiaDepth;
r = g = b = gry;
r = r + (sepiaDepth * 2);
g = g + sepiaDepth;
if (r>255) r=255;
if (g>255) g=255;
if (b>255) b=255;
if (r>255) r=255;
if (g>255) g=255;
if (b>255) b=255;
// Darken blue color to increase sepia effect
b -= sepiaIntensity;
// Darken blue color to increase sepia effect
b -= sepiaIntensity;
// normalize if out of bounds
if (b<0) b=0;
if (b>255) b=255;
// normalize if out of bounds
if (b<0) b=0;
if (b>255) b=255;
pixels[0] = b;
pixels[1] = g;
pixels[2] = r;
pixels[0] = b;
pixels[1] = g;
pixels[2] = r;
}
}
@ -1248,9 +1248,9 @@ void CSDL_Ext::applyEffect( SDL_Surface * surf, const SDL_Rect * rect, int mode
{
ui8 * pixels = (ui8*)surf->pixels + yp * surf->pitch + xp * surf->format->BytesPerPixel;
int b = pixels[0];
int g = pixels[1];
int r = pixels[2];
int b = pixels[0];
int g = pixels[1];
int r = pixels[2];
int gry = (r + g + b) / 3;
pixels[0] = pixels[1] = pixels[2] = gry;

View File

@ -40,7 +40,7 @@ bool isItIn(const SDL_Rect * rect, int x, int y);
namespace Colors
{
SDL_Color createColor(int r, int g, int b, int a = 0);
SDL_Color createColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 0);
const SDL_Color Jasmine = createColor(229, 215, 123, 0); // http://en.wikipedia.org/wiki/Jasmine_%28color%29
const SDL_Color Cornsilk = createColor(255, 243, 222, 0); // http://en.wikipedia.org/wiki/Shades_of_white

479
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.60)
AC_INIT(vcmi, 0.84b) # Follow VCMI_VERSION in GameConstants.h
AC_INIT(vcmi, 0.87b) # Follow VCMI_VERSION in GameConstants.h
AM_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIR([aclocal/m4])
@ -14,6 +14,7 @@ AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AX_COMPILER_VENDOR
# Use silent rules if supported.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@ -29,10 +30,13 @@ if test "x$GXX" = "xyes" -a "x$enable_debug" = "xyes" ; then
CXXFLAGS="$CXXFLAGS -O0 -ggdb"
fi
# For c++11 compatibility. Required at least in VCAI
CXXFLAGS="$CXXFLAGS -std=c++0x"
# For gcc and compatible compilers, enable compilation warnings, but
# selectively disable some because too many are generated.
if test "x$GXX" = "xyes" ; then
CXXFLAGS="$CXXFLAGS -Wall -Wno-switch -Wno-sign-compare -Wcast-align -Wpointer-arith -Wno-unknown-pragmas"
CXXFLAGS="$CXXFLAGS -Wall -Wno-switch -Wno-sign-compare -Wcast-align -Wpointer-arith"
fi
# extra clang parameters
@ -110,4 +114,4 @@ AC_SUBST(VCMI_AI_LIBS_DIR)
VCMI_SCRIPTING_LIBS_DIR="$libdir/vcmi/Scripting"
AC_SUBST(VCMI_SCRIPTING_LIBS_DIR)
AC_OUTPUT(Makefile lib/Makefile client/Makefile server/Makefile AI/Makefile AI/StupidAI/Makefile AI/GeniusAI/Makefile AI/EmptyAI/Makefile Scripting/ERM/Makefile)
AC_OUTPUT(Makefile lib/Makefile client/Makefile server/Makefile AI/Makefile AI/StupidAI/Makefile AI/EmptyAI/Makefile AI/VCAI/Makefile Scripting/ERM/Makefile)

View File

@ -36,7 +36,8 @@ public:
class DLL_LINKAGE CBuildingHandler
{
public:
std::vector< bmap<int, ConstTransitivePtr<CBuilding> > > buildings; ///< vector by castle ID, second the building ID (in ERM-U format)
typedef bmap<int, ConstTransitivePtr<CBuilding> > TBuildingsMap;
std::vector< TBuildingsMap > buildings; ///< vector by castle ID, second the building ID (in ERM-U format)
bmap<int, std::pair<std::string,std::vector< std::vector< std::vector<int> > > > > hall; //map<castle ID, pair<hall bg name, std::vector< std::vector<building id> >[5]> - external vector is the vector of buildings in the row, internal is the list of buildings for the specific slot
void loadBuildings(); //main loader

View File

@ -59,7 +59,7 @@ template <typename T> class CApplyOnGS;
class CBaseForGSApply
{
public:
virtual void applyOnGS(CGameState *gs, void *pack) const =0;
virtual void applyOnGS(CGameState *gs, void *pack) const =0;
virtual ~CBaseForGSApply(){};
template<typename U> static CBaseForGSApply *getApplier(const U * t=NULL)
{
@ -107,7 +107,7 @@ public:
class CObjectCallersHandler
{
public:
std::vector<IObjectCaller*> apps;
std::vector<IObjectCaller*> apps;
template<typename T> void registerType(const T * t=NULL)
{
@ -161,7 +161,7 @@ void InfoAboutTown::initFromTown( const CGTownInstance *t, bool detailed )
tType = t->town;
owner = t->tempOwner;
if(detailed)
if(detailed)
{
//include details about hero
details = new Details;
@ -336,7 +336,7 @@ DLL_LINKAGE std::string MetaString::buildList () const
{
size_t exSt = 0, loSt = 0, nums = 0;
std::string lista;
std::string lista;
for (int i = 0; i < message.size(); ++i)
{
if (i > 0 && (message[i] == TEXACT_STRING || message[i] == TLOCAL_STRING))
@ -557,9 +557,9 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
case 70: //random hero
return std::pair<int,int>(GameConstants::HEROI_TYPE,pickHero(obj->tempOwner));
case 71: //random monster
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran)));
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran)));
case 72: //random monster lvl1
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran), 1));
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran), 1));
case 73: //random monster lvl2
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran), 2));
case 74: //random monster lvl3
@ -567,7 +567,7 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
case 75: //random monster lvl4
return std::pair<int,int>(54, VLC->creh->pickRandomMonster(boost::ref(ran), 4));
case 76: //random resource
return std::pair<int,int>(79,ran()%7); //now it's OH3 style, use %8 for mithril
return std::pair<int,int>(79,ran()%7); //now it's OH3 style, use %8 for mithril
case 77: //random town
{
int align = (static_cast<CGTownInstance*>(obj))->alignment,
@ -584,7 +584,7 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
f = scenarioOps->getIthPlayersSettings(align).castle;
}
if(f<0) f = ran()%VLC->townh->towns.size();
return std::pair<int,int>(GameConstants::TOWNI_TYPE,f);
return std::pair<int,int>(GameConstants::TOWNI_TYPE,f);
}
case 162: //random monster lvl5
return std::pair<int,int>(54, VLC->creh->pickRandomMonster(boost::ref(ran), 5));
@ -627,7 +627,7 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
int cid = VLC->townh->towns[faction].basicCreatures[level];
for(ui32 i=0;i<VLC->objh->cregens.size();i++)
if(VLC->objh->cregens[i]==cid)
return std::pair<int,int>(17,i);
return std::pair<int,int>(17,i);
tlog3 << "Cannot find a dwelling for creature "<< cid << std::endl;
return std::pair<int,int>(17,0);
delete dwl->info;
@ -667,7 +667,7 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
int cid = VLC->townh->towns[faction].basicCreatures[obj->subID];
for(ui32 i=0;i<VLC->objh->cregens.size();i++)
if(VLC->objh->cregens[i]==cid)
return std::pair<int,int>(17,i);
return std::pair<int,int>(17,i);
tlog3 << "Cannot find a dwelling for creature "<<cid <<std::endl;
return std::pair<int,int>(17,0);
delete dwl->info;
@ -681,9 +681,9 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
int cid = VLC->townh->towns[obj->subID].basicCreatures[level];
for(ui32 i=0;i<VLC->objh->cregens.size();i++)
if(VLC->objh->cregens[i]==cid)
return std::pair<int,int>(17,i);
return std::pair<int,int>(17,i);
tlog3 << "Cannot find a dwelling for creature "<<cid <<std::endl;
return std::pair<int,int>(17,0);
return std::pair<int,int>(17,0);
delete dwl->info;
dwl->info = NULL;
}
@ -692,7 +692,7 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
}
void CGameState::randomizeObject(CGObjectInstance *cur)
{
{
std::pair<int,int> ran = pickObject(cur);
if(ran.first<0 || ran.second<0) //this is not a random object, or we couldn't find anything
{
@ -705,7 +705,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
else if(t->hasFort())
t->defInfo = forts[t->subID];
else
t->defInfo = villages[t->subID];
t->defInfo = villages[t->subID];
}
return;
}
@ -732,7 +732,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
else if(t->hasFort())
t->defInfo = forts[t->subID];
else
t->defInfo = villages[t->subID];
t->defInfo = villages[t->subID];
t->randomizeArmy(t->subID);
map->towns.push_back(t);
return;
@ -769,11 +769,11 @@ int CGameState::getDate(int mode) const
temp = ((day-1)/7)+1;
if (!(temp%4))
return 4;
else
else
return (temp%4);
break;
case 3: //current month
return ((day-1)/28)+1;
return ((day-1)/28)+1;
break;
case 4: //day of month
temp = (day)%28;
@ -877,7 +877,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
static std::vector<const PlayerSettings *> getHumanPlayerInfo(const StartInfo * si)
{
std::vector<const PlayerSettings *> ret;
for(std::map<int, PlayerSettings>::const_iterator it = si->playerInfos.begin();
for(std::map<int, PlayerSettings>::const_iterator it = si->playerInfos.begin();
it != si->playerInfos.end(); ++it)
{
if(it->second.human)
@ -887,7 +887,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
return ret;
}
static void replaceHero( CGameState * gs, int objId, CGHeroInstance * ghi )
static void replaceHero( CGameState * gs, int objId, CGHeroInstance * ghi )
{
ghi->id = objId;
gs->map->objects[objId] = ghi;
@ -901,7 +901,6 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
}
};
seed = Seed;
ran.seed((boost::int32_t)seed);
scenarioOps = new StartInfo(*si);
@ -926,13 +925,11 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
break;
case StartInfo::DUEL:
{
bool success = false;
DuelParameters dp;
try
{
CLoadFile lf(scenarioOps->mapname);
lf >> dp;
success = true;
}
catch(...)
{}
@ -958,7 +955,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
CGCreature *c = new CGCreature();
armies[i] = obj = c;
c->subID = 34;
}
obj->initObj();
@ -1008,7 +1005,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
std::vector<int3> allowedPos;
// add all not blocked tiles in range
for (int i = 0; i < map->width ; i++)
{
@ -1017,16 +1014,16 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
for (int k = 0; k <= map->twoLevel ; k++)
{
const TerrainTile &t = map->terrain[i][j][k];
if(!t.blocked
&& !t.visitable
&& t.tertype != TerrainTile::water
if(!t.blocked
&& !t.visitable
&& t.tertype != TerrainTile::water
&& t.tertype != TerrainTile::rock
&& map->grailPos.dist2d(int3(i,j,k)) <= map->grailRadious)
allowedPos.push_back(int3(i,j,k));
}
}
}
//remove tiles with holes
for(ui32 no=0; no<map->objects.size(); ++no)
if(map->objects[no]->ID == 124)
@ -1039,7 +1036,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
}
//picking random factions for players
for(std::map<int, PlayerSettings>::iterator it = scenarioOps->playerInfos.begin();
for(std::map<int, PlayerSettings>::iterator it = scenarioOps->playerInfos.begin();
it != scenarioOps->playerInfos.end(); ++it)
{
if(it->second.castle==-1)
@ -1072,7 +1069,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
//std::cout<<"\tRandomizing objects: "<<th.getDif()<<std::endl;
/*********creating players entries in gs****************************************/
for(std::map<int, PlayerSettings>::iterator it = scenarioOps->playerInfos.begin();
for(std::map<int, PlayerSettings>::iterator it = scenarioOps->playerInfos.begin();
it != scenarioOps->playerInfos.end(); ++it)
{
std::pair<int,PlayerState> ins(it->first,PlayerState());
@ -1214,7 +1211,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
//give start resource bonus in case of campaign
if (scenarioOps->mode == StartInfo::CAMPAIGN)
{
CScenarioTravel::STravelBonus chosenBonus =
CScenarioTravel::STravelBonus chosenBonus =
campaign->camp->scenarios[scenarioOps->whichMapInCampaign].travelOptions.bonusesToChoose[scenarioOps->choosenCampaignBonus];
if(chosenBonus.type == 7) //resource
{
@ -1299,7 +1296,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
if (scenarioOps->mode == StartInfo::CAMPAIGN) //give campaign bonuses for specific / best hero
{
CScenarioTravel::STravelBonus chosenBonus =
CScenarioTravel::STravelBonus chosenBonus =
campaign->camp->scenarios[scenarioOps->whichMapInCampaign].travelOptions.bonusesToChoose[scenarioOps->choosenCampaignBonus];
if (chosenBonus.isBonusForHero() && chosenBonus.info1 != 0xFFFE) //exclude generated heroes
{
@ -1372,7 +1369,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
}
}
}
for(std::map<ui8, PlayerState>::iterator k=players.begin(); k!=players.end(); ++k)
{
//starting bonus
@ -1416,7 +1413,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
/****************************TOWNS************************************************/
for ( int i=0; i<4; i++)
CGTownInstance::universitySkills.push_back(14+i);//skills for university
for (ui32 i=0;i<map->towns.size();i++)
{
CGTownInstance * vti =(map->towns[i]);
@ -1435,10 +1432,10 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
if(ran()%2)
vti->builtBuildings.insert(31);
}
if (vstd::contains(vti->builtBuildings,(6)) && vti->state()==2)
vti->builtBuildings.erase(6);//if we have harbor without water - erase it (this is H3 behaviour)
//init hordes
for (int i = 0; i<GameConstants::CREATURES_PER_TOWN; i++)
if (vstd::contains(vti->builtBuildings,(-31-i))) //if we have horde for this level
@ -1457,7 +1454,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
vti->builtBuildings.insert(25);
}
}
//town events
BOOST_FOREACH(CCastleEvent *ev, vti->events)
{
@ -1511,7 +1508,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
//campaign bonuses for towns
if (scenarioOps->mode == StartInfo::CAMPAIGN)
{
CScenarioTravel::STravelBonus chosenBonus =
CScenarioTravel::STravelBonus chosenBonus =
campaign->camp->scenarios[scenarioOps->whichMapInCampaign].travelOptions.bonusesToChoose[scenarioOps->choosenCampaignBonus];
if (chosenBonus.type == 2)
@ -1519,14 +1516,17 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
for (int g=0; g<map->towns.size(); ++g)
{
PlayerState * owner = getPlayer(map->towns[g]->getOwner());
PlayerInfo & pi = map->players[owner->color];
if (owner->human && //human-owned
map->towns[g]->pos == pi.posOfMainTown + int3(2, 0, 0))
if (owner)
{
map->towns[g]->builtBuildings.insert(
CBuildingHandler::campToERMU(chosenBonus.info1, map->towns[g]->town->typeID, map->towns[g]->builtBuildings));
break;
PlayerInfo & pi = map->players[owner->color];
if (owner->human && //human-owned
map->towns[g]->pos == pi.posOfMainTown + int3(2, 0, 0))
{
map->towns[g]->builtBuildings.insert(
CBuildingHandler::campToERMU(chosenBonus.info1, map->towns[g]->town->typeID, map->towns[g]->builtBuildings));
break;
}
}
}
}
@ -1551,7 +1551,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
//init visiting and garrisoned heroes
BOOST_FOREACH(CGHeroInstance *h, k->second.heroes)
{
{
BOOST_FOREACH(CGTownInstance *t, k->second.towns)
{
int3 vistile = t->pos; vistile.x--; //tile next to the entrance
@ -1589,8 +1589,8 @@ int CGameState::battleGetBattlefieldType(int3 tile)
const std::vector <ConstTransitivePtr<CGObjectInstance> > & objs = map->objects;
for(int g=0; g<objs.size(); ++g)
{
if( !objs[g] || objs[g]->pos.x - tile.x < 0 || objs[g]->pos.x - tile.x >= 8
|| tile.y - objs[g]->pos.y + 5 < 0 || tile.y - objs[g]->pos.y + 5 >=6
if( !objs[g] || objs[g]->pos.x - tile.x < 0 || objs[g]->pos.x - tile.x >= 8
|| tile.y - objs[g]->pos.y + 5 < 0 || tile.y - objs[g]->pos.y + 5 >=6
|| !objs[g]->coveringAt(objs[g]->pos.x - tile.x, tile.y - objs[g]->pos.y + 5)
) //look only for objects covering given tile
continue;
@ -1701,7 +1701,7 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack)
}
//hero is visiting Hill Fort
if(h && map->getTile(h->visitablePos()).visitableObjects.front()->ID == 35)
if(h && map->getTile(h->visitablePos()).visitableObjects.front()->ID == 35)
{
static const int costModifiers[] = {0, 25, 50, 75, 100}; //we get cheaper upgrades depending on level
const int costModifier = costModifiers[std::min<int>(std::max((int)base->level - 1, 0), ARRAY_COUNT(costModifiers) - 1)];
@ -1724,7 +1724,7 @@ int CGameState::getPlayerRelations( ui8 color1, ui8 color2 )
if ( color1 == color2 )
return 2;
if(color1 == 255 || color2 == 255) //neutral player has no friends
return 0;
return 0;
const TeamState * ts = getPlayerTeam(color1);
if (ts && vstd::contains(ts->players, color2))
@ -1752,7 +1752,7 @@ void CGameState::loadTownDInfos()
capitols[i] = new CGDefInfo(*VLC->dobjinfo->castles[i]);
capitols[i]->name = t["capitol"].String();
map->defy.push_back(capitols[i]);
++i;
}
}
@ -1765,7 +1765,7 @@ void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vector<i
for (size_t i = 0; i < ARRAY_COUNT(dirs); i++)
{
const int3 hlp = tile + dirs[i];
if(!map->isInTheMap(hlp))
if(!map->isInTheMap(hlp))
continue;
const TerrainTile &hlpt = map->getTile(hlp);
@ -1787,8 +1787,8 @@ void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vector<i
continue;
}
if((indeterminate(onLand) || onLand == (hlpt.tertype!=TerrainTile::water) )
&& hlpt.tertype != TerrainTile::rock)
if((indeterminate(onLand) || onLand == (hlpt.tertype!=TerrainTile::water) )
&& hlpt.tertype != TerrainTile::rock)
{
vec.push_back(hlp);
}
@ -1886,9 +1886,9 @@ int3 CGameState::guardingCreaturePosition (int3 pos) const
if (!map->isInTheMap(pos))
return int3(-1, -1, -1);
const TerrainTile &posTile = map->terrain[pos.x][pos.y][pos.z];
if (posTile.visitable)
if (posTile.visitable)
{
BOOST_FOREACH (CGObjectInstance* obj, posTile.visitableObjects)
BOOST_FOREACH (CGObjectInstance* obj, posTile.visitableObjects)
{
if(obj->blockVisit)
{
@ -1902,19 +1902,19 @@ int3 CGameState::guardingCreaturePosition (int3 pos) const
// See if there are any monsters adjacent.
pos -= int3(1, 1, 0); // Start with top left.
for (int dx = 0; dx < 3; dx++)
for (int dx = 0; dx < 3; dx++)
{
for (int dy = 0; dy < 3; dy++)
for (int dy = 0; dy < 3; dy++)
{
if (map->isInTheMap(pos))
if (map->isInTheMap(pos))
{
TerrainTile &tile = map->terrain[pos.x][pos.y][pos.z];
if (tile.visitable && (tile.tertype == TerrainTile::water) == (posTile.tertype == TerrainTile::water))
if (tile.visitable && (tile.tertype == TerrainTile::water) == (posTile.tertype == TerrainTile::water))
{
BOOST_FOREACH (CGObjectInstance* obj, tile.visitableObjects)
BOOST_FOREACH (CGObjectInstance* obj, tile.visitableObjects)
{
if (obj->ID == 54 && checkForVisitableDir(pos, &map->getTile(originalPos), originalPos)) // Monster being able to attack investigated tile
{
{
return pos;
}
}
@ -1950,8 +1950,8 @@ bool CGameState::isVisible( const CGObjectInstance *obj, int player )
for(int fy=0; fy<6; ++fy)
{
int3 pos = obj->pos + int3(fx-7,fy-5,0);
if(map->isInTheMap(pos)
&& !((obj->defInfo->blockMap[fy] >> (7 - fx)) & 1)
if(map->isInTheMap(pos)
&& !((obj->defInfo->blockMap[fy] >> (7 - fx)) & 1)
&& isVisible(pos, player) )
return true;
}
@ -2044,7 +2044,7 @@ int CGameState::victoryCheck( ui8 player ) const
for(size_t i = 0; i < map->objects.size(); i++)
{
const CArmedInstance *ai = NULL;
if(map->objects[i]
if(map->objects[i]
&& map->objects[i]->tempOwner == player //object controlled by player
&& (ai = dynamic_cast<const CArmedInstance*>(map->objects[i].get()))) //contains army
{
@ -2076,7 +2076,7 @@ int CGameState::victoryCheck( ui8 player ) const
case EVictoryConditionType::BUILDGRAIL:
BOOST_FOREACH(const CGTownInstance *t, map->towns)
if((t == map->victoryCondition.obj || !map->victoryCondition.obj)
&& t->tempOwner == player
&& t->tempOwner == player
&& vstd::contains(t->builtBuildings, 26))
return 1;
break;
@ -2149,7 +2149,7 @@ ui8 CGameState::checkForStandardWin() const
{
if(i->second.status == PlayerState::INGAME && i->first < GameConstants::PLAYER_LIMIT)
{
if(supposedWinner == 255)
if(supposedWinner == 255)
{
//first player remaining ingame - candidate for victory
supposedWinner = i->second.color;
@ -2262,7 +2262,7 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
if(g->second.color != 255)
tgi.playerColors.push_back(g->second.color);
}
if(level >= 1) //num of towns & num of heroes
{
//num of towns
@ -2327,7 +2327,7 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
{
tgi.personality[g->second.color] = map->players[g->second.color].AITactic;
}
}
}
if(level >= 10) //best creature
@ -2421,7 +2421,7 @@ void CGameState::buildBonusSystemTree()
{
t->deserializationFix();
}
// CStackInstance <-> CCreature, CStackInstance <-> CArmedInstance, CArtifactInstance <-> CArtifact
// CStackInstance <-> CCreature, CStackInstance <-> CArmedInstance, CArtifactInstance <-> CArtifact
// are provided on initializing / deserializing
}
@ -2559,8 +2559,8 @@ void CGPath::convert( ui8 mode )
}
}
PlayerState::PlayerState()
: color(-1), currentSelection(0xffffffff), enteredWinningCheatCode(0),
PlayerState::PlayerState()
: color(-1), currentSelection(0xffffffff), enteredWinningCheatCode(0),
enteredLosingCheatCode(0), status(INGAME), daysWithoutCastle(0)
{
setNodeType(PLAYER);
@ -2575,7 +2575,7 @@ std::string PlayerState::nodeName() const
// {
// return; //no loops possible
// }
//
//
// void PlayerState::getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root /*= NULL*/) const
// {
// for (std::vector<CGHeroInstance *>::const_iterator it = heroes.begin(); it != heroes.end(); it++)
@ -2612,7 +2612,7 @@ void InfoAboutHero::initFromHero( const CGHeroInstance *h, bool detailed )
portrait = h->portrait;
army = ArmyDescriptor(h, detailed);
if(detailed)
if(detailed)
{
//include details about hero
details = new Details;
@ -2857,7 +2857,7 @@ void CPathfinder::calculatePaths(int3 src /*= int3(-1,-1,-1)*/, int movement /*=
dp->turns = turnAtNextTile;
dp->theNodeBefore = cp;
const bool guardedDst = guardingCreaturePosition(dp->coord) != int3(-1, -1, -1)
const bool guardedDst = guardingCreaturePosition(dp->coord) != int3(-1, -1, -1)
&& dp->accessible == CGPathNode::BLOCKVIS;
if (dp->accessible == CGPathNode::ACCESSIBLE
@ -2898,7 +2898,7 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile
if(tinfo->tertype == TerrainTile::rock || !FoW[curPos.x][curPos.y][curPos.z])
return CGPathNode::BLOCKED;
if(tinfo->visitable)
{
if(tinfo->visitableObjects.front()->ID == 80 && tinfo->visitableObjects.back()->ID == GameConstants::HEROI_TYPE && tinfo->visitableObjects.back()->tempOwner != hero->tempOwner) //non-owned hero stands on Sanctuary
@ -2941,20 +2941,20 @@ bool CPathfinder::goodForLandSeaTransition()
if(cp->land) //from land to sea -> embark or assault hero on boat
{
if(dp->accessible == CGPathNode::ACCESSIBLE || destTopVisObjID < 0) //cannot enter empty water tile from land -> it has to be visitable
return false;
return false;
if(destTopVisObjID != GameConstants::HEROI_TYPE && destTopVisObjID != GameConstants::BOATI_TYPE) //only boat or hero can be accessed from land
return false;
if(destTopVisObjID == GameConstants::BOATI_TYPE)
useEmbarkCost = 1;
useEmbarkCost = 1;
}
else //disembark
{
//can disembark only on coastal tiles
if(!dt->isCoastal())
if(!dt->isCoastal())
return false;
//tile must be accessible -> exception: unblocked blockvis tiles -> clear but guarded by nearby monster coast
if(dp->accessible != CGPathNode::ACCESSIBLE && (dp->accessible != CGPathNode::BLOCKVIS || dt->blocked)
if( (dp->accessible != CGPathNode::ACCESSIBLE && (dp->accessible != CGPathNode::BLOCKVIS || dt->blocked))
|| dt->visitable) //TODO: passableness problem -> town says it's passable (thus accessible) but we obviously can't disembark onto town gate
return false;;
@ -2962,7 +2962,7 @@ bool CPathfinder::goodForLandSeaTransition()
}
}
return true;
return true;
}
CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance *_hero) : CGameInfoCallback(_gs, -1), out(_out), hero(_hero), FoW(getPlayerTeam(hero->tempOwner)->fogOfWarMap)

View File

@ -1273,32 +1273,14 @@ void CGameHandler::run(bool resume)
{
static time_duration p = milliseconds(200);
states.cv.timed_wait(lock,p);
}
}
}
while(conns.size() && (*conns.begin())->isOpen())
boost::this_thread::sleep(boost::posix_time::milliseconds(5)); //give time client to close socket
}
//namespace CGH
//{
// using namespace std;
// static void readItTo(ifstream & input, vector< vector<int> > & dest) //reads 7 lines, i-th one containing i integers, and puts it to dest
// {
// for(int j=0; j<7; ++j)
// {
// std::vector<int> pom;
// for(int g=0; g<j+1; ++g)
// {
// int hlp; input>>hlp;
// pom.push_back(hlp);
// }
// dest.push_back(pom);
// }
// }
//}
void CGameHandler::setupBattle( int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town )
{
battleResult.set(NULL);
@ -3437,6 +3419,21 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message )
sendAndApply(&cs);
sendAndApply(&sm);
}
else if (message == "vcmiarmenelos") //build all buildings in selected town
{
CGTownInstance *town = gs->getTown(gs->getPlayer(player)->currentSelection);
if (town)
{
BOOST_FOREACH (CBuildingHandler::TBuildingsMap::value_type &build, VLC->buildh->buildings[town->subID])
{
if (!vstd::contains(town->builtBuildings, build.first)
&& !build.second->Name().empty())
{
buildStructure(town->id, build.first, true);
}
}
}
}
else if(message == "vcmiainur") //gives 5 archangels into each slot
{
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
@ -3512,12 +3509,10 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message )
else if(message == "vcmisilmaril") //player wins
{
gs->getPlayer(player)->enteredWinningCheatCode = 1;
checkLossVictory(player);
}
else if(message == "vcmimelkor") //player looses
{
gs->getPlayer(player)->enteredLosingCheatCode = 1;
checkLossVictory(player);
}
else if (message == "vcmiforgeofnoldorking") //hero gets all artifacts except war machines, spell scrolls and spell book
{
@ -3532,6 +3527,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message )
{
SystemMessage temp_message(VLC->generaltexth->allTexts[260]);
sendAndApply(&temp_message);
checkLossVictory(player);//Player enter win code or got required art\creature
}
}
@ -4484,6 +4480,7 @@ void CGameHandler::engageIntoBattle( ui8 player )
void CGameHandler::winLoseHandle(ui8 players )
{
for(size_t i = 0; i < GameConstants::PLAYER_LIMIT; i++)
{
if(players & 1<<i && gs->getPlayer(i))
@ -4505,10 +4502,10 @@ void CGameHandler::checkLossVictory( ui8 player )
if(!loss && !vic)
return;
InfoWindow iw;
getLossVicMessage(player, vic ? vic : loss , vic, iw);
sendAndApply(&iw);
PlayerEndsGame peg;
peg.player = player;
peg.victory = vic;
@ -4545,28 +4542,28 @@ void CGameHandler::checkLossVictory( ui8 player )
//eliminating one player may cause victory of another:
winLoseHandle(GameConstants::ALL_PLAYERS & ~(1<<player));
}
}
if(vic)
{
{
end2 = true;
if(gs->campaign)
{
{
std::vector<CGHeroInstance *> hes;
BOOST_FOREACH(CGHeroInstance * ghi, gs->map->heroes)
{
{
if (ghi->tempOwner == vic)
{
{
hes.push_back(ghi);
}
}
}
gs->campaign->mapConquered(hes);
UpdateCampaignState ucs;
ucs.camp = gs->campaign;
sendAndApply(&ucs);
}
}
}
}