fix bounds checking, add /play
This commit is contained in:
parent
7d87a7027f
commit
9985b7daf8
@ -57,6 +57,7 @@ class AOClient : public QObject {
|
|||||||
bool authenticated = false;
|
bool authenticated = false;
|
||||||
QString moderator_name = "";
|
QString moderator_name = "";
|
||||||
QString ooc_name = "";
|
QString ooc_name = "";
|
||||||
|
QString showname = "";
|
||||||
|
|
||||||
QMap<QString, unsigned long long> ACLFlags {
|
QMap<QString, unsigned long long> ACLFlags {
|
||||||
{"NONE", 0ULL},
|
{"NONE", 0ULL},
|
||||||
@ -196,6 +197,7 @@ class AOClient : public QObject {
|
|||||||
void cmdBan(int argc, QStringList argv);
|
void cmdBan(int argc, QStringList argv);
|
||||||
void cmdKick(int argc, QStringList argv);
|
void cmdKick(int argc, QStringList argv);
|
||||||
// Casing/RP
|
// Casing/RP
|
||||||
|
void cmdPlay(int argc, QStringList argv);
|
||||||
void cmdNeed(int argc, QStringList argv);
|
void cmdNeed(int argc, QStringList argv);
|
||||||
void cmdFlip(int argc, QStringList argv);
|
void cmdFlip(int argc, QStringList argv);
|
||||||
void cmdRoll(int argc, QStringList argv);
|
void cmdRoll(int argc, QStringList argv);
|
||||||
@ -257,6 +259,7 @@ class AOClient : public QObject {
|
|||||||
{"unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}},
|
{"unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}},
|
||||||
{"timer", {ACLFlags.value("CM"), 0, &AOClient::cmdTimer}},
|
{"timer", {ACLFlags.value("CM"), 0, &AOClient::cmdTimer}},
|
||||||
{"area", {ACLFlags.value("NONE"), 1, &AOClient::cmdArea}},
|
{"area", {ACLFlags.value("NONE"), 1, &AOClient::cmdArea}},
|
||||||
|
{"play", {ACLFlags.value("CM"), 1, &AOClient::cmdPlay}},
|
||||||
};
|
};
|
||||||
|
|
||||||
QString partial_packet;
|
QString partial_packet;
|
||||||
|
@ -53,6 +53,7 @@ class Server : public QObject {
|
|||||||
void broadcast(AOPacket packet);
|
void broadcast(AOPacket packet);
|
||||||
QString getServerName();
|
QString getServerName();
|
||||||
int getDiceValue(QString value_type);
|
int getDiceValue(QString value_type);
|
||||||
|
int getCharID(QString char_name);
|
||||||
|
|
||||||
QVector<AOClient*> clients;
|
QVector<AOClient*> clients;
|
||||||
|
|
||||||
|
@ -641,13 +641,18 @@ void AOClient::cmdArea(int argc, QStringList argv)
|
|||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int new_area = argv[0].toInt(&ok);
|
int new_area = argv[0].toInt(&ok);
|
||||||
if (!ok || new_area > server->areas.size() || new_area < 0) {
|
if (!ok || new_area >= server->areas.size() || new_area < 0) {
|
||||||
sendServerMessage("That does not look like a valid area ID.");
|
sendServerMessage("That does not look like a valid area ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
changeArea(new_area);
|
changeArea(new_area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AOClient::cmdPlay(int argc, QStringList argv)
|
||||||
|
{
|
||||||
|
sendPacket("MC", {argv.join(" "), QString::number(server->getCharID(current_char)), showname, "1", "0"});
|
||||||
|
}
|
||||||
|
|
||||||
QStringList AOClient::buildAreaList(int area_idx)
|
QStringList AOClient::buildAreaList(int area_idx)
|
||||||
{
|
{
|
||||||
QStringList entries;
|
QStringList entries;
|
||||||
|
@ -454,8 +454,9 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
|||||||
// 2.6 packet extensions
|
// 2.6 packet extensions
|
||||||
if (incoming_args.length() > 15) {
|
if (incoming_args.length() > 15) {
|
||||||
// showname
|
// showname
|
||||||
QString showname = dezalgo(incoming_args[15].toString().trimmed());
|
QString incoming_showname = dezalgo(incoming_args[15].toString().trimmed());
|
||||||
args.append(showname);
|
args.append(incoming_showname);
|
||||||
|
showname = incoming_showname;
|
||||||
|
|
||||||
// other char id
|
// other char id
|
||||||
// things get a bit hairy here
|
// things get a bit hairy here
|
||||||
|
@ -191,6 +191,16 @@ AOClient* Server::getClientByID(int id)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Server::getCharID(QString char_name)
|
||||||
|
{
|
||||||
|
for (QString character : characters) {
|
||||||
|
if (character == char_name) {
|
||||||
|
return characters.indexOf(character);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1; // character does not exist
|
||||||
|
}
|
||||||
|
|
||||||
Server::~Server()
|
Server::~Server()
|
||||||
{
|
{
|
||||||
for (AOClient* client : clients) {
|
for (AOClient* client : clients) {
|
||||||
|
Loading…
Reference in New Issue
Block a user