blacha / diablo2

Utilities to work with diablo2, Clientless map rendering & packet sniffing
MIT License
191 stars 68 forks source link

Entry / exit locations for non-dungeon areas #414

Closed markusjohnsson closed 1 year ago

markusjohnsson commented 1 year ago

It seams to me that in the json, only dungeon exits are included in the objects list. Is it possible to also include the exit and entry points of non-dungeon areas, such as Cold plains (entry from Blood moor, exit to Stony field)?

Thanks for a useful project.

blacha commented 1 year ago

The entry/exit for non dungeon areas is in a separate location to where I am grabbing the dungeon areas from.

https://github.com/blacha/diablo2/blob/master/packages/map/map/d2_client.c#L334 this loop is looking over the objects in the map which has all the exits that are objects like stairs or caves.

The near by object is never looped, so we are not currently exporting the "nearby" exits.

To export the near by you would need to loop the pRoom2->dwRoomsNear

something like

for (int i = 0; i < pRoom2->dwRoomsNear; i++) {
    if (pLevel->dwLevelNo != pRoom2->pRoom2Near[i]->pLevel->dwLevelNo){
        int levelX = pRoom2->pRoom2Near[i]->pLevel->dwPosX * 5;
        int levelY = pRoom2->pRoom2Near[i]->pLevel->dwPosY * 5 ;

        int levelNumber = pRoom2->pRoom2Near[i]->pLevel->dwLevelNo;

        json_object_start();
        json_key_value("id", levelNumber);
        json_key_value("type", "exit");
        json_key_value("x", levelX);
        json_key_value("y", levelY);
        if (is_good_exit(pAct, pLevel, levelNumber)) json_key_value("isGoodExit", true);
        json_object_end();
    }
}
markusjohnsson commented 1 year ago

Wow cool, will check out your PR and try it!