add area_kick, switch, randomchar
This commit is contained in:
parent
9985b7daf8
commit
d1918e50a9
@ -97,6 +97,7 @@ class AOClient : public QObject {
|
|||||||
void handlePacket(AOPacket packet);
|
void handlePacket(AOPacket packet);
|
||||||
void handleCommand(QString command, int argc, QStringList argv);
|
void handleCommand(QString command, int argc, QStringList argv);
|
||||||
void changeArea(int new_area);
|
void changeArea(int new_area);
|
||||||
|
void changeCharacter(int char_id);
|
||||||
void arup(ARUPType type, bool broadcast);
|
void arup(ARUPType type, bool broadcast);
|
||||||
void fullArup();
|
void fullArup();
|
||||||
void sendServerMessage(QString message);
|
void sendServerMessage(QString message);
|
||||||
@ -190,6 +191,7 @@ class AOClient : public QObject {
|
|||||||
void cmdGetAreas(int argc, QStringList argv);
|
void cmdGetAreas(int argc, QStringList argv);
|
||||||
void cmdGetArea(int argc, QStringList argv);
|
void cmdGetArea(int argc, QStringList argv);
|
||||||
void cmdArea(int argc, QStringList argv);
|
void cmdArea(int argc, QStringList argv);
|
||||||
|
void cmdAreaKick(int argc, QStringList argv);
|
||||||
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);
|
||||||
@ -207,6 +209,8 @@ class AOClient : public QObject {
|
|||||||
void cmdTimer(int argc, QStringList argv);
|
void cmdTimer(int argc, QStringList argv);
|
||||||
// Messaging/Client
|
// Messaging/Client
|
||||||
void cmdPos(int argc, QStringList argv);
|
void cmdPos(int argc, QStringList argv);
|
||||||
|
void cmdSwitch(int argc, QStringList argv);
|
||||||
|
void cmdRandomChar(int argc, QStringList argv);
|
||||||
void cmdG(int argc, QStringList argv);
|
void cmdG(int argc, QStringList argv);
|
||||||
|
|
||||||
// Command helper functions
|
// Command helper functions
|
||||||
@ -260,6 +264,9 @@ class AOClient : public QObject {
|
|||||||
{"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}},
|
{"play", {ACLFlags.value("CM"), 1, &AOClient::cmdPlay}},
|
||||||
|
{"areakick", {ACLFlags.value("CM"), 1, &AOClient::cmdAreaKick}},
|
||||||
|
{"randomchar", {ACLFlags.value("NONE"), 0, &AOClient::cmdRandomChar}},
|
||||||
|
{"switch", {ACLFlags.value("NONE"), 1, &AOClient::cmdSwitch}},
|
||||||
};
|
};
|
||||||
|
|
||||||
QString partial_packet;
|
QString partial_packet;
|
||||||
|
@ -145,6 +145,54 @@ void AOClient::changeArea(int new_area)
|
|||||||
sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM.");
|
sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AOClient::changeCharacter(int char_id)
|
||||||
|
{
|
||||||
|
AreaData* area = server->areas[current_area];
|
||||||
|
|
||||||
|
if (current_char != "") {
|
||||||
|
area->characters_taken[current_char] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(char_id > server->characters.length())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (char_id >= 0) {
|
||||||
|
QString char_selected = server->characters[char_id];
|
||||||
|
bool taken = area->characters_taken.value(char_selected);
|
||||||
|
if (taken || char_selected == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
area->characters_taken[char_selected] = true;
|
||||||
|
current_char = char_selected;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
current_char = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = "";
|
||||||
|
|
||||||
|
server->updateCharsTaken(area);
|
||||||
|
sendPacket("PV", {QString::number(id), "CID", QString::number(char_id)});
|
||||||
|
fullArup();
|
||||||
|
if (server->timer->isActive()) {
|
||||||
|
sendPacket("TI", {QString::number(0), QString::number(2)});
|
||||||
|
sendPacket("TI", {QString::number(0), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(server->timer->remainingTime())))});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendPacket("TI", {QString::number(0), QString::number(3)});
|
||||||
|
}
|
||||||
|
for (QTimer* timer : area->timers) {
|
||||||
|
int timer_id = area->timers.indexOf(timer) + 1;
|
||||||
|
if (timer->isActive()) {
|
||||||
|
sendPacket("TI", {QString::number(timer_id), QString::number(2)});
|
||||||
|
sendPacket("TI", {QString::number(timer_id), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendPacket("TI", {QString::number(timer_id), QString::number(3)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AOClient::handleCommand(QString command, int argc, QStringList argv)
|
void AOClient::handleCommand(QString command, int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
CommandInfo info = commands.value(command, {false, -1, &AOClient::cmdDefault});
|
CommandInfo info = commands.value(command, {false, -1, &AOClient::cmdDefault});
|
||||||
|
@ -653,6 +653,35 @@ void AOClient::cmdPlay(int argc, QStringList argv)
|
|||||||
sendPacket("MC", {argv.join(" "), QString::number(server->getCharID(current_char)), showname, "1", "0"});
|
sendPacket("MC", {argv.join(" "), QString::number(server->getCharID(current_char)), showname, "1", "0"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AOClient::cmdAreaKick(int argc, QStringList argv)
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
int idx = argv[0].toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
sendServerMessage("That does not look like a valid ID.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AOClient* client_to_kick = server->getClientByID(idx);
|
||||||
|
client_to_kick->changeArea(0);
|
||||||
|
sendServerMessage("Client " + argv[0] + " kicked back to area 0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOClient::cmdSwitch(int argc, QStringList argv)
|
||||||
|
{
|
||||||
|
int char_id = server->getCharID(argv.join(" "));
|
||||||
|
if (char_id == -1) {
|
||||||
|
sendServerMessage("That does not look like a valid character.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
changeCharacter(char_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOClient::cmdRandomChar(int argc, QStringList argv)
|
||||||
|
{
|
||||||
|
int char_id = genRand(0, server->characters.size() - 1);
|
||||||
|
changeCharacter(char_id);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList AOClient::buildAreaList(int area_idx)
|
QStringList AOClient::buildAreaList(int area_idx)
|
||||||
{
|
{
|
||||||
QStringList entries;
|
QStringList entries;
|
||||||
|
@ -118,48 +118,7 @@ void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacke
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_char != "") {
|
changeCharacter(char_id);
|
||||||
area->characters_taken[current_char] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(char_id > server->characters.length())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (char_id >= 0) {
|
|
||||||
QString char_selected = server->characters[char_id];
|
|
||||||
bool taken = area->characters_taken.value(char_selected);
|
|
||||||
if (taken || char_selected == "")
|
|
||||||
return;
|
|
||||||
|
|
||||||
area->characters_taken[char_selected] = true;
|
|
||||||
current_char = char_selected;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
current_char = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
pos = "";
|
|
||||||
|
|
||||||
server->updateCharsTaken(area);
|
|
||||||
sendPacket("PV", {QString::number(id), "CID", argv[1]});
|
|
||||||
fullArup();
|
|
||||||
if (server->timer->isActive()) {
|
|
||||||
sendPacket("TI", {QString::number(0), QString::number(2)});
|
|
||||||
sendPacket("TI", {QString::number(0), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(server->timer->remainingTime())))});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sendPacket("TI", {QString::number(0), QString::number(3)});
|
|
||||||
}
|
|
||||||
for (QTimer* timer : area->timers) {
|
|
||||||
int timer_id = area->timers.indexOf(timer) + 1;
|
|
||||||
if (timer->isActive()) {
|
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(2)});
|
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(3)});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||||
|
@ -194,8 +194,8 @@ AOClient* Server::getClientByID(int id)
|
|||||||
int Server::getCharID(QString char_name)
|
int Server::getCharID(QString char_name)
|
||||||
{
|
{
|
||||||
for (QString character : characters) {
|
for (QString character : characters) {
|
||||||
if (character == char_name) {
|
if (character.toLower() == char_name.toLower()) {
|
||||||
return characters.indexOf(character);
|
return characters.indexOf(QRegExp(character, Qt::CaseInsensitive));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1; // character does not exist
|
return -1; // character does not exist
|
||||||
|
Loading…
Reference in New Issue
Block a user