From d04fef0ded9d52ca3296fc6675475cdc7b77657d Mon Sep 17 00:00:00 2001 From: in1tiate Date: Wed, 10 Mar 2021 20:10:05 -0600 Subject: [PATCH] add currentmusic, define forcepos in aoclient.h --- include/aoclient.h | 4 ++++ include/area_data.h | 2 ++ src/commands.cpp | 18 ++++++++++++++++-- src/packets.cpp | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/aoclient.h b/include/aoclient.h index 76bc7e7..f65b737 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -198,6 +198,7 @@ class AOClient : public QObject { void cmdBgLock(int argc, QStringList argv); void cmdBgUnlock(int argc, QStringList argv); void cmdStatus(int argc, QStringList argv); + void cmdCurrentMusic(int argc, QStringList argv); // Moderation void cmdMods(int argc, QStringList argv); void cmdBan(int argc, QStringList argv); @@ -213,6 +214,7 @@ class AOClient : public QObject { void cmdTimer(int argc, QStringList argv); // Messaging/Client void cmdPos(int argc, QStringList argv); + void cmdForcePos(int argc, QStringList argv); void cmdSwitch(int argc, QStringList argv); void cmdRandomChar(int argc, QStringList argv); void cmdG(int argc, QStringList argv); @@ -280,6 +282,8 @@ class AOClient : public QObject { {"mods", {ACLFlags.value("NONE"), 0, &AOClient::cmdMods}}, {"help", {ACLFlags.value("NONE"), 0, &AOClient::cmdHelp}}, {"status", {ACLFlags.value("NONE"), 1, &AOClient::cmdStatus}}, + {"forcepos", {ACLFlags.value("CM"), 2, &AOClient::cmdForcePos}}, + {"currentmusic", {ACLFlags.value("NONE"), 0, &AOClient::cmdCurrentMusic}}, }; QString partial_packet; diff --git a/include/area_data.h b/include/area_data.h index f26311d..2ea154b 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -71,6 +71,8 @@ class AreaData : public QObject { QString document; int def_hp; int pro_hp; + QString current_music; + QString music_played_by; Logger* logger; }; diff --git a/src/commands.cpp b/src/commands.cpp index 103eb63..1f1151a 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -696,7 +696,11 @@ void AOClient::cmdArea(int argc, QStringList argv) void AOClient::cmdPlay(int argc, QStringList argv) { - sendPacket("MC", {argv.join(" "), QString::number(server->getCharID(current_char)), showname, "1", "0"}); + AreaData* area = server->areas[current_area]; + QString song = argv.join(" "); + area->current_music = song; + area->music_played_by = showname; + sendPacket("MC", {song, QString::number(server->getCharID(current_char)), showname, "1", "0"}); } void AOClient::cmdAreaKick(int argc, QStringList argv) @@ -777,7 +781,8 @@ void AOClient::cmdHelp(int argc, QStringList argv) sendServerMessage(entries.join("\n")); } -void AOClient::cmdStatus(int argc, QStringList argv) { +void AOClient::cmdStatus(int argc, QStringList argv) +{ AreaData* area = server->areas[current_area]; QString arg = argv[0].toLower(); if (arg == "idle") @@ -799,6 +804,15 @@ void AOClient::cmdStatus(int argc, QStringList argv) { arup(ARUPType::STATUS, true); } +void AOClient::cmdCurrentMusic(int argc, QStringList argv) +{ + AreaData* area = server->areas[current_area]; + if (area->current_music != "" && area->current_music != "~stop.mp3") // dummy track for stopping music + sendServerMessage("The current song is " + area->current_music + " played by " + area->music_played_by); + else + sendServerMessage("There is no music playing."); +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; diff --git a/src/packets.cpp b/src/packets.cpp index 5b952b7..bdc7adf 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -180,6 +180,8 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack if (song == argument) { // We have a song here AOPacket music_change("MC", {song, argv[1], argv[2], "1", "0", argv[3]}); + area->current_music = song; + area->music_played_by = argv[2]; server->broadcast(music_change, current_area); return; }