Skip to content

Commit

Permalink
g/j2: Integrate highscores with Speedrun.com/JakSpeedruns.com when sp…
Browse files Browse the repository at this point in the history
…eedrunner mode is enabled (#3037)
  • Loading branch information
xTVaser authored Oct 12, 2023
1 parent 97e04a7 commit 8b3b967
Show file tree
Hide file tree
Showing 3,831 changed files with 554,423 additions and 1,130 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .github/workflows/linux-build-clang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
sudo apt install build-essential cmake \
clang gcc g++ lcov make nasm libxrandr-dev \
libxinerama-dev libxcursor-dev libpulse-dev \
libxi-dev zip ninja-build libgl1-mesa-dev
libxi-dev zip ninja-build libgl1-mesa-dev libssl-dev
- name: Setup Buildcache
uses: mikehardy/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-build-gcc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
sudo apt install build-essential cmake \
clang gcc g++ lcov make nasm libxrandr-dev \
libxinerama-dev libxcursor-dev libpulse-dev \
libxi-dev zip ninja-build libgl1-mesa-dev
libxi-dev zip ninja-build libgl1-mesa-dev libssl-dev
- name: Setup Buildcache
uses: mikehardy/[email protected]
Expand Down
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ endif()
# For clangd
if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json" )
configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json"
"${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json"
"${PROJECT_SOURCE_DIR}/build/compile_commands.json")
endif()

Expand Down Expand Up @@ -183,6 +183,23 @@ include_directories(./)
# build templating engine library
include_directories(SYSTEM third-party/inja)

# libcurl for HTTP requests

# Enable SSL Support, most URLs now-a-days use SSL!
if(WIN32)
set(CURL_USE_SCHANNEL ON) # native Windows SSL support
elseif(APPLE)
set(CURL_USE_SECTRANSP ON) # native macOS SSL support
else()
set(CURL_USE_OPENSSL ON) # not native, but seems to be the best choice for linux
endif()
include_directories(third-party/curl/include)
if(STATICALLY_LINK)
build_third_party_lib(curl libcurl_static)
else()
build_third_party_lib(curl libcurl_shared)
endif()

# build repl library
build_third_party_lib(replxx replxx)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Unfortunately you'll still need task runner on your local machine to run the gam
Install packages and init repository:

```sh
sudo apt install gcc make cmake build-essential g++ nasm clang-format libxrandr-dev libxinerama-dev libxcursor-dev libpulse-dev libxi-dev python libgl1-mesa-dev
sudo apt install gcc make cmake build-essential g++ nasm clang-format libxrandr-dev libxinerama-dev libxcursor-dev libpulse-dev libxi-dev python libgl1-mesa-dev libssl-dev
sudo sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
```

Expand Down
9 changes: 9 additions & 0 deletions common/util/json_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ std::string strip_cpp_style_comments(const std::string& input) {
return output;
}

std::optional<nlohmann::json> safe_parse_json(const std::string& input) {
json j = json::parse(input, nullptr, false);
if (j.is_discarded()) {
lg::error("Failed to parse json");
return {};
}
return j;
}

/*!
* Parse JSON file with comments stripped. Unlike the default comment stripping feature
* of nlohmann::json, this allows you to have multiple comments in a row!
Expand Down
1 change: 1 addition & 0 deletions common/util/json_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using json = nlohmann::json;

std::string strip_cpp_style_comments(const std::string& input);
std::optional<nlohmann::json> safe_parse_json(const std::string& input);
nlohmann::json parse_commented_json(const std::string& input, const std::string& source_name);
Range<int> parse_json_optional_integer_range(const nlohmann::json& json);

Expand Down
48 changes: 40 additions & 8 deletions decompiler/config/jak2/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -6800,6 +6800,26 @@
(progress-highscores-6th #x13c)
(progress-highscores-7th #x13d)
(progress-highscores-8th #x13e)
(progress-highscores-header-race #x13f)
(progress-highscores-subheader-class1 #x140)
(progress-highscores-subheader-class2 #x141)
(progress-highscores-subheader-class3 #x142)
(progress-highscores-header-guncourse #x143)
(progress-highscores-subheader-scattergun #x144)
(progress-highscores-subheader-blaster #x145)
(progress-highscores-subheader-vulcan #x146)
(progress-highscores-subheader-peacemaker #x147)
(progress-highscores-header-onin #x148)
(progress-highscores-header-metalhead-mash #x149)
(progress-highscores-header-jetboard #x14a)
(progress-highscores-subheader-oninstent #x14b)
(progress-highscores-subheader-hiphog #x14c)
(progress-highscores-subheader-stadium #x14d)
(progress-highscores-subheader-class1-reverse #x14e)
(progress-highscores-subheader-class2-reverse #x14f)
(progress-highscores-subheader-class3-reverse #x150)
(progress-highscores-subheader-portrace #x151)
(progress-highscores-subheader-cityrace #x152)
(progress-root-secrets #x153)
(progress-secrets-unlocked #x154)
(progress-secrets-toggle-beard #x0155)
Expand Down Expand Up @@ -7391,6 +7411,14 @@
(progress-hires-sky #x1309)
(progress-fast-airlock #x130a)
(progress-fast-elevator #x130b)
(progress-highscores-header-speedrun #x130c)
(progress-highscores-subheader-speedrun-any #x130d)
(progress-highscores-subheader-speedrun-anyhoverless #x130e)
(progress-highscores-subheader-speedrun-allmissions #x130f)
(progress-highscores-subheader-speedrun-100 #x1310)
(progress-highscores-subheader-speedrun-anyorbs #x1311)
(progress-highscores-subheader-speedrun-anyhero #x1312)
(progress-highscores-local-time #x1313)
)
;; ---text-id-h:text-id

Expand Down Expand Up @@ -31306,23 +31334,27 @@
(function int none))
(define-extern find-mission-text-at-index (function int game-task-node-info))
(define-extern draw-secret-list (function secret-item-option progress font-context int symbol float none))
(define-extern draw-highscore-icon (function menu-highscores-option uint int int float pointer))
(define-extern draw-highscore-icon (function menu-highscores-option texture-id int int float pointer))
(define-extern draw-highscore-cup "First int is an enum" (function menu-highscores-option int int int float float pointer))
(define-extern get-highscore-score "TODO - takes and returns an enum?" (function int int))
(define-extern get-highscore-score (function int int))
(define-extern eval-highscore (function print-highscore-obj int))
(define-extern str-print-time (function float string))
(define-extern print-highscore (function print-highscore-obj float))
(define-extern get-highscore-text "TODO - takes an enum?" (function int text-id))
(define-extern get-highscore-text-sub "TODO - takes an enum?" (function int text-id))
(define-extern get-highscore-icon "TODO - Icon id enum perhaps?" (function int uint))
(define-extern get-highscore-type "TODO - takes an enum?" (function int symbol))
(define-extern get-highscore-text (function int text-id))
(define-extern get-highscore-text-sub (function int text-id))
(define-extern get-highscore-icon (function int texture-id))
(define-extern get-highscore-type
"Given a highscore index, return it's type as a symbol
@param highscore-index-arg something
@returns The type, as as symbol. Either `'game` or `'race`"
(function int symbol))
(define-extern highscore-available? (function int symbol))
(define-extern get-num-highscores (function int))
(define-extern get-next-highscore (function int int))
(define-extern get-prev-highscore (function int int))
(define-extern get-highscore-icon-scale "TODO - takes an enum?" (function int float))
(define-extern get-highscore-icon-scale (function int float))
(define-extern get-highscore-icon-xoffset (function int int))
(define-extern get-highscore-icon-yoffset "TODO - takes an enum?" (function int int))
(define-extern get-highscore-icon-yoffset (function int int))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ocean ;;
Expand Down
16 changes: 8 additions & 8 deletions decompiler/config/jak2/ntsc_v1/label_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@
["L939", "uint64", true],
["L940", "uint64", true],
["L941", "uint64", true],
["L942", "uint64", true],
["L942", "texture-id", true],
["L943", "uint64", true],
["L944", "uint64", true],
["L945", "uint64", true],
["L946", "uint64", true],
["L946", "texture-id", true],
["L947", "uint64", true],
["L948", "uint64", true],
["L949", "uint64", true],
Expand All @@ -314,7 +314,7 @@
["L952", "uint64", true],
["L953", "uint64", true],
["L954", "uint64", true],
["L955", "uint64", true],
["L955", "texture-id", true],
["L956", "uint64", true],
["L957", "uint64", true],
["L958", "uint64", true],
Expand All @@ -325,7 +325,7 @@
["L963", "uint64", true],
["L964", "uint64", true],
["L965", "uint64", true],
["L966", "uint64", true],
["L966", "texture-id", true],
["L967", "uint64", true],
["L968", "uint64", true],
["L969", "uint64", true],
Expand All @@ -336,18 +336,18 @@
["L974", "uint64", true],
["L975", "uint64", true],
["L976", "uint64", true],
["L977", "uint64", true],
["L977", "texture-id", true],
["L978", "uint64", true],
["L979", "uint64", true],
["L980", "uint64", true],
["L981", "uint64", true],
["L982", "uint64", true],
["L982", "texture-id", true],
["L983", "uint64", true],
["L984", "uint64", true],
["L985", "uint64", true],
["L986", "uint64", true],
["L987", "uint64", true],
["L988", "uint64", true],
["L988", "texture-id", true],
["L989", "uint64", true],
["L990", "uint64", true],
["L991", "uint64", true],
Expand All @@ -359,7 +359,7 @@
["L997", "uint64", true],
["L998", "uint64", true],
["L999", "uint64", true],
["L1000", "uint64", true],
["L1000", "texture-id", true],
["L1001", "uint64", true],
["L1002", "uint64", true],
["L1003", "uint64", true],
Expand Down
117 changes: 117 additions & 0 deletions decompiler/config/jak2/ntsc_v1/var_names.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4508,5 +4508,122 @@
"vars": {
"v0-2": ["result", "draw-string-result"]
}
},
"get-num-highscores": {
"vars": {
"gp-0": "count",
"s5-0": "max-highscores"
}
},
"highscore-available?": {
"args": ["highscore-index"],
"vars": {
"v0-0": "available?",
"v1-0": "index"
}
},
"get-next-highscore": {
"args": ["current-highscore-index"],
"vars": {
"s3-0": "index-change",
"s4-0": "max-highscores",
"gp-0": "selected-index",
"s2-0": "curr-index"
}
},
"get-prev-highscore": {
"vars": {
"s4-0": "max-highscores",
"s3-0": "index-change",
"gp-0": "selected-index",
"s2-0": "curr-index",
"t9-0": "highscore-available-fn",
"a0-1": "normalized-index"
}
},
"(method 10 menu-highscores-option)": {
"args": ["this", "progress", "font-ctx", "option-index", "selected?"]
},
"get-highscore-type": {
"args": ["highscore-index-arg"],
"vars": {
"v1-0": "highscore-index",
"v0-0": "highscore-type"
}
},
"get-highscore-icon": {
"args": ["highscore-index-arg"],
"vars": {
"v0-0": "texture",
"v1-1": "highscore-index"
}
},
"get-highscore-text": {
"args": ["highscore-index"],
"vars": {
"v1-0": "index",
"v0-0": "text-id"
}
},
"get-highscore-text-sub": {
"args": ["highscore-index"],
"vars": {
"v0-0": "id",
"v1-0": "index"
}
},
"get-highscore-icon-scale": {
"args": ["highscore-index"],
"vars": {
"f0-0": "scale",
"f2-0": "guncourse-scale",
"f1-0": "race-scale"
}
},
"get-highscore-icon-xoffset": {
"args": ["highscore-index"]
},
"get-highscore-icon-yoffset": {
"args": ["highscore-index"],
"vars": {
"v0-1": "offset",
"a0-1": "guncourse-offset",
"v1-0": "race-offset"
}
},
"str-print-time": {
"args": ["time"],
"vars": {
"gp-0": "minutes",
"v1-5": "remainder-minutes",
"s5-0": "seconds",
"v1-6": "remainder-seconds",
"s3-0": "milliseconds"
}
},
"draw-highscore-cup": {
"args": ["highscore-option", "arg1", "arg2", "arg3", "arg4", "arg5"]
},
"eval-highscore": {
"args": ["print-highscore-info"]
},
"get-highscore-score": {
"args": ["highscore-index"],
"vars": {
"v1-0": "index",
"v0-0": "score-array-index"
}
},
"(method 9 highscore-info)": {
"args": ["this", "score"],
"vars": {
"v0-0": "place"
}
},
"(method 9 menu-highscores-option)": {
"args": ["this", "progress", "selected?"],
"vars": {
"s5-0": "play-sound?"
}
}
}
3 changes: 2 additions & 1 deletion game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ set(RUNTIME_SOURCE
sce/sif_ee.cpp
sce/stubs.cpp
settings/settings.cpp
system/background_worker.cpp
system/Deci2Server.cpp
system/hid/devices/game_controller.cpp
system/hid/devices/keyboard.cpp
Expand All @@ -246,7 +247,7 @@ add_subdirectory(sound)
# we build the runtime as a static library.
add_library(runtime STATIC ${RUNTIME_SOURCE} "../third-party/glad/src/glad.c")

target_link_libraries(runtime common fmt SDL2::SDL2 imgui discord-rpc sound stb_image libco)
target_link_libraries(runtime common fmt SDL2::SDL2 imgui discord-rpc sound stb_image libco libcurl)
if(WIN32)
target_link_libraries(runtime mman)
else()
Expand Down
10 changes: 9 additions & 1 deletion game/assets/jak2/text/game_custom_text_en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,13 @@
"1308": "Unknown",
"1309": "High-Resolution Sky",
"130a": "Fast Airlocks and Doors",
"130b": "Fast Elevators"
"130b": "Fast Elevators",
"130c": "Speedrun",
"130d": "Any%",
"130e": "Any% - Hoverless",
"130f": "All Missions",
"1310": "100%",
"1311": "Any% - All Orbs",
"1312": "Any% - Hero Mode",
"1313": "Local Time"
}
Loading

0 comments on commit 8b3b967

Please sign in to comment.