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

bugfixing:

- support for one more Russian localisation, fixes #1321
 - fixed icon for level 1 town hall, #1294
 - correct portraits for first heroes from mods, #1297 and probably #1298
And a lot of gcc compile fixes
This commit is contained in:
Ivan Savenko 2013-06-23 19:35:54 +00:00
parent 17403b544c
commit dd808ef5cc
19 changed files with 64 additions and 44 deletions

View File

@ -67,7 +67,7 @@ auto sum(const Container & c, Pred p) -> decltype(p(*boost::begin(c)))
CBattleAI::CBattleAI(void)
: side(-1), cb(NULL)
: side(-1)
{
print("created");
}

View File

@ -83,8 +83,9 @@ struct AttackPossibility
};
template<typename Key, typename Val, typename Val2>
const Val &getValOr(const std::map<Key, Val> &Map, const Key &key, const Val2 &defaultValue)
const Val getValOr(const std::map<Key, Val> &Map, const Key &key, const Val2 defaultValue)
{
//returning references here won't work: defaultValue must be converted into Val, creating temporary
auto i = Map.find(key);
if(i != Map.end())
return i->second;

View File

@ -8,7 +8,7 @@
shared_ptr<CBattleCallback> cbc;
CStupidAI::CStupidAI(void)
: side(-1), cb(NULL)
: side(-1)
{
print("created");
}

View File

@ -411,7 +411,6 @@ bool compareDanger(const CGObjectInstance *lhs, const CGObjectInstance *rhs)
VCAI::VCAI(void)
{
LOG_TRACE(logAi);
myCb = nullptr;
makingTurn = nullptr;
}

View File

@ -166,6 +166,16 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero):
new CAnimImage("PSKIL42", 4, 0, 20, 230, false);
new CAnimImage("PSKIL42", 5, 0, 242, 111, false);
// various texts
new CLabel( 52, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[1]);
new CLabel(123, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[2]);
new CLabel(193, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[3]);
new CLabel(262, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[4]);
new CLabel( 69, 183, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[5]);
new CLabel( 69, 232, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[6]);
new CLabel(213, 232, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[7]);
update(hero);
}
@ -272,7 +282,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
//setting formations
formations->onChange = 0;
formations->select(curHero->formation,true);
formations->onChange = boost::bind(&CCallback::setFormation, LOCPLINT->cb, curHero, _1);
formations->onChange = boost::bind(&CCallback::setFormation, LOCPLINT->cb.get(), curHero, _1);
morale->set(&heroWArt);
luck->set(&heroWArt);
@ -284,7 +294,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
void CHeroWindow::dismissCurrent()
{
CFunctionList<void()> ony = boost::bind(&CHeroWindow::close,this);
ony += boost::bind(&CCallback::dismissHero,LOCPLINT->cb,curHero);
ony += boost::bind(&CCallback::dismissHero, LOCPLINT->cb.get(), curHero);
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22], ony, 0, false);
}
@ -335,12 +345,6 @@ void CHeroWindow::showAll(SDL_Surface * to)
boost::algorithm::replace_first(secondLine,"%d",boost::lexical_cast<std::string>(curHero->level));
boost::algorithm::replace_first(secondLine,"%s",curHero->type->heroClass->name);
printAtMiddleLoc(secondLine, 190, 65, FONT_MEDIUM, Colors::WHITE, to);
//primary skills names
printAtMiddleLoc(CGI->generaltexth->jktexts[1], 52, 99, FONT_SMALL, Colors::YELLOW, 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);
//printing primary skills' amounts
for(int m=0; m<4; ++m)
@ -358,15 +362,11 @@ void CHeroWindow::showAll(SDL_Surface * to)
}
//printing special ability
printAtLoc(CGI->generaltexth->jktexts[5].substr(1, CGI->generaltexth->jktexts[5].size()-2), 69, 183, FONT_SMALL, Colors::YELLOW, to);
printAtLoc(curHero->type->specName, 69, 205, FONT_SMALL, Colors::WHITE, to);
//printing necessery texts
printAtLoc(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 232, FONT_SMALL, Colors::YELLOW, to);
std::ostringstream expstr;
expstr << curHero->exp;
printAtLoc(expstr.str(), 68, 252, FONT_SMALL, Colors::WHITE, to);
printAtLoc(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 213, 232, FONT_SMALL, Colors::YELLOW, to);
std::ostringstream manastr;
manastr << curHero->mana << '/' << heroWArt.manaLimit();
printAtLoc(manastr.str(), 211, 252, FONT_SMALL, Colors::WHITE, to);

View File

@ -767,7 +767,7 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
}
cb->unregisterBattleInterface(autofightingAI);
autofightingAI = nullptr;
autofightingAI.reset();
}
CBattleInterface *b = battleInt;
@ -804,7 +804,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br)
{
isAutoFightOn = false;
cb->unregisterBattleInterface(autofightingAI);
autofightingAI = nullptr;
autofightingAI.reset();
if(!battleInt)
{

View File

@ -920,7 +920,7 @@ void CSelectionScreen::startScenario()
saveGameName = "Saves/" + sel->txt->text;
CFunctionList<void()> overWrite;
overWrite += boost::bind(&CCallback::save, LOCPLINT->cb, saveGameName);
overWrite += boost::bind(&CCallback::save, LOCPLINT->cb.get(), saveGameName);
overWrite += bind(&CGuiHandler::popIntTotally, &GH, this);
if(CResourceHandler::get()->existsResource(ResourceID(saveGameName, EResType::CLIENT_SAVEGAME)))

View File

@ -464,7 +464,7 @@ void CClient::serialize( Handler &h, const int version )
h & pid & dllname & isHuman;
LOG_TRACE_PARAMS(logGlobal, "Loading player %s interface", pid);
shared_ptr<CGameInterface> nInt = nullptr;
shared_ptr<CGameInterface> nInt;
if(dllname.length())
{
if(pid == PlayerColor::NEUTRAL)
@ -579,7 +579,7 @@ void CClient::battleStarted(const BattleInfo * info)
// if(battleCallbacks.count(side))
// battleCallbacks[side]->setBattle(info);
shared_ptr<CPlayerInterface> att = nullptr, def = nullptr;
shared_ptr<CPlayerInterface> att, def;
//If quick combat is not, do not prepare interfaces for battleint
if(!settings["adventure"]["quickCombat"].Bool())

View File

@ -165,8 +165,7 @@ void CTownTooltip::init(const InfoAboutTown &town)
if(town.details)
{
if (town.details->hallLevel)
new CAnimImage("ITMTLS", town.details->hallLevel, 0, 67, 31);
new CAnimImage("ITMTLS", town.details->hallLevel, 0, 67, 31);
if (town.details->goldIncome)
new CLabel(157, 58, FONT_TINY, CENTER, Colors::WHITE,
@ -322,8 +321,8 @@ void CGarrisonSlot::clickLeft(tribool down, bool previousState)
bool canDismiss = getObj()->tempOwner == LOCPLINT->playerID && (getObj()->stacksCount()>1 || !getObj()->needsLastStack());
boost::function<void()> upgr = NULL;
boost::function<void()> dism = NULL;
if (canUpgrade) upgr = boost::bind(&CCallback::upgradeCreature, LOCPLINT->cb, getObj(), ID, pom.newID[0]);
if (canDismiss) dism = boost::bind(&CCallback::dismissCreature, LOCPLINT->cb, getObj(), ID);
if (canUpgrade) upgr = boost::bind(&CCallback::upgradeCreature, LOCPLINT->cb.get(), getObj(), ID, pom.newID[0]);
if (canDismiss) dism = boost::bind(&CCallback::dismissCreature, LOCPLINT->cb.get(), getObj(), ID);
owner->selectSlot(nullptr);
owner->setSplittingMode(false);
@ -1280,7 +1279,7 @@ CSelWindow::CSelWindow(const std::string &Text, PlayerColor player, int charperl
buttons.back()->assignedKeys.insert(SDLK_ESCAPE); //last button - reacts on escape
if(buttons.size() > 1 && askID.getNum() >= 0) //cancel button functionality
buttons.back()->callback += boost::bind(&CCallback::selectionMade,LOCPLINT->cb,0,askID);
buttons.back()->callback += boost::bind(&CCallback::selectionMade,LOCPLINT->cb.get(),0,askID);
for(int i=0;i<comps.size();i++)
{
@ -4260,7 +4259,7 @@ void CArtPlace::clickRight(tribool down, bool previousState)
ourArt->artType->id,
combination->id,
true,
boost::bind(&CCallback::assembleArtifacts, LOCPLINT->cb, ourOwner->curHero, slotID, true, combination->id),
boost::bind(&CCallback::assembleArtifacts, LOCPLINT->cb.get(), ourOwner->curHero, slotID, true, combination->id),
0);
if(assemblyPossibilities.size() > 2)
@ -4278,7 +4277,7 @@ void CArtPlace::clickRight(tribool down, bool previousState)
ourArt->artType->id,
0,
false,
boost::bind(&CCallback::assembleArtifacts, LOCPLINT->cb, ourOwner->curHero, slotID, false, ArtifactID()),
boost::bind(&CCallback::assembleArtifacts, LOCPLINT->cb.get(), ourOwner->curHero, slotID, false, ArtifactID()),
0);
return;
}

View File

@ -59,8 +59,10 @@
cl->battleints[player]->function(__VA_ARGS__); \
\
if(cl->additionalBattleInts.count(player)) \
{ \
BOOST_FOREACH(auto bInt, cl->additionalBattleInts[player])\
bInt->function(__VA_ARGS__); \
} \
} while (0);
#define BATTLE_INTERFACE_CALL_RECEIVERS(function,...) \

View File

@ -92,12 +92,11 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
CGHeroInstance *hero1, CGHeroInstance *hero2,
const SDL_Rect & myRect,
shared_ptr<CPlayerInterface> att, shared_ptr<CPlayerInterface> defen)
: queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
: background(nullptr), queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
activeStack(NULL), stackToActivate(NULL), selectedStack(NULL), mouseHoveredStack(-1), lastMouseHoveredStackAnimationTime(-1), previouslyHoveredHex(-1),
currentlyHoveredHex(-1), attackingHex(-1), tacticianInterface(NULL), stackCanCastSpell(false), creatureCasting(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(NULL), sp(NULL),
currentlyHoveredHex(-1), attackingHex(-1), stackCanCastSpell(false), creatureCasting(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(NULL), sp(NULL),
siegeH(NULL), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0),
givenCommand(NULL), myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL),
background(nullptr)
givenCommand(NULL), myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL)
{
OBJ_CONSTRUCTION;

View File

@ -227,6 +227,8 @@ public:
bool moveStarted; //if true, the creature that is already moving is going to make its first step
int moveSh; // sound handler used when moving a unit
const BattleResult * bresult; //result of a battle; if non-zero then display when all animations end
//button handle funcs:
void bOptionsf();
void bSurrenderf();
@ -265,7 +267,6 @@ public:
void hexLclicked(int whichOne); //hex only call-in
void stackIsCatapulting(const CatapultAttack & ca); //called when a stack is attacking walls
void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed
const BattleResult * bresult; //result of a battle; if non-zero then display when all animations end
void displayBattleFinished(); //displays battle result
void spellCast(const BattleSpellCast * sc); //called when a hero casts a spell
void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks

View File

@ -345,8 +345,6 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
}
else
{
int bestMonsterID = -1;
ui32 bestPower = 0;
auto stacks = owner.cb->battleGetAllStacks();
vstd::erase_if(stacks, [i](const CStack *stack) //erase stack of other side and not coming from garrison
{ return stack->attackerOwned == i || !stack->base; });

View File

@ -285,7 +285,24 @@ std::vector<JsonNode> CCreatureHandler::loadLegacyData(size_t dataSize)
CLegacyConfigParser parser("DATA/CRTRAITS.TXT");
parser.endLine(); // header
parser.endLine();
// this file is a bit different in some of Russian localisations:
//ENG: Singular Plural Wood ...
//RUS: Singular Plural Plural2 Wood ...
// Try to detect which version this is by header
// TODO: use 3rd name? Stand for "whose", e.g. pikemans'
size_t namesCount;
{
if ( parser.readString() != "Singular" || parser.readString() != "Plural" )
throw std::runtime_error("Incorrect format of CrTraits.txt");
if (parser.readString() == "Plural2")
namesCount = 3;
else
namesCount = 2;
parser.endLine();
}
for (size_t i=0; i<dataSize; i++)
{
@ -296,6 +313,10 @@ std::vector<JsonNode> CCreatureHandler::loadLegacyData(size_t dataSize)
JsonNode data;
data["name"]["singular"].String() = parser.readString();
if (namesCount == 3)
parser.readString();
data["name"]["plural"].String() = parser.readString();
for(int v=0; v<7; ++v)

View File

@ -195,7 +195,7 @@ void CAdventureAI::battleSpellCast(const BattleSpellCast *sc)
void CAdventureAI::battleEnd(const BattleResult *br)
{
battleAI->battleEnd(br);
battleAI = nullptr;
battleAI.reset();
}
void CAdventureAI::battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom)

View File

@ -112,7 +112,7 @@ public:
class DLL_LINKAGE CAdventureAI : public CGlobalAI
{
public:
CAdventureAI() : battleAI(NULL), cbc(NULL) {};
CAdventureAI() {};
shared_ptr<CBattleGameInterface> battleAI;
shared_ptr<CBattleCallback> cbc;

View File

@ -103,7 +103,7 @@ std::string CLegacyConfigParser::readString()
else
ret = extractNormalString();//string without quotes - copy till \t or \r
curr++;
curr++;
return ret;
}
@ -122,7 +122,7 @@ float CLegacyConfigParser::readNumber()
return result;
}
bool CLegacyConfigParser::isNextEntryEmpty()
bool CLegacyConfigParser::isNextEntryEmpty() const
{
char * nextSymbol = curr;
while (nextSymbol < end && *nextSymbol == ' ')
@ -136,7 +136,7 @@ bool CLegacyConfigParser::endLine()
while (curr < end && *curr != '\n')
readString();
curr++;
curr++;
return curr < end;
}

View File

@ -46,7 +46,7 @@ public:
}
/// returns true if next entry is empty
bool isNextEntryEmpty();
bool isNextEntryEmpty() const;
/// end current line
bool endLine();

View File

@ -470,7 +470,7 @@ void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNod
{
auto object = loadFromJson(data);
object->ID = HeroTypeID(heroes.size());
object->imageIndex = heroes.size() + 8; // 2 special frames + some extra portraits
object->imageIndex = heroes.size() + 10; // 2 special frames + some extra portraits
heroes.push_back(object);