mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 13:51:40 +00:00
Fix Lua scripts not being read from WAD files
This commit is contained in:
parent
86422d7498
commit
cca2949f6d
2 changed files with 58 additions and 1 deletions
|
@ -1140,7 +1140,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
if (issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
return GetAllLumpsData("LUA_");
|
||||
return GetAllLumpsDataWithPrefix("LUA_");
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
@ -1192,6 +1192,25 @@ namespace CodeImp.DoomBuilder.Data
|
|||
return result;
|
||||
}
|
||||
|
||||
//mxd
|
||||
private List<TextResourceData> GetAllLumpsDataWithPrefix(string prefix)
|
||||
{
|
||||
List<TextResourceData> result = new List<TextResourceData>();
|
||||
|
||||
// Find all lumps with given name
|
||||
int lumpindex = file.FindLumpIndexWithPrefix(prefix);
|
||||
while (lumpindex > -1)
|
||||
{
|
||||
// Add to collection
|
||||
result.Add(new TextResourceData(this, file.Lumps[lumpindex].GetSafeStream(), prefix, lumpindex, true));
|
||||
|
||||
// Find next entry
|
||||
lumpindex = file.FindLumpIndexWithPrefix(prefix, lumpindex + 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== IO (mxd)
|
||||
|
|
|
@ -568,6 +568,44 @@ namespace CodeImp.DoomBuilder.IO
|
|||
return -1;
|
||||
}
|
||||
|
||||
// This finds a lump with given prefix, returns -1 when not found
|
||||
public int FindLumpIndexWithPrefix(string prefix)
|
||||
{
|
||||
// Do search
|
||||
return FindLumpIndexWithPrefix(prefix, 0, lumps.Count - 1);
|
||||
}
|
||||
|
||||
// This finds a lump with given prefix, returns -1 when not found
|
||||
public int FindLumpIndexWithPrefix(string prefix, int start)
|
||||
{
|
||||
// Do search
|
||||
return FindLumpIndex(prefix, start, lumps.Count - 1);
|
||||
}
|
||||
|
||||
// This finds a lump with given prefix, returns -1 when not found
|
||||
public int FindLumpIndexWithPrefix(string prefix, int start, int end)
|
||||
{
|
||||
if (prefix.Length > 8 || lumps.Count == 0 || start > lumps.Count - 1) return -1; //mxd. Can't be here. Go away!
|
||||
|
||||
// Fix start/end when they exceed safe bounds
|
||||
start = Math.Max(start, 0);
|
||||
end = General.Clamp(end, 0, lumps.Count - 1);
|
||||
|
||||
// Loop through the lumps
|
||||
for (int i = start; i < end + 1; i++)
|
||||
{
|
||||
// Check if the lump name matches
|
||||
if (lumps[i].Name.StartsWith(prefix))
|
||||
{
|
||||
// Found the lump!
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found
|
||||
return -1;
|
||||
}
|
||||
|
||||
//mxd. Same as above, but searches in reversed order
|
||||
|
||||
// This finds a lump by name, returns null when not found
|
||||
|
|
Loading…
Reference in a new issue