improve arup function, add /status
This commit is contained in:
parent
a792c063ee
commit
556fe9a0b1
@ -197,6 +197,7 @@ class AOClient : public QObject {
|
|||||||
void cmdSetBackground(int argc, QStringList argv);
|
void cmdSetBackground(int argc, QStringList argv);
|
||||||
void cmdBgLock(int argc, QStringList argv);
|
void cmdBgLock(int argc, QStringList argv);
|
||||||
void cmdBgUnlock(int argc, QStringList argv);
|
void cmdBgUnlock(int argc, QStringList argv);
|
||||||
|
void cmdStatus(int argc, QStringList argv);
|
||||||
// Moderation
|
// Moderation
|
||||||
void cmdMods(int argc, QStringList argv);
|
void cmdMods(int argc, QStringList argv);
|
||||||
void cmdBan(int argc, QStringList argv);
|
void cmdBan(int argc, QStringList argv);
|
||||||
@ -278,6 +279,7 @@ class AOClient : public QObject {
|
|||||||
{"toggleglobal", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleGlobal}},
|
{"toggleglobal", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleGlobal}},
|
||||||
{"mods", {ACLFlags.value("NONE"), 0, &AOClient::cmdMods}},
|
{"mods", {ACLFlags.value("NONE"), 0, &AOClient::cmdMods}},
|
||||||
{"help", {ACLFlags.value("NONE"), 0, &AOClient::cmdHelp}},
|
{"help", {ACLFlags.value("NONE"), 0, &AOClient::cmdHelp}},
|
||||||
|
{"status", {ACLFlags.value("NONE"), 1, &AOClient::cmdStatus}},
|
||||||
};
|
};
|
||||||
|
|
||||||
QString partial_packet;
|
QString partial_packet;
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
class Logger;
|
class Logger;
|
||||||
class AreaData {
|
class AreaData : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AreaData(QStringList p_characters, QString p_name, int p_index);
|
AreaData(QStringList p_characters, QString p_name, int p_index);
|
||||||
|
|
||||||
@ -43,7 +44,16 @@ class AreaData {
|
|||||||
QMap<QString, bool> characters_taken;
|
QMap<QString, bool> characters_taken;
|
||||||
QList<Evidence> evidence;
|
QList<Evidence> evidence;
|
||||||
int player_count;
|
int player_count;
|
||||||
QString status;
|
enum Status {
|
||||||
|
IDLE,
|
||||||
|
RP,
|
||||||
|
CASING,
|
||||||
|
LOOKING_FOR_PLAYERS,
|
||||||
|
RECESS,
|
||||||
|
GAMING
|
||||||
|
};
|
||||||
|
Q_ENUM(Status);
|
||||||
|
Status status;
|
||||||
QList<int> owners;
|
QList<int> owners;
|
||||||
QList<int> invited;
|
QList<int> invited;
|
||||||
enum LockStatus {
|
enum LockStatus {
|
||||||
@ -51,6 +61,7 @@ class AreaData {
|
|||||||
LOCKED,
|
LOCKED,
|
||||||
SPECTATABLE
|
SPECTATABLE
|
||||||
};
|
};
|
||||||
|
Q_ENUM(LockStatus);
|
||||||
LockStatus locked;
|
LockStatus locked;
|
||||||
QString background;
|
QString background;
|
||||||
bool is_protected;
|
bool is_protected;
|
||||||
|
@ -215,42 +215,38 @@ void AOClient::arup(ARUPType type, bool broadcast)
|
|||||||
QStringList arup_data;
|
QStringList arup_data;
|
||||||
arup_data.append(QString::number(type));
|
arup_data.append(QString::number(type));
|
||||||
for (AreaData* area : server->areas) {
|
for (AreaData* area : server->areas) {
|
||||||
if (type == ARUPType::PLAYER_COUNT) {
|
switch(type) {
|
||||||
arup_data.append(QString::number(area->player_count));
|
case ARUPType::PLAYER_COUNT: {
|
||||||
}
|
arup_data.append(QString::number(area->player_count));
|
||||||
else if (type == ARUPType::STATUS) {
|
break;
|
||||||
arup_data.append(area->status);
|
}
|
||||||
}
|
case ARUPType::STATUS: {
|
||||||
else if (type == ARUPType::CM) {
|
QString area_status = QVariant::fromValue(area->status).toString().replace("_", "-");
|
||||||
if (area->owners.isEmpty())
|
arup_data.append(area_status);
|
||||||
arup_data.append("FREE");
|
break;
|
||||||
else {
|
}
|
||||||
QStringList area_owners;
|
case ARUPType::CM: {
|
||||||
for (int owner_id : area->owners) {
|
if (area->owners.isEmpty())
|
||||||
AOClient* owner = server->getClientByID(owner_id);
|
arup_data.append("FREE");
|
||||||
area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char);
|
else {
|
||||||
|
QStringList area_owners;
|
||||||
|
for (int owner_id : area->owners) {
|
||||||
|
AOClient* owner = server->getClientByID(owner_id);
|
||||||
|
area_owners.append("[" + QString::number(owner->id) + "] " + owner->current_char);
|
||||||
|
}
|
||||||
|
arup_data.append(area_owners.join(", "));
|
||||||
}
|
}
|
||||||
arup_data.append(area_owners.join(", "));
|
break;
|
||||||
|
}
|
||||||
|
case ARUPType::LOCKED: {
|
||||||
|
QString lock_status = QVariant::fromValue(area->locked).toString();
|
||||||
|
arup_data.append(lock_status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == ARUPType::LOCKED) {
|
|
||||||
QString lock_status;
|
|
||||||
switch (area->locked) {
|
|
||||||
case AreaData::LockStatus::FREE:
|
|
||||||
lock_status = "FREE";
|
|
||||||
break;
|
|
||||||
case AreaData::LockStatus::LOCKED:
|
|
||||||
lock_status = "LOCKED";
|
|
||||||
break;
|
|
||||||
case AreaData::LockStatus::SPECTATABLE:
|
|
||||||
lock_status = "SPECTATABLE";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
arup_data.append(lock_status);
|
|
||||||
}
|
|
||||||
else return;
|
|
||||||
}
|
}
|
||||||
if (broadcast)
|
if (broadcast)
|
||||||
server->broadcast(AOPacket("ARUP", arup_data));
|
server->broadcast(AOPacket("ARUP", arup_data));
|
||||||
|
@ -32,7 +32,7 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index)
|
|||||||
areas_ini.endGroup();
|
areas_ini.endGroup();
|
||||||
player_count = 0;
|
player_count = 0;
|
||||||
locked = FREE;
|
locked = FREE;
|
||||||
status = "FREE";
|
status = IDLE;
|
||||||
def_hp = 10;
|
def_hp = 10;
|
||||||
pro_hp = 10;
|
pro_hp = 10;
|
||||||
document = "No document.";
|
document = "No document.";
|
||||||
|
@ -723,13 +723,35 @@ void AOClient::cmdHelp(int argc, QStringList argv)
|
|||||||
QMap<QString, CommandInfo>::const_iterator i;
|
QMap<QString, CommandInfo>::const_iterator i;
|
||||||
for (i = commands.constBegin(); i!= commands.constEnd(); ++i) {
|
for (i = commands.constBegin(); i!= commands.constEnd(); ++i) {
|
||||||
CommandInfo info = i.value();
|
CommandInfo info = i.value();
|
||||||
if (checkAuth(info.acl_mask)) {
|
if (checkAuth(info.acl_mask)) { // if we are allowed to use this command
|
||||||
entries << "/" + i.key();
|
entries << "/" + i.key();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendServerMessage(entries.join("\n"));
|
sendServerMessage(entries.join("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AOClient::cmdStatus(int argc, QStringList argv) {
|
||||||
|
AreaData* area = server->areas[current_area];
|
||||||
|
QString arg = argv[0].toLower();
|
||||||
|
if (arg == "idle")
|
||||||
|
area->status = AreaData::IDLE;
|
||||||
|
else if (arg == "rp")
|
||||||
|
area->status = AreaData::RP;
|
||||||
|
else if (arg == "casing")
|
||||||
|
area->status = AreaData::CASING;
|
||||||
|
else if (arg == "looking-for-players" || arg == "lfp")
|
||||||
|
area->status = AreaData::LOOKING_FOR_PLAYERS;
|
||||||
|
else if (arg == "recess")
|
||||||
|
area->status = AreaData::RECESS;
|
||||||
|
else if (arg == "gaming")
|
||||||
|
area->status = AreaData::GAMING;
|
||||||
|
else {
|
||||||
|
sendServerMessage("That does not look like a valid status. Valid statuses are idle, rp, casing, lfp, recess, gaming");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
arup(ARUPType::STATUS, true);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList AOClient::buildAreaList(int area_idx)
|
QStringList AOClient::buildAreaList(int area_idx)
|
||||||
{
|
{
|
||||||
QStringList entries;
|
QStringList entries;
|
||||||
|
Loading…
Reference in New Issue
Block a user