• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Over flow, infinite loop

marcelomnzs

Active Member
Joined
Aug 9, 2019
Messages
159
Reaction score
40
I was having an error on my server (tfs 1.2+) and I couldn't identify it.
After a lot of searching, I found the error:
There was a ramp on the map, which, when climbing, the player fell onto a floorless square (which was covered by another ramp, making it impossible to see without looking with the field browser).

when the player tried to go up, it kind of got stuck, but then went down and continued playing.
but the server keeps trying to process that "teleport" in a loop, and after a few minutes the server crashes.

OK, I fixed the error on the map.
But I was thinking: "and if there is another map bug like this, how could I identify it?"

This is my doubt, and if it would be possible to make any changes to the source, so that if the position is invalid, teleport it to the previous one, stop the loop, or teleport it to the temple (as happens when the player tries to log in to a position invalid).

Can anyone give an idea about this?
 
Firstly, thank you very much for the feedback, but I tried again and same behavior.
see: it's not a temport.. it's a stair.
Looking at the sources, I believe the problem is here:
movement.cpp:

LUA:
ool MoveEvent::executeStep(Creature* creature, Item* item, const Position& pos)
{
    //onStepIn(creature, item, pos, fromPosition)
    //onStepOut(creature, item, pos, fromPosition)
    if (!scriptInterface->reserveScriptEnv()) {
        std::cout << "[Error - MoveEvent::executeStep] Call stack overflow" << std::endl;
        return false;
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(scriptId, scriptInterface);

    lua_State* L = scriptInterface->getLuaState();

    scriptInterface->pushFunction(scriptId);
    LuaScriptInterface::pushUserdata<Creature>(L, creature);
    LuaScriptInterface::setCreatureMetatable(L, -1, creature);
    LuaScriptInterface::pushThing(L, item);
    LuaScriptInterface::pushPosition(L, pos);
    LuaScriptInterface::pushPosition(L, creature->getLastPosition());

    return scriptInterface->callFunction(4);
}
 
You should have a file in lua. Maybe in data/movements/scripts/teleports.lua. or if you have revscripts it could be in data/scripts/movements/teleports.lua. If you do paste it here.
 
You should have a file in lua. Maybe in data/movements/scripts/teleports.lua. or if you have revscripts it could be in data/scripts/movements/teleports.lua. If you do paste it here.
searching here, the script is movements/floorchange.lua in this case..here is:

LUA:
local list = {
    [293] = {x = 0, y = 0, z = 1},
    [294] = {x = 0, y = 0, z = 1},
    [369] = {x = 0, y = 0, z = 1},
    [370] = {x = 0, y = 0, z = 1},
    [385] = {x = 0, y = 0, z = 1},
    [394] = {x = 0, y = 0, z = 1},
    [411] = {x = 0, y = 0, z = 1},
    [412] = {x = 0, y = 0, z = 1},
    [413] = {x = 0, y = 1, z = 1},
    [414] = {x = 0, y = 1, z = 1},
    [428] = {x = 0, y = 1, z = 1},
    [4823] = {x = 0, y = 1, z = 1},
    [4824] = {x = 0, y = 1, z = 1},
    [4825] = {x = 0, y = 1, z = 1},
    [4826] = {x = 0, y = 1, z = 1},
    [432] = {x = 0, y = 0, z = 1},
    [433] = {x = 0, y = 0, z = 1},
    [434] = {x = 0, y = 1, z = 1},
    [437] = {x = 0, y = 1, z = 1},
    [438] = {x = 0, y = 1, z = 1},
    [451] = {x = 0, y = 1, z = 1},
    [465] = {x = 0, y = -1, z = 1},
    [466] = {x = -1, y = 0, z = 1},
    [467] = {x = 1, y = 0, z = 1},
    [471] = {x = -1, y = -1, z = 1},
    [472] = {x = 1, y = -1, z = 1},
    [473] = {x = -1, y = 1, z = 1},
    [474] = {x = 1, y = 1, z = 1},
    [475] = {x = 0, y = 0, z = 1},
    [476] = {x = 0, y = 0, z = 1},
    [482] = {x = 0, y = 0, z = 1},
    [5081] = {x = 0, y = 0, z = 1},
    [483] = {x = 0, y = 0, z = 1},
    [484] = {x = 0, y = 1, z = 1},
    [485] = {x = 0, y = 1, z = 1},
    [566] = {x = 0, y = 1, z = 1},
    [567] = {x = 1, y = 0, z = 1},
    [594] = {x = 0, y = 0, z = 1},
    [595] = {x = 0, y = 0, z = 1},
    [600] = {x = -1, y = 0, z = 1},
    [601] = {x = 1, y = 0, z = 1},
    [604] = {x = -1, y = 0, z = 1},
    [605] = {x = 1, y = 0, z = 1},
    [607] = {x = 0, y = 0, z = 1},
    [609] = {x = 0, y = 0, z = 1},
    [610] = {x = 0, y = 0, z = 1},
    [615] = {x = 0, y = 0, z = 1},
    [1066] = {x = 0, y = 0, z = 1},
    [1067] = {x = 0, y = 0, z = 1},
    [1080] = {x = 0, y = 0, z = 1},
    [1156] = {x = 0, y = 1, z = 1},
    [1947] = {x = 0, y = -1, z = -1},
    [1950] = {x = 1, y = 0, z = -1},
    [1952] = {x = -1, y = 0, z = -1},
    [1954] = {x = 0, y = 1, z = -1},
    [1956] = {x = 0, y = -1, z = -1},
    [1958] = {x = 0, y = -1, z = -1},
    [1960] = {x = 1, y = 0, z = -1},
    [1962] = {x = -1, y = 0, z = -1},
    [1964] = {x = 0, y = 1, z = -1},
    [1966] = {x = 0, y = -1, z = -1},
    [1969] = {x = 1, y = 0, z = -1},
    [1971] = {x = -1, y = 0, z = -1},
    [1973] = {x = 0, y = 1, z = -1},
    [1975] = {x = 0, y = -1, z = -1},
    [1977] = {x = 0, y = -1, z = -1},
    [1978] = {x = -1, y = 0, z = -1},
    [2192] = {x = -1, y = -1, z = -1},
    [2194] = {x = 1, y = -1, z = -1},
    [2196] = {x = 1, y = 1, z = -1},
    [2198] = {x = -1, y = 1, z = -1},
    [5257] = {x = -1, y = 0, z = -1},
    [5258] = {x = 0, y = -1, z = -1},
    [5259] = {x = -1, y = 0, z = -1},
    [5544] = {x = 0, y = 0, z = 1},
    [5691] = {x = 1, y = 0, z = 1},
    [5731] = {x = 0, y = 0, z = 1},
    [5763] = {x = 0, y = 0, z = 1},
    [6127] = {x = 0, y = -1, z = 1},
    [6128] = {x = 0, y = 1, z = 1},
    [6129] = {x = 0, y = -1, z = 1},
    [6130] = {x = 0, y = 1, z = 1},
    [6172] = {x = 0, y = 0, z = 1},
    [6173] = {x = 0, y = 0, z = 1},
    [6909] = {x = 1, y = 0, z = -1},
    [6911] = {x = -1, y = 0, z = -1},
    [6913] = {x = 0, y = 1, z = -1},
    [6915] = {x = 0, y = -1, z = -1},
    [6917] = {x = -1, y = 0, z = 1},
    [6918] = {x = 1, y = 0, z = 1},
    [6919] = {x = 0, y = -1, z = 1},
    [6920] = {x = 0, y = 1, z = 1},
    [6921] = {x = -1, y = 0, z = 1},
    [6922] = {x = 1, y = 0, z = 1},
    [6923] = {x = 0, y = -1, z = 1},
    [6924] = {x = 0, y = 1, z = 1},
    [7053] = {x = 1, y = 0, z = 1},
    [17114] = {x = 0, y = 0, z = 1},
    [17136] = {x = 0, y = 0, z = 1},
}

function onStepIn(creature, item, position, fromPosition)
    local entry = list[item:getId()]
    local relPos = item:getPosition():moveRel(entry.x, entry.y, entry.z)
   
    local tile = Tile(relPos)
    if tile == nil or tile:getGround() == nil then
        return false
    end
   
    Tile(item:getPosition()):relocateTo(relPos)
    if item:getId() == 293 then
        item:transform(294)
        item:decay()
    elseif item:getId() == 475 then
        item:transform(476)
        item:decay()
    elseif item:getId() == 1066 then
        item:transform(1067)
        item:decay()  
    end
    return true
end

function onAddItem(item, tileitem, position)
    if tileitem:getId() ~= 293 and tileitem:getId() ~= 475 and tileitem:getId() ~= 476 and tileitem:getId() ~= 1066 then
        local entry = list[tileitem:getId()]
        local relPos = tileitem:getPosition():moveRel(entry.x, entry.y, entry.z)
        item:moveTo(relPos)
    end
    return true
end
 
This is not TFS 1.2 I dont think anyway. but maybe you can change this:

Line 108-110
LUA:
if not tile or not tile:getGround() then
    creature:moveRel(fromPosition.x, fromPosition.y, fromPosition.z)
    return true
end
 
Back
Top