diff options
author | PilzAdam <pilzadam@minetest.net> | 2013-07-20 14:50:19 +0200 |
---|---|---|
committer | RealBadAngel <mk@realbadangel.pl> | 2013-07-20 20:37:59 +0200 |
commit | cba90d4441bd2e81efb262e663e9c53c24322a54 (patch) | |
tree | 24675eb4f1bab2b2cfcb15eab63c2e72f9089450 /src | |
parent | d19c8b815dc137ea4c19e5f5a54c40693059b455 (diff) | |
download | minetest-cba90d4441bd2e81efb262e663e9c53c24322a54.tar.gz minetest-cba90d4441bd2e81efb262e663e9c53c24322a54.tar.bz2 minetest-cba90d4441bd2e81efb262e663e9c53c24322a54.zip |
Make range of tools configureable
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 7 | ||||
-rw-r--r-- | src/itemdef.cpp | 5 | ||||
-rw-r--r-- | src/itemdef.h | 1 | ||||
-rw-r--r-- | src/script/common/c_content.cpp | 2 |
4 files changed, 13 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp index ff694d12e..3f14f09d4 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2488,7 +2488,12 @@ void the_game( //u32 t1 = device->getTimer()->getRealTime(); - f32 d = 4; // max. distance + f32 d = playeritem_def.range; // max. distance + f32 d_hand = itemdef->get("").range; + if(d < 0 && d_hand >= 0) + d = d_hand; + else if(d < 0) + d = 4.0; core::line3d<f32> shootline(camera_position, camera_position + camera_direction * BS * (d+1)); diff --git a/src/itemdef.cpp b/src/itemdef.cpp index e7498ce55..4ac23d0fc 100644 --- a/src/itemdef.cpp +++ b/src/itemdef.cpp @@ -76,6 +76,7 @@ ItemDefinition& ItemDefinition::operator=(const ItemDefinition &def) groups = def.groups; node_placement_prediction = def.node_placement_prediction; sound_place = def.sound_place; + range = def.range; return *this; } @@ -109,6 +110,7 @@ void ItemDefinition::reset() } groups.clear(); sound_place = SimpleSoundSpec(); + range = -1; node_placement_prediction = ""; } @@ -146,6 +148,7 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const //serializeSimpleSoundSpec(sound_place, os); os<<serializeString(sound_place.name); writeF1000(os, sound_place.gain); + writeF1000(os, range); } } @@ -198,7 +201,7 @@ void ItemDefinition::deSerialize(std::istream &is) // If you add anything here, insert it primarily inside the try-catch // block to not need to increase the version. try{ - + range = readF1000(is); }catch(SerializationError &e) {}; } diff --git a/src/itemdef.h b/src/itemdef.h index 08c9c8358..f993fdbac 100644 --- a/src/itemdef.h +++ b/src/itemdef.h @@ -68,6 +68,7 @@ struct ItemDefinition ToolCapabilities *tool_capabilities; ItemGroupList groups; SimpleSoundSpec sound_place; + f32 range; // Client shall immediately place this node when player places the item. // Server will update the precise end result a moment later. diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 11f749160..7b80cc5ee 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -100,6 +100,8 @@ ItemDefinition read_item_definition(lua_State* L,int index, } lua_pop(L, 1); + def.range = getfloatfield_default(L, index, "range", def.range); + // Client shall immediately place this node when player places the item. // Server will update the precise end result a moment later. // "" = no prediction |