Skip to content

Commit

Permalink
修复 grantitem
Browse files Browse the repository at this point in the history
  • Loading branch information
zhnkc9 committed Oct 30, 2023
1 parent eadd98c commit ea9226c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 2)
set(PROJECT_VERSION_PATCH 36)
set(PROJECT_VERSION_PATCH 362)
set(PROJECT_RELEASE_TYPE "rc")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-${PROJECT_RELEASE_TYPE}")

Expand Down
4 changes: 3 additions & 1 deletion resource/skinprefabs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ table.insert(prefs, CreatePrefabSkin("{{ prefix + skinid }}",{
{{ key }} = {{ dump(value) }} ,
{% else if key == "base_prefab" %}
{{ key }} = {{ value }} ,
{% else if key == "granted_items" %}
granted_items = { {% for v in value %} "{{prefix+v}}" , {% endfor %} },
{% else if key == "skins" %}
skins = { {% for sk,sv in value %}{{ sk }} = "{{sv}}" , {% endfor %} },
{% else if key == "origin_skins" or key == "origin_build_name" or key == "bigportrait_anim"%}
{% else if key == "origin_skins" or key == "origin_build_name" or key == "bigportrait_anim" or key == "granted_items"%}
{% else %}
{{ key }} = {{ value }},
{% endif %}
Expand Down
14 changes: 12 additions & 2 deletions src/LParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ namespace LParser {
regex re("^table\\.insert\\(prefs, CreatePrefabSkin\\(\"(\\w+?)\"");
regex kv_re(R"(^\s*(\w+)\s*=\s*(.+),$)");
regex skins_re(R"(\s*(\w+)\s*=\s*\"?(\w+)\"?)");
regex arr_re(R"((\w+))");
smatch match;
smatch value_match;
smatch skins_match;
smatch grant_item_match;
bool need_find;
json result;
json *v = nullptr;
auto f =
[&match, &re, &need_find, &result, &v, &value_match, &kv_re, &skins_re, &skins_match](string &line) -> void {
[&match, &re, &need_find, &result, &v, &value_match, &kv_re, &skins_re, &skins_match ,&grant_item_match,&arr_re](string &line) -> void {
regex_search(line, match, re);
if (match[1].matched) {
// 拿到了数据
Expand All @@ -90,7 +92,15 @@ namespace LParser {
if (value_match[2].matched) {
auto &v_k = value_match[1];
auto &v_v = value_match[2];
if (v_k == "skins") {

if (v_k == "granted_items"){
for (sregex_iterator it(v_v.begin(), v_v.end(), arr_re); it != sregex_iterator(); ++it) {
grant_item_match = *it;
if (match.size() > 1) {
(*v)[v_k].push_back(grant_item_match[1]);
}
}
} else if (v_k == "skins") {
(*v)["origin_skins"] = json(v_v);
// {ghost_skin = "ghost_walter", normal_skin = "walter_bee"}
json skins;
Expand Down

0 comments on commit ea9226c

Please sign in to comment.