From b4ea6da1a968a672ee584229bc4dad4444681c71 Mon Sep 17 00:00:00 2001 From: nitrocaster Date: Fri, 27 Nov 2015 15:01:48 +0300 Subject: [PATCH] Fix hierarchy of lua-exported classes. New luabind performs automatic cast to most derived class, which causes crash when trying to call parent class function from lua. --- src/xrGame/PhysicObject_script.cpp | 6 +++--- src/xrGame/ai/stalker/ai_stalker_script.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/xrGame/PhysicObject_script.cpp b/src/xrGame/PhysicObject_script.cpp index b768c77c428..199020e03cc 100644 --- a/src/xrGame/PhysicObject_script.cpp +++ b/src/xrGame/PhysicObject_script.cpp @@ -13,8 +13,6 @@ SCRIPT_EXPORT(CPhysicObject, (CGameObject), { module(luaState) [ - class_("CDestroyablePhysicsObject") - .def(constructor<>()), class_("CPhysicObject") .def(constructor<>()) .def("run_anim_forward", &CPhysicObject::run_anim_forward) @@ -25,6 +23,8 @@ SCRIPT_EXPORT(CPhysicObject, (CGameObject), .def("play_bones_sound", &CPhysicObject::play_bones_sound) .def("stop_bones_sound", &CPhysicObject::stop_bones_sound) .def("set_door_ignore_dynamics", &CPhysicObject::set_door_ignore_dynamics) - .def("unset_door_ignore_dynamics", &CPhysicObject::unset_door_ignore_dynamics) + .def("unset_door_ignore_dynamics", &CPhysicObject::unset_door_ignore_dynamics), + class_("CDestroyablePhysicsObject") + .def(constructor<>()) ]; }); diff --git a/src/xrGame/ai/stalker/ai_stalker_script.cpp b/src/xrGame/ai/stalker/ai_stalker_script.cpp index 68b7cc95e40..c4a5456ce52 100644 --- a/src/xrGame/ai/stalker/ai_stalker_script.cpp +++ b/src/xrGame/ai/stalker/ai_stalker_script.cpp @@ -16,11 +16,11 @@ using namespace luabind; -SCRIPT_EXPORT(CStalkerPlanner, (), +SCRIPT_EXPORT(CStalkerPlanner, (CScriptActionPlanner), { module(luaState) [ - class_("stalker_ids") + class_("stalker_ids") // CScriptActionPlanner .enum_("properties") [ luabind::value("property_alive", StalkerDecisionSpace::eWorldPropertyAlive),