Browse Source

* resolving #18
* small bugfix

mateuszb 18 years ago
parent
commit
e32eaac8af
4 changed files with 23 additions and 3 deletions
  1. 1 1
      CCallback.cpp
  2. 20 1
      CGameInterface.cpp
  3. 1 0
      CGameInterface.h
  4. 1 1
      mapHandler.cpp

+ 1 - 1
CCallback.cpp

@@ -107,7 +107,7 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
 			int nn=0; //number of interfece of currently browsed player
 			for(std::map<int, PlayerState>::iterator j=CGI->state->players.begin(); j!=CGI->state->players.end(); ++j)//CGI->state->players.size(); ++j) //for testing
 			{
-				if(j->second.fogOfWarMap[stpos.x][stpos.y][stpos.z] || j->second.fogOfWarMap[endpos.x][endpos.y][endpos.z])
+				if(j->second.fogOfWarMap[stpos.x-1][stpos.y][stpos.z] || j->second.fogOfWarMap[endpos.x-1][endpos.y][endpos.z])
 				{ //player should be notified
 					CGI->playerint[nn]->heroMoved(curd);
 				}

+ 20 - 1
CGameInterface.cpp

@@ -217,6 +217,12 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		adventureInt->terrain.currentPath->nodes.erase(adventureInt->terrain.currentPath->nodes.end()-1);
 	}
 
+	int3 buff = details.ho->pos;
+	buff.x-=11;
+	buff.y-=9;
+	buff = repairScreenPos(buff);
+	LOCPLINT->adventureInt->position = buff; //actualizing screen pos
+
 	if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl
 	{
 		ho->moveDir = 1;
@@ -953,4 +959,17 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
 	}
 	current = NULL;
 
-} //event end
+} //event end
+
+int3 CPlayerInterface::repairScreenPos(int3 pos)
+{
+	if(pos.x<=-Woff)
+		pos.x = -Woff+1;
+	if(pos.y<=-Hoff)
+		pos.y = -Hoff+1;
+	if(pos.x>CGI->mh->reader->map.width - this->adventureInt->terrain.tilesw + Woff)
+		pos.x = CGI->mh->reader->map.width - this->adventureInt->terrain.tilesw + Woff;
+	if(pos.y>CGI->mh->reader->map.height - this->adventureInt->terrain.tilesh + Hoff)
+		pos.y = CGI->mh->reader->map.height - this->adventureInt->terrain.tilesh + Hoff;
+	return pos;
+}

+ 1 - 0
CGameInterface.h

@@ -124,6 +124,7 @@ public:
 
 	void handleEvent(SDL_Event * sEvent);
 	void init(CCallback * CB);
+	int3 repairScreenPos(int3 pos);
 
 	CPlayerInterface(int Player, int serial);
 };

+ 1 - 1
mapHandler.cpp

@@ -517,7 +517,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 								}
 							}
 							SDL_BlitSurface(tb,&pp,su,&sr);
-							if(ttiles[x+bx][y+by][level].objects[h].first->flagPrinted)
+							if(!ttiles[x+bx][y+by][level].objects[h].first->flagPrinted)
 							{
 								SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, NULL, su, &sr);
 								ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;