Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

IpDrv.OnlinePlaylistManager


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
/**
 * Copyright 1998-2011 Epic Games, Inc. All Rights Reserved.
 */

/**
 * This class holds the set of playlists that the game exposes, handles
 * downloading updates to the playlists via MCP/TitleFiles, and creates the
 * game settings objects that make up a playlist
 */
class OnlinePlaylistManager extends Object
	native
	inherits(FTickableObject)
	config(Playlist);

/** Contains a game settings class name to load and instance using the specified URL to override defaults */
struct native ConfiguredGameSetting
{
	/** The unique (within the playlist) id for this game setting */
	var int GameSettingId;
	/** The name of the class to load and instance */
	var string GameSettingsClassName;
	/** The URL to use to replace settings with (see UpdateFromURL()) */
	var string Url;
	/** Holds the object that was created for this entry in a playlist */
	var transient OnlineGameSettings GameSettings;
};

/** Allows for per playlist inventory swapping */
struct native InventorySwap
{
	/** The inventory to replace */
	var name Original;
	/** The inventory to replace it with */
	var string SwapTo;
};

/** A playlist contains 1 or more game configurations that players can choose between */
struct native Playlist
{
	/** Holds the list of game configurations that are part of this playlist */
	var array<ConfiguredGameSetting> ConfiguredGames;
	/** The unique id for this playlist */
	var int PlaylistId;
	/** The load balance id for this playlist */
	var int LoadBalanceId;
	/** The string to use to lookup the display name for this playlist */
	var string LocalizationString;
	/** The set of content/maps (or DLC bundles) that must be present in order to play on this playlist */
	var array<int> ContentIds;
	/** The number of players per team if different from the defaults */
	var int TeamSize;
	/** The number of teams per match if different from the defaults */
	var int TeamCount;
	/** The max party size for this playlist if different from the team size */
	var int MaxPartySize;
	/** The string to use in the UI for this playlist */
	var string Name;
	/** URL to append to the MP options in GameInfo.InitGame() */
	var string Url;
	/** Whether this playlist is arbitrated or not */
	var bool bIsArbitrated;
	/** Whether dedicated server searches are supported with this playlist */
	var bool bDisableDedicatedServerSearches;
	/** The custom map cycle for this playlist */
	var array<name> MapCycle;
	/** The list of inventory swaps for the playlist */
	var array<InventorySwap> InventorySwaps;
};

/** This is the complete set of playlists available to choose from */
var config array<Playlist> Playlists;

/** The file names to request when downloading a playlist from MCP/TMS/etc */
var array<string> PlaylistFileNames;

/** The set of UIDataStore_GameResource objects to refresh once the download has completed */
var config array<name> DatastoresToRefresh;

/** Used to know when we should finalize the objects */
var int DownloadCount;

/** Incremented when successful to determine whether to update at all */
var int SuccessfulCount;

/** The version number of the playlist that was downloaded */
var config int VersionNumber;

/** Holds the overall and per region playlist population numbers */
struct native PlaylistPopulation
{
	/** The unique id for this playlist */
	var int PlaylistId;
	/** The total across all regions */
	var int WorldwideTotal;
	/** The total for the player's region */
	var int RegionTotal;
};

/** The list of playlists and the number of players in them */
var config array<PlaylistPopulation> PopulationData;

/** The total number of players across all playlists worldwide */
var int WorldwideTotalPlayers;

/** The total number of players across all playlists in the region */
var int RegionTotalPlayers;

/** Cached object ref that we use for accessing the TitleFileInterface */
var transient OnlineTitleFileInterface TitleFileInterface;

/** The name of the population data file to request */
var string PopulationFileName;

/** The next time the playlist population data needs to be sent */
var transient float NextPlaylistPopulationUpdateTime;

/** How often (in seconds) we should update the population data */
var config float PlaylistPopulationUpdateInterval;

/** The lowest number playlist id to report to the backend. Used to turn off "not mp" playlist ids */
var config int MinPlaylistIdToReport;

/** The playlist id that is being played */
var transient int CurrentPlaylistId;

/** The name of the interface to request as our upload object */
var config name EventsInterfaceName;

/** The datacenter id to use for this machine */
var config int DataCenterId;

/** The name of the datacenter file to request */
var string DataCenterFileName;

cpptext
{
// FTickableObject interface

	/**
	 * Returns whether it is okay to tick this object. E.g. objects being loaded in the background shouldn't be ticked
	 * till they are finalized and unreachable objects cannot be ticked either.
	 *
	 * @return	TRUE if tickable, FALSE otherwise
	 */
	virtual UBOOL IsTickable() const
	{
		// We cannot tick objects that are unreachable or are in the process of being loaded in the background.
		return !HasAnyFlags(RF_Unreachable | RF_AsyncLoading);
	}

	/**
	 * Used to determine if an object should be ticked when the game is paused.
	 *
	 * @return always TRUE as networking needs to be ticked even when paused
	 */
	virtual UBOOL IsTickableWhenPaused() const
	{
		return TRUE;
	}

	/**
	 * Determines whether an update of the playlist population information is needed or not
	 *
	 * @param DeltaTime the amount of time that has passed since the last tick
	 */
	virtual void Tick(FLOAT DeltaTime);
}

/**
 * Delegate fired when the playlist has been downloaded and processed
 */
delegate OnReadPlaylistComplete();

/**
 * Reads the playlist from either MCP or from some form of title storage
 */
function DownloadPlaylist()
{
	local OnlineSubsystem OnlineSub;
	local int FileIndex;

	if (SuccessfulCount == 0)
	{
		OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
		if (OnlineSub != None &&
			OnlineSub.Patcher != None)
		{
			// Request notification of file downloads
			OnlineSub.Patcher.AddReadFileDelegate(OnReadTitleFileComplete);
			// Reset our counts since we might be re-downloading
			DownloadCount = 0;
			SuccessfulCount = 0;
			// Don't rebuild the list of files when already there
			if (PlaylistFileNames.Length == 0)
			{
				DetermineFilesToDownload();
			}
			// Iterate the files that we read and request them
			for (FileIndex = 0; FileIndex < PlaylistFileNames.Length; FileIndex++)
			{
				OnlineSub.Patcher.AddFileToDownload(PlaylistFileNames[FileIndex]);
			}
			// Download the datacenter file now too
			if (class'WorldInfo'.static.GetWorldInfo().NetMode != NM_DedicatedServer)
			{
				ReadDataCenterId();
			}
			// Force an update of the playlist population data
			NextPlaylistPopulationUpdateTime = PlaylistPopulationUpdateInterval;
		}
		else
		{
			`Log("No online layer present, using defaults for playlist",,'DevMCP');
			// Initialize all playlist objects with defaults
			FinalizePlaylistObjects();
			// Notify the completion
			OnReadPlaylistComplete();
		}
	}
	else
	{
		// Notify the completion
		OnReadPlaylistComplete();
	}
}

/** Uses the current loc setting and game ini name to build the download list */
native function DetermineFilesToDownload();

/**
 * Notifies us when the download of the playlist file is complete
 *
 * @param bWasSuccessful true if the download completed ok, false otherwise
 * @param FileName the file that was downloaded (or failed to)
 */
function OnReadTitleFileComplete(bool bWasSuccessful,string FileName)
{
	local OnlineSubsystem OnlineSub;
	local int FileIndex;

	for (FileIndex = 0; FileIndex < PlaylistFileNames.Length; FileIndex++)
	{
		if (PlaylistFileNames[FileIndex] == FileName)
		{
			// Increment how many we've downloaded
			DownloadCount++;
			SuccessfulCount += int(bWasSuccessful);
			// If they have all been downloaded, rebuild the playlist
			if (DownloadCount == PlaylistFileNames.Length)
			{
				if (SuccessfulCount != DownloadCount)
				{
					`Log("PlaylistManager: not all files downloaded correctly, using defaults where applicable",,'DevMCP');
				}
				// Rebuild the playlist and update any objects/ui
				FinalizePlaylistObjects();
				// Notify our requester
				OnReadPlaylistComplete();

				// Remove the delegates since we are done
				OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
				if (OnlineSub != None &&
					OnlineSub.Patcher != None)
				{
					OnlineSub.Patcher.ClearReadFileDelegate(OnReadTitleFileComplete);
				}
			}
		}
	}
}

/**
 * Uses the configuration data to create the requested objects and then applies any
 * specific game settings changes to them
 */
native function FinalizePlaylistObjects();

/**
 * Finds the game settings object associated with this playlist and game settings id
 *
 * @param PlaylistId the playlist we are searching
 * @param GameSettingsId the game settings id being searched for
 *
 * @return the game settings specified or None if not found
 */
function OnlineGameSettings GetGameSettings(int PlaylistId,int GameSettingsId)
{
	local int PlaylistIndex;
	local int GameIndex;

	// Find the matching playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		// Search through the registered games for this playlist
		for (GameIndex = 0; GameIndex < Playlists[PlaylistIndex].ConfiguredGames.Length; GameIndex++)
		{
			if (Playlists[PlaylistIndex].ConfiguredGames[GameIndex].GameSettingId == GameSettingsId)
			{
				return Playlists[PlaylistIndex].ConfiguredGames[GameIndex].GameSettings;
			}
		}
	}
	return None;
}

/**
 * Determine if any game settings exist for the given playlistid
 *
 * @param PlaylistId playlist to check for game settings
 * @return TRUE if game settings exist for the given id
 */
function bool HasAnyGameSettings(int PlaylistId)
{
	local int PlaylistIndex;
	local int GameIndex;

	// Find the matching playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		// Search through the registered games for this playlist
		for (GameIndex = 0; GameIndex < Playlists[PlaylistIndex].ConfiguredGames.Length; GameIndex++)
		{
			if (Playlists[PlaylistIndex].ConfiguredGames[GameIndex].GameSettings != None)
			{
				return true;
			}
		}
	}
	return false;
}
			
/*
 * Determines if this playlist can be found on dedicated servers
 *
 * @param PlaylistId playlist to check for dedicated server support
 */
function bool PlaylistSupportsDedicatedServers(int PlaylistId)
{
	local int PlaylistIndex;

	// Find the playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		// Search through the registered games for this playlist
		return !Playlists[PlaylistIndex].bDisableDedicatedServerSearches;
	}
	return false;
}

/**
 * Finds the team information for the specified playlist and returns it in the out vars
 *
 * @param PlaylistId the playlist being searched for
 * @param TeamSize out var getting the number of players per team
 * @param TeamCount out var getting the number of teams per match
 * @param MaxPartySize out var getting the number of players per party
 */
function GetTeamInfoFromPlaylist(int PlaylistId,out int TeamSize,out int TeamCount,out int MaxPartySize)
{
	local int PlaylistIndex;

	TeamSize = 0;
	TeamCount = 0;
	// Find the playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		TeamSize = Playlists[PlaylistIndex].TeamSize;
		TeamCount = Playlists[PlaylistIndex].TeamCount;
		MaxPartySize = Playlists[PlaylistIndex].MaxPartySize;
		// If it wasn't set up for this playlist, use the team size
		if (MaxPartySize == 0)
		{
			MaxPartySize = TeamSize;
		}
	}
}

/**
 * Determine the load balance id for the specified playlist and returns it in the out vars.
 * The load balance id can be used to change the match mode during a search.
 *
 * @param PlaylistId the playlist being searched for
 * @param LoadBalanceId out var getting the id for load balancing
 */
function GetLoadBalanceIdFromPlaylist(int PlaylistId,out int LoadBalanceId)
{
	local int PlaylistIndex;

	LoadBalanceId = 0;
	// Find the playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		LoadBalanceId = Playlists[PlaylistIndex].LoadBalanceId;
	}		
}

/**
 * Determine if the given playlist entry is arbitrated or not
 *
 * @param PlaylistId the playlist being searched for
 * @return TRUE if the playlist is arbitrated
 */
function bool IsPlaylistArbitrated(int PlaylistId)
{
	local int PlaylistIndex;

	// Find the playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		return Playlists[PlaylistIndex].bIsArbitrated;
	}
	return false;
}

/**
 * Finds the specified playlist and returns any additional URL options
 *
 * @param PlaylistId the playlist being searched for
 *
 * @return the URL string associated with this playlist
 */
function string GetUrlFromPlaylist(int PlaylistId)
{
	local int PlaylistIndex;

	// Find the playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		return Playlists[PlaylistIndex].Url;
	}
	return "";
}

/**
 * Finds the specified playlist and returns the map cycle for it
 *
 * @param PlaylistId the playlist being searched for
 * @param MapCycle the out var that gets the map cycle
 */
function GetMapCycleFromPlaylist(int PlaylistId,out array<name> MapCycle)
{
	local int PlaylistIndex;

	// Find the playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		// Don't overwrite if there isn't one specified
		if (Playlists[PlaylistIndex].MapCycle.Length > 0)
		{
			MapCycle = Playlists[PlaylistIndex].MapCycle;
		}
	}
}

/**
 * Searches for a per playlist inventory swap
 *
 * @param PlaylistId the playlist we are checking for swaps in
 * @param SourceInventory the source item we are checking for swapping
 *
 * @return the swapped item or the original if not found
 */
function class<Inventory> GetInventorySwapFromPlaylist(int PlaylistId,class<Inventory> SourceInventory)
{
	local int PlaylistIndex;
	local int SwapIndex;

	// Find the playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		SwapIndex = Playlists[PlaylistIndex].InventorySwaps.Find('Original',SourceInventory.Name);
		if (SwapIndex != INDEX_NONE)
		{
			return class<Inventory>(DynamicLoadObject(Playlists[PlaylistIndex].InventorySwaps[SwapIndex].SwapTo,class'class'));
		}
	}
	return SourceInventory;
}

/**
 * Finds the specified playlist and return the content ids in the out var
 *
 * @param PlaylistId the playlist being searched for
 * @param ContentIds the list to set the content ids in
 */
function GetContentIdsFromPlaylist(int PlaylistId,out array<int> ContentIds)
{
	local int PlaylistIndex;

	// Find the matching playlist
	PlaylistIndex = Playlists.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		ContentIds = Playlists[PlaylistIndex].ContentIds;
	}
}

/**
 * Allows the playlists to be re-requested from the server
 */
function Reset()
{
	local OnlineSubsystem OnlineSub;

	DownloadCount = 0;
	SuccessfulCount = 0;

	// Clear out any cached file contents if present
	OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
	if (OnlineSub != None &&
		OnlineSub.Patcher != None)
	{
		OnlineSub.Patcher.ClearCachedFiles();
	}
}

/**
 * Reads the player population data for playlists by region
 */
function ReadPlaylistPopulation()
{
	local OnlineSubsystem OnlineSub;

	// Get the object to download with the first time
	if (TitleFileInterface == None)
	{
		OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
		if (OnlineSub != None)
		{
			// Ask for the interface by name
			TitleFileInterface = OnlineSub.TitleFileInterface;
		}
	}
	if (TitleFileInterface != None)
	{
		// Force an update of this information
		TitleFileInterface.ClearDownloadedFile(PopulationFileName);
		// Set the callback for notifications of files completing
		TitleFileInterface.AddReadTitleFileCompleteDelegate(OnReadPlaylistPopulationComplete);
		// Request the playlist population numbers
		TitleFileInterface.ReadTitleFile(PopulationFileName);
	}
	else
	{
		`warn("Cannot download playlist population due to missing TitleFileInterface object");
	}
}

/**
 * Notifies us when the download of a file is complete
 *
 * @param bWasSuccessful true if the download completed ok, false otherwise
 * @param FileName the file that was downloaded (or failed to)
 */
function OnReadPlaylistPopulationComplete(bool bWasSuccessful,string FileName)
{
	local array<byte> FileData;

	if (FileName == PopulationFileName)
	{
		if (bWasSuccessful)
		{
			// Read the contents so that they can be processed
			if (TitleFileInterface.GetTitleFileContents(FileName,FileData))
			{
				ParsePlaylistPopulationData(FileData);
			}
		}
		else
		{
			`Log("Failed to download the file ("$FileName$") from TitleFileInterface",,'DevMCP');
		}
		// Notify any listener
		OnPlaylistPopulationDataUpdated();
	}
}

/**
 * Tells the listener when playlist population data was updated
 */
delegate OnPlaylistPopulationDataUpdated();

/**
 * Converts the data into the structure used by the playlist manager
 *
 * @param Data the data that was downloaded
 */
native function ParsePlaylistPopulationData(const out array<byte> Data);

/**
 * Finds the population information for the specified playlist and returns it in the out vars
 *
 * @param PlaylistId the playlist being searched for
 * @param WorldwideTotal out var getting the number of players worldwide
 * @param RegionTotal out var getting the number of players in this region
 */
function GetPopulationInfoFromPlaylist(int PlaylistId,out int WorldwideTotal,out int RegionTotal)
{
	local int PlaylistIndex;

	WorldwideTotal = 0;
	RegionTotal = 0;
	// Find the playlist
	PlaylistIndex = PopulationData.Find('PlaylistId',PlaylistId);
	if (PlaylistIndex != INDEX_NONE)
	{
		WorldwideTotal = PopulationData[PlaylistIndex].WorldwideTotal;
		RegionTotal = PopulationData[PlaylistIndex].RegionTotal;
	}
}

/**
 * Called once enough time has elapsed that a playlist update is required
 *
 * @param NumPlayers the numbers of players to report (easier to get at in native)
 */
event SendPlaylistPopulationUpdate(int NumPlayers)
{
	local OnlineEventsInterface EventsInterface;
	local OnlineSubsystem OnlineSub;

	OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
	if (OnlineSub != None)
	{
		EventsInterface = OnlineEventsInterface(OnlineSub.GetNamedInterface(EventsInterfaceName));
		if (EventsInterface != None &&
			NumPlayers > 0)
		{
			`Log("Updating playlist population with PlaylistId="$CurrentPlaylistId$" and NumPlayers="$NumPlayers,,'DevMCP');
			// Send this to the network backend
			EventsInterface.UpdatePlaylistPopulation(CurrentPlaylistId,NumPlayers);
		}
	}
}

/**
 * Asks the network backend which datacenter this machine is to use
 */
function ReadDataCenterId()
{
	local OnlineSubsystem OnlineSub;

	// Get the object to download with the first time
	if (TitleFileInterface == None)
	{
		OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
		if (OnlineSub != None)
		{
			// Ask for the interface by name
			TitleFileInterface = OnlineSub.TitleFileInterface;
		}
	}
	if (TitleFileInterface != None)
	{
		// Set the callback for notifications of files completing
		TitleFileInterface.AddReadTitleFileCompleteDelegate(OnReadDataCenterIdComplete);
		// Request the datacenter id
		TitleFileInterface.ReadTitleFile(DataCenterFileName);
	}
	else
	{
		`warn("Cannot download datacenter id due to missing TitleFileInterface object");
	}
}

/**
 * Notifies us when the download of a file is complete
 *
 * @param bWasSuccessful true if the download completed ok, false otherwise
 * @param FileName the file that was downloaded (or failed to)
 */
function OnReadDataCenterIdComplete(bool bWasSuccessful,string FileName)
{
	local array<byte> FileData;

	if (bWasSuccessful)
	{
		if (FileName == DataCenterFileName)
		{
			// Read the contents so that they can be processed
			if (TitleFileInterface.GetTitleFileContents(FileName,FileData))
			{
				ParseDataCenterId(FileData);
			}
		}
	}
	else
	{
		`Log("Failed to download the file ("$FileName$") from TitleFileInterface",,'DevMCP');
	}
}

/**
 * Converts the data into the datacenter id
 *
 * @param Data the data that was downloaded
 */
native function ParseDataCenterId(const out array<byte> Data);

defaultproperties
{
	PopulationFileName="PlaylistPopulationData.ini"
	DataCenterFileName="DataCenter.Id"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ti 15-2-2011 19:59:02.000 - Creation time: ti 22-3-2011 19:57:08.853 - Created with UnCodeX