Page 1 of 2

ExperienceRO scratch pad

Posted: 08 Aug 2009, 12:57
by kali

Code: Select all

		String unpackString = "v2 x20 V4 v x22 x2 v x2 v x2 v2 x2 v2 x2 v x2 v x2 v4 Z24 C6 v x2";
		unpack(
				true,
				unpackString,
				charInfo,
				qw("header length charID exp zeny jobExp jobLevel hp maxHp sp maxSp jobId hairstyle level headLow headTop headMid hairColor clothesColor name str agi vit intel dex luk slot"));
	}
Difference with old 006B:
20 bytes skipped from length field to first charID
2 bytes skipped after hp
2 bytes skipped after maxHp

Re: ExperienceRO scratch pad

Posted: 09 Aug 2009, 21:02
by kali
Andy12345, if you're reading this, could you paste here the servers.txt entry for ExperienceRO? So I can test my patches too :)

Re: ExperienceRO scratch pad

Posted: 10 Aug 2009, 01:55
by andy12345
kali wrote:Andy12345, if you're reading this, could you paste here the servers.txt entry for ExperienceRO? So I can test my patches too :)
Sure

Code: Select all

[ExpRO]
ip 66.160.197.121
port 6900
version 20
master_version 16
serverType 8_4 #Already experimented with#
private 1
serverEncoding Western
charBlocksize 132  #this one to experimented with.#
recvpackets recvpackets.txt

Re: ExperienceRO scratch pad

Posted: 10 Aug 2009, 02:27
by kali
Note to self:
charBlockSize must be set to 112

Re: ExperienceRO scratch pad

Posted: 10 Aug 2009, 03:06
by kali
Andy, could you try patching this in as a test?

Code: Select all

Index: Receive.pm
===================================================================
--- Receive.pm	(revision 6835)
+++ Receive.pm	(working copy)
@@ -4917,21 +4917,22 @@
 	my $blockSize = $self->received_characters_blockSize();
 	for (my $i = $args->{RAW_MSG_SIZE} % $blockSize; $i < $args->{RAW_MSG_SIZE}; $i += $blockSize) {
 		#exp display bugfix - chobit andy 20030129
-		$num = unpack("C1", substr($args->{RAW_MSG}, $i + 104, 1));
+		$num = unpack("C1", substr($args->{RAW_MSG}, $i + 104+4, 1));
 		$chars[$num] = new Actor::You;
 		$chars[$num]{ID} = $accountID;
-		$chars[$num]{charID} = substr($args->{RAW_MSG}, $i, 4);
+		$chars[$num]{charID} = substr($args->{RAW_MSG}, $i-4, 4);
 		$chars[$num]{nameID} = unpack("V", $chars[$num]{ID});
+        message $chars[$num]{nameID};
 		$chars[$num]{exp} = unpack("V", substr($args->{RAW_MSG}, $i + 4, 4));
-		$chars[$num]{zenny} = unpack("V", substr($args->{RAW_MSG}, $i + 8, 4));
-		$chars[$num]{exp_job} = unpack("V", substr($args->{RAW_MSG}, $i + 12, 4));
-		$chars[$num]{lv_job} = unpack("v", substr($args->{RAW_MSG}, $i + 16, 2));
-		$chars[$num]{hp} = unpack("v", substr($args->{RAW_MSG}, $i + 42, 2));
-		$chars[$num]{hp_max} = unpack("v", substr($args->{RAW_MSG}, $i + 44, 2));
-		$chars[$num]{sp} = unpack("v", substr($args->{RAW_MSG}, $i + 46, 2));
-		$chars[$num]{sp_max} = unpack("v", substr($args->{RAW_MSG}, $i + 48, 2));
-		$chars[$num]{jobID} = unpack("v", substr($args->{RAW_MSG}, $i + 52, 2));
-		$chars[$num]{hair_style} = unpack("v", substr($args->{RAW_MSG}, $i + 54, 2));
+		$chars[$num]{zenny} = unpack("V", substr($args->{RAW_MSG}, $i + 8-4, 4));
+		$chars[$num]{exp_job} = unpack("V", substr($args->{RAW_MSG}, $i + 12-4, 4));
+		$chars[$num]{lv_job} = unpack("v", substr($args->{RAW_MSG}, $i + 16-4, 2));
+		$chars[$num]{hp} = unpack("V", substr($args->{RAW_MSG}, $i + 42, 2+2));
+		$chars[$num]{hp_max} = unpack("V", substr($args->{RAW_MSG}, $i + 44+2, 2+2));
+		$chars[$num]{sp} = unpack("v", substr($args->{RAW_MSG}, $i + 46+4, 2));
+		$chars[$num]{sp_max} = unpack("v", substr($args->{RAW_MSG}, $i + 48+4, 2));
+		$chars[$num]{jobID} = unpack("v", substr($args->{RAW_MSG}, $i + 52+4, 2));
+		$chars[$num]{hair_style} = unpack("v", substr($args->{RAW_MSG}, $i + 54+4, 2));
 		$chars[$num]{lv} = unpack("v", substr($args->{RAW_MSG}, $i + 58, 2));
 		$chars[$num]{headgear}{low} = unpack("v", substr($args->{RAW_MSG}, $i + 62, 2));
 		$chars[$num]{headgear}{top} = unpack("v", substr($args->{RAW_MSG}, $i + 66, 2));

Re: ExperienceRO scratch pad

Posted: 10 Aug 2009, 03:26
by andy12345
Recv Packets got from the exe

Re: ExperienceRO scratch pad

Posted: 10 Aug 2009, 04:46
by h4rry84
it's using RagnarokRenewal client ?

here's a sneaky eA code that could help ;p : https://opensvn.csie.org/traccgi/RE/changeset/21

Re: ExperienceRO scratch pad

Posted: 10 Aug 2009, 05:39
by kLabMouse
Please Commit us ServerType 8_6.
Don't forget the new packets 07xx that eA supports and we not.

Changes:
https://opensvn.csie.org/traccgi/RE/changeset/21

Re: ExperienceRO scratch pad

Posted: 10 Aug 2009, 05:54
by kali
Does not work yet, it's just a workaround for the first character. I'll code a proper fix later (at least I know my parsing works).

Re: ExperienceRO scratch pad

Posted: 10 Aug 2009, 22:19
by kali
Here is the working patch (specific to ExperienceRO)

Code: Select all

Index: src/Network/Receive.pm
===================================================================
--- src/Network/Receive.pm	(revision 6835)
+++ src/Network/Receive.pm	(working copy)
@@ -4914,38 +4914,45 @@
 	}
 
 	my $num;
-	my $blockSize = $self->received_characters_blockSize();
+	my $blockSize = 112;
+	#$self->received_characters_blockSize(); <-- doesn't work?
 	for (my $i = $args->{RAW_MSG_SIZE} % $blockSize; $i < $args->{RAW_MSG_SIZE}; $i += $blockSize) {
 		#exp display bugfix - chobit andy 20030129
-		$num = unpack("C1", substr($args->{RAW_MSG}, $i + 104, 1));
+        my $unpack_string = "V4 v x22 x2 v x2 v x2 v2 x2 v2 x2 v x2 v x2 v4 Z24 C6 v x2";
+		my ($cID,$exp,$zeny,$jobExp,$jobLevel,$hp,$maxHp,$sp,$maxSp,$jobId,
+		    $hairstyle,$level,$headLow,$headTop,$headMid,$hairColor,
+		    $clothesColor,$name,$str,$agi,$vit,$intel,$dex,$luk,$num) =
+		    unpack($unpack_string, substr($args->{RAW_MSG}, $i));
+		   
 		$chars[$num] = new Actor::You;
 		$chars[$num]{ID} = $accountID;
-		$chars[$num]{charID} = substr($args->{RAW_MSG}, $i, 4);
+		$chars[$num]{charID} = $cID;
+		$chars[$num]{exp} = $exp;
+		$chars[$num]{zenny} = $zeny;
+		$chars[$num]{exp_job} = $jobExp;
+		$chars[$num]{lv_job} = $jobLevel;
+		$chars[$num]{hp} = $hp;
+		$chars[$num]{hp_max} = $maxHp;
+		$chars[$num]{sp} = $sp;
+		$chars[$num]{sp_max} = $maxSp;
+		$chars[$num]{jobID} = $jobId;
+		$chars[$num]{hair_style} = $hairstyle;
+		$chars[$num]{lv} = $level;
+		$chars[$num]{headgear}{low} = $headLow;
+		$chars[$num]{headgear}{top} = $headTop;
+		$chars[$num]{headgear}{mid} = $headMid;
+		$chars[$num]{hair_color} = $hairColor;
+		$chars[$num]{clothes_color} = $clothesColor;
+		$chars[$num]{name} = $name;
+		$chars[$num]{str} = $str;
+		$chars[$num]{agi} = $agi;
+		$chars[$num]{vit} = $vit;
+		$chars[$num]{int} = $intel;
+		$chars[$num]{dex} = $dex;
+		$chars[$num]{luk} = $luk;
+		$chars[$num]{sex} = $accountSex2;
+
 		$chars[$num]{nameID} = unpack("V", $chars[$num]{ID});
-		$chars[$num]{exp} = unpack("V", substr($args->{RAW_MSG}, $i + 4, 4));
-		$chars[$num]{zenny} = unpack("V", substr($args->{RAW_MSG}, $i + 8, 4));
-		$chars[$num]{exp_job} = unpack("V", substr($args->{RAW_MSG}, $i + 12, 4));
-		$chars[$num]{lv_job} = unpack("v", substr($args->{RAW_MSG}, $i + 16, 2));
-		$chars[$num]{hp} = unpack("v", substr($args->{RAW_MSG}, $i + 42, 2));
-		$chars[$num]{hp_max} = unpack("v", substr($args->{RAW_MSG}, $i + 44, 2));
-		$chars[$num]{sp} = unpack("v", substr($args->{RAW_MSG}, $i + 46, 2));
-		$chars[$num]{sp_max} = unpack("v", substr($args->{RAW_MSG}, $i + 48, 2));
-		$chars[$num]{jobID} = unpack("v", substr($args->{RAW_MSG}, $i + 52, 2));
-		$chars[$num]{hair_style} = unpack("v", substr($args->{RAW_MSG}, $i + 54, 2));
-		$chars[$num]{lv} = unpack("v", substr($args->{RAW_MSG}, $i + 58, 2));
-		$chars[$num]{headgear}{low} = unpack("v", substr($args->{RAW_MSG}, $i + 62, 2));
-		$chars[$num]{headgear}{top} = unpack("v", substr($args->{RAW_MSG}, $i + 66, 2));
-		$chars[$num]{headgear}{mid} = unpack("v", substr($args->{RAW_MSG}, $i + 68, 2));
-		$chars[$num]{hair_color} = unpack("v", substr($args->{RAW_MSG}, $i + 70, 2));
-		$chars[$num]{clothes_color} = unpack("v", substr($args->{RAW_MSG}, $i + 72, 2));
-		($chars[$num]{name}) = unpack("Z*", substr($args->{RAW_MSG}, $i + 74, 24));
-		$chars[$num]{str} = unpack("C1", substr($args->{RAW_MSG}, $i + 98, 1));
-		$chars[$num]{agi} = unpack("C1", substr($args->{RAW_MSG}, $i + 99, 1));
-		$chars[$num]{vit} = unpack("C1", substr($args->{RAW_MSG}, $i + 100, 1));
-		$chars[$num]{int} = unpack("C1", substr($args->{RAW_MSG}, $i + 101, 1));
-		$chars[$num]{dex} = unpack("C1", substr($args->{RAW_MSG}, $i + 102, 1));
-		$chars[$num]{luk} = unpack("C1", substr($args->{RAW_MSG}, $i + 103, 1));
-		$chars[$num]{sex} = $accountSex2;
 		$chars[$num]{name} = bytesToString($chars[$num]{name});
 	}
 
I suggest we create a separate function to specify the unpack string, so that other servertypes can just override that instead of overriding the whole function. So for example (pseudo code):

Code: Select all

sub received_characters_unpack_string {
    return "unpack string goes here";
}
sub received_characters {
    my $unpack_string = received_characters_unpack_string();
    my ($charID,$exp ...) = unpack($unpack_string, $raw_data);
}
Other servertypes will just override sub received_characters_unpack_string if they want to specify a different unpacking algorithm (just like with expro).

AFAIK this is the first time OpenKore will support a server with a unique character info packing. The previous one was a simple change of character block size, this time the change is more drastic. I suggest we adapt our code so it becomes more maintainable n the future in case Gravity decides to change this packing format.

This is also the reason why I am not yet creating a separate servertype for expro - I believe we first need to refactor the function involved before extending it; otherwise we'll be stuck with a tangled mess.

And btw, it seems that whatever I do to change the charBlockSize doesn't work. Changing it in servers.txt or in config.txt doesn't seem to stick (I checked with placing trace messages and logs). Maybe it's just me, but it seems that the function broke somehow, or the specific config.txt entryis not being loaded.