DICE2000 / rvdata2json

interconvert rvdata/rvdata2 and json
26 stars 9 forks source link

fix some event command not convert back correctly #2

Closed mix5003 closed 9 months ago

mix5003 commented 1 year ago

i am not expert at ruby.

but sometime i found that some json not convert to object correctly

this is example json (this map has only 1 event, that contain 1 move route to move down 2 times)

{"json_class":"RPG::Map","@display_name":"","@tileset_id":1,"@width":17,"@height":13,"@scroll_type":0,"@specify_battleback":false,"@battleback_floor_name":null,"@battleback_wall_name":null,"@autoplay_bgm":false,"@bgm":{"json_class":"RPG::BGM","@name":"","@volume":100,"@pitch":100},"@autoplay_bgs":false,"@bgs":{"json_class":"RPG::BGS","@name":"","@volume":80,"@pitch":100},"@disable_dashing":false,"@encounter_list":[],"@encounter_step":30,"@parallax_name":"","@parallax_loop_x":false,"@parallax_loop_y":false,"@parallax_sx":0,"@parallax_sy":0,"@parallax_show":false,"@note":"","@data":{"json_class":"Table","@num_of_dimensions":3,"@xsize":17,"@ysize":13,"@zsize":4,"@num_of_elements":884,"@elements":[[[2816,2816,2816,2816,2816,2840,2064,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2816,2816,2816,2816,2816,2840,2064,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2816,2816,2816,2816,2816,2840,2064,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2816,2816,2816,2816,2816,2840,2064,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2816,2816,2816,2816,2816,2840,2064,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2844,2844,2844,2844,2844,2854,2064,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2068,2068,2068,2068,2068,2068,2049,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048],[2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048]],[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]]},"@events":{"1":{"json_class":"RPG::Event","@id":1,"@name":"EV001","@x":0,"@y":0,"@pages":[{"json_class":"RPG::Event::Page","@condition":{"json_class":"RPG::Event::Page::Condition","@switch1_valid":false,"@switch2_valid":false,"@variable_valid":false,"@self_switch_valid":false,"@item_valid":false,"@actor_valid":false,"@switch1_id":1,"@switch2_id":1,"@variable_id":1,"@variable_value":0,"@self_switch_ch":"A","@item_id":1,"@actor_id":1},"@graphic":{"json_class":"RPG::Event::Page::Graphic","@tile_id":0,"@character_name":"Animal","@character_index":0,"@direction":2,"@pattern":0},"@move_type":0,"@move_speed":3,"@move_frequency":3,"@move_route":{"json_class":"RPG::MoveRoute","@repeat":true,"@skippable":false,"@wait":false,"@list":[{"json_class":"RPG::MoveCommand","@code":0,"@parameters":[]}]},"@walk_anime":true,"@step_anime":false,"@direction_fix":false,"@through":false,"@priority_type":1,"@trigger":3,"@list":[{"json_class":"RPG::EventCommand","@code":205,"@indent":0,"@parameters":[0,{"json_class":"RPG::MoveRoute","@repeat":false,"@skippable":false,"@wait":true,"@list":[{"json_class":"RPG::MoveCommand","@code":1,"@parameters":[]},{"json_class":"RPG::MoveCommand","@code":1,"@parameters":[]},{"json_class":"RPG::MoveCommand","@code":0,"@parameters":[]}]}]},{"json_class":"RPG::EventCommand","@code":505,"@indent":0,"@parameters":[{"json_class":"RPG::MoveCommand","@code":1,"@parameters":[]}]},{"json_class":"RPG::EventCommand","@code":505,"@indent":0,"@parameters":[{"json_class":"RPG::MoveCommand","@code":1,"@parameters":[]}]},{"json_class":"RPG::EventCommand","@code":0,"@indent":0,"@parameters":[]}]}]}}}

and this is example output before this patch

<RPG::Event:0x00000000065a0720 
    @id=1, 
    @name="EV001",
    @x=0, 
    @y=0, 
    @pages=[
        <RPG::Event::Page:0x000000000659bec8 
        @condition=<RPG::Event::Page::Condition:0x000000000659b9a0 @switch1_valid=false, @switch2_valid=false, @variable_valid=false, @self_switch_valid=false, @item_valid=false, @actor_valid=false, @switch1_id=1, @switch2_id=1, @variable_id=1, @variable_value=0, @self_switch_ch="A", @item_id=1, @actor_id=1>, 
        @graphic=<RPG::Event::Page::Graphic:0x000000000659ae88 
            @tile_id=0, 
            @character_name="Animal", 
            @character_index=0, 
            @direction=2, 
            @pattern=0>, 
            @move_type=0, 
            @move_speed=3, 
            @move_frequency=3, 
            @move_route=<RPG::MoveRoute:0x000000000659a690 @repeat=true, @skippable=false, @wait=false, @list=[<RPG::MoveCommand:0x000000000659a2d0 @code=0, @parameters=[]>]>, 
            @walk_anime=true,
            @step_anime=false, 
            @direction_fix=false, 
            @through=false, 
            @priority_type=1, 
            @trigger=3, 
            @list=[
                <RPG::EventCommand:0x0000000006599c40 
                    @code=205, 
                    @indent=0, 
                    @parameters=[
                        0, 
                        {"json_class"=>"RPG::MoveRoute", "@repeat"=>false, "@skippable"=>false, "@wait"=>true, "@list"=>[
                            {"json_class"=>"RPG::MoveCommand", "@code"=>1, "@parameters"=>[]}, 
                            {"json_class"=>"RPG::MoveCommand", "@code"=>1, "@parameters"=>[]}, 
                            {"json_class"=>"RPG::MoveCommand", "@code"=>0, "@parameters"=>[]}
                        ]}
                    ]
                >, 
                <RPG::EventCommand:0x00000000065999c0 @code=505, @indent=0, @parameters=[<RPG::MoveCommand:0x00000000065996f0 @code=1, @parameters=[]>]>, 
                <RPG::EventCommand:0x00000000065994e8 @code=505, @indent=0, @parameters=[<RPG::MoveCommand:0x0000000006599268 @code=1, @parameters=[]>]>, 
                <RPG::EventCommand:0x0000000006599060 @code=0, @indent=0, @parameters=[]>
            ]
        >
    ]
>