1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +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;
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)
{

View File

@ -153,13 +153,13 @@ struct AddDefForButton
currentButton->additionalDefs.push_back(str);
}
};
void addGRes()
static void addGRes()
{
if(current)
conf.guiOptions[curRes] = *current; //we'll use by default settings from previous resolution
current = &conf.guiOptions[curRes];
}
void setGem(int x, int val)
static void setGem(int x, int val)
{
if(x)
current->ac.gemX[gnb] = val;
@ -361,4 +361,4 @@ void config::CConfigHandler::init()
GUIOptions * config::CConfigHandler::go()
{
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;
}
}
int getDir(int3 src, int3 dst)
static int getDir(int3 src, int3 dst)
{
int ret = -1;
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 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;
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;
}

View File

@ -54,7 +54,7 @@ extern TTF_Font * GEOR16;
extern std::queue<SDL_Event*> events;
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);
if(!h) return NULL;
@ -2425,7 +2425,7 @@ SDL_Surface * CMarketplaceWindow::CTradeableItem::getSurface()
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);
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.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;
for(;last<in.size();last++)
@ -32,7 +32,7 @@ unsigned int readNr(std::string &in, int &it)
ss >> last;
return last;
}
CBuilding * readBg(std::string &buf, int& it)
static CBuilding * readBg(std::string &buf, int& it)
{
CBuilding * nb = new CBuilding();
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;
ret.push_back(50); //sorrow
@ -874,4 +874,4 @@ void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int
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;
long c = a;

View File

@ -248,7 +248,7 @@ int CGObjectInstance::getSightRadious() const
return 3;
}
int lowestSpeed(const CGHeroInstance * chi)
static int lowestSpeed(const CGHeroInstance * chi)
{
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)
cb->setObjProperty(id,10,h->getOwner());
}
}
}

View File

@ -22,35 +22,35 @@ extern CLodHandler *bitmaph;
namespace SRSLPraserHelpers
{
int XYToHex(int x, int y)
static int XYToHex(int x, int 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);
}
int hexToY(int battleFieldPosition)
static int hexToY(int battleFieldPosition)
{
return battleFieldPosition/17;
}
int hexToX(int battleFieldPosition)
static int hexToX(int battleFieldPosition)
{
int pos = battleFieldPosition - hexToY(battleFieldPosition) * 17;
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));
}
//moves hex by one hex in given direction
//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)
{
@ -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);
}
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;
}
//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;
if(low == 0)

View File

@ -168,7 +168,7 @@ std::string DLL_EXPORT toString(MetaString &ms)
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;
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);
}
std::vector<StackFeature> stackEffectToFeature(const CStack::StackEffect & sse)
static std::vector<StackFeature> stackEffectToFeature(const CStack::StackEffect & sse)
{
std::vector<StackFeature> sf;
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::set<si32> ret;
@ -72,14 +72,14 @@ std::set<si32> convertBuildings(const std::set<si32> h3m, int castleID)
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;
for(int i=0; i<b; ++i)
ret*=a;
return ret;
}
unsigned char reverse(unsigned char arg)
static unsigned char reverse(unsigned char arg)
{
unsigned char ret = 0;
for (int i=0; i<8;i++)
@ -91,7 +91,7 @@ unsigned char reverse(unsigned char arg)
}
return ret;
}
EDefType getDefType(CGDefInfo * a)
static EDefType getDefType(CGDefInfo * a)
{
switch(a->id)
{
@ -147,7 +147,7 @@ EDefType getDefType(CGDefInfo * a)
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 amp=1;
@ -162,11 +162,11 @@ int readNormalNr (unsigned char * bufor, int pos, int bytCon = 4, bool cyclic =
}
return ret;
}
char readChar(unsigned char * bufor, int &i)
static char readChar(unsigned char * bufor, int &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;
std::string ret; ret.reserve(len);
@ -176,7 +176,7 @@ std::string readString(unsigned char * bufor, int &i)
}
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)
{
@ -1979,4 +1979,4 @@ CMapInfo::CMapInfo( std::string fname, unsigned char *map )
:CMapHeader(map),filename(fname)
{
countPlayers();
}
}

View File

@ -28,7 +28,7 @@
extern SDL_Surface * screen;
std::string nameFromType (int typ)
static std::string nameFromType (int typ)
{
switch(static_cast<TerrainTile::EterrainType>(typ))
{
@ -98,7 +98,7 @@ struct OCM_HLP
return (*a.first)<(*b.first);
}
} ocmptwo ;
void alphaTransformDef(CGDefInfo * defInfo)
static void alphaTransformDef(CGDefInfo * defInfo)
{
SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
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)
return;

View File

@ -92,11 +92,11 @@ public:
}
} 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) );
}
void giveExp(BattleResult &r)
static void giveExp(BattleResult &r)
{
r.exp[0] = 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);
for(int i=0; i<bat->stacks.size();i++)
@ -621,7 +621,7 @@ void CGameHandler::init(StartInfo *si, int Seed)
states.addPlayer(i->first);
}
bool evntCmp(const CMapEvent *a, const CMapEvent *b)
static bool evntCmp(const CMapEvent *a, const CMapEvent *b)
{
return *a < *b;
}
@ -804,7 +804,7 @@ void CGameHandler::run(bool resume)
namespace CGH
{
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)
{
@ -1461,7 +1461,6 @@ void CGameHandler::sendAndApply( CPackForClient * info )
void CGameHandler::save( const std::string &fname )
{
{
tlog0 << "Ordering clients to serialize...\n";
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
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);
}