d2waypoints.h 3.14 KB
#ifndef D2WAYPOINTS_H
#define D2WAYPOINTS_H

// Forward declaration
typedef enum D2S_DIFFICULTY D2S_DIFFICULTY;

#include <stdint.h>

#include "d2strings.h"

#define D2S_WAYPOINTSDATA_HEADER_LENGTH 2
#define D2S_WAYPOINTSDATA_LENGTH 5
#define D2S_WAYPOINTSDATA_NUMWAYPOINTS 39

typedef enum D2S_WAYPOINT {
    D2S_WAYPOINT_UNKNOWN = -1,
    D2S_WAYPOINT_ROGUE_ENCAMPMENT = 0,
    D2S_WAYPOINT_COLD_PLAINS,
    D2S_WAYPOINT_STONY_FIELD,
    D2S_WAYPOINT_DARK_WOOD,
    D2S_WAYPOINT_BLACK_MARSH,
    D2S_WAYPOINT_OUTER_CLOISTER,
    D2S_WAYPOINT_JAIL,
    D2S_WAYPOINT_INNER_CLOISTER,
    D2S_WAYPOINT_CATACOMBS,
    D2S_WAYPOINT_LUT_GHOLEIN,
    D2S_WAYPOINT_SEWERS,
    D2S_WAYPOINT_DRY_HILLS,
    D2S_WAYPOINT_HALLS_OF_THE_DEAD,
    D2S_WAYPOINT_FAR_OASIS,
    D2S_WAYPOINT_LOST_CITY,
    D2S_WAYPOINT_PALACE_CELLAR,
    D2S_WAYPOINT_ARCANE_SANCTUARY,
    D2S_WAYPOINT_CANYON_OF_THE_MAGI,
    D2S_WAYPOINT_KURAST_DOCS,
    D2S_WAYPOINT_SPIDER_FOREST,
    D2S_WAYPOINT_GREAT_MARSH,
    D2S_WAYPOINT_FLAYER_JUNGLE,
    D2S_WAYPOINT_LOWER_KURAST,
    D2S_WAYPOINT_KURAST_BAZAAR,
    D2S_WAYPOINT_UPPER_KURAST,
    D2S_WAYPOINT_TRAVINCAL,
    D2S_WAYPOINT_DURANCE_OF_HATE,
    D2S_WAYPOINT_PANDEMONIUM_FORTRESS,
    D2S_WAYPOINT_CITY_OF_THE_DAMNED,
    D2S_WAYPOINT_RIVER_OF_FLAMES,
    D2S_WAYPOINT_HARROGATH,
    D2S_WAYPOINT_FRIGID_HIGHLANDS,
    D2S_WAYPOINT_ARREAT_PLATEAU,
    D2S_WAYPOINT_CRYSTALLINE_PASSAGE,
    D2S_WAYPOINT_HALLS_OF_PAIN,
    D2S_WAYPOINT_GLACIAL_TRAIL,
    D2S_WAYPOINT_FROZEN_TUNDRA,
    D2S_WAYPOINT_ANCIENTS_WAY,
    D2S_WAYPOINT_WORLDSTONE_KEEP
} D2S_WAYPOINT;

const char* const waypoints[] = {
    D2S_WAYPOINT_0,
    D2S_WAYPOINT_1,
    D2S_WAYPOINT_2,
    D2S_WAYPOINT_3,
    D2S_WAYPOINT_4,
    D2S_WAYPOINT_5,
    D2S_WAYPOINT_6,
    D2S_WAYPOINT_7,
    D2S_WAYPOINT_8,
    D2S_WAYPOINT_9,
    D2S_WAYPOINT_10,
    D2S_WAYPOINT_11,
    D2S_WAYPOINT_12,
    D2S_WAYPOINT_13,
    D2S_WAYPOINT_14,
    D2S_WAYPOINT_15,
    D2S_WAYPOINT_16,
    D2S_WAYPOINT_17,
    D2S_WAYPOINT_18,
    D2S_WAYPOINT_19,
    D2S_WAYPOINT_20,
    D2S_WAYPOINT_21,
    D2S_WAYPOINT_22,
    D2S_WAYPOINT_23,
    D2S_WAYPOINT_24,
    D2S_WAYPOINT_25,
    D2S_WAYPOINT_26,
    D2S_WAYPOINT_27,
    D2S_WAYPOINT_28,
    D2S_WAYPOINT_29,
    D2S_WAYPOINT_30,
    D2S_WAYPOINT_31,
    D2S_WAYPOINT_32,
    D2S_WAYPOINT_33,
    D2S_WAYPOINT_34,
    D2S_WAYPOINT_35,
    D2S_WAYPOINT_36,
    D2S_WAYPOINT_37,
    D2S_WAYPOINT_38
};

typedef struct __attribute__((packed)) {
    uint16_t unknown1; // Apparently, always 0x0201
    uint8_t waypointData[D2S_WAYPOINTSDATA_LENGTH];
    uint8_t unknown2[17];
} D2Waypoints;

typedef struct __attribute__((packed)) {
    const char* header[D2S_WAYPOINTSDATA_HEADER_LENGTH]; // WS
    uint32_t unknown1; // This is likely version data
    uint16_t size; // in bytes
    D2Waypoints waypoints[3]; // 1 set for each difficulty
} D2WaypointsData;

// Returns static string from library memory, no need to free
const char* getWaypointName(D2S_WAYPOINT waypoint);
int isWaypointActivated(D2WaypointsData* d, D2S_WAYPOINT waypoint, D2S_DIFFICULTY difficulty);
int setWaypointActivated(D2WaypointsData* d, D2S_WAYPOINT waypoint, D2S_DIFFICULTY difficulty, int activated);

#endif