Skip to content

Commit

Permalink
Merge v0.3.0.1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Jul 24, 2023
1 parent c3919ca commit 4a2c374
Show file tree
Hide file tree
Showing 54 changed files with 1,202 additions and 286 deletions.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ This page lists all the individual contributions to the project by their author.
- Exploding unit passenger killing customization
- Railgun particle target coordinate fix
- Building target coordinate offset fix
- Additional sync logging
- **Morton (MortonPL)**:
- `XDrawOffset`
- Shield passthrough & absorption
Expand Down
4 changes: 3 additions & 1 deletion Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
<ClCompile Include="src\Utilities\Constructs.cpp" />
<ClCompile Include="src\Utilities\EnumFunctions.cpp" />
<ClCompile Include="src\Utilities\GeneralUtils.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.VehicleToBuildingMCFix.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.DeploysInto.cpp" />
<ClCompile Include="src\Misc\SyncLogging.cpp" />
<ClCompile Include="YRpp\StaticInits.cpp" />
<ClCompile Include="src\Utilities\Patch.cpp" />
</ItemGroup>
Expand All @@ -149,6 +150,7 @@
<ClInclude Include="src\Misc\CaptureManager.h" />
<ClInclude Include="src\Misc\FlyingStrings.h" />
<ClInclude Include="src\Misc\PhobosToolTip.h" />
<ClInclude Include="src\Misc\SyncLogging.h" />
<ClInclude Include="src\New\Entity\ShieldClass.h" />
<ClInclude Include="src\New\Type\RadTypeClass.h" />
<ClInclude Include="src\New\Type\ShieldTypeClass.h" />
Expand Down
2 changes: 1 addition & 1 deletion YRpp
Submodule YRpp updated 168 files
4 changes: 2 additions & 2 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
![Waving trees](_static/images/tree-shake.gif)
*Animated trees used in [Ion Shock](https://www.moddb.com/mods/tiberian-war-ionshock)*

- `IsAnimated`, `AnimationRate` and `AnimationProbability` now work on TerrainTypes without `SpawnsTiberium` set to true.
- `IsAnimated`, `AnimationRate` and `AnimationProbability` now work on TerrainTypes without `SpawnsTiberium` set to true. Note that this might impact performance.
- Fixed transports recursively put into each other not having a correct killer set after second transport when being killed by something.

![image](_static/images/translucency-fix.png)
Expand All @@ -94,7 +94,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho

- `Weapon` can be set to a WeaponType, to create a projectile and immediately detonate it instead of simply dealing `Damage` by `Warhead`. This allows weapon effects to be applied.
- `Damage.Delay` determines delay between two applications of `Damage`. Requires `Damage` to be set to 1.0 or above. Value of 0 disables the delay. Keep in mind that this is measured in animation frames, not game frames. Depending on `Rate`, animation may or may not advance animation frames on every game frame.
- `Damage.DealtByInvoker`, if set to true, makes any `Damage` dealt to be considered as coming from the animation's invoker (f.ex, firer of the weapon if it is Warhead `AnimList/SplashList` animation, the destroyed vehicle if it is `DestroyAnim` animation or the object the animation is attached to). Does not affect which house the `Damage` dealt by `Warhead` is dealt by.
- `Damage.DealtByInvoker`, if set to true, makes any `Damage` dealt to be considered as coming from the animation's invoker (f.ex, firer of the weapon if it is Warhead `AnimList/SplashList` animation, the destroyed vehicle if it is `DestroyAnim` animation or the object the animation is attached to). If invoker has died or does not exist, the house the invoker belonged to is still used to deal damage and apply Phobos-introduced Warhead effects. Does not affect which house the `Damage` dealt by `Warhead` is dealt by.
- `Damage.ApplyOncePerLoop`, if set to true, makes `Damage` be dealt only once per animation loop (on single loop animations, only once, period) instead of on every frame or intervals defined by `Damage.Delay`. The frame on which it is dealt is determined by `Damage.Delay`, defaulting to after the first animation frame.

In `artmd.ini`:
Expand Down
2 changes: 2 additions & 0 deletions docs/Miscellanous.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This page describes every change in Phobos that wasn't categorized into a proper category yet.

- Phobos writes additional information to the `SYNC#.txt` log files when a desynchronization occurs such as calls to random number generator functions, facing / target / destination changes etc.

## Developer tools

### Dump Object Info
Expand Down
9 changes: 4 additions & 5 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ Shield.InheritStateOnReplace=false ; boolean
- `CreateUnit.RemapAnim`, if set to true, will cause the animation to be drawn in unit palette and remappable to owner's team color.
- `CreateUnit.Mission` determines the initial mission of the created VehicleType.
- `CreateUnit.Facing` determines the initial facing of created VehicleType.
- `CreateUnit.RandomFacing`, if set to true makes it so that a random facing is picked instead.
- `CreateUnit.InheritFacings` and `CreateUnit.InheritTurretFacings` inherit facings for vehicle body and turret respectively from the destroyed vehicle if the animation is a vehicle destroy animation.
- `CreateUnit.ConsiderPathfinding`, if set to true, will consider whether or not the cell where the animation is located is occupied by other objects or impassable to the vehicle being created and will attempt to find a nearby cell that is not. Otherwise the vehicle will be created at the animation's location despite these obstacles.
- `CreateUnit.RandomFacing`, if set to true, makes it so that a random facing is picked instead.
- `CreateUnit.InheritFacings` and `CreateUnit.InheritTurretFacings` inherit facings for vehicle body and turret respectively from the destroyed vehicle if the animation is a vehicle destroy animation. `InheritTurretFacings` does not work with jumpjet vehicles due to technical constraints.
- `CreateUnit.ConsiderPathfinding`, if set to true, will consider whether or not the cell where the animation is located is occupied by other objects or impassable to the vehicle being created and will attempt to find a nearby cell that is not. Otherwise the vehicle will be created at the animation's location despite these obstacles if possible.

In `artmd.ini`:
```ini
Expand Down Expand Up @@ -618,10 +618,9 @@ Both `InitialStrength` and `InitialStrength.Cloning` never surpass the type's `S
If this option is not set, the self-destruction logic will not be enabled.
```{note}
Please notice that if the object is a unit which carries passengers, they will not be released even with the `kill` option. This might change in the future if necessary.
If the object enters transport, the countdown will continue, but it will not self-destruct inside the transport.
```

This logic also supports buildings delivered by [LimboDelivery](#LimboDelivery)

In `rulesmd.ini`:
```ini
Expand Down
27 changes: 27 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,33 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]

## Changelog

### 0.3.0.1

New:
- Additional sync logging in case of desync errors occuring (by Starkku)

Phobos fixes:
- `AutoDeath` support for objects in limbo (by Trsdy)
- Buildings sold by `AutoDeath` no longer play a click sound effect (by Trsdy)
- Fixed shield animation being hidden while underground or in tunnels fix not working correctly (by Starkku)
- Restore the `MindClearedSound` when deploying a mind-controlled unit into a building loses the mind-control (by Trsdy)
- Fixed `RadSiteWarhead.Detonate` not detonating precisely on the affected object (thus requiring `CellSpread`) (by Starkku)
- Fixed script action 10103 'Load Into Transports' unintentionally skipping next action (by FS-21)
- Changed mission retry dialog button order to better match old order people are used to (by Trsdy)
- Allow PowerPlant Enhancer to be affected by EMP (by Trsdy)
- Animation `Weapon` with `Damage.DealtByInvoker=true` now uses the invoker's house to deal damage and apply Phobos warhead effects even if invoker is dead when weapon is fired (by Starkku)
- Fixed a crash when trying to create radiation outside map bounds (by Otamaa)
- Fixed new AI attack scripts not allowing zero damage weapons to pick targets (by Starkku)
- Fixed floating point value parsing precision to match the game (by Starkku)
- Power output / drain should now correctly be applied for buildings created via `LimboDelivery` in campaigns (by Starkku)
- Fixed shield health bar showing empty bar when shield is still on very low health instead of depleted (by Starkku)
- Fixed `CanTarget` not considering objects on bridges when checking if cell is empty (by Starkku)
- Fixed vehicle deploy weapons not working if the unit is cloaked and weapon has `DecloakToFire=true` (by NetsuNegi & Starkku)
- Fixed `IsAnimated` terrain not updating correctly in all circumstances (by Starkku)
- Fixed `CreateUnit` interaction with bridges (spawning under when shouldn't etc) (by Starkku)
- `CanTarget` now considers bridges as land like game's normal weapon selection does (by Starkku)
- `AreaFire.Target` now takes cells with bridges into consideration depending on firer's elevation (by Starkku)

### 0.3

<details>
Expand Down
95 changes: 9 additions & 86 deletions src/Commands/ObjectInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,81 +50,6 @@ void ObjectInfoCommandClass::Execute(WWKey eInput) const
strcat_s(buffer, Phobos::readBuffer);
};

auto getMissionName = [](int mID)
{
switch (mID)
{
case -1:
return "None";
case 0:
return "Sleep";
case 1:
return "Attack";
case 2:
return "Move";
case 3:
return "QMove";
case 4:
return "Retreat";
case 5:
return "Guard";
case 6:
return "Sticky";
case 7:
return "Enter";
case 8:
return "Capture";
case 9:
return "Eaten";
case 10:
return "Harvest";
case 11:
return "Area_Guard";
case 12:
return "Return";
case 13:
return "Stop";
case 14:
return "Ambush";
case 15:
return "Hunt";
case 16:
return "Unload";
case 17:
return "Sabotage";
case 18:
return "Construction";
case 19:
return "Selling";
case 20:
return "Repair";
case 21:
return "Rescue";
case 22:
return "Missile";
case 23:
return "Harmless";
case 24:
return "Open";
case 25:
return "Patrol";
case 26:
return "ParadropApproach";
case 27:
return "ParadropOverfly";
case 28:
return "Wait";
case 29:
return "AttackMove";
case 30:
return "SpyplaneApproach";
case 31:
return "SpyplaneOverfly";
default:
return "INVALID_MISSION";
}
};

auto display = [&buffer]()
{
memset(Phobos::wideBuffer, 0, sizeof Phobos::wideBuffer);
Expand All @@ -134,14 +59,14 @@ void ObjectInfoCommandClass::Execute(WWKey eInput) const
buffer[0] = 0;
};

auto printFoots = [&append, &display, &getMissionName](FootClass* pFoot)
auto printFoots = [&append, &display](FootClass* pFoot)
{
append("[Phobos] Dump ObjectInfo runs.\n");
auto pType = pFoot->GetTechnoType();
append("ID = %s, ", pType->ID);
append("Owner = %s (%s), ", pFoot->Owner->get_ID(), pFoot->Owner->PlainName);
append("Location = (%d, %d), ", pFoot->GetMapCoords().X, pFoot->GetMapCoords().Y);
append("Current Mission = %d (%s)\n", pFoot->CurrentMission, getMissionName((int)pFoot->CurrentMission));
append("Current Mission = %d (%s)\n", pFoot->CurrentMission, MissionControlClass::FindName(pFoot->CurrentMission));

if (pFoot->BelongsToATeam())
{
Expand Down Expand Up @@ -177,12 +102,10 @@ void ObjectInfoCommandClass::Execute(WWKey eInput) const

if (pFoot->Passengers.NumPassengers > 0)
{
append("Passengers: %s", pFoot->Passengers.FirstPassenger->GetTechnoType()->ID);
for (NextObject j(pFoot->Passengers.FirstPassenger->NextObject); j && abstract_cast<FootClass*>(*j); ++j)
{
auto passenger = static_cast<FootClass*>(*j);
append(", %s", passenger->GetTechnoType()->ID);
}
FootClass* pCurrent = pFoot->Passengers.FirstPassenger;
append("%d Passengers: %s", pFoot->Passengers.NumPassengers, pCurrent->GetTechnoType()->ID);
for (pCurrent = abstract_cast<FootClass*>(pCurrent->NextObject); pCurrent; pCurrent = abstract_cast<FootClass*>(pCurrent->NextObject))
append(", %s", pCurrent->GetTechnoType()->ID);
append("\n");
}

Expand Down Expand Up @@ -210,7 +133,7 @@ void ObjectInfoCommandClass::Execute(WWKey eInput) const
auto printBuilding = [&append, &display](BuildingClass* pBuilding)
{
append("[Phobos] Dump ObjectInfo runs.\n");
auto pType = pBuilding->GetTechnoType();
auto pType = pBuilding->Type;
append("ID = %s, ", pType->ID);
append("Owner = %s (%s), ", pBuilding->Owner->get_ID(), pBuilding->Owner->PlainName);
append("Location = (%d, %d)\n", pBuilding->GetMapCoords().X, pBuilding->GetMapCoords().Y);
Expand Down Expand Up @@ -263,10 +186,10 @@ void ObjectInfoCommandClass::Execute(WWKey eInput) const
case AbstractType::Infantry:
case AbstractType::Unit:
case AbstractType::Aircraft:
printFoots(abstract_cast<FootClass*>(pObject));
printFoots(static_cast<FootClass*>(pObject));
break;
case AbstractType::Building:
printBuilding(abstract_cast<BuildingClass*>(pObject));
printBuilding(static_cast<BuildingClass*>(pObject));
break;
default:
append("INVALID ITEM!");
Expand Down
8 changes: 4 additions & 4 deletions src/Commands/QuickSave.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "QuickSave.h"

#include <GameStrings.h>
#include <ScenarioClass.h>
#include <HouseClass.h>
#include <SessionClass.h>
Expand Down Expand Up @@ -47,7 +47,7 @@ void QuickSaveCommandClass::Execute(WWKey eInput) const
_snprintf_s(fName, 0x7F, "Map.%04u%02u%02u-%02u%02u%02u-%05u.sav",
time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond, time.wMilliseconds);

PrintMessage(StringTable::LoadString("TXT_SAVING_GAME"));
PrintMessage(StringTable::LoadString(GameStrings::TXT_SAVING_GAME));

wchar_t fDescription[0x80] = { 0 };
if (SessionClass::Instance->GameMode == GameMode::Campaign)
Expand All @@ -58,9 +58,9 @@ void QuickSaveCommandClass::Execute(WWKey eInput) const
wcscat_s(fDescription, GeneralUtils::LoadStringUnlessMissing("TXT_QUICKSAVE_SUFFIX", L"Quicksaved"));

if (ScenarioClass::SaveGame(fName, fDescription))
PrintMessage(StringTable::LoadString("TXT_GAME_WAS_SAVED"));
PrintMessage(StringTable::LoadString(GameStrings::TXT_GAME_WAS_SAVED));
else
PrintMessage(StringTable::LoadString("TXT_ERROR_SAVING_GAME"));
PrintMessage(StringTable::LoadString(GameStrings::TXT_ERROR_SAVING_GAME));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Ext/Aircraft/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ DEFINE_HOOK(0x414F47, AircraftClass_AI_TrailerInheritOwner, 0x6)
if (auto const pAnimExt = AnimExt::ExtMap.Find(pAnim))
{
pAnim->Owner = pThis->Owner;
pAnimExt->Invoker = pThis;
pAnimExt->SetInvoker(pThis);
}
}

Expand Down
35 changes: 35 additions & 0 deletions src/Ext/Anim/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

#include <Ext/AnimType/Body.h>
#include <Ext/House/Body.h>
#include <Misc/SyncLogging.h>

template<> const DWORD Extension<AnimClass>::Canary = 0xAAAAAAAA;
AnimExt::ExtContainer AnimExt::ExtMap;

void AnimExt::ExtData::SetInvoker(TechnoClass* pInvoker)
{
this->Invoker = pInvoker;
this->InvokerHouse = pInvoker ? pInvoker->Owner : nullptr;
}

//Modified from Ares
const bool AnimExt::SetAnimOwnerHouseKind(AnimClass* pAnim, HouseClass* pInvoker, HouseClass* pVictim, bool defaultToVictimOwner)
{
Expand Down Expand Up @@ -35,6 +42,7 @@ void AnimExt::ExtData::Serialize(T& Stm)
.Process(this->DeathUnitTurretFacing)
.Process(this->DeathUnitHasTurret)
.Process(this->Invoker)
.Process(this->InvokerHouse)
;
}

Expand All @@ -59,12 +67,39 @@ AnimExt::ExtContainer::~ExtContainer() = default;
// =============================
// container hooks

namespace CTORTemp
{
CoordStruct coords;
unsigned int callerAddress;
}

DEFINE_HOOK(0x421EA0, AnimClass_CTOR_SetContext, 0x6)
{
GET_STACK(CoordStruct*, coords, 0x8);
GET_STACK(unsigned int, callerAddress, 0x0);

CTORTemp::coords = *coords;
CTORTemp::callerAddress = callerAddress;

return 0;
}

DEFINE_HOOK_AGAIN(0x422126, AnimClass_CTOR, 0x5)
DEFINE_HOOK_AGAIN(0x422707, AnimClass_CTOR, 0x5)
DEFINE_HOOK(0x4228D2, AnimClass_CTOR, 0x5)
{
GET(AnimClass*, pItem, ESI);

// Do this here instead of using a duplicate hook in SyncLogger.cpp
if (!SyncLogger::HooksDisabled && pItem->UniqueID != -2)
SyncLogger::AddAnimCreationSyncLogEvent(CTORTemp::coords, CTORTemp::callerAddress);

if (pItem && !pItem->Type)
{
Debug::Log("Attempting to create animation with null Type (Caller: %08x)!", CTORTemp::callerAddress);
return 0;
}

AnimExt::ExtMap.FindOrAllocate(pItem);

return 0;
Expand Down
6 changes: 6 additions & 0 deletions src/Ext/Anim/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,25 @@ class AnimExt
bool FromDeathUnit;
bool DeathUnitHasTurret;
TechnoClass* Invoker;
HouseClass* InvokerHouse;

ExtData(AnimClass* OwnerObject) : Extension<AnimClass>(OwnerObject)
, DeathUnitFacing { 0 }
, DeathUnitTurretFacing {}
, FromDeathUnit { false }
, DeathUnitHasTurret { false }
, Invoker {}
, InvokerHouse {}
{ }

void SetInvoker(TechnoClass* pInvoker);

virtual ~ExtData() = default;

virtual void InvalidatePointer(void* ptr, bool bRemoved) override
{
AnnounceInvalidPointer(Invoker, ptr);
AnnounceInvalidPointer(InvokerHouse, ptr);
}

virtual void LoadFromStream(PhobosStreamReader& Stm) override;
Expand All @@ -58,6 +63,7 @@ class AnimExt
case AbstractType::Building:
case AbstractType::Infantry:
case AbstractType::Unit:
case AbstractType::House:
return false;
default:
return true;
Expand Down
Loading

0 comments on commit 4a2c374

Please sign in to comment.