Skip to content

Commit

Permalink
Fix invalid smart casts.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Nov 14, 2015
1 parent d33f8d2 commit 7651718
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/xrGame/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 5 additions & 6 deletions src/xrGame/script_binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
// comment next string when commiting
//#define DBG_DISABLE_SCRIPTS

CScriptBinder::CScriptBinder ()
CScriptBinder::CScriptBinder (CGameObject *owner)
{
this->owner = owner;
init ();
}

Expand Down Expand Up @@ -87,10 +88,8 @@ void CScriptBinder::reload (LPCSTR section)
return;
}

CGameObject *game_object = smart_cast<CGameObject*>(this);

try {
lua_function (game_object ? game_object->lua_game_object() : 0);
lua_function (owner->lua_game_object());
}
catch(...) {
clear ();
Expand Down Expand Up @@ -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<CGameObject*>(this) ? *smart_cast<CGameObject*>(this)->cName() : "");
Msg ("* Core object %s is UNbinded from the script object", owner->cName());
#endif // _DEBUG
try {
m_object->net_Destroy ();
Expand All @@ -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<CGameObject*>(this) ? *smart_cast<CGameObject*>(this)->cName() : "");
Msg ("* Core object %s is binded with the script object", owner->cName());
#endif // _DEBUG
m_object = object;
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/xrGame/script_binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down

0 comments on commit 7651718

Please sign in to comment.