mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
- fixed 355, 356, 360
- fixed bug in map handling (random creatures in random town\hero)
This commit is contained in:
parent
96819379c5
commit
5eef9cde44
@ -1150,9 +1150,11 @@ void CCastleInterface::CCreaInfo::clickRight(tribool down, bool previousState)
|
||||
CGI->creh->creatures[crid].hordeGrowth);
|
||||
|
||||
cnt = 0;
|
||||
int creaLevel = (bid-30)%CREATURES_PER_TOWN;//dwellings have unupgraded units
|
||||
|
||||
for (std::vector<CGDwelling*>::const_iterator it = CGI->state->players[ci->town->tempOwner].dwellings.begin();
|
||||
it !=CGI->state->players[ci->town->tempOwner].dwellings.end(); ++it)
|
||||
if (CGI->creh->creatures[crid].idNumber == (*it)->creatures[0].second[0])
|
||||
if (CGI->creh->creatures[ci->town->town->basicCreatures[level]].idNumber == (*it)->creatures[0].second[0])
|
||||
cnt++;//external dwellings count to summ
|
||||
summ+=AddToString(CGI->generaltexth->allTexts[591],descr,cnt);
|
||||
|
||||
|
@ -79,7 +79,7 @@ CKingdomInterface::CKingdomInterface()
|
||||
boost::bind(&CKingdomInterface::close,this),748,99+size*116,"OVBUTN1.DEF", SDLK_RETURN);
|
||||
exit->bitmapOffset = 3;
|
||||
|
||||
statusbar = new CStatusBar(pos.x+7,pos.y+91+size*116,"TSTATBAR.bmp",732);
|
||||
statusbar = new CStatusBar(7, 91+size*116,"TSTATBAR.bmp",732);
|
||||
resdatabar = new CResDataBar("KRESBAR.bmp",pos.x+3,pos.y+111+size*116,32,2,76,76);
|
||||
|
||||
for(size_t i=0;i<size;i++)//creating empty hero/town lists for input
|
||||
@ -228,12 +228,12 @@ void CKingdomInterface::close()
|
||||
void CKingdomInterface::updateAllGarrisons()
|
||||
{
|
||||
for (int i = 0; i<towns.size(); i++)
|
||||
{tlog1<<"Have "<<towns.size()<<" town elements, recreating "<<i<<"\n";
|
||||
{
|
||||
if (towns[i] && towns[i]->garr)
|
||||
towns[i]->garr->recreateSlots();
|
||||
}
|
||||
for (int i = 0; i<heroes.size(); i++)
|
||||
{tlog1<<"Have "<<heroes.size()<<" hero elements, recreating "<<i<<"\n";
|
||||
{
|
||||
if (heroes[i] && heroes[i]->garr)
|
||||
heroes[i]->garr->recreateSlots();
|
||||
}
|
||||
|
@ -1132,8 +1132,8 @@ CStatusBar::CStatusBar(int x, int y, std::string name, int maxw)
|
||||
else
|
||||
pos.w=bg->w;
|
||||
pos.h=bg->h;
|
||||
middlex=(pos.w/2)+x;
|
||||
middley=(bg->h/2)+y;
|
||||
middlex=(pos.w/2)+pos.x;
|
||||
middley=(bg->h/2)+pos.y;
|
||||
}
|
||||
|
||||
CStatusBar::~CStatusBar()
|
||||
@ -1589,7 +1589,7 @@ void CTownList::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
hx-=pos.x;
|
||||
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
|
||||
int ny = hy/32;
|
||||
if ((ny>SIZE || ny<0) || (from+ny>=items.size()))
|
||||
if ((ny>=SIZE || ny<0) || (from+ny>=items.size()))
|
||||
{
|
||||
LOCPLINT->statusbar->clear();
|
||||
return;
|
||||
@ -1628,7 +1628,7 @@ void CTownList::clickLeft(tribool down, bool previousState)
|
||||
hx-=pos.x;
|
||||
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
|
||||
int ny = hy/32;
|
||||
if (ny>SIZE || ny<0)
|
||||
if (ny>=SIZE || ny<0)
|
||||
return;
|
||||
if(GH.topInt() == LOCPLINT->adventureInt
|
||||
&& (ny+from)==selected
|
||||
@ -1692,7 +1692,7 @@ void CTownList::clickRight(tribool down, bool previousState)
|
||||
hx-=pos.x;
|
||||
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
|
||||
int ny = hy/32;
|
||||
if ((ny>5 || ny<0) || (from+ny>=items.size()))
|
||||
if ((ny>=SIZE || ny<0) || (from+ny>=items.size()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -5065,4 +5065,4 @@ void MoraleLuckBox::set( bool morale, const CGHeroInstance *hero, int slot /*= -
|
||||
for(int it=0; it < mrl.size(); it++)
|
||||
text += "\n" + mrl[it].second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ public:
|
||||
int dailyIncome() const; //calculates daily income of this town
|
||||
int spellsAtLevel(int level, bool checkGuild) const; //levels are counted from 1 (1 - 5)
|
||||
void removeCapitols (ui8 owner, bool me) const;
|
||||
int defenceBonus(int type) const;//bonuses for defending hero, 0..3 - primary skills, 4 = morale, 5 = luck
|
||||
int defenceBonus(int type) const;//primary skills bonuses for defending hero
|
||||
|
||||
CGTownInstance();
|
||||
virtual ~CGTownInstance();
|
||||
|
@ -1148,25 +1148,20 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
|
||||
return std::pair<int,int>(-1,-1);
|
||||
}
|
||||
|
||||
void convertHordes(CGTownInstance * town)//converting hordes from -36..-30 to 18 & 24
|
||||
void randomizeArmy(CArmedInstance * army, int type)
|
||||
{
|
||||
for (int i = 0; i<CREATURES_PER_TOWN; i++)
|
||||
if (vstd::contains(town->builtBuildings,(-31-i))) //if we have horde for this level
|
||||
int max = VLC->creh->creatures.size();
|
||||
for (std::map<si32,std::pair<ui32,si32> >::iterator j=army->army.slots.begin(); j!=army->army.slots.end();j++)
|
||||
{
|
||||
town->builtBuildings.erase(-31-i);//remove old ID
|
||||
if (town->town->hordeLvl[0] == i)//if town first horde is this one
|
||||
if(j->second.first > max)
|
||||
{
|
||||
town->builtBuildings.insert(18);//add it
|
||||
if (vstd::contains(town->builtBuildings,(37+i)))//if we have upgraded dwelling as well
|
||||
town->builtBuildings.insert(19);//add it as well
|
||||
}
|
||||
if (town->town->hordeLvl[1] == i)//if town second horde is this one
|
||||
{
|
||||
town->builtBuildings.insert(24);//add it
|
||||
if (vstd::contains(town->builtBuildings,(37+i)))//if we have upgraded dwelling as well
|
||||
town->builtBuildings.insert(25);//add it as well
|
||||
if(j->second.first % 2)
|
||||
j->second.first = VLC->townh->towns[type].basicCreatures[ (j->second.first-197) / 2 -1];
|
||||
else
|
||||
j->second.first = VLC->townh->towns[type].upgradedCreatures[ (j->second.first-197) / 2 -1];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void CGameState::randomizeObject(CGObjectInstance *cur)
|
||||
@ -1194,6 +1189,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
|
||||
cur->ID = ran.first;
|
||||
h->portrait = cur->subID = ran.second;
|
||||
h->type = VLC->heroh->heroes[ran.second];
|
||||
randomizeArmy(h, h->type->heroType/2);
|
||||
map->heroes.push_back(h);
|
||||
return; //TODO: maybe we should do something with definfo?
|
||||
}
|
||||
@ -1210,6 +1206,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
|
||||
t->defInfo = forts[t->subID];
|
||||
else
|
||||
t->defInfo = villages[t->subID];
|
||||
randomizeArmy(t, t->subID);
|
||||
map->towns.push_back(t);
|
||||
return;
|
||||
}
|
||||
@ -1561,8 +1558,24 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
|
||||
vti->builtBuildings.insert(30);
|
||||
if(ran()%2)
|
||||
vti->builtBuildings.insert(31);
|
||||
}
|
||||
convertHordes(vti);
|
||||
}//init hordes
|
||||
for (int i = 0; i<CREATURES_PER_TOWN; i++)
|
||||
if (vstd::contains(vti->builtBuildings,(-31-i))) //if we have horde for this level
|
||||
{
|
||||
vti->builtBuildings.erase(-31-i);//remove old ID
|
||||
if (vti->town->hordeLvl[0] == i)//if town first horde is this one
|
||||
{
|
||||
vti->builtBuildings.insert(18);//add it
|
||||
if (vstd::contains(vti->builtBuildings,(37+i)))//if we have upgraded dwelling as well
|
||||
vti->builtBuildings.insert(19);//add it as well
|
||||
}
|
||||
if (vti->town->hordeLvl[1] == i)//if town second horde is this one
|
||||
{
|
||||
vti->builtBuildings.insert(24);
|
||||
if (vstd::contains(vti->builtBuildings,(37+i)))
|
||||
vti->builtBuildings.insert(25);
|
||||
}
|
||||
}
|
||||
//init spells
|
||||
vti->spells.resize(SPELL_LEVELS);
|
||||
CSpell *s;
|
||||
@ -1594,18 +1607,6 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
|
||||
vti->spells[s->level-1].push_back(s->id);
|
||||
vti->possibleSpells -= s->id;
|
||||
}
|
||||
|
||||
//init garrisons
|
||||
for (std::map<si32,std::pair<ui32,si32> >::iterator j=vti->army.slots.begin(); j!=vti->army.slots.end();j++)
|
||||
{
|
||||
if(j->second.first > 196 && j->second.first < 211)
|
||||
{
|
||||
if(j->second.first%2)
|
||||
j->second.first = vti->town->basicCreatures[ (j->second.first-197) / 2 ];
|
||||
else
|
||||
j->second.first = vti->town->upgradedCreatures[ (j->second.first-197) / 2 ];
|
||||
}
|
||||
}
|
||||
if(vti->getOwner() != 255)
|
||||
getPlayer(vti->getOwner())->towns.push_back(vti);
|
||||
}
|
||||
@ -3715,4 +3716,4 @@ InfoAboutHero & InfoAboutHero::operator=( const InfoAboutHero & iah )
|
||||
{
|
||||
assign(iah);
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
12
lib/map.cpp
12
lib/map.cpp
@ -149,10 +149,10 @@ static CCreatureSet readCreatureSet(const unsigned char * bufor, int &i, int num
|
||||
std::pair<ui32,si32> ins;
|
||||
for(int ir=0;ir<number;ir++)
|
||||
{
|
||||
int rettt = readNormalNr(bufor,i+ir*4, 2);
|
||||
int rettt = readNormalNr(bufor,i+ir*4, 2);tlog1<<"Creature has ID "<<rettt<<"\n";
|
||||
if(rettt==0xffff) continue;
|
||||
if(rettt>32768)
|
||||
rettt = 65536-rettt+VLC->creh->creatures.size()-16;
|
||||
if(rettt>65520)
|
||||
rettt = 65536-rettt+VLC->creh->creatures.size();//this will happens when random object has random army
|
||||
ins.first = rettt;
|
||||
ins.second = readNormalNr(bufor,i+ir*4+2, 2);
|
||||
std::pair<si32,std::pair<ui32,si32> > tt(ir,ins);
|
||||
@ -169,8 +169,8 @@ static CCreatureSet readCreatureSet(const unsigned char * bufor, int &i, int num
|
||||
{
|
||||
int rettt = readNormalNr(bufor,i+ir*3, 1);
|
||||
if(rettt==0xff) continue;
|
||||
if(rettt>220)
|
||||
rettt = 256-rettt+VLC->creh->creatures.size()-16;
|
||||
if(rettt>240)
|
||||
rettt = 256-rettt+VLC->creh->creatures.size();
|
||||
ins.first = rettt;
|
||||
ins.second = readNormalNr(bufor,i+ir*3+1, 2);
|
||||
std::pair<si32,std::pair<ui32,si32> > tt(ir,ins);
|
||||
@ -2153,4 +2153,4 @@ CVictoryCondition::CVictoryCondition()
|
||||
pos = int3(-1,-1,-1);
|
||||
obj = NULL;
|
||||
ID = allowNormalVictory = appliesToAI = count = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user