summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2015-10-24 12:28:35 +0200
committerBlockMen <nmuelll@web.de>2015-11-07 13:23:38 +0100
commit2a12579fab7803fdee2fac2fa8a6837f131dde7a (patch)
treefc4229b476b979d52d91d1a2f3f9ed6082f14328 /src
parent578649bd158a756adc966609f72444dc845355f0 (diff)
downloadminetest-2a12579fab7803fdee2fac2fa8a6837f131dde7a.tar.gz
minetest-2a12579fab7803fdee2fac2fa8a6837f131dde7a.tar.bz2
minetest-2a12579fab7803fdee2fac2fa8a6837f131dde7a.zip
Add support for audio feedback if placing node failed
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp6
-rw-r--r--src/itemdef.cpp12
-rw-r--r--src/itemdef.h1
-rw-r--r--src/script/common/c_content.cpp3
4 files changed, 18 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp
index d74c1fa1d..1738517b5 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -3682,8 +3682,12 @@ void Game::handlePointingAtNode(GameRunData *runData,
SimpleSoundSpec();
if (playeritem_def.node_placement_prediction == "" ||
- nodedef_manager->get(map.getNodeNoEx(nodepos)).rightclickable)
+ nodedef_manager->get(map.getNodeNoEx(nodepos)).rightclickable) {
client->interact(3, pointed); // Report to server
+ } else {
+ soundmaker->m_player_rightpunch_sound =
+ playeritem_def.sound_place_failed;
+ }
}
}
}
diff --git a/src/itemdef.cpp b/src/itemdef.cpp
index 2971d4e88..60a7dc64e 100644
--- a/src/itemdef.cpp
+++ b/src/itemdef.cpp
@@ -80,6 +80,7 @@ ItemDefinition& ItemDefinition::operator=(const ItemDefinition &def)
groups = def.groups;
node_placement_prediction = def.node_placement_prediction;
sound_place = def.sound_place;
+ sound_place_failed = def.sound_place_failed;
range = def.range;
return *this;
}
@@ -114,6 +115,7 @@ void ItemDefinition::reset()
}
groups.clear();
sound_place = SimpleSoundSpec();
+ sound_place_failed = SimpleSoundSpec();
range = -1;
node_placement_prediction = "";
@@ -155,8 +157,10 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
os<<serializeString(sound_place.name);
writeF1000(os, sound_place.gain);
}
- if(protocol_version > 20){
+ if (protocol_version > 20) {
writeF1000(os, range);
+ os << serializeString(sound_place_failed.name);
+ writeF1000(os, sound_place_failed.gain);
}
}
@@ -211,8 +215,10 @@ 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{
- }catch(SerializationError &e) {};
+ try {
+ sound_place_failed.name = deSerializeString(is);
+ sound_place_failed.gain = readF1000(is);
+ } catch(SerializationError &e) {};
}
/*
diff --git a/src/itemdef.h b/src/itemdef.h
index f993fdbac..805b4aa5d 100644
--- a/src/itemdef.h
+++ b/src/itemdef.h
@@ -68,6 +68,7 @@ struct ItemDefinition
ToolCapabilities *tool_capabilities;
ItemGroupList groups;
SimpleSoundSpec sound_place;
+ SimpleSoundSpec sound_place_failed;
f32 range;
// Client shall immediately place this node when player places the item.
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 787541ad0..fe429b5d4 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -100,6 +100,9 @@ ItemDefinition read_item_definition(lua_State* L,int index,
lua_getfield(L, -1, "place");
read_soundspec(L, -1, def.sound_place);
lua_pop(L, 1);
+ lua_getfield(L, -1, "place_failed");
+ read_soundspec(L, -1, def.sound_place_failed);
+ lua_pop(L, 1);
}
lua_pop(L, 1);