Skip to content

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko committed Oct 30, 2024
1 parent b0d36a7 commit b470dd9
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 24 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v2.0.1

* Fixed crash if some macro info was null for whatever reason.
* Fixed macro bot info saving bug.
* Fixed practice rotation bug.

# v2.0.0

* Changed render FPS cap to 240 (more than 240 fps would need tps bypass lol).
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.206",
"android": "2.206"
},
"version": "v2.0.0",
"version": "v2.0.1",
"id": "zilko.xdbot",
"name": "xdBot",
"developer": "Zilko",
Expand Down
47 changes: 31 additions & 16 deletions src/gdr/gdr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <optional>

#include "json.hpp"
#include <Geode/Geode.hpp>

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

Expand Down Expand Up @@ -133,28 +132,38 @@ namespace gdr {
// replayJson = json::parse(data);
// }

replay.gameVersion = replayJson["gameVersion"];
replay.description = replayJson["description"];
replay.version = replayJson["version"];
replay.duration = replayJson["duration"];
replay.botInfo.name = replayJson["bot"]["name"];
replay.botInfo.version = replayJson["bot"]["version"];
replay.levelInfo.id = replayJson["level"]["id"];
replay.levelInfo.name = replayJson["level"]["name"];
replay.author = replayJson["author"];
replay.seed = replayJson["seed"];
replay.coins = replayJson["coins"];
replay.ldm = replayJson["ldm"];
if (!replayJson["gameVersion"].is_null()) replay.gameVersion = replayJson["gameVersion"];
if (!replayJson["description"].is_null()) replay.description = replayJson["description"];
if (!replayJson["version"].is_null()) replay.version = replayJson["version"];
if (!replayJson["duration"].is_null()) replay.duration = replayJson["duration"];
if (!replayJson["author"].is_null()) replay.author = replayJson["author"];
if (!replayJson["seed"].is_null()) replay.seed = replayJson["seed"];
if (!replayJson["coins"].is_null()) replay.coins = replayJson["coins"];
if (!replayJson["ldm"].is_null()) replay.ldm = replayJson["ldm"];

if (!replayJson["bot"]["name"].is_null()) replay.botInfo.name = replayJson["bot"]["name"];
if (!replayJson["bot"]["version"].is_null()) replay.botInfo.version = replayJson["bot"]["version"];
if (!replayJson["level"]["id"].is_null()) replay.levelInfo.id = replayJson["level"]["id"];
if (!replayJson["level"]["name"].is_null()) replay.levelInfo.name = replayJson["level"]["name"];

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

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

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

if (!importInputs)
return replay;

for (json const& inputJson : replayJson["inputs"]) {
InputType input;

if (!inputJson.contains("frame")) continue;
if (inputJson["frame"].is_null()) continue;

input.frame = inputJson["frame"];
input.button = inputJson["btn"];
input.player2 = inputJson["2p"];
Expand All @@ -164,10 +173,13 @@ namespace gdr {
replay.inputs.push_back(input);
}

if (!replayJson.contains("frameFixes")) return replay;

for (json const& frameFixJson : replayJson["frameFixes"]) {
FrameFix frameFix;

if (!frameFixJson.contains("frame")) continue;
if (frameFixJson["frame"].is_null()) continue;

frameFix.frame = frameFixJson["frame"];

Expand All @@ -189,13 +201,16 @@ 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"))
frameFix.p1.pos.x = frameFixJson["p1"]["x"];

if (frameFixJson["p1"].contains("y"))
frameFix.p1.pos.y = frameFixJson["p1"]["y"];

if (frameFixJson["p1"].contains("r"))
if (frameFixJson["p1"].contains("r") && rotation)
frameFix.p1.rotation = frameFixJson["p1"]["r"];

if (frameFixJson.contains("p2")) {
Expand All @@ -205,8 +220,8 @@ namespace gdr {
if (frameFixJson["p2"].contains("y"))
frameFix.p2.pos.y = frameFixJson["p2"]["y"];

if (frameFixJson["p2"].contains("r"))
frameFix.p2.rotation= frameFixJson["p2"]["r"];
if (frameFixJson["p2"].contains("r") && rotation)
frameFix.p2.rotation = frameFixJson["p2"]["r"];
}
} else continue;

Expand Down
2 changes: 1 addition & 1 deletion src/hacks/show_trajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class $modify(PlayLayer) {

void destroyPlayer(PlayerObject * player, GameObject * gameObject) {
if (t.creatingTrajectory || (player == t.fakePlayer1 || player == t.fakePlayer2)) {
t.deathRotation = player->getRotationX();
t.deathRotation = player->getRotation();
t.cancelTrajectory = true;
return;
}
Expand Down
3 changes: 3 additions & 0 deletions src/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ void Macro::updateInfo(PlayLayer* pl) {

if (g.macro.author == "")
g.macro.author = "N/A";

g.macro.botInfo.name = "xdBot";
g.macro.botInfo.version = xdBotVersion;
}

int Macro::save(std::string author, std::string desc, std::string path, bool json) {
Expand Down
6 changes: 4 additions & 2 deletions src/macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const std::vector<float> safeValues = {
1.0f / 5, 1.0f / 4, 1.0f / 3, 1.0f / 2
};

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

enum state {
none,
recording,
Expand All @@ -39,7 +41,7 @@ struct input : gdr::Input {

struct Macro : gdr::Replay<Macro, input> {

Macro() : Replay("xdBot", "v2.0.0-beta.7") {}
Macro() : Replay("xdBot", xdBotVersion.c_str()) {}

public:

Expand Down Expand Up @@ -87,7 +89,7 @@ struct PlayerData {
#endif
std::vector<float> m_playerFollowFloats;
cocos2d::CCPoint position;
float rotationX;
float rotation;
bool m_holdingRight;
bool m_holdingLeft;
cocos2d::CCNode* m_mainLayer;
Expand Down
4 changes: 2 additions & 2 deletions src/practice_fixes/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PlayerData PlayerPracticeFixes::saveData(PlayerObject* player) {
#endif

data.position = player->getPosition();
data.rotationX = player->getRotationX();
data.rotation = player->getRotation();
data.m_holdingRight = player->m_holdingRight;
data.m_holdingLeft = player->m_holdingLeft;
data.m_mainLayer = player->m_mainLayer;
Expand Down Expand Up @@ -522,5 +522,5 @@ void PlayerPracticeFixes::applyData(PlayerObject* player, PlayerData data, bool
player->m_enable22Changes = data.m_enable22Changes;

player->setPosition(data.position);
player->setRotationX(data.rotationX);
player->setRotation(data.rotation);
}
2 changes: 1 addition & 1 deletion src/renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class $modify(CCScheduler) {
bool Renderer::toggle() {
auto& g = Global::get();
if (Loader::get()->isModLoaded("syzzi.click_between_frames")) {
FLAlertLayer::create("Render", "Disable CBF in Geode to render a level.", "OK");
FLAlertLayer::create("Render", "Disable CBF in Geode to render a level.", "OK")->show();
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/record_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ bool RecordLayer::setup() {
CCSprite* spriteOn = CCSprite::createWithSpriteFrameName("GJ_checkOn_001.png");
CCSprite* spriteOff = CCSprite::createWithSpriteFrameName("GJ_checkOff_001.png");

CCLabelBMFont* versionLabel = CCLabelBMFont::create("xdBot v2.0.0-beta.7", "chatFont.fnt");
CCLabelBMFont* versionLabel = CCLabelBMFont::create(("xdBot " + xdBotVersion).c_str(), "chatFont.fnt");
versionLabel->setOpacity(63);
versionLabel->setPosition(ccp(-217, -125));
versionLabel->setAnchorPoint({ 0, 0.5 });
Expand Down

0 comments on commit b470dd9

Please sign in to comment.