Skip to content

Commit

Permalink
fix: bug reports for players with spaces in their name (opentibiabr#1694
Browse files Browse the repository at this point in the history
)
  • Loading branch information
luan authored Oct 11, 2023
1 parent c8f7233 commit a9198d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ function Player:onMoveCreature(creature, fromPosition, toPosition)
end

local function hasPendingReport(name, targetName, reportType)
name = self:getName():gsub("%s+", "_")
FS.mkdir_p(string.format("%s/reports/players/%s", CORE_DIRECTORY, name))
local file = io.open(string.format("%s/reports/players/%s-%s-%d.txt", CORE_DIRECTORY, name, targetName, reportType), "r")
if file then
io.close(file)
Expand All @@ -407,7 +409,7 @@ local function hasPendingReport(name, targetName, reportType)
end

function Player:onReportRuleViolation(targetName, reportType, reportReason, comment, translation)
local name = self:getName()
name = self:getName()
if hasPendingReport(name, targetName, reportType) then
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your report is being processed.")
return
Expand Down Expand Up @@ -444,7 +446,7 @@ function Player:onReportRuleViolation(targetName, reportType, reportReason, comm
end

function Player:onReportBug(message, position, category)
local name = self:getName()
local name = self:getName():gsub("%s+", "_")
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")

Expand Down
2 changes: 1 addition & 1 deletion data/libs/functions/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function FS.mkdir(path)
if FS.exists(path) then
return true
end
local success, err = os.execute("mkdir " .. path)
local success, err = os.execute('mkdir "' .. path .. '"')
if not success then
return false, err
end
Expand Down

0 comments on commit a9198d2

Please sign in to comment.