Commit Graph

60 Commits

Author SHA1 Message Date
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
afdeae6901 fixed some formatting issues.
changed conditional for lord and thises evaluation from hardcoded value to length of the array being evaluated.  This doesn't change current functionality, but minimizes code change if these arrays were ever to change in size.
2010-12-16 12:53:48 +00:00
wrenczes@gmail.com
1cc516193e Sidecar fix to the CardView change: running the test suite revealed a few other places where bad assumptions were being made that an event's card view pointer was legitimate. Now they properly evaluate whether the view is null and adjust accordingly. 2010-12-16 09:41:14 +00:00
wrenczes@gmail.com
4d0296d628 Fixed issue 551, "this vector contains over 1 million members" crash.
Thanks to Mike for helping me with the repro & debug session on his machine.
2010-12-12 09:44:45 +00:00
omegablast2002@yahoo.com
5d96f68d21 reverted my changes in rev 2774 which intruduced bugs, coincidently stumbled across what really fixed triggers substep, which was moving it into stateeffects...this revert reintruduces the double interrupt offer to combatdamage in some specail cases. 2010-12-09 13:31:09 +00:00
omegablast2002@yahoo.com
d3a4745686 did a couple things here, fixed issue507 but also, very very very possibly fixed issue548, tho i will leave the closing of those 2 tickets to wololo, as he was the one who originally reported them.
another issue i fixed, when last trigger would be resolving in "trigger" substep, the game was moving to next combatstep before you could finish it, NOW the game correctly finishes resolving any triggers that might have fired off in "Triggers" substep, THEN it adds combatdamage step to the stack. this also fixes an issue where if you were multiblocked and combattriggers fired off, then your trigger would be UNDER the "ordering window" and unresolvable.

added waitingforanwsers return to userRequestNextGamePhase
when youre "waiting for anwsers" that means you have a menu box open and the game is waiting for you to decide....this was one of the causes of the rush to combat damage while youre still selecting something on a menu.

moved Trigger step call to requestnextgamephase into stateEffects() and out of updates, works MUCH better this way. i wonder why this isnt handling more of the automated functions, i suggest we consider moving the autopassphase into stateEffects() also as it will most likely be handled much better in there then in the update function.


also,
adjust Ailessons on Adrawer, it was still getting a little too excited about drawing cards. 
moved around the eff setting on grantingability lessons.
having it set to 0 BEFORE actually giving it a value was conter productive.

added a peice of commented out code in "isintop" function that if you uncomment will allow you to have Ai ALWAYS multiblock you.

im pushing this in as i feel comfortable with the positives and havent really come across an adverse effect yet.
however i am just one person and testing something like this is much easier with alot more then 1 person on it.
2010-12-07 17:58:46 +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
omegablast2002@yahoo.com
2aa47cd68b reverted the change i made, found specail cases where this cause bugs. 2010-11-24 14:40:06 +00:00
omegablast2002@yahoo.com
d1577ef35e corrected an issue where the player was being offered interupt 2 times for "combat damage" not closing the ticket until i can get some help verifying that it covers all cases where it might be true. 2010-11-24 13:46:27 +00:00
techdragon.nguyen@gmail.com
acd7bb1aa4 reformatting code according to guidelines defined at
http://wololo.net/forum/viewtopic.php?f=35&t=2235&start=10
2010-11-16 00:55:16 +00:00
techdragon.nguyen@gmail.com
0c34d7a04f removed dead code
reformatted statements
removed unnecessary debug statements
fixed a few floating point warnings
2010-11-06 03:49:15 +00:00
wrenczes@gmail.com
5a1e8e6ffe More reorganization work around CardSelector and the singleton pattern. Broke the source for the singleton into its own separate source file, to keep things clean. Also broke apart a circular header dependency: CardSelector defines and uses a SelectorZone, which is a member inside of CardView. CardView in turn is used heavily by CardSelector. Instead SelectorZone is now defined within CardView (where it's set & controlled anyway).
I've also added my current work on the zone navigation system (class Navigator) - it's currently turned off for now (the override for this is inside of CardSelectorSingleton's Instance() call, simply comment out the NEW CardSelector and uncomment out the NEW Navigator line.)  It's functional, but I want to do more testing before considering wiring it into the game options or something similar.  (Also, note that it currently doesn't support the mouse functionality added by DJardin.)

Lastly, there's a bug crash fix in ActionStack that I tripped across while testing - basically, an illegal index value would have us walk off the bounds of a vector.
2010-10-31 07:50:53 +00:00
wrenczes
d5f3e4cfea Enabled precompiled headers for the build. This cuts the win compile time in debug by at least half on my laptop; on the psp compile, it shaves it down by ~ 45 seconds. I only did a cursory inspection of what to add to PrecompiledHeader.h, there's probably more that we can throw in there for more incremental speed improvements.
Also fixed the project includes so that we don't need to always use the indirect include path, ie:
#include "../include/foo.h" -> #include "foo.h"

I'm don't know much about make files - if I busted the linux build, mea culpa, but I think we're okay on that front too.  For future reference, here's the most straightforward link on the topic of adding pch support to make files:

http://www.mercs-eng.com/~hulud/index.php?2008/06/13/6-writing-a-good-makefile-for-a-c-project
2010-10-24 05:55:24 +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
omegablast2002@yahoo.com
d13e8904b5 massive update, additions and changelog in first comment. 2010-10-18 10:46:36 +00:00
wrenczes@gmail.com
25cb9dde54 Cleaned up some compile warnings (double to float/ int to float conversions). 2010-10-13 23:34:36 +00:00
wagic.the.homebrew@gmail.com
f40af0b1cb Erwan
- Chinese patch by linshier
2010-07-31 14:41:04 +00:00
jean.chalard
32352161cc J :
* Fix a segfault case.
* Improve the trash system to handle several types more gracefully.
2010-06-13 14:03:02 +00:00
wagic.jeck
e9b6860923 Jeck - reverted fix for invalid issue 359. 2010-02-26 00:46:03 +00:00
wagic.jeck
5e0be442b0 Jeck - Removed "Reverse Triggers" option, as per issue 359. 2010-02-25 15:22:19 +00:00
jean.chalard
39c5a3d465 J :
* Fix u32 into JButtons.
* Add a few comments.
* Remove useless variables.
2010-02-24 17:28:17 +00:00
jean.chalard
56ce4a14ae J :
* Create the subsystem for keybindings.
2010-02-14 13:21:12 +00:00
wagic.the.homebrew@gmail.com
bd6c1a2407 Erwan
- fix compilation issues introduced in r1727
2010-01-18 12:43:30 +00:00
jean.chalard
aefc5f7b6e J :
* Fix the damage assignment interface to take Deathtouch into account.
* This addresses issue 32.
2009-12-16 15:29:44 +00:00
wagic.the.homebrew@gmail.com
f224dc0a25 ERwan
-fix issue 145 (double strike damages)
2009-12-03 15:02:34 +00:00
wagic.the.homebrew@gmail.com
9ca552093e Erwan
- Added "PreventAllCombatDamage" [from(...)] [to(...)] keyword. Please test it on a few cards before we "mass" use it. As a side effect, fixed issue 155 (ebony horse target).
2009-11-14 11:35:29 +00:00
wagic.the.homebrew@gmail.com
83bc12a275 Erwan
- Fix issue 102 (Rampage not working correctly)
2009-10-20 13:24:12 +00:00
wagic.the.homebrew@gmail.com
8c50e71b33 Erwan
- Fix a bug when a token would be removed from game while being an attacker or a blocker. Potentially fix issue 42
2009-10-16 14:41:27 +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.the.homebrew@gmail.com
ac120266a9 Erwan
-fix issue 48 (dragon claw endless ability list)
-switched incorrect unsigned int to size_t
2009-09-25 15:35:19 +00:00
wagic.the.homebrew@gmail.com
eabb99c675 Erwan
- fix armadillo cloak test + fix damage assignation step. A side effect is that when clicking on "Go", the game goes to the Damage step instead of going to the combat step. I believe this is acceptable but let me know if this feels weird when playing
- daily build
2009-09-25 13:38:08 +00:00
wagic.jeck
2020dce4fd Jeck - unsigned/signed fix, options fixes
* Abstracted out option calls to "f3" behind Constants::OPTION_FONT
 * Added option to disable card image loading.
2009-09-24 23:26:32 +00:00
jean.chalard
8d6f3567ed J :
* Fix interface (when a creature has trample and exactly one blocker,
  show the damage assignation screen)
2009-09-24 00:56:32 +00:00
jean.chalard
f907f39334 J :
* Affect overflowing damage.
* Reinstate Armadillo cloak test.
  . Note that this test does not work at the moment : my understanding
    is the TEST is wrong and not the implementation, but I'd like a
    double check before changing the test.
2009-09-23 16:22:56 +00:00
jean.chalard
28f93c035f J :
CAREFUL : this update REVERSES the triggers default actions.
* Make the right trigger opens the hand and the left trigger skips to
  next phase.
* Add an option to reverse triggers (and thus revert to old style).
2009-09-23 07:25:39 +00:00
wagic.the.homebrew@gmail.com
82551174d9 Erwan - Fix issue 30 (memory leaks in GuiCombat.cpp) 2009-09-23 06:56:05 +00:00
wagic.the.homebrew@gmail.com
71d4818646 Erwan
- Fix issue #16 (testsuite segfaults if file does not exist)
- Fix issue #37 (Normal Combat Damage is not dealt to creatures when the AI attacks)
- TestSuite now has an "AI" mode (see test/manual/p2_attacks.txt)
2009-09-22 06:15:32 +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
jean.chalard
ce39961d78 J :
* Fix the filename
2009-09-15 12:28:19 +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
1b468bde14 Jeck - Replaced ok_quad with ok_tex, which won't expire until the duel is over. 2009-09-14 21:09:58 +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.the.homebrew@gmail.com
7ce2c563e1 Erwan
- Fixed empty ActionStack "interrupt" messages
- If no attackers are declared, go straight to Combat end phase
- Once First strike damage is declared, attacking player needs to "actively" request a next phase event to go to the next damage step
- Second Damage step is called "Combat Damage (2)"
- UserRequestNextPhase is to be used knowing that it might not succeed
- Step change for GuiCombat is now computed at GameObserver::nextGamePhase

Note: Combat damage to creatures is not assigned when AI attacks. As this seems to be a problem with the previous SVN version, I4m still committing this change
2009-09-13 12:42:18 +00:00
jean.chalard
34d973c60d J :
* Create selection zones to remember the last card the cursor was on.
2009-09-12 12:57:50 +00:00
jean.chalard
ea92876d7b J :
* Fix a little memory leak.
2009-09-07 17:18:46 +00:00
jean.chalard
5b473a1505 J :
* Fix almost all tests.
* This version "nearly" works.
2009-09-07 14:37:32 +00:00
jean.chalard
74bd57cb55 J :
* Fix a bug where a creature dying would not leave the battlefield.
2009-09-05 15:38:01 +00:00
jean.chalard
e5b09cf5ec J :
* Fix a bug where combat damage would be wrongly assigned.
2009-09-05 15:05:16 +00:00
jean.chalard
2e7570fdea J :
* Add some pretty printers to help debugging.
2009-09-04 13:22:15 +00:00
wagic.jeck
f220d2e9b9 Jeck - Cache and resource manager merged, streamlined.
This is pretty major, so there'll probably be something wrong with it... even though I did spend a few hours looking.
NOTES:
 * If you've Retrieved it, don't delete it--- Use resources.Release(Whatever). 
    Textures automatically release subordinate quads.
 * Most of the time, use resources.RetrieveQuad to grab a quad. Should handle everything for you.
    RetrieveQuad will load the required texture, if needed.
    Only managed resources have a resource name ("back", "simon", etc). 
    Managed resources can be retrieved with GetTexture/GetQuad/GetWhatever.
    Non managed quads lookup by position/dimensions, defaulting to the whole texture.
 * Use resources.RetrieveTexture only when you need to do something special to it. 
    Calling retrieve texture with RETRIEVE_MANAGE will permanently add a texture to the manager
    RETRIEVE_LOCK and RETRIEVE_VRAM will lock a texture. It will not leave the cache until
    Release(JTexture*) is called, or as a last resort during cache overflow.
 * Try to only store (as a class member) pointers to textures retrieved with RETRIEVE_MANAGE. 
    All others may become invalid, although locked textures do have a high degree of stability. It's
    pretty safe to store a locked texture if you're not going to load much between uses.

There's a lot going on here, so I might have missed something... but it runs through the test suite alright.

TODO: 
 * When called without any arguments, RetrieveQuad sometimes leaves a thin border around the image. 
    This can be bypassed by specifying a quad one or two pixels less than the image size. Why?
 * I've had a crash while runing the Demo mode, something to do with receiveEventMinus? 
    This hasn't exactly reproduced on a clean SVN copy, (being a hang, rather than a crash) so 
    I've probably done something to worsen the problem somehow? I'll look into it tomorrow.
 * Clean up lock/unlock system, memory usage. Streamline interface, consider phasing out calls using GetWhatever() format.
2009-09-03 09:28:16 +00:00