summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api/l_client.cpp')
-rw-r--r--src/script/lua_api/l_client.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp
index febf528de..08976ee11 100644
--- a/src/script/lua_api/l_client.cpp
+++ b/src/script/lua_api/l_client.cpp
@@ -36,6 +36,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h"
#include "nodedef.h"
+#define checkCSMRestrictionFlag(flag) \
+ ( getClient(L)->checkCSMRestrictionFlag(CSMRestrictionFlags::flag) )
+
// get_current_modname()
int ModApiClient::l_get_current_modname(lua_State *L)
{
@@ -106,11 +109,8 @@ int ModApiClient::l_send_chat_message(lua_State *L)
// If server disabled this API, discard
- // clang-format off
- if (getClient(L)->checkCSMRestrictionFlag(
- CSMRestrictionFlags::CSM_RF_CHAT_MESSAGES))
+ if (checkCSMRestrictionFlag(CSM_RF_CHAT_MESSAGES))
return 0;
- // clang-format on
std::string message = luaL_checkstring(L, 1);
getClient(L)->sendChatMessage(utf8_to_wide(message));
@@ -127,12 +127,8 @@ int ModApiClient::l_clear_out_chat_queue(lua_State *L)
// get_player_names()
int ModApiClient::l_get_player_names(lua_State *L)
{
- // clang-format off
- if (getClient(L)->checkCSMRestrictionFlag(
- CSMRestrictionFlags::CSM_RF_READ_PLAYERINFO)) {
+ if (checkCSMRestrictionFlag(CSM_RF_READ_PLAYERINFO))
return 0;
- }
- // clang-format on
const std::list<std::string> &plist = getClient(L)->getConnectedPlayerNames();
lua_createtable(L, plist.size(), 0);
@@ -201,7 +197,7 @@ int ModApiClient::l_get_node_or_nil(lua_State *L)
// Do it
bool pos_ok;
- MapNode n = getClient(L)->getNode(pos, &pos_ok);
+ MapNode n = getClient(L)->CSMGetNode(pos, &pos_ok);
if (pos_ok) {
// Return node
pushnode(L, n, getClient(L)->ndef());
@@ -308,11 +304,8 @@ int ModApiClient::l_get_item_def(lua_State *L)
IItemDefManager *idef = gdef->idef();
assert(idef);
- // clang-format off
- if (getClient(L)->checkCSMRestrictionFlag(
- CSMRestrictionFlags::CSM_RF_READ_ITEMDEFS))
+ if (checkCSMRestrictionFlag(CSM_RF_READ_ITEMDEFS))
return 0;
- // clang-format on
if (!lua_isstring(L, 1))
return 0;
@@ -339,11 +332,8 @@ int ModApiClient::l_get_node_def(lua_State *L)
if (!lua_isstring(L, 1))
return 0;
- // clang-format off
- if (getClient(L)->checkCSMRestrictionFlag(
- CSMRestrictionFlags::CSM_RF_READ_NODEDEFS))
+ if (checkCSMRestrictionFlag(CSM_RF_READ_NODEDEFS))
return 0;
- // clang-format on
std::string name = readParam<std::string>(L, 1);
const ContentFeatures &cf = ndef->get(ndef->getId(name));