Skip to content

Commit

Permalink
Remove empty structures becuase visual studio not like empty structs
Browse files Browse the repository at this point in the history
  • Loading branch information
4144 committed Apr 11, 2023
1 parent 43b6c13 commit 0b691b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/api/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#define GET_DATA(var, type) const struct PACKET_API_REPLY_ ## type *var = (const struct PACKET_API_REPLY_ ## type*)data;
#define CREATE_DATA(var, type) struct PACKET_API_ ## type ## _data var = { 0 };
#define SEND_ASYNC_DATA(name, data) aloginif->send_to_char(fd, sd, API_MSG_ ## name, data, sizeof(struct PACKET_API_ ## name));
// SEND_ASYNC_DATA_EMPTY is workaround for visual studio bugs
#define SEND_ASYNC_DATA_EMPTY(name, data) aloginif->send_to_char(fd, sd, API_MSG_ ## name, data, 0);
#define SEND_ASYNC_DATA_SPLIT(name, data, size) aloginif->send_split_to_char(fd, sd, API_MSG_ ## name, data, size);

static struct handlers_interface handlers_s;
Expand Down Expand Up @@ -98,7 +100,7 @@ HTTPURL(userconfig_load)
#endif
aclif->show_request(fd, sd, false);

SEND_ASYNC_DATA(userconfig_load, NULL);
SEND_ASYNC_DATA_EMPTY(userconfig_load, NULL);

return true;
}
Expand Down Expand Up @@ -177,7 +179,7 @@ HTTPURL(charconfig_load)
#endif
aclif->show_request(fd, sd, false);

SEND_ASYNC_DATA(charconfig_load, NULL);
SEND_ASYNC_DATA_EMPTY(charconfig_load, NULL);

return true;
}
Expand Down
28 changes: 14 additions & 14 deletions src/common/apipackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,24 @@ struct PACKET_API_PROXY {
// [4144] duplicate of PACKET_API_PROXY with data field.
// for avoid visual studio bug with emply arrays
struct PACKET_API_PROXY0 {
int16 packet_id;
int16 packet_len;
int16 msg_id;
int32 server_id;
int32 client_fd;
int32 account_id;
int32 char_id;
int32 client_random_id;
struct PACKET_API_PROXY base;
char data[];
} __attribute__((packed));

STATIC_ASSERT(sizeof(struct PACKET_API_PROXY) == sizeof(struct PACKET_API_PROXY0), "Structs PACKET_API_PROXY and PACKET_API_PROXY0 must be same");
STATIC_ASSERT(sizeof(struct PACKET_API_PROXY) == sizeof(struct PACKET_API_PROXY0),
"Structs PACKET_API_PROXY and PACKET_API_PROXY0 must be same");

struct PACKET_API_PROXY_CHUNKED {
struct PACKET_API_PROXY base;
uint8 flag;
char data[];
} __attribute__((packed));

struct PACKET_API_EMPTY {
} __attribute__((packed));

struct userconfig_emotes {
char emote[MAX_EMOTES][EMOTE_SIZE];
} __attribute__((packed));

// api to char
struct PACKET_API_userconfig_load {
} __attribute__((packed));

struct PACKET_API_userconfig_save_emotes_data {
struct userconfig_emotes emotes;
Expand All @@ -93,11 +82,18 @@ struct PACKET_API_userconfig_save_emotes {
struct PACKET_API_userconfig_save_emotes_data data;
} __attribute__((packed));

/*
empty structs not supported by visual studio. left for future usage
struct PACKET_API_userconfig_load {
} __attribute__((packed));
struct PACKET_API_charconfig_load {
} __attribute__((packed));
struct PACKET_API_emblem_upload {
} __attribute__((packed));
*/

struct PACKET_API_emblem_upload_guild_id_data {
int guild_id;
Expand All @@ -121,6 +117,9 @@ struct PACKET_API_REPLY_userconfig_load {
struct userconfig_emotes emotes;
} __attribute__((packed));

/*
empty structs not supported by visual studio. left for future usage
struct PACKET_API_REPLY_userconfig_save {
} __attribute__((packed));
Expand All @@ -129,6 +128,7 @@ struct PACKET_API_REPLY_charconfig_load {
struct PACKET_API_REPLY_emblem_upload {
} __attribute__((packed));
*/

struct PACKET_API_REPLY_emblem_download {
uint8 flag;
Expand Down

0 comments on commit 0b691b9

Please sign in to comment.