Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Fix conditional compilation of scholar
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankvdStam committed May 5, 2024
1 parent 958a258 commit 205d1f4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 34 deletions.
19 changes: 5 additions & 14 deletions soulmemory-rs/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use std::sync::{Arc, Mutex};
use windows::Win32::Foundation::{BOOL, HINSTANCE};
use windows::Win32::Foundation::HINSTANCE;
use imgui::{Condition, Ui};
use windows::Win32::System::Threading::{GetCurrentProcess, IsWow64Process};
use crate::widgets::widget::Widget;
use crate::util::server::Server;
use crate::widgets::ai_toggle_widget::AiToggleWidget;
Expand Down Expand Up @@ -69,18 +68,10 @@ impl App
{
"mockgame.exe" => Box::new(MockGame::new()),
"darksouls.exe" => Box::new(DarkSoulsPrepareToDieEdition::new()),
"darksoulsii.exe" =>
{
let mut is64wow = BOOL(0);
if unsafe{ IsWow64Process(GetCurrentProcess(), &mut is64wow).is_ok() && !is64wow.as_bool() }
{
Box::new(DarkSouls2ScholarOfTheFirstSin::new())
}
else
{
Box::new(DarkSouls2Vanilla::new())
}
},
#[cfg(target_arch = "x86_64")]
"darksoulsii.exe" => Box::new(DarkSouls2ScholarOfTheFirstSin::new()),
#[cfg(target_arch = "x86")]
"darksoulsii.exe" => Box::new(DarkSouls2Vanilla::new()),
"darksoulsremastered.exe" => Box::new(DarkSoulsRemastered::new()),
"darksoulsiii.exe" => Box::new(DarkSouls3::new()),
"sekiro.exe" => Box::new(Sekiro::new()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_pointer_width = "32")]
#[allow(dead_code)]

mod buffered_event_flags;

use std::any::Any;
Expand Down Expand Up @@ -46,10 +43,6 @@ impl DarkSouls2ScholarOfTheFirstSin

impl Game for DarkSouls2ScholarOfTheFirstSin
{
#[cfg(target_pointer_width = "32")]
fn refresh(&mut self) -> Result<(), String> { unimplemented!("DarkSouls2ScholarOfTheFirstSin is only available for x64"); }

#[cfg(target_pointer_width = "64")]
fn refresh(&mut self) -> Result<(), String>
{
if !self.process.is_attached()
Expand All @@ -62,6 +55,7 @@ impl Game for DarkSouls2ScholarOfTheFirstSin
let set_event_flag_address = self.process.scan_abs("set_event_flag" , "48 89 74 24 10 57 48 83 ec 20 8b fa 45 0f b6 d8", 0, Vec::new())?.get_base_address();

self.fn_get_event_flag = mem::transmute(get_event_flag_address);

unsafe extern "win64" fn read_event_flag_hook_fn(registers: *mut Registers, _:usize)
{
let instance = App::get_instance();
Expand Down Expand Up @@ -92,10 +86,10 @@ impl Game for DarkSouls2ScholarOfTheFirstSin
Ok(())
}

fn event_flags(&mut self) -> Option<Box<&mut dyn BufferedEventFlags>> { Some(Box::new(self)) }

fn get_dx_version(&self) -> DxVersion { DxVersion::Dx11 }

fn event_flags(&mut self) -> Option<Box<&mut dyn BufferedEventFlags>> { Some(Box::new(self)) }

fn as_any(&self) -> &dyn Any { self }

fn as_any_mut(&mut self) -> &mut dyn Any { self }
Expand Down
10 changes: 2 additions & 8 deletions soulmemory-rs/src/games/dark_souls_2_vanilla/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[allow(dead_code)]

mod buffered_event_flags;

use std::any::Any;
Expand Down Expand Up @@ -46,10 +44,6 @@ impl DarkSouls2Vanilla

impl Game for DarkSouls2Vanilla
{
#[cfg(target_pointer_width = "64")]
fn refresh(&mut self) -> Result<(), String> { unimplemented!("DarkSouls2Vanilla is only available for x86"); }

#[cfg(target_pointer_width = "32")]
fn refresh(&mut self) -> Result<(), String>
{
if !self.process.is_attached()
Expand Down Expand Up @@ -91,10 +85,10 @@ impl Game for DarkSouls2Vanilla
Ok(())
}

fn event_flags(&mut self) -> Option<Box<&mut dyn BufferedEventFlags>> { Some(Box::new(self)) }

fn get_dx_version(&self) -> DxVersion { DxVersion::Dx9 }

fn event_flags(&mut self) -> Option<Box<&mut dyn BufferedEventFlags>> { Some(Box::new(self)) }

fn as_any(&self) -> &dyn Any { self }

fn as_any_mut(&mut self) -> &mut dyn Any { self }
Expand Down
9 changes: 6 additions & 3 deletions soulmemory-rs/src/games/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ mod mock_game;
pub mod dx_version;
mod game;
mod game_ext;
mod dark_souls_2_scholar_of_the_first_sin;
mod dark_souls_2_vanilla;

pub use game::Game;
Expand All @@ -35,14 +34,18 @@ pub use game_ext::GameExt;
pub use mock_game::MockGame;
pub use dark_souls_remastered::DarkSoulsRemastered;
pub use dark_souls_prepare_to_die_edition::DarkSoulsPrepareToDieEdition;
pub use dark_souls_2_scholar_of_the_first_sin::DarkSouls2ScholarOfTheFirstSin;


pub use dark_souls_2_vanilla::DarkSouls2Vanilla;
pub use dark_souls_3::DarkSouls3;
pub use sekiro::Sekiro;
pub use elden_ring::EldenRing;
pub use armored_core_6::ArmoredCore6;


#[cfg(target_arch = "x86_64")]
mod dark_souls_2_scholar_of_the_first_sin;
#[cfg(target_arch = "x86_64")]
pub use dark_souls_2_scholar_of_the_first_sin::DarkSouls2ScholarOfTheFirstSin;

pub type ChrDbgFlag = (u32, String, bool);

Expand Down

0 comments on commit 205d1f4

Please sign in to comment.