Skip to content

Commit 7240a90

Browse files
committed
v1.1.1
1 parent d43db5a commit 7240a90

4 files changed

Lines changed: 27 additions & 23 deletions

File tree

src/GatoBot.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,17 @@ GatoBot* GatoBot::sharedState() {
3232
}
3333

3434
bool GatoBot::FFmpegInstalled() {
35-
auto utils = CCFileUtils::sharedFileUtils();
35+
/*auto utils = CCFileUtils::sharedFileUtils();
3636
3737
// what is bro cooking :skull:
3838
auto path = utils->fullPathForFilename("ffmpeg.exe", false);
39-
return strcmp(path.c_str(), "ffmpeg.exe");
39+
return strcmp(path.c_str(), "ffmpeg.exe");*/
40+
41+
WCHAR buffer[MAX_PATH];
42+
GetModuleFileNameW(GetModuleHandleA(nullptr), buffer, MAX_PATH);
43+
const auto path = std::filesystem::path(buffer).parent_path() / "ffmpeg.exe";
44+
45+
return std::filesystem::exists(path);
4046
}
4147

4248
int GatoBot::getCurrentFPS() {

src/GatoBot.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class GatoBot {
159159

160160
void handleFrame(gd::PlayLayer*);
161161
void handleCheckpoint(gd::PlayLayer*);
162+
void handleClick(gd::GJBaseGameLayer*, bool, ButtonType);
162163

163164
void saveReplay(std::string& filepath);
164165
void loadReplay(std::string data);

src/Record.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,17 @@ void GatoBot::saveReplay(std::string& filePath) {
133133

134134
// done
135135
saveFile.close();
136+
}
137+
138+
void GatoBot::handleClick(gd::GJBaseGameLayer* self, bool rightSide, ButtonType btnType) {
139+
bool twoPlayer = MBO(bool, self->m_pLevelSettings, 0xFA);
140+
141+
bool playerIsDead = MBO(bool, self, 0x39C);
142+
143+
if(status == Recording && !playerIsDead) {
144+
if(MBO(bool, self, 0x2A9) && !rightSide && twoPlayer)
145+
queuedBtnP2 = btnType;
146+
147+
else queuedBtnP1 = btnType;
148+
}
136149
}

src/main.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,14 @@ void(__thiscall* GJBaseGameLayer_pushButtonO)(gd::GJBaseGameLayer*, int, bool);
145145
void __fastcall GJBaseGameLayer_pushButtonH(gd::GJBaseGameLayer* self, uintptr_t, int button, bool rightSide) {
146146
GJBaseGameLayer_pushButtonO(self, button, rightSide);
147147

148-
auto bot = GatoBot::sharedState();
149-
150-
if(bot->status == Recording && !MBO(bool, self, 0x39C)) {
151-
bool twoPlayer = MBO(bool, self->m_pLevelSettings, 0xFA);
152-
153-
if(MBO(bool, self, 0x2A9) && !rightSide && twoPlayer)
154-
bot->queuedBtnP2 = Pressed;
155-
156-
else bot->queuedBtnP1 = Pressed;
157-
}
148+
GatoBot::sharedState()->handleClick(self, rightSide, Pressed);
158149
}
159150

160151
void(__thiscall* GJBaseGameLayer_releaseButtonO)(gd::GJBaseGameLayer*, int, bool);
161152
void __fastcall GJBaseGameLayer_releaseButtonH(gd::GJBaseGameLayer* self, uintptr_t, int button, bool rightSide) {
162153
GJBaseGameLayer_releaseButtonO(self, button, rightSide);
163154

164-
auto bot = GatoBot::sharedState();
165-
166-
if(bot->status == Recording && !MBO(bool, self, 0x39C)) {
167-
bool twoPlayer = MBO(bool, self->m_pLevelSettings, 0xFA);
168-
169-
if(MBO(bool, self, 0x2A9) && !rightSide && twoPlayer)
170-
bot->queuedBtnP2 = Released;
171-
172-
else bot->queuedBtnP1 = Released;
173-
}
155+
GatoBot::sharedState()->handleClick(self, rightSide, Released);
174156
}
175157

176158
void(__thiscall* UILayer_onCheckO)(gd::UILayer*, CCObject*);
@@ -239,6 +221,8 @@ void __fastcall PlayLayer_resetLevelH(gd::PlayLayer* self, uintptr_t) {
239221
}
240222

241223
// jump?
224+
// MBO(bool, self, 0x2A9) && !rightSide && twoPlayer
225+
242226
if(bot->levelFrames.back().player1.isHolding != MBO(bool, self->m_pPlayer1, 0x611)) {
243227
if(MBO(bool, self->m_pPlayer1, 0x611)) {
244228
bot->levelFrames.back().player1.action = Pressed;
@@ -250,7 +234,7 @@ void __fastcall PlayLayer_resetLevelH(gd::PlayLayer* self, uintptr_t) {
250234
}
251235
}
252236

253-
if(bot->levelFrames.back().player2.isHolding != MBO(bool, self->m_pPlayer2, 0x611)) {
237+
if(bot->levelFrames.back().player2.isHolding != MBO(bool, self->m_pPlayer2, 0x611) && (MBO(bool, self, 0x2A9) && !MBO(bool, self->m_pPlayer2, 0x611) && MBO(bool, self->m_pLevelSettings, 0xFA))) {
254238
if(MBO(bool, self->m_pPlayer2, 0x611)) {
255239
bot->levelFrames.back().player2.action = Pressed;
256240
bot->levelFrames.back().player2.isHolding = true;

0 commit comments

Comments
 (0)