static int _client_anongame_set_icon(t_connection * c, t_packet const * const packet)
{
    //BlacKDicK 04/20/2003
    unsigned int desired_icon;
    char user_icon[5];

    /*FIXME: In this case we do not get a 'count' but insted of it we get the icon
    that the client wants to set.'W3H2' for an example. For now it is ok, since they share
    the same position	on the packet*/
    desired_icon=bn_int_get(packet->u.client_findanongame.count);
    user_icon[4]=0;
    if (desired_icon==0){
	std::strcpy(user_icon,"NULL");
	eventlog(eventlog_level_info,__FUNCTION__,"[%d] Set icon packet to DEFAULT ICON [%4.4s]",conn_get_socket(c),user_icon);
    }else{
	std::memcpy(user_icon,&desired_icon,4);
	eventlog(eventlog_level_info,__FUNCTION__,"[%d] Set icon packet to ICON [%s]",conn_get_socket(c),user_icon);
    }

    account_set_user_icon(conn_get_account(c),conn_get_clienttag(c),user_icon);
    //FIXME: Still need a way to 'refresh the user/channel'
    //_handle_rejoin_command(conn_get_account(c),"");
    /* ??? channel_update_userflags() */
	conn_update_w3_playerinfo(c);

    channel_rejoin(c);
    return 0;
}
Example #2
0
		/* Choose icon by user from profile > portrait */
		static int _client_anongame_set_icon(t_connection * c, t_packet const * const packet)
		{
			//BlacKDicK 04/20/2003
			// Modified by aancw 16/12/2014
			unsigned int desired_icon;
			char user_icon[5];
			t_account * account;

			// disable with custom icons
			if (prefs_get_custom_icons() == 1)
			{
				return 0;
			}

			/*FIXME: In this case we do not get a 'count' but insted of it we get the icon
			that the client wants to set.'W3H2' for an example. For now it is ok, since they share
			the same position	on the packet*/
			desired_icon = bn_int_get(packet->u.client_findanongame.count);
			//user_icon[4]=0;
			if (desired_icon == 0){
				std::strcpy(user_icon, "1O3W"); // 103W is equal to Default Icon
				eventlog(eventlog_level_info, __FUNCTION__, "[%d] Set icon packet to DEFAULT ICON [%4.4s]", conn_get_socket(c), user_icon);
			}
			else{
				std::memcpy(user_icon, &desired_icon, 4);
				eventlog(eventlog_level_info, __FUNCTION__, "[%d] Set icon packet to ICON [%s]", conn_get_socket(c), user_icon);
			}

			account = conn_get_account(c);
			
			// ICON SWITCH HACK PROTECTION
			if (check_user_icon(account, user_icon) == 0)
			{
				std::strcpy(user_icon, "1O3W"); // set icon to default
				eventlog(eventlog_level_info, __FUNCTION__, "[%s] \"%s\" ICON SWITCH hack attempt, icon set to default ", conn_get_username(c), user_icon);
				//conn_set_state(c,conn_state_destroy); // dont kill user session
			}

			account_set_user_icon(conn_get_account(c), conn_get_clienttag(c), user_icon);
			//FIXME: Still need a way to 'refresh the user/channel'
			//_handle_rejoin_command(conn_get_account(c),"");
			/* ??? channel_update_userflags() */
			conn_update_w3_playerinfo(c);

			channel_rejoin(c);
			return 0;
		}