mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
Fixed crash on casting spell. Fixed giving resources from towns. Version set to 0.74c. Incremented save format version.
Disabled adventure AI. Will be released as dev build.
This commit is contained in:
parent
82faf7538e
commit
7f97a56a28
@ -1028,31 +1028,31 @@ void CGeniusAI::yourTurn()
|
||||
m_cb->waitTillRealize = true;
|
||||
static int seed = rand();
|
||||
srand(seed);
|
||||
if (m_cb->getDate() == 1) {
|
||||
// startFirstTurn();
|
||||
|
||||
// m_cb->endTurn();
|
||||
// return;
|
||||
}
|
||||
//////////////TODO: replace with updates. Also add suspected objects list./////////
|
||||
knownVisitableObjects.clear();
|
||||
int3 pos = m_cb->getMapSize();
|
||||
for (int x = 0; x < pos.x; x++) {
|
||||
for (int y = 0; y < pos.y; y++) {
|
||||
for (int z = 0; z < pos.z; z++)
|
||||
tileRevealed(int3(x,y,z));
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
reportResources();
|
||||
|
||||
trueGameState = HypotheticalGameState(*this);
|
||||
AIObjective * objective;
|
||||
while ((objective = getBestObjective()) != NULL)
|
||||
objective->fulfill(*this,trueGameState);
|
||||
|
||||
seed = rand();
|
||||
// if (m_cb->getDate() == 1) {
|
||||
// // startFirstTurn();
|
||||
//
|
||||
// // m_cb->endTurn();
|
||||
// // return;
|
||||
// }
|
||||
// //////////////TODO: replace with updates. Also add suspected objects list./////////
|
||||
// knownVisitableObjects.clear();
|
||||
// int3 pos = m_cb->getMapSize();
|
||||
// for (int x = 0; x < pos.x; x++) {
|
||||
// for (int y = 0; y < pos.y; y++) {
|
||||
// for (int z = 0; z < pos.z; z++)
|
||||
// tileRevealed(int3(x,y,z));
|
||||
// }
|
||||
// }
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// reportResources();
|
||||
//
|
||||
// trueGameState = HypotheticalGameState(*this);
|
||||
// AIObjective * objective;
|
||||
// while ((objective = getBestObjective()) != NULL)
|
||||
// objective->fulfill(*this,trueGameState);
|
||||
//
|
||||
// seed = rand();
|
||||
m_cb->endTurn();
|
||||
m_cb->waitTillRealize = false;
|
||||
}
|
||||
|
@ -1455,17 +1455,6 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
|
||||
SDL_SetClipRect(to, &buf); //restoring previous clip_rect
|
||||
|
||||
//showing buttons
|
||||
bOptions->show(to);
|
||||
bSurrender->show(to);
|
||||
bFlee->show(to);
|
||||
bAutofight->show(to);
|
||||
bSpell->show(to);
|
||||
bWait->show(to);
|
||||
bDefence->show(to);
|
||||
bConsoleUp->show(to);
|
||||
bConsoleDown->show(to);
|
||||
|
||||
//prevents blitting outside this window
|
||||
SDL_GetClipRect(to, &buf);
|
||||
SDL_SetClipRect(to, &pos);
|
||||
@ -1611,6 +1600,17 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
blitAt(menu, pos.x, 556 + pos.y, to);
|
||||
console->show(to);
|
||||
|
||||
//showing buttons
|
||||
bOptions->show(to);
|
||||
bSurrender->show(to);
|
||||
bFlee->show(to);
|
||||
bAutofight->show(to);
|
||||
bSpell->show(to);
|
||||
bWait->show(to);
|
||||
bDefence->show(to);
|
||||
bConsoleUp->show(to);
|
||||
bConsoleDown->show(to);
|
||||
|
||||
//showing window with result of battle
|
||||
if(resWindow)
|
||||
{
|
||||
|
2
global.h
2
global.h
@ -20,7 +20,7 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
|
||||
#define THC
|
||||
#endif
|
||||
|
||||
#define NAME_VER ("VCMI 0.74b")
|
||||
#define NAME_VER ("VCMI 0.74c")
|
||||
extern std::string NAME; //full name
|
||||
extern std::string NAME_AFFIX; //client / server
|
||||
#define CONSOLE_LOGGING_LEVEL 5
|
||||
|
@ -246,16 +246,16 @@ CLoadFile::CLoadFile( const std::string &fname )
|
||||
|
||||
if(std::memcmp(buffer,"VCMI",4))
|
||||
{
|
||||
tlog1 << "Error: wrong save format! (file " << fname << " )\n";
|
||||
tlog1 << "Error: not a VCMI save! (file " << fname << " )\n";
|
||||
delete sfile;
|
||||
sfile = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
*this >> myVersion;
|
||||
if(myVersion > version || myVersion < 110)
|
||||
if(myVersion != version)
|
||||
{
|
||||
tlog1 << "Wrong save format! (file " << fname << " )\n";
|
||||
tlog1 << "Error: Not supported save format! (file " << fname << " )\n";
|
||||
delete sfile;
|
||||
sfile = NULL;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
const ui32 version = 711;
|
||||
const ui32 version = 712;
|
||||
class CConnection;
|
||||
class CGObjectInstance;
|
||||
class CGameState;
|
||||
|
@ -215,20 +215,20 @@ struct SetResource : public CPackForClient //102
|
||||
h & player & resid & val;
|
||||
}
|
||||
};
|
||||
struct SetResources : public CPackForClient //104
|
||||
{
|
||||
SetResources(){res.resize(RESOURCE_QUANTITY);type = 104;};
|
||||
void applyCl(CClient *cl);
|
||||
DLL_EXPORT void applyGs(CGameState *gs);
|
||||
|
||||
ui8 player;
|
||||
std::vector<si32> res; //res[resid] => res amount
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & player & res;
|
||||
}
|
||||
};
|
||||
struct SetResources : public CPackForClient //104
|
||||
{
|
||||
SetResources(){res.resize(RESOURCE_QUANTITY);type = 104;};
|
||||
void applyCl(CClient *cl);
|
||||
DLL_EXPORT void applyGs(CGameState *gs);
|
||||
|
||||
ui8 player;
|
||||
std::vector<si32> res; //res[resid] => res amount
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & player & res;
|
||||
}
|
||||
};
|
||||
|
||||
struct SetPrimSkill : public CPackForClient //105
|
||||
{
|
||||
@ -593,8 +593,9 @@ struct NewTurn : public CPackForClient //101
|
||||
};
|
||||
|
||||
std::set<Hero> heroes; //updates movement and mana points
|
||||
std::vector<SetResources> res;//resource list
|
||||
std::vector<SetAvailableCreatures> cres;//resource list
|
||||
//std::vector<SetResources> res;//resource list
|
||||
std::map<ui8, std::vector<si32> > res; //player ID => resource value[res_id]
|
||||
std::vector<SetAvailableCreatures> cres;//creatures to be placed in towns
|
||||
ui32 day;
|
||||
bool resetBuilded;
|
||||
|
||||
|
@ -42,12 +42,12 @@ DLL_EXPORT void SetResource::applyGs( CGameState *gs )
|
||||
gs->getPlayer(player)->resources[resid] = val;
|
||||
}
|
||||
|
||||
DLL_EXPORT void SetResources::applyGs( CGameState *gs )
|
||||
{
|
||||
assert(player < PLAYER_LIMIT);
|
||||
for(int i=0;i<res.size();i++)
|
||||
gs->getPlayer(player)->resources[i] = res[i];
|
||||
}
|
||||
DLL_EXPORT void SetResources::applyGs( CGameState *gs )
|
||||
{
|
||||
assert(player < PLAYER_LIMIT);
|
||||
for(int i=0;i<res.size();i++)
|
||||
gs->getPlayer(player)->resources[i] = res[i];
|
||||
}
|
||||
|
||||
DLL_EXPORT void SetPrimSkill::applyGs( CGameState *gs )
|
||||
{
|
||||
@ -546,8 +546,13 @@ DLL_EXPORT void NewTurn::applyGs( CGameState *gs )
|
||||
hero->mana = h.mana;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(SetResources h, res) //give resources
|
||||
h.applyGs(gs);
|
||||
for(std::map<ui8, std::vector<si32> >::iterator i = res.begin(); i != res.end(); i++)
|
||||
{
|
||||
assert(i->first < PLAYER_LIMIT);
|
||||
std::vector<si32> &playerRes = gs->getPlayer(i->first)->resources;
|
||||
for(int j = 0; j < i->second.size(); j++)
|
||||
playerRes[j] = i->second[j];
|
||||
}
|
||||
|
||||
BOOST_FOREACH(SetAvailableCreatures h, cres) //set available creatures in towns
|
||||
h.applyGs(gs);
|
||||
@ -748,7 +753,8 @@ DLL_EXPORT void StartAction::applyGs( CGameState *gs )
|
||||
break;
|
||||
}
|
||||
|
||||
st->state -= WAITING; //if stack was waiting it has made move, so it won't be "waiting" anymore (if the action was WAIT, then we have returned)
|
||||
if(st)
|
||||
st->state -= WAITING; //if stack was waiting it has made move, so it won't be "waiting" anymore (if the action was WAIT, then we have returned)
|
||||
}
|
||||
|
||||
DLL_EXPORT void SpellCast::applyGs( CGameState *gs )
|
||||
|
@ -801,10 +801,12 @@ void CGameHandler::newTurn()
|
||||
sendAndApply(&sah);
|
||||
}
|
||||
if(i->first>=PLAYER_LIMIT) continue;
|
||||
SetResources r;
|
||||
r.player = i->first;
|
||||
for(int j=0;j<RESOURCE_QUANTITY;j++)
|
||||
r.res[j] = i->second.resources[j];
|
||||
|
||||
n.res[i->first] = i->second.resources;
|
||||
// SetResources r;
|
||||
// r.player = i->first;
|
||||
// for(int j=0;j<RESOURCE_QUANTITY;j++)
|
||||
// r.res[j] = i->second.resources[j];
|
||||
|
||||
BOOST_FOREACH(CGHeroInstance *h, (*i).second.heroes)
|
||||
{
|
||||
@ -827,25 +829,26 @@ void CGameHandler::newTurn()
|
||||
switch(h->getSecSkillLevel(13)) //handle estates - give gold
|
||||
{
|
||||
case 1: //basic
|
||||
r.res[6] += 125;
|
||||
n.res[i->first][6] += 125;
|
||||
break;
|
||||
case 2: //advanced
|
||||
r.res[6] += 250;
|
||||
n.res[i->first][6] += 250;
|
||||
break;
|
||||
case 3: //expert
|
||||
r.res[6] += 500;
|
||||
n.res[i->first][6] += 500;
|
||||
break;
|
||||
}
|
||||
|
||||
for(std::list<HeroBonus>::iterator i = h->bonuses.begin(); i != h->bonuses.end(); i++)
|
||||
if(i->type == HeroBonus::GENERATE_RESOURCE)
|
||||
r.res[i->subtype] += i->val;
|
||||
for(std::list<HeroBonus>::iterator j = h->bonuses.begin(); j != h->bonuses.end(); j++)
|
||||
if(j->type == HeroBonus::GENERATE_RESOURCE)
|
||||
n.res[i->first][j->subtype] += j->val;
|
||||
}
|
||||
}
|
||||
n.res.push_back(r);
|
||||
//n.res.push_back(r);
|
||||
}
|
||||
for(std::vector<CGTownInstance *>::iterator j = gs->map->towns.begin(); j!=gs->map->towns.end(); j++)//handle towns
|
||||
{
|
||||
ui8 player = (*j)->tempOwner;
|
||||
if(gs->getDate(1)==7) //first day of week
|
||||
{
|
||||
SetAvailableCreatures sac;
|
||||
@ -862,24 +865,23 @@ void CGameHandler::newTurn()
|
||||
}
|
||||
n.cres.push_back(sac);
|
||||
}
|
||||
if(gs->day && (*j)->tempOwner < PLAYER_LIMIT)//not the first day and town not neutral
|
||||
if(gs->day && player < PLAYER_LIMIT)//not the first day and town not neutral
|
||||
{
|
||||
SetResources r;
|
||||
r.player = (**j).tempOwner;
|
||||
////SetResources r;
|
||||
//r.player = (**j).tempOwner;
|
||||
if(vstd::contains((**j).builtBuildings,15)) //there is resource silo
|
||||
{
|
||||
if((**j).town->primaryRes == 127) //we'll give wood and ore
|
||||
{
|
||||
r.res[0] += 1;
|
||||
r.res[2] += 1;
|
||||
n.res[player][0] += 1;
|
||||
n.res[player][2] += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.res[(**j).town->primaryRes] += 1;
|
||||
n.res[player][(**j).town->primaryRes] += 1;
|
||||
}
|
||||
}
|
||||
r.res[6] += (**j).dailyIncome();
|
||||
n.res.push_back(r);
|
||||
n.res[player][6] += (**j).dailyIncome();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2493,6 +2495,7 @@ bool CGameHandler::queryReply( ui32 qid, ui32 answer )
|
||||
|
||||
bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
{
|
||||
tlog1 << "\tMaking action of type " << ba.actionType << std::endl;
|
||||
bool ok = true;
|
||||
switch(ba.actionType)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user