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 object picking up animation, fix object remove from map and fix restoration of the object type for the tile #8949

Merged
merged 37 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1f4fa83
Fix artifact picking up animation when it is set to the bottom layer …
Districh-ru Jul 10, 2024
bb3a940
Make IWYU happy
Districh-ru Jul 10, 2024
174fde4
Use the same get UID approach for all objects fade out animation
Districh-ru Jul 10, 2024
6e7eb52
Fix incorrect included header
Districh-ru Jul 10, 2024
65a27c9
Reduce code duplication
Districh-ru Jul 12, 2024
adef3d4
Restore object type after action object pick up
Districh-ru Jul 12, 2024
d5911f3
Fix jail upper tiles restoration after remove
Districh-ru Jul 12, 2024
9ea10fe
Also check the bottom layer when removing the action object (campaign…
Districh-ru Jul 12, 2024
ab6c643
Rename: setAsEmpty() -> updateObjectType()
Districh-ru Jul 13, 2024
ba65a24
Remove `updateEmpty()` method. Use its code in the only place where i…
Districh-ru Jul 13, 2024
c8e9065
Remove invalid assertion - monsters can be recruited from other objec…
Districh-ru Jul 13, 2024
8766745
Fix radar update after removing an object.
Districh-ru Jul 13, 2024
0ade01f
Merge branch 'master' into pr/8949
ihhub Jul 14, 2024
45b1e6f
Expand the comment
ihhub Jul 14, 2024
dbb09ff
Update logic
ihhub Jul 14, 2024
30d8f30
Update logic
ihhub Jul 14, 2024
1717be4
Rename function to reflect what it does
ihhub Jul 14, 2024
ffa303d
Add an extra check
ihhub Jul 14, 2024
680b6a7
Update logic
ihhub Jul 14, 2024
23a532e
Add extra boat directions to properly get object type by boat ICN id …
Districh-ru Jul 14, 2024
3b1d772
Update logic
ihhub Jul 14, 2024
4cd3a6d
Remove a comment
ihhub Jul 14, 2024
b982293
Remove unused variable
ihhub Jul 14, 2024
eadfc19
Add a TODO comment
ihhub Jul 14, 2024
fbcc0e7
Use revert indexing for objects
ihhub Jul 14, 2024
d1f3266
Add an assertion
ihhub Jul 14, 2024
ee886a0
Update logic
ihhub Jul 14, 2024
5429369
Add const
ihhub Jul 14, 2024
f66bb3a
Minot speed-up in removeObjectFromMapByUID()
Districh-ru Jul 14, 2024
97e2d52
Combine scoutTileOnRadar() with runActionObjectFadeOutAnumation()
Districh-ru Jul 14, 2024
f0e31ed
Make sure to set interactive action object type first
ihhub Jul 14, 2024
9904e80
Fix logic
ihhub Jul 14, 2024
eacd614
Fix the condition
ihhub Jul 14, 2024
ca44335
Update logic
Districh-ru Jul 14, 2024
1e56bde
Revert "Update logic"
Districh-ru Jul 14, 2024
5395477
Address comments
Districh-ru Jul 14, 2024
4efee5f
Merge branch 'master' into fix-artifact-pickup
Districh-ru Jul 20, 2024
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
53 changes: 25 additions & 28 deletions src/fheroes2/ai/ai_hero_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,8 @@ namespace
}

if ( destroy ) {
setMonsterCountOnTile( tile, 0 );

removeObjectSprite( tile );
tile.setAsEmpty();
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );
}
}

Expand All @@ -589,8 +587,8 @@ namespace
hero.GetKingdom().AddFundsResource( getFundsFromTile( tile ) );
}

removeObjectSprite( tile );
resetObjectInfoOnTile( tile );
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );
hero.GetPath().Reset();
}

Expand Down Expand Up @@ -668,8 +666,8 @@ namespace
kingdom.AddFundsResource( Funds( Resource::GOLD, gold ) );
}

removeObjectSprite( tile );
resetObjectInfoOnTile( tile );
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );
}

void AIToCaptureObject( Heroes & hero, const MP2::MapObjectType objectType, const int32_t dstIndex )
Expand Down Expand Up @@ -742,7 +740,7 @@ namespace
Maps::Tiles & tile = world.GetTiles( dst_index );
hero.GetKingdom().AddFundsResource( getFundsFromTile( tile ) );

resetObjectInfoOnTile( tile );
resetObjectMetadata( tile );
hero.setVisitedForAllies( dst_index );
}

Expand All @@ -760,7 +758,7 @@ namespace
hero.GetKingdom().AddFundsResource( Funds( Resource::GOLD, gold ) );
}

resetObjectInfoOnTile( tile );
resetObjectMetadata( tile );
}

hero.SetVisitedWideTile( dst_index, objectType, Visit::GLOBAL );
Expand All @@ -780,7 +778,7 @@ namespace
else
hero.GetKingdom().AddFundsResource( getFundsFromTile( tile ) );

resetObjectInfoOnTile( tile );
resetObjectMetadata( tile );
}

hero.SetVisited( dst_index, Visit::GLOBAL );
Expand All @@ -793,8 +791,8 @@ namespace
Maps::Tiles & tile = world.GetTiles( dst_index );

hero.GetKingdom().AddFundsResource( getFundsFromTile( tile ) );
removeObjectSprite( tile );
resetObjectInfoOnTile( tile );
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );
}

void AIToSign( Heroes & hero, int32_t dst_index )
Expand Down Expand Up @@ -1217,7 +1215,7 @@ namespace
}

if ( complete ) {
resetObjectInfoOnTile( tile );
resetObjectMetadata( tile );
}
else if ( 0 == gold && !hero.isObjectTypeVisited( objectType ) ) {
// Modify morale
Expand Down Expand Up @@ -1257,7 +1255,7 @@ namespace
hero.AppendSpellToBook( spell );
}

resetObjectInfoOnTile( tile );
resetObjectMetadata( tile );
hero.SetVisited( dst_index, Visit::GLOBAL );
}
else {
Expand Down Expand Up @@ -1332,7 +1330,7 @@ namespace
AIBattleLose( hero, res, true );
}

resetObjectInfoOnTile( tile );
resetObjectMetadata( tile );
}
}

Expand Down Expand Up @@ -1400,8 +1398,8 @@ namespace

// Remove genie lamp sprite if no genies are available to hire.
if ( MP2::OBJ_GENIE_LAMP == objectType && ( availableTroopCount == recruitTroopCount ) ) {
removeObjectSprite( tile );
tile.setAsEmpty();
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );
}
}

Expand Down Expand Up @@ -1501,8 +1499,8 @@ namespace
const Kingdom & kingdom = hero.GetKingdom();

if ( kingdom.IsVisitTravelersTent( getColorFromTile( tile ) ) ) {
removeObjectSprite( tile );
tile.setAsEmpty();
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );
}
}

Expand All @@ -1527,8 +1525,8 @@ namespace
else
hero.PickupArtifact( getArtifactFromTile( tile ) );

removeObjectSprite( tile );
resetObjectInfoOnTile( tile );
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );
}

void AIToArtifact( Heroes & hero, int32_t dst_index )
Expand Down Expand Up @@ -1580,8 +1578,8 @@ namespace
}

if ( result && hero.PickupArtifact( art ) ) {
removeObjectSprite( tile );
resetObjectInfoOnTile( tile );
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );
}
}

Expand Down Expand Up @@ -1660,8 +1658,8 @@ namespace
if ( kingdom.GetHeroes().size() < Kingdom::GetMaxHeroes() ) {
Maps::Tiles & tile = world.GetTiles( tileIndex );

removeObjectSprite( tile );
tile.setAsEmpty();
removeMainObjectFromTile( tile );
resetObjectMetadata( tile );

Heroes * prisoner = world.FromJailHeroes( tileIndex );

Expand Down Expand Up @@ -2218,8 +2216,7 @@ namespace AI
gameArea.runSingleObjectAnimation( std::make_shared<Interface::ObjectFadingOutInfo>( tileSource.GetObjectUID(), boatSource, MP2::OBJ_BOAT ) );
}
else {
removeObjectSprite( tileSource );
tileSource.setAsEmpty();
removeMainObjectFromTile( tileSource );
}

Maps::Tiles & tileDest = world.GetTiles( boatDestinationIndex );
Expand Down
3 changes: 1 addition & 2 deletions src/fheroes2/gui/interface_gamearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,6 @@ Interface::ObjectFadingOutInfo::~ObjectFadingOutInfo()
Maps::Tiles & tile = world.GetTiles( tileId );

if ( tile.GetObject() == type ) {
removeObjectSprite( tile );
tile.setAsEmpty();
removeMainObjectFromTile( tile );
}
}
Loading
Loading