Skip to content

Commit

Permalink
Update dependencies and eo-protocol
Browse files Browse the repository at this point in the history
Fix problems in build script
  • Loading branch information
sorokya committed Aug 21, 2024
1 parent 2021a6a commit dd94ed8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "eolib"
version = "1.0.0"
version = "2.0.0"
authors = ["Richard Leek <richard@richardleek.com>"]
description = "A core rust library for writing applications related to Endless Online"
edition = "2021"
Expand Down
13 changes: 11 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,14 @@ fn generate_serialize_field(code: &mut String, field: &Field, enums: &[Enum], st
};

code.push_str(&format!(
" if let Some({}) = self.{} {{\n",
" if let Some({}) = self.{}{} {{\n",
replace_keyword(name),
replace_keyword(name)
replace_keyword(name),
if is_primitive(&field.data_type) || enums.iter().any(|e| e.name == field.data_type) {
""
} else {
".as_ref()"
}
));
generate_inner_field_serialize(code, field, enums, structs);
code.push_str(" }\n");
Expand Down Expand Up @@ -1605,6 +1610,10 @@ static PRIMITIVE_TYPES: [&str; 9] = [
"blob",
];

fn is_primitive(data_type: &str) -> bool {
PRIMITIVE_TYPES.contains(&data_type)
}

fn get_imports(elements: &[StructElement], protocols: &[(Protocol, PathBuf)]) -> Vec<String> {
let mut imports = vec![
"use crate::data::{EoReader, EoReaderError, EoWriter, EoSerialize, EoSerializeError};"
Expand Down
2 changes: 1 addition & 1 deletion eo-protocol

0 comments on commit dd94ed8

Please sign in to comment.