コード例 #1
0
ファイル: RoomActions.cpp プロジェクト: exussum12/rvserver
bool HandleForceJoin( ChatServer *server, User *user, const ChatPacket *packet )
{
	if( !user->IsMod() )
		return false;

	const string& sRoom = packet->sMessage;
	RoomList *list = server->GetRoomList();
	Room *room = list->GetRoom( sRoom );

	// doesn't exist, don't let mods send users into oblivion
	if( room == NULL )
		return false;

	User *target = server->GetUserByName( packet->sUsername );

	// can't find the desired target, so can't mess with
	if( target == NULL )
		return false;

	room->AddUser( target );

	// broadcast the new room join
	server->Broadcast( ChatPacket(JOIN_ROOM, target->GetName(), sRoom) );

	const string sMessage = target->GetName() + " was forced to join "
		+ sRoom + " by " + user->GetName();

	server->WallMessage( sMessage );

	return true;
}
コード例 #2
0
ファイル: RoomActions.cpp プロジェクト: exussum12/rvserver
bool HandleCreate( ChatServer *server, User *user, const ChatPacket *packet )
{
	if( !user->IsMod() )
		return false;

	const string &sRoom = packet->sMessage;

	RoomList *list = server->GetRoomList();
	Room *room = list->GetRoom( sRoom );

	if( room != NULL )
	{
		ChatPacket msg( WALL_MESSAGE, BLANK, "That room already exists!" );
		user->Write( msg.ToString() );
		return false;
	}

	// length check, since really long names make the client freak out
	if( sRoom.length() > 16 )
	{
		ChatPacket msg( WALL_MESSAGE, BLANK, "Room names are limited to 16 characters." );
		user->Write( msg.ToString() );
		return false;
	}

	list->AddRoom( sRoom );

	// this should never fail - we just added it
	room = list->GetRoom( sRoom );
	if( room == NULL )
	{
		LOG->System( "Failed to get newly created room \"%s\"!", sRoom.c_str() );
		return true;	// log it
	}

	room->AddUser( user );

	// broadcast the new room creation and join
	server->Broadcast( ChatPacket(CREATE_ROOM, BLANK, sRoom) );
	server->Broadcast( ChatPacket(JOIN_ROOM, user->GetName(), sRoom) );

	return true;
}
コード例 #3
0
ファイル: RoomActions.cpp プロジェクト: exussum12/rvserver
bool HandleJoin( ChatServer *server, User *user, const ChatPacket *packet )
{
	const string &sRoom = packet->sMessage;

	Room *room = server->GetRoomList()->GetRoom( sRoom );

	// doesn't exist, so can't join
	if( room == NULL )
		return false;

	// already here
	if( room->HasUser(user) )
		return false;

	room->AddUser( user );
	server->Broadcast( ChatPacket(JOIN_ROOM, user->GetName(), sRoom) );

	return true;
}