Skip to content

Commit

Permalink
fix: allow players to send in bug reports (opentibiabr#1666)
Browse files Browse the repository at this point in the history
  • Loading branch information
luan authored Oct 5, 2023
1 parent 72adc6e commit 5eac8f5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ end

function Player:onReportBug(message, position, category)
local name = self:getName()
FS.mkdir_p(string.format("%s/reports/bugs/%s", CORE_DIRECTORY, name))
local file = io.open(string.format("%s/reports/bugs/%s/report.txt", CORE_DIRECTORY, name), "a")

if not file then
Expand Down
32 changes: 32 additions & 0 deletions data/libs/functions/fs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FS = {}

function FS.exists(path)
local file = io.open(path, "r")
if file then
file:close()
return true
end
return false
end

function FS.mkdir(path)
if FS.exists(path) then
return true
end
local success, err = os.execute("mkdir " .. path)
if not success then
return false, err
end
return true
end

function FS.mkdir_p(path)
if path == "" then
return true
end
if FS.exists(path) then
return true
end
FS.mkdir_p(path:match("(.*[/\\])"))
return FS.mkdir(path)
end
1 change: 1 addition & 0 deletions data/libs/functions/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dofile(CORE_DIRECTORY .. "/libs/functions/constants.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/container.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/creature.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/functions.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/fs.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/game.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/item.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/itemtype.lua")
Expand Down
6 changes: 1 addition & 5 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6039,11 +6039,7 @@ void ProtocolGame::sendAllowBugReport() {

NetworkMessage msg;
msg.addByte(0x1A);
if (player->getAccountType() >= account::ACCOUNT_TYPE_NORMAL) {
msg.addByte(0x01);
} else {
msg.addByte(0x00);
}
msg.addByte(0x00); // 0x01 = DISABLE bug report
writeToOutputBuffer(msg);
}

Expand Down

0 comments on commit 5eac8f5

Please sign in to comment.