diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index a584026b0..db883d978 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -1947,7 +1947,6 @@ void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, int pskill, std: showingDialog->cond.wait(un); } boost::unique_lock un(*pim); - LOCPLINT->showingDialog->setn(true); CLevelWindow *lw = new CLevelWindow(hero,pskill,skills,callback); curint->deactivate(); lw->activate(); @@ -2101,6 +2100,7 @@ void CPlayerInterface::actionStarted(const BattleAction* action) battleInt->defendingHero->setPhase(4); else battleInt->attackingHero->setPhase(4); + return; } if(!stack) { @@ -3582,18 +3582,17 @@ void CLevelWindow::close() } delete this; LOCPLINT->curint->activate(); + LOCPLINT->showingDialog->setn(false); } CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector &skills, boost::function &callback) { + LOCPLINT->showingDialog->setn(true); heroType = hero->subID; cb = callback; for(int i=0;igetSecSkillLevel(skills[i])+1,boost::bind(&CLevelWindow::selectionChanged,this,i))); - if(comps.size()) { - comps[0]->assignedKeys.insert(SDLK_1); - if(comps.size() > 1) - comps[1]->assignedKeys.insert(SDLK_2); + comps.push_back(new CSelectableComponent(SComponent::secskill44,skills[i],hero->getSecSkillLevel(skills[i])+1,boost::bind(&CLevelWindow::selectionChanged,this,i))); + comps.back()->assignedKeys.insert(SDLK_1 + i); } bitmap = BitmapHandler::loadBitmap("LVLUPBKG.bmp"); graphics->blueToPlayersAdv(bitmap,hero->tempOwner); @@ -3603,7 +3602,6 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vectorw; pos.h = bitmap->h; ok = new AdventureMapButton("","",boost::bind(&CLevelWindow::close,this),pos.x+297,pos.y+413,"IOKAY.DEF",SDLK_RETURN); - ok->block(true); //draw window char buf[100], buf2[100]; strcpy(buf2,CGI->generaltexth->allTexts[444].c_str()); //%s has gained a level. @@ -3631,6 +3629,16 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vectorw + 18; } } + + if(comps.size() > 1) + { + ok->block(true); + } + else if(comps.size() == 1) + { + comps[0]->select(true); + } + SDL_FreeSurface(ort); } diff --git a/README b/README index e69de29bb..4d15f1f30 100644 --- a/README +++ b/README @@ -0,0 +1,16 @@ + VCMI Project + Copyright (C) 2007-2009 VCMI Team (check AUTHORS file for the contributors list) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 (included in the license.txt) + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. \ No newline at end of file diff --git a/client/CBitmapHandler.cpp b/client/CBitmapHandler.cpp index b6f529ac1..af4f2fb9b 100644 --- a/client/CBitmapHandler.cpp +++ b/client/CBitmapHandler.cpp @@ -167,7 +167,7 @@ SDL_Surface * CPCXConv::getSurface() { SDL_Surface * ret; - BMPHeader bh; + int width = -1, height = -1; Epcxformat format; int fSize,y;//,i; //TODO use me 'i' bool check1, check2; @@ -175,13 +175,13 @@ SDL_Surface * CPCXConv::getSurface() int it=0; fSize = readNormalNr(it,4,pcx);it+=4; - bh.x = readNormalNr(it,4,pcx);it+=4; - bh.y = readNormalNr(it,4,pcx);it+=4; - if (fSize==bh.x*bh.y*3) + width = readNormalNr(it,4,pcx);it+=4; + height = readNormalNr(it,4,pcx);it+=4; + if (fSize==width*height*3) check1=true; else check1=false; - if (fSize==bh.x*bh.y) + if (fSize==width*height) check2=true; else check2=false; @@ -191,12 +191,12 @@ SDL_Surface * CPCXConv::getSurface() format=PCX8B; else return NULL; - add = 4 - bh.x%4; + add = 4 - width%4; if (add==4) add=0; if (format==PCX8B) { - ret = SDL_CreateRGBSurface(SDL_SWSURFACE, bh.x+add, bh.y, 8, 0, 0, 0, 0); + ret = SDL_CreateRGBSurface(SDL_SWSURFACE, width+add, height, 8, 0, 0, 0, 0); } else { @@ -209,7 +209,7 @@ SDL_Surface * CPCXConv::getSurface() int gmask = 0x00ff00; int rmask = 0xff0000; #endif - ret = SDL_CreateRGBSurface(SDL_SWSURFACE, bh.x+add, bh.y, 24, rmask, gmask, bmask, 0); + ret = SDL_CreateRGBSurface(SDL_SWSURFACE, width+add, height, 24, rmask, gmask, bmask, 0); } if (format==PCX8B) { @@ -229,10 +229,10 @@ SDL_Surface * CPCXConv::getSurface() tp.unused = 0; *(ret->format->palette->colors+i) = tp; } - for (y=bh.y;y>0;y--) + for (y=height;y>0;y--) { - it=0xC+(y-1)*bh.x; - for (int j=0;jpixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * j) = pcx[it+j]; } @@ -240,17 +240,17 @@ SDL_Surface * CPCXConv::getSurface() { for (int j=0;jpixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * (j+bh.x)) = 0; + *((char*)ret->pixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * (j+width)) = 0; } } } } else { - for (y=bh.y; y>0; y--) + for (y=height; y>0; y--) { - it=0xC+(y-1)*bh.x*3; - for (int j=0;jpixels + ret->pitch * (y-1) + j) = pcx[it+j]; } @@ -258,7 +258,7 @@ SDL_Surface * CPCXConv::getSurface() { for (int j=0;jpixels + ret->pitch * (y-1) + (j+bh.x*3)) = 0; + *((char*)ret->pixels + ret->pitch * (y-1) + (j+width*3)) = 0; } } } @@ -269,7 +269,10 @@ SDL_Surface * CPCXConv::getSurface() SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey) { if(!fname.size()) + { + tlog2 << "Call to loadBitmap with void fname!\n"; return NULL; + } unsigned char * pcx; std::transform(fname.begin(),fname.end(),fname.begin(),toupper); fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX"); @@ -295,7 +298,10 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey) fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX"); f = fopen(fname.c_str(),"r"); if(!f) + { + tlog1 << "Cannot open " << fname << " - not present as bmp nor as pcx.\n"; return NULL; + } fread(sign,1,3,f); if(sign[0]=='B' && sign[1]=='M') //BMP named as PCX - people (eg. Kulex) sometimes use such files { @@ -338,7 +344,7 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey) int res=bitmaph->infs2(pcd,e->size,e->realSize,pcx); if(res!=0) { - tlog2<<"an error "<spells; //XXX for testing only - //mySpells = myHero->spells; - for(ui32 v=0; vspellh->spells.size(); ++v) - { - if(!CGI->spellh->spells[v].creatureAbility) - mySpells.insert(v); - } + //for(ui32 v=0; vspellh->spells.size(); ++v) + //{ + // if(!CGI->spellh->spells[v].creatureAbility) + // mySpells.insert(v); + //} for(int b=0; b<4; ++b) schoolLvls[b] = 0; for(size_t b=0; bsecSkills.size(); ++b) diff --git a/readme.txt b/readme.txt deleted file mode 100644 index 15fd11bc3..000000000 --- a/readme.txt +++ /dev/null @@ -1,15 +0,0 @@ - Copyright (C) 2007-2009 VCMI Team - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. \ No newline at end of file diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 53639867e..57af6caab 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -241,16 +241,18 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs) expert.insert(hero->secSkills[i].first); none.erase(hero->secSkills[i].first); } + //first offered skill if(hero->secSkills.size() < hero->type->heroClass->skillLimit) //free skill slot { hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //new skill } - else + else if(basicAndAdv.size()) { int s = hero->type->heroClass->chooseSecSkill(basicAndAdv); hlu.skills.push_back(s); basicAndAdv.erase(s); } + //second offered skill if(basicAndAdv.size()) { hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(basicAndAdv)); //new skill @@ -259,8 +261,21 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs) { hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //new skill } - boost::function callback = boost::function(boost::bind(callWith,hlu.skills,boost::function(boost::bind(&CGameHandler::changeSecSkill,this,ID,_1,1,0)),_1)); - applyAndAsk(&hlu,hero->tempOwner,callback); //call changeSecSkill with appropriate args when client responds + + if(hlu.skills.size() > 1) //apply and ask for secondary skill + { + boost::function callback = boost::function(boost::bind(callWith,hlu.skills,boost::function(boost::bind(&CGameHandler::changeSecSkill,this,ID,_1,1,0)),_1)); + applyAndAsk(&hlu,hero->tempOwner,callback); //call changeSecSkill with appropriate args when client responds + } + else if(hlu.skills.size() == 1) //apply, give only possible skill and send info + { + changeSecSkill(ID,hlu.skills.back(),1,false); + sendAndApply(&hlu); + } + else //apply and send info + { + sendAndApply(&hlu); + } } } }