Fix a load of warnings (two were actual errors, only in diagnostics though)

heavy-resources
Julius Michaelis 2014-04-17 19:16:24 +02:00
parent f4e93d13bf
commit 2c7d9c0549
11 changed files with 36 additions and 29 deletions

View File

@ -717,6 +717,8 @@ void C4ControlPlayerAction::Execute() const
callback->Exec(nullptr, &pars);
break;
}
case CPA_NoAction: break;
}
}

View File

@ -925,7 +925,7 @@ void C4Playback::Clear()
if (Config.General.DebugRec)
{
C4IDPacket *pkt;
while (pkt = DebugRec.firstPkt()) DebugRec.Delete(pkt);
while ((pkt = DebugRec.firstPkt())) DebugRec.Delete(pkt);
if (Config.General.DebugRecExternalFile[0])
DbgRecFile.Close();
}
@ -1035,7 +1035,7 @@ void C4Playback::Check(C4RecordChunkType eType, const uint8_t *pData, int iSize)
{
// check debug rec in list
C4IDPacket *pkt;
if (pkt = DebugRec.firstPkt())
if ((pkt = DebugRec.firstPkt()))
{
// copy from list
PktInReplay = *static_cast<C4PktDebugRec *>(pkt->getPkt());

View File

@ -228,7 +228,7 @@ void C4EditCursor::ClearSelection()
// remove all objects from selection and do script callbacks
// iterate safely because callback might delete selected objects!
C4Object *obj;
while (obj = Selection.GetObject(0))
while ((obj = Selection.GetObject(0)))
{
Selection.Remove(obj);
if (obj->Status)

View File

@ -206,7 +206,7 @@ static bool FnCheckConstructionSite(C4PropList * _this, C4PropList * PropList, i
{
// Make sure parameters are valid
if (!PropList || !PropList->GetDef())
return NULL;
return false;
// Local object calls override position offset, owner
if (Object(_this))
@ -1568,7 +1568,7 @@ static bool FnClearParticles(C4PropList * _this)
{
#ifndef USE_CONSOLE
C4Object *obj;
if (obj = Object(_this))
if ((obj = Object(_this)))
{
if (obj->BackParticles)
obj->BackParticles->Clear();

View File

@ -751,11 +751,11 @@ bool C4Landscape::_SetPixIfMask(int32_t x, int32_t y, BYTE npix, BYTE nMask)
bool C4Landscape::CheckInstability(int32_t tx, int32_t ty, int32_t recursion_count)
{
int32_t mat=GetMat(tx,ty);
if (MatValid(mat))
if (MatValid(mat)) {
if (::MaterialMap.Map[mat].Instable)
return ::MassMover.Create(tx,ty);
// Get rid of single pixels
else if (::MaterialMap.Map[mat].DigFree && recursion_count<10)
else if (::MaterialMap.Map[mat].DigFree && recursion_count<10)
if ((!::GBackSolid(tx,ty+1)) + (!::GBackSolid(tx,ty-1)) + (!::GBackSolid(tx+1,ty)) + (!::GBackSolid(tx-1,ty)) >= 3)
{
if (!ClearPix(tx,ty)) return false;
@ -769,6 +769,7 @@ bool C4Landscape::CheckInstability(int32_t tx, int32_t ty, int32_t recursion_cou
CheckInstability(tx,ty+1,recursion_count);
return true;
}
}
return false;
}
@ -1454,11 +1455,12 @@ bool C4Landscape::SaveDiffInternal(C4Group &hGroup, bool fSyncSave)
bool fChanged = false;
if (!fSyncSave)
for (int y = 0; y < Height; y++)
for (int x = 0; x < Width; x++)
for (int x = 0; x < Width; x++) {
if (pInitial[y * Width + x] == _GetPix(x, y))
Surface8->SetPix(x,y,0xff);
else
fChanged = true;
}
if (fSyncSave || fChanged)
{

View File

@ -195,8 +195,8 @@ bool C4LandscapeRenderGL::InitMaterialTexture(C4TextureMap *pTexs)
// Find first (actual) texture
int iRefTexIx = 0; C4Texture *pRefTex; C4Surface *pRefSfc = NULL;
for(; pRefTex = pTexs->GetTexture(pTexs->GetTexture(iRefTexIx)); iRefTexIx++)
if(pRefSfc = pRefTex->Surface32)
for(; (pRefTex = pTexs->GetTexture(pTexs->GetTexture(iRefTexIx))); iRefTexIx++)
if((pRefSfc = pRefTex->Surface32))
break;
if(!pRefSfc)
return false;
@ -901,7 +901,7 @@ void C4LandscapeRenderGL::AddTexturesFromMap(C4TextureMap *pMap)
// Future work...
const C4TexMapEntry *pEntry;
for(int32_t i = 0; pEntry = pMap->GetEntry(i); i++)
for(int32_t i = 0; (pEntry = pMap->GetEntry(i)); i++)
// ToDo: Properly handle jumping back
AddTextureAnim(pEntry->GetTextureName());
@ -926,7 +926,7 @@ void C4LandscapeRenderGL::BuildMatMap(GLfloat *pFMap, GLubyte *pIMap)
// Got animation?
int iPhases = 1; const char *p = pEntry->GetTextureName();
while(p = strchr(p, '-')) { p++; iPhases++; }
while((p = strchr(p, '-'))) { p++; iPhases++; }
// Hard-coded hack. Fix me!
const int iPhaseLength = 300;
float phase = (iPhases == 1 ? 0 : float(C4TimeMilliseconds::Now().AsInt() % (iPhases * iPhaseLength)) / iPhaseLength);

View File

@ -1129,7 +1129,7 @@ void C4MCParser::ParseTo(C4MCNode *pToNode)
else if (SEqual(CurrTokenIdtf, C4MC_Point) && !pToNode->GetNodeByName(CurrTokenIdtf))
{
// only in overlays
if (!pToNode->Type() == MCN_Overlay)
if (!(pToNode->Type() == MCN_Overlay))
throw C4MCParserErr(this, C4MCErr_PointOnlyOvl);
// create point node, using default template
pNewNode = new C4MCPoint(this, pToNode, MapCreator->DefaultPoint, false);

View File

@ -130,7 +130,7 @@ void C4MapScriptMatTexMask::UnmaskSpec(C4String *spec)
const char *tex_name;
int32_t col;
for (int32_t itex=0; (tex_name=::TextureMap.GetTexture(itex)); itex++)
if (col = ::TextureMap.GetIndex(cspec,tex_name,false))
if ((col = ::TextureMap.GetIndex(cspec,tex_name,false)))
mat_mask[col] = true;
}
}
@ -262,7 +262,7 @@ static bool FnLayerSetPixel(C4PropList * _this, int32_t x, int32_t y, const C4Va
C4MapScriptLayer *layer = _this->GetMapScriptLayer();
if (!layer) return false;
int32_t to_value; C4String *to_value_s;
if (to_value_s = to_value_c4v.getStr())
if ((to_value_s = to_value_c4v.getStr()))
{
to_value = FnParTexCol(to_value_s);
}
@ -300,13 +300,13 @@ static bool FnLayerFindPosition(C4PropList * _this, C4PropList *out_pos, const C
{
// Layer script function: Find a position (x,y) that has a color matching mask_spec. Set resulting position as X,Y properties in out_pos prop list
C4MapScriptLayer *layer = _this->GetMapScriptLayer();
if (!layer) return NULL;
if (!layer) return false;
C4MapScriptMatTexMask mat_mask(mask_spec);
C4Rect search_rect;
if (!FnParRect(layer, rect, &search_rect)) return NULL;
if (!FnParRect(layer, rect, &search_rect)) return false;
int32_t x,y; bool result;
if (!max_tries) max_tries = 500;
if (result = layer->FindPos(search_rect, mat_mask, &x, &y, max_tries))
if ((result = layer->FindPos(search_rect, mat_mask, &x, &y, max_tries)))
{
if (out_pos && !out_pos->IsFrozen())
{
@ -409,7 +409,7 @@ bool C4MapScriptLayer::Blit(const C4Rect &rcBounds, const C4MapScriptAlgo *algo)
uint8_t col;
for (int32_t y=rcBounds.y; y<rcBounds.y+rcBounds.Hgt; ++y)
for (int32_t x=rcBounds.x; x<rcBounds.x+rcBounds.Wdt; ++x)
if (col=(*algo)(x,y))
if ((col=(*algo)(x,y)))
surface->_SetPix(x,y,col);
return true;
}
@ -605,4 +605,4 @@ bool C4MapScriptHost::InitializeMap(C4Group &group, CSurface8 **pmap_surface)
return !!result;
}
C4MapScriptHost MapScript;
C4MapScriptHost MapScript;

View File

@ -35,7 +35,7 @@ bool C4MapScriptAlgo::GetXYProps(const C4PropList *props, C4PropertyName k, int3
}
C4Value val; C4ValueArray *arr;
props->GetProperty(k, &val);
if (arr = val.getArray())
if ((arr = val.getArray()))
{
if (arr->GetSize() != 2)
throw new C4AulExecError(FormatString("C4MapScriptAlgo: Expected either integer or array with two integer elements in property \"%s\".", Strings.P[k].GetCStr()).getData());
@ -246,7 +246,7 @@ C4MapScriptAlgoModifier::C4MapScriptAlgoModifier(const C4PropList *props, int32_
for (int32_t i=0; i<n; ++i)
{
C4MapScriptAlgo *new_algo = FnParAlgo(ops->GetItem(i).getPropList());
if (!new_algo) throw new C4AulExecError(FormatString("C4MapScriptAlgo: Operand %d in property \"Op\" not valid.", (int)min_ops, (int)max_ops).getData());
if (!new_algo) throw new C4AulExecError(FormatString("C4MapScriptAlgo: Operand %d in property \"Op\" not valid.", (int)i).getData());
operands[i] = new_algo;
}
}
@ -280,7 +280,7 @@ uint8_t C4MapScriptAlgoOr::operator () (int32_t x, int32_t y) const
// Return first nonzero operand
uint8_t val;
for (std::vector<C4MapScriptAlgo *>::const_iterator i=operands.begin(); i != operands.end(); ++i)
if (val=(**i)(x,y)) return val;
if ((val=(**i)(x,y))) return val;
// If all operands are zero, return zero.
return 0;
}

View File

@ -125,10 +125,10 @@ bool C4MaterialShape::Load(C4Group &group, const char *filename)
{
min = max = *j;
}
if (j ->x<- overlap_left ) overlap_left =- j ->x;
if (j ->y<- overlap_top ) overlap_top =- j ->y;
if (j ->x> wdt+overlap_right ) overlap_right = j ->x- wdt;
if (j ->y> hgt+overlap_bottom) overlap_bottom = j ->y- hgt;
if (j ->x<- overlap_left ) overlap_left = -j->x;
if (j ->y<- overlap_top ) overlap_top = -j->y;
if (j ->x> wdt+overlap_right ) overlap_right = j->x - wdt;
if (j ->y> hgt+overlap_bottom) overlap_bottom = j->y - hgt;
}
center.x /= n; center.y /= n;
i->center = center; i->min = min; i->max = max;
@ -585,9 +585,12 @@ bool C4MaterialMap::CrossMapMaterials(const char* szEarthMaterial) // Called aft
{
// single material target
if (pReact->fInverseSpec)
for (int32_t cnt2=-1; cnt2<Num; cnt2++) if (cnt2!=tmat) SetMatReaction(cnt, cnt2, pReact);
for (int32_t cnt2=-1; cnt2<Num; cnt2++) {
if (cnt2!=tmat)
SetMatReaction(cnt, cnt2, pReact);
else
SetMatReaction(cnt, tmat, pReact);
}
}
else if (SEqualNoCase(pReact->TargetSpec.getData(), "All"))
{

View File

@ -145,7 +145,7 @@ C4Network2::C4Network2()
pVoteDialog(NULL),
fPausedForVote(false),
iLastOwnVoting(0),
fStreaming(NULL)
fStreaming(false)
{
}