[patch] Automatic finding charBlockSize

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

UltimaWeapon
Human
Human
Posts: 37
Joined: 04 Apr 2008, 22:55
Noob?: Yes
Location: Thailand

[patch] Automatic finding charBlockSize

#1 Post by UltimaWeapon »

Code: Select all

Index: src/Network/Receive.pm

===================================================================

--- src/Network/Receive.pm	(revision 6497)

+++ src/Network/Receive.pm	(working copy)

@@ -4639,9 +4639,34 @@

 		$charServer = $net->serverPeerHost . ":" . $net->serverPeerPort;
 	}
 
-	my $num;
+	my ($num, $startVal);
 	my $blockSize = $self->received_characters_blockSize();
-	for (my $i = $args->{RAW_MSG_SIZE} % $blockSize; $i < $args->{RAW_MSG_SIZE}; $i += $blockSize) {
+
+	if ($blockSize eq 'auto') {
+		my $devide = ($args->{RAW_MSG_SIZE} - 24) % 106;
+
+		if ($devide == 0) {
+			#Sakexe with block size 106
+			$startVal = 24;
+			$blockSize = 106;
+		} elsif (length(unpack('x4 Z4', $args->{msg})) == 0 && $devide <= 24) {
+			#Sakexe with block size 108
+			$startVal = 24;
+			$blockSize = 108;
+		} elsif ($devide == 86) {
+			#Ragexe with block size 106
+			$startVal = 4;
+			$blockSize = 106;
+		} else {
+			#Ragexe with block size 108
+			$startVal = 4;
+			$blockSize = 108;
+		}
+	} else {
+		$startVal = $args->{RAW_MSG_SIZE} % $blockSize;
+	}
+
+	for (my $i = $startVal; $i < $args->{RAW_MSG_SIZE}; $i += $blockSize) {
 		#exp display bugfix - chobit andy 20030129
 		$num = unpack("C1", substr($args->{RAW_MSG}, $i + 104, 1));
 		$chars[$num] = new Actor::You;
Change 'charBlockSize' in servers.txt to 'auto' to using Auto finding charBlockSize.

Need tester because I don't tested yet.
I may make you misunderstand. Because my English isn't good enough. So Sorry.
Image
Click
Human
Human
Posts: 39
Joined: 15 Apr 2008, 06:08
Noob?: Yes
Location: Russia, Velikiy Novgorod

Re: [patch] Automatic finding charBlockSize

#2 Post by Click »

Good idea, somebody test silt it?
kangkong
Human
Human
Posts: 25
Joined: 22 Nov 2012, 17:45
Noob?: Yes

Re: [patch] Automatic finding charBlockSize

#3 Post by kangkong »

UltimaWeapon wrote:

Code: Select all

Index: src/Network/Receive.pm

===================================================================

--- src/Network/Receive.pm	(revision 6497)

+++ src/Network/Receive.pm	(working copy)

@@ -4639,9 +4639,34 @@

 		$charServer = $net->serverPeerHost . ":" . $net->serverPeerPort;
 	}
 
-	my $num;
+	my ($num, $startVal);
 	my $blockSize = $self->received_characters_blockSize();
-	for (my $i = $args->{RAW_MSG_SIZE} % $blockSize; $i < $args->{RAW_MSG_SIZE}; $i += $blockSize) {
+
+	if ($blockSize eq 'auto') {
+		my $devide = ($args->{RAW_MSG_SIZE} - 24) % 106;
+
+		if ($devide == 0) {
+			#Sakexe with block size 106
+			$startVal = 24;
+			$blockSize = 106;
+		} elsif (length(unpack('x4 Z4', $args->{msg})) == 0 && $devide <= 24) {
+			#Sakexe with block size 108
+			$startVal = 24;
+			$blockSize = 108;
+		} elsif ($devide == 86) {
+			#Ragexe with block size 106
+			$startVal = 4;
+			$blockSize = 106;
+		} else {
+			#Ragexe with block size 108
+			$startVal = 4;
+			$blockSize = 108;
+		}
+	} else {
+		$startVal = $args->{RAW_MSG_SIZE} % $blockSize;
+	}
+
+	for (my $i = $startVal; $i < $args->{RAW_MSG_SIZE}; $i += $blockSize) {
 		#exp display bugfix - chobit andy 20030129
 		$num = unpack("C1", substr($args->{RAW_MSG}, $i + 104, 1));
 		$chars[$num] = new Actor::You;
Change 'charBlockSize' in servers.txt to 'auto' to using Auto finding charBlockSize.

Need tester because I don't tested yet.

Apparently, I tested it and this was the result.

Screenshot

hmm I do what you said and instructed and I got errors.
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: [patch] Automatic finding charBlockSize

#4 Post by kLabMouse »

kangkong wrote: Apparently, I tested it and this was the result.

Screenshot

hmm I do what you said and instructed and I got errors.
LOL! it's 4y old patch. You still think that it will work properly?
Not... Network subsystem changed alot. so it needs to be rewritten from scratch with same idea in mind.