Ejemplo n.º 1
0
 /// <summary>
 /// Decompiles this object into a text format of:
 ///
 /// enum NAME
 /// {
 ///     [ELEMENTS]
 /// };
 /// </summary>
 /// <returns></returns>
 public override string Decompile()
 {
     return(UDecompilingState.Tabs + FormatHeader() +
            UnrealConfig.PrintBeginBracket() +
            FormatNames() +
            UnrealConfig.PrintEndBracket() + ";");
 }
Ejemplo n.º 2
0
        private string FormatCode()
        {
            UDecompilingState.AddTabs(1);
            string locals = FormatLocals();

            if (locals != String.Empty)
            {
                locals += "\r\n";
            }
            string code;

            try
            {
                code = DecompileScript();
            }
            catch (Exception e)
            {
                code = e.Message;
            }
            finally
            {
                UDecompilingState.RemoveTabs(1);
            }

            // Empty function!
            if (String.IsNullOrEmpty(locals) && String.IsNullOrEmpty(code))
            {
                return(String.Empty);
            }

            return(UnrealConfig.PrintBeginBracket() + "\r\n" +
                   locals +
                   code +
                   UnrealConfig.PrintEndBracket());
        }
Ejemplo n.º 3
0
        protected string FormatCPPText()
        {
            if (CppText == null)
            {
                return(String.Empty);
            }

            string output = String.Format("\r\n{0}{1}{2}\r\n",
                                          UDecompilingState.Tabs,
                                          CPPTextKeyword,
                                          UnrealConfig.PrintBeginBracket()
                                          );

            output += CppText.Decompile() + UnrealConfig.PrintEndBracket() + "\r\n";
            return(output);
        }
        /// <summary>
        /// Decompiles this object into a text format of:
        ///
        /// [FLAGS] state[()] NAME [extends NAME]
        /// {
        ///     [ignores Name[,Name];]
        ///
        ///     [FUNCTIONS]
        ///
        /// [STATE CODE]
        /// };
        /// </summary>
        /// <returns></returns>
        public override string Decompile()
        {
            string content = FormatHeader() + UnrealConfig.PrintBeginBracket();

            UDecompilingState.AddTabs(1);

            var locals = FormatLocals();

            if (locals != String.Empty)
            {
                content += "\r\n" + locals;
            }

            content += FormatIgnores() +
                       FormatConstants() +
                       FormatFunctions() +
                       DecompileScript();
            UDecompilingState.RemoveTabs(1);
            content += UnrealConfig.PrintEndBracket();
            return(content);
        }
Ejemplo n.º 5
0
        public GameOptions ReadGameOptions()
        {
            var config    = new UnrealConfig(GameConfigPath);
            var enbConfig = new UnrealConfig(EnbConfigPath);

            var options = new GameOptions
            {
                Language    = ParseLanguage(config.GetSetting("Engine.Engine", "Language")),
                Resolution  = ParseResolution(config.GetSetting("WinDrv.WindowsClient", "FullscreenViewportX"), config.GetSetting("WinDrv.WindowsClient", "FullscreenViewportY")),
                RunInWindow = !bool.Parse(config.GetSetting("WinDrv.WindowsClient", "StartupFullscreen"))
            };

            switch (config.GetSetting("Engine.Engine", "GameRenderDevice"))
            {
            case "OpenGLDrv.OpenGLRenderDevice":
                options.Effect = ScreenEffect.OpenGL;
                break;

            case "D3D9Drv.D3D9RenderDevice":
                options.Effect = int.Parse(enbConfig.GetSetting("GLOBAL", "UseEffect")) == 1 ? ScreenEffect.D3D9_ENB : ScreenEffect.D3D9;
                break;

            case "D3D10Drv.D3D10RenderDevice":
                options.Effect = ScreenEffect.D3D10;
                break;
            }

            if (options.Resolution.Width <= 0 || options.Resolution.Height <= 0)
            {
                options.Resolution = new ScreenResolution
                {
                    Width  = Convert.ToUInt32(SystemParameters.VirtualScreenWidth),
                    Height = Convert.ToUInt32(SystemParameters.VirtualScreenHeight)
                };

                options.RunInWindow = false;
            }

            return(options);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Decompiles this object into a text format of:
        ///
        /// struct [FLAGS] NAME [extends NAME]
        /// {
        ///     [STRUCTCPPTEXT]
        ///
        ///     [CONSTS]
        ///
        ///     [ENUMS]
        ///
        ///     [STRUCTS]
        ///
        ///     [VARIABLES]
        ///
        ///     [STRUCTDEFAULTPROPERTIES]
        /// };
        /// </summary>
        /// <returns></returns>
        public override string Decompile()
        {
            string content = UDecompilingState.Tabs + FormatHeader() +
                             UnrealConfig.PrintBeginBracket();

            UDecompilingState.AddTabs(1);
            string cpptext = FormatCPPText();
            string props   = FormatProperties();

            string defProps = FormatDefaultProperties();

            if (defProps.Length != 0)
            {
                defProps += "\r\n";
            }
            UDecompilingState.RemoveTabs(1);
            content += cpptext + props + defProps;
            if (content.EndsWith("\r\n"))
            {
                content = content.TrimEnd('\r', '\n');
            }
            return(content + UnrealConfig.PrintEndBracket() + ";");
        }
Ejemplo n.º 7
0
        public string FormatReplication()
        {
            if (DataScriptSize <= 0)
            {
                return(string.Empty);
            }

            var replicatedObjects = new List <IUnrealNetObject>();

            if (Variables != null)
            {
                replicatedObjects.AddRange(Variables.Where(prop => prop.HasPropertyFlag(Flags.PropertyFlagsLO.Net) && prop.RepOffset != ushort.MaxValue));
            }

            if (Package.Version < VReliableDeprecation && Functions != null)
            {
                replicatedObjects.AddRange(Functions.Where(func => func.HasFunctionFlag(Flags.FunctionFlags.Net) && func.RepOffset != ushort.MaxValue));
            }

            if (replicatedObjects.Count == 0)
            {
                return(string.Empty);
            }

            var statements = new Dictionary <uint, List <IUnrealNetObject> >();

            replicatedObjects.Sort((ro, ro2) => ro.RepKey.CompareTo(ro2.RepKey));
            for (int netIndex = 0; netIndex < replicatedObjects.Count; ++netIndex)
            {
                var firstObject = replicatedObjects[netIndex];
                var netObjects  = new List <IUnrealNetObject> {
                    firstObject
                };
                for (int nextIndex = netIndex + 1; nextIndex < replicatedObjects.Count; ++nextIndex)
                {
                    var nextObject = replicatedObjects[nextIndex];
                    if (nextObject.RepOffset != firstObject.RepOffset ||
                        nextObject.RepReliable != firstObject.RepReliable
                        )
                    {
                        netIndex = nextIndex - 1;
                        break;
                    }
                    netObjects.Add(nextObject);
                }

                netObjects.Sort((o, o2) => string.Compare(o.Name, o2.Name, StringComparison.Ordinal));
                if (!statements.ContainsKey(firstObject.RepKey))
                {
                    statements.Add(firstObject.RepKey, netObjects);
                }
            }
            replicatedObjects.Clear();

            var output = new StringBuilder("\r\n" + "replication" + UnrealConfig.PrintBeginBracket());

            UDecompilingState.AddTab();

            foreach (var statement in statements)
            {
                try
                {
                    var pos = (ushort)(statement.Key & 0x0000FFFF);
                    var rel = Convert.ToBoolean(statement.Key & 0xFFFF0000);

                    output.Append("\r\n" + UDecompilingState.Tabs);
                    if (!UnrealConfig.SuppressComments)
                    {
                        output.AppendFormat("// Pos:0x{0:X3}\r\n{1}", pos, UDecompilingState.Tabs);
                    }

                    ByteCodeManager.Deserialize();
                    ByteCodeManager.JumpTo(pos);
                    string statementCode;
                    try
                    {
                        statementCode = ByteCodeManager.CurrentToken.Decompile();
                    }
                    catch (Exception e)
                    {
                        statementCode = string.Format("/* An exception occurred while decompiling condition ({0}) */", e);
                    }
                    var statementType   = Package.Version < VReliableDeprecation ? rel ? "reliable" : "unreliable" : string.Empty;
                    var statementFormat = string.Format("{0} if({1})", statementType, statementCode);
                    output.Append(statementFormat);

                    UDecompilingState.AddTab();
                    // NetObjects
                    for (int i = 0; i < statement.Value.Count; ++i)
                    {
                        var shouldSplit = i % 2 == 0;
                        if (shouldSplit)
                        {
                            output.Append("\r\n" + UDecompilingState.Tabs);
                        }

                        var netObject = statement.Value[i];
                        output.Append(netObject.Name);

                        var isNotLast = i != statement.Value.Count - 1;
                        output.Append(isNotLast ? ", " : ";");
                    }
                    UDecompilingState.RemoveTab();

                    // IsNotLast
                    if (statements.Last().Key != statement.Key)
                    {
                        output.Append("\r\n");
                    }
                }
                catch (Exception e)
                {
                    output.AppendFormat("/* An exception occurred while decompiling a statement! ({0}) */", e);
                }
            }
            UDecompilingState.RemoveTab();
            output.Append(UnrealConfig.PrintEndBracket() + "\r\n");
            return(output.ToString());
        }
Ejemplo n.º 8
0
        public void SaveGameOptions(GameOptions options)
        {
            var config = new UnrealConfig(GameConfigPath);

            string language;

            switch (options.Language)
            {
            case GameLanguage.Russian:
                language = LanguageRussian;
                break;

            case GameLanguage.English:
                language = LanguageEnglish;
                break;

            default:
                throw new Exception("Invalid language");
            }

            switch (options.Effect)
            {
            case ScreenEffect.OpenGL:
                config.SetSetting("Engine.Engine", "GameRenderDevice", "OpenGLDrv.OpenGLRenderDevice");
                break;

            case ScreenEffect.D3D9:
            case ScreenEffect.D3D9_ENB:
                config.SetSetting("Engine.Engine", "GameRenderDevice", "D3D9Drv.D3D9RenderDevice");
                break;

            case ScreenEffect.D3D10:
                config.SetSetting("Engine.Engine", "GameRenderDevice", "D3D10Drv.D3D10RenderDevice");
                break;
            }

            config.SetSetting("WinDrv.WindowsClient", "WindowedViewportX", options.Resolution.Width.ToString());
            config.SetSetting("WinDrv.WindowsClient", "WindowedViewportY", options.Resolution.Height.ToString());
            config.SetSetting("WinDrv.WindowsClient", "FullscreenViewportX", options.Resolution.Width.ToString());
            config.SetSetting("WinDrv.WindowsClient", "FullscreenViewportY", options.Resolution.Height.ToString());
            config.SetSetting("WinDrv.WindowsClient", "StartupFullscreen", !options.RunInWindow ? "True" : "False");

            config.SetSetting("Engine.Engine", "Language", language);
            config.Save();

            var enbConfig = new UnrealConfig(EnbConfigPath);

            enbConfig.SetSetting("GLOBAL", "UseEffect", options.Effect == ScreenEffect.D3D9_ENB ? "1" : "0");
            enbConfig.Save();

            var userConfig = new UnrealConfig(UserConfigPath);
            var fov        = CalculateFov(options.Resolution);

            userConfig.SetSetting("Engine.PlayerPawn", "DesiredFOV", fov.ToString());
            userConfig.SetSetting("Engine.PlayerPawn", "DefaultFOV", fov.ToString());

            userConfig.SetSetting("DeusEx.DeusExPlayer", "bShowItemArticles",
                                  options.Language == GameLanguage.English ? "True" : "False");

            userConfig.Save();
        }
Ejemplo n.º 9
0
        public void Init(Frame frame)
        {
            mFrame = frame;
            mConfig = new UnrealConfig(frame.Name);

            if (mConfig.AutoStartUnreal)
                Launch();
            else if (mConfig.AutoStartServer)
                StartServer();
        }