Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local M = {}
local imgui = ui_imgui
local http = require("socket.http")
local VERSION_PRTL = "0.7.1"
local version = require("lua/ge/extensions/version")
local VERSION_PRTL = version.VERSION_STR

local filter_servers_notfull = imgui.BoolPtr(false)
local filter_servers_notempty = imgui.BoolPtr(false)
Expand Down
5 changes: 3 additions & 2 deletions KISSMultiplayer/lua/ge/extensions/network.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local M = {}

M.VERSION_STR = "0.7.1"
local version = require("lua/ge/extensions/version")
M.VERSION_STR = version.VERSION_STR
M.is_server_public = false

M.downloads = {}
Expand Down Expand Up @@ -337,7 +338,7 @@ local function connect(addr, player_name, is_public)
name = player_name,
secret = generate_secret(server_info.server_identifier),
steamid64 = steamid64,
client_version = {0, 7}
client_version = version.VERSION
}
}
send_data(client_info, true)
Expand Down
1 change: 1 addition & 0 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "shared"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
36 changes: 36 additions & 0 deletions shared/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::env;
use std::fs;
use std::path::Path;

fn main() {
let version_str = env!("CARGO_PKG_VERSION");
let parts: Vec<u32> = version_str.split('.')
.map(|s| s.parse().unwrap_or(0))
.collect();
let major = parts[0];
let minor = parts[1];

// Generate Lua version file
let lua_version_content = format!(
"-- Generated by shared/build.rs\nlocal M = {{}}\nM.VERSION_STR = \"{}\"\nM.VERSION = {{ {}, {} }}\nreturn M\n",
version_str, major, minor
);

let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let lua_file_path = Path::new(&manifest_dir).parent().unwrap().join("KISSMultiplayer/lua/ge/extensions/version.lua");

// Create directory if it doesn't exist
if let Some(parent) = lua_file_path.parent() {
let _ = fs::create_dir_all(parent);
}

let _ = fs::write(lua_file_path, lua_version_content);

// Generate Rust version file
let rust_version_content = format!(
"// Generated by shared/build.rs\npub const VERSION: (u32, u32) = ({}, {});\npub const VERSION_STR: &str = \"{}\";\n",
major, minor, version_str
);
let rust_file_path = Path::new(&manifest_dir).join("src/version_gen.rs");
let _ = fs::write(rust_file_path, rust_version_content);
}
4 changes: 2 additions & 2 deletions shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::io::Write;
use chrono::Local;
pub use log::{info, warn, error};

pub const VERSION: (u32, u32) = (0, 7);
pub const VERSION_STR: &str = "0.7.1";
mod version_gen;
pub use version_gen::*;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ClientInfoPrivate {
Expand Down
3 changes: 3 additions & 0 deletions shared/src/version_gen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Generated by shared/build.rs
pub const VERSION: (u32, u32) = (0, 7);
pub const VERSION_STR: &str = "0.7.1";