Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta53 #122

Merged
merged 64 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
1479feb
beta9
Hoshinonyaruko Jan 26, 2024
4a6f523
beta11
Hoshinonyaruko Jan 26, 2024
8739198
beta11
Hoshinonyaruko Jan 26, 2024
d9e0844
beta13
Hoshinonyaruko Jan 26, 2024
ab96bf7
beta14
Hoshinonyaruko Jan 26, 2024
9b7bf0e
beta12
Hoshinonyaruko Jan 26, 2024
7c66e7d
beta13
Hoshinonyaruko Jan 26, 2024
eb0b186
beta15
Hoshinonyaruko Jan 26, 2024
122de8b
beta16
Hoshinonyaruko Jan 26, 2024
5e4903f
beta17
Hoshinonyaruko Jan 26, 2024
7a82cfb
beta18
Hoshinonyaruko Jan 27, 2024
ecc8263
mergefix
Hoshinonyaruko Jan 27, 2024
d0a0a85
beta19
Hoshinonyaruko Jan 27, 2024
afcb856
beta20
Hoshinonyaruko Jan 27, 2024
fafe0f9
beta20
Hoshinonyaruko Jan 27, 2024
397d4c7
beta21
Hoshinonyaruko Jan 27, 2024
c00e1a8
fixmerge
Hoshinonyaruko Jan 27, 2024
42ed202
add_playermanager_api
Hoshinonyaruko Jan 27, 2024
31a6771
beta22
Hoshinonyaruko Jan 27, 2024
050d359
beta22
Hoshinonyaruko Jan 27, 2024
939e818
beta23
Hoshinonyaruko Jan 28, 2024
19cf927
merge
Hoshinonyaruko Jan 28, 2024
8073f3a
beta24
Hoshinonyaruko Jan 29, 2024
fdd6016
mergechanges
Hoshinonyaruko Jan 29, 2024
b167455
beta25
Hoshinonyaruko Jan 30, 2024
844698b
merge
Hoshinonyaruko Jan 30, 2024
f5c8d82
beta26
Hoshinonyaruko Jan 30, 2024
2d5e94d
merge
Hoshinonyaruko Jan 30, 2024
3076085
beta27
Hoshinonyaruko Jan 30, 2024
a8a67ed
beta28
Hoshinonyaruko Jan 31, 2024
4c954fa
beta28
Hoshinonyaruko Jan 31, 2024
2f9063e
beta28
Hoshinonyaruko Jan 31, 2024
cd6fad7
beta29
Hoshinonyaruko Jan 31, 2024
2651176
beta29
Hoshinonyaruko Jan 31, 2024
265b5e3
beta30
Hoshinonyaruko Jan 31, 2024
8aac47a
beta31
Hoshinonyaruko Feb 2, 2024
a559fa2
beta31
Hoshinonyaruko Feb 2, 2024
f5bb66a
beta32
Hoshinonyaruko Feb 2, 2024
44fac8f
beta33
Hoshinonyaruko Feb 6, 2024
a44ef68
merge
Hoshinonyaruko Feb 6, 2024
e731f93
beta34
Hoshinonyaruko Feb 8, 2024
c8921a1
beta34
Hoshinonyaruko Feb 8, 2024
e6b4a3e
beta35
Hoshinonyaruko Feb 8, 2024
ac77292
merge
Hoshinonyaruko Feb 8, 2024
3992e84
beta35
Hoshinonyaruko Feb 8, 2024
d19fc5c
beta36
Hoshinonyaruko Feb 8, 2024
ff271bc
merge
Hoshinonyaruko Feb 8, 2024
a451334
beta37
Hoshinonyaruko Feb 18, 2024
6e4f28c
beta37
Hoshinonyaruko Feb 18, 2024
89d6c06
beta38
Hoshinonyaruko Feb 18, 2024
75002bc
beta39
Hoshinonyaruko Feb 18, 2024
e808a36
beta40
Hoshinonyaruko Feb 18, 2024
d2d5f4c
beta41
Hoshinonyaruko Feb 25, 2024
a40afd7
beta41
Hoshinonyaruko Feb 25, 2024
5977c8d
beat43
Hoshinonyaruko Mar 2, 2024
0ca7960
beta43
Hoshinonyaruko Mar 2, 2024
44b7bb5
beta45
Hoshinonyaruko Mar 2, 2024
d40d897
beta45
Hoshinonyaruko Mar 2, 2024
18282f6
beta46
Hoshinonyaruko Mar 3, 2024
4c89765
beta47
Hoshinonyaruko Mar 3, 2024
881dd1f
beta50
Hoshinonyaruko Mar 3, 2024
b5a8fbd
beta51
Hoshinonyaruko Mar 3, 2024
74bcb7c
beta52
Hoshinonyaruko Mar 3, 2024
4ef420a
beta53
Hoshinonyaruko Mar 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type Config struct {
EnableBotNotification bool `json:"enableBotNotification"` // 是否开启机器人广播
EnableRebootLater bool `json:"enableRebootLater"` // 是否开启延时关闭&重启
OverrideDLL bool `json:"overrideDLL"` // 是否由palgo中内置的dll覆盖游戏目录的dll
UsePalServerExe bool `json:"usePalserverexe"` // 是否维持传统启动行为
}

// 默认配置
Expand All @@ -91,6 +92,7 @@ var defaultConfig = Config{
EnableUe4Debug: false,
EnableEngineSetting: true,
OverrideDLL: true,
UsePalServerExe: false,
BackupInterval: 1800, // 30 分钟
MemoryCheckInterval: 30, // 30 秒
MemoryUsageThreshold: 80, // 80%
Expand Down
9 changes: 7 additions & 2 deletions front/palworld-front/src/pages/IndexView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
label="是否覆盖dll(不开请自己管理palguard和ue4的dll)"
class="q-my-md"
/>
<q-toggle
v-model="config.usePalserverexe"
label="是否使用Palserverexe启动服务端(开启=有字版,不开启=无字版)"
class="q-my-md"
/>
<q-toggle
v-model="config.enableEngineSetting"
label="是否启用引擎配置,部分电脑修改引擎配置会卡顿,可关闭"
Expand Down Expand Up @@ -1089,7 +1094,7 @@
uin: Number,
});

const players = ref([]);

Check warning on line 1097 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for arm64

'players' is assigned a value but never used

Check warning on line 1097 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for amd64

'players' is assigned a value but never used

Check warning on line 1097 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on windows for amd64

'players' is assigned a value but never used

Check warning on line 1097 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for amd64

'players' is assigned a value but never used

Check warning on line 1097 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for arm64

'players' is assigned a value but never used

const status = ref(null); // 假设 ProcessInfo 是一个对象,这里使用 null 作为初始值

Expand All @@ -1103,11 +1108,11 @@
const showDifficultyTooltip = ref(false);
const showDeathPenaltyTooltip = ref(false);

const toggleTooltip = (type) => {

Check warning on line 1111 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for arm64

'type' is defined but never used

Check warning on line 1111 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for amd64

'type' is defined but never used

Check warning on line 1111 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on windows for amd64

'type' is defined but never used

Check warning on line 1111 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for amd64

'type' is defined but never used

Check warning on line 1111 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for arm64

'type' is defined but never used
showDeathPenaltyTooltip.value = !showDeathPenaltyTooltip.value;
};

const toggleTooltip2 = (type) => {

Check warning on line 1115 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for arm64

'type' is defined but never used

Check warning on line 1115 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for amd64

'type' is defined but never used

Check warning on line 1115 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on windows for amd64

'type' is defined but never used

Check warning on line 1115 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for amd64

'type' is defined but never used

Check warning on line 1115 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for arm64

'type' is defined but never used
showDifficultyTooltip.value = !showDifficultyTooltip.value;
};

Expand Down Expand Up @@ -1189,8 +1194,8 @@
} catch (error) {
console.error('Error saving configuration:', error);
$q.notify({
type: 'negative',
message: '保存配置失败',
type: 'positive',
message: '配置已保存!',
});
}
};
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"github.com/hoshinonyaruko/palworld-go/bot"
"github.com/hoshinonyaruko/palworld-go/config"
"github.com/hoshinonyaruko/palworld-go/status"
"github.com/hoshinonyaruko/palworld-go/sys"
"github.com/hoshinonyaruko/palworld-go/tool"
"github.com/hoshinonyaruko/palworld-go/webui"
Expand Down Expand Up @@ -115,6 +116,8 @@ func main() {
fmt.Println("PalServer.exe exists in the current directory.")
}
}
//还原状态
status.SetManualServerShutdown(false)

// 设置监控和自动重启
supervisor := NewSupervisor(jsonconfig)
Expand Down
19 changes: 12 additions & 7 deletions mod/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ func BuildEmbeddedFilesMap() (map[string]struct{}, error) {
return embeddedFilesPaths, err
}

// RemoveEmbeddedFiles 遍历嵌入文件列表,如果它们存在于指定路径下,则删除它们
// RemoveEmbeddedFiles 遍历嵌入文件列表,如果它们存在于指定路径下且为exe或dll文件,则删除它们
func RemoveEmbeddedFiles(path string) error {
// 动态构建嵌入文件的路径映射
embeddedFilesPaths, err := BuildEmbeddedFilesMap()
if err != nil {
return err
Expand All @@ -84,11 +83,17 @@ func RemoveEmbeddedFiles(path string) error {
relativePath := strings.TrimPrefix(embeddedPath, "embeds/")
externalPath := filepath.Join(path, relativePath)

// 检查文件或目录是否存在于文件系统中
if _, err := os.Stat(externalPath); err == nil {
// 如果存在,删除文件或目录
if err := os.RemoveAll(externalPath); err != nil {
return err
// 获取文件扩展名
ext := filepath.Ext(externalPath)

// 如果文件扩展名为.exe或.dll,则尝试删除
if ext == ".exe" || ext == ".dll" {
// 检查文件是否存在
if _, err := os.Stat(externalPath); err == nil {
// 如果存在,删除文件
if err := os.Remove(externalPath); err != nil {
return err
}
}
}
}
Expand Down
44 changes: 27 additions & 17 deletions sys/restart_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,34 @@ func RestartService(config config.Config) {
if config.WorldSettings.RconEnabled {
args = append(args, "-rcon")
}

args = append(args, config.ServerOptions...) // 添加GameWorldSettings参数

// 执行启动命令
log.Printf("启动命令: %s %s", exePath, strings.Join(args, " "))

cmd := exec.Command(exePath, args...)
cmd.Dir = config.GamePath // 设置工作目录为游戏路径

// 启动进程
if err := cmd.Start(); err != nil {
log.Printf("Failed to restart game server: %v", err)
// 添加GameWorldSettings参数
args = append(args, config.ServerOptions...)

if config.GameService && config.GameServiceName != "" {
cmd := exec.Command("sudo", "systemctl", "restart", config.GameServiceName)
// 启动进程
if err := cmd.Start(); err != nil {
log.Printf("Failed to restart game server: %v", err)
} else {
log.Printf("Game server restarted successfully")
}
} else {
log.Printf("Game server restarted successfully")
// 执行启动命令
log.Printf("启动命令: %s %s", exePath, strings.Join(args, " "))

cmd := exec.Command(exePath, args...)
cmd.Dir = config.GamePath // 设置工作目录为游戏路径

// 启动进程
if err := cmd.Start(); err != nil {
log.Printf("Failed to restart game server: %v", err)
} else {
log.Printf("Game server restarted successfully")
}

// 获取并打印 PID
log.Printf("Game server started successfully with PID %d", cmd.Process.Pid)
status.SetGlobalPid(cmd.Process.Pid)
}

// 获取并打印 PID
log.Printf("Game server started successfully with PID %d", cmd.Process.Pid)
status.SetGlobalPid(cmd.Process.Pid)

}
69 changes: 59 additions & 10 deletions sys/restart_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package sys

import (
"bytes"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -224,23 +225,26 @@ func RestartService(config config.Config) {
}
//exePath = filepath.Join(config.GamePath, "Pal", "Binaries", "Win64", "PalServerInject.exe")
//只要文件存在就会自动注入,无需PalServerInject.exe了
exePath = filepath.Join(config.GamePath, "Pal", "Binaries", "Win64", "PalServer-Win64-Test-Cmd.exe")

} else {
//在这里加一个CheckAndWriteFiles的删除版本(因为只要文件存在就会自动注入)
err := mod.RemoveEmbeddedFiles(filepath.Join(config.GamePath, "Pal", "Binaries", "Win64"))
if err != nil {
log.Printf("Failed to remove files: %v", err)
return
}
}
//自由选择有字版 无字版
if config.UsePalServerExe {
exePath = filepath.Join(config.GamePath, "PalServer.exe")
args = []string{
"Pal",
"-RconEnabled=True",
fmt.Sprintf("-AdminPassword=%s", config.WorldSettings.AdminPassword),
fmt.Sprintf("-port=%d", config.WorldSettings.PublicPort),
fmt.Sprintf("-players=%d", config.WorldSettings.ServerPlayerMaxNum),
}
} else {
err := mod.RemoveEmbeddedFiles(filepath.Join(config.GamePath, "Pal", "Binaries", "Win64"))
if err != nil {
log.Printf("Failed to remove files: %v", err)
return
}
//在这里加一个CheckAndWriteFiles的删除版本(因为只要文件存在就会自动注入)
exePath = filepath.Join(config.GamePath, "Pal", "Binaries", "Win64", "PalServer-Win64-Test-Cmd.exe")
//exePath = "\"" + exePath + "\""
args = []string{
"Pal",
"-RconEnabled=True",
Expand Down Expand Up @@ -290,8 +294,53 @@ func RestartService(config config.Config) {

// 获取并打印 PID
log.Printf("Game server started successfully with PID %d", cmd.Process.Pid)
status.SetGlobalPid(cmd.Process.Pid)
//使用PalServer.exe启动获取到的pid不一致
if config.UsePalServerExe {
// PowerShell脚本模板
psScript := `
$processName = "%s"
$configGamePath = "%s"
$matchingProcesses = Get-WmiObject Win32_Process | Where-Object { $_.Name -eq $processName }
foreach ($process in $matchingProcesses) {
$commandLine = $process.CommandLine
if ($commandLine -and $commandLine.Contains($configGamePath)) {
Write-Output $process.ProcessId
break
}
}
`
// 使用config.GamePath和processName填充PowerShell脚本模板
psScriptFormatted := fmt.Sprintf(psScript, "PalServer-Win64-Test-Cmd.exe", config.GamePath)

// 调用PowerShell执行脚本
cmd := exec.Command("powershell", "-Command", psScriptFormatted)
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
fmt.Println("Failed to execute PowerShell script:", err)
return
}

output := strings.TrimSpace(out.String())
if output == "" {
fmt.Println("No matching process found")
return
}

fmt.Println("Matching Real Server PID:", output)

// 将output字符串转换为int
pid, err := strconv.Atoi(output)
if err != nil {
fmt.Println("Error converting PID from string to int:", err)
return
}

status.SetGlobalPid(pid)
} else {
status.SetGlobalPid(cmd.Process.Pid)
}
}

// ConfigureUE4DebugSettings 根据config.EnableUe4Debug的值配置UE4SS-settings.ini文件
Expand Down
34 changes: 17 additions & 17 deletions webui/dist2/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/assets/favicon-orkAu1xw.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Palworld Server Configuration Generator</title>
<script type="module" crossorigin src="/assets/index-uaZDSxZ1.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-M1eIIqPy.css">
</head>
<body>
<div id="root"></div>
</body>
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" href="/assets/favicon-orkAu1xw.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Palworld Server Configuration Generator</title>
<script type="module" crossorigin src="/assets/index-uaZDSxZ1.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-M1eIIqPy.css">
</head>

<body>
<div id="root"></div>

</body>

</html>
Loading