Complete refactor of the FFI to use handles instead of pointers.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-06-24 14:44:23 +02:00
parent 4c222cb753
commit 78bb91093b
76 changed files with 1510 additions and 1952 deletions

View File

@@ -8,13 +8,10 @@ use crate::dynamic_data::Pokemon;
use crate::dynamic_data::ScriptContainer;
use crate::dynamic_data::{LearnedMove, ScriptWrapper};
use crate::dynamic_data::{ScriptSource, ScriptSourceData};
use crate::{ValueIdentifiable, ValueIdentifier};
/// The data on a turn choice that should be contained in every turn choice, regardless of type.
#[derive(Debug)]
struct CommonChoiceData {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,
/// The user of the turn choice
user: Pokemon,
/// The speed of the user at the beginning of the turn.
@@ -180,7 +177,6 @@ impl MoveChoice {
script: Default::default(),
priority: AtomicI8::new(0),
choice_data: Box::new(CommonChoiceData {
identifier: Default::default(),
user,
speed: AtomicU32::new(speed),
random_value: AtomicU32::new(0),
@@ -253,7 +249,6 @@ impl ItemChoice {
let speed = user.boosted_stats().speed();
Self {
choice_data: Box::new(CommonChoiceData {
identifier: Default::default(),
user,
speed: AtomicU32::new(speed),
random_value: AtomicU32::new(0),
@@ -293,7 +288,6 @@ impl SwitchChoice {
let speed = user.boosted_stats().speed();
Self {
choice_data: Box::new(CommonChoiceData {
identifier: Default::default(),
user,
speed: AtomicU32::new(speed),
random_value: AtomicU32::new(0),
@@ -332,7 +326,6 @@ impl FleeChoice {
pub fn new(user: Pokemon) -> Self {
Self {
choice_data: Box::new(CommonChoiceData {
identifier: Default::default(),
user,
speed: AtomicU32::new(0),
random_value: AtomicU32::new(0),
@@ -372,7 +365,6 @@ impl PassChoice {
let speed = user.boosted_stats().speed();
Self {
choice_data: Box::new(CommonChoiceData {
identifier: Default::default(),
user,
speed: AtomicU32::new(speed),
random_value: AtomicU32::new(0),
@@ -485,9 +477,3 @@ impl Ord for TurnChoice {
}
}
}
impl ValueIdentifiable for TurnChoice {
fn value_identifier(&self) -> ValueIdentifier {
self.choice_data().identifier
}
}