diff --git a/CAdvmapInterface.cpp b/CAdvmapInterface.cpp index fe7baacf2..bb17440f1 100644 --- a/CAdvmapInterface.cpp +++ b/CAdvmapInterface.cpp @@ -268,6 +268,10 @@ void CMinimap::clickRight (tribool down) {} void CMinimap::clickLeft (tribool down) { + if (down && (!pressedL)) + MotionInterested::activate(); + else if (!down) + MotionInterested::deactivate(); ClickableL::clickLeft(down); if (!((bool)down)) return; @@ -300,14 +304,25 @@ void CMinimap::hover (bool on) else if (LOCPLINT->adventureInt->statusbar.current==statusbarTxt) LOCPLINT->adventureInt->statusbar.clear(); } +void CMinimap::mouseMoved (SDL_MouseMotionEvent & sEvent) +{ + if (pressedL) + { + clickLeft(true); + } +} void CMinimap::activate() { ClickableL::activate(); ClickableR::activate(); Hoverable::activate(); + if (pressedL) + MotionInterested::activate(); } void CMinimap::deactivate() { + if (pressedL) + MotionInterested::deactivate(); ClickableL::deactivate(); ClickableR::deactivate(); Hoverable::deactivate(); diff --git a/CAdvmapInterface.h b/CAdvmapInterface.h index eb943cbcd..b048c6076 100644 --- a/CAdvmapInterface.h +++ b/CAdvmapInterface.h @@ -99,7 +99,7 @@ public: void show(); //shows statusbar (with current text) }; class CMinimap - : public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject + : public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject { public: CDefHandler * radar; //radar.def; TODO: radars for maps with custom dimensions @@ -117,6 +117,7 @@ public: void clickRight (tribool down); void clickLeft (tribool down); void hover (bool on); + void mouseMoved (SDL_MouseMotionEvent & sEvent); void activate(); // makes button active void deactivate(); // makes button inactive (but don't deletes) }; diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index 98dd7c3cc..b010ff527 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -132,10 +132,9 @@ void CAmbarCendamo::deh3m() } - - i++; //unknown - - if(bufor[i++]!=0xff) + map.players[pom].p8= bufor[i++]; + map.players[pom].p9= bufor[i++]; + if(map.players[pom].p9!=0xff) { map.players[pom].mainHeroPortrait = bufor[i++]; int nameLength = bufor[i++]; @@ -144,7 +143,6 @@ void CAmbarCendamo::deh3m() map.players[pom].mainHeroName+=bufor[i++]; } - //i++; //unknown byte if(map.version != Eformat::RoE) { i++; ////unknown byte diff --git a/CCallback.cpp b/CCallback.cpp new file mode 100644 index 000000000..9ebb08fab --- /dev/null +++ b/CCallback.cpp @@ -0,0 +1,7 @@ +#include "stdafx.h" +#include "CCallback.h" + +bool CCallback::moveHero(int ID, int3 destPoint) +{ + return false; +} \ No newline at end of file diff --git a/CCallback.h b/CCallback.h new file mode 100644 index 000000000..21cb58a6f --- /dev/null +++ b/CCallback.h @@ -0,0 +1,12 @@ +#ifndef CCALLBACK_H +#define CCALLBACK_H +class CGameState; +class CCallback +{ +protected: + CGameState * gs; +public: + bool moveHero(int ID, int3 destPoint); +}; + +#endif //CCALLBACK_H \ No newline at end of file diff --git a/CGameInterface.cpp b/CGameInterface.cpp index f3fcddaba..adc903755 100644 --- a/CGameInterface.cpp +++ b/CGameInterface.cpp @@ -81,6 +81,15 @@ void KeyInterested::deactivate() LOCPLINT-> keyinterested.erase(std::find(LOCPLINT->keyinterested.begin(),LOCPLINT->keyinterested.end(),this)); } +void MotionInterested::activate() +{ + LOCPLINT->motioninterested.push_back(this); +} +void MotionInterested::deactivate() +{ + LOCPLINT-> + motioninterested.erase(std::find(LOCPLINT->motioninterested.begin(),LOCPLINT->motioninterested.end(),this)); +} CPlayerInterface::CPlayerInterface(int Player, int serial) { playerID=Player; @@ -111,7 +120,7 @@ void CPlayerInterface::yourTurn() CGI->screenh->updateScreen(); LOCPLINT->adventureInt->updateScreen = false; - if(SDL_PollEvent(&sEvent)) //wait for event... + while (SDL_PollEvent(&sEvent)) //wait for event... { handleEvent(&sEvent); } @@ -259,6 +268,13 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent) hoverable[i]->hover(false); } } + for(int i=0; ipos,sEvent->motion.x,sEvent->motion.y)) + { + motioninterested[i]->mouseMoved(sEvent->motion); + } + } if(sEvent->motion.x<15) { LOCPLINT->adventureInt->scrollingLeft = true; diff --git a/CGameInterface.h b/CGameInterface.h index 7ae7cf9fe..f0b2943a5 100644 --- a/CGameInterface.h +++ b/CGameInterface.h @@ -64,6 +64,13 @@ public: virtual void activate()=0; virtual void deactivate()=0; }; +class MotionInterested: public virtual CIntObject +{ +public: + virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0; + virtual void activate()=0; + virtual void deactivate()=0; +}; class CGameInterface { public: @@ -88,6 +95,7 @@ public: std::vector rclickable; std::vector hoverable; std::vector keyinterested; + std::vector motioninterested; void yourTurn(); void handleEvent(SDL_Event * sEvent); diff --git a/CGameState.h b/CGameState.h index de24ba28a..b97138644 100644 --- a/CGameState.h +++ b/CGameState.h @@ -14,7 +14,7 @@ #include "CDefObjInfoHandler.h" #include "CLodHandler.h" #include "CTownHandler.h" - +class CCallback; struct PlayerState { public: @@ -27,9 +27,12 @@ public: class CGameState { -public: int currentPlayer; std::map players; //color <-> playerstate +public: + friend CCallback; + friend int _tmain(int argc, _TCHAR* argv[]); + CCallback * cb; //for communication between PlayerInterface/AI and GameState }; #endif //CGAMESTATE_H \ No newline at end of file diff --git a/h3m.txt b/h3m.txt index b0b55f354..33ea5f961 100644 Binary files a/h3m.txt and b/h3m.txt differ diff --git a/map.cpp b/map.cpp index d87a72ad2..36ba48e75 100644 --- a/map.cpp +++ b/map.cpp @@ -89,10 +89,9 @@ CMapHeader::CMapHeader(unsigned char *map) this->players[pom].posOfMainTown.y = map[i++]; this->players[pom].posOfMainTown.z = map[i++]; } - - i++; //unknown byte - int customPortrait = map[i++]; - if (customPortrait != 255) + players[pom].p8= map[i++]; + players[pom].p9= map[i++]; + if(players[pom].p9!=0xff) { players[pom].mainHeroPortrait = map[i++]; int nameLength = map[i++]; diff --git a/map.h b/map.h index 3264b3df3..9e4d0ff7a 100644 --- a/map.h +++ b/map.h @@ -75,6 +75,7 @@ struct SheroName //name of starting hero }; struct PlayerInfo { + int p8, p9; bool canHumanPlay; bool canComputerPlay; unsigned int AITactic; //(00 - random, 01 - warrior, 02 - builder, 03 - explorer)