Beispiel #1
0
        unsafe private static IntPtr VirtualMachine__RunFunctionHook(VirtualMachinePtr virtualMachine, String functionName, Int32 a3, Int32 a4, Int32 a5, Int32 a6)
        {
            var result = IntPtr.Zero;

            try
            {
                switch (functionName)
                {
                case "config":
                    var file = Storm.FileOpenFileEx(IntPtr.Zero, "war3map.cs", 0);
                    if (file != IntPtr.Zero)
                    {
                        var script = Storm.FileReadToEnd(file);
                        Storm.FileCloseFile(file);
                        InternalScript.OnScriptLoad(script);
                    }
                    else
                    {
                        InternalScript.OnScriptLoad(null);
                    }
                    InternalScript.OnPreConfig(InternalGame.IsInMap);
                    result = InternalScript.VirtualMachine__RunFunction(virtualMachine, functionName, a3, a4, a5, a6);
                    InternalScript.OnPostConfig(InternalGame.IsInMap);
                    break;

                case "main":
                    InternalScript.OnPreMain();
                    result = InternalScript.VirtualMachine__RunFunction(virtualMachine, functionName, a3, a4, a5, a6);
                    InternalScript.OnPostMain();
                    break;

                default:
                    result = InternalScript.VirtualMachine__RunFunction(virtualMachine, functionName, a3, a4, a5, a6);
                    break;
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Unhandled Exception in InternalScript.VirtualMachine__RunFunctionHook!");
                Trace.WriteLine(e.ToString());
            }

            return(result);
        }