Cogito, ergo sum

Legacy:LadderGameRules

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT2003 :: Object >> Actor >> Info >> GameRules >> LadderGameRules (Ladder1.46)
  1. //-----------------------------------------------------------
  2. // Ladder.LadderGameRules
  3. //
  4. // Class responsible for maintenance of all profiles
  5. //
  6. // Handles all interface between game & profiles
  7. // Handles all interaction from webadmin interface & adminmenu interface
  8. //-----------------------------------------------------------
  9.  
  10. class LadderGameRules extends GameRules
  11. 	config;
  12.  
  13. const LOGNAME	= 'LadderGameRules';
  14.  
  15. // Handles all ServerActors with PlayInfo
  16. var ConfigMaster				SAManager;
  17.  
  18. // Server was shut down before game was finished
  19. var config bool					bDirtyStart;
  20.  
  21. // Profiles
  22. struct Profile
  23. {
  24. 	var string 					ProfileName;	// Name of Profile
  25. 	var bool 					bActive;		// This profile is currently in use
  26. 	var bool					bReload;		// This profile was the last profile to be used
  27. };
  28.  
  29. // Profile Storage
  30. var protected config array<Profile> 	Profiles;
  31. var protected config int				NumRemainingMatches;
  32.  
  33. // Profile Usage Variables
  34. var array<ProfileConfigSet> 	LadderProfiles;
  35. var ProfileConfigSet 			CurrentProfile;			// Currently Active Profile
  36. var 		StringArray 		AllLadderProfiles;		// Only used for sorting in switch profiles by name
  37. var 		StringArray			ProfileMaps;			// Holds maplist for switching server to new profile
  38. var 		string 				ProfileMutators;		// Holds mutator string for switch server to new profile
  39. var			array<string>		ProfileActors;
  40. var 		bool				bWaitingToSwitch;		// Waiting for end of match to switch server to new profile
  41. var			int					Index;					// Index of currently active profile
  42.  
  43. var string 						LadderProfile${1}< ${3} >
  44. var string						DefaultProfileName;
  45. var class<ProfileConfigSet>		Profile${1}< ${3} >
  46.  
  47. struct CommandLineParam { var string ParamName; var string Value; };
  48. var array<CommandLineParam> CommandLineOptions;
  49.  
  50. // Localization
  51. var localized string ShutdownWhileTemporary;
  52. var localized string ShutdownWhilePermanent;
  53. var localized string ShutdownWhileWaiting;
  54. var localized string ShutdownRemainingMatches;
  55. var localized string ShutdownResumingTemporary;
  56. var localized string ShutdownResumingPermanent;
  57. var localized string ShutdownTrackingCorrupted;
  58.  
  59. var localized string EndOfGame;
  60. var localized string EndofGameIntercepting;
  61. var localized string EndofGameNoRemainingMatches;
  62. var localized string OverridingURL;
  63.  
  64. // Error Messages
  65. var localized string BadProfile${1}< ${3} >
  66. var localized string CannotRemoveActive;
  67. var localized string PreviousProfileRemoved;
  68.  
  69. // Warning Messages
  70. var localized string EmptyMaplist;
  71. var localized string InvalidMaplist;
  72. var localized string CancellingProfile;
  73. var localized string BadIndex;
  74.  
  75. // Turns out there is a bug with the 2166 (and probably earlier) version
  76. // of the MatchEnded state of DeathMatch:
  77. // Once Level.TimeSeconds > EndTime + RestartWait, MatchEnded.Timer() begins
  78. // calling RestartGame().  This results in RestartGame (and thus GameRules.HandleRestartGame())
  79. // getting called multiple times.
  80. var bool						bRestartCalled;
  81.  
  82. //function bool AddTextParam(string ParamName, optional string DefaultValue, optional bool bAddIfNotExists)
  83. //{
  84. //	local int i;
  85. //	local TextParam TmpT;
  86.  
  87. //	for (
  88. //}
  89.  
  90. function bool AddBoolParam(string ParamName, optional bool DefaultValue, optional bool bAddIfNotExists);
  91. function bool AddSelectParam(string ParamName, array<string> VarOptions, optional bool bAddIfNotExists);
  92.  
  93. event Tick(float DeltaTime)
  94. {
  95. 	if (Level != None && Level.NextURL != "")
  96. 	{
  97. 		bDirtyStart = False;
  98. 		SaveConfig();
  99. 		Disable('Tick');
  100. 	}
  101. }
  102.  
  103. event PreBeginPlay()
  104. {
  105. 	ProfileClass = class<ProfileConfigSet>(DynamicLoadObject(LadderProfileClass, class'Class'));
  106. 	if (ProfileClass == None)
  107. 	{
  108. 		log(BadProfileClass@"'"$LadderProfileClass$"'",LOGNAME);
  109. 		Destroy();
  110. 		return;
  111. 	}
  112.  
  113. // Initialize String Arrays
  114. 	AllLadderProfiles = new(None) class'SortedStringArray';
  115. 	ProfileMaps = new(None) class'StringArray';
  116. 	InitializeProfileArray();
  117.  
  118. 	Super.PreBeginPlay();
  119. }
  120.  
  121. event PostBeginPlay()
  122. {
  123. 	local int i, j, Matches;
  124.  
  125. 	i = 0 - 1;
  126. 	j = 0 - 1;
  127.  
  128. 	if (Level.Game.BaseMutator != None && ConfigMaster(Level.Game.BaseMutator.NextMutator) != None)
  129. 		SAManager = ConfigMaster(Level.Game.BaseMutator.NextMutator);
  130. 	Super.PostBeginPlay();
  131.  
  132. 	if (bDirtyStart)
  133. 	{
  134. 		i = FindPreviousProfile();
  135. 		j = FindActiveProfile();
  136. 		Matches = NumRemainingMatches;
  137. 		if (i >= 0) // Found a previous profile
  138. 		{
  139. 			if (j >= 0)  // Found an active profile
  140. 			{
  141. 				if ( Matches > 0 )  // Temporary profile was active
  142. 				{
  143. 					log(ShutdownWhileTemporary@"'"$Profiles[j].ProfileName$"'.",LOGNAME);
  144. 					log(ShutdownRemainingMatches$":"@NumRemainingMatches$"."@ShutdownResumingTemporary,LOGNAME);
  145. 					ApplyProfile( j, Matches );
  146. 				}
  147.  
  148. 				else
  149. 				{
  150. 					log(ShutdownWhileTemporary@"'"$Profiles[j].ProfileName$"'.",LOGNAME);
  151. 					log(ShutdownRemainingMatches$":"@NumRemainingMatches$"."@ShutdownResumingPermanent@"'"$Profiles[i].ProfileName$"'.",LOGNAME);
  152. 					ApplyProfile( i, 0);
  153. 				}
  154.  
  155. 			}
  156. 			else
  157. 			{
  158. 				log(ShutdownWhileWaiting,LOGNAME);	// Shutdown while waiting to apply temporary profile - cancel
  159. 				if ( Matches > 0 )
  160. 				{
  161. 					ResetTrackingValues();
  162. 					ApplyProfile(i,Matches);
  163. 				}
  164. 				else
  165. 				{
  166. 					ResetTrackingValues();
  167. 					ApplyProfile(i,0);
  168. 				}
  169. 			}
  170. 		}
  171. 		else if (j >= 0) // no reload, but found active profile
  172. 		{
  173. 			log(ShutdownWhilePermanent@"'"$Profiles[j].ProfileName$"'."@ShutdownResumingPermanent@"'"$Profiles[j].ProfileName$"'.",LOGNAME);
  174. 			ApplyProfile( j, 0 );
  175. 		}
  176.  
  177. 		else if (Matches > 0)	// no reload, no active
  178. 		{
  179. 			NumRemainingMatches = 0;
  180. 			SaveConfig();
  181. 		}
  182. 	}
  183. 	else
  184. 	{
  185. 		bDirtyStart = True;
  186. 		SaveConfig();
  187. 	}
  188. }
  189.  
  190. // Game has ended - even if we want to handle restart, cannot simply
  191. // return True, or GameRulesModifiers later in the list do not recieve
  192. // HandleRestartGame() calls
  193. function bool HandleRestartGame()
  194. {
  195. 	local int i;
  196. 	local bool bHandleRestart;	// True if we are handling restart
  197.  
  198. 	if (bDirtyStart)
  199. 	{
  200. 		bDirtyStart = False;
  201. 		SaveConfig();
  202. 	}
  203.  
  204. 	if (!Level.Game.bChangeLevels || Level.Game.bAlreadyChanged)
  205. 		return Super.HandleRestartGame();
  206.  
  207. 	if (bRestartCalled)
  208. 		return Super.HandleRestartGame();
  209.  
  210. 	else bRestartCalled = True;
  211.  
  212. 	if ( bWaitingToSwitch )
  213. 	{
  214. 		i = FindPreviousProfile();
  215. 		if (i >= 0)
  216. 		{
  217. 			log(EndOfGame,LOGNAME);
  218. 			log(EndofGameIntercepting@"'"$Profiles[i].ProfileName$"'.",LOGNAME);
  219. 			ApplyProfile(i,NumRemainingMatches);
  220. 			bHandleRestart = True;
  221. 		}
  222. 	}
  223.  
  224. 	else if ( NumRemainingMatches > 0)
  225. 	{
  226. 		if (NumRemainingMatches == 1)
  227. 		{
  228. 		// Time to switch server to previous profile
  229. 			i = FindPreviousProfile();
  230. 			if (i >= 0)
  231. 			{
  232. 				log(EndOfGame,LOGNAME);
  233. 				log(EndOfGameNoRemainingMatches,LOGNAME);
  234. 				log(EndOfGameIntercepting@"'"$Profiles[i].ProfileName$"'.",LOGNAME);
  235. 				ApplyProfile(i,0);
  236. 				bHandleRestart = true;
  237. 			}
  238. 			else
  239. 			{
  240. 				log(EndOfGame,LOGNAME);
  241. 				log(PreviousProfileRemoved,LOGNAME);
  242. 			}
  243. 		}
  244.  
  245. 		if ( !bHandleRestart )
  246. 		{
  247. 			NumRemainingMatches--;
  248. 			SaveConfig();
  249. 		}
  250. 	}
  251.  
  252. 	// Returns true if either one is true
  253. 	return (Super.HandleRestartGame() || bHandleRestart);
  254. }
  255.  
  256. //#########################################
  257. // Profile Management
  258. //
  259.  
  260. // Applies selected profile immediately
  261. function ApplyProfile(coerce int NewProfileIndex, int NumberOfMatches)
  262. {
  263. 	local int idx,i,j;
  264. 	local ProfileConfigSet TempPCS;
  265. 	local array<string> TempArr;
  266. 	local string GameType,ShortName,FirstMap,Tmp,TmpV;
  267.  
  268. 	idx = ActivateProfile(NewProfileIndex, NumberOfMatches > 0);
  269.  
  270. 	if (idx < 0)
  271. 	{
  272. 		Warn(CancellingProfile@"'"$Profiles[NewProfileIndex].ProfileName$"'"@"("$BadIndex$")");
  273. 		if (ActivateProfile(Index) < 0)
  274. 			ResetTrackingValues();
  275.  
  276. 		return;
  277. 	}
  278.  
  279. 	TempPCS = LadderProfiles[idx];
  280. 	class'Ladder.CommandLineParams'.default.bRejectPlayInfo = True;
  281. 	TempPCS.StartEdit();
  282. 	GameType = string(TempPCS.GetGameClass());
  283.  
  284. // Set the maplist
  285. 	ProfileMaps.Reset();
  286. 	TempArr = TempPCS.GetUsedMaps();
  287. 	if (TempArr.Length == 0)
  288. 	{
  289. 		Warn(CancellingProfile@"'"$Profiles[idx].ProfileName$"'"@"("$EmptyMaplist$")");
  290. 		if (Index == idx) DeactivateProfile(Index);
  291.  
  292. 		else if (ActivateProfile(Index, False) < 0)
  293. 			ResetTrackingValues();
  294.  
  295. 		TempPCS.EndEdit(False);
  296. 		return;
  297. 	}
  298.  
  299. 	NumRemainingMatches = NumberOfMatches;
  300. 	for (i=0;i<TempArr.Length;i++)
  301. 		ProfileMaps.Add(string(i),TempArr[i]);
  302.  
  303. 	FirstMap = ProfileMaps.getTag(0);
  304. 	UpdateDefaultMaps(GameType,ProfileMaps);
  305. //log("TempPCS:"$TempPCS@"ConfigManager:"$SAManager,'ApplyProfile');
  306. // Set the mutators
  307. 	ProfileMutators = "";
  308. 	ProfileMutators = UpdateMutatorString(TempPCS);
  309.  
  310. // Set the server actors
  311. 	ProfileActors = TempPCS.GetUsedServerActors();
  312. 	TempArr = SAManager.GetAllManagedActors();
  313. 	for (i = 0; i < TempArr.Length; i++)
  314. 	{
  315. 		Tmp = Left(TempArr[i],InStr(TempArr[i],","));
  316. 		for (j = 0; j < ProfileActors.Length; j++)
  317. 		{
  318. 			if (Tmp ~= ProfileActors[j])
  319. 				break;
  320.  
  321. 		}
  322.  
  323. 		if (j < ProfileActors.Length)
  324. 			EnableManagedActor(Tmp);
  325.  
  326. 		else DisableManagedActor(Tmp);
  327. 	}
  328.  
  329. // Set the PlayInfo
  330. 	for (i=0;i<TempPCS.Count();i++)
  331. 	{
  332. 		Tmp = TempPCS.GetProfileParamName(i);
  333. 		TmpV = TempPCS.GetProfileParam(i);
  334. 		ShortName = GetItemName(Tmp);
  335.  
  336. 	// If this parameter was specified at the URL,
  337. 	// make sure to replace it, otherwise the URL value will
  338. 	// override the profile value
  339. 		if (HasURLOption(ShortName))
  340. 		{
  341. 			log(OverridingURL@ShortName$".",LOGNAME);
  342. 			UpdateURL(ShortName, TmpV, false);
  343. 		}
  344.  
  345. 		else if (!TempPCS.SetNamedParam(Tmp, TmpV))
  346. 		{
  347. 			for (j = 0; j < CommandLineOptions.Length; j++)
  348. 			{
  349. 				if (Tmp ~= CommandLineOptions[j].ParamName && TmpV != "")
  350. 					UpdateURL(ShortName, TmpV, false);
  351. 			}
  352. 		}
  353. 	}
  354.  
  355. 	TempPCS.SavePI();
  356. 	TempPCS.EndEdit(False);
  357. 	if (bDirtyStart)
  358. 	{
  359. 		bDirtyStart = False;
  360. 		SaveConfig();
  361. 	}
  362.  
  363. 	Level.ServerTravel(FirstMap$"?Game="$GameType$"?Mutator="$ProfileMutators, False);
  364. }
  365.  
  366. // Applies selected profile at the end of the current match
  367. function bool WaitApplyProfile(coerce int NewProfileIndex, int NumberOfMatches)
  368. {
  369. 	local int i;
  370. 	local int CurrentActive;
  371.  
  372. 	CurrentActive = FindActiveProfile();
  373. // Check to make sure we aren't attempting to switch to the currently active profile
  374. 	if ( NewProfileIndex == CurrentActive)
  375. 		return false;
  376.  
  377. // Clean up any other profiles that were supposed to be reloaded
  378. 	i = FindPreviousProfile();
  379. 	if (i >= 0) Profiles[i].bReload = False;
  380. 	if (CurrentActive >= 0) Profiles[CurrentActive].bActive = False;
  381. 	Profiles[NewProfileIndex].bReload = True;
  382. 	bWaitingToSwitch = True;
  383. 	NumRemainingMatches = NumberOfMatches;
  384. 	SaveConfig();
  385. 	return true;
  386. }
  387.  
  388. // Add new profile
  389. function ProfileConfigSet AddProfile(string PCSName, optional string GameType)
  390. {
  391. 	local Profile TempP;
  392. 	local int i, NumProfiles;
  393.  
  394. 	NumProfiles = Profiles.Length;
  395. 	for (i = 0; i < NumProfiles; i++)
  396. 		if (Profiles[i].ProfileName ~= PCSName)
  397. 			return None;
  398.  
  399. 	TempP.ProfileName = PCSName;
  400. 	Profiles[Profiles.Length] = TempP;
  401.  
  402. 	LoadProfile(TempP,GameType);
  403. 	SaveConfig();
  404.  
  405. 	return LadderProfiles[NumProfiles];
  406. }
  407.  
  408. // Copy profile - NewProfileName must be unique
  409. function bool CopyProfile(int SourceProfileIndex, string NewProfileName)
  410. {
  411. 	local ProfileConfigSet PCS;
  412.  
  413. 	if (SourceProfileIndex < 0 || SourceProfileIndex >= Profiles.Length)
  414. 		return false;
  415.  
  416. 	if (LadderProfiles[SourceProfileIndex] == None)
  417. 		return false;
  418.  
  419. 	PCS = AddProfile(NewProfileName);
  420. 	if (PCS != None)
  421. 	{
  422. 		LadderProfiles[SourceProfileIndex].StartEdit();
  423. 		PCS.StartEdit();
  424. 		PCS.ReplaceWith(LadderProfiles[SourceProfileIndex]);
  425. 		PCS.EndEdit(True);
  426. 		LadderProfiles[SourceProfileIndex].EndEdit(False);
  427. 		return true;
  428. 	}
  429. 	return false;
  430. }
  431.  
  432. // Remove profile
  433. function bool RemoveProfile(int idx)
  434. {
  435. 	local ProfileConfigSet LastPCS;
  436. 	local int LastIDX;
  437.  
  438. 	if (idx < 0 || idx >= LadderProfiles.Length)
  439. 		return false;
  440.  
  441. 	if (Profiles[idx].bActive)
  442. 	{
  443. 		log(CannotRemoveActive,LOGNAME);
  444. 		return false;
  445. 	}
  446.  
  447. 	LastIDX = LadderProfiles.Length - 1;
  448. 	LastPCS = LadderProfiles[LastIDX];
  449. 	LastPCS.StartEdit();
  450. 	if (idx < LastIDX)
  451. 	{
  452. 		Profiles[idx] = Profiles[LastIDX];
  453.  
  454. 		LadderProfiles[idx].StartEdit();
  455. 		LadderProfiles[idx].ReplaceWith(LastPCS);
  456. 		LadderProfiles[idx].EndEdit(True);
  457.  
  458. 		AllLadderProfiles.Remove(AllLadderProfiles.FindItemId(string(idx)));
  459. 		AllLadderProfiles.Add(string(idx),Profiles[LastIDX].ProfileName);
  460. 	}
  461.  
  462. 	LastPCS.Wipe();
  463. 	LastPCS.EndEdit(True);
  464. 	Profiles.Remove(LastIDX,1);
  465. 	LadderProfiles.Remove(LastIDX,1);
  466. 	AllLadderProfiles.Remove(AllLadderProfiles.FindItemId(string(LastIDX)));
  467. 	SaveConfig();
  468. 	return true;
  469. }
  470.  
  471. // Returns index of currently active profile
  472. function int FindActiveProfile()
  473. {
  474. 	local int i;
  475.  
  476. 	if (Index < -1)
  477. 	{
  478. 		for (i=0;i<Profiles.Length;i++)
  479. 			if (Profiles[i].bActive)
  480. 				Index = i;
  481.  
  482. 		if (Index < -1) Index++;
  483. 	}
  484.  
  485. 	return Index;
  486. }
  487.  
  488. // Returns index of previously active profile
  489. function int FindPreviousProfile()
  490. {
  491. 	local int i;
  492.  
  493. 	for (i=0;i<Profiles.Length;i++)
  494. 		if (Profiles[i].bReload)
  495. 			return i;
  496.  
  497. 	return -1;
  498. }
  499.  
  500. //#####################################################
  501. // Profile Interface
  502. //
  503.  
  504. // Returns an array of map names that in the maplist for this profile
  505. function array<string> GetProfileMaps(optional string CurrentProfileItem)
  506. {
  507. 	local int j;
  508. 	local ProfileConfigSet PCS;
  509. 	local array<string> TempMaps;
  510.  
  511. 	if (CurrentProfileItem != "")
  512. 	{
  513. 		j = int(CurrentProfileItem);
  514. 		PCS = LadderProfiles[j];
  515. 	}
  516.  
  517. 	if (PCS == None && CurrentProfile!=None)
  518. 		PCS = CurrentProfile;
  519.  
  520. 	if (PCS != None)
  521. 		TempMaps = PCS.GetUsedMaps();
  522.  
  523. 	return TempMaps;
  524. }
  525.  
  526. // Returns an array of class names for mutators that this profile will use in the game
  527. function array<string> GetProfileMutators(optional string CurrentProfileItem)
  528. {
  529. 	local int j;
  530. 	local ProfileConfigSet PCS;
  531. 	local array<string> TempString;
  532.  
  533. 	if (CurrentProfileItem != "")
  534. 	{
  535. 		j = int(CurrentProfileItem);
  536. 		PCS = LadderProfiles[j];
  537. 	}
  538.  
  539. 	if (PCS == None && CurrentProfile != None)
  540. 		PCS = CurrentProfile;
  541.  
  542. 	// Query profile for mutators to display
  543. 	if (PCS != none)
  544. 		TempString = PCS.GetUsedMutators();
  545.  
  546. 	return TempString;
  547. }
  548.  
  549. function array<string> GetProfileServerActors(optional string CurrentProfileItem)
  550. {
  551. 	local int j;
  552. 	local ProfileConfigSet PCS;
  553. 	local array<string> Temp;
  554.  
  555. 	if (CurrentProfileItem != "")
  556. 	{
  557. 		j = int(CurrentProfileItem);
  558. 		PCS = LadderProfiles[j];
  559. 	}
  560.  
  561. 	if (PCS == None && CurrentProfile != None)
  562. 		PCS = CurrentProfile;
  563.  
  564. 	if (PCS != None)
  565. 		Temp = PCS.GetUsedServerActors();
  566.  
  567. 	return Temp;
  568. }
  569.  
  570. //#####################################################
  571. // Protected helper functions
  572. //
  573.  
  574. // Clears LadderProfiles array and loads each stored (Profiles array)
  575. // profile to the LadderProfiles array
  576. protected function InitializeProfileArray()
  577. {
  578. 	local int i;
  579.  
  580. 	LadderProfiles.Length = 0;
  581.  
  582. // Load all profiles immediately
  583. 	for (i = 0; i < Profiles.Length; i++)
  584. 		LoadProfile(Profiles[i]);
  585. }
  586.  
  587. // Adds a profile to the LadderProfiles array & initializes the profile
  588. protected function LoadProfile(Profile NewProfile, optional string GameType)
  589. {
  590. 	local int i;
  591.  
  592. 	i = LadderProfiles.Length;
  593. 	LadderProfiles.Length = LadderProfiles.Length + 1;
  594.  
  595. 	LadderProfiles[i] = new(None,"Profile"$string(i)) Profile${1}< ${3} >
  596.  
  597. 	if (LadderProfiles[i].GetGameClass() != None)
  598. 	{
  599. 		LadderProfiles[i].StartEdit();
  600. 		LadderProfiles[i].Wipe();
  601. 		LadderProfiles[i].EndEdit(True);
  602. 	}
  603.  
  604. 	if (GameType == "") LadderProfiles[i].Init(Level);
  605. 	else LadderProfiles[i].Init(Level,GameType);
  606.  
  607. 	AllLadderProfiles.Add(string(i), NewProfile.ProfileName);
  608. }
  609.  
  610. protected function int ActivateProfile(coerce int ProfileId, optional bool bStoreLast)
  611. {
  612. 	local int i,j;
  613.  
  614. 	if (ProfileId < 0 || ProfileId >= Profiles.Length)
  615. 		return -1;
  616.  
  617. 	i = FindActiveProfile();
  618.  
  619. 	if (i == ProfileId) return ProfileId;
  620. 	j = 0 - 1;
  621.  
  622. 	if (i >= 0) j = DeactivateProfile(i);
  623. 	if (j >= 0)
  624. 	{
  625. 		if (bStoreLast) Profiles[j].bReload = True;
  626. 		else Profiles[j].bReload = False;
  627. 	}
  628.  
  629. 	Profiles[ProfileId].bActive = True;
  630. 	Profiles[ProfileId].bReload = False;
  631. 	SaveConfig();
  632. 	return ProfileId;
  633. }
  634.  
  635. protected function int DeactivateProfile(coerce int j)
  636. {
  637. 	if (j < 0 || j > Profiles.Length)
  638. 		return -1;
  639.  
  640. 	Profiles[j].bActive = False;
  641. 	Index = default.Index;
  642. 	return j;
  643. }
  644.  
  645. // Copied from UTServerAdmin - Applies the profile's maplist to the server's maplist
  646. function UpdateDefaultMaps(String GameType, StringArray Maps)
  647. {
  648. 	local class<GameInfo> Game${1}< ${3} >
  649. 	local MapList List;
  650. 	local int i;
  651.  
  652. 	if (Maps == None)
  653. 	{
  654. 		Warn(InvalidMaplist);
  655. 		return;
  656. 	}
  657. 	GameClass = class<GameInfo>(DynamicLoadObject(GameType, class'Class'));
  658. 	if (GameClass != None && GameClass.Default.MapListType != "")
  659. 	{
  660. 		List = Level.Game.GetMapList(GameClass.Default.MapListType);
  661. 		if (List != None)
  662. 		{
  663. 			List.Maps.Length = 0;
  664. 			for (i=0; i<Maps.Count(); i++)
  665. 				List.Maps[i] = Maps.GetTag(i);
  666.  
  667. 			List.MapNum = 0;
  668. 			List.SaveConfig();
  669. 			List.Destroy();
  670. 		}
  671. 	}
  672. }
  673.  
  674. function EnableManagedActor(string ActorName)
  675. {
  676. 	local int i;
  677. 	local string S;
  678. 	local class<AutoLoader> A;
  679. 	local array<string> Arr;
  680.  
  681. 	if (SAManager == None) return;
  682.  
  683. 	for (i = 0; i < SAManager.LoaderClasses.Length; i++)
  684. 	{
  685. 		A = SAManager.LoaderClasses[i].AutoLoader${1}< ${3} >
  686. 		if (A == None) continue;
  687.  
  688. 		Arr = A.static.GetManagedActors();
  689. 		while (Arr.Length > 0)
  690. 		{
  691. 			S = class'wUtils103.wArray'.static.ShiftS(Arr);
  692. 			if (ActorName ~= Left(S, InStr(S,",")))
  693. 			{
  694. 				A.static.EnableLoader(ActorName);
  695. 				return;
  696. 			}
  697. 		}
  698. 	}
  699. }
  700.  
  701. function DisableManagedActor(string ActorName)
  702. {
  703. 	local int i;
  704. 	local string S;
  705. 	local class<AutoLoader> A;
  706. 	local array<string> Arr;
  707.  
  708. 	if (SAManager == None) return;
  709.  
  710. 	for (i = 0; i < SAManager.LoaderClasses.Length; i++)
  711. 	{
  712. 		A = SAManager.LoaderClasses[i].AutoLoader${1}< ${3} >
  713. 		if (A == None) continue;
  714.  
  715. 		Arr = A.static.GetManagedActors();
  716. 		while (Arr.Length > 0)
  717. 		{
  718. 			S = class'wUtils103.wArray'.static.ShiftS(Arr);
  719. 			if (ActorName ~= Left(S, InStr(S,",")))
  720. 			{
  721. 				A.static.DisableLoader(ActorName);
  722. 				return;
  723. 			}
  724. 		}
  725. 	}
  726. }
  727.  
  728. // Replaces the ?mutator= command line parameter with this profile's configured mutators
  729. function string UpdateMutatorString(ProfileConfigSet PCS)
  730. {
  731. 	local array<string> Mutators;
  732. 	local string MutatorString;
  733.  
  734. 	if (PCS == None)
  735. 		return "";
  736.  
  737. 	Mutators = PCS.GetUsedMutators();
  738. 	MutatorString = class'wUtils103.wArray'.static.Join(Mutators,",",True);
  739. 	return MutatorString;
  740. }
  741.  
  742. // Copied from UTServerAdmin and modified
  743. final function bool HasURLOption(string ParamName)
  744. {
  745. 	local string Param, Value;
  746. 	local int i;
  747.  
  748. 	Param = ParamName;
  749. 	while (true)
  750. 	{
  751. 		i = Instr(Param, ".");
  752. 		if (i < 0)
  753. 			break;
  754.  
  755. 		Param = Mid(Param, i+1);
  756. 	}
  757.  
  758. 	Value = Level.GetUrlOption(Param);
  759. 	return Value != "";
  760. }
  761.  
  762. protected function ResetTrackingValues()
  763. {
  764. 	local int i;
  765. 	for (i=0;i<Profiles.Length;i++)
  766. 	{
  767. 		Profiles[i].bActive = False;
  768. 		Profiles[i].bReload = False;
  769. 	}
  770.  
  771. 	NumRemainingMatches = 0;
  772. 	SaveConfig();
  773. }
  774.  
  775. function int GetRemainingMatches()
  776. {
  777. 	return NumRemainingMatches;
  778. }
  779.  
  780. defaultproperties
  781. {
  782. 	Index=-2
  783.     LadderProfileClass="Ladder.ProfileConfigSet"
  784.     ShutdownWhileTemporary="Server was shutdown with active temporary profile"
  785.     ShutdownWhilePermanent="Server was shutdown with active profile"
  786.     ShutdownWhileWaiting="Server was shutdown while waiting to apply a profile. Now applying new profile."
  787.     ShutdownRemainingMatches="Number of matches remaining for this profile"
  788.     ShutdownResumingTemporary="Reactivating temporary profile with remaining number of matches."
  789.     ShutdownResumingPermanent="Reactivating standard profile"
  790.     ShutdownTrackingCorrupted="Profile tracking was corrupted.  Resetting profile tracking values."
  791.     EndOfGame="END OF GAME DETECTED."
  792.     EndofGameIntercepting="Intercepting map change & activating profile"
  793.     EndofGameNoRemainingMatches="Profile match limit reached. Reactivating previous profile."
  794.     OverridingURL="Overriding command line value for parameter"
  795.     BadProfileClass="Bad Profile Class"
  796.     CannotRemoveActive="Removal of active profile not allowed! Please switch server to a different profile, then try again."
  797.     PreviousProfileRemoved="Attempted to return server to previous profile, but no previous profile was found.  Leaving server set to current profile."
  798.     BadIndex="Invalid profile index"
  799.     CancellingProfile="Cancelling activation of profile"
  800.     EmptyMaplist="Profile maplist is empty"
  801.     InvalidMaplist="Attempting to load profile with invalid maplist!"
  802. 	CommandLineOptions(0)=(ParamName="CommandLineParams.AdminUserName",Value="")
  803. 	CommandLineOptions(1)=(ParamName="CommandLineParams.AdminPassword",Value="")
  804. 	CommandLineOptions(2)=(ParamName="CommandLineParams.GameRules",Value="")
  805. 	CommandLineOptions(3)=(ParamName="CommandLineParams.DemoRec",Value="")
  806. 	CommandLineOptions(4)=(ParamName="CommandLineParams.bAutoNumBots",Value="")
  807. 	CommandLineOptions(5)=(ParamName="CommandLineParams.QuickStart",Value="")
  808. 	CommandLineOptions(6)=(ParamName="CommandLineParams.RedTeamAI",Value="UnrealGame.TeamAI")
  809. 	CommandLineOptions(7)=(ParamName="CommandLineParams.BlueTeamAI",Value="UnrealGame.TeamAI")
  810. 	CommandLineOptions(8)=(ParamName="CommandLineParams.RedTeamSymbol",Value="")
  811. 	CommandLineOptions(9)=(ParamName="CommandLineParams.BlueTeamSymbol",Value="")
  812. }