raduprv / Eternal-Lands

http://www.eternal-lands.com
Other
158 stars 57 forks source link

Map Editor: Change the object entity_name on deleted objects when saving #104

Closed feeltheburn closed 3 years ago

feeltheburn commented 3 years ago

When a 3D object is deleted, the blending_level is changed to 20 instead of actually removing it. This tells the client not to show it.

It's done this way to ensure the object ID does not get changed (as that would break quests and other stuff). The next object added overwrites the lowest object that's at blending 20.

However, I don't think some of the server code is taking it into consideration that some of these objects are deleted. For example, a recent pear hunt has made me believe that the pear may have been placed in a DELETED harvestable item. Obviously that's a bad thing, heh.

In order to ensure this doesn't happen in the future, I'd like to see the object's file name change from whatever it was to a badobject e3d file (which does exist, but these days should only be possibly seen on ancient guild maps). As that object is of no use whatsoever to the client or server in normal game play, it's a perfect option.

Saving appears to occur at map_editor/map_io.c line 208.

Perhaps an "if" objects_list[i]->blended equals 20, change the cur_3d_obj_io.file_name to './3dobjects/badobject.e3d'

Doing it at the save rather than when it's deleted while editing will allow fixing the deleted entries in current maps by resaving them all. A dirty job, but I'll do it. ;)

This is a sample deleted 3d object's info from a json dump of the elm file, for reference if needed. { 'blending_level' => 20, 'rotation' => [ '0', '0', '140' ], 'scale' => '0', 'entity_name' => './3dobjects/sword5.e3d', '__unused' => [ 0, 0 ], 'position' => [ '76.438591003418', '72.8404312133789', '0' ], 'lighting_disabled' => 0, 'id' => 1024, 'color' => [ '0', '0', '0' ] }

feeltheburn commented 3 years ago

BTW, can anyone point out where in the client code the elm file is loaded, specifically where it presents the 3d objects (and doesn't show the ones marked as blended = 20)?

I wanna test something.

gvissers commented 3 years ago

BTW, can anyone point out where in the client code the elm file is loaded, specifically where it presents the 3d objects (and doesn't show the ones marked as blended = 20)?

I wanna test something.

It's in io/map_io.c, lines 298-323:

        if (cur_3d_obj_io.blended != 20)
        {
                    ...
        }
        else
        {
            inc_objects_list_placeholders();
        }
gvissers commented 3 years ago

Saving appears to occur at map_editor/map_io.c line 208.

Perhaps an "if" objects_list[i]->blended equals 20, change the cur_3d_obj_io.file_name to './3dobjects/badobject.e3d'

Why not...

Doing it at the save rather than when it's deleted while editing will allow fixing the deleted entries in current maps by resaving them all. A dirty job, but I'll do it. ;)

Oh, that's why :laughing: Will take stab at this tonight.

feeltheburn commented 3 years ago

Okay, did a test build that showed the deleted objects in the client. That was weird in some places ;)

Can't seem to harvest harvestable deleted objects but that doesn't mean the script that places the pear isn't missing that check.

(But then, I could be wrong as well, but as thoroughly as I checked the map in question during hunting including tearing down the map in the editor to find possibly hidden harvs - there were none - very unlikely I and at least two other separate hunters "just missed it".)

Regardless, this won't hurt.

gvissers commented 3 years ago

Okay, I've made the change.

Side note: not having access to the current server code I can of course not say for certain that deleted objects cannot be used to store a pear. I do have reasons to believe it is unlikely that this is what happened though. Nevertheless, the change seems reasonable anyway.

feeltheburn commented 3 years ago

'color' => [ '0', '0', '0' ], 'id' => 1917, 'blending_level' => 20, 'lighting_disabled' => 0, 'entity_name' => './3dobjects/badobject.e3d', 'scale' => '0', '__unused' => [ 0, 0 ], 'position' => [ '180.471801757812', '26.0829925537109', '0' ], 'rotation' => [ '0', '0', '0' ]

Works, thx!