#ifndef SERVER_HEADER
#define SERVER_HEADER
-#include "connection.h"
+#include "network/connection.h"
#include "irr_v3d.h"
#include "map.h"
#include "hud.h"
#include "util/thread.h"
#include "environment.h"
#include "clientiface.h"
+#include "network/networkpacket.h"
#include <string>
#include <list>
#include <map>
void AsyncRunStep(bool initial_step=false);
void Receive();
PlayerSAO* StageTwoClientInit(u16 peer_id);
+
+ /*
+ * Command Handlers
+ */
+
+ void handleCommand(NetworkPacket* pkt);
+
+ void handleCommand_Null(NetworkPacket* pkt) {};
+ void handleCommand_Deprecated(NetworkPacket* pkt);
+ void handleCommand_Init(NetworkPacket* pkt);
+ void handleCommand_Init2(NetworkPacket* pkt);
+ void handleCommand_RequestMedia(NetworkPacket* pkt);
+ void handleCommand_ReceivedMedia(NetworkPacket* pkt);
+ void handleCommand_ClientReady(NetworkPacket* pkt);
+ void handleCommand_GotBlocks(NetworkPacket* pkt);
+ void handleCommand_PlayerPos(NetworkPacket* pkt);
+ void handleCommand_DeletedBlocks(NetworkPacket* pkt);
+ void handleCommand_InventoryAction(NetworkPacket* pkt);
+ void handleCommand_ChatMessage(NetworkPacket* pkt);
+ void handleCommand_Damage(NetworkPacket* pkt);
+ void handleCommand_Breath(NetworkPacket* pkt);
+ void handleCommand_Password(NetworkPacket* pkt);
+ void handleCommand_PlayerItem(NetworkPacket* pkt);
+ void handleCommand_Respawn(NetworkPacket* pkt);
+ void handleCommand_Interact(NetworkPacket* pkt);
+ void handleCommand_RemovedSounds(NetworkPacket* pkt);
+ void handleCommand_NodeMetaFields(NetworkPacket* pkt);
+ void handleCommand_InventoryFields(NetworkPacket* pkt);
+
void ProcessData(u8 *data, u32 datasize, u16 peer_id);
+ void Send(NetworkPacket* pkt);
+
// Environment must be locked when called
void setTimeOfDay(u32 time);
IWritableCraftDefManager* getWritableCraftDefManager();
const ModSpec* getModSpec(const std::string &modname);
- void getModNames(std::list<std::string> &modlist);
+ void getModNames(std::vector<std::string> &modlist);
std::string getBuiltinLuaPath();
inline std::string getWorldPath()
{ return m_path_world; }
bool showFormspec(const char *name, const std::string &formspec, const std::string &formname);
Map & getMap() { return m_env->getMap(); }
ServerEnvironment & getEnv() { return *m_env; }
-
+
u32 hudAdd(Player *player, HudElement *element);
bool hudRemove(Player *player, u32 id);
bool hudChange(Player *player, u32 id, HudElementStat stat, void *value);
inline Address getPeerAddress(u16 peer_id)
{ return m_con.GetPeerAddress(peer_id); }
-
+
bool setLocalPlayerAnimations(Player *player, v2s32 animation_frames[4], f32 frame_speed);
bool setPlayerEyeOffset(Player *player, v3f first, v3f third);
bool setSky(Player *player, const video::SColor &bgcolor,
const std::string &type, const std::vector<std::string> ¶ms);
-
+
bool overrideDayNightRatio(Player *player, bool do_override,
float brightness);
u8* ser_vers, u16* prot_vers, u8* major, u8* minor, u8* patch,
std::string* vers_string);
+ void SendPlayerHPOrDie(u16 peer_id, bool die) { die ? DiePlayer(peer_id) : SendPlayerHP(peer_id); }
+ void SendPlayerBreath(u16 peer_id);
+ void SendInventory(PlayerSAO* playerSAO);
+ void SendMovePlayer(u16 peer_id);
+
+ // Bind address
+ Address m_bind_addr;
+
private:
friend class EmergeThread;
/* mark blocks not sent for all clients */
void SetBlocksNotSent(std::map<v3s16, MapBlock *>& block);
- // Envlock and conlock should be locked when calling these
- void SendInventory(u16 peer_id);
+
void SendChatMessage(u16 peer_id, const std::wstring &message);
void SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed);
void SendPlayerHP(u16 peer_id);
- void SendPlayerBreath(u16 peer_id);
- void SendMovePlayer(u16 peer_id);
+
void SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed);
void SendEyeOffset(u16 peer_id, v3f first, v3f third);
void SendPlayerPrivileges(u16 peer_id);
void SendSetSky(u16 peer_id, const video::SColor &bgcolor,
const std::string &type, const std::vector<std::string> ¶ms);
void SendOverrideDayNightRatio(u16 peer_id, bool do_override, float ratio);
-
+
/*
Send a node removal/addition event to all clients except ignore_id.
Additionally, if far_players!=NULL, players further away than
*/
// Envlock and conlock should be locked when calling these
void sendRemoveNode(v3s16 p, u16 ignore_id=0,
- std::list<u16> *far_players=NULL, float far_d_nodes=100);
+ std::vector<u16> *far_players=NULL, float far_d_nodes=100);
void sendAddNode(v3s16 p, MapNode n, u16 ignore_id=0,
- std::list<u16> *far_players=NULL, float far_d_nodes=100,
+ std::vector<u16> *far_players=NULL, float far_d_nodes=100,
bool remove_metadata=true);
void setBlockNotSent(v3s16 p);
void fillMediaCache();
void sendMediaAnnouncement(u16 peer_id);
void sendRequestedMedia(u16 peer_id,
- const std::list<std::string> &tosend);
+ const std::vector<std::string> &tosend);
void sendDetachedInventory(const std::string &name, u16 peer_id);
void sendDetachedInventories(u16 peer_id);
void DiePlayer(u16 peer_id);
void RespawnPlayer(u16 peer_id);
void DeleteClient(u16 peer_id, ClientDeletionReason reason);
- void UpdateCrafting(u16 peer_id);
+ void UpdateCrafting(Player *player);
// When called, connection mutex should be locked
RemoteClient* getClient(u16 peer_id,ClientState state_min=CS_Active);
Queues stuff from peerAdded() and deletingPeer() to
handlePeerChanges()
*/
- Queue<con::PeerChange> m_peer_change_queue;
+ std::queue<con::PeerChange> m_peer_change_queue;
/*
Random stuff
*/
- // Mod parent directory paths
- std::list<std::string> m_modspaths;
-
bool m_shutdown_requested;
/*
Queue of map edits from the environment for sending to the clients
This is behind m_env_mutex
*/
- Queue<MapEditEvent*> m_unsent_map_edit_queue;
+ std::queue<MapEditEvent*> m_unsent_map_edit_queue;
/*
Set to true when the server itself is modifying the map and does
all sending of information by itself.