Ejemplo n.º 1
0
bool ScmdServer_Impl::HandleSetMission( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the mission index desired.
	uint8 nMissionIndex = msg.Readuint8( );

	// Check to make sure the mission index is within range.
	Campaign& campaign = g_pServerMissionMgr->GetCampaign( );
	if( nMissionIndex >= campaign.size( ))
	{
		// Tell the client it failed.
		if( !SendStatusMessage( hClient, kScmdCommandSetMission, kScmdCommandStatusFailed ))
			return false;

		return true;
	}

	// Tell the client it worked.
	if( !SendStatusMessage( hClient, kScmdCommandSetMission, kScmdCommandStatusOk ))
		return false;

	// Do the switch.
	g_pServerMissionMgr->SwitchToCampaignIndex( nMissionIndex );

	return true;
}
Ejemplo n.º 2
0
static void SendStatusMessages()
{
    if (TimeForStatusMessage(STATUS_MSG_TYPE_OP_STATE))
    {
        SendStatusMessage(STATUS_MSG_TYPE_OP_STATE);
    }
    
    if (TimeForStatusMessage(STATUS_MSG_TYPE_ODOM))
    {
        SendStatusMessage(STATUS_MSG_TYPE_ODOM);
    }
    
    if (TimeForStatusMessage(STATUS_MSG_TYPE_AIR_SENSOR))
    {
        SendStatusMessage(STATUS_MSG_TYPE_AIR_SENSOR);
    }    
    
    if (TimeForStatusMessage(STATUS_MSG_TYPE_US_SENSOR))
    {
        SendStatusMessage(STATUS_MSG_TYPE_US_SENSOR);
    }
    
    if (TimeForStatusMessage(STATUS_MSG_TYPE_DIR_SENSOR))
    {
        SendStatusMessage(STATUS_MSG_TYPE_DIR_SENSOR);
    }
}
Ejemplo n.º 3
0
bool ScmdServer_Impl::HandleLogout( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Check if we should send a message to all clients about our state change.
	// Only need to do this if the admin was a client.
	bool bSendPlayerInfoMsg = ( m_eAdminControl == kAdminControlClient );

	// No longer admin controlled.
	m_eAdminControl = kAdminControlNone;

	// Forget our client.
	m_hAdminClient = NULL;

	// If the admin was just taken by a client, then tell all the clients.
	if( bSendPlayerInfoMsg )
	{
		CPlayerObj* pPlayerObj = ( CPlayerObj* )g_pLTServer->GetClientUserData( hClient );
		g_pGameServerShell->SendPlayerInfoMsgToClients( NULL, pPlayerObj, MID_PI_UPDATE );
	}

	// Tell the client it worked.
	if( !SendStatusMessage( hClient, kScmdCommandLogout, kScmdCommandStatusOk ))
		return false;

	return true;
}
Ejemplo n.º 4
0
bool ScmdServer_Impl::HandleBanClient( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the id of the client to boot.
	uint16 nClientId = msg.Readuint16( );

	bool bOk = true;
	HCLIENT hBanClient = g_pLTServer->GetClientHandle( nClientId );
	if( !hBanClient )
	{
		bOk = false;
	}

	if( bOk )
	{
		uint8 aClientIP[4];
		uint16 nPort;
		g_pLTServer->GetClientAddr( hBanClient, aClientIP, &nPort );

		BanIPMgr::ClientIP clientIP = { aClientIP[0], aClientIP[1], aClientIP[2], aClientIP[3] };

		// Ban the client.
		bOk = BanIPMgr::Instance( ).AddBan( clientIP );
	}

	// Tell the client if it worked.
	ScmdCommandStatus eScmdCommandStatus = ( bOk ) ? kScmdCommandStatusOk : kScmdCommandStatusFailed;
	if( !SendStatusMessage( hClient, kScmdCommandBanClient, eScmdCommandStatus ))
		return false;

	return true;
}
Ejemplo n.º 5
0
/*
 *	Toggle overwrite mode.
 */
void ToggleOverwrite( LPCLASSDATA lpcd )
{
	/*
	 * Toggle overwrite mode.
	 */
	lpcd->bOverwrite = ! lpcd->bOverwrite;

	/*
	 * Destroy the caret if we have focus and
	 * the caret type is not fixed at a block cursor.
	 */
	if ( Parser->nCaretType != CARET_BLOCK && lpcd->bHasFocus ) 
	{
		/*
		 * Destroy...
		 */
		DisplayCaret( lpcd, FALSE );
		DestroyCaret();
	}

	/*
	 * Update status.
	 */
	SendStatusMessage( lpcd );

	/*
	 * Create the caret if we have focus and
	 * the caret type is not fixed at a block cursor.
	 */
	if ( Parser->nCaretType != CARET_BLOCK && lpcd->bHasFocus ) 
		/*
		 * Create the caret.
		 */
		CreateTheCaret( lpcd ); 
}
Ejemplo n.º 6
0
LRESULT OnSetFocus( HWND hWnd, WPARAM wParam, LPARAM lParam, LPCLASSDATA lpcd )
{
	/*
	 *	We have the focus.
	 */
	lpcd->bHasFocus = TRUE;

	/*
	 *	Compute view.
	 */
	SetupViewSize( lpcd );

	/*
	 *	Make the caret.
	 */
	CreateTheCaret( lpcd );

	/*
	 *	Send a status message.
	 */
	SendStatusMessage( lpcd );

	/*
	 *	Refresh the view.
	 */
	if ( HasMark( lpcd ))
		InvalidateRect( hWnd, NULL, FALSE );

	/*
	 *	Is the search or replace window active?
	 */
	if ( lpcd->hReplaceWnd && ! IsWindowVisible( lpcd->hReplaceWnd )) ShowWindow( lpcd->hReplaceWnd, SW_SHOW );
	if ( lpcd->hFindWnd && ! IsWindowVisible( lpcd->hFindWnd )) ShowWindow( lpcd->hFindWnd, SW_SHOW );
	return 0;
}
Ejemplo n.º 7
0
void NetworkClient::SendDisconnect() {
	if (socket_) {
		cure::Packet* _packet = GetPacketFactory()->Allocate();
		SendStatusMessage(socket_, 0, cure::kRemoteNoConnection, cure::MessageStatus::kInfoLogin, "", _packet);
		GetPacketFactory()->Release(_packet);
	}
	SendAll();
}
Ejemplo n.º 8
0
/*
 *	Set/Clear modified mode.
 */
void SetModified( LPCLASSDATA lpcd, BOOL bModified )
{
	if ( bModified != lpcd->bModified )
	{
		lpcd->bModified = bModified;
		SendStatusMessage( lpcd );
	}
}
Ejemplo n.º 9
0
bool ScmdServer_Impl::HandleLogin( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Check if we're already controlled by an admin.
	if( m_eAdminControl != kAdminControlNone )
	{
		if( !SendStatusMessage( hClient, kScmdCommandLogin, kScmdCommandStatusAdminAlreadyLoggedIn ))
			return false;

		return true;
	}

	// Read the password they sent in.
	uint32 nHashedPassword = msg.Readuint32( );

	// Read the current password.
	uint32 nCurrentHashedPassword = str_Hash( m_sPassword.c_str( ));

	// Make sure the hashed values match.
	if( nCurrentHashedPassword != nHashedPassword )
	{
		if( !SendStatusMessage( hClient, kScmdCommandLogin, kScmdCommandStatusIncorrectPassword ))
			return false;

		return true;
	}

	// Admin is now controlled.
	m_eAdminControl = ( hClient ) ? kAdminControlClient : kAdminControlServerapp;

	// This is our admin.  It will be NULL for a standalone server.
	m_hAdminClient = hClient;

	// If the admin was just taken by a client, then tell all the clients.
	if( m_eAdminControl == kAdminControlClient )
	{
		CPlayerObj* pPlayerObj = ( CPlayerObj* )g_pLTServer->GetClientUserData( hClient );
		g_pGameServerShell->SendPlayerInfoMsgToClients( NULL, pPlayerObj, MID_PI_UPDATE );
	}

	// Tell the client it worked.
	if( !SendStatusMessage( hClient, kScmdCommandLogin, kScmdCommandStatusOk ))
		return false;

	return true;
}
Ejemplo n.º 10
0
bool ScmdServer_Impl::HandleNextRound( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Tell the client it worked.
	if( !SendStatusMessage( hClient, kScmdCommandNextRound, kScmdCommandStatusOk ))
		return false;

	g_pServerMissionMgr->NextRound( );
	return true;
}
Ejemplo n.º 11
0
static void CaretMoveExtend( LPCLASSDATA lpcd, int nMove )
{
	int	nOldStart, nOldEnd;

	/*
	 *	Marker set?
	 */
	if ( HasMark( lpcd ) == FALSE )
		/*
		 *	Setup starting point.
		 */
		lpcd->ptStartPos = lpcd->ptSelStart = lpcd->ptSelEnd = lpcd->ptCaretPos;

	/*
	 *	Copy old values.
	 */
	nOldStart = lpcd->ptSelStart.y;
	nOldEnd   = lpcd->ptSelEnd.y;

	/*
	 *	Move the caret.
	 */
	( FuncTable[ nMove ] )( lpcd );

	/*
	 *	Where are we?
	 */
	if ( lpcd->ptCaretPos.y < lpcd->ptStartPos.y || lpcd->ptCaretPos.y == lpcd->ptStartPos.y && lpcd->ptCaretPos.x < lpcd->ptStartPos.x )
	{
		/*
		 *	Setup new start position.
		 */
		lpcd->ptSelStart = lpcd->ptCaretPos;
		lpcd->ptSelEnd   = lpcd->ptStartPos;
	}
	else
	{
		lpcd->ptSelStart = lpcd->ptStartPos;
		lpcd->ptSelEnd   = lpcd->ptCaretPos;
	}

	/*
	 *	Update visuals.
	 */
	RenderLines( lpcd, nOldStart, lpcd->ptSelStart.y );
	RenderLines( lpcd, nOldEnd,   lpcd->ptSelEnd.y   );

	/*
	 *	Send status message.
	 */
	SendStatusMessage( lpcd );
}
Ejemplo n.º 12
0
bool ScmdServer_Impl::HandleBootId( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the id of the client to boot.
	uint16 nClientId = msg.Readuint16( );

	// Boot the client.
	bool bBooted = BootClient( true, nClientId, "" );

	// Tell the client if it worked.
	ScmdCommandStatus eScmdCommandStatus = ( bBooted ) ? kScmdCommandStatusOk : kScmdCommandStatusFailed;
	if( !SendStatusMessage( hClient, kScmdCommandBootId, eScmdCommandStatus ))
		return false;

	return true;
}
Ejemplo n.º 13
0
bool ScmdServer_Impl::HandleAddBan( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the IP.
	char szBanIP[16];
	msg.ReadString( szBanIP, ARRAY_LEN( szBanIP ));

	bool bSuccess = BanIPMgr::Instance( ).AddBan( szBanIP );

	// Tell the client if it worked or not.
	if( !SendStatusMessage( hClient, kScmdCommandAddBan, ( bSuccess ) ? kScmdCommandStatusOk : 
		kScmdCommandStatusFailed ))
		return false;

	return true;
}
Ejemplo n.º 14
0
bool ScmdServer_Impl::HandleBootName( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the name of the player to boot.
	char szPlayerName[MAX_PLAYER_NAME];
	msg.ReadString( szPlayerName, ARRAY_LEN( szPlayerName ));

	// Boot the client.
	bool bBooted = BootClient( false, 0, szPlayerName );

	// Tell the client if it worked.
	ScmdCommandStatus eScmdCommandStatus = ( bBooted ) ? kScmdCommandStatusOk : kScmdCommandStatusFailed;
	if( !SendStatusMessage( hClient, kScmdCommandBootName, eScmdCommandStatus ))
		return false;

	return true;
}
Ejemplo n.º 15
0
void Room::RoomImpl::HandleClientDisconnection(ENetPeer* client) {
    // Remove the client from the members list.
    std::string nickname, username;
    {
        std::lock_guard lock(member_mutex);
        auto member = std::find_if(members.begin(), members.end(), [client](const Member& member) {
            return member.peer == client;
        });
        if (member != members.end()) {
            nickname = member->nickname;
            username = member->user_data.username;
            members.erase(member);
        }
    }

    // Announce the change to all clients.
    enet_peer_disconnect(client, 0);
    if (!nickname.empty())
        SendStatusMessage(IdMemberLeave, nickname, username);
    BroadcastRoomInformation();
}
Ejemplo n.º 16
0
bool ScmdServer_Impl::HandleRemoveBan( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the banid.
	uint8 nBanId = msg.Readuint8( );

	bool bOk = true;

	// Index into the ban list.
	BanIPMgr::BanList const& banList = BanIPMgr::Instance( ).GetBanList( );

	// Make sure the id is in range.
	if( nBanId >= banList.size( ))
	{
		bOk = false;
	}

	if( bOk )
	{
		// Index into ban list and remove the ban.
		BanIPMgr::BanList::const_iterator iter = banList.begin( );
		for( uint8 nId = 0; iter != banList.end( ); iter++, nId++ )
		{
			if( nId == nBanId )
			{
				BanIPMgr::ClientIP const& clientIP = *iter;
				bOk = BanIPMgr::Instance( ).RemoveBan( clientIP );
				break;
			}
		}
	}

	// Tell the client if it worked or not.
	if( !SendStatusMessage( hClient, kScmdCommandRemoveBan, ( bOk ) ? kScmdCommandStatusOk : 
		kScmdCommandStatusFailed ))
		return false;

	return true;
}
Ejemplo n.º 17
0
void ClearClipboard( LPCLASSDATA lpcd )
{
	/*
	 *	Open the clipboard.
	 */
	if ( OpenClipboard( lpcd->hWnd ))
	{
		/*
		 *	Empty it.
		 */
		 EmptyClipboard();

		/*
		 *	Send status message.
		 */
		 SendStatusMessage( lpcd );

		/*
		 *	Close the clipboard.
		 */
		CloseClipboard();
	}
}
Ejemplo n.º 18
0
void Room::RoomImpl::HandleModKickPacket(const ENetEvent* event) {
    if (!HasModPermission(event->peer)) {
        SendModPermissionDenied(event->peer);
        return;
    }

    Packet packet;
    packet.Append(event->packet->data, event->packet->dataLength);
    packet.IgnoreBytes(sizeof(u8)); // Ignore the message type

    std::string nickname;
    packet >> nickname;

    std::string username;
    {
        std::lock_guard lock(member_mutex);
        const auto target_member =
            std::find_if(members.begin(), members.end(),
                         [&nickname](const auto& member) { return member.nickname == nickname; });
        if (target_member == members.end()) {
            SendModNoSuchUser(event->peer);
            return;
        }

        // Notify the kicked member
        SendUserKicked(target_member->peer);

        username = target_member->user_data.username;

        enet_peer_disconnect(target_member->peer, 0);
        members.erase(target_member);
    }

    // Announce the change to all clients.
    SendStatusMessage(IdMemberKicked, nickname, username);
    BroadcastRoomInformation();
}
Ejemplo n.º 19
0
void Room::RoomImpl::HandleModUnbanPacket(const ENetEvent* event) {
    if (!HasModPermission(event->peer)) {
        SendModPermissionDenied(event->peer);
        return;
    }

    Packet packet;
    packet.Append(event->packet->data, event->packet->dataLength);
    packet.IgnoreBytes(sizeof(u8)); // Ignore the message type

    std::string address;
    packet >> address;

    bool unbanned = false;
    {
        std::lock_guard lock(ban_list_mutex);

        auto it = std::find(username_ban_list.begin(), username_ban_list.end(), address);
        if (it != username_ban_list.end()) {
            unbanned = true;
            username_ban_list.erase(it);
        }

        it = std::find(ip_ban_list.begin(), ip_ban_list.end(), address);
        if (it != ip_ban_list.end()) {
            unbanned = true;
            ip_ban_list.erase(it);
        }
    }

    if (unbanned) {
        SendStatusMessage(IdAddressUnbanned, address, "");
    } else {
        SendModNoSuchUser(event->peer);
    }
}
Ejemplo n.º 20
0
void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
    {
        std::lock_guard lock(member_mutex);
        if (members.size() >= room_information.member_slots) {
            SendRoomIsFull(event->peer);
            return;
        }
    }
    Packet packet;
    packet.Append(event->packet->data, event->packet->dataLength);
    packet.IgnoreBytes(sizeof(u8)); // Ignore the message type
    std::string nickname;
    packet >> nickname;

    std::string console_id_hash;
    packet >> console_id_hash;

    MacAddress preferred_mac;
    packet >> preferred_mac;

    u32 client_version;
    packet >> client_version;

    std::string pass;
    packet >> pass;

    std::string token;
    packet >> token;

    if (pass != password) {
        SendWrongPassword(event->peer);
        return;
    }

    if (!IsValidNickname(nickname)) {
        SendNameCollision(event->peer);
        return;
    }

    if (preferred_mac != NoPreferredMac) {
        // Verify if the preferred mac is available
        if (!IsValidMacAddress(preferred_mac)) {
            SendMacCollision(event->peer);
            return;
        }
    } else {
        // Assign a MAC address of this client automatically
        preferred_mac = GenerateMacAddress();
    }

    if (!IsValidConsoleId(console_id_hash)) {
        SendConsoleIdCollision(event->peer);
        return;
    }

    if (client_version != network_version) {
        SendVersionMismatch(event->peer);
        return;
    }

    // At this point the client is ready to be added to the room.
    Member member{};
    member.mac_address = preferred_mac;
    member.console_id_hash = console_id_hash;
    member.nickname = nickname;
    member.peer = event->peer;

    std::string uid;
    {
        std::lock_guard lock(verify_UID_mutex);
        uid = verify_UID;
    }
    member.user_data = verify_backend->LoadUserData(uid, token);

    {
        std::lock_guard lock(ban_list_mutex);

        // Check username ban
        if (!member.user_data.username.empty() &&
            std::find(username_ban_list.begin(), username_ban_list.end(),
                      member.user_data.username) != username_ban_list.end()) {

            SendUserBanned(event->peer);
            return;
        }

        // Check IP ban
        char ip_raw[256];
        enet_address_get_host_ip(&event->peer->address, ip_raw, sizeof(ip_raw) - 1);
        std::string ip = ip_raw;

        if (std::find(ip_ban_list.begin(), ip_ban_list.end(), ip) != ip_ban_list.end()) {
            SendUserBanned(event->peer);
            return;
        }
    }

    // Notify everyone that the user has joined.
    SendStatusMessage(IdMemberJoin, member.nickname, member.user_data.username);

    {
        std::lock_guard lock(member_mutex);
        members.push_back(std::move(member));
    }

    // Notify everyone that the room information has changed.
    BroadcastRoomInformation();
    if (HasModPermission(event->peer)) {
        SendJoinSuccessAsMod(event->peer, preferred_mac);
    } else {
        SendJoinSuccess(event->peer, preferred_mac);
    }
}
Ejemplo n.º 21
0
void Room::RoomImpl::HandleModBanPacket(const ENetEvent* event) {
    if (!HasModPermission(event->peer)) {
        SendModPermissionDenied(event->peer);
        return;
    }

    Packet packet;
    packet.Append(event->packet->data, event->packet->dataLength);
    packet.IgnoreBytes(sizeof(u8)); // Ignore the message type

    std::string nickname;
    packet >> nickname;

    std::string username;
    std::string ip;

    {
        std::lock_guard lock(member_mutex);
        const auto target_member =
            std::find_if(members.begin(), members.end(),
                         [&nickname](const auto& member) { return member.nickname == nickname; });
        if (target_member == members.end()) {
            SendModNoSuchUser(event->peer);
            return;
        }

        // Notify the banned member
        SendUserBanned(target_member->peer);

        nickname = target_member->nickname;
        username = target_member->user_data.username;

        char ip_raw[256];
        enet_address_get_host_ip(&target_member->peer->address, ip_raw, sizeof(ip_raw) - 1);
        ip = ip_raw;

        enet_peer_disconnect(target_member->peer, 0);
        members.erase(target_member);
    }

    {
        std::lock_guard lock(ban_list_mutex);

        if (!username.empty()) {
            // Ban the forum username
            if (std::find(username_ban_list.begin(), username_ban_list.end(), username) ==
                username_ban_list.end()) {

                username_ban_list.emplace_back(username);
            }
        }

        // Ban the member's IP as well
        if (std::find(ip_ban_list.begin(), ip_ban_list.end(), ip) == ip_ban_list.end()) {
            ip_ban_list.emplace_back(ip);
        }
    }

    // Announce the change to all clients.
    SendStatusMessage(IdMemberBanned, nickname, username);
    BroadcastRoomInformation();
}
Ejemplo n.º 22
0
static LRESULT CALLBACK PropProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch ( uMsg )
	{
		case	WM_INITDIALOG:
		{
			LPCLASSDATA	lpcd = ( LPCLASSDATA )lParam;
			HDC		hDC;
			RECT		rcClient;
			HWND		hControl;
			HFONT		hFont, hOFont;
			TCHAR		szBuffer[ MAX_PATH ];
			int		i;

			/*
			 *	Save data.
			 */
			nFileMode = Parser->nFileMode;
			nTabSize  = Parser->nTabSize;

			/*
			 *	Setup class data pointer as
			 *	the dialog user data.
			 */
			SetWindowLong( hDlg, DWL_USER, ( LONG )lpcd );

			/*
			 *	Get handle to the file name control.
			 */
			hControl = GetDlgItem( hDlg, IDC_PROP_FILENAME );

			/*
			 *	Copy the file name into
			 *	a buffer.
			 */
			_tcsncpy_s( szBuffer, MAX_PATH, lpcd->szFileName, MAX_PATH );

			/*
			 *	Get the client rectangle of
			 *	the file name control.
			 */
			GetClientRect( hControl, &rcClient );

			/*
			 *	Get the device context.
			 */
			if (( hDC = GetDC( hControl )) != NULL )
			{
				/*
				 *	Get the dialog font.
				 */
				if (( hFont = ( HFONT )SendMessage( hDlg, WM_GETFONT, 0, 0 )) != NULL )
				{
					/*
					 *	Make sure we use the correct font.
					 */
					hOFont = SelectObject( hDC, hFont );

					/*
					 *	Compact the path.
					 */
					PathCompactPath( hDC, szBuffer, rcClient.right );

					/*
					 *	Reset the font.
					 */
					SelectObject( hDC, hOFont );
				}
				/*
				 *	Release the device context.
				 */
				ReleaseDC( hControl, hDC );
			}

			/*
			 *	Set the path.
			 */
			SetWindowText( hControl, szBuffer );

			/*
			 *	Unicode?
			 */
			SetDlgItemText( hDlg, IDC_PROP_UNICODE, GetString( lpcd->bUnicode ? IDS_TRUE : IDS_FALSE ));

			/*
			 *	Setup the up/down range
			 *	and the tab stop.
			 */
			SendDlgItemMessage( hDlg, IDC_PROP_TABSPIN, UDM_SETRANGE, 0, MAKELPARAM( 24,2 ));

			/*
			 *	Setup file modes.
			 */
			for ( i = FMODE_MSDOS; i <= FMODE_MACINTOSH; i++ )
				SendDlgItemMessage( hDlg, IDC_PROP_TYPE, CB_ADDSTRING, 0, ( LPARAM )lpszFileModes[ i ] );

			/*
			 *	Setup the file size and the
			 *	tab size controls.
			 */
			SetSizeControls( hDlg );

			/*
			 *	Valid file date?
			 */
			if ( lpcd->ftFileTime.dwHighDateTime == 0 && lpcd->ftFileTime.dwLowDateTime == 0 )
				SetDlgItemText( hDlg, IDC_PROP_DATE, GetString( IDS_NOT_SAVED ));
			else
			{
				FILETIME	ft;
				SYSTEMTIME	st;

				/*
				 *	Convert file time to
				 *	system time.
				 */
				FileTimeToLocalFileTime( &lpcd->ftFileTime, &ft );
				FileTimeToSystemTime( &ft, &st );

				/*
				 *	Format time.
				 */
				GetTimeFormat( LOCALE_USER_DEFAULT,
					       0, //LOCALE_NOUSEROVERRIDE,
					       &st,
					       NULL,
					       szBuffer,
					       256 );

				/*
				 *	Add space.
				 */
				_tcscat_s( szBuffer, MAX_PATH, _T(" "));

				/*
				 *	Format date.
				 */
				GetDateFormat( LOCALE_USER_DEFAULT,
					       0, //LOCALE_NOUSEROVERRIDE,
					       &st,
					       NULL,
					       &szBuffer[ _tcslen( szBuffer ) ],
					       256 - _tcslen( szBuffer ));

				/*
				 *	Output result.
				 */
				SetDlgItemText( hDlg, IDC_PROP_DATE, szBuffer );
			}

			/*
			 *	Focus the OK button.
			 */
			return TRUE;
		}

		case	WM_CLOSE:
			/*
			 *	Bye...
			 */
			EndDialog( hDlg, 0 );
			break;

		case	WM_COMMAND:
		{
			LPCLASSDATA	lpcd = ( LPCLASSDATA )GetWindowLong( hDlg, DWL_USER );

			switch ( LOWORD( wParam ))
			{
				case	IDC_PROP_TYPE:
					/*
					 *	Get file mode.
					 */
					Parser->nFileMode = SendDlgItemMessage( hDlg, IDC_PROP_TYPE, CB_GETCURSEL, 0, 0 );

					/*
					 *	Send status message.
					 */
					SendStatusMessage( lpcd );
					break;

				case	IDC_PROP_TABSIZE:
				{
					/*
					 *	Lost focus on the edit control?
					 */
					if ( HIWORD( wParam ) == EN_KILLFOCUS )
					{
						/*
						 *	Get value.
						 */
						int	nTabStop = GetDlgItemInt( hDlg, IDC_PROP_TABSIZE, NULL, FALSE );

						/*
						 *	Clamp entered value between 2 and 24.
						 */
						if (      nTabStop < 2  ) nTabStop = 2;
						else if ( nTabStop > 24 ) nTabStop = 24;

						/*
						 *	Set this value to the 
						 *	edit control.
						 */
						SetDlgItemInt( hDlg, IDC_PROP_TABSIZE, ( UINT )nTabStop, FALSE );

						/*
						 *	Save tab value.
						 */
						Parser->nTabSize = nTabStop;

						/*
						 *	Re-render if it changed...
						 */
						if ( nTabStop != nTabSize )
							InvalidateRect( lpcd->hWnd, NULL, FALSE );
					}
					break;
				}

				case	IDCANCEL:
					/*
					 *	Reset tabsize.
					 */
					if ( Parser->nTabSize != nTabSize )
					{
						Parser->nTabSize = nTabSize;
						InvalidateRect( lpcd->hWnd, NULL, FALSE );
					}

					/*
					 *	And file mode.
					 */
					if ( Parser->nFileMode != nFileMode )
					{
						Parser->nFileMode = nFileMode;
						SendStatusMessage( lpcd );
					}

					/*
					 *	Fall through...
					 */

				case	IDOK:
					/*
					 *	Bye...
					 */
					EndDialog( hDlg, 0 );
					break;
			}
		}
	}
	return 0;
}
Ejemplo n.º 23
0
BOOL Delete( LPCLASSDATA lpcd )
{
	/*
	 *	Read only?
	 */
	if ( ISREADONLY )
		return TRUE;

	/*
	 *	Do we have a mark and
	 *	is it valid?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Remove the text.
		 */
		DeleteText( lpcd, &lpcd->ptSelStart, &lpcd->ptSelEnd, TRUE );

		/*
		 *	We _must_ have atleast one
		 *	empty line.
		 */
		if ( ArrayGetSize( lpcd->lpLines ) == 0 )
		{
			if ( InsertLine( lpcd, NULL, 0, -1, TRUE ) == FALSE )
				return FALSE;
		}

		/*
		 *	Hide the caret.
		 */
		DisplayCaret( lpcd, FALSE );

		/*
		 *	Move to the start position.
		 */
		lpcd->ptCaretPos = lpcd->ptSelStart;

		/*
		 *	Update column position.
		 */
		lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

		/*
		 *	Invalidate marks.
		 */
		lpcd->ptSelStart.x = lpcd->ptSelStart.y = -1;
		lpcd->ptSelEnd.x   = lpcd->ptSelEnd.y   = -1;

		/*
		 *	Is the caret inside
		 *	the view?
		 */
		if ( CaretInView( lpcd ) == FALSE )
			/*
			 *	No. Move the view to
			 *	make it visible.
			 */
			MakeCaretVisibleNoRedraw( lpcd );

		/*
		 *	Re-render.
		 */
		InvalidateRect( lpcd->hWnd, NULL, FALSE );

		/*
		 *	Setup scrollers.
		 */
		SetupHScroller( lpcd );
		SetupVScroller( lpcd );

		/*
		 *	We are modified.
		 */
		SetModified( lpcd, TRUE );

		/*
		 *	Send status message.
		 */
		SendStatusMessage( lpcd );

		/*
		 *	Show the caret.
		 */
		DisplayCaret( lpcd, TRUE );
	}
	return TRUE;
}
Ejemplo n.º 24
0
BOOL Copy( LPCLASSDATA lpcd )
{
	HANDLE		hData;
	BOOL		bRC = FALSE, bClearMark = FALSE;

	/*
	 *	Do we have a mark and, if so,
	 *	is it valid?
	 */
	if ( HasMark( lpcd ) == FALSE )
	{
		/*
		 *	We have no marker so we simply
		 *	copy the current line to the
		 *	clipboard.
		 */
		if ( ! MarkWholeLine( lpcd, TRUE ))
		{
			/*
			 *	Probably an empty line. Clear the
			 *	clipboard contents.
			 */
			if ( OpenClipboard( lpcd->hWnd ))
			{
				EmptyClipboard();
				CloseClipboard();
			}

			/*
			 *	Update the status.
			 */
			SendStatusMessage( lpcd );
			return FALSE;
		}
		bClearMark = TRUE;
	}

	/*
	 *	Open the clipboard.
	 */
	if ( OpenClipboard( lpcd->hWnd ))
	{
		/*
		 *	Empty the clipboard.
		 */
		EmptyClipboard();

		/*
		 *	Get the marked text.
		 */
		if (( hData = GetTextGlobal( lpcd, &lpcd->ptSelStart, &lpcd->ptSelEnd )) != NULL )
		{
			/*
			 *	Set data to the clipboard.
			 */
			if ( SetClipboardData( CF_TEXT, hData ) == hData )
				bRC = TRUE;
		}
		/*
		 *	Close the clipboard.
		 */
		CloseClipboard();
	}

	/*
	 *	Clear markers?
	 */
	if ( bClearMark )
		ClearMark( lpcd );
	return bRC;
}
Ejemplo n.º 25
0
void RMDSBridgeSubscription::OnStatusMessage( mamaMsgStatus statusCode )
{
	SendStatusMessage(statusCode);
}
Ejemplo n.º 26
0
bool ScmdServer_Impl::HandleSetGameOption( HCLIENT hClient, ILTMessage_Read& msg )
{
	bool bOk = true;

	// Get the game option they are setting.
	uint8 nGameOption = msg.Readuint8( );

	// Read in the value.
	char szVal[256];
	msg.ReadString( szVal, ARRAY_LEN( szVal ));

	ServerMissionSettings sms = g_pServerMissionMgr->GetServerSettings();
	switch( g_pGameServerShell->GetGameType( ))
	{
		case eGameTypeDeathmatch:
		{
			switch( nGameOption )
			{
				// Runspeed.
				case 0:
				{
					SetGameOption( sms.m_nRunSpeed, atoi( szVal ), 100, 150 );
				}
				break;
				// Score limit.
				case 1:
				{
					SetGameOption( sms.m_nScoreLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Time limit.
				case 2:
				{
					SetGameOption( sms.m_nTimeLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Rounds.
				case 3:
				{
					SetGameOption( sms.m_nRounds, atoi( szVal ), 1, 255 );
				}
				break;
				default:
				{
					bOk = false;
				}
				break;
			}
		}
		break;

		case eGameTypeTeamDeathmatch:
		{
			switch( nGameOption )
			{
				// Runspeed.
				case 0:
				{
					SetGameOption( sms.m_nRunSpeed, atoi( szVal ), 100, 150 );
				}
				break;
				// Score limit.
				case 1:
				{
					SetGameOption( sms.m_nScoreLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Time limit.
				case 2:
				{
					SetGameOption( sms.m_nTimeLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Rounds.
				case 3:
				{
					SetGameOption( sms.m_nRounds, atoi( szVal ), 1, 255 );
				}
				break;
				// Friendly fire.
				case 4:
				{
					SetGameOption( sms.m_bFriendlyFire, ( bool )( !!atoi( szVal )), false, true );
				}
				break;
				default:
				{
					bOk = false;
				}
				break;
			}
		}
		break;

		case eGameTypeDoomsDay:
		{
			switch( nGameOption )
			{
				// Runspeed.
				case 0:
				{
					SetGameOption( sms.m_nRunSpeed, atoi( szVal ), 100, 150 );
				}
				break;
				// Time limit.
				case 1:
				{
					SetGameOption( sms.m_nTimeLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Rounds.
				case 2:
				{
					SetGameOption( sms.m_nRounds, atoi( szVal ), 1, 255 );
				}
				break;
				// Friendly fire.
				case 3:
				{
					SetGameOption( sms.m_bFriendlyFire, ( bool )( !!atoi( szVal )), false, true );
				}
				break;
				default:
				{
					bOk = false;
				}
				break;
			}
		}
		break;

		case eGameTypeCooperative:
		{
			switch( nGameOption )
			{
				// Friendly fire.
				case 0:
				{
					SetGameOption( sms.m_bFriendlyFire, ( bool )( !!atoi( szVal )), false, true );
				}
				break;

				// mp difficulty.
				case 1:
				{
					SetGameOption( sms.m_nMPDifficulty, atoi( szVal ), 0, 255 );
				}
				break;

				// player diff factor.
				case 2:
				{
					SetGameOption( sms.m_fPlayerDiffFactor, ( float )atof( szVal ), 0.0f, 20.0f );
				}
				break;

				default:
				{
					bOk = false;
				}
				break;
			}
		}
		break;

		default:
		{
			bOk = false;
		}
		break;
	}
	
	// We need to tell the host client about the new settings.
	if( bOk )
	{
		// Record any changes.
		g_pServerMissionMgr->SetServerSettings(sms);

		// Try to find a local host if one exists.
		HCLIENT hHost = g_pLTServer->GetNextClient( NULL );
		while( hHost )
		{
			uint32 nClientInfoFlags = g_pLTServer->GetClientInfoFlags( hHost );
			if( nClientInfoFlags & CIF_LOCAL )
			{
				break;
			}

			hHost = g_pLTServer->GetNextClient( hHost );
		}
		
		// If we have a host, tell them about the new settings.
		if( hHost )
		{
			CAutoMessage cMsg;
			cMsg.Writeuint8( MID_MULTIPLAYER_OPTIONS );
			cMsg.Writeuint8( sms.m_nRunSpeed);
			cMsg.Writeuint8( sms.m_nScoreLimit);
			cMsg.Writeuint8( sms.m_nTimeLimit);
			cMsg.Writeuint8( sms.m_nRounds);
			cMsg.Writebool( sms.m_bFriendlyFire);
			cMsg.Writeuint8( sms.m_nMPDifficulty);
			cMsg.Writefloat( sms.m_fPlayerDiffFactor);
			g_pLTServer->SendToClient( cMsg.Read( ), hHost, MESSAGE_GUARANTEED );
		}
	}

	SendStatusMessage( hClient, kScmdCommandSetGameOption, ( bOk ) ? kScmdCommandStatusOk : kScmdCommandStatusFailed );

	return true;
}
Ejemplo n.º 27
0
bool ScmdServer_Impl::HandleScmdMessage( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Check if SCMD commands are not allowed.
	if( !m_bAllowScmdCommands )
	{
		return true;
	}

	// Read the scmd command.
	ScmdCommand eScmdCommand = ( ScmdCommand )msg.Readuint8( );

	// Check if we're not controlled by an admin.  Since Login is the only
	// command you can send without being logged in, it has special handling.
	if( eScmdCommand != kScmdCommandLogin &&
		( m_eAdminControl == kAdminControlNone ) ||
		( m_eAdminControl == kAdminControlClient && hClient != m_hAdminClient ) ||
		( m_eAdminControl == kAdminControlServerapp && hClient != NULL ))
	{
		// Doesn't have privileges.
		SendStatusMessage( hClient, eScmdCommand, kScmdCommandStatusNotLoggedIn );
		return false;
	}


	switch( eScmdCommand )
	{
		case kScmdCommandLogin:
			return HandleLogin( hClient, msg );
			break;

		case kScmdCommandLogout:
			return HandleLogout( hClient, msg );
			break;

		case kScmdCommandListClients:
			return HandleListClients( hClient, msg );
			break;

		case kScmdCommandListMissions:
			return HandleListMissions( hClient, msg );
			break;

		case kScmdCommandNextMission:
			return HandleNextMission( hClient, msg );
			break;

		case kScmdCommandNextRound:
			return HandleNextRound( hClient, msg );
			break;

		case kScmdCommandSetMission:
			return HandleSetMission( hClient, msg );
			break;

		case kScmdCommandBootName:
			return HandleBootName( hClient, msg );
			break;

		case kScmdCommandBootId:
			return HandleBootId( hClient, msg );
			break;

		case kScmdCommandAddBan:
			return HandleAddBan( hClient, msg );
			break;

		case kScmdCommandRemoveBan:
			return HandleRemoveBan( hClient, msg );
			break;

		case kScmdCommandListBans:
			return HandleListBans( hClient, msg );
			break;

		case kScmdCommandBanClient:
			return HandleBanClient( hClient, msg );
			break;

		case kScmdCommandListGameOptions:
			return HandleListGameOptions( hClient, msg );
			break;

		case kScmdCommandSetGameOption:
			return HandleSetGameOption( hClient, msg );
			break;

	}

	return false;
}