Skip to content

Commit

Permalink
Extend BaseUnit to accept more than one entry, use all values from Bu…
Browse files Browse the repository at this point in the history
…ildConst, BuildRefinery, BuildFactory (#1073)

Co-authored-by: CCHyper <[email protected]>
  • Loading branch information
ZivDero and CCHyper committed Oct 27, 2024
1 parent 8801f91 commit fd7bdd0
Show file tree
Hide file tree
Showing 13 changed files with 1,204 additions and 135 deletions.
3 changes: 3 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ This page lists all the individual contributions to the project by their author.
- Implement various controls to customise target lasers line.
- Implement various controls to show and customise NavCom queue lines.
- Implement customizable mouse cursors and actions.
- Extend `BaseUnit` to accept a list of vehicles.
- **CnCNet Contributors**:
- Tiberian Sun TS-patches spawner, Yuri's Revenge CnCNet spawner that served as a base for Vinifera spawner.
- **Kerbiter (Metadorius)**:
Expand Down Expand Up @@ -204,4 +205,6 @@ This page lists all the individual contributions to the project by their author.
- Implement support for a Saved Games subdirectory.
- Fix a bug where if the player loaded a saved game, the score screen timer would report the time since the saved game was loaded, instead of since when the scenario was first started.
- Implement the multiplayer spawner.
- Extend `BaseUnit` to accept a list of vehicles.
- Allow `BuildConst`, `BuildRefinery`, `BuildWeapons` and `HarvesterUnit` to properly have multiple entries.

2 changes: 2 additions & 0 deletions docs/Miscellaneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ This page describes every change in Vinifera that wasn't categorized into a prop
- Harvesters used to drop their cargo as Tiberium Riparius on death. They will now drop the Tiberium types they are carrying, instead.
- It is no longer required to list all Tiberiums in a map to override some Tiberium's properties.
- It was possible to make a building get built at a different speed than its cost implied by giving the building a `FreeUnit` or `PadAircraft` that was more expensive than the building itself. This functionality has been removed in preference of `BuildTimeCost`.
- BaseUnit now accepts a list units. Players will be granted the first unit in the list that has their house listed under `Owners=`.
- The AI now correctly considers all entries of `BuildConst`, `BuildRefinery`, `BuildWeapons` and `HarvesterUnit`.

## Spawner

Expand Down
2 changes: 2 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ New:
- Implement support for a Saved Games subdirectory (by ZivDero)

- Implemented the multiplayer spawner (by ZivDero)
- Extend `BaseUnit` to accept a list of vehicles (by ZivDero/CCHyper)
- Allow `BuildConst`, `BuildRefinery`, `BuildWeapons` and `HarvesterUnit` to properly have multiple entries (by ZivDero)

Vanilla fixes:
- Fix HouseType `Nod` having the `Prefix=B` and `Side=GDI` in vanilla `rules.ini` by setting them to `N` and `Nod`, respectively (by CCHyper/tomsons26)
Expand Down
93 changes: 88 additions & 5 deletions src/extensions/building/buildingext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

#include "hooker.h"
#include "hooker_macros.h"
#include "rulesext.h"
#include "spawner.h"


Expand Down Expand Up @@ -273,7 +274,8 @@ int BuildingClassExt::_Shape_Number() const
shapenum += largest;
}
}
}

return shapenum;
}


Expand Down Expand Up @@ -332,7 +334,7 @@ void BuildingClassExt::_Draw_Overlays(Point2D& coord, Rect& rect)
if (House->Is_Ally(PlayerPtr) || SpiedBy & (1 << (PlayerPtr->Class->House)) || (Spawner::Active && Spawner::Get_Config()->Houses[PlayerPtr->Get_Heap_ID()].IsSpectator))
{
Point2D xy(coord.X - 10, coord.Y + 10);
entry_338(xy, coord, rect);
Draw_Text_Overlay(xy, coord, rect);
}

/**
Expand Down Expand Up @@ -386,9 +388,6 @@ void BuildingClassExt::_Draw_Overlays(Point2D& coord, Rect& rect)
}
}

return shapenum;
}


/**
* #issue-204
Expand Down Expand Up @@ -1109,6 +1108,86 @@ DECLARE_PATCH(_BuildingClass_Grand_Opening_Assign_FreeUnit_LastDockedBuilding_Pa
}


/**
* #issue-177
*
* Patches the check for if a building is a Construction Yard to check the entire BuildConst list.
*
* @author: ZivDero
*/
DECLARE_PATCH(_BuildingClass_Unlimbo_BuildConst_Patch)
{
GET_REGISTER_STATIC(BuildingClass*, this_ptr, esi);

if (Rule->BuildConst.Is_Present(this_ptr->Class))
{
JMP(0x0042AA8B);
}

JMP(0x0042AACF);
}


/**
* #issue-177
*
* Patches the check for if a building is a Construction Yard to check the entire BuildConst list.
*
* @author: ZivDero
*/
DECLARE_PATCH(_BuildingClass_Captured_BuildConst_Patch1)
{
GET_REGISTER_STATIC(BuildingTypeClass*, buildingtype, ecx);

if (Rule->BuildConst.Is_Present(buildingtype))
{
JMP(0x0042F968);
}

JMP(0x0042F9A2);
}


/**
* #issue-177
*
* Patches the check for if you have a Construction Yard to check the entire BuildConst list.
*
* @author: ZivDero
*/
DECLARE_PATCH(_BuildingClass_Captured_BuildConst_Patch2)
{
GET_REGISTER_STATIC(HouseClass*, house, ebx);

if (house->Count_Owned(Rule->BuildConst))
{
JMP(0x0042FAEF);
}

JMP(0x0042FB10);
}


/**
* #issue-177
*
* Patches the check for if a building is a Construction Yard to check the entire BuildConst list.
*
* @author: ZivDero
*/
DECLARE_PATCH(_BuildingClass_Captured_BuildConst_Patch3)
{
GET_REGISTER_STATIC(BuildingClass*, this_ptr, esi);

if (Rule->BuildConst.Is_Present(this_ptr->Class))
{
JMP(0x0042FCB6);
}

JMP(0x0042FCF8);
}


/**
* Main function for patching the hooks.
*/
Expand Down Expand Up @@ -1143,4 +1222,8 @@ void BuildingClassExtension_Hooks()
Patch_Jump(0x0042E5F5, &_BuildingClass_Grand_Opening_Assign_FreeUnit_LastDockedBuilding_Patch);
//Patch_Jump(0x00429220, &BuildingClassExt::_Shape_Number); // It's identical to vanilla, leaving it in in case it's ever needed
Patch_Jump(0x00428810, &BuildingClassExt::_Draw_Overlays);
Patch_Jump(0x0042AA76, &_BuildingClass_Unlimbo_BuildConst_Patch);
Patch_Jump(0x0042F958, &_BuildingClass_Captured_BuildConst_Patch1);
Patch_Jump(0x0042FACC, &_BuildingClass_Captured_BuildConst_Patch2);
Patch_Jump(0x0042FCA1, &_BuildingClass_Captured_BuildConst_Patch3);
}
Loading

0 comments on commit fd7bdd0

Please sign in to comment.