1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

- (linux) build system update

- gcc errors/warnings fixes
This commit is contained in:
Ivan Savenko 2011-07-05 11:31:26 +00:00
parent b3234e8bfa
commit b8448e4c3b
6 changed files with 86 additions and 76 deletions

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "StupidAI.h"
#include <cstring>
#ifdef __GNUC__
#define strcpy_s(a, b, c) strncpy(a, c, b)

View File

@ -8,8 +8,6 @@ vcmiclient_SOURCES = \
../CCallback.h \
../CConsoleHandler.cpp \
../CConsoleHandler.h \
../CGameInterface.cpp \
../CGameInterface.h \
../CThreadHelper.cpp \
../CThreadHelper.h \
AdventureMapButton.cpp \

View File

@ -60,7 +60,6 @@ am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_vcmiclient_OBJECTS = vcmiclient-CCallback.$(OBJEXT) \
vcmiclient-CConsoleHandler.$(OBJEXT) \
vcmiclient-CGameInterface.$(OBJEXT) \
vcmiclient-CThreadHelper.$(OBJEXT) \
vcmiclient-AdventureMapButton.$(OBJEXT) \
vcmiclient-CAdvmapInterface.$(OBJEXT) \
@ -282,8 +281,6 @@ vcmiclient_SOURCES = \
../CCallback.h \
../CConsoleHandler.cpp \
../CConsoleHandler.h \
../CGameInterface.cpp \
../CGameInterface.h \
../CThreadHelper.cpp \
../CThreadHelper.h \
AdventureMapButton.cpp \
@ -450,7 +447,6 @@ distclean-compile:
@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-CGameInfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CGameInterface.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CHeroWindow.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@
@ -527,22 +523,6 @@ vcmiclient-CConsoleHandler.obj: ../CConsoleHandler.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-CConsoleHandler.obj `if test -f '../CConsoleHandler.cpp'; then $(CYGPATH_W) '../CConsoleHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/../CConsoleHandler.cpp'; fi`
vcmiclient-CGameInterface.o: ../CGameInterface.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CGameInterface.o -MD -MP -MF $(DEPDIR)/vcmiclient-CGameInterface.Tpo -c -o vcmiclient-CGameInterface.o `test -f '../CGameInterface.cpp' || echo '$(srcdir)/'`../CGameInterface.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CGameInterface.Tpo $(DEPDIR)/vcmiclient-CGameInterface.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CGameInterface.cpp' object='vcmiclient-CGameInterface.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-CGameInterface.o `test -f '../CGameInterface.cpp' || echo '$(srcdir)/'`../CGameInterface.cpp
vcmiclient-CGameInterface.obj: ../CGameInterface.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CGameInterface.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CGameInterface.Tpo -c -o vcmiclient-CGameInterface.obj `if test -f '../CGameInterface.cpp'; then $(CYGPATH_W) '../CGameInterface.cpp'; else $(CYGPATH_W) '$(srcdir)/../CGameInterface.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/vcmiclient-CGameInterface.Tpo $(DEPDIR)/vcmiclient-CGameInterface.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../CGameInterface.cpp' object='vcmiclient-CGameInterface.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-CGameInterface.obj `if test -f '../CGameInterface.cpp'; then $(CYGPATH_W) '../CGameInterface.cpp'; else $(CYGPATH_W) '$(srcdir)/../CGameInterface.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

View File

@ -1,5 +1,5 @@
pkglib_LTLIBRARIES = libvcmi.la
libvcmi_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lz -lpthread
libvcmi_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lz -lpthread -ldl
libvcmi_la_CXXFLAGS = @SDL_CXXFLAGS@
libvcmi_la_SOURCES = \
BattleAction.cpp \
@ -20,6 +20,8 @@ libvcmi_la_SOURCES = \
CDefObjInfoHandler.h \
CFileUtility.cpp \
CFileUtility.h \
CGameInterface.cpp \
CGameInterface.h \
CGameState.cpp \
CGameState.h \
CGeneralTextHandler.cpp \
@ -50,6 +52,8 @@ libvcmi_la_SOURCES = \
Interprocess.h \
NetPacks.h \
NetPacksLib.cpp \
ResourceSet.cpp \
ResourceSet.h \
RegisterTypes.cpp \
RegisterTypes.h \
VCMIDirs.h \

View File

@ -84,12 +84,13 @@ am_libvcmi_la_OBJECTS = libvcmi_la-BattleAction.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-CGameState.lo libvcmi_la-CGeneralTextHandler.lo \
libvcmi_la-CHeroHandler.lo libvcmi_la-CLodHandler.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-NetPacksLib.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-CObjectHandler.lo libvcmi_la-CSpellHandler.lo \
libvcmi_la-CTownHandler.lo libvcmi_la-Connection.lo \
libvcmi_la-HeroBonus.lo libvcmi_la-IGameCallback.lo \
libvcmi_la-NetPacksLib.lo libvcmi_la-ResourceSet.lo \
libvcmi_la-RegisterTypes.lo libvcmi_la-VCMI_Lib.lo \
libvcmi_la-map.lo
libvcmi_la_OBJECTS = $(am_libvcmi_la_OBJECTS)
@ -278,7 +279,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
pkglib_LTLIBRARIES = libvcmi.la
libvcmi_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lz -lpthread
libvcmi_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lz -lpthread -ldl
libvcmi_la_CXXFLAGS = @SDL_CXXFLAGS@
libvcmi_la_SOURCES = \
BattleAction.cpp \
@ -299,6 +300,8 @@ libvcmi_la_SOURCES = \
CDefObjInfoHandler.h \
CFileUtility.cpp \
CFileUtility.h \
CGameInterface.cpp \
CGameInterface.h \
CGameState.cpp \
CGameState.h \
CGeneralTextHandler.cpp \
@ -329,6 +332,8 @@ libvcmi_la_SOURCES = \
Interprocess.h \
NetPacks.h \
NetPacksLib.cpp \
ResourceSet.cpp \
ResourceSet.h \
RegisterTypes.cpp \
RegisterTypes.h \
VCMIDirs.h \
@ -420,6 +425,7 @@ distclean-compile:
@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@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CFileUtility.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CGameInterface.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CGameState.Plo@am__quote@
@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@
@ -433,6 +439,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-IGameCallback.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-VCMI_Lib.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-map.Plo@am__quote@
@ -532,6 +539,14 @@ libvcmi_la-CFileUtility.lo: CFileUtility.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-CFileUtility.lo `test -f 'CFileUtility.cpp' || echo '$(srcdir)/'`CFileUtility.cpp
libvcmi_la-CGameInterface.lo: CGameInterface.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-CGameInterface.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-CGameInterface.Tpo -c -o libvcmi_la-CGameInterface.lo `test -f 'CGameInterface.cpp' || echo '$(srcdir)/'`CGameInterface.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-CGameInterface.Tpo $(DEPDIR)/libvcmi_la-CGameInterface.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CGameInterface.cpp' object='libvcmi_la-CGameInterface.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-CGameInterface.lo `test -f 'CGameInterface.cpp' || echo '$(srcdir)/'`CGameInterface.cpp
libvcmi_la-CGameState.lo: CGameState.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-CGameState.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-CGameState.Tpo -c -o libvcmi_la-CGameState.lo `test -f 'CGameState.cpp' || echo '$(srcdir)/'`CGameState.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-CGameState.Tpo $(DEPDIR)/libvcmi_la-CGameState.Plo
@ -628,6 +643,14 @@ libvcmi_la-NetPacksLib.lo: NetPacksLib.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-NetPacksLib.lo `test -f 'NetPacksLib.cpp' || echo '$(srcdir)/'`NetPacksLib.cpp
libvcmi_la-ResourceSet.lo: ResourceSet.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-ResourceSet.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-ResourceSet.Tpo -c -o libvcmi_la-ResourceSet.lo `test -f 'ResourceSet.cpp' || echo '$(srcdir)/'`ResourceSet.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-ResourceSet.Tpo $(DEPDIR)/libvcmi_la-ResourceSet.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ResourceSet.cpp' object='libvcmi_la-ResourceSet.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-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

View File

@ -512,8 +512,8 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
const CGHeroInstance * h0 = gs->curB->heroes[0],
* h1 = gs->curB->heroes[1];
bool noLuck = false;
if(h0 && NBonus::hasOfType(h0, Bonus::BLOCK_LUCK) ||
h1 && NBonus::hasOfType(h1, Bonus::BLOCK_LUCK))
if((h0 && NBonus::hasOfType(h0, Bonus::BLOCK_LUCK)) ||
(h1 && NBonus::hasOfType(h1, Bonus::BLOCK_LUCK)))
{
noLuck = true;
}
@ -970,7 +970,7 @@ void CGameHandler::newTurn()
{
////SetResources r;
//r.player = (**j).tempOwner;
if(vstd::contains((**j).builtBuildings,15)) //there is resource silo
if(vstd::contains((**j).builtBuildings, Buildings::RESOURCE_SILO)) //there is resource silo
{
if((**j).town->primaryRes == 127) //we'll give wood and ore
{
@ -985,7 +985,7 @@ void CGameHandler::newTurn()
n.res[player][Res::GOLD] += (**j).dailyIncome();
}
handleTownEvents(*j, n, newCreas);
if (vstd::contains((**j).builtBuildings, 26))
if (vstd::contains((**j).builtBuildings, Buildings::GRAIL))
{
switch ((**j).subID)
{
@ -1299,7 +1299,7 @@ void CGameHandler::giveSpells( const CGTownInstance *t, const CGHeroInstance *h
cs.learn = true;
for(int i=0; i<std::min(t->mageGuildLevel(),h->getSecSkillLevel(CGHeroInstance::WISDOM)+2);i++)
{
if (t->subID == 8 && vstd::contains(t->builtBuildings, 26)) //Aurora Borealis
if (t->subID == 8 && vstd::contains(t->builtBuildings, Buildings::GRAIL)) //Aurora Borealis
{
std::vector<ui16> spells;
getAllowedSpells(spells, i);
@ -1385,16 +1385,16 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
//it's a rock or blocked and not visitable tile
//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)
&& complain("Cannot move hero, destination tile is on water!")
|| (h->boat && t.tertype != TerrainTile::water && t.blocked)
&& complain("Cannot disembark hero, tile is blocked!")
|| (h->movement < cost && dst != h->pos && !instant)
&& complain("Hero doesn't have any movement points left!")
|| states.checkFlag(h->tempOwner, &PlayerStatus::engagedIntoBattle)
&& complain("Cannot move hero during the battle"))
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)
&& complain("Cannot move hero, destination tile is on water!"))
|| ((h->boat && t.tertype != TerrainTile::water && t.blocked)
&& complain("Cannot disembark hero, tile is blocked!"))
|| ((h->movement < cost && dst != h->pos && !instant)
&& complain("Hero doesn't have any movement points left!"))
|| (states.checkFlag(h->tempOwner, &PlayerStatus::engagedIntoBattle)
&& complain("Cannot move hero during the battle")))
{
//send info about movement failure
sendAndApply(&tmh);
@ -1436,8 +1436,8 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
//checks for standard movement
if(!instant)
{
if( distance(h->pos,dst) >= 1.5 && complain("Tiles are not neighboring!")
|| h->movement < cost && h->movement < 100 && complain("Not enough move points!"))
if( (distance(h->pos,dst) >= 1.5 && complain("Tiles are not neighboring!"))
|| (h->movement < cost && h->movement < 100 && complain("Not enough move points!")))
{
sendAndApply(&tmh);
return false;
@ -1524,12 +1524,12 @@ bool CGameHandler::teleportHero(si32 hid, si32 dstid, ui8 source, ui8 asker/* =
tlog1<<"Invalid call to teleportHero!";
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, 22))
&& complain("Hero must be in town with Castle gate for teleporting")
|| (t->subID!=3 || !vstd::contains(t->builtBuildings, 22))
&& complain("Cannot teleport hero to town without Castle gate in it"))
if(((h->getOwner() != t->getOwner())
&& complain("Cannot teleport hero to another player"))
|| ((!from || from->subID!=3 || !vstd::contains(from->builtBuildings, Buildings::SPECIAL_3))
&& complain("Hero must be in town with Castle gate for teleporting"))
|| ((t->subID!=3 || !vstd::contains(t->builtBuildings, Buildings::SPECIAL_3))
&& complain("Cannot teleport hero to town without Castle gate in it")))
return false;
int3 pos = t->visitablePos();
pos += h->getVisitableOffset();
@ -1565,9 +1565,13 @@ void CGameHandler::setOwner(int objid, ui8 owner)
const PlayerState * p = gs->getPlayer(owner);
if((obj->ID == 17 || obj->ID == 20 ) && p && p->dwellings.size()==1)//first dwelling captured
{
BOOST_FOREACH(const CGTownInstance *t, gs->getPlayer(owner)->towns)
{
if (t->subID == 5 && vstd::contains(t->builtBuildings, 22))
setPortalDwelling(t);//set initial creatures for all portals of summoning
}
}
}
void CGameHandler::setHoverName(int objid, MetaString* name)
@ -2027,7 +2031,7 @@ bool CGameHandler::arrangeStacks( si32 id1, si32 id2, ui8 what, ui8 p1, ui8 p2,
else if(what==2)//merge
{
if (( S1.stacks[p1]->type != S2.stacks[p2]->type && complain("Cannot merge different creatures stacks!"))
|| ((s1->tempOwner != player && s1->tempOwner != 254) && S2.stacks[p2]->count) && complain("Can't take troops from another player!"))
|| (((s1->tempOwner != player && s1->tempOwner != 254) && S2.stacks[p2]->count) && complain("Can't take troops from another player!")))
return false;
moveStack(sl1, sl2);
@ -2297,10 +2301,10 @@ bool CGameHandler::recruitCreatures( si32 objid, ui32 crid, ui32 cram, si32 from
}
int slot = dst->getSlotFor(crid);
if(!found && complain("Cannot recruit: no such creatures!")
|| cram > VLC->creh->creatures[crid]->maxAmount(gs->getPlayer(dst->tempOwner)->resources) && complain("Cannot recruit: lack of resources!")
|| cram<=0 && complain("Cannot recruit: cram <= 0!")
|| slot<0 && !warMachine && complain("Cannot recruit: no available slot!"))
if( (!found && complain("Cannot recruit: no such creatures!"))
|| (cram > VLC->creh->creatures[crid]->maxAmount(gs->getPlayer(dst->tempOwner)->resources) && complain("Cannot recruit: lack of resources!"))
|| (cram<=0 && complain("Cannot recruit: cram <= 0!"))
|| (slot<0 && !warMachine && complain("Cannot recruit: no available slot!")))
{
return false;
}
@ -2583,10 +2587,10 @@ bool CGameHandler::buyArtifact( ui32 hid, si32 aid )
CGTownInstance *town = hero->visitedTown;
if(aid==0) //spellbook
{
if(!vstd::contains(town->builtBuildings,si32(0)) && 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(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!"))
)
return false;
giveResource(hero->getOwner(),Res::GOLD,-SPELLBOOK_GOLD_COST);
@ -2598,11 +2602,11 @@ bool CGameHandler::buyArtifact( ui32 hid, si32 aid )
else if(aid < 7 && aid > 3) //war machine
{
int price = VLC->arth->artifacts[aid]->price;
if(hero->getArt(9+aid) && complain("Hero already has this machine!")
|| !vstd::contains(town->builtBuildings,si32(16)) && 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(22) ) )
&& town->town->warMachine!= aid ) && complain("This machine is unavailable here!") )
if((hero->getArt(9+aid) && complain("Hero already has this machine!"))
|| (!vstd::contains(town->builtBuildings,si32(Buildings::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->town->warMachine!= aid ) && complain("This machine is unavailable here!")))
{
return false;
}
@ -2699,13 +2703,13 @@ bool CGameHandler::buySecSkill( const IMarket *m, const CGHeroInstance *h, int s
if(!vstd::contains(m->availableItemsIds(RESOURCE_SKILL), skill))
COMPLAIN_RET("That skill is unavailable!");
if(getResource(h->tempOwner, 6) < 2000)//TODO: remove hardcoded resource\summ?
if(getResource(h->tempOwner, Res::GOLD) < 2000)//TODO: remove hardcoded resource\summ?
COMPLAIN_RET("You can't afford to buy this skill");
SetResource sr;
sr.player = h->tempOwner;
sr.resid = 6;
sr.val = getResource(h->tempOwner, 6) - 2000;
sr.resid = Res::GOLD;
sr.val = getResource(h->tempOwner, Res::GOLD) - 2000;
sendAndApply(&sr);
changeSecSkill(h->id, skill, 1, true);
@ -2749,8 +2753,8 @@ bool CGameHandler::sellCreatures(ui32 count, const IMarket *market, const CGHero
const CStackInstance &s = hero->getStack(slot);
if(s.count < count //can't sell more creatures than have
|| hero->Slots().size() == 1 && hero->needsLastStack() && s.count == count) //can't sell last stack
if( s.count < count //can't sell more creatures than have
|| (hero->Slots().size() == 1 && hero->needsLastStack() && s.count == count)) //can't sell last stack
{
COMPLAIN_RET("Not enough creatures in army!");
}
@ -2839,14 +2843,14 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, ui8 player)
const CGTownInstance *t = gs->getTown(obj->id);
//common preconditions
if( p->resources[Res::GOLD]<2500 && complain("Not enough gold for buying hero!")
|| getHeroCount(player, false) >= 8 && complain("Cannot hire hero, only 8 wandering heroes are allowed!"))
if( (p->resources[Res::GOLD]<2500 && complain("Not enough gold for buying hero!"))
|| (getHeroCount(player, false) >= 8 && complain("Cannot hire hero, only 8 wandering heroes are allowed!")))
return false;
if(t) //tavern in town
{
if(!vstd::contains(t->builtBuildings,5) && complain("No tavern!")
|| t->visitingHero && complain("There is visiting hero - no place!"))
if( (!vstd::contains(t->builtBuildings,Buildings::TAVERN) && complain("No tavern!"))
|| (t->visitingHero && complain("There is visiting hero - no place!")))
return false;
}
else if(obj->ID == 95) //Tavern on adv map