Skip to content

Commit

Permalink
Prioritize MVE specific packages for download
Browse files Browse the repository at this point in the history
  • Loading branch information
peterekepeter committed Aug 7, 2024
1 parent a23eba1 commit b2afd44
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 33 deletions.
15 changes: 0 additions & 15 deletions MVES/Classes/MV_MainExtension.uc
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,6 @@ function TimedMessage( int ID)
}
}
function string GenerateSPList( string NewPacks)
{
local string Result;
local int i;
if ( (MapVote(Outer) == None) || (MapVote(Outer).MainServerPackages == "") )
return "";
Result = MapVote(Outer).MainServerPackages;
Result = Left( Result, Len(Result) -1 );
while ( NewPacks != "" )
Result = Result$","$chr(34)$static.NextParameter(NewPacks,",")$chr(34);
return Result$")";
}
function MLC_Rules( Info MapListCacheActor)
{
local MV_MapList MapList;
Expand Down
46 changes: 37 additions & 9 deletions MVES/Classes/MV_Result.uc
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ static function MV_Result Create(optional string map, optional int gameIdx)
return object;
}

function bool AddPackages(string packageNameList)
function AddPackages(string packageNameList)
{
local string packageName;

// unwrap decorations
if ( InStr(packageNameList, "(") == 0 )
{
packageNameList = Mid(packageNameList, 1, Len(packageNameList) - 2);
}

while ( class'MV_Parser'.static.TrySplit(packageNameList, ",", packageName, packageNameList) )
{
AddPackage(packageName);
Expand All @@ -58,20 +65,27 @@ function bool AddPackages(string packageNameList)
function bool AddPackage(string packageName)
{
local int i;

// unwrap decorations
if ( InStr(packageName, "\"") == 0 )
{
packageName = Mid(packageName, 1, Len(packageName) - 2);
}

if ( i >= ServerPackageMaxCount )
{
Err("Cannot add `"$packageName$"`, max server package count reached!");
return False;
}
for ( i = 0; i < ServerPackageCount; i ++ )
for ( i = 0; i < ServerPackageCount; i++ )
{
if ( ServerPackages[i] == packageName )
{
return False;
}
}
ServerPackages[ServerPackageCount] = packageName;
ServerPackageCount ++ ;
ServerPackageCount++;
return True;
}

Expand All @@ -80,14 +94,28 @@ function string GetPackagesStringList()
local string separator, result;
local int i;
separator = "";
for ( i = 0; i < ServerPackageCount; i ++ )
for ( i = 0; i < ServerPackageCount; i++ )
{
result = result$separator$ServerPackages[i];
separator = ",";
}
return result;
}

function string GetWrappedPackages()
{
local string separator, result;
local int i;
separator = "(\"";
for ( i = 0; i < ServerPackageCount; i++ )
{
result = result$separator$ServerPackages[i];
separator = "\",\"";
}
return result$"\")";
}


function bool AddMutators(string list)
{
local string mutator;
Expand All @@ -106,15 +134,15 @@ function bool AddMutator(string mutator)
Err("Cannot add `"$mutator$"`, max mutator count reached!");
return False;
}
for ( i = 0; i < MutatorCount; i ++ )
for ( i = 0; i < MutatorCount; i++ )
{
if ( Mutators[i] == mutator )
{
return False;
}
}
Mutators[MutatorCount] = mutator;
MutatorCount ++ ;
MutatorCount++;
return True;
}

Expand All @@ -136,15 +164,15 @@ function bool AddActor(string actor)
Err("Cannot add `"$actor$"`, max server actor count reached!");
return False;
}
for ( i = 0; i < ActorCount; i ++ )
for ( i = 0; i < ActorCount; i++ )
{
if ( Actors[i] == actor )
{
return False;
}
}
Actors[ActorCount] = actor;
ActorCount ++ ;
ActorCount++;
return True;
}

Expand Down Expand Up @@ -186,7 +214,7 @@ function bool UpdateSingleGameSetting(string key, string value)
}
SettingsKey[SettingsCount] = key;
SettingsValue[SettingsCount] = value;
SettingsCount ++ ;
SettingsCount++;
return True;
}

Expand Down
7 changes: 2 additions & 5 deletions MVES/Classes/MapVote.uc
Original file line number Diff line number Diff line change
Expand Up @@ -1593,11 +1593,8 @@ final function bool SetupTravelString( string mapStringWithIdx )
// add gametype packages
Result.AddPackages(CustomGame[Result.GameIndex].Packages);
// concats main packages
spk = Extension.GenerateSPList(Result.GetPackagesStringList());
if ( spk == "" )
{
spk = MainServerPackages;
}
Result.AddPackages(MainServerPackages);
spk = Result.GetWrappedPackages();
if ( InStr( spk, "<") >= 0 )
{
spk = ParseAliases( spk);
Expand Down
2 changes: 1 addition & 1 deletion TestMVE/Classes/TestAll.uc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class TestAll extends TestClass;
function TestMain()
{
TestChild(class'TestSort');
TestChild(class'TestMapVoteResult');
TestChild(class'TestMapTags');
TestChild(class'TestMapListEncoder');
TestChild(class'TestMvAliases');
TestChild(class'TestMapHistory');
TestChild(class'TestMapVoteResult');
}
19 changes: 16 additions & 3 deletions TestMVE/Classes/TestMapVoteResult.uc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function TestMain()
TestIntProperties();
TestActors();
TestSettings();
TestWrappedPackages();
}

function TestPackages()
Expand All @@ -24,6 +25,16 @@ function TestPackages()
AssertEquals(s.GetPackagesStringList(), "Package1,Package2,Package3", "can get string list");
}

function TestWrappedPackages()
{
Describe("MV_Result accepts packages wrapped in paren");
s.AddPackages("(\"SoldierSkins\",\"CommandoSkins\")");
AssertEquals(s.GetPackagesStringList(), "SoldierSkins,CommandoSkins", "can get string list");
s.AddPackages("(\"MVE2h\",\"CommandoSkins\")");
AssertEquals(s.GetPackagesStringList(), "SoldierSkins,CommandoSkins,MVE2h", "appends additional");
AssertEquals(s.GetWrappedPackages(), "(\"SoldierSkins\",\"CommandoSkins\",\"MVE2h\")", "can wrap packages");
}

function TestMapLoading()
{

Expand Down Expand Up @@ -85,15 +96,17 @@ function TestStringProperties()
AssertEquals(s.FilterCode, "dmlist", "empty string does not change FilterCode");
}

function TestIntProperties(){
function TestIntProperties()
{
Describe("int properties");
s.SetTickRate(75);
AssertEquals(s.TickRate, 75, "sets tickrate");
s.SetTickRate(0);
AssertEquals(s.TickRate, 75, "previous tickrate is kept when settikng to 0");
}

function TestSettings(){
function TestSettings()
{
Describe("game settings");
s.AddGameSettings("FragLimit=30,TimeLimit=0,GameSpeed=1.00,MinPlayers=2,bUseTranslocator=False,GameName=Instagib Deathmatch");
AssertEquals(s.SettingsCount, 6, "parses settings correctly");
Expand All @@ -114,6 +127,6 @@ function TestSettings(){

function Describe(string subject)
{
super.Describe(subject);
Super.Describe(subject);
s = new class'MV_Result';
}

0 comments on commit b2afd44

Please sign in to comment.