Files
Shiip-of-Hakinian-Espanol/soh/soh/Network/Anchor/Packets/PlayerSfx.cpp
Garrett Cox 060878fb2e Anchor (#4910)
This is far and away the proudest thing I have been apart of in the Zelda community. Thank you to everyone who either directly or indirectly contributed to this effort. If I forgot to co-author you and you were involved, know that I simply forgot but still appreciated your help! Also thank you to the literal tens of thousands of people who have played Anchor, providing feedback and bug reports. Super thrilled to finally have this merged into the main Ship of Harkinian experience.

Co-authored-by: mattman107 <65982675+mattman107@users.noreply.github.com>
Co-authored-by: David Chavez <david@dcvz.io>
Co-authored-by: MelonSpeedruns <melonspeedruns@outlook.com>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: Malkierian <malkierian@gmail.com>
Co-authored-by: Caladius <Caladius@users.noreply.github.com>
Co-authored-by: Patrick12115 <115201185+Patrick12115@users.noreply.github.com>
Co-authored-by: PurpleHato <47987542+PurpleHato@users.noreply.github.com>
Co-authored-by: balloondude2 <55861555+balloondude2@users.noreply.github.com>
Co-authored-by: lilacLunatic <8488221+lilacLunatic@users.noreply.github.com>
Co-authored-by: Felix Lee <flee135@users.noreply.github.com>
Co-authored-by: Sirius902 <10891979+Sirius902@users.noreply.github.com>
2025-11-14 11:04:09 -07:00

48 lines
1.2 KiB
C++

#include "soh/Network/Anchor/Anchor.h"
#include "soh/Network/Anchor/JsonConversions.hpp"
#include <nlohmann/json.hpp>
#include <libultraship/libultraship.h>
extern "C" {
#include "macros.h"
#include "functions.h"
#include "variables.h"
extern PlayState* gPlayState;
}
/**
* PLAYER_SFX
*
* Sound effects, only sent to other clients in the same scene as the player
*/
void Anchor::SendPacket_PlayerSfx(u16 sfxId) {
if (!IsSaveLoaded()) {
return;
}
nlohmann::json payload;
payload["type"] = PLAYER_SFX;
payload["sfxId"] = sfxId;
payload["quiet"] = true;
for (auto& [clientId, client] : clients) {
if (client.sceneNum == gPlayState->sceneNum && client.online && client.isSaveLoaded && !client.self) {
payload["targetClientId"] = clientId;
SendJsonToRemote(payload);
}
}
}
void Anchor::HandlePacket_PlayerSfx(nlohmann::json payload) {
uint32_t clientId = payload["clientId"].get<uint32_t>();
u16 sfxId = payload["sfxId"].get<u16>();
if (!clients.contains(clientId) || !clients[clientId].player) {
return;
}
Player_PlaySfx((Actor*)clients[clientId].player, sfxId);
}