void BFBC2CommandHandler::parsePunkBusterVersionEvent(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); if (packet.getWordCount() >= 1) { QString version = packet.getWord(1).getContent(); emit (onPunkBusterVersionEvent(version)); } }
/* Parse events */ void BFBC2CommandHandler::parsePlayerKickedEvent(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); if (packet.getWordCount() >= 1) { QString player = packet.getWord(1).getContent(); QString reason = packet.getWord(2).getContent(); emit (onPlayerKickedEvent(player, reason)); } }
void BF3CommandHandler::parseVarsGunMasterWeaponsPresetCommand(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); QString response = packet.getWord(0).getContent(); if (response == "OK" && lastSentPacket.getWordCount() > 1) { int weaponPreset = FrostbiteUtils::toInt(packet.getWord(1).getContent()); emit (onVarsGunMasterWeaponsPresetCommand(weaponPreset)); } }
void BF3CommandHandler::parseVarsRoundsPerMapCommand(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); QString response = packet.getWord(0).getContent(); if (response == "OK" && lastSentPacket.getWordCount() > 1) { int rounds = FrostbiteUtils::toInt(packet.getWord(1).getContent()); emit (onVarsRoundsPerMapCommand(rounds)); } }
void BF3CommandHandler::parseVarsBannerUrlCommand(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); QString response = packet.getWord(0).getContent(); if (response == "OK" && lastSentPacket.getWordCount() > 1) { QString bannerUrl = packet.getWord(1).getContent(); emit (onVarsBannerUrlCommand(bannerUrl)); } }
void BF3CommandHandler::parseVarsPremiumStatusCommand(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); QString response = packet.getWord(0).getContent(); if (response == "OK" && lastSentPacket.getWordCount() > 1) { bool enabled = FrostbiteUtils::toBool(packet.getWord(1).getContent()); emit (onVarsPremiumStatusCommand(enabled)); } }
void BF3CommandHandler::parseVarsPlayerManDownTimeCommand(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); QString response = packet.getWord(0).getContent(); if (response == "OK" && lastSentPacket.getWordCount() > 1) { int percent = FrostbiteUtils::toInt(packet.getWord(1).getContent()); emit (onVarsPlayerManDownTimeCommand(percent)); } }
// Admin void BF3CommandHandler::parseAdminEffectiveMaxPlayersCommand(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket) QString response = packet.getWord(0).getContent(); if (response == "OK" && packet.getWordCount() > 1) { int effectiveMaxPlayers = FrostbiteUtils::toInt(packet.getWord(1).getContent()); emit (onAdminEffectiveMaxPlayersCommand(effectiveMaxPlayers)); } }
void BF3CommandHandler::parseCurrentLevelCommand(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); QString response = packet.getWord(0).getContent(); if (response == "OK" && packet.getWordCount() > 1) { QString currentLevel = packet.getWord(1).getContent(); emit (onCurrentLevelCommand(currentLevel)); } }
void BFBC2CommandHandler::parseServerLoadingLevelEvent(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); if (packet.getWordCount() >= 1) { QString levelName = packet.getWord(1).getContent(); int roundsPlayed = FrostbiteUtils::toInt(packet.getWord(2).getContent()); int roundsTotal = FrostbiteUtils::toInt(packet.getWord(3).getContent()); emit (onServerLoadingLevelEvent(levelName, roundsPlayed, roundsTotal)); } }
void BFBC2CommandHandler::parseServerLevelStartedEvent(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); if (packet.getWordCount() >= 1) { emit (onServerLevelStartedEvent()); } }
// Misc void BF3CommandHandler::parseServerInfoCommand(const FrostbiteRconPacket &packet, const FrostbiteRconPacket &lastSentPacket) { Q_UNUSED(lastSentPacket); QString response = packet.getWord(0).getContent(); if (response == "OK" && packet.getWordCount() > 1) { QString serverName = packet.getWord(1).getContent(); int playerCount = FrostbiteUtils::toInt(packet.getWord(2).getContent()); int maxPlayerCount = FrostbiteUtils::toInt(packet.getWord(3).getContent()); QString gamemode = packet.getWord(4).getContent(); QString currentMap = packet.getWord(5).getContent(); int roundsPlayed = FrostbiteUtils::toInt(packet.getWord(6).getContent()); int roundsTotal = FrostbiteUtils::toInt(packet.getWord(7).getContent()); // Parsing team scores. int entries = FrostbiteUtils::toInt(packet.getWord(8).getContent()); QList<int> scoreList; int targetScore; for (int i = 9; i < entries; i++) { scoreList.append(FrostbiteUtils::toInt(packet.getWord(i).getContent())); if (i == entries) { targetScore = FrostbiteUtils::toInt(packet.getWord(i + 1).getContent()); } } TeamScores scores(scoreList, targetScore); // Parsing online state. QString onlineStateString = packet.getWord(12).getContent(); OnlineState onlineState; if (onlineStateString == "NotConnected") { onlineState = OnlineState::NotConnected; } else if (onlineStateString == "ConnectedToBackend") { onlineState = OnlineState::ConnectedToBackend; } else if (onlineStateString == "AcceptingPlayers") { onlineState = OnlineState::AcceptingPlayers; } bool ranked = FrostbiteUtils::toBool(packet.getWord(13).getContent()); bool punkBuster = FrostbiteUtils::toBool(packet.getWord(14).getContent()); bool hasGamePassword = FrostbiteUtils::toBool(packet.getWord(15).getContent()); int serverUpTime = FrostbiteUtils::toInt(packet.getWord(16).getContent()); int roundTime = FrostbiteUtils::toInt(packet.getWord(17).getContent()); QString gameIpAndPort = packet.getWord(18).getContent(); QString punkBusterVersion = packet.getWord(19).getContent(); bool joinQueueEnabled = FrostbiteUtils::toBool(packet.getWord(20).getContent()); QString region = packet.getWord(21).getContent(); QString closestPingSite = packet.getWord(22).getContent(); QString country = packet.getWord(23).getContent(); bool matchMakingEnabled = FrostbiteUtils::toBool(packet.getWord(24).getContent()); Frostbite2ServerInfo serverInfo( serverName, playerCount, maxPlayerCount, gamemode, currentMap, roundsPlayed, roundsTotal, scores, onlineState, ranked, punkBuster, hasGamePassword, serverUpTime, roundTime, gameIpAndPort, punkBusterVersion, joinQueueEnabled, region, closestPingSite, country, matchMakingEnabled ); emit (onServerInfoCommand(serverInfo)); } }
void FrostbiteConnection::handlePacket(const FrostbiteRconPacket &packet) { if (packet.isResponse()) { QVector<FrostbiteRconPacket>::iterator it; for (it = packetSendQueue.begin(); it < packetSendQueue.end(); it++) { if (it->getSequenceNum() == packet.getSequenceNum()) { break; } } if (it != packetSendQueue.end()) { const FrostbiteRconPacket &lastSentPacket = *it; QString request = lastSentPacket.getWord(0).getContent(); if (packet.getWordCount() > 0) { QString messages = request + " "; for (unsigned int i = 1; i < lastSentPacket.getWordCount(); i++) { messages += lastSentPacket.getWord(i).getContent(); messages += " "; } responseDataSent(messages); qDebug() << messages; QString messager; for (unsigned int i = 0; i < packet.getWordCount(); i++) { messager += packet.getWord(i).getContent(); messager += " "; } responseDataReceived(messager); qDebug() << messager; commandHandler->parse(request, packet, lastSentPacket); } // BIG MISTAKE HERE: packetSendQueue.erase(it); for (it = packetSendQueue.begin(); it < packetSendQueue.end(); it++) { if (it->getSequenceNum() == packet.getSequenceNum()) { packetSendQueue.erase(it); break; } } } } else { QString request = packet.getWord(0).getContent(); QString message; for (unsigned int i = 0; i < packet.getWordCount(); i++) { message += packet.getWord(i).getContent(); message += " "; } responseDataSent(message); qDebug() << message; commandHandler->parse(request, packet, FrostbiteRconPacket()); } }