Commit Graph
42 Commits
Author SHA1 Message Date
Walter Agazzi f6e4d415a5 AGS: Common: implemented a sprite placeholder in SpriteCache
Currently placeholder is a 1x1 transparent sprite.
Placeholder is returned by the operator[] for safety purposes.
DoesSpriteExist() is still a valid way to test if a sprite is actually registered.
Removed the obscure mechanic of remapping failed sprites to sprite 0.
From upstream 74ff2bdf0ccba4d62821099bce11817f161f47ae
2024-10-30 18:07:42 +02:00
Walter Agazzi 6833358204 AGS: Common: made SpriteCache::GetFreeIndex() much faster
From upstream 5cc9cfb6c537898ec6ef8181ec18fb8b04f9976f
and 7f745a0906adaf8288306cc49c296d26827f15b8
2024-10-30 18:07:42 +02:00
Walter Agazzi 3d6f4c62f7 AGS: Common: fixed stupid mistake in SpriteCache::InitNullSprite()
This fixes deleted dynamic sprites leaving sprite slots marked as "used" indefinitely.
From upstream dcef4084dcde6a2d9fbdc35b5dc91a6009884e5c
2024-10-30 18:07:42 +02:00
Walter Agazzi 3078b207d3 AGS: Engine: refactor around add_dynamic_sprite()
* separate variant of add_dynamic_sprite() that searches for the free slot itself,
not requiring user to do this;
* the previously existing variant is used for: replacing modified dynamic sprite
and restoring sprites from save.
* add_dynamic_sprite() accepts unique_ptr<Bitmap>, explicitly saying that the
ownership will be taken by the spriteset.
* sprite info and SPF_* flags are set inside spriteset, instead of hacking them in
add_dynamic_sprite().
* simplified LoadSaveSlotScreenshot()

From upstream 0913f49e4212fea3a48539251ffc1ab92518a231
and aca47b9f466fe41d73d99a15b9f0ae41e65c6926
+ minor changes
2024-10-30 18:07:42 +02:00
Walter Agazzi 2199dd1555 AGS: Engine: check failure of adding a sprite
Partially from upstream 9c54262d973114110952b8794d737e6e45a532fb
2024-10-30 18:07:42 +02:00
Walter Agazzi eefccd3067 AGS: Common: explicit LockSprite/UnlockSprite methods in SpriteCache
Reimplemented From upstream 8e2d2fc9329a393dcdcddbe29dd5cc7094793350
2024-10-30 18:07:42 +02:00
Walter Agazzi dcd7be5b2d AGS: Common: fixed sprInfo init in SpriteCache::SetSprite()
From upstream 9bb30c7973c138bee3efc3ba86e0f10175b9d1f7
2024-10-30 18:07:42 +02:00
Walter Agazzi ee6cf385c9 AGS: SpriteCache: corrected handling of "remapped" sprites
Remapped sprites are the sprites that were supposed to be present in the game
assets (according to the sprite index), but failed to load for whatever reasons.
The idea is that whenever a remapped sprite is requested, sprite cache should
return a placeholder sprite (sprite 0) instead.

This commit corrects the logic of this, where it would use remapped sprite index
one step earlier. This should fix incorrect duplicating addition of same "bad" sprite
index to the MRU list, and also saves little redundant actions where the LoadSprite
would reload the sprite 0 unnecessarily per each such request.

From upstream eca2e2d3b47a7fcf235690ee0ebda9058a662c91
2024-10-30 18:07:42 +02:00
Walter Agazzi 7edb641ff2 AGS: SpriteCache: store bitmaps in unique_ptr, tidy storage code a little
From upstream ccffbf65b7ea6c85f074ee8f42066102df95c93e
2024-10-30 18:07:42 +02:00
Walter Agazzi 2fbeea1840 AGS: SpriteCache: SetSprite() disposes old sprite in the same slot itself
From upstream 68f1e1a141e53c525b26e8b8f32f81eaa590d299
2024-10-30 18:07:42 +02:00
Walter Agazzi 1527b38a5c AGS: Engine: SpriteCache uses proper callbacks instead of hardcoded externs
From upstream 9354aaf7d105158418dfbc1ba67e75adcd9f89d4
2024-10-30 18:07:42 +02:00
Walter Agazzi 90f94f74c0 AGS: Engine: reduced spriteset's [] operator use where possible
The spriteset's [] operator loads a sprite, but some operations may
 omit that and check the preloaded information instead.
This also makes it more certain where the actual sprite's bitmap is necessary.
From upstream df30fc1edd30d4f334addaf7883286e745dea2c3
2024-10-30 18:07:42 +02:00
Walter Agazzi 3d981f1159 AGS: SpriteCache: separated Remove() and Dispose() methods for convenience
From upstream 92c0f64e47c782e2532760a6b3a10a1b0b5978b6
2024-10-30 18:07:42 +02:00
Le Philousophe 49b4c1b3c4 AGS: Revert to use std namespace
This allows to minimize changes from upstream
2024-07-08 21:37:28 +02:00
Paul Gilbert c2a476411c AGS: Move std namespace into common/std/ 2024-07-07 15:28:31 -07:00
Walter Agazzi 9b5dddd9ac AGS: Remove overzealous assert in spritecache
The assertion is reduntant since there's already an identical check with error
logging and it should not trigger for remapped sprites.
Fixes TRAC #14730
2023-12-11 02:11:38 +01:00
Thierry Crozat ed8e6fb1ce AGS: added safety check for removing sprites
Part of upstream a9e0e47ecfeec205a49ceaf8dd681944eede5eca
2022-12-15 22:40:17 +01:00
Thierry Crozat eb252cf824 AGS: fixed case when imported sprite got flags from placeholder
This could make a new sprite look differently, depending on placeholder's (sprite 0) settings, until the game is saved once.

From upstream f2a922a9cefd40337502bde734503605a76550db
2022-10-09 19:23:13 +01:00
Thierry Crozat 5fd47e4055 AGS: define verbose sprite cache log through a macro function
From upstream a3e762c55b9424ebfc3f311b57ac30a8bcedf945
2022-10-09 18:34:44 +01:00
Thierry Crozat 7f6d7f41d4 AGS: use #if instead of #ifdef for log macros
Sprite Cache and Managed Objects produce a lot of entries in the log currently.
They use a macro to set if they should be on or not, but this macro may be set =0, with the intent of disabling.
Let's instead use #if when testing these macros.

Additionally

- only define DEBUG_MANAGED_OBJECTS if AGS_DEBUG_MANAGED_OBJECTS is true
- adds a new command line flag AGS_DEBUG_SPRITECACHE, which will only define DEBUG_SPRITECACHE if true
- guard indefinition through core/platform.h

From upstream e8bd58da2e09d844068dc087f1da153a693b7aa8
2022-10-09 18:11:02 +01:00
Thierry Crozat 4e3c2ec299 AGS: Invalidate iterators to MRU list in SpriteCache when the item is erased
The implementation of std::list::erase invalidates iterators to the
erased item. However our implementation in Common::List does not.
And the SpriteCache code relied on this behaviour. So instead we
have to invalidate the iterators manually.
2022-06-18 22:20:40 +01:00
Thierry Crozat 15563b5a7c AGS: Changed SpriteCache::FreeMem to comply with sound cache
From upstream 94a462d52d5533f4ebb4cef1bbddd280b4f876a2
2022-06-18 18:21:35 +01:00
Thierry Crozat ee23fde329 AGS: Fixed SpriteCache::FreeMem not using an argument
From upstream 0369250309f797eb5035fcdf75cd8ad882fa317e
2022-06-18 01:03:30 +01:00
Thierry Crozat fad62e8cef AGS: Refactored SpriteCache's MRU list
Using ideas from Nick Sonneveld (@sonneveld).
From upstream: 1f57208879ca278e5b3c45d05a8c29f30632a5bd
2022-06-18 01:03:30 +01:00
Thierry Crozat d6d464f898 AGS: Fixed sprite cache limit was reset on sprite file open
From upstream 4f57730e2b3d41af4fd0300e8b092d31d448f544
2022-06-16 23:16:20 +01:00
Paul Gilbert 959b8a78e1 AGS: Fixed SaveSpriteFile unintentionally restoring deleted sprites
From upstream f2973226e29120d4ef193e81a1d098c6c40f5b36
2022-04-10 19:39:07 -07:00
Paul Gilbert a2cf1dd946 AGS: Properly reset SpriteCache and SpiteFile when they reinit
From upstream 938d7300f70180f55b6f2056ec5fb0d894a63735
2022-04-10 19:39:07 -07:00
Paul Gilbert 6d4a816fb4 AGS: SpriteFile supports compression type selection (RLE/LZW)
From upstream 1526a939223974a88abf4c9601f1d4e421296a65
2022-03-30 22:13:18 -07:00
Paul Gilbert 6912f58a2f AGS: SpriteFile's extended format, let store as indexed bitmaps
From upstream 34f32e3b71b2f8d0f7480aa04a2fcd38d77fb83b
2022-03-30 22:13:17 -07:00
Paul Gilbert d2bb96db47 AGS: Fixed printing error in SpriteCache::LoadSprite()
From upstream 2398b431552b182f98c9fd5ee48204e8688694a5
2022-03-29 22:09:00 -07:00
Paul Gilbert fc9473d175 AGS: Picked a sprite file writing code into SpriteFileWriter class
From upstream 62a87664fc9249bad2886b44d10affc4d60071c3
2022-03-17 21:49:23 -07:00
Paul Gilbert ea65fe3c69 AGS: Moved SpriteFile class to a separate code unit for convenience
From upstream 393ef2c24bbc835d8e7a7229d40f638a6f172304
2022-03-17 21:49:22 -07:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Alexandre Detiste 6044504762 JANITORIAL: typos
some in the variable names, some in the comments;
no change for the strings that interract with original games assets
2021-10-31 20:46:31 +01:00
Paul Gilbert 0aba516dac AGS: fixed SpriteFile may try loading a non-existing sprite
From upstream 5800e80ceaa26b8725d6bd3337de3aec5b204dc5
2021-07-31 14:34:08 -07:00
Paul Gilbert 7e322be394 AGS: Moved image (de)compression functions out from SpriteFile
From upstream a3c6e7cfded18daadab00474ff6d148904581f08
2021-07-07 22:07:09 -07:00
Paul Gilbert 41b1126aed AGS: Split SpriteCache, picking out read/write into SpriteFile class
From upstream 565eaaf90e63ad444798cd949b1e4c60dfb4a0f8
2021-07-07 22:07:09 -07:00
Paul Gilbert 313a824fb9 AGS: Fix int pointer type mismatches 2021-06-15 19:16:10 -07:00
Paul Gilbert edb1ac0f6c AGS: fixed formatting type for several size_t and soff_t values
From upstream 548573740a5c8acc48600f9b069b7d1dc94d0dc3
2021-06-13 21:09:01 -07:00
Paul Gilbert c7ce28934a AGS: fixed formatting in SpriteCache::InitFile()
From upstream 25bc13eb548a5f6e0e8201163809ba038f5b362e
2021-06-13 21:09:00 -07:00
Paul Gilbert d57474ce59 AGS: Provided more function variants accepting const String&
From upstream 44402962003db439e54d79e0c562fba1cf59e455
2021-06-13 21:08:58 -07:00
Paul Gilbert 701396361c AGS: Import of fresh codebase 2021-06-13 21:08:44 -07:00