mirror of
https://github.com/redstrate/Kawari.git
synced 2025-05-19 17:27:45 +00:00
Add GM rank to database, default to normal user and set online status
Instead of everyone starting out as a GM, they are a normal user by default. Right now the only way to set GM rank is through editing the database. The online status is set accordingly.
This commit is contained in:
parent
a88b9037d4
commit
b21d9933b3
4 changed files with 41 additions and 11 deletions
|
@ -336,6 +336,12 @@ async fn client_loop(
|
||||||
connection.send_inventory(false).await;
|
connection.send_inventory(false).await;
|
||||||
connection.send_stats(&chara_details).await;
|
connection.send_stats(&chara_details).await;
|
||||||
|
|
||||||
|
let online_status = if connection.player_data.gm_rank == GameMasterRank::NormalUser {
|
||||||
|
OnlineStatus::Online
|
||||||
|
} else {
|
||||||
|
OnlineStatus::GameMasterBlue
|
||||||
|
};
|
||||||
|
|
||||||
// send player spawn
|
// send player spawn
|
||||||
{
|
{
|
||||||
let ipc = ServerZoneIpcSegment {
|
let ipc = ServerZoneIpcSegment {
|
||||||
|
@ -346,8 +352,8 @@ async fn client_loop(
|
||||||
content_id: connection.player_data.content_id,
|
content_id: connection.player_data.content_id,
|
||||||
current_world_id: config.world.world_id,
|
current_world_id: config.world.world_id,
|
||||||
home_world_id: config.world.world_id,
|
home_world_id: config.world.world_id,
|
||||||
gm_rank: GameMasterRank::Debug,
|
gm_rank: connection.player_data.gm_rank,
|
||||||
online_status: OnlineStatus::GameMasterBlue,
|
online_status,
|
||||||
common: common.clone(),
|
common: common.clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub enum OnlineStatus {
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[brw(little)]
|
#[brw(little)]
|
||||||
#[brw(repr = u8)]
|
#[brw(repr = u8)]
|
||||||
#[derive(Debug, Clone, Default, PartialEq)]
|
#[derive(Debug, Clone, Copy, Default, PartialEq)]
|
||||||
pub enum GameMasterRank {
|
pub enum GameMasterRank {
|
||||||
#[default]
|
#[default]
|
||||||
NormalUser,
|
NormalUser,
|
||||||
|
@ -116,6 +116,23 @@ pub enum GameMasterRank {
|
||||||
Debug = 90,
|
Debug = 90,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TryFrom<u8> for GameMasterRank {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||||
|
match value {
|
||||||
|
0 => Ok(Self::NormalUser),
|
||||||
|
1 => Ok(Self::GameMaster),
|
||||||
|
3 => Ok(Self::EventJunior),
|
||||||
|
4 => Ok(Self::EventSenior),
|
||||||
|
5 => Ok(Self::Support),
|
||||||
|
7 => Ok(Self::Senior),
|
||||||
|
90 => Ok(Self::Debug),
|
||||||
|
_ => Err(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct DisplayFlag(u32);
|
pub struct DisplayFlag(u32);
|
||||||
|
|
|
@ -15,9 +15,9 @@ use crate::{
|
||||||
chat::ServerChatIpcSegment,
|
chat::ServerChatIpcSegment,
|
||||||
zone::{
|
zone::{
|
||||||
ActorControl, ActorControlSelf, ActorControlTarget, ClientZoneIpcSegment, CommonSpawn,
|
ActorControl, ActorControlSelf, ActorControlTarget, ClientZoneIpcSegment, CommonSpawn,
|
||||||
ContainerInfo, DisplayFlag, Equip, InitZone, ItemInfo, Move, NpcSpawn, ObjectKind,
|
ContainerInfo, DisplayFlag, Equip, GameMasterRank, InitZone, ItemInfo, Move, NpcSpawn,
|
||||||
PlayerStats, PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect,
|
ObjectKind, PlayerStats, PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment,
|
||||||
StatusEffectList, UpdateClassInfo, Warp, WeatherChange,
|
StatusEffect, StatusEffectList, UpdateClassInfo, Warp, WeatherChange,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
opcodes::ServerZoneIpcType,
|
opcodes::ServerZoneIpcType,
|
||||||
|
@ -60,6 +60,7 @@ pub struct PlayerData {
|
||||||
pub inventory: Inventory,
|
pub inventory: Inventory,
|
||||||
|
|
||||||
pub teleport_query: TeleportQuery,
|
pub teleport_query: TeleportQuery,
|
||||||
|
pub gm_rank: GameMasterRank,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a single connection between an instance of the client and the world server
|
/// Represents a single connection between an instance of the client and the world server
|
||||||
|
|
|
@ -9,7 +9,10 @@ use crate::{
|
||||||
workdefinitions::{CharaMake, ClientSelectData, RemakeMode},
|
workdefinitions::{CharaMake, ClientSelectData, RemakeMode},
|
||||||
},
|
},
|
||||||
inventory::Inventory,
|
inventory::Inventory,
|
||||||
ipc::lobby::{CharacterDetails, CharacterFlag},
|
ipc::{
|
||||||
|
lobby::{CharacterDetails, CharacterFlag},
|
||||||
|
zone::GameMasterRank,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PlayerData;
|
use super::PlayerData;
|
||||||
|
@ -44,7 +47,7 @@ impl WorldDatabase {
|
||||||
|
|
||||||
// Create characters data table
|
// Create characters data table
|
||||||
{
|
{
|
||||||
let query = "CREATE TABLE IF NOT EXISTS character_data (content_id INTEGER PRIMARY KEY, name STRING, chara_make STRING, city_state INTEGER, zone_id INTEGER, pos_x REAL, pos_y REAL, pos_z REAL, rotation REAL, inventory STRING, remake_mode INTEGER);";
|
let query = "CREATE TABLE IF NOT EXISTS character_data (content_id INTEGER PRIMARY KEY, name STRING, chara_make STRING, city_state INTEGER, zone_id INTEGER, pos_x REAL, pos_y REAL, pos_z REAL, rotation REAL, inventory STRING, remake_mode INTEGER, gm_rank INTEGER);";
|
||||||
connection.execute(query, ()).unwrap();
|
connection.execute(query, ()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,15 +142,16 @@ impl WorldDatabase {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
stmt = connection
|
stmt = connection
|
||||||
.prepare("SELECT pos_x, pos_y, pos_z, rotation, zone_id, inventory FROM character_data WHERE content_id = ?1")
|
.prepare("SELECT pos_x, pos_y, pos_z, rotation, zone_id, inventory, gm_rank FROM character_data WHERE content_id = ?1")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let (pos_x, pos_y, pos_z, rotation, zone_id, inventory_json): (
|
let (pos_x, pos_y, pos_z, rotation, zone_id, inventory_json, gm_rank): (
|
||||||
f32,
|
f32,
|
||||||
f32,
|
f32,
|
||||||
f32,
|
f32,
|
||||||
f32,
|
f32,
|
||||||
u16,
|
u16,
|
||||||
String,
|
String,
|
||||||
|
u8,
|
||||||
) = stmt
|
) = stmt
|
||||||
.query_row((content_id,), |row| {
|
.query_row((content_id,), |row| {
|
||||||
Ok((
|
Ok((
|
||||||
|
@ -157,6 +161,7 @@ impl WorldDatabase {
|
||||||
row.get(3)?,
|
row.get(3)?,
|
||||||
row.get(4)?,
|
row.get(4)?,
|
||||||
row.get(5)?,
|
row.get(5)?,
|
||||||
|
row.get(6)?,
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -175,6 +180,7 @@ impl WorldDatabase {
|
||||||
rotation,
|
rotation,
|
||||||
zone_id,
|
zone_id,
|
||||||
inventory,
|
inventory,
|
||||||
|
gm_rank: GameMasterRank::try_from(gm_rank).unwrap(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,7 +350,7 @@ impl WorldDatabase {
|
||||||
// insert char data
|
// insert char data
|
||||||
connection
|
connection
|
||||||
.execute(
|
.execute(
|
||||||
"INSERT INTO character_data VALUES (?1, ?2, ?3, ?4, ?5, 0.0, 0.0, 0.0, 0.0, ?6, 0);",
|
"INSERT INTO character_data VALUES (?1, ?2, ?3, ?4, ?5, 0.0, 0.0, 0.0, 0.0, ?6, 0, 0);",
|
||||||
(
|
(
|
||||||
content_id,
|
content_id,
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Add table
Reference in a new issue