Skip to content

Commit

Permalink
Rescan map player on first error
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-c committed Mar 4, 2023
1 parent 7f2b333 commit 8604e17
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
19 changes: 16 additions & 3 deletions app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ static void help_marker(const char *desc) {
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 30.0f);
ImGui::TextUnformatted(desc);
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
Expand Down Expand Up @@ -65,11 +65,20 @@ int main(int, char **) {
set_priority_class(HIGH_PRIORITY_CLASS);

maniac::randomize(hit_objects, maniac::config.randomization_range);
maniac::humanize(hit_objects, maniac::config.humanization_modifier);

if (maniac::config.humanization_type == maniac::config::STATIC_HUMANIZATION) {
maniac::humanize_static(hit_objects, maniac::config.humanization_modifier);
}

if (maniac::config.humanization_type == maniac::config::DYNAMIC_HUMANIZATION) {
maniac::humanize_dynamic(hit_objects, maniac::config.humanization_modifier);
}

auto actions = maniac::to_actions(hit_objects, osu.get_game_time());

message = "playing";

maniac::play(maniac::to_actions(hit_objects, osu.get_game_time()));
maniac::play(actions);

set_priority_class(NORMAL_PRIORITY_CLASS);
};
Expand All @@ -96,6 +105,10 @@ int main(int, char **) {
ImGui::Text("Status: %s", message.c_str());
horizontal_break();

ImGui::Combo("Humanization Type", &maniac::config.humanization_type, "Static\0Dynamic (new)\0\0");
ImGui::SameLine();
help_marker("Static: Density calculated per 1s chunk and applied to all hit objects in that chunk. Dynamic: Density 1s 'in front' of each hit object, applied individually.");

ImGui::SliderInt("Humanization", &maniac::config.humanization_modifier, 0, 1000);
ImGui::SameLine();
help_marker("Advanced hit-time randomization based on hit density.");
Expand Down
4 changes: 1 addition & 3 deletions lib/include/maniac/osu/signatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
namespace signatures {
const auto time = Signature{ "EB 0A A1 ? ? ? ? A3", 3 };
const auto player = Signature{ "A1 ? ? ? ? 8B ? ? ? 00 00 6A 00", 1 };

// constexpr auto STATE_SIG_OFFSET = 1;
// constexpr auto STATE_SIG = "A1 ? ? ? ? A3 ? ? ? ? A1 ? ? ? ? A3 ? ? ? ? 83 3D ? ? ? ? 00 0F 84 ? ? ? ? B9 ? ? ? ? E8\0";
const auto status = Signature{ "A1 ? ? ? ? A3 ? ? ? ? A1 ? ? ? ? A3 ? ? ? ? 83 3D ? ? ? ? 00 0F 84 ? ? ? ? B9 ? ? ? ? E8", 1 };

// constexpr auto RULESET_SIG_OFFSET = 4;
// constexpr auto RULESET_SIG = "73 7A 8B 0D ? ? ? ? 85 C9 74 1F\0";
Expand Down
16 changes: 14 additions & 2 deletions lib/osu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Osu::Osu() : Process("osu!.exe") {

player_pointer = read_memory<uintptr_t>(find_signature(signatures::player));
debug("found player pointer: %#x", player_pointer);

status_pointer = read_memory<uintptr_t>(find_signature(signatures::status));
debug("found status pointer: %#x", status_pointer);
}

Osu::~Osu() = default;
Expand Down Expand Up @@ -61,7 +64,16 @@ std::vector<HitObject> Osu::get_hit_objects() {
internal::process = this;

const auto player_address = read_memory_safe<uintptr_t>("player", player_pointer);
const auto player = internal::map_player(player_address);

return player.manager.list.content;
try {
const auto player = internal::map_player(player_address);

return player.manager.list.content;
} catch (std::runtime_error &err) {
// if this fails, it's very likely because we previously scanned an outdated map player so just rescan
debug("failed getting map player, rescanning")
player_pointer = read_memory<uintptr_t>(find_signature(signatures::player));

return get_hit_objects();
}
}

0 comments on commit 8604e17

Please sign in to comment.