From 76517184db251704f642ac558c48d7e7a986b46f Mon Sep 17 00:00:00 2001 From: nitrocaster Date: Sat, 14 Nov 2015 18:09:47 +0300 Subject: [PATCH] Fix invalid smart casts. --- src/xrGame/GameObject.cpp | 2 +- src/xrGame/script_binder.cpp | 11 +++++------ src/xrGame/script_binder.h | 5 +++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/xrGame/GameObject.cpp b/src/xrGame/GameObject.cpp index 5f354c402de..8e88e366cbf 100644 --- a/src/xrGame/GameObject.cpp +++ b/src/xrGame/GameObject.cpp @@ -47,7 +47,7 @@ extern MagicBox3 MagicMinBox (int iQuantity, const Fvector* akPoint); ENGINE_API bool g_dedicated_server; -CGameObject::CGameObject () +CGameObject::CGameObject () : scriptBinder(this) { // CUsableScriptObject init m_bNonscriptUsable = true; diff --git a/src/xrGame/script_binder.cpp b/src/xrGame/script_binder.cpp index dca63775ce3..073684f070b 100644 --- a/src/xrGame/script_binder.cpp +++ b/src/xrGame/script_binder.cpp @@ -19,8 +19,9 @@ // comment next string when commiting //#define DBG_DISABLE_SCRIPTS -CScriptBinder::CScriptBinder () +CScriptBinder::CScriptBinder (CGameObject *owner) { + this->owner = owner; init (); } @@ -87,10 +88,8 @@ void CScriptBinder::reload (LPCSTR section) return; } - CGameObject *game_object = smart_cast(this); - try { - lua_function (game_object ? game_object->lua_game_object() : 0); + lua_function (owner->lua_game_object()); } catch(...) { clear (); @@ -148,7 +147,7 @@ void CScriptBinder::net_Destroy () { if (m_object) { #ifdef _DEBUG - Msg ("* Core object %s is UNbinded from the script object",smart_cast(this) ? *smart_cast(this)->cName() : ""); + Msg ("* Core object %s is UNbinded from the script object", owner->cName()); #endif // _DEBUG try { m_object->net_Destroy (); @@ -165,7 +164,7 @@ void CScriptBinder::set_object (CScriptBinderObject *object) if (IsGameTypeSingle()) { VERIFY2 (!m_object,"Cannot bind to the object twice!"); #ifdef _DEBUG - Msg ("* Core object %s is binded with the script object",smart_cast(this) ? *smart_cast(this)->cName() : ""); + Msg ("* Core object %s is binded with the script object", owner->cName()); #endif // _DEBUG m_object = object; } else { diff --git a/src/xrGame/script_binder.h b/src/xrGame/script_binder.h index e10360878a8..61ff52a480f 100644 --- a/src/xrGame/script_binder.h +++ b/src/xrGame/script_binder.h @@ -11,13 +11,14 @@ class CSE_Abstract; class CScriptBinderObject; class NET_Packet; +class CGameObject; class CScriptBinder { protected: CScriptBinderObject *m_object; - + CGameObject *owner; public: - CScriptBinder (); + CScriptBinder (CGameObject *owner); virtual ~CScriptBinder (); void init (); void clear ();