99#include " pch_script.h"
1010#include " object_item_script.h"
1111#include " object_factory.h"
12+ #include " xrScriptEngine/Functor.hpp"
1213
1314#ifndef NO_XR_GAME
1415# include " attachable_item.h"
1516
1617ObjectFactory::CLIENT_BASE_CLASS *CObjectItemScript::client_object () const
1718{
18- using namespace luabind ::policy;
19- ObjectFactory::CLIENT_SCRIPT_BASE_CLASS *object;
19+ ObjectFactory::CLIENT_SCRIPT_BASE_CLASS *object = nullptr ;
2020 try {
21- object = luabind::object_cast<ObjectFactory::CLIENT_SCRIPT_BASE_CLASS*>( m_client_creator (), adopt< 0 >() );
21+ object = m_client_creator ();
2222 }
2323 catch (...) {
2424 return (0 );
@@ -31,39 +31,22 @@ ObjectFactory::CLIENT_BASE_CLASS *CObjectItemScript::client_object () const
3131
3232ObjectFactory::SERVER_BASE_CLASS *CObjectItemScript::server_object (LPCSTR section) const
3333{
34- using namespace luabind ::policy;
35- typedef ObjectFactory::SERVER_SCRIPT_BASE_CLASS SERVER_SCRIPT_BASE_CLASS;
36- typedef ObjectFactory::SERVER_BASE_CLASS SERVER_BASE_CLASS;
37- SERVER_SCRIPT_BASE_CLASS *object;
34+ ObjectFactory::SERVER_BASE_CLASS *object = nullptr ;
3835
3936 try {
40- // XXX nitrocaster: why not call m_server_creator(section) with adopt policy?
41- luabind::object *instance = 0 ;
42- try {
43- instance = xr_new<luabind::object>((luabind::object)(m_server_creator (section)));
44- }
45- catch (std::exception e) {
46- Msg (" Exception [%s] raised while creating server object from section [%s]" , e.what (),section);
47- return (0 );
48- }
49- catch (...) {
50- Msg (" Exception raised while creating server object from section [%s]" ,section);
51- return (0 );
52- }
53- object = luabind::object_cast<ObjectFactory::SERVER_SCRIPT_BASE_CLASS*>(*instance, adopt<0 >());
54- xr_delete (instance);
37+ object = m_server_creator (section);
5538 }
5639 catch (std::exception e) {
57- Msg (" Exception [%s] raised while casting and adopting script server object from section [%s]" , e.what (),section);
58- return (0 );
40+ Msg (" Exception [%s] raised while creating server object from section [%s]" , e.what (),section);
41+ return (0 );
5942 }
6043 catch (...) {
61- Msg (" Exception raised while creating script server object from section [%s]" , section);
62- return (0 );
44+ Msg (" Exception raised while creating server object from section [%s]" ,section);
45+ return (0 );
6346 }
6447
6548 R_ASSERT (object);
66- SERVER_BASE_CLASS *o = object->init ();
49+ ObjectFactory:: SERVER_BASE_CLASS *o = object->init ();
6750 R_ASSERT (o);
6851 return (o);
6952}
0 commit comments