1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-22 04:15:44 +02:00

Allow nil puncher in object:punch (#14319)

This commit is contained in:
sfence
2024-04-28 17:55:04 +02:00
committed by GitHub
parent fc0ac64277
commit 72cb4e9bea
11 changed files with 89 additions and 36 deletions

View File

@@ -462,11 +462,9 @@ u32 PlayerSAO::punch(v3f dir,
if (!toolcap)
return 0;
FATAL_ERROR_IF(!puncher, "Punch action called without SAO");
// No effect if PvP disabled or if immortal
if (isImmortal() || !g_settings->getBool("enable_pvp")) {
if (puncher->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
if (puncher && puncher->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
// create message and add to list
sendPunchCommand();
return 0;
@@ -493,11 +491,16 @@ u32 PlayerSAO::punch(v3f dir,
}
}
actionstream << puncher->getDescription() << " (id=" << puncher->getId() <<
", hp=" << puncher->getHP() << ") punched " <<
getDescription() << " (id=" << m_id << ", hp=" << m_hp <<
"), damage=" << (old_hp - (s32)getHP()) <<
(damage_handled ? " (handled by Lua)" : "") << std::endl;
if (puncher) {
actionstream << puncher->getDescription() << " (id=" << puncher->getId() <<
", hp=" << puncher->getHP() << ")";
} else {
actionstream << "(none)";
}
actionstream << " puched " <<
getDescription() << " (id=" << m_id << ", hp=" << m_hp <<
"), damage=" << (old_hp - (s32)getHP()) <<
(damage_handled ? " (handled by Lua)" : "") << std::endl;
return hitparams.wear;
}