Use parking_lot::RwLock instead of tokio::sync::RwLock
See https://docs.rs/tokio/latest/tokio/sync/struct.Mutex.html\#which-kind-of-mutex-should-you-use (same applies for RwLock). We don't need an asynchronous Mutex/RwLock for data.
This commit is contained in:
parent
a7f7102266
commit
07560e605a
16 changed files with 222 additions and 294 deletions
|
@ -20,6 +20,7 @@ leb128 = "0.2.5"
|
||||||
paste = "1.0.14"
|
paste = "1.0.14"
|
||||||
sysinfo = "0.30.7"
|
sysinfo = "0.30.7"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
parking_lot = "0.12.3"
|
||||||
|
|
||||||
csv = "1.3.0"
|
csv = "1.3.0"
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
|
|
|
@ -29,6 +29,7 @@ tracing-bunyan-formatter.workspace = true
|
||||||
common.workspace = true
|
common.workspace = true
|
||||||
protocol.workspace = true
|
protocol.workspace = true
|
||||||
qwer.workspace = true
|
qwer.workspace = true
|
||||||
|
parking_lot.workspace = true
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "nap-gameserver"
|
name = "nap-gameserver"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use parking_lot::RwLock;
|
||||||
use protocol::{PlayerInfo, PtcPlayerInfoChangedArg};
|
use protocol::{PlayerInfo, PtcPlayerInfoChangedArg};
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
use crate::net::NetworkSession;
|
use crate::net::NetworkSession;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::{anyhow, bail, Result};
|
use anyhow::{anyhow, bail, Result};
|
||||||
|
use parking_lot::RwLock;
|
||||||
use protocol::*;
|
use protocol::*;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
use crate::game::{manager::UniqueIDManager, util, PlayerOperationResult};
|
use crate::game::{manager::UniqueIDManager, util, PlayerOperationResult};
|
||||||
use qwer::{
|
use qwer::{
|
||||||
|
@ -23,9 +23,9 @@ impl DungeonManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn enter_main_city(&self) -> Result<PlayerOperationResult<PtcEnterSceneArg>> {
|
pub fn enter_main_city(&self) -> Result<PlayerOperationResult<PtcEnterSceneArg>> {
|
||||||
let (player_uid, scene_position, scene_rotation) = {
|
let (player_uid, scene_position, scene_rotation) = {
|
||||||
let player = self.player.read().await;
|
let player = self.player.read();
|
||||||
let pos_in_main_city = player.pos_in_main_city.as_ref().unwrap();
|
let pos_in_main_city = player.pos_in_main_city.as_ref().unwrap();
|
||||||
|
|
||||||
(
|
(
|
||||||
|
@ -35,7 +35,7 @@ impl DungeonManager {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let default_scene_uid = player
|
let default_scene_uid = player
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -113,12 +113,12 @@ impl DungeonManager {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn enter_scene_section(
|
pub fn enter_scene_section(
|
||||||
&self,
|
&self,
|
||||||
scene_uid: u64,
|
scene_uid: u64,
|
||||||
section_id: i32,
|
section_id: i32,
|
||||||
) -> PlayerOperationResult<PtcEnterSectionArg> {
|
) -> PlayerOperationResult<PtcEnterSectionArg> {
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let scene_info = player
|
let scene_info = player
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
@ -145,12 +145,9 @@ impl DungeonManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn enter_scene(
|
pub fn enter_scene(&self, scene_uid: u64) -> Result<PlayerOperationResult<PtcEnterSceneArg>> {
|
||||||
&self,
|
|
||||||
scene_uid: u64,
|
|
||||||
) -> Result<PlayerOperationResult<PtcEnterSceneArg>> {
|
|
||||||
let (player_uid, prev_scene_uid) = {
|
let (player_uid, prev_scene_uid) = {
|
||||||
let player = self.player.read().await;
|
let player = self.player.read();
|
||||||
|
|
||||||
(
|
(
|
||||||
*player.uid.as_ref().unwrap(),
|
*player.uid.as_ref().unwrap(),
|
||||||
|
@ -158,7 +155,7 @@ impl DungeonManager {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
player.scene_uid.replace(scene_uid);
|
player.scene_uid.replace(scene_uid);
|
||||||
player.prev_scene_uid.replace(prev_scene_uid);
|
player.prev_scene_uid.replace(prev_scene_uid);
|
||||||
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
||||||
|
@ -248,10 +245,10 @@ impl DungeonManager {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn hollow_finished(&self) -> PlayerOperationResult<u64> {
|
pub fn hollow_finished(&self) -> PlayerOperationResult<u64> {
|
||||||
let cur_scene_uid = self.get_cur_scene_uid().await;
|
let cur_scene_uid = self.get_cur_scene_uid();
|
||||||
|
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
|
|
||||||
let hollow_scene = player
|
let hollow_scene = player
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
|
@ -313,10 +310,9 @@ impl DungeonManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_default_scene_uid(&self) -> u64 {
|
pub fn get_default_scene_uid(&self) -> u64 {
|
||||||
self.player
|
self.player
|
||||||
.read()
|
.read()
|
||||||
.await
|
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -325,10 +321,9 @@ impl DungeonManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub async fn get_default_scene_uid_for_dungeon(&self, dungeon_uid: u64) -> u64 {
|
pub fn get_default_scene_uid_for_dungeon(&self, dungeon_uid: u64) -> u64 {
|
||||||
self.player
|
self.player
|
||||||
.read()
|
.read()
|
||||||
.await
|
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -340,12 +335,12 @@ impl DungeonManager {
|
||||||
.default_scene_uid
|
.default_scene_uid
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_cur_scene_uid(&self) -> u64 {
|
pub fn get_cur_scene_uid(&self) -> u64 {
|
||||||
self.player.read().await.scene_uid.unwrap()
|
self.player.read().scene_uid.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn add_default_hollow_properties(&self, scene_uid: u64) {
|
fn add_default_hollow_properties(&self, scene_uid: u64) {
|
||||||
let mut props = self.scene_properties.write().await;
|
let mut props = self.scene_properties.write();
|
||||||
|
|
||||||
for (sub_key, value) in &[
|
for (sub_key, value) in &[
|
||||||
(1001, 0),
|
(1001, 0),
|
||||||
|
@ -380,11 +375,11 @@ impl DungeonManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn leave_battle(&self) -> Result<PlayerOperationResult<PtcEnterSceneArg>> {
|
pub fn leave_battle(&self) -> Result<PlayerOperationResult<PtcEnterSceneArg>> {
|
||||||
let back_scene_uid = self.get_back_scene_uid().await;
|
let back_scene_uid = self.get_back_scene_uid();
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
|
|
||||||
let hollow_scene = player
|
let hollow_scene = player
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
|
@ -404,11 +399,11 @@ impl DungeonManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.enter_scene(back_scene_uid).await
|
self.enter_scene(back_scene_uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_back_scene_uid(&self) -> u64 {
|
fn get_back_scene_uid(&self) -> u64 {
|
||||||
let player = self.player.read().await;
|
let player = self.player.read();
|
||||||
let fight_scene_uid = player.scene_uid.as_ref().unwrap();
|
let fight_scene_uid = player.scene_uid.as_ref().unwrap();
|
||||||
let fight_scene = player
|
let fight_scene = player
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
|
@ -423,14 +418,12 @@ impl DungeonManager {
|
||||||
fight_scene.get_back_scene_uid()
|
fight_scene.get_back_scene_uid()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn enter_battle(&self, scene_uid: u64) -> PlayerOperationResult<PtcEnterSceneArg> {
|
pub fn enter_battle(&self, scene_uid: u64) -> PlayerOperationResult<PtcEnterSceneArg> {
|
||||||
let hollow_scene_uid = *self.player.read().await.scene_uid.as_ref().unwrap();
|
let hollow_scene_uid = *self.player.read().scene_uid.as_ref().unwrap();
|
||||||
let hollow_scene = self
|
let hollow_scene = self.set_cur_hollow_battle(scene_uid, hollow_scene_uid);
|
||||||
.set_cur_hollow_battle(scene_uid, hollow_scene_uid)
|
let ptc_enter_scene = self.enter_scene(scene_uid).unwrap().unwrap().clone();
|
||||||
.await;
|
|
||||||
let ptc_enter_scene = self.enter_scene(scene_uid).await.unwrap().unwrap().clone();
|
|
||||||
|
|
||||||
let player = self.player.read().await;
|
let player = self.player.read();
|
||||||
let dungeon_collection = player.dungeon_collection.as_ref().unwrap();
|
let dungeon_collection = player.dungeon_collection.as_ref().unwrap();
|
||||||
let fight_scene = dungeon_collection
|
let fight_scene = dungeon_collection
|
||||||
.scenes
|
.scenes
|
||||||
|
@ -459,8 +452,8 @@ impl DungeonManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn set_cur_hollow_battle(&self, scene_uid: u64, hollow_scene_uid: u64) -> SceneInfo {
|
fn set_cur_hollow_battle(&self, scene_uid: u64, hollow_scene_uid: u64) -> SceneInfo {
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let hollow_scene = player
|
let hollow_scene = player
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
@ -485,8 +478,8 @@ impl DungeonManager {
|
||||||
hollow_scene.clone()
|
hollow_scene.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_fight(&self, id: i32, hollow_scene_uid: u64) -> PlayerOperationResult<u64> {
|
pub fn create_fight(&self, id: i32, hollow_scene_uid: u64) -> PlayerOperationResult<u64> {
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
||||||
let scenes = dungeon_collection.scenes.as_mut().unwrap();
|
let scenes = dungeon_collection.scenes.as_mut().unwrap();
|
||||||
let hollow_scene = scenes.get_mut(&hollow_scene_uid).unwrap();
|
let hollow_scene = scenes.get_mut(&hollow_scene_uid).unwrap();
|
||||||
|
@ -526,10 +519,10 @@ impl DungeonManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub async fn is_in_tutorial(&self) -> bool {
|
pub fn is_in_tutorial(&self) -> bool {
|
||||||
let cur_scene_uid = self.get_cur_scene_uid().await;
|
let cur_scene_uid = self.get_cur_scene_uid();
|
||||||
|
|
||||||
let player = self.player.read().await;
|
let player = self.player.read();
|
||||||
let cur_scene = player
|
let cur_scene = player
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -543,24 +536,22 @@ impl DungeonManager {
|
||||||
matches!(cur_scene, SceneInfo::Fresh { .. })
|
matches!(cur_scene, SceneInfo::Fresh { .. })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_hollow(
|
pub fn create_hollow(
|
||||||
&self,
|
&self,
|
||||||
id: i32,
|
id: i32,
|
||||||
world_quest_id: i32,
|
world_quest_id: i32,
|
||||||
avatar_uids: &[u64],
|
avatar_uids: &[u64],
|
||||||
) -> PlayerOperationResult<(u64, u64)> {
|
) -> PlayerOperationResult<(u64, u64)> {
|
||||||
let back_scene_uid = self.get_default_scene_uid().await;
|
let back_scene_uid = self.get_default_scene_uid();
|
||||||
|
|
||||||
let mut dungeon = self
|
let mut dungeon = self.create_base_dungeon(id, back_scene_uid, world_quest_id);
|
||||||
.create_base_dungeon(id, back_scene_uid, world_quest_id)
|
|
||||||
.await;
|
|
||||||
dungeon.hollow_event_version = 526;
|
dungeon.hollow_event_version = 526;
|
||||||
|
|
||||||
let scene_uid = self.uid_mgr.next();
|
let scene_uid = self.uid_mgr.next();
|
||||||
dungeon.default_scene_uid = scene_uid;
|
dungeon.default_scene_uid = scene_uid;
|
||||||
dungeon.scene_properties_uid = scene_uid;
|
dungeon.scene_properties_uid = scene_uid;
|
||||||
|
|
||||||
self.add_default_hollow_properties(scene_uid).await;
|
self.add_default_hollow_properties(scene_uid);
|
||||||
|
|
||||||
for (index, avatar_uid) in avatar_uids.iter().enumerate() {
|
for (index, avatar_uid) in avatar_uids.iter().enumerate() {
|
||||||
dungeon.avatar_map.insert(
|
dungeon.avatar_map.insert(
|
||||||
|
@ -642,10 +633,10 @@ impl DungeonManager {
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
player
|
player
|
||||||
.scene_properties
|
.scene_properties
|
||||||
.replace(self.scene_properties.read().await.clone());
|
.replace(self.scene_properties.read().clone());
|
||||||
|
|
||||||
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
||||||
|
|
||||||
|
@ -660,7 +651,7 @@ impl DungeonManager {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(scene_uid, scene.clone());
|
.insert(scene_uid, scene.clone());
|
||||||
}
|
}
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let items = player.items.as_mut().unwrap();
|
let items = player.items.as_mut().unwrap();
|
||||||
|
|
||||||
let mut updated_items = Vec::new();
|
let mut updated_items = Vec::new();
|
||||||
|
@ -674,7 +665,7 @@ impl DungeonManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut prop_changes = Vec::new();
|
let mut prop_changes = Vec::new();
|
||||||
for (key, sub_key, value) in &*self.scene_properties.write().await {
|
for (key, sub_key, value) in &*self.scene_properties.write() {
|
||||||
prop_changes.push((*key, *sub_key, *value));
|
prop_changes.push((*key, *sub_key, *value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,8 +696,8 @@ impl DungeonManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_hall(&self, id: i32) -> PlayerOperationResult<u64> {
|
pub fn create_hall(&self, id: i32) -> PlayerOperationResult<u64> {
|
||||||
let mut dungeon = self.create_base_dungeon(id, 0, 0).await;
|
let mut dungeon = self.create_base_dungeon(id, 0, 0);
|
||||||
let dungeon_uid = dungeon.uid;
|
let dungeon_uid = dungeon.uid;
|
||||||
|
|
||||||
let scene_uid = self.uid_mgr.next();
|
let scene_uid = self.uid_mgr.next();
|
||||||
|
@ -726,7 +717,7 @@ impl DungeonManager {
|
||||||
|
|
||||||
dungeon.default_scene_uid = scene_uid;
|
dungeon.default_scene_uid = scene_uid;
|
||||||
|
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
||||||
|
|
||||||
dungeon_collection
|
dungeon_collection
|
||||||
|
@ -762,8 +753,8 @@ impl DungeonManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_fresh(&self) -> PlayerOperationResult<u64> {
|
pub fn create_fresh(&self) -> PlayerOperationResult<u64> {
|
||||||
let mut dungeon = self.create_base_dungeon(2, 0, 0).await;
|
let mut dungeon = self.create_base_dungeon(2, 0, 0);
|
||||||
let dungeon_uid = dungeon.uid;
|
let dungeon_uid = dungeon.uid;
|
||||||
|
|
||||||
let scene_uid = self.uid_mgr.next();
|
let scene_uid = self.uid_mgr.next();
|
||||||
|
@ -783,7 +774,7 @@ impl DungeonManager {
|
||||||
|
|
||||||
dungeon.default_scene_uid = scene_uid;
|
dungeon.default_scene_uid = scene_uid;
|
||||||
|
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
let dungeon_collection = player.dungeon_collection.as_mut().unwrap();
|
||||||
|
|
||||||
dungeon_collection
|
dungeon_collection
|
||||||
|
@ -817,13 +808,13 @@ impl DungeonManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_base_dungeon(
|
fn create_base_dungeon(
|
||||||
&self,
|
&self,
|
||||||
id: i32,
|
id: i32,
|
||||||
back_scene_uid: u64,
|
back_scene_uid: u64,
|
||||||
world_quest_id: i32,
|
world_quest_id: i32,
|
||||||
) -> DungeonInfo {
|
) -> DungeonInfo {
|
||||||
let player = self.player.read().await;
|
let player = self.player.read();
|
||||||
let uid = self.uid_mgr.next();
|
let uid = self.uid_mgr.next();
|
||||||
|
|
||||||
DungeonInfo {
|
DungeonInfo {
|
||||||
|
|
|
@ -3,9 +3,9 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use parking_lot::RwLock;
|
||||||
use protocol::*;
|
use protocol::*;
|
||||||
use qwer::{phashmap, phashset, PropertyHashMap, PropertyHashSet};
|
use qwer::{phashmap, phashset, PropertyHashMap, PropertyHashSet};
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
use crate::data::{self, ConfigAction, ConfigEventType, ConfigValue};
|
use crate::data::{self, ConfigAction, ConfigEventType, ConfigValue};
|
||||||
|
|
||||||
|
@ -24,25 +24,24 @@ impl HollowGridManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_cur_position_in_hollow(&self) -> u16 {
|
pub fn get_cur_position_in_hollow(&self) -> u16 {
|
||||||
self.map.read().await.as_ref().unwrap().start_grid
|
self.map.read().as_ref().unwrap().start_grid
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn move_to(
|
pub fn move_to(
|
||||||
&self,
|
&self,
|
||||||
destination_grid: u16,
|
destination_grid: u16,
|
||||||
scene_uid: u64,
|
scene_uid: u64,
|
||||||
) -> (PtcHollowGridArg, Option<PtcSyncHollowEventInfoArg>) {
|
) -> (PtcHollowGridArg, Option<PtcSyncHollowEventInfoArg>) {
|
||||||
let mut map = self.map.write().await;
|
let mut map = self.map.write();
|
||||||
let map = map.as_mut().unwrap();
|
let map = map.as_mut().unwrap();
|
||||||
|
|
||||||
map.start_grid = destination_grid;
|
map.start_grid = destination_grid;
|
||||||
let grid = map.grids.get_mut(&destination_grid).unwrap();
|
let grid = map.grids.get_mut(&destination_grid).unwrap();
|
||||||
|
|
||||||
self.update_position_to_scene(scene_uid, destination_grid)
|
self.update_position_to_scene(scene_uid, destination_grid);
|
||||||
.await;
|
|
||||||
|
|
||||||
let mut events = self.events.write().await;
|
let mut events = self.events.write();
|
||||||
let sync_event_info =
|
let sync_event_info =
|
||||||
if let Entry::Vacant(entry) = events.entry(u64::from(destination_grid)) {
|
if let Entry::Vacant(entry) = events.entry(u64::from(destination_grid)) {
|
||||||
let event_info = EventInfo {
|
let event_info = EventInfo {
|
||||||
|
@ -83,7 +82,7 @@ impl HollowGridManager {
|
||||||
|
|
||||||
(
|
(
|
||||||
PtcHollowGridArg {
|
PtcHollowGridArg {
|
||||||
player_uid: self.player.read().await.uid.unwrap(),
|
player_uid: self.player.read().uid.unwrap(),
|
||||||
is_partial: true,
|
is_partial: true,
|
||||||
scene_uid,
|
scene_uid,
|
||||||
hollow_level: 1,
|
hollow_level: 1,
|
||||||
|
@ -93,8 +92,8 @@ impl HollowGridManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn battle_finished(&self) -> (PtcSyncHollowEventInfoArg, bool) {
|
pub fn battle_finished(&self) -> (PtcSyncHollowEventInfoArg, bool) {
|
||||||
let map = self.map.read().await;
|
let map = self.map.read();
|
||||||
let map = map.as_ref().unwrap();
|
let map = map.as_ref().unwrap();
|
||||||
let cur_grid = map.grids.get(&map.start_grid).unwrap();
|
let cur_grid = map.grids.get(&map.start_grid).unwrap();
|
||||||
|
|
||||||
|
@ -130,16 +129,16 @@ impl HollowGridManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_cur_event_template_id(&self) -> i32 {
|
pub fn get_cur_event_template_id(&self) -> i32 {
|
||||||
let map = self.map.read().await;
|
let map = self.map.read();
|
||||||
let map = map.as_ref().unwrap();
|
let map = map.as_ref().unwrap();
|
||||||
let cur_grid = map.grids.get(&map.start_grid).unwrap();
|
let cur_grid = map.grids.get(&map.start_grid).unwrap();
|
||||||
|
|
||||||
cur_grid.grid.event_graph_info.hollow_event_template_id
|
cur_grid.grid.event_graph_info.hollow_event_template_id
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_position_to_scene(&self, scene_uid: u64, pos: u16) {
|
fn update_position_to_scene(&self, scene_uid: u64, pos: u16) {
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let scene = player
|
let scene = player
|
||||||
.dungeon_collection
|
.dungeon_collection
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
@ -166,7 +165,7 @@ impl HollowGridManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_event_graph(
|
pub fn run_event_graph(
|
||||||
&self,
|
&self,
|
||||||
event_graph_uid: u64,
|
event_graph_uid: u64,
|
||||||
_event_id: i32,
|
_event_id: i32,
|
||||||
|
@ -178,12 +177,12 @@ impl HollowGridManager {
|
||||||
bool,
|
bool,
|
||||||
) {
|
) {
|
||||||
let (player_uid, scene_uid) = {
|
let (player_uid, scene_uid) = {
|
||||||
let player = self.player.read().await;
|
let player = self.player.read();
|
||||||
|
|
||||||
(player.uid.unwrap(), player.scene_uid.unwrap())
|
(player.uid.unwrap(), player.scene_uid.unwrap())
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut map = self.map.write().await;
|
let mut map = self.map.write();
|
||||||
let map = map.as_mut().unwrap();
|
let map = map.as_mut().unwrap();
|
||||||
|
|
||||||
let mut trigger_battle_id = None;
|
let mut trigger_battle_id = None;
|
||||||
|
@ -316,23 +315,19 @@ impl HollowGridManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn sync_hollow_maps(
|
pub fn sync_hollow_maps(&self, player_uid: u64, scene_uid: u64) -> PtcSyncHollowGridMapsArg {
|
||||||
&self,
|
|
||||||
player_uid: u64,
|
|
||||||
scene_uid: u64,
|
|
||||||
) -> PtcSyncHollowGridMapsArg {
|
|
||||||
PtcSyncHollowGridMapsArg {
|
PtcSyncHollowGridMapsArg {
|
||||||
player_uid,
|
player_uid,
|
||||||
scene_uid,
|
scene_uid,
|
||||||
hollow_level: 1,
|
hollow_level: 1,
|
||||||
main_map: self.map.read().await.clone().unwrap(),
|
main_map: self.map.read().clone().unwrap(),
|
||||||
time_period: TimePeriodType::Random,
|
time_period: TimePeriodType::Random,
|
||||||
weather: WeatherType::Random,
|
weather: WeatherType::Random,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn init_default_map(&self) {
|
pub fn init_default_map(&self) {
|
||||||
*self.map.write().await = Some(HollowGridMapProtocolInfo {
|
*self.map.write() = Some(HollowGridMapProtocolInfo {
|
||||||
row: 5,
|
row: 5,
|
||||||
col: 11,
|
col: 11,
|
||||||
start_grid: 22,
|
start_grid: 22,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
use parking_lot::RwLock;
|
||||||
use protocol::{ItemInfo, PlayerInfo};
|
use protocol::{ItemInfo, PlayerInfo};
|
||||||
use qwer::{phashmap, PropertyHashMap};
|
use qwer::{phashmap, PropertyHashMap};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
use crate::game::{util, PlayerOperationResult};
|
use crate::game::{util, PlayerOperationResult};
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ impl ItemManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn add_resource(&self, currency_id: i32, amount: i32) -> PlayerOperationResult<i32> {
|
pub fn add_resource(&self, currency_id: i32, amount: i32) -> PlayerOperationResult<i32> {
|
||||||
let mut player_info = self.player_info.write().await;
|
let mut player_info = self.player_info.write();
|
||||||
|
|
||||||
for (uid, item) in player_info.items.as_mut().unwrap() {
|
for (uid, item) in player_info.items.as_mut().unwrap() {
|
||||||
if let ItemInfo::Resource { id, count, .. } = item {
|
if let ItemInfo::Resource { id, count, .. } = item {
|
||||||
|
@ -66,7 +66,7 @@ impl ItemManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unlock_avatar(&self, id: i32) -> PlayerOperationResult<u64> {
|
pub fn unlock_avatar(&self, id: i32) -> PlayerOperationResult<u64> {
|
||||||
let uid = self.uid_mgr.next();
|
let uid = self.uid_mgr.next();
|
||||||
|
|
||||||
let avatar = ItemInfo::Avatar {
|
let avatar = ItemInfo::Avatar {
|
||||||
|
@ -86,10 +86,10 @@ impl ItemManager {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Unlock & equip default weapon
|
// Unlock & equip default weapon
|
||||||
let weapon_uid = *self.unlock_weapon(10012).await.unwrap();
|
let weapon_uid = *self.unlock_weapon(10012).unwrap();
|
||||||
self.equip_weapon(weapon_uid, uid).await;
|
self.equip_weapon(weapon_uid, uid);
|
||||||
|
|
||||||
let mut player_info = self.player_info.write().await;
|
let mut player_info = self.player_info.write();
|
||||||
let items = player_info.items.as_mut().unwrap();
|
let items = player_info.items.as_mut().unwrap();
|
||||||
items.insert(uid, avatar.clone());
|
items.insert(uid, avatar.clone());
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ impl ItemManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unlock_weapon(&self, id: i32) -> PlayerOperationResult<u64> {
|
pub fn unlock_weapon(&self, id: i32) -> PlayerOperationResult<u64> {
|
||||||
let mut player_info = self.player_info.write().await;
|
let mut player_info = self.player_info.write();
|
||||||
let items = player_info.items.as_mut().unwrap();
|
let items = player_info.items.as_mut().unwrap();
|
||||||
|
|
||||||
let uid = self.uid_mgr.next();
|
let uid = self.uid_mgr.next();
|
||||||
|
@ -141,12 +141,12 @@ impl ItemManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn equip_weapon(
|
pub fn equip_weapon(
|
||||||
&self,
|
&self,
|
||||||
weapon_uid: u64,
|
weapon_uid: u64,
|
||||||
equip_avatar_uid: u64,
|
equip_avatar_uid: u64,
|
||||||
) -> PlayerOperationResult<bool> {
|
) -> PlayerOperationResult<bool> {
|
||||||
let mut player_info = self.player_info.write().await;
|
let mut player_info = self.player_info.write();
|
||||||
let items = player_info.items.as_mut().unwrap();
|
let items = player_info.items.as_mut().unwrap();
|
||||||
|
|
||||||
let Some(ItemInfo::Weapon { avatar_uid, .. }) = items.get_mut(&weapon_uid) else {
|
let Some(ItemInfo::Weapon { avatar_uid, .. }) = items.get_mut(&weapon_uid) else {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
use parking_lot::RwLock;
|
||||||
use protocol::{AccountInfo, PlayerInfo, PropertyBlob};
|
use protocol::{AccountInfo, PlayerInfo, PropertyBlob};
|
||||||
use qwer::OctData;
|
use qwer::OctData;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
const CLIENT_PROP_FLAG: u16 = 1;
|
const CLIENT_PROP_FLAG: u16 = 1;
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@ pub struct PropertyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PropertyManager {
|
impl PropertyManager {
|
||||||
pub async fn serialize_account_info(&self) -> PropertyBlob {
|
pub fn serialize_account_info(&self) -> PropertyBlob {
|
||||||
Self::serialize_property(&*self.account_info.read().await).unwrap()
|
Self::serialize_property(&*self.account_info.read()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn serialize_player_info(&self) -> PropertyBlob {
|
pub fn serialize_player_info(&self) -> PropertyBlob {
|
||||||
Self::serialize_property(&*self.player_info.read().await).unwrap()
|
Self::serialize_property(&*self.player_info.read()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn serialize_property(prop: &impl OctData) -> Result<PropertyBlob, std::io::Error> {
|
pub fn serialize_property(prop: &impl OctData) -> Result<PropertyBlob, std::io::Error> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use parking_lot::RwLock;
|
||||||
use qwer::PropertyDoubleKeyHashMap;
|
use qwer::PropertyDoubleKeyHashMap;
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
use crate::game::PlayerOperationResult;
|
use crate::game::PlayerOperationResult;
|
||||||
|
|
||||||
|
@ -18,11 +18,10 @@ impl QuestManager {
|
||||||
Self { uid_mgr, player }
|
Self { uid_mgr, player }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn add_world_quest(&self, quest: QuestInfo) -> PlayerOperationResult<u64> {
|
pub fn add_world_quest(&self, quest: QuestInfo) -> PlayerOperationResult<u64> {
|
||||||
let mut world_quest_collection_uid = self
|
let mut world_quest_collection_uid = self
|
||||||
.player
|
.player
|
||||||
.read()
|
.read()
|
||||||
.await
|
|
||||||
.quest_data
|
.quest_data
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -33,7 +32,6 @@ impl QuestManager {
|
||||||
world_quest_collection_uid = self.uid_mgr.next();
|
world_quest_collection_uid = self.uid_mgr.next();
|
||||||
self.player
|
self.player
|
||||||
.write()
|
.write()
|
||||||
.await
|
|
||||||
.quest_data
|
.quest_data
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -42,15 +40,14 @@ impl QuestManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.add_quest_to_collection(world_quest_collection_uid, quest)
|
self.add_quest_to_collection(world_quest_collection_uid, quest)
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn add_quest_to_collection(
|
pub fn add_quest_to_collection(
|
||||||
&self,
|
&self,
|
||||||
collection_uid: u64,
|
collection_uid: u64,
|
||||||
mut quest: QuestInfo,
|
mut quest: QuestInfo,
|
||||||
) -> PlayerOperationResult<u64> {
|
) -> PlayerOperationResult<u64> {
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let quest_data = player.quest_data.as_mut().unwrap();
|
let quest_data = player.quest_data.as_mut().unwrap();
|
||||||
quest.set_collection_uid(collection_uid);
|
quest.set_collection_uid(collection_uid);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
|
use parking_lot::RwLock;
|
||||||
use protocol::*;
|
use protocol::*;
|
||||||
use qwer::{phashmap, PropertyHashMap};
|
use qwer::{phashmap, PropertyHashMap};
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
use crate::data;
|
use crate::data;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ impl SceneUnitManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_npc(
|
pub fn create_npc(
|
||||||
&self,
|
&self,
|
||||||
id: i32,
|
id: i32,
|
||||||
tag: i32,
|
tag: i32,
|
||||||
|
@ -31,7 +31,7 @@ impl SceneUnitManager {
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
let uid = self.uid_mgr.next();
|
let uid = self.uid_mgr.next();
|
||||||
|
|
||||||
self.units.write().await.insert(
|
self.units.write().insert(
|
||||||
uid,
|
uid,
|
||||||
SceneUnitProtocolInfo::NpcProtocolInfo {
|
SceneUnitProtocolInfo::NpcProtocolInfo {
|
||||||
uid,
|
uid,
|
||||||
|
@ -45,11 +45,11 @@ impl SceneUnitManager {
|
||||||
uid
|
uid
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get(&self, uid: u64) -> Option<SceneUnitProtocolInfo> {
|
pub fn get(&self, uid: u64) -> Option<SceneUnitProtocolInfo> {
|
||||||
self.units.read().await.get(&uid).map(|u| u.clone())
|
self.units.read().get(&uid).map(|u| u.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn sync(&self, scene_uid: u64, section_id: i32) -> PtcSyncSceneUnitArg {
|
pub fn sync(&self, scene_uid: u64, section_id: i32) -> PtcSyncSceneUnitArg {
|
||||||
PtcSyncSceneUnitArg {
|
PtcSyncSceneUnitArg {
|
||||||
scene_uid,
|
scene_uid,
|
||||||
section_id,
|
section_id,
|
||||||
|
@ -58,14 +58,13 @@ impl SceneUnitManager {
|
||||||
scene_units: self
|
scene_units: self
|
||||||
.units
|
.units
|
||||||
.read()
|
.read()
|
||||||
.await
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, unit)| unit.clone())
|
.map(|(_, unit)| unit.clone())
|
||||||
.collect(),
|
.collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn add_scene_units(&self, section_id: i32) {
|
pub fn add_scene_units(&self, section_id: i32) {
|
||||||
for o in data::iter_main_city_object_collection().filter(|o| {
|
for o in data::iter_main_city_object_collection().filter(|o| {
|
||||||
o.create_type == 0
|
o.create_type == 0
|
||||||
&& data::is_transform_in_section(&o.create_position, section_id)
|
&& data::is_transform_in_section(&o.create_position, section_id)
|
||||||
|
@ -93,8 +92,7 @@ impl SceneUnitManager {
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use parking_lot::RwLock;
|
||||||
use protocol::*;
|
use protocol::*;
|
||||||
use qwer::PropertyHashSet;
|
use qwer::PropertyHashSet;
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
use crate::game::PlayerOperationResult;
|
use crate::game::PlayerOperationResult;
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ impl UnlockManager {
|
||||||
Self { player }
|
Self { player }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unlock(&self, unlock_id: i32) -> PlayerOperationResult<PtcUnlockArg> {
|
pub fn unlock(&self, unlock_id: i32) -> PlayerOperationResult<PtcUnlockArg> {
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let unlock_info = player.unlock_info.as_mut().unwrap();
|
let unlock_info = player.unlock_info.as_mut().unwrap();
|
||||||
|
|
||||||
unlock_info
|
unlock_info
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use parking_lot::RwLock;
|
||||||
use qwer::{PropertyDoubleKeyHashMap, PropertyHashSet};
|
use qwer::{PropertyDoubleKeyHashMap, PropertyHashSet};
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
use crate::game::PlayerOperationResult;
|
use crate::game::PlayerOperationResult;
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@ impl YorozuyaQuestManager {
|
||||||
Self { player }
|
Self { player }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn add_hollow_quest(
|
pub fn add_hollow_quest(
|
||||||
&self,
|
&self,
|
||||||
yorozuya_collection_id: i32,
|
yorozuya_collection_id: i32,
|
||||||
hollow_quest_type: HollowQuestType,
|
hollow_quest_type: HollowQuestType,
|
||||||
id: i32,
|
id: i32,
|
||||||
) -> PlayerOperationResult<i32> {
|
) -> PlayerOperationResult<i32> {
|
||||||
let mut player = self.player.write().await;
|
let mut player = self.player.write();
|
||||||
let yorozuya = player.yorozuya_info.as_mut().unwrap();
|
let yorozuya = player.yorozuya_info.as_mut().unwrap();
|
||||||
let hollow_quests = yorozuya.hollow_quests.as_mut().unwrap();
|
let hollow_quests = yorozuya.hollow_quests.as_mut().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -13,23 +13,17 @@ pub async fn on_rpc_hollow_move(
|
||||||
tracing::info!("Hollow movement {:?}", &arg);
|
tracing::info!("Hollow movement {:?}", &arg);
|
||||||
|
|
||||||
let destination_pos = *arg.positions.last().unwrap();
|
let destination_pos = *arg.positions.last().unwrap();
|
||||||
let scene_uid = session
|
let scene_uid = session.ns_prop_mgr.player_info.read().scene_uid.unwrap();
|
||||||
.ns_prop_mgr
|
|
||||||
.player_info
|
|
||||||
.read()
|
|
||||||
.await
|
|
||||||
.scene_uid
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let (ptc_hollow_grid, ptc_sync_hollow_event) = session
|
let (ptc_hollow_grid, ptc_sync_hollow_event) = session
|
||||||
.context
|
.context
|
||||||
.hollow_grid_manager
|
.hollow_grid_manager
|
||||||
.move_to(destination_pos, scene_uid)
|
.move_to(destination_pos, scene_uid);
|
||||||
.await;
|
|
||||||
|
|
||||||
session
|
session
|
||||||
.send_rpc_arg(PTC_HOLLOW_GRID_ID, &ptc_hollow_grid)
|
.send_rpc_arg(PTC_HOLLOW_GRID_ID, &ptc_hollow_grid)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if let Some(ptc_sync_hollow_event) = ptc_sync_hollow_event {
|
if let Some(ptc_sync_hollow_event) = ptc_sync_hollow_event {
|
||||||
session
|
session
|
||||||
.send_rpc_arg(PTC_SYNC_HOLLOW_EVENT_INFO_ID, &ptc_sync_hollow_event)
|
.send_rpc_arg(PTC_SYNC_HOLLOW_EVENT_INFO_ID, &ptc_sync_hollow_event)
|
||||||
|
@ -59,7 +53,7 @@ pub async fn on_rpc_end_battle(
|
||||||
tracing::info!("RpcEndBattle: {:?}", &arg);
|
tracing::info!("RpcEndBattle: {:?}", &arg);
|
||||||
|
|
||||||
let player_uid = session.player_uid().raw();
|
let player_uid = session.player_uid().raw();
|
||||||
let (sync_event, hollow_finished) = session.context.hollow_grid_manager.battle_finished().await;
|
let (sync_event, hollow_finished) = session.context.hollow_grid_manager.battle_finished();
|
||||||
|
|
||||||
if !hollow_finished {
|
if !hollow_finished {
|
||||||
session
|
session
|
||||||
|
@ -70,7 +64,6 @@ pub async fn on_rpc_end_battle(
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.hollow_finished()
|
.hollow_finished()
|
||||||
.await
|
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -91,7 +84,6 @@ pub async fn on_rpc_end_battle(
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.leave_battle()
|
.leave_battle()
|
||||||
.await
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?
|
.await?
|
||||||
|
@ -100,14 +92,10 @@ pub async fn on_rpc_end_battle(
|
||||||
session
|
session
|
||||||
.send_rpc_arg(
|
.send_rpc_arg(
|
||||||
PTC_SYNC_HOLLOW_GRID_MAPS_ID,
|
PTC_SYNC_HOLLOW_GRID_MAPS_ID,
|
||||||
&session
|
&session.context.hollow_grid_manager.sync_hollow_maps(
|
||||||
.context
|
player_uid,
|
||||||
.hollow_grid_manager
|
session.context.dungeon_manager.get_cur_scene_uid(),
|
||||||
.sync_hollow_maps(
|
),
|
||||||
player_uid,
|
|
||||||
session.context.dungeon_manager.get_cur_scene_uid().await,
|
|
||||||
)
|
|
||||||
.await,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -117,8 +105,7 @@ pub async fn on_rpc_end_battle(
|
||||||
position: session
|
position: session
|
||||||
.context
|
.context
|
||||||
.hollow_grid_manager
|
.hollow_grid_manager
|
||||||
.get_cur_position_in_hollow()
|
.get_cur_position_in_hollow(),
|
||||||
.await,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
session
|
session
|
||||||
|
@ -136,8 +123,7 @@ pub async fn on_rpc_end_battle(
|
||||||
session
|
session
|
||||||
.context
|
.context
|
||||||
.hollow_grid_manager
|
.hollow_grid_manager
|
||||||
.get_cur_event_template_id()
|
.get_cur_event_template_id(),
|
||||||
.await,
|
|
||||||
HashMap::new(),
|
HashMap::new(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -148,13 +134,7 @@ pub async fn on_rpc_run_hollow_event_graph(
|
||||||
) -> Result<RpcRunHollowEventGraphRet> {
|
) -> Result<RpcRunHollowEventGraphRet> {
|
||||||
tracing::info!("Run hollow event graph {:?}", arg);
|
tracing::info!("Run hollow event graph {:?}", arg);
|
||||||
|
|
||||||
let scene_uid = session
|
let scene_uid = session.ns_prop_mgr.player_info.read().scene_uid.unwrap();
|
||||||
.ns_prop_mgr
|
|
||||||
.player_info
|
|
||||||
.read()
|
|
||||||
.await
|
|
||||||
.scene_uid
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
if arg.event_graph_uid == 3405096459205834 {
|
if arg.event_graph_uid == 3405096459205834 {
|
||||||
// Perform (cutscene)
|
// Perform (cutscene)
|
||||||
|
@ -179,11 +159,8 @@ pub async fn on_rpc_run_hollow_event_graph(
|
||||||
.send_rpc_arg(PTC_SYNC_HOLLOW_EVENT_INFO_ID, &finish_perform)
|
.send_rpc_arg(PTC_SYNC_HOLLOW_EVENT_INFO_ID, &finish_perform)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let (ptc_hollow_grid, ptc_sync_hollow_event) = session
|
let (ptc_hollow_grid, ptc_sync_hollow_event) =
|
||||||
.context
|
session.context.hollow_grid_manager.move_to(22, scene_uid);
|
||||||
.hollow_grid_manager
|
|
||||||
.move_to(22, scene_uid)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
session
|
session
|
||||||
.send_rpc_arg(PTC_HOLLOW_GRID_ID, &ptc_hollow_grid)
|
.send_rpc_arg(PTC_HOLLOW_GRID_ID, &ptc_hollow_grid)
|
||||||
|
@ -197,8 +174,7 @@ pub async fn on_rpc_run_hollow_event_graph(
|
||||||
let (sync_hollow_event, hollow_grid, trigger_battle_id, hollow_finished) = session
|
let (sync_hollow_event, hollow_grid, trigger_battle_id, hollow_finished) = session
|
||||||
.context
|
.context
|
||||||
.hollow_grid_manager
|
.hollow_grid_manager
|
||||||
.run_event_graph(arg.event_graph_uid, arg.event_id, arg.move_path.clone())
|
.run_event_graph(arg.event_graph_uid, arg.event_id, arg.move_path.clone());
|
||||||
.await;
|
|
||||||
|
|
||||||
if !hollow_finished {
|
if !hollow_finished {
|
||||||
session
|
session
|
||||||
|
@ -214,7 +190,6 @@ pub async fn on_rpc_run_hollow_event_graph(
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.hollow_finished()
|
.hollow_finished()
|
||||||
.await
|
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -236,7 +211,6 @@ pub async fn on_rpc_run_hollow_event_graph(
|
||||||
.ns_prop_mgr
|
.ns_prop_mgr
|
||||||
.player_info
|
.player_info
|
||||||
.read()
|
.read()
|
||||||
.await
|
|
||||||
.scene_uid
|
.scene_uid
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -244,7 +218,6 @@ pub async fn on_rpc_run_hollow_event_graph(
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.create_fight(trigger_battle_id, hollow_uid)
|
.create_fight(trigger_battle_id, hollow_uid)
|
||||||
.await
|
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -254,8 +227,7 @@ pub async fn on_rpc_run_hollow_event_graph(
|
||||||
position: session
|
position: session
|
||||||
.context
|
.context
|
||||||
.hollow_grid_manager
|
.hollow_grid_manager
|
||||||
.get_cur_position_in_hollow()
|
.get_cur_position_in_hollow(),
|
||||||
.await,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
session
|
session
|
||||||
|
@ -272,7 +244,6 @@ pub async fn on_rpc_run_hollow_event_graph(
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.enter_battle(battle_scene_uid)
|
.enter_battle(battle_scene_uid)
|
||||||
.await
|
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?,
|
.await?,
|
||||||
)
|
)
|
||||||
|
@ -291,27 +262,29 @@ pub async fn on_rpc_start_hollow_quest(
|
||||||
|
|
||||||
// Set avatar HP properties
|
// Set avatar HP properties
|
||||||
for (_idx, avatar_uid) in &arg.avatar_map {
|
for (_idx, avatar_uid) in &arg.avatar_map {
|
||||||
let player_info = session.ns_prop_mgr.player_info.read().await;
|
let update_properties = {
|
||||||
let items = player_info.items.as_ref().unwrap();
|
let player_info = session.ns_prop_mgr.player_info.read();
|
||||||
let Some(ItemInfo::Avatar { id, .. }) = items
|
let items = player_info.items.as_ref().unwrap();
|
||||||
.iter()
|
let Some(ItemInfo::Avatar { id, .. }) = items
|
||||||
.find(|(uid, _)| **uid == *avatar_uid)
|
.iter()
|
||||||
.map(|(_, item)| item)
|
.find(|(uid, _)| **uid == *avatar_uid)
|
||||||
else {
|
.map(|(_, item)| item)
|
||||||
return Ok(RpcStartHollowQuestRet::error(
|
else {
|
||||||
ErrorCode::ObjectNotExist,
|
return Ok(RpcStartHollowQuestRet::error(
|
||||||
Vec::new(),
|
ErrorCode::ObjectNotExist,
|
||||||
));
|
Vec::new(),
|
||||||
};
|
));
|
||||||
|
};
|
||||||
|
|
||||||
let avatar_config = data::iter_avatar_config_collection()
|
let avatar_config = data::iter_avatar_config_collection()
|
||||||
.find(|c| c.id == *id)
|
.find(|c| c.id == *id)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let update_properties = PtcPropertyChangedArg {
|
PtcPropertyChangedArg {
|
||||||
scene_unit_uid: *avatar_uid,
|
scene_unit_uid: *avatar_uid,
|
||||||
is_partial: true,
|
is_partial: true,
|
||||||
changed_properties: phashmap![(1, avatar_config.hp), (111, avatar_config.hp)],
|
changed_properties: phashmap![(1, avatar_config.hp), (111, avatar_config.hp)],
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
session
|
session
|
||||||
|
@ -329,7 +302,6 @@ pub async fn on_rpc_start_hollow_quest(
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.create_hollow(10001, 10010001, &avatars)
|
.create_hollow(10001, 10010001, &avatars)
|
||||||
.await
|
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -350,20 +322,18 @@ pub async fn on_rpc_start_hollow_quest(
|
||||||
sort_id: 2000,
|
sort_id: 2000,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let ptc_enter_scene = session
|
let ptc_enter_scene = session
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.enter_scene(scene_uid)
|
.enter_scene(scene_uid)?
|
||||||
.await?
|
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?
|
.await?
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
session.context.hollow_grid_manager.init_default_map().await;
|
session.context.hollow_grid_manager.init_default_map();
|
||||||
|
|
||||||
session
|
session
|
||||||
.send_rpc_arg(
|
.send_rpc_arg(
|
||||||
|
@ -371,8 +341,7 @@ pub async fn on_rpc_start_hollow_quest(
|
||||||
&session
|
&session
|
||||||
.context
|
.context
|
||||||
.hollow_grid_manager
|
.hollow_grid_manager
|
||||||
.sync_hollow_maps(session.player_uid().raw(), scene_uid)
|
.sync_hollow_maps(session.player_uid().raw(), scene_uid),
|
||||||
.await,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -382,8 +351,7 @@ pub async fn on_rpc_start_hollow_quest(
|
||||||
position: session
|
position: session
|
||||||
.context
|
.context
|
||||||
.hollow_grid_manager
|
.hollow_grid_manager
|
||||||
.get_cur_position_in_hollow()
|
.get_cur_position_in_hollow(),
|
||||||
.await,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
session
|
session
|
||||||
|
|
|
@ -11,15 +11,12 @@ const DEFAULT_ACCOUNT_ID: u64 = 1;
|
||||||
pub async fn on_rpc_login(session: &NetworkSession, arg: &RpcLoginArg) -> Result<RpcLoginRet> {
|
pub async fn on_rpc_login(session: &NetworkSession, arg: &RpcLoginArg) -> Result<RpcLoginRet> {
|
||||||
tracing::info!("Received rpc login arg: {}", arg.account_name);
|
tracing::info!("Received rpc login arg: {}", arg.account_name);
|
||||||
|
|
||||||
match session
|
match session.logged_in(
|
||||||
.logged_in(
|
AccountUID(DEFAULT_ACCOUNT_ID),
|
||||||
AccountUID(DEFAULT_ACCOUNT_ID),
|
util::create_default_account(DEFAULT_ACCOUNT_ID),
|
||||||
util::create_default_account(DEFAULT_ACCOUNT_ID),
|
) {
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(()) => Ok(RpcLoginRet::new(
|
Ok(()) => Ok(RpcLoginRet::new(
|
||||||
session.ns_prop_mgr.serialize_account_info().await,
|
session.ns_prop_mgr.serialize_account_info(),
|
||||||
)),
|
)),
|
||||||
Err(_) => Ok(RpcLoginRet::error(ErrorCode::RepeatedLogin, Vec::new())),
|
Err(_) => Ok(RpcLoginRet::error(ErrorCode::RepeatedLogin, Vec::new())),
|
||||||
}
|
}
|
||||||
|
@ -34,7 +31,6 @@ pub async fn on_rpc_create_player(
|
||||||
.ns_prop_mgr
|
.ns_prop_mgr
|
||||||
.account_info
|
.account_info
|
||||||
.read()
|
.read()
|
||||||
.await
|
|
||||||
.players
|
.players
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -45,7 +41,6 @@ pub async fn on_rpc_create_player(
|
||||||
.ns_prop_mgr
|
.ns_prop_mgr
|
||||||
.account_info
|
.account_info
|
||||||
.write()
|
.write()
|
||||||
.await
|
|
||||||
.players
|
.players
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -6,17 +6,19 @@ pub async fn on_rpc_mod_nick_name(
|
||||||
) -> Result<RpcModNickNameRet> {
|
) -> Result<RpcModNickNameRet> {
|
||||||
tracing::info!("creating character");
|
tracing::info!("creating character");
|
||||||
|
|
||||||
let mut player = session.ns_prop_mgr.player_info.write().await;
|
let player_info_changed = {
|
||||||
player.nick_name.replace(arg.nick_name.clone());
|
let mut player = session.ns_prop_mgr.player_info.write();
|
||||||
player.avatar_id.replace(arg.avatar_id);
|
player.nick_name.replace(arg.nick_name.clone());
|
||||||
|
player.avatar_id.replace(arg.avatar_id);
|
||||||
|
|
||||||
let player_info_changed = PtcPlayerInfoChangedArg {
|
PtcPlayerInfoChangedArg {
|
||||||
player_uid: player.uid.unwrap(),
|
player_uid: player.uid.unwrap(),
|
||||||
player_info: PlayerInfo {
|
player_info: PlayerInfo {
|
||||||
nick_name: Some(arg.nick_name.clone()),
|
nick_name: Some(arg.nick_name.clone()),
|
||||||
avatar_id: Some(arg.avatar_id),
|
avatar_id: Some(arg.avatar_id),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
session
|
session
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub async fn on_rpc_run_event_graph(
|
||||||
session: &NetworkSession,
|
session: &NetworkSession,
|
||||||
arg: &RpcRunEventGraphArg,
|
arg: &RpcRunEventGraphArg,
|
||||||
) -> Result<RpcRunEventGraphRet> {
|
) -> Result<RpcRunEventGraphRet> {
|
||||||
let unit = session.context.scene_unit_manager.get(arg.owner_uid).await;
|
let unit = session.context.scene_unit_manager.get(arg.owner_uid);
|
||||||
|
|
||||||
let interact_id = match unit {
|
let interact_id = match unit {
|
||||||
Some(SceneUnitProtocolInfo::NpcProtocolInfo { interacts_info, .. })
|
Some(SceneUnitProtocolInfo::NpcProtocolInfo { interacts_info, .. })
|
||||||
|
@ -105,7 +105,7 @@ pub async fn on_rpc_interact_with_unit(
|
||||||
arg.interaction
|
arg.interaction
|
||||||
);
|
);
|
||||||
|
|
||||||
let unit = session.context.scene_unit_manager.get(arg.unit_uid).await;
|
let unit = session.context.scene_unit_manager.get(arg.unit_uid);
|
||||||
|
|
||||||
let interact_id = match unit {
|
let interact_id = match unit {
|
||||||
Some(SceneUnitProtocolInfo::NpcProtocolInfo { interacts_info, .. })
|
Some(SceneUnitProtocolInfo::NpcProtocolInfo { interacts_info, .. })
|
||||||
|
@ -203,11 +203,7 @@ fn create_player(id: u64) -> PlayerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn enter_main_city(session: &NetworkSession) -> Result<()> {
|
pub async fn enter_main_city(session: &NetworkSession) -> Result<()> {
|
||||||
let hall_scene_uid = session
|
let hall_scene_uid = session.context.dungeon_manager.get_default_scene_uid();
|
||||||
.context
|
|
||||||
.dungeon_manager
|
|
||||||
.get_default_scene_uid()
|
|
||||||
.await;
|
|
||||||
|
|
||||||
session
|
session
|
||||||
.send_rpc_arg(
|
.send_rpc_arg(
|
||||||
|
@ -216,7 +212,6 @@ pub async fn enter_main_city(session: &NetworkSession) -> Result<()> {
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.enter_scene_section(hall_scene_uid, 2)
|
.enter_scene_section(hall_scene_uid, 2)
|
||||||
.await
|
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -224,11 +219,7 @@ pub async fn enter_main_city(session: &NetworkSession) -> Result<()> {
|
||||||
session
|
session
|
||||||
.send_rpc_arg(
|
.send_rpc_arg(
|
||||||
PTC_SYNC_SCENE_UNIT_ID,
|
PTC_SYNC_SCENE_UNIT_ID,
|
||||||
&session
|
&session.context.scene_unit_manager.sync(hall_scene_uid, 2),
|
||||||
.context
|
|
||||||
.scene_unit_manager
|
|
||||||
.sync(hall_scene_uid, 2)
|
|
||||||
.await,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -238,8 +229,7 @@ pub async fn enter_main_city(session: &NetworkSession) -> Result<()> {
|
||||||
session
|
session
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.enter_main_city()
|
.enter_main_city()?
|
||||||
.await?
|
|
||||||
.send_changes(session)
|
.send_changes(session)
|
||||||
.await?,
|
.await?,
|
||||||
)
|
)
|
||||||
|
@ -250,81 +240,72 @@ pub async fn on_rpc_enter_world(
|
||||||
session: &NetworkSession,
|
session: &NetworkSession,
|
||||||
_arg: &RpcEnterWorldArg,
|
_arg: &RpcEnterWorldArg,
|
||||||
) -> Result<RpcEnterWorldRet> {
|
) -> Result<RpcEnterWorldRet> {
|
||||||
let account = session.ns_prop_mgr.account_info.read().await;
|
{
|
||||||
|
let account = session.ns_prop_mgr.account_info.read();
|
||||||
|
|
||||||
let player_uid = *account.players.as_ref().unwrap().first().unwrap(); // get first id from list
|
let player_uid = *account.players.as_ref().unwrap().first().unwrap(); // get first id from list
|
||||||
session
|
session.set_cur_player(PlayerUID::from(player_uid), create_player(player_uid))?;
|
||||||
.set_cur_player(PlayerUID::from(player_uid), create_player(player_uid))
|
}
|
||||||
.await?;
|
|
||||||
|
|
||||||
let item_manager = &session.context.item_manager;
|
let item_manager = &session.context.item_manager;
|
||||||
item_manager.add_resource(501, 120).await;
|
item_manager.add_resource(501, 120);
|
||||||
item_manager.add_resource(10, 228).await;
|
item_manager.add_resource(10, 228);
|
||||||
item_manager.add_resource(100, 1337).await;
|
item_manager.add_resource(100, 1337);
|
||||||
|
|
||||||
for avatar_id in data::iter_avatar_config_collection()
|
for avatar_id in data::iter_avatar_config_collection()
|
||||||
.filter(|c| c.camp != 0)
|
.filter(|c| c.camp != 0)
|
||||||
.map(|c| c.id)
|
.map(|c| c.id)
|
||||||
{
|
{
|
||||||
item_manager.unlock_avatar(avatar_id).await;
|
item_manager.unlock_avatar(avatar_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for unlock_id in data::iter_unlock_config_collection().map(|c| c.id) {
|
for unlock_id in data::iter_unlock_config_collection().map(|c| c.id) {
|
||||||
session.context.unlock_manager.unlock(unlock_id).await;
|
session.context.unlock_manager.unlock(unlock_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.context.dungeon_manager.create_hall(1).await;
|
session.context.dungeon_manager.create_hall(1);
|
||||||
session.context.scene_unit_manager.add_scene_units(2).await;
|
session.context.scene_unit_manager.add_scene_units(2);
|
||||||
|
|
||||||
let quest_manager = session.context.quest_manager.clone();
|
let quest_manager = session.context.quest_manager.clone();
|
||||||
quest_manager
|
quest_manager.add_world_quest(QuestInfo::MainCity {
|
||||||
.add_world_quest(QuestInfo::MainCity {
|
id: 10020002,
|
||||||
id: 10020002,
|
finished_count: 0,
|
||||||
finished_count: 0,
|
collection_uid: 0,
|
||||||
collection_uid: 0,
|
progress: 0,
|
||||||
progress: 0,
|
parent_quest_id: 0,
|
||||||
parent_quest_id: 0,
|
state: QuestState::InProgress,
|
||||||
state: QuestState::InProgress,
|
finish_condition_progress: phashmap![],
|
||||||
finish_condition_progress: phashmap![],
|
progress_time: 2111012,
|
||||||
progress_time: 2111012,
|
sort_id: 1000,
|
||||||
sort_id: 1000,
|
bound_npc_and_interact: phashmap![],
|
||||||
bound_npc_and_interact: phashmap![],
|
});
|
||||||
})
|
|
||||||
.await;
|
|
||||||
|
|
||||||
quest_manager
|
quest_manager.add_world_quest(QuestInfo::Hollow {
|
||||||
.add_world_quest(QuestInfo::Hollow {
|
id: 10010002,
|
||||||
id: 10010002,
|
finished_count: 0,
|
||||||
finished_count: 0,
|
collection_uid: 3405096459205774,
|
||||||
collection_uid: 3405096459205774,
|
progress: 0,
|
||||||
progress: 0,
|
parent_quest_id: 0,
|
||||||
parent_quest_id: 0,
|
state: QuestState::Ready,
|
||||||
state: QuestState::Ready,
|
sort_id: 1001,
|
||||||
sort_id: 1001,
|
statistics: phashmap![],
|
||||||
statistics: phashmap![],
|
statistics_ext: pdkhashmap![],
|
||||||
statistics_ext: pdkhashmap![],
|
acquired_hollow_challenge_reward: 0,
|
||||||
acquired_hollow_challenge_reward: 0,
|
progress_time: 0,
|
||||||
progress_time: 0,
|
finish_condition_progress: phashmap![],
|
||||||
finish_condition_progress: phashmap![],
|
dungeon_uid: 0,
|
||||||
dungeon_uid: 0,
|
});
|
||||||
})
|
|
||||||
.await;
|
|
||||||
|
|
||||||
session
|
session.context.yorozuya_quest_manager.add_hollow_quest(
|
||||||
.context
|
102,
|
||||||
.yorozuya_quest_manager
|
HollowQuestType::SideQuest,
|
||||||
.add_hollow_quest(102, HollowQuestType::SideQuest, 10010002)
|
10010002,
|
||||||
.await;
|
);
|
||||||
|
|
||||||
if CONFIGURATION.skip_tutorial {
|
if CONFIGURATION.skip_tutorial {
|
||||||
Box::pin(enter_main_city(session)).await?;
|
Box::pin(enter_main_city(session)).await?;
|
||||||
} else {
|
} else {
|
||||||
let fresh_scene_uid = *session
|
let fresh_scene_uid = *session.context.dungeon_manager.create_fresh().unwrap();
|
||||||
.context
|
|
||||||
.dungeon_manager
|
|
||||||
.create_fresh()
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
session
|
session
|
||||||
.send_rpc_arg(
|
.send_rpc_arg(
|
||||||
PTC_ENTER_SCENE_ID,
|
PTC_ENTER_SCENE_ID,
|
||||||
|
@ -332,7 +313,6 @@ pub async fn on_rpc_enter_world(
|
||||||
.context
|
.context
|
||||||
.dungeon_manager
|
.dungeon_manager
|
||||||
.enter_scene(fresh_scene_uid)
|
.enter_scene(fresh_scene_uid)
|
||||||
.await
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
|
@ -350,7 +330,7 @@ pub async fn on_rpc_enter_world(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(RpcEnterWorldRet::new(
|
Ok(RpcEnterWorldRet::new(
|
||||||
session.ns_prop_mgr.serialize_player_info().await,
|
session.ns_prop_mgr.serialize_player_info(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,16 +60,16 @@ impl NetworkSession {
|
||||||
self.client_socket.lock().await
|
self.client_socket.lock().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn logged_in(&self, uid: AccountUID, account: AccountInfo) -> Result<()> {
|
pub fn logged_in(&self, uid: AccountUID, account: AccountInfo) -> Result<()> {
|
||||||
self.account_uid.set(uid)?;
|
self.account_uid.set(uid)?;
|
||||||
*self.ns_prop_mgr.account_info.write().await = account;
|
*self.ns_prop_mgr.account_info.write() = account;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_cur_player(&self, uid: PlayerUID, player: PlayerInfo) -> Result<()> {
|
pub fn set_cur_player(&self, uid: PlayerUID, player: PlayerInfo) -> Result<()> {
|
||||||
self.player_uid.set(uid)?;
|
self.player_uid.set(uid)?;
|
||||||
*self.ns_prop_mgr.player_info.write().await = player;
|
*self.ns_prop_mgr.player_info.write() = player;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue