1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

* New files for lib: CBattleCallback.cpp and CBattleCallback.h

* Updated MSVC project files
* Filesystem: My version of .SND archive does not have \0 after WAV extension. Fixed (though hardcoded 3-char extension length).
* New bonus types: BLOCK_MAGIC_ABOVE for blocking casting spells above given level and BLOCK_ALL_MAGIC for blocking all magic.
* Heavy rewrite of battle callbacks. Fixed some minor bugs. Code reusage between lib/client/server (removed proxy calls). Better access control and support for various perspectives.
* Fixed #1031
* Fixed Orb of Inhibition and Recanter's Cloak (they were incorrectly implemented). Fixed #97.
* Fleeing hero won't lose artifacts. Spellbook won't be captured. Fixed #980.
* Fixed crash when attacking stack dies before counterattack (ie. because of Fire Shield)
* Server does some basic checks if action requests during battle are valid
* Minor stuff.
This commit is contained in:
Michał W. Urbańczyk
2012-08-26 09:07:48 +00:00
parent 2dd9d943c9
commit d390113c23
39 changed files with 3069 additions and 2386 deletions

View File

@@ -117,7 +117,7 @@ void CClient::waitForMoveAndSend(int color)
try
{
assert(vstd::contains(battleints, color));
BattleAction ba = battleints[color]->activeStack(gs->curB->getStack(gs->curB->activeStack, false));
BattleAction ba = battleints[color]->activeStack(gs->curB->battleGetStackByID(gs->curB->activeStack, false));
MakeAction temp_action(ba);
sendRequest(&temp_action, color);
return;
@@ -381,13 +381,14 @@ void CClient::newGame( CConnection *con, StartInfo *si )
battleints[color] = playerint[color];
playerint[color]->init(cb.get());
callbacks[color] = cb;
battleCallbacks[color] = callbacks[color] = cb;
}
else
{
CBattleCallback * cbc = new CBattleCallback(gs, color, this);
auto cbc = make_shared<CBattleCallback>(gs, color, this);
battleCallbacks[color] = cbc;
battleints[color] = CDynLibHandler::getNewBattleAI("StupidAI");
battleints[color]->init(cbc);
battleints[color]->init(cbc.get());
}
}
@@ -399,7 +400,9 @@ void CClient::newGame( CConnection *con, StartInfo *si )
battleints[254] = playerint[254] = p;
privilagedBattleEventReceivers.push_back(p);
GH.curInt = p;
p->init(new CCallback(gs, -1, this));
auto cb = make_shared<CCallback>(gs, -1, this);
battleCallbacks[-1] = callbacks[-1] = cb;
p->init(cb.get());
battleStarted(gs->curB);
}
else
@@ -554,6 +557,15 @@ void CClient::stopConnection()
void CClient::battleStarted(const BattleInfo * info)
{
BOOST_FOREACH(auto &battleCb, battleCallbacks)
{
if(vstd::contains(info->sides, battleCb.first) || battleCb.first >= GameConstants::PLAYER_LIMIT)
battleCb.second->setBattle(info);
}
// BOOST_FOREACH(ui8 side, info->sides)
// if(battleCallbacks.count(side))
// battleCallbacks[side]->setBattle(info);
CPlayerInterface * att, * def;
if(vstd::contains(playerint, info->sides[0]) && playerint[info->sides[0]]->human)
att = static_cast<CPlayerInterface*>( playerint[info->sides[0]] );
@@ -586,10 +598,19 @@ void CClient::battleStarted(const BattleInfo * info)
}
}
void CClient::battleFinished()
{
BOOST_FOREACH(ui8 side, gs->curB->sides)
if(battleCallbacks.count(side))
battleCallbacks[side]->setBattle(nullptr);
}
void CClient::loadNeutralBattleAI()
{
battleints[255] = CDynLibHandler::getNewBattleAI(settings["server"]["neutralAI"].String());
battleints[255]->init(new CBattleCallback(gs, 255, this));
auto cbc = make_shared<CBattleCallback>(gs, 255, this);
battleCallbacks[255] = cbc;
battleints[255]->init(cbc.get());
}
void CClient::commitPackage( CPackForClient *pack )