• 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!

C++ Game::playerLookAt crash?

yohanaugusto

New Member
Joined
Sep 28, 2008
Messages
73
Reaction score
0
Hello,

I have a server with 500/600 players online. My server are crashing by an error related to events / onlook (maybe?).

Can someone help me? I searched and found one thread related to this in 2016, but no answers there. TFS 1.3

Here is gdb log:

#0 __memcpy_sse2_unaligned ()
at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:36
No locals.
#1 0x00007ffff692b450 in std::basic_streambuf<char, std::char_traits<char> >::xsputn(char const*, long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#2 0x00007ffff6922c05 in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#3 0x00000000005d6664 in operator<< <char, std::char_traits<char>, std::allocator<char> > (__str=..., __os=...)
at /usr/include/c++/4.8/bits/basic_string.h:2758
No locals.
#4 Player::getDescription (this=0x7fffbf131130,
lookDistance=1)
at /home/server/source/src/player.cpp:175
memberCount = <optimized out>
s = <incomplete type>
#5 0x000000000053bbf7 in LuaScriptInterface::luaCreatureGetDescription (L=0x8d14e0)
at /home/server/source/src/luascript.cpp:7525
distance = 1
creature = <optimized out>
#6 0x00007ffff767ff78 in ?? ()
from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
No symbol table info available.
#7 0x00007ffff768a6af in ?? ()
from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
No symbol table info available.
#8 0x00007ffff76803cd in ?? ()
from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
No symbol table info available.
#9 0x00007ffff767f6eb in ?? ()
from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
No symbol table info available.
#10 0x00007ffff768055a in ?? ()
from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
No symbol table info available.
#11 0x00007ffff767c34d in lua_pcall ()
from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
No symbol table info available.
#12 0x000000000053c446 in LuaScriptInterface::protectedCall (L=0x8d14e0, nargs=nargs@entry=4,
nresults=nresults@entry=0)
at /home/server/source/src/luascript.cpp:288
error_index = 5
ret = <optimized out>
#13 0x00000000005a4566 in LuaScriptInterface::callVoidFunction (this=this@entry=0x7ffff12926e0,
params=params@entry=4)
at /home/server/source/src/luascript.cpp:530
size = 9
#14 0x00000000004d9d90 in Events::eventPlayerOnLook (
this=0x7ffff12926e0,
player=player@entry=0x7fffba6d03f0, position=...,
thing=thing@entry=0x7fffbf131130,
stackpos=stackpos@entry=1 '\001', lookDistance=1)
at /home/server/source/src/events.cpp:433
No locals.
#15 0x00000000004f4aaf in Game::playerLookAt (
this=<optimized out>, playerId=<optimized out>,
pos=..., stackPos=<optimized out>)
at /home/server/source/src/game.cpp:3040
thingPos = {x = 33485, y = 31984, z = 7 '\a'}
playerPos = <optimized out>
lookDistance = <optimized out>
player = 0x7fffba6d03f0
thing = 0x7fffbf131130
#16 0x0000000000623563 in operator() (this=0xba5c00)
at /usr/include/c++/4.8/functional:2471
No locals.
#17 operator() (this=0xba5bf0)
at /home/server/source/src/tasks.h:40
No locals.
#18 Dispatcher::threadMain (
this=0x8c3f20 <g_dispatcher>)
at /home/server/source/src/tasks.cpp:60
task = 0xba5bf0
taskLockUnique = {
_M_device = 0x8c3f38 <g_dispatcher+24>,
_M_owns = false}
#19 0x00007ffff693fa60 in ?? ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#20 0x00007ffff6b9a184 in start_thread (
arg=0x7ffff5316700) at pthread_create.c:312
__res = <optimized out>
pd = 0x7ffff5316700
now = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {
140737307043584, 147974438091105147, 1,
0, 140737307044288, 140737307043584,
-147950743800634501,
-147958509884398725},
mask_was_saved = 0}}, priv = {pad = {0x0,
0x0, 0x0, 0x0}, data = {prev = 0x0,
cleanup = 0x0, canceltype = 0}}}
not_first_call = <optimized out>
pagesize_m1 = <optimized out>
sp = <optimized out>
freesize = <optimized out>
__PRETTY_FUNCTION__ = "start_thread"
#21 0x00007ffff60a737d in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals.
 
Last edited:
events.xml

<?xml version="1.0" encoding="UTF-8"?>
<events>
<!-- Creature methods -->
<event class="Creature" method="onChangeOutfit" enabled="0" />
<event class="Creature" method="onAreaCombat" enabled="0" />
<event class="Creature" method="onTargetCombat" enabled="1" />

<!-- Party methods -->
<event class="Party" method="onJoin" enabled="0" />
<event class="Party" method="onLeave" enabled="0" />
<event class="Party" method="onDisband" enabled="0" />

<!-- Player methods -->
<event class="Player" method="onBrowseField" enabled="0" />
<event class="Player" method="onLook" enabled="1" />
<event class="Player" method="onLookInBattleList" enabled="1" />
<event class="Player" method="onLookInTrade" enabled="1" />
<event class="Player" method="onLookInShop" enabled="0" />
<event class="Player" method="onMoveItem" enabled="1" />
<event class="Player" method="onMoveCreature" enabled="0" />
<event class="Player" method="onTurn" enabled="1" />
<event class="Player" method="onTradeRequest" enabled="1" />
<event class="Player" method="onTradeAccept" enabled="0" />
<event class="Player" method="onGainExperience" enabled="1" />
<event class="Player" method="onLoseExperience" enabled="0" />
<event class="Player" method="onGainSkillTries" enabled="1" />
</events>

player.lua

-- Players cannot throw items on teleports if set to true
local blockTeleportTrashing = false

function Player:eek:nBrowseField(position)
return true
end

function Player:eek:nLook(thing, position, distance)
local description = "You see " .. thing:getDescription(distance)
if self:getGroup():getAccess() then
if thing:isItem() then
description = string.format("%s\nItem ID: %d", description, thing:getId())

local actionId = thing:getActionId()
if actionId ~= 0 then
description = string.format("%s, Action ID: %d", description, actionId)
end

local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
if uniqueId > 0 and uniqueId < 65536 then
description = string.format("%s, Unique ID: %d", description, uniqueId)
end

local itemType = thing:getType()

local transformEquipId = itemType:getTransformEquipId()
local transformDeEquipId = itemType:getTransformDeEquipId()
if transformEquipId ~= 0 then
description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)
elseif transformDeEquipId ~= 0 then
description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)
end

local decayId = itemType:getDecayId()
if decayId ~= -1 then
description = string.format("%s\nDecays to: %d", description, decayId)
end
elseif thing:isCreature() then
local str = "%s\nHealth: %d / %d"
if thing:getMaxMana() > 0 then
str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana())
end
description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."
end

local position = thing:getPosition()
description = string.format(
"%s\nPosition: %d, %d, %d",
description, position.x, position.y, position.z
)

if thing:isCreature() then
if thing:isPlayer() then
description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
end
end
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:eek:nLookInBattleList(creature, distance)
local description = "You see " .. creature:getDescription(distance)
if self:getGroup():getAccess() then
local str = "%s\nHealth: %d / %d"
if creature:getMaxMana() > 0 then
str = string.format("%s, Mana: %d / %d", str, creature:getMana(), creature:getMaxMana())
end
description = string.format(str, description, creature:getHealth(), creature:getMaxHealth()) .. "."

local position = creature:getPosition()
description = string.format(
"%s\nPosition: %d, %d, %d",
description, position.x, position.y, position.z
)

if creature:isPlayer() then
description = string.format("%s\nIP: %s", description, Game.convertIpToString(creature:getIp()))
end
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:eek:nLookInTrade(partner, item, distance)
self:sendTextMessage(MESSAGE_INFO_DESCR, 'You see ' .. item:getDescription(distance))
end

function Player:eek:nLookInShop(itemType, count)
return true
end

function Player:eek:nMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
local tile = toPosition:getTile()
if tile then -- checks if tile
if Tile(toPosition):getItemCount() >= 91 then
self:sendCancelMessage("Sorry, not possible.")
return false
end
end

if item:getActionId() == NOT_MOVEABLE_ACTION then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end

if item:getActionId() == 52960 then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end

if blockTeleportTrashing and toPosition.x ~= CONTAINER_POSITION then
local thing = Tile(toPosition):getItemByType(ITEM_TYPE_TELEPORT)
if thing then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end

if item:getId() == 2595 and item:getWeight() > 250000 then
self:sendCancelMessage('This object is too heavy to be moved.')
return false
end

if item:getId() == 7582 then
if self:getStorageValue(Storage.TravellingTrader.Mission04) == 2 then
self:setStorageValue(Storage.TravellingTrader.Mission04, 1)
self:sendTextMessage(MESSAGE_STATUS_SMALL, "Oh no! The vase has broken!")
end
item:remove()
end

if isInArray({1714, 1715, 1716, 1717, 1738, 1740, 1741, 1747, 1748, 1749}, item:getId()) and item:getActionId() > 0 or item:getActionId() == 5640 then
self:sendCancelMessage('You cannot move this object.')
return false
elseif isInArray({6068, 7466, 16014, 21518}, item:getId()) then
self:sendCancelMessage('You cannot move this object.')
return false
elseif isInArray({23798, 23799, 23800, 23801, 23802, 23803, 23804, 23805}, item:getId()) then
self:sendCancelMessage('You cannot move this object.')
return false
end

if item:getActionId() == 14787 then
self:sendCancelMessage('You cannot move this object.')
return false
end

if item:getTopParent() == self and bit.band(toPosition.y, 0x40) == 0 then
local itemType, moveItem = ItemType(item:getId())
if bit.band(itemType:getSlotPosition(), SLOTP_TWO_HAND) ~= 0 and toPosition.y == CONST_SLOT_LEFT then
moveItem = self:getSlotItem(CONST_SLOT_RIGHT)
elseif itemType:getWeaponType() == WEAPON_SHIELD and toPosition.y == CONST_SLOT_RIGHT then
moveItem = self:getSlotItem(CONST_SLOT_LEFT)
if moveItem and bit.band(ItemType(moveItem:getId()):getSlotPosition(), SLOTP_TWO_HAND) == 0 then
return true
end
end

if moveItem then
local parent = item:getParent()
if parent:getSize() == parent:getCapacity() then
self:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_CONTAINERNOTENOUGHROOM))
return false
else
return moveItem:moveTo(parent)
end
end
end

if toPosition.x == CONTAINER_POSITION then
local containerId = toPosition.y - 64
local container = self:getContainerById(containerId)
if not container then
return true
end

local itemId = container:getId()

if itemId == 26385 and isInArray({2148, 2152, 2160}, item:getId()) then
if item.itemid == 2148 then
self:depositMoney(item:getCount())
item:remove()
return true
elseif item.itemid == 2152 then
self:depositMoney(item:getCount() * 100)
item:remove()
return true
elseif item.itemid == 2160 then
self:depositMoney(item:getCount() * 10000)
item:remove()
return true
end
end

if itemId == 26385 and not isInArray({2148, 2152, 2160}, item:getId()) then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end

if toCylinder:getId() == 26052 then
if not (isInArray({26054, 26385}, item:getId())) then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end
else
if isInArray({26054, 26385}, item:getId()) then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end
end

-- Do not let the player insert items into either the Reward Container or the Reward Chest
if itemId == ITEM_REWARD_CONTAINER or itemId == ITEM_REWARD_CHEST then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end

-- The player also shouldn't be able to insert items into the boss corpse
local tile = Tile(container:getPosition())
for _, item in ipairs(tile:getItems()) do
if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2^31 - 1 and item:getName() == container:getName() then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end
end
end

-- Do not let the player move the boss corpse.
if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2^31 - 1 then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end

if fromPosition.x == CONTAINER_POSITION and toPosition.x == CONTAINER_POSITION and item.itemid == 8710 and self:getItemCount(8710) == 2 and self:getStorageValue(Storage.RookgaardTutorialIsland.cockroachLegsMsgStorage) ~= 1 then
self:sendTextMessage(MESSAGE_INFO_DESCR, 'Well done, you have enough cockroach legs! You should head back to Santiago with them. Climb the ladder to the north to exit.')
self:setStorageValue(Storage.RookgaardTutorialIsland.cockroachLegsMsgStorage, 1)
self:setStorageValue(Storage.RookgaardTutorialIsland.SantiagoNpcGreetStorage, 6)
end
return true
end

function Player:eek:nMoveCreature(creature, fromPosition, toPosition)
return true
end

function Player:eek:nTurn(direction)
if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then
if self:getDirection() == direction then
local nextPosition = self:getPosition()
nextPosition:getNextPosition(direction)

self:teleportTo(nextPosition, true)
end
end
return true
end

function Player:eek:nTradeRequest(target, item)
if isInArray({26054, 26385}, item.itemid) then
self:sendCancelMessage('Sorry, not possible.')
return false
end
if isInArray({1738, 1740, 1747, 1748, 1749, 8766}, item.itemid) and item.actionid > 0 or item.actionid == 5640 then
self:sendCancelMessage('Sorry, not possible.')
return false
end
return true
end

function Player:eek:nTradeAccept(target, item, targetItem)
return true
end

local soulCondition = Condition(CONDITION_SOUL, CONDITIONID_DEFAULT)
soulCondition:setTicks(4 * 60 * 1000)
soulCondition:setParameter(CONDITION_PARAM_SOULGAIN, 1)

local function useStamina(player)
local staminaMinutes = player:getStamina()
if staminaMinutes == 0 then
return
end

local playerId = player:getId()
local currentTime = os.time()
local timePassed = currentTime - nextUseStaminaTime[playerId]
if timePassed <= 0 then
return
end

if timePassed > 60 then
if staminaMinutes > 2 then
staminaMinutes = staminaMinutes - 2
else
staminaMinutes = 0
end
nextUseStaminaTime[playerId] = currentTime + 120
else
staminaMinutes = staminaMinutes - 1
nextUseStaminaTime[playerId] = currentTime + 60
end
player:setStamina(staminaMinutes)
end

function Player:eek:nGainExperience(source, exp, rawExp)
if not source or source:isPlayer() then
return exp
end

local level = self:getLevel()

-- Soul regeneration
local vocation = self:getVocation()
if self:getSoul() < vocation:getMaxSoul() and exp >= level then
soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
self:addCondition(soulCondition)
end

-- Apply experience stage multiplier
if self:getVocation():getBase():getId() == 0 then
if level < 150 then
exp = exp * 50
else
exp = exp * 10
end
else
exp = exp * Game.getExperienceStage(level)
end

if configManager.getBoolean(configKeys.LOWLEVEL_BONUS) then
if level < 50 then
exp = exp * (1 + ((50 - level) / 100))
end
end

if configManager.getBoolean(configKeys.EXP_BOOSTER) then
local staminaMinutes = self:getStamina()
if staminaMinutes >= 840 and self:getExpBoostTime() > 0 then
exp = exp * (1 + (configManager.getNumber(configKeys.EXP_BOOSTER_EXTRA) / 100))
end
end

-- Stamina modifier
if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
useStamina(self)

local staminaMinutes = self:getStamina()
if staminaMinutes > 2400 and self:isPremium() then
exp = exp * 1.5
elseif staminaMinutes <= 840 then
exp = exp * 0.5
end
end

return exp
end

function Player:eek:nLoseExperience(exp)
return exp
end

function Player:eek:nGainSkillTries(skill, tries)
if skill == SKILL_MAGLEVEL then
return tries * configManager.getNumber(configKeys.RATE_MAGIC)
end
return tries * configManager.getNumber(configKeys.RATE_SKILL)
end
 
Back
Top