aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-02-11 00:03:26 +0100
committerParamat <paramat@users.noreply.github.com>2019-02-10 23:03:26 +0000
commitffb17f1c9a203fea6de70159b461f52d104e05b9 (patch)
treeca2c9f26515b8c6dad2a42b7e09f5d2a91d6f398 /src/script
parentba5a9f2b361a2fa01d1a3396999a5833983c0f4a (diff)
downloadminetest-ffb17f1c9a203fea6de70159b461f52d104e05b9.tar.gz
minetest-ffb17f1c9a203fea6de70159b461f52d104e05b9.tar.bz2
minetest-ffb17f1c9a203fea6de70159b461f52d104e05b9.zip
Consistent HP and damage types (#8167)
Remove deprecated HUDs and chat message handling. Remove unused m_damage variable (compat break). HP: s32 for setter/calculations, u16 for getter.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/common/c_content.cpp2
-rw-r--r--src/script/cpp_api/s_entity.cpp18
-rw-r--r--src/script/cpp_api/s_player.cpp4
-rw-r--r--src/script/cpp_api/s_player.h2
-rw-r--r--src/script/lua_api/l_object.cpp4
5 files changed, 6 insertions, 24 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 7e2f6772f..793485e25 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -191,7 +191,7 @@ void read_object_properties(lua_State *L, int index,
int hp_max = 0;
if (getintfield(L, -1, "hp_max", hp_max))
- prop->hp_max = (s16)rangelim(hp_max, 0, S16_MAX);
+ prop->hp_max = (u16)rangelim(hp_max, 0, U16_MAX);
getintfield(L, -1, "breath_max", prop->breath_max);
getboolfield(L, -1, "physical", prop->physical);
diff --git a/src/script/cpp_api/s_entity.cpp b/src/script/cpp_api/s_entity.cpp
index a3f7fa68b..8af9f9bf6 100644
--- a/src/script/cpp_api/s_entity.cpp
+++ b/src/script/cpp_api/s_entity.cpp
@@ -169,24 +169,6 @@ void ScriptApiEntity::luaentity_GetProperties(u16 id,
// Set default values that differ from ObjectProperties defaults
prop->hp_max = 10;
- /* Read stuff */
-
- prop->hp_max = getintfield_default(L, -1, "hp_max", 10);
-
- getboolfield(L, -1, "physical", prop->physical);
- getboolfield(L, -1, "collide_with_objects", prop->collideWithObjects);
-
- getfloatfield(L, -1, "weight", prop->weight);
-
- lua_getfield(L, -1, "collisionbox");
- if (lua_istable(L, -1))
- prop->collisionbox = read_aabb3f(L, -1, 1.0);
- lua_pop(L, 1);
-
- getstringfield(L, -1, "visual", prop->visual);
-
- getstringfield(L, -1, "mesh", prop->mesh);
-
// Deprecated: read object properties directly
read_object_properties(L, -1, prop, getServer()->idef());
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp
index fac86295a..df67ea00c 100644
--- a/src/script/cpp_api/s_player.cpp
+++ b/src/script/cpp_api/s_player.cpp
@@ -77,8 +77,8 @@ bool ScriptApiPlayer::on_punchplayer(ServerActiveObject *player,
return readParam<bool>(L, -1);
}
-s16 ScriptApiPlayer::on_player_hpchange(ServerActiveObject *player,
- s16 hp_change, const PlayerHPChangeReason &reason)
+s32 ScriptApiPlayer::on_player_hpchange(ServerActiveObject *player,
+ s32 hp_change, const PlayerHPChangeReason &reason)
{
SCRIPTAPI_PRECHECKHEADER
diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h
index 764455a53..cf24ddc73 100644
--- a/src/script/cpp_api/s_player.h
+++ b/src/script/cpp_api/s_player.h
@@ -46,7 +46,7 @@ public:
bool on_punchplayer(ServerActiveObject *player, ServerActiveObject *hitter,
float time_from_last_punch, const ToolCapabilities *toolcap,
v3f dir, s16 damage);
- s16 on_player_hpchange(ServerActiveObject *player, s16 hp_change,
+ s32 on_player_hpchange(ServerActiveObject *player, s32 hp_change,
const PlayerHPChangeReason &reason);
void on_playerReceiveFields(ServerActiveObject *player,
const std::string &formname, const StringMap &fields);
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index e673778e9..9edb2f4f8 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -183,8 +183,8 @@ int ObjectRef::l_punch(lua_State *L)
ToolCapabilities toolcap = read_tool_capabilities(L, 4);
dir.normalize();
- s16 src_original_hp = co->getHP();
- s16 dst_origin_hp = puncher->getHP();
+ u16 src_original_hp = co->getHP();
+ u16 dst_origin_hp = puncher->getHP();
// Do it
co->punch(dir, &toolcap, puncher, time_from_last_punch);