Skip to content

Commit

Permalink
Rename crates
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthox committed Sep 30, 2023
1 parent 574897e commit 57c8b88
Show file tree
Hide file tree
Showing 61 changed files with 108 additions and 44 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
members = [
"arcdps",
"arcdps_codegen",
"arcdps_evtc",
"arcdps_parse",
"evtc",
"evtc_dump",
"evtc_parse",
"example_plugin",
]
resolver = "2"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ This project is split into multiple crates covering different parts of ArcDPS.
| Crate | Purpose |
|---|---|
| [arcdps](./arcdps) | Bindings for ArcDPS plugins.
| [arcdps_evtc](./arcdps_evtc) | Bindings for the ArcDPS EVTC API.
| [arcdps_parse](./arcdps_parse) | Parsing for ArcDPS EVTC logs.
| [evtc](./evtc) | Bindings for the ArcDPS EVTC API.
| [evtc_parse](./evtc_parse) | Parsing for ArcDPS EVTC logs.

If you are interested in writing an ArcDPS plugin in Rust, take a look at the [arcdps](./arcdps) crate in this repository.
Its documentation can be found at [zerthox.github.io/arcdps-bindings/arcdps/](https://zerthox.github.io/arcdps-bindings/arcdps/).
Expand Down
6 changes: 3 additions & 3 deletions arcdps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ license = "MIT"

[dependencies]
arcdps_codegen = { path = "../arcdps_codegen" }
arcdps_evtc = { path = "../arcdps_evtc" }
arcdps-imgui = { version = "0.8.0", features = ["tables-api"] }
chrono = { version = "0.4.24", optional = true }
evtc = { path = "../evtc" }
log = { version = "0.4.17", features = ["std"], optional = true }
num_enum = "0.7.0"
serde = { version = "1.0.160", features = ["derive"], optional = true }
Expand All @@ -34,5 +34,5 @@ features = [
default = ["unwind"]
unwind = ["arcdps_codegen/unwind"]
extras = ["arcdps_codegen/extras", "chrono"]
serde = ["dep:serde", "arcdps_evtc/serde", "chrono/serde"]
strum = ["dep:strum", "arcdps_evtc/strum"]
serde = ["dep:serde", "evtc/serde", "chrono/serde"]
strum = ["dep:strum", "evtc/strum"]
2 changes: 1 addition & 1 deletion arcdps/src/evtc/agent.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::util::str_from_cstr;
use arcdps_evtc::AgentKind;
use evtc::AgentKind;
use std::os::raw::c_char;

#[cfg(feature = "serde")]
Expand Down
2 changes: 1 addition & 1 deletion arcdps/src/evtc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mod ext {
pub mod agent;
}

pub use arcdps_evtc::*;
pub use evtc::*;
pub use ext::agent::*;
6 changes: 5 additions & 1 deletion arcdps_evtc/Cargo.toml → evtc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "arcdps_evtc"
name = "evtc"
version = "0.7.0"
authors = ["Zerthox"]
edition = "2021"
Expand All @@ -14,3 +14,7 @@ strum = { version = "0.25.0", features = ["derive"], optional = true }

[dev-dependencies]
approx = "0.5.1"

[features]
serde = ["dep:serde"]
strum = ["dep:strum"]
4 changes: 2 additions & 2 deletions arcdps_evtc/README.md → evtc/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# arcdps_evtc
# evtc

Rust bindings for the ArcDPS EVTC API.
Includes everything shared between Arc's realtime API used by plugins and Arc's log API consumed by parsers.

Documentation can be found at [zerthox.github.io/arcdps-bindings/arcdps_evtc/](https://zerthox.github.io/arcdps-bindings/arcdps_evtc/).
Documentation can be found at [zerthox.github.io/arcdps-bindings/evtc/](https://zerthox.github.io/arcdps-bindings/evtc/).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions arcdps_evtc/src/buff/apply.rs → evtc/src/buff/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct BuffApplyEvent {
pub common: CommonEvent,

/// Kind of buff application/extension.
pub kind: BuffApplyKind,
pub apply: BuffApplyKind,

/// Buff.
// TODO: meaning?
Expand All @@ -38,7 +38,7 @@ impl Extract for BuffApplyEvent {
Self {
common: event.into(),
buff: event.buff,
kind: BuffApplyKind::extract(event),
apply: BuffApplyKind::extract(event),
stack_active: event.is_shields,
stack_id: transmute_field!(event.pad61 as u32),
}
Expand All @@ -55,6 +55,7 @@ impl TryExtract for BuffApplyEvent {
/// Buff apply behavior.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "kind"))]
#[cfg_attr(
feature = "strum",
derive(Display, EnumCount, EnumIter, IntoStaticStr, EnumVariantNames)
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions arcdps_evtc/src/buff/formula.rs → evtc/src/buff/formula.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct BuffFormula {
pub kind: u32,
pub formula: u32,
pub attr1: u32,
pub attr2: u32,
pub param1: f32,
Expand Down Expand Up @@ -53,7 +53,7 @@ impl From<RawBuffFormula> for BuffFormula {
#[inline]
fn from(raw: RawBuffFormula) -> Self {
Self {
kind: raw.kind as _,
formula: raw.formula as _,
attr1: raw.attr1 as _,
attr2: raw.attr2 as _,
param1: raw.param1,
Expand All @@ -76,7 +76,7 @@ impl From<RawBuffFormula> for BuffFormula {
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct RawBuffFormula {
pub kind: f32,
pub formula: f32,
pub attr1: f32,
pub attr2: f32,
pub param1: f32,
Expand Down Expand Up @@ -112,7 +112,7 @@ impl Extract for RawBuffFormula {
let [buff_src, buff_self] = transmute_field!(event.src_instance_id as [f32; 2]);

Self {
kind,
formula: kind,
attr1,
attr2,
param1,
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions arcdps_evtc/src/buff/remove.rs → evtc/src/buff/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct BuffRemoveEvent {
pub common: CommonEvent,

/// Kind of buff remove.
pub kind: BuffRemove,
pub remove: BuffRemove,

/// Buff.
// TODO: meaning?
Expand Down Expand Up @@ -51,7 +51,7 @@ impl Extract for BuffRemoveEvent {
let kind = event.get_buffremove();
Self {
common: event.into(),
kind,
remove: kind,
buff: event.buff,
removed_duration: event.value,
removed_intensity: event.buff_dmg,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use serde::{Deserialize, Serialize};
/// Possible [`Event`] kinds.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "kind"))]
pub enum EventKind {
/// Agent entered combat.
EnterCombat(EnterCombatEvent),
Expand Down Expand Up @@ -146,7 +147,7 @@ pub enum EventKind {
Extension(Event),

/// Delayed combat event.
ApiDelayed(Box<EventKind>),
ApiDelayed { event: Box<EventKind> },

/// Instance started.
InstanceStart { time: u64, start: u64 },
Expand Down Expand Up @@ -261,7 +262,9 @@ impl From<Event> for EventKind {
StateChange::Extension => Self::Extension(event),
StateChange::ApiDelayed => {
event.is_statechange = StateChange::None.into();
Self::ApiDelayed(event.into_kind().into())
Self::ApiDelayed {
event: event.into_kind().into(),
}
}
StateChange::InstanceStart => Self::InstanceStart {
time: event.time,
Expand All @@ -284,9 +287,9 @@ impl From<Event> for EventKind {
StateChange::Unknown(_) => Self::Unknown(event),
},
EventCategory::Activation => Self::Activation(event.extract()),
EventCategory::BuffRemove => Self::Activation(event.extract()),
EventCategory::BuffApply => Self::Activation(event.extract()),
EventCategory::BuffDamage => Self::Activation(event.extract()),
EventCategory::BuffRemove => Self::BuffRemove(event.extract()),
EventCategory::BuffApply => Self::BuffApply(event.extract()),
EventCategory::BuffDamage => Self::BuffDamage(event.extract()),
EventCategory::Strike => Self::Strike(event.extract()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion arcdps_evtc/src/event/mod.rs → evtc/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl Event {
self.affinity.into()
}

/// Returns the event ìs_activation` as [`Activation`].
/// Returns the event `is_activation` as [`Activation`].
///
/// This will return [`Activation::Unknown`] if the event has no valid data in `is_activation`.
#[inline]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct ActivationEvent {
pub skill_id: u32,

/// Kind of activation state change.
pub kind: Activation,
pub activation: Activation,

/// Activation duration.
pub duration: i32,
Expand All @@ -45,7 +45,7 @@ impl Extract for ActivationEvent {
time: event.time,
agent: AgentId::from_src(event),
skill_id: event.skill_id,
kind: event.get_activation(),
activation: event.get_activation(),
duration: event.value,
full_duration: event.buff_dmg,
target: Position::new(x, y, z),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions arcdps_evtc/src/strike.rs → evtc/src/strike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct StrikeEvent {
pub common: CommonEvent,

/// Kind of strike.
pub kind: Strike,
pub strike: Strike,

/// Total damage inflicted.
pub total_damage: i32,
Expand All @@ -35,7 +35,7 @@ impl Extract for StrikeEvent {
unsafe fn extract(event: &Event) -> Self {
Self {
common: event.into(),
kind: event.result.into(),
strike: event.result.into(),
total_damage: event.value,
shield_damage: event.overstack_value,
target_downed: event.is_offcycle == 1,
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions evtc_dump/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "evtc_dump"
version = "0.1.0"
authors = ["Zerthox"]
edition = "2021"
description = "Dump ArcDPS EVTC log information"
repository = "https://github.com/zerthox/arcdps-bindings"

[dependencies]
clap = { version = "4.4.6", features = ["derive"] }
evtc_parse = { path = "../evtc_parse", features = ["serde", "zevtc"] }
serde_json = "1.0.107"
43 changes: 43 additions & 0 deletions evtc_dump/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use clap::Parser;
use evtc_parse::parse_file;
use std::{
fs::File,
io::BufWriter,
path::{Path, PathBuf},
};

#[derive(Debug, Clone, Parser)]
struct Args {
/// Input path to EVTC file.
pub input: String,

/// Output path to JSON file.
///
/// Defaults to input path with JSON file extension.
pub output: Option<PathBuf>,
}

impl Args {
fn output_path(&self) -> PathBuf {
self.output
.as_ref()
.cloned()
.unwrap_or_else(|| Path::new(&self.input).with_extension("json"))
}
}

fn main() {
let args = Args::parse();

let log = parse_file(&args.input).expect("failed to parse EVTC log");

let events = log
.events
.into_iter()
.map(|event| event.into_kind())
.collect::<Vec<_>>();

let file = File::create(args.output_path()).expect("failed to create output file");
let writer = BufWriter::new(file);
serde_json::to_writer_pretty(writer, &events).expect("failed to write events");
}
6 changes: 3 additions & 3 deletions arcdps_parse/Cargo.toml → evtc_parse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "arcdps_parse"
name = "evtc_parse"
version = "0.6.2"
authors = ["Zerthox"]
edition = "2021"
description = "Parsing for ArcDPS EVTC logs"
repository = "https://github.com/zerthox/arcdps-bindings"

[dependencies]
arcdps_evtc = { path = "../arcdps_evtc" }
evtc = { path = "../evtc" }
byteorder = "1.4.3"
serde = { version = "1.0.160", features = ["derive"], optional = true }
thiserror = "1.0.38"
zip = { version = "0.6.4", optional = true }

[features]
serde = ["dep:serde", "arcdps_evtc/serde"]
serde = ["dep:serde", "evtc/serde"]
zevtc = ["dep:zip"]
zip = ["zevtc"]
12 changes: 6 additions & 6 deletions arcdps_parse/README.md → evtc_parse/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# arcdps_parse
# evtc_parse

Parsing for ArcDPS EVTC logs.

Documentation can be found at [zerthox.github.io/arcdps-bindings/arcdps_parse/](https://zerthox.github.io/arcdps-bindings/arcdps_parse/).
Documentation can be found at [zerthox.github.io/arcdps-bindings/evtc_parse/](https://zerthox.github.io/arcdps-bindings/evtc_parse/).

## Usage
```toml
[dependencies]
arcdps_parse = { git = "https://github.com/zerthox/arcdps-bindings" }
evtc_parse = { git = "https://github.com/zerthox/arcdps-bindings" }
```

Use the `parse_file` function to easily parse a log from a file path.
```rs
match arcdps_parse::parse_file("path/to/log.evtc") {
match evtc_parse::parse_file("path/to/log.evtc") {
Ok(log) => println!("Log for boss id {}", log.header.boss_id),
Err(err) => eprintln!("Encountered error {}", err),
}
```

A log can also be parsed from any input implementing `Read`.
```rs
use arcdps_parse::{Log, Parse};
use evtc_parse::{Log, Parse};
use std::io;

fn parse_from_read(input: &mut impl io::Read) -> Log {
Expand All @@ -34,5 +34,5 @@ Enabling the `"zevtc"` or `"zip"` feature adds support for compressed logs.

```toml
[dependencies]
arcdps_parse = { git = "https://github.com/zerthox/arcdps-bindings", features = ["zevtc"] }
evtc_parse = { git = "https://github.com/zerthox/arcdps-bindings", features = ["zevtc"] }
```
2 changes: 1 addition & 1 deletion arcdps_parse/src/agent.rs → evtc_parse/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{
util::{read_string_buffer, write_string_buffer, Endian},
Parse, ParseError, Save,
};
use arcdps_evtc::AgentKind;
use byteorder::{ReadBytesExt, WriteBytesExt};
use evtc::AgentKind;
use std::io;

#[cfg(feature = "serde")]
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 57c8b88

Please sign in to comment.