Skip to content

Commit

Permalink
Reimplemented quick build menu debug feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
klei1984 committed Jul 9, 2024
1 parent 9f8db49 commit 6bab091
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ bool Access_IsChildOfUnitInList(UnitInfo* unit, SmartList<UnitInfo>* list, Smart
return *it != list->End();
}

UnitInfo* Access_GetUnit5(int32_t grid_x, int32_t grid_y) {
UnitInfo* Access_GetQuickBuilderUnit(int32_t grid_x, int32_t grid_y) {
UnitInfo* unit;

unit = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void Access_UpdateResourcesTotal(Complex *complex);
void Access_DestroyUtilities(int32_t grid_x, int32_t grid_y, bool remove_slabs, bool remove_rubble, bool remove_connectors,
bool remove_road);
void Access_DestroyGroundCovers(int32_t grid_x, int32_t grid_y);
UnitInfo *Access_GetUnit5(int32_t grid_x, int32_t grid_y);
UnitInfo *Access_GetQuickBuilderUnit(int32_t grid_x, int32_t grid_y);
UnitInfo *Access_GetUnit3(int32_t grid_x, int32_t grid_y, uint32_t flags);
UnitInfo *Access_GetUnit1(int32_t grid_x, int32_t grid_y);
UnitInfo *Access_GetUnit2(int32_t grid_x, int32_t grid_y, uint16_t team);
Expand Down
256 changes: 236 additions & 20 deletions src/game_manager.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/game_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extern bool GameManager_DisplayControlsInitialized;
extern bool GameManager_RenderMinimapDisplay;
extern bool GameManager_PlayFlic;
extern bool GameManager_MaxSurvey;
extern bool GameManager_UnknownFlag3;
extern bool GameManager_QuickBuildMenuActive;
extern bool GameManager_IsMainMenuEnabled;
extern bool GameManager_WrapUpGame;
extern Button* Gamemanager_FlicButton;
Expand Down
2 changes: 1 addition & 1 deletion src/gnw.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ void win_set_bk_color(int32_t color) {
}
}

void win_print(WinID id, char *str, int32_t field_width, int32_t x, int32_t y, int32_t color) {
void win_print(WinID id, const char *str, int32_t field_width, int32_t x, int32_t y, int32_t color) {
GNW_Window *w;
uint8_t *buf;

Expand Down
2 changes: 1 addition & 1 deletion src/gnw.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void win_delete(WinID id);
void win_buffering(int32_t state);
void win_border(WinID id);
void win_set_bk_color(int32_t color);
void win_print(WinID id, char* str, int32_t field_width, int32_t x, int32_t y, int32_t color);
void win_print(WinID id, const char* str, int32_t field_width, int32_t x, int32_t y, int32_t color);
void win_text(WinID id, char** list, int32_t num, int32_t field_width, int32_t x, int32_t y, int32_t color);
void win_line(WinID id, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t color);
void win_box(WinID id, int32_t ulx, int32_t uly, int32_t lrx, int32_t lry, int32_t color);
Expand Down
6 changes: 3 additions & 3 deletions src/remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,13 +1844,13 @@ void Remote_ReceiveNetPacket_14(NetPacket& packet) {
packet >> grid_x;
packet >> grid_y;

bool state_backup = GameManager_UnknownFlag3;
bool state_backup = GameManager_QuickBuildMenuActive;

GameManager_UnknownFlag3 = true;
GameManager_QuickBuildMenuActive = true;

GameManager_DeployUnit(entity_id, unit_type, grid_x, grid_y);

GameManager_UnknownFlag3 = state_backup;
GameManager_QuickBuildMenuActive = state_backup;
}

void Remote_SendNetPacket_16(const char* file_name, const char* file_title) {
Expand Down
4 changes: 1 addition & 3 deletions src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,12 +765,10 @@ int32_t ResourceManager_InitResManager() {
uint8_t *ResourceManager_ReadResource(ResourceID id) {
uint8_t *resource_buffer;

SDL_assert(id < RESOURCE_E);

if (id == INVALID_ID) {
resource_buffer = nullptr;
} else {
SDL_assert(id > MEM_END);
SDL_assert(id > MEM_END && id < RESOURCE_E);

if (ResourceManager_ResMetaTable[id].res_file_item_index == INVALID_ID) {
resource_buffer = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/units_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4126,7 +4126,7 @@ SmartPointer<UnitInfo> UnitsManager_DeployUnit(ResourceID unit_type, uint16_t te
}
}

if (GameManager_GameState != GAME_STATE_12 && !GameManager_UnknownFlag3 && !is_existing_unit) {
if (GameManager_GameState != GAME_STATE_12 && !GameManager_QuickBuildMenuActive && !is_existing_unit) {
unit->storage = 0;
}

Expand Down Expand Up @@ -5636,7 +5636,7 @@ void UnitsManager_BuildClearing(UnitInfo* unit, bool mode) {
}

if ((unit_flags & (BUILDING | STANDALONE)) || unit_orders == ORDER_BUILD || unit_orders == ORDER_CLEAR) {
if (unit_type == CONSTRCT && unit_orders == ORDER_BUILD) {
if (unit_type == CONSTRCT && unit_orders == ORDER_BUILD && rubble_type == SMLRUBLE) {
SmartPointer<UnitInfo> utility_unit(Access_GetConstructionUtility(unit_team, unit_grid_x, unit_grid_y));

unit_grid_x = utility_unit->grid_x;
Expand Down

0 comments on commit 6bab091

Please sign in to comment.