mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- some fixes for town events
- #190 - InfoWindow components adjusted vertically - #194 - correct sex for heroes in battles
This commit is contained in:
parent
ea966a3d21
commit
dc2f3cf181
@ -1217,7 +1217,10 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
//loading hero animations
|
||||
if(hero1) // attacking hero
|
||||
{
|
||||
attackingHero = new CBattleHero(graphics->battleHeroes[hero1->type->heroType], 0, 0, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : NULL, this);
|
||||
int type = hero1->type->heroType;
|
||||
if ( type % 2 ) type--;
|
||||
if ( hero1->sex ) type++;
|
||||
attackingHero = new CBattleHero(graphics->battleHeroes[type], 0, 0, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : NULL, this);
|
||||
attackingHero->pos = genRect(attackingHero->dh->ourImages[0].bitmap->h, attackingHero->dh->ourImages[0].bitmap->w, -40 + pos.x, pos.y);
|
||||
}
|
||||
else
|
||||
@ -1226,7 +1229,10 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
}
|
||||
if(hero2) // defending hero
|
||||
{
|
||||
defendingHero = new CBattleHero(graphics->battleHeroes[hero2->type->heroType], 0, 0, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : NULL, this);
|
||||
int type = hero2->type->heroType;
|
||||
if ( type % 2 ) type--;
|
||||
if ( hero2->sex ) type++;
|
||||
defendingHero = new CBattleHero(graphics->battleHeroes[type ], 0, 0, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : NULL, this);
|
||||
defendingHero->pos = genRect(defendingHero->dh->ourImages[0].bitmap->h, defendingHero->dh->ourImages[0].bitmap->w, 690 + pos.x, pos.y);
|
||||
}
|
||||
else
|
||||
|
@ -422,10 +422,11 @@ void CHeroWindow::redrawCurBack()
|
||||
CSDL_Ext::printAtMiddle(curHero->name, 190, 38, FONT_BIG, tytulowy, curBack);
|
||||
|
||||
//printing hero's level
|
||||
std::ostringstream secondLine;
|
||||
secondLine<<"Level "<<curHero->level<<" "<<curHero->type->heroClass->name;
|
||||
CSDL_Ext::printAtMiddle(secondLine.str(), 190, 65, FONT_MEDIUM, zwykly, curBack);
|
||||
|
||||
std::string secondLine= CGI->generaltexth->allTexts[342];
|
||||
boost::algorithm::replace_first(secondLine,"%d",boost::lexical_cast<std::string>(curHero->level));
|
||||
boost::algorithm::replace_first(secondLine,"%s",curHero->type->heroClass->name);
|
||||
CSDL_Ext::printAtMiddle(secondLine, 190, 65, FONT_MEDIUM, zwykly, curBack);
|
||||
|
||||
//primary skills names
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[1], 52, 99, FONT_SMALL, tytulowy, curBack);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[2], 123, 99, FONT_SMALL, tytulowy, curBack);
|
||||
|
@ -592,39 +592,43 @@ ComponentsToBlit::ComponentsToBlit(std::vector<SComponent*> & SComps, int maxw,
|
||||
|
||||
void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh, SDL_Surface *ret )
|
||||
{
|
||||
for (size_t i=0;i<comps.size();i++)
|
||||
for (size_t i=0;i<comps.size();i++)//for each row
|
||||
{
|
||||
int totalw=0, maxh=0;
|
||||
for(size_t j=0;j<(comps)[i].size();j++)
|
||||
for(size_t j=0;j<(comps)[i].size();j++)//find max height & total width in this row
|
||||
{
|
||||
ComponentResolved *cur = (comps)[i][j];
|
||||
totalw += cur->comp->pos.w;
|
||||
amax(maxh,cur->comp->pos.h+BETWEEN_COMPS_ROWS);
|
||||
amax(maxh,cur->comp->getImg()->h);//subtitles height will added later
|
||||
}
|
||||
if(_or)
|
||||
{
|
||||
totalw += (inter*2+_or->w) * ((comps)[i].size() - 1);
|
||||
}
|
||||
else
|
||||
else//add space between comps in this row
|
||||
{
|
||||
totalw += (inter) * ((comps)[i].size() - 1);
|
||||
}
|
||||
|
||||
curh+=maxh/2;
|
||||
int compX, compY;
|
||||
|
||||
int curw = (ret->w/2)-(totalw/2);
|
||||
for(size_t j=0;j<(comps)[i].size();j++)
|
||||
{
|
||||
ComponentResolved *cur = (comps)[i][j];
|
||||
|
||||
//blit img
|
||||
int hlp = curh-(cur->comp->pos.h)/2;
|
||||
blitAt(cur->img, curw + (cur->comp->pos.w - cur->comp->getImg()->w)/2, hlp, ret);
|
||||
cur->comp->pos.x = curw;
|
||||
cur->comp->pos.y = hlp;
|
||||
compX = curw + ( cur->comp->pos.w - cur->comp->getImg()->w ) / 2;
|
||||
compY = curh - cur->comp->getImg()->h / 2;
|
||||
blitAt(cur->img, compX, compY, ret);
|
||||
cur->comp->pos.x = compX;
|
||||
cur->comp->pos.y = compY;
|
||||
|
||||
//blit subtitle
|
||||
hlp += cur->img->h + COMPONENT_TO_SUBTITLE;
|
||||
CMessage::blitTextOnSur(cur->txt, cur->txtFontHeight, hlp, ret, cur->comp->pos.x + cur->comp->pos.w/2 );
|
||||
compX += cur->comp->getImg()->w/2;
|
||||
compY = curh + maxh / 2 + COMPONENT_TO_SUBTITLE;
|
||||
CMessage::blitTextOnSur(cur->txt, cur->txtFontHeight, compY, ret, compX );
|
||||
|
||||
//if there is subsequent component blit "or"
|
||||
curw += cur->comp->pos.w;
|
||||
@ -639,6 +643,6 @@ void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh,
|
||||
curw+=inter;
|
||||
}
|
||||
}
|
||||
curh+=maxh/2;
|
||||
curh = compY+BETWEEN_COMPS_ROWS;
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,19 @@ CH00.DEF
|
||||
CH01.DEF
|
||||
CH02.DEF
|
||||
CH03.DEF
|
||||
CH04.DEF
|
||||
CH05.DEF
|
||||
CH04.DEF
|
||||
CH06.DEF
|
||||
CH07.DEF
|
||||
CH08.DEF
|
||||
CH09.DEF
|
||||
CH010.DEF
|
||||
CH11.DEF
|
||||
CH012.DEF
|
||||
CH013.DEF
|
||||
CH012.DEF
|
||||
CH014.DEF
|
||||
CH015.DEF
|
||||
CH16.DEF
|
||||
CH17.DEF
|
||||
CH17.DEF
|
||||
|
||||
hero animation used in battles, each 2 def represent male and female heroes for each race
|
@ -1,158 +1,158 @@
|
||||
//heroes'_inintial_set_of_secondary_abilities_format:_heroID_numberOfInitialSecSkills_(Skill_ID,_skill_lvl_for_every_spell)
|
||||
0 2 6 1 1 1
|
||||
1 2 6 1 1 1
|
||||
2 2 6 1 23 1
|
||||
3 2 6 1 5 1
|
||||
4 2 6 1 13 1
|
||||
5 2 6 1 22 1
|
||||
6 2 6 1 20 1
|
||||
7 2 6 1 19 1
|
||||
8 2 7 1 27 1
|
||||
9 2 7 1 4 1
|
||||
10 2 7 1 13 1
|
||||
11 1 7 2
|
||||
12 2 7 1 8 1
|
||||
13 2 7 1 11 1
|
||||
14 2 7 1 21 1
|
||||
15 2 7 1 24 1
|
||||
16 2 6 1 23 1
|
||||
17 2 9 1 26 1
|
||||
18 1 1 2
|
||||
19 2 4 1 6 1
|
||||
20 1 26 2
|
||||
21 2 1 1 22 1
|
||||
22 2 0 1 26 1
|
||||
23 2 1 1 2 1
|
||||
24 2 7 1 18 1
|
||||
25 2 7 2 10 1
|
||||
26 2 7 1 24 1
|
||||
27 2 7 1 27 1
|
||||
28 2 7 1 11 1
|
||||
29 2 7 1 9 1
|
||||
30 2 7 1 25 1
|
||||
31 2 7 1 3 1
|
||||
32 2 3 1 8 1
|
||||
33 1 18 2
|
||||
34 2 8 1 25 1
|
||||
35 2 18 1 23 1
|
||||
36 2 8 1 19 1
|
||||
37 2 18 1 26 1
|
||||
38 2 8 1 22 1
|
||||
39 2 18 1 24 1
|
||||
40 1 7 2
|
||||
41 2 7 1 8 1
|
||||
42 2 7 1 11 1
|
||||
43 2 7 1 24 1
|
||||
44 2 7 1 10 1
|
||||
45 2 7 1 25 1
|
||||
46 2 7 1 4 1
|
||||
47 2 7 1 18 1
|
||||
48 1 3 2
|
||||
49 2 7 1 18 1
|
||||
50 1 23 2
|
||||
51 2 19 1 26 1
|
||||
52 2 18 1 22 1
|
||||
53 2 1 1 3 1
|
||||
54 2 20 1 2 1
|
||||
55 1 22 2
|
||||
56 2 7 1 24 1
|
||||
57 2 7 1 18 1
|
||||
58 2 7 1 8 1
|
||||
59 2 7 1 10 1
|
||||
60 2 7 1 21 1
|
||||
61 2 7 1 11 1
|
||||
62 2 7 1 25 1
|
||||
63 2 7 1 6 1
|
||||
64 2 12 1 26 1
|
||||
65 2 12 1 20 1
|
||||
66 2 12 1 21 1
|
||||
67 2 12 1 19 1
|
||||
68 2 12 1 22 1
|
||||
69 1 12 2
|
||||
70 2 12 1 22 1
|
||||
71 2 12 1 23 1
|
||||
72 2 12 1 18 1
|
||||
73 2 12 1 7 1
|
||||
74 2 12 1 25 1
|
||||
75 2 12 1 11 1
|
||||
76 2 12 1 8 1
|
||||
77 2 12 1 21 1
|
||||
78 1 12 2
|
||||
79 2 12 1 24 1
|
||||
80 2 3 1 6 1
|
||||
81 2 20 1 22 1
|
||||
82 2 19 1 22 1
|
||||
83 2 6 1 26 1
|
||||
84 1 22 2
|
||||
85 2 2 1 19 1
|
||||
86 2 6 1 18 1
|
||||
87 2 19 1 22 1
|
||||
88 2 7 1 18 1
|
||||
89 2 7 1 8 1
|
||||
90 2 7 1 25 1
|
||||
91 1 7 2
|
||||
92 2 7 1 11 1
|
||||
93 2 7 1 3 2
|
||||
94 2 7 1 24 1
|
||||
95 2 7 1 21 1
|
||||
96 2 22 1 10 1
|
||||
97 2 22 1 20 1
|
||||
98 2 22 1 1 1
|
||||
99 2 22 1 3 1
|
||||
100 2 22 1 0 1
|
||||
101 2 22 1 26 1
|
||||
102 1 22 2
|
||||
103 2 22 1 19 1
|
||||
104 2 7 1 25 1
|
||||
105 2 7 1 6 1
|
||||
106 2 7 1 2 1
|
||||
107 2 7 1 19 1
|
||||
108 2 7 1 20 1
|
||||
109 2 7 1 22 1
|
||||
110 2 7 1 11 1
|
||||
111 2 7 1 26 1
|
||||
112 2 23 1 26 1
|
||||
113 2 23 1 6 1
|
||||
114 2 23 1 1 1
|
||||
115 1 23 2
|
||||
116 2 23 1 22 1
|
||||
117 2 23 1 0 1
|
||||
118 2 23 1 20 1
|
||||
119 2 23 1 3 1
|
||||
120 1 7 2
|
||||
121 2 7 1 8 1
|
||||
122 2 7 1 5 1
|
||||
123 2 7 1 27 1
|
||||
124 2 7 1 21 1
|
||||
125 2 7 1 25 1
|
||||
126 2 7 1 24 1
|
||||
127 2 7 1 11 1
|
||||
128 2 20 1 22 1
|
||||
129 2 13 1 19 1
|
||||
130 2 20 1 22 1
|
||||
131 1 19 2
|
||||
132 2 2 1 22 1
|
||||
133 2 13 1 19 1
|
||||
134 1 22 2
|
||||
135 2 19 1 21 1
|
||||
136 2 7 1 14 1
|
||||
137 2 7 1 15 1
|
||||
138 2 7 1 16 1
|
||||
139 2 7 1 17 1
|
||||
140 2 7 1 14 1
|
||||
141 2 7 1 15 1
|
||||
142 2 7 1 16 1
|
||||
143 2 7 1 17 1
|
||||
144 1 6 2
|
||||
145 2 7 1 14 3
|
||||
146 2 6 1 22 1
|
||||
147 1 7 2
|
||||
148 2 1 1 6 1
|
||||
149 1 22 2
|
||||
150 1 12 2
|
||||
151 2 13 1 19 1
|
||||
152 2 6 1 23 1
|
||||
153 2 13 1 19 1
|
||||
154 2 19 1 22 1
|
||||
155 2 6 1 19 1
|
||||
-1
|
||||
//heroes'_inintial_set_of_secondary_abilities_format:_heroID,_sex_numberOfInitialSecSkills_(Skill_ID,_skill_lvl_for_every_skill)
|
||||
0 0 2 6 1 1 1
|
||||
1 1 2 6 1 1 1
|
||||
2 0 2 6 1 23 1
|
||||
3 1 2 6 1 5 1
|
||||
4 0 2 6 1 13 1
|
||||
5 1 2 6 1 22 1
|
||||
6 0 2 6 1 20 1
|
||||
7 1 2 6 1 19 1
|
||||
8 0 2 7 1 27 1
|
||||
9 1 2 7 1 4 1
|
||||
10 0 2 7 1 13 1
|
||||
11 1 1 7 2
|
||||
12 0 2 7 1 8 1
|
||||
13 1 2 7 1 11 1
|
||||
14 0 2 7 1 21 1
|
||||
15 1 2 7 1 24 1
|
||||
16 1 2 6 1 23 1
|
||||
17 0 2 9 1 26 1
|
||||
18 1 1 1 2
|
||||
19 0 2 4 1 6 1
|
||||
20 0 1 26 2
|
||||
21 0 2 1 1 22 1
|
||||
22 0 2 0 1 26 1
|
||||
23 1 2 1 1 2 1
|
||||
24 0 2 7 1 18 1
|
||||
25 0 2 7 2 10 1
|
||||
26 0 2 7 1 24 1
|
||||
27 1 2 7 1 27 1
|
||||
28 0 2 7 1 11 1
|
||||
29 1 2 7 1 9 1
|
||||
30 0 2 7 1 25 1
|
||||
31 0 2 7 1 3 1
|
||||
32 0 2 3 1 8 1
|
||||
33 0 1 18 2
|
||||
34 1 2 8 1 25 1
|
||||
35 1 2 18 1 23 1
|
||||
36 0 2 8 1 19 1
|
||||
37 0 2 18 1 26 1
|
||||
38 1 2 8 1 22 1
|
||||
39 1 2 18 1 24 1
|
||||
40 0 1 7 2
|
||||
41 0 2 7 1 8 1
|
||||
42 1 2 7 1 11 1
|
||||
43 1 2 7 1 24 1
|
||||
44 0 2 7 1 10 1
|
||||
45 0 2 7 1 25 1
|
||||
46 1 2 7 1 4 1
|
||||
47 1 2 7 1 18 1
|
||||
48 1 1 3 2
|
||||
49 0 2 7 1 18 1
|
||||
50 1 1 23 2
|
||||
51 0 2 19 1 26 1
|
||||
52 1 2 18 1 22 1
|
||||
53 0 2 1 1 3 1
|
||||
54 1 2 20 1 2 1
|
||||
55 1 1 22 2
|
||||
56 0 2 7 1 24 1
|
||||
57 0 2 7 1 18 1
|
||||
58 0 2 7 1 8 1
|
||||
59 1 2 7 1 10 1
|
||||
60 0 2 7 1 21 1
|
||||
61 1 2 7 1 11 1
|
||||
62 0 2 7 1 25 1
|
||||
63 0 2 7 1 6 1
|
||||
64 0 2 12 1 26 1
|
||||
65 0 2 12 1 20 1
|
||||
66 0 2 12 1 21 1
|
||||
67 1 2 12 1 19 1
|
||||
68 1 2 12 1 22 1
|
||||
69 1 1 12 2
|
||||
70 0 2 12 1 22 1
|
||||
71 0 2 12 1 23 1
|
||||
72 1 2 12 1 18 1
|
||||
73 1 2 12 1 7 1
|
||||
74 0 2 12 1 25 1
|
||||
75 0 2 12 1 11 1
|
||||
76 0 2 12 1 8 1
|
||||
77 1 2 12 1 21 1
|
||||
78 1 1 12 2
|
||||
79 0 2 12 1 24 1
|
||||
80 1 2 3 1 6 1
|
||||
81 0 2 20 1 22 1
|
||||
82 0 2 19 1 22 1
|
||||
83 0 2 6 1 26 1
|
||||
84 0 1 22 2
|
||||
85 0 2 2 1 19 1
|
||||
86 1 2 6 1 18 1
|
||||
87 0 2 19 1 22 1
|
||||
88 0 2 7 1 18 1
|
||||
89 0 2 7 1 8 1
|
||||
90 0 2 7 1 25 1
|
||||
91 1 1 7 2
|
||||
92 0 2 7 1 11 1
|
||||
93 0 2 7 1 3 2
|
||||
94 1 2 7 1 24 1
|
||||
95 0 2 7 1 21 1
|
||||
96 0 2 22 1 10 1
|
||||
97 0 2 22 1 20 1
|
||||
98 0 2 22 1 1 1
|
||||
99 1 2 22 1 3 1
|
||||
100 1 2 22 1 0 1
|
||||
101 0 2 22 1 26 1
|
||||
102 0 1 22 2
|
||||
103 0 2 22 1 19 1
|
||||
104 1 2 7 1 25 1
|
||||
105 0 2 7 1 6 1
|
||||
106 1 2 7 1 2 1
|
||||
107 0 2 7 1 19 1
|
||||
108 0 2 7 1 20 1
|
||||
109 1 2 7 1 22 1
|
||||
110 1 2 7 1 11 1
|
||||
111 0 2 7 1 26 1
|
||||
112 0 2 23 1 26 1
|
||||
113 0 2 23 1 6 1
|
||||
114 0 2 23 1 1 1
|
||||
115 0 1 23 2
|
||||
116 0 2 23 1 22 1
|
||||
117 0 2 23 1 0 1
|
||||
118 0 2 23 1 20 1
|
||||
119 0 2 23 1 3 1
|
||||
120 1 1 7 2
|
||||
121 1 2 7 1 8 1
|
||||
122 1 2 7 1 5 1
|
||||
123 1 2 7 1 27 1
|
||||
124 1 2 7 1 21 1
|
||||
125 1 2 7 1 25 1
|
||||
126 1 2 7 1 24 1
|
||||
127 1 2 7 1 11 1
|
||||
128 1 2 20 1 22 1
|
||||
129 1 2 13 1 19 1
|
||||
130 1 2 20 1 22 1
|
||||
131 1 1 19 2
|
||||
132 0 2 2 1 22 1
|
||||
133 0 2 13 1 19 1
|
||||
134 0 1 22 2
|
||||
135 0 2 19 1 21 1
|
||||
136 1 2 7 1 14 1
|
||||
137 1 2 7 1 15 1
|
||||
138 1 2 7 1 16 1
|
||||
139 1 2 7 1 17 1
|
||||
140 0 2 7 1 14 1
|
||||
141 0 2 7 1 15 1
|
||||
142 0 2 7 1 16 1
|
||||
143 0 2 7 1 17 1
|
||||
144 0 1 6 2
|
||||
145 1 2 7 1 14 3
|
||||
146 1 2 6 1 22 1
|
||||
147 0 1 7 2
|
||||
148 0 2 1 1 6 1
|
||||
149 0 1 22 2
|
||||
150 0 1 12 2
|
||||
151 1 2 13 1 19 1
|
||||
152 0 2 6 1 23 1
|
||||
153 1 2 13 1 19 1
|
||||
154 0 2 19 1 22 1
|
||||
155 0 2 6 1 19 1
|
||||
-1
|
||||
|
@ -304,6 +304,8 @@ void CHeroHandler::loadHeroes()
|
||||
if(hid == -1)
|
||||
break;
|
||||
inp>>secQ;
|
||||
heroes[hid]->sex = secQ;
|
||||
inp>>secQ;
|
||||
for(int g=0; g<secQ; ++g)
|
||||
{
|
||||
int a, b;
|
||||
@ -356,6 +358,7 @@ void CHeroHandler::loadHeroes()
|
||||
int i = expPerLevel.size() - 1;
|
||||
expPerLevel.push_back (expPerLevel[i] + (expPerLevel[i] - expPerLevel[i-1]) * 1.2);
|
||||
}
|
||||
expPerLevel.pop_back();//last value is broken
|
||||
|
||||
//ballistics info
|
||||
buf = bitmaph->getTextFile("BALLIST.TXT");
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
std::vector<std::pair<ui8,ui8> > secSkillsInit; //initial secondary skills; first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert)
|
||||
std::vector<SSpecialtyInfo> spec;
|
||||
si32 startingSpell; //-1 if none
|
||||
ui8 sex; // default sex: 0=male, 1=female
|
||||
//bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
|
||||
|
||||
CHero();
|
||||
|
@ -842,6 +842,9 @@ void CGHeroInstance::initHero()
|
||||
level = VLC->heroh->level(exp);
|
||||
}
|
||||
|
||||
if (sex == 0xFF)//sex is default
|
||||
sex = type->sex;
|
||||
|
||||
setFormation(false);
|
||||
if (!stacksCount()) //standard army//initial army
|
||||
{
|
||||
|
@ -1732,6 +1732,17 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
vti->builtBuildings.insert(25);
|
||||
}
|
||||
}
|
||||
|
||||
for (std::list<CCastleEvent*>::iterator ev=vti->events.begin(); ev!=vti->events.end(); ev++)
|
||||
for (int i = 0; i<CREATURES_PER_TOWN; i++)
|
||||
if (vstd::contains((*ev)->buildings,(-31-i))) //if we have horde for this level
|
||||
{
|
||||
(*ev)->buildings.erase(-31-i);
|
||||
if (vti->town->hordeLvl[0] == i)
|
||||
(*ev)->buildings.insert(18);
|
||||
if (vti->town->hordeLvl[1] == i)
|
||||
(*ev)->buildings.insert(24);
|
||||
}
|
||||
//init spells
|
||||
vti->spells.resize(SPELL_LEVELS);
|
||||
CSpell *s;
|
||||
|
@ -905,8 +905,13 @@ void Mapa::loadHero( CGObjectInstance * &nobj, const unsigned char * bufor, int
|
||||
{
|
||||
if(readChar(bufor,i))//true if hero has nonstandard (mapmaker defined) biography
|
||||
nhi->biography = readString(bufor,i);
|
||||
nhi->sex = !(bufor[i]); ++i;
|
||||
nhi->sex = bufor[i]; ++i;
|
||||
|
||||
if (nhi->sex != 0xFF)//remove trash
|
||||
nhi->sex &=1;
|
||||
}
|
||||
else
|
||||
nhi->sex = 0xFF;
|
||||
//spells
|
||||
if(version>AB)
|
||||
{
|
||||
|
@ -1123,6 +1123,9 @@ void CGameHandler::newTurn()
|
||||
}
|
||||
//n.res.push_back(r);
|
||||
}
|
||||
// townID, creatureID, amount
|
||||
std::map<si32, std::map<si32, si32> > newCreas;//creatures that needs to be added by town events
|
||||
|
||||
for(std::vector<CGTownInstance *>::iterator j = gs->map->towns.begin(); j!=gs->map->towns.end(); j++)//handle towns
|
||||
{
|
||||
ui8 player = (*j)->tempOwner;
|
||||
@ -1152,7 +1155,7 @@ void CGameHandler::newTurn()
|
||||
}
|
||||
n.res[player][6] += (**j).dailyIncome();
|
||||
}
|
||||
handleTownEvents(*j, n);
|
||||
handleTownEvents(*j, n, newCreas);
|
||||
if (vstd::contains((**j).builtBuildings, 26))
|
||||
{
|
||||
switch ((**j).subID)
|
||||
@ -1215,6 +1218,11 @@ void CGameHandler::newTurn()
|
||||
amin(sac.creatures[k].first, VLC->creh->creatures[(*j)->town->basicCreatures[k]]->growth);
|
||||
}
|
||||
}
|
||||
//creatures from town events
|
||||
if (vstd::contains(newCreas, (**j).id))
|
||||
for(std::map<si32, si32>::iterator i=newCreas[(**j).id].begin() ; i!=newCreas[(**j).id].end(); i++)
|
||||
sac.creatures[i->first].first += i->second;
|
||||
|
||||
n2.cres.push_back(sac);
|
||||
}
|
||||
if (gs->getDate(0) > 1)
|
||||
@ -2783,7 +2791,7 @@ bool CGameHandler::buildStructure( si32 tid, si32 bid, bool force /*=false*/ )
|
||||
}
|
||||
|
||||
ns.bid.insert(bid);
|
||||
ns.builded = t->builded + 1;
|
||||
ns.builded = force?t->builded:(t->builded+1);
|
||||
sendAndApply(&ns);
|
||||
|
||||
//reveal ground for lookout tower
|
||||
@ -4488,7 +4496,7 @@ void CGameHandler::handleTimeEvents()
|
||||
}
|
||||
}
|
||||
|
||||
void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
||||
void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n, std::map<si32, std::map<si32, si32> > &newCreas)
|
||||
{
|
||||
town->events.sort(evntCmp);
|
||||
while(town->events.size() && town->events.front()->firstOccurence == gs->day)
|
||||
@ -4525,28 +4533,15 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
||||
iw.components.push_back(Component(Component::BUILDING, town->subID, *i, 0));
|
||||
}
|
||||
|
||||
SetAvailableCreatures sac;
|
||||
if (n.cres.empty() || n.cres.back().tid != town->id)
|
||||
{
|
||||
sac.tid = town->id;
|
||||
sac.creatures = town->creatures;
|
||||
}
|
||||
else
|
||||
{
|
||||
sac = n.cres.back();
|
||||
n.cres.pop_back();
|
||||
}
|
||||
|
||||
for(int i=0;i<ev->creatures.size();i++) //creature growths
|
||||
for(si32 i=0;i<ev->creatures.size();i++) //creature growths
|
||||
{
|
||||
if(town->creatureDwelling(i) && ev->creatures[i])//there is dwelling
|
||||
{
|
||||
sac.creatures[i].first += ev->creatures[i];
|
||||
newCreas[town->id][i] += ev->creatures[i];
|
||||
iw.components.push_back(Component(Component::CREATURE,
|
||||
town->creatures[i].second.back(), ev->creatures[i], 0));
|
||||
}
|
||||
}
|
||||
n.cres.push_back(sac);
|
||||
sendAndApply(&iw); //show dialog
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "../global.h"
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include "../client/FunctionList.h"
|
||||
#include "../lib/CGameState.h"
|
||||
#include "../lib/Connection.h"
|
||||
@ -194,7 +195,7 @@ public:
|
||||
void save(const std::string &fname);
|
||||
void close();
|
||||
void handleTimeEvents();
|
||||
void handleTownEvents(CGTownInstance *town, NewTurn &n);
|
||||
void handleTownEvents(CGTownInstance *town, NewTurn &n, std::map<si32, std::map<si32, si32> > &newCreas);
|
||||
bool complain(const std::string &problem); //sends message to all clients, prints on the logs and return true
|
||||
void objectVisited( const CGObjectInstance * obj, const CGHeroInstance * h );
|
||||
void engageIntoBattle( ui8 player );
|
||||
|
Loading…
Reference in New Issue
Block a user