d2waypoints.h 1.68 KB
#ifndef D2WAYPOINTS_H
#define D2WAYPOINTS_H

#include <stdint.h>

#include "d2strings.h"

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

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;

int isWaypointActivated(D2WaypointsData* d, unsigned int waypoint, unsigned int difficulty);
void setWaypointActivated(D2WaypointsData* d, unsigned int waypoint, unsigned int difficulty, int activated);

#endif