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;
|
||||
QString moderator_name = "";
|
||||
QString ooc_name = "";
|
||||
QString showname = "";
|
||||
|
||||
QMap<QString, unsigned long long> ACLFlags {
|
||||
{"NONE", 0ULL},
|
||||
@ -196,6 +197,7 @@ class AOClient : public QObject {
|
||||
void cmdBan(int argc, QStringList argv);
|
||||
void cmdKick(int argc, QStringList argv);
|
||||
// Casing/RP
|
||||
void cmdPlay(int argc, QStringList argv);
|
||||
void cmdNeed(int argc, QStringList argv);
|
||||
void cmdFlip(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}},
|
||||
{"timer", {ACLFlags.value("CM"), 0, &AOClient::cmdTimer}},
|
||||
{"area", {ACLFlags.value("NONE"), 1, &AOClient::cmdArea}},
|
||||
{"play", {ACLFlags.value("CM"), 1, &AOClient::cmdPlay}},
|
||||
};
|
||||
|
||||
QString partial_packet;
|
||||
|
@ -53,6 +53,7 @@ class Server : public QObject {
|
||||
void broadcast(AOPacket packet);
|
||||
QString getServerName();
|
||||
int getDiceValue(QString value_type);
|
||||
int getCharID(QString char_name);
|
||||
|
||||
QVector<AOClient*> clients;
|
||||
|
||||
|
@ -641,13 +641,18 @@ void AOClient::cmdArea(int argc, QStringList argv)
|
||||
{
|
||||
bool 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.");
|
||||
return;
|
||||
}
|
||||
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 entries;
|
||||
|
@ -454,8 +454,9 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
||||
// 2.6 packet extensions
|
||||
if (incoming_args.length() > 15) {
|
||||
// showname
|
||||
QString showname = dezalgo(incoming_args[15].toString().trimmed());
|
||||
args.append(showname);
|
||||
QString incoming_showname = dezalgo(incoming_args[15].toString().trimmed());
|
||||
args.append(incoming_showname);
|
||||
showname = incoming_showname;
|
||||
|
||||
// other char id
|
||||
// things get a bit hairy here
|
||||
|
@ -191,6 +191,16 @@ AOClient* Server::getClientByID(int id)
|
||||
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()
|
||||
{
|
||||
for (AOClient* client : clients) {
|
||||
|
Loading…
Reference in New Issue
Block a user