Skip to content

Commit

Permalink
feat: add lose condition setting for multiplayer/skirmish
Browse files Browse the repository at this point in the history
either by structures or by ground-units + structures
  • Loading branch information
codeflorist committed May 13, 2023
1 parent 01d549d commit b6ef892
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 52 deletions.
5 changes: 5 additions & 0 deletions src/mods/mapgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ enum MapSeedMode {
MAP_SEED_MODE_SURPRISE = 2,
};

enum MapLoseCondition {
MAP_LOSE_CONDITION_STRUCTURES = 0,
MAP_LOSE_CONDITION_UNITS = 1
};

extern enum MapGeneratorMode MapGenerator_TransitionState(enum MapGeneratorMode mode, bool success);
extern uint32 MapGenerator_PickRandomSeed(void);

Expand Down
1 change: 1 addition & 0 deletions src/mods/multiplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Multiplayer_Init(void)
g_multiplayer.curr_seed = MapGenerator_PickRandomSeed();
g_multiplayer.next_seed = g_multiplayer.curr_seed;
g_multiplayer.seed_mode = MAP_SEED_MODE_RANDOM;
g_multiplayer.lose_condition = MAP_LOSE_CONDITION_STRUCTURES;

g_multiplayer.landscape_params.min_spice_fields = 24;
g_multiplayer.landscape_params.max_spice_fields = 48;
Expand Down
3 changes: 3 additions & 0 deletions src/mods/multiplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ typedef struct Multiplayer {
/* Map seed modes include random, user-defined and hidden from user. */
uint32 seed_mode;

/* Win condition can be structures or units. */
uint32 lose_condition;

LandscapeGeneratorParams landscape_params;

enum MultiplayerHouseState state[HOUSE_MAX];
Expand Down
1 change: 1 addition & 0 deletions src/net/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ Client_Recv_Scenario(const unsigned char **buf)
g_multiplayer.next_seed = Net_Decode_uint32(buf);
g_multiplayer.test_seed = g_multiplayer.next_seed;
g_multiplayer.seed_mode = Net_Decode_uint32(buf);
g_multiplayer.lose_condition = Net_Decode_uint32(buf);
g_multiplayer.landscape_params.min_spice_fields = Net_Decode_uint32(buf);
g_multiplayer.landscape_params.max_spice_fields = Net_Decode_uint32(buf);
enhancement_fog_of_war = Net_Decode_uint8(buf);
Expand Down
1 change: 1 addition & 0 deletions src/net/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ Server_Send_Scenario(unsigned char **buf)
Net_Encode_uint16(buf, g_multiplayer.credits);
Net_Encode_uint32(buf, g_multiplayer.next_seed);
Net_Encode_uint32(buf, g_multiplayer.seed_mode);
Net_Encode_uint32(buf, g_multiplayer.lose_condition);
Net_Encode_uint32(buf, g_multiplayer.landscape_params.min_spice_fields);
Net_Encode_uint32(buf, g_multiplayer.landscape_params.max_spice_fields);
Net_Encode_uint8 (buf, enhancement_fog_of_war);
Expand Down
143 changes: 96 additions & 47 deletions src/newui/menu_lobby.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum MapGeneratorMode lobby_map_generator_mode;

char map_options_fixed_seed[5 + 1] = "";
char map_options_starting_credits[5 + 1] = "0";
enum MapLoseCondition map_options_lose_condition = MAP_LOSE_CONDITION_STRUCTURES;
enum MapSeedMode map_options_seed_mode = MAP_SEED_MODE_RANDOM;
char map_options_spice_fields_min[3 + 1] = "0";
char map_options_spice_fields_max[3 + 1] = "0";
Expand All @@ -49,6 +50,7 @@ char map_options_spice_fields_max[3 + 1] = "0";
Skirmish map_options_saved_skirmish;
Multiplayer map_options_saved_multiplayer;
enum MapSeedMode map_options_saved_seed_mode;
enum MapLoseCondition map_options_saved_lose_condition;

/*--------------------------------------------------------------*/

Expand Down Expand Up @@ -261,6 +263,17 @@ MapOptionsLobby_ChangeSeedMode(enum MapSeedMode seed_mode)
map_options_seed_mode = seed_mode;
}

static void
MapOptionsLobby_ChangeLoseCondition(enum MapLoseCondition lose_condition)
{
for(int m = 0; m < 2; m++) {
Widget *w = GUI_Widget_Get_ByIndex(map_options_lobby_widgets, MAP_OPTIONS_WIDGET_LOSE_CONDITION_STRUCTURES + m);
w->drawParameterNormal.sprite = ((int)lose_condition == m) ? SHAPE_RADIO_BUTTON_ON: SHAPE_RADIO_BUTTON_OFF;
w->state.selected = ((int)lose_condition == m) ? 1: 0;
}
map_options_lose_condition = lose_condition;
}

static void
MapOptionsLobby_UpdateReadOnlyView(void)
{
Expand All @@ -283,23 +296,37 @@ MapOptionsLobby_UpdateReadOnlyView(void)
map_options_seed_mode = g_multiplayer.seed_mode;
MapOptionsLobby_ChangeSeedMode(map_options_seed_mode);
}

if (map_options_lose_condition != g_multiplayer.lose_condition) {
map_options_lose_condition = g_multiplayer.lose_condition;
MapOptionsLobby_ChangeLoseCondition(map_options_lose_condition);
}
}
}

static bool
MapOptionsLobby_ClickRadioButton(Widget *radio)
MapOptionsLobby_ClickMapSeedRadioButton(Widget *radio)
{
MapOptionsLobby_ChangeSeedMode(radio->index - MAP_OPTIONS_WIDGET_SEED_RANDOM);

return true;
}

static bool
MapOptionsLobby_ClickLoseConditionRadioButton(Widget *radio)
{
MapOptionsLobby_ChangeLoseCondition(radio->index - MAP_OPTIONS_WIDGET_LOSE_CONDITION_STRUCTURES);

return true;
}

static void
MapOptionsLobby_InitWidgets(void)
{
Widget *w;

const int lineHeight = MAP_OPTIONS_GUI_LINE_HEIGHT;
int offsetY;

/* Starting credits. */
w = GUI_Widget_Allocate(24, 0, MAP_OPTIONS_GUI_MAIN_X + 4, MAP_OPTIONS_GUI_MAIN_Y + 1*lineHeight, 0xFFFE, STR_NULL);
Expand All @@ -319,23 +346,36 @@ MapOptionsLobby_InitWidgets(void)
w->flags.invisible = true;
map_options_lobby_widgets = GUI_Widget_Link(map_options_lobby_widgets, w);

/* lose condition radio buttons. */
const int loseConditionRadioOffsetX[] = {0,68};
for (int choice = 0; choice < 2; choice++) {
w = GUI_Widget_Allocate(MAP_OPTIONS_WIDGET_LOSE_CONDITION_STRUCTURES + choice, 0, MAP_OPTIONS_GUI_MAIN_X + loseConditionRadioOffsetX[choice],
MAP_OPTIONS_GUI_MAIN_Y + 44, SHAPE_RADIO_BUTTON_OFF, STR_NULL);
w->width = (choice == MAP_OPTIONS_WIDGET_LOSE_CONDITION_STRUCTURES) ? 84 : 46;
w->clickProc = MapOptionsLobby_ClickLoseConditionRadioButton;
w->drawParameterNormal.sprite = (choice == (int)map_options_lose_condition) ? SHAPE_RADIO_BUTTON_ON: SHAPE_RADIO_BUTTON_OFF;
w->state.selected = (choice == (int)map_options_lose_condition) ? 1: 0;
w->flags.greyWhenInvisible = true;
map_options_lobby_widgets = GUI_Widget_Link(map_options_lobby_widgets, w);
}

/* Map selection mode. */

/* Radio buttons. */
const int mapOffsetY[] = {14, 28, 56};
/* Seed radio buttons. */
const int mapOffsetY[] = {14, 28, 42};
for (int choice = 0; choice < 3; choice++) {
w = GUI_Widget_Allocate(MAP_OPTIONS_WIDGET_SEED_RANDOM + choice, 0, MAP_OPTIONS_GUI_MAP_X + 4,
MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[choice], SHAPE_RADIO_BUTTON_OFF, STR_NULL);
w->width = (choice == MAP_SEED_MODE_SURPRISE) ? 84 : 46;
w->clickProc = MapOptionsLobby_ClickRadioButton;
w->clickProc = MapOptionsLobby_ClickMapSeedRadioButton;
w->drawParameterNormal.sprite = (choice == (int)map_options_seed_mode) ? SHAPE_RADIO_BUTTON_ON: SHAPE_RADIO_BUTTON_OFF;
w->state.selected = (choice == (int)map_options_seed_mode) ? 1: 0;
w->flags.greyWhenInvisible = true;
map_options_lobby_widgets = GUI_Widget_Link(map_options_lobby_widgets, w);
}

/* Map selection override. */
w = GUI_Widget_Allocate(23, 0, MAP_OPTIONS_GUI_MAP_X + 16, MAP_OPTIONS_GUI_MAP_Y + 42 - 2, 0xFFFE, STR_NULL);
/* Map fixed seed input. */
w = GUI_Widget_Allocate(23, 0, MAP_OPTIONS_GUI_MAP_X + 50, MAP_OPTIONS_GUI_MAP_Y + 28 - 2, 0xFFFE, STR_NULL);
w->width = 46;
w->height = 12;
memset(&w->flags, 0, sizeof(w->flags));
Expand All @@ -352,9 +392,8 @@ MapOptionsLobby_InitWidgets(void)
w->flags.invisible = true;
map_options_lobby_widgets = GUI_Widget_Link(map_options_lobby_widgets, w);

/* Spice fields */
int offsetY = MAP_OPTIONS_GUI_MAIN_Y + 6;
w = GUI_Widget_Allocate(3, 0, MAP_OPTIONS_GUI_MAIN_X + 22, offsetY + 3 * lineHeight, 0xFFFE, STR_NULL);
/* Spice fields min input */
w = GUI_Widget_Allocate(3, 0, MAP_OPTIONS_GUI_MAP_X + 22, MAP_OPTIONS_GUI_MAP_Y + 70 -2, 0xFFFE, STR_NULL);
w->width = 32;
w->height = 12;
memset(&w->flags, 0, sizeof(w->flags));
Expand All @@ -371,7 +410,8 @@ MapOptionsLobby_InitWidgets(void)
w->flags.invisible = true;
map_options_lobby_widgets = GUI_Widget_Link(map_options_lobby_widgets, w);

w = GUI_Widget_Allocate(4, 0, MAP_OPTIONS_GUI_MAIN_X + 78, offsetY + 3 * lineHeight, 0xFFFE, STR_NULL);
/* Spice fields max input */
w = GUI_Widget_Allocate(4, 0, MAP_OPTIONS_GUI_MAP_X + 78, MAP_OPTIONS_GUI_MAP_Y + 70 -2, 0xFFFE, STR_NULL);
w->width = 32;
w->height = 12;
memset(&w->flags, 0, sizeof(w->flags));
Expand Down Expand Up @@ -405,7 +445,7 @@ MapOptionsLobby_InitWidgets(void)
map_options_lobby_widgets = GUI_Widget_Link(map_options_lobby_widgets, w);

/* Regenerate map. */
w = GUI_Widget_Allocate(9, 0, MAP_OPTIONS_GUI_MAP_X + 110, MAP_OPTIONS_GUI_MAP_Y + 9, SHAPE_INVALID, STR_NULL);
w = GUI_Widget_Allocate(9, 0, MAP_OPTIONS_GUI_MAP_X + 119, MAP_OPTIONS_GUI_MAP_Y + 9, SHAPE_INVALID, STR_NULL);
w->width = 62;
w->height = 62;
map_options_lobby_widgets = GUI_Widget_Link(map_options_lobby_widgets, w);
Expand Down Expand Up @@ -458,9 +498,10 @@ MapOptionsLobby_Initialise(void)
map_options_saved_skirmish = g_skirmish;
map_options_saved_multiplayer = g_multiplayer;
map_options_saved_seed_mode = map_options_seed_mode;
map_options_saved_lose_condition = map_options_lose_condition;

int widgetIDs[] = {3, 4, 5, 6, 23, 24, MAP_OPTIONS_WIDGET_SEED_RANDOM,
MAP_OPTIONS_WIDGET_SEED_RANDOM+1, MAP_OPTIONS_WIDGET_SEED_RANDOM+2, -1};
int widgetIDs[] = {3, 4, 5, 6, 23, 24, MAP_OPTIONS_WIDGET_LOSE_CONDITION_STRUCTURES, MAP_OPTIONS_WIDGET_LOSE_CONDITION_STRUCTURES+1,
MAP_OPTIONS_WIDGET_SEED_RANDOM, MAP_OPTIONS_WIDGET_SEED_RANDOM+1, MAP_OPTIONS_WIDGET_SEED_RANDOM+2, -1};
for (int i = 0; widgetIDs[i] > 0; i++)
GUI_Widget_Get_ByIndex(map_options_lobby_widgets, widgetIDs[i])->flags.invisible = MapOptionsLobby_IsReadOnly();

Expand All @@ -481,6 +522,7 @@ MapOptionsLobby_Initialise(void)
widgetApply->flags.greyWhenInvisible = !MapOptionsLobby_IsReadOnly();

MapOptionsLobby_ChangeSeedMode(map_options_seed_mode);
MapOptionsLobby_ChangeLoseCondition(map_options_lose_condition);
}

static int
Expand Down Expand Up @@ -567,12 +609,14 @@ MapOptionsLobby_Loop(void)
g_skirmish = map_options_saved_skirmish;
g_multiplayer = map_options_saved_multiplayer;
map_options_seed_mode = map_options_saved_seed_mode;
map_options_lose_condition = map_options_saved_lose_condition;
return MENU_NO_TRANSITION | (is_multiplayer ? MENU_MULTIPLAYER_LOBBY: MENU_SKIRMISH_LOBBY);
}

if (widgetID == 0x8002) { /* Apply was pressed. */
GUI_Widget_MakeNormal(GUI_Widget_Get_ByIndex(map_options_lobby_widgets, 2), false);
g_multiplayer.seed_mode = map_options_seed_mode;
g_multiplayer.lose_condition = map_options_lose_condition;
enhancement_fog_of_war = (GUI_Widget_Get_ByIndex(map_options_lobby_widgets, 5)->state.selected != 0);
enhancement_insatiable_sandworms = (GUI_Widget_Get_ByIndex(map_options_lobby_widgets, 6)->state.selected != 0);
int result = MapOptionsLobby_HandleMapAndMessages(true);
Expand Down Expand Up @@ -975,6 +1019,7 @@ MapOptionsLobby_Draw(void)
const int lineHeight = MAP_OPTIONS_GUI_LINE_HEIGHT;
const int errorX = MAP_OPTIONS_GUI_ERROR_X, errorY = MAP_OPTIONS_GUI_ERROR_Y;
bool issuesFound = false;
int offsetY;

GUI_HallOfFame_SetColourScheme(true);
HallOfFame_DrawBackground(HOUSE_INVALID, HALLOFFAMESTYLE_CLEAR_BACKGROUND);
Expand Down Expand Up @@ -1002,34 +1047,11 @@ MapOptionsLobby_Draw(void)
}
}

/* Spice fields */
int offsetY = MAP_OPTIONS_GUI_MAIN_Y + 6;
GUI_DrawText_Wrapper("Spice fields:", MAP_OPTIONS_GUI_MAIN_X, offsetY + 2*lineHeight, 0xF, 0, 0x22);
GUI_DrawText_Wrapper("Min:", MAP_OPTIONS_GUI_MAIN_X, offsetY + 3*lineHeight + 2, 0xF, 0, 0x21);
GUI_DrawText_Wrapper("Max:", MAP_OPTIONS_GUI_MAIN_X + 55, offsetY + 3*lineHeight + 2, 0xF, 0, 0x21);
const int spice_min = atoi(map_options_spice_fields_min);
if (spice_min < MAP_OPTIONS_SPICE_MIN) {
GUI_DrawText_Wrapper("x", MAP_OPTIONS_GUI_MAIN_X + 68, offsetY + 2*lineHeight, 0xE7, 0, 0x21);
if (!issuesFound) {
GUI_DrawText_Wrapper("Min. %u spice field spawn points", errorX, errorY, 0xE7, 0, 0x21, MAP_OPTIONS_SPICE_MIN);
issuesFound = true;
}
}
const int spice_max = atoi(map_options_spice_fields_max);
if (spice_max > MAP_OPTIONS_SPICE_MAX) {
GUI_DrawText_Wrapper("x", MAP_OPTIONS_GUI_MAIN_X + 68, offsetY + 2*lineHeight, 0xE7, 0, 0x21);
if (!issuesFound) {
GUI_DrawText_Wrapper("Max. %u spice field spawn points", errorX, errorY, 0xE7, 0, 0x21, MAP_OPTIONS_SPICE_MAX);
issuesFound = true;
}
}
if (spice_min > spice_max) {
GUI_DrawText_Wrapper("x", MAP_OPTIONS_GUI_MAIN_X + 68, offsetY + 2*lineHeight, 0xE7, 0, 0x21);
if (!issuesFound) {
GUI_DrawText_Wrapper("Min. spice larger than max.", errorX, errorY, 0xE7, 0, 0x21);
issuesFound = true;
}
}
/* Win Condition */
offsetY = MAP_OPTIONS_GUI_MAIN_Y + 6;
GUI_DrawText_Wrapper("Lose condition:", MAP_OPTIONS_GUI_MAIN_X, offsetY + 2*lineHeight, 0xF, 0, 0x22);
GUI_DrawText_Wrapper("Structures", MAP_OPTIONS_GUI_MAIN_X + 10, offsetY + 3*lineHeight + 2, (map_options_lose_condition == MAP_LOSE_CONDITION_STRUCTURES) ? 0x8: 0xF, 0, 0x21);
GUI_DrawText_Wrapper("Units", MAP_OPTIONS_GUI_MAIN_X + 78, offsetY + 3*lineHeight + 2, (map_options_lose_condition == MAP_LOSE_CONDITION_UNITS) ? 0x8: 0xF, 0, 0x21);

/* Enhancement: Fog of War */
offsetY = MAP_OPTIONS_GUI_MAIN_Y + 12;
Expand All @@ -1040,30 +1062,57 @@ MapOptionsLobby_Draw(void)
/* Map and map options */
Prim_DrawBorder(MAP_OPTIONS_GUI_MAP_X - 2, MAP_OPTIONS_GUI_MAP_Y - 2,
MAP_OPTIONS_GUI_MAP_W + 4, MAP_OPTIONS_GUI_MAP_H + 4, 1, false, false, 4);
const int mapOffsetY[] = {0, 14, 28, 42, 56};
const int mapOffsetY[] = {0, 14, 28, 42, 56, 70};

/* Map Seed */
GUI_DrawText_Wrapper("Map seed:", MAP_OPTIONS_GUI_MAP_X, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[0], 0xF, 0, 0x22);
GUI_DrawText_Wrapper("Random", MAP_OPTIONS_GUI_MAP_X + 16, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[1],
(map_options_seed_mode == MAP_SEED_MODE_RANDOM) ? 0x8: 0xF, 0, 0x21);
GUI_DrawText_Wrapper("Fixed:", MAP_OPTIONS_GUI_MAP_X + 16, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[2],
(map_options_seed_mode == MAP_SEED_MODE_FIXED) ? 0x8: 0xF, 0, 0x21);
GUI_DrawText_Wrapper("Surprise me!", MAP_OPTIONS_GUI_MAP_X + 16, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[4],
GUI_DrawText_Wrapper("Surprise me!", MAP_OPTIONS_GUI_MAP_X + 16, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[3],
(map_options_seed_mode == MAP_SEED_MODE_SURPRISE) ? 0x8: 0xF, 0, 0x21);

const uint32 override_seed = atoi(map_options_fixed_seed);
const uint32 current_seed = is_skirmish ? g_skirmish.seed : g_multiplayer.test_seed;
if ((map_options_seed_mode == MAP_SEED_MODE_FIXED) && (override_seed != current_seed)) {
/* Show an error indication, because the requested seed could not be applied.*/
GUI_DrawText_Wrapper("x", MAP_OPTIONS_GUI_MAP_X + 65, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[3], 0xE7, 0, 0x21);
GUI_DrawText_Wrapper("x", MAP_OPTIONS_GUI_MAP_X + 97, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[2], 0xE7, 0, 0x21);
if (!issuesFound) {
GUI_DrawText_Wrapper("Map rejected. Enough build space?",
errorX, errorY, 0xE7, 0, 0x21, MAP_OPTIONS_STARTING_CREDITS_MAX);
issuesFound = true;
}
}

/* Error message box region */
Prim_DrawBorder(MAP_OPTIONS_GUI_ERROR_X - 2, MAP_OPTIONS_GUI_ERROR_Y - 2,
MAP_OPTIONS_GUI_ERROR_W + 4, MAP_OPTIONS_GUI_ERROR_H + 4, 1, false, false, 4);
/* Spice fields */
offsetY = MAP_OPTIONS_GUI_MAIN_Y + 6;
GUI_DrawText_Wrapper("Spice fields:", MAP_OPTIONS_GUI_MAP_X, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[4], 0xF, 0, 0x22);
GUI_DrawText_Wrapper("Min:", MAP_OPTIONS_GUI_MAP_X, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[5], 0xF, 0, 0x21);
GUI_DrawText_Wrapper("Max:", MAP_OPTIONS_GUI_MAP_X + 55, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[5], 0xF, 0, 0x21);
const int spice_min = atoi(map_options_spice_fields_min);
if (spice_min < MAP_OPTIONS_SPICE_MIN) {
GUI_DrawText_Wrapper("x", MAP_OPTIONS_GUI_MAP_X + 110, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[5], 0xE7, 0, 0x21);
if (!issuesFound) {
GUI_DrawText_Wrapper("Min. %u spice field spawn points", errorX, errorY, 0xE7, 0, 0x21, MAP_OPTIONS_SPICE_MIN);
issuesFound = true;
}
}
const int spice_max = atoi(map_options_spice_fields_max);
if (spice_max > MAP_OPTIONS_SPICE_MAX) {
GUI_DrawText_Wrapper("x", MAP_OPTIONS_GUI_MAP_X + 110, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[5], 0xE7, 0, 0x21);
if (!issuesFound) {
GUI_DrawText_Wrapper("Max. %u spice field spawn points", errorX, errorY, 0xE7, 0, 0x21, MAP_OPTIONS_SPICE_MAX);
issuesFound = true;
}
}
if (spice_min > spice_max) {
GUI_DrawText_Wrapper("x", MAP_OPTIONS_GUI_MAP_X + 110, MAP_OPTIONS_GUI_MAP_Y + mapOffsetY[5], 0xE7, 0, 0x21);
if (!issuesFound) {
GUI_DrawText_Wrapper("Min. spice larger than max.", errorX, errorY, 0xE7, 0, 0x21);
issuesFound = true;
}
}

const uint32 next_seed = is_skirmish ? g_skirmish.seed : g_multiplayer.next_seed;
Lobby_DrawRadar(map_options_lobby_widgets, next_seed);
Expand Down
7 changes: 3 additions & 4 deletions src/newui/menu_lobby.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

enum MapOptions {
MAP_OPTIONS_WIDGET_SEED_RANDOM = 20,
MAP_OPTIONS_WIDGET_LOSE_CONDITION_STRUCTURES = 50,
MAP_OPTIONS_STARTING_CREDITS_MIN = 1000,
MAP_OPTIONS_STARTING_CREDITS_MAX = 10000,
MAP_OPTIONS_SPICE_MIN = 0,
Expand All @@ -17,11 +18,9 @@ enum MapOptions {
MAP_OPTIONS_GUI_MAP_X = 126,
MAP_OPTIONS_GUI_MAP_Y = MAP_OPTIONS_GUI_MAIN_Y,
MAP_OPTIONS_GUI_MAP_W = 183,
MAP_OPTIONS_GUI_MAP_H = 74,
MAP_OPTIONS_GUI_MAP_H = 90,
MAP_OPTIONS_GUI_ERROR_X = 126,
MAP_OPTIONS_GUI_ERROR_Y = 164,
MAP_OPTIONS_GUI_ERROR_W = 183,
MAP_OPTIONS_GUI_ERROR_H = 9
MAP_OPTIONS_GUI_ERROR_Y = 164
};

extern void Lobby_InitWidgets(void);
Expand Down
13 changes: 12 additions & 1 deletion src/opendune.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,22 @@ GameLoop_Server_IsHouseFinished(enum HouseType houseID)

if (g_campaign_selected == CAMPAIGNID_SKIRMISH
|| g_campaign_selected == CAMPAIGNID_MULTIPLAYER) {
for (const Unit *u = Unit_FindFirst(&find, HOUSE_INVALID, UNIT_MCV);

// If lose condition is set to structures,
// we only search for MCVs to determine, if house is still alive.
// It it is set to units, we search for all units,
// and filter out non-ground-units in the loop.
uint8 findUnitType = g_multiplayer.lose_condition == MAP_LOSE_CONDITION_STRUCTURES ? UNIT_MCV : 0xFFFF;

for (const Unit *u = Unit_FindFirst(&find, HOUSE_INVALID, findUnitType);
u != NULL;
u = Unit_FindNext(&find)) {
if (foundFriendly && foundEnemy)
break;

// Only ground units count for lose condition.
if (u->o.type < UNIT_INFANTRY || u->o.type > UNIT_MCV)
continue;

const enum HouseType h2 = Unit_GetHouseID(u);
if (g_campaign_selected == CAMPAIGNID_MULTIPLAYER
Expand Down

0 comments on commit b6ef892

Please sign in to comment.