Skip to content

Commit

Permalink
2.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko committed Jan 12, 2025
1 parent 7905323 commit 8a43250
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 18 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.3.6

* Improved compatibility with other bots macros.

# v2.3.5

* Added render warning.
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"win": "2.2074",
"android": "2.2074"
},
"version": "2.3.5",
"version": "2.3.6",
"id": "zilko.xdbot",
"name": "xdBot",
"developer": "Zilko",
Expand Down
28 changes: 27 additions & 1 deletion src/gdr/gdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,30 @@ cocos2d::CCPoint dataFromString(std::string dataString) {
}

return { xPos, yPos };
};
};

std::vector<std::string> splitByChar(std::string str, char splitChar) {
std::vector<std::string> strs;
strs.reserve(std::count(str.begin(), str.end(), splitChar) + 1);

size_t start = 0;
size_t end = str.find(splitChar);
while (end != std::string::npos) {
strs.emplace_back(str.substr(start, end - start));
start = end + 1;
end = str.find(splitChar, start);
}
strs.emplace_back(str.substr(start));

return strs;
}

geode::prelude::VersionInfo getVersion(std::vector<std::string> nums) {
size_t major = geode::utils::numFromString<int>(nums[0]).unwrapOr(-1);
size_t minor = geode::utils::numFromString<int>(nums[1]).unwrapOr(-1);
size_t patch = geode::utils::numFromString<int>(nums[2]).unwrapOr(-1);

geode::prelude::VersionInfo ret(major, minor, patch);

return ret;
}
38 changes: 32 additions & 6 deletions src/gdr/gdr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

#include "json.hpp"

#include <Geode/utils/VersionInfo.hpp>

geode::prelude::VersionInfo getVersion(std::vector<std::string> nums);

cocos2d::CCPoint dataFromString(std::string dataString);

std::vector<std::string> splitByChar(std::string str, char splitChar);

const std::string xdBotVersion = "v2.3.6";

namespace gdr {

using namespace nlohmann;
Expand Down Expand Up @@ -150,12 +158,31 @@ namespace gdr {
if (!replayJson["level"]["id"].is_null()) replay.levelInfo.id = replayJson["level"]["id"];
if (!replayJson["level"]["name"].is_null()) replay.levelInfo.name = replayJson["level"]["name"];

std::string ver = replay.botInfo.version;

if (replayJson.contains("framerate"))
replay.framerate = replayJson["framerate"];

bool rotation = replay.botInfo.version.find("beta.") == std::string::npos && replay.botInfo.version.find("alpha.") == std::string::npos;
bool addOffset = false;
if (replay.botInfo.name == "xdBot" && replay.botInfo.version == "v2.0.0") rotation = true;
bool rotation = ver.find("beta.") == std::string::npos && ver.find("alpha.") == std::string::npos;
if (replay.botInfo.name == "xdBot" && ver == "v2.0.0") rotation = true;

// bool addOffset = false;
bool addOffset = replay.botInfo.name == "xdBot";

if (addOffset) {
if (ver.front() == 'v') ver = ver.substr(1);

std::vector<std::string> splitVer = splitByChar(ver, '.');

if (splitVer.size() <= 3) {
std::vector<std::string> realVer = {"2", "3", "6"};

geode::prelude::VersionInfo macroVer = getVersion(splitVer);
geode::prelude::VersionInfo checkVer = getVersion(realVer);

if (macroVer >= checkVer) addOffset = false;
}
}

replay.parseExtension(replayJson.get<json::object_t>());

Expand All @@ -168,7 +195,7 @@ namespace gdr {
if (!inputJson.contains("frame")) continue;
if (inputJson["frame"].is_null()) continue;

input.frame = inputJson["frame"].get<int>() - (addOffset ? 1 : 0);
input.frame = inputJson["frame"].get<int>() + (addOffset ? 1 : 0);
input.button = inputJson["btn"];
input.player2 = inputJson["2p"];
input.down = inputJson["down"];
Expand All @@ -185,7 +212,7 @@ namespace gdr {
if (!frameFixJson.contains("frame")) continue;
if (frameFixJson["frame"].is_null()) continue;

frameFix.frame = frameFixJson["frame"].get<int>() - (addOffset ? 1 : 0);
frameFix.frame = frameFixJson["frame"].get<int>() + (addOffset ? 1 : 0);

if (frameFixJson.contains("player1")) {

Expand All @@ -205,7 +232,6 @@ namespace gdr {
frameFix.p2.rotate = false;

} else if (frameFixJson.contains("p1")) {
bool rotation = replay.botInfo.version.find("beta.") == std::string::npos && replay.botInfo.version.find(".alpha") == std::string::npos;
if (replay.botInfo.name != "xdBot") rotation = false;

if (frameFixJson["p1"].contains("x"))
Expand Down
7 changes: 5 additions & 2 deletions src/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ bool Global::hasIncompatibleMods() {
return ret;
}

int Global::getTPS() {
float Global::getTPS() {
auto& g = Global::get();
return g.tpsEnabled ? g.tps : 240;
return g.tpsEnabled ? g.tps : 240.f;
}

int Global::getCurrentFrame(bool editor) {
Expand All @@ -168,9 +168,12 @@ int Global::getCurrentFrame(bool editor) {
}

levelTime = pl->m_gameState.m_levelTime;
// int frame = pl->m_gameState.m_currentProgress;
int frame = static_cast<int>(levelTime * getTPS());

frame -= Global::get().frameOffset;
frame++;

if (frame < 0) return 0;

return frame;
Expand Down
6 changes: 3 additions & 3 deletions src/hacks/clickbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ void Clickbot::playSound(std::string id) {

if (!sound) return;

int masterVol = g.mod->getSavedValue<int64_t>("clickbot_volume");
if (settings.volume == 0 || masterVol == 0) return;

FMOD_RESULT result;

result = c.system->playSound(sound, nullptr, false, &c.channel);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 2");

int masterVol = g.mod->getSavedValue<int64_t>("clickbot_volume");
if (settings.volume == 0 || masterVol == 0) return;

result = c.channel->setVolume((settings.volume / 100.f) * (masterVol / 100.f));
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 3");

Expand Down
2 changes: 1 addition & 1 deletion src/includes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Global {

static bool hasIncompatibleMods();

static int getTPS();
static float getTPS();

static int getCurrentFrame(bool editor = false);

Expand Down
3 changes: 3 additions & 0 deletions src/keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class $modify(CCKeyboardDispatcher) {
}
}

// if (key == enumKeyCodes::KEY_L && !isKeyRepeat && isKeyDown) {
// }

// if (key == enumKeyCodes::KEY_F && !isKeyRepeat && isKeyDown && PlayLayer::get()) {
// log::debug("POS DEBUG {}", PlayLayer::get()->m_player1->getPosition());
// log::debug("POS2 DEBUG {}", PlayLayer::get()->m_player2->getPosition());
Expand Down
4 changes: 0 additions & 4 deletions src/macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "gdr/gdr.hpp"
#include "utils/utils.hpp"

#include <Geode/Geode.hpp>

using namespace geode::prelude;

#define DIF(a, b) (std::fabs((a) - (b)) > 0.001f)
Expand All @@ -17,8 +15,6 @@ const std::vector<float> safeValues = {
1.0f / 5, 1.0f / 4, 1.0f / 3, 1.0f / 2
};

const std::string xdBotVersion = "v2.3.5";

enum state {
none,
recording,
Expand Down

0 comments on commit 8a43250

Please sign in to comment.