1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Major refactoring. First part: BattleInterface

Introduction of pre compiled headers,...
This commit is contained in:
beegee1
2011-12-13 21:23:17 +00:00
parent ef7a9dfd46
commit 7f04ed990b
179 changed files with 4076 additions and 3765 deletions

View File

@@ -1,6 +1,8 @@
#include "../stdafx.h"
#include "StdInc.h"
#include "CAdvmapInterface.h"
#include "CBattleInterface.h"
#include "BattleInterface/CBattleInterface.h"
#include "BattleInterface/CBattleConsole.h"
#include "../CCallback.h"
#include "CCastleInterface.h"
#include "CCursorHandler.h"
@@ -30,22 +32,10 @@
#include "../lib/map.h"
#include "../lib/VCMIDirs.h"
#include "mapHandler.h"
#include "../timeHandler.h"
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>
#include <cmath>
#include <queue>
#include <sstream>
#include <boost/filesystem.hpp>
#include "../StartInfo.h"
#include <boost/foreach.hpp>
#include "../lib/StopWatch.h"
#include "../lib/StartInfo.h"
#include "../lib/CGameState.h"
#include "../lib/GameConstants.h"
#ifdef min
#undef min
@@ -116,7 +106,7 @@ CPlayerInterface::~CPlayerInterface()
{
howManyPeople--;
//delete pim;
//delNull(pim);
//vstd::clear_pointer(pim);
delete showingDialog;
if(adventureInt)
{
@@ -383,14 +373,14 @@ SDL_Surface * CPlayerInterface::infoWin(const CGObjectInstance * specific) //spe
switch(specific->ID)
{
case HEROI_TYPE:
case GameConstants::HEROI_TYPE:
{
InfoAboutHero iah;
bool gotInfo = LOCPLINT->cb->getHeroInfo(specific, iah);
assert(gotInfo);
return graphics->drawHeroInfoWin(iah);
}
case TOWNI_TYPE:
case GameConstants::TOWNI_TYPE:
case 33: // Garrison
case 219:
{
@@ -424,7 +414,7 @@ void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int
if(CAltarWindow *ctw = dynamic_cast<CAltarWindow *>(GH.topInt()))
ctw->setExpToLevel();
}
else if(which < PRIMARY_SKILLS) //no need to redraw infowin if this is experience (exp is treated as prim skill with id==4)
else if(which < GameConstants::PRIMARY_SKILLS) //no need to redraw infowin if this is experience (exp is treated as prim skill with id==4)
updateInfo(hero);
}
@@ -729,7 +719,7 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
{
boost::unique_lock<boost::recursive_mutex> un(*pim);
if(vstd::contains(stack->state,MOVED)) //this stack has moved and makes second action -> high morale
if(vstd::contains(stack->state,EBattleStackState::MOVED)) //this stack has moved and makes second action -> high morale
{
std::string hlp = CGI->generaltexth->allTexts[33];
boost::algorithm::replace_first(hlp,"%s",(stack->count != 1) ? stack->getCreature()->namePl : stack->getCreature()->nameSing);
@@ -765,7 +755,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br)
battleInt->battleFinished(*br);
}
void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector<THex> dest, int distance)
void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector<SHexField> dest, int distance)
{
if(LOCPLINT != this)
{ //another local interface should do this
@@ -883,10 +873,10 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba)
else
{
int shift = 0;
if(ba->counter() && THex::mutualPosition(curAction->destinationTile, attacker->position) < 0)
if(ba->counter() && SHexField::mutualPosition(curAction->destinationTile, attacker->position) < 0)
{
int distp = THex::getDistance(curAction->destinationTile + 1, attacker->position);
int distm = THex::getDistance(curAction->destinationTile - 1, attacker->position);
int distp = SHexField::getDistance(curAction->destinationTile + 1, attacker->position);
int distm = SHexField::getDistance(curAction->destinationTile - 1, attacker->position);
if( distp < distm )
shift = 1;
@@ -1339,7 +1329,7 @@ void CPlayerInterface::objectPropertyChanged(const SetObjectProperty * sop)
adventureInt->minimap.showTile(*it);
}
if(obj->ID == TOWNI_TYPE)
if(obj->ID == GameConstants::TOWNI_TYPE)
{
if(obj->tempOwner == playerID)
towns.push_back(static_cast<const CGTownInstance *>(obj));
@@ -1360,7 +1350,7 @@ void CPlayerInterface::recreateHeroTownList()
//applying current heroes order to new heroes info
int j;
for (int i = 0; i < wanderingHeroes.size(); i++)
if ((j = vstd::findPos(allHeroes, wanderingHeroes[i])) >= 0)
if ((j = vstd::find_pos(allHeroes, wanderingHeroes[i])) >= 0)
if (!allHeroes[j]->inTownGarrison)
{
newWanderingHeroes += allHeroes[j];
@@ -1377,7 +1367,7 @@ void CPlayerInterface::recreateHeroTownList()
std::vector<const CGTownInstance*> newTowns;
std::vector<const CGTownInstance*> allTowns = cb->getTownsInfo();
for (int i = 0; i < towns.size(); i++)
if ((j = vstd::findPos(allTowns, towns[i])) >= 0)
if ((j = vstd::find_pos(allTowns, towns[i])) >= 0)
{
newTowns += allTowns[j];
allTowns -= allTowns[j];
@@ -1456,7 +1446,7 @@ void CPlayerInterface::centerView (int3 pos, int focusTime)
void CPlayerInterface::objectRemoved( const CGObjectInstance *obj )
{
if(obj->ID == HEROI_TYPE && obj->tempOwner == playerID)
if(obj->ID == GameConstants::HEROI_TYPE && obj->tempOwner == playerID)
{
const CGHeroInstance *h = static_cast<const CGHeroInstance*>(obj);
heroKilled(h);
@@ -2019,7 +2009,7 @@ void CPlayerInterface::showPuzzleMap()
boost::unique_lock<boost::recursive_mutex> un(*pim);
//TODO: interface should not know the real position of Grail...
float ratio = 0;
double ratio = 0;
int3 grailPos = cb->getGrailPos(ratio);
GH.pushInt(new CPuzzleWindow(grailPos, ratio));
@@ -2230,11 +2220,11 @@ void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInsta
boost::unique_lock<boost::recursive_mutex> un(*pim);
if(market->o->ID == 2) //Altar
{
//EMarketMode mode = market->availableModes().front();
if(market->allowsTrade(ARTIFACT_EXP) && visitor->getAlignment() != EVIL)
GH.pushInt(new CAltarWindow(market, visitor, ARTIFACT_EXP));
else if(market->allowsTrade(CREATURE_EXP) && visitor->getAlignment() != GOOD)
GH.pushInt(new CAltarWindow(market, visitor, CREATURE_EXP));
//EEMarketMode mode = market->availableModes().front();
if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
GH.pushInt(new CAltarWindow(market, visitor, EMarketMode::ARTIFACT_EXP));
else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
GH.pushInt(new CAltarWindow(market, visitor, EMarketMode::CREATURE_EXP));
}
else
GH.pushInt(new CMarketplaceWindow(market, visitor, market->availableModes().front()));