mirror of
https://github.com/bvanroll/pokevault.git
synced 2025-08-29 12:02:50 +00:00
finish the convert_trainer_name when not lazy
This commit is contained in:
8
main/Cargo.toml
Normal file
8
main/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "pokevault"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
12
main/main.iml
Normal file
12
main/main.iml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="RUST_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
28
main/src/main.rs
Normal file
28
main/src/main.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::path::Path;
|
||||
|
||||
use crate::saves::{convert_trainer_name, Save};
|
||||
|
||||
mod test;
|
||||
mod saves;
|
||||
|
||||
fn main() {
|
||||
|
||||
}
|
||||
|
||||
fn read_save(save_path: &Path) -> Result<Save, ()>{
|
||||
let f = File::open(save_path).unwrap();
|
||||
let mut reader = BufReader::new(f);
|
||||
let mut buffer = Vec::new();
|
||||
reader.read_to_end(&mut buffer).unwrap();
|
||||
let mut temp:Vec<u8> = Vec::new();
|
||||
for &var in &buffer[0x2598.. 0x2598 + 0xb] {
|
||||
|
||||
}
|
||||
let save = Save {
|
||||
trainer_name: convert_trainer_name(buffer[0x2598 .. 0x2598 + 0xb]),
|
||||
playtime_hours: *&buffer[0x2CED]
|
||||
};
|
||||
return Ok(save); //learned something new today
|
||||
}
|
@@ -1,4 +1,13 @@
|
||||
pub struct Save {
|
||||
pub(crate) trainer_name: String,
|
||||
pub(crate) playtime_hours: u8 //in seconds, biggest number should be like 4.3 mill, biggest available time (999:95) is like... 3.6 mill, maybe a little more. 3.7 max
|
||||
}
|
||||
|
||||
// Bytes from the save are not utf8... or i think so. The numbers need to be lower at least.
|
||||
// The save's name should be RED, so have to finish this function
|
||||
pub fn convert_trainer_name(bytes: [u8]) -> String {
|
||||
for mut x in bytes {
|
||||
x -= 40;
|
||||
}
|
||||
return String::from_utf8(bytes).unwrap();
|
||||
}
|
Reference in New Issue
Block a user