Skip to content

Commit

Permalink
2.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko committed Jan 13, 2025
1 parent f8bb207 commit 1d5ae22
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 47 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v2.3.7

* Fixed macro death bug with other bot's macros.
* Fixed tps input bugs.
* Made render use video args if using ffmpeg api.
* Made render settings that dont work gray out if youre using ffmpeg api.

# v2.3.6

* Improved compatibility with other bot's macros (Pathfinder, Eclipse).
Expand Down
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"geode": "4.1.1",
"geode": "4.0.1",
"gd": {
"win": "2.2074",
"android": "2.2074"
},
"version": "2.3.6",
"version": "2.3.7",
"id": "zilko.xdbot",
"name": "xdBot",
"developer": "Zilko",
Expand Down
2 changes: 1 addition & 1 deletion src/gdr/gdr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cocos2d::CCPoint dataFromString(std::string dataString);

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

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

namespace gdr {

Expand Down
7 changes: 7 additions & 0 deletions src/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,21 @@ PauseLayer* Global::getPauseLayer() {
$execute{
auto & g = Global::get();

if (!g.mod->setSavedValue("defaults_set_14", true)) {
g.mod->setSavedValue("render_fade_in_video", std::to_string(2));
g.mod->setSavedValue("render_fade_out_video", std::to_string(2));
}

if (!g.mod->setSavedValue("defaults_set_12", true)) {
g.mod->setSettingValue<std::filesystem::path>("macros_folder", g.mod->getSaveDir() / "macros");
g.mod->setSettingValue<std::filesystem::path>("autosaves_folder", g.mod->getSaveDir() / "autosaves");
}

#ifdef GEODE_IS_ANDROID

if (!g.mod->setSavedValue("defaults_set_11", true))
g.mod->setSavedValue("render_codec", std::string("libx264"));

#endif

if (!g.mod->setSavedValue("defaults_set_10", true)) {
Expand Down
16 changes: 3 additions & 13 deletions src/hacks/tps_bypass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,22 @@

class $modify(GJBaseGameLayer) {

struct Fields {
float leftOver = 0.f;
};

void update(float dt) {
if (!Global::get().tpsEnabled) return GJBaseGameLayer::update(dt);
if (Global::getTPS() == 240.f) return GJBaseGameLayer::update(dt);
if (!PlayLayer::get()) return GJBaseGameLayer::update(dt);
if (Global::get().frameStepper) return GJBaseGameLayer::update(dt);

using namespace std::literals;
if (!PlayLayer::get()) return GJBaseGameLayer::update(dt);

float newDt = 1.f / Global::getTPS();

auto startTime = std::chrono::high_resolution_clock::now();
int mult = static_cast<int>((dt + m_fields->leftOver) / newDt);

for (int i = 0; i < mult; ++i) {
for (int i = 0; i < static_cast<int>(dt / newDt); ++i) {
GJBaseGameLayer::update(newDt);
if (std::chrono::high_resolution_clock::now() - startTime > 33.333ms) {
mult = i + 1;
if (std::chrono::high_resolution_clock::now() - startTime > std::chrono::duration<double, std::milli>(16.666))
break;
}
}

m_fields->leftOver += (dt - newDt * mult);
}

float getModifiedDelta(float dt) {
Expand Down
17 changes: 6 additions & 11 deletions src/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,14 @@ void Macro::updateTPS() {

if (g.state != state::none && !g.macro.inputs.empty()) {
g.previousTpsEnabled = g.tpsEnabled;
g.previousTps = g.tps;

g.mod->setSavedValue("macro_tps", g.macro.framerate);
g.mod->setSavedValue("macro_tps_enabled", true);
g.tpsEnabled = g.macro.framerate != 240.f;
if (g.tpsEnabled) g.tps = g.macro.framerate;

if (g.macro.framerate != 240.f) {
g.tps = g.macro.framerate;
g.tpsEnabled = true;
g.previousTps = g.tps;
} else
g.tpsEnabled = false;

// g.tpsEnabled = g.tps != 240.f;
// if (g.tpsEnabled) g.tps = g.macro.framerate;
g.mod->setSavedValue("macro_tps", g.tps);
g.mod->setSavedValue("macro_tps_enabled", g.tpsEnabled);

}
else if (g.previousTps != 0.f) {
g.tpsEnabled = g.previousTpsEnabled;
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ class $modify(BGLHook, GJBaseGameLayer) {
return pl->resetLevel();
}

// if (g.previousFrame == frame && frame != 0)
// return GJBaseGameLayer::processCommands(dt);
if (g.previousFrame == frame && frame != 0 && g.macro.xdBotMacro)
return GJBaseGameLayer::processCommands(dt);

}

Expand All @@ -241,7 +241,7 @@ class $modify(BGLHook, GJBaseGameLayer) {
int frame = Global::getCurrentFrame();
g.previousFrame = frame;

if (g.restart && !m_levelEndAnimationStarted) {
if (g.macro.xdBotMacro && g.restart && !m_levelEndAnimationStarted) {
if ((m_levelSettings->m_platformerMode && g.state != state::none) || g.renderer.recording || g.renderer.recordingAudio)
return pl->resetLevelFromStart();
else
Expand Down
28 changes: 21 additions & 7 deletions src/renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ class $modify(CCScheduler) {

};

bool Renderer::shouldUseAPI() {
#ifdef GEODE_IS_WINDOWS

bool foundApi = Loader::get()->isModLoaded("eclipse.ffmpeg-api");
std::filesystem::path ffmpegPath = Mod::get()->getSettingValue<std::filesystem::path>("ffmpeg_path");
bool foundExe = std::filesystem::exists(ffmpegPath) && ffmpegPath.filename().string() == "ffmpeg.exe";

return !foundExe && foundApi;

#else

return true;

#endif

}

bool Renderer::toggle() {
auto& g = Global::get();
if (Loader::get()->isModLoaded("syzzi.click_between_frames")) {
Expand All @@ -149,14 +166,10 @@ bool Renderer::toggle() {
}

bool foundApi = Loader::get()->isModLoaded("eclipse.ffmpeg-api");

#ifdef GEODE_IS_WINDOWS
std::filesystem::path ffmpegPath = g.mod->getSettingValue<std::filesystem::path>("ffmpeg_path");
std::filesystem::path ffmpegPath = Mod::get()->getSettingValue<std::filesystem::path>("ffmpeg_path");
bool foundExe = std::filesystem::exists(ffmpegPath) && ffmpegPath.filename().string() == "ffmpeg.exe";
g.renderer.usingApi = !foundExe && foundApi;
#else
g.renderer.usingApi = true;
#endif

g.renderer.usingApi = Renderer::shouldUseAPI();

if (g.renderer.recording || g.renderer.recordingAudio) {
g.renderer.recordingAudio ? g.renderer.stopAudio() : g.renderer.stop(Global::getCurrentFrame());
Expand Down Expand Up @@ -291,6 +304,7 @@ void Renderer::start() {
settings.m_height = height;
settings.m_fps = fps;
settings.m_outputFile = path;
settings.m_colorspaceFilters = videoArgs;

if (!Mod::get()->setSavedValue("first_render_", true)) {
FLAlertLayer::create(
Expand Down
1 change: 1 addition & 0 deletions src/renderer/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ class Renderer {
void handleAudioRecording(PlayLayer* pl, int frame);

static bool toggle();
static bool shouldUseAPI();
bool tryPause();
};
2 changes: 2 additions & 0 deletions src/ui/record_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ void RecordLayer::togglePlaying(CCObject*) {
if (g.state == state::playing) {
g.currentAction = 0;
g.currentFrameFix = 0;

g.macro.xdBotMacro = g.macro.botInfo.name == "xdBot";

PlayLayer* pl = PlayLayer::get();

Expand Down
Loading

0 comments on commit 1d5ae22

Please sign in to comment.