Skip to content

Commit

Permalink
Corrected a regression.
Browse files Browse the repository at this point in the history
  • Loading branch information
klei1984 committed Oct 31, 2023
1 parent 17445df commit b068279
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
4 changes: 1 addition & 3 deletions src/complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ void Complex::GetCargoMinable(Cargo& capacity) {
it != UnitsManager_StationaryUnits.End(); ++it) {
if ((*it).GetComplex() == this && (*it).orders != ORDER_POWER_OFF && (*it).orders != ORDER_DISABLE &&
(*it).orders != ORDER_IDLE) {
Cargo cargo;

Cargo_GetNetProduction(&*it, &cargo);
Cargo cargo = Cargo_GetNetProduction(it->Get());

if ((*it).unit_type == MININGST) {
cargo.gold -= (*it).gold_mining;
Expand Down
8 changes: 4 additions & 4 deletions src/game_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7271,7 +7271,7 @@ void GameManager_DrawInfoDisplayType2(UnitInfo* unit) {
current_value = 0;
base_value = 0;

Cargo_GetNetProduction(unit, &cargo);
cargo = Cargo_GetNetProduction(unit);

current_power_need = cargo.power;

Expand Down Expand Up @@ -7303,7 +7303,7 @@ void GameManager_DrawInfoDisplayType2(UnitInfo* unit) {
std::swap((*it).orders, (*it).prior_orders);
}

Cargo_GetNetProduction(&(*it), &cargo);
cargo = Cargo_GetNetProduction(it->Get());

if (upgrade_all) {
std::swap((*it).orders, (*it).prior_orders);
Expand Down Expand Up @@ -7342,7 +7342,7 @@ void GameManager_DrawInfoDisplayType1(UnitInfo* unit) {
current_value = 0;
base_value = 0;

Cargo_GetNetProduction(unit, &cargo);
cargo = Cargo_GetNetProduction(unit);

current_life_need = cargo.life;

Expand Down Expand Up @@ -7374,7 +7374,7 @@ void GameManager_DrawInfoDisplayType1(UnitInfo* unit) {
std::swap((*it).orders, (*it).prior_orders);
}

Cargo_GetNetProduction(&(*it), &cargo);
cargo = Cargo_GetNetProduction(it->Get());

if (upgrade_all) {
std::swap((*it).orders, (*it).prior_orders);
Expand Down
26 changes: 14 additions & 12 deletions src/reportstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ struct InterfaceMeta {
};

static void ReportStats_RenderSprite(struct InterfaceMeta* data);
static void ReportStats_DrawIcons(WindowInfo* window, ResourceID icon_normal, ResourceID icon_empty, int32_t current_value,
int32_t base_value);
static void ReportStats_DrawIcons(WindowInfo* window, ResourceID icon_normal, ResourceID icon_empty,
int32_t current_value, int32_t base_value);
static void ReportStats_DrawRowEx(const char* text, WinID id, Rect* bounds, int32_t row_id, ResourceID icon_normal,
ResourceID icon_empty, int32_t current_value, int32_t base_value, int32_t factor, bool drawline);
ResourceID icon_empty, int32_t current_value, int32_t base_value, int32_t factor,
bool drawline);
static void ReportStats_DrawCommonUnit(UnitInfo* unit, WinID id, Rect* bounds);
static void ReportStats_DrawStorageUnit(UnitInfo* unit, WinID id, Rect* bounds);
static void ReportStats_DrawPointsUnit(UnitInfo* unit, WinID id, Rect* bounds);
Expand Down Expand Up @@ -82,8 +83,8 @@ void ReportStats_RenderSprite(struct InterfaceMeta* data) {
ResourceManager_Realloc(data->icon, Gfx_ResourceBuffer, data_size);
}

image_frame = &Gfx_ResourceBuffer[reinterpret_cast<uint32_t*>(
&Gfx_ResourceBuffer[sizeof(uint16_t)])[data->frame_index]];
image_frame =
&Gfx_ResourceBuffer[reinterpret_cast<uint32_t*>(&Gfx_ResourceBuffer[sizeof(uint16_t)])[data->frame_index]];

map_scaling_factor = Gfx_MapScalingFactor;
map_window_ulx = Gfx_MapWindowUlx;
Expand Down Expand Up @@ -194,7 +195,8 @@ void ReportStats_DrawIcons(WindowInfo* window, ResourceID icon_normal, ResourceI
}

void ReportStats_DrawRowEx(const char* text, WinID id, Rect* bounds, int32_t row_id, ResourceID icon_normal,
ResourceID icon_empty, int32_t current_value, int32_t base_value, int32_t factor, bool drawline) {
ResourceID icon_empty, int32_t current_value, int32_t base_value, int32_t factor,
bool drawline) {
Rect new_bounds;
int32_t height;

Expand Down Expand Up @@ -320,8 +322,8 @@ void ReportStats_DrawListItemIcon(uint8_t* buffer, int32_t width, ResourceID uni
}
}

void ReportStats_DrawListItem(uint8_t* buffer, int32_t width, ResourceID unit_type, int32_t ulx, int32_t uly, int32_t full,
int32_t color) {
void ReportStats_DrawListItem(uint8_t* buffer, int32_t width, ResourceID unit_type, int32_t ulx, int32_t uly,
int32_t full, int32_t color) {
ReportStats_DrawListItemIcon(buffer, width, unit_type, GameManager_PlayerTeam, ulx + 16, uly + 16);
Text_TextBox(buffer, width, UnitsManager_BaseUnits[unit_type].singular_name, ulx + 35, uly, full - 35, 32, color,
false);
Expand Down Expand Up @@ -361,7 +363,7 @@ void ReportStats_DrawCommonUnit(UnitInfo* unit, WinID id, Rect* bounds) {
current_value = 0;
base_value = 0;

Cargo_GetNetProduction(unit, &cargo);
cargo = Cargo_GetNetProduction(unit);
power_consumption_current = cargo.power;

if (power_consumption_base >= 0) {
Expand All @@ -386,7 +388,7 @@ void ReportStats_DrawCommonUnit(UnitInfo* unit, WinID id, Rect* bounds) {
power_consumption_base -= cargo.power;
}

Cargo_GetNetProduction(&*it, &cargo);
cargo = Cargo_GetNetProduction(it->Get());

if (cargo.power >= 0) {
power_consumption_current += cargo.power;
Expand Down Expand Up @@ -420,7 +422,7 @@ void ReportStats_DrawStorageUnit(UnitInfo* unit, WinID id, Rect* bounds) {
current_value = 0;
base_value = 0;

Cargo_GetNetProduction(unit, &cargo);
cargo = Cargo_GetNetProduction(unit);

current_life_need = cargo.life;

Expand All @@ -445,7 +447,7 @@ void ReportStats_DrawStorageUnit(UnitInfo* unit, WinID id, Rect* bounds) {
life_need -= cargo.life;
}

Cargo_GetNetProduction(&*it, &cargo);
cargo = Cargo_GetNetProduction(it->Get());

if (cargo.life >= 0) {
current_life_need += cargo.life;
Expand Down
5 changes: 3 additions & 2 deletions src/winloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ int32_t WinLoss_CountReadyUnits(uint16_t team, ResourceID unit_type) {
return result;
}

void WinLoss_CountTotalMining(uint16_t team, int32_t* raw_mining_max, int32_t* fuel_mining_max, int32_t* gold_mining_max) {
void WinLoss_CountTotalMining(uint16_t team, int32_t* raw_mining_max, int32_t* fuel_mining_max,
int32_t* gold_mining_max) {
raw_mining_max[0] = 0;
fuel_mining_max[0] = 0;
gold_mining_max[0] = 0;
Expand Down Expand Up @@ -389,7 +390,7 @@ int32_t WinLoss_GetTotalConsumption(uint16_t team, uint8_t cargo_type) {
for (SmartList<UnitInfo>::Iterator it = UnitsManager_StationaryUnits.Begin();
it != UnitsManager_StationaryUnits.End(); ++it) {
if ((*it).team == team) {
Cargo_GetNetProduction(&*it, &cargo);
cargo = Cargo_GetNetProduction(it->Get());

switch (cargo_type) {
case CARGO_MATERIALS: {
Expand Down

0 comments on commit b068279

Please sign in to comment.