Skip to content

Commit

Permalink
Merge 2d5e94d into d6795f8
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko authored Jan 30, 2024
2 parents d6795f8 + 2d5e94d commit c1ee0c8
Show file tree
Hide file tree
Showing 11 changed files with 626 additions and 32 deletions.
360 changes: 356 additions & 4 deletions config/config.go

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions front/palworld-front/src/pages/IndexView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<q-tabs v-model="tab" align="justify" scrollable>
<q-tab name="guard" label="守护配置修改" />
<q-tab name="server" label="服务端配置修改" />
<q-tab name="engine" label="引擎配置修改" />
<q-tab name="command" label="服务器指令" />
<q-tab name="player-manage" label="玩家管理" />
<q-tab name="advanced" label="SAV修改" @click="redirectToSav" />
Expand Down Expand Up @@ -686,6 +687,140 @@
/>
</div>
</q-page>
<q-page padding v-if="tab === 'engine'">
<!-- 引擎配置修改页面内容 -->
<div class="q-gutter-xs q-mt-md">
<div class="text-subtitle2">引擎配置修改</div>
<div class="text-subtitle3">默认已为您载入最佳配置</div>
<div class="text-subtitle4">请在了解的情况下修改</div>

<!-- 玩家互联网速度配置 -->
<q-input
filled
v-model.number="config.engine.player.ConfiguredInternetSpeed"
type="number"
label="玩家互联网速度 (字节/秒)"
hint="设置假定的玩家互联网速度。高值可以减少带宽限制的可能性。"
class="q-my-md"
/>

<!-- 玩家局域网速度配置 -->
<q-input
filled
v-model.number="config.engine.player.ConfiguredLanSpeed"
type="number"
label="玩家局域网速度 (字节/秒)"
hint="设置局域网速度,确保局域网玩家可以利用最大的网络容量。"
class="q-my-md"
/>

<!-- 最大客户端数据传输速率 -->
<q-input
filled
v-model.number="config.engine.socketsubsystemepic.MaxClientRate"
type="number"
label="最大客户端数据传输速率 (字节/秒)"
hint="为所有连接设置每个客户端的最大数据传输速率,设置高值以防止数据上限。"
class="q-my-md"
/>

<!-- 特别针对互联网客户端的最大数据传输速率 -->
<q-input
filled
v-model.number="
config.engine.socketsubsystemepic.MaxInternetClientRate
"
type="number"
label="互联网客户端最大数据传输速率 (字节/秒)"
hint="特别针对互联网客户端,允许高容量数据传输而不受限制。"
class="q-my-md"
/>

<!-- 游戏引擎平滑帧率设置 -->
<q-toggle
v-model="config.engine.engine.bSmoothFrameRate"
label="启用平滑帧率"
hint="使游戏引擎平滑帧率波动,以获得更一致的游戏体验。"
class="q-my-md"
/>

<!-- 禁用固定帧率设置 -->
<q-toggle
v-model="config.engine.engine.bUseFixedFrameRate"
label="启用动态帧率"
hint="动态帧率,允许游戏服务端动态调整帧率以获得最佳性能。"
class="q-my-md"
/>

<!-- 最低可接受帧率设置 -->
<q-input
filled
v-model.number="config.engine.engine.MinDesiredFrameRate"
type="number"
label="最低可接受帧率"
hint="指定最低可接受帧率,确保游戏至少以这个帧率流畅运行。"
class="q-my-md"
/>

<!-- 平滑帧率范围的下限 -->
<q-input
filled
v-model.number="
config.engine.engine.SmoothedFrameRateRange.LowerBound.Value
"
type="number"
label="平滑帧率范围下限"
hint="设置平滑的目标帧率下限。"
class="q-my-md"
/>

<!-- 平滑帧率范围的上限 -->
<q-input
filled
v-model.number="
config.engine.engine.SmoothedFrameRateRange.UpperBound.Value
"
type="number"
label="平滑帧率范围上限"
hint="设置平滑的目标帧率上限。"
class="q-my-md"
/>

<!-- 固定帧率配置 -->
<q-input
filled
v-model.number="config.engine.engine.FixedFrameRate"
type="number"
label="固定帧率"
hint="设置固定帧率的值(仅当启用固定帧率时有效)。"
class="q-my-md"
/>

<!-- 客户端更新频率设置 -->
<q-input
filled
v-model.number="config.engine.engine.NetClientTicksPerSecond"
type="number"
label="客户端更新频率 (次/秒)"
hint="增加客户端的更新频率,提高响应性并减少延迟。"
class="q-my-md"
/>
<!-- 保存按钮 -->
<q-btn
color="primary"
label="保存"
@click="saveConfig"
class="q-mt-md"
/>
<!-- 重启服务端按钮 -->
<q-btn
color="secondary"
label="重启服务端"
@click="restartServer"
class="q-mt-md"
/>
</div>
</q-page>
<q-page padding v-if="tab === 'command'">
<div class="q-pa-md">
<div class="text-h6">服务器指令页面</div>
Expand Down
20 changes: 20 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,32 @@ func main() {
for range saveSettingsTicker.C {
// 定时保存配置
jsonconfig := config.ReadConfigv2()
//保存帕鲁服务端配置
err := config.WriteGameWorldSettings(&jsonconfig, jsonconfig.WorldSettings)
if err != nil {
fmt.Println("Error writing game world settings:", err)
} else {
fmt.Println("Game world settings saved successfully.")
}
//保存引擎配置
err = config.WriteEngineSettings(&jsonconfig, jsonconfig.Engine)
if err != nil {
fmt.Println("Error writing Engine settings:", err)
} else {
fmt.Println("Engine settings saved successfully.")
}
}
}()
}

if jsonconfig.RestartInterval != 0 {
restartInterval := time.Duration(jsonconfig.RestartInterval) * time.Second
restartTicker := time.NewTicker(restartInterval)
go func() {
defer restartTicker.Stop()
for range restartTicker.C {
// 定时推送并重启 120秒 发数组第一条信息
tool.Shutdown(jsonconfig, "120", jsonconfig.RegularMessages[0])
}
}()
}
Expand Down
Binary file modified mod/embeds/PalServerInject.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion mod/embeds/UE4SS-settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ GuiConsoleFontScaling = 1
; The API that will be used to render the GUI debug window.
; Valid values (case-insensitive): dx11, d3d11, opengl
; Default: opengl
GraphicsAPI = opengl
GraphicsAPI = dx11

; How many objects to put in each group in the live view.
; A lower number means more groups but less lag when a group is open.
Expand Down
Binary file added mod/embeds/pal-plugin-loader.dll
Binary file not shown.
Binary file removed mod/embeds/pal-srv-loader-win.dll
Binary file not shown.
103 changes: 76 additions & 27 deletions mod/mod.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package mod

import (
"crypto/md5"
"embed"
"encoding/hex"
"io"
"io/fs"
"os"
"path/filepath"
Expand All @@ -11,7 +14,7 @@ import (
//go:embed embeds/*
var embeddedFiles embed.FS

// CheckAndWriteFiles 检查嵌入文件是否存在于指定路径下,如果不存在,则写出这些文件
// CheckAndWriteFiles 检查嵌入文件是否存在于指定路径下,对于exe和dll文件,如果不存在或者MD5不同,则写出;对于其他文件,如果不存在,则写出
func CheckAndWriteFiles(path string) error {
return fs.WalkDir(embeddedFiles, "embeds", func(embeddedPath string, d fs.DirEntry, err error) error {
if err != nil {
Expand All @@ -29,33 +32,79 @@ func CheckAndWriteFiles(path string) error {
// 构建在外部文件系统中的路径
externalPath := filepath.Join(path, relativePath)

// 检查文件是否存在
if _, err := os.Stat(externalPath); os.IsNotExist(err) {
// 文件不存在,需要写出
if d.IsDir() {
// 创建目录
if err := os.MkdirAll(externalPath, os.ModePerm); err != nil {
return err
}
} else {
// 读取嵌入的文件内容
data, err := fs.ReadFile(embeddedFiles, embeddedPath)
if err != nil {
return err
}

// 确保目标文件夹存在
if err := os.MkdirAll(filepath.Dir(externalPath), os.ModePerm); err != nil {
return err
}

// 写出文件
if err := os.WriteFile(externalPath, data, os.ModePerm); err != nil {
return err
}
if d.IsDir() {
// 如果是目录,则创建(如果不存在)
return os.MkdirAll(externalPath, os.ModePerm)
} else {
// 处理文件
return processFile(embeddedPath, externalPath)
}
})
}

// processFile 处理单个文件:根据文件类型和MD5决定是否写出
func processFile(embeddedPath, externalPath string) error {
// 检查文件类型
ext := strings.ToLower(filepath.Ext(externalPath))
isExecutableOrDLL := ext == ".exe" || ext == ".dll"

// 读取嵌入的文件内容
embeddedData, err := fs.ReadFile(embeddedFiles, embeddedPath)
if err != nil {
return err
}

// 对于exe和dll文件,比较MD5,如果不同则写出;对于其他文件类型,如果文件不存在,则写出
if isExecutableOrDLL {
// 计算嵌入文件的MD5
embeddedMD5 := calculateMD5(embeddedData)

// 检查文件是否存在并比较MD5
existingMD5, err := fileMD5(externalPath)
if err == nil {
// 如果MD5相同,则跳过写出
if existingMD5 == embeddedMD5 {
return nil
}
} // 如果文件不存在或无法读取MD5,则继续写出
} else {
// 对于非exe和dll文件,如果文件已存在,则跳过
if _, err := os.Stat(externalPath); err == nil {
return nil
}
}

return nil
})
// 确保目标文件夹存在
if err := os.MkdirAll(filepath.Dir(externalPath), os.ModePerm); err != nil {
return err
}

// 写出文件
return os.WriteFile(externalPath, embeddedData, os.ModePerm)
}

// calculateMD5 计算数据的MD5值
func calculateMD5(data []byte) string {
hash := md5.Sum(data)
return hex.EncodeToString(hash[:])
}

// fileMD5 计算文件的MD5值
func fileMD5(filePath string) (string, error) {
file, err := os.Open(filePath)
if err != nil {
if os.IsNotExist(err) {
// 如果文件不存在,返回空字符串和nil错误
return "", nil
}
return "", err
}
defer file.Close()

hash := md5.New()
if _, err := io.Copy(hash, file); err != nil {
return "", err
}

return hex.EncodeToString(hash.Sum(nil)), nil
}
Binary file added pic/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ However, you are free to use the built-in web page translation features of vario

Should you encounter any issues, please feel free to submit an issue in any language.

交流群:955320532 587997911

本项目的webui特别对移动端设备进行优化,手机使用更轻松
(老版本iossafari 如果遇到按钮点不动刷新页面再点即可)

Expand Down Expand Up @@ -118,13 +120,42 @@ webui默认地址:http://127.0.0.1:52000

![机器人管理](pic/10.png)

![引擎配置管理](pic/11.png)

## 兼容性
windows通过了测试,linux有待测试

## RCON发送中文

内置了

https://github.com/VeroFess/PalWorld-Server-Unoffical-Api/releases/tag/previev-0.0.2

开启-守护配置修改-自动注入DLL 可在palworld命令行使用 Broadcast 中文

完全是得益于VeroFess的开发,palgo面板只是自动做了载入。

## 场景支持

在手机上痛快的操作和管理服务器,当管理不再手忙脚乱。

内存不足的时候,通过rcon通知服务器成员,然后重启服务器

通过调用微软的rammap释放无用内存,并将有用内存转移至虚拟内存,实现一次释放50%+内存

## 贴心提示

如果启动自动注入UE4SS和可输入命令控制台DLL后游戏服务端无法启动

请定位到"\PalServer\Pal\Binaries\Win64\UE4SS-settings.ini"

打开,定位到GraphicsAPI,修改为dx11
; The API that will be used to render the GUI debug window.

; Valid values (case-insensitive): dx11, d3d11, opengl

; Default: opengl

GraphicsAPI = dx11

或设置Debug 配置项 3个值 全部为0
7 changes: 7 additions & 0 deletions webui/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ func HandleSaveJSON(c *gin.Context, cfg config.Config) {
fmt.Println("Game world settings saved successfully.")
}

err = config.WriteEngineSettings(&newConfig, newConfig.Engine)
if err != nil {
fmt.Println("Error writing Engine settings:", err)
} else {
fmt.Println("Engine settings saved successfully.")
}

c.JSON(http.StatusOK, gin.H{"message": "Config updated successfully"})

//重启自身 很快 唰的一下
Expand Down

0 comments on commit c1ee0c8

Please sign in to comment.