Skip to content

Commit

Permalink
Always set random mii default names
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Aug 19, 2023
1 parent 2e242d4 commit 506e141
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
20 changes: 10 additions & 10 deletions emuiibo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions emuiibo/src/amiibo/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ impl VirtualAmiiboAreaInfo {
}
}

const DEFAULT_MII_NAME: &'static str = "emuiibo";

pub fn generate_areas_json(path: String) -> Result<Option<nfp::AccessId>> {
let mut access_ids: Vec<nfp::AccessId> = Vec::new();

Expand Down Expand Up @@ -237,8 +235,6 @@ impl VirtualAmiibo {
}
else {
let mut random_mii = miiext::generate_random_mii()?;
random_mii.name.set_str(DEFAULT_MII_NAME)?;

let mut mii_charinfo_file = fs::open_file(mii_charinfo_path, fs::FileOpenOption::Create() | fs::FileOpenOption::Write() | fs::FileOpenOption::Append())?;
mii_charinfo_file.write_val(&random_mii)?;
Ok(random_mii)
Expand Down
7 changes: 6 additions & 1 deletion emuiibo/src/miiext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ pub fn finalize() {
}
}

const DEFAULT_MII_NAME: &'static str = "emuiibo";

#[inline]
pub fn generate_random_mii() -> Result<mii::CharInfo> {
get_database_service()?.get().build_random(sf::EnumAsPrimitiveType::from(mii::Age::All), sf::EnumAsPrimitiveType::from(mii::Gender::All), sf::EnumAsPrimitiveType::from(mii::Race::All))
let mut char_info = get_database_service()?.get().build_random(sf::EnumAsPrimitiveType::from(mii::Age::All), sf::EnumAsPrimitiveType::from(mii::Gender::All), sf::EnumAsPrimitiveType::from(mii::Race::All))?;
// Default name is "no name", use our own default instead
char_info.name.set_str(DEFAULT_MII_NAME)?;
Ok(char_info)
}

const MII_SOURCE_FLAG: mii::SourceFlag = mii::SourceFlag::Database();
Expand Down

0 comments on commit 506e141

Please sign in to comment.