1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Removed object recycling that was causing #796. Fixed text nr typo.

Corrected json include in client/Client.cpp.
This commit is contained in:
Michał W. Urbańczyk 2011-09-01 01:40:46 +00:00
parent d49058049e
commit 20a53b04fd
5 changed files with 31 additions and 18 deletions

View File

@ -850,7 +850,7 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba)
if (ba->deathBlow())
{
const CStack *stack = cb->battleGetStackByID(ba->stackAttacking);
std::string hlp = CGI->generaltexth->allTexts[(stack->count != 1) ? 336 : 335];
std::string hlp = CGI->generaltexth->allTexts[(stack->count != 1) ? 366 : 365];
boost::algorithm::replace_first(hlp,"%s", (stack->count != 1) ? stack->getCreature()->namePl.c_str() : stack->getCreature()->nameSing.c_str());
battleInt->console->addText(hlp);
for (std::vector<BattleStackAttacked>::const_iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++)

View File

@ -20,7 +20,7 @@
#include "../lib/NetPacks.h"
#include "../lib/VCMI_Lib.h"
#include "../lib/map.h"
#include "../lib/JsonNode.cpp"
#include "../lib/JsonNode.h"
#include "mapHandler.h"
#include "CConfigHandler.h"
#include "Client.h"

View File

@ -2562,6 +2562,14 @@ bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defen
}
bool CStack::ableToRetaliate() const
{
return alive()
&& (counterAttacks > 0 || hasBonusOfType(Bonus::UNLIMITED_RETALIATIONS))
&& !hasBonusOfType(Bonus::SIEGE_WEAPON)
&& !hasBonusOfType(Bonus::HYPNOTIZED);
}
bool CMP_stack::operator()( const CStack* a, const CStack* b )
{
switch(phase)

View File

@ -161,6 +161,7 @@ public:
const Bonus * getEffect(ui16 id, int turn = 0) const; //effect id (SP)
ui8 howManyEffectsSet(ui16 id) const; //returns amount of effects with given id set for this stack
bool willMove(int turn = 0) const; //if stack has remaining move this turn
bool ableToRetaliate() const; //if stack can retaliate after attacked
bool moved(int turn = 0) const; //if stack was already moved this turn
bool canMove(int turn = 0) const; //if stack can move
ui32 Speed(int turn = 0) const; //get speed of creature with all modificators

View File

@ -3055,19 +3055,19 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
}
//attack
BattleAttack bat;
prepareAttack(bat, curStack, stackAtEnd, distance, ba.additionalInfo);
handleAttackBeforeCasting(bat); //only before first attack
sendAndApply(&bat);
handleAfterAttackCasting(bat);
{
BattleAttack bat;
prepareAttack(bat, curStack, stackAtEnd, distance, ba.additionalInfo);
handleAttackBeforeCasting(bat); //only before first attack
sendAndApply(&bat);
handleAfterAttackCasting(bat);
}
//counterattack
if(!curStack->hasBonusOfType(Bonus::BLOCKS_RETALIATION)
&& stackAtEnd->alive()
&& ( stackAtEnd->counterAttacks > 0 || stackAtEnd->hasBonusOfType(Bonus::UNLIMITED_RETALIATIONS) )
&& !stackAtEnd->hasBonusOfType(Bonus::SIEGE_WEAPON)
&& !stackAtEnd->hasBonusOfType(Bonus::HYPNOTIZED))
&& stackAtEnd->ableToRetaliate())
{
BattleAttack bat;
prepareAttack(bat, stackAtEnd, curStack, 0, curStack->position);
bat.flags |= BattleAttack::COUNTER;
sendAndApply(&bat);
@ -3080,7 +3080,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
&& curStack->alive()
&& stackAtEnd->alive() )
{
bat.flags = 0;
BattleAttack bat;
prepareAttack(bat, curStack, stackAtEnd, 0, ba.additionalInfo);
sendAndApply(&bat);
handleAfterAttackCasting(bat);
@ -3105,12 +3105,14 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
StartAction start_action(ba);
sendAndApply(&start_action); //start shooting
BattleAttack bat;
bat.flags |= BattleAttack::SHOT;
prepareAttack(bat, curStack, destStack, 0, ba.destinationTile);
handleAttackBeforeCasting(bat);
sendAndApply(&bat);
handleAfterAttackCasting(bat);
{
BattleAttack bat;
bat.flags |= BattleAttack::SHOT;
prepareAttack(bat, curStack, destStack, 0, ba.destinationTile);
handleAttackBeforeCasting(bat);
sendAndApply(&bat);
handleAfterAttackCasting(bat);
}
//ballista & artillery handling
if(destStack->alive() && curStack->getCreature()->idNumber == 146)
@ -3127,6 +3129,8 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
&& curStack->shots
)
{
BattleAttack bat;
bat.flags |= BattleAttack::SHOT;
prepareAttack(bat, curStack, destStack, 0, ba.destinationTile);
sendAndApply(&bat);
handleAfterAttackCasting(bat);