From 7f04ed990b7e6c1489933d2f8816cada1e22094b Mon Sep 17 00:00:00 2001 From: beegee1 Date: Tue, 13 Dec 2011 21:23:17 +0000 Subject: [PATCH] Major refactoring. First part: BattleInterface Introduction of pre compiled headers,... --- AI/EmptyAI/CEmptyAI.cpp | 3 +- AI/EmptyAI/CEmptyAI.h | 2 + AI/EmptyAI/Makefile.am | 5 +- AI/EmptyAI/Makefile.in | 43 ++- AI/EmptyAI/exp_funcs.cpp | 18 +- AI/GeniusAI/AIPriorities.cpp | 24 +- AI/GeniusAI/AIPriorities.h | 19 +- AI/GeniusAI/BattleHelper.cpp | 46 ++- AI/GeniusAI/BattleHelper.h | 7 +- AI/GeniusAI/BattleLogic.cpp | 49 ++- AI/GeniusAI/BattleLogic.h | 9 +- AI/GeniusAI/CGeniusAI.cpp | 33 +- AI/GeniusAI/CGeniusAI.h | 26 +- AI/GeniusAI/Common.h | 9 +- AI/GeniusAI/DLLMain.cpp | 18 +- AI/GeniusAI/ExpertSystem.cpp | 3 +- AI/GeniusAI/ExpertSystem.h | 4 +- AI/GeniusAI/GeneralAI.cpp | 2 + AI/GeniusAI/GeneralAI.h | 7 +- AI/GeniusAI/Makefile.am | 4 + AI/GeniusAI/Makefile.in | 97 +++++- AI/GeniusAI/genius.vcxproj | 10 +- AI/GeniusAI/neuralNetwork.cpp | 17 +- AI/GeniusAI/neuralNetwork.h | 10 +- AI/StupidAI/Makefile.am | 7 +- AI/StupidAI/Makefile.in | 46 ++- AI/StupidAI/StupidAI.cpp | 35 +- AI/StupidAI/StupidAI.h | 6 +- AI/StupidAI/StupidAI.vcxproj | 12 +- AI/StupidAI/main.cpp | 15 +- CCallback.cpp | 9 +- CCallback.h | 13 +- Scripting/ERM/ERM.vcxproj | 9 +- Scripting/ERM/ERMInterpreter.cpp | 20 +- Scripting/ERM/ERMInterpreter.h | 11 +- Scripting/ERM/ERMParser.cpp | 5 +- Scripting/ERM/ERMParser.h | 4 +- Scripting/ERM/ERMScriptModule.cpp | 6 +- Scripting/ERM/Makefile.am | 5 +- Scripting/ERM/Makefile.in | 17 +- VCMI_global.props | 4 +- aclocal.m4 | 4 +- client/AdventureMapButton.cpp | 33 +- client/AdventureMapButton.h | 8 +- client/CAdvmapInterface.cpp | 55 ++-- client/CAdvmapInterface.h | 14 +- client/CAnimation.cpp | 79 +++-- client/CAnimation.h | 34 +- client/CBitmapHandler.cpp | 19 +- client/CBitmapHandler.h | 11 +- client/CCastleInterface.cpp | 144 ++++---- client/CCastleInterface.h | 12 +- client/CConfigHandler.cpp | 17 +- client/CConfigHandler.h | 9 +- client/CCreatureAnimation.cpp | 29 +- client/CCreatureAnimation.h | 20 +- client/CCreatureWindow.cpp | 19 +- client/CCreatureWindow.h | 4 +- client/CCursorHandler.cpp | 3 +- client/CCursorHandler.h | 12 +- client/CDefHandler.cpp | 66 ++-- client/CDefHandler.h | 27 +- client/CGameInfo.cpp | 3 +- client/CGameInfo.h | 19 +- client/CHeroWindow.cpp | 15 +- client/CHeroWindow.h | 6 +- client/CKingdomInterface.cpp | 37 +-- client/CKingdomInterface.h | 5 +- client/CMT.cpp | 71 ++-- client/CMessage.cpp | 49 ++- client/CMessage.h | 12 +- client/CMusicBase.h | 5 +- client/CMusicHandler.cpp | 29 +- client/CMusicHandler.h | 18 +- client/CPlayerInterface.cpp | 62 ++-- client/CPlayerInterface.h | 16 +- client/CPreGame.cpp | 91 +++-- client/CPreGame.h | 17 +- client/CSndHandler.cpp | 15 +- client/CSndHandler.h | 13 +- client/CSoundBase.h | 7 +- client/CSpellWindow.cpp | 29 +- client/CSpellWindow.h | 7 +- client/CVideoHandler.cpp | 35 +- client/CVideoHandler.h | 9 +- client/Client.cpp | 54 ++- client/Client.h | 11 +- client/FontBase.h | 11 +- client/FunctionList.h | 9 +- client/GUIBase.cpp | 20 +- client/GUIBase.h | 16 +- client/GUIClasses.cpp | 297 ++++++++--------- client/GUIClasses.h | 32 +- client/Graphics.cpp | 63 ++-- client/Graphics.h | 12 +- client/Makefile.am | 50 ++- client/Makefile.in | 432 +++++++++++++++++++++--- client/NetPacksClient.cpp | 13 +- client/SDL_Extensions.cpp | 24 +- client/SDL_Extensions.h | 17 +- client/SDL_framerate.cpp | 72 ++-- client/SDL_framerate.h | 47 ++- client/VCMI_client.vcxproj | 62 +++- client/mapHandler.cpp | 56 ++-- client/mapHandler.h | 25 +- configure | 91 +++-- configure.ac | 6 +- lib/BattleAction.cpp | 7 +- lib/BattleAction.h | 15 +- lib/BattleState.cpp | 529 +++++++++++++++--------------- lib/BattleState.h | 91 ++--- lib/CArtHandler.cpp | 71 ++-- lib/CArtHandler.h | 46 +-- lib/CBuildingHandler.cpp | 26 +- lib/CBuildingHandler.h | 15 +- lib/CCampaignHandler.cpp | 36 +- lib/CCampaignHandler.h | 38 +-- lib/CCreatureHandler.cpp | 36 +- lib/CCreatureHandler.h | 27 +- lib/CCreatureSet.cpp | 37 +-- lib/CCreatureSet.h | 25 +- lib/CDefObjInfoHandler.cpp | 9 +- lib/CDefObjInfoHandler.h | 14 +- lib/CFileUtility.cpp | 4 +- lib/CFileUtility.h | 5 +- lib/CGameInterface.cpp | 16 +- lib/CGameInterface.h | 22 +- lib/CGameState.cpp | 195 ++++++----- lib/CGameState.h | 58 ++-- lib/CGeneralTextHandler.cpp | 34 +- lib/CGeneralTextHandler.h | 16 +- lib/CHeroHandler.cpp | 59 ++-- lib/CHeroHandler.h | 36 +- lib/CLodHandler.cpp | 54 ++- lib/CLodHandler.h | 31 +- lib/CMapInfo.cpp | 11 +- lib/CMapInfo.h | 8 +- lib/CObjectHandler.cpp | 329 +++++++++---------- lib/CObjectHandler.h | 189 +++++------ lib/CObstacleInstance.h | 2 +- lib/CScriptingModule.h | 13 +- lib/CSpellHandler.cpp | 14 +- lib/CSpellHandler.h | 18 +- lib/CTownHandler.cpp | 15 +- lib/CTownHandler.h | 17 +- lib/CondSh.h | 5 +- lib/Connection.cpp | 13 +- lib/Connection.h | 51 ++- lib/ConstTransitivePtr.h | 10 + lib/HeroBonus.cpp | 96 +++--- lib/HeroBonus.h | 97 +++--- lib/IGameCallback.cpp | 114 +++---- lib/IGameCallback.h | 63 ++-- lib/IGameEventsReceiver.h | 12 +- lib/Interprocess.h | 2 + lib/JsonNode.cpp | 22 +- lib/JsonNode.h | 16 +- lib/Makefile.am | 15 +- lib/Makefile.in | 87 +++-- lib/NetPacks.h | 172 +++++----- lib/NetPacksLib.cpp | 225 +++++++------ lib/RegisterTypes.h | 244 +++++++++++++- lib/ResourceSet.cpp | 17 +- lib/ResourceSet.h | 24 +- lib/VCMIDirs.h | 11 +- lib/VCMI_Lib.cpp | 58 ++-- lib/VCMI_Lib.h | 19 +- lib/VCMI_lib.vcxproj | 31 +- lib/map.cpp | 261 ++++++++------- lib/map.h | 107 +++--- lib/vcmi_endian.h | 78 +++-- server/CGameHandler.cpp | 326 +++++++++--------- server/CGameHandler.h | 15 +- server/CVCMIServer.cpp | 38 ++- server/CVCMIServer.h | 11 +- server/Makefile.am | 13 +- server/Makefile.in | 83 +---- server/NetPacksServer.cpp | 27 +- server/VCMI_server.vcxproj | 12 +- 179 files changed, 4076 insertions(+), 3765 deletions(-) diff --git a/AI/EmptyAI/CEmptyAI.cpp b/AI/EmptyAI/CEmptyAI.cpp index 0e19deaab..5991ccd3f 100644 --- a/AI/EmptyAI/CEmptyAI.cpp +++ b/AI/EmptyAI/CEmptyAI.cpp @@ -1,5 +1,6 @@ +#include "StdInc.h" #include "CEmptyAI.h" -#include + void CEmptyAI::init(CCallback * CB) { cb = CB; diff --git a/AI/EmptyAI/CEmptyAI.h b/AI/EmptyAI/CEmptyAI.h index c42a1bf8f..3ffb12124 100644 --- a/AI/EmptyAI/CEmptyAI.h +++ b/AI/EmptyAI/CEmptyAI.h @@ -1,3 +1,5 @@ +#pragma once + #include "../../AI_Base.h" #include "../../CCallback.h" diff --git a/AI/EmptyAI/Makefile.am b/AI/EmptyAI/Makefile.am index 3bda0893e..127353970 100644 --- a/AI/EmptyAI/Makefile.am +++ b/AI/EmptyAI/Makefile.am @@ -1,10 +1,13 @@ vcmiaidir = $(VCMI_AI_LIBS_DIR) +BUILT_SOURCES = StdInc.h.gch +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -DVCMI_DLL -fPIC -c $< vcmiai_LTLIBRARIES = libEmptyAI.la libEmptyAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la +libEmptyAI_la_CXXFLAGS = -DVCMI_DLL libEmptyAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version libEmptyAI_la_SOURCES = \ CEmptyAI.cpp \ CEmptyAI.h \ exp_funcs.cpp - diff --git a/AI/EmptyAI/Makefile.in b/AI/EmptyAI/Makefile.in index 70e5a6cfd..7513bc9f3 100644 --- a/AI/EmptyAI/Makefile.in +++ b/AI/EmptyAI/Makefile.in @@ -79,15 +79,16 @@ am__base_list = \ am__installdirs = "$(DESTDIR)$(vcmiaidir)" LTLIBRARIES = $(vcmiai_LTLIBRARIES) libEmptyAI_la_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la -am_libEmptyAI_la_OBJECTS = CEmptyAI.lo exp_funcs.lo +am_libEmptyAI_la_OBJECTS = libEmptyAI_la-CEmptyAI.lo \ + libEmptyAI_la-exp_funcs.lo libEmptyAI_la_OBJECTS = $(am_libEmptyAI_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libEmptyAI_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ - $(AM_CXXFLAGS) $(CXXFLAGS) $(libEmptyAI_la_LDFLAGS) $(LDFLAGS) \ - -o $@ + $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) $(libEmptyAI_la_LDFLAGS) \ + $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -270,15 +271,18 @@ 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 = libEmptyAI.la libEmptyAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la +libEmptyAI_la_CXXFLAGS = -DVCMI_DLL libEmptyAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version libEmptyAI_la_SOURCES = \ CEmptyAI.cpp \ CEmptyAI.h \ exp_funcs.cpp -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj @@ -352,8 +356,8 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CEmptyAI.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_funcs.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libEmptyAI_la-CEmptyAI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libEmptyAI_la-exp_funcs.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -379,6 +383,22 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< +libEmptyAI_la-CEmptyAI.lo: CEmptyAI.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) $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) -MT libEmptyAI_la-CEmptyAI.lo -MD -MP -MF $(DEPDIR)/libEmptyAI_la-CEmptyAI.Tpo -c -o libEmptyAI_la-CEmptyAI.lo `test -f 'CEmptyAI.cpp' || echo '$(srcdir)/'`CEmptyAI.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libEmptyAI_la-CEmptyAI.Tpo $(DEPDIR)/libEmptyAI_la-CEmptyAI.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CEmptyAI.cpp' object='libEmptyAI_la-CEmptyAI.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) $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libEmptyAI_la-CEmptyAI.lo `test -f 'CEmptyAI.cpp' || echo '$(srcdir)/'`CEmptyAI.cpp + +libEmptyAI_la-exp_funcs.lo: exp_funcs.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) $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) -MT libEmptyAI_la-exp_funcs.lo -MD -MP -MF $(DEPDIR)/libEmptyAI_la-exp_funcs.Tpo -c -o libEmptyAI_la-exp_funcs.lo `test -f 'exp_funcs.cpp' || echo '$(srcdir)/'`exp_funcs.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libEmptyAI_la-exp_funcs.Tpo $(DEPDIR)/libEmptyAI_la-exp_funcs.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='exp_funcs.cpp' object='libEmptyAI_la-exp_funcs.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) $(libEmptyAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libEmptyAI_la-exp_funcs.lo `test -f 'exp_funcs.cpp' || echo '$(srcdir)/'`exp_funcs.cpp + mostlyclean-libtool: -rm -f *.lo @@ -468,13 +488,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-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: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -499,6 +521,7 @@ distclean-generic: 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 \ @@ -570,7 +593,7 @@ ps-am: uninstall-am: uninstall-vcmiaiLTLIBRARIES -.MAKE: install-am install-strip +.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 \ @@ -586,6 +609,8 @@ uninstall-am: uninstall-vcmiaiLTLIBRARIES 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. diff --git a/AI/EmptyAI/exp_funcs.cpp b/AI/EmptyAI/exp_funcs.cpp index 1c700fe5d..e9d7f3175 100644 --- a/AI/EmptyAI/exp_funcs.cpp +++ b/AI/EmptyAI/exp_funcs.cpp @@ -1,31 +1,31 @@ -#define VCMI_DLL +#include "StdInc.h" + #include "../../AI_Base.h" #include "CEmptyAI.h" -#include -#include + std::set ais; -extern "C" DLL_EXPORT int GetGlobalAiVersion() +extern "C" DLL_LINKAGE int GetGlobalAiVersion() { return AI_INTERFACE_VER; } -extern "C" DLL_EXPORT void GetAiName(char* name) +extern "C" DLL_LINKAGE void GetAiName(char* name) { strcpy(name,NAME); } -extern "C" DLL_EXPORT char * GetAiNameS() +extern "C" DLL_LINKAGE char * GetAiNameS() { char * ret = new char[50]; strcpy(ret,NAME); return ret; } -extern "C" DLL_EXPORT CGlobalAI * GetNewAI() +extern "C" DLL_LINKAGE CGlobalAI * GetNewAI() { return new CEmptyAI(); // return } -extern "C" DLL_EXPORT void ReleaseAI(CGlobalAI * i) +extern "C" DLL_LINKAGE void ReleaseAI(CGlobalAI * i) { delete (CEmptyAI*)i; ais.erase(i); -} \ No newline at end of file +} diff --git a/AI/GeniusAI/AIPriorities.cpp b/AI/GeniusAI/AIPriorities.cpp index 3937646f0..11b1a0382 100644 --- a/AI/GeniusAI/AIPriorities.cpp +++ b/AI/GeniusAI/AIPriorities.cpp @@ -1,13 +1,12 @@ -#ifndef AI_PRIORITIES -#define AI_PRIORITIES +#include "StdInc.h" #include "AIPriorities.h" -#include + // TODO: No using namespace!! using namespace geniusai; Network::Network() {} -Network::Network(vector whichFeatures)// random network +Network::Network(vector whichFeatures)// random network : whichFeatures(whichFeatures), net(whichFeatures.size(), whichFeatures.size() * 0.601 + 2, @@ -34,15 +33,15 @@ Network::Network(istream & input) } -float Network::feedForward(const vector & stateFeatures) +double Network::feedForward(const vector & stateFeatures) { // TODO: Should comment/rewrite it... - return (rand() % 1000) / 800.0f; + return (rand() % 1000) / 800.0; double * input = new double[whichFeatures.size()]; for (int i = 0; i < whichFeatures.size(); i++) input[i] = stateFeatures[whichFeatures[i]]; - float ans = net.feedForwardPattern(input)[0]; + double ans = net.feedForwardPattern(input)[0]; delete input; return ans; @@ -98,18 +97,18 @@ void Priorities::fillFeatures(const CGeniusAI::HypotheticalGameState & hgs) } -float Priorities::getCost(vector &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay) +double Priorities::getCost(vector &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay) { if(!resourceCosts.size())return -1; //TODO: replace with ann - float cost = resourceCosts[0]/4.0+resourceCosts[1]/2.0+resourceCosts[2]/4.0+resourceCosts[3]/2.0+resourceCosts[4]/2.0+resourceCosts[5]/2.0+resourceCosts[6]/3000.0; + double cost = resourceCosts[0]/4.0+resourceCosts[1]/2.0+resourceCosts[2]/4.0+resourceCosts[3]/2.0+resourceCosts[4]/2.0+resourceCosts[5]/2.0+resourceCosts[6]/3000.0; if(moved) //TODO: multiply by importance of hero cost+=distOutOfTheWay/10000.0; return cost; } -float Priorities::getValue(const CGeniusAI::AIObjective & obj) +double Priorities::getValue(const CGeniusAI::AIObjective & obj) { //resource vector resourceAmounts(8,0); @@ -117,7 +116,7 @@ float Priorities::getValue(const CGeniusAI::AIObjective & obj) if(obj.type==CGeniusAI::AIObjective::finishTurn) //TODO: replace with value of visiting that object divided by days till completed return .0001; //small nonzero - float a; + double a; if(obj.type==CGeniusAI::AIObjective::attack) return 100; if(dynamic_cast(&obj)) @@ -249,5 +248,4 @@ float Priorities::getValue(const CGeniusAI::AIObjective & obj) return 0; -} -#endif +} \ No newline at end of file diff --git a/AI/GeniusAI/AIPriorities.h b/AI/GeniusAI/AIPriorities.h index b7b6c8189..08ca5319c 100644 --- a/AI/GeniusAI/AIPriorities.h +++ b/AI/GeniusAI/AIPriorities.h @@ -1,7 +1,5 @@ -#ifndef AIP_H -#define AIP_H +#pragma once -#include #include "CGeniusAI.h" #include "neuralNetwork.h" @@ -11,10 +9,10 @@ class Network { public: Network(); - Network(vector whichFeatures);// random network + Network(vector whichFeatures);// random network Network(istream & input); - vector whichFeatures; - float feedForward(const vector & stateFeatures); + vector whichFeatures; + double feedForward(const vector & stateFeatures); neuralNetwork net; //a network with whichFeatures.size() inputs, and 1 output }; @@ -25,15 +23,14 @@ public: Priorities(const string & filename); //read brain from file - vector stateFeatures; + vector stateFeatures; int specialFeaturesStart; int numSpecialFeatures; void fillFeatures(const CGeniusAI::HypotheticalGameState & AI); - float getValue(const CGeniusAI::AIObjective & obj); - float getCost(vector &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay); + double getValue(const CGeniusAI::AIObjective & obj); + double getCost(vector &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay); vector > objectNetworks; vector > buildingNetworks; }; -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/AI/GeniusAI/BattleHelper.cpp b/AI/GeniusAI/BattleHelper.cpp index a8d060489..32fcece6e 100644 --- a/AI/GeniusAI/BattleHelper.cpp +++ b/AI/GeniusAI/BattleHelper.cpp @@ -1,11 +1,5 @@ +#include "StdInc.h" #include "BattleHelper.h" -#include -#include -#include -#include -#include -#include -#include using namespace geniusai::BattleAI; using namespace std; @@ -13,8 +7,8 @@ using namespace std; CBattleHelper::CBattleHelper(): InfiniteDistance(0xffff), - BattlefieldWidth(BFIELD_WIDTH-2), - BattlefieldHeight(BFIELD_HEIGHT), + BattlefieldWidth(GameConstants::BFIELD_WIDTH-2), + BattlefieldHeight(GameConstants::BFIELD_HEIGHT), m_voteForMaxDamage(10), m_voteForMinDamage(10), m_voteForMaxSpeed(10), @@ -106,21 +100,21 @@ CBattleHelper::~CBattleHelper() int CBattleHelper::GetBattleFieldPosition(int x, int y) { - return x + BFIELD_WIDTH * (y - 1); + return x + GameConstants::BFIELD_WIDTH * (y - 1); } int CBattleHelper::DecodeXPosition(int battleFieldPosition) { - int x = battleFieldPosition%BFIELD_WIDTH; - assert( x > 0 && x < BFIELD_WIDTH-1 ); + int x = battleFieldPosition%GameConstants::BFIELD_WIDTH; + assert( x > 0 && x < GameConstants::BFIELD_WIDTH-1 ); return x; } int CBattleHelper::DecodeYPosition(int battleFieldPosition) { - int y=battleFieldPosition/BFIELD_WIDTH +1; - assert( y > 0 && y <= BFIELD_HEIGHT); + int y=battleFieldPosition/GameConstants::BFIELD_WIDTH +1; + assert( y > 0 && y <= GameConstants::BFIELD_HEIGHT); return y; } @@ -133,34 +127,34 @@ int CBattleHelper::StepLeft(int pos){ } int CBattleHelper::StepUpleft(int pos){ - if((pos/BFIELD_WIDTH)%2==0){ - return pos-BFIELD_WIDTH; + if((pos/GameConstants::BFIELD_WIDTH)%2==0){ + return pos-GameConstants::BFIELD_WIDTH; }else{ - return pos-BFIELD_WIDTH-1; + return pos-GameConstants::BFIELD_WIDTH-1; } } int CBattleHelper::StepUpright(int pos){ - if((pos/BFIELD_WIDTH)%2==0){ - return pos-BFIELD_WIDTH+1; + if((pos/GameConstants::BFIELD_WIDTH)%2==0){ + return pos-GameConstants::BFIELD_WIDTH+1; }else{ - return pos-BFIELD_WIDTH; + return pos-GameConstants::BFIELD_WIDTH; } } int CBattleHelper::StepDownleft(int pos){ - if((pos/BFIELD_WIDTH)%2==0){ - return pos+BFIELD_WIDTH; + if((pos/GameConstants::BFIELD_WIDTH)%2==0){ + return pos+GameConstants::BFIELD_WIDTH; }else{ - return pos+BFIELD_WIDTH-1; + return pos+GameConstants::BFIELD_WIDTH-1; } } int CBattleHelper::StepDownright(int pos){ - if((pos/BFIELD_WIDTH)%2==0){ - return pos+BFIELD_WIDTH+1; + if((pos/GameConstants::BFIELD_WIDTH)%2==0){ + return pos+GameConstants::BFIELD_WIDTH+1; }else{ - return pos+BFIELD_WIDTH; + return pos+GameConstants::BFIELD_WIDTH; } } diff --git a/AI/GeniusAI/BattleHelper.h b/AI/GeniusAI/BattleHelper.h index e1f4ffeeb..592983959 100644 --- a/AI/GeniusAI/BattleHelper.h +++ b/AI/GeniusAI/BattleHelper.h @@ -1,5 +1,4 @@ -#ifndef __BATTLE_HELPER__ -#define __BATTLE_HELPER__ +#pragma once #include "Common.h" @@ -47,6 +46,4 @@ private: CBattleHelper &operator=(const CBattleHelper &); }; -}} - -#endif/*__BATTLE_HELPER__*/ \ No newline at end of file +}} \ No newline at end of file diff --git a/AI/GeniusAI/BattleLogic.cpp b/AI/GeniusAI/BattleLogic.cpp index ffbb70550..0579ae29e 100644 --- a/AI/GeniusAI/BattleLogic.cpp +++ b/AI/GeniusAI/BattleLogic.cpp @@ -1,11 +1,10 @@ +#include "StdInc.h" #include "BattleLogic.h" + #include "../../lib/BattleState.h" -#include -#include #include #include #include -#include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing @@ -152,27 +151,27 @@ void CBattleLogic::MakeStatistics(int currentCreatureId) //CGHeroInstance *defendingHero = (m_side)? m_hero2 : m_hero1; int attackDefenseBonus = currentStack->Attack() - st->Defense(); - float damageFactor = 1.0f; + double damageFactor = 1.0; if(attackDefenseBonus < 0) //decreasing dmg { - if(0.02f * (-attackDefenseBonus) > 0.3f) + if(0.02 * (-attackDefenseBonus) > 0.3) { - damageFactor += -0.3f; + damageFactor += -0.3; } else { - damageFactor += 0.02f * attackDefenseBonus; + damageFactor += 0.02 * attackDefenseBonus; } } else //increasing dmg { - if(0.05f * attackDefenseBonus > 4.0f) + if(0.05 * attackDefenseBonus > 4.0) { - damageFactor += 4.0f; + damageFactor += 4.0; } else { - damageFactor += 0.05f * attackDefenseBonus; + damageFactor += 0.05 * attackDefenseBonus; } } @@ -222,8 +221,8 @@ void CBattleLogic::MakeStatistics(int currentCreatureId) totalHitPoints += hitPoints; } } - if ((float)totalDamage / (float)totalEnemyDamage < 0.5f && - (float)totalHitPoints / (float)totalEnemyHitPoints < 0.5f) + if (totalDamage / static_cast(totalEnemyDamage) < 0.5 && + totalHitPoints / static_cast(totalEnemyHitPoints) < 0.5) { m_bEnemyDominates = true; DbgBox("** EnemyDominates!"); @@ -240,29 +239,29 @@ void CBattleLogic::MakeStatistics(int currentCreatureId) // sort max damage std::sort(m_statMaxDamage.begin(), m_statMaxDamage.end(), - bind((IntPtr)&creature_stat::value_type::second, _1) > bind((IntPtr)&creature_stat::value_type::second, _2)); + bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2)); // sort min damage std::sort(m_statMinDamage.begin(), m_statMinDamage.end(), - bind((IntPtr)&creature_stat::value_type::second, _1) > bind((IntPtr)&creature_stat::value_type::second, _2)); + bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2)); // sort max speed std::sort(m_statMaxSpeed.begin(), m_statMaxSpeed.end(), - bind((IntPtr)&creature_stat::value_type::second, _1) > bind((IntPtr)&creature_stat::value_type::second, _2)); + bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2)); // sort distance std::sort(m_statDistance.begin(), m_statDistance.end(), - bind((IntPtr)&creature_stat::value_type::second, _1) < bind((IntPtr)&creature_stat::value_type::second, _2)); + bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) < bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2)); // sort distance from shooters std::sort(m_statDistanceFromShooters.begin(), m_statDistanceFromShooters.end(), - bind((IntPtr)&creature_stat::value_type::second, _1) < bind((IntPtr)&creature_stat::value_type::second, _2)); + bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) < bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2)); // sort hit points std::sort(m_statHitPoints.begin(), m_statHitPoints.end(), - bind((IntPtr)&creature_stat::value_type::second, _1) > bind((IntPtr)&creature_stat::value_type::second, _2)); + bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2)); // sort casualties std::sort(m_statCasualties.begin(), m_statCasualties.end(), bind((CreaPtr)&creature_stat_casualties::value_type::second_type::damage_max, - bind((CreaPairPtr)&creature_stat_casualties::value_type::second, _1)) + bind((CreaPairPtr)&creature_stat_casualties::value_type::second, boost::lambda::_1)) > bind((CreaPtr)&creature_stat_casualties::value_type::second_type::damage_max, - bind((CreaPairPtr)&creature_stat_casualties::value_type::second, _2))); + bind((CreaPairPtr)&creature_stat_casualties::value_type::second, boost::lambda::_2))); } BattleAction CBattleLogic::MakeDecision(int stackID) @@ -527,7 +526,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID) } } - std::vector fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false); + std::vector fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false); if(fields.size() == 0) { @@ -541,11 +540,11 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID) ba.destinationTile = static_cast(dest_tile); //simplified checking for possibility of attack (previous was too simplified) int destStackPos = m_cb->battleGetPos(destinationID); - if(THex::mutualPosition(dest_tile, destStackPos) != -1) + if(SHexField::mutualPosition(dest_tile, destStackPos) != -1) ba.additionalInfo = destStackPos; - else if(THex::mutualPosition(dest_tile, destStackPos+1) != -1) + else if(SHexField::mutualPosition(dest_tile, destStackPos+1) != -1) ba.additionalInfo = destStackPos+1; - else if(THex::mutualPosition(dest_tile, destStackPos-1) != -1) + else if(SHexField::mutualPosition(dest_tile, destStackPos-1) != -1) ba.additionalInfo = destStackPos-1; else return BattleAction::makeDefend(attackerStack); @@ -582,7 +581,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID) } } - for (std::vector::const_iterator it = fields.begin(); it != fields.end(); ++it) + for (std::vector::const_iterator it = fields.begin(); it != fields.end(); ++it) { if (*it == dest_tile) { diff --git a/AI/GeniusAI/BattleLogic.h b/AI/GeniusAI/BattleLogic.h index 2388ba8ee..e9c0130ac 100644 --- a/AI/GeniusAI/BattleLogic.h +++ b/AI/GeniusAI/BattleLogic.h @@ -1,11 +1,10 @@ -#ifndef __BATTLE_LOGIC_H__ -#define __BATTLE_LOGIC_H__ +#pragma once #include "Common.h" #include "BattleHelper.h" #pragma warning (disable: 4100 4251 4245 4018 4081) -#include "../../global.h" + #include "../../CCallback.h" #include "../../lib/CCreatureHandler.h" #include "../../lib/CObjectHandler.h" @@ -129,6 +128,4 @@ private: void PrintBattleAction(const BattleAction &action); }; -}} - -#endif/*__BATTLE_LOGIC_H__*/ \ No newline at end of file +}} \ No newline at end of file diff --git a/AI/GeniusAI/CGeniusAI.cpp b/AI/GeniusAI/CGeniusAI.cpp index 1011759a2..de8d3551f 100644 --- a/AI/GeniusAI/CGeniusAI.cpp +++ b/AI/GeniusAI/CGeniusAI.cpp @@ -1,8 +1,6 @@ +#include "StdInc.h" #include "CGeniusAI.h" -#include -#include - #include "../../lib/BattleState.h" #include "../../lib/CBuildingHandler.h" #include "../../lib/CHeroHandler.h" @@ -10,6 +8,7 @@ #include "../../lib/NetPacks.h" #include "AIPriorities.h" #include "../../lib/CGameState.h" +#include "../../lib/GameConstants.h" using std::endl; using geniusai::CGeniusAI; @@ -150,7 +149,7 @@ CGeniusAI::HeroObjective::HeroObjective(const HypotheticalGameState &hgs, } -float CGeniusAI::HeroObjective::getValue() const +double CGeniusAI::HeroObjective::getValue() const { if (_value >= 0) return _value - _cost; @@ -165,7 +164,7 @@ float CGeniusAI::HeroObjective::getValue() const resourceCosts[6] += 1000; // TODO: Add some meaningful (and not exploitable) number here. - float bestCost = 9e9f; + double bestCost = 9e9f; HypotheticalGameState::HeroModel* bestHero = NULL; if (type != AIObjective::finishTurn) { @@ -195,7 +194,7 @@ float CGeniusAI::HeroObjective::getValue() const distOutOfTheWay-=path3.nodes[0].dist; } - float cost = AI->m_priorities->getCost(resourceCosts, + double cost = AI->m_priorities->getCost(resourceCosts, whoCanAchieve[i]->h, distOutOfTheWay); if (cost < bestCost) @@ -269,7 +268,7 @@ CGeniusAI::TownObjective::TownObjective( _value = -1; } -float CGeniusAI::TownObjective::getValue() const +double CGeniusAI::TownObjective::getValue() const { if (_value >= 0) return _value - _cost; @@ -278,7 +277,7 @@ float CGeniusAI::TownObjective::getValue() const vector resourceCosts(8,0); CBuilding* b = NULL; CCreature* creature = NULL; - float cost = 0; // TODO: Needed? + double cost = 0; // TODO: Needed? int ID = 0; int newID = 0; int howMany = 0; @@ -310,7 +309,7 @@ float CGeniusAI::TownObjective::getValue() const else creatures_max = INT_MAX; // TODO: Will have to rewrite it. // TODO: Buy the best units (the least I can buy)? - amin(howMany, creatures_max); + vstd::amin(howMany, creatures_max); } // The cost of recruiting the stack of creatures. for (int i = 0; creature && (i < creature->cost.size() ); ++i) @@ -401,7 +400,7 @@ void CGeniusAI::TownObjective::print() const creatures_max = hgs.resourceAmounts[i]/creature->cost[i]; else creatures_max = INT_MAX; - amin(howMany, creatures_max); + vstd::amin(howMany, creatures_max); } tlog6 << "recruit " << howMany << " " << creature->namePl << " (Total AI Strength " << creature->AIValue*howMany @@ -503,7 +502,7 @@ void CGeniusAI::addHeroObjectives(CGeniusAI::HypotheticalGameState::HeroModel& h // maybe the hero wants to visit a seemingly unguarded enemy town, // but there is a hero on top of it. // if(i->o->) - if (i->o->ID != HEROI_TYPE) + if (i->o->ID != GameConstants::HEROI_TYPE) {// Unless you are trying to visit a hero. bool heroThere = false; for(int j = 0; j < hgs.heroModels.size(); j++) @@ -514,7 +513,7 @@ void CGeniusAI::addHeroObjectives(CGeniusAI::HypotheticalGameState::HeroModel& h if (heroThere) // It won't work if there is already someone visiting that spot. continue; } - if (i->o->ID == HEROI_TYPE && // Visiting friendly heroes not yet supported. + if (i->o->ID == GameConstants::HEROI_TYPE && // Visiting friendly heroes not yet supported. i->o->getOwner() == m_cb->getMyColor()) continue; if (i->o->id == h.h->id) // Don't visit yourself (should be caught by above). @@ -541,7 +540,7 @@ void CGeniusAI::addHeroObjectives(CGeniusAI::HypotheticalGameState::HeroModel& h // TODO: Make constants of those 1.2 & 2.5. if (dynamic_cast (i->o)) enemyStrength = static_cast((dynamic_cast (i->o))->getArmyStrength() * 1.2); - float heroStrength = h.h->getTotalStrength(); + double heroStrength = h.h->getTotalStrength(); // TODO: ballence these numbers using objective cost formula. // TODO: it would be nice to do a battle simulation. if (enemyStrength * 2.5 > heroStrength) @@ -945,7 +944,7 @@ void CGeniusAI::TownObjective::fulfill(CGeniusAI& cg, creature = VLC->creh->creatures[ID]; howMany = whichTown->creaturesToRecruit[which].first; for (int i = 0; i < creature->cost.size(); i++) - amin(howMany, creature->cost[i] ? hgs.resourceAmounts[i]/creature->cost[i] : INT_MAX); + vstd::amin(howMany, creature->cost[i] ? hgs.resourceAmounts[i]/creature->cost[i] : INT_MAX); if (howMany == 0) { tlog6 << "tried to recruit without enough money."; @@ -1262,7 +1261,7 @@ void CGeniusAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2 // TODO: Battle logic what... assert(!m_battleLogic); // We have been informed that battle will start (or we are neutral AI) - assert( (playerID > PLAYER_LIMIT) || (m_state.get() == UPCOMING_BATTLE) ); + assert( (playerID > GameConstants::PLAYER_LIMIT) || (m_state.get() == UPCOMING_BATTLE) ); m_state.setn(ONGOING_BATTLE); m_battleLogic = new BattleAI::CBattleLogic(m_cb, army1, army2, tile, hero1, @@ -1312,7 +1311,7 @@ void CGeniusAI::battleNewRound(int round) /** * */ -void CGeniusAI::battleStackMoved(int ID, std::vector dest, int distance) +void CGeniusAI::battleStackMoved(int ID, std::vector dest, int distance) { std::string message("\t\t\tCGeniusAI::battleStackMoved ID("); message += boost::lexical_cast(ID); @@ -1346,7 +1345,7 @@ void CGeniusAI::battleSpellCast(const BattleSpellCast *sc) * */ // void CGeniusAI::battleStackMoved(int ID, -// THex dest, +// SHexField dest, // bool startMoving, // bool endMoving) // { diff --git a/AI/GeniusAI/CGeniusAI.h b/AI/GeniusAI/CGeniusAI.h index f79d6fc7a..747ea024b 100644 --- a/AI/GeniusAI/CGeniusAI.h +++ b/AI/GeniusAI/CGeniusAI.h @@ -1,13 +1,9 @@ -#ifndef __CGENIUSAI_H__ -#define __CGENIUSAI_H__ +#pragma once #include "Common.h" #include "BattleLogic.h" #include "GeneralAI.h" #include "../../lib/CondSh.h" -#include -#include -#include class CBuilding; @@ -101,7 +97,7 @@ private: virtual void fulfill(CGeniusAI &,HypotheticalGameState & hgs)=0; virtual HypotheticalGameState pretend(const HypotheticalGameState&) =0; virtual void print() const=0; - virtual float getValue() const=0; //how much is it worth to the AI to achieve + virtual double getValue() const=0; //how much is it worth to the AI to achieve }; class HeroObjective: public AIObjective @@ -122,11 +118,11 @@ private: bool operator< (const HeroObjective &other) const; void fulfill(CGeniusAI &,HypotheticalGameState & hgs); HypotheticalGameState pretend(const HypotheticalGameState &hgs){return hgs;}; - float getValue() const; + double getValue() const; void print() const; private: - mutable float _value; - mutable float _cost; + mutable double _value; + mutable double _cost; }; //town objectives @@ -147,11 +143,11 @@ private: bool operator < (const TownObjective &other)const; void fulfill(CGeniusAI &,HypotheticalGameState & hgs); HypotheticalGameState pretend(const HypotheticalGameState &hgs){return hgs;}; - float getValue() const; + double getValue() const; void print() const; private: - mutable float _value; - mutable float _cost; + mutable double _value; + mutable double _cost; }; class AIObjectivePtrCont @@ -205,7 +201,7 @@ public: virtual void battleStacksAttacked(const std::set & bsa); //called when stack receives damage (after battleAttack()) virtual void battleEnd(const BattleResult *br); virtual void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn - virtual void battleStackMoved(int ID, std::vector dest, int distance); + virtual void battleStackMoved(int ID, std::vector dest, int distance); virtual void battleSpellCast(const BattleSpellCast *sc); virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right //virtual void battlefieldPrepared(int battlefieldType, std::vector obstacles); //called when battlefield is prepared, prior the battle beginning @@ -217,6 +213,4 @@ public: void battleResultsApplied(); friend class Priorities; }; -} - -#endif // __CGENIUSAI_H__ +} \ No newline at end of file diff --git a/AI/GeniusAI/Common.h b/AI/GeniusAI/Common.h index e65f9ce06..bf669cb51 100644 --- a/AI/GeniusAI/Common.h +++ b/AI/GeniusAI/Common.h @@ -1,14 +1,11 @@ -#ifndef __GENIUS_COMMON__ -#define __GENIUS_COMMON__ +#pragma once #ifdef __GNUC__ #define strcpy_s(a, b, c) strncpy(a, c, b) #endif #pragma warning (disable: 4100 4244) -#include "../../AI_Base.h" +#include "../../lib/AI_Base.h" #pragma warning (default: 4100 4244) -void DbgBox(const char *msg, bool messageBox = false); - -#endif/*__GENIUS_COMMON__*/ \ No newline at end of file +void DbgBox(const char *msg, bool messageBox = false); \ No newline at end of file diff --git a/AI/GeniusAI/DLLMain.cpp b/AI/GeniusAI/DLLMain.cpp index 2868295d9..da73785dc 100644 --- a/AI/GeniusAI/DLLMain.cpp +++ b/AI/GeniusAI/DLLMain.cpp @@ -1,40 +1,38 @@ -#pragma warning (disable: 4100 4251 4245 4018 4081) -#include "../../AI_Base.h" -#pragma warning (default: 4100 4251 4245 4018 4081) - +#include "StdInc.h" +#include "../../lib/AI_Base.h" #include "CGeniusAI.h" using namespace geniusai; const char *g_cszAiName = "Genius 1.0"; -extern "C" DLL_F_EXPORT int GetGlobalAiVersion() +extern "C" DLL_EXPORT int GetGlobalAiVersion() { return AI_INTERFACE_VER; } -extern "C" DLL_F_EXPORT void GetAiName(char* name) +extern "C" DLL_EXPORT void GetAiName(char* name) { strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName); } -extern "C" DLL_F_EXPORT char* GetAiNameS() +extern "C" DLL_EXPORT char* GetAiNameS() { // need to be defined return NULL; } -extern "C" DLL_F_EXPORT CGlobalAI* GetNewAI() +extern "C" DLL_EXPORT CGlobalAI* GetNewAI() { return new CGeniusAI(); } -extern "C" DLL_F_EXPORT void ReleaseAI(CGlobalAI* i) +extern "C" DLL_EXPORT void ReleaseAI(CGlobalAI* i) { delete (CGeniusAI*)i; } -extern "C" DLL_F_EXPORT CBattleGameInterface* GetNewBattleAI() +extern "C" DLL_EXPORT CBattleGameInterface* GetNewBattleAI() { return new CGeniusAI(); } \ No newline at end of file diff --git a/AI/GeniusAI/ExpertSystem.cpp b/AI/GeniusAI/ExpertSystem.cpp index daadf842d..8fe840eb3 100644 --- a/AI/GeniusAI/ExpertSystem.cpp +++ b/AI/GeniusAI/ExpertSystem.cpp @@ -1,3 +1,4 @@ +#include "StdInc.h" #include "GeneralAI.h" #include "../../CCallback.h" #include "ExpertSystem.h" @@ -139,4 +140,4 @@ bool BonusCondition::matchesFact(Bonus &fact) if (object(&fact)) //Bonus(fact) matches local Selector(object) return true; return false; -} +} \ No newline at end of file diff --git a/AI/GeniusAI/ExpertSystem.h b/AI/GeniusAI/ExpertSystem.h index 75ab50e77..a1b20aa7d 100644 --- a/AI/GeniusAI/ExpertSystem.h +++ b/AI/GeniusAI/ExpertSystem.h @@ -1,4 +1,4 @@ -#include "../../global.h" + #include "../../CCallback.h" #include "../../lib/HeroBonus.h" #include @@ -101,7 +101,7 @@ public: template class Weight : public Rule { public: - float multiplier; //multiply input by value and return to output + double multiplier; //multiply input by value and return to output void fireTule(){}; }; diff --git a/AI/GeniusAI/GeneralAI.cpp b/AI/GeniusAI/GeneralAI.cpp index c9dee7984..d9521cb60 100644 --- a/AI/GeniusAI/GeneralAI.cpp +++ b/AI/GeniusAI/GeneralAI.cpp @@ -1,4 +1,6 @@ +#include "StdInc.h" #include "GeneralAI.h" + #include "../../CCallback.h" using namespace geniusai::GeneralAI; diff --git a/AI/GeniusAI/GeneralAI.h b/AI/GeniusAI/GeneralAI.h index 0a9bb99e5..48315b3cd 100644 --- a/AI/GeniusAI/GeneralAI.h +++ b/AI/GeniusAI/GeneralAI.h @@ -1,5 +1,4 @@ -#ifndef __GENERAL_AI_H__ -#define __GENERAL_AI_H__ +#pragma once #include "Common.h" @@ -16,6 +15,4 @@ namespace geniusai { namespace GeneralAI { CCallback *m_cb; }; -}} - -#endif/*__GENERAL_AI_H__*/ \ No newline at end of file +}} \ No newline at end of file diff --git a/AI/GeniusAI/Makefile.am b/AI/GeniusAI/Makefile.am index acdeb81a1..9f6699658 100644 --- a/AI/GeniusAI/Makefile.am +++ b/AI/GeniusAI/Makefile.am @@ -1,7 +1,11 @@ vcmiaidir = $(VCMI_AI_LIBS_DIR) +BUILT_SOURCES = StdInc.h.gch +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -DVCMI_DLL -fPIC -c $< vcmiai_LTLIBRARIES = libGeniusAI.la libGeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la +libGeniusAI_la_CXXFLAGS = -DVCMI_DLL libGeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version libGeniusAI_la_SOURCES = \ AIPriorities.cpp \ diff --git a/AI/GeniusAI/Makefile.in b/AI/GeniusAI/Makefile.in index be1a90d28..912bc462d 100644 --- a/AI/GeniusAI/Makefile.in +++ b/AI/GeniusAI/Makefile.in @@ -79,17 +79,18 @@ am__base_list = \ am__installdirs = "$(DESTDIR)$(vcmiaidir)" LTLIBRARIES = $(vcmiai_LTLIBRARIES) libGeniusAI_la_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la -am_libGeniusAI_la_OBJECTS = AIPriorities.lo BattleHelper.lo \ - BattleLogic.lo CGeniusAI.lo DLLMain.lo GeneralAI.lo \ - neuralNetwork.lo +am_libGeniusAI_la_OBJECTS = libGeniusAI_la-AIPriorities.lo \ + libGeniusAI_la-BattleHelper.lo libGeniusAI_la-BattleLogic.lo \ + libGeniusAI_la-CGeniusAI.lo libGeniusAI_la-DLLMain.lo \ + libGeniusAI_la-GeneralAI.lo libGeniusAI_la-neuralNetwork.lo libGeniusAI_la_OBJECTS = $(am_libGeniusAI_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libGeniusAI_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ - $(AM_CXXFLAGS) $(CXXFLAGS) $(libGeniusAI_la_LDFLAGS) \ - $(LDFLAGS) -o $@ + $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) \ + $(libGeniusAI_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -272,8 +273,10 @@ 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 = libGeniusAI.la libGeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la +libGeniusAI_la_CXXFLAGS = -DVCMI_DLL libGeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version libGeniusAI_la_SOURCES = \ AIPriorities.cpp \ @@ -291,7 +294,8 @@ libGeniusAI_la_SOURCES = \ neuralNetwork.cpp \ neuralNetwork.h -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj @@ -365,13 +369,13 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AIPriorities.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BattleHelper.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BattleLogic.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CGeniusAI.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DLLMain.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GeneralAI.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/neuralNetwork.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-AIPriorities.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-BattleHelper.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-BattleLogic.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-CGeniusAI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-DLLMain.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-GeneralAI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-neuralNetwork.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -397,6 +401,62 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< +libGeniusAI_la-AIPriorities.lo: AIPriorities.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-AIPriorities.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-AIPriorities.Tpo -c -o libGeniusAI_la-AIPriorities.lo `test -f 'AIPriorities.cpp' || echo '$(srcdir)/'`AIPriorities.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-AIPriorities.Tpo $(DEPDIR)/libGeniusAI_la-AIPriorities.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='AIPriorities.cpp' object='libGeniusAI_la-AIPriorities.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-AIPriorities.lo `test -f 'AIPriorities.cpp' || echo '$(srcdir)/'`AIPriorities.cpp + +libGeniusAI_la-BattleHelper.lo: BattleHelper.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-BattleHelper.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-BattleHelper.Tpo -c -o libGeniusAI_la-BattleHelper.lo `test -f 'BattleHelper.cpp' || echo '$(srcdir)/'`BattleHelper.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-BattleHelper.Tpo $(DEPDIR)/libGeniusAI_la-BattleHelper.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='BattleHelper.cpp' object='libGeniusAI_la-BattleHelper.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-BattleHelper.lo `test -f 'BattleHelper.cpp' || echo '$(srcdir)/'`BattleHelper.cpp + +libGeniusAI_la-BattleLogic.lo: BattleLogic.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-BattleLogic.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-BattleLogic.Tpo -c -o libGeniusAI_la-BattleLogic.lo `test -f 'BattleLogic.cpp' || echo '$(srcdir)/'`BattleLogic.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-BattleLogic.Tpo $(DEPDIR)/libGeniusAI_la-BattleLogic.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='BattleLogic.cpp' object='libGeniusAI_la-BattleLogic.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-BattleLogic.lo `test -f 'BattleLogic.cpp' || echo '$(srcdir)/'`BattleLogic.cpp + +libGeniusAI_la-CGeniusAI.lo: CGeniusAI.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-CGeniusAI.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-CGeniusAI.Tpo -c -o libGeniusAI_la-CGeniusAI.lo `test -f 'CGeniusAI.cpp' || echo '$(srcdir)/'`CGeniusAI.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-CGeniusAI.Tpo $(DEPDIR)/libGeniusAI_la-CGeniusAI.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CGeniusAI.cpp' object='libGeniusAI_la-CGeniusAI.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-CGeniusAI.lo `test -f 'CGeniusAI.cpp' || echo '$(srcdir)/'`CGeniusAI.cpp + +libGeniusAI_la-DLLMain.lo: DLLMain.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-DLLMain.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-DLLMain.Tpo -c -o libGeniusAI_la-DLLMain.lo `test -f 'DLLMain.cpp' || echo '$(srcdir)/'`DLLMain.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-DLLMain.Tpo $(DEPDIR)/libGeniusAI_la-DLLMain.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='DLLMain.cpp' object='libGeniusAI_la-DLLMain.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-DLLMain.lo `test -f 'DLLMain.cpp' || echo '$(srcdir)/'`DLLMain.cpp + +libGeniusAI_la-GeneralAI.lo: GeneralAI.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-GeneralAI.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-GeneralAI.Tpo -c -o libGeniusAI_la-GeneralAI.lo `test -f 'GeneralAI.cpp' || echo '$(srcdir)/'`GeneralAI.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-GeneralAI.Tpo $(DEPDIR)/libGeniusAI_la-GeneralAI.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='GeneralAI.cpp' object='libGeniusAI_la-GeneralAI.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-GeneralAI.lo `test -f 'GeneralAI.cpp' || echo '$(srcdir)/'`GeneralAI.cpp + +libGeniusAI_la-neuralNetwork.lo: neuralNetwork.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-neuralNetwork.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-neuralNetwork.Tpo -c -o libGeniusAI_la-neuralNetwork.lo `test -f 'neuralNetwork.cpp' || echo '$(srcdir)/'`neuralNetwork.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-neuralNetwork.Tpo $(DEPDIR)/libGeniusAI_la-neuralNetwork.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='neuralNetwork.cpp' object='libGeniusAI_la-neuralNetwork.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) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-neuralNetwork.lo `test -f 'neuralNetwork.cpp' || echo '$(srcdir)/'`neuralNetwork.cpp + mostlyclean-libtool: -rm -f *.lo @@ -486,13 +546,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-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: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -517,6 +579,7 @@ distclean-generic: 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 \ @@ -588,7 +651,7 @@ ps-am: uninstall-am: uninstall-vcmiaiLTLIBRARIES -.MAKE: install-am install-strip +.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 \ @@ -604,6 +667,8 @@ uninstall-am: uninstall-vcmiaiLTLIBRARIES 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. diff --git a/AI/GeniusAI/genius.vcxproj b/AI/GeniusAI/genius.vcxproj index 67391a19f..d05f272d7 100644 --- a/AI/GeniusAI/genius.vcxproj +++ b/AI/GeniusAI/genius.vcxproj @@ -107,11 +107,11 @@ true EnableFastChecks MultiThreadedDebugDLL - - + Use Level4 EditAndContinue 4512;%(DisableSpecificWarnings) + StdInc.h VCMI_lib.lib;%(AdditionalDependencies) @@ -216,6 +216,11 @@ + + Create + StdInc.h + %(PreprocessorDefinitions) + @@ -225,6 +230,7 @@ + diff --git a/AI/GeniusAI/neuralNetwork.cpp b/AI/GeniusAI/neuralNetwork.cpp index 03758217d..c6f0cc45e 100644 --- a/AI/GeniusAI/neuralNetwork.cpp +++ b/AI/GeniusAI/neuralNetwork.cpp @@ -1,5 +1,4 @@ -#include -#include +#include "StdInc.h" #include "neuralNetwork.h" //using namespace std; @@ -8,18 +7,18 @@ #define M_PI 3.14159265358979323846 #endif -static float norm(void)//add desired mean, multiply to get desired SD +static double norm(void)//add desired mean, multiply to get desired SD { - static float kept = 0; + static double kept = 0; static bool in = 0; if(!in) { - float x = (rand()+1)/float(RAND_MAX+1); - float f = sqrtf( - 2.0f * log(x) ); - x = (rand()+1)/float(RAND_MAX+1); - kept = f * cosf( 2.0f * M_PI * x ); + double x = (rand() + 1) / static_cast(RAND_MAX + 1); + double f = sqrtf( - 2.0 * log(x) ); + x = (rand() + 1) / static_cast(RAND_MAX + 1); + kept = f * cosf( 2.0 * M_PI * x ); in = true; - return f * sinf( 2.0f * M_PI * x ); + return f * sinf( 2.0 * M_PI * x ); } else { diff --git a/AI/GeniusAI/neuralNetwork.h b/AI/GeniusAI/neuralNetwork.h index b4da08e44..9002a93df 100644 --- a/AI/GeniusAI/neuralNetwork.h +++ b/AI/GeniusAI/neuralNetwork.h @@ -8,13 +8,8 @@ * Bobby Anguelov - takinginitiative.wordpress.com (2008) * MSN & email: banguelov@cs.up.ac.za ********************************************************************/ -#ifndef NEURAL_NETWORK_H -#define NEURAL_NETWORK_H +#pragma once //standard includes -#include -#include -#include -#include #include @@ -63,5 +58,4 @@ private: }; std::istream & operator >> (std::istream &, neuralNetwork & ann); -std::ostream & operator << (std::ostream &, const neuralNetwork & ann); -#endif \ No newline at end of file +std::ostream & operator << (std::ostream &, const neuralNetwork & ann); \ No newline at end of file diff --git a/AI/StupidAI/Makefile.am b/AI/StupidAI/Makefile.am index f0fce2304..5e196c8ef 100644 --- a/AI/StupidAI/Makefile.am +++ b/AI/StupidAI/Makefile.am @@ -1,12 +1,13 @@ vcmiaidir = $(VCMI_AI_LIBS_DIR) +BUILT_SOURCES = StdInc.h.gch +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -DVCMI_DLL -fPIC -c $< vcmiai_LTLIBRARIES = libStupidAI.la libStupidAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la +libStupidAI_la_CXXFLAGS = -DVCMI_DLL libStupidAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version libStupidAI_la_SOURCES = \ main.cpp\ - stdafx.cpp\ - stdafx.h\ StupidAI.cpp\ StupidAI.h - diff --git a/AI/StupidAI/Makefile.in b/AI/StupidAI/Makefile.in index f55921793..82126315f 100644 --- a/AI/StupidAI/Makefile.in +++ b/AI/StupidAI/Makefile.in @@ -79,15 +79,16 @@ am__base_list = \ am__installdirs = "$(DESTDIR)$(vcmiaidir)" LTLIBRARIES = $(vcmiai_LTLIBRARIES) libStupidAI_la_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la -am_libStupidAI_la_OBJECTS = main.lo stdafx.lo StupidAI.lo +am_libStupidAI_la_OBJECTS = libStupidAI_la-main.lo \ + libStupidAI_la-StupidAI.lo libStupidAI_la_OBJECTS = $(am_libStupidAI_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libStupidAI_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ - $(AM_CXXFLAGS) $(CXXFLAGS) $(libStupidAI_la_LDFLAGS) \ - $(LDFLAGS) -o $@ + $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) \ + $(libStupidAI_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -270,17 +271,18 @@ 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 = libStupidAI.la libStupidAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la +libStupidAI_la_CXXFLAGS = -DVCMI_DLL libStupidAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version libStupidAI_la_SOURCES = \ main.cpp\ - stdafx.cpp\ - stdafx.h\ StupidAI.cpp\ StupidAI.h -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj @@ -354,9 +356,8 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StupidAI.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdafx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libStupidAI_la-StupidAI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libStupidAI_la-main.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -382,6 +383,22 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< +libStupidAI_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) $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) -MT libStupidAI_la-main.lo -MD -MP -MF $(DEPDIR)/libStupidAI_la-main.Tpo -c -o libStupidAI_la-main.lo `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libStupidAI_la-main.Tpo $(DEPDIR)/libStupidAI_la-main.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='main.cpp' object='libStupidAI_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) $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libStupidAI_la-main.lo `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp + +libStupidAI_la-StupidAI.lo: StupidAI.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) $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) -MT libStupidAI_la-StupidAI.lo -MD -MP -MF $(DEPDIR)/libStupidAI_la-StupidAI.Tpo -c -o libStupidAI_la-StupidAI.lo `test -f 'StupidAI.cpp' || echo '$(srcdir)/'`StupidAI.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libStupidAI_la-StupidAI.Tpo $(DEPDIR)/libStupidAI_la-StupidAI.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='StupidAI.cpp' object='libStupidAI_la-StupidAI.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) $(libStupidAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libStupidAI_la-StupidAI.lo `test -f 'StupidAI.cpp' || echo '$(srcdir)/'`StupidAI.cpp + mostlyclean-libtool: -rm -f *.lo @@ -471,13 +488,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-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: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -502,6 +521,7 @@ distclean-generic: 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 \ @@ -573,7 +593,7 @@ ps-am: uninstall-am: uninstall-vcmiaiLTLIBRARIES -.MAKE: install-am install-strip +.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 \ @@ -589,6 +609,8 @@ uninstall-am: uninstall-vcmiaiLTLIBRARIES 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. diff --git a/AI/StupidAI/StupidAI.cpp b/AI/StupidAI/StupidAI.cpp index 51ee36ec6..59a1a0c70 100644 --- a/AI/StupidAI/StupidAI.cpp +++ b/AI/StupidAI/StupidAI.cpp @@ -1,12 +1,9 @@ -#include "stdafx.h" +#include "StdInc.h" +#include "../../lib/AI_Base.h" #include "StupidAI.h" #include "../../lib/BattleState.h" #include "../../CCallback.h" -#include -#include #include "../../lib/CCreatureHandler.h" -#include -//#include CBattleCallback * cbc; @@ -42,7 +39,7 @@ struct EnemyInfo { const CStack * s; int adi, adr; - std::vector attackFrom; //for melee fight + std::vector attackFrom; //for melee fight EnemyInfo(const CStack * _s) : s(_s) {} void calcDmg(const CStack * ourStack) @@ -63,10 +60,10 @@ bool isMoreProfitable(const EnemyInfo &ei1, const EnemyInfo& ei2) return (ei1.adi-ei1.adr) < (ei2.adi - ei2.adr); } -int distToNearestNeighbour(THex hex, const std::vector & dists, THex *chosenHex = NULL) +int distToNearestNeighbour(SHexField hex, const std::vector & dists, SHexField *chosenHex = NULL) { int ret = 1000000; - BOOST_FOREACH(THex n, hex.neighbouringTiles()) + BOOST_FOREACH(SHexField n, hex.neighbouringTiles()) { if(dists[n] >= 0 && dists[n] < ret) { @@ -84,12 +81,12 @@ bool isCloser(const EnemyInfo & ei1, const EnemyInfo & ei2, const std::vectorposition, dists) < distToNearestNeighbour(ei2.s->position, dists); } -static bool willSecondHexBlockMoreEnemyShooters(const THex &h1, const THex &h2) +static bool willSecondHexBlockMoreEnemyShooters(const SHexField &h1, const SHexField &h2) { int shooters[2] = {0}; //count of shooters on hexes for(int i = 0; i < 2; i++) - BOOST_FOREACH(THex neighbour, (i ? h2 : h1).neighbouringTiles()) + BOOST_FOREACH(SHexField neighbour, (i ? h2 : h1).neighbouringTiles()) if(const CStack *s = cbc->battleGetStackByPos(neighbour)) if(s->getCreature()->isShooting()) shooters[i]++; @@ -101,7 +98,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack ) { //boost::this_thread::sleep(boost::posix_time::seconds(2)); print("activeStack called"); - std::vector avHexes = cb->battleGetAvailableHexes(stack, false); + std::vector avHexes = cb->battleGetAvailableHexes(stack, false); std::vector dists = cb->battleGetDistances(stack); std::vector enemiesShootable, enemiesReachable, enemiesUnreachable; @@ -113,7 +110,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack ) } else { - BOOST_FOREACH(THex hex, avHexes) + BOOST_FOREACH(SHexField hex, avHexes) { if(CStack::isMeleeAttackPossible(stack, s, hex)) { @@ -146,7 +143,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack ) else { const EnemyInfo &ei= *std::min_element(enemiesUnreachable.begin(), enemiesUnreachable.end(), boost::bind(isCloser, _1, _2, boost::ref(dists))); - if(distToNearestNeighbour(ei.s->position, dists) < BFIELD_SIZE) + if(distToNearestNeighbour(ei.s->position, dists) < GameConstants::BFIELD_SIZE) { return goTowards(stack, ei.s->position); } @@ -185,7 +182,7 @@ void CStupidAI::battleNewRound(int round) print("battleNewRound called"); } -void CStupidAI::battleStackMoved(const CStack * stack, std::vector dest, int distance) +void CStupidAI::battleStackMoved(const CStack * stack, std::vector dest, int distance) { print("battleStackMoved called");; } @@ -236,19 +233,19 @@ void CStupidAI::print(const std::string &text) const tlog0 << "CStupidAI [" << this <<"]: " << text << std::endl; } -BattleAction CStupidAI::goTowards(const CStack * stack, THex hex) +BattleAction CStupidAI::goTowards(const CStack * stack, SHexField hex) { - THex realDest = hex; - THex predecessors[BFIELD_SIZE]; + SHexField realDest = hex; + SHexField predecessors[GameConstants::BFIELD_SIZE]; std::vector dists = cb->battleGetDistances(stack, hex); - if(distToNearestNeighbour(hex, dists, &realDest) > BFIELD_SIZE) + if(distToNearestNeighbour(hex, dists, &realDest) > GameConstants::BFIELD_SIZE) { print("goTowards: Cannot reach"); return BattleAction::makeDefend(stack); } dists = cb->battleGetDistances(stack, realDest, predecessors); - std::vector avHexes = cb->battleGetAvailableHexes(stack, false); + std::vector avHexes = cb->battleGetAvailableHexes(stack, false); if(!avHexes.size()) { diff --git a/AI/StupidAI/StupidAI.h b/AI/StupidAI/StupidAI.h index 9f2413393..663c399e9 100644 --- a/AI/StupidAI/StupidAI.h +++ b/AI/StupidAI/StupidAI.h @@ -1,5 +1,7 @@ #pragma once +#include "../../lib/SHexField.h" + class CStupidAI : public CBattleGameInterface { int side; @@ -21,7 +23,7 @@ public: //void battleResultsApplied() OVERRIDE; //called when all effects of last battle are applied void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied; void battleNewRound(int round) OVERRIDE; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn - void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE; + void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE; void battleSpellCast(const BattleSpellCast *sc) OVERRIDE; void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE;//called when a specific effect is set to stacks //void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE; @@ -32,6 +34,6 @@ public: void battleCatapultAttacked(const CatapultAttack & ca) OVERRIDE; //called when catapult makes an attack void battleStacksRemoved(const BattleStacksRemoved & bsr) OVERRIDE; //called when certain stack is completely removed from battlefield - BattleAction goTowards(const CStack * stack, THex hex ); + BattleAction goTowards(const CStack * stack, SHexField hex ); }; diff --git a/AI/StupidAI/StupidAI.vcxproj b/AI/StupidAI/StupidAI.vcxproj index 022a23eab..7ff466078 100644 --- a/AI/StupidAI/StupidAI.vcxproj +++ b/AI/StupidAI/StupidAI.vcxproj @@ -91,7 +91,8 @@ Disabled %(AdditionalIncludeDirectories) Use - stdafx.h + StdInc.h + %(PreprocessorDefinitions) true @@ -155,16 +156,15 @@ - + + %(PreprocessorDefinitions) Create - Create - Create - Create + StdInc.h - + diff --git a/AI/StupidAI/main.cpp b/AI/StupidAI/main.cpp index 3963b80b2..3fb39db00 100644 --- a/AI/StupidAI/main.cpp +++ b/AI/StupidAI/main.cpp @@ -1,6 +1,7 @@ -#include "stdafx.h" +#include "StdInc.h" + +#include "../../lib/AI_Base.h" #include "StupidAI.h" -#include #ifdef __GNUC__ #define strcpy_s(a, b, c) strncpy(a, c, b) @@ -8,28 +9,28 @@ const char *g_cszAiName = "Stupid AI 0.1"; -extern "C" DLL_F_EXPORT int GetGlobalAiVersion() +extern "C" DLL_EXPORT int GetGlobalAiVersion() { return AI_INTERFACE_VER; } -extern "C" DLL_F_EXPORT void GetAiName(char* name) +extern "C" DLL_EXPORT void GetAiName(char* name) { strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName); } -extern "C" DLL_F_EXPORT char* GetAiNameS() +extern "C" DLL_EXPORT char* GetAiNameS() { // need to be defined return NULL; } -extern "C" DLL_F_EXPORT CBattleGameInterface* GetNewBattleAI() +extern "C" DLL_EXPORT CBattleGameInterface* GetNewBattleAI() { return new CStupidAI(); } -extern "C" DLL_F_EXPORT void ReleaseBattleAI(CBattleGameInterface* i) +extern "C" DLL_EXPORT void ReleaseBattleAI(CBattleGameInterface* i) { delete (CStupidAI*)i; } diff --git a/CCallback.cpp b/CCallback.cpp index 7dc4fa427..762e046cf 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -1,5 +1,6 @@ -#include "stdafx.h" +#include "StdInc.h" #include "CCallback.h" + #include "lib/CCreatureHandler.h" #include "client/CGameInfo.h" #include "lib/CGameState.h" @@ -15,11 +16,9 @@ #include "lib/Connection.h" #include "lib/NetPacks.h" #include "client/mapHandler.h" -#include -#include -#include #include "lib/CSpellHandler.h" #include "lib/CArtHandler.h" +#include "lib/GameConstants.h" #ifdef min #undef min #endif @@ -247,7 +246,7 @@ void CCallback::setSelection(const CArmedInstance * obj) ss.id = obj->id; sendRequest(&(CPackForClient&)ss); - if(obj->ID == HEROI_TYPE) + if(obj->ID == GameConstants::HEROI_TYPE) { if(cl->pathInfo->hero != obj) //calculate new paths only if we selected a different hero cl->calculatePaths(static_cast(obj)); diff --git a/CCallback.h b/CCallback.h index 71e99c1cd..28ea9492a 100644 --- a/CCallback.h +++ b/CCallback.h @@ -1,14 +1,5 @@ -#ifndef __CCALLBACK_H__ -#define __CCALLBACK_H__ +#pragma once -#include "global.h" -#ifdef _WIN32 -#include "tchar.h" -#else -#include "tchar_amigaos4.h" //XXX this is mingw header are we need this for something? for 'true' -//support of unicode we should use ICU or some boost wraper areound it -//(boost using this lib during compilation i dont know what for exactly) -#endif #include "lib/IGameCallback.h" @@ -148,5 +139,3 @@ public: //friends friend class CClient; }; - -#endif // __CCALLBACK_H__ diff --git a/Scripting/ERM/ERM.vcxproj b/Scripting/ERM/ERM.vcxproj index 9caf824a7..b3fa4a53b 100644 --- a/Scripting/ERM/ERM.vcxproj +++ b/Scripting/ERM/ERM.vcxproj @@ -90,8 +90,8 @@ Level3 Disabled %(AdditionalIncludeDirectories) - NotUsing - stdafx.h + Use + StdInc.h true @@ -132,11 +132,16 @@ + + + Create + StdInc.h + diff --git a/Scripting/ERM/ERMInterpreter.cpp b/Scripting/ERM/ERMInterpreter.cpp index 332ef6458..7e44eb99b 100644 --- a/Scripting/ERM/ERMInterpreter.cpp +++ b/Scripting/ERM/ERMInterpreter.cpp @@ -1,13 +1,7 @@ +#include "StdInc.h" #include "ERMInterpreter.h" -#include -#include -#include -#include -#include -#include // for 'operator+=()' -#include -#include +#include #include "../../lib/CObjectHandler.h" #include "../../lib/CHeroHandler.h" #include "../../lib/CCreatureHandler.h" @@ -372,13 +366,13 @@ void ERMInterpreter::scanForScripts() { using namespace boost::filesystem; //parser checking - if(!exists(DATA_DIR "/Data/s/")) + if(!exists(GameConstants::DATA_DIR + "/Data/s/")) { - tlog3 << "Warning: Folder " DATA_DIR "/Data/s/ doesn't exist!\n"; + tlog3 << "Warning: Folder " << GameConstants::DATA_DIR << "/Data/s/ doesn't exist!\n"; return; } directory_iterator enddir; - for (directory_iterator dir(DATA_DIR "/Data/s"); dir!=enddir; dir++) + for (directory_iterator dir(GameConstants::DATA_DIR + "/Data/s"); dir!=enddir; dir++) { if(is_regular(dir->status())) { @@ -2293,7 +2287,7 @@ void IexpValStr::setTo( int val ) } } -void IexpValStr::setTo( float val ) +void IexpValStr::setTo( double val ) { DBG_PRINT("setting " << getName() << " to " << val); switch(type) @@ -2337,7 +2331,7 @@ int IexpValStr::getInt() const } } -float IexpValStr::getFloat() const +double IexpValStr::getFloat() const { switch(type) { diff --git a/Scripting/ERM/ERMInterpreter.h b/Scripting/ERM/ERMInterpreter.h index 6be683f6f..99177de4b 100644 --- a/Scripting/ERM/ERMInterpreter.h +++ b/Scripting/ERM/ERMInterpreter.h @@ -1,5 +1,6 @@ #pragma once -#include "../../global.h" + + #include "ERMParser.h" #include "ERMScriptModule.h" @@ -135,7 +136,7 @@ namespace VERMInterpreter static const int NUM_LOCALS = 100; static const int NUM_STRINGS = 10; static const int NUM_FLOATINGS = 100; - + int & getParam(int num); int & getLocal(int num); std::string & getString(int num); @@ -621,10 +622,10 @@ public: enum {WRONGVAL, INT, INTVAR, FLOATVAR, STRINGVAR} type; void setTo(const IexpValStr & second); void setTo(int val); - void setTo(float val); + void setTo(double val); void setTo(const std::string & val); int getInt() const; - float getFloat() const; + double getFloat() const; std::string getString() const; IexpValStr() : type(WRONGVAL) @@ -796,7 +797,7 @@ class ERMInterpreter : public CScriptingModule VERMInterpreter::Trigger * curTrigger; VERMInterpreter::FunctionLocalVars * curFunc; static const int TRIG_FUNC_NUM = 30000; - VERMInterpreter::FunctionLocalVars funcVars[TRIG_FUNC_NUM+1]; //+1 because we use [0] as a global set of y-vars + VERMInterpreter::FunctionLocalVars funcVars[TRIG_FUNC_NUM + 1]; //+1 because we use [0] as a global set of y-vars VERMInterpreter::FunctionLocalVars * getFuncVars(int funNum); //0 is a global func-like set IexpValStr getIexp(const ERM::TIexp & iexp) const; diff --git a/Scripting/ERM/ERMParser.cpp b/Scripting/ERM/ERMParser.cpp index eff6cc4f0..1526e3a17 100644 --- a/Scripting/ERM/ERMParser.cpp +++ b/Scripting/ERM/ERMParser.cpp @@ -1,19 +1,18 @@ +#include "StdInc.h" #include "ERMParser.h" + #include //To make compilation with older boost versions possible //Don't know exact version - 1.46 works while 1.42 not #if BOOST_VERSION >= 104600 #include -#include #include #include #include #include #include #include -#include -#include namespace spirit = boost::spirit; namespace qi = boost::spirit::qi; diff --git a/Scripting/ERM/ERMParser.h b/Scripting/ERM/ERMParser.h index 16efa2175..cde879b44 100644 --- a/Scripting/ERM/ERMParser.h +++ b/Scripting/ERM/ERMParser.h @@ -1,6 +1,6 @@ #pragma once -#include "../../global.h" -#include + + #include #include #include diff --git a/Scripting/ERM/ERMScriptModule.cpp b/Scripting/ERM/ERMScriptModule.cpp index 8954a4fbb..c835c89ca 100644 --- a/Scripting/ERM/ERMScriptModule.cpp +++ b/Scripting/ERM/ERMScriptModule.cpp @@ -1,4 +1,6 @@ +#include "StdInc.h" #include "ERMScriptModule.h" + #include "ERMInterpreter.h" /* @@ -21,12 +23,12 @@ CPrivilagedInfoCallback *icb; const char *g_cszAiName = "(V)ERM interpreter"; -extern "C" DLL_F_EXPORT void GetAiName(char* name) +extern "C" DLL_EXPORT void GetAiName(char* name) { strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName); } -extern "C" DLL_F_EXPORT CScriptingModule* GetNewModule() +extern "C" DLL_EXPORT CScriptingModule* GetNewModule() { return new ERMInterpreter(); } \ No newline at end of file diff --git a/Scripting/ERM/Makefile.am b/Scripting/ERM/Makefile.am index 56a1a4315..0400fdf47 100644 --- a/Scripting/ERM/Makefile.am +++ b/Scripting/ERM/Makefile.am @@ -1,8 +1,11 @@ vcmiscriptingdir = $(VCMI_SCRIPTING_LIBS_DIR) +BUILT_SOURCES = StdInc.h.gch +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -DVCMI_DLL -fPIC -c $< vcmiscripting_LTLIBRARIES = libvcmiERM.la libvcmiERM_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -libvcmiERM_la_CXXFLAGS = +libvcmiERM_la_CXXFLAGS = -DVCMI_DLL libvcmiERM_la_SOURCES = \ ERMInterpreter.cpp \ ERMInterpreter.h \ diff --git a/Scripting/ERM/Makefile.in b/Scripting/ERM/Makefile.in index ce5564219..c53682f3b 100644 --- a/Scripting/ERM/Makefile.in +++ b/Scripting/ERM/Makefile.in @@ -271,9 +271,10 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ vcmiscriptingdir = $(VCMI_SCRIPTING_LIBS_DIR) +BUILT_SOURCES = StdInc.h.gch vcmiscripting_LTLIBRARIES = libvcmiERM.la libvcmiERM_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -libvcmiERM_la_CXXFLAGS = +libvcmiERM_la_CXXFLAGS = -DVCMI_DLL libvcmiERM_la_SOURCES = \ ERMInterpreter.cpp \ ERMInterpreter.h \ @@ -282,7 +283,8 @@ libvcmiERM_la_SOURCES = \ ERMScriptModule.cpp \ ERMScriptModule.h -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj @@ -497,13 +499,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(vcmiscriptingdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -528,6 +532,7 @@ distclean-generic: 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-vcmiscriptingLTLIBRARIES \ @@ -599,7 +604,7 @@ ps-am: uninstall-am: uninstall-vcmiscriptingLTLIBRARIES -.MAKE: install-am install-strip +.MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-vcmiscriptingLTLIBRARIES ctags distclean \ @@ -615,6 +620,8 @@ uninstall-am: uninstall-vcmiscriptingLTLIBRARIES mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-vcmiscriptingLTLIBRARIES +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. diff --git a/VCMI_global.props b/VCMI_global.props index 8f2fe710f..771b10fde 100644 --- a/VCMI_global.props +++ b/VCMI_global.props @@ -4,8 +4,8 @@ <_PropertySheetDisplayName>VCMI_global - $(SolutionDir)..\libs\$(PlatformShortName);$(LibraryPath) - $(SolutionDir)..\include;$(IncludePath) + D:\Programme\Boost\boost_1_48_0\stage\lib;$(SolutionDir)..\libs\$(PlatformShortName);$(LibraryPath) + D:\Programme\Boost\boost_1_48_0;$(SolutionDir)..\include;$(IncludePath) diff --git a/aclocal.m4 b/aclocal.m4 index ea740a707..549e03ad1 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],, -[m4_warning([this file was generated for autoconf 2.67. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.66],, +[m4_warning([this file was generated for autoconf 2.66. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) diff --git a/client/AdventureMapButton.cpp b/client/AdventureMapButton.cpp index a3ac6dfcf..da7b46ae6 100644 --- a/client/AdventureMapButton.cpp +++ b/client/AdventureMapButton.cpp @@ -1,14 +1,13 @@ +#include "StdInc.h" #include "AdventureMapButton.h" + #include "CAnimation.h" -//#include "CAdvmapInterface.h" #include "SDL_Extensions.h" #include "CGameInfo.h" -//#include "../lib/CGeneralTextHandler.h" -//#include "../lib/CTownHandler.h" #include "../CCallback.h" #include "CConfigHandler.h" -//#include "Graphics.h" -#include "CBattleInterface.h" +#include "BattleInterface/CBattleInterface.h" +#include "BattleInterface/CBattleConsole.h" #include "CPlayerInterface.h" #include "CMessage.h" #include "CMusicHandler.h" @@ -444,7 +443,7 @@ void CSlider::sliderClicked() void CSlider::mouseMoved (const SDL_MouseMotionEvent & sEvent) { - float v = 0; + double v = 0; if(horizontal) { if( std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2+40 || std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2 ) @@ -461,7 +460,7 @@ void CSlider::mouseMoved (const SDL_MouseMotionEvent & sEvent) v *= positions; v /= (pos.h - 48); } - v += 0.5f; + v += 0.5; if(v!=value) { moveTo(v); @@ -486,8 +485,8 @@ void CSlider::moveRight() void CSlider::moveTo(int to) { - amax(to, 0); - amin(to, positions); + vstd::amax(to, 0); + vstd::amin(to, positions); //same, old position? if(value == to) @@ -498,7 +497,7 @@ void CSlider::moveTo(int to) { if(positions) { - float part = (float)to/positions; + double part = static_cast(to) / positions; part*=(pos.w-48); int newPos = part + pos.x + 16 - slider->pos.x; slider->moveBy(Point(newPos, 0)); @@ -510,7 +509,7 @@ void CSlider::moveTo(int to) { if(positions) { - float part = (float)to/positions; + double part = static_cast(to) / positions; part*=(pos.h-48); int newPos = part + pos.y + 16 - slider->pos.y; slider->moveBy(Point(0, newPos)); @@ -527,24 +526,24 @@ void CSlider::clickLeft(tribool down, bool previousState) { if(down && !slider->isBlocked()) { - float pw = 0; - float rw = 0; + double pw = 0; + double rw = 0; if(horizontal) { pw = GH.current->motion.x-pos.x-25; - rw = pw / ((float)(pos.w-48)); + rw = pw / static_cast(pos.w - 48); } else { pw = GH.current->motion.y-pos.y-24; - rw = pw / ((float)(pos.h-48)); + rw = pw / (pos.h-48); } if(pw < -8 || pw > (horizontal ? pos.w : pos.h) - 40) return; // if (rw>1) return; // if (rw<0) return; slider->clickLeft(true, slider->pressedL); - moveTo(rw * positions + 0.5f); + moveTo(rw * positions + 0.5); return; } if(active & MOVE) @@ -645,7 +644,7 @@ void CSlider::setAmount( int to ) { amount = to; positions = to - capacity; - amax(positions, 0); + vstd::amax(positions, 0); } void CSlider::showAll(SDL_Surface * to) diff --git a/client/AdventureMapButton.h b/client/AdventureMapButton.h index 8226e8bf4..00146094e 100644 --- a/client/AdventureMapButton.h +++ b/client/AdventureMapButton.h @@ -1,8 +1,6 @@ -#ifndef __ADVENTUREMAPBUTTON_H__ -#define __ADVENTUREMAPBUTTON_H__ +#pragma once #include "FunctionList.h" -#include #include "GUIBase.h" /* @@ -163,6 +161,4 @@ public: int Value=0, bool Horizontal=true, int style = 0); //style 0 - brown, 1 - blue ~CSlider(); void moveToMax(); -}; - -#endif // __ADVENTUREMAPBUTTON_H__ +}; diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index 455661881..66e44e760 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -1,5 +1,7 @@ -#include "AdventureMapButton.h" +#include "StdInc.h" #include "CAdvmapInterface.h" + +#include "AdventureMapButton.h" #include "../CCallback.h" #include "CCastleInterface.h" #include "CCursorHandler.h" @@ -21,16 +23,9 @@ #include "../lib/map.h" #include "../lib/JsonNode.h" #include "mapHandler.h" -#include "../stdafx.h" -#include -#include -#include -#include -#include #include "CPreGame.h" #include "../lib/VCMI_Lib.h" #include "../lib/CSpellHandler.h" -#include #include "CSoundBase.h" #include "../lib/CGameState.h" #include "CMusicHandler.h" @@ -71,7 +66,7 @@ CMinimap::CMinimap() temps = newSurface(pos.w,pos.h); aiShield = new CPicture("AISHIELD.bmp"); - const JsonNode config(DATA_DIR "/config/minimap.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/minimap.json"); const JsonVector &minimap_vec = config["MinimapColors"].Vector(); BOOST_FOREACH(const JsonNode &m, minimap_vec) { @@ -123,7 +118,7 @@ void CMinimap::draw(SDL_Surface * to) int3 hpos = hh[i]->getPosition(false); if(hpos.z!=adventureInt->position.z) continue; - //float zawx = ((float)hpos.x/CGI->mh->sizes.x), zawy = ((float)hpos.y/CGI->mh->sizes.y); + int3 maplgp ( (hpos.x*mw)/mapSizes.x, (hpos.y*mh)/mapSizes.y, hpos.z ); for (int ii=0; iiposition.x)/(((float)mapSizes.x)))*pos.w, - by = (((float)adventureInt->position.y)/(((float)mapSizes.y)))*pos.h, - rx = (((float)tilesw)/(mapSizes.x))*((float)pos.w), //width - ry = (((float)tilesh)/(mapSizes.y))*((float)pos.h); //height + int bx = static_cast((adventureInt->position.x / static_cast(mapSizes.x)) * pos.w), + by = static_cast((adventureInt->position.y / static_cast(mapSizes.y)) * pos.h), + rx = static_cast((tilesw / static_cast(mapSizes.x)) * pos.w), //width + ry = static_cast((tilesh / static_cast(mapSizes.y)) * pos.h); //height CSDL_Ext::drawDashedBorder(temps, Rect(bx, by, rx, ry), int3(255,75,125)); @@ -295,8 +290,8 @@ void CMinimap::clickLeft(tribool down, bool previousState) if (!((bool)down)) return; - float dx=((float)(GH.current->motion.x-pos.x))/((float)pos.w), - dy=((float)(GH.current->motion.y-pos.y))/((float)pos.h); + double dx = (GH.current->motion.x - pos.x) / static_cast(pos.w), + dy = (GH.current->motion.y - pos.y) / static_cast(pos.h); int3 newCPos; newCPos.x = (CGI->mh->sizes.x*dx); @@ -981,7 +976,7 @@ void CInfoBar::deactivate() void CInfoBar::updateSelection(const CGObjectInstance *obj) { - if(obj->ID == HEROI_TYPE) + if(obj->ID == GameConstants::HEROI_TYPE) curSel = static_cast(obj); else curSel = NULL; @@ -1593,9 +1588,9 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/) centerOn(sel); terrain.currentPath = NULL; - if(sel->ID==TOWNI_TYPE) + if(sel->ID==GameConstants::TOWNI_TYPE) { - int pos = vstd::findPos(LOCPLINT->towns,sel); + int pos = vstd::find_pos(LOCPLINT->towns,sel); townList.selected = pos; townList.fixPos(); updateSleepWake(NULL); @@ -1736,10 +1731,10 @@ void CAdvMapInt::tileLClicked(const int3 &mp) return; } //check if we can select this object - bool canSelect = topBlocking && topBlocking->ID == HEROI_TYPE && topBlocking->tempOwner == LOCPLINT->playerID; - canSelect |= topBlocking && topBlocking->ID == TOWNI_TYPE && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner); + bool canSelect = topBlocking && topBlocking->ID == GameConstants::HEROI_TYPE && topBlocking->tempOwner == LOCPLINT->playerID; + canSelect |= topBlocking && topBlocking->ID == GameConstants::TOWNI_TYPE && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner); - if (selection->ID != HEROI_TYPE) //hero is not selected (presumably town) + if (selection->ID != GameConstants::HEROI_TYPE) //hero is not selected (presumably town) { assert(!terrain.currentPath); //path can be active only when hero is selected if(selection == topBlocking) //selected town clicked @@ -1820,7 +1815,7 @@ void CAdvMapInt::tileHovered(const int3 &tile) bool accessible = pnode->turns < 255; int turns = pnode->turns; - amin(turns, 3); + vstd::amin(turns, 3); if(!selection) //may occur just at the start of game (fake move before full intiialization) return; @@ -1850,13 +1845,13 @@ void CAdvMapInt::tileHovered(const int3 &tile) const bool guardingCreature = CGI->mh->map->isInTheMap(LOCPLINT->cb->guardingCreaturePosition(tile)); - if(selection->ID == TOWNI_TYPE) + if(selection->ID == GameConstants::TOWNI_TYPE) { if(objAtTile) { - if(objAtTile->ID == TOWNI_TYPE && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, objAtTile->tempOwner)) + if(objAtTile->ID == GameConstants::TOWNI_TYPE && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, objAtTile->tempOwner)) CCS->curh->changeGraphic(0, 3); - else if(objAtTile->ID == HEROI_TYPE && objAtTile->tempOwner == LOCPLINT->playerID) + else if(objAtTile->ID == GameConstants::HEROI_TYPE && objAtTile->tempOwner == LOCPLINT->playerID) CCS->curh->changeGraphic(0, 2); } else @@ -1866,7 +1861,7 @@ void CAdvMapInt::tileHovered(const int3 &tile) { if(objAtTile) { - if(objAtTile->ID == HEROI_TYPE) + if(objAtTile->ID == GameConstants::HEROI_TYPE) { if(!LOCPLINT->cb->getPlayerRelations( LOCPLINT->playerID, objAtTile->tempOwner)) //enemy hero { @@ -1885,7 +1880,7 @@ void CAdvMapInt::tileHovered(const int3 &tile) CCS->curh->changeGraphic(0, 2); } } - else if(objAtTile->ID == TOWNI_TYPE) + else if(objAtTile->ID == GameConstants::TOWNI_TYPE) { if(!LOCPLINT->cb->getPlayerRelations( LOCPLINT->playerID, objAtTile->tempOwner)) //enemy town { @@ -2042,7 +2037,7 @@ void CAdvMapInt::leaveCastingMode(bool cast /*= false*/, int3 dest /*= int3(-1, const CGHeroInstance * CAdvMapInt::curHero() const { - if(selection && selection->ID == HEROI_TYPE) + if(selection && selection->ID == GameConstants::HEROI_TYPE) return static_cast(selection); else return NULL; @@ -2050,7 +2045,7 @@ const CGHeroInstance * CAdvMapInt::curHero() const const CGTownInstance * CAdvMapInt::curTown() const { - if(selection && selection->ID == TOWNI_TYPE) + if(selection && selection->ID == GameConstants::TOWNI_TYPE) return static_cast(selection); else return NULL; diff --git a/client/CAdvmapInterface.h b/client/CAdvmapInterface.h index 588dcf848..7e0d24386 100644 --- a/client/CAdvmapInterface.h +++ b/client/CAdvmapInterface.h @@ -1,11 +1,11 @@ -#ifndef __CADVMAPINTERFACE_H__ -#define __CADVMAPINTERFACE_H__ +#pragma once + #include -#include "../global.h" + #include "SDL.h" -#include #include "AdventureMapButton.h" #include "GUIClasses.h" + class CDefHandler; class CCallback; struct CGPath; @@ -176,8 +176,8 @@ public: enum{NA, INGAME, WAITING} state; bool updateScreen, updateMinimap ; - unsigned char anim, animValHitCount; //animation frame - unsigned char heroAnim, heroAnimValHitCount; //animation frame + ui8 anim, animValHitCount; //animation frame + ui8 heroAnim, heroAnimValHitCount; //animation frame SDL_Surface * bg; std::vector gems; @@ -256,5 +256,3 @@ public: }; extern CAdvMapInt *adventureInt; - -#endif // __CADVMAPINTERFACE_H__ diff --git a/client/CAnimation.cpp b/client/CAnimation.cpp index 84d0d0513..c5077c4cd 100644 --- a/client/CAnimation.cpp +++ b/client/CAnimation.cpp @@ -1,7 +1,4 @@ -#include -#include -#include - +#include "StdInc.h" #include #include "../lib/CLodHandler.h" @@ -23,8 +20,8 @@ * */ -extern DLL_EXPORT CLodHandler *spriteh; -extern DLL_EXPORT CLodHandler *bitmaph; +extern DLL_LINKAGE CLodHandler *spriteh; +extern DLL_LINKAGE CLodHandler *bitmaph; typedef std::map > source_map; typedef std::map image_map; @@ -53,7 +50,7 @@ class CompImageLoader CompImage * image; ui8 *position; ui8 *entry; - unsigned int currentLine; + ui32 currentLine; inline ui8 typeOf(ui8 color); inline void NewEntry(ui8 color, size_t size); @@ -97,15 +94,15 @@ CDefFile::CDefFile(std::string Name): palette = new SDL_Color[256]; int it = 0; - unsigned int type = read_le_u32(data + it); + ui32 type = read_le_u32(data + it); it+=4; //int width = read_le_u32(data + it); it+=4;//not used //int height = read_le_u32(data + it); it+=4; it+=8; - unsigned int totalBlocks = read_le_u32(data + it); + ui32 totalBlocks = read_le_u32(data + it); it+=4; - for (unsigned int i= 0; i<256; i++) + for (ui32 i= 0; i<256; i++) { palette[i].r = data[it++]; palette[i].g = data[it++]; @@ -117,7 +114,7 @@ CDefFile::CDefFile(std::string Name): else memcpy(palette, H3Palette, sizeof(SDL_Color)*8);//initialize shadow\selection colors - for (unsigned int i=0; i(FDef+currentOffset); currentOffset += sizeof(ui32) * sprite.height; - for (unsigned int i=0; ipalette, (void*)pal, 256*sizeof(SDL_Color)); //Allocate enought space for worst possible case, c-style malloc used due to resizing after load image->surf = (ui8*)malloc(SpriteSize.x*SpriteSize.y*3); - image->line = new unsigned int[SpriteSize.y+1]; + image->line = new ui32[SpriteSize.y+1]; image->line[0] = 0; position = image->surf; } @@ -591,7 +588,7 @@ SDLImage::SDLImage(std::string filename, bool compressed): } } -void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, unsigned char rotation) const +void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 rotation) const { if (!surf) return; @@ -751,7 +748,7 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha) for (size_t i=0; i::PutColorAlpha(dest, col); } return; @@ -811,7 +808,7 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha) void CompImage::playerColored(int player) { SDL_Color *pal = NULL; - if(player < PLAYER_LIMIT && player >= 0) + if(player < GameConstants::PLAYER_LIMIT && player >= 0) { pal = graphics->playerColorPalette + 32*player; } @@ -941,7 +938,7 @@ void CAnimation::init(CDefFile * file) if (spriteh->haveFile(name, FILE_TEXT)) { int size = 0; - unsigned char * configFile = spriteh->giveFile(name, FILE_TEXT, &size); + ui8 * configFile = spriteh->giveFile(name, FILE_TEXT, &size); const JsonNode config((char*)configFile, size); delete configFile; @@ -1118,7 +1115,7 @@ void CAnimation::getAnimInfo() } } -CAnimImage::CAnimImage(std::string name, size_t Frame, size_t Group, int x, int y, unsigned char Flags): +CAnimImage::CAnimImage(std::string name, size_t Frame, size_t Group, int x, int y, ui8 Flags): frame(Frame), group(Group), player(-1), @@ -1130,7 +1127,7 @@ CAnimImage::CAnimImage(std::string name, size_t Frame, size_t Group, int x, int init(); } -CAnimImage::CAnimImage(CAnimation *Anim, size_t Frame, size_t Group, int x, int y, unsigned char Flags): +CAnimImage::CAnimImage(CAnimation *Anim, size_t Frame, size_t Group, int x, int y, ui8 Flags): anim(Anim), frame(Frame), group(Group), @@ -1206,7 +1203,7 @@ void CAnimImage::playerColored(int currPlayer) anim->getImage(0, group)->playerColored(player); } -CShowableAnim::CShowableAnim(int x, int y, std::string name, unsigned char Flags, unsigned int Delay, size_t Group): +CShowableAnim::CShowableAnim(int x, int y, std::string name, ui8 Flags, ui32 Delay, size_t Group): anim(name, Flags & USE_RLE), group(Group), frame(0), @@ -1232,9 +1229,9 @@ CShowableAnim::~CShowableAnim() anim.unloadGroup(group); } -void CShowableAnim::setAlpha(unsigned int alphaValue) +void CShowableAnim::setAlpha(ui32 alphaValue) { - alpha = std::min(alphaValue, 255); + alpha = std::min(alphaValue, 255); } bool CShowableAnim::set(size_t Group, size_t from, size_t to) @@ -1320,14 +1317,14 @@ void CShowableAnim::blitImage(size_t frame, size_t group, SDL_Surface *to) void CShowableAnim::rotate(bool on, bool vertical) { - unsigned char flag = vertical? VERTICAL_FLIP:HORIZONTAL_FLIP; + ui8 flag = vertical? VERTICAL_FLIP:HORIZONTAL_FLIP; if (on) flags |= flag; else flags &= ~flag; } -CCreatureAnim::CCreatureAnim(int x, int y, std::string name, Rect picPos, unsigned char flags, EAnimType type): +CCreatureAnim::CCreatureAnim(int x, int y, std::string name, Rect picPos, ui8 flags, EAnimType type): CShowableAnim(x,y,name,flags,3,type) { xOffset = picPos.x; diff --git a/client/CAnimation.h b/client/CAnimation.h index 8d50f1d94..e17291137 100644 --- a/client/CAnimation.h +++ b/client/CAnimation.h @@ -1,14 +1,6 @@ -#ifndef __CANIMATION_H__ -#define __CANIMATION_H__ +#pragma once -#include -#include -#include -#include -#include - -#include "../global.h" #include "GUIBase.h" /* @@ -46,7 +38,7 @@ private: //offset[group][frame] - offset of frame data in file std::map > offset; - unsigned char * data; + ui8 * data; SDL_Color * palette; public: @@ -135,7 +127,7 @@ class CompImage : public IImage //RLE-d data ui8 * surf; //array of offsets for each line - unsigned int * line; + ui32 * line; //palette SDL_Color *palette; @@ -237,13 +229,13 @@ private: size_t frame; size_t group; int player; - unsigned char flags; + ui8 flags; void init(); public: - CAnimImage(std::string name, size_t Frame, size_t Group=0, int x=0, int y=0, unsigned char Flags=0); - CAnimImage(CAnimation* anim, size_t Frame, size_t Group=0, int x=0, int y=0, unsigned char Flags=0); + CAnimImage(std::string name, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0); + CAnimImage(CAnimation* anim, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0); ~CAnimImage();//d-tor //size of animation @@ -278,10 +270,10 @@ protected: size_t first, last; //animation range //TODO: replace with time delay(needed for battles) - unsigned int frameDelay;//delay in frames of each image - unsigned int value;//how many times current frame was showed + ui32 frameDelay;//delay in frames of each image + ui32 value;//how many times current frame was showed - unsigned char flags;//Flags from EFlags enum + ui8 flags;//Flags from EFlags enum //blit image with optional rotation, fitting into rect, etc void blitImage(size_t frame, size_t group, SDL_Surface *to); @@ -296,9 +288,9 @@ public: boost::function callback; //Set per-surface alpha, 0 = transparent, 255 = opaque - void setAlpha(unsigned int alphaValue); + void setAlpha(ui32 alphaValue); - CShowableAnim(int x, int y, std::string name, unsigned char flags=0, unsigned int Delay=4, size_t Group=0); + CShowableAnim(int x, int y, std::string name, ui8 flags=0, ui32 Delay=4, size_t Group=0); ~CShowableAnim(); //set animation to group or part of group @@ -376,8 +368,6 @@ public: void clearAndSet(EAnimType type); CCreatureAnim(int x, int y, std::string name, Rect picPos, - unsigned char flags= USE_RLE, EAnimType = HOLDING ); + ui8 flags= USE_RLE, EAnimType = HOLDING ); }; - -#endif // __CANIMATIONHANDLER_H__ diff --git a/client/CBitmapHandler.cpp b/client/CBitmapHandler.cpp index 5a3723fa3..63337fa0e 100644 --- a/client/CBitmapHandler.cpp +++ b/client/CBitmapHandler.cpp @@ -1,12 +1,11 @@ -#include "../stdafx.h" +#include "StdInc.h" + #include "SDL.h" #include "SDL_image.h" #include "CBitmapHandler.h" #include "CDefHandler.h" #include "../lib/CLodHandler.h" #include "../lib/vcmi_endian.h" -#include -#include /* * CBitmapHandler.cpp, part of VCMI engine @@ -18,14 +17,14 @@ * */ -extern DLL_EXPORT CLodHandler *bitmaph; -extern DLL_EXPORT CLodHandler *bitmaph_ab; -extern DLL_EXPORT CLodHandler *spriteh; +extern DLL_LINKAGE CLodHandler *bitmaph; +extern DLL_LINKAGE CLodHandler *bitmaph_ab; +extern DLL_LINKAGE CLodHandler *spriteh; void CPCXConv::openPCX(char * PCX, int len) { pcxs=len; - pcx=(unsigned char*)PCX; + pcx=(ui8*)PCX; } void CPCXConv::fromFile(std::string path) { @@ -34,7 +33,7 @@ void CPCXConv::fromFile(std::string path) is.seekg(0,std::ios::end); // to the end pcxs = is.tellg(); // read length is.seekg(0,std::ios::beg); // wracamy na poczatek - pcx = new unsigned char[pcxs]; // allocate memory + pcx = new ui8[pcxs]; // allocate memory is.read((char*)pcx, pcxs); // read map file to buffer is.close(); } @@ -119,7 +118,7 @@ SDL_Surface * CPCXConv::getSurface() const return ret; } -bool isPCX(const unsigned char *header)//check whether file can be PCX according to 1st 12 bytes +bool isPCX(const ui8 *header)//check whether file can be PCX according to 1st 12 bytes { int fSize = read_le_u32(header + 0); int width = read_le_u32(header + 4); @@ -142,7 +141,7 @@ SDL_Surface * BitmapHandler::loadBitmapFromLod(CLodHandler *lod, std::string fna SDL_Surface * ret=NULL; int size; - unsigned char * file = 0; + ui8 * file = 0; file = lod->giveFile(fname, FILE_GRAPHICS, &size); if (isPCX(file)) diff --git a/client/CBitmapHandler.h b/client/CBitmapHandler.h index 563b2fcb1..d8ceedf63 100644 --- a/client/CBitmapHandler.h +++ b/client/CBitmapHandler.h @@ -1,8 +1,7 @@ -#ifndef __CBITMAPHANDLER_H__ -#define __CBITMAPHANDLER_H__ +#pragma once + -#include "../global.h" struct SDL_Surface; class CLodHandler; @@ -21,14 +20,14 @@ enum Epcxformat {PCX8B, PCX24B}; /// Struct which stands for a simple rgba palette struct BMPPalette { - unsigned char R,G,B,F; + ui8 R,G,B,F; }; /// Class which converts pcx to bmp images class CPCXConv { public: - unsigned char * pcx, *bmp; + ui8 * pcx, *bmp; int pcxs, bmps; void fromFile(std::string path); void saveBMP(std::string path) const; @@ -52,5 +51,3 @@ namespace BitmapHandler //Load file from any LODs SDL_Surface * loadBitmap(std::string fname, bool setKey=true); }; - -#endif // __CBITMAPHANDLER_H__ diff --git a/client/CCastleInterface.cpp b/client/CCastleInterface.cpp index 6e4d5a46b..8ae467671 100644 --- a/client/CCastleInterface.cpp +++ b/client/CCastleInterface.cpp @@ -1,13 +1,6 @@ -#include "../stdafx.h" - -#include -#include -#include -#include -#include -#include - +#include "StdInc.h" #include "CCastleInterface.h" + #include "../CCallback.h" #include "../lib/CArtHandler.h" #include "../lib/CBuildingHandler.h" @@ -28,6 +21,7 @@ #include "CPlayerInterface.h" #include "Graphics.h" #include "SDL_Extensions.h" +#include "../lib/GameConstants.h" using namespace boost::assign; @@ -126,7 +120,7 @@ void CBuildingRect::clickRight(tribool down, bool previousState) { int bid = hordeToDwellingID(str->ID); const CBuilding *bld = CGI->buildh->buildings[str->townID].find(bid)->second; - if (bid < Buildings::DWELL_FIRST) + if (bid < EBuilding::DWELL_FIRST) { std::vector comps(1, new SComponent(SComponent::building, bld->tid, bld->bid, @@ -136,13 +130,13 @@ void CBuildingRect::clickRight(tribool down, bool previousState) } else { - int level = ( bid - Buildings::DWELL_FIRST ) % CREATURES_PER_TOWN; + int level = ( bid - EBuilding::DWELL_FIRST ) % GameConstants::CREATURES_PER_TOWN; GH.pushInt(new CDwellingInfoBox(parent->pos.x+parent->pos.w/2, parent->pos.y+parent->pos.h/2, town, level)); } } } -SDL_Color multiplyColors (const SDL_Color &b, const SDL_Color &a, float f) +SDL_Color multiplyColors (const SDL_Color &b, const SDL_Color &a, double f) { SDL_Color ret; ret.r = a.r*f + b.r*(1-f); @@ -153,12 +147,12 @@ SDL_Color multiplyColors (const SDL_Color &b, const SDL_Color &a, float f) void CBuildingRect::show(SDL_Surface *to) { - const unsigned int stageDelay = 16; + const ui32 stageDelay = 16; - const unsigned int S1_TRANSP = 16; //0.5 sec building appear 0->100 transparency - const unsigned int S2_WHITE_B = 32; //0.5 sec border glows from white to yellow - const unsigned int S3_YELLOW_B= 48; //0.5 sec border glows from yellow to normal - const unsigned int BUILDED = 80; // 1 sec delay, nothing happens + const ui32 S1_TRANSP = 16; //0.5 sec building appear 0->100 transparency + const ui32 S2_WHITE_B = 32; //0.5 sec border glows from white to yellow + const ui32 S3_YELLOW_B= 48; //0.5 sec border glows from yellow to normal + const ui32 BUILDED = 80; // 1 sec delay, nothing happens if (stateCounter < S1_TRANSP) { @@ -184,15 +178,15 @@ void CBuildingRect::show(SDL_Surface *to) SDL_Color c2 = {120, 100, 60, 255}; SDL_Color c3 = {200, 180, 110, 255}; - unsigned int colorID = SDL_MapRGB(border->format, c3.r, c3.g, c3.b); + ui32 colorID = SDL_MapRGB(border->format, c3.r, c3.g, c3.b); SDL_Color oldColor = border->format->palette->colors[colorID]; SDL_Color newColor; if (stateCounter < S2_WHITE_B) - newColor = multiplyColors(c1, c2, float(stateCounter%stageDelay)/stageDelay); + newColor = multiplyColors(c1, c2, static_cast(stateCounter % stageDelay) / stageDelay); else if (stateCounter < S3_YELLOW_B) - newColor = multiplyColors(c2, c3, float(stateCounter%stageDelay)/stageDelay); + newColor = multiplyColors(c2, c3, static_cast(stateCounter % stageDelay) / stageDelay); else newColor = oldColor; @@ -224,7 +218,7 @@ std::string getBuildingSubtitle(int tid, int bid)//hover text for building return CGI->buildh->buildings[tid].find(bid)->second->Name(); else//dwellings - recruit %creature% { - int creaID = t->creatures[(bid-30)%CREATURES_PER_TOWN].second.back();//taking last of available creatures + int creaID = t->creatures[(bid-30)%GameConstants::CREATURES_PER_TOWN].second.back();//taking last of available creatures return CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creaID]->namePl; } } @@ -272,7 +266,7 @@ CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstanc available = new CLabel(80,190, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->allTexts[217] + text); costPerTroop = new CLabel(80, 227, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->allTexts[346]); - for(int i = 0; icost[i]) { @@ -484,7 +478,7 @@ CCastleBuildings::CCastleBuildings(const CGTownInstance* Town): if(shipyard && vstd::contains(groups, shipyard->group)) { std::vector vobjs = LOCPLINT->cb->getVisitableObjs(town->bestLocation()); - if(!vobjs.empty() && (vobjs.front()->ID == 8 || vobjs.front()->ID == HEROI_TYPE)) //there is visitable obj at shipyard output tile and it's a boat or hero (on boat) + if(!vobjs.empty() && (vobjs.front()->ID == 8 || vobjs.front()->ID == GameConstants::HEROI_TYPE)) //there is visitable obj at shipyard output tile and it's a boat or hero (on boat) { groups[shipyard->group].push_back(CGI->townh->structures[town->subID][20]); } @@ -652,52 +646,52 @@ void CCastleBuildings::buildingClicked(int building) building = hordeToDwellingID(building); const CBuilding *b = CGI->buildh->buildings[town->subID].find(building)->second; - if(building >= Buildings::DWELL_FIRST) + if(building >= EBuilding::DWELL_FIRST) { - enterDwelling((building-Buildings::DWELL_FIRST)%CREATURES_PER_TOWN); + enterDwelling((building-EBuilding::DWELL_FIRST)%GameConstants::CREATURES_PER_TOWN); } else { switch(building) { - case Buildings::MAGES_GUILD_1: - case Buildings::MAGES_GUILD_2: - case Buildings::MAGES_GUILD_3: - case Buildings::MAGES_GUILD_4: - case Buildings::MAGES_GUILD_5: + case EBuilding::MAGES_GUILD_1: + case EBuilding::MAGES_GUILD_2: + case EBuilding::MAGES_GUILD_3: + case EBuilding::MAGES_GUILD_4: + case EBuilding::MAGES_GUILD_5: enterMagesGuild(); break; - case Buildings::TAVERN: + case EBuilding::TAVERN: LOCPLINT->showTavernWindow(town); break; - case Buildings::SHIPYARD: + case EBuilding::SHIPYARD: LOCPLINT->showShipyardDialog(town); break; - case Buildings::FORT: - case Buildings::CITADEL: - case Buildings::CASTLE: + case EBuilding::FORT: + case EBuilding::CITADEL: + case EBuilding::CASTLE: GH.pushInt(new CFortScreen(town)); break; - case Buildings::VILLAGE_HALL: - case Buildings::CITY_HALL: - case Buildings::TOWN_HALL: - case Buildings::CAPITOL: + case EBuilding::VILLAGE_HALL: + case EBuilding::CITY_HALL: + case EBuilding::TOWN_HALL: + case EBuilding::CAPITOL: enterTownHall(); break; - case Buildings::MARKETPLACE: + case EBuilding::MARKETPLACE: GH.pushInt(new CMarketplaceWindow(town, town->visitingHero)); break; - case Buildings::BLACKSMITH: + case EBuilding::BLACKSMITH: enterBlacksmith(town->town->warMachine); break; - case Buildings::SPECIAL_1: + case EBuilding::SPECIAL_1: switch(town->subID) { case 1://Mystic Pond @@ -706,7 +700,7 @@ void CCastleBuildings::buildingClicked(int building) case 2: case 5: case 8://Artifact Merchant if(town->visitingHero) - GH.pushInt(new CMarketplaceWindow(town, town->visitingHero, RESOURCE_ARTIFACT)); + GH.pushInt(new CMarketplaceWindow(town, town->visitingHero, EMarketMode::RESOURCE_ARTIFACT)); else LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->Name())); //Only visiting heroes may use the %s. break; @@ -717,11 +711,11 @@ void CCastleBuildings::buildingClicked(int building) } break; - case Buildings::SHIP: + case EBuilding::SHIP: LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]); //Cannot build another boat break; - case Buildings::SPECIAL_2: + case EBuilding::SPECIAL_2: switch(town->subID) { case 1: //Fountain of Fortune @@ -730,7 +724,7 @@ void CCastleBuildings::buildingClicked(int building) case 6: //Freelancer's Guild if(getHero()) - GH.pushInt(new CMarketplaceWindow(town, getHero(), CREATURE_RESOURCE)); + GH.pushInt(new CMarketplaceWindow(town, getHero(), EMarketMode::CREATURE_RESOURCE)); else LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->Name())); //Only visiting heroes may use the %s. break; @@ -748,7 +742,7 @@ void CCastleBuildings::buildingClicked(int building) } break; - case Buildings::SPECIAL_3: + case EBuilding::SPECIAL_3: switch(town->subID) { case 0: //Brotherhood of sword @@ -764,10 +758,10 @@ void CCastleBuildings::buildingClicked(int building) break; case 5: //Portal of Summoning - if (town->creatures[CREATURES_PER_TOWN].second.empty())//No creatures + if (town->creatures[GameConstants::CREATURES_PER_TOWN].second.empty())//No creatures LOCPLINT->showInfoDialog(CGI->generaltexth->tcommands[30]); else - enterDwelling(CREATURES_PER_TOWN); + enterDwelling(GameConstants::CREATURES_PER_TOWN); break; case 6: //Ballista Yard @@ -887,13 +881,13 @@ void CCastleBuildings::enterMagesGuild() void CCastleBuildings::enterTownHall() { if(town->visitingHero && town->visitingHero->hasArt(2) && - !vstd::contains(town->builtBuildings, Buildings::GRAIL)) //hero has grail, but town does not have it + !vstd::contains(town->builtBuildings, EBuilding::GRAIL)) //hero has grail, but town does not have it { - if(!vstd::contains(town->forbiddenBuildings, Buildings::GRAIL)) + if(!vstd::contains(town->forbiddenBuildings, EBuilding::GRAIL)) { LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[597], //Do you wish this to be the permanent home of the Grail? std::vector(), - boost::bind(&CCallback::buildBuilding, LOCPLINT->cb, town, Buildings::GRAIL), + boost::bind(&CCallback::buildBuilding, LOCPLINT->cb, town, EBuilding::GRAIL), boost::bind(&CCastleBuildings::openTownHall, this), true); } else @@ -954,11 +948,11 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, int listPos): townlist = new CTownList(3, 744, 414, "IAM014", "IAM015"); townlist->fun = boost::bind(&CCastleInterface::townChange, this); - townlist->selected = vstd::findPos(LOCPLINT->towns, Town); + townlist->selected = vstd::find_pos(LOCPLINT->towns, Town); townlist->from = townlist->selected - listPos; - amax(townlist->from, 0); - amin(townlist->from, LOCPLINT->towns.size() - townlist->SIZE); + vstd::amax(townlist->from, 0); + vstd::amin(townlist->from, LOCPLINT->towns.size() - townlist->SIZE); LOCPLINT->castleInt = this; recreateIcons(); @@ -1034,9 +1028,9 @@ void CCastleInterface::recreateIcons() size_t iconIndex = town->subID*2; if (!town->hasFort()) - iconIndex += F_NUMBER*2; + iconIndex += GameConstants::F_NUMBER*2; - if(town->builded >= MAX_BUILDING_PER_TURN) + if(town->builded >= GameConstants::MAX_BUILDING_PER_TURN) iconIndex++; icon->setFrame(iconIndex); @@ -1073,7 +1067,7 @@ CCreaInfo::CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool } used = LCLICK | RCLICK | HOVER; - unsigned int creatureID = town->creatures[level].second.back(); + ui32 creatureID = town->creatures[level].second.back(); creature = CGI->creh->creatures[creatureID]; picture = new CAnimImage("CPRSMALL", creatureID+2, 0, 8, 0); @@ -1297,9 +1291,9 @@ void CHallInterface::CBuildingBox::hover(bool on) if(on) { std::string toPrint; - if(state==Buildings::PREREQUIRES) + if(state==EBuildingState::PREREQUIRES) toPrint = CGI->generaltexth->hcommands[5]; - else if(state==Buildings::CANT_BUILD_TODAY) + else if(state==EBuildingState::CANT_BUILD_TODAY) toPrint = CGI->generaltexth->allTexts[223]; else toPrint = CGI->generaltexth->hcommands[state]; @@ -1334,7 +1328,7 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance * pos.h = 92; state = LOCPLINT->cb->canBuildStructure(town,building->bid); - assert(state < Buildings::ERROR); + assert(state < EBuildingState::BUILDING_ERROR); static int panelIndex[9] = { 3, 3, 3, 0, 0, 2, 2, 1, 2}; static int iconIndex[9] = {-1, -1, -1, 0, 0, 1, 2, -1, 1}; @@ -1359,7 +1353,7 @@ CHallInterface::CHallInterface(const CGTownInstance *Town): Rect barRect(5, 556, 740, 18); statusBar = new CGStatusBar(new CPicture(*background, barRect, 5, 556, false)); - title = new CLabel(399, 12, FONT_MEDIUM, CENTER, zwykly, CGI->buildh->buildings[town->subID][town->hallLevel()+Buildings::VILLAGE_HALL]->Name()); + title = new CLabel(399, 12, FONT_MEDIUM, CENTER, zwykly, CGI->buildh->buildings[town->subID][town->hallLevel()+EBuilding::VILLAGE_HALL]->Name()); exit = new AdventureMapButton(CGI->generaltexth->hcommands[8], "", boost::bind(&CHallInterface::close,this), 748, 556, "TPMAGE1.DEF", SDLK_RETURN); exit->assignedKeys.insert(SDLK_ESCAPE); @@ -1468,7 +1462,7 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin buildingState = new CTextBox(getTextForState(state), Rect(33, 216, 329, 67), 0, FONT_SMALL, CENTER); //Create objects for all required resources - for(int i = 0; iresources[i]) { @@ -1478,7 +1472,7 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin } } - unsigned int rowSize[2]; + ui32 rowSize[2]; int posY; if (resAmount.size() > 4) {//Resources will be placed in multiple rows @@ -1492,7 +1486,7 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin } rowSize[1] = resAmount.size() - rowSize[0]; - unsigned int index=0; + ui32 index=0; for (size_t row=0; row<2; row++) { int posX = pos.w/2 - rowSize[row] * 40 + 24; @@ -1532,11 +1526,11 @@ void CFortScreen::close() CFortScreen::CFortScreen(const CGTownInstance * town) { OBJ_CONSTRUCTION_CAPTURING_ALL; - unsigned int fortSize = town->creatures.size(); - if (fortSize > CREATURES_PER_TOWN && town->creatures.back().second.empty()) + ui32 fortSize = town->creatures.size(); + if (fortSize > GameConstants::CREATURES_PER_TOWN && town->creatures.back().second.empty()) fortSize--; - if (fortSize == CREATURES_PER_TOWN) + if (fortSize == GameConstants::CREATURES_PER_TOWN) background = new CPicture("TPCASTL7"); else background = new CPicture("TPCASTL8"); @@ -1554,20 +1548,20 @@ CFortScreen::CFortScreen(const CGTownInstance * town) Point(10, 155), Point(404,155), Point(10, 288), Point(404,288); - if (fortSize == CREATURES_PER_TOWN) + if (fortSize == GameConstants::CREATURES_PER_TOWN) positions += Point(206,421); else positions += Point(10, 421), Point(404,421); - for (unsigned int i=0; ibuiltBuildings, Buildings::DWELL_UP_FIRST+i)) - buildingID = Buildings::DWELL_UP_FIRST+i; + if (vstd::contains(town->builtBuildings, EBuilding::DWELL_UP_FIRST+i)) + buildingID = EBuilding::DWELL_UP_FIRST+i; else - buildingID = Buildings::DWELL_FIRST+i; + buildingID = EBuilding::DWELL_FIRST+i; } else buildingID = 22; @@ -1678,7 +1672,7 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance * if (vstd::contains(town->builtBuildings, buildingID)) { - unsigned int available = town->creatures[level].first; + ui32 available = town->creatures[level].first; std::string availableText = CGI->generaltexth->allTexts[217]+ boost::lexical_cast(available); availableCount = new CLabel(78, 119, FONT_SMALL, CENTER, zwykly, availableText); } diff --git a/client/CCastleInterface.h b/client/CCastleInterface.h index cff7d37ee..e5a80045c 100644 --- a/client/CCastleInterface.h +++ b/client/CCastleInterface.h @@ -1,7 +1,6 @@ -#ifndef __CCASTLEINTERFACE_H__ -#define __CCASTLEINTERFACE_H__ +#pragma once + -#include "../global.h" #include "CAnimation.h" #include "GUIBase.h" @@ -31,6 +30,7 @@ struct Structure; * */ + /// Building "button" class CBuildingRect : public CShowableAnim { @@ -41,7 +41,7 @@ public: SDL_Surface* border; SDL_Surface* area; - unsigned int stateCounter;//For building construction - current stage in animation + ui32 stateCounter;//For building construction - current stage in animation CBuildingRect(CCastleBuildings * Par, const CGTownInstance *Town, const Structure *Str); //c-tor ~CBuildingRect(); //d-tor @@ -234,7 +234,7 @@ class CHallInterface : public CIntObject const CGTownInstance * town; const CBuilding * building; - unsigned int state;//Buildings::EBuildStructure enum + ui32 state;//Buildings::EBuildStructure enum CAnimImage * picture; CAnimImage * panel; @@ -392,5 +392,3 @@ class CBlacksmithDialog : public CIntObject public: CBlacksmithDialog(bool possible, int creMachineID, int aid, int hid); }; - -#endif // __CCASTLEINTERFACE_H__ diff --git a/client/CConfigHandler.cpp b/client/CConfigHandler.cpp index e060d9c46..f6e34c6c9 100644 --- a/client/CConfigHandler.cpp +++ b/client/CConfigHandler.cpp @@ -1,11 +1,9 @@ -//#define BOOST_SPIRIT_DEBUG -#include "CConfigHandler.h" -#include -#include +#include "StdInc.h" #include -#include -#include +#include "CConfigHandler.h" + #include "../lib/JsonNode.h" +#include "../lib/GameConstants.h" using namespace config; @@ -148,10 +146,11 @@ CConfigHandler::~CConfigHandler(void) void config::CConfigHandler::init() { std::vector settings; - std::ifstream ifs(DATA_DIR "/config/settings.txt"); + std::string settingsDir = GameConstants::DATA_DIR + "/config/settings.txt"; + std::ifstream ifs(settingsDir.c_str()); if(!ifs) { - tlog1 << "Cannot open " DATA_DIR "/config/settings.txt !" << std::endl; + tlog1 << "Cannot open " << GameConstants::DATA_DIR << "/config/settings.txt !" << std::endl; return; } ifs.unsetf(std::ios::skipws); // Turn of white space skipping on the stream @@ -170,7 +169,7 @@ void config::CConfigHandler::init() tlog2 << "Not entire config/settings.txt parsed!\n"; /* Read resolutions. */ - const JsonNode config(DATA_DIR "/config/resolutions.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/resolutions.json"); const JsonVector &guisettings_vec = config["GUISettings"].Vector(); BOOST_FOREACH(const JsonNode &g, guisettings_vec) { diff --git a/client/CConfigHandler.h b/client/CConfigHandler.h index 25dab51a8..6863bd03a 100644 --- a/client/CConfigHandler.h +++ b/client/CConfigHandler.h @@ -1,6 +1,7 @@ -#ifndef __CCONFIGHANDLER_H__ -#define __CCONFIGHANDLER_H__ -#include "../global.h" +#pragma once + + + class CAdvMapInt; /* @@ -95,5 +96,3 @@ namespace config }; } extern config::CConfigHandler conf; - -#endif // __CCONFIGHANDLER_H__ diff --git a/client/CCreatureAnimation.cpp b/client/CCreatureAnimation.cpp index b70208a7c..5b10a7e90 100644 --- a/client/CCreatureAnimation.cpp +++ b/client/CCreatureAnimation.cpp @@ -1,8 +1,9 @@ +#include "StdInc.h" #include "CCreatureAnimation.h" + #include "../lib/CLodHandler.h" #include "../lib/VCMI_Lib.h" #include "../lib/vcmi_endian.h" -#include #include "SDL_Extensions.h" /* @@ -95,7 +96,7 @@ CCreatureAnimation::CCreatureAnimation(std::string name) : internalFrame(0), onc frames = totalEntries; } -int CCreatureAnimation::nextFrameMiddle(SDL_Surface *dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect) +int CCreatureAnimation::nextFrameMiddle(SDL_Surface *dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect) { return nextFrame(dest, x-fullWidth/2, y-fullHeight/2, attacker, animCount, incrementFrame, yellowBorder, blueBorder, destRect); } @@ -159,7 +160,7 @@ void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type ) template -int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/) +int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/) { //increasing frame number int SIndex = curFrame; @@ -172,17 +173,17 @@ int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attack i, FullHeight, #endif - unsigned char SegmentType, SegmentLength; - unsigned int i; + ui8 SegmentType, SegmentLength; + ui32 i; i = SEntries[SIndex].offset; /*int prSize = read_le_u32(FDef + i);*/ i += 4; //TODO use me - const unsigned int defType2 = read_le_u32(FDef + i); i += 4; - const unsigned int FullWidth = read_le_u32(FDef + i); i += 4; - const unsigned int FullHeight = read_le_u32(FDef + i); i += 4; - const unsigned int SpriteWidth = read_le_u32(FDef + i); i += 4; - const unsigned int SpriteHeight = read_le_u32(FDef + i); i += 4; + const ui32 defType2 = read_le_u32(FDef + i); i += 4; + const ui32 FullWidth = read_le_u32(FDef + i); i += 4; + const ui32 FullHeight = read_le_u32(FDef + i); i += 4; + const ui32 SpriteWidth = read_le_u32(FDef + i); i += 4; + const ui32 SpriteHeight = read_le_u32(FDef + i); i += 4; const int LeftMargin = read_le_u32(FDef + i); i += 4; const int TopMargin = read_le_u32(FDef + i); i += 4; const int RightMargin = FullWidth - SpriteWidth - LeftMargin; @@ -224,7 +225,7 @@ int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attack const int remainder = ftcp % FullWidth; int xB = (attacker ? remainder : FullWidth - remainder - 1) + x; - const unsigned char aCountMod = (animCount & 0x20) ? ((animCount & 0x1e) >> 1) << 4 : (0x0f - ((animCount & 0x1e) >> 1)) << 4; + const ui8 aCountMod = (animCount & 0x20) ? ((animCount & 0x1e) >> 1) << 4 : (0x0f - ((animCount & 0x1e) >> 1)) << 4; for (int k = 0; k <= SegmentLength; k++) { @@ -265,7 +266,7 @@ int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attack return 0; } -int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect) +int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame, bool yellowBorder, bool blueBorder, SDL_Rect * destRect) { switch(dest->format->BytesPerPixel) { @@ -296,10 +297,10 @@ inline void CCreatureAnimation::putPixel( const int & ftcpX, const int & ftcpY, const BMPPalette & color, - const unsigned char & palc, + const ui8 & palc, const bool & yellowBorder, const bool & blueBorder, - const unsigned char & animCount + const ui8 & animCount ) const { if(palc!=0) diff --git a/client/CCreatureAnimation.h b/client/CCreatureAnimation.h index eca542fbe..dd8170afc 100644 --- a/client/CCreatureAnimation.h +++ b/client/CCreatureAnimation.h @@ -1,8 +1,6 @@ -#ifndef __CCREATUREANIMATION_H__ -#define __CCREATUREANIMATION_H__ +#pragma once -#include "../global.h" #include "CDefHandler.h" #include "GUIBase.h" #include "../client/CBitmapHandler.h" @@ -41,22 +39,22 @@ private: const int & ftcpX, const int & ftcpY, const BMPPalette & color, - const unsigned char & palc, + const ui8 & palc, const bool & yellowBorder, const bool & blueBorder, - const unsigned char & animCount + const ui8 & animCount ) const; //////////// - unsigned char * FDef; //animation raw data + ui8 * FDef; //animation raw data int curFrame, internalFrame; //number of currently displayed frame - unsigned int frames; //number of frames + ui32 frames; //number of frames CCreatureAnim::EAnimType type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1]) template - int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next - int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next + int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next + int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next std::map > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group bool once; @@ -69,7 +67,7 @@ public: void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount CCreatureAnim::EAnimType getType() const; //returns type of animation - int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next + int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next void incrementFrame(); int getFrame() const; // Gets the current frame ID relative to DEF file. int getAnimationFrame() const; // Gets the current frame ID relative to frame group. @@ -80,5 +78,3 @@ public: int framesInGroup(CCreatureAnim::EAnimType group) const; //retirns number of fromes in given group }; - -#endif // __CCREATUREANIMATION_H__ diff --git a/client/CCreatureWindow.cpp b/client/CCreatureWindow.cpp index 0e92183bf..7a83b02bc 100644 --- a/client/CCreatureWindow.cpp +++ b/client/CCreatureWindow.cpp @@ -1,4 +1,6 @@ +#include "StdInc.h" #include "CCreatureWindow.h" + #include "../lib/CCreatureSet.h" #include "CGameInfo.h" #include "../lib/CGeneralTextHandler.h" @@ -14,13 +16,6 @@ #include "CPlayerInterface.h" #include "CConfigHandler.h" -#include -#include -#include -#include -#include -#include -#include #include "../lib/CGameState.h" #include "../lib/BattleState.h" #include "../lib/CSpellHandler.h" @@ -180,8 +175,8 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode * } bonusRows = std::min ((int)((bonusItems.size() + 1) / 2), (conf.cc.resy - 230) / 60); - amin(bonusRows, 4); - amax(bonusRows, 1); + vstd::amin(bonusRows, 4); + vstd::amax(bonusRows, 1); bitmap = new CPicture("CreWin" + boost::lexical_cast(bonusRows) + ".pcx"); //1 to 4 rows for now bitmap->colorizeAndConvert(LOCPLINT->playerID); @@ -206,7 +201,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode * new CPicture(graphics->pskillsm->ourImages[4].bitmap, 335, 50, false); //exp icon - Print it always? if (type) //not in fort window { - if (STACK_EXP) + if (GameConstants::STACK_EXP) { int rank = std::min(stack->getExpRank(), 10); //hopefully nobody adds more printAtMiddle(CGI->generaltexth->zcrexp[rank] + " [" + boost::lexical_cast(rank) + "]", 436, 62, FONT_MEDIUM, tytulowy,*bitmap); @@ -214,7 +209,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode * if (type > BATTLE) //we need it only on adv. map { int tier = stack->type->level; - if (!iswith(tier, 1, 7)) + if (!vstd::iswithin(tier, 1, 7)) tier = 0; int number; std::string expText = CGI->generaltexth->zcrexp[324]; @@ -253,7 +248,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode * } } - if (STACK_ARTIFACT && type > BATTLE) + if (GameConstants::STACK_ARTIFACT && type > BATTLE) { //SDL_Rect rect = genRect(44,44,465,98); //creatureArtifact = new CArtPlace(NULL); diff --git a/client/CCreatureWindow.h b/client/CCreatureWindow.h index d3c001bc0..9358d79b0 100644 --- a/client/CCreatureWindow.h +++ b/client/CCreatureWindow.h @@ -1,4 +1,6 @@ -#include "../global.h" +#pragma once + + #include "GUIBase.h" #include "GUIClasses.h" #include "../lib/HeroBonus.h" diff --git a/client/CCursorHandler.cpp b/client/CCursorHandler.cpp index 74aae01b6..517005c45 100644 --- a/client/CCursorHandler.cpp +++ b/client/CCursorHandler.cpp @@ -1,5 +1,6 @@ -#include "../stdafx.h" +#include "StdInc.h" #include "CCursorHandler.h" + #include "SDL.h" #include "SDL_Extensions.h" #include "CGameInfo.h" diff --git a/client/CCursorHandler.h b/client/CCursorHandler.h index 0c7e54220..6dc668f47 100644 --- a/client/CCursorHandler.h +++ b/client/CCursorHandler.h @@ -1,7 +1,7 @@ -#ifndef __CCURSORHANDLER_H__ -#define __CCURSORHANDLER_H__ -#include "../global.h" -#include +#pragma once + + + struct SDL_Thread; class CDefHandler; struct SDL_Surface; @@ -41,7 +41,3 @@ public: void centerCursor(); ~CCursorHandler(); }; - - - -#endif // __CCURSORHANDLER_H__ diff --git a/client/CDefHandler.cpp b/client/CDefHandler.cpp index ddb72b6a5..19862e122 100644 --- a/client/CDefHandler.cpp +++ b/client/CDefHandler.cpp @@ -1,7 +1,7 @@ -#include "../stdafx.h" +#include "StdInc.h" #include "SDL.h" #include "CDefHandler.h" -#include + #include "../lib/CLodHandler.h" #include "../lib/VCMI_Lib.h" #include "../lib/vcmi_endian.h" @@ -51,19 +51,19 @@ CDefEssential::~CDefEssential() SDL_FreeSurface(ourImages[i].bitmap); } -void CDefHandler::openFromMemory(unsigned char *table, const std::string & name) +void CDefHandler::openFromMemory(ui8 *table, const std::string & name) { BMPPalette palette[256]; SDefEntry &de = * reinterpret_cast(table); - unsigned char *p; + ui8 *p; defName = name; DEFType = SDL_SwapLE32(de.DEFType); width = SDL_SwapLE32(de.width); height = SDL_SwapLE32(de.height); - unsigned int totalBlocks = SDL_SwapLE32(de.totalBlocks); + ui32 totalBlocks = SDL_SwapLE32(de.totalBlocks); - for (unsigned int it=0;it<256;it++) + for (ui32 it=0;it<256;it++) { palette[it].R = de.palette[it].R; palette[it].G = de.palette[it].G; @@ -72,22 +72,22 @@ void CDefHandler::openFromMemory(unsigned char *table, const std::string & name) } // The SDefEntryBlock starts just after the SDefEntry - p = reinterpret_cast(&de); + p = reinterpret_cast(&de); p += sizeof(de); int totalEntries=0; - for (unsigned int z=0; z(p); - unsigned int totalInBlock; + ui32 totalInBlock; totalInBlock = read_le_u32(&block.totalInBlock); - for (unsigned int j=SEntries.size(); j> 5; BR = N & 0x1F; } -SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, const BMPPalette * palette) const +SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPalette * palette) const { SDL_Surface * ret=NULL; - unsigned int BaseOffset, + ui32 BaseOffset, SpriteWidth, SpriteHeight, //format of sprite TotalRowLength, // length of read segment add, FullHeight,FullWidth, @@ -143,7 +143,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co int LeftMargin, RightMargin, TopMargin, BottomMargin; - unsigned char SegmentType;//, BL, BR; //TODO use me + ui8 SegmentType;//, BL, BR; //TODO use me BaseOffset = SEntries[SIndex].offset; SSpriteDef sd = * reinterpret_cast(FDef + BaseOffset); @@ -201,7 +201,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co { case 0: { - for (unsigned int i=0;i0) ftcp += LeftMargin; @@ -218,9 +218,9 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co case 1: { - const unsigned int * RWEntriesLoc = reinterpret_cast(FDef+BaseOffset); + const ui32 * RWEntriesLoc = reinterpret_cast(FDef+BaseOffset); BaseOffset += sizeof(int) * SpriteHeight; - for (unsigned int i=0;i0) @@ -229,7 +229,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co TotalRowLength=0; do { - unsigned int SegmentLength; + ui32 SegmentLength; SegmentType=FDef[BaseOffset++]; SegmentLength=FDef[BaseOffset++] + 1; @@ -262,7 +262,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co { BaseOffset = BaseOffsetor + read_le_u16(FDef + BaseOffsetor); - for (unsigned int i=0;i0) @@ -273,8 +273,8 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co do { SegmentType=FDef[BaseOffset++]; - unsigned char code = SegmentType / 32; - unsigned char value = (SegmentType & 31) + 1; + ui8 code = SegmentType / 32; + ui8 value = (SegmentType & 31) + 1; if(code==7) { memcpy(reinterpret_cast(ret->pixels)+ftcp, &FDef[BaseOffset], value); @@ -302,7 +302,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co case 3: { - for (unsigned int i=0;i0) @@ -313,11 +313,11 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co do { SegmentType=FDef[BaseOffset++]; - unsigned char code = SegmentType / 32; - unsigned char value = (SegmentType & 31) + 1; + ui8 code = SegmentType / 32; + ui8 value = (SegmentType & 31) + 1; - int len = std::min(value, SpriteWidth - TotalRowLength) - std::max(0, -LeftMargin); - amax(len, 0); + int len = std::min(value, SpriteWidth - TotalRowLength) - std::max(0, -LeftMargin); + vstd::amax(len, 0); if(code==7) { @@ -365,7 +365,7 @@ CDefEssential * CDefHandler::essentialize() CDefHandler * CDefHandler::giveDef(const std::string & defName) { - unsigned char * data = spriteh->giveFile(defName, FILE_ANIMATION); + ui8 * data = spriteh->giveFile(defName, FILE_ANIMATION); if(!data) throw "bad def name!"; CDefHandler * nh = new CDefHandler(); diff --git a/client/CDefHandler.h b/client/CDefHandler.h index 7bac7a388..a1c6f5706 100644 --- a/client/CDefHandler.h +++ b/client/CDefHandler.h @@ -1,7 +1,6 @@ -#ifndef __CDEFHANDLER_H__ -#define __CDEFHANDLER_H__ +#pragma once + -#include "../global.h" struct SDL_Surface; struct BMPPalette; @@ -30,7 +29,7 @@ struct SDefEntryBlock { ui32 totalInBlock; ui32 unknown2; ui32 unknown3; - unsigned char data[0]; + ui8 data[0]; }; // Def entry in file. Integer fields are all little endian and will @@ -42,9 +41,9 @@ struct SDefEntry { ui32 totalBlocks; struct { - unsigned char R; - unsigned char G; - unsigned char B; + ui8 R; + ui8 G; + ui8 B; } palette[256]; // SDefEntry is followed by a series of SDefEntryBlock @@ -75,9 +74,9 @@ public: class CDefHandler { private: - unsigned int DEFType; + ui32 DEFType; int length; - //unsigned int * RWEntries; + //ui32 * RWEntries; struct SEntry { std::string name; @@ -94,15 +93,11 @@ public: CDefHandler(); //c-tor ~CDefHandler(); //d-tor - SDL_Surface * getSprite (int SIndex, const unsigned char * FDef, const BMPPalette * palette) const; //saves picture with given number to "testtt.bmp" - static void expand(unsigned char N,unsigned char & BL, unsigned char & BR); - void openFromMemory(unsigned char * table, const std::string & name); + SDL_Surface * getSprite (int SIndex, const ui8 * FDef, const BMPPalette * palette) const; //saves picture with given number to "testtt.bmp" + static void expand(ui8 N,ui8 & BL, ui8 & BR); + void openFromMemory(ui8 * table, const std::string & name); CDefEssential * essentialize(); static CDefHandler * giveDef(const std::string & defName); static CDefEssential * giveDefEss(const std::string & defName); }; - - - -#endif // __CDEFHANDLER_H__ diff --git a/client/CGameInfo.cpp b/client/CGameInfo.cpp index f929cedaf..e2fb7c2a0 100644 --- a/client/CGameInfo.cpp +++ b/client/CGameInfo.cpp @@ -1,5 +1,6 @@ -#include "../stdafx.h" +#include "StdInc.h" #include "CGameInfo.h" + #include "../lib/VCMI_Lib.h" /* diff --git a/client/CGameInfo.h b/client/CGameInfo.h index c24d98f29..1b945fd43 100644 --- a/client/CGameInfo.h +++ b/client/CGameInfo.h @@ -1,9 +1,8 @@ -#ifndef __CGAMEINFO_H__ -#define __CGAMEINFO_H__ -#include "../global.h" -#include "../lib/ConstTransitivePtr.h" +#pragma once +#include "../lib/ConstTransitivePtr.h" + /* * CGameInfo.h, part of VCMI engine * @@ -42,6 +41,7 @@ public: CCursorHandler * curh; IMainVideoPlayer * videoh; }; +extern CClientState * CCS; struct Mapa; @@ -70,13 +70,4 @@ public: CGameInfo(); }; - -// -// public: -// -// ConstTransitivePtr generaltexth; - - - - -#endif // __CGAMEINFO_H__ +extern const CGameInfo* CGI; diff --git a/client/CHeroWindow.cpp b/client/CHeroWindow.cpp index 8e714107f..778acfefe 100644 --- a/client/CHeroWindow.cpp +++ b/client/CHeroWindow.cpp @@ -1,4 +1,5 @@ -#include "../stdafx.h" +#include "StdInc.h" + #include "AdventureMapButton.h" #include "CAdvmapInterface.h" #include "../CCallback.h" @@ -13,21 +14,13 @@ #include "CSpellWindow.h" #include "CConfigHandler.h" #include "CPlayerInterface.h" -#include "../global.h" + #include "../lib/CArtHandler.h" #include "CDefHandler.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CLodHandler.h" #include "../lib/CObjectHandler.h" -#include -#include -#include -#include -#include -#include -#include -#include #undef min @@ -131,7 +124,7 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero) //areas portraitArea = new LRClickableAreaWText(Rect(18, 18, 58, 64)); - for(int v=0; vtext = CGI->generaltexth->arraytxt[2+v]; diff --git a/client/CHeroWindow.h b/client/CHeroWindow.h index 46a418bc0..2059b225d 100644 --- a/client/CHeroWindow.h +++ b/client/CHeroWindow.h @@ -1,5 +1,5 @@ -#ifndef __CHEROWINDOW_H__ -#define __CHEROWINDOW_H__ +#pragma once + #include "../lib/HeroBonus.h" @@ -95,5 +95,3 @@ public: friend void CArtPlace::clickLeft(tribool down, bool previousState); friend class CPlayerInterface; }; - -#endif // __CHEROWINDOW_H__ diff --git a/client/CKingdomInterface.cpp b/client/CKingdomInterface.cpp index 73d5ff035..d9f21225b 100644 --- a/client/CKingdomInterface.cpp +++ b/client/CKingdomInterface.cpp @@ -1,11 +1,6 @@ +#include "StdInc.h" #include "CKingdomInterface.h" -#include -#include -#include -#include -#include - #include "../CCallback.h" #include "../lib/CCreatureHandler.h" //creatures name for objects list #include "../lib/CGeneralTextHandler.h" @@ -472,7 +467,7 @@ CKingdomInterface::CKingdomInterface() background = new CPicture(conf.go()->ac.overviewBg); background->colorize(LOCPLINT->playerID); pos = background->center(); - unsigned int footerPos = conf.go()->ac.overviewSize * 116; + ui32 footerPos = conf.go()->ac.overviewSize * 116; tabArea = new CTabbedInt(boost::bind(&CKingdomInterface::createMainTab, this, _1), CTabbedInt::DestroyFunc(), Point(4,4)); @@ -487,7 +482,7 @@ CKingdomInterface::CKingdomInterface() void CKingdomInterface::generateObjectsList(const std::vector &ownedObjects) { - unsigned int footerPos = conf.go()->ac.overviewSize * 116; + ui32 footerPos = conf.go()->ac.overviewSize * 116; size_t dwellSize = (footerPos - 64)/57; //Map used to determine image number for several objects @@ -563,8 +558,8 @@ CIntObject * CKingdomInterface::createMainTab(size_t index) void CKingdomInterface::generateMinesList(const std::vector &ownedObjects) { - unsigned int footerPos = conf.go()->ac.overviewSize * 116; - std::vector minesCount(RESOURCE_QUANTITY, 0); + ui32 footerPos = conf.go()->ac.overviewSize * 116; + std::vector minesCount(GameConstants::RESOURCE_QUANTITY, 0); int totalIncome=0; BOOST_FOREACH(const CGObjectInstance * object, ownedObjects) @@ -609,7 +604,7 @@ void CKingdomInterface::generateMinesList(const std::vectorac.overviewSize * 116; + ui32 footerPos = conf.go()->ac.overviewSize * 116; //Main control buttons btnHeroes = new AdventureMapButton (CGI->generaltexth->overview[11], CGI->generaltexth->overview[6], @@ -692,8 +687,8 @@ CKingdHeroList::CKingdHeroList(size_t maxSize) heroLabel = new CLabel(150, 10, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[0]); skillsLabel = new CLabel(500, 10, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[1]); - unsigned int townCount = LOCPLINT->cb->howManyHeroes(false); - unsigned int size = conf.go()->ac.overviewSize*116 + 19; + ui32 townCount = LOCPLINT->cb->howManyHeroes(false); + ui32 size = conf.go()->ac.overviewSize*116 + 19; heroes = new CListBox(boost::bind(&CKingdHeroList::createHeroItem, this, _1), boost::bind(&CKingdHeroList::destroyHeroItem, this, _1), Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) ); } @@ -710,7 +705,7 @@ void CKingdHeroList::updateGarrisons() CIntObject* CKingdHeroList::createHeroItem(size_t index) { - unsigned int picCount = conf.go()->ac.overviewPics; + ui32 picCount = conf.go()->ac.overviewPics; size_t heroesCount = LOCPLINT->cb->howManyHeroes(false); if (index < heroesCount) @@ -745,8 +740,8 @@ CKingdTownList::CKingdTownList(size_t maxSize) garrHeroLabel = new CLabel(375,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[4]); visitHeroLabel = new CLabel(608,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[5]); - unsigned int townCount = LOCPLINT->cb->howManyTowns(); - unsigned int size = conf.go()->ac.overviewSize*116 + 19; + ui32 townCount = LOCPLINT->cb->howManyTowns(); + ui32 size = conf.go()->ac.overviewSize*116 + 19; towns = new CListBox(boost::bind(&CKingdTownList::createTownItem, this, _1), CListBox::DestroyFunc(), Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) ); } @@ -774,7 +769,7 @@ void CKingdTownList::updateGarrisons() CIntObject* CKingdTownList::createTownItem(size_t index) { - unsigned int picCount = conf.go()->ac.overviewPics; + ui32 picCount = conf.go()->ac.overviewPics; size_t townsCount = LOCPLINT->cb->howManyTowns(); if (index < townsCount) @@ -799,9 +794,9 @@ CTownItem::CTownItem(const CGTownInstance* Town): size_t iconIndex = town->subID*2; if (!town->hasFort()) - iconIndex += F_NUMBER*2; + iconIndex += GameConstants::F_NUMBER*2; - if(town->builded >= MAX_BUILDING_PER_TURN) + if(town->builded >= GameConstants::MAX_BUILDING_PER_TURN) iconIndex++; picture = new CAnimImage("ITPT", iconIndex, 0, 5, 6); @@ -929,11 +924,11 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart * name = new CLabel(73, 7, FONT_SMALL, TOPLEFT, zwykly, hero->name); artsText = new CLabel(320, 55, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->overview[2]); - for (size_t i=0; i #include "GUIBase.h" #include "GUIClasses.h" @@ -202,7 +199,7 @@ private: struct OwnedObjectInfo { int imageID; - unsigned int count; + ui32 count; std::string hoverText; }; std::vector objects; diff --git a/client/CMT.cpp b/client/CMT.cpp index 89a38795a..5f4a9871c 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -1,23 +1,16 @@ // CMT.cpp : Defines the entry point for the console application. // -#include "../stdafx.h" -#include -#include -#include -#include -#include -#include +#include "StdInc.h" #include -#include #include #include "SDL_Extensions.h" #include "SDL_framerate.h" #include "CGameInfo.h" #include "mapHandler.h" -#include "../global.h" + #include "CPreGame.h" #include "CCastleInterface.h" -#include "../CConsoleHandler.h" +#include "../lib/CConsoleHandler.h" #include "CCursorHandler.h" #include "../lib/CGameState.h" #include "../CCallback.h" @@ -39,18 +32,16 @@ #include "../lib/Connection.h" #include "../lib/VCMI_Lib.h" #include "../lib/VCMIDirs.h" -#include #include "../lib/NetPacks.h" #include "CMessage.h" #include "../lib/CObjectHandler.h" -#include #include "../lib/CArtHandler.h" #include "../lib/CScriptingModule.h" +#include "../lib/GameConstants.h" #ifdef _WIN32 #include "SDL_syswm.h" #endif -#include #include "../lib/CDefObjInfoHandler.h" #if __MINGW32__ @@ -70,7 +61,7 @@ namespace po = boost::program_options; */ std::string NAME_AFFIX = "client"; -std::string NAME = NAME_VER + std::string(" (") + NAME_AFFIX + ')'; //application name +std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name CGuiHandler GH; static CClient *client; SDL_Surface *screen = NULL, //main screen surface @@ -104,14 +95,14 @@ void startGame(StartInfo * options, CConnection *serv = NULL); void init() { - timeHandler tmh, pomtime; + StopWatch tmh, pomtime; #if SDL_BYTEORDER == SDL_BIG_ENDIAN int rmask = 0xff000000;int gmask = 0x00ff0000;int bmask = 0x0000ff00;int amask = 0x000000ff; #else int rmask = 0x000000ff; int gmask = 0x0000ff00; int bmask = 0x00ff0000; int amask = 0xff000000; #endif CSDL_Ext::std32bppSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 32, rmask, gmask, bmask, amask); - tlog0 << "\tInitializing minors: " << pomtime.getDif() << std::endl; + tlog0 << "\tInitializing minors: " << pomtime.getDiff() << std::endl; { //read system options CLoadFile settings(GVCMIDirs.UserPath + "/config/sysopts.bin", 727); @@ -128,7 +119,7 @@ void init() GDefaultOptions.settingsChanged(); } } - THC tlog0<<"\tLoading default system settings: "<musich = new CMusicHandler; CCS->musich->init(); CCS->musich->setVolume(GDefaultOptions.musicVolume); - tlog0<<"\tInitializing sound: "<(CGI)->setFromLib(); CCS->soundh->initCreaturesSounds(CGI->creh->creatures); CCS->soundh->initSpellsSounds(CGI->spellh->spells); - tlog0<<"Initializing VCMI_Lib: "<curh = new CCursorHandler; CCS->curh->initCursor(); CCS->curh->show(); - tlog0<<"Screen handler: "<loadHeroAnims(); - tlog0<<"\tMain graphics: "<cb = boost::bind(&processCommand, _1); console->start(); atexit(dispose); - tlog0 <<"Creating console and logfile: "< cannot load 32-bit DLLs for video handling @@ -263,7 +254,7 @@ int main(int argc, char** argv) #else CCS->videoh = new CVideoPlayer; #endif - tlog0<<"\tInitializing video: "<init(std::string(DATA_DIR "/Data/H3bitmap.lod"),""); + txth->init(GameConstants::DATA_DIR + "/Data/H3bitmap.lod",""); tlog0<<"done.\nScanning .lod file\n"; BOOST_FOREACH(Entry e, txth->entries) @@ -543,8 +534,8 @@ void dispose() static void setScreenRes(int w, int h, int bpp, bool fullscreen) { // VCMI will only work with 2, 3 or 4 bytes per pixel - amax(bpp, 16); - amin(bpp, 32); + vstd::amax(bpp, 16); + vstd::amin(bpp, 32); // Try to use the best screen depth for the display int suggestedBpp = SDL_VideoModeOK(w, h, bpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0)); diff --git a/client/CMessage.cpp b/client/CMessage.cpp index bca0f3613..e479fc02c 100644 --- a/client/CMessage.cpp +++ b/client/CMessage.cpp @@ -1,14 +1,12 @@ -#include "../stdafx.h" +#include "StdInc.h" #include "CMessage.h" + #include "SDL_ttf.h" #include "CDefHandler.h" #include "CAnimation.h" #include "CGameInfo.h" #include "SDL_Extensions.h" #include "../lib/CLodHandler.h" -#include -#include -#include #include "../lib/CGeneralTextHandler.h" #include "Graphics.h" #include "GUIClasses.h" @@ -59,8 +57,8 @@ namespace NMessage void CMessage::init() { { - piecesOfBox.resize(PLAYER_LIMIT); - for (int i=0;i CMessage::breakText( std::string text, size_t maxLineSi while (text.length()) { - unsigned int lineLength = 0; //in characters or given char metric - unsigned int z = 0; //our position in text + ui32 lineLength = 0; //in characters or given char metric + ui32 z = 0; //our position in text bool opened = false;//if we have an unclosed brace in current line bool lineManuallyBroken = false; @@ -153,10 +151,10 @@ std::vector CMessage::breakText( std::string text, size_t maxLineSi * possible. We backtrack on the line until we find a * suitable character. * Note: Cyrillic symbols have indexes 220-255 so we need - * to use unsigned char for comparison + * to use ui8 for comparison */ int pos = z-1; - while(pos > 0 && ((unsigned char)text[pos]) > ' ' ) + while(pos > 0 && ((ui8)text[pos]) > ' ' ) pos --; if (pos > 0) @@ -341,10 +339,10 @@ std::vector > * CMessage::drawText(std::vectorpos.x = GH.current->motion.x - ret->pos.w/2; // ret->pos.y = GH.current->motion.y - ret->pos.h/2; // // Put the window back on screen if necessary -// amax(ret->pos.x, 0); -// amax(ret->pos.y, 0); -// amin(ret->pos.x, conf.cc.resx - ret->pos.w); -// amin(ret->pos.y, conf.cc.resy - ret->pos.h); +// vstd::amax(ret->pos.x, 0); +// vstd::amax(ret->pos.y, 0); +// vstd::amin(ret->pos.x, conf.cc.resx - ret->pos.w); +// vstd::amin(ret->pos.y, conf.cc.resy - ret->pos.h); // } // else // { @@ -394,6 +392,7 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player) _or = FNT_RenderText(FONT_MEDIUM,CGI->generaltexth->allTexts[4],zwykly); const int sizes[][2] = {{400, 125}, {500, 150}, {600, 200}, {480, 400}}; + for(int i = 0; i < ARRAY_COUNT(sizes) && sizes[i][0] < conf.cc.resx - 150 @@ -425,12 +424,12 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player) } // Clip window size - amax(winSize.second, 50); - amax(winSize.first, 80); - amax(winSize.first, comps.w); - amax(winSize.first, bw); + vstd::amax(winSize.second, 50); + vstd::amax(winSize.first, 80); + vstd::amax(winSize.first, comps.w); + vstd::amax(winSize.first, bw); - amin(winSize.first, conf.cc.resx - 150); + vstd::amin(winSize.first, conf.cc.resx - 150); ret->bitmap = drawBox1 (winSize.first + 2*SIDE_MARGIN, winSize.second + 2*SIDE_MARGIN, player); ret->pos.h=ret->bitmap->h; @@ -596,14 +595,14 @@ ComponentsToBlit::ComponentsToBlit(std::vector & SComps, int maxw, if (curw + toadd > maxw) { curr++; - amax(w,curw); + vstd::amax(w,curw); curw = cur->comp->pos.w; comps.resize(curr+1); } else { curw += toadd; - amax(w,curw); + vstd::amax(w,curw); } comps[curr].push_back(cur); @@ -613,7 +612,7 @@ ComponentsToBlit::ComponentsToBlit(std::vector & SComps, int maxw, { int maxh = 0; for(size_t j=0;jcomp->pos.h); + vstd::amax(maxh,comps[i][j]->comp->pos.h); h += maxh + BETWEEN_COMPS_ROWS; } } @@ -627,7 +626,7 @@ void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh, { ComponentResolved *cur = (comps)[i][j]; totalw += cur->comp->pos.w; - amax(maxh,cur->comp->getImg()->h);//subtitles height will added later + vstd::amax(maxh,cur->comp->getImg()->h);//subtitles height will added later } if(_or) { @@ -670,7 +669,7 @@ void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh, } curw+=inter; } - amax(curh, textY); + vstd::amax(curh, textY); } curh += BETWEEN_COMPS_ROWS; } diff --git a/client/CMessage.h b/client/CMessage.h index 2af7423d4..d43fd034f 100644 --- a/client/CMessage.h +++ b/client/CMessage.h @@ -1,10 +1,7 @@ -#ifndef __CMESSAGE_H__ -#define __CMESSAGE_H__ +#pragma once #include "FontBase.h" -#include "../global.h" -//#include -#include + /* * CMessage.h, part of VCMI engine @@ -74,8 +71,3 @@ public: static void init(); static void dispose(); }; -// - - - -#endif // __CMESSAGE_H__ diff --git a/client/CMusicBase.h b/client/CMusicBase.h index dfa46bb8a..6dc6eb214 100644 --- a/client/CMusicBase.h +++ b/client/CMusicBase.h @@ -1,5 +1,4 @@ -#ifndef __CMUSICBASE_H__ -#define __CMUSICBASE_H__ +#pragma once /* * CMusicBase.h, part of VCMI engine @@ -87,6 +86,4 @@ public: #undef VCMI_MUSIC_FILE }; -#endif // __CMUSICBASE_H__ - diff --git a/client/CMusicHandler.cpp b/client/CMusicHandler.cpp index 3f07c6bfd..c5aec4b8d 100644 --- a/client/CMusicHandler.cpp +++ b/client/CMusicHandler.cpp @@ -1,11 +1,5 @@ -#include "../stdafx.h" - -#include -#include -#include +#include "StdInc.h" #include -#include - #include #include "CSndHandler.h" @@ -14,6 +8,7 @@ #include "../lib/CSpellHandler.h" #include "../client/CGameInfo.h" #include "../lib/JsonNode.h" +#include "../lib/GameConstants.h" /* * CMusicHandler.cpp, part of VCMI engine @@ -63,7 +58,7 @@ void CAudioBase::release() } } -void CAudioBase::setVolume(unsigned int percent) +void CAudioBase::setVolume(ui32 percent) { if (percent > 100) percent = 100; @@ -103,9 +98,9 @@ void CSoundHandler::init() if (initialized) { // Load sounds - sndh.add_file(std::string(DATA_DIR "/Data/Heroes3.snd")); - sndh.add_file(std::string(DATA_DIR "/Data/Heroes3-cd2.snd"), false); - sndh.add_file(std::string(DATA_DIR "/Data/H3ab_ahd.snd")); + sndh.add_file(std::string(GameConstants::DATA_DIR + "/Data/Heroes3.snd")); + sndh.add_file(std::string(GameConstants::DATA_DIR + "/Data/Heroes3-cd2.snd"), false); + sndh.add_file(std::string(GameConstants::DATA_DIR + "/Data/H3ab_ahd.snd")); Mix_ChannelFinished(soundFinishedCallbackC); } } @@ -172,7 +167,7 @@ soundBase::soundID CSoundHandler::getSoundID(const std::string &fileName) void CSoundHandler::initCreaturesSounds(const std::vector > &creatures) { tlog5 << "\t\tReading config/cr_sounds.json" << std::endl; - const JsonNode config(DATA_DIR "/config/cr_sounds.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/cr_sounds.json"); CBattleSounds.resize(creatures.size()); @@ -215,7 +210,7 @@ void CSoundHandler::initCreaturesSounds(const std::vector > &spells) { - const JsonNode config(DATA_DIR "/config/sp_sounds.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/sp_sounds.json"); if (!config["spell_sounds"].isNull()) { BOOST_FOREACH(const JsonNode &node, config["spell_sounds"].Vector()) { @@ -283,7 +278,7 @@ void CSoundHandler::stopSound( int handler ) } // Sets the sound volume, from 0 (mute) to 100 -void CSoundHandler::setVolume(unsigned int percent) +void CSoundHandler::setVolume(ui32 percent) { CAudioBase::setVolume(percent); @@ -420,7 +415,7 @@ void CMusicHandler::stopMusic(int fade_ms) } // Sets the music volume, from 0 (mute) to 100 -void CMusicHandler::setVolume(unsigned int percent) +void CMusicHandler::setVolume(ui32 percent) { CAudioBase::setVolume(percent); @@ -477,7 +472,7 @@ MusicEntry::~MusicEntry() void MusicEntry::load(musicBase::musicID ID) { currentID = ID; - filename = DATA_DIR "/Mp3/"; + filename = GameConstants::DATA_DIR + "/Mp3/"; filename += owner->musics[ID]; tlog5<<"Loading music file "< -#include - -#include +#pragma once #include "CSoundBase.h" #include "CMusicBase.h" @@ -62,8 +56,8 @@ public: virtual void init() = 0; virtual void release() = 0; - virtual void setVolume(unsigned int percent); - unsigned int getVolume() { return volume; }; + virtual void setVolume(ui32 percent); + ui32 getVolume() { return volume; }; }; class CSoundHandler: public CAudioBase @@ -88,7 +82,7 @@ public: void initCreaturesSounds(const std::vector > &creatures); void initSpellsSounds(const std::vector< ConstTransitivePtr > &spells); - void setVolume(unsigned int percent); + void setVolume(ui32 percent); // Sounds int playSound(soundBase::soundID soundID, int repeats=0); @@ -153,7 +147,7 @@ public: void init(); void release(); - void setVolume(unsigned int percent); + void setVolume(ui32 percent); // Musics std::map musics; @@ -167,5 +161,3 @@ public: void stopMusic(int fade_ms=1000); void musicFinishedCallback(void); }; - -#endif // __CMUSICHANDLER_H__ diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 0674fcc84..b34c91c99 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1,6 +1,8 @@ -#include "../stdafx.h" +#include "StdInc.h" + #include "CAdvmapInterface.h" -#include "CBattleInterface.h" +#include "BattleInterface/CBattleInterface.h" +#include "BattleInterface/CBattleConsole.h" #include "../CCallback.h" #include "CCastleInterface.h" #include "CCursorHandler.h" @@ -30,22 +32,10 @@ #include "../lib/map.h" #include "../lib/VCMIDirs.h" #include "mapHandler.h" -#include "../timeHandler.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../StartInfo.h" -#include +#include "../lib/StopWatch.h" +#include "../lib/StartInfo.h" #include "../lib/CGameState.h" +#include "../lib/GameConstants.h" #ifdef min #undef min @@ -116,7 +106,7 @@ CPlayerInterface::~CPlayerInterface() { howManyPeople--; //delete pim; - //delNull(pim); + //vstd::clear_pointer(pim); delete showingDialog; if(adventureInt) { @@ -383,14 +373,14 @@ SDL_Surface * CPlayerInterface::infoWin(const CGObjectInstance * specific) //spe switch(specific->ID) { - case HEROI_TYPE: + case GameConstants::HEROI_TYPE: { InfoAboutHero iah; bool gotInfo = LOCPLINT->cb->getHeroInfo(specific, iah); assert(gotInfo); return graphics->drawHeroInfoWin(iah); } - case TOWNI_TYPE: + case GameConstants::TOWNI_TYPE: case 33: // Garrison case 219: { @@ -424,7 +414,7 @@ void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int if(CAltarWindow *ctw = dynamic_cast(GH.topInt())) ctw->setExpToLevel(); } - else if(which < PRIMARY_SKILLS) //no need to redraw infowin if this is experience (exp is treated as prim skill with id==4) + else if(which < GameConstants::PRIMARY_SKILLS) //no need to redraw infowin if this is experience (exp is treated as prim skill with id==4) updateInfo(hero); } @@ -729,7 +719,7 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i { boost::unique_lock un(*pim); - if(vstd::contains(stack->state,MOVED)) //this stack has moved and makes second action -> high morale + if(vstd::contains(stack->state,EBattleStackState::MOVED)) //this stack has moved and makes second action -> high morale { std::string hlp = CGI->generaltexth->allTexts[33]; boost::algorithm::replace_first(hlp,"%s",(stack->count != 1) ? stack->getCreature()->namePl : stack->getCreature()->nameSing); @@ -765,7 +755,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br) battleInt->battleFinished(*br); } -void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector dest, int distance) +void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector dest, int distance) { if(LOCPLINT != this) { //another local interface should do this @@ -883,10 +873,10 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba) else { int shift = 0; - if(ba->counter() && THex::mutualPosition(curAction->destinationTile, attacker->position) < 0) + if(ba->counter() && SHexField::mutualPosition(curAction->destinationTile, attacker->position) < 0) { - int distp = THex::getDistance(curAction->destinationTile + 1, attacker->position); - int distm = THex::getDistance(curAction->destinationTile - 1, attacker->position); + int distp = SHexField::getDistance(curAction->destinationTile + 1, attacker->position); + int distm = SHexField::getDistance(curAction->destinationTile - 1, attacker->position); if( distp < distm ) shift = 1; @@ -1339,7 +1329,7 @@ void CPlayerInterface::objectPropertyChanged(const SetObjectProperty * sop) adventureInt->minimap.showTile(*it); } - if(obj->ID == TOWNI_TYPE) + if(obj->ID == GameConstants::TOWNI_TYPE) { if(obj->tempOwner == playerID) towns.push_back(static_cast(obj)); @@ -1360,7 +1350,7 @@ void CPlayerInterface::recreateHeroTownList() //applying current heroes order to new heroes info int j; for (int i = 0; i < wanderingHeroes.size(); i++) - if ((j = vstd::findPos(allHeroes, wanderingHeroes[i])) >= 0) + if ((j = vstd::find_pos(allHeroes, wanderingHeroes[i])) >= 0) if (!allHeroes[j]->inTownGarrison) { newWanderingHeroes += allHeroes[j]; @@ -1377,7 +1367,7 @@ void CPlayerInterface::recreateHeroTownList() std::vector newTowns; std::vector allTowns = cb->getTownsInfo(); for (int i = 0; i < towns.size(); i++) - if ((j = vstd::findPos(allTowns, towns[i])) >= 0) + if ((j = vstd::find_pos(allTowns, towns[i])) >= 0) { newTowns += allTowns[j]; allTowns -= allTowns[j]; @@ -1456,7 +1446,7 @@ void CPlayerInterface::centerView (int3 pos, int focusTime) void CPlayerInterface::objectRemoved( const CGObjectInstance *obj ) { - if(obj->ID == HEROI_TYPE && obj->tempOwner == playerID) + if(obj->ID == GameConstants::HEROI_TYPE && obj->tempOwner == playerID) { const CGHeroInstance *h = static_cast(obj); heroKilled(h); @@ -2019,7 +2009,7 @@ void CPlayerInterface::showPuzzleMap() boost::unique_lock un(*pim); //TODO: interface should not know the real position of Grail... - float ratio = 0; + double ratio = 0; int3 grailPos = cb->getGrailPos(ratio); GH.pushInt(new CPuzzleWindow(grailPos, ratio)); @@ -2230,11 +2220,11 @@ void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInsta boost::unique_lock un(*pim); if(market->o->ID == 2) //Altar { - //EMarketMode mode = market->availableModes().front(); - if(market->allowsTrade(ARTIFACT_EXP) && visitor->getAlignment() != EVIL) - GH.pushInt(new CAltarWindow(market, visitor, ARTIFACT_EXP)); - else if(market->allowsTrade(CREATURE_EXP) && visitor->getAlignment() != GOOD) - GH.pushInt(new CAltarWindow(market, visitor, CREATURE_EXP)); + //EEMarketMode mode = market->availableModes().front(); + if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL) + GH.pushInt(new CAltarWindow(market, visitor, EMarketMode::ARTIFACT_EXP)); + else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD) + GH.pushInt(new CAltarWindow(market, visitor, EMarketMode::CREATURE_EXP)); } else GH.pushInt(new CMarketplaceWindow(market, visitor, market->availableModes().front())); diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index db4473bb6..933bbf2a7 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -1,13 +1,10 @@ -#ifndef __CPLAYERINTERFACE_H__ -#define __CPLAYERINTERFACE_H__ -#include "../global.h" -#include "../lib/CGameInterface.h" +#pragma once + + #include "../lib/CondSh.h" -#include -#include -#include #include "GUIBase.h" #include "FunctionList.h" +#include "../lib/CGameInterface.h" #ifdef __GNUC__ #define sprintf_s snprintf @@ -221,7 +218,7 @@ public: void battleEnd(const BattleResult *br) OVERRIDE; //end of battle void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied; used for HP regen handling void battleNewRound(int round) OVERRIDE; //called at the beginning of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn - void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE; + void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE; void battleSpellCast(const BattleSpellCast *sc) OVERRIDE; void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE; //called when a specific effect is set to stacks void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE; //various one-shot effect @@ -278,6 +275,3 @@ public: }; extern CPlayerInterface * LOCPLINT; - - -#endif // __CPLAYERINTERFACE_H__ diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index bb61de2b3..f6c9e0d4c 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -1,11 +1,8 @@ -#include "../stdafx.h" +#include "StdInc.h" #include "CPreGame.h" -#include -#include // includes all needed Boost.Filesystem declarations -#include + #include -#include "../timeHandler.h" -#include +#include "../lib/StopWatch.h" #include "SDL_Extensions.h" #include "CGameInfo.h" #include "CCursorHandler.h" @@ -22,17 +19,7 @@ #include "../lib/JsonNode.h" #include "CMusicHandler.h" #include "CVideoHandler.h" -#include #include "Graphics.h" -//#include -#include -#include -#include -#include -#include -#include - -#include #include "../lib/Connection.h" #include "../lib/VCMIDirs.h" #include "../lib/map.h" @@ -40,8 +27,6 @@ #include "GUIClasses.h" #include "CPlayerInterface.h" #include "../CCallback.h" -#include -#include #include "CMessage.h" #include "../lib/CSpellHandler.h" /*for campaign bonuses*/ #include "../lib/CArtHandler.h" /*for campaign bonuses*/ @@ -49,11 +34,11 @@ #include "CBitmapHandler.h" #include "Client.h" #include "../lib/NetPacks.h" -#include "../lib/RegisterTypes.cpp" -#include -#include "../CThreadHelper.h" +#include "../lib/RegisterTypes.h" +#include "../lib/CThreadHelper.h" #include "CConfigHandler.h" #include "../lib/CFileUtility.h" +#include "../lib/GameConstants.h" /* * CPreGame.cpp, part of VCMI engine @@ -93,8 +78,8 @@ struct EvilHlpStruct { if(strong) { - delNull(serv); - delNull(sInfo); + vstd::clear_pointer(serv); + vstd::clear_pointer(sInfo); } else { @@ -160,7 +145,7 @@ void updateStartInfo(std::string filename, StartInfo & sInfo, const CMapHeader * std::map::const_iterator namesIt = playerNames.begin(); - for (int i = 0; i < PLAYER_LIMIT; i++) + for (int i = 0; i < GameConstants::PLAYER_LIMIT; i++) { const PlayerInfo &pinfo = mapHeader->players[i]; @@ -410,7 +395,7 @@ void CreditsScreen::clickRight(tribool down, bool previousState) } CGPreGame::CGPreGame(): - pregameConfig(new JsonNode(DATA_DIR "/config/mainmenu.json")) + pregameConfig(new JsonNode(GameConstants::DATA_DIR + "/config/mainmenu.json")) { OBJ_CONSTRUCTION_CAPTURING_ALL; GH.defActionsDef = 63; @@ -672,7 +657,7 @@ CSelectionScreen::~CSelectionScreen() playerNames.clear(); assert(!serv); - delNull(applier); + vstd::clear_pointer(applier); delete mx; } @@ -713,7 +698,7 @@ void CSelectionScreen::changeSelection( const CMapInfo *to ) { if(multiPlayer == CMenuScreen::MULTI_NETWORK_GUEST) { - delNull(current); + vstd::clear_pointer(current); } current = to; @@ -981,7 +966,7 @@ void SelectionTab::getFiles(std::vector &out, const std::string &dirna void SelectionTab::parseMaps(std::vector &files, int start, int threads) { int read=0; - unsigned char mapBuffer[1500]; + ui8 mapBuffer[1500]; while(start < allItems.size()) { @@ -1080,11 +1065,11 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::functionvalue; - amax(py, 0); - amin(py, curItems.size()-1); + vstd::amax(py, 0); + vstd::amin(py, curItems.size()-1); selectionPos = py; @@ -1337,14 +1322,14 @@ void SelectionTab::printMaps(SDL_Surface *to) blitAt(format->ourImages[temp].bitmap, POS(88, 117), to); //victory conditions - if (currentItem->mapHeader->victoryCondition.condition == winStandard) + if (currentItem->mapHeader->victoryCondition.condition == EVictoryConditionType::WINSTANDARD) temp = 11; else temp = currentItem->mapHeader->victoryCondition.condition; blitAt(CGP->victory->ourImages[temp].bitmap, POS(306, 117), to); //loss conditions - if (currentItem->mapHeader->lossCondition.typeOfLossCon == lossStandard) + if (currentItem->mapHeader->lossCondition.typeOfLossCon == ELossConditionType::LOSSSTANDARD) temp=3; else temp=currentItem->mapHeader->lossCondition.typeOfLossCon; @@ -1784,7 +1769,7 @@ void InfoCard::showTeamsPopup() hlp.replace(hlp.find("%d"), 2, boost::lexical_cast(i+1)); CSDL_Ext::printAtMiddle(hlp, 128, 65 + 50*i, FONT_SMALL, zwykly, bmp); - for(int j = 0; j < PLAYER_LIMIT; j++) + for(int j = 0; j < GameConstants::PLAYER_LIMIT; j++) if((SEL->current->mapHeader->players[j].canHumanPlay || SEL->current->mapHeader->players[j].canComputerPlay) && SEL->current->mapHeader->players[j].team == i) flags.push_back(j); @@ -1876,8 +1861,8 @@ void OptionsTab::nextCastle( int player, int dir ) if (cur == -1) //random => first/last available { - int pom = (dir>0) ? (0) : (F_NUMBER-1); // last or first - for (;pom >= 0 && pom < F_NUMBER; pom+=dir) + int pom = (dir>0) ? (0) : (GameConstants::F_NUMBER-1); // last or first + for (;pom >= 0 && pom < GameConstants::F_NUMBER; pom+=dir) { if((1 << pom) & allowed) { @@ -1894,9 +1879,9 @@ void OptionsTab::nextCastle( int player, int dir ) if ((1 << cur) & allowed) break; - if (cur >= F_NUMBER || cur<0) + if (cur >= GameConstants::F_NUMBER || cur<0) { - double p1 = log((double)allowed) / log(2.0f)+0.000001f; + double p1 = log((double)allowed) / log(2.0)+0.000001; double check = p1 - ((int)p1); if (check < 0.001) cur = (int)p1; @@ -1933,16 +1918,16 @@ void OptionsTab::nextHero( int player, int dir ) if (s.hero == -1) //random => first/last available { - int max = (s.castle*HEROES_PER_TYPE*2+15), - min = (s.castle*HEROES_PER_TYPE*2); + int max = (s.castle*GameConstants::HEROES_PER_TYPE*2+15), + min = (s.castle*GameConstants::HEROES_PER_TYPE*2); s.hero = nextAllowedHero(min,max,0,dir); } else { if(dir > 0) - s.hero = nextAllowedHero(s.hero,(s.castle*HEROES_PER_TYPE*2+16),1,dir); + s.hero = nextAllowedHero(s.hero,(s.castle*GameConstants::HEROES_PER_TYPE*2+16),1,dir); else - s.hero = nextAllowedHero(s.castle*HEROES_PER_TYPE*2-1,s.hero,1,dir); + s.hero = nextAllowedHero(s.castle*GameConstants::HEROES_PER_TYPE*2-1,s.hero,1,dir); } if(old != s.hero) @@ -2046,7 +2031,7 @@ void OptionsTab::recreate() void OptionsTab::setTurnLength( int npos ) { static const int times[] = {1, 2, 4, 6, 8, 10, 15, 20, 25, 30, 0}; - amin(npos, ARRAY_COUNT(times) - 1); + vstd::amin(npos, ARRAY_COUNT(times) - 1); SEL->sInfo.turnTime = times[npos]; redraw(); @@ -2267,7 +2252,7 @@ SDL_Surface * OptionsTab::SelectedBox::getImg() const switch(which) { case TOWN: - if (s.castle < F_NUMBER && s.castle >= 0) + if (s.castle < GameConstants::F_NUMBER && s.castle >= 0) return graphics->getPic(s.castle, true, false); else if (s.castle == -1) return CGP->rTown; @@ -2323,7 +2308,7 @@ const std::string * OptionsTab::SelectedBox::getText() const switch(which) { case TOWN: - if (s.castle < F_NUMBER && s.castle >= 0) + if (s.castle < GameConstants::F_NUMBER && s.castle >= 0) return &CGI->townh->towns[s.castle].Name(); else if (s.castle == -1) return &CGI->generaltexth->allTexts[522]; @@ -2710,7 +2695,7 @@ void CHotSeatPlayers::enterSelectionScreen() CBonusSelection::CBonusSelection( CCampaignState * _ourCampaign ) : highlightedRegion(NULL), ourCampaign(_ourCampaign), ourHeader(NULL), - diffLb(NULL), diffRb(NULL), bonuses(NULL) + diffLb(NULL), diffRb(NULL), bonuses(NULL) { OBJ_CONSTRUCTION_CAPTURING_ALL; static const std::string bgNames [] = {"E1_BG.BMP", "G2_BG.BMP", "E2_BG.BMP", "G1_BG.BMP", "G3_BG.BMP", "N1_BG.BMP", @@ -2839,7 +2824,7 @@ void CBonusSelection::showAll( SDL_Surface * to ) void CBonusSelection::loadPositionsOfGraphics() { - const JsonNode config(DATA_DIR "/config/campaign_regions.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/campaign_regions.json"); int idx = 0; BOOST_FOREACH(const JsonNode &campaign, config["campaign_regions"].Vector()) @@ -3032,7 +3017,7 @@ void CBonusSelection::updateBonusSelection() int leadingSkill = -1; std::vector > toPrint; //primary skills to be listed const ui8* ptr = reinterpret_cast(&bonDescs[i].info2); - for (int g=0; g ptr[leadingSkill]) { @@ -3349,7 +3334,7 @@ void QuitMenuWithoutStarting::apply(CSelectionScreen *selScreen) GH.popIntTotally(selScreen); //will wait with deleting us before this thread ends } - delNull(selScreen->serv); + vstd::clear_pointer(selScreen->serv); } void PlayerJoined::apply(CSelectionScreen *selScreen) @@ -3467,7 +3452,7 @@ void StartWithCurrentSettings::apply(CSelectionScreen *selScreen) } selScreen->serv = NULL; //hide it so it won't be deleted - delNull(selScreen->serverHandlingThread); //detach us + vstd::clear_pointer(selScreen->serverHandlingThread); //detach us selectedName = selScreen->sInfo.mapname; GH.curInt = NULL; diff --git a/client/CPreGame.h b/client/CPreGame.h index cfa51269e..fa5a8676b 100644 --- a/client/CPreGame.h +++ b/client/CPreGame.h @@ -1,9 +1,8 @@ -#ifndef __CPREGAME_H__ -#define __CPREGAME_H__ -#include "../global.h" -#include +#pragma once + + #include -#include "../StartInfo.h" +#include "../lib/StartInfo.h" #include "GUIBase.h" #include "GUIClasses.h" #include "FunctionList.h" @@ -355,7 +354,7 @@ class CHotSeatPlayers : public CIntObject { CPicture *bg; CTextBox *title; - CTextInput *txt[8]; + CTextInput* txt[8]; AdventureMapButton *ok, *cancel; CGStatusBar *bar; @@ -395,7 +394,7 @@ class CBonusSelection : public CIntObject class CRegion : public CIntObject { CBonusSelection * owner; - SDL_Surface * graphics[3]; //[0] - not selected, [1] - selected, [2] - striped + SDL_Surface* graphics[3]; //[0] - not selected, [1] - selected, [2] - striped bool accessible; //false if region should be striped bool selectable; //true if region should be selectable int myNumber; //number of region @@ -416,7 +415,7 @@ class CBonusSelection : public CIntObject CCampaignState * ourCampaign; CMapHeader *ourHeader; CDefHandler *sizes; //icons of map sizes - SDL_Surface * diffPics[5]; //pictures of difficulties, user-selectable (or not if campaign locks this) + SDL_Surface* diffPics[5]; //pictures of difficulties, user-selectable (or not if campaign locks this) AdventureMapButton * diffLb, * diffRb; //buttons for changing difficulty void changeDiff(bool increase); //if false, then decrease @@ -506,5 +505,3 @@ public: }; extern CGPreGame *CGP; - -#endif // __CPREGAME_H__ diff --git a/client/CSndHandler.cpp b/client/CSndHandler.cpp index 53c1a5f87..a4dc7b8f1 100644 --- a/client/CSndHandler.cpp +++ b/client/CSndHandler.cpp @@ -1,8 +1,7 @@ -#include "../stdafx.h" -#include -#include "CSndHandler.h" +#include "StdInc.h" #include #include +#include "CSndHandler.h" /* * CSndHandler.cpp, part of VCMI engine @@ -153,10 +152,10 @@ void CSndHandler::add_file(std::string fname, bool important /*= true*/) } const char *data = mfile->data(); - unsigned int numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]); + ui32 numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]); struct soundEntry *se = (struct soundEntry *)&data[4]; - for (unsigned int i=0; idata(); - unsigned int numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]); + const ui8 *data = (const ui8 *)mfile->data(); + ui32 numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]); struct videoEntry *ve = (struct videoEntry *)&data[4]; - for (unsigned int i=0; i #include -#include #include @@ -52,8 +49,8 @@ protected: struct Entry { std::string name; - unsigned int size; - unsigned int offset; + ui32 size; + ui32 offset; const char *data; }; @@ -82,7 +79,3 @@ class CVidHandler: public CMediaHandler public: void add_file(std::string fname); }; - - - -#endif // __CSNDHANDLER_H__ diff --git a/client/CSoundBase.h b/client/CSoundBase.h index b2046031e..2f4d44cfb 100644 --- a/client/CSoundBase.h +++ b/client/CSoundBase.h @@ -1,5 +1,4 @@ -#ifndef __CSOUNDBASE_H__ -#define __CSOUNDBASE_H__ +#pragma once // Use some magic to keep the list of files and their code name in sync. @@ -1033,6 +1032,4 @@ public: }; #undef VCMI_SOUND_NAME #undef VCMI_SOUND_FILE -}; - -#endif // __CSOUNDBASE_H__ \ No newline at end of file +}; \ No newline at end of file diff --git a/client/CSpellWindow.cpp b/client/CSpellWindow.cpp index 8980ed9f4..cb8453351 100644 --- a/client/CSpellWindow.cpp +++ b/client/CSpellWindow.cpp @@ -1,4 +1,6 @@ +#include "StdInc.h" #include "CSpellWindow.h" + #include "Graphics.h" #include "CDefHandler.h" #include "../lib/CObjectHandler.h" @@ -6,21 +8,16 @@ #include "../lib/CGeneralTextHandler.h" #include "CVideoHandler.h" #include "CAdvmapInterface.h" -#include "CBattleInterface.h" +#include "BattleInterface/CBattleInterface.h" #include "CGameInfo.h" #include "SDL_Extensions.h" #include "CMessage.h" #include "CPlayerInterface.h" #include "../CCallback.h" -#include -#include -#include -#include -#include -#include #include "CBitmapHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/BattleState.h" +#include "../lib/GameConstants.h" /* * CSpellWindow.cpp, part of VCMI engine @@ -217,7 +214,7 @@ CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * _myHe selectedTab = battleSpellsOnly ? LOCPLINT->spellbookSettings.spellbookLastTabBattle : LOCPLINT->spellbookSettings.spellbookLastTabAdvmap; currentPage = battleSpellsOnly ? LOCPLINT->spellbookSettings.spellbookLastPageBattle : LOCPLINT->spellbookSettings.spellbokLastPageAdvmap; - abetw(currentPage, 0, pagesWithinCurrentTab()); + vstd::abetween(currentPage, 0, pagesWithinCurrentTab()); computeSpellsPerArea(); } @@ -536,11 +533,11 @@ void CSpellWindow::keyPressed(const SDL_KeyboardEvent & key) case SDLK_DOWN: { bool down = key.keysym.sym == SDLK_DOWN; - static const int schoolsOrder[] = {0, 3, 1, 2, 4}; + static const int schoolsOrder[] = { 0, 3, 1, 2, 4 }; int index = -1; while(schoolsOrder[++index] != selectedTab); index += (down ? 1 : -1); - abetw(index, 0, ARRAY_COUNT(schoolsOrder) - 1); + vstd::abetween(index, 0, ARRAY_COUNT(schoolsOrder) - 1); if(selectedTab != schoolsOrder[index]) selectSchool(schoolsOrder[index]); break; @@ -621,23 +618,23 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState) //we will cast a spell if(sp->combatSpell && owner->myInt->battleInt && owner->myInt->cb->battleCanCastSpell()) //if battle window is open { - SpellCasting::ESpellCastProblem problem = owner->myInt->cb->battleCanCastThisSpell(sp); + ESpellCastProblem::ESpellCastProblem problem = owner->myInt->cb->battleCanCastThisSpell(sp); switch (problem) { - case SpellCasting::OK: + case ESpellCastProblem::OK: { int spell = mySpell; owner->fexitb(); owner->myInt->battleInt->castThisSpell(spell); } break; - case SpellCasting::ANOTHER_ELEMENTAL_SUMMONED: + case ESpellCastProblem::ANOTHER_ELEMENTAL_SUMMONED: { std::string text = CGI->generaltexth->allTexts[538], summoner, elemental, caster; std::vector stacks = owner->myInt->cb->battleGetStacks(); BOOST_FOREACH(const CStack * s, stacks) { - if(vstd::contains(s->state, SUMMONED)) + if(vstd::contains(s->state, EBattleStackState::SUMMONED)) { elemental = s->getCreature()->namePl; summoner = owner->myInt->cb->battleGetFightingHero(!s->attackerOwned)->name; @@ -658,14 +655,14 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState) owner->myInt->showInfoDialog(text); } break; - case SpellCasting::SPELL_LEVEL_LIMIT_EXCEEDED: + case ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED: { std::string text = CGI->generaltexth->allTexts[541], caster = owner->myHero->name; text = boost::str(boost::format(text) % caster); owner->myInt->showInfoDialog(text); } break; - case SpellCasting::NO_APPROPRIATE_TARGET: + case ESpellCastProblem::NO_APPROPRIATE_TARGET: { owner->myInt->showInfoDialog(CGI->generaltexth->allTexts[185]); } diff --git a/client/CSpellWindow.h b/client/CSpellWindow.h index 70619b856..d5325b192 100644 --- a/client/CSpellWindow.h +++ b/client/CSpellWindow.h @@ -1,10 +1,7 @@ -#ifndef __CSPELLWINDOW_H__ -#define __CSPELLWINDOW_H__ +#pragma once -#include "../global.h" #include "GUIBase.h" -#include "boost/function.hpp" /* * CSpellWindow.h, part of VCMI engine @@ -114,5 +111,3 @@ public: void teleportTo(int town, const CGHeroInstance * hero); }; - -#endif // __CSPELLWINDOW_H__ diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp index d75007872..0912f7d95 100644 --- a/client/CVideoHandler.cpp +++ b/client/CVideoHandler.cpp @@ -1,11 +1,10 @@ -#include "../stdafx.h" -#include +#include "StdInc.h" +#include #include "CSndHandler.h" #include "CVideoHandler.h" -#include + #include "SDL_Extensions.h" #include "CPlayerInterface.h" -#include extern SystemOptions GDefaultOptions; //reads events and returns true on key down @@ -393,8 +392,8 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update ) CVideoPlayer::CVideoPlayer() { - vidh.add_file(std::string(DATA_DIR "/Data/VIDEO.VID")); - vidh.add_file(std::string(DATA_DIR "/Data/H3ab_ahd.vid")); + vidh.add_file(std::string(GameConstants::DATA_DIR + "/Data/VIDEO.VID")); + vidh.add_file(std::string(GameConstants::DATA_DIR + "/Data/H3ab_ahd.vid")); current = NULL; } @@ -600,11 +599,11 @@ static int lod_close(URLContext* h) } // Define a set of functions to read data -static int lod_read(URLContext *context, unsigned char *buf, int size) +static int lod_read(URLContext *context, ui8 *buf, int size) { CVideoPlayer *video = (CVideoPlayer *)context->priv_data; - amin(size, video->length - video->offset); + vstd::amin(size, video->length - video->offset); if (size < 0) return -1; @@ -617,14 +616,14 @@ static int lod_read(URLContext *context, unsigned char *buf, int size) return size; } -static int64_t lod_seek(URLContext *context, int64_t pos, int whence) +static si64 lod_seek(URLContext *context, si64 pos, int whence) { CVideoPlayer *video = (CVideoPlayer *)context->priv_data; // Not sure what the parameter whence is. Assuming it always // indicates an absolute value; video->offset = pos; - amin(video->offset, video->length); + vstd::amin(video->offset, video->length); return -1;//video->offset; } @@ -659,8 +658,8 @@ CVideoPlayer::CVideoPlayer() av_register_protocol(&lod_protocol); #endif - vidh.add_file(std::string(DATA_DIR "/Data/VIDEO.VID")); - vidh.add_file(std::string(DATA_DIR "/Data/H3ab_ahd.vid")); + vidh.add_file(GameConstants::DATA_DIR + "/Data/VIDEO.VID"); + vidh.add_file(GameConstants::DATA_DIR + "/Data/H3ab_ahd.vid"); } bool CVideoPlayer::open(std::string fname) @@ -699,12 +698,12 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) } else { // File is not in a container #if LIBAVFORMAT_VERSION_MAJOR < 54 - int avfopen = av_open_input_file(&format, (DATA_DIR "/Data/video/" + fname).c_str(), NULL, 0, NULL); + int avfopen = av_open_input_file(&format, (GameConstants::DATA_DIR + "/Data/video/" + fname).c_str(), NULL, 0, NULL); #else - int avfopen = avformat_open_input(&format, (DATA_DIR "/Data/video/" + fname).c_str(), NULL, NULL); + int avfopen = avformat_open_input(&format, (GameConstants::DATA_DIR + "/Data/video/" + fname).c_str(), NULL, NULL); #endif if (avfopen != 0) { - // tlog1 << "Video file not found: " DATA_DIR "/Data/video/" + fname << std::endl; + // tlog1 << "Video file not found: " GameConstants::DATA_DIR + "/Data/video/" + fname << std::endl; return false; } } @@ -715,7 +714,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) // Find the first video stream stream = -1; - for(unsigned int i=0; inb_streams; i++) { + for(ui32 i=0; inb_streams; i++) { #if LIBAVCODEC_VERSION_MAJOR < 53 if (format->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) #else @@ -850,7 +849,7 @@ bool CVideoPlayer::nextFrame() SDL_UnlockYUVOverlay(overlay); } else { - pict.data[0] = (uint8_t *)dest->pixels; + pict.data[0] = (ui8 *)dest->pixels; pict.linesize[0] = dest->pitch; sws_scale(sws, frame->data, frame->linesize, @@ -985,4 +984,4 @@ CVideoPlayer::~CVideoPlayer() close(); } -#endif \ No newline at end of file +#endif diff --git a/client/CVideoHandler.h b/client/CVideoHandler.h index 8ae59aa85..d6daa5d0c 100644 --- a/client/CVideoHandler.h +++ b/client/CVideoHandler.h @@ -1,7 +1,6 @@ -#ifndef __CVIDEOHANDLER_H__ -#define __CVIDEOHANDLER_H__ +#pragma once + -#include "../global.h" #include "CSndHandler.h" struct SDL_Surface; @@ -289,7 +288,7 @@ public: const char *data; // video buffer int length; // video size - unsigned int offset; // current data offset + ui32 offset; // current data offset }; #define VIDEO_TAVERN "tavern.mjpg" @@ -301,5 +300,3 @@ public: #define VIDEO_SURRENDER "surrender.mjpg" #endif - -#endif // __CVIDEOHANDLER_H__ diff --git a/client/Client.cpp b/client/Client.cpp index 039134993..c6b66a0af 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -1,11 +1,13 @@ +#include "StdInc.h" + #include "CMusicHandler.h" #include "../lib/CCampaignHandler.h" #include "../CCallback.h" -#include "../CConsoleHandler.h" +#include "../lib/CConsoleHandler.h" #include "CGameInfo.h" #include "../lib/CGameState.h" #include "CPlayerInterface.h" -#include "../StartInfo.h" +#include "../lib/StartInfo.h" #include "../lib/BattleState.h" #include "../lib/CArtHandler.h" #include "../lib/CDefObjInfoHandler.h" @@ -26,20 +28,12 @@ #include "CConfigHandler.h" #include "Client.h" #include "GUIBase.h" -#include -#include -#include -#include -#include -#include #include "CPreGame.h" -#include "CBattleInterface.h" -#include "../CThreadHelper.h" +#include "BattleInterface/CBattleInterface.h" +#include "../lib/CThreadHelper.h" #include "../lib/CScriptingModule.h" #include "../lib/CFileUtility.h" - -#define NOT_LIB -#include "../lib/RegisterTypes.cpp" +#include "../lib/RegisterTypes.h" extern std::string NAME; namespace intpr = boost::interprocess; @@ -228,7 +222,7 @@ void CClient::loadGame( const std::string & fname ) CServerHandler sh; sh.startServer(); - timeHandler tmh; + StopWatch tmh; { char sig[8]; CMapHeader dum; @@ -237,21 +231,21 @@ void CClient::loadGame( const std::string & fname ) CLoadFile lf(fname + ".vlgm1"); lf >> sig >> dum >> si; - tlog0 <<"Reading save signature: "<> *VLC; const_cast(CGI)->setFromLib(); - tlog0 <<"Reading handlers: "<> gs; - tlog0 <<"Reading gamestate: "<(CGI)->state = gs; const_cast(CGI)->mh->map = gs->map; pathInfo = new CPathsInfo(int3(gs->map->width, gs->map->height, gs->map->twoLevel+1)); CGI->mh->init(); - tlog0 <<"Initing maphandler: "<addStdVecItems(gs); @@ -273,7 +267,7 @@ void CClient::loadGame( const std::string & fname ) *serv << ui8(it->first); //players } *serv << ui8(255); // neutrals - tlog0 <<"Sent info to server: "<(CGI)->state = new CGameState(); - tlog0 <<"\tGamestate: "<> si >> sum >> seed; - tlog0 <<"\tSending/Getting info to/from the server: "<(CGI)->state; gs->scenarioOps = si; gs->init(si, sum, seed); - tlog0 <<"Initializing GameState (together): "<map) { const_cast(CGI)->mh = new CMapHandler(); CGI->mh->map = gs->map; - tlog0 <<"Creating mapHandler: "<mh->init(); pathInfo = new CPathsInfo(int3(gs->map->width, gs->map->height, gs->map->twoLevel+1)); - tlog0 <<"Initializing mapHandler (together): "<serialize(h, version); } - if(!vstd::contains(battleints, NEUTRAL_PLAYER)) + if(!vstd::contains(battleints, GameConstants::NEUTRAL_PLAYER)) loadNeutralBattleAI(); } } @@ -631,7 +625,7 @@ void CServerHandler::startServer() serverThread = new boost::thread(&CServerHandler::callServer, this); //runs server executable; if(verbose) - tlog0 << "Setting up thread calling server: " << th.getDif() << std::endl; + tlog0 << "Setting up thread calling server: " << th.getDiff() << std::endl; } void CServerHandler::waitForServer() @@ -646,7 +640,7 @@ void CServerHandler::waitForServer() shared->sr->cond.wait(slock); } if(verbose) - tlog0 << "Waiting for server: " << th.getDif() << std::endl; + tlog0 << "Waiting for server: " << th.getDiff() << std::endl; } CConnection * CServerHandler::connectToServer() @@ -658,7 +652,7 @@ CConnection * CServerHandler::connectToServer() CConnection *ret = justConnectToServer(conf.cc.server, port); if(verbose) - tlog0<<"\tConnecting to the server: "< " + logName; + std::string comm = GameConstants::BIN_DIR + GameConstants::PATH_SEPARATOR + GameConstants::SERVER_NAME + " " + port + " > " + logName; std::system(comm.c_str()); tlog0 << "Server finished\n"; } diff --git a/client/Client.h b/client/Client.h index 617ef3507..a26593800 100644 --- a/client/Client.h +++ b/client/Client.h @@ -1,12 +1,9 @@ -#ifndef __CLIENT_H__ -#define __CLIENT_H__ +#pragma once -#include "../global.h" -#include #include "../lib/IGameCallback.h" #include "../lib/CondSh.h" -#include +#include "../lib/StopWatch.h" /* * Client.h, part of VCMI engine @@ -41,7 +38,7 @@ class CServerHandler private: void callServer(); //calls server via system(), should be called as thread public: - timeHandler th; + StopWatch th; boost::thread *serverThread; //thread that called system to run server SharedMem *shared; //interprocess memory (for waiting for server) bool verbose; //whether to print log msgs @@ -175,5 +172,3 @@ public: template void serialize(Handler &h, const int version); }; - -#endif // __CLIENT_H__ diff --git a/client/FontBase.h b/client/FontBase.h index ee74a552a..7c18bba43 100644 --- a/client/FontBase.h +++ b/client/FontBase.h @@ -1,5 +1,4 @@ -#ifndef __FONTBASE_H__ -#define __FONTBASE_H__ +#pragma once /* * FontBase.h, part of VCMI engine @@ -22,19 +21,17 @@ struct Font struct Char { si32 unknown1, width, unknown2, offset; - unsigned char *pixels; + ui8 *pixels; }; Char chars[256]; ui8 height; - unsigned char *data; + ui8 *data; - Font(unsigned char *Data); + Font(ui8 *Data); ~Font(); int getWidth(const char *text) const; int getCharWidth(char c) const; }; - -#endif diff --git a/client/FunctionList.h b/client/FunctionList.h index 435f77c94..23695532a 100644 --- a/client/FunctionList.h +++ b/client/FunctionList.h @@ -1,8 +1,5 @@ -#ifndef FUNCTIONLIST_H -#define FUNCTIONLIST_H +#pragma once -#include -#include /* * FunctionList.h, part of VCMI engine @@ -120,6 +117,4 @@ public: funcs2[i](a); } } -}; - -#endif //FUNCTIONLISt_H \ No newline at end of file +}; \ No newline at end of file diff --git a/client/GUIBase.cpp b/client/GUIBase.cpp index db3051683..cffb9e8ca 100644 --- a/client/GUIBase.cpp +++ b/client/GUIBase.cpp @@ -1,16 +1,13 @@ +#include "StdInc.h" #include "SDL_Extensions.h" -#include -#include #include "GUIBase.h" -#include -#include + #include "CGameInfo.h" #include "CCursorHandler.h" #include "CBitmapHandler.h" #include "Graphics.h" -#include "../CThreadHelper.h" +#include "../lib/CThreadHelper.h" #include "CConfigHandler.h" -#include /* * GUIBase.cpp, part of VCMI engine @@ -25,6 +22,7 @@ extern std::queue events; extern boost::mutex eventsM; + SDL_Color Colors::MetallicGold = createColor(173, 142, 66); SDL_Color Colors::Yellow = createColor(242, 226, 110); @@ -124,7 +122,7 @@ void CGuiHandler::totalRedraw() void CGuiHandler::updateTime() { - int tv = th.getDif(); + int tv = th.getDiff(); std::list hlp = timeinterested; for (std::list::iterator i=hlp.begin(); i != hlp.end();i++) { @@ -756,10 +754,10 @@ const Rect & CIntObject::center(const Point &p, bool propagate /*= true*/) void CIntObject::fitToScreen(int borderWidth, bool propagate) { Point newPos = pos.topLeft(); - amax(newPos.x, borderWidth); - amax(newPos.y, borderWidth); - amin(newPos.x, screen->w - borderWidth - pos.w); - amin(newPos.y, screen->h - borderWidth - pos.h); + vstd::amax(newPos.x, borderWidth); + vstd::amax(newPos.y, borderWidth); + vstd::amin(newPos.x, screen->w - borderWidth - pos.w); + vstd::amin(newPos.y, screen->h - borderWidth - pos.h); if (newPos != pos.topLeft()) moveTo(newPos, propagate); } diff --git a/client/GUIBase.h b/client/GUIBase.h index 5451c98de..764c51ca1 100644 --- a/client/GUIBase.h +++ b/client/GUIBase.h @@ -1,11 +1,9 @@ -#ifndef __GUIBASE_H__ -#define __GUIBASE_H__ +#pragma once -#include "../global.h" + +#include "../lib/int3.h" #include "SDL.h" -#include -#include -#include "../timeHandler.h" +#include "../lib/StopWatch.h" #include "FontBase.h" #include "SDL_framerate.h" @@ -57,6 +55,8 @@ class CGTownInstance; class StackState; class CPlayerInterface; +using boost::logic::tribool; + /// A point with x/y coordinate, used mostly for graphic rendering struct Point { @@ -533,7 +533,7 @@ class CGuiHandler { public: FPSManager *mainFPSmng; //to keep const framerate - timeHandler th; + StopWatch th; std::list listInt; //list of interfaces - front=foreground; back = background (includes adventure map, window interfaces, all kind of active dialogs, and so on) IStatusBar * statusbar; @@ -624,5 +624,3 @@ public: #define OBJ_CONSTRUCTION_CAPTURING_ALL defActions = 255; SetCaptureState obj__i1(true, 255); ObjectConstruction obj__i(this) #define BLOCK_CAPTURING SetCaptureState obj__i(false, 0) #define BLOCK_CAPTURING_DONT_TOUCH_REC_ACTIONS SetCaptureState obj__i(false, GH.defActionsDef) - -#endif //__GUIBASE_H__ diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index d84ccc836..7e082772c 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -1,9 +1,10 @@ +#include "StdInc.h" #include "GUIClasses.h" #include "SDL_Extensions.h" -#include "../stdafx.h" #include "CAdvmapInterface.h" -#include "CBattleInterface.h" +#include "BattleInterface/CBattleInterface.h" +#include "BattleInterface/CBattleConsole.h" #include "../CCallback.h" #include "CCastleInterface.h" #include "CCreatureWindow.h" @@ -29,30 +30,19 @@ #include "../lib/CondSh.h" #include "../lib/map.h" #include "mapHandler.h" -#include "../timeHandler.h" -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include +#include "../lib/StopWatch.h" #include "../lib/NetPacks.h" #include "CSpellWindow.h" #include "CHeroWindow.h" #include "CVideoHandler.h" -#include "../StartInfo.h" +#include "../lib/StartInfo.h" #include "CPreGame.h" #include "../lib/HeroBonus.h" #include "../lib/CCreatureHandler.h" #include "CMusicHandler.h" #include "../lib/BattleState.h" #include "../lib/CGameState.h" +#include "../lib/GameConstants.h" /* * GUIClasses.cpp, part of VCMI engine @@ -116,7 +106,7 @@ void CGarrisonSlot::hover (bool on) { temp = CGI->generaltexth->tcommands[32]; //Select %s (visiting) } - else if(owner->armedObjs[0] && owner->armedObjs[0]->ID == TOWNI_TYPE) + else if(owner->armedObjs[0] && owner->armedObjs[0]->ID == GameConstants::TOWNI_TYPE) { temp = CGI->generaltexth->tcommands[12]; //Select %s (in garrison) } @@ -702,10 +692,10 @@ void CInfoPopup::init(int x, int y) pos.w = bitmap->w; // Put the window back on screen if necessary - amax(pos.x, 0); - amax(pos.y, 0); - amin(pos.x, conf.cc.resx - bitmap->w); - amin(pos.y, conf.cc.resy - bitmap->h); + vstd::amax(pos.x, 0); + vstd::amax(pos.y, 0); + vstd::amin(pos.x, conf.cc.resx - bitmap->w); + vstd::amin(pos.y, conf.cc.resy - bitmap->h); } void SComponent::init(Etype Type, int Subtype, int Val) @@ -1295,8 +1285,8 @@ void CList::fixPos() else if(from + SIZE <= selected) from = selected - SIZE + 1; - amin(from, size() - SIZE); - amax(from, 0); + vstd::amin(from, size() - SIZE); + vstd::amax(from, 0); draw(screen); } @@ -1397,7 +1387,7 @@ void CHeroList::clickLeft(tribool down, bool previousState) int ny = hy/32; if (ny>=SIZE || ny<0) return; - if ( (ny+from)==selected && (adventureInt->selection->ID == HEROI_TYPE)) + if ( (ny+from)==selected && (adventureInt->selection->ID == GameConstants::HEROI_TYPE)) LOCPLINT->openHeroWindow(LOCPLINT->wanderingHeroes[selected]);//print hero screen select(ny+from); } @@ -1566,7 +1556,7 @@ void CHeroList::draw(SDL_Surface * to) blitAt(mana->ourImages[pom].bitmap,posmanx,posmany+i*32,to); //mana SDL_Surface * temp = graphics->portraitSmall[cur->portrait]; blitAt(temp,posporx,pospory+i*32,to); - if (adventureInt->selection && (selected == iT) && (adventureInt->selection->ID == HEROI_TYPE)) + if (adventureInt->selection && (selected == iT) && (adventureInt->selection->ID == GameConstants::HEROI_TYPE)) { blitAt(selection,posporx,pospory+i*32,to); } @@ -1585,7 +1575,7 @@ void CHeroList::draw(SDL_Surface * to) int CHeroList::getPosOfHero(const CGHeroInstance* h) { - return vstd::findPos(LOCPLINT->wanderingHeroes, h, std::equal_to()); + return vstd::find_pos(LOCPLINT->wanderingHeroes, h, std::equal_to()); } void CHeroList::show( SDL_Surface * to ) @@ -1722,7 +1712,7 @@ void CTownList::clickLeft(tribool down, bool previousState) return; if(GH.topInt() == adventureInt && (ny+from)==selected - && adventureInt->selection->ID == TOWNI_TYPE + && adventureInt->selection->ID == GameConstants::TOWNI_TYPE ) LOCPLINT->openTownWindow(LOCPLINT->towns[selected]);//print town screen else @@ -1813,7 +1803,7 @@ void CTownList::draw(SDL_Surface * to) blitAt(graphics->getPic(LOCPLINT->towns[iT]->subID,LOCPLINT->towns[iT]->hasFort(),LOCPLINT->towns[iT]->builded),posporx,pospory+i*32,to); - if (adventureInt->selection && (selected == iT) && (adventureInt->selection->ID == TOWNI_TYPE)) + if (adventureInt->selection && (selected == iT) && (adventureInt->selection->ID == GameConstants::TOWNI_TYPE)) { blitAt(graphics->getPic(-2),posporx,pospory+i*32,to); } @@ -1881,7 +1871,7 @@ void CRecruitmentWindow::Buy() if(dstslot < 0 && !vstd::contains(CGI->arth->bigArtifacts,CGI->arth->convertMachineID(crid, true))) //no available slot { std::string txt; - if(dst->ID == HEROI_TYPE) + if(dst->ID == GameConstants::HEROI_TYPE) { txt = CGI->generaltexth->allTexts[425]; //The %s would join your hero, but there aren't enough provisions to support them. boost::algorithm::replace_first(txt, "%s", slider->value > 1 ? CGI->creh->creatures[crid]->namePl : CGI->creh->creatures[crid]->nameSing); @@ -2895,7 +2885,7 @@ void CTradeWindow::CTradeableItem::setArtInstance(const CArtifactInstance *art) id = -1; } -CTradeWindow::CTradeWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode Mode) +CTradeWindow::CTradeWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode) : market(Market), hero(Hero), arts(NULL), hLeft(NULL), hRight(NULL), readyToTrade(false) { type |= BLOCK_ADV_HOTKEYS; @@ -2907,31 +2897,31 @@ void CTradeWindow::initTypes() { switch(mode) { - case RESOURCE_RESOURCE: + case EMarketMode::RESOURCE_RESOURCE: itemsType[1] = RESOURCE; itemsType[0] = RESOURCE; break; - case RESOURCE_PLAYER: + case EMarketMode::RESOURCE_PLAYER: itemsType[1] = RESOURCE; itemsType[0] = PLAYER; break; - case CREATURE_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: itemsType[1] = CREATURE; itemsType[0] = RESOURCE; break; - case RESOURCE_ARTIFACT: + case EMarketMode::RESOURCE_ARTIFACT: itemsType[1] = RESOURCE; itemsType[0] = ARTIFACT_TYPE; break; - case ARTIFACT_RESOURCE: + case EMarketMode::ARTIFACT_RESOURCE: itemsType[1] = ARTIFACT_INSTANCE; itemsType[0] = RESOURCE; break; - case CREATURE_EXP: + case EMarketMode::CREATURE_EXP: itemsType[1] = CREATURE; itemsType[0] = CREATURE_PLACEHOLDER; break; - case ARTIFACT_EXP: + case EMarketMode::ARTIFACT_EXP: itemsType[1] = ARTIFACT_TYPE; itemsType[0] = ARTIFACT_PLACEHOLDER; break; @@ -2943,7 +2933,7 @@ void CTradeWindow::initItems(bool Left) if(Left && (itemsType[1] == ARTIFACT_TYPE || itemsType[1] == ARTIFACT_INSTANCE)) { int xOffset = 0, yOffset = 0; - if(mode == ARTIFACT_RESOURCE) + if(mode == EMarketMode::ARTIFACT_RESOURCE) { xOffset = -361; yOffset = +46; @@ -2969,7 +2959,7 @@ void CTradeWindow::initItems(bool Left) addChild(arts); artSets.push_back(arts); - if(mode == ARTIFACT_RESOURCE) + if(mode == EMarketMode::ARTIFACT_RESOURCE) arts->highlightModeCallback = boost::bind(&CTradeWindow::artifactSelected, this, _1); return; } @@ -2986,12 +2976,12 @@ void CTradeWindow::initItems(bool Left) amount = ids->size(); if(ids) - amin(amount, ids->size()); + vstd::amin(amount, ids->size()); for(int j=0; jsize()>j) ? (*ids)[j] : j; - if(id < 0 && mode != ARTIFACT_EXP) //when sacrificing artifacts we need to prepare empty slots + if(id < 0 && mode != EMarketMode::ARTIFACT_EXP) //when sacrificing artifacts we need to prepare empty slots continue; CTradeableItem *hlp = new CTradeableItem(itemsType[Left], id, Left, j); @@ -3006,7 +2996,7 @@ std::vector *CTradeWindow::getItemsIds(bool Left) { std::vector *ids = NULL; - if(mode == ARTIFACT_EXP) + if(mode == EMarketMode::ARTIFACT_EXP) return new std::vector(22, -1); if(Left) @@ -3031,7 +3021,7 @@ std::vector *CTradeWindow::getItemsIds(bool Left) { case PLAYER: ids = new std::vector; - for(int i = 0; i < PLAYER_LIMIT; i++) + for(int i = 0; i < GameConstants::PLAYER_LIMIT; i++) if(i != LOCPLINT->playerID && LOCPLINT->cb->getPlayerStatus(i) == PlayerState::INGAME) ids->push_back(i); break; @@ -3047,7 +3037,7 @@ std::vector *CTradeWindow::getItemsIds(bool Left) void CTradeWindow::getPositionsFor(std::vector &poss, bool Left, EType type) const { - if(mode == ARTIFACT_EXP && !Left) + if(mode == EMarketMode::ARTIFACT_EXP && !Left) { //22 boxes, 5 in row, last row: two boxes centered int h, w, x, y, dx, dy; @@ -3111,7 +3101,7 @@ void CTradeWindow::initSubs(bool Left) { int h1, h2; //hlp variables for getting offer market->getOffer(hLeft->id, t->id, h1, h2, mode); - if(t->id != hLeft->id || mode != RESOURCE_RESOURCE) //don't allow exchanging same resources + if(t->id != hLeft->id || mode != EMarketMode::RESOURCE_RESOURCE) //don't allow exchanging same resources { std::ostringstream oss; oss << h2; @@ -3171,7 +3161,7 @@ void CTradeWindow::getEmptySlots(std::set &toRemove) toRemove.insert(t); } -void CTradeWindow::setMode(EMarketMode Mode) +void CTradeWindow::setMode(EMarketMode::EMarketMode Mode) { const IMarket *m = market; const CGHeroInstance *h = hero; @@ -3181,8 +3171,8 @@ void CTradeWindow::setMode(EMarketMode Mode) switch(Mode) { - case CREATURE_EXP: - case ARTIFACT_EXP: + case EMarketMode::CREATURE_EXP: + case EMarketMode::ARTIFACT_EXP: nwindow = new CAltarWindow(m, h, Mode); break; default: @@ -3195,7 +3185,7 @@ void CTradeWindow::setMode(EMarketMode Mode) void CTradeWindow::artifactSelected(CArtPlace *slot) { - assert(mode == ARTIFACT_RESOURCE); + assert(mode == EMarketMode::ARTIFACT_RESOURCE); items[1][0]->setArtInstance(slot->ourArt); if(slot->ourArt) hLeft = items[1][0]; @@ -3205,7 +3195,7 @@ void CTradeWindow::artifactSelected(CArtPlace *slot) selectionChanged(true); } -CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode Mode) +CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode) : CTradeWindow(Market, Hero, Mode) { OBJ_CONSTRUCTION_CAPTURING_ALL; @@ -3215,24 +3205,24 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan switch(Mode) { - case RESOURCE_RESOURCE: + case EMarketMode::RESOURCE_RESOURCE: bgName = "TPMRKRES.bmp"; break; - case RESOURCE_PLAYER: + case EMarketMode::RESOURCE_PLAYER: bgName = "TPMRKPTS.bmp"; break; - case CREATURE_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: bgName = "TPMRKCRS.bmp"; break; - case RESOURCE_ARTIFACT: + case EMarketMode::RESOURCE_ARTIFACT: bgName = "TPMRKABS.bmp"; sliderNeeded = false; break; - case ARTIFACT_RESOURCE: + case EMarketMode::ARTIFACT_RESOURCE: bgName = "TPMRKASS.bmp"; sliderNeeded = false; break; @@ -3252,16 +3242,16 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan { printAtMiddle(CGI->generaltexth->allTexts[159],300,27,FONT_BIG,tytulowy,*bg); //title } - else if(mode == CREATURE_RESOURCE) + else if(mode == EMarketMode::CREATURE_RESOURCE) { - if(market->o->ID == TOWNI_TYPE) + if(market->o->ID == GameConstants::TOWNI_TYPE) printAtMiddle(CGI->buildh->buildings[6][21]->Name(), 300, 27, FONT_BIG, tytulowy, *bg); //title else printAtMiddle(market->o->getHoverText(), 300, 27, FONT_BIG, tytulowy, *bg); //title } - else if(mode == RESOURCE_ARTIFACT || mode == ARTIFACT_RESOURCE) + else if(mode == EMarketMode::RESOURCE_ARTIFACT || mode == EMarketMode::ARTIFACT_RESOURCE) { - const std::string &title = market->o->ID == TOWNI_TYPE + const std::string &title = market->o->ID == GameConstants::TOWNI_TYPE ? CGI->buildh->buildings[market->o->subID][17]->Name() : market->o->getHoverText(); @@ -3301,15 +3291,15 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan //left side switch(Mode) { - case RESOURCE_RESOURCE: - case RESOURCE_PLAYER: - case RESOURCE_ARTIFACT: + case EMarketMode::RESOURCE_RESOURCE: + case EMarketMode::RESOURCE_PLAYER: + case EMarketMode::RESOURCE_ARTIFACT: printAtMiddle(CGI->generaltexth->allTexts[270],154,148,FONT_SMALL,zwykly,*bg); //kingdom res. break; - case CREATURE_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: printAtMiddle(boost::str(boost::format(CGI->generaltexth->allTexts[272]) % hero->name), 152, 102, FONT_SMALL, zwykly, *bg); //%s's Creatures break; - case ARTIFACT_RESOURCE: + case EMarketMode::ARTIFACT_RESOURCE: printAtMiddle(boost::str(boost::format(CGI->generaltexth->allTexts[271]) % hero->name), 152, 57, FONT_SMALL, zwykly, *bg); //%s's Artifacts break; } @@ -3317,32 +3307,32 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan //right side switch(Mode) { - case RESOURCE_RESOURCE: - case CREATURE_RESOURCE: - case RESOURCE_ARTIFACT: - case ARTIFACT_RESOURCE: + case EMarketMode::RESOURCE_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: + case EMarketMode::RESOURCE_ARTIFACT: + case EMarketMode::ARTIFACT_RESOURCE: printAtMiddle(CGI->generaltexth->allTexts[168],445,148,FONT_SMALL,zwykly,*bg); //available for trade traderTextRect = Rect(316, 48, 260, 75); break; - case RESOURCE_PLAYER: + case EMarketMode::RESOURCE_PLAYER: printAtMiddle(CGI->generaltexth->allTexts[169],445,55,FONT_SMALL,zwykly,*bg); //players traderTextRect = Rect(28, 48, 260, 75); break; } traderText = new CTextBox("", traderTextRect, 0, FONT_SMALL, CENTER); - int specialOffset = mode == ARTIFACT_RESOURCE ? 35 : 0; //in selling artifacts mode we need to move res-res and art-res buttons down + int specialOffset = mode == EMarketMode::ARTIFACT_RESOURCE ? 35 : 0; //in selling artifacts mode we need to move res-res and art-res buttons down - if(printButtonFor(RESOURCE_PLAYER)) - new AdventureMapButton(CGI->generaltexth->zelp[612],boost::bind(&CMarketplaceWindow::setMode,this, RESOURCE_PLAYER), 18, 520,"TPMRKBU1.DEF"); - if(printButtonFor(RESOURCE_RESOURCE)) - new AdventureMapButton(CGI->generaltexth->zelp[605],boost::bind(&CMarketplaceWindow::setMode,this, RESOURCE_RESOURCE), 516, 450 + specialOffset,"TPMRKBU5.DEF"); - if(printButtonFor(CREATURE_RESOURCE)) - new AdventureMapButton(CGI->generaltexth->zelp[599],boost::bind(&CMarketplaceWindow::setMode,this, CREATURE_RESOURCE), 516, 485,"TPMRKBU4.DEF"); //was y=450, changed to not overlap res-res in some conditions - if(printButtonFor(RESOURCE_ARTIFACT)) - new AdventureMapButton(CGI->generaltexth->zelp[598],boost::bind(&CMarketplaceWindow::setMode,this, RESOURCE_ARTIFACT), 18, 450 + specialOffset,"TPMRKBU2.DEF"); - if(printButtonFor(ARTIFACT_RESOURCE)) - new AdventureMapButton(CGI->generaltexth->zelp[613],boost::bind(&CMarketplaceWindow::setMode,this, ARTIFACT_RESOURCE), 18, 485,"TPMRKBU3.DEF"); //was y=450, changed to not overlap res-art in some conditions + if(printButtonFor(EMarketMode::RESOURCE_PLAYER)) + new AdventureMapButton(CGI->generaltexth->zelp[612],boost::bind(&CMarketplaceWindow::setMode,this, EMarketMode::RESOURCE_PLAYER), 18, 520,"TPMRKBU1.DEF"); + if(printButtonFor(EMarketMode::RESOURCE_RESOURCE)) + new AdventureMapButton(CGI->generaltexth->zelp[605],boost::bind(&CMarketplaceWindow::setMode,this, EMarketMode::RESOURCE_RESOURCE), 516, 450 + specialOffset,"TPMRKBU5.DEF"); + if(printButtonFor(EMarketMode::CREATURE_RESOURCE)) + new AdventureMapButton(CGI->generaltexth->zelp[599],boost::bind(&CMarketplaceWindow::setMode,this, EMarketMode::CREATURE_RESOURCE), 516, 485,"TPMRKBU4.DEF"); //was y=450, changed to not overlap res-res in some conditions + if(printButtonFor(EMarketMode::RESOURCE_ARTIFACT)) + new AdventureMapButton(CGI->generaltexth->zelp[598],boost::bind(&CMarketplaceWindow::setMode,this, EMarketMode::RESOURCE_ARTIFACT), 18, 450 + specialOffset,"TPMRKBU2.DEF"); + if(printButtonFor(EMarketMode::ARTIFACT_RESOURCE)) + new AdventureMapButton(CGI->generaltexth->zelp[613],boost::bind(&CMarketplaceWindow::setMode,this, EMarketMode::ARTIFACT_RESOURCE), 18, 485,"TPMRKBU3.DEF"); //was y=450, changed to not overlap res-art in some conditions updateTraderText(); } @@ -3380,9 +3370,9 @@ void CMarketplaceWindow::makeDeal() return; int leftIdToSend = -1; - if(mode == CREATURE_RESOURCE) + if(mode == EMarketMode::CREATURE_RESOURCE) leftIdToSend = hLeft->serial; - else if(mode == ARTIFACT_RESOURCE) + else if(mode == EMarketMode::ARTIFACT_RESOURCE) leftIdToSend = hLeft->getArtInstance()->id; else leftIdToSend = hLeft->id; @@ -3411,10 +3401,10 @@ void CMarketplaceWindow::sliderMoved( int to ) void CMarketplaceWindow::selectionChanged(bool side) { readyToTrade = hLeft && hRight; - if(mode == RESOURCE_RESOURCE) + if(mode == EMarketMode::RESOURCE_RESOURCE) readyToTrade = readyToTrade && (hLeft->id != hRight->id); //for resource trade, two DIFFERENT resources must be selected - if(mode == ARTIFACT_RESOURCE && !hLeft) + if(mode == EMarketMode::ARTIFACT_RESOURCE && !hLeft) arts->unmarkSlots(false); if(readyToTrade) @@ -3462,14 +3452,14 @@ void CMarketplaceWindow::selectionChanged(bool side) redraw(); } -bool CMarketplaceWindow::printButtonFor(EMarketMode M) const +bool CMarketplaceWindow::printButtonFor(EMarketMode::EMarketMode M) const { - return market->allowsTrade(M) && M != mode && (hero || ( M != CREATURE_RESOURCE && M != RESOURCE_ARTIFACT && M != ARTIFACT_RESOURCE )); + return market->allowsTrade(M) && M != mode && (hero || ( M != EMarketMode::CREATURE_RESOURCE && M != EMarketMode::RESOURCE_ARTIFACT && M != EMarketMode::ARTIFACT_RESOURCE )); } void CMarketplaceWindow::garrisonChanged() { - if(mode != CREATURE_RESOURCE) + if(mode != EMarketMode::CREATURE_RESOURCE) return; std::set toRemove; @@ -3483,7 +3473,7 @@ void CMarketplaceWindow::garrisonChanged() void CMarketplaceWindow::artifactsChanged(bool Left) { assert(!Left); - if(mode != RESOURCE_ARTIFACT) + if(mode != EMarketMode::RESOURCE_ARTIFACT) return; std::vector available = market->availableItemsIds(mode); @@ -3553,7 +3543,7 @@ Point CMarketplaceWindow::selectionOffset(bool Left) const switch(itemsType[0]) { case RESOURCE: - if(mode == ARTIFACT_RESOURCE) + if(mode == EMarketMode::ARTIFACT_RESOURCE) return Point(410, 469); else return Point(410, 446); @@ -3620,27 +3610,27 @@ void CMarketplaceWindow::updateTraderText() { if(readyToTrade) { - if(mode == RESOURCE_PLAYER) + if(mode == EMarketMode::RESOURCE_PLAYER) { //I can give %s to the %s player. traderText->setTxt(boost::str(boost::format(CGI->generaltexth->allTexts[165]) % hLeft->getName() % hRight->getName())); } - else if(mode == RESOURCE_ARTIFACT) + else if(mode == EMarketMode::RESOURCE_ARTIFACT) { //I can offer you the %s for %d %s of %s. traderText->setTxt(boost::str(boost::format(CGI->generaltexth->allTexts[267]) % hRight->getName() % r1 % CGI->generaltexth->allTexts[160 + (r1==1)] % hLeft->getName())); } - else if(mode == RESOURCE_RESOURCE) + else if(mode == EMarketMode::RESOURCE_RESOURCE) { //I can offer you %d %s of %s for %d %s of %s. traderText->setTxt(boost::str(boost::format(CGI->generaltexth->allTexts[157]) % r2 % CGI->generaltexth->allTexts[160 + (r2==1)] % hRight->getName() % r1 % CGI->generaltexth->allTexts[160 + (r1==1)] % hLeft->getName())); } - else if(mode == CREATURE_RESOURCE) + else if(mode == EMarketMode::CREATURE_RESOURCE) { //I can offer you %d %s of %s for %d %s. traderText->setTxt(boost::str(boost::format(CGI->generaltexth->allTexts[269]) % r2 % CGI->generaltexth->allTexts[160 + (r2==1)] % hRight->getName() % r1 % hLeft->getName(r1))); } - else if(mode == ARTIFACT_RESOURCE) + else if(mode == EMarketMode::ARTIFACT_RESOURCE) { //I can offer you %d %s of %s for your %s. traderText->setTxt(boost::str(boost::format(CGI->generaltexth->allTexts[268]) % r2 % CGI->generaltexth->allTexts[160 + (r2==1)] % hRight->getName() % hLeft->getName(r1))); @@ -3651,14 +3641,14 @@ void CMarketplaceWindow::updateTraderText() int gnrtxtnr = -1; if(madeTransaction) { - if(mode == RESOURCE_PLAYER) + if(mode == EMarketMode::RESOURCE_PLAYER) gnrtxtnr = 166; //Are there any other resources you'd like to give away? else gnrtxtnr = 162; //You have received quite a bargain. I expect to make no profit on the deal. Can I interest you in any of my other wares? } else { - if(mode == RESOURCE_PLAYER) + if(mode == EMarketMode::RESOURCE_PLAYER) gnrtxtnr = 167; //If you'd like to give any of your resources to another player, click on the item you wish to give and to whom. else gnrtxtnr = 163; //Please inspect our fine wares. If you feel like offering a trade, click on the items you wish to trade with and for. @@ -3666,18 +3656,18 @@ void CMarketplaceWindow::updateTraderText() traderText->setTxt(CGI->generaltexth->allTexts[gnrtxtnr]); } -CAltarWindow::CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero /*= NULL*/, EMarketMode Mode) +CAltarWindow::CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero /*= NULL*/, EMarketMode::EMarketMode Mode) :CTradeWindow(Market, Hero, Mode) { OBJ_CONSTRUCTION_CAPTURING_ALL; - bg = new CPicture(Mode == CREATURE_EXP ? "ALTARMON.bmp" : "ALTRART2.bmp"); + bg = new CPicture(Mode == EMarketMode::CREATURE_EXP ? "ALTARMON.bmp" : "ALTRART2.bmp"); bg->colorizeAndConvert(LOCPLINT->playerID); pos = bg->center(); - if(Mode == CREATURE_EXP) + if(Mode == EMarketMode::CREATURE_EXP) { printAtMiddle(boost::str(boost::format(CGI->generaltexth->allTexts[272]) % hero->name), 155, 30, FONT_SMALL, tytulowy, *bg); //%s's Creatures printAtMiddle(CGI->generaltexth->allTexts[479], 450, 30, FONT_SMALL, tytulowy, *bg); //Altar of Sacrifice @@ -3687,7 +3677,7 @@ CAltarWindow::CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero /*= slider->moved = boost::bind(&CAltarWindow::sliderMoved,this,_1); max = new AdventureMapButton(CGI->generaltexth->zelp[578],boost::bind(&CSlider::moveToMax, slider),147,520,"IRCBTNS.DEF"); - sacrificedUnits.resize(ARMY_SIZE, 0); + sacrificedUnits.resize(GameConstants::ARMY_SIZE, 0); sacrificeAll = new AdventureMapButton(CGI->generaltexth->zelp[579],boost::bind(&CAltarWindow::SacrificeAll,this),393,520,"ALTARMY.DEF"); sacrificeBackpack = NULL; @@ -3720,12 +3710,12 @@ CAltarWindow::CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero /*= deal = new AdventureMapButton(CGI->generaltexth->zelp[585],boost::bind(&CAltarWindow::makeDeal,this),269,520,"ALTSACR.DEF"); - if(Hero->getAlignment() != EVIL && Mode == CREATURE_EXP) - new AdventureMapButton(CGI->generaltexth->zelp[580], boost::bind(&CTradeWindow::setMode,this, ARTIFACT_EXP), 516, 421, "ALTART.DEF"); - if(Hero->getAlignment() != GOOD && Mode == ARTIFACT_EXP) - new AdventureMapButton(CGI->generaltexth->zelp[572], boost::bind(&CTradeWindow::setMode,this, CREATURE_EXP), 516, 421, "ALTSACC.DEF"); + if(Hero->getAlignment() != ::EAlignment::EVIL && Mode == EMarketMode::CREATURE_EXP) + new AdventureMapButton(CGI->generaltexth->zelp[580], boost::bind(&CTradeWindow::setMode,this, EMarketMode::ARTIFACT_EXP), 516, 421, "ALTART.DEF"); + if(Hero->getAlignment() != ::EAlignment::GOOD && Mode == EMarketMode::ARTIFACT_EXP) + new AdventureMapButton(CGI->generaltexth->zelp[572], boost::bind(&CTradeWindow::setMode,this, EMarketMode::CREATURE_EXP), 516, 421, "ALTSACC.DEF"); - expPerUnit.resize(ARMY_SIZE, 0); + expPerUnit.resize(GameConstants::ARMY_SIZE, 0); getExpValues(); expToLevel = new CLabel(73, 475, FONT_SMALL, CENTER); @@ -3763,7 +3753,7 @@ void CAltarWindow::sliderMoved(int to) void CAltarWindow::makeDeal() { - if(mode == CREATURE_EXP) + if(mode == EMarketMode::CREATURE_EXP) { blockTrade(); slider->value = 0; @@ -3808,7 +3798,7 @@ void CAltarWindow::makeDeal() void CAltarWindow::SacrificeAll() { - if(mode == CREATURE_EXP) + if(mode == EMarketMode::CREATURE_EXP) { bool movedAnything = false; BOOST_FOREACH(CTradeableItem *t, items[1]) @@ -3841,7 +3831,7 @@ void CAltarWindow::SacrificeAll() void CAltarWindow::selectionChanged(bool side) { - if(mode != CREATURE_EXP) + if(mode != EMarketMode::CREATURE_EXP) return; CTradeableItem *&selected = side ? hLeft : hRight; @@ -3850,7 +3840,7 @@ void CAltarWindow::selectionChanged(bool side) theOther = *std::find_if(items[!side].begin(), items[!side].end(), boost::bind(&CTradeableItem::serial, _1) == selected->serial); int stackCount = 0; - for (int i = 0; i < ARMY_SIZE; i++) + for (int i = 0; i < GameConstants::ARMY_SIZE; i++) if(hero->getStackCount(i) > sacrificedUnits[i]) stackCount++; @@ -3900,7 +3890,7 @@ void CAltarWindow::artifactsChanged(bool left) void CAltarWindow::garrisonChanged() { - if(mode != CREATURE_EXP) + if(mode != EMarketMode::CREATURE_EXP) return; std::set empty; @@ -3921,13 +3911,13 @@ void CAltarWindow::getExpValues() int dump; BOOST_FOREACH(CTradeableItem *t, items[1]) if(t->id >= 0) - market->getOffer(t->id, 0, dump, expPerUnit[t->serial], CREATURE_EXP); + market->getOffer(t->id, 0, dump, expPerUnit[t->serial], EMarketMode::CREATURE_EXP); } void CAltarWindow::calcTotalExp() { int val = 0; - if(mode == CREATURE_EXP) + if(mode == EMarketMode::CREATURE_EXP) { for (int i = 0; i < sacrificedUnits.size(); i++) { @@ -3943,7 +3933,7 @@ void CAltarWindow::calcTotalExp() val += valOfArt; //WAS val += valOfArt * arts->artifactsOnAltar.count(*i); } } - val *=(100+hero->getSecSkillLevel(CGHeroInstance::LEARNING)*5)/100.0f; + val *=(100+hero->getSecSkillLevel(CGHeroInstance::LEARNING)*5)/100.0; expOnAltar->setTxt(boost::lexical_cast(val)); } @@ -4006,12 +3996,12 @@ void CAltarWindow::artifactPicked() void CAltarWindow::showAll(SDL_Surface * to) { CTradeWindow::showAll(to); - if(mode == ARTIFACT_EXP && arts && arts->commonInfo->src.art) + if(mode == EMarketMode::ARTIFACT_EXP && arts && arts->commonInfo->src.art) { blitAtLoc(graphics->artDefs->ourImages[arts->commonInfo->src.art->artType->id].bitmap, 281, 442, to); int dmp, val; - market->getOffer(arts->commonInfo->src.art->artType->id, 0, dmp, val, ARTIFACT_EXP); + market->getOffer(arts->commonInfo->src.art->artType->id, 0, dmp, val, EMarketMode::ARTIFACT_EXP); printAtMiddleLoc(boost::lexical_cast(val), 304, 498, FONT_SMALL, zwykly, to); } } @@ -4037,7 +4027,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance } int dmp, val; - market->getOffer(artID, 0, dmp, val, ARTIFACT_EXP); + market->getOffer(artID, 0, dmp, val, EMarketMode::ARTIFACT_EXP); arts->artifactsOnAltar.insert(art); altarSlot->setArtInstance(art); @@ -4049,7 +4039,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance void CAltarWindow::moveFromSlotToAltar(int slotID, CTradeableItem* altarSlot, const CArtifactInstance *art) { - int freeBackpackSlot = hero->artifactsInBackpack.size() + Arts::BACKPACK_START; + int freeBackpackSlot = hero->artifactsInBackpack.size() + GameConstants::BACKPACK_START; if(arts->commonInfo->src.art) { arts->commonInfo->dst.slotID = freeBackpackSlot; @@ -4058,7 +4048,7 @@ void CAltarWindow::moveFromSlotToAltar(int slotID, CTradeableItem* altarSlot, co if(putOnAltar(altarSlot, art)) { - if(slotID < Arts::BACKPACK_START) + if(slotID < GameConstants::BACKPACK_START) LOCPLINT->cb->swapArtifacts(hero, slotID, hero, freeBackpackSlot); else { @@ -4307,8 +4297,7 @@ void CTavernWindow::show(SDL_Surface * to) void CTavernWindow::HeroPortrait::clickLeft(tribool down, bool previousState) { if(previousState && !down && h) - as(); - //ClickableL::clickLeft(down); + *_sel = _id; } void CTavernWindow::HeroPortrait::clickRight(tribool down, bool previousState) @@ -4320,7 +4309,7 @@ void CTavernWindow::HeroPortrait::clickRight(tribool down, bool previousState) } CTavernWindow::HeroPortrait::HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H) -:as(sel,id), h(H) +: h(H), _id(id), _sel(&sel) { used = LCLICK | RCLICK | HOVER; h = H; @@ -4688,8 +4677,8 @@ void CArtPlace::activate() void CArtPlace::clickLeft(tribool down, bool previousState) { //LRClickableAreaWTextComp::clickLeft(down); - bool inBackpack = slotID >= Arts::BACKPACK_START, - srcInBackpack = ourOwner->commonInfo->src.slotID >= Arts::BACKPACK_START, + bool inBackpack = slotID >= GameConstants::BACKPACK_START, + srcInBackpack = ourOwner->commonInfo->src.slotID >= GameConstants::BACKPACK_START, srcInSameHero = ourOwner->commonInfo->src.AOH == ourOwner; if(ourOwner->highlightModeCallback && ourArt) @@ -4766,10 +4755,10 @@ void CArtPlace::clickLeft(tribool down, bool previousState) break; default: setMeAsDest(); - amin(ourOwner->commonInfo->dst.slotID, ourOwner->curHero->artifactsInBackpack.size() + Arts::BACKPACK_START); + vstd::amin(ourOwner->commonInfo->dst.slotID, ourOwner->curHero->artifactsInBackpack.size() + GameConstants::BACKPACK_START); if(srcInBackpack && srcInSameHero) { - if(!ourArt //cannot move from backpack to AFTER backpack -> combined with amin above it will guarantee that dest is at most the last artifact + if(!ourArt //cannot move from backpack to AFTER backpack -> combined with vstd::amin above it will guarantee that dest is at most the last artifact || ourOwner->commonInfo->src.slotID < ourOwner->commonInfo->dst.slotID) //rearranging arts in backpack after taking src artifact, the dest id will be shifted ourOwner->commonInfo->dst.slotID--; } @@ -4860,9 +4849,9 @@ void CArtPlace::select () return; picked = true; - if(ourArt->canBeDisassembled() && slotID < Arts::BACKPACK_START) //worn combined artifact -> locks have to disappear + if(ourArt->canBeDisassembled() && slotID < GameConstants::BACKPACK_START) //worn combined artifact -> locks have to disappear { - for(int i = 0; i < Arts::BACKPACK_START; i++) + for(int i = 0; i < GameConstants::BACKPACK_START; i++) { CArtPlace *ap = ourOwner->getArtPlace(i); ap->picked = ourArt->isPart(ap->ourArt); @@ -4875,7 +4864,7 @@ void CArtPlace::select () ourOwner->commonInfo->src.setTo(this, false); ourOwner->markPossibleSlots(ourArt); - if(slotID >= Arts::BACKPACK_START) + if(slotID >= GameConstants::BACKPACK_START) ourOwner->scrollBackpack(0); //will update slots ourOwner->updateParentWindow(); @@ -4890,14 +4879,14 @@ void CArtPlace::deselect () picked = false; if(ourArt && ourArt->canBeDisassembled()) //combined art returned to its slot -> restore locks { - for(int i = 0; i < Arts::BACKPACK_START; i++) + for(int i = 0; i < GameConstants::BACKPACK_START; i++) ourOwner->getArtPlace(i)->picked = false; } CCS->curh->dragAndDropCursor(NULL); ourOwner->unmarkSlots(); ourOwner->commonInfo->src.clear(); - if(slotID >= Arts::BACKPACK_START) + if(slotID >= GameConstants::BACKPACK_START) ourOwner->scrollBackpack(0); //will update slots @@ -5225,7 +5214,7 @@ void CArtifactsOfHero::setHero(const CGHeroInstance * hero) void CArtifactsOfHero::dispose() { - //delNull(curHero); + //vstd::clear_pointer(curHero); //unmarkSlots(false); CCS->curh->dragAndDropCursor(NULL); } @@ -5339,7 +5328,7 @@ void CArtifactsOfHero::unmarkLocalSlots(bool withRedraw /*= true*/) */ void CArtifactsOfHero::setSlotData(CArtPlace* artPlace, int slotID) { - if(!artPlace && slotID >= Arts::BACKPACK_START) //spurious call from artifactMoved in attempt to update hidden backpack slot + if(!artPlace && slotID >= GameConstants::BACKPACK_START) //spurious call from artifactMoved in attempt to update hidden backpack slot { return; } @@ -5511,9 +5500,9 @@ void CArtifactsOfHero::realizeCurrentTransaction() void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst) { - if(src.hero == curHero && src.slot >= Arts::BACKPACK_START) + if(src.hero == curHero && src.slot >= GameConstants::BACKPACK_START) updateSlot(src.slot); - if(dst.hero == curHero && dst.slot >= Arts::BACKPACK_START) + if(dst.hero == curHero && dst.slot >= GameConstants::BACKPACK_START) updateSlot(dst.slot); if(src.hero == curHero || dst.hero == curHero) //we need to update all slots, artifact might be combined and affect more slots updateWornSlots(false); @@ -5523,13 +5512,13 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact if(commonInfo->src == src) //artifact was taken from us { - assert(commonInfo->dst == dst || dst.slot == dst.hero->artifactsInBackpack.size() + Arts::BACKPACK_START); + assert(commonInfo->dst == dst || dst.slot == dst.hero->artifactsInBackpack.size() + GameConstants::BACKPACK_START); commonInfo->reset(); unmarkSlots(); } else if(commonInfo->dst == src) //the dest artifact was moved -> we are picking it { - assert(dst.slot >= Arts::BACKPACK_START); + assert(dst.slot >= GameConstants::BACKPACK_START); commonInfo->reset(); CArtPlace *ap = NULL; @@ -5556,7 +5545,7 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact markPossibleSlots(dst.getArt()); } } - else if(src.slot >= Arts::BACKPACK_START && + else if(src.slot >= GameConstants::BACKPACK_START && src.slot < commonInfo->src.slotID && src.hero == commonInfo->src.AOH->curHero) //artifact taken from before currently picked one { @@ -5577,13 +5566,13 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact // if(dst.slot >= Arts::BACKPACK_START && dst.slot - Arts::BACKPACK_START < backpackPos) // shift++; // - if(src.slot < Arts::BACKPACK_START && dst.slot - Arts::BACKPACK_START < backpackPos) + if(src.slot < GameConstants::BACKPACK_START && dst.slot - GameConstants::BACKPACK_START < backpackPos) shift++; - if(dst.slot < Arts::BACKPACK_START && src.slot - Arts::BACKPACK_START < backpackPos) + if(dst.slot < GameConstants::BACKPACK_START && src.slot - GameConstants::BACKPACK_START < backpackPos) shift--; - if( (src.hero == curHero && src.slot >= Arts::BACKPACK_START) - || (dst.hero == curHero && dst.slot >= Arts::BACKPACK_START) ) + if( (src.hero == curHero && src.slot >= GameConstants::BACKPACK_START) + || (dst.hero == curHero && dst.slot >= GameConstants::BACKPACK_START) ) scrollBackpack(shift); //update backpack slots } @@ -5591,7 +5580,7 @@ void CArtifactsOfHero::artifactRemoved(const ArtifactLocation &al) { if(al.hero == curHero) { - if(al.slot < Arts::BACKPACK_START) + if(al.slot < GameConstants::BACKPACK_START) updateWornSlots(0); else scrollBackpack(0); //update backpack slots @@ -5600,7 +5589,7 @@ void CArtifactsOfHero::artifactRemoved(const ArtifactLocation &al) CArtPlace * CArtifactsOfHero::getArtPlace(int slot) { - if(slot < Arts::BACKPACK_START) + if(slot < GameConstants::BACKPACK_START) { return artWorn[slot]; } @@ -5899,7 +5888,7 @@ CShipyardWindow::CShipyardWindow(const std::vector &cost, int state, int b costLabel = new CLabel(164, 220, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->jktexts[14]); } -CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio) +CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, double discoveredRatio) :animCount(0) { SDL_Surface * back = BitmapHandler::loadBitmap("PUZZLE.BMP", false); @@ -6059,7 +6048,7 @@ void CTransformerWindow::makeDeal() { for (int i=0; ileft) - LOCPLINT->cb->trade(town, CREATURE_UNDEAD, items[i]->id, 0, 0, hero); + LOCPLINT->cb->trade(town, EMarketMode::CREATURE_UNDEAD, items[i]->id, 0, 0, hero); } void CTransformerWindow::addAll() @@ -6137,7 +6126,7 @@ int CUniversityWindow::CItem::state() { if (parent->hero->getSecSkillLevel(static_cast(ID)))//hero know this skill return 1; - if (parent->hero->secSkills.size() >= SKILL_PER_HERO)//can't learn more skills + if (parent->hero->secSkills.size() >= GameConstants::SKILL_PER_HERO)//can't learn more skills return 0; if (parent->hero->type->heroClass->proSec[ID]==0)//can't learn this skill (like necromancy for most of non-necros) return 0; @@ -6207,7 +6196,7 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket printAtMiddleWBLoc(CGI->generaltexth->allTexts[603], 232, 153, FONT_SMALL, 70,zwykly,bg->bg);//Clerk speech printAtMiddleLoc (CGI->generaltexth->allTexts[602], 231, 26 , FONT_MEDIUM ,tytulowy,bg->bg);//University - std::vector list = market->availableItemsIds(RESOURCE_SKILL); + std::vector list = market->availableItemsIds(EMarketMode::RESOURCE_SKILL); if (list.size()!=4) tlog0<<"\t\tIncorrect size of available items vector!\n"; for (int i=0; icb->trade(parent->market->o, RESOURCE_SKILL, 6, skill, 1, parent->hero); + LOCPLINT->cb->trade(parent->market->o, EMarketMode::RESOURCE_SKILL, 6, skill, 1, parent->hero); GH.popIntTotally(this); } @@ -6285,7 +6274,7 @@ CHillFortWindow::CHillFortWindow(const CGHeroInstance *visitor, const CGObjectIn currState.resize(slotsCount+1); costs.resize(slotsCount); - totalSumm.resize(RESOURCE_QUANTITY); + totalSumm.resize(GameConstants::RESOURCE_QUANTITY); std::vector files; files += "APHLF1R.DEF", "APHLF1Y.DEF", "APHLF1G.DEF"; for (int i=0; ipos; if(maxw < pos.w) { - amin(pos.w, maxw); + vstd::amin(pos.w, maxw); bg->srcRect = new Rect(0, 0, maxw, pos.h); } calcOffset(); diff --git a/client/GUIClasses.h b/client/GUIClasses.h index ef6de8413..ff1d8989e 100644 --- a/client/GUIClasses.h +++ b/client/GUIClasses.h @@ -1,13 +1,10 @@ -#ifndef __GUICLASSES_H__ -#define __GUICLASSES_H__ +#pragma once + -#include "../global.h" #include "GUIBase.h" #include "FunctionList.h" -#include -#include -#include #include "../lib/ResourceSet.h" +#include "../lib/GameConstants.h" #ifdef max #undef max @@ -761,12 +758,12 @@ public: CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight) EType itemsType[2]; - EMarketMode mode;//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact + EMarketMode::EMarketMode mode;//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact AdventureMapButton *ok, *max, *deal; CSlider *slider; //for choosing amount to be exchanged bool readyToTrade; - CTradeWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode Mode); //c + CTradeWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode); //c void showAll(SDL_Surface * to); @@ -778,7 +775,7 @@ public: void removeItems(const std::set &toRemove); void removeItem(CTradeableItem * t); void getEmptySlots(std::set &toRemove); - void setMode(EMarketMode Mode); //mode setter + void setMode(EMarketMode::EMarketMode Mode); //mode setter void artifactSelected(CArtPlace *slot); //used when selling artifacts -> called when user clicked on artifact slot @@ -792,7 +789,7 @@ public: class CMarketplaceWindow : public CTradeWindow { - bool printButtonFor(EMarketMode M) const; + bool printButtonFor(EMarketMode::EMarketMode M) const; public: int r1, r2; //suggested amounts of traded resources bool madeTransaction; //if player made at least one transaction @@ -802,7 +799,7 @@ public: void sliderMoved(int to); void makeDeal(); void selectionChanged(bool side); //true == left - CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero = NULL, EMarketMode Mode = RESOURCE_RESOURCE); //c-tor + CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero = NULL, EMarketMode::EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE); //c-tor ~CMarketplaceWindow(); //d-tor Point selectionOffset(bool Left) const; @@ -820,7 +817,7 @@ public: class CAltarWindow : public CTradeWindow { public: - CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode Mode); //c-tor + CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode); //c-tor void getExpValues(); ~CAltarWindow(); //d-tor @@ -889,7 +886,6 @@ public: { public: std::string hoverName; - vstd::assigner as; const CGHeroInstance *h; char descr[100]; // "XXX is a level Y ZZZ with N artifacts" @@ -899,6 +895,10 @@ public: HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H); void show(SDL_Surface * to); + private: + int *_sel; + const int _id; + } *h1, *h2; //recruitable heroes CPicture *bg; //background @@ -1179,7 +1179,7 @@ class CExchangeWindow : public CWindowWithGarrison, public CWindowWithArtifacts public: - const CGHeroInstance * heroInst[2]; + const CGHeroInstance* heroInst[2]; CArtifactsOfHero * artifs[2]; void close(); @@ -1231,7 +1231,7 @@ public: void deactivate(); void show(SDL_Surface * to); - CPuzzleWindow(const int3 &grailPos, float discoveredRatio); + CPuzzleWindow(const int3 &grailPos, double discoveredRatio); ~CPuzzleWindow(); }; @@ -1367,5 +1367,3 @@ public: CIntObject *createCreWindow(const CStack *s); CIntObject *createCreWindow(int Cid, int Type, int creatureCount); CIntObject *createCreWindow(const CStackInstance *s, int type, boost::function Upg = 0, boost::function Dsm = 0, UpgradeInfo *ui = NULL); - -#endif //__GUICLASSES_H__ diff --git a/client/Graphics.cpp b/client/Graphics.cpp index 139f37d44..e58d979e7 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -1,16 +1,10 @@ -#include "../stdafx.h" +#include "StdInc.h" #include "Graphics.h" + #include "CDefHandler.h" #include "SDL_Extensions.h" #include -#include -#include -#include -#include -#include -#include -#include -#include "../CThreadHelper.h" +#include "../lib/CThreadHelper.h" #include "CGameInfo.h" #include "../lib/CLodHandler.h" #include "../lib/VCMI_Lib.h" @@ -25,6 +19,7 @@ #include "../lib/CGameState.h" #include "../lib/JsonNode.h" #include "../lib/vcmi_endian.h" +#include "../lib/GameConstants.h" using namespace boost::assign; using namespace CSDL_Ext; @@ -74,7 +69,7 @@ SDL_Surface * Graphics::drawHeroInfoWin(const InfoAboutHero &curh) if(curh.details) { - for (int i = 0; i < PRIMARY_SKILLS; i++) + for (int i = 0; i < GameConstants::PRIMARY_SKILLS; i++) { SDL_itoa(curh.details->primskills[i], buf, 10); printAtMiddle(buf,84+28*i,70,FONT_SMALL,zwykly,ret); @@ -139,7 +134,7 @@ SDL_Surface * Graphics::drawTownInfoWin( const InfoAboutTown & curh ) if (curh.tType) { pom = curh.tType->typeID*2; if (!curh.fortLevel) - pom += F_NUMBER*2; + pom += GameConstants::F_NUMBER*2; if(curh.built) pom++; blitAt(bigTownPic->ourImages[pom].bitmap,13,13,ret); @@ -167,7 +162,7 @@ void Graphics::loadPaletteAndColors() std::string pals = bitmaph->getTextFile("PLAYERS.PAL", FILE_OTHER); playerColorPalette = new SDL_Color[256]; neutralColor = new SDL_Color; - playerColors = new SDL_Color[PLAYER_LIMIT]; + playerColors = new SDL_Color[GameConstants::PLAYER_LIMIT]; int startPoint = 24; //beginning byte; used to read for(int i=0; i<256; ++i) { @@ -181,7 +176,8 @@ void Graphics::loadPaletteAndColors() neutralColorPalette = new SDL_Color[32]; std::ifstream ncp; - ncp.open(DATA_DIR "/config/NEUTRAL.PAL", std::ios::binary); + std::string neutralFile = GameConstants::DATA_DIR + "/config/NEUTRAL.PAL"; + ncp.open(neutralFile.c_str(), std::ios::binary); for(int i=0; i<32; ++i) { ncp.read((char*)&neutralColorPalette[i].r,1); @@ -202,7 +198,7 @@ void Graphics::loadPaletteAndColors() playerColors[i].unused = 0; } neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84; neutralColor->unused = 0x0;//gray - const JsonNode config(DATA_DIR "/config/town_pictures.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/town_pictures.json"); BOOST_FOREACH(const JsonNode &p, config["town_pictures"].Vector()) { townBgs.push_back(p["town_background"].String()); @@ -213,7 +209,7 @@ void Graphics::loadPaletteAndColors() void Graphics::initializeBattleGraphics() { - const JsonNode config(DATA_DIR "/config/battles_graphics.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/battles_graphics.json"); // Reserve enough space for the terrains int idx = config["backgrounds"].Vector().size(); @@ -302,14 +298,14 @@ Graphics::Graphics() tasks += GET_DEF_ESS(spellscr,"SPELLSCR.DEF"); tasks += GET_DEF_ESS(heroMoveArrows,"ADAG.DEF"); - const JsonNode config(DATA_DIR "/config/creature_backgrounds.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/creature_backgrounds.json"); BOOST_FOREACH(const JsonNode &b, config["backgrounds"].Vector()) { const int id = b["id"].Float(); tasks += GET_SURFACE(backgrounds[id], b["bg130"].String()); tasks += GET_SURFACE(backgroundsm[id], b["bg120"].String()); } - CThreadHelper th(&tasks,std::max((unsigned int)1,boost::thread::hardware_concurrency())); + CThreadHelper th(&tasks,std::max((ui32)1,boost::thread::hardware_concurrency())); th.run(); for(size_t y=0; y < heroMoveArrows->ourImages.size(); ++y) @@ -336,7 +332,7 @@ Graphics::Graphics() } void Graphics::loadHeroPortraits() { - const JsonNode config(DATA_DIR "/config/portraits.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/portraits.json"); BOOST_FOREACH(const JsonNode &portrait_node, config["hero_portrait"].Vector()) { std::string filename = portrait_node["filename"].String(); @@ -362,7 +358,7 @@ void Graphics::loadHeroPortraits() void Graphics::loadWallPositions() { - const JsonNode config(DATA_DIR "/config/wall_pos.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/wall_pos.json"); BOOST_FOREACH(const JsonNode &town, config["towns"].Vector()) { int townID = town["id"].Float(); @@ -381,7 +377,7 @@ void Graphics::loadHeroAnims() std::vector > rotations; //first - group number to be rotated1, second - group number after rotation1 rotations += std::make_pair(6,10), std::make_pair(7,11), std::make_pair(8,12), std::make_pair(1,13), std::make_pair(2,14), std::make_pair(3,15); - for(size_t i=0; i Graphics::*, void Graphics::loadHeroFlags() { using namespace boost::assign; - timeHandler th; + StopWatch th; std::pair Graphics::*, std::vector > pr[4]; pr[0].first = &Graphics::flags1; pr[0].second+=("ABF01L.DEF"),("ABF01G.DEF"),("ABF01R.DEF"),("ABF01D.DEF"),("ABF01B.DEF"), @@ -508,7 +504,7 @@ void Graphics::loadHeroFlags() grupa.create_thread(boost::bind(&Graphics::loadHeroFlags,this,boost::ref(pr[g]),true)); } grupa.join_all(); - tlog0 << "Loading and transforming heroes' flags: "<ourImages[1].bitmap; else if (ID==-3) - return smallIcons->ourImages[2+F_NUMBER*4].bitmap; - else if (ID>F_NUMBER || ID<-3) + return smallIcons->ourImages[2+GameConstants::F_NUMBER*4].bitmap; + else if (ID>GameConstants::F_NUMBER || ID<-3) #ifndef __GNUC__ throw new std::exception("Invalid ID"); #else @@ -528,7 +524,7 @@ SDL_Surface * Graphics::getPic(int ID, bool fort, bool builded) { int pom = 3; if(!fort) - pom+=F_NUMBER*2; + pom+=GameConstants::F_NUMBER*2; pom += ID*2; if (!builded) pom--; @@ -543,7 +539,7 @@ void Graphics::blueToPlayersAdv(SDL_Surface * sur, int player) if(sur->format->BitsPerPixel == 8) { SDL_Color *palette = NULL; - if(player < PLAYER_LIMIT && player >= 0) + if(player < GameConstants::PLAYER_LIMIT && player >= 0) { palette = playerColorPalette + 32*player; } @@ -633,7 +629,8 @@ void Graphics::loadTrueType() bool ttfPresent = false;//was TTF initialised or not for(int i = 0; i < FONTS_NUMBER; i++) fontsTrueType[i] = NULL; - std::ifstream ff(DATA_DIR "/config/fonts.txt"); + std::string fontsFile = GameConstants::DATA_DIR + "/config/fonts.txt"; + std::ifstream ff(fontsFile.c_str()); while(!ff.eof()) { int enabl, fntID, fntSize; @@ -653,7 +650,7 @@ void Graphics::loadTrueType() TTF_Init(); atexit(TTF_Quit); }; - fntName = DATA_DIR + ( "/Fonts/" + fntName); + fntName = GameConstants::DATA_DIR + ( "/Fonts/" + fntName); fontsTrueType[fntID] = TTF_OpenFont(fntName.c_str(),fntSize); } } @@ -664,7 +661,7 @@ void Graphics::loadTrueType() Font * Graphics::loadFont( const char * name ) { int len = 0; - unsigned char * hlp = bitmaph->giveFile(name, FILE_FONT, &len); + ui8 * hlp = bitmaph->giveFile(name, FILE_FONT, &len); if(!hlp || !len) { tlog1 << "Error: cannot load font: " << name << std::endl; @@ -707,7 +704,7 @@ CDefEssential * Graphics::getDef( const CGDefInfo * info ) void Graphics::loadErmuToPicture() { //loading ERMU to picture - const JsonNode config(DATA_DIR "/config/ERMU_to_picture.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/ERMU_to_picture.json"); int etp_idx = 0; BOOST_FOREACH(const JsonNode &etp, config["ERMU_to_picture"].Vector()) { int idx = 0; @@ -722,7 +719,7 @@ void Graphics::loadErmuToPicture() assert (etp_idx == 44); } -Font::Font(unsigned char *Data) +Font::Font(ui8 *Data) { data = Data; int i = 0; @@ -758,7 +755,7 @@ int Font::getWidth(const char *text ) const for(int i = 0; i < length; i++) { - unsigned char c = text[i]; + ui8 c = text[i]; ret += chars[c].width + chars[c].unknown1 + chars[c].unknown2; } @@ -767,7 +764,7 @@ int Font::getWidth(const char *text ) const int Font::getCharWidth( char c ) const { - const Char &C = chars[(unsigned char)c]; + const Char &C = chars[(ui8)c]; return C.width + C.unknown1 + C.unknown2;; } diff --git a/client/Graphics.h b/client/Graphics.h index 9f2a47829..1f3561b2c 100644 --- a/client/Graphics.h +++ b/client/Graphics.h @@ -1,9 +1,9 @@ -#ifndef __GRAPHICS_H__ -#define __GRAPHICS_H__ +#pragma once + -#include "../global.h" #include "FontBase.h" #include "GUIBase.h" +#include "../lib/GameConstants.h" /* * Graphics.h, part of VCMI engine @@ -80,13 +80,13 @@ public: std::vector< std::string > buildingPics;//filenames of def with building images (used rarely, too big to keep them loaded) std::vector< std::string > townBgs;//backgrounds of town std::vector< std::string > guildBgs;// name of bitmaps with imgs for mage guild screen - std::map ERMUtoPicture[F_NUMBER]; //maps building ID to it's picture's name for each town type + std::map ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type //for battles std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type std::vector< std::string > battleHeroes; //battleHeroes[hero type] - name of def that has hero animation for battle std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names CDefEssential * spellEffectsPics; //bitmaps representing spells affecting a stack in battle - std::vector< Point > wallPositions[F_NUMBER]; //positions of different pieces of wall + std::vector< Point > wallPositions[GameConstants::F_NUMBER]; //positions of different pieces of wall //abilities CDefEssential * abils32, * abils44, * abils82; //spells @@ -114,5 +114,3 @@ public: }; extern Graphics * graphics; - -#endif // __GRAPHICS_H__ diff --git a/client/Makefile.am b/client/Makefile.am index e42f4e101..84158f3b9 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -1,23 +1,59 @@ bin_PROGRAMS = vcmiclient +BUILT_SOURCES = StdInc.h.gch +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -c $< -vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.la @SDL_LIBS@ @FFMPEG_LIBS@ @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lrt +vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.la @SDL_LIBS@ @FFMPEG_LIBS@ @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lrt -lz vcmiclient_CXXFLAGS = @SDL_CFLAGS@ @FFMPEG_CXXFLAGS@ vcmiclient_LDFLAGS = -L$(top_builddir)/lib vcmiclient_SOURCES = \ ../CCallback.cpp \ ../CCallback.h \ - ../CConsoleHandler.cpp \ - ../CConsoleHandler.h \ - ../CThreadHelper.cpp \ - ../CThreadHelper.h \ + ./BattleInterface/CAttackAnimation.cpp \ + ./BattleInterface/CAttackAnimation.h \ + ./BattleInterface/CBattleAnimation.cpp \ + ./BattleInterface/CBattleAnimation.h \ + ./BattleInterface/CBattleConsole.cpp \ + ./BattleInterface/CBattleConsole.h \ + ./BattleInterface/CBattleHero.cpp \ + ./BattleInterface/CBattleHero.h \ + ./BattleInterface/CBattleInterface.cpp \ + ./BattleInterface/CBattleInterface.h \ + ./BattleInterface/CBattleOptionsWindow.cpp \ + ./BattleInterface/CBattleOptionsWindow.h \ + ./BattleInterface/CBattleResultWindow.cpp \ + ./BattleInterface/CBattleResultWindow.h \ + ./BattleInterface/CBattleStackAnimation.cpp \ + ./BattleInterface/CBattleStackAnimation.h \ + ./BattleInterface/CDefenceAnimation.cpp \ + ./BattleInterface/CDefenceAnimation.h \ + ./BattleInterface/CDummyAnimation.cpp \ + ./BattleInterface/CDummyAnimation.h \ + ./BattleInterface/CHexFieldControl.cpp \ + ./BattleInterface/CHexFieldControl.h \ + ./BattleInterface/CMeleeAttackAnimation.cpp \ + ./BattleInterface/CMeleeAttackAnimation.h \ + ./BattleInterface/CMovementAnimation.cpp \ + ./BattleInterface/CMovementAnimation.h \ + ./BattleInterface/CMovementEndAnimation.cpp \ + ./BattleInterface/CMovementEndAnimation.h \ + ./BattleInterface/CMovementStartAnimation.cpp \ + ./BattleInterface/CMovementStartAnimation.h \ + ./BattleInterface/CReverseAnimation.cpp \ + ./BattleInterface/CReverseAnimation.h \ + ./BattleInterface/CShootingAnimation.cpp \ + ./BattleInterface/CShootingAnimation.h \ + ./BattleInterface/CSpellEffectAnimation.cpp \ + ./BattleInterface/CSpellEffectAnimation.h \ + ./BattleInterface/CStackQueue.cpp \ + ./BattleInterface/CStackQueue.h \ + ./BattleInterface/SStackAttackedInfo.h \ AdventureMapButton.cpp \ AdventureMapButton.h \ CAdvmapInterface.cpp \ CAdvmapInterface.h \ CAnimation.cpp \ CAnimation.h \ - CBattleInterface.cpp \ - CBattleInterface.h \ CBitmapHandler.cpp \ CBitmapHandler.h \ CCastleInterface.cpp \ diff --git a/client/Makefile.in b/client/Makefile.in index 2d0f1ebc4..55377deea 100644 --- a/client/Makefile.in +++ b/client/Makefile.in @@ -59,12 +59,28 @@ CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_vcmiclient_OBJECTS = vcmiclient-CCallback.$(OBJEXT) \ - vcmiclient-CConsoleHandler.$(OBJEXT) \ - vcmiclient-CThreadHelper.$(OBJEXT) \ + vcmiclient-CAttackAnimation.$(OBJEXT) \ + vcmiclient-CBattleAnimation.$(OBJEXT) \ + vcmiclient-CBattleConsole.$(OBJEXT) \ + vcmiclient-CBattleHero.$(OBJEXT) \ + vcmiclient-CBattleInterface.$(OBJEXT) \ + vcmiclient-CBattleOptionsWindow.$(OBJEXT) \ + vcmiclient-CBattleResultWindow.$(OBJEXT) \ + vcmiclient-CBattleStackAnimation.$(OBJEXT) \ + vcmiclient-CDefenceAnimation.$(OBJEXT) \ + vcmiclient-CDummyAnimation.$(OBJEXT) \ + vcmiclient-CHexFieldControl.$(OBJEXT) \ + vcmiclient-CMeleeAttackAnimation.$(OBJEXT) \ + vcmiclient-CMovementAnimation.$(OBJEXT) \ + vcmiclient-CMovementEndAnimation.$(OBJEXT) \ + vcmiclient-CMovementStartAnimation.$(OBJEXT) \ + vcmiclient-CReverseAnimation.$(OBJEXT) \ + vcmiclient-CShootingAnimation.$(OBJEXT) \ + vcmiclient-CSpellEffectAnimation.$(OBJEXT) \ + vcmiclient-CStackQueue.$(OBJEXT) \ vcmiclient-AdventureMapButton.$(OBJEXT) \ vcmiclient-CAdvmapInterface.$(OBJEXT) \ vcmiclient-CAnimation.$(OBJEXT) \ - vcmiclient-CBattleInterface.$(OBJEXT) \ vcmiclient-CBitmapHandler.$(OBJEXT) \ vcmiclient-CCastleInterface.$(OBJEXT) \ vcmiclient-CConfigHandler.$(OBJEXT) \ @@ -276,24 +292,58 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.la @SDL_LIBS@ @FFMPEG_LIBS@ @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lrt +BUILT_SOURCES = StdInc.h.gch +vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.la @SDL_LIBS@ @FFMPEG_LIBS@ @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lrt -lz vcmiclient_CXXFLAGS = @SDL_CFLAGS@ @FFMPEG_CXXFLAGS@ vcmiclient_LDFLAGS = -L$(top_builddir)/lib vcmiclient_SOURCES = \ ../CCallback.cpp \ ../CCallback.h \ - ../CConsoleHandler.cpp \ - ../CConsoleHandler.h \ - ../CThreadHelper.cpp \ - ../CThreadHelper.h \ + ./BattleInterface/CAttackAnimation.cpp \ + ./BattleInterface/CAttackAnimation.h \ + ./BattleInterface/CBattleAnimation.cpp \ + ./BattleInterface/CBattleAnimation.h \ + ./BattleInterface/CBattleConsole.cpp \ + ./BattleInterface/CBattleConsole.h \ + ./BattleInterface/CBattleHero.cpp \ + ./BattleInterface/CBattleHero.h \ + ./BattleInterface/CBattleInterface.cpp \ + ./BattleInterface/CBattleInterface.h \ + ./BattleInterface/CBattleOptionsWindow.cpp \ + ./BattleInterface/CBattleOptionsWindow.h \ + ./BattleInterface/CBattleResultWindow.cpp \ + ./BattleInterface/CBattleResultWindow.h \ + ./BattleInterface/CBattleStackAnimation.cpp \ + ./BattleInterface/CBattleStackAnimation.h \ + ./BattleInterface/CDefenceAnimation.cpp \ + ./BattleInterface/CDefenceAnimation.h \ + ./BattleInterface/CDummyAnimation.cpp \ + ./BattleInterface/CDummyAnimation.h \ + ./BattleInterface/CHexFieldControl.cpp \ + ./BattleInterface/CHexFieldControl.h \ + ./BattleInterface/CMeleeAttackAnimation.cpp \ + ./BattleInterface/CMeleeAttackAnimation.h \ + ./BattleInterface/CMovementAnimation.cpp \ + ./BattleInterface/CMovementAnimation.h \ + ./BattleInterface/CMovementEndAnimation.cpp \ + ./BattleInterface/CMovementEndAnimation.h \ + ./BattleInterface/CMovementStartAnimation.cpp \ + ./BattleInterface/CMovementStartAnimation.h \ + ./BattleInterface/CReverseAnimation.cpp \ + ./BattleInterface/CReverseAnimation.h \ + ./BattleInterface/CShootingAnimation.cpp \ + ./BattleInterface/CShootingAnimation.h \ + ./BattleInterface/CSpellEffectAnimation.cpp \ + ./BattleInterface/CSpellEffectAnimation.h \ + ./BattleInterface/CStackQueue.cpp \ + ./BattleInterface/CStackQueue.h \ + ./BattleInterface/SStackAttackedInfo.h \ AdventureMapButton.cpp \ AdventureMapButton.h \ CAdvmapInterface.cpp \ CAdvmapInterface.h \ CAnimation.cpp \ CAnimation.h \ - CBattleInterface.cpp \ - CBattleInterface.h \ CBitmapHandler.cpp \ CBitmapHandler.h \ CCastleInterface.cpp \ @@ -349,7 +399,8 @@ vcmiclient_SOURCES = \ SDL_framerate.cpp \ SDL_framerate.h -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj @@ -439,27 +490,43 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-AdventureMapButton.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CAdvmapInterface.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CAnimation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CAttackAnimation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CBattleAnimation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CBattleConsole.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CBattleHero.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CBattleInterface.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CBattleOptionsWindow.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CBattleResultWindow.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CBattleStackAnimation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CBitmapHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CCallback.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CCastleInterface.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CConfigHandler.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CConsoleHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CCreatureAnimation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CCreatureWindow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CCursorHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CDefHandler.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CDefenceAnimation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CDummyAnimation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CGameInfo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CHeroWindow.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CHexFieldControl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CKingdomInterface.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMT.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMeleeAttackAnimation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMessage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMovementAnimation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMovementEndAnimation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMovementStartAnimation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMusicHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CPlayerInterface.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CPreGame.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CReverseAnimation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CShootingAnimation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CSndHandler.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CSpellEffectAnimation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CSpellWindow.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CThreadHelper.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CStackQueue.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CVideoHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-Client.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-GUIBase.Po@am__quote@ @@ -510,37 +577,309 @@ vcmiclient-CCallback.obj: ../CCallback.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CCallback.obj `if test -f '../CCallback.cpp'; then $(CYGPATH_W) '../CCallback.cpp'; else $(CYGPATH_W) '$(srcdir)/../CCallback.cpp'; fi` -vcmiclient-CConsoleHandler.o: ../CConsoleHandler.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CConsoleHandler.o -MD -MP -MF $(DEPDIR)/vcmiclient-CConsoleHandler.Tpo -c -o vcmiclient-CConsoleHandler.o `test -f '../CConsoleHandler.cpp' || echo '$(srcdir)/'`../CConsoleHandler.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CConsoleHandler.Tpo $(DEPDIR)/vcmiclient-CConsoleHandler.Po +vcmiclient-CAttackAnimation.o: ./BattleInterface/CAttackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CAttackAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CAttackAnimation.Tpo -c -o vcmiclient-CAttackAnimation.o `test -f './BattleInterface/CAttackAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CAttackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CAttackAnimation.Tpo $(DEPDIR)/vcmiclient-CAttackAnimation.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CConsoleHandler.cpp' object='vcmiclient-CConsoleHandler.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CAttackAnimation.cpp' object='vcmiclient-CAttackAnimation.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CConsoleHandler.o `test -f '../CConsoleHandler.cpp' || echo '$(srcdir)/'`../CConsoleHandler.cpp +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CAttackAnimation.o `test -f './BattleInterface/CAttackAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CAttackAnimation.cpp -vcmiclient-CConsoleHandler.obj: ../CConsoleHandler.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CConsoleHandler.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CConsoleHandler.Tpo -c -o vcmiclient-CConsoleHandler.obj `if test -f '../CConsoleHandler.cpp'; then $(CYGPATH_W) '../CConsoleHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/../CConsoleHandler.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CConsoleHandler.Tpo $(DEPDIR)/vcmiclient-CConsoleHandler.Po +vcmiclient-CAttackAnimation.obj: ./BattleInterface/CAttackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CAttackAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CAttackAnimation.Tpo -c -o vcmiclient-CAttackAnimation.obj `if test -f './BattleInterface/CAttackAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CAttackAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CAttackAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CAttackAnimation.Tpo $(DEPDIR)/vcmiclient-CAttackAnimation.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CConsoleHandler.cpp' object='vcmiclient-CConsoleHandler.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CAttackAnimation.cpp' object='vcmiclient-CAttackAnimation.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CConsoleHandler.obj `if test -f '../CConsoleHandler.cpp'; then $(CYGPATH_W) '../CConsoleHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/../CConsoleHandler.cpp'; fi` +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CAttackAnimation.obj `if test -f './BattleInterface/CAttackAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CAttackAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CAttackAnimation.cpp'; fi` -vcmiclient-CThreadHelper.o: ../CThreadHelper.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CThreadHelper.o -MD -MP -MF $(DEPDIR)/vcmiclient-CThreadHelper.Tpo -c -o vcmiclient-CThreadHelper.o `test -f '../CThreadHelper.cpp' || echo '$(srcdir)/'`../CThreadHelper.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CThreadHelper.Tpo $(DEPDIR)/vcmiclient-CThreadHelper.Po +vcmiclient-CBattleAnimation.o: ./BattleInterface/CBattleAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleAnimation.Tpo -c -o vcmiclient-CBattleAnimation.o `test -f './BattleInterface/CBattleAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleAnimation.Tpo $(DEPDIR)/vcmiclient-CBattleAnimation.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CThreadHelper.cpp' object='vcmiclient-CThreadHelper.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleAnimation.cpp' object='vcmiclient-CBattleAnimation.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CThreadHelper.o `test -f '../CThreadHelper.cpp' || echo '$(srcdir)/'`../CThreadHelper.cpp +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleAnimation.o `test -f './BattleInterface/CBattleAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleAnimation.cpp -vcmiclient-CThreadHelper.obj: ../CThreadHelper.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CThreadHelper.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CThreadHelper.Tpo -c -o vcmiclient-CThreadHelper.obj `if test -f '../CThreadHelper.cpp'; then $(CYGPATH_W) '../CThreadHelper.cpp'; else $(CYGPATH_W) '$(srcdir)/../CThreadHelper.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CThreadHelper.Tpo $(DEPDIR)/vcmiclient-CThreadHelper.Po +vcmiclient-CBattleAnimation.obj: ./BattleInterface/CBattleAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleAnimation.Tpo -c -o vcmiclient-CBattleAnimation.obj `if test -f './BattleInterface/CBattleAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleAnimation.Tpo $(DEPDIR)/vcmiclient-CBattleAnimation.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CThreadHelper.cpp' object='vcmiclient-CThreadHelper.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleAnimation.cpp' object='vcmiclient-CBattleAnimation.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CThreadHelper.obj `if test -f '../CThreadHelper.cpp'; then $(CYGPATH_W) '../CThreadHelper.cpp'; else $(CYGPATH_W) '$(srcdir)/../CThreadHelper.cpp'; fi` +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleAnimation.obj `if test -f './BattleInterface/CBattleAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleAnimation.cpp'; fi` + +vcmiclient-CBattleConsole.o: ./BattleInterface/CBattleConsole.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleConsole.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleConsole.Tpo -c -o vcmiclient-CBattleConsole.o `test -f './BattleInterface/CBattleConsole.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleConsole.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleConsole.Tpo $(DEPDIR)/vcmiclient-CBattleConsole.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleConsole.cpp' object='vcmiclient-CBattleConsole.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleConsole.o `test -f './BattleInterface/CBattleConsole.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleConsole.cpp + +vcmiclient-CBattleConsole.obj: ./BattleInterface/CBattleConsole.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleConsole.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleConsole.Tpo -c -o vcmiclient-CBattleConsole.obj `if test -f './BattleInterface/CBattleConsole.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleConsole.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleConsole.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleConsole.Tpo $(DEPDIR)/vcmiclient-CBattleConsole.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleConsole.cpp' object='vcmiclient-CBattleConsole.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleConsole.obj `if test -f './BattleInterface/CBattleConsole.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleConsole.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleConsole.cpp'; fi` + +vcmiclient-CBattleHero.o: ./BattleInterface/CBattleHero.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleHero.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleHero.Tpo -c -o vcmiclient-CBattleHero.o `test -f './BattleInterface/CBattleHero.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleHero.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleHero.Tpo $(DEPDIR)/vcmiclient-CBattleHero.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleHero.cpp' object='vcmiclient-CBattleHero.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleHero.o `test -f './BattleInterface/CBattleHero.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleHero.cpp + +vcmiclient-CBattleHero.obj: ./BattleInterface/CBattleHero.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleHero.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleHero.Tpo -c -o vcmiclient-CBattleHero.obj `if test -f './BattleInterface/CBattleHero.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleHero.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleHero.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleHero.Tpo $(DEPDIR)/vcmiclient-CBattleHero.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleHero.cpp' object='vcmiclient-CBattleHero.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleHero.obj `if test -f './BattleInterface/CBattleHero.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleHero.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleHero.cpp'; fi` + +vcmiclient-CBattleInterface.o: ./BattleInterface/CBattleInterface.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleInterface.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleInterface.Tpo -c -o vcmiclient-CBattleInterface.o `test -f './BattleInterface/CBattleInterface.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleInterface.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleInterface.Tpo $(DEPDIR)/vcmiclient-CBattleInterface.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleInterface.cpp' object='vcmiclient-CBattleInterface.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleInterface.o `test -f './BattleInterface/CBattleInterface.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleInterface.cpp + +vcmiclient-CBattleInterface.obj: ./BattleInterface/CBattleInterface.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleInterface.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleInterface.Tpo -c -o vcmiclient-CBattleInterface.obj `if test -f './BattleInterface/CBattleInterface.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleInterface.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleInterface.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleInterface.Tpo $(DEPDIR)/vcmiclient-CBattleInterface.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleInterface.cpp' object='vcmiclient-CBattleInterface.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleInterface.obj `if test -f './BattleInterface/CBattleInterface.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleInterface.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleInterface.cpp'; fi` + +vcmiclient-CBattleOptionsWindow.o: ./BattleInterface/CBattleOptionsWindow.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleOptionsWindow.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleOptionsWindow.Tpo -c -o vcmiclient-CBattleOptionsWindow.o `test -f './BattleInterface/CBattleOptionsWindow.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleOptionsWindow.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleOptionsWindow.Tpo $(DEPDIR)/vcmiclient-CBattleOptionsWindow.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleOptionsWindow.cpp' object='vcmiclient-CBattleOptionsWindow.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleOptionsWindow.o `test -f './BattleInterface/CBattleOptionsWindow.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleOptionsWindow.cpp + +vcmiclient-CBattleOptionsWindow.obj: ./BattleInterface/CBattleOptionsWindow.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleOptionsWindow.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleOptionsWindow.Tpo -c -o vcmiclient-CBattleOptionsWindow.obj `if test -f './BattleInterface/CBattleOptionsWindow.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleOptionsWindow.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleOptionsWindow.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleOptionsWindow.Tpo $(DEPDIR)/vcmiclient-CBattleOptionsWindow.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleOptionsWindow.cpp' object='vcmiclient-CBattleOptionsWindow.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleOptionsWindow.obj `if test -f './BattleInterface/CBattleOptionsWindow.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleOptionsWindow.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleOptionsWindow.cpp'; fi` + +vcmiclient-CBattleResultWindow.o: ./BattleInterface/CBattleResultWindow.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleResultWindow.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleResultWindow.Tpo -c -o vcmiclient-CBattleResultWindow.o `test -f './BattleInterface/CBattleResultWindow.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleResultWindow.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleResultWindow.Tpo $(DEPDIR)/vcmiclient-CBattleResultWindow.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleResultWindow.cpp' object='vcmiclient-CBattleResultWindow.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleResultWindow.o `test -f './BattleInterface/CBattleResultWindow.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleResultWindow.cpp + +vcmiclient-CBattleResultWindow.obj: ./BattleInterface/CBattleResultWindow.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleResultWindow.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleResultWindow.Tpo -c -o vcmiclient-CBattleResultWindow.obj `if test -f './BattleInterface/CBattleResultWindow.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleResultWindow.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleResultWindow.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleResultWindow.Tpo $(DEPDIR)/vcmiclient-CBattleResultWindow.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleResultWindow.cpp' object='vcmiclient-CBattleResultWindow.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleResultWindow.obj `if test -f './BattleInterface/CBattleResultWindow.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleResultWindow.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleResultWindow.cpp'; fi` + +vcmiclient-CBattleStackAnimation.o: ./BattleInterface/CBattleStackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleStackAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleStackAnimation.Tpo -c -o vcmiclient-CBattleStackAnimation.o `test -f './BattleInterface/CBattleStackAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleStackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleStackAnimation.Tpo $(DEPDIR)/vcmiclient-CBattleStackAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleStackAnimation.cpp' object='vcmiclient-CBattleStackAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleStackAnimation.o `test -f './BattleInterface/CBattleStackAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CBattleStackAnimation.cpp + +vcmiclient-CBattleStackAnimation.obj: ./BattleInterface/CBattleStackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleStackAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleStackAnimation.Tpo -c -o vcmiclient-CBattleStackAnimation.obj `if test -f './BattleInterface/CBattleStackAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleStackAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleStackAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleStackAnimation.Tpo $(DEPDIR)/vcmiclient-CBattleStackAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CBattleStackAnimation.cpp' object='vcmiclient-CBattleStackAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleStackAnimation.obj `if test -f './BattleInterface/CBattleStackAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CBattleStackAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CBattleStackAnimation.cpp'; fi` + +vcmiclient-CDefenceAnimation.o: ./BattleInterface/CDefenceAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CDefenceAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CDefenceAnimation.Tpo -c -o vcmiclient-CDefenceAnimation.o `test -f './BattleInterface/CDefenceAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CDefenceAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CDefenceAnimation.Tpo $(DEPDIR)/vcmiclient-CDefenceAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CDefenceAnimation.cpp' object='vcmiclient-CDefenceAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CDefenceAnimation.o `test -f './BattleInterface/CDefenceAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CDefenceAnimation.cpp + +vcmiclient-CDefenceAnimation.obj: ./BattleInterface/CDefenceAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CDefenceAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CDefenceAnimation.Tpo -c -o vcmiclient-CDefenceAnimation.obj `if test -f './BattleInterface/CDefenceAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CDefenceAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CDefenceAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CDefenceAnimation.Tpo $(DEPDIR)/vcmiclient-CDefenceAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CDefenceAnimation.cpp' object='vcmiclient-CDefenceAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CDefenceAnimation.obj `if test -f './BattleInterface/CDefenceAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CDefenceAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CDefenceAnimation.cpp'; fi` + +vcmiclient-CDummyAnimation.o: ./BattleInterface/CDummyAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CDummyAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CDummyAnimation.Tpo -c -o vcmiclient-CDummyAnimation.o `test -f './BattleInterface/CDummyAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CDummyAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CDummyAnimation.Tpo $(DEPDIR)/vcmiclient-CDummyAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CDummyAnimation.cpp' object='vcmiclient-CDummyAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CDummyAnimation.o `test -f './BattleInterface/CDummyAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CDummyAnimation.cpp + +vcmiclient-CDummyAnimation.obj: ./BattleInterface/CDummyAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CDummyAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CDummyAnimation.Tpo -c -o vcmiclient-CDummyAnimation.obj `if test -f './BattleInterface/CDummyAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CDummyAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CDummyAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CDummyAnimation.Tpo $(DEPDIR)/vcmiclient-CDummyAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CDummyAnimation.cpp' object='vcmiclient-CDummyAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CDummyAnimation.obj `if test -f './BattleInterface/CDummyAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CDummyAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CDummyAnimation.cpp'; fi` + +vcmiclient-CHexFieldControl.o: ./BattleInterface/CHexFieldControl.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CHexFieldControl.o -MD -MP -MF $(DEPDIR)/vcmiclient-CHexFieldControl.Tpo -c -o vcmiclient-CHexFieldControl.o `test -f './BattleInterface/CHexFieldControl.cpp' || echo '$(srcdir)/'`./BattleInterface/CHexFieldControl.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CHexFieldControl.Tpo $(DEPDIR)/vcmiclient-CHexFieldControl.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CHexFieldControl.cpp' object='vcmiclient-CHexFieldControl.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CHexFieldControl.o `test -f './BattleInterface/CHexFieldControl.cpp' || echo '$(srcdir)/'`./BattleInterface/CHexFieldControl.cpp + +vcmiclient-CHexFieldControl.obj: ./BattleInterface/CHexFieldControl.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CHexFieldControl.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CHexFieldControl.Tpo -c -o vcmiclient-CHexFieldControl.obj `if test -f './BattleInterface/CHexFieldControl.cpp'; then $(CYGPATH_W) './BattleInterface/CHexFieldControl.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CHexFieldControl.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CHexFieldControl.Tpo $(DEPDIR)/vcmiclient-CHexFieldControl.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CHexFieldControl.cpp' object='vcmiclient-CHexFieldControl.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CHexFieldControl.obj `if test -f './BattleInterface/CHexFieldControl.cpp'; then $(CYGPATH_W) './BattleInterface/CHexFieldControl.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CHexFieldControl.cpp'; fi` + +vcmiclient-CMeleeAttackAnimation.o: ./BattleInterface/CMeleeAttackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMeleeAttackAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CMeleeAttackAnimation.Tpo -c -o vcmiclient-CMeleeAttackAnimation.o `test -f './BattleInterface/CMeleeAttackAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CMeleeAttackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CMeleeAttackAnimation.Tpo $(DEPDIR)/vcmiclient-CMeleeAttackAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CMeleeAttackAnimation.cpp' object='vcmiclient-CMeleeAttackAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CMeleeAttackAnimation.o `test -f './BattleInterface/CMeleeAttackAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CMeleeAttackAnimation.cpp + +vcmiclient-CMeleeAttackAnimation.obj: ./BattleInterface/CMeleeAttackAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMeleeAttackAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CMeleeAttackAnimation.Tpo -c -o vcmiclient-CMeleeAttackAnimation.obj `if test -f './BattleInterface/CMeleeAttackAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CMeleeAttackAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CMeleeAttackAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CMeleeAttackAnimation.Tpo $(DEPDIR)/vcmiclient-CMeleeAttackAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CMeleeAttackAnimation.cpp' object='vcmiclient-CMeleeAttackAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CMeleeAttackAnimation.obj `if test -f './BattleInterface/CMeleeAttackAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CMeleeAttackAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CMeleeAttackAnimation.cpp'; fi` + +vcmiclient-CMovementAnimation.o: ./BattleInterface/CMovementAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMovementAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CMovementAnimation.Tpo -c -o vcmiclient-CMovementAnimation.o `test -f './BattleInterface/CMovementAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CMovementAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CMovementAnimation.Tpo $(DEPDIR)/vcmiclient-CMovementAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CMovementAnimation.cpp' object='vcmiclient-CMovementAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CMovementAnimation.o `test -f './BattleInterface/CMovementAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CMovementAnimation.cpp + +vcmiclient-CMovementAnimation.obj: ./BattleInterface/CMovementAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMovementAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CMovementAnimation.Tpo -c -o vcmiclient-CMovementAnimation.obj `if test -f './BattleInterface/CMovementAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CMovementAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CMovementAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CMovementAnimation.Tpo $(DEPDIR)/vcmiclient-CMovementAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CMovementAnimation.cpp' object='vcmiclient-CMovementAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CMovementAnimation.obj `if test -f './BattleInterface/CMovementAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CMovementAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CMovementAnimation.cpp'; fi` + +vcmiclient-CMovementEndAnimation.o: ./BattleInterface/CMovementEndAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMovementEndAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CMovementEndAnimation.Tpo -c -o vcmiclient-CMovementEndAnimation.o `test -f './BattleInterface/CMovementEndAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CMovementEndAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CMovementEndAnimation.Tpo $(DEPDIR)/vcmiclient-CMovementEndAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CMovementEndAnimation.cpp' object='vcmiclient-CMovementEndAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CMovementEndAnimation.o `test -f './BattleInterface/CMovementEndAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CMovementEndAnimation.cpp + +vcmiclient-CMovementEndAnimation.obj: ./BattleInterface/CMovementEndAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMovementEndAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CMovementEndAnimation.Tpo -c -o vcmiclient-CMovementEndAnimation.obj `if test -f './BattleInterface/CMovementEndAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CMovementEndAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CMovementEndAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CMovementEndAnimation.Tpo $(DEPDIR)/vcmiclient-CMovementEndAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CMovementEndAnimation.cpp' object='vcmiclient-CMovementEndAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CMovementEndAnimation.obj `if test -f './BattleInterface/CMovementEndAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CMovementEndAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CMovementEndAnimation.cpp'; fi` + +vcmiclient-CMovementStartAnimation.o: ./BattleInterface/CMovementStartAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMovementStartAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CMovementStartAnimation.Tpo -c -o vcmiclient-CMovementStartAnimation.o `test -f './BattleInterface/CMovementStartAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CMovementStartAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CMovementStartAnimation.Tpo $(DEPDIR)/vcmiclient-CMovementStartAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CMovementStartAnimation.cpp' object='vcmiclient-CMovementStartAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CMovementStartAnimation.o `test -f './BattleInterface/CMovementStartAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CMovementStartAnimation.cpp + +vcmiclient-CMovementStartAnimation.obj: ./BattleInterface/CMovementStartAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMovementStartAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CMovementStartAnimation.Tpo -c -o vcmiclient-CMovementStartAnimation.obj `if test -f './BattleInterface/CMovementStartAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CMovementStartAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CMovementStartAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CMovementStartAnimation.Tpo $(DEPDIR)/vcmiclient-CMovementStartAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CMovementStartAnimation.cpp' object='vcmiclient-CMovementStartAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CMovementStartAnimation.obj `if test -f './BattleInterface/CMovementStartAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CMovementStartAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CMovementStartAnimation.cpp'; fi` + +vcmiclient-CReverseAnimation.o: ./BattleInterface/CReverseAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CReverseAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CReverseAnimation.Tpo -c -o vcmiclient-CReverseAnimation.o `test -f './BattleInterface/CReverseAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CReverseAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CReverseAnimation.Tpo $(DEPDIR)/vcmiclient-CReverseAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CReverseAnimation.cpp' object='vcmiclient-CReverseAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CReverseAnimation.o `test -f './BattleInterface/CReverseAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CReverseAnimation.cpp + +vcmiclient-CReverseAnimation.obj: ./BattleInterface/CReverseAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CReverseAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CReverseAnimation.Tpo -c -o vcmiclient-CReverseAnimation.obj `if test -f './BattleInterface/CReverseAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CReverseAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CReverseAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CReverseAnimation.Tpo $(DEPDIR)/vcmiclient-CReverseAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CReverseAnimation.cpp' object='vcmiclient-CReverseAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CReverseAnimation.obj `if test -f './BattleInterface/CReverseAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CReverseAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CReverseAnimation.cpp'; fi` + +vcmiclient-CShootingAnimation.o: ./BattleInterface/CShootingAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CShootingAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CShootingAnimation.Tpo -c -o vcmiclient-CShootingAnimation.o `test -f './BattleInterface/CShootingAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CShootingAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CShootingAnimation.Tpo $(DEPDIR)/vcmiclient-CShootingAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CShootingAnimation.cpp' object='vcmiclient-CShootingAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CShootingAnimation.o `test -f './BattleInterface/CShootingAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CShootingAnimation.cpp + +vcmiclient-CShootingAnimation.obj: ./BattleInterface/CShootingAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CShootingAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CShootingAnimation.Tpo -c -o vcmiclient-CShootingAnimation.obj `if test -f './BattleInterface/CShootingAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CShootingAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CShootingAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CShootingAnimation.Tpo $(DEPDIR)/vcmiclient-CShootingAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CShootingAnimation.cpp' object='vcmiclient-CShootingAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CShootingAnimation.obj `if test -f './BattleInterface/CShootingAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CShootingAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CShootingAnimation.cpp'; fi` + +vcmiclient-CSpellEffectAnimation.o: ./BattleInterface/CSpellEffectAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CSpellEffectAnimation.o -MD -MP -MF $(DEPDIR)/vcmiclient-CSpellEffectAnimation.Tpo -c -o vcmiclient-CSpellEffectAnimation.o `test -f './BattleInterface/CSpellEffectAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CSpellEffectAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CSpellEffectAnimation.Tpo $(DEPDIR)/vcmiclient-CSpellEffectAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CSpellEffectAnimation.cpp' object='vcmiclient-CSpellEffectAnimation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CSpellEffectAnimation.o `test -f './BattleInterface/CSpellEffectAnimation.cpp' || echo '$(srcdir)/'`./BattleInterface/CSpellEffectAnimation.cpp + +vcmiclient-CSpellEffectAnimation.obj: ./BattleInterface/CSpellEffectAnimation.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CSpellEffectAnimation.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CSpellEffectAnimation.Tpo -c -o vcmiclient-CSpellEffectAnimation.obj `if test -f './BattleInterface/CSpellEffectAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CSpellEffectAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CSpellEffectAnimation.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CSpellEffectAnimation.Tpo $(DEPDIR)/vcmiclient-CSpellEffectAnimation.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CSpellEffectAnimation.cpp' object='vcmiclient-CSpellEffectAnimation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CSpellEffectAnimation.obj `if test -f './BattleInterface/CSpellEffectAnimation.cpp'; then $(CYGPATH_W) './BattleInterface/CSpellEffectAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CSpellEffectAnimation.cpp'; fi` + +vcmiclient-CStackQueue.o: ./BattleInterface/CStackQueue.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CStackQueue.o -MD -MP -MF $(DEPDIR)/vcmiclient-CStackQueue.Tpo -c -o vcmiclient-CStackQueue.o `test -f './BattleInterface/CStackQueue.cpp' || echo '$(srcdir)/'`./BattleInterface/CStackQueue.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CStackQueue.Tpo $(DEPDIR)/vcmiclient-CStackQueue.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CStackQueue.cpp' object='vcmiclient-CStackQueue.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CStackQueue.o `test -f './BattleInterface/CStackQueue.cpp' || echo '$(srcdir)/'`./BattleInterface/CStackQueue.cpp + +vcmiclient-CStackQueue.obj: ./BattleInterface/CStackQueue.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CStackQueue.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CStackQueue.Tpo -c -o vcmiclient-CStackQueue.obj `if test -f './BattleInterface/CStackQueue.cpp'; then $(CYGPATH_W) './BattleInterface/CStackQueue.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CStackQueue.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CStackQueue.Tpo $(DEPDIR)/vcmiclient-CStackQueue.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='./BattleInterface/CStackQueue.cpp' object='vcmiclient-CStackQueue.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CStackQueue.obj `if test -f './BattleInterface/CStackQueue.cpp'; then $(CYGPATH_W) './BattleInterface/CStackQueue.cpp'; else $(CYGPATH_W) '$(srcdir)/./BattleInterface/CStackQueue.cpp'; fi` vcmiclient-AdventureMapButton.o: AdventureMapButton.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-AdventureMapButton.o -MD -MP -MF $(DEPDIR)/vcmiclient-AdventureMapButton.Tpo -c -o vcmiclient-AdventureMapButton.o `test -f 'AdventureMapButton.cpp' || echo '$(srcdir)/'`AdventureMapButton.cpp @@ -590,22 +929,6 @@ vcmiclient-CAnimation.obj: CAnimation.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CAnimation.obj `if test -f 'CAnimation.cpp'; then $(CYGPATH_W) 'CAnimation.cpp'; else $(CYGPATH_W) '$(srcdir)/CAnimation.cpp'; fi` -vcmiclient-CBattleInterface.o: CBattleInterface.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleInterface.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleInterface.Tpo -c -o vcmiclient-CBattleInterface.o `test -f 'CBattleInterface.cpp' || echo '$(srcdir)/'`CBattleInterface.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleInterface.Tpo $(DEPDIR)/vcmiclient-CBattleInterface.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CBattleInterface.cpp' object='vcmiclient-CBattleInterface.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleInterface.o `test -f 'CBattleInterface.cpp' || echo '$(srcdir)/'`CBattleInterface.cpp - -vcmiclient-CBattleInterface.obj: CBattleInterface.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBattleInterface.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CBattleInterface.Tpo -c -o vcmiclient-CBattleInterface.obj `if test -f 'CBattleInterface.cpp'; then $(CYGPATH_W) 'CBattleInterface.cpp'; else $(CYGPATH_W) '$(srcdir)/CBattleInterface.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBattleInterface.Tpo $(DEPDIR)/vcmiclient-CBattleInterface.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CBattleInterface.cpp' object='vcmiclient-CBattleInterface.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CBattleInterface.obj `if test -f 'CBattleInterface.cpp'; then $(CYGPATH_W) 'CBattleInterface.cpp'; else $(CYGPATH_W) '$(srcdir)/CBattleInterface.cpp'; fi` - vcmiclient-CBitmapHandler.o: CBitmapHandler.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CBitmapHandler.o -MD -MP -MF $(DEPDIR)/vcmiclient-CBitmapHandler.Tpo -c -o vcmiclient-CBitmapHandler.o `test -f 'CBitmapHandler.cpp' || echo '$(srcdir)/'`CBitmapHandler.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CBitmapHandler.Tpo $(DEPDIR)/vcmiclient-CBitmapHandler.Po @@ -1111,13 +1434,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -1142,6 +1467,7 @@ distclean-generic: 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-binPROGRAMS clean-generic clean-libtool mostlyclean-am @@ -1212,7 +1538,7 @@ ps-am: uninstall-am: uninstall-binPROGRAMS -.MAKE: install-am install-strip +.MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool ctags distclean distclean-compile \ @@ -1228,6 +1554,8 @@ uninstall-am: uninstall-binPROGRAMS pdf pdf-am ps ps-am tags uninstall uninstall-am \ uninstall-binPROGRAMS +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -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. diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 401d7b70b..e8f271f8b 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -1,4 +1,6 @@ +#include "StdInc.h" #include "../lib/NetPacks.h" + #include "../CCallback.h" #include "Client.h" #include "CPlayerInterface.h" @@ -15,16 +17,13 @@ #include "CSoundBase.h" #include "mapHandler.h" #include "GUIClasses.h" -#include -#include -#include -#include #include "CConfigHandler.h" #include "SDL_Extensions.h" -#include "CBattleInterface.h" +#include "BattleInterface/CBattleInterface.h" #include "../lib/CCampaignHandler.h" #include "../lib/CGameState.h" #include "../lib/BattleState.h" +#include "../lib/GameConstants.h" //macros to avoid code duplication - calls given method with given arguments if interface for specific player is present @@ -337,7 +336,7 @@ void TryMoveHero::applyFirstCl( CClient *cl ) //check if playerint will have the knowledge about movement - if not, directly update maphandler for(std::map::iterator i=cl->playerint.begin();i!=cl->playerint.end();i++) { - if(i->first >= PLAYER_LIMIT) + if(i->first >= GameConstants::PLAYER_LIMIT) continue; TeamState *t = GS(cl)->getPlayerTeam(i->first); if((t->fogOfWarMap[start.x-1][start.y][start.z] || t->fogOfWarMap[end.x-1][end.y][end.z]) @@ -376,7 +375,7 @@ void TryMoveHero::applyCl( CClient *cl ) //notify interfaces about move for(std::map::iterator i=cl->playerint.begin();i!=cl->playerint.end();i++) { - if(i->first >= PLAYER_LIMIT) continue; + if(i->first >= GameConstants::PLAYER_LIMIT) continue; TeamState *t = GS(cl)->getPlayerTeam(i->first); if(t->fogOfWarMap[start.x-1][start.y][start.z] || t->fogOfWarMap[end.x-1][end.y][end.z]) { diff --git a/client/SDL_Extensions.cpp b/client/SDL_Extensions.cpp index fd37bd1c8..b44885291 100644 --- a/client/SDL_Extensions.cpp +++ b/client/SDL_Extensions.cpp @@ -1,14 +1,10 @@ -#include "../stdafx.h" +#include "StdInc.h" #include "SDL_Extensions.h" + #include "SDL_ttf.h" #include "CGameInfo.h" -#include -#include -#include #include "CMessage.h" -#include #include "CDefHandler.h" -#include #include "Graphics.h" #include "GUIBase.h" @@ -323,7 +319,7 @@ void CSDL_Ext::printAtMiddleWB( const std::string & text, int x, int y, EFonts f } } -void printAtMiddle(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2) +void printAtMiddle(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, ui8 quality=2) { if(text.length()==0) return; SDL_Surface * temp; @@ -366,7 +362,7 @@ void CSDL_Ext::printAtMiddle( const std::string & text, int x, int y, EFonts fon printAt(text, nx, ny, font, kolor, dst); } -void printAt(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2, bool refresh=false) +void printAt(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, ui8 quality=2, bool refresh=false) { if (text.length()==0) return; @@ -431,7 +427,7 @@ void CSDL_Ext::printAt( const std::string & text, int x, int y, EFonts font, SDL for(int txti = first; txti < beyondEnd; txti++) { - const unsigned char c = text[txti]; + const ui8 c = text[txti]; x += f->chars[c].unknown1; for(int i = std::max(0, -y); i < f->height && (y + i) < (dst->h - 1); i++) @@ -462,7 +458,7 @@ void CSDL_Ext::printAt( const std::string & text, int x, int y, EFonts font, SDL } } -void printTo(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2) +void printTo(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, ui8 quality=2) { if (text.length()==0) return; @@ -504,7 +500,7 @@ void CSDL_Ext::printTo( const std::string & text, int x, int y, EFonts font, SDL printAt(text, x - f->getWidth(text.c_str()), y - f->height, font, kolor, dst); } -void printToWR(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2) +void printToWR(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, ui8 quality=2) { if (text.length()==0) return; @@ -1049,7 +1045,7 @@ void CSDL_Ext::drawDashedBorder(SDL_Surface * sur, const Rect &r, const int3 &co } } -void CSDL_Ext::setPlayerColor(SDL_Surface * sur, unsigned char player) +void CSDL_Ext::setPlayerColor(SDL_Surface * sur, ui8 player) { if(player==254) return; @@ -1206,7 +1202,7 @@ void CSDL_Ext::applyEffect( SDL_Surface * surf, const SDL_Rect * rect, int mode { for(int yp = rect->y; yp < rect->y + rect->h; ++yp) { - unsigned char * pixels = (unsigned char*)surf->pixels + yp * surf->pitch + xp * surf->format->BytesPerPixel; + ui8 * pixels = (ui8*)surf->pixels + yp * surf->pitch + xp * surf->format->BytesPerPixel; int b = pixels[0]; int g = pixels[1]; @@ -1242,7 +1238,7 @@ void CSDL_Ext::applyEffect( SDL_Surface * surf, const SDL_Rect * rect, int mode { for(int yp = rect->y; yp < rect->y + rect->h; ++yp) { - unsigned char * pixels = (unsigned char*)surf->pixels + yp * surf->pitch + xp * surf->format->BytesPerPixel; + ui8 * pixels = (ui8*)surf->pixels + yp * surf->pitch + xp * surf->format->BytesPerPixel; int b = pixels[0]; int g = pixels[1]; diff --git a/client/SDL_Extensions.h b/client/SDL_Extensions.h index e666f9bee..466e0492f 100644 --- a/client/SDL_Extensions.h +++ b/client/SDL_Extensions.h @@ -1,11 +1,9 @@ -#ifndef __SDL_EXTENSIONS_H__ -#define __SDL_EXTENSIONS_H__ -#include "../global.h" +#pragma once + + +#include "../lib/int3.h" #include "SDL_video.h" #include "SDL_ttf.h" -#include -#include -#include #include "FontBase.h" /* @@ -61,7 +59,7 @@ std::string makeNumberShort(IntType number) //the output is a string containing return ost.str(); } - //make the number short + //make the number int char symbol[] = {'G', 'M', 'k'}; if(negative) number = (-number); //absolute value @@ -173,13 +171,10 @@ namespace CSDL_Ext void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color); void drawBorder(SDL_Surface * sur, const SDL_Rect &r, const int3 &color); void drawDashedBorder(SDL_Surface * sur, const Rect &r, const int3 &color); - void setPlayerColor(SDL_Surface * sur, unsigned char player); //sets correct color of flags; -1 for neutral + void setPlayerColor(SDL_Surface * sur, ui8 player); //sets correct color of flags; -1 for neutral std::string processStr(std::string str, std::vector & tor); //replaces %s in string SDL_Surface * newSurface(int w, int h, SDL_Surface * mod=screen); //creates new surface, with flags/format same as in surface given SDL_Surface * copySurface(SDL_Surface * mod); //returns copy of given surface void VflipSurf(SDL_Surface * surf); //fluipis given surface by vertical axis void applyEffect(SDL_Surface * surf, const SDL_Rect * rect, int mode); //mode: 0 - sepia, 1 - grayscale }; - - -#endif // __SDL_EXTENSIONS_H__ diff --git a/client/SDL_framerate.cpp b/client/SDL_framerate.cpp index d76b38776..bc25129f0 100644 --- a/client/SDL_framerate.cpp +++ b/client/SDL_framerate.cpp @@ -1,41 +1,31 @@ - -/* - * SDL_framerate.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ - -#include "../stdafx.h" -#include "SDL_framerate.h" -#include - - -FPSManager::FPSManager(int rate) -{ - this->rate = rate; - this->rateticks = (1000.0 / (double) rate); - this->fps = 0; -} - -void FPSManager::init() -{ - this->lastticks = SDL_GetTicks(); -} - -void FPSManager::framerateDelay() -{ - Uint32 currentTicks = SDL_GetTicks(); - double diff = currentTicks - this->lastticks; - - if (diff < this->rateticks) // FPS is higher than it should be, then wait some time - { - SDL_Delay(ceil(this->rateticks) - diff); - } - - this->fps = ceil(1000. / (SDL_GetTicks() - this->lastticks)); - this->lastticks = SDL_GetTicks(); -} +#include "StdInc.h" +#include "SDL_framerate.h" + +#include + + +FPSManager::FPSManager(int rate) +{ + this->rate = rate; + this->rateticks = (1000.0 / (double) rate); + this->fps = 0; +} + +void FPSManager::init() +{ + this->lastticks = SDL_GetTicks(); +} + +void FPSManager::framerateDelay() +{ + Uint32 currentTicks = SDL_GetTicks(); + double diff = currentTicks - this->lastticks; + + if (diff < this->rateticks) // FPS is higher than it should be, then wait some time + { + SDL_Delay(ceil(this->rateticks) - diff); + } + + this->fps = ceil(1000. / (SDL_GetTicks() - this->lastticks)); + this->lastticks = SDL_GetTicks(); +} diff --git a/client/SDL_framerate.h b/client/SDL_framerate.h index 17218f586..1f9087d0b 100644 --- a/client/SDL_framerate.h +++ b/client/SDL_framerate.h @@ -1,33 +1,28 @@ - +#pragma once + /* - * timeHandler.h, part of VCMI engine + * SDL_framerate.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * - */ - -#ifndef _SDL_framerate_h -#define _SDL_framerate_h - - -/// A fps manager which holds game updates at a constant rate -class FPSManager -{ -private: - double rateticks; - unsigned int lastticks; - int rate; - -public: - int fps; // the actual fps value - - FPSManager(int rate); // initializes the manager with a given fps rate - void init(); // needs to be called directly before the main game loop to reset the internal timer - void framerateDelay(); // needs to be called every game update cycle -}; - - -#endif + */ + + +/// A fps manager which holds game updates at a constant rate +class FPSManager +{ +private: + double rateticks; + ui32 lastticks; + int rate; + +public: + int fps; // the actual fps value + + FPSManager(int rate); // initializes the manager with a given fps rate + void init(); // needs to be called directly before the main game loop to reset the internal timer + void framerateDelay(); // needs to be called every game update cycle +}; diff --git a/client/VCMI_client.vcxproj b/client/VCMI_client.vcxproj index 2b7cdbafd..8c6dc0515 100644 --- a/client/VCMI_client.vcxproj +++ b/client/VCMI_client.vcxproj @@ -83,9 +83,9 @@ - D:\Program Files\boost\boost_1_46_1;$(IncludePath) + $(IncludePath) $(IncludePath) - D:\Program Files\boost\boost_1_46_1\stage\lib;$(LibraryPath) + $(LibraryPath) $(LibraryPath) C:\C++\boost_1_42_0;$(IncludePath) C:\C++\boost_1_42_0;$(IncludePath) @@ -102,10 +102,12 @@ false EnableFastChecks MultiThreadedDebugDLL - Level1 + Level3 EditAndContinue 4251;%(DisableSpecificWarnings) NoListing + Use + StdInc.h SDL.lib;zlib.lib;SDL_image.lib;SDL_ttf.lib;SDL_mixer.lib;VCMI_lib.lib;%(AdditionalDependencies) @@ -221,11 +223,29 @@ false false + + + + + + + + + + + + + + + + + + + - - + @@ -251,13 +271,35 @@ + + Create + StdInc.h + - + + + + + + + + + + + + + + + + + + + + - @@ -281,18 +323,14 @@ - - - - - + diff --git a/client/mapHandler.cpp b/client/mapHandler.cpp index caf1f6b41..3b96ddad6 100644 --- a/client/mapHandler.cpp +++ b/client/mapHandler.cpp @@ -1,23 +1,20 @@ -#include "../stdafx.h" +#include "StdInc.h" #include "mapHandler.h" + #include "SDL_Extensions.h" #include "CGameInfo.h" -#include #include "../lib/CLodHandler.h" #include "../lib/CDefObjInfoHandler.h" -#include #include "../lib/CGameState.h" #include "../lib/CHeroHandler.h" #include "../lib/CTownHandler.h" #include "Graphics.h" -#include -#include #include "../lib/CObjectHandler.h" #include "../lib/map.h" #include "CDefHandler.h" #include "CConfigHandler.h" -#include #include "../lib/CGeneralTextHandler.h" +#include "../lib/GameConstants.h" /* * mapHandler.cpp, part of VCMI engine @@ -29,6 +26,9 @@ * */ +const bool MARK_BLOCKED_POSITIONS = false; +const bool MARK_VISITABLE_POSITIONS = false; + extern SDL_Surface * screen; #define ADVOPT (conf.go()->ac) @@ -110,23 +110,23 @@ void CMapHandler::prepareFOWDefs() //necessaary rotations added //alpha - transformation - for(size_t i=0; iFoWpartialHide->ourImages.size(); ++i) + for(size_t i = 0; i < graphics->FoWpartialHide->ourImages.size(); ++i) { CSDL_Ext::alphaTransform(graphics->FoWpartialHide->ourImages[i].bitmap); } //initialization of type of full-hide image hideBitmap.resize(sizes.x); - for (size_t i=0;iFoWfullHide->ourImages.size(); } @@ -247,7 +247,7 @@ void CMapHandler::initObjectRects() { const CGObjectInstance *obj = map->objects[f]; if( !obj - || (obj->ID==HEROI_TYPE && static_cast(obj)->inTownGarrison) //garrisoned hero + || (obj->ID==GameConstants::HEROI_TYPE && static_cast(obj)->inTownGarrison) //garrisoned hero || (obj->ID==8 && static_cast(obj)->hero) //boat with hero (hero graphics is used) || !obj->defInfo || !graphics->getDef(obj)) //no graphic... @@ -296,7 +296,7 @@ void CMapHandler::initObjectRects() } static void processDef (const CGDefInfo* def) { - if(def->id == EVENTI_TYPE) + if(def->id == GameConstants::EVENTI_TYPE) { graphics->advmapobjGraphics[def->id][def->subid][def->name] = NULL; return; @@ -335,8 +335,8 @@ void CMapHandler::initHeroDef(const CGHeroInstance * h) } void CMapHandler::init() { - timeHandler th; - th.getDif(); + StopWatch th; + th.getDiff(); graphics->advmapobjGraphics[8][0]["AB01_.DEF"] = graphics->boatAnims[0]; graphics->advmapobjGraphics[8][1]["AB02_.DEF"] = graphics->boatAnims[1]; @@ -379,7 +379,7 @@ void CMapHandler::init() } std::for_each(map->defy.begin(),map->defy.end(),processDef); //load h3m defs - tlog0<<"\tUnpacking and handling defs: "< > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect, int moveX, int moveY, bool puzzleMode, int3 grailPosRel ) const +void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::vector< std::vector > > * visibilityMap, bool otherHeroAnim, ui8 heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect, int moveX, int moveY, bool puzzleMode, int3 grailPosRel ) const { // Width and height of the portion of the map to process. Units in tiles. - unsigned int dx = tilesW; - unsigned int dy = tilesH; + ui32 dx = tilesW; + ui32 dy = tilesH; // Basic rectangle for a tile. Should be a const but conflicts with SDL headers SDL_Rect rtile = { 0, 0, 32, 32 }; @@ -518,7 +518,7 @@ void CMapHandler::terrainRect( int3 top_tile, unsigned char anim, const std::vec ui8 color = obj->tempOwner; //checking if object has non-empty graphic on this tile - if(obj->ID != HEROI_TYPE && !obj->coveringAt(obj->pos.x - (top_tile.x + bx), top_tile.y + by - obj->pos.y + 5)) + if(obj->ID != GameConstants::HEROI_TYPE && !obj->coveringAt(obj->pos.x - (top_tile.x + bx), top_tile.y + by - obj->pos.y + 5)) continue; static const int notBlittedInPuzzleMode[] = {124}; @@ -533,7 +533,7 @@ void CMapHandler::terrainRect( int3 top_tile, unsigned char anim, const std::vec pp.h = sr.h; pp.w = sr.w; - const CGHeroInstance * themp = (obj->ID != HEROI_TYPE + const CGHeroInstance * themp = (obj->ID != GameConstants::HEROI_TYPE ? NULL : static_cast(obj)); @@ -780,7 +780,7 @@ void CMapHandler::terrainRect( int3 top_tile, unsigned char anim, const std::vec SDL_SetClipRect(extSurf, &prevClip); //restoring clip_rect } -std::pair CMapHandler::getVisBitmap( const int3 & pos, const std::vector< std::vector< std::vector > > & visibilityMap ) const +std::pair CMapHandler::getVisBitmap( const int3 & pos, const std::vector< std::vector< std::vector > > & visibilityMap ) const { static const int visBitmaps[256] = {-1, 34, -1, 4, 22, 22, 4, 4, 36, 36, 38, 38, 47, 47, 38, 38, 3, 25, 12, 12, 3, 25, 12, 12, 9, 9, 6, 6, 9, 9, 6, 6, 35, 34, 4, 4, 22, 22, 4, 4, 36, 36, 38, 38, 47, 47, 38, 38, 26, 49, 28, 28, 26, 49, 28, @@ -894,16 +894,16 @@ bool CMapHandler::removeObject(CGObjectInstance *obj) return true; } -unsigned char CMapHandler::getHeroFrameNum(unsigned char dir, bool isMoving) const +ui8 CMapHandler::getHeroFrameNum(ui8 dir, bool isMoving) const { if(isMoving) { - static const unsigned char frame [] = {0xff, 10, 5, 6, 7, 8, 9, 12, 11}; + static const ui8 frame [] = {0xff, 10, 5, 6, 7, 8, 9, 12, 11}; return frame[dir]; } else //if(isMoving) { - static const unsigned char frame [] = {0xff, 13, 0, 1, 2, 3, 4, 15, 14}; + static const ui8 frame [] = {0xff, 13, 0, 1, 2, 3, 4, 15, 14}; return frame[dir]; } } @@ -948,7 +948,7 @@ void CMapHandler::validateRectTerr(SDL_Rect * val, const SDL_Rect * ext) } } -unsigned char CMapHandler::getDir(const int3 &a, const int3 &b) +ui8 CMapHandler::getDir(const int3 &a, const int3 &b) { if(a.z!=b.z) return -1; //error! diff --git a/client/mapHandler.h b/client/mapHandler.h index 6286a6187..d0e823495 100644 --- a/client/mapHandler.h +++ b/client/mapHandler.h @@ -1,8 +1,7 @@ -#ifndef __MAPHANDLER_H__ -#define __MAPHANDLER_H__ -#include "../global.h" -#include -#include +#pragma once + + +#include "../lib/int3.h" /* * mapHandler.h, part of VCMI engine @@ -97,12 +96,15 @@ public: std::vector roadDefs; std::vector staticRiverDefs; - std::vector > > hideBitmap; //specifies number of graphic that should be used to fully hide a tile + std::vector > > hideBitmap; //specifies number of graphic that should be used to fully hide a tile + + static const bool MARK_BLOCKED_POSITIONS; + static const bool MARK_VISITABLE_POSITIONS; CMapHandler(); //c-tor ~CMapHandler(); //d-tor - std::pair getVisBitmap(const int3 & pos, const std::vector< std::vector< std::vector > > & visibilityMap) const; //returns appropriate bitmap and info if alpha blitting is necessary + std::pair getVisBitmap(const int3 & pos, const std::vector< std::vector< std::vector > > & visibilityMap) const; //returns appropriate bitmap and info if alpha blitting is necessary std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position void getTerrainDescr(const int3 &pos, std::string & out, bool terName); //if tername == false => empty string when tile is clear @@ -118,13 +120,10 @@ public: void roadsRiverTerrainInit(); void prepareFOWDefs(); - void terrainRect(int3 top_tile, unsigned char anim, const std::vector< std::vector< std::vector > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect, int moveX, int moveY, bool puzzleMode, int3 grailPosRel) const; + void terrainRect(int3 top_tile, ui8 anim, const std::vector< std::vector< std::vector > > * visibilityMap, bool otherHeroAnim, ui8 heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect, int moveX, int moveY, bool puzzleMode, int3 grailPosRel) const; void updateWater(); - unsigned char getHeroFrameNum(unsigned char dir, bool isMoving) const; //terrainRect helper function + ui8 getHeroFrameNum(ui8 dir, bool isMoving) const; //terrainRect helper function void validateRectTerr(SDL_Rect * val, const SDL_Rect * ext); //terrainRect helper - static unsigned char getDir(const int3 & a, const int3 & b); //returns direction number in range 0 - 7 (0 is left top, clockwise) [direction: form a to b] + static ui8 getDir(const int3 & a, const int3 & b); //returns direction number in range 0 - 7 (0 is left top, clockwise) [direction: form a to b] }; - - -#endif // __MAPHANDLER_H__ diff --git a/configure b/configure index b8681b40c..ceeff50b2 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for vcmi 0.84b. +# Generated by GNU Autoconf 2.66 for vcmi 0.84b. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -834,9 +834,8 @@ do fi case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -1526,7 +1525,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF vcmi configure 0.84b -generated by GNU Autoconf 2.67 +generated by GNU Autoconf 2.66 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -1713,7 +1712,7 @@ $as_echo "$ac_try_echo"; } >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { + test $ac_status = 0; } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1859,7 +1858,7 @@ $as_echo "$ac_try_echo"; } >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { + test $ac_status = 0; } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : @@ -2010,7 +2009,7 @@ if ac_fn_cxx_try_cpp "$LINENO"; then : else ac_header_preproc=no fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } @@ -2121,7 +2120,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by vcmi $as_me 0.84b, which was -generated by GNU Autoconf 2.67. Invocation command line was +generated by GNU Autoconf 2.66. Invocation command line was $ $0 $@ @@ -2379,7 +2378,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -2467,7 +2466,7 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu - # Follow NAME_VER in global.h + # Follow VCMI_VERSION in GameConstants.h am__api_version='1.11' ac_aux_dir= @@ -2603,11 +2602,11 @@ am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5 ;; + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5 ;; + as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's @@ -3208,7 +3207,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3251,7 +3250,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3310,7 +3309,7 @@ $as_echo "$ac_try_echo"; } >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -3362,7 +3361,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3789,7 +3788,7 @@ fi $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -3822,7 +3821,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -4208,7 +4207,7 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -7717,7 +7716,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -7733,11 +7732,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -7776,7 +7775,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -7792,18 +7791,18 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -11926,7 +11925,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -11942,11 +11941,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -11985,7 +11984,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -12001,18 +12000,18 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=cpp @@ -15179,7 +15178,7 @@ fi # 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 -ftime-report -Wall -Wno-switch -Wno-sign-compare -Wcast-align -Wpointer-arith -Wno-unknown-pragmas" fi # extra clang parameters @@ -17468,7 +17467,7 @@ fi done -CXXFLAGS="$CXXFLAGS -DDATA_DIR=\\\"\$(pkgdatadir)\\\" -DBIN_DIR=\\\"\$(bindir)\\\" -DLIB_DIR=\\\"\$(pkglibdir)\\\"" +CXXFLAGS="$CXXFLAGS -DM_DATA_DIR=\\\"\$(pkgdatadir)\\\" -DM_BIN_DIR=\\\"\$(bindir)\\\" -DM_LIB_DIR=\\\"\$(pkglibdir)\\\"" @@ -18046,7 +18045,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by vcmi $as_me 0.84b, which was -generated by GNU Autoconf 2.67. Invocation command line was +generated by GNU Autoconf 2.66. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -18103,7 +18102,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ vcmi config.status 0.84b -configured by $0, generated by GNU Autoconf 2.67, +configured by $0, generated by GNU Autoconf 2.66, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. @@ -18124,16 +18123,11 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=?*) + --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; *) ac_option=$1 ac_optarg=$2 @@ -18155,7 +18149,6 @@ do $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -18609,7 +18602,7 @@ do "AI/EmptyAI/Makefile") CONFIG_FILES="$CONFIG_FILES AI/EmptyAI/Makefile" ;; "Scripting/ERM/Makefile") CONFIG_FILES="$CONFIG_FILES Scripting/ERM/Makefile" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -18816,7 +18809,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -18844,7 +18837,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -18871,7 +18864,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac diff --git a/configure.ac b/configure.ac index 689f7b139..e71f71b26 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.60) -AC_INIT(vcmi, 0.84b) # Follow NAME_VER in global.h +AC_INIT(vcmi, 0.84b) # Follow VCMI_VERSION in GameConstants.h AM_INIT_AUTOMAKE AC_CONFIG_MACRO_DIR([aclocal/m4]) @@ -32,7 +32,7 @@ fi # 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 -ftime-report -Wall -Wno-switch -Wno-sign-compare -Wcast-align -Wpointer-arith -Wno-unknown-pragmas" fi # extra clang parameters @@ -94,7 +94,7 @@ AC_CHECK_HEADERS([boost/filesystem.hpp boost/algorithm/string.hpp boost/algorith # Checks for library functions. AC_CHECK_FUNCS([atexit memset pow select sqrt]) -CXXFLAGS="$CXXFLAGS -DDATA_DIR=\\\"\$(pkgdatadir)\\\" -DBIN_DIR=\\\"\$(bindir)\\\" -DLIB_DIR=\\\"\$(pkglibdir)\\\"" +CXXFLAGS="$CXXFLAGS -DM_DATA_DIR=\\\"\$(pkgdatadir)\\\" -DM_BIN_DIR=\\\"\$(bindir)\\\" -DM_LIB_DIR=\\\"\$(pkglibdir)\\\"" AC_SUBST(SDL_LIBS) AC_SUBST(SDL_CXXFLAGS) diff --git a/lib/BattleAction.cpp b/lib/BattleAction.cpp index e4ab83070..cf7d54c33 100644 --- a/lib/BattleAction.cpp +++ b/lib/BattleAction.cpp @@ -1,5 +1,6 @@ -#define VCMI_DLL +#include "StdInc.h" #include "BattleAction.h" + #include "BattleState.h" /* @@ -31,7 +32,7 @@ BattleAction BattleAction::makeDefend(const CStack *stack) } -BattleAction BattleAction::makeMeleeAttack(const CStack *stack, const CStack * attacked, THex attackFrom /*= THex::INVALID*/) +BattleAction BattleAction::makeMeleeAttack(const CStack *stack, const CStack * attacked, SHexField attackFrom /*= SHexField::INVALID*/) { BattleAction ba; ba.side = !stack->attackerOwned; @@ -61,7 +62,7 @@ BattleAction BattleAction::makeShotAttack(const CStack *shooter, const CStack *t return ba; } -BattleAction BattleAction::makeMove(const CStack *stack, THex dest) +BattleAction BattleAction::makeMove(const CStack *stack, SHexField dest) { BattleAction ba; ba.side = !stack->attackerOwned; diff --git a/lib/BattleAction.h b/lib/BattleAction.h index 4df6d6f65..896bda764 100644 --- a/lib/BattleAction.h +++ b/lib/BattleAction.h @@ -1,8 +1,8 @@ #pragma once -#ifndef __BATTLEACTION_H__ -#define __BATTLEACTION_H__ -#include "../global.h" + +#include "SHexField.h" + /* * BattleAction.h, part of VCMI engine * @@ -16,7 +16,7 @@ /// A struct which handles battle actions like defending, walking,... - represents a creature stack in a battle class CStack; -struct DLL_EXPORT BattleAction +struct DLL_LINKAGE BattleAction { ui8 side; //who made this action: false - left, true - right player ui32 stackNumber;//stack ID, -1 left hero, -2 right hero, @@ -26,7 +26,7 @@ struct DLL_EXPORT BattleAction STACK_HEAL, DAEMON_SUMMONING }; si8 actionType; //use ActionType enum for values - THex destinationTile; + SHexField destinationTile; si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6 template void serialize(Handler &h, const int version) { @@ -37,9 +37,8 @@ struct DLL_EXPORT BattleAction static BattleAction makeDefend(const CStack *stack); static BattleAction makeWait(const CStack *stack); - static BattleAction makeMeleeAttack(const CStack *stack, const CStack * attacked, THex attackFrom = THex::INVALID); + static BattleAction makeMeleeAttack(const CStack *stack, const CStack * attacked, SHexField attackFrom = SHexField::INVALID); static BattleAction makeShotAttack(const CStack *shooter, const CStack *target); - static BattleAction makeMove(const CStack *stack, THex dest); + static BattleAction makeMove(const CStack *stack, SHexField dest); static BattleAction makeEndOFTacticPhase(ui8 side); }; -#endif // __BATTLEACTION_H__ diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index 50b488f1f..e25c6c44b 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -1,14 +1,8 @@ -#define VCMI_DLL +#include "StdInc.h" #include "BattleState.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include "VCMI_Lib.h" #include "CObjectHandler.h" #include "CHeroHandler.h" @@ -18,6 +12,7 @@ #include "NetPacks.h" #include "../lib/JsonNode.h" + /* * BattleState.h, part of VCMI engine * @@ -95,7 +90,7 @@ static const CStack *takeStack(std::vector &st, int &curside, in CStack * BattleInfo::getStack(int stackID, bool onlyAlive) { - for(unsigned int g=0; gID == stackID && (!onlyAlive || stacks[g]->alive())) return stacks[g]; @@ -108,9 +103,9 @@ const CStack * BattleInfo::getStack(int stackID, bool onlyAlive) const return const_cast(this)->getStack(stackID, onlyAlive); } -CStack * BattleInfo::getStackT(THex tileID, bool onlyAlive) +CStack * BattleInfo::getStackT(SHexField tileID, bool onlyAlive) { - for(unsigned int g=0; gposition == tileID || (stacks[g]->doubleWide() && stacks[g]->attackerOwned && stacks[g]->position-1 == tileID) @@ -125,23 +120,23 @@ CStack * BattleInfo::getStackT(THex tileID, bool onlyAlive) return NULL; } -const CStack * BattleInfo::getStackT(THex tileID, bool onlyAlive) const +const CStack * BattleInfo::getStackT(SHexField tileID, bool onlyAlive) const { return const_cast(this)->getStackT(tileID, onlyAlive); } -void BattleInfo::getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set & occupyable, bool flying, const CStack * stackToOmmit) const +void BattleInfo::getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set & occupyable, bool flying, const CStack * stackToOmmit) const { - memset(accessibility, 1, BFIELD_SIZE); //initialize array with trues + memset(accessibility, 1, GameConstants::BFIELD_SIZE); //initialize array with trues //removing accessibility for side columns of hexes - for(int v = 0; v < BFIELD_SIZE; ++v) + for(int v = 0; v < GameConstants::BFIELD_SIZE; ++v) { - if( v % BFIELD_WIDTH == 0 || v % BFIELD_WIDTH == (BFIELD_WIDTH - 1) ) + if( v % GameConstants::BFIELD_WIDTH == 0 || v % GameConstants::BFIELD_WIDTH == (GameConstants::BFIELD_WIDTH - 1) ) accessibility[v] = false; } - for(unsigned int g=0; galive() || (stackToOmmit && stacks[g]->ID==stackToOmmit->ID) || stacks[g]->position < 0) //we don't want to lock position of this stack (eg. if it's a turret) continue; @@ -156,12 +151,12 @@ void BattleInfo::getAccessibilityMap(bool *accessibility, bool twoHex, bool atta } } //obstacles - for(unsigned int b=0; b blocked = VLC->heroh->obstacles[obstacles[b].ID].getBlocked(obstacles[b].pos); - for(unsigned int c=0; c blocked = VLC->heroh->obstacles[obstacles[b].ID].getBlocked(obstacles[b].pos); + for(ui32 c=0; c=0 && blocked[c] < BFIELD_SIZE) + if(blocked[c] >=0 && blocked[c] < GameConstants::BFIELD_SIZE) accessibility[blocked[c]] = false; } } @@ -175,9 +170,9 @@ void BattleInfo::getAccessibilityMap(bool *accessibility, bool twoHex, bool atta accessibility[permanentlyLocked[b]] = false; } - static const std::pair lockedIfNotDestroyed[] = //(which part of wall, which hex is blocked if this part of wall is not destroyed - {std::make_pair(2, THex(182)), std::make_pair(3, THex(130)), - std::make_pair(4, THex(62)), std::make_pair(5, THex(29))}; + static const std::pair lockedIfNotDestroyed[] = //(which part of wall, which hex is blocked if this part of wall is not destroyed + {std::make_pair(2, SHexField(182)), std::make_pair(3, SHexField(130)), + std::make_pair(4, SHexField(62)), std::make_pair(5, SHexField(29))}; for(int b=0; b rem; //tiles to unlock - for(int h=0; h rem; //tiles to unlock + for(int h=0; h > hexq; //bfs queue (second filed used only if fillPredecessors is true) + std::queue< std::pair > hexq; //bfs queue (second filed used only if fillPredecessors is true) hexq.push(std::make_pair(start, true)); dists[hexq.front().first] = 0; int curNext = -1; //for bfs loop only (helper var) while(!hexq.empty()) //bfs loop { - std::pair curHex = hexq.front(); - std::vector neighbours = curHex.first.neighbouringTiles(); + std::pair curHex = hexq.front(); + std::vector neighbours = curHex.first.neighbouringTiles(); hexq.pop(); - for(unsigned int nr=0; nr=dists[curNext]) bool accessible = isAccessible(curNext, accessibility, twoHex, attackerOwned, flying, dists[curHex.first]+1 == dists[curNext]); @@ -270,31 +265,31 @@ void BattleInfo::makeBFS(THex start, bool *accessibility, THex *predecessor, int } }; -std::vector BattleInfo::getAccessibility( const CStack * stack, bool addOccupiable, std::vector * attackable ) const +std::vector BattleInfo::getAccessibility( const CStack * stack, bool addOccupiable, std::vector * attackable ) const { - std::vector ret; - bool ac[BFIELD_SIZE]; + std::vector ret; + bool ac[GameConstants::BFIELD_SIZE]; if(stack->position < 0) //turrets - return std::vector(); + return std::vector(); - std::set occupyable; + std::set occupyable; getAccessibilityMap(ac, stack->doubleWide(), stack->attackerOwned, addOccupiable, occupyable, stack->hasBonusOfType(Bonus::FLYING), stack); - THex pr[BFIELD_SIZE]; - int dist[BFIELD_SIZE]; + SHexField pr[GameConstants::BFIELD_SIZE]; + int dist[GameConstants::BFIELD_SIZE]; makeBFS(stack->position, ac, pr, dist, stack->doubleWide(), stack->attackerOwned, stack->hasBonusOfType(Bonus::FLYING), false); if(stack->doubleWide()) { if(!addOccupiable) { - std::vector rem; - for(int b=0; b rem; + for(int b=0; battackerOwned ? ac[b-1] : ac[b+1]) ) @@ -303,19 +298,19 @@ std::vector BattleInfo::getAccessibility( const CStack * stack, bool addOc } } - for(unsigned int g=0; gattackerOwned ? (v%BFIELD_WIDTH)==1 : (v%BFIELD_WIDTH)==(BFIELD_WIDTH - 2)) + for(int v=0; vattackerOwned ? (v%GameConstants::BFIELD_WIDTH)==1 : (v%GameConstants::BFIELD_WIDTH)==(GameConstants::BFIELD_WIDTH - 2)) ac[v] = false; } } - for (int i = 0; i < BFIELD_SIZE; ++i) + for (int i = 0; i < GameConstants::BFIELD_SIZE; ++i) { bool rangeFits; if (tacticDistance) @@ -336,11 +331,11 @@ std::vector BattleInfo::getAccessibility( const CStack * stack, bool addOc { struct HLP { - static bool meleeAttackable(THex hex, const std::vector & baseRng) + static bool meleeAttackable(SHexField hex, const std::vector & baseRng) { - BOOST_FOREACH(THex h, baseRng) + BOOST_FOREACH(SHexField h, baseRng) { - if(THex::mutualPosition(h, hex) > 0) + if(SHexField::mutualPosition(h, hex) > 0) return true; } @@ -352,7 +347,7 @@ std::vector BattleInfo::getAccessibility( const CStack * stack, bool addOc if(otherSt->owner == stack->owner) continue; - std::vector occupiedBySecond; + std::vector occupiedBySecond; occupiedBySecond.push_back(otherSt->position); if(otherSt->doubleWide()) occupiedBySecond.push_back(otherSt->occupiedHex()); @@ -365,7 +360,7 @@ std::vector BattleInfo::getAccessibility( const CStack * stack, bool addOc } - BOOST_FOREACH(THex he, occupiedBySecond) + BOOST_FOREACH(SHexField he, occupiedBySecond) { if(HLP::meleeAttackable(he, ret)) attackable->push_back(he); @@ -387,17 +382,17 @@ int BattleInfo::getAvaliableHex(TCreature creID, bool attackerOwned, int initial if (attackerOwned) pos = 0; //top left else - pos = BFIELD_WIDTH; //top right + pos = GameConstants::BFIELD_WIDTH; //top right } - bool ac[BFIELD_SIZE]; - std::set occupyable; + bool ac[GameConstants::BFIELD_SIZE]; + std::set occupyable; bool twoHex = VLC->creh->creatures[creID]->isDoubleWide(); bool flying = VLC->creh->creatures[creID]->isFlying();// vstd::contains(VLC->creh->creatures[creID]->bonuses, Bonus::FLYING); getAccessibilityMap(ac, twoHex, attackerOwned, true, occupyable, flying); - for (int g = pos; (-1 < g) && (g < BFIELD_SIZE); ) + for (int g = pos; (-1 < g) && (g < GameConstants::BFIELD_SIZE); ) { - if ((g % BFIELD_WIDTH != 0) && (g % BFIELD_WIDTH != BFIELD_WIDTH-1) && BattleInfo::isAccessible (g, ac, twoHex, attackerOwned, flying, true)) + if ((g % GameConstants::BFIELD_WIDTH != 0) && (g % GameConstants::BFIELD_WIDTH != GameConstants::BFIELD_WIDTH-1) && BattleInfo::isAccessible (g, ac, twoHex, attackerOwned, flying, true)) { pos = g; break; @@ -424,21 +419,21 @@ bool BattleInfo::isStackBlocked(const CStack * stack) const return false; } -std::pair< std::vector, int > BattleInfo::getPath(THex start, THex dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned) +std::pair< std::vector, int > BattleInfo::getPath(SHexField start, SHexField dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned) { - THex predecessor[BFIELD_SIZE]; //for getting the Path - int dist[BFIELD_SIZE]; //calculated distances + SHexField predecessor[GameConstants::BFIELD_SIZE]; //for getting the Path + int dist[GameConstants::BFIELD_SIZE]; //calculated distances makeBFS(start, accessibility, predecessor, dist, twoHex, attackerOwned, flyingCreature, false); if(predecessor[dest] == -1) //cannot reach destination { - return std::make_pair(std::vector(), 0); + return std::make_pair(std::vector(), 0); } //making the Path - std::vector path; - THex curElem = dest; + std::vector path; + SHexField curElem = dest; while(curElem != start) { path.push_back(curElem); @@ -451,7 +446,7 @@ std::pair< std::vector, int > BattleInfo::getPath(THex start, THex dest, b TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* defender, TQuantity attackerCount, TQuantity defenderCount, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky, bool deathBlow, bool ballistaDoubleDmg ) const { - float additiveBonus=1.0f, multBonus=1.0f, + double additiveBonus = 1.0, multBonus = 1.0, minDmg = attacker->getMinDamage() * attackerCount, maxDmg = attacker->getMaxDamage() * attackerCount; @@ -464,8 +459,8 @@ TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* d maxDmg = 15; break; case -3: case -4: //turrets - minDmg = 7.5f; - maxDmg = 7.5f; + minDmg = 7.5; + maxDmg = 7.5; break; } } @@ -479,7 +474,7 @@ TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* d int attackDefenceDifference = 0; if(attacker->hasBonusOfType(Bonus::GENERAL_ATTACK_REDUCTION)) { - float multAttackReduction = attacker->valOfBonuses(Bonus::GENERAL_ATTACK_REDUCTION, -1024) / 100.0f; + double multAttackReduction = attacker->valOfBonuses(Bonus::GENERAL_ATTACK_REDUCTION, -1024) / 100.0; attackDefenceDifference = attacker->Attack() * multAttackReduction; } else @@ -489,7 +484,7 @@ TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* d if(attacker->hasBonusOfType(Bonus::ENEMY_DEFENCE_REDUCTION)) { - float multDefenceReduction = (100.0f - attacker->valOfBonuses(Bonus::ENEMY_DEFENCE_REDUCTION, -1024)) / 100.0f; + double multDefenceReduction = (100 - attacker->valOfBonuses(Bonus::ENEMY_DEFENCE_REDUCTION, -1024)) / 100.0; attackDefenceDifference -= defender->Defense() * multDefenceReduction; } else @@ -524,7 +519,7 @@ TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* d } } - for(unsigned int g=0; ggetCreature()->idNumber == affectedIds[g]) { @@ -537,22 +532,22 @@ TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* d //bonus from attack/defense skills if(attackDefenceDifference < 0) //decreasing dmg { - float dec = 0.025f * (-attackDefenceDifference); - if(dec > 0.7f) + double dec = 0.025 * (-attackDefenceDifference); + if(dec > 0.7) { - multBonus *= 0.3f; //1.0 - 0.7 + multBonus *= 0.3; //1.0 - 0.7 } else { - multBonus *= 1.0f - dec; + multBonus *= 1.0 - dec; } } else //increasing dmg { - float inc = 0.05f * attackDefenceDifference; - if(inc > 4.0f) + double inc = 0.05 * attackDefenceDifference; + if(inc > 4.0) { - additiveBonus += 4.0f; + additiveBonus += 4.0; } else { @@ -563,7 +558,7 @@ TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* d //applying jousting bonus if( attacker->hasBonusOfType(Bonus::JOUSTING) && !defender->hasBonusOfType(Bonus::CHARGE_IMMUNITY) ) - additiveBonus += charge * 0.05f; + additiveBonus += charge * 0.05; //handling secondary abilities and artifacts giving premies to them @@ -571,47 +566,47 @@ TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* d { if(shooting) { - additiveBonus += attackerHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ARCHERY) / 100.0f; + additiveBonus += attackerHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ARCHERY) / 100.0; } else { - additiveBonus += attackerHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::OFFENCE) / 100.0f; + additiveBonus += attackerHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::OFFENCE) / 100.0; } } if(defendingHero) { - multBonus *= (std::max(0, 100-defendingHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ARMORER))) / 100.0f; + multBonus *= (std::max(0, 100-defendingHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ARMORER))) / 100.0; } //handling hate effect - additiveBonus += attacker->valOfBonuses(Bonus::HATE, defender->getCreature()->idNumber) / 100.f; + additiveBonus += attacker->valOfBonuses(Bonus::HATE, defender->getCreature()->idNumber) / 100.; //luck bonus if (lucky) { - additiveBonus += 1.0f; + additiveBonus += 1.0; } //ballista double dmg if(ballistaDoubleDmg) { - additiveBonus += 1.0f; + additiveBonus += 1.0; } if (deathBlow) //Dread Knight and many WoGified creatures { - additiveBonus += 1.0f; + additiveBonus += 1.0; } //handling spell effects if(!shooting && defender->hasBonusOfType(Bonus::GENERAL_DAMAGE_REDUCTION, 0)) //eg. shield { - multBonus *= float(defender->valOfBonuses(Bonus::GENERAL_DAMAGE_REDUCTION, 0)) / 100.0f; + multBonus *= defender->valOfBonuses(Bonus::GENERAL_DAMAGE_REDUCTION, 0) / 100.0; } else if(shooting && defender->hasBonusOfType(Bonus::GENERAL_DAMAGE_REDUCTION, 1)) //eg. air shield { - multBonus *= float(defender->valOfBonuses(Bonus::GENERAL_DAMAGE_REDUCTION, 1)) / 100.0f; + multBonus *= defender->valOfBonuses(Bonus::GENERAL_DAMAGE_REDUCTION, 1) / 100.0; } TBonusListPtr curseEffects = attacker->getBonuses(Selector::type(Bonus::ALWAYS_MINIMUM_DAMAGE)); //attacker->getEffect(42); @@ -682,8 +677,8 @@ TDmgRange BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* d } //damage cannot be less than 1 - amax(returnedVal.first, 1); - amax(returnedVal.second, 1); + vstd::amax(returnedVal.first, 1); + vstd::amax(returnedVal.second, 1); return returnedVal; } @@ -716,17 +711,17 @@ ui32 BattleInfo::calculateDmg( const CStack* attacker, const CStack* defender, c void BattleInfo::calculateCasualties( std::map *casualties ) const { - for(unsigned int i=0; ialive() ? st->baseAmount - st->count : st->baseAmount); - amax(killed, 0); + vstd::amax(killed, 0); if(killed) casualties[!st->attackerOwned][st->getCreature()->idNumber] += killed; } } -std::set BattleInfo::getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, THex destinationTile ) +std::set BattleInfo::getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, SHexField destinationTile ) { std::set attackedHexes = s->rangeInHexes(destinationTile, skillLevel); std::set attackedCres; /*std::set to exclude multiple occurrences of two hex creatures*/ @@ -806,24 +801,24 @@ std::set BattleInfo::getAttackedCreatures(const CSpell * s, int skillLe } return attackedCres; } -void BattleInfo::getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, THex destinationTile, THex attackerPos) +void BattleInfo::getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, SHexField destinationTile, SHexField attackerPos) { - const int WN = BFIELD_WIDTH; - ui16 hex = (attackerPos != THex::INVALID) ? attackerPos.hex : attacker->position.hex; //real or hypothetical (cursor) position + const int WN = GameConstants::BFIELD_WIDTH; + ui16 hex = (attackerPos != SHexField::INVALID) ? attackerPos.hex : attacker->position.hex; //real or hypothetical (cursor) position if (attacker->hasBonusOfType(Bonus::ATTACKS_ALL_ADJACENT)) { - std::vector hexes = attacker->getSurroundingHexes(attackerPos); - BOOST_FOREACH (THex tile, hexes) + std::vector hexes = attacker->getSurroundingHexes(attackerPos); + BOOST_FOREACH (SHexField tile, hexes) { at.hostileCreaturePositions.insert(tile); } } if (attacker->hasBonusOfType(Bonus::THREE_HEADED_ATTACK)) { - std::vector hexes = attacker->getSurroundingHexes(attackerPos); - BOOST_FOREACH (THex tile, hexes) + std::vector hexes = attacker->getSurroundingHexes(attackerPos); + BOOST_FOREACH (SHexField tile, hexes) { - if ((THex::mutualPosition(tile, destinationTile) > -1 && THex::mutualPosition(tile, hex) > -1) //adjacent both to attacker's head and attacked tile + if ((SHexField::mutualPosition(tile, destinationTile) > -1 && SHexField::mutualPosition(tile, hex) > -1) //adjacent both to attacker's head and attacked tile || tile == destinationTile) //or simply attacked directly { CStack * st = getStackT(tile, true); @@ -836,26 +831,26 @@ void BattleInfo::getPotentiallyAttackableHexes(AttackableTiles &at, const CStack } if (attacker->hasBonusOfType(Bonus::TWO_HEX_ATTACK_BREATH)) { - std::vector hexes; //only one, in fact + std::vector hexes; //only one, in fact int pseudoVector = destinationTile.hex - hex; switch (pseudoVector) { case 1: case -1: - THex::checkAndPush(destinationTile.hex + pseudoVector, hexes); + SHexField::checkAndPush(destinationTile.hex + pseudoVector, hexes); break; case WN: //17 case WN + 1: //18 case -WN: //-17 case -WN + 1: //-16 - THex::checkAndPush(destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : -1 ), hexes); + SHexField::checkAndPush(destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : -1 ), hexes); break; case WN-1: //16 case -WN-1: //-18 - THex::checkAndPush(destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : 0), hexes); + SHexField::checkAndPush(destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : 0), hexes); break; } - BOOST_FOREACH (THex tile, hexes) + BOOST_FOREACH (SHexField tile, hexes) { CStack * st = getStackT(tile, true); if(st) //friendly stacks can also be damaged by Dragon Breath @@ -865,12 +860,12 @@ void BattleInfo::getPotentiallyAttackableHexes(AttackableTiles &at, const CStack } } } -std::set BattleInfo::getAttackedCreatures(const CStack* attacker, THex destinationTile, THex attackerPos) +std::set BattleInfo::getAttackedCreatures(const CStack* attacker, SHexField destinationTile, SHexField attackerPos) { //TODO: caching? AttackableTiles at; getPotentiallyAttackableHexes(at, attacker, destinationTile, attackerPos); std::set attackedCres; - BOOST_FOREACH (THex tile, at.hostileCreaturePositions) //all around & three-headed attack + BOOST_FOREACH (SHexField tile, at.hostileCreaturePositions) //all around & three-headed attack { CStack * st = getStackT(tile, true); if(st && st->owner != attacker->owner) //only hostile stacks - does it work well with Berserk? @@ -878,7 +873,7 @@ std::set BattleInfo::getAttackedCreatures(const CStack* attacker, THex attackedCres.insert(st); } } - BOOST_FOREACH (THex tile, at.friendlyCreaturePositions) + BOOST_FOREACH (SHexField tile, at.friendlyCreaturePositions) { CStack * st = getStackT(tile, true); if(st) //friendly stacks can also be damaged by Dragon Breath @@ -889,12 +884,12 @@ std::set BattleInfo::getAttackedCreatures(const CStack* attacker, THex return attackedCres; } -std::set BattleInfo::getAttackedHexes(const CStack* attacker, THex destinationTile, THex attackerPos) +std::set BattleInfo::getAttackedHexes(const CStack* attacker, SHexField destinationTile, SHexField attackerPos) { AttackableTiles at; getPotentiallyAttackableHexes(at, attacker, destinationTile, attackerPos); - std::set attackedHexes; - BOOST_FOREACH (THex tile, at.hostileCreaturePositions) + std::set attackedHexes; + BOOST_FOREACH (SHexField tile, at.hostileCreaturePositions) { CStack * st = getStackT(tile, true); if(st && st->owner != attacker->owner) //only hostile stacks - does it work well with Berserk? @@ -902,7 +897,7 @@ std::set BattleInfo::getAttackedHexes(const CStack* attacker, THex destina attackedHexes.insert(tile); } } - BOOST_FOREACH (THex tile, at.friendlyCreaturePositions) + BOOST_FOREACH (SHexField tile, at.friendlyCreaturePositions) { CStack * st = getStackT(tile, true); if(st) //friendly stacks can also be damaged by Dragon Breath @@ -918,7 +913,7 @@ std::set BattleInfo::getAdjacentCreatures (const CStack * stack) const std::set stacks; CStack * localStack; - BOOST_FOREACH (THex hex, stack->getSurroundingHexes()) + BOOST_FOREACH (SHexField hex, stack->getSurroundingHexes()) { localStack = const_cast(getStackT(hex, true)); //only alive? if (localStack) @@ -945,17 +940,17 @@ int BattleInfo::calculateSpellDuration( const CSpell * spell, const CGHeroInstan } } -CStack * BattleInfo::generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, THex position) const +CStack * BattleInfo::generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, SHexField position) const { int owner = attackerOwned ? sides[0] : sides[1]; - assert((owner >= PLAYER_LIMIT) || + assert((owner >= GameConstants::PLAYER_LIMIT) || (base.armyObj && base.armyObj->tempOwner == owner)); CStack * ret = new CStack(&base, owner, stackID, attackerOwned, slot); ret->position = position; return ret; } -CStack * BattleInfo::generateNewStack(const CStackBasicDescriptor &base, int stackID, bool attackerOwned, int slot, THex position) const +CStack * BattleInfo::generateNewStack(const CStackBasicDescriptor &base, int stackID, bool attackerOwned, int slot, SHexField position) const { int owner = attackerOwned ? sides[0] : sides[1]; CStack * ret = new CStack(&base, owner, stackID, attackerOwned, slot); @@ -975,18 +970,18 @@ ui32 BattleInfo::getSpellCost(const CSpell * sp, const CGHeroInstance * caster) { if( stacks[g]->owner == caster->tempOwner && stacks[g]->hasBonusOfType(Bonus::CHANGES_SPELL_COST_FOR_ALLY) ) { - amax(manaReduction, stacks[g]->valOfBonuses(Bonus::CHANGES_SPELL_COST_FOR_ALLY)); + vstd::amax(manaReduction, stacks[g]->valOfBonuses(Bonus::CHANGES_SPELL_COST_FOR_ALLY)); } if( stacks[g]->owner != caster->tempOwner && stacks[g]->hasBonusOfType(Bonus::CHANGES_SPELL_COST_FOR_ENEMY) ) { - amax(manaIncrease, stacks[g]->valOfBonuses(Bonus::CHANGES_SPELL_COST_FOR_ENEMY)); + vstd::amax(manaIncrease, stacks[g]->valOfBonuses(Bonus::CHANGES_SPELL_COST_FOR_ENEMY)); } } return ret - manaReduction + manaIncrease; } -int BattleInfo::hexToWallPart(THex hex) const +int BattleInfo::hexToWallPart(SHexField hex) const { if(siege == 0) //there is no battle! return -1; @@ -1012,19 +1007,19 @@ int BattleInfo::lineToWallHex( int line ) const return lineToHex[line]; } -std::pair BattleInfo::getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const +std::pair BattleInfo::getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const { - bool ac[BFIELD_SIZE]; - std::set occupyable; + bool ac[GameConstants::BFIELD_SIZE]; + std::set occupyable; getAccessibilityMap(ac, closest->doubleWide(), closest->attackerOwned, false, occupyable, closest->hasBonusOfType(Bonus::FLYING), closest); - THex predecessor[BFIELD_SIZE]; - int dist[BFIELD_SIZE]; + SHexField predecessor[GameConstants::BFIELD_SIZE]; + int dist[GameConstants::BFIELD_SIZE]; makeBFS(closest->position, ac, predecessor, dist, closest->doubleWide(), closest->attackerOwned, closest->hasBonusOfType(Bonus::FLYING), true); std::vector< std::pair< std::pair, const CStack *> > stackPairs; //pairs <, stack> - for(int g=0; gID == closest->ID) //if there is not stack or we are the closest one @@ -1060,7 +1055,7 @@ std::pair BattleInfo::getNearestStack(const CStack * close return std::make_pair(minPair.second, predecessor[minPair.first.second]); } - return std::make_pair(NULL, THex::INVALID); + return std::make_pair(NULL, SHexField::INVALID); } ui32 BattleInfo::calculateSpellBonus(ui32 baseDamage, const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature) const { @@ -1068,20 +1063,20 @@ ui32 BattleInfo::calculateSpellBonus(ui32 baseDamage, const CSpell * sp, const C //applying sorcery secondary skill if(caster) { - ret *= (100.f + caster->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::SORCERY)) / 100.0f; - ret *= (100.f + caster->valOfBonuses(Bonus::SPELL_DAMAGE) + caster->valOfBonuses(Bonus::SPECIFIC_SPELL_DAMAGE, sp->id)) / 100.0f; + ret *= (100.0 + caster->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::SORCERY)) / 100.0; + ret *= (100.0 + caster->valOfBonuses(Bonus::SPELL_DAMAGE) + caster->valOfBonuses(Bonus::SPECIFIC_SPELL_DAMAGE, sp->id)) / 100.0; if(sp->air) - ret *= (100.0f + caster->valOfBonuses(Bonus::AIR_SPELL_DMG_PREMY)) / 100.0f; + ret *= (100.0 + caster->valOfBonuses(Bonus::AIR_SPELL_DMG_PREMY)) / 100.0; else if(sp->fire) //only one type of bonus for Magic Arrow - ret *= (100.0f + caster->valOfBonuses(Bonus::FIRE_SPELL_DMG_PREMY)) / 100.0f; + ret *= (100.0 + caster->valOfBonuses(Bonus::FIRE_SPELL_DMG_PREMY)) / 100.0; else if(sp->water) - ret *= (100.0f + caster->valOfBonuses(Bonus::WATER_SPELL_DMG_PREMY)) / 100.0f; + ret *= (100.0 + caster->valOfBonuses(Bonus::WATER_SPELL_DMG_PREMY)) / 100.0; else if(sp->earth) - ret *= (100.0f + caster->valOfBonuses(Bonus::EARTH_SPELL_DMG_PREMY)) / 100.0f; + ret *= (100.0 + caster->valOfBonuses(Bonus::EARTH_SPELL_DMG_PREMY)) / 100.0; if (affectedCreature && affectedCreature->getCreature()->level) //Hero specials like Solmyr, Deemer - ret *= (100.f + ((caster->valOfBonuses(Bonus::SPECIAL_SPELL_LEV, sp->id) * caster->level) / affectedCreature->getCreature()->level)) / 100.0f; + ret *= (100. + ((caster->valOfBonuses(Bonus::SPECIAL_SPELL_LEV, sp->id) * caster->level) / affectedCreature->getCreature()->level)) / 100.0; } return ret; } @@ -1172,7 +1167,7 @@ void BattleInfo::getStackQueue( std::vector &out, int howMany, i const CStack *active = getStack(activeStack); //active stack hasn't taken any action yet - must be placed at the beginning of queue, no matter what - if(!turn && active && active->willMove() && !vstd::contains(active->state, WAITING)) + if(!turn && active && active->willMove() && !vstd::contains(active->state, EBattleStackState::WAITING)) { out.push_back(active); if(out.size() == howMany) @@ -1180,7 +1175,7 @@ void BattleInfo::getStackQueue( std::vector &out, int howMany, i } - for(unsigned int i=0; iwillMove()) //we are considering current round and stack won't move @@ -1191,9 +1186,9 @@ void BattleInfo::getStackQueue( std::vector &out, int howMany, i } int p = -1; //in which phase this tack will move? - if(turn <= 0 && vstd::contains(s->state, WAITING)) //consider waiting state only for ongoing round + if(turn <= 0 && vstd::contains(s->state, EBattleStackState::WAITING)) //consider waiting state only for ongoing round { - if(vstd::contains(s->state, HAD_MORALE)) + if(vstd::contains(s->state, EBattleStackState::HAD_MORALE)) p = 2; else p = 3; @@ -1256,13 +1251,13 @@ void BattleInfo::getStackQueue( std::vector &out, int howMany, i } } -si8 BattleInfo::hasDistancePenalty( const CStack * stack, THex destHex ) const +si8 BattleInfo::hasDistancePenalty( const CStack * stack, SHexField destHex ) const { struct HLP { - static bool lowerAnalyze(const CStack * stack, THex hex) + static bool lowerAnalyze(const CStack * stack, SHexField hex) { - int distance = THex::getDistance(hex, stack->position); + int distance = SHexField::getDistance(hex, stack->position); //I hope it's approximately correct return distance > 10 && !stack->hasBonusOfType(Bonus::NO_DISTANCE_PENALTY); @@ -1279,8 +1274,8 @@ si8 BattleInfo::hasDistancePenalty( const CStack * stack, THex destHex ) const si8 BattleInfo::sameSideOfWall(int pos1, int pos2) const { - int wallInStackLine = lineToWallHex(pos1/BFIELD_WIDTH); - int wallInDestLine = lineToWallHex(pos2/BFIELD_WIDTH); + int wallInStackLine = lineToWallHex(pos1/GameConstants::BFIELD_WIDTH); + int wallInDestLine = lineToWallHex(pos2/GameConstants::BFIELD_WIDTH); bool stackLeft = pos1 < wallInStackLine; bool destLeft = pos2 < wallInDestLine; @@ -1288,23 +1283,23 @@ si8 BattleInfo::sameSideOfWall(int pos1, int pos2) const return stackLeft != destLeft; } -si8 BattleInfo::hasWallPenalty( const CStack* stack, THex destHex ) const +si8 BattleInfo::hasWallPenalty( const CStack* stack, SHexField destHex ) const { if (!siege || stack->hasBonusOfType(Bonus::NO_WALL_PENALTY)) { return false; } - int wallInStackLine = lineToWallHex(stack->position/BFIELD_WIDTH); - int wallInDestLine = lineToWallHex(destHex/BFIELD_WIDTH); + int wallInStackLine = lineToWallHex(stack->position/GameConstants::BFIELD_WIDTH); + int wallInDestLine = lineToWallHex(destHex/GameConstants::BFIELD_WIDTH); bool stackLeft = stack->position < wallInStackLine; bool destRight = destHex > wallInDestLine; if (stackLeft && destRight) //shooting from outside to inside { - int row = (stack->position + destHex) / (2 * BFIELD_WIDTH); - if (stack->position > destHex && ((destHex & BFIELD_WIDTH - stack->position % BFIELD_WIDTH) < 2)) //shooting up high + int row = (stack->position + destHex) / (2 * GameConstants::BFIELD_WIDTH); + if (stack->position > destHex && ((destHex & GameConstants::BFIELD_WIDTH - stack->position % GameConstants::BFIELD_WIDTH) < 2)) //shooting up high row -= 2; int wallPos = lineToWallHex(row); if (hexToWallPart(wallPos) != -1) //wall still exists or is indestructible @@ -1313,11 +1308,11 @@ si8 BattleInfo::hasWallPenalty( const CStack* stack, THex destHex ) const return false; } -si8 BattleInfo::canTeleportTo(const CStack * stack, THex destHex, int telportLevel) const +si8 BattleInfo::canTeleportTo(const CStack * stack, SHexField destHex, int telportLevel) const { - bool ac[BFIELD_SIZE]; + bool ac[GameConstants::BFIELD_SIZE]; - std::set occupyable; + std::set occupyable; getAccessibilityMap(ac, stack->doubleWide(), stack->attackerOwned, false, occupyable, stack->hasBonusOfType(Bonus::FLYING), stack); @@ -1332,7 +1327,7 @@ si8 BattleInfo::canTeleportTo(const CStack * stack, THex destHex, int telportLev } -bool BattleInfo::battleCanShoot(const CStack * stack, THex dest) const +bool BattleInfo::battleCanShoot(const CStack * stack, SHexField dest) const { const CStack *dst = getStackT(dest); @@ -1380,10 +1375,10 @@ bool BattleInfo::battleCanFlee(int player) const return true; } -const CStack * BattleInfo::battleGetStack(THex pos, bool onlyAlive) +const CStack * BattleInfo::battleGetStack(SHexField pos, bool onlyAlive) { CStack * stack = NULL; - for(unsigned int g=0; gposition == pos || (stacks[g]->doubleWide() @@ -1411,12 +1406,12 @@ si8 BattleInfo::battleMinSpellLevel() const if(const CGHeroInstance *h1 = heroes[0]) { - amax(levelLimit, h1->valOfBonuses(Bonus::LEVEL_SPELL_IMMUNITY)); + vstd::amax(levelLimit, h1->valOfBonuses(Bonus::LEVEL_SPELL_IMMUNITY)); } if(const CGHeroInstance *h2 = heroes[1]) { - amax(levelLimit, h2->valOfBonuses(Bonus::LEVEL_SPELL_IMMUNITY)); + vstd::amax(levelLimit, h2->valOfBonuses(Bonus::LEVEL_SPELL_IMMUNITY)); } return levelLimit; @@ -1502,7 +1497,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const //reading battleStartpos std::vector< std::vector > attackerLoose, defenderLoose, attackerTight, defenderTight, attackerCreBank, defenderCreBank; - const JsonNode config(DATA_DIR "/config/battleStartpos.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/battleStartpos.json"); const JsonVector &positions = config["battle_positions"].Vector(); CGH::readBattlePositions(positions[0]["levels"], attackerLoose); @@ -1548,12 +1543,12 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const //we should do that for creature bank too if(stacks[g]->doubleWide() && stacks[g]->attackerOwned) { - stacks[g]->position += THex::RIGHT; + stacks[g]->position += SHexField::RIGHT; } else if(stacks[g]->doubleWide() && !stacks[g]->attackerOwned) { if (stacks[g]->position.getX() > 1) - stacks[g]->position += THex::LEFT; + stacks[g]->position += SHexField::LEFT; } } @@ -1635,10 +1630,10 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const //randomize obstacles if(town == NULL && !creatureBank) //do it only when it's not siege and not creature bank { - bool obAv[BFIELD_SIZE]; //availability of hexes for obstacles; + bool obAv[GameConstants::BFIELD_SIZE]; //availability of hexes for obstacles; std::vector possibleObstacles; - for(int i=0; i 12) { @@ -1667,12 +1662,12 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const CObstacleInstance coi; coi.uniqueID = curB->obstacles.size(); coi.ID = possibleObstacles[rand()%possibleObstacles.size()]; - coi.pos = rand()%BFIELD_SIZE; - std::vector block = VLC->heroh->obstacles[coi.ID].getBlocked(coi.pos); + coi.pos = rand()%GameConstants::BFIELD_SIZE; + std::vector block = VLC->heroh->obstacles[coi.ID].getBlocked(coi.pos); bool badObstacle = false; for(int b=0; b= BFIELD_SIZE || !obAv[block[b]]) + if(block[b] < 0 || block[b] >= GameConstants::BFIELD_SIZE || !obAv[block[b]]) { badObstacle = true; break; @@ -1683,7 +1678,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const curB->obstacles.push_back(coi); for(int b=0; b= 0 && block[b] < BFIELD_SIZE) + if(block[b] >= 0 && block[b] < GameConstants::BFIELD_SIZE) obAv[block[b]] = false; } toBlock -= block.size(); @@ -1727,8 +1722,8 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const case 18: //holy ground { - curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(new CreatureAlignmentLimiter(GOOD))); - curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(new CreatureAlignmentLimiter(EVIL))); + curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(new CreatureAlignmentLimiter(EAlignment::GOOD))); + curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(new CreatureAlignmentLimiter(EAlignment::EVIL))); break; } case 19: //clover field @@ -1738,15 +1733,15 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const } case 20: //evil fog { - curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(new CreatureAlignmentLimiter(GOOD))); - curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(new CreatureAlignmentLimiter(EVIL))); + curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(new CreatureAlignmentLimiter(EAlignment::GOOD))); + curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(new CreatureAlignmentLimiter(EAlignment::EVIL))); break; } case 22: //cursed ground { curB->addNewBonus(makeFeature(Bonus::NO_MORALE, Bonus::ONE_BATTLE, 0, 0, Bonus::TERRAIN_OVERLAY)); curB->addNewBonus(makeFeature(Bonus::NO_LUCK, Bonus::ONE_BATTLE, 0, 0, Bonus::TERRAIN_OVERLAY)); - Bonus * b = makeFeature(Bonus::LEVEL_SPELL_IMMUNITY, Bonus::ONE_BATTLE, SPELL_LEVELS, 1, Bonus::TERRAIN_OVERLAY); + Bonus * b = makeFeature(Bonus::LEVEL_SPELL_IMMUNITY, Bonus::ONE_BATTLE, GameConstants::SPELL_LEVELS, 1, Bonus::TERRAIN_OVERLAY); b->valType = Bonus::INDEPENDENT_MAX; curB->addNewBonus(b); break; @@ -1805,65 +1800,65 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const return curB; } -bool BattleInfo::isInTacticRange( THex dest ) const +bool BattleInfo::isInTacticRange( SHexField dest ) const { return ((!tacticsSide && dest.getX() > 0 && dest.getX() <= tacticDistance) - || (tacticsSide && dest.getX() < BFIELD_WIDTH - 1 && dest.getX() >= BFIELD_WIDTH - tacticDistance - 1)); + || (tacticsSide && dest.getX() < GameConstants::BFIELD_WIDTH - 1 && dest.getX() >= GameConstants::BFIELD_WIDTH - tacticDistance - 1)); } -SpellCasting::ESpellCastProblem BattleInfo::battleCanCastSpell(int player, SpellCasting::ECastingMode mode) const +ESpellCastProblem::ESpellCastProblem BattleInfo::battleCanCastSpell(int player, ECastingMode::ECastingMode mode) const { int side = sides[0] == player ? 0 : 1; switch (mode) { - case SpellCasting::HERO_CASTING: + case ECastingMode::HERO_CASTING: { if(castSpells[side] > 0) - return SpellCasting::ALREADY_CASTED_THIS_TURN; + return ESpellCastProblem::ALREADY_CASTED_THIS_TURN; if(!heroes[side]) - return SpellCasting::NO_HERO_TO_CAST_SPELL; + return ESpellCastProblem::NO_HERO_TO_CAST_SPELL; if(!heroes[side]->getArt(17)) - return SpellCasting::NO_SPELLBOOK; + return ESpellCastProblem::NO_SPELLBOOK; } break; } - return SpellCasting::OK; + return ESpellCastProblem::OK; } -SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, const CSpell * spell, SpellCasting::ECastingMode mode ) const +ESpellCastProblem::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, const CSpell * spell, ECastingMode::ECastingMode mode ) const { - SpellCasting::ESpellCastProblem genProblem = battleCanCastSpell(player, mode); - if(genProblem != SpellCasting::OK) + ESpellCastProblem::ESpellCastProblem genProblem = battleCanCastSpell(player, mode); + if(genProblem != ESpellCastProblem::OK) return genProblem; int cside = sides[0] == player ? 0 : 1; //caster's side switch(mode) { - case SpellCasting::HERO_CASTING: + case ECastingMode::HERO_CASTING: { const CGHeroInstance * caster = heroes[cside]; if(!caster->canCastThisSpell(spell)) - return SpellCasting::HERO_DOESNT_KNOW_SPELL; + return ESpellCastProblem::HERO_DOESNT_KNOW_SPELL; if(caster->mana < getSpellCost(spell, caster)) //not enough mana - return SpellCasting::NOT_ENOUGH_MANA; + return ESpellCastProblem::NOT_ENOUGH_MANA; } break; } if(spell->id < 10) //it's adventure spell (not combat)) - return SpellCasting::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL; + return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL; if(NBonus::hasOfType(heroes[1-cside], Bonus::SPELL_IMMUNITY, spell->id)) //non - casting hero provides immunity for this spell - return SpellCasting::SECOND_HEROS_SPELL_IMMUNITY; + return ESpellCastProblem::SECOND_HEROS_SPELL_IMMUNITY; if(battleMinSpellLevel() > spell->level) //non - casting hero stops caster from casting this spell - return SpellCasting::SPELL_LEVEL_LIMIT_EXCEEDED; - + return ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED; + int spellIDs[] = {66, 67, 68, 69}; //IDs of summon elemental spells (fire, earth, water, air) int creIDs[] = {114, 113, 115, 112}; //(fire, earth, water, air) @@ -1874,9 +1869,9 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, //check if there are summoned elementals of other type BOOST_FOREACH ( const CStack * st, stacks) { - if (vstd::contains(st->state, SUMMONED) && st->getCreature()->idNumber != creIDs[arpos]) + if (vstd::contains(st->state, EBattleStackState::SUMMONED) && st->getCreature()->idNumber != creIDs[arpos]) { - return SpellCasting::ANOTHER_ELEMENTAL_SUMMONED; + return ESpellCastProblem::ANOTHER_ELEMENTAL_SUMMONED; } } } @@ -1886,7 +1881,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, { case CSpell::CREATURE: case CSpell::CREATURE_EXPERT_MASSIVE: - if(mode == SpellCasting::HERO_CASTING) + if(mode == ECastingMode::HERO_CASTING) { const CGHeroInstance * caster = getHero(player); bool targetExists = false; @@ -1897,7 +1892,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, case 1: if(stack->owner == caster->getOwner()) { - if(battleIsImmune(caster, spell, mode, stack->position) == SpellCasting::OK) + if(battleIsImmune(caster, spell, mode, stack->position) == ESpellCastProblem::OK) { targetExists = true; break; @@ -1905,7 +1900,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, } break; case 0: - if(battleIsImmune(caster, spell, mode, stack->position) == SpellCasting::OK) + if(battleIsImmune(caster, spell, mode, stack->position) == ESpellCastProblem::OK) { targetExists = true; break; @@ -1914,7 +1909,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, case -1: if(stack->owner != caster->getOwner()) { - if(battleIsImmune(caster, spell, mode, stack->position) == SpellCasting::OK) + if(battleIsImmune(caster, spell, mode, stack->position) == ESpellCastProblem::OK) { targetExists = true; break; @@ -1925,7 +1920,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, } if(!targetExists) { - return SpellCasting::NO_APPROPRIATE_TARGET; + return ESpellCastProblem::NO_APPROPRIATE_TARGET; } } break; @@ -1933,16 +1928,16 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, break; } - return SpellCasting::OK; + return ESpellCastProblem::OK; } -SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpellHere( int player, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest ) const +ESpellCastProblem::ESpellCastProblem BattleInfo::battleCanCastThisSpellHere( int player, const CSpell * spell, ECastingMode::ECastingMode mode, SHexField dest ) const { - SpellCasting::ESpellCastProblem moreGeneralProblem = battleCanCastThisSpell(player, spell, mode); - if(moreGeneralProblem != SpellCasting::OK) + ESpellCastProblem::ESpellCastProblem moreGeneralProblem = battleCanCastThisSpell(player, spell, mode); + if(moreGeneralProblem != ESpellCastProblem::OK) return moreGeneralProblem; - if (mode != SpellCasting::CREATURE_ACTIVE_CASTING && mode != SpellCasting::ENCHANTER_CASTING) + if (mode != ECastingMode::CREATURE_ACTIVE_CASTING && mode != ECastingMode::ENCHANTER_CASTING) return battleIsImmune(getHero(player), spell, mode, dest); else return battleIsImmune(NULL, spell, mode, dest); @@ -1952,13 +1947,13 @@ TSpell BattleInfo::getRandomBeneficialSpell(const CStack * subject) const { std::vector possibleSpells; CSpell * spell; - for (int i = 0; i < SPELLS_QUANTITY; ++i) //should not use future spells added by mods + for (int i = 0; i < GameConstants::SPELLS_QUANTITY; ++i) //should not use future spells added by mods { spell = VLC->spellh->spells[i]; if (spell->positiveness == 1) //only positive { if (subject->hasBonusFrom(Bonus::SPELL_EFFECT, i) || - battleCanCastThisSpellHere(subject->owner, spell, SpellCasting::CREATURE_ACTIVE_CASTING, subject->position) != SpellCasting::OK) + battleCanCastThisSpellHere(subject->owner, spell, ECastingMode::CREATURE_ACTIVE_CASTING, subject->position) != ESpellCastProblem::OK) continue; switch (i) { @@ -2098,38 +2093,38 @@ bool BattleInfo::battleTestElementalImmunity(const CStack * subject, const CSpel return false; } -SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest) const +ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, SHexField dest) const { const CStack * subject = getStackT(dest, false); if(subject) { if (spell->positiveness == 1 && subject->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells - return SpellCasting::OK; + return ESpellCastProblem::OK; switch (spell->id) //TODO: more general logic for new spells? { case Spells::DESTROY_UNDEAD: if (!subject->hasBonusOfType(Bonus::UNDEAD)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; break; case Spells::DEATH_RIPPLE: if (subject->hasBonusOfType(Bonus::SIEGE_WEAPON)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; //don't break here - undeads and war machines are immune, non-living are not + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; //don't break here - undeads and war machines are immune, non-living are not case Spells::BLESS: case Spells::CURSE: //undeads are immune to bless & curse if (subject->hasBonusOfType(Bonus::UNDEAD)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; break; case Spells::HASTE: case Spells::SLOW: case Spells::TELEPORT: case Spells::CLONE: if (subject->hasBonusOfType(Bonus::SIEGE_WEAPON)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; //war machines are mmune to some spells than involve movement + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; //war machines are mmune to some spells than involve movement break; case Spells::FORGETFULNESS: if (!subject->hasBonusOfType(Bonus::SHOOTER)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; break; case Spells::DISPEL_HELPFUL_SPELLS: { @@ -2145,7 +2140,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance } if(!hasPositiveSpell) { - return SpellCasting::NO_SPELLS_TO_DISPEL; + return ESpellCastProblem::NO_SPELLS_TO_DISPEL; } } break; @@ -2154,33 +2149,33 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance bool damageSpell = (vstd::contains(VLC->spellh->damageSpells, spell->id)); if (damageSpell && subject->hasBonusOfType(Bonus::DIRECT_DAMAGE_IMMUNITY)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; if (spell->fire) { if (battleTestElementalImmunity(subject, spell, Bonus::FIRE_IMMUNITY, damageSpell)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; } if (spell->water) { if (battleTestElementalImmunity(subject, spell, Bonus::WATER_IMMUNITY, damageSpell)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; } if (spell->earth) { if (battleTestElementalImmunity(subject, spell, Bonus::EARTH_IMMUNITY, damageSpell)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; } if (spell->air) { if (battleTestElementalImmunity(subject, spell, Bonus::AIR_IMMUNITY, damageSpell)) - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; } if (vstd::contains(VLC->spellh->risingSpells, spell->id)) { if (subject->count >= subject->baseAmount) //TODO: calculate potential hp raised - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; } TBonusListPtr immunities = subject->getBonuses(Selector::type(Bonus::LEVEL_SPELL_IMMUNITY)); @@ -2193,27 +2188,27 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance if(subject->hasBonusOfType(Bonus::SPELL_IMMUNITY, spell->id) || ( immunities->size() > 0 && immunities->totalValue() >= spell->level && spell->level)) { - return SpellCasting::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; } } else { if(spell->getTargetType() == CSpell::CREATURE || - (spell->getTargetType() == CSpell::CREATURE_EXPERT_MASSIVE && mode == SpellCasting::HERO_CASTING && caster && caster->getSpellSchoolLevel(spell) < 3)) + (spell->getTargetType() == CSpell::CREATURE_EXPERT_MASSIVE && mode == ECastingMode::HERO_CASTING && caster && caster->getSpellSchoolLevel(spell) < 3)) { - return SpellCasting::WRONG_SPELL_TARGET; + return ESpellCastProblem::WRONG_SPELL_TARGET; } } - return SpellCasting::OK; + return ESpellCastProblem::OK; } -std::vector BattleInfo::calculateResistedStacks( const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set affectedCreatures, int casterSideOwner, SpellCasting::ECastingMode mode ) const +std::vector BattleInfo::calculateResistedStacks( const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set affectedCreatures, int casterSideOwner, ECastingMode::ECastingMode mode ) const { std::vector ret; for(std::set::const_iterator it = affectedCreatures.begin(); it != affectedCreatures.end(); ++it) { - if(battleIsImmune(caster, sp, mode, (*it)->position) != SpellCasting::OK) + if(battleIsImmune(caster, sp, mode, (*it)->position) != ESpellCastProblem::OK) { ret.push_back((*it)->ID); continue; @@ -2274,7 +2269,7 @@ int BattleInfo::getSurrenderingCost(int player) const discount += h->valOfBonuses(Bonus::SURRENDER_DISCOUNT); ret *= (100.0 - discount) / 100.0; - amax(ret, 0); //no negative costs for >100% discounts (impossible in original H3 mechanics, but some day...) + vstd::amax(ret, 0); //no negative costs for >100% discounts (impossible in original H3 mechanics, but some day...) return ret; } @@ -2325,7 +2320,7 @@ void CStack::init() owner = 255; slot = 255; attackerOwned = false; - position = THex(); + position = SHexField(); counterAttacks = -1; } @@ -2338,7 +2333,7 @@ void CStack::postInit() shots = getCreature()->valOfBonuses(Bonus::SHOTS); counterAttacks = 1 + valOfBonuses(Bonus::ADDITIONAL_RETALIATION); casts = valOfBonuses(Bonus::CASTS); //TODO: set them in cr_abils.txt - state.insert(ALIVE); //alive state indication + state.insert(EBattleStackState::ALIVE); //alive state indication } ui32 CStack::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const @@ -2379,11 +2374,11 @@ si32 CStack::magicResistance() const { if (stack->owner == owner) { - amax(auraBonus, stack->valOfBonuses(Bonus::SPELL_RESISTANCE_AURA)); //max value + vstd::amax(auraBonus, stack->valOfBonuses(Bonus::SPELL_RESISTANCE_AURA)); //max value } } magicResistance += auraBonus; - amin (magicResistance, 100); + vstd::amin (magicResistance, 100); } else magicResistance = type->magicResistance(); @@ -2437,7 +2432,7 @@ void CStack::stackEffectToFeature(std::vector & sf, const Bonus & sse) sf.back().sid = sse.sid; break; case 34: //anti-magic - sf.push_back(featureGenerator(Bonus::LEVEL_SPELL_IMMUNITY, SPELL_LEVELS, power - 1, sse.turnsRemain)); + sf.push_back(featureGenerator(Bonus::LEVEL_SPELL_IMMUNITY, GameConstants::SPELL_LEVELS, power - 1, sse.turnsRemain)); sf.back().valType = Bonus::INDEPENDENT_MAX; sf.back().sid = sse.sid; break; @@ -2586,7 +2581,7 @@ ui8 CStack::howManyEffectsSet(ui16 id) const bool CStack::willMove(int turn /*= 0*/) const { - return ( turn ? true : !vstd::contains(state, DEFENDING) ) + return ( turn ? true : !vstd::contains(state, EBattleStackState::DEFENDING) ) && !moved(turn) && canMove(turn); } @@ -2600,7 +2595,7 @@ bool CStack::canMove( int turn /*= 0*/ ) const bool CStack::moved( int turn /*= 0*/ ) const { if(!turn) - return vstd::contains(state, MOVED); + return vstd::contains(state, EBattleStackState::MOVED); else return false; } @@ -2610,7 +2605,7 @@ bool CStack::doubleWide() const return getCreature()->doubleWide; } -THex CStack::occupiedHex() const +SHexField CStack::occupiedHex() const { if (doubleWide()) { @@ -2621,54 +2616,54 @@ THex CStack::occupiedHex() const } else { - return THex::INVALID; + return SHexField::INVALID; } } -std::vector CStack::getHexes() const +std::vector CStack::getHexes() const { - std::vector hexes; - hexes.push_back(THex(position)); - THex occupied = occupiedHex(); + std::vector hexes; + hexes.push_back(SHexField(position)); + SHexField occupied = occupiedHex(); if(occupied.isValid()) hexes.push_back(occupied); return hexes; } -bool CStack::coversPos(THex pos) const +bool CStack::coversPos(SHexField pos) const { return vstd::contains(getHexes(), pos); } -std::vector CStack::getSurroundingHexes(THex attackerPos) const +std::vector CStack::getSurroundingHexes(SHexField attackerPos) const { - THex hex = (attackerPos != THex::INVALID) ? attackerPos : position; //use hypothetical position - std::vector hexes; + SHexField hex = (attackerPos != SHexField::INVALID) ? attackerPos : position; //use hypothetical position + std::vector hexes; if (doubleWide()) { - const int WN = BFIELD_WIDTH; + const int WN = GameConstants::BFIELD_WIDTH; if(attackerOwned) { //position is equal to front hex - THex::checkAndPush(hex - ( (hex/WN)%2 ? WN+2 : WN+1 ), hexes); - THex::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); - THex::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes); - THex::checkAndPush(hex - 2, hexes); - THex::checkAndPush(hex + 1, hexes); - THex::checkAndPush(hex + ( (hex/WN)%2 ? WN-2 : WN-1 ), hexes); - THex::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes); - THex::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); + SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN+2 : WN+1 ), hexes); + SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); + SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes); + SHexField::checkAndPush(hex - 2, hexes); + SHexField::checkAndPush(hex + 1, hexes); + SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN-2 : WN-1 ), hexes); + SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes); + SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); } else { - THex::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); - THex::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes); - THex::checkAndPush(hex - ( (hex/WN)%2 ? WN-1 : WN-2 ), hexes); - THex::checkAndPush(hex + 2, hexes); - THex::checkAndPush(hex - 1, hexes); - THex::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes); - THex::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); - THex::checkAndPush(hex + ( (hex/WN)%2 ? WN+1 : WN+2 ), hexes); + SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), hexes); + SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), hexes); + SHexField::checkAndPush(hex - ( (hex/WN)%2 ? WN-1 : WN-2 ), hexes); + SHexField::checkAndPush(hex + 2, hexes); + SHexField::checkAndPush(hex - 1, hexes); + SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), hexes); + SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), hexes); + SHexField::checkAndPush(hex + ( (hex/WN)%2 ? WN+1 : WN+2 ), hexes); } return hexes; } @@ -2750,11 +2745,11 @@ void CStack::prepareAttacked(BattleStackAttacked &bsa) const { int resurrectedCount = base->count * resurrectFactor / 100; if (resurrectedCount) - resurrectedCount += ((base->count * resurrectFactor / 100.0f - resurrectedCount) > ran()%100 / 100.0f) ? 1 : 0; //last stack has proportional chance to rebirth + resurrectedCount += ((base->count * resurrectFactor / 100.0 - resurrectedCount) > ran()%100 / 100.0) ? 1 : 0; //last stack has proportional chance to rebirth else //only one unit - resurrectedCount += ((base->count * resurrectFactor / 100.0f) > ran()%100 / 100.0f) ? 1 : 0; + resurrectedCount += ((base->count * resurrectFactor / 100.0) > ran()%100 / 100.0) ? 1 : 0; if (hasBonusOfType(Bonus::REBIRTH, 1)) - amax (resurrectedCount, 1); //resurrect at least one Sacred Phoenix + vstd::amax (resurrectedCount, 1); //resurrect at least one Sacred Phoenix if (resurrectedCount) { bsa.flags |= BattleStackAttacked::REBIRTH; @@ -2769,7 +2764,7 @@ void CStack::prepareAttacked(BattleStackAttacked &bsa) const } } -bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defender, THex attackerPos /*= THex::INVALID*/, THex defenderPos /*= THex::INVALID*/) +bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defender, SHexField attackerPos /*= SHexField::INVALID*/, SHexField defenderPos /*= SHexField::INVALID*/) { if (!attackerPos.isValid()) { @@ -2781,13 +2776,13 @@ bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defen } return - (THex::mutualPosition(attackerPos, defenderPos) >= 0) //front <=> front + (SHexField::mutualPosition(attackerPos, defenderPos) >= 0) //front <=> front || (attacker->doubleWide() //back <=> front - && THex::mutualPosition(attackerPos + (attacker->attackerOwned ? -1 : 1), defenderPos) >= 0) + && SHexField::mutualPosition(attackerPos + (attacker->attackerOwned ? -1 : 1), defenderPos) >= 0) || (defender->doubleWide() //front <=> back - && THex::mutualPosition(attackerPos, defenderPos + (defender->attackerOwned ? -1 : 1)) >= 0) + && SHexField::mutualPosition(attackerPos, defenderPos + (defender->attackerOwned ? -1 : 1)) >= 0) || (defender->doubleWide() && attacker->doubleWide()//back <=> back - && THex::mutualPosition(attackerPos + (attacker->attackerOwned ? -1 : 1), defenderPos + (defender->attackerOwned ? -1 : 1)) >= 0); + && SHexField::mutualPosition(attackerPos + (attacker->attackerOwned ? -1 : 1), defenderPos + (defender->attackerOwned ? -1 : 1)) >= 0); } diff --git a/lib/BattleState.h b/lib/BattleState.h index f63a7804f..f4f6f29d0 100644 --- a/lib/BattleState.h +++ b/lib/BattleState.h @@ -1,12 +1,14 @@ #pragma once -#include "../global.h" + +#include "SHexField.h" #include "HeroBonus.h" #include "CCreatureSet.h" #include "CObjectHandler.h" #include "CCreatureHandler.h" #include "CObstacleInstance.h" #include "ConstTransitivePtr.h" +#include "GameConstants.h" /* * BattleState.h, part of VCMI engine @@ -25,35 +27,36 @@ class CGTownInstance; class CStackInstance; struct BattleStackAttacked; + //only for use in BattleInfo -struct DLL_EXPORT SiegeInfo +struct DLL_LINKAGE SiegeInfo { ui8 wallState[8]; //[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; 1 - intact, 2 - damaged, 3 - destroyed - + template void serialize(Handler &h, const int version) { h & wallState; } }; -struct DLL_EXPORT AttackableTiles +struct DLL_LINKAGE AttackableTiles { - std::set hostileCreaturePositions; - std::set friendlyCreaturePositions; //for Dragon Breath + std::set hostileCreaturePositions; + std::set friendlyCreaturePositions; //for Dragon Breath template void serialize(Handler &h, const int version) { h & hostileCreaturePositions & friendlyCreaturePositions; } }; -struct DLL_EXPORT BattleInfo : public CBonusSystemNode +struct DLL_LINKAGE BattleInfo : public CBonusSystemNode { ui8 sides[2]; //sides[0] - attacker, sides[1] - defender si32 round, activeStack; ui8 siege; // = 0 ordinary battle = 1 a siege with a Fort = 2 a siege with a Citadel = 3 a siege with a Castle const CGTownInstance * town; //used during town siege - id of attacked town; -1 if not town defence int3 tile; //for background and bonuses - CGHeroInstance *heroes[2]; + CGHeroInstance* heroes[2]; CArmedInstance *belligerents[2]; //may be same as heroes std::vector stacks; std::vector obstacles; @@ -84,14 +87,14 @@ struct DLL_EXPORT BattleInfo : public CBonusSystemNode void getStackQueue(std::vector &out, int howMany, int turn = 0, int lastMoved = -1) const; //returns stack in order of their movement action CStack * getStack(int stackID, bool onlyAlive = true); const CStack * getStack(int stackID, bool onlyAlive = true) const; - CStack * getStackT(THex tileID, bool onlyAlive = true); - const CStack * getStackT(THex tileID, bool onlyAlive = true) const; - void getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set & occupyable, bool flying, const CStack* stackToOmmit = NULL) const; //send pointer to at least 187 allocated bytes - static bool isAccessible(THex hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS + CStack * getStackT(SHexField tileID, bool onlyAlive = true); + const CStack * getStackT(SHexField tileID, bool onlyAlive = true) const; + void getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set & occupyable, bool flying, const CStack* stackToOmmit = NULL) const; //send pointer to at least 187 allocated bytes + static bool isAccessible(SHexField hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS int getAvaliableHex(TCreature creID, bool attackerOwned, int initialPos = -1) const; //find place for summon / clone effects - void makeBFS(THex start, bool*accessibility, THex *predecessor, int *dists, bool twoHex, bool attackerOwned, bool flying, bool fillPredecessors) const; //*accessibility must be prepared bool[187] array; last two pointers must point to the at least 187-elements int arrays - there is written result - std::pair< std::vector, int > getPath(THex start, THex dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned); //returned value: pair; length may be different than number of elements in path since flying vreatures jump between distant hexes - std::vector getAccessibility(const CStack * stack, bool addOccupiable, std::vector * attackable = NULL) const; //returns vector of accessible tiles (taking into account the creature range) + void makeBFS(SHexField start, bool*accessibility, SHexField *predecessor, int *dists, bool twoHex, bool attackerOwned, bool flying, bool fillPredecessors) const; //*accessibility must be prepared bool[187] array; last two pointers must point to the at least 187-elements int arrays - there is written result + std::pair< std::vector, int > getPath(SHexField start, SHexField dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned); //returned value: pair; length may be different than number of elements in path since flying vreatures jump between distant hexes + std::vector getAccessibility(const CStack * stack, bool addOccupiable, std::vector * attackable = NULL) const; //returns vector of accessible tiles (taking into account the creature range) bool isStackBlocked(const CStack * stack) const; //returns true if there is neighboring enemy stack @@ -99,56 +102,56 @@ struct DLL_EXPORT BattleInfo : public CBonusSystemNode TDmgRange calculateDmgRange(const CStack* attacker, const CStack* defender, TQuantity attackerCount, TQuantity defenderCount, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky, bool deathBlow, bool ballistaDoubleDmg) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair TDmgRange calculateDmgRange(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky, bool deathBlow, bool ballistaDoubleDmg) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair void calculateCasualties(std::map *casualties) const; //casualties are array of maps size 2 (attacker, defeneder), maps are (crid => amount) - std::set getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, THex destinationTile); //calculates stack affected by given spell - void getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, THex destinationTile, THex attackerPos); //hexes around target that could be attacked in melee - std::set getAttackedCreatures(const CStack* attacker, THex destinationTile, THex attackerPos = THex::INVALID); //calculates range of multi-hex attacks - std::set getAttackedHexes(const CStack* attacker, THex destinationTile, THex attackerPos = THex::INVALID); //calculates range of multi-hex attacks + std::set getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, SHexField destinationTile); //calculates stack affected by given spell + void getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, SHexField destinationTile, SHexField attackerPos); //hexes around target that could be attacked in melee + std::set getAttackedCreatures(const CStack* attacker, SHexField destinationTile, SHexField attackerPos = SHexField::INVALID); //calculates range of multi-hex attacks + std::set getAttackedHexes(const CStack* attacker, SHexField destinationTile, SHexField attackerPos = SHexField::INVALID); //calculates range of multi-hex attacks std::set getAdjacentCreatures (const CStack * stack) const; static int calculateSpellDuration(const CSpell * spell, const CGHeroInstance * caster, int usedSpellPower); - CStack * generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, THex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield - CStack * generateNewStack(const CStackBasicDescriptor &base, int stackID, bool attackerOwned, int slot, THex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield + CStack * generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, SHexField position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield + CStack * generateNewStack(const CStackBasicDescriptor &base, int stackID, bool attackerOwned, int slot, SHexField position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield ui32 getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //returns cost of given spell - int hexToWallPart(THex hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found + int hexToWallPart(SHexField hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found int lineToWallHex(int line) const; //returns hex with wall in given line - std::pair getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const; //if attackerOwned is indetermnate, returened stack is of any owner; hex is the number of hex we should be looking from; returns (nerarest creature, predecessorHex) + std::pair getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const; //if attackerOwned is indetermnate, returened stack is of any owner; hex is the number of hex we should be looking from; returns (nerarest creature, predecessorHex) ui32 calculateSpellBonus(ui32 baseDamage, const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature) const; ui32 calculateSpellDmg(const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature, int spellSchoolLevel, int usedSpellPower) const; //calculates damage inflicted by spell ui32 calculateHealedHP(const CGHeroInstance * caster, const CSpell * spell, const CStack * stack) const; ui32 calculateHealedHP(int healedHealth, const CSpell * spell, const CStack * stack) const; //for Archangel ui32 calculateHealedHP(const CSpell * spell, int usedSpellPower, int spellSchoolLevel, const CStack * stack) const; //unused bool resurrects(TSpell spellid) const; //TODO: move it to spellHandler? - si8 hasDistancePenalty(const CStack * stackID, THex destHex) const; //determines if given stack has distance penalty shooting given pos + si8 hasDistancePenalty(const CStack * stackID, SHexField destHex) const; //determines if given stack has distance penalty shooting given pos si8 sameSideOfWall(int pos1, int pos2) const; //determines if given positions are on the same side of wall - si8 hasWallPenalty(const CStack * stack, THex destHex) const; //determines if given stack has wall penalty shooting given pos - si8 canTeleportTo(const CStack * stack, THex destHex, int telportLevel) const; //determines if given stack can teleport to given place - bool battleCanShoot(const CStack * stack, THex dest) const; //determines if stack with given ID shoot at the selected destination + si8 hasWallPenalty(const CStack * stack, SHexField destHex) const; //determines if given stack has wall penalty shooting given pos + si8 canTeleportTo(const CStack * stack, SHexField destHex, int telportLevel) const; //determines if given stack can teleport to given place + bool battleCanShoot(const CStack * stack, SHexField dest) const; //determines if stack with given ID shoot at the selected destination const CGHeroInstance * getHero(int player) const; //returns fighting hero that belongs to given player - SpellCasting::ESpellCastProblem battleCanCastSpell(int player, SpellCasting::ECastingMode mode) const; //returns true if there are no general issues preventing from casting a spell - SpellCasting::ESpellCastProblem battleCanCastThisSpell(int player, const CSpell * spell, SpellCasting::ECastingMode mode) const; //checks if given player can cast given spell - SpellCasting::ESpellCastProblem battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest) const; //checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into acount general problems such as not having spellbook or mana points etc. - SpellCasting::ESpellCastProblem battleCanCastThisSpellHere(int player, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest) const; //checks if given player can cast given spell at given tile in given mode + ESpellCastProblem::ESpellCastProblem battleCanCastSpell(int player, ECastingMode::ECastingMode mode) const; //returns true if there are no general issues preventing from casting a spell + ESpellCastProblem::ESpellCastProblem battleCanCastThisSpell(int player, const CSpell * spell, ECastingMode::ECastingMode mode) const; //checks if given player can cast given spell + ESpellCastProblem::ESpellCastProblem battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, SHexField dest) const; //checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into acount general problems such as not having spellbook or mana points etc. + ESpellCastProblem::ESpellCastProblem battleCanCastThisSpellHere(int player, const CSpell * spell, ECastingMode::ECastingMode mode, SHexField dest) const; //checks if given player can cast given spell at given tile in given mode bool battleTestElementalImmunity(const CStack * subject, const CSpell * spell, Bonus::BonusType element, bool damageSpell) const; TSpell getRandomBeneficialSpell(const CStack * subject) const; TSpell getRandomCastedSpell(const CStack * caster) const; //called at the beginning of turn for Faerie Dragon - std::vector calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set affectedCreatures, int casterSideOwner, SpellCasting::ECastingMode mode) const; + std::vector calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set affectedCreatures, int casterSideOwner, ECastingMode::ECastingMode mode) const; bool battleCanFlee(int player) const; //returns true if player can flee from the battle - const CStack * battleGetStack(THex pos, bool onlyAlive); //returns stack at given tile + const CStack * battleGetStack(SHexField pos, bool onlyAlive); //returns stack at given tile const CGHeroInstance * battleGetOwner(const CStack * stack) const; //returns hero that owns given stack; NULL if none si8 battleMinSpellLevel() const; //calculates minimum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, 0 is returned void localInit(); static BattleInfo * setupBattle( int3 tile, int terrain, int terType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town ); - bool isInTacticRange( THex dest ) const; + bool isInTacticRange( SHexField dest ) const; int getSurrenderingCost(int player) const; int theOtherPlayer(int player) const; ui8 whatSide(int player) const; }; -class DLL_EXPORT CStack : public CBonusSystemNode, public CStackBasicDescriptor +class DLL_LINKAGE CStack : public CBonusSystemNode, public CStackBasicDescriptor { public: const CStackInstance *base; @@ -158,12 +161,12 @@ public: ui32 firstHPleft; //HP of first creature in stack ui8 owner, slot; //owner - player colour (255 for neutrals), slot - position in garrison (may be 255 for neutrals/called creatures) ui8 attackerOwned; //if true, this stack is owned by attakcer (this one from left hand side of battle) - THex position; //position on battlefield; -2 - keep, -3 - lower tower, -4 - upper tower + SHexField position; //position on battlefield; -2 - keep, -3 - lower tower, -4 - upper tower ui8 counterAttacks; //how many counter attacks can be performed more in this turn (by default set at the beginning of the round to 1) si16 shots; //how many shots left ui8 casts; //how many casts left - std::set state; + std::set state; //overrides const CCreature* getCreature() const {return type;} @@ -204,13 +207,13 @@ public: return ret; } - static bool isMeleeAttackPossible(const CStack * attacker, const CStack * defender, THex attackerPos = THex::INVALID, THex defenderPos = THex::INVALID); + static bool isMeleeAttackPossible(const CStack * attacker, const CStack * defender, SHexField attackerPos = SHexField::INVALID, SHexField defenderPos = SHexField::INVALID); bool doubleWide() const; - THex occupiedHex() const; //returns number of occupied hex (not the position) if stack is double wide; otherwise -1 - std::vector getHexes() const; //up to two occupied hexes, starting from front - bool coversPos(THex position) const; //checks also if unit is double-wide - std::vector getSurroundingHexes(THex attackerPos = THex::INVALID) const; // get six or 8 surrounding hexes depending on creature size + SHexField occupiedHex() const; //returns number of occupied hex (not the position) if stack is double wide; otherwise -1 + std::vector getHexes() const; //up to two occupied hexes, starting from front + bool coversPos(SHexField position) const; //checks also if unit is double-wide + std::vector getSurroundingHexes(SHexField attackerPos = SHexField::INVALID) const; // get six or 8 surrounding hexes depending on creature size void prepareAttacked(BattleStackAttacked &bsa) const; //requires bsa.damageAmout filled @@ -245,11 +248,11 @@ public: } bool alive() const //determines if stack is alive { - return vstd::contains(state,ALIVE); + return vstd::contains(state,EBattleStackState::ALIVE); } }; -class DLL_EXPORT CMP_stack +class DLL_LINKAGE CMP_stack { int phase; //rules of which phase will be used int turn; diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index 838df4443..e4b9e5230 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -1,16 +1,9 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "CArtHandler.h" + #include "CLodHandler.h" #include "CGeneralTextHandler.h" -#include -#include -#include -#include -#include -#include #include -#include #include "../lib/VCMI_Lib.h" #include "CSpellHandler.h" #include "CObjectHandler.h" @@ -226,10 +219,10 @@ void CArtHandler::loadArtifacts(bool onlyTxt) { loadToIt(dump,buf,it,3); } - VLC->generaltexth->artifNames.resize(ARTIFACTS_QUANTITY); - VLC->generaltexth->artifDescriptions.resize(ARTIFACTS_QUANTITY); + VLC->generaltexth->artifNames.resize(GameConstants::ARTIFACTS_QUANTITY); + VLC->generaltexth->artifDescriptions.resize(GameConstants::ARTIFACTS_QUANTITY); std::map::iterator itr; - for (int i=0; iisBig()) //discard big artifact - return Arts::BACKPACK_START + h->artifactsInBackpack.size(); + return GameConstants::BACKPACK_START + h->artifactsInBackpack.size(); return -1; } bool CArtifactInstance::canBePutAt(const ArtifactLocation &al, bool assumeDestRemoved /*= false*/) const { - if(al.slot >= Arts::BACKPACK_START) + if(al.slot >= GameConstants::BACKPACK_START) { if(artType->isBig()) return false; @@ -972,7 +965,7 @@ void CArtifactInstance::putAt(CGHeroInstance *h, ui16 slot) assert(canBePutAt(ArtifactLocation(h, slot))); h->setNewArtSlot(slot, this, false); - if(slot < Arts::BACKPACK_START) + if(slot < GameConstants::BACKPACK_START) h->attachTo(this); } @@ -980,7 +973,7 @@ void CArtifactInstance::removeFrom(CGHeroInstance *h, ui16 slot) { assert(h->CArtifactSet::getArt(slot) == this); h->eraseArtSlot(slot); - if(slot < Arts::BACKPACK_START) + if(slot < GameConstants::BACKPACK_START) h->detachFrom(this); //TODO delete me? @@ -1024,7 +1017,7 @@ void CArtifactInstance::move(ArtifactLocation &src, ArtifactLocation &dst) { removeFrom(src.hero, src.slot); putAt(dst.hero, dst.slot); - if (artType->id == 135 && dst.slot == Arts::RIGHT_HAND && !dst.hero->hasSpellbook()) //Titan's Thunder creates new spellbook on equip + if (artType->id == 135 && dst.slot == ArtifactPosition::RIGHT_HAND && !dst.hero->hasSpellbook()) //Titan's Thunder creates new spellbook on equip dst.hero->giveArtifact(0); } @@ -1071,7 +1064,7 @@ bool CCombinedArtifactInstance::canBePutAt(const ArtifactLocation &al, bool assu bool canMainArtifactBePlaced = CArtifactInstance::canBePutAt(al, assumeDestRemoved); if(!canMainArtifactBePlaced) return false; //no is no... - if(al.slot >= Arts::BACKPACK_START) + if(al.slot >= GameConstants::BACKPACK_START) return true; //we can always remove combined art to the backapck @@ -1087,7 +1080,7 @@ bool CCombinedArtifactInstance::canBePutAt(const ArtifactLocation &al, bool assu } //we iterate over all active slots and check if constituents fits them - for (int i = 0; i < Arts::BACKPACK_START; i++) + for (int i = 0; i < GameConstants::BACKPACK_START; i++) { for(std::vector::iterator art = constituentsToBePlaced.begin(); art != constituentsToBePlaced.end(); art++) { @@ -1137,7 +1130,7 @@ void CCombinedArtifactInstance::addAsConstituent(CArtifactInstance *art, int slo void CCombinedArtifactInstance::putAt(CGHeroInstance *h, ui16 slot) { - if(slot >= Arts::BACKPACK_START) + if(slot >= GameConstants::BACKPACK_START) { CArtifactInstance::putAt(h, slot); BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo) @@ -1153,12 +1146,12 @@ void CCombinedArtifactInstance::putAt(CGHeroInstance *h, ui16 slot) if(ci.art != mainConstituent) { int pos = -1; - if(isbetw(ci.slot, 0, Arts::BACKPACK_START) && ci.art->canBePutAt(ArtifactLocation(h, ci.slot))) //there is a valid suggestion where to place lock + if(vstd::isbetween(ci.slot, 0, GameConstants::BACKPACK_START) && ci.art->canBePutAt(ArtifactLocation(h, ci.slot))) //there is a valid suggestion where to place lock pos = ci.slot; else ci.slot = pos = ci.art->firstAvailableSlot(h); - assert(pos < Arts::BACKPACK_START); + assert(pos < GameConstants::BACKPACK_START); h->setNewArtSlot(pos, ci.art, true); //sets as lock } else @@ -1171,7 +1164,7 @@ void CCombinedArtifactInstance::putAt(CGHeroInstance *h, ui16 slot) void CCombinedArtifactInstance::removeFrom(CGHeroInstance *h, ui16 slot) { - if(slot >= Arts::BACKPACK_START) + if(slot >= GameConstants::BACKPACK_START) { CArtifactInstance::removeFrom(h, slot); } @@ -1292,7 +1285,7 @@ si32 CArtifactSet::getArtPos(int aid, bool onlyWorn /*= true*/) const for(int i = 0; i < artifactsInBackpack.size(); i++) if(artifactsInBackpack[i].artifact->artType->id == aid) - return Arts::BACKPACK_START + i; + return GameConstants::BACKPACK_START + i; return -1; } @@ -1305,7 +1298,7 @@ si32 CArtifactSet::getArtPos(const CArtifactInstance *art) const for(int i = 0; i < artifactsInBackpack.size(); i++) if(artifactsInBackpack[i].artifact == art) - return Arts::BACKPACK_START + i; + return GameConstants::BACKPACK_START + i; return -1; } @@ -1327,9 +1320,9 @@ const ArtSlotInfo * CArtifactSet::getSlot(ui16 pos) const { if(vstd::contains(artifactsWorn, pos)) return &artifactsWorn[pos]; - if(pos >= Arts::AFTER_LAST ) + if(pos >= ArtifactPosition::AFTER_LAST ) { - int backpackPos = (int)pos - Arts::BACKPACK_START; + int backpackPos = (int)pos - GameConstants::BACKPACK_START; if(backpackPos < 0 || backpackPos >= artifactsInBackpack.size()) return NULL; else @@ -1358,22 +1351,22 @@ CArtifactSet::~CArtifactSet() ArtSlotInfo & CArtifactSet::retreiveNewArtSlot(ui16 slot) { assert(!vstd::contains(artifactsWorn, slot)); - ArtSlotInfo &ret = slot < Arts::BACKPACK_START + ArtSlotInfo &ret = slot < GameConstants::BACKPACK_START ? artifactsWorn[slot] - : *artifactsInBackpack.insert(artifactsInBackpack.begin() + (slot - Arts::BACKPACK_START), ArtSlotInfo()); + : *artifactsInBackpack.insert(artifactsInBackpack.begin() + (slot - GameConstants::BACKPACK_START), ArtSlotInfo()); return ret; } void CArtifactSet::eraseArtSlot(ui16 slot) { - if(slot < Arts::BACKPACK_START) + if(slot < GameConstants::BACKPACK_START) { artifactsWorn.erase(slot); } else { - slot -= Arts::BACKPACK_START; + slot -= GameConstants::BACKPACK_START; artifactsInBackpack.erase(artifactsInBackpack.begin() + slot); } } @@ -1381,7 +1374,7 @@ void CArtifactSet::eraseArtSlot(ui16 slot) ArtSlotInfo & CCreatureArtifactSet::retreiveNewArtSlot(ui16 slot) { assert(slot); //ke? - ArtSlotInfo &ret = slot <= Arts::CREATURE_ART + ArtSlotInfo &ret = slot <= GameConstants::CREATURE_ART ? activeArtifact : *artifactsInBackpack.insert(artifactsInBackpack.begin() + (slot - 1), ArtSlotInfo()); @@ -1390,7 +1383,7 @@ ArtSlotInfo & CCreatureArtifactSet::retreiveNewArtSlot(ui16 slot) void CCreatureArtifactSet::eraseArtSlot(ui16 slot) { - if(slot == Arts::CREATURE_ART) + if(slot == GameConstants::CREATURE_ART) { activeArtifact.artifact = NULL; //hmm? } @@ -1403,9 +1396,9 @@ void CCreatureArtifactSet::eraseArtSlot(ui16 slot) const ArtSlotInfo * CCreatureArtifactSet::getSlot(ui16 pos) const { - if (pos == Arts::CREATURE_ART) + if (pos == GameConstants::CREATURE_ART) return &activeArtifact; - else if(pos > Arts::CREATURE_ART) + else if(pos > GameConstants::CREATURE_ART) { int backpackPos = (int)pos - 1; if(backpackPos < 0 || backpackPos >= artifactsInBackpack.size()) @@ -1419,7 +1412,7 @@ const ArtSlotInfo * CCreatureArtifactSet::getSlot(ui16 pos) const si32 CCreatureArtifactSet::getArtPos(int aid, bool onlyWorn) const { if (aid == activeArtifact.artifact->artType->id ) - return Arts::CREATURE_ART; + return GameConstants::CREATURE_ART; if(onlyWorn) return -1; @@ -1436,11 +1429,11 @@ si32 CCreatureArtifactSet::getArtPos(int aid, bool onlyWorn) const si32 CCreatureArtifactSet::getArtPos(const CArtifactInstance *art) const { if (activeArtifact.artifact == art) - return Arts::CREATURE_ART; + return GameConstants::CREATURE_ART; for(int i = 0; i < artifactsInBackpack.size(); i++) if(artifactsInBackpack[i].artifact == art) - return Arts::BACKPACK_START + i; + return GameConstants::BACKPACK_START + i; return -1; } diff --git a/lib/CArtHandler.h b/lib/CArtHandler.h index 3682e74ca..5c9be27e3 100644 --- a/lib/CArtHandler.h +++ b/lib/CArtHandler.h @@ -1,10 +1,7 @@ -#ifndef __CARTHANDLER_H__ -#define __CARTHANDLER_H__ -#include "../global.h" -#include "../lib/HeroBonus.h" -#include -#include +#pragma once + +#include "../lib/HeroBonus.h" #include "../lib/ConstTransitivePtr.h" /* @@ -21,7 +18,18 @@ class CArtifact; class CGHeroInstance; struct ArtifactLocation; -class DLL_EXPORT CArtifact : public CBonusSystemNode //container for artifacts +namespace ArtifactPosition +{ + enum ArtifactPosition + { + PRE_FIRST = -1, + HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, RIGHT_RING, LEFT_RING, FEET, MISC1, MISC2, MISC3, MISC4, + MACH1, MACH2, MACH3, MACH4, SPELLBOOK, MISC5, + AFTER_LAST + }; +} + +class DLL_LINKAGE CArtifact : public CBonusSystemNode //container for artifacts { protected: std::string name, description; //set if custom @@ -54,7 +62,7 @@ public: //void getParents(TCNodes &out, const CBonusSystemNode *root = NULL) const; }; -class DLL_EXPORT CArtifactInstance : public CBonusSystemNode +class DLL_LINKAGE CArtifactInstance : public CBonusSystemNode { protected: void init(); @@ -96,7 +104,7 @@ public: static CArtifactInstance *createNewArtifactInstance(int aid); }; -class DLL_EXPORT CCombinedArtifactInstance : public CArtifactInstance +class DLL_LINKAGE CCombinedArtifactInstance : public CArtifactInstance { CCombinedArtifactInstance(CArtifact *Art); public: @@ -139,7 +147,7 @@ public: } }; -// class DLL_EXPORT IModableArt : public CArtifact //artifact which can have different properties, such as scroll or banner +// class DLL_LINKAGE IModableArt : public CArtifact //artifact which can have different properties, such as scroll or banner // { //used only for dynamic cast :P // public: // si32 ID; //used for smart serialization @@ -151,7 +159,7 @@ public: // } // }; // -// class DLL_EXPORT CScroll : public IModableArt // Spell Scroll +// class DLL_LINKAGE CScroll : public IModableArt // Spell Scroll // { // public: // CScroll(){spellid=0;}; @@ -166,7 +174,7 @@ public: // } // }; // -// class DLL_EXPORT CCustomizableArt : public IModableArt // Warlord's Banner with multiple options +// class DLL_LINKAGE CCustomizableArt : public IModableArt // Warlord's Banner with multiple options // { // public: // ui8 mode; @@ -180,7 +188,7 @@ public: // } // }; // -// class DLL_EXPORT CCommanderArt : public IModableArt // Growing with time +// class DLL_LINKAGE CCommanderArt : public IModableArt // Growing with time // { // public: // ui32 level; @@ -195,7 +203,7 @@ public: // } // }; -class DLL_EXPORT CArtHandler //handles artifacts +class DLL_LINKAGE CArtHandler //handles artifacts { void giveArtBonus(int aid, Bonus::BonusType type, int val, int subtype = -1, int valType = Bonus::BASE_NUMBER, ILimiter * limiter = NULL); void giveArtBonus(int aid, Bonus::BonusType type, int val, int subtype, IPropagator* propagator); @@ -231,7 +239,7 @@ public: } }; -struct DLL_EXPORT ArtSlotInfo +struct DLL_LINKAGE ArtSlotInfo { ConstTransitivePtr artifact; ui8 locked; //if locked, then artifact points to the combined artifact @@ -246,7 +254,7 @@ struct DLL_EXPORT ArtSlotInfo } }; -class DLL_EXPORT IArtifactSetBase +class DLL_LINKAGE IArtifactSetBase { ///artifacts container public: virtual void setNewArtSlot(ui16 slot, CArtifactInstance *art, bool locked); @@ -265,7 +273,7 @@ public: virtual si32 getArtTypeId(ui16 pos) const=0; }; -class DLL_EXPORT CArtifactSet : public IArtifactSetBase +class DLL_LINKAGE CArtifactSet : public IArtifactSetBase { ///hero artifacts public: std::vector artifactsInBackpack; //hero's artifacts from bag @@ -288,7 +296,7 @@ public: } }; -class DLL_EXPORT CCreatureArtifactSet : public IArtifactSetBase +class DLL_LINKAGE CCreatureArtifactSet : public IArtifactSetBase { ///creature artifacts public: std::vector artifactsInBackpack; //artifacts carried by creature - 4 max @@ -310,5 +318,3 @@ public: h & artifactsInBackpack & activeArtifact; } }; - -#endif // __CARTHANDLER_H__ diff --git a/lib/CBuildingHandler.cpp b/lib/CBuildingHandler.cpp index 061b94bcf..37201b7e8 100644 --- a/lib/CBuildingHandler.cpp +++ b/lib/CBuildingHandler.cpp @@ -1,15 +1,11 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "CBuildingHandler.h" + #include "CGeneralTextHandler.h" #include "CLodHandler.h" #include "../lib/VCMI_Lib.h" -#include -#include -#include -#include -#include #include "../lib/JsonNode.h" +#include "GameConstants.h" extern CLodHandler * bitmaph; @@ -23,7 +19,7 @@ extern CLodHandler * bitmaph; * */ -static unsigned int readNr(std::string &in, int &it) +static ui32 readNr(std::string &in, int &it) { int last=it; for(;lasttid = f; @@ -83,12 +79,12 @@ void CBuildingHandler::loadBuildings() } //create Grail entries - for(int i=0; i builtBu return campToERMU[camp]; } - static const std::vector hordeLvlsPerTType[F_NUMBER] = {list_of(2), list_of(1), list_of(1)(4), list_of(0)(2), + static const std::vector hordeLvlsPerTType[GameConstants::F_NUMBER] = {list_of(2), list_of(1), list_of(1)(4), list_of(0)(2), list_of(0), list_of(0), list_of(0), list_of(0), list_of(0)}; int curPos = campToERMU.size(); diff --git a/lib/CBuildingHandler.h b/lib/CBuildingHandler.h index 80a43148d..e36f0295f 100644 --- a/lib/CBuildingHandler.h +++ b/lib/CBuildingHandler.h @@ -1,9 +1,5 @@ -#ifndef __CBUILDINGHANDLER_H__ -#define __CBUILDINGHANDLER_H__ -#include "../global.h" -#include -#include -#include +#pragma once + #include "../lib/ConstTransitivePtr.h" #include "ResourceSet.h" @@ -19,7 +15,7 @@ */ //enum EbuildingType {NEUTRAL=-1, CASTLE, RAMPART, TOWER, INFERNO, NECROPOLIS, DUNGEON, STRONGHOLD, FORTRESS, CONFLUX}; -class DLL_EXPORT CBuilding //a typical building encountered in every castle ;] +class DLL_LINKAGE CBuilding //a typical building encountered in every castle ;] { public: si32 tid, bid; //town ID and structure ID @@ -37,7 +33,7 @@ public: CBuilding(int TID = -1, int BID = -1); }; -class DLL_EXPORT CBuildingHandler +class DLL_LINKAGE CBuildingHandler { public: std::vector< bmap > > buildings; ///< vector by castle ID, second the building ID (in ERM-U format) @@ -52,6 +48,3 @@ public: h & buildings & hall; } }; - - -#endif // __CBUILDINGHANDLER_H__ diff --git a/lib/CCampaignHandler.cpp b/lib/CCampaignHandler.cpp index 57958ab6f..4c9ad6404 100644 --- a/lib/CCampaignHandler.cpp +++ b/lib/CCampaignHandler.cpp @@ -1,18 +1,14 @@ -#define VCMI_DLL - +#include "StdInc.h" #include "CCampaignHandler.h" -#include -#include -#include + #include "CLodHandler.h" #include "../lib/VCMI_Lib.h" #include "../lib/vcmi_endian.h" #include "CGeneralTextHandler.h" -#include "../StartInfo.h" +#include "StartInfo.h" #include "CArtHandler.h" //for hero crossover #include "CObjectHandler.h" //for hero crossover #include "CHeroHandler.h" -#include namespace fs = boost::filesystem; @@ -31,7 +27,7 @@ std::vector CCampaignHandler::getCampaignHeaders(GetMode mode) { std::vector ret; - std::string dirname = DATA_DIR "/Maps"; + std::string dirname = GameConstants::DATA_DIR + "/Maps"; std::string ext = ".H3C"; if(!boost::filesystem::exists(dirname)) @@ -70,7 +66,7 @@ std::vector CCampaignHandler::getCampaignHeaders(GetMode mode) CCampaignHeader CCampaignHandler::getHeader( const std::string & name, bool fromLod ) { int realSize; - unsigned char * cmpgn = getFile(name, fromLod, realSize); + ui8 * cmpgn = getFile(name, fromLod, realSize); int it = 0;//iterator for reading CCampaignHeader ret = readHeaderFromMemory(cmpgn, it); @@ -87,7 +83,7 @@ CCampaign * CCampaignHandler::getCampaign( const std::string & name, bool fromLo CCampaign * ret = new CCampaign(); int realSize; - unsigned char * cmpgn = getFile(name, fromLod, realSize); + ui8 * cmpgn = getFile(name, fromLod, realSize); int it = 0; //iterator for reading ret->header = readHeaderFromMemory(cmpgn, it); @@ -139,7 +135,7 @@ CCampaign * CCampaignHandler::getCampaign( const std::string & name, bool fromLo return ret; } -CCampaignHeader CCampaignHandler::readHeaderFromMemory( const unsigned char *buffer, int & outIt ) +CCampaignHeader CCampaignHandler::readHeaderFromMemory( const ui8 *buffer, int & outIt ) { CCampaignHeader ret; ret.version = read_le_u32(buffer + outIt); outIt+=4; @@ -155,12 +151,12 @@ CCampaignHeader CCampaignHandler::readHeaderFromMemory( const unsigned char *buf return ret; } -CCampaignScenario CCampaignHandler::readScenarioFromMemory( const unsigned char *buffer, int & outIt, int version, int mapVersion ) +CCampaignScenario CCampaignHandler::readScenarioFromMemory( const ui8 *buffer, int & outIt, int version, int mapVersion ) { struct HLP { //reads prolog/epilog info from memory - static CCampaignScenario::SScenarioPrologEpilog prologEpilogReader( const unsigned char *buffer, int & outIt ) + static CCampaignScenario::SScenarioPrologEpilog prologEpilogReader( const ui8 *buffer, int & outIt ) { CCampaignScenario::SScenarioPrologEpilog ret; ret.hasPrologEpilog = buffer[outIt++]; @@ -196,7 +192,7 @@ CCampaignScenario CCampaignHandler::readScenarioFromMemory( const unsigned char return ret; } -CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory( const unsigned char * buffer, int & outIt , int version ) +CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory( const ui8 * buffer, int & outIt , int version ) { CScenarioTravel ret; @@ -328,7 +324,7 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory( const unsigned c return ret; } -std::vector CCampaignHandler::locateH3mStarts( const unsigned char * buffer, int start, int size ) +std::vector CCampaignHandler::locateH3mStarts( const ui8 * buffer, int start, int size ) { std::vector ret; for(int g=start; g CCampaignHandler::locateH3mStarts( const unsigned char * buffe return ret; } -bool CCampaignHandler::startsAt( const unsigned char * buffer, int size, int pos ) +bool CCampaignHandler::startsAt( const ui8 * buffer, int size, int pos ) { struct HLP { - static unsigned char at(const unsigned char * buffer, int size, int place) + static ui8 at(const ui8 * buffer, int size, int place) { if(place < size) return buffer[place]; @@ -360,7 +356,7 @@ bool CCampaignHandler::startsAt( const unsigned char * buffer, int size, int pos HLP::at(buffer, size, 100); //check version - unsigned char tmp = HLP::at(buffer, size, pos); + ui8 tmp = HLP::at(buffer, size, pos); if(!(tmp == 0x0e || tmp == 0x15 || tmp == 0x1c || tmp == 0x33)) { return false; @@ -413,9 +409,9 @@ bool CCampaignHandler::startsAt( const unsigned char * buffer, int size, int pos return true; } -unsigned char * CCampaignHandler::getFile( const std::string & name, bool fromLod, int & outSize ) +ui8 * CCampaignHandler::getFile( const std::string & name, bool fromLod, int & outSize ) { - unsigned char * cmpgn = 0; + ui8 * cmpgn = 0; if(fromLod) { if (bitmaph->haveFile(name, FILE_CAMPAIGN)) diff --git a/lib/CCampaignHandler.h b/lib/CCampaignHandler.h index 5b1dabd9c..9170422b9 100644 --- a/lib/CCampaignHandler.h +++ b/lib/CCampaignHandler.h @@ -1,9 +1,6 @@ -#ifndef __CCAMPAIGNHANDLER_H__ -#define __CCAMPAIGNHANDLER_H__ +#pragma once + -#include "../global.h" -#include -#include /* * CCampaignHandler.h, part of VCMI engine @@ -29,7 +26,7 @@ namespace CampaignVersion }; } -class DLL_EXPORT CCampaignHeader +class DLL_LINKAGE CCampaignHeader { public: si32 version; //4 - RoE, 5 - AB, 6 - SoD and WoG @@ -47,7 +44,7 @@ public: } }; -class DLL_EXPORT CScenarioTravel +class DLL_LINKAGE CScenarioTravel { public: ui8 whatHeroKeeps; //bitfield [0] - experience, [1] - prim skills, [2] - sec skills, [3] - spells, [4] - artifacts @@ -58,7 +55,7 @@ public: ui8 playerColor; //only for startOptions == 1 - struct DLL_EXPORT STravelBonus + struct DLL_LINKAGE STravelBonus { ui8 type; //0 - spell, 1 - monster, 2 - building, 3 - artifact, 4 - spell scroll, 5 - prim skill, 6 - sec skill, 7 - resource, //8 - player from previous scenario, 9 - hero [???] @@ -81,7 +78,7 @@ public: }; -class DLL_EXPORT CCampaignScenario +class DLL_LINKAGE CCampaignScenario { public: std::string mapName; @@ -93,7 +90,7 @@ public: std::string regionText; - struct DLL_EXPORT SScenarioPrologEpilog + struct DLL_LINKAGE SScenarioPrologEpilog { ui8 hasPrologEpilog; ui8 prologVideo; // from CmpMovie.txt @@ -123,7 +120,7 @@ public: } }; -class DLL_EXPORT CCampaign +class DLL_LINKAGE CCampaign { public: CCampaignHeader header; @@ -140,7 +137,7 @@ public: CCampaign(); }; -class DLL_EXPORT CCampaignState +class DLL_LINKAGE CCampaignState { public: CCampaign *camp; @@ -157,14 +154,14 @@ public: } }; -class DLL_EXPORT CCampaignHandler +class DLL_LINKAGE CCampaignHandler { - static CCampaignHeader readHeaderFromMemory( const unsigned char *buffer, int & outIt ); - static CCampaignScenario readScenarioFromMemory( const unsigned char *buffer, int & outIt, int version, int mapVersion ); - static CScenarioTravel readScenarioTravelFromMemory( const unsigned char * buffer, int & outIt , int version); - static std::vector locateH3mStarts(const unsigned char * buffer, int start, int size); - static bool startsAt( const unsigned char * buffer, int size, int pos ); //a simple heuristic that checks if a h3m starts at given pos - static unsigned char * getFile(const std::string & name, bool fromLod, int & outSize); + static CCampaignHeader readHeaderFromMemory( const ui8 *buffer, int & outIt ); + static CCampaignScenario readScenarioFromMemory( const ui8 *buffer, int & outIt, int version, int mapVersion ); + static CScenarioTravel readScenarioTravelFromMemory( const ui8 * buffer, int & outIt , int version); + static std::vector locateH3mStarts(const ui8 * buffer, int start, int size); + static bool startsAt( const ui8 * buffer, int size, int pos ); //a simple heuristic that checks if a h3m starts at given pos + static ui8 * getFile(const std::string & name, bool fromLod, int & outSize); public: enum GetMode {RoE, AB, SoD, WoG, Custom, ALL}; static std::vector getCampaignHeaders(GetMode mode); @@ -172,6 +169,3 @@ public: static CCampaign * getCampaign(const std::string & name, bool fromLod); //name - name of appropriate file }; - - -#endif /* __CCAMPAIGNHANDLER_H__ */ diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index 25352d265..f4a86d311 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -1,19 +1,9 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "CCreatureHandler.h" + #include "CLodHandler.h" -#include -#include -#include -#include -#include -#include -#include -#include #include "../lib/VCMI_Lib.h" #include "../lib/CGameState.h" -#include -#include #include "../lib/JsonNode.h" using namespace boost::assign; @@ -77,7 +67,7 @@ int CCreature::getQuantityID(const int & quantity) return 8; } -int CCreature::estimateCreatureCount(unsigned int countID) +int CCreature::estimateCreatureCount(ui32 countID) { static const int creature_count[] = { 3, 8, 15, 35, 75, 175, 375, 750, 2500 }; @@ -179,7 +169,7 @@ int readNumber(int & befi, int & i, int andame, std::string & buf) //helper func return ret; } -float readFloat(int & befi, int & i, int andame, std::string & buf) //helper function for void CCreatureHandler::loadUnitAnimInfo() +double readFloat(int & befi, int & i, int andame, std::string & buf) //helper function for void CCreatureHandler::loadUnitAnimInfo() { befi=i; for(; i::const_iterator it_map; @@ -498,7 +488,7 @@ void CCreatureHandler::loadCreatures() //std::map >::iterator it = stackBonuses.find(Bonus::MAGIC_RESISTANCE); //stackBonuses[Bonus::SECONDARY_SKILL_PREMY] = std::pair(it->second.first, it->second.second); - if (STACK_EXP) //reading default stack experience bonuses + if (GameConstants::STACK_EXP) //reading default stack experience bonuses { buf = bitmaph->getTextFile("CREXPBON.TXT"); int it = 0; @@ -830,7 +820,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, std::string & src break; case ':': b.type = Bonus::LEVEL_SPELL_IMMUNITY; - b.val = SPELL_LEVELS; //in case someone adds higher level spells? + b.val = GameConstants::SPELL_LEVELS; //in case someone adds higher level spells? break; case 'F': b.type = Bonus::FIRE_IMMUNITY; @@ -1027,7 +1017,7 @@ int CCreatureHandler::pickRandomMonster(const boost::function &randGen, i } else { - assert(iswith(tier, 1, 7)); + assert(vstd::iswithin(tier, 1, 7)); std::vector allowed; BOOST_FOREACH(const CBonusSystemNode *b, creaturesOfLevel[tier].getChildrenNodes()) { @@ -1051,7 +1041,7 @@ int CCreatureHandler::pickRandomMonster(const boost::function &randGen, i void CCreatureHandler::addBonusForTier(int tier, Bonus *b) { - assert(iswith(tier, 1, 7)); + assert(vstd::iswithin(tier, 1, 7)); creaturesOfLevel[tier].addNewBonus(b); } @@ -1064,7 +1054,7 @@ void CCreatureHandler::buildBonusTreeForTiers() { BOOST_FOREACH(CCreature *c, creatures) { - if(isbetw(c->level, 0, ARRAY_COUNT(creaturesOfLevel))) + if(vstd::isbetween(c->level, 0, ARRAY_COUNT(creaturesOfLevel))) c->attachTo(&creaturesOfLevel[c->level]); else c->attachTo(&creaturesOfLevel[0]); diff --git a/lib/CCreatureHandler.h b/lib/CCreatureHandler.h index ce246aac1..6c6c8337e 100644 --- a/lib/CCreatureHandler.h +++ b/lib/CCreatureHandler.h @@ -1,14 +1,10 @@ -#ifndef __CCREATUREHANDLER_H__ -#define __CCREATUREHANDLER_H__ -#include "../global.h" -#include -#include -#include -#include +#pragma once + #include "../lib/HeroBonus.h" #include "../lib/ConstTransitivePtr.h" #include "ResourceSet.h" +#include "GameConstants.h" /* * CCreatureHandler.h, part of VCMI engine @@ -25,7 +21,7 @@ class CLodHandler; class CCreatureHandler; class CCreature; -class DLL_EXPORT CCreature : public CBonusSystemNode +class DLL_LINKAGE CCreature : public CBonusSystemNode { public: std::string namePl, nameSing, nameRef; //name in singular and plural form; and reference name @@ -44,9 +40,9 @@ public: ui8 doubleWide; ///animation info - float timeBetweenFidgets, walkAnimationTime, attackAnimationTime, flightAnimationDistance; + double timeBetweenFidgets, walkAnimationTime, attackAnimationTime, flightAnimationDistance; int upperRightMissleOffsetX, rightMissleOffsetX, lowerRightMissleOffsetX, upperRightMissleOffsetY, rightMissleOffsetY, lowerRightMissleOffsetY; - float missleFrameAngles[12]; + double missleFrameAngles[12]; int troopCountLocationOffset, attackClimaxFrame; ///end of anim info @@ -58,7 +54,7 @@ public: bool isEvil () const; si32 maxAmount(const std::vector &res) const; //how many creatures can be bought static int getQuantityID(const int & quantity); //0 - a few, 1 - several, 2 - pack, 3 - lots, 4 - horde, 5 - throng, 6 - swarm, 7 - zounds, 8 - legion - static int estimateCreatureCount(unsigned int countID); //reverse version of above function, returns middle of range + static int estimateCreatureCount(ui32 countID); //reverse version of above function, returns middle of range bool isMyUpgrade(const CCreature *anotherCre) const; bool valid() const; @@ -98,10 +94,11 @@ public: friend class CCreatureHandler; }; -class DLL_EXPORT CCreatureHandler +class DLL_LINKAGE CCreatureHandler { private: //? - CBonusSystemNode allCreatures, creaturesOfLevel[CREATURES_PER_TOWN + 1];//index 0 is used for creatures of unknown tier or outside <1-7> range + CBonusSystemNode allCreatures; + CBonusSystemNode creaturesOfLevel[GameConstants::CREATURES_PER_TOWN + 1];//index 0 is used for creatures of unknown tier or outside <1-7> range public: std::set notUsedMonsters; std::set doubledCreatures; //they get double week @@ -110,7 +107,7 @@ public: bmap idToProjectile; bmap idToProjectileSpin; //if true, appropriate projectile is spinning during flight std::vector factionAlignments; //1 for good, 0 for neutral and -1 for evil with faction ID as index - int factionToTurretCreature[F_NUMBER]; //which creature's animation should be used to dispaly creature in turret while siege + int factionToTurretCreature[GameConstants::F_NUMBER]; //which creature's animation should be used to dispaly creature in turret while siege std::map > stackBonuses; // bonus => name, description std::vector > expRanks; // stack experience needed for certain rank, index 0 for other tiers (?) @@ -147,5 +144,3 @@ public: BONUS_TREE_DESERIALIZATION_FIX } }; - -#endif // __CCREATUREHANDLER_H__ diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index 04e89acc3..a6eb92ced 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -1,16 +1,13 @@ -#define VCMI_DLL +#include "StdInc.h" #include "CCreatureSet.h" + #include "CCreatureHandler.h" #include "VCMI_Lib.h" -#include #include "CObjectHandler.h" #include "IGameCallback.h" #include "CGameState.h" #include "CGeneralTextHandler.h" -#include #include "CSpellHandler.h" -#include -#include const CStackInstance &CCreatureSet::operator[](TSlot slot) const { @@ -240,8 +237,8 @@ void CCreatureSet::setStackCount(TSlot slot, TQuantity count) { assert(hasStackAtSlot(slot)); assert(stacks[slot]->count + count > 0); - if (STACK_EXP && count > stacks[slot]->count) - stacks[slot]->experience *= (count/(float)stacks[slot]->count); + if (GameConstants::STACK_EXP && count > stacks[slot]->count) + stacks[slot]->experience *= (count / static_cast(stacks[slot]->count)); stacks[slot]->count = count; armyChanged(); } @@ -282,7 +279,7 @@ void CCreatureSet::eraseStack(TSlot slot) { assert(hasStackAtSlot(slot)); CStackInstance *toErase = detachStack(slot); - delNull(toErase); + vstd::clear_pointer(toErase); } bool CCreatureSet::contains(const CStackInstance *stack) const @@ -330,7 +327,7 @@ void CCreatureSet::joinStack(TSlot slot, CStackInstance * stack) //TODO move stuff changeStackCount(slot, stack->count); - delNull(stack); + vstd::clear_pointer(stack); } void CCreatureSet::changeStackCount(TSlot slot, TQuantity toAdd) @@ -396,7 +393,7 @@ bool CCreatureSet::canBeMergedWith(const CCreatureSet &cs, bool allowMergingStac { if(!allowMergingStacks) { - int freeSlots = stacksCount() - ARMY_SIZE; + int freeSlots = stacksCount() - GameConstants::ARMY_SIZE; std::set cresToAdd; for(TSlots::const_iterator i = cs.stacks.begin(); i != cs.stacks.end(); i++) { @@ -480,7 +477,7 @@ int CStackInstance::getQuantityID() const int CStackInstance::getExpRank() const { int tier = type->level; - if (iswith(tier, 1, 7)) + if (vstd::iswithin(tier, 1, 7)) { for (int i = VLC->creh->expRanks[tier].size()-2; i >-1; --i)//sic! { //exp values vary from 1st level to max exp at 11th level @@ -508,22 +505,22 @@ si32 CStackInstance::magicResistance() const //resistance skill val += hero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::RESISTANCE); } - amin (val, 100); + vstd::amin (val, 100); return val; } void CStackInstance::giveStackExp(expType exp) { int level = type->level; - if (!iswith(level, 1, 7)) + if (!vstd::iswithin(level, 1, 7)) level = 0; CCreatureHandler * creh = VLC->creh; ui32 maxExp = creh->expRanks[level].back(); - amin(exp, (expType)maxExp); //prevent exp overflow due to different types - amin(exp, (maxExp * creh->maxExpPerBattle[level])/100); - amin(experience += exp, maxExp); //can't get more exp than this limit + vstd::amin(exp, (expType)maxExp); //prevent exp overflow due to different types + vstd::amin(exp, (maxExp * creh->maxExpPerBattle[level])/100); + vstd::amin(experience += exp, maxExp); //can't get more exp than this limit } void CStackInstance::setType(int creID) @@ -539,8 +536,8 @@ void CStackInstance::setType(const CCreature *c) if(type) { detachFrom(const_cast(type)); - if (type->isMyUpgrade(c) && STACK_EXP) - experience *= VLC->creh->expAfterUpgrade / 100.0f; + if (type->isMyUpgrade(c) && GameConstants::STACK_EXP) + experience *= VLC->creh->expAfterUpgrade / 100.0; } type = c; @@ -840,7 +837,7 @@ std::string CStackInstance::bonusToGraphics(Bonus *bonus) const break; case Bonus::LEVEL_SPELL_IMMUNITY: { - if (iswith(bonus->val, 1 , 5)) + if (vstd::iswithin(bonus->val, 1 , 5)) { fileName = "E_SPLVL" + boost::lexical_cast(bonus->val) + ".bmp"; } @@ -961,7 +958,7 @@ CStackBasicDescriptor::CStackBasicDescriptor(const CCreature *c, TQuantity Count { } -DLL_EXPORT std::ostream & operator<<(std::ostream & str, const CStackInstance & sth) +DLL_LINKAGE std::ostream & operator<<(std::ostream & str, const CStackInstance & sth) { if(!sth.valid(true)) str << "an invalid stack!"; diff --git a/lib/CCreatureSet.h b/lib/CCreatureSet.h index 24561360d..070b43aee 100644 --- a/lib/CCreatureSet.h +++ b/lib/CCreatureSet.h @@ -1,16 +1,15 @@ -#ifndef __CCREATURESET_H__ -#define __CCREATURESET_H__ +#pragma once + -#include "../global.h" -#include #include "HeroBonus.h" +#include "GameConstants.h" class CCreature; class CGHeroInstance; class CArmedInstance; -class DLL_EXPORT CStackBasicDescriptor +class DLL_LINKAGE CStackBasicDescriptor { public: const CCreature *type; @@ -26,7 +25,7 @@ public: } }; -class DLL_EXPORT CStackInstance : public CBonusSystemNode, public CStackBasicDescriptor +class DLL_LINKAGE CStackInstance : public CBonusSystemNode, public CStackBasicDescriptor { const CArmedInstance *_armyObj; //stack must be part of some army, army must be part of some object public: @@ -70,7 +69,7 @@ public: void deserializationFix(); }; -DLL_EXPORT std::ostream & operator<<(std::ostream & str, const CStackInstance & sth); +DLL_LINKAGE std::ostream & operator<<(std::ostream & str, const CStackInstance & sth); typedef std::map TSlots; typedef std::map TSimpleSlots; @@ -83,7 +82,7 @@ public: }; //simplified version of CCreatureSet -class DLL_EXPORT CSimpleArmy : public IArmyDescriptor +class DLL_LINKAGE CSimpleArmy : public IArmyDescriptor { public: TSimpleSlots army; @@ -97,7 +96,7 @@ public: } }; -class DLL_EXPORT CCreatureSet : public IArmyDescriptor //seven combined creatures +class DLL_LINKAGE CCreatureSet : public IArmyDescriptor //seven combined creatures { CCreatureSet(const CCreatureSet&);; CCreatureSet &operator=(const CCreatureSet&); @@ -140,9 +139,9 @@ public: int getStackCount (TSlot slot) const; expType getStackExperience(TSlot slot) const; TSlot findStack(const CStackInstance *stack) const; //-1 if none - TSlot getSlotFor(TCreature creature, ui32 slotsAmount=ARMY_SIZE) const; //returns -1 if no slot available - TSlot getSlotFor(const CCreature *c, ui32 slotsAmount=ARMY_SIZE) const; //returns -1 if no slot available - TSlot getFreeSlot(ui32 slotsAmount=ARMY_SIZE) const; + TSlot getSlotFor(TCreature creature, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available + TSlot getSlotFor(const CCreature *c, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available + TSlot getFreeSlot(ui32 slotsAmount = GameConstants::ARMY_SIZE) const; bool mergableStacks(std::pair &out, TSlot preferable = -1) const; //looks for two same stacks, returns slot positions; bool validTypes(bool allowUnrandomized = false) const; //checks if all types of creatures are set properly bool slotEmpty(TSlot slot) const; @@ -166,5 +165,3 @@ public: } void sweep(); }; - -#endif // __CCREATURESET_H__ diff --git a/lib/CDefObjInfoHandler.cpp b/lib/CDefObjInfoHandler.cpp index 7a447a6bf..c82e09bd0 100644 --- a/lib/CDefObjInfoHandler.cpp +++ b/lib/CDefObjInfoHandler.cpp @@ -1,11 +1,10 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "CDefObjInfoHandler.h" + #include "../client/CGameInfo.h" #include "CLodHandler.h" -#include #include "../lib/VCMI_Lib.h" -#include +#include "GameConstants.h" extern CLodHandler * bitmaph; @@ -120,7 +119,7 @@ void CDefObjInfoHandler::load() gobjs[nobj->id][nobj->subid] = nobj; - if(nobj->id==TOWNI_TYPE) + if(nobj->id==GameConstants::TOWNI_TYPE) castles[nobj->subid]=nobj; } diff --git a/lib/CDefObjInfoHandler.h b/lib/CDefObjInfoHandler.h index f4d9a038d..93cdce8dd 100644 --- a/lib/CDefObjInfoHandler.h +++ b/lib/CDefObjInfoHandler.h @@ -1,8 +1,6 @@ -#ifndef __CDEFOBJINFOHANDLER_H__ -#define __CDEFOBJINFOHANDLER_H__ -#include -#include -#include "../global.h" +#pragma once + + #include "../lib/ConstTransitivePtr.h" /* @@ -17,7 +15,7 @@ class CDefEssential; class CLodHandler; -class DLL_EXPORT CGDefInfo +class DLL_LINKAGE CGDefInfo { public: std::string name; @@ -48,7 +46,7 @@ public: CGDefInfo(); void fetchInfoFromMSK(); }; -class DLL_EXPORT CDefObjInfoHandler +class DLL_LINKAGE CDefObjInfoHandler { public: bmap > > gobjs; @@ -63,5 +61,3 @@ public: h & castles; } }; - -#endif // __CDEFOBJINFOHANDLER_H__ diff --git a/lib/CFileUtility.cpp b/lib/CFileUtility.cpp index 3d7022290..1b016b19a 100644 --- a/lib/CFileUtility.cpp +++ b/lib/CFileUtility.cpp @@ -1,7 +1,5 @@ -#define VCMI_DLL +#include "StdInc.h" #include "CFileUtility.h" -#include // includes all needed Boost.Filesystem declarations -#include /* * CFileUtility.cpp, part of VCMI engine diff --git a/lib/CFileUtility.h b/lib/CFileUtility.h index 063040a7a..48d1fdaeb 100644 --- a/lib/CFileUtility.h +++ b/lib/CFileUtility.h @@ -1,5 +1,6 @@ #pragma once -#include "../global.h" + + /* * CFileUtility.cpp, part of VCMI engine @@ -19,7 +20,7 @@ struct FileInfo bool inLod; //tells if this file is located in Lod }; -class DLL_EXPORT CFileUtility +class DLL_LINKAGE CFileUtility { public: CFileUtility(void); diff --git a/lib/CGameInterface.cpp b/lib/CGameInterface.cpp index 278c0f98f..a7e09e895 100644 --- a/lib/CGameInterface.cpp +++ b/lib/CGameInterface.cpp @@ -1,6 +1,8 @@ -#define VCMI_DLL +#include "StdInc.h" #include "CGameInterface.h" + #include "BattleState.h" +#include "GameConstants.h" #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing @@ -63,12 +65,12 @@ rett * createAny(std::string dllname, std::string methodName) #ifdef _WIN32 std::string getAIFileName(std::string input) { - return input + '.' + LIB_EXT; + return input + '.' + GameConstants::LIB_EXT; } #else std::string getAIFileName(std::string input) { - return "lib" + input + '.' + LIB_EXT; + return "lib" + input + '.' + GameConstants::LIB_EXT; } #endif @@ -77,7 +79,7 @@ rett * createAnyAI(std::string dllname, std::string methodName) { tlog1<<"Opening "<(LIB_DIR "/AI/" + filename, methodName); + rett* ret = createAny(GameConstants::LIB_DIR + "/AI/" + filename, methodName); ret->dllName = dllname; return ret; } @@ -168,7 +170,7 @@ void CAdventureAI::battleNewStackAppeared(const CStack * stack) battleAI->battleNewStackAppeared(stack); } -void CAdventureAI::battleStackMoved(const CStack * stack, std::vector dest, int distance) +void CAdventureAI::battleStackMoved(const CStack * stack, std::vector dest, int distance) { battleAI->battleStackMoved(stack, dest, distance); } @@ -186,7 +188,7 @@ void CAdventureAI::battleSpellCast(const BattleSpellCast *sc) void CAdventureAI::battleEnd(const BattleResult *br) { battleAI->battleEnd(br); - delNull(battleAI); + vstd::clear_pointer(battleAI); } void CAdventureAI::battleStacksHealedRes(const std::vector > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) @@ -202,4 +204,4 @@ BattleAction CAdventureAI::activeStack(const CStack * stack) void CAdventureAI::yourTacticPhase(int distance) { battleAI->yourTacticPhase(distance); -} \ No newline at end of file +} diff --git a/lib/CGameInterface.h b/lib/CGameInterface.h index cb6f41239..118ba2d71 100644 --- a/lib/CGameInterface.h +++ b/lib/CGameInterface.h @@ -1,8 +1,6 @@ -#ifndef __CGAMEINTERFACE_H__ -#define __CGAMEINTERFACE_H__ -#include "../global.h" -#include -#include +#pragma once + + #include "BattleAction.h" #include "IGameEventsReceiver.h" @@ -49,7 +47,6 @@ class CStack; class CCreature; class CLoadFile; class CSaveFile; -typedef si32 TQuantity; template class CISer; template class COSer; struct ArtifactLocation; @@ -83,7 +80,7 @@ public: virtual void serialize(CISer &h, const int version){}; //loading }; -class DLL_EXPORT CDynLibHandler +class DLL_LINKAGE CDynLibHandler { public: static CGlobalAI * getNewAI(std::string dllname); @@ -91,21 +88,21 @@ public: static CScriptingModule * getNewScriptingModule(std::string dllname); }; -class DLL_EXPORT CGlobalAI : public CGameInterface // AI class (to derivate) +class DLL_LINKAGE CGlobalAI : public CGameInterface // AI class (to derivate) { public: CGlobalAI(); virtual void yourTurn() OVERRIDE{}; virtual void heroKilled(const CGHeroInstance*){}; virtual void heroCreated(const CGHeroInstance*) OVERRIDE{}; - virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE{}; + virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance) OVERRIDE{}; virtual void battleStackAttacking(int ID, int dest) {}; virtual void battleStacksAttacked(const std::vector & bsa) OVERRIDE{}; virtual BattleAction activeStack(const CStack * stack) OVERRIDE; }; //class to be inherited by adventure-only AIs, it cedes battle actions to given battle-AI -class DLL_EXPORT CAdventureAI : public CGlobalAI +class DLL_LINKAGE CAdventureAI : public CGlobalAI { public: CAdventureAI() : battleAI(NULL), cbc(NULL) {}; @@ -130,12 +127,9 @@ public: virtual void battleStacksRemoved(const BattleStacksRemoved & bsr); virtual void battleObstaclesRemoved(const std::set & removedObstacles); virtual void battleNewStackAppeared(const CStack * stack); - virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance); + virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance); virtual void battleAttack(const BattleAttack *ba); virtual void battleSpellCast(const BattleSpellCast *sc); virtual void battleEnd(const BattleResult *br); virtual void battleStacksHealedRes(const std::vector > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom); }; - - -#endif // __CGAMEINTERFACE_H__ diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 1a2f50c9c..ce7729bb4 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -1,10 +1,8 @@ -#define VCMI_DLL -#include "CCampaignHandler.h" -#include -#include -#include +#include "StdInc.h" #include "CGameState.h" + #include +#include "CCampaignHandler.h" #include "CDefObjInfoHandler.h" #include "CArtHandler.h" #include "CBuildingHandler.h" @@ -14,23 +12,16 @@ #include "CHeroHandler.h" #include "CObjectHandler.h" #include "CCreatureHandler.h" -//#include "../lib/IGameCallback.h" #include "VCMI_Lib.h" #include "Connection.h" #include "map.h" -#include "../StartInfo.h" +#include "StartInfo.h" #include "NetPacks.h" -#include -#include -#include -#include -#include -#include "RegisterTypes.cpp" -#include -#include +#include "RegisterTypes.h" #include "CMapInfo.h" #include "BattleState.h" #include "../lib/JsonNode.h" +#include "GameConstants.h" boost::rand48 ran; class CGObjectInstance; @@ -288,7 +279,7 @@ void MetaString::getLocalString(const std::pair &txt, std::string &dst } } -DLL_EXPORT void MetaString::toString(std::string &dst) const +DLL_LINKAGE void MetaString::toString(std::string &dst) const { size_t exSt = 0, loSt = 0, nums = 0; dst.clear(); @@ -333,14 +324,14 @@ DLL_EXPORT void MetaString::toString(std::string &dst) const } } -DLL_EXPORT std::string MetaString::toString() const +DLL_LINKAGE std::string MetaString::toString() const { std::string ret; toString(ret); return ret; } -DLL_EXPORT std::string MetaString::buildList () const +DLL_LINKAGE std::string MetaString::buildList () const ///used to handle loot from creature bank { @@ -413,7 +404,7 @@ static CGObjectInstance * createObject(int id, int subid, int3 pos, int owner) CGObjectInstance * nobj; switch(id) { - case HEROI_TYPE: //hero + case GameConstants::HEROI_TYPE: //hero { CGHeroInstance * nobj = new CGHeroInstance(); nobj->pos = pos; @@ -422,7 +413,7 @@ static CGObjectInstance * createObject(int id, int subid, int3 pos, int owner) //nobj->initHero(ran); return nobj; } - case TOWNI_TYPE: //town + case GameConstants::TOWNI_TYPE: //town nobj = new CGTownInstance; break; default: //rest of objects @@ -441,7 +432,7 @@ static CGObjectInstance * createObject(int id, int subid, int3 pos, int owner) nobj->defInfo->subid = subid; //assigning defhandler - if(nobj->ID==HEROI_TYPE || nobj->ID==TOWNI_TYPE) + if(nobj->ID==GameConstants::HEROI_TYPE || nobj->ID==GameConstants::TOWNI_TYPE) return nobj; nobj->defInfo = VLC->dobjinfo->gobjs[id][subid]; return nobj; @@ -451,7 +442,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, int player, co { CGHeroInstance *ret = NULL; - if(player<0 || player>=PLAYER_LIMIT) + if(player<0 || player>=GameConstants::PLAYER_LIMIT) { tlog1 << "Cannot pick hero for " << town->Name() << ". Wrong owner!\n"; return NULL; @@ -499,7 +490,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, int player, co } r = rand()%sum; - for (unsigned int i=0; itype->heroClass->selectionProbability[town->typeID]; if(r < 0) @@ -536,12 +527,12 @@ int CGameState::pickHero(int owner) do //try to find free hero of our faction { i++; - h = ps.castle*HEROES_PER_TYPE*2+(ran()%(HEROES_PER_TYPE*2));//->scenarioOps->playerInfos[pru].hero = VLC-> + h = ps.castle*GameConstants::HEROES_PER_TYPE*2+(ran()%(GameConstants::HEROES_PER_TYPE*2));//->scenarioOps->playerInfos[pru].hero = VLC-> } while( map->getHero(h) && i<175); if(i>174) //probably no free heroes - there's no point in further search, we'll take first free { tlog3 << "Warning: cannot find free hero - trying to get first available..."<getHero(j)) h=j; } @@ -564,7 +555,7 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) case 69: //random relic artifact return std::pair(5, VLC->arth->getRandomArt (CArtifact::ART_RELIC)); case 70: //random hero - return std::pair(HEROI_TYPE,pickHero(obj->tempOwner)); + return std::pair(GameConstants::HEROI_TYPE,pickHero(obj->tempOwner)); case 71: //random monster return std::pair(54,VLC->creh->pickRandomMonster(boost::ref(ran))); case 72: //random monster lvl1 @@ -581,9 +572,9 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) { int align = (static_cast(obj))->alignment, f; - if(align>PLAYER_LIMIT-1)//same as owner / random + if(align>GameConstants::PLAYER_LIMIT-1)//same as owner / random { - if(obj->tempOwner > PLAYER_LIMIT-1) + if(obj->tempOwner > GameConstants::PLAYER_LIMIT-1) f = -1; //random else f = scenarioOps->getIthPlayersSettings(obj->tempOwner).castle; @@ -593,7 +584,7 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) f = scenarioOps->getIthPlayersSettings(align).castle; } if(f<0) f = ran()%VLC->townh->towns.size(); - return std::pair(TOWNI_TYPE,f); + return std::pair(GameConstants::TOWNI_TYPE,f); } case 162: //random monster lvl5 return std::pair(54, VLC->creh->pickRandomMonster(boost::ref(ran), 5)); @@ -603,12 +594,12 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) return std::pair(54, VLC->creh->pickRandomMonster(boost::ref(ran), 7)); case 216: //random dwelling { - int faction = ran()%F_NUMBER; + int faction = ran()%GameConstants::F_NUMBER; CGDwelling * dwl = static_cast(obj); CCreGen2ObjInfo* info = static_cast(dwl->info); if (info->asCastle) { - for(unsigned int i=0;iobjects.size();i++) + for(ui32 i=0;iobjects.size();i++) { if(map->objects[i]->ID==77 && dynamic_cast(map->objects[i].get())->identifier == info->identifier) { @@ -616,7 +607,7 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) faction = map->objects[i]->subID; break; } - else if(map->objects[i]->ID==TOWNI_TYPE && dynamic_cast(map->objects[i].get())->identifier == info->identifier) + else if(map->objects[i]->ID==GameConstants::TOWNI_TYPE && dynamic_cast(map->objects[i].get())->identifier == info->identifier) { faction = map->objects[i]->subID; break; @@ -629,12 +620,12 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) { if((faction>7) && (info->castles[1]&(1<<(faction-8)))) break; - faction = ran()%F_NUMBER; + faction = ran()%GameConstants::F_NUMBER; } } int level = ((info->maxLevel-info->minLevel) ? (ran()%(info->maxLevel-info->minLevel)+info->minLevel) : (info->minLevel)); int cid = VLC->townh->towns[faction].basicCreatures[level]; - for(unsigned int i=0;iobjh->cregens.size();i++) + for(ui32 i=0;iobjh->cregens.size();i++) if(VLC->objh->cregens[i]==cid) return std::pair(17,i); tlog3 << "Cannot find a dwelling for creature "<< cid << std::endl; @@ -644,12 +635,12 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) } case 217: { - int faction = ran()%F_NUMBER; + int faction = ran()%GameConstants::F_NUMBER; CGDwelling * dwl = static_cast(obj); CCreGenObjInfo* info = static_cast(dwl->info); if (info->asCastle) { - for(unsigned int i=0;iobjects.size();i++) + for(ui32 i=0;iobjects.size();i++) { if(map->objects[i]->ID==77 && dynamic_cast(map->objects[i].get())->identifier == info->identifier) { @@ -657,7 +648,7 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) faction = map->objects[i]->subID; break; } - else if(map->objects[i]->ID==TOWNI_TYPE && dynamic_cast(map->objects[i].get())->identifier == info->identifier) + else if(map->objects[i]->ID==GameConstants::TOWNI_TYPE && dynamic_cast(map->objects[i].get())->identifier == info->identifier) { faction = map->objects[i]->subID; break; @@ -670,11 +661,11 @@ std::pair CGameState::pickObject (CGObjectInstance *obj) { if((faction>7) && (info->castles[1]&(1<<(faction-8)))) break; - faction = ran()%F_NUMBER; + faction = ran()%GameConstants::F_NUMBER; } } int cid = VLC->townh->towns[faction].basicCreatures[obj->subID]; - for(unsigned int i=0;iobjh->cregens.size();i++) + for(ui32 i=0;iobjh->cregens.size();i++) if(VLC->objh->cregens[i]==cid) return std::pair(17,i); tlog3 << "Cannot find a dwelling for creature "< CGameState::pickObject (CGObjectInstance *obj) CCreGen3ObjInfo* info = static_cast(dwl->info); int level = ((info->maxLevel-info->minLevel) ? (ran()%(info->maxLevel-info->minLevel)+info->minLevel) : (info->minLevel)); int cid = VLC->townh->towns[obj->subID].basicCreatures[level]; - for(unsigned int i=0;iobjh->cregens.size();i++) + for(ui32 i=0;iobjh->cregens.size();i++) if(VLC->objh->cregens[i]==cid) return std::pair(17,i); tlog3 << "Cannot find a dwelling for creature "< ran = pickObject(cur); if(ran.first<0 || ran.second<0) //this is not a random object, or we couldn't find anything { - if(cur->ID==TOWNI_TYPE) //town - set def + if(cur->ID==GameConstants::TOWNI_TYPE) //town - set def { CGTownInstance *t = dynamic_cast(cur); t->town = &VLC->townh->towns[t->subID]; @@ -718,7 +709,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur) } return; } - else if(ran.first==HEROI_TYPE)//special code for hero + else if(ran.first==GameConstants::HEROI_TYPE)//special code for hero { CGHeroInstance *h = dynamic_cast(cur); if(!h) {tlog2<<"Wrong random hero at "<pos<heroes.push_back(h); return; //TODO: maybe we should do something with definfo? } - else if(ran.first==TOWNI_TYPE)//special code for town + else if(ran.first==GameConstants::TOWNI_TYPE)//special code for town { CGTownInstance *t = dynamic_cast(cur); if(!t) {tlog2<<"Wrong random town at "<pos<slotEmpty(i)) { @@ -864,7 +855,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) case 5: //prim skill { const ui8* ptr = reinterpret_cast(&curBonus.info2); - for (int g=0; gcamp->mapPieces[scenarioOps->whichMapInCampaign]; map = new Mapa(); - map->initFromBytes((const unsigned char*)mapContent.c_str(), mapContent.size()); + map->initFromBytes((const ui8*)mapContent.c_str(), mapContent.size()); } break; case StartInfo::DUEL: @@ -1037,7 +1028,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) } //remove tiles with holes - for(unsigned int no=0; noobjects.size(); ++no) + for(ui32 no=0; noobjects.size(); ++no) if(map->objects[no]->ID == 124) allowedPos -= map->objects[no]->pos; @@ -1056,7 +1047,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) int f; do { - f = ran()%F_NUMBER; + f = ran()%GameConstants::F_NUMBER; }while(!(map->players[it->first].allowedFactions & 1<second.castle = f; } @@ -1094,7 +1085,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) } /*********give starting hero****************************************/ - for(int i=0;iplayers[i]; bool generateHero = (p.generateHeroAtMainTown && p.hasMainTown); @@ -1107,7 +1098,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) if(scenarioOps->playerInfos[i].hero == -1) scenarioOps->playerInfos[i].hero = h; - CGHeroInstance * nnn = static_cast(createObject(HEROI_TYPE,h,hpos,i)); + CGHeroInstance * nnn = static_cast(createObject(GameConstants::HEROI_TYPE,h,hpos,i)); nnn->id = map->objects.size(); nnn->initHero(); map->heroes.push_back(nnn); @@ -1186,7 +1177,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) /******************RESOURCES****************************************************/ TResources startresAI, startresHuman; - const JsonNode config(DATA_DIR "/config/startres.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/startres.json"); const JsonVector &vector = config["difficulty"].Vector(); const JsonNode &level = vector[scenarioOps->difficulty]; const JsonNode &human = level["human"]; @@ -1259,11 +1250,11 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) /*************************HEROES************************************************/ std::set hids; //hero ids to create pool - for(unsigned int i=0; iallowedHeroes.size(); i++) //add to hids all allowed heroes + for(ui32 i=0; iallowedHeroes.size(); i++) //add to hids all allowed heroes if(map->allowedHeroes[i]) hids.insert(i); - for (unsigned int i=0; iheroes.size();i++) //heroes instances initialization + for (ui32 i=0; iheroes.size();i++) //heroes instances initialization { if (map->heroes[i]->getOwner()<0) { @@ -1276,13 +1267,13 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) hids.erase(vhi->subID); } - for (unsigned int i=0; iobjects.size();i++) //prisons + for (ui32 i=0; iobjects.size();i++) //prisons { if (map->objects[i]->ID == 62) hids.erase(map->objects[i]->subID); } - for(unsigned int i=0; ipredefinedHeroes.size(); i++) + for(ui32 i=0; ipredefinedHeroes.size(); i++) { if(!vstd::contains(hids,map->predefinedHeroes[i]->subID)) continue; @@ -1300,7 +1291,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) hpool.pavailable[hid] = 0xff; } - for(unsigned int i=0; idisposedHeroes.size(); i++) + for(ui32 i=0; idisposedHeroes.size(); i++) { hpool.pavailable[map->disposedHeroes[i].ID] = map->disposedHeroes[i].players; } @@ -1425,7 +1416,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) for ( int i=0; i<4; i++) CGTownInstance::universitySkills.push_back(14+i);//skills for university - for (unsigned int i=0;itowns.size();i++) + for (ui32 i=0;itowns.size();i++) { CGTownInstance * vti =(map->towns[i]); if(!vti->town) @@ -1448,7 +1439,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) vti->builtBuildings.erase(6);//if we have harbor without water - erase it (this is H3 behaviour) //init hordes - for (int i = 0; ibuiltBuildings,(-31-i))) //if we have horde for this level { vti->builtBuildings.erase(-31-i);//remove old ID @@ -1469,7 +1460,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) //town events BOOST_FOREACH(CCastleEvent *ev, vti->events) { - for (int i = 0; ibuildings,(-31-i))) //if we have horde for this level { ev->buildings.erase(-31-i); @@ -1480,9 +1471,9 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) } } //init spells - vti->spells.resize(SPELL_LEVELS); + vti->spells.resize(GameConstants::SPELL_LEVELS); CSpell *s; - for(unsigned int z=0; zobligatorySpells.size();z++) + for(ui32 z=0; zobligatorySpells.size();z++) { s = VLC->spellh->spells[vti->obligatorySpells[z]]; vti->spells[s->level-1].push_back(s->id); @@ -1493,10 +1484,10 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) ui32 total=0; int sel = -1; - for(unsigned int ps=0;pspossibleSpells.size();ps++) + for(ui32 ps=0;pspossibleSpells.size();ps++) total += VLC->spellh->spells[vti->possibleSpells[ps]]->probabilities[vti->subID]; int r = (total)? ran()%total : -1; - for(unsigned int ps=0; pspossibleSpells.size();ps++) + for(ui32 ps=0; pspossibleSpells.size();ps++) { r -= VLC->spellh->spells[vti->possibleSpells[ps]]->probabilities[vti->subID]; if(r<0) @@ -1657,7 +1648,7 @@ int CGameState::battleGetBattlefieldType(int3 tile) std::set > costDiff(const std::vector &a, const std::vector &b, const int modifier = 100) //modifer % { std::set > ret; - for(int j=0;j= b[j]); if(int dif = modifier * (a[j] - b[j]) / 100) @@ -1671,10 +1662,10 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack) UpgradeInfo ret; const CCreature *base = stack.type; - const CGHeroInstance *h = stack.armyObj->ID == HEROI_TYPE ? static_cast(stack.armyObj) : NULL; + const CGHeroInstance *h = stack.armyObj->ID == GameConstants::HEROI_TYPE ? static_cast(stack.armyObj) : NULL; const CGTownInstance *t = NULL; - if(stack.armyObj->ID == TOWNI_TYPE) + if(stack.armyObj->ID == GameConstants::TOWNI_TYPE) t = static_cast(stack.armyObj); else if(h) { //hero speciality @@ -1738,9 +1729,9 @@ int CGameState::getPlayerRelations( ui8 color1, ui8 color2 ) void CGameState::loadTownDInfos() { int i; - const JsonNode config(DATA_DIR "/config/towns_defs.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/towns_defs.json"); - assert(config["town_defnames"].Vector().size() == F_NUMBER); + assert(config["town_defnames"].Vector().size() == GameConstants::F_NUMBER); i = 0; BOOST_FOREACH(const JsonNode &t, config["town_defnames"].Vector()) @@ -1815,15 +1806,15 @@ int CGameState::getMovementCost(const CGHeroInstance *h, const int3 &src, const if(!freeFlying) { - ret *= 1.4f; //40% penalty for movement over blocked tile + ret *= 1.4; //40% penalty for movement over blocked tile } } else if (d.tertype == TerrainTile::water) { if(h->boat && s.hasFavourableWinds() && d.hasFavourableWinds()) //Favourable Winds - ret *= 0.666f; + ret *= 0.666; else if (!h->boat && h->getBonusesCount(Selector::typeSubtype(Bonus::WATER_WALKING, 1)) > 0) - ret *= 1.4f; //40% penalty for water walking + ret *= 1.4; //40% penalty for water walking } if(src.x != dest.x && src.y != dest.y) //it's diagonal move @@ -1970,7 +1961,7 @@ bool CGameState::checkForVisitableDir(const int3 & src, const int3 & dst) const bool CGameState::checkForVisitableDir( const int3 & src, const TerrainTile *pom, const int3 & dst ) const { - for(unsigned int b=0; bvisitableObjects.size(); ++b) //checking destination tile + for(ui32 b=0; bvisitableObjects.size(); ++b) //checking destination tile { if(!vstd::contains(pom->blockingObjects, pom->visitableObjects[b])) //this visitable object is not blocking, ignore continue; @@ -2016,7 +2007,7 @@ bool CGameState::checkForVisitableDir( const int3 & src, const TerrainTile *pom, int CGameState::victoryCheck( ui8 player ) const { const PlayerState *p = CGameInfoCallback::getPlayer(player); - if(map->victoryCondition.condition == winStandard || map->victoryCondition.allowNormalVictory) + if(map->victoryCondition.condition == EVictoryConditionType::WINSTANDARD || map->victoryCondition.allowNormalVictory) if(player == checkForStandardWin()) return -1; @@ -2029,7 +2020,7 @@ int CGameState::victoryCheck( ui8 player ) const { switch(map->victoryCondition.condition) { - case artifact: + case EVictoryConditionType::ARTIFACT: //check if any hero has winning artifact for(size_t i = 0; i < p->heroes.size(); i++) if(p->heroes[i]->hasArt(map->victoryCondition.ID)) @@ -2037,7 +2028,7 @@ int CGameState::victoryCheck( ui8 player ) const break; - case gatherTroop: + case EVictoryConditionType::GATHERTROOP: { //check if in players armies there is enough creatures int total = 0; //creature counter @@ -2059,13 +2050,13 @@ int CGameState::victoryCheck( ui8 player ) const } break; - case gatherResource: + case EVictoryConditionType::GATHERRESOURCE: if(p->resources[map->victoryCondition.ID] >= map->victoryCondition.count) return 1; break; - case buildCity: + case EVictoryConditionType::BUILDCITY: { const CGTownInstance *t = static_cast(map->victoryCondition.obj); if(t->tempOwner == player && t->fortLevel()-1 >= map->victoryCondition.ID && t->hallLevel()-1 >= map->victoryCondition.count) @@ -2073,7 +2064,7 @@ int CGameState::victoryCheck( ui8 player ) const } break; - case buildGrail: + case EVictoryConditionType::BUILDGRAIL: BOOST_FOREACH(const CGTownInstance *t, map->towns) if((t == map->victoryCondition.obj || !map->victoryCondition.obj) && t->tempOwner == player @@ -2081,21 +2072,21 @@ int CGameState::victoryCheck( ui8 player ) const return 1; break; - case beatHero: - if(map->victoryCondition.obj->tempOwner >= PLAYER_LIMIT) //target hero not present on map + case EVictoryConditionType::BEATHERO: + if(map->victoryCondition.obj->tempOwner >= GameConstants::PLAYER_LIMIT) //target hero not present on map return 1; break; - case captureCity: + case EVictoryConditionType::CAPTURECITY: { if(map->victoryCondition.obj->tempOwner == player) return 1; } break; - case beatMonster: + case EVictoryConditionType::BEATMONSTER: if(!map->objects[map->victoryCondition.obj->id]) //target monster not present on map return 1; break; - case takeDwellings: + case EVictoryConditionType::TAKEDWELLINGS: for(size_t i = 0; i < map->objects.size(); i++) { if(map->objects[i] && map->objects[i]->tempOwner != player) //check not flagged objs @@ -2110,7 +2101,7 @@ int CGameState::victoryCheck( ui8 player ) const } return 1; break; - case takeMines: + case EVictoryConditionType::TAKEMINES: for(size_t i = 0; i < map->objects.size(); i++) { if(map->objects[i] && map->objects[i]->tempOwner != player) //check not flagged objs @@ -2124,7 +2115,7 @@ int CGameState::victoryCheck( ui8 player ) const } return 1; break; - case transportItem: + case EVictoryConditionType::TRANSPORTITEM: { const CGTownInstance *t = static_cast(map->victoryCondition.obj); if((t->visitingHero && t->visitingHero->hasArt(map->victoryCondition.ID)) @@ -2147,7 +2138,7 @@ ui8 CGameState::checkForStandardWin() const ui8 supposedWinner = 255, winnerTeam = 255; for(std::map::const_iterator i = players.begin(); i != players.end(); i++) { - if(i->second.status == PlayerState::INGAME && i->first < PLAYER_LIMIT) + if(i->second.status == PlayerState::INGAME && i->first < GameConstants::PLAYER_LIMIT) { if(supposedWinner == 255) { @@ -2372,7 +2363,7 @@ int CGameState::lossCheck( ui8 player ) const { switch(map->lossCondition.typeOfLossCon) { - case lossCastle: + case ELossConditionType::LOSSCASTLE: { const CGTownInstance *t = dynamic_cast(map->lossCondition.obj); assert(t); @@ -2380,7 +2371,7 @@ int CGameState::lossCheck( ui8 player ) const return 1; } break; - case lossHero: + case ELossConditionType::LOSSHERO: { const CGHeroInstance *h = dynamic_cast(map->lossCondition.obj); assert(h); @@ -2388,7 +2379,7 @@ int CGameState::lossCheck( ui8 player ) const return 1; } break; - case timeExpires: + case ELossConditionType::TIMEEXPIRES: if(map->lossCondition.timeLimit < day) return 1; break; @@ -2464,7 +2455,7 @@ void CPath::convert(ui8 mode) //mode=0 -> from 'manifest' to 'object' { if (mode==0) { - for (unsigned int i=0;iluck = h->LuckVal(); details->morale = h->MoraleVal(); details->mana = h->mana; - details->primskills.resize(PRIMARY_SKILLS); + details->primskills.resize(GameConstants::PRIMARY_SKILLS); - for (int i = 0; i < PRIMARY_SKILLS ; i++) + for (int i = 0; i < GameConstants::PRIMARY_SKILLS ; i++) { details->primskills[i] = h->getPrimSkillLevel(i); } @@ -2774,7 +2765,7 @@ void CPathfinder::calculatePaths(int3 src /*= int3(-1,-1,-1)*/, int movement /*= neighbours.clear(); //handling subterranean gate => it's exit is the only neighbour - bool subterraneanEntry = (ct->topVisitableID() == SUBTERRANEAN_GATE_TYPE && useSubterraneanGates); + bool subterraneanEntry = (ct->topVisitableID() == GameConstants::SUBTERRANEAN_GATE_TYPE && useSubterraneanGates); if(subterraneanEntry) { //try finding the exit gate @@ -2793,7 +2784,7 @@ void CPathfinder::calculatePaths(int3 src /*= int3(-1,-1,-1)*/, int movement /*= gs->getNeighbours(*ct, cp->coord, neighbours, boost::logic::indeterminate, !cp->land); - for(unsigned int i=0; i < neighbours.size(); i++) + for(ui32 i=0; i < neighbours.size(); i++) { const int3 &n = neighbours[i]; //current neighbor dp = getNode(n); @@ -2815,13 +2806,13 @@ void CPathfinder::calculatePaths(int3 src /*= int3(-1,-1,-1)*/, int movement /*= continue; //special case -> hero embarked a boat standing on a guarded tile -> we must allow to move away from that tile - if(cp->accessible == CGPathNode::VISITABLE && guardedSource && cp->theNodeBefore->land && ct->topVisitableID() == BOATI_TYPE) + if(cp->accessible == CGPathNode::VISITABLE && guardedSource && cp->theNodeBefore->land && ct->topVisitableID() == GameConstants::BOATI_TYPE) guardedSource = false; int cost = gs->getMovementCost(hero, cp->coord, dp->coord, movement); //special case -> moving from src Subterranean gate to dest gate -> it's free - if(subterraneanEntry && destTopVisObjID == SUBTERRANEAN_GATE_TYPE && cp->coord.z != dp->coord.z) + if(subterraneanEntry && destTopVisObjID == GameConstants::SUBTERRANEAN_GATE_TYPE && cp->coord.z != dp->coord.z) cost = 0; int remains = movement - cost; @@ -2857,7 +2848,7 @@ void CPathfinder::calculatePaths(int3 src /*= int3(-1,-1,-1)*/, int movement /*= if (dp->accessible == CGPathNode::ACCESSIBLE || (useEmbarkCost && allowEmbarkAndDisembark) - || destTopVisObjID == SUBTERRANEAN_GATE_TYPE + || destTopVisObjID == GameConstants::SUBTERRANEAN_GATE_TYPE || (guardedDst && !guardedSource)) // Can step into a hostile tile once. { mq.push_back(dp); @@ -2896,7 +2887,7 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile if(tinfo->visitable) { - if(tinfo->visitableObjects.front()->ID == 80 && tinfo->visitableObjects.back()->ID == HEROI_TYPE && tinfo->visitableObjects.back()->tempOwner != hero->tempOwner) //non-owned hero stands on Sanctuary + 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 { return CGPathNode::BLOCKED; } @@ -2912,7 +2903,7 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile { return CGPathNode::BLOCKVIS; } - else if(obj->ID != EVENTI_TYPE) //pathfinder should ignore placed events + else if(obj->ID != GameConstants::EVENTI_TYPE) //pathfinder should ignore placed events { ret = CGPathNode::VISITABLE; } @@ -2937,9 +2928,9 @@ bool CPathfinder::goodForLandSeaTransition() { if(dp->accessible == CGPathNode::ACCESSIBLE || destTopVisObjID < 0) //cannot enter empty water tile from land -> it has to be visitable return false; - if(destTopVisObjID != HEROI_TYPE && destTopVisObjID != BOATI_TYPE) //only boat or hero can be accessed from land + if(destTopVisObjID != GameConstants::HEROI_TYPE && destTopVisObjID != GameConstants::BOATI_TYPE) //only boat or hero can be accessed from land return false; - if(destTopVisObjID == BOATI_TYPE) + if(destTopVisObjID == GameConstants::BOATI_TYPE) useEmbarkCost = 1; } else //disembark diff --git a/lib/CGameState.h b/lib/CGameState.h index 457e8b895..1b0d4d3da 100644 --- a/lib/CGameState.h +++ b/lib/CGameState.h @@ -1,7 +1,6 @@ -#ifndef __CGAMESTATE_H__ -#define __CGAMESTATE_H__ -#include "../global.h" -#include +#pragma once + + #ifndef _MSC_VER #include "CCreatureHandler.h" @@ -9,21 +8,12 @@ #include "map.h" #endif -#include -#include -#include #include "HeroBonus.h" #include "CCreatureSet.h" - -#ifdef _WIN32 -#include -#else -#include "../tchar_amigaos4.h" -#endif - #include "ConstTransitivePtr.h" #include "IGameCallback.h" #include "ResourceSet.h" +#include "int3.h" /* @@ -67,6 +57,7 @@ class CCampaign; class CCampaignState; class IModableArt; class CGGarrison; +class CGameInfo; namespace boost { @@ -77,18 +68,18 @@ namespace boost struct ArmyDescriptor : public std::map { bool isDetailed; - DLL_EXPORT ArmyDescriptor(const CArmedInstance *army, bool detailed); //not detailed -> quantity ids as count - DLL_EXPORT ArmyDescriptor(); + DLL_LINKAGE ArmyDescriptor(const CArmedInstance *army, bool detailed); //not detailed -> quantity ids as count + DLL_LINKAGE ArmyDescriptor(); - DLL_EXPORT int getStrength() const; + DLL_LINKAGE int getStrength() const; }; -struct DLL_EXPORT InfoAboutHero +struct DLL_LINKAGE InfoAboutHero { private: void assign(const InfoAboutHero & iah); public: - struct DLL_EXPORT Details + struct DLL_LINKAGE Details { std::vector primskills; int mana, luck, morale; @@ -108,8 +99,8 @@ public: void initFromHero(const CGHeroInstance *h, bool detailed); }; -/// Struct which holds a short information about a town -struct DLL_EXPORT InfoAboutTown +/// Struct which holds a int information about a town +struct DLL_LINKAGE InfoAboutTown { struct Details { @@ -138,7 +129,7 @@ struct DLL_EXPORT InfoAboutTown // typedef std::vector TResourceVector; // typedef std::set TResourceSet; -struct DLL_EXPORT SThievesGuildInfo +struct DLL_LINKAGE SThievesGuildInfo { std::vector playerColors; //colors of players that are in-game @@ -157,7 +148,7 @@ struct DLL_EXPORT SThievesGuildInfo }; -struct DLL_EXPORT PlayerState : public CBonusSystemNode +struct DLL_LINKAGE PlayerState : public CBonusSystemNode { public: enum EStatus {INGAME, LOSER, WINNER}; @@ -192,7 +183,7 @@ public: } }; -struct DLL_EXPORT TeamState : public CBonusSystemNode +struct DLL_LINKAGE TeamState : public CBonusSystemNode { public: ui8 id; //position in gameState::teams @@ -246,7 +237,7 @@ struct CGPathNode }; -struct DLL_EXPORT CPath +struct DLL_LINKAGE CPath { std::vector nodes; //just get node by node @@ -255,7 +246,7 @@ struct DLL_EXPORT CPath void convert(ui8 mode); //mode=0 -> from 'manifest' to 'object' }; -struct DLL_EXPORT CGPath +struct DLL_LINKAGE CGPath { std::vector nodes; //just get node by node @@ -264,7 +255,7 @@ struct DLL_EXPORT CGPath void convert(ui8 mode); //mode=0 -> from 'manifest' to 'object' }; -struct DLL_EXPORT CPathsInfo +struct DLL_LINKAGE CPathsInfo { bool isValid; const CGHeroInstance *hero; @@ -277,7 +268,7 @@ struct DLL_EXPORT CPathsInfo ~CPathsInfo(); }; -struct DLL_EXPORT DuelParameters +struct DLL_LINKAGE DuelParameters { si32 terType, bfieldType; struct SideSettings @@ -293,7 +284,8 @@ struct DLL_EXPORT DuelParameters StackSettings(); StackSettings(si32 Type, si32 Count); - } stacks[ARMY_SIZE]; + }; + StackSettings stacks[GameConstants::ARMY_SIZE]; si32 heroId; //-1 if none std::set spells; @@ -349,7 +341,7 @@ public: struct BattleInfo; -class DLL_EXPORT CGameState : public CNonConstInfoCallback +class DLL_LINKAGE CGameState : public CNonConstInfoCallback { public: ConstTransitivePtr scenarioOps, initialOpts; //second one is a copy of settings received from pregame (not randomized) @@ -365,7 +357,7 @@ public: CBonusSystemNode globalEffects; bmap ongoingVisits; - struct DLL_EXPORT HeroesPool + struct DLL_LINKAGE HeroesPool { bmap > heroesPool; //[subID] - heroes available to buy; NULL if not available bmap pavailable; // [subid] -> which players can recruit hero (binary flags) @@ -389,7 +381,6 @@ public: int battleGetBattlefieldType(int3 tile = int3());// 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship UpgradeInfo getUpgradeInfo(const CStackInstance &stack); int getPlayerRelations(ui8 color1, ui8 color2);// 0 = enemy, 1 = ally, 2 = same player - //float getMarketEfficiency(int player, int mode=0); bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile bool checkForVisitableDir(const int3 & src, const TerrainTile *pom, const int3 & dst) const; //check if src tile is visitable from dst tile bool getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret); //calculates path between src and dest; returns pointer to newly allocated CPath or NULL if path does not exists @@ -435,7 +426,4 @@ public: friend class CMapHandler; friend class CGameHandler; }; - - -#endif // __CGAMESTATE_H__ diff --git a/lib/CGeneralTextHandler.cpp b/lib/CGeneralTextHandler.cpp index b1c1e8c2d..343b36f86 100644 --- a/lib/CGeneralTextHandler.cpp +++ b/lib/CGeneralTextHandler.cpp @@ -1,12 +1,9 @@ -#define VCMI_DLL -#include "../stdafx.h" -#include "../lib/VCMI_Lib.h" +#include "StdInc.h" #include "CGeneralTextHandler.h" + +#include "../lib/VCMI_Lib.h" #include "CLodHandler.h" -#include -#include -#include -#include +#include "GameConstants.h" /* * CGeneralTextHandler.cpp, part of VCMI engine @@ -87,7 +84,7 @@ void CGeneralTextHandler::load() i+=2; } - hTxts.resize(HEROES_QUANTITY); + hTxts.resize(GameConstants::HEROES_QUANTITY); buf = bitmaph->getTextFile("HEROSPEC.TXT"); i=0; @@ -120,7 +117,7 @@ void CGeneralTextHandler::load() { std::string name = readTo(buf,it,'\t'), description = readTo(buf,it,'\n'); - for(int fi=0;figetTextFile("BLDGSPEC.TXT"); andame = buf.size(), it=0; - for(int f=0;fgetTextFile("DWELLING.TXT"); andame = buf.size(), it=0; - for(int f=0;f -#include +#pragma once + + /* * CGeneralTextHandler.h, part of VCMI engine @@ -14,9 +12,9 @@ * */ -DLL_EXPORT void loadToIt(std::string &dest, const std::string &src, int &iter, int mode); +DLL_LINKAGE void loadToIt(std::string &dest, const std::string &src, int &iter, int mode); std::string readTo(const std::string &in, int &it, char end); -class DLL_EXPORT CGeneralTextHandler //Handles general texts +class DLL_LINKAGE CGeneralTextHandler //Handles general texts { public: class HeroTexts @@ -86,7 +84,3 @@ public: void load(); CGeneralTextHandler(); }; - - - -#endif // __CGENERALTEXTHANDLER_H__ diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 95a05681e..6203eb019 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -1,19 +1,16 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "CHeroHandler.h" + #include "CLodHandler.h" #include "../lib/VCMI_Lib.h" #include "../lib/JsonNode.h" -#include -#include -#include +#include "GameConstants.h" #include #if BOOST_VERSION >= 103800 #include #else #include #endif -#include using namespace boost::spirit; @@ -55,9 +52,9 @@ int CHeroClass::chooseSecSkill(const std::set & possibles) const //picks se throw std::string("Cannot pick secondary skill!"); } -EAlignment CHeroClass::getAlignment() +EAlignment::EAlignment CHeroClass::getAlignment() { - return (EAlignment)alignment; + return (EAlignment::EAlignment)alignment; } int CObstacleInfo::getWidth() const @@ -95,9 +92,9 @@ int CObstacleInfo::getHeight() const return ret; } -std::vector CObstacleInfo::getBlocked(THex hex) const +std::vector CObstacleInfo::getBlocked(SHexField hex) const { - std::vector ret; + std::vector ret; int cur = hex; //currently browsed hex int curBeg = hex; //beginning of current line for(int h=0; h CObstacleInfo::getBlocked(THex hex) const ++cur; break; case 'L': - cur = curBeg + BFIELD_WIDTH; - if((cur/BFIELD_WIDTH)%2 == 1) + cur = curBeg + GameConstants::BFIELD_WIDTH; + if((cur/GameConstants::BFIELD_WIDTH)%2 == 1) { cur--; } @@ -124,9 +121,9 @@ std::vector CObstacleInfo::getBlocked(THex hex) const return ret; } -THex CObstacleInfo::getMaxBlocked(THex hex) const +SHexField CObstacleInfo::getMaxBlocked(SHexField hex) const { - std::vector blocked = getBlocked(hex); + std::vector blocked = getBlocked(hex); return *std::max_element(blocked.begin(), blocked.end()); } @@ -144,7 +141,7 @@ CHeroHandler::CHeroHandler() void CHeroHandler::loadObstacles() { - const JsonNode config(DATA_DIR "/config/obstacles.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/obstacles.json"); BOOST_FOREACH(const JsonNode &obs, config["obstacles"].Vector()) { CObstacleInfo obi; @@ -163,7 +160,7 @@ void CHeroHandler::loadObstacles() void CHeroHandler::loadPuzzleInfo() { - const JsonNode config(DATA_DIR "/config/puzzle_map.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/puzzle_map.json"); int faction = 0; @@ -185,7 +182,7 @@ void CHeroHandler::loadPuzzleInfo() suffix << std::setfill('0') << std::setw(2); suffix << idx << ".BMP"; - static const std::string factionToInfix[F_NUMBER] = {"CAS", "RAM", "TOW", "INF", "NEC", "DUN", "STR", "FOR", "ELE"}; + static const std::string factionToInfix[GameConstants::F_NUMBER] = {"CAS", "RAM", "TOW", "INF", "NEC", "DUN", "STR", "FOR", "ELE"}; spi.filename = "PUZ" + factionToInfix[faction] + suffix.str(); puzzleInfo[faction].push_back(spi); @@ -198,7 +195,7 @@ void CHeroHandler::loadPuzzleInfo() faction ++; } - assert(faction == F_NUMBER); + assert(faction == GameConstants::F_NUMBER); } void CHeroHandler::loadHeroes() @@ -230,7 +227,7 @@ void CHeroHandler::loadHeroes() addTab[11] = CHero::DEMONIAC; - for (int i=0; i> intPart; str.ignore();//ignore decimal separator str >> fracPart; - hc->aggression = intPart + fracPart/100.0f; + hc->aggression = intPart + fracPart/100.0; str >> hc->initialAttack; str >> hc->initialDefence; str >> hc->initialPower; str >> hc->initialKnowledge; - hc->primChance.resize(PRIMARY_SKILLS); - for(int x=0; xprimChance.resize(GameConstants::PRIMARY_SKILLS); + for(int x=0; x> hc->primChance[x].first; } - for(int x=0; x> hc->primChance[x].second; } - hc->proSec.resize(SKILL_QUANTITY); - for(int dd=0; ddproSec.resize(GameConstants::SKILL_QUANTITY); + for(int dd=0; dd> hc->proSec[dd]; } @@ -426,7 +423,7 @@ void CHeroHandler::initHeroClasses() loadTerrains(); } -unsigned int CHeroHandler::level (ui64 experience) const +ui32 CHeroHandler::level (ui64 experience) const { int i; if (experience <= expPerLevel.back()) @@ -443,7 +440,7 @@ unsigned int CHeroHandler::level (ui64 experience) const } } -ui64 CHeroHandler::reqExp (unsigned int level) const +ui64 CHeroHandler::reqExp (ui32 level) const { if(!level) return 0; @@ -462,9 +459,9 @@ ui64 CHeroHandler::reqExp (unsigned int level) const void CHeroHandler::loadTerrains() { int faction = 0; - const JsonNode config(DATA_DIR "/config/terrains.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/terrains.json"); - nativeTerrains.resize(F_NUMBER); + nativeTerrains.resize(GameConstants::F_NUMBER); BOOST_FOREACH(const JsonNode &terrain, config["terrains"].Vector()) { @@ -480,7 +477,7 @@ void CHeroHandler::loadTerrains() faction ++; } - assert(faction == F_NUMBER); + assert(faction == GameConstants::F_NUMBER); } CHero::CHero() diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index a9acfac59..5cd4a069b 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -1,11 +1,9 @@ -#ifndef __CHEROHANDLER_H__ -#define __CHEROHANDLER_H__ -#include "../global.h" -#include -#include -#include +#pragma once + +#include "SHexField.h" #include "../lib/ConstTransitivePtr.h" +#include "GameConstants.h" /* * CHeroHandler.h, part of VCMI engine @@ -32,7 +30,7 @@ struct SSpecialtyInfo } }; -class DLL_EXPORT CHero +class DLL_LINKAGE CHero { public: enum EHeroClasses {KNIGHT, CLERIC, RANGER, DRUID, ALCHEMIST, WIZARD, @@ -60,13 +58,13 @@ public: } }; -class DLL_EXPORT CHeroClass +class DLL_LINKAGE CHeroClass { public: ui8 alignment; ui32 skillLimit; //how many secondary skills can hero learn std::string name; - float aggression; + double aggression; int initialAttack, initialDefence, initialPower, initialKnowledge; //initial values of primary skills std::vector > primChance;//primChance[PRIMARY_SKILL_ID] - first is for levels 2 - 9, second for 10+;;; probability (%) of getting point of primary skill when getting new level std::vector proSec; //probabilities of gaining secondary skills (out of 112), in id order @@ -82,10 +80,10 @@ public: h & skillLimit & name & aggression & initialAttack & initialDefence & initialPower & initialKnowledge & primChance & proSec & selectionProbability & terrCosts & alignment; } -EAlignment getAlignment(); + EAlignment::EAlignment getAlignment(); }; -struct DLL_EXPORT CObstacleInfo +struct DLL_LINKAGE CObstacleInfo { int ID; std::string defName, @@ -98,15 +96,15 @@ struct DLL_EXPORT CObstacleInfo std::pair posShift; //shift of obstacle's position in the battlefield , eg. if it's <-1, 2> obstacle will be printed one pixel to the left and two to the bottom int getWidth() const; //returns width of obstacle in hexes int getHeight() const; //returns height of obstacle in hexes - std::vector getBlocked(THex hex) const; //returns vector of hexes blocked by obstacle when it's placed on hex 'hex' - THex getMaxBlocked(THex hex) const; //returns maximal hex (max number) covered by this obstacle + std::vector getBlocked(SHexField hex) const; //returns vector of hexes blocked by obstacle when it's placed on hex 'hex' + SHexField getMaxBlocked(SHexField hex) const; //returns maximal hex (max number) covered by this obstacle template void serialize(Handler &h, const int version) { h & ID & defName & blockmap & allowedTerrains & posShift; } }; -struct DLL_EXPORT SPuzzleInfo +struct DLL_LINKAGE SPuzzleInfo { ui16 number; //type of puzzle si16 x, y; //position @@ -121,7 +119,7 @@ struct DLL_EXPORT SPuzzleInfo const int PUZZLES_PER_FACTION = 48; -class DLL_EXPORT CHeroHandler +class DLL_LINKAGE CHeroHandler { public: std::vector< ConstTransitivePtr > heroes; //changed from nodrze @@ -146,11 +144,11 @@ public: void loadObstacles(); //loads info about obstacles - std::vector puzzleInfo[F_NUMBER]; //descriptions of puzzles + std::vector puzzleInfo[GameConstants::F_NUMBER]; //descriptions of puzzles void loadPuzzleInfo(); - unsigned int level(ui64 experience) const; //calculates level corresponding to given experience amount - ui64 reqExp(unsigned int level) const; //calculates experience required for given level + ui32 level(ui64 experience) const; //calculates level corresponding to given experience amount + ui64 reqExp(ui32 level) const; //calculates experience required for given level void loadHeroes(); void loadHeroClasses(); @@ -172,5 +170,3 @@ public: } } }; - -#endif // __CHEROHANDLER_H__ diff --git a/lib/CLodHandler.cpp b/lib/CLodHandler.cpp index 02e943f19..d557b8e45 100644 --- a/lib/CLodHandler.cpp +++ b/lib/CLodHandler.cpp @@ -1,17 +1,7 @@ -#define VCMI_DLL -#include "../stdafx.h" -#include "zlib.h" +#include "StdInc.h" #include "CLodHandler.h" -#include -#include -#include -#include -#include -#include "boost/filesystem.hpp" -#include -#include -#include -#include + +#include "zlib.h" #include "vcmi_endian.h" #include "VCMIDirs.h" #ifdef max @@ -30,7 +20,7 @@ VCMIDirs GVCMIDirs; * */ -std::string readString(const unsigned char * bufor, int &i) +std::string readString(const ui8 * bufor, int &i) { int len = read_le_u32(bufor + i); i+=4; assert(len >= 0 && len <= 500000); //not too long @@ -56,7 +46,7 @@ void CLodHandler::convertName(std::string &filename, std::string *extension) } } -unsigned char * CLodHandler::giveFile(std::string fname, LodFileType type, int * length) +ui8 * CLodHandler::giveFile(std::string fname, LodFileType type, int * length) { convertName(fname); boost::unordered_set::const_iterator en_it = entries.find(Entry(fname, type)); @@ -71,11 +61,11 @@ unsigned char * CLodHandler::giveFile(std::string fname, LodFileType type, int * if(length) *length = ourEntry.realSize; mutex->lock(); - unsigned char * outp; + ui8 * outp; if (ourEntry.offset<0) //file is in the sprites/ folder; no compression { int result; - outp = new unsigned char[ourEntry.realSize]; + outp = new ui8[ourEntry.realSize]; FILE * f = fopen((myDir + "/" + ourEntry.realName).c_str(), "rb"); if (f) { @@ -96,7 +86,7 @@ unsigned char * CLodHandler::giveFile(std::string fname, LodFileType type, int * } else if (ourEntry.size==0) //file is not compressed { - outp = new unsigned char[ourEntry.realSize]; + outp = new ui8[ourEntry.realSize]; LOD.seekg(ourEntry.offset, std::ios::beg); LOD.read((char*)outp, ourEntry.realSize); @@ -105,11 +95,11 @@ unsigned char * CLodHandler::giveFile(std::string fname, LodFileType type, int * } else //we will decompress file { - outp = new unsigned char[ourEntry.size]; + outp = new ui8[ourEntry.size]; LOD.seekg(ourEntry.offset, std::ios::beg); LOD.read((char*)outp, ourEntry.size); - unsigned char * decomp = NULL; + ui8 * decomp = NULL; infs2(outp, ourEntry.size, ourEntry.realSize, decomp); mutex->unlock(); delete[] outp; @@ -134,12 +124,12 @@ bool CLodHandler::haveFile(std::string name, LodFileType type) return vstd::contains(entries, Entry(name, type)); } -DLL_EXPORT int CLodHandler::infs2(unsigned char * in, int size, int realSize, unsigned char *& out, int wBits) +DLL_LINKAGE int CLodHandler::infs2(ui8 * in, int size, int realSize, ui8 *& out, int wBits) { int ret; unsigned have; z_stream strm; - out = new unsigned char [realSize]; + out = new ui8 [realSize]; int latPosOut = 0; /* allocate inflate state */ @@ -201,7 +191,7 @@ DLL_EXPORT int CLodHandler::infs2(unsigned char * in, int size, int realSize, un void CLodHandler::extractFile(const std::string FName, const std::string name, LodFileType type) { int len; //length of file to write - unsigned char * outp = giveFile(name, type, &len); + ui8 * outp = giveFile(name, type, &len); std::ofstream out; out.open(FName.c_str(), std::ios::binary); if(!out.is_open()) @@ -271,7 +261,7 @@ void CLodHandler::init(const std::string lodFile, const std::string dirName) struct LodEntry *lodEntries = new struct LodEntry[totalFiles]; LOD.read((char *)lodEntries, sizeof(struct LodEntry) * totalFiles); - for (unsigned int i=0; i mapstr; + std::vector mapstr; // Read a map by chunks // We could try to read the map size directly (cf RFC 1952) and then read // directly the whole map, but that would create more problems. do { - unsigned char *buf = new unsigned char[bufsize]; + ui8 *buf = new ui8[bufsize]; int ret = gzread(map, buf, bufsize); if (ret == 0 || ret == -1) { @@ -393,9 +383,9 @@ unsigned char * CLodHandler::getUnpackedFile( const std::string & path, int * si gzclose(map); // Now that we know the uncompressed size, reassemble the chunks - unsigned char *initTable = new unsigned char[mapsize]; + ui8 *initTable = new ui8[mapsize]; - std::vector::iterator it; + std::vector::iterator it; int offset; int tocopy = mapsize; for (it = mapstr.begin(), offset = 0; diff --git a/lib/CLodHandler.h b/lib/CLodHandler.h index e89a4b900..337436356 100644 --- a/lib/CLodHandler.h +++ b/lib/CLodHandler.h @@ -1,12 +1,6 @@ -#ifndef __CLODHANDLER_H__ -#define __CLODHANDLER_H__ -#include "../global.h" -#include -#include -#include -#include -#include -#include +#pragma once + + /* * CLodhandler.h, part of VCMI engine @@ -35,12 +29,12 @@ struct LodEntry { ui32 size; /* little endian */ }; -static inline char readChar(const unsigned char * bufor, int &i) +static inline char readChar(const ui8 * bufor, int &i) { return bufor[i++]; } -DLL_EXPORT std::string readString(const unsigned char * bufor, int &i); +DLL_LINKAGE std::string readString(const ui8 * bufor, int &i); enum LodFileType{ FILE_ANY, @@ -91,17 +85,17 @@ public: } -class DLL_EXPORT CLodHandler +class DLL_LINKAGE CLodHandler { std::map extMap;// to convert extensions to file type std::ifstream LOD; - unsigned int totalFiles; + ui32 totalFiles; boost::mutex *mutex; std::string myDir; //load files from this dir instead of .lod file void initEntry(Entry &e, const std::string name); - int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler + int infs2(ui8 * in, int size, int realSize, ui8*& out, int wBits=15); //zlib fast handler public: //convert string to upper case and remove extension. If extension!=NULL -> it will be copied here (including dot) @@ -113,16 +107,13 @@ public: ~CLodHandler(); void init(const std::string lodFile, const std::string dirName); std::string getFileName(std::string lodFile, LodFileType type=FILE_ANY); - unsigned char * giveFile(std::string defName, LodFileType type=FILE_ANY, int * length=NULL); //returns pointer to the decompressed data - it must be deleted when no longer needed! + ui8 * giveFile(std::string defName, LodFileType type=FILE_ANY, int * length=NULL); //returns pointer to the decompressed data - it must be deleted when no longer needed! bool haveFile(std::string name, LodFileType type=FILE_ANY);//check if file is present in lod std::string getTextFile(std::string name, LodFileType type=FILE_TEXT); //extracts one file void extractFile(const std::string FName, const std::string name, LodFileType type=FILE_ANY); //extracts a specific file //unpack data from memory, input data will be deleted - static unsigned char * getUnpackedData(unsigned char *data, size_t inputSize, int * outputSize); + static ui8 * getUnpackedData(ui8 *data, size_t inputSize, int * outputSize); //loads given file, decompresses and returns - static unsigned char * getUnpackedFile(const std::string & path, int * sizeOut); + static ui8 * getUnpackedFile(const std::string & path, int * sizeOut); }; - - -#endif // __CLODHANDLER_H__ diff --git a/lib/CMapInfo.cpp b/lib/CMapInfo.cpp index 93a802fc0..6f4bd169e 100644 --- a/lib/CMapInfo.cpp +++ b/lib/CMapInfo.cpp @@ -1,14 +1,15 @@ -#define VCMI_DLL - +#include "StdInc.h" #include "CMapInfo.h" -#include "../StartInfo.h" + +#include "StartInfo.h" #include "map.h" #include "CCampaignHandler.h" +#include "GameConstants.h" void CMapInfo::countPlayers() { actualHumanPlayers = playerAmnt = humenPlayers = 0; - for(int i=0;iplayers[i].canHumanPlay) { @@ -32,7 +33,7 @@ CMapInfo::CMapInfo(bool map) { } -void CMapInfo::mapInit(const std::string &fname, const unsigned char *map ) +void CMapInfo::mapInit(const std::string &fname, const ui8 *map ) { filename = fname; int i = 0; diff --git a/lib/CMapInfo.h b/lib/CMapInfo.h index 4f62ad143..9f5169d34 100644 --- a/lib/CMapInfo.h +++ b/lib/CMapInfo.h @@ -1,6 +1,6 @@ #pragma once -#include "../global.h" + class CMapHeader; class CCampaignHeader; @@ -8,7 +8,7 @@ struct StartInfo; /// A class which stores the count of human players and all players, the filename, /// scenario options, the map header information,... -class DLL_EXPORT CMapInfo +class DLL_LINKAGE CMapInfo { public: CMapHeader * mapHeader; //may be NULL if campaign @@ -22,9 +22,9 @@ public: int actualHumanPlayers; // >1 if multiplayer game CMapInfo(bool map = true); ~CMapInfo(); - //CMapInfo(const std::string &fname, const unsigned char *map); + //CMapInfo(const std::string &fname, const ui8 *map); void setHeader(CMapHeader *header); - void mapInit(const std::string &fname, const unsigned char *map); + void mapInit(const std::string &fname, const ui8 *map); void campaignInit(); void countPlayers(); diff --git a/lib/CObjectHandler.cpp b/lib/CObjectHandler.cpp index 546103d37..c2a442e6e 100644 --- a/lib/CObjectHandler.cpp +++ b/lib/CObjectHandler.cpp @@ -1,6 +1,6 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "CObjectHandler.h" + #include "CDefObjInfoHandler.h" #include "CLodHandler.h" #include "CGeneralTextHandler.h" @@ -8,10 +8,6 @@ #include "CHeroHandler.h" #include "CSpellHandler.h" #include "../client/CSoundBase.h" -#include -#include -#include -#include #include #include "CTownHandler.h" #include "CCreatureHandler.h" @@ -19,15 +15,12 @@ #include "IGameCallback.h" #include "CGameState.h" #include "NetPacks.h" -#include "../StartInfo.h" +#include "StartInfo.h" #include "map.h" -#include #include -#include -#include -#include #include "CBuildingHandler.h" #include "../lib/JsonNode.h" +#include "GameConstants.h" using namespace boost::assign; @@ -44,7 +37,7 @@ using namespace boost::assign; std::map > > CGTeleport::objs; std::vector > CGTeleport::gates; IGameCallback * IObjectInterface::cb = NULL; -DLL_EXPORT void loadToIt(std::string &dest, const std::string &src, int &iter, int mode); +DLL_LINKAGE void loadToIt(std::string &dest, const std::string &src, int &iter, int mode); extern CLodHandler * bitmaph; extern boost::rand48 ran; std::map > CGKeys::playerKeyMap; @@ -121,10 +114,10 @@ static void readCreatures(const JsonNode &creature, std::vector< std::pair pos.y>cmp.pos.y) return false; - if(cmp.ID==HEROI_TYPE && ID!=HEROI_TYPE) + if(cmp.ID==GameConstants::HEROI_TYPE && ID!=GameConstants::HEROI_TYPE) return true; - if(cmp.ID!=HEROI_TYPE && ID==HEROI_TYPE) + if(cmp.ID!=GameConstants::HEROI_TYPE && ID==GameConstants::HEROI_TYPE) return false; if(!defInfo->isVisitable() && cmp.defInfo->isVisitable()) return true; @@ -515,7 +508,7 @@ static int lowestSpeed(const CGHeroInstance * chi) return ret; } -unsigned int CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &from) const +ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &from) const { //TODO: check if all creatures are on its native terrain and change cost appropriately @@ -554,9 +547,9 @@ unsigned int CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainT // - for loop is wrong. will not find all creatures. must use iterator instead. // - -> is the slot number. use second->first for creature index // Is lowestSpeed() the correct equivalent ? -unsigned int CGHeroInstance::getLowestCreatureSpeed() const +ui32 CGHeroInstance::getLowestCreatureSpeed() const { - unsigned int sl = 100; + ui32 sl = 100; for(size_t h=0; h < stacksCount(); ++h) { if(VLC->creh->creatures[Slots().find(h)->first]->speedheroh->heroes[subID]; @@ -725,11 +718,11 @@ void CGHeroInstance::initHero() else //remove placeholder spells -= 0xffffffff; - if(!getArt(Arts::MACH4) && !getArt(Arts::SPELLBOOK) && type->startingSpell >= 0) //no catapult means we haven't read pre-existent set -> use default rules for spellbook - putArtifact(Arts::SPELLBOOK, CArtifactInstance::createNewArtifactInstance(0)); + if(!getArt(ArtifactPosition::MACH4) && !getArt(ArtifactPosition::SPELLBOOK) && type->startingSpell >= 0) //no catapult means we haven't read pre-existent set -> use default rules for spellbook + putArtifact(ArtifactPosition::SPELLBOOK, CArtifactInstance::createNewArtifactInstance(0)); - if(!getArt(Arts::MACH4)) - putArtifact(Arts::MACH4, CArtifactInstance::createNewArtifactInstance(3)); //everyone has a catapult + if(!getArt(ArtifactPosition::MACH4)) + putArtifact(ArtifactPosition::MACH4, CArtifactInstance::createNewArtifactInstance(3)); //everyone has a catapult if(portrait < 0 || portrait == 255) portrait = subID; @@ -803,7 +796,7 @@ void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= NULL*/) switch (creID) { case 145: //catapult - slot = Arts::MACH4; + slot = ArtifactPosition::MACH4; aid = 3; break; default: @@ -823,10 +816,10 @@ void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= NULL*/) } void CGHeroInstance::initHeroDefInfo() { - if(!defInfo || defInfo->id != HEROI_TYPE) + if(!defInfo || defInfo->id != GameConstants::HEROI_TYPE) { defInfo = new CGDefInfo(); - defInfo->id = HEROI_TYPE; + defInfo->id = GameConstants::HEROI_TYPE; defInfo->subid = subID; defInfo->printPriority = 0; defInfo->visitDir = 0xff; @@ -854,7 +847,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const { if(h == this) return; //exclude potential self-visiting - if (ID == HEROI_TYPE) //hero + if (ID == GameConstants::HEROI_TYPE) //hero { if( cb->gameState()->getPlayerRelations(tempOwner, h->tempOwner)) //our or ally hero { @@ -878,7 +871,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const if(cb->getHeroCount(h->tempOwner,false) < 8) //free hero slot { cb->changeObjPos(id,pos+int3(1,0,0),0); - cb->setObjProperty(id, ObjProperty::ID, HEROI_TYPE); //set ID to 34 + cb->setObjProperty(id, ObjProperty::ID, GameConstants::HEROI_TYPE); //set ID to 34 cb->giveHero(id,h->tempOwner); //recreates def and adds hero to player iw.text << std::pair(11,102); @@ -1046,7 +1039,7 @@ void CGHeroInstance::initObj() speciality.addNewBonus(bonus); bonus = new Bonus(*bonus); } - delNull(bonus); + vstd::clear_pointer(bonus); break; } case 10://resource generation @@ -1232,7 +1225,7 @@ ui64 CGHeroInstance::getTotalStrength() const expType CGHeroInstance::calculateXp(expType exp) const { - return exp * (100 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::LEARNING))/100.0f; + return exp * (100 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::LEARNING))/100.0; } ui8 CGHeroInstance::getSpellSchoolLevel(const CSpell * spell, int *outSelectedSchool) const @@ -1260,8 +1253,8 @@ ui8 CGHeroInstance::getSpellSchoolLevel(const CSpell * spell, int *outSelectedSc - amax(skill, valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 0)); //any school bonus - amax(skill, valOfBonuses(Bonus::SPELL, spell->id)); //given by artifact or other effect + vstd::amax(skill, valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 0)); //any school bonus + vstd::amax(skill, valOfBonuses(Bonus::SPELL, spell->id)); //given by artifact or other effect if (hasBonusOfType(Bonus::MAXED_SPELL, spell->id))//hero speciality (Daremyth, Melodia) skill = 3; assert(skill >= 0 && skill <= 3); @@ -1301,7 +1294,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b if (necromancyLevel > 0) { double necromancySkill = valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, NECROMANCY)/100.0; - amin(necromancySkill, 1.0); //it's impossible to raise more creatures than all... + vstd::amin(necromancySkill, 1.0); //it's impossible to raise more creatures than all... const std::map &casualties = battleResult.casualties[!battleResult.winner]; ui32 raisedUnits = 0; @@ -1431,7 +1424,7 @@ void CGHeroInstance::pushPrimSkill(int which, int val) addNewBonus(new Bonus(Bonus::PERMANENT, Bonus::PRIMARY_SKILL, Bonus::HERO_BASE_SKILL, val, id, which)); } -EAlignment CGHeroInstance::getAlignment() const +EAlignment::EAlignment CGHeroInstance::getAlignment() const { return type->heroClass->getAlignment(); } @@ -1460,7 +1453,7 @@ void CGHeroInstance::putInBackpack(CArtifactInstance *art) bool CGHeroInstance::hasSpellbook() const { - return getArt(Arts::SPELLBOOK); + return getArt(ArtifactPosition::SPELLBOOK); } void CGHeroInstance::deserializationFix() @@ -1488,7 +1481,7 @@ CBonusSystemNode * CGHeroInstance::whereShouldBeAttached(CGameState *gs) int CGHeroInstance::movementPointsAfterEmbark(int MPsBefore, int basicCost, bool disembark /*= false*/) const { if(hasBonusOfType(Bonus::FREE_SHIP_BOARDING)) - return (MPsBefore - basicCost) * ((float)(maxMovePoints(disembark)) / maxMovePoints(!disembark)); + return (MPsBefore - basicCost) * static_cast(maxMovePoints(disembark)) / maxMovePoints(!disembark); return 0; //take all MPs otherwise } @@ -1564,12 +1557,12 @@ void CGDwelling::setProperty(ui8 what, ui32 val) case ObjProperty::OWNER: //change owner if (ID == 17) //single generators { - if (tempOwner != NEUTRAL_PLAYER) + if (tempOwner != GameConstants::NEUTRAL_PLAYER) { std::vector >* dwellings = &cb->gameState()->players[tempOwner].dwellings; dwellings->erase (std::find(dwellings->begin(), dwellings->end(), this)); } - if (val != NEUTRAL_PLAYER) //can new owner be neutral? + if (val != GameConstants::NEUTRAL_PLAYER) //can new owner be neutral? cb->gameState()->players[val].dwellings.push_back (this); } break; @@ -1647,7 +1640,7 @@ void CGDwelling::newTurn() const return; //town growths and War Machines Factories are handled separately - if(ID == TOWNI_TYPE || ID == 106) + if(ID == GameConstants::TOWNI_TYPE || ID == 106) return; if(ID == 78) //if it's a refugee camp, we need to pick an available creature @@ -1666,7 +1659,7 @@ void CGDwelling::newTurn() const { CCreature *cre = VLC->creh->creatures[creatures[i].second[0]]; TQuantity amount = cre->growth * (1 + cre->valOfBonuses(Bonus::CREATURE_GROWTH_PERCENT)/100) + cre->valOfBonuses(Bonus::CREATURE_GROWTH); - if (DWELLINGS_ACCUMULATE_CREATURES) + if (GameConstants::DWELLINGS_ACCUMULATE_CREATURES) sac.creatures[i].first += amount; else sac.creatures[i].first = amount; @@ -1839,9 +1832,9 @@ int CGTownInstance::mageGuildLevel() const } bool CGTownInstance::creatureDwelling(const int & level, bool upgraded) const { - if ( level<0 || level >= CREATURES_PER_TOWN ) + if ( level<0 || level >= GameConstants::CREATURES_PER_TOWN ) return false; - return vstd::contains(builtBuildings, 30+level+upgraded*CREATURES_PER_TOWN); + return vstd::contains(builtBuildings, 30+level+upgraded*GameConstants::CREATURES_PER_TOWN); } int CGTownInstance::getHordeLevel(const int & HID) const//HID - 0 or 1; returns creature level or -1 if that horde structure is not present { @@ -1856,9 +1849,9 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const { GrowthInfo ret; - if (level<0 || level >=CREATURES_PER_TOWN) + if (level<0 || level >=GameConstants::CREATURES_PER_TOWN) return ret; - if (!vstd::contains(builtBuildings, Buildings::DWELL_FIRST+level)) + if (!vstd::contains(builtBuildings, EBuilding::DWELL_FIRST+level)) return ret; //no dwelling const CCreature *creature = VLC->creh->creatures[town->basicCreatures[level]]; @@ -1867,18 +1860,18 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const ret.entries.push_back(GrowthInfo::Entry(VLC->generaltexth->allTexts[590], base));// \n\nBasic growth %d" - if ( vstd::contains(builtBuildings, Buildings::CASTLE)) - ret.entries.push_back(GrowthInfo::Entry(subID, Buildings::CASTLE, castleBonus = base)); - else if ( vstd::contains(builtBuildings, Buildings::CITADEL)) - ret.entries.push_back(GrowthInfo::Entry(subID, Buildings::CITADEL, castleBonus = base / 2)); + if ( vstd::contains(builtBuildings, EBuilding::CASTLE)) + ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::CASTLE, castleBonus = base)); + else if ( vstd::contains(builtBuildings, EBuilding::CITADEL)) + ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::CITADEL, castleBonus = base / 2)); if(town->hordeLvl[0] == level)//horde 1 - if( vstd::contains(builtBuildings, Buildings::HORDE_1) || vstd::contains(builtBuildings, Buildings::HORDE_1_UPGR)) - ret.entries.push_back(GrowthInfo::Entry(subID, Buildings::HORDE_1, creature->hordeGrowth)); + if( vstd::contains(builtBuildings, EBuilding::HORDE_1) || vstd::contains(builtBuildings, EBuilding::HORDE_1_UPGR)) + ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::HORDE_1, creature->hordeGrowth)); if(town->hordeLvl[1] == level)//horde 2 - if(vstd::contains(builtBuildings, Buildings::HORDE_2) || vstd::contains(builtBuildings, Buildings::HORDE_2_UPGR)) - ret.entries.push_back(GrowthInfo::Entry(subID, Buildings::HORDE_2, creature->hordeGrowth)); + if(vstd::contains(builtBuildings, EBuilding::HORDE_2) || vstd::contains(builtBuildings, EBuilding::HORDE_2_UPGR)) + ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::HORDE_2, creature->hordeGrowth)); int dwellingBonus = 0; if(const PlayerState *p = cb->getPlayer(tempOwner, false)) @@ -1901,8 +1894,8 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const BOOST_FOREACH(const Bonus *b, *bonuses2) ret.entries.push_back(GrowthInfo::Entry(b->Description() + " %+d", b->val * (base + castleBonus) / 100)); - if(vstd::contains(builtBuildings, Buildings::GRAIL)) //grail - +50% to ALL (so far added) growth - ret.entries.push_back(GrowthInfo::Entry(subID, Buildings::GRAIL, ret.totalGrowth() / 2)); + if(vstd::contains(builtBuildings, EBuilding::GRAIL)) //grail - +50% to ALL (so far added) growth + ret.entries.push_back(GrowthInfo::Entry(subID, EBuilding::GRAIL, ret.totalGrowth() / 2)); return ret; } @@ -2008,10 +2001,10 @@ void CGTownInstance::initObj() hoverName = name + ", " + town->Name(); if (subID == 5) - creatures.resize(CREATURES_PER_TOWN+1);//extra dwelling for Dungeon + creatures.resize(GameConstants::CREATURES_PER_TOWN+1);//extra dwelling for Dungeon else - creatures.resize(CREATURES_PER_TOWN); - for (int i = 0; i < CREATURES_PER_TOWN; i++) + creatures.resize(GameConstants::CREATURES_PER_TOWN); + for (int i = 0; i < GameConstants::CREATURES_PER_TOWN; i++) { if(creatureDwelling(i,false)) creatures[i].second.push_back(town->basicCreatures[i]); @@ -2042,7 +2035,7 @@ void CGTownInstance::newTurn() const { if (cb->getDate(1) == 1) //reset on new week { - if (vstd::contains(builtBuildings,17) && subID == 1 && cb->getDate(0) != 1 && (tempOwner < PLAYER_LIMIT) )//give resources for Rampart, Mystic Pond + if (vstd::contains(builtBuildings,17) && subID == 1 && cb->getDate(0) != 1 && (tempOwner < GameConstants::PLAYER_LIMIT) )//give resources for Rampart, Mystic Pond { int resID = rand()%4+2;//bonus to random rare resource resID = (resID==2)?1:resID; @@ -2059,7 +2052,7 @@ void CGTownInstance::newTurn() const cb->setObjProperty (id, 12, (*i)->id); //reset visitors for Mana Vortex } - if (tempOwner == NEUTRAL_PLAYER) //garrison growth for neutral towns + if (tempOwner == GameConstants::NEUTRAL_PLAYER) //garrison growth for neutral towns { std::vector nativeCrits; //slots for (TSlots::const_iterator it = Slots().begin(); it != Slots().end(); it++) @@ -2084,9 +2077,9 @@ void CGTownInstance::newTurn() const cb->changeStackType(sl, VLC->creh->creatures[*c->upgrades.begin()]); } } - if ((stacksCount() < ARMY_SIZE && rand()%100 < 25) || Slots().empty()) //add new stack + if ((stacksCount() < GameConstants::ARMY_SIZE && rand()%100 < 25) || Slots().empty()) //add new stack { - int i = rand() % std::min (ARMY_SIZE, cb->getDate(3)<<1); + int i = rand() % std::min (GameConstants::ARMY_SIZE, cb->getDate(3)<<1); TCreature c = town->basicCreatures[i]; TSlot n = -1; @@ -2118,7 +2111,7 @@ int3 CGTownInstance::getSightCenter() const ui8 CGTownInstance::getPassableness() const { if (!armedGarrison())//empty castle - anyone can visit - return ALL_PLAYERS; + return GameConstants::ALL_PLAYERS; if ( tempOwner == 255 )//neutral guarded - no one can visit return 0; @@ -2196,21 +2189,21 @@ int CGTownInstance::getMarketEfficiency() const return marketCount; } -bool CGTownInstance::allowsTrade(EMarketMode mode) const +bool CGTownInstance::allowsTrade(EMarketMode::EMarketMode mode) const { switch(mode) { - case RESOURCE_RESOURCE: - case RESOURCE_PLAYER: + case EMarketMode::RESOURCE_RESOURCE: + case EMarketMode::RESOURCE_PLAYER: return vstd::contains(builtBuildings, 14); // marketplace - case ARTIFACT_RESOURCE: - case RESOURCE_ARTIFACT: + case EMarketMode::ARTIFACT_RESOURCE: + case EMarketMode::RESOURCE_ARTIFACT: return (subID == 2 || subID == 5 || subID == 8) && vstd::contains(builtBuildings, 17);//artifact merchants - case CREATURE_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: return subID == 6 && vstd::contains(builtBuildings, 21); //Freelancer's guild - case CREATURE_UNDEAD: + case EMarketMode::CREATURE_UNDEAD: return subID == 4 && vstd::contains(builtBuildings, 22);//Skeleton transformer - case RESOURCE_SKILL: + case EMarketMode::RESOURCE_SKILL: return subID == 8 && vstd::contains(builtBuildings, 21);//Magic University default: assert(0); @@ -2218,9 +2211,9 @@ bool CGTownInstance::allowsTrade(EMarketMode mode) const } } -std::vector CGTownInstance::availableItemsIds(EMarketMode mode) const +std::vector CGTownInstance::availableItemsIds(EMarketMode::EMarketMode mode) const { - if(mode == RESOURCE_ARTIFACT) + if(mode == EMarketMode::RESOURCE_ARTIFACT) { std::vector ret; BOOST_FOREACH(const CArtifact *a, merchantArtifacts) @@ -2230,7 +2223,7 @@ std::vector CGTownInstance::availableItemsIds(EMarketMode mode) const ret.push_back(-1); return ret; } - else if ( mode == RESOURCE_SKILL ) + else if ( mode == EMarketMode::RESOURCE_SKILL ) { return universitySkills; } @@ -2823,7 +2816,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const break; case 5://academy of battle scholars what = 4; - val = 1000*(100+h->getSecSkillLevel(CGHeroInstance::LEARNING)*5)/100.0f; + val = 1000*(100+h->getSecSkillLevel(CGHeroInstance::LEARNING)*5)/100.0; mid = 583; iw.components.push_back (Component(Component::EXPERIENCE, 0, val, 0)); break; @@ -3012,13 +3005,13 @@ void CGCreature::initObj() } void CGCreature::newTurn() const {//Works only for stacks of single type of size up to 2 millions - if (stacks.begin()->second->count < CREEP_SIZE && cb->getDate(1) == 1 && cb->getDate(0) > 1) + if (stacks.begin()->second->count < GameConstants::CREEP_SIZE && cb->getDate(1) == 1 && cb->getDate(0) > 1) { - ui32 power = temppower * (100 + WEEKLY_GROWTH)/100; - cb->setObjProperty(id, ObjProperty::MONSTER_COUNT, std::min (power/1000 , (ui32)CREEP_SIZE)); //set new amount + ui32 power = temppower * (100 + GameConstants::WEEKLY_GROWTH)/100; + cb->setObjProperty(id, ObjProperty::MONSTER_COUNT, std::min (power/1000 , (ui32)GameConstants::CREEP_SIZE)); //set new amount cb->setObjProperty(id, ObjProperty::MONSTER_POWER, power); //increase temppower } - if (STACK_EXP) + if (GameConstants::STACK_EXP) cb->setObjProperty(id, ObjProperty::MONSTER_EXP, 10000); //for testing purpose } void CGCreature::setPropertyDer(ui8 what, ui32 val) @@ -3168,7 +3161,7 @@ void CGCreature::fight( const CGHeroInstance *h ) const int basicType = stacks.begin()->second->type->idNumber; cb->setObjProperty(id, ObjProperty::MONSTER_RESTORE_TYPE, basicType); //store info about creature stack - float relativePower = ((float)h->getTotalStrength() / getArmyStrength()); + double relativePower = static_cast(h->getTotalStrength()) / getArmyStrength(); int stacksCount; //TODO: number depends on tile type if (relativePower < 0.5) @@ -3270,7 +3263,7 @@ void CGMine::newTurn() const if(cb->getDate() == 1) return; - if (tempOwner == NEUTRAL_PLAYER) + if (tempOwner == GameConstants::NEUTRAL_PLAYER) return; cb->giveResource(tempOwner, producedResource, producedQuantity); @@ -3293,7 +3286,7 @@ void CGMine::initObj() assert(possibleResources.size()); producedResource = possibleResources[ran()%possibleResources.size()]; - tempOwner = NEUTRAL_PLAYER; + tempOwner = GameConstants::NEUTRAL_PLAYER; hoverName = VLC->generaltexth->mines[7].first + "\n" + VLC->generaltexth->allTexts[202] + " " + troglodytes->getQuantityTXT(false) + " " + troglodytes->type->namePl; } else @@ -3302,8 +3295,8 @@ void CGMine::initObj() MetaString ms; ms << std::pair(9,producedResource); - if(tempOwner >= PLAYER_LIMIT) - tempOwner = NEUTRAL_PLAYER; + if(tempOwner >= GameConstants::PLAYER_LIMIT) + tempOwner = GameConstants::NEUTRAL_PLAYER; else ms << " (" << std::pair(6,23+tempOwner) << ")"; ms.toString(hoverName); @@ -3569,7 +3562,7 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const } TQuantity countToTake = h->getStackCount(targetstack) * 0.5; - amax(countToTake, 1); + vstd::amax(countToTake, 1); InfoWindow iw; @@ -4402,7 +4395,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const switch (rewardType) { - case 1: bd.components.push_back(Component (Component::EXPERIENCE, 0, rVal*(100+h->getSecSkillLevel(CGHeroInstance::LEARNING)*5)/100.0f, 0)); + case 1: bd.components.push_back(Component (Component::EXPERIENCE, 0, rVal*(100+h->getSecSkillLevel(CGHeroInstance::LEARNING)*5)/100.0, 0)); break; case 2: bd.components.push_back(Component (Component::PRIM_SKILL, 5, rVal, 0)); break; @@ -4556,7 +4549,7 @@ const CGHeroInstance * CGSeerHut::getHeroToKill(bool allowNull) const const CGObjectInstance *o = cb->getObjByQuestIdentifier(m13489val); if(allowNull && !o) return NULL; - assert(o && o->ID == HEROI_TYPE); + assert(o && o->ID == GameConstants::HEROI_TYPE); return static_cast(o); } @@ -4625,7 +4618,7 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const iw.text << std::pair(11,172); iw.text.addReplacement(MetaString::SEC_SKILL_NAME, ability); } - else if(h->secSkills.size() >= SKILL_PER_HERO) //already all skills slots used + else if(h->secSkills.size() >= GameConstants::SKILL_PER_HERO) //already all skills slots used { iw.text << std::pair(11,173); iw.text.addReplacement(MetaString::SEC_SKILL_NAME, ability); @@ -5025,7 +5018,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con int curLev = h->getSecSkillLevel(static_cast(abilities[i])); if( (curLev && curLev < abilityLevels[i]) - || (h->secSkills.size() < SKILL_PER_HERO) ) + || (h->secSkills.size() < GameConstants::SKILL_PER_HERO) ) { cb->changeSecSkill(h->id,abilities[i],abilityLevels[i],true); } @@ -5380,13 +5373,13 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const //check if the bonus if applicable, if not - give primary skill (always possible) int ssl = h->getSecSkillLevel(static_cast(bid)); //current sec skill level, used if bonusType == 1 if((type == 1 - && ((ssl == 3) || (!ssl && h->secSkills.size() == SKILL_PER_HERO))) ////hero already has expert level in the skill or (don't know skill and doesn't have free slot) + && ((ssl == 3) || (!ssl && h->secSkills.size() == GameConstants::SKILL_PER_HERO))) ////hero already has expert level in the skill or (don't know skill and doesn't have free slot) || (type == 2 && (!h->getArt(17) || vstd::contains(h->spells, (ui32) bid) || (VLC->spellh->spells[bid]->level > h->getSecSkillLevel(CGHeroInstance::WISDOM) + 2) ))) //hero doesn't have a spellbook or already knows the spell or doesn't have Wisdom { type = 0; - bid = ran() % PRIMARY_SKILLS; + bid = ran() % GameConstants::PRIMARY_SKILLS; } @@ -5431,10 +5424,10 @@ void CGScholar::initObj() switch(bonusType) { case 0: - bonusID = ran() % PRIMARY_SKILLS; + bonusID = ran() % GameConstants::PRIMARY_SKILLS; break; case 1: - bonusID = ran() % SKILL_QUANTITY; + bonusID = ran() % GameConstants::SKILL_QUANTITY; break; case 2: std::vector possibilities; @@ -5471,7 +5464,7 @@ void CGGarrison::fightOver (const CGHeroInstance *h, BattleResult *result) const ui8 CGGarrison::getPassableness() const { if ( !stacksCount() )//empty - anyone can visit - return ALL_PLAYERS; + return GameConstants::ALL_PLAYERS; if ( tempOwner == 255 )//neutral guarded - no one can visit return 0; @@ -5748,7 +5741,7 @@ void CBank::setPropertyDer (ui8 what, ui32 val) daycounter++; break; case 12: //multiplier, in percent - multiplier = ((float)val)/100; + multiplier = val / 100.0; break; case 13: //bank preset bc = VLC->objh->banksInfo[index][val]; @@ -6127,7 +6120,7 @@ void CGPyramid::endBattle (const CGHeroInstance *h, const BattleResult *result) } void CGKeys::setPropertyDer (ui8 what, ui32 val) //101-108 - enable key for player 1-8 { - if (what >= 101 && what <= (100 + PLAYER_LIMIT)) + if (what >= 101 && what <= (100 + GameConstants::PLAYER_LIMIT)) playerKeyMap.find(what-101)->second.insert((ui8)val); } @@ -6219,7 +6212,7 @@ void CGBorderGate::onHeroVisit( const CGHeroInstance * h ) const //TODO: passabi ui8 CGBorderGate::getPassableness() const { ui8 ret = 0; - for (int i = 0; i < PLAYER_LIMIT; i++) + for (int i = 0; i < GameConstants::PLAYER_LIMIT; i++) ret |= wasMyColorVisited(i)< &cost ) const { - cost.resize(RESOURCE_QUANTITY); + cost.resize(GameConstants::RESOURCE_QUANTITY); cost[0] = 10; cost[6] = 1000; } @@ -6419,7 +6412,7 @@ IShipyard * IShipyard::castFrom( CGObjectInstance *obj ) if(!obj) return NULL; - if(obj->ID == TOWNI_TYPE) + if(obj->ID == GameConstants::TOWNI_TYPE) { return static_cast(obj); } @@ -6597,7 +6590,7 @@ void CGObelisk::setPropertyDer( ui8 what, ui32 val ) switch(what) { case 20: - assert(val < PLAYER_LIMIT); + assert(val < GameConstants::PLAYER_LIMIT); visited[val]++; if(visited[val] > obeliskCount) @@ -6626,7 +6619,7 @@ void CGLighthouse::onHeroVisit( const CGHeroInstance * h ) const giveBonusTo(h->tempOwner); - if(oldOwner < PLAYER_LIMIT) //remove bonus from old owner + if(oldOwner < GameConstants::PLAYER_LIMIT) //remove bonus from old owner { RemoveBonus rb(RemoveBonus::PLAYER); rb.whoID = oldOwner; @@ -6639,7 +6632,7 @@ void CGLighthouse::onHeroVisit( const CGHeroInstance * h ) const void CGLighthouse::initObj() { - if(tempOwner < PLAYER_LIMIT) + if(tempOwner < GameConstants::PLAYER_LIMIT) { giveBonusTo(tempOwner); } @@ -6758,7 +6751,7 @@ void CArmedInstance::armyChanged() CBonusSystemNode * CArmedInstance::whereShouldBeAttached(CGameState *gs) { - if(tempOwner < PLAYER_LIMIT) + if(tempOwner < GameConstants::PLAYER_LIMIT) return gs->getPlayer(tempOwner); else return &gs->globalEffects; @@ -6769,15 +6762,15 @@ CBonusSystemNode * CArmedInstance::whatShouldBeAttached() return this; } -bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const +bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMarketMode mode) const { switch(mode) { - case RESOURCE_RESOURCE: + case EMarketMode::RESOURCE_RESOURCE: { - float effectiveness = std::min(((float)getMarketEfficiency()+1.0f) / 20.0f, 0.5f); + double effectiveness = std::min((getMarketEfficiency() + 1.0) / 20.0, 0.5); - float r = VLC->objh->resVals[id1], //value of given resource + double r = VLC->objh->resVals[id1], //value of given resource g = VLC->objh->resVals[id2] / effectiveness; //value of wanted resource if(r>g) //if given resource is more expensive than wanted @@ -6787,17 +6780,17 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) } else //if wanted resource is more expensive { - val1 = (g / r) + 0.5f; + val1 = (g / r) + 0.5; val2 = 1; } } break; - case CREATURE_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: { - const float effectivenessArray[] = {0, 0.3, 0.45, 0.50, 0.65, 0.7, 0.85, 0.9, 1}; - float effectiveness = effectivenessArray[std::min(getMarketEfficiency(), 8)]; + const double effectivenessArray[] = {0.0, 0.3, 0.45, 0.50, 0.65, 0.7, 0.85, 0.9, 1.0}; + double effectiveness = effectivenessArray[std::min(getMarketEfficiency(), 8)]; - float r = VLC->creh->creatures[id1]->cost[6], //value of given creature in gold + double r = VLC->creh->creatures[id1]->cost[6], //value of given creature in gold g = VLC->objh->resVals[id2] / effectiveness; //value of wanted resource if(r>g) //if given resource is more expensive than wanted @@ -6807,49 +6800,49 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) } else //if wanted resource is more expensive { - val1 = (g / r) + 0.5f; + val1 = (g / r) + 0.5; val2 = 1; } } break; - case RESOURCE_PLAYER: + case EMarketMode::RESOURCE_PLAYER: val1 = 1; val2 = 1; break; - case RESOURCE_ARTIFACT: + case EMarketMode::RESOURCE_ARTIFACT: { - float effectiveness = std::min(((float)getMarketEfficiency()+3.0f) / 20.0f, 0.6f); - float r = VLC->objh->resVals[id1], //value of offered resource + double effectiveness = std::min((getMarketEfficiency() + 3.0) / 20.0, 0.6); + double r = VLC->objh->resVals[id1], //value of offered resource g = VLC->arth->artifacts[id2]->price / effectiveness; //value of bought artifact in gold if(id1 != 6) //non-gold prices are doubled r /= 2; assert(g >= r); //should we allow artifacts cheaper than unit of resource? - val1 = (g / r) + 0.5f; + val1 = (g / r) + 0.5; val2 = 1; } break; - case ARTIFACT_RESOURCE: + case EMarketMode::ARTIFACT_RESOURCE: { - float effectiveness = std::min(((float)getMarketEfficiency()+3.0f) / 20.0f, 0.6f); - float r = VLC->arth->artifacts[id1]->price * effectiveness, + double effectiveness = std::min((getMarketEfficiency() + 3.0) / 20.0, 0.6); + double r = VLC->arth->artifacts[id1]->price * effectiveness, g = VLC->objh->resVals[id2]; // if(id2 != 6) //non-gold prices are doubled // r /= 2; val1 = 1; - val2 = (r / g) + 0.5f; + val2 = (r / g) + 0.5; } break; - case CREATURE_EXP: + case EMarketMode::CREATURE_EXP: { val1 = 1; val2 = (VLC->creh->creatures[id1]->AIValue / 40) * 5; } break; - case ARTIFACT_EXP: + case EMarketMode::ARTIFACT_EXP: { val1 = 1; @@ -6872,32 +6865,32 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) return true; } -bool IMarket::allowsTrade(EMarketMode mode) const +bool IMarket::allowsTrade(EMarketMode::EMarketMode mode) const { return false; } -int IMarket::availableUnits(EMarketMode mode, int marketItemSerial) const +int IMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const { switch(mode) { - case RESOURCE_RESOURCE: - case ARTIFACT_RESOURCE: - case CREATURE_RESOURCE: + case EMarketMode::RESOURCE_RESOURCE: + case EMarketMode::ARTIFACT_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: return -1; default: return 1; } } -std::vector IMarket::availableItemsIds(EMarketMode mode) const +std::vector IMarket::availableItemsIds(EMarketMode::EMarketMode mode) const { std::vector ret; switch(mode) { - case RESOURCE_RESOURCE: - case ARTIFACT_RESOURCE: - case CREATURE_RESOURCE: + case EMarketMode::RESOURCE_RESOURCE: + case EMarketMode::ARTIFACT_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: for (int i = 0; i < 7; i++) ret.push_back(i); default: @@ -6910,7 +6903,7 @@ const IMarket * IMarket::castFrom(const CGObjectInstance *obj) { switch(obj->ID) { - case TOWNI_TYPE: + case GameConstants::TOWNI_TYPE: return static_cast(obj); case 2: //Altar of Sacrifice case 7: //Black Market @@ -6932,12 +6925,12 @@ IMarket::IMarket(const CGObjectInstance *O) } -std::vector IMarket::availableModes() const +std::vector IMarket::availableModes() const { - std::vector ret; - for (int i = 0; i < MARTKET_AFTER_LAST_PLACEHOLDER; i++) - if(allowsTrade((EMarketMode)i)) - ret.push_back((EMarketMode)i); + std::vector ret; + for (int i = 0; i < EMarketMode::MARTKET_AFTER_LAST_PLACEHOLDER; i++) + if(allowsTrade((EMarketMode::EMarketMode)i)) + ret.push_back((EMarketMode::EMarketMode)i); return ret; } @@ -6956,12 +6949,12 @@ int CGMarket::getMarketEfficiency() const return 5; } -bool CGMarket::allowsTrade(EMarketMode mode) const +bool CGMarket::allowsTrade(EMarketMode::EMarketMode mode) const { switch(mode) { - case RESOURCE_RESOURCE: - case RESOURCE_PLAYER: + case EMarketMode::RESOURCE_RESOURCE: + case EMarketMode::RESOURCE_PLAYER: switch(ID) { case 99: //Trading Post @@ -6970,32 +6963,32 @@ bool CGMarket::allowsTrade(EMarketMode mode) const default: return false; } - case CREATURE_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: return ID == 213; //Freelancer's Guild //case ARTIFACT_RESOURCE: - case RESOURCE_ARTIFACT: + case EMarketMode::RESOURCE_ARTIFACT: return ID == 7; //Black Market - case ARTIFACT_EXP: - case CREATURE_EXP: + case EMarketMode::ARTIFACT_EXP: + case EMarketMode::CREATURE_EXP: return ID == 2; //TODO? check here for alignment of visiting hero? - would not be coherent with other checks here - case RESOURCE_SKILL: + case EMarketMode::RESOURCE_SKILL: return ID == 104;//University default: return false; } } -int CGMarket::availableUnits(EMarketMode mode, int marketItemSerial) const +int CGMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const { return -1; } -std::vector CGMarket::availableItemsIds(EMarketMode mode) const +std::vector CGMarket::availableItemsIds(EMarketMode::EMarketMode mode) const { switch(mode) { - case RESOURCE_RESOURCE: - case RESOURCE_PLAYER: + case EMarketMode::RESOURCE_RESOURCE: + case EMarketMode::RESOURCE_PLAYER: return IMarket::availableItemsIds(mode); default: return std::vector(); @@ -7007,13 +7000,13 @@ CGMarket::CGMarket() { } -std::vector CGBlackMarket::availableItemsIds(EMarketMode mode) const +std::vector CGBlackMarket::availableItemsIds(EMarketMode::EMarketMode mode) const { switch(mode) { - case ARTIFACT_RESOURCE: + case EMarketMode::ARTIFACT_RESOURCE: return IMarket::availableItemsIds(mode); - case RESOURCE_ARTIFACT: + case EMarketMode::RESOURCE_ARTIFACT: { std::vector ret; BOOST_FOREACH(const CArtifact *a, artifacts) @@ -7042,7 +7035,7 @@ void CGBlackMarket::newTurn() const void CGUniversity::initObj() { std::vector toChoose; - for (int i=0; iisAllowed(2,i)) toChoose.push_back(i); if (toChoose.size() < 4) @@ -7059,11 +7052,11 @@ void CGUniversity::initObj() } } -std::vector CGUniversity::availableItemsIds(EMarketMode mode) const +std::vector CGUniversity::availableItemsIds(EMarketMode::EMarketMode mode) const { switch (mode) { - case RESOURCE_SKILL: + case EMarketMode::RESOURCE_SKILL: return skills; default: @@ -7086,7 +7079,7 @@ GrowthInfo::Entry::Entry(const std::string &format, int _count) description = boost::str(boost::format(format) % count); } -GrowthInfo::Entry::Entry(int subID, Buildings::EBuilding building, int _count) +GrowthInfo::Entry::Entry(int subID, EBuilding::EBuilding building, int _count) : count(_count) { description = boost::str(boost::format("%s %+d") % VLC->buildh->buildings[subID][building]->Name() % count); diff --git a/lib/CObjectHandler.h b/lib/CObjectHandler.h index 19c01f9a5..af012e208 100644 --- a/lib/CObjectHandler.h +++ b/lib/CObjectHandler.h @@ -1,11 +1,6 @@ -#ifndef __COBJECTHANDLER_H__ -#define __COBJECTHANDLER_H__ -#include "../global.h" -#include -#include -#include -#include -#include +#pragma once + + #ifndef _MSC_VER #include "CHeroHandler.h" #include "CTownHandler.h" @@ -14,7 +9,8 @@ #include "../lib/CCreatureSet.h" #include "CArtHandler.h" #include "../lib/ConstTransitivePtr.h" -#include +#include "int3.h" +#include "GameConstants.h" /* * CObjectHandler.h, part of VCMI engine @@ -56,7 +52,7 @@ struct NewArtifact; class CGBoat; class CArtifactSet; -class DLL_EXPORT CQuest +class DLL_LINKAGE CQuest { public: enum Emission {MISSION_NONE = 0, MISSION_LEVEL = 1, MISSION_PRIMARY_STAT = 2, MISSION_KILL_HERO = 3, MISSION_KILL_CREATURE = 4, @@ -84,7 +80,7 @@ public: } }; -class DLL_EXPORT IObjectInterface +class DLL_LINKAGE IObjectInterface { public: static IGameCallback *cb; @@ -102,7 +98,7 @@ public: static void postInit();//caleed after objs receive their initObj }; -class DLL_EXPORT IBoatGenerator +class DLL_LINKAGE IBoatGenerator { public: const CGObjectInstance *o; @@ -115,7 +111,7 @@ public: void getProblemText(MetaString &out, const CGHeroInstance *visitor = NULL) const; }; -class DLL_EXPORT IShipyard : public IBoatGenerator +class DLL_LINKAGE IShipyard : public IBoatGenerator { public: IShipyard(const CGObjectInstance *O); @@ -125,24 +121,24 @@ public: static IShipyard *castFrom(CGObjectInstance *obj); }; -class DLL_EXPORT IMarket +class DLL_LINKAGE IMarket { virtual int getMarketEfficiency() const =0; public: const CGObjectInstance *o; IMarket(const CGObjectInstance *O); - virtual bool allowsTrade(EMarketMode mode) const; - virtual int availableUnits(EMarketMode mode, int marketItemSerial) const; //-1 if unlimited - virtual std::vector availableItemsIds(EMarketMode mode) const; + virtual bool allowsTrade(EMarketMode::EMarketMode mode) const; + virtual int availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const; //-1 if unlimited + virtual std::vector availableItemsIds(EMarketMode::EMarketMode mode) const; - bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units - std::vector availableModes() const; + bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units + std::vector availableModes() const; static const IMarket *castFrom(const CGObjectInstance *obj); }; -class DLL_EXPORT CGObjectInstance : public IObjectInterface +class DLL_LINKAGE CGObjectInstance : public IObjectInterface { protected: void getNameVis(std::string &hname) const; @@ -209,7 +205,7 @@ public: } }; -class DLL_EXPORT CPlayersVisited: public CGObjectInstance +class DLL_LINKAGE CPlayersVisited: public CGObjectInstance { public: std::set players; //players that visited this object @@ -224,7 +220,7 @@ public: } }; -class DLL_EXPORT CArmedInstance: public CGObjectInstance, public CBonusSystemNode, public CCreatureSet +class DLL_LINKAGE CArmedInstance: public CGObjectInstance, public CBonusSystemNode, public CCreatureSet { public: BattleInfo *battle; //set to the current battle, if engaged @@ -250,7 +246,7 @@ public: } }; -class DLL_EXPORT CGHeroInstance : public CArmedInstance, public IBoatGenerator, public CArtifactSet +class DLL_LINKAGE CGHeroInstance : public CArmedInstance, public IBoatGenerator, public CArtifactSet { public: enum SecondarySkill @@ -289,7 +285,7 @@ public: std::set spells; //known spells (spell IDs) - struct DLL_EXPORT Patrol + struct DLL_LINKAGE Patrol { Patrol(){patrolling=false;patrolRadious=-1;}; ui8 patrolling; @@ -300,7 +296,7 @@ public: } } patrol; - struct DLL_EXPORT HeroSpecial : CBonusSystemNode + struct DLL_LINKAGE HeroSpecial : CBonusSystemNode { bool growthsWithLevel; template void serialize(Handler &h, const int version) @@ -339,11 +335,11 @@ public: ////////////////////////////////////////////////////////////////////////// bool hasSpellbook() const; - EAlignment getAlignment() const; + EAlignment::EAlignment getAlignment() const; const std::string &getBiography() const; bool needsLastStack()const; - unsigned int getTileCost(const TerrainTile &dest, const TerrainTile &from) const; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling - unsigned int getLowestCreatureSpeed() const; + ui32 getTileCost(const TerrainTile &dest, const TerrainTile &from) const; //move cost - applying pathfinding skill, road and terrain modifiers. NOT includes diagonal move penalty, last move levelling + ui32 getLowestCreatureSpeed() const; int3 getPosition(bool h3m = false) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation' si32 manaRegain() const; //how many points of mana can hero regain "naturally" in one day bool canWalkOnSea() const; @@ -399,37 +395,37 @@ public: void onHeroVisit(const CGHeroInstance * h) const; }; -class DLL_EXPORT CSpecObjInfo +class DLL_LINKAGE CSpecObjInfo { public: virtual ~CSpecObjInfo(){}; }; -class DLL_EXPORT CCreGenObjInfo : public CSpecObjInfo +class DLL_LINKAGE CCreGenObjInfo : public CSpecObjInfo { public: - unsigned char player; //owner + ui8 player; //owner bool asCastle; ui32 identifier; - unsigned char castles[2]; //allowed castles + ui8 castles[2]; //allowed castles }; -class DLL_EXPORT CCreGen2ObjInfo : public CSpecObjInfo +class DLL_LINKAGE CCreGen2ObjInfo : public CSpecObjInfo { public: - unsigned char player; //owner + ui8 player; //owner bool asCastle; ui32 identifier; - unsigned char castles[2]; //allowed castles - unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6> + ui8 castles[2]; //allowed castles + ui8 minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6> }; -class DLL_EXPORT CCreGen3ObjInfo : public CSpecObjInfo +class DLL_LINKAGE CCreGen3ObjInfo : public CSpecObjInfo { public: - unsigned char player; //owner - unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6> + ui8 player; //owner + ui8 minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6> }; -class DLL_EXPORT CGDwelling : public CArmedInstance +class DLL_LINKAGE CGDwelling : public CArmedInstance { public: CSpecObjInfo * info; //h3m info about dewlling @@ -450,7 +446,7 @@ public: }; -class DLL_EXPORT CGVisitableOPH : public CGObjectInstance //objects visitable only once per hero +class DLL_LINKAGE CGVisitableOPH : public CGObjectInstance //objects visitable only once per hero { public: std::set visitors; //ids of heroes who have visited this obj @@ -471,7 +467,7 @@ public: h & visitors & ttype; } }; -class DLL_EXPORT CGTownBuilding : public IObjectInterface +class DLL_LINKAGE CGTownBuilding : public IObjectInterface { ///basic class for town structures handled as map objects public: @@ -484,7 +480,7 @@ public: h & ID & id; } }; -class DLL_EXPORT COPWBonus : public CGTownBuilding +class DLL_LINKAGE COPWBonus : public CGTownBuilding {///used for OPW bonusing structures public: std::set visitors; @@ -500,7 +496,7 @@ public: } }; -class DLL_EXPORT CTownBonus : public CGTownBuilding +class DLL_LINKAGE CTownBonus : public CGTownBuilding { ///used for one-time bonusing structures ///feel free to merge inheritance tree @@ -518,27 +514,27 @@ public: } }; -class DLL_EXPORT CTownAndVisitingHero : public CBonusSystemNode +class DLL_LINKAGE CTownAndVisitingHero : public CBonusSystemNode { public: CTownAndVisitingHero(); }; -struct DLL_EXPORT GrowthInfo +struct DLL_LINKAGE GrowthInfo { struct Entry { int count; std::string description; Entry(const std::string &format, int _count); - Entry(int subID, Buildings::EBuilding building, int _count); + Entry(int subID, EBuilding::EBuilding building, int _count); }; std::vector entries; int totalGrowth() const; }; -class DLL_EXPORT CGTownInstance : public CGDwelling, public IShipyard, public IMarket +class DLL_LINKAGE CGTownInstance : public CGDwelling, public IShipyard, public IMarket { public: CTownAndVisitingHero townAndVis; @@ -594,8 +590,8 @@ public: int getBoatType() const; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral void getOutOffsets(std::vector &offsets) const; //offsets to obj pos when we boat can be placed int getMarketEfficiency() const; //=market count - bool allowsTrade(EMarketMode mode) const; - std::vector availableItemsIds(EMarketMode mode) const; + bool allowsTrade(EMarketMode::EMarketMode mode) const; + std::vector availableItemsIds(EMarketMode::EMarketMode mode) const; void setPropertyDer(ui8 what, ui32 val); void newTurn() const; @@ -627,7 +623,7 @@ public: void onHeroLeave(const CGHeroInstance * h) const; void initObj(); }; -class DLL_EXPORT CGPandoraBox : public CArmedInstance +class DLL_LINKAGE CGPandoraBox : public CArmedInstance { public: std::string message; @@ -661,7 +657,7 @@ public: } }; -class DLL_EXPORT CGEvent : public CGPandoraBox //event objects +class DLL_LINKAGE CGEvent : public CGPandoraBox //event objects { public: ui8 removeAfterVisit; //true if event is removed after occurring @@ -680,7 +676,7 @@ public: }; -class DLL_EXPORT CGCreature : public CArmedInstance //creatures on map +class DLL_LINKAGE CGCreature : public CArmedInstance //creatures on map { public: ui32 identifier; //unique code for this monster (used in missions) @@ -705,7 +701,7 @@ public: void setPropertyDer(ui8 what, ui32 val); int takenAction(const CGHeroInstance *h, bool allowJoin=true) const; //action on confrontation: -2 - fight, -1 - flee, >=0 - will join for given value of gold (may be 0) - struct DLL_EXPORT RestoredCreature // info about merging stacks after battle back into one + struct DLL_LINKAGE RestoredCreature // info about merging stacks after battle back into one { si32 basicType; template void serialize(Handler &h, const int version) @@ -722,7 +718,7 @@ public: }; -class DLL_EXPORT CGSignBottle : public CGObjectInstance //signs and ocean bottles +class DLL_LINKAGE CGSignBottle : public CGObjectInstance //signs and ocean bottles { public: std::string message; @@ -737,7 +733,7 @@ public: } }; -class DLL_EXPORT CGSeerHut : public CArmedInstance, public CQuest //army is used when giving reward +class DLL_LINKAGE CGSeerHut : public CArmedInstance, public CQuest //army is used when giving reward { public: ui8 rewardType; //type of reward: 0 - no reward; 1 - experience; 2 - mana points; 3 - morale bonus; 4 - luck bonus; 5 - resources; 6 - main ability bonus (attak, defence etd.); 7 - secondary ability gain; 8 - artifact; 9 - spell; 10 - creature @@ -776,7 +772,7 @@ public: } }; -class DLL_EXPORT CGQuestGuard : public CGSeerHut +class DLL_LINKAGE CGQuestGuard : public CGSeerHut { public: void initObj(); @@ -788,7 +784,7 @@ public: } }; -class DLL_EXPORT CGWitchHut : public CPlayersVisited +class DLL_LINKAGE CGWitchHut : public CPlayersVisited { public: std::vector allowedAbilities; @@ -805,7 +801,7 @@ public: }; -class DLL_EXPORT CGScholar : public CGObjectInstance +class DLL_LINKAGE CGScholar : public CGObjectInstance { public: ui8 bonusType; //255 - random, 0 - primary skill, 1 - secondary skill, 2 - spell @@ -821,7 +817,7 @@ public: } }; -class DLL_EXPORT CGGarrison : public CArmedInstance +class DLL_LINKAGE CGGarrison : public CArmedInstance { public: ui8 removableUnits; @@ -837,7 +833,7 @@ public: } }; -class DLL_EXPORT CGArtifact : public CArmedInstance +class DLL_LINKAGE CGArtifact : public CArmedInstance { public: CArtifactInstance *storedArtifact; @@ -856,7 +852,7 @@ public: } }; -class DLL_EXPORT CGResource : public CArmedInstance +class DLL_LINKAGE CGResource : public CArmedInstance { public: ui32 amount; //0 if random @@ -875,7 +871,7 @@ public: } }; -class DLL_EXPORT CGPickable : public CGObjectInstance //campfire, treasure chest, Flotsam, Shipwreck Survivor, Sea Chest +class DLL_LINKAGE CGPickable : public CGObjectInstance //campfire, treasure chest, Flotsam, Shipwreck Survivor, Sea Chest { public: ui32 type, val1, val2; @@ -891,7 +887,7 @@ public: } }; -class DLL_EXPORT CGShrine : public CPlayersVisited +class DLL_LINKAGE CGShrine : public CPlayersVisited { public: ui8 spell; //number of spell or 255 if random @@ -906,7 +902,7 @@ public: } }; -class DLL_EXPORT CGMine : public CArmedInstance +class DLL_LINKAGE CGMine : public CArmedInstance { public: ui8 producedResource; @@ -929,7 +925,7 @@ public: ui32 defaultResProduction(); }; -class DLL_EXPORT CGVisitableOPW : public CGObjectInstance //objects visitable OPW +class DLL_LINKAGE CGVisitableOPW : public CGObjectInstance //objects visitable OPW { public: ui8 visited; //true if object has been visited this week @@ -945,7 +941,7 @@ public: } }; -class DLL_EXPORT CGTeleport : public CGObjectInstance //teleports and subterranean gates +class DLL_LINKAGE CGTeleport : public CGObjectInstance //teleports and subterranean gates { public: static std::map > > objs; //teleports: map[ID][subID] => vector of ids @@ -961,7 +957,7 @@ public: } }; -class DLL_EXPORT CGBonusingObject : public CGObjectInstance //objects giving bonuses to luck/morale/movement +class DLL_LINKAGE CGBonusingObject : public CGObjectInstance //objects giving bonuses to luck/morale/movement { public: void onHeroVisit(const CGHeroInstance * h) const; @@ -974,7 +970,7 @@ public: } }; -class DLL_EXPORT CGMagicSpring : public CGVisitableOPW +class DLL_LINKAGE CGMagicSpring : public CGVisitableOPW {///unfortunatelly, this one is quite different than others public: void onHeroVisit(const CGHeroInstance * h) const; @@ -987,7 +983,7 @@ public: } }; -class DLL_EXPORT CGMagicWell : public CGObjectInstance //objects giving bonuses to luck/morale/movement +class DLL_LINKAGE CGMagicWell : public CGObjectInstance //objects giving bonuses to luck/morale/movement { public: void onHeroVisit(const CGHeroInstance * h) const; @@ -999,7 +995,7 @@ public: } }; -class DLL_EXPORT CGSirens : public CGObjectInstance +class DLL_LINKAGE CGSirens : public CGObjectInstance { public: void onHeroVisit(const CGHeroInstance * h) const; @@ -1012,7 +1008,7 @@ public: } }; -class DLL_EXPORT CGObservatory : public CGObjectInstance //Redwood observatory +class DLL_LINKAGE CGObservatory : public CGObjectInstance //Redwood observatory { public: void onHeroVisit(const CGHeroInstance * h) const; @@ -1024,7 +1020,7 @@ public: }; -class DLL_EXPORT CGKeys : public CGObjectInstance //Base class for Keymaster and guards +class DLL_LINKAGE CGKeys : public CGObjectInstance //Base class for Keymaster and guards { public: static std::map > playerKeyMap; //[players][keysowned] @@ -1038,7 +1034,7 @@ public: } }; -class DLL_EXPORT CGKeymasterTent : public CGKeys +class DLL_LINKAGE CGKeymasterTent : public CGKeys { public: void onHeroVisit(const CGHeroInstance * h) const; @@ -1050,7 +1046,7 @@ public: } }; -class DLL_EXPORT CGBorderGuard : public CGKeys +class DLL_LINKAGE CGBorderGuard : public CGKeys { public: void initObj(); @@ -1065,14 +1061,14 @@ public: } }; -class DLL_EXPORT CGBorderGate : public CGBorderGuard //not fully imlemented, waiting for garrison +class DLL_LINKAGE CGBorderGate : public CGBorderGuard //not fully imlemented, waiting for garrison { public: void onHeroVisit(const CGHeroInstance * h) const; ui8 getPassableness() const; }; -class DLL_EXPORT CGBoat : public CGObjectInstance +class DLL_LINKAGE CGBoat : public CGObjectInstance { public: ui8 direction; @@ -1091,7 +1087,7 @@ public: } }; -class DLL_EXPORT CGOnceVisitable : public CPlayersVisited +class DLL_LINKAGE CGOnceVisitable : public CPlayersVisited ///wagon, corpse, lean to, warriors tomb { public: @@ -1111,12 +1107,12 @@ public: } }; -class DLL_EXPORT CBank : public CArmedInstance +class DLL_LINKAGE CBank : public CArmedInstance { public: int index; //banks have unusal numbering - see ZCRBANK.txt and initObj() BankConfig *bc; - float multiplier; //for improved banks script + double multiplier; //for improved banks script std::vector artifacts; //fixed and deterministic ui32 daycounter; @@ -1136,7 +1132,7 @@ class DLL_EXPORT CBank : public CArmedInstance h & index & multiplier & artifacts & daycounter & bc; } }; -class DLL_EXPORT CGPyramid : public CBank +class DLL_LINKAGE CGPyramid : public CBank { public: ui16 spell; @@ -1162,7 +1158,7 @@ public: void onHeroVisit(const CGHeroInstance * h) const; }; -class DLL_EXPORT CGMagi : public CGObjectInstance +class DLL_LINKAGE CGMagi : public CGObjectInstance { public: static std::map > eyelist; //[subID][id], supports multiple sets as in H5 @@ -1178,7 +1174,7 @@ public: -class DLL_EXPORT CCartographer : public CPlayersVisited +class DLL_LINKAGE CCartographer : public CPlayersVisited { ///behaviour varies depending on surface and floor public: @@ -1191,12 +1187,12 @@ public: } }; -class DLL_EXPORT CGDenOfthieves : public CGObjectInstance +class DLL_LINKAGE CGDenOfthieves : public CGObjectInstance { void onHeroVisit (const CGHeroInstance * h) const; }; -class DLL_EXPORT CGObelisk : public CPlayersVisited +class DLL_LINKAGE CGObelisk : public CPlayersVisited { public: static ui8 obeliskCount; //how many obelisks are on map @@ -1213,7 +1209,7 @@ public: } }; -class DLL_EXPORT CGLighthouse : public CGObjectInstance +class DLL_LINKAGE CGLighthouse : public CGObjectInstance { public: void onHeroVisit(const CGHeroInstance * h) const; @@ -1227,16 +1223,16 @@ public: void giveBonusTo( ui8 player ) const; }; -class DLL_EXPORT CGMarket : public CGObjectInstance, public IMarket +class DLL_LINKAGE CGMarket : public CGObjectInstance, public IMarket { public: CGMarket(); void onHeroVisit(const CGHeroInstance * h) const; //open trading window int getMarketEfficiency() const; - bool allowsTrade(EMarketMode mode) const; - int availableUnits(EMarketMode mode, int marketItemSerial) const; //-1 if unlimited - std::vector availableItemsIds(EMarketMode mode) const; + bool allowsTrade(EMarketMode::EMarketMode mode) const; + int availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const; //-1 if unlimited + std::vector availableItemsIds(EMarketMode::EMarketMode mode) const; template void serialize(Handler &h, const int version) { @@ -1244,13 +1240,13 @@ public: } }; -class DLL_EXPORT CGBlackMarket : public CGMarket +class DLL_LINKAGE CGBlackMarket : public CGMarket { public: std::vector artifacts; //available artifacts void newTurn() const; //reset artifacts for black market every month - std::vector availableItemsIds(EMarketMode mode) const; + std::vector availableItemsIds(EMarketMode::EMarketMode mode) const; template void serialize(Handler &h, const int version) { @@ -1259,12 +1255,12 @@ public: } }; -class DLL_EXPORT CGUniversity : public CGMarket +class DLL_LINKAGE CGUniversity : public CGMarket { public: std::vector skills; //available skills - std::vector availableItemsIds(EMarketMode mode) const; + std::vector availableItemsIds(EMarketMode::EMarketMode mode) const; void initObj();//set skills for trade void onHeroVisit(const CGHeroInstance * h) const; //open window @@ -1296,7 +1292,7 @@ struct BankConfig } }; -class DLL_EXPORT CObjectHandler +class DLL_LINKAGE CObjectHandler { public: std::vector cregens; //type 17. dwelling subid -> creature ID @@ -1311,6 +1307,3 @@ public: h & cregens & banksInfo & creBanksNames & resVals; } }; - - -#endif // __COBJECTHANDLER_H__ diff --git a/lib/CObstacleInstance.h b/lib/CObstacleInstance.h index 0e99b237d..f80907245 100644 --- a/lib/CObstacleInstance.h +++ b/lib/CObstacleInstance.h @@ -1,6 +1,6 @@ #pragma once -struct DLL_EXPORT CObstacleInstance +struct DLL_LINKAGE CObstacleInstance { int uniqueID; int ID; //ID of obstacle (defines type of it) diff --git a/lib/CScriptingModule.h b/lib/CScriptingModule.h index 773505056..cfb6402cb 100644 --- a/lib/CScriptingModule.h +++ b/lib/CScriptingModule.h @@ -1,8 +1,19 @@ #pragma once -#include "../global.h" + + #include "IGameEventsReceiver.h" #include "IGameCallback.h" +/* + * CScriptingModule.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + class CScriptingModule : public IGameEventsReceiver, public IBattleEventsReceiver { public: diff --git a/lib/CSpellHandler.cpp b/lib/CSpellHandler.cpp index 435f1d578..e71ffad3f 100644 --- a/lib/CSpellHandler.cpp +++ b/lib/CSpellHandler.cpp @@ -1,14 +1,12 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "CSpellHandler.h" + + #include "CLodHandler.h" #include "../lib/VCMI_Lib.h" #include "../lib/JsonNode.h" -#include -#include -#include #include - +#include "GameConstants.h" extern CLodHandler *bitmaph; @@ -212,7 +210,7 @@ static bool startsWithX(const std::string &s) return s.size() && s[0] == 'x'; } -bool DLL_EXPORT isInScreenRange(const int3 ¢er, const int3 &pos) +bool DLL_LINKAGE isInScreenRange(const int3 ¢er, const int3 &pos) { int3 diff = pos - center; if(diff.x >= -9 && diff.x <= 9 && diff.y >= -8 && diff.y <= 8) @@ -298,7 +296,7 @@ void CSpellHandler::loadSpells() boost::replace_first (spells[47]->attributes, "2", ""); // disrupting ray will now affect single creature //loading of additional spell traits - const JsonNode config(DATA_DIR "/config/spell_info.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/spell_info.json"); BOOST_FOREACH(const JsonNode &spell, config["spells"].Vector()) { diff --git a/lib/CSpellHandler.h b/lib/CSpellHandler.h index ee280838e..f23964335 100644 --- a/lib/CSpellHandler.h +++ b/lib/CSpellHandler.h @@ -1,11 +1,8 @@ -#ifndef __CSPELLHANDLER_H__ -#define __CSPELLHANDLER_H__ - -#include -#include -#include +#pragma once #include "../lib/ConstTransitivePtr.h" +#include "int3.h" +#include "GameConstants.h" /* * CSpellHandler.h, part of VCMI engine @@ -17,7 +14,7 @@ * */ -class DLL_EXPORT CSpell +class DLL_LINKAGE CSpell { public: enum ETargetType {NO_TARGET, CREATURE, CREATURE_EXPERT_MASSIVE, OBSTACLE}; @@ -77,9 +74,9 @@ namespace Spells }; } -bool DLL_EXPORT isInScreenRange(const int3 ¢er, const int3 &pos); //for spells like Dimension Door +bool DLL_LINKAGE isInScreenRange(const int3 ¢er, const int3 &pos); //for spells like Dimension Door -class DLL_EXPORT CSpellHandler +class DLL_LINKAGE CSpellHandler { public: CSpellHandler(); @@ -93,6 +90,3 @@ public: h & spells & damageSpells & risingSpells; } }; - - -#endif // __CSPELLHANDLER_H__ diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 920e66f57..b256fbbf7 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -1,12 +1,11 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "CTownHandler.h" + #include "CLodHandler.h" -#include #include "../lib/VCMI_Lib.h" #include "CGeneralTextHandler.h" #include "../lib/JsonNode.h" -#include +#include "GameConstants.h" /* * CTownHandler.cpp, part of VCMI engine @@ -32,7 +31,7 @@ void CTownHandler::loadStructures() { int townID; - for (townID=0; townID &requires = requirements[townID][node["id"].Float()]; diff --git a/lib/CTownHandler.h b/lib/CTownHandler.h index 4aa9be0e6..2e560da68 100644 --- a/lib/CTownHandler.h +++ b/lib/CTownHandler.h @@ -1,7 +1,7 @@ -#ifndef __CTOWNHANDLER_H__ -#define __CTOWNHANDLER_H__ -#include "../global.h" -#include +#pragma once + + +#include "int3.h" /* * CTownHandler.h, part of VCMI engine @@ -17,7 +17,7 @@ class CBuilding; class CSpell; class CHero; class CGTownInstance; -class DLL_EXPORT CTown +class DLL_LINKAGE CTown { std::string name; //name of type public: @@ -44,7 +44,7 @@ public: } }; -struct DLL_EXPORT Structure +struct DLL_LINKAGE Structure { int ID; int3 pos; @@ -60,7 +60,7 @@ struct DLL_EXPORT Structure } }; -class DLL_EXPORT CTownHandler +class DLL_LINKAGE CTownHandler { public: std::vector towns; @@ -78,6 +78,3 @@ public: loadStructures(); } }; - - -#endif // __CTOWNHANDLER_H__ diff --git a/lib/CondSh.h b/lib/CondSh.h index 227b02da1..73189e3e7 100644 --- a/lib/CondSh.h +++ b/lib/CondSh.h @@ -1,6 +1,4 @@ -#ifndef __CONDSH_H__ -#define __CONDSH_H__ -#include +#pragma once /* * CondSh.h, part of VCMI engine @@ -69,4 +67,3 @@ template struct CondSh cond.wait(un); } }; -#endif // __CONDSH_H__ diff --git a/lib/Connection.cpp b/lib/Connection.cpp index be39255c4..6257d14b2 100644 --- a/lib/Connection.cpp +++ b/lib/Connection.cpp @@ -1,17 +1,13 @@ -#define VCMI_DLL -#pragma warning(disable:4355) +#include "StdInc.h" #include "Connection.h" -#include -#include -#include #ifndef _MSC_VER -#include "../lib/RegisterTypes.cpp" +#include "../lib/RegisterTypes.h" #endif //for smart objs serialization over net #include "../lib/CMapInfo.h" -#include "../StartInfo.h" +#include "StartInfo.h" #include "BattleState.h" #include "CGameState.h" #include "map.h" @@ -25,6 +21,7 @@ #include "CCampaignHandler.h" #include "NetPacks.h" +#include /* * Connection.cpp, part of VCMI engine @@ -38,7 +35,7 @@ using namespace boost; using namespace boost::asio::ip; -template DLL_EXPORT void registerTypes(Serializer &s); //defined elsewhere and explicitly instantiated for used serializers +template DLL_LINKAGE void registerTypes(Serializer &s); //defined elsewhere and explicitly instantiated for used serializers CTypeList typeList; diff --git a/lib/Connection.h b/lib/Connection.h index b7b00148b..a22087bcf 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -1,12 +1,7 @@ -#ifndef __CONNECTION_H__ -#define __CONNECTION_H__ -#include "../global.h" -#include -#include -#include -#include +#pragma once + + #include //XXX this is in namespace std if you want w/o use typeinfo.h? -#include #include #include @@ -16,7 +11,6 @@ #include #include #include -#include #include #include @@ -34,7 +28,7 @@ class CCreature; class LibClasses; class CHero; struct CPack; -extern DLL_EXPORT LibClasses * VLC; +extern DLL_LINKAGE LibClasses * VLC; namespace mpl = boost::mpl; /* @@ -86,7 +80,7 @@ struct TypeComparer } }; -class DLL_EXPORT CTypeList +class DLL_LINKAGE CTypeList { typedef std::multimap TTypeMap; TTypeMap types; @@ -114,7 +108,7 @@ public: } }; -extern DLL_EXPORT CTypeList typeList; +extern DLL_LINKAGE CTypeList typeList; template struct SavePrimitive @@ -245,7 +239,7 @@ struct VectorisedObjectInfo }; /// Class which is responsible for storing and loading data. -class DLL_EXPORT CSerializer +class DLL_LINKAGE CSerializer { public: typedef std::map TTypeVecMap; @@ -314,7 +308,7 @@ public: void addStdVecItems(CGameState *gs, LibClasses *lib = VLC); }; -class DLL_EXPORT CSaverBase : public virtual CSerializer +class DLL_LINKAGE CSaverBase : public virtual CSerializer { }; @@ -351,7 +345,7 @@ struct VectorisedTypeFor }; /// The class which manages saving objects. -template class DLL_EXPORT COSer : public CSaverBase +template class DLL_LINKAGE COSer : public CSaverBase { public: bool saving; @@ -509,7 +503,7 @@ public: template void saveSerializable(const std::vector &data) { - boost::uint32_t length = data.size(); + ui32 length = data.size(); *this << length; for(ui32 i=0;i &data) { std::set &d = const_cast &>(data); - boost::uint32_t length = d.size(); + ui32 length = d.size(); *this << length; for(typename std::set::iterator i=d.begin();i!=d.end();i++) *this << *i; @@ -527,7 +521,7 @@ public: void saveSerializable(const boost::unordered_set &data) { boost::unordered_set &d = const_cast &>(data); - boost::uint32_t length = d.size(); + ui32 length = d.size(); *this << length; for(typename boost::unordered_set::iterator i=d.begin();i!=d.end();i++) *this << *i; @@ -536,7 +530,7 @@ public: void saveSerializable(const std::list &data) { std::list &d = const_cast &>(data); - boost::uint32_t length = d.size(); + ui32 length = d.size(); *this << length; for(typename std::list::iterator i=d.begin();i!=d.end();i++) *this << *i; @@ -562,7 +556,7 @@ public: -class DLL_EXPORT CLoaderBase : public virtual CSerializer +class DLL_LINKAGE CLoaderBase : public virtual CSerializer {}; class CBasicPointerLoader @@ -590,7 +584,7 @@ public: }; /// The class which manages loading of objects. -template class DLL_EXPORT CISer : public CLoaderBase +template class DLL_LINKAGE CISer : public CLoaderBase { public: bool saving; @@ -682,7 +676,7 @@ public: void loadArray(T &data) { ui32 size = ARRAY_COUNT(data); - for(ui32 i=0; i < size; i++) + for(ui32 i = 0; i < size; i++) *this >> data[i]; } template @@ -758,7 +752,7 @@ public: } #define READ_CHECK_U32(x) \ - boost::uint32_t length; \ + ui32 length; \ *this >> length; \ if(length > 50000) \ { \ @@ -842,7 +836,7 @@ public: }; -class DLL_EXPORT CSaveFile +class DLL_LINKAGE CSaveFile : public COSer { void dummyMagicFunction() @@ -862,7 +856,7 @@ public: void reportState(CLogger &out); }; -class DLL_EXPORT CLoadFile +class DLL_LINKAGE CLoadFile : public CISer { void dummyMagicFunction() @@ -886,7 +880,7 @@ public: typedef boost::asio::basic_stream_socket < boost::asio::ip::tcp , boost::asio::stream_socket_service > TSocket; typedef boost::asio::basic_socket_acceptor > TAcceptor; -class DLL_EXPORT CConnection +class DLL_LINKAGE CConnection :public CISer, public COSer { //CGameState *gs; @@ -925,7 +919,7 @@ public: void sendPack(const CPack &pack); }; -DLL_EXPORT std::ostream &operator<<(std::ostream &str, const CConnection &cpc); +DLL_LINKAGE std::ostream &operator<<(std::ostream &str, const CConnection &cpc); template class CApplier @@ -947,6 +941,3 @@ public: } }; - - -#endif // __CONNECTION_H__ diff --git a/lib/ConstTransitivePtr.h b/lib/ConstTransitivePtr.h index ccaf8b9a4..b1347bf35 100644 --- a/lib/ConstTransitivePtr.h +++ b/lib/ConstTransitivePtr.h @@ -2,6 +2,16 @@ class CGameHandler; +/* + * ConstTransitivePtr.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + template class ConstTransitivePtr { diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index ea1f93ff0..9e5dd36ab 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -1,26 +1,22 @@ -#define VCMI_DLL +#include "StdInc.h" #include "HeroBonus.h" -#include + #include "VCMI_Lib.h" #include "CSpellHandler.h" -#include #include "CCreatureHandler.h" -#include #include "CCreatureSet.h" -#include -#include #include "CHeroHandler.h" #include "CGeneralTextHandler.h" #include "BattleState.h" #include "CArtHandler.h" -#include +#include "GameConstants.h" #define FOREACH_PARENT(pname) TNodes lparents; getParents(lparents); BOOST_FOREACH(CBonusSystemNode *pname, lparents) #define FOREACH_RED_CHILD(pname) TNodes lchildren; getRedChildren(lchildren); BOOST_FOREACH(CBonusSystemNode *pname, lchildren) #define FOREACH_RED_PARENT(pname) TNodes lparents; getRedParents(lparents); BOOST_FOREACH(CBonusSystemNode *pname, lparents) #define BONUS_NAME(x) ( #x, Bonus::x ) - DLL_EXPORT const std::map bonusNameMap = boost::assign::map_list_of BONUS_LIST; + DLL_LINKAGE const std::map bonusNameMap = boost::assign::map_list_of BONUS_LIST; #undef BONUS_NAME #define BONUS_LOG_LINE(x) tlog5 << x << std::endl @@ -85,7 +81,7 @@ int BonusList::totalValue() const } else { - amax(indepMax, b->val); + vstd::amax(indepMax, b->val); } break; @@ -97,7 +93,7 @@ int BonusList::totalValue() const } else { - amin(indepMin, b->val); + vstd::amin(indepMin, b->val); } break; @@ -110,15 +106,15 @@ int BonusList::totalValue() const if(hasIndepMin && hasIndepMax) assert(indepMin < indepMax); if (hasIndepMax) - amax(valFirst, indepMax); + vstd::amax(valFirst, indepMax); if (hasIndepMin) - amin(valFirst, indepMin); + vstd::amin(valFirst, indepMin); return valFirst; } const Bonus * BonusList::getFirst(const CSelector &selector) const { - for (unsigned int i = 0; i < bonuses.size(); i++) + for (ui32 i = 0; i < bonuses.size(); i++) { const Bonus *b = bonuses[i]; if(selector(b)) @@ -129,7 +125,7 @@ const Bonus * BonusList::getFirst(const CSelector &selector) const Bonus * BonusList::getFirst(const CSelector &select) { - for (unsigned int i = 0; i < bonuses.size(); i++) + for (ui32 i = 0; i < bonuses.size(); i++) { Bonus *b = bonuses[i]; if(select(b)) @@ -158,7 +154,7 @@ void BonusList::getBonuses(TBonusListPtr out, const CSelector &selector) const void BonusList::getBonuses(TBonusListPtr out, const CSelector &selector, const CSelector &limit, const bool caching /*= false*/) const { - for (unsigned int i = 0; i < bonuses.size(); i++) + for (ui32 i = 0; i < bonuses.size(); i++) { Bonus *b = bonuses[i]; @@ -329,9 +325,9 @@ int IBonusBearer::MoraleVal() const int ret = valOfBonuses(Bonus::MORALE); if(hasBonusOfType(Bonus::SELF_MORALE)) //eg. minotaur - amax(ret, +1); + vstd::amax(ret, +1); - return abetw(ret, -3, +3); + return vstd::abetween(ret, -3, +3); } int IBonusBearer::LuckVal() const @@ -342,9 +338,9 @@ int IBonusBearer::LuckVal() const int ret = valOfBonuses(Bonus::LUCK); if(hasBonusOfType(Bonus::SELF_LUCK)) //eg. halfling - amax(ret, +1); + vstd::amax(ret, +1); - return abetw(ret, -3, +3); + return vstd::abetween(ret, -3, +3); } si32 IBonusBearer::Attack() const @@ -355,7 +351,7 @@ si32 IBonusBearer::Attack() const { ret += frenzyPower * Defense(false); } - amax(ret, 0); + vstd::amax(ret, 0); return ret; } @@ -368,7 +364,7 @@ si32 IBonusBearer::Defense(bool withFrenzy /*= true*/) const { return 0; } - amax(ret, 0); + vstd::amax(ret, 0); return ret; } @@ -393,7 +389,7 @@ ui32 IBonusBearer::getMaxDamage() const si32 IBonusBearer::manaLimit() const { - return si32(getPrimSkillLevel(3) * (100.0f + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, 24)) / 10.0f); + return si32(getPrimSkillLevel(3) * (100.0 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, 24)) / 10.0); } int IBonusBearer::getPrimSkillLevel(int id) const @@ -406,7 +402,7 @@ int IBonusBearer::getPrimSkillLevel(int id) const else ret = valOfBonuses(Bonus::PRIMARY_SKILL, id); - amax(ret, id/2); //minimal value is 0 for attack and defense and 1 for spell power and knowledge + vstd::amax(ret, id/2); //minimal value is 0 for attack and defense and 1 for spell power and knowledge return ret; } @@ -452,7 +448,7 @@ const Bonus * CBonusSystemNode::getBonus( const CSelector &selector ) const void CBonusSystemNode::getParents(TCNodes &out) const /*retreives list of parent nodes (nodes to inherit bonuses from) */ { - for (unsigned int i = 0; i < parents.size(); i++) + for (ui32 i = 0; i < parents.size(); i++) { const CBonusSystemNode *parent = parents[i]; out.insert(parent); @@ -461,7 +457,7 @@ void CBonusSystemNode::getParents(TCNodes &out) const /*retreives list of parent void CBonusSystemNode::getParents(TNodes &out) { - for (unsigned int i = 0; i < parents.size(); i++) + for (ui32 i = 0; i < parents.size(); i++) { const CBonusSystemNode *parent = parents[i]; out.insert(const_cast(parent)); @@ -618,7 +614,7 @@ void CBonusSystemNode::removeBonus(Bonus *b) unpropagateBonus(b); else bonuses -= b; - delNull(b); + vstd::clear_pointer(b); CBonusSystemNode::treeChanged++; } @@ -777,7 +773,7 @@ void CBonusSystemNode::getRedDescendants(TNodes &out) void CBonusSystemNode::battleTurnPassed() { BonusList bonusesCpy = exportedBonuses; //copy, because removing bonuses invalidates iters - for (unsigned int i = 0; i < bonusesCpy.size(); i++) + for (ui32 i = 0; i < bonusesCpy.size(); i++) { Bonus *b = bonusesCpy[i]; @@ -970,36 +966,36 @@ Bonus * Bonus::addPropagator(boost::shared_ptr Propagator) return this; } -CSelector DLL_EXPORT operator&&(const CSelector &first, const CSelector &second) +CSelector DLL_LINKAGE operator&&(const CSelector &first, const CSelector &second) { return CSelectorsConjunction(first, second); } -CSelector DLL_EXPORT operator||(const CSelector &first, const CSelector &second) +CSelector DLL_LINKAGE operator||(const CSelector &first, const CSelector &second) { return CSelectorsAlternative(first, second); } namespace Selector { - DLL_EXPORT CSelectFieldEqual type(&Bonus::type, 0); - DLL_EXPORT CSelectFieldEqual subtype(&Bonus::subtype, 0); - DLL_EXPORT CSelectFieldEqual info(&Bonus::additionalInfo, 0); - DLL_EXPORT CSelectFieldEqual duration(&Bonus::duration, 0); - DLL_EXPORT CSelectFieldEqual sourceType(&Bonus::source, 0); - DLL_EXPORT CSelectFieldEqual effectRange(&Bonus::effectRange, Bonus::NO_LIMIT); - DLL_EXPORT CWillLastTurns turns; + DLL_LINKAGE CSelectFieldEqual type(&Bonus::type, 0); + DLL_LINKAGE CSelectFieldEqual subtype(&Bonus::subtype, 0); + DLL_LINKAGE CSelectFieldEqual info(&Bonus::additionalInfo, 0); + DLL_LINKAGE CSelectFieldEqual duration(&Bonus::duration, 0); + DLL_LINKAGE CSelectFieldEqual sourceType(&Bonus::source, 0); + DLL_LINKAGE CSelectFieldEqual effectRange(&Bonus::effectRange, Bonus::NO_LIMIT); + DLL_LINKAGE CWillLastTurns turns; - CSelector DLL_EXPORT typeSubtype(TBonusType Type, TBonusSubtype Subtype) + CSelector DLL_LINKAGE typeSubtype(TBonusType Type, TBonusSubtype Subtype) { return type(Type) && subtype(Subtype); } - CSelector DLL_EXPORT typeSubtypeInfo(TBonusType type, TBonusSubtype subtype, si32 info) + CSelector DLL_LINKAGE typeSubtypeInfo(TBonusType type, TBonusSubtype subtype, si32 info) { return CSelectFieldEqual(&Bonus::type, type) && CSelectFieldEqual(&Bonus::subtype, subtype) && CSelectFieldEqual(&Bonus::additionalInfo, info); } - CSelector DLL_EXPORT source(ui8 source, ui32 sourceID) + CSelector DLL_LINKAGE source(ui8 source, ui32 sourceID) { return CSelectFieldEqual(&Bonus::source, source) && CSelectFieldEqual(&Bonus::sid, sourceID); } @@ -1009,19 +1005,19 @@ namespace Selector return CSelectFieldEqual(&Bonus::duration, duration); } - CSelector DLL_EXPORT sourceTypeSel(ui8 source) + CSelector DLL_LINKAGE sourceTypeSel(ui8 source) { return CSelectFieldEqual(&Bonus::source, source); } - bool DLL_EXPORT matchesType(const CSelector &sel, TBonusType type) + bool DLL_LINKAGE matchesType(const CSelector &sel, TBonusType type) { Bonus dummy; dummy.type = type; return sel(&dummy); } - bool DLL_EXPORT matchesTypeSubtype(const CSelector &sel, TBonusType type, TBonusSubtype subtype) + bool DLL_LINKAGE matchesTypeSubtype(const CSelector &sel, TBonusType type, TBonusSubtype subtype) { Bonus dummy; dummy.type = type; @@ -1029,7 +1025,7 @@ namespace Selector return sel(&dummy); } - bool DLL_EXPORT positiveSpellEffects(const Bonus *b) + bool DLL_LINKAGE positiveSpellEffects(const Bonus *b) { if(b->source == Bonus::SPELL_EFFECT) { @@ -1078,9 +1074,9 @@ const CCreature * retrieveCreature(const CBonusSystemNode *node) } } -DLL_EXPORT std::ostream & operator<<(std::ostream &out, const BonusList &bonusList) +DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const BonusList &bonusList) { - for (unsigned int i = 0; i < bonusList.size(); i++) + for (ui32 i = 0; i < bonusList.size(); i++) { Bonus *b = bonusList[i]; out << "Bonus " << i << "\n" << *b << std::endl; @@ -1088,7 +1084,7 @@ DLL_EXPORT std::ostream & operator<<(std::ostream &out, const BonusList &bonusLi return out; } -DLL_EXPORT std::ostream & operator<<(std::ostream &out, const Bonus &bonus) +DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const Bonus &bonus) { for(std::map::const_iterator i = bonusNameMap.begin(); i != bonusNameMap.end(); i++) if(i->second == bonus.type) @@ -1208,7 +1204,7 @@ CreatureNativeTerrainLimiter::CreatureNativeTerrainLimiter() bool CreatureNativeTerrainLimiter::limit(const Bonus *b, const CBonusSystemNode &node) const { const CCreature *c = retrieveCreature(&node); - return !c || !iswith(c->faction, 0, 9) || VLC->heroh->nativeTerrains[c->faction] != terrainType; //drop bonus for non-creatures or non-native residents + return !c || !vstd::iswithin(c->faction, 0, 9) || VLC->heroh->nativeTerrains[c->faction] != terrainType; //drop bonus for non-creatures or non-native residents //TODO neutral creatues } @@ -1242,11 +1238,11 @@ bool CreatureAlignmentLimiter::limit(const Bonus *b, const CBonusSystemNode &nod return true; switch(alignment) { - case GOOD: + case EAlignment::GOOD: return !c->isGood(); //if not good -> return true (drop bonus) - case NEUTRAL: + case EAlignment::NEUTRAL: return c->isEvil() || c->isGood(); - case EVIL: + case EAlignment::EVIL: return !c->isEvil(); default: tlog1 << "Warning: illegal alignment in limiter!\n"; diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index 8d5d9dd39..34126a45e 100644 --- a/lib/HeroBonus.h +++ b/lib/HeroBonus.h @@ -1,11 +1,8 @@ #pragma once -#include "../global.h" -#include -#include -#include -#include + + #include -#include +#include "GameConstants.h" /* * HeroBonus.h, part of VCMI engine @@ -37,6 +34,8 @@ namespace PrimarySkill enum { ATTACK, DEFENSE, SPELL_POWER, KNOWLEDGE}; } +#define BONUS_TREE_DESERIALIZATION_FIX if(!h.saving && h.smartPointerSerialization) deserializationFix(); + #define BONUS_LIST \ BONUS_NAME(NONE) \ BONUS_NAME(MOVEMENT) /*both water/land*/ \ @@ -175,7 +174,7 @@ namespace PrimarySkill BONUS_NAME(REBIRTH) /* val - percent of life restored, subtype = 0 - regular, 1 - at least one unit (sacred Phoenix) */ /// Struct for handling bonuses of several types. Can be transferred to any hero -struct DLL_EXPORT Bonus +struct DLL_LINKAGE Bonus { enum BonusType { @@ -327,10 +326,10 @@ struct DLL_EXPORT Bonus Bonus *addPropagator(boost::shared_ptr Propagator); //returns this for convenient chain-calls }; -DLL_EXPORT std::ostream & operator<<(std::ostream &out, const Bonus &bonus); +DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const Bonus &bonus); -class DLL_EXPORT BonusList +class DLL_LINKAGE BonusList { private: std::vector bonuses; @@ -380,7 +379,7 @@ public: void remove_if(Predicate pred) { BonusList newList; - for (unsigned int i = 0; i < bonuses.size(); i++) + for (ui32 i = 0; i < bonuses.size(); i++) { Bonus *b = bonuses[i]; if (!pred(b)) @@ -426,9 +425,9 @@ inline std::vector::const_iterator range_end(BonusList const &x) return x.end(); } -DLL_EXPORT std::ostream & operator<<(std::ostream &out, const BonusList &bonusList); +DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const BonusList &bonusList); -class DLL_EXPORT IPropagator +class DLL_LINKAGE IPropagator { public: virtual ~IPropagator(); @@ -439,7 +438,7 @@ public: {} }; -class DLL_EXPORT CPropagatorNodeType : public IPropagator +class DLL_LINKAGE CPropagatorNodeType : public IPropagator { ui8 nodeType; public: @@ -454,7 +453,7 @@ public: } }; -class DLL_EXPORT ILimiter +class DLL_LINKAGE ILimiter { public: virtual ~ILimiter(); @@ -465,7 +464,7 @@ public: {} }; -class DLL_EXPORT IBonusBearer +class DLL_LINKAGE IBonusBearer { public: //new bonusing node interface @@ -504,7 +503,7 @@ public: const TBonusListPtr getSpellBonuses() const; }; -class DLL_EXPORT CBonusSystemNode : public IBonusBearer +class DLL_LINKAGE CBonusSystemNode : public IBonusBearer { private: BonusList bonuses; //wielded bonuses (local or up-propagated here) @@ -600,11 +599,11 @@ public: namespace NBonus { //set of methods that may be safely called with NULL objs - DLL_EXPORT int valOf(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype = -1); //subtype -> subtype of bonus, if -1 then any - DLL_EXPORT bool hasOfType(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype = -1);//determines if hero has a bonus of given type (and optionally subtype) - //DLL_EXPORT const HeroBonus * get(const CBonusSystemNode *obj, int from, int id ); - DLL_EXPORT void getModifiersWDescr(const CBonusSystemNode *obj, TModDescr &out, Bonus::BonusType type, int subtype = -1 ); //out: pairs - DLL_EXPORT int getCount(const CBonusSystemNode *obj, int from, int id); + DLL_LINKAGE int valOf(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype = -1); //subtype -> subtype of bonus, if -1 then any + DLL_LINKAGE bool hasOfType(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype = -1);//determines if hero has a bonus of given type (and optionally subtype) + //DLL_LINKAGE const HeroBonus * get(const CBonusSystemNode *obj, int from, int id ); + DLL_LINKAGE void getModifiersWDescr(const CBonusSystemNode *obj, TModDescr &out, Bonus::BonusType type, int subtype = -1 ); //out: pairs + DLL_LINKAGE int getCount(const CBonusSystemNode *obj, int from, int id); }; /// generates HeroBonus from given data @@ -629,7 +628,7 @@ inline Bonus * makeFeature(Bonus::BonusType type, ui8 duration, si16 subtype, si } -class DLL_EXPORT CSelectorsConjunction +class DLL_LINKAGE CSelectorsConjunction { const CSelector first, second; public: @@ -642,9 +641,9 @@ public: return first(bonus) && second(bonus); } }; -CSelector DLL_EXPORT operator&&(const CSelector &first, const CSelector &second); +CSelector DLL_LINKAGE operator&&(const CSelector &first, const CSelector &second); -class DLL_EXPORT CSelectorsAlternative +class DLL_LINKAGE CSelectorsAlternative { const CSelector first, second; public: @@ -657,7 +656,7 @@ public: return first(bonus) || second(bonus); } }; -CSelector DLL_EXPORT operator||(const CSelector &first, const CSelector &second); +CSelector DLL_LINKAGE operator||(const CSelector &first, const CSelector &second); template class CSelectFieldEqual @@ -680,7 +679,7 @@ public: } }; -class DLL_EXPORT CWillLastTurns +class DLL_LINKAGE CWillLastTurns { public: int turnsRequested; @@ -698,7 +697,7 @@ public: } }; -class DLL_EXPORT CCreatureTypeLimiter : public ILimiter //affect only stacks of given creature (and optionally it's upgrades) +class DLL_LINKAGE CCreatureTypeLimiter : public ILimiter //affect only stacks of given creature (and optionally it's upgrades) { public: const CCreature *creature; @@ -715,7 +714,7 @@ public: } }; -class DLL_EXPORT HasAnotherBonusLimiter : public ILimiter //applies only to nodes that have another bonus working +class DLL_LINKAGE HasAnotherBonusLimiter : public ILimiter //applies only to nodes that have another bonus working { public: TBonusType type; @@ -733,7 +732,7 @@ public: } }; -class DLL_EXPORT CreatureNativeTerrainLimiter : public ILimiter //applies only to creatures that are on their native terrain +class DLL_LINKAGE CreatureNativeTerrainLimiter : public ILimiter //applies only to creatures that are on their native terrain { public: si8 terrainType; @@ -748,7 +747,7 @@ public: } }; -class DLL_EXPORT CreatureFactionLimiter : public ILimiter //applies only to creatures of given faction +class DLL_LINKAGE CreatureFactionLimiter : public ILimiter //applies only to creatures of given faction { public: si8 faction; @@ -763,7 +762,7 @@ public: } }; -class DLL_EXPORT CreatureAlignmentLimiter : public ILimiter //applies only to creatures of given alignment +class DLL_LINKAGE CreatureAlignmentLimiter : public ILimiter //applies only to creatures of given alignment { public: si8 alignment; @@ -778,7 +777,7 @@ public: } }; -class DLL_EXPORT StackOwnerLimiter : public ILimiter //applies only to creatures of given alignment +class DLL_LINKAGE StackOwnerLimiter : public ILimiter //applies only to creatures of given alignment { public: ui8 owner; @@ -793,7 +792,7 @@ public: } }; -class DLL_EXPORT RankRangeLimiter : public ILimiter //applies to creatures with min <= Rank <= max +class DLL_LINKAGE RankRangeLimiter : public ILimiter //applies to creatures with min <= Rank <= max { public: ui8 minRank, maxRank; @@ -812,26 +811,26 @@ const CCreature *retrieveCreature(const CBonusSystemNode *node); namespace Selector { - extern DLL_EXPORT CSelectFieldEqual type; - extern DLL_EXPORT CSelectFieldEqual subtype; - extern DLL_EXPORT CSelectFieldEqual info; - extern DLL_EXPORT CSelectFieldEqual duration; - extern DLL_EXPORT CSelectFieldEqual sourceType; - extern DLL_EXPORT CSelectFieldEqual effectRange; - extern DLL_EXPORT CWillLastTurns turns; + extern DLL_LINKAGE CSelectFieldEqual type; + extern DLL_LINKAGE CSelectFieldEqual subtype; + extern DLL_LINKAGE CSelectFieldEqual info; + extern DLL_LINKAGE CSelectFieldEqual duration; + extern DLL_LINKAGE CSelectFieldEqual sourceType; + extern DLL_LINKAGE CSelectFieldEqual effectRange; + extern DLL_LINKAGE CWillLastTurns turns; - CSelector DLL_EXPORT typeSubtype(TBonusType Type, TBonusSubtype Subtype); - CSelector DLL_EXPORT typeSubtypeInfo(TBonusType type, TBonusSubtype subtype, si32 info); - CSelector DLL_EXPORT source(ui8 source, ui32 sourceID); - CSelector DLL_EXPORT durationType(ui16 duration); - CSelector DLL_EXPORT sourceTypeSel(ui8 source); + CSelector DLL_LINKAGE typeSubtype(TBonusType Type, TBonusSubtype Subtype); + CSelector DLL_LINKAGE typeSubtypeInfo(TBonusType type, TBonusSubtype subtype, si32 info); + CSelector DLL_LINKAGE source(ui8 source, ui32 sourceID); + CSelector DLL_LINKAGE durationType(ui16 duration); + CSelector DLL_LINKAGE sourceTypeSel(ui8 source); - bool DLL_EXPORT matchesType(const CSelector &sel, TBonusType type); - bool DLL_EXPORT matchesTypeSubtype(const CSelector &sel, TBonusType type, TBonusSubtype subtype); - bool DLL_EXPORT positiveSpellEffects(const Bonus *b); + bool DLL_LINKAGE matchesType(const CSelector &sel, TBonusType type); + bool DLL_LINKAGE matchesTypeSubtype(const CSelector &sel, TBonusType type, TBonusSubtype subtype); + bool DLL_LINKAGE positiveSpellEffects(const Bonus *b); } -extern DLL_EXPORT const std::map bonusNameMap; +extern DLL_LINKAGE const std::map bonusNameMap; // BonusList template that requires full interface of CBonusSystemNode template diff --git a/lib/IGameCallback.cpp b/lib/IGameCallback.cpp index d1e453635..b915e3410 100644 --- a/lib/IGameCallback.cpp +++ b/lib/IGameCallback.cpp @@ -1,20 +1,20 @@ -#define VCMI_DLL +#include "StdInc.h" #include "IGameCallback.h" + #include "../lib/CGameState.h" #include "../lib/map.h" #include "CObjectHandler.h" #include "CHeroHandler.h" -#include "../StartInfo.h" +#include "StartInfo.h" #include "CArtHandler.h" #include "CSpellHandler.h" #include "../lib/VCMI_Lib.h" #include #include "CTownHandler.h" #include "BattleState.h" -#include #include "NetPacks.h" -#include #include "CBuildingHandler.h" +#include "GameConstants.h" /* * IGameCallback.cpp, part of VCMI engine @@ -39,35 +39,35 @@ boost::shared_mutex& CCallbackBase::getGsMutex() return *gs->mx; } -si8 CBattleInfoCallback::battleHasDistancePenalty( const CStack * stack, THex destHex ) +si8 CBattleInfoCallback::battleHasDistancePenalty( const CStack * stack, SHexField destHex ) { return gs->curB->hasDistancePenalty(stack, destHex); } -si8 CBattleInfoCallback::battleHasWallPenalty( const CStack * stack, THex destHex ) +si8 CBattleInfoCallback::battleHasWallPenalty( const CStack * stack, SHexField destHex ) { return gs->curB->hasWallPenalty(stack, destHex); } -si8 CBattleInfoCallback::battleCanTeleportTo(const CStack * stack, THex destHex, int telportLevel) +si8 CBattleInfoCallback::battleCanTeleportTo(const CStack * stack, SHexField destHex, int telportLevel) { return gs->curB->canTeleportTo(stack, destHex, telportLevel); } -std::vector CBattleInfoCallback::battleGetDistances(const CStack * stack, THex hex /*= THex::INVALID*/, THex * predecessors /*= NULL*/) +std::vector CBattleInfoCallback::battleGetDistances(const CStack * stack, SHexField hex /*= SHexField::INVALID*/, SHexField * predecessors /*= NULL*/) { if(!hex.isValid()) hex = stack->position; std::vector ret; - bool ac[BFIELD_SIZE] = {0}; - std::set occupyable; + bool ac[GameConstants::BFIELD_SIZE] = {0}; + std::set occupyable; gs->curB->getAccessibilityMap(ac, stack->doubleWide(), stack->attackerOwned, false, occupyable, stack->hasBonusOfType(Bonus::FLYING), stack); - THex pr[BFIELD_SIZE]; - int dist[BFIELD_SIZE]; + SHexField pr[GameConstants::BFIELD_SIZE]; + int dist[GameConstants::BFIELD_SIZE]; gs->curB->makeBFS(stack->position, ac, pr, dist, stack->doubleWide(), stack->attackerOwned, stack->hasBonusOfType(Bonus::FLYING), false); - for(int i=0; i CBattleInfoCallback::battleGetDistances(const CStack * stack, T if(predecessors) { - memcpy(predecessors, pr, BFIELD_SIZE * sizeof(THex)); + memcpy(predecessors, pr, GameConstants::BFIELD_SIZE * sizeof(SHexField)); } return ret; } -std::set CBattleInfoCallback::battleGetAttackedHexes(const CStack* attacker, THex destinationTile, THex attackerPos /*= THex::INVALID*/) +std::set CBattleInfoCallback::battleGetAttackedHexes(const CStack* attacker, SHexField destinationTile, SHexField attackerPos /*= SHexField::INVALID*/) { if(!gs->curB) { tlog1 << "battleGetAttackedHexes called when there is no battle!\n"; - std::set set; + std::set set; return set; } return gs->curB->getAttackedHexes(attacker, destinationTile, attackerPos); } -SpellCasting::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell( const CSpell * spell ) +ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell( const CSpell * spell ) { if(!gs->curB) { tlog1 << "battleCanCastThisSpell called when there is no battle!\n"; - return SpellCasting::NO_HERO_TO_CAST_SPELL; + return ESpellCastProblem::NO_HERO_TO_CAST_SPELL; } - return gs->curB->battleCanCastThisSpell(player, spell, SpellCasting::HERO_CASTING); + return gs->curB->battleCanCastThisSpell(player, spell, ECastingMode::HERO_CASTING); } -SpellCasting::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell(const CSpell * spell, THex destination) +ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell(const CSpell * spell, SHexField destination) { if(!gs->curB) { tlog1 << "battleCanCastThisSpell called when there is no battle!\n"; - return SpellCasting::NO_HERO_TO_CAST_SPELL; + return ESpellCastProblem::NO_HERO_TO_CAST_SPELL; } - return gs->curB->battleCanCastThisSpellHere(player, spell, SpellCasting::CREATURE_ACTIVE_CASTING, destination); + return gs->curB->battleCanCastThisSpellHere(player, spell, ECastingMode::CREATURE_ACTIVE_CASTING, destination); } TSpell CBattleInfoCallback::battleGetRandomStackSpell(const CStack * stack, ERandomSpell mode) @@ -185,7 +185,7 @@ int CBattleInfoCallback::battleGetBattlefieldType() return gs->curB->battlefieldType; } -int CBattleInfoCallback::battleGetObstaclesAtTile(THex tile) //returns bitfield +int CBattleInfoCallback::battleGetObstaclesAtTile(SHexField tile) //returns bitfield { //TODO - write return -1; @@ -207,26 +207,26 @@ const CStack* CBattleInfoCallback::battleGetStackByID(int ID, bool onlyAlive) return gs->curB->getStack(ID, onlyAlive); } -const CStack* CBattleInfoCallback::battleGetStackByPos(THex pos, bool onlyAlive) +const CStack* CBattleInfoCallback::battleGetStackByPos(SHexField pos, bool onlyAlive) { //boost::shared_lock lock(*gs->mx); return gs->curB->battleGetStack(pos, onlyAlive); } -THex CBattleInfoCallback::battleGetPos(int stack) +SHexField CBattleInfoCallback::battleGetPos(int stack) { //boost::shared_lock lock(*gs->mx); if(!gs->curB) { tlog2<<"battleGetPos called when there is no battle!"<curB->stacks.size(); ++g) { if(gs->curB->stacks[g]->ID == stack) return gs->curB->stacks[g]->position; } - return THex::INVALID; + return SHexField::INVALID; } TStacks CBattleInfoCallback::battleGetStacks(EStackOwnership whose /*= MINE_AND_ENEMY*/, bool onlyAlive /*= true*/) @@ -265,27 +265,27 @@ void CBattleInfoCallback::battleGetStackCountOutsideHexes(bool *ac) if(!gs->curB) { tlog2<<"battleGetAvailableHexes called when there is no battle!"< ignored; + std::set ignored; gs->curB->getAccessibilityMap(ac, false /*ignored*/, false, false, ignored, false /*ignored*/, NULL); } } -std::vector CBattleInfoCallback::battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector * attackable) +std::vector CBattleInfoCallback::battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector * attackable) { //boost::shared_lock lock(*gs->mx); if(!gs->curB) { tlog2<<"battleGetAvailableHexes called when there is no battle!"<(); + return std::vector(); } return gs->curB->getAccessibility(stack, addOccupiable, attackable); //return gs->battleGetRange(ID); } -bool CBattleInfoCallback::battleCanShoot(const CStack * stack, THex dest) +bool CBattleInfoCallback::battleCanShoot(const CStack * stack, SHexField dest) { //boost::shared_lock lock(*gs->mx); @@ -299,7 +299,7 @@ bool CBattleInfoCallback::battleCanCastSpell() if(!gs->curB) //there is no battle return false; - return gs->curB->battleCanCastSpell(player, SpellCasting::HERO_CASTING) == SpellCasting::OK; + return gs->curB->battleCanCastSpell(player, ECastingMode::HERO_CASTING) == ESpellCastProblem::OK; } bool CBattleInfoCallback::battleCanFlee() @@ -324,7 +324,7 @@ ui8 CBattleInfoCallback::battleGetWallState(int partOfWall) return gs->curB->si.wallState[partOfWall]; } -int CBattleInfoCallback::battleGetWallUnderHex(THex hex) +int CBattleInfoCallback::battleGetWallUnderHex(SHexField hex) { if(!gs->curB || gs->curB->siege == 0) { @@ -432,7 +432,7 @@ const PlayerSettings * CGameInfoCallback::getPlayerSettings(int color) const void CPrivilagedInfoCallback::getTilesInRange( boost::unordered_set &tiles, int3 pos, int radious, int player/*=-1*/, int mode/*=0*/ ) const { - if(player >= PLAYER_LIMIT) + if(player >= GameConstants::PLAYER_LIMIT) { tlog1 << "Illegal call to getTilesInRange!\n"; return; @@ -462,7 +462,7 @@ void CPrivilagedInfoCallback::getTilesInRange( boost::unordered_set &tiles, int Player/*=-1*/, int level, int surface ) const { - if(Player >= PLAYER_LIMIT) + if(Player >= GameConstants::PLAYER_LIMIT) { tlog1 << "Illegal call to getAllTiles !\n"; return; @@ -568,7 +568,7 @@ void CPrivilagedInfoCallback::getAllowedSpells(std::vector &out, ui16 leve { CSpell *spell; - for (unsigned int i = 0; i < gs->map->allowedSpell.size(); i++) //spellh size appears to be greater (?) + for (ui32 i = 0; i < gs->map->allowedSpell.size(); i++) //spellh size appears to be greater (?) { spell = VLC->spellh->spells[i]; if (isAllowed (0, spell->id) && spell->level == level) @@ -702,10 +702,10 @@ void CGameInfoCallback::getThievesGuildInfo(SThievesGuildInfo & thi, const CGObj { //boost::shared_lock lock(*gs->mx); ERROR_RET_IF(!obj, "No guild object!"); - ERROR_RET_IF(obj->ID == TOWNI_TYPE && !canGetFullInfo(obj), "Cannot get info about town guild object!"); + ERROR_RET_IF(obj->ID == GameConstants::TOWNI_TYPE && !canGetFullInfo(obj), "Cannot get info about town guild object!"); //TODO: advmap object -> check if they're visited by our hero - if(obj->ID == TOWNI_TYPE || obj->ID == 95) //it is a town or adv map tavern + if(obj->ID == GameConstants::TOWNI_TYPE || obj->ID == 95) //it is a town or adv map tavern { gs->obtainPlayersStats(thi, gs->players[obj->tempOwner].towns.size()); } @@ -727,7 +727,7 @@ bool CGameInfoCallback::getTownInfo( const CGObjectInstance *town, InfoAboutTown bool detailed = hasAccess(town->tempOwner); //TODO vision support - if(town->ID == TOWNI_TYPE) + if(town->ID == GameConstants::TOWNI_TYPE) dest.initFromTown(static_cast(town), detailed); else if(town->ID == 33 || town->ID == 219) dest.initFromGarrison(static_cast(town), detailed); @@ -896,18 +896,18 @@ int CGameInfoCallback::canBuildStructure( const CGTownInstance *t, int ID ) { ERROR_RET_VAL_IF(!canGetFullInfo(t), "Town is not owned!", -1); - int ret = Buildings::ALLOWED; - if(t->builded >= MAX_BUILDING_PER_TURN) - ret = Buildings::CANT_BUILD_TODAY; //building limit + int ret = EBuildingState::ALLOWED; + if(t->builded >= GameConstants::MAX_BUILDING_PER_TURN) + ret = EBuildingState::CANT_BUILD_TODAY; //building limit CBuilding * pom = VLC->buildh->buildings[t->subID][ID]; if(!pom) - return Buildings::ERROR; + return EBuildingState::BUILDING_ERROR; //checking resources if(!pom->resources.canBeAfforded(getPlayer(t->tempOwner)->resources)) - ret = Buildings::NO_RESOURCES; //lack of res + ret = EBuildingState::NO_RESOURCES; //lack of res //checking for requirements std::set reqs = getBuildingRequiments(t, ID);//getting all requirements @@ -915,12 +915,12 @@ int CGameInfoCallback::canBuildStructure( const CGTownInstance *t, int ID ) for( std::set::iterator ri = reqs.begin(); ri != reqs.end(); ri++ ) { if(t->builtBuildings.find(*ri)==t->builtBuildings.end()) - ret = Buildings::PREREQUIRES; //lack of requirements - cannot build + ret = EBuildingState::PREREQUIRES; //lack of requirements - cannot build } //can we build it? if(t->forbiddenBuildings.find(ID)!=t->forbiddenBuildings.end()) - ret = Buildings::FORBIDDEN; //forbidden + ret = EBuildingState::FORBIDDEN; //forbidden if(ID == 13) //capitol { @@ -931,7 +931,7 @@ int CGameInfoCallback::canBuildStructure( const CGTownInstance *t, int ID ) { if(vstd::contains(t->builtBuildings, 13)) { - ret = Buildings::HAVE_CAPITAL; //no more than one capitol + ret = EBuildingState::HAVE_CAPITAL; //no more than one capitol break; } } @@ -942,11 +942,11 @@ int CGameInfoCallback::canBuildStructure( const CGTownInstance *t, int ID ) const TerrainTile *tile = getTile(t->bestLocation()); if(!tile || tile->tertype != TerrainTile::water ) - ret = Buildings::NO_WATER; //lack of water + ret = EBuildingState::NO_WATER; //lack of water } if(t->builtBuildings.find(ID)!=t->builtBuildings.end()) //already built - ret = Buildings::ALREADY_PRESENT; + ret = EBuildingState::ALREADY_PRESENT; return ret; } @@ -1027,7 +1027,7 @@ int CGameInfoCallback::getHeroCount( int player, bool includeGarrisoned ) const if(includeGarrisoned) return p->heroes.size(); else - for(unsigned int i = 0; i < p->heroes.size(); i++) + for(ui32 i = 0; i < p->heroes.size(); i++) if(!p->heroes[i]->inTownGarrison) ret++; return ret; @@ -1040,7 +1040,7 @@ bool CGameInfoCallback::isOwnedOrVisited(const CGObjectInstance *obj) const const TerrainTile *t = getTile(obj->visitablePos()); //get entrance tile const CGObjectInstance *visitor = t->visitableObjects.back(); //visitong hero if present or the obejct itself at last - return visitor->ID == HEROI_TYPE && canGetFullInfo(visitor); //owned or allied hero is a visitor + return visitor->ID == GameConstants::HEROI_TYPE && canGetFullInfo(visitor); //owned or allied hero is a visitor } int CGameInfoCallback::getCurrentPlayer() const @@ -1058,7 +1058,7 @@ CGameInfoCallback::CGameInfoCallback(CGameState *GS, int Player) player = Player; } -const std::vector< std::vector< std::vector > > & CPlayerSpecificInfoCallback::getVisibilityMap() const +const std::vector< std::vector< std::vector > > & CPlayerSpecificInfoCallback::getVisibilityMap() const { //boost::shared_lock lock(*gs->mx); return gs->getPlayerTeam(player)->fogOfWarMap; @@ -1119,15 +1119,15 @@ int CPlayerSpecificInfoCallback::getHeroSerial(const CGHeroInstance * hero) cons return -1; } -int3 CPlayerSpecificInfoCallback::getGrailPos( float &outKnownRatio ) +int3 CPlayerSpecificInfoCallback::getGrailPos( double &outKnownRatio ) { if (CGObelisk::obeliskCount == 0) { - outKnownRatio = 0.0f; + outKnownRatio = 0.0; } else { - outKnownRatio = (float)CGObelisk::visited[gs->getPlayerTeam(player)->id] / CGObelisk::obeliskCount; + outKnownRatio = static_cast(CGObelisk::visited[gs->getPlayerTeam(player)->id]) / CGObelisk::obeliskCount; } return gs->map->grailPos; } @@ -1167,7 +1167,7 @@ const CGHeroInstance* CPlayerSpecificInfoCallback::getHeroBySerial(int serialId, if (!includeGarrisoned) { - for(unsigned int i = 0; i < p->heroes.size() && i<=serialId; i++) + for(ui32 i = 0; i < p->heroes.size() && i<=serialId; i++) if(p->heroes[i]->inTownGarrison) serialId++; } diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index c75a58db5..c19ccbe45 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -1,12 +1,12 @@ -#ifndef __IGAMECALLBACK_H__ -#define __IGAMECALLBACK_H__ +#pragma once -#include "../global.h" -#include -#include + +#include "SHexField.h" #include "../client/FunctionList.h" #include "CObstacleInstance.h" #include "ResourceSet.h" +#include "int3.h" +#include "GameConstants.h" /* * IGameCallback.h, part of VCMI engine @@ -63,7 +63,7 @@ typedef std::vector TStacks; namespace boost {class shared_mutex;} -class DLL_EXPORT CCallbackBase +class DLL_LINKAGE CCallbackBase { protected: CGameState *gs; @@ -80,7 +80,7 @@ public: boost::shared_mutex &getGsMutex(); //just return a reference to mutex, does not lock nor anything }; -class DLL_EXPORT CBattleInfoCallback : public virtual CCallbackBase +class DLL_LINKAGE CBattleInfoCallback : public virtual CCallbackBase { public: enum EStackOwnership @@ -94,33 +94,33 @@ public: //battle int battleGetBattlefieldType(); // 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship - int battleGetObstaclesAtTile(THex tile); //returns bitfield + int battleGetObstaclesAtTile(SHexField tile); //returns bitfield std::vector battleGetAllObstacles(); //returns all obstacles on the battlefield const CStack * battleGetStackByID(int ID, bool onlyAlive = true); //returns stack info by given ID - const CStack * battleGetStackByPos(THex pos, bool onlyAlive = true); //returns stack info by given pos - THex battleGetPos(int stack); //returns position (tile ID) of stack + const CStack * battleGetStackByPos(SHexField pos, bool onlyAlive = true); //returns stack info by given pos + SHexField battleGetPos(int stack); //returns position (tile ID) of stack TStacks battleGetStacks(EStackOwnership whose = MINE_AND_ENEMY, bool onlyAlive = true); //returns stacks on battlefield void getStackQueue( std::vector &out, int howMany ); //returns vector of stack in order of their move sequence void battleGetStackCountOutsideHexes(bool *ac); // returns hexes which when in front of a stack cause us to move the amount box back - std::vector battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector * attackable = NULL); //returns numbers of hexes reachable by creature with id ID - std::vector battleGetDistances(const CStack * stack, THex hex = THex::INVALID, THex * predecessors = NULL); //returns vector of distances to [dest hex number] - std::set battleGetAttackedHexes(const CStack* attacker, THex destinationTile, THex attackerPos = THex::INVALID); - bool battleCanShoot(const CStack * stack, THex dest); //returns true if unit with id ID can shoot to dest + std::vector battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector * attackable = NULL); //returns numbers of hexes reachable by creature with id ID + std::vector battleGetDistances(const CStack * stack, SHexField hex = SHexField::INVALID, SHexField * predecessors = NULL); //returns vector of distances to [dest hex number] + std::set battleGetAttackedHexes(const CStack* attacker, SHexField destinationTile, SHexField attackerPos = SHexField::INVALID); + bool battleCanShoot(const CStack * stack, SHexField dest); //returns true if unit with id ID can shoot to dest bool battleCanCastSpell(); //returns true, if caller can cast a spell - SpellCasting::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell); //determines if given spell can be casted (and returns problem description) - SpellCasting::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell, THex destination); //determines if creature can cast a spell here - TSpell battleGetRandomStackSpell(const CStack * stack, ERandomSpell mode); + ESpellCastProblem::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell); //determines if given spell can be casted (and returns problem description) + ESpellCastProblem::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell, SHexField destination); //determines if creature can cast a spell here + ui32 battleGetRandomStackSpell(const CStack * stack, ERandomSpell mode); bool battleCanFlee(); //returns true if caller can flee from the battle int battleGetSurrenderCost(); //returns cost of surrendering battle, -1 if surrendering is not possible const CGTownInstance * battleGetDefendedTown(); //returns defended town if current battle is a siege, NULL instead ui8 battleGetWallState(int partOfWall); //for determining state of a part of the wall; format: parameter [0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; returned value: 1 - intact, 2 - damaged, 3 - destroyed; 0 - no battle - int battleGetWallUnderHex(THex hex); //returns part of destructible wall / gate / keep under given hex or -1 if not found - TDmgRange battleEstimateDamage(const CStack * attacker, const CStack * defender, TDmgRange * retaliationDmg = NULL); //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair + int battleGetWallUnderHex(SHexField hex); //returns part of destructible wall / gate / keep under given hex or -1 if not found + std::pair battleEstimateDamage(const CStack * attacker, const CStack * defender, std::pair * retaliationDmg = NULL); //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair ui8 battleGetSiegeLevel(); //returns 0 when there is no siege, 1 if fort, 2 is citadel, 3 is castle const CGHeroInstance * battleGetFightingHero(ui8 side) const; //returns hero corresponding to given side (0 - attacker, 1 - defender) - si8 battleHasDistancePenalty(const CStack * stack, THex destHex); //checks if given stack has distance penalty - si8 battleHasWallPenalty(const CStack * stack, THex destHex); //checks if given stack has wall penalty - si8 battleCanTeleportTo(const CStack * stack, THex destHex, int telportLevel); //checks if teleportation of given stack to given position can take place + si8 battleHasDistancePenalty(const CStack * stack, SHexField destHex); //checks if given stack has distance penalty + si8 battleHasWallPenalty(const CStack * stack, SHexField destHex); //checks if given stack has wall penalty + si8 battleCanTeleportTo(const CStack * stack, SHexField destHex, int telportLevel); //checks if teleportation of given stack to given position can take place si8 battleGetTacticDist(); //returns tactic distance for calling player or 0 if player is not in tactic phase ui8 battleGetMySide(); //return side of player in battle (attacker/defender) @@ -131,7 +131,7 @@ public: } }; -class DLL_EXPORT CGameInfoCallback : public virtual CCallbackBase +class DLL_LINKAGE CGameInfoCallback : public virtual CCallbackBase { protected: CGameInfoCallback(); @@ -210,12 +210,12 @@ public: }; -class DLL_EXPORT CPlayerSpecificInfoCallback : public CGameInfoCallback +class DLL_LINKAGE CPlayerSpecificInfoCallback : public CGameInfoCallback { public: int howManyTowns() const; int howManyHeroes(bool includeGarrisoned = true) const; - int3 getGrailPos(float &outKnownRatio); + int3 getGrailPos(double &outKnownRatio); int getMyColor() const; std::vector getTownsInfo(bool onlyOur = true) const; //true -> only owned; false -> all visible @@ -228,11 +228,11 @@ public: int getResourceAmount(int type)const; TResources getResourceAmount() const; - const std::vector< std::vector< std::vector > > & getVisibilityMap()const; //returns visibility map + const std::vector< std::vector< std::vector > > & getVisibilityMap()const; //returns visibility map const PlayerSettings * getPlayerSettings(int color) const; }; -class DLL_EXPORT CPrivilagedInfoCallback : public CGameInfoCallback +class DLL_LINKAGE CPrivilagedInfoCallback : public CGameInfoCallback { public: CGameState *const gameState (); @@ -246,7 +246,7 @@ public: void getAllowedSpells(std::vector &out, ui16 level); }; -class DLL_EXPORT CNonConstInfoCallback : public CPrivilagedInfoCallback +class DLL_LINKAGE CNonConstInfoCallback : public CPrivilagedInfoCallback { public: PlayerState *getPlayer(ui8 color, bool verbose = true); @@ -257,7 +257,7 @@ public: TerrainTile * getTile(int3 pos); }; -class DLL_EXPORT IGameEventRealizer +class DLL_LINKAGE IGameEventRealizer { public: virtual void commitPackage(CPackForClient *pack) = 0; @@ -269,7 +269,7 @@ public: virtual void showInfoDialog(const std::string &msg, int player); }; -class DLL_EXPORT IGameEventCallback : public IGameEventRealizer +class DLL_LINKAGE IGameEventCallback : public IGameEventRealizer { public: virtual void changeSpells(int hid, bool give, const std::set &spells)=0; @@ -320,7 +320,7 @@ public: }; /// Interface class for handling general game logic and actions -class DLL_EXPORT IGameCallback : public CPrivilagedInfoCallback, public IGameEventCallback +class DLL_LINKAGE IGameCallback : public CPrivilagedInfoCallback, public IGameEventCallback { public: virtual ~IGameCallback(){}; @@ -333,4 +333,3 @@ public: friend struct CPackForClient; friend struct CPackForServer; }; -#endif // __IGAMECALLBACK_H__ diff --git a/lib/IGameEventsReceiver.h b/lib/IGameEventsReceiver.h index 7e1acece9..964645fe5 100644 --- a/lib/IGameEventsReceiver.h +++ b/lib/IGameEventsReceiver.h @@ -1,6 +1,8 @@ #pragma once -#include "../global.h" -#include + + +#include "SHexField.h" +#include "int3.h" class CGTownInstance; class CCreature; @@ -33,7 +35,7 @@ struct SetStackEffect; struct BattleTriggerEffect; -class DLL_EXPORT IBattleEventsReceiver +class DLL_LINKAGE IBattleEventsReceiver { public: virtual void actionFinished(const BattleAction *action){};//occurs AFTER every action taken by any stack or by the hero @@ -43,7 +45,7 @@ public: virtual void battleEnd(const BattleResult *br){}; virtual void battleNewRoundFirst(int round){}; //called at the beginning of each turn before changes are applied; virtual void battleNewRound(int round){}; //called at the beginning of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn - virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance){}; + virtual void battleStackMoved(const CStack * stack, std::vector dest, int distance){}; virtual void battleSpellCast(const BattleSpellCast *sc){}; virtual void battleStacksEffectsSet(const SetStackEffect & sse){};//called when a specific effect is set to stacks virtual void battleTriggerEffect(const BattleTriggerEffect & bte){}; //called for various one-shot effects @@ -55,7 +57,7 @@ public: virtual void battleStacksRemoved(const BattleStacksRemoved & bsr){}; //called when certain stack is completely removed from battlefield }; -class DLL_EXPORT IGameEventsReceiver +class DLL_LINKAGE IGameEventsReceiver { public: virtual void buildChanged(const CGTownInstance *town, int buildingID, int what){}; //what: 1 - built, 2 - demolished diff --git a/lib/Interprocess.h b/lib/Interprocess.h index 6f7363227..4c4ac9c45 100644 --- a/lib/Interprocess.h +++ b/lib/Interprocess.h @@ -1,3 +1,5 @@ +#pragma once + #include #include #include diff --git a/lib/JsonNode.cpp b/lib/JsonNode.cpp index 6ffeeadbf..6aa8f1d3b 100644 --- a/lib/JsonNode.cpp +++ b/lib/JsonNode.cpp @@ -1,14 +1,6 @@ -#define VCMI_DLL +#include "StdInc.h" #include "JsonNode.h" -#include -#include - -#include -#include -#include -#include - const JsonNode JsonNode::nullNode; JsonNode::JsonNode(JsonType Type): @@ -123,7 +115,7 @@ bool & JsonNode::Bool() return data.Bool; } -float & JsonNode::Float() +double & JsonNode::Float() { setType(DATA_FLOAT); return data.Float; @@ -156,8 +148,8 @@ const bool & JsonNode::Bool() const return data.Bool; } -const float floatDefault = 0; -const float & JsonNode::Float() const +const double floatDefault = 0; +const double & JsonNode::Float() const { if (type == DATA_NULL) return floatDefault; @@ -362,7 +354,7 @@ bool JsonParser::extractWhitespace(bool verbose) { while (true) { - while (pos < input.size() && (unsigned char)input[pos] <= ' ') + while (pos < input.size() && (ui8)input[pos] <= ' ') { if (input[pos] == '\n') { @@ -602,7 +594,7 @@ bool JsonParser::extractFloat(JsonNode &node) { assert(input[pos] == '-' || (input[pos] >= '0' && input[pos] <= '9')); bool negative=false; - float result=0; + double result=0; if (input[pos] == '-') { @@ -624,7 +616,7 @@ bool JsonParser::extractFloat(JsonNode &node) { //extract fractional part pos++; - float fractMult = 0.1; + double fractMult = 0.1; if (input[pos] < '0' || input[pos] > '9') return error("Decimal part expected!"); diff --git a/lib/JsonNode.h b/lib/JsonNode.h index 4bcb4ec9f..c383a8a08 100644 --- a/lib/JsonNode.h +++ b/lib/JsonNode.h @@ -1,18 +1,12 @@ #pragma once -#include "../global.h" -#include -#include -#include -#include -#include class JsonNode; typedef std::map JsonMap; typedef std::vector JsonVector; -class DLL_EXPORT JsonNode +class DLL_LINKAGE JsonNode { public: enum JsonType @@ -29,7 +23,7 @@ private: union JsonData { bool Bool; - float Float; + double Float; std::string* String; JsonVector* Vector; JsonMap* Struct; @@ -61,14 +55,14 @@ public: //non-const accessors, node will change type on type mismatch bool & Bool(); - float & Float(); + double & Float(); std::string & String(); JsonVector & Vector(); JsonMap & Struct(); //const accessors, will cause assertion failure on type mismatch const bool & Bool() const; - const float & Float() const; + const double & Float() const; const std::string & String() const; const JsonVector & Vector() const; const JsonMap & Struct() const; @@ -129,7 +123,7 @@ class JsonParser { std::string errors; // Contains description of all encountered errors constString input; // Input data - unsigned int lineCount; // Currently parsed line, starting from 1 + ui32 lineCount; // Currently parsed line, starting from 1 size_t lineStart; // Position of current line start size_t pos; // Current position of parser diff --git a/lib/Makefile.am b/lib/Makefile.am index 87f8c31b3..531f0a491 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,10 @@ +BUILT_SOURCES = StdInc.h.gch +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -DVCMI_DLL -fPIC -c $< + pkglib_LTLIBRARIES = libvcmi.la libvcmi_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lz -lpthread -ldl -libvcmi_la_CXXFLAGS = @SDL_CFLAGS@ +libvcmi_la_CXXFLAGS = @SDL_CFLAGS@ -DVCMI_DLL libvcmi_la_SOURCES = \ BattleAction.cpp \ BattleAction.h \ @@ -12,6 +16,8 @@ libvcmi_la_SOURCES = \ CBuildingHandler.h \ CCampaignHandler.cpp \ CCampaignHandler.h \ + CConsoleHandler.cpp \ + CConsoleHandler.h \ CCreatureHandler.cpp \ CCreatureHandler.h \ CCreatureSet.cpp \ @@ -30,6 +36,8 @@ libvcmi_la_SOURCES = \ CHeroHandler.h \ CLodHandler.cpp \ CLodHandler.h \ + CLogger.cpp \ + CLogger.h \ CMapInfo.cpp \ CMapInfo.h \ CObjectHandler.cpp \ @@ -40,6 +48,8 @@ libvcmi_la_SOURCES = \ CScriptingModule.h \ CTownHandler.cpp \ CTownHandler.h \ + CThreadHelper.cpp \ + CThreadHelper.h \ CondSh.h \ Connection.cpp \ Connection.h \ @@ -56,8 +66,9 @@ libvcmi_la_SOURCES = \ NetPacksLib.cpp \ ResourceSet.cpp \ ResourceSet.h \ - RegisterTypes.cpp \ RegisterTypes.h \ + SHexField.cpp \ + SHexField.h \ VCMIDirs.h \ VCMI_Lib.cpp \ VCMI_Lib.h \ diff --git a/lib/Makefile.in b/lib/Makefile.in index 68e259848..cfe714b99 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -82,17 +82,19 @@ libvcmi_la_DEPENDENCIES = am_libvcmi_la_OBJECTS = libvcmi_la-BattleAction.lo \ libvcmi_la-BattleState.lo libvcmi_la-CArtHandler.lo \ libvcmi_la-CBuildingHandler.lo libvcmi_la-CCampaignHandler.lo \ - libvcmi_la-CCreatureHandler.lo libvcmi_la-CCreatureSet.lo \ - libvcmi_la-CDefObjInfoHandler.lo libvcmi_la-CFileUtility.lo \ - libvcmi_la-CGameInterface.lo libvcmi_la-CGameState.lo \ - libvcmi_la-CGeneralTextHandler.lo libvcmi_la-CHeroHandler.lo \ - libvcmi_la-CLodHandler.lo libvcmi_la-CMapInfo.lo \ + libvcmi_la-CConsoleHandler.lo libvcmi_la-CCreatureHandler.lo \ + libvcmi_la-CCreatureSet.lo libvcmi_la-CDefObjInfoHandler.lo \ + libvcmi_la-CFileUtility.lo libvcmi_la-CGameInterface.lo \ + libvcmi_la-CGameState.lo libvcmi_la-CGeneralTextHandler.lo \ + libvcmi_la-CHeroHandler.lo libvcmi_la-CLodHandler.lo \ + libvcmi_la-CLogger.lo libvcmi_la-CMapInfo.lo \ libvcmi_la-CObjectHandler.lo libvcmi_la-CSpellHandler.lo \ - libvcmi_la-CTownHandler.lo libvcmi_la-Connection.lo \ - libvcmi_la-HeroBonus.lo libvcmi_la-IGameCallback.lo \ - libvcmi_la-JsonNode.lo libvcmi_la-NetPacksLib.lo \ - libvcmi_la-ResourceSet.lo libvcmi_la-RegisterTypes.lo \ - libvcmi_la-VCMI_Lib.lo libvcmi_la-map.lo + libvcmi_la-CTownHandler.lo libvcmi_la-CThreadHelper.lo \ + libvcmi_la-Connection.lo libvcmi_la-HeroBonus.lo \ + libvcmi_la-IGameCallback.lo libvcmi_la-JsonNode.lo \ + libvcmi_la-NetPacksLib.lo libvcmi_la-ResourceSet.lo \ + libvcmi_la-SHexField.lo libvcmi_la-VCMI_Lib.lo \ + libvcmi_la-map.lo libvcmi_la_OBJECTS = $(am_libvcmi_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) @@ -281,9 +283,10 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +BUILT_SOURCES = StdInc.h.gch pkglib_LTLIBRARIES = libvcmi.la libvcmi_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lz -lpthread -ldl -libvcmi_la_CXXFLAGS = @SDL_CFLAGS@ +libvcmi_la_CXXFLAGS = @SDL_CFLAGS@ -DVCMI_DLL libvcmi_la_SOURCES = \ BattleAction.cpp \ BattleAction.h \ @@ -295,6 +298,8 @@ libvcmi_la_SOURCES = \ CBuildingHandler.h \ CCampaignHandler.cpp \ CCampaignHandler.h \ + CConsoleHandler.cpp \ + CConsoleHandler.h \ CCreatureHandler.cpp \ CCreatureHandler.h \ CCreatureSet.cpp \ @@ -313,6 +318,8 @@ libvcmi_la_SOURCES = \ CHeroHandler.h \ CLodHandler.cpp \ CLodHandler.h \ + CLogger.cpp \ + CLogger.h \ CMapInfo.cpp \ CMapInfo.h \ CObjectHandler.cpp \ @@ -323,6 +330,8 @@ libvcmi_la_SOURCES = \ CScriptingModule.h \ CTownHandler.cpp \ CTownHandler.h \ + CThreadHelper.cpp \ + CThreadHelper.h \ CondSh.h \ Connection.cpp \ Connection.h \ @@ -339,15 +348,17 @@ libvcmi_la_SOURCES = \ NetPacksLib.cpp \ ResourceSet.cpp \ ResourceSet.h \ - RegisterTypes.cpp \ RegisterTypes.h \ + SHexField.cpp \ + SHexField.h \ VCMIDirs.h \ VCMI_Lib.cpp \ VCMI_Lib.h \ map.cpp \ map.h -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj @@ -426,6 +437,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CArtHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CBuildingHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CCampaignHandler.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CConsoleHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CCreatureHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CCreatureSet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CDefObjInfoHandler.Plo@am__quote@ @@ -435,17 +447,19 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CGeneralTextHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CHeroHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CLodHandler.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CLogger.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CMapInfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CObjectHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CSpellHandler.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CThreadHelper.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CTownHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-Connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-HeroBonus.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-IGameCallback.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-JsonNode.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-NetPacksLib.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-RegisterTypes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-ResourceSet.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-SHexField.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-VCMI_Lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-map.Plo@am__quote@ @@ -513,6 +527,14 @@ libvcmi_la-CCampaignHandler.lo: CCampaignHandler.cpp @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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-CCampaignHandler.lo `test -f 'CCampaignHandler.cpp' || echo '$(srcdir)/'`CCampaignHandler.cpp +libvcmi_la-CConsoleHandler.lo: CConsoleHandler.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-CConsoleHandler.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-CConsoleHandler.Tpo -c -o libvcmi_la-CConsoleHandler.lo `test -f 'CConsoleHandler.cpp' || echo '$(srcdir)/'`CConsoleHandler.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-CConsoleHandler.Tpo $(DEPDIR)/libvcmi_la-CConsoleHandler.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CConsoleHandler.cpp' object='libvcmi_la-CConsoleHandler.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-CConsoleHandler.lo `test -f 'CConsoleHandler.cpp' || echo '$(srcdir)/'`CConsoleHandler.cpp + libvcmi_la-CCreatureHandler.lo: CCreatureHandler.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-CCreatureHandler.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-CCreatureHandler.Tpo -c -o libvcmi_la-CCreatureHandler.lo `test -f 'CCreatureHandler.cpp' || echo '$(srcdir)/'`CCreatureHandler.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-CCreatureHandler.Tpo $(DEPDIR)/libvcmi_la-CCreatureHandler.Plo @@ -585,6 +607,14 @@ libvcmi_la-CLodHandler.lo: CLodHandler.cpp @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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-CLodHandler.lo `test -f 'CLodHandler.cpp' || echo '$(srcdir)/'`CLodHandler.cpp +libvcmi_la-CLogger.lo: CLogger.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-CLogger.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-CLogger.Tpo -c -o libvcmi_la-CLogger.lo `test -f 'CLogger.cpp' || echo '$(srcdir)/'`CLogger.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-CLogger.Tpo $(DEPDIR)/libvcmi_la-CLogger.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CLogger.cpp' object='libvcmi_la-CLogger.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-CLogger.lo `test -f 'CLogger.cpp' || echo '$(srcdir)/'`CLogger.cpp + libvcmi_la-CMapInfo.lo: CMapInfo.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-CMapInfo.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-CMapInfo.Tpo -c -o libvcmi_la-CMapInfo.lo `test -f 'CMapInfo.cpp' || echo '$(srcdir)/'`CMapInfo.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-CMapInfo.Tpo $(DEPDIR)/libvcmi_la-CMapInfo.Plo @@ -617,6 +647,14 @@ libvcmi_la-CTownHandler.lo: CTownHandler.cpp @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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-CTownHandler.lo `test -f 'CTownHandler.cpp' || echo '$(srcdir)/'`CTownHandler.cpp +libvcmi_la-CThreadHelper.lo: CThreadHelper.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-CThreadHelper.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-CThreadHelper.Tpo -c -o libvcmi_la-CThreadHelper.lo `test -f 'CThreadHelper.cpp' || echo '$(srcdir)/'`CThreadHelper.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-CThreadHelper.Tpo $(DEPDIR)/libvcmi_la-CThreadHelper.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CThreadHelper.cpp' object='libvcmi_la-CThreadHelper.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-CThreadHelper.lo `test -f 'CThreadHelper.cpp' || echo '$(srcdir)/'`CThreadHelper.cpp + libvcmi_la-Connection.lo: Connection.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-Connection.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-Connection.Tpo -c -o libvcmi_la-Connection.lo `test -f 'Connection.cpp' || echo '$(srcdir)/'`Connection.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-Connection.Tpo $(DEPDIR)/libvcmi_la-Connection.Plo @@ -665,13 +703,13 @@ libvcmi_la-ResourceSet.lo: ResourceSet.cpp @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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-ResourceSet.lo `test -f 'ResourceSet.cpp' || echo '$(srcdir)/'`ResourceSet.cpp -libvcmi_la-RegisterTypes.lo: RegisterTypes.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-RegisterTypes.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-RegisterTypes.Tpo -c -o libvcmi_la-RegisterTypes.lo `test -f 'RegisterTypes.cpp' || echo '$(srcdir)/'`RegisterTypes.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-RegisterTypes.Tpo $(DEPDIR)/libvcmi_la-RegisterTypes.Plo +libvcmi_la-SHexField.lo: SHexField.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-SHexField.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-SHexField.Tpo -c -o libvcmi_la-SHexField.lo `test -f 'SHexField.cpp' || echo '$(srcdir)/'`SHexField.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-SHexField.Tpo $(DEPDIR)/libvcmi_la-SHexField.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='RegisterTypes.cpp' object='libvcmi_la-RegisterTypes.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SHexField.cpp' object='libvcmi_la-SHexField.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-RegisterTypes.lo `test -f 'RegisterTypes.cpp' || echo '$(srcdir)/'`RegisterTypes.cpp +@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-SHexField.lo `test -f 'SHexField.cpp' || echo '$(srcdir)/'`SHexField.cpp libvcmi_la-VCMI_Lib.lo: VCMI_Lib.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) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-VCMI_Lib.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-VCMI_Lib.Tpo -c -o libvcmi_la-VCMI_Lib.lo `test -f 'VCMI_Lib.cpp' || echo '$(srcdir)/'`VCMI_Lib.cpp @@ -778,13 +816,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -809,6 +849,7 @@ distclean-generic: 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-pkglibLTLIBRARIES \ @@ -880,7 +921,7 @@ ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES -.MAKE: install-am install-strip +.MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \ @@ -896,6 +937,8 @@ uninstall-am: uninstall-pkglibLTLIBRARIES mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES +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. diff --git a/lib/NetPacks.h b/lib/NetPacks.h index fbafac2ab..8dc4c2fbe 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -1,15 +1,13 @@ -#ifndef __NETPACKS_H__ -#define __NETPACKS_H__ -#include -#include "../global.h" +#pragma once + + #include "BattleAction.h" #include "HeroBonus.h" -#include #include "CCreatureSet.h" #include "CMapInfo.h" -#include "../StartInfo.h" +#include "StartInfo.h" #include "ConstTransitivePtr.h" -#include "../int3.h" +#include "int3.h" #include "ResourceSet.h" /* @@ -45,7 +43,7 @@ struct CPack { tlog1 << "CPack serialized... this should not happen!\n"; } - DLL_EXPORT void applyGs(CGameState *gs) + DLL_LINKAGE void applyGs(CGameState *gs) {}; }; @@ -141,9 +139,9 @@ public: message.push_back(TREPLACE_PLUSNUMBER); numbers.push_back(txt); } - DLL_EXPORT void addCreReplacement(TCreature id, TQuantity count); //adds sing or plural name; - DLL_EXPORT void addReplacement(const CStackBasicDescriptor &stack); //adds sing or plural name; - DLL_EXPORT std::string buildList () const; + DLL_LINKAGE void addCreReplacement(TCreature id, TQuantity count); //adds sing or plural name; + DLL_LINKAGE void addReplacement(const CStackBasicDescriptor &stack); //adds sing or plural name; + DLL_LINKAGE std::string buildList () const; void clear() { exactStrings.clear(); @@ -151,8 +149,8 @@ public: message.clear(); numbers.clear(); } - DLL_EXPORT void toString(std::string &dst) const; - DLL_EXPORT std::string toString() const; + DLL_LINKAGE void toString(std::string &dst) const; + DLL_LINKAGE std::string toString() const; void getLocalString(const std::pair &txt, std::string &dst) const; MetaString() @@ -213,7 +211,7 @@ struct YourTurn : public CPackForClient //100 { YourTurn(){type = 100;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 player; @@ -227,7 +225,7 @@ struct SetResource : public CPackForClient //102 { SetResource(){type = 102;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 player, resid; si32 val; @@ -241,7 +239,7 @@ struct SetResource : public CPackForClient //102 { SetResources(){type = 104;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 player; TResources res; //res[resid] => res amount @@ -256,7 +254,7 @@ struct SetPrimSkill : public CPackForClient //105 { SetPrimSkill(){type = 105;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 abs; //0 - changes by value; 1 - sets to value si32 id; @@ -272,7 +270,7 @@ struct SetSecSkill : public CPackForClient //106 { SetSecSkill(){type = 106;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 abs; //0 - changes by value; 1 - sets to value si32 id; @@ -287,7 +285,7 @@ struct HeroVisitCastle : public CPackForClient //108 { HeroVisitCastle(){flags=0;type = 108;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 flags; //1 - start ui32 tid, hid; @@ -309,7 +307,7 @@ struct ChangeSpells : public CPackForClient //109 { ChangeSpells(){type = 109;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 learn; //1 - gives spell, 0 - takes ui32 hid; @@ -325,7 +323,7 @@ struct SetMana : public CPackForClient //110 { SetMana(){type = 110;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 hid, val; @@ -340,7 +338,7 @@ struct SetMovePoints : public CPackForClient //111 { SetMovePoints(){type = 111;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui32 hid, val; @@ -354,7 +352,7 @@ struct FoWChange : public CPackForClient //112 { FoWChange(){type = 112;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); boost::unordered_set tiles; ui8 player, mode; //mode==0 - hide, mode==1 - reveal @@ -369,18 +367,18 @@ struct SetAvailableHeroes : public CPackForClient //113 SetAvailableHeroes() { type = 113; - for (int i = 0; i < AVAILABLE_HEROES_PER_PLAYER; i++) + for (int i = 0; i < GameConstants::AVAILABLE_HEROES_PER_PLAYER; i++) army[i].clear(); } ~SetAvailableHeroes() { } void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 player; - si32 hid[AVAILABLE_HEROES_PER_PLAYER]; //-1 if no hero - CSimpleArmy army[AVAILABLE_HEROES_PER_PLAYER]; + si32 hid[GameConstants::AVAILABLE_HEROES_PER_PLAYER]; //-1 if no hero + CSimpleArmy army[GameConstants::AVAILABLE_HEROES_PER_PLAYER]; template void serialize(Handler &h, const int version) { h & player & hid & army; @@ -396,7 +394,7 @@ struct GiveBonus : public CPackForClient //115 } void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); enum {HERO, PLAYER, TOWN}; ui8 who; //who receives bonus, uses enum above @@ -419,7 +417,7 @@ struct ChangeObjPos : public CPackForClient //116 } void applyFirstCl(CClient *cl); void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui32 objid; int3 nPos; @@ -439,7 +437,7 @@ struct PlayerEndsGame : public CPackForClient //117 } void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui8 player; ui8 victory; @@ -460,7 +458,7 @@ struct RemoveBonus : public CPackForClient //118 } void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); enum {HERO, PLAYER, TOWN}; ui8 who; //who receives bonus, uses enum above @@ -501,7 +499,7 @@ struct RemoveObject : public CPackForClient //500 RemoveObject(si32 ID){id = ID;type = 500;}; void applyFirstCl(CClient *cl); void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 id; @@ -540,7 +538,7 @@ struct TryMoveHero : public CPackForClient //501 // { // SetGarrisons(){type = 502;}; // void applyCl(CClient *cl); -// DLL_EXPORT void applyGs(CGameState *gs); +// DLL_LINKAGE void applyGs(CGameState *gs); // // std::map garrs; // @@ -554,7 +552,7 @@ struct NewStructures : public CPackForClient //504 { NewStructures(){type = 504;}; void applyCl(CClient *cl); - DLL_EXPORT virtual void applyGs(CGameState *gs); + DLL_LINKAGE virtual void applyGs(CGameState *gs); si32 tid; std::set bid; @@ -569,7 +567,7 @@ struct RazeStructures : public CPackForClient //505 { RazeStructures() {type = 505;}; void applyCl (CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 tid; std::set bid; @@ -584,7 +582,7 @@ struct SetAvailableCreatures : public CPackForClient //506 { SetAvailableCreatures(){type = 506;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 tid; std::vector > > creatures; @@ -598,7 +596,7 @@ struct SetHeroesInTown : public CPackForClient //508 { SetHeroesInTown(){type = 508;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 tid, visiting, garrison; //id of town, visiting hero, hero in garrison @@ -612,8 +610,8 @@ struct SetHeroesInTown : public CPackForClient //508 // { // SetHeroArtifacts(){type = 509;}; // void applyCl(CClient *cl); -// DLL_EXPORT void applyGs(CGameState *gs); -// DLL_EXPORT void setArtAtPos(ui16 pos, const CArtifact* art); +// DLL_LINKAGE void applyGs(CGameState *gs); +// DLL_LINKAGE void setArtAtPos(ui16 pos, const CArtifact* art); // // si32 hid; // std::vector artifacts; //hero's artifacts from bag @@ -632,7 +630,7 @@ struct HeroRecruited : public CPackForClient //515 { HeroRecruited(){type = 515;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 hid, tid; //subID of hero int3 tile; @@ -649,7 +647,7 @@ struct GiveHero : public CPackForClient //516 GiveHero(){type = 516;}; void applyFirstCl(CClient *cl); void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui32 id; //object id ui8 player; @@ -684,7 +682,7 @@ struct NewObject : public CPackForClient //518 id = -1; } void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui32 ID, subID; int3 pos; @@ -701,7 +699,7 @@ struct SetAvailableArtifacts : public CPackForClient //519 { SetAvailableArtifacts(){type = 519;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 id; //two variants: id < 0: set artifact pool for Artifact Merchants in towns; id >= 0: set pool for adv. map Black Market (id is the id of Black Market instance then) std::vector arts; @@ -716,7 +714,7 @@ struct NewArtifact : public CPackForClient //520 { NewArtifact(){type = 520;}; //void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ConstTransitivePtr art; @@ -740,7 +738,7 @@ struct StackLocation army = const_cast(Army); //we are allowed here to const cast -> change will go through one of our packages... do not abuse! slot = Slot; } - DLL_EXPORT const CStackInstance *getStack(); + DLL_LINKAGE const CStackInstance *getStack(); template void serialize(Handler &h, const int version) { h & army & slot; @@ -762,7 +760,7 @@ struct ChangeStackCount : CGarrisonOperationPack //521 ui8 absoluteValue; //if not -> count will be added (or subtracted if negative) void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -776,7 +774,7 @@ struct SetStackType : CGarrisonOperationPack //522 CCreature *type; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -789,7 +787,7 @@ struct EraseStack : CGarrisonOperationPack //523 StackLocation sl; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -802,7 +800,7 @@ struct SwapStacks : CGarrisonOperationPack //524 StackLocation sl1, sl2; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -816,7 +814,7 @@ struct InsertNewStack : CGarrisonOperationPack //525 CStackBasicDescriptor stack; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -831,7 +829,7 @@ struct RebalanceStacks : CGarrisonOperationPack //526 TQuantity count; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -855,9 +853,9 @@ struct ArtifactLocation hero = const_cast(Hero); //we are allowed here to const cast -> change will go through one of our packages... do not abuse! slot = Slot; } - DLL_EXPORT const CArtifactInstance *getArt() const; - DLL_EXPORT CArtifactInstance *getArt(); - DLL_EXPORT const ArtSlotInfo *getSlot() const; + DLL_LINKAGE const CArtifactInstance *getArt() const; + DLL_LINKAGE CArtifactInstance *getArt(); + DLL_LINKAGE const ArtSlotInfo *getSlot() const; template void serialize(Handler &h, const int version) { h & hero & slot; @@ -870,7 +868,7 @@ struct PutArtifact : CArtifactOperationPack //526 ConstTransitivePtr art; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -883,7 +881,7 @@ struct EraseArtifact : CArtifactOperationPack //527 ArtifactLocation al; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -896,7 +894,7 @@ struct MoveArtifact : CArtifactOperationPack //528 ArtifactLocation src, dst; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -912,7 +910,7 @@ struct AssembledArtifact : CArtifactOperationPack //529 void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -925,7 +923,7 @@ struct DisassembledArtifact : CArtifactOperationPack //530 ArtifactLocation al; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -940,7 +938,7 @@ struct HeroVisit : CPackForClient //531 bool starting; //false -> ending void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); template void serialize(Handler &h, const int version) { @@ -953,7 +951,7 @@ struct NewTurn : public CPackForClient //101 enum weekType {NORMAL, DOUBLE_GROWTH, BONUS_GROWTH, DEITYOFFIRE, PLAGUE, NO_ACTION}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); struct Hero { @@ -997,7 +995,7 @@ struct Component : public CPack //2002 helper for object scrips informations { type = 2002; } - DLL_EXPORT explicit Component(const CStackBasicDescriptor &stack); + DLL_LINKAGE explicit Component(const CStackBasicDescriptor &stack); Component(ui16 Type, ui16 Subtype, si32 Val, si16 When) :id(Type),subtype(Subtype),val(Val),when(When) { @@ -1034,7 +1032,7 @@ namespace ObjProperty struct SetObjectProperty : public CPackForClient//1001 { - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); ui32 id; @@ -1051,7 +1049,7 @@ struct SetObjectProperty : public CPackForClient//1001 struct SetHoverName : public CPackForClient//1002 { - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui32 id; MetaString name; @@ -1066,7 +1064,7 @@ struct SetHoverName : public CPackForClient//1002 struct HeroLevelUp : public Query//2000 { void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 heroid; ui8 primskill, level; @@ -1084,7 +1082,7 @@ struct TradeComponents : public CPackForClient, public CPackForServer { ///used to handle info about components available in shops void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); si32 heroid; ui32 objectid; @@ -1159,7 +1157,7 @@ struct BattleStart : public CPackForClient//3000 { BattleStart(){type = 3000;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); BattleInfo * info; @@ -1174,7 +1172,7 @@ struct BattleNextRound : public CPackForClient//3001 BattleNextRound(){type = 3001;}; void applyFirstCl(CClient *cl); void applyCl(CClient *cl); - DLL_EXPORT void applyGs( CGameState *gs ); + DLL_LINKAGE void applyGs( CGameState *gs ); si32 round; template void serialize(Handler &h, const int version) @@ -1186,7 +1184,7 @@ struct BattleSetActiveStack : public CPackForClient//3002 { BattleSetActiveStack(){type = 3002;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui32 stack; @@ -1216,7 +1214,7 @@ struct BattleResult : public CPackForClient//3003 struct BattleStackMoved : public CPackForClient//3004 { ui32 stack; - std::vector tilesToMove; + std::vector tilesToMove; ui8 distance, teleporting; BattleStackMoved(){type = 3004;}; void applyFirstCl(CClient *cl); @@ -1231,7 +1229,7 @@ struct StacksHealedOrResurrected : public CPackForClient //3013 { StacksHealedOrResurrected(){type = 3013;} - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); struct HealInfo @@ -1260,7 +1258,7 @@ struct BattleStackAttacked : public CPackForClient//3005 { BattleStackAttacked(){flags = 0; type = 3005;}; void applyCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); ui32 stackAttacked, attackerID; ui32 newAmount, newHP, killedAmount, damageAmount; @@ -1305,7 +1303,7 @@ struct BattleAttack : public CPackForClient//3006 { BattleAttack(){flags = 0; type = 3006;}; void applyFirstCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); std::vector bsa; @@ -1353,7 +1351,7 @@ struct StartAction : public CPackForClient//3007 StartAction(){type = 3007;}; StartAction(const BattleAction &act){ba = act; type = 3007;}; void applyFirstCl(CClient *cl); - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); BattleAction ba; template void serialize(Handler &h, const int version) @@ -1375,7 +1373,7 @@ struct EndAction : public CPackForClient//3008 struct BattleSpellCast : public CPackForClient//3009 { BattleSpellCast(){type = 3009;}; - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); si32 dmgToDisplay; //this amount will be displayed as amount of damage dealt by spell @@ -1384,7 +1382,7 @@ struct BattleSpellCast : public CPackForClient//3009 ui8 skill; //caster's skill level ui8 spellCost; ui8 manaGained; //mana channeling ability - THex tile; //destination tile (may not be set in some global/mass spells + SHexField tile; //destination tile (may not be set in some global/mass spells std::vector resisted; //ids of creatures that resisted this spell std::set affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure) TCreature attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact) @@ -1398,7 +1396,7 @@ struct BattleSpellCast : public CPackForClient//3009 struct SetStackEffect : public CPackForClient //3010 { SetStackEffect(){type = 3010;}; - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); std::vector stacks; //affected stacks (IDs) @@ -1413,7 +1411,7 @@ struct SetStackEffect : public CPackForClient //3010 struct StacksInjured : public CPackForClient //3011 { StacksInjured(){type = 3011;} - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); std::vector stacks; @@ -1440,7 +1438,7 @@ struct ObstaclesRemoved : public CPackForClient //3014 { ObstaclesRemoved(){type = 3014;} - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); std::set obstacles; //uniqueIDs of removed obstacles @@ -1455,7 +1453,7 @@ struct CatapultAttack : public CPackForClient //3015 { CatapultAttack(){type = 3015;} - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); std::set< std::pair< std::pair< ui8, si16 >, ui8> > attackedParts; // < , damageDealt> @@ -1474,7 +1472,7 @@ struct BattleStacksRemoved : public CPackForClient //3016 { BattleStacksRemoved(){type = 3016;} - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); std::set stackIDs; //IDs of removed stacks @@ -1489,7 +1487,7 @@ struct BattleStackAdded : public CPackForClient //3017 { BattleStackAdded(){type = 3017;}; - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); int attacker; // if true, stack belongs to attacker @@ -1510,7 +1508,7 @@ struct BattleSetStackProperty : public CPackForClient //3018 enum BattleStackProperty {CASTS, ENCHANTER_COUNTER, UNBIND}; - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); //void applyCl(CClient *cl){}; int stackID; @@ -1528,7 +1526,7 @@ struct BattleTriggerEffect : public CPackForClient //3019 { //activated at the beginning of turn BattleTriggerEffect(){type = 3019;}; - DLL_EXPORT void applyGs(CGameState *gs); //effect + DLL_LINKAGE void applyGs(CGameState *gs); //effect void applyCl(CClient *cl); //play animations & stuff //enum BattleEffect {REGENERATION, MANA_DRAIN, FEAR, MANA_CHANNELING, ENCHANTER, UNBIND, POISON, ENCHANTED, SUMMONER}; @@ -1795,7 +1793,7 @@ struct TradeOnMarketplace : public CPackForServer const CGObjectInstance *market; const CGHeroInstance *hero; //needed when trading artifacts / creatures - ui8 mode;//enum EMarketMode + ui8 mode;//enum EEMarketMode ui32 r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?] ui32 val; //units of sold resource @@ -1953,7 +1951,7 @@ struct PlayerMessage : public CPackForClient, public CPackForServer //513 struct SetSelection : public CPackForClient, public CPackForServer //514 { SetSelection(){CPackForClient::type = 514;}; - DLL_EXPORT void applyGs(CGameState *gs); + DLL_LINKAGE void applyGs(CGameState *gs); bool applyGh(CGameHandler *gh); void applyCl(CClient *cl); @@ -2155,5 +2153,3 @@ public: //h & playerNames; } }; - -#endif //__NETPACKS_H__ diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 3422c5b52..5b045693c 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -1,5 +1,6 @@ -#define VCMI_DLL +#include "StdInc.h" #include "NetPacks.h" + #include "CGeneralTextHandler.h" #include "CDefObjInfoHandler.h" #include "CArtHandler.h" @@ -9,12 +10,6 @@ #include "map.h" #include "CSpellHandler.h" #include "CCreatureHandler.h" -#include -#include -#include -#include -#include -#include #include "CGameState.h" #include "BattleState.h" @@ -38,20 +33,20 @@ #undef max #endif -DLL_EXPORT void SetResource::applyGs( CGameState *gs ) +DLL_LINKAGE void SetResource::applyGs( CGameState *gs ) { - assert(player < PLAYER_LIMIT); - amax(val, 0); //new value must be >= 0 + assert(player < GameConstants::PLAYER_LIMIT); + vstd::amax(val, 0); //new value must be >= 0 gs->getPlayer(player)->resources[resid] = val; } -DLL_EXPORT void SetResources::applyGs( CGameState *gs ) +DLL_LINKAGE void SetResources::applyGs( CGameState *gs ) { - assert(player < PLAYER_LIMIT); + assert(player < GameConstants::PLAYER_LIMIT); gs->getPlayer(player)->resources = res; } -DLL_EXPORT void SetPrimSkill::applyGs( CGameState *gs ) +DLL_LINKAGE void SetPrimSkill::applyGs( CGameState *gs ) { CGHeroInstance *hero = gs->getHero(id); assert(hero); @@ -75,13 +70,13 @@ DLL_EXPORT void SetPrimSkill::applyGs( CGameState *gs ) } } -DLL_EXPORT void SetSecSkill::applyGs( CGameState *gs ) +DLL_LINKAGE void SetSecSkill::applyGs( CGameState *gs ) { CGHeroInstance *hero = gs->getHero(id); hero->setSecSkillLevel(static_cast(which), val, abs); } -DLL_EXPORT void HeroVisitCastle::applyGs( CGameState *gs ) +DLL_LINKAGE void HeroVisitCastle::applyGs( CGameState *gs ) { CGHeroInstance *h = gs->getHero(hid); CGTownInstance *t = gs->getTown(tid); @@ -92,7 +87,7 @@ DLL_EXPORT void HeroVisitCastle::applyGs( CGameState *gs ) t->setVisitingHero(NULL); } -DLL_EXPORT void ChangeSpells::applyGs( CGameState *gs ) +DLL_LINKAGE void ChangeSpells::applyGs( CGameState *gs ) { CGHeroInstance *hero = gs->getHero(hid); @@ -104,20 +99,20 @@ DLL_EXPORT void ChangeSpells::applyGs( CGameState *gs ) hero->spells.erase(sid); } -DLL_EXPORT void SetMana::applyGs( CGameState *gs ) +DLL_LINKAGE void SetMana::applyGs( CGameState *gs ) { CGHeroInstance *hero = gs->getHero(hid); - amax(val, 0); //not less than 0 + vstd::amax(val, 0); //not less than 0 hero->mana = val; } -DLL_EXPORT void SetMovePoints::applyGs( CGameState *gs ) +DLL_LINKAGE void SetMovePoints::applyGs( CGameState *gs ) { CGHeroInstance *hero = gs->getHero(hid); hero->movement = val; } -DLL_EXPORT void FoWChange::applyGs( CGameState *gs ) +DLL_LINKAGE void FoWChange::applyGs( CGameState *gs ) { TeamState * team = gs->getPlayerTeam(player); BOOST_FOREACH(int3 t, tiles) @@ -145,12 +140,12 @@ DLL_EXPORT void FoWChange::applyGs( CGameState *gs ) team->fogOfWarMap[t.x][t.y][t.z] = 1; } } -DLL_EXPORT void SetAvailableHeroes::applyGs( CGameState *gs ) +DLL_LINKAGE void SetAvailableHeroes::applyGs( CGameState *gs ) { PlayerState *p = gs->getPlayer(player); p->availableHeroes.clear(); - for (int i = 0; i < AVAILABLE_HEROES_PER_PLAYER; i++) + for (int i = 0; i < GameConstants::AVAILABLE_HEROES_PER_PLAYER; i++) { CGHeroInstance *h = (hid[i]>=0 ? (CGHeroInstance*)gs->hpool.heroesPool[hid[i]] : NULL); if(h && army[i]) @@ -159,7 +154,7 @@ DLL_EXPORT void SetAvailableHeroes::applyGs( CGameState *gs ) } } -DLL_EXPORT void GiveBonus::applyGs( CGameState *gs ) +DLL_LINKAGE void GiveBonus::applyGs( CGameState *gs ) { CBonusSystemNode *cbsn = NULL; switch(who) @@ -185,7 +180,7 @@ DLL_EXPORT void GiveBonus::applyGs( CGameState *gs ) if(!bdescr.message.size() && bonus.source == Bonus::OBJECT && (bonus.type == Bonus::LUCK || bonus.type == Bonus::MORALE) - && gs->map->objects[bonus.sid]->ID == EVENTI_TYPE) //it's morale/luck bonus from an event without description + && gs->map->objects[bonus.sid]->ID == GameConstants::EVENTI_TYPE) //it's morale/luck bonus from an event without description { descr = VLC->generaltexth->arraytxt[bonus.val > 0 ? 110 : 109]; //+/-%d Temporary until next battle" boost::replace_first(descr,"%d",boost::lexical_cast(std::abs(bonus.val))); @@ -196,7 +191,7 @@ DLL_EXPORT void GiveBonus::applyGs( CGameState *gs ) } } -DLL_EXPORT void ChangeObjPos::applyGs( CGameState *gs ) +DLL_LINKAGE void ChangeObjPos::applyGs( CGameState *gs ) { CGObjectInstance *obj = gs->map->objects[objid]; if(!obj) @@ -209,13 +204,13 @@ DLL_EXPORT void ChangeObjPos::applyGs( CGameState *gs ) gs->map->addBlockVisTiles(obj); } -DLL_EXPORT void PlayerEndsGame::applyGs( CGameState *gs ) +DLL_LINKAGE void PlayerEndsGame::applyGs( CGameState *gs ) { PlayerState *p = gs->getPlayer(player); p->status = victory ? 2 : 1; } -DLL_EXPORT void RemoveBonus::applyGs( CGameState *gs ) +DLL_LINKAGE void RemoveBonus::applyGs( CGameState *gs ) { CBonusSystemNode *node; if (who == HERO) @@ -237,7 +232,7 @@ DLL_EXPORT void RemoveBonus::applyGs( CGameState *gs ) } } -DLL_EXPORT void RemoveObject::applyGs( CGameState *gs ) +DLL_LINKAGE void RemoveObject::applyGs( CGameState *gs ) { CGObjectInstance *obj = gs->map->objects[id]; //unblock tiles @@ -246,7 +241,7 @@ DLL_EXPORT void RemoveObject::applyGs( CGameState *gs ) gs->map->removeBlockVisTiles(obj); } - if(obj->ID==HEROI_TYPE) + if(obj->ID==GameConstants::HEROI_TYPE) { CGHeroInstance *h = static_cast(obj); PlayerState *p = gs->getPlayer(h->tempOwner); @@ -362,7 +357,7 @@ void TryMoveHero::applyGs( CGameState *gs ) gs->getPlayerTeam(h->getOwner())->fogOfWarMap[t.x][t.y][t.z] = 1; } -DLL_EXPORT void NewStructures::applyGs( CGameState *gs ) +DLL_LINKAGE void NewStructures::applyGs( CGameState *gs ) { CGTownInstance *t = gs->getTown(tid); BOOST_FOREACH(si32 id,bid) @@ -372,7 +367,7 @@ DLL_EXPORT void NewStructures::applyGs( CGameState *gs ) t->builded = builded; t->recreateBuildingsBonuses(); } -DLL_EXPORT void RazeStructures::applyGs( CGameState *gs ) +DLL_LINKAGE void RazeStructures::applyGs( CGameState *gs ) { CGTownInstance *t = gs->getTown(tid); BOOST_FOREACH(si32 id,bid) @@ -383,14 +378,14 @@ DLL_EXPORT void RazeStructures::applyGs( CGameState *gs ) t->recreateBuildingsBonuses(); } -DLL_EXPORT void SetAvailableCreatures::applyGs( CGameState *gs ) +DLL_LINKAGE void SetAvailableCreatures::applyGs( CGameState *gs ) { CGDwelling *dw = dynamic_cast(gs->map->objects[tid].get()); assert(dw); dw->creatures = creatures; } -DLL_EXPORT void SetHeroesInTown::applyGs( CGameState *gs ) +DLL_LINKAGE void SetHeroesInTown::applyGs( CGameState *gs ) { CGTownInstance *t = gs->getTown(tid); @@ -419,7 +414,7 @@ DLL_EXPORT void SetHeroesInTown::applyGs( CGameState *gs ) } } -DLL_EXPORT void HeroRecruited::applyGs( CGameState *gs ) +DLL_LINKAGE void HeroRecruited::applyGs( CGameState *gs ) { assert(vstd::contains(gs->hpool.heroesPool, hid)); CGHeroInstance *h = gs->hpool.heroesPool[hid]; @@ -451,7 +446,7 @@ DLL_EXPORT void HeroRecruited::applyGs( CGameState *gs ) } } -DLL_EXPORT void GiveHero::applyGs( CGameState *gs ) +DLL_LINKAGE void GiveHero::applyGs( CGameState *gs ) { CGHeroInstance *h = gs->getHero(id); gs->map->removeBlockVisTiles(h,true); @@ -464,7 +459,7 @@ DLL_EXPORT void GiveHero::applyGs( CGameState *gs ) h->inTownGarrison = false; } -DLL_EXPORT void NewObject::applyGs( CGameState *gs ) +DLL_LINKAGE void NewObject::applyGs( CGameState *gs ) { CGObjectInstance *o = NULL; @@ -515,7 +510,7 @@ DLL_EXPORT void NewObject::applyGs( CGameState *gs ) o->initObj(); assert(o->defInfo); } -DLL_EXPORT void NewArtifact::applyGs( CGameState *gs ) +DLL_LINKAGE void NewArtifact::applyGs( CGameState *gs ) { assert(!vstd::contains(gs->map->artInstances, art)); gs->map->addNewArtifactInstance(art); @@ -526,7 +521,7 @@ DLL_EXPORT void NewArtifact::applyGs( CGameState *gs ) cart->createConstituents(); } -DLL_EXPORT const CStackInstance * StackLocation::getStack() +DLL_LINKAGE const CStackInstance * StackLocation::getStack() { if(!army->hasStackAtSlot(slot)) { @@ -536,7 +531,7 @@ DLL_EXPORT const CStackInstance * StackLocation::getStack() return &army->getStack(slot); } -DLL_EXPORT const CArtifactInstance *ArtifactLocation::getArt() const +DLL_LINKAGE const CArtifactInstance *ArtifactLocation::getArt() const { const ArtSlotInfo *s = getSlot(); if(s && s->artifact) @@ -553,18 +548,18 @@ DLL_EXPORT const CArtifactInstance *ArtifactLocation::getArt() const return NULL; } -DLL_EXPORT CArtifactInstance *ArtifactLocation::getArt() +DLL_LINKAGE CArtifactInstance *ArtifactLocation::getArt() { const ArtifactLocation *t = this; return const_cast(t->getArt()); } -DLL_EXPORT const ArtSlotInfo *ArtifactLocation::getSlot() const +DLL_LINKAGE const ArtSlotInfo *ArtifactLocation::getSlot() const { return hero->getSlot(slot); } -DLL_EXPORT void ChangeStackCount::applyGs( CGameState *gs ) +DLL_LINKAGE void ChangeStackCount::applyGs( CGameState *gs ) { if(absoluteValue) sl.army->setStackCount(sl.slot, count); @@ -572,17 +567,17 @@ DLL_EXPORT void ChangeStackCount::applyGs( CGameState *gs ) sl.army->changeStackCount(sl.slot, count); } -DLL_EXPORT void SetStackType::applyGs( CGameState *gs ) +DLL_LINKAGE void SetStackType::applyGs( CGameState *gs ) { sl.army->setStackType(sl.slot, type); } -DLL_EXPORT void EraseStack::applyGs( CGameState *gs ) +DLL_LINKAGE void EraseStack::applyGs( CGameState *gs ) { sl.army->eraseStack(sl.slot); } -DLL_EXPORT void SwapStacks::applyGs( CGameState *gs ) +DLL_LINKAGE void SwapStacks::applyGs( CGameState *gs ) { CStackInstance *s1 = sl1.army->detachStack(sl1.slot), *s2 = sl2.army->detachStack(sl2.slot); @@ -591,13 +586,13 @@ DLL_EXPORT void SwapStacks::applyGs( CGameState *gs ) sl1.army->putStack(sl1.slot, s2); } -DLL_EXPORT void InsertNewStack::applyGs( CGameState *gs ) +DLL_LINKAGE void InsertNewStack::applyGs( CGameState *gs ) { CStackInstance *s = new CStackInstance(stack.type, stack.count); sl.army->putStack(sl.slot, s); } -DLL_EXPORT void RebalanceStacks::applyGs( CGameState *gs ) +DLL_LINKAGE void RebalanceStacks::applyGs( CGameState *gs ) { const CCreature *srcType = src.army->getCreature(src.slot); TQuantity srcCount = src.army->getStackCount(src.slot); @@ -607,7 +602,7 @@ DLL_EXPORT void RebalanceStacks::applyGs( CGameState *gs ) if(const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> merge { assert(c == srcType); - if (STACK_EXP) + if (GameConstants::STACK_EXP) { ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot); src.army->eraseStack(src.slot); @@ -631,7 +626,7 @@ DLL_EXPORT void RebalanceStacks::applyGs( CGameState *gs ) if(const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> rebalance { assert(c == srcType); - if (STACK_EXP) + if (GameConstants::STACK_EXP) { ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot); src.army->changeStackCount(src.slot, -count); @@ -648,35 +643,35 @@ DLL_EXPORT void RebalanceStacks::applyGs( CGameState *gs ) { src.army->changeStackCount(src.slot, -count); dst.army->addToSlot(dst.slot, srcType->idNumber, count, false); - if (STACK_EXP) + if (GameConstants::STACK_EXP) dst.army->setStackExp(dst.slot, src.army->getStackExperience(src.slot)); } } } -DLL_EXPORT void PutArtifact::applyGs( CGameState *gs ) +DLL_LINKAGE void PutArtifact::applyGs( CGameState *gs ) { assert(art->canBePutAt(al)); al.hero->putArtifact(al.slot, art); } -DLL_EXPORT void EraseArtifact::applyGs( CGameState *gs ) +DLL_LINKAGE void EraseArtifact::applyGs( CGameState *gs ) { CArtifactInstance *a = al.getArt(); assert(a); a->removeFrom(al.hero, al.slot); } -DLL_EXPORT void MoveArtifact::applyGs( CGameState *gs ) +DLL_LINKAGE void MoveArtifact::applyGs( CGameState *gs ) { CArtifactInstance *a = src.getArt(); - if(dst.slot < Arts::BACKPACK_START) + if(dst.slot < GameConstants::BACKPACK_START) assert(!dst.getArt()); a->move(src, dst); } -DLL_EXPORT void AssembledArtifact::applyGs( CGameState *gs ) +DLL_LINKAGE void AssembledArtifact::applyGs( CGameState *gs ) { CGHeroInstance *h = al.hero; const CArtifactInstance *transformedArt = al.getArt(); @@ -703,7 +698,7 @@ DLL_EXPORT void AssembledArtifact::applyGs( CGameState *gs ) combinedArt->putAt(h, al.slot); } -DLL_EXPORT void DisassembledArtifact::applyGs( CGameState *gs ) +DLL_LINKAGE void DisassembledArtifact::applyGs( CGameState *gs ) { CGHeroInstance *h = al.hero; CCombinedArtifactInstance *disassembled = dynamic_cast(al.getArt()); @@ -720,7 +715,7 @@ DLL_EXPORT void DisassembledArtifact::applyGs( CGameState *gs ) gs->map->eraseArtifactInstance(disassembled); } -DLL_EXPORT void HeroVisit::applyGs( CGameState *gs ) +DLL_LINKAGE void HeroVisit::applyGs( CGameState *gs ) { if(starting) gs->ongoingVisits[hero] = obj; @@ -728,7 +723,7 @@ DLL_EXPORT void HeroVisit::applyGs( CGameState *gs ) gs->ongoingVisits.erase(hero); } -DLL_EXPORT void SetAvailableArtifacts::applyGs( CGameState *gs ) +DLL_LINKAGE void SetAvailableArtifacts::applyGs( CGameState *gs ) { if(id >= 0) { @@ -747,7 +742,7 @@ DLL_EXPORT void SetAvailableArtifacts::applyGs( CGameState *gs ) } } -DLL_EXPORT void NewTurn::applyGs( CGameState *gs ) +DLL_LINKAGE void NewTurn::applyGs( CGameState *gs ) { gs->day = day; BOOST_FOREACH(NewTurn::Hero h, heroes) //give mana/movement point @@ -759,7 +754,7 @@ DLL_EXPORT void NewTurn::applyGs( CGameState *gs ) for(std::map::iterator i = res.begin(); i != res.end(); i++) { - assert(i->first < PLAYER_LIMIT); + assert(i->first < GameConstants::PLAYER_LIMIT); gs->getPlayer(i->first)->resources = i->second; } @@ -785,7 +780,7 @@ DLL_EXPORT void NewTurn::applyGs( CGameState *gs ) t->builded = 0; } -DLL_EXPORT void SetObjectProperty::applyGs( CGameState *gs ) +DLL_LINKAGE void SetObjectProperty::applyGs( CGameState *gs ) { CGObjectInstance *obj = gs->map->objects[id]; if(!obj) @@ -797,12 +792,12 @@ DLL_EXPORT void SetObjectProperty::applyGs( CGameState *gs ) CArmedInstance *cai = dynamic_cast(obj); if(what == ObjProperty::OWNER && cai) { - if(obj->ID == TOWNI_TYPE) + if(obj->ID == GameConstants::TOWNI_TYPE) { CGTownInstance *t = static_cast(obj); - if(t->tempOwner < PLAYER_LIMIT) + if(t->tempOwner < GameConstants::PLAYER_LIMIT) gs->getPlayer(t->tempOwner)->towns -= t; - if(val < PLAYER_LIMIT) + if(val < GameConstants::PLAYER_LIMIT) gs->getPlayer(val)->towns.push_back(t); } @@ -817,12 +812,12 @@ DLL_EXPORT void SetObjectProperty::applyGs( CGameState *gs ) } } -DLL_EXPORT void SetHoverName::applyGs( CGameState *gs ) +DLL_LINKAGE void SetHoverName::applyGs( CGameState *gs ) { name.toString(gs->map->objects[id]->hoverName); } -DLL_EXPORT void HeroLevelUp::applyGs( CGameState *gs ) +DLL_LINKAGE void HeroLevelUp::applyGs( CGameState *gs ) { CGHeroInstance* h = gs->getHero(heroid); h->level = level; @@ -830,36 +825,36 @@ DLL_EXPORT void HeroLevelUp::applyGs( CGameState *gs ) h->UpdateSpeciality(); } -DLL_EXPORT void BattleStart::applyGs( CGameState *gs ) +DLL_LINKAGE void BattleStart::applyGs( CGameState *gs ) { gs->curB = info; gs->curB->localInit(); } -DLL_EXPORT void BattleNextRound::applyGs( CGameState *gs ) +DLL_LINKAGE void BattleNextRound::applyGs( CGameState *gs ) { gs->curB->castSpells[0] = gs->curB->castSpells[1] = 0; for (int i = 0; i < 2; ++i) { - amax(--gs->curB->enchanterCounter[i], 0); + vstd::amax(--gs->curB->enchanterCounter[i], 0); } gs->curB->round = round; BOOST_FOREACH(CStack *s, gs->curB->stacks) { - s->state -= DEFENDING; - s->state -= WAITING; - s->state -= MOVED; - s->state -= HAD_MORALE; - s->state -= FEAR; + s->state -= EBattleStackState::DEFENDING; + s->state -= EBattleStackState::WAITING; + s->state -= EBattleStackState::MOVED; + s->state -= EBattleStackState::HAD_MORALE; + s->state -= EBattleStackState::FEAR; s->counterAttacks = 1 + s->valOfBonuses(Bonus::ADDITIONAL_RETALIATION); // new turn effects s->battleTurnPassed(); } } -DLL_EXPORT void BattleSetActiveStack::applyGs( CGameState *gs ) +DLL_LINKAGE void BattleSetActiveStack::applyGs( CGameState *gs ) { gs->curB->activeStack = stack; CStack *st = gs->curB->getStack(stack); @@ -867,24 +862,24 @@ DLL_EXPORT void BattleSetActiveStack::applyGs( CGameState *gs ) //remove bonuses that last until when stack gets new turn st->getBonusList().remove_if(Bonus::UntilGetsTurn); - if(vstd::contains(st->state,MOVED)) //if stack is moving second time this turn it must had a high morale bonus - st->state.insert(HAD_MORALE); + if(vstd::contains(st->state,EBattleStackState::MOVED)) //if stack is moving second time this turn it must had a high morale bonus + st->state.insert(EBattleStackState::HAD_MORALE); } -DLL_EXPORT void BattleTriggerEffect::applyGs( CGameState *gs ) +DLL_LINKAGE void BattleTriggerEffect::applyGs( CGameState *gs ) { CStack *st = gs->curB->getStack(stackID); switch (effect) { case Bonus::HP_REGENERATION: st->firstHPleft += val; - amin (st->firstHPleft, (ui32)st->MaxHealth()); + vstd::amin (st->firstHPleft, (ui32)st->MaxHealth()); break; case Bonus::MANA_DRAIN: { CGHeroInstance * h = gs->getHero(additionalInfo); h->mana -= val; - amax(h->mana, 0); + vstd::amax(h->mana, 0); break; } case Bonus::POISON: @@ -897,7 +892,7 @@ DLL_EXPORT void BattleTriggerEffect::applyGs( CGameState *gs ) case Bonus::ENCHANTER: break; case Bonus::FEAR: - st->state.insert(FEAR); + st->state.insert(EBattleStackState::FEAR); break; default: tlog2 << "Unrecognized trigger effect type "<< type <<"\n"; @@ -909,7 +904,7 @@ void BattleResult::applyGs( CGameState *gs ) //stack with SUMMONED flag but coming from garrison -> most likely resurrected, needs to be removed BOOST_FOREACH(CStack *s, gs->curB->stacks) { - if(s->base && s->base->armyObj && vstd::contains(s->state, SUMMONED)) + if(s->base && s->base->armyObj && vstd::contains(s->state, EBattleStackState::SUMMONED)) { assert(&s->base->armyObj->getStack(s->slot) == s->base); const_cast(s->base->armyObj)->eraseStack(s->slot); @@ -928,7 +923,7 @@ void BattleResult::applyGs( CGameState *gs ) if(h) h->getBonusList().remove_if(Bonus::OneBattle); - if (STACK_EXP) + if (GameConstants::STACK_EXP) { if (exp[0]) //checking local array is easier than dereferencing this crap twice gs->curB->belligerents[0]->giveStackExp(exp[0]); @@ -945,7 +940,7 @@ void BattleStackMoved::applyGs( CGameState *gs ) gs->curB->getStack(stack)->position = tilesToMove.back(); } -DLL_EXPORT void BattleStackAttacked::applyGs( CGameState *gs ) +DLL_LINKAGE void BattleStackAttacked::applyGs( CGameState *gs ) { CStack * at = gs->curB->getStack(stackAttacked); at->count = newAmount; @@ -953,7 +948,7 @@ DLL_EXPORT void BattleStackAttacked::applyGs( CGameState *gs ) if(killed()) { - at->state -= ALIVE; + at->state -= EBattleStackState::ALIVE; } //life drain handling for (int g=0; gcasts--; - at->state.insert(ALIVE); //hmm? + at->state.insert(EBattleStackState::ALIVE); //hmm? } } -DLL_EXPORT void BattleAttack::applyGs( CGameState *gs ) +DLL_LINKAGE void BattleAttack::applyGs( CGameState *gs ) { CStack *attacker = gs->curB->getStack(stackAttacking); if(counter()) @@ -1003,7 +998,7 @@ DLL_EXPORT void BattleAttack::applyGs( CGameState *gs ) } } -DLL_EXPORT void StartAction::applyGs( CGameState *gs ) +DLL_LINKAGE void StartAction::applyGs( CGameState *gs ) { CStack *st = gs->curB->getStack(ba.stackNumber); @@ -1025,23 +1020,23 @@ DLL_EXPORT void StartAction::applyGs( CGameState *gs ) switch(ba.actionType) { case BattleAction::DEFEND: - st->state.insert(DEFENDING); + st->state.insert(EBattleStackState::DEFENDING); break; case BattleAction::WAIT: - st->state.insert(WAITING); + st->state.insert(EBattleStackState::WAITING); return; case BattleAction::HERO_SPELL: //no change in current stack state return; default: //any active stack action - attack, catapult, heal, spell... - st->state.insert(MOVED); + st->state.insert(EBattleStackState::MOVED); break; } if(st) - st->state -= WAITING; //if stack was waiting it has made move, so it won't be "waiting" anymore (if the action was WAIT, then we have returned) + st->state -= EBattleStackState::WAITING; //if stack was waiting it has made move, so it won't be "waiting" anymore (if the action was WAIT, then we have returned) } -DLL_EXPORT void BattleSpellCast::applyGs( CGameState *gs ) +DLL_LINKAGE void BattleSpellCast::applyGs( CGameState *gs ) { assert(gs->curB); if (castedByHero) @@ -1050,7 +1045,7 @@ DLL_EXPORT void BattleSpellCast::applyGs( CGameState *gs ) CGHeroInstance * enemy = gs->curB->heroes[1-side]; h->mana -= spellCost; - amax(h->mana, 0); + vstd::amax(h->mana, 0); if (enemy && manaGained) enemy->mana += manaGained; if (side >= 0 && side < 2) @@ -1102,7 +1097,7 @@ void actualizeEffect(CStack * s, const Bonus & ef) } } -DLL_EXPORT void SetStackEffect::applyGs( CGameState *gs ) +DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs ) { int spellid = effect.begin()->sid; //effects' source ID @@ -1142,22 +1137,22 @@ DLL_EXPORT void SetStackEffect::applyGs( CGameState *gs ) } } -DLL_EXPORT void StacksInjured::applyGs( CGameState *gs ) +DLL_LINKAGE void StacksInjured::applyGs( CGameState *gs ) { BOOST_FOREACH(BattleStackAttacked stackAttacked, stacks) stackAttacked.applyGs(gs); } -DLL_EXPORT void StacksHealedOrResurrected::applyGs( CGameState *gs ) +DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs ) { for(int g=0; gcurB->getStack(healedStacks[g].stackID, false); //checking if we resurrect a stack that is under a living stack - std::vector access = gs->curB->getAccessibility(changedStack, true); - bool acc[BFIELD_SIZE]; - for(int h=0; h access = gs->curB->getAccessibility(changedStack, true); + bool acc[GameConstants::BFIELD_SIZE]; + for(int h=0; halive(); //indicates if stack is resurrected or just healed if(resurrected) { - changedStack->state.insert(ALIVE); + changedStack->state.insert(EBattleStackState::ALIVE); if(healedStacks[g].lowLevelResurrection) - changedStack->state.insert(SUMMONED); //TODO: different counter for rised units + changedStack->state.insert(EBattleStackState::SUMMONED); //TODO: different counter for rised units } //int missingHPfirst = changedStack->MaxHealth() - changedStack->firstHPleft; int res = std::min( healedStacks[g].healedHP / changedStack->MaxHealth() , changedStack->baseAmount - changedStack->count ); @@ -1186,7 +1181,7 @@ DLL_EXPORT void StacksHealedOrResurrected::applyGs( CGameState *gs ) changedStack->count += 1; } } - amin(changedStack->firstHPleft, changedStack->MaxHealth()); + vstd::amin(changedStack->firstHPleft, changedStack->MaxHealth()); //removal of negative effects if(resurrected) { @@ -1215,7 +1210,7 @@ DLL_EXPORT void StacksHealedOrResurrected::applyGs( CGameState *gs ) } } -DLL_EXPORT void ObstaclesRemoved::applyGs( CGameState *gs ) +DLL_LINKAGE void ObstaclesRemoved::applyGs( CGameState *gs ) { if(gs->curB) //if there is a battle { @@ -1233,7 +1228,7 @@ DLL_EXPORT void ObstaclesRemoved::applyGs( CGameState *gs ) } } -DLL_EXPORT void CatapultAttack::applyGs( CGameState *gs ) +DLL_LINKAGE void CatapultAttack::applyGs( CGameState *gs ) { if(gs->curB && gs->curB->siege != 0) //if there is a battle and it's a siege { @@ -1245,7 +1240,7 @@ DLL_EXPORT void CatapultAttack::applyGs( CGameState *gs ) } } -DLL_EXPORT void BattleStacksRemoved::applyGs( CGameState *gs ) +DLL_LINKAGE void BattleStacksRemoved::applyGs( CGameState *gs ) { if(!gs->curB) return; @@ -1263,9 +1258,9 @@ DLL_EXPORT void BattleStacksRemoved::applyGs( CGameState *gs ) } } -DLL_EXPORT void BattleStackAdded::applyGs(CGameState *gs) +DLL_LINKAGE void BattleStackAdded::applyGs(CGameState *gs) { - if (!THex(pos).isValid()) + if (!SHexField(pos).isValid()) { tlog2 << "No place found for new stack!\n"; return; @@ -1274,13 +1269,13 @@ DLL_EXPORT void BattleStackAdded::applyGs(CGameState *gs) csi->setArmyObj(gs->curB->belligerents[attacker ? 0 : 1]); CStack * summonedStack = gs->curB->generateNewStack(*csi, gs->curB->stacks.size(), attacker, 255, pos); //TODO: netpacks? if (summoned) - summonedStack->state.insert(SUMMONED); + summonedStack->state.insert(EBattleStackState::SUMMONED); summonedStack->attachTo(csi); summonedStack->postInit(); gs->curB->stacks.push_back(summonedStack); //the stack is not "SUMMONED", it is permanent } -DLL_EXPORT void BattleSetStackProperty::applyGs(CGameState *gs) +DLL_LINKAGE void BattleSetStackProperty::applyGs(CGameState *gs) { CStack * stack = gs->curB->getStack(stackID); switch (which) @@ -1291,7 +1286,7 @@ DLL_EXPORT void BattleSetStackProperty::applyGs(CGameState *gs) stack->casts = val; else stack->casts += val; - amax(stack->casts, 0); + vstd::amax(stack->casts, 0); break; } case ENCHANTER_COUNTER: @@ -1301,7 +1296,7 @@ DLL_EXPORT void BattleSetStackProperty::applyGs(CGameState *gs) gs->curB->enchanterCounter[side] = val; else gs->curB->enchanterCounter[side] += val; - amax(gs->curB->enchanterCounter[side], 0); + vstd::amax(gs->curB->enchanterCounter[side], 0); break; } case UNBIND: @@ -1312,17 +1307,17 @@ DLL_EXPORT void BattleSetStackProperty::applyGs(CGameState *gs) } } -DLL_EXPORT void YourTurn::applyGs( CGameState *gs ) +DLL_LINKAGE void YourTurn::applyGs( CGameState *gs ) { gs->currentPlayer = player; } -DLL_EXPORT void SetSelection::applyGs( CGameState *gs ) +DLL_LINKAGE void SetSelection::applyGs( CGameState *gs ) { gs->getPlayer(player)->currentSelection = id; } -DLL_EXPORT Component::Component(const CStackBasicDescriptor &stack) +DLL_LINKAGE Component::Component(const CStackBasicDescriptor &stack) :id(CREATURE), subtype(stack.type->idNumber), val(stack.count), when(0) { diff --git a/lib/RegisterTypes.h b/lib/RegisterTypes.h index e282d2319..1d20a88e3 100644 --- a/lib/RegisterTypes.h +++ b/lib/RegisterTypes.h @@ -1,21 +1,13 @@ #pragma once -//templates for registering object types -//first set of types - derivatives of CGObjectInstance -template DLL_EXPORT -void registerTypes1(Serializer &s); - - -//second set of types - derivatives of CPack for client (network VCMI packages) -template DLL_EXPORT -void registerTypes2(Serializer &s); - -template DLL_EXPORT -void registerTypes3(Serializer &s); - -//register all -template DLL_EXPORT -void registerTypes(Serializer &s); +#include "Connection.h" +#include "NetPacks.h" +#include "VCMI_Lib.h" +#include "CArtHandler.h" +#include "CObjectHandler.h" +#include "CGameState.h" +#include "CHeroHandler.h" +#include "CTownHandler.h" /* * RegisterTypes.h, part of VCMI engine @@ -25,4 +17,222 @@ void registerTypes(Serializer &s); * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * - */ \ No newline at end of file + */ + +template +void registerTypes1(Serializer &s) +{ + //map objects + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + //end of objects + s.template registerType(); + s.template registerType(); + + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); +} + +template +void registerTypes2(Serializer &s) +{ + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + //s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + //s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); +} + +template +void registerTypes3(Serializer &s) +{ + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); +} + +template +void registerTypes4(Serializer &s) +{ + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); + s.template registerType(); +} + +template +void registerTypes(Serializer &s) +{ + registerTypes1(s); + registerTypes2(s); + registerTypes3(s); + registerTypes4(s); +} \ No newline at end of file diff --git a/lib/ResourceSet.cpp b/lib/ResourceSet.cpp index b5cb6edc5..ffcb4f229 100644 --- a/lib/ResourceSet.cpp +++ b/lib/ResourceSet.cpp @@ -1,9 +1,10 @@ -#define VCMI_DLL +#include "StdInc.h" #include "ResourceSet.h" +#include "GameConstants.h" Res::ResourceSet::ResourceSet() { - resize(RESOURCE_QUANTITY, 0); + resize(GameConstants::RESOURCE_QUANTITY, 0); } bool Res::ResourceSet::nonZero() const @@ -18,7 +19,7 @@ bool Res::ResourceSet::nonZero() const void Res::ResourceSet::amax(const TResource &val) { for(int i = 0; i < size(); i++) - ::amax(at(i), val); + ::vstd::amax(at(i), val); } bool Res::ResourceSet::canBeAfforded(const ResourceSet &res) const @@ -33,8 +34,8 @@ bool Res::ResourceSet::canAfford(const ResourceSet &price) const bool Res::canAfford(const ResourceSet &res, const ResourceSet &price) { - assert(res.size() == price.size() && price.size() == RESOURCE_QUANTITY); - for(int i = 0; i < RESOURCE_QUANTITY; i++) + assert(res.size() == price.size() && price.size() == GameConstants::RESOURCE_QUANTITY); + for(int i = 0; i < GameConstants::RESOURCE_QUANTITY; i++) if(price[i] > res[i]) return false; @@ -43,7 +44,7 @@ bool Res::canAfford(const ResourceSet &res, const ResourceSet &price) bool Res::ResourceSet::nziterator::valid() { - return cur.resType < RESOURCE_QUANTITY && cur.resVal; + return cur.resType < GameConstants::RESOURCE_QUANTITY && cur.resVal; } Res::ResourceSet::nziterator Res::ResourceSet::nziterator::operator++() @@ -74,9 +75,9 @@ void Res::ResourceSet::nziterator::advance() do { cur.resType++; - } while(cur.resType < RESOURCE_QUANTITY && !(cur.resVal=rs[cur.resType])); + } while(cur.resType < GameConstants::RESOURCE_QUANTITY && !(cur.resVal=rs[cur.resType])); - if(cur.resType >= RESOURCE_QUANTITY) + if(cur.resType >= GameConstants::RESOURCE_QUANTITY) cur.resVal = -1; } diff --git a/lib/ResourceSet.h b/lib/ResourceSet.h index a9cc49ff3..d6ad8d4ab 100644 --- a/lib/ResourceSet.h +++ b/lib/ResourceSet.h @@ -1,6 +1,6 @@ #pragma once -#include "../global.h" + #include typedef si32 TResource; @@ -19,11 +19,11 @@ namespace Res class ResourceSet : public std::vector { public: - DLL_EXPORT ResourceSet(); + DLL_LINKAGE ResourceSet(); #define scalarOperator(OPSIGN) \ - DLL_EXPORT ResourceSet operator OPSIGN(const TResource &rhs) const \ + DLL_LINKAGE ResourceSet operator OPSIGN(const TResource &rhs) const \ { \ ResourceSet ret = *this; \ for(int i = 0; i < size(); i++) \ @@ -35,7 +35,7 @@ namespace Res #define vectorOperator(OPSIGN) \ - DLL_EXPORT ResourceSet operator OPSIGN(const ResourceSet &rhs) const \ + DLL_LINKAGE ResourceSet operator OPSIGN(const ResourceSet &rhs) const \ { \ ResourceSet ret = *this; \ for(int i = 0; i < size(); i++) \ @@ -46,7 +46,7 @@ namespace Res #define opEqOperator(OPSIGN, RHS_TYPE) \ - DLL_EXPORT ResourceSet& operator OPSIGN ## =(const RHS_TYPE &rhs) \ + DLL_LINKAGE ResourceSet& operator OPSIGN ## =(const RHS_TYPE &rhs) \ { \ return *this = *this OPSIGN rhs; \ } @@ -68,12 +68,12 @@ namespace Res #undef opEqOperator //to be used for calculations of type "how many units of sth can I afford?" - DLL_EXPORT int operator/(const ResourceSet &rhs) + DLL_LINKAGE int operator/(const ResourceSet &rhs) { int ret = INT_MAX; for(int i = 0; i < size(); i++) if(rhs[i]) - amin(ret, at(i) / rhs[i]); + vstd::amin(ret, at(i) / rhs[i]); return ret; } @@ -94,13 +94,13 @@ namespace Res h & static_cast&>(*this); } - DLL_EXPORT void amax(const TResource &val); //performs amax on each element - DLL_EXPORT bool nonZero() const; //returns true if at least one value is non-zero; - DLL_EXPORT bool canAfford(const ResourceSet &price) const; - DLL_EXPORT bool canBeAfforded(const ResourceSet &res) const; + DLL_LINKAGE void amax(const TResource &val); //performs vstd::amax on each element + DLL_LINKAGE bool nonZero() const; //returns true if at least one value is non-zero; + DLL_LINKAGE bool canAfford(const ResourceSet &price) const; + DLL_LINKAGE bool canBeAfforded(const ResourceSet &res) const; //special iterator of iterating over non-zero resources in set - class DLL_EXPORT nziterator + class DLL_LINKAGE nziterator { struct ResEntry { diff --git a/lib/VCMIDirs.h b/lib/VCMIDirs.h index ffe45f9ee..e840fbd97 100644 --- a/lib/VCMIDirs.h +++ b/lib/VCMIDirs.h @@ -1,8 +1,9 @@ -#ifndef __VCMIDIRS_H__ -#define __VCMIDIRS_H__ +#pragma once + +#include "GameConstants.h" /* - * UserHome.h, part of VCMI engine + * VCMIDirs.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * @@ -25,7 +26,7 @@ public: VCMIDirs() { #ifdef _WIN32 - UserPath = DATA_DIR; + UserPath = GameConstants::DATA_DIR; #else try { #ifdef ANDROID @@ -52,5 +53,3 @@ public: } }; extern VCMIDirs GVCMIDirs; - -#endif // __VCMIDIRS_H__ diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index c7aa98012..5add0d34f 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -1,6 +1,7 @@ -#define VCMI_DLL -#include "../global.h" +#include "StdInc.h" #include "VCMI_Lib.h" + + #include "CArtHandler.h" #include "CCreatureHandler.h" #include "CDefObjInfoHandler.h" @@ -12,6 +13,7 @@ #include "CSpellHandler.h" #include "CGeneralTextHandler.h" #include "IGameEventsReceiver.h" +#include "StopWatch.h" /* * VCMI_Lib.cpp, part of VCMI engine @@ -25,23 +27,12 @@ class CLodHandler; LibClasses * VLC = NULL; -DLL_EXPORT CLodHandler *bitmaph = NULL, +DLL_LINKAGE CLodHandler *bitmaph = NULL, *spriteh = NULL, *bitmaph_ab = NULL; -DLL_EXPORT CLogger tlog0(0); -DLL_EXPORT CLogger tlog1(1); -DLL_EXPORT CLogger tlog2(2); -DLL_EXPORT CLogger tlog3(3); -DLL_EXPORT CLogger tlog4(4); -DLL_EXPORT CLogger tlog5(5); -DLL_EXPORT CLogger tlog6(-2); - -DLL_EXPORT CConsoleHandler *console = NULL; -DLL_EXPORT std::ostream *logfile = NULL -; -DLL_EXPORT void initDLL(CConsoleHandler *Console, std::ostream *Logfile) +DLL_LINKAGE void initDLL(CConsoleHandler *Console, std::ostream *Logfile) { console = Console; logfile = Logfile; @@ -49,10 +40,11 @@ DLL_EXPORT void initDLL(CConsoleHandler *Console, std::ostream *Logfile) try { VLC->init(); - } HANDLE_EXCEPTION; + } + HANDLE_EXCEPTION; } -DLL_EXPORT void loadToIt(std::string &dest, const std::string &src, int &iter, int mode) +DLL_LINKAGE void loadToIt(std::string &dest, const std::string &src, int &iter, int mode) { switch(mode) { @@ -160,7 +152,7 @@ DLL_EXPORT void loadToIt(std::string &dest, const std::string &src, int &iter, i } -DLL_EXPORT void loadToIt(si32 &dest, const std::string &src, int &iter, int mode) +DLL_LINKAGE void loadToIt(si32 &dest, const std::string &src, int &iter, int mode) { std::string pom; loadToIt(pom,src,iter,mode); @@ -169,45 +161,45 @@ DLL_EXPORT void loadToIt(si32 &dest, const std::string &src, int &iter, int mode void LibClasses::init() { - timeHandler pomtime; + StopWatch pomtime; generaltexth = new CGeneralTextHandler; generaltexth->load(); - tlog0<<"\tGeneral text handler: "<loadHeroes(); heroh->loadObstacles(); heroh->loadPuzzleInfo(); - tlog0 <<"\tHero handler: "<loadArtifacts(false); - tlog0<<"\tArtifact handler: "<loadCreatures(); - tlog0<<"\tCreature handler: "<loadStructures(); - tlog0<<"\tTown handler: "<loadObjects(); - tlog0<<"\tObject handler: "<load(); - tlog0<<"\tDef information handler: "<loadBuildings(); - tlog0<<"\tBuilding handler: "<loadSpells(); - tlog0<<"\tSpell handler: "<init(DATA_DIR "/Data/H3sprite.lod", DATA_DIR "/Sprites"); + spriteh->init(GameConstants::DATA_DIR + "/Data/H3sprite.lod", GameConstants::DATA_DIR + "/Sprites"); bitmaph = new CLodHandler; - bitmaph->init(DATA_DIR "/Data/H3bitmap.lod", DATA_DIR "/Data"); + bitmaph->init(GameConstants::DATA_DIR + "/Data/H3bitmap.lod", GameConstants::DATA_DIR + "/Data"); bitmaph_ab = new CLodHandler(); - bitmaph_ab->init(DATA_DIR "/Data/H3ab_bmp.lod", DATA_DIR "/Data"); - tlog0<<"Loading .lod files: "<init(GameConstants::DATA_DIR + "/Data/H3ab_bmp.lod", GameConstants::DATA_DIR + "/Data"); + tlog0<<"Loading .lod files: "<false EnableFastChecks MultiThreadedDebugDLL - Level1 + Level3 EditAndContinue 4251;%(DisableSpecificWarnings) false NoListing false + Use + StdInc.h + $(IntDir)StdInc.h.pch + VCMI_DLL;%(PreprocessorDefinitions) zlib.lib;%(AdditionalDependencies) @@ -209,13 +213,12 @@ - - + @@ -225,30 +228,36 @@ + + - - + + + VCMI_DLL;%(PreprocessorDefinitions) + Create + StdInc.h + - + - + @@ -258,6 +267,7 @@ + @@ -266,16 +276,23 @@ + + + + + + + diff --git a/lib/map.cpp b/lib/map.cpp index d9c13ae08..92f65b962 100644 --- a/lib/map.cpp +++ b/lib/map.cpp @@ -1,6 +1,6 @@ -#define VCMI_DLL -#include "../stdafx.h" +#include "StdInc.h" #include "map.h" + #include "CObjectHandler.h" #include "CDefObjInfoHandler.h" #include "VCMI_Lib.h" @@ -9,12 +9,11 @@ #include "CLodHandler.h" #include "CArtHandler.h" #include "CCreatureHandler.h" -#include -#include #include "CSpellHandler.h" -#include #include "../lib/JsonNode.h" #include "vcmi_endian.h" +#include "GameConstants.h" +#include "StopWatch.h" /* * map.cpp, part of VCMI engine @@ -32,7 +31,7 @@ static std::set convertBuildings(const std::set h3m, int castleID, b std::set ret; // Note: this file is parsed many times. - const JsonNode config(DATA_DIR "/config/buildings5.json"); + const JsonNode config(GameConstants::DATA_DIR + "/config/buildings5.json"); BOOST_FOREACH(const JsonNode &entry, config["table"].Vector()) { @@ -46,7 +45,7 @@ static std::set convertBuildings(const std::set h3m, int castleID, b { if(mapa[*i]>=0) ret.insert(mapa[*i]); - else if(mapa[*i] >= (-CREATURES_PER_TOWN)) // horde buildings + else if(mapa[*i] >= (-GameConstants::CREATURES_PER_TOWN)) // horde buildings { int level = (mapa[*i]); ret.insert(level-30);//(-30)..(-36) - horde buildings (for game loading only), don't see other way to handle hordes in random towns @@ -73,16 +72,16 @@ static std::set convertBuildings(const std::set h3m, int castleID, b return ret; } -static unsigned int intPow(unsigned int a, unsigned int b) +static ui32 intPow(ui32 a, ui32 b) { - unsigned int ret=1; - for(unsigned int i=0; i>i) @@ -93,7 +92,7 @@ static unsigned char reverse(unsigned char arg) return ret; } -void readCreatureSet(CCreatureSet *out, const unsigned char * bufor, int &i, int number, bool version) //version==true for >RoE maps +void readCreatureSet(CCreatureSet *out, const ui8 * bufor, int &i, int number, bool version) //version==true for >RoE maps { const int bytesPerCre = version ? 4 : 3, maxID = version ? 0xffff : 0xff; @@ -135,7 +134,7 @@ void readCreatureSet(CCreatureSet *out, const unsigned char * bufor, int &i, int out->validTypes(true); } -CMapHeader::CMapHeader(const unsigned char *map) +CMapHeader::CMapHeader(const ui8 *map) { int i=0; initFromMemory(map,i); @@ -147,7 +146,7 @@ CMapHeader::CMapHeader() height = width = twoLevel = -1; } -void CMapHeader::initFromMemory( const unsigned char *bufor, int &i ) +void CMapHeader::initFromMemory( const ui8 *bufor, int &i ) { version = (Eformat)(read_le_u32(bufor + i)); i+=4; //map version if(version != RoE && version != AB && version != SoD && version != WoG) @@ -178,20 +177,20 @@ void CMapHeader::initFromMemory( const unsigned char *bufor, int &i ) } else//no alliances { - for(int i=0;iRoE) //probably reserved for further heroes @@ -201,7 +200,7 @@ void CMapHeader::initFromMemory( const unsigned char *bufor, int &i ) placeholdedHeroes.push_back(bufor[i++]); } } -void CMapHeader::loadPlayerInfo( int &pom, const unsigned char * bufor, int &i ) +void CMapHeader::loadPlayerInfo( int &pom, const ui8 * bufor, int &i ) { players.resize(8); for (pom=0;pom<8;pom++) @@ -288,22 +287,22 @@ void CMapHeader::loadPlayerInfo( int &pom, const unsigned char * bufor, int &i ) } } -void CMapHeader::loadViCLossConditions( const unsigned char * bufor, int &i) +void CMapHeader::loadViCLossConditions( const ui8 * bufor, int &i) { victoryCondition.obj = NULL; - victoryCondition.condition = (EvictoryConditions)bufor[i++]; - if (victoryCondition.condition != winStandard) //specific victory conditions + victoryCondition.condition = (EVictoryConditionType::EVictoryConditionType)bufor[i++]; + if (victoryCondition.condition != EVictoryConditionType::WINSTANDARD) //specific victory conditions { int nr; switch (victoryCondition.condition) //read victory conditions { - case artifact: + case EVictoryConditionType::ARTIFACT: { victoryCondition.ID = bufor[i+2]; nr=(version==RoE ? 1 : 2); break; } - case gatherTroop: + case EVictoryConditionType::GATHERTROOP: { // int temp1 = bufor[i+2]; // int temp2 = bufor[i+3]; @@ -312,14 +311,14 @@ void CMapHeader::loadViCLossConditions( const unsigned char * bufor, int &i) nr=(version==RoE ? 5 : 6); break; } - case gatherResource: + case EVictoryConditionType::GATHERRESOURCE: { victoryCondition.ID = bufor[i+2]; victoryCondition.count = read_le_u32(bufor + i+3); nr = 5; break; } - case buildCity: + case EVictoryConditionType::BUILDCITY: { victoryCondition.pos.x = bufor[i+2]; victoryCondition.pos.y = bufor[i+3]; @@ -329,7 +328,7 @@ void CMapHeader::loadViCLossConditions( const unsigned char * bufor, int &i) nr = 5; break; } - case buildGrail: + case EVictoryConditionType::BUILDGRAIL: { if (bufor[i+4]>2) victoryCondition.pos = int3(-1,-1,-1); @@ -342,9 +341,9 @@ void CMapHeader::loadViCLossConditions( const unsigned char * bufor, int &i) nr = 3; break; } - case beatHero: - case captureCity: - case beatMonster: + case EVictoryConditionType::BEATHERO: + case EVictoryConditionType::CAPTURECITY: + case EVictoryConditionType::BEATMONSTER: { victoryCondition.pos.x = bufor[i+2]; victoryCondition.pos.y = bufor[i+3]; @@ -352,13 +351,13 @@ void CMapHeader::loadViCLossConditions( const unsigned char * bufor, int &i) nr = 3; break; } - case takeDwellings: - case takeMines: + case EVictoryConditionType::TAKEDWELLINGS: + case EVictoryConditionType::TAKEMINES: { nr = 0; break; } - case transportItem: + case EVictoryConditionType::TRANSPORTITEM: { victoryCondition.ID = bufor[i+2]; victoryCondition.pos.x = bufor[i+3]; @@ -372,18 +371,18 @@ void CMapHeader::loadViCLossConditions( const unsigned char * bufor, int &i) victoryCondition.appliesToAI = bufor[i++]; i+=nr; } - lossCondition.typeOfLossCon = (ElossCon)bufor[i++]; + lossCondition.typeOfLossCon = (ELossConditionType::ELossConditionType)bufor[i++]; switch (lossCondition.typeOfLossCon) //read loss conditions { - case lossCastle: - case lossHero: + case ELossConditionType::LOSSCASTLE: + case ELossConditionType::LOSSHERO: { lossCondition.pos.x=bufor[i++]; lossCondition.pos.y=bufor[i++]; lossCondition.pos.z=bufor[i++]; break; } - case timeExpires: + case ELossConditionType::TIMEEXPIRES: { lossCondition.timeLimit = read_le_u16(bufor + i); i+=2; @@ -397,7 +396,7 @@ CMapHeader::~CMapHeader() } -void Mapa::initFromBytes(const unsigned char * bufor, size_t size) +void Mapa::initFromBytes(const ui8 * bufor, size_t size) { // Compute checksum boost::crc_32_type result; @@ -407,42 +406,42 @@ void Mapa::initFromBytes(const unsigned char * bufor, size_t size) int i=0; initFromMemory(bufor,i); - timeHandler th; - th.getDif(); + StopWatch th; + th.getDiff(); readHeader(bufor, i); - tlog0<<"\tReading header: "<defInfo) continue; addBlockVisTiles(objects[f]); } - tlog0<<"\tCalculating blocked/visitable tiles: "<subID == ID) return heroes[i]; return NULL; } -int Mapa::loadSeerHut( const unsigned char * bufor, int i, CGObjectInstance *& nobj ) +int Mapa::loadSeerHut( const ui8 * bufor, int i, CGObjectInstance *& nobj ) { CGSeerHut *hut = new CGSeerHut(); nobj = hut; @@ -581,7 +580,7 @@ int Mapa::loadSeerHut( const unsigned char * bufor, int i, CGObjectInstance *& n if(hut->missionType) { - unsigned char rewardType = bufor[i]; ++i; + ui8 rewardType = bufor[i]; ++i; hut->rewardType = rewardType; switch(rewardType) @@ -667,7 +666,7 @@ int Mapa::loadSeerHut( const unsigned char * bufor, int i, CGObjectInstance *& n return i; } -void Mapa::loadTown( CGObjectInstance * &nobj, const unsigned char * bufor, int &i, int subid) +void Mapa::loadTown( CGObjectInstance * &nobj, const ui8 * bufor, int &i, int subid) { CGTownInstance * nt = new CGTownInstance(); //(*(static_cast(nt))) = *nobj; @@ -717,12 +716,12 @@ void Mapa::loadTown( CGObjectInstance * &nobj, const unsigned char * bufor, int { for(; iobligatorySpells.push_back((i-ist)*8+yy); } } @@ -732,12 +731,12 @@ void Mapa::loadTown( CGObjectInstance * &nobj, const unsigned char * bufor, int ist = i; for(; ipossibleSpells.push_back((i-ist)*8+yy); } } @@ -805,7 +804,7 @@ void Mapa::loadTown( CGObjectInstance * &nobj, const unsigned char * bufor, int nt->garrisonHero = NULL; } -CGObjectInstance * Mapa::loadHero(const unsigned char * bufor, int &i, int idToBeGiven) +CGObjectInstance * Mapa::loadHero(const ui8 * bufor, int &i, int idToBeGiven) { CGHeroInstance * nhi = new CGHeroInstance(); @@ -819,7 +818,7 @@ CGObjectInstance * Mapa::loadHero(const unsigned char * bufor, int &i, int idToB ui8 owner = bufor[i++]; nhi->subID = bufor[i++]; - for(unsigned int j=0; jsubID == nhi->subID) { @@ -833,7 +832,7 @@ CGObjectInstance * Mapa::loadHero(const unsigned char * bufor, int &i, int idToB nhi->portrait = nhi->subID; - for(unsigned int j=0; jsubID) { @@ -904,12 +903,12 @@ CGObjectInstance * Mapa::loadHero(const unsigned char * bufor, int &i, int idToB int ist = i; for(; ispells.insert((i-ist)*8+yy); } } @@ -918,7 +917,7 @@ CGObjectInstance * Mapa::loadHero(const unsigned char * bufor, int &i, int idToB } else if(version==AB) //we can read one spell { - unsigned char buff = bufor[i]; ++i; + ui8 buff = bufor[i]; ++i; if(buff != 254) { nhi->spells.insert(0xffffffff); //placeholder "preset spells" @@ -940,7 +939,7 @@ CGObjectInstance * Mapa::loadHero(const unsigned char * bufor, int &i, int idToB return nhi; } -void Mapa::readRumors( const unsigned char * bufor, int &i) +void Mapa::readRumors( const ui8 * bufor, int &i) { int rumNr = read_le_u32(bufor + i);i+=4; for (int it=0;it=SoD) { @@ -979,8 +978,8 @@ void Mapa::readHeader( const unsigned char * bufor, int &i) i+=31; //omitting NULLS - allowedArtifact.resize(ARTIFACTS_QUANTITY); - for (unsigned int x=0; x=SoD) @@ -1027,10 +1026,10 @@ void Mapa::readHeader( const unsigned char * bufor, int &i) ist=i; //starting i for loop for(; iID = HEROI_TYPE; + cgh->ID = GameConstants::HEROI_TYPE; cgh->subID = z; if(readChar(bufor,i))//true if hore's experience is greater than 0 { cgh->exp = read_le_u32(bufor + i); i+=4; } @@ -1091,12 +1090,12 @@ void Mapa::readPredefinedHeroes( const unsigned char * bufor, int &i) int ist = i; for(; ispells.insert((i-ist)*8+yy); } } @@ -1117,7 +1116,7 @@ void Mapa::readPredefinedHeroes( const unsigned char * bufor, int &i) } } -void Mapa::readTerrain( const unsigned char * bufor, int &i) +void Mapa::readTerrain( const ui8 * bufor, int &i) { terrain = new TerrainTile**[width]; // allocate memory for (int ii=0;iiname.begin(),vinya->name.end(),vinya->name.begin(),(int(*)(int))toupper); - unsigned char bytes[12]; + ui8 bytes[12]; for (int v=0; v<12; v++) // read info { bytes[v] = bufor[i++]; @@ -1200,7 +1199,7 @@ void Mapa::readDefInfo( const unsigned char * bufor, int &i) vinya->visitMap[zi] = reverse(bytes[6+zi]); } i+=16; - if(vinya->id!=HEROI_TYPE && vinya->id!=70) + if(vinya->id!=GameConstants::HEROI_TYPE && vinya->id!=70) { CGDefInfo *h = VLC->dobjinfo->gobjs[vinya->id][vinya->subid]; if(!h) @@ -1221,7 +1220,7 @@ void Mapa::readDefInfo( const unsigned char * bufor, int &i) vinya->visitDir = 0xff; } - if(vinya->id == EVENTI_TYPE) + if(vinya->id == GameConstants::EVENTI_TYPE) std::memset(vinya->blockMap,255,6); //calculating coverageMap @@ -1246,7 +1245,7 @@ public: } }; -void Mapa::readObjects( const unsigned char * bufor, int &i) +void Mapa::readObjects( const ui8 * bufor, int &i) { int howManyObjs = read_le_u32(bufor + i); i+=4; for(int ww=0; wwid) { - case EVENTI_TYPE: //for event objects + case GameConstants::EVENTI_TYPE: //for event objects { CGEvent *evnt = new CGEvent(); nobj = evnt; @@ -1291,17 +1290,17 @@ void Mapa::readObjects( const unsigned char * bufor, int &i) } evnt->gainedExp = read_le_u32(bufor + i); i+=4; evnt->manaDiff = read_le_u32(bufor + i); i+=4; - evnt->moraleDiff = (si8)bufor[i]; ++i; - evnt->luckDiff = (si8)bufor[i]; ++i; + evnt->moraleDiff = (char)bufor[i]; ++i; + evnt->luckDiff = (char)bufor[i]; ++i; - evnt->resources.resize(RESOURCE_QUANTITY); + evnt->resources.resize(GameConstants::RESOURCE_QUANTITY); for(int x=0; x<7; x++) { evnt->resources[x] = read_le_u32(bufor + i); i+=4; } - evnt->primskills.resize(PRIMARY_SKILLS); + evnt->primskills.resize(GameConstants::PRIMARY_SKILLS); for(int x=0; x<4; x++) { evnt->primskills[x] = bufor[i]; @@ -1415,7 +1414,7 @@ void Mapa::readObjects( const unsigned char * bufor, int &i) if(isMesTre) { cre->message = readString(bufor,i); - cre->resources.resize(RESOURCE_QUANTITY); + cre->resources.resize(GameConstants::RESOURCE_QUANTITY); for(int j=0; j<7; j++) { cre->resources[j] = read_le_u32(bufor + i); i+=4; @@ -1473,12 +1472,12 @@ void Mapa::readObjects( const unsigned char * bufor, int &i) int ist=i; //starting i for loop for(; iallowedAbilities.push_back((i-ist)*8+yy); } } @@ -1486,7 +1485,7 @@ void Mapa::readObjects( const unsigned char * bufor, int &i) } else //(RoE map) { - for(int gg=0; ggallowedAbilities.push_back(gg); } @@ -1627,14 +1626,14 @@ void Mapa::readObjects( const unsigned char * bufor, int &i) box->moraleDiff = (si8)bufor[i]; ++i; box->luckDiff = (si8)bufor[i]; ++i; - box->resources.resize(RESOURCE_QUANTITY); + box->resources.resize(GameConstants::RESOURCE_QUANTITY); for(int x=0; x<7; x++) { box->resources[x] = read_le_u32(bufor + i); i+=4; } - box->primskills.resize(PRIMARY_SKILLS); + box->primskills.resize(GameConstants::PRIMARY_SKILLS); for(int x=0; x<4; x++) { box->primskills[x] = bufor[i]; @@ -1897,21 +1896,21 @@ void Mapa::readObjects( const unsigned char * bufor, int &i) nobj->pos = pos; nobj->ID = defInfo->id; nobj->id = idToBeGiven; - if(nobj->ID != HEROI_TYPE && nobj->ID != 214 && nobj->ID != 62) + if(nobj->ID != GameConstants::HEROI_TYPE && nobj->ID != 214 && nobj->ID != 62) nobj->subID = defInfo->subid; nobj->defInfo = defInfo; assert(idToBeGiven == objects.size()); objects.push_back(nobj); - if(nobj->ID==TOWNI_TYPE) + if(nobj->ID==GameConstants::TOWNI_TYPE) towns.push_back(static_cast(nobj)); - if(nobj->ID==HEROI_TYPE) + if(nobj->ID==GameConstants::HEROI_TYPE) heroes.push_back(static_cast(nobj)); } std::sort(heroes.begin(), heroes.end(), _HERO_SORTER()); } -void Mapa::readEvents( const unsigned char * bufor, int &i ) +void Mapa::readEvents( const ui8 * bufor, int &i ) { int numberOfEvents = read_le_u32(bufor + i); i+=4; for(int yyoo=0; yyoomissionType = bufor[i]; ++i; //int len1, len2, len3; @@ -2060,9 +2059,9 @@ const CGObjectInstance *Mapa::getObjectiveObjectFrom(int3 pos, bool lookForHero) { const std::vector &objs = getTile(pos).visitableObjects; assert(objs.size()); - if(objs.size() > 1 && lookForHero && objs.front()->ID != HEROI_TYPE) + if(objs.size() > 1 && lookForHero && objs.front()->ID != GameConstants::HEROI_TYPE) { - assert(objs.back()->ID == HEROI_TYPE); + assert(objs.back()->ID == GameConstants::HEROI_TYPE); return objs.back(); } else @@ -2072,10 +2071,10 @@ const CGObjectInstance *Mapa::getObjectiveObjectFrom(int3 pos, bool lookForHero) void Mapa::checkForObjectives() { if(isInTheMap(victoryCondition.pos)) - victoryCondition.obj = getObjectiveObjectFrom(victoryCondition.pos, victoryCondition.condition == beatHero); + victoryCondition.obj = getObjectiveObjectFrom(victoryCondition.pos, victoryCondition.condition == EVictoryConditionType::BEATHERO); if(isInTheMap(lossCondition.pos)) - lossCondition.obj = getObjectiveObjectFrom(lossCondition.pos, lossCondition.typeOfLossCon == lossHero); + lossCondition.obj = getObjectiveObjectFrom(lossCondition.pos, lossCondition.typeOfLossCon == ELossConditionType::LOSSHERO); } void Mapa::addNewArtifactInstance( CArtifactInstance *art ) @@ -2084,7 +2083,7 @@ void Mapa::addNewArtifactInstance( CArtifactInstance *art ) artInstances.push_back(art); } -bool Mapa::loadArtifactToSlot(CGHeroInstance *h, int slot, const unsigned char * bufor, int &i) +bool Mapa::loadArtifactToSlot(CGHeroInstance *h, int slot, const ui8 * bufor, int &i) { const int artmask = version == RoE ? 0xff : 0xffff; int aid; @@ -2101,16 +2100,16 @@ bool Mapa::loadArtifactToSlot(CGHeroInstance *h, int slot, const unsigned char * bool isArt = aid != artmask; if(isArt) { - if(vstd::contains(VLC->arth->bigArtifacts, aid) && slot >= Arts::BACKPACK_START) + if(vstd::contains(VLC->arth->bigArtifacts, aid) && slot >= GameConstants::BACKPACK_START) { tlog3 << "Warning: A big artifact (war machine) in hero's backpack, ignoring...\n"; return false; } - if(aid == 0 && slot == Arts::MISC5) + if(aid == 0 && slot == ArtifactPosition::MISC5) { //TODO: check how H3 handles it -> art 0 in slot 18 in AB map tlog3 << "Spellbook to MISC5 slot? Putting it spellbook place. AB format peculiarity ? (format " << (int)version << ")\n"; - slot = Arts::SPELLBOOK; + slot = ArtifactPosition::SPELLBOOK; } h->putArtifact(slot, createArt(aid)); @@ -2118,7 +2117,7 @@ bool Mapa::loadArtifactToSlot(CGHeroInstance *h, int slot, const unsigned char * return isArt; } -void Mapa::loadArtifactsOfHero(const unsigned char * bufor, int & i, CGHeroInstance * nhi) +void Mapa::loadArtifactsOfHero(const ui8 * bufor, int & i, CGHeroInstance * nhi) { bool artSet = bufor[i]; ++i; //true if artifact set is not default (hero has some artifacts) if(artSet) @@ -2129,22 +2128,22 @@ void Mapa::loadArtifactsOfHero(const unsigned char * bufor, int & i, CGHeroInsta //misc5 art //17 if(version >= SoD) { - if(!loadArtifactToSlot(nhi, Arts::MACH4, bufor, i)) - nhi->putArtifact(Arts::MACH4, createArt(Arts::ID_CATAPULT)); //catapult by default + if(!loadArtifactToSlot(nhi, ArtifactPosition::MACH4, bufor, i)) + nhi->putArtifact(ArtifactPosition::MACH4, createArt(GameConstants::ID_CATAPULT)); //catapult by default } - loadArtifactToSlot(nhi, Arts::SPELLBOOK, bufor, i); + loadArtifactToSlot(nhi, ArtifactPosition::SPELLBOOK, bufor, i); //19 //???what is that? gap in file or what? - it's probably fifth slot.. if(version > RoE) - loadArtifactToSlot(nhi, Arts::MISC5, bufor, i); + loadArtifactToSlot(nhi, ArtifactPosition::MISC5, bufor, i); else i+=1; //bag artifacts //20 int amount = read_le_u16(bufor + i); i+=2; //number of artifacts in hero's bag for(int ss = 0; ss < amount; ++ss) - loadArtifactToSlot(nhi, Arts::BACKPACK_START + nhi->artifactsInBackpack.size(), bufor, i); + loadArtifactToSlot(nhi, GameConstants::BACKPACK_START + nhi->artifactsInBackpack.size(), bufor, i); } //artifacts } diff --git a/lib/map.h b/lib/map.h index 50f150239..629fb80e6 100644 --- a/lib/map.h +++ b/lib/map.h @@ -1,14 +1,6 @@ -#ifndef __MAP_H__ -#define __MAP_H__ -#ifdef _MSC_VER -#pragma warning (disable : 4482) -#endif -#include -#include -#include -#include -#include -#include "../global.h" +#pragma once + + #ifndef _MSC_VER #include "CObjectHandler.h" #include "CDefObjInfoHandler.h" @@ -16,6 +8,8 @@ #include "ConstTransitivePtr.h" #include "ResourceSet.h" +#include "int3.h" +#include "GameConstants.h" /* * map.h, part of VCMI engine @@ -37,19 +31,19 @@ class CGTownInstance; class IModableArt; /// Struct which describes a single terrain tile -struct DLL_EXPORT TerrainTile +struct DLL_LINKAGE TerrainTile { enum EterrainType {border=-1, dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock}; enum Eriver {noRiver=0, clearRiver, icyRiver, muddyRiver, lavaRiver}; enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad}; EterrainType tertype; // type of terrain - unsigned char terview; // look of terrain + ui8 terview; // look of terrain Eriver nuine; // type of Eriver (0 if there is no river) - unsigned char rivDir; // direction of Eriver + ui8 rivDir; // direction of Eriver Eroad malle; // type of Eroad (0 if there is no river) - unsigned char roadDir; // direction of Eroad - unsigned char siodmyTajemniczyBajt; //first two bits - how to rotate terrain graphic (next two - river graphic, next two - road); 7th bit - whether tile is coastal (allows disembarking if land or block movement if water); 8th bit - Favourable Winds effect + ui8 roadDir; // direction of Eroad + ui8 siodmyTajemniczyBajt; //first two bits - how to rotate terrain graphic (next two - river graphic, next two - road); 7th bit - whether tile is coastal (allows disembarking if land or block movement if water); 8th bit - Favourable Winds effect bool visitable; //false = not visitable; true = visitable bool blocked; //false = free; true = blocked; @@ -78,7 +72,7 @@ struct DLL_EXPORT TerrainTile }; /// name of starting hero -struct DLL_EXPORT SheroName +struct DLL_LINKAGE SheroName { int heroID; std::string heroName; @@ -91,7 +85,7 @@ struct DLL_EXPORT SheroName /// Player information regarding map. Which factions are allowed, AI tactic setting, main hero name, /// position of main town,... -struct DLL_EXPORT PlayerInfo +struct DLL_LINKAGE PlayerInfo { si32 p7, p8, p9; ui8 powerPlacehodlers; //q-ty of hero placeholders containing hero type, WARNING: powerPlacehodlers sometimes gives false 0 (eg. even if there is one placeholder), maybe different meaning??? @@ -117,7 +111,7 @@ struct DLL_EXPORT PlayerInfo si8 defaultCastle() const { si8 ret = -2; - for (int j = 0; j < F_NUMBER && ret != -1; j++) //we start with none and find matching faction. if more than one, then set to random + for (int j = 0; j < GameConstants::F_NUMBER && ret != -1; j++) //we start with none and find matching faction. if more than one, then set to random { if((1 << j) & allowedFactions) { @@ -148,9 +142,9 @@ struct DLL_EXPORT PlayerInfo }; /// Small struct which holds information about the loss condition -struct DLL_EXPORT LossCondition +struct DLL_LINKAGE LossCondition { - ElossCon typeOfLossCon; + ELossConditionType::ELossConditionType typeOfLossCon; int3 pos; @@ -167,9 +161,9 @@ struct DLL_EXPORT LossCondition }; /// Small struct which holds information about the victory condition -struct DLL_EXPORT CVictoryCondition +struct DLL_LINKAGE CVictoryCondition { - EvictoryConditions condition; //ID of condition + EVictoryConditionType::EVictoryConditionType condition; //ID of condition ui8 allowNormalVictory, appliesToAI; int3 pos; //pos of city to upgrade (3); pos of town to build grail, {-1,-1,-1} if not relevant (4); hero pos (5); town pos(6); monster pos (7); destination pos(8) @@ -187,7 +181,7 @@ struct DLL_EXPORT CVictoryCondition }; /// Struct which holds a name and the rumor text -struct DLL_EXPORT Rumor +struct DLL_LINKAGE Rumor { std::string name, text; @@ -198,7 +192,7 @@ struct DLL_EXPORT Rumor }; /// Struct which describes who can hire this hero -struct DLL_EXPORT DisposedHero +struct DLL_LINKAGE DisposedHero { ui32 ID; ui16 portrait; //0xFF - default @@ -212,7 +206,7 @@ struct DLL_EXPORT DisposedHero }; /// Class which manages map events. -class DLL_EXPORT CMapEvent +class DLL_LINKAGE CMapEvent { public: std::string name, message; @@ -240,7 +234,7 @@ public: /// Sub-class derived by CMapEvent; This event can build specific buildings or add /// additional creatures in a town. -class DLL_EXPORT CCastleEvent: public CMapEvent +class DLL_LINKAGE CCastleEvent: public CMapEvent { public: std::set buildings;//build specific buildings @@ -255,7 +249,7 @@ public: }; /// Holds information about loss/victory condition, map format, version, players, height, width,... -class DLL_EXPORT CMapHeader +class DLL_LINKAGE CMapHeader { public: enum Eformat {invalid, WoG=0x33, AB=0x15, RoE=0x0e, SoD=0x1c}; @@ -272,10 +266,10 @@ public: ui8 howManyTeams; std::vector allowedHeroes; //allowedHeroes[hero_ID] - if the hero is allowed std::vector placeholdedHeroes; //ID of types of heroes in placeholders - void initFromMemory(const unsigned char *bufor, int &i); - void loadViCLossConditions( const unsigned char * bufor, int &i); - void loadPlayerInfo( int &pom, const unsigned char * bufor, int &i); - CMapHeader(const unsigned char *map); //an argument is a reference to string described a map (unpacked) + void initFromMemory(const ui8 *bufor, int &i); + void loadViCLossConditions( const ui8 * bufor, int &i); + void loadPlayerInfo( int &pom, const ui8 * bufor, int &i); + CMapHeader(const ui8 *map); //an argument is a reference to string described a map (unpacked) CMapHeader(); virtual ~CMapHeader(); @@ -289,7 +283,7 @@ public: /// Extends the base class and adds further map information like rumors, disposed heroes, /// allowed spells, artifacts, abilities and such things. -struct DLL_EXPORT Mapa : public CMapHeader +struct DLL_LINKAGE Mapa : public CMapHeader { ui32 checksum; TerrainTile*** terrain; @@ -314,21 +308,21 @@ struct DLL_EXPORT Mapa : public CMapHeader bmap questIdentifierToId; - void initFromBytes( const unsigned char * bufor, size_t size); //creates map from decompressed .h3m data + void initFromBytes( const ui8 * bufor, size_t size); //creates map from decompressed .h3m data - void readEvents( const unsigned char * bufor, int &i); - void readObjects( const unsigned char * bufor, int &i); - void loadQuest( CQuest * guard, const unsigned char * bufor, int & i); - void readDefInfo( const unsigned char * bufor, int &i); - void readTerrain( const unsigned char * bufor, int &i); - void readPredefinedHeroes( const unsigned char * bufor, int &i); - void readHeader( const unsigned char * bufor, int &i); - void readRumors( const unsigned char * bufor, int &i); - CGObjectInstance *loadHero(const unsigned char * bufor, int &i, int idToBeGiven); - void loadArtifactsOfHero(const unsigned char * bufor, int & i, CGHeroInstance * nhi); - bool loadArtifactToSlot(CGHeroInstance *h, int slot, const unsigned char * bufor, int &i); - void loadTown( CGObjectInstance * &nobj, const unsigned char * bufor, int &i, int subid); - int loadSeerHut( const unsigned char * bufor, int i, CGObjectInstance *& nobj); + void readEvents( const ui8 * bufor, int &i); + void readObjects( const ui8 * bufor, int &i); + void loadQuest( CQuest * guard, const ui8 * bufor, int & i); + void readDefInfo( const ui8 * bufor, int &i); + void readTerrain( const ui8 * bufor, int &i); + void readPredefinedHeroes( const ui8 * bufor, int &i); + void readHeader( const ui8 * bufor, int &i); + void readRumors( const ui8 * bufor, int &i); + CGObjectInstance *loadHero(const ui8 * bufor, int &i, int idToBeGiven); + void loadArtifactsOfHero(const ui8 * bufor, int & i, CGHeroInstance * nhi); + bool loadArtifactToSlot(CGHeroInstance *h, int slot, const ui8 * bufor, int &i); + void loadTown( CGObjectInstance * &nobj, const ui8 * bufor, int &i, int subid); + int loadSeerHut( const ui8 * bufor, int i, CGObjectInstance *& nobj); CArtifactInstance *createArt(int aid, int spellID = -1); void addNewArtifactInstance(CArtifactInstance *art); @@ -387,11 +381,11 @@ struct DLL_EXPORT Mapa : public CMapHeader // // if(h.saving) //create vector with all defs used on map // { -// for(unsigned int i=0; idefInfo->serial = -1; //set serial to serial -1 - indicates that def is not present in defs vector // -// for(unsigned int i=0; idefInfo; @@ -426,7 +420,7 @@ struct DLL_EXPORT Mapa : public CMapHeader h & CGObelisk::obeliskCount & CGObelisk::visited; h & CGTownInstance::merchantArtifacts; -// for(unsigned int i=0; iID == HEROI_TYPE) + if(objects[i]->ID == GameConstants::HEROI_TYPE) heroes.push_back(static_cast(+objects[i])); - else if(objects[i]->ID == TOWNI_TYPE) + else if(objects[i]->ID == GameConstants::TOWNI_TYPE) towns.push_back(static_cast(+objects[i])); addBlockVisTiles(objects[i]); //recreate blockvis map } - for(unsigned int i=0; ipos; vistile.x++; - for(unsigned int j=0; jpos) //hero stands on the town entrance { @@ -480,7 +474,7 @@ struct DLL_EXPORT Mapa : public CMapHeader const TerrainTile &t = getTile(vistile); if(t.tertype != TerrainTile::water) continue; //hero stands on the water - he must be in the boat - for(unsigned int j = 0; j < t.visitableObjects.size(); j++) + for(ui32 j = 0; j < t.visitableObjects.size(); j++) { if(t.visitableObjects[j]->ID == 8) { @@ -495,4 +489,3 @@ struct DLL_EXPORT Mapa : public CMapHeader } //!saving } }; -#endif // __MAP_H__ diff --git a/lib/vcmi_endian.h b/lib/vcmi_endian.h index 3df5ef692..1455b44ff 100644 --- a/lib/vcmi_endian.h +++ b/lib/vcmi_endian.h @@ -1,33 +1,45 @@ -#include - -/* Reading values from memory. - * - * read_le_u16, read_le_u32 : read a little endian value from - * memory. On big endian machines, the value will be byteswapped. - */ - -#if defined(linux) && defined(sparc) -/* SPARC does not support unaligned memory access. Let gcc know when - * to emit the right code. */ -struct unaligned_Uint16 { ui16 val __attribute__(( packed )); }; -struct unaligned_Uint32 { ui32 val __attribute__(( packed )); }; - -static inline ui16 read_unaligned_u16(const void *p) -{ - const struct unaligned_Uint16 *v = reinterpret_cast(p); - return v->val; -} - -static inline ui32 read_unaligned_u32(const void *p) -{ - const struct unaligned_Uint32 *v = reinterpret_cast(p); - return v->val; -} - -#define read_le_u16(p) (SDL_SwapLE16(read_unaligned_u16(p))) -#define read_le_u32(p) (SDL_SwapLE32(read_unaligned_u32(p))) - -#else -#define read_le_u16(p) (SDL_SwapLE16(* reinterpret_cast(p))) -#define read_le_u32(p) (SDL_SwapLE32(* reinterpret_cast(p))) -#endif +#pragma once + +#include + +/* + * vcmi_endian.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +/* Reading values from memory. + * + * read_le_u16, read_le_u32 : read a little endian value from + * memory. On big endian machines, the value will be byteswapped. + */ + +#if defined(linux) && defined(sparc) +/* SPARC does not support unaligned memory access. Let gcc know when + * to emit the right code. */ +struct unaligned_Uint16 { ui16 val __attribute__(( packed )); }; +struct unaligned_Uint32 { ui32 val __attribute__(( packed )); }; + +static inline ui16 read_unaligned_u16(const void *p) +{ + const struct unaligned_Uint16 *v = reinterpret_cast(p); + return v->val; +} + +static inline ui32 read_unaligned_u32(const void *p) +{ + const struct unaligned_Uint32 *v = reinterpret_cast(p); + return v->val; +} + +#define read_le_u16(p) (SDL_SwapLE16(read_unaligned_u16(p))) +#define read_le_u32(p) (SDL_SwapLE32(read_unaligned_u32(p))) + +#else +#define read_le_u16(p) (SDL_SwapLE16(* reinterpret_cast(p))) +#define read_le_u32(p) (SDL_SwapLE32(* reinterpret_cast(p))) +#endif diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 945f08a6d..45e69cbbb 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1,7 +1,8 @@ -#include "stdafx.h" -#include "../int3.h" +#include "StdInc.h" + +#include "../lib/int3.h" #include "../lib/CCampaignHandler.h" -#include "../StartInfo.h" +#include "../lib/StartInfo.h" #include "../lib/CArtHandler.h" #include "../lib/CBuildingHandler.h" #include "../lib/CDefObjInfoHandler.h" @@ -24,6 +25,9 @@ #include #include #include "../lib/CCreatureSet.h" +#include "../lib/CThreadHelper.h" +#include "../lib/GameConstants.h" +#include "../lib/RegisterTypes.h" /* * CGameHandler.cpp, part of VCMI engine @@ -35,9 +39,7 @@ * */ -#undef DLL_EXPORT -#define DLL_EXPORT -#include "../lib/RegisterTypes.cpp" + #ifndef _MSC_VER #include #endif @@ -210,7 +212,7 @@ void CGameHandler::levelUpHero(int ID) tlog5 << hero->name <<" got level "<level<::*g = (hero->level>9) ? (&std::pair::second) : (&std::pair::first); - for(;xtype->heroClass->primChance[x].*g; if(r basicAndAdv, expert, none; - for(int i=0;itempOwnertempOwnertempOwner, &PlayerStatus::engagedIntoBattle, false); - if(bEndArmy2 && bEndArmy2->tempOwnertempOwnertempOwner, &PlayerStatus::engagedIntoBattle, false); } @@ -680,7 +682,7 @@ void CGameHandler::handleConnection(std::set players, CConnection &c) tlog1 << "Ended handling connection\n"; } -int CGameHandler::moveStack(int stack, THex dest) +int CGameHandler::moveStack(int stack, SHexField dest) { int ret = 0; @@ -688,7 +690,7 @@ int CGameHandler::moveStack(int stack, THex dest) *stackAtEnd = gs->curB->getStackT(dest); assert(curStack); - assert(dest < BFIELD_SIZE); + assert(dest < GameConstants::BFIELD_SIZE); if (gs->curB->tacticDistance) { @@ -696,9 +698,9 @@ int CGameHandler::moveStack(int stack, THex dest) } //initing necessary tables - bool accessibility[BFIELD_SIZE]; - std::vector accessible = gs->curB->getAccessibility(curStack, false); - for(int b=0; b accessible = gs->curB->getAccessibility(curStack, false); + for(int b=0; battackerOwned) { if(accessibility[dest+1]) - dest += THex::RIGHT; + dest += SHexField::RIGHT; } else { if(accessibility[dest-1]) - dest += THex::LEFT; + dest += SHexField::LEFT; } } if((stackAtEnd && stackAtEnd!=curStack && stackAtEnd->alive()) || !accessibility[dest]) return 0; - bool accessibilityWithOccupyable[BFIELD_SIZE]; - std::vector accOc = gs->curB->getAccessibility(curStack, true); - for(int b=0; b accOc = gs->curB->getAccessibility(curStack, true); + for(int b=0; b curStack->creature->speed && !(stackAtEnd && dists[dest] == curStack->creature->speed+1)) //we can attack a stack if we can go to adjacent hex // return false; - std::pair< std::vector, int > path = gs->curB->getPath(curStack->position, dest, accessibilityWithOccupyable, curStack->hasBonusOfType(Bonus::FLYING), curStack->doubleWide(), curStack->attackerOwned); + std::pair< std::vector, int > path = gs->curB->getPath(curStack->position, dest, accessibilityWithOccupyable, curStack->hasBonusOfType(Bonus::FLYING), curStack->doubleWide(), curStack->attackerOwned); ret = path.second; - int creSpeed = gs->curB->tacticDistance ? BFIELD_SIZE : curStack->Speed(); + int creSpeed = gs->curB->tacticDistance ? GameConstants::BFIELD_SIZE : curStack->Speed(); if(curStack->hasBonusOfType(Bonus::FLYING)) { @@ -752,7 +754,7 @@ int CGameHandler::moveStack(int stack, THex dest) //inform clients about move BattleStackMoved sm; sm.stack = curStack->ID; - std::vector tiles; + std::vector tiles; tiles.push_back(path.first[0]); sm.tilesToMove = tiles; sm.distance = path.second; @@ -763,7 +765,7 @@ int CGameHandler::moveStack(int stack, THex dest) else //for non-flying creatures { // send one package with the creature path information - std::vector tiles; + std::vector tiles; int tilesToMove = std::max((int)(path.first.size() - creSpeed), 0); for(int v=path.first.size()-1; v>=tilesToMove; --v) { @@ -827,12 +829,12 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa return; } - if (forced || town->creatures[CREATURES_PER_TOWN].second.empty())//we need to change creature + if (forced || town->creatures[GameConstants::CREATURES_PER_TOWN].second.empty())//we need to change creature { SetAvailableCreatures ssi; ssi.tid = town->id; ssi.creatures = town->creatures; - ssi.creatures[CREATURES_PER_TOWN].second.clear();//remove old one + ssi.creatures[GameConstants::CREATURES_PER_TOWN].second.clear();//remove old one const std::vector > &dwellings = p->dwellings; if (dwellings.empty())//no dwellings - just remove @@ -846,10 +848,10 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa ui32 creature = dwellings[dwellpos]->creatures[creapos].second[0]; if (clear) - ssi.creatures[CREATURES_PER_TOWN].first = std::max((ui32)1, (VLC->creh->creatures[creature]->growth)/2); + ssi.creatures[GameConstants::CREATURES_PER_TOWN].first = std::max((ui32)1, (VLC->creh->creatures[creature]->growth)/2); else - ssi.creatures[CREATURES_PER_TOWN].first = VLC->creh->creatures[creature]->growth; - ssi.creatures[CREATURES_PER_TOWN].second.push_back(creature); + ssi.creatures[GameConstants::CREATURES_PER_TOWN].first = VLC->creh->creatures[creature]->growth; + ssi.creatures[GameConstants::CREATURES_PER_TOWN].second.push_back(creature); sendAndApply(&ssi); } } @@ -875,7 +877,7 @@ void CGameHandler::newTurn() bool deityOfFireBuilt = false; BOOST_FOREACH(const CGTownInstance *t, gs->map->towns) { - if(t->subID == 3 && vstd::contains(t->builtBuildings, Buildings::GRAIL)) + if(t->subID == 3 && vstd::contains(t->builtBuildings, EBuilding::GRAIL)) { deityOfFireBuilt = true; break; @@ -929,7 +931,7 @@ void CGameHandler::newTurn() { if(i->first == 255) continue; - else if(i->first >= PLAYER_LIMIT) + else if(i->first >= GameConstants::PLAYER_LIMIT) assert(0); //illegal player number! std::pair playerGold(i->first,i->second.resources[Res::GOLD]); @@ -942,7 +944,7 @@ void CGameHandler::newTurn() //pick heroes and their armies CHeroClass *banned = NULL; - for (int j = 0; j < AVAILABLE_HEROES_PER_PLAYER; j++) + for (int j = 0; j < GameConstants::AVAILABLE_HEROES_PER_PLAYER; j++) { if(CGHeroInstance *h = gs->hpool.pickHeroFor(j == 0, i->first, getNativeTown(i->first), pool, banned)) //first hero - native if possible, second hero -> any other class { @@ -979,7 +981,7 @@ void CGameHandler::newTurn() { n.res[i->first][Res::GOLD] += h->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ESTATES)); //estates - for (int k = 0; k < RESOURCE_QUANTITY; k++) + for (int k = 0; k < GameConstants::RESOURCE_QUANTITY; k++) { n.res[i->first][k] += h->valOfBonuses(Bonus::GENERATE_RESOURCE, k); } @@ -995,17 +997,17 @@ void CGameHandler::newTurn() handleTownEvents(t, n, newCreas); if(newWeek) //first day of week { - if(t->subID == 5 && vstd::contains(t->builtBuildings, Buildings::SPECIAL_3)) + if(t->subID == 5 && vstd::contains(t->builtBuildings, EBuilding::SPECIAL_3)) setPortalDwelling(t, true, (n.specialWeek == NewTurn::PLAGUE ? true : false)); //set creatures for Portal of Summoning if(!firstTurn) - if (t->subID == 1 && player < PLAYER_LIMIT && vstd::contains(t->builtBuildings, Buildings::SPECIAL_3))//dwarven treasury + if (t->subID == 1 && player < GameConstants::PLAYER_LIMIT && vstd::contains(t->builtBuildings, EBuilding::SPECIAL_3))//dwarven treasury n.res[player][Res::GOLD] += hadGold[player]/10; //give 10% of starting gold SetAvailableCreatures sac; sac.tid = t->id; sac.creatures = t->creatures; - for (int k=0; k < CREATURES_PER_TOWN; k++) //creature growths + for (int k=0; k < GameConstants::CREATURES_PER_TOWN; k++) //creature growths { if(t->creatureDwelling(k))//there is dwelling (k-level) { @@ -1041,9 +1043,9 @@ void CGameHandler::newTurn() n.cres.push_back(sac); } - if(!firstTurn && player < PLAYER_LIMIT)//not the first day and town not neutral + if(!firstTurn && player < GameConstants::PLAYER_LIMIT)//not the first day and town not neutral { - if(vstd::contains(t->builtBuildings, Buildings::RESOURCE_SILO)) //there is resource silo + if(vstd::contains(t->builtBuildings, EBuilding::RESOURCE_SILO)) //there is resource silo { if(t->town->primaryRes == 127) //we'll give wood and ore { @@ -1058,7 +1060,7 @@ void CGameHandler::newTurn() n.res[player][Res::GOLD] += t->dailyIncome(); } - if(vstd::contains(t->builtBuildings, Buildings::GRAIL) && t->subID == 2) + if(vstd::contains(t->builtBuildings, EBuilding::GRAIL) && t->subID == 2) { // Skyship, probably easier to handle same as Veil of darkness //do it every new day after veils apply @@ -1147,7 +1149,7 @@ void CGameHandler::newTurn() { for (std::map::iterator i=gs->players.begin() ; i!=gs->players.end();i++) { - if(i->second.status || i->second.towns.size() || i->second.color >= PLAYER_LIMIT) + if(i->second.status || i->second.towns.size() || i->second.color >= GameConstants::PLAYER_LIMIT) continue; InfoWindow iw; @@ -1235,7 +1237,7 @@ void CGameHandler::run(bool resume) { if((i->second.towns.size()==0 && i->second.heroes.size()==0) || i->second.color<0 - || i->first>=PLAYER_LIMIT + || i->first>=GameConstants::PLAYER_LIMIT || i->second.status) { continue; @@ -1317,7 +1319,7 @@ void CGameHandler::giveSpells( const CGTownInstance *t, const CGHeroInstance *h cs.learn = true; for(int i=0; imageGuildLevel(),h->getSecSkillLevel(CGHeroInstance::WISDOM)+2);i++) { - if (t->subID == 8 && vstd::contains(t->builtBuildings, Buildings::GRAIL)) //Aurora Borealis + if (t->subID == 8 && vstd::contains(t->builtBuildings, EBuilding::GRAIL)) //Aurora Borealis { std::vector spells; getAllowedSpells(spells, i); @@ -1405,7 +1407,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255* //OR hero is on land and dest is water and (there is not present only one object - boat) if(((t.tertype == TerrainTile::rock || (t.blocked && !t.visitable && !h->hasBonusOfType(Bonus::FLYING_MOVEMENT) )) && complain("Cannot move hero, destination tile is blocked!")) - || ((!h->boat && !h->canWalkOnSea() && t.tertype == TerrainTile::water && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != 8 && t.visitableObjects.back()->ID != HEROI_TYPE))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276) + || ((!h->boat && !h->canWalkOnSea() && t.tertype == TerrainTile::water && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != 8 && t.visitableObjects.back()->ID != GameConstants::HEROI_TYPE))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276) && complain("Cannot move hero, destination tile is on water!")) || ((h->boat && t.tertype != TerrainTile::water && t.blocked) && complain("Cannot disembark hero, tile is blocked!")) @@ -1502,7 +1504,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255* { BOOST_FOREACH(CGObjectInstance* obj, t.blockingObjects) { - if(obj->ID==HEROI_TYPE) + if(obj->ID==GameConstants::HEROI_TYPE) { CGHeroInstance *dh = static_cast(obj); @@ -1533,9 +1535,9 @@ bool CGameHandler::teleportHero(si32 hid, si32 dstid, ui8 source, ui8 asker/* = const CGTownInstance *from = h->visitedTown; if(((h->getOwner() != t->getOwner()) && complain("Cannot teleport hero to another player")) - || ((!from || from->subID!=3 || !vstd::contains(from->builtBuildings, Buildings::SPECIAL_3)) + || ((!from || from->subID!=3 || !vstd::contains(from->builtBuildings, EBuilding::SPECIAL_3)) && complain("Hero must be in town with Castle gate for teleporting")) - || ((t->subID!=3 || !vstd::contains(t->builtBuildings, Buildings::SPECIAL_3)) + || ((t->subID!=3 || !vstd::contains(t->builtBuildings, EBuilding::SPECIAL_3)) && complain("Cannot teleport hero to town without Castle gate in it"))) return false; int3 pos = t->visitablePos(); @@ -1553,7 +1555,7 @@ void CGameHandler::setOwner(int objid, ui8 owner) sendAndApply(&sop); winLoseHandle(1<subID == 5 && vstd::contains(town->builtBuildings, 22)) @@ -1626,7 +1628,7 @@ void CGameHandler::giveCreatures(const CArmedInstance *obj, const CGHeroInstance COMPLAIN_RET_IF(!creatures.stacksCount(), "Strange, giveCreatures called without args!"); COMPLAIN_RET_IF(obj->stacksCount(), "Cannot give creatures from not-cleared object!"); - COMPLAIN_RET_IF(creatures.stacksCount() > ARMY_SIZE, "Too many stacks to give!"); + COMPLAIN_RET_IF(creatures.stacksCount() > GameConstants::ARMY_SIZE, "Too many stacks to give!"); //first we move creatures to give to make them army of object-source for (TSlots::const_iterator stack = creatures.Slots().begin(); stack != creatures.Slots().end(); stack++) @@ -1685,7 +1687,7 @@ void CGameHandler::heroVisitCastle(int obj, int heroID) vistiCastleObjects (getTown(obj), h); giveSpells (getTown(obj), getHero(heroID)); - if(gs->map->victoryCondition.condition == transportItem) + if(gs->map->victoryCondition.condition == EVictoryConditionType::TRANSPORTITEM) checkLossVictory(h->tempOwner); //transported artifact? } @@ -1716,7 +1718,7 @@ void CGameHandler::startBattleI(const CArmedInstance *army1, const CArmedInstanc engageIntoBattle(army1->tempOwner); engageIntoBattle(army2->tempOwner); //block engaged players - if(army2->tempOwner < PLAYER_LIMIT) + if(army2->tempOwner < GameConstants::PLAYER_LIMIT) states.setFlag(army2->tempOwner,&PlayerStatus::engagedIntoBattle,true); static const CArmedInstance *armies[2]; @@ -1732,8 +1734,8 @@ void CGameHandler::startBattleI(const CArmedInstance *army1, const CArmedInstanc void CGameHandler::startBattleI( const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, boost::function cb, bool creatureBank ) { startBattleI(army1, army2, tile, - army1->ID == HEROI_TYPE ? static_cast(army1) : NULL, - army2->ID == HEROI_TYPE ? static_cast(army2) : NULL, + army1->ID == GameConstants::HEROI_TYPE ? static_cast(army1) : NULL, + army2->ID == GameConstants::HEROI_TYPE ? static_cast(army2) : NULL, creatureBank, cb); } @@ -1944,7 +1946,7 @@ void CGameHandler::applyAndSend(CPackForClient * info) void CGameHandler::sendAndApply(CGarrisonOperationPack * info) { sendAndApply((CPackForClient*)info); - if(gs->map->victoryCondition.condition == gatherTroop) + if(gs->map->victoryCondition.condition == EVictoryConditionType::GATHERTROOP) winLoseHandle(); } @@ -1959,21 +1961,21 @@ void CGameHandler::sendAndApply(CGarrisonOperationPack * info) void CGameHandler::sendAndApply( SetResource * info ) { sendAndApply((CPackForClient*)info); - if(gs->map->victoryCondition.condition == gatherResource) + if(gs->map->victoryCondition.condition == EVictoryConditionType::GATHERRESOURCE) checkLossVictory(info->player); } void CGameHandler::sendAndApply( SetResources * info ) { sendAndApply((CPackForClient*)info); - if(gs->map->victoryCondition.condition == gatherResource) + if(gs->map->victoryCondition.condition == EVictoryConditionType::GATHERRESOURCE) checkLossVictory(info->player); } void CGameHandler::sendAndApply( NewStructures * info ) { sendAndApply((CPackForClient*)info); - if(gs->map->victoryCondition.condition == buildCity) + if(gs->map->victoryCondition.condition == EVictoryConditionType::BUILDCITY) checkLossVictory(getTown(info->tid)->tempOwner); } @@ -2280,7 +2282,7 @@ bool CGameHandler::recruitCreatures( si32 objid, ui32 crid, ui32 cram, si32 from //TODO: test for owning - if(dw->ID == TOWNI_TYPE) + if(dw->ID == GameConstants::TOWNI_TYPE) dst = (static_cast(dw))->getUpperArmy(); else if(dw->ID == 17 || dw->ID == 20 || dw->ID == 78) //advmap dwelling dst = getHero(gs->getPlayer(dw->tempOwner)->currentSelection); //TODO: check if current hero is really visiting dwelling @@ -2343,13 +2345,13 @@ bool CGameHandler::recruitCreatures( si32 objid, ui32 crid, ui32 cram, si32 from switch(crid) { case 146: - giveHeroNewArtifact(h, VLC->arth->artifacts[4], Arts::MACH1); + giveHeroNewArtifact(h, VLC->arth->artifacts[4], ArtifactPosition::MACH1); break; case 147: - giveHeroNewArtifact(h, VLC->arth->artifacts[6], Arts::MACH3); + giveHeroNewArtifact(h, VLC->arth->artifacts[6], ArtifactPosition::MACH3); break; case 148: - giveHeroNewArtifact(h, VLC->arth->artifacts[5], Arts::MACH2); + giveHeroNewArtifact(h, VLC->arth->artifacts[5], ArtifactPosition::MACH2); break; default: complain("This war machine cannot be recruited!"); @@ -2371,7 +2373,7 @@ bool CGameHandler::upgradeCreature( ui32 objid, ui8 pos, ui32 upgID ) int player = obj->tempOwner; const PlayerState *p = getPlayer(player); int crQuantity = obj->stacks[pos]->count; - int newIDpos= vstd::findPos(ui.newID, upgID);//get position of new id in UpgradeInfo + int newIDpos= vstd::find_pos(ui.newID, upgID);//get position of new id in UpgradeInfo TResources totalCost = ui.cost[newIDpos] * crQuantity; //check if upgrade is possible @@ -2515,26 +2517,26 @@ bool CGameHandler::moveArtifact(si32 srcHeroID, si32 destHeroID, ui16 srcSlot, u // Check if src/dest slots are appropriate for the artifacts exchanged. // Moving to the backpack is always allowed. - if ((!srcArtifact || destSlot < Arts::BACKPACK_START) + if ((!srcArtifact || destSlot < GameConstants::BACKPACK_START) && srcArtifact && !srcArtifact->canBePutAt(dst, true)) COMPLAIN_RET("Cannot move artifact!"); - if ((srcArtifact && srcArtifact->artType->id == Arts::ID_LOCK) || (destArtifact && destArtifact->artType->id == Arts::ID_LOCK)) + if ((srcArtifact && srcArtifact->artType->id == GameConstants::ID_LOCK) || (destArtifact && destArtifact->artType->id == GameConstants::ID_LOCK)) COMPLAIN_RET("Cannot move artifact locks."); - if (destSlot >= Arts::BACKPACK_START && srcArtifact->artType->isBig()) + if (destSlot >= GameConstants::BACKPACK_START && srcArtifact->artType->isBig()) COMPLAIN_RET("Cannot put big artifacts in backpack!"); - if (srcSlot == Arts::MACH4 || destSlot == Arts::MACH4) + if (srcSlot == ArtifactPosition::MACH4 || destSlot == ArtifactPosition::MACH4) COMPLAIN_RET("Cannot move catapult!"); - if(dst.slot >= Arts::BACKPACK_START) - amin(dst.slot, Arts::BACKPACK_START + dst.hero->artifactsInBackpack.size()); + if(dst.slot >= GameConstants::BACKPACK_START) + vstd::amin(dst.slot, GameConstants::BACKPACK_START + dst.hero->artifactsInBackpack.size()); if (src.slot == dst.slot && src.hero == dst.hero) COMPLAIN_RET("Won't move artifact: Dest same as source!"); //moving art to backpack is always allowed (we've ruled out exceptions) - if(destSlot >= Arts::BACKPACK_START) + if(destSlot >= GameConstants::BACKPACK_START) { moveArtifact(src, dst); } @@ -2542,7 +2544,7 @@ bool CGameHandler::moveArtifact(si32 srcHeroID, si32 destHeroID, ui16 srcSlot, u { if(destArtifact) //old artifact must be removed first { - moveArtifact(dst, ArtifactLocation(destHero, destHero->artifactsInBackpack.size() + Arts::BACKPACK_START)); + moveArtifact(dst, ArtifactLocation(destHero, destHero->artifactsInBackpack.size() + GameConstants::BACKPACK_START)); } moveArtifact(src, dst); } @@ -2599,15 +2601,15 @@ bool CGameHandler::buyArtifact( ui32 hid, si32 aid ) CGTownInstance *town = hero->visitedTown; if(aid==0) //spellbook { - if((!vstd::contains(town->builtBuildings,si32(Buildings::MAGES_GUILD_1)) && complain("Cannot buy a spellbook, no mage guild in the town!")) - || (getResource(hero->getOwner(), Res::GOLD) < SPELLBOOK_GOLD_COST && complain("Cannot buy a spellbook, not enough gold!") ) - || (hero->getArt(Arts::SPELLBOOK) && complain("Cannot buy a spellbook, hero already has a one!")) + if((!vstd::contains(town->builtBuildings,si32(EBuilding::MAGES_GUILD_1)) && complain("Cannot buy a spellbook, no mage guild in the town!")) + || (getResource(hero->getOwner(), Res::GOLD) < GameConstants::SPELLBOOK_GOLD_COST && complain("Cannot buy a spellbook, not enough gold!") ) + || (hero->getArt(ArtifactPosition::SPELLBOOK) && complain("Cannot buy a spellbook, hero already has a one!")) ) return false; - giveResource(hero->getOwner(),Res::GOLD,-SPELLBOOK_GOLD_COST); - giveHeroNewArtifact(hero, VLC->arth->artifacts[0], Arts::SPELLBOOK); - assert(hero->getArt(Arts::SPELLBOOK)); + giveResource(hero->getOwner(),Res::GOLD,-GameConstants::SPELLBOOK_GOLD_COST); + giveHeroNewArtifact(hero, VLC->arth->artifacts[0], ArtifactPosition::SPELLBOOK); + assert(hero->getArt(ArtifactPosition::SPELLBOOK)); giveSpells(town,hero); return true; } @@ -2615,9 +2617,9 @@ bool CGameHandler::buyArtifact( ui32 hid, si32 aid ) { int price = VLC->arth->artifacts[aid]->price; if((hero->getArt(9+aid) && complain("Hero already has this machine!")) - || (!vstd::contains(town->builtBuildings,si32(Buildings::BLACKSMITH)) && complain("No blackismith!")) + || (!vstd::contains(town->builtBuildings,si32(EBuilding::BLACKSMITH)) && complain("No blackismith!")) || (gs->getPlayer(hero->getOwner())->resources[Res::GOLD] < price && complain("Not enough gold!")) //no gold - || ((!(town->subID == 6 && vstd::contains(town->builtBuildings,si32(Buildings::SPECIAL_3) ) ) + || ((!(town->subID == 6 && vstd::contains(town->builtBuildings,si32(EBuilding::SPECIAL_3) ) ) && town->town->warMachine!= aid ) && complain("This machine is unavailable here!"))) { return false; @@ -2632,11 +2634,11 @@ bool CGameHandler::buyArtifact( ui32 hid, si32 aid ) bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, int rid, int aid) { - if(!vstd::contains(m->availableItemsIds(RESOURCE_ARTIFACT), aid)) + if(!vstd::contains(m->availableItemsIds(EMarketMode::RESOURCE_ARTIFACT), aid)) COMPLAIN_RET("That artifact is unavailable!"); int b1, b2; - m->getOffer(rid, aid, b1, b2, RESOURCE_ARTIFACT); + m->getOffer(rid, aid, b1, b2, EMarketMode::RESOURCE_ARTIFACT); if(getResource(h->tempOwner, rid) < b1) COMPLAIN_RET("You can't afford to buy this artifact!"); @@ -2649,7 +2651,7 @@ bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, int ri SetAvailableArtifacts saa; - if(m->o->ID == TOWNI_TYPE) + if(m->o->ID == GameConstants::TOWNI_TYPE) { saa.id = -1; saa.arts = CGTownInstance::merchantArtifacts; @@ -2691,7 +2693,7 @@ bool CGameHandler::sellArtifact(const IMarket *m, const CGHeroInstance *h, int a COMPLAIN_RET("Cannot sell a war machine or spellbook!"); int resVal = 0, dump = 1; - m->getOffer(art->artType->id, rid, dump, resVal, ARTIFACT_RESOURCE); + m->getOffer(art->artType->id, rid, dump, resVal, EMarketMode::ARTIFACT_RESOURCE); removeArtifact(ArtifactLocation(h, h->getArtPos(art))); giveResource(h->tempOwner, rid, resVal); @@ -2706,13 +2708,13 @@ bool CGameHandler::buySecSkill( const IMarket *m, const CGHeroInstance *h, int s if (h->getSecSkillLevel(static_cast(skill))) COMPLAIN_RET("Hero already know this skill"); - if (h->secSkills.size() >= SKILL_PER_HERO)//can't learn more skills + if (h->secSkills.size() >= GameConstants::SKILL_PER_HERO)//can't learn more skills COMPLAIN_RET("Hero can't learn any more skills"); if (h->type->heroClass->proSec[skill]==0)//can't learn this skill (like necromancy for most of non-necros) COMPLAIN_RET("The hero can't learn this skill!"); - if(!vstd::contains(m->availableItemsIds(RESOURCE_SKILL), skill)) + if(!vstd::contains(m->availableItemsIds(EMarketMode::RESOURCE_SKILL), skill)) COMPLAIN_RET("That skill is unavailable!"); if(getResource(h->tempOwner, Res::GOLD) < 2000)//TODO: remove hardcoded resource\summ? @@ -2733,10 +2735,10 @@ bool CGameHandler::tradeResources(const IMarket *market, ui32 val, ui8 player, u int r1 = gs->getPlayer(player)->resources[id1], r2 = gs->getPlayer(player)->resources[id2]; - amin(val, r1); //can't trade more resources than have + vstd::amin(val, r1); //can't trade more resources than have int b1, b2; //base quantities for trade - market->getOffer(id1, id2, b1, b2, RESOURCE_RESOURCE); + market->getOffer(id1, id2, b1, b2, EMarketMode::RESOURCE_RESOURCE); int units = val / b1; //how many base quantities we trade if(val%b1) //all offered units of resource should be used, if not -> somewhere in calculations must be an error @@ -2772,7 +2774,7 @@ bool CGameHandler::sellCreatures(ui32 count, const IMarket *market, const CGHero } int b1, b2; //base quantities for trade - market->getOffer(s.type->idNumber, resourceID, b1, b2, CREATURE_RESOURCE); + market->getOffer(s.type->idNumber, resourceID, b1, b2, EMarketMode::CREATURE_RESOURCE); int units = count / b1; //how many base quantities we trade if(count%b1) //all offered units of resource should be used, if not -> somewhere in calculations must be an error @@ -2861,7 +2863,7 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, ui8 player) if(t) //tavern in town { - if( (!vstd::contains(t->builtBuildings,Buildings::TAVERN) && complain("No tavern!")) + if( (!vstd::contains(t->builtBuildings,EBuilding::TAVERN) && complain("No tavern!")) || (t->visitingHero && complain("There is visiting hero - no place!"))) return false; } @@ -3166,7 +3168,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) attack.second = 0; int chanceForHit = 0; - int dmgChance[3] = {sbi.noDmg, sbi.oneDmg, sbi.twoDmg}; //dmgChance[i] - chance for doing i dmg when hit is successful + int dmgChance[] = { sbi.noDmg, sbi.oneDmg, sbi.twoDmg }; //dmgChance[i] - chance for doing i dmg when hit is successful switch(attackedPart) { case 0: //keep @@ -3328,21 +3330,21 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) CStack * stack = gs->curB->getStack(ba.stackNumber); int spellID = ba.additionalInfo; - THex destination(ba.destinationTile); + SHexField destination(ba.destinationTile); int spellLvl = 0; Bonus * bonus = stack->getBonus(Selector::typeSubtype(Bonus::SPELLCASTER, spellID)); if (bonus) - amax(spellLvl, bonus->val); + vstd::amax(spellLvl, bonus->val); bonus = stack->getBonus(Selector::type(Bonus::RANDOM_SPELLCASTER)); if (bonus) - amax(spellLvl, bonus->val); - amin (spellLvl, 3); + vstd::amax(spellLvl, bonus->val); + vstd::amin (spellLvl, 3); int casterSide = gs->curB->whatSide(stack->owner); const CGHeroInstance * secHero = gs->curB->getHero(gs->curB->theOtherPlayer(stack->owner)); - handleSpellCasting(spellID, spellLvl, destination, casterSide, stack->owner, NULL, secHero, 0, SpellCasting::CREATURE_ACTIVE_CASTING, stack); + handleSpellCasting(spellID, spellLvl, destination, casterSide, stack->owner, NULL, secHero, 0, ECastingMode::CREATURE_ACTIVE_CASTING, stack); sendAndApply(&end_action); break; @@ -3381,7 +3383,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message ) sm.val = 999; if(!h->hasSpellbook()) //hero doesn't have spellbook - giveHeroNewArtifact(h, VLC->arth->artifacts[0], Arts::SPELLBOOK); //give spellbook + giveHeroNewArtifact(h, VLC->arth->artifacts[0], ArtifactPosition::SPELLBOOK); //give spellbook sendAndApply(&cs); sendAndApply(&sm); @@ -3392,7 +3394,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message ) const CCreature *archangel = VLC->creh->creatures[13]; if(!hero) return; - for(int i = 0; i < ARMY_SIZE; i++) + for(int i = 0; i < GameConstants::ARMY_SIZE; i++) if(!hero->hasStackAtSlot(i)) insertNewStack(StackLocation(hero, i), archangel, 5); } @@ -3402,7 +3404,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message ) const CCreature *blackKnight = VLC->creh->creatures[66]; if(!hero) return; - for(int i = 0; i < ARMY_SIZE; i++) + for(int i = 0; i < GameConstants::ARMY_SIZE; i++) if(!hero->hasStackAtSlot(i)) insertNewStack(StackLocation(hero, i), blackKnight, 10); } @@ -3411,12 +3413,12 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message ) CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection); if(!hero) return; - if(!hero->getArt(Arts::MACH1)) - giveHeroNewArtifact(hero, VLC->arth->artifacts[4], Arts::MACH1); - if(!hero->getArt(Arts::MACH2)) - giveHeroNewArtifact(hero, VLC->arth->artifacts[5], Arts::MACH2); - if(!hero->getArt(Arts::MACH3)) - giveHeroNewArtifact(hero, VLC->arth->artifacts[6], Arts::MACH3); + if(!hero->getArt(ArtifactPosition::MACH1)) + giveHeroNewArtifact(hero, VLC->arth->artifacts[4], ArtifactPosition::MACH1); + if(!hero->getArt(ArtifactPosition::MACH2)) + giveHeroNewArtifact(hero, VLC->arth->artifacts[5], ArtifactPosition::MACH2); + if(!hero->getArt(ArtifactPosition::MACH3)) + giveHeroNewArtifact(hero, VLC->arth->artifacts[6], ArtifactPosition::MACH3); } else if(message == "vcminahar") //1000000 movement points { @@ -3484,7 +3486,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message ) } } -void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode, const CStack * stack) +void CGameHandler::handleSpellCasting( int spellID, int spellLvl, SHexField destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, ECastingMode::ECastingMode mode, const CStack * stack) { const CSpell *spell = VLC->spellh->spells[spellID]; @@ -3503,14 +3505,14 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati { sc.spellCost = gs->curB->getSpellCost(VLC->spellh->spells[spellID], caster); - if (secHero && mode == SpellCasting::HERO_CASTING) //handle mana channel + if (secHero && mode == ECastingMode::HERO_CASTING) //handle mana channel { int manaChannel = 0; BOOST_FOREACH(CStack * stack, gs->curB->stacks) //TODO: shouldn't bonus system handle it somehow? { if (stack->owner == secHero->tempOwner) { - amax(manaChannel, stack->valOfBonuses(Bonus::MANA_CHANNELING)); + vstd::amax(manaChannel, stack->valOfBonuses(Bonus::MANA_CHANNELING)); } } sc.manaGained = (manaChannel * sc.spellCost) / 100; @@ -3519,7 +3521,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati //calculating affected creatures for all spells std::set attackedCres; - if (mode != SpellCasting::ENCHANTER_CASTING) + if (mode != ECastingMode::ENCHANTER_CASTING) { attackedCres = gs->curB->getAttackedCreatures(spell, spellLvl, casterColor, destination); for(std::set::const_iterator it = attackedCres.begin(); it != attackedCres.end(); ++it) @@ -3555,7 +3557,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati { sc.dmgToDisplay = usedSpellPower; if (spellID == Spells::DEATH_STARE) - amin(sc.dmgToDisplay, (*attackedCres.begin())->count); //stack is already reduced after attack + vstd::amin(sc.dmgToDisplay, (*attackedCres.begin())->count); //stack is already reduced after attack } StacksInjured si; @@ -3577,7 +3579,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati case Spells::THUNDERBOLT: //(thunderbirds) { int spellDamage = 0; - if (stack && mode != SpellCasting::MAGIC_MIRROR) + if (stack && mode != ECastingMode::MAGIC_MIRROR) { int unitSpellPower = stack->valOfBonuses(Bonus::SPECIFIC_SPELL_POWER, spellID); if (unitSpellPower) @@ -3653,7 +3655,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati case Spells::ACID_BREATH_DEFENSE: { int stackSpellPower = 0; - if (stack && mode != SpellCasting::MAGIC_MIRROR) + if (stack && mode != ECastingMode::MAGIC_MIRROR) { stackSpellPower = stack->valOfBonuses(Bonus::CREATURE_ENCHANT_POWER); } @@ -3735,7 +3737,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati BattleStackMoved bsm; bsm.distance = -1; bsm.stack = gs->curB->activeStack; - std::vector tiles; + std::vector tiles; tiles.push_back(destination); bsm.tilesToMove = tiles; bsm.teleporting = true; @@ -3811,7 +3813,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati bsa.pos = gs->curB->getAvaliableHex(creID, !(bool)casterSide); //TODO: unify it bsa.amount = caster->getPrimSkillLevel(2) * VLC->spellh->spells[spellID]->powers[spellLvl] * - (100 + caster->valOfBonuses(Bonus::SPECIFIC_SPELL_DAMAGE, spellID)) / 100.0f; //new feature - percentage bonus + (100 + caster->valOfBonuses(Bonus::SPECIFIC_SPELL_DAMAGE, spellID)) / 100.0; //new feature - percentage bonus bsa.creID = creID; bsa.attacker = !(bool)casterSide; @@ -3824,7 +3826,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati ObstaclesRemoved obr; for(int g=0; gcurB->obstacles.size(); ++g) { - std::vector blockedHexes = VLC->heroh->obstacles[gs->curB->obstacles[g].ID].getBlocked(gs->curB->obstacles[g].pos); + std::vector blockedHexes = VLC->heroh->obstacles[gs->curB->obstacles[g].ID].getBlocked(gs->curB->obstacles[g].pos); if(vstd::contains(blockedHexes, destination)) //this obstacle covers given hex { @@ -3878,7 +3880,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati if(!si.stacks.empty()) //after spellcast info shows sendAndApply(&si); - if (mode == SpellCasting::CREATURE_ACTIVE_CASTING || mode == SpellCasting::ENCHANTER_CASTING) //reduce number of casts remaining + if (mode == ECastingMode::CREATURE_ACTIVE_CASTING || mode == ECastingMode::ENCHANTER_CASTING) //reduce number of casts remaining { BattleSetStackProperty ssp; ssp.stackID = stack->ID; @@ -3889,7 +3891,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati } //Magic Mirror effect - if (spell->positiveness < 0 && mode != SpellCasting::MAGIC_MIRROR && spell->level && spell->range[0] == "0") //it is actual spell and can be reflected to single target, no recurrence + if (spell->positiveness < 0 && mode != ECastingMode::MAGIC_MIRROR && spell->level && spell->range[0] == "0") //it is actual spell and can be reflected to single target, no recurrence { for(std::set::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it) { @@ -3902,14 +3904,14 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati { if(battleStacks[j]->owner == casterSide) //get enemy stacks which can be affected by this spell { - if (!gs->curB->battleIsImmune(NULL, spell, SpellCasting::MAGIC_MIRROR, battleStacks[j]->position)) + if (!gs->curB->battleIsImmune(NULL, spell, ECastingMode::MAGIC_MIRROR, battleStacks[j]->position)) mirrorTargets.push_back(battleStacks[j]); } } if (mirrorTargets.size()) { int targetHex = mirrorTargets[rand() % mirrorTargets.size()]->position; - handleSpellCasting(spellID, 0, targetHex, 1 - casterSide, (*it)->owner, NULL, (caster ? caster : NULL), usedSpellPower, SpellCasting::MAGIC_MIRROR, (*it)); + handleSpellCasting(spellID, 0, targetHex, 1 - casterSide, (*it)->owner, NULL, (caster ? caster : NULL), usedSpellPower, ECastingMode::MAGIC_MIRROR, (*it)); } } } @@ -3941,8 +3943,8 @@ bool CGameHandler::makeCustomAction( BattleAction &ba ) { ui8 skill = h->getSpellSchoolLevel(s); //skill level - SpellCasting::ESpellCastProblem escp = gs->curB->battleCanCastThisSpell(h->tempOwner, s, SpellCasting::HERO_CASTING); - if(escp != SpellCasting::OK) + ESpellCastProblem::ESpellCastProblem escp = gs->curB->battleCanCastThisSpell(h->tempOwner, s, ECastingMode::HERO_CASTING); + if(escp != ESpellCastProblem::OK) { tlog2 << "Spell cannot be cast!\n"; tlog2 << "Problem : " << escp << std::endl; @@ -3952,7 +3954,7 @@ bool CGameHandler::makeCustomAction( BattleAction &ba ) StartAction start_action(ba); sendAndApply(&start_action); //start spell casting - handleSpellCasting (ba.additionalInfo, skill, ba.destinationTile, ba.side, h->tempOwner, h, secondHero, h->getPrimSkillLevel(2), SpellCasting::HERO_CASTING, NULL); + handleSpellCasting (ba.additionalInfo, skill, ba.destinationTile, ba.side, h->tempOwner, h, secondHero, h->getPrimSkillLevel(2), ECastingMode::HERO_CASTING, NULL); sendAndApply(&end_action); if( !gs->curB->getStack(gs->curB->activeStack, false)->alive() ) @@ -4047,7 +4049,7 @@ void CGameHandler::stackTurnTrigger(const CStack * st) if (enemy) { ui32 manaDrained = st->valOfBonuses(Bonus::MANA_DRAIN); - amin (manaDrained, gs->curB->heroes[0]->mana); + vstd::amin (manaDrained, gs->curB->heroes[0]->mana); if (manaDrained) { bte.effect = Bonus::MANA_DRAIN; @@ -4083,11 +4085,11 @@ void CGameHandler::stackTurnTrigger(const CStack * st) { int index = rand() % bl.size(); int spellID = bl[index]->subtype; //spell ID - if (gs->curB->battleCanCastThisSpell(st->owner, VLC->spellh->spells[spellID], SpellCasting::ENCHANTER_CASTING)); //TODO: select another? + if (gs->curB->battleCanCastThisSpell(st->owner, VLC->spellh->spells[spellID], ECastingMode::ENCHANTER_CASTING)); //TODO: select another? { int spellLeveL = bl[index]->val; //spell level const CGHeroInstance * enemyHero = gs->curB->getHero(gs->curB->theOtherPlayer(st->owner)); - handleSpellCasting(spellID, spellLeveL, -1, side, st->owner, NULL, enemyHero, 0, SpellCasting::ENCHANTER_CASTING, st); + handleSpellCasting(spellID, spellLeveL, -1, side, st->owner, NULL, enemyHero, 0, ECastingMode::ENCHANTER_CASTING, st); BattleSetStackProperty ssp; ssp.which = BattleSetStackProperty::ENCHANTER_COUNTER; @@ -4106,7 +4108,7 @@ void CGameHandler::handleTimeEvents() while(gs->map->events.size() && gs->map->events.front()->firstOccurence+1 == gs->day) { CMapEvent *ev = gs->map->events.front(); - for(int player = 0; player < PLAYER_LIMIT; player++) + for(int player = 0; player < GameConstants::PLAYER_LIMIT; player++) { PlayerState *pinfo = gs->getPlayer(player); @@ -4297,19 +4299,19 @@ bool CGameHandler::isAllowedExchange( int id1, int id2 ) const CGObjectInstance *o1 = getObj(id1), *o2 = getObj(id2); - if(o1->ID == TOWNI_TYPE) + if(o1->ID == GameConstants::TOWNI_TYPE) { const CGTownInstance *t = static_cast(o1); if(t->visitingHero == o2 || t->garrisonHero == o2) return true; } - if(o2->ID == TOWNI_TYPE) + if(o2->ID == GameConstants::TOWNI_TYPE) { const CGTownInstance *t = static_cast(o2); if(t->visitingHero == o1 || t->garrisonHero == o1) return true; } - if(o1->ID == HEROI_TYPE && o2->ID == HEROI_TYPE + if(o1->ID == GameConstants::HEROI_TYPE && o2->ID == GameConstants::HEROI_TYPE && distance(o1->pos, o2->pos) < 2) //hero stands on the same tile or on the neighbouring tiles { //TODO: it's workaround, we should check if first hero visited second and player hasn't closed exchange window @@ -4344,7 +4346,7 @@ bool CGameHandler::buildBoat( ui32 objid ) complain("Cannot build boat in this shipyard!"); return false; } - else if(obj->o->ID == TOWNI_TYPE + else if(obj->o->ID == GameConstants::TOWNI_TYPE && !vstd::contains((static_cast(obj))->builtBuildings,6)) { complain("Cannot build boat in the town - no shipyard!"); @@ -4397,7 +4399,7 @@ void CGameHandler::engageIntoBattle( ui8 player ) void CGameHandler::winLoseHandle(ui8 players ) { - for(size_t i = 0; i < PLAYER_LIMIT; i++) + for(size_t i = 0; i < GameConstants::PLAYER_LIMIT; i++) { if(players & 1<getPlayer(i)) { @@ -4433,7 +4435,7 @@ void CGameHandler::checkLossVictory( ui8 player ) for (bmap::const_iterator i = gs->players.begin(); i!=gs->players.end(); i++) { - if(i->first < PLAYER_LIMIT && i->first != player)//FIXME: skip already eliminated players? + if(i->first < GameConstants::PLAYER_LIMIT && i->first != player)//FIXME: skip already eliminated players? { iw.player = i->first; sendAndApply(&iw); @@ -4453,11 +4455,11 @@ void CGameHandler::checkLossVictory( ui8 player ) for (std::vector >::const_iterator i = gs->map->objects.begin(); i != gs->map->objects.end(); i++) //unflag objs { if(*i && (*i)->tempOwner == player) - setOwner((**i).id,NEUTRAL_PLAYER); + setOwner((**i).id,GameConstants::NEUTRAL_PLAYER); } //eliminating one player may cause victory of another: - winLoseHandle(ALL_PLAYERS & ~(1<map->victoryCondition.condition) { - case artifact: + case EVictoryConditionType::ARTIFACT: out.text.addTxt(MetaString::GENERAL_TXT, 280); //Congratulations! You have found the %s, and can claim victory! out.text.addReplacement(MetaString::ART_NAMES,gs->map->victoryCondition.ID); //artifact name break; - case gatherTroop: + case EVictoryConditionType::GATHERTROOP: out.text.addTxt(MetaString::GENERAL_TXT, 276); //Congratulations! You have over %d %s in your armies. Your enemies have no choice but to bow down before your power! out.text.addReplacement(gs->map->victoryCondition.count); out.text.addReplacement(MetaString::CRE_PL_NAMES, gs->map->victoryCondition.ID); break; - case gatherResource: + case EVictoryConditionType::GATHERRESOURCE: out.text.addTxt(MetaString::GENERAL_TXT, 278); //Congratulations! You have collected over %d %s in your treasury. Victory is yours! out.text.addReplacement(gs->map->victoryCondition.count); out.text.addReplacement(MetaString::RES_NAMES, gs->map->victoryCondition.ID); break; - case buildCity: + case EVictoryConditionType::BUILDCITY: out.text.addTxt(MetaString::GENERAL_TXT, 282); //Congratulations! You have successfully upgraded your town, and can claim victory! break; - case buildGrail: + case EVictoryConditionType::BUILDGRAIL: out.text.addTxt(MetaString::GENERAL_TXT, 284); //Congratulations! You have constructed a permanent home for the Grail, and can claim victory! break; - case beatHero: + case EVictoryConditionType::BEATHERO: { out.text.addTxt(MetaString::GENERAL_TXT, 252); //Congratulations! You have completed your quest to defeat the enemy hero %s. Victory is yours! const CGHeroInstance *h = dynamic_cast(gs->map->victoryCondition.obj); @@ -4525,7 +4527,7 @@ void CGameHandler::getLossVicMessage( ui8 player, ui8 standard, bool victory, In out.text.addReplacement(h->name); } break; - case captureCity: + case EVictoryConditionType::CAPTURECITY: { out.text.addTxt(MetaString::GENERAL_TXT, 249); //Congratulations! You captured %s, and are victorious! const CGTownInstance *t = dynamic_cast(gs->map->victoryCondition.obj); @@ -4533,16 +4535,16 @@ void CGameHandler::getLossVicMessage( ui8 player, ui8 standard, bool victory, In out.text.addReplacement(t->name); } break; - case beatMonster: + case EVictoryConditionType::BEATMONSTER: out.text.addTxt(MetaString::GENERAL_TXT, 286); //Congratulations! You have completed your quest to kill the fearsome beast, and can claim victory! break; - case takeDwellings: + case EVictoryConditionType::TAKEDWELLINGS: out.text.addTxt(MetaString::GENERAL_TXT, 288); //Congratulations! Your flag flies on the dwelling of every creature. Victory is yours! break; - case takeMines: + case EVictoryConditionType::TAKEMINES: out.text.addTxt(MetaString::GENERAL_TXT, 290); //Congratulations! Your flag flies on every mine. Victory is yours! break; - case transportItem: + case EVictoryConditionType::TRANSPORTITEM: out.text.addTxt(MetaString::GENERAL_TXT, 292); //Congratulations! You have reached your destination, precious cargo intact, and can claim victory! break; } @@ -4558,7 +4560,7 @@ void CGameHandler::getLossVicMessage( ui8 player, ui8 standard, bool victory, In { switch(gs->map->lossCondition.typeOfLossCon) { - case lossCastle: + case ELossConditionType::LOSSCASTLE: { out.text.addTxt(MetaString::GENERAL_TXT, 251); //The town of %s has fallen - all is lost! const CGTownInstance *t = dynamic_cast(gs->map->lossCondition.obj); @@ -4566,7 +4568,7 @@ void CGameHandler::getLossVicMessage( ui8 player, ui8 standard, bool victory, In out.text.addReplacement(t->name); } break; - case lossHero: + case ELossConditionType::LOSSHERO: { out.text.addTxt(MetaString::GENERAL_TXT, 253); //The hero, %s, has suffered defeat - your quest is over! const CGHeroInstance *h = dynamic_cast(gs->map->lossCondition.obj); @@ -4574,7 +4576,7 @@ void CGameHandler::getLossVicMessage( ui8 player, ui8 standard, bool victory, In out.text.addReplacement(h->name); } break; - case timeExpires: + case ELossConditionType::TIMEEXPIRES: out.text.addTxt(MetaString::GENERAL_TXT, 254); //Alas, time has run out on your quest. All is lost. break; } @@ -4673,17 +4675,17 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta TBonusListPtr spellsByType = attacker->getBonuses(Selector::typeSubtype(attackMode, spellID)); BOOST_FOREACH(const Bonus *sf, *spellsByType) { - amax(spellLevel, sf->additionalInfo % 1000); //pick highest level + vstd::amax(spellLevel, sf->additionalInfo % 1000); //pick highest level meleeRanged = sf->additionalInfo / 1000; if (meleeRanged == 0 || (meleeRanged == 1 && bat.shot()) || (meleeRanged == 2 && !bat.shot())) castMe = true; } int chance = attacker->valOfBonuses((Selector::typeSubtype(attackMode, spellID))); - amin (chance, 100); + vstd::amin (chance, 100); int destination = oneOfAttacked->position; const CSpell * spell = VLC->spellh->spells[spellID]; - if(gs->curB->battleCanCastThisSpellHere(attacker->owner, spell, SpellCasting::AFTER_ATTACK_CASTING, oneOfAttacked->position) != SpellCasting::OK) + if(gs->curB->battleCanCastThisSpellHere(attacker->owner, spell, ECastingMode::AFTER_ATTACK_CASTING, oneOfAttacked->position) != ESpellCastProblem::OK) continue; //check if spell should be casted (probability handling) @@ -4692,7 +4694,7 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta //casting //TODO: check if spell can be blocked or target is immune if (castMe) //stacks use 0 spell power. If needed, default = 3 or custom value is used - handleSpellCasting(spellID, spellLevel, destination, !attacker->attackerOwned, attacker->owner, NULL, NULL, 0, SpellCasting::AFTER_ATTACK_CASTING, attacker); + handleSpellCasting(spellID, spellLevel, destination, !attacker->attackerOwned, attacker->owner, NULL, NULL, 0, ECastingMode::AFTER_ATTACK_CASTING, attacker); } } } @@ -4727,7 +4729,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat ) { if (bat.bsa.size() && bat.bsa[0].newAmount > 0) //TODO: death stare was not originally available for multiple-hex attacks, but... handleSpellCasting(79, 0, gs->curB->getStack(bat.bsa[0].stackAttacked)->position, - !attacker->attackerOwned, attacker->owner, NULL, NULL, staredCreatures, SpellCasting::AFTER_ATTACK_CASTING, attacker); + !attacker->attackerOwned, attacker->owner, NULL, NULL, staredCreatures, ECastingMode::AFTER_ATTACK_CASTING, attacker); } } int acidDamage = 0; @@ -4741,7 +4743,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat ) { handleSpellCasting(81, 0, gs->curB->getStack(bat.bsa[0].stackAttacked)->position, !attacker->attackerOwned, attacker->owner, NULL, NULL, - acidDamage * attacker->count, SpellCasting::AFTER_ATTACK_CASTING, attacker); + acidDamage * attacker->count, ECastingMode::AFTER_ATTACK_CASTING, attacker); } } @@ -4927,7 +4929,7 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p if (!gs->map->isInTheMap(pos)) COMPLAIN_RET("Destination tile not present!") TerrainTile tile = gs->map->getTile(pos); - if (tile.visitableObjects.empty() || tile.visitableObjects.back()->ID != TOWNI_TYPE ) + if (tile.visitableObjects.empty() || tile.visitableObjects.back()->ID != GameConstants::TOWNI_TYPE ) COMPLAIN_RET("Town not found for Town Portal!"); CGTownInstance * town = static_cast(tile.visitableObjects.back()); @@ -5010,7 +5012,7 @@ bool CGameHandler::sacrificeCreatures(const IMarket *market, const CGHeroInstanc changeStackCount(StackLocation(hero, slot), -count); int dump, exp; - market->getOffer(crid, 0, dump, exp, CREATURE_EXP); + market->getOffer(crid, 0, dump, exp, EMarketMode::CREATURE_EXP); exp *= count; changePrimSkill(hero->id, 4, hero->calculateXp(exp)); @@ -5027,7 +5029,7 @@ bool CGameHandler::sacrificeArtifact(const IMarket * m, const CGHeroInstance * h int dmp, expToGive; - m->getOffer(hero->getArtTypeId(slot), 0, dmp, expToGive, ARTIFACT_EXP); + m->getOffer(hero->getArtTypeId(slot), 0, dmp, expToGive, EMarketMode::ARTIFACT_EXP); removeArtifact(al); changePrimSkill(hero->id, 4, expToGive); @@ -5217,7 +5219,7 @@ void CGameHandler::runBattle() TBonusListPtr bl = gs->curB->heroes[i]->getBonuses(Selector::type(Bonus::OPENING_BATTLE_SPELL)); BOOST_FOREACH (Bonus *b, *bl) { - handleSpellCasting(b->subtype, 3, -1, 0, gs->curB->heroes[i]->tempOwner, NULL, gs->curB->heroes[1-i], b->val, SpellCasting::HERO_CASTING, NULL); + handleSpellCasting(b->subtype, 3, -1, 0, gs->curB->heroes[i]->tempOwner, NULL, gs->curB->heroes[1-i], b->val, ECastingMode::HERO_CASTING, NULL); } } } @@ -5374,7 +5376,7 @@ void CGameHandler::runBattle() { stackTurnTrigger(next); //various effects - if (vstd::contains(next->state, FEAR)) + if (vstd::contains(next->state, EBattleStackState::FEAR)) { makeStackDoNothing(next); //end immediately if stack was affected by fear } @@ -5402,10 +5404,10 @@ void CGameHandler::runBattle() //check for good morale nextStackMorale = next->MoraleVal(); - if(!vstd::contains(next->state,HAD_MORALE) //only one extra move per turn possible - && !vstd::contains(next->state,DEFENDING) - && !vstd::contains(next->state,WAITING) - && !vstd::contains(next->state, FEAR) + if(!vstd::contains(next->state,EBattleStackState::HAD_MORALE) //only one extra move per turn possible + && !vstd::contains(next->state,EBattleStackState::DEFENDING) + && !vstd::contains(next->state,EBattleStackState::WAITING) + && !vstd::contains(next->state, EBattleStackState::FEAR) && next->alive() && nextStackMorale > 0 && !(NBonus::hasOfType(gs->curB->heroes[0], Bonus::BLOCK_MORALE) || NBonus::hasOfType(gs->curB->heroes[1], Bonus::BLOCK_MORALE)) //checking if gs->curB->heroes have (or don't have) morale blocking bonuses @@ -5531,11 +5533,11 @@ CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance *army, BattleI { int color = army->tempOwner; if(color == 254) - color = NEUTRAL_PLAYER; + color = GameConstants::NEUTRAL_PLAYER; BOOST_FOREACH(CStack *st, bat->stacks) { - if(vstd::contains(st->state, SUMMONED)) //don't take into account summoned stacks + if(vstd::contains(st->state, EBattleStackState::SUMMONED)) //don't take into account summoned stacks continue; if(st->owner==color && !army->slotEmpty(st->slot) && st->count < army->getStackCount(st->slot)) diff --git a/server/CGameHandler.h b/server/CGameHandler.h index 0ed269248..724f910da 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -1,17 +1,12 @@ -#ifndef __CGAMEHANDLER_H__ -#define __CGAMEHANDLER_H__ +#pragma once + -#include "../global.h" -#include -#include #include "../client/FunctionList.h" #include "../lib/CGameState.h" #include "../lib/Connection.h" #include "../lib/IGameCallback.h" #include "../lib/BattleAction.h" #include "../lib/NetPacks.h" -#include -#include /* * CGameHandler.h, part of VCMI engine @@ -106,7 +101,7 @@ public: bool isAllowedExchange(int id1, int id2); bool isAllowedArrangePack(const ArrangeStacks *pack); void giveSpells(const CGTownInstance *t, const CGHeroInstance *h); - int moveStack(int stack, THex dest); //returned value - travelled distance + int moveStack(int stack, SHexField dest); //returned value - travelled distance void startBattle(const CArmedInstance *armies[2], int3 tile, const CGHeroInstance *heroes[2], bool creatureBank, boost::function cb, const CGTownInstance *town = NULL); //use hero=NULL for no hero void runBattle(); void checkLossVictory(ui8 player); @@ -197,7 +192,7 @@ public: void playerMessage( ui8 player, const std::string &message); bool makeBattleAction(BattleAction &ba); - void handleSpellCasting(int spellID, int spellLvl, THex destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode, const CStack * stack); + void handleSpellCasting(int spellID, int spellLvl, SHexField destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, ECastingMode::ECastingMode mode, const CStack * stack); bool makeCustomAction(BattleAction &ba); void stackTurnTrigger(const CStack * stack); bool queryReply( ui32 qid, ui32 answer, ui8 player ); @@ -262,6 +257,4 @@ public: friend class CScriptCallback; }; -#endif // __CGAMEHANDLER_H__ - void makeStackDoNothing(); diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 7c7609593..d6274d4a9 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -1,31 +1,41 @@ -#include "stdafx.h" +#include "StdInc.h" + +#include //no i/o just types +#include +#include +#include +#include +#include + + + #include "../lib/CCampaignHandler.h" -#include "../global.h" +#include "../lib/CThreadHelper.h" #include "../lib/Connection.h" #include "../lib/CArtHandler.h" #include "../lib/CDefObjInfoHandler.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CTownHandler.h" -#include "../lib/CObjectHandler.h" #include "../lib/CBuildingHandler.h" #include "../lib/CSpellHandler.h" #include "../lib/CCreatureHandler.h" #include "zlib.h" -#ifndef __GNUC__ -#include -#endif #include "CVCMIServer.h" -#include "../StartInfo.h" +#include "../lib/StartInfo.h" #include "../lib/map.h" #include "../lib/Interprocess.h" #include "../lib/VCMI_Lib.h" #include "../lib/VCMIDirs.h" #include "CGameHandler.h" #include "../lib/CMapInfo.h" +#include "../lib/CObjectHandler.h" +#include "../lib/GameConstants.h" + +#include std::string NAME_AFFIX = "server"; -std::string NAME = NAME_VER + std::string(" (") + NAME_AFFIX + ')'; //application name +std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name using namespace boost; using namespace boost::asio; using namespace boost::asio::ip; @@ -120,7 +130,7 @@ void CPregameServer::handleConnection(CConnection *cpc) tlog0 << "Thread listening for " << *cpc << " ended\n"; listeningThreads--; - delNull(cpc->handler); + vstd::clear_pointer(cpc->handler); } void CPregameServer::run() @@ -261,14 +271,14 @@ void CPregameServer::processPack(CPackForSelectionScreen * pack) } else if(SelectMap *sm = dynamic_cast(pack)) { - delNull(curmap); + vstd::clear_pointer(curmap); curmap = sm->mapInfo; sm->free = false; announcePack(*pack); } else if(UpdateStartOptions *uso = dynamic_cast(pack)) { - delNull(curStartInfo); + vstd::clear_pointer(curStartInfo); curStartInfo = uso->options; uso->free = false; announcePack(*pack); @@ -298,7 +308,7 @@ void CPregameServer::startListeningThread(CConnection * pc) } CVCMIServer::CVCMIServer() -: io(new io_service()), acceptor(new TAcceptor(*io, tcp::endpoint(tcp::v4(), port))), firstConnection(NULL) +: io(new boost::asio::io_service()), acceptor(new TAcceptor(*io, tcp::endpoint(tcp::v4(), port))), firstConnection(NULL) { tlog4 << "CVCMIServer created!" <run(false); - delNull(gh); + vstd::clear_pointer(gh); } void CVCMIServer::newPregame() @@ -518,7 +528,7 @@ int main(int argc, char** argv) } tlog0 << "Port " << port << " will be used." << std::endl; initDLL(console,logfile); - srand ( (unsigned int)time(NULL) ); + srand ( (ui32)time(NULL) ); try { io_service io_service; diff --git a/server/CVCMIServer.h b/server/CVCMIServer.h index 642b00a91..64649fde8 100644 --- a/server/CVCMIServer.h +++ b/server/CVCMIServer.h @@ -1,8 +1,6 @@ -#ifndef __CVCMISERVER_H__ -#define __CVCMISERVER_H__ -#include "../global.h" -#include -#include +#pragma once + + /* * CVCMIServer.h, part of VCMI engine @@ -98,6 +96,3 @@ public: void sendPack(CConnection * pc, const CPackForSelectionScreen & pack); void startListeningThread(CConnection * pc); }; - - -#endif // __CVCMISERVER_H__ diff --git a/server/Makefile.am b/server/Makefile.am index c34c7763a..1ab6d83f8 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -1,17 +1,14 @@ bin_PROGRAMS = vcmiserver +BUILT_SOURCES = StdInc.h.gch +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -c $< -vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ -lrt +vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ -lrt -lpthread vcmiserver_CXXFLAGS = @SDL_CFLAGS@ vcmiserver_LDFLAGS = -L$(top_builddir)/lib vcmiserver_SOURCES = \ - ../CConsoleHandler.cpp \ - ../CConsoleHandler.h \ - ../CThreadHelper.cpp \ - ../CThreadHelper.h \ CGameHandler.cpp \ CGameHandler.h \ CVCMIServer.cpp \ CVCMIServer.h \ - NetPacksServer.cpp \ - stdafx.cpp \ - stdafx.h + NetPacksServer.cpp diff --git a/server/Makefile.in b/server/Makefile.in index 950247b4a..df37ed3e2 100644 --- a/server/Makefile.in +++ b/server/Makefile.in @@ -58,12 +58,9 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am_vcmiserver_OBJECTS = vcmiserver-CConsoleHandler.$(OBJEXT) \ - vcmiserver-CThreadHelper.$(OBJEXT) \ - vcmiserver-CGameHandler.$(OBJEXT) \ +am_vcmiserver_OBJECTS = vcmiserver-CGameHandler.$(OBJEXT) \ vcmiserver-CVCMIServer.$(OBJEXT) \ - vcmiserver-NetPacksServer.$(OBJEXT) \ - vcmiserver-stdafx.$(OBJEXT) + vcmiserver-NetPacksServer.$(OBJEXT) vcmiserver_OBJECTS = $(am_vcmiserver_OBJECTS) vcmiserver_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la AM_V_lt = $(am__v_lt_$(V)) @@ -253,23 +250,19 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ -lrt +BUILT_SOURCES = StdInc.h.gch +vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ -lrt -lpthread vcmiserver_CXXFLAGS = @SDL_CFLAGS@ vcmiserver_LDFLAGS = -L$(top_builddir)/lib vcmiserver_SOURCES = \ - ../CConsoleHandler.cpp \ - ../CConsoleHandler.h \ - ../CThreadHelper.cpp \ - ../CThreadHelper.h \ CGameHandler.cpp \ CGameHandler.h \ CVCMIServer.cpp \ CVCMIServer.h \ - NetPacksServer.cpp \ - stdafx.cpp \ - stdafx.h + NetPacksServer.cpp -all: all-am +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj @@ -356,12 +349,9 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiserver-CConsoleHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiserver-CGameHandler.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiserver-CThreadHelper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiserver-CVCMIServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiserver-NetPacksServer.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiserver-stdafx.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -387,38 +377,6 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< -vcmiserver-CConsoleHandler.o: ../CConsoleHandler.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -MT vcmiserver-CConsoleHandler.o -MD -MP -MF $(DEPDIR)/vcmiserver-CConsoleHandler.Tpo -c -o vcmiserver-CConsoleHandler.o `test -f '../CConsoleHandler.cpp' || echo '$(srcdir)/'`../CConsoleHandler.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiserver-CConsoleHandler.Tpo $(DEPDIR)/vcmiserver-CConsoleHandler.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CConsoleHandler.cpp' object='vcmiserver-CConsoleHandler.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -c -o vcmiserver-CConsoleHandler.o `test -f '../CConsoleHandler.cpp' || echo '$(srcdir)/'`../CConsoleHandler.cpp - -vcmiserver-CConsoleHandler.obj: ../CConsoleHandler.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -MT vcmiserver-CConsoleHandler.obj -MD -MP -MF $(DEPDIR)/vcmiserver-CConsoleHandler.Tpo -c -o vcmiserver-CConsoleHandler.obj `if test -f '../CConsoleHandler.cpp'; then $(CYGPATH_W) '../CConsoleHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/../CConsoleHandler.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiserver-CConsoleHandler.Tpo $(DEPDIR)/vcmiserver-CConsoleHandler.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CConsoleHandler.cpp' object='vcmiserver-CConsoleHandler.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -c -o vcmiserver-CConsoleHandler.obj `if test -f '../CConsoleHandler.cpp'; then $(CYGPATH_W) '../CConsoleHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/../CConsoleHandler.cpp'; fi` - -vcmiserver-CThreadHelper.o: ../CThreadHelper.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -MT vcmiserver-CThreadHelper.o -MD -MP -MF $(DEPDIR)/vcmiserver-CThreadHelper.Tpo -c -o vcmiserver-CThreadHelper.o `test -f '../CThreadHelper.cpp' || echo '$(srcdir)/'`../CThreadHelper.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiserver-CThreadHelper.Tpo $(DEPDIR)/vcmiserver-CThreadHelper.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CThreadHelper.cpp' object='vcmiserver-CThreadHelper.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -c -o vcmiserver-CThreadHelper.o `test -f '../CThreadHelper.cpp' || echo '$(srcdir)/'`../CThreadHelper.cpp - -vcmiserver-CThreadHelper.obj: ../CThreadHelper.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -MT vcmiserver-CThreadHelper.obj -MD -MP -MF $(DEPDIR)/vcmiserver-CThreadHelper.Tpo -c -o vcmiserver-CThreadHelper.obj `if test -f '../CThreadHelper.cpp'; then $(CYGPATH_W) '../CThreadHelper.cpp'; else $(CYGPATH_W) '$(srcdir)/../CThreadHelper.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiserver-CThreadHelper.Tpo $(DEPDIR)/vcmiserver-CThreadHelper.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CThreadHelper.cpp' object='vcmiserver-CThreadHelper.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -c -o vcmiserver-CThreadHelper.obj `if test -f '../CThreadHelper.cpp'; then $(CYGPATH_W) '../CThreadHelper.cpp'; else $(CYGPATH_W) '$(srcdir)/../CThreadHelper.cpp'; fi` - vcmiserver-CGameHandler.o: CGameHandler.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -MT vcmiserver-CGameHandler.o -MD -MP -MF $(DEPDIR)/vcmiserver-CGameHandler.Tpo -c -o vcmiserver-CGameHandler.o `test -f 'CGameHandler.cpp' || echo '$(srcdir)/'`CGameHandler.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiserver-CGameHandler.Tpo $(DEPDIR)/vcmiserver-CGameHandler.Po @@ -467,22 +425,6 @@ vcmiserver-NetPacksServer.obj: NetPacksServer.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -c -o vcmiserver-NetPacksServer.obj `if test -f 'NetPacksServer.cpp'; then $(CYGPATH_W) 'NetPacksServer.cpp'; else $(CYGPATH_W) '$(srcdir)/NetPacksServer.cpp'; fi` -vcmiserver-stdafx.o: stdafx.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -MT vcmiserver-stdafx.o -MD -MP -MF $(DEPDIR)/vcmiserver-stdafx.Tpo -c -o vcmiserver-stdafx.o `test -f 'stdafx.cpp' || echo '$(srcdir)/'`stdafx.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiserver-stdafx.Tpo $(DEPDIR)/vcmiserver-stdafx.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='stdafx.cpp' object='vcmiserver-stdafx.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -c -o vcmiserver-stdafx.o `test -f 'stdafx.cpp' || echo '$(srcdir)/'`stdafx.cpp - -vcmiserver-stdafx.obj: stdafx.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -MT vcmiserver-stdafx.obj -MD -MP -MF $(DEPDIR)/vcmiserver-stdafx.Tpo -c -o vcmiserver-stdafx.obj `if test -f 'stdafx.cpp'; then $(CYGPATH_W) 'stdafx.cpp'; else $(CYGPATH_W) '$(srcdir)/stdafx.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiserver-stdafx.Tpo $(DEPDIR)/vcmiserver-stdafx.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='stdafx.cpp' object='vcmiserver-stdafx.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiserver_CXXFLAGS) $(CXXFLAGS) -c -o vcmiserver-stdafx.obj `if test -f 'stdafx.cpp'; then $(CYGPATH_W) 'stdafx.cpp'; else $(CYGPATH_W) '$(srcdir)/stdafx.cpp'; fi` - mostlyclean-libtool: -rm -f *.lo @@ -572,13 +514,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -603,6 +547,7 @@ distclean-generic: 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-binPROGRAMS clean-generic clean-libtool mostlyclean-am @@ -673,7 +618,7 @@ ps-am: uninstall-am: uninstall-binPROGRAMS -.MAKE: install-am install-strip +.MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool ctags distclean distclean-compile \ @@ -689,6 +634,8 @@ uninstall-am: uninstall-binPROGRAMS pdf pdf-am ps ps-am tags uninstall uninstall-am \ uninstall-binPROGRAMS +StdInc.h.gch: StdInc.h + $(CXXCOMPILE) -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. diff --git a/server/NetPacksServer.cpp b/server/NetPacksServer.cpp index a83863271..b96871828 100644 --- a/server/NetPacksServer.cpp +++ b/server/NetPacksServer.cpp @@ -1,5 +1,6 @@ -#include "stdafx.h" +#include "StdInc.h" #include "../lib/NetPacks.h" + #include "CGameHandler.h" #include "../lib/CObjectHandler.h" #include "../lib/IGameCallback.h" @@ -158,10 +159,10 @@ bool TradeOnMarketplace::applyGh( CGameHandler *gh ) ui8 player = market->tempOwner; - if(player >= PLAYER_LIMIT) + if(player >= GameConstants::PLAYER_LIMIT) player = gh->getTile(market->visitablePos())->visitableObjects.back()->tempOwner; - if(player >= PLAYER_LIMIT) + if(player >= GameConstants::PLAYER_LIMIT) COMPLAIN_AND_RETURN("No player can use this market!"); if(hero && (player != hero->tempOwner || hero->visitablePos() != market->visitablePos())) @@ -171,29 +172,29 @@ bool TradeOnMarketplace::applyGh( CGameHandler *gh ) switch(mode) { - case RESOURCE_RESOURCE: + case EMarketMode::RESOURCE_RESOURCE: return gh->tradeResources(m, val, player, r1, r2); - case RESOURCE_PLAYER: + case EMarketMode::RESOURCE_PLAYER: return gh->sendResources(val, player, r1, r2); - case CREATURE_RESOURCE: + case EMarketMode::CREATURE_RESOURCE: if(!hero) COMPLAIN_AND_RETURN("Only hero can sell creatures!"); return gh->sellCreatures(val, m, hero, r1, r2); - case RESOURCE_ARTIFACT: + case EMarketMode::RESOURCE_ARTIFACT: if(!hero) COMPLAIN_AND_RETURN("Only hero can buy artifacts!"); return gh->buyArtifact(m, hero, r1, r2); - case ARTIFACT_RESOURCE: + case EMarketMode::ARTIFACT_RESOURCE: if(!hero) COMPLAIN_AND_RETURN("Only hero can sell artifacts!"); return gh->sellArtifact(m, hero, r1, r2); - case CREATURE_UNDEAD: + case EMarketMode::CREATURE_UNDEAD: return gh->transformInUndead(m, hero, r1); - case RESOURCE_SKILL: + case EMarketMode::RESOURCE_SKILL: return gh->buySecSkill(m, hero, r2); - case CREATURE_EXP: + case EMarketMode::CREATURE_EXP: return gh->sacrificeCreatures(m, hero, r1, val); - case ARTIFACT_EXP: + case EMarketMode::ARTIFACT_EXP: return gh->sacrificeArtifact(m, hero, r1); default: COMPLAIN_AND_RETURN("Unknown exchange mode!"); @@ -210,7 +211,7 @@ bool HireHero::applyGh( CGameHandler *gh ) { const CGObjectInstance *obj = gh->getObj(tid); - if(obj->ID == TOWNI_TYPE) + if(obj->ID == GameConstants::TOWNI_TYPE) ERROR_IF_NOT_OWNS(tid); //TODO check for visiting hero diff --git a/server/VCMI_server.vcxproj b/server/VCMI_server.vcxproj index 1a75b0046..1a5a4e52a 100644 --- a/server/VCMI_server.vcxproj +++ b/server/VCMI_server.vcxproj @@ -100,11 +100,11 @@ false EnableFastChecks MultiThreadedDebugDLL - Level1 + Level3 EditAndContinue 4251;%(DisableSpecificWarnings) Use - stdafx.h + StdInc.h VCMI_lib.lib;zlib.lib;%(AdditionalDependencies) @@ -198,17 +198,15 @@ - + Create - Create - Create - Create + StdInc.h - +