Legacy:ProfileConfigSet - Unreal Wiki

# Legacy:ProfileConfigSet

### From Unreal Wiki, The Unreal Engine Documentation Site

UT2003 :: Object >> ProfileConfigSet (Ladder1.46)

1. //-----------------------------------------------------------
2. // Ladder.ProfileConfigSet
3. // Loosely (very loosely) based on GameConfigSet
4. //
5. // ProfileConfigSet is, in essence, a primitive database program which
6. // stores and retrieves not only numerous different "GameConfigSet"
7. // profiles, but map, mutator, serveractor and accesscontrol information as well.
8. //-----------------------------------------------------------
9. class ProfileConfigSet extends Object
10. Config(System)
11. PerObjectConfig;
13. const LOGNAME = 'ProfileConfigSet';
15. // Variables that are used globally
16. var LevelInfo Level; // Need access to Level object
17. var protected string AllMapsPrefix; // Which map prefix is currently loaded
18. var protected array< class<GameInfo> > AllGameTypes; // All valid gametypes
19. var protected config string DefaultGameType;// The gametype for this profile
20. var protected class<AccessControl> ACClass; // The access control class
21. var protected GameConfigSet RealConfigSet; // Actual gameconfigset used by the game
23. var protected class<GameInfo> GameClass; // Which game class is used by this profile
24. var protected PlayInfo PInfo; // PlayInfo for currently active GameType, AccessControl Class, and Active Mutators
25. var protected MapList Maps; // Maps currently in rotation
27. // Regarding ServerActors
28. struct ProfileSA {
29. var string ActorClass;
30. var bool bRequired; };
31. var config array<ProfileSA> AllServerActors;
32. var config array<string> ProfileServerActors;
33. var protected array<string> GameServerActors;
34. var protected StringArray ActiveServerActors;
36. // Regarding Maps
37. struct ProfileMap {
38. var string MapName;
39. var int MapListOrder;
40. var bool bRequired; };
41. var config int MaxMaps; // Maximum maps allowed in maplist
42. var protected array<string> GameMaps; // List of all maps for this gametype that exist on server
43. var protected config array<ProfileMap> AllMaps; // List of all maps that could be used by this profile
44. var protected config array<string> ProfileMaps; // List of all maps that are included in the maplist for this profile
45. var protected StringArray ActiveMaps; // StringArray of ProfileMaps
47. // Regarding Mutators
48. struct ProfileMutator {
49. var string MutatorName;
50. var bool bRequired; };
51. var string NextMutators; // What mutators were set during this session
52. var protected array<xUtil.MutatorRecord> GameMutators; // List of all mutators that exist on server
53. var protected config array<ProfileMutator> AllMutators; // List of all mutators that could be used this profile
54. var protected config array<string> ProfileMutators; // Mutators that will be loaded by this profile
55. var protected StringArray ActiveMutators; // StringArray of ProfileMutators
57. // Regarding PlayInfo
58. var protected config string AccessClass;
59. struct ProfileSetting { var string SettingName;
60. var string SettingValue; };
61. var protected config array<ProfileSetting> ProfileSettings; // Stored Profile Settings which include non-active mutators PlayInfo
62. var protected array<ProfileSetting> ActiveSettings; // Representation of stored profile settings including only active mutators
64. // Whether we are currently editing something
65. var protected bool bEdit;
67. // Localized strings
68. var localized string ErrorNoGameType;
69. var localized string SavingToFile;
70. var localized string DidNotStartEdit;
72. function Init(LevelInfo Lv, optional string GameType, optional string AC)
73. {
74. if (Lv==None)
75. return;
77. Level = Lv;
78. if (GameType!="") DefaultGameType = GameType;
79. if (AC != "") AccessClass = AC;
80. else AccessClass = Level.Game.AccessControlClass;
81. AllMapsPrefix = FindGameType(DefaultGameType).default.MapPrefix;
83. // Make sure that none of the configured mutators have been removed from this server
84. ValidateProfile();
85. }
87. function Cleanup()
88. {
89. // Destroy any references to actors
90. if (Level != None)
91. Level=None;
93. if (ActiveMaps != None)
94. ActiveMaps = None;
96. if (Maps != None)
97. Maps = None;
98. }
100. function ValidateProfile()
101. {
102. ValidateAllMutators();
103. ValidateAllMaps();
104. ValidateAllServerActors();
105. }
107. function ValidateAllMutators()
108. {
109. local class<Mutator> TempMutClass;
110. local int i;
112. for (i = 0;i < AllMutators.Length; i++)
113. {
114. TempMutClass = class<Mutator>(DynamicLoadObject(AllMutators[i].MutatorName, Class'class'));
115. if (TempMutClass == None)
116. {
117. log("Mutator class '"$AllMutators[i].MutatorName$"' has been removed from this server. Removing mutator from current profile.",LOGNAME);
118. AllMutators.Remove(i--,1);
119. SaveConfig();
120. }
121. }
122. }
124. function ValidateAllMaps()
125. {
126. local int i, j;
128. LoadAllMaps();
129. for (i = 0;i < AllMaps.Length;i++)
130. {
131. for (j = 0;j < GameMaps.Length;j++)
132. if (GameMaps[j] ~= AllMaps[i].MapName)
133. break;
135. if (j == GameMaps.Length)
136. {
137. log("Map '"$AllMaps[i].MapName$"' has been removed from this server. Removing map from profile.",LOGNAME);
138. AllMaps.Remove(i--,1);
139. SaveConfig();
140. }
141. }
142. }
144. function ValidateAllServerActors()
145. {
146. local int i;
147. local class<Info> TempSA;
149. for (i=0;i<AllServerActors.Length;i++)
150. {
151. TempSA = class<Info>(DynamicLoadObject(AllServerActors[i].ActorClass,Class'Class'));
152. if (TempSA == None)
153. {
154. log("ServerActor '"$AllServerActors[i].ActorClass$"' does not exist on this server. Removing ServerActor from profile.",LOGNAME);
155. AllServerActors.Remove(i--,1);
156. SaveConfig();
157. }
158. }
159. }
161. function bool StartEdit()
162. {
163. if (Level == None || bEdit)
164. return false;
166. bEdit = true;
168. if (PInfo == None)
169. PInfo = New(None) class'PlayInfo';
171. if (AllGameTypes.Length == 0)
172. LoadGameTypes();
173. GameClass = FindGameType(DefaultGameType);
174. if (GameClass == None)
175. {
176. log(ErrorNoGameType$DefaultGameType);
177. return false;
178. }
180. if (AccessClass != "")
181. ACClass = class<AccessControl>(DynamicLoadObject(AccessClass, class'class'));
183. if (Level != None && Level.Game != None && Level.Game.AccessControl != None && AccessControlIni(Level.Game.AccessControl) != None && AccessControlIni(Level.Game.AccessControl).ConfigSet != None)
184. RealConfigSet = AccessControlIni(Level.Game.AccessControl).ConfigSet;
186. if (ActiveMutators == None)
187. ActiveMutators = new(None) class'SortedStringArray';
188. if (ActiveMaps == None)
189. ActiveMaps = new(None) class'StringArray';
190. if (ActiveServerActors == None)
191. ActiveServerActors = new(None) class'SortedStringArray';
193. NextMutators = "";
194. LoadAllMaps();
196. if (GameMutators.Length == 0)
197. LoadAllMutators();
198. LoadAllServerActors();
200. SetUsedMaps();
201. SetUsedMutators();
202. SetUsedServerActors();
204. // Load Game Setting
205. LoadSettings(GameClass);
206. AllMapsPrefix = GameClass.default.MapPrefix;
207. return true;
208. }
210. function bool EndEdit(bool bSave, optional bool bQuiet)
211. {
212. if (Level == None || !bEdit)
213. return false;
215. // Save all data where it belongs
216. if (bSave)
217. {
218. if (!bQuiet) Log(Name@SavingToFile);
220. SaveUsedMaps();
221. SaveUsedMutators();
222. SaveUsedServerActors();
223. SaveConfig();
224. }
226. bEdit = false;
227. return true;
228. }
230. function ReplaceWith(ProfileConfigSet SourcePCS)
231. {
232. local int i;
234. if (!bEdit)
235. {
236. log("ReplaceWith()"@DidNotStartEdit);
237. return;
238. }
240. if (SourcePCS.GetGameClass() != None)
241. {
242. Wipe();
243. DefaultGameType = string(SourcePCS.GetGameClass());
244. GameClass = FindGameType(DefaultGameType);
245. AccessClass = SourcePCS.GetAccessControl();
246. ACClass = SourcePCS.GetAccessClass();
247. AllMapsPrefix = GameClass.default.MapPrefix;
248. MaxMaps = SourcePCS.MaxMaps;
250. AllMaps = SourcePCS.GetProfileMaps();
251. AllMutators = SourcePCS.GetProfileMutators();
252. AllServerActors = SourcePCS.GetProfileServerActors();
253. ProfileMaps = SourcePCS.GetUsedMaps();
254. ProfileMutators = SourcePCS.GetUsedMutators();
255. ProfileServerActors = SourcePCS.GetUsedServerActors();
256. ProfileSettings.Length = SourcePCS.Count();
257. for (i = 0; i < SourcePCS.Count(); i++)
258. SetProfileParam(i, SourcePCS.GetProfileParamName(i), SourcePCS.GetProfileParam(i));
260. LoadSettings(GameClass);
261. }
262. }
264. function bool CanEdit()
265. {
266. return !bEdit;
267. }
269. // This profile was deleted, but PerObjectConfig config values cannot be completely removed from .ini (that I know of)
270. // We can, however, make the ini entry for this object as small as possible until it is reused.
271. final function Wipe()
272. {
273. //log("Wiping Profile"@Name);
274. ActiveMaps.Reset();
275. ActiveMutators.Reset();
277. MaxMaps = 0;
279. ProfileMaps.Length = 0;
280. AllMaps.Length = 0;
281. ProfileMutators.Length = 0;
282. AllMutators.Length = 0;
283. ProfileServerActors.Length = 0;
284. AllServerActors.Length = 0;
285. ProfileSettings.Length = 0;
286. ActiveSettings.Length = 0;
288. DefaultGameType = "";
289. AccessClass = "";
290. AllMapsPrefix = "";
291. NextMutators = "";
293. GameClass = None;
294. ACClass = None;
295. Maps = None;
297. }
299. ///////////////////////////////////////////////////////////////////
300. // Public GameType Information
301. ///////////////////////////////////////////////////////////////////
303. function bool SetGameType(optional string NewGameType)
304. {
305. local string OldGameType;
307. if (!bEdit)
308. {
309. log("SetGameType()"@DidNotStartEdit);
310. return false;
311. }
313. OldGameType = DefaultGameType;
314. if (NewGameType=="")
315. NewGameType=DefaultGameType;
316. else DefaultGameType = NewGameType;
318. if (AllGameTypes.Length==0)
319. LoadGameTypes();
321. GameClass = FindGameType(NewGameType);
323. if (GameClass != None && (NewGameType != OldGameType))
324. {
325. AllMapsPrefix = GameClass.default.MapPrefix;
326. ClearUsedMaps();
327. ClearAllMaps();
328. ClearProfile(ProfileSettings);
329. LoadSettings(GameClass);
330. return true;
331. }
332. return false;
333. }
335. function class<GameInfo> GetGameClass()
336. {
337. if (GameClass != None)
338. return GameClass;
340. return None;
341. }
343. function string GetGameAcronym()
344. {
345. if (GameClass != None)
346. return GameClass.default.Acronym;
348. return "";
349. }
351. function string GetAccessControl()
352. {
353. return AccessClass;
354. }
356. function class<AccessControl> GetAccessClass()
357. {
358. if (ACClass != None)
359. return ACClass;
360. return None;
361. }
363. /////////////////////////////////////////////////////////////
364. // Public MapList Functions
365. /////////////////////////////////////////////////////////////
366. function bool AddProfileMap(string MapMask, bool bRequired)
367. {
368. local int i;
369. local ProfileMap tmp;
371. if (!bEdit)
372. {
373. log("AddProfileMap()"@DidNotStartEdit);
374. return false;
375. }
377. for (i=0;i<AllMaps.Length;i++)
378. {
379. if (AllMaps[i].MapName ~= MapMask)
380. {
381. AllMaps[i].bRequired = bRequired;
382. return true;
383. }
384. }
386. for (i=0;i<GameMaps.Length;i++)
387. {
388. if (MapMask ~= GameMaps[i])
389. {
390. tmp.MapName = GameMaps[i];
391. tmp.bRequired = bRequired;
392. AllMaps[AllMaps.Length] = tmp;
393. return true;
394. }
395. }
397. return false;
398. }
400. function bool DelProfileMap(string MapName)
401. {
402. local int i;
403. local string Str;
405. if (!bEdit)
406. {
407. log("DelProfileMap()"@DidNotStartEdit);
408. return false;
409. }
411. for (i=0;i<AllMaps.Length;i++)
412. {
413. Str = AllMaps[i].MapName;
414. if (Str ~= MapName)
415. {
416. AllMaps.Remove(i, 1);
417. SetUsedMaps();
418. return true;
419. }
420. }
422. return false;
423. }
425. function string AddMap(string MapMask, int Order)
426. {
427. local int i, j, k;
428. local bool bFound;
430. if (!bEdit)
431. {
432. log("AddMaps()"@DidNotStartEdit);
433. return "";
434. }
436. k = ActiveMaps.Count();
437. for (i = 0; i<AllMaps.Length; i++)
438. {
439. if (AllMaps[i].MapName ~= MapMask)
440. {
441. // Found a matching map, see if its already in the Used Maps list
442. bFound = false;
443. for (j = 0; j < k; j++)
444. {
445. if (ActiveMaps.GetTag(j) ~= AllMaps[i].MapName)
446. {
447. bFound = true;
448. AllMaps[i].MapListOrder = Order;
449. break;
450. }
451. }
453. if (!bFound && ((MaxMaps == 0) || (k < MaxMaps)))
454. {
455. AllMaps[i].MapListOrder = ActiveMaps.Count();
456. ActiveMaps.Add(string(i), AllMaps[i].MapName);
457. return AllMaps[i].MapName;
458. }
459. }
460. }
461. return "";
462. }
464. function string RemoveMap(string MapName)
465. {
466. local int i;
467. local string TempStr;
468. if (!bEdit)
469. {
470. log("RemoveMaps()"@DidNotStartEdit);
471. return "";
472. }
474. for (i=0; i<ActiveMaps.Count(); i++)
475. {
476. TempStr = ActiveMaps.GetTag(i);
477. if (TempStr ~= MapName)
478. {
479. ActiveMaps.Remove(i);
480. return TempStr;
481. }
482. }
483. return "";
484. }
486. function array<string> FindMaps(string MapMask)
487. {
488. local array<string> FoundMasks, FoundMaps;
489. local int i, j, k;
490. local bool bFound;
492. class'wUtils103.wString'.static.Split2(MapMask, " ", FoundMasks);
493. if (FoundMasks.Length > 0)
494. {
495. for (i = 0; i<AllMaps.Length; i++)
496. {
497. for (j = 0; j<FoundMasks.Length; j++)
498. {
499. if (class'wUtils103.wString'.static.MaskedCompare(AllMaps[i].MapName, FoundMasks[j]))
500. {
501. // Found a matching map, see if its already in the Used Maps list
502. bFound = false;
503. for (k = 0; k<ActiveMaps.Count(); k++)
504. {
505. if (ActiveMaps.GetTag(k) ~= AllMaps[i].MapName)
506. {
507. bFound = true;
508. break;
509. }
510. }
512. if (bFound)
513. FoundMaps[FoundMaps.Length] = "+"$AllMaps[i].MapName;
514. else
515. FoundMaps[FoundMaps.Length] = AllMaps[i].MapName;
517. break;
518. }
519. }
520. }
521. }
522. return FoundMaps;
523. }
525. function MapList GetMaps()
526. {
527. if (Maps==None)
528. {
529. if (GameClass==None)
530. GameClass=class<GameInfo>(DynamicLoadObject(DefaultGameType, class'Class'));
532. Maps = Level.Game.GetMapList(AllMapsPrefix);
533. }
535. return Maps;
536. }
538. function array<string> GetUsedMaps()
539. {
540. local array<string> Strings;
541. local int i;
543. if (ActiveMaps == None)
544. ActiveMaps = new(None) class'StringArray';
546. for (i = 0; i<ActiveMaps.Count(); i++)
547. Strings[Strings.Length] = ActiveMaps.GetTag(i);
549. return Strings;
550. }
552. function array<string> GetUnusedMaps()
553. {
554. local array<string> Strings;
555. local int i;
557. if (ActiveMaps == None)
558. ActiveMaps = new(None) class'StringArray';
560. Strings.Length = AllMaps.Length;
561. for (i = 0; i<AllMaps.Length; i++)
562. Strings[i] = AllMaps[i].MapName;
564. // Tag all used mutators
565. for (i = 0; i<ActiveMaps.Count(); i++)
566. Strings[int(ActiveMaps.GetItem(i))] = "";
568. for (i = 0; i<Strings.Length; i++)
569. {
570. if (Strings[i] == "")
571. {
572. Strings.Remove(i, 1);
573. i--;
574. }
575. }
576. return Strings;
577. }
579. function bool MapIsRequired(string MapName)
580. {
581. local int i;
582. for (i=0;i<AllMaps.Length;i++)
583. if (MapName ~= AllMaps[i].MapName && AllMaps[i].bRequired)
584. return true;
585. return false;
586. }
588. function array<ProfileMap> GetProfileMaps()
589. {
590. return AllMaps;
591. }
593. function int GetMaxMaps()
594. {
595. return MaxMaps;
596. }
598. /////////////////////////////////////////////////////////////////////
599. // Public Mutator list functions
600. /////////////////////////////////////////////////////////////////////
602. function array<ProfileMutator> GetProfileMutators()
603. {
604. return AllMutators;
605. }
607. function array<string> GetUsedMutators()
608. {
609. local array<string> Strings;
610. local int i;
612. if (ActiveMutators == None)
613. ActiveMutators = new(None) class'SortedStringArray';
615. for (i = 0; i<ActiveMutators.Count(); i++)
616. Strings[Strings.Length] = ActiveMutators.GetTag(i);
618. return Strings;
619. }
621. function array<string> GetUnusedMutators()
622. {
623. local array<string> Strings;
624. local int i;
626. if (ActiveMutators == None)
627. ActiveMutators = new(None) class'SortedStringArray';
629. Strings.Length = AllMutators.Length;
630. for (i = 0; i<AllMutators.Length; i++)
631. Strings[i] = AllMutators[i].MutatorName;
633. // Tag all used mutators
634. for (i = 0; i<ActiveMutators.Count(); i++)
635. Strings[int(ActiveMutators.GetItem(i))] = "";
637. for (i = 0; i<Strings.Length; i++)
638. {
639. if (Strings[i] == "")
640. {
641. Strings.Remove(i, 1);
642. i--;
643. }
644. }
645. return Strings;
646. }
648. function bool AddMutator(string MutatorName)
649. {
650. local int i;
651. local string Str;
653. if (!bEdit)
654. {
655. log("AddMutator()"@DidNotStartEdit);
656. return false;
657. }
659. if (ActiveMutators.Count() == 0)
660. SetUsedMutators();
662. // First make sure it isnt in the list
663. for (i = 0; i<ActiveMutators.Count(); i++)
664. {
665. Str = ActiveMutators.GetTag(i);
666. if (Str ~= MutatorName || Right(Str, Len(MutatorName) + 1) ~= ("."$MutatorName))
667. return false;
668. }
670. for (i=0;i<AllMutators.Length;i++)
671. {
672. Str = AllMutators[i].MutatorName;
673. if (Str ~= MutatorName || Right(Str, Len(MutatorName) + 1) ~= ("."$MutatorName))
674. {
675. ActiveMutators.Add(string(i), Str);
676. return true;
677. }
678. }
679. return false;
680. }
682. function bool DelMutator(string MutatorName)
683. {
684. local int i;
685. local string Str;
687. if (!bEdit)
688. {
689. log("DelMutator()"@DidNotStartEdit);
690. return false;
691. }
693. if (MutIsRequired(MutatorName))
694. return false;
696. // First make sure it is in the list
697. for (i = 0; i<ActiveMutators.Count(); i++)
698. {
699. Str = ActiveMutators.GetTag(i);
700. if (Str ~= MutatorName || Right(Str, Len(MutatorName) + 1) ~= ("."$MutatorName))
701. {
702. ActiveMutators.Remove(i);
703. return true;
704. }
705. }
706. return false;
707. }
709. // Add mutator to list of possible mutators
710. function bool AddProfileMutator(string MutatorName, bool bRequired)
711. {
712. local int i,j;
713. local string Str;
714. local ProfileMutator tmp;
716. if (!bEdit)
717. {
718. log("AddProfileMutator()"@DidNotStartEdit);
719. return false;
720. }
722. for (i=0;i<AllMutators.Length;i++)
723. {
724. Str = AllMutators[i].MutatorName;
725. if (Str ~= MutatorName || Right(Str, Len(MutatorName) + 1) ~= ("."$MutatorName))
726. {
727. AllMutators[i].bRequired = bRequired;
728. return false;
729. }
730. }
732. for (j=0;j<GameMutators.Length;j++)
733. {
734. Str = GameMutators[j].ClassName;
735. if (Str ~= MutatorName || Right(Str, Len(MutatorName) + 1) ~= ("."$MutatorName))
736. {
737. tmp.MutatorName = Str;
738. tmp.bRequired = bRequired;
739. AllMutators[AllMutators.Length] = tmp;
740. return true;
741. }
742. }
744. return false;
745. }
747. function bool DelProfileMutator(string MutatorName)
748. {
749. local int i;
750. local string Str;
752. if (!bEdit)
753. {
754. log("DelProfileMutator()"@DidNotStartEdit);
755. return false;
756. }
758. for (i=0;i<AllMutators.Length;i++)
759. {
760. Str = AllMutators[i].MutatorName;
761. if (Str ~= MutatorName || Right(Str, Len(MutatorName)+1) ~= ("."$MutatorName))
762. {
763. AllMutators.Remove(i, 1);
764. SetUsedMutators();
765. return true;
766. }
767. }
769. return false;
770. }
772. function bool MutIsRequired(string MutatorName)
773. {
774. local int i;
775. for (i=0;i<AllMutators.Length;i++)
776. if (MutatorName ~= AllMutators[i].MutatorName && AllMutators[i].bRequired)
777. return true;
778. return false;
779. }
781. //////////////////////////////////
782. // Public ServerActor Functions
783. //////////////////////////////////
785. function array<ProfileSA> GetProfileServerActors()
786. {
787. return AllServerActors;
788. }
790. function array<string> GetUsedServerActors()
791. {
792. local array<string> Strings;
793. local int i;
795. if (ActiveServerActors == None)
796. ActiveServerActors = new(None) class'SortedStringArray';
798. for (i = 0; i<ActiveServerActors.Count(); i++)
799. Strings[Strings.Length] = ActiveServerActors.GetTag(i);
801. return Strings;
802. }
804. function bool AddProfileServerActor(string ActorName, bool bRequired)
805. {
806. local int i;
807. local ProfileSA tmp;
809. if (!bEdit)
810. {
811. log("AddProfileServerActor()"@DidNotStartEdit);
812. return false;
813. }
815. for (i=0;i<AllServerActors.Length;i++)
816. {
817. if (AllServerActors[i].ActorClass ~= ActorName)
818. {
819. AllServerActors[i].bRequired = bRequired;
820. return false;
821. }
822. }
824. tmp.ActorClass = ActorName;
825. tmp.bRequired = bRequired;
826. AllServerActors[AllServerActors.Length] = tmp;
827. SetUsedServerActors();
828. return true;
829. }
831. function bool AddServerActor(string ActorName)
832. {
833. local int i;
835. if (!bEdit)
836. {
837. log("AddServerActor()"@DidNotStartEdit);
838. return false;
839. }
841. // Check for already exists
842. for (i=0;i<ProfileServerActors.Length;i++)
843. {
844. if (ProfileServerActors[i] ~= ActorName)
845. return false;
846. }
848. for (i=0;i<AllServerActors.Length;i++)
849. {
850. if (AllServerActors[i].ActorClass ~= ActorName)
851. {
852. ProfileServerActors[ProfileServerActors.Length] = ActorName;
853. SetUsedServerActors();
854. return true;
855. }
856. }
857. return false;
858. }
860. function bool DelProfileServerActor(string ActorName)
861. {
862. local int i;
864. if (!bEdit)
865. {
866. log("DelProfileServerActor()"@DidNotStartEdit);
867. return false;
868. }
870. for (i=0;i<AllServerActors.Length;i++)
871. {
872. if (AllServerActors[i].ActorClass ~= ActorName)
873. {
874. AllServerActors.Remove(i,1);
875. SetUsedServerActors();
876. return true;
877. }
878. }
880. return false;
881. }
883. function bool DelServerActor(string ActorName)
884. {
885. local int i;
887. if (!bEdit)
888. {
889. log("DelServerActor()"@DidNotStartEdit);
890. return false;
891. }
893. i = ActiveServerActors.FindTagId(ActorName);
894. if (i >= 0)
895. {
896. ActiveServerActors.Remove(i);
897. return true;
898. }
900. return false;
901. }
903. function bool ServerActorIsRequired(string ActorName)
904. {
905. local int i;
906. for (i=0;i<AllServerActors.Length;i++)
907. if (ActorName ~= AllServerActors[i].ActorClass)
908. return AllServerActors[i].bRequired;
910. return false;
911. }
914. ////////////////////////////////
915. // Protected Helping functions
916. ////////////////////////////////
918. // Always reload settings at StartEdit()
919. protected function string LoadSettings(class<GameInfo> GameClass)
920. {
921. local class<Mutator> MutClass;
922. local class<Info> SAClass;
923. local int i,j;
925. if (!bEdit)
926. {
927. log("LoadSettings()"@DidNotStartEdit);
928. return "";
929. }
931. if (PInfo == None)
932. PInfo = new(None) class'PlayInfo';
934. PInfo.Clear();
936. // Unhook GameInfo.FillPlayInfo()'s hook to BaseMutator.FillPlayInfo()
937. // Otherwise, we end up with mutator playinfo that we may not want
938. GameClass.static.FillPlayInfo(PInfo);
939. PInfo.PopClass();
941. if (ACClass == None && AccessClass != "")
942. ACClass = class<AccessControl>(DynamicLoadObject(AccessClass,class'Class'));
944. if (ACClass!=None)
945. {
946. ACClass.static.FillPlayInfo(PInfo);
947. PInfo.PopClass();
948. }
950. if (GameClass.default.MutatorClass != "")
951. {
952. MutClass = class<Mutator>(DynamicLoadObject(GameClass.default.MutatorClass,class'Class'));
953. if (MutClass != None)
954. {
955. MutClass.static.FillPlayInfo(PInfo);
956. PInfo.PopClass();
957. }
958. }
960. if (ActiveMutators.Count() == 0)
961. SetUsedMutators();
963. if (ActiveServerActors.Count() == 0)
964. SetUsedServerActors();
966. for (i=0;i<ActiveMutators.Count();i++)
967. {
968. MutClass=class<Mutator>(DynamicLoadObject(AllMutators[int(ActiveMutators.GetItem(i))].MutatorName,class'class'));
969. if (MutClass!=None)
970. {
971. MutClass.static.FillPlayInfo(PInfo);
972. PInfo.PopClass();
973. }
974. }
976. for (i=0;i<ActiveServerActors.Count();i++)
977. {
978. j = int(ActiveServerActors.GetItem(i));
979. SAClass = class<Info>(DynamicLoadObject(AllServerActors[j].ActorClass,class'Class'));
980. if (SAClass != None)
981. {
982. SAClass.static.FillPlayInfo(PInfo);
983. PInfo.PopClass();
984. }
985. }
987. // Create active profile array
988. InitializeProfile(ActiveSettings);
989. if (ProfileSettings.Length > 0)
990. {
991. ActiveSettings.Length = ProfileSettings.Length;
992. // Then retrieve all stored values from saved profile
993. for (i=0;i<ProfileSettings.Length;i++)
994. ActiveSettings[i] = ProfileSettings[i];
995. }
996. else // Copy active profile to saved profile.
997. {
998. ProfileSettings.Length = ActiveSettings.Length;
999. for (i=0;i<ActiveSettings.Length;i++)
1000. SetProfileParam(i,ActiveSettings[i].SettingName,ActiveSettings[i].SettingValue);
1001. }
1003. return string(GameClass);
1004. }
1006. protected function LoadGameTypes()
1007. {
1008. local class<GameInfo> TempClass;
1009. local String NextGame;
1010. local int i;
1012. // Compile a list of all gametypes.
1013. i = 0;
1014. NextGame = Level.GetNextInt("Engine.GameInfo", 0);
1015. AllGameTypes.Length = 0;
1016. while (NextGame != "")
1017. {
1018. TempClass = class<GameInfo>(DynamicLoadObject(NextGame, class'Class'));
1019. if (TempClass != None)
1020. AllGameTypes[AllGameTypes.Length] = TempClass;
1022. NextGame = Level.GetNextInt("Engine.GameInfo", ++i);
1023. }
1024. }
1026. protected function class<GameInfo> FindGameType(string GameType)
1027. {
1028. local class<GameInfo> TempClass;
1029. local int i;
1031. if (AllGameTypes.Length == 0)
1032. LoadGameTypes();
1033. TempClass = None;
1034. for (i=0; i<AllGameTypes.Length; i++)
1035. {
1036. TempClass = AllGameTypes[i];
1037. if (GameType ~= string(TempClass)) break;
1038. if (GameType ~= TempClass.default.Acronym) break;
1039. if (GameType ~= TempClass.default.DecoTextName) break;
1040. if (Right(string(TempClass), Len(GameType)+1) ~= ("."$GameType)) break;
1041. if (Right(TempClass.default.DecoTextName, Len(GameType)+1) ~= ("."$GameType)) break;
1042. }
1043. return TempClass;
1044. }
1046. protected function LoadAllMaps()
1047. {
1048. if (GameClass==None)
1049. GameClass = FindGameType(DefaultGameType);
1051. if (GameClass == None)
1052. return;
1054. GameMaps.Length = 0;
1055. GameClass.static.LoadMapList(GameClass.default.MapPrefix, GameMaps);
1056. }
1058. protected function LoadAllMutators()
1059. {
1060. class'xUtil'.static.GetMutatorList(GameMutators);
1061. }
1063. protected function LoadAllServerActors()
1064. {
1065. local int i;
1066. local ConfigMaster ConfigM;
1068. if (Level != None && Level.Game != None && Level.Game.BaseMutator != None && ConfigMaster(Level.Game.BaseMutator.NextMutator) != None)
1069. ConfigM = ConfigMaster(Level.Game.BaseMutator.NextMutator);
1070. else return;
1072. for (i=0;i<ConfigM.ManagedActors.Length;i++)
1073. GameServerActors[GameServerActors.Length] = string(ConfigM.ManagedActors[i].SAClass);
1074. }
1076. protected function bool MapIsValid(string MapName)
1077. {
1078. local string Prefix, ShortName;
1080. Divide(MapName,"-",Prefix,ShortName);
1081. if (Prefix ~= AllMapsPrefix)
1082. return true;
1083. return false;
1084. }
1086. protected function string GetMutatorGroup(string MutName)
1087. {
1088. local int i;
1090. if (GameMutators.Length == 0)
1091. LoadAllMutators();
1093. for (i=0;i<GameMutators.Length;i++)
1094. if (GameMutators[i].ClassName ~= MutName)
1095. return GameMutators[i].GroupName;
1097. return "";
1098. }
1100. protected function SetUsedMaps()
1101. {
1102. local int i,j;
1104. if (!bEdit)
1105. {
1106. log("SetUsedMaps()"@DidNotStartEdit);
1107. return;
1108. }
1110. if (AllMaps.Length == 0)
1111. return;
1113. ActiveMaps.Reset();
1115. // Add required maps first, up to MaxMaps count
1116. for (i=0;i<AllMaps.Length;i++)
1117. {
1118. if (MaxMaps > 0 && ActiveMaps.Count() >= MaxMaps)
1119. break;
1120. if (AllMaps[i].bRequired)
1121. ActiveMaps.Add(string(i),AllMaps[i].MapName);
1122. }
1124. if ((((MaxMaps > 0) && (ActiveMaps.Count() < MaxMaps)) || (MaxMaps == 0))&&(ProfileMaps.Length>0))
1125. {
1126. for (i=0;i<ProfileMaps.Length;i++)
1127. {
1128. if (!MapIsValid(ProfileMaps[i]))
1129. {
1130. ProfileMaps.Remove(i,1);
1131. i--;
1132. continue;
1133. }
1135. if (MaxMaps > 0 && ActiveMaps.Count() >= MaxMaps)
1136. break;
1137. for (j=0;j<AllMaps.Length;j++)
1138. if ((ProfileMaps[i]~=AllMaps[j].MapName) && (ActiveMaps.FindTagId(AllMaps[j].MapName)<0))
1139. ActiveMaps.Add(string(j), AllMaps[j].MapName);
1140. }
1141. }
1142. }
1144. // Loads used mutators from ini into ActiveMutators StringArray
1145. protected function SetUsedMutators()
1146. {
1147. local int i,j;
1148. local string MutatorGroups, tmp;
1149. if (!bEdit)
1150. {
1151. log("SetUsedMutators()"@DidNotStartEdit);
1152. return;
1153. }
1155. if (AllMutators.Length == 0)
1156. return;
1158. ActiveMutators.Reset();
1159. // Add required mutators first
1160. for (i=0;i<AllMutators.Length;i++)
1161. {
1162. if (AllMutators[i].bRequired)
1163. {
1164. tmp = GetMutatorGroup(AllMutators[i].MutatorName);
1165. if (InStr(MutatorGroups, tmp) == -1)
1166. {
1167. if (MutatorGroups != "") MutatorGroups = MutatorGroups $ ",";
1168. MutatorGroups = MutatorGroups $ tmp;
1169. ActiveMutators.Add(string(i), AllMutators[i].MutatorName);
1170. }
1171. }
1172. }
1174. for (i=0;i<ProfileMutators.Length;i++)
1175. {
1176. for (j=0;j<AllMutators.Length;j++)
1177. {
1178. if ((AllMutators[j].MutatorName ~= ProfileMutators[i])&&(ActiveMutators.FindTagId(AllMutators[j].MutatorName)<0))
1179. {
1180. tmp = GetMutatorGroup(AllMutators[j].MutatorName);
1181. if (InStr(MutatorGroups, tmp) == -1)
1182. {
1183. if (MutatorGroups != "") MutatorGroups = MutatorGroups $ ",";
1184. MutatorGroups = MutatorGroups $ tmp;
1185. ActiveMutators.Add(string(j), AllMutators[j].MutatorName);
1186. }
1187. }
1188. }
1189. }
1190. }
1192. protected function SetUsedServerActors()
1193. {
1194. local int i,j;
1195. if (!bEdit)
1196. {
1197. log("SetUsedServerActors()"@DidNotStartEdit);
1198. return;
1199. }
1201. if (AllServerActors.Length == 0)
1202. return;
1204. ActiveServerActors.Reset();
1205. // Add required server actors first
1206. for (i=0;i<AllServerActors.Length;i++)
1207. if (AllServerActors[i].bRequired)
1208. ActiveServerActors.Add(string(i), AllServerActors[i].ActorClass,True);
1210. for (i=0;i<ProfileServerActors.Length;i++)
1211. for (j=0;j<AllServerActors.Length;j++)
1212. if (AllServerActors[j].ActorClass ~= ProfileServerActors[i])
1213. ActiveServerActors.Add(string(j),AllServerActors[j].ActorClass,True);
1214. }
1216. protected function ClearUsedMaps()
1217. {
1218. ProfileMaps.Length = 0;
1219. SaveConfig();
1220. }
1222. protected function ClearUsedMutators()
1223. {
1224. ProfileMutators.Length = 0;
1225. SaveConfig();
1226. }
1228. protected function ClearUsedServerActors()
1229. {
1230. ProfileServerActors.Length = 0;
1231. SaveConfig();
1232. }
1234. protected function ClearAllMaps()
1235. {
1236. AllMaps.Length=0;
1237. SaveConfig();
1238. }
1240. protected function ClearAllMutators()
1241. {
1242. AllMutators.Length = 0;
1243. SaveConfig();
1244. }
1246. protected function ClearAllServerActors()
1247. {
1248. AllServerActors.Length = 0;
1249. SaveConfig();
1250. }
1252. // Saves active maps for this profile to ini
1253. protected function SaveUsedMaps()
1254. {
1255. local int i;
1256. if (!bEdit)
1257. {
1258. log("SaveUsedMaps()"@DidNotStartEdit);
1259. return;
1260. }
1262. ClearUsedMaps();
1263. for (i=0;i<ActiveMaps.Count();i++)
1264. ProfileMaps[ProfileMaps.Length] = ActiveMaps.GetTag(i);
1265. }
1267. // Saves ActiveMutators to ini
1268. protected function SaveUsedMutators()
1269. {
1270. local int i;
1272. if (!bEdit)
1273. {
1274. log("SaveUsedMutators()"@DidNotStartEdit);
1275. return;
1276. }
1278. ClearUsedMutators();
1279. for (i=0;i<ActiveMutators.Count();i++)
1280. ProfileMutators[ProfileMutators.Length] = ActiveMutators.GetTag(i);
1281. }
1283. protected function SaveUsedServerActors()
1284. {
1285. local int i;
1287. if (!bEdit)
1288. {
1289. log("SaveUsedServerActors()"@DidNotStartEdit);
1290. return;
1291. }
1292. ClearUsedServerActors();
1293. for (i=0;i<ActiveServerActors.Count();i++)
1294. ProfileServerActors[ProfileServerActors.Length] = ActiveServerActors.GetTag(i);
1295. }
1297. // Applies the active maps to the actual Game maplist
1298. protected function ApplyMapList(array<string> NewMapList)
1299. {
1300. local int i;
1302. if (GameClass == None)
1303. GameClass = class<GameInfo>(DynamicLoadObject(DefaultGameType,class'Class'));
1305. if (Maps == None)
1306. GetMaps();
1308. if (Maps == None)
1309. return;
1311. Maps.Maps.Length = 0;
1312. for (i=0;i<NewMapList.Length;i++)
1313. Maps.Maps[i] = NewMapList[i];
1315. Maps.SaveConfig();
1316. }
1318. // Applies ActiveMutators to actual Game mutator list
1319. protected function ApplyMutators()
1320. {
1321. local int i;
1322. local array<string> TempMut;
1324. if (!bEdit)
1325. {
1326. log("ApplyMutators()"@DidNotStartEdit);
1327. return;
1328. }
1330. for (i=0;i<ActiveMutators.Count();i++)
1331. TempMut[TempMut.Length] = ActiveMutators.GetTag(i);
1333. if (TempMut.Length == 0)
1334. NextMutators = "";
1336. else NextMutators = class'wUtils103.wArray'.static.Join(TempMut,",");
1337. }
1339. protected function ClearProfile(out array<ProfileSetting> OldProfile)
1340. {
1341. if (!bEdit)
1342. {
1343. log("ClearProfile()"@DidNotStartEdit);
1344. return;
1345. }
1347. OldProfile.Length = 0;
1348. }
1350. protected function bool InitializeProfile(out array<ProfileSetting> NewProfile)
1351. {
1352. local int i;
1353. local ProfileSetting NewSetting;
1355. if (!bEdit)
1356. {
1357. log("InitializeProfile()"@DidNotStartEdit);
1358. return false;
1359. }
1361. if (PInfo==None)
1362. return false;
1364. if (NewProfile.Length>0)
1365. ClearProfile(NewProfile);
1367. for (i = 0; i < PInfo.Settings.Length; i++)
1368. {
1369. if (InStr(PInfo.Settings[i].SettingName,"AdminName") != -1 || InStr(PInfo.Settings[i].SettingName,"AdminEmail") != -1)
1370. continue;
1372. NewSetting.SettingName = PInfo.Settings[i].SettingName;
1373. NewSetting.SettingValue = PInfo.Settings[i].Value;
1375. NewProfile[NewProfile.Length] = NewSetting;
1376. }
1378. return true;
1379. }
1381. ////////////////////////////////////////////////////////////////////////////
1382. // PlayInfo Query Functions
1383. ////////////////////////////////////////////////////////////////////////////
1385. function string GetParamName(int idx)
1386. {
1387. if (idx < 0 || idx >= PInfo.Settings.Length)
1388. return "";
1390. return PInfo.Settings[idx].SettingName;
1391. }
1393. function int GetParamIndex(string SettingName)
1394. {
1395. local int i;
1397. for (i = 0; i < PInfo.Settings.Length; i++)
1398. if (PInfo.Settings[i].SettingName ~= SettingName)
1399. break;
1401. if (i==PInfo.Settings.Length)
1402. return -1;
1404. return i;
1405. }
1407. function string GetParam(int idx)
1408. {
1409. if (idx < 0 || idx >= PInfo.Settings.Length)
1410. return "";
1412. return PInfo.Settings[idx].Value;
1413. }
1415. function string GetNamedParam(string Parameter)
1416. {
1417. local int i;
1418. local string SettingName;
1420. for (i = 0; i < PInfo.Settings.Length; i++)
1421. {
1422. SettingName = PInfo.Settings[i].SettingName;
1423. if (SettingName ~= Parameter || Right(SettingName, Len(Parameter) + 1) ~= ("."$Parameter))
1424. return PInfo.Settings[i].Value;
1425. }
1426. return "";
1427. }
1429. function array<string> GetMaskedParams(string ParamMask)
1430. {
1431. local array<string> FoundParams;
1432. local array<string> FoundMasks;
1433. local string SettingName, ShortName;
1434. local int i, j, p;
1436. class'wUtils103.wString'.static.Split2(ParamMask, " ", FoundMasks);
1437. if (FoundMasks.Length > 0)
1438. {
1439. for (i = 0; i<PInfo.Settings.Length; i++)
1440. {
1441. SettingName = PInfo.Settings[i].SettingName;
1443. ShortName = SettingName;
1444. j = Instr(ShortName, ".");
1445. while (j != -1)
1446. {
1447. ShortName = Mid(ShortName, p+1);
1448. j = Instr(ShortName, ".");
1449. }
1451. for (j = 0; j<FoundMasks.Length; j++)
1452. {
1453. if (class'wUtils103.wString'.static.MaskedCompare(ShortName, FoundMasks[j]) || class'wUtils103.wString'.static.MaskedCompare(SettingName, FoundMasks[j]))
1454. {
1455. FoundParams[FoundParams.Length] = SettingName;
1456. FoundParams[FoundParams.Length] = PInfo.Settings[i].Value;
1457. break;
1458. }
1459. }
1460. }
1461. }
1462. return FoundParams;
1463. }
1465. /////////////////////////////////////////////////////////////////////
1466. // Profile Query Functions
1467. ////////////////////////////////////////////////////////////////////
1469. function int GetProfileParamIndex(string SettingName)
1470. {
1471. local int i;
1473. for (i=0;i<ProfileSettings.Length;i++)
1474. if (ProfileSettings[i].SettingName ~= SettingName)
1475. break;
1477. if (i==ProfileSettings.Length)
1478. return -1;
1480. return i;
1481. }
1483. function string GetProfileParamName(int idx)
1484. {
1485. if (idx < 0 || idx >= ProfileSettings.Length)
1486. return "";
1488. return ProfileSettings[idx].SettingName;
1489. }
1491. function string GetProfileParam(int idx)
1492. {
1493. if (idx < 0 || idx >= ProfileSettings.Length)
1494. return "";
1496. return ProfileSettings[idx].SettingValue;
1497. }
1499. function string GetProfileNamedParam(string Parameter)
1500. {
1501. local int i;
1502. local string SettingName;
1504. for (i = 0; i < ProfileSettings.Length; i++)
1505. {
1506. SettingName = ProfileSettings[i].SettingName;
1507. if (SettingName ~= Parameter || Right(SettingName, Len(Parameter)+1) ~= ("."$Parameter))
1508. return ProfileSettings[i].SettingValue;
1509. }
1511. return "";
1512. }
1514. /////////////////////////////////////////////////////////////////////
1515. // PlayInfo Manipulation Functions
1516. /////////////////////////////////////////////////////////////////////
1518. function SavePI()
1519. {
1520. if (!bEdit)
1521. {
1522. log("SavePI()"@DidNotStartEdit);
1523. return;
1524. }
1526. if (PInfo == None)
1527. return;
1529. PInfo.SaveSettings();
1530. }
1532. function bool SetParam(int idx, string Value)
1533. {
1534. if (PInfo == None || idx < 0 || idx >= PInfo.Settings.Length)
1535. return false;
1537. if (InStr(PInfo.Settings[idx].SettingName,"AdminName") != -1 || InStr(PInfo.Settings[idx].SettingName,"AdminEmail") != -1)
1538. return false;
1540. return PInfo.StoreSetting(idx, Value);
1541. }
1543. function bool SetNamedParam(string Parameter, string Value)
1544. {
1545. local int i;
1546. local string SettingName;
1548. if (PInfo == None) return false;
1550. for (i = 0; i < PInfo.Settings.Length; i++)
1551. {
1552. SettingName = PInfo.Settings[i].SettingName;
1553. if (SettingName ~= Parameter || Right(SettingName, Len(Parameter) + 1) ~= ("."$Parameter))
1554. {
1555. if (InStr(PInfo.Settings[i].SettingName,"AdminName") != -1 || InStr(PInfo.Settings[i].SettingName,"AdminEmail") != -1)
1556. return false;
1558. return PInfo.StoreSetting(i, Value);
1559. }
1560. }
1561. // Parameter not found
1562. return false;
1563. }
1565. ///////////////////////////////////////////////////////////////////////////
1566. // Profile Manipulation Functions
1567. ///////////////////////////////////////////////////////////////////////////
1569. function int Count()
1570. {
1571. return ProfileSettings.Length;
1572. }
1574. function bool SetProfileParam(int idx, string SettingName, coerce string SettingValue)
1575. {
1576. if (idx < 0 || idx > ProfileSettings.Length)
1577. return false;
1579. if (ProfileSettings.Length == idx)
1580. ProfileSettings.Length = ProfileSettings.Length+1;
1582. ProfileSettings[idx].SettingName = SettingName;
1583. ProfileSettings[idx].SettingValue = SettingValue;
1585. return true;
1586. }
1588. function bool SetProfileNamedParam(string Parameter, string Value)
1589. {
1590. local int i;
1591. local string SettingName;
1593. for (i = 0;i < ProfileSettings.Length; i++)
1594. {
1595. SettingName = ProfileSettings[i].SettingName;
1596. if (SettingName ~= Parameter || Right(SettingName, Len(Parameter) + 1) ~= ("."$Parameter))
1597. {
1598. ProfileSettings[i].SettingValue = Value;
1599. return true;
1600. }
1601. }
1603. return false;
1604. }

##### Views

- Legacy
- Discussion
- Current revision

##### Search