mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix number of tool uses being off by 1..32767 (#11110)
This commit is contained in:
parent
38ba813c55
commit
6910c8d920
18 changed files with 229 additions and 71 deletions
|
@ -305,10 +305,11 @@ void LuaEntitySAO::getStaticData(std::string *result) const
|
|||
*result = os.str();
|
||||
}
|
||||
|
||||
u16 LuaEntitySAO::punch(v3f dir,
|
||||
u32 LuaEntitySAO::punch(v3f dir,
|
||||
const ToolCapabilities *toolcap,
|
||||
ServerActiveObject *puncher,
|
||||
float time_from_last_punch)
|
||||
float time_from_last_punch,
|
||||
u16 initial_wear)
|
||||
{
|
||||
if (!m_registered) {
|
||||
// Delete unknown LuaEntities when punched
|
||||
|
@ -326,7 +327,8 @@ u16 LuaEntitySAO::punch(v3f dir,
|
|||
m_armor_groups,
|
||||
toolcap,
|
||||
&tool_item,
|
||||
time_from_last_punch);
|
||||
time_from_last_punch,
|
||||
initial_wear);
|
||||
|
||||
bool damage_handled = m_env->getScriptIface()->luaentity_Punch(m_id, puncher,
|
||||
time_from_last_punch, toolcap, dir, result.did_punch ? result.damage : 0);
|
||||
|
|
|
@ -44,9 +44,10 @@ public:
|
|||
bool isStaticAllowed() const { return m_prop.static_save; }
|
||||
bool shouldUnload() const { return true; }
|
||||
void getStaticData(std::string *result) const;
|
||||
u16 punch(v3f dir, const ToolCapabilities *toolcap = nullptr,
|
||||
u32 punch(v3f dir, const ToolCapabilities *toolcap = nullptr,
|
||||
ServerActiveObject *puncher = nullptr,
|
||||
float time_from_last_punch = 1000000.0f);
|
||||
float time_from_last_punch = 1000000.0f,
|
||||
u16 initial_wear = 0);
|
||||
void rightClick(ServerActiveObject *clicker);
|
||||
void setPos(const v3f &pos);
|
||||
void moveTo(v3f pos, bool continuous);
|
||||
|
|
|
@ -409,10 +409,11 @@ void PlayerSAO::setLookPitchAndSend(const float pitch)
|
|||
m_env->getGameDef()->SendMovePlayer(m_peer_id);
|
||||
}
|
||||
|
||||
u16 PlayerSAO::punch(v3f dir,
|
||||
u32 PlayerSAO::punch(v3f dir,
|
||||
const ToolCapabilities *toolcap,
|
||||
ServerActiveObject *puncher,
|
||||
float time_from_last_punch)
|
||||
float time_from_last_punch,
|
||||
u16 initial_wear)
|
||||
{
|
||||
if (!toolcap)
|
||||
return 0;
|
||||
|
@ -430,7 +431,7 @@ u16 PlayerSAO::punch(v3f dir,
|
|||
|
||||
s32 old_hp = getHP();
|
||||
HitParams hitparams = getHitParams(m_armor_groups, toolcap,
|
||||
time_from_last_punch);
|
||||
time_from_last_punch, initial_wear);
|
||||
|
||||
PlayerSAO *playersao = m_player->getPlayerSAO();
|
||||
|
||||
|
|
|
@ -109,8 +109,8 @@ public:
|
|||
Interaction interface
|
||||
*/
|
||||
|
||||
u16 punch(v3f dir, const ToolCapabilities *toolcap, ServerActiveObject *puncher,
|
||||
float time_from_last_punch);
|
||||
u32 punch(v3f dir, const ToolCapabilities *toolcap, ServerActiveObject *puncher,
|
||||
float time_from_last_punch, u16 initial_wear = 0);
|
||||
void rightClick(ServerActiveObject *clicker);
|
||||
void setHP(s32 hp, const PlayerHPChangeReason &reason) override
|
||||
{
|
||||
|
|
|
@ -145,11 +145,12 @@ public:
|
|||
virtual bool shouldUnload() const
|
||||
{ return true; }
|
||||
|
||||
// Returns tool wear
|
||||
virtual u16 punch(v3f dir,
|
||||
// Returns added tool wear
|
||||
virtual u32 punch(v3f dir,
|
||||
const ToolCapabilities *toolcap = nullptr,
|
||||
ServerActiveObject *puncher = nullptr,
|
||||
float time_from_last_punch = 1000000.0f)
|
||||
float time_from_last_punch = 1000000.0f,
|
||||
u16 initial_wear = 0)
|
||||
{ return 0; }
|
||||
virtual void rightClick(ServerActiveObject *clicker)
|
||||
{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue