mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Sound refactor and improvements (#12764)
This commit is contained in:
parent
8e1af25738
commit
edcbfa31c9
52 changed files with 2802 additions and 1211 deletions
|
@ -104,10 +104,10 @@ void read_item_definition(lua_State* L, int index,
|
|||
if (!lua_isnil(L, -1)) {
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
lua_getfield(L, -1, "place");
|
||||
read_soundspec(L, -1, def.sound_place);
|
||||
read_simplesoundspec(L, -1, def.sound_place);
|
||||
lua_pop(L, 1);
|
||||
lua_getfield(L, -1, "place_failed");
|
||||
read_soundspec(L, -1, def.sound_place_failed);
|
||||
read_simplesoundspec(L, -1, def.sound_place_failed);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
@ -117,10 +117,10 @@ void read_item_definition(lua_State* L, int index,
|
|||
if (!lua_isnil(L, -1)) {
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
lua_getfield(L, -1, "punch_use");
|
||||
read_soundspec(L, -1, def.sound_use);
|
||||
read_simplesoundspec(L, -1, def.sound_use);
|
||||
lua_pop(L, 1);
|
||||
lua_getfield(L, -1, "punch_use_air");
|
||||
read_soundspec(L, -1, def.sound_use_air);
|
||||
read_simplesoundspec(L, -1, def.sound_use_air);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
@ -187,9 +187,9 @@ void push_item_definition_full(lua_State *L, const ItemDefinition &i)
|
|||
}
|
||||
push_groups(L, i.groups);
|
||||
lua_setfield(L, -2, "groups");
|
||||
push_soundspec(L, i.sound_place);
|
||||
push_simplesoundspec(L, i.sound_place);
|
||||
lua_setfield(L, -2, "sound_place");
|
||||
push_soundspec(L, i.sound_place_failed);
|
||||
push_simplesoundspec(L, i.sound_place_failed);
|
||||
lua_setfield(L, -2, "sound_place_failed");
|
||||
lua_pushstring(L, i.node_placement_prediction.c_str());
|
||||
lua_setfield(L, -2, "node_placement_prediction");
|
||||
|
@ -821,13 +821,13 @@ void read_content_features(lua_State *L, ContentFeatures &f, int index)
|
|||
lua_getfield(L, index, "sounds");
|
||||
if(lua_istable(L, -1)){
|
||||
lua_getfield(L, -1, "footstep");
|
||||
read_soundspec(L, -1, f.sound_footstep);
|
||||
read_simplesoundspec(L, -1, f.sound_footstep);
|
||||
lua_pop(L, 1);
|
||||
lua_getfield(L, -1, "dig");
|
||||
read_soundspec(L, -1, f.sound_dig);
|
||||
read_simplesoundspec(L, -1, f.sound_dig);
|
||||
lua_pop(L, 1);
|
||||
lua_getfield(L, -1, "dug");
|
||||
read_soundspec(L, -1, f.sound_dug);
|
||||
read_simplesoundspec(L, -1, f.sound_dug);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
@ -965,11 +965,11 @@ void push_content_features(lua_State *L, const ContentFeatures &c)
|
|||
push_nodebox(L, c.collision_box);
|
||||
lua_setfield(L, -2, "collision_box");
|
||||
lua_newtable(L);
|
||||
push_soundspec(L, c.sound_footstep);
|
||||
push_simplesoundspec(L, c.sound_footstep);
|
||||
lua_setfield(L, -2, "sound_footstep");
|
||||
push_soundspec(L, c.sound_dig);
|
||||
push_simplesoundspec(L, c.sound_dig);
|
||||
lua_setfield(L, -2, "sound_dig");
|
||||
push_soundspec(L, c.sound_dug);
|
||||
push_simplesoundspec(L, c.sound_dug);
|
||||
lua_setfield(L, -2, "sound_dug");
|
||||
lua_setfield(L, -2, "sounds");
|
||||
lua_pushboolean(L, c.legacy_facedir_simple);
|
||||
|
@ -1067,10 +1067,11 @@ void read_server_sound_params(lua_State *L, int index,
|
|||
if(index < 0)
|
||||
index = lua_gettop(L) + 1 + index;
|
||||
|
||||
if(lua_istable(L, index)){
|
||||
if (lua_istable(L, index)) {
|
||||
// Functional overlap: this may modify SimpleSoundSpec contents
|
||||
getfloatfield(L, index, "fade", params.spec.fade);
|
||||
getfloatfield(L, index, "pitch", params.spec.pitch);
|
||||
getfloatfield(L, index, "start_time", params.spec.start_time);
|
||||
getboolfield(L, index, "loop", params.spec.loop);
|
||||
|
||||
getfloatfield(L, index, "gain", params.gain);
|
||||
|
@ -1101,7 +1102,7 @@ void read_server_sound_params(lua_State *L, int index,
|
|||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void read_soundspec(lua_State *L, int index, SimpleSoundSpec &spec)
|
||||
void read_simplesoundspec(lua_State *L, int index, SoundSpec &spec)
|
||||
{
|
||||
if(index < 0)
|
||||
index = lua_gettop(L) + 1 + index;
|
||||
|
@ -1118,7 +1119,7 @@ void read_soundspec(lua_State *L, int index, SimpleSoundSpec &spec)
|
|||
}
|
||||
}
|
||||
|
||||
void push_soundspec(lua_State *L, const SimpleSoundSpec &spec)
|
||||
void push_simplesoundspec(lua_State *L, const SoundSpec &spec)
|
||||
{
|
||||
lua_createtable(L, 0, 3);
|
||||
lua_pushstring(L, spec.name.c_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue