#bindings #classi-cube #classicube

sys no-std classicube-sys

Rust C bindings for ClassiCube

6 stable releases

4.0.0+classicube.1.3.7 Oct 2, 2024
3.1.0+classicube.1.3.7 Oct 2, 2024
3.0.5+classicube.1.3.6 Sep 20, 2024
3.0.4+classicube.1.3.6 Jul 4, 2024
3.0.2+classicube.1.3.6 Feb 8, 2024

#282 in Game dev

Download history 78/week @ 2024-07-29 88/week @ 2024-08-05 52/week @ 2024-08-12 54/week @ 2024-08-19 59/week @ 2024-08-26 57/week @ 2024-09-02 72/week @ 2024-09-09 279/week @ 2024-09-16 83/week @ 2024-09-23 421/week @ 2024-09-30 106/week @ 2024-10-07 126/week @ 2024-10-14 77/week @ 2024-10-21 73/week @ 2024-10-28 117/week @ 2024-11-04 25/week @ 2024-11-11

295 downloads per month

MIT license

11MB
222K SLoC

C 210K SLoC // 0.2% comments GNU Style Assembly 3.5K SLoC // 0.0% comments Rust 3K SLoC // 0.0% comments Objective-C 2K SLoC // 0.2% comments JavaScript 1K SLoC // 0.1% comments Java 1K SLoC // 0.2% comments C++ 673 SLoC // 0.1% comments Visual Studio Project 610 SLoC C# 148 SLoC Shell 104 SLoC // 0.2% comments ReScript 84 SLoC Batch 66 SLoC HLSL 51 SLoC R 48 SLoC // 0.1% comments GLSL 43 SLoC Visual Studio Solution 43 SLoC

Contains (JAR file, 50KB) gradle-wrapper.jar

classicube-sys

Rust bindings to ClassiCube

Documentation

Example

Add this to Cargo.toml:

[lib]
crate-type = ["cdylib"]

[dependencies]
classicube-sys = { git = "https://github.com/SpiralP/rust-classicube-sys.git" }

lib.rs:

use classicube_sys::*;
use std::{os::raw::c_int, ptr};

extern "C" fn init() {
    let owned_string = OwnedString::new("hello from rust!");
    unsafe {
        Chat_Add(owned_string.as_cc_string());
    }
}

#[no_mangle]
pub static Plugin_ApiVersion: c_int = 1;

#[no_mangle]
pub static mut Plugin_Component: IGameComponent = IGameComponent {
    // Called when the game is being loaded.
    Init: Some(init),
    // Called when the component is being freed. (e.g. due to game being closed)
    Free: None,
    // Called to reset the component's state. (e.g. reconnecting to server)
    Reset: None,
    // Called to update the component's state when the user begins loading a new map.
    OnNewMap: None,
    // Called to update the component's state when the user has finished loading a new map.
    OnNewMapLoaded: None,
    // Next component in linked list of components.
    next: ptr::null_mut(),
};

Copy the .dll/.so/.dylib from target/{debug,release}/ to the plugins folder where your ClassiCube executable is found

References

Example library usage

ClassiCube source

ClassiCube Plugin help

ClassiCube Plugin examples

Dependencies