From 16fcac19912122b134cc9b953b1de0741e3347d6 Mon Sep 17 00:00:00 2001 From: Nay Date: Sat, 31 Aug 2013 21:02:14 +0100 Subject: [PATCH 1/3] Core/RBAC: Move bf commands to RBAC (using individual permissions) --- sql/updates/auth/2013_08_30_04_auth_misc.sql | 24 +++++++++++++++++++ .../world/2013_08_31_08_world_command.sql | 12 ++++++++++ src/server/game/Accounts/RBAC.h | 6 +++++ src/server/scripts/Commands/cs_bf.cpp | 16 ++++++------- 4 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 sql/updates/auth/2013_08_30_04_auth_misc.sql create mode 100644 sql/updates/world/2013_08_31_08_world_command.sql diff --git a/sql/updates/auth/2013_08_30_04_auth_misc.sql b/sql/updates/auth/2013_08_30_04_auth_misc.sql new file mode 100644 index 00000000000..422f0f38c50 --- /dev/null +++ b/sql/updates/auth/2013_08_30_04_auth_misc.sql @@ -0,0 +1,24 @@ +/* cs_bf.cpp */ + +SET @id = 257; + +-- Add new permissions +DELETE FROM `rbac_permissions` WHERE `id` BETWEEN @id AND @id+5; +INSERT INTO `rbac_permissions` (`id`, `name`) VALUES +(@id+0, 'bf'), +(@id+1, 'bf start'), +(@id+2, 'bf stop'), +(@id+3, 'bf switch'), +(@id+4, 'bf timer'), +(@id+5, 'bf enabled'); + +-- Add permissions to "corresponding Commands Role" +DELETE FROM `rbac_role_permissions` WHERE `permissionId` BETWEEN @id AND @id+5; +INSERT INTO `rbac_role_permissions` (`roleId`, `permissionId`) VALUES +(4, @id+0), +(4, @id+1), +(4, @id+2), +(4, @id+3), +(4, @id+4), +(4, @id+5); + diff --git a/sql/updates/world/2013_08_31_08_world_command.sql b/sql/updates/world/2013_08_31_08_world_command.sql new file mode 100644 index 00000000000..c48180f36b5 --- /dev/null +++ b/sql/updates/world/2013_08_31_08_world_command.sql @@ -0,0 +1,12 @@ +/* cs_bf.cpp */ + +SET @id = 257; + +-- Update command table with new RBAC permissions +UPDATE `command` SET `permission` = @id+0 WHERE `name` = 'bf'; +UPDATE `command` SET `permission` = @id+1 WHERE `name` = 'bf start'; +UPDATE `command` SET `permission` = @id+2 WHERE `name` = 'bf stop'; +UPDATE `command` SET `permission` = @id+3 WHERE `name` = 'bf switch'; +UPDATE `command` SET `permission` = @id+4 WHERE `name` = 'bf timer'; +UPDATE `command` SET `permission` = @id+5 WHERE `name` = 'bf enabled'; + diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index 55f8527a125..be4356f6b54 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -154,6 +154,12 @@ enum RBACPermissions RBAC_PERM_COMMAND_UNBAN_CHARACTER = 254, RBAC_PERM_COMMAND_UNBAN_IP = 255, RBAC_PERM_COMMAND_UNBAN_PLAYERACCOUNT = 256, + RBAC_PERM_COMMAND_BF = 257, + RBAC_PERM_COMMAND_BF_START = 258, + RBAC_PERM_COMMAND_BF_STOP = 259, + RBAC_PERM_COMMAND_BF_SWITCH = 260, + RBAC_PERM_COMMAND_BF_TIMER = 261, + RBAC_PERM_COMMAND_BF_ENABLE = 262, // custom permissions 1000+ RBAC_PERM_MAX diff --git a/src/server/scripts/Commands/cs_bf.cpp b/src/server/scripts/Commands/cs_bf.cpp index 5ab94062a85..0b239219ddd 100644 --- a/src/server/scripts/Commands/cs_bf.cpp +++ b/src/server/scripts/Commands/cs_bf.cpp @@ -35,17 +35,17 @@ public: { static ChatCommand battlefieldcommandTable[] = { - { "start", RBAC_PERM_ADMINISTRATOR_COMMANDS, false, &HandleBattlefieldStart, "", NULL }, - { "stop", RBAC_PERM_ADMINISTRATOR_COMMANDS, false, &HandleBattlefieldEnd, "", NULL }, - { "switch", RBAC_PERM_ADMINISTRATOR_COMMANDS, false, &HandleBattlefieldSwitch, "", NULL }, - { "timer", RBAC_PERM_ADMINISTRATOR_COMMANDS, false, &HandleBattlefieldTimer, "", NULL }, - { "enable", RBAC_PERM_ADMINISTRATOR_COMMANDS, false, &HandleBattlefieldEnable, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "start", RBAC_PERM_COMMAND_BF_START, false, &HandleBattlefieldStart, "", NULL }, + { "stop", RBAC_PERM_COMMAND_BF_STOP, false, &HandleBattlefieldEnd, "", NULL }, + { "switch", RBAC_PERM_COMMAND_BF_SWITCH, false, &HandleBattlefieldSwitch, "", NULL }, + { "timer", RBAC_PERM_COMMAND_BF_TIMER, false, &HandleBattlefieldTimer, "", NULL }, + { "enable", RBAC_PERM_COMMAND_BF_ENABLE, false, &HandleBattlefieldEnable, "", NULL }, + { NULL, 0, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { - { "bf", RBAC_PERM_ADMINISTRATOR_COMMANDS, false, NULL, "", battlefieldcommandTable }, - { NULL, 0, false, NULL, "", NULL } + { "bf", RBAC_PERM_COMMAND_BF, false, NULL, "", battlefieldcommandTable }, + { NULL, 0, false, NULL, "", NULL } }; return commandTable; } From eab035eca6a30fadb30a7517e929f571a85e1e75 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Sat, 31 Aug 2013 21:25:53 +0100 Subject: [PATCH 2/3] Revert e6761ea2aa7897eda7dafa0b11f17c26eb60e334 --- src/server/game/Server/WorldSocket.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 27bb17962ce..625ebff8471 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -512,7 +512,6 @@ int WorldSocket::handle_input_payload (void) m_RecvPct.base (NULL, 0); m_RecvPct.reset(); - delete m_RecvWPct; m_RecvWPct = NULL; m_Header.reset(); From 0394238a294d65b5a4cdfcfac6ac2720c7e57aa0 Mon Sep 17 00:00:00 2001 From: Nay Date: Sat, 31 Aug 2013 22:44:10 +0100 Subject: [PATCH 3/3] Dep/G3D: Fix a typo in Matrix4 == operator --- dep/g3dlite/G3D-v8.0_hotfix7.diff | 13 +++++++++++++ dep/g3dlite/source/Matrix4.cpp | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 dep/g3dlite/G3D-v8.0_hotfix7.diff diff --git a/dep/g3dlite/G3D-v8.0_hotfix7.diff b/dep/g3dlite/G3D-v8.0_hotfix7.diff new file mode 100644 index 00000000000..00ab78f5c7c --- /dev/null +++ b/dep/g3dlite/G3D-v8.0_hotfix7.diff @@ -0,0 +1,13 @@ +diff --git a/dep/g3dlite/source/Matrix4.cpp b/dep/g3dlite/source/Matrix4.cpp +index 2ce14f6..fbc918f 100644 +--- a/dep/g3dlite/source/Matrix4.cpp ++++ b/dep/g3dlite/source/Matrix4.cpp +@@ -382,7 +382,7 @@ bool Matrix4::operator==(const Matrix4& other) const { + // If the bit patterns are identical, they must be + // the same matrix. If not, they *might* still have + // equal elements due to floating point weirdness. +- if (memcmp(this, &other, sizeof(Matrix4) == 0)) { ++ if (memcmp(this, &other, sizeof(Matrix4)) == 0) { + return true; + } + diff --git a/dep/g3dlite/source/Matrix4.cpp b/dep/g3dlite/source/Matrix4.cpp index 2ce14f6c5d4..fbc918f8f3e 100644 --- a/dep/g3dlite/source/Matrix4.cpp +++ b/dep/g3dlite/source/Matrix4.cpp @@ -382,7 +382,7 @@ bool Matrix4::operator==(const Matrix4& other) const { // If the bit patterns are identical, they must be // the same matrix. If not, they *might* still have // equal elements due to floating point weirdness. - if (memcmp(this, &other, sizeof(Matrix4) == 0)) { + if (memcmp(this, &other, sizeof(Matrix4)) == 0) { return true; }