GM:S 1.4 Draw Path Display Bug

Discussion in 'Programming' started by dcamod, May 30, 2019.

  1. dcamod

    dcamod Member

    Joined:
    Feb 9, 2017
    Posts:
    43
    I am having an issue where I have drawn a path in the draw GUI event that does not display. I ran through the debugger and it appears as if there is no path index even though I have declared a path and set mp_grid_path in both the create event and the step event. I copied the exact code with the exact same objects and variable names into another project and it worked just fine which is why I am posting here. It seems strange. I have been using this project file for a long time to test various AI methods and I would hate to have to recreate it just to reference my old code. The project is not from an earlier version of GM:S so I have ruled that out. The room only has the controller object and the AI object in it. There is no creation code for the room and the objects are in the correct creation order (controller then AI). Is the project file corrupted?

    Here is the code for both projects. I stripped the old project down to only this just to test it.

    Code:
    ///Grid and Display
    global.grid = mp_grid_create(0,0,room_width/64+1,room_height/64+1,64,64);
    mp_grid_add_instances(global.grid,obj_par_solid,true)
    
    as = 0
    
    display_set_gui_size(view_wport[0], view_hport[0]);

    Code:
    //Paths
    path = path_add();
    
    path_set_kind(path,1);
    path_set_precision(path,8);
    
    mp_grid_path(global.grid,path,x,y,x+256,y+256,true);
    

    Code:
    draw_path(path,x,y,1)
     
  2. zATARA_0

    zATARA_0 Member

    Joined:
    Apr 10, 2019
    Posts:
    40
    If the exact code worked fine in another project then probably the file is corrupted, sorry.
     
  3. EvanSki

    EvanSki Dedicated link provider

    Joined:
    Apr 17, 2018
    Posts:
    439
    Make sure to clear your cache by pressing the broom next to the run button
     
  4. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,058
    You can use Micks Resource Importer Tool to quickly recreate your project which will save time from having to do it manually.
     
  5. dcamod

    dcamod Member

    Joined:
    Feb 9, 2017
    Posts:
    43
    I cleaned the project file cache before starting this thread. Thanks for the input though. The resource importer tool looks neat. I will give it a look.
     
  6. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,068
    What's the size of the room you are testing with (room_width and room_height)?

    What's the return value of the mp_grid_path() function? ( It will return false if no path was found )

    What's the x and y starting position of the OBJ_AI instance in the room?

    You are setting the target destination as (x + 256) and (y + 256). I can imagine some setups where that location would be outside of the mp_grid, thus would cause mp_grid_path() to fail to find a path to the goal. For example, if your OBJ AI was positioned in the lower right hand corner of the room, the target goal would be outside the mp_grid for small room sizes.
     
    dcamod and EvanSki like this.
  7. dcamod

    dcamod Member

    Joined:
    Feb 9, 2017
    Posts:
    43
    Thanks for the response. The room size is 2048x2048. The return value for mp_grid path is positive. the x and y are well within the boundaries of the room. The code above is just place holder code with no reason for the destination I have set other than to give it a destination. The reason I drew the path on the GUI layer just to test it and make sure it was returning a path.
     
  8. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,068
    Ignore this if you have already checked for this, but the only other thing I can think of is that the GUI Layer coordinates are not the same as room coordinates. You're using the x and y position in the room to draw the path, and while it may be within the room, the same values may not be withing the GUI Layer. GUI Layer goes from 0,0 at the top left corner to display width/height at the bottom right corner of the display.
     
    EvanSki likes this.
  9. dcamod

    dcamod Member

    Joined:
    Feb 9, 2017
    Posts:
    43
    The GUI layer is the same size as the viewport, which is the same size as the room. I am not sure if when I set the GUI layer to be the size of the viewport if that messed something up. It does not seem like it would to me, but maybe I am missing something? What I am wondering is why it would work fine in one project and not the other. They have the exact same code in the room and the objects that are within the room. The only difference is that the buggy project has a lot of other code in it from around 40 different movement code experiments and I have used it quite a long time for testing different movement codes. I have several versions of it but the one that is bugged is the newest one.
     
  10. dcamod

    dcamod Member

    Joined:
    Feb 9, 2017
    Posts:
    43
    I have new information I have discovered about this bug. When I run the project file and close out of the game it crashes giving me this error.
    Problem signature:
    Problem Event Name: APPCRASH
    Application Name: Runner.exe
    Application Version: 99.99.99.99
    Application Timestamp: 5aa7bf57
    Fault Module Name: Runner.exe
    Fault Module Version: 99.99.99.99
    Fault Module Timestamp: 5aa7bf57
    Exception Code: c0000005
    Exception Offset: 00093132
    OS Version: 6.1.7601.2.1.0.256.1
    Locale ID: 1033
    Additional Information 1: 0a9e
    Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
    Additional Information 3: 0a9e
    Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

    This is a clue as to what is happening. I know this issue probably won't be solved, but I am a very curious person and would still like to know what this error is. I have tried to look it up but all I have gathered is that this can happen for many reasons. In this case the engine is creating temporary files when I execute and removing them when I terminate I presume. This leads me to believe that the cause is file corruption. Could it be file corruption caused by a memory error?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice