fix multi path avatar

This commit is contained in:
amizing25
2024-06-27 19:41:36 +07:00
parent 4aae475c09
commit 19d39c7a26
10 changed files with 443 additions and 384 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
use crate::net::tools::JsonData; use crate::net::tools::FreesrData;
use super::*; use super::*;
@@ -13,7 +13,7 @@ pub async fn on_get_avatar_data_cs_req(
session: &mut PlayerSession, session: &mut PlayerSession,
body: &GetAvatarDataCsReq, body: &GetAvatarDataCsReq,
) -> Result<()> { ) -> Result<()> {
let json = JsonData::load().await; let json = FreesrData::load().await;
session session
.send( .send(
CMD_GET_AVATAR_DATA_SC_RSP, CMD_GET_AVATAR_DATA_SC_RSP,
+2 -3
View File
@@ -67,14 +67,13 @@ pub async fn on_scene_cast_skill_cs_req(
} }
async fn create_battle_info() -> SceneBattleInfo { async fn create_battle_info() -> SceneBattleInfo {
let player = tools::JsonData::load().await; let player = tools::FreesrData::load().await;
let mut battle_info = SceneBattleInfo { let mut battle_info = SceneBattleInfo {
stage_id: player.battle_config.stage_id, stage_id: player.battle_config.stage_id,
logic_random_seed: rand::thread_rng().gen::<u32>(), logic_random_seed: rand::thread_rng().gen::<u32>(),
battle_id: 1, battle_id: 1,
// cleheggdkal: player.battle_config.cycle_count, // wave rounds_limit: player.battle_config.cycle_count,
rounds_limit: player.battle_config.cycle_count, // wave
..Default::default() ..Default::default()
}; };
+80 -42
View File
@@ -1,5 +1,8 @@
use crate::{ use crate::{
net::{tools::JsonData, PlayerSession}, net::{
tools::{FreesrData, MultiPathAvatar},
PlayerSession,
},
util::cur_timestamp_ms, util::cur_timestamp_ms,
}; };
@@ -63,6 +66,13 @@ pub async fn on_get_private_chat_history_cs_req(
sender_uid: 727, sender_uid: 727,
..Default::default() ..Default::default()
}, },
Chat {
msg_type: MsgType::CustomText.into(),
sent_time: cur_timestamp_ms(),
text: "'march {march_id}' march_id can be set 1001 or 1224".to_string(),
sender_uid: 727,
..Default::default()
},
Chat { Chat {
msg_type: MsgType::CustomText.into(), msg_type: MsgType::CustomText.into(),
sent_time: cur_timestamp_ms(), sent_time: cur_timestamp_ms(),
@@ -80,9 +90,9 @@ pub async fn on_get_private_chat_history_cs_req(
} }
pub async fn on_send_msg_cs_req(session: &mut PlayerSession, body: &SendMsgCsReq) -> Result<()> { pub async fn on_send_msg_cs_req(session: &mut PlayerSession, body: &SendMsgCsReq) -> Result<()> {
let json = JsonData::load().await; let mut json = FreesrData::load().await;
if let Some((cmd, _args)) = parse_command(&body.text) { if let Some((cmd, args)) = parse_command(&body.text) {
match cmd { match cmd {
"sync" => { "sync" => {
sync_player(session, json).await?; sync_player(session, json).await?;
@@ -102,48 +112,76 @@ pub async fn on_send_msg_cs_req(session: &mut PlayerSession, body: &SendMsgCsReq
.await?; .await?;
} }
"mc" => { "mc" => {
// let mc = MainCharacter::from( let mc = MultiPathAvatar::from(
// args.first() args.first()
// .unwrap_or(&"") .unwrap_or(&"")
// .parse::<u32>() .parse::<u32>()
// .unwrap_or(json.main_character as u32), .unwrap_or(json.main_character as u32),
// ); );
// json.main_character = mc; json.main_character = mc;
// json.save().await; json.save().await;
// session session
// .send( .send(
// CMD_GET_HERO_BASIC_TYPE_INFO_SC_RSP, CMD_AVATAR_PATH_CHANGED_NOTIFY,
// GetHeroBasicTypeInfoScRsp { AvatarPathChangedNotify {
// retcode: 0, base_avatar_id: 8001,
// gender: mc.get_gender().into(), cur_multi_path_avatar_type: mc as i32,
// cur_basic_type: mc.get_type().into(), },
// basic_type_info_list: vec![HeroBasicTypeInfo { )
// basic_type: mc.get_type().into(), .await?;
// ..Default::default()
// }],
// ..Default::default()
// },
// )
// .await?;
// sync_player(session, json).await?; session
.send(
CMD_REVC_MSG_SC_NOTIFY,
RevcMsgScNotify {
enlmbccjfbg: body.enlmbccjfbg.clone(),
msg_type: body.msg_type,
text: format!("Success change mc to {:#?}", mc),
emote: body.emote,
from_uid: 727, // from
to_uid: 1337, // to
chat_type: body.chat_type,
},
)
.await?;
}
"march" => {
let march_type = MultiPathAvatar::from(
args.first()
.unwrap_or(&"")
.parse::<u32>()
.unwrap_or(json.march_type as u32),
);
// session json.march_type = march_type;
// .send( json.save().await;
// CMD_REVC_MSG_SC_NOTIFY,
// Klonpheafip { session
// ggadmjhlomj: body.ggadmjhlomj.clone(), .send(
// kokadficdfb: body.kokadficdfb, CMD_AVATAR_PATH_CHANGED_NOTIFY,
// ajlhdpcjand: format!("Set MC to: {mc:#?}"), AvatarPathChangedNotify {
// mgmicgabebd: body.mgmicgabebd, base_avatar_id: 1001,
// ghojifhngmc: 727, cur_multi_path_avatar_type: march_type as i32,
// cmmildghfnl: 1337, },
// nmfepfoojic: body.nmfepfoojic, )
// }, .await?;
// )
// .await?; session
.send(
CMD_REVC_MSG_SC_NOTIFY,
RevcMsgScNotify {
enlmbccjfbg: body.enlmbccjfbg.clone(),
msg_type: body.msg_type,
text: format!("Success change march to {:#?}", march_type),
emote: body.emote,
from_uid: 727, // from
to_uid: 1337, // to
chat_type: body.chat_type,
},
)
.await?;
} }
_ => {} _ => {}
} }
@@ -170,7 +208,7 @@ fn parse_command(command: &str) -> Option<(&str, Vec<&str>)> {
Some((parts[0], parts[1..].to_vec())) Some((parts[0], parts[1..].to_vec()))
} }
async fn sync_player(session: &mut PlayerSession, json: JsonData) -> Result<()> { async fn sync_player(session: &mut PlayerSession, json: FreesrData) -> Result<()> {
session session
.send( .send(
CMD_PLAYER_SYNC_SC_NOTIFY, CMD_PLAYER_SYNC_SC_NOTIFY,
+2 -2
View File
@@ -1,10 +1,10 @@
use anyhow::Result; use anyhow::Result;
use proto::*; use proto::*;
use crate::net::{tools::JsonData, PlayerSession}; use crate::net::{tools::FreesrData, PlayerSession};
pub async fn on_get_bag_cs_req(session: &mut PlayerSession, _: &GetBagCsReq) -> Result<()> { pub async fn on_get_bag_cs_req(session: &mut PlayerSession, _: &GetBagCsReq) -> Result<()> {
let player = JsonData::load().await; let player = FreesrData::load().await;
session session
.send( .send(
+14 -10
View File
@@ -1,7 +1,7 @@
use scene_entity_info::Entity; use scene_entity_info::Entity;
use scene_entity_refresh_info::RefreshType; use scene_entity_refresh_info::RefreshType;
use crate::net::tools::{self, AvatarJson, JsonData}; use crate::net::tools::{self, AvatarJson, FreesrData};
use super::*; use super::*;
@@ -9,7 +9,7 @@ pub async fn on_get_all_lineup_data_cs_req(
session: &mut PlayerSession, session: &mut PlayerSession,
_body: &GetAllLineupDataCsReq, _body: &GetAllLineupDataCsReq,
) -> Result<()> { ) -> Result<()> {
let player = tools::JsonData::load().await; let player = tools::FreesrData::load().await;
let lineup = LineupInfo { let lineup = LineupInfo {
extra_lineup_type: ExtraLineupType::LineupNone.into(), extra_lineup_type: ExtraLineupType::LineupNone.into(),
name: "Squad 1".to_string(), name: "Squad 1".to_string(),
@@ -34,7 +34,7 @@ pub async fn on_get_cur_lineup_data_cs_req(
session: &mut PlayerSession, session: &mut PlayerSession,
_body: &GetCurLineupDataCsReq, _body: &GetCurLineupDataCsReq,
) -> Result<()> { ) -> Result<()> {
let player = tools::JsonData::load().await; let player = tools::FreesrData::load().await;
let mut lineup = LineupInfo { let mut lineup = LineupInfo {
extra_lineup_type: ExtraLineupType::LineupNone.into(), extra_lineup_type: ExtraLineupType::LineupNone.into(),
name: "Squad 1".to_string(), name: "Squad 1".to_string(),
@@ -91,12 +91,14 @@ pub async fn on_join_lineup_cs_req(
// update lineups // update lineups
// TODO: FIX THESE SHIT // TODO: FIX THESE SHIT
{ {
let mut player = tools::JsonData::load().await; let mut player = tools::FreesrData::load().await;
let lineups = &mut player.lineups; let lineups = &mut player.lineups;
lineups.insert( lineups.insert(
body.slot, body.slot,
if body.base_avatar_id > 8000 { if body.base_avatar_id == 8001 {
player.main_character as u32 player.main_character as u32
} else if body.base_avatar_id == 1001 {
player.march_type as u32
} else { } else {
body.base_avatar_id body.base_avatar_id
}, },
@@ -105,7 +107,7 @@ pub async fn on_join_lineup_cs_req(
} }
{ {
let player = tools::JsonData::load().await; let player = tools::FreesrData::load().await;
refresh_lineup(session, &player).await?; refresh_lineup(session, &player).await?;
} }
@@ -120,13 +122,15 @@ pub async fn on_replace_lineup_cs_req(
req: &ReplaceLineupCsReq, req: &ReplaceLineupCsReq,
) -> Result<()> { ) -> Result<()> {
{ {
let mut player = tools::JsonData::load().await; let mut player = tools::FreesrData::load().await;
let lineups = &mut player.lineups; let lineups = &mut player.lineups;
for (slot, avatar_id) in &mut *lineups { for (slot, avatar_id) in &mut *lineups {
if let Some(lineup) = req.slots.get(*slot as usize) { if let Some(lineup) = req.slots.get(*slot as usize) {
*avatar_id = if lineup.id > 8000 { *avatar_id = if lineup.id == 8001 {
player.main_character as u32 player.main_character as u32
} else if lineup.id == 1001 {
player.march_type as u32
} else { } else {
lineup.id lineup.id
}; };
@@ -138,7 +142,7 @@ pub async fn on_replace_lineup_cs_req(
} }
{ {
let player = tools::JsonData::load().await; let player = tools::FreesrData::load().await;
refresh_lineup(_session, &player).await?; refresh_lineup(_session, &player).await?;
} }
@@ -157,7 +161,7 @@ pub async fn on_quit_lineup_cs_req(
.await .await
} }
async fn refresh_lineup(sess: &mut PlayerSession, player: &JsonData) -> Result<()> { async fn refresh_lineup(sess: &mut PlayerSession, player: &FreesrData) -> Result<()> {
let lineup = LineupInfo { let lineup = LineupInfo {
extra_lineup_type: ExtraLineupType::LineupNone.into(), extra_lineup_type: ExtraLineupType::LineupNone.into(),
name: "Squad 1".to_string(), name: "Squad 1".to_string(),
+42 -57
View File
@@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use crate::util::{self}; use crate::{net::tools::FreesrData, util};
use super::*; use super::*;
@@ -50,12 +50,7 @@ pub async fn on_player_login_finish_cs_req(
session session
.send(CMD_PLAYER_LOGIN_FINISH_SC_RSP, Dummy {}) .send(CMD_PLAYER_LOGIN_FINISH_SC_RSP, Dummy {})
.await?; .await?;
session
.send(CMD_CONTENT_PACKAGE_UNLOCK_SC_RSP, Dummy {})
.await?;
session
.send(CMD_CONTENT_PACKAGE_GET_DATA_SC_RSP, Dummy {})
.await?;
session session
.send( .send(
CMD_CONTENT_PACKAGE_SYNC_DATA_SC_NOTIFY, CMD_CONTENT_PACKAGE_SYNC_DATA_SC_NOTIFY,
@@ -96,6 +91,8 @@ pub async fn on_get_multi_path_avatar_info_cs_req(
session: &mut PlayerSession, session: &mut PlayerSession,
_: &GetMultiPathAvatarInfoCsReq, _: &GetMultiPathAvatarInfoCsReq,
) -> Result<()> { ) -> Result<()> {
let json = FreesrData::load().await;
session session
.send( .send(
CMD_GET_MULTI_PATH_AVATAR_INFO_SC_RSP, CMD_GET_MULTI_PATH_AVATAR_INFO_SC_RSP,
@@ -103,70 +100,58 @@ pub async fn on_get_multi_path_avatar_info_cs_req(
retcode: 0, retcode: 0,
multi_path_avatar_type_info_list: vec![ multi_path_avatar_type_info_list: vec![
MultiPathAvatarTypeInfo { MultiPathAvatarTypeInfo {
multi_path_avatar_type: MultiPathAvatarType::GirlShamanType.into(), multi_path_avatar_type: json.main_character as i32,
rank: 6, rank: 6,
equip_relic_list: vec![], equip_relic_list: json
skilltree_list: vec![ .relics
AvatarSkillTree { .iter()
.filter(|v| v.equip_avatar == json.main_character as u32)
.map(|v| v.to_equipment_relic_proto())
.collect(),
skilltree_list: (1..=4)
.map(|v| AvatarSkillTree {
level: 1, level: 1,
point_id: 8006001, point_id: (json.main_character as u32) * 1000 + v,
}, })
AvatarSkillTree { .collect(),
level: 1,
point_id: 8006002,
},
AvatarSkillTree {
level: 1,
point_id: 8006003,
},
AvatarSkillTree {
level: 1,
point_id: 8006004,
},
AvatarSkillTree {
level: 1,
point_id: 8006001,
},
],
all_path_special_skilltree_list: vec![], all_path_special_skilltree_list: vec![],
path_equipment_id: 0, path_equipment_id: json
.lightcones
.iter()
.find(|v| v.equip_avatar == json.main_character as u32)
.map(|v| v.internal_uid)
.unwrap_or_default(),
all_path_unlocked_special_point_id_list: vec![], all_path_unlocked_special_point_id_list: vec![],
}, },
MultiPathAvatarTypeInfo { MultiPathAvatarTypeInfo {
multi_path_avatar_type: MultiPathAvatarType::Mar7thKnightType.into(), multi_path_avatar_type: json.march_type as i32,
rank: 6, rank: 6,
equip_relic_list: vec![], equip_relic_list: json
skilltree_list: vec![ .relics
AvatarSkillTree { .iter()
.filter(|v| v.equip_avatar == json.march_type as u32)
.map(|v| v.to_equipment_relic_proto())
.collect(),
skilltree_list: (1..=4)
.map(|v| AvatarSkillTree {
level: 1, level: 1,
point_id: 1224001, point_id: (json.march_type as u32) * 1000 + v,
}, })
AvatarSkillTree { .collect(),
level: 1,
point_id: 1224002,
},
AvatarSkillTree {
level: 1,
point_id: 1224003,
},
AvatarSkillTree {
level: 1,
point_id: 1224004,
},
AvatarSkillTree {
level: 1,
point_id: 1224005,
},
],
all_path_special_skilltree_list: vec![], all_path_special_skilltree_list: vec![],
path_equipment_id: 1224, path_equipment_id: json
.lightcones
.iter()
.find(|v| v.equip_avatar == json.march_type as u32)
.map(|v| v.internal_uid)
.unwrap_or_default(),
all_path_unlocked_special_point_id_list: vec![], all_path_unlocked_special_point_id_list: vec![],
}, },
], ],
gmhdhimdkfi: vec![], gmhdhimdkfi: vec![],
current_multi_path_avatar_id: HashMap::from([ current_multi_path_avatar_id: HashMap::from([
(8001, MultiPathAvatarType::GirlShamanType.into()), (8001, json.main_character.get_type().into()),
(1001, MultiPathAvatarType::Mar7thRogueType.into()), (1001, json.march_type.get_type().into()),
]), ]),
}, },
) )
+5 -5
View File
@@ -5,7 +5,7 @@ use tokio::sync::Mutex;
use crate::{ use crate::{
net::{ net::{
tools::{AvatarJson, JsonData, Position}, tools::{AvatarJson, FreesrData, Position},
tools_res::{PropState, GAME_RESOURCES}, tools_res::{PropState, GAME_RESOURCES},
}, },
util::{self}, util::{self},
@@ -20,7 +20,7 @@ pub async fn on_get_cur_scene_info_cs_req(
session: &mut PlayerSession, session: &mut PlayerSession,
_body: &GetCurSceneInfoCsReq, _body: &GetCurSceneInfoCsReq,
) -> Result<()> { ) -> Result<()> {
let mut player = JsonData::load().await; let mut player = FreesrData::load().await;
let entry = player.scene.entry_id; let entry = player.scene.entry_id;
let scene = load_scene(session, &mut player, entry, false, Option::<u32>::None).await; let scene = load_scene(session, &mut player, entry, false, Option::<u32>::None).await;
@@ -63,7 +63,7 @@ pub async fn on_enter_scene_cs_req(
session: &mut PlayerSession, session: &mut PlayerSession,
request: &EnterSceneCsReq, request: &EnterSceneCsReq,
) -> Result<()> { ) -> Result<()> {
let mut player = JsonData::load().await; let mut player = FreesrData::load().await;
// send packet first // send packet first
session session
@@ -169,7 +169,7 @@ pub async fn on_scene_entity_move_cs_req(
session: &mut PlayerSession, session: &mut PlayerSession,
request: &SceneEntityMoveCsReq, request: &SceneEntityMoveCsReq,
) -> Result<()> { ) -> Result<()> {
let mut player = JsonData::load().await; let mut player = FreesrData::load().await;
let mut timestamp = NEXT_SCENE_SAVE.lock().await; let mut timestamp = NEXT_SCENE_SAVE.lock().await;
if util::cur_timestamp_ms() <= *timestamp { if util::cur_timestamp_ms() <= *timestamp {
@@ -236,7 +236,7 @@ pub async fn on_get_entered_scene_cs_req(
async fn load_scene( async fn load_scene(
session: &mut PlayerSession, session: &mut PlayerSession,
json: &mut JsonData, json: &mut FreesrData,
entry_id: u32, entry_id: u32,
_save: bool, _save: bool,
teleport_id: Option<u32>, teleport_id: Option<u32>,
+40 -22
View File
@@ -129,7 +129,7 @@ impl AvatarJson {
} }
} }
pub fn to_lineup_avatars(player: &JsonData) -> Vec<LineupAvatar> { pub fn to_lineup_avatars(player: &FreesrData) -> Vec<LineupAvatar> {
let avatar_ids = player let avatar_ids = player
.avatars .avatars
.values() .values()
@@ -479,7 +479,7 @@ impl Position {
// FREESR-DATA.json // FREESR-DATA.json
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct JsonData { pub struct FreesrData {
pub lightcones: Vec<Lightcone>, pub lightcones: Vec<Lightcone>,
pub relics: Vec<Relic>, pub relics: Vec<Relic>,
pub avatars: BTreeMap<u32, AvatarJson>, pub avatars: BTreeMap<u32, AvatarJson>,
@@ -493,11 +493,13 @@ pub struct JsonData {
#[serde(default)] #[serde(default)]
pub scene: Scene, pub scene: Scene,
#[serde(default)] #[serde(default)]
pub main_character: MainCharacter, pub main_character: MultiPathAvatar,
#[serde(default)]
pub march_type: MultiPathAvatar,
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct JsonData2 { pub struct Persistent {
#[serde(default)] #[serde(default)]
pub lineups: BTreeMap<u32, u32>, pub lineups: BTreeMap<u32, u32>,
#[serde(default)] #[serde(default)]
@@ -505,10 +507,12 @@ pub struct JsonData2 {
#[serde(default)] #[serde(default)]
pub scene: Scene, pub scene: Scene,
#[serde(default)] #[serde(default)]
pub main_character: MainCharacter, pub main_character: MultiPathAvatar,
#[serde(default)]
pub march_type: MultiPathAvatar,
} }
impl Default for JsonData2 { impl Default for Persistent {
fn default() -> Self { fn default() -> Self {
let mut lineups = BTreeMap::<u32, u32>::new(); let mut lineups = BTreeMap::<u32, u32>::new();
lineups.insert(0, 8006); lineups.insert(0, 8006);
@@ -521,21 +525,24 @@ impl Default for JsonData2 {
position: Default::default(), position: Default::default(),
main_character: Default::default(), main_character: Default::default(),
scene: Default::default(), scene: Default::default(),
march_type: MultiPathAvatar::MarchHunt,
} }
} }
} }
#[derive(Serialize, Deserialize, Clone, Debug, Copy)] #[derive(Serialize, Deserialize, Clone, Debug, Copy)]
pub enum MainCharacter { pub enum MultiPathAvatar {
MalePyhsical = 8001, MalePyhsical = 8001,
FemalePhysical = 8002, FemalePhysical = 8002,
MalePreservation = 8003, MalePreservation = 8003,
FemalePreservation = 8004, FemalePreservation = 8004,
MaleHarmony = 8005, MaleHarmony = 8005,
FemaleHarmony = 8006, FemaleHarmony = 8006,
MarchHunt = 1224,
MarchPreservation = 1001,
} }
impl From<u32> for MainCharacter { impl From<u32> for MultiPathAvatar {
fn from(value: u32) -> Self { fn from(value: u32) -> Self {
match value { match value {
8001 => Self::MalePyhsical, 8001 => Self::MalePyhsical,
@@ -544,14 +551,18 @@ impl From<u32> for MainCharacter {
8004 => Self::FemalePreservation, 8004 => Self::FemalePreservation,
8005 => Self::MaleHarmony, 8005 => Self::MaleHarmony,
8006 => Self::FemaleHarmony, 8006 => Self::FemaleHarmony,
1224 => Self::MarchHunt,
1001 => Self::MarchPreservation,
_ => Self::FemaleHarmony, _ => Self::FemaleHarmony,
} }
} }
} }
impl MainCharacter { impl MultiPathAvatar {
pub fn get_gender(&self) -> Gender { pub fn get_gender(&self) -> Gender {
if *self as u32 % 2 == 1 { if (*self as u32) < 8000 {
Gender::None
} else if *self as u32 % 2 == 1 {
Gender::Man Gender::Man
} else { } else {
Gender::Woman Gender::Woman
@@ -560,33 +571,35 @@ impl MainCharacter {
pub fn get_type(&self) -> MultiPathAvatarType { pub fn get_type(&self) -> MultiPathAvatarType {
match *self { match *self {
Self::MalePyhsical => MultiPathAvatarType::BoyWarriorType, MultiPathAvatar::MalePyhsical => MultiPathAvatarType::BoyWarriorType,
Self::FemalePhysical => MultiPathAvatarType::GirlWarriorType, MultiPathAvatar::FemalePhysical => MultiPathAvatarType::GirlWarriorType,
Self::MalePreservation => MultiPathAvatarType::BoyKnightType, MultiPathAvatar::MalePreservation => MultiPathAvatarType::BoyKnightType,
Self::FemalePreservation => MultiPathAvatarType::GirlKnightType, MultiPathAvatar::FemalePreservation => MultiPathAvatarType::GirlKnightType,
Self::MaleHarmony => MultiPathAvatarType::BoyShamanType, MultiPathAvatar::MaleHarmony => MultiPathAvatarType::BoyShamanType,
Self::FemaleHarmony => MultiPathAvatarType::GirlShamanType, MultiPathAvatar::FemaleHarmony => MultiPathAvatarType::GirlShamanType,
MultiPathAvatar::MarchHunt => MultiPathAvatarType::Mar7thRogueType,
MultiPathAvatar::MarchPreservation => MultiPathAvatarType::Mar7thKnightType,
} }
} }
} }
impl Default for MainCharacter { impl Default for MultiPathAvatar {
fn default() -> Self { fn default() -> Self {
Self::FemaleHarmony Self::FemaleHarmony
} }
} }
impl JsonData { impl FreesrData {
pub async fn load() -> Self { pub async fn load() -> Self {
let mut json: JsonData = tokio::fs::read_to_string("freesr-data.json") let mut json: FreesrData = tokio::fs::read_to_string("freesr-data.json")
.await .await
.map(|v| { .map(|v| {
serde_json::from_str::<JsonData>(&v) serde_json::from_str::<FreesrData>(&v)
.expect("freesr-data.json is broken, pls redownload") .expect("freesr-data.json is broken, pls redownload")
}) })
.expect("failed to read freesr-data.json"); .expect("failed to read freesr-data.json");
let json2: JsonData2 = serde_json::from_str( let json2: Persistent = serde_json::from_str(
&tokio::fs::read_to_string("persistent") &tokio::fs::read_to_string("persistent")
.await .await
.unwrap_or_default(), .unwrap_or_default(),
@@ -600,6 +613,10 @@ impl JsonData {
json.verify_lineup().await; json.verify_lineup().await;
if json.march_type as u32 > 8000 {
json.march_type = MultiPathAvatar::MarchHunt;
}
json json
} }
@@ -623,11 +640,12 @@ impl JsonData {
let _ = tokio::fs::write("freesr-data.json", json.as_bytes()).await; let _ = tokio::fs::write("freesr-data.json", json.as_bytes()).await;
let _ = tokio::fs::write( let _ = tokio::fs::write(
"persistent", "persistent",
serde_json::to_string_pretty(&JsonData2 { serde_json::to_string_pretty(&Persistent {
lineups: self.lineups.clone(), lineups: self.lineups.clone(),
main_character: self.main_character, main_character: self.main_character,
position: self.position.clone(), position: self.position.clone(),
scene: self.scene.clone(), scene: self.scene.clone(),
march_type: self.march_type,
}) })
.unwrap() .unwrap()
.as_bytes(), .as_bytes(),
+255 -240
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -11,7 +11,7 @@ pub struct VersionConfig {
pub asset_bundle_url: String, pub asset_bundle_url: String,
pub ex_resource_url: String, pub ex_resource_url: String,
pub lua_url: String, pub lua_url: String,
pub lua_version: String, // pub lua_version: String,
} }
lazy_static! { lazy_static! {