mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-01 12:57:51 +02:00
Merged most of the changes from trunk.
Because of really huge amount of modifications here I've probably missed some minor stuff. I doubt if it's still compatible with gcc - some changes should be reapplied.
This commit is contained in:
parent
dc82232e70
commit
cc7be20b07
11
AI_Base.h
11
AI_Base.h
@ -3,4 +3,13 @@
|
||||
#include <iostream>
|
||||
#include "CGameInterface.h"
|
||||
|
||||
#define AI_INTERFACE_VER 1
|
||||
#define AI_INTERFACE_VER 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ void AdventureMapButton::clickLeft (tribool down)
|
||||
{
|
||||
state=1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
state=0;
|
||||
}
|
||||
@ -264,4 +264,4 @@ CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int
|
||||
slider.actOnDown = true;
|
||||
|
||||
moveTo(value);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ CAdvMapInt::~CAdvMapInt()
|
||||
}
|
||||
CMinimap::CMinimap(bool draw)
|
||||
{
|
||||
statusbarTxt = CGI->preth->zelp[291].first;
|
||||
statusbarTxt = CGI->preth->zelp[291].first;
|
||||
rcText = CGI->preth->zelp[291].second;
|
||||
pos.x=630;
|
||||
pos.y=26;
|
||||
@ -64,7 +64,7 @@ CMinimap::CMinimap(bool draw)
|
||||
SDL_PutPixel(radar,radar->w-1,i,255,75,125);
|
||||
}
|
||||
}
|
||||
SDL_SetColorKey(radar,SDL_SRCCOLORKEY,SDL_MapRGB(radar->format,0,255,255));
|
||||
SDL_SetColorKey(radar,SDL_SRCCOLORKEY,SDL_MapRGB(radar->format,0,255,255));
|
||||
|
||||
//radar = CDefHandler::giveDef("RADAR.DEF");
|
||||
std::ifstream is("config/minimap.txt",std::ifstream::in);
|
||||
@ -86,7 +86,7 @@ CMinimap::CMinimap(bool draw)
|
||||
is >> pom;
|
||||
vinya2.second.g=pom;
|
||||
is >> pom;
|
||||
vinya2.second.b=pom;
|
||||
vinya2.second.b=pom;
|
||||
vinya.second.unused=vinya2.second.unused=255;
|
||||
colors.insert(vinya);
|
||||
colorsBlocked.insert(vinya2);
|
||||
@ -121,9 +121,9 @@ void CMinimap::draw()
|
||||
}
|
||||
}
|
||||
//blitAt(FoW[LOCPLINT->adventureInt->position.z],0,0,temps);
|
||||
|
||||
|
||||
//draw radar
|
||||
int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w,
|
||||
int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w,
|
||||
by = (((float)LOCPLINT->adventureInt->position.y)/(((float)CGI->mh->sizes.y)))*pos.h;
|
||||
blitAt(radar,bx,by,temps);
|
||||
blitAt(temps,pos.x,pos.y);
|
||||
@ -173,7 +173,7 @@ void CMinimap::clickLeft (tribool down)
|
||||
ClickableL::clickLeft(down);
|
||||
if (!((bool)down))
|
||||
return;
|
||||
|
||||
|
||||
float dx=((float)(LOCPLINT->current->motion.x-pos.x))/((float)pos.w),
|
||||
dy=((float)(LOCPLINT->current->motion.y-pos.y))/((float)pos.h);
|
||||
|
||||
@ -252,7 +252,7 @@ void CTerrainRect::activate()
|
||||
Hoverable::activate();
|
||||
KeyInterested::activate();
|
||||
MotionInterested::activate();
|
||||
};
|
||||
};
|
||||
void CTerrainRect::deactivate()
|
||||
{
|
||||
ClickableL::deactivate();
|
||||
@ -260,7 +260,7 @@ void CTerrainRect::deactivate()
|
||||
Hoverable::deactivate();
|
||||
KeyInterested::deactivate();
|
||||
MotionInterested::deactivate();
|
||||
};
|
||||
};
|
||||
void CTerrainRect::clickLeft(tribool down)
|
||||
{
|
||||
if ((down==false) || indeterminate(down))
|
||||
@ -307,7 +307,7 @@ void CTerrainRect::clickLeft(tribool down)
|
||||
}
|
||||
const CGHeroInstance * currentHero = (LOCPLINT->adventureInt->heroList.items.size())?(LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].first):(NULL);
|
||||
if(!currentHero)
|
||||
return;
|
||||
return;
|
||||
int3 bufpos = currentHero->getPosition(false);
|
||||
//bufpos.x-=1;
|
||||
if (mres)
|
||||
@ -330,7 +330,7 @@ void CTerrainRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
|
||||
int3 pom=LOCPLINT->adventureInt->verifyPos(whichTileIsIt(sEvent.x,sEvent.y));
|
||||
if (pom!=curHoveredTile)
|
||||
curHoveredTile=pom;
|
||||
else
|
||||
else
|
||||
return;
|
||||
std::vector<std::string> temp = LOCPLINT->cb->getObjDescriptions(pom);
|
||||
if (temp.size())
|
||||
@ -618,13 +618,13 @@ void CResDataBar::draw()
|
||||
char * buf = new char[15];
|
||||
for (int i=0;i<7;i++)
|
||||
{
|
||||
itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
|
||||
SDL_itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
|
||||
printAt(buf,txtpos[i].first,txtpos[i].second,GEOR13,zwykly);
|
||||
}
|
||||
std::vector<std::string> temp;
|
||||
itoa(LOCPLINT->cb->getDate(3),buf,10); temp+=std::string(buf);
|
||||
itoa(LOCPLINT->cb->getDate(2),buf,10); temp+=std::string(buf);
|
||||
itoa(LOCPLINT->cb->getDate(1),buf,10); temp+=std::string(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(3),buf,10); temp+=std::string(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(2),buf,10); temp+=std::string(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(1),buf,10); temp+=std::string(buf);
|
||||
printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,GEOR13,zwykly);
|
||||
temp.clear();
|
||||
//updateRect(&pos,screen);
|
||||
@ -671,7 +671,7 @@ void CInfoBar::draw(const CGObjectInstance * specific)
|
||||
draw((const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected);
|
||||
}
|
||||
if (!specific)
|
||||
specific = (const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected;
|
||||
specific = (const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected;
|
||||
//TODO: to rzutowanie wyglada groznie, ale dziala. Ale nie powinno wygladac groznie.
|
||||
|
||||
if(!specific)
|
||||
@ -744,7 +744,7 @@ void CInfoBar::newDay(int Day)
|
||||
{
|
||||
mode = 0; //showing day
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
switch(LOCPLINT->cb->getDate(2))
|
||||
{
|
||||
@ -866,7 +866,7 @@ townList(5,&genRect(192,48,747,196),747,196,747,372)
|
||||
townList.genList();
|
||||
|
||||
heroWindow = new CHeroWindow(this->player);
|
||||
|
||||
|
||||
gems.push_back(CDefHandler::giveDef("agemLL.def"));
|
||||
gems.push_back(CDefHandler::giveDef("agemLR.def"));
|
||||
gems.push_back(CDefHandler::giveDef("agemUL.def"));
|
||||
@ -886,7 +886,7 @@ void CAdvMapInt::fswitchLevel()
|
||||
underground.curimg=0;
|
||||
underground.show();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
underground.curimg=1;
|
||||
position.z++;
|
||||
@ -930,7 +930,7 @@ void CAdvMapInt::fendTurn()
|
||||
void CAdvMapInt::activate()
|
||||
{
|
||||
LOCPLINT->curint = this;
|
||||
LOCPLINT->statusbar = &statusbar;
|
||||
LOCPLINT->statusbar = &statusbar;
|
||||
kingOverview.activate();
|
||||
underground.activate();
|
||||
questlog.activate();
|
||||
@ -1049,7 +1049,7 @@ CAdvMapInt::CurrentSelection::CurrentSelection()
|
||||
selected=NULL;
|
||||
}
|
||||
void CAdvMapInt::handleRightClick(std::string text, tribool down, CIntObject * client)
|
||||
{
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
boost::algorithm::erase_all(text,"\"");
|
||||
@ -1090,4 +1090,4 @@ int3 CAdvMapInt::verifyPos(int3 ver)
|
||||
if (ver.z>=CGI->mh->sizes.z)
|
||||
ver.z=CGI->mh->sizes.z-1;
|
||||
return ver;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "AdventureMapButton.h"
|
||||
class CDefHandler;
|
||||
class CCallback;
|
||||
struct CPath;
|
||||
struct CPath;
|
||||
class CAdvMapInt;
|
||||
class CGHeroInstance;
|
||||
class CGTownInstance;
|
||||
@ -18,7 +18,7 @@ class CMinimap
|
||||
: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * radar;
|
||||
SDL_Surface * radar;
|
||||
SDL_Surface * temps;
|
||||
std::map<int,SDL_Color> colors;
|
||||
std::map<int,SDL_Color> colorsBlocked;
|
||||
@ -26,7 +26,7 @@ public:
|
||||
//TODO flagged buildings
|
||||
std::string statusbarTxt, rcText;
|
||||
|
||||
CMinimap(bool draw=true);
|
||||
CMinimap(bool draw=true);
|
||||
void draw();
|
||||
void redraw(int level=-1);// (level==-1) => redraw all levels
|
||||
void updateRadar();
|
||||
@ -51,7 +51,7 @@ public:
|
||||
CDefHandler * arrows;
|
||||
CTerrainRect();
|
||||
CPath * currentPath;
|
||||
void activate();
|
||||
void activate();
|
||||
void deactivate();
|
||||
void clickLeft(tribool down);
|
||||
void clickRight(tribool down);
|
||||
@ -60,7 +60,7 @@ public:
|
||||
void keyPressed (SDL_KeyboardEvent & key);
|
||||
void show();
|
||||
void showPath();
|
||||
int3 whichTileIsIt(int x, int y); //x,y are cursor position
|
||||
int3 whichTileIsIt(int x, int y); //x,y are cursor position
|
||||
int3 whichTileIsIt(); //uses current cursor pos
|
||||
};
|
||||
class CResDataBar
|
||||
@ -72,7 +72,7 @@ public:
|
||||
std::string datetext;
|
||||
|
||||
void clickRight (tribool down);
|
||||
void activate();
|
||||
void activate();
|
||||
void deactivate();
|
||||
CResDataBar();
|
||||
~CResDataBar();
|
||||
@ -108,7 +108,7 @@ public:
|
||||
int player;
|
||||
|
||||
std::vector<CDefHandler *> gems;
|
||||
|
||||
|
||||
bool scrollingLeft ;
|
||||
bool scrollingRight ;
|
||||
bool scrollingUp ;
|
||||
@ -128,7 +128,7 @@ public:
|
||||
moveHero, //- move hero
|
||||
spellbook,//- spellbook
|
||||
advOptions, //- adventure options
|
||||
sysOptions,//- system options
|
||||
sysOptions,//- system options
|
||||
nextHero, //- next hero
|
||||
endTurn;//- end turn
|
||||
//CHeroList herolist;
|
||||
@ -137,13 +137,13 @@ public:
|
||||
|
||||
CStatusBar statusbar;
|
||||
CResDataBar resdatabar;
|
||||
|
||||
|
||||
CHeroList heroList;
|
||||
CTownList townList;
|
||||
CTownList townList;
|
||||
CInfoBar infoBar;
|
||||
|
||||
CHeroWindow * heroWindow;
|
||||
|
||||
|
||||
struct CurrentSelection
|
||||
{
|
||||
int type; //0 - hero, 1 - town
|
||||
@ -153,8 +153,8 @@ public:
|
||||
|
||||
//fuctions binded to buttons
|
||||
void fshowOverview();
|
||||
void fswitchLevel();
|
||||
void fshowQuestlog();
|
||||
void fswitchLevel();
|
||||
void fshowQuestlog();
|
||||
void fsleepWake();
|
||||
void fmoveHero();
|
||||
void fshowSpellbok();
|
||||
@ -177,4 +177,4 @@ public:
|
||||
|
||||
|
||||
};
|
||||
#endif //CADVENTUREMAPINTERFACE_H
|
||||
#endif //CADVENTUREMAPINTERFACE_H
|
||||
|
@ -15,13 +15,15 @@
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
|
||||
const double M_PI = 3.14159265358979323846;
|
||||
|
||||
extern SDL_Surface * screen;
|
||||
extern TTF_Font * GEOR13;
|
||||
extern SDL_Color zwykly;
|
||||
SDL_Surface * CBattleInterface::cellBorder, * CBattleInterface::cellShade;
|
||||
|
||||
CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2)
|
||||
: printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL)
|
||||
CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2)
|
||||
: printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL), myTurn(false)
|
||||
{
|
||||
//initializing armies
|
||||
this->army1 = army1;
|
||||
@ -61,7 +63,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
blitAt(background, 0, 0);
|
||||
blitAt(menu, 0, 556);
|
||||
CSDL_Ext::update();
|
||||
|
||||
|
||||
//preparing buttons and console
|
||||
bOptions = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bOptionsf,this), 3, 561, "icm003.def", false, NULL, false);
|
||||
bSurrender = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bSurrenderf,this), 54, 561, "icm001.def", false, NULL, false);
|
||||
@ -78,7 +80,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
console->pos.y = 560;
|
||||
console->pos.w = 406;
|
||||
console->pos.h = 38;
|
||||
|
||||
|
||||
//loading hero animations
|
||||
if(hero1) // attacking hero
|
||||
{
|
||||
@ -107,7 +109,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
for(int h=0; h<187; ++h)
|
||||
{
|
||||
bfield[h].myNumber = h;
|
||||
|
||||
|
||||
int x = 14 + ((h/17)%2==0 ? 22 : 0) + 44*(h%17);
|
||||
int y = 86 + 42 * (h/17);
|
||||
bfield[h].pos = genRect(cellShade->h, cellShade->w, x, y);
|
||||
@ -119,7 +121,31 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
{
|
||||
bfield[it->second.position].accesible = false;
|
||||
}
|
||||
|
||||
|
||||
//loading projectiles for units
|
||||
for(std::map<int, CStack>::iterator g = stacks.begin(); g != stacks.end(); ++g)
|
||||
{
|
||||
if(g->second.creature->isShooting() && CGI->creh->idToProjectile[g->second.creature->idNumber] != std::string())
|
||||
{
|
||||
idToProjectile[g->second.creature->idNumber] = CDefHandler::giveDef(CGI->creh->idToProjectile[g->second.creature->idNumber]);
|
||||
|
||||
if(idToProjectile[g->second.creature->idNumber]->ourImages.size() > 2) //add symmetric images
|
||||
{
|
||||
for(int k = idToProjectile[g->second.creature->idNumber]->ourImages.size()-2; k > 1; --k)
|
||||
{
|
||||
Cimage ci;
|
||||
ci.bitmap = CSDL_Ext::rotate01(idToProjectile[g->second.creature->idNumber]->ourImages[k].bitmap);
|
||||
ci.groupNumber = 0;
|
||||
ci.imName = std::string();
|
||||
idToProjectile[g->second.creature->idNumber]->ourImages.push_back(ci);
|
||||
}
|
||||
}
|
||||
for(int s=0; s<idToProjectile[g->second.creature->idNumber]->ourImages.size(); ++s) //alpha transforming
|
||||
{
|
||||
CSDL_Ext::alphaTransform(idToProjectile[g->second.creature->idNumber]->ourImages[s].bitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CBattleInterface::~CBattleInterface()
|
||||
@ -147,6 +173,9 @@ CBattleInterface::~CBattleInterface()
|
||||
|
||||
for(std::map< int, CCreatureAnimation * >::iterator g=creAnims.begin(); g!=creAnims.end(); ++g)
|
||||
delete g->second;
|
||||
|
||||
for(std::map< int, CDefHandler * >::iterator g=idToProjectile.begin(); g!=idToProjectile.end(); ++g)
|
||||
delete g->second;
|
||||
}
|
||||
|
||||
void CBattleInterface::activate()
|
||||
@ -241,7 +270,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
if(defendingHero)
|
||||
defendingHero->show(to);
|
||||
|
||||
//showing units //a lot of work...
|
||||
////showing units //a lot of work...
|
||||
std::vector<int> stackAliveByHex[187];
|
||||
//double loop because dead stacks should be printed first
|
||||
for(std::map<int, CStack>::iterator j=stacks.begin(); j!=stacks.end(); ++j)
|
||||
@ -309,6 +338,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
}
|
||||
}
|
||||
//units shown
|
||||
projectileShowHelper(to);//showing projectiles
|
||||
}
|
||||
|
||||
bool CBattleInterface::reverseCreature(int number, int hex, bool wideTrick)
|
||||
@ -404,8 +434,36 @@ void CBattleInterface::stackRemoved(CStack stack)
|
||||
creAnims.erase(stack.ID);
|
||||
}
|
||||
|
||||
void CBattleInterface::stackKilled(int ID, int dmg, int killed, int IDby)
|
||||
void CBattleInterface::stackKilled(int ID, int dmg, int killed, int IDby, bool byShooting)
|
||||
{
|
||||
if(creAnims[ID]->getType() != 2)
|
||||
{
|
||||
return; //something went wrong
|
||||
}
|
||||
if(byShooting) //delay hit animation
|
||||
{
|
||||
CStack attacker = *LOCPLINT->cb->battleGetStackByID(IDby);
|
||||
while(true)
|
||||
{
|
||||
bool found = false;
|
||||
for(std::list<SProjectileInfo>::const_iterator it = projectiles.begin(); it!=projectiles.end(); ++it)
|
||||
{
|
||||
if(it->creID == attacker.creature->idNumber)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
break;
|
||||
else
|
||||
{
|
||||
show();
|
||||
CSDL_Ext::update();
|
||||
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
||||
}
|
||||
}
|
||||
}
|
||||
creAnims[ID]->setType(5); //death
|
||||
for(int i=0; i<creAnims[ID]->framesInGroup(5)-1; ++i)
|
||||
{
|
||||
@ -413,7 +471,7 @@ void CBattleInterface::stackKilled(int ID, int dmg, int killed, int IDby)
|
||||
CSDL_Ext::update();
|
||||
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
||||
}
|
||||
|
||||
|
||||
printConsoleAttacked(ID, dmg, killed, IDby);
|
||||
}
|
||||
|
||||
@ -421,6 +479,8 @@ void CBattleInterface::stackActivated(int number)
|
||||
{
|
||||
givenCommand = NULL;
|
||||
activeStack = number;
|
||||
shadedHexes = LOCPLINT->cb->battleGetAvailableHexes(number);
|
||||
myTurn = true;
|
||||
}
|
||||
|
||||
void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, bool endMoving)
|
||||
@ -442,7 +502,7 @@ void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, boo
|
||||
|
||||
int mutPos = CBattleHex::mutualPosition(curStackPos, destHex);
|
||||
|
||||
if(LOCPLINT->cb->battleGetCreature(number).isDoubleWide() &&
|
||||
if(LOCPLINT->cb->battleGetCreature(number).isDoubleWide() &&
|
||||
((creDir[number] && mutPos == 5) || (creDir[number] && mutPos == 0) || (creDir[number] && mutPos == 4))) //for special cases
|
||||
{
|
||||
switch(CBattleHex::mutualPosition(curStackPos, destHex)) //reverse unit if necessary
|
||||
@ -593,14 +653,42 @@ void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, boo
|
||||
reverseCreature(number, destHex);
|
||||
//creDir[number] = (curs.owner == attackingHeroInstance->tempOwner);
|
||||
}
|
||||
|
||||
|
||||
std::pair <int, int> coords = CBattleHex::getXYUnitAnim(destHex, creDir[number], curs.creature);
|
||||
creAnims[number]->pos.x = coords.first;
|
||||
creAnims[number]->pos.y = coords.second;
|
||||
}
|
||||
|
||||
void CBattleInterface::stackIsAttacked(int ID, int dmg, int killed, int IDby)
|
||||
void CBattleInterface::stackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting)
|
||||
{
|
||||
if(creAnims[ID]->getType() != 2)
|
||||
{
|
||||
return; //something went wrong
|
||||
}
|
||||
if(byShooting) //delay hit animation
|
||||
{
|
||||
CStack attacker = *LOCPLINT->cb->battleGetStackByID(IDby);
|
||||
while(true)
|
||||
{
|
||||
bool found = false;
|
||||
for(std::list<SProjectileInfo>::const_iterator it = projectiles.begin(); it!=projectiles.end(); ++it)
|
||||
{
|
||||
if(it->creID == attacker.creature->idNumber)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
break;
|
||||
else
|
||||
{
|
||||
show();
|
||||
CSDL_Ext::update();
|
||||
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
||||
}
|
||||
}
|
||||
}
|
||||
creAnims[ID]->setType(3); //getting hit
|
||||
for(int i=0; i<creAnims[ID]->framesInGroup(3); ++i)
|
||||
{
|
||||
@ -615,6 +703,10 @@ void CBattleInterface::stackIsAttacked(int ID, int dmg, int killed, int IDby)
|
||||
|
||||
void CBattleInterface::stackAttacking(int ID, int dest)
|
||||
{
|
||||
if(attackingInfo != NULL)
|
||||
{
|
||||
return; //something went wrong
|
||||
}
|
||||
CStack aStack = *LOCPLINT->cb->battleGetStackByID(ID); //attacking stack
|
||||
if(aStack.creature->isDoubleWide())
|
||||
{
|
||||
@ -664,54 +756,28 @@ void CBattleInterface::stackAttacking(int ID, int dest)
|
||||
attackingInfo->frame = 0;
|
||||
attackingInfo->ID = ID;
|
||||
attackingInfo->reversing = false;
|
||||
attackingInfo->shooting = false;
|
||||
|
||||
if(aStack.creature->isDoubleWide())
|
||||
switch(CBattleHex::mutualPosition(aStack.position, dest)) //attack direction
|
||||
{
|
||||
switch(CBattleHex::mutualPosition(aStack.position, dest)) //attack direction
|
||||
{
|
||||
case 0:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(10);
|
||||
break;
|
||||
case 1:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(10);
|
||||
break;
|
||||
case 2:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(11);
|
||||
break;
|
||||
case 3:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(12);
|
||||
break;
|
||||
case 4:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(12);
|
||||
break;
|
||||
case 5:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(11);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //else for if(aStack.creature->isDoubleWide())
|
||||
{
|
||||
switch(CBattleHex::mutualPosition(aStack.position, dest)) //attack direction
|
||||
{
|
||||
case 0:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(10);
|
||||
break;
|
||||
case 1:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(10);
|
||||
break;
|
||||
case 2:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(11);
|
||||
break;
|
||||
case 3:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(12);
|
||||
break;
|
||||
case 4:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(12);
|
||||
break;
|
||||
case 5:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(11);
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(10);
|
||||
break;
|
||||
case 1:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(10);
|
||||
break;
|
||||
case 2:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(11);
|
||||
break;
|
||||
case 3:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(12);
|
||||
break;
|
||||
case 4:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(12);
|
||||
break;
|
||||
case 5:
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(11);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -724,6 +790,9 @@ void CBattleInterface::hexLclicked(int whichOne)
|
||||
{
|
||||
if((whichOne%17)!=0 && (whichOne%17)!=16) //if player is trying to attack enemey unit or move creature stack
|
||||
{
|
||||
if(!myTurn)
|
||||
return; //we are not permit to do anything
|
||||
|
||||
int atCre = LOCPLINT->cb->battleGetStack(whichOne); //creature at destination tile; -1 if there is no one
|
||||
//LOCPLINT->cb->battleGetCreature();
|
||||
if(atCre==-1) //normal move action
|
||||
@ -734,6 +803,15 @@ void CBattleInterface::hexLclicked(int whichOne)
|
||||
ba->stackNumber = activeStack;
|
||||
givenCommand = ba;
|
||||
}
|
||||
else if(LOCPLINT->cb->battleGetStackByID(atCre)->owner != attackingHeroInstance->tempOwner
|
||||
&& LOCPLINT->cb->battleCanShoot(activeStack, whichOne)) //shooting
|
||||
{
|
||||
BattleAction * ba = new BattleAction(); //to be deleted by engine
|
||||
ba->actionType = 7;
|
||||
ba->destinationTile = whichOne;
|
||||
ba->stackNumber = activeStack;
|
||||
givenCommand = ba;
|
||||
}
|
||||
else if(LOCPLINT->cb->battleGetStackByID(atCre)->owner != attackingHeroInstance->tempOwner) //attacking
|
||||
{
|
||||
BattleAction * ba = new BattleAction(); //to be deleted by engine
|
||||
@ -745,9 +823,80 @@ void CBattleInterface::hexLclicked(int whichOne)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::stackIsShooting(int ID, int dest)
|
||||
{
|
||||
if(attackingInfo != NULL)
|
||||
{
|
||||
return; //something went wrong
|
||||
}
|
||||
//projectile
|
||||
float projectileAngle; //in radians; if positive, projectiles goes up
|
||||
float straightAngle = 0.2f; //maximal angle in radians between straight horizontal line and shooting line for which shot is considered to be straight (absoulte value)
|
||||
int fromHex = LOCPLINT->cb->battleGetPos(ID);
|
||||
projectileAngle = atan2(float(abs(dest - fromHex)/17), float(abs(dest - fromHex)%17));
|
||||
if(fromHex < dest)
|
||||
projectileAngle = -projectileAngle;
|
||||
|
||||
SProjectileInfo spi;
|
||||
spi.creID = LOCPLINT->cb->battleGetStackByID(ID)->creature->idNumber;
|
||||
|
||||
spi.step = 0;
|
||||
spi.frameNum = 0;
|
||||
spi.spin = CGI->creh->idToProjectileSpin[spi.creID];
|
||||
|
||||
std::pair<int, int> xycoord = CBattleHex::getXYUnitAnim(LOCPLINT->cb->battleGetPos(ID), true, &LOCPLINT->cb->battleGetCreature(ID));
|
||||
std::pair<int, int> destcoord = CBattleHex::getXYUnitAnim(dest, false, &LOCPLINT->cb->battleGetCreature(ID));
|
||||
destcoord.first += 250; destcoord.second += 210; //TODO: find a better place to shoot
|
||||
|
||||
if(projectileAngle > straightAngle) //upper shot
|
||||
{
|
||||
spi.x = xycoord.first + 200 + LOCPLINT->cb->battleGetCreature(ID).upperRightMissleOffsetX;
|
||||
spi.y = xycoord.second + 150 - LOCPLINT->cb->battleGetCreature(ID).upperRightMissleOffsetY;
|
||||
}
|
||||
else if(projectileAngle < -straightAngle) //lower shot
|
||||
{
|
||||
spi.x = xycoord.first + 200 + LOCPLINT->cb->battleGetCreature(ID).lowerRightMissleOffsetX;
|
||||
spi.y = xycoord.second + 150 - LOCPLINT->cb->battleGetCreature(ID).lowerRightMissleOffsetY;
|
||||
}
|
||||
else //straight shot
|
||||
{
|
||||
spi.x = xycoord.first + 200 + LOCPLINT->cb->battleGetCreature(ID).rightMissleOffsetX;
|
||||
spi.y = xycoord.second + 150 - LOCPLINT->cb->battleGetCreature(ID).rightMissleOffsetY;
|
||||
}
|
||||
spi.lastStep = sqrt((float)((destcoord.first - spi.x)*(destcoord.first - spi.x) + (destcoord.second - spi.y) * (destcoord.second - spi.y))) / 40;
|
||||
spi.dx = (destcoord.first - spi.x) / spi.lastStep;
|
||||
spi.dy = (destcoord.second - spi.y) / spi.lastStep;
|
||||
//set starting frame
|
||||
if(spi.spin)
|
||||
{
|
||||
spi.frameNum = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
spi.frameNum = ((M_PI/2.0f - projectileAngle) / (2.0f *M_PI) + 1/((float)(2*(idToProjectile[spi.creID]->ourImages.size()-1)))) * (idToProjectile[spi.creID]->ourImages.size()-1);
|
||||
}
|
||||
//set delay
|
||||
spi.animStartDelay = CGI->creh->creatures[spi.creID].attackClimaxFrame;
|
||||
projectiles.push_back(spi);
|
||||
|
||||
//attack aniamtion
|
||||
attackingInfo = new CAttHelper;
|
||||
attackingInfo->dest = dest;
|
||||
attackingInfo->frame = 0;
|
||||
attackingInfo->ID = ID;
|
||||
attackingInfo->reversing = false;
|
||||
attackingInfo->shooting = true;
|
||||
if(projectileAngle > straightAngle) //upper shot
|
||||
attackingInfo->shootingGroup = 14;
|
||||
else if(projectileAngle < -straightAngle) //lower shot
|
||||
attackingInfo->shootingGroup = 15;
|
||||
else //straight shot
|
||||
attackingInfo->shootingGroup = 16;
|
||||
attackingInfo->maxframe = creAnims[ID]->framesInGroup(attackingInfo->shootingGroup);
|
||||
}
|
||||
|
||||
void CBattleInterface::showRange(SDL_Surface * to, int ID)
|
||||
{
|
||||
std::vector<int> shadedHexes = LOCPLINT->cb->battleGetAvailableHexes(ID);
|
||||
for(int i=0; i<shadedHexes.size(); ++i)
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(CBattleInterface::cellShade, NULL, to, &bfield[shadedHexes[i]].pos);
|
||||
@ -762,52 +911,59 @@ void CBattleInterface::attackingShowHelper()
|
||||
if(attackingInfo->frame == 0)
|
||||
{
|
||||
CStack aStack = *LOCPLINT->cb->battleGetStackByID(attackingInfo->ID); //attacking stack
|
||||
if(aStack.creature->isDoubleWide())
|
||||
if(attackingInfo->shooting)
|
||||
{
|
||||
switch(CBattleHex::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
|
||||
{
|
||||
case 0:
|
||||
creAnims[attackingInfo->ID]->setType(10);
|
||||
break;
|
||||
case 1:
|
||||
creAnims[attackingInfo->ID]->setType(10);
|
||||
break;
|
||||
case 2:
|
||||
creAnims[attackingInfo->ID]->setType(11);
|
||||
break;
|
||||
case 3:
|
||||
creAnims[attackingInfo->ID]->setType(12);
|
||||
break;
|
||||
case 4:
|
||||
creAnims[attackingInfo->ID]->setType(12);
|
||||
break;
|
||||
case 5:
|
||||
creAnims[attackingInfo->ID]->setType(11);
|
||||
break;
|
||||
}
|
||||
creAnims[attackingInfo->ID]->setType(attackingInfo->shootingGroup);
|
||||
}
|
||||
else //else for if(aStack.creature->isDoubleWide())
|
||||
else
|
||||
{
|
||||
switch(CBattleHex::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
|
||||
if(aStack.creature->isDoubleWide())
|
||||
{
|
||||
case 0:
|
||||
creAnims[attackingInfo->ID]->setType(10);
|
||||
break;
|
||||
case 1:
|
||||
creAnims[attackingInfo->ID]->setType(10);
|
||||
break;
|
||||
case 2:
|
||||
creAnims[attackingInfo->ID]->setType(11);
|
||||
break;
|
||||
case 3:
|
||||
creAnims[attackingInfo->ID]->setType(12);
|
||||
break;
|
||||
case 4:
|
||||
creAnims[attackingInfo->ID]->setType(12);
|
||||
break;
|
||||
case 5:
|
||||
creAnims[attackingInfo->ID]->setType(11);
|
||||
break;
|
||||
switch(CBattleHex::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
|
||||
{
|
||||
case 0:
|
||||
creAnims[attackingInfo->ID]->setType(10);
|
||||
break;
|
||||
case 1:
|
||||
creAnims[attackingInfo->ID]->setType(10);
|
||||
break;
|
||||
case 2:
|
||||
creAnims[attackingInfo->ID]->setType(11);
|
||||
break;
|
||||
case 3:
|
||||
creAnims[attackingInfo->ID]->setType(12);
|
||||
break;
|
||||
case 4:
|
||||
creAnims[attackingInfo->ID]->setType(12);
|
||||
break;
|
||||
case 5:
|
||||
creAnims[attackingInfo->ID]->setType(11);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //else for if(aStack.creature->isDoubleWide())
|
||||
{
|
||||
switch(CBattleHex::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
|
||||
{
|
||||
case 0:
|
||||
creAnims[attackingInfo->ID]->setType(10);
|
||||
break;
|
||||
case 1:
|
||||
creAnims[attackingInfo->ID]->setType(10);
|
||||
break;
|
||||
case 2:
|
||||
creAnims[attackingInfo->ID]->setType(11);
|
||||
break;
|
||||
case 3:
|
||||
creAnims[attackingInfo->ID]->setType(12);
|
||||
break;
|
||||
case 4:
|
||||
creAnims[attackingInfo->ID]->setType(12);
|
||||
break;
|
||||
case 5:
|
||||
creAnims[attackingInfo->ID]->setType(11);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -892,6 +1048,47 @@ void CBattleInterface::printConsoleAttacked(int ID, int dmg, int killed, int IDb
|
||||
console->addText(std::string(tabh));
|
||||
}
|
||||
|
||||
void CBattleInterface::projectileShowHelper(SDL_Surface * to)
|
||||
{
|
||||
if(to == NULL)
|
||||
to = screen;
|
||||
std::list< std::list<SProjectileInfo>::iterator > toBeDeleted;
|
||||
for(std::list<SProjectileInfo>::iterator it=projectiles.begin(); it!=projectiles.end(); ++it)
|
||||
{
|
||||
if(it->animStartDelay>0)
|
||||
{
|
||||
--(it->animStartDelay);
|
||||
continue;
|
||||
}
|
||||
SDL_Rect dst;
|
||||
dst.h = idToProjectile[it->creID]->ourImages[it->frameNum].bitmap->h;
|
||||
dst.w = idToProjectile[it->creID]->ourImages[it->frameNum].bitmap->w;
|
||||
dst.x = it->x;
|
||||
dst.y = it->y;
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(idToProjectile[it->creID]->ourImages[it->frameNum].bitmap, NULL, to, &dst);
|
||||
//actualizing projectile
|
||||
++it->step;
|
||||
if(it->step == it->lastStep)
|
||||
{
|
||||
toBeDeleted.insert(toBeDeleted.end(), it);
|
||||
}
|
||||
else
|
||||
{
|
||||
it->x += it->dx;
|
||||
it->y += it->dy;
|
||||
if(it->spin)
|
||||
{
|
||||
++(it->frameNum);
|
||||
it->frameNum %= idToProjectile[it->creID]->ourImages.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(std::list< std::list<SProjectileInfo>::iterator >::iterator it = toBeDeleted.begin(); it!= toBeDeleted.end(); ++it)
|
||||
{
|
||||
projectiles.erase(*it);
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::show(SDL_Surface *to)
|
||||
{
|
||||
//animation of flag
|
||||
@ -935,7 +1132,7 @@ CBattleHero::CBattleHero(std::string defName, int phaseG, int imageG, bool flipG
|
||||
if(flip)
|
||||
{
|
||||
SDL_Surface * hlp = CSDL_Ext::rotate01(dh->ourImages[i].bitmap);
|
||||
SDL_FreeSurface(dh->ourImages[i].bitmap);
|
||||
SDL_FreeSurface(dh->ourImages[i].bitmap);
|
||||
dh->ourImages[i].bitmap = hlp;
|
||||
}
|
||||
dh->ourImages[i].bitmap = CSDL_Ext::alphaTransform(dh->ourImages[i].bitmap);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "global.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include <list>
|
||||
|
||||
class CCreatureSet;
|
||||
class CGHeroInstance;
|
||||
@ -79,9 +80,11 @@ private:
|
||||
CCreatureSet * army1, * army2; //fighting armies
|
||||
CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
|
||||
std::map< int, CCreatureAnimation * > creAnims; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
|
||||
std::map< int, CDefHandler * > idToProjectile; //projectiles of creaures (creatureID, defhandler)
|
||||
std::map< int, bool > creDir; // <creatureID, if false reverse creature's animation>
|
||||
unsigned char animCount;
|
||||
int activeStack; //number of active stack; -1 - no one
|
||||
std::vector<int> shadedHexes; //hexes available for active stack
|
||||
void showRange(SDL_Surface * to, int ID); //show helper funtion ot mark range of a unit
|
||||
|
||||
class CAttHelper
|
||||
@ -91,10 +94,25 @@ private:
|
||||
int dest; //atacked hex
|
||||
int frame, maxframe; //frame of animation, number of frames of animation
|
||||
bool reversing;
|
||||
bool shooting;
|
||||
int shootingGroup; //if shooting is true, print this animation group
|
||||
} * attackingInfo;
|
||||
void attackingShowHelper();
|
||||
void printConsoleAttacked(int ID, int dmg, int killed, int IDby);
|
||||
|
||||
struct SProjectileInfo
|
||||
{
|
||||
int x, y; //position on the screen
|
||||
int dx, dy; //change in position in one step
|
||||
int step, lastStep; //to know when finish showing this projectile
|
||||
int creID; //ID of creature that shot this projectile
|
||||
int frameNum; //frame to display form projectile animation
|
||||
bool spin; //if true, frameNum will be increased
|
||||
int animStartDelay; //how many times projectile must be attempted to be shown till it's really show (decremented after hit)
|
||||
};
|
||||
std::list<SProjectileInfo> projectiles;
|
||||
void projectileShowHelper(SDL_Surface * to=NULL); //prints projectiles present on the battlefield
|
||||
|
||||
public:
|
||||
CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2); //c-tor
|
||||
~CBattleInterface(); //d-tor
|
||||
@ -105,6 +123,7 @@ public:
|
||||
std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield
|
||||
static SDL_Surface * cellBorder, * cellShade;
|
||||
BattleAction * givenCommand; //true if we have i.e. moved current unit
|
||||
bool myTurn; //if true, interface is active (commands can be ordered
|
||||
|
||||
//button handle funcs:
|
||||
void bOptionsf();
|
||||
@ -126,13 +145,14 @@ public:
|
||||
//call-ins
|
||||
void newStack(CStack stack); //new stack appeared on battlefield
|
||||
void stackRemoved(CStack stack); //stack disappeared from batlefiled
|
||||
void stackKilled(int ID, int dmg, int killed, int IDby); //stack has been killed (but corpses remain)
|
||||
void stackKilled(int ID, int dmg, int killed, int IDby, bool byShooting); //stack has been killed (but corpses remain)
|
||||
void stackActivated(int number); //active stack has been changed
|
||||
void stackMoved(int number, int destHex, bool startMoving, bool endMoving); //stack with id number moved to destHex
|
||||
void stackIsAttacked(int ID, int dmg, int killed, int IDby); //called when stack id attacked by stack with id IDby
|
||||
void stackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting); //called when stack id attacked by stack with id IDby
|
||||
void stackAttacking(int ID, int dest); //called when stack with id ID is attacking something on hex dest
|
||||
void newRound(int number); //caled when round is ended; number is the number of round
|
||||
void hexLclicked(int whichOne); //hex only call-in
|
||||
void stackIsShooting(int ID, int dest); //called when stack with id ID is shooting to hex dest
|
||||
|
||||
friend CBattleHex;
|
||||
friend class CBattleHex;
|
||||
};
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include "lib/NetPacks.h"
|
||||
//LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
|
||||
extern CSharedCond<std::set<IPack*> > mess;
|
||||
|
||||
HeroMoveDetails::HeroMoveDetails(int3 Src, int3 Dst, CGHeroInstance*Ho)
|
||||
@ -79,7 +78,6 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
|
||||
int3 stpos(ourPath->nodes[i].coord.x, ourPath->nodes[i].coord.y, hero->pos.z),
|
||||
endpos(ourPath->nodes[i-1].coord.x, ourPath->nodes[i-1].coord.y, hero->pos.z);
|
||||
HeroMoveDetails curd(stpos,endpos,hero);
|
||||
|
||||
*cl->serv << ui16(501) << hero->id << stpos << endpos;
|
||||
{//wait till there is server answer
|
||||
boost::unique_lock<boost::mutex> lock(*mess.mx);
|
||||
@ -288,6 +286,29 @@ std::vector<si32> CCallback::getResourceAmount()
|
||||
int CCallback::getDate(int mode)
|
||||
{
|
||||
return gs->getDate(mode);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
std::vector < std::string > CCallback::getObjDescriptions(int3 pos)
|
||||
{
|
||||
@ -310,15 +331,15 @@ bool CCallback::verifyPath(CPath * path, bool blockSea)
|
||||
continue;
|
||||
|
||||
if (
|
||||
((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tileInfo->tertype==EterrainType::water)
|
||||
((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tileInfo->tertype==water)
|
||||
&&
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype!=EterrainType::water))
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype!=water))
|
||||
||
|
||||
((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tileInfo->tertype!=EterrainType::water)
|
||||
((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tileInfo->tertype!=water)
|
||||
&&
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype==EterrainType::water))
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype==water))
|
||||
||
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype==EterrainType::rock)
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype==rock)
|
||||
|
||||
)
|
||||
return false;
|
||||
@ -401,6 +422,9 @@ const CCreatureSet* CCallback::getGarrison(const CGObjectInstance *obj)
|
||||
int CCallback::swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)
|
||||
{
|
||||
if(s1->tempOwner != player || s2->tempOwner != player)
|
||||
|
||||
|
||||
|
||||
return -1;
|
||||
|
||||
*cl->serv << ui16(502) << ui8(1) << s1->id << ui8(p1) << s2->id << ui8(p2);
|
||||
@ -493,18 +517,7 @@ int CCallback::battleGetObstaclesAtTile(int tile) //returns bitfield
|
||||
}
|
||||
int CCallback::battleGetStack(int pos)
|
||||
{
|
||||
for(int g=0; g<CGI->state->curB->stacks.size(); ++g)
|
||||
{
|
||||
if(CGI->state->curB->stacks[g]->position == pos ||
|
||||
( CGI->state->curB->stacks[g]->creature->isDoubleWide() &&
|
||||
( (CGI->state->curB->stacks[g]->attackerOwned && CGI->state->curB->stacks[g]->position-1 == pos) ||
|
||||
(!CGI->state->curB->stacks[g]->attackerOwned && CGI->state->curB->stacks[g]->position+1 == pos)
|
||||
)
|
||||
)
|
||||
)
|
||||
return CGI->state->curB->stacks[g]->ID;
|
||||
}
|
||||
return -1;
|
||||
return CGI->state->battleGetStack(pos);
|
||||
}
|
||||
|
||||
CStack* CCallback::battleGetStackByID(int ID)
|
||||
@ -565,4 +578,13 @@ bool CCallback::battleIsStackMine(int ID)
|
||||
return CGI->state->curB->stacks[h]->owner == player;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool CCallback::battleCanShoot(int ID, int dest) //TODO: finish
|
||||
{
|
||||
if(battleGetStackByID(ID)->creature->isShooting()
|
||||
&& battleGetStack(dest) != -1
|
||||
&& battleGetStackByPos(dest)->owner != battleGetStackByID(ID)->owner
|
||||
&& battleGetStackByPos(dest)->alive)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
29
CCallback.h
29
CCallback.h
@ -2,8 +2,13 @@
|
||||
#define CCALLBACK_H
|
||||
|
||||
#include "global.h"
|
||||
#ifdef _WIN32
|
||||
#include "tchar.h"
|
||||
#include <set>
|
||||
#else
|
||||
#include "tchar_amigaos4.h"
|
||||
#endif
|
||||
#include "CGameState.h"
|
||||
|
||||
class CGHeroInstance;
|
||||
class CGameState;
|
||||
struct CPath;
|
||||
@ -28,9 +33,9 @@ struct UpgradeInfo
|
||||
};
|
||||
|
||||
class ICallback
|
||||
{
|
||||
{
|
||||
public:
|
||||
virtual bool moveHero(int ID, CPath * path, int idtype, int pathType=0)=0;//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero
|
||||
virtual bool moveHero(int ID, CPath * path, int idtype, int pathType=0)=0;//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero
|
||||
//pathType: 0 - nodes are manifestation pos, 1 - nodes are object pos
|
||||
virtual int swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)=0;//swaps creatures between two posiibly different garrisons // TODO: AI-unsafe code - fix it!
|
||||
virtual int mergeStacks(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)=0;//joins first stack tothe second (creatures must be same type)
|
||||
@ -63,7 +68,7 @@ public:
|
||||
|
||||
//battle
|
||||
virtual int battleGetBattlefieldType()=0; // 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship
|
||||
virtual int battleGetObstaclesAtTile(int tile)=0; //returns bitfield
|
||||
virtual int battleGetObstaclesAtTile(int tile)=0; //returns bitfield
|
||||
virtual int battleGetStack(int pos)=0; //returns ID of stack on the tile
|
||||
virtual CStack * battleGetStackByID(int ID)=0; //returns stack info by given ID
|
||||
virtual CStack * battleGetStackByPos(int pos)=0; //returns stack info by given pos
|
||||
@ -74,6 +79,7 @@ public:
|
||||
//virtual bool battleMoveCreature(int ID, int dest)=0; //moves creature with id ID to dest if possible
|
||||
virtual std::vector<int> battleGetAvailableHexes(int ID)=0; //reutrns numbers of hexes reachable by creature with id ID
|
||||
virtual bool battleIsStackMine(int ID)=0; //returns true if stack with id ID belongs to caller
|
||||
virtual bool battleCanShoot(int ID, int dest)=0; //returns true if unit with id ID can shoot to dest
|
||||
};
|
||||
|
||||
struct HeroMoveDetails
|
||||
@ -99,7 +105,7 @@ protected:
|
||||
|
||||
public:
|
||||
//commands
|
||||
bool moveHero(int ID, CPath * path, int idtype, int pathType=0);//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero
|
||||
bool moveHero(int ID, CPath * path, int idtype, int pathType=0);//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero
|
||||
//pathType: 0 - nodes are manifestation pos, 1 - nodes are object pos
|
||||
void selectionMade(int selection, int asker);
|
||||
int swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2);
|
||||
@ -136,7 +142,7 @@ public:
|
||||
|
||||
//battle
|
||||
int battleGetBattlefieldType(); // 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship
|
||||
int battleGetObstaclesAtTile(int tile); //returns bitfield
|
||||
int battleGetObstaclesAtTile(int tile); //returns bitfield
|
||||
int battleGetStack(int pos); //returns ID of stack on the tile
|
||||
CStack * battleGetStackByID(int ID); //returns stack info by given ID
|
||||
CStack * battleGetStackByPos(int pos); //returns stack info by given pos
|
||||
@ -147,9 +153,16 @@ public:
|
||||
//bool battleMoveCreature(int ID, int dest); //moves creature with id ID to dest if possible
|
||||
std::vector<int> battleGetAvailableHexes(int ID); //reutrns numbers of hexes reachable by creature with id ID
|
||||
bool battleIsStackMine(int ID); //returns true if stack with id ID belongs to caller
|
||||
|
||||
bool battleCanShoot(int ID, int dest); //returns true if unit with id ID can shoot to dest
|
||||
|
||||
|
||||
|
||||
//friends
|
||||
friend class CClient;
|
||||
#ifndef __GNUC__
|
||||
friend int _tmain(int argc, _TCHAR* argv[]);
|
||||
#else
|
||||
friend int main(int argc, _TCHAR* argv[]);
|
||||
#endif
|
||||
};
|
||||
#endif //CCALLBACK_H
|
||||
#endif //CCALLBACK_H
|
||||
|
@ -17,7 +17,7 @@
|
||||
extern TTF_Font * GEOR16;
|
||||
CBuildingRect::CBuildingRect(Structure *Str)
|
||||
:str(Str), moi(false), offset(0)
|
||||
{
|
||||
{
|
||||
def = CDefHandler::giveDef(Str->defName);
|
||||
max = def->ourImages.size();
|
||||
|
||||
@ -88,7 +88,7 @@ void CBuildingRect::hover(bool on)
|
||||
MotionInterested::activate();
|
||||
moi = true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if(moi)
|
||||
MotionInterested::deactivate();
|
||||
@ -102,7 +102,7 @@ void CBuildingRect::hover(bool on)
|
||||
}
|
||||
void CBuildingRect::clickLeft (tribool down)
|
||||
{
|
||||
|
||||
|
||||
if(area && (LOCPLINT->castleInt->hBuild==this) && !(indeterminate(down)) && (CSDL_Ext::SDL_GetPixel(area,LOCPLINT->current->motion.x-pos.x,LOCPLINT->current->motion.y-pos.y) != 0)) //na polu
|
||||
{
|
||||
if(pressedL && !down)
|
||||
@ -110,7 +110,7 @@ void CBuildingRect::clickLeft (tribool down)
|
||||
ClickableL::clickLeft(down);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//todo - handle
|
||||
}
|
||||
void CBuildingRect::clickRight (tribool down)
|
||||
@ -123,8 +123,8 @@ void CBuildingRect::clickRight (tribool down)
|
||||
vinya->free = true;
|
||||
vinya->bitmap = CMessage::drawBoxTextBitmapSub
|
||||
(LOCPLINT->playerID,
|
||||
CGI->buildh->buildings[str->townID][str->ID]->description,
|
||||
LOCPLINT->castleInt->bicons->ourImages[str->ID].bitmap,
|
||||
CGI->buildh->buildings[str->townID][str->ID]->description,
|
||||
LOCPLINT->castleInt->bicons->ourImages[str->ID].bitmap,
|
||||
CGI->buildh->buildings[str->townID][str->ID]->name);
|
||||
vinya->pos.x = screen->w/2 - vinya->bitmap->w/2;
|
||||
vinya->pos.y = screen->h/2 - vinya->bitmap->h/2;
|
||||
@ -194,7 +194,11 @@ std::string getBgName(int type) //TODO - co z tym zrobi
|
||||
case 8:
|
||||
return "TBELBACK.bmp";
|
||||
default:
|
||||
#ifndef __GNUC__
|
||||
throw new std::exception("std::string getBgName(int type): invalid type");
|
||||
#else
|
||||
throw new std::exception();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
class SORTHELP
|
||||
@ -209,7 +213,7 @@ public:
|
||||
} srthlp ;
|
||||
|
||||
CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
||||
{
|
||||
{
|
||||
hall = NULL;
|
||||
townInt = BitmapHandler::loadBitmap("TOWNSCRN.bmp");
|
||||
cityBg = BitmapHandler::loadBitmap(getBgName(Town->subID));
|
||||
@ -283,7 +287,11 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
||||
defname = "HALLELEM.DEF";
|
||||
break;
|
||||
default:
|
||||
#ifndef __GNUC__
|
||||
throw new std::exception("Bad town subID");
|
||||
#else
|
||||
throw new std::exception();
|
||||
#endif
|
||||
}
|
||||
bicons = CDefHandler::giveDefEss(defname);
|
||||
//blit buildings on bg
|
||||
@ -368,7 +376,7 @@ void CCastleInterface::enterHall()
|
||||
hallInt->show();
|
||||
}
|
||||
void CCastleInterface::showAll(SDL_Surface * to)
|
||||
{
|
||||
{
|
||||
if (!to)
|
||||
to=screen;
|
||||
blitAt(cityBg,0,0,to);
|
||||
@ -377,7 +385,7 @@ void CCastleInterface::showAll(SDL_Surface * to)
|
||||
townlist->draw();
|
||||
statusbar->show();
|
||||
|
||||
garr->show();
|
||||
garr->show();
|
||||
int pom;
|
||||
|
||||
//draw fort icon
|
||||
@ -426,7 +434,7 @@ void CCastleInterface::showAll(SDL_Surface * to)
|
||||
//print name and income
|
||||
CSDL_Ext::printAt(town->name,85,389,GEOR13,zwykly,to);
|
||||
char temp[10];
|
||||
itoa(town->dailyIncome(),temp,10);
|
||||
SDL_itoa(town->dailyIncome(),temp,10);
|
||||
CSDL_Ext::printAtMiddle(temp,195,442,GEOR13,zwykly,to);
|
||||
|
||||
//blit town icon
|
||||
@ -476,13 +484,13 @@ void CCastleInterface::show(SDL_Surface * to)
|
||||
blitAt(buildings[i]->def->ourImages[0].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
|
||||
blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
|
||||
}
|
||||
else
|
||||
else
|
||||
blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
|
||||
|
||||
if(hBuild==buildings[i] && hBuild->border) //if this this higlighted structure and has border we'll blit it
|
||||
blitAt(hBuild->border,hBuild->pos,to);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void CCastleInterface::activate()
|
||||
{
|
||||
@ -553,7 +561,7 @@ void CCastleInterface::recreateBuildings()
|
||||
{
|
||||
if(seti->first == st->group)
|
||||
{
|
||||
obecny = seti;
|
||||
obecny = seti;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -567,7 +575,11 @@ void CCastleInterface::recreateBuildings()
|
||||
{
|
||||
delete buildings[itpb];
|
||||
buildings.erase(buildings.begin() + itpb);
|
||||
#ifndef __GNUC__
|
||||
obecny->second = st->ID;
|
||||
#else
|
||||
*(const_cast<int*>(&(obecny->second))) = st->ID;
|
||||
#endif
|
||||
buildings.push_back(new CBuildingRect(st));
|
||||
}
|
||||
}
|
||||
@ -588,7 +600,7 @@ void CCastleInterface::recreateBuildings()
|
||||
std::sort(buildings.begin(),buildings.end(),srthlp);
|
||||
|
||||
//code for Mana Vortex (there are two sets of animation frames - one without mage guild and one with
|
||||
if((town->subID == 5) && (town->builtBuildings.find(21)!=town->builtBuildings.end()))
|
||||
if((town->subID == 5) && (town->builtBuildings.find(21)!=town->builtBuildings.end()))
|
||||
{
|
||||
CBuildingRect *vortex = NULL;
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
@ -611,7 +623,7 @@ void CCastleInterface::recreateBuildings()
|
||||
}
|
||||
}
|
||||
//code for the shipyard in the Castle
|
||||
else if((town->subID == 0) && (town->builtBuildings.find(6)!=town->builtBuildings.end()))
|
||||
else if((town->subID == 0) && (town->builtBuildings.find(6)!=town->builtBuildings.end()))
|
||||
{
|
||||
CBuildingRect *shipyard = NULL;
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
@ -640,19 +652,19 @@ void CHallInterface::CResDataBar::show(SDL_Surface * to)
|
||||
char * buf = new char[15];
|
||||
for (int i=0;i<7;i++)
|
||||
{
|
||||
itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
|
||||
SDL_itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
|
||||
CSDL_Ext::printAtMiddle(buf,pos.x + 50 + 76*i,pos.y+pos.h/2,GEOR13,zwykly);
|
||||
}
|
||||
std::vector<std::string> temp;
|
||||
itoa(LOCPLINT->cb->getDate(3),buf,10); temp.push_back(std::string(buf));
|
||||
itoa(LOCPLINT->cb->getDate(2),buf,10); temp.push_back(buf);
|
||||
itoa(LOCPLINT->cb->getDate(1),buf,10); temp.push_back(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(3),buf,10); temp.push_back(std::string(buf));
|
||||
SDL_itoa(LOCPLINT->cb->getDate(2),buf,10); temp.push_back(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(1),buf,10); temp.push_back(buf);
|
||||
CSDL_Ext::printAtMiddle(CSDL_Ext::processStr(
|
||||
CGI->generaltexth->allTexts[62]
|
||||
+": %s, "
|
||||
+ CGI->generaltexth->allTexts[63]
|
||||
+ ": %s, "
|
||||
+ CGI->generaltexth->allTexts[64]
|
||||
+": %s, "
|
||||
+ CGI->generaltexth->allTexts[63]
|
||||
+ ": %s, "
|
||||
+ CGI->generaltexth->allTexts[64]
|
||||
+ ": %s",temp)
|
||||
,pos.x+545+(pos.w-545)/2,pos.y+pos.h/2,GEOR13,zwykly);
|
||||
temp.clear();
|
||||
@ -715,7 +727,7 @@ void CHallInterface::CBuildingBox::show(SDL_Surface * to)
|
||||
int pom, pom2=-1;
|
||||
switch (state)
|
||||
{
|
||||
case 4:
|
||||
case 4:
|
||||
pom = 0;
|
||||
pom2 = 0;
|
||||
break;
|
||||
@ -790,7 +802,7 @@ CHallInterface::CHallInterface(CCastleInterface * owner)
|
||||
{
|
||||
if(
|
||||
(owner->town->builtBuildings.find(CGI->buildh->hall[owner->town->subID].second[i][j][k]))
|
||||
==
|
||||
==
|
||||
(owner->town->builtBuildings.end()) )
|
||||
{
|
||||
int x = 34 + 194*j,
|
||||
@ -828,7 +840,7 @@ CHallInterface::CHallInterface(CCastleInterface * owner)
|
||||
}
|
||||
|
||||
//TODO: check if capital is already built, check if there is water for shipyard
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -967,9 +979,9 @@ std::string CHallInterface::CBuildWindow::getTextForState(int state)
|
||||
std::set<int> used;
|
||||
used.insert(bid);
|
||||
std::set<int> reqs;
|
||||
|
||||
|
||||
for(std::set<int>::iterator i=CGI->townh->requirements[tid][bid].begin();i!=CGI->townh->requirements[tid][bid].end();i++)
|
||||
if (LOCPLINT->castleInt->town->builtBuildings.find(*i) == LOCPLINT->castleInt->town->builtBuildings.end())
|
||||
if (LOCPLINT->castleInt->town->builtBuildings.find(*i) == LOCPLINT->castleInt->town->builtBuildings.end())
|
||||
reqs.insert(*i);
|
||||
while(true)
|
||||
{
|
||||
@ -986,7 +998,7 @@ std::string CHallInterface::CBuildWindow::getTextForState(int state)
|
||||
)
|
||||
{
|
||||
if(LOCPLINT->castleInt->town->builtBuildings.find(*j) == //this building is not built
|
||||
LOCPLINT->castleInt->town->builtBuildings.end())
|
||||
LOCPLINT->castleInt->town->builtBuildings.end())
|
||||
reqs.insert(*j);
|
||||
}
|
||||
}
|
||||
@ -1012,12 +1024,12 @@ CHallInterface::CBuildWindow::CBuildWindow(int Tid, int Bid, int State, bool Mod
|
||||
:tid(Tid),bid(Bid),mode(Mode), state(State)
|
||||
{
|
||||
SDL_Surface *hhlp = BitmapHandler::loadBitmap("TPUBUILD.bmp");
|
||||
graphics->blueToPlayersAdv(hhlp,LOCPLINT->playerID);
|
||||
bitmap = SDL_ConvertSurface(hhlp,screen->format,0); //na 8bitowej mapie by sie psulo
|
||||
SDL_SetColorKey(hhlp,SDL_SRCCOLORKEY,SDL_MapRGB(hhlp->format,0,255,255));
|
||||
SDL_FreeSurface(hhlp);
|
||||
pos.x = screen->w/2 - bitmap->w/2;
|
||||
pos.y = screen->h/2 - bitmap->h/2;
|
||||
graphics->blueToPlayersAdv(bitmap,LOCPLINT->playerID);
|
||||
blitAt(LOCPLINT->castleInt->bicons->ourImages[bid].bitmap,125,50,bitmap);
|
||||
std::vector<std::string> pom; pom.push_back(CGI->buildh->buildings[tid][bid]->name);
|
||||
CSDL_Ext::printAtMiddleWB(CGI->buildh->buildings[tid][bid]->description,197,168,GEOR16,40,zwykly,bitmap);
|
||||
@ -1033,7 +1045,7 @@ CHallInterface::CBuildWindow::CBuildWindow(int Tid, int Bid, int State, bool Mod
|
||||
{
|
||||
if(!CGI->buildh->buildings[tid][bid]->resources[cn])
|
||||
continue;
|
||||
itoa(CGI->buildh->buildings[tid][bid]->resources[cn],buf,10);
|
||||
SDL_itoa(CGI->buildh->buildings[tid][bid]->resources[cn],buf,10);
|
||||
if(it<4)
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(buf,(bitmap->w/2-row1w/2)+77*it+16,ah+42,GEOR16,zwykly,bitmap);
|
||||
@ -1066,4 +1078,4 @@ CHallInterface::CBuildWindow::~CBuildWindow()
|
||||
delete buy;
|
||||
delete cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
|
||||
class CBuildWindow: public IShowable, public ClickableR
|
||||
{
|
||||
public:
|
||||
public:
|
||||
int tid, bid, state; //town id, building id, state
|
||||
bool mode; // 0 - normal (with buttons), 1 - r-click popup
|
||||
SDL_Surface * bitmap; //main window bitmap, with blitted res/text, without buttons/subtitle in "statusbar"
|
||||
@ -129,4 +129,4 @@ public:
|
||||
void show(SDL_Surface * to=NULL);
|
||||
void activate();
|
||||
void deactivate();
|
||||
};
|
||||
};
|
||||
|
@ -53,7 +53,7 @@ int internalFunc(void * callback)
|
||||
boost::filesystem::create_directory("Extracted_txts");
|
||||
std::cout<<"Command accepted. Opening .lod file...\t";
|
||||
CLodHandler * txth = new CLodHandler;
|
||||
txth->init(std::string("Data\\H3bitmap.lod"),"data");
|
||||
txth->init(std::string(DATA_DIR "Data" PATHSEPARATOR "H3bitmap.lod"),"data");
|
||||
std::cout<<"done.\nScanning .lod file\n";
|
||||
int curp=0;
|
||||
std::string pattern = ".TXT";
|
||||
@ -74,6 +74,9 @@ int internalFunc(void * callback)
|
||||
std::cout<<"\rExtracting done :)\n";
|
||||
}
|
||||
vector<Coordinate>* p;
|
||||
int heroX;
|
||||
int heroY;
|
||||
int heroZ;
|
||||
switch (*cn.c_str())
|
||||
{
|
||||
//case 'P':
|
||||
@ -144,6 +147,7 @@ int internalFunc(void * callback)
|
||||
//SDL_Delay(100);
|
||||
//delete p;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -8,6 +8,12 @@ public:
|
||||
void runConsole();
|
||||
|
||||
friend class CClient;
|
||||
|
||||
#ifndef __GNUC__
|
||||
friend int _tmain(int argc, _TCHAR* argv[]);
|
||||
#else
|
||||
friend int main(int argc, _TCHAR* argv[]);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif //CCONSOLEHANDLER_H
|
||||
#endif //CCONSOLEHANDLER_H
|
||||
|
@ -37,4 +37,4 @@ void CCursorHandler::draw1()
|
||||
void CCursorHandler::draw2()
|
||||
{
|
||||
blitAt(help,xpos,ypos);
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //CCURSORHANDLER_H
|
||||
#endif //CCURSORHANDLER_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "stdafx.h"
|
||||
#include "CGameInfo.h"
|
||||
|
||||
CGameInfo * CGI;
|
||||
CGameInfo * CGI;
|
||||
|
@ -2,6 +2,10 @@
|
||||
#define CGAMEINFO_H
|
||||
#include "global.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
@ -60,4 +64,4 @@ public:
|
||||
CScreenHandler * screenh;
|
||||
};
|
||||
|
||||
#endif //CGAMEINFO_H
|
||||
#endif //CGAMEINFO_H
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "stdafx.h"
|
||||
#include "CGameInterface.h"
|
||||
#include "CAdvMapInterface.h"
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "CMessage.h"
|
||||
#include "mapHandler.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "SDL_framerate.h"
|
||||
#include "CScreenHandler.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "CCallback.h"
|
||||
#include "SDL_Extensions.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include <sstream>
|
||||
#include "hch/CHeroHandler.h"
|
||||
#include "SDL_framerate.h"
|
||||
#include "AI/EmptyAI/CEmptyAI.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h> //for .dll libs
|
||||
@ -28,6 +28,7 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
|
||||
CGlobalAI * ret=NULL;
|
||||
CGlobalAI*(*getAI)();
|
||||
void(*getName)(char*);
|
||||
|
||||
#ifdef _WIN32
|
||||
HINSTANCE dll = LoadLibraryA(dllname.c_str());
|
||||
if (!dll)
|
||||
@ -42,11 +43,17 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
|
||||
; //TODO: handle AI library on Linux
|
||||
#endif
|
||||
char * temp = new char[50];
|
||||
#if !defined(__amigaos4__) && !defined(__unix__)
|
||||
getName(temp);
|
||||
#endif
|
||||
std::cout << "Loaded .dll with AI named " << temp << std::endl;
|
||||
delete temp;
|
||||
#if !defined(__amigaos4__) && !defined(__unix__)
|
||||
ret = getAI();
|
||||
ret->init(cb);
|
||||
#else
|
||||
//ret = new CEmptyAI();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
//CGlobalAI::CGlobalAI()
|
||||
|
@ -28,9 +28,9 @@ class CObstacle
|
||||
struct BattleAction
|
||||
{
|
||||
bool side; //who made this action: false - left, true - right player
|
||||
int stackNumber;//stack ID, -1 left hero, -2 right hero,
|
||||
int actionType; // 0 = Cancel BattleAction 1 = Hero cast a spell 2 = Walk 3 = Defend 4 = Retreat from the battle 5 = Surrender 6 = Walk and Attack 7 = Shoot 8 = Wait 9 = Catapult 10 = Monster casts a spell (i.e. Faerie Dragons)
|
||||
int destinationTile;
|
||||
int stackNumber;//stack ID, -1 left hero, -2 right hero,
|
||||
int actionType; // 0 = Cancel BattleAction 1 = Hero cast a spell 2 = Walk 3 = Defend 4 = Retreat from the battle 5 = Surrender 6 = Walk and Attack 7 = Shoot 8 = Wait 9 = Catapult 10 = Monster casts a spell (i.e. Faerie Dragons)
|
||||
int destinationTile;
|
||||
int additionalInfo; // e.g. spell number if type is 1 || 10
|
||||
};
|
||||
|
||||
@ -40,7 +40,7 @@ struct StackState
|
||||
int attackBonus, defenseBonus, healthBonus, speedBonus;
|
||||
int currentHealth;
|
||||
int shotsLeft;
|
||||
std::set<int> effects;
|
||||
std::set<int> effects;
|
||||
int morale, luck;
|
||||
};
|
||||
|
||||
@ -50,12 +50,12 @@ public:
|
||||
bool human;
|
||||
int playerID, serialID;
|
||||
|
||||
virtual void init(ICallback * CB)=0{};
|
||||
virtual void yourTurn()=0{};
|
||||
virtual void heroKilled(const CGHeroInstance*)=0{};
|
||||
virtual void heroCreated(const CGHeroInstance*)=0{};
|
||||
virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val)=0{};
|
||||
virtual void heroMoved(const HeroMoveDetails & details)=0{};
|
||||
virtual void init(ICallback * CB){};
|
||||
virtual void yourTurn(){};
|
||||
virtual void heroKilled(const CGHeroInstance*){};
|
||||
virtual void heroCreated(const CGHeroInstance*){};
|
||||
virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val){};
|
||||
virtual void heroMoved(const HeroMoveDetails & details){};
|
||||
virtual void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town){};
|
||||
virtual void tileRevealed(int3 pos){};
|
||||
virtual void tileHidden(int3 pos){};
|
||||
@ -64,7 +64,7 @@ public:
|
||||
virtual void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID)=0{};
|
||||
virtual void garrisonChanged(const CGObjectInstance * obj){};
|
||||
virtual void buildChanged(const CGTownInstance *town, int buildingID, int what){}; //what: 1 - built, 2 - demolished
|
||||
//battle call-ins
|
||||
//battle call-ins
|
||||
virtual void battleStart(CCreatureSet * army1, CCreatureSet * army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
|
||||
virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles){}; //called when battlefield is prepared, prior the battle beginning
|
||||
virtual void battleNewRound(int round){}; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
|
||||
@ -74,8 +74,8 @@ public:
|
||||
virtual void battleEnd(CCreatureSet * army1, CCreatureSet * army2, CArmedInstance *hero1, CArmedInstance *hero2, std::vector<int> capturedArtifacts, int expForWinner, bool winner){};
|
||||
virtual void battleStackMoved(int ID, int dest, bool startMoving, bool endMoving)=0;
|
||||
virtual void battleStackAttacking(int ID, int dest)=0;
|
||||
virtual void battleStackIsAttacked(int ID, int dmg, int killed, int IDby)=0;
|
||||
virtual void battleStackKilled(int ID, int dmg, int killed, int IDby)=0;
|
||||
virtual void battleStackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting)=0;
|
||||
virtual void battleStackKilled(int ID, int dmg, int killed, int IDby, bool byShooting)=0;
|
||||
//
|
||||
|
||||
};
|
||||
@ -93,8 +93,8 @@ public:
|
||||
virtual void heroCreated(const CGHeroInstance*){};
|
||||
virtual void battleStackMoved(int ID, int dest, bool startMoving, bool endMoving){};
|
||||
virtual void battleStackAttacking(int ID, int dest){};
|
||||
virtual void battleStackIsAttacked(int ID, int dmg, int killed, int IDby){};
|
||||
virtual void battleStackKilled(int ID, int dmg, int killed, int IDby){};
|
||||
virtual void battleStackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting){};
|
||||
virtual void battleStackKilled(int ID, int dmg, int killed, int IDby, bool byShooting){};
|
||||
virtual BattleAction activeStack(int stackID) {BattleAction ba; ba.actionType = 3; ba.stackNumber = stackID; return ba;};
|
||||
};
|
||||
#endif //CGAMEINTERFACE_H
|
||||
#endif //CGAMEINTERFACE_H
|
||||
|
168
CGameState.cpp
168
CGameState.cpp
@ -922,6 +922,11 @@ void CGameState::battle(CCreatureSet * army1, CCreatureSet * army2, int3 tile, C
|
||||
battleAttackCreatureStack(ba.stackNumber, ba.destinationTile);
|
||||
break;
|
||||
}
|
||||
case 7: //shoot
|
||||
{
|
||||
battleShootCreatureStack(ba.stackNumber, ba.destinationTile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1030,7 +1035,7 @@ bool CGameState::battleMoveCreatureStack(int ID, int dest)
|
||||
if(curStack->attackerOwned ? (v%17)==1 : (v%17)==15)
|
||||
accessibility[v] = false;
|
||||
}
|
||||
if(!accessibility[dest])
|
||||
if(!stackAtEnd && !accessibility[dest])
|
||||
return false;
|
||||
int predecessor[187]; //for getting the Path
|
||||
for(int b=0; b<187; ++b)
|
||||
@ -1111,43 +1116,7 @@ bool CGameState::battleMoveCreatureStack(int ID, int dest)
|
||||
{
|
||||
LOCPLINT->battleStackAttacking(ID, path[v]);
|
||||
//counting dealt damage
|
||||
int numberOfCres = curStack->amount; //number of attacking creatures
|
||||
int attackDefenseBonus = curStack->creature->attack - curB->stacks[numberOfStackAtEnd]->creature->defence;
|
||||
int damageBase = 0;
|
||||
if(curStack->creature->damageMax == curStack->creature->damageMin) //constant damage
|
||||
{
|
||||
damageBase = curStack->creature->damageMin;
|
||||
}
|
||||
else
|
||||
{
|
||||
damageBase = ran()%(curStack->creature->damageMax - curStack->creature->damageMin) + curStack->creature->damageMin + 1;
|
||||
}
|
||||
|
||||
float dmgBonusMultiplier = 1.0;
|
||||
if(attackDefenseBonus < 0) //decreasing dmg
|
||||
{
|
||||
if(0.02f * (-attackDefenseBonus) > 0.3f)
|
||||
{
|
||||
dmgBonusMultiplier += -0.3f;
|
||||
}
|
||||
else
|
||||
{
|
||||
dmgBonusMultiplier += 0.02f * attackDefenseBonus;
|
||||
}
|
||||
}
|
||||
else //increasing dmg
|
||||
{
|
||||
if(0.05f * attackDefenseBonus > 4.0f)
|
||||
{
|
||||
dmgBonusMultiplier += 4.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
dmgBonusMultiplier += 0.05f * attackDefenseBonus;
|
||||
}
|
||||
}
|
||||
|
||||
int finalDmg = (float)damageBase * (float)curStack->amount * dmgBonusMultiplier;
|
||||
int finalDmg = calculateDmg(curStack, curB->stacks[numberOfStackAtEnd]);
|
||||
|
||||
//applying damages
|
||||
int cresKilled = finalDmg / curB->stacks[numberOfStackAtEnd]->creature->hitPoints;
|
||||
@ -1168,12 +1137,12 @@ bool CGameState::battleMoveCreatureStack(int ID, int dest)
|
||||
if(curB->stacks[numberOfStackAtEnd]->amount<=0) //stack killed
|
||||
{
|
||||
curB->stacks[numberOfStackAtEnd]->amount = 0;
|
||||
LOCPLINT->battleStackKilled(curB->stacks[numberOfStackAtEnd]->ID, finalDmg, std::min(cresKilled, cresInstackBefore) , ID);
|
||||
LOCPLINT->battleStackKilled(curB->stacks[numberOfStackAtEnd]->ID, finalDmg, std::min(cresKilled, cresInstackBefore) , ID, false);
|
||||
curB->stacks[numberOfStackAtEnd]->alive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->battleStackIsAttacked(curB->stacks[numberOfStackAtEnd]->ID, finalDmg, std::min(cresKilled, cresInstackBefore), ID);
|
||||
LOCPLINT->battleStackIsAttacked(curB->stacks[numberOfStackAtEnd]->ID, finalDmg, std::min(cresKilled, cresInstackBefore), ID, false);
|
||||
}
|
||||
|
||||
//damage applied
|
||||
@ -1201,6 +1170,125 @@ bool CGameState::battleAttackCreatureStack(int ID, int dest)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameState::battleShootCreatureStack(int ID, int dest)
|
||||
{/*
|
||||
CStack * curStack = NULL;
|
||||
for(int y=0; y<curB->stacks.size(); ++y)
|
||||
{
|
||||
if(curB->stacks[y]->ID == ID)
|
||||
{
|
||||
curStack = curB->stacks[y];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!curStack)
|
||||
return false;
|
||||
int IDOfStackAtEnd = battleGetStack(dest);
|
||||
int numberOfStackAtEnd = -1;
|
||||
for(int v=0; v<curB->stacks.size(); ++v)
|
||||
{
|
||||
if(curB->stacks[v]->ID == IDOfStackAtEnd)
|
||||
{
|
||||
numberOfStackAtEnd = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(IDOfStackAtEnd == -1 || curB->stacks[numberOfStackAtEnd]->owner == curStack->owner || !curB->stacks[numberOfStackAtEnd]->alive)
|
||||
return false;
|
||||
|
||||
LOCPLINT->battleStackIsShooting(ID, dest);
|
||||
|
||||
//counting dealt damage
|
||||
int finalDmg = calculateDmg(curStack, curB->stacks[numberOfStackAtEnd]);
|
||||
|
||||
//applying damages
|
||||
int cresKilled = finalDmg / curB->stacks[ID]->creature->hitPoints;
|
||||
int damageFirst = finalDmg % curB->stacks[ID]->creature->hitPoints;
|
||||
|
||||
if( curB->stacks[numberOfStackAtEnd]->firstHPleft <= damageFirst )
|
||||
{
|
||||
curB->stacks[numberOfStackAtEnd]->amount -= 1;
|
||||
curB->stacks[numberOfStackAtEnd]->firstHPleft += curB->stacks[numberOfStackAtEnd]->creature->hitPoints - damageFirst;
|
||||
}
|
||||
else
|
||||
{
|
||||
curB->stacks[numberOfStackAtEnd]->firstHPleft -= damageFirst;
|
||||
}
|
||||
|
||||
int cresInstackBefore = curB->stacks[numberOfStackAtEnd]->amount;
|
||||
curB->stacks[numberOfStackAtEnd]->amount -= cresKilled;
|
||||
if(curB->stacks[numberOfStackAtEnd]->amount<=0) //stack killed
|
||||
{
|
||||
curB->stacks[numberOfStackAtEnd]->amount = 0;
|
||||
LOCPLINT->battleStackKilled(curB->stacks[numberOfStackAtEnd]->ID, finalDmg, std::min(cresKilled, cresInstackBefore), ID, true);
|
||||
curB->stacks[numberOfStackAtEnd]->alive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->battleStackIsAttacked(curB->stacks[numberOfStackAtEnd]->ID, finalDmg, std::min(cresKilled, cresInstackBefore), ID, true);
|
||||
}
|
||||
|
||||
//damage applied*/
|
||||
return true;
|
||||
}
|
||||
|
||||
int CGameState::battleGetStack(int pos)
|
||||
{
|
||||
for(int g=0; g<curB->stacks.size(); ++g)
|
||||
{
|
||||
if(curB->stacks[g]->position == pos ||
|
||||
( curB->stacks[g]->creature->isDoubleWide() &&
|
||||
( (curB->stacks[g]->attackerOwned && curB->stacks[g]->position-1 == pos) ||
|
||||
(!curB->stacks[g]->attackerOwned && curB->stacks[g]->position+1 == pos)
|
||||
)
|
||||
)
|
||||
)
|
||||
return curB->stacks[g]->ID;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CGameState::calculateDmg(const CStack* attacker, const CStack* defender)
|
||||
{
|
||||
int attackDefenseBonus = attacker->creature->attack - defender->creature->defence;
|
||||
int damageBase = 0;
|
||||
if(attacker->creature->damageMax == attacker->creature->damageMin) //constant damage
|
||||
{
|
||||
damageBase = attacker->creature->damageMin;
|
||||
}
|
||||
else
|
||||
{
|
||||
damageBase = rand()%(attacker->creature->damageMax - attacker->creature->damageMin) + attacker->creature->damageMin + 1;
|
||||
}
|
||||
|
||||
float dmgBonusMultiplier = 1.0;
|
||||
if(attackDefenseBonus < 0) //decreasing dmg
|
||||
{
|
||||
if(0.02f * (-attackDefenseBonus) > 0.3f)
|
||||
{
|
||||
dmgBonusMultiplier += -0.3f;
|
||||
}
|
||||
else
|
||||
{
|
||||
dmgBonusMultiplier += 0.02f * attackDefenseBonus;
|
||||
}
|
||||
}
|
||||
else //increasing dmg
|
||||
{
|
||||
if(0.05f * attackDefenseBonus > 4.0f)
|
||||
{
|
||||
dmgBonusMultiplier += 4.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
dmgBonusMultiplier += 0.05f * attackDefenseBonus;
|
||||
}
|
||||
}
|
||||
|
||||
return (float)damageBase * (float)attacker->amount * dmgBonusMultiplier;
|
||||
}
|
||||
|
||||
std::vector<int> CGameState::battleGetRange(int ID)
|
||||
{/*
|
||||
int initialPlace=-1; //position of unit
|
||||
|
@ -3,7 +3,11 @@
|
||||
#include "global.h"
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#include "tchar_amigaos4.h"
|
||||
#endif
|
||||
|
||||
class CScriptCallback;
|
||||
class CCallback;
|
||||
@ -78,7 +82,6 @@ private:
|
||||
ui32 day; //total number of days in game
|
||||
Mapa * map;
|
||||
std::map<ui8,PlayerState> players; //ID <-> playerstate
|
||||
|
||||
std::map<int, CGDefInfo*> villages, forts, capitols; //def-info for town graphics
|
||||
|
||||
boost::shared_mutex *mx;
|
||||
@ -94,6 +97,9 @@ private:
|
||||
void battle(CCreatureSet * army1, CCreatureSet * army2, int3 tile, CArmedInstance *hero1, CArmedInstance *hero2);
|
||||
bool battleMoveCreatureStack(int ID, int dest);
|
||||
bool battleAttackCreatureStack(int ID, int dest);
|
||||
bool battleShootCreatureStack(int ID, int dest);
|
||||
int battleGetStack(int pos); //returns ID of stack at given tile
|
||||
static int calculateDmg(const CStack* attacker, const CStack* defender); //TODO: add additional conditions and require necessary data
|
||||
std::vector<int> battleGetRange(int ID); //called by std::vector<int> CCallback::battleGetAvailableHexes(int ID);
|
||||
public:
|
||||
int getDate(int mode=0) const; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
|
||||
|
@ -47,7 +47,6 @@ CHeroWindow::CHeroWindow(int playerColor):
|
||||
gar3button = new AdventureMapButton(CGI->generaltexth->heroscrn[24], CGI->generaltexth->heroscrn[30], boost::bind(&CHeroWindow::gar3,this), 546, 527, "hsbtns7.def", false, NULL, false);
|
||||
gar4button = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[32], boost::function<void()>(), 604, 527, "hsbtns9.def", false, NULL, false);
|
||||
|
||||
//boost::bind(&CGarrisonInt::splitClick,garInt)
|
||||
leftArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind(&CHeroWindow::leftArtRoller,this), 379, 364, "hsbtns3.def", false, NULL, false);
|
||||
rightArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind(&CHeroWindow::rightArtRoller,this), 632, 364, "hsbtns5.def", false, NULL, false);
|
||||
|
||||
@ -191,7 +190,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
|
||||
CGHeroInstance *hero = const_cast<CGHeroInstance*>(Hero); //but don't modify hero! - it's only for easy map reading
|
||||
if(!hero) //something strange... no hero? it shouldn't happen
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
curHero = hero;
|
||||
|
||||
@ -236,7 +235,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
|
||||
secSkillAreas[g]->text = hlp.substr(1, hlp.size()-2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
char * hlpp = new char[200];
|
||||
sprintf(hlpp, CGI->generaltexth->heroscrn[21].c_str(), CGI->abilh->levels[hero->secSkills[g].second].c_str(), CGI->abilh->abilities[hero->secSkills[g].first]->name.c_str());
|
||||
secSkillAreas[g]->hoverText = std::string(hlpp);
|
||||
@ -632,12 +631,12 @@ void CHeroWindow::deactivate()
|
||||
}
|
||||
|
||||
for(int f=0; f<artWorn.size(); ++f)
|
||||
{
|
||||
{
|
||||
if(artWorn[f])
|
||||
artWorn[f]->deactivate();
|
||||
}
|
||||
for(int f=0; f<backpack.size(); ++f)
|
||||
{
|
||||
{
|
||||
if(backpack[f])
|
||||
backpack[f]->deactivate();
|
||||
}
|
||||
@ -737,7 +736,7 @@ void CHeroWindow::redrawCurBack()
|
||||
blitAt(skillpics->ourImages[4].bitmap, 20, 230, curBack);
|
||||
blitAt(skillpics->ourImages[3].bitmap, 162, 230, curBack);
|
||||
|
||||
blitAt(graphics->portraitLarge[curHero->subID], 19, 19, curBack);
|
||||
blitAt(graphics->portraitLarge[curHero->portrait], 19, 19, curBack);
|
||||
|
||||
CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack);
|
||||
|
||||
@ -802,14 +801,14 @@ void CHeroWindow::redrawCurBack()
|
||||
for(int g=0; g<LOCPLINT->cb->howManyHeroes(); ++g)
|
||||
{
|
||||
const CGHeroInstance * cur = LOCPLINT->cb->getHeroInfo(player, g, false);
|
||||
blitAt(graphics->portraitSmall[cur->subID], 611, 87+g*54, curBack);
|
||||
blitAt(graphics->portraitSmall[cur->portrait], 611, 87+g*54, curBack);
|
||||
//printing yellow border
|
||||
if(cur->name == curHero->name)
|
||||
{
|
||||
for(int f=0; f<graphics->portraitSmall[cur->subID]->w; ++f)
|
||||
for(int f=0; f<graphics->portraitSmall[cur->portrait]->w; ++f)
|
||||
{
|
||||
for(int h=0; h<graphics->portraitSmall[cur->subID]->h; ++h)
|
||||
if(f==0 || h==0 || f==graphics->portraitSmall[cur->subID]->w-1 || h==graphics->portraitSmall[cur->subID]->h-1)
|
||||
for(int h=0; h<graphics->portraitSmall[cur->portrait]->h; ++h)
|
||||
if(f==0 || h==0 || f==graphics->portraitSmall[cur->portrait]->w-1 || h==graphics->portraitSmall[cur->portrait]->h-1)
|
||||
{
|
||||
CSDL_Ext::SDL_PutPixel(curBack, 611+f, 87+g*54+h, 240, 220, 120);
|
||||
}
|
||||
@ -914,7 +913,7 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
|
||||
if(this->fitsHere(ourWindow->activeArtPlace->ourArt) && ourWindow->activeArtPlace->fitsHere(this->ourArt))
|
||||
{
|
||||
//swap artifacts
|
||||
|
||||
|
||||
LOCPLINT->cb->swapArifacts(
|
||||
ourWindow->curHero,
|
||||
this->myNumber>=0,
|
||||
@ -936,7 +935,7 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
|
||||
text = ourArt->description;
|
||||
else
|
||||
text = std::string();
|
||||
|
||||
|
||||
ourWindow->activeArtPlace->clicked = false;
|
||||
ourWindow->activeArtPlace = NULL;
|
||||
}
|
||||
@ -1038,6 +1037,10 @@ void LClickableArea::clickLeft(boost::logic::tribool down)
|
||||
//{
|
||||
// LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RClickableArea::activate()
|
||||
@ -1054,13 +1057,21 @@ void RClickableArea::clickRight(boost::logic::tribool down)
|
||||
//{
|
||||
// LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LRClickableAreaWText::clickLeft(boost::logic::tribool down)
|
||||
{
|
||||
if(!down)
|
||||
{
|
||||
#ifndef __amigaos4__
|
||||
LOCPLINT->showInfoDialog(text, std::vector<SComponent*>());
|
||||
#else
|
||||
#warning error here!
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void LRClickableAreaWText::clickRight(boost::logic::tribool down)
|
||||
@ -1104,7 +1115,11 @@ void LRClickableAreaWTextComp::clickLeft(boost::logic::tribool down)
|
||||
{
|
||||
if((!down) && pressedL)
|
||||
{
|
||||
#ifndef __amigaos4__
|
||||
LOCPLINT->showInfoDialog(text, std::vector<SComponent*>(1, new SComponent(SComponent::Etype(baseType), type, bonus)));
|
||||
#else
|
||||
#warning error here!
|
||||
#endif
|
||||
}
|
||||
ClickableL::clickLeft(down);
|
||||
}
|
||||
|
@ -135,5 +135,5 @@ public:
|
||||
|
||||
//friends
|
||||
friend void CArtPlace::clickLeft(tribool down);
|
||||
friend CPlayerInterface;
|
||||
friend class CPlayerInterface;
|
||||
};
|
||||
|
79
CLua.cpp
79
CLua.cpp
@ -32,7 +32,7 @@ bool getGlobalFunc(lua_State * L, std::string fname)
|
||||
|
||||
CObjectScript::CObjectScript()
|
||||
{
|
||||
language = ESLan::UNDEF;
|
||||
language = UNDEF;
|
||||
//std::cout << "Tworze obiekt objectscript "<<this<<std::endl;
|
||||
}
|
||||
|
||||
@ -77,6 +77,10 @@ void CLua::open(std::string initpath)
|
||||
// temp += initpath;
|
||||
// throw std::exception(temp.c_str());
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
void CLua::registerCLuaCallback()
|
||||
{
|
||||
@ -109,12 +113,16 @@ void CLua::findFS(std::string fname)
|
||||
// lua_settop(is, 0);
|
||||
// throw new std::exception((fname + ": function not defined").c_str()); // the call is not defined
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
#undef LST
|
||||
|
||||
CLuaObjectScript::CLuaObjectScript(std::string filename)
|
||||
{
|
||||
language = ESLan::LUA;
|
||||
language = LUA;
|
||||
open(filename);
|
||||
//binit = bnewobject = bonherovisit = brightext = false;
|
||||
//std::cout << "Tworze obiekt CLuaObjectScript "<<this<<std::endl;
|
||||
@ -145,6 +153,10 @@ void CLuaObjectScript::newObject(int objid)
|
||||
// throw new std::exception(("Failed to call "+genFN("newObject",os->ID)+" function in lua script.").c_str());
|
||||
//}
|
||||
//lua_settop(is, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
void CLuaObjectScript::onHeroVisit(int objid, int heroID)
|
||||
@ -158,6 +170,10 @@ void CLuaObjectScript::onHeroVisit(int objid, int heroID)
|
||||
// throw new std::exception(("Failed to call "+genFN("heroVisit",os->ID)+" function in lua script.").c_str());
|
||||
//}
|
||||
//lua_settop(is, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
//std::string CLuaObjectScript::hoverText(int objid)
|
||||
//{
|
||||
@ -276,6 +292,8 @@ void CVisitableOPH::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
|
||||
//weko.push_back(new SComponent(SComponent::primskill,w,vvv));
|
||||
//cb->showInfoDialog(cb->getHeroOwner(heroID),VLC->objh->advobtxt[ot],&weko);
|
||||
//break;
|
||||
|
||||
|
||||
}
|
||||
case 100:
|
||||
{
|
||||
@ -284,6 +302,8 @@ void CVisitableOPH::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
|
||||
//weko.push_back(new SComponent(SComponent::experience,0,vvv));
|
||||
//cb->showInfoDialog(cb->getHeroOwner(heroID),VLC->objh->advobtxt[ot],&weko);
|
||||
//break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -308,6 +328,46 @@ std::vector<int> CVisitableOPH::yourObjects()
|
||||
void CVisitableOPW::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
|
||||
{
|
||||
DEFOS;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int mid;
|
||||
switch (os->ID)
|
||||
{
|
||||
@ -450,6 +510,15 @@ void CMines::onHeroVisit(int objid, int heroID)
|
||||
iw.player = h->tempOwner;
|
||||
iw.components.push_back(Component(2,os->subID,vv,-1));
|
||||
cb->showInfoDialog(&iw);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
std::vector<int> CMines::yourObjects()
|
||||
{
|
||||
@ -595,6 +664,10 @@ void CPickable::chosen(int which)
|
||||
//for (int i=0;i<tempStore.size();i++)
|
||||
// delete tempStore[i];
|
||||
//tempStore.clear();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
std::vector<int> CPickable::yourObjects() //returns IDs of objects which are handled by script
|
||||
@ -743,4 +816,4 @@ std::vector<int> CCreatureGen::yourObjects() //returns IDs of objects which are
|
||||
std::vector<int> ret(1);
|
||||
ret.push_back(17); //cregen1
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
17
CLua.h
17
CLua.h
@ -1,6 +1,11 @@
|
||||
#pragma once
|
||||
#include "global.h"
|
||||
//#include "lstate.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
class CLua;
|
||||
@ -32,7 +37,7 @@ public:
|
||||
virtual void onHeroVisit(int objid, int heroID){};
|
||||
virtual void onHeroLeave(int objid, int heroID){};
|
||||
virtual std::string hoverText(int objid){return "";};
|
||||
virtual void newTurn (){};
|
||||
virtual void newTurn (){};
|
||||
|
||||
|
||||
//TODO: implement functions below:
|
||||
@ -71,7 +76,7 @@ public:
|
||||
void findF2(std::string fname);
|
||||
void findFS(std::string fname);
|
||||
|
||||
|
||||
|
||||
friend CGameState;
|
||||
};
|
||||
|
||||
@ -98,7 +103,7 @@ class CVisitableOPH : public CCPPObjectScript //once per hero
|
||||
public:
|
||||
CVisitableOPH(CScriptCallback * CB):CCPPObjectScript(CB){};
|
||||
std::map<int,std::set<int> > visitors;
|
||||
|
||||
|
||||
void onNAHeroVisit(int objid, int heroID, bool alreadyVisited);
|
||||
void newObject(int objid);
|
||||
void onHeroVisit(int objid, int heroID);
|
||||
@ -114,7 +119,7 @@ public:
|
||||
void newObject(int objid);
|
||||
void onHeroVisit(int objid, int heroID);
|
||||
std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
|
||||
void newTurn ();
|
||||
void newTurn ();
|
||||
};
|
||||
|
||||
class CMines : public CCPPObjectScript //flaggable, and giving resource at each day
|
||||
@ -127,7 +132,7 @@ public:
|
||||
void newObject(int objid);
|
||||
void onHeroVisit(int objid, int heroID);
|
||||
std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
|
||||
void newTurn ();
|
||||
void newTurn ();
|
||||
};
|
||||
|
||||
class CPickable : public CCPPObjectScript, public IChosen //pickable - resources, artifacts, etc
|
||||
@ -180,4 +185,4 @@ public:
|
||||
void newObject(int objid);
|
||||
void onHeroVisit(int objid, int heroID);
|
||||
std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
|
||||
};
|
||||
};
|
||||
|
@ -1,8 +1,17 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
}
|
||||
#endif
|
||||
|
||||
//#include <luabind/luabind.hpp>
|
||||
//#include <luabind/function.hpp>
|
||||
//#include <luabind/class.hpp>
|
||||
@ -38,6 +47,30 @@ void CLuaHandler::test()
|
||||
// }
|
||||
//}
|
||||
//lua_close (lua);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -89,4 +122,4 @@ std::vector<std::string> * CLuaHandler::functionList(std::string file)
|
||||
}
|
||||
is.close();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -20,4 +20,4 @@ public:
|
||||
|
||||
void test();
|
||||
};
|
||||
#endif //CLUAHANDLER_H
|
||||
#endif //CLUAHANDLER_H
|
||||
|
85
CMT.cpp
85
CMT.cpp
@ -1,6 +1,6 @@
|
||||
// CMT.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -10,14 +10,13 @@
|
||||
#include "SDL_TTF.h"
|
||||
#include "SDL_mixer.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "SDL_framerate.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "SDL_framerate.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "mapHandler.h"
|
||||
#include "global.h"
|
||||
#include "CPreGame.h"
|
||||
#include "CPreGame.h"
|
||||
#include "CConsoleHandler.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "CScreenHandler.h"
|
||||
#include "CPathfinder.h"
|
||||
#include "CGameState.h"
|
||||
#include "CCallback.h"
|
||||
@ -43,13 +42,10 @@
|
||||
std::string NAME = NAME_VER + std::string(" (client)");
|
||||
DLL_EXPORT void initDLL(CLodHandler *b);
|
||||
SDL_Surface * screen, * screen2;
|
||||
extern SDL_Surface * CSDL_Ext::std32bppSurface;
|
||||
|
||||
extern SDL_Surface * CSDL_Ext::std32bppSurface;
|
||||
std::queue<SDL_Event> events;
|
||||
boost::mutex eventsM;
|
||||
|
||||
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM, *GEOR16;
|
||||
|
||||
boost::mutex eventsM;
|
||||
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM, *GEOR16;
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
std::cout.flags(ios::unitbuf);
|
||||
@ -59,7 +55,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
atexit(SDL_Quit);
|
||||
CGameInfo * cgi = CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler itp.)
|
||||
//CLuaHandler luatest;
|
||||
//luatest.test();
|
||||
//luatest.test();
|
||||
//CBIKHandler cb;
|
||||
//cb.open("CSECRET.BIK");
|
||||
std::cout << "Starting... " << std::endl;
|
||||
@ -73,7 +69,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
int rmask = 0xff000000;int gmask = 0x00ff0000;int bmask = 0x0000ff00;int amask = 0x000000ff;
|
||||
#else
|
||||
int rmask = 0x000000ff; int gmask = 0x0000ff00; int bmask = 0x00ff0000; int amask = 0xff000000;
|
||||
#endif
|
||||
#endif
|
||||
CSDL_Ext::std32bppSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 32, rmask, gmask, bmask, amask);
|
||||
THC std::cout<<"\tInitializing minors: "<<pomtime.getDif()<<std::endl;
|
||||
TTF_Init();
|
||||
@ -81,33 +77,30 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
GEOR13 = TTF_OpenFont("Fonts\\georgia.ttf",13);
|
||||
GEOR16 = TTF_OpenFont("Fonts\\georgia.ttf",16);
|
||||
GEORXX = TTF_OpenFont("Fonts\\tnrb.ttf",22);
|
||||
GEORM = TTF_OpenFont("Fonts\\georgia.ttf",10);
|
||||
GEORM = TTF_OpenFont("Fonts\\georgia.ttf",10);
|
||||
atexit(TTF_Quit);
|
||||
THC std::cout<<"\tInitializing fonts: "<<pomtime.getDif()<<std::endl;
|
||||
CMusicHandler * mush = new CMusicHandler; //initializing audio
|
||||
mush->initMusics();
|
||||
//audio initialized
|
||||
//audio initialized
|
||||
cgi->consoleh = new CConsoleHandler;
|
||||
cgi->mush = mush;
|
||||
THC std::cout<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
|
||||
THC std::cout<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
|
||||
THC std::cout<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
|
||||
CDefHandler::Spriteh = cgi->spriteh = new CLodHandler();
|
||||
cgi->spriteh->init("Data\\H3sprite.lod","Sprites");
|
||||
BitmapHandler::bitmaph = cgi->bitmaph = new CLodHandler;
|
||||
cgi->bitmaph->init("Data\\H3bitmap.lod","Data");
|
||||
THC std::cout<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
|
||||
initDLL(cgi->bitmaph);
|
||||
|
||||
initDLL(cgi->bitmaph);
|
||||
CGI->arth = VLC->arth;
|
||||
CGI->creh = VLC->creh;
|
||||
CGI->townh = VLC->townh;
|
||||
CGI->heroh = VLC->heroh;
|
||||
CGI->objh = VLC->objh;
|
||||
CGI->dobjinfo = VLC->dobjinfo;
|
||||
CGI->buildh = VLC->buildh;
|
||||
|
||||
THC std::cout<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
|
||||
|
||||
CGI->buildh = VLC->buildh;
|
||||
THC std::cout<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
|
||||
//cgi->curh->initCursor();
|
||||
//cgi->curh->showGraphicCursor();
|
||||
pomtime.getDif();
|
||||
@ -115,13 +108,11 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
cgi->curh->initCursor();
|
||||
//cgi->screenh = new CScreenHandler;
|
||||
//cgi->screenh->initScreen();
|
||||
THC std::cout<<"\tScreen handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
THC std::cout<<"\tScreen handler: "<<pomtime.getDif()<<std::endl;
|
||||
CAbilityHandler * abilh = new CAbilityHandler;
|
||||
abilh->loadAbilities();
|
||||
cgi->abilh = abilh;
|
||||
THC std::cout<<"\tAbility handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
THC std::cout<<"\tAbility handler: "<<pomtime.getDif()<<std::endl;
|
||||
THC std::cout<<"Preparing first handlers: "<<tmh.getDif()<<std::endl;
|
||||
pomtime.getDif();
|
||||
graphics = new Graphics();
|
||||
@ -135,43 +126,35 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
CMessage::init();
|
||||
cgi->generaltexth = new CGeneralTextHandler;
|
||||
cgi->generaltexth->load();
|
||||
THC std::cout<<"Preparing more handlers: "<<tmh.getDif()<<std::endl;
|
||||
THC std::cout<<"Preparing more handlers: "<<tmh.getDif()<<std::endl;
|
||||
CPreGame * cpg = new CPreGame(); //main menu and submenus
|
||||
THC std::cout<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
|
||||
THC std::cout<<"Initialization of VCMI (togeter): "<<total.getDif()<<std::endl;
|
||||
cpg->mush = mush;
|
||||
StartInfo *options = new StartInfo(cpg->runLoop());
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
boost::thread servthr(boost::bind(system,"VCMI_server.exe > server_log.txt")); //runs server executable;
|
||||
//TODO: will it work on non-windows platforms?
|
||||
THC tmh.getDif();pomtime.getDif();//reset timers
|
||||
|
||||
|
||||
THC tmh.getDif();pomtime.getDif();//reset timers
|
||||
CSpellHandler * spellh = new CSpellHandler;
|
||||
spellh->loadSpells();
|
||||
cgi->spellh = spellh;
|
||||
THC std::cout<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
|
||||
THC std::cout<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
|
||||
cgi->pathf = new CPathfinder();
|
||||
THC std::cout<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
|
||||
cgi->consoleh->runConsole();
|
||||
THC std::cout<<"\tCallback and console: "<<pomtime.getDif()<<std::endl;
|
||||
THC std::cout<<"Handlers initialization (together): "<<tmh.getDif()<<std::endl;
|
||||
|
||||
THC std::cout<<"Handlers initialization (together): "<<tmh.getDif()<<std::endl;
|
||||
std::ofstream lll("client_log.txt");
|
||||
CConnection c("localhost","3030",NAME,lll);
|
||||
THC std::cout<<"\tConnecting to the server: "<<tmh.getDif()<<std::endl;
|
||||
|
||||
THC std::cout<<"\tConnecting to the server: "<<tmh.getDif()<<std::endl;
|
||||
CClient cl(&c,options);
|
||||
boost::thread t(boost::bind(&CClient::run,&cl));
|
||||
|
||||
boost::thread t(boost::bind(&CClient::run,&cl));
|
||||
SDL_Event ev;
|
||||
while(1) //main SDL events loop
|
||||
{
|
||||
SDL_WaitEvent(&ev);
|
||||
if(ev.type==SDL_QUIT)
|
||||
if(ev.type==SDL_QUIT)
|
||||
{
|
||||
t.interrupt();
|
||||
exit(0);
|
||||
@ -179,29 +162,24 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
eventsM.lock();
|
||||
events.push(ev);
|
||||
eventsM.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
///claculating FoWs for minimap
|
||||
/****************************Minimaps' FoW******************************************/
|
||||
//for(int g=0; g<cgi->playerint.size(); ++g)
|
||||
//{
|
||||
// if(!cgi->playerint[g]->human)
|
||||
// continue;
|
||||
// CMinimap & mm = ((CPlayerInterface*)cgi->playerint[g])->adventureInt->minimap;
|
||||
|
||||
// CMinimap & mm = ((CPlayerInterface*)cgi->playerint[g])->adventureInt->minimap;
|
||||
// int mw = mm.map[0]->w, mh = mm.map[0]->h,
|
||||
// wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
|
||||
|
||||
// wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
|
||||
// for(int d=0; d<cgi->mh->map->twoLevel+1; ++d)
|
||||
// {
|
||||
// SDL_Surface * pt = CSDL_Ext::newSurface(mm.pos.w, mm.pos.h, CSDL_Ext::std32bppSurface);
|
||||
|
||||
// SDL_Surface * pt = CSDL_Ext::newSurface(mm.pos.w, mm.pos.h, CSDL_Ext::std32bppSurface);
|
||||
// for (int i=0; i<mw; i++)
|
||||
// {
|
||||
// for (int j=0; j<mh; j++)
|
||||
// {
|
||||
// int3 pp( ((i*CGI->mh->sizes.x)/mw), ((j*CGI->mh->sizes.y)/mh), d );
|
||||
|
||||
// int3 pp( ((i*CGI->mh->sizes.x)/mw), ((j*CGI->mh->sizes.y)/mh), d );
|
||||
// if ( !((CPlayerInterface*)cgi->playerint[g])->cb->isVisible(pp) )
|
||||
// {
|
||||
// CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i,j,0,0,0);
|
||||
@ -210,8 +188,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
// }
|
||||
// CSDL_Ext::update(pt);
|
||||
// mm.FoW.push_back(pt);
|
||||
// }
|
||||
|
||||
// }
|
||||
//}
|
||||
}
|
||||
else
|
||||
|
62
CMessage.cpp
62
CMessage.cpp
@ -1,6 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "CMessage.h"
|
||||
#include "SDL_TTF.h"
|
||||
#include "SDL_ttf.h"
|
||||
#include "hch/CDefHandler.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "SDL_Extensions.h"
|
||||
@ -133,7 +133,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, int line, bool
|
||||
{
|
||||
int whereCut = -1, braces=0;
|
||||
bool pom = true, opened=false;
|
||||
for (int i=0; i<line+braces; i++)
|
||||
for (int i=0; i<line+braces; i++)
|
||||
{
|
||||
if (text[i]==10) //end of line sign
|
||||
{
|
||||
@ -145,7 +145,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, int line, bool
|
||||
{
|
||||
if (text[i]=='{')
|
||||
opened=true;
|
||||
else
|
||||
else
|
||||
opened=false;
|
||||
braces++;
|
||||
}
|
||||
@ -172,7 +172,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, int line, bool
|
||||
}
|
||||
}
|
||||
for (int i=0;i<text.length();i++)
|
||||
{
|
||||
{
|
||||
if (text[i]==10) //end of line sign
|
||||
{
|
||||
ret->push_back(text.substr(0,i));
|
||||
@ -211,7 +211,7 @@ std::pair<int, int> CMessage::getMaxSizes(std::vector< std::vector<CSelectableCo
|
||||
|
||||
std::pair<int,int> CMessage::getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg)
|
||||
{
|
||||
std::pair<int,int> ret;
|
||||
std::pair<int,int> ret;
|
||||
ret.first = -1;
|
||||
ret.second=0;
|
||||
for (int i=0; i<txtg->size();i++) //szukamy najszerszej linii i lacznej wysokosci
|
||||
@ -239,7 +239,7 @@ SDL_Surface * CMessage::blitTextOnSur(std::vector<std::vector<SDL_Surface*> > *
|
||||
|
||||
int tw = pw;
|
||||
for (int j=0;j<(*txtg)[i].size();j++) //blit text
|
||||
{
|
||||
{
|
||||
blitAt((*txtg)[i][j],tw,curh+i*19,ret);
|
||||
tw+=(*txtg)[i][j]->w;
|
||||
SDL_FreeSurface((*txtg)[i][j]);
|
||||
@ -253,7 +253,7 @@ SDL_Surface * CMessage::blitCompsOnSur(std::vector<SComponent*> & comps, int max
|
||||
std::vector<std::string> * brdtext;
|
||||
if (comps.size())
|
||||
brdtext = breakText(comps[0]->subtitle,12,true,true);
|
||||
else
|
||||
else
|
||||
brdtext = NULL;
|
||||
curh += 30;
|
||||
comps[0]->pos.x = (ret->w/2) - ((comps[0]->getImg()->w)/2);
|
||||
@ -269,7 +269,7 @@ SDL_Surface * CMessage::blitCompsOnSur(std::vector<SComponent*> & comps, int max
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * or, std::vector< std::vector<CSelectableComponent*> > * komp, int inter, int &curh, SDL_Surface *ret)
|
||||
SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * _or, std::vector< std::vector<CSelectableComponent*> > * komp, int inter, int &curh, SDL_Surface *ret)
|
||||
{
|
||||
for (int i=0;i<komp->size();i++)
|
||||
{
|
||||
@ -280,7 +280,7 @@ SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * or, std::vector< std::vector
|
||||
if(maxh<(*komp)[i][j]->getImg()->h)
|
||||
maxh=(*komp)[i][j]->getImg()->h;
|
||||
}
|
||||
totalw += (inter*2+or->w) * ((*komp)[i].size() - 1);
|
||||
totalw += (inter*2+_or->w) * ((*komp)[i].size() - 1);
|
||||
curh+=maxh/2;
|
||||
int curw = (ret->w/2)-(totalw/2);
|
||||
for(int j=0;j<(*komp)[i].size();j++)
|
||||
@ -293,8 +293,8 @@ SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * or, std::vector< std::vector
|
||||
if(j<((*komp)[i].size()-1))
|
||||
{
|
||||
curw+=inter;
|
||||
blitAt(or,curw,curh-(or->h/2),ret);
|
||||
curw+=or->w;
|
||||
blitAt(_or,curw,curh-(_or->h/2),ret);
|
||||
curw+=_or->w;
|
||||
curw+=inter;
|
||||
}
|
||||
}
|
||||
@ -336,7 +336,7 @@ std::vector<std::vector<SDL_Surface*> > * CMessage::drawText(std::vector<std::st
|
||||
(*txtg)[i].push_back(TTF_RenderText_Blended(TNRB16,(*brtext)[i].substr(1,z-1).c_str(),tytulowy));
|
||||
(*brtext)[i].erase(0,z+1); //z+1 bo dajemy zamykajaca klamre
|
||||
} //ends while((*brtext)[i].length())
|
||||
} //ends for(int i=0; i<brtext->size();i++)
|
||||
} //ends for(int i=0; i<brtext->size();i++)
|
||||
return txtg;
|
||||
}
|
||||
CSimpleWindow * CMessage::genWindow(std::string text, int player, int Lmar, int Rmar, int Tmar, int Bmar)
|
||||
@ -345,7 +345,7 @@ CSimpleWindow * CMessage::genWindow(std::string text, int player, int Lmar, int
|
||||
std::vector<std::string> * brtext = breakText(text,32,true,true);
|
||||
std::vector<std::vector<SDL_Surface*> > * txtg = drawText(brtext);
|
||||
std::pair<int,int> txts = getMaxSizes(txtg);
|
||||
ret->bitmap = drawBox1(txts.first+Lmar+Rmar,txts.second+Tmar+Bmar,0);
|
||||
ret->bitmap = drawBox1(txts.first+Lmar+Rmar,txts.second+Tmar+Bmar,0);
|
||||
ret->pos.h=ret->bitmap->h;
|
||||
ret->pos.w=ret->bitmap->w;
|
||||
for (int i=0; i<txtg->size();i++)
|
||||
@ -364,7 +364,7 @@ CSimpleWindow * CMessage::genWindow(std::string text, int player, int Lmar, int
|
||||
//std::stringstream n;
|
||||
//n <<"temp_"<<i<<"__"<<j<<".bmp";
|
||||
blitAt((*txtg)[i][j],tw,ph+i*19,ret->bitmap);
|
||||
//SDL_SaveBMP(ret->bitmap,n.str().c_str());
|
||||
//SDL_SaveBMP(ret->bitmap,n.str().c_str());
|
||||
tw+=(*txtg)[i][j]->w;
|
||||
SDL_FreeSurface((*txtg)[i][j]);
|
||||
}
|
||||
@ -390,7 +390,7 @@ CInfoWindow * CMessage::genIWindow(std::string text, int player, int charperline
|
||||
+ comps[0]->getImg()->h
|
||||
+ 5 //img <-> subtitle
|
||||
+ 20; //subtitle //!!!!!!!!!!!!!!!!!!!!
|
||||
ret->bitmap = drawBox1(txts.first+70,txts.second+70,0);
|
||||
ret->bitmap = drawBox1(txts.first+70,txts.second+70,0);
|
||||
ret->pos.h=ret->bitmap->h;
|
||||
ret->pos.w=ret->bitmap->w;
|
||||
int curh = 30; //gorny margines
|
||||
@ -406,21 +406,21 @@ CInfoWindow * CMessage::genIWindow(std::string text, int player, int charperline
|
||||
curh+=ret->okb.imgs[0][0]->h;
|
||||
return ret;
|
||||
}
|
||||
std::vector< std::vector<CSelectableComponent*> > * CMessage::breakComps(std::vector<CSelectableComponent*> & comps,int maxw, SDL_Surface* or)
|
||||
std::vector< std::vector<CSelectableComponent*> > * CMessage::breakComps(std::vector<CSelectableComponent*> & comps,int maxw, SDL_Surface* _or)
|
||||
{
|
||||
std::vector< std::vector<CSelectableComponent*> > * ret = new std::vector< std::vector<CSelectableComponent*> >();
|
||||
ret->resize(1);
|
||||
bool wywalicOr=false;
|
||||
if (!or)
|
||||
if (!_or)
|
||||
{
|
||||
or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
|
||||
_or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
|
||||
wywalicOr=true;
|
||||
}
|
||||
int rvi = 0;
|
||||
int curw = 0;
|
||||
for(int i=0;i<comps.size();i++)
|
||||
{
|
||||
curw += (comps[i]->getImg()->w + 12 + or->w);
|
||||
curw += (comps[i]->getImg()->w + 12 + _or->w);
|
||||
if (curw > maxw)
|
||||
{
|
||||
curw = 0;
|
||||
@ -431,7 +431,7 @@ std::vector< std::vector<CSelectableComponent*> > * CMessage::breakComps(std::ve
|
||||
}
|
||||
if (wywalicOr)
|
||||
{
|
||||
SDL_FreeSurface(or);
|
||||
SDL_FreeSurface(_or);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -444,7 +444,7 @@ SDL_Surface * CMessage::drawBoxTextBitmapSub(int player, std::string text, SDL_S
|
||||
std::pair<int,int> txts = getMaxSizes(txtg), boxs;
|
||||
boxs.first = std::max(txts.first,bitmap->w) // text/bitmap max width
|
||||
+ 50; //side margins
|
||||
boxs.second =
|
||||
boxs.second =
|
||||
(curh=45) //top margin
|
||||
+ txts.second //text total height
|
||||
+ 55 //text <=> img
|
||||
@ -474,8 +474,8 @@ CSelWindow * CMessage::genSelWindow(std::string text, int player, int charperlin
|
||||
std::pair<int,int> txts = getMaxSizes(txtg);
|
||||
txts.first+=45; //side margins
|
||||
int curh = 50; //top margin
|
||||
SDL_Surface * or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
|
||||
std::vector< std::vector<CSelectableComponent*> > * komp = breakComps(comps,500,or);
|
||||
SDL_Surface * _or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
|
||||
std::vector< std::vector<CSelectableComponent*> > * komp = breakComps(comps,500,_or);
|
||||
std::pair<int,int> txts2 = getMaxSizes(komp);
|
||||
ret->pos.h = txts.second //wys. tekstu
|
||||
+ txts2.second //wys komponentow
|
||||
@ -489,13 +489,13 @@ CSelWindow * CMessage::genSelWindow(std::string text, int player, int charperlin
|
||||
ret->bitmap = drawBox1(ret->pos.w,ret->pos.h,player);
|
||||
blitTextOnSur(txtg,curh,ret->bitmap);
|
||||
curh += 50;
|
||||
blitCompsOnSur(or,komp,10,curh,ret->bitmap);
|
||||
blitCompsOnSur(_or,komp,10,curh,ret->bitmap);
|
||||
curh += 30; //to buttton
|
||||
ret->okb.posr.x = (ret->bitmap->w/2) - (ret->okb.imgs[0][0]->w/2);
|
||||
ret->okb.posr.y = curh;
|
||||
ret->okb.show();
|
||||
curh+=ret->okb.imgs[0][0]->h;
|
||||
SDL_FreeSurface(or);
|
||||
SDL_FreeSurface(_or);
|
||||
delete komp;
|
||||
delete tekst;
|
||||
return ret;
|
||||
@ -521,17 +521,17 @@ SDL_Surface * CMessage::genMessage
|
||||
else hh=60+(21*tekst->size());
|
||||
if (type==yesOrNO) //make place for buttons
|
||||
{
|
||||
if (ww<200) ww=200;
|
||||
if (ww<200) ww=200;
|
||||
hh+=70;
|
||||
}
|
||||
|
||||
SDL_Surface * ret = drawBox1(ww,hh,0);
|
||||
//prepare title text
|
||||
|
||||
|
||||
if (title.length())
|
||||
{
|
||||
//SDL_Surface * titleText = TTF_RenderText_Shaded(TNRB16,title.c_str(),tytulowy,tlo);
|
||||
SDL_Surface * titleText = TTF_RenderText_Blended(TNRB16,title.c_str(),tytulowy);
|
||||
//SDL_Surface * titleText = TTF_RenderText_Shaded(TNRB16,title.c_str(),tytulowy,tlo);
|
||||
SDL_Surface * titleText = TTF_RenderText_Blended(TNRB16,title.c_str(),tytulowy);
|
||||
|
||||
//draw title
|
||||
SDL_Rect tytul = genRect(titleText->h,titleText->w,((ret->w/2)-(titleText->w/2)),37);
|
||||
@ -539,7 +539,7 @@ SDL_Surface * CMessage::genMessage
|
||||
SDL_FreeSurface(titleText);
|
||||
}
|
||||
//draw text
|
||||
for (int i=0; i<tekst->size(); i++)
|
||||
for (int i=0; i<tekst->size(); i++)
|
||||
{
|
||||
int by = 37+i*21;
|
||||
if (title.length()) by+=40;
|
||||
@ -565,4 +565,4 @@ SDL_Surface * CMessage::genMessage
|
||||
}
|
||||
delete tekst;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
16
CMessage.h
16
CMessage.h
@ -2,8 +2,10 @@
|
||||
#define CMESSAGE_H
|
||||
|
||||
#include "global.h"
|
||||
#include "SDL_TTF.h"
|
||||
#include <SDL_ttf.h>
|
||||
#include "SDL.h"
|
||||
#include "CPreGame.h"
|
||||
|
||||
enum EWindowType {infoOnly, infoOK, yesOrNO};
|
||||
class CPreGame;
|
||||
class MapSel;
|
||||
@ -23,18 +25,18 @@ namespace NMessage
|
||||
class CMessage
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
static std::pair<int,int> getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg);
|
||||
static std::pair<int, int> getMaxSizes(std::vector< std::vector<CSelectableComponent*> > * komp);
|
||||
static std::vector<std::vector<SDL_Surface*> > * drawText(std::vector<std::string> * brtext);
|
||||
static SDL_Surface * blitTextOnSur(std::vector<std::vector<SDL_Surface*> > * txtg, int & curh, SDL_Surface * ret);
|
||||
static SDL_Surface * blitCompsOnSur(std::vector<SComponent*> & comps, int maxw, int inter, int & curh, SDL_Surface * ret);
|
||||
static SDL_Surface* blitCompsOnSur(SDL_Surface * or, std::vector< std::vector<CSelectableComponent*> > * komp, int inter, int &curh, SDL_Surface *ret);
|
||||
static CInfoWindow * genIWindow(std::string text, int player, int charperline, std::vector<SComponent*> & comps);
|
||||
static std::vector< std::vector<CSelectableComponent*> > * breakComps(std::vector<CSelectableComponent*> & comps,int maxw, SDL_Surface* or=NULL);
|
||||
static SDL_Surface * blitCompsOnSur(SDL_Surface *_or, std::vector< std::vector<CSelectableComponent*> > *komp, int inter, int &curh, SDL_Surface *ret);
|
||||
static CInfoWindow * genIWindow(std::string text, int player, int charperline, std::vector<SComponent*> &comps);
|
||||
static std::vector< std::vector<CSelectableComponent*> > * breakComps(std::vector<CSelectableComponent*> &comps, int maxw, SDL_Surface* _or=NULL);
|
||||
static CSelWindow * genSelWindow(std::string text, int player, int charperline, std::vector<CSelectableComponent*> & comps, int owner);
|
||||
static CSimpleWindow * genWindow(std::string text, int player, int Lmar=35, int Rmar=35, int Tmar=35, int Bmar=35);//supports h3 text formatting; player sets color of window, Lmar/Rmar/Tmar/Bmar are Left/Right/Top/Bottom margins
|
||||
static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,
|
||||
static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,
|
||||
std::vector<CDefHandler*> *addPics=NULL, void * cb=NULL);
|
||||
static SDL_Surface * drawBox1(int w, int h, int playerColor=1);
|
||||
static SDL_Surface * drawBoxTextBitmapSub(int player, std::string text, SDL_Surface* bitmap, std::string sub, int charperline=30);
|
||||
@ -46,4 +48,4 @@ public:
|
||||
//
|
||||
|
||||
|
||||
#endif //CMESSAGE_H
|
||||
#endif //CMESSAGE_H
|
||||
|
@ -35,14 +35,14 @@ vector<Coordinate>* CPathfinder::GetPath(const CGHeroInstance* hero)
|
||||
Hero = hero;
|
||||
|
||||
//Reset the queues
|
||||
Open = priority_queue < vector<Coordinate>, vector<vector<Coordinate>>, Compare>();
|
||||
Open = priority_queue < vector<Coordinate>, vector<vector<Coordinate> >, Compare>();
|
||||
Closed.clear();
|
||||
|
||||
//Determine if the hero can move on water
|
||||
int3 hpos = Hero->getPosition(false);
|
||||
if (!Hero->canWalkOnSea())
|
||||
{
|
||||
if (CGI->mh->ttiles[hpos.x][hpos.y][hpos.z].tileInfo->tertype==EterrainType::water)
|
||||
if (CGI->mh->ttiles[hpos.x][hpos.y][hpos.z].tileInfo->tertype==water)
|
||||
blockLandSea=false;
|
||||
else
|
||||
blockLandSea=true;
|
||||
@ -138,14 +138,14 @@ bool CPathfinder::ExistsInClosed(Coordinate node)
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds the neighbors of the current node to the open cue so they can be considered in the
|
||||
* Adds the neighbors of the current node to the open cue so they can be considered in the
|
||||
* path creation. If the node has a cost (f = g + h) less than zero, it isn't added to Open.
|
||||
*/
|
||||
void CPathfinder::AddNeighbors(vector<Coordinate>* branch)
|
||||
{
|
||||
//8 possible Nodes to add
|
||||
//
|
||||
// 1 2 3
|
||||
//
|
||||
// 1 2 3
|
||||
// 4 X 5
|
||||
// 6 7 8
|
||||
|
||||
@ -193,13 +193,13 @@ void CPathfinder::CalcH(Coordinate* node)
|
||||
* => Impossible to move there.
|
||||
*/
|
||||
if( (CGI->mh->ttiles[node->x][node->y][node->z].tileInfo->blocked && !(node->x==End.x && node->y==End.y && CGI->mh->ttiles[node->x][node->y][node->z].tileInfo->visitable)) ||
|
||||
(CGI->mh->ttiles[node->x][node->y][node->z].tileInfo->tertype==EterrainType::rock) ||
|
||||
((blockLandSea) && (CGI->mh->ttiles[node->x][node->y][node->z].tileInfo->tertype==EterrainType::water)) ||
|
||||
(CGI->mh->ttiles[node->x][node->y][node->z].tileInfo->tertype==rock) ||
|
||||
((blockLandSea) && (CGI->mh->ttiles[node->x][node->y][node->z].tileInfo->tertype==water)) ||
|
||||
(!CGI->state->players[Hero->tempOwner].fogOfWarMap[node->x][node->y][node->z]) ||
|
||||
((!blockLandSea) && (CGI->mh->ttiles[node->x][node->y][node->z].tileInfo->tertype!=EterrainType::water)))
|
||||
((!blockLandSea) && (CGI->mh->ttiles[node->x][node->y][node->z].tileInfo->tertype!=water)))
|
||||
{
|
||||
//Impossible.
|
||||
|
||||
|
||||
node->h = -1;
|
||||
return;
|
||||
}
|
||||
@ -214,7 +214,7 @@ void CPathfinder::CalcH(Coordinate* node)
|
||||
|
||||
//Get the movement cost.
|
||||
ret = Hero->getTileCost(CGI->mh->ttiles[x][y][node->z].tileInfo->tertype, CGI->mh->map->terrain[x][y][node->z].malle,CGI->mh->map->terrain[x][y][node->z].nuine);
|
||||
|
||||
|
||||
node->h = ret;
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ CPath* CPathfinder::ConvertToOldFormat(vector<Coordinate>* p)
|
||||
|
||||
//Set coord
|
||||
temp.coord = int3(p->at(i).x,p->at(i).y,p->at(i).z);
|
||||
|
||||
|
||||
//Set accesible
|
||||
if(p->at(i).h == -1)
|
||||
{
|
||||
@ -334,4 +334,4 @@ void Coordinate::operator =(const Coordinate &other)
|
||||
this->z = other.z;
|
||||
this->g = other.g;
|
||||
this->h = other.h;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <math.h>
|
||||
class CGHeroInstance;
|
||||
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
class Coordinate
|
||||
{
|
||||
@ -54,7 +54,7 @@ class CPathfinder
|
||||
{
|
||||
private:
|
||||
boost::logic::tribool blockLandSea; //true - blocks sea, false - blocks land, indeterminate - allows all
|
||||
|
||||
|
||||
/*
|
||||
* Does the actual path calculation. Don't call this directly, call GetPath instead.
|
||||
*/
|
||||
@ -67,7 +67,7 @@ private:
|
||||
bool ExistsInClosed(Coordinate node);
|
||||
|
||||
/*
|
||||
* Adds the neighbors of the current node to the open cue so they can be considered in the
|
||||
* Adds the neighbors of the current node to the open cue so they can be considered in the
|
||||
* path creation. If the node has a cost (f = g + h) less than zero, it isn't added to Open.
|
||||
*/
|
||||
void AddNeighbors(vector<Coordinate>* node);
|
||||
@ -84,7 +84,7 @@ private:
|
||||
|
||||
public:
|
||||
//Contains nodes to be searched
|
||||
priority_queue < vector<Coordinate>, vector<vector<Coordinate>>, Compare> Open;
|
||||
priority_queue < vector<Coordinate>, vector<vector<Coordinate> >, Compare > Open;
|
||||
|
||||
//History of nodes you have been to before
|
||||
vector<Coordinate> Closed;
|
||||
@ -97,7 +97,7 @@ public:
|
||||
|
||||
//A reference to the Hero.
|
||||
const CGHeroInstance* Hero;
|
||||
|
||||
|
||||
/*
|
||||
* Does basic input checking and setup for the path calculation.
|
||||
*/
|
||||
@ -111,4 +111,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif //CPATHFINDER_H
|
||||
#endif //CPATHFINDER_H
|
||||
|
@ -239,7 +239,7 @@ void CGarrisonSlot::show()
|
||||
if(creature)
|
||||
{
|
||||
char* buf = new char[15];
|
||||
itoa(count,buf,10);
|
||||
SDL_itoa(count,buf,10);
|
||||
blitAt(graphics->bigImgs[creature->idNumber],pos);
|
||||
printTo(buf,pos.x+56,pos.y+62,GEOR16,zwykly);
|
||||
if(owner->highlighted==this)
|
||||
@ -344,7 +344,7 @@ void CGarrisonInt::createSlots()
|
||||
(std::map<si32,std::pair<ui32,si32> >::const_iterator i=set1->slots.begin();
|
||||
i!=set1->slots.end(); i++)
|
||||
{
|
||||
(*sup)[i->first] =
|
||||
(*sup)[i->first] =
|
||||
new CGarrisonSlot(this, pos.x + (i->first*(58+interx)), pos.y,i->first, 0, &CGI->creh->creatures[i->second.first],i->second.second);
|
||||
}
|
||||
for(int i=0; i<sup->size(); i++)
|
||||
@ -352,13 +352,13 @@ void CGarrisonInt::createSlots()
|
||||
(*sup)[i] = new CGarrisonSlot(this, pos.x + (i*(58+interx)), pos.y,i,0,NULL, 0);
|
||||
}
|
||||
if(set2)
|
||||
{
|
||||
{
|
||||
sdown = new std::vector<CGarrisonSlot*>(7,(CGarrisonSlot *)(NULL));
|
||||
for
|
||||
(std::map<si32,std::pair<ui32,si32> >::const_iterator i=set2->slots.begin();
|
||||
i!=set2->slots.end(); i++)
|
||||
{
|
||||
(*sdown)[i->first] =
|
||||
(*sdown)[i->first] =
|
||||
new CGarrisonSlot(this, pos.x + (i->first*(58+interx)), pos.y + 64 + intery,i->first,1, &CGI->creh->creatures[i->second.first],i->second.second);
|
||||
}
|
||||
for(int i=0; i<sup->size(); i++)
|
||||
@ -618,7 +618,7 @@ CSelectableComponent::CSelectableComponent(Etype Type, int Sub, int Val, CSelWin
|
||||
{
|
||||
SDL_Surface * symb = SComponent::getImg();
|
||||
myBitmap = CSDL_Ext::newSurface(symb->w+2,symb->h+2,screen);
|
||||
SDL_SetColorKey(myBitmap,SDL_SRCCOLORKEY,SDL_MapRGB(myBitmap->format,0,255,255));
|
||||
SDL_SetColorKey(myBitmap,SDL_SRCCOLORKEY,SDL_MapRGB(myBitmap->format,0,255,255));
|
||||
blitAt(symb,1,1,myBitmap);
|
||||
if (Border) //use custom border
|
||||
{
|
||||
@ -640,7 +640,7 @@ CSelectableComponent::CSelectableComponent(Etype Type, int Sub, int Val, CSelWin
|
||||
SDL_PutPixel(border,0,i,239,215,123);
|
||||
SDL_PutPixel(border,(border->w)-1,i,239,215,123);
|
||||
}
|
||||
SDL_SetColorKey(border,SDL_SRCCOLORKEY,SDL_MapRGB(border->format,0,255,255));
|
||||
SDL_SetColorKey(border,SDL_SRCCOLORKEY,SDL_MapRGB(border->format,0,255,255));
|
||||
}
|
||||
selected = false;
|
||||
}
|
||||
@ -677,7 +677,7 @@ void CSelectableComponent::select(bool on)
|
||||
selected = on;
|
||||
return;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -732,7 +732,7 @@ void CSelWindow::close()
|
||||
ret = i;
|
||||
}
|
||||
components[i]->deactivate();
|
||||
}
|
||||
}
|
||||
components.clear();
|
||||
okb.deactivate();
|
||||
SDL_FreeSurface(bitmap);
|
||||
@ -763,7 +763,7 @@ template <typename T> void CSCButton<T>::clickLeft (tribool down)
|
||||
{
|
||||
state=1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
state=0;
|
||||
}
|
||||
@ -772,16 +772,16 @@ template <typename T> void CSCButton<T>::clickLeft (tribool down)
|
||||
if (delg)
|
||||
(delg->*func)(down);
|
||||
}
|
||||
template <typename T> void CSCButton<typename T>::activate()
|
||||
template <typename T> void CSCButton<T>::activate()
|
||||
{
|
||||
ClickableL::activate();
|
||||
}
|
||||
template <typename T> void CSCButton<typename T>::deactivate()
|
||||
template <typename T> void CSCButton<T>::deactivate()
|
||||
{
|
||||
ClickableL::deactivate();
|
||||
}
|
||||
|
||||
template <typename T> void CSCButton<typename T>::show(SDL_Surface * to)
|
||||
template <typename T> void CSCButton<T>::show(SDL_Surface * to)
|
||||
{
|
||||
if (delg) //we blit on our owner's bitmap
|
||||
{
|
||||
@ -819,7 +819,7 @@ void CButtonBase::show(SDL_Surface * to)
|
||||
if (abs)
|
||||
{
|
||||
blitAt(imgs[curimg]
|
||||
[( (state+bitmapOffset) < (imgs[curimg].size()) ) ?
|
||||
[( (state+bitmapOffset) < (imgs[curimg].size()) ) ?
|
||||
(state+bitmapOffset) :
|
||||
(imgs[curimg].size()-1) ]
|
||||
,pos.x,pos.y,to);
|
||||
@ -828,11 +828,11 @@ void CButtonBase::show(SDL_Surface * to)
|
||||
else
|
||||
{
|
||||
blitAt(imgs[curimg]
|
||||
[( (state+bitmapOffset) < (imgs[curimg].size()) ) ?
|
||||
[( (state+bitmapOffset) < (imgs[curimg].size()) ) ?
|
||||
(state+bitmapOffset) :
|
||||
(imgs[curimg].size()-1) ],pos.x+ourObj->pos.x,pos.y+ourObj->pos.y,to);
|
||||
//updateRect(&genRect(pos.h,pos.w,pos.x+ourObj->pos.x,pos.y+ourObj->pos.y),to);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
ClickableL::ClickableL()
|
||||
@ -988,7 +988,7 @@ void CPlayerInterface::yourTurn()
|
||||
// CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[160 + i] = tab[i];
|
||||
// }
|
||||
// //SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t2.bmp");
|
||||
// CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap);
|
||||
// CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap);
|
||||
// }
|
||||
//}
|
||||
//water tiles updated
|
||||
@ -1082,7 +1082,7 @@ void CPlayerInterface::yourTurn()
|
||||
cb->endTurn();
|
||||
}
|
||||
|
||||
inline void subRect(const int & x, const int & y, const int & z, SDL_Rect & r, const int & hid)
|
||||
inline void subRect(const int & x, const int & y, const int & z, const SDL_Rect & r, const int & hid)
|
||||
{
|
||||
TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z];
|
||||
for(int h=0; h<hlp.objects.size(); ++h)
|
||||
@ -1104,7 +1104,7 @@ inline void delObjRect(const int & x, const int & y, const int & z, const int &
|
||||
}
|
||||
}
|
||||
int getDir(int3 src, int3 dst)
|
||||
{
|
||||
{
|
||||
int ret = -1;
|
||||
if(dst.x+1 == src.x && dst.y+1 == src.y) //tl
|
||||
{
|
||||
@ -1774,13 +1774,13 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
|
||||
CGI->curh->cursorMove(sEvent->motion.x, sEvent->motion.y);
|
||||
}
|
||||
|
||||
if(sEvent->type==SDL_QUIT)
|
||||
if(sEvent->type==SDL_QUIT)
|
||||
exit(0);
|
||||
else if (sEvent->type==SDL_KEYDOWN)
|
||||
{
|
||||
handleKeyDown(sEvent);
|
||||
} //keydown end
|
||||
else if(sEvent->type==SDL_KEYUP)
|
||||
else if(sEvent->type==SDL_KEYUP)
|
||||
{
|
||||
handleKeyUp(sEvent);
|
||||
}//keyup end
|
||||
@ -1904,12 +1904,12 @@ void CPlayerInterface::garrisonChanged(const CGObjectInstance * obj)
|
||||
hw->garInt->recreateSlots();
|
||||
hw->garInt->show();
|
||||
}
|
||||
else if(castleInt == curint) //opened town window - redraw town garrsion slots (change is within hero garr)
|
||||
else if(castleInt == curint) //opened town window - redraw town garrsion slots (change is within hero garr)
|
||||
{
|
||||
castleInt->garr->highlighted = NULL;
|
||||
castleInt->garr->recreateSlots();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (obj->ID == 98) //town
|
||||
{
|
||||
@ -1919,7 +1919,7 @@ void CPlayerInterface::garrisonChanged(const CGObjectInstance * obj)
|
||||
SDL_FreeSurface(graphics->townWins[tt->identifier]);
|
||||
graphics->townWins[tt->identifier] = infoWin(tt);
|
||||
}
|
||||
|
||||
|
||||
const CCastleInterface *ci = dynamic_cast<CCastleInterface*>(curint);
|
||||
if(ci)
|
||||
{
|
||||
@ -1989,7 +1989,7 @@ BattleAction CPlayerInterface::activeStack(int stackID) //called when it's turn
|
||||
objsToBlit[i]->show();
|
||||
//SDL_Flip(screen);
|
||||
CSDL_Ext::update(screen);
|
||||
|
||||
|
||||
/*timeHandler th;
|
||||
th.getDif();
|
||||
int tv = th.getDif();
|
||||
@ -2007,6 +2007,7 @@ BattleAction CPlayerInterface::activeStack(int stackID) //called when it's turn
|
||||
BattleAction ret = *(dynamic_cast<CBattleInterface*>(curint)->givenCommand);
|
||||
delete dynamic_cast<CBattleInterface*>(curint)->givenCommand;
|
||||
dynamic_cast<CBattleInterface*>(curint)->givenCommand = NULL;
|
||||
dynamic_cast<CBattleInterface*>(curint)->myTurn = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2029,14 +2030,19 @@ void CPlayerInterface::battleStackAttacking(int ID, int dest)
|
||||
dynamic_cast<CBattleInterface*>(curint)->stackAttacking(ID, dest);
|
||||
}
|
||||
|
||||
void CPlayerInterface::battleStackIsAttacked(int ID, int dmg, int killed, int IDby)
|
||||
void CPlayerInterface::battleStackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting)
|
||||
{
|
||||
dynamic_cast<CBattleInterface*>(curint)->stackIsAttacked(ID, dmg, killed, IDby);
|
||||
dynamic_cast<CBattleInterface*>(curint)->stackIsAttacked(ID, dmg, killed, IDby, byShooting);
|
||||
}
|
||||
|
||||
void CPlayerInterface::battleStackKilled(int ID, int dmg, int killed, int IDby)
|
||||
void CPlayerInterface::battleStackKilled(int ID, int dmg, int killed, int IDby, bool byShooting)
|
||||
{
|
||||
dynamic_cast<CBattleInterface*>(curint)->stackKilled(ID, dmg, killed, IDby);
|
||||
dynamic_cast<CBattleInterface*>(curint)->stackKilled(ID, dmg, killed, IDby, byShooting);
|
||||
}
|
||||
|
||||
void CPlayerInterface::battleStackIsShooting(int ID, int dest)
|
||||
{
|
||||
dynamic_cast<CBattleInterface*>(curint)->stackIsShooting(ID, dest);
|
||||
}
|
||||
|
||||
void CPlayerInterface::showComp(SComponent comp)
|
||||
@ -2150,7 +2156,7 @@ void CList::activate()
|
||||
Hoverable::activate();
|
||||
KeyInterested::activate();
|
||||
MotionInterested::activate();
|
||||
};
|
||||
};
|
||||
void CList::deactivate()
|
||||
{
|
||||
ClickableL::deactivate();
|
||||
@ -2158,7 +2164,7 @@ void CList::deactivate()
|
||||
Hoverable::deactivate();
|
||||
KeyInterested::deactivate();
|
||||
MotionInterested::deactivate();
|
||||
};
|
||||
};
|
||||
void CList::clickLeft(tribool down)
|
||||
{
|
||||
};
|
||||
@ -2170,7 +2176,7 @@ CHeroList::CHeroList(int Size)
|
||||
:CList(Size)
|
||||
{
|
||||
pos = genRect(192,64,609,196);
|
||||
|
||||
|
||||
arrupp = genRect(16,64,609,196);
|
||||
arrdop = genRect(16,64,609,372);
|
||||
//32px per hero
|
||||
@ -2180,7 +2186,7 @@ CHeroList::CHeroList(int Size)
|
||||
pospory = 212;
|
||||
posmanx = 666;
|
||||
posmany = 213;
|
||||
|
||||
|
||||
arrup = CDefHandler::giveDef("IAM012.DEF");
|
||||
arrdo = CDefHandler::giveDef("IAM013.DEF");
|
||||
mobile = CDefHandler::giveDef("IMOBIL.DEF");
|
||||
@ -2214,7 +2220,7 @@ void CHeroList::select(int which)
|
||||
draw();
|
||||
LOCPLINT->adventureInt->infoBar.draw(NULL);
|
||||
}
|
||||
if (which>=items.size())
|
||||
if (which>=items.size())
|
||||
return;
|
||||
selected = which;
|
||||
LOCPLINT->adventureInt->centerOn(items[which].first->pos);
|
||||
@ -2223,7 +2229,7 @@ void CHeroList::select(int which)
|
||||
LOCPLINT->adventureInt->terrain.currentPath = items[which].second;
|
||||
draw();
|
||||
LOCPLINT->adventureInt->townList.draw();
|
||||
|
||||
|
||||
LOCPLINT->adventureInt->infoBar.draw(NULL);
|
||||
}
|
||||
void CHeroList::clickLeft(tribool down)
|
||||
@ -2379,7 +2385,7 @@ void CHeroList::updateMove(const CGHeroInstance* which) //draws move points bar
|
||||
blitAt(mobile->ourImages[pom].bitmap,posmobx,posmoby+ser*32); //move point
|
||||
}
|
||||
void CHeroList::draw()
|
||||
{
|
||||
{
|
||||
for (int iT=0+from;iT<5+from;iT++)
|
||||
{
|
||||
int i = iT-from;
|
||||
@ -2398,7 +2404,7 @@ void CHeroList::draw()
|
||||
if (pom>25) pom=25;
|
||||
if (pom<0) pom=0;
|
||||
blitAt(mana->ourImages[pom].bitmap,posmanx,posmany+i*32); //mana
|
||||
SDL_Surface * temp = graphics->portraitSmall[LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->subID];
|
||||
SDL_Surface * temp = graphics->portraitSmall[LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->portrait];
|
||||
blitAt(temp,posporx,pospory+i*32);
|
||||
if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == HEROI_TYPE))
|
||||
{
|
||||
@ -2446,7 +2452,7 @@ CTownList::CTownList(int Size, SDL_Rect * Pos, int arupx, int arupy, int ardox,
|
||||
pressed = indeterminate;
|
||||
|
||||
from = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CTownList::genList()
|
||||
@ -2460,7 +2466,7 @@ void CTownList::genList()
|
||||
|
||||
void CTownList::select(int which)
|
||||
{
|
||||
if (which>=items.size())
|
||||
if (which>=items.size())
|
||||
return;
|
||||
selected = which;
|
||||
if(!fun.empty())
|
||||
@ -2562,7 +2568,7 @@ void CTownList::clickLeft(tribool down)
|
||||
}
|
||||
|
||||
void CTownList::clickRight(tribool down)
|
||||
{
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
/***************************ARROWS*****************************************/
|
||||
@ -2604,7 +2610,7 @@ void CTownList::keyPressed (SDL_KeyboardEvent & key)
|
||||
}
|
||||
|
||||
void CTownList::draw()
|
||||
{
|
||||
{
|
||||
for (int iT=0+from;iT<SIZE+from;iT++)
|
||||
{
|
||||
int i = iT-from;
|
||||
@ -2687,7 +2693,7 @@ void CRecrutationWindow::clickLeft(tribool down)
|
||||
{
|
||||
if(isItIn(&genRect(132,102,pos.x+curx,pos.y+64),LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
|
||||
{
|
||||
which = i;
|
||||
which = i;
|
||||
int newAmount = min(amounts[i],creatures[i].amount);
|
||||
slider->amount = newAmount;
|
||||
if(slider->value > newAmount)
|
||||
@ -2735,9 +2741,9 @@ void CRecrutationWindow::show(SDL_Surface * to)
|
||||
cancel->show();
|
||||
slider->show();
|
||||
char pom[15];
|
||||
itoa(creatures[which].amount,pom,10); //available
|
||||
SDL_itoa(creatures[which].amount,pom,10); //available
|
||||
printAtMiddle(pom,pos.x+205,pos.y+252,GEOR13,zwykly,screen);
|
||||
itoa(slider->value,pom,10); //recruit
|
||||
SDL_itoa(slider->value,pom,10); //recruit
|
||||
printAtMiddle(pom,pos.x+279,pos.y+252,GEOR13,zwykly,screen);
|
||||
printAtMiddle(CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creatures[which].ID].namePl,pos.x+243,pos.y+32,GEOR16,tytulowy,screen); //eg "Recruit Dragon flies"
|
||||
int curx = pos.x+115-creatures[which].res.size()*16;
|
||||
@ -2745,9 +2751,9 @@ void CRecrutationWindow::show(SDL_Surface * to)
|
||||
{
|
||||
blitAt(graphics->resources32->ourImages[creatures[which].res[i].first].bitmap,curx,pos.y+243,screen);
|
||||
blitAt(graphics->resources32->ourImages[creatures[which].res[i].first].bitmap,curx+258,pos.y+243,screen);
|
||||
itoa(creatures[which].res[i].second,pom,10);
|
||||
SDL_itoa(creatures[which].res[i].second,pom,10);
|
||||
printAtMiddle(pom,curx+12,pos.y+286,GEOR13,zwykly,screen);
|
||||
itoa(creatures[which].res[i].second * slider->value,pom,10);
|
||||
SDL_itoa(creatures[which].res[i].second * slider->value,pom,10);
|
||||
printAtMiddle(pom,curx+12+258,pos.y+286,GEOR13,zwykly,screen);
|
||||
curx+=32;
|
||||
}
|
||||
@ -2818,7 +2824,7 @@ CRecrutationWindow::CRecrutationWindow(const std::vector<std::pair<int,int> > &C
|
||||
buy = new AdventureMapButton("","",boost::bind(&CRecrutationWindow::Buy,this),pos.x+212,pos.y+313,"IBY6432.DEF");
|
||||
cancel = new AdventureMapButton("","",boost::bind(&CRecrutationWindow::Cancel,this),pos.x+290,pos.y+313,"ICN6432.DEF");
|
||||
LOCPLINT->curint->deactivate();
|
||||
//AdventureMapButton( std::string Name, std::string HelpBox, void(T::*Function)(),
|
||||
//AdventureMapButton( std::string Name, std::string HelpBox, void(T::*Function)(),
|
||||
//int x, int y, std::string defName, T* Owner, bool activ=false, std::vector<std::string> * add = NULL, bool playerColoredButton = true );//c-tor
|
||||
}//(int x, int y, int totalw, T*Owner,void(T::*Moved)(int to), int Capacity, int Amount, int Value, bool Horizontal)
|
||||
CRecrutationWindow::~CRecrutationWindow()
|
||||
@ -2891,7 +2897,7 @@ void CSplitWindow::close()
|
||||
deactivate();
|
||||
delete this;
|
||||
LOCPLINT->curint->activate();
|
||||
|
||||
|
||||
CCastleInterface *c = dynamic_cast<CCastleInterface*>(LOCPLINT->curint);
|
||||
if(c) c->showAll();
|
||||
}
|
||||
@ -2908,16 +2914,16 @@ void CSplitWindow::show(SDL_Surface * to)
|
||||
ok->show();
|
||||
cancel->show();
|
||||
slider->show();
|
||||
itoa(a1,pom,10);
|
||||
SDL_itoa(a1,pom,10);
|
||||
printAtMiddle(pom,pos.x+70,pos.y+237,GEOR16,zwykly,screen);
|
||||
itoa(a2,pom,10);
|
||||
SDL_itoa(a2,pom,10);
|
||||
printAtMiddle(pom,pos.x+233,pos.y+237,GEOR16,zwykly,screen);
|
||||
anim->blitPic(screen,pos.x+20,pos.y+54,false);
|
||||
anim->blitPic(screen,pos.x+177,pos.y+54,false);
|
||||
}
|
||||
void CSplitWindow::keyPressed (SDL_KeyboardEvent & key)
|
||||
{
|
||||
//TODO: make manual typing possible
|
||||
//TODO: make manual typing possible
|
||||
}
|
||||
|
||||
void CCreInfoWindow::show(SDL_Surface * to)
|
||||
@ -2954,12 +2960,12 @@ CCreInfoWindow::CCreInfoWindow
|
||||
|
||||
//atttack
|
||||
printAt(CGI->preth->zelp[435].first,155,48,GEOR13,zwykly,bitmap);
|
||||
itoa(c->attack,pom,10);
|
||||
SDL_itoa(c->attack,pom,10);
|
||||
if(State && State->attackBonus)
|
||||
{
|
||||
int hlp = log10f(c->attack)+2;
|
||||
pom[hlp-1] = ' '; pom[hlp] = '(';
|
||||
itoa(c->attack+State->attackBonus,pom+hlp+1,10);
|
||||
SDL_itoa(c->attack+State->attackBonus,pom+hlp+1,10);
|
||||
hlp += 2+(int)log10f(State->attackBonus+c->attack);
|
||||
pom[hlp] = ')'; pom[hlp+1] = '\0';
|
||||
}
|
||||
@ -2967,12 +2973,12 @@ CCreInfoWindow::CCreInfoWindow
|
||||
|
||||
//defense
|
||||
printAt(CGI->preth->zelp[436].first,155,67,GEOR13,zwykly,bitmap);
|
||||
itoa(c->defence,pom,10);
|
||||
SDL_itoa(c->defence,pom,10);
|
||||
if(State && State->defenseBonus)
|
||||
{
|
||||
int hlp = log10f(c->defence)+2;
|
||||
pom[hlp-1] = ' '; pom[hlp] = '(';
|
||||
itoa(c->defence+State->defenseBonus,pom+hlp+1,10);
|
||||
SDL_itoa(c->defence+State->defenseBonus,pom+hlp+1,10);
|
||||
pom[hlp+2+(int)log10f(State->defenseBonus+c->defence)] = ')';
|
||||
}
|
||||
printToWR(pom,276,80,GEOR13,zwykly,bitmap);
|
||||
@ -2981,21 +2987,21 @@ CCreInfoWindow::CCreInfoWindow
|
||||
if(c->shots)
|
||||
{
|
||||
printAt(CGI->generaltexth->allTexts[198],155,86,GEOR13,zwykly,bitmap);
|
||||
itoa(c->shots,pom,10);
|
||||
SDL_itoa(c->shots,pom,10);
|
||||
printToWR(pom,276,99,GEOR13,zwykly,bitmap);
|
||||
}
|
||||
|
||||
//damage
|
||||
printAt(CGI->generaltexth->allTexts[199],155,105,GEOR13,zwykly,bitmap);
|
||||
itoa(c->damageMin,pom,10);
|
||||
SDL_itoa(c->damageMin,pom,10);
|
||||
hlp=log10f(c->damageMin)+2;
|
||||
pom[hlp-1]=' '; pom[hlp]='-'; pom[hlp+1]=' ';
|
||||
itoa(c->damageMax,pom+hlp+2,10);
|
||||
SDL_itoa(c->damageMax,pom+hlp+2,10);
|
||||
printToWR(pom,276,118,GEOR13,zwykly,bitmap);
|
||||
|
||||
//health
|
||||
printAt(CGI->preth->zelp[439].first,155,124,GEOR13,zwykly,bitmap);
|
||||
itoa(c->hitPoints,pom,10);
|
||||
SDL_itoa(c->hitPoints,pom,10);
|
||||
printToWR(pom,276,137,GEOR13,zwykly,bitmap);
|
||||
|
||||
//remaining health - TODO: show during the battles
|
||||
@ -3003,7 +3009,7 @@ CCreInfoWindow::CCreInfoWindow
|
||||
|
||||
//speed
|
||||
printAt(CGI->preth->zelp[441].first,155,162,GEOR13,zwykly,bitmap);
|
||||
itoa(c->speed,pom,10);
|
||||
SDL_itoa(c->speed,pom,10);
|
||||
printToWR(pom,276,175,GEOR13,zwykly,bitmap);
|
||||
|
||||
|
||||
@ -3074,7 +3080,7 @@ void CCreInfoWindow::keyPressed (SDL_KeyboardEvent & key)
|
||||
void CCreInfoWindow::deactivate()
|
||||
{
|
||||
if(!type)
|
||||
ClickableR::deactivate();
|
||||
ClickableR::deactivate();
|
||||
LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
|
||||
if(ok)
|
||||
ok->deactivate();
|
||||
|
@ -206,16 +206,16 @@ public:
|
||||
{
|
||||
primskill, secskill, resource, creature, artifact, experience
|
||||
} type;
|
||||
int subtype;
|
||||
int subtype;
|
||||
int val;
|
||||
|
||||
std::string description; //r-click
|
||||
std::string subtitle;
|
||||
std::string subtitle;
|
||||
|
||||
void init(Etype Type, int Subtype, int Val);
|
||||
SComponent(Etype Type, int Subtype, int Val);
|
||||
SComponent(const Component &c);
|
||||
|
||||
|
||||
void clickRight (boost::logic::tribool down);
|
||||
virtual SDL_Surface * getImg();
|
||||
virtual void activate();
|
||||
@ -249,7 +249,7 @@ public:
|
||||
int count;
|
||||
int upg; //0 - up garrison, 1 - down garrison
|
||||
bool active;
|
||||
|
||||
|
||||
virtual void hover (bool on);
|
||||
const CArmedInstance * getObj();
|
||||
void clickRight (boost::logic::tribool down);
|
||||
@ -342,8 +342,9 @@ public:
|
||||
void battleEnd(CCreatureSet * army1, CCreatureSet * army2, CArmedInstance *hero1, CArmedInstance *hero2, std::vector<int> capturedArtifacts, int expForWinner, bool winner);
|
||||
void battleStackMoved(int ID, int dest, bool startMoving, bool endMoving);
|
||||
void battleStackAttacking(int ID, int dest);
|
||||
void battleStackIsAttacked(int ID, int dmg, int killed, int IDby);
|
||||
void battleStackKilled(int ID, int dmg, int killed, int IDby);
|
||||
void battleStackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting);
|
||||
void battleStackKilled(int ID, int dmg, int killed, int IDby, bool byShooting);
|
||||
void battleStackIsShooting(int ID, int dest); //called when stack with id ID is shooting to hex dest
|
||||
|
||||
|
||||
//-------------//
|
||||
@ -380,30 +381,30 @@ public:
|
||||
std::string getCurrent();
|
||||
};
|
||||
|
||||
class CList
|
||||
class CList
|
||||
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg;
|
||||
CDefHandler *arrup, *arrdo;
|
||||
SDL_Surface *empty, *selection;
|
||||
SDL_Surface *empty, *selection;
|
||||
SDL_Rect arrupp, arrdop; //positions of arrows
|
||||
int posw, posh; //position width/height
|
||||
int selected, //id of selected position, <0 if none
|
||||
from;
|
||||
from;
|
||||
const int SIZE;
|
||||
boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
|
||||
|
||||
CList(int Size = 5);
|
||||
void clickLeft(boost::logic::tribool down);
|
||||
void activate();
|
||||
void activate();
|
||||
void deactivate();
|
||||
virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
|
||||
virtual void genList()=0;
|
||||
virtual void select(int which)=0;
|
||||
virtual void draw()=0;
|
||||
};
|
||||
class CHeroList
|
||||
class CHeroList
|
||||
: public CList
|
||||
{
|
||||
public:
|
||||
@ -426,10 +427,10 @@ public:
|
||||
void init();
|
||||
};
|
||||
|
||||
class CTownList
|
||||
class CTownList
|
||||
: public CList
|
||||
{
|
||||
public:
|
||||
public:
|
||||
boost::function<void()> fun;
|
||||
std::vector<const CGTownInstance*> items;
|
||||
int posporx,pospory;
|
||||
@ -481,7 +482,7 @@ public:
|
||||
void Cancel();
|
||||
void sliderMoved(int to);
|
||||
void clickLeft(boost::logic::tribool down);
|
||||
void activate();
|
||||
void activate();
|
||||
void deactivate();
|
||||
void show(SDL_Surface * to = NULL);
|
||||
CRecrutationWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount>
|
||||
@ -501,7 +502,7 @@ public:
|
||||
|
||||
CSplitWindow(int cid, int max, CGarrisonInt *Owner);
|
||||
~CSplitWindow();
|
||||
void activate();
|
||||
void activate();
|
||||
void split();
|
||||
void close();
|
||||
void deactivate();
|
||||
@ -524,7 +525,7 @@ public:
|
||||
AdventureMapButton *dismiss, *upgrade, *ok;
|
||||
CCreInfoWindow(int Cid, int Type, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm);
|
||||
~CCreInfoWindow();
|
||||
void activate();
|
||||
void activate();
|
||||
void close();
|
||||
void clickRight(boost::logic::tribool down);
|
||||
void dismissF();
|
||||
@ -535,4 +536,4 @@ public:
|
||||
|
||||
extern CPlayerInterface * LOCPLINT;
|
||||
|
||||
#endif //CPLAYERINTERFACE_H
|
||||
#endif //CPLAYERINTERFACE_H
|
||||
|
BIN
CPreGame.cpp
BIN
CPreGame.cpp
Binary file not shown.
43
CPreGame.h
43
CPreGame.h
@ -9,6 +9,7 @@
|
||||
#include "map.h"
|
||||
#include "hch/CMusicHandler.h"
|
||||
class CPreGame;
|
||||
class CDefHandler;
|
||||
extern CPreGame * CPG;
|
||||
|
||||
typedef void(CPreGame::*ttt)();
|
||||
@ -42,12 +43,12 @@ template <class T=ttt> struct Button: public HighButton
|
||||
T fun;
|
||||
virtual void hover(bool on=true);
|
||||
virtual void select(bool on=true);
|
||||
};
|
||||
};
|
||||
template <class T=ttt> struct SetrButton: public Button<T>
|
||||
{
|
||||
int key, * poin;
|
||||
virtual void press(bool down=true);
|
||||
SetrButton(){type=1;selectable=selected=false;state=0;highlightable=false;}
|
||||
SetrButton(){int type=1;bool selectable=false;bool selected=false;int state=0;bool highlightable=false;}
|
||||
};
|
||||
template<class T=CPreGame> class Slider
|
||||
{ //
|
||||
@ -55,7 +56,7 @@ public:
|
||||
bool vertical; // false means horizontal
|
||||
SDL_Rect pos; // position
|
||||
Button<void(Slider::*)()> up, down, //or left/right
|
||||
slider;
|
||||
slider;
|
||||
int positionsAmnt, capacity;// capacity - amount of positions dispplayed at once
|
||||
int whereAreWe; // first displayed thing
|
||||
bool moving;
|
||||
@ -78,7 +79,7 @@ template<class T=ttt> struct IntBut: public Button<T>
|
||||
public:
|
||||
int key;
|
||||
int * what;
|
||||
IntBut(){type=2;fun=NULL;highlightable=false;};
|
||||
IntBut(){int type=2;int fun=NULL;bool highlightable=false;};
|
||||
void set(){*what=key;};
|
||||
};
|
||||
template<class T=ttt> struct IntSelBut: public Button<T>
|
||||
@ -88,8 +89,14 @@ public:
|
||||
int key;
|
||||
IntSelBut(){};
|
||||
IntSelBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup<T>* gr=NULL, int My=-1)
|
||||
: Button(Pos,Fun,Imgs,Sel,gr),key(My){ourPoinGroup=gr;};
|
||||
void select(bool on=true) {(*this).Button::select(on);ourPoinGroup->setYour(this);CPG->printRating();}
|
||||
: Button<T>(Pos,Fun,Imgs,Sel,gr),key(My){ourPoinGroup=gr;};
|
||||
void select(bool on=true) {(*this).Button<T>::select(on);ourPoinGroup->setYour(this);
|
||||
#if !defined(__amigaos4__) && !defined(__unix__)
|
||||
CPG->printRating();
|
||||
#else
|
||||
#warning not compile here
|
||||
#endif
|
||||
}
|
||||
};
|
||||
template <class T> class CPoinGroup :public CGroup<T>
|
||||
{
|
||||
@ -181,7 +188,7 @@ public:
|
||||
ESortBy sortBy;
|
||||
SDL_Surface * bg;
|
||||
int selected; //selected map
|
||||
CDefHandler * Dtypes, * Dvic;
|
||||
CDefHandler * Dtypes, * Dvic;
|
||||
CDefHandler *Dsizes, * Dloss,
|
||||
* sFlags;
|
||||
std::vector<Mapa*> scenList;
|
||||
@ -228,7 +235,7 @@ public:
|
||||
} ;
|
||||
class CPreGame
|
||||
{
|
||||
public:
|
||||
public:
|
||||
std::string playerName;
|
||||
int playerColor;
|
||||
HighButton * highlighted;
|
||||
@ -240,13 +247,13 @@ public:
|
||||
CMusicHandler * mush;
|
||||
std::vector<HighButton *> btns;
|
||||
CPreGameTextHandler * preth ;
|
||||
SDL_Rect * currentMessage;
|
||||
SDL_Rect * currentMessage;
|
||||
SDL_Surface * behindCurMes;
|
||||
CDefHandler *ok, *cancel;
|
||||
enum EState { //where are we?
|
||||
mainMenu, newGame, loadGame, ScenarioList
|
||||
} state;
|
||||
struct menuItems {
|
||||
struct menuItems {
|
||||
SDL_Surface * background, *bgAd;
|
||||
CDefHandler *newGame, *loadGame, *highScores,*credits, *quit;
|
||||
SDL_Rect lNewGame, lLoadGame, lHighScores, lCredits, lQuit;
|
||||
@ -263,15 +270,15 @@ public:
|
||||
void scenHandleEv(SDL_Event& sEvent);
|
||||
void begin(){run=false;ret.difficulty=ourScenSel->selectedDiff;};
|
||||
void quitAskBox();
|
||||
void quit(){exit(0);};
|
||||
void initScenSel();
|
||||
void showScenSel();
|
||||
void showScenList();
|
||||
void quit(){exit(0);};
|
||||
void initScenSel();
|
||||
void showScenSel();
|
||||
void showScenList();
|
||||
void initOptions();
|
||||
void showOptions();
|
||||
void initNewMenu();
|
||||
void showNewMenu();
|
||||
void showMainMenu();
|
||||
void showOptions();
|
||||
void initNewMenu();
|
||||
void showNewMenu();
|
||||
void showMainMenu();
|
||||
StartInfo runLoop(); // runs mainloop of PreGame
|
||||
void initMainMenu(); //loads components for main menu
|
||||
void highlightButton(int which, int on); //highlights one from 5 main menu buttons
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "SDL_TTF.h"
|
||||
#include "SDL_ttf.h"
|
||||
#include "CGameInfo.h"
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
@ -234,34 +234,38 @@ void CSDL_Ext::printToWR(std::string text, int x, int y, TTF_Font * font, SDL_Co
|
||||
void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC, Uint8 A)
|
||||
{
|
||||
Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC;
|
||||
/*
|
||||
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
p[0] = R;
|
||||
p[1] = G;
|
||||
p[2] = B;
|
||||
#else
|
||||
*/
|
||||
p[0] = B;
|
||||
p[1] = G;
|
||||
p[2] = R;
|
||||
if(ekran->format->BytesPerPixel==4)
|
||||
p[3] = A;
|
||||
#endif
|
||||
//#endif
|
||||
SDL_UpdateRect(ekran, x, y, 1, 1);
|
||||
}
|
||||
|
||||
void CSDL_Ext::SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC, Uint8 A)
|
||||
{
|
||||
Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC;
|
||||
/*
|
||||
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
p[0] = B;
|
||||
p[1] = G;
|
||||
p[2] = R;
|
||||
#else
|
||||
*/
|
||||
p[0] = R;
|
||||
p[1] = G;
|
||||
p[2] = B;
|
||||
if(ekran->format->BytesPerPixel==4)
|
||||
p[3] = A;
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
///**************/
|
||||
@ -279,11 +283,14 @@ SDL_Surface * CSDL_Ext::rotate01(SDL_Surface * toRot, int myC)
|
||||
{
|
||||
{
|
||||
Uint8 *p = (Uint8 *)toRot->pixels + j * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
|
||||
/*
|
||||
|
||||
#if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], myC);
|
||||
#else
|
||||
*/
|
||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], myC);
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -316,11 +323,13 @@ SDL_Surface * CSDL_Ext::hFlip(SDL_Surface * toRot)
|
||||
{
|
||||
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel;
|
||||
//int k=2;
|
||||
/*
|
||||
#if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
|
||||
#else
|
||||
*/
|
||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -354,11 +363,13 @@ SDL_Surface * CSDL_Ext::rotate02(SDL_Surface * toRot)
|
||||
{
|
||||
{
|
||||
Uint8 *p = (Uint8 *)toRot->pixels + i * toRot->pitch + j * toRot->format->BytesPerPixel;
|
||||
/*
|
||||
#if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
|
||||
#else
|
||||
*/
|
||||
SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -380,11 +391,13 @@ SDL_Surface * CSDL_Ext::rotate03(SDL_Surface * toRot)
|
||||
{
|
||||
{
|
||||
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j - 1) * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel+2;
|
||||
/*
|
||||
#if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
SDL_PutPixel(ret, i, j, p[0], p[1], p[2], 2);
|
||||
#else
|
||||
*/
|
||||
SDL_PutPixel(ret, i, j, p[2], p[1], p[0], 2);
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -421,11 +434,13 @@ Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y
|
||||
return *(Uint16 *)p;
|
||||
|
||||
case 3:
|
||||
/*
|
||||
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
return p[0] << 16 | p[1] << 8 | p[2];
|
||||
#else
|
||||
*/
|
||||
return p[0] | p[1] << 8 | p[2] << 16;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
case 4:
|
||||
return *(Uint32 *)p;
|
||||
@ -440,11 +455,11 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src)
|
||||
Uint32 trans = SDL_MapRGBA(src->format, 0, 255, 255, 255);
|
||||
SDL_SetColorKey(src, 0, trans);
|
||||
src->flags|=SDL_SRCALPHA;
|
||||
|
||||
|
||||
SDL_Color transp;
|
||||
transp.b = transp.g = transp.r = 0;
|
||||
transp.unused = 255;
|
||||
|
||||
|
||||
if(src->format->BitsPerPixel == 8)
|
||||
{
|
||||
for(int yy=0; yy<src->format->palette->ncolors; ++yy)
|
||||
@ -517,7 +532,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
/* clip the source rectangle to the source surface */
|
||||
if(srcRect) {
|
||||
int maxw, maxh;
|
||||
|
||||
|
||||
srcx = srcRect->x;
|
||||
w = srcRect->w;
|
||||
if(srcx < 0) {
|
||||
@ -539,7 +554,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
maxh = src->h - srcy;
|
||||
if(maxh < h)
|
||||
h = maxh;
|
||||
|
||||
|
||||
} else {
|
||||
srcx = srcy = 0;
|
||||
w = src->w;
|
||||
@ -589,11 +604,11 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
SDL_Color tbc = src->format->palette->colors[*((Uint8*)src->pixels + (y+sr.y)*src->pitch + x + sr.x)]; //color to blit
|
||||
Uint8 * p = (Uint8*)dst->pixels + (y+dstRect->y)*dst->pitch + (x+dstRect->x)*dst->format->BytesPerPixel; //place to blit at
|
||||
|
||||
// According analyze, the values of tbc.unused are fixed,
|
||||
// According analyze, the values of tbc.unused are fixed,
|
||||
// and the approximate ratios are as following:
|
||||
//
|
||||
// tbc.unused numbers
|
||||
// 192 2679
|
||||
// 192 2679
|
||||
// 164 326907
|
||||
// 82 705590
|
||||
// 214 1292625
|
||||
@ -603,7 +618,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
//
|
||||
// By making use of such characteristic, we may implement a
|
||||
// very fast algorithm for heroes3 without loose much quality.
|
||||
switch ((Uint32)tbc.unused)
|
||||
switch ((Uint32)tbc.unused)
|
||||
{
|
||||
case 255:
|
||||
break;
|
||||
@ -621,9 +636,9 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
p[0] = ((((Uint32)p[0]-(Uint32)tbc.r)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.r) & 0xFF;
|
||||
p[1] = ((((Uint32)p[1]-(Uint32)tbc.g)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.g) & 0xFF;
|
||||
p[2] = ((((Uint32)p[2]-(Uint32)tbc.b)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.b) & 0xFF;
|
||||
//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red
|
||||
//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green
|
||||
//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue
|
||||
//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red
|
||||
//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green
|
||||
//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -637,8 +652,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
{
|
||||
SDL_Color tbc = src->format->palette->colors[*((Uint8*)src->pixels + (y+sr.y)*src->pitch + x + sr.x)]; //color to blit
|
||||
Uint8 * p = (Uint8*)dst->pixels + (y+dstRect->y)*dst->pitch + (x+dstRect->x)*dst->format->BytesPerPixel; //place to blit at
|
||||
|
||||
switch ((Uint32)tbc.unused)
|
||||
|
||||
switch ((Uint32)tbc.unused)
|
||||
{
|
||||
case 255:
|
||||
break;
|
||||
@ -656,9 +671,9 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
p[2] = ((((Uint32)p[2]-(Uint32)tbc.r)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.r) & 0xFF;
|
||||
p[1] = ((((Uint32)p[1]-(Uint32)tbc.g)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.g) & 0xFF;
|
||||
p[0] = ((((Uint32)p[0]-(Uint32)tbc.b)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.b) & 0xFF;
|
||||
//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red
|
||||
//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green
|
||||
//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue
|
||||
//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red
|
||||
//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green
|
||||
//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -706,7 +721,7 @@ void CSDL_Ext::setPlayerColor(SDL_Surface * sur, unsigned char player)
|
||||
return;
|
||||
if(sur->format->BitsPerPixel==8)
|
||||
{
|
||||
if(player != 255)
|
||||
if(player != 255)
|
||||
*(sur->format->palette->colors+5) = graphics->playerColors[player];
|
||||
else
|
||||
*(sur->format->palette->colors+5) = *graphics->neutralColor;
|
||||
|
@ -50,4 +50,4 @@ namespace CSDL_Ext
|
||||
SDL_Surface * copySurface(SDL_Surface * mod); //returns copy of given surface
|
||||
};
|
||||
|
||||
#endif // SDL_EXTENSIONS_H
|
||||
#endif // SDL_EXTENSIONS_H
|
||||
|
@ -42,7 +42,11 @@ struct StartInfo
|
||||
for(unsigned int i=0; i<playerInfos.size(); ++i)
|
||||
if(playerInfos[i].color == no)
|
||||
return playerInfos[i];
|
||||
#ifndef __GNUC__
|
||||
throw new std::exception("Cannot find info about player");
|
||||
#else
|
||||
throw new std::exception();
|
||||
#endif
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
@ -201,9 +201,15 @@ SDL_Surface * CPCXConv::getSurface()
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
int bmask = 0xff0000;
|
||||
int gmask = 0x00ff00;
|
||||
int rmask = 0x0000ff;
|
||||
#else
|
||||
int bmask = 0x0000ff;
|
||||
int gmask = 0x00ff00;
|
||||
int rmask = 0xff0000;
|
||||
#endif
|
||||
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, bh.x+add, bh.y, 24, rmask, gmask, bmask, 0);
|
||||
}
|
||||
if (format==PCX8B)
|
||||
@ -212,9 +218,15 @@ SDL_Surface * CPCXConv::getSurface()
|
||||
for (int i=0;i<256;i++)
|
||||
{
|
||||
SDL_Color tp;
|
||||
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
tp.b = pcx[it++];
|
||||
tp.g = pcx[it++];
|
||||
tp.r = pcx[it++];
|
||||
#else
|
||||
tp.r = pcx[it++];
|
||||
tp.g = pcx[it++];
|
||||
tp.b = pcx[it++];
|
||||
#endif
|
||||
tp.unused = 0;
|
||||
*(ret->format->palette->colors+i) = tp;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ SDL_Surface * Graphics::drawHeroInfoWin(const CGHeroInstance * curh)
|
||||
itoa((*i).second.second,buf,10);
|
||||
printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret);
|
||||
}
|
||||
blitAt(graphics->portraitLarge[curh->subID],11,12,ret);
|
||||
blitAt(graphics->portraitLarge[curh->portrait],11,12,ret);
|
||||
itoa(curh->mana,buf,10);
|
||||
printAtMiddle(buf,166,109,GEORM,zwykly,ret); //mana points
|
||||
delete[] buf;
|
||||
@ -205,7 +205,9 @@ Graphics::Graphics()
|
||||
void Graphics::loadHeroPortraits()
|
||||
{
|
||||
std::ifstream of("config/portrety.txt");
|
||||
for (int j=0;j<HEROES_QUANTITY;j++)
|
||||
int numberOfPortraits;
|
||||
of>>numberOfPortraits;
|
||||
for (int j=0; j<numberOfPortraits; j++)
|
||||
{
|
||||
int ID;
|
||||
of>>ID;
|
||||
|
40
config/cr_shots.txt
Normal file
40
config/cr_shots.txt
Normal file
@ -0,0 +1,40 @@
|
||||
//here are defs with things shot by different units - don't delete this line; format: unit_ID def_name spin_projectile
|
||||
2 PLCBOWX.DEF 0
|
||||
3 PLCBOWX.DEF 0
|
||||
8 SMBALX.DEF 1
|
||||
9 SMBALX.DEF 1
|
||||
18 PELFX.DEF 0
|
||||
19 PELFX.DEF 0
|
||||
29 CPGRE.DEF 1
|
||||
34 PMAGX.DEF 1
|
||||
35 PMAGX.DEF 1
|
||||
41 SMBALX.DEF 0
|
||||
44 CPRGOGX.DEF 1
|
||||
45 CPRGOGX.DEF 1
|
||||
64 PLICH.DEF 0
|
||||
65 PLICH.DEF 0
|
||||
74 SMBALX.DEF 0
|
||||
75 SMBALX.DEF 0
|
||||
76 PMEDUSX.DEF 0
|
||||
77 PMEDUSX.DEF 0
|
||||
88 PORCHX.DEF 1
|
||||
89 PORCHX.DEF 1
|
||||
94 PCYCLBX.DEF 1
|
||||
95 PCYCLBX.DEF 1
|
||||
100 PPLIZAX.DEF 0
|
||||
101 PPLIZAX.DEF 0
|
||||
123 PICEE.DEF 0
|
||||
127 SMBALX.DEF 0
|
||||
136 SMBALX.DEF 0
|
||||
137 PLCBOWX.DEF 0
|
||||
138 PHALF.DEF 1
|
||||
145 SMBALX.DEF 0
|
||||
146 SMBALX.DEF 0
|
||||
152 SMBALX.DEF 0
|
||||
169 SMBALX.DEF 0
|
||||
170 PLCBOWX.DEF 0
|
||||
171 PLCBOWX.DEF 0
|
||||
173 CPGRE.DEF 1
|
||||
193 SMBALX.DEF 0
|
||||
196 SMBALX.DEF 0
|
||||
-1
|
@ -1,3 +1,4 @@
|
||||
163
|
||||
0 HPS000KN.bmp
|
||||
1 HPS001KN.bmp
|
||||
2 HPS002KN.bmp
|
||||
@ -154,3 +155,10 @@
|
||||
153 HPS008SH.bmp
|
||||
154 HPS001SH.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
|
19
global.h
19
global.h
@ -18,16 +18,25 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
|
||||
|
||||
#define NAME_VER ("VCMI \"Altanatse\" 0.7")
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PATHSEPARATOR "\\"
|
||||
#define DATA_DIR ""
|
||||
#else
|
||||
#define PATHSEPARATOR "/"
|
||||
#define DATA_DIR "/progdir/"
|
||||
#endif
|
||||
|
||||
enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; //player's colors
|
||||
enum EterrainType {border=-1, dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock};
|
||||
enum Eriver {noRiver=0, clearRiver, icyRiver, muddyRiver, lavaRiver};
|
||||
enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad};
|
||||
enum Eformat { WoG=0x33, AB=0x15, RoE=0x0e, SoD=0x1c};
|
||||
enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,
|
||||
enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,
|
||||
captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255};
|
||||
enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
|
||||
enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HERO_ALCHEMIST, HERO_WIZARD,
|
||||
HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD,
|
||||
enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HERO_ALCHEMIST, HERO_WIZARD,
|
||||
HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD,
|
||||
HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
|
||||
class CGameInfo;
|
||||
extern CGameInfo* CGI;
|
||||
@ -78,6 +87,6 @@ const int MAX_BUILDING_PER_TURN = 1;
|
||||
{ \
|
||||
std::cerr << e->what()<< std::endl; \
|
||||
delete e; \
|
||||
}
|
||||
}
|
||||
|
||||
#endif //GLOBAL_H
|
||||
#endif //GLOBAL_H
|
||||
|
@ -26,4 +26,4 @@ public:
|
||||
void loadAbilities();
|
||||
};
|
||||
|
||||
#endif CABILITYHANDLER_H
|
||||
#endif //CABILITYHANDLER_H
|
||||
|
@ -40,4 +40,4 @@
|
||||
// delete map.terrain[ii] ;
|
||||
// delete map.terrain;
|
||||
// delete[] bufor;
|
||||
//}
|
||||
//}
|
||||
|
@ -16,4 +16,4 @@ public:
|
||||
//CAmbarCendamo (unsigned char * data); // c-tor; data is pointer to decompressed h3m data
|
||||
//~CAmbarCendamo (); // d-tor
|
||||
};
|
||||
#endif //CAMBARCENDAMO_H
|
||||
#endif //CAMBARCENDAMO_H
|
||||
|
@ -31,4 +31,4 @@ public:
|
||||
CArtHandler();
|
||||
};
|
||||
|
||||
#endif // CARTHANDLER_H
|
||||
#endif // CARTHANDLER_H
|
||||
|
@ -19,7 +19,11 @@ unsigned int readNr(std::string &in, unsigned int &it)
|
||||
if(in[last]=='\t' || in[last]=='\n' || in[last]==' ' || in[last]=='\r' || in[last]=='\n')
|
||||
break;
|
||||
if(last==in.size())
|
||||
#ifndef __GNUC__
|
||||
throw new std::exception("Cannot read number...");
|
||||
#else
|
||||
throw new std::exception();
|
||||
#endif
|
||||
std::stringstream ss(in.substr(it,last-it));
|
||||
it+=(1+last-it);
|
||||
ss >> last;
|
||||
@ -63,7 +67,7 @@ void CBuildingHandler::loadBuildings()
|
||||
delete nb;
|
||||
}
|
||||
|
||||
//reading 14 per faction dwellings
|
||||
//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++)
|
||||
{
|
||||
@ -106,7 +110,7 @@ void CBuildingHandler::loadBuildings()
|
||||
buildings[fi][16]->description = readTo(buf,it,'\n');
|
||||
}
|
||||
/////done reading "BLDGNEUT.TXT"******************************
|
||||
|
||||
|
||||
buf = bitmaph->getTextFile("BLDGSPEC.TXT");
|
||||
andame = buf.size(), it=0;
|
||||
for(int f=0;f<F_NUMBER;f++)
|
||||
@ -135,7 +139,7 @@ void CBuildingHandler::loadBuildings()
|
||||
}
|
||||
}
|
||||
|
||||
char line[100]; //bufor
|
||||
char line[100]; //bufor
|
||||
std::ifstream ofs("config/hall.txt");
|
||||
int castles;
|
||||
ofs>>castles;
|
||||
@ -170,12 +174,12 @@ void CBuildingHandler::loadBuildings()
|
||||
(hall[tid].second)[j][box].push_back(last);
|
||||
areboxes = it; //wyzeruje jak nie znajdzie kolejnej spacji = koniec linii
|
||||
if(!it)
|
||||
it = seppos+1;
|
||||
it = seppos+1;
|
||||
}
|
||||
box++;
|
||||
it+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,4 +23,4 @@ public:
|
||||
void loadBuildings(); //main loader
|
||||
};
|
||||
|
||||
#endif //CBUILDINGHANDLER_H
|
||||
#endif //CBUILDINGHANDLER_H
|
||||
|
@ -45,6 +45,10 @@ bool CCreature::isFlying()
|
||||
{
|
||||
return boost::algorithm::find_first(abilityRefs, "FLYING_ARMY");
|
||||
}
|
||||
bool CCreature::isShooting()
|
||||
{
|
||||
return boost::algorithm::find_first(abilityRefs, "SHOOTING_ARMY");
|
||||
}
|
||||
si32 CCreature::maxAmount(const std::vector<si32> &res) const //how many creatures can be bought
|
||||
{
|
||||
int ret = 2147483645;
|
||||
@ -318,7 +322,7 @@ void CCreatureHandler::loadCreatures()
|
||||
}
|
||||
|
||||
//loading reference names
|
||||
std::ifstream ifs("config/crerefnam.txt");
|
||||
std::ifstream ifs("config/crerefnam.txt");
|
||||
int tempi;
|
||||
std::string temps;
|
||||
for (;;)
|
||||
@ -333,7 +337,7 @@ void CCreatureHandler::loadCreatures()
|
||||
ifs.clear();
|
||||
for(int i=1;i<=10;i++)
|
||||
levelCreatures.insert(std::pair<int,std::vector<CCreature*> >(i,std::vector<CCreature*>()));
|
||||
ifs.open("config/monsters.txt");
|
||||
ifs.open("config/monsters.txt");
|
||||
{
|
||||
while(!ifs.eof())
|
||||
{
|
||||
@ -349,7 +353,7 @@ void CCreatureHandler::loadCreatures()
|
||||
ifs.close();
|
||||
ifs.clear();
|
||||
|
||||
ifs.open("config/cr_factions.txt");
|
||||
ifs.open("config/cr_factions.txt");
|
||||
while(!ifs.eof())
|
||||
{
|
||||
int id, fact;
|
||||
@ -359,7 +363,7 @@ void CCreatureHandler::loadCreatures()
|
||||
ifs.close();
|
||||
ifs.clear();
|
||||
|
||||
ifs.open("config/cr_upgrade_list.txt");
|
||||
ifs.open("config/cr_upgrade_list.txt");
|
||||
while(!ifs.eof())
|
||||
{
|
||||
int id, up;
|
||||
@ -368,17 +372,21 @@ void CCreatureHandler::loadCreatures()
|
||||
}
|
||||
ifs.close();
|
||||
ifs.clear();
|
||||
|
||||
|
||||
//loading unit animation def names
|
||||
std::ifstream inp("config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
|
||||
inp.seekg(0,std::ios::end); // na koniec
|
||||
int andame2 = inp.tellg(); // read length
|
||||
inp.seekg(0,std::ios::beg); // wracamy na poczatek
|
||||
char * bufor = new char[andame2]; // allocate memory
|
||||
char * bufor = new char[andame2]; // allocate memory
|
||||
inp.read((char*)bufor, andame2); // read map file to buffer
|
||||
inp.close();
|
||||
buf = std::string(bufor);
|
||||
#ifndef __GNUC__
|
||||
delete [andame2] bufor;
|
||||
#else
|
||||
delete [] bufor;
|
||||
#endif
|
||||
|
||||
i = 0; //buf iterator
|
||||
hmcr = 0;
|
||||
@ -410,6 +418,27 @@ void CCreatureHandler::loadCreatures()
|
||||
creatures[s].animDefName = defName;
|
||||
}
|
||||
loadAnimationInfo();
|
||||
|
||||
//loading id to projectile mapping
|
||||
|
||||
std::ifstream inp2("config/cr_shots.TXT", std::ios::in | std::ios::binary); //this file is not in lod
|
||||
char dump [200];
|
||||
inp2.getline(dump, 200);
|
||||
while(true)
|
||||
{
|
||||
int id;
|
||||
std::string name;
|
||||
bool spin;
|
||||
|
||||
inp2>>id;
|
||||
if(id == -1)
|
||||
break;
|
||||
inp2>>name;
|
||||
idToProjectile[id] = name;
|
||||
inp2>>spin;
|
||||
idToProjectileSpin[id] = spin;
|
||||
}
|
||||
inp2.close();
|
||||
}
|
||||
|
||||
void CCreatureHandler::loadAnimationInfo()
|
||||
@ -583,4 +612,4 @@ void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int
|
||||
break;
|
||||
}
|
||||
i+=2;
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ public:
|
||||
|
||||
bool isDoubleWide(); //returns true if unit is double wide on battlefield
|
||||
bool isFlying(); //returns true if it is a flying unit
|
||||
bool isShooting(); //returns true if unit can shoot
|
||||
si32 maxAmount(const std::vector<si32> &res) const; //how many creatures can be bought
|
||||
|
||||
static int getQuantityID(int quantity); //0 - a few, 1 - several, 2 - pack, 3 - lots, 4 - horde, 5 - throng, 6 - swarm, 7 - zounds, 8 - legion
|
||||
};
|
||||
|
||||
@ -52,9 +52,11 @@ public:
|
||||
std::vector<CCreature> creatures; //creature ID -> creature info
|
||||
std::map<int,std::vector<CCreature*> > levelCreatures; //level -> list of creatures
|
||||
std::map<std::string,int> nameToID;
|
||||
std::map<int,std::string> idToProjectile;
|
||||
std::map<int,bool> idToProjectileSpin; //if true, appropriate projectile is spinning during flight
|
||||
void loadCreatures();
|
||||
void loadAnimationInfo();
|
||||
void loadUnitAnimInfo(CCreature & unit, std::string & src, int & i);
|
||||
CCreatureHandler();
|
||||
};
|
||||
#endif //CCREATUREHANDLER_H
|
||||
#endif //CCREATUREHANDLER_H
|
||||
|
Binary file not shown.
@ -8,7 +8,7 @@ class CLodHandler;
|
||||
class DLL_EXPORT CGDefInfo
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
std::string name;
|
||||
|
||||
unsigned char visitMap[6];
|
||||
unsigned char blockMap[6];
|
||||
@ -39,4 +39,4 @@ public:
|
||||
void load();
|
||||
};
|
||||
|
||||
#endif //COBJINFOECTHANDLER_H
|
||||
#endif //COBJINFOECTHANDLER_H
|
||||
|
@ -14,6 +14,7 @@ void CGeneralTextHandler::load()
|
||||
if(buf[i]=='\r')
|
||||
break;
|
||||
}
|
||||
|
||||
i+=2;
|
||||
for(int jj=0; jj<764; ++jj)
|
||||
{
|
||||
@ -22,8 +23,8 @@ void CGeneralTextHandler::load()
|
||||
allTexts.push_back(buflet);
|
||||
}
|
||||
|
||||
|
||||
std::string strs = CGI->bitmaph->getTextFile("ARRAYTXT.TXT");
|
||||
|
||||
int itr=0;
|
||||
while(itr<strs.length()-1)
|
||||
{
|
||||
|
@ -17,4 +17,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //CGENERALTEXTHANDLER_H
|
||||
#endif //CGENERALTEXTHANDLER_H
|
||||
|
@ -54,4 +54,4 @@ public:
|
||||
~CHeroHandler();
|
||||
void initTerrainCosts();
|
||||
};
|
||||
#endif //CHEROHANDLER_H
|
||||
#endif //CHEROHANDLER_H
|
||||
|
@ -218,7 +218,7 @@ void CLodHandler::extract(std::string FName)
|
||||
for (int i=0;i<totalFiles;i++)
|
||||
{
|
||||
fseek(FLOD, entries[i].offset, 0);
|
||||
std::string bufff = (FName.substr(0, FName.size()-4) + "\\" + (char*)entries[i].name);
|
||||
std::string bufff = (DATA_DIR + FName.substr(0, FName.size()-4) + PATHSEPARATOR + (char*)entries[i].name);
|
||||
unsigned char * outp;
|
||||
if (entries[i].size==0) //file is not compressed
|
||||
{
|
||||
@ -239,7 +239,7 @@ void CLodHandler::extract(std::string FName)
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
outp = new unsigned char[entries[i].size];
|
||||
fread((char*)outp, 1, entries[i].size, FLOD);
|
||||
|
@ -57,4 +57,4 @@ public:
|
||||
void init(std::string lodFile, std::string dirName);
|
||||
};
|
||||
|
||||
#endif //CLODHANDLER_H
|
||||
#endif //CLODHANDLER_H
|
||||
|
@ -12,53 +12,53 @@ void CMusicHandler::initMusics()
|
||||
}
|
||||
atexit(Mix_CloseAudio);
|
||||
|
||||
//AITheme0 = Mix_LoadMUS("MP3\\AITheme0.mp3");
|
||||
//AITheme1 = Mix_LoadMUS("MP3\\AITHEME1.mp3");
|
||||
//AITheme2 = Mix_LoadMUS("MP3\\AITHEME2.mp3");
|
||||
//buildTown = Mix_LoadWAV("MP3\\BUILDTWN.wav");
|
||||
//combat1 = Mix_LoadMUS("MP3\\COMBAT01.mp3");
|
||||
//combat2 = Mix_LoadMUS("MP3\\COMBAT02.mp3");
|
||||
//combat3 = Mix_LoadMUS("MP3\\COMBAT03.mp3");
|
||||
//combat4 = Mix_LoadMUS("MP3\\COMBAT04.mp3");
|
||||
//castleTown = Mix_LoadMUS("MP3\\CstleTown.mp3");
|
||||
//defendCastle = Mix_LoadMUS("MP3\\Defend Castle.mp3");
|
||||
//dirt = Mix_LoadMUS("MP3\\DIRT.mp3");
|
||||
//dungeon = Mix_LoadMUS("MP3\\DUNGEON.mp3");
|
||||
//elemTown = Mix_LoadMUS("MP3\\ElemTown.mp3");
|
||||
//evilTheme = Mix_LoadMUS("MP3\\EvilTheme.mp3");
|
||||
//fortressTown = Mix_LoadMUS("MP3\\FortressTown.mp3");
|
||||
//goodTheme = Mix_LoadMUS("MP3\\GoodTheme.mp3");
|
||||
//grass = Mix_LoadMUS("MP3\\GRASS.mp3");
|
||||
//infernoTown = Mix_LoadMUS("MP3\\InfernoTown.mp3");
|
||||
//lava = Mix_LoadMUS("MP3\\LAVA.mp3");
|
||||
//loopLepr = Mix_LoadMUS("MP3\\LoopLepr.mp3");
|
||||
//loseCampain = Mix_LoadMUS("MP3\\Lose Campain.mp3");
|
||||
//loseCastle = Mix_LoadMUS("MP3\\LoseCastle.mp3");
|
||||
//loseCombat = Mix_LoadMUS("MP3\\LoseCombat.mp3");
|
||||
//mainMenu = Mix_LoadMUS("MP3\\MAINMENU.mp3");
|
||||
//mainMenuWoG = Mix_LoadMUS("MP3\\MainMenuWoG.mp3");
|
||||
//necroTown = Mix_LoadMUS("MP3\\necroTown.mp3");
|
||||
//neutralTheme = Mix_LoadMUS("MP3\\NeutralTheme.mp3");
|
||||
//rampart = Mix_LoadMUS("MP3\\RAMPART.mp3");
|
||||
//retreatBattle = Mix_LoadMUS("MP3\\Retreat Battle.mp3");
|
||||
//rough = Mix_LoadMUS("MP3\\ROUGH.mp3");
|
||||
//sand = Mix_LoadMUS("MP3\\SAND.mp3");
|
||||
//secretTheme = Mix_LoadMUS("MP3\\SecretTheme.mp3");
|
||||
//snow = Mix_LoadMUS("MP3\\SNOW.mp3");
|
||||
//stronghold = Mix_LoadMUS("MP3\\StrongHold.mp3");
|
||||
//surrenderBattle = Mix_LoadMUS("MP3\\Surrender Battle.mp3");
|
||||
//swamp = Mix_LoadMUS("MP3\\SWAMP.mp3");
|
||||
//towerTown = Mix_LoadMUS("MP3\\TowerTown.mp3");
|
||||
//ultimateLose = Mix_LoadMUS("MP3\\UltimateLose.mp3");
|
||||
//underground = Mix_LoadMUS("MP3\\Underground.mp3");
|
||||
//water = Mix_LoadMUS("MP3\\WATER.mp3");
|
||||
//winBattle = Mix_LoadMUS("MP3\\Win Battle.mp3");
|
||||
//winScenario = Mix_LoadMUS("MP3\\Win Scenario.mp3");
|
||||
|
||||
click = Mix_LoadWAV("MP3\\snd1.wav");
|
||||
//AITheme0 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "AITheme0.mp3");
|
||||
//AITheme1 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "AITHEME1.mp3");
|
||||
//AITheme2 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "AITHEME2.mp3");
|
||||
//buildTown = Mix_LoadWAV("MP3" PATHSEPARATOR "BUILDTWN.wav");
|
||||
//combat1 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "COMBAT01.mp3");
|
||||
//combat2 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "COMBAT02.mp3");
|
||||
//combat3 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "COMBAT03.mp3");
|
||||
//combat4 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "COMBAT04.mp3");
|
||||
//castleTown = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "CstleTown.mp3");
|
||||
//defendCastle = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Defend Castle.mp3");
|
||||
//dirt = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "DIRT.mp3");
|
||||
//dungeon = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "DUNGEON.mp3");
|
||||
//elemTown = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "ElemTown.mp3");
|
||||
//evilTheme = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "EvilTheme.mp3");
|
||||
//fortressTown = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "FortressTown.mp3");
|
||||
//goodTheme = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "GoodTheme.mp3");
|
||||
//grass = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "GRASS.mp3");
|
||||
//infernoTown = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "InfernoTown.mp3");
|
||||
//lava = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "LAVA.mp3");
|
||||
//loopLepr = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "LoopLepr.mp3");
|
||||
//loseCampain = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Lose Campain.mp3");
|
||||
//loseCastle = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "LoseCastle.mp3");
|
||||
//loseCombat = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "LoseCombat.mp3");
|
||||
//mainMenu = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "MAINMENU.mp3");
|
||||
//mainMenuWoG = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "MainMenuWoG.mp3");
|
||||
//necroTown = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "necroTown.mp3");
|
||||
//neutralTheme = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "NeutralTheme.mp3");
|
||||
//rampart = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "RAMPART.mp3");
|
||||
//retreatBattle = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Retreat Battle.mp3");
|
||||
//rough = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "ROUGH.mp3");
|
||||
//sand = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "SAND.mp3");
|
||||
//secretTheme = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "SecretTheme.mp3");
|
||||
//snow = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "SNOW.mp3");
|
||||
//stronghold = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "StrongHold.mp3");
|
||||
//surrenderBattle = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Surrender Battle.mp3");
|
||||
//swamp = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "SWAMP.mp3");
|
||||
//towerTown = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "TowerTown.mp3");
|
||||
//ultimateLose = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "UltimateLose.mp3");
|
||||
//underground = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Underground.mp3");
|
||||
//water = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "WATER.mp3");
|
||||
//winBattle = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Win Battle.mp3");
|
||||
//winScenario = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Win Scenario.mp3");
|
||||
|
||||
click = Mix_LoadWAV(DATA_DIR "MP3" PATHSEPARATOR "snd1.wav");
|
||||
click->volume = 30;
|
||||
|
||||
this->sndh = new CSndHandler(std::string("Data\\Heroes3.snd"));
|
||||
this->sndh = new CSndHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "Heroes3.snd"));
|
||||
}
|
||||
|
||||
void CMusicHandler::playClick()
|
||||
@ -86,12 +86,12 @@ void CMusicHandler::playLodSnd(std::string sndname)
|
||||
|
||||
ops = SDL_RWFromConstMem(data, size);
|
||||
chunk = Mix_LoadWAV_RW(ops, 1);
|
||||
|
||||
|
||||
channel = Mix_PlayChannel(-1, chunk, 0);
|
||||
if(channel == -1)
|
||||
{
|
||||
fprintf(stderr, "Unable to play WAV file(Data\\Heroes3.wav::%s): %s\n",
|
||||
fprintf(stderr, "Unable to play WAV file("DATA_DIR "Data" PATHSEPARATOR "Heroes3.wav::%s): %s\n",
|
||||
sndname.c_str(),Mix_GetError());
|
||||
}
|
||||
ops->close(ops);
|
||||
}
|
||||
}
|
||||
|
@ -17,4 +17,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //CMUSICHANDLER_H
|
||||
#endif //CMUSICHANDLER_H
|
||||
|
@ -102,7 +102,7 @@ int CGObjectInstance::getOwner() const
|
||||
{
|
||||
//if (state)
|
||||
// return state->owner;
|
||||
//else
|
||||
//else
|
||||
return tempOwner; //won't have owner
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ bool CGObjectInstance::operator<(const CGObjectInstance & cmp) const //screen p
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CGHeroInstance::isHero() const
|
||||
{
|
||||
return true;
|
||||
@ -390,4 +390,4 @@ CGObjectInstance& CGObjectInstance::operator=(const CGObjectInstance & right)
|
||||
//*state = *right.state;
|
||||
tempOwner = right.tempOwner;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ public:
|
||||
|
||||
int tempOwner; //uzywane dla szybkosci, skrypt ma obowiazek aktualizowac te zmienna
|
||||
int blockVisit; //if non-zero then blocks the tile but is visitable from neighbouring tile
|
||||
|
||||
|
||||
virtual bool isHero() const;
|
||||
int getOwner() const;
|
||||
void setOwner(int ow);
|
||||
int getOwner() const;
|
||||
void setOwner(int ow);
|
||||
int getWidth() const; //returns width of object graphic in tiles
|
||||
int getHeight() const; //returns height of object graphic in tiles
|
||||
bool visitableAt(int x, int y) const; //returns true if ibject is visitable at location (x, y) form left top tile of image (x, y in tiles)
|
||||
@ -184,4 +184,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //COBJECTHANDLER_H
|
||||
#endif //COBJECTHANDLER_H
|
||||
|
@ -18,4 +18,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //CPREGAMETEXTHANDLER_H
|
||||
#endif //CPREGAMETEXTHANDLER_H
|
||||
|
@ -12,7 +12,11 @@ CSndHandler::CSndHandler(std::string fname):CHUNK(65535)
|
||||
{
|
||||
file.open(fname.c_str(),std::ios::binary);
|
||||
if (!file.is_open())
|
||||
#ifndef __GNUC__
|
||||
throw new std::exception((std::string("Cannot open ")+fname).c_str());
|
||||
#else
|
||||
throw new std::exception();
|
||||
#endif
|
||||
int nr = readNormalNr(0,4);
|
||||
char tempc;
|
||||
for (int i=0;i<nr;i++)
|
||||
@ -98,7 +102,7 @@ void CSndHandler::extract(std::string srcfile, std::string dstfile, bool caseSen
|
||||
}
|
||||
MemberFile CSndHandler::getFile(std::string name)
|
||||
{
|
||||
MemberFile ret;
|
||||
MemberFile ret;
|
||||
std::transform(name.begin(),name.end(),name.begin(),tolower);
|
||||
for (int i=0;i<entries.size();i++)
|
||||
{
|
||||
@ -149,7 +153,11 @@ CVidHandler::CVidHandler(std::string fname):CHUNK(65535)
|
||||
{
|
||||
file.open(fname.c_str(),std::ios::binary);
|
||||
if (!file.is_open())
|
||||
#ifndef __GNUC__
|
||||
throw new std::exception((std::string("Cannot open ")+fname).c_str());
|
||||
#else
|
||||
throw new std::exception();
|
||||
#endif
|
||||
int nr = readNormalNr(0,4);
|
||||
char tempc;
|
||||
for (int i=0;i<nr;i++)
|
||||
@ -169,9 +177,9 @@ CVidHandler::CVidHandler(std::string fname):CHUNK(65535)
|
||||
entries[i-1].size=entry.offset-entries[i-1].offset;
|
||||
if (i==nr-1)
|
||||
{
|
||||
file.seekg(0,std::ios::end);
|
||||
file.seekg(0,std::ios::end);
|
||||
entry.size = ((int)file.tellg())-entry.offset;
|
||||
file.seekg(0,std::ios::beg);
|
||||
file.seekg(0,std::ios::beg);
|
||||
}
|
||||
entries.push_back(entry);
|
||||
}
|
||||
@ -234,7 +242,7 @@ void CVidHandler::extract(std::string srcfile, std::string dstfile, bool caseSen
|
||||
}
|
||||
MemberFile CVidHandler::getFile(std::string name)
|
||||
{
|
||||
MemberFile ret;
|
||||
MemberFile ret;
|
||||
std::transform(name.begin(),name.end(),name.begin(),tolower);
|
||||
for (int i=0;i<entries.size();i++)
|
||||
{
|
||||
|
@ -56,4 +56,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //CSNDHANDLER_H
|
||||
#endif //CSNDHANDLER_H
|
||||
|
@ -38,4 +38,4 @@ public:
|
||||
void loadSpells();
|
||||
};
|
||||
|
||||
#endif //CSPELLHANDLER_H
|
||||
#endif //CSPELLHANDLER_H
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "../stdafx.h"
|
||||
#include "CTownHandler.h"
|
||||
#include "CLodHandler.h"
|
||||
#include <sstream>
|
||||
#include <sstream>
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
extern CLodHandler * bitmaph;
|
||||
void loadToIt(std::string &dest, std::string &src, int &iter, int mode);
|
||||
@ -33,7 +33,7 @@ void CTownHandler::loadNames()
|
||||
}
|
||||
town.typeID=si++;
|
||||
town.bonus=towns.size();
|
||||
if (town.bonus==8) town.bonus=3;
|
||||
if (town.bonus==8) town.bonus=3;
|
||||
if (town.name.length())
|
||||
towns.push_back(town);
|
||||
}
|
||||
@ -122,7 +122,7 @@ void CTownHandler::loadNames()
|
||||
{
|
||||
i2->second->borderName = border;
|
||||
i2->second->areaName = area;
|
||||
}
|
||||
}
|
||||
else
|
||||
std::cout << "Warning2: No building "<<id<<" in the castle "<<town<<std::endl;
|
||||
else
|
||||
@ -188,7 +188,7 @@ void CTownHandler::loadNames()
|
||||
{
|
||||
for(i=structures.begin();i!=structures.end();i++)
|
||||
{
|
||||
for(i2=i->second.begin(); i2!=i->second.end(); i2++)
|
||||
for(i2=i->second.begin(); i2!=i->second.end(); i2++)
|
||||
{
|
||||
if(i2->first == buildingID)
|
||||
{
|
||||
@ -247,7 +247,7 @@ void CTownHandler::loadNames()
|
||||
}
|
||||
of.close();
|
||||
of.clear();
|
||||
|
||||
|
||||
of.open("config/requirements.txt");
|
||||
while(!of.eof())
|
||||
{
|
||||
@ -274,4 +274,4 @@ void CTownHandler::loadNames()
|
||||
of.close();
|
||||
of.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,4 +46,4 @@ public:
|
||||
void loadNames();
|
||||
};
|
||||
|
||||
#endif //CTOWNHANDLER_H
|
||||
#endif //CTOWNHANDLER_H
|
||||
|
@ -2,9 +2,14 @@
|
||||
#include <iostream>
|
||||
#include "CVideoHandler.h"
|
||||
#include "SDL.h"
|
||||
|
||||
void DLLHandler::Instantiate(const char *filename)
|
||||
{
|
||||
#ifdef WIN32
|
||||
dll = LoadLibraryA(filename);
|
||||
#else
|
||||
dll = dlopen(filename,RTLD_LOCAL | RTLD_LAZY);
|
||||
#endif
|
||||
}
|
||||
const char *DLLHandler::GetLibExtension()
|
||||
{
|
||||
@ -21,14 +26,22 @@ const char *DLLHandler::GetLibExtension()
|
||||
|
||||
void *DLLHandler::FindAddress234(const char *symbol)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if ((int)symbol == 0x00001758)
|
||||
return NULL;
|
||||
std::cout<<"co ja tu robie"<<std::endl;
|
||||
return (void*) GetProcAddress(dll,symbol);
|
||||
#else
|
||||
return (void *)dlsym(dll, symbol);
|
||||
#endif
|
||||
}
|
||||
DLLHandler::~DLLHandler()
|
||||
{
|
||||
#ifdef WIN32
|
||||
FreeLibrary(dll);
|
||||
#else
|
||||
dlclose(dll);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -53,13 +66,15 @@ int readNormalNr2 (unsigned char* bufor, int &iter, int bytCon)
|
||||
}
|
||||
void RaiseLastOSErrorAt(char * offset)
|
||||
{
|
||||
#ifdef WIN32
|
||||
int * lastError = new int;
|
||||
std::exception * error;
|
||||
*lastError = GetLastError();
|
||||
if (*lastError)
|
||||
throw lastError;
|
||||
|
||||
|
||||
#else
|
||||
throw new std::exception();
|
||||
#endif
|
||||
}
|
||||
//var
|
||||
// LastError: Integer;
|
||||
@ -93,10 +108,7 @@ void RaiseLastOSErrorAt(char * offset)
|
||||
//}
|
||||
void CBIKHandler::open(std::string name)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
hBinkFile = CreateFile
|
||||
(
|
||||
L"CSECRET.BIK", // file name
|
||||
@ -135,7 +147,7 @@ void CBIKHandler::open(std::string name)
|
||||
gg.bmPlanes=1;
|
||||
gg.bmWidthBytes=3*width;
|
||||
gg.bmBits = new unsigned char[width*height*(gg.bmBitsPixel/8)];
|
||||
|
||||
|
||||
//HBITMAP bitmapa = CreateBitmap(width, height,1,24,NULL);
|
||||
std::cout<<"przeszlo!"<<std::endl;
|
||||
}
|
||||
@ -143,7 +155,9 @@ void CBIKHandler::open(std::string name)
|
||||
{
|
||||
printf("cos nie tak");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//void CBIKHandler::close()
|
||||
//{
|
||||
// void *binkClose;
|
||||
|
@ -2,7 +2,12 @@
|
||||
#define CVIDEOHANDLEER_H
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
#define BINKNOTHREADEDIO 0x00800000
|
||||
//
|
||||
@ -75,14 +80,14 @@
|
||||
//end;
|
||||
typedef struct
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int frameCount;
|
||||
int currentFrame;
|
||||
int width;
|
||||
int height;
|
||||
int frameCount;
|
||||
int currentFrame;
|
||||
int lastFrame;
|
||||
int FPSMul;
|
||||
int FPSMul;
|
||||
int FPSDiv;
|
||||
int unknown0;
|
||||
int unknown0;
|
||||
unsigned char flags;
|
||||
unsigned char unknown1[260];
|
||||
int CurPlane; // current plane
|
||||
@ -109,8 +114,11 @@ struct SMKStruct
|
||||
class DLLHandler
|
||||
{
|
||||
public:
|
||||
#if !defined(__amigaos4__) && !defined(__unix__)
|
||||
HINSTANCE dll;
|
||||
|
||||
#else
|
||||
void *dll;
|
||||
#endif
|
||||
void Instantiate(const char *filename);
|
||||
const char *GetLibExtension();
|
||||
void *FindAddress234(const char *symbol);
|
||||
@ -123,7 +131,11 @@ class CBIKHandler
|
||||
public:
|
||||
DLLHandler ourLib;
|
||||
int newmode;
|
||||
#if !defined(__amigaos4__) && !defined(__unix__)
|
||||
HANDLE hBinkFile;
|
||||
#else
|
||||
void *hBinkFile;
|
||||
#endif
|
||||
HBINK hBink;
|
||||
BINK_STRUCT data;
|
||||
unsigned char * buffer;
|
||||
@ -135,4 +147,4 @@ public:
|
||||
void open(std::string name);
|
||||
void close();
|
||||
};
|
||||
#endif //CVIDEOHANDLEER_H
|
||||
#endif //CVIDEOHANDLEER_H
|
||||
|
10
int3.h
10
int3.h
@ -35,7 +35,7 @@ public:
|
||||
x+=i.x;
|
||||
y+=i.y;
|
||||
z+=i.z;
|
||||
}
|
||||
}
|
||||
inline void operator+=(const si32 & i)
|
||||
{
|
||||
x+=i;
|
||||
@ -47,15 +47,15 @@ public:
|
||||
x-=i.x;
|
||||
y-=i.y;
|
||||
z-=i.z;
|
||||
}
|
||||
}
|
||||
inline void operator-=(const si32 & i)
|
||||
{
|
||||
x+=i;
|
||||
y+=i;
|
||||
z+=i;
|
||||
}
|
||||
}
|
||||
inline bool operator==(const int3 & i) const
|
||||
{return (x==i.x) && (y==i.y) && (z==i.z);}
|
||||
{return (x==i.x) && (y==i.y) && (z==i.z);}
|
||||
inline bool operator!=(const int3 & i) const
|
||||
{return !(*this==i);}
|
||||
inline bool operator<(const int3 & i) const
|
||||
@ -88,4 +88,4 @@ inline std::ostream & operator<<(std::ostream & str, const int3 & sth)
|
||||
{
|
||||
return str<<sth.x<<' '<<sth.y<<' '<<sth.z;
|
||||
}
|
||||
#endif //INT3_H
|
||||
#endif //INT3_H
|
||||
|
60
map.cpp
60
map.cpp
@ -210,9 +210,9 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
this->areAnyPLayers = map[4]; //seems to be invalid
|
||||
this->height = this->width = map[5]; // wymiary mapy
|
||||
this->twoLevel = map[9]; //czy sa lochy
|
||||
|
||||
|
||||
int length = map[10]; //name length
|
||||
int i=14, pom;
|
||||
int i=14, pom;
|
||||
while (i-14<length) //read name
|
||||
this->name+=map[i++];
|
||||
length = map[i] + map[i+1]*256; //description length
|
||||
@ -220,7 +220,7 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
for (pom=0;pom<length;pom++)
|
||||
this->description+=map[i++];
|
||||
this->difficulty = map[i++]; // reading map difficulty
|
||||
if(version!=Eformat::RoE)
|
||||
if(version!=RoE)
|
||||
{
|
||||
this->levelLimit = map[i++]; // hero level limit
|
||||
}
|
||||
@ -236,13 +236,13 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
{
|
||||
switch(version)
|
||||
{
|
||||
case Eformat::SoD: case Eformat::WoG:
|
||||
case SoD: case WoG:
|
||||
i+=13;
|
||||
break;
|
||||
case Eformat::AB:
|
||||
case AB:
|
||||
i+=12;
|
||||
break;
|
||||
case Eformat::RoE:
|
||||
case RoE:
|
||||
i+=6;
|
||||
break;
|
||||
}
|
||||
@ -251,39 +251,39 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
|
||||
this->players[pom].AITactic = map[i++];
|
||||
|
||||
if(version == Eformat::SoD || version == Eformat::WoG)
|
||||
if(version == SoD || version == WoG)
|
||||
i++;
|
||||
|
||||
this->players[pom].allowedFactions = 0;
|
||||
this->players[pom].allowedFactions += map[i++];
|
||||
if(version != Eformat::RoE)
|
||||
if(version != RoE)
|
||||
this->players[pom].allowedFactions += (map[i++])*256;
|
||||
|
||||
this->players[pom].isFactionRandom = map[i++];
|
||||
this->players[pom].hasMainTown = map[i++];
|
||||
if (this->players[pom].hasMainTown)
|
||||
{
|
||||
if(version != Eformat::RoE)
|
||||
if(version != RoE)
|
||||
{
|
||||
this->players[pom].generateHeroAtMainTown = map[i++];
|
||||
this->players[pom].generateHero = map[i++];
|
||||
}
|
||||
this->players[pom].posOfMainTown.x = map[i++];
|
||||
this->players[pom].posOfMainTown.y = map[i++];
|
||||
this->players[pom].posOfMainTown.z = map[i++];
|
||||
this->players[pom].posOfMainTown.z = map[i++];
|
||||
}
|
||||
players[pom].p8= map[i++];
|
||||
players[pom].p9= map[i++];
|
||||
players[pom].p9= map[i++];
|
||||
if(players[pom].p9!=0xff)
|
||||
{
|
||||
players[pom].mainHeroPortrait = map[i++];
|
||||
int nameLength = map[i++];
|
||||
i+=3;
|
||||
i+=3;
|
||||
for (int pp=0;pp<nameLength;pp++)
|
||||
players[pom].mainHeroName+=map[i++];
|
||||
}
|
||||
|
||||
if(version!=Eformat::RoE)
|
||||
if(version!=RoE)
|
||||
{
|
||||
i++; ////heroes placeholders //domostwa
|
||||
int heroCount = map[i++];
|
||||
@ -363,7 +363,7 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
this->vicConDetails = new VicCon5();
|
||||
((VicCon5*)this->vicConDetails)->locationOfHero.x = map[i+2];
|
||||
((VicCon5*)this->vicConDetails)->locationOfHero.y = map[i+3];
|
||||
((VicCon5*)this->vicConDetails)->locationOfHero.z = map[i+4];
|
||||
((VicCon5*)this->vicConDetails)->locationOfHero.z = map[i+4];
|
||||
nr=3;
|
||||
break;
|
||||
}
|
||||
@ -372,7 +372,7 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
this->vicConDetails = new VicCon6();
|
||||
((VicCon6*)this->vicConDetails)->locationOfTown.x = map[i+2];
|
||||
((VicCon6*)this->vicConDetails)->locationOfTown.y = map[i+3];
|
||||
((VicCon6*)this->vicConDetails)->locationOfTown.z = map[i+4];
|
||||
((VicCon6*)this->vicConDetails)->locationOfTown.z = map[i+4];
|
||||
nr=3;
|
||||
break;
|
||||
}
|
||||
@ -381,19 +381,19 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
this->vicConDetails = new VicCon7();
|
||||
((VicCon7*)this->vicConDetails)->locationOfMonster.x = map[i+2];
|
||||
((VicCon7*)this->vicConDetails)->locationOfMonster.y = map[i+3];
|
||||
((VicCon7*)this->vicConDetails)->locationOfMonster.z = map[i+4];
|
||||
((VicCon7*)this->vicConDetails)->locationOfMonster.z = map[i+4];
|
||||
nr=3;
|
||||
break;
|
||||
}
|
||||
case takeDwellings:
|
||||
{
|
||||
{
|
||||
this->vicConDetails = new CspecificVictoryConidtions();
|
||||
nr=3;
|
||||
break;
|
||||
}
|
||||
case takeMines:
|
||||
{
|
||||
this->vicConDetails = new CspecificVictoryConidtions();
|
||||
{
|
||||
this->vicConDetails = new CspecificVictoryConidtions();
|
||||
nr=3;
|
||||
break;
|
||||
}
|
||||
@ -403,7 +403,7 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
((VicCona*)this->vicConDetails)->artifactID = map[i+2];
|
||||
((VicCona*)this->vicConDetails)->destinationPlace.x = map[i+3];
|
||||
((VicCona*)this->vicConDetails)->destinationPlace.y = map[i+4];
|
||||
((VicCona*)this->vicConDetails)->destinationPlace.z = map[i+5];
|
||||
((VicCona*)this->vicConDetails)->destinationPlace.z = map[i+5];
|
||||
nr=4;
|
||||
break;
|
||||
}
|
||||
@ -462,7 +462,7 @@ void Mapa::initFromBytes(unsigned char * bufor)
|
||||
name = readString(bufor,i);
|
||||
description= readString(bufor,i);
|
||||
difficulty = readChar(bufor,i); // reading map difficulty
|
||||
if(version != Eformat::RoE)
|
||||
if(version != RoE)
|
||||
levelLimit = readChar(bufor,i); // hero level limit
|
||||
else
|
||||
levelLimit = 0;
|
||||
@ -474,13 +474,13 @@ void Mapa::initFromBytes(unsigned char * bufor)
|
||||
{
|
||||
switch(version)
|
||||
{
|
||||
case Eformat::SoD: case Eformat::WoG:
|
||||
case SoD: case WoG:
|
||||
i+=13;
|
||||
break;
|
||||
case Eformat::AB:
|
||||
case AB:
|
||||
i+=12;
|
||||
break;
|
||||
case Eformat::RoE:
|
||||
case RoE:
|
||||
i+=6;
|
||||
break;
|
||||
}
|
||||
@ -489,19 +489,19 @@ void Mapa::initFromBytes(unsigned char * bufor)
|
||||
|
||||
players[pom].AITactic = bufor[i++];
|
||||
|
||||
if(version == Eformat::SoD || version == Eformat::WoG)
|
||||
if(version == SoD || version == WoG)
|
||||
players[pom].p7= bufor[i++];
|
||||
|
||||
players[pom].allowedFactions = 0;
|
||||
players[pom].allowedFactions += bufor[i++];
|
||||
if(version != Eformat::RoE)
|
||||
if(version != RoE)
|
||||
players[pom].allowedFactions += (bufor[i++])*256;
|
||||
|
||||
players[pom].isFactionRandom = bufor[i++];
|
||||
players[pom].hasMainTown = bufor[i++];
|
||||
if (players[pom].hasMainTown)
|
||||
{
|
||||
if(version != Eformat::RoE)
|
||||
if(version != RoE)
|
||||
{
|
||||
players[pom].generateHeroAtMainTown = bufor[i++];
|
||||
players[pom].generateHero = bufor[i++];
|
||||
@ -529,7 +529,7 @@ void Mapa::initFromBytes(unsigned char * bufor)
|
||||
players[pom].mainHeroName+=bufor[i++];
|
||||
}
|
||||
|
||||
if(version != Eformat::RoE)
|
||||
if(version != RoE)
|
||||
{
|
||||
i++; ////unknown byte
|
||||
int heroCount = bufor[i++];
|
||||
@ -699,7 +699,7 @@ void Mapa::initFromBytes(unsigned char * bufor)
|
||||
for(int xx=0;xx<HEROES_QUANTITY;xx++)
|
||||
allowedHeroes[xx] = true;
|
||||
|
||||
for(i; i<ist+ (version == Eformat::RoE ? 16 : 20) ; ++i)
|
||||
for(i; i<ist+ (version == RoE ? 16 : 20) ; ++i)
|
||||
{
|
||||
unsigned char c = bufor[i];
|
||||
for(int yy=0; yy<8; ++yy)
|
||||
@ -2355,4 +2355,4 @@ CGHeroInstance * Mapa::getHero(int ID, int mode)
|
||||
if(heroes[i]->subID == ID)
|
||||
return heroes[i];
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
24
map.h
24
map.h
@ -1,6 +1,6 @@
|
||||
#ifndef MAPD_H
|
||||
#define MAPD_H
|
||||
#pragma warning (disable : 4482)
|
||||
#pragma warning (disable : 4482)
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@ -10,7 +10,7 @@ class CGDefInfo;
|
||||
class CGObjectInstance;
|
||||
class CGHeroInstance;
|
||||
class CGTownInstance;
|
||||
enum ESortBy{name,playerAm,size,format, viccon,loscon};
|
||||
enum ESortBy{_name, _playerAm, _size, _format, _viccon, _loscon};
|
||||
enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF,
|
||||
EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF, ARTIFACT_DEF, WITCHHUT_DEF, SCHOLAR_DEF, PLAYERONLY_DEF,
|
||||
SHRINE_DEF, SPELLSCROLL_DEF, PANDORA_DEF, GRAIL_DEF, CREGEN_DEF, CREGEN2_DEF, CREGEN3_DEF,
|
||||
@ -282,7 +282,7 @@ struct DLL_EXPORT PlayerInfo
|
||||
bool canComputerPlay;
|
||||
unsigned int AITactic; //(00 - random, 01 - warrior, 02 - builder, 03 - explorer)
|
||||
unsigned int allowedFactions; //(01 - castle; 02 - rampart; 04 - tower; 08 - inferno; 16 - necropolis; 32 - dungeon; 64 - stronghold; 128 - fortress; 256 - conflux);
|
||||
bool isFactionRandom;
|
||||
bool isFactionRandom;
|
||||
unsigned int mainHeroPortrait; //it's ID of hero with choosen portrait; 255 if standard
|
||||
std::string mainHeroName;
|
||||
std::vector<SheroName> heroesNames;
|
||||
@ -375,7 +375,7 @@ class DLL_EXPORT CMapHeader
|
||||
public:
|
||||
Eformat version; // version of map Eformat
|
||||
bool areAnyPLayers; // if there are any playable players on map
|
||||
int height, width;
|
||||
int height, width;
|
||||
bool twoLevel; // if map has underground level
|
||||
std::string name; //name of map
|
||||
std::string description; //and description
|
||||
@ -385,7 +385,7 @@ public:
|
||||
EvictoryConditions victoryCondition; //victory conditions
|
||||
CspecificVictoryConidtions * vicConDetails; // used only if vistory conditions aren't standard
|
||||
PlayerInfo players[8]; // info about players
|
||||
std::vector<int> teams; // teams[i] = team of player no i
|
||||
std::vector<int> teams; // teams[i] = team of player no i
|
||||
int howManyTeams;
|
||||
CMapHeader(unsigned char *map); //an argument is a reference to string described a map (unpacked)
|
||||
};
|
||||
@ -410,17 +410,17 @@ class DLL_EXPORT mapSorter
|
||||
{
|
||||
public:
|
||||
ESortBy sortBy;
|
||||
bool operator()(CMapHeader & a, CMapHeader& b)
|
||||
bool operator()(const CMapHeader & a, const CMapHeader& b)
|
||||
{
|
||||
switch (sortBy)
|
||||
{
|
||||
case ESortBy::format:
|
||||
case _format:
|
||||
return (a.version<b.version);
|
||||
break;
|
||||
case ESortBy::loscon:
|
||||
case _loscon:
|
||||
return (a.lossCondition.typeOfLossCon<b.lossCondition.typeOfLossCon);
|
||||
break;
|
||||
case ESortBy::playerAm:
|
||||
case _playerAm:
|
||||
int playerAmntB,humenPlayersB,playerAmntA,humenPlayersA;
|
||||
playerAmntB=humenPlayersB=playerAmntA=humenPlayersA=0;
|
||||
for (int i=0;i<8;i++)
|
||||
@ -435,13 +435,13 @@ public:
|
||||
else
|
||||
return (humenPlayersA<humenPlayersB);
|
||||
break;
|
||||
case ESortBy::size:
|
||||
case _size:
|
||||
return (a.width<b.width);
|
||||
break;
|
||||
case ESortBy::viccon:
|
||||
case _viccon:
|
||||
return (a.victoryCondition<b.victoryCondition);
|
||||
break;
|
||||
case ESortBy::name:
|
||||
case _name:
|
||||
return (a.name<b.name);
|
||||
break;
|
||||
default:
|
||||
|
@ -1119,7 +1119,7 @@ bool CMapHandler::printObject(CGObjectInstance *obj)
|
||||
std::pair<CGObjectInstance*,SDL_Rect> toAdd = std::make_pair(obj, cr);
|
||||
if((obj->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
|
||||
{
|
||||
TerrainTile2 & curt =
|
||||
TerrainTile2 & curt =
|
||||
ttiles
|
||||
[obj->pos.x + fx - curd->ourImages[0].bitmap->w/32]
|
||||
[obj->pos.y + fy - curd->ourImages[0].bitmap->h/32]
|
||||
@ -1374,4 +1374,4 @@ void CMapHandler::loadDefs()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <list>
|
||||
#include <set>
|
||||
const int Woff = 12; //width of map's frame
|
||||
const int Hoff = 8;
|
||||
const int Hoff = 8;
|
||||
|
||||
class CGObjectInstance;
|
||||
class CGHeroInstance;
|
||||
@ -105,4 +105,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif //MAPHANDLER_H
|
||||
#endif //MAPHANDLER_H
|
||||
|
53
nodrze.h
53
nodrze.h
@ -6,9 +6,12 @@
|
||||
//ignore comment above, it is simply TowDragon's envy. Everything (without removing) is working fine
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define CLOG(x)
|
||||
|
||||
const bool CZERWONY=true, CZARNY=false;
|
||||
template <typename T> class wezel
|
||||
{
|
||||
@ -82,7 +85,7 @@ public:
|
||||
ktory=0;
|
||||
};
|
||||
T * begin () {return minimumimum();}; //first element (=minimum)
|
||||
T * end () {return NIL;}; //
|
||||
T * end () {return NIL;}; //
|
||||
void clear(); // czysci az do korzenia wlacznie
|
||||
// removes all elements, including root
|
||||
void usun (T co); // usuwa element z drzewa
|
||||
@ -140,7 +143,7 @@ template <typename T> void nodrze<T>::wypisuj(wezel<T> * w, std::ostream & strum
|
||||
if (w==NIL) return;
|
||||
wypisuj(w->lewy, strum);
|
||||
|
||||
strum << "Informacje o wezle: "<<flush<<w<<flush;
|
||||
strum << "Informacje o wezle: "<<std::flush<<w<<std::flush;
|
||||
if (w->ojciec!=NIL)
|
||||
strum <<"\n\tOjciec: "<<(w->ojciec)<<" - "<<*(w->ojciec->zawart);
|
||||
else strum <<"\n\tOjciec: NIL";
|
||||
@ -159,7 +162,7 @@ template <typename T> void nodrze<T>::wypisujPre(wezel<T> * w, std::ostream & st
|
||||
{
|
||||
if (w==NIL) return;
|
||||
|
||||
strum << "Informacje o wezle: "<<flush<<w<<flush;
|
||||
strum << "Informacje o wezle: "<<std::flush<<w<<std::flush;
|
||||
if (w->ojciec!=NIL)
|
||||
strum <<"\n\tOjciec: "<<(w->ojciec)<<" - "<<*(w->ojciec->zawart);
|
||||
else strum <<"\n\tOjciec: NIL";
|
||||
@ -179,14 +182,16 @@ template <typename T> void nodrze<T>::wypiszObficie(std::ostream & strum)
|
||||
{
|
||||
strum << "Nodrze " <<this<<" ma " << ile << " elementów."<<std::endl;
|
||||
strum << "NIL to " << NIL <<std::endl;
|
||||
strum << "Ostatnio bralismy "<<ktory<<flush<<" element, czyli "<<" ("<<ostatnio<<")"<<flush<<*ostatnio<<flush<<std::endl;
|
||||
strum << "Ostatnio bralismy "<<ktory<<std::flush<<" element, czyli "<<" ("<<ostatnio<<")"<<std::flush<<*ostatnio<<std::flush<<std::endl;
|
||||
strum << "Nasze wezly in-order"<<std::endl;
|
||||
wypisujPre(korzen,strum);
|
||||
};
|
||||
template <typename T, class X> T* operator%(nodrze<T> & drzewko, X co)
|
||||
{
|
||||
CLOG ("Szukam " <<co <<std::endl);
|
||||
#if !defined(__amigaos4__) && !defined(__unix__)
|
||||
drzewko.wypiszObficie(*C->gl->loguj);
|
||||
#endif
|
||||
wezel<T> * w = drzewko.korzen;
|
||||
while (w!=drzewko.NIL && (*w->zawart)!=co)
|
||||
{
|
||||
@ -494,10 +499,10 @@ template <typename T> void nodrze<T>::naprawUsun (wezel<T> * x)
|
||||
wezel<T> *w;
|
||||
while ( (x != korzen) && (x->kolor == CZARNY) )
|
||||
{
|
||||
CLOG("6... "<<flush);
|
||||
CLOG("6... "<<std::flush);
|
||||
if (x == x->ojciec->lewy)
|
||||
{
|
||||
CLOG("7... "<<flush);
|
||||
CLOG("7... "<<std::flush);
|
||||
w = x->ojciec->prawy;
|
||||
if (w->kolor == CZERWONY)
|
||||
{
|
||||
@ -506,38 +511,38 @@ template <typename T> void nodrze<T>::naprawUsun (wezel<T> * x)
|
||||
rotacjaLewa(x->ojciec);
|
||||
w = x->ojciec->prawy;
|
||||
}
|
||||
CLOG("8... "<<flush);
|
||||
CLOG("8... "<<std::flush);
|
||||
if ( (w->lewy->kolor == CZARNY) && (w->prawy->kolor == CZARNY) )
|
||||
{
|
||||
CLOG("8,1... "<<flush);
|
||||
CLOG("8,1... "<<std::flush);
|
||||
w->kolor = CZERWONY;
|
||||
x = x->ojciec;
|
||||
}
|
||||
else
|
||||
{
|
||||
CLOG("9... "<<flush);
|
||||
CLOG("9... "<<std::flush);
|
||||
if (w->prawy->kolor == CZARNY)
|
||||
{
|
||||
CLOG("9,1... "<<flush);
|
||||
CLOG("9,1... "<<std::flush);
|
||||
w->lewy->kolor = CZARNY;
|
||||
w->kolor = CZERWONY;
|
||||
rotacjaPrawa(w);
|
||||
w = x->ojciec->prawy;
|
||||
CLOG("9,2... "<<flush);
|
||||
CLOG("9,2... "<<std::flush);
|
||||
}
|
||||
CLOG("9,3... "<<flush);
|
||||
CLOG("9,3... "<<std::flush);
|
||||
w->kolor = x->ojciec->kolor;
|
||||
x->ojciec->kolor = CZARNY;
|
||||
w->prawy->kolor = CZARNY;
|
||||
rotacjaLewa(x->ojciec);
|
||||
x=korzen;
|
||||
CLOG("9,4... "<<flush);
|
||||
|
||||
CLOG("9,4... "<<std::flush);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLOG("10... "<<flush);
|
||||
CLOG("10... "<<std::flush);
|
||||
w = x->ojciec->lewy;
|
||||
if (w->kolor == CZERWONY)
|
||||
{
|
||||
@ -546,7 +551,7 @@ template <typename T> void nodrze<T>::naprawUsun (wezel<T> * x)
|
||||
rotacjaPrawa(x->ojciec);
|
||||
w = x->ojciec->lewy;
|
||||
}
|
||||
CLOG("11... "<<flush);
|
||||
CLOG("11... "<<std::flush);
|
||||
if ( (w->lewy->kolor == CZARNY) && (w->prawy->kolor == CZARNY) )
|
||||
{
|
||||
w->kolor = CZERWONY;
|
||||
@ -566,12 +571,12 @@ template <typename T> void nodrze<T>::naprawUsun (wezel<T> * x)
|
||||
w->lewy->kolor = CZARNY;
|
||||
rotacjaPrawa(x->ojciec);
|
||||
x=korzen;
|
||||
CLOG("12... "<<flush);
|
||||
CLOG("12... "<<std::flush);
|
||||
}
|
||||
}
|
||||
}
|
||||
x->kolor = CZARNY;
|
||||
CLOG("13... "<<flush);
|
||||
CLOG("13... "<<std::flush);
|
||||
};
|
||||
template <typename T> wezel<T> * nodrze<T>::usunRBT (wezel<T> * nowy)
|
||||
{
|
||||
@ -597,27 +602,27 @@ template <typename T> wezel<T> * nodrze<T>::usunRBT (wezel<T> * nowy)
|
||||
}
|
||||
CLOG(*ostatnio->zawart<<std::endl);
|
||||
}
|
||||
CLOG("1... "<<flush);
|
||||
CLOG("1... "<<std::flush);
|
||||
wezel<T> *y, *x;
|
||||
if ( (nowy->lewy == NIL) || (nowy->prawy == NIL) )
|
||||
y=nowy;
|
||||
else y = nastepnik(nowy);
|
||||
CLOG("2... "<<flush);
|
||||
CLOG("2... "<<std::flush);
|
||||
if (y->lewy != NIL)
|
||||
x = y->lewy;
|
||||
else x = y->prawy;
|
||||
x->ojciec = y->ojciec;
|
||||
CLOG("3... "<<flush);
|
||||
CLOG("3... "<<std::flush);
|
||||
if (y->ojciec == NIL)
|
||||
korzen = x;
|
||||
else if (y == y->ojciec->lewy)
|
||||
y->ojciec->lewy = x;
|
||||
else
|
||||
y->ojciec->prawy = x;
|
||||
CLOG("4... "<<flush);
|
||||
CLOG("4... "<<std::flush);
|
||||
if (y != nowy)
|
||||
(*nowy) = (*y); // skopiowanie
|
||||
CLOG("5... "<<flush);
|
||||
CLOG("5... "<<std::flush);
|
||||
if (y->kolor == CZARNY)
|
||||
naprawUsun(x);
|
||||
CLOG ("koniec usuwania"<<std::endl);
|
||||
@ -904,4 +909,4 @@ template <typename T> void nodrze<T>::pre(std::ostream & strum, wezel<T> * wsk)
|
||||
if (wsk->prawy != NIL)
|
||||
pre(strum,wsk->prawy);
|
||||
};
|
||||
#endif //_NODRZE_H
|
||||
#endif //_NODRZE_H
|
||||
|
4
stdafx.h
4
stdafx.h
@ -7,7 +7,11 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <cstdio>
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#include "tchar_amigaos4.h"
|
||||
#endif
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
238
tchar_amigaos4.h
Normal file
238
tchar_amigaos4.h
Normal file
@ -0,0 +1,238 @@
|
||||
/*
|
||||
* tchar.h
|
||||
*
|
||||
* Unicode mapping layer for the standard C library. By including this
|
||||
* file and using the 't' names for string functions
|
||||
* (eg. _tprintf) you can make code which can be easily adapted to both
|
||||
* Unicode and non-unicode environments. In a unicode enabled compile define
|
||||
* _UNICODE before including tchar.h, otherwise the standard non-unicode
|
||||
* library functions will be used.
|
||||
*
|
||||
* Note that you still need to include string.h or stdlib.h etc. to define
|
||||
* the appropriate functions. Also note that there are several defines
|
||||
* included for non-ANSI functions which are commonly available (but using
|
||||
* the convention of prepending an underscore to non-ANSI library function
|
||||
* names).
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.1.1.1 $
|
||||
* $Author: brandon6684 $
|
||||
* $Date: 2001/12/18 22:54:08 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TCHAR_H_
|
||||
#define _TCHAR_H_
|
||||
|
||||
/*
|
||||
* NOTE: This tests _UNICODE, which is different from the UNICODE define
|
||||
* used to differentiate Win32 API calls.
|
||||
*/
|
||||
#ifdef __unix__
|
||||
#define _TCHAR char*
|
||||
#endif
|
||||
#ifdef _UNICODE
|
||||
|
||||
|
||||
/*
|
||||
* Use TCHAR instead of char or wchar_t. It will be appropriately translated
|
||||
* if _UNICODE is correctly defined (or not).
|
||||
*/
|
||||
#ifndef _TCHAR_DEFINED
|
||||
#ifndef RC_INVOKED
|
||||
typedef wchar_t TCHAR;
|
||||
#endif /* Not RC_INVOKED */
|
||||
#define _TCHAR_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Enclose constant strings and literal characters in the _TEXT and _T macro to make
|
||||
* them unicode constant strings when _UNICODE is defined.
|
||||
*/
|
||||
#define _TEXT(x) L ## x
|
||||
#define _T(x) L ## x
|
||||
|
||||
/*
|
||||
* Unicode functions
|
||||
*/
|
||||
|
||||
#define _tprintf wprintf
|
||||
#define _ftprintf fwprintf
|
||||
#define _stprintf swprintf
|
||||
#define _sntprintf _snwprintf
|
||||
#define _vtprintf vwprintf
|
||||
#define _vftprintf vfwprintf
|
||||
#define _vstprintf vswprintf
|
||||
#define _vsntprintf _vsnwprintf
|
||||
#define _tscanf wscanf
|
||||
#define _ftscanf fwscanf
|
||||
#define _stscanf swscanf
|
||||
#define _fgettc fgetwc
|
||||
#define _fgettchar _fgetwchar
|
||||
#define _fgetts fgetws
|
||||
#define _fputtc fputwc
|
||||
#define _fputtchar _fputwchar
|
||||
#define _fputts fputws
|
||||
#define _gettc getwc
|
||||
#define _getts getws
|
||||
#define _puttc putwc
|
||||
#define _putts putws
|
||||
#define _ungettc ungetwc
|
||||
#define _tcstod wcstod
|
||||
#define _tcstol wcstol
|
||||
#define _tcstoul wcstoul
|
||||
#define _tcscat wcscat
|
||||
#define _tcschr wcschr
|
||||
#define _tcscmp wcscmp
|
||||
#define _tcscpy wcscpy
|
||||
#define _tcscspn wcscspn
|
||||
#define _tcslen wcslen
|
||||
#define _tcsncat wcsncat
|
||||
#define _tcsncmp wcsncmp
|
||||
#define _tcsncpy wcsncpy
|
||||
#define _tcspbrk wcspbrk
|
||||
#define _tcsrchr wcsrchr
|
||||
#define _tcsspn wcsspn
|
||||
#define _tcsstr wcsstr
|
||||
#define _tcstok wcstok
|
||||
#define _tcsdup _wcsdup
|
||||
#define _tcsicmp _wcsicmp
|
||||
#define _tcsnicmp _wcsnicmp
|
||||
#define _tcsnset _wcsnset
|
||||
#define _tcsrev _wcsrev
|
||||
#define _tcsset _wcsset
|
||||
#define _tcslwr _wcslwr
|
||||
#define _tcsupr _wcsupr
|
||||
#define _tcsxfrm wcsxfrm
|
||||
#define _tcscoll wcscoll
|
||||
#define _tcsicoll _wcsicoll
|
||||
#define _istalpha iswalpha
|
||||
#define _istupper iswupper
|
||||
#define _istlower iswlower
|
||||
#define _istdigit iswdigit
|
||||
#define _istxdigit iswxdigit
|
||||
#define _istspace iswspace
|
||||
#define _istpunct iswpunct
|
||||
#define _istalnum iswalnum
|
||||
#define _istprint iswprint
|
||||
#define _istgraph iswgraph
|
||||
#define _istcntrl iswcntrl
|
||||
#define _istascii iswascii
|
||||
#define _totupper towupper
|
||||
#define _totlower towlower
|
||||
#define _ttoi _wtoi
|
||||
#define _tcsftime wcsftime
|
||||
|
||||
#else /* Not _UNICODE */
|
||||
|
||||
/*
|
||||
* TCHAR, the type you should use instead of char.
|
||||
*/
|
||||
#ifndef _TCHAR_DEFINED
|
||||
#ifndef RC_INVOKED
|
||||
typedef char TCHAR;
|
||||
#endif
|
||||
#define _TCHAR_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enclose constant strings and characters in the _TEXT and _T macro.
|
||||
*/
|
||||
#define _TEXT(x) x
|
||||
#define _T(x) x
|
||||
|
||||
|
||||
/*
|
||||
* Non-unicode (standard) functions
|
||||
*/
|
||||
|
||||
#define _tprintf printf
|
||||
#define _ftprintf fprintf
|
||||
#define _stprintf sprintf
|
||||
#define _sntprintf _snprintf
|
||||
#define _vtprintf vprintf
|
||||
#define _vftprintf vfprintf
|
||||
#define _vstprintf vsprintf
|
||||
#define _vsntprintf _vsnprintf
|
||||
#define _tscanf scanf
|
||||
#define _ftscanf fscanf
|
||||
#define _stscanf sscanf
|
||||
#define _fgettc fgetc
|
||||
#define _fgettchar _fgetchar
|
||||
#define _fgetts fgets
|
||||
#define _fputtc fputc
|
||||
#define _fputtchar _fputchar
|
||||
#define _fputts fputs
|
||||
#define _gettc getc
|
||||
#define _getts gets
|
||||
#define _puttc putc
|
||||
#define _putts puts
|
||||
#define _ungettc ungetc
|
||||
#define _tcstod strtod
|
||||
#define _tcstol strtol
|
||||
#define _tcstoul strtoul
|
||||
#define _tcscat strcat
|
||||
#define _tcschr strchr
|
||||
#define _tcscmp strcmp
|
||||
#define _tcscpy strcpy
|
||||
#define _tcscspn strcspn
|
||||
#define _tcslen strlen
|
||||
#define _tcsncat strncat
|
||||
#define _tcsncmp strncmp
|
||||
#define _tcsncpy strncpy
|
||||
#define _tcspbrk strpbrk
|
||||
#define _tcsrchr strrchr
|
||||
#define _tcsspn strspn
|
||||
#define _tcsstr strstr
|
||||
#define _tcstok strtok
|
||||
#define _tcsdup _strdup
|
||||
#define _tcsicmp _stricmp
|
||||
#define _tcsnicmp _strnicmp
|
||||
#define _tcsnset _strnset
|
||||
#define _tcsrev _strrev
|
||||
#define _tcsset _strset
|
||||
#define _tcslwr _strlwr
|
||||
#define _tcsupr _strupr
|
||||
#define _tcsxfrm strxfrm
|
||||
#define _tcscoll strcoll
|
||||
#define _tcsicoll _stricoll
|
||||
#define _istalpha isalpha
|
||||
#define _istupper isupper
|
||||
#define _istlower islower
|
||||
#define _istdigit isdigit
|
||||
#define _istxdigit isxdigit
|
||||
#define _istspace isspace
|
||||
#define _istpunct ispunct
|
||||
#define _istalnum isalnum
|
||||
#define _istprint isprint
|
||||
#define _istgraph isgraph
|
||||
#define _istcntrl iscntrl
|
||||
#define _istascii isascii
|
||||
#define _totupper toupper
|
||||
#define _totlower tolower
|
||||
#define _ttoi atoi
|
||||
#define _tcsftime strftime
|
||||
|
||||
#ifdef __amigaos4__
|
||||
#define _TCHAR wchar_t
|
||||
#endif
|
||||
|
||||
#endif /* Not _UNICODE */
|
||||
|
||||
#endif /* Not _TCHAR_H_ */
|
||||
|
@ -13,4 +13,4 @@ public:
|
||||
long memDif(){return mem-clock();};
|
||||
};
|
||||
|
||||
#endif //TIMEHANDLER_H
|
||||
#endif //TIMEHANDLER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user