Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00714 00715 00716 00717 00718 00719 00720 00721 00722 00723 00724 00725 00726 00727 00728 00729 00730 00731 00732 00733 00734 00735 00736 00737 00738 00739 00740 00741 00742 00743 00744 00745 00746 00747 00748 00749 00750 00751 00752 00753 00754 00755 00756 00757 00758 00759 00760 00761 00762 00763 00764 00765 00766 00767 00768 00769 00770 00771 00772 00773 00774 00775 00776 00777 00778 00779 00780 00781 00782 00783 00784 00785 00786 00787 00788 00789 00790 00791 00792 00793 00794 00795 00796 00797 00798 00799 00800 00801 00802 00803 00804 00805 00806 00807 00808 00809 00810 00811 00812 00813 00814 00815 00816 00817 00818 00819 00820 00821 00822 00823 00824 00825 00826 00827 00828 00829 00830 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 00841 00842 00843 00844 00845 00846 00847 00848 00849 00850 00851 00852 00853 00854 00855 00856 00857 00858 00859 00860 00861 00862 00863 00864 00865 00866 00867 00868 00869 00870 00871 00872 00873 00874 00875 00876 00877 00878 00879 00880 00881 00882 00883 00884 00885 00886 00887 00888 00889 00890 00891 00892 00893 00894 00895 00896 00897 00898 00899 00900 00901 00902 00903 00904 00905 00906 00907 00908 00909 |
/** * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. */ // NOTE: If you subclass this then don't specify a new config file name, otherwise there will be duplicates of the globalconfig // properties from here, in your new config file. These duplicates wont be updated when setting up a maplist from the menus, // because the menus can only update variables for the [UTGame.UTMapListManager] section in UTMapLists.ini. Class UTMapListManager extends Info config(MapLists); /** A struct for describing a gametype and it's corresponding settings */ struct GameProfile { var string GameClass; // The game class this profile uses, must be in the format: 'Package.Class' var string GameName; // The displayed gametype name (e.g "Warfare", "Capture The Flag") var name MapListName; // The name of the maplist this gametype uses (maplists are defined in UTMapLists.ini) var string Options; // Added URL options used with this game profile var string Mutators; // A list of default mutators which are used with this game profile, format: 'Pkg.Class,Pkg2.Class2' var string ExcludedMuts; // A list of mutators which are disallowed when playing under this game profile var bool bIsTeamGame; // Whether this gametype is a team game (saves loading gametype to find out) structdefaultproperties { bIsTeamGame=true; //err on the side of making team skins } }; /** The list of available game profiles */ var globalconfig array<GameProfile> GameProfiles; /** The currently active game profile; used to help determine the current map cycle */ var globalconfig string ActiveGameProfileName; /** A list of URL options which are automatically removed from the URL upon map change */ var globalconfig string AutoStripOptions; /** The same as 'AutoStripOptions', except these options are given an empty value on the URL */ var globalconfig string AutoEmptyOptions; /** The index of the current game session, incremented upon map switch (used to keep track of when maps have been played) */ var globalconfig int PlayIndex; /** After a map has been played, this many matches must pass before the map can be played again */ var globalconfig int MapReplayLimit; // Runtime variables /** Cache of loaded maplists */ var array<UTMapList> LoadedMapLists; /** List of maplist names from UTMapLists.ini which have not been loaded into 'MapListCache' */ var array<string> UnloadedMapLists; /** If true, 'UnLoadedMapLists' has been filled from UTMapLists.ini */ var bool bGotMapListSections; /** Used to help detect bad maps */ var bool bPendingMapChange; /** Forces the current GameInfo to use the map supplies by this object, instead of e.g. that supplied by the vote collector */ var bool bOverrideNextMap; /** The currently active maplist for this gametype */ var UTMapList ActiveMapList; /** Runtime copy of the 'GameProfiles' list, so that editing through webadmin doesn't break the code */ var array<GameProfile> AvailableGameProfiles; /** The currently active game profile; used to determine the current map cycle */ var int ActiveGameProfile; /** The game profile that was active when the maplist manager was initialized */ var int StartupGameProfile; /** Mutators added to the URL in 'AddDefaultOptions'; used by 'ModifyOptions' when switching between game profiles */ var array<string> AddedMutators; function Initialize() { local int CurMapIdx, i; // Initialize the runtime copy of 'GameProfiles' AvailableGameProfiles.Length = GameProfiles.Length; for (i=0; i<GameProfiles.Length; ++i) AvailableGameProfiles[i] = GameProfiles[i]; // Sync ActiveGameProfile with the current game class GetCurrentGameProfileIndex(); StartupGameProfile = ActiveGameProfile; // Determine whether or not the current map is the maplists 'active' map, and if not, increment the maps playcount if (GetCurrentMapList() != none) { CurMapIdx = ActiveMapList.GetMapIndex(WorldInfo.GetMapName(True),, WorldInfo.Game.ServerOptions); if (CurMapIdx != ActiveMapList.LastActiveMapIndex) { // Update the play index ++PlayIndex; // Now update the maplist if (CurMapIdx != INDEX_None) { LogInternal("Current map is not the maplist's active map, updating maplist"); ActiveMapList.SetLastActiveIndex(CurMapIdx); UpdateMapHistory(ActiveMapList, CurMapIdx); } else { LogInternal("Current map was not found within the active map list"); } } } SaveConfig(); } // Used to retrieve the next map in the cycle (does not modify map history) function string GetNextMap(optional UTMapList InMapList=ActiveMapList) { local int CurMapIdx, NextMapIdx, i, LastPlayDiff, FallbackIdx;//, FallbackPlayDiff; local bool bFound; if (InMapList == none) InMapList = GetCurrentMapList(); if (InMapList == none) return ""; CurMapIdx = InMapList.LastActiveMapIndex; NextMapIdx = InMapList.GetNextMapIndex(); // This should only ever happen when the maplist length is 0 (and that shouldn't ever happen) if (NextMapIdx >= InMapList.Maps.Length) return ""; // If the next map is disabled, then keep iterating until a selectable one is found if (!bMapEnabled(InMapList, NextMapIdx)) { // Iterate all the maps i = InMapList.GetNextMapIndex(NextMapIdx); while (i != NextMapIdx) { if (bMapEnabled(InMapList, i) && i != CurMapIdx) { NextMapIdx = i; bFound = True; break; } i = InMapList.GetNextMapIndex(i); } // No valid map was found, reiterate the list with more leniant checks if (!bFound) { FallbackIdx = INDEX_None; i = InMapList.GetNextMapIndex(NextMapIdx); while (i != NextMapIdx) { if (bMapEnabled(InMapList, i, False) && i != CurMapIdx) { LastPlayDiff = GetMapLastPlayDiff(InMapList, i); // If the map has never been played, return immediately if (LastPlayDiff == INDEX_None) { FallbackIdx = i; break; } if (FallbackIdx == INDEX_None)// || LastPlayDiff > FallbackPlayDiff) { FallbackIdx = i; //FallbackPlayDiff = LastPlayDiff; } } i = InMapList.GetNextMapIndex(i); } // If there are still no valid maps, then just use the next map in the list if (FallbackIdx == INDEX_None) NextMapIdx = InMapList.GetNextMapIndex(); else NextMapIdx = FallbackIdx; } } return InMapList.GetMap(NextMapIdx); } // Used to track map changes and modify map history, including disabling of maps and playcount tracking etc. function NotifyMapChange(string NextMap) { local int CurMapIdx, i; local UTMapList PendingMaplist; ++PlayIndex; SaveConfig(); bPendingMapChange = True; // Determine what maplist will be in use next game (i.e. when the vote collector changes the active game profile) if (ActiveGameProfile != INDEX_None && ActiveGameProfile < AvailableGameProfiles.Length) PendingMapList = GetMapListByName(AvailableGameProfiles[ActiveGameProfile].MapListName); if (PendingMapList == none) PendingMapList = ActiveMapList; if (PendingMapList == none) return; // Check for map options i = InStr(NextMap, "?"); if (i == INDEX_None) CurMapIdx = PendingMapList.GetMapIndex(NextMap); else CurMapIdx = PendingMapList.GetMapIndex(Left(NextMap, i),, Mid(NextMap, i+1)); if (CurMapIdx == INDEX_None) return; // Update the stored map info UpdateMapHistory(PendingMapList, CurMapIdx); } // Notification used for detecting bad maps function NotifyTravelFailed(string TravelURL, string Error, optional string ErrorCode) { local int i; local string BadMap; // Don't try to deal with unexpected map changes if (!bPendingMapChange) return; i = InStr(TravelURL, "?"); if (i == INDEX_None) BadMap = TravelURL; else BadMap = Left(TravelURL, i); LogInternal("Travel to '"$BadMap$"' failed, moving on to the next map in list"); bOverrideNextMap = True; WorldInfo.NextURL = ""; WorldInfo.Game.bGameRestarted = False; WorldInfo.Game.bAlreadyChanged = False; WorldInfo.Game.RestartGame(); } // Used to add default URL options upon map change, must NOT be used to remove options, as that should be done in ModifyOptions instead function string AddDefaultOptions(string CurOptions) { local string MutStr; // If there is no active game profile, there are no checks to be made if (ActiveGameProfile == INDEX_None) return CurOptions; // Parse the current game profiles default mutator lists MutStr = GetDefaultMutators(ActiveGameProfile); // If the list is not empty, parse the mutators and modify the URL if (Len(MutStr) > 1) { ParseStringIntoArray(MutStr, AddedMutators, ",", True); ModifyMutatorOptions(CurOptions, AddedMutators); } return CurOptions; } // Used to alter or remove URL options, after all the default options have been set function ModifyOptions(out string CurOptions) { local string MutStr, RemainingOptions, NewOpt, GrabbedOpt; local array<string> RemoveMuts, RemoveOptions; local int i; // Parse the 'AutoStripOptions' list and go through it ParseStringIntoArray(AutoStripOptions, RemoveOptions, ",", True); for (i=0; i<RemoveOptions.Length; ++i) CurOptions = StripOption(CurOptions, RemoveOptions[i]); // Now do the same with 'AutoEmptyOptions' ParseStringIntoArray(AutoEmptyOptions, RemoveOptions, ",", True); for (i=0; i<RemoveOptions.Length; ++i) CurOptions = StripOption(CurOptions, RemoveOptions[i], True); // If the active game profile is not set, there are no checks to be made if (ActiveGameProfile == INDEX_None) return; // Parse the excluded mutator list for the active game profile MutStr = AvailableGameProfiles[ActiveGameProfile].ExcludedMuts; if (MutStr != "") { ParseStringIntoArray(MutStr, RemoveMuts, ",", True); ModifyMutatorOptions(CurOptions,, RemoveMuts); } // If switching between game profiles, disable mutators which were added by the old game profile if (StartupGameProfile != INDEX_None && ActiveGameProfile != StartupGameProfile) { MutStr = GetDefaultMutators(StartupGameProfile); if (Len(MutStr) > 1) { // Strip the newly added mutators (those being added by the new game profile) from the 'RemoveMuts' list ParseStringIntoArray(MutStr, RemoveMuts, ",", True); RemoveMuts = GetDisabledDefaultMutators(RemoveMuts, AddedMutators); if (RemoveMuts.Length > 0) ModifyMutatorOptions(CurOptions,, RemoveMuts); } } // Append the game profile's options and game class RemainingOptions = StripOption(StripOption(AvailableGameProfiles[ActiveGameProfile].Options, "Mutator"), "Game"); while (Class'GameInfo'.static.GrabOption(RemainingOptions, NewOpt)) { GrabbedOpt = Left(NewOpt, InStr(NewOpt, "=")); // Override options which are already present if (Class'GameInfo'.static.HasOption(CurOptions, GrabbedOpt)) CurOptions = StripOption(CurOptions, GrabbedOpt)$"?"$NewOpt; else CurOptions $= "?"$NewOpt; } CurOptions = StripOption(CurOptions, "Game")$"?Game="$AvailableGameProfiles[ActiveGameProfile].GameClass; // If switching from a non-team gametype into a different gametype, then make sure the teams get rebalanced after travelling if (UTTeamGame(WorldInfo.Game) == none && !(PathName(WorldInfo.Game.Class) ~= AvailableGameProfiles[ActiveGameProfile].GameClass)) { Class'UTTeamGame'.default.bRebalanceOnceAfterTravel = True; Class'UTTeamGame'.static.StaticSaveConfig(); } // If going from a non team game to a team game, force non-seamless server travel to fixup team skins if (WorldInfo.Game.bTeamGame != AvailableGameProfiles[ActiveGameProfile].bIsTeamGame) { WorldInfo.Game.bUseSeamlessTravel = false; } } // Maplist management functions // Returns or creates a maplist with the specified name function UTMapList GetMapListByName(name MapListName, optional bool bCreate) { local int i; local UTMapList NewMapList; local string sMapList; for (i=0; i<LoadedMapLists.Length; ++i) if (LoadedMapLists[i].Name == MapListName) return LoadedMapLists[i]; if (!bGotMapListSections) { GetPerObjectConfigSections(Class'UTMapList', UnloadedMapLists); bGotMapListSections = True; // GetPerObjectConfigSections returns values like so 'ConfigName ClassName'; strip out the class names for (i=0; i<UnloadedMapLists.Length; ++i) UnloadedMapLists[i] = Left(UnloadedMapLists[i], InStr(UnloadedMapLists[i], " ")); } if (UnloadedMapLists.Length != 0) { // Check if the desired maplist exists sMapList = string(MapListName); i = UnloadedMapLists.Find(sMapList); // If so, load the maplist and remove its name from 'UnloadedMapLists' if (i != INDEX_None) { UnloadedMapLists.Remove(i, 1); NewMapList = new(none, sMapList) Class'UTMapList'; NewMapList.Initialize(); LoadedMapLists.AddItem(NewMapList); return NewMapList; } } // If the maplist has not been found (i.e. doesn't exist yet), then create it if (bCreate) { NewMapList = new(none, sMapList) Class'UTMapList'; NewMapList.Initialize(); LoadedMapLists.AddItem(NewMapList); return NewMapList; } LogInternal("Unable to find named maplist '"$MapListName$"'"); return none; } // Static, non-cached version of the above (mainly used by the map selection menus) static final function UTMapList StaticGetMapListByName(name MapListName, optional bool bCreate) { local UTMapList MLObj; local array<string> AvailableMapLists; local string sMapList; local int i; sMapList = string(MapListName); // If creating a maplist instead of searching for one, return immediately if (bCreate) { MLObj = new(none, sMapList) Class'UTMapList'; MLObj.Initialize(); return MLObj; } GetPerObjectConfigSections(Class'UTMapList', AvailableMaplists); i = AvailableMapLists.Find(sMapList@Class'UTMapList'.Name); if (i != INDEX_None) { MLObj = new(none, sMapList) Class'UTMapList'; MLObj.Initialize(); return MLObj; } LogInternal("Unable to find named maplist '"$MapListName$"'"); return none; } // Finds all maps with the specified prefixes, and populates the specified maplist with those maps static final function PopulateMapListByPrefix(UTMapList MapList, array<string> Prefixes, optional bool bAppend) { local array<UTUIResourceDataProvider> MapProviders; local int i, j, k; local string CurMap; if (!bAppend) MapList.Maps.Length = 0; Class'UTUIDataStore_MenuItems'.static.GetAllResourceDataProviders(Class'UTUIDataProvider_MapInfo', MapProviders); i = MapProviders.Length; for (j=0; j<i; ++j) { CurMap = UTUIDataProvider_MapInfo(MapProviders[j]).MapName; k = InStr(CurMap, "-"); if (k != INDEX_None && Prefixes.Find(Left(CurMap, k)) != INDEX_None && (!bAppend || MapList.GetMapIndex(CurMap) == INDEX_None)) { k = MapList.Maps.Length; MapList.Maps.Length = k+1; MapList.SetMap(k, CurMap); } } } // Caches and returns the active game profiles maplist in the 'ActiveMapList' variable function UTMapList GetCurrentMapList(optional bool bForceUpdate) { local int GameProfileIdx; if (!bForceUpdate && ActiveMapList != none) return ActiveMapList; GameProfileIdx = GetCurrentGameProfileIndex(); if (GameProfileIdx == INDEX_None) return none; ActiveMapList = GetMapListByName(AvailableGameProfiles[GameProfileIdx].MapListName); return ActiveMapList; } // Returns whether or not the specified map is enabled (i.e. whether or not switching to the map is allowed) function bool bMapEnabled(UTMapList MapList, int MapIdx, optional bool bStrict=True) { local string CurMapData; local int LastPlayDiff, ReplayLimit; if (MapList == none || MapIdx >= MapList.Maps.Length) return False; CurMapData = MapList.GetExtraMapData(MapIdx, 'bDisabled'); if (CurMapData != "" && bool(CurMapData)) return False; if (bStrict) { ReplayLimit = (MapList.MapReplayLimit != INDEX_None ? MapList.MapReplayLimit : MapReplayLimit); if (ReplayLimit > 0) { LastPlayDiff = GetMapLastPlayDiff(MapList, MapIdx); if (LastPlayDiff != INDEX_None && LastPlayDiff < ReplayLimit) return False; } } return True; } // Returns an integer which represents the number of games since the map was last played (or INDEX_None if the map was never played) function int GetMapLastPlayDiff(UTMapList MapList, int MapIdx) { local string LastPlayIndex; local int LastPlayDiff; LastPlayIndex = MapList.GetExtraMapData(MapIdx, 'LastPlayIdx'); if (LastPlayIndex == "") return INDEX_None; LastPlayDiff = PlayIndex - int(LastPlayIndex); if (LastPlayDiff < 0) return INDEX_None; return LastPlayDiff; } // Updates various per-map values, e.g. the number of times the map has been played function UpdateMapHistory(UTMapList MapList, int MapIdx) { local int NewPlayCount; // Update the maps playcount NewPlayCount = int(MapList.GetExtraMapData(MapIdx, 'PlayCount')) + 1; MapList.SetExtraMapData(MapIdx, 'PlayCount', string(NewPlayCount)); MapList.SetExtraMapData(MapIdx, 'LastPlayIdx', string(PlayIndex)); // Now update the maplists 'last active map' index MapList.SetLastActiveIndex(MapIdx); } // Game profile helper functions // Returns the currently active 'AvailableGameProfile' index (or the best match) function int GetCurrentGameProfileIndex() { local string ClassPath; ClassPath = PathName(WorldInfo.Game.Class); if (ActiveGameProfile == INDEX_None && ActiveGameProfileName != "") ActiveGameProfile = AvailableGameProfiles.Find('GameName', ActiveGameProfileName); // If 'ActiveGameProfile' is set the respective 'AvailableGameProfiles' entry matches the current gametype, return it's index if (ActiveGameProfile != INDEX_None && AvailableGameProfiles[ActiveGameProfile].GameClass == ClassPath) return ActiveGameProfile; // Otherwise, set 'ActiveGameProfile' to the first gametype in the list which matches this one (or -1 if there are none), and return SetCurrentGameProfileIndex(AvailableGameProfiles.Find('GameClass', ClassPath)); return ActiveGameProfile; } // Static version of the above, for map selection menus static final function int StaticGetCurrentGameProfileIndex() { return default.GameProfiles.Find('GameName', default.ActiveGameProfileName); } // Changes the currently active game profile function SetCurrentGameProfileIndex(int Idx) { ActiveGameProfile = Idx; if (Idx >= 0 && Idx < AvailableGameProfiles.Length) ActiveGameProfileName = AvailableGameProfiles[Idx].GameName; else ActiveGameProfileName = ""; SaveConfig(); } // Find the first game profile with the matching game class function int FindGameProfileIndex(string GameClass) { return AvailableGameProfiles.Find('GameClass', GameClass); } // Static version of the above, mainly used by map selection menus static final function int StaticFindGameProfileIndex(string GameClass) { return default.GameProfiles.Find('GameClass', GameClass); } // Create and setup values for a new game profile entry (used by map selection menus) static final function GameProfile CreateNewGameProfile(string InGameClass, optional string InGameName, optional name InMapListName, optional string InOptions, optional string InMutators) { local GameProfile NewProfile; local int i; NewProfile.GameClass = InGameClass; if (InGameName == "") { i = InStr(InGameClass, "."); // Get 'GameName' without actually loading the class InGameName = Localize(Mid(InGameClass, i+1), "GameName", Left(InGameClass, i)); // If localization failed, then just use the game classname if (InStr(InGameName, "?"$InGameClass$".GameName?") != INDEX_None) InGameName = Mid(InGameClass, i+1); } NewProfile.GameName = InGameName; NewProfile.MapListName = InMapListName; NewProfile.Options = InOptions; NewProfile.Mutators = InMutators; return NewProfile; } // URL helper functions static final function string StripOption(string Options, string InKey, optional bool bAddEmptyValue) { local int i, j; local string sTempStr; ReStrip: i = InStr(Caps(Options), "?"$Caps(InKey)); if (i == INDEX_None) { if (bAddEmptyValue) return Options$"?"$InKey$"="; else return Options; } sTempStr = Mid(Options, i+1); j = InStr(sTempStr, "?"); if (j == INDEX_None) Options = Left(Options, i); else Options = Left(Options, i)$Mid(Options, i+j+1); goto 'ReStrip'; } // Returns true if the options in string A contain all of the options in string B static final function bool ContainsOptions(string A, string B) { local int i, j; local string Pair; if (Left(B, 1) != "?") return True; if (Left(A, 1) != "?") return False; // Convert A to caps for use with InStr (which is case-sensitive) A = Caps(A); while (B != "") { // Strip out the initial '?' B = Mid(B, 1); // Find the next '?' and make sure it's not before the next '=' (i.e. if someone types "??Game=Blah.Blah") i = InStr(B, "?"); j = InStr(B, "="); if (i < j && i != INDEX_None) continue; // Grab the key/value pair and search for that within A if (i != INDEX_None) { Pair = Caps(Left(B, i)); if (Pair == "") return True; B = Mid(B, i+1); } else { Pair = Caps(B); B = ""; } if (InStr(A, Pair) == INDEX_None) return False; } return True; } // Parses the value of the "?Mutator=" option in the URL (if any), and adds/removes mutators as specified static final function ModifyMutatorOptions(out string CurOptions, optional out const array<string> AddMuts, optional out const array<string> RemoveMuts) { local string MutStr; local array<string> MutatorList; local int i, j, PreLen; local bool bModifiedList; // Get the previous URL mutator list if (CurOptions != "") { MutStr = Class'GameInfo'.static.ParseOption(CurOptions, "Mutator"); if (MutStr != "") ParseStringIntoArray(MutStr, MutatorList, ",", True); } // Iterate the mutator lists and add/remove as appropriate for (i=0; i<AddMuts.Length; ++i) { if (MutatorList.Find(AddMuts[i]) == INDEX_None) { MutatorList.AddItem(AddMuts[i]); bModifiedList = True; } } for (i=0; i<RemoveMuts.Length; ++i) { j = InStr(RemoveMuts[i], "."); // Checks are performed differently, depending upon whether the current RemoveMut entry contains the package name if (j != INDEX_None) { PreLen = MutatorList.Length; MutatorList.RemoveItem(RemoveMuts[i]); if (MutatorList.Length != PreLen) bModifiedList = True; } else { for (j=0; j<MutatorList.Length; ++j) { if (InStr(Caps(MutatorList[j]), "."$Caps(RemoveMuts[i])) != INDEX_None) { MutatorList.Remove(j--, 1); bModifiedList = True; } } } } // Now reconstruct the mutator list if (bModifiedList) { if (MutatorList.Length != 0) { MutStr = "?Mutator="; for (i=0; i<MutatorList.Length; ++i) { if (i != 0) MutStr $= ","; MutStr $= MutatorList[i]; } } else { MutStr = "?Mutator="; } // Remove the current mutator list, and add the modifed one if (CurOptions != "") CurOptions = StripOption(CurOptions, "Mutator")$MutStr; else CurOptions = MutStr; } } // Returns the default mutators for a particular game profile final function string GetDefaultMutators(int Idx) { local string ReturnStr; if (Idx < 0 || Idx >= AvailableGameProfiles.Length) return ReturnStr; ReturnStr = AvailableGameProfiles[Idx].Mutators; ReturnStr $= ","$Class'GameInfo'.static.ParseOption(AvailableGameProfiles[Idx].Options, "Mutator"); if (ReturnStr == ",") return ""; return ReturnStr; } // Returns the list of default mutators from one game profile, which should be removed when moving to another game profile // (only moved here, due to also being used by the vote code) // NOTE: Expects both lists to contain the full package and class names final function array<string> GetDisabledDefaultMutators(const out array<string> OldDefaults, const out array<string> NewDefaults) { local int i; local array<string> ReturnVal; for (i=0; i<OldDefaults.Length; ++i) if (NewDefaults.Find(OldDefaults[i]) == INDEX_None) ReturnVal.AddItem(OldDefaults[i]); return ReturnVal; } defaultproperties { GameProfiles(0)=(GameClass="UTGame.UTDeathmatch",GameName="DeathMatch",MapListName="DMMapList") GameProfiles(1)=(GameClass="UTGame.UTTeamGame",GameName="Team DeathMatch",MapListName="TDMMapList",bIsTeamGame=True) GameProfiles(2)=(GameClass="UTGameContent.UTCTFGame_Content",GameName="Capture The Flag",MapListName="CTFMapList",bIsTeamGame=True) GameProfiles(3)=(GameClass="UTGameContent.UTVehicleCTFGame_Content",GameName="Vehicle Capture The Flag",MapListName="VCTFMapList",bIsTeamGame=True) GameProfiles(4)=(GameClass="UTGameContent.UTOnslaughtGame_Content",GameName="Warfare",MapListName="WARMapList",bIsTeamGame=True) GameProfiles(5)=(GameClass="UTGame.UTDuelGame",GameName="Duel",MapListName="DuelMapList") GameProfiles(6)=(GameClass="UTGame.UTBetrayalGame",GameName="Betrayal",MapListName="BetrayalMapList") GameProfiles(7)=(GameClass="UT3GoldGame.UTGreedGame_Content",GameName="Greed",MapListName="GreedMapList",bIsTeamGame=True) ActiveGameProfileName="Warfare" AutoStripOptions="LinkSetup" AutoEmptyOptions="GoalScore" ActiveGameProfile=-1 StartupGameProfile=-1 Begin Object Class=SpriteComponent Name=Sprite ObjName=Sprite Archetype=SpriteComponent'Engine.Default__Info:Sprite' ObjectArchetype=SpriteComponent'Engine.Default__Info:Sprite' End Object Components(0)=Sprite CollisionType=COLLIDE_CustomDefault Name="Default__UTMapListManager" ObjectArchetype=Info'Engine.Default__Info' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |