Skip to content

Commit

Permalink
Merged in FluffyQuack/cncremastered (pull request #2)
Browse files Browse the repository at this point in the history
Support for WallsAlwaysHaveFullCost for RA2/TS-style wall building
  • Loading branch information
FluffyQuack authored and cfehunter committed Jun 15, 2020
2 parents 201b2ff + fcc2437 commit 5e31323
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1,240 deletions.
1 change: 1 addition & 0 deletions Mod Data/CCDATA/DEFAULT.CFEPATCH.INI
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ QUEUE_JUMP_CUTOFF=3
TIB_GROWTH_SCALE=1
WALL_BUILD_LENGTH=5
BUILDING_GAP_OFFSET=0
WALLS_HAVE_FULL_COST=1
11 changes: 11 additions & 0 deletions TIBERIANDAWN/BUILDING.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,20 @@ bool BuildingClass::Unlimbo_Wall(COORDINATE coord)
{
adjcell = Adjacent_Cell(adjcell, dir);

//FluffyQuack 14/06/2020: If WallsAlwaysHaveFullCost is true then we charge the player for each extra piece. Abort with "insufficient funds" if player can't afford it
if (ActiveCFEPatchConfig.WallsAlwaysHaveFullCost && House->Available_Money() < Class->Cost_Of())
{
Speak(VOX_NO_CASH);
break;
}

//If we fail to create the overlay here, abort this direction and move on
if (!Create_Overlay_At(oclass, adjcell))
break;

//Pay the cost of this extra wall
if (ActiveCFEPatchConfig.WallsAlwaysHaveFullCost)
House->Spend_Money(Class->Cost_Of());
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion TIBERIANDAWN/CFEUTIL.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ void Populate_CFE_Patch_Config_From_INI(const INIClass& ini)
GetSetting(ActiveCFEPatchConfig.EnableRepairQueue , "FEATURES", "REPAIR_QUEUE");
GetSetting(ActiveCFEPatchConfig.EnableHarvySelfRepair , "FEATURES", "HARVY_SELF_REPAIR");
GetSetting(ActiveCFEPatchConfig.DisableCommandoAirstrikes , "FEATURES", "DISABLE_COMMANDO_AIRSTRIKES");

//Settings
GetSetting(ActiveCFEPatchConfig.BuildingGap , "SETTINGS", "BUILDING_GAP");
GetSetting(ActiveCFEPatchConfig.HarvyQueueJumpCutoff , "SETTINGS", "QUEUE_JUMP_CUTOFF");
GetSetting(ActiveCFEPatchConfig.TibGrowthScale , "SETTINGS", "TIB_GROWTH_SCALE");
GetSetting(ActiveCFEPatchConfig.WallBuildLength , "SETTINGS", "WALL_BUILD_LENGTH");
GetSetting(ActiveCFEPatchConfig.WallsAlwaysHaveFullCost , "SETTINGS", "WALLS_HAVE_FULL_COST");

//Clamp Wall Length between 1 (build at all) and 10 (buffer limits)
ActiveCFEPatchConfig.WallBuildLength = (std::max)(1, (std::min)(ActiveCFEPatchConfig.WallBuildLength, 10));
Expand Down
1 change: 1 addition & 0 deletions TIBERIANDAWN/EXTERNS.H
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct CFEPatchConfig
int HarvyQueueJumpCutoff = 3;
int TibGrowthScale = 1;
int WallBuildLength = 5;
bool WallsAlwaysHaveFullCost = true;
};

extern CFEPatchConfig ActiveCFEPatchConfig;
Expand Down
3 changes: 2 additions & 1 deletion TIBERIANDAWN/HOUSE.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -4734,7 +4734,8 @@ void HouseClass::Sell_Wall(CELL cell)
}

//Disable wall refunds if the player has a wall build length > 1
if (!IsHuman || ActiveCFEPatchConfig.WallBuildLength <= 1)
//FluffyQuack 14/06/2020: Always allow refunds if walls have full cost
if (!IsHuman || ActiveCFEPatchConfig.WallBuildLength <= 1 || ActiveCFEPatchConfig.WallsAlwaysHaveFullCost)
Refund_Money(btype->Cost_Of() / 2);

Map[cell].Overlay = OVERLAY_NONE;
Expand Down
Loading

0 comments on commit 5e31323

Please sign in to comment.