Files
guru/games-engines/fs2_open/files/fs2_open-24.0.2-fix-odr.patch

174 lines
6.0 KiB
Diff

Fix ODR violations for `barracks_buttons` and `Section`.
https://bugs.gentoo.org/859982
https://github.com/scp-fs2open/fs2open.github.com/pull/6417
--- a/code/menuui/playermenu.cpp
+++ b/code/menuui/playermenu.cpp
@@ -79,45 +79,45 @@ const char *Player_select_background_mask_bitmap[GR_NUM_RESOLUTIONS] = {
#define PLAYER_SELECT_MAIN_HALL_OVERLAY NOX("MainHall1") // main hall help overlay
// convenient struct for handling all button controls
-struct barracks_buttons {
+struct barracks_buttons_alt {
const char *filename;
int x, y, xt, yt;
int hotspot;
UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
- barracks_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {}
+ barracks_buttons_alt(const char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {}
};
-static barracks_buttons Player_select_buttons[GR_NUM_RESOLUTIONS][NUM_PLAYER_SELECT_BUTTONS] = {
+static barracks_buttons_alt Player_select_buttons[GR_NUM_RESOLUTIONS][NUM_PLAYER_SELECT_BUTTONS] = {
{ // GR_640
// create, clone and delete (respectively)
- barracks_buttons("CPB_00", 114, 205, 117, 240, 0),
- barracks_buttons("CPB_01", 172, 205, 175, 240, 1),
- barracks_buttons("CPB_02", 226, 205, 229, 240, 2),
+ barracks_buttons_alt("CPB_00", 114, 205, 117, 240, 0),
+ barracks_buttons_alt("CPB_01", 172, 205, 175, 240, 1),
+ barracks_buttons_alt("CPB_02", 226, 205, 229, 240, 2),
// scroll up, scroll down, and accept (respectively)
- barracks_buttons("CPB_03", 429, 213, -1, -1, 3),
- barracks_buttons("CPB_04", 456, 213, -1, -1, 4),
- barracks_buttons("CPB_05", 481, 207, 484, 246, 5),
+ barracks_buttons_alt("CPB_03", 429, 213, -1, -1, 3),
+ barracks_buttons_alt("CPB_04", 456, 213, -1, -1, 4),
+ barracks_buttons_alt("CPB_05", 481, 207, 484, 246, 5),
// single player select and multiplayer select, respectively
- barracks_buttons("CPB_06", 428, 82, 430, 108, 6),
- barracks_buttons("CPB_07", 477, 82, 481, 108, 7)
+ barracks_buttons_alt("CPB_06", 428, 82, 430, 108, 6),
+ barracks_buttons_alt("CPB_07", 477, 82, 481, 108, 7)
},
{ // GR_1024
// create, clone and delete (respectively)
- barracks_buttons("2_CPB_00", 182, 328, 199, 384, 0),
- barracks_buttons("2_CPB_01", 275, 328, 292, 384, 1),
- barracks_buttons("2_CPB_02", 361, 328, 379, 384, 2),
+ barracks_buttons_alt("2_CPB_00", 182, 328, 199, 384, 0),
+ barracks_buttons_alt("2_CPB_01", 275, 328, 292, 384, 1),
+ barracks_buttons_alt("2_CPB_02", 361, 328, 379, 384, 2),
// scroll up, scroll down, and accept (respectively)
- barracks_buttons("2_CPB_03", 686, 341, -1, -1, 3),
- barracks_buttons("2_CPB_04", 729, 341, -1, -1, 4),
- barracks_buttons("2_CPB_05", 770, 332, 787, 394, 5),
+ barracks_buttons_alt("2_CPB_03", 686, 341, -1, -1, 3),
+ barracks_buttons_alt("2_CPB_04", 729, 341, -1, -1, 4),
+ barracks_buttons_alt("2_CPB_05", 770, 332, 787, 394, 5),
// single player select and multiplayer select, respectively
- barracks_buttons("2_CPB_06", 685, 132, 700, 173, 6),
- barracks_buttons("2_CPB_07", 764, 132, 782, 173, 7)
+ barracks_buttons_alt("2_CPB_06", 685, 132, 700, 173, 6),
+ barracks_buttons_alt("2_CPB_07", 764, 132, 782, 173, 7)
}
};
@@ -294,7 +294,7 @@ void player_select_set_controls(int gray)
void player_select_init()
{
int i;
- barracks_buttons *b;
+ barracks_buttons_alt *b;
UI_WINDOW *w;
// start a looping ambient sound
--- a/code/osapi/osregistry.cpp
+++ b/code/osapi/osregistry.cpp
@@ -475,17 +475,17 @@ typedef struct KeyValue
struct KeyValue *next;
} KeyValue;
-typedef struct Section
+typedef struct IniSection
{
char *name;
struct KeyValue *pairs;
- struct Section *next;
-} Section;
+ struct IniSection *next;
+} IniSection;
typedef struct Profile
{
- struct Section *sections;
+ struct IniSection *sections;
} Profile;
// For string config functions
@@ -602,8 +602,8 @@ static Profile *profile_read(const char *file)
Profile *profile = (Profile *)vm_malloc(sizeof(Profile));
profile->sections = NULL;
- Section **sp_ptr = &(profile->sections);
- Section *sp = NULL;
+ IniSection **sp_ptr = &(profile->sections);
+ IniSection *sp = NULL;
KeyValue **kvp_ptr = NULL;
@@ -620,7 +620,7 @@ static Profile *profile_read(const char *file)
*pend = 0;
if (*ptr) {
- sp = (Section *)vm_malloc(sizeof(Section));
+ sp = (IniSection *)vm_malloc(sizeof(IniSection));
sp->next = NULL;
sp->name = vm_strdup(ptr);
@@ -675,9 +675,9 @@ static void profile_free(Profile *profile)
if (profile == NULL)
return;
- Section *sp = profile->sections;
+ IniSection *sp = profile->sections;
while (sp != NULL) {
- Section *st = sp;
+ IniSection *st = sp;
KeyValue *kvp = sp->pairs;
while (kvp != NULL) {
@@ -709,8 +709,8 @@ static Profile *profile_update(Profile *profile, const char *section, const char
KeyValue *kvp;
- Section **sp_ptr = &(profile->sections);
- Section *sp = profile->sections;
+ IniSection **sp_ptr = &(profile->sections);
+ IniSection *sp = profile->sections;
while (sp != NULL) {
if (strcmp(section, sp->name) == 0) {
@@ -758,7 +758,7 @@ static Profile *profile_update(Profile *profile, const char *section, const char
}
/* section not found */
- sp = (Section *)vm_malloc(sizeof(Section));
+ sp = (IniSection *)vm_malloc(sizeof(IniSection));
sp->next = NULL;
sp->name = vm_strdup(section);
@@ -779,7 +779,7 @@ static char *profile_get_value(Profile *profile, const char *section, const char
if (profile == NULL)
return NULL;
- Section *sp = profile->sections;
+ IniSection *sp = profile->sections;
while (sp != NULL) {
if (stricmp(section, sp->name) == 0) {
@@ -814,7 +814,7 @@ static void profile_save(Profile *profile, const char *file)
if (fp == NULL)
return;
- Section *sp = profile->sections;
+ IniSection *sp = profile->sections;
while (sp != NULL) {
sprintf(tmp, NOX("[%s]\n"), sp->name);