Added node flag structs

This commit is contained in:
Emily 2020-12-27 02:11:48 +01:00
parent a23057c2fd
commit 9e1577b1dc
2 changed files with 41 additions and 4 deletions

View File

@ -97,7 +97,7 @@ void parseNode(FILE* file, PathNode* node) {
node->node = serializedNode.node;
node->width = serializedNode.width;
node->flood_fill = serializedNode.flood_fill;
node->flags = serializedNode.flags;
node->flags = *(NodeFlags*)&serializedNode.flags;
}
void parseNav(FILE* file, NavNode* node) {
@ -109,7 +109,7 @@ void parseNav(FILE* file, NavNode* node) {
node->node = serializedNode.node;
node->direction_x = serializedNode.direction_x / 100.f;
node->direction_y = serializedNode.direction_y / 100.f;
node->flags = serializedNode.flags;
node->flags = *(NavNodeFlags*)&serializedNode.flags;
}
void parseLink(FILE* file, Link* link) {

View File

@ -6,6 +6,9 @@
#define PATH "plugins/samp-npcs/Paths/"
#define STATIC_ASSERT(E) typedef char __static_assert_[(E)?1:-1]
#define EXPECT_SIZE(S,SIZE) STATIC_ASSERT(sizeof(S)==(SIZE))
#pragma pack(push, 1)
struct SerializedHeader {
unsigned int num_nodes;
@ -49,6 +52,40 @@ struct SerializedIntersectionFlags {
bool road_cross : 1;
bool ped_traffic_light : 1;
};
struct NodeFlags {
unsigned char link_count : 4;
unsigned char traffic_level : 2;
unsigned char roadblocks : 1;
unsigned char boats : 1;
unsigned char emergency_vehicles_only : 1;
unsigned char _unknown_D : 1;
unsigned char _unknown_E : 1;
unsigned char _unknown_F : 1;
unsigned char not_highway : 1;
unsigned char highway : 1;
unsigned char _unknown_I : 1;
unsigned char _unknown_J : 1;
unsigned char spawn_probability : 4;
unsigned char _unknown_roadblock_O : 1;
unsigned char parking : 1;
unsigned char _unknown_Q : 1;
unsigned char _unknown_R : 1;
unsigned char _unknown_S : 8;
};
EXPECT_SIZE(NodeFlags, 4);
struct NavNodeFlags {
unsigned int width : 8;
unsigned int num_left_lanes : 3;
unsigned int num_right_lanes : 3;
unsigned int traffic_lights_direction_behavior : 1;
unsigned int _unused_F : 1;
unsigned int traffic_lights_behavior : 2;
unsigned int train_crossing : 1;
unsigned int _unused_M : 13;
};
EXPECT_SIZE(NavNodeFlags, 4);
#pragma pack(pop)
struct PathNode {
@ -57,14 +94,14 @@ struct PathNode {
unsigned short link, area, node;
unsigned char width;
unsigned char flood_fill;
unsigned int flags;
NodeFlags flags;
};
struct NavNode {
float position_x, position_y;
unsigned short area, node;
float direction_x, direction_y;
unsigned int flags;
NavNodeFlags flags;
};
struct Link : SerializedLink {};