Skip to content

Commit

Permalink
Release v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleYang0531 committed Jan 26, 2023
1 parent de3f0c9 commit 02faad6
Show file tree
Hide file tree
Showing 11 changed files with 404 additions and 12 deletions.
63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
- [Sonolus Website](https://sonolus.com/)
- [Sonolus Wiki](https://wiki.sonolus.com/)

## 安装

我们提供对 Windows 用户的安装包,内含 MySQL v5.7.37,下载地址: [Latest Release](https://github.com/LittleYang0531/sonolus-server-cpp/releases/latest)

安装后第一次使用需要**以管理员身份运行**启动菜单里的 `Setup Sonolus Database` 程序,之后就可以启动 `Sonolus Server for Windows` 来启动服务。

导入数据需要运行 `Import Sonolus Data` 程序,按照提示输入相关信息即可。

我们并未提供对 Linux 用户的安装包 ~~(都用 Linux 了相信或多或少还是有一点使用终端的基础了吧)~~,请自行参照下方教程进行构建。

## 构建

### 下载依赖
Expand All @@ -36,10 +46,34 @@ sudo apt install g++ libjsoncpp-dev libmysqlclient-dev libssl-dev -y
g++ main.cpp -o main -lpthread -lcrypto -lssl -ljsoncpp -lmysqlclient -g
```

### 导入数据

以 bandori 的数据包 `bandori.bin` 为例。

```bash
./main import bandori.bin
```

我们提供各官方引擎的数据包下载: [Data Packages for v1.1.1+](https://github.com/LittleYang0531/sonolus-server-cpp/releases/tag/data)

### 运行

```bash
./main
./main serve
```

### 导出数据

以导出名为 `bandori` 的引擎为例

```bash
./main export engine bandori bandori.bin
```

以导出名为 `bandori-#1` 的关卡为例

```bash
./main export level "bandori-#1" bandori1.bin
```

## 配置信息
Expand Down Expand Up @@ -100,6 +134,24 @@ g++ main.cpp -o main -lpthread -lcrypto -lssl -ljsoncpp -lmysqlclient -g
- `GET /particles/{name}`: 显示名为 {name} 的粒子效果信息。
- `GET /engines/{name}`: 显示名为 {name} 的引擎信息。

<!-- ## 数据包格式
**数据格式**
| 域 | 长度 | 内容说明 |
|:-:|:-:|:-:|
| FileNumber | $8$ bytes | 存储数据包文件数 |
| FileChunk | $x$ bytes | 存储各文件数据 |
| SQLCode | $y$ bytes | 存储更新数据库代码 |
**FileChunk 格式**
| 域 | 长度 | 内容说明 |
|:-:|:-:|:-:|
| FileSHA1 | $20$ bytes | 文件 SHA1 码,用于校验文件 |
| FileSize | $8$ bytes | 存储文件大小 |
| FileBuffer | $z$ bytes | 存储文件内容 | -->

## 提示

### 2023.1.21
Expand All @@ -124,6 +176,15 @@ g++ main.cpp -o main -lpthread -lcrypto -lssl -ljsoncpp -lmysqlclient -g

## 更新日志

### v1.1.1 2023.1.26

1. 修复当没有条目时主页面显示 `{{html.xxx}}` 的错误。
2. 修复当数据库中存在 NULL 数据时引起程序退出错误。
3. 新增数据导入功能,并提供 bandori, pjsekai, llsif, taiko, voez, deemo 的数据包。
4. 新增数据导出功能,支持引擎和关卡的导出。
5. 修改服务器启动方式为 `./main serve`
6. 新增应用帮助信息。

### v1.1.0 2023.1.24

1. 修复 Windows 由于缺少 __int64_t 导致的编译错误。
Expand Down
65 changes: 63 additions & 2 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ Use httpd core developed by myself, which also support you to build HTTPS server
- [Sonolus Website](https://sonolus.com/)
- [Sonolus Wiki](https://wiki.sonolus.com/)

## Install

We provide an installation package for Windows users, including MySQL v5.7.37. Download link: [Latest Release](https://github.com/LittleYang0531/sonolus-server-cpp/releases/latest).

The first use after installation requires to run the `Setup Sonolus Database` program in the startup menu **as an administrator**, and then you can run the `Sonolus Server for Windows` to start the service.

To import data, you need to run the `Import Sonolus Data` program and enter relevant information according to the prompts.

We have not provided the installation package for Linux users. Please refer to the following tutorial to build it.

## Building

### Install Dependencies
Expand All @@ -36,12 +46,36 @@ Just enter MySQL Server and import `data.sql`.
g++ main.cpp -o main -lpthread -lcrypto -lssl -ljsoncpp -lmysqlclient -g
```

### Import Data

Take Bandori's data package `bandori.bin` as an example.

```bash
./main import bandori.bin
```

We provide data package download of all official engines: [Data Packages for v1.1.1+](https://github.com/LittleYang0531/sonolus-server-cpp/releases/tag/data)

### Run

```bash
./main
```

### Export Data

Take the export engine named `bandori` as an example

```bash
./main export engine bandori bandori.bin
```

Take the export level named `bandori-#1` as an example

```bash
./main export level "bandori-#1" bandori1.bin
```

## Configuration

- `mysql.hostname`: MySQL Server listen host.
Expand Down Expand Up @@ -100,6 +134,24 @@ g++ main.cpp -o main -lpthread -lcrypto -lssl -ljsoncpp -lmysqlclient -g
- `GET /particles/{name}`: Show information of particle named {name}.
- `GET /engines/{name}`: Show information of engine named {name}.

<!-- ## 数据包格式
**数据格式**
| 域 | 长度 | 内容说明 |
|:-:|:-:|:-:|
| FileNumber | $8$ bytes | 存储数据包文件数 |
| FileChunk | $x$ bytes | 存储各文件数据 |
| SQLCode | $y$ bytes | 存储更新数据库代码 |
**FileChunk 格式**
| 域 | 长度 | 内容说明 |
|:-:|:-:|:-:|
| FileSHA1 | $20$ bytes | 文件 SHA1 码,用于校验文件 |
| FileSize | $8$ bytes | 存储文件大小 |
| FileBuffer | $z$ bytes | 存储文件内容 | -->

## Tips

### 2023.1.21
Expand All @@ -124,13 +176,22 @@ These days, the official wiki website has added an endpoint `/sonolus/authentica

## Upload Log

### v1.1.1 2023.1.26

1. Fixed the error that the main page displays `{{html.xxx}}` when there are no entries.
2. Fixed the program error caused by NULL data in the database.
3. Added data import function and provided data packages of bandori, pjsekai, llsif, taiko, voez and deemo.
4. Added data export function and provided exporting engines and levels.
5. Modified the server startup mode to `./main serve`
6. Added application help information.

### v1.1.0 2023.1.24

1. Fixed Windows version will compiled error caused by missing __int64_t.
2. Fixed the error that the feedbacks of all list apis is the same.
3. Add the recommended display function, which displays 5 works of the same author by default.
4. Add a new homepage and use native js to write it after the official project.
5. Add the detail page of each component, and use native js to write after the official project.
4. Add a new homepage and use native javascript to write it after the official project.
5. Add the detail page of each component, and use native javascript to write after the official project.
6. Add the website internationalization function.

### v1.0.2-2 2023.1.21
Expand Down
46 changes: 40 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@

Json::Value appConfig;
Json::Value i18n, i18n_raw;
int exportLevelId[] = {};
int exportSkinId[] = {};
int exportBackgroundId[] = {};
int exportEffectId[] = {};
int exportParticleId[] = {};
int exportEngineId[] = {};

#include"httpd.h"
#include"html.h"
#include"mysqli.h"
#include"json.h"
#include"encrypt.h"
#include"modules/import.h"
#include"items/Items.h"
#include"sonolus/sonolus.h"
#include"api/import.h"
#include"web/import.h"
#include"modules/export.h"
using namespace std;

int main() {
void invalidUsage(char** argv) {
cerr << "Usage: " << argv[0] << " [command]" << endl;
cerr << "commands: " << endl;
cerr << " help: " << argv[0] << " help" << endl;
cerr << " serve: " << argv[0] << " serve" << endl;
cerr << " import: " << argv[0] << " import [file]" << endl;
cerr << " export: " << argv[0] << " export [level/engine] [name] [file]" << endl;
exit(0);
}

int main(int argc, char** argv) {
app.setopt(LOG_TARGET_TYPE, LOG_TARGET_CONSOLE);
app.setopt(OPEN_DEBUG, true);

Expand All @@ -41,6 +54,27 @@ int main() {
exit(3);
}
loadDefaultVariable();

if (argc < 2) invalidUsage(argv);
if (string(argv[1]) == "import") {
if (argc < 3) invalidUsage(argv);
import(argv[2]);
return 0;
}
else if (string(argv[1]) == "export") {
if (argc < 5) invalidUsage(argv);
if (string(argv[2]) == "level") {
exportLevel(argv[3]);
exportData(argv[4]);
return 0;
} else if (string(argv[2]) == "engine") {
exportEngine(argv[3]);
exportData(argv[4]);
return 0;
} else invalidUsage(argv);
} else if (string(argv[1]) == "help") invalidUsage(argv);
else if (string(argv[1]) != "serve") invalidUsage(argv);

mysql = mysqli_connect(appConfig["mysql.hostname"].asString().c_str(), appConfig["mysql.username"].asString().c_str(),
appConfig["mysql.password"].asString().c_str(), appConfig["mysql.database"].asString().c_str(), appConfig["mysql.port"].asInt());
app.setopt(HTTP_ENABLE_SSL, appConfig["server.enableSSL"].asBool());
Expand Down
File renamed without changes.
Loading

0 comments on commit 02faad6

Please sign in to comment.