Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Insignia.Weapon failed to parse in map & Insignia.Passengers #1365

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ This page lists all the individual contributions to the project by their author.
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
- Passenger-based insignias
- **handama** - AI script action to jump back to previous script
- **Ares developers**
- YRpp and Syringe which are used, save/load, project foundation and generally useful code from Ares
Expand Down
2 changes: 1 addition & 1 deletion YRpp
10 changes: 10 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ Due to technical constraints, these settings do not apply to buildings teleporte
- `InsigniaFrame(.Rookie|Veteran|Elite)` can be used to set (zero-based) frame index of the insignia to display, optionally for each veterancy stage. Using -1 uses the default setting. Default settings are -1 (none) for rookie, 14 for veteran and 15 for elite.
- A shorthand `InsigniaFrames` can be used to list them in order from rookie, veteran and elite instead as well. `InsigniaFrame(.Rookie|Veteran|Elite)` takes priority over this.
- Normal insignia can be overridden for specific weapon modes of `Gunner=true` units by setting `Insignia(.Frame/.Frames).WeaponN` where `N` stands for 1-based weapon mode index. If not set, defaults to non-mode specific insignia settings.
- Normal insignia can be overridden when its current passenger size reaches a certain amount by setting `Insignia(.Frame/.Frames).PassengersN` where `N` stands for the current passenger size amount (from 0 to `Passengers` of the transport). If not set, defaults to non-passenger specific insignia settings. Will be overridden by weapon mode insignia settings, if set.
- `Insignia.ShowEnemy` controls whether or not the insignia is shown to enemy players. Defaults to `[General]` -> `EnemyInsignia`, which in turn defaults to true.
- You can make insignias appear only on selected units using `DrawInsignia.OnlyOnSelected`.
- Position for insignias can be adjusted by setting `DrawInsignia.AdjustPos.Infantry` for infantry, `DrawInsignia.AdjustPos.Buildings` for buildings, and `DrawInsignia.AdjustPos.Units` for others.
Expand Down Expand Up @@ -548,11 +549,20 @@ Insignia.WeaponN= ; filename - excluding the .shp extensi
Insignia.WeaponN.Rookie= ; filename - excluding the .shp extension
Insignia.WeaponN.Veteran= ; filename - excluding the .shp extension
Insignia.WeaponN.Elite= ; filename - excluding the .shp extension
Insignia.PassengersN= ; filename - excluding the .shp extension
Insignia.PassengersN.Rookie= ; filename - excluding the .shp extension
Insignia.PassengersN.Veteran= ; filename - excluding the .shp extension
Insignia.PassengersN.Elite= ; filename - excluding the .shp extension
InsigniaFrame.WeaponN=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.WeaponN.Rookie=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.WeaponN.Veteran=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.WeaponN.Elite=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.PassengersN=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.PassengersN.Rookie=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.PassengersN.Veteran=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.PassengersN.Elite=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrames.WeaponN=-1,-1,-1 ; int, frames of insignia shp (zero-based) or -1 for default
InsigniaFrames.PassengersN=-1,-1,-1 ; int, frames of insignia shp (zero-based) or -1 for default
Insignia.ShowEnemy= ; boolean
```

Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ New:
- Nonprovocative Warheads (by Starkku)
- Option to restore `PowerSurplus` setting for AI (by Starkku)
- `FireOnce` infantry sequence reset toggle (by Starkku)
- Passenger-based insignias (by Ollerus)

Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
24 changes: 23 additions & 1 deletion src/Ext/Techno/Body.Visuals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,28 @@ void TechnoExt::DrawInsignia(TechnoClass* pThis, Point2D* pLocation, RectangleSt
int insigniaFrame = insigniaFrames.X;
int frameIndex = pTechnoTypeExt->InsigniaFrame.Get(pThis);

if (pTechnoType->Passengers > 0)
{
int passengersIndex = pThis->Passengers.GetTotalSize();

if (auto const pCustomShapeFile = pTechnoTypeExt->Insignia_Passengers[passengersIndex].Get(pThis))
{
pShapeFile = pCustomShapeFile;
defaultFrameIndex = 0;
isCustomInsignia = true;
}

int frame = pTechnoTypeExt->InsigniaFrame_Passengers[passengersIndex].Get(pThis);

if (frame != -1)
frameIndex = frame;

auto& frames = pTechnoTypeExt->InsigniaFrames_Passengers[passengersIndex];

if (frames.isset())
insigniaFrames = frames;
}

if (pTechnoType->Gunner)
{
int weaponIndex = pThis->CurrentWeaponNumber;
Expand All @@ -156,7 +178,7 @@ void TechnoExt::DrawInsignia(TechnoClass* pThis, Point2D* pLocation, RectangleSt

auto& frames = pTechnoTypeExt->InsigniaFrames_Weapon[weaponIndex];

if (frames != Vector3D<int>(-1, -1, -1))
if (frames.isset())
insigniaFrames = frames;
}

Expand Down
56 changes: 40 additions & 16 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,30 +335,51 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

char tempBuffer[32];

if (this->OwnerObject()->Gunner && this->Insignia_Weapon.empty())
if (this->OwnerObject()->Gunner)
{
int weaponCount = this->OwnerObject()->WeaponCount;
this->Insignia_Weapon.resize(weaponCount);
this->InsigniaFrame_Weapon.resize(weaponCount);
this->InsigniaFrames_Weapon.resize(weaponCount);
size_t weaponCount = this->OwnerObject()->WeaponCount;

for (int i = 0; i < weaponCount; i++)
if (this->Insignia_Weapon.empty() || this->Insignia_Weapon.size() != weaponCount)
{
this->Insignia_Weapon.resize(weaponCount);
this->InsigniaFrame_Weapon.resize(weaponCount);
this->InsigniaFrames_Weapon.resize(weaponCount);
}

for (size_t i = 0; i < weaponCount; i++)
{
Promotable<SHPStruct*> insignia;
_snprintf_s(tempBuffer, sizeof(tempBuffer), "Insignia.Weapon%d.%s", i + 1, "%s");
insignia.Read(exINI, pSection, tempBuffer);
this->Insignia_Weapon[i] = insignia;
this->Insignia_Weapon[i].Read(exINI, pSection, tempBuffer);

Promotable<int> frame = Promotable<int>(-1);
_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrame.Weapon%d.%s", i + 1, "%s");
frame.Read(exINI, pSection, tempBuffer);
this->InsigniaFrame_Weapon[i] = frame;
this->InsigniaFrame_Weapon[i].Read(exINI, pSection, tempBuffer);

Valueable<Vector3D<int>> frames;
frames = Vector3D<int>(-1, -1, -1);
_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrames.Weapon%d", i + 1);
frames.Read(exINI, pSection, tempBuffer);
this->InsigniaFrames_Weapon[i] = frames;
this->InsigniaFrames_Weapon[i].Read(exINI, pSection, tempBuffer);
}
}

if (this->OwnerObject()->Passengers > 0)
{
size_t passengers = this->OwnerObject()->Passengers + 1;

if (this->Insignia_Passengers.empty() || this->Insignia_Passengers.size() != passengers)
{
this->Insignia_Passengers.resize(passengers);
this->InsigniaFrame_Passengers.resize(passengers);
this->InsigniaFrames_Passengers.resize(passengers);
}

for (size_t i = 0; i < passengers; i++)
{
_snprintf_s(tempBuffer, sizeof(tempBuffer), "Insignia.Passengers%d.%s", i, "%s");
this->Insignia_Passengers[i].Read(exINI, pSection, tempBuffer);

_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrame.Passengers%d.%s", i, "%s");
this->InsigniaFrame_Passengers[i].Read(exINI, pSection, tempBuffer);

_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrames.Passengers%d", i);
this->InsigniaFrames_Passengers[i].Read(exINI, pSection, tempBuffer);
}
}

Expand Down Expand Up @@ -630,6 +651,9 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->Insignia_Weapon)
.Process(this->InsigniaFrame_Weapon)
.Process(this->InsigniaFrames_Weapon)
.Process(this->Insignia_Passengers)
.Process(this->InsigniaFrame_Passengers)
.Process(this->InsigniaFrames_Passengers)

.Process(this->TiltsWhenCrushes_Vehicles)
.Process(this->TiltsWhenCrushes_Overlays)
Expand Down
8 changes: 7 additions & 1 deletion src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ class TechnoTypeExt
Nullable<bool> Insignia_ShowEnemy;
std::vector<Promotable<SHPStruct*>> Insignia_Weapon;
std::vector<Promotable<int>> InsigniaFrame_Weapon;
std::vector<Vector3D<int>> InsigniaFrames_Weapon;
std::vector<Nullable<Vector3D<int>>> InsigniaFrames_Weapon;
std::vector<Promotable<SHPStruct*>> Insignia_Passengers;
std::vector<Promotable<int>> InsigniaFrame_Passengers;
std::vector<Nullable<Vector3D<int>>> InsigniaFrames_Passengers;

Nullable<bool> TiltsWhenCrushes_Vehicles;
Nullable<bool> TiltsWhenCrushes_Overlays;
Expand Down Expand Up @@ -403,6 +406,9 @@ class TechnoTypeExt
, Insignia_Weapon {}
, InsigniaFrame_Weapon {}
, InsigniaFrames_Weapon {}
, Insignia_Passengers {}
, InsigniaFrame_Passengers {}
, InsigniaFrames_Passengers {}

, TiltsWhenCrushes_Vehicles {}
, TiltsWhenCrushes_Overlays {}
Expand Down
Loading