From 4e70877ef1e19a0e0148551904571673048c2022 Mon Sep 17 00:00:00 2001 From: "spartanj@gmail.com" Date: Mon, 22 Aug 2011 19:36:50 -0300 Subject: [PATCH] Changed the way to know if a GameObject is some type. --- src/base.hpp | 9 +++++++++ src/gaming/cgameobject.cpp | 8 -------- src/gaming/cgameobject.hpp | 6 +----- src/gaming/cgameobjectshape.cpp | 4 ++++ src/gaming/cgameobjectshape.hpp | 2 ++ src/gaming/cgameobjectshapeex.cpp | 4 ++++ src/gaming/cgameobjectshapeex.hpp | 2 ++ src/gaming/cgameobjectsprite.cpp | 4 ++++ src/gaming/cgameobjectsprite.hpp | 2 ++ src/gaming/cgameobjectvirtual.cpp | 4 ++++ src/gaming/cgameobjectvirtual.hpp | 2 ++ src/gaming/cmap.cpp | 2 +- src/ui/cuimessagebox.cpp | 4 ++-- src/ui/cuimessagebox.hpp | 2 +- 14 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/base.hpp b/src/base.hpp index 07a506be6..939d188e2 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -229,6 +229,15 @@ namespace EE { typedef unsigned int eeUint; typedef signed int eeInt; + #if SOPHIST_has_64 + typedef SOPHIST_uint64 Uint64; + typedef SOPHIST_int64 Int64; + #else + typedef SOPHIST_uint32 Uint64; // Fallback to a 32 bit int + typedef SOPHIST_int32 Int64; // All the desktop platforms support 64bit ints, so this should not happend. + #warning 64bit ints represented with 32bit ints because the compiler or platform doesnt support it. + #endif + #define EE_PI 3.14159265358979323846 #define EE_PI2 6.28318530717958647692 const eeFloat EE_PI_180 = EE_PI / 180; diff --git a/src/gaming/cgameobject.cpp b/src/gaming/cgameobject.cpp index a950a864d..1a9e1723f 100644 --- a/src/gaming/cgameobject.cpp +++ b/src/gaming/cgameobject.cpp @@ -17,14 +17,6 @@ bool cGameObject::IsType( const Uint32& type ) { return type == Type(); } -bool cGameObject::InheritsFrom( const Uint32& Type ) { - return false; -} - -bool cGameObject::IsTypeOrInheritsFrom( const Uint32& Type ) { - return IsType( Type ) || InheritsFrom( Type ); -} - const Uint32& cGameObject::Flags() const { return mFlags; } diff --git a/src/gaming/cgameobject.hpp b/src/gaming/cgameobject.hpp index 4dc2156a3..eb64b6d3f 100644 --- a/src/gaming/cgameobject.hpp +++ b/src/gaming/cgameobject.hpp @@ -32,11 +32,7 @@ class EE_API cGameObject { virtual Uint32 Type() const; - bool IsType( const Uint32& type ); - - virtual bool InheritsFrom( const Uint32& Type ); - - bool IsTypeOrInheritsFrom( const Uint32& Type ); + virtual bool IsType( const Uint32& type ); const Uint32& Flags() const; diff --git a/src/gaming/cgameobjectshape.cpp b/src/gaming/cgameobjectshape.cpp index c8290d8dc..307a3d38e 100644 --- a/src/gaming/cgameobjectshape.cpp +++ b/src/gaming/cgameobjectshape.cpp @@ -21,6 +21,10 @@ Uint32 cGameObjectShape::Type() const { return GAMEOBJECT_TYPE_SHAPE; } +bool cGameObjectShape::IsType( const Uint32& type ) { + return ( Type() == type ) ? true : cGameObject::IsType( type ); +} + void cGameObjectShape::Draw() { if ( NULL != mShape ) { if ( mLayer->Map()->LightsEnabled() && mLayer->LightsEnabled() ) { diff --git a/src/gaming/cgameobjectshape.hpp b/src/gaming/cgameobjectshape.hpp index 0e66521e4..0c03419e0 100644 --- a/src/gaming/cgameobjectshape.hpp +++ b/src/gaming/cgameobjectshape.hpp @@ -33,6 +33,8 @@ class EE_API cGameObjectShape : public cGameObject { virtual Uint32 Type() const; + virtual bool IsType( const Uint32& type ); + virtual Uint32 DataId(); virtual void DataId( Uint32 Id ); diff --git a/src/gaming/cgameobjectshapeex.cpp b/src/gaming/cgameobjectshapeex.cpp index d938ba795..9ce24e067 100644 --- a/src/gaming/cgameobjectshapeex.cpp +++ b/src/gaming/cgameobjectshapeex.cpp @@ -27,6 +27,10 @@ Uint32 cGameObjectShapeEx::Type() const { return GAMEOBJECT_TYPE_SHAPEEX; } +bool cGameObjectShapeEx::IsType( const Uint32& type ) { + return ( Type() == type ) ? true : cGameObjectShape::IsType( type ); +} + void cGameObjectShapeEx::Draw() { if ( NULL != mShape ) { if ( mLayer->Map()->LightsEnabled() && mLayer->LightsEnabled() ) { diff --git a/src/gaming/cgameobjectshapeex.hpp b/src/gaming/cgameobjectshapeex.hpp index 1768b5d25..f5f9eb6d6 100644 --- a/src/gaming/cgameobjectshapeex.hpp +++ b/src/gaming/cgameobjectshapeex.hpp @@ -16,6 +16,8 @@ class EE_API cGameObjectShapeEx : public cGameObjectShape { virtual Uint32 Type() const; + virtual bool IsType( const Uint32& type ); + virtual void FlagSet( const Uint32& Flag ); protected: EE_PRE_BLEND_FUNC mBlend; diff --git a/src/gaming/cgameobjectsprite.cpp b/src/gaming/cgameobjectsprite.cpp index c00084a27..b024b4f21 100644 --- a/src/gaming/cgameobjectsprite.cpp +++ b/src/gaming/cgameobjectsprite.cpp @@ -23,6 +23,10 @@ Uint32 cGameObjectSprite::Type() const { return GAMEOBJECT_TYPE_SPRITE; } +bool cGameObjectSprite::IsType( const Uint32& type ) { + return ( Type() == type ) ? true : cGameObject::IsType( type ); +} + void cGameObjectSprite::Draw() { if ( NULL != mSprite ) { mSprite->Angle( GetAngle() ); diff --git a/src/gaming/cgameobjectsprite.hpp b/src/gaming/cgameobjectsprite.hpp index eb08eed12..9478cc3cd 100644 --- a/src/gaming/cgameobjectsprite.hpp +++ b/src/gaming/cgameobjectsprite.hpp @@ -33,6 +33,8 @@ class EE_API cGameObjectSprite : public cGameObject { virtual Uint32 Type() const; + virtual bool IsType( const Uint32& type ); + virtual void FlagSet( const Uint32& Flag ); virtual Uint32 DataId(); diff --git a/src/gaming/cgameobjectvirtual.cpp b/src/gaming/cgameobjectvirtual.cpp index 816c3af3f..6b32fa403 100644 --- a/src/gaming/cgameobjectvirtual.cpp +++ b/src/gaming/cgameobjectvirtual.cpp @@ -37,6 +37,10 @@ Uint32 cGameObjectVirtual::Type() const { return GAMEOBJECT_TYPE_VIRTUAL; } +bool cGameObjectVirtual::IsType( const Uint32& type ) { + return ( Type() == type ) ? true : cGameObject::IsType( type ); +} + Uint32 cGameObjectVirtual::RealType() const { return mType; } diff --git a/src/gaming/cgameobjectvirtual.hpp b/src/gaming/cgameobjectvirtual.hpp index a0877d93a..70e5898e1 100644 --- a/src/gaming/cgameobjectvirtual.hpp +++ b/src/gaming/cgameobjectvirtual.hpp @@ -28,6 +28,8 @@ class EE_API cGameObjectVirtual : public cGameObject { virtual Uint32 Type() const; + virtual bool IsType( const Uint32& type ); + virtual Uint32 RealType() const; virtual Uint32 DataId(); diff --git a/src/gaming/cmap.cpp b/src/gaming/cmap.cpp index 05ec001c0..fc567b4de 100644 --- a/src/gaming/cmap.cpp +++ b/src/gaming/cmap.cpp @@ -1209,7 +1209,7 @@ cGameObject * cMap::IsTypeInTilePos( const Uint32& Type, const eeVector2i& TileP cGameObject * tObj = NULL; if ( ( tObj = tLayer->GetGameObject( TilePos ) ) ) { - if ( tObj->Type() == Type ) { + if ( tObj->IsType( Type ) ) { return tObj; } } diff --git a/src/ui/cuimessagebox.cpp b/src/ui/cuimessagebox.cpp index 79dbee1ba..811501de2 100644 --- a/src/ui/cuimessagebox.cpp +++ b/src/ui/cuimessagebox.cpp @@ -4,7 +4,7 @@ namespace EE { namespace UI { cUIMessageBox::cUIMessageBox( const cUIMessageBox::CreateParams& Params ) : cUIWindow( Params ), - mType( Params.Type ) + mMsgBoxType( Params.Type ) { cUIPushButton::CreateParams ButtonParams; ButtonParams.Parent( Container() ); @@ -31,7 +31,7 @@ cUIMessageBox::cUIMessageBox( const cUIMessageBox::CreateParams& Params ) : mTextBox->Text( Params.Message ); - switch ( mType ) { + switch ( mMsgBoxType ) { case MSGBOX_OKCANCEL: { mButtonOK->Text( "OK" ); diff --git a/src/ui/cuimessagebox.hpp b/src/ui/cuimessagebox.hpp index 3c27c0b0c..f7e12751f 100644 --- a/src/ui/cuimessagebox.hpp +++ b/src/ui/cuimessagebox.hpp @@ -37,7 +37,7 @@ class EE_API cUIMessageBox : public cUIWindow { cUIPushButton * ButtonCancel() const; protected: - UI_MSGBOX_TYPE mType; + UI_MSGBOX_TYPE mMsgBoxType; cUITextBox * mTextBox; cUIPushButton * mButtonOK; cUIPushButton * mButtonCancel;