1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00
- removed some no longer needed code from map handler
- blocked "back" button on campaign map screen if some of scenarios are
already completed
This commit is contained in:
Ivan Savenko 2014-01-05 13:45:44 +00:00
parent 5e812492e0
commit 1f325bafb3
5 changed files with 14 additions and 29 deletions

View File

@ -3136,6 +3136,8 @@ void CBonusSelection::init()
startB = new CAdventureMapButton("", "", boost::bind(&CBonusSelection::startMap, this), 475, 536, "CBBEGIB.DEF", SDLK_RETURN);
restartB = new CAdventureMapButton("", "", boost::bind(&CBonusSelection::restartMap, this), 475, 536, "CBRESTB.DEF", SDLK_RETURN);
backB = new CAdventureMapButton("", "", boost::bind(&CBonusSelection::goBack, this), 624, 536, "CBCANCB.DEF", SDLK_ESCAPE);
// block back button for in-progress campaigns. May not be H3 behaviour but avoids the crash
backB->block(!ourCampaign->mapsConquered.empty());
//campaign name
if (ourCampaign->camp->header.name.length())

View File

@ -492,7 +492,6 @@ void HeroRecruited::applyCl( CClient *cl )
logNetwork->errorStream() << "Something wrong with hero recruited!";
}
CGI->mh->initHeroDef(h);
CGI->mh->printObject(h);
if(vstd::contains(cl->playerint,h->tempOwner))
@ -506,7 +505,6 @@ void HeroRecruited::applyCl( CClient *cl )
void GiveHero::applyCl( CClient *cl )
{
CGHeroInstance *h = GS(cl)->getHero(id);
CGI->mh->initHeroDef(h);
CGI->mh->printObject(h);
cl->playerint[h->tempOwner]->heroCreated(h);
}

View File

@ -314,11 +314,6 @@ void CMapHandler::initObjectRects()
}
}
void CMapHandler::initHeroDef(const CGHeroInstance * h)
{
graphics->advmapobjGraphics[h->appearance.animationFile] = graphics->flags1[0];
}
void CMapHandler::init()
{
CStopWatch th;
@ -356,14 +351,6 @@ void CMapHandler::init()
offsetX = (mapW - (2*frameW+1)*32)/2;
offsetY = (mapH - (2*frameH+1)*32)/2;
for(auto & elem : map->heroesOnMap)
{
if( !graphics->getDef(elem) )
{
initHeroDef(elem);
}
}
prepareFOWDefs();
roadsRiverTerrainInit(); //road's and river's DefHandlers; and simple values initialization
borderAndTerrainBitmapInit();
@ -894,25 +881,23 @@ bool CMapHandler::printObject(const CGObjectInstance *obj)
bool CMapHandler::hideObject(const CGObjectInstance *obj)
{
CDefEssential * curd = graphics->getDef(obj);
if(!curd) return false;
const SDL_Surface *bitmap = curd->ourImages[0].bitmap;
for(int fx=0; fx<bitmap->w/32; ++fx)
for (size_t i=0; i<map->width; i++)
{
for(int fy=0; fy<bitmap->h/32; ++fy)
for (size_t j=0; j<map->height; j++)
{
if((obj->pos.x + fx - bitmap->w/32+1)>=0 && (obj->pos.x + fx - bitmap->w/32+1)<ttiles.size()-frameW && (obj->pos.y + fy - bitmap->h/32+1)>=0 && (obj->pos.y + fy - bitmap->h/32+1)<ttiles[0].size()-frameH)
for (size_t k=0; k<(map->twoLevel ? 2 : 1); k++)
{
std::vector < std::pair<const CGObjectInstance*,SDL_Rect> > & ctile = ttiles[obj->pos.x + fx - bitmap->w/32+1][obj->pos.y + fy - bitmap->h/32+1][obj->pos.z].objects;
for(size_t dd=0; dd < ctile.size(); ++dd)
for(size_t x=0; x < ttiles[i][j][k].objects.size(); x++)
{
if(ctile[dd].first->id==obj->id)
ctile.erase(ctile.begin() + dd);
if (ttiles[i][j][k].objects[x].first->id == obj->id)
{
ttiles[i][j][k].objects.erase(ttiles[i][j][k].objects.begin() + x);
break;
}
}
}
} // for(int fy=0; fy<bitmap->h/32; ++fy)
} //for(int fx=0; fx<bitmap->w/32; ++fx)
}
}
return true;
}
bool CMapHandler::removeObject(CGObjectInstance *obj)

View File

@ -117,7 +117,6 @@ public:
bool printObject(const CGObjectInstance * obj); //puts appropriate things to ttiles, so obj will be visible on map
bool hideObject(const CGObjectInstance * obj); //removes appropriate things from ttiles, so obj will be no longer visible on map (but still will exist)
bool removeObject(CGObjectInstance * obj); //removes object from each place in VCMI (I hope)
void initHeroDef(const CGHeroInstance * h);
void init();
void calculateBlockedPos();
void initObjectRects();

View File

@ -550,6 +550,7 @@ DLL_LINKAGE void GiveHero::applyGs( CGameState *gs )
//bonus system
h->detachFrom(&gs->globalEffects);
h->attachTo(gs->getPlayer(player));
h->appearance = VLC->dobjinfo->pickCandidates(Obj::HERO, h->type->heroClass->id).front();
gs->map->removeBlockVisTiles(h,true);
h->setOwner(player);