Skip to content

Commit

Permalink
Add Single Level Debug Repair Option
Browse files Browse the repository at this point in the history
  • Loading branch information
kgd192 committed Jan 13, 2024
1 parent 6712498 commit 4649adb
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 48 deletions.
48 changes: 27 additions & 21 deletions data/forms/city/debugoverlay_city.form
Original file line number Diff line number Diff line change
Expand Up @@ -41,128 +41,134 @@
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="B" text="B = Spawn UFO on Assualt Mission">
<label id="ShiftR" text="Shift+R = Repair Scenery (Single Story Mode)">
<position x="left" y="84"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="U" text="U = Spawn Three Crashed UFOs">
<label id="B" text="B = Spawn UFO on Assualt Mission">
<position x="left" y="98"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="X" text="X = Crash All Vehicles">
<label id="U" text="U = Spawn Three Crashed UFOs">
<position x="left" y="112"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="PgUpPgDn" text="PgUp / PgDown = Display One Map Layer">
<label id="X" text="X = Crash All Vehicles">
<position x="left" y="126"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F2" text="F2 = Show Road Pathfinding">
<label id="PgUpPgDn" text="PgUp / PgDown = Display One Map Layer">
<position x="left" y="140"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F3" text="F3 = Highlight Walkmode, Collapsing Tiles, Basement Tiles">
<label id="F2" text="F2 = Show Road Pathfinding">
<position x="left" y="154"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F3" text="F3 = Highlight Walkmode, Collapsing Tiles, Basement Tiles">
<position x="left" y="168"/>
<size width="400" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F4" text="F4 = Show Aliens on Strategy Map">
<position x="left" y="168"/>
<position x="left" y="182"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F5" text="F5 = Show Vehicles Paths">
<position x="left" y="182"/>
<position x="left" y="196"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F6" text="F6 = Dump Voxelmap LOS">
<position x="left" y="196"/>
<position x="left" y="210"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F7" text="F7 = Dump Voxelmap LOS (Fast)">
<position x="left" y="210"/>
<position x="left" y="224"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F8" text="F8 = Dump Voxelmap LOF">
<position x="left" y="224"/>
<position x="left" y="238"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F9" text="F9 = Dump Voxelmap LOF (Fast)">
<position x="left" y="238"/>
<position x="left" y="252"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F10" text="F10 = Highlight Tubes">
<position x="left" y="252"/>
<position x="left" y="266"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F11" text="F11 = Highlight Roads">
<position x="left" y="266"/>
<position x="left" y="280"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F12" text="F12 = Highlight Hills">
<position x="left" y="280"/>
<position x="left" y="294"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Num" text="Show Roads / Tubes Num1379 = Direction, Num28 = Up / Down, Num0 = Show All, Num5 = Switch Views">
<position x="left" y="294"/>
<position x="left" y="308"/>
<size width="640" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="VClick" text="V+LeftClick = Fix Stuck Vehicle in CityScape (Deprecated)">
<position x="left" y="308"/>
<position x="left" y="322"/>
<size width="350" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="P" text="P = Show Vehicle Targets">
<position x="left" y="322"/>
<position x="left" y="336"/>
<size width="350" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="MINUS" text="MINUS = Clear Space Liners (If game is running slowly)">
<position x="left" y="336"/>
<position x="left" y="350"/>
<size width="350" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Base" text="Base Screen - F10 = Finish All Facilities">
<position x="left" y="350"/>
<position x="left" y="364"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Research" text="Research Screen - F10 = Complete Project at Next Update (With at least two Scientists Assigned)">
<position x="left" y="364"/>
<position x="left" y="378"/>
<size width="640" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
Expand Down
27 changes: 14 additions & 13 deletions game/state/city/city.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void City::updateInfiltration(GameState &state)
}
}

void City::repairScenery(GameState &state)
void City::repairScenery(GameState &state, bool debugRepair)
{
// Step 01: Repair damaged scenery one by one
std::list<sp<Scenery>> sceneryToUndamage;
Expand Down Expand Up @@ -427,10 +427,10 @@ void City::repairScenery(GameState &state)

std::set<sp<OpenApoc::Vehicle>> constructionVehicles = findConstructionVehicles(state);

while (!constructionVehicles.empty())
while (!constructionVehicles.empty() || debugRepair)
{
// Step 02: Repair destroyed scenery
LogWarning("Repair Cycle starting");
LogInfo("Repair Cycle starting");
std::set<sp<Scenery>> sceneryToRepair;
for (auto &s : scenery)
{
Expand All @@ -454,12 +454,12 @@ void City::repairScenery(GameState &state)
std::string pos = std::to_string(nextScenery->initialPosition.x) + ", " +
std::to_string(nextScenery->initialPosition.y) + ", " +
std::to_string(nextScenery->initialPosition.z);
LogWarning("Currently Processing Tile: " + pos);
LogInfo("Currently Processing Tile: " + pos);

if (nextScenery->supportedBy.empty())
{
LogWarning("Tile at " + pos +
" is has no support requirement, adding to repair queue");
LogInfo("Tile at " + pos +
" is has no support requirement, adding to repair queue");
repairQueue.push(nextScenery);
}
else
Expand All @@ -470,12 +470,11 @@ void City::repairScenery(GameState &state)

if (!support || !support->isAlive())
{
LogWarning("Tile at " + pos +
" has no support due to destroyed tile below");
LogInfo("Tile at " + pos + " has no support due to destroyed tile below");
}
else
{
LogWarning("Tile at " + pos + " has support below, adding to repair queue");
LogInfo("Tile at " + pos + " has support below, adding to repair queue");
repairQueue.push(nextScenery);
}
}
Expand Down Expand Up @@ -519,7 +518,7 @@ void City::repairScenery(GameState &state)
// check if sufficient funds are available, the tile is still dead and a construction
// vehicle is available
if (buildingOwner->balance < initialType->value || s->isAlive() ||
currentVehicle == NULL)
(currentVehicle == NULL && !debugRepair))
{
repairQueue.pop();
continue;
Expand All @@ -533,15 +532,15 @@ void City::repairScenery(GameState &state)
// delete out of list to prevent repairing again
repairQueue.pop();
tilesRepaired++;
if (currentVehicle->tilesRepaired++ >
config().getInt("OpenApoc.NewFeature.MaxTileRepair"))
if (currentVehicle && currentVehicle->tilesRepaired++ >
config().getInt("OpenApoc.NewFeature.MaxTileRepair"))
{
constructionVehicles.erase(currentVehicle);
}
}
}
// No Tiles repaired in last iteration due to no funds or vehicle match
if (tilesRepaired <= 0)
if (tilesRepaired <= 0 || debugRepair)
{
break;
}
Expand All @@ -553,6 +552,8 @@ void City::repairScenery(GameState &state)
{
v->tilesRepaired = 0;
}

LogInfo("Repair Cycle Complete");
}

std::set<sp<OpenApoc::Vehicle>> City::findConstructionVehicles(GameState &state)
Expand Down
2 changes: 1 addition & 1 deletion game/state/city/city.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class City : public StateObject<City>, public std::enable_shared_from_this<City>
void generatePortals(GameState &state);
void updateInfiltration(GameState &state);
void repairVehicles(GameState &state);
void repairScenery(GameState &state);
void repairScenery(GameState &state, bool debugRepair = false);
std::set<sp<OpenApoc::Vehicle>> findConstructionVehicles(GameState &state);

void initialSceneryLinkUp();
Expand Down
35 changes: 22 additions & 13 deletions game/ui/tileview/cityview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3444,24 +3444,33 @@ bool CityView::handleKeyDown(Event *e)
{
case SDLK_r:
{
LogInfo("Repairing...");
std::set<sp<Scenery>> stuffToRepair;
for (auto &s : state->current_city->scenery)
if (modifierLShift)
{
if (s->damaged || !s->isAlive())
LogInfo("Single Level Debug Repair");
state->current_city->repairScenery(*state, true);
return true;
}
else
{
LogInfo("Debug Repair");
std::set<sp<Scenery>> stuffToRepair;
for (auto &s : state->current_city->scenery)
{
stuffToRepair.insert(s);
if (s->damaged || !s->isAlive())
{
stuffToRepair.insert(s);
}
}
}
LogInfo("Repairing %u tiles out of %u",
static_cast<unsigned>(stuffToRepair.size()),
static_cast<unsigned>(state->current_city->scenery.size()));
LogInfo("Repairing %u tiles out of %u",
static_cast<unsigned>(stuffToRepair.size()),
static_cast<unsigned>(state->current_city->scenery.size()));

for (auto &s : stuffToRepair)
{
s->repair(*state);
for (auto &s : stuffToRepair)
{
s->repair(*state);
}
return true;
}
return true;
}
case SDLK_x:
{
Expand Down

0 comments on commit 4649adb

Please sign in to comment.