spring_ai_sys

Struct SSkirmishAILibrary

Source
#[repr(C)]
pub struct SSkirmishAILibrary { pub getLevelOfSupportFor: Option<unsafe extern "C" fn(aiShortName: *const c_char, aiVersion: *const c_char, engineVersionString: *const c_char, engineVersionNumber: c_int, aiInterfaceShortName: *const c_char, aiInterfaceVersion: *const c_char) -> LevelOfSupport>, pub init: Option<unsafe extern "C" fn(skirmishAIId: c_int, callback: *const SSkirmishAICallback) -> c_int>, pub release: Option<unsafe extern "C" fn(skirmishAIId: c_int) -> c_int>, pub handleEvent: Option<unsafe extern "C" fn(skirmishAIId: c_int, topicId: c_int, data: *const c_void) -> c_int>, }
Expand description

@brief Skirmish Artificial Intelligence library interface

This is the interface between the engine and an implementation of a Skirmish AI. The engine will address AIs through this interface, but AIs will not actually implement it. It is the job of the AI Interface library, to make sure the engine can address AI implementations through instances of this struct.

An example of loading a C AI through the C AI Interface: The C AI exports functions fitting the function pointers in this struct. When the engine requests C-AI-X on the C AI Interface, the interface loads the shared library, eg C-AI-X.dll, creates a new instance of this struct, and sets the member function pointers to the addresses of the fitting functions exported by the shared AI library. This struct then goes to the engine which calls the functions appropriately.

Fields§

§getLevelOfSupportFor: Option<unsafe extern "C" fn(aiShortName: *const c_char, aiVersion: *const c_char, engineVersionString: *const c_char, engineVersionNumber: c_int, aiInterfaceShortName: *const c_char, aiInterfaceVersion: *const c_char) -> LevelOfSupport>

Level of Support for a specific engine version and AI interface version.

[optional] An AI not exporting this function is still valid.

@param aiShortName this is indisposable for non-native interfaces, as they need a means of redirecting from one wrapper function to the respective non-native libraries @param aiVersion see aiShortName @return the level of support for the supplied engine and AI interface versions

§init: Option<unsafe extern "C" fn(skirmishAIId: c_int, callback: *const SSkirmishAICallback) -> c_int>

This function is called, when an AI instance shall be created for skirmishAIId. It is called before the first call to handleEvent() for that AI instance.

A typical series of events (engine point of view, conceptual): [code] KAIK.init(1) KAIK.handleEvent(EVENT_INIT, InitEvent(1)) RAI.init(2) RAI.handleEvent(EVENT_INIT, InitEvent(2)) KAIK.handleEvent(EVENT_UPDATE, UpdateEvent(0)) RAI.handleEvent(EVENT_UPDATE, UpdateEvent(0)) KAIK.handleEvent(EVENT_UPDATE, UpdateEvent(1)) RAI.handleEvent(EVENT_UPDATE, UpdateEvent(1)) … [/code]

This method exists only for performance reasons, which come into play on OO languages. For non-OO language AIs, this method can be ignored, because using only EVENT_INIT will cause no performance decrease.

[optional] An AI not exporting this function is still valid.

@param skirmishAIId the ID this library shall create an instance for @param callback the callback for this Skirmish AI @return 0: ok != 0: error

§release: Option<unsafe extern "C" fn(skirmishAIId: c_int) -> c_int>

This function is called, when an AI instance shall be deleted. It is called after the last call to handleEvent() for that AI instance.

A typical series of events (engine point of view, conceptual): [code] … KAIK.handleEvent(EVENT_UPDATE, UpdateEvent(654321)) RAI.handleEvent(EVENT_UPDATE, UpdateEvent(654321)) KAIK.handleEvent(EVENT_UPDATE, UpdateEvent(654322)) RAI.handleEvent(EVENT_UPDATE, UpdateEvent(654322)) KAIK.handleEvent(EVENT_RELEASE, ReleaseEvent(1)) KAIK.release(1) RAI.handleEvent(EVENT_RELEASE, ReleaseEvent(2)) RAI.release(2) [/code]

This method exists only for performance reasons, which come into play on OO languages. For non-OO language AIs, this method can be ignored, because using only EVENT_RELEASE will cause no performance decrease.

[optional] An AI not exporting this function is still valid.

@param skirmishAIId the ID the library shall release the instance of @return 0: ok != 0: error

§handleEvent: Option<unsafe extern "C" fn(skirmishAIId: c_int, topicId: c_int, data: *const c_void) -> c_int>

Through this function, the AI receives events from the engine. For details about events that may arrive here, see file AISEvents.h.

@param skirmishAIId the AI instance the event is addressed to // * @param fromId the id of the AI the event comes from, // * or FROM_ENGINE_ID if it comes from the engine // * @param eventId used on asynchronous events. this allows the AI to // * identify a possible result message, which was sent // * with the same eventId @param topicId unique identifier of a message (see EVENT_* defines in AISEvents.h) @param data an topic specific struct, which contains the data associatedwith the event (see S*Event structs in AISEvents.h) @return 0: ok != 0: error

Trait Implementations§

Source§

impl Clone for SSkirmishAILibrary

Source§

fn clone(&self) -> SSkirmishAILibrary

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SSkirmishAILibrary

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for SSkirmishAILibrary

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.