63 Commits

Author SHA1 Message Date
Anthony Calosa
1428eeba06 fix copier token image 2017-01-26 15:32:17 +08:00
Anthony Calosa
8530292fef Revert my Graphic changes
I think it's the one who cause those crashes
2016-08-13 16:45:46 +08:00
Anthony Calosa
dae1b10de1 Copied Token Image
If the image is not found, try finding the token counterpart by Id
2016-08-05 21:52:46 +08:00
Anthony Calosa
cd1b629191 Fix Segmentation Fault & Formatting 2015-11-10 11:58:36 +08:00
Xawotihs@gmail.com
c38c52c6ad Refactored audio sample playback 2012-02-11 18:20:08 +00:00
wagic.the.homebrew
e27cf56fa2 - Support for Zip Filesystem. It is now possible to zip the entire Res folder ("store" method preferred, zip so that the root of the zip has ai, player, etc...) in one single file for read only. Write access is done in another folder (hardcoded to be User/ for now, can be updated depending on platforms, etc...
-- zipFS has several limitations...
--- in a general way, seekg doesn't work... so getting a file's size needs to be done through JFileSystem.
--- getLine on files open with zipFS doesn't work so great. Not sure if it is a normal issue because files are open in binary or not... JFileSystem therefore offers a "readIntoString" function that needs to be used instead of the usual "getline" technique. However getLine can then be used on a stream connected to the string.

-- tested on Windows and PSP, I also made sure android still works, but haven't tested zip support on Android.
-- I tried to maintain backwards compatibility, but this might break on some platforms, if I broke some platforms and you can't find a way to fix them, please contact me and we'll figure something out
-- This removes wagic::ifstream. I didn't reimplement the securities that were involved in this, apologies for that. Might be useful to reimplement such securities in JFileSystem
-- I haven't tested options/profiles in a deep way, it is possible I broke that.
2011-08-21 09:04:59 +00:00
wagic.the.homebrew
3148a25f3a - Manual cache cleanup in the menu to help a bit with issue 693. This is unfortunately not enough, we are dealing with ram fragmentation problems here :( 2011-07-10 13:51:39 +00:00
wrenczes@gmail.com
c5963c3c23 Three improvements involving image caching:
1) prevent the textureQuad map from containing references to cards when we're returning a temp (card backdrop) image in the threaded version.
2) we had two copies of the pspicon image in the cache (ie the regular & managed).  Changed the reference in the DeckMenu code to use the managed instance.
3) Fixed a problem with a default constructor param that would set RESOURCE_LOCKED on certain images.  I noticed that the 'NEW' image was locking itself in the cache because no resource modes was being passed in, so the default constructor param was setting it to locked.  This seems like a bad idea - if you're not explicitly locking a resource in the call, that shouldn't be the default behaviour.

Also added an assert safeguard to catch the possibility of 'overlocking' an image resource, as this probably means the image fetching routine is being abused somehow.
2011-07-07 07:37:17 +00:00
wrenczes@gmail.com
aaa169f86c Consolidated some loose strings into constant declarations in order to reduce allocation thrashing on temporary string constructs. I'm sure there are more, but "back_thumb", "back", and "backdrop.jpg" were the ones that showed up most in memory profiling. 2011-04-21 22:48:22 +00:00
wrenczes@gmail.com
180f83083c Fixed compilation times by refactoring: WResourceManager.h gets included either directly or indirectly into every header & cpp file; so does its includes & implementation details. Broke out WResourceManager into a pure virtual class that contains only the required calls, and added a WResourceManagerImpl header that contains all the dirty details that the rest of the app doesn't care about / need to know. 2011-04-20 06:27:44 +00:00
Xawotihs
40958170fa Fix to have r3450 at least compile on linux 64 bits 2011-04-19 19:04:12 +00:00
wrenczes@gmail.com
7a10993114 *POSSIBLY DESTABLIZING CHANGE, PLS PING ME IF YOU SEE ISSUES*
Turned on the threaded card fetching code for win/linux.  PSP runs unthreaded.   There's an easy toggle for switching which mode the app runs in: check out WResourceManager's constructor.

To fully appreciate the difference, try going into the deck editor without these changes, and use the arrow keys to navigate around (esp. up/down, as it loads 7 cards at a time).  Then try again with these mods, you'll see the cards flicker briefly to the back card image and then load as they scroll onto the screen.
2011-04-19 07:12:05 +00:00
wrenczes@gmail.com
76cba56a1c Resuming on my threading support work with the card caching mechanism. This change unfortunately touches quite a few files, but I needed to get it out of the way before things got out of hand: one significant hurdle is the assumed lifetime of a JQuad pointer. In a single threaded model, the life time of the pointer is clear: you fetch it into the cache, the cache makes room, you use the pointer immediately. In a multithreaded context however, it's unsafe, as the drawing thread can request a few JQuads, and the cache operating on a separate thread can potentially bounce a JQuad out of the cache before the draw routine is done using it, which ends up in an access violation when you attempt to draw using an invalidated quad pointer. To prevent this, the bulk of this change swaps out the use of naked JQuad* pointers in the code with a JQuadPtr, which is basically a typedef to a boost shared_ptr<JQuad>.
This btw points out another circular dependancy between the texture and the JQuad - a texture owns a bunch of JQuads, yet the renderer uses JQuads and always assumes that the texture is valid.  We're going to need to add more defensiveness to JGE to protect against this.

Other changes in this check-in:  WResourceManager doesn't derive from JResourceManager anymore.  It actually didn't require anything from the base, so I killed the dependency.  Also cleaned up the notion of a WTrackedQuad in the WCachedResource - it didn't need a separate class, just a better container.

I've build this & tested against PSP, win, linux, QT (linux).  I haven't tried against iOS and QT Win, or Maemo.  If these other platforms are broken, I apologize in advance! - I'm hoping it should be fairly simple to put them back into play.
2011-02-01 10:37:21 +00:00
techdragon.nguyen@gmail.com
e53c16f700 No code change just reformatting of header files.
finishing up my reformatting of the source from November/December following the guidelines that were posted.
some extra things I added:
   * Any empty virtual declarations were kept to one line.  
   * Enums were split up into separate lines to promote uniformity across all headers. ( each header file had a different style for enums)
2011-01-21 18:01:14 +00:00
wagic.the.homebrew@gmail.com
6360734ea3 Erwan
-Attempt at fixing issue 538. This is a wild guess, but basically 1 000 000 bytes is NOT enough to decompress a 512*512*4 texture (32bits png). We need at least 1MB (1024*1024) AND some additional space for the decompression process. Based on that, bumped the 1 000 000 (minimum contiguous ram necessary to start decompressing a picture) to 1 500 000. I've had pretty good results so far but this needs confirmation
- GameObserver <- changes from Win to *nix carriage returns.
2010-12-09 13:47:04 +00:00
wrenczes@gmail.com
65e38b0694 Another change that looks bigger than it is: changed out the global extern WResourceManager to a real singleton. This means that it's no longer being init'ed at static initialization time, and we can debug construction/destruction properly; it's also safer in a multithreaded context. 2010-12-01 08:22:17 +00:00
wrenczes@gmail.com
609ece329e Splitting up my threading changes into smaller pieces, as it's getting too large. This change: pass strings by reference, never by value; some minor formatting cleanup in WResourceManager. 2010-12-01 04:27:56 +00:00
wrenczes@gmail.com
3eeb8a6465 - renamed WResourceManager::autoResize() to ResetCacheLimits(), since the function doesn't actually resize anything. It's merely setting clamping limits on when we should purge the cache.
- fixed the debug framerate calculation / drawing code (consolidated duplicated functions & variables mDelta vs a win-only mDeltaTime, no reason to have two), repositioned it to draw on the bottom left (it was colliding with other debug text for the cache info).
 - for debug testing purposes, added a #define override to force the image cache to work with less memory (I've picked 8 megs, which is what the psp seems to use - the normal default on win/linux is 20 megs).
2010-11-09 19:01:38 +00:00
wrenczes@gmail.com
5aa3dc6fd3 Refactoring of some of the font management in WResourceManager. This change looks bigger than it actually is - most of the touched files are simply renaming of some font enums that I moved out of MTGDefinitions into the resource manager header files. The main points of this change: collapsing the font containers into a single map, eliminating duplicated functions, and migrating the font building logic into the resource manager class. GameApp doesn't need to know anything about the fonts it uses, and likewise, font users don't need to know what the name of their chosen font is, just the FONT_TYPE enum.
(I did a cursory check to make sure chinese still displays correctly - at a glance, I'm seeing what looks correct to someone who doesn't read the language :) )
2010-10-19 07:51:32 +00:00
wrenczes@gmail.com
832f11c153 Switched the managed JQuad container implementation from a vector to a map. This speeds up the cache lookup time from O(n) to O(log n). Hard to see a noticeable difference on win, but it definitely feels snappier on my psp, for instance, when browsing your library for a card, or your graveyard, etc.
I'm also noticing that the GetQuad(int) variant never seems to get hit, so I suspect that the ID lookup map is redundant.  I left it alone as the JResourceManager base class forces the need for the function; I need to spend more time looking at just how much of JResourceManager we actually use at this point.
2010-10-17 16:54:08 +00:00
wagic.the.homebrew@gmail.com
f40af0b1cb Erwan
- Chinese patch by linshier
2010-07-31 14:41:04 +00:00
jean.chalard
5a2bae75d5 J :
* Add newlines at end of files. This is for better portability.
* Fix a direct reference to g++ in the makefile
2010-02-02 10:19:43 +00:00
wagic.the.homebrew@gmail.com
d22b7b5e37 Erwan
-some fixes for HQ cards support
2010-01-23 03:35:43 +00:00
wagic.the.homebrew@gmail.com
66a505969e Erwan
- fix issue 215
- added test for purple screen (this is the small white square on top of the loading screen)
2009-11-23 08:25:27 +00:00
wagic.the.homebrew@gmail.com
e059890446 Erwan
-reduced SFX Quality. This seems to fix the Bug with samples getting silent on the PSP (issue 112), and improves loading times. If you think this is unacceptable, let's discuss it
- AI now should play fetchlands' ability, although still not "efficiently"
- Fix a bug where the game would crash if a card has a valid alias to a hardcoded card that is in no _cards.dat (starwars mod cards aliasing a MTG card)
2009-11-12 11:39:47 +00:00
wagic.the.homebrew@gmail.com
f33d37d9f2 Erwan
-attempt at fixing shop crash introduced in r1231 (size needed in ram divided by 4)
2009-11-04 13:33:21 +00:00
wagic.jeck
3347fd020b Jeck - Removed some unused bits of code, added zip support to themes' card overrides. @Jean, please check WResourceManager::dirOK() on Linux.
This needs some impact testing, to be certain it doesn't noticeably slow anything down. In a future version I'd like to memoize checking for zip file existence in each "Res/sets/XXX/" directory once during boot, and in the themed directory whenever switching themes.
2009-10-28 04:06:45 +00:00
wagic.jeck
fb7f48f26b Jeck - Please review: this makes minor changes to a lot of files, and major changes to the WCache flatten() function.
* Removed all calls to Release(JQuad*).
* Updated flatten(). Prior flatten was buggy beyond belief.
* Done some extensive testing, but if this causes more trouble than it fixes, we'll have to revert. It's too close to release time.
2009-10-27 02:46:39 +00:00
wagic.jeck
8e0bcef6e9 Jeck - Removed a ton of unreached or unused code from the cache, to make debugging easier. None of this actually effects execution at all. Some of these functions (though not many) are potentially useful, but as they aren't actually used there's no reason to have them cluttering up the files. 2009-10-26 05:55:52 +00:00
wagic.jeck
7f7320f904 Jeck - Some basic options handling rewrites, main menu update, example alternate theme (for testing). I'm closing issues 44 and 45, as hopefully this resolves them satisfactorily.
* The alternate theme is just useful for testing themes, but please comment on the changes to the main theme.
 * Options reading and initializing separated from UI.
 * Options UI abstracted a bit, made more easily extensible.
 * With some extension, the options UI could be used as the basis for more complicated themes, if we load a file and use it to do stuff like GameStateOptions::Start()
2009-10-20 03:46:18 +00:00
wagic.the.homebrew@gmail.com
273b0672e4 Erwan
- various optimization fixes
2009-10-19 11:37:47 +00:00
wagic.the.homebrew@gmail.com
97a0732682 Erwan
- Fix issue 97. Please review. How about performance ?
2009-10-15 13:58:35 +00:00
wagic.the.homebrew@gmail.com
6f159fb39c Erwan - cache fixes - Code review highly appreciated, please criticize my code!
- fix issue 65 (quads when no image  load slowly in shop/deck editor)
- Possibly fix issue 92, please let me know if it reproduces
- Fix issue 97 (Deck editor: weird behavior of deck display)
- Fix issue 39 - please verify
- Issue 56 can probably be closed as well
- Fix issue 86
2009-10-13 14:16:30 +00:00
wagic.jeck
d9786dfdc2 Jeck - (Probable) fix for issue 41. Turns out AttachZipFile is very robust, and already handles all the unattach / reattach optimizing & checking for us. 2009-09-22 05:33:01 +00:00
wagic.jeck
6de4f5612e Jeck - Resource manager zipfile fix.
* Only attaches when necessary.
2009-09-21 06:59:28 +00:00
wagic.jeck
20b41ab569 Jeck - Larger small cache size, to reduce likelihood of issue 39. 2009-09-21 00:02:10 +00:00
wagic.jeck
8c9374fe1f Jeck - GameStateMenu releases background image from cache, minor cache fixes. 2009-09-20 23:56:08 +00:00
wagic.jeck
e0b225bad9 Jeck - TEMPORARY enabling of exceptions. (~6hrs) Sorry, I've been an idiot lately and coded myself into a corner with stuff that "should only take a minute" to fine tune. I honestly shouldn't have committed r871+, but I'd sworn to high heaven that the damn thing was fixed. In reality getting the cache 100% needs a bit more time, so I'm committing this in the hopes that it'll prevent sloppy cache work from interrupting other people's coding.
Exception handling in the cache means that Wagic runs slightly, but noticeably slower. However, it also means that the cache works the way it was intended to, and should prevent all sorts of awkward errors I introduced because things were half-allocated or worse. 

I've learned my lesson from tonight, and once I get this stuff put back together without exception handling I think I'll self-impose a manditory 24 hours debugging time before any commits. Sorry for the inconvenience. 

If for some reason you can't compile with exceptions, r862 should be completely without them. Again, wow, this was stupid-- I hadn't even realized exceptions were off for like 24 hours, as the compiler wasn't producing warnings. 

Apologies,
—Jeck
2009-09-20 03:10:34 +00:00
wagic.jeck
1ba7f108b0 Jeck - Cache is using map<> again. The implementation is cleaner and seems a little faster. 2009-09-19 23:20:43 +00:00
wagic.jeck
8cc9bff484 Jeck - Stricter cache limits. 2009-09-19 22:34:48 +00:00
wagic.jeck
0d3686e65a Jeck - Cache fix, booster duplicate fix.
* Restored OptionItem saving fix.
 * Booster duplicate replacement was picking random cards from the wrong set. My fault, but I've fixed it :)
 * The problem with cache had nothing to do with memory fragmentation, but I've switched to an array rather than map<> just in case. The actual issue was that in GameStateDeckViewer, I'd given the cache unlimited space, thinking that AttemptNew would recover from any bad_allocs. Unfortunately, the image loading routines and similar stuff called by various implementations of WResource::Attempt() could fail halfway through, leaking memory. 

The temporary solution is to set a proper limit (8000000 px, more or less) and (in case we still run out of memory) test to make certain CACHE_SPACE_RESERVED can be malloc'd/free'd. The proper solution would be to keep byte-perfect records of memory used (right now we're kinda fuzzy-- we track pixels per image and bytes per sound, but not the space for jquads or other incidentals) instead of testing a malloc, and potentially cleaning up all calls inside of Attempt() so they fail without leaks. That's what I'm working on now.

Still, it's nice to have identified the problem. This version of the cache should be fully functional, it's just a bit inelegant.
2009-09-19 21:11:35 +00:00
wagic.jeck
4b8d344bcd Jeck - Card ID collisions, cache fixes, cache deleted pooling.
* mtgid now defaults to 0.
 * TextScroller will not update when empty.
 * Cache now moves WCachedResources we're finished with to a garbage pool for later use (to reduce memory fragmentation). 
 * Demo still crashes... but I'm thinking that has to do with fragmentation, not a leak?
2009-09-19 01:48:42 +00:00
wagic.jeck
8ba34dafca Jeck - WResourceManager / Cache should now be leak free. Demo mode still crashes around EnstackBlocker. 2009-09-18 01:20:46 +00:00
wagic.jeck
505ee8d1eb Jeck - I somehow managed to break the test suite. Rolled back my changes to r843, won't commit until they're properly debugged. 2009-09-15 01:53:02 +00:00
wagic.jeck
a84ed94954 Jeck - Cache Leakfix. Quads now individually lock/unlock. Demo still crashes PSP. 2009-09-14 20:54:49 +00:00
wagic.jeck
5467fd379f Jeck - Signed/unsigned fix in resource manager, options save fix. 2009-09-14 18:30:47 +00:00
wagic.jeck
d55fc91112 Jeck - [Requires JGE rebuild] Extensive cache improvements.
* Numerous cache fixes, reduced filesystem access.
 * Cache fails very gracefully. 
 * Cache is now a templated class, with individual caches per data-type.
 * Much easier to extend.
 * Extensively debugged. Try compiling with -DDEBUG_CACHE.
 * Caches limits can be set on a per-item basis.
 * hgeParticleSystemInfo are now cached, mana particles now fall back to defaults.
 * Samples are not cached, but track filesystem misses using the cache backbone. 
 * Avatars are cached. Default baka avatar is now baka.jpg, to prevent collision with player.

A note on the retrieval types: 
  RETRIEVE_MANAGE puts a resource into a seperate, managed resource list.
    Managed resources are guarenteed valid for the lifetime of the program. 
    Retrieving a managed quad promotes the associated texture to managed. Don't do that by mistake.
    Calls to Resources.Refresh() will attempt to reload managed resources in place.

  RETRIVE_LOCK (and by extension, RETRIEVE_VRAM), returns a resource after locking it.
    A resource may have many locks, and remains in cache until they are all released. 
    If the resource is managed, it returns it unmodified.

A note on quads:
Unlike all other RetrieveWhatever() functions, the default behavior for RetrieveQuad is RETRIEVE_LOCK. Worse, Release(JQuad*) is slow, and will /always/ release one lock from the associated texture.   

There's a long and complicated explanation for this, involving support for live relinking of textures to existing quads, but basically what it means is that we only use RetrieveQuad for quads we intend to store and later Release(). If a temporary quad is needed, the preferred method is to use NEW JQuad* and SAFE_DELETE with RetrieveTexture(). RetrieveTempQuad is also provided, but is only guaranteed until the next call to the cache.

Note that RetrieveCard has none of these problems.
2009-09-14 08:28:49 +00:00
wagic.jeck
9d203619aa Jeck - Extremely minor speedup for cache access in GameStateDeckViewer, minor fix to WResourceManager::cleanup(). 2009-09-11 08:17:05 +00:00
wagic.the.homebrew@gmail.com
c0be024093 Erwan
- Put back delayed loading functionality for the Deck editor
2009-09-09 13:51:29 +00:00
wagic.jeck
4993cc5dea Jeck - Cache now pretty damn near guarantees successful retrieval.
* The only fail condition is if all resources are locked, or the file doesn't exist at all.
2009-09-09 05:02:08 +00:00