bool user_getPositionW(const char* user, double* x, double* y, double* z, int* w,float* yaw, float* pitch, double *stance) { std::string userStr(user); for (std::vector<User*>::iterator it = Mineserver::get()->usersBegin(); it != Mineserver::get()->usersEnd(); ++it) { User *user = *it; if(user->fd && user->logged) { //Is this the user? if(userStr == user->nick) { //For safety, check for NULL pointers! if(x != NULL) *x=user->pos.x; if(y != NULL) *y=user->pos.y; if(z != NULL) *z=user->pos.z; if(yaw != NULL) *yaw=user->pos.yaw; if(pitch != NULL) *pitch=user->pos.pitch; if(stance != NULL) *stance=user->pos.stance; if(w != NULL) *w=user->pos.map; //We found the user return true; } } } return false; }
// CHAT WRAPPER FUNCTIONS bool chat_sendmsgTo(const char* user,const char* msg) { std::string userStr(user); if (userStr == "[Server]") { LOG(INFO, "Chat", msg); return true; } for (std::vector<User*>::iterator it = Mineserver::get()->usersBegin(); it != Mineserver::get()->usersEnd(); ++it) { User *user = *it; if(user->fd && user->logged) { // Don't send to his user if he is DND and the message is a chat message if(userStr == user->nick) { user->buffer << (int8_t)PACKET_CHAT_MESSAGE << std::string(msg); return true; } } } return false; }
bool user_getPositionW(const char* user, double* x, double* y, double* z, int* w,float* yaw, float* pitch, double *stance) { std::string userStr(user); for(unsigned int i = 0; i < Mineserver::get()->users().size(); i++) { if(Mineserver::get()->users()[i]->fd && Mineserver::get()->users()[i]->logged) { //Is this the user? if(userStr == Mineserver::get()->users()[i]->nick) { //For safety, check for NULL pointers! if(x != NULL) *x=Mineserver::get()->users()[i]->pos.x; if(y != NULL) *y=Mineserver::get()->users()[i]->pos.y; if(z != NULL) *z=Mineserver::get()->users()[i]->pos.z; if(yaw != NULL) *yaw=Mineserver::get()->users()[i]->pos.yaw; if(pitch != NULL) *pitch=Mineserver::get()->users()[i]->pos.pitch; if(stance != NULL) *stance=Mineserver::get()->users()[i]->pos.stance; if(w != NULL) *w=Mineserver::get()->users()[i]->pos.map; //We found the user return true; } } } return false; }
bool chat_sendUserlist(const char* user) { std::string userStr(user); User *userPtr = userFromName(userStr); if(userPtr != NULL) { Mineserver::get()->chat()->sendUserlist(userPtr); return true; } return false; }
// CHAT WRAPPER FUNCTIONS bool chat_sendmsgTo(const char* user, const char* msg) { std::string userStr(user); if (userStr == "[Server]") { LOG(INFO, "Chat", msg); return true; } for (unsigned int i = 0; i < Mineserver::get()->users().size(); i++) { if (Mineserver::get()->users()[i]->fd && Mineserver::get()->users()[i]->logged) { // Don't send to his user if he is DND and the message is a chat message if (userStr == Mineserver::get()->users()[i]->nick) { Mineserver::get()->users()[i]->buffer << (int8_t)PACKET_CHAT_MESSAGE << std::string(msg); return true; } } } return false; }