Use C types to make sure everything has the same type

master
eater 5 years ago
parent ee0ee84936
commit a57471935f
Signed by: eater
GPG Key ID: AD2560A0F84F0759

@ -142,17 +142,17 @@ class PrimitiveHeaderParser:
TYPE_TRANSLATION = { TYPE_TRANSLATION = {
'const char*': '*const i8', 'const char*': '*const c_char',
'const char *': '*const i8', 'const char *': '*const c_char',
'bool': 'bool', 'bool': 'bool',
'unsigned short': 'u16', 'unsigned short': 'c_ushort',
'ScriptFunc': 'fn()', 'ScriptFunc': 'fn()',
'int': 'i16', 'int': 'c_int',
'unsigned int': 'u16', 'unsigned int': 'c_uint',
'unsigned char': 'u8', 'unsigned char': 'c_uchar',
'char': 'i8', 'char': 'c_char',
'float': 'f32', 'float': 'c_float',
'double': 'f64', 'double': 'c_double',
# No good way with these 2 types yet # No good way with these 2 types yet
'va_list': '<REMOVE>', 'va_list': '<REMOVE>',
'boost::any': '<REMOVE>' 'boost::any': '<REMOVE>'
@ -195,7 +195,7 @@ def main():
ret = "" ret = ""
if func.return_type in ['const char*', 'const char *']: if func.return_type in ['const char*', 'const char *']:
ret = " -> *const i8" ret = " -> *const c_char"
elif func.return_type != "void": elif func.return_type != "void":
ret = f" -> {TYPE_TRANSLATION[func.return_type]}" ret = f" -> {TYPE_TRANSLATION[func.return_type]}"
@ -267,8 +267,8 @@ def main():
fancy += " }\n" fancy += " }\n"
fancy += "}\n\n" fancy += "}\n\n"
whole = "use std::ffi::{CStr, CString};\n\n" whole = "use std::ffi::{CStr, CString};\nuse std::os::raw::*;\n\n"
whole += "#[allow(non_upper_case_globals)]\npub mod raw {\n" whole += "#[allow(non_upper_case_globals)]\npub mod raw {\n use std::os::raw::*;\n"
for line in raw.splitlines(): for line in raw.splitlines():
whole += " " + line + "\n" whole += " " + line + "\n"
whole += "}\n\n" whole += "}\n\n"

File diff suppressed because it is too large Load Diff

@ -3,53 +3,54 @@
pub mod generated; pub mod generated;
pub use generated::*; pub use generated::*;
use std::os::raw::*;
pub const LOG_VERBOSE: u16 = 0;
pub const LOG_INFO: u16 = 1; pub const LOG_VERBOSE: c_ushort = 0;
pub const LOG_WARN: u16 = 2; pub const LOG_INFO: c_ushort = 1;
pub const LOG_ERROR: u16 = 3; pub const LOG_WARN: c_ushort = 2;
pub const LOG_FATAL: u16 = 4; pub const LOG_ERROR: c_ushort = 3;
pub const LOG_FATAL: c_ushort = 4;
pub const REGULAR: u16 = 0;
pub const IMPERIAL_SHRINE: u16 = 1; pub const REGULAR: c_uint = 0;
pub const TRIBUNAL_TEMPLE: u16 = 2; pub const IMPERIAL_SHRINE: c_uint = 1;
pub const TRIBUNAL_TEMPLE: c_uint = 2;
pub const CLIENT_GAMEPLAY: u8 = 0;
pub const CLIENT_CONSOLE: u8 = 1; pub const CLIENT_GAMEPLAY: c_uchar = 0;
pub const CLIENT_DIALOGUE: u8 = 2; pub const CLIENT_CONSOLE: c_uchar = 1;
pub const CLIENT_SCRIPT_LOCAL: u8 = 3; pub const CLIENT_DIALOGUE: c_uchar = 2;
pub const CLIENT_SCRIPT_GLOBAL: u8 = 4; pub const CLIENT_SCRIPT_LOCAL: c_uchar = 3;
pub const SERVER_SCRIPT: u8 = 5; pub const CLIENT_SCRIPT_GLOBAL: c_uchar = 4;
pub const SERVER_SCRIPT: c_uchar = 5;
pub const NONE: u8 = 0;
pub const DRAG: u8 = 1; pub const NONE: c_uchar = 0;
pub const DROP: u8 = 2; pub const DRAG: c_uchar = 1;
pub const TAKE_ALL: u8 = 3; pub const DROP: c_uchar = 2;
pub const TAKE_ALL: c_uchar = 3;
pub const ITEM: u16 = 0;
pub const ITEM_MAGIC: u16 = 1; pub const ITEM: c_int = 0;
pub const MAGIC: u16 = 2; pub const ITEM_MAGIC: c_int = 1;
pub const UNASSIGNED: u16 = 3; pub const MAGIC: c_int = 2;
pub const UNASSIGNED: c_int = 3;
pub const SET: u8 = 0;
pub const ADD: u8 = 1; pub const SET: c_uchar = 0;
pub const REMOVE: u8 = 2; pub const ADD: c_uchar = 1;
pub const REQUEST: u8 = 3; pub const REMOVE: c_uchar = 2;
pub const REQUEST: c_uchar = 3;
pub const LOAD: u16 = 0;
pub const UNLOAD: u16 = 1; pub const LOAD: c_uint = 0;
pub const UNLOAD: c_uint = 1;
pub const RANK: u8 = 0;
pub const EXPULSION: u8 = 1; pub const RANK: c_uchar = 0;
pub const REPUTATION: u8 = 3; pub const EXPULSION: c_uchar = 1;
pub const REPUTATION: c_uchar = 3;
pub const ENTRY: i16 = 0;
pub const INDEX: i16 = 1; pub const ENTRY: c_int = 0;
pub const INDEX: c_int = 1;
pub const SPELL: u16 = 0;
pub const POTION: u16 = 1; pub const SPELL: c_ushort = 0;
pub const ENCHANTMENT: u16 = 2; pub const POTION: c_ushort = 1;
pub const NPC: u16 = 3; pub const ENCHANTMENT: c_ushort = 2;
pub const NPC: c_ushort = 3;
/// Calls a function on `EVENTS_INSTANCE` with given parameters /// Calls a function on `EVENTS_INSTANCE` with given parameters
#[macro_export] #[macro_export]
@ -82,6 +83,7 @@ macro_rules! call_instance {
macro_rules! use_events { macro_rules! use_events {
($events:ident) => { ($events:ident) => {
use std::ffi::CStr; use std::ffi::CStr;
use std::os::raw::*;
static mut EVENTS_INSTANCE: Option<$events> = None; static mut EVENTS_INSTANCE: Option<$events> = None;
@ -111,7 +113,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnActorAI(player_id: u16, description: *const i8) { pub fn OnActorAI(player_id: c_ushort, description: *const i8) {
call_instance!(on_actor_ai, player_id, unsafe { call_instance!(on_actor_ai, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -119,7 +121,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnActorCellChange(player_id: u16, description: *const i8) { pub fn OnActorCellChange(player_id: c_ushort, description: *const i8) {
call_instance!(on_actor_cell_change, player_id, unsafe { call_instance!(on_actor_cell_change, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -127,7 +129,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnActorDeath(player_id: u16, description: *const i8) { pub fn OnActorDeath(player_id: c_ushort, description: *const i8) {
call_instance!(on_actor_death, player_id, unsafe { call_instance!(on_actor_death, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -135,7 +137,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnActorEquipment(player_id: u16, description: *const i8) { pub fn OnActorEquipment(player_id: c_ushort, description: *const i8) {
call_instance!(on_actor_equipment, player_id, unsafe { call_instance!(on_actor_equipment, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -143,7 +145,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnActorList(player_id: u16, description: *const i8) { pub fn OnActorList(player_id: c_ushort, description: *const i8) {
call_instance!(on_actor_list, player_id, unsafe { call_instance!(on_actor_list, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -151,7 +153,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnActorTest(player_id: u16, description: *const i8) { pub fn OnActorTest(player_id: c_ushort, description: *const i8) {
call_instance!(on_actor_test, player_id, unsafe { call_instance!(on_actor_test, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -183,7 +185,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnContainer(player_id: u16, description: *const i8) { pub fn OnContainer(player_id: c_ushort, description: *const i8) {
call_instance!(on_container, player_id, unsafe { call_instance!(on_container, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -191,7 +193,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnDoorState(player_id: u16, description: *const i8) { pub fn OnDoorState(player_id: c_ushort, description: *const i8) {
call_instance!(on_door_state, player_id, unsafe { call_instance!(on_door_state, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -199,7 +201,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnGUIAction(player_id: u16, message_box_id: i16, data: *const i8) { pub fn OnGUIAction(player_id: c_ushort, message_box_id: c_int, data: *const i8) {
call_instance!(on_gui_action, player_id, message_box_id, unsafe { call_instance!(on_gui_action, player_id, message_box_id, unsafe {
CStr::from_ptr(data).to_str().unwrap_or_default() CStr::from_ptr(data).to_str().unwrap_or_default()
}); });
@ -207,13 +209,13 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnMpNumIncrement(current_mp_num: i16) { pub fn OnMpNumIncrement(current_mp_num: c_int) {
call_instance!(on_mp_num_increment, current_mp_num); call_instance!(on_mp_num_increment, current_mp_num);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnObjectActivate(player_id: u16, description: *const i8) { pub fn OnObjectActivate(player_id: c_ushort, description: *const i8) {
call_instance!(on_object_activate, player_id, unsafe { call_instance!(on_object_activate, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -221,7 +223,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnObjectDelete(player_id: u16, description: *const i8) { pub fn OnObjectDelete(player_id: c_ushort, description: *const i8) {
call_instance!(on_object_delete, player_id, unsafe { call_instance!(on_object_delete, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -229,7 +231,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnObjectLock(player_id: u16, description: *const i8) { pub fn OnObjectLock(player_id: c_ushort, description: *const i8) {
call_instance!(on_object_lock, player_id, unsafe { call_instance!(on_object_lock, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -237,7 +239,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnObjectPlace(player_id: u16, description: *const i8) { pub fn OnObjectPlace(player_id: c_ushort, description: *const i8) {
call_instance!(on_object_place, player_id, unsafe { call_instance!(on_object_place, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -245,7 +247,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnObjectScale(player_id: u16, description: *const i8) { pub fn OnObjectScale(player_id: c_ushort, description: *const i8) {
call_instance!(on_object_scale, player_id, unsafe { call_instance!(on_object_scale, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -253,7 +255,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnObjectSpawn(player_id: u16, description: *const i8) { pub fn OnObjectSpawn(player_id: c_ushort, description: *const i8) {
call_instance!(on_object_spawn, player_id, unsafe { call_instance!(on_object_spawn, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -261,7 +263,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnObjectState(player_id: u16, description: *const i8) { pub fn OnObjectState(player_id: c_ushort, description: *const i8) {
call_instance!(on_object_state, player_id, unsafe { call_instance!(on_object_state, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -269,7 +271,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnObjectTrap(player_id: u16, description: *const i8) { pub fn OnObjectTrap(player_id: c_ushort, description: *const i8) {
call_instance!(on_object_trap, player_id, unsafe { call_instance!(on_object_trap, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -277,133 +279,133 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerAttribute(player_id: u16) { pub fn OnPlayerAttribute(player_id: c_ushort) {
call_instance!(on_player_attribute, player_id); call_instance!(on_player_attribute, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerBook(player_id: u16) { pub fn OnPlayerBook(player_id: c_ushort) {
call_instance!(on_player_book, player_id); call_instance!(on_player_book, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerBounty(player_id: u16) { pub fn OnPlayerBounty(player_id: c_ushort) {
call_instance!(on_player_bounty, player_id); call_instance!(on_player_bounty, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerCellChange(player_id: u16) { pub fn OnPlayerCellChange(player_id: c_ushort) {
call_instance!(on_player_cell_change, player_id); call_instance!(on_player_cell_change, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerConnect(player_id: u16) { pub fn OnPlayerConnect(player_id: c_ushort) {
call_instance!(on_player_connect, player_id); call_instance!(on_player_connect, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerDeath(player_id: u16) { pub fn OnPlayerDeath(player_id: c_ushort) {
call_instance!(on_player_death, player_id); call_instance!(on_player_death, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerDisconnect(player_id: u16) { pub fn OnPlayerDisconnect(player_id: c_ushort) {
call_instance!(on_player_disconnect, player_id); call_instance!(on_player_disconnect, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerDisposition(player_id: u16) { pub fn OnPlayerDisposition(player_id: c_ushort) {
call_instance!(on_player_disposition, player_id); call_instance!(on_player_disposition, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerEndCharGen(player_id: u16) { pub fn OnPlayerEndCharGen(player_id: c_ushort) {
call_instance!(on_player_end_char_gen, player_id); call_instance!(on_player_end_char_gen, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerEquipment(player_id: u16) { pub fn OnPlayerEquipment(player_id: c_ushort) {
call_instance!(on_player_equipment, player_id); call_instance!(on_player_equipment, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerFaction(player_id: u16) { pub fn OnPlayerFaction(player_id: c_ushort) {
call_instance!(on_player_faction, player_id); call_instance!(on_player_faction, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerInput(player_id: u16) { pub fn OnPlayerInput(player_id: c_ushort) {
call_instance!(on_player_input, player_id); call_instance!(on_player_input, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerInventory(player_id: u16) { pub fn OnPlayerInventory(player_id: c_ushort) {
call_instance!(on_player_inventory, player_id); call_instance!(on_player_inventory, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerItemUse(player_id: u16) { pub fn OnPlayerItemUse(player_id: c_ushort) {
call_instance!(on_player_item_use, player_id); call_instance!(on_player_item_use, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerJournal(player_id: u16) { pub fn OnPlayerJournal(player_id: c_ushort) {
call_instance!(on_player_journal, player_id); call_instance!(on_player_journal, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerLevel(player_id: u16) { pub fn OnPlayerLevel(player_id: c_ushort) {
call_instance!(on_player_level, player_id); call_instance!(on_player_level, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerMiscellaneous(player_id: u16) { pub fn OnPlayerMiscellaneous(player_id: c_ushort) {
call_instance!(on_player_miscellaneous, player_id); call_instance!(on_player_miscellaneous, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerQuickKeys(player_id: u16) { pub fn OnPlayerQuickKeys(player_id: c_ushort) {
call_instance!(on_player_quick_keys, player_id); call_instance!(on_player_quick_keys, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerReputation(player_id: u16) { pub fn OnPlayerReputation(player_id: c_ushort) {
call_instance!(on_player_reputation, player_id); call_instance!(on_player_reputation, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerRest(player_id: u16) { pub fn OnPlayerRest(player_id: c_ushort) {
call_instance!(on_player_rest, player_id); call_instance!(on_player_rest, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerResurrect(player_id: u16) { pub fn OnPlayerResurrect(player_id: c_ushort) {
call_instance!(on_player_resurrect, player_id); call_instance!(on_player_resurrect, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerSendMessage(player_id: u16, message: *const i8) { pub fn OnPlayerSendMessage(player_id: c_ushort, message: *const i8) {
call_instance!(on_player_send_message, player_id, unsafe { call_instance!(on_player_send_message, player_id, unsafe {
CStr::from_ptr(message).to_str().unwrap_or_default() CStr::from_ptr(message).to_str().unwrap_or_default()
}); });
@ -411,31 +413,31 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerShapeshift(player_id: u16) { pub fn OnPlayerShapeshift(player_id: c_ushort) {
call_instance!(on_player_shapeshift, player_id); call_instance!(on_player_shapeshift, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerSkill(player_id: u16) { pub fn OnPlayerSkill(player_id: c_ushort) {
call_instance!(on_player_skill, player_id); call_instance!(on_player_skill, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerSpellbook(player_id: u16) { pub fn OnPlayerSpellbook(player_id: c_ushort) {
call_instance!(on_player_spellbook, player_id); call_instance!(on_player_spellbook, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnPlayerTopic(player_id: u16) { pub fn OnPlayerTopic(player_id: c_ushort) {
call_instance!(on_player_topic, player_id); call_instance!(on_player_topic, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnRecordDynamic(player_id: u16) { pub fn OnRecordDynamic(player_id: c_ushort) {
call_instance!(on_record_dynamic, player_id); call_instance!(on_record_dynamic, player_id);
} }
@ -447,7 +449,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnScriptGlobalShort(player_id: u16) { pub fn OnScriptGlobalShort(player_id: c_ushort) {
call_instance!(on_script_global_short, player_id); call_instance!(on_script_global_short, player_id);
} }
@ -461,7 +463,7 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnVideoPlay(player_id: u16, description: *const i8) { pub fn OnVideoPlay(player_id: c_ushort, description: *const i8) {
call_instance!(on_video_play, player_id, unsafe { call_instance!(on_video_play, player_id, unsafe {
CStr::from_ptr(description).to_str().unwrap_or_default() CStr::from_ptr(description).to_str().unwrap_or_default()
}); });
@ -469,19 +471,19 @@ macro_rules! use_events {
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnWorldKillCount(player_id: u16) { pub fn OnWorldKillCount(player_id: c_ushort) {
call_instance!(on_world_kill_count, player_id); call_instance!(on_world_kill_count, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnWorldMap(player_id: u16) { pub fn OnWorldMap(player_id: c_ushort) {
call_instance!(on_world_map, player_id); call_instance!(on_world_map, player_id);
} }
#[no_mangle] #[no_mangle]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn OnWorldWeather(player_id: u16) { pub fn OnWorldWeather(player_id: c_ushort) {
call_instance!(on_world_weather, player_id); call_instance!(on_world_weather, player_id);
} }
}; };
@ -492,74 +494,74 @@ pub trait Events: Sized {
fn new() -> Self; fn new() -> Self;
fn on_any(&self, event_name: &str) {} fn on_any(&self, event_name: &str) {}
fn on_actor_ai(&self, player_id: u16, description: &str) {} fn on_actor_ai(&self, player_id: c_ushort, description: &str) {}
fn on_actor_cell_change(&self, player_id: u16, description: &str) {} fn on_actor_cell_change(&self, player_id: c_ushort, description: &str) {}
fn on_actor_death(&self, player_id: u16, description: &str) {} fn on_actor_death(&self, player_id: c_ushort, description: &str) {}
fn on_actor_equipment(&self, player_id: u16, description: &str) {} fn on_actor_equipment(&self, player_id: c_ushort, description: &str) {}
fn on_actor_list(&self, player_id: u16, description: &str) {} fn on_actor_list(&self, player_id: c_ushort, description: &str) {}
fn on_actor_test(&self, player_id: u16, description: &str) {} fn on_actor_test(&self, player_id: c_ushort, description: &str) {}
fn on_cell_deletion(&self, description: &str) {} fn on_cell_deletion(&self, description: &str) {}
fn on_cell_load(&self, description: &str) {} fn on_cell_load(&self, description: &str) {}
fn on_cell_unload(&self, description: &str) {} fn on_cell_unload(&self, description: &str) {}
fn on_container(&self, player_id: u16, description: &str) {} fn on_container(&self, player_id: c_ushort, description: &str) {}
fn on_door_state(&self, player_id: u16, description: &str) {} fn on_door_state(&self, player_id: c_ushort, description: &str) {}
fn on_gui_action(&self, player_id: u16, message_box_id: i16, data: &str) {} fn on_gui_action(&self, player_id: c_ushort, message_box_id: c_int, data: &str) {}
fn on_mp_num_increment(&self, current_mp_num: i16) {} fn on_mp_num_increment(&self, current_mp_num: c_int) {}
fn on_object_activate(&self, player_id: u16, description: &str) {} fn on_object_activate(&self, player_id: c_ushort, description: &str) {}
fn on_object_delete(&self, player_id: u16, description: &str) {} fn on_object_delete(&self, player_id: c_ushort, description: &str) {}
fn on_object_lock(&self, player_id: u16, description: &str) {} fn on_object_lock(&self, player_id: c_ushort, description: &str) {}
fn on_object_place(&self, player_id: u16, description: &str) {} fn on_object_place(&self, player_id: c_ushort, description: &str) {}
fn on_object_scale(&self, player_id: u16, description: &str) {} fn on_object_scale(&self, player_id: c_ushort, description: &str) {}
fn on_object_spawn(&self, player_id: u16, description: &str) {} fn on_object_spawn(&self, player_id: c_ushort, description: &str) {}
fn on_object_state(&self, player_id: u16, description: &str) {} fn on_object_state(&self, player_id: c_ushort, description: &str) {}
fn on_object_trap(&self, player_id: u16, description: &str) {} fn on_object_trap(&self, player_id: c_ushort, description: &str) {}
fn on_player_attribute(&self, player_id: u16) {} fn on_player_attribute(&self, player_id: c_ushort) {}
fn on_player_book(&self, player_id: u16) {} fn on_player_book(&self, player_id: c_ushort) {}
fn on_player_bounty(&self, player_id: u16) {} fn on_player_bounty(&self, player_id: c_ushort) {}
fn on_player_cell_change(&self, player_id: u16) {} fn on_player_cell_change(&self, player_id: c_ushort) {}
fn on_player_connect(&self, player_id: u16) {} fn on_player_connect(&self, player_id: c_ushort) {}
fn on_player_death(&self, player_id: u16) {} fn on_player_death(&self, player_id: c_ushort) {}
fn on_player_disconnect(&self, player_id: u16) {} fn on_player_disconnect(&self, player_id: c_ushort) {}
fn on_player_disposition(&self, player_id: u16) {} fn on_player_disposition(&self, player_id: c_ushort) {}
fn on_player_end_char_gen(&self, player_id: u16) {} fn on_player_end_char_gen(&self, player_id: c_ushort) {}
fn on_player_equipment(&self, player_id: u16) {} fn on_player_equipment(&self, player_id: c_ushort) {}
fn on_player_faction(&self, player_id: u16) {} fn on_player_faction(&self, player_id: c_ushort) {}
fn on_player_input(&self, player_id: u16) {} fn on_player_input(&self, player_id: c_ushort) {}
fn on_player_inventory(&self, player_id: u16) {} fn on_player_inventory(&self, player_id: c_ushort) {}
fn on_player_item_use(&self, player_id: u16) {} fn on_player_item_use(&self, player_id: c_ushort) {}
fn on_player_journal(&self, player_id: u16) {} fn on_player_journal(&self, player_id: c_ushort) {}
fn on_player_level(&self, player_id: u16) {} fn on_player_level(&self, player_id: c_ushort) {}
fn on_player_miscellaneous(&self, player_id: u16) {} fn on_player_miscellaneous(&self, player_id: c_ushort) {}
fn on_player_quick_keys(&self, player_id: u16) {} fn on_player_quick_keys(&self, player_id: c_ushort) {}
fn on_player_reputation(&self, player_id: u16) {} fn on_player_reputation(&self, player_id: c_ushort) {}
fn on_player_rest(&self, player_id: u16) {} fn on_player_rest(&self, player_id: c_ushort) {}
fn on_player_resurrect(&self, player_id: u16) {} fn on_player_resurrect(&self, player_id: c_ushort) {}
fn on_player_send_message(&self, player_id: u16, message: &str) {} fn on_player_send_message(&self, player_id: c_ushort, message: &str) {}
fn on_player_shapeshift(&self, player_id: u16) {} fn on_player_shapeshift(&self, player_id: c_ushort) {}
fn on_player_skill(&self, player_id: u16) {} fn on_player_skill(&self, player_id: c_ushort) {}
fn on_player_spellbook(&self, player_id: u16) {} fn on_player_spellbook(&self, player_id: c_ushort) {}
fn on_player_topic(&self, player_id: u16) {} fn on_player_topic(&self, player_id: c_ushort) {}
fn on_record_dynamic(&self, player_id: u16) {} fn on_record_dynamic(&self, player_id: c_ushort) {}
fn on_request_data_file_list(&self) {} fn on_request_data_file_list(&self) {}
fn on_script_global_short(&self, player_id: u16) {} fn on_script_global_short(&self, player_id: c_ushort) {}
fn on_server_exit(&self, is_error: bool) {} fn on_server_exit(&self, is_error: bool) {}
fn on_server_init(&self) {} fn on_server_init(&self) {}
fn on_server_post_init(&self) {} fn on_server_post_init(&self) {}
fn on_server_script_crash(&self, error: &str) {} fn on_server_script_crash(&self, error: &str) {}
fn on_video_play(&self, player_id: u16, description: &str) {} fn on_video_play(&self, player_id: c_ushort, description: &str) {}
fn on_world_kill_count(&self, player_id: u16) {} fn on_world_kill_count(&self, player_id: c_ushort) {}
fn on_world_map(&self, player_id: u16) {} fn on_world_map(&self, player_id: c_ushort) {}
fn on_world_weather(&self, player_id: u16) {} fn on_world_weather(&self, player_id: c_ushort) {}
} }

Loading…
Cancel
Save