From 5d0a38cbd922317262d981fb32c2075f2c752bf7 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Mon, 20 Jun 2016 08:02:30 +0300 Subject: [PATCH] Fix the keybind creation by obtaining a keybind slot automatically if one was not specified. --- source/CoreEntity.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/CoreEntity.cpp b/source/CoreEntity.cpp index 41aa92a5..e20f63e1 100644 --- a/source/CoreEntity.cpp +++ b/source/CoreEntity.cpp @@ -724,6 +724,16 @@ Object & Core::NewCheckpoint(Int32 player, Int32 world, bool sphere, Float32 x, Object & Core::NewKeybind(Int32 slot, bool release, Int32 primary, Int32 secondary, Int32 alternative, Int32 header, Object & payload) { + // Should we obtain a new keybind slot automatically? + if (slot < 0) + { + slot = _Func->GetKeyBindUnusedSlot(); + } + // Validate the keybind slot + if (slot < 0) + { + STHROWF("Out of keybind slots"); + } // Request the server to create this entity const Int32 id = _Func->RegisterKeyBind(slot, release, primary, secondary, alternative); // See if the entity creation failed on the server