From e32eaac8af6ed6b9c271d237c72b43aef3363607 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Tue, 9 Oct 2007 15:15:35 +0000 Subject: [PATCH] * resolving #18 * small bugfix --- CCallback.cpp | 2 +- CGameInterface.cpp | 21 ++++++++++++++++++++- CGameInterface.h | 1 + mapHandler.cpp | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CCallback.cpp b/CCallback.cpp index e4f79e2f4..bd9a4a90b 100644 --- a/CCallback.cpp +++ b/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::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); } diff --git a/CGameInterface.cpp b/CGameInterface.cpp index 4e94e5958..6888f69ae 100644 --- a/CGameInterface.cpp +++ b/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 \ No newline at end of file +} //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; +} \ No newline at end of file diff --git a/CGameInterface.h b/CGameInterface.h index c65c7995c..7a3c0dbdc 100644 --- a/CGameInterface.h +++ b/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); }; diff --git a/mapHandler.cpp b/mapHandler.cpp index 69133a2de..46d4f7c02 100644 --- a/mapHandler.cpp +++ b/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;