Skip to content

Commit db42542

Browse files
committedJun 26, 2018
Rename CSM flavours to restrictions
& Satisfy LINT
1 parent 7bdf5ea commit db42542

13 files changed

+65
-54
lines changed
 

‎builtin/settingtypes.txt

+7-8
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ safe_dig_and_place (Safe digging and placing) bool false
115115
# Enable random user input (only used for testing).
116116
random_input (Random input) bool false
117117

118-
# Continuous forward movement, toggled by autoforward key.
118+
# Continuous forward movement, toggled by autoforward key.
119119
# Press the autoforward key again or the backwards movement to disable.
120120
continuous_forward (Continuous forward) bool false
121121

@@ -1134,13 +1134,12 @@ server_side_occlusion_culling (Server side occlusion culling) bool true
11341134
# CHAT_MESSAGES: 2 (disable send_chat_message call client-side)
11351135
# READ_ITEMDEFS: 4 (disable get_item_def call client-side)
11361136
# READ_NODEDEFS: 8 (disable get_node_def call client-side)
1137-
# LOOKUP_NODES_LIMIT: 16 (limits get_node call client-side to csm_flavour_noderange_limit)
1138-
# type: int
1139-
csm_flavour_limits (Client side modding flavour limits) int 18
1137+
# LOOKUP_NODES_LIMIT: 16 (limits get_node call client-side to csm_restriction_noderange)
1138+
csm_restriction_flags (Client side modding restrictions) int 18
11401139

1141-
# If the CSM flavour for node range is enabled, get_node is limited to
1142-
# this many nodes from the player.
1143-
csm_flavour_noderange_limit (Client side noderange flavour limit) int 8
1140+
# If the CSM restriction for node range is enabled, get_node calls are limited
1141+
# to this distance from the player to the node.
1142+
csm_restriction_noderange (Client side node lookup range restriction) int 8
11441143

11451144
[*Security]
11461145

@@ -1246,7 +1245,7 @@ high_precision_fpu (High-precision FPU) bool true
12461245
# Changes the main menu UI:
12471246
# - Full: Multple singleplayer worlds, game choice, texture pack chooser, etc.
12481247
# - Simple: One singleplayer world, no game or texture pack choosers. May be necessary for smaller screens.
1249-
# - Auto: Simple on Android, full on everything else.
1248+
# - Auto: Simple on Android, full on everything else.
12501249
main_menu_style (Main menu style) enum auto auto,full,simple
12511250

12521251
# Replaces the default main menu with a custom one.

‎src/client.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ void Client::loadMods()
130130
return;
131131
}
132132

133-
// If modding is not enabled or flavour disable it, don't load mods, just builtin
133+
// If modding is not enabled or CSM restrictions disable it
134+
// don't load CSM mods, only builtin
134135
if (!m_modding_enabled) {
135136
warningstream << "Client side mods are disabled by configuration." << std::endl;
136137
return;
137138
}
138139

139-
if (checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOAD_CLIENT_MODS)) {
140+
if (checkCSMRestrictionFlag(CSMRestrictionFlags::CSM_RF_LOAD_CLIENT_MODS)) {
140141
warningstream << "Client side mods are disabled by server." << std::endl;
141142
// If mods loading is disabled and builtin integrity is wrong, disconnect user.
142143
if (!checkBuiltinIntegrity()) {
@@ -1282,16 +1283,16 @@ void Client::removeNode(v3s16 p)
12821283

12831284
/**
12841285
* Helper function for Client Side Modding
1285-
* Flavour is applied there, this should not be used for core engine
1286+
* CSM restrictions are applied there, this should not be used for core engine
12861287
* @param p
12871288
* @param is_valid_position
12881289
* @return
12891290
*/
12901291
MapNode Client::getNode(v3s16 p, bool *is_valid_position)
12911292
{
1292-
if (checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOOKUP_NODES)) {
1293+
if (checkCSMRestrictionFlag(CSMRestrictionFlags::CSM_RF_LOOKUP_NODES)) {
12931294
v3s16 ppos = floatToInt(m_env.getLocalPlayer()->getPosition(), BS);
1294-
if ((u32) ppos.getDistanceFrom(p) > m_csm_noderange_limit) {
1295+
if ((u32) ppos.getDistanceFrom(p) > m_csm_restriction_noderange) {
12951296
*is_valid_position = false;
12961297
return {};
12971298
}

‎src/client.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
226226
void handleCommand_ModChannelSignal(NetworkPacket *pkt);
227227
void handleCommand_SrpBytesSandB(NetworkPacket *pkt);
228228
void handleCommand_FormspecPrepend(NetworkPacket *pkt);
229-
void handleCommand_CSMFlavourLimits(NetworkPacket *pkt);
229+
void handleCommand_CSMRestrictionFlags(NetworkPacket *pkt);
230230

231231
void ProcessData(NetworkPacket *pkt);
232232

@@ -261,7 +261,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
261261

262262
/**
263263
* Helper function for Client Side Modding
264-
* Flavour is applied there, this should not be used for core engine
264+
* CSM restrictions are applied there, this should not be used for core engine
265265
* @param p
266266
* @param is_valid_position
267267
* @return
@@ -412,14 +412,14 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
412412
return m_address_name;
413413
}
414414

415-
inline bool checkCSMFlavourLimit(CSMFlavourLimit flag) const
415+
inline bool checkCSMRestrictionFlag(CSMRestrictionFlags flag) const
416416
{
417-
return m_csm_flavour_limits & flag;
417+
return m_csm_restriction_flags & flag;
418418
}
419419

420420
u32 getCSMNodeRangeLimit() const
421421
{
422-
return m_csm_noderange_limit;
422+
return m_csm_restriction_noderange;
423423
}
424424

425425
inline std::unordered_map<u32, u32> &getHUDTranslationMap()
@@ -600,9 +600,9 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
600600

601601
bool m_shutdown = false;
602602

603-
// CSM flavour limits byteflag
604-
u64 m_csm_flavour_limits = CSMFlavourLimit::CSM_FL_NONE;
605-
u32 m_csm_noderange_limit = 8;
603+
// CSM restrictions byteflag
604+
u64 m_csm_restriction_flags = CSMRestrictionFlags::CSM_RF_NONE;
605+
u32 m_csm_restriction_noderange = 8;
606606

607607
std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
608608
};

‎src/defaultsettings.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ void set_default_settings(Settings *settings)
332332
settings->setDefault("max_block_send_distance", "9");
333333
settings->setDefault("block_send_optimize_distance", "4");
334334
settings->setDefault("server_side_occlusion_culling", "true");
335-
settings->setDefault("csm_flavour_limits", "18");
336-
settings->setDefault("csm_flavour_noderange_limit", "8");
335+
settings->setDefault("csm_restriction_flags", "18");
336+
settings->setDefault("csm_restriction_noderange", "8");
337337
settings->setDefault("max_clearobjects_extra_loaded_blocks", "4096");
338338
settings->setDefault("time_speed", "72");
339339
settings->setDefault("world_start_time", "5250");

‎src/network/clientopcodes.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] =
6666
{ "TOCLIENT_INVENTORY", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_Inventory }, // 0x27
6767
null_command_handler,
6868
{ "TOCLIENT_TIME_OF_DAY", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_TimeOfDay }, // 0x29
69-
{ "TOCLIENT_CSM_FLAVOUR_LIMITS", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_CSMFlavourLimits }, // 0x2A
69+
{ "TOCLIENT_CSM_RESTRICTION_FLAGS", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_CSMRestrictionFlags }, // 0x2A
7070
null_command_handler,
7171
null_command_handler,
7272
null_command_handler,

‎src/network/clientpackethandler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1333,11 +1333,11 @@ void Client::handleCommand_FormspecPrepend(NetworkPacket *pkt)
13331333
*pkt >> player->formspec_prepend;
13341334
}
13351335

1336-
void Client::handleCommand_CSMFlavourLimits(NetworkPacket *pkt)
1336+
void Client::handleCommand_CSMRestrictionFlags(NetworkPacket *pkt)
13371337
{
1338-
*pkt >> m_csm_flavour_limits >> m_csm_noderange_limit;
1338+
*pkt >> m_csm_restriction_flags >> m_csm_restriction_noderange;
13391339

1340-
// Now we have flavours, load mods if it's enabled
1340+
// Restrictions were received -> load mods if it's enabled
13411341
// Note: this should be moved after mods receptions from server instead
13421342
loadMods();
13431343
}

‎src/network/networkprotocol.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
169169
* sender
170170
* type (RAW, NORMAL, ANNOUNCE, SYSTEM)
171171
* content
172-
Add TOCLIENT_CSM_FLAVOUR_LIMITS to define which CSM flavour should be
172+
Add TOCLIENT_CSM_RESTRICTION_FLAGS to define which CSM features should be
173173
limited
174174
Add settable player collisionbox. Breaks compatibility with older
175175
clients as a 1-node vertical offset has been removed from player's
@@ -283,9 +283,9 @@ enum ToClientCommand
283283
f1000 time_speed
284284
*/
285285

286-
TOCLIENT_CSM_FLAVOUR_LIMITS = 0x2A,
286+
TOCLIENT_CSM_RESTRICTION_FLAGS = 0x2A,
287287
/*
288-
u32 CSMFlavourLimits byteflag
288+
u32 CSMRestrictionFlags byteflag
289289
*/
290290

291291
// (oops, there is some gap here)
@@ -928,12 +928,12 @@ enum PlayerListModifer: u8
928928
PLAYER_LIST_REMOVE,
929929
};
930930

931-
enum CSMFlavourLimit : u64 {
932-
CSM_FL_NONE = 0x00000000,
933-
CSM_FL_LOAD_CLIENT_MODS = 0x00000001, // Disable mods provided by clients
934-
CSM_FL_CHAT_MESSAGES = 0x00000002, // Disable chat message sending from CSM
935-
CSM_FL_READ_ITEMDEFS = 0x00000004, // Disable itemdef lookups
936-
CSM_FL_READ_NODEDEFS = 0x00000008, // Disable nodedef lookups
937-
CSM_FL_LOOKUP_NODES = 0x00000010, // Limit node lookups
938-
CSM_FL_ALL = 0xFFFFFFFF,
931+
enum CSMRestrictionFlags : u64 {
932+
CSM_RF_NONE = 0x00000000,
933+
CSM_RF_LOAD_CLIENT_MODS = 0x00000001, // Disable mods provided by clients
934+
CSM_RF_CHAT_MESSAGES = 0x00000002, // Disable chat message sending from CSM
935+
CSM_RF_READ_ITEMDEFS = 0x00000004, // Disable itemdef lookups
936+
CSM_RF_READ_NODEDEFS = 0x00000008, // Disable nodedef lookups
937+
CSM_RF_LOOKUP_NODES = 0x00000010, // Limit node lookups
938+
CSM_RF_ALL = 0xFFFFFFFF,
939939
};

‎src/network/serveropcodes.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
155155
{ "TOCLIENT_INVENTORY", 0, true }, // 0x27
156156
null_command_factory,
157157
{ "TOCLIENT_TIME_OF_DAY", 0, true }, // 0x29
158-
{ "TOCLIENT_CSM_FLAVOUR_LIMITS", 0, true }, // 0x2A
158+
{ "TOCLIENT_CSM_RESTRICTION_FLAGS", 0, true }, // 0x2A
159159
null_command_factory,
160160
null_command_factory,
161161
null_command_factory,

‎src/network/serverpackethandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void Server::handleCommand_Init2(NetworkPacket* pkt)
320320
float time_speed = g_settings->getFloat("time_speed");
321321
SendTimeOfDay(pkt->getPeerId(), time, time_speed);
322322

323-
SendCSMFlavourLimits(pkt->getPeerId());
323+
SendCSMRestrictionFlags(pkt->getPeerId());
324324

325325
// Warnings about protocol version can be issued here
326326
if (getClient(pkt->getPeerId())->net_proto_version < LATEST_PROTOCOL_VERSION) {

‎src/script/lua_api/l_client.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ int ModApiClient::l_send_chat_message(lua_State *L)
9494
return 0;
9595

9696
// If server disabled this API, discard
97-
if (getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_CHAT_MESSAGES))
97+
98+
// clang-format off
99+
if (getClient(L)->checkCSMRestrictionFlag(
100+
CSMRestrictionFlags::CSM_RF_CHAT_MESSAGES))
98101
return 0;
102+
// clang-format on
99103

100104
std::string message = luaL_checkstring(L, 1);
101105
getClient(L)->sendChatMessage(utf8_to_wide(message));
@@ -290,8 +294,11 @@ int ModApiClient::l_get_item_def(lua_State *L)
290294
IItemDefManager *idef = gdef->idef();
291295
assert(idef);
292296

293-
if (getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_READ_ITEMDEFS))
297+
// clang-format off
298+
if (getClient(L)->checkCSMRestrictionFlag(
299+
CSMRestrictionFlags::CSM_RF_READ_ITEMDEFS))
294300
return 0;
301+
// clang-format on
295302

296303
if (!lua_isstring(L, 1))
297304
return 0;
@@ -318,8 +325,11 @@ int ModApiClient::l_get_node_def(lua_State *L)
318325
if (!lua_isstring(L, 1))
319326
return 0;
320327

321-
if (getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_READ_NODEDEFS))
328+
// clang-format off
329+
if (getClient(L)->checkCSMRestrictionFlag(
330+
CSMRestrictionFlags::CSM_RF_READ_NODEDEFS))
322331
return 0;
332+
// clang-format on
323333

324334
const std::string &name = lua_tostring(L, 1);
325335
const ContentFeatures &cf = ndef->get(ndef->getId(name));

‎src/script/lua_api/l_env.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ int ModApiEnvMod::l_find_node_near(lua_State *L)
770770
#ifndef SERVER
771771
// Client API limitations
772772
if (getClient(L) &&
773-
getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOOKUP_NODES)) {
773+
getClient(L)->checkCSMRestrictionFlag(
774+
CSMRestrictionFlags::CSM_RF_LOOKUP_NODES)) {
774775
radius = std::max<int>(radius, getClient(L)->getCSMNodeRangeLimit());
775776
}
776777
#endif

‎src/server.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ void Server::init()
401401

402402
m_liquid_transform_every = g_settings->getFloat("liquid_update");
403403
m_max_chatmessage_length = g_settings->getU16("chat_message_max_size");
404-
m_csm_flavour_limits = g_settings->getU64("csm_flavour_limits");
405-
m_csm_noderange_limit = g_settings->getU32("csm_flavour_noderange_limit");
404+
m_csm_restriction_flags = g_settings->getU64("csm_restriction_flags");
405+
m_csm_restriction_noderange = g_settings->getU32("csm_restriction_noderange");
406406
}
407407

408408
void Server::start()
@@ -1934,11 +1934,11 @@ void Server::SendActiveObjectMessages(session_t peer_id, const std::string &data
19341934
&pkt, reliable);
19351935
}
19361936

1937-
void Server::SendCSMFlavourLimits(session_t peer_id)
1937+
void Server::SendCSMRestrictionFlags(session_t peer_id)
19381938
{
1939-
NetworkPacket pkt(TOCLIENT_CSM_FLAVOUR_LIMITS,
1940-
sizeof(m_csm_flavour_limits) + sizeof(m_csm_noderange_limit), peer_id);
1941-
pkt << m_csm_flavour_limits << m_csm_noderange_limit;
1939+
NetworkPacket pkt(TOCLIENT_CSM_RESTRICTION_FLAGS,
1940+
sizeof(m_csm_restriction_flags) + sizeof(m_csm_restriction_noderange), peer_id);
1941+
pkt << m_csm_restriction_flags << m_csm_restriction_noderange;
19421942
Send(&pkt);
19431943
}
19441944

‎src/server.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ class Server : public con::PeerHandler, public MapEventReceiver,
462462
u32 SendActiveObjectRemoveAdd(session_t peer_id, const std::string &datas);
463463
void SendActiveObjectMessages(session_t peer_id, const std::string &datas,
464464
bool reliable = true);
465-
void SendCSMFlavourLimits(session_t peer_id);
465+
void SendCSMRestrictionFlags(session_t peer_id);
466466

467467
/*
468468
Something random
@@ -650,9 +650,9 @@ class Server : public con::PeerHandler, public MapEventReceiver,
650650
std::unordered_map<std::string, ModMetadata *> m_mod_storages;
651651
float m_mod_storage_save_timer = 10.0f;
652652

653-
// CSM flavour limits byteflag
654-
u64 m_csm_flavour_limits = CSMFlavourLimit::CSM_FL_NONE;
655-
u32 m_csm_noderange_limit = 8;
653+
// CSM restrictions byteflag
654+
u64 m_csm_restriction_flags = CSMRestrictionFlags::CSM_RF_NONE;
655+
u32 m_csm_restriction_noderange = 8;
656656

657657
// ModChannel manager
658658
std::unique_ptr<ModChannelMgr> m_modchannel_mgr;

0 commit comments

Comments
 (0)
Please sign in to comment.