Minor fixes!

This commit is contained in:
Martín Lucas Golini
2014-05-31 21:58:18 -03:00
parent 1e86bda44b
commit b25bf76330
11 changed files with 63 additions and 44 deletions

View File

@@ -873,17 +873,19 @@ bool cMap::LoadFromStream( cIOStream& IOS ) {
cLayer * tLayer = AddLayer( tLayerHdr->Type, tLayerHdr->Flags, std::string( tLayerHdr->Name ) );
tLayer->Offset( eeVector2f( (eeFloat)tLayerHdr->OffsetX, (eeFloat)tLayerHdr->OffsetY ) );
if ( NULL != tLayer ) {
tLayer->Offset( eeVector2f( (eeFloat)tLayerHdr->OffsetX, (eeFloat)tLayerHdr->OffsetY ) );
sPropertyHdr * tProps = eeNewArray( sPropertyHdr, tLayerHdr->PropertyCount );
sPropertyHdr * tProps = eeNewArray( sPropertyHdr, tLayerHdr->PropertyCount );
IOS.Read( (char*)&tProps[0], sizeof(sPropertyHdr) * tLayerHdr->PropertyCount );
IOS.Read( (char*)&tProps[0], sizeof(sPropertyHdr) * tLayerHdr->PropertyCount );
for ( z = 0; z < tLayerHdr->PropertyCount; z++ ) {
tLayer->AddProperty( std::string( tProps[z].Name ), std::string( tProps[z].Value ) );
for ( z = 0; z < tLayerHdr->PropertyCount; z++ ) {
tLayer->AddProperty( std::string( tProps[z].Name ), std::string( tProps[z].Value ) );
}
eeSAFE_DELETE_ARRAY( tProps );
}
eeSAFE_DELETE_ARRAY( tProps );
}
bool ThereIsTiled = false;

View File

@@ -219,7 +219,7 @@ void cConsole::Draw() {
}
}
if ( mShowFps ) {
if ( mShowFps && NULL != mFont ) {
eeColorA OldColor1( mFont->Color() );
mFont->Color( eeColorA () );
mFont->SetText( "FPS: " + String::ToStr( mWindow->FPS() ) );

View File

@@ -428,7 +428,8 @@ eeSize cImage::Size() {
void cImage::ClearCache() {
if ( mLoadedFromStbi ) {
free( mPixels );
if ( NULL != mPixels )
free( mPixels );
} else {
eeSAFE_DELETE_ARRAY( mPixels );
}

View File

@@ -113,7 +113,7 @@ void cParticleSystem::Reset( cParticle * P ) {
x = ( mPos2.x - mPos.x + 1 ) * Math::Randf() + mPos.x;
y = ( mPos2.y - mPos.y + 1 ) * Math::Randf() + mPos.y;
P->Reset( mPos.x, mPos.y, Math::Randf() - 0.5f, ( Math::Randf() - 1.1f ) * 8.5f, 0.f, 0.05f, mSize );
P->Reset( x, y, Math::Randf() - 0.5f, ( Math::Randf() - 1.1f ) * 8.5f, 0.f, 0.05f, mSize );
P->Color( eeColorAf( 1.f, 0.5f, 0.1f, ( Math::Randf() * 0.5f ) ), Math::Randf() * 0.4f + 0.01f );
break;
}

View File

@@ -419,12 +419,16 @@ bool cSprite::AddSubFrame( cSubTexture * SubTexture, const eeUint& NumFrame, con
else
NSF = NumSubFrame;
if ( mFrames[NF].Spr.size() != (eeUint)mSubFrames )
mFrames[NF].Spr.resize( mSubFrames );
if ( NF <= mFrames.size() ) {
if ( mFrames[NF].Spr.size() != (eeUint)mSubFrames )
mFrames[NF].Spr.resize( mSubFrames );
mFrames[NF].Spr[NSF] = SubTexture;
mFrames[NF].Spr[NSF] = SubTexture;
return true;
return true;
}
return false;
}
eeUint cSprite::AddFrame( cSubTexture * SubTexture ) {

View File

@@ -304,7 +304,7 @@ Uint8 * cSubTexture::Lock() {
}
bool cSubTexture::Unlock( const bool& KeepData, const bool& Modified ) {
if ( NULL != mPixels ) {
if ( NULL != mPixels && NULL != mTexture ) {
if ( Modified ) {
cTextureSaver saver( mTexture->Handle() );

View File

@@ -105,7 +105,7 @@ bool cTexturePacker::MergeNodes() {
cTexturePackerNode *f = mFreeList;
while ( f ) {
cTexturePackerNode * prev = 0;
cTexturePackerNode * prev = NULL;
cTexturePackerNode * c = mFreeList;
while ( c ) {
@@ -113,7 +113,9 @@ bool cTexturePacker::MergeNodes() {
if ( f->Merge( *c ) ) {
eeASSERT( prev );
prev->SetNext( c->GetNext() );
if ( NULL != prev ) {
prev->SetNext( c->GetNext() );
}
eeSAFE_DELETE( c );
@@ -732,11 +734,13 @@ void cTexturePacker::ChildSave( const EE_SAVE_TYPE& Format ) {
Parent = Parent->GetParent();
}
std::string fFpath = FileSystem::FileRemoveExtension( LastParent->GetFilepath() );
std::string fExt = FileSystem::FileExtension( LastParent->GetFilepath() );
std::string fName = fFpath + "_ch" + String::ToStr( ParentCount ) + "." + fExt;
if ( NULL != LastParent ) {
std::string fFpath = FileSystem::FileRemoveExtension( LastParent->GetFilepath() );
std::string fExt = FileSystem::FileExtension( LastParent->GetFilepath() );
std::string fName = fFpath + "_ch" + String::ToStr( ParentCount ) + "." + fExt;
mChild->Save( fName, Format, mSaveExtensions );
mChild->Save( fName, Format, mSaveExtensions );
}
}
}

View File

@@ -642,6 +642,8 @@ void cUIControl::ChildAdd( cUIControl * ChildCtrl ) {
}
void cUIControl::ChildAddAt( cUIControl * ChildCtrl, Uint32 Pos ) {
eeASSERT( NULL != ChildCtrl );
cUIControl * ChildLoop = mChild;
ChildCtrl->Parent( this );
@@ -649,32 +651,36 @@ void cUIControl::ChildAddAt( cUIControl * ChildCtrl, Uint32 Pos ) {
ChildRemove( ChildCtrl );
ChildCtrl->mParentCtrl = this;
if( Pos == 0 ) {
if ( mChild == NULL ) {
mChild = ChildCtrl;
mChildLast = ChildCtrl;
ChildCtrl->mNext = NULL;
ChildCtrl->mPrev = NULL;
} else {
if ( ChildLoop == NULL ) {
mChild = ChildCtrl;
mChildLast = ChildCtrl;
ChildCtrl->mNext = NULL;
ChildCtrl->mPrev = NULL;
} else {
if( Pos == 0 ) {
mChild->mPrev = ChildCtrl;
ChildCtrl->mNext = mChild;
ChildCtrl->mPrev = NULL;
mChild = ChildCtrl;
} else {
Uint32 i = 0;
while ( NULL != ChildLoop->mNext && i < Pos ) {
ChildLoop = ChildLoop->mNext;
i++;
}
cUIControl * ChildTmp = ChildLoop->mNext;
ChildLoop->mNext = ChildCtrl;
ChildCtrl->mPrev = ChildLoop;
ChildCtrl->mNext = ChildTmp;
if ( NULL != ChildTmp ) {
ChildTmp->mPrev = ChildCtrl;
} else {
mChildLast = ChildCtrl;
}
}
} else {
Uint32 i = 0;
while ( NULL != ChildLoop->mNext && i < Pos ) {
ChildLoop = ChildLoop->mNext;
i++;
}
cUIControl * ChildTmp = ChildLoop->mNext;
ChildLoop->mNext = ChildCtrl;
ChildCtrl->mPrev = ChildLoop;
ChildCtrl->mNext = ChildTmp;
ChildTmp->mPrev = ChildCtrl;
}
}

View File

@@ -326,6 +326,8 @@ const eeColorA& cUIManager::HighlightOverColor() const {
}
void cUIManager::CheckTabPress( const Uint32& KeyCode ) {
eeASSERT( NULL != mFocusControl );
if ( KeyCode == KEY_TAB ) {
cUIControl * Ctrl = mFocusControl->NextComplexControl();

View File

@@ -315,7 +315,7 @@ void cUITextBox::DrawSelection() {
return;
}
Int32 lastEnd = end;
Int32 lastEnd;
eeVector2i initPos, endPos;
cPrimitives P;

View File

@@ -41,7 +41,7 @@ cCursorX11::~cCursorX11() {
}
void cCursorX11::Create() {
if ( NULL == mImage && mImage->MemSize() )
if ( NULL == mImage || 0 == mImage->MemSize() )
return;
XcursorImage * image;