* resolved #62 and #66

This commit is contained in:
mateuszb
2008-08-02 10:26:56 +00:00
parent 7aeadd5a06
commit e1b4331ee2
8 changed files with 37 additions and 21 deletions
+2 -1
View File
@@ -847,7 +847,8 @@ bool CCallback::battleCanShoot(int ID, int dest) //TODO: finish
{ {
if(battleGetStackByID(ID).creature->isShooting() if(battleGetStackByID(ID).creature->isShooting()
&& battleGetStack(dest) != -1 && battleGetStack(dest) != -1
&& battleGetStackByPos(dest).owner != battleGetStackByID(ID).owner) && battleGetStackByPos(dest).owner != battleGetStackByID(ID).owner
&& battleGetStackByPos(dest).alive)
return true; return true;
return false; return false;
} }
+1 -1
View File
@@ -509,7 +509,7 @@ bool CGameState::battleShootCreatureStack(int ID, int dest)
} }
} }
if(IDOfStackAtEnd == -1 || curB->stacks[numberOfStackAtEnd]->owner == curStack->owner) if(IDOfStackAtEnd == -1 || curB->stacks[numberOfStackAtEnd]->owner == curStack->owner || !curB->stacks[numberOfStackAtEnd]->alive)
return false; return false;
LOCPLINT->battleStackIsShooting(ID, dest); LOCPLINT->battleStackIsShooting(ID, dest);
+5 -5
View File
@@ -731,7 +731,7 @@ void CHeroWindow::redrawCurBack()
blitAt(skillpics->ourImages[4].bitmap, 20, 230, curBack); blitAt(skillpics->ourImages[4].bitmap, 20, 230, curBack);
blitAt(skillpics->ourImages[3].bitmap, 162, 230, curBack); blitAt(skillpics->ourImages[3].bitmap, 162, 230, curBack);
blitAt(curHero->type->portraitLarge, 19, 19, curBack); blitAt(CGI->heroh->largePortraits[curHero->portrait], 19, 19, curBack);
CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack); CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack);
@@ -796,14 +796,14 @@ void CHeroWindow::redrawCurBack()
for(int g=0; g<LOCPLINT->cb->howManyHeroes(); ++g) for(int g=0; g<LOCPLINT->cb->howManyHeroes(); ++g)
{ {
const CGHeroInstance * cur = LOCPLINT->cb->getHeroInfo(player, g, false); const CGHeroInstance * cur = LOCPLINT->cb->getHeroInfo(player, g, false);
blitAt(cur->type->portraitSmall, 611, 87+g*54, curBack); blitAt(CGI->heroh->smallPortraits[cur->portrait], 611, 87+g*54, curBack);
//printing yellow border //printing yellow border
if(cur->name == curHero->name) if(cur->name == curHero->name)
{ {
for(int f=0; f<cur->type->portraitSmall->w; ++f) for(int f=0; f<CGI->heroh->smallPortraits[cur->portrait]->w; ++f)
{ {
for(int h=0; h<cur->type->portraitSmall->h; ++h) for(int h=0; h<CGI->heroh->smallPortraits[cur->portrait]->h; ++h)
if(f==0 || h==0 || f==cur->type->portraitSmall->w-1 || h==cur->type->portraitSmall->h-1) if(f==0 || h==0 || f==CGI->heroh->smallPortraits[cur->portrait]->w-1 || h==CGI->heroh->smallPortraits[cur->portrait]->h-1)
{ {
CSDL_Ext::SDL_PutPixel(curBack, 611+f, 87+g*54+h, 240, 220, 120); CSDL_Ext::SDL_PutPixel(curBack, 611+f, 87+g*54+h, 240, 220, 120);
} }
+2 -2
View File
@@ -1586,7 +1586,7 @@ SDL_Surface * CPlayerInterface::drawHeroInfoWin(const CGHeroInstance * curh)
SDL_itoa((*i).second.second,buf,10); SDL_itoa((*i).second.second,buf,10);
printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret); printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret);
} }
blitAt(curh->type->portraitLarge,11,12,ret); blitAt(CGI->heroh->largePortraits[curh->portrait],11,12,ret);
SDL_itoa(curh->mana,buf,10); SDL_itoa(curh->mana,buf,10);
printAtMiddle(buf,166,109,GEORM,zwykly,ret); //mana points printAtMiddle(buf,166,109,GEORM,zwykly,ret); //mana points
delete[] buf; delete[] buf;
@@ -2435,7 +2435,7 @@ void CHeroList::draw()
if (pom>25) pom=25; if (pom>25) pom=25;
if (pom<0) pom=0; if (pom<0) pom=0;
blitAt(mana->ourImages[pom].bitmap,posmanx,posmany+i*32); //mana blitAt(mana->ourImages[pom].bitmap,posmanx,posmany+i*32); //mana
SDL_Surface * temp = LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->type->portraitSmall; SDL_Surface * temp = CGI->heroh->smallPortraits[LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->portrait];
blitAt(temp,posporx,pospory+i*32); blitAt(temp,posporx,pospory+i*32);
if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == HEROI_TYPE)) if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == HEROI_TYPE))
{ {
+2 -2
View File
@@ -556,7 +556,7 @@ void Options::showIcon (int what, int nr, bool abs) //what: -1=castle, 0=hero, 1
{ {
if(ourOpt->heroPortrait>=0) if(ourOpt->heroPortrait>=0)
{ {
blitAtWR(CGI->heroh->heroes[ourOpt->heroPortrait]->portraitSmall,252,130+50*se); blitAtWR(CGI->heroh->smallPortraits[ourOpt->heroPortrait],252,130+50*se);
} }
else else
{ {
@@ -565,7 +565,7 @@ void Options::showIcon (int what, int nr, bool abs) //what: -1=castle, 0=hero, 1
} }
else else
{ {
blitAtWR(CGI->heroh->heroes[pom]->portraitSmall,252,130+50*se); blitAtWR(CGI->heroh->smallPortraits[pom],252,130+50*se);
} }
break; break;
} }
+8
View File
@@ -1,3 +1,4 @@
163
0 HPS000KN.bmp 0 HPS000KN.bmp
1 HPS001KN.bmp 1 HPS001KN.bmp
2 HPS002KN.bmp 2 HPS002KN.bmp
@@ -154,3 +155,10 @@
153 HPS008SH.bmp 153 HPS008SH.bmp
154 HPS001SH.bmp 154 HPS001SH.bmp
155 HPS131DM.bmp 155 HPS131DM.bmp
156 HPS129MK.bmp
157 HPS002SH.bmp
158 HPS132Wl.bmp
159 HPS133Nc.bmp
160 HPS134Nc.bmp
161 HPS135Wi.bmp
162 HPS136Wi.bmp
+16 -8
View File
@@ -14,22 +14,30 @@ CHeroHandler::~CHeroHandler()
{ {
for (int j=0;j<heroes.size();j++) for (int j=0;j<heroes.size();j++)
{ {
if (heroes[j]->portraitSmall)
SDL_FreeSurface(heroes[j]->portraitSmall);
delete heroes[j]; delete heroes[j];
} }
for(std::map<int, SDL_Surface*>::iterator it = smallPortraits.begin(); it!=smallPortraits.end(); ++it)
{
delete it->second;
}
for(std::map<int, SDL_Surface*>::iterator it = largePortraits.begin(); it!=largePortraits.end(); ++it)
{
delete it->second;
}
} }
void CHeroHandler::loadPortraits() void CHeroHandler::loadPortraits()
{ {
std::ifstream of("config/portrety.txt"); std::ifstream of("config/portrety.txt");
for (int j=0;j<heroes.size();j++) int numberOfPortraits;
of>>numberOfPortraits;
for (int j=0; j<numberOfPortraits; j++)
{ {
int ID; int ID;
of>>ID; of>>ID;
std::string path; std::string path;
of>>path; of>>path;
heroes[ID]->portraitSmall=CGI->bitmaph->loadBitmap(path); smallPortraits[ID] = CGI->bitmaph->loadBitmap(path);
if (!heroes[ID]->portraitSmall) if (!smallPortraits[ID])
std::cout<<"Can't read small portrait for "<<ID<<" ("<<path<<")\n"; std::cout<<"Can't read small portrait for "<<ID<<" ("<<path<<")\n";
for(int ff=0; ff<path.size(); ++ff) //size letter is usually third one, but there are exceptions an it should fix the problem for(int ff=0; ff<path.size(); ++ff) //size letter is usually third one, but there are exceptions an it should fix the problem
{ {
@@ -39,10 +47,10 @@ void CHeroHandler::loadPortraits()
break; break;
} }
} }
heroes[ID]->portraitLarge=CGI->bitmaph->loadBitmap(path); largePortraits[ID] = CGI->bitmaph->loadBitmap(path);
if (!heroes[ID]->portraitLarge) if (!largePortraits[ID])
std::cout<<"Can't read large portrait for "<<ID<<" ("<<path<<")\n"; std::cout<<"Can't read large portrait for "<<ID<<" ("<<path<<")\n";
SDL_SetColorKey(heroes[ID]->portraitLarge,SDL_SRCCOLORKEY,SDL_MapRGB(heroes[ID]->portraitLarge->format,0,255,255)); SDL_SetColorKey(largePortraits[ID],SDL_SRCCOLORKEY,SDL_MapRGB(largePortraits[ID]->format,0,255,255));
} }
of.close(); of.close();
+1 -2
View File
@@ -26,8 +26,6 @@ public:
CHeroClass * heroClass; CHeroClass * heroClass;
EHeroClasses heroType; //hero class EHeroClasses heroType; //hero class
//bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;} //bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
SDL_Surface * portraitSmall; //48x32 px
SDL_Surface * portraitLarge; //58x64 px
}; };
class CHeroClass class CHeroClass
@@ -50,6 +48,7 @@ public:
std::vector<CHero*> heroes; //by³o nodrze std::vector<CHero*> heroes; //by³o nodrze
std::vector<CHeroClass *> heroClasses; std::vector<CHeroClass *> heroClasses;
std::vector<CDefHandler *> flags1, flags2, flags3, flags4; //flags blitted on heroes when , std::vector<CDefHandler *> flags1, flags2, flags3, flags4; //flags blitted on heroes when ,
std::map<int, SDL_Surface *> smallPortraits, largePortraits; //there are more portraits than playable heroes! ; small - 48x32 px ; large - 58x64 px
CDefHandler * pskillsb, *resources; //82x93 CDefHandler * pskillsb, *resources; //82x93
CDefHandler * un44; //many things CDefHandler * un44; //many things
std::vector<std::string> pskillsn; std::vector<std::string> pskillsn;