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