65 for (
unsigned int i = 0; i <
m_clients.size(); i++) {
75 for (
unsigned int i = 0; i <
m_clients.size(); i++) {
90 bool collision =
false;
91 for (
unsigned int i = 0; i <
m_clients.size(); i++) {
92 if (
m_clients[i]->user.colournum == col) {
124 for (
int i = 2; i < 99; i++) {
125 nick = new_nick_base + std::to_string(i);
147#ifdef WITH_ANGELSCRIPT
165 if (client ==
nullptr) {
167 "ServerScriptSequencer::QueueClientForDisconnect() Internal error, got non-existent user ID: %d", uid);
177 const char *data = cmd.c_str();
178 int size = cmd.size();
193 msg = std::string(
"SERVER: ") + msg;
198 msg = std::string(
"Host(general): ") + msg;
200 msg = std::string(
"Host(private): ") + msg;
205 msg = std::string(
"Rules: ") + msg;
209 msg = std::string(
"MOTD: ") + msg;
216 for (; itor != endi; ++itor) {
226 if (kicked_client ==
nullptr) {
240 if (client ==
nullptr) {
275 client->
streams[streamid] = *reg;
288 if (client ==
nullptr) {
295 if (client->
streams.erase(streamid) > 0) {
305 if (client ==
nullptr) {
322 if (client ==
nullptr) {
342 if (str ==
"!help") {
343 serverSay(std::string(
"builtin commands:"), uid);
344 serverSay(std::string(
"!help !version, !list, !say, !kick"), uid);
347 if (str ==
"!version") {;
349 }
else if (str ==
"!list") {
352 serverSay(std::string(
" uid | auth | nick | ip"), uid);
356 serverSay(std::string(
" uid | auth | nick"), uid);
359 for (
unsigned int i = 0; i <
m_clients.size(); i++) {
362 char authst[10] =
"";
371 sprintf(tmp2,
"% 3d | %-6s | %-20s",
m_clients[i]->user.uniqueid, authst,
377 }
else if (str.substr(0, 6) ==
"!kick ") {
380 char kickmsg_tmp[256] =
"";
381 int res = sscanf(str.substr(6).c_str(),
"%d %s", &kuid, kickmsg_tmp);
382 std::string kickMsg = std::string(kickmsg_tmp);
383 Ogre::StringUtil::trim(kickMsg);
384 if (res != 2 || kuid == -1 || !kickMsg.size()) {
385 serverSay(std::string(
"usage: !kick <uid> <message>"), uid);
386 serverSay(std::string(
"example: !kick 3 bye!"), uid);
388 bool kicked =
Kick(kuid);
390 serverSay(std::string(
"kick not successful: uid not found!"), uid);
394 serverSay(std::string(
"You are not authorized to kick people!"), uid);
397 }
else if (str.substr(0, 5) ==
"!say ") {
400 char saymsg_tmp[256] =
"";
401 int res = sscanf(str.substr(5).c_str(),
"%d %s", &kuid, saymsg_tmp);
402 std::string sayMsg = std::string(saymsg_tmp);
403 Ogre::StringUtil::trim(sayMsg);
404 if (res != 2 || kuid < -1 || !sayMsg.size()) {
405 serverSay(std::string(
"usage: !say <uid> <message> (use uid -1 for general broadcast)"), uid);
406 serverSay(std::string(
"example: !say 3 Wecome to this server!"), uid);
413 serverSay(std::string(
"You are not authorized to use this command!"), uid);
422 if (client ==
nullptr) {
453 for (; itor != endi; ++itor) {
void queueStringForExecution(const Ogre::String command)
Queues a string for execution.
std::vector< ServerScriptClient * > m_clients
unsigned int m_free_user_id
int GetFreePlayerColour()
void sendGameCommand(int uid, std::string cmd)
void queueMessageGameCmd(int uid, const std::string &data)
ServerScriptClient * getClient(int uid)
std::mutex m_clients_mutex
guards access to m_clients and execution of script callbacks.
void frameStepScripts(float dt)
int Initialize(const std::string &script_filename)
bool CheckNickIsUnique(std::string &nick)
void queueMessageUserLeave(int uid)
void serverSay(std::string msg, int uid=-1, int type=0)
void queueMessageStreamUnregister(int uid, unsigned int streamid)
void queueMessageStreamRegister(int uid, RoRnet::StreamRegister *reg)
ServerScriptClient * FindClientById(unsigned int client_id)
void queueMessagePlayerChat(int uid, const std::string &data)
void createClient(RoRnet::UserInfo &user)
void QueueClientForDisconnect(int client_id)
std::unique_ptr< ServerScriptEngine > m_script_engine
bool Kick(int to_kick_uid)
void Log(ServerLogLevel level, const char *format,...)
ScriptEngine * GetScriptEngine()
void EraseIf(std::vector< T, A > &c, Predicate pred)
std::string SanitizeUtf8String(std::string const &str_in)
@ AUTH_MOD
moderator status
@ AUTH_RANKED
ranked status
@ AUTH_ADMIN
admin on the server
#define RORNET_MAX_USERNAME_LEN
bytes.
RoRnet::UserInfo user
user information
std::map< unsigned int, RoRnet::StreamRegister > streams
< Sent from the client to server and vice versa, to broadcast a new stream
int32_t type
0 = Actor, 1 = Character, 3 = ChatSystem
int32_t origin_streamid
origin streamid
int32_t status
initial stream status
int32_t authstatus
auth status set by server: AUTH_*
char username[RORNET_MAX_USERNAME_LEN]
the nickname of the user (UTF-8)
int32_t colournum
colour set by server
uint32_t uniqueid
user unique id