Commit da77bc26 authored by Yuri Chornoivan's avatar Yuri Chornoivan
Browse files

Fix minor EBN issues

parent 343befc3
......@@ -40,7 +40,7 @@ Ai::Ai(int pn,ShipSprite* s[2],QList<BulletSprite*>* b[2],
opponentNumber=(pn+1)%2;
cfg=c;
for(i=0;i<2;i++)
for(i=0;i<2;++i)
{
ship[i]=s[i];
bullets[i]=b[i];
......@@ -219,15 +219,15 @@ void Ai::calculateNextPositions()
j=(int)(calcPositionNumber[Options::aiDifficulty(playerNumber)]/cfg->gamespeed);
if(shipsNextPositions[0]->size() != j)
for(i=0;i<2;i++)
for(i=0;i<2;++i)
shipsNextPositions[i]->resize(j);
for(i=0;i<2;i++)
for(i=0;i<2;++i)
nextPositions(ship[i]->toAiSprite(),shipsNextPositions[i],
calcFrameIncrement[Options::aiDifficulty(playerNumber)]);
if(cfg->maxMines > aiMines[0]->size())
for(i=0;i<2;i++)
for(i=0;i<2;++i)
aiMines[i]->resize(cfg->maxMines);
for(i=0;i<2;i++)
......@@ -263,17 +263,17 @@ void Ai::tryShots()
if(bullets[playerNumber]->count() <
(cfg->maxBullets+ship[playerNumber]->getBulletPowerups()))
{
for(f=0;f<=frameNum;f++)
for(f=0;f<=frameNum;++f)
{
if(f!=0)
for(i=0;i<frameIncrement;i++)
for(i=0;i<frameIncrement;++i)
me=nextPosition(me,cfg->gamespeed);
else
me=nextPosition(me,cfg->gamespeed);
if(!ship[playerNumber]->reloadsBullet(f*frameIncrement*cfg->gamespeed))
{
for(i=0;i<2;i++)
for(i=0;i<2;++i)
{
if((f==0)&&(i==1))
continue;
......@@ -325,7 +325,7 @@ Hit Ai::firstObject(AiSprite shot,int time,int frames)
num=optime-basetime;
if(num>0)
{
for(t=0;(t<num)&&(!hitfound)&&(!shot.sun);t++)
for(t=0;(t<num)&&(!hitfound)&&(!shot.sun);++t)
{
if(t==0)
shot=nextPosition(shot,cfg->gamespeed*rtime);
......@@ -333,7 +333,7 @@ Hit Ai::firstObject(AiSprite shot,int time,int frames)
shot=nextPosition(shot,cfg->gamespeed*frames);
//distance to other objects
for(i=0;i<2;i++)
for(i=0;i<2;++i)
{
distx=(*(shipsNextPositions[i]))[basetime].x-shot.x;
disty=(*(shipsNextPositions[i]))[basetime].y-shot.y;
......@@ -364,7 +364,7 @@ Hit Ai::firstObject(AiSprite shot,int time,int frames)
}
//mines
for(m=0;m<mineNumber[i];m++)
for(m=0;m<mineNumber[i];++m)
{
distx=(*(aiMines[i]))[m].x-shot.x;
disty=(*(aiMines[i]))[m].y-shot.y;
......@@ -445,10 +445,10 @@ void Ai::testForHits()
objectsHitByShip.clear();
qDeleteAll(minesHitByShot);
minesHitByShot.clear();
for(i=0;i<2;i++)
for(i=0;i<2;++i)
{
listsize = bullets[i]->size();
for (j=0; j<listsize; j++)
for (j=0; j<listsize; ++j)
{
bullet=bullets[i]->value(j);
shot=bullet->toAiSprite();
......@@ -471,7 +471,7 @@ void Ai::testForHits()
hit.distance=400;
for(i=0;(i<shipsNextPositions[0]->size()) &&
!(*shipsNextPositions[playerNumber])[i].sun;i++)
!(*shipsNextPositions[playerNumber])[i].sun;++i)
{
if((borderTime<0) && (*shipsNextPositions[playerNumber])[i].border)
borderTime=i*calcFrameIncrement[Options::aiDifficulty(playerNumber)];
......@@ -483,8 +483,8 @@ void Ai::testForHits()
sunTime=i*calcFrameIncrement[Options::aiDifficulty(playerNumber)];
if(!hitfound)
for(p=0;p<2;p++)
for(m=0;m<mineNumber[p];m++)
for(p=0;p<2;++p)
for(m=0;m<mineNumber[p];++m)
{
dx=(*shipsNextPositions[playerNumber])[i].x-(*aiMines[p])[m].x;
dy=(*shipsNextPositions[playerNumber])[i].y-(*aiMines[p])[m].y;
......@@ -525,7 +525,7 @@ void Ai::shotScores()
dist=dx*dx+dy*dy;
listsize = myShots.size();
for (j=0; j<listsize; j++)
for (j=0; j<listsize; ++j)
{
s = myShots[j];
fuel=(100-(ship[playerNumber]->getEnergy()-cfg->shotEnergyNeed));
......@@ -538,7 +538,7 @@ void Ai::shotScores()
if(s->hit.object==HMINE)
{
found=false;
for (i=0; i<objectsHitByShip.size() && !found; i++)
for (i=0; i<objectsHitByShip.size() && !found; ++i)
{
h=objectsHitByShip[i];
if((h->object==HMINE)&&(h->playerNumber==s->hit.playerNumber)
......@@ -553,7 +553,7 @@ void Ai::shotScores()
{
foundmh=false;
listsize2 = minesHitByShot.size();
for (k=0; k<listsize2 && !foundmh; k++)
for (k=0; k<listsize2 && !foundmh; ++k)
{
mh = minesHitByShot[k];
if((mh->playerNumber==s->hit.playerNumber)
......@@ -705,7 +705,7 @@ void Ai::chooseAction()
int listsize; // used for caching QtList::size()
bestShot=0;
listsize = myShots.size();
for (i=0; i<listsize; i++)
for (i=0; i<listsize; ++i)
{
s=myShots[i];
if(s->score<bestScore)
......
......@@ -160,14 +160,14 @@ ConfigSetup::ConfigSetup(SConfig *custom,QWidget *parent)
boxlayout->setMargin(6);
tabs=new QTabWidget(this);
for(i=0;i<TabNum;i++)
for(i=0;i<TabNum;++i)
{
configWidgets[i]=new QWidget(tabs);
stacklayout[i]=new QGridLayout(configWidgets[i]);
stacklayout[i]->setMargin(10);
}
for(i=0;i<EditNum;i++)
for(i=0;i<EditNum;++i)
{
label[i]=new QLabel(i18n(LabelName[i]),configWidgets[Parent[i]]);
slider[i]=new QSlider(Qt::Horizontal,configWidgets[Parent[i]]);
......@@ -182,7 +182,7 @@ ConfigSetup::ConfigSetup(SConfig *custom,QWidget *parent)
configCombo=new QComboBox(this);
configCombo->setEditable(false);
connect(configCombo, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), this, &ConfigSetup::configSelected);
for(i=0;i<predefinedConfigNum;i++)
for(i=0;i<predefinedConfigNum;++i)
configCombo->addItem(i18n(predefinedConfigName[i]));
configCombo->addItem(i18nc("custom values","Custom"));
......@@ -190,14 +190,14 @@ ConfigSetup::ConfigSetup(SConfig *custom,QWidget *parent)
boxlayout->addWidget(configCombo);
boxlayout->addWidget(tabs);
for(i=0;i<EditNum;i++)
for(i=0;i<EditNum;++i)
{
stacklayout[Parent[i]]->addWidget(label[i],Position[i],0);
stacklayout[Parent[i]]->addWidget(slider[i],Position[i],1);
stacklayout[Parent[i]]->addWidget(value[i],Position[i],2);
}
for(i=0;i<TabNum;i++)
for(i=0;i<TabNum;++i)
stacklayout[i]->activate();
tabs->addTab(configWidgets[0],i18nc("general game settings","General"));
......@@ -375,7 +375,7 @@ void ConfigSetup::setValue(int ednum,double val)
else
{
h=1;
for(n=0;h<EditDiv[ednum];n++)
for(n=0;h<EditDiv[ednum];++n)
h*=10;
str.sprintf("%*.*f",LCDLen,n,val);
}
......@@ -404,7 +404,7 @@ void ConfigSetup::sliderChanged(int val)
else
{
h=1;
for(n=0;h<EditDiv[i];n++)
for(n=0;h<EditDiv[i];++n)
h*=10;
str.sprintf("%*.*f",LCDLen,n,(double)val/EditDiv[i]);
}
......
......@@ -76,9 +76,9 @@ MyMainView::MyMainView(QWidget *parent)
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setFrameStyle(QFrame::NoFrame);
for(p=0;p<2;p++)
for(p=0;p<2;++p)
{
for(i=0;i<PlayerKeyNum;i++)
for(i=0;i<PlayerKeyNum;++i)
playerKeyPressed[p][i]=false;
bulletShot[p]=false;
minePut[p]=false;
......@@ -103,7 +103,7 @@ MyMainView::MyMainView(QWidget *parent)
readSprites();
for(i=0;i<2;i++)
for(i=0;i<2;++i)
{
// ship[i]->setBoundsAction(QwRealMobileSprite::Wrap);
ship[i]->hide();
......@@ -243,7 +243,7 @@ void MyMainView::readConfig()
else
config=modifyConfig(customConfig);
for(i=0;i<2;i++)
for(i=0;i<2;++i)
ai[i]=new Ai(i,ship,bullets,mines,&config);
}
......@@ -430,20 +430,20 @@ void MyMainView::resizeEvent(QResizeEvent *event)
sun->setPos(QPointF(width()/2-1-(sun->width()/2),
height()/2-1-(sun->height()/2)));
for(i=0;i<2;i++)
for(i=0;i<2;++i)
{
// ship[i]->adoptSpritefieldBounds();
ship[i]->moveBy(mx,my);
listsize = mines[i]->size();
for (current=0; current<listsize; current++)
for (current=0; current<listsize; ++current)
{
// mine->adoptSpritefieldBounds();
mines[i]->value(current)->moveBy(mx,my);
}
listsize = bullets[i]->size();
for (current=0; current<listsize; current++)
for (current=0; current<listsize; ++current)
{
// bullet->adoptSpritefieldBounds();
bullets[i]->value(current)->moveBy(mx,my);
......@@ -481,7 +481,7 @@ void MyMainView::newRound()
ship[0]->setVelocity(config.startVelX,config.startVelY);
ship[1]->setVelocity(-config.startVelX,-config.startVelY);
for(i=0;i<2;i++)
for(i=0;i<2;++i)
{
ship[i]->show();
ship[i]->setEnergy(MAX_ENERGY);
......@@ -507,7 +507,7 @@ void MyMainView::newRound()
qDeleteAll(explosions);
explosions.clear();
gameEnd=-10.0;
for(i=0;i<PlayerKeyNum;i++)
for(i=0;i<PlayerKeyNum;++i)
{
playerKeyPressed[0][i]=false;
playerKeyPressed[1][i]=false;
......@@ -597,7 +597,7 @@ void MyMainView::timerEvent(QTimerEvent *event)
if( !stopped )
{
for(i=0;i<2;i++)
for(i=0;i<2;++i)
if(Options::playerIsAi(i)&&(ship[i]->getHitPoints()>0))
ai[i]->think();
......@@ -621,7 +621,7 @@ void MyMainView::moveShips()
MineSprite *mine;
for(i=0;i<2;i++)
for(i=0;i<2;++i)
{
bool playerIsAi = Options::playerIsAi(i);
olde=(int)ship[i]->getEnergy();
......@@ -874,7 +874,7 @@ void MyMainView::collisions()
int i;
int listsize; // used for caching QtList::size()
for(pl=0;pl<2;pl++)
for(pl=0;pl<2;++pl)
{
if(!ship[pl]->isStopped())
{
......@@ -969,7 +969,7 @@ void MyMainView::collisions()
}
listsize = mines[pl]->size();
for (i=0; i<listsize; i++)
for (i=0; i<listsize; ++i)
{
mine = mines[pl]->value(i);
if(!mine->explodes())
......@@ -1041,7 +1041,7 @@ void MyMainView::collisions()
}
for(pl=0;pl<2;pl++)
for(pl=0;pl<2;++pl)
{
hp=ship[pl]->getHitPoints();
if(hp!=oldhp[pl])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment