1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

Made a few functions static or static inline.

This commit is contained in:
Frank Zago
2009-05-23 22:57:39 +00:00
parent 938aaac2ca
commit 6635cf4f23
18 changed files with 49 additions and 50 deletions

View File

@ -32,7 +32,7 @@
* *
*/ */
int gcd(int x, int y) static int gcd(int x, int y)
{ {
int temp; int temp;
if (y > x) if (y > x)

View File

@ -343,7 +343,7 @@ CHeroGSlot::~CHeroGSlot()
{ {
} }
std::string getBgName(int type) //TODO - co z tym zrobi�? static std::string getBgName(int type) //TODO - co z tym zrobi�?
{ {
switch (type) switch (type)
{ {

View File

@ -153,13 +153,13 @@ struct AddDefForButton
currentButton->additionalDefs.push_back(str); currentButton->additionalDefs.push_back(str);
} }
}; };
void addGRes() static void addGRes()
{ {
if(current) if(current)
conf.guiOptions[curRes] = *current; //we'll use by default settings from previous resolution conf.guiOptions[curRes] = *current; //we'll use by default settings from previous resolution
current = &conf.guiOptions[curRes]; current = &conf.guiOptions[curRes];
} }
void setGem(int x, int val) static void setGem(int x, int val)
{ {
if(x) if(x)
current->ac.gemX[gnb] = val; current->ac.gemX[gnb] = val;
@ -361,4 +361,4 @@ void config::CConfigHandler::init()
GUIOptions * config::CConfigHandler::go() GUIOptions * config::CConfigHandler::go()
{ {
return &guiOptions[std::pair<int,int>(cc.resx,cc.resy)]; return &guiOptions[std::pair<int,int>(cc.resx,cc.resy)];
} }

View File

@ -261,7 +261,7 @@ inline void delObjRect(const int & x, const int & y, const int & z, const int &
return; return;
} }
} }
int getDir(int3 src, int3 dst) static int getDir(int3 src, int3 dst)
{ {
int ret = -1; int ret = -1;
if(dst.x+1 == src.x && dst.y+1 == src.y) //tl if(dst.x+1 == src.x && dst.y+1 == src.y) //tl

View File

@ -48,7 +48,7 @@ CPreGame * CPG;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace s = CSDL_Ext; namespace s = CSDL_Ext;
int getNextCastle(int current, PlayerInfo * ourInf, bool next=true) //next=flase => previous castle static int getNextCastle(int current, PlayerInfo * ourInf, bool next=true) //next=flase => previous castle
{ {
int dir = next ? 1 : -1; int dir = next ? 1 : -1;
if (current==-2) //no castle - no change if (current==-2) //no castle - no change
@ -1122,7 +1122,7 @@ void MapSel::processGames(const std::vector<std::string> &pliczkiTemp)
} }
} }
bool isNull(CMapInfo*mi) static bool isNull(CMapInfo*mi)
{ {
return mi==NULL; return mi==NULL;
} }

View File

@ -54,7 +54,7 @@ extern TTF_Font * GEOR16;
extern std::queue<SDL_Event*> events; extern std::queue<SDL_Event*> events;
extern boost::mutex eventsM; extern boost::mutex eventsM;
StackState* getStackState(const CGObjectInstance *obj, int pos, bool town) static StackState* getStackState(const CGObjectInstance *obj, int pos, bool town)
{ {
const CGHeroInstance *h = dynamic_cast<const CGHeroInstance *>(obj); const CGHeroInstance *h = dynamic_cast<const CGHeroInstance *>(obj);
if(!h) return NULL; if(!h) return NULL;
@ -2425,7 +2425,7 @@ SDL_Surface * CMarketplaceWindow::CTradeableItem::getSurface()
return NULL; return NULL;
} }
} }
void initItems( std::vector<CMarketplaceWindow::CTradeableItem*> &i, std::vector<SDL_Rect> &p, int type, int amount, bool left, std::vector<int> *ids/*=NULL*/ ) static void initItems( std::vector<CMarketplaceWindow::CTradeableItem*> &i, std::vector<SDL_Rect> &p, int type, int amount, bool left, std::vector<int> *ids/*=NULL*/ )
{ {
i.resize(amount); i.resize(amount);
for(int j=0;j<amount;j++) for(int j=0;j<amount;j++)

View File

@ -447,7 +447,7 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src)
} }
// <=> // <=>
void prepareOutRect(SDL_Rect &dst, const SDL_Rect *dstRect, const SDL_Rect *clip_rect) static void prepareOutRect(SDL_Rect &dst, const SDL_Rect *dstRect, const SDL_Rect *clip_rect)
{ {
dst.x = std::max(dstRect->x,clip_rect->x); dst.x = std::max(dstRect->x,clip_rect->x);
dst.y = std::max(dstRect->y,clip_rect->y); dst.y = std::max(dstRect->y,clip_rect->y);

View File

@ -18,7 +18,7 @@ extern CLodHandler * bitmaph;
* *
*/ */
unsigned int readNr(std::string &in, int &it) static unsigned int readNr(std::string &in, int &it)
{ {
int last=it; int last=it;
for(;last<in.size();last++) for(;last<in.size();last++)
@ -32,7 +32,7 @@ unsigned int readNr(std::string &in, int &it)
ss >> last; ss >> last;
return last; return last;
} }
CBuilding * readBg(std::string &buf, int& it) static CBuilding * readBg(std::string &buf, int& it)
{ {
CBuilding * nb = new CBuilding(); CBuilding * nb = new CBuilding();
nb->resources.resize(RESOURCE_QUANTITY); nb->resources.resize(RESOURCE_QUANTITY);

View File

@ -23,7 +23,7 @@ extern CLodHandler * bitmaph;
* *
*/ */
std::vector<int> getMindSpells() static std::vector<int> getMindSpells()
{ {
std::vector<int> ret; std::vector<int> ret;
ret.push_back(50); //sorrow ret.push_back(50); //sorrow
@ -874,4 +874,4 @@ void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int
CCreatureHandler::~CCreatureHandler() CCreatureHandler::~CCreatureHandler()
{ {
} }

View File

@ -15,7 +15,7 @@
* *
*/ */
long long pow(long long a, int b) static long long pow(long long a, int b)
{ {
if (!b) return 1; if (!b) return 1;
long c = a; long c = a;

View File

@ -248,7 +248,7 @@ int CGObjectInstance::getSightRadious() const
return 3; return 3;
} }
int lowestSpeed(const CGHeroInstance * chi) static int lowestSpeed(const CGHeroInstance * chi)
{ {
if(!chi->army.slots.size()) if(!chi->army.slots.size())
{ {
@ -2994,4 +2994,4 @@ void CGOnceVisitable::searchTomb(const CGHeroInstance *h, ui32 accept) const
//add player to the visitors (for visited tooltop) //add player to the visitors (for visited tooltop)
cb->setObjProperty(id,10,h->getOwner()); cb->setObjProperty(id,10,h->getOwner());
} }
} }

View File

@ -22,35 +22,35 @@ extern CLodHandler *bitmaph;
namespace SRSLPraserHelpers namespace SRSLPraserHelpers
{ {
int XYToHex(int x, int y) static int XYToHex(int x, int y)
{ {
return x + 17 * y; return x + 17 * y;
} }
int XYToHex(std::pair<int, int> xy) static int XYToHex(std::pair<int, int> xy)
{ {
return XYToHex(xy.first, xy.second); return XYToHex(xy.first, xy.second);
} }
int hexToY(int battleFieldPosition) static int hexToY(int battleFieldPosition)
{ {
return battleFieldPosition/17; return battleFieldPosition/17;
} }
int hexToX(int battleFieldPosition) static int hexToX(int battleFieldPosition)
{ {
int pos = battleFieldPosition - hexToY(battleFieldPosition) * 17; int pos = battleFieldPosition - hexToY(battleFieldPosition) * 17;
return pos; return pos;
} }
std::pair<int, int> hexToPair(int battleFieldPosition) static std::pair<int, int> hexToPair(int battleFieldPosition)
{ {
return std::make_pair(hexToX(battleFieldPosition), hexToY(battleFieldPosition)); return std::make_pair(hexToX(battleFieldPosition), hexToY(battleFieldPosition));
} }
//moves hex by one hex in given direction //moves hex by one hex in given direction
//0 - left top, 1 - right top, 2 - right, 3 - right bottom, 4 - left bottom, 5 - left //0 - left top, 1 - right top, 2 - right, 3 - right bottom, 4 - left bottom, 5 - left
std::pair<int, int> gotoDir(int x, int y, int direction) static std::pair<int, int> gotoDir(int x, int y, int direction)
{ {
switch(direction) switch(direction)
{ {
@ -69,18 +69,18 @@ namespace SRSLPraserHelpers
} }
} }
std::pair<int, int> gotoDir(std::pair<int, int> xy, int direction) static std::pair<int, int> gotoDir(std::pair<int, int> xy, int direction)
{ {
return gotoDir(xy.first, xy.second, direction); return gotoDir(xy.first, xy.second, direction);
} }
bool isGoodHex(std::pair<int, int> xy) static bool isGoodHex(std::pair<int, int> xy)
{ {
return xy.first >=0 && xy.first < 17 && xy.second >= 0 && xy.second < 11; return xy.first >=0 && xy.first < 17 && xy.second >= 0 && xy.second < 11;
} }
//helper fonction for std::set<ui16> CSpell::rangeInHexes(unsigned int centralHex, ui8 schoolLvl ) const //helper fonction for std::set<ui16> CSpell::rangeInHexes(unsigned int centralHex, ui8 schoolLvl ) const
std::set<ui16> getInRange(unsigned int center, int low, int high) static std::set<ui16> getInRange(unsigned int center, int low, int high)
{ {
std::set<ui16> ret; std::set<ui16> ret;
if(low == 0) if(low == 0)

View File

@ -168,7 +168,7 @@ std::string DLL_EXPORT toString(MetaString &ms)
return ret; return ret;
} }
CGObjectInstance * createObject(int id, int subid, int3 pos, int owner) static CGObjectInstance * createObject(int id, int subid, int3 pos, int owner)
{ {
CGObjectInstance * nobj; CGObjectInstance * nobj;
switch(id) switch(id)

View File

@ -612,12 +612,12 @@ DLL_EXPORT void SpellCast::applyGs( CGameState *gs )
} }
} }
StackFeature featureGenerator(StackFeature::ECombatFeatures type, si16 subtype, si32 value, ui16 turnsRemain, si32 additionalInfo = 0) static inline StackFeature featureGenerator(StackFeature::ECombatFeatures type, si16 subtype, si32 value, ui16 turnsRemain, si32 additionalInfo = 0)
{ {
return makeFeature(type, StackFeature::N_TURNS, subtype, value, StackFeature::SPELL_EFFECT, turnsRemain, additionalInfo); return makeFeature(type, StackFeature::N_TURNS, subtype, value, StackFeature::SPELL_EFFECT, turnsRemain, additionalInfo);
} }
std::vector<StackFeature> stackEffectToFeature(const CStack::StackEffect & sse) static std::vector<StackFeature> stackEffectToFeature(const CStack::StackEffect & sse)
{ {
std::vector<StackFeature> sf; std::vector<StackFeature> sf;
switch(sse.id) switch(sse.id)

View File

@ -17,7 +17,7 @@
* *
*/ */
std::set<si32> convertBuildings(const std::set<si32> h3m, int castleID) static std::set<si32> convertBuildings(const std::set<si32> h3m, int castleID)
{ {
std::map<int,int> mapa; std::map<int,int> mapa;
std::set<si32> ret; std::set<si32> ret;
@ -72,14 +72,14 @@ std::set<si32> convertBuildings(const std::set<si32> h3m, int castleID)
return ret; return ret;
} }
unsigned int intPow(unsigned int a, unsigned int b) static unsigned int intPow(unsigned int a, unsigned int b)
{ {
unsigned int ret=1; unsigned int ret=1;
for(int i=0; i<b; ++i) for(int i=0; i<b; ++i)
ret*=a; ret*=a;
return ret; return ret;
} }
unsigned char reverse(unsigned char arg) static unsigned char reverse(unsigned char arg)
{ {
unsigned char ret = 0; unsigned char ret = 0;
for (int i=0; i<8;i++) for (int i=0; i<8;i++)
@ -91,7 +91,7 @@ unsigned char reverse(unsigned char arg)
} }
return ret; return ret;
} }
EDefType getDefType(CGDefInfo * a) static EDefType getDefType(CGDefInfo * a)
{ {
switch(a->id) switch(a->id)
{ {
@ -147,7 +147,7 @@ EDefType getDefType(CGDefInfo * a)
return TERRAINOBJ_DEF; // nothing to be handled return TERRAINOBJ_DEF; // nothing to be handled
} }
} }
int readNormalNr (unsigned char * bufor, int pos, int bytCon = 4, bool cyclic = false) static int readNormalNr (unsigned char * bufor, int pos, int bytCon = 4, bool cyclic = false)
{ {
int ret=0; int ret=0;
int amp=1; int amp=1;
@ -162,11 +162,11 @@ int readNormalNr (unsigned char * bufor, int pos, int bytCon = 4, bool cyclic =
} }
return ret; return ret;
} }
char readChar(unsigned char * bufor, int &i) static char readChar(unsigned char * bufor, int &i)
{ {
return bufor[i++]; return bufor[i++];
} }
std::string readString(unsigned char * bufor, int &i) static std::string readString(unsigned char * bufor, int &i)
{ {
int len = readNormalNr(bufor,i); i+=4; int len = readNormalNr(bufor,i); i+=4;
std::string ret; ret.reserve(len); std::string ret; ret.reserve(len);
@ -176,7 +176,7 @@ std::string readString(unsigned char * bufor, int &i)
} }
return ret; return ret;
} }
CCreatureSet readCreatureSet(unsigned char * bufor, int &i, int number, bool version) //version==true for >RoE maps static CCreatureSet readCreatureSet(unsigned char * bufor, int &i, int number, bool version) //version==true for >RoE maps
{ {
if(version) if(version)
{ {
@ -1979,4 +1979,4 @@ CMapInfo::CMapInfo( std::string fname, unsigned char *map )
:CMapHeader(map),filename(fname) :CMapHeader(map),filename(fname)
{ {
countPlayers(); countPlayers();
} }

View File

@ -28,7 +28,7 @@
extern SDL_Surface * screen; extern SDL_Surface * screen;
std::string nameFromType (int typ) static std::string nameFromType (int typ)
{ {
switch(static_cast<TerrainTile::EterrainType>(typ)) switch(static_cast<TerrainTile::EterrainType>(typ))
{ {
@ -98,7 +98,7 @@ struct OCM_HLP
return (*a.first)<(*b.first); return (*a.first)<(*b.first);
} }
} ocmptwo ; } ocmptwo ;
void alphaTransformDef(CGDefInfo * defInfo) static void alphaTransformDef(CGDefInfo * defInfo)
{ {
SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
for(int yy=0;yy<defInfo->handler->ourImages.size();yy++) for(int yy=0;yy<defInfo->handler->ourImages.size();yy++)
@ -417,7 +417,7 @@ void CMapHandler::initObjectRects()
} }
} }
} }
void processDef (CGDefInfo* def) static void processDef (CGDefInfo* def)
{ {
if(def->id == 26) if(def->id == 26)
return; return;

View File

@ -92,11 +92,11 @@ public:
} }
} cmpst ; } cmpst ;
double distance(int3 a, int3 b) static inline double distance(int3 a, int3 b)
{ {
return std::sqrt( (double)(a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); return std::sqrt( (double)(a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
} }
void giveExp(BattleResult &r) static void giveExp(BattleResult &r)
{ {
r.exp[0] = 0; r.exp[0] = 0;
r.exp[1] = 0; r.exp[1] = 0;
@ -292,7 +292,7 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs)
} }
} }
CCreatureSet takeCasualties(int color, const CCreatureSet &set, BattleInfo *bat) static CCreatureSet takeCasualties(int color, const CCreatureSet &set, BattleInfo *bat)
{ {
CCreatureSet ret(set); CCreatureSet ret(set);
for(int i=0; i<bat->stacks.size();i++) for(int i=0; i<bat->stacks.size();i++)
@ -621,7 +621,7 @@ void CGameHandler::init(StartInfo *si, int Seed)
states.addPlayer(i->first); states.addPlayer(i->first);
} }
bool evntCmp(const CMapEvent *a, const CMapEvent *b) static bool evntCmp(const CMapEvent *a, const CMapEvent *b)
{ {
return *a < *b; return *a < *b;
} }
@ -804,7 +804,7 @@ void CGameHandler::run(bool resume)
namespace CGH namespace CGH
{ {
using namespace std; using namespace std;
void readItTo(ifstream & input, vector< vector<int> > & dest) static void readItTo(ifstream & input, vector< vector<int> > & dest)
{ {
for(int j=0; j<7; ++j) for(int j=0; j<7; ++j)
{ {
@ -1461,7 +1461,6 @@ void CGameHandler::sendAndApply( CPackForClient * info )
void CGameHandler::save( const std::string &fname ) void CGameHandler::save( const std::string &fname )
{ {
{ {
tlog0 << "Ordering clients to serialize...\n"; tlog0 << "Ordering clients to serialize...\n";
SaveGame sg(fname); SaveGame sg(fname);
@ -2261,7 +2260,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message )
} }
} }
ui32 calculateSpellDmg(const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature) static ui32 calculateSpellDmg(const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature)
{ {
ui32 ret = 0; //value to return ui32 ret = 0; //value to return
switch(sp->id) switch(sp->id)

View File

@ -43,7 +43,7 @@ int port = 3030;
* *
*/ */
void vaccept(tcp::acceptor *ac, tcp::socket *s, boost::system::error_code *error) static void vaccept(tcp::acceptor *ac, tcp::socket *s, boost::system::error_code *error)
{ {
ac->accept(*s,*error); ac->accept(*s,*error);
} }