2020-08-23 17:14:54 +00:00
|
|
|
#pragma once
|
2020-08-18 20:42:30 +00:00
|
|
|
|
|
|
|
#include "Player.hpp"
|
2021-03-17 19:07:40 +00:00
|
|
|
#include "core/Core.hpp"
|
|
|
|
#include "servers/CNShardServer.hpp"
|
2021-03-16 22:29:13 +00:00
|
|
|
#include "Chunking.hpp"
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-09-17 22:45:43 +00:00
|
|
|
#include <utility>
|
2020-08-18 20:42:30 +00:00
|
|
|
#include <map>
|
|
|
|
#include <list>
|
|
|
|
|
2020-08-25 01:34:53 +00:00
|
|
|
struct WarpLocation;
|
|
|
|
|
2020-08-18 20:42:30 +00:00
|
|
|
namespace PlayerManager {
|
2020-11-17 23:16:16 +00:00
|
|
|
extern std::map<CNSocket*, Player*> players;
|
2020-08-18 20:42:30 +00:00
|
|
|
void init();
|
|
|
|
|
|
|
|
void removePlayer(CNSocket* key);
|
|
|
|
|
2020-11-18 00:07:04 +00:00
|
|
|
void updatePlayerPosition(CNSocket* sock, int X, int Y, int Z, uint64_t I, int angle);
|
2020-09-17 22:45:43 +00:00
|
|
|
|
2020-10-12 16:55:41 +00:00
|
|
|
void sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I);
|
2020-10-03 15:21:36 +00:00
|
|
|
void sendPlayerTo(CNSocket* sock, int X, int Y, int Z);
|
|
|
|
|
2020-08-25 01:34:53 +00:00
|
|
|
Player *getPlayer(CNSocket* key);
|
2020-10-31 20:31:25 +00:00
|
|
|
std::string getPlayerName(Player *plr, bool id=true);
|
2020-09-01 22:37:09 +00:00
|
|
|
|
|
|
|
bool isAccountInUse(int accountId);
|
|
|
|
void exitDuplicate(int accountId);
|
2020-10-04 23:54:08 +00:00
|
|
|
Player *getPlayerFromID(int32_t iID);
|
|
|
|
CNSocket *getSockFromID(int32_t iID);
|
2020-12-31 01:13:43 +00:00
|
|
|
CNSocket *getSockFromName(std::string firstname, std::string lastname);
|
|
|
|
CNSocket *getSockFromAny(int by, int id, int uid, std::string firstname, std::string lastname);
|
2021-03-19 21:28:25 +00:00
|
|
|
|
|
|
|
void sendToViewable(CNSocket *sock, void* buf, uint32_t type, size_t size);
|
|
|
|
|
|
|
|
// TODO: unify this under the new Entity system
|
|
|
|
template<class T>
|
|
|
|
void sendToViewable(CNSocket *sock, T& pkt, uint32_t type) {
|
|
|
|
Player* plr = getPlayer(sock);
|
|
|
|
for (auto it = plr->viewableChunks->begin(); it != plr->viewableChunks->end(); it++) {
|
|
|
|
Chunk* chunk = *it;
|
|
|
|
for (CNSocket* otherSock : chunk->players) {
|
|
|
|
if (otherSock == sock)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
otherSock->sendPacket(pkt, type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 20:42:30 +00:00
|
|
|
}
|