Skip to content

Commit

Permalink
Address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Apr 16, 2024
1 parent 23df71f commit 7b99cba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions dmsrc/iconforge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
/// ...,
/// )
/// TRANSFORM_OBJECT format:
/// list("type" = "BlendColor", "color" = "#ff0000", "blend_mode" = ICON_MULTIPLY)
/// list("type" = "BlendIcon", "icon" = [SPRITE_OBJECT], "blend_mode" = ICON_OVERLAY)
/// list("type" = "Scale", "width" = 32, "height" = 32)
/// list("type" = "Crop", "x1" = 1, "y1" = 1, "x2" = 32, "y2" = 32) // (BYOND icons index from 1,1 to the upper bound, inclusive)
/// list("type" = RUSTG_ICONFORGE_BLEND_COLOR, "color" = "#ff0000", "blend_mode" = ICON_MULTIPLY)
/// list("type" = RUSTG_ICONFORGE_BLEND_ICON, "icon" = [SPRITE_OBJECT], "blend_mode" = ICON_OVERLAY)
/// list("type" = RUSTG_ICONFORGE_SCALE, "width" = 32, "height" = 32)
/// list("type" = RUSTG_ICONFORGE_CROP, "x1" = 1, "y1" = 1, "x2" = 32, "y2" = 32) // (BYOND icons index from 1,1 to the upper bound, inclusive)
///
/// Returns a SpritesheetResult as JSON, containing fields:
/// list(
Expand All @@ -35,7 +35,7 @@
#define rustg_iconforge_generate(file_path, spritesheet_name, sprites, hash_icons) RUSTG_CALL(RUST_G, "iconforge_generate")(file_path, spritesheet_name, sprites, "[hash_icons]")
/// Returns a job_id for use with rustg_iconforge_check()
#define rustg_iconforge_generate_async(file_path, spritesheet_name, sprites, hash_icons) RUSTG_CALL(RUST_G, "iconforge_generate_async")(file_path, spritesheet_name, sprites, "[hash_icons]")
/// Returns the status of a job_id
/// Returns the status of an async job_id, or its result if it is completed. See RUSTG_JOB DEFINEs.
#define rustg_iconforge_check(job_id) RUSTG_CALL(RUST_G, "iconforge_check")("[job_id]")
/// Clears all cached DMIs and images, freeing up memory.
/// This should be used after spritesheets are done being generated.
Expand Down
2 changes: 1 addition & 1 deletion src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn hash_algorithm<B: AsRef<[u8]>>(name: &str, bytes: B) -> Result<String> {
Ok(format!("{:x}", hasher.finish()))
}
"xxh64_fixed" => {
let mut hasher = XxHash64::with_seed(17479268743136991876);
let mut hasher = XxHash64::with_seed(17479268743136991876); // this seed is just a random number that should stay the same between builds and runs
hasher.write(bytes.as_ref());
Ok(format!("{:x}", hasher.finish()))
}
Expand Down
4 changes: 3 additions & 1 deletion src/iconforge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,9 @@ fn icon_from_io(icon_in: IconObjectIO) -> IconObject {
transform_hash_input: String::new(),
icon_hash_input: String::new(),
};
result.gen_icon_hash_input().unwrap(); // unsafe but idc
// This line can panic, but I consider that acceptable considering how annoying "proper" error handling would be
// especially when this failing basically breaks the entire program. The panic will be caught and written to logs anyway.
result.gen_icon_hash_input().unwrap();
result
}

Expand Down

0 comments on commit 7b99cba

Please sign in to comment.