[ServerPlayer] 'isOnline' added.
This commit is contained in:
parent
0cdb08060a
commit
616ad0c50a
@ -123,6 +123,7 @@
|
||||
|
||||
- `const ClientInfo &client()`
|
||||
- `ItemStack held_item_stack()`
|
||||
- `bool is_online()`
|
||||
|
||||
## ServerWorld
|
||||
|
||||
|
@ -32,9 +32,9 @@
|
||||
#include "ServerPlayer.hpp"
|
||||
|
||||
class PlayerList {
|
||||
using Container = std::unordered_map<u16, ServerPlayer>;
|
||||
using Iterator = Container::iterator;
|
||||
using ConstIterator = Container::const_iterator;
|
||||
using PlayerMap = std::unordered_map<u16, ServerPlayer>;
|
||||
using Iterator = PlayerMap::iterator;
|
||||
using ConstIterator = PlayerMap::const_iterator;
|
||||
|
||||
public:
|
||||
ServerPlayer &addPlayer(ClientInfo &client);
|
||||
@ -50,7 +50,7 @@ class PlayerList {
|
||||
ConstIterator end() const { return m_players.end(); }
|
||||
|
||||
private:
|
||||
Container m_players;
|
||||
PlayerMap m_players;
|
||||
};
|
||||
|
||||
#endif // PLAYERLIST_HPP_
|
||||
|
@ -115,12 +115,12 @@ bool ServerApplication::init() {
|
||||
|
||||
gkInfo() << ("Server is running on localhost:" + std::to_string(m_server.port())).c_str();
|
||||
|
||||
if (m_eventHandler)
|
||||
m_eventHandler->emplaceEvent<ServerOnlineEvent>(true, m_server.port());
|
||||
|
||||
if (!m_worldName.empty())
|
||||
m_worldController.load(m_worldName);
|
||||
|
||||
if (m_eventHandler)
|
||||
m_eventHandler->emplaceEvent<ServerOnlineEvent>(true, m_server.port());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,8 @@ void ServerPlayer::initUsertype(sol::state &lua) {
|
||||
lua.new_usertype<ServerPlayer>("ServerPlayer",
|
||||
sol::base_classes, sol::bases<Player>(),
|
||||
"client", &ServerPlayer::client,
|
||||
"held_item_stack", &ServerPlayer::heldItemStack
|
||||
"held_item_stack", &ServerPlayer::heldItemStack,
|
||||
"is_online", &ServerPlayer::isOnline
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,17 @@ class ServerPlayer : public Player {
|
||||
const ItemStack &heldItemStack() { return m_inventory.getStack(m_heldItemSlot, 0); }
|
||||
void setHeldItemSlot(u8 heldItemSlot) { m_heldItemSlot = heldItemSlot; }
|
||||
|
||||
bool isOnline() const { return m_isOnline; }
|
||||
void setOnline(bool isOnline) { m_isOnline = isOnline; }
|
||||
|
||||
static void initUsertype(sol::state &lua);
|
||||
|
||||
private:
|
||||
ClientInfo &m_client;
|
||||
|
||||
u8 m_heldItemSlot = 0;
|
||||
|
||||
bool m_isOnline = false;
|
||||
};
|
||||
|
||||
#endif // SERVERPLAYER_HPP_
|
||||
|
Loading…
x
Reference in New Issue
Block a user