Feature: parce Contacs and laying ground for a iRacing Contact system

This commit is contained in:
2025-10-17 16:24:27 +01:00
parent 1fe0452ad6
commit 2df0838be8
5 changed files with 99 additions and 29 deletions
+9 -7
View File
@@ -49,16 +49,18 @@ int32_t read_int32(const u_int8_t *buf, size_t recv_len, size_t *offset, int *ok
return (int32_t)ntohl(v);
}
void read_float(const u_int8_t *buf, size_t recv_len, size_t *offset, float *out, int *ok) {
float read_float(const u_int8_t *buf, size_t recv_len, size_t *offset, int *ok) {
if (!ensure(recv_len, *offset, sizeof(float))) {
*ok = 0;
return;
return 0.0f;
}
uint32_t v;
memcpy(&v, buf + *offset, sizeof(v));
*offset += sizeof(v);
v = ntohl(v);
memcpy(out, &v, sizeof(float));
u_int32_t v_int;
memcpy(&v_int, buf + *offset, sizeof(v_int));
*offset += sizeof(v_int);
v_int = ntohl(v_int);
float v_float;
memcpy(&v_float, &v_int, sizeof(v_float));
return v_float;
}
void read_bytes(const u_int8_t *buf, size_t recv_len, size_t *offset, u_int8_t *out, size_t len, int *ok) {
+1 -1
View File
@@ -35,7 +35,7 @@ int32_t read_int32(const u_int8_t *buf, size_t recv_len, size_t *offset, int *ok
// Reads a 32-bit float from the buffer in network byte order.
// Advances the offset by 4 bytes.
void read_float(const u_int8_t *buf, size_t recv_len, size_t *offset, float *out, int *ok);
float read_float(const u_int8_t *buf, size_t recv_len, size_t *offset, int *ok);
// Reads a fixed number of bytes into the output buffer.
// The output buffer must be at least 'len' bytes long.
+16 -1
View File
@@ -59,10 +59,18 @@ struct postion {
float z;
} __attribute__((packed));
enum flag {
NO_FLAG = 0,
YELLOW_FLAG = 1,
BLUE_FLAG = 2,
BLACK_FLAG = 3,
CHECKERED_FLAG = 4,
}
struct carAtributes {
// Related to ACSP_CAR_INFO
u_char isConnected; // 1 = connected, 0 = disconnected
u_char isLoading; // 1 = loading, 0 = not loading
u_char isLoading; // 1 = loading, 0 = not isLoading
char *car_model;
char *car_skin;
@@ -80,6 +88,13 @@ struct carAtributes {
u_int32_t cuts;
u_int32_t total_cuts;
u_int32_t total_cuts_alltime;
u_int16_t total_laps_completed;
u_int16_t contacts;
u_int16_t total_contacts;
flag current_flag; // TODO: implement flag status updates
// TAG:3
float_t normalizedSplinePos;
} __attribute__((packed));