Skip to content

Commit

Permalink
Release v1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleYang0531 committed Feb 11, 2023
1 parent 55d03c1 commit 58813c5
Show file tree
Hide file tree
Showing 62 changed files with 963 additions and 109 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Sonolus Server for C++
<p align="center"><img src="http://pic.littleyang.ml/sonolus-server-screenshot/favicon.png"/></p>

[English](./README_en.md) [简体中文](./README.md)
<h1 align="center">Sonolus Server for C++</h1>

<p align="center"><a href="./README_en.md">English</a>&nbsp; <a href="./README.md">简体中文</a></p>

使用 C++ 与 MySQL 开发的一个适用于 Sonolus 的 api 服务器,您可以用于测试您自己的引擎或自己构建一个 Sonolus 服务。

Expand Down Expand Up @@ -272,9 +274,21 @@ string levelSearch(map<string, string> $_GET) {
- [openssl/openssl](https://github.com/openssl/openssl)
- [jquery/jquery](https://github.com/jquery/jquery)
- [dankogai/js-base64](https://github.com/dankogai/js-base64)
- [lyoj-dev/webserver](https://github.com/lyoj-dev/webserver)
## 更新日志
### v1.1.3 2023.2.11
1. 修复当 list 页面没有条目时显示 `{{html.xxx}}` 的错误。
2. 彻底修复由于客户端长连接不发送信息导致的内存爆炸。
3. 新增各组件 list 页面对搜索条件的显示。
4. 修复链接跳转时动画生硬的问题。
5. 修复读取搜索配置文件时读取出错的问题。
6. 修复各组件 list 页面搜索链接无法使用的问题。
7. 修复服务器标题无法显示的问题。
8. 新增各组件搜索页面。
### v1.1.2 2023.2.5
1. 新增 WebServer Core 对监听地址的显示。
Expand Down
18 changes: 16 additions & 2 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Sonolus Server for C++
<p align="center"><img src="http://pic.littleyang.ml/sonolus-server-screenshot/favicon.png"/></p>

[English](./README_en.md) [简体中文](./README.md)
<h1 align="center">Sonolus Server for C++</h1>

<p align="center"><a href="./README_en.md">English</a>&nbsp; <a href="./README.md">简体中文</a></p>

A sample api server for Sonolus, use C++ & MySQL to develop. You can use it to test your own Sonolus engine or build a Sonolus server for yourself.

Expand Down Expand Up @@ -272,9 +274,21 @@ These days, the official wiki website has added an endpoint `/sonolus/authentica
- [openssl/openssl](https://github.com/openssl/openssl)
- [jquery/jquery](https://github.com/jquery/jquery)
- [dankogai/js-base64](https://github.com/dankogai/js-base64)
- [lyoj-dev/webserver](https://github.com/lyoj-dev/webserver)
## Upload Log
### v1.1.3 2023.2.11
1. Fix the error of displaying `{{html. xxx}}` when the list page has no entries.
2. Completely repair the memory leak caused by the client's long connection without sending information.
3. Add the display of search criteria on the list page of each component.
4. Fix the problem of stiff animation when the link jumps.
5. Fix the problem of reading error when reading the search configuration file.
6. Fix the problem that the search link on the list page of each component cannot be used.
7. Fix the problem that the server title cannot be displayed.
8. Add a search page for each component.
### v1.1.2 2023.2.5
1. Add WebServer Core to display listening address.
Expand Down
4 changes: 2 additions & 2 deletions config/background_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"options": [
{
"query": "keywords",
"name": "#KEYWORDS",
"name": "Keywords",
"type": "text",
"placeholder": "#KEYWORDS"
"placeholder": "Enter keywords..."
}
]
}
4 changes: 2 additions & 2 deletions config/effect_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"options": [
{
"query": "keywords",
"name": "#KEYWORDS",
"name": "Keywords",
"type": "text",
"placeholder": "#KEYWORDS"
"placeholder": "Enter keywords..."
}
]
}
4 changes: 2 additions & 2 deletions config/engine_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"options": [
{
"query": "keywords",
"name": "#KEYWORDS",
"name": "Keywords",
"type": "text",
"placeholder": "#KEYWORDS"
"placeholder": "Enter keywords..."
}
]
}
34 changes: 32 additions & 2 deletions config/level_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,39 @@
"options": [
{
"query": "keywords",
"name": "#KEYWORDS",
"name": "Keywords",
"type": "text",
"placeholder": "#KEYWORDS"
"placeholder": "Enter keywords..."
},
{
"query": "artist",
"name": "Artist",
"type": "text",
"placeholder": "Enter artist name..."
},
{
"query": "author",
"name": "Author",
"type": "text",
"placeholder": "Enter author name..."
},
{
"query": "maxRating",
"name": "Maximum Rating",
"type": "slider",
"def": 50,
"min": 5,
"max": 50,
"step": 1
},
{
"query": "minRating",
"name": "Minimal Rating",
"type": "slider",
"def": 5,
"min": 5,
"max": 50,
"step": 1
}
]
}
4 changes: 2 additions & 2 deletions config/particle_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"options": [
{
"query": "keywords",
"name": "#KEYWORDS",
"name": "Keywords",
"type": "text",
"placeholder": "#KEYWORDS"
"placeholder": "Enter keywords..."
}
]
}
4 changes: 2 additions & 2 deletions config/skin_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"options": [
{
"query": "keywords",
"name": "#KEYWORDS",
"name": "Keywords",
"type": "text",
"placeholder": "#KEYWORDS"
"placeholder": "Enter keywords..."
}
]
}
8 changes: 7 additions & 1 deletion i18n/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@
"particles": "Particles",
"engines": "Engines",
"search": "Search",
"more": "More"
"more": "More",
"opening": "Opening...",
"retry": "If Sonolus did not open, click the following link to try again:",
"download": "If you do not have Sonolus yet, download it here:",
"searchButton":"Search",
"yes": "OFF",
"no": "ON"
}
8 changes: 7 additions & 1 deletion i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@
"particles": "粒子效果",
"engines": "引擎",
"search": "搜索",
"more": "更多"
"more": "更多",
"opening": "正在打开...",
"retry": "如果 Sonolus 没有打开,请点击以下链接重试:",
"download": "如果您还没有 sonolus,请前往下载:",
"searchButton":"搜索",
"yes": "",
"no": ""
}
2 changes: 1 addition & 1 deletion items/BackgroundItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Section<BackgroundItem> backgroundList(string filter, int st = 1, int en = 20) {

string backgroundFilter(argvar arg) {
string filter = "";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", arg["keywords"]) + "%\"";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", urldecode(arg["keywords"])) + "%\"";
return filter;
}

Expand Down
2 changes: 1 addition & 1 deletion items/EffectItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Section<EffectItem> effectList(string filter, int st = 1, int en = 20) {

string effectFilter(argvar arg) {
string filter = "";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", arg["keywords"]) + "%\"";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", urldecode(arg["keywords"])) + "%\"";
return filter;
}

Expand Down
2 changes: 1 addition & 1 deletion items/EngineItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Section<EngineItem> engineList(string filter, int st = 1, int en = 20) {

string engineFilter(argvar arg) {
string filter = "";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", arg["keywords"]) + "%\"";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", urldecode(arg["keywords"])) + "%\"";
return filter;
}

Expand Down
2 changes: 1 addition & 1 deletion items/Items.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Search readJson(string path) {
json[i]["def"].asInt(),
vector<string>()
);
for (int j = 0; j < json[i]["values"].size(); i++)
for (int j = 0; j < json[i]["values"].size(); j++)
select.values.push_back(json[i]["values"][j].asString());
search.append(select);
} else {
Expand Down
8 changes: 6 additions & 2 deletions items/LevelItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ Section<LevelItem> levelList(string filter, int st = 1, int en = 20) {
}

string levelFilter(argvar arg) {
string filter = "";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", arg["keywords"]) + "%\"";
string filter = ""; bool pre = false;
if (arg["keywords"] != "") filter += (pre ? "AND " : "") + string("title like \"%") + str_replace("\"", "\\\"", urldecode(arg["keywords"])) + "%\" ", pre = true;
if (arg["artist"] != "") filter += (pre ? "AND " : "") + string("artists like \"%") + str_replace("\"", "\\\"", urldecode(arg["artist"])) + "%\" ", pre = true;
if (arg["author"] != "") filter += (pre ? "AND " : "") + string("author like \"%") + str_replace("\"", "\\\"", urldecode(arg["author"])) + "%\" ", pre = true;
if (arg["minRating"] != "") filter += (pre ? "AND " : "") + string("rating >= ") + arg["minRating"] + " ", pre = true;
if (arg["maxRating"] != "") filter += (pre ? "AND " : "") + string("rating <= ") + arg["maxRating"] + " ", pre = true;
return filter;
}

Expand Down
2 changes: 1 addition & 1 deletion items/ParticleItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Section<ParticleItem> particleList(string filter, int st = 1, int en = 20) {

string particleFilter(argvar arg) {
string filter = "";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", arg["keywords"]) + "%\"";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", urldecode(arg["keywords"])) + "%\"";
return filter;
}

Expand Down
2 changes: 1 addition & 1 deletion items/SkinItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Section<SkinItem> skinList(string filter, int st = 1, int en = 20) {

string skinFilter(argvar arg) {
string filter = "";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", arg["keywords"]) + "%\"";
if (arg["keywords"] != "") filter = "title like \"%" + str_replace("\"", "\\\"", urldecode(arg["keywords"])) + "%\"";
return filter;
}

Expand Down
15 changes: 9 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ int main(int argc, char** argv) {
app.addRoute("/data/%s", downloader);
app.addRoute("/js/%s", js_import);
app.addRoute("/css/%s", css_import);
app.addRoute("/test", [](client_conn conn, http_request request, param argv){

});

app.addRoute("/sonolus/info", sonolus_info);
app.addRoute("/sonolus/levels/create", sonolus_levels_create);
Expand Down Expand Up @@ -125,12 +128,12 @@ int main(int argc, char** argv) {
app.addRoute("/effects/list", web_effects_list);
app.addRoute("/particles/list", web_particles_list);
app.addRoute("/engines/list", web_engines_list);
// app.addRoute("/levels/search", web_levels_search);
// app.addRoute("/skins/search", web_skins_search);
// app.addRoute("/backgrounds/search", web_backgrounds_search);
// app.addRoute("/effects/search", web_effects_search);
// app.addRoute("/particles/search", web_particles_search);
// app.addRoute("/engines/search", web_engines_search);
app.addRoute("/levels/search", web_levels_search);
app.addRoute("/skins/search", web_skins_search);
app.addRoute("/backgrounds/search", web_backgrounds_search);
app.addRoute("/effects/search", web_effects_search);
app.addRoute("/particles/search", web_particles_search);
app.addRoute("/engines/search", web_engines_search);
app.addRoute("/levels/%s", web_levels);
app.addRoute("/skins/%s", web_skins);
app.addRoute("/backgrounds/%s", web_backgrounds);
Expand Down
8 changes: 4 additions & 4 deletions modules/export.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void exportData(const char* path) {
reverse(x.begin(), x.end());
char* ch = new char[8];
for (int i = 0; i < 8; i++) ch[i] = x[i];
fout.write(ch, 8); free(ch);
fout.write(ch, 8); delete[] ch;
for (auto v : fileSha) {
if (v == "") continue;
char* sha = new char[20];
Expand All @@ -149,7 +149,7 @@ void exportData(const char* path) {
val += isdigit(b) ? b - '0' : b - 'a' + 10;
sha[i / 2] = val;
}
fout.write(sha, 20); free(sha);
fout.write(sha, 20); delete[] sha;

ifstream fin(("./data/" + v).c_str());
fin.seekg(0, ios::end);
Expand All @@ -158,13 +158,13 @@ void exportData(const char* path) {
reverse(x.begin(), x.end());
char* ch = new char[8];
for (int i = 0; i < 8; i++) ch[i] = x[i];
fout.write(ch, 8); free(ch);
fout.write(ch, 8); delete[] ch;

len = tmp;
fin.seekg(0, ios::beg);
ch = new char[len];
fin.read(ch, len); fin.close();
fout.write(ch, len); free(ch);
fout.write(ch, len); delete[] ch;
writeLog(LOG_LEVEL_DEBUG, "Add file " + v + " into binary file.");
}
fout << sqlbuffer.str();
Expand Down
Loading

0 comments on commit 58813c5

Please sign in to comment.