Removing Inline::C dependency.

This commit is contained in:
sergiotarxz 2023-02-09 16:04:04 +01:00
parent a0e3b8d1df
commit 710178b9cf
2 changed files with 3 additions and 31 deletions

View File

@ -9,7 +9,6 @@ my $build = Module::Build->new(
dist_author => 'Sergio Iglesias <contact@owlcode.tech>',
dist_abstract => 'Ruby/Sapphire save editor lib.',
requires => {
'Inline::C' => 0,
},
);
$build->create_build_script;

View File

@ -409,7 +409,7 @@ sub _pokemon_checksum_substructures_fh {
for ( 0 .. 3 ) {
for ( 0 .. 5 ) {
read $fh, my $read, 2 or die "Unable to read";
$checksum = _sum_u16( ( unpack 'v', $read ), $checksum );
$checksum = 0xffff & (( unpack 'v', $read ) + $checksum );
}
}
return $checksum;
@ -674,18 +674,6 @@ sub _decrypt_pokemon_substructures_raw {
read $fh, my $read, 1 and die "Not all read";
close $fh;
open $fh, '<', \$result;
# my @order_substructures = _pokemon_substructures_order_by_modulo($personality % 24);
# for my $substruct_n (0..3) {
# my $offset = $substruct_n * 12;
# seek $fh, $substruct_n * 12, 0;
# for (0..5) {
# read $fh, my $read, 2 or die "Unable to read";
# $read = unpack 'v', $read;
# $compare_checksum = _sum_u16($read, $compare_checksum);
# }
# }
#
my $compare_checksum = _pokemon_checksum_substructures_fh($fh);
die "Checksum $compare_checksum not equal to $checksum"
if $compare_checksum != $checksum;
@ -1024,27 +1012,12 @@ sub _recalculate_checksum {
my $readed = '';
read $fh, $readed, 4;
my $to_add = unpack 'V', $readed;
$checksum = _sum_u32( $checksum, $to_add );
$checksum = 0xffffffff & ($checksum + $to_add);
}
my $final_checksum = _sum_u32_to_u16( $checksum, $checksum >> 16 );
my $final_checksum = (_hihalf_u32($checksum) + _lowhalf_u32($checksum)) & 0xffffffff;
$section->{checksum} = $final_checksum;
}
use Inline C => <<'EOF';
unsigned int
_sum_u32(unsigned int a, unsigned int b) {
return a + b;
}
unsigned short
_sum_u32_to_u16(unsigned int a, unsigned int b) {
return (short) a + b;
}
unsigned short
_sum_u16(unsigned short a, unsigned short b) {
return (unsigned short) a + b;
}
EOF
sub _find_section_save {
my $save = shift;
my $section_id = shift;