1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Common changes.

for changes see http://vcmi.antypika.aplus.pl/forum/viewtopic.php?p=2576#2576
This commit is contained in:
mateuszb
2009-05-22 19:20:30 +00:00
parent 8e2a6466e2
commit 564c8ae839
7 changed files with 27 additions and 24 deletions

View File

@@ -676,6 +676,11 @@ std::vector<const CGHeroInstance *> CCallback::getAvailableHeroes(const CGTownIn
const TerrainTile * CCallback::getTileInfo( int3 tile ) const const TerrainTile * CCallback::getTileInfo( int3 tile ) const
{ {
if(!gs->map->isInTheMap(tile))
{
tlog1 << tile << "is outside the map! (call to getTileInfo)\n";
return NULL;
}
if(!isVisible(tile, player)) return NULL; if(!isVisible(tile, player)) return NULL;
boost::shared_lock<boost::shared_mutex> lock(*gs->mx); boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
return &gs->map->getTile(tile); return &gs->map->getTile(tile);

View File

@@ -1522,6 +1522,8 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
break; break;
case SDLK_SPACE: //space - try to revisit current object with selected hero case SDLK_SPACE: //space - try to revisit current object with selected hero
{ {
if(!active)
return;
const CGHeroInstance *h = dynamic_cast<const CGHeroInstance*>(selection); const CGHeroInstance *h = dynamic_cast<const CGHeroInstance*>(selection);
if(h && key.state == SDL_PRESSED) if(h && key.state == SDL_PRESSED)
{ {

View File

@@ -27,7 +27,6 @@ class CBuildingHandler;
class CObjectHandler; class CObjectHandler;
class CSoundHandler; class CSoundHandler;
class CMusicHandler; class CMusicHandler;
class CSemiLodHandler;
class CDefObjInfoHandler; class CDefObjInfoHandler;
class CTownHandler; class CTownHandler;
class CLodHandler; class CLodHandler;
@@ -58,11 +57,8 @@ public:
CObjectHandler * objh; CObjectHandler * objh;
CSoundHandler * soundh; CSoundHandler * soundh;
CMusicHandler * musich; CMusicHandler * musich;
CSemiLodHandler * sspriteh;
CDefObjInfoHandler * dobjinfo; CDefObjInfoHandler * dobjinfo;
CTownHandler * townh; CTownHandler * townh;
//CLodHandler * spriteh;
//CLodHandler * bitmaph;
CGeneralTextHandler * generaltexth; CGeneralTextHandler * generaltexth;
CConsoleHandler * consoleh; CConsoleHandler * consoleh;
CCursorHandler * curh; CCursorHandler * curh;

View File

@@ -676,7 +676,7 @@ void CHeroWindow::redrawCurBack()
CSDL_Ext::printAt(expstr.str(), 69, 247, GEOR16, zwykly, curBack); CSDL_Ext::printAt(expstr.str(), 69, 247, GEOR16, zwykly, curBack);
CSDL_Ext::printAt(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 212, 231, GEOR13, tytulowy, curBack); CSDL_Ext::printAt(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 212, 231, GEOR13, tytulowy, curBack);
std::stringstream manastr; std::stringstream manastr;
manastr<<curHero->mana<<'/'<<curHero->getPrimSkillLevel(3)*10; manastr << curHero->mana << '/' << curHero->manaLimit();
CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack); CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
} }
@@ -728,19 +728,19 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
LOCPLINT->cb->swapArtifacts(ourWindow->curHero,destSlot,ourWindow->curHero,srcSlot); LOCPLINT->cb->swapArtifacts(ourWindow->curHero,destSlot,ourWindow->curHero,srcSlot);
const CArtifact * pmh = ourArt; //const CArtifact * pmh = ourArt;
ourArt = ourWindow->activeArtPlace->ourArt; //ourArt = ourWindow->activeArtPlace->ourArt;
ourWindow->activeArtPlace->ourArt = pmh; //ourWindow->activeArtPlace->ourArt = pmh;
//set texts ////set texts
if(pmh) //if(pmh)
ourWindow->activeArtPlace->text = pmh->Description(); // ourWindow->activeArtPlace->text = pmh->Description();
else //else
ourWindow->activeArtPlace->text = std::string(); // ourWindow->activeArtPlace->text = std::string();
if(ourArt) //if(ourArt)
text = ourArt->Description(); // text = ourArt->Description();
else //else
text = std::string(); // text = std::string();
ourWindow->activeArtPlace->clicked = false; ourWindow->activeArtPlace->clicked = false;
ourWindow->activeArtPlace = NULL; ourWindow->activeArtPlace = NULL;

View File

@@ -1595,7 +1595,7 @@ bool CPlayerInterface::moveHero( const CGHeroInstance *h, CPath path )
} else } else
#endif #endif
{ {
newTerrain = cb->getTileInfo(path.nodes[i].coord)->tertype; newTerrain = cb->getTileInfo(CGHeroInstance::convertPosition(path.nodes[i].coord, false))->tertype;
if (newTerrain != currentTerrain) { if (newTerrain != currentTerrain) {
CGI->soundh->stopSound(sh); CGI->soundh->stopSound(sh);

View File

@@ -4,7 +4,7 @@
#include <list> #include <list>
#include <set> #include <set>
const int Woff = 13; //width of map's frame const int Woff = 14; //width of map's frame
const int Hoff = 10; const int Hoff = 10;
/* /*

View File

@@ -1869,16 +1869,16 @@ bool CGameHandler::swapArtifacts( si32 hid1, si32 hid2, ui16 slot1, ui16 slot2 )
const CArtifact *a1 = h1->getArt(slot1), const CArtifact *a1 = h1->getArt(slot1),
*a2=h2->getArt(slot2); *a2=h2->getArt(slot2);
if(a1 && slot2<19 && !vstd::contains(a1->possibleSlots,slot2) //check if
|| a2 && slot1<19 && !vstd::contains(a2->possibleSlots,slot1) // 1) slots are appropriate for that artifacts
// 2) they are not war machine
if((a1 && slot2<19 && !vstd::contains(a1->possibleSlots,slot2) || (a2 && slot1<19 && !vstd::contains(a2->possibleSlots,slot1))) && complain("Cannot swap artifacts!")
|| (slot1>=13 && slot1<=16 || slot2>=13 && slot2<=16) && complain("Cannot move war machine!")
) )
{ {
//artifact doesn't fit dst slot
complain("Cannot swap artifacts!");
return false; return false;
} }
SetHeroArtifacts sha; SetHeroArtifacts sha;
sha.hid = hid1; sha.hid = hid1;
sha.artifacts = h1->artifacts; sha.artifacts = h1->artifacts;