From 2d7dbbefc31e8b11f9eb8c540337ab98f536226d Mon Sep 17 00:00:00 2001 From: mateuszb Date: Wed, 29 Aug 2007 12:18:31 +0000 Subject: [PATCH] * partially written hero moving * improvements in include system --- CAbilityHandler.cpp | 1 + CAdvmapInterface.cpp | 2 ++ CAdvmapInterface.h | 2 ++ CAmbarCendamo.cpp | 2 ++ CArtHandler.cpp | 1 + CBuildingHandler.cpp | 1 + CCallback.cpp | 17 ++++++++++++- CConsoleHandler.cpp | 21 ++++++++++++++-- CCreatureHandler.cpp | 1 + CCursorHandler.cpp | 2 +- CDefObjInfoHandler.cpp | 1 + CGameInfo.h | 52 +++++++++++++++++++++------------------- CGameInterface.cpp | 2 ++ CGameState.h | 20 ++++------------ CGeneralTextHandler.cpp | 1 + CHeroHandler.cpp | 2 ++ CMT.cpp | 2 ++ CMessage.cpp | 1 + CObjectHandler.cpp | 2 ++ CPathfinder.cpp | 2 ++ CPreGame.cpp | Bin 122986 -> 123330 bytes CPreGameTextHandler.cpp | 1 + CScreenHandler.cpp | 2 ++ CSpellHandler.cpp | 1 + CTownHandler.cpp | 1 + SDL_Extensions.cpp | 2 +- int3.h | 4 ++++ mapHandler.cpp | 2 ++ mapHandler.h | 1 + 29 files changed, 104 insertions(+), 45 deletions(-) diff --git a/CAbilityHandler.cpp b/CAbilityHandler.cpp index 17864ea67..cf5d8ee91 100644 --- a/CAbilityHandler.cpp +++ b/CAbilityHandler.cpp @@ -2,6 +2,7 @@ #include "CAbilityHandler.h" #include "CGameInfo.h" #include "CGeneralTextHandler.h" +#include "CLodHandler.h" void CAbilityHandler::loadAbilities() { std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("SSTRAITS.TXT"); diff --git a/CAdvmapInterface.cpp b/CAdvmapInterface.cpp index bb17440f1..0832ddd99 100644 --- a/CAdvmapInterface.cpp +++ b/CAdvmapInterface.cpp @@ -1,5 +1,7 @@ #include "stdafx.h" #include "CAdvmapInterface.h" +#include "CLodHandler.h" +#include "CPreGameTextHandler.h" extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts diff --git a/CAdvmapInterface.h b/CAdvmapInterface.h index b048c6076..1fd1a7d6e 100644 --- a/CAdvmapInterface.h +++ b/CAdvmapInterface.h @@ -9,6 +9,8 @@ #include "SDL_Extensions.h" #include #include "global.h" +#include "CPathfinder.h" +#include "mapHandler.h" class AdventureMapButton : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index b010ff527..f39b09249 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -4,8 +4,10 @@ #include "CGameInfo.h" #include "CObjectHandler.h" #include "CCastleHandler.h" +#include "CDefObjInfoHandler.h" #include "SDL_Extensions.h" #include "boost\filesystem.hpp" +#include "CLodHandler.h" #include #include #include diff --git a/CArtHandler.cpp b/CArtHandler.cpp index 31b3a4e02..06e3d6637 100644 --- a/CArtHandler.cpp +++ b/CArtHandler.cpp @@ -2,6 +2,7 @@ #include "CArtHandler.h" #include "CGameInfo.h" #include "CGeneralTextHandler.h" +#include "CLodHandler.h" void CArtHandler::loadArtifacts() { diff --git a/CBuildingHandler.cpp b/CBuildingHandler.cpp index e2590ee4f..e008cbae5 100644 --- a/CBuildingHandler.cpp +++ b/CBuildingHandler.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "CGameInfo.h" #include "CBuildingHandler.h" +#include "CLodHandler.h" void CBuildingHandler::loadBuildings() { diff --git a/CCallback.cpp b/CCallback.cpp index 640c91207..aad72aeb4 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -1,8 +1,23 @@ #include "stdafx.h" #include "CCallback.h" #include "CPathfinder.h" +#include "CHeroHandler.h" +#include "CGameInfo.h" +#include "CAmbarCendamo.h" +#include "mapHandler.h" bool CCallback::moveHero(int ID, int3 destPoint) { + if(ID<0 || ID>CGI->heroh->heroInstances.size()) + return false; + if(destPoint.x<0 || destPoint.x>CGI->ac->map.width) + return false; + if(destPoint.y<0 || destPoint.y>CGI->ac->map.height) + return false; + if(destPoint.z<0 || destPoint.z>CGI->mh->ttiles[0][0].size()-1) + return false; + CPath * ourPath = CGI->pathf->getPath(CGI->heroh->heroInstances[ID]->pos, destPoint, CGI->heroh->heroInstances[ID]); + if(!ourPath) + return false; return false; -} \ No newline at end of file +} diff --git a/CConsoleHandler.cpp b/CConsoleHandler.cpp index 01518ecea..1430f7802 100644 --- a/CConsoleHandler.cpp +++ b/CConsoleHandler.cpp @@ -5,6 +5,8 @@ #include "SDL_thread.h" #include "CGameInfo.h" #include "global.h" +#include "CGameState.h" +#include "CCallback.h" #include int internalFunc(void * nothingUsed) @@ -19,14 +21,29 @@ int internalFunc(void * nothingUsed) readed.str(pom); std::string cn; //command name readed >> cn; + int3 src, dst; + + int heronum; + int3 dest; + switch (*cn.c_str()) { case 'P': - std::cout<<"Policzyc sciezke."<>src>>dst; LOCPLINT->adventureInt->terrain.currentPath = CGI->pathf->getPath(src,dst,CGI->heroh->heroInstances[0]); break; + case 'm': //number of heroes + std::cout<<"Number of heroes: "<heroh->heroInstances.size()<>heronum; + std::cout<<"Position of hero "<heroh->heroInstances[heronum]->pos<>heronum>>dest; + CGI->state->cb->moveHero(heronum, dest); + break; } //SDL_Delay(100); } diff --git a/CCreatureHandler.cpp b/CCreatureHandler.cpp index eaf9ffee8..f60340a54 100644 --- a/CCreatureHandler.cpp +++ b/CCreatureHandler.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "CGameInfo.h" #include "CCreatureHandler.h" +#include "CLodHandler.h" void CCreatureHandler::loadCreatures() { diff --git a/CCursorHandler.cpp b/CCursorHandler.cpp index 01e18c44d..a3bd2e056 100644 --- a/CCursorHandler.cpp +++ b/CCursorHandler.cpp @@ -4,6 +4,7 @@ #include "SDL_thread.h" #include "CGameInfo.h" #include "SDL_framerate.h" +#include "CLodHandler.h" extern SDL_Surface * screen; @@ -194,7 +195,6 @@ void CCursorHandler::initCursor() xpos = ypos = 0; behindCur = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, rmask, gmask, bmask, amask); xbef = ybef = 0; - std::vector pom = CGI->spriteh->entries.vectorize(); adventure = CGI->spriteh->giveDef("CRADVNTR.DEF"); combat = CGI->spriteh->giveDef("CRCOMBAT.DEF"); deflt = CGI->spriteh->giveDef("CRDEFLT.DEF"); diff --git a/CDefObjInfoHandler.cpp b/CDefObjInfoHandler.cpp index f752c3a72..867d1eaa0 100644 --- a/CDefObjInfoHandler.cpp +++ b/CDefObjInfoHandler.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "CDefObjInfoHandler.h" #include "CGameInfo.h" +#include "CLodHandler.h" #include bool DefObjInfo::operator==(const std::string & por) const diff --git a/CGameInfo.h b/CGameInfo.h index 76950379f..a39481975 100644 --- a/CGameInfo.h +++ b/CGameInfo.h @@ -1,38 +1,40 @@ #ifndef CGAMEINFO_H #define CGAMEINFO_H -#include "CPreGame.h" #include "StartInfo.h" -#include "CSpellHandler.h" -#include "CAbilityHandler.h" -#include "CCreaturehandler.h" -#include "CArtHandler.h" -#include "CHeroHandler.h" -#include "CAmbarCendamo.h" -#include "CBuildingHandler.h" -#include "CObjectHandler.h" -#include "CMusicHandler.h" -#include "CSemiLodHandler.h" -#include "CDefObjInfoHandler.h" -#include "CLodHandler.h" -#include "CTownHandler.h" -#include "CGeneralTextHandler.h" -#include "CGameInterface.h" -#include "CGameState.h" -#include "mapHandler.h" -#include "CConsoleHandler.h" -#include "CPathfinder.h" -#include "CCursorHandler.h" -#include "CScreenHandler.h" #include "SDL.h" #include + + +class CMapHandler; +class CArtHandler; +class CHeroHandler; +class CCreatureHandler; +class CAbilityHandler; +class CSpellHandler; +class CAmbarCendamo; +class CPreGameTextHandler; +class CBuildingHandler; +class CObjectHandler; +class CMusicHandler; +class CSemiLodHandler; +class CDefObjInfoHandler; +class CTownHandler; +class CLodHandler; +class CGeneralTextHandler; +class CConsoleHandler; +class CPathfinder; +class CCursorHandler; +class CScreenHandler; +class CGameState; +class CMapHandler; +class CGameInterface; +class CPreGame; /* CGameInfo class for allowing different functions for modifying game informations */ - -class CMapHandler; class CGameInfo { public: @@ -45,7 +47,7 @@ public: CSpellHandler * spellh; CMapHandler * mh; CAmbarCendamo * ac; - CPreGameTextHandler * preth ; + CPreGameTextHandler * preth; CBuildingHandler * buildh; CObjectHandler * objh; CMusicHandler * mush; diff --git a/CGameInterface.cpp b/CGameInterface.cpp index 291e06da3..0abedc751 100644 --- a/CGameInterface.cpp +++ b/CGameInterface.cpp @@ -4,6 +4,8 @@ #include "CMessage.h" #include "SDL_Extensions.h" #include "SDL_framerate.h" +#include "CScreenHandler.h" +#include "CCursorHandler.h" using namespace CSDL_Ext; CButtonBase::CButtonBase() { diff --git a/CGameState.h b/CGameState.h index b97138644..2b3d46431 100644 --- a/CGameState.h +++ b/CGameState.h @@ -1,28 +1,18 @@ #ifndef CGAMESTATE_H #define CGAMESTATE_H -#include "CSpellHandler.h" -#include "CAbilityHandler.h" -#include "CCreaturehandler.h" -#include "CArtHandler.h" -#include "CHeroHandler.h" -#include "CAmbarCendamo.h" -#include "CBuildingHandler.h" -#include "CObjectHandler.h" -#include "CMusicHandler.h" -#include "CSemiLodHandler.h" -#include "CDefObjInfoHandler.h" -#include "CLodHandler.h" -#include "CTownHandler.h" +class CHeroInstance; +class CTownInstance; class CCallback; + struct PlayerState { public: int color; std::vector > >fogOfWarMap; std::vector resources; - std::vector heroes; - std::vector towns; + std::vector heroes; + std::vector towns; }; class CGameState diff --git a/CGeneralTextHandler.cpp b/CGeneralTextHandler.cpp index f2972fa61..13e0ae02e 100644 --- a/CGeneralTextHandler.cpp +++ b/CGeneralTextHandler.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "CGeneralTextHandler.h" #include "CGameInfo.h" +#include "CLodHandler.h" #include void CGeneralTextHandler::load() diff --git a/CHeroHandler.cpp b/CHeroHandler.cpp index 26906cd28..d097af46b 100644 --- a/CHeroHandler.cpp +++ b/CHeroHandler.cpp @@ -4,6 +4,8 @@ #include #include "CGameInfo.h" #include "CGeneralTextHandler.h" +#include "CLodHandler.h" +#include "CAbilityHandler.h" CHeroHandler::~CHeroHandler() { diff --git a/CMT.cpp b/CMT.cpp index d27c4b12e..88d0a40dd 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -40,6 +40,8 @@ #include "CConsoleHandler.h" #include "CCursorHandler.h" #include "CScreenHandler.h" +#include "CPathfinder.h" +#include "CGameState.h" #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) # include diff --git a/CMessage.cpp b/CMessage.cpp index bb358cebf..91021bddd 100644 --- a/CMessage.cpp +++ b/CMessage.cpp @@ -5,6 +5,7 @@ #include "CDefHandler.h" #include "CGameInfo.h" #include "SDL_Extensions.h" +#include "CLodHandler.h" SDL_Color tytulowy, tlo, zwykly ; SDL_Rect genRect(int hh, int ww, int xx, int yy); diff --git a/CObjectHandler.cpp b/CObjectHandler.cpp index 0bf066245..0af0133e7 100644 --- a/CObjectHandler.cpp +++ b/CObjectHandler.cpp @@ -2,6 +2,8 @@ #include "CObjectHandler.h" #include "CGameInfo.h" #include "CGeneralTextHandler.h" +#include "CLodHandler.h" +#include "CAmbarCendamo.h" void CObjectHandler::loadObjects() { diff --git a/CPathfinder.cpp b/CPathfinder.cpp index fb02e3917..f8c0ba1c9 100644 --- a/CPathfinder.cpp +++ b/CPathfinder.cpp @@ -2,6 +2,8 @@ #include "global.h" #include "CPathfinder.h" #include "CGameInfo.h" +#include "CAmbarCendamo.h" +#include "mapHandler.h" CPath * CPathfinder::getPath(int3 &src, int3 &dest, CHeroInstance * hero) //TODO: test it (seems to be finished, but relies on unwritten functions :() { if(src.z!=dest.z) //first check diff --git a/CPreGame.cpp b/CPreGame.cpp index def7fd07990eb94aa246ebcc85db55e19de5d069..e92c5a280e01e5120b4f9fc01e5b5557078d6e69 100644 GIT binary patch delta 133 zcmaELfc?;6_6@t3B$XJP8Qd9C8S;R*h#`?7ham*Ws$eLY{FhOiA0+F{PzsbOX2@qK zf{O(+Bm>1#LHa;q%s_S1^VqA9@ E0PzGOwEzGB delta 18 acmX?fnEllO_6@t3nuS=l3$ZY6xC;PKHwT^o diff --git a/CPreGameTextHandler.cpp b/CPreGameTextHandler.cpp index 2cae4ae7d..7c447b632 100644 --- a/CPreGameTextHandler.cpp +++ b/CPreGameTextHandler.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "CPreGameTextHandler.h" #include "CGameInfo.h" +#include "CLodHandler.h" std::string CPreGameTextHandler::getTitle(std::string text) { std::string ret; diff --git a/CScreenHandler.cpp b/CScreenHandler.cpp index ac5687165..13f16660a 100644 --- a/CScreenHandler.cpp +++ b/CScreenHandler.cpp @@ -4,7 +4,9 @@ #include "SDL_thread.h" #include "SDL_framerate.h" #include "SDL_Extensions.h" +#include "CCursorHandler.h" #include "CGameInfo.h" +#include "CDefHandler.h" extern SDL_Surface * screen, * screen2; diff --git a/CSpellHandler.cpp b/CSpellHandler.cpp index cede23e2e..fe4d1e1fd 100644 --- a/CSpellHandler.cpp +++ b/CSpellHandler.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "CSpellHandler.h" #include "CGameInfo.h" +#include "CLodHandler.h" void CSpellHandler::loadSpells() { diff --git a/CTownHandler.cpp b/CTownHandler.cpp index 27b05e67a..ff978e2b1 100644 --- a/CTownHandler.cpp +++ b/CTownHandler.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "CTownHandler.h" #include "CGameInfo.h" +#include "CLodHandler.h" #include CTownHandler::CTownHandler() diff --git a/SDL_Extensions.cpp b/SDL_Extensions.cpp index 015ecbb69..dc00fdfc3 100644 --- a/SDL_Extensions.cpp +++ b/SDL_Extensions.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include "CMessage.h" bool isItIn(const SDL_Rect * rect, int x, int y) { diff --git a/int3.h b/int3.h index cf5d03f00..6d6ff2b9a 100644 --- a/int3.h +++ b/int3.h @@ -68,4 +68,8 @@ inline std::istream & operator>>(std::istream & str, int3 & dest) str>>dest.x>>dest.y>>dest.z; return str; } +inline std::ostream & operator<<(std::ostream & str, int3 & sth) +{ + return str< extern SDL_Surface * ekran; diff --git a/mapHandler.h b/mapHandler.h index 9d3b52a23..b4e5fa80e 100644 --- a/mapHandler.h +++ b/mapHandler.h @@ -6,6 +6,7 @@ #include "CGameInfo.h" #include "CDefHandler.h" #include +#include "CObjectHandler.h" const int Woff = 4; //width of map's frame const int Hoff = 4;