Browse Source

* partially written hero moving
* improvements in include system

mateuszb 18 years ago
parent
commit
2d7dbbefc3

+ 1 - 0
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");

+ 2 - 0
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
 

+ 2 - 0
CAdvmapInterface.h

@@ -9,6 +9,8 @@
 #include "SDL_Extensions.h"
 #include <boost/logic/tribool.hpp>
 #include "global.h"
+#include "CPathfinder.h"
+#include "mapHandler.h"
 
 class AdventureMapButton 
 	: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase

+ 2 - 0
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 <set>
 #include <iomanip>
 #include <sstream>

+ 1 - 0
CArtHandler.cpp

@@ -2,6 +2,7 @@
 #include "CArtHandler.h"
 #include "CGameInfo.h"
 #include "CGeneralTextHandler.h"
+#include "CLodHandler.h"
 
 void CArtHandler::loadArtifacts()
 {

+ 1 - 0
CBuildingHandler.cpp

@@ -1,6 +1,7 @@
 #include "stdafx.h"
 #include "CGameInfo.h"
 #include "CBuildingHandler.h"
+#include "CLodHandler.h"
 
 void CBuildingHandler::loadBuildings()
 {

+ 16 - 1
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;
-}
+}

+ 19 - 2
CConsoleHandler.cpp

@@ -5,6 +5,8 @@
 #include "SDL_thread.h"
 #include "CGameInfo.h"
 #include "global.h"
+#include "CGameState.h"
+#include "CCallback.h"
 #include <sstream>
 
 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."<<std::endl;
-			int3 src, dst;
+			std::cout<<"Policzyc sciezke."<<std::endl;		
 			readed>>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: "<<CGI->heroh->heroInstances.size()<<std::endl;
+			break;
+		case 'H': //position of hero
+			readed>>heronum;
+			std::cout<<"Position of hero "<<heronum<<": "<<CGI->heroh->heroInstances[heronum]->pos<<std::endl;
+			break;
+		case 'M': //move hero
+			readed>>heronum>>dest;
+			CGI->state->cb->moveHero(heronum, dest);
+			break;
 		}
 		//SDL_Delay(100);
 	}

+ 1 - 0
CCreatureHandler.cpp

@@ -1,6 +1,7 @@
 #include "stdafx.h"
 #include "CGameInfo.h"
 #include "CCreatureHandler.h"
+#include "CLodHandler.h"
 
 void CCreatureHandler::loadCreatures()
 {

+ 1 - 1
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<Entry> pom = CGI->spriteh->entries.vectorize();
 	adventure = CGI->spriteh->giveDef("CRADVNTR.DEF");
 	combat = CGI->spriteh->giveDef("CRCOMBAT.DEF");
 	deflt = CGI->spriteh->giveDef("CRDEFLT.DEF");

+ 1 - 0
CDefObjInfoHandler.cpp

@@ -1,6 +1,7 @@
 #include "stdafx.h"
 #include "CDefObjInfoHandler.h"
 #include "CGameInfo.h"
+#include "CLodHandler.h"
 #include <sstream>
 
 bool DefObjInfo::operator==(const std::string & por) const

+ 27 - 25
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 <vector>
+
+
+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;

+ 2 - 0
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()
 {

+ 5 - 15
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<std::vector<std::vector<bool> > >fogOfWarMap;
 	std::vector<int> resources;
-	std::vector<CHeroInstance> heroes;
-	std::vector<CTownInstance> towns;
+	std::vector<CHeroInstance *> heroes;
+	std::vector<CTownInstance *> towns;
 };
 
 class CGameState

+ 1 - 0
CGeneralTextHandler.cpp

@@ -1,6 +1,7 @@
 #include "stdafx.h"
 #include "CGeneralTextHandler.h"
 #include "CGameInfo.h"
+#include "CLodHandler.h"
 #include <fstream>
 
 void CGeneralTextHandler::load()

+ 2 - 0
CHeroHandler.cpp

@@ -4,6 +4,8 @@
 #include <sstream>
 #include "CGameInfo.h"
 #include "CGeneralTextHandler.h"
+#include "CLodHandler.h"
+#include "CAbilityHandler.h"
 
 CHeroHandler::~CHeroHandler()
 {

+ 2 - 0
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 <fcntl.h>

+ 1 - 0
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);

+ 2 - 0
CObjectHandler.cpp

@@ -2,6 +2,8 @@
 #include "CObjectHandler.h"
 #include "CGameInfo.h"
 #include "CGeneralTextHandler.h"
+#include "CLodHandler.h"
+#include "CAmbarCendamo.h"
 
 void CObjectHandler::loadObjects()
 {

+ 2 - 0
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

BIN
CPreGame.cpp


+ 1 - 0
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;

+ 2 - 0
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;
 

+ 1 - 0
CSpellHandler.cpp

@@ -1,6 +1,7 @@
 #include "stdafx.h"
 #include "CSpellHandler.h"
 #include "CGameInfo.h"
+#include "CLodHandler.h"
 
 void CSpellHandler::loadSpells()
 {

+ 1 - 0
CTownHandler.cpp

@@ -1,6 +1,7 @@
 #include "stdafx.h"
 #include "CTownHandler.h"
 #include "CGameInfo.h"
+#include "CLodHandler.h"
 #include <sstream>
 
 CTownHandler::CTownHandler()

+ 1 - 1
SDL_Extensions.cpp

@@ -5,7 +5,7 @@
 #include <iostream>
 #include <utility>
 #include <algorithm>
-
+#include "CMessage.h"
 
 bool isItIn(const SDL_Rect * rect, int x, int y)
 {

+ 4 - 0
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<<sth.x<<' '<<sth.y<<' '<<sth.z;
+}
 #endif //INT3_H

+ 2 - 0
mapHandler.cpp

@@ -5,6 +5,8 @@
 #include "SDL_Extensions.h"
 #include "CGameInfo.h"
 #include "stdlib.h"
+#include "CLodHandler.h"
+#include "CDefObjInfoHandler.h"
 #include <algorithm>
 
 extern SDL_Surface * ekran;

+ 1 - 0
mapHandler.h

@@ -6,6 +6,7 @@
 #include "CGameInfo.h"
 #include "CDefHandler.h"
 #include <boost/logic/tribool.hpp>
+#include "CObjectHandler.h"
 const int Woff = 4; //width of map's frame
 const int Hoff = 4;