show crc32 for some pieces of .bin and .dat data in quest info display
This commit is contained in:
parent
7fd21a493c
commit
5bc061be5f
|
@ -8,6 +8,7 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.40"
|
||||
crc = "1.8.1"
|
||||
|
||||
[dependencies.psoutils]
|
||||
path = "../psoutils"
|
|
@ -6,6 +6,8 @@ use psoutils::quest::bin::QuestBin;
|
|||
use psoutils::quest::dat::{QuestDat, QuestDatTableType};
|
||||
use psoutils::quest::Quest;
|
||||
|
||||
use crate::utils::crc32;
|
||||
|
||||
fn format_description_field(description: &String) -> String {
|
||||
description
|
||||
.trim()
|
||||
|
@ -13,13 +15,21 @@ fn format_description_field(description: &String) -> String {
|
|||
}
|
||||
|
||||
fn display_quest_bin_info(bin: &QuestBin) {
|
||||
let object_code_crc32 = crc32(bin.object_code.as_ref());
|
||||
let function_offset_table_crc32 = crc32(bin.function_offset_table.as_ref());
|
||||
|
||||
println!("QUEST .BIN FILE");
|
||||
println!("======================================================================");
|
||||
println!("name: {}", bin.header.name);
|
||||
println!("object_code size: {}", bin.object_code.len());
|
||||
println!(
|
||||
"function_offset_table size: {}",
|
||||
bin.function_offset_table.len()
|
||||
"object_code: size: {}, crc32: {:08x}",
|
||||
bin.object_code.len(),
|
||||
object_code_crc32
|
||||
);
|
||||
println!(
|
||||
"function_offset_table: size: {}, crc32: {:08x}",
|
||||
bin.function_offset_table.len(),
|
||||
function_offset_table_crc32
|
||||
);
|
||||
println!("is_download: {}", bin.header.is_download);
|
||||
println!(
|
||||
|
@ -46,58 +56,65 @@ fn display_quest_bin_info(bin: &QuestBin) {
|
|||
|
||||
fn display_quest_dat_info(dat: &QuestDat, episode: u32) {
|
||||
println!("QUEST .DAT FILE");
|
||||
println!("======================================================================");
|
||||
println!("================================================================================");
|
||||
|
||||
for (index, table) in dat.tables.iter().enumerate() {
|
||||
let body_size = table.bytes.len();
|
||||
let body_crc32 = crc32(table.bytes.as_ref());
|
||||
|
||||
match table.table_type() {
|
||||
QuestDatTableType::Object => {
|
||||
let num_entities = body_size / 68;
|
||||
println!(
|
||||
"{:3} {:5} {:<21} {:30} {:5}",
|
||||
"{:3} {:5} {:<21} {:30} {:5} {:08x}",
|
||||
index,
|
||||
body_size,
|
||||
table.table_type().to_string(),
|
||||
table.area_name(episode).to_string(),
|
||||
num_entities
|
||||
num_entities,
|
||||
body_crc32
|
||||
);
|
||||
}
|
||||
QuestDatTableType::NPC => {
|
||||
let num_entities = body_size / 72;
|
||||
println!(
|
||||
"{:3} {:5} {:<21} {:30} {:5}",
|
||||
"{:3} {:5} {:<21} {:30} {:5} {:08x}",
|
||||
index,
|
||||
body_size,
|
||||
table.table_type().to_string(),
|
||||
table.area_name(episode).to_string(),
|
||||
num_entities
|
||||
num_entities,
|
||||
body_crc32
|
||||
);
|
||||
}
|
||||
QuestDatTableType::Wave => {
|
||||
println!(
|
||||
"{:3} {:5} {:<21} {:30}",
|
||||
index,
|
||||
body_size,
|
||||
table.table_type().to_string(),
|
||||
table.area_name(episode).to_string()
|
||||
);
|
||||
}
|
||||
QuestDatTableType::ChallengeModeSpawns => {
|
||||
println!(
|
||||
"{:3} {:5} {:<21} {:30}",
|
||||
index,
|
||||
body_size,
|
||||
table.table_type().to_string(),
|
||||
table.area_name(episode).to_string()
|
||||
);
|
||||
}
|
||||
QuestDatTableType::ChallengeModeUnknown => {
|
||||
println!(
|
||||
"{:3} {:5} {:<21} {:30}",
|
||||
"{:3} {:5} {:<21} {:30} {:08x}",
|
||||
index,
|
||||
body_size,
|
||||
table.table_type().to_string(),
|
||||
table.area_name(episode).to_string(),
|
||||
body_crc32
|
||||
);
|
||||
}
|
||||
QuestDatTableType::ChallengeModeSpawns => {
|
||||
println!(
|
||||
"{:3} {:5} {:<21} {:30} {:08x}",
|
||||
index,
|
||||
body_size,
|
||||
table.table_type().to_string(),
|
||||
table.area_name(episode).to_string(),
|
||||
body_crc32
|
||||
);
|
||||
}
|
||||
QuestDatTableType::ChallengeModeUnknown => {
|
||||
println!(
|
||||
"{:3} {:5} {:<21} {:30} {:08x}",
|
||||
index,
|
||||
body_size,
|
||||
table.table_type().to_string(),
|
||||
table.area_name(episode).to_string(),
|
||||
body_crc32
|
||||
);
|
||||
}
|
||||
QuestDatTableType::Unknown(n) => {
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
pub mod convert;
|
||||
pub mod info;
|
||||
mod utils;
|
||||
|
|
7
psogc_quest_tool/src/utils.rs
Normal file
7
psogc_quest_tool/src/utils.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use crc::{crc32, Hasher32};
|
||||
|
||||
pub fn crc32(bytes: &[u8]) -> u32 {
|
||||
let mut digest = crc32::Digest::new(crc32::IEEE);
|
||||
digest.write(bytes);
|
||||
digest.sum32()
|
||||
}
|
Loading…
Reference in a new issue