1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-03 23:19:22 +02:00

Trading Post handling.

This commit is contained in:
Michał W. Urbańczyk
2010-05-18 07:01:54 +00:00
parent 71b73bad53
commit 1002bd2b4f
22 changed files with 372 additions and 102 deletions

View File

@@ -28,6 +28,7 @@
#include "CPreGame.h"
#include "../lib/VCMI_Lib.h"
#include "../hch/CSpellHandler.h"
#include <boost/foreach.hpp>
#ifdef _MSC_VER
#pragma warning (disable : 4355)
@@ -1521,15 +1522,19 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
//act on key down if marketplace windows is not already opened
if(key.state != SDL_PRESSED || GH.topInt()->type & BLOCK_ADV_HOTKEYS) return;
//check if we have aby marketplace
std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo();
size_t i = 0;
for(; i<towns.size(); i++)
if(vstd::contains(towns[i]->builtBuildings, 14))
//check if we have any marketplace
const CGTownInstance *townWithMarket = NULL;
BOOST_FOREACH(const CGTownInstance *t, LOCPLINT->cb->getTownsInfo())
{
if(vstd::contains(t->builtBuildings, 14))
{
townWithMarket = t;
break;
}
}
if(i != towns.size()) //if any town has marketplace, open window
GH.pushInt(new CMarketplaceWindow);
if(townWithMarket) //if any town has marketplace, open window
GH.pushInt(new CMarketplaceWindow(townWithMarket));
else //if not - complain
LOCPLINT->showInfoDialog("No available marketplace!", std::vector<SComponent*>(), soundBase::sound_todo);
return;