implement pairing and other ic features
This commit is contained in:
parent
8c4eec8805
commit
ae6a6f7e94
@ -39,9 +39,9 @@ class AOClient : public QObject {
|
|||||||
~AOClient();
|
~AOClient();
|
||||||
|
|
||||||
QString getHwid();
|
QString getHwid();
|
||||||
void setHwid(QString p_hwid);
|
|
||||||
|
|
||||||
QString getIpid();
|
QString getIpid();
|
||||||
|
Server* getServer();
|
||||||
|
void setHwid(QString p_hwid);
|
||||||
|
|
||||||
QHostAddress remote_ip;
|
QHostAddress remote_ip;
|
||||||
QString password;
|
QString password;
|
||||||
@ -51,7 +51,6 @@ class AOClient : public QObject {
|
|||||||
bool authenticated = false;
|
bool authenticated = false;
|
||||||
QString moderator_name = "";
|
QString moderator_name = "";
|
||||||
QString ooc_name = "";
|
QString ooc_name = "";
|
||||||
Server* server;
|
|
||||||
|
|
||||||
QMap<QString, unsigned long long> ACLFlags {
|
QMap<QString, unsigned long long> ACLFlags {
|
||||||
{"NONE", 0ULL},
|
{"NONE", 0ULL},
|
||||||
@ -71,6 +70,7 @@ class AOClient : public QObject {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QTcpSocket* socket;
|
QTcpSocket* socket;
|
||||||
|
Server* server;
|
||||||
|
|
||||||
enum ARUPType {
|
enum ARUPType {
|
||||||
PLAYER_COUNT,
|
PLAYER_COUNT,
|
||||||
@ -112,6 +112,10 @@ class AOClient : public QObject {
|
|||||||
// Packet helper global variables
|
// Packet helper global variables
|
||||||
bool last_msg_blankpost = false;
|
bool last_msg_blankpost = false;
|
||||||
int char_id = -1;
|
int char_id = -1;
|
||||||
|
int pairing_with = -1;
|
||||||
|
QString emote = "";
|
||||||
|
QString offset = "";
|
||||||
|
QString flipping = "";
|
||||||
|
|
||||||
struct PacketInfo {
|
struct PacketInfo {
|
||||||
unsigned long long acl_mask;
|
unsigned long long acl_mask;
|
||||||
|
@ -55,7 +55,7 @@ void AOClient::clientData()
|
|||||||
|
|
||||||
void AOClient::clientDisconnected()
|
void AOClient::clientDisconnected()
|
||||||
{
|
{
|
||||||
qDebug() << remote_ip.toString() << "disconnected";
|
//qDebug() << remote_ip.toString() << "disconnected";
|
||||||
if (joined) {
|
if (joined) {
|
||||||
server->player_count--;
|
server->player_count--;
|
||||||
server->areas[current_area]->player_count--;
|
server->areas[current_area]->player_count--;
|
||||||
@ -70,7 +70,7 @@ void AOClient::clientDisconnected()
|
|||||||
|
|
||||||
void AOClient::handlePacket(AOPacket packet)
|
void AOClient::handlePacket(AOPacket packet)
|
||||||
{
|
{
|
||||||
// qDebug() << "Received packet:" << packet.header << ":" << packet.contents << "args length:" << packet.contents.length();
|
qDebug() << "Received packet:" << packet.header << ":" << packet.contents << "args length:" << packet.contents.length();
|
||||||
AreaData* area = server->areas[current_area];
|
AreaData* area = server->areas[current_area];
|
||||||
PacketInfo info = packets.value(packet.header, {false, 0, &AOClient::pktDefault});
|
PacketInfo info = packets.value(packet.header, {false, 0, &AOClient::pktDefault});
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ void AOClient::fullArup() {
|
|||||||
|
|
||||||
void AOClient::sendPacket(AOPacket packet)
|
void AOClient::sendPacket(AOPacket packet)
|
||||||
{
|
{
|
||||||
// qDebug() << "Sent packet:" << packet.header << ":" << packet.contents;
|
qDebug() << "Sent packet:" << packet.header << ":" << packet.contents;
|
||||||
socket->write(packet.toUtf8());
|
socket->write(packet.toUtf8());
|
||||||
socket->flush();
|
socket->flush();
|
||||||
}
|
}
|
||||||
@ -241,6 +241,8 @@ bool AOClient::checkAuth(unsigned long long acl_mask)
|
|||||||
|
|
||||||
QString AOClient::getIpid() { return ipid; }
|
QString AOClient::getIpid() { return ipid; }
|
||||||
|
|
||||||
|
Server* AOClient::getServer() { return server; };
|
||||||
|
|
||||||
AOClient::~AOClient() {
|
AOClient::~AOClient() {
|
||||||
socket->deleteLater();
|
socket->deleteLater();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ Logger::Logger(int p_max_length)
|
|||||||
void Logger::logIC(AOClient *client, AOPacket *packet)
|
void Logger::logIC(AOClient *client, AOPacket *packet)
|
||||||
{
|
{
|
||||||
QString time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
|
QString time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
|
||||||
QString area_name = client->server->area_names.value(client->current_area);
|
QString area_name = client->getServer()->area_names.value(client->current_area);
|
||||||
QString char_name = client->current_char;
|
QString char_name = client->current_char;
|
||||||
QString ipid = client->getIpid();
|
QString ipid = client->getIpid();
|
||||||
QString message = packet->contents[4];
|
QString message = packet->contents[4];
|
||||||
|
@ -290,7 +290,8 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
|||||||
args.append(incoming_args[2].toString());
|
args.append(incoming_args[2].toString());
|
||||||
|
|
||||||
// emote
|
// emote
|
||||||
args.append(incoming_args[3].toString());
|
emote = incoming_args[3].toString();
|
||||||
|
args.append(emote);
|
||||||
|
|
||||||
// message text
|
// message text
|
||||||
QString incoming_msg = incoming_args[4].toString().trimmed();
|
QString incoming_msg = incoming_args[4].toString().trimmed();
|
||||||
@ -359,7 +360,8 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
|||||||
int flip = incoming_args[12].toInt();
|
int flip = incoming_args[12].toInt();
|
||||||
if (flip != 0 && flip != 1)
|
if (flip != 0 && flip != 1)
|
||||||
return invalid;
|
return invalid;
|
||||||
args.append(QString::number(flip));
|
flipping = QString::number(flip);
|
||||||
|
args.append(flipping);
|
||||||
|
|
||||||
// realization
|
// realization
|
||||||
int realization = incoming_args[13].toInt();
|
int realization = incoming_args[13].toInt();
|
||||||
@ -375,13 +377,87 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
|||||||
|
|
||||||
// 2.6 packet extensions
|
// 2.6 packet extensions
|
||||||
if (incoming_args.length() > 15) {
|
if (incoming_args.length() > 15) {
|
||||||
|
// showname
|
||||||
|
args.append(incoming_args[15].toString());
|
||||||
|
|
||||||
|
// other char id
|
||||||
|
// things get a bit hairy here
|
||||||
|
// don't ask me how this works, because i don't know either
|
||||||
|
QStringList pair_data = incoming_args[16].toString().split("^");
|
||||||
|
pairing_with = pair_data[0].toInt();
|
||||||
|
QString front_back = "";
|
||||||
|
if (pair_data.length() > 1)
|
||||||
|
front_back = "^" + pair_data[1];
|
||||||
|
int other_charid = pairing_with;
|
||||||
|
bool pairing = false;
|
||||||
|
QString other_name = "0";
|
||||||
|
QString other_emote = "0";
|
||||||
|
QString other_offset = "0";
|
||||||
|
QString other_flip = "0";
|
||||||
|
for (AOClient* client : server->clients) {
|
||||||
|
if (client->pairing_with == char_id && other_charid != char_id && client->char_id == pairing_with) {
|
||||||
|
other_name = server->characters.at(other_charid);
|
||||||
|
other_emote = client->emote;
|
||||||
|
other_offset = client->offset;
|
||||||
|
other_flip = client->flipping;
|
||||||
|
pairing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!pairing) {
|
||||||
|
other_charid = -1;
|
||||||
|
front_back = "";
|
||||||
|
}
|
||||||
|
args.append(QString::number(other_charid) + front_back);
|
||||||
|
args.append(other_name);
|
||||||
|
args.append(other_emote);
|
||||||
|
|
||||||
|
// self offset
|
||||||
|
offset = incoming_args[17].toString();
|
||||||
|
args.append(offset);
|
||||||
|
args.append(other_offset);
|
||||||
|
args.append(other_flip);
|
||||||
|
|
||||||
|
// noninterrupting preanim
|
||||||
|
int ni_pa = incoming_args[18].toInt();
|
||||||
|
if (ni_pa != 1 && ni_pa != 0)
|
||||||
|
return invalid;
|
||||||
|
args.append(QString::number(ni_pa));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.8 packet extensions
|
// 2.8 packet extensions
|
||||||
if (incoming_args.length() > 19) {
|
if (incoming_args.length() > 19) {
|
||||||
|
// sfx looping
|
||||||
|
int sfx_loop = incoming_args[19].toInt();
|
||||||
|
if (sfx_loop != 0 && sfx_loop != 1)
|
||||||
|
return invalid;
|
||||||
|
args.append(QString::number(sfx_loop));
|
||||||
|
|
||||||
|
// screenshake
|
||||||
|
int screenshake = incoming_args[20].toInt();
|
||||||
|
if (screenshake != 0 && screenshake != 1)
|
||||||
|
return invalid;
|
||||||
|
args.append(QString::number(screenshake));
|
||||||
|
|
||||||
|
// frames shake
|
||||||
|
args.append(incoming_args[21].toString());
|
||||||
|
|
||||||
|
// frames realization
|
||||||
|
args.append(incoming_args[22].toString());
|
||||||
|
|
||||||
|
// frames sfx
|
||||||
|
args.append(incoming_args[23].toString());
|
||||||
|
|
||||||
|
// additive
|
||||||
|
int additive = incoming_args[24].toInt();
|
||||||
|
if (additive != 0 && additive != 1)
|
||||||
|
return invalid;
|
||||||
|
args.append(QString::number(additive));
|
||||||
|
|
||||||
|
// effect
|
||||||
|
args.append(incoming_args[25].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << args.length();
|
||||||
|
|
||||||
return AOPacket("MS", args);
|
return AOPacket("MS", args);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ void Server::clientConnected()
|
|||||||
// completely in any client 2.4.3 or newer
|
// completely in any client 2.4.3 or newer
|
||||||
client->sendPacket(decryptor);
|
client->sendPacket(decryptor);
|
||||||
|
|
||||||
qDebug() << client->remote_ip.toString() << "connected";
|
//qDebug() << client->remote_ip.toString() << "connected";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::updateCharsTaken(AreaData* area)
|
void Server::updateCharsTaken(AreaData* area)
|
||||||
|
Loading…
Reference in New Issue
Block a user