void StepManiaLanServer::AnalizeChat(PacketFunctions &Packet, const unsigned int clientNum) { CString message = Packet.ReadNT(); if (message.at(0) == '/') { CString command = message.substr(1, message.find(" ")-1); if ((command.compare("list") == 0)||(command.compare("have") == 0)) { if (command.compare("list") == 0) { Reply.ClearPacket(); Reply.Write1(NSCCM + NSServerOffset); Reply.WriteNT(ListPlayers()); SendNetPacket(clientNum, Reply); } else { message = ""; message += Client[clientNum]->Player[0].name; if (Client[clientNum]->twoPlayers) message += "&"; message += Client[clientNum]->Player[1].name; message += " forces has song."; Client[clientNum]->forceHas = true; ServerChat(message); } } else { if (clientNum == 0) { if (command.compare("force_start") == 0) ForceStart(); if (command.compare("kick") == 0) { CString name = message.substr(message.find(" ")+1); Kick(name); } if (command.compare("ban") == 0) { CString name = message.substr(message.find(" ")+1); Ban(name); } } else { Reply.ClearPacket(); Reply.Write1(NSCCM + NSServerOffset); Reply.WriteNT("You do not have permission to use server commands."); SendNetPacket(clientNum, Reply); } } } else RelayChat(message, clientNum); }
objID cGameWorld::GetGoodSpawnEnt() { /** * Step through the list of spawn ents. * choose the one that is farthest from * the rest of the players. */ list< cGamePlayerEnt* > players; ListPlayers( &players ); DebPrint( "found %d players", players.size() ); int nSpawnEnts = m_spawnEnts.size(); int best=0; float bestDist = 0.f; for( int i=0; i<nSpawnEnts; i++ ) { cGameEnt* pEnt = (cGameEnt*)MsgDaemon()->Get( m_spawnEnts[i] ); if( !pEnt ) { LogPrint("cGameWorld::GetGoodSpawnEnt: bad ID"); return -1; } list< cGamePlayerEnt* >::iterator iter; float bestCurrDist = 10000.f; for( iter = players.begin(); iter != players.end(); iter++ ) { float currDist = point3::Dist( (*iter)->GetLoc(), pEnt->GetLoc() ); if( currDist < bestCurrDist ) { bestCurrDist = currDist; } } // If this is the new best one, take it. if( bestCurrDist > bestDist ) { best = i; bestDist = bestCurrDist; } } // return the best one. return m_spawnEnts[ best ]; }
void ProcessCommand(const std::string & cmd) { if (cmd == "/help") { PrintHelp(); } else if (!cmd.compare(0, 6, "/kick ")) { std::string nick = cmd.substr(6, cmd.size() - 6); UserCommand(nick, USER_KICK); } else if (!cmd.compare(0, 9, "/address ")) { std::string nick = cmd.substr(9, cmd.size() - 9); UserCommand(nick, USER_ADDRESS); } else if (!cmd.compare(0, 5, "/list")) { ListPlayers(); } else { AppWarmux::GetInstance()->ReceiveMsgCallback(_("Unknown command"), primary_red_color); PrintHelp(); } }