diff --git a/CCallback.cpp b/CCallback.cpp index 01bad1e34..0379519bf 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -925,7 +925,14 @@ void CCallback::calculatePaths( const CGHeroInstance *hero, CPathsInfo &out, int int3 CCallback::getGrailPos( float &outKnownRatio ) { - outKnownRatio = (float)CGObelisk::visited[player] / CGObelisk::obeliskCount; + if (CGObelisk::obeliskCount == 0) + { + outKnownRatio = 0.0f; + } + else + { + outKnownRatio = (float)CGObelisk::visited[player] / CGObelisk::obeliskCount; + } return gs->map->grailPos; } diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index e2496c1f3..daf735d40 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -613,7 +613,7 @@ void SelectionTab::parseCampaigns( std::vector & files ) { for(int i=0; i &cost, int state, int b CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio) :animCount(0) { + CDefHandler * arrows = CDefHandler::giveDef("ADAG.DEF"); + alphaTransform(arrows->ourImages[0].bitmap); + SDL_Surface * back = BitmapHandler::loadBitmap("PUZZLE.BMP", false); graphics->blueToPlayersAdv(back, LOCPLINT->playerID); //make transparency black @@ -4745,13 +4748,28 @@ CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio) resdatabar = new CResDataBar("ZRESBAR.bmp", pos.x+3, pos.y+575, 32, 2, 85, 85); resdatabar->pos.x = pos.x+3; resdatabar->pos.y = pos.y+575; - //printing necessary thinks to background - + //printing necessary things to background + int3 moveInt = int3(8, 9, 0); CGI->mh->terrainRect - (grailPos, LOCPLINT->adventureInt->anim, + (grailPos - moveInt, LOCPLINT->adventureInt->anim, &LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim, background, &genRect(544, 591, 8, 8), 0, 0, true); + //printing X sign + { + int x = 32*moveInt.x + 8, + y = 32*moveInt.y + 8; + if (x<0 || y<0 || x>pos.w || y>pos.h) + { + } + else + { + CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[0].bitmap, NULL, background, &genRect(32, 32, x, y)); + } + } + + delete arrows; + int faction = LOCPLINT->cb->getStartInfo()->playerInfos[LOCPLINT->serialID].castle; std::vector puzzlesToPrint; diff --git a/hch/CCampaignHandler.cpp b/hch/CCampaignHandler.cpp index 08be282dc..f0d1742cd 100644 --- a/hch/CCampaignHandler.cpp +++ b/hch/CCampaignHandler.cpp @@ -50,8 +50,8 @@ std::vector CCampaignHandler::getCampaignHeaders(GetMode mode) { for(int g=0; gentries.size(); ++g) { - std::string rn = bitmaph->entries[g].nameStr; - if( boost::ends_with(bitmaph->entries[g].nameStr, ext) ) + const std::string & nameS = bitmaph->entries[g].nameStr; + if( boost::ends_with(nameS, ext) && nameS != "TOSBLK1.H3C" ) { ret.push_back( getHeader(bitmaph->entries[g].nameStr, true) ); } @@ -66,12 +66,12 @@ std::vector CCampaignHandler::getCampaignHeaders(GetMode mode) CCampaignHeader CCampaignHandler::getHeader( const std::string & name, bool fromLod ) { int realSize; - unsigned char * cmpgn = CLodHandler::getUnpackedFile(name, &realSize); + unsigned char * cmpgn = getFile(name, fromLod, realSize); int it = 0;//iterator for reading CCampaignHeader ret = readHeaderFromMemory(cmpgn, it); ret.filename = name; - ret.loadFromLod = false; + ret.loadFromLod = fromLod; delete [] cmpgn; @@ -83,15 +83,7 @@ CCampaign * CCampaignHandler::getCampaign( const std::string & name, bool fromLo CCampaign * ret = new CCampaign(); int realSize; - unsigned char * cmpgn; - if (fromLod) - { - cmpgn = bitmaph->giveFile(name, &realSize); - } - else - { - cmpgn = CLodHandler::getUnpackedFile(name, &realSize); - } + unsigned char * cmpgn = getFile(name, fromLod, realSize); int it = 0; //iterator for reading ret->header = readHeaderFromMemory(cmpgn, it); @@ -410,6 +402,25 @@ bool CCampaignHandler::startsAt( const unsigned char * buffer, int size, int pos return true; } +unsigned char * CCampaignHandler::getFile( const std::string & name, bool fromLod, int & outSize ) +{ + unsigned char * cmpgn; + if(fromLod) + { + cmpgn = bitmaph->giveFile(name, &outSize); + FILE * tmp = fopen("tmp_cmpgn", "wb"); + fwrite(cmpgn, 1, outSize, tmp); + fclose(tmp); + delete [] cmpgn; + cmpgn = CLodHandler::getUnpackedFile("tmp_cmpgn", &outSize); + } + else + { + cmpgn = CLodHandler::getUnpackedFile(name, &outSize); + } + return cmpgn; +} + bool CCampaign::conquerable( int whichScenario ) const { if (scenarios[whichScenario].conquered) diff --git a/hch/CCampaignHandler.h b/hch/CCampaignHandler.h index 7bad0e439..7732d1598 100644 --- a/hch/CCampaignHandler.h +++ b/hch/CCampaignHandler.h @@ -123,6 +123,7 @@ class DLL_EXPORT CCampaignHandler static CScenarioTravel readScenarioTravelFromMemory( const unsigned char * buffer, int & outIt , int version); static std::vector locateH3mStarts(const unsigned char * buffer, int start, int size); static bool startsAt( const unsigned char * buffer, int size, int pos ); //a simple heuristic that checks if a h3m starts at given pos + static unsigned char * getFile(const std::string & name, bool fromLod, int & outSize); public: enum GetMode {RoE, AB, SoD, WoG, Custom, ALL}; static std::vector getCampaignHeaders(GetMode mode); diff --git a/hch/CLodHandler.cpp b/hch/CLodHandler.cpp index 268d8346a..cff8f9a28 100644 --- a/hch/CLodHandler.cpp +++ b/hch/CLodHandler.cpp @@ -302,6 +302,7 @@ unsigned char * CLodHandler::getUnpackedFile( const std::string & path, int * si int mapsize = 0; gzFile map = gzopen(path.c_str(), "rb"); + assert(map); std::vector mapstr; // Read a map by chunks diff --git a/mapHandler.cpp b/mapHandler.cpp index e413d5de7..60d13bb0f 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -687,15 +687,19 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect else { //blitting Fog of War - if (pos.x >= 0 && - pos.y >= 0 && - pos.x < CGI->mh->map->width && - pos.y < CGI->mh->map->height && - !(*visibilityMap)[pos.x][pos.y][top_tile.z]) + if (!puzzleMode) { - SDL_Surface * hide = getVisBitmap(pos.x, pos.y, *visibilityMap, top_tile.z); - CSDL_Ext::blit8bppAlphaTo24bpp(hide, &rtile, extSurf, &sr); + if (pos.x >= 0 && + pos.y >= 0 && + pos.x < CGI->mh->map->width && + pos.y < CGI->mh->map->height && + !(*visibilityMap)[pos.x][pos.y][top_tile.z]) + { + SDL_Surface * hide = getVisBitmap(pos.x, pos.y, *visibilityMap, top_tile.z); + CSDL_Ext::blit8bppAlphaTo24bpp(hide, &rtile, extSurf, &sr); + } } + //FoW blitted // TODO: these should be activable by the console