Esempio n. 1
0
bool HandleDestroy( ChatServer *server, User *user, const ChatPacket *packet )
{
	if( !user->IsMod() )
		return false;

	RoomList *pList = server->GetRoomList();
	const string &sRoom = packet->sMessage;

	// check to make sure that no one's trying to destroy Main
	const string &sDefaultRoom = pList->GetName( pList->GetDefaultRoom() );

	// consequences shall be dire!
	if( sRoom.compare( sDefaultRoom ) == 0 )
	{
		const string HAL = "[Server] I'm afraid I can't let you do that, " + user->GetName() + ".";
		server->Broadcast( ChatPacket(WALL_MESSAGE, BLANK, HAL) );
		user->Kill();
		return true;
	}

	// remove the room and broadcast its destruction
	pList->RemoveRoom( sRoom );
	server->Broadcast( ChatPacket(DESTROY_ROOM, BLANK, sRoom) );

	return true;
}