Skip to content

Commit

Permalink
[Receive] rodex solve <MSG> (#3315)
Browse files Browse the repository at this point in the history
* rodex solve <MSG>

* rodex solve <MSG>
- added debug messages

Co-authored-by: ya4ept <[email protected]>
  • Loading branch information
alisonrag and ya4ept authored Dec 10, 2020
1 parent 35460ff commit 29fe641
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
23 changes: 23 additions & 0 deletions src/Misc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ our @EXPORT = (
fromBase62
solveItemLink
solveMessage
solveMSG
absunit/,

# Npc buy and sell
Expand Down Expand Up @@ -5491,6 +5492,28 @@ sub fromBase62 {
return $base10;
}

sub solveMSG {
my $msg = shift;
my $id;

if ($msg =~ /<MSG>(\d+)<\/MSG>/) {
$id = $1 + 1;
if ($msgTable[$id]) { # show message from msgstringtable.txt
debug "Replace the original message with: '$msgTable[$id]'\n";
$msg = $msgTable[$id];
}
} elsif ($msg =~ /<MSG>(\d+),(\d+)<\/MSG>/) {
$id = $1 + 1;
if ($msgTable[$id]) {
debug "Replace the original message with: '$msgTable[$id]'\n";
$msg = sprintf ($msgTable[$id], $2);
}
}
warning TF("Unknown msgid: %d. Need to update the file msgstringtable.txt (from data.grf)\n", --$id) if !$msgTable[$id];

return $msg;
}

# Solve each <ITEML>.*</ITEML> to kore-style item name
sub solveItemLink {
my ($itemlstr) = @_;
Expand Down
10 changes: 5 additions & 5 deletions src/Network/Receive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8192,8 +8192,8 @@ sub rodex_mail_list {

@{$mail}{@{$mail_info->{keys}}} = unpack($mail_info->{types}, substr($args->{mailList}, $i, $mail_info->{len}));

$mail->{title} = bytesToString(substr($args->{mailList}, ($i+$mail_info->{len}), $mail->{Titlelength}));

$mail->{title} = solveMSG(bytesToString(substr($args->{mailList}, ($i+$mail_info->{len}), $mail->{Titlelength})));
$mail->{sender} = solveMSG(bytesToString($mail->{sender}));
$mail->{page} = $rodexList->{current_page};
$mail->{page_index} = $index;

Expand Down Expand Up @@ -8239,9 +8239,9 @@ sub rodex_read_mail {

$mail->{items} = [];

message center(" " . "Mail ".$args->{mailID1} . " ", 119, '-') . "\n";

message "Message:\n" . bytesToString($mail->{body});
message center(" " . "Mail (" . $args->{mailID1} . ")" . $rodexList->{mails}{$args->{mailID1}}->{sender} . " ", 119, '-') . "\n";
message sprintf("From: %s \n", $rodexList->{mails}{$args->{mailID1}}->{sender});
message "Message:\n" . solveMSG(bytesToString($mail->{body}));
# FIXME for some reason message can't concatenate bytesToString + "\n"
message "\n";

Expand Down

0 comments on commit 29fe641

Please sign in to comment.