Add More Missing Sound Events
All checks were successful
minecraft-pi-reborn/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2021-09-13 17:06:04 -04:00
parent d18afddf1b
commit 6c791d6c9d
7 changed files with 63 additions and 20 deletions

View File

@ -1 +1 @@
2.2.1
2.2.2

View File

@ -1,5 +1,9 @@
# Changelog
**2.2.2**
* Add More Missing Sound Events
* Make Missing Sound Event Cause Warning Rather Than Crash
**2.2.1**
* Prevent `random.burp` Sound From Crashing Game
* Always Cleanup Media Layer, Even On Crash

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -2,6 +2,7 @@
#include <string>
#include <functional>
#include <cstdint>
#include <cstring>
#include <unistd.h>
#include <sys/mman.h>
#include <elf.h>

View File

@ -321,6 +321,30 @@ static std::unordered_map<std::string, std::vector<std::string>> repository = {
{
"PCM_burp"
}
},
{
"random.fizz",
{
"PCM_fizz"
}
},
{
"random.drink",
{
"PCM_drink"
}
},
{
"random.chestopen",
{
"PCM_chestopen"
}
},
{
"random.chestclosed",
{
"PCM_chestclosed"
}
}
}
};
@ -337,7 +361,8 @@ std::string _sound_pick(std::string sound) {
return options[rand() % options.size()];
} else {
// Invalid Sound
ERR("Invalid Sound: %s", sound.c_str());
WARN("Invalid Sound Event: %s", sound.c_str());
return "";
}
}

View File

@ -62,17 +62,18 @@ std::string _sound_get_source_file() {
// Play Sound
// The pitch value is unsued because it causes glitchy sounds, it is seemingly unused in MCPE as well.
static void SoundEngine_playUI_injection(__attribute__((unused)) unsigned char *sound_engine, std::string const& name, __attribute__((unused)) float pitch, float volume) {
static void play(std::string name, float x, float y, float z, float volume, bool is_ui) {
std::string source = _sound_get_source_file();
if (source.size() > 0) {
media_audio_play(source.c_str(), _sound_pick(name).c_str(), 0.0f, 0.0f, 0.0f, 1.0f, volume, 1);
std::string resolved_name = _sound_pick(name);
if (source.size() > 0 && resolved_name.size() > 0) {
media_audio_play(source.c_str(), resolved_name.c_str(), x, y, z, 1.0f, volume, is_ui);
}
}
static void SoundEngine_playUI_injection(__attribute__((unused)) unsigned char *sound_engine, std::string const& name, __attribute__((unused)) float pitch, float volume) {
play(name, 0, 0, 0, volume, true);
}
static void SoundEngine_play_injection(__attribute__((unused)) unsigned char *sound_engine, std::string const& name, float x, float y, float z, __attribute__((unused)) float pitch, float volume) {
std::string source = _sound_get_source_file();
if (source.size() > 0) {
media_audio_play(source.c_str(), _sound_pick(name).c_str(), x, y, z, 1.0f, volume, 0);
}
play(name, x, y, z, volume, false);
}
// Refresh Data

View File

@ -164,6 +164,14 @@ static void *LoginPacket_read_vtable_addr = (void *) 0x108dcc;
static uint32_t LoginPacket_username_property_offset = 0xc; // RakString
// StartGamePacket
typedef void (*StartGamePacket_read_t)(unsigned char *packet, unsigned char *bit_stream);
static StartGamePacket_read_t StartGamePacket_read = (StartGamePacket_read_t) 0x72c58;
static void *StartGamePacket_read_vtable_addr = (void *) 0x109264;
static uint32_t StartGamePacket_game_mode_property_offset = 0x14; // int32_t
// ChatPacket
static uint32_t ChatPacket_message_property_offset = 0xc; // char *
@ -206,17 +214,6 @@ typedef ItemInstance *(*ItemInstance_constructor_extra_t)(ItemInstance *item_ins
static ItemInstance_constructor_extra_t ItemInstance_constructor_tile_extra = (ItemInstance_constructor_extra_t) 0x99918;
static ItemInstance_constructor_extra_t ItemInstance_constructor_item_extra = (ItemInstance_constructor_extra_t) 0x99960;
// Player
typedef int (*Player_isUsingItem_t)(unsigned char *player);
static Player_isUsingItem_t Player_isUsingItem = (Player_isUsingItem_t) 0x8f15c;
typedef void (*Player_drop_t)(unsigned char *player, ItemInstance *item_instance, bool is_death);
static uint32_t Player_drop_vtable_offset = 0x208;
static uint32_t Player_username_property_offset = 0xbf4; // char *
static uint32_t Player_inventory_property_offset = 0xbe0; // Inventory *
// Entity
typedef void (*Entity_die_t)(unsigned char *entity, unsigned char *cause);
@ -237,8 +234,23 @@ typedef void (*Mob_actuallyHurt_t)(unsigned char *entity, int32_t damage);
static Mob_actuallyHurt_t Mob_actuallyHurt = (Mob_actuallyHurt_t) 0x7f11c;
static uint32_t Mob_actuallyHurt_vtable_offset = 0x16c;
typedef float (*Mob_getWalkingSpeedModifier_t)(unsigned char *entity);
static uint32_t Mob_health_property_offset = 0xec; // int32_t
// Player
typedef int (*Player_isUsingItem_t)(unsigned char *player);
static Player_isUsingItem_t Player_isUsingItem = (Player_isUsingItem_t) 0x8f15c;
typedef void (*Player_drop_t)(unsigned char *player, ItemInstance *item_instance, bool is_death);
static uint32_t Player_drop_vtable_offset = 0x208;
static Mob_getWalkingSpeedModifier_t Player_getWalkingSpeed = (Mob_getWalkingSpeedModifier_t) 0x8ea0c;
static uint32_t Player_username_property_offset = 0xbf4; // char *
static uint32_t Player_inventory_property_offset = 0xbe0; // Inventory *
// LocalPlayer
static Mob_actuallyHurt_t LocalPlayer_actuallyHurt = (Mob_actuallyHurt_t) 0x44010;