The International Simutrans Forum

 

Author Topic: Problems with map rotation  (Read 26182 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1107
    • Simutrans-BLOG
  • Languages: ES
Problems with map rotation
« on: April 13, 2018, 10:02:15 PM »
Thank you very much, I have solved it with a "return coord(count_c.x, count_c.y)"  ;D

I'm sorry to divert the subject, but now the problem is the coordinates out of range when rotating the map.  :-[




Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4465
  • Languages: EN, DE, AT
Re: Problems with map rotation
« Reply #1 on: April 14, 2018, 08:03:39 AM »
Please stop posting new problems to unrelated threads. Just open a new one.

Map rotation in simutrans rotates all coordinates. I tried hard to hide this from the script side.

Cannot reproduce an error. What steps should I do?


Edit: Did you try to use coord::href?
« Last Edit: April 14, 2018, 09:59:23 AM by Dwachs »

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1107
    • Simutrans-BLOG
  • Languages: ES
Re: Problems with map rotation
« Reply #2 on: April 14, 2018, 02:50:16 PM »
It seems to only happen on maps with an asymmetric size, try a 64x192 map
to replicate you must rotate the map and use the "select" link to choose a coordinate.

Edit: Did you try to use coord::href?

Code: [Select]
function get_goal_text(pl)
{
    local goal = ttextfile("goal.txt")
    goal.start = "<em>--></em> <a href='script:script_text()'>"+ translate("Select")+"</a>"
    goal.c1 = "<a href=\"("+our_coord.x+","+our_coord.y+")\">("+our_coord.x +","+""+our_coord.y+")</a>"
    goal.c2 = "<a href=\"("+gl_pos.x+","+gl_pos.y+")\">("+gl_pos.x +","+""+gl_pos.y+")</a>"
    goal.miss = ""+miss_list[our_coord.x]+""
    return goal.tostring()
}

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4465
  • Languages: EN, DE, AT
Re: Problems with map rotation
« Reply #3 on: April 14, 2018, 05:45:27 PM »
What exactly is the problem? Please read the documentation of coord::href and coord::_tostring.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1107
    • Simutrans-BLOG
  • Languages: ES
Re: Problems with map rotation
« Reply #4 on: April 14, 2018, 09:07:17 PM »

I understand that "coord :: href" is to create links, but it's not what I'm looking for, the problem is that this function generates coordinates out of range when I rotate the map:

Code: [Select]
    function check_coord()
    {
        count_c.y+=gl_c.y/15
        if(count_c.y >= gl_c.y){
           count_c.x+= gl_c.x/15
        }
        if(!world.is_coord_valid(coord(count_c.x,0)))
            count_c.x=0
        if(!world.is_coord_valid(coord(0,count_c.y)))
            count_c.y=0

        return coord(count_c.x,count_c.y)
    }


Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4465
  • Languages: EN, DE, AT
Re: Problems with map rotation
« Reply #5 on: April 15, 2018, 01:16:44 PM »
There was indeed a problem with handling of coordinates on rotated non-square maps. Should be fixed with r 8422. Thanks for the report!

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1107
    • Simutrans-BLOG
  • Languages: ES
Re: Problems with map rotation
« Reply #6 on: April 15, 2018, 09:02:00 PM »
well that solved it!, I suspected that it was an error in the code hehehehe. :D

later I try it  ;) .