aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorWeicao Mao <1992414357@qq.com>2025-06-16 05:00:08 +0800
committerGitHub <noreply@github.com>2025-06-16 05:00:08 +0800
commitf5072499d9241b22e7a259267cc0315841b7589d (patch)
treeda0ef21a88131b6e495bf6ec0dc03092e2815a76 /core/src
parentbb7a31c753df0a7663cdcc89aff840384b16564e (diff)
parentb44b687c3c90642bbe609593b301cd248745dfc6 (diff)
Merge pull request #5 from CatilGrass/c_bindings
Add CBindings of GameData, GameRuntime
Diffstat (limited to 'core/src')
-rw-r--r--core/src/data/game/game_cli.rs4
-rw-r--r--core/src/data/game/game_data.rs4
-rw-r--r--core/src/data/game/game_runtime.rs2
-rw-r--r--core/src/data/player/player_data.rs11
4 files changed, 16 insertions, 5 deletions
diff --git a/core/src/data/game/game_cli.rs b/core/src/data/game/game_cli.rs
index 521de3f..fd71556 100644
--- a/core/src/data/game/game_cli.rs
+++ b/core/src/data/game/game_cli.rs
@@ -172,7 +172,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) -> bool
Commands::Pop => {
entry_mutex!(runtime, |guard| {
- if let Some((account, message)) = guard.pop_event() {
+ if let Some((account, message)) = guard.pop_control_event() {
info!("{}: {:?}", account.id, message);
} else {
info!("None")
@@ -182,7 +182,7 @@ pub fn process_game_cli(runtime: Arc<Mutex<GameRuntime>>, cmd: GameCli) -> bool
Commands::PopAll => {
entry_mutex!(runtime, |guard| {
- while let Some((account, message)) = guard.pop_event() {
+ while let Some((account, message)) = guard.pop_control_event() {
info!("{}: {:?}", account.id, message);
}
});
diff --git a/core/src/data/game/game_data.rs b/core/src/data/game/game_data.rs
index 3bdf28b..35a5c0e 100644
--- a/core/src/data/game/game_data.rs
+++ b/core/src/data/game/game_data.rs
@@ -71,8 +71,8 @@ impl GameData {
}
/// Read game runtime archive data
- pub fn load_data(&mut self, storage: GameRuntimeDataArchive) -> &mut GameData {
- self.archive = storage;
+ pub fn load_data(&mut self, archive: GameRuntimeDataArchive) -> &mut GameData {
+ self.archive = archive;
self
}
diff --git a/core/src/data/game/game_runtime.rs b/core/src/data/game/game_runtime.rs
index 1c5a548..7ce1991 100644
--- a/core/src/data/game/game_runtime.rs
+++ b/core/src/data/game/game_runtime.rs
@@ -154,7 +154,7 @@ impl GameRuntime {
}
/// Pop an event message
- pub fn pop_event(&mut self) -> Option<(Account, ControlMessage)> {
+ pub fn pop_control_event(&mut self) -> Option<(Account, ControlMessage)> {
let pop = self.control.events.pop_front();
if pop.is_some() {
let (account, msg) = pop.unwrap();
diff --git a/core/src/data/player/player_data.rs b/core/src/data/player/player_data.rs
index 1fe5ff0..9b1ab71 100644
--- a/core/src/data/player/player_data.rs
+++ b/core/src/data/player/player_data.rs
@@ -65,6 +65,17 @@ impl Player {
player
}
+ pub fn register_from_hash(hash: String) -> Player {
+ let mut player = Player {
+ customize: None,
+ account: Account::default()
+ };
+
+ player.account.id = "$only_hash$".to_string();
+ player.account.player_hash = hash;
+ player
+ }
+
pub fn check(&self, password: String) -> bool {
let hash = Self::gen_hash(self.account.id.clone(), password);
hash == self.account.player_hash