#[repr(C)]pub struct PlayerInfo {
pub header: Header,
pub slot: u32,
pub entity: Entity,
pub key: PlayerKey,
pub permissions: u8,
pub name_len: u8,
pub name: [u8; 64],
}Expand description
A connected player, from HostApi::player or HostApi::players.
Unlike other structs with a Header, its layout is frozen and it never
grows: ActionCall and RenameCall carry it before fields of their
own, and HostApi::players writes an array of it with no entry size.
Player data a later minor adds goes into a new struct. The caller still
starts each one it passes with Header::of.
§Examples
use enshwick::abi::{Header, PlayerInfo};
let mut name = [0u8; 64];
name[..3].copy_from_slice(b"Ann");
let player = PlayerInfo {
header: Header::of::<PlayerInfo>(),
slot: 0,
entity: enshwick::Entity(2),
key: enshwick::PlayerKey::new(7),
permissions: PlayerInfo::CAN_ACCESS_INVENTORIES,
name_len: 3,
name,
};
assert_eq!(&player.name[..usize::from(player.name_len)], b"Ann");Fields§
§header: HeaderSize and version of this struct.
slot: u32The server’s player slot.
entity: EntityThe player character’s entity.
key: PlayerKeyThe same number for the same account in every session.
permissions: u8The server’s permission bits for the player: 1 kick and ban, 2 open inventories, 4 edit the base, 8 edit the world, 16 extend the base, 32 receive experience.
name_len: u8Bytes of name in use.
name: [u8; 64]The name the client sent, UTF-8 as sent, cut at 64 bytes.
Implementations§
Source§impl PlayerInfo
impl PlayerInfo
Sourcepub const CAN_KICK_BAN: u8 = 1
pub const CAN_KICK_BAN: u8 = 1
May kick and ban; the server’s administrators.
Sourcepub const CAN_ACCESS_INVENTORIES: u8
pub const CAN_ACCESS_INVENTORIES: u8
May open chests and other inventories.
Sourcepub const CAN_EDIT_BASE: u8
pub const CAN_EDIT_BASE: u8
May build in bases.
Sourcepub const CAN_EDIT_WORLD: u8
pub const CAN_EDIT_WORLD: u8
May change the world outside bases.
Sourcepub const CAN_EXTEND_BASE: u8
pub const CAN_EXTEND_BASE: u8
May extend bases.
Sourcepub const CAN_RECEIVE_EXP: u8
pub const CAN_RECEIVE_EXP: u8
Receives experience.