Shadowss/TravianZ

Sending troops ends up with "Coordinates do not exist" error

greldinard opened this issue · 4 comments

  1. expected behaviour
    Entering Coordinates target fiels will send troops to the corresponding field.

  2. incorrect behaviour
    Message "Coordinates do not exist" appears, troops are not send.
    Probable encoding error? But where? Apache? PHP?

  3. the operating system & version
    Ubuntu 20.04

  4. PHP version on the server
    PHP 7.4.3

  5. MySQL / MariaDB version on the server
    MySQL 8.0.27

Resolved:

Change the function:

public function getBaseID($x, $y){
		return ((WORLD_MAX - $y) * (WORLD_MAX * 2 + 1)) + (WORLD_MAX + $x + 1);
	}

in the file GameEngine/Generator.php to:

public function getBaseID($x, $y){
		return ((WORLD_MAX - $y) * (WORLD_MAX * 2 + 1)) + (WORLD_MAX - $x + 1);
	}

And the coordinated will be calculated correctly.

I just setup a server for me to play around and that '+' to '-' change actually breaks the game for me, making both the map and attack coordinates unusable.
Reverting back the '+' to '-' is actually a fix for me.

Resolved:
...snip...
And the coordinated will be calculated correctly.

Applied this fix locally on my test system and gave it a quick test: appears it fixed my issue of being unable to raid some locations as well. Thank you.

My test system is:

  • Ubuntu 20.04.4 LTS (5.4.0-104-generic) fully patched
  • mysql-server-8.0
  • php7.4

Guys, i think the fix is:

$a = ( WORLD_MAX - $y );
$b = ( WORLD_MAX - $x );  
if ( $b < 0 ) {
    	$b = -$b;
} 
return ( $a * (WORLD_MAX * 2 + 1) ) + $b + 1;

Tested doing:

SELECT* FROM `s1_wdata` WHERE ( ( 100 - y ) * 201 + ABS( 100 - x ) + 1 ) <> id

the result is empty