diff --git a/AVPPH_CustomLauncher.sdf b/AVPPH_CustomLauncher.sdf index 965c4dd..2e8b3b9 100644 Binary files a/AVPPH_CustomLauncher.sdf and b/AVPPH_CustomLauncher.sdf differ diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 0e832a7..e8d2e73 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -32,8 +32,8 @@ private void InitializeComponent() this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.B_Exit = new System.Windows.Forms.Button(); this.B_DisplaySettings = new System.Windows.Forms.Button(); - this.B_StartGame = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.B_StartGame = new System.Windows.Forms.Button(); this.tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -84,6 +84,16 @@ private void InitializeComponent() this.B_DisplaySettings.UseVisualStyleBackColor = true; this.B_DisplaySettings.Click += new System.EventHandler(this.B_DisplaySettings_Click); // + // pictureBox1 + // + this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Top; + this.pictureBox1.Image = global::AVP_CustomLauncher.Properties.Resources.yes1; + this.pictureBox1.Location = new System.Drawing.Point(4, 4); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(348, 210); + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // // B_StartGame // this.B_StartGame.Anchor = System.Windows.Forms.AnchorStyles.None; @@ -96,16 +106,6 @@ private void InitializeComponent() this.B_StartGame.UseVisualStyleBackColor = true; this.B_StartGame.Click += new System.EventHandler(this.B_StartGame_Click); // - // pictureBox1 - // - this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Top; - this.pictureBox1.Image = global::AVP_CustomLauncher.Properties.Resources.yes1; - this.pictureBox1.Location = new System.Drawing.Point(4, 4); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(348, 210); - this.pictureBox1.TabIndex = 0; - this.pictureBox1.TabStop = false; - // // mainform // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -119,7 +119,9 @@ private void InitializeComponent() this.Name = "mainform"; this.ShowIcon = false; this.Text = "Aliens vs. Predator 2: Primal Hunt - Custom Launcher"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.mainform_FormClosing); this.Load += new System.EventHandler(this.mainform_Load); + this.LocationChanged += new System.EventHandler(this.mainform_LocationChanged); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); diff --git a/MainForm.cs b/MainForm.cs index 353e773..817e3bb 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -19,48 +19,119 @@ public partial class mainform : Form GameSettings _GraphicsSettings; ConfigChoice _ConfigChoice; GameHack _gamehack = new GameHack(); + int _posX = 0; + int _posY = 0; public mainform() { + if (File.Exists("autoexecextended.cfg")) + { + setPositionFromConfig(); + } InitializeComponent(); } - private void mainform_Load(object sender, EventArgs e) + #region Functions + private void CheckForRequiredGameFiles() { - CheckForRequiredGameFiles(); + string[] files = { "lithtech.exe", "AVP2X.REZ", "AVP2DLL.REZ", "AVP2L.REZ", "DIALOGUE.REZ", "AVP2P1.REZ", "AVP2P.REZ", "binkw32.dll", "MULTI.REZ", "server.dll", "ltmsg.dll", "binkw32.dll" }; - if(!File.Exists(@"autoexec.cfg")) + for (int i = 0; i < files.Length; i++) { - _ConfigChoice = new ConfigChoice(); - _ConfigChoice.ShowDialog(); + if (!File.Exists(@files[i])) + { + MessageBox.Show("No " + files[i] + " found. Please place the custom launcher in the directory with the game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + Close(); + } } - if (!File.Exists(@"avp2cmds.txt")) + if (!File.Exists(@"widescreenfix.dll")) { - MessageBox.Show("No avp2cmds.txt found. The launcher will try to create it based on files in your current directory.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); - CreateGenericAVP2Cmds(); + MessageBox.Show("Widescreenfix.dll has not been found. This file is required for Widescreen support.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } - - _GraphicsSettings = new GameSettings(this); } - private void CheckForRequiredGameFiles() + private void CreateGenericAVP2Cmds() { - string[] files = { "lithtech.exe", "AVP2X.REZ", "AVP2DLL.REZ", "AVP2L.REZ", "DIALOGUE.REZ", "AVP2P1.REZ", "AVP2P.REZ", "binkw32.dll", "MULTI.REZ", "server.dll", "ltmsg.dll", "binkw32.dll"}; + string basePath = ""; + object key = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Monolith Productions\\Aliens vs. Predator 2\\1.0", "InstallDir", ""); - for (int i=0; i scrRect.X && PosX < scrRect.X + scrRect.Width && + PosY > scrRect.Y && PosY < scrRect.Y + scrRect.Height) + return true; + } + return false; } + #endregion } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index f6a9095..f88d491 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.0.0")] -[assembly: AssemblyFileVersion("0.6.0.0")] +[assembly: AssemblyVersion("0.6.1.0")] +[assembly: AssemblyFileVersion("0.6.1.0")] diff --git a/Release/AVP2PH_CustomLauncher.exe b/Release/AVP2PH_CustomLauncher.exe index 9e31c06..ddaf03d 100644 Binary files a/Release/AVP2PH_CustomLauncher.exe and b/Release/AVP2PH_CustomLauncher.exe differ diff --git a/Release/widescreenfix.dll b/Release/widescreenfix.dll index cbfe09d..34b61e6 100644 Binary files a/Release/widescreenfix.dll and b/Release/widescreenfix.dll differ diff --git a/SettingsForms/GameSettingsForm.cs b/SettingsForms/GameSettingsForm.cs index 0338bde..9a131e9 100644 --- a/SettingsForms/GameSettingsForm.cs +++ b/SettingsForms/GameSettingsForm.cs @@ -40,6 +40,8 @@ public GameSettings(mainform parent) } else readcustomconfig(); + + readfile(); } @@ -55,7 +57,6 @@ struct autoexecstruct private void GraphicsSettings_Load(object sender, EventArgs e) { - readfile(); } public void readcustomconfig() diff --git a/widescreenfix/Main.cpp b/widescreenfix/Main.cpp index b790631..9dcad5c 100644 --- a/widescreenfix/Main.cpp +++ b/widescreenfix/Main.cpp @@ -32,7 +32,16 @@ bool Hook(void * toHook, void * ourFunction, int lenght) DWORD jmpResAddress; DWORD jmpFovAddress; -float horizontalRadiansF; +float horizontalRadiansF = 1.57f; +float ViewmodelFOVF; +DWORD jmpViewModelRet; +bool d3drenHooked = false; + +static float modifyViewmodels(float val) +{ + float tempVradian = 2 * atanf(tanf(val / 2.0f) * ((float)resolutionY/resolutionX)); + return (2.0f * atanf(tanf(tempVradian / 2.0f) * 1.333333f)); +} static float increaseHorFOV() { @@ -40,6 +49,46 @@ static float increaseHorFOV() return (2.0f * atanf(tanf(tempVradian / 2.0f) * aspectRatio)); } +void __declspec(naked) ViewModelHack() +{ + /* + "d3d.ren"+107F2: + fstp dword ptr [ebx+4C] + fld dword ptr [ebx+00000098] + */ + __asm + { + fstp dword ptr[ViewmodelFOVF] + push eax + push ebx + push ecx + push edx + push esi + push edi + push esp + push ebp + } + + ViewmodelFOVF = modifyViewmodels(ViewmodelFOVF); + ViewmodelFOVF = modifyViewmodels(ViewmodelFOVF); + + __asm + { + pop ebp + pop esp + pop edi + pop esi + pop edx + pop ecx + pop ebx + pop eax + fld dword ptr[ViewmodelFOVF] + fstp dword ptr[ebx + 0x4C] + fld dword ptr[ebx + 0x00000098] + jmp[jmpViewModelRet] + } +} + void __declspec(naked) fovHack() { __asm @@ -70,6 +119,7 @@ void __declspec(naked) fovHack() jmp[jmpFovAddress] } } + void __declspec(naked) resHack() { __asm @@ -110,6 +160,27 @@ DWORD WINAPI HookThread(LPVOID param) while (true) { aspectRatio = (float)(1.0 * resolutionX / resolutionY); + MODULEINFO d3dren = GetModuleInfo("d3d.ren"); + if (d3dren.lpBaseOfDll == 0x0) + { + d3drenHooked = false; + } + else if(!d3drenHooked) + { + #ifdef _DEBUG + OutputDebugString("d3dRenHooked"); + #endif // DEBUG + + //ViewModel hack + //Overriding: + //fstp dword ptr [ebx+4C] + //fld dword ptr[ebx + 00000098] + int hookLenght = 9; + DWORD hookAddress = (DWORD)d3dren.lpBaseOfDll + 0x107F2; //Solve address = "cshell.dll"+64A0B + jmpViewModelRet = hookAddress + hookLenght; + Hook((void*)hookAddress, ViewModelHack, hookLenght); + d3drenHooked = true; + } Sleep(400); } } diff --git a/widescreenfix/widescreenfix.vcxproj b/widescreenfix/widescreenfix.vcxproj index ebf9961..5bf569e 100644 --- a/widescreenfix/widescreenfix.vcxproj +++ b/widescreenfix/widescreenfix.vcxproj @@ -120,7 +120,7 @@ false WIN32;NDEBUG;_WINDOWS;_USRDLL;WIDESCREENFIX_EXPORTS;%(PreprocessorDefinitions) true - MultiThreadedDebugDLL + MultiThreadedDLL Windows