From 9351c689599927f82bf9e94a82b38c7539d016ba Mon Sep 17 00:00:00 2001 From: SyS Date: Mon, 20 May 2024 11:11:47 +0530 Subject: [PATCH] add helpful traits to the types, structs and enums --- omp-gdk/src/scripting/checkpoints/mod.rs | 3 +- omp-gdk/src/scripting/classes/mod.rs | 2 +- omp-gdk/src/scripting/dialogs/mod.rs | 4 +-- omp-gdk/src/scripting/gangzones/mod.rs | 2 +- omp-gdk/src/scripting/models/mod.rs | 2 +- omp-gdk/src/scripting/objects/mod.rs | 15 ++++----- omp-gdk/src/scripting/players/mod.rs | 40 ++++++++++++++---------- omp-gdk/src/scripting/textdraws/mod.rs | 5 +-- omp-gdk/src/scripting/textlabels/mod.rs | 2 +- omp-gdk/src/scripting/vehicles/mod.rs | 7 +++-- omp-gdk/src/types/colour.rs | 17 ++++++++-- omp-gdk/src/types/network.rs | 2 +- omp-gdk/src/types/vector.rs | 6 ++-- 13 files changed, 65 insertions(+), 42 deletions(-) diff --git a/omp-gdk/src/scripting/checkpoints/mod.rs b/omp-gdk/src/scripting/checkpoints/mod.rs index c69736b..fee2de8 100644 --- a/omp-gdk/src/scripting/checkpoints/mod.rs +++ b/omp-gdk/src/scripting/checkpoints/mod.rs @@ -7,7 +7,7 @@ pub use functions::load_functions; /// Types Of Race Checkpoints #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum RaceCheckpointType { /// Normal, must have nextPosition, else it shows as RACE_FINISH Normal = 0, @@ -52,6 +52,7 @@ impl PlayerRaceCheckPointData { } /// Player checkpoint information +#[derive(PartialEq, Clone, Copy, Debug)] pub struct PlayerCheckPointData { /// position of checkpoint pub center_pos: Vector3, diff --git a/omp-gdk/src/scripting/classes/mod.rs b/omp-gdk/src/scripting/classes/mod.rs index 24fd90a..68c77e2 100644 --- a/omp-gdk/src/scripting/classes/mod.rs +++ b/omp-gdk/src/scripting/classes/mod.rs @@ -8,7 +8,7 @@ pub use functions::{ /// Player Class Information #[repr(C)] -#[derive(Default)] +#[derive(Clone, Copy, Debug, Default)] pub struct PlayerClass { /// The class's team team: u8, diff --git a/omp-gdk/src/scripting/dialogs/mod.rs b/omp-gdk/src/scripting/dialogs/mod.rs index 61a419f..415d01b 100644 --- a/omp-gdk/src/scripting/dialogs/mod.rs +++ b/omp-gdk/src/scripting/dialogs/mod.rs @@ -6,7 +6,7 @@ pub use functions::load_functions; /// Type of Dialog Styles /// #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum DialogStyle { MsgBox = 0, Input, @@ -18,7 +18,7 @@ pub enum DialogStyle { /// Type of Dialog Response #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum DialogResponse { /// right button Right = 0, diff --git a/omp-gdk/src/scripting/gangzones/mod.rs b/omp-gdk/src/scripting/gangzones/mod.rs index c3b1930..59a595b 100644 --- a/omp-gdk/src/scripting/gangzones/mod.rs +++ b/omp-gdk/src/scripting/gangzones/mod.rs @@ -9,7 +9,7 @@ use crate::{players::Player, types::colour::Colour, types::vector::Vector2}; /// GangZone dimensions #[repr(C)] -#[derive(Default)] +#[derive(Default, Clone, Copy, Debug, PartialEq)] pub struct GangZonePos { /// west (x) and south (y) side of a gangzone pub min: Vector2, diff --git a/omp-gdk/src/scripting/models/mod.rs b/omp-gdk/src/scripting/models/mod.rs index 6f2fae1..a0a564b 100644 --- a/omp-gdk/src/scripting/models/mod.rs +++ b/omp-gdk/src/scripting/models/mod.rs @@ -5,7 +5,7 @@ pub use functions::load_functions; /// Model Download Type #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum ModelDownloadType { /// None NONE = 0, diff --git a/omp-gdk/src/scripting/objects/mod.rs b/omp-gdk/src/scripting/objects/mod.rs index 3f51cb8..0e9fe1c 100644 --- a/omp-gdk/src/scripting/objects/mod.rs +++ b/omp-gdk/src/scripting/objects/mod.rs @@ -485,7 +485,7 @@ impl PlayerObject { } #[repr(C)] -#[derive(Default)] +#[derive(Default, Clone, Copy, Debug)] pub struct ObjectMoveData { targetPos: Vector3, targetRot: Vector3, @@ -493,7 +493,7 @@ pub struct ObjectMoveData { } #[repr(C)] -#[derive(Default, PartialEq)] +#[derive(Default, PartialEq, Clone, Copy, Debug)] pub enum ObjectAttachmentType { #[default] None, @@ -503,7 +503,7 @@ pub enum ObjectAttachmentType { } #[repr(C)] -#[derive(Default)] +#[derive(Default, Clone, Copy, Debug)] pub struct ObjectAttachmentData { attachment_type: ObjectAttachmentType, syncRotation: bool, @@ -513,7 +513,7 @@ pub struct ObjectAttachmentData { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum ObjectMaterialTextAlign { Left, Center, @@ -521,7 +521,7 @@ pub enum ObjectMaterialTextAlign { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum ObjectMaterialSize { Size32x32 = 10, Size64x32 = 20, @@ -540,7 +540,7 @@ pub enum ObjectMaterialSize { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum ObjectMaterialType { None, Default, @@ -595,7 +595,7 @@ impl ObjectMaterialData { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum ObjectEditResponse { Cancel, Final, @@ -603,6 +603,7 @@ pub enum ObjectEditResponse { } #[repr(C)] +#[derive(Clone, Copy, Debug)] pub struct ObjectAttachmentSlotData { model: isize, bone: isize, diff --git a/omp-gdk/src/scripting/players/mod.rs b/omp-gdk/src/scripting/players/mod.rs index cc21cad..65af551 100644 --- a/omp-gdk/src/scripting/players/mod.rs +++ b/omp-gdk/src/scripting/players/mod.rs @@ -1212,7 +1212,7 @@ impl Player { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum MapIconStyle { Local, Global, @@ -1221,7 +1221,7 @@ pub enum MapIconStyle { } #[repr(u8)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum ClientVersion { Samp037, Samp03dl, @@ -1229,7 +1229,7 @@ pub enum ClientVersion { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerCameraCutType { Cut, Move, @@ -1237,7 +1237,7 @@ pub enum PlayerCameraCutType { /// The player's name status returned when updating their name #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerNameStatus { /// The name has successfully been updated Updated, @@ -1248,7 +1248,7 @@ pub enum PlayerNameStatus { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerAnimationSyncType { NoSync, Sync, @@ -1256,7 +1256,7 @@ pub enum PlayerAnimationSyncType { } #[repr(C)] -#[derive(Default, Clone, Copy)] +#[derive(Default, Clone, Copy, Debug)] pub struct WeaponSlotData { id: PlayerWeapon, ammo: u32, @@ -1269,12 +1269,13 @@ impl WeaponSlotData { } #[repr(C)] +#[derive(PartialEq, Clone, Copy, Debug)] pub struct PlayerAnimationData { ID: u16, flags: u16, } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerFightingStyle { Normal = 4, Boxing = 5, @@ -1285,7 +1286,7 @@ pub enum PlayerFightingStyle { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerState { None = 0, OnFoot = 1, @@ -1300,7 +1301,7 @@ pub enum PlayerState { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerWeaponSkill { Pistol, SilencedPistol, @@ -1316,7 +1317,7 @@ pub enum PlayerWeaponSkill { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerSpecialAction { None, Duck, @@ -1341,6 +1342,7 @@ pub enum PlayerSpecialAction { } #[repr(C)] +#[derive(PartialEq, Clone, Copy, Debug)] pub struct PlayerSurfingData { surftype: isize, ID: isize, @@ -1348,6 +1350,7 @@ pub struct PlayerSurfingData { } #[repr(C)] +#[derive(PartialEq, Clone, Copy, Debug)] pub struct PlayerKeyData { pub keys: u32, pub upDown: i16, @@ -1355,6 +1358,7 @@ pub struct PlayerKeyData { } #[repr(C)] +#[derive(PartialEq, Clone, Copy, Debug)] pub struct PlayerBulletData { origin: Vector3, hitPos: Vector3, @@ -1364,7 +1368,7 @@ pub struct PlayerBulletData { hitID: u16, } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerBulletHitType { None, Player = 1, @@ -1374,7 +1378,7 @@ pub enum PlayerBulletHitType { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum SpectateType { None, Vehicle, @@ -1382,6 +1386,7 @@ pub enum SpectateType { } #[repr(C)] +#[derive(PartialEq, Clone, Copy, Debug)] pub struct PlayerSpectateData { spectating: bool, spectateID: isize, @@ -1389,7 +1394,7 @@ pub struct PlayerSpectateData { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerSpectateMode { Normal = 1, Fixed, @@ -1397,6 +1402,7 @@ pub enum PlayerSpectateMode { } #[repr(C)] +#[derive(PartialEq, Clone, Copy, Debug)] pub struct PlayerAimData { camFrontVector: Vector3, camPos: Vector3, @@ -1408,7 +1414,7 @@ pub struct PlayerAimData { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerWeaponState { Unknown = -1, NoBullets, @@ -1418,7 +1424,7 @@ pub enum PlayerWeaponState { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum BodyPart { Torso = 3, Groin, @@ -1430,7 +1436,7 @@ pub enum BodyPart { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PlayerClickSource { Scoreboard, } @@ -1438,7 +1444,7 @@ pub enum PlayerClickSource { pub type WeaponSlots = StaticArray; #[repr(u8)] -#[derive(PartialEq, Copy, Clone, Default)] +#[derive(PartialEq, Copy, Clone, Default, Debug)] pub enum PlayerWeapon { #[default] Fist, diff --git a/omp-gdk/src/scripting/textdraws/mod.rs b/omp-gdk/src/scripting/textdraws/mod.rs index ffb5349..bdca93a 100644 --- a/omp-gdk/src/scripting/textdraws/mod.rs +++ b/omp-gdk/src/scripting/textdraws/mod.rs @@ -384,8 +384,9 @@ impl PlayerTextDraw { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug, Default)] pub enum TextDrawAlignmentTypes { + #[default] Default, Left, Center, @@ -393,7 +394,7 @@ pub enum TextDrawAlignmentTypes { } #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum TextDrawStyle { FontBeckettRegular = 0, FontAharoniBold, diff --git a/omp-gdk/src/scripting/textlabels/mod.rs b/omp-gdk/src/scripting/textlabels/mod.rs index d6c828f..3a56929 100644 --- a/omp-gdk/src/scripting/textlabels/mod.rs +++ b/omp-gdk/src/scripting/textlabels/mod.rs @@ -167,7 +167,7 @@ impl PlayerTextLabel { } #[repr(C)] -#[derive(Default)] +#[derive(Default, PartialEq, Clone, Copy, Debug)] pub struct TextLabelAttachmentData { playerID: isize, vehicleID: isize, diff --git a/omp-gdk/src/scripting/vehicles/mod.rs b/omp-gdk/src/scripting/vehicles/mod.rs index 9e42b7f..eb579fd 100644 --- a/omp-gdk/src/scripting/vehicles/mod.rs +++ b/omp-gdk/src/scripting/vehicles/mod.rs @@ -461,13 +461,14 @@ impl Default for VehicleParams { } #[repr(C)] +#[derive(Default, PartialEq, Clone, Copy, Debug)] pub struct UnoccupiedVehicleUpdate { seat: u8, position: Vector3, velocity: Vector3, } -#[derive(Default)] +#[derive(Default, PartialEq, Clone, Copy, Debug)] pub struct VehicleDamageStatusData { pub panels: isize, pub doors: isize, @@ -475,7 +476,7 @@ pub struct VehicleDamageStatusData { pub tires: isize, } -#[derive(Default)] +#[derive(Default, PartialEq, Clone, Copy, Debug)] pub struct VehicleSpawnData { pub respawnDelay: isize, pub modelID: isize, @@ -487,7 +488,7 @@ pub struct VehicleSpawnData { pub interior: isize, } -#[derive(Default)] +#[derive(Default, PartialEq, Clone, Copy, Debug)] pub struct VehicleMatrix { pub right: Vector3, pub up: Vector3, diff --git a/omp-gdk/src/types/colour.rs b/omp-gdk/src/types/colour.rs index de12c41..b62b7b5 100644 --- a/omp-gdk/src/types/colour.rs +++ b/omp-gdk/src/types/colour.rs @@ -1,5 +1,7 @@ +use std::fmt::Debug; + #[repr(C)] -#[derive(Default, Copy, Clone)] +#[derive(Default, Copy, Clone, Debug)] struct Rgba { r: u8, g: u8, @@ -20,8 +22,19 @@ impl Default for ColourData { } } +impl Debug for ColourData { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Rgba") + .field("red", unsafe { &self.rgba.r }) + .field("blue", unsafe { &self.rgba.g }) + .field("green", unsafe { &self.rgba.b }) + .field("alpha", unsafe { &self.rgba.a }) + .finish() + } +} + #[repr(C)] -#[derive(Default, Clone, Copy)] +#[derive(Default, Clone, Copy, Debug)] pub struct Colour { data: ColourData, } diff --git a/omp-gdk/src/types/network.rs b/omp-gdk/src/types/network.rs index cb5e161..d4155e2 100644 --- a/omp-gdk/src/types/network.rs +++ b/omp-gdk/src/types/network.rs @@ -1,5 +1,5 @@ #[repr(C)] -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy, Debug)] pub enum PeerDisconnectReason { PeerDisconnectReasonTimeout, PeerDisconnectReasonQuit, diff --git a/omp-gdk/src/types/vector.rs b/omp-gdk/src/types/vector.rs index 7a5b78e..a0ff9b2 100644 --- a/omp-gdk/src/types/vector.rs +++ b/omp-gdk/src/types/vector.rs @@ -1,4 +1,4 @@ -#[derive(Copy, Clone, Debug, Default)] +#[derive(Copy, Clone, Debug, Default, PartialEq)] #[repr(C)] pub struct Vector2 { pub x: f32, @@ -11,7 +11,7 @@ impl Vector2 { } } -#[derive(Copy, Clone, Debug, Default)] +#[derive(Copy, Clone, Debug, Default, PartialEq)] #[repr(C)] pub struct Vector3 { pub x: f32, @@ -25,7 +25,7 @@ impl Vector3 { } } -#[derive(Copy, Clone, Debug, Default)] +#[derive(Copy, Clone, Debug, Default, PartialEq)] #[repr(C)] pub struct Vector4 { pub x: f32,