From c1bf6f9f7a6d2c5bd743422593a5ec72939bc6af Mon Sep 17 00:00:00 2001 From: Zeg9 Date: Thu, 27 Dec 2012 14:22:59 +0100 Subject: Fix camera "jumping" when attached and the parent goes too fast --- src/content_cao.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/content_cao.cpp') diff --git a/src/content_cao.cpp b/src/content_cao.cpp index ee1009b6c..84fc0bf79 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1129,6 +1129,7 @@ public: { LocalPlayer *player = m_env->getLocalPlayer(); player->overridePosition = getParent()->getPosition(); + m_env->getLocalPlayer()->parent = getParent(); } } else -- cgit v1.2.3 From c5a8448c41e4ea9d33a43cebef61425d4568a46d Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Fri, 5 Apr 2013 01:03:28 -1000 Subject: Allow modifying movement speed, jump height and gravity per-player via the Lua API. --- doc/lua_api.txt | 4 ++++ src/clientserver.h | 4 +++- src/content_cao.cpp | 13 +++++++++++++ src/content_sao.cpp | 17 +++++++++++++++-- src/content_sao.h | 9 ++++++--- src/environment.cpp | 2 +- src/genericobject.cpp | 12 ++++++++++++ src/genericobject.h | 3 +++ src/localplayer.cpp | 6 +++--- src/player.cpp | 5 +++++ src/player.h | 4 ++++ src/scriptapi_object.cpp | 23 +++++++++++++++++++++++ src/scriptapi_object.h | 3 +++ src/serverobject.h | 2 ++ 14 files changed, 97 insertions(+), 10 deletions(-) (limited to 'src/content_cao.cpp') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 029c84d03..a61ffce64 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1348,6 +1348,10 @@ Player-only: (no-op for other objects) {jump=bool,right=bool,left=bool,LMB=bool,RMB=bool,sneak=bool,aux1=bool,down=bool,up=bool} - get_player_control_bits(): returns integer with bit packed player pressed keys bit nr/meaning: 0/up ,1/down ,2/left ,3/right ,4/jump ,5/aux1 ,6/sneak ,7/LMB ,8/RMB +- set_physics_override(speed, jump, gravity) + modifies per-player walking speed, jump height, and gravity. + Values default to 1 and act as offsets to the physics settings + in minetest.conf. nil will keep the current setting. InvRef: Reference to an inventory methods: diff --git a/src/clientserver.h b/src/clientserver.h index 28b579971..8b1e0a7e4 100644 --- a/src/clientserver.h +++ b/src/clientserver.h @@ -88,9 +88,11 @@ SharedBuffer makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed); PROTOCOL_VERSION 18: damageGroups added to ToolCapabilities sound_place added to ItemDefinition + PROTOCOL_VERSION 19: + GENERIC_CMD_SET_PHYSICS_OVERRIDE */ -#define LATEST_PROTOCOL_VERSION 18 +#define LATEST_PROTOCOL_VERSION 19 // Server's supported network protocol range #define SERVER_PROTOCOL_VERSION_MIN 13 diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 84fc0bf79..0a1a92271 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1679,6 +1679,19 @@ public: updateTexturePos(); } + else if(cmd == GENERIC_CMD_SET_PHYSICS_OVERRIDE) + { + float override_speed = readF1000(is); + float override_jump = readF1000(is); + float override_gravity = readF1000(is); + if(m_is_local_player) + { + LocalPlayer *player = m_env->getLocalPlayer(); + player->physics_override_speed = override_speed; + player->physics_override_jump = override_jump; + player->physics_override_gravity = override_gravity; + } + } else if(cmd == GENERIC_CMD_SET_ANIMATION) { m_animation_range = readV2F1000(is); diff --git a/src/content_sao.cpp b/src/content_sao.cpp index ae08b4260..e6c8c725c 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -935,7 +935,11 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_, m_moved(false), m_inventory_not_sent(false), m_hp_not_sent(false), - m_wielded_item_not_sent(false) + m_wielded_item_not_sent(false), + m_physics_override_speed(1), + m_physics_override_jump(1), + m_physics_override_gravity(1), + m_physics_override_sent(false) { assert(m_player); assert(m_peer_id != 0); @@ -1019,7 +1023,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version) writeF1000(os, m_player->getYaw()); writeS16(os, getHP()); - writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here + writeU8(os, 5 + m_bone_position.size()); // number of messages stuffed in here os<getSpeed(); if(lplayer->in_liquid == false) - speed.Y -= lplayer->movement_gravity * dtime_part * 2; + speed.Y -= lplayer->movement_gravity * lplayer->physics_override_gravity * dtime_part * 2; // Liquid floating / sinking if(lplayer->in_liquid && !lplayer->swimming_vertical) diff --git a/src/genericobject.cpp b/src/genericobject.cpp index f7b272b00..e2fbde838 100644 --- a/src/genericobject.cpp +++ b/src/genericobject.cpp @@ -117,6 +117,18 @@ std::string gob_cmd_update_armor_groups(const ItemGroupList &armor_groups) return os.str(); } +std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump, float physics_override_gravity) +{ + std::ostringstream os(std::ios::binary); + // command + writeU8(os, GENERIC_CMD_SET_PHYSICS_OVERRIDE); + // parameters + writeF1000(os, physics_override_speed); + writeF1000(os, physics_override_jump); + writeF1000(os, physics_override_gravity); + return os.str(); +} + std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend) { std::ostringstream os(std::ios::binary); diff --git a/src/genericobject.h b/src/genericobject.h index 9a21baa67..276865ab9 100644 --- a/src/genericobject.h +++ b/src/genericobject.h @@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define GENERIC_CMD_SET_ANIMATION 6 #define GENERIC_CMD_SET_BONE_POSITION 7 #define GENERIC_CMD_SET_ATTACHMENT 8 +#define GENERIC_CMD_SET_PHYSICS_OVERRIDE 9 #include "object_properties.h" std::string gob_cmd_set_properties(const ObjectProperties &prop); @@ -62,6 +63,8 @@ std::string gob_cmd_punched(s16 damage, s16 result_hp); #include "itemgroup.h" std::string gob_cmd_update_armor_groups(const ItemGroupList &armor_groups); +std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump, float physics_override_gravity); + std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend); std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a90ae6967..b69bdb24f 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -529,7 +529,7 @@ void LocalPlayer::applyControl(float dtime) v3f speedJ = getSpeed(); if(speedJ.Y >= -0.5 * BS) { - speedJ.Y = movement_speed_jump; + speedJ.Y = movement_speed_jump * physics_override_jump; setSpeed(speedJ); MtEvent *e = new SimpleTriggerEvent("PlayerJump"); @@ -584,8 +584,8 @@ void LocalPlayer::applyControl(float dtime) incH = incV = movement_acceleration_default * BS * dtime; // Accelerate to target speed with maximum increment - accelerateHorizontal(speedH, incH); - accelerateVertical(speedV, incV); + accelerateHorizontal(speedH * physics_override_speed, incH * physics_override_speed); + accelerateVertical(speedV * physics_override_speed, incV * physics_override_speed); } v3s16 LocalPlayer::getStandingNodePos() diff --git a/src/player.cpp b/src/player.cpp index 4c81887be..1ca9423b0 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -71,6 +71,11 @@ Player::Player(IGameDef *gamedef): movement_liquid_fluidity_smooth = 0.5 * BS; movement_liquid_sink = 10 * BS; movement_gravity = 9.81 * BS; + + // Movement overrides are multipliers and must be 1 by default + physics_override_speed = 1; + physics_override_jump = 1; + physics_override_gravity = 1; } Player::~Player() diff --git a/src/player.h b/src/player.h index 496c99532..d95e535ff 100644 --- a/src/player.h +++ b/src/player.h @@ -222,6 +222,10 @@ public: f32 movement_liquid_sink; f32 movement_gravity; + float physics_override_speed; + float physics_override_jump; + float physics_override_gravity; + u16 hp; float hurt_tilt_timer; diff --git a/src/scriptapi_object.cpp b/src/scriptapi_object.cpp index a0f93cbba..05433a598 100644 --- a/src/scriptapi_object.cpp +++ b/src/scriptapi_object.cpp @@ -297,6 +297,28 @@ int ObjectRef::l_set_armor_groups(lua_State *L) return 0; } +// set_physics_override(self, physics_override_speed, physics_override_jump, physics_override_gravity) +int ObjectRef::l_set_physics_override(lua_State *L) +{ + ObjectRef *ref = checkobject(L, 1); + PlayerSAO *co = (PlayerSAO *) getobject(ref); + if(co == NULL) return 0; + // Do it + if(!lua_isnil(L, 2)){ + co->m_physics_override_speed = lua_tonumber(L, 2); + co->m_physics_override_sent = false; + } + if(!lua_isnil(L, 3)){ + co->m_physics_override_jump = lua_tonumber(L, 3); + co->m_physics_override_sent = false; + } + if(!lua_isnil(L, 4)){ + co->m_physics_override_gravity = lua_tonumber(L, 4); + co->m_physics_override_sent = false; + } + return 0; +} + // set_animation(self, frame_range, frame_speed, frame_blend) int ObjectRef::l_set_animation(lua_State *L) { @@ -756,6 +778,7 @@ const luaL_reg ObjectRef::methods[] = { luamethod(ObjectRef, get_wielded_item), luamethod(ObjectRef, set_wielded_item), luamethod(ObjectRef, set_armor_groups), + luamethod(ObjectRef, set_physics_override), luamethod(ObjectRef, set_animation), luamethod(ObjectRef, set_bone_position), luamethod(ObjectRef, set_attach), diff --git a/src/scriptapi_object.h b/src/scriptapi_object.h index a37abbb78..a44016933 100644 --- a/src/scriptapi_object.h +++ b/src/scriptapi_object.h @@ -103,6 +103,9 @@ private: // set_armor_groups(self, groups) static int l_set_armor_groups(lua_State *L); + // set_physics_override(self, physics_override_speed, physics_override_jump, physics_override_gravity) + static int l_set_physics_override(lua_State *L); + // set_animation(self, frame_range, frame_speed, frame_blend) static int l_set_animation(lua_State *L); diff --git a/src/serverobject.h b/src/serverobject.h index 7a5b47bd1..13a075a25 100644 --- a/src/serverobject.h +++ b/src/serverobject.h @@ -152,6 +152,8 @@ public: virtual void setArmorGroups(const ItemGroupList &armor_groups) {} + virtual void setPhysicsOverride(float physics_override_speed, float physics_override_jump, float physics_override_gravity) + {} virtual void setAnimation(v2f frames, float frame_speed, float frame_blend) {} virtual void setBonePosition(std::string bone, v3f position, v3f rotation) -- cgit v1.2.3 From b0e68060777dfb7daefc81c169e1ed4d95c4a2d6 Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Mon, 25 Mar 2013 19:13:25 +0100 Subject: Fix nick completion --- src/chat.cpp | 8 ++++---- src/chat.h | 2 +- src/client.cpp | 13 ++----------- src/client.h | 2 +- src/content_cao.cpp | 4 ++++ src/environment.h | 8 ++++++++ src/guiChatConsole.cpp | 2 +- 7 files changed, 21 insertions(+), 18 deletions(-) (limited to 'src/content_cao.cpp') diff --git a/src/chat.cpp b/src/chat.cpp index 1135ccdf7..3102e194a 100644 --- a/src/chat.cpp +++ b/src/chat.cpp @@ -464,7 +464,7 @@ void ChatPrompt::historyNext() } } -void ChatPrompt::nickCompletion(const std::list& names, bool backwards) +void ChatPrompt::nickCompletion(const std::list& names, bool backwards) { // Two cases: // (a) m_nick_completion_start == m_nick_completion_end == 0 @@ -493,13 +493,13 @@ void ChatPrompt::nickCompletion(const std::list& names, bool backw // find all names that start with the selected prefix std::vector completions; - for (std::list::const_iterator + for (std::list::const_iterator i = names.begin(); i != names.end(); ++i) { - if (str_starts_with(*i, prefix, true)) + if (str_starts_with(narrow_to_wide(*i), prefix, true)) { - std::wstring completion = *i; + std::wstring completion = narrow_to_wide(*i); if (prefix_start == 0) completion += L":"; completions.push_back(completion); diff --git a/src/chat.h b/src/chat.h index 8a40c7ccf..19b48456e 100644 --- a/src/chat.h +++ b/src/chat.h @@ -160,7 +160,7 @@ public: void historyNext(); // Nick completion - void nickCompletion(const std::list& names, bool backwards); + void nickCompletion(const std::list& names, bool backwards); // Update console size and reformat the visible portion of the prompt void reformat(u32 cols); diff --git a/src/client.cpp b/src/client.cpp index f27f95d98..1d5f8f472 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2501,18 +2501,9 @@ void Client::printDebugInfo(std::ostream &os) < Client::getConnectedPlayerNames() +std::list Client::getConnectedPlayerNames() { - std::list players = m_env.getPlayers(true); - std::list playerNames; - for(std::list::iterator - i = players.begin(); - i != players.end(); ++i) - { - Player *player = *i; - playerNames.push_back(narrow_to_wide(player->getName())); - } - return playerNames; + return m_env.getPlayerNames(); } float Client::getAnimationTime() diff --git a/src/client.h b/src/client.h index d476a1d51..16cdc237f 100644 --- a/src/client.h +++ b/src/client.h @@ -315,7 +315,7 @@ public: // Prints a line or two of info void printDebugInfo(std::ostream &os); - std::list getConnectedPlayerNames(); + std::list getConnectedPlayerNames(); float getAnimationTime(); diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 0a1a92271..8bec67c8c 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -708,11 +708,15 @@ public: if(player && player->isLocal()){ m_is_local_player = true; } + m_env->addPlayerName(m_name.c_str()); } } ~GenericCAO() { + if(m_is_player){ + m_env->removePlayerName(m_name.c_str()); + } } static ClientActiveObject* create(IGameDef *gamedef, ClientEnvironment *env) diff --git a/src/environment.h b/src/environment.h index 02301e5d3..7f73a5461 100644 --- a/src/environment.h +++ b/src/environment.h @@ -470,6 +470,13 @@ public: ClientEnvEvent getClientEvent(); std::vector > attachment_list; // X is child ID, Y is parent ID + + std::list getPlayerNames() + { return m_player_names; } + void addPlayerName(std::string name) + { m_player_names.push_back(name); } + void removePlayerName(std::string name) + { m_player_names.remove(name); } private: ClientMap *m_map; @@ -482,6 +489,7 @@ private: Queue m_client_event_queue; IntervalLimiter m_active_object_light_update_interval; IntervalLimiter m_lava_hurt_interval; + std::list m_player_names; }; #endif diff --git a/src/guiChatConsole.cpp b/src/guiChatConsole.cpp index 5fc576cf8..ec23648f8 100644 --- a/src/guiChatConsole.cpp +++ b/src/guiChatConsole.cpp @@ -535,7 +535,7 @@ bool GUIChatConsole::OnEvent(const SEvent& event) { // Tab or Shift-Tab pressed // Nick completion - std::list names = m_client->getConnectedPlayerNames(); + std::list names = m_client->getConnectedPlayerNames(); bool backwards = event.KeyInput.Shift; m_chat_backend->getPrompt().nickCompletion(names, backwards); return true; -- cgit v1.2.3 From 1586cdac53935cd4735162ad8337c269f0dfa718 Mon Sep 17 00:00:00 2001 From: khonkhortisan Date: Tue, 19 Mar 2013 11:05:32 -0700 Subject: unkn own block -> unkn own node --- builtin/misc_register.lua | 8 ++++---- games/minimal/mods/experimental/init.lua | 4 ++-- src/content_cao.cpp | 6 +++--- src/game.cpp | 2 +- src/nodedef.cpp | 2 +- textures/base/pack/unknown_block.png | Bin 582 -> 0 bytes textures/base/pack/unknown_node.png | Bin 0 -> 608 bytes 7 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 textures/base/pack/unknown_block.png create mode 100644 textures/base/pack/unknown_node.png (limited to 'src/content_cao.cpp') diff --git a/builtin/misc_register.lua b/builtin/misc_register.lua index d1e28fdab..4041fb9e2 100644 --- a/builtin/misc_register.lua +++ b/builtin/misc_register.lua @@ -253,8 +253,8 @@ minetest.register_item(":unknown", { minetest.register_node(":air", { description = "Air (you hacker you!)", - inventory_image = "unknown_block.png", - wield_image = "unknown_block.png", + inventory_image = "unknown_node.png", + wield_image = "unknown_node.png", drawtype = "airlike", paramtype = "light", sunlight_propagates = true, @@ -269,8 +269,8 @@ minetest.register_node(":air", { minetest.register_node(":ignore", { description = "Ignore (you hacker you!)", - inventory_image = "unknown_block.png", - wield_image = "unknown_block.png", + inventory_image = "unknown_node.png", + wield_image = "unknown_node.png", drawtype = "airlike", paramtype = "none", sunlight_propagates = false, diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua index 2edfd0f67..6fce9698a 100644 --- a/games/minimal/mods/experimental/init.lua +++ b/games/minimal/mods/experimental/init.lua @@ -28,10 +28,10 @@ minetest.after(1.0, switch_player_visual) ]] minetest.register_node("experimental:soundblock", { - tile_images = {"unknown_block.png", "default_tnt_bottom.png", + tile_images = {"unknown_node.png", "default_tnt_bottom.png", "default_tnt_side.png", "default_tnt_side.png", "default_tnt_side.png", "default_tnt_side.png"}, - inventory_image = minetest.inventorycube("unknown_block.png", + inventory_image = minetest.inventorycube("unknown_node.png", "default_tnt_side.png", "default_tnt_side.png"), groups = {dig_immediate=3}, }) diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 8bec67c8c..9738dc34c 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -864,7 +864,7 @@ public: m_spritenode = smgr->addBillboardSceneNode( NULL, v2f(1, 1), v3f(0,0,0), -1); m_spritenode->setMaterialTexture(0, - tsrc->getTextureRaw("unknown_block.png")); + tsrc->getTextureRaw("unknown_node.png")); m_spritenode->setMaterialFlag(video::EMF_LIGHTING, false); m_spritenode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); @@ -1268,7 +1268,7 @@ public: { if(m_prop.visual == "sprite") { - std::string texturestring = "unknown_block.png"; + std::string texturestring = "unknown_node.png"; if(m_prop.textures.size() >= 1) texturestring = m_prop.textures[0]; texturestring += mod; @@ -1334,7 +1334,7 @@ public: { for (u32 i = 0; i < 6; ++i) { - std::string texturestring = "unknown_block.png"; + std::string texturestring = "unknown_node.png"; if(m_prop.textures.size() > i) texturestring = m_prop.textures[i]; texturestring += mod; diff --git a/src/game.cpp b/src/game.cpp index 5e4e06148..65feb50bf 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2388,7 +2388,7 @@ void the_game( infotext = narrow_to_wide(meta->getString("infotext")); } else { MapNode n = map.getNode(nodepos); - if(nodedef->get(n).tiledef[0].name == "unknown_block.png"){ + if(nodedef->get(n).tiledef[0].name == "unknown_node.png"){ infotext = L"Unknown node: "; infotext += narrow_to_wide(nodedef->get(n).name); } diff --git a/src/nodedef.cpp b/src/nodedef.cpp index ca8898907..e2b72333f 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -593,7 +593,7 @@ public: { tiledef[j] = f->tiledef[j]; if(tiledef[j].name == "") - tiledef[j].name = "unknown_block.png"; + tiledef[j].name = "unknown_node.png"; } bool is_liquid = false; diff --git a/textures/base/pack/unknown_block.png b/textures/base/pack/unknown_block.png deleted file mode 100644 index a27cb8ca9..000000000 Binary files a/textures/base/pack/unknown_block.png and /dev/null differ diff --git a/textures/base/pack/unknown_node.png b/textures/base/pack/unknown_node.png new file mode 100644 index 000000000..9cae26d5c Binary files /dev/null and b/textures/base/pack/unknown_node.png differ -- cgit v1.2.3