Miscfix (#156)
- 在md5计算中将qml文件夹改名为Fk - 修复了Linux每次启动都复制文件 - 修复单机游戏刷手气卡时走小道会卡死 - 服主退出大厅时会关闭服务器(伪热更新) - 修复重连/旁观时武将名不显示
This commit is contained in:
parent
2acec5f20a
commit
ead6de967f
|
@ -203,8 +203,8 @@ Item {
|
|||
icon.name: "application-exit"
|
||||
onClicked: {
|
||||
toast.show("Goodbye.");
|
||||
Backend.quitLobby();
|
||||
mainStack.pop();
|
||||
Backend.quitLobby();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,16 @@ local function discardInit(room, player)
|
|||
end
|
||||
end
|
||||
|
||||
local function checkNoHuman(room)
|
||||
for _, p in ipairs(room.players) do
|
||||
-- TODO: trust
|
||||
if p.serverplayer:getStateString() == "online" then
|
||||
return
|
||||
end
|
||||
end
|
||||
room:gameOver("")
|
||||
end
|
||||
|
||||
GameEvent.functions[GameEvent.DrawInitial] = function(self)
|
||||
local room = self.room
|
||||
|
||||
|
@ -98,6 +108,8 @@ GameEvent.functions[GameEvent.DrawInitial] = function(self)
|
|||
break
|
||||
end
|
||||
|
||||
checkNoHuman(room)
|
||||
|
||||
coroutine.yield("__handleRequest", (remainTime - elapsed) * 1000)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ local function tellRoomToObserver(self, player)
|
|||
player:doNotify("EnterRoom", json.encode{
|
||||
#self.players, self.timeout, self.settings
|
||||
})
|
||||
player:doNotify("StartGame", "")
|
||||
|
||||
-- send player data
|
||||
for _, p in ipairs(self:getOtherPlayers(observee, true, true)) do
|
||||
|
|
|
@ -273,6 +273,7 @@ function ServerPlayer:reconnect()
|
|||
self:doNotify("EnterRoom", json.encode{
|
||||
#room.players, room.timeout, room.settings,
|
||||
})
|
||||
self:doNotify("StartGame", "")
|
||||
room:notifyProperty(self, self, "role")
|
||||
|
||||
-- send player data
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
Client *ClientInstance;
|
||||
ClientPlayer *Self;
|
||||
|
||||
static ClientPlayer dummyPlayer(0, nullptr);
|
||||
|
||||
Client::Client(QObject *parent) : QObject(parent), callback(0) {
|
||||
ClientInstance = this;
|
||||
Self = new ClientPlayer(0, this);
|
||||
|
@ -27,6 +29,9 @@ Client::Client(QObject *parent) : QObject(parent), callback(0) {
|
|||
|
||||
Client::~Client() {
|
||||
ClientInstance = nullptr;
|
||||
// Self->deleteLater();
|
||||
Self = nullptr;
|
||||
Backend->getEngine()->rootContext()->setContextProperty("Self", &dummyPlayer);
|
||||
lua_close(L);
|
||||
router->getSocket()->disconnectFromHost();
|
||||
router->getSocket()->deleteLater();
|
||||
|
|
|
@ -215,8 +215,6 @@ QString calcFileMD5() {
|
|||
writeDirMD5(flist, "packages", "*.qml");
|
||||
writeDirMD5(flist, "packages", "*.js");
|
||||
writeDirMD5(flist, "lua", "*.lua");
|
||||
writeDirMD5(flist, "qml", "*.qml");
|
||||
writeDirMD5(flist, "qml", "*.js");
|
||||
writeDirMD5(flist, "Fk", "*.qml");
|
||||
writeDirMD5(flist, "Fk", "*.js");
|
||||
|
||||
|
|
|
@ -85,12 +85,12 @@ static void prepareForLinux() {
|
|||
const char *home = getenv("HOME");
|
||||
if (!strcmp(buf, "/usr/bin/FreeKill")) {
|
||||
system("mkdir -p ~/.local/share/FreeKill");
|
||||
installFkAssets("/usr/share/FreeKill", QString("%1/.local/share").arg(home));
|
||||
installFkAssets("/usr/share/FreeKill", QString("%1/.local/share/FreeKill").arg(home));
|
||||
chdir(home);
|
||||
chdir(".local/share/FreeKill");
|
||||
} else if (!strcmp(buf, "/usr/local/bin/FreeKill")) {
|
||||
system("mkdir -p ~/.local/share/FreeKill");
|
||||
installFkAssets("/usr/local/share/FreeKill", QString("%1/.local/share").arg(home));
|
||||
installFkAssets("/usr/local/share/FreeKill", QString("%1/.local/share/FreeKill").arg(home));
|
||||
chdir(home);
|
||||
chdir(".local/share/FreeKill");
|
||||
}
|
||||
|
|
|
@ -52,11 +52,11 @@ Server::Server(QObject *parent) : QObject(parent) {
|
|||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
if (!this->isListening) {
|
||||
return;
|
||||
}
|
||||
QThread::sleep(2);
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
foreach (auto p, this->players.values()) {
|
||||
|
@ -75,6 +75,12 @@ Server::~Server() {
|
|||
isListening = false;
|
||||
ServerInstance = nullptr;
|
||||
m_lobby->deleteLater();
|
||||
foreach (auto room, idle_rooms) {
|
||||
room->deleteLater();
|
||||
}
|
||||
foreach (auto room, rooms) {
|
||||
room->deleteLater();
|
||||
}
|
||||
sqlite3_close(db);
|
||||
RSA_free(rsa);
|
||||
}
|
||||
|
@ -390,13 +396,13 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name,
|
|||
|
||||
void Server::onRoomAbandoned() {
|
||||
Room *room = qobject_cast<Room *>(sender());
|
||||
if (room->isRunning()) {
|
||||
room->wait();
|
||||
}
|
||||
room->gameOver();
|
||||
rooms.remove(room->getId());
|
||||
updateRoomList();
|
||||
// room->deleteLater();
|
||||
if (room->isRunning()) {
|
||||
room->wait();
|
||||
}
|
||||
idle_rooms.push(room);
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << rooms.size() << "running room(s)," << idle_rooms.size()
|
||||
|
|
|
@ -108,9 +108,9 @@ void QmlBackend::joinServer(QString address) {
|
|||
|
||||
void QmlBackend::quitLobby() {
|
||||
if (ClientInstance)
|
||||
delete ClientInstance;
|
||||
// if (ServerInstance)
|
||||
// delete ServerInstance;
|
||||
ClientInstance->deleteLater();
|
||||
if (ServerInstance)
|
||||
ServerInstance->deleteLater();
|
||||
}
|
||||
|
||||
void QmlBackend::emitNotifyUI(const QString &command, const QString &jsonData) {
|
||||
|
@ -120,6 +120,7 @@ void QmlBackend::emitNotifyUI(const QString &command, const QString &jsonData) {
|
|||
QString QmlBackend::translate(const QString &src) {
|
||||
if (!ClientInstance)
|
||||
return src;
|
||||
|
||||
lua_State *L = ClientInstance->getLuaState();
|
||||
lua_getglobal(L, "Translate");
|
||||
auto bytes = src.toUtf8();
|
||||
|
@ -172,6 +173,7 @@ void QmlBackend::pushLuaValue(lua_State *L, QVariant v) {
|
|||
|
||||
QString QmlBackend::callLuaFunction(const QString &func_name,
|
||||
QVariantList params) {
|
||||
if (!ClientInstance) return "{}";
|
||||
lua_State *L = ClientInstance->getLuaState();
|
||||
lua_getglobal(L, func_name.toLatin1().data());
|
||||
|
||||
|
|
Loading…
Reference in New Issue