Rust help needed, beginner

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::map::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::map::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,

With this much code, can you put it in a public repository somewhere?

Hello there,
Please accept my sincere apologies, for now this one can be in here. But in the next questions, I'll make sure to put it up in a repo. Thank you very much.

Please take a look at the pinned post about code formatting. And note that you can edit posts :wink:

2 Likes

Could you copy and paste the errors that you get when you try to run build.bat?

I suspect it might have to do with the cargo fmt invocation: it could be erroring on the unstable rustfmt features.

If you bought that code from someone but it doesn't work, it only makes sense to address your question to the person you bought it from. They'll know more than we here about the way their code should be built, and they have an obligation to provide a working product.

4 Likes

Hey all, the seller says that he is able to compile this code and he says he doesn't needs to help. Andf there's like 73 errors on the file I believe it's so hard to copy.

Well, it's possible to a) format the code according to link above, and b) copy at least one of the errors, if they all look similar.

2 Likes

General Kenobi :v:

Please, consider formatting your code properly :blush:

2 Likes

Warning: can't set imports_granularity = One, unstable features are only available in nightly channel.
Warning: can't set brace_style = PreferSameLine, unstable features are only available in nightly channel.
Warning: can't set trailing_comma = Never, unstable features are only available in nightly channel.
Warning: can't set unstable_features = true, unstable features are only available in nightly channel.
Compiling map-engine v0.1.0 (C:\Users\admin\Downloads\mapengine)
Building [ ] 0/1: map-engine
error[E0463]: can't find crate for std
|
= note: the i686-pc-windows-msvc target may not be installed
= help: consider downloading the target with rustup target add i686-pc-windows-msvc
|
= note: the i686-pc-windows-msvc target may not be installed
= help: consider downloading the target with rustup target add i686-pc-windows-msvc
error[E0463]: can't find crate for std
--> src\lib.rs:4:1
|
4 | std::{ffi::CStr, os::raw::c_char},
| ^^^ can't find crate
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:7:29
|
7 | pub static mut CHECKPOINTS: Vec = Vec::new();
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:8:22
|
8 | pub static mut MAPS: Vec = Vec::new();
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:9:26
|
9 | pub static mut MAPTILES: Vec = Vec::new();
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:10:35
|
10 | pub static mut MAPTILES_EXTENDED: Vec = Vec::new();
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:11:26
|
11 | pub static mut MAPZONES: Vec = Vec::new();
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:13:11
|
13 | pub name: Vec,
|
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:14:12
14 | pub tiles: Vec,
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:19:30
|
19 | pub fn init_server_map(name: Vec, tiles: Vec, map_id: i32, tile_id: i32) -> Self {
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:19:46
|
19 | pub fn init_server_map(name: Vec, tiles: Vec, map_id: i32, tile_id: i32) -> Self {
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:55:16
|
55 | pub item_type: Vec,
| ^^^ not found in this scope
error[E0412]: cannot find type Vec in this scope
--> src\mods\map_system.rs:68:12
|
68 | item_type: Vec,
| ^^^ not found in this scope
error[E0412]: cannot find type Option in this scope
--> src\mods\map_system.rs:88:68
|
88 | pub unsafe fn get_client_tile_transwall(x: i32, y: i32, z: i32) -> Option<&'static MapItem> {
| ^^^^^^ not found in this scope
error[E0412]: cannot find type Option in this scope
--> src\mods\map_system.rs:100:61
|
100 | pub unsafe fn get_client_tile_at(x: i32, y: i32, z: i32) -> Option<&'static MapItem> {
| ^^^^^^ not found in this scope
error[E0412]: cannot find type Option in this scope
--> src\mods\map_system.rs:107:70
|
107 | pub unsafe fn get_extended_client_tile_at(x: i32, y: i32, z: i32) -> Option<&'static MapItem> {
| ^^^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:108:8
|
108
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:125:8
|
125 | if let Some(map) = get_map_by_ref(map_name) {
| ^^^^ not found in this scope
error[E0425]: cannot find value None in this scope
--> src\mods\map_system.rs:132:1
|
132 | None
| ^^^^ not found in this scope
--> src\mods\map_system.rs:140:6
140 | ) -> Option<&'static MapItem> {
| ^^^^^^ not found in this scope
41
141 | if let Some(map) = get_map_by_ref_from_id(map_id) {
| ^^^^ not found in this scope
error[E0425]: cannot find value None in this scope
--> src\mods\map_system.rs:148:1
|
148 | None
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:161:8
|
161 | if let Some(map) = get_map_by_mut_ref(map_name) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:188:8
|
188 | if let Some(map) = get_map_by_mut_ref(map_name) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
-->
--> src\mods\map_system.rs:224:8
|
224 | if let Some(map) = get_map_by_mut_ref(map_name) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:233:8
|
233 | if let Some(index) = MAPS.iter().position(|x| x.name == map_name) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:254:8
|
254 | if let Some(map) = get_map_by_ref(map_name) {
| ^^^^ not found in this scope
error[E0412]: cannot find type Option in this scope
--> src\mods\map_system.rs:270:49
|
270 | pub unsafe fn get_map_index(map_name: &[u8]) -> Option {
| ^^^^^^ not found in this scope
error[E0412]: cannot find type Option in this scope
--> src\mods\map_system.rs:274:50
|
274 | pub unsafe fn get_map_by_ref(map_name: &[u8]) -> Option<&'static Map> {
| ^^^^^^ not found in this scope
error[E0412]: cannot find type Option in this scope
--> src\mods\map_system.rs:278:54
|
278 | pub unsafe fn get_map_by_mut_ref(map_name: &[u8]) -> Option<&'static mut Map> {
| ^^^^^^ not found in this scope
error[E0412]: cannot find type Option in this scope
--> src\mods\map_system.rs:282:54
|

282 | pub unsafe fn get_map_by_ref_from_id(map_id: i32) -> Option<&'static Map> {
| ^^^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:309:8
|
309 | if let Some(tile) = MAPTILES.iter_mut().find(|a| a.id == tile_id) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:328:8
|
328 | if let Some(tile) = MAPTILES_EXTENDED.iter_mut().find(|a| a.id == tile_id) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:339:8
|
339 | if let Some(tile) = MAPTILES.iter_mut().find(|a| a.id == tile_id) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:345:8
|
345 | if let Some(tile) = MAPTILES_EXTENDED.iter_mut().find(|a| a.id == tile_id) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:351:8
|
351 | if let Some(index) = MAPTILES.iter().position(|x| x.id == id) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:357:8
|
357 | if let Some(index) = MAPTILES_EXTENDED.iter().position(|x| x.id == id) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:363:8
|
381 | if let Some(index) = MAPZONES.iter().position(|x| x.id == id) {
95
395 | if let Some(checkpoint) = CHECKPOINTS
408
408 | if let Some(index) = CHECKPOINTS
420
420 | if let Some(index) = CHECKPOINTS.iter_mut().position(|entry| entry.id == id) {
--> src\lib.rs:9:8
|
9 | if let Some(index) = map_system::get_map_index(CStr::from_ptr(map_name).to_bytes()) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\lib.rs:157:8
157 | if let Some(tile) = map_system::get_client_tile_at(x, y, z) {
--> src\lib.rs:172:8
172 | if let Some(tile) = map_system::get_extended_client_tile_at(x, y, z) {
--> src\lib.rs:188:8
188 | if let Some(tile) = map_system::get_server_tile_at(x, y, z, CStr::from_ptr(map).to_bytes()) {
|
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\lib.rs:204:8
204 | if let Some(tile) = map_system::get_server_tile_by_map_id_at(x, y, z, map_id) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\lib.rs:389:8
|
389 | if let Some(index) = map_system::MAPTILES.iter().position(|tile| {
| ^^^^
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\lib.rs:468:8
|
468 | if let Some(zone) = map_system::get_zone_at(x, y, z) {
| ^^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant Some in this scope
--> src\lib.rs:495:8
|
495 | if let Some(map) = map_system::MAPS.iter_mut().find(|x| x.name == temp) {
|
|
270 | pub unsafe fn get_map_index(map_name: &[u8]) -> Option {
| ^^^^^
error: requires sized lang_item
--> src\mods\map_system.rs:274:40
274 | pub unsafe fn get_map_by_ref(map_name: &[u8]) -> Option<&'static Map> {
| ^^^^^
error: requires sized lang_item
--> src\mods\map_system.rs:278:44
278 | pub unsafe fn get_map_by_mut_ref(map_name: &[u8]) -> Option<&'static mut Map> {
| ^^^^^
error: requires sized lang_item
--> src\mods\map_system.rs:286:36
286 | pub unsafe fn map_exists(map_name: &[u8]) -> bool {
| ^^^^^
error: requires sized lang_item
--> src\mods\map_system.rs:338:69
338 | pub unsafe fn update_client_tile_name_by_id(tile_id: i32, new_name: &[u8]) {
| ^^^^^
error: requires sized lang_item
--> src\mods\map_system.rs:344:78
344 | pub unsafe fn update_client_tile_extended_name_by_id(tile_id: i32, new_name: &[u8]) {
| ^^^^^
error[E0433]: failed to resolve: use of undeclared type Vec
--> src\mods\map_system.rs:7:47
|
7 | pub static mut CHECKPOINTS: Vec = Vec::new();
| ^^^ use of undeclared type Vec
error[E0433]: failed to resolve: use of undeclared type Vec
--> src\mods\map_system.rs:8:33
|
8 |
8 | pub static mut MAPS: Vec = Vec::new();
| ^^^ use of undeclared type Vec
error[E0433]: failed to resolve: use of undeclared type Vec
--> src\mods\map_system.rs:9:41
9 | pub static mut MAPTILES: Vec = Vec::new();
| ^^^ use of undeclared type Vec
error[E0433]: failed to resolve: use of undeclared type Vec
--> src\mods\map_system.rs:10:50
|
10 | pub static mut MAPTILES_EXTENDED: Vec = Vec::new();
| ^^^ use of undeclared type Vec
error[E0433]: failed to resolve: use of undeclared type Vec
--> src\mods\map_system.rs:11:41
|
11 | pub static mut MAPZONES: Vec = Vec::new();
| ^^^ use of undeclared type Vec
error[E0433]: failed to resolve: use of undeclared type Vec
--> src\lib.rs:22:1
|
22 | Vec::<map_system::MapItem>::new(),
| ^^^ use of undeclared type Vec
error[E0433]: failed to resolve: use of undeclared type Vec
--> src\lib.rs:37:1
|
37 | Vec::<map_system::MapItem>::new(),
| ^^^ use of undeclared type Vec
error[E0425]: cannot find function, tuple struct or tuple variant Some in this scope
--> src\mods\map_system.rs:111:8
|
111 | return Some(tile);
| ^^^^ not found in this scope
Some errors have detailed explanations: E0412, E0425, E0433, E0463, E0531.
For more information about an error, try rustc --explain E0412.

Still no formatting, but one relevant bit of information:

Have you installed the target which is used in your build.bat, as compiler asks you to?

1 Like

Lol, the error was the thing that I forgot to install, thanks for mentioning that. Good bye for now, have a nice day. I am closing this topic.

I can't seem to close the topic, so it will stay until an admin closes it.