Skip to content

Commit

Permalink
2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko committed Jan 11, 2025
1 parent 084f8eb commit 9056d88
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 106 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.4

* Fixed render green video?.

# v2.3.3

* Fixed android render inputs length being limited to 3 or 2 idk.
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.0.1",
"geode": "4.1.1",
"gd": {
"win": "2.2074",
"android": "2.2074"
},
"version": "2.3.3",
"version": "2.3.4",
"id": "zilko.xdbot",
"name": "xdBot",
"developer": "Zilko",
Expand Down
2 changes: 1 addition & 1 deletion src/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void Global::updateSeed(bool isRestart) {
else {
std::random_device rd;
std::mt19937 generator(rd());
std::uniform_int_distribution<int> distribution(1000, 9999);
std::uniform_int_distribution<int> distribution(1000, 999999999);
finalSeed = distribution(generator);
}

Expand Down
106 changes: 105 additions & 1 deletion src/hacks/clickbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,108 @@ class $modify(GJBaseGameLayer) {
Clickbot::playSound(id);
}

};
};

FMOD::Sound* Clickbot::getSound(std::string id) {
auto& c = get();

if (id == "hold_click")
return c.holdClick;
else if (id == "release_click")
return c.releaseClick;
else if (id == "hold_left")
return c.holdLeft;
else if (id == "release_left")
return c.releaseLeft;
else if (id == "hold_right")
return c.holdRight;
else if (id == "release_right")
return c.releaseRight;

return nullptr;
}

void Clickbot::setSound(std::string id, FMOD::Sound* sound) {
auto& c = get();

if (id == "hold_click")
c.holdClick = sound;
else if (id == "release_click")
c.releaseClick = sound;
else if (id == "hold_left")
c.holdLeft = sound;
else if (id == "release_left")
c.releaseLeft = sound;
else if (id == "hold_right")
c.holdRight = sound;
else if (id == "release_right")
c.releaseRight = sound;
}

void Clickbot::playSound(std::string id) {
auto& c = get();
if (!c.system) return updateSounds();

auto& g = Global::get();
matjson::Value data = g.mod->getSavedValue<matjson::Value>(id);
ClickSetting settings = matjson::Serialize<ClickSetting>::from_json(data);

if (settings.disabled) return;

FMOD::Sound* sound = getSound(id);

if (!sound) return;

FMOD_RESULT result;

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

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

result = c.channel->setPitch(g.currentPitch);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 4");

FMOD::DSP* pitchShifter = c.pitchShifter;
if (!pitchShifter) return updateSounds();

result = pitchShifter->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, settings.pitch * g.mod->getSavedValue<float>("clickbot_pitch"));
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 6");

result = c.channel->addDSP(0, pitchShifter);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 7");
}

void Clickbot::updateSounds() {
auto& c = get();
FMOD_RESULT result;

if (!c.system) {
FMODAudioEngine* fmod = FMODAudioEngine::sharedEngine();
c.system = fmod->m_system;
}

if (!c.system) return;

for (std::string name : buttonNames) {
matjson::Value data = Global::get().mod->getSavedValue<matjson::Value>(name);
ClickSetting settings = matjson::Serialize<ClickSetting>::from_json(data);
if (!std::filesystem::exists(settings.path)) continue;

FMOD::Sound* sound = getSound(name);
result = c.system->createSound(settings.path.string().c_str(), FMOD_DEFAULT, nullptr, &sound);
if (result != FMOD_OK) {
log::debug("Click sound errored. ID: 1");
continue;
}

setSound(name, sound);
}

if (!c.pitchShifter) {
result = c.system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &c.pitchShifter);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 5");
}
}
103 changes: 4 additions & 99 deletions src/hacks/clickbot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,107 +56,12 @@ class Clickbot {
return instance;
}

static FMOD::Sound* getSound(std::string id) {
auto& c = get();

if (id == "hold_click")
return c.holdClick;
else if (id == "release_click")
return c.releaseClick;
else if (id == "hold_left")
return c.holdLeft;
else if (id == "release_left")
return c.releaseLeft;
else if (id == "hold_right")
return c.holdRight;
else if (id == "release_right")
return c.releaseRight;

return nullptr;
}

static void setSound(std::string id, FMOD::Sound* sound) {
auto& c = get();

if (id == "hold_click")
c.holdClick = sound;
else if (id == "release_click")
c.releaseClick = sound;
else if (id == "hold_left")
c.holdLeft = sound;
else if (id == "release_left")
c.releaseLeft = sound;
else if (id == "hold_right")
c.holdRight = sound;
else if (id == "release_right")
c.releaseRight = sound;
}

static void playSound(std::string id) {
auto& c = get();
if (!c.system) return updateSounds();

auto& g = Global::get();
matjson::Value data = g.mod->getSavedValue<matjson::Value>(id);
ClickSetting settings = matjson::Serialize<ClickSetting>::from_json(data);

if (settings.disabled) return;

FMOD::Sound* sound = getSound(id);

if (!sound) 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");

result = c.channel->setVolume((settings.volume / 100.f) * (g.mod->getSavedValue<int64_t>("clickbot_volume") / 100.f));
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 3");
static FMOD::Sound* getSound(std::string id);

result = c.channel->setPitch(g.currentPitch);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 4");
static void setSound(std::string, FMOD::Sound*);

FMOD::DSP* pitchShifter = c.pitchShifter;
if (!pitchShifter) return updateSounds();
static void playSound(std::string);

result = pitchShifter->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, settings.pitch * g.mod->getSavedValue<float>("clickbot_pitch"));
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 6");

result = c.channel->addDSP(0, pitchShifter);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 7");
}

static void updateSounds() {
auto& c = get();
FMOD_RESULT result;

if (!c.system) {
FMODAudioEngine* fmod = FMODAudioEngine::sharedEngine();
c.system = fmod->m_system;
}

if (!c.system) return;

for (std::string name : buttonNames) {
matjson::Value data = Global::get().mod->getSavedValue<matjson::Value>(name);
ClickSetting settings = matjson::Serialize<ClickSetting>::from_json(data);
if (!std::filesystem::exists(settings.path)) continue;

FMOD::Sound* sound = getSound(name);
result = c.system->createSound(settings.path.string().c_str(), FMOD_DEFAULT, nullptr, &sound);
if (result != FMOD_OK) {
log::debug("Click sound errored. ID: 1");
continue;
}

setSound(name, sound);
}

if (!c.pitchShifter) {
result = c.system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &c.pitchShifter);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 5");
}
}
static void updateSounds();

};
2 changes: 1 addition & 1 deletion src/hacks/tps_bypass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class $modify(GJBaseGameLayer) {

if (0 < m_resumeTimer) {
// cocos2d::CCDirector::sharedDirector();
m_resumeTimer = m_resumeTimer + -1;
m_resumeTimer--;
dt = 0.0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const std::vector<float> safeValues = {
1.0f / 5, 1.0f / 4, 1.0f / 3, 1.0f / 2
};

const std::string xdBotVersion = "v2.3.3";
const std::string xdBotVersion = "v2.3.4";

enum state {
none,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void Renderer::start() {
} else {
#ifdef GEODE_IS_WINDOWS
command = fmt::format(
"\"{}\" -y -f rawvideo -pix_fmt yuv420p -s {}x{} -r {} -i - {}{}{} -vf \"vflip,{}{}\" -an \"{}\" ",
"\"{}\" -y -f rawvideo -pix_fmt rgb24 -s {}x{} -r {} -i - {}{}{} -vf \"vflip,{}{}\" -an \"{}\" ",
ffmpegPath,
std::to_string(width),
std::to_string(height),
Expand Down

0 comments on commit 9056d88

Please sign in to comment.