Hello there, folks.
I am working on a project that is in an unsupported programming language, but I can't switch languages right now due to the large amount of time I'd have to spend recoding the thing.
Instead, I thought of buying a code from someone. They gave me a code that can be compiled to a dll, and I can't do that. When I run build bat, it gives me some errors, which I don't understand. I will show you codes and things and the structure of files, and any of you can please tell me what to do.
Files and directories list:
src
build.bat
Cargo.lock
Cargo.toml
rust_fmt_nightly.bat
rustfmt.toml
codes list:
src/mods/map_system.rs
#![allow(unused)]
pub static mut CHECKPOINT_ID: i32 = 0;
pub static mut CLIENTTILEID: i32 = 0_i32;
pub static mut CLIENT_TILE_EXTENDED_ID: i32 = 0_i32;
pub static mut MAPID: i32 = 0;
pub static mut ZONEID: i32 = 0;
pub static mut CHECKPOINTS: Vec = Vec::new();
pub static mut MAPS: Vec = Vec::new();
pub static mut MAPTILES: Vec = Vec::new();
pub static mut MAPTILES_EXTENDED: Vec = Vec::new();
pub static mut MAPZONES: Vec = Vec::new();
pub struct Map {
pub name: Vec,
pub tiles: Vec,
pub map_id: i32,
pub tile_id: i32
}
impl Map {
pub fn init_server_map(name: Vec, tiles: Vec, map_id: i32, tile_id: i32) -> Self {
Self {
name,
tiles,
map_id,
tile_id
}
}
}
pub struct Checkpoint {
pub x: i32,
pub y: i32,
pub z: i32,
pub cps: i32,
pub id: i32
}
impl Checkpoint {
pub unsafe fn add_checkpoint(x: i32, y: i32, z: i32) -> Self {
CHECKPOINT_ID += 1;
Self {
x,
y,
z,
cps: 1,
id: CHECKPOINT_ID
}
}
}
pub struct MapItem {
pub minx: i32,
pub maxx: i32,
pub miny: i32,
pub maxy: i32,
pub minz: i32,
pub maxz: i32,
pub item_type: Vec,
pub active: bool,
pub transwall: bool,
pub id: i32
}
impl MapItem {
pub const fn add_map_item(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
item_type: Vec,
active: bool,
transwall: bool,
id: i32
) -> Self {
Self {
minx,
maxx,
miny,
maxy,
minz,
maxz,
item_type,
active,
transwall,
id
}
}
}
pub unsafe fn get_client_tile_transwall(x: i32, y: i32, z: i32) -> Option<&'static MapItem> {
MAPTILES.iter().rev().find(|a| {
a.transwall
&& a.minx <= x
&& a.maxx >= x
&& a.miny <= y
&& a.maxy >= y
&& a.minz <= z
&& a.maxz >= z
})
}
pub unsafe fn get_client_tile_at(x: i32, y: i32, z: i32) -> Option<&'static MapItem> {
MAPTILES
.iter()
.rev()
.find(|a| a.minx <= x && a.maxx >= x && a.miny <= y && a.maxy >= y && a.minz <= z && a.maxz >= z)
}
pub unsafe fn get_extended_client_tile_at(x: i32, y: i32, z: i32) -> Option<&'static MapItem> {
if let Some(tile) = MAPTILES_EXTENDED.iter().rev().find(|a| {
a.active && a.minx <= x && a.maxx >= x && a.miny <= y && a.maxy >= y && a.minz <= z && a.maxz >= z
}) {
return Some(tile);
}
MAPTILES
.iter()
.rev()
.find(|a| a.minx <= x && a.maxx >= x && a.miny <= y && a.maxy >= y && a.minz <= z && a.maxz >= z)
}
pub unsafe fn get_server_tile_at(
x: i32,
y: i32,
z: i32,
map_name: &[u8]
) -> Option<&'static MapItem> {
if let Some(map) = get_map_by_ref(map_name) {
return map
.tiles
.iter()
.rev()
.find(|a| a.minx <= x && a.maxx >= x && a.miny <= y && a.maxy >= y && a.minz <= z && a.maxz >= z);
}
None
}
pub unsafe fn get_server_tile_by_map_id_at(
x: i32,
y: i32,
z: i32,
map_id: i32
) -> Option<&'static MapItem> {
if let Some(map) = get_map_by_ref_from_id(map_id) {
return map
.tiles
.iter()
.rev()
.find(|a| a.minx <= x && a.maxx >= x && a.miny <= y && a.maxy >= y && a.minz <= z && a.maxz >= z);
}
None
}
pub unsafe fn add_server_tile(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
map_name: &[u8],
tile: &[u8]
) {
if let Some(map) = get_map_by_mut_ref(map_name) {
map.tiles.push(MapItem::add_map_item(
minx,
maxx,
miny,
maxy,
minz,
maxz,
tile.to_vec(),
true,
false,
0
));
}
}
pub unsafe fn add_server_tile_return_id(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
map_name: &[u8],
tile: &[u8],
transwall: bool
) -> i32 {
if let Some(map) = get_map_by_mut_ref(map_name) {
map.tile_id += 1;
map.tiles.push(MapItem::add_map_item(
minx,
maxx,
miny,
maxy,
minz,
maxz,
tile.to_vec(),
true,
transwall,
map.tile_id
));
return map.tile_id;
}
0
}
pub unsafe fn clear_client_tiles(release_memory: i32) {
MAPTILES.clear();
CLIENTTILEID = 0;
if release_memory == 1 {
MAPTILES.shrink_to_fit();
}
}
pub unsafe fn clear_extended_client_tiles(release_memory: i32) {
MAPTILES_EXTENDED.clear();
CLIENT_TILE_EXTENDED_ID = 0;
if release_memory == 1 {
MAPTILES_EXTENDED.shrink_to_fit();
}
}
pub unsafe fn clear_server_tiles(map_name: &[u8], release_memory: i32) {
if let Some(map) = get_map_by_mut_ref(map_name) {
map.tiles.clear();
if release_memory == 1 {
map.tiles.shrink_to_fit();
}
}
}
pub unsafe fn remove_server_map(map_name: &[u8]) {
if let Some(index) = MAPS.iter().position(|x| x.name == map_name) {
MAPS.remove(index);
}
}
pub unsafe fn is_client_staircase(x: i32, y: i32, z: i32) -> i32 {
if MAPTILES.iter().rev().any(|a| {
a.minz != a.maxz
&& a.minx <= x
&& a.maxx >= x
&& a.miny <= y
&& a.maxy >= y
&& a.minz <= z
&& a.maxz >= z
}) {
return 1;
}
0
}
pub unsafe fn is_server_staircase(x: i32, y: i32, z: i32, map_name: &[u8]) -> i32 {
if let Some(map) = get_map_by_ref(map_name) {
if map.tiles.iter().rev().any(|a| {
a.minz != a.maxz
&& a.minx <= x
&& a.maxx >= x
&& a.miny <= y
&& a.maxy >= y
&& a.minz <= z
&& a.maxz >= z
}) {
return 1;
}
}
0
}
pub unsafe fn get_map_index(map_name: &[u8]) -> Option {
MAPS.iter().position(|x| x.name == map_name)
}
pub unsafe fn get_map_by_ref(map_name: &[u8]) -> Option<&'static Map> {
MAPS.iter().find(|x| x.name == map_name)
}
pub unsafe fn get_map_by_mut_ref(map_name: &[u8]) -> Option<&'static mut Map> {
MAPS.iter_mut().find(|x| x.name == map_name)
}
pub unsafe fn get_map_by_ref_from_id(map_id: i32) -> Option<&'static Map> {
MAPS.iter().find(|x| x.map_id == map_id)
}
pub unsafe fn map_exists(map_name: &[u8]) -> bool {
MAPS.iter().rev().any(|a| a.name == map_name)
}
pub unsafe fn increase_client_tile_id() -> i32 {
CLIENTTILEID += 1;
CLIENTTILEID
}
pub unsafe fn increase_client_tile_extended_id() -> i32 {
CLIENT_TILE_EXTENDED_ID += 1;
CLIENT_TILE_EXTENDED_ID
}
pub unsafe fn update_client_tile_positions_by_id(
tile_id: i32,
new_minx: i32,
new_maxx: i32,
new_miny: i32,
new_maxy: i32,
new_minz: i32,
new_maxz: i32
) {
if let Some(tile) = MAPTILES.iter_mut().find(|a| a.id == tile_id) {
tile.minx = new_minx;
tile.maxx = new_maxx;
tile.miny = new_miny;
tile.maxy = new_maxy;
tile.minz = new_minz;
tile.maxz = new_maxz;
}
}
pub unsafe fn update_client_tile_extended_positions_by_id(
tile_id: i32,
new_minx: i32,
new_maxx: i32,
new_miny: i32,
new_maxy: i32,
new_minz: i32,
new_maxz: i32
) {
if let Some(tile) = MAPTILES_EXTENDED.iter_mut().find(|a| a.id == tile_id) {
tile.minx = new_minx;
tile.maxx = new_maxx;
tile.miny = new_miny;
tile.maxy = new_maxy;
tile.minz = new_minz;
tile.maxz = new_maxz;
}
}
pub unsafe fn update_client_tile_name_by_id(tile_id: i32, new_name: &[u8]) {
if let Some(tile) = MAPTILES.iter_mut().find(|a| a.id == tile_id) {
tile.item_type = new_name.to_vec();
}
}
pub unsafe fn update_client_tile_extended_name_by_id(tile_id: i32, new_name: &[u8]) {
if let Some(tile) = MAPTILES_EXTENDED.iter_mut().find(|a| a.id == tile_id) {
tile.item_type = new_name.to_vec();
}
}
pub unsafe fn remove_client_tile_by_id(id: i32) {
if let Some(index) = MAPTILES.iter().position(|x| x.id == id) {
MAPTILES.remove(index);
}
}
pub unsafe fn remove_client_tile_extended_by_id(id: i32) {
if let Some(index) = MAPTILES_EXTENDED.iter().position(|x| x.id == id) {
MAPTILES_EXTENDED.remove(index);
}
}
pub unsafe fn set_client_tile_extended_status(id: i32, status: bool) {
if let Some(tile) = MAPTILES_EXTENDED.iter_mut().rev().find(|a| a.id == id) {
tile.active = status;
}
}
pub unsafe fn increase_zone_id() -> i32 {
ZONEID += 1;
ZONEID
}
pub unsafe fn get_zone_at(x: i32, y: i32, z: i32) -> Option<&'static MapItem> {
MAPZONES
.iter()
.rev()
.find(|a| a.minx <= x && a.maxx >= x && a.miny <= y && a.maxy >= y && a.minz <= z && a.maxz >= z)
}
pub unsafe fn remove_client_zone_by_id(id: i32) {
if let Some(index) = MAPZONES.iter().position(|x| x.id == id) {
MAPZONES.remove(index);
}
}
pub unsafe fn clear_client_zones(release_memory: i32) {
MAPZONES.clear();
ZONEID = 0;
if release_memory == 1 {
MAPZONES.shrink_to_fit();
}
}
pub unsafe fn add_client_checkpoint_return_id(x: i32, y: i32, z: i32) -> i32 {
if let Some(checkpoint) = CHECKPOINTS
.iter_mut()
.find(|entry| entry.x == x && entry.y == y && entry.z == z)
{
checkpoint.cps += 1;
checkpoint.id
} else {
CHECKPOINTS.push(Checkpoint::add_checkpoint(x, y, z));
CHECKPOINTS.last().unwrap_unchecked().id
}
}
pub unsafe fn remove_client_checkpoint_by_position(x: i32, y: i32, z: i32) {
if let Some(index) = CHECKPOINTS
.iter_mut()
.position(|entry| entry.x == x && entry.y == y && entry.z == z)
{
CHECKPOINTS[index].cps -= 1;
if CHECKPOINTS[index].cps <= 0 {
CHECKPOINTS.remove(index);
}
}
}
pub unsafe fn remove_client_checkpointby_id(id: i32) {
if let Some(index) = CHECKPOINTS.iter_mut().position(|entry| entry.id == id) {
CHECKPOINTS[index].cps -= 1;
if CHECKPOINTS[index].cps <= 0 {
CHECKPOINTS.remove(index);
}
}
}
src/mods/mod.rs
pub mod map_system;
src/lib.rs
mod mods;
use {
mods::map_system,
std::{ffi::CStr, os::raw::c_char}
};
#[no_mangle]
#[inline]
pub unsafe extern "system" fn get_map_index(map_name: *const c_char, result_ptr: *mut i32) {
if let Some(index) = map_system::get_map_index(CStr::from_ptr(map_name).to_bytes()) {
*result_ptr = index.try_into().unwrap();
} else {
*result_ptr = -1;
}
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn init_server_map_without_tiles(map_name: *const c_char) {
map_system::MAPID += 1;
map_system::MAPS.push(map_system::init_server_map(
CStr::from_ptr(map_name).to_bytes().to_vec(),
Vec::<map_system::MapItem>::new(),
map_system::MAPID,
0
));
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn init_server_map_without_tiles_ret_id(
map_name: *const c_char,
id_ptr: *mut i32
) {
map_system::MAPID += 1;
map_system::MAPS.push(map_system::init_server_map(
CStr::from_ptr(map_name).to_bytes().to_vec(),
Vec::<map_system::MapItem>::new(),
map_system::MAPID,
0
));
*id_ptr = map_system::MAPID;
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_server_map(map_name: *const c_char) {
map_system::remove_server_map(CStr::from_ptr(map_name).to_bytes());
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_all_client_tiles(release_memory: i32) {
map_system::clear_client_tiles(release_memory);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_all_extended_client_tiles(release_memory: i32) {
map_system::clear_extended_client_tiles(release_memory);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_all_server_tiles(
map_name: *const c_char,
release_memory: i32
) {
map_system::clear_server_tiles(CStr::from_ptr(map_name).to_bytes(), release_memory);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn add_server_tile_return_id(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
map: *const c_char,
tile: *const c_char,
id_ptr: *mut i32
) {
*id_ptr = map_system::add_server_tile_return_id(
minx,
maxx,
miny,
maxy,
minz,
maxz,
CStr::from_ptr(map).to_bytes(),
CStr::from_ptr(tile).to_bytes_with_nul(),
false
);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn add_server_tile(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
map: *const c_char,
tile: *const c_char
) {
map_system::add_server_tile(
minx,
maxx,
miny,
maxy,
minz,
maxz,
CStr::from_ptr(map).to_bytes(),
CStr::from_ptr(tile).to_bytes_with_nul()
);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn is_client_staircase(x: i32, y: i32, z: i32, result_ptr: *mut i32) {
*result_ptr = map_system::is_client_staircase(x, y, z);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn is_server_staircase(
x: i32,
y: i32,
z: i32,
map_name: *const c_char,
result_ptr: *mut i32
) {
*result_ptr = map_system::is_server_staircase(x, y, z, CStr::from_ptr(map_name).to_bytes());
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn get_client_tile_transwall(
x: i32,
y: i32,
z: i32,
result_ptr: *mut i32
) {
if map_system::get_client_tile_transwall(x, y, z).is_some() {
*result_ptr = 1;
} else {
*result_ptr = 0_i32;
}
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn get_client_tile(x: i32, y: i32, z: i32, result_ptr: *mut i32) {
if let Some(tile) = map_system::get_client_tile_at(x, y, z) {
*result_ptr = tile.item_type.as_ptr() as i32;
} else {
*result_ptr = 0_i32;
}
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn get_extended_client_tile(
x: i32,
y: i32,
z: i32,
result_ptr: *mut i32
) {
if let Some(tile) = map_system::get_extended_client_tile_at(x, y, z) {
*result_ptr = tile.item_type.as_ptr() as i32;
} else {
*result_ptr = 0_i32;
}
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn get_server_tile(
x: i32,
y: i32,
z: i32,
map: *const c_char,
result_ptr: *mut i32
) {
if let Some(tile) = map_system::get_server_tile_at(x, y, z, CStr::from_ptr(map).to_bytes()) {
*result_ptr = tile.item_type.as_ptr() as i32;
} else {
*result_ptr = 0_i32;
}
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn get_server_tile_by_map_id(
x: i32,
y: i32,
z: i32,
map_id: i32,
result_ptr: *mut i32
) {
if let Some(tile) = map_system::get_server_tile_by_map_id_at(x, y, z, map_id) {
*result_ptr = tile.item_type.as_ptr() as i32;
} else {
*result_ptr = 0_i32;
}
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn spawn_client_tile(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
tile: *const c_char
) {
map_system::MAPTILES.push(map_system::MapItem::add_map_item(
minx,
maxx,
miny,
maxy,
minz,
maxz,
CStr::from_ptr(tile).to_bytes_with_nul().to_vec(),
true,
false,
map_system::increase_client_tile_id()
));
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn spawn_client_tile_return_id(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
tile: *const c_char,
transwall: bool,
id_ptr: *mut i32
) {
map_system::MAPTILES.push(map_system::MapItem::add_map_item(
minx,
maxx,
miny,
maxy,
minz,
maxz,
CStr::from_ptr(tile).to_bytes_with_nul().to_vec(),
true,
transwall,
map_system::increase_client_tile_id()
));
*id_ptr = map_system::CLIENTTILEID;
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn spawn_client_tile_extended(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
tile: *const c_char
) {
map_system::MAPTILES_EXTENDED.push(map_system::MapItem::add_map_item(
minx,
maxx,
miny,
maxy,
minz,
maxz,
CStr::from_ptr(tile).to_bytes_with_nul().to_vec(),
true,
false,
map_system::increase_client_tile_extended_id()
));
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn spawn_client_tile_extended_return_id(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
tile: *const c_char,
id_ptr: *mut i32
) {
map_system::MAPTILES_EXTENDED.push(map_system::MapItem::add_map_item(
minx,
maxx,
miny,
maxy,
minz,
maxz,
CStr::from_ptr(tile).to_bytes_with_nul().to_vec(),
true,
false,
map_system::increase_client_tile_extended_id()
));
*id_ptr = map_system::CLIENT_TILE_EXTENDED_ID;
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn map_exists(map_name: *const c_char, result_ptr: *mut i32) {
*result_ptr = i32::from(map_system::map_exists(CStr::from_ptr(map_name).to_bytes()));
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn update_client_tile_name_by_id(id: i32, new_name: *const c_char) {
map_system::update_client_tile_name_by_id(id, CStr::from_ptr(new_name).to_bytes_with_nul());
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn update_client_tile_extended_name_by_id(
id: i32,
new_name: *const c_char
) {
map_system::update_client_tile_extended_name_by_id(
id,
CStr::from_ptr(new_name).to_bytes_with_nul()
);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn update_client_tile_positions_by_id(
id: i32,
new_minx: i32,
new_maxx: i32,
new_miny: i32,
new_maxy: i32,
new_minz: i32,
new_maxz: i32
) {
map_system::update_client_tile_positions_by_id(
id, new_minx, new_maxx, new_miny, new_maxy, new_minz, new_maxz
);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn update_client_tile_extended_positions_by_id(
id: i32,
new_minx: i32,
new_maxx: i32,
new_miny: i32,
new_maxy: i32,
new_minz: i32,
new_maxz: i32
) {
map_system::update_client_tile_extended_positions_by_id(
id, new_minx, new_maxx, new_miny, new_maxy, new_minz, new_maxz
);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_client_tile_by_id(id: i32) {
map_system::remove_client_tile_by_id(id);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_client_tile_by_position(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
tile_name: *const c_char
) {
if let Some(index) = map_system::MAPTILES.iter().position(|tile| {
tile.item_type == CStr::from_ptr(tile_name).to_bytes_with_nul()
&& tile.minx == minx
&& tile.maxx == maxx
&& tile.miny == miny
&& tile.maxy == maxy
&& tile.minz == minz
&& tile.maxz == maxz
}) {
map_system::MAPTILES.remove(index);
}
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_client_tile_extended_by_id(id: i32) {
map_system::remove_client_tile_extended_by_id(id);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn set_client_tile_extended_status(id: i32, status: bool) {
map_system::set_client_tile_extended_status(id, status);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn add_client_zone_return_id(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
zone: *const c_char,
id_ptr: *mut i32
) {
map_system::MAPZONES.push(map_system::MapItem::add_map_item(
minx,
maxx,
miny,
maxy,
minz,
maxz,
CStr::from_ptr(zone).to_bytes_with_nul().to_vec(),
true,
false,
map_system::increase_zone_id()
));
*id_ptr = map_system::ZONEID;
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn add_client_zone(
minx: i32,
maxx: i32,
miny: i32,
maxy: i32,
minz: i32,
maxz: i32,
zone: *const c_char
) {
map_system::MAPZONES.push(map_system::MapItem::add_map_item(
minx,
maxx,
miny,
maxy,
minz,
maxz,
CStr::from_ptr(zone).to_bytes_with_nul().to_vec(),
true,
false,
map_system::increase_zone_id()
));
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn get_zone_at(x: i32, y: i32, z: i32, result_ptr: *mut i32) {
if let Some(zone) = map_system::get_zone_at(x, y, z) {
*result_ptr = zone.item_type.as_ptr() as i32;
} else {
*result_ptr = 0_i32;
}
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_client_zone_by_id(id: i32) {
map_system::remove_client_zone_by_id(id);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn remove_all_client_zones(release_memory: i32) {
map_system::clear_client_zones(release_memory);
}
#[no_mangle]
#[inline]
pub unsafe extern "system" fn rename_server_map(
old_map_name: *const c_char,
new_map_name: *const c_char,
result_ptr: *mut i32
) {
let temp = CStr::from_ptr(old_map_name).to_bytes().to_vec();
if let Some(map) = map_system::MAPS.iter_mut().find(|x| x.name == temp) {
map.name = CStr::from_ptr(new_map_name).to_bytes().to_vec();
*result_ptr = 1;
} else {
result_ptr = 0;
}
}
build.bat
@echo off
cargo fmt
cargo build --target=i686-pc-windows-msvc --release
pause
Cargo.toml
[package]
name = "map-engine"
version = "0.1.0"
edition = "2021"
[lib]
crate_type =["cdylib"]
[profile.release]
lto = true
panic = "abort"
[profile.release.package.""]
opt-level = 3
rust_fmt_nightly.bat
@echo off
cargo +nightly fmt
pause
rustfmt.toml
unstable_features = true
brace_style= "PreferSameLine"
edition = "2021"
imports_granularity = "One"
tab_spaces = 0
trailing_comma = "Never"
I believe that is all the readable codes, I want this code to compile when I run the built bat file. You can make improvements to the code if you wish, it will be thank full. But, please don't change the functionality of the code.
Thanks and sincerely regards:
I believe that is all the readable code. I want this code to compile when I run the built bat file. You are welcome to make changes to the code; it will be greatly appreciated.But please don't change the functionality of the code.
Thank you very much,