Add sendServerMessageArea and sendServerBroadcast

+ Update some prior created commands to use them
+ Change style of global messages
+ Change style of need messages
+ Pretend to fix some formatting since I don't understand indentation
This commit is contained in:
Salanto 2021-01-20 14:49:07 +01:00
parent f43e360c86
commit 2422287753
3 changed files with 37 additions and 15 deletions

View File

@ -88,6 +88,8 @@ class AOClient : public QObject {
void arup(ARUPType type, bool broadcast); void arup(ARUPType type, bool broadcast);
void fullArup(); void fullArup();
void sendServerMessage(QString message); void sendServerMessage(QString message);
void sendServerMessageArea(QString message);
void sendServerBroadcast(QString message);
bool checkAuth(unsigned long long acl_mask); bool checkAuth(unsigned long long acl_mask);
// Packet headers // Packet headers

View File

@ -216,7 +216,26 @@ void AOClient::setHwid(QString p_hwid)
void AOClient::sendServerMessage(QString message) void AOClient::sendServerMessage(QString message)
{ {
sendPacket("CT", {"Server", message, "1"}); QSettings config("config/config.ini", QSettings::IniFormat);
config.beginGroup("Options");
QString hostname = config.value("hostname", "Server").toString();
sendPacket("CT", {hostname, message, "1"});
}
void AOClient::sendServerMessageArea(QString message)
{
QSettings config("config/config.ini", QSettings::IniFormat);
config.beginGroup("Options");
QString hostname = config.value("hostname", "Server").toString();
server->broadcast(AOPacket("CT", {hostname, message, "1"}), current_area);
}
void AOClient::sendServerBroadcast(QString message)
{
QSettings config("config/config.ini", QSettings::IniFormat);
config.beginGroup("Options");
QString hostname = config.value("hostname", "Server").toString();
server->broadcast(AOPacket("CT", {hostname, message, "1"}));
} }
bool AOClient::checkAuth(unsigned long long acl_mask) bool AOClient::checkAuth(unsigned long long acl_mask)

View File

@ -374,8 +374,9 @@ void AOClient::cmdPos(int argc, QStringList argv)
void AOClient::cmdG(int argc, QStringList argv) void AOClient::cmdG(int argc, QStringList argv)
{ {
QString sender_name = ooc_name; QString sender_name = ooc_name;
QString sender_area = server->area_names.value(current_area);
QString sender_message = argv.join(" "); QString sender_message = argv.join(" ");
server->broadcast(AOPacket("CT", {"[G]" + sender_name, sender_message+ "."})); server->broadcast(AOPacket("CT", {"[" + sender_area + "]" + sender_name, sender_message}));
return; return;
} }
@ -383,7 +384,7 @@ void AOClient::cmdNeed(int argc, QStringList argv)
{ {
QString sender_area = server->area_names.value(current_area); QString sender_area = server->area_names.value(current_area);
QString sender_message = argv.join(" "); QString sender_message = argv.join(" ");
server->broadcast(AOPacket("CT", {"=== Advert ===","[" + sender_area + "] needs " + sender_message+ "."})); sendServerBroadcast({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."});
} }
void AOClient::cmdFlip(int argc, QStringList argv) void AOClient::cmdFlip(int argc, QStringList argv)
@ -403,15 +404,15 @@ void AOClient::cmdRoll(int argc, QStringList argv)
if (argc == 0) if (argc == 0)
{ {
QString dice_result = QString::number(AOClient::genRand(1, 6)); QString dice_result = QString::number(AOClient::genRand(1, 6));
server->broadcast(AOPacket("CT",{"Roll",sender_name + " rolled " + dice_result + " out of 6"}), current_area); sendServerMessageArea(sender_name + " rolled " + dice_result + " out of 6");
} }
else if (argc == 1) else if (argc == 1)
{ {
int amount_faces = argv[0].toInt(); int amount_faces = argv[0].toInt();
if (1 <= amount_faces and amount_faces <= max_roll_faces) if (1 <= amount_faces and amount_faces <= max_roll_faces)
{ {
QString dice_result = QString::number(AOClient::genRand(1, amount_faces)); QString dice_result = QString::number(AOClient::genRand(1, amount_faces));
server->broadcast(AOPacket("CT",{"Roll",sender_name + " rolled " + dice_result + " out of " + argv[0]}), current_area); sendServerMessageArea(sender_name + " rolled " + dice_result + " out of " + argv[0]);
} }
else else
{ {
@ -434,10 +435,10 @@ void AOClient::cmdRoll(int argc, QStringList argv)
} }
else else
{ {
dice_results = dice_results.append(dice_result + ","); dice_results = dice_results.append(dice_result + ",");
} }
} }
server->broadcast(AOPacket("CT",{"Roll",sender_name + " rolled (" + dice_results + ") out of " + argv[0]}), current_area); sendServerMessageArea(sender_name + " rolled (" + dice_results + ") out of " + argv[0]);
} }
else else
{ {
@ -456,16 +457,16 @@ void AOClient::cmdRollP(int argc, QStringList argv)
{ {
QString dice_result = QString::number(AOClient::genRand(1, 6)); QString dice_result = QString::number(AOClient::genRand(1, 6));
sendServerMessage(sender_name + " rolled " + dice_result + " out of 6"); sendServerMessage(sender_name + " rolled " + dice_result + " out of 6");
server->broadcast(AOPacket("CT",{"Roll",sender_name + " rolled in secret."}), current_area); sendServerMessageArea((sender_name + " rolled in secret."));
} }
else if (argc == 1) else if (argc == 1)
{ {
int amount_faces = argv[0].toInt(); int amount_faces = argv[0].toInt();
if (1 <= amount_faces and amount_faces <= max_roll_faces) if (1 <= amount_faces and amount_faces <= max_roll_faces)
{ {
QString dice_result = QString::number(AOClient::genRand(1, amount_faces)); QString dice_result = QString::number(AOClient::genRand(1, amount_faces));
sendServerMessage(sender_name + " rolled " + dice_result + " out of " + argv[0]); sendServerMessage(sender_name + " rolled " + dice_result + " out of " + argv[0]);
server->broadcast(AOPacket("CT",{"Roll",sender_name + " rolled in secret."}), current_area); sendServerMessageArea((sender_name + " rolled in secret."));;
} }
else else
{ {
@ -488,11 +489,11 @@ void AOClient::cmdRollP(int argc, QStringList argv)
} }
else else
{ {
dice_results = dice_results.append(dice_result + ","); dice_results = dice_results.append(dice_result + ",");
} }
} }
sendServerMessage(sender_name + " rolled " + dice_results + " out of " + argv[0]); sendServerMessage(sender_name + " rolled " + dice_results + " out of " + argv[0]);
server->broadcast(AOPacket("CT",{"Roll",sender_name + " rolled in secret."}), current_area); sendServerMessageArea((sender_name + " rolled in secret."));;
} }
else else
{ {