mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* several implrovements in campaign handling
* new cheat codes: - vcmisilmaril - player wins - vcmimelkor - player loses
This commit is contained in:
parent
686061071f
commit
99fcb23182
@ -2289,6 +2289,8 @@ void CBonusSelection::showAll( SDL_Surface * to )
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
blitAt(background, pos.x, pos.y, to);
|
||||
|
||||
show(to);
|
||||
}
|
||||
|
||||
void CBonusSelection::loadPositionsOfGraphics()
|
||||
@ -2333,7 +2335,7 @@ void CBonusSelection::selectMap( int whichOne )
|
||||
int i = 0;
|
||||
delete ourHeader;
|
||||
ourHeader = new CMapHeader();
|
||||
ourHeader->initFromMemory((const unsigned char*)ourCampaign->mapPieces[whichOne].c_str(), i);
|
||||
ourHeader->initFromMemory((const unsigned char*)ourCampaign->mapPieces.find(whichOne)->second.c_str(), i);
|
||||
CMapInfo *mapInfo = const_cast<CMapInfo *>(curMap);
|
||||
mapInfo->mapHeader = ourHeader;
|
||||
mapInfo->countPlayers();
|
||||
@ -2490,7 +2492,35 @@ void CBonusSelection::updateBonusSelection()
|
||||
|
||||
break;
|
||||
case 7: //resource
|
||||
//TODO
|
||||
{
|
||||
int serialResID = 0;
|
||||
switch(bonDescs[i].info1)
|
||||
{
|
||||
case 0: case 1: case 2: case 3: case 4: case 5: case 6:
|
||||
serialResID = bonDescs[i].info1;
|
||||
break;
|
||||
case 0xFD: //wood + ore
|
||||
serialResID = 7;
|
||||
break;
|
||||
case 0xFE: //rare resources
|
||||
serialResID = 8;
|
||||
break;
|
||||
}
|
||||
surfToDuplicate = de->ourImages[serialResID].bitmap;
|
||||
|
||||
desc = CGI->generaltexth->allTexts[717];
|
||||
boost::algorithm::replace_first(desc, "%d", boost::lexical_cast<std::string>(bonDescs[i].info2));
|
||||
std::string replacement;
|
||||
if (serialResID <= 6)
|
||||
{
|
||||
replacement = CGI->generaltexth->restypes[serialResID];
|
||||
}
|
||||
else
|
||||
{
|
||||
replacement = CGI->generaltexth->allTexts[714 + serialResID];
|
||||
}
|
||||
boost::algorithm::replace_first(desc, "%s", replacement);
|
||||
}
|
||||
break;
|
||||
case 8: //player
|
||||
//TODO
|
||||
@ -2517,8 +2547,10 @@ void CBonusSelection::updateBonusSelection()
|
||||
delete de;
|
||||
}
|
||||
}
|
||||
|
||||
bonuses->select(0, 0);
|
||||
if (bonDescs.size() > 0)
|
||||
{
|
||||
bonuses->select(0, 0);
|
||||
}
|
||||
|
||||
delete twcp;
|
||||
|
||||
|
@ -100,26 +100,34 @@ CCampaign * CCampaignHandler::getCampaign( const std::string & name, bool fromLo
|
||||
std::vector<ui32> h3mStarts = locateH3mStarts(cmpgn, it, realSize);
|
||||
|
||||
assert(h3mStarts.size() <= howManyScenarios);
|
||||
//it looks like we can have less scenarios than we should..
|
||||
//if(h3mStarts.size() != howManyScenarios)
|
||||
//{
|
||||
// tlog1<<"Our heuristic for h3m start points gave wrong results for campaign " << name <<std::endl;
|
||||
// tlog1<<"Please send this campaign to VCMI Project team to help us fix this problem" << std::endl;
|
||||
// delete [] cmpgn;
|
||||
// assert(0);
|
||||
// return NULL;
|
||||
//}
|
||||
//it looks like we can have more scenarios than we should..
|
||||
if(h3mStarts.size() > howManyScenarios)
|
||||
{
|
||||
tlog1<<"Our heuristic for h3m start points gave wrong results for campaign " << name <<std::endl;
|
||||
tlog1<<"Please send this campaign to VCMI Project team to help us fix this problem" << std::endl;
|
||||
delete [] cmpgn;
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int scenarioID = 0;
|
||||
|
||||
for (int g=0; g<h3mStarts.size(); ++g)
|
||||
{
|
||||
while(!ret->scenarios[scenarioID].isNotVoid()) //skip void scenarios
|
||||
{
|
||||
scenarioID++;
|
||||
}
|
||||
//set map piece appropriately
|
||||
if(g == h3mStarts.size() - 1)
|
||||
{
|
||||
ret->mapPieces.push_back(std::string( cmpgn + h3mStarts[g], cmpgn + realSize ));
|
||||
ret->mapPieces[scenarioID] = std::string( cmpgn + h3mStarts[g], cmpgn + realSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
ret->mapPieces.push_back(std::string( cmpgn + h3mStarts[g], cmpgn + h3mStarts[g+1] ));
|
||||
ret->mapPieces[scenarioID] = std::string( cmpgn + h3mStarts[g], cmpgn + h3mStarts[g+1] );
|
||||
}
|
||||
scenarioID++;
|
||||
}
|
||||
|
||||
delete [] cmpgn;
|
||||
@ -423,6 +431,12 @@ unsigned char * CCampaignHandler::getFile( const std::string & name, bool fromLo
|
||||
|
||||
bool CCampaign::conquerable( int whichScenario ) const
|
||||
{
|
||||
//check for void scenraio
|
||||
if (!scenarios[whichScenario].isNotVoid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (scenarios[whichScenario].conquered)
|
||||
{
|
||||
return false;
|
||||
@ -440,4 +454,9 @@ bool CCampaign::conquerable( int whichScenario ) const
|
||||
CCampaign::CCampaign()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool CCampaignScenario::isNotVoid() const
|
||||
{
|
||||
return mapName.size() > 0;
|
||||
}
|
||||
|
@ -94,6 +94,8 @@ public:
|
||||
|
||||
CScenarioTravel travelOptions;
|
||||
|
||||
bool isNotVoid() const;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
||||
{
|
||||
h & mapName & packedMapSize & preconditionRegion & regionColor & difficulty & conquered & regionText &
|
||||
@ -106,7 +108,7 @@ class DLL_EXPORT CCampaign
|
||||
public:
|
||||
CCampaignHeader header;
|
||||
std::vector<CCampaignScenario> scenarios;
|
||||
std::vector<std::string> mapPieces; //binary h3ms
|
||||
std::map<int, std::string> mapPieces; //binary h3ms, scenario number -> map data
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
std::vector<std::string> creGens4; //names of multiple creatures' generators
|
||||
std::vector<std::string> advobtxt;
|
||||
std::vector<std::string> xtrainfo;
|
||||
std::vector<std::string> restypes;
|
||||
std::vector<std::string> restypes; //names of resources
|
||||
std::vector<std::string> terrainNames;
|
||||
std::vector<std::string> randsign;
|
||||
std::vector<std::pair<std::string,std::string> > mines; //first - name; second - event description
|
||||
|
@ -3090,6 +3090,11 @@ int CGameState::victoryCheck( ui8 player ) const
|
||||
if(player == checkForStandardWin())
|
||||
return -1;
|
||||
|
||||
if (p->enteredWinningCheatCode)
|
||||
{ //cheater or tester, but has entered the code...
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(p->human || map->victoryCondition.appliesToAI)
|
||||
{
|
||||
switch(map->victoryCondition.condition)
|
||||
@ -3428,6 +3433,11 @@ int CGameState::lossCheck( ui8 player ) const
|
||||
if(checkForStandardLoss(player))
|
||||
return -1;
|
||||
|
||||
if (p->enteredLosingCheatCode)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(p->human) //special loss condition applies only to human player
|
||||
{
|
||||
switch(map->lossCondition.typeOfLossCon)
|
||||
@ -3879,7 +3889,8 @@ CMP_stack::CMP_stack( int Phase /*= 1*/, int Turn )
|
||||
}
|
||||
|
||||
PlayerState::PlayerState()
|
||||
: color(-1), currentSelection(0xffffffff), status(INGAME), daysWithoutCastle(0)
|
||||
: color(-1), currentSelection(0xffffffff), status(INGAME), daysWithoutCastle(0),
|
||||
enteredLosingCheatCode(0), enteredWinningCheatCode(0)
|
||||
{
|
||||
|
||||
}
|
||||
@ -3979,7 +3990,10 @@ void CCampaignState::initNewCampaign( const StartInfo &si )
|
||||
campaignName = si.mapname;
|
||||
currentMap = si.whichMapInCampaign;
|
||||
|
||||
camp = CCampaignHandler::getCampaign(campaignName, true); //TODO lod???
|
||||
//check if campaign is in lod or not
|
||||
bool inLod = campaignName.find('/') == std::string::npos;
|
||||
|
||||
camp = CCampaignHandler::getCampaign(campaignName, inLod); //TODO lod???
|
||||
for (ui8 i = 0; i < camp->mapPieces.size(); i++)
|
||||
mapsRemaining.push_back(i);
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
std::vector<CGHeroInstance *> availableHeroes; //heroes available in taverns
|
||||
std::vector<CGDwelling *> dwellings; //used for town growth
|
||||
|
||||
ui8 enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory
|
||||
ui8 status; //0 - in game, 1 - loser, 2 - winner <- uses EStatus enum
|
||||
ui8 daysWithoutCastle;
|
||||
|
||||
@ -140,6 +141,7 @@ public:
|
||||
{
|
||||
h & color & serial & human & currentSelection & fogOfWarMap & resources & status;
|
||||
h & heroes & towns & availableHeroes & dwellings & bonuses & status & daysWithoutCastle;
|
||||
h & enteredLosingCheatCode & enteredWinningCheatCode;
|
||||
h & static_cast<CBonusSystemNode&>(*this);
|
||||
}
|
||||
};
|
||||
|
@ -3898,11 +3898,21 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message )
|
||||
fc.tiles.insert(int3(i,j,k));
|
||||
sendAndApply(&fc);
|
||||
}
|
||||
else if(message == "vcmiglorfindel")
|
||||
else if(message == "vcmiglorfindel") //selected hero gains a new level
|
||||
{
|
||||
CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
|
||||
changePrimSkill(hero->id,4,VLC->heroh->reqExp(hero->level+1) - VLC->heroh->reqExp(hero->level));
|
||||
}
|
||||
else if(message == "vcmisilmaril") //player wins
|
||||
{
|
||||
gs->getPlayer(player)->enteredWinningCheatCode = 1;
|
||||
checkLossVictory(player);
|
||||
}
|
||||
else if(message == "vcmimelkor") //player looses
|
||||
{
|
||||
gs->getPlayer(player)->enteredLosingCheatCode = 1;
|
||||
checkLossVictory(player);
|
||||
}
|
||||
else
|
||||
cheated = false;
|
||||
if(cheated)
|
||||
|
Loading…
Reference in New Issue
Block a user