I knew more about all this crap when I wrote it.
Code:
package EQEmu::PlayerProfile_Struct;
use strict;
use warnings;
use EQEmu::BlobConvert;
use EQEmu::Bind_Struct;
use EQEmu::Color_Struct;
# constructor
sub new {
my ($class, %params) = @_;
my $self = {};
bless ($self, $class);
foreach my ($key, $val) (%params) {
print "$key => $val.\n";
}
$self->parseBlob($blob);
$self;
}
# data extraction/conversion happens here
sub parseBlob {
my ($self, $blob) = @_;
$self->{_checksum} = asc2dec($blob, 0, 4);
$self->{_name} = asconly($blob, 4, 64);
$self->{_last_name} = asconly($blob, 68, 32);
$self->{_gender} = asc2dec($blob, 100, 4);
$self->{_race} = asc2dec($blob, 104, 4);
$self->{_class_} = asc2dec($blob, 108, 4);
$self->{_unknown0112} = asc2dec($blob, 112, 4);
$self->{_level} = asc2dec($blob, 116, 4);
foreach my $i (0..4) {
$self->{_binds}[$i] = new EQEmu::Bind_Struct
(
asc2dec($blob, $i*20+120, 4), # zoneID
asc2float($blob, $i*20+124, 4), # x
asc2float($blob, $i*20+128, 4), # y
asc2float($blob, $i*20+132, 4), # z
asc2float($blob, $i*20+136, 4) # heading
);
}
$self->{_haircolor} = asc2dec($blob, 296, 1);
$self->{_beardcolor} = asc2dec($blob, 297, 1);
$self->{_eyecolor1} = asc2dec($blob, 298, 1);
$self->{_eyecolor2} = asc2dec($blob, 299, 1);
$self->{_hairstyle} = asc2dec($blob, 300, 1);
$self->{_beard} = asc2dec($blob, 301, 1);
$self->{_face} = asc2dec($blob, 2504, 1);
$self->{_drakkin_heritage} = asc2dec($blob, 5440, 4);
$self->{_drakkin_tattoo} = asc2dec($blob, 5444, 4);
$self->{_drakin_details} = asc2dec($blob, 5448, 4);
foreach my $i (0..8) {
$self->{_item_material}[$i] = asc2dec($blob, $i*4+312, 4);
}
foreach my $i (0..8) {
$self->{_item_tint}[$i] = new EQEmu::Color_Struct
(
asc2dec($blob, $i*4+396, 1), # blue
asc2dec($blob, $i*4+397, 1), # green
asc2dec($blob, $i*4+398, 1), # red
asc2dec($blob, $i*4+399, 1) # use_tint
);
}
}
# read-only accessor methods
# array accessors return the specified element if an index is passed
# otherwise, the entire array is returned
sub checksum { shift->{_checksum}; }
sub name { shift->{_name}; }
sub last_name { shift->{_last_name}; }
sub gender { shift->{_gender}; }
sub race { shift->{_race}; }
sub class_ { shift->{_class_}; }
sub level { shift->{_level}; }
sub haircolor { shift->{_haircolor}; }
sub beardcolor { shift->{_beardcolor}; }
sub eyecolor1 { shift->{_eyecolor1}; }
sub eyecolor2 { shift->{_eyecolor2}; }
sub hairs { shift->{_hairstyle}; }
sub beard { shift->{_beard}; }
sub face { shift->{_face}; }
sub drakkin_heritage { shift->{_drakkin_heritage}; }
sub drakkin_tattoo { shift->{_drakkin_tattoo}; }
sub drakkin_details { shift->{_drakkin_details}; }
sub item_material {
my ($self, $i) = @_;
defined($i) ? ${$self->{_item_material}}[$i] : @{$self->{_item_material}};
}
sub binds {
my ($self, $i) = @_;
defined($i) ? ${$self->{_binds}}[$i] : @{$self->{_binds}};
}
sub item_tint {
my ($self, $i) = @_;
defined($i) ? ${$self->{_item_tint}}[$i] : @{$self->{_item_tint}};
}
1;