Skip to content

Commit

Permalink
fixes #15. Push Support-Transformers to Master.
Browse files Browse the repository at this point in the history
  • Loading branch information
EliotVU committed Sep 28, 2015
2 parents 7fa9683 + 570abf9 commit 6e14040
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 16 deletions.
12 changes: 12 additions & 0 deletions src/Core/Classes/Props/Custom/UScriptMapProperty.cs
@@ -0,0 +1,12 @@
#if TRANSFORMERS
namespace UELib.Core
{
/// <summary>
/// ScriptMap Property
/// </summary>
[UnrealRegisterClass]
public class UScriptMapProperty : UMapProperty
{
}
}
#endif
6 changes: 5 additions & 1 deletion src/Core/Classes/UClass.cs
Expand Up @@ -170,7 +170,11 @@ protected override void Deserialize()
if( Package.Version >= 220 )
{
// TODO: Corrigate Version
if( isHideCategoriesOldOrder && !Package.IsConsoleCooked() && !Package.Build.IsXenonCompressed )
if( (isHideCategoriesOldOrder && !Package.IsConsoleCooked() && !Package.Build.IsXenonCompressed)
#if TRANSFORMERS
|| Package.Build == UnrealPackage.GameBuild.BuildName.Transformers
#endif
)
{
DeserializeHideCategories();
}
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Classes/UField.cs
Expand Up @@ -30,6 +30,9 @@ protected override void Deserialize()
if( (Package.Version < 756
#if SPECIALFORCE2
|| Package.Build == UnrealPackage.GameBuild.BuildName.SpecialForce2
#endif
#if TRANSFORMERS
|| Package.Build == UnrealPackage.GameBuild.BuildName.Transformers
#endif
)
#if BIOSHOCK
Expand Down
12 changes: 12 additions & 0 deletions src/Core/Classes/UFunction.cs
Expand Up @@ -81,14 +81,26 @@ protected override void Deserialize()
_Buffer.Skip( 5 );
}

#if TRANSFORMERS
FunctionFlags = Package.Build == UnrealPackage.GameBuild.BuildName.Transformers ? _Buffer.ReadUInt64() : _Buffer.ReadUInt32();
#else
FunctionFlags = _Buffer.ReadUInt32();
#endif
Record( "FunctionFlags", (FunctionFlags)FunctionFlags );
if( HasFunctionFlag( Flags.FunctionFlags.Net ) )
{
RepOffset = _Buffer.ReadUShort();
Record( "RepOffset", RepOffset );
}

#if TRANSFORMERS
if( Package.Build == UnrealPackage.GameBuild.BuildName.Transformers )
{
FriendlyName = Table.ObjectName;
return;
}
#endif

if( (Package.Version >= VFriendlyName && !Package.IsConsoleCooked())
#if MKKE
|| Package.Build == UnrealPackage.GameBuild.BuildName.MKKE
Expand Down
20 changes: 18 additions & 2 deletions src/Core/Classes/UState.cs
Expand Up @@ -58,6 +58,13 @@ protected override void Deserialize()
// 64b ProbeMask
// 64b IgnoreMask

#if TRANSFORMERS
if( Package.Build == UnrealPackage.GameBuild.BuildName.Transformers )
{
goto noMasks;
}
#endif

// UE3
if( Package.Version >= 220 )
{
Expand Down Expand Up @@ -85,14 +92,15 @@ protected override void Deserialize()
Record( "_IgnoreMask", _IgnoreMask );
}

noMasks:
_LabelTableOffset = _Buffer.ReadInt16();
Record( "_LabelTableOffset", _LabelTableOffset );

if( Package.Version > VStateFlags )
{
#if BORDERLANDS2
#if BORDERLANDS2 || TRANSFORMERS
// FIXME:Temp fix
if( Package.Build == UnrealPackage.GameBuild.BuildName.Borderlands2 )
if( Package.Build == UnrealPackage.GameBuild.BuildName.Borderlands2 || Package.Build == UnrealPackage.GameBuild.BuildName.Transformers )
{
_StateFlags = _Buffer.ReadUShort();
goto skipStateFlags;
Expand All @@ -104,6 +112,14 @@ protected override void Deserialize()
Record( "StateFlags", (StateFlags)_StateFlags );
}

#if TRANSFORMERS
if( Package.Build == UnrealPackage.GameBuild.BuildName.Transformers )
{
_Buffer.Skip( 4 );
return;
}
#endif

if( Package.Version >= 220 )
{
int mapCount = _Buffer.ReadIndex();
Expand Down
17 changes: 15 additions & 2 deletions src/Core/Classes/UStruct.cs
Expand Up @@ -139,10 +139,23 @@ protected override void Deserialize()
Record( "TextPos", TextPos );
}

#if TRANSFORMERS
if( Package.Build == UnrealPackage.GameBuild.BuildName.Transformers )
{
// The line where the struct's code body ends.
_Buffer.Skip( 4 );
}
#endif

ByteScriptSize = _Buffer.ReadInt32();
Record( "ByteScriptSize", ByteScriptSize );
const int vDataScriptSize = 639;
if( Package.Version >= vDataScriptSize )
var hasFixedScriptSize = Package.Version >= vDataScriptSize
#if TRANSFORMERS
&& Package.Build != UnrealPackage.GameBuild.BuildName.Transformers
#endif
;
if( hasFixedScriptSize )
{
DataScriptSize = _Buffer.ReadInt32();
Record( "DataScriptSize", DataScriptSize );
Expand All @@ -158,7 +171,7 @@ protected override void Deserialize()
return;

ByteCodeManager = new UByteCodeDecompiler( this );
if( Package.Version >= vDataScriptSize )
if( hasFixedScriptSize )
{
_Buffer.Skip( DataScriptSize );
}
Expand Down
13 changes: 13 additions & 0 deletions src/Core/Tables/UExportTableItem.cs
Expand Up @@ -121,6 +121,9 @@ public void Deserialize( IUnrealStream stream )
if( stream.Version < 543
#if ALPHAPROTOCOL
&& stream.Package.Build != UnrealPackage.GameBuild.BuildName.AlphaProtcol
#endif
#if TRANSFORMERS
&& (stream.Package.Build != UnrealPackage.GameBuild.BuildName.Transformers || stream.Package.LicenseeVersion < 37)
#endif
)
{
Expand All @@ -142,6 +145,16 @@ public void Deserialize( IUnrealStream stream )
ExportFlags = stream.ReadUInt32();
if( stream.Version < 322 )
return;
#if TRANSFORMERS
if( stream.Package.Build == UnrealPackage.GameBuild.BuildName.Transformers && stream.Package.LicenseeVersion >= 116 )
{
var flag = stream.ReadByte();
if( flag == 0 )
{
return;
}
}
#endif
#if BIOSHOCK
if( stream.Package.Build == UnrealPackage.GameBuild.BuildName.Bioshock_Infinite )
{
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Tokens/ContextTokens.cs
Expand Up @@ -15,6 +15,9 @@ public override void Deserialize( IUnrealStream stream )
var propertyAdded = stream.Version >= VSizeByteMoved
#if TERA
&& stream.Package.Build != UnrealPackage.GameBuild.BuildName.Tera
#endif
#if TRANSFORMERS
&& stream.Package.Build != UnrealPackage.GameBuild.BuildName.Transformers
#endif
;

Expand Down
9 changes: 9 additions & 0 deletions src/Core/Tokens/JumpTokens.cs
Expand Up @@ -342,6 +342,14 @@ public class SwitchToken : Token

public override void Deserialize( IUnrealStream stream )
{
#if TRANSFORMERS
if( Package.Build == UnrealPackage.GameBuild.BuildName.Transformers )
{
PropertyType = stream.ReadUInt16();
Decompiler.AlignSize( sizeof(ushort) );
goto deserialize;
}
#endif
if( stream.Version >= 600 )
{
// Points to the object that was passed to the switch,
Expand All @@ -362,6 +370,7 @@ public override void Deserialize( IUnrealStream stream )
Decompiler.AlignSize( sizeof(byte) );
}

deserialize:
// Expression
DeserializeNext();
}
Expand Down
5 changes: 3 additions & 2 deletions src/Eliot.UELib.csproj
Expand Up @@ -42,7 +42,7 @@
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\..\..\..\..\Program Files %28x86%29\UE Explorer\</OutputPath>
<DefineConstants>TRACE;DEBUG;DECOMPILE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 DEBUG_TEST APB SPECIALFORCE2 XIII SINGULARITY THIEFDEADLYSHADOWS BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE</DefineConstants>
<DefineConstants>TRACE;DEBUG;DECOMPILE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 DEBUG_TEST APB SPECIALFORCE2 XIII SINGULARITY THIEFDEADLYSHADOWS BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -115,6 +115,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BinaryMetaData.cs" />
<Compile Include="Core\Classes\Props\Custom\UScriptMapProperty.cs" />
<Compile Include="Core\Classes\Props\UArrayProperty.cs" />
<Compile Include="Core\Classes\Props\UBoolProperty.cs" />
<Compile Include="Core\Classes\Props\UByteProperty.cs" />
Expand Down Expand Up @@ -242,7 +243,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.None" />
<UserProperties BuildVersion_BuildVersioningStyle="None.None.Increment.None" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
37 changes: 31 additions & 6 deletions src/UnrealPackage.cs
Expand Up @@ -139,6 +139,7 @@ public ushort LicenseeVersion

public class GameBuild
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
private sealed class BuildAttribute : Attribute
{
private readonly int _MinVersion;
Expand Down Expand Up @@ -405,6 +406,16 @@ public enum BuildName
[Build( 845, 59 )]
XCOM_EU,

/// <summary>
/// 846/181
/// </summary>
[Build( 511, 039 )] // The Bourne Conspiracy
[Build( 511, 145 )] // Transformers: War for Cybertron (PC version)
[Build( 511, 144 )] // Transformers: War for Cybertron (PS3 and XBox 360 version)
[Build( 537, 174 )] // Transformers: Dark of the Moon
[Build( 846, 181, 2, 1 )] // Transformers: Fall of Cybertron
Transformers,

/// <summary>
/// 860/004
/// </summary>
Expand Down Expand Up @@ -449,11 +460,8 @@ public GameBuild( UnrealPackage package )
continue;

var attribs = gameBuildMember[0].GetCustomAttributes( false );
if( attribs.Length == 0 )
continue;

var myAttrib = attribs[0] as BuildAttribute;
if( !myAttrib.Verify( this, package ) )
var game = attribs.OfType<BuildAttribute>().SingleOrDefault(attr => attr.Verify( this, package ));
if( game == null )
continue;

Name = (BuildName)Enum.Parse( typeof(BuildName), Enum.GetName( typeof(BuildName), gameBuild ) );
Expand Down Expand Up @@ -573,12 +581,19 @@ public void Deserialize( IUnrealStream stream )
return;

DependsOffset = stream.ReadUInt32();
if( stream.Version >= 584 )
if( stream.Version >= 584
#if TRANSFORMERS
|| (stream.Package.Build == GameBuild.BuildName.Transformers && stream.Version >= 535)
#endif
)
{
// Additional tables, like thumbnail, and guid data.
if( stream.Version >= 623
#if BIOSHOCK
&& stream.Package.Build != GameBuild.BuildName.Bioshock_Infinite
#endif
#if TRANSFORMERS
&& stream.Package.Build != GameBuild.BuildName.Transformers // FIXME: This is not skipped Gildor's UModel game support odd?
#endif
)
{
Expand Down Expand Up @@ -835,6 +850,16 @@ public void Deserialize( UPackageStream stream )
{
stream.Skip( 8 );
}
#endif
#if TRANSFORMERS
if( Build == GameBuild.BuildName.Transformers && LicenseeVersion >= 55 )
{
if( LicenseeVersion >= 181 )
{
stream.Skip( 16 );
}
stream.Skip( 4 );
}
#endif
// Offset to the first class(not object) in the package.
HeaderSize = stream.ReadUInt32();
Expand Down
26 changes: 23 additions & 3 deletions src/UnrealStream.cs
Expand Up @@ -167,6 +167,7 @@ public string ReadText()
return ReadAnsi();
}

byte[] strBytes;
int unfixedSize; var size = (unfixedSize =
#if BIOSHOCK
_UnrealStream.Package.Build == UnrealPackage.GameBuild.BuildName.Bioshock ? -ReadIndex() :
Expand All @@ -175,9 +176,18 @@ public string ReadText()
System.Diagnostics.Debug.Assert( size < 1000000, "Dangerous string size detected! IT'S OVER 9000 THOUSAND!" );
if( unfixedSize > 0 ) // ANSI
{
var strBytes = new byte[size - 1];
#if TRANSFORMERS
if( _UnrealStream.Package.Build == UnrealPackage.GameBuild.BuildName.Transformers && _UnrealStream.Package.LicenseeVersion >= 181 )
{
strBytes = new byte[size];
Read( strBytes, 0, size);
goto reverse;
}
#endif
strBytes = new byte[size - 1];
Read( strBytes, 0, size - 1 );
++ BaseStream.Position; // null
reverse:
if( _MyEncoding == Encoding.BigEndianUnicode )
{
Array.Reverse( strBytes );
Expand All @@ -190,9 +200,19 @@ public string ReadText()

if( unfixedSize < 0 ) // UNICODE
{
var strBytes = new byte[(size * 2) - 2];
Read( strBytes, 0, (size * 2) - 2 );
size *= 2;
#if TRANSFORMERS
if( _UnrealStream.Package.Build == UnrealPackage.GameBuild.BuildName.Transformers && _UnrealStream.Package.LicenseeVersion >= 181 )
{
strBytes = new byte[size];
Read( strBytes, 0, size);
goto reverse;
}
#endif
strBytes = new byte[size - 2];
Read( strBytes, 0, size - 2 );
BaseStream.Position += 2; // null
reverse:
// Convert Byte Str to a String type
if( _MyEncoding == Encoding.BigEndianUnicode )
{
Expand Down

0 comments on commit 6e14040

Please sign in to comment.