Aftermath of Armour duplication bug #3903

Open
opened 2023-02-27 22:39:03 +00:00 by AliasAlreadyTaken · 1 comment

Since in #3668 a couple of armour were duplicated, we'd now like to remove those excess armours.

First, we need to find who might have experienced the bug. Most likely it was ingame from 24.1.2023 to 12.2.2023

The bug happened to everyone who

  • died between 24.1.2023 and 12.2.2023
  • wore armour during death
  • did NOT respawn between death and leave
2023-02-27 20:41:28: ACTION[Server]: [bones] Boris dies at (2007,15,1068) and their inventory goes to bones.

2023-02-27 20:44:13: ACTION[Server]: Boris respawns at (2002,15,1154)

2023-02-27 20:44:53: ACTION[Server]: Boris leaves game. List of players: AliasAlreadyTaken 

To remove the [bones] I do a simple search and replace, else I'd have to account for that in the following script.

If there is no respawn between death and leave, then the person closed the client or otherwise lost connection after death, but before they hit the respawn button.

local function get_time(readable_time)
    local format_string = "%Y-%m-%d %X" -- format string for parsing readable time
    local time_table = {} -- empty table to store time components
    local parsed_time = os.date("*t", os.time {
        year = 1970,
        month = 1,
        day = 1
    }) -- create empty time table
    parsed_time.year = tonumber(readable_time:sub(1, 4)) -- extract year component
    parsed_time.month = tonumber(readable_time:sub(6, 7)) -- extract month component
    parsed_time.day = tonumber(readable_time:sub(9, 10)) -- extract day component
    parsed_time.hour = tonumber(readable_time:sub(12, 13)) -- extract hour component
    parsed_time.min = tonumber(readable_time:sub(15, 16)) -- extract minute component
    parsed_time.sec = tonumber(readable_time:sub(18, 19)) -- extract second component
    local unix_timestamp = os.time(parsed_time) -- convert time table to Unix timestamp
    return unix_timestamp + 3600
end

local function mysplit(inputstr, sep)
    -- https://stackoverflow.com/questions/1426954/split-string-in-lua
    if sep == nil then
        sep = "%s"
    end
    local t = {}
    for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
        table.insert(t, str)
    end
    return t
end

local file = io.open("3668_1.txt", "r")
local lines = {}
for line in file:lines() do
    table.insert(lines, line)
end
file:close()

local curr = {}
local prev = {}

for _, line in ipairs(lines) do

    local ret = mysplit(line, " ")

    local n = ret[4] or ""
    local m = curr[n] or ""

    if m == "dies" and ret[5] == "leaves" and string.find(prev[ret[4]], "and their inventory goes to bones") then
        -- local t = get_time(prev[ret[1]] .. " " .. prev[ret[2]])
        local prevline = prev[ret[4]]
        local prevtime = mysplit(prevline, " ")
        local t = get_time(prevtime[1] .. " " .. prevtime[2])
        print(t .. " " .. prev[ret[4]])
        local tt = get_time(ret[1] .. " " .. ret[2])
        print(tt .. " " .. line)
    end

    curr[ret[4]] = ret[5]

    prev[ret[4]] = line

end

That leaves me with 147 incidents and 294 lines. They need to be matched to the leave records. Those only have a timestamp. Ofc the log is in UTC, while the leave tiemstamps are UTC+1. Hence the +3600 in get_time

Since in #3668 a couple of armour were duplicated, we'd now like to remove those excess armours. First, we need to find who might have experienced the bug. Most likely it was ingame from 24.1.2023 to 12.2.2023 The bug happened to everyone who - died between 24.1.2023 and 12.2.2023 - wore armour during death - did NOT respawn between death and leave ``` 2023-02-27 20:41:28: ACTION[Server]: [bones] Boris dies at (2007,15,1068) and their inventory goes to bones. 2023-02-27 20:44:13: ACTION[Server]: Boris respawns at (2002,15,1154) 2023-02-27 20:44:53: ACTION[Server]: Boris leaves game. List of players: AliasAlreadyTaken ``` To remove the [bones] I do a simple search and replace, else I'd have to account for that in the following script. If there is no respawn between death and leave, then the person closed the client or otherwise lost connection after death, but before they hit the respawn button. ```lua local function get_time(readable_time) local format_string = "%Y-%m-%d %X" -- format string for parsing readable time local time_table = {} -- empty table to store time components local parsed_time = os.date("*t", os.time { year = 1970, month = 1, day = 1 }) -- create empty time table parsed_time.year = tonumber(readable_time:sub(1, 4)) -- extract year component parsed_time.month = tonumber(readable_time:sub(6, 7)) -- extract month component parsed_time.day = tonumber(readable_time:sub(9, 10)) -- extract day component parsed_time.hour = tonumber(readable_time:sub(12, 13)) -- extract hour component parsed_time.min = tonumber(readable_time:sub(15, 16)) -- extract minute component parsed_time.sec = tonumber(readable_time:sub(18, 19)) -- extract second component local unix_timestamp = os.time(parsed_time) -- convert time table to Unix timestamp return unix_timestamp + 3600 end local function mysplit(inputstr, sep) -- https://stackoverflow.com/questions/1426954/split-string-in-lua if sep == nil then sep = "%s" end local t = {} for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do table.insert(t, str) end return t end local file = io.open("3668_1.txt", "r") local lines = {} for line in file:lines() do table.insert(lines, line) end file:close() local curr = {} local prev = {} for _, line in ipairs(lines) do local ret = mysplit(line, " ") local n = ret[4] or "" local m = curr[n] or "" if m == "dies" and ret[5] == "leaves" and string.find(prev[ret[4]], "and their inventory goes to bones") then -- local t = get_time(prev[ret[1]] .. " " .. prev[ret[2]]) local prevline = prev[ret[4]] local prevtime = mysplit(prevline, " ") local t = get_time(prevtime[1] .. " " .. prevtime[2]) print(t .. " " .. prev[ret[4]]) local tt = get_time(ret[1] .. " " .. ret[2]) print(tt .. " " .. line) end curr[ret[4]] = ret[5] prev[ret[4]] = line end ``` That leaves me with 147 incidents and 294 lines. They need to be matched to the leave records. Those only have a timestamp. Ofc the log is in UTC, while the leave tiemstamps are UTC+1. Hence the +3600 in get_time
Member

@AliasAlreadyTaken it's certainly not the cause of any bug, but the following line declares a variable which isn't used, and can be deleted:

  • local time_table = {} -- empty table to store time components

i don't see anything obvious, but to properly test things, i'm gonna need a section of server log, or the time to generate events w/ the right code on my local server.

@AliasAlreadyTaken it's certainly not the cause of any bug, but the following line declares a variable which isn't used, and can be deleted: * `local time_table = {} -- empty table to store time components` i don't see anything obvious, but to properly test things, i'm gonna need a section of server log, or the time to generate events w/ the right code on my local server.
AliasAlreadyTaken added the
1. kind/protocol
label 2023-02-28 10:19:39 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#3903
No description provided.