mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
parent
ff1c224a97
commit
c4c592b773
@ -977,7 +977,7 @@ void VCAI::makeTurn()
|
||||
boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());
|
||||
setThreadName("VCAI::makeTurn");
|
||||
|
||||
BNLOG("Player %d starting turn", playerID);
|
||||
BNLOG("Player %d starting turn", static_cast<int>(playerID.getNum()));
|
||||
INDENT;
|
||||
|
||||
switch(cb->getDate(Date::DAY_OF_WEEK))
|
||||
@ -2051,7 +2051,7 @@ HeroPtr VCAI::primaryHero() const
|
||||
|
||||
void VCAI::endTurn()
|
||||
{
|
||||
tlog4 << "Player " << playerID << " ends turn\n";
|
||||
tlog4 << "Player " << static_cast<int>(playerID.getNum()) << " ends turn\n";
|
||||
if(!status.haveTurn())
|
||||
{
|
||||
tlog1 << "Not having turn at the end of turn???\n";
|
||||
@ -2062,7 +2062,7 @@ void VCAI::endTurn()
|
||||
cb->endTurn();
|
||||
} while(status.haveTurn()); //for some reasons, our request may fail -> stop requesting end of turn only after we've received a confirmation that it's over
|
||||
|
||||
tlog4 << "Player " << playerID << " ended turn\n";
|
||||
tlog4 << "Player " << static_cast<int>(playerID.getNum()) << " ended turn\n";
|
||||
}
|
||||
|
||||
bool VCAI::fulfillsGoal (CGoal &goal, CGoal &mainGoal)
|
||||
|
@ -152,6 +152,10 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero):
|
||||
secSkillImages.push_back(new CAnimImage("SECSKILL", 0, 0, r.x, r.y));
|
||||
}
|
||||
|
||||
//dismiss / quest log
|
||||
new CTextBox(CGI->generaltexth->jktexts[8], Rect(370, 430, 65, 35), 0, FONT_SMALL, TOPLEFT, Colors::WHITE);
|
||||
new CTextBox(CGI->generaltexth->jktexts[9], Rect(510, 430, 65, 35), 0, FONT_SMALL, TOPLEFT, Colors::WHITE);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////???????????????
|
||||
|
||||
//primary skills & exp and mana
|
||||
@ -337,10 +341,6 @@ void CHeroWindow::showAll(SDL_Surface * to)
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[2], 123, 99, FONT_SMALL, Colors::YELLOW, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[3], 193, 99, FONT_SMALL, Colors::YELLOW, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[4], 262, 99, FONT_SMALL, Colors::YELLOW, to);
|
||||
|
||||
//dismiss / quest log
|
||||
printAtMiddleWBLoc(CGI->generaltexth->jktexts[8], 388, 455, FONT_SMALL, 50, Colors::WHITE, to);
|
||||
printAtMiddleWBLoc(CGI->generaltexth->jktexts[9], 534, 455, FONT_SMALL, 50, Colors::WHITE, to);
|
||||
|
||||
//printing primary skills' amounts
|
||||
for(int m=0; m<4; ++m)
|
||||
|
@ -201,6 +201,7 @@ void CSoundHandler::initSpellsSounds(const std::vector< ConstTransitivePtr<CSpel
|
||||
// Plays a sound, and return its channel so we can fade it out later
|
||||
int CSoundHandler::playSound(soundBase::soundID soundID, int repeats)
|
||||
{
|
||||
assert(soundID < soundBase::sound_after_last);
|
||||
if (!initialized)
|
||||
return -1;
|
||||
|
||||
|
@ -1029,6 +1029,7 @@ public:
|
||||
invalid=0,
|
||||
sound_todo=1, // temp entry until code is fixed
|
||||
VCMI_SOUND_LIST
|
||||
sound_after_last
|
||||
};
|
||||
#undef VCMI_SOUND_NAME
|
||||
#undef VCMI_SOUND_FILE
|
||||
|
@ -373,7 +373,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
||||
else
|
||||
sensibleAILimit--;
|
||||
playerint[color] = static_cast<CGameInterface*>(CDynLibHandler::getNewAI(AItoGive));
|
||||
tlog1 << "Player " << color << " will be lead by " << AItoGive << std::endl;
|
||||
tlog1 << "Player " << static_cast<int>(color.getNum()) << " will be lead by " << AItoGive << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3657,9 +3657,11 @@ CTavernWindow::CTavernWindow(const CGObjectInstance *TavernObj):
|
||||
|
||||
h1 = new HeroPortrait(selected,0,72,299,h[0]);
|
||||
h2 = new HeroPortrait(selected,1,162,299,h[1]);
|
||||
if(h[0])
|
||||
selected = 0;
|
||||
else
|
||||
|
||||
selected = 0;
|
||||
if (!h[0])
|
||||
selected = 1;
|
||||
if (!h[0] && !h[1])
|
||||
selected = -1;
|
||||
oldSelected = -1;
|
||||
|
||||
@ -3675,23 +3677,23 @@ CTavernWindow::CTavernWindow(const CGObjectInstance *TavernObj):
|
||||
if(LOCPLINT->cb->getResourceAmount(Res::GOLD) < 2500) //not enough gold
|
||||
{
|
||||
recruit->hoverTexts[0] = CGI->generaltexth->tavernInfo[0]; //Cannot afford a Hero
|
||||
recruit->block(2);
|
||||
recruit->block(true);
|
||||
}
|
||||
else if(LOCPLINT->cb->howManyHeroes(false) >= 8)
|
||||
{
|
||||
recruit->hoverTexts[0] = CGI->generaltexth->tavernInfo[1]; //Cannot recruit. You already have %d Heroes.
|
||||
boost::algorithm::replace_first(recruit->hoverTexts[0],"%d",boost::lexical_cast<std::string>(LOCPLINT->cb->howManyHeroes()));
|
||||
recruit->block(2);
|
||||
recruit->block(true);
|
||||
}
|
||||
else if(LOCPLINT->castleInt && LOCPLINT->castleInt->town->visitingHero)
|
||||
{
|
||||
recruit->hoverTexts[0] = CGI->generaltexth->tavernInfo[2]; //Cannot recruit. You already have a Hero in this town.
|
||||
recruit->block(2);
|
||||
recruit->block(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!h[0])
|
||||
recruit->block(1);
|
||||
if(selected == -1)
|
||||
recruit->block(true);
|
||||
}
|
||||
|
||||
CCS->videoh->open("TAVERN.BIK");
|
||||
@ -5394,7 +5396,7 @@ void CUniversityWindow::CItem::clickRight(tribool down, bool previousState)
|
||||
if(down)
|
||||
{
|
||||
CRClickPopup::createAndPush(CGI->generaltexth->skillInfoTexts[ID][0],
|
||||
new CComponent(CComponent::secskill, ID, 0));
|
||||
new CComponent(CComponent::secskill, ID, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,12 +56,10 @@ MacroString::MacroString(const std::string &format)
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!start_pos == std::string::npos);
|
||||
while (start_pos != std::string::npos);
|
||||
|
||||
//no more macros
|
||||
items.push_back(Item(Item::STRING,format.substr(end_pos)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
std::string MacroString::build(const GetValue& getValue) const
|
||||
|
@ -646,7 +646,7 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
|
||||
{
|
||||
BOOST_FOREACH (const JsonNode &exp, input.Vector())
|
||||
{
|
||||
auto bonus = JsonUtils::parseBonus (exp["bonus"]); // FIXME: memory leak? Only copies of bonus is added to creature
|
||||
auto bonus = JsonUtils::parseBonus (exp["bonus"]);
|
||||
bonus->source = Bonus::STACK_EXPERIENCE;
|
||||
bonus->duration = Bonus::PERMANENT;
|
||||
const JsonVector &values = exp["values"].Vector();
|
||||
@ -679,6 +679,7 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
|
||||
++lowerLimit;
|
||||
}
|
||||
}
|
||||
delete bonus;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2293,13 +2293,12 @@ void CGTownInstance::removeCapitols (PlayerColor owner) const
|
||||
|
||||
int CGTownInstance::getBoatType() const
|
||||
{
|
||||
const CCreature *c = VLC->creh->creatures[town->creatures.front().front()];
|
||||
if (c->isGood())
|
||||
return 1;
|
||||
else if (c->isEvil())
|
||||
return 0;
|
||||
else //neutral
|
||||
return 2;
|
||||
switch (VLC->townh->factions[town->typeID].alignment)
|
||||
{
|
||||
case EAlignment::EVIL : return 0;
|
||||
case EAlignment::GOOD : return 1;
|
||||
case EAlignment::NEUTRAL : return 2;
|
||||
}
|
||||
}
|
||||
|
||||
int CGTownInstance::getMarketEfficiency() const
|
||||
@ -4877,7 +4876,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
bool visited = h->hasBonusFrom(Bonus::OBJECT,ID);
|
||||
int messageID=0;
|
||||
int bonusMove = 0, sound = -1;
|
||||
int bonusMove = 0;
|
||||
ui32 descr_id = 0;
|
||||
InfoWindow iw;
|
||||
iw.player = h->tempOwner;
|
||||
@ -4894,14 +4893,14 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
case Obj::BUOY:
|
||||
messageID = 21;
|
||||
sound = soundBase::MORALE;
|
||||
iw.soundID = soundBase::MORALE;
|
||||
gbonus.bonus.type = Bonus::MORALE;
|
||||
gbonus.bonus.val = +1;
|
||||
descr_id = 94;
|
||||
break;
|
||||
case Obj::SWAN_POND:
|
||||
messageID = 29;
|
||||
sound = soundBase::LUCK;
|
||||
iw.soundID = soundBase::LUCK;
|
||||
gbonus.bonus.type = Bonus::LUCK;
|
||||
gbonus.bonus.val = 2;
|
||||
descr_id = 67;
|
||||
@ -4909,14 +4908,14 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
break;
|
||||
case Obj::FAERIE_RING:
|
||||
messageID = 49;
|
||||
sound = soundBase::LUCK;
|
||||
iw.soundID = soundBase::LUCK;
|
||||
gbonus.bonus.type = Bonus::LUCK;
|
||||
gbonus.bonus.val = 1;
|
||||
descr_id = 71;
|
||||
break;
|
||||
case Obj::FOUNTAIN_OF_FORTUNE:
|
||||
messageID = 55;
|
||||
sound = soundBase::LUCK;
|
||||
iw.soundID = soundBase::LUCK;
|
||||
gbonus.bonus.type = Bonus::LUCK;
|
||||
gbonus.bonus.val = rand()%5 - 1;
|
||||
descr_id = 69;
|
||||
@ -4924,7 +4923,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
break;
|
||||
case Obj::IDOL_OF_FORTUNE:
|
||||
messageID = 62;
|
||||
sound = soundBase::experience;
|
||||
iw.soundID = soundBase::experience;
|
||||
|
||||
gbonus.bonus.val = 1;
|
||||
descr_id = 68;
|
||||
@ -4942,13 +4941,13 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
break;
|
||||
case Obj::MERMAID:
|
||||
messageID = 83;
|
||||
sound = soundBase::LUCK;
|
||||
iw.soundID = soundBase::LUCK;
|
||||
gbonus.bonus.type = Bonus::LUCK;
|
||||
gbonus.bonus.val = 1;
|
||||
descr_id = 72;
|
||||
break;
|
||||
case Obj::RALLY_FLAG:
|
||||
sound = soundBase::MORALE;
|
||||
iw.soundID = soundBase::MORALE;
|
||||
messageID = 111;
|
||||
gbonus.bonus.type = Bonus::MORALE;
|
||||
gbonus.bonus.val = 1;
|
||||
@ -4961,6 +4960,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
bonusMove = 400;
|
||||
break;
|
||||
case Obj::OASIS:
|
||||
iw.soundID = soundBase::MORALE;
|
||||
messageID = 95;
|
||||
gbonus.bonus.type = Bonus::MORALE;
|
||||
gbonus.bonus.val = 1;
|
||||
@ -4983,7 +4983,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
}
|
||||
break;
|
||||
case Obj::WATERING_HOLE:
|
||||
sound = soundBase::MORALE;
|
||||
iw.soundID = soundBase::MORALE;
|
||||
messageID = 166;
|
||||
gbonus.bonus.type = Bonus::MORALE;
|
||||
gbonus.bonus.val = 1;
|
||||
@ -4991,7 +4991,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
bonusMove = 400;
|
||||
break;
|
||||
case Obj::FOUNTAIN_OF_YOUTH:
|
||||
sound = soundBase::MORALE;
|
||||
iw.soundID = soundBase::MORALE;
|
||||
messageID = 57;
|
||||
gbonus.bonus.type = Bonus::MORALE;
|
||||
gbonus.bonus.val = 1;
|
||||
@ -4999,7 +4999,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
bonusMove = 400;
|
||||
break;
|
||||
case Obj::STABLES:
|
||||
sound = soundBase::STORE;
|
||||
iw.soundID = soundBase::STORE;
|
||||
bool someUpgradeDone = false;
|
||||
|
||||
for (TSlots::const_iterator i = h->Slots().begin(); i != h->Slots().end(); ++i)
|
||||
@ -5056,7 +5056,6 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
cb->setMovePoints(&smp);
|
||||
}
|
||||
}
|
||||
iw.soundID = sound;
|
||||
iw.text.addTxt(MetaString::ADVOB_TXT,messageID);
|
||||
cb->showInfoDialog(&iw);
|
||||
}
|
||||
@ -5689,7 +5688,7 @@ ui8 CGGarrison::getPassableness() const
|
||||
|
||||
void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
int sound;
|
||||
int sound = soundBase::sound_todo;
|
||||
int txtid;
|
||||
|
||||
switch(ID)
|
||||
|
@ -133,9 +133,9 @@ void JsonNode::setType(JsonType Type)
|
||||
break; case DATA_NULL:
|
||||
break; case DATA_BOOL: data.Bool = false;
|
||||
break; case DATA_FLOAT: data.Float = 0;
|
||||
break; case DATA_STRING: data.String = new std::string;
|
||||
break; case DATA_VECTOR: data.Vector = new JsonVector;
|
||||
break; case DATA_STRUCT: data.Struct = new JsonMap;
|
||||
break; case DATA_STRING: data.String = new std::string();
|
||||
break; case DATA_VECTOR: data.Vector = new JsonVector();
|
||||
break; case DATA_STRUCT: data.Struct = new JsonMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1108,7 @@ struct NewTurn : public CPackForClient //101
|
||||
std::set<Hero> heroes; //updates movement and mana points
|
||||
//std::vector<SetResources> res;//resource list
|
||||
std::map<PlayerColor, TResources> res; //player ID => resource value[res_id]
|
||||
std::vector<SetAvailableCreatures> cres;//creatures to be placed in towns
|
||||
std::map<ObjectInstanceID, SetAvailableCreatures> cres;//creatures to be placed in towns
|
||||
ui32 day;
|
||||
bool resetBuilded;
|
||||
ui8 specialWeek; //weekType
|
||||
|
@ -933,8 +933,8 @@ DLL_LINKAGE void NewTurn::applyGs( CGameState *gs )
|
||||
gs->getPlayer(i->first)->resources = i->second;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(SetAvailableCreatures h, cres) //set available creatures in towns
|
||||
h.applyGs(gs);
|
||||
BOOST_FOREACH(auto creatureSet, cres) //set available creatures in towns
|
||||
creatureSet.second.applyGs(gs);
|
||||
|
||||
gs->globalEffects.popBonuses(Bonus::OneDay); //works for children -> all game objs
|
||||
if(gs->getDate(Date::DAY_OF_WEEK) == 1) //new week
|
||||
|
@ -1300,13 +1300,10 @@ void CGameHandler::newTurn()
|
||||
}
|
||||
}
|
||||
}
|
||||
// townID, creatureID, amount
|
||||
std::map<ObjectInstanceID, std::map<si32, si32> > newCreas;//creatures that needs to be added by town events
|
||||
|
||||
BOOST_FOREACH(CGTownInstance *t, gs->map->towns)
|
||||
{
|
||||
PlayerColor player = t->tempOwner;
|
||||
handleTownEvents(t, n, newCreas);
|
||||
handleTownEvents(t, n);
|
||||
if(newWeek) //first day of week
|
||||
{
|
||||
if(t->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
|
||||
@ -1316,9 +1313,13 @@ void CGameHandler::newTurn()
|
||||
if (t->hasBuilt(BuildingID::TREASURY, ETownType::RAMPART) && player < PlayerColor::PLAYER_LIMIT)
|
||||
n.res[player][Res::GOLD] += hadGold[player]/10; //give 10% of starting gold
|
||||
|
||||
SetAvailableCreatures sac;
|
||||
sac.tid = t->id;
|
||||
sac.creatures = t->creatures;
|
||||
if (!vstd::contains(n.cres, t->id))
|
||||
{
|
||||
n.cres[t->id].tid = t->id;
|
||||
n.cres[t->id].creatures = t->creatures;
|
||||
}
|
||||
auto & sac = n.cres[t->id];
|
||||
|
||||
for (int k=0; k < GameConstants::CREATURES_PER_TOWN; k++) //creature growths
|
||||
{
|
||||
if(t->creatureDwellingLevel(k) >= 0)//there is dwelling (k-level)
|
||||
@ -1349,12 +1350,6 @@ void CGameHandler::newTurn()
|
||||
}
|
||||
}
|
||||
}
|
||||
//add creatures from town events
|
||||
if (vstd::contains(newCreas, t->id))
|
||||
for(auto i=newCreas[t->id].begin() ; i!=newCreas[t->id].end(); i++)
|
||||
sac.creatures[i->first].first += i->second;
|
||||
|
||||
n.cres.push_back(sac);
|
||||
}
|
||||
if(!firstTurn && player < PlayerColor::PLAYER_LIMIT)//not the first day and town not neutral
|
||||
{
|
||||
@ -4765,7 +4760,7 @@ void CGameHandler::handleTimeEvents()
|
||||
sendAndApply(&ume);
|
||||
}
|
||||
|
||||
void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n, std::map<ObjectInstanceID, std::map<si32, si32> > &newCreas)
|
||||
void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
||||
{
|
||||
town->events.sort(evntCmp);
|
||||
while(town->events.size() && town->events.front().firstOccurence == gs->day)
|
||||
@ -4807,11 +4802,18 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n, std::map<
|
||||
}
|
||||
}
|
||||
|
||||
if (!ev.creatures.empty() && !vstd::contains(n.cres, town->id))
|
||||
{
|
||||
n.cres[town->id].tid = town->id;
|
||||
n.cres[town->id].creatures = town->creatures;
|
||||
}
|
||||
auto & sac = n.cres[town->id];
|
||||
|
||||
for(si32 i=0;i<ev.creatures.size();i++) //creature growths
|
||||
{
|
||||
if(town->creatureDwellingLevel(i) >= 0 && ev.creatures[i])//there is dwelling
|
||||
{
|
||||
newCreas[town->id][i] += ev.creatures[i];
|
||||
sac.creatures[i].first += ev.creatures[i];
|
||||
iw.components.push_back(Component(Component::CREATURE,
|
||||
town->creatures[i].second.back(), ev.creatures[i], 0));
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public:
|
||||
void save(const std::string &fname);
|
||||
void close();
|
||||
void handleTimeEvents();
|
||||
void handleTownEvents(CGTownInstance *town, NewTurn &n, std::map<ObjectInstanceID, std::map<si32, si32> > &newCreas);
|
||||
void handleTownEvents(CGTownInstance *town, NewTurn &n);
|
||||
bool complain(const std::string &problem); //sends message to all clients, prints on the logs and return true
|
||||
void objectVisited( const CGObjectInstance * obj, const CGHeroInstance * h );
|
||||
void engageIntoBattle( PlayerColor player );
|
||||
|
Loading…
Reference in New Issue
Block a user