1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #2384 from IvanSavenko/bugfixing_beta

Bugfixing iteration
This commit is contained in:
Ivan Savenko 2023-07-24 00:49:34 +03:00 committed by GitHub
commit a280cc8845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 69 additions and 57 deletions

View File

@ -251,7 +251,7 @@ BattleAction CBattleAI::selectStackAction(const CStack * stack)
void CBattleAI::yourTacticPhase(int distance)
{
cb->battleMakeUnitAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
}
void CBattleAI::activeStack( const CStack * stack )

View File

@ -41,7 +41,7 @@ void CEmptyAI::activeStack(const CStack * stack)
void CEmptyAI::yourTacticPhase(int distance)
{
cb->battleMakeUnitAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
}
void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)

View File

@ -90,7 +90,7 @@ static bool willSecondHexBlockMoreEnemyShooters(const BattleHex &h1, const Battl
void CStupidAI::yourTacticPhase(int distance)
{
cb->battleMakeUnitAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
}
void CStupidAI::activeStack( const CStack * stack )

View File

@ -1907,8 +1907,9 @@ bool CPlayerInterface::capturedAllEvents()
}
bool needToLockAdventureMap = adventureInt && adventureInt->isActive() && CGI->mh->hasOngoingAnimations();
bool quickCombatOngoing = isAutoFightOn && !battleInt;
if (ignoreEvents || needToLockAdventureMap || isAutoFightOn)
if (ignoreEvents || needToLockAdventureMap || quickCombatOngoing )
{
GH.input().ignoreEventsUntilInput();
return true;

View File

@ -26,6 +26,7 @@
#include "../lib/gameState/CGameState.h"
#include "../lib/CThreadHelper.h"
#include "../lib/VCMIDirs.h"
#include "../lib/UnlockGuard.h"
#include "../lib/battle/BattleInfo.h"
#include "../lib/serializer/BinaryDeserializer.h"
#include "../lib/mapping/CMapService.h"
@ -624,6 +625,14 @@ void CClient::battleStarted(const BattleInfo * info)
CPlayerInterface::battleInt = std::make_shared<BattleInterface>(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, att, def, spectratorInt);
}
}
if(info->tacticDistance)
{
auto tacticianColor = info->sides[info->tacticsSide].color;
if (vstd::contains(battleints, tacticianColor))
battleints[tacticianColor]->yourTacticPhase(info->tacticDistance);
}
}
void CClient::battleFinished()
@ -645,6 +654,9 @@ void CClient::startPlayerBattleAction(PlayerColor color)
if(vstd::contains(battleints, color))
{
// we want to avoid locking gamestate and causing UI to freeze while AI is making turn
auto unlock = vstd::makeUnlockGuardIf(*CPlayerInterface::pim, !battleints[color]->human);
assert(vstd::contains(battleints, color));
battleints[color]->activeStack(gs->curB->battleGetStackByID(gs->curB->activeStack, false));
}

View File

@ -330,8 +330,6 @@ bool BattleSiegeController::isAttackableByCatapult(BattleHex hex) const
void BattleSiegeController::stackIsCatapulting(const CatapultAttack & ca)
{
owner.checkForAnimations();
if (ca.attacker != -1)
{
const CStack *stack = owner.curInt->cb->battleGetStackByID(ca.attacker);

View File

@ -154,11 +154,6 @@ void BattleStacksController::collectRenderableObjects(BattleRenderer & renderer)
void BattleStacksController::stackReset(const CStack * stack)
{
owner.checkForAnimations();
//reset orientation?
//stackFacingRight[stack->unitId()] = stack->unitSide() == BattleSide::ATTACKER;
auto iter = stackAnimation.find(stack->unitId());
if(iter == stackAnimation.end())
@ -240,6 +235,9 @@ void BattleStacksController::setActiveStack(const CStack *stack)
stackAnimation[activeStack->unitId()]->setBorderColor(AnimationControls::getGoldBorder());
owner.windowObject->blockUI(activeStack == nullptr);
if (activeStack)
stackAmountBoxHidden.clear();
}
bool BattleStacksController::stackNeedsAmountBox(const CStack * stack) const

View File

@ -81,7 +81,10 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin
{
Point distance = convertTouchToMouse(tfinger) - lastTapPosition;
if ( std::abs(distance.x) > params.panningSensitivityThreshold || std::abs(distance.y) > params.panningSensitivityThreshold)
{
state = TouchState::TAP_DOWN_PANNING;
GH.events().dispatchGesturePanningStarted(lastTapPosition);
}
break;
}
case TouchState::TAP_DOWN_PANNING:
@ -128,11 +131,16 @@ void InputSourceTouch::handleEventFingerDown(const SDL_TouchFingerEvent & tfinge
{
lastTapPosition = convertTouchToMouse(tfinger);
GH.input().setCursorPosition(lastTapPosition);
GH.events().dispatchGesturePanningStarted(lastTapPosition);
state = TouchState::TAP_DOWN_SHORT;
break;
}
case TouchState::TAP_DOWN_SHORT:
{
GH.input().setCursorPosition(convertTouchToMouse(tfinger));
GH.events().dispatchGesturePanningStarted(lastTapPosition);
state = TouchState::TAP_DOWN_DOUBLE;
break;
}
case TouchState::TAP_DOWN_PANNING:
{
GH.input().setCursorPosition(convertTouchToMouse(tfinger));

View File

@ -90,6 +90,15 @@ CSelWindow::CSelWindow(const std::string &Text, PlayerColor player, int charperl
//buttons.back()->addCallback(std::bind(&CCallback::selectionMade, LOCPLINT->cb.get(), 0, askID));
}
if(buttons.size() == 1)
buttons.front()->assignedKey = EShortcut::GLOBAL_RETURN;
if(buttons.size() == 2)
{
buttons.front()->assignedKey = EShortcut::GLOBAL_ACCEPT;
buttons.back()->assignedKey = EShortcut::GLOBAL_CANCEL;
}
for(int i=0;i<comps.size();i++)
{
comps[i]->recActions = 255-DISPOSE;

View File

@ -280,7 +280,7 @@ CModEntry CModList::getMod(QString modname) const
if(conf.isNull())
{
settings["active"] = true; // default
settings["active"] = !local.value("keepDisabled").toBool();
}
else
{
@ -288,7 +288,7 @@ CModEntry CModList::getMod(QString modname) const
{
settings = conf.toMap();
if(settings.value("active").isNull())
settings["active"] = true; // default
settings["active"] = !local.value("keepDisabled").toBool();
}
else
settings.insert("active", conf);

View File

@ -1390,18 +1390,7 @@ void HeroRecruited::applyGs(CGameState * gs) const
h->setOwner(player);
h->pos = tile;
bool fresh = !h->isInitialized();
if(fresh)
{ // this is a fresh hero who hasn't appeared yet
if (boatId >= 0) //Hero spawns on water
{
h->setMovementPoints(h->movementPointsLimit(false));
}
else
{
h->setMovementPoints(h->movementPointsLimit(true));
}
}
h->initObj(gs->getRandomGenerator());
if(h->id == ObjectInstanceID())
{
@ -1414,16 +1403,10 @@ void HeroRecruited::applyGs(CGameState * gs) const
gs->map->heroesOnMap.emplace_back(h);
p->heroes.emplace_back(h);
h->attachTo(*p);
if(fresh)
{
h->initObj(gs->getRandomGenerator());
}
gs->map->addBlockVisTiles(h);
if(t)
{
t->setVisitingHero(h);
}
}
void GiveHero::applyGs(CGameState * gs) const
@ -2208,19 +2191,25 @@ void BattleResultAccepted::applyGs(CGameState * gs) const
res.hero->removeBonusesRecursive(Bonus::OneBattle);
}
// Grow up growing artifacts
if(const auto hero = heroResult[winnerSide].hero)
if(winnerSide != 2)
{
if(hero->commander && hero->commander->alive)
// Grow up growing artifacts
const auto hero = heroResult[winnerSide].hero;
if (hero)
{
for(auto & art : hero->commander->artifactsWorn)
if(hero->commander && hero->commander->alive)
{
for(auto & art : hero->commander->artifactsWorn)
art.second.artifact->growingUp();
}
for(auto & art : hero->artifactsWorn)
{
art.second.artifact->growingUp();
}
for(auto & art : hero->artifactsWorn)
{
art.second.artifact->growingUp();
}
}
}
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
{
if(heroResult[0].army)

View File

@ -255,6 +255,7 @@ CGHeroInstance::CGHeroInstance():
setNodeType(HERO);
ID = Obj::HERO;
secSkills.emplace_back(SecondarySkill::DEFAULT, -1);
blockVisit = true;
}
PlayerColor CGHeroInstance::getOwner() const
@ -364,8 +365,19 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
commander->giveStackExp (exp); //after our exp is set
}
if (mana < 0)
mana = manaLimit();
skillsInfo.rand.setSeed(rand.nextInt());
skillsInfo.resetMagicSchoolCounter();
skillsInfo.resetWisdomCounter();
//copy active (probably growing) bonuses from hero prototype to hero object
for(const std::shared_ptr<Bonus> & b : type->specialty)
addNewBonus(b);
//initialize bonuses
recreateSecondarySkillsBonuses();
movement = movementPointsLimit(true);
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
}
void CGHeroInstance::initArmy(CRandomGenerator & rand, IArmyDescriptor * dst)
@ -533,15 +545,9 @@ void CGHeroInstance::SecondarySkillsInfo::resetWisdomCounter()
void CGHeroInstance::initObj(CRandomGenerator & rand)
{
blockVisit = true;
if(!type)
initHero(rand); //TODO: set up everything for prison before specialties are configured
skillsInfo.rand.setSeed(rand.nextInt());
skillsInfo.resetMagicSchoolCounter();
skillsInfo.resetWisdomCounter();
if (ID != Obj::PRISON)
{
auto terrain = cb->gameState()->getTile(visitablePos())->terType->getId();
@ -549,15 +555,6 @@ void CGHeroInstance::initObj(CRandomGenerator & rand)
if (customApp)
appearance = customApp;
}
//copy active (probably growing) bonuses from hero prototype to hero object
for(const std::shared_ptr<Bonus> & b : type->specialty)
addNewBonus(b);
//initialize bonuses
recreateSecondarySkillsBonuses();
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
}
void CGHeroInstance::recreateSecondarySkillsBonuses()