1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* updated project files for MSVC

* fixed a few includes paths
* it's possible to enter Tavern via Brotherhood of Sword
* fixes for statusbar
* fixes for townlist
* fixed crashes on building / clicking some buildings
* bumped version number to 0.71c
* bonuses from wearing more than one same artifact won't cumulate
This commit is contained in:
Michał W. Urbańczyk 2009-05-21 23:50:45 +00:00
parent 73949f3367
commit 1d5565b3a3
15 changed files with 172 additions and 67 deletions

View File

@ -149,13 +149,16 @@ void CBuildingRect::clickRight (tribool down)
return;
if((CSDL_Ext::SDL_GetPixel(area,LOCPLINT->current->motion.x-pos.x,LOCPLINT->current->motion.y-pos.y) != 0)) //na polu
{
CBuilding *bld = CGI->buildh->buildings[str->townID][str->ID];
assert(bld);
CInfoPopup *vinya = new CInfoPopup();
vinya->free = true;
vinya->bitmap = CMessage::drawBoxTextBitmapSub
(LOCPLINT->playerID,
CGI->buildh->buildings[str->townID][str->ID]->Description(),
bld->Description(),
LOCPLINT->castleInt->bicons->ourImages[str->ID].bitmap,
CGI->buildh->buildings[str->townID][str->ID]->Name());
bld->Name());
vinya->pos.x = screen->w/2 - vinya->bitmap->w/2;
vinya->pos.y = screen->h/2 - vinya->bitmap->h/2;
LOCPLINT->pushInt(vinya);
@ -551,11 +554,11 @@ void CCastleInterface::buildingClicked(int building)
}
case 5: //tavern
{
std::vector<const CGHeroInstance*> h = LOCPLINT->cb->getAvailableHeroes(town);
CTavernWindow *tv = new CTavernWindow(h[0],h[1],"GOSSIP TEST");
LOCPLINT->pushInt(tv);
enterTavern();
break;
}
//TODO: case 6: //shipyard
case 7: case 8: case 9: //fort/citadel/castle
{
CFortScreen *fs = new CFortScreen(this);
@ -573,7 +576,7 @@ void CCastleInterface::buildingClicked(int building)
}
case 15: //resource silo
{
LOCPLINT->showInfoDialog(CGI->buildh->buildings[town->subID][15]->description,std::vector<SComponent*>(), soundBase::sound_todo);
LOCPLINT->showInfoDialog(CGI->buildh->buildings[town->subID][15]->Description(),std::vector<SComponent*>(), soundBase::sound_todo);
break;
}
case 16: //blacksmith
@ -595,6 +598,29 @@ void CCastleInterface::buildingClicked(int building)
LOCPLINT->pushInt(new CBlacksmithDialog(possible,CArtHandler::convertMachineID(aid,false),aid,hero->id));
break;
}
//TODO: case 17: //special 1
//TODO: case 18: //basic horde 1
//TODO: case 19: //upg horde 1
//TODO: case 20: //ship at shipyard
//TODO: case 21: //special 2
case 22: //special 3
{
switch(town->subID)
{
case 0: //brotherhood of sword
enterTavern();
break;
default:
tlog4<<"This building isn't handled...\n";
break;
}
break;
}
//TODO: case 23: //special 4
//TODO: case 24: //basic horde 2
//TODO: case 25: //upg horde 2
//TODO: case 26: //grail
default:
tlog4<<"This building isn't handled...\n";
}
@ -907,6 +933,14 @@ void CCastleInterface::enterMageGuild()
{
LOCPLINT->pushInt(new CMageGuildScreen(this));
}
void CCastleInterface::enterTavern()
{
std::vector<const CGHeroInstance*> h = LOCPLINT->cb->getAvailableHeroes(town);
CTavernWindow *tv = new CTavernWindow(h[0],h[1],"GOSSIP TEST");
LOCPLINT->pushInt(tv);
}
void CHallInterface::CBuildingBox::hover(bool on)
{
Hoverable::hover(on);
@ -1083,6 +1117,7 @@ void CHallInterface::close()
void CHallInterface::show(SDL_Surface * to)
{
blitAt(bg,pos,to);
LOCPLINT->castleInt->statusbar->show(to);
resdatabar->show(to);
exit->show(to);
for(int i=0; i<5; i++)

View File

@ -101,6 +101,7 @@ public:
void show(SDL_Surface * to);
void showAll(SDL_Surface * to);
void buildingClicked(int building);
void enterTavern();
void enterMageGuild();
CRecruitmentWindow * showRecruitmentWindow(int building);
void enterHall();

View File

@ -630,6 +630,13 @@ CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free)
pos.h = bitmap->h;
pos.w = bitmap->w;
}
CInfoPopup::CInfoPopup(SDL_Surface *Bitmap, bool Free)
{
free=Free;
bitmap=Bitmap;
}
void CInfoPopup::close()
{
if(free)
@ -975,7 +982,7 @@ void CStatusBar::print(const std::string & text)
if(LOCPLINT->cingconsole->enteredText == "" || text == LOCPLINT->cingconsole->enteredText) //for appropriate support for in-game console
{
current=text;
show(screen);
show(LOCPLINT->topInt()==LOCPLINT->adventureInt ? screen : screen2); //if there are now windows opened, update statusbar on screen, else to cache surface
}
}
@ -1418,6 +1425,7 @@ void CTownList::mouseMoved (const SDL_MouseMotionEvent & sEvent)
void CTownList::clickLeft(tribool down)
{
SDL_Surface *dst = (LOCPLINT->topInt()==LOCPLINT->adventureInt ? screen : screen2);
if (down)
{
/***************************ARROWS*****************************************/
@ -1425,7 +1433,7 @@ void CTownList::clickLeft(tribool down)
{
if(from>0)
{
blitAt(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y);
blitAt(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y,dst);
pressed = true;
}
return;
@ -1434,7 +1442,7 @@ void CTownList::clickLeft(tribool down)
{
if(items.size()-from > SIZE)
{
blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y);
blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y,dst);
pressed = false;
}
return;
@ -1460,7 +1468,7 @@ void CTownList::clickLeft(tribool down)
return;
if (pressed) //up
{
blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y,dst);
pressed = indeterminate;
if (!down)
{
@ -1468,12 +1476,12 @@ void CTownList::clickLeft(tribool down)
if (from<0)
from=0;
draw(screen2);
draw(dst);
}
}
else if (!pressed) //down
{
blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y,dst);
pressed = indeterminate;
if (!down)
{
@ -1481,7 +1489,7 @@ void CTownList::clickLeft(tribool down)
//if (from<items.size()-5)
// from=items.size()-5;
draw(screen2);
draw(dst);
}
}
else

View File

@ -107,10 +107,10 @@ class CInfoPopup : public CRClickPopup
public:
bool free; //TODO: comment me
SDL_Surface * bitmap; //popup background
CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
void close();
void show(SDL_Surface * to);
CInfoPopup(){free=false;bitmap=NULL;} //default c-tor
CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
CInfoPopup(SDL_Surface *Bitmap = NULL, bool Free = false); //default c-tor
~CInfoPopup(){}; //d-tor
};

View File

@ -271,15 +271,15 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\AdventureMapButton.cpp"
RelativePath=".\AdventureMapButton.cpp"
>
</File>
<File
RelativePath="..\CAdvmapInterface.cpp"
RelativePath=".\CAdvmapInterface.cpp"
>
</File>
<File
RelativePath="..\CBattleInterface.cpp"
RelativePath=".\CBattleInterface.cpp"
>
</File>
<File
@ -291,7 +291,7 @@
>
</File>
<File
RelativePath="..\CCastleInterface.cpp"
RelativePath=".\CCastleInterface.cpp"
>
</File>
<File
@ -303,7 +303,7 @@
>
</File>
<File
RelativePath="..\CCursorHandler.cpp"
RelativePath=".\CCursorHandler.cpp"
>
</File>
<File
@ -311,7 +311,7 @@
>
</File>
<File
RelativePath="..\CGameInfo.cpp"
RelativePath=".\CGameInfo.cpp"
>
</File>
<File
@ -319,7 +319,7 @@
>
</File>
<File
RelativePath="..\CHeroWindow.cpp"
RelativePath=".\CHeroWindow.cpp"
>
</File>
<File
@ -327,11 +327,11 @@
>
</File>
<File
RelativePath="..\CMessage.cpp"
RelativePath=".\CMessage.cpp"
>
</File>
<File
RelativePath="..\CMT.cpp"
RelativePath=".\CMT.cpp"
>
</File>
<File
@ -339,11 +339,11 @@
>
</File>
<File
RelativePath="..\CPlayerInterface.cpp"
RelativePath=".\CPlayerInterface.cpp"
>
</File>
<File
RelativePath="..\CPreGame.cpp"
RelativePath=".\CPreGame.cpp"
>
</File>
<File
@ -362,6 +362,14 @@
RelativePath=".\Graphics.cpp"
>
</File>
<File
RelativePath=".\GUIBase.cpp"
>
</File>
<File
RelativePath=".\GUIClasses.cpp"
>
</File>
<File
RelativePath="..\mapHandler.cpp"
>
@ -371,11 +379,11 @@
>
</File>
<File
RelativePath="..\SDL_Extensions.cpp"
RelativePath=".\SDL_Extensions.cpp"
>
</File>
<File
RelativePath="..\SDL_framerate.cpp"
RelativePath=".\SDL_framerate.cpp"
>
</File>
</Filter>
@ -385,7 +393,7 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\AdventureMapButton.h"
RelativePath=".\AdventureMapButton.h"
>
</File>
<File
@ -393,7 +401,7 @@
>
</File>
<File
RelativePath="..\CAdvmapInterface.h"
RelativePath=".\CAdvmapInterface.h"
>
</File>
<File
@ -405,7 +413,7 @@
>
</File>
<File
RelativePath="..\CBattleInterface.h"
RelativePath=".\CBattleInterface.h"
>
</File>
<File
@ -421,7 +429,7 @@
>
</File>
<File
RelativePath="..\CCastleInterface.h"
RelativePath=".\CCastleInterface.h"
>
</File>
<File
@ -433,7 +441,7 @@
>
</File>
<File
RelativePath="..\CCursorHandler.h"
RelativePath=".\CCursorHandler.h"
>
</File>
<File
@ -441,7 +449,7 @@
>
</File>
<File
RelativePath="..\CGameInfo.h"
RelativePath=".\CGameInfo.h"
>
</File>
<File
@ -453,7 +461,7 @@
>
</File>
<File
RelativePath="..\CHeroWindow.h"
RelativePath=".\CHeroWindow.h"
>
</File>
<File
@ -461,7 +469,7 @@
>
</File>
<File
RelativePath="..\CMessage.h"
RelativePath=".\CMessage.h"
>
</File>
<File
@ -477,11 +485,11 @@
>
</File>
<File
RelativePath="..\CPlayerInterface.h"
RelativePath=".\CPlayerInterface.h"
>
</File>
<File
RelativePath="..\CPreGame.h"
RelativePath=".\CPreGame.h"
>
</File>
<File
@ -509,11 +517,15 @@
>
</File>
<File
RelativePath="..\int3.h"
RelativePath=".\GUIBase.h"
>
</File>
<File
RelativePath="..\map.h"
RelativePath=".\GUIClasses.h"
>
</File>
<File
RelativePath="..\int3.h"
>
</File>
<File
@ -525,7 +537,11 @@
>
</File>
<File
RelativePath="..\SDL_framerate.h"
RelativePath=".\SDL_Extensions.h"
>
</File>
<File
RelativePath=".\SDL_framerate.h"
>
</File>
<File

View File

@ -19,7 +19,7 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
#define THC
#endif
#define NAME_VER ("VCMI 0.71b")
#define NAME_VER ("VCMI 0.71c")
#define CONSOLE_LOGGING_LEVEL 5
#define FILE_LOGGING_LEVEL 6

View File

@ -78,6 +78,10 @@ void CBuildingHandler::loadBuildings()
delete nb;
}
//create Grail entries
for(int i=0; i<F_NUMBER; i++)
buildings[i][26] = new CBuilding(i,26);
//reading 14 per faction dwellings
temp = readTo(buf,it,'\n');temp = readTo(buf,it,'\n');//dwellings - skip 2 lines
for(int i=0;i<F_NUMBER;i++)
@ -163,4 +167,10 @@ const std::string & CBuilding::Description()
return VLC->generaltexth->buildings[tid][bid].second;
tlog2 << "Warning: Cannot find description text for building " << bid << "for " << tid << "town.\n";
return "";
}
CBuilding::CBuilding( int TID, int BID )
{
tid = TID;
bid = BID;
}

View File

@ -18,8 +18,8 @@
class DLL_EXPORT CBuilding //a typical building encountered in every castle ;]
{
public:
int tid, bid; //town ID and structure ID
std::vector<int> resources;
si32 tid, bid; //town ID and structure ID
std::vector<si32> resources;
std::string name;
std::string description;
@ -30,6 +30,7 @@ public:
{
h & tid & bid & resources & name & description;
}
CBuilding(int TID = -1, int BID = -1);
};
class DLL_EXPORT CBuildingHandler

View File

@ -160,6 +160,18 @@ void CGeneralTextHandler::load()
}
}
//remove prceeding / trailing whitespaces nad quoation marks from buildings descriptions
for(std::map<int, std::map<int, std::pair<std::string, std::string> > >::iterator i = buildings.begin(); i != buildings.end(); i++)
{
for(std::map<int, std::pair<std::string, std::string> >::iterator j = i->second.begin(); j != i->second.end(); j++)
{
std::string &str = j->second.second;
boost::algorithm::trim(str);
if(str[0] == '"' && str[str.size()-1] == '"')
str = str.substr(1,str.size()-2);
}
}
buf = bitmaph->getTextFile("TCOMMAND.TXT");
itr=0;
while(itr<buf.length()-1)

View File

@ -882,6 +882,14 @@ bool CGHeroInstance::hasBonusOfType(HeroBonus::BonusType type, int subtype /*= -
return false;
}
si32 CGHeroInstance::getArtPos(int aid) const
{
for(std::map<ui16,ui32>::const_iterator i = artifWorn.begin(); i != artifWorn.end(); i++)
if(i->second == aid)
return i->first;
return -1;
}
int CGTownInstance::getSightRadious() const //returns sight distance
{
return 5;

View File

@ -260,6 +260,7 @@ public:
int maxMovePoints(bool onLand) const;
ui32 getArtAtPos(ui16 pos) const; //-1 - no artifact
const CArtifact * getArt(int pos) const;
si32 getArtPos(int aid) const; //looks for equipped artifact with given ID and returns its slot ID or -1 if none(if more than one such artifact lower ID is returned)
int getSpellSecLevel(int spell) const; //returns level of secondary ability (fire, water, earth, air magic) known to this hero and applicable to given spell; -1 if error
static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
double getHeroStrength() const;

View File

@ -316,11 +316,31 @@ DLL_EXPORT void SetHeroArtifacts::applyGs( CGameState *gs )
if(!vstd::contains(h->artifWorn,i->first) || h->artifWorn[i->first] != i->second)
equiped.push_back(i->second);
BOOST_FOREACH(ui32 id, equiped)
{
//if hero already had equipped at least one artifact of that type, don't give any new bonuses
if(h->getArtPos(id) >= 0)
continue;
CArtifact &art = VLC->arth->artifacts[id];
for(std::list<HeroBonus>::iterator i = art.bonuses.begin(); i != art.bonuses.end(); i++)
{
gained.push_back(&*i);
h->bonuses.push_back(*i);
}
}
//update hero data
h->artifacts = artifacts;
h->artifWorn = artifWorn;
//remove bonus from unequipped artifact
BOOST_FOREACH(ui32 id, unequiped)
{
//if hero still has equipped at least one artifact of that type, don't remove bonuses
if(h->getArtPos(id) >= 0)
continue;
while(1)
{
std::list<HeroBonus>::iterator hlp = std::find_if(h->bonuses.begin(),h->bonuses.end(),boost::bind(HeroBonus::IsFrom,_1,HeroBonus::ARTIFACT,id));
@ -335,16 +355,6 @@ DLL_EXPORT void SetHeroArtifacts::applyGs( CGameState *gs )
}
}
}
BOOST_FOREACH(ui32 id, equiped)
{
CArtifact &art = VLC->arth->artifacts[id];
for(std::list<HeroBonus>::iterator i = art.bonuses.begin(); i != art.bonuses.end(); i++)
{
gained.push_back(&*i);
h->bonuses.push_back(*i);
}
}
}
DLL_EXPORT void SetHeroArtifacts::setArtAtPos(ui16 pos, int art)

View File

@ -42,7 +42,10 @@ DLL_EXPORT void initDLL(CConsoleHandler *Console, std::ostream *Logfile)
console = Console;
logfile = Logfile;
VLC = new LibClasses;
VLC->init();
try
{
VLC->init();
} HANDLE_EXCEPTION
}
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode)

View File

@ -282,10 +282,6 @@
RelativePath="..\hch\CDefObjInfoHandler.cpp"
>
</File>
<File
RelativePath="..\CGameState.cpp"
>
</File>
<File
RelativePath="..\hch\CGeneralTextHandler.cpp"
>
@ -318,10 +314,6 @@
RelativePath=".\IGameCallback.cpp"
>
</File>
<File
RelativePath="..\map.cpp"
>
</File>
<File
RelativePath=".\NetPacksLib.cpp"
>
@ -369,7 +361,7 @@
>
</File>
<File
RelativePath="..\CGameState.h"
RelativePath=".\CGameState.h"
>
</File>
<File
@ -421,7 +413,7 @@
>
</File>
<File
RelativePath="..\map.h"
RelativePath=".\map.h"
>
</File>
<File
@ -437,6 +429,14 @@
>
</File>
</Filter>
<File
RelativePath=".\CGameState.cpp"
>
</File>
<File
RelativePath=".\map.cpp"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "mapHandler.h"
#include "SDL_Extensions.h"
#include "CGameInfo.h"
#include "client/SDL_Extensions.h"
#include "client/CGameInfo.h"
#include <cstdlib>
#include "hch/CLodHandler.h"
#include "hch/CDefObjInfoHandler.h"