修更多小bug
This commit is contained in:
notify 2023-07-01 23:14:30 +08:00 committed by GitHub
parent fd270a2edb
commit cee3ec279d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 17 deletions

View File

@ -29,7 +29,7 @@ callbacks["ServerDetected"] = (j) => {
}
callbacks["GetServerDetail"] = (j) => {
const [addr, ver, icon, desc, capacity, count] = JSON.parse(j);
const [ver, icon, desc, capacity, count, addr] = JSON.parse(j);
const serverDialog = mainStack.currentItem.serverDialog;
if (!serverDialog) {
return;

View File

@ -19,6 +19,7 @@ Item {
Item {
height: 64
width: serverList.width - 48
clip: true
RowLayout {
anchors.fill: parent
@ -31,16 +32,26 @@ Item {
source: favicon
}
Text {
text: serverIP
}
ColumnLayout {
Layout.fillWidth: true
Text {
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
text: serverIP
font.bold: true
}
Text {
text: description
Text {
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
text: description
textFormat: TextEdit.RichText
}
}
Text {
text: online + "/" + capacity
font.pixelSize: 30
}
}
@ -357,7 +368,8 @@ Item {
const [ver, icon, desc, capacity, count] = data;
for (let i = 0; i < serverModel.count; i++) {
const item = serverModel.get(i);
if (addr.endsWith(item.serverIP)) { // endsWithIPv6ip
const ip = item.serverIP;
if (addr.endsWith(ip)) { // endsWithIPv6ip
item.description = FkVersion === ver ? desc : "Ver " + ver;
item.favicon = icon;
item.online = count.toString();
@ -376,7 +388,7 @@ Item {
description: qsTr("Server not up"),
online: "-",
capacity: "-",
favicon: "https://img1.imgtp.com/2023/07/01/DGUdj8eu.png",
favicon: "",
});
Backend.getServerInfo(key);
}

View File

@ -47,12 +47,14 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
-- when this function is called, card is already in PlaceTable and no filter skill is applied.
-- So filter this card manually here to get 'real' use.card
local card = _card
---[[
if not _card:isVirtual() then
local temp = { card = _card }
Fk:filterCard(_card.id, room:getPlayerById(from), temp)
card = temp.card
end
cardUseEvent.card = card
--]]
playCardEmotionAndSound(room, room:getPlayerById(from), card)
room:doAnimate("Indicate", {

View File

@ -1501,8 +1501,6 @@ function Room:handleUseCardReply(player, data)
Self = player
local c = skill:viewAs(selected_cards)
if c then
self:useSkill(player, skill, Util.DummyFunc)
local use = {} ---@type CardUseStruct
use.from = player.id
use.tos = {}
@ -1515,6 +1513,9 @@ function Room:handleUseCardReply(player, data)
use.card = c
skill:beforeUse(player, use)
self:useSkill(player, skill, Util.DummyFunc)
return use
end
end
@ -1538,6 +1539,7 @@ function Room:handleUseCardReply(player, data)
if #use.tos == 0 then
use.tos = nil
end
Fk:filterCard(card, player)
use.card = Fk:getCardById(card)
return use
end

View File

@ -203,7 +203,7 @@ local fireAttackSkill = fk.CreateActiveSkill{
local to = room:getPlayerById(cardEffectEvent.to)
if to:isKongcheng() then return end
local showCard = room:askForCard(to, 1, 1, false, self.name, false, nil, "#fire_attack-show:" .. from.id)[1]
local showCard = room:askForCard(to, 1, 1, false, self.name, false, ".|.|.|hand", "#fire_attack-show:" .. from.id)[1]
to:showCards(showCard)
showCard = Fk:getCardById(showCard)

View File

@ -39,7 +39,6 @@ Server::Server(QObject *parent) : QObject(parent) {
&Server::processNewConnection);
udpSocket = new QUdpSocket(this);
udpSocket->bind(9527);
connect(udpSocket, &QUdpSocket::readyRead,
this, &Server::readPendingDatagrams);
@ -95,6 +94,7 @@ Server::~Server() {
bool Server::listen(const QHostAddress &address, ushort port) {
bool ret = server->listen(address, port);
udpSocket->bind(port);
isListening = ret;
return ret;
}
@ -632,13 +632,14 @@ void Server::readPendingDatagrams() {
void Server::processDatagram(const QByteArray &msg, const QHostAddress &addr, uint port) {
if (msg == "fkDetectServer") {
udpSocket->writeDatagram("me", addr, port);
} else if (msg == "fkGetDetail") {
} else if (msg.startsWith("fkGetDetail,")) {
udpSocket->writeDatagram(JsonArray2Bytes(QJsonArray({
FK_VERSION,
getConfig("iconUrl"),
getConfig("description"),
getConfig("capacity"),
players.count(),
msg.sliced(12).constData(),
})), addr, port);
}
udpSocket->flush();

View File

@ -337,7 +337,7 @@ void QmlBackend::detectServer() {
void QmlBackend::getServerInfo(const QString &address) {
QString addr = "127.0.0.1";
ushort port = 9527u;
static const char *ask_str = "fkGetDetail";
static const char *ask_str = "fkGetDetail,";
if (address.contains(QChar(':'))) {
QStringList texts = address.split(QChar(':'));
@ -347,8 +347,10 @@ void QmlBackend::getServerInfo(const QString &address) {
addr = address;
}
udpSocket->writeDatagram(ask_str,
strlen(ask_str),
QByteArray ask(ask_str);
ask.append(address.toLatin1());
udpSocket->writeDatagram(ask, ask.size(),
QHostAddress(addr), port);
}
@ -364,7 +366,6 @@ void QmlBackend::readPendingDatagrams() {
emit notifyUI("ServerDetected", addr.toString());
} else {
auto arr = QJsonDocument::fromJson(data).array();
arr.prepend(addr.toString());
emit notifyUI("GetServerDetail", JsonArray2Bytes(arr));
}
}