master #6

Merged
BRNSystems merged 85 commits from Mirrorlandia_minetest/minetest:master into master 2024-01-09 17:53:52 +01:00
24 changed files with 0 additions and 702 deletions
Showing only changes of commit da832a295e - Show all commits

@ -1,33 +0,0 @@
BasedOnStyle: LLVM
IndentWidth: 4
UseTab: Always
TabWidth: 4
BreakBeforeBraces: Custom
Standard: c++17
BraceWrapping:
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
FixNamespaceComments: false
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AccessModifierOffset: -4
ColumnLimit: 90
AllowShortFunctionsOnASingleLine: InlineOnly
SortIncludes: Never
IncludeCategories:
- Regex: '^".*'
Priority: 2
- Regex: '^<.*'
Priority: 1
AlignAfterOpenBracket: DontAlign
ContinuationIndentWidth: 8
ConstructorInitializerIndentWidth: 8
BreakConstructorInitializers: AfterColon
AlwaysBreakTemplateDeclarations: Yes

@ -67,20 +67,6 @@ Contributions are welcome! Here's how you can help:
might need more work in the future. might need more work in the future.
5. It uses protocols and formats which include the required compatibility. 5. It uses protocols and formats which include the required compatibility.
### Important note about automated GitHub checks
When you submit a pull request, GitHub automatically runs checks on the Minetest
Engine combined with your changes. One of these checks is called 'cpp lint /
clang format', which checks code formatting. Because formatting for readability
requires human judgement this check often fails and often makes unsuitable
formatting requests which make code readability worse.
If this check fails, look at the details to check for any clear mistakes and
correct those. However, you should not apply everything ClangFormat requests.
Ignore requests that make code readability worse and any other clearly
unsuitable requests. Discuss in the pull request with a core developer about how
to progress.
## Issues ## Issues
If you experience an issue, we would like to know the details - especially when If you experience an issue, we would like to know the details - especially when

@ -24,23 +24,6 @@ on:
- '.github/workflows/**.yml' - '.github/workflows/**.yml'
jobs: jobs:
# clang_format:
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v3
# - name: Install clang-format
# run: |
# sudo apt-get update
# sudo apt-get install -y clang-format-9
#
# - name: Run clang-format
# run: |
# source ./util/ci/clang-format.sh
# check_format
# env:
# CLANG_FORMAT: clang-format-9
clang_tidy: clang_tidy:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:

@ -50,7 +50,6 @@ void ActiveObjectMgr::step(
} }
} }
// clang-format off
bool ActiveObjectMgr::registerObject(std::unique_ptr<ClientActiveObject> obj) bool ActiveObjectMgr::registerObject(std::unique_ptr<ClientActiveObject> obj)
{ {
assert(obj); // Pre-condition assert(obj); // Pre-condition
@ -93,7 +92,6 @@ void ActiveObjectMgr::removeObject(u16 id)
obj->removeFromScene(true); obj->removeFromScene(true);
} }
// clang-format on
void ActiveObjectMgr::getActiveObjects(const v3f &origin, f32 max_d, void ActiveObjectMgr::getActiveObjects(const v3f &origin, f32 max_d,
std::vector<DistanceSortedActiveObject> &dest) std::vector<DistanceSortedActiveObject> &dest)
{ {

@ -47,7 +47,6 @@ struct MeshCollector
// offset: offset added to vertices // offset: offset added to vertices
MeshCollector(const v3f center_pos, v3f offset = v3f()) : m_center_pos(center_pos), offset(offset) {} MeshCollector(const v3f center_pos, v3f offset = v3f()) : m_center_pos(center_pos), offset(offset) {}
// clang-format off
void append(const TileSpec &material, void append(const TileSpec &material,
const video::S3DVertex *vertices, u32 numVertices, const video::S3DVertex *vertices, u32 numVertices,
const u16 *indices, u32 numIndices); const u16 *indices, u32 numIndices);
@ -55,10 +54,8 @@ struct MeshCollector
const video::S3DVertex *vertices, u32 numVertices, const video::S3DVertex *vertices, u32 numVertices,
const u16 *indices, u32 numIndices, const u16 *indices, u32 numIndices,
v3f pos, video::SColor c, u8 light_source); v3f pos, video::SColor c, u8 light_source);
// clang-format on
private: private:
// clang-format off
void append(const TileLayer &material, void append(const TileLayer &material,
const video::S3DVertex *vertices, u32 numVertices, const video::S3DVertex *vertices, u32 numVertices,
const u16 *indices, u32 numIndices, const u16 *indices, u32 numIndices,
@ -68,7 +65,6 @@ private:
const u16 *indices, u32 numIndices, const u16 *indices, u32 numIndices,
v3f pos, video::SColor c, u8 light_source, v3f pos, video::SColor c, u8 light_source,
u8 layernum, bool use_scale = false); u8 layernum, bool use_scale = false);
// clang-format on
PreMeshBuffer &findBuffer(const TileLayer &layer, u8 layernum, u32 numVertices); PreMeshBuffer &findBuffer(const TileLayer &layer, u8 layernum, u32 numVertices);
}; };

@ -108,10 +108,8 @@ bool parseModContents(ModSpec &spec)
if (info.exists("depends")) { if (info.exists("depends")) {
mod_conf_has_depends = true; mod_conf_has_depends = true;
std::string dep = info.get("depends"); std::string dep = info.get("depends");
// clang-format off
dep.erase(std::remove_if(dep.begin(), dep.end(), dep.erase(std::remove_if(dep.begin(), dep.end(),
static_cast<int (*)(int)>(&std::isspace)), dep.end()); static_cast<int (*)(int)>(&std::isspace)), dep.end());
// clang-format on
for (const auto &dependency : str_split(dep, ',')) { for (const auto &dependency : str_split(dep, ',')) {
spec.depends.insert(dependency); spec.depends.insert(dependency);
} }
@ -120,10 +118,8 @@ bool parseModContents(ModSpec &spec)
if (info.exists("optional_depends")) { if (info.exists("optional_depends")) {
mod_conf_has_depends = true; mod_conf_has_depends = true;
std::string dep = info.get("optional_depends"); std::string dep = info.get("optional_depends");
// clang-format off
dep.erase(std::remove_if(dep.begin(), dep.end(), dep.erase(std::remove_if(dep.begin(), dep.end(),
static_cast<int (*)(int)>(&std::isspace)), dep.end()); static_cast<int (*)(int)>(&std::isspace)), dep.end());
// clang-format on
for (const auto &dependency : str_split(dep, ',')) { for (const auto &dependency : str_split(dep, ',')) {
spec.optdepends.insert(dependency); spec.optdepends.insert(dependency);
} }

@ -455,7 +455,6 @@ bool GUIEditBox::processKey(const SEvent &event)
bool GUIEditBox::onKeyUp(const SEvent &event, s32 &mark_begin, s32 &mark_end) bool GUIEditBox::onKeyUp(const SEvent &event, s32 &mark_begin, s32 &mark_end)
{ {
// clang-format off
if (m_multiline || (m_word_wrap && m_broken_text.size() > 1)) { if (m_multiline || (m_word_wrap && m_broken_text.size() > 1)) {
s32 lineNo = getLineFromPos(m_cursor_pos); s32 lineNo = getLineFromPos(m_cursor_pos);
s32 mb = (m_mark_begin == m_mark_end) ? m_cursor_pos : s32 mb = (m_mark_begin == m_mark_end) ? m_cursor_pos :
@ -481,13 +480,11 @@ bool GUIEditBox::onKeyUp(const SEvent &event, s32 &mark_begin, s32 &mark_end)
return true; return true;
} }
// clang-format on
return false; return false;
} }
bool GUIEditBox::onKeyDown(const SEvent &event, s32 &mark_begin, s32 &mark_end) bool GUIEditBox::onKeyDown(const SEvent &event, s32 &mark_begin, s32 &mark_end)
{ {
// clang-format off
if (m_multiline || (m_word_wrap && m_broken_text.size() > 1)) { if (m_multiline || (m_word_wrap && m_broken_text.size() > 1)) {
s32 lineNo = getLineFromPos(m_cursor_pos); s32 lineNo = getLineFromPos(m_cursor_pos);
s32 mb = (m_mark_begin == m_mark_end) ? m_cursor_pos : s32 mb = (m_mark_begin == m_mark_end) ? m_cursor_pos :
@ -513,7 +510,6 @@ bool GUIEditBox::onKeyDown(const SEvent &event, s32 &mark_begin, s32 &mark_end)
return true; return true;
} }
// clang-format on
return false; return false;
} }

@ -199,14 +199,12 @@ bool GUIPasswordChange::processInput()
bool GUIPasswordChange::OnEvent(const SEvent &event) bool GUIPasswordChange::OnEvent(const SEvent &event)
{ {
if (event.EventType == EET_KEY_INPUT_EVENT) { if (event.EventType == EET_KEY_INPUT_EVENT) {
// clang-format off
if ((event.KeyInput.Key == KEY_ESCAPE || if ((event.KeyInput.Key == KEY_ESCAPE ||
event.KeyInput.Key == KEY_CANCEL) && event.KeyInput.Key == KEY_CANCEL) &&
event.KeyInput.PressedDown) { event.KeyInput.PressedDown) {
quitMenu(); quitMenu();
return true; return true;
} }
// clang-format on
if (event.KeyInput.Key == KEY_RETURN && event.KeyInput.PressedDown) { if (event.KeyInput.Key == KEY_RETURN && event.KeyInput.PressedDown) {
acceptInput(); acceptInput();
if (processInput()) if (processInput())

@ -155,7 +155,6 @@ bool GUIScrollBar::OnEvent(const SEvent &event)
if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
is_dragging = false; is_dragging = false;
// clang-format off
if (!dragged_by_slider) { if (!dragged_by_slider) {
if (is_inside) { if (is_inside) {
dragged_by_slider = slider_rect.isPointInside(p); dragged_by_slider = slider_rect.isPointInside(p);
@ -167,7 +166,6 @@ bool GUIScrollBar::OnEvent(const SEvent &event)
return is_inside; return is_inside;
} }
} }
// clang-format on
const s32 new_pos = getPosFromMousePos(p); const s32 new_pos = getPosFromMousePos(p);
const s32 old_pos = scroll_pos; const s32 old_pos = scroll_pos;

@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "touchscreengui.h" #include "touchscreengui.h"
#endif #endif
// clang-format off
GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
s32 id, IMenuManager *menumgr, bool remap_dbl_click) : s32 id, IMenuManager *menumgr, bool remap_dbl_click) :
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
@ -57,7 +56,6 @@ GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
m_doubleclickdetect[0].pos = v2s32(0, 0); m_doubleclickdetect[0].pos = v2s32(0, 0);
m_doubleclickdetect[1].pos = v2s32(0, 0); m_doubleclickdetect[1].pos = v2s32(0, 0);
} }
// clang-format on
GUIModalMenu::~GUIModalMenu() GUIModalMenu::~GUIModalMenu()
{ {
@ -110,7 +108,6 @@ void GUIModalMenu::quitMenu()
#endif #endif
} }
// clang-format off
bool GUIModalMenu::DoubleClickDetection(const SEvent &event) bool GUIModalMenu::DoubleClickDetection(const SEvent &event)
{ {
/* The following code is for capturing double-clicks of the mouse button /* The following code is for capturing double-clicks of the mouse button
@ -160,7 +157,6 @@ bool GUIModalMenu::DoubleClickDetection(const SEvent &event)
return false; return false;
} }
// clang-format on
static bool isChild(gui::IGUIElement *tocheck, gui::IGUIElement *parent) static bool isChild(gui::IGUIElement *tocheck, gui::IGUIElement *parent)
{ {
@ -236,7 +232,6 @@ void GUIModalMenu::leave()
bool GUIModalMenu::preprocessEvent(const SEvent &event) bool GUIModalMenu::preprocessEvent(const SEvent &event)
{ {
#ifdef __ANDROID__ #ifdef __ANDROID__
// clang-format off
// display software keyboard when clicking edit boxes // display software keyboard when clicking edit boxes
if (event.EventType == EET_MOUSE_INPUT_EVENT && if (event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) { event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {

@ -144,9 +144,6 @@ public:
} }
}; };
// clang-format off
// ^ dislikes long lines
/** Constructs a shared pointer as a *secondary* reference to an object /** Constructs a shared pointer as a *secondary* reference to an object
* *
* This function is intended to make a temporary reference to an object which * This function is intended to make a temporary reference to an object which
@ -205,5 +202,3 @@ irr_ptr<T> make_irr(Args&&... args)
{ {
return irr_ptr<T>(new T(std::forward<Args>(args)...)); return irr_ptr<T>(new T(std::forward<Args>(args)...));
} }
// clang-format on

@ -193,7 +193,6 @@ void LuaCamera::Register(lua_State *L)
registerClass(L, className, methods, metamethods); registerClass(L, className, methods, metamethods);
} }
// clang-format off
const char LuaCamera::className[] = "Camera"; const char LuaCamera::className[] = "Camera";
const luaL_Reg LuaCamera::methods[] = { const luaL_Reg LuaCamera::methods[] = {
luamethod(LuaCamera, set_camera_mode), luamethod(LuaCamera, set_camera_mode),
@ -208,4 +207,3 @@ const luaL_Reg LuaCamera::methods[] = {
{0, 0} {0, 0}
}; };
// clang-format on

@ -115,7 +115,6 @@ ModChannel *ModChannelRef::getobject(lua_State *L, ModChannelRef *ref)
return getGameDef(L)->getModChannel(ref->m_modchannel_name); return getGameDef(L)->getModChannel(ref->m_modchannel_name);
} }
// clang-format off
const char ModChannelRef::className[] = "ModChannelRef"; const char ModChannelRef::className[] = "ModChannelRef";
const luaL_Reg ModChannelRef::methods[] = { const luaL_Reg ModChannelRef::methods[] = {
luamethod(ModChannelRef, leave), luamethod(ModChannelRef, leave),
@ -123,4 +122,3 @@ const luaL_Reg ModChannelRef::methods[] = {
luamethod(ModChannelRef, send_all), luamethod(ModChannelRef, send_all),
{0, 0}, {0, 0},
}; };
// clang-format on

@ -59,7 +59,6 @@ void PlayerMetaRef::Register(lua_State *L)
// lua_register(L, className, create_object); // lua_register(L, className, create_object);
} }
// clang-format off
const char PlayerMetaRef::className[] = "PlayerMetaRef"; const char PlayerMetaRef::className[] = "PlayerMetaRef";
const luaL_Reg PlayerMetaRef::methods[] = { const luaL_Reg PlayerMetaRef::methods[] = {
luamethod(MetaDataRef, contains), luamethod(MetaDataRef, contains),
@ -76,4 +75,3 @@ const luaL_Reg PlayerMetaRef::methods[] = {
luamethod(MetaDataRef, equals), luamethod(MetaDataRef, equals),
{0,0} {0,0}
}; };
// clang-format on

@ -69,7 +69,6 @@ void ActiveObjectMgr::step(
} }
} }
// clang-format off
bool ActiveObjectMgr::registerObject(std::unique_ptr<ServerActiveObject> obj) bool ActiveObjectMgr::registerObject(std::unique_ptr<ServerActiveObject> obj)
{ {
assert(obj); // Pre-condition assert(obj); // Pre-condition
@ -126,7 +125,6 @@ void ActiveObjectMgr::removeObject(u16 id)
m_active_objects.erase(id); // `it` can be invalid now m_active_objects.erase(id); // `it` can be invalid now
} }
// clang-format on
void ActiveObjectMgr::getObjectsInsideRadius(const v3f &pos, float radius, void ActiveObjectMgr::getObjectsInsideRadius(const v3f &pos, float radius,
std::vector<ServerActiveObject *> &result, std::vector<ServerActiveObject *> &result,
std::function<bool(ServerActiveObject *obj)> include_obj_cb) std::function<bool(ServerActiveObject *obj)> include_obj_cb)

@ -49,7 +49,6 @@ ServerModManager::ServerModManager(const std::string &worldpath):
configuration.checkConflictsAndDeps(); configuration.checkConflictsAndDeps();
} }
// clang-format off
// This function cannot be currenctly easily tested but it should be ASAP // This function cannot be currenctly easily tested but it should be ASAP
void ServerModManager::loadMods(ServerScripting *script) void ServerModManager::loadMods(ServerScripting *script)
{ {
@ -75,7 +74,6 @@ void ServerModManager::loadMods(ServerScripting *script)
script->on_mods_loaded(); script->on_mods_loaded();
} }
// clang-format on
const ModSpec *ServerModManager::getModSpec(const std::string &modname) const const ModSpec *ServerModManager::getModSpec(const std::string &modname) const
{ {
for (const auto &mod : configuration.getMods()) { for (const auto &mod : configuration.getMods()) {

@ -92,7 +92,6 @@ void UnitSAO::getBonePosition(const std::string &bone, v3f *position, v3f *rotat
} }
} }
// clang-format off
void UnitSAO::sendOutdatedData() void UnitSAO::sendOutdatedData()
{ {
if (!m_armor_groups_sent) { if (!m_armor_groups_sent) {
@ -123,7 +122,6 @@ void UnitSAO::sendOutdatedData()
m_messages_out.emplace(getId(), true, generateUpdateAttachmentCommand()); m_messages_out.emplace(getId(), true, generateUpdateAttachmentCommand());
} }
} }
// clang-format on
void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position, void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position,
v3f rotation, bool force_visible) v3f rotation, bool force_visible)

@ -44,13 +44,11 @@ enum class OverrideTarget : override_t
SPECIAL_5 = 1 << 12, SPECIAL_5 = 1 << 12,
SPECIAL_6 = 1 << 13, SPECIAL_6 = 1 << 13,
// clang-format off
SIDES = LEFT | RIGHT | FRONT | BACK, SIDES = LEFT | RIGHT | FRONT | BACK,
ALL_FACES = TOP | BOTTOM | SIDES, ALL_FACES = TOP | BOTTOM | SIDES,
ALL_SPECIAL = SPECIAL_1 | SPECIAL_2 | SPECIAL_3 | SPECIAL_4 | SPECIAL_5 | SPECIAL_6, ALL_SPECIAL = SPECIAL_1 | SPECIAL_2 | SPECIAL_3 | SPECIAL_4 | SPECIAL_5 | SPECIAL_6,
NODE_TARGETS = ALL_FACES | ALL_SPECIAL, NODE_TARGETS = ALL_FACES | ALL_SPECIAL,
ITEM_TARGETS = INVENTORY | WIELD, ITEM_TARGETS = INVENTORY | WIELD,
// clang-format on
}; };
struct TextureOverride struct TextureOverride

@ -32,7 +32,6 @@
// float, return the float. // float, return the float.
f32 u32Tof32Slow(u32 i) f32 u32Tof32Slow(u32 i)
{ {
// clang-format off
int exp = (i >> 23) & 0xFF; int exp = (i >> 23) & 0xFF;
u32 sign = i & 0x80000000UL; u32 sign = i & 0x80000000UL;
u32 imant = i & 0x7FFFFFUL; u32 imant = i & 0x7FFFFFUL;
@ -56,7 +55,6 @@ f32 u32Tof32Slow(u32 i)
return sign ? -ldexpf((f32)(imant | 0x800000UL), exp - 150) : return sign ? -ldexpf((f32)(imant | 0x800000UL), exp - 150) :
ldexpf((f32)(imant | 0x800000UL), exp - 150); ldexpf((f32)(imant | 0x800000UL), exp - 150);
// clang-format on
} }
// Given a float, return an unsigned 32-bit integer representing the f32 // Given a float, return an unsigned 32-bit integer representing the f32
@ -94,7 +92,6 @@ u32 f32Tou32Slow(f32 f)
// - The endianness of f32s and integers must match. // - The endianness of f32s and integers must match.
FloatType getFloatSerializationType() FloatType getFloatSerializationType()
{ {
// clang-format off
const f32 cf = -22220490.f; const f32 cf = -22220490.f;
const u32 cu = 0xCBA98765UL; const u32 cu = 0xCBA98765UL;
if (std::numeric_limits<f32>::is_iec559 && sizeof(cf) == 4 && if (std::numeric_limits<f32>::is_iec559 && sizeof(cf) == 4 &&
@ -132,5 +129,4 @@ FloatType getFloatSerializationType()
} }
return FLOATTYPE_SLOW; return FLOATTYPE_SLOW;
// clang-format on
} }

@ -26,7 +26,6 @@
* *
*/ */
// clang-format off
#include <cstddef> #include <cstddef>
@ -37,7 +36,6 @@
#include <ctime> #include <ctime>
#endif #endif
// clang-format on
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@ -80,7 +78,6 @@ void *(*srp_alloc)(size_t) = &malloc;
void *(*srp_realloc)(void *, size_t) = &realloc; void *(*srp_realloc)(void *, size_t) = &realloc;
void (*srp_free)(void *) = &free; void (*srp_free)(void *) = &free;
// clang-format off
void srp_set_memory_functions( void srp_set_memory_functions(
void *(*new_srp_alloc)(size_t), void *(*new_srp_alloc)(size_t),
void *(*new_srp_realloc)(void *, size_t), void *(*new_srp_realloc)(void *, size_t),
@ -90,7 +87,6 @@ void srp_set_memory_functions(
srp_realloc = new_srp_realloc; srp_realloc = new_srp_realloc;
srp_free = new_srp_free; srp_free = new_srp_free;
} }
// clang-format on
typedef struct { typedef struct {
mpz_t N; mpz_t N;
@ -261,7 +257,6 @@ struct SRPUser {
unsigned char session_key[SHA512_DIGEST_LENGTH]; unsigned char session_key[SHA512_DIGEST_LENGTH];
}; };
// clang-format off
static int hash_init(SRP_HashAlgorithm alg, HashCTX *c) static int hash_init(SRP_HashAlgorithm alg, HashCTX *c)
{ {
switch (alg) { switch (alg) {
@ -357,7 +352,6 @@ static size_t hash_length(SRP_HashAlgorithm alg)
default: return 0; default: return 0;
}; };
} }
// clang-format on
inline static int mpz_num_bytes(const mpz_t op) inline static int mpz_num_bytes(const mpz_t op)
{ {
@ -588,7 +582,6 @@ static SRP_Result init_random()
* *
***********************************************************************************************************/ ***********************************************************************************************************/
// clang-format off
SRP_Result srp_create_salted_verification_key( SRP_HashAlgorithm alg, SRP_Result srp_create_salted_verification_key( SRP_HashAlgorithm alg,
SRP_NGType ng_type, const char *username_for_verifier, SRP_NGType ng_type, const char *username_for_verifier,
const unsigned char *password, size_t len_password, const unsigned char *password, size_t len_password,
@ -600,7 +593,6 @@ SRP_Result srp_create_salted_verification_key( SRP_HashAlgorithm alg,
mpz_t v; mpz_init(v); mpz_t v; mpz_init(v);
mpz_t x; mpz_init(x); mpz_t x; mpz_init(x);
// clang-format on
NGConstant *ng = new_ng(ng_type, n_hex, g_hex); NGConstant *ng = new_ng(ng_type, n_hex, g_hex);
@ -646,7 +638,6 @@ error_and_exit:
goto cleanup_and_exit; goto cleanup_and_exit;
} }
// clang-format off
/* Out: bytes_B, len_B. /* Out: bytes_B, len_B.
* *
@ -671,7 +662,6 @@ struct SRPVerifier *srp_verifier_new(SRP_HashAlgorithm alg,
mpz_t tmp1; mpz_init(tmp1); mpz_t tmp1; mpz_init(tmp1);
mpz_t tmp2; mpz_init(tmp2); mpz_t tmp2; mpz_init(tmp2);
mpz_t tmp3; mpz_init(tmp3); mpz_t tmp3; mpz_init(tmp3);
// clang-format on
size_t ulen = strlen(username) + 1; size_t ulen = strlen(username) + 1;
NGConstant *ng = new_ng(ng_type, n_hex, g_hex); NGConstant *ng = new_ng(ng_type, n_hex, g_hex);
struct SRPVerifier *ver = 0; struct SRPVerifier *ver = 0;
@ -922,13 +912,11 @@ size_t srp_user_get_session_key_length(struct SRPUser *usr)
return hash_length(usr->hash_alg); return hash_length(usr->hash_alg);
} }
// clang-format off
/* Output: username, bytes_A, len_A */ /* Output: username, bytes_A, len_A */
SRP_Result srp_user_start_authentication(struct SRPUser *usr, char **username, SRP_Result srp_user_start_authentication(struct SRPUser *usr, char **username,
const unsigned char *bytes_a, size_t len_a, const unsigned char *bytes_a, size_t len_a,
unsigned char **bytes_A, size_t *len_A) unsigned char **bytes_A, size_t *len_A)
{ {
// clang-format on
if (bytes_a) { if (bytes_a) {
mpz_from_bin(bytes_a, len_a, usr->a); mpz_from_bin(bytes_a, len_a, usr->a);
} else { } else {
@ -956,7 +944,6 @@ error_and_exit:
return SRP_ERR; return SRP_ERR;
} }
// clang-format off
/* Output: bytes_M. Buffer length is SHA512_DIGEST_LENGTH */ /* Output: bytes_M. Buffer length is SHA512_DIGEST_LENGTH */
void srp_user_process_challenge(struct SRPUser *usr, void srp_user_process_challenge(struct SRPUser *usr,
const unsigned char *bytes_s, size_t len_s, const unsigned char *bytes_s, size_t len_s,
@ -972,7 +959,6 @@ void srp_user_process_challenge(struct SRPUser *usr,
mpz_t tmp2; mpz_init(tmp2); mpz_t tmp2; mpz_init(tmp2);
mpz_t tmp3; mpz_init(tmp3); mpz_t tmp3; mpz_init(tmp3);
mpz_t tmp4; mpz_init(tmp4); mpz_t tmp4; mpz_init(tmp4);
// clang-format on
*len_M = 0; *len_M = 0;
*bytes_M = 0; *bytes_M = 0;
@ -996,7 +982,6 @@ void srp_user_process_challenge(struct SRPUser *usr,
srp_dbg_num(v, "Client calculated v: "); srp_dbg_num(v, "Client calculated v: ");
// clang-format off
/* S = (B - k*(g^x)) ^ (a + ux) */ /* S = (B - k*(g^x)) ^ (a + ux) */
mpz_mul(tmp1, u, x); mpz_mul(tmp1, u, x);
mpz_add(tmp2, usr->a, tmp1); /* tmp2 = (a + ux) */ mpz_add(tmp2, usr->a, tmp1); /* tmp2 = (a + ux) */
@ -1004,7 +989,6 @@ void srp_user_process_challenge(struct SRPUser *usr,
mpz_mulm(tmp3, k, tmp1, usr->ng->N, tmp4); /* tmp3 = k*(g^x) */ mpz_mulm(tmp3, k, tmp1, usr->ng->N, tmp4); /* tmp3 = k*(g^x) */
mpz_subm(tmp1, B, tmp3, usr->ng->N, tmp4); /* tmp1 = (B - K*(g^x)) */ mpz_subm(tmp1, B, tmp3, usr->ng->N, tmp4); /* tmp1 = (B - K*(g^x)) */
mpz_powm(usr->S, tmp1, tmp2, usr->ng->N); mpz_powm(usr->S, tmp1, tmp2, usr->ng->N);
// clang-format on
if (!hash_num(usr->hash_alg, usr->S, usr->session_key)) goto cleanup_and_exit; if (!hash_num(usr->hash_alg, usr->S, usr->session_key)) goto cleanup_and_exit;

@ -79,8 +79,6 @@ typedef enum {
SRP_OK, SRP_OK,
} SRP_Result; } SRP_Result;
// clang-format off
/* Sets the memory functions used by srp. /* Sets the memory functions used by srp.
* Note: this doesn't set the memory functions used by gmp, * Note: this doesn't set the memory functions used by gmp,
* but it is supported to have different functions for srp and gmp. * but it is supported to have different functions for srp and gmp.
@ -130,8 +128,6 @@ struct SRPVerifier* srp_verifier_new(SRP_HashAlgorithm alg, SRP_NGType ng_type,
unsigned char** bytes_B, size_t *len_B, unsigned char** bytes_B, size_t *len_B,
const char* n_hex, const char* g_hex); const char* n_hex, const char* g_hex);
// clang-format on
void srp_verifier_delete(struct SRPVerifier *ver); void srp_verifier_delete(struct SRPVerifier *ver);
// srp_verifier_verify_session must have been called before // srp_verifier_verify_session must have been called before
@ -170,8 +166,6 @@ const unsigned char *srp_user_get_session_key(struct SRPUser *usr, size_t *key_l
size_t srp_user_get_session_key_length(struct SRPUser *usr); size_t srp_user_get_session_key_length(struct SRPUser *usr);
// clang-format off
/* Output: username, bytes_A, len_A. /* Output: username, bytes_A, len_A.
* If you don't want it get written, set username to NULL. * If you don't want it get written, set username to NULL.
* If bytes_a == NULL, random data is used for a. */ * If bytes_a == NULL, random data is used for a. */
@ -185,7 +179,6 @@ void srp_user_process_challenge(struct SRPUser *usr,
const unsigned char *bytes_s, size_t len_s, const unsigned char *bytes_s, size_t len_s,
const unsigned char *bytes_B, size_t len_B, const unsigned char *bytes_B, size_t len_B,
unsigned char **bytes_M, size_t *len_M); unsigned char **bytes_M, size_t *len_M);
// clang-format on
/* bytes_HAMK must be exactly srp_user_get_session_key_length() bytes in size */ /* bytes_HAMK must be exactly srp_user_get_session_key_length() bytes in size */
void srp_user_verify_session(struct SRPUser *usr, const unsigned char *bytes_HAMK); void srp_user_verify_session(struct SRPUser *usr, const unsigned char *bytes_HAMK);

@ -1,500 +0,0 @@
src/activeobject.h
src/ban.cpp
src/camera.cpp
src/camera.h
src/chat.cpp
src/chat.h
src/chat_interface.h
src/client/clientlauncher.cpp
src/client/clientlauncher.h
src/client/sound_openal.cpp
src/client.cpp
src/clientenvironment.cpp
src/clientenvironment.h
src/client/gameui.cpp
src/client.h
src/client/hud.cpp
src/client/hud.h
src/clientiface.cpp
src/clientiface.h
src/client/joystick_controller.cpp
src/client/joystick_controller.h
src/clientmap.cpp
src/clientmap.h
src/clientmedia.cpp
src/clientmedia.h
src/clientobject.cpp
src/clientobject.h
src/client/render/core.cpp
src/client/renderingengine.cpp
src/client/render/interlaced.cpp
src/client/render/plain.cpp
src/client/render/sidebyside.cpp
src/client/render/stereo.cpp
src/client/tile.cpp
src/client/tile.h
src/client/fontengine.h
src/client/clientenvironment.cpp
src/client/mapblock_mesh.cpp
src/client/sound_openal.h
src/client/clouds.cpp
src/client/fontengine.cpp
src/client/camera.h
src/client/hud.cpp
src/client/clientmap.cpp
src/client/sound_openal.cpp
src/client/minimap.h
src/client/content_cao.cpp
src/client/localplayer.h
src/client/mapblock_mesh.h
src/client/mesh.cpp
src/client/sound.cpp
src/client/guiscalingfilter.cpp
src/client/content_cso.cpp
src/client/gameui.cpp
src/client/wieldmesh.cpp
src/client/clientmedia.h
src/client/game.cpp
src/client/keys.h
src/client/client.h
src/client/shader.cpp
src/client/clientmap.h
src/client/inputhandler.h
src/client/content_mapblock.h
src/client/game.h
src/client/mesh.h
src/client/camera.cpp
src/client/sky.h
src/client/mesh_generator_thread.cpp
src/client/guiscalingfilter.h
src/client/clientobject.cpp
src/client/tile.cpp
src/client/hud.h
src/client/inputhandler.cpp
src/client/clientevent.h
src/client/gameui.h
src/client/content_cso.h
src/client/sky.cpp
src/client/localplayer.cpp
src/client/content_mapblock.cpp
src/client/clientobject.h
src/client/filecache.cpp
src/client/particles.h
src/client/clientenvironment.h
src/client/imagefilters.h
src/client/renderingengine.cpp
src/client/tile.h
src/client/clientmedia.cpp
src/client/event_manager.h
src/client/joystick_controller.h
src/client/clouds.h
src/client/clientlauncher.h
src/client/content_cao.h
src/client/minimap.cpp
src/client/sound.h
src/client/keycode.cpp
src/client/particles.cpp
src/client/joystick_controller.cpp
src/client/keycode.h
src/client/wieldmesh.h
src/client/filecache.h
src/client/shader.h
src/client/mesh_generator_thread.h
src/client/renderingengine.h
src/client/client.cpp
src/client/imagefilters.cpp
src/client/clientlauncher.cpp
src/clouds.cpp
src/clouds.h
src/collision.cpp
src/collision.h
src/config.h
src/content_cao.cpp
src/content_cao.h
src/content_cso.cpp
src/content_cso.h
src/content_mapblock.cpp
src/content_mapblock.h
src/content_mapnode.cpp
src/content_nodemeta.cpp
src/content_nodemeta.h
src/convert_json.cpp
src/convert_json.h
src/craftdef.cpp
src/craftdef.h
src/database/database.cpp
src/database/database-dummy.cpp
src/database/database-files.cpp
src/database/database-leveldb.cpp
src/database/database-postgresql.cpp
src/database/database-postgresql.h
src/database/database-redis.cpp
src/database/database-sqlite3.cpp
src/database/database-sqlite3.h
src/daynightratio.h
src/debug.cpp
src/debug.h
src/defaultsettings.cpp
src/emerge.cpp
src/emerge.h
src/environment.cpp
src/exceptions.h
src/face_position_cache.cpp
src/face_position_cache.h
src/filecache.cpp
src/filesys.cpp
src/filesys.h
src/fontengine.cpp
src/fontengine.h
src/game.cpp
src/gamedef.h
src/game.h
src/gettext.cpp
src/gettext.h
src/gui/guiAnimatedImage.cpp
src/gui/guiAnimatedImage.h
src/gui/guiBackgroundImage.cpp
src/gui/guiBackgroundImage.h
src/gui/guiBox.cpp
src/gui/guiBox.h
src/gui/guiButton.cpp
src/gui/guiButton.h
src/gui/guiButtonImage.cpp
src/gui/guiButtonImage.h
src/gui/guiButtonItemImage.cpp
src/gui/guiButtonItemImage.h
src/gui/guiChatConsole.cpp
src/gui/guiChatConsole.h
src/gui/guiConfirmRegistration.cpp
src/gui/guiEditBoxWithScrollbar.cpp
src/gui/guiEditBoxWithScrollbar.h
src/gui/guiEngine.cpp
src/gui/guiEngine.h
src/gui/guiFormSpecMenu.cpp
src/gui/guiFormSpecMenu.h
src/gui/guiKeyChangeMenu.cpp
src/gui/guiHyperText.cpp
src/gui/guiHyperText.h
src/gui/guiInventoryList.cpp
src/gui/guiInventoryList.h
src/gui/guiItemImage.cpp
src/gui/guiItemImage.h
src/gui/guiMainMenu.h
src/gui/guiPasswordChange.cpp
src/gui/guiPathSelectMenu.cpp
src/gui/guiPathSelectMenu.h
src/gui/guiScene.cpp
src/gui/guiScene.h
src/gui/guiScrollBar.cpp
src/gui/guiSkin.cpp
src/gui/guiSkin.h
src/gui/guiTable.cpp
src/gui/guiTable.h
src/gui/guiVolumeChange.cpp
src/gui/guiVolumeChange.h
src/gui/mainmenumanager.h
src/gui/modalMenu.h
src/guiscalingfilter.cpp
src/guiscalingfilter.h
src/gui/StyleSpec.h
src/gui/touchscreengui.cpp
src/httpfetch.cpp
src/hud.cpp
src/hud.h
src/imagefilters.cpp
src/imagefilters.h
src/inventory.cpp
src/inventory.h
src/inventorymanager.cpp
src/inventorymanager.h
src/irrlicht_changes/CGUITTFont.cpp
src/irrlicht_changes/CGUITTFont.h
src/irrlicht_changes/irrUString.h
src/irrlicht_changes/static_text.cpp
src/irrlicht_changes/static_text.h
src/irrlichttypes.h
src/itemdef.cpp
src/itemdef.h
src/itemstackmetadata.cpp
src/keycode.cpp
src/light.cpp
src/localplayer.cpp
src/log.cpp
src/log.h
src/main.cpp
src/mapblock.cpp
src/mapblock.h
src/mapblock_mesh.cpp
src/mapblock_mesh.h
src/map.cpp
src/mapgen/cavegen.cpp
src/mapgen/cavegen.h
src/mapgen/dungeongen.cpp
src/mapgen/dungeongen.h
src/mapgen/mapgen.cpp
src/mapgen/mapgen.h
src/mapgen/mapgen_carpathian.cpp
src/mapgen/mapgen_carpathian.h
src/mapgen/mapgen_flat.cpp
src/mapgen/mapgen_flat.h
src/mapgen/mapgen_fractal.cpp
src/mapgen/mapgen_fractal.h
src/mapgen/mapgen_singlenode.cpp
src/mapgen/mapgen_singlenode.h
src/mapgen/mapgen_v5.cpp
src/mapgen/mapgen_v5.h
src/mapgen/mapgen_v6.cpp
src/mapgen/mapgen_v6.h
src/mapgen/mapgen_v7.cpp
src/mapgen/mapgen_v7.h
src/mapgen/mapgen_valleys.cpp
src/mapgen/mapgen_valleys.h
src/mapgen/mg_biome.cpp
src/mapgen/mg_biome.h
src/mapgen/mg_decoration.cpp
src/mapgen/mg_decoration.h
src/mapgen/mg_ore.cpp
src/mapgen/mg_ore.h
src/mapgen/mg_schematic.cpp
src/mapgen/mg_schematic.h
src/mapgen/treegen.cpp
src/mapgen/treegen.h
src/map.h
src/mapnode.cpp
src/mapnode.h
src/mapsector.cpp
src/mapsector.h
src/map_settings_manager.cpp
src/map_settings_manager.h
src/mesh.cpp
src/mesh_generator_thread.cpp
src/mesh.h
src/metadata.h
src/minimap.cpp
src/minimap.h
src/mods.cpp
src/mods.h
src/network/address.cpp
src/network/clientopcodes.cpp
src/network/clientopcodes.h
src/network/clientpackethandler.cpp
src/network/connection.cpp
src/network/connection.h
src/network/connectionthreads.cpp
src/network/networkpacket.cpp
src/network/networkprotocol.h
src/network/serveropcodes.cpp
src/network/serveropcodes.h
src/network/serverpackethandler.cpp
src/nodedef.cpp
src/nodedef.h
src/nodemetadata.cpp
src/nodemetadata.h
src/nodetimer.cpp
src/nodetimer.h
src/noise.cpp
src/noise.h
src/objdef.cpp
src/objdef.h
src/object_properties.cpp
src/object_properties.h
src/particles.cpp
src/particles.h
src/pathfinder.cpp
src/pathfinder.h
src/player.cpp
src/player.h
src/porting_android.cpp
src/porting_android.h
src/porting.cpp
src/porting.h
src/profiler.h
src/raycast.cpp
src/raycast.h
src/reflowscan.cpp
src/reflowscan.h
src/remoteplayer.cpp
src/rollback.cpp
src/rollback.h
src/rollback_interface.cpp
src/rollback_interface.h
src/script/common/c_content.cpp
src/script/common/c_content.h
src/script/common/c_converter.cpp
src/script/common/c_converter.h
src/script/common/c_internal.cpp
src/script/common/c_internal.h
src/script/common/c_types.cpp
src/script/common/c_types.h
src/script/cpp_api/s_async.cpp
src/script/cpp_api/s_async.h
src/script/cpp_api/s_base.cpp
src/script/cpp_api/s_base.h
src/script/cpp_api/s_client.cpp
src/script/cpp_api/s_entity.cpp
src/script/cpp_api/s_entity.h
src/script/cpp_api/s_env.cpp
src/script/cpp_api/s_env.h
src/script/cpp_api/s_internal.h
src/script/cpp_api/s_inventory.cpp
src/script/cpp_api/s_inventory.h
src/script/cpp_api/s_item.cpp
src/script/cpp_api/s_item.h
src/script/cpp_api/s_mainmenu.h
src/script/cpp_api/s_node.cpp
src/script/cpp_api/s_node.h
src/script/cpp_api/s_nodemeta.cpp
src/script/cpp_api/s_nodemeta.h
src/script/cpp_api/s_player.cpp
src/script/cpp_api/s_player.h
src/script/cpp_api/s_security.cpp
src/script/cpp_api/s_security.h
src/script/cpp_api/s_server.cpp
src/script/cpp_api/s_server.h
src/script/lua_api/l_areastore.cpp
src/script/lua_api/l_base.cpp
src/script/lua_api/l_base.h
src/script/lua_api/l_client.cpp
src/script/lua_api/l_craft.cpp
src/script/lua_api/l_craft.h
src/script/lua_api/l_env.cpp
src/script/lua_api/l_env.h
src/script/lua_api/l_http.cpp
src/script/lua_api/l_http.h
src/script/lua_api/l_internal.h
src/script/lua_api/l_inventory.cpp
src/script/lua_api/l_inventory.h
src/script/lua_api/l_item.cpp
src/script/lua_api/l_item.h
src/script/lua_api/l_itemstackmeta.cpp
src/script/lua_api/l_itemstackmeta.h
src/script/lua_api/l_localplayer.cpp
src/script/lua_api/l_mainmenu.cpp
src/script/lua_api/l_mainmenu.h
src/script/lua_api/l_mapgen.cpp
src/script/lua_api/l_mapgen.h
src/script/lua_api/l_metadata.cpp
src/script/lua_api/l_minimap.cpp
src/script/lua_api/l_nodemeta.cpp
src/script/lua_api/l_nodemeta.h
src/script/lua_api/l_nodetimer.cpp
src/script/lua_api/l_noise.cpp
src/script/lua_api/l_object.cpp
src/script/lua_api/l_object.h
src/script/lua_api/l_particles.cpp
src/script/lua_api/l_particles.h
src/script/lua_api/l_particles_local.cpp
src/script/lua_api/l_rollback.cpp
src/script/lua_api/l_rollback.h
src/script/lua_api/l_server.cpp
src/script/lua_api/l_settings.cpp
src/script/lua_api/l_sound.cpp
src/script/lua_api/l_storage.cpp
src/script/lua_api/l_util.cpp
src/script/lua_api/l_vmanip.cpp
src/script/scripting_client.cpp
src/script/scripting_client.h
src/script/scripting_mainmenu.cpp
src/script/scripting_mainmenu.h
src/script/scripting_server.cpp
src/script/scripting_server.h
src/serialization.cpp
src/serialization.h
src/server.cpp
src/serverenvironment.cpp
src/serverenvironment.h
src/server.h
src/serverlist.cpp
src/serverlist.h
src/server/luaentity_sao.cpp
src/server/player_sao.cpp
src/server/serveractiveobject.cpp
src/server/serveractiveobject.h
src/settings.cpp
src/settings.h
src/settings_translation_file.cpp
src/shader.cpp
src/shader.h
src/sky.cpp
src/sound.cpp
src/staticobject.cpp
src/staticobject.h
src/subgame.cpp
src/subgame.h
src/terminal_chat_console.cpp
src/terminal_chat_console.h
src/texture_override.cpp
src/threading/atomic.h
src/threading/event.cpp
src/threading/mutex_auto_lock.h
src/threading/mutex.cpp
src/threading/mutex.h
src/threading/semaphore.cpp
src/threading/thread.cpp
src/threading/thread.h
src/threads.h
src/tileanimation.cpp
src/tileanimation.h
src/tool.cpp
src/tool.h
src/translation.cpp
src/unittest/test_areastore.cpp
src/unittest/test_collision.cpp
src/unittest/test_compression.cpp
src/unittest/test_connection.cpp
src/unittest/test.cpp
src/unittest/test_filepath.cpp
src/unittest/test.h
src/unittest/test_inventory.cpp
src/unittest/test_keycode.cpp
src/unittest/test_map_settings_manager.cpp
src/unittest/test_noderesolver.cpp
src/unittest/test_noise.cpp
src/unittest/test_random.cpp
src/unittest/test_schematic.cpp
src/unittest/test_serialization.cpp
src/unittest/test_settings.cpp
src/unittest/test_socket.cpp
src/unittest/test_threading.cpp
src/unittest/test_utilities.cpp
src/unittest/test_voxelalgorithms.cpp
src/unittest/test_voxelmanipulator.cpp
src/util/areastore.cpp
src/util/areastore.h
src/util/auth.cpp
src/util/auth.h
src/util/base64.cpp
src/util/base64.h
src/util/basic_macros.h
src/util/container.h
src/util/directiontables.cpp
src/util/directiontables.h
src/util/enriched_string.cpp
src/util/enriched_string.h
src/util/md32_common.h
src/util/numeric.cpp
src/util/numeric.h
src/util/pointedthing.cpp
src/util/pointedthing.h
src/util/pointer.h
src/util/quicktune.h
src/util/quicktune_shortcutter.h
src/util/quicktune.cpp
src/util/serialize.cpp
src/util/serialize.h
src/util/sha1.cpp
src/util/srp.cpp
src/util/srp.h
src/util/strfnd.h
src/util/string.cpp
src/util/string.h
src/util/thread.h
src/util/timetaker.cpp
src/util/timetaker.h
src/version.cpp
src/version.h
src/voxelalgorithms.cpp
src/voxelalgorithms.h
src/voxel.cpp
src/voxel.h
src/wieldmesh.cpp

@ -1,64 +0,0 @@
#! /bin/bash
function setup_for_format() {
if [ -z "${CLANG_FORMAT}" ]; then
CLANG_FORMAT=clang-format
fi
echo "LINT: Using binary $CLANG_FORMAT"
CLANG_FORMAT_WHITELIST="util/ci/clang-format-whitelist.txt"
files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"
}
function check_format() {
echo "Checking format..."
setup_for_format
local errorcount=0
local fail=0
for f in ${files_to_lint}; do
d=$(diff -u "$f" <(${CLANG_FORMAT} "$f") || true)
if ! [ -z "$d" ]; then
whitelisted=$(awk '$1 == "'$f'" { print 1 }' "$CLANG_FORMAT_WHITELIST")
# If file is not whitelisted, mark a failure
if [ -z "${whitelisted}" ]; then
errorcount=$((errorcount+1))
printf "The file %s is not compliant with the coding style" "$f"
if [ ${errorcount} -gt 50 ]; then
printf "\nToo many errors encountered previously, this diff is hidden.\n"
else
printf ":\n%s\n" "$d"
fi
fail=1
fi
fi
done
if [ "$fail" = 1 ]; then
echo "LINT reports failure."
exit 1
fi
echo "LINT OK"
}
function fix_format() {
echo "Fixing format..."
setup_for_format
for f in ${files_to_lint}; do
whitelisted=$(awk '$1 == "'$f'" { print 1 }' "$CLANG_FORMAT_WHITELIST")
if [ -z "${whitelisted}" ]; then
echo "$f"
$CLANG_FORMAT -i "$f"
fi
done
}

@ -1,5 +0,0 @@
#!/bin/bash -e
. ./util/ci/clang-format.sh
fix_format