From bdfcf805e493dcc924d5fafd0863f25769bf5edd Mon Sep 17 00:00:00 2001 From: YoumuKon <38815081+YoumuKon@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:42:06 +0800 Subject: [PATCH] fix (#358) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复了装备牌格式报错的bug - 修复了副将相关bug --- CHANGELOG.md | 7 +++++++ CMakeLists.txt | 2 +- Fk/Pages/RoomLogic.js | 4 ++-- Fk/util.js | 2 +- android/AndroidManifest.xml | 4 ++-- lua/core/skill.lua | 2 +- lua/server/events/usecard.lua | 5 ++--- lua/server/room.lua | 33 +++++++++++++++++++++++++++++++-- src/server/serverplayer.cpp | 4 ++++ 9 files changed, 51 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62feda30..e58b0f82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # ChangeLog +## v0.4.18 + +- 修复掉线仍在读条的bug +- 修复国战单亮副将导致UI失常的bug + +___ + ## v0.4.16 & v0.4.17 在引入freekill-core之后的第一次版本更新,甚至无法保证这次更新是否正常 diff --git a/CMakeLists.txt b/CMakeLists.txt index cfcfbf2f..da082a00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.16) -project(FreeKill VERSION 0.4.17) +project(FreeKill VERSION 0.4.18) add_definitions(-DFK_VERSION=\"${CMAKE_PROJECT_VERSION}\") find_package(Qt6 REQUIRED COMPONENTS diff --git a/Fk/Pages/RoomLogic.js b/Fk/Pages/RoomLogic.js index 00b6f30f..a49e60aa 100644 --- a/Fk/Pages/RoomLogic.js +++ b/Fk/Pages/RoomLogic.js @@ -522,7 +522,7 @@ function doIndicate(from, tos) { function getPlayerStr(playerid) { const photo = getPhoto(playerid); - if (photo.general === "anjiang" && (photo.deputyGeneral === "anjiang" || !p.deputyGeneral)) { + if (photo.general === "anjiang" && (photo.deputyGeneral === "anjiang" || !photo.deputyGeneral)) { return luatr("seat#" + photo.seatNumber); } @@ -755,7 +755,7 @@ function updateSelectedTargets(playerid, selected) { roomScene.resetPrompt(); // update prompt due to selected_targets const prompt = lcall("ActiveSkillPrompt", dashboard.pending_skill !== "" ? dashboard.pending_skill: lcall("GetCardSkill", card), - dashboard.pending_skill !== "" ? dashboard.pendings : [card], + dashboard.pending_skill !== "" ? dashboard.pendings : card, selected_targets); if (prompt !== "") { roomScene.setPrompt(Util.processPrompt(prompt)); diff --git a/Fk/util.js b/Fk/util.js index 40273a7d..4cd65430 100644 --- a/Fk/util.js +++ b/Fk/util.js @@ -14,7 +14,7 @@ function convertNumber(number) { function getPlayerStr(playerid) { const photo = getPhoto(playerid); - if (photo.general === "anjiang" && (photo.deputyGeneral === "anjiang" || !p.deputyGeneral)) { + if (photo.general === "anjiang" && (photo.deputyGeneral === "anjiang" || !photo.deputyGeneral)) { return luatr("seat#" + photo.seatNumber); } diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 9155809d..de717dd4 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -3,8 +3,8 @@ + android:versionCode="418" + android:versionName="0.4.18"> diff --git a/lua/core/skill.lua b/lua/core/skill.lua index 000699d7..79967807 100644 --- a/lua/core/skill.lua +++ b/lua/core/skill.lua @@ -94,7 +94,7 @@ end ---@return boolean function Skill:isEquipmentSkill(player) if player then - local filterSkills = Fk:currentRoom().status_skills[FilterSkill] + local filterSkills = Fk:currentRoom().status_skills[FilterSkill] or Util.DummyTable for _, filter in ipairs(filterSkills) do local result = filter:equipSkillFilter(self, player) if result then diff --git a/lua/server/events/usecard.lua b/lua/server/events/usecard.lua index 4e79b134..03cea326 100644 --- a/lua/server/events/usecard.lua +++ b/lua/server/events/usecard.lua @@ -355,9 +355,8 @@ function CardEffect:main() local logic = room.logic for _, event in ipairs({ fk.PreCardEffect, fk.BeforeCardEffect, fk.CardEffecting, fk.CardEffectFinished }) do - local user = cardEffectEvent.from and room:getPlayerById(cardEffectEvent.from) or nil if cardEffectEvent.isCancellOut then - if logic:trigger(fk.CardEffectCancelledOut, user, cardEffectEvent) then + if logic:trigger(fk.CardEffectCancelledOut, room:getPlayerById(cardEffectEvent.from), cardEffectEvent) then cardEffectEvent.isCancellOut = false else logic:breakEvent() @@ -379,7 +378,7 @@ function CardEffect:main() end if event == fk.PreCardEffect then - if cardEffectEvent.from and logic:trigger(event, room:getPlayerById(cardEffectEvent.from), cardEffectEvent) then + if logic:trigger(event, room:getPlayerById(cardEffectEvent.from), cardEffectEvent) then if cardEffectEvent.to then cardEffectEvent.nullifiedTargets = cardEffectEvent.nullifiedTargets or {} table.insert(cardEffectEvent.nullifiedTargets, cardEffectEvent.to) diff --git a/lua/server/room.lua b/lua/server/room.lua index 84888492..203c6e98 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -160,6 +160,25 @@ function Room:makeGeneralPile() return true end +-- 因为现在已经不是轮询了,加上有点难分析 +-- 选择开摆 +function Room:isReady() + -- 因为delay函数而延时:判断延时是否已经结束。 + -- 注意整个delay函数的实现都搬到这来了,delay本身只负责挂起协程了。 + --[[ + if self.in_delay then + local rest = self.delay_duration - (os.getms() - self.delay_start) / 1000 + if rest <= 50 then + self.in_delay = false + return true + end + return false, rest + end + --]] + return true +end + +--[[ -- 供调度器使用的函数,用来指示房间是否就绪。 -- 如果没有就绪的话,可能会返回第二个值来告诉调度器自己还有多久就绪。 function Room:isReady() @@ -197,6 +216,7 @@ function Room:isReady() end return ret, (rest and rest > 1) and rest or nil end +--]] function Room:checkNoHuman(chkOnly) if #self.players == 0 then return end @@ -920,6 +940,10 @@ end --- 延迟一段时间。 ---@param ms integer @ 要延迟的毫秒数 function Room:delay(ms) + local start = os.getms() + self.delay_start = start + self.delay_duration = ms + self.in_delay = true self.room:delay(ms) coroutine.yield("__handleRequest", ms) end @@ -2115,9 +2139,14 @@ function Room:askForGuanxing(player, cards, top_limit, bottom_limit, customNotif local command = "AskForGuanxing" self:notifyMoveFocus(player, customNotify or command) local max_top = top_limit and top_limit[2] or #cards - local card_map = {table.slice(cards, 1, max_top + 1)} + local card_map = {} + if max_top > 0 then + table.insert(card_map, table.slice(cards, 1, max_top + 1)) + else + table.insert(card_map, {}) + end if max_top < #cards then - table.insert(card_map, table.slice(cards, max_top)) + table.insert(card_map, table.slice(cards, max_top + 1)) end local data = { prompt = "", diff --git a/src/server/serverplayer.cpp b/src/server/serverplayer.cpp index 38132990..902c3d34 100644 --- a/src/server/serverplayer.cpp +++ b/src/server/serverplayer.cpp @@ -199,6 +199,10 @@ void ServerPlayer::onDisconnected() { deleteLater(); return; } + if (room->getThread()) { + // && thinking()) { + room->getThread()->wakeUp(room->getId()); + } setState(Player::Offline); setSocket(nullptr); // TODO: add a robot