Skip to content

Commit 29d4448

Browse files
committed
xrGame/script_game_object_script3.cpp: use lambda functions for level changer
1 parent 701e195 commit 29d4448

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

src/xrGame/level_changer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CLevelChanger : public CGameObject, public Feel::Touch
4545
bool IsLevelChangerEnabled() const { return m_b_enabled; }
4646
void EnableSilentMode(bool silent) { m_bSilentMode = silent; }
4747
bool IsSilentModeEnabled() const { return m_bSilentMode; }
48-
void SetLEvelChangerInvitationStr(LPCSTR str) { m_invite_str = str; }
48+
void SetLevelChangerInvitationStr(LPCSTR str) { m_invite_str = str; }
4949
// serialization
5050
virtual bool net_SaveRelevant();
5151
virtual void save(NET_Packet& output_packet);

src/xrGame/script_game_object.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,7 @@ class CScriptGameObject
664664
CScriptGameObject* active_detector() const;
665665
u32 active_slot();
666666
void activate_slot(u32 slot_id);
667-
void enable_level_changer(bool b);
668-
bool is_level_changer_enabled();
669-
void set_level_changer_invitation(LPCSTR str);
667+
670668
#ifdef DEBUG
671669
void debug_planner(const script_planner* planner);
672670
#endif

src/xrGame/script_game_object4.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -309,27 +309,6 @@ bool CScriptGameObject::inv_box_can_take_status()
309309
CZoneCampfire* CScriptGameObject::get_campfire() { return smart_cast<CZoneCampfire*>(&object()); }
310310
CArtefact* CScriptGameObject::get_artefact() { return smart_cast<CArtefact*>(&object()); }
311311
CPhysicObject* CScriptGameObject::get_physics_object() { return smart_cast<CPhysicObject*>(&object()); }
312-
#include "level_changer.h"
313-
void CScriptGameObject::enable_level_changer(bool b)
314-
{
315-
CLevelChanger* lch = smart_cast<CLevelChanger*>(&object());
316-
if (lch)
317-
lch->EnableLevelChanger(b);
318-
}
319-
bool CScriptGameObject::is_level_changer_enabled()
320-
{
321-
CLevelChanger* lch = smart_cast<CLevelChanger*>(&object());
322-
if (lch)
323-
return lch->IsLevelChangerEnabled();
324-
return false;
325-
}
326-
327-
void CScriptGameObject::set_level_changer_invitation(LPCSTR str)
328-
{
329-
CLevelChanger* lch = smart_cast<CLevelChanger*>(&object());
330-
if (lch)
331-
lch->SetLEvelChangerInvitationStr(str);
332-
}
333312

334313
void CScriptGameObject::start_particles(LPCSTR pname, LPCSTR bone)
335314
{

src/xrGame/script_game_object_script3.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,18 @@ luabind::class_<CScriptGameObject>& script_register_game_object2(luabind::class_
402402
.def("aim_bone_id", (LPCSTR(CScriptGameObject::*)() const) & CScriptGameObject::aim_bone_id)
403403

404404
.def("actor_look_at_point", &CScriptGameObject::ActorLookAtPoint)
405-
.def("enable_level_changer", &CScriptGameObject::enable_level_changer)
406-
.def("is_level_changer_enabled", &CScriptGameObject::is_level_changer_enabled)
405+
406+
.def("enable_level_changer", [](const CScriptGameObject* self, bool enable)
407+
{
408+
if (auto* lch = smart_cast<CLevelChanger*>(&self->object()))
409+
lch->EnableLevelChanger(enable);
410+
})
411+
.def("is_level_changer_enabled", [](const CScriptGameObject* self)
412+
{
413+
if (const auto* lch = smart_cast<CLevelChanger*>(&self->object()))
414+
return lch->IsLevelChangerEnabled();
415+
return false;
416+
})
407417
.def("enable_silent_level_changer", [](const CScriptGameObject* self, bool silent)
408418
{
409419
if (auto* lch = smart_cast<CLevelChanger*>(&self->object()))
@@ -415,8 +425,12 @@ luabind::class_<CScriptGameObject>& script_register_game_object2(luabind::class_
415425
return lch->IsSilentModeEnabled();
416426
return false;
417427
})
428+
.def("set_level_changer_invitation", [](const CScriptGameObject* self, pcstr invitation)
429+
{
430+
if (auto* lch = smart_cast<CLevelChanger*>(&self->object()))
431+
lch->SetLevelChangerInvitationStr(invitation);
432+
})
418433

419-
.def("set_level_changer_invitation", &CScriptGameObject::set_level_changer_invitation)
420434
.def("start_particles", &CScriptGameObject::start_particles)
421435
.def("stop_particles", &CScriptGameObject::stop_particles)
422436

0 commit comments

Comments
 (0)