Skip to content

Commit

Permalink
wtf it works
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubesicle committed Sep 26, 2024
1 parent f740d96 commit 4de3b35
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 36 deletions.
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ set(GEODE_TARGET_PLATFORM "Win64")

project(test VERSION 1.0.0)

# Set up the mod binary
add_library(${PROJECT_NAME} SHARED
src/main.cpp
# Add any extra C++ source files here
)

include(FetchContent)

FetchContent_Declare(
Expand All @@ -23,10 +17,20 @@ FetchContent_Declare(
FetchContent_MakeAvailable(Corrosion)

# Import targets defined in a package or workspace manifest `Cargo.toml` file
corrosion_import_crate(MANIFEST_PATH ${CMAKE_SOURCE_DIR}/Cargo.toml)
corrosion_import_crate(MANIFEST_PATH Cargo.toml)

corrosion_experimental_cbindgen(
TARGET rusty
HEADER_NAME Rusty.h
)

# Set up the mod binary
add_library(${PROJECT_NAME} SHARED
src/main.cpp
# Add any extra C++ source files here
)

target_link_libraries(${PROJECT_NAME} rusty)
include_directories(${CMAKE_SOURCE_DIR}/target)

if (NOT DEFINED ENV{GEODE_SDK})
message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode")
Expand Down
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ edition = "2021"
path = "rusty-src/lib.rs"
crate-type = ["staticlib"]

[dependencies]

[build-dependencies]
cbindgen = "0.27"
[dependencies]
12 changes: 0 additions & 12 deletions build.rs

This file was deleted.

7 changes: 3 additions & 4 deletions rusty-src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::ffi::c_int;

#[no_mangle]
pub extern "C" fn peepeepoopoo() -> c_int {
69
pub extern "C" fn bingus(this_ptr: isize, fn_ptr: isize) {
println!("Hello from rust!! >:) {:#06x} {:#06x}", this_ptr, fn_ptr);
unsafe { std::mem::transmute::<_, fn(isize)>(fn_ptr)(this_ptr); }
}
12 changes: 4 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
* Include the Geode headers.
*/
#include "Geode/loader/ModEvent.hpp"
#include "Geode/binding/PlayLayer.hpp"
#include <Geode/Geode.hpp>
#include <Geode/utils/addresser.hpp>
#include "Rusty.h"

/**
* Brings cocos2d and all Geode namespaces to the current scope.
Expand Down Expand Up @@ -103,12 +105,6 @@ class $modify(MyMenuLayer, MenuLayer) {
#include "Geode/modify/PlayLayer.hpp"
class $modify(PlayLayer) {
void startGame() {
log::info("fuck you lmao");
PlayLayer::startGame();
bingus(getNonVirtual(this), getNonVirtual(&PlayLayer::startGame));
}
};

#include "Rusty.h"
$on_mod(Loaded) {
peepeepoopoo();
};

0 comments on commit 4de3b35

Please sign in to comment.