1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

* refactoring

This commit is contained in:
mateuszb 2009-05-01 14:37:25 +00:00
parent b0e2d13b4e
commit bb8e505ccd
6 changed files with 12 additions and 12 deletions

View File

@ -872,7 +872,7 @@ void CTerrainRect::showPath(const SDL_Rect * extRect)
}
}
if ( ((currentPath->nodes[i].dist)-(*(currentPath->nodes.end()-1)).dist) > ((const CGHeroInstance*)(LOCPLINT->adventureInt->selection))->movement)
if ( ((currentPath->nodes[i].dist)-(*(currentPath->nodes.end()-1)).dist) > (static_cast<const CGHeroInstance*>(LOCPLINT->adventureInt->selection))->movement)
pn+=25;
if (pn>=0)
{
@ -1324,7 +1324,7 @@ void CAdvMapInt::fshowSpellbok()
return;
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), ((const CGHeroInstance*)LOCPLINT->adventureInt->selection));
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), (static_cast<const CGHeroInstance*>(LOCPLINT->adventureInt->selection)));
LOCPLINT->pushInt(spellWindow);
}
void CAdvMapInt::fadventureOPtions()

View File

@ -716,7 +716,7 @@ std::pair<int,int> CGameState::pickObject(CGObjectInstance *obj)
return std::pair<int,int>(79,ran()%7); //now it's OH3 style, use %8 for mithril
case 77: //random town
{
int align = ((CGTownInstance*)obj)->alignment,
int align = (static_cast<CGTownInstance*>(obj))->alignment,
f;
if(align>PLAYER_LIMIT-1)//same as owner / random
{
@ -741,7 +741,7 @@ std::pair<int,int> CGameState::pickObject(CGObjectInstance *obj)
case 216: //random dwelling
{
int faction = ran()%F_NUMBER;
CCreGen2ObjInfo* info =(CCreGen2ObjInfo*)obj->info;
CCreGen2ObjInfo* info = static_cast<CCreGen2ObjInfo*>(obj->info);
if (info->asCastle)
{
for(int i=0;i<map->objects.size();i++)
@ -779,7 +779,7 @@ std::pair<int,int> CGameState::pickObject(CGObjectInstance *obj)
case 217:
{
int faction = ran()%F_NUMBER;
CCreGenObjInfo* info =(CCreGenObjInfo*)obj->info;
CCreGenObjInfo* info = static_cast<CCreGenObjInfo*>(obj->info);
if (info->asCastle)
{
for(int i=0;i<map->objects.size();i++)
@ -815,7 +815,7 @@ std::pair<int,int> CGameState::pickObject(CGObjectInstance *obj)
}
case 218:
{
CCreGen3ObjInfo* info =(CCreGen3ObjInfo*)obj->info;
CCreGen3ObjInfo* info = static_cast<CCreGen3ObjInfo*>(obj->info);
int level = ((info->maxLevel-info->minLevel) ? (ran()%(info->maxLevel-info->minLevel)+info->minLevel) : (info->minLevel));
int cid = VLC->townh->towns[obj->subID].basicCreatures[level];
for(int i=0;i<VLC->objh->cregens.size();i++)

View File

@ -455,11 +455,11 @@ SDL_Surface * CMessage::genMessage
//ok
SDL_Rect trescRect = genRect((*addPics)[0]->ourImages[0].bitmap->h,hwo,((ret->w/2)-hwo-10),by);
SDL_BlitSurface((*addPics)[0]->ourImages[0].bitmap,NULL,ret,&trescRect);
((std::vector<SDL_Rect>*)(cb))->push_back(trescRect);
reinterpret_cast<std::vector<SDL_Rect>*>(cb)->push_back(trescRect);
//cancel
trescRect = genRect((*addPics)[1]->ourImages[0].bitmap->h,hwc,((ret->w/2)+10),by);
SDL_BlitSurface((*addPics)[1]->ourImages[0].bitmap,NULL,ret,&trescRect);
((std::vector<SDL_Rect>*)(cb))->push_back(trescRect);
reinterpret_cast<std::vector<SDL_Rect>*>(cb)->push_back(trescRect);
}
delete tekst;
return ret;

View File

@ -277,7 +277,7 @@ void HeroLevelUp::applyCl( CClient *cl )
if(vstd::contains(cl->playerint,h->tempOwner))
{
boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind(&CCallback::selectionMade,LOCPLINT->cb,_1,id));
cl->playerint[h->tempOwner]->heroGotLevel((const CGHeroInstance *)h,(int)primskill,skills, callback);
cl->playerint[h->tempOwner]->heroGotLevel(const_cast<const CGHeroInstance*>(h),static_cast<int>(primskill),skills, callback);
}
}

View File

@ -466,7 +466,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, CStack *att, CStack *def)
bat.bsa.clear();
bat.stackAttacking = att->ID;
std::set<BattleStackAttacked>::iterator i = bat.bsa.insert(BattleStackAttacked()).first;
BattleStackAttacked *bsa = (BattleStackAttacked *) &*i;
BattleStackAttacked *bsa = &*i;
bsa->stackAttacked = def->ID;
bsa->damageAmount = BattleInfo::calculateDmg(att, def, gs->getHero(att->attackerOwned ? gs->curB->hero1 : gs->curB->hero2), gs->getHero(def->attackerOwned ? gs->curB->hero1 : gs->curB->hero2), bat.shot());//counting dealt damage
@ -1339,7 +1339,7 @@ void CGameHandler::giveHeroArtifact(int artid, int hid, int position) //pos==-1
void CGameHandler::startBattleI(const CCreatureSet * army1, const CCreatureSet * army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, boost::function<void(BattleResult*)> cb) //use hero=NULL for no hero
{
boost::thread(boost::bind(&CGameHandler::startBattle,this,*(CCreatureSet *)army1,*(CCreatureSet *)army2,tile,(CGHeroInstance *)hero1,(CGHeroInstance *)hero2,cb));
boost::thread(boost::bind(&CGameHandler::startBattle,this,*const_cast<CCreatureSet *>(army1),*const_cast<CCreatureSet *>(army2),tile,const_cast<CGHeroInstance *>(hero1), const_cast<CGHeroInstance *>(hero2),cb));
}
void CGameHandler::startBattleI(int heroID, CCreatureSet army, int3 tile, boost::function<void(BattleResult*)> cb) //for hero<=>neutral army
{

View File

@ -121,7 +121,7 @@ void CVCMIServer::start()
intpr::shared_memory_object smo(intpr::open_only,"vcmi_memory",intpr::read_write);
smo.truncate(sizeof(ServerReady));
mr = new intpr::mapped_region(smo,intpr::read_write);
sr = (ServerReady*)mr->get_address();
sr = reinterpret_cast<ServerReady*>(mr->get_address());
}
catch(...)
{