855 Commits

Author SHA1 Message Date
xawotihs
ab34d0d366 Removed Werror to work around a bug in the PSP cross-compiler. 2015-08-29 20:31:56 +02:00
xawotihs
963ab2840b Should fix cross-compilation issue on PSP. 2015-08-29 19:23:07 +02:00
xawotihs
a25b010429 Merge branch 'master' into minmax 2015-08-28 23:48:54 +02:00
xawotihs
504160a740 Latest min-max branch 2015-08-25 23:29:58 +02:00
xawotihs
5061f7c37f Merge branch 'master' into minmax 2015-08-25 22:41:44 +02:00
Xawotihs
30f5a49988 Merge pull request #614 from kevlahnota/master
added FRF
2015-08-24 17:56:32 +02:00
Anthony Calosa
2998e95a3b tokenizer should work now for cloning ability
Populate(Put a token onto the battlefield that's a copy of a creature
token you control.)
2015-08-24 22:39:54 +08:00
Anthony Calosa
ac29367ff8 update _tests.txt 2015-08-24 10:05:05 +08:00
Anthony Calosa
dbd7f82eab added tokenizer test 2015-08-24 10:03:34 +08:00
Anthony Calosa
176b74489e added parallel lives
support token doubler... :)
2015-08-23 21:56:23 +08:00
Anthony Calosa
f940f8e303 some corrections
added Induce Paranoia, Draining Whelk
2015-08-22 23:40:31 +08:00
Anthony Calosa
2679213121 added FRF 2015-08-21 17:38:15 +08:00
Anthony Calosa
59c0cf467f serum powder code
serum powder second ability...
Any time you could mulligan and Serum Powder is in your hand, you may
exile all the cards from your hand, then draw that many cards.
2015-08-20 23:11:44 +08:00
Anthony Calosa
5a2637856f Merge remote-tracking branch 'WagicProject/master' 2015-08-20 23:09:12 +08:00
Anthony Calosa
26ecb199d3 Merge remote-tracking branch 'WagicProject/master' 2015-08-20 23:00:56 +08:00
Xawotihs
62d42fb61f Removed local check of mac branch 2015-08-17 23:53:11 +02:00
Xawotihs
19c96e496b More debug 2015-08-17 23:03:53 +02:00
Xawotihs
e982ba50be Removed a suspicous $ from the mac script 2015-08-17 22:27:39 +02:00
Xawotihs
27ad956034 More debug of the mac script 2015-08-17 21:57:29 +02:00
Xawotihs
8c6f694645 Replaced suspicious test 2015-08-16 21:11:41 +02:00
Xawotihs
8ce85636d9 More debug 2015-08-16 20:52:10 +02:00
Xawotihs
07683480b4 build => release => tag => build ... 2015-08-16 18:41:36 +02:00
Xawotihs
7d8fdbfd58 Restored branch removal and added some debug 2015-08-16 18:24:57 +02:00
Xawotihs
2a1cb03484 OMG what a stupid typo 2015-08-16 18:02:22 +02:00
Anthony Calosa
baa90fb605 added Ral Zarek 2015-08-16 14:57:34 +08:00
Anthony Calosa
1b67b736df Merge remote-tracking branch 'WagicProject/master' 2015-08-16 14:29:44 +08:00
Anthony Calosa
e6514a8b33 added gravecrawler
gravecrawler is supported :)
2015-08-16 14:17:26 +08:00
Xawotihs
636b07b350 Try to fix macosx branch deletion 2015-08-15 23:29:47 +02:00
Xawotihs
4b5478530c Merge pull request #612 from kevlahnota/master
Support of "formidable" abilities, added JOU, THS, M14 and fixed various cards.
2015-08-15 21:00:12 +02:00
Anthony Calosa
4a721a7e18 added KTK cards 2015-08-15 23:41:31 +08:00
Anthony Calosa
2470629afd Merge remote-tracking branch 'WagicProject/master' 2015-08-15 22:23:00 +08:00
Anthony Calosa
ccdd16bbc7 Used proper constant 2015-08-15 19:13:48 +08:00
Anthony Calosa
9cf6e621ab Removes viewing of tokens (rarity with T) on Spoiler 2015-08-15 14:51:26 +08:00
Anthony Calosa
94a97a3032 give credits
thanks KF1 and Tacoghandi
2015-08-15 08:18:35 +08:00
Anthony Calosa
f4ef7b9851 added M14 cards 2015-08-15 08:17:21 +08:00
Anthony Calosa
c2be7dd025 Fix M14 card dat 2015-08-15 08:07:36 +08:00
Anthony Calosa
b51dfc7733 added THS cards 2015-08-14 13:19:05 +08:00
Anthony Calosa
9999820a8f added missing cards from theros block 2015-08-13 23:19:20 +08:00
Anthony Calosa
10bc8283ed added JOU cards 2015-08-12 22:40:24 +08:00
Anthony Calosa
66f3ba5a7b removed id collision
avatar token already defined below ajani goldmane
2015-08-12 21:38:19 +08:00
Anthony Calosa
07f0175c5e fix bad line 2015-08-12 21:33:46 +08:00
Anthony Calosa
7376ac382f added missing copy cards 2015-08-12 20:53:30 +08:00
Anthony Calosa
3646219da4 Added missing devotion cards 2015-08-12 20:46:23 +08:00
Anthony Calosa
bfbc073593 added cards 2015-08-12 20:23:46 +08:00
Anthony Calosa
307be96fd6 Added Formidable cards 2015-08-12 20:16:07 +08:00
Anthony Calosa
22f4f21619 Added missing sets 2015-08-12 18:20:03 +08:00
Anthony Calosa
1738e216d0 Delete JOU 2015-08-12 18:05:45 +08:00
Anthony Calosa
567650357f Create JOU 2015-08-12 18:03:46 +08:00
Anthony Calosa
32de6ac124 Minor primitives correction
corrected some typo and added some cards
2015-08-12 17:32:42 +08:00
Anthony Calosa
60f3c87de1 Count Total Power of Creatures you control
example usage:  auto={4}{G}:4/4
restriction{compare(powertotalinplay)~morethan~7}
2015-08-10 22:44:27 +08:00
Xawotihs
d9561118bc Update appveyor.yml
Skip building macosx environment on windows
2015-07-20 22:32:25 +02:00
Xawotihs
228e5342fb Merge pull request #609 from WagicProject/CI-fixes
Ci fixes
2015-07-11 23:47:44 +02:00
Xawotihs
8574154071 Update .travis.yml 2015-07-11 21:58:30 +02:00
Xawotihs
80379ecde5 Update .travis.yml 2015-07-11 21:52:20 +02:00
Xawotihs
31b8ad248f Update .travis.yml
Fixed references to SDK package
2015-07-11 20:03:37 +02:00
Xawotihs
2d02f97f7f Update .travis.yml
Updated android SDK to 24.3.3
2015-07-11 18:51:11 +02:00
Xawotihs
6a37b5e461 Update .travis.yml
And a last one.
2015-07-11 18:36:34 +02:00
Xawotihs
38ed60bf63 Update .travis.yml
Add some \ to try fixing the script
2015-07-11 18:27:23 +02:00
Xawotihs
e664ecfaf5 Update .travis.yml
Updated android build tools to 22.0.1
2015-07-11 18:05:39 +02:00
Xawotihs
e2814c04f4 Merge pull request #607 from WagicProject/coverage
Adds test code coverage support
2014-12-31 13:57:14 +01:00
Xawotihs
8c2836b0c2 Update README.md
Added coverage status
2014-12-29 15:04:00 +01:00
Xawotihs
fcfab4c756 Update .travis.yml
Removed traces
2014-12-27 13:43:38 +01:00
Xawotihs
ddd59c489a Update .travis.yml
trying to fix gcov root
2014-12-27 12:17:03 +01:00
xawotihs
db922a0e77 Activated perf logs with qt console config 2014-12-27 11:47:54 +01:00
Xawotihs
793c4d1d7d Update .travis.yml
Added some traces
2014-12-27 10:39:16 +01:00
Xawotihs
24eab33b6d Update .travis.yml
updating coveralls options
2014-12-27 02:07:38 +01:00
Xawotihs
4985323ad9 Update .travis.yml
Tweaked coveralls config
2014-12-27 01:29:58 +01:00
Xawotihs
9fc551982b Update .travis.yml
Updated android sdk version
2014-12-26 21:23:11 +01:00
xawotihs
8ee67b5af8 Adds coverage support 2014-12-21 22:49:47 +01:00
xawotihs
78ad22479c Added changelog file 2014-12-09 22:18:51 +01:00
Xawotihs
2041aa45f0 Reactivated PSP build 2014-12-08 20:52:04 +01:00
xawotihs
c8b0ce9669 added sudo to install python packages on macosx 2014-12-08 00:10:48 +01:00
xawotihs
11eb6de57e Changed token and redirect push output 2014-12-07 23:33:46 +01:00
xawotihs
c451234bd5 Moved definition of origin 2014-12-07 22:47:04 +01:00
xawotihs
b56862fcf8 Added python dependencies, replaced token and removed "x" option in shell scripts 2014-12-07 22:26:39 +01:00
xawotihs
21a6da91ca Added git remote URL as HTTPS 2014-12-07 21:48:50 +01:00
xawotihs
410108a005 Added email and name to enable git commit 2014-12-07 21:06:53 +01:00
xawotihs
51d5b166a6 Deactivated PSP build and refactored build conditions 2014-12-07 20:29:27 +01:00
xawotihs
1f77243881 Fixed mac build script 2014-12-07 19:48:53 +01:00
xawotihs
f63afb2dd6 Merge branch 'mac-build' 2014-12-07 17:55:25 +01:00
xawotihs
dbe1c6e2ae Moved mac travis file outside of script and update oauth token 2014-12-07 17:26:32 +01:00
xawotihs
6a37425a38 Changed number of processes to 4 2014-12-07 16:48:57 +01:00
xawotihs
02efa4745f Fixed access to mac script and added mac branch to the list of branch authorized to upload binaries 2014-12-07 16:39:15 +01:00
xawotihs
e78754bcd5 Fixed mac script call 2014-12-07 16:24:39 +01:00
xawotihs
16dcf3cc5e - Moved scripts in tools directory
- Added a Mac cross-compiling script
2014-12-07 16:02:56 +01:00
xawotihs
03d168f972 Added MacOS bundle creation in Qt .pro file 2014-12-06 15:13:45 +01:00
Xawotihs
6f6c8b0eb6 Merge pull request #606 from kevlahnota/master
Fix for guild_keywords Devotion, added some "Chroma" cards
2014-12-05 07:47:37 +01:00
Anthony Calosa
fa14219e12 Fix for Devotion, added some "Chroma" cards 2014-12-05 10:18:05 +08:00
Xawotihs
15cd86fad1 Add traces at the end of the upload 2014-12-04 22:51:38 +01:00
Xawotihs
56ccebb720 Merge pull request #605 from kevlahnota/master
added guild keywords, added specific life cost
2014-12-03 07:37:55 +01:00
Anthony Calosa
8ef3789970 reverted sacred foundry 2014-12-03 07:54:13 +08:00
Anthony Calosa
ed7769c373 Revert "update sacred_foundry_i275.txt"
This reverts commit 5745006c35.
2014-12-03 07:47:00 +08:00
Anthony Calosa
5745006c35 update sacred_foundry_i275.txt 2014-12-02 19:19:05 +08:00
Anthony Calosa
16b243c52a Added bng cards to the main primitives. Removed bngGods.txt 2014-12-02 10:39:53 +08:00
Anthony Calosa
bc91eaf5ca updated card primitives that supports specific life cost 2014-11-29 07:10:02 +08:00
Anthony Calosa
6962d1e888 added cards, needs more testing before merging with the main primitives 2014-11-29 06:58:33 +08:00
Anthony Calosa
4d1e8dfb36 Update bngGods.txt
9/15/2013 	The type-changing ability that can make the God not be a creature functions only on the battlefield. It’s always a creature card in other zones, regardless of your devotion to its color.
2014-11-28 15:31:24 +08:00
Anthony Calosa
6ff6f95044 added Xenagos, God of Revels and Phenax, God of Deception for test purpose. 2014-11-28 14:34:37 +08:00
Anthony Calosa
5369983b35 Added BNG set 2014-11-28 14:19:04 +08:00
Anthony Calosa
46a8041c48 Added guild keyword gruul test for Xenagos, God of Revels. You must have Born of the gods set (BNG) 2014-11-28 14:00:58 +08:00
Anthony Calosa
84185a7c78 Added specific life cost test for griselbrand. Pls read note. 2014-11-28 13:35:13 +08:00
Anthony Calosa
4f41248978 Added specific life cost. if we use {l}{l}{l} to pay 3 life, and you have 2 life, you cannot afford to pay the cost but instead the game allows it. if we use specific life cost like: {l:3}, the restriction works. 2014-11-27 14:38:55 +08:00
Anthony Calosa
92d52a78be Update ExtraCost.cpp 2014-11-27 14:33:43 +08:00
Anthony Calosa
a76594046b Update ExtraCost.h 2014-11-27 14:31:25 +08:00
kevlahnota
2214ec66f1 Update AllAbilities.h
keywords for the "gods", "azorius" returns value of devotion to blue and white. ex. auto=azorius/dimir ueot
2014-11-27 11:31:19 +08:00
xawotihs
b8da46ac18 Fixed phonon support. 2014-11-23 16:27:18 +01:00
xawotihs
d656730d3a Fixed phonon support 2014-11-23 16:24:36 +01:00
xawotihs
2f230e4b38 Added buyback.txt to the list of automatic tests 2014-11-23 16:23:18 +01:00
xawotihs
494f64acbd Merge branch 'apollovy-master' 2014-11-23 14:32:02 +01:00
xawotihs
50978200d4 Merge branch 'master' of https://github.com/apollovy/wagic into apollovy-master 2014-11-23 14:30:17 +01:00
xawotihs
a38e1daec7 Updated Android build tools to 21.1.1 2014-11-23 12:44:22 +01:00
Yuriy A. Apollov
57a26b4583 Add test for buyback case. 2014-11-18 06:58:38 +03:00
Yuriy A. Apollov
c018c8fcd1 Fix buyback payed once stayed forever. 2014-11-18 06:51:40 +03:00
xawotihs
3ba4aca8bc Fixed stupid bug in python release creation 2014-08-25 22:16:12 +02:00
xawotihs
870f6e3b58 Fixed python typo 2014-08-25 00:27:40 +02:00
xawotihs
83e0869548 Updated python upload code to re-create new release 'latest-master' for each master commit 2014-08-25 00:02:46 +02:00
xawotihs
90b08db038 Updated travis to use python uploading script 2014-08-24 19:45:18 +02:00
xawotihs
c888e143a1 Fixed python typo 2014-08-24 18:46:42 +02:00
xawotihs
4e727bc164 Fixed python typo 2014-08-24 18:23:08 +02:00
xawotihs
b37afadb01 Fixed typo. 2014-08-24 17:59:04 +02:00
xawotihs
2c2744f6fb Fixed python issue 2014-08-24 17:40:05 +02:00
xawotihs
db2b2fa3b5 Replaced \ by / 2014-08-24 17:07:00 +02:00
xawotihs
0127f7aab9 Tries to activate automatic artifact deployment to github release from appveyor 2014-08-24 16:07:26 +02:00
Xawotihs
ce41791fa4 Remove broken comments 2014-08-23 09:36:46 +02:00
Xawotihs
ec4be4f6b1 Uses real python path 2014-08-23 00:53:33 +02:00
Xawotihs
f82d89b3db Removed empty environment section 2014-08-23 00:47:30 +02:00
xawotihs
202175f2a7 First appveyor script and python windows package build file 2014-08-22 23:26:03 +02:00
xawotihs
165eb699e8 Fixed and activated redo in testsuite 2014-08-17 16:31:21 +02:00
xawotihs
33760f4066 Add minmax in Qt project, fixed small issue in later qtMultimedia code 2014-08-08 18:08:13 +02:00
xawotihs
656ab78cf5 Merge branch 'master' into minmax 2014-08-07 22:29:41 +02:00
xawotihs
d7628b3eb2 Fixed console with Qtmultimedia 2014-08-03 12:20:45 +02:00
Xawotihs
7560db571c Trying without HTTPS to speed up SDK update 2014-08-03 11:43:55 +02:00
Xawotihs
775143355d Add lib pulse-dev 2014-08-03 01:51:41 +02:00
Xawotihs
846ba30821 Tries to fix android sdk update issue 2014-08-03 01:34:53 +02:00
Xawotihs
ad88592229 Replaced pulse-dev with pulseaudio 2014-08-02 23:44:40 +02:00
Xawotihs
6b90956af1 Adding pulse 2014-08-02 23:35:25 +02:00
Xawotihs
26e905a36e Update Androi build tools to 20.0.0 2014-08-02 23:16:22 +02:00
xawotihs
1a9ff38f0c Merge branch 'qtMultimedia' of https://github.com/WagicProject/wagic into qtMultimedia 2014-08-02 21:07:12 +02:00
xawotihs
8b22d032cd Fixed QT version needed for pixelRatio API 2014-08-02 21:05:55 +02:00
Xawotihs
8d58baf4a3 adding qtmultimedia in apt-get 2014-08-02 19:38:11 +02:00
Xawotihs
a447a0c9af Trying with --all 2014-08-02 19:22:38 +02:00
xawotihs
555fb3ae93 Updated Qt building scripts to use qt5 qmake and no fmod 2014-08-02 18:54:28 +02:00
Xawotihs
7053531a4d Added qmake qt5 configuration 2014-08-02 18:37:53 +02:00
Xawotihs
7d4e5177b9 Reordered actions from install to before_install 2014-08-02 18:15:45 +02:00
Xawotihs
06f30eca3a Upgraded travis to use qt5 2014-08-02 17:50:45 +02:00
xawotihs
ac5c14b977 Fixed QtMultimedia port, replaced QSoundEffect by QMediaPlayer as all codecs were not supported by first class. 2014-08-02 17:12:19 +02:00
xawotihs
c3d810bd3b Merge branch 'master' into qtMultimedia 2014-08-02 16:16:19 +02:00
xawotihs
1e24f25c18 Fixed repository against Qt5.3.1 2014-08-02 15:56:52 +02:00
xawotihs
28db884498 Cleaned up cross-compiling travis stuff 2014-07-26 19:45:59 +02:00
xawotihs
36ecc1ffef Cleaned up cross-compiling travis stuff 2014-07-26 19:38:14 +02:00
Xawotihs
9ec6803a02 Merge pull request #602 from WagicProject/feature/ios-update-xcode5.1
Feature/ios update xcode5.1
2014-07-24 23:08:39 +02:00
xawotihs
e87996a7f2 Deactivate window cross-compiling build 2014-07-23 23:20:54 +02:00
xawotihs
f2a5273029 Activating logs on android issue 2014-07-23 22:22:06 +02:00
xawotihs
9bc750da9a Upgrade Android SDK to r23.0.2 2014-07-23 22:05:02 +02:00
Xawotihs
539c5bd18a Trying to fix android build 2014-07-23 20:53:25 +02:00
Xawotihs
bdc1ada090 Update README.md
Added build status on AppVeyor
2014-07-23 00:17:07 +02:00
Michael Nguyen
2efc24a1ce Merge branch 'develop' into feature/ios-update-xcode5.1 2014-04-13 11:50:16 -07:00
Michael Nguyen
63561e6122 update Xcode build preferences as recommended by XCode. 2014-04-13 11:39:40 -07:00
Michael Nguyen
d2390b1227 updated project file for iOS to work with current codebase
- added missing source/headers (GameView.h, CarouselView.h, etc )
- removed dependency on admob static library
- removed CardEffect.h and CardEffect.cpp from project reference
- removed -no_implicit_dylibs flag (apparently no longer supported)
- added -fno-objc-arc (turns off ARC compilation for entire project)
- added -DTIXML_USE_STL
2014-04-13 08:34:21 -07:00
Michael Nguyen
d0799ea3f2 updating to latest code from master
Merge branch 'master' into develop
2014-04-13 08:26:53 -07:00
Xawotihs
44cbfbb1fb Merge pull request #601 from ZobyTwo/cleanup_3
Remove dead code and fix circular initialization
2014-03-13 20:20:12 +01:00
Tobias Loose
b078dd1f6a Fix android makefile 2014-03-11 17:31:25 +01:00
Tobias Loose
225dd23753 Fix makefile 2014-03-11 17:19:05 +01:00
Rolzad73
51b4755242 Update README.md
Added sample play-through video link
2014-02-05 23:39:57 -05:00
Tobias Loose
8f233b3027 Avoid circular initialization 2014-02-03 19:44:51 +01:00
Tobias Loose
197540763e Remove unused Effects.h/.cpp and class Effect
There was an empty vector of effect* in PlayGuiObject.
2014-02-03 13:52:40 +01:00
xawotihs
5d7667dc01 Cleaned Phonon vs QtMultimedia config 2014-01-31 21:53:27 +01:00
xawotihs
18383579e9 Fixed android compilation 2014-01-27 06:31:23 +01:00
xawotihs
03d4f8ffa1 Added Qt Multimedia support in order to replace Phonon. Currently does not work on Mac. 2014-01-26 23:56:15 +01:00
xawotihs
541698f98e Merge branch 'master' into minmax 2014-01-24 23:49:30 +01:00
xawotihs
30d92eb68c Should fix issue #497 with the broken freezing the game. 2014-01-18 22:50:16 +01:00
xawotihs
6e6a0fd5c2 OMG I so hate shells 2014-01-18 16:00:14 +01:00
xawotihs
cd4a980182 More debug 2014-01-18 15:26:09 +01:00
xawotihs
aad54fd98d Adds debug in build script 2014-01-18 14:57:23 +01:00
xawotihs
6b7a49506c Should fix the stringifying issue 2014-01-18 14:23:26 +01:00
xawotihs
7ecf67c176 And again 2014-01-18 13:37:43 +01:00
xawotihs
77aeb2d0ac Fixed release name 2014-01-18 13:29:50 +01:00
xawotihs
7a9f989104 Adds some URL error log 2014-01-18 12:46:27 +01:00
xawotihs
ae06bebd24 Merge branch 'github_downloader' 2014-01-18 12:11:08 +01:00
xawotihs
042fb7b376 Tries to fix Android compilation 2014-01-18 11:18:27 +01:00
xawotihs
c3583ade01 Updated resource name and URL for android project 2014-01-17 23:25:48 +01:00
xawotihs
f97d9805dd Removed build number in released filename and added computation of resource URL based on release name. 2014-01-17 21:50:10 +01:00
xawotihs
1d33de59a9 Fixed compilation issue 2014-01-12 22:56:53 +01:00
xawotihs
0c4b09891b Removed hardcoded testing values and used 32 bits file size instead of 64 bits. 2014-01-12 22:40:45 +01:00
xawotihs
25955303e7 Adds a Downloader component to JGE able to download and cache files. 2014-01-12 22:16:35 +01:00
Rolzad73
27b75eecb0 Merge pull request #600 from WagicProject/android_build_update
update android build tools version
2014-01-09 12:33:11 -08:00
Rolzad73
e40921cf13 update android build tools version 2014-01-09 14:57:06 -05:00
Rolzad73
083cebcc7e updated credits text 2014-01-09 14:46:58 -05:00
Rolzad73
a722736335 Merge pull request #599 from WagicProject/android_travis_explicit
Attempt to make android tools fetching for TravisCI explicit and futureproof
2014-01-08 08:40:47 -08:00
Rolzad73
c483c20c81 attempt to make android tools fetching for TravisCI explicit and futureproof 2014-01-08 11:14:47 -05:00
Dmitry Panin
dec1caa43c Revert "Fixed issue with multiple basic abilities in TargetChooser"
This reverts commit d9816c7ad0.
2014-01-04 18:40:59 -08:00
Dmitry Panin
9526e22118 Fixed grave pact 2014-01-04 18:14:15 -08:00
Dmitry Panin
d9816c7ad0 Fixed issue with multiple basic abilities in TargetChooser
E.g. card create[trample;haste] wasn't handled properly
2014-01-04 18:13:22 -08:00
Dmitry Panin
8e327a27df Fixed formatting 2014-01-04 18:13:22 -08:00
xawotihs
43fe67d7d8 Adds executioners_swing tests in _tests.txt 2013-12-31 18:38:30 +01:00
Xawotihs
a63991bb4e Merge pull request #598 from bjornsnoen/master
Damager keyword
2013-12-31 09:11:20 -08:00
xawotihs
b09db0c60f Removed c++11 warning. 2013-12-22 21:26:06 +01:00
Bjørn Snoen
928ca3497a More code compliance. New tests. 2013-12-21 19:31:32 +01:00
Bjørn Snoen
60219411f6 Coding style compliance 2013-12-21 14:33:44 +01:00
Bjørn Snoen
642f5bb515 Fixed indentation mistakes 2013-12-21 11:18:18 +01:00
Bjørn Snoen
20e878a102 Made damager keyword work. Fixed Executioner's Swing in mtg.txt 2013-12-21 11:05:15 +01:00
xawotihs
da31371d86 Include c++11 threading 2013-12-20 18:39:02 +01:00
xawotihs
0df408793a Tries to fix android sdk installation in Travis 2013-12-20 14:09:30 +01:00
xawotihs
9630bcd56b Removed file wrongly added. 2013-12-20 12:37:25 +01:00
xawotihs
3c38e21b25 Merge branch 'master' into Qt5.2_macx 2013-12-20 11:14:10 +01:00
xawotihs
caec886e22 Fixed issues found by XCode. 2013-12-20 00:24:08 +01:00
Dmitry Panin
927f8955e9 Merge pull request #596 from bjornsnoen/master
Fix a rarity mistake and a grammatical error
2013-12-19 02:44:38 -08:00
Bjørn Snoen
d4e0296d2b Fixed wrong rarity on millstone in M14 2013-12-18 09:37:20 +01:00
Bjørn Snoen
8eb664f93d Fixed grammatical then/than error. 2013-12-18 05:50:30 +01:00
xawotihs
b180c3d1a7 Fixed Qt5 mingw32 build 2013-12-16 22:11:28 +01:00
Dmitry Panin
db9f18a644 Added _cards.dat for M14 (taken from forum) 2013-12-15 22:39:08 +04:00
xawotihs
95805ea387 Fixed QT mingw cross compile with QT4.8 2013-12-15 00:26:04 +01:00
xawotihs
4765890d0a Fixed mouse input with retina display 2013-12-14 23:46:23 +01:00
Xawotihs
2e13f29945 Update README.md 2013-12-14 19:13:26 +01:00
xawotihs
22b1c3b5d8 Fixed zip permission while rezipping PSP package 2013-12-14 14:40:26 +01:00
xawotihs
c7bae65697 Fixed core unzip 2013-12-14 13:18:11 +01:00
xawotihs
2381f0306c Fixed paths 2013-12-14 12:06:51 +01:00
xawotihs
b12e15e4ff Tries to arrange a bit the PSP binary package to make it more usual for users. 2013-12-14 11:55:12 +01:00
xawotihs
9e21751e12 Fixed windows build upload 2013-12-13 22:54:40 +01:00
xawotihs
db60c38eda Added windows build 2013-12-13 23:07:17 +01:00
xawotihs
1a4327a2e6 Fixed mingw32 build linking 2013-12-13 21:54:43 +01:00
xawotihs
88095c67b8 Fixed mingw32 compilation 2013-12-13 21:27:40 +01:00
xawotihs
ec34380668 Fixed mingw gcc package name 2013-12-13 00:12:32 +01:00
xawotihs
89dcd6c71d Added some windows cross compiling of the Qt flavor. 2013-12-12 17:54:43 -05:00
Dmitry Panin
fd3cf574cf Remove previous tag "latest-master" before uploading new one 2013-12-12 21:08:39 +04:00
Dmitry Panin
f21452feec Fixed some Cards:
Rune-Tail, Kitsune Ascendant
Shifting Sky
Flourishing Defenses (thanks to Shadowfireomega)
2013-12-12 20:11:35 +04:00
Dmitry Panin
0f85471216 Enabled automatic releases for each commit in master 2013-12-12 02:20:14 +04:00
Tobias Loose
5d92553017 Fix bug where the phase wheel got out of sync
The phase wheel messures phases within another unit and not
mtg phases. It is important to map between those
2013-12-11 01:53:05 +01:00
xawotihs
f0e6d820c7 Fixed GuiPhaseBar logics. 2013-12-10 22:23:28 +01:00
xawotihs
545fc21260 Merge branch 'more_easing' of https://github.com/ZobyTwo/wagic into ZobyTwo-more_easing 2013-12-10 20:35:47 +01:00
Xawotihs
8b68568106 Merge pull request #585 from bjornsnoen/master
Added Avatar Tokens created by Ajani Goldmane.
2013-12-10 11:12:33 -08:00
xawotihs
739a5d9e2b Removed env traces and change the secure token as it was exposed. 2013-12-09 22:39:25 +01:00
Tobias Loose
4c627f74b6 Add easing to GuiPhaseBar, simplify math a bit. 2013-12-09 22:20:43 +01:00
Tobias Loose
1e610ff653 Add InQuadEasing and OutQuadEasing and make tasklists...
easing more natural
2013-12-09 22:20:43 +01:00
Tobias Loose
5d6557a49f Add easing to task list and fix a bug where
opening the task list a second time was not possible
2013-12-09 22:20:43 +01:00
xawotihs
7528329a58 Add more debug in travis script 2013-12-09 21:54:55 +01:00
xawotihs
c62597dce5 Add some debugging to Travis script 2013-12-09 21:43:26 +01:00
Xawotihs
d8dfcdba67 Merge pull request #583 from ZobyTwo/deck_viewer_1
Cleanup, usability fixes and source code documentation for DeckView.h and GridDeckView.h
2013-12-09 11:51:40 -08:00
Bjørn Snoen
7b5f00260b Added Avatar Tokens created by Ajani Goldmane. 2013-12-09 16:55:31 +01:00
Tobias Loose
f9dc551942 Fix logic error in grid view 2013-12-08 23:05:06 +01:00
Tobias Loose
718ceca919 Do not allow that the selection moves outside in grid view. 2013-12-08 22:43:03 +01:00
xawotihs
89fb76a8e7 Updated scripts to remove any modified artifacts from Res directory.
Not doing it causes side effects on the testsuite.
2013-12-08 12:16:25 +01:00
Tobias Loose
1cc65ab611 Enable rotating over multiple filters, add src code doc 2013-12-08 12:03:13 +01:00
xawotihs
3b22354ad9 Fixed testsuite 2013-12-08 11:36:18 +01:00
Tobias Loose
2b9977a334 Rename methods for consistency and add source code doc
to DeckView.h
2013-12-08 10:48:15 +01:00
Tobias Loose
12c5f31562 Add a buttonMode to grid view to enable it on pointerless devices. 2013-12-08 09:11:44 +01:00
xawotihs
8cfd887375 Fixed upload script 2013-12-08 01:10:29 +01:00
xawotihs
292bf7b1d2 Merge branch 'ci_upload_binaries' 2013-12-08 00:33:42 +01:00
xawotihs
4041fe690b Create a release and parse its ID using jq. 2013-12-08 00:16:52 +01:00
xawotihs
cb73e2b90d Merge branch 'master' into ci_upload_binaries
Fixed Windows compilation.
2013-12-07 22:08:54 +01:00
ZobyTwo
a1fa36a934 Merge pull request #578 from ZobyTwo/deck_viewer_1
Reset positions and filters when reopening the editor. These changes are trivial so I will merge them.
2013-12-07 11:53:16 -08:00
Tobias Loose
bdd0e6c042 Reset positions and filters when reopening the editor 2013-12-07 20:47:50 +01:00
xawotihs
ee217e94a8 Fixed carousel pull request with Visual Studio. 2013-12-07 20:29:42 +01:00
xawotihs
38e19f7d35 Removed mingw32-qt
Merged SDL and QT .pro files
Removed glu dependency in corewrapper and JGfx to enable mingw cross compilation.
2013-12-07 18:57:57 +01:00
xawotihs
0bbfd00d15 Tries to install mingw32-qt on Travis 2013-12-07 18:31:02 +01:00
Tobias Loose
aaceb3c038 Remove unused declaration 2013-12-07 13:33:16 +01:00
Tobias Loose
5efa7e10bd Remove test debug output. Fix HUD fading. 2013-12-07 13:01:14 +01:00
Tobias Loose
14c164364e Cleanups and state reduction.
This mainly moves datamembers around and tries to avoid caching of
results of calculations when the calculations are cheap.
2013-12-07 12:58:20 +01:00
Tobias Loose
4514725aba Make the eased value a reference and add source code doc to Easing.h
This allows to apply multiple easings to the same variable.
2013-12-07 10:05:26 +01:00
Tobias Loose
2b0f50bb88 Remove redundancy and make control flow a bit simpler 2013-12-07 09:04:24 +01:00
xawotihs
a65fc0c0f0 Merge branch 'master' into ci_upload_binaries
sudo pip installation of pyjavaproperties
2013-12-06 22:52:32 +01:00
xawotihs
99db363253 Uses pip to install pyjavaproperties 2013-12-06 22:41:09 +01:00
xawotihs
c25dfec67e Fixed python module installation 2013-12-06 22:17:19 +01:00
xawotihs
dd7210d187 Install pyjavaproperties in travis. 2013-12-06 21:59:29 +01:00
xawotihs
904b7a6d86 Build and upload core resource package 2013-12-06 21:21:01 +01:00
Tobias Loose
31b353c5ec Use easing within the carousel view sliding 2013-12-06 21:04:21 +01:00
Tobias Loose
0d350af1b6 Use easing within the carousel views scrolling
It is visible if you scroll more than one card
2013-12-06 20:51:18 +01:00
xawotihs
3bc9c93bab Build and upload PSP binary archive. 2013-12-06 20:40:02 +01:00
Tobias Loose
2002bb4e16 Fix crash that occured when opening the editor a second time 2013-12-06 20:13:30 +01:00
Tobias Loose
7e9c4ddbdd Fix logic error in optimization introduced in last commit 2013-12-06 19:53:38 +01:00
Tobias Loose
12b71de63c Render small cards as thumbnails 2013-12-06 19:51:42 +01:00
Tobias Loose
15011961f4 Do only prefetch cards if resource management is threaded 2013-12-06 16:43:09 +01:00
xawotihs
b851103711 Commented out the release creation and refered an existing release instead. 2013-12-06 00:47:24 +01:00
xawotihs
67b8af8d15 Merge branch 'ci_upload_binaries' of https://github.com/WagicProject/wagic into ci_upload_binaries 2013-12-06 00:41:16 +01:00
xawotihs
8100e390b1 I'm starting to understand the stuff, the upload only works with a releaseId... 2013-12-06 00:10:36 +01:00
Tobias Loose
72e6876001 Remove temporary and binary files 2013-12-05 23:57:03 +01:00
Tobias Loose
96aeaffa1b Style and logic error. 2013-12-05 23:33:43 +01:00
xawotihs
74faa35b91 Removed useless local file copy before upload. 2013-12-05 23:27:40 +01:00
Tobias Loose
8bb58ca3b1 Put boilerplate code into easing base class 2013-12-05 23:27:28 +01:00
Tobias Loose
93d1a637b6 Style guide 2013-12-05 23:22:50 +01:00
xawotihs
30e86ffcd8 Update script to handle better variables. 2013-12-05 23:09:06 +01:00
Tobias Loose
cbe6c0c842 Parameterize animations in grid deck view 2013-12-05 23:06:32 +01:00
Tobias Loose
77eb7f2777 Add missing header 2013-12-05 23:06:32 +01:00
Tobias Loose
077ab10c05 Rename Button to ButtonPressed 2013-12-05 23:06:32 +01:00
Tobias Loose
1194463349 Let the deck view base class handle buttons 2013-12-05 23:06:32 +01:00
Tobias Loose
8de50532f2 Put easing code into Easing.h. Add easing to sliding 2013-12-05 23:06:31 +01:00
Tobias Loose
334454655d Add Easing code to make scrolling in grid view more fluid 2013-12-05 23:06:31 +01:00
Tobias Loose
d8d52e185d Add another missing include 2013-12-05 23:06:31 +01:00
Tobias Loose
9f1d225259 Add additional source files to various build systems 2013-12-05 23:06:30 +01:00
Tobias Loose
0c72bfd4c4 Make deck views toggleable 2013-12-05 23:06:30 +01:00
Tobias Loose
55e0366f19 Move griddeckview implementation into source file 2013-12-05 23:06:30 +01:00
Tobias Loose
667b95f2b8 Refactor gamestatedeckviewer and add a grid view suited...
for bigger screens.
2013-12-05 23:06:30 +01:00
Tobias Loose
e90f6fe224 Whitespaces and add button to toggle griv/scrolling view 2013-12-05 23:06:30 +01:00
Tobias Loose
2289fffb8d Do not ftbfs when in release mode (-weror, -wunused-.. combination) 2013-12-05 23:06:30 +01:00
xawotihs
826403a512 Fixed upload shell script 2013-12-05 22:44:02 +01:00
xawotihs
35fec3d9a0 Made upload-binaries executable 2013-12-05 22:05:31 +01:00
xawotihs
e9eb86488e Redirect ant update errors to a file and push correct upload-binaries.sh 2013-12-05 21:43:29 +01:00
xawotihs
ae97abbf96 Activates an automatic pre-release and binary upload from Travis. 2013-12-05 21:21:08 +01:00
Xawotihs
a8391112b0 Merge pull request #576 from ZobyTwo/directories_1
Do not specify the system directory in JGE
2013-12-04 13:07:05 -08:00
Rolzad73
4257592568 Updated output of info about Android APIs 2013-12-04 12:58:22 -05:00
Tobias Loose
657479e0e4 Do not specify the system directory in JGE 2013-12-04 11:58:36 +01:00
Dmitry Panin
9e969881fd Added output of info about Android APIs 2013-12-04 12:04:54 +04:00
Dmitry Panin
2b434a7182 Merge pull request #575 from WagicProject/android_travis_sdk_downgrade
Changed Travis build file to use Android API 10 and Android build tools 18.1.1
2013-12-04 00:02:49 -08:00
Rolz73
d2e41f98c3 Changed Travis build file to use Android API 10 and Android build tools 18.1.1 2013-12-03 02:36:11 -05:00
Xawotihs
318fc98a39 Merge pull request #574 from WagicProject/feature/play-from-grave
Feature/play from grave
2013-12-02 12:34:52 -08:00
Dmitry Panin
b7a4b7f6b9 Fixing Yawgmoth's will 2013-12-02 21:26:55 +04:00
Dmitry Panin
ed03fb744d Added [Yawgmoth's Will] 2013-12-02 13:42:31 +04:00
Dmitry Panin
02be213d1e Test for keyword "CanPlayFromGraveyard"
Also added card [Crucible of Worlds] as example of it.
2013-12-02 04:36:58 +04:00
Dmitry Panin
0d4db9ee54 Fixed bug in alternative cost when playing lands 2013-12-02 04:33:39 +04:00
Dmitry Panin
ae927576c5 Draft of new feature: canplayfromgraveyard
this will allow playing cards from graveyard
examples: tbd
2013-12-02 04:20:04 +04:00
Dmitry Panin
f08ddac77b Fixed formatting 2013-12-02 04:16:25 +04:00
xawotihs
746a486e7a Added some comments for the redo tests. 2013-11-30 23:39:29 +01:00
xawotihs
261a6e4780 Merge branch 'master' into minmax 2013-11-30 23:10:24 +01:00
Dmitry Panin
9effa7c975 Slightly changed formatting while investigating src 2013-12-01 01:01:57 +04:00
Dmitry Panin
a70259b5ba Fixed: Assembly-Worker didn't appear as creature type
For artifact creatures the parent type TYPE_ARTIFACT was used
and therefore that creature's subtype wasn't added in full list.
2013-12-01 00:59:16 +04:00
xawotihs
bf0a0a1580 Build the graphics version in release instead of debug. 2013-11-30 19:32:55 +01:00
xawotihs
eb8b22b2d5 Merge branch 'master' of https://github.com/WagicProject/wagic 2013-11-30 12:21:43 +01:00
xawotihs
4095676b6b Fixed memory leak introduced in #555 2013-11-29 22:07:45 +01:00
xawotihs
bedd1e8da8 Merge branch 'valgrind' of https://github.com/ZobyTwo/wagic into ZobyTwo-valgrind 2013-11-29 19:41:46 +01:00
xawotihs
965d4f6d45 Fixes Windows project 2013-11-29 19:31:23 +01:00
Tobias Loose
0db2925e7a Fix initialization orders 2013-11-29 18:44:30 +01:00
Tobias Loose
031f2dbffb Fix Valgrind warnings appearing during the test suit. 2013-11-29 18:21:53 +01:00
Tobias Loose
dbece750f8 Use tabs instead of spaces if the file uses tabs 2013-11-29 13:51:13 +01:00
Tobias Loose
6699902c24 Add TIXML_USE_STL to android builds 2013-11-29 13:34:44 +01:00
Tobias Loose
e8407caa2a Add TIXML_USE_STL compiler flag to psp makefile to make headers compatible 2013-11-29 13:34:35 +01:00
Tobias Loose
69c6745f53 Make getMenuText() return string. 2013-11-29 13:33:33 +01:00
Tobias Loose
6f083389c2 Speedup MTGAllCards::countByType a bit 2013-11-29 11:51:58 +01:00
Tobias Loose
9ee44ca091 Substitute more char arrays with strings 2013-11-29 11:51:22 +01:00
Tobias Loose
3f0dd987f0 Remove bool CardInstance::hasSubtype(const char * _subtype)
There exists bool CardInstance::hasSubtype(const string& _subtype) and the
const char* version converts _subtype into string deeper in the call
hierarchy anyway. So both methods did the same.
2013-11-29 11:43:59 +01:00
Tobias Loose
672b0be7bd Fix a few string bugs add StartsWith for strings 2013-11-29 11:38:49 +01:00
Tobias Loose
9d5a83d588 Replace more strcmp with std::string::compare or std::string::operator==.
This commit also enables TinyXML STL support.
2013-11-28 16:42:29 +01:00
Tobias Loose
5d0d130587 Make MTGGameZone::countByType use string instead of char*
and replace strcmp with std::string operator== calls.
2013-11-28 16:42:29 +01:00
Tobias Loose
c85d857604 Replace constness cast 2013-11-28 16:42:29 +01:00
Tobias Loose
f68568cc1e Replace strcmp with c++ equivalent when comparing std::strings. 2013-11-28 16:42:29 +01:00
Dmitry Panin
89206b3a6b Added testing that QT GUI build is successfull 2013-11-28 16:44:12 +04:00
Michael Nguyen
a8cff5ed8e Merge branch 'master' into develop 2013-11-28 02:19:41 -08:00
xawotihs
dc118c64b8 Fixed compilation on Mac 2013-11-27 23:04:46 +01:00
xawotihs
a43854420d Fixed compilation issue on Windows 2013-11-27 20:33:59 +01:00
xawotihs
a695323bc7 Merge pull request #564 from ZobyTwo/cleanup_1
Add a few namespaces and fix header guards.
2013-11-25 15:42:18 -08:00
xawotihs
02a65ecd82 Merge branch 'cleanup_1' of https://github.com/ZobyTwo/wagic into ZobyTwo-cleanup_1 2013-11-26 00:17:48 +01:00
xawotihs
9ff087ecde Merge pull request #570 from WagicProject/android-travis-ci
Android travis ci
2013-11-25 14:31:15 -08:00
xawotihs
47685f4892 Added installation of 32 bits libs to make Android SDK work. 2013-11-25 22:42:09 +01:00
xawotihs
7aaebdc661 Merge branch 'android_build_fix' into android-travis-ci 2013-11-25 21:23:58 +01:00
Rolzad73
8aa0b8cea0 reverting sdk.buildtools change 2013-11-25 13:41:07 -05:00
Rolzad73
fac44c4b48 - updated AndroidManifest.xml to match desired API values.
- removed CardEffect.cpp reference from Android.mk build file.
- added sdk.buildtools=18.1.1 line to default.properties and project.properties
- updated .gitignore
2013-11-25 11:54:19 -05:00
Dmitry Panin
9889186eab Added missing "echo" statement 2013-11-25 13:41:29 +04:00
xawotihs
73f9319b92 Activates Android build from Travis 2013-11-25 05:27:31 +01:00
xawotihs
fd6bc95539 Merge pull request #562 from citiral/master
Updated deckmenu.cpp to properly render deck description and summary
2013-11-24 10:28:05 -08:00
Tobias Loose
0bb211a581 Remove unused global variables from DeckStats.cpp and add proper...
member variable initialization.
2013-11-24 09:18:34 +01:00
Tobias Loose
e0428ac7b0 Avoid more conflicts. We could now do unit builds...
and make the linker put every data element and function into its own section.
On linktime, we can output every discarded section and get a list of dead
code (for that build).
2013-11-23 17:04:24 +01:00
Tobias Loose
3e94de985f Add more include guards 2013-11-23 16:25:14 +01:00
Tobias Loose
9f0b70d1c9 Put constans into extra namespace as kBackToMainMenuID...
collides with itself. GameStateAwards::kBackToMainMenuID and
GameStateOptions::kBackToMainMenuID define those with different
values.
2013-11-23 16:18:45 +01:00
Tobias Loose
1e8fc81aa3 Add/fix broken include guards 2013-11-23 16:09:11 +01:00
Tobias Loose
352e3c2daa Remove makros and add undefs to avoid clashing names
FRAND and Clamp were not used and Clamp collided when doing unit builds.
SQUARE(x) is longer than x*x and if x is an expression it gets evaluated
twice.
2013-11-23 16:03:04 +01:00
Dmitry Panin
678a4734bb Merge pull request #560 from ZobyTwo/dead_code
Remove some dead code
2013-11-22 00:09:40 -08:00
Dmitry Panin
052e3abdb8 Small fix in match_and ( [-color1; -color2] was handled incorrectly ) 2013-11-22 01:03:07 +04:00
citiral
73c2d17080 Updated deckmenu.cpp to properly render deck description and summary
Deck description and statistics were being drawn as black text, this made it invisible as it was rendered over a black background. I made it change the color to white before drawing, so its shown as its suposed to be.(Did the default text color change?)
2013-11-21 20:38:41 +01:00
Dmitry Panin
ffbb228d2d Fixed wrong activation cost in dragon hatchling 2013-11-21 14:25:01 +04:00
Dmitry Panin
306765c6b6 Merge pull request #561 from ZobyTwo/valgrind
Fix some valgrind memcheck warnings. However there remains one...

... within the threaded texture cache. Once it is resized, some textures
in GetQuad(...) (WCachedResource.cpp:102/103) have uninitialized widths/heights.
2013-11-21 01:58:49 -08:00
Tobias Loose
3cee80e3bc Delete another unused file (GuiMessageBox.cpp) 2013-11-20 14:01:59 +01:00
Tobias Loose
8209716fc9 Remove unused file 2013-11-20 13:53:15 +01:00
Tobias Loose
e76c57d747 Fix some valgrind memcheck warnings. However there remains one...
... within the threaded texture cache. Once it is resized, some textures
in GetQuad(...) (WCachedResource.cpp:102/103) have uninitialized widths/heights.
2013-11-20 12:56:33 +01:00
Tobias Loose
9c282aeb56 Remove CardEffect.o from Makefile 2013-11-20 12:02:33 +01:00
Tobias Loose
bbc310dec7 Remove some dead code 2013-11-20 11:43:27 +01:00
Dmitry Panin
a37af1776a Merge pull request #557 from ZobyTwo/defines
Defines/Typos
2013-11-20 02:34:32 -08:00
Tobias Loose
35697a65b4 Use style guide 2013-11-20 11:13:35 +01:00
Tobias Loose
6bed1666be Merge branch 'master' into defines 2013-11-20 11:06:41 +01:00
Tobias Loose
f021866368 Merge remote-tracking branch 'wp/master' 2013-11-20 11:06:28 +01:00
xawotihs
d7e527166c Merge branch 'show-output-only-for-failing-tests' 2013-11-19 11:14:41 +01:00
xawotihs
a683f5a2b7 Some preliminary work for minmax 2013-11-19 11:09:39 +01:00
Dmitry Panin
071a487100 Fixed compilation error 2013-11-19 11:06:31 +04:00
Dmitry Panin
f370899a8a Thread-safe version of OutputCapturer 2013-11-19 03:58:43 +04:00
Dmitry Panin
331e126787 Added info about total number of tests 2013-11-19 02:57:42 +04:00
Dmitry Panin
6c41e5c92c Added option (#define CAPTURE_STDERR)
if set then the DebugTrace calls only for failing tests are shown
2013-11-19 02:41:30 +04:00
Tobias Loose
82e3ab3977 Merge branch 'cleanup' into defines
Merge cleanup codings style commit as i accidentally used that branch as
the base.
2013-11-17 21:06:56 +01:00
Tobias Loose
f2314ca673 Use proposed coding style 2013-11-17 21:05:07 +01:00
Tobias Loose
94c3ac9ad9 Fix FTBFS 2013-11-17 21:02:08 +01:00
Tobias Loose
5419d87e4e Get rid of two more define groups. 2013-11-17 20:22:03 +01:00
Tobias Loose
e1213d1c1f Remove variables flagged for removal (via conditional TODO comment)
x and y is provided by PlayGuiObject::Pos.
2013-11-17 19:50:17 +01:00
Tobias Loose
446ed20758 Fix typo ActionLayer::receiveEventPlus(...)
This method is rarely used, however it returned 0 after adding stuff.
It now returns the sum.
2013-11-17 19:39:46 +01:00
Tobias Loose
7a48c5e087 Fix some cppcheck warnings (mostly style and postfix vs prefix iteration) 2013-11-17 19:36:24 +01:00
Tobias Loose
3ca2f1c1ed Replace defines in Damage.h with enums. 2013-11-17 17:12:58 +01:00
Tobias Loose
146872797b ActionElement.h: Replace defines, remove superfluous ";"
Defines do not follow scope rules, but enums do. Enum classes
even utilize strong type checking (but i am not sure about compiler
support for c++11 on all target platforms).
2013-11-17 16:08:29 +01:00
Tobias Loose
c6dc51c7d3 Simplify Damage::resolve a bit 2013-11-17 15:37:56 +01:00
Dmitry Panin
0ef92d154a Merge pull request #555 from WagicProject/fix-cranial-plating
Fix cranial plating
2013-11-16 13:58:56 -08:00
Dmitry Panin
2835bdf767 Fixed issue with Cranial Plating.
Issue
	attach then equip: plating will give bonus to both creatures
Fix
	Changed "attach" to "retarget target(creature|mybattlefield)"
	as this doesnot admit this bug
	Attach should become deprecated in future
2013-11-17 01:49:51 +04:00
Dmitry Panin
afc903e31b Added different names for attach and equip
+ moved implementation of AEquip to .cpp
2013-11-17 00:44:37 +04:00
Dmitry Panin
6294bb1eed Added Master of Waves 2013-11-16 23:54:37 +04:00
xawotihs
9f16b2208d Removes the error, it was perfectly detected by Travis CI. 2013-11-09 20:15:00 +01:00
xawotihs
0a765b702b Introducing an error to check if Travis reports correctly a compile
error with the script.
2013-11-09 20:01:57 +01:00
xawotihs
82de6f2840 Fixes stupid typo. 2013-11-09 19:51:47 +01:00
xawotihs
90652fa73d Fixed PSP build and integrates it with Travis CI 2013-11-09 19:40:01 +01:00
Rolzad73
e8c73aaf9d Merge pull request #1 from WagicProject/android_cleanup
Android cleanup
2013-11-07 13:15:41 -08:00
Rolzad73
f95094a429 removing commented lines I had intended to delete outright 2013-11-07 15:56:43 -05:00
Rolzad73
7a57de6608 removed ads on Android version 2013-11-07 15:49:53 -05:00
Rolzad73
14c2d522c2 removed Android gen dir 2013-11-07 15:04:37 -05:00
Dmitry Panin
6bf2147d94 From the Vault: Twenty
// imported accidental commit from svn repo
2013-11-06 12:56:54 +04:00
xawotihs
fea5b04a77 Fixed compilation on Windows. 2013-10-31 23:48:19 +01:00
xawotihs
ea98b769a7 Merge branch 'develop'
Activates full testsuite run in Travis CI. Travis will complain as soon as at least one testcase does not pass successfully after a new commit.
2013-10-30 23:10:03 +01:00
xawotihs
017f6dd1ed Deactivated part of the traces outputted by the testsuite to make Travis
happy.
2013-10-30 22:58:04 +01:00
xawotihs
784d127a6e I think I got it ... messy / not appearing at the end of folders in the
travis linux where it appears fine on mine :(
2013-10-30 22:28:09 +01:00
xawotihs
f6c47b85e3 More debug 2013-10-30 22:02:43 +01:00
xawotihs
dac31994b6 Adding traces for important directories. 2013-10-30 21:44:23 +01:00
xawotihs
74280aef1d Added some traces in the primitives and sets loading. 2013-10-30 20:50:34 +01:00
xawotihs
8013d09e4f Reactivated wagic console in travis CI 2013-10-30 20:30:33 +01:00
Dmitry Panin
6bbe290762 Fixed bug with syncopate to consume all the mana available
Now pay[[{x}]] is not supported because of this.
use "pay[[{value:storedx}]]" instead
2013-10-30 12:39:08 +04:00
xawotihs
57c9940244 Deactivated testsuite from travis, resources are not loaded correctly. 2013-10-30 00:38:34 +01:00
xawotihs
db1c552321 Tries to work around crash of the testsuite in Travis. 2013-10-30 00:20:58 +01:00
xawotihs
f08f0ad3b9 Merge branch 'master' of https://github.com/WagicProject/wagic
Conflicts:
	JGE/include/JTypes.h
2013-10-29 23:36:07 +01:00
xawotihs
a3a1bc2b79 Created a dedicate console Qt based wagic application and run it in the
travis file.
2013-10-29 22:38:37 +01:00
Dmitry Panin
9037699281 Added missing test for syncopate + 2 tests for spell_rupture 2013-10-29 19:49:31 +04:00
Michael Nguyen
8d66f82179 Merge branch 'release/wagic-v0.19.2' 2013-10-28 16:19:28 -07:00
Michael Nguyen
eeb4a4e755 updated version number to 0.19.2, changed min target to API 10 vs API 9 as recommended by Android 2013-10-28 16:19:01 -07:00
Michael Nguyen
38725aaeac Merge commit '82171773fe89cd582e62a52fdadb152040fc0fd5' into develop 2013-10-28 15:37:35 -07:00
Michael Nguyen
ed474d6b5d Merge commit '224c94e89089317fac33aacb9319ab250301c98e' into develop 2013-10-28 15:37:24 -07:00
Michael Nguyen
b17d9d3f85 Merge branch 'master' of github.com:WagicProject/wagic 2013-10-28 15:35:45 -07:00
Michael Nguyen
c5190a62cd Merge branch 'develop' 2013-10-28 15:35:18 -07:00
Michael Nguyen
89472eeccd tidied up gitignore file for XCode 2013-10-28 15:29:51 -07:00
Michael Nguyen
2b4404f352 Merge branch 'feature/update-for-iOS6' into develop 2013-10-28 15:21:33 -07:00
Michael Nguyen
84ca7457b5 updaed for iOS6 2013-10-28 15:20:35 -07:00
Michael Nguyen
4eb1fd35e0 changed the default location for the sdcard. Instead of using a fixed value of "/sdcard/Wagic/Res" it now uses Environment.getExternalStorageDirectory().getPath() + "/Wagic/Res" 2013-10-28 15:20:11 -07:00
Michael Nguyen
362cc1b4c2 updated project to rotate and display correctly in iOS6+
removed all references to adwhirl for iOS.
2013-10-28 15:14:17 -07:00
xawotihs
82171773fe revert travis config file while the X dependency is not sorted. 2013-10-28 00:07:55 +01:00
Unknown
224c94e890 Included some testsuite into qtmain and updated travis file to try to use it. 2013-10-27 23:06:29 +01:00
Dmitry Panin
7a7bc70773 Update README.md 2013-10-27 13:36:23 +03:00
Dmitry Panin
1401fef37e Simple support for CI at travis
- now compilataion on Linux (using qmake and make) is checked
2013-10-27 14:30:34 +04:00
Dmitry Panin
cf50b7d403 Fizzle unless pay x (thanks to excessum)
- saves source card in storedSourceCard for ATransform
- adds support for WParsedInt in pay as "pay[[{value:WParsedInt}]]":

name=Spell Rupture
target=*|stack
auto=if cantargetcard(*|opponentstack) then transforms((,newability[pay[[{value:power:highest:creature:opponentbattlefield}]] name(pay {value} mana) donothing?fizzle])) forever
text=Counter target spell unless its controller pays {X}, where X is the greatest power among creatures you control.
mana={1}{U}
type=Instant

- adds support for {x} in *some* “pay” abilities (Syncopate):

name=Syncopate
target=*|stack
auto=transforms((,newability[pay[[{x}]] name(pay {value} mana) donothing?fizzleto(exile)])) forever
text=Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into  its owner's graveyard.
mana={X}{U}
type=Instant

- support of "name(pay {value} mana)" in pay abilities to show actual number to pay (see example above)
2013-10-27 13:47:00 +04:00
Dmitry Panin
b8b6153cc5 Reworked AVanishing (fixed bugs + more fair implementation) 2013-10-27 13:42:48 +04:00
Dmitry Panin
461eedd626 Fixed bug with preventing Melira from putting +1/+1 counters on creatures you control 2013-10-27 13:42:48 +04:00
xawotihs
f0977ebc04 Update README.md 2013-10-26 12:12:58 +02:00
xawotihs
e38f42d854 Create README.md 2013-10-26 11:50:40 +02:00
xawotihs
4ac376b5f2 Ignored non-source extensions 2013-10-24 21:53:46 +02:00
Xawotihs@gmail.com
1f0485ff8e Support for running the testsuite in command line programs for continuous integration.
Here is a small example inspired from SDLmain.c:

g_launcher = new JGameLauncher();
InitGame();
MTGCollection()->loadFolder("sets/primitives/");
MTGCollection()->loadFolder("sets/", "_cards.dat");
options.reloadProfile();
TestSuite testSuite("test/_tests.txt");
int result = testSuite.run();
DestroyGame();
delete g_launcher;
return result;
2013-10-23 22:08:30 +00:00
Xawotihs@gmail.com
98861dd916 Fixed memory leaks and refactored a bit the ManaCost class while I was at it. 2013-10-19 14:29:17 +00:00
pankdm
b5794ad328 Small fixes (misstype, formatting, target p2) 2013-10-18 06:38:15 +00:00
pankdm
38b4213f9c Refactored formatting for easier reading of the code 2013-10-18 06:38:03 +00:00
pankdm
f1a9f0d162 Fixed Grave Pact, butcher of malikir and some other cards
"Whenever creature you control dies" --
it's @movedTo(creature|  graveyard) from(mybattlefield)
NOT  @movedTo(creature|mygraveyard) from(  battlefield)
2013-10-18 06:37:53 +00:00
pankdm
e62feddaf4 Added Probe 2013-10-18 06:37:43 +00:00
pankdm
5c3eb2c405 Changed the owner of ManaCost in LifeorManaCost to itself 2013-10-18 06:37:31 +00:00
pankdm
f7eded7417 Devotion mechanics (thanks to excessum for patch)
+ some refactoring:
extrManaCost --> ExtraManaCost
unattachCost --> UnattachCost
2013-10-18 06:37:09 +00:00
pankdm
d5b089f86b Small fixes to _cards.dat 2013-10-18 06:36:56 +00:00
pankdm
1d3c4bcd69 Added _cards.dat file for Theros 2013-10-18 06:36:46 +00:00
pankdm
9d2a2454b2 Fixed: exile was not meaning both exiles
and revised Crypt Incursion
2013-10-18 06:35:52 +00:00
pankdm
173f787fac Revise cards that deals damage and gain life
This cards created multiple instances of life gain and damage,
which caused wrong behaviour with for example Ajani's Pridemate
2013-10-18 06:35:02 +00:00
pankdm
0ac6057ee9 Fixed Balduvan conjurer (added land restriction) 2013-10-18 06:34:51 +00:00
pankdm
8b16074647 Fixed memory leak in menuability (thanks to excessum) 2013-10-18 06:34:42 +00:00
pankdm
62dad30f6b Revised Bloodigift demon (now it targets players) 2013-10-18 06:34:32 +00:00
pankdm
43ba9aa13d Fixed parsing of "if(ifnot) ... then may ... " 2013-10-18 06:34:23 +00:00
pankdm
ea217fdba1 Fixed [card] 2013-10-18 06:34:14 +00:00
pankdm
eea88cdeb5 Tests for new "fizzleto" keyword 2013-10-08 23:18:56 +00:00
pankdm
0c6d77daa0 Refactored FizzleToZone
Get rid of common code
Better naming of zone (where we put spell after countering)
More generic syntax: fizzleto(X) where X in [hand, exile, librarytop]
which will give more flexibility later
2013-10-08 23:18:42 +00:00
pankdm
4341e23210 Added Increasing Ambitions 2013-10-08 23:18:32 +00:00
pankdm
80be19db86 Added missing type=Artifact Creature to Trisk token 2013-10-08 23:18:19 +00:00
pankdm
1da9f5a4af Fixed time sieve 2013-10-08 23:18:08 +00:00
pankdm
fa5aedfe64 Fixed Triskelavus
(tokens didn't have ping ability after death of Trisk)
2013-10-08 23:17:57 +00:00
pankdm
17fdedb648 Draft of the "fizzle to zone"
(credit goes to excessum)
2013-10-08 23:17:43 +00:00
pankdm
da7c336dc2 Removed debug code that was added by mistake 2013-10-01 14:49:31 +00:00
pankdm
be76c8a4f1 Fixed issue with cantbeblockerof and cantbeblockedby vs protection 2013-10-01 14:47:39 +00:00
Xawotihs@gmail.com
490752e9da - Removed dependencies on Boost/string in mtg sources
- Removes dependencies on Boost/shared_ptr in mtg sources only for WP8 for the moment
- Various compilation fixes on WP8
2013-09-30 21:25:17 +00:00
pankdm
7894ca3ace Refactored ABlink: extracted common code as method "returnCardIntoPlay" 2013-09-27 19:25:28 +00:00
pankdm
d4268f18af Fixed Mortus Strider 2013-09-27 18:54:01 +00:00
pankdm
3761684816 Fixed blinking (until EOT) of creature with X in cost 2013-09-26 14:17:39 +00:00
pankdm
f10eb609d7 Added:
Belltower Sphinx
	Spellstutter Sprite

Thanks to Tacoghandi and dber for providing the code
2013-09-24 16:44:19 +00:00
pankdm
00ebc8c8eb Fixed issue with blinking creature that has X in cost 2013-09-23 20:27:52 +00:00
pankdm
36cfe84445 Revised Door of Destinies 2013-09-23 20:02:26 +00:00
pankdm
54d1126c58 Small fix in TestSuite
"Update" should pass "dt" since the last update, not since the beginning the game.
2013-09-23 19:44:03 +00:00
pankdm
11f541a627 Fixed:
Edge of autumn
	Mirrorworks

	Clone of the card now have the same image as original
	Issue with cloning and trigger "nontoken * enters"

	Blitzkrig rules
	Hermit druid rules
2013-09-23 19:40:12 +00:00
pankdm
93ebca3041 Forgot to remove Wildfire from unsupported 2013-09-20 16:39:23 +00:00
pankdm
ce7689c8c6 Added:
Wildfire

Fixed:
	Stitch in Time -- missing flipend at end
	Raging Ravine -- can't have trigger inside second transofrm
	Prey Upon -- can be cast only on opponents creature
	Mesmeric Fiend -- target(player) --> target(opponent)
	Caribou Range -- ability should be on ench
2013-09-20 16:18:56 +00:00
pankdm
de8309a7c2 Small fixes for:
Gravecrawler
Riot Control
Teysa, Envoy of Ghosts
Vengevine
Izzet Staticaster
Batwing Brume
2013-09-19 16:02:34 +00:00
pankdm
ec11bf917d Fixed slight bugs with formatting in primitives files
This appeared in several places (usually unsupported and mtg):
Churning Eddy
Izzet Staticaster
Kjeldoran Pride
Storage Matrix 
Torch Song

This had multiline values under "text=" or "auto=":
Debt to the Deathless
Smelt-Ward Gatekeepers
Sunspire Gatekeepers
Teysa, Envoy of Ghosts
Ubul Sar Gatekeepers
2013-09-18 07:00:29 +00:00
pankdm
8626451977 Fixed uninitialized value
Due to this, activated abilities with {X} in cost sometimes were having X=0 when playing
(This appeared only in Debug mode)
2013-09-16 20:18:36 +00:00
pankdm
4aa5dec51a Fixed some warnings
+ added compile flags to mute some warnings that don't have an obvious fix
2013-09-16 17:42:07 +00:00
pankdm
3c3fcfc655 Fixed typo in Rising Waters 2013-09-15 18:51:42 +00:00
wagic.the.homebrew@gmail.com
bd25b12fb2 Fix for issue 962 (Hexproof) by Dmitri 2013-09-15 02:57:29 +00:00
wagic.the.homebrew@gmail.com
7b8189bd13 Fixing tests that got broken in r4842 2013-09-15 02:47:09 +00:00
omegablast2002@yahoo.com
a2d020b2ae updated 2013-07-07 18:56:20 +00:00
omegablast2002@yahoo.com
20eda1560b psp fix 2013-06-19 21:57:08 +00:00
omegablast2002@yahoo.com
7917a70b1b forgot to reset the opponents miracle on beforebegins. i knew i had coded the miracle to be player independent :P 2013-06-19 13:33:24 +00:00
omegablast2002@yahoo.com
2fa3f468b4 added menutext overriding to transforms.
castcard-> is now the copied spell x.
2013-06-19 11:46:09 +00:00
omegablast2002@yahoo.com
1851f3c7a6 added Blitzkrieg gamemode created by tacoghandi. for those that like playing at top speed :) 2013-06-19 02:03:34 +00:00
anthonycalosa@gmail.com
45711bb504 Added 204 New Cards as of R4840 changes:
Aeon Chronicler
AEther Barrier
All Hallow's Eve
Azorius AEthermage
Banishing Stroke
Basilica Guards
Basilica Screecher
Batwing Brume
Benalish Commander
Blessings of Nature
Blind Obedience
Bog-Strider Ash
Callow Jushi
Jaraku the Interloper
Carrion Thrash
Chain of Acid
Chain of Smog
Chalice of the Void
Chandra Ablaze
Cloven Casting
Controvert
Convolute
Cradle of Vitality
Crypt Ghast
Crystal Shard
Cursecatcher
Customs Depot
Cut the Tethers
Darigaaz, the Igniter
Dawnglow Infusion
Daze
Death Charmer
Decaying Soil
Decree of Silence
Detritivore
Devastation Tide
Diluvian Primordial
Disrupt
Disruptive Pitmage
Disruptive Student
Dovescape
Drainpipe Vermin
Drowner Initiate
Dual Casting
Echo Mage
Elephant Grass
Embersmith
Equilibrium
Erayo, Soratami Ascendant
Erayo's Essence
Erratic Portal
Firespout
Flay
Flight Spellbomb
Force Spike
Force Void
Fork
Freyalise's Charm
Furnace Celebration
Ghost-Lit Warder
Ghostly Prison
Goblin Vandal
Grim Harvest
Grizzled Wolverine
Hasran Ogress
Hematite Talisman
Hesitation
Horizon Spellbomb
Icefall
In the Eye of Chaos
Inheritance
Insidious Bookworms
Intimidator Initiate
Invert the Skies
Isolation Cell
Izzet Guildmage
Jeweled Torque
Judge's Familiar
Kalastria Highborn
Kazuul, Tyrant of the Cliffs
Kingpin's Pet
Knight of Obligation
Knowledge Exploitation
Krovikan Rot
Lapis Lazuli Talisman
Leshrac's Sigil
Leyline of Lightning
Lifesmith
Lightning Axe
Lightning Cloud
Lightning Rift
Lunar Mystic
Maelstrom Archangel
Magnetic Mountain
Malachite Talisman
Mana Leak
Mana Tithe
Masked Admirers
Megatherium
Memory Plunder
Merfolk Seer
Militia's Pride
Mind's Eye
Mindclaw Shaman
Mindleech Mass
Mindstatic
Minion Reflector
Mirari
Mirrorworks
Miscalculation
Mischievous Quanar
Moonhold
Mudslide
Myrsmith
Mystic Remora
Nacre Talisman
Nether Traitor
Nether Void
Nivix Guildmage
Nihil Spellbomb
Nurturer Initiate
Off Balance
Offering to Asha
Onyx Talisman
Origin Spellbomb
Panic Spellbomb
Patron Wizard
Pedantic Learning
Phyrexian Tyranny
Plague Fiend
Pontiff of Blight
Propaganda
Punishing Fire
Purraj of Urborg
Pyrewild Shaman
Reborn Hero
Reforge the Soul
Reiterate
Resize
Revenge of the Hunted
Reverberate
Rhystic Deluge
Rhystic Shield
Rhystic Study
Riftmarked Knight
Riku of Two Reflections
Rishadan Brigand
Rishadan Cutpurse
Rishadan Footpad
Rootwater Thief
Runeboggle
Sage's Dousing
Searing Meditation
Second Guess
Seer's Sundial
Sigil of the New Dawn
Sigil Tracer
Silent-Blade Oni
Sludge Strider
Smolder Initiate
Soratami Savant
Soul Charmer
Soul Net
Spawnsire of Ulamog
Spell Contortion
Spell Pierce
Spell Snip
Spelltithe Enforcer
Sphinx of Lost Truths
Spiketail Drake
Spiketail Drakeling
Spiketail Hatchling
Spirit Cairn
Sudden Spoiling
Sunforger
Sunken Field
Sun's Bounty
Surgespanner
Syndic of Tithes
Syndicate Enforcer
Tablet of Epityr
Tears of Rage
Telekinetic Bonds
Temporal Mastery
Terminus
Thelon's Curse
Thrull Wizard
Thunderblade Charge
Thunderous Wrath
Torrent of Souls
Toshiro Umezawa
Treasury Thrull
Twincast
Undergrowth
Unnerving Assault
Urza's Chalice
Uyo, Silent Prophet
Vanishment
Vectis Dominator
Veiling Oddity
Vigorous Charge
Vodalian Mage
Voidmage Apprentice
Windborn Muse
Wizard Replica
Wrexial, the Risen Deep

96 Revised/Fixed Cards as of R4840 changes:
Apothecary Initiate
Artisan of Kozilek
Auspicious Ancestor
Azorius Herald
Blood Crypt
Boros Fury-Shield
Breeding Pool
Chaotic Backlash
Choking Tethers
Countersquall
Crackleburr
Crosis, the Purger
Crypt Champion
Crystal Rod
Death Pulse
Deathforge Shaman
Dirge of Dread
Disciple of the Vault
Divine Congregation
Dromar, the Banisher
Dryad's Caress
Esper Sojourners
Eye of Ugin
Flash Conscription
Frenzied Goblin
Gempalm Incinerator
Gempalm Polluter
Godless Shrine
Grixis Sojourners
Gruul Scrapper
Haazda Snare Squad
Hallowed Fountain
Hellkite Charger
Honden of Night's Reach
Iron Star
Ivory Cup
Jovial Evil
Jugan, the Rising Star
Jund Sojourners
Knight of the Mists
Krosan Tusker
Legion's Initiative
Llanowar Sentinel
Lorthos, the Tidemaker
Mind Knives
Mindstab
Naya Sojourners
Nemesis Trap
Numot, the Devastator
Obzedat, Ghost Council
Offalsnout
Ogre Savant
Order of the Golden Cricket
Oros, the Avenger
Overgrown Tomb
Patagia Viper
Plaxmanta
Price of Progress
Primal Boost
Psionic Sliver
Renewed Faith
Ribbons of Night
Rith, the Awakener
Rolling Spoil
Rubblebelt Maaka
Rupture Spire
Samurai of the Pale Curtain
Seance
Seed Spark
Shrieking Grotesque
Slice and Dice
Solar Blast
Splinter Twin
Steam Vents
Steamcore Weird
Stomping Ground
Stone Catapult
Sunfire Balm
Temple Garden
Tendrils of Agony
Teneb, the Harvester
The Fallen
The Hive
Throne of Bone
Tin Street Hooligan
Trade Caravan
Transguild Promenade
Treva, the Renewer
Viashino Firstblade
Vigor Mortis
Vorosh, the Hunter
Watery Grave
Wellspring
Wing Shards
Wing Storm
Wooden Sphere
2013-06-18 02:17:52 +00:00
omegablast2002@yahoo.com
f1d88611cb updated test to adjust for new legendary rules 2013-06-18 01:42:49 +00:00
omegablast2002@yahoo.com
b61cd2f69a megapatch contents
added
"whenever a creature enters the battlefield you may pay {1}, if you do gain one life"
conditional may pay({cost}) effect 
this version is a super type ability, and can only be used in certain combos.

to nest you will need to use it in its subtype pay[[{cost}]] effect
pay keyword can have sideeffects coded as follows
pay[[{1}]] life:1?life:-1
pay one mana and gain 1 life, if you dont then you lose one life. notice no space between the abilities and the question mark.

added castcard()
a method to cast a targeted card, this contains the following subkeywords which can be used in combinations
(normal)
(restricted)
(copied)
(noevent)
castcard(restricted copied noevent) for example will cast a card that is a copy or the spell without sending a cast event only when the spell is castable.
"normal" subkeyword cast the actual spell, not a copy.

extended the use of exiledeath to everyzone, any card going from any zone to graveyard is placed in exile if it has exiledeath.

limited swipe left to open hand only when hand is closed view.

"moveto(" can now be named.
2013-06-18 01:41:34 +00:00
anthonycalosa@gmail.com
ece78395f4 Update SOK for Erayo, Soratami Ascendant 2013-06-13 13:37:25 +00:00
anthonycalosa@gmail.com
95bbe06c7e added swipe on Story Mode. So if playing a duel on story mode, you can cancel with swipe down. 2013-06-13 04:34:20 +00:00
anthonycalosa@gmail.com
b3f81e95bb Update WWK for Kazuul, Tyrant of the Cliffs 2013-06-13 04:28:14 +00:00
anthonycalosa@gmail.com
3c63b152a6 Update PLC for Riftmarked Knight token 2013-06-11 06:42:55 +00:00
Xawotihs@gmail.com
26ab65860e Fixed a gazillion of warnings occuring when compiling Wagic with Clang with Werror. 2013-06-09 21:16:39 +00:00
rolzad73@gmail.com
7990540096 fixed music resource adding from resource zip to nested folder on Android platorm. Fixed issue 776 2013-06-03 02:15:12 +00:00
punkeduard@gmail.com
1442b73029 Fixed some cards from DGM and Crackleburr 2013-06-03 01:17:56 +00:00
anthonycalosa@gmail.com
fee9ee756c typo fix Obzedat's Aid 2013-06-02 13:24:30 +00:00
rolzad73@gmail.com
a400cabfc7 - code foramtting only mostly of whitespace for readability of a few Android files 2013-06-01 16:02:10 +00:00
anthonycalosa@gmail.com
8a7d5f4490 added Auriok Replica, Austere Command 2013-05-22 02:14:11 +00:00
anthonycalosa@gmail.com
b0a1e670ba fix Overload. 2013-05-20 16:54:14 +00:00
anthonycalosa@gmail.com
b5906a4299 revised Martyr of Sands 2013-05-20 14:01:46 +00:00
anthonycalosa@gmail.com
b7324280aa added Prowl cards.
Auntie's Snitch
Earwig Squad
Latchkey Faerie
Morsel Theft
Notorius Throng
Stinkdrinker Bandit


Revised cards:

Denying Wind
Extract
Jester's Cap
Sadistic Sacrament
Supreme Inquisitor
2013-05-20 07:19:18 +00:00
anthonycalosa@gmail.com
f0de00086b added Prowl support.
example usage:
other={1}{B} name(Prowl)
otherrestriction=prowl
2013-05-20 02:59:18 +00:00
omegablast2002@yahoo.com
a055044281 added miracle ability.
i choose to use other cost instead of creating a brand new cost type.

otherrestriction determines if the card is the miracle for the turn.

[card]
name=Devastation Tide
auto=all(*[-land]) moveto(ownerhand)
other={1}{u} name(Miracle)
otherrestriction=miracle
text=Return all nonland permanents to their owners' hands. -- Miracle {1}{U} (You may cast this card for its miracle cost when you draw it if it's the first card you drew this turn.)
mana={3}{U}{U}
type=Sorcery
[/card]
2013-05-19 01:48:51 +00:00
anthonycalosa@gmail.com
4b167c3776 added Abyssal Gatekeeper, Akki Blizzard-Herder, Archmage Ascension, Runeflare Trap 2013-05-18 16:30:14 +00:00
anthonycalosa@gmail.com
cf74c3480e added drawCounter. Returns the number of cards drawn this turn (excludes pre-game draw).
pdrewcount - player draw count
odrewcount - opponent draw count
2013-05-18 15:31:12 +00:00
anthonycalosa@gmail.com
ba5debad05 added AEther Burst. revised code for An-Havva Inn, Kindle, Mind Burst, Vitalizing Cascade, Wall of Tombstones 2013-05-17 03:30:40 +00:00
anthonycalosa@gmail.com
4f915b38c8 added basic support for "X plus one", "X plus two" & "X plus three".
example:

[card]
name=AEther Burst
target=<plusonetype:AEther Burst:graveyard>creature|battlefield
auto=moveto(ownerhand)
text=Return up to X target creatures to their owners' hands, where X is one plus the number of cards named AEther Burst in all graveyards as you cast AEther Burst.
mana={1}{U}
type=Instant
[/card] 

[card]
name=Vitalizing Cascade
auto=life:Xplusthree
text=You gain X plus 3 life.
mana={X}{G}{W}
type=Instant
[/card]
2013-05-17 02:09:48 +00:00
anthonycalosa@gmail.com
c286aa02a6 added Vibrating Sphere, Vish Kal, Blood Arbiter, Vodalian Mystic, Wurmskin Forger 2013-05-17 00:48:11 +00:00
anthonycalosa@gmail.com
3171c62089 added Tsabo's Decree, Tunnel Ignus, Urza's Guilt 2013-05-16 00:39:12 +00:00
anthonycalosa@gmail.com
819ddd0496 added Thran Foundry, Treacherous Vampire, Tremble, Truce 2013-05-15 02:30:14 +00:00
anthonycalosa@gmail.com
c15d0ec523 added Thought Lash, Thoughtcutter Agent, Thoughts of Ruin 2013-05-15 02:01:29 +00:00
anthonycalosa@gmail.com
5da2033d74 added Tectonic Break, Temporary Truce, Tephraderm, Terraformer 2013-05-15 01:29:20 +00:00
anthonycalosa@gmail.com
f449ec5fdd added Sway of Illusion, Swirling Spriggan 2013-05-14 13:30:40 +00:00
anthonycalosa@gmail.com
ee310b7bb3 added Student of Elements // Tobita, Master of Winds 2013-05-14 04:26:48 +00:00
anthonycalosa@gmail.com
b50eaf83a1 added Stonecloaker, Stonehewer Giant 2013-05-14 03:52:37 +00:00
anthonycalosa@gmail.com
79fca90db9 added Sigil of Distinction, Spectral Searchlight, Spell Burst 2013-05-14 03:31:17 +00:00
anthonycalosa@gmail.com
d8b77bf796 Added Sickening Shoal.
Updated codes for Nourishing Shoal and Blazing Shoal.
2013-05-14 02:33:36 +00:00
anthonycalosa@gmail.com
fa07242370 added GTC unsupported cards 2013-05-14 01:30:48 +00:00
anthonycalosa@gmail.com
6626b52e3a added DGM unsupported cards 2013-05-14 00:46:21 +00:00
anthonycalosa@gmail.com
86d748bc43 minor corrections 2013-05-14 00:45:05 +00:00
rolzad73@gmail.com
4f8d5b3300 globalized version number for Android project. 2013-05-13 02:18:27 +00:00
rolzad73@gmail.com
0908c76434 -Added Android release keystore (both passwords are 'password')
- updated ant.properties to reference new release keystore
2013-05-12 19:47:12 +00:00
anthonycalosa@gmail.com
1edd1546a2 Martyr of sands removed from unsupported.txt 2013-05-12 00:40:34 +00:00
anthonycalosa@gmail.com
c2abc6e4a8 added Debt to the Deathless 2013-05-12 00:14:20 +00:00
anthonycalosa@gmail.com
7905ed1533 updated code for False Cure and Transcendence. added Martyr of Sands to borderline. 2013-05-12 00:03:11 +00:00
omegablast2002@yahoo.com
f6f75ca660 psp comp fix, I was not able to test it though as i am not set up to comp psp builds anymore. 2013-05-11 00:48:21 +00:00
omegablast2002@yahoo.com
9f6a728150 i run the set names through translation now when filtering by sets.
what this means is that if a player so choose, they can list the sets 3 letter code in the en.txt as follows
BOK=betrayers of kamikawa
it will now list the names either as the 3 letter code if thier is no entry, or as whatever you call it in the lang->en.txt file.
2013-05-09 01:53:01 +00:00
omegablast2002@yahoo.com
54021a7f75 removed the remaining trademarked names. for future reference: we are not allowed to add the set names directly to card.dats. WOTC trademarks the names of sets months before they are released. 2013-05-09 00:49:56 +00:00
omegablast2002@yahoo.com
9f89353b4b reverted the adding of trademarked names to card.dat, as sad as it is we have to follow the laws. 2013-05-09 00:39:51 +00:00
wagic.the.homebrew@gmail.com
9fa9e1eb81 undo my changes with libhgetools.a, it seems something's wrong on my end, as my computer interprets u32 as unsigned long instead of unsigned int 2013-05-08 12:37:16 +00:00
omegablast2002@yahoo.com
e54d212418 thanks MarSprite for adding the missing set names to the card.dats missing them. 2013-05-08 01:57:06 +00:00
anthonycalosa@gmail.com
07fdf735f5 added "twice" and "thrice" variables.
example usage:

auto=life:thriceX
auto=@damaged(player):life:twicethatmuch
auto=life:twicetype:creature:mybattlefield

so to code cards like Debt to the Deathless

[card]
name=Debt to the Deathless
auto=@lifeloss(opponent):life:thatmuch controller
auto=life:-twiceX opponent
text=Each opponent loses two times X life. You gain life equal to the life lost this way.
mana={X}{W}{W}{B}{B}
type=Sorcery
[/card]
2013-05-07 07:27:45 +00:00
omegablast2002@yahoo.com
a7e9fe6699 spanish translation stuff, thanks atriel 2013-05-06 23:21:29 +00:00
punkeduard@gmail.com
f3df94b319 Fixed some dragons maze cards 2013-05-06 17:26:54 +00:00
wagic.the.homebrew@gmail.com
aa51083b2b update hge compiled lib 2013-05-06 06:01:19 +00:00
wagic.the.homebrew@gmail.com
0c8f1e1573 Increase version number to 0.19.0. I did it manually, not sure how to run the build scripts :/ 2013-05-06 05:10:19 +00:00
anthonycalosa@gmail.com
386fc08e3a Added Reap Intellect :) 2013-05-05 23:25:12 +00:00
wagic.the.homebrew@gmail.com
a40c677f1e Adding test for i953 2013-05-05 13:52:42 +00:00
wagic.the.homebrew@gmail.com
38a203aac8 Reverted the "more than 50 elements in the stack" fix for Exquisite Blood + Sanguine Bond, as this created more issues than it fixed. I'll open a ticket for the Exquisite blood bug 2013-05-05 13:49:51 +00:00
wagic.the.homebrew@gmail.com
2349908f66 Refactored the "fast test", "slow test" bits of the test suite to make the intent clear, and prevent the first test slowness from being broken again. I've kept the fast_test value to 6 (it was originally 3) as Zethfox mentioned weird race conditions when it is set to 6. 2013-05-05 11:56:35 +00:00
omegablast2002@yahoo.com
30d3b52a9e Izzet Staticaster added 2013-05-04 17:58:55 +00:00
omegablast2002@yahoo.com
107874d88e restricted the creation of clones from progenator mimic to check if the clone is a token before making more. 2013-05-04 17:41:10 +00:00
omegablast2002@yahoo.com
f0a6770948 added progenitor mimic and morgue burst 2013-05-04 08:55:00 +00:00
omegablast2002@yahoo.com
14c605f2a6 garruk and rakdos returns fixed 2013-05-03 03:36:07 +00:00
omegablast2002@yahoo.com
8dcd261258 couple card fixes, moved dryad arbor to the end of primitives because it was associating creature and forest in the subtypes and super types list. 2013-05-03 03:33:59 +00:00
omegablast2002@yahoo.com
537f994ae4 added spike jester 2013-05-02 22:12:20 +00:00
omegablast2002@yahoo.com
6403f75769 bad line fixes 2013-05-02 02:33:12 +00:00
omegablast2002@yahoo.com
e076e64d97 changes to fix a bug, previous entries of the same name already exist causing the first oocurence to be used. 2013-05-02 01:57:29 +00:00
omegablast2002@yahoo.com
8deb0537a8 corrected names 2013-05-01 22:54:12 +00:00
omegablast2002@yahoo.com
83ef3aa08c fixed a crash with flip cards. how does the test for this pass? 2013-05-01 00:02:42 +00:00
omegablast2002@yahoo.com
305bdb386b t2 Selesnya deck 2013-04-30 06:27:18 +00:00
omegablast2002@yahoo.com
ad855ce8d1 token fixes for dgm 2013-04-29 02:25:47 +00:00
omegablast2002@yahoo.com
150c28ae72 token fixes for dgm 2013-04-29 02:25:28 +00:00
punkeduard@gmail.com
2a25db403d Fixes to dragon's maze cards 2013-04-28 17:26:10 +00:00
omegablast2002@yahoo.com
80501edc2a format fix 2013-04-28 12:55:49 +00:00
omegablast2002@yahoo.com
d7c1868de3 added corrected and checked the cards for dragon maze, thanks kf1! 2013-04-28 01:03:24 +00:00
omegablast2002@yahoo.com
7b11ede1d5 added dragon maze dat 2013-04-28 01:02:03 +00:00
omegablast2002@yahoo.com
e8ee356892 fix for issue 913. 2013-04-24 13:29:54 +00:00
omegablast2002@yahoo.com
dd68023249 new deck 2013-04-23 23:20:16 +00:00
omegablast2002@yahoo.com
96adbabea8 fixed a crash that could be reproduced demo->classic->best of 3->endless demo 2013-04-21 02:20:22 +00:00
omegablast2002@yahoo.com
89ae87cc3d opps, just a fix 2013-04-11 10:39:16 +00:00
omegablast2002@yahoo.com
8c80efbe2a replaced simon again with a medium thickness version of the same thing. 2013-04-10 22:50:03 +00:00
omegablast2002@yahoo.com
9ffe7349e2 added a hint that allows you to override how ai views a cards effects.
#HINT:good(icy prison)
ai will act as though the effects of this card are now good, choosing to cast it on it's own creatures.

#HINT:bad(ancestral recall)
ai will now use this card targeting the opponent. 
good in cases where you are trying to mill the opponent

the effects in wagic have gotten so complex that ai simply has no idea what some cards should target. this helps in most of the cases.
2013-04-10 02:38:52 +00:00
omegablast2002@yahoo.com
f9410f695a added excessum to the deck builder credits. 2013-04-08 02:20:00 +00:00
omegablast2002@yahoo.com
7c8d3cedbd added 2 more decks from our deck builder excessum 2013-04-08 02:13:46 +00:00
omegablast2002@yahoo.com
49b6b028c5 fixed a bug with alwaysattack hint, if there was an attack readied it would undo it by clicking it the second time. 2013-04-07 17:30:48 +00:00
omegablast2002@yahoo.com
1bea0736a5 replaced backdrops pieces, task board, deck menu and deck editor with graphics from kevlahnota's mtg theme. to get the mtg look you will still have to download his theme, however these pieces i felt were so polished that they made the original wagic default theme look slapped together. 2013-04-07 14:41:44 +00:00
omegablast2002@yahoo.com
1c61ebddae added a shuffle to optimizedhand to avoid drawing the same hand over and over when its optimized.
adjusted normal difficulty to include 2 lands, 2 spells under 3 mana.

adjusted hard difficulty to always include 2 lands, the rest are randomly drawn. this prevents ai from being mana screwed on opening hand.
2013-04-07 01:07:00 +00:00
omegablast2002@yahoo.com
6727c1af52 added HINT:alwaysattackwith(targetchooser) and HINT:alwaysblockwith(targetchooser) 2013-04-07 00:56:44 +00:00
omegablast2002@yahoo.com
ce656adeba new simon font. they are a little fatter then i would personally like but they look great on full screen. thanks Atriel for the new simon! 2013-04-07 00:33:27 +00:00
omegablast2002@yahoo.com
2a7bcb2170 ifdef on simon font to up the res of simon.
you will need to rename your old simon font to pspsimon
only english is effected.
2013-04-07 00:32:11 +00:00
anthonycalosa@gmail.com
5789d0cae4 added Shred Memory, Shyft, Simplify 2013-04-05 11:41:35 +00:00
omegablast2002@yahoo.com
80e36c2b92 readjusted the carddisplays for libarary and graveyard for both players to move them off the top of the avatars. you can now click thier respective button to close them when in a targetchooser action.
also readded a piece of code i commented out, it does nothing but the compiler saids it expected something there.
2013-03-30 17:09:50 +00:00
omegablast2002@yahoo.com
c9360eb005 added the first 18 decks by our very talented deck builder excessum! i've had a chance to play against these before they got the combohint vamp up, i imagine now they're almost unstoppable. enjoy! make sure to thank excessum on the forum if you enjoy them as much as i have. 2013-03-29 20:23:32 +00:00
omegablast2002@yahoo.com
734b142879 the fix originally only targeted too many triggers unresolved on the stack, moving the other 2 out of the check as it actually causes new bugs to include them in the skip. 2013-03-28 00:05:39 +00:00
omegablast2002@yahoo.com
bfb88f1bb5 increased the res of f3 font to 1024 x 1024. renamed old to pspf3 these will be the new f3 fonts using much higher res on everything but psp. 2013-03-27 23:31:38 +00:00
omegablast2002@yahoo.com
802c970ec3 #ifdef psp for the increase res font f3 which is by far the worst looking font on higher res devices. 2013-03-27 23:29:18 +00:00
omegablast2002@yahoo.com
b38d6c6bc5 applying the patch for torny mode not awarding credits at end of torny. 2013-03-27 22:58:51 +00:00
Xawotihs@gmail.com
701ca64e8a Display IP address of game host before connection is established and handles disconnection of peer. 2013-03-26 22:32:29 +00:00
omegablast2002@yahoo.com
810c3967d6 after much testing and corrections, our user Holgern from the forums has completely recreated and reworked the gauntlet mode originally coded for ai vs ai into a completely new way to play wagic, you can choose the number of matchs, various modes, and other wonderful additions. Don't take my word for it, try all the fun new stuff out yourself!
THANK YOU Holgern!
2013-03-26 02:10:45 +00:00
omegablast2002@yahoo.com
c994886ca8 polished the actionstack rendering a little. draw only as much black square as we need to render so we dont make a massive black square for nothing. 2013-03-23 20:53:33 +00:00
Xawotihs@gmail.com
2c0e0c7251 Removed the link between the font textures resolution and the size of the characters displayed. That allows to use very high resolution fonts similarly to card pictures... 2013-03-23 17:21:17 +00:00
omegablast2002@yahoo.com
b6a4197d88 fix for a bug i introduced. 2013-03-23 06:21:01 +00:00
omegablast2002@yahoo.com
e2f4dd7095 if its a land you should consider playing it. 2013-03-22 01:35:45 +00:00
omegablast2002@yahoo.com
0578ebde80 minor fixes for combo system. 2013-03-22 00:53:42 +00:00
omegablast2002@yahoo.com
9b44d627a3 changed ai eff return on token creation. over 50 tokens on my battlefield return 0.
changed an inefficient check on phaseskip.
2013-03-21 01:28:56 +00:00
omegablast2002@yahoo.com
8b626b378f that was not supposed to be in that last commit. someone please teach me to revert just a file without having to do a rain dance. 2013-03-16 21:50:21 +00:00
omegablast2002@yahoo.com
b436550150 ai simple combo system is finally fully working.
added ai hint dontblockwith(targetchooser)
2013-03-16 21:35:10 +00:00
anthonycalosa@gmail.com
c2132ab97f morthan typo 2013-03-15 23:51:04 +00:00
omegablast2002@yahoo.com
22640130dc fixes from the bugs section on the forum 2013-03-15 22:52:02 +00:00
omegablast2002@yahoo.com
90a0f5c86f as per mtg rules, the effects of unpaid upkeep cost should only happen if the from id was upkeep. ie:skipped phases. 2013-03-15 21:49:35 +00:00
omegablast2002@yahoo.com
3cb0a6c091 psp compilation fix 2013-03-15 21:42:24 +00:00
anthonycalosa@gmail.com
1818a8be82 corrected some typos 2013-03-15 15:13:02 +00:00
omegablast2002@yahoo.com
9c0ce5f7bf more changes to fix the combo system. 2013-03-15 02:08:03 +00:00
omegablast2002@yahoo.com
31ee6d2b90 trying to figure out why ai is cast cards that belong to a combo outside of a combo even though it is told to skip these cards. 2013-03-15 01:44:31 +00:00
omegablast2002@yahoo.com
d4ff6d1453 spanish translation stuff 2013-03-14 22:22:18 +00:00
omegablast2002@yahoo.com
a7aeb7efe5 fix for a bug in combohint. ai will now rarely want to use a card outside of a combo if it is to be held for a combo 2013-03-13 01:11:58 +00:00
omegablast2002@yahoo.com
cd54ad7012 correction 2013-03-07 03:35:35 +00:00
omegablast2002@yahoo.com
04dce1ad50 ai vs ai matchs will play with optimizedhands. 2013-03-01 23:10:16 +00:00
omegablast2002@yahoo.com
ef18f376b1 ifdef(psp) on cache hit miss handling. 2013-02-26 23:22:49 +00:00
anthonycalosa@gmail.com
f9bd6e1c44 Added:
Scuttlemutt
Shieldmage Elder
Shields of Velis Vel
Show and Tell

Borderline:
Scapeshift

Fix:
Talara's Battalion - changed restrictions= to restriction=
2013-02-22 13:22:00 +00:00
anthonycalosa@gmail.com
e8f8aae43f fix kjeldoran home guard and bloodlord of vaasgoth 2013-02-22 07:41:06 +00:00
omegablast2002@yahoo.com
b4d4515e01 set init baka timer fastmode to a safer float. 2013-02-21 22:59:59 +00:00
omegablast2002@yahoo.com
9a52ae28a2 several changes here,
first, i added a timer to hide the big card after 5 secs or until a movement is registered. 

2nd, removed the advancing of phases with flick up.

3rd added a flick left to "show/hide hand"

4th, fixed an error in the logic of "getDifficulty" part of the reason optimizedhand was not working.

finally, unrefactored the checks of optimized hand, it was FAR to difficult to see what was actually happening the way it was coded.

optimizedhand is finally working again, 
toggledifficulty and optimizedhand will again trigger and greatly improve ai vs player matches
2013-02-21 00:48:39 +00:00
anthonycalosa@gmail.com
2330e6a613 fix all similar cards like Duress to have a "look" ability. 2013-02-20 09:04:09 +00:00
anthonycalosa@gmail.com
620c5595d9 Fix various typos reported on the forum. 2013-02-20 04:05:16 +00:00
omegablast2002@yahoo.com
a5ea3275cd i introduced a bug a couple revs back. dyslexia got me. 2013-02-16 21:07:13 +00:00
anthonycalosa@gmail.com
bf677b7bdd Added:
Jilt
Jugan, the Rising Star
Laquatus's Creativity
Mogg Infestation
Prahv, Spires of Order
Quest for the Holy Relic
Razing Snidd

Fix:
Gerrard Capashen - first ability is targeted
Spiraling Embers - removed "(" and ")" and revised
Sword of War and Peace - revised
Venser's Journal - revised
Vicious Shadows - ability is targeted
2013-02-16 09:46:18 +00:00
anthonycalosa@gmail.com
026600c084 Added:
Careful Consideration
Haunting Hymn
Might of Old Krosa
Return to Dust
Sulfurous Blast

Fix:
Liliana of the Dark Realms - missing add, thanks Tacoghandi
2013-02-16 05:59:50 +00:00
anthonycalosa@gmail.com
a1a16fce57 Added Flux, Freyalise Supplicant, Hag Hedge-Mage, Harsh Mercy 2013-02-15 10:55:41 +00:00
omegablast2002@yahoo.com
defb8e32c6 corrected the mana not removing from pool correctly bug, sorry about that. 2013-02-13 23:33:05 +00:00
omegablast2002@yahoo.com
8aef74e32a pestilence shouldn't care about protections of any kind. 2013-02-12 23:09:24 +00:00
anthonycalosa@gmail.com
fbc1b14dca Added:
Mark of Sakiko
Sakiko, Mother of Summer
Sakura-Tribe Springcaller
Shizuko, Caller of Autumn
Upwelling
2013-02-12 13:08:17 +00:00
omegablast2002@yahoo.com
e24f269c36 just a format 2013-02-10 14:34:13 +00:00
omegablast2002@yahoo.com
3c15357c38 added poolsave(COLOR) its an ability that works only on permanents in play.
opponentpoolsave(
mypoolsave(
ex:Upwelling


added a tag for mana, doesntempty
add{g}{g}{g} doesntempty
what this does is make THAT mana remain in the pool until end of turn.
ex:
Sakura-Tribe Springcaller
2013-02-09 06:48:16 +00:00
omegablast2002@yahoo.com
2b4c3a51aa removed a condiational that was limiting blink ability. i left the portion commented out just incase i put it there becuase of a bug. but as far as i can see it doesn't seem to cause an issue to remove it. 2013-02-09 02:37:22 +00:00
omegablast2002@yahoo.com
f0405342be commited the spanish translation files that the spanish wagic group have worked so hard at producing a full almost 100% translation of wagic into spanish.
thank you to the translators involved in making it happen.
http://wololo.net/forum/viewtopic.php?f=24&t=16761
for more info and spanish card images.
2013-02-09 02:09:02 +00:00
omegablast2002@yahoo.com
d2f14897a6 fixed a loop that can occur in multitarget where the maxs targets are set with a variable word and ends up resulting in a return of maxtargets = 0 which inturn locks ai in a loop, i imagine layers also. 2013-02-08 00:34:45 +00:00
dan.solomatin@googlemail.com
8b7c0e6b83 Fixed Righteous Indignation. 2013-02-07 23:14:59 +00:00
anthonycalosa@gmail.com
f7116a84b4 Added Slavering Nulls, Slum Reaper, Smallpox, Snakeform 2013-02-07 14:33:52 +00:00
anthonycalosa@gmail.com
dff6302773 Added Skyship Weatherlight 2013-02-07 11:44:52 +00:00
anthonycalosa@gmail.com
b88b217c46 Added Domestication, Duergar Hedge-Mage, Ertai's Trickery 2013-02-07 11:33:07 +00:00
dan.solomatin@googlemail.com
13c10ec856 Added 4 cards based on revision4692.
Duct Crawler
Screeching Griffin
Shrewd Hatchling
Spin Engine

Optimized the code of 11 cards based on the same revision:

Boldwyr Intimidator
Bower Passage
Brassclaw Orcs
Gibbering Hyenas
Goblin Mutant
Hunted Ghoul
Ironclaw Buzzardiers
Ironclaw Orcs
Orcish Veteran
Orgg
Sabertooth Alley Cat
2013-02-07 11:00:15 +00:00
omegablast2002@yahoo.com
54780d3ef0 fixed a typo in cantbeblockerof , forgot a letter :X 2013-02-06 23:52:09 +00:00
dan.solomatin@googlemail.com
cea9f0d8ae Added more info to Decimate to clear out its current overpoweredness. 2013-02-06 18:02:14 +00:00
dan.solomatin@googlemail.com
3daa0eec7d Moved Decimate from unsupported.txt to crappy.txt.
The Wagic version of Decimate would be like 50$, while the real version is currently 2$ max.
2013-02-06 17:50:47 +00:00
dan.solomatin@googlemail.com
101dd163a3 Fixed small typo in Consuming Ferocity's code. 2013-02-06 10:18:01 +00:00
dan.solomatin@googlemail.com
c33ae31895 Moved Decimate from to unsupported.txt.
Decimate should only be castable if there are 4 legal targets for it.
If treated like it is in the current way of coding, the card is more then overpowered and thus shouldn't even be moved to crappy.txt!
2013-02-06 09:11:43 +00:00
omegablast2002@yahoo.com
cbe6028a52 opps, i need to slow down my happy trigger finger before i hit commit. 2013-02-06 02:55:27 +00:00
omegablast2002@yahoo.com
e424c3ab27 fixed a bug with lords not removing altercost correctly when the source is phased.
added 
cantbeblockerof(this)<--this = the card who owns the ability.
cantbeblockerof(targetchooser) <--the target cant block anything targetable by this targetchooser.
spin engine and similar will use cantbeblockerof(this).
others were done with a workaround, which i hope will be updated soon.
2013-02-06 02:45:40 +00:00
anthonycalosa@gmail.com
1d06a74fd9 added:
Death Cloud
Decimate
Destructive Force
Din of the Fireherd
2013-02-05 13:27:56 +00:00
anthonycalosa@gmail.com
81294a0d2b Added:
Azorius Ploy
Barter in Blood
Consuming Ferocity
Corpse Harvester
Corrupted Resolve
Cruel Ultimatum
Cyclopean Tomb

Borderline:
Consume Strength

Fixes:
Contagion Engine - can select targets once but add counters twice
Emblems missing forever tag

Moved Drain Life - we can now limit black using {X:black}
2013-02-05 10:43:03 +00:00
anthonycalosa@gmail.com
ae8893617f Shifting sliver evasion doesn't work with creatures with protection from color 2013-02-05 04:02:26 +00:00
anthonycalosa@gmail.com
38895dfcd3 @each myupkeep -> @each my upkeep
fix recurring nightmare cost, Snow hound cost.
2013-02-04 14:08:05 +00:00
omegablast2002@yahoo.com
90c0b42a07 changed the defaults of the testsuite game constructor to set the default timerlimit to 6
the other threads were running test suite at 0 which was causing race condition fails in test suite, i incremented by 1 until the normally passing test no longer failed, test effected were proliferate and mortician beetle both passing test in normal mode, failing in hyperspeed. test suite takes only 30 secs more to run but we can't sacrifice actual results for speed.

the commented out section is not even taken into account after first test is run.
2013-02-04 05:09:52 +00:00
omegablast2002@yahoo.com
7e16b50fd3 just giving credit 2013-02-04 02:49:52 +00:00
Xawotihs@gmail.com
5a9b7eefc0 Fixed PSP compilation by stubbing the socket implementation. Somebody with a PSP, please replace this code with a real implementation. 2013-02-03 21:41:31 +00:00
Xawotihs@gmail.com
5c25189aef Added code to let user specify the server address.
Updated SimplePad to include dot and fixed problem with digits.
2013-02-03 19:21:43 +00:00
anthonycalosa@gmail.com
452ae08593 Cleanup my mess... 2013-02-03 15:57:48 +00:00
omegablast2002@yahoo.com
b85f2240a7 fix for @sacrificed crash and not triggering to cost. 2013-02-03 15:31:06 +00:00
anthonycalosa@gmail.com
6928df6819 Added Sedris, the Traitor King 2013-02-03 13:45:56 +00:00
anthonycalosa@gmail.com
6fa633f822 tests:
-----------
Mortician_Beetle.txt
Savra_Queen_of_the_Golgari.txt

added:
-----------
Saprazzan Breaker
Savra, Queen of the Golgari

borderline:
-----------
Ogre Marauder

crappy:
-----------
Barbarian Bully
Skullscorch
2013-02-03 11:21:12 +00:00
omegablast2002@yahoo.com
2b9fdc41dc added 2 new restrictions for use in triggers and abilities
ownerscontrol
opponentscontrol

ownerscontrol returns 1 if the owner has the card in thier battlefield. 0 otherwise. vice versa.
this should make it easier to add cards which should be treated differently depending on who controls them.
2013-02-02 18:42:39 +00:00
anthonycalosa@gmail.com
ef4a8c6d84 Moved rune of protection to crappy.
Revised Pursuit of Knowledge
Added Samite Elder
2013-02-02 14:24:07 +00:00
anthonycalosa@gmail.com
44fa0e9015 added:
Reap
Rebel Informer
Repopulate
Rix Maadi Guildmage
Rocket Launcher
Roots of Life
Rotting Giant
Rune of Protection: Artifacts
Rune of Protection: Black
Rune of Protection: Blue
Rune of Protection: Green
Rune of Protection: Lands
Rune of Protection: Red
Rune of Protection: White
Sadistic Augermage

borderline:
Rakdos Augermage
2013-02-02 10:50:16 +00:00
omegablast2002@yahoo.com
a8ebaee527 added a check to avoid skipping a gameState update if there are more than 50 items left to resolve in the stack, let run a gameStates check and see if we havent already won.
Exquisite Blood + Sanguine Bond example of the kinds of loops this fixes.
2013-02-02 05:43:46 +00:00
anthonycalosa@gmail.com
cca8f1ce4e minor cleanup spaces 2013-02-02 03:49:53 +00:00
anthonycalosa@gmail.com
a8c6da03a8 Added - Prismatic Lace, Quickchange
Borderline - Govern the Guildless
Fixed - Prismwake Merrow
2013-02-02 02:23:05 +00:00
omegablast2002@yahoo.com
6a1591d72b reverted the newtarget/retarget fix, it didn't fix the issue and created new ones. 2013-02-01 18:54:07 +00:00
anthonycalosa@gmail.com
fa5e3ad9b4 Softcoded Reminisce
Added Prismatic Lace in Borderline
2013-02-01 14:34:30 +00:00
anthonycalosa@gmail.com
0095dcceb5 Added Predatory Advantage, Priest of Yawgmoth & Pursuit of Knowledge 2013-02-01 14:04:17 +00:00
omegablast2002@yahoo.com
6c86c276d2 missed a file last commit. 2013-02-01 04:35:40 +00:00
omegablast2002@yahoo.com
0bd769d3c0 added engine code to do a putinzone without sending events.
equipping no longer retriggers a copier.
retarget and newtarget no long send the events due to refreshing the cards.
2013-02-01 04:21:08 +00:00
anthonycalosa@gmail.com
94955088c8 Moved Gerrard's Verdict, Lurking Evil to crappy.
Added Rix Maadi, Dungeon Palace
Added Rotting Rats
Added Stronghold Rats
2013-02-01 03:15:39 +00:00
anthonycalosa@gmail.com
7de5cfbd37 Fixed Possessed Portal since you cant discard a card unless you have one permanent to sacrifice, replace 0/0 with donothing
Moved Maralen of the Mornsong to borderline since the effect is not draw replacement but players cant draw anything (there isn't any stated "would draw"), maybe we can have CANTDRAW ability in the future.
2013-02-01 02:20:27 +00:00
anthonycalosa@gmail.com
ea0a3efc38 Added Possessed Portal. 2013-01-31 14:37:29 +00:00
anthonycalosa@gmail.com
6e7c57151c Added Piston Sledge, fixed Grifter's Blade 2013-01-31 13:52:50 +00:00
omegablast2002@yahoo.com
2ef93bc722 readded the rest of the stuff that anthony commited that the svn ate during my commit. 2013-01-31 11:33:30 +00:00
anthonycalosa@gmail.com
21897f2f63 removed workaround, and revised code to simian spirit guide and elvish spirit guide. 2013-01-31 11:09:20 +00:00
anthonycalosa@gmail.com
de16c53534 Re commitied my previous cards in primitives/mtg.txt
I dont know why my previous commit has been removed but its all working. I included tests for the cards in this commit. All test suite passes. please update your FUT/_cards.dat because i change the name of oriss to its original name.

--------------------------------------
[card]
primitive=Oriss, Samite Guardian
id=136210
rarity=R
[/card]
2013-01-31 09:00:25 +00:00
omegablast2002@yahoo.com
a83e029ca6 master transmuter can now be the card returned 2013-01-31 06:55:12 +00:00
omegablast2002@yahoo.com
aadd0c56b2 fixed a couple easy issues 2013-01-31 06:45:50 +00:00
anthonycalosa@gmail.com
29c50becf0 Added Pain Magnification 2013-01-30 15:51:07 +00:00
anthonycalosa@gmail.com
dffecf7ee0 Added Nim Devourer
Added Nourishing Shoal
Added Oak Street Innkeeper
Added Opal Avenger
-----------------
Revised Oriss, Samite Guardian - ability must be targeted
-----------------
fixed Blazing Shoal alternate cost
fixed Contaminated Ground trigger
2013-01-30 14:46:57 +00:00
omegablast2002@yahoo.com
eab782c32f this was accidental, i was just about to toy with a may pay( ability. 2013-01-30 04:22:01 +00:00
omegablast2002@yahoo.com
1b689adf05 forgot a ( in the replacement for donothing 2013-01-30 04:01:57 +00:00
omegablast2002@yahoo.com
c078af5f24 fix for crash from not having a playerTarget when ability$! is used on targetedPlayer by an instant. 2013-01-30 03:51:16 +00:00
anthonycalosa@gmail.com
d07951fbdf Added Nemesis Trap, Nicol Bolas, Planeswalker 2013-01-30 03:25:22 +00:00
omegablast2002@yahoo.com
415e8dbcb2 updated cards using 0/0 as a fake ability into donothing 2013-01-30 02:40:49 +00:00
omegablast2002@yahoo.com
f8800b8bbd added an ability keyword that resolves to do nothing.
"donothing"
this is to avoid using powerandtoughness 0/0 ability to mean "do nothing"

old code
[card]
name=Inquisition
target=player
auto=target(*|targetedpersonshand) 0/0
auto=foreach(*[white]|targetedpersonshand) damage:1 targetedplayer
text=Target player reveals his or her hand. Inquisition deals damage to that player equal to the number of white cards in his or her hand.
mana={2}{B}
type=Sorcery
[/card]

new code
[card]
name=Inquisition
target=player
auto=target(*|targetedpersonshand) donothing
auto=foreach(*[white]|targetedpersonshand) damage:1 targetedplayer
text=Target player reveals his or her hand. Inquisition deals damage to that player equal to the number of white cards in his or her hand.
mana={2}{B}
type=Sorcery
[/card]
2013-01-30 02:38:25 +00:00
omegablast2002@yahoo.com
b7a2c000be corrected typo in lurking evil.
just for future notice this card should be moved to crappy.
whenever an ability has
blah blah:effect
that means, {cost}:effect
if you can not do it with supported cost in engine, do not add it as
{0}:effect && effect
this is a workaround we stopped using a very very long time ago.
the ability of losing life is not treated the same as "paying" life. same as any other cost.

the issue arose several times while i have added support, and due to a workaround, my support would be flawed, at first i would try to munipulate what i coded to allow for the workarounds to continue working. 
that was the past, i long since stopped doing that, if a card is a workaround, and it breaks, i remove it completely.
2013-01-30 00:36:09 +00:00
Xawotihs@gmail.com
12620e5d22 Just tested network game Linux desktop vs Android tablet ... works fine :) 2013-01-29 21:05:24 +00:00
anthonycalosa@gmail.com
0a8c846f9a added:
Mangara's Equity
Maralen of the Mornsong
Mercenary Informer
Mind Swords
Monkey Cage
Myr Battlesphere
Mystic Snake
Necropolis
2013-01-29 15:35:16 +00:00
omegablast2002@yahoo.com
c7e1dfb72f added rules to hermit 2013-01-29 00:57:38 +00:00
Xawotihs@gmail.com
47cfc5bdeb Reverted TestSuiteAI.cpp from previous commit 2013-01-28 22:40:56 +00:00
Xawotihs@gmail.com
73131c8064 Removed unused variables 2013-01-28 22:37:01 +00:00
Xawotihs@gmail.com
48d45f2a65 Added missing .h and fixed the boost sleep, it works fine on linux now. 2013-01-28 22:26:13 +00:00
Xawotihs@gmail.com
faff7724d6 Added a function to get the current IP address 2013-01-28 22:03:26 +00:00
anthonycalosa@gmail.com
f1fa655306 added cards:
------------
Lore Broker
Lorthos, the Tidemaker
Luminarch Ascension
Lurking Evil
Magus of the Jar
Makeshift Mannequin
Malfegor
Manaforge Cinder
Memory Jar

fixed:
------------
Geist of Saint Traft token, it says @combat ends exile the token.
2013-01-28 12:56:32 +00:00
anthonycalosa@gmail.com
313598fab0 fixed sublime archangel 2013-01-28 06:58:53 +00:00
anthonycalosa@gmail.com
da186a6225 revised living death and living end 2013-01-28 06:06:13 +00:00
omegablast2002@yahoo.com
3ac3836538 added the stack to countValidTargets() 2013-01-28 05:04:34 +00:00
omegablast2002@yahoo.com
2b9cae8950 added functionality to may and choice ability so that it can check a "restriction{}" like a activated ability with cost, that can keep a menu option from appearing if the restriction is not met
auto=choice damage:1 target(creature) restriction{type(creature[blue])~morethan~1}

this choice menu will only appear is there is more than one blue creature inplay
2013-01-28 03:49:24 +00:00
anthonycalosa@gmail.com
a32a58f621 Added Cards:
------------
Laquatus's Champion
Lich's Tomb
Liege of the Tangle
Living Death
Living End,
Locust Miser
Lodestone Bauble

Fixes: Flakenrath Aristocrat, Sublime Archangel
2013-01-28 01:39:30 +00:00
omegablast2002@yahoo.com
eaf4d94a2e this part didnt commit in last rev, it fixes the mana display.
the progress is removed on this though, so you might not notice it until next release when you do a fresh install.
any new decks for both player or ai will show the mana symbols after a match is completed.
2013-01-27 19:35:52 +00:00
omegablast2002@yahoo.com
dac14020a2 fixed stats resetting and decks being marked as new.
this should also allow for the ai difficulty tools to work correctly again. mana symbols displayed again, mini info, and everything related to the stats.
2013-01-27 18:52:12 +00:00
wagic.the.homebrew@gmail.com
5fa1cc915b A "fix" for Android compilation. Feel free to replace if something better is available 2013-01-27 09:36:43 +00:00
omegablast2002@yahoo.com
2fcd031a7d corrected a crash from NULL pointer cause by ability$! not having the "lastcontroller" set. 2013-01-27 04:25:09 +00:00
omegablast2002@yahoo.com
822c3bc9c8 2013-01-27 02:56:23 +00:00
omegablast2002@yahoo.com
b7c13825c5 2013-01-27 02:55:35 +00:00
omegablast2002@yahoo.com
534d87e3bd fixed evolve hoepfully for the final time. 2013-01-27 02:54:03 +00:00
anthonycalosa@gmail.com
c1c6296c9c modified _tests.txt 2013-01-27 02:29:53 +00:00
anthonycalosa@gmail.com
79d9ad865e moved the evolve test outside the main test suite 2013-01-27 02:13:35 +00:00
wagic.the.homebrew@gmail.com
d8da70361a - Fix an android warning (false instead of null in GuiCombat)
- removed unnecessary "if" in some parts of MTGRules.cpp
2013-01-27 02:09:10 +00:00
anthonycalosa@gmail.com
f6e95af995 Added generic test for Evolve mechanic. I intentionally reverese the order of creature so that the evolve come in play with no counters before hand, then attack with utvara hellkite to see if it will trigger evolve. 2013-01-27 01:24:44 +00:00
anthonycalosa@gmail.com
892c7d34c0 fixed Firemane Avenger, added Knollspine Dragon 2013-01-27 00:13:10 +00:00
Xawotihs@gmail.com
975445d3d5 #ifdef out on Windows a fix for Linux 2013-01-26 22:35:57 +00:00
Xawotihs@gmail.com
eec9bb44a8 Fixed warnings from linux and Android compilers
Cleaned up network code on Linux, it still does not work correctly
2013-01-26 22:17:43 +00:00
omegablast2002@yahoo.com
5b0f5bd90f fixed compilation for psp, ambiguous else warning. 2013-01-26 18:50:28 +00:00
omegablast2002@yahoo.com
3443c8d075 corrected a goof up i made in evolve, i should have been comparing the events card controller to source controller to determine "under your control" 2013-01-26 16:52:34 +00:00
Xawotihs@gmail.com
f45c8e1d41 Just won my first Wagic network game :)
In details:
- I removed my player swap idea, it caused tons of issues with randoms
- instead I simply keep both peer on the exact same game and added one single parameter allowing to configure the view on the game. So, each peer is rendering the same game (gameObserver class) from a different player point of view (DuelLayers and related classes).
- a lot of gui stuff are missing to prevent user forbidden interactions but it works fine on Windows
2013-01-26 16:42:16 +00:00
omegablast2002@yahoo.com
db0f401ba5 moved the triggering of forced lure block to eventblockerschoosen. this corrects issues where lure wasnt applying the abilities like flanking correctly on cards which were forced to block. 2013-01-26 16:23:22 +00:00
anthonycalosa@gmail.com
f59b8db91f Added test for Alluring Scent -> card that grants lure ability. the following are to test if forcing a block from lure, trigger events of a block. I don't know if the problem is lure or the flanking ability. the correct result is every creature must survive. flanking makes the walls power to 0. 2013-01-26 13:12:16 +00:00
anthonycalosa@gmail.com
ed77b40a29 added cards
--------------

Hurloon Shaman
Ignorant Bliss
Ill-Gotten Gains
Impatience
Innocent Blood
Jace's Archivist
Jin-Gitaxias, Core Augur
Kangee, Aerie Keeper
Keldon Battlewagon
Windfall

---------------
fixed Blazing Archon
2013-01-26 09:14:26 +00:00
Xawotihs@gmail.com
365fe10765 Fixed another dumb warning reported in the forum and added a nice assert for synchronization issues during network game. So, don't try it if you're not ready to get crashes in the face. 2013-01-26 08:07:31 +00:00
Xawotihs@gmail.com
da2098368b Added dumb cast for dumb compilators 2013-01-25 23:45:58 +00:00
Xawotihs@gmail.com
2ba5eb0022 Cleaned up Network code (hope that fixes the PSP compilation problems)
Added random seed logging
2013-01-25 21:47:16 +00:00
omegablast2002@yahoo.com
4bf419fbaf corrected evolve triggering from cards moving from inplay to inplay. 2013-01-25 19:56:26 +00:00
anthonycalosa@gmail.com
84950ad1f8 Added test for taunting elf. 2013-01-25 14:51:48 +00:00
omegablast2002@yahoo.com
0db78c0444 force a lure block when the players decide they want to skip the action, a lurer MUST be blocked if the defending creature can block it. this action can not be skipped. 2013-01-25 14:25:26 +00:00
anthonycalosa@gmail.com
f1032c64b5 changed add:{mana} to add{mana} 2013-01-25 02:19:29 +00:00
punkeduard@gmail.com
78797356ea Fixes on Markov Warlord, Skarrg Guildmage 2013-01-25 01:53:03 +00:00
anthonycalosa@gmail.com
2c00d99563 fixed card ability
-------------------
Dwell on the Past
Krosan Reclamation
Loaming Shaman
Memory's Journey
Stream of Consciousness
2013-01-25 01:29:05 +00:00
omegablast2002@yahoo.com
798258798c corrected an issue where ai was able to ignore lure ability 2013-01-24 21:04:23 +00:00
anthonycalosa@gmail.com
fccedcaaab added cards
--------------
Grand Abolisher
Hamletback Goliath
Hanabi Blast
Harmonic Sliver
Heed the Mists
Hellkite Charger
Hired Giant
Homeward Path
Hunter's Insight

---------------
fixed Arboria
fixed Hunters' Feast
fixed Zhang Liao, Hero of Hefei
2013-01-24 17:55:41 +00:00
anthonycalosa@gmail.com
80cdd56971 Added GTC Cards 192/249 (including reprints) refactored all names, ability texts, all codes. also include some fixes on other cards :)
--------------------------------------------------------------------

AEtherize
Adaptive Snapjaw
Aerial Maneuver
Agoraphobia
Alms Beast
Alpha Authority
Angelic Edict
Angelic Skirmisher
Armored Transport
Arrows of Justice
Assemble the Legion
Aurelia, the Warleader
Biomass Mutation
Biovisionary
Bomber Corps
Boros Charm
Boros Elite
Boros Guildgate
Boros Keyrune
Boros Reckoner
Burning-Tree Emissary
Burst of Strength
Cartel Aristocrat
Clinging Anemones
Cloudfin Raptor
Coerced Confession
Corpse Blockade
Court Street Denizen
Crackling Perimeter
Crocanura
Crowned Ceratok
Daring Skyjek
Death's Approach
Deathcult Rogue
Deathpact Angel
Debtor's Pulpit
Devour Flesh
Dimir Guildgate
Dimir Keyrune
Dinrova Horror
Disciple of the Old Ways
Drakewing Krasis
Duskmantle Guildmage
Dutiful Thrull
Dying Wish
Elusive Krasis
Enter the Infinite
Executioner's Swing
Experiment One
Fathom Mage
Firefist Striker
Firemane Avenger
Five-Alarm Fire
Forced Adaptation
Fortress Cyclops
Foundry Champion
Foundry Street Denizen
Frilled Oculus
Furious Resistance
Gateway Shade
Ghor-Clan Rampager
Giant Adephage
Gideon, Champion of Justice
Gift of Orzhova
Glaring Spotlight
Greenside Watcher
Gridlock
Grisly Spectacle
Ground Assault
Gruul Charm
Gruul Guildgate
Gruul Keyrune
Gruul Ragebeast
Guildscorn Ward
Gutter Skulk
Gyre Sage
Hellkite Tyrant
Hellraiser Goblin
High Priest of Penance
Hindervines
Hold the Gates
Holy Mantle
Homing Lightning
Horror of the Dim
Hydroform
Illness in the Ranks
Immortal Servitude
Incursion Specialist
Ivy Lane Denizen
Keymaster Rogue
Killing Glare
Knight Watch
Legion Loyalist
Leyline Phantom
Luminate Primordial
Martial Glory
Massive Raid
Master Biomancer
Merciless Eviction
Merfolk of the Depths
Metropolis Sprite
Millennial Gargoyle
Miming Slime
Mindeye Drake
Molten Primordial
Mortus Strider
Mugging
Murder Investigation
Nav Squad Commandos
Nimbus Swimmer
Obzedat, Ghost Council
Ogre Slumlord
One Thousand Lashes
Ordruun Veteran
Orzhov Guildgate
Orzhov Keyrune
Pit Fight
Predator's Rapport
Primal Visitation
Prime Speaker Zegana
Psychic Strike
Purge the Profane
Rapid Hybridization
Razortip Whip
Realmwright
Riot Gear
Rubblebelt Raiders
Rubblehulk
Ruination Wurm
Rust Scarab
Sage's Row Denizen
Sapphire Drake
Scab-Clan Charger
Scatter Arc
Scorchwalker
Sepulchral Primordial
Serene Remembrance
Shadow Alley Denizen
Shambleshark
Shattering Blow
Shielded Passage
Simic Fluxmage
Simic Guildgate
Simic Keyrune
Skarrg Goliath
Skarrg Guildmage
Skinbrand Goblin
Skyblinder Staff
Skygames
Slate Street Ruffian
Slaughterhorn
Smog Elemental
Spark Trooper
Spire Tracer
Sunhome Guildmage
Sylvan Primordial
Tin Street Market
Totally Lost
Tower Defense
Towering Thunderfist
Truefire Paladin
Urban Evolution
Urbis Protector
Verdant Haven
Viashino Shanktail
Vizkopa Guildmage
Warmind Infantry
Wasteland Viper
Way of the Thief
Wight of Precinct Six
Wildwood Rebirth
Wojek Halberdiers
Wrecking Ogre
Zarichi Tiger
Zhur-Taa Swine

TODO:merge unsupported cards from GTC (but will wait for zeth)
2013-01-24 03:57:02 +00:00
anthonycalosa@gmail.com
ba682e4802 Added:
Gaea's Blessing
Garza's Assassin
Gauntlet of Power
Gerrard's Verdict
Gigantiform
Glory of Warfare
Goblin Brawler
Smite

Fixes:
Opalescence
Thelonite Monk
2013-01-23 03:11:13 +00:00
anthonycalosa@gmail.com
db0dae7f8d Added GTC dat files, all ID, names and rarity are 100% accurate from gatherer. :) (exception change Æ to AE) 2013-01-23 02:07:40 +00:00
Xawotihs@gmail.com
9db8478dfe Created a NetworkGameObserver class able to extend the serialization code of GameObserver to synchronize and forward game actions on the network
Fixes in GameObserver serialization/deserialization code
Fixes in JNetwork and JSocket on windows
Various code cleanup (currentGamePhase access in particular)
Updated GUI code to re-enable a basic network GUI
Activated threaded tests on Windows. It uses 4 threads by default.
2013-01-22 22:39:49 +00:00
anthonycalosa@gmail.com
ada0a1555d cleanup remaining space in add_{mana} 2013-01-22 06:03:45 +00:00
anthonycalosa@gmail.com
782a8305fe Removed all spaces in auto line : Add_{mana} 2013-01-22 05:52:14 +00:00
anthonycalosa@gmail.com
f04dfac4b5 fixed Eiganjo Castle, Nezumi Shortfang, Shimian Specter 2013-01-22 03:34:10 +00:00
anthonycalosa@gmail.com
0b4ebc6e51 fix drana, banshee and added fleshbag marauder, fortune thief, fractured loyalty, frantic search, fungus elemental 2013-01-21 15:26:41 +00:00
anthonycalosa@gmail.com
cae9ff79d6 3rd Part: Dredge & Others
added 19 other cards from unsupported
-------------------------------------
Deus of Calamity
Diaochan, Artful Beauty
Dralnu's Pet
Dreams of the Dead
Due Respect
Ebon Praetor
Ego Erasure
Elemental Mastery
Erhnam Djinn
Essence Vortex
Exhume
False Cure
False Memories
Fanning the Flames
Feast of Worms
Festival of the Guildpact
Fight to the Death
Figure of Destiny
Final Punishment

added 16 dredge & cards with "draw" replacement
-----------------------------------------------
Dakmor Salvage
Darkblast
Golgari Brownscale
Golgari Grave-Troll
Golgari Thug
Grave-Shell Scarab
Greater Mossdog
Life from the Loam
Moldervine Cloak
Necroplasm
Nightmare Void
Obstinate Familiar
Plagiarize
Shambling Shell
Stinkweed Imp
Thought Reflection
2013-01-21 04:54:59 +00:00
anthonycalosa@gmail.com
32d06d1148 change damagecount as damage counter to actual damage received for "normal case" damage, this fixes odcount and pdcount int values. 2013-01-21 01:24:19 +00:00
omegablast2002@yahoo.com
1b7b1e2cf1 add dredge rule. 2013-01-20 20:13:32 +00:00
omegablast2002@yahoo.com
ca3dc49d71 added basic card draw replacement,
auto=replacedraw choice damage:2

auto=replacedraw choice draw:2 noreplace

notice noreplace exempts the draw from sending a draw event. draw events and drawn events are seperate events.

added dredge and it's rules.

[card]
name=Dakmor Salvage
auto=tap
auto={t}:add{b}
dredge=dredge(2)
text=Dakmor Salvage enters the battlefield tapped. -- {T}: Add {B} to your mana pool. -- Dredge 2 (If you would draw a card, instead you may put exactly two cards from the top of your library into your graveyard. If you do, return this card from your graveyard to your hand. Otherwise, draw a card.)
type=Land
[/card]
2013-01-20 20:13:07 +00:00
punkeduard@gmail.com
0709aaefb8 Added from the vaults: realms, after research concluded the official abbreviation is V12 and the others FTV sets should remain the same, this set is just reprints supported 13/15 total 2013-01-19 19:49:36 +00:00
anthonycalosa@gmail.com
69af807510 added City of Solitude, Detonate, Dosan the Falling Leaf, Harsh Justice.
added restriction for Reset, fixed Seedtime, fixed Wild Defiance, fixed Abundant Growth (thanks excessum)
2013-01-19 08:46:10 +00:00
omegablast2002@yahoo.com
a9352a3b69 opened all possible restrictions to be checked as a intvalue of 1, inline with anthonys change a couple revs back.
this(variable:restriction{casted a spell})
2013-01-19 02:06:46 +00:00
anthonycalosa@gmail.com
e67084afb9 Added restriction "during my turn", "during opponent turn".
Added variable "controllerturn", "opponentturn" -> returns integer value if its your turn then 1 if not then 0.

ex. use

restriction=during my turn
otherrestriction=during opponent turn
auto=this(variable{controllerturn}) lord(creature|mybattlefield) 8/0
auto=this(variable{opponentturn}) lord(creature|mybattlefield) 0/8
2013-01-18 04:41:24 +00:00
anthonycalosa@gmail.com
fda7166752 2nd Part:
Added entwine cards and other cards as of SVN r4587.

Entwine Cards
----------------------
Incite War
Journey of Discovery
Promise of Power
Roar of the Kha
Rude Awakening
Savage Beating
Solar Tide
Stir the Pride
Temporal Cascade
Tooth and Nail
Wail of the Nim

Cards from Unsupported
----------------------
Circle of Protection: Shadow
Circle of Solace
Cloudstone Curio
Coalition Relic
Commando Raid
Copy Artifact
Cornered Market
Crack the Earth
Crag Saurian
Crescendo of War
Crypt Champion
Curfew
Dance of the Dead


I don't have an exact amount of cards supported in the latest SVN because there are a lot of cards in my local copy to be tested before commiting.

OT: I think overload card can be done if the target card and store it for use until the spell resolves. ex:

[card]
name=Blustersquall
other={3}{U} name(Overload)
auto=if paid(alternative) then tap all(creature)
auto=ifnot paid(alternative) then tap all(mytarget)
text=Tap target creature you don't control. -- Overload {3}{U} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.")
mana={U}{target(creature|opponentbattlefield)}
type=Instant
[/card]
2013-01-17 02:52:02 +00:00
anthonycalosa@gmail.com
5f90d1ee9f added keyword phandcount - player hand count
added keyword ohandcount - opponent hand count
2013-01-16 12:08:46 +00:00
omegablast2002@yahoo.com
a26f872ff3 add restriction for checking what alternative cost was paid. combined with if/ifnot ability becomes a very powerful tool.
paid(blah)
auto=if paid(alternative) then damage:3 target(creature)
auto=if paid(alternative) then life:10 target(player)
auto=ifnot paid(alternative) then damage:3 controller
auto=ifnot paid(alternative) then life:4 opponent

it can be used any place a restriction can be used. 
rearranged the constants for the payment type keywords to match the order we int the alternatePayment array on a card, added keywords for the remaining payment types, 

    "notpaid",
    "paidmana",
the 2 above pretain to paying the real manacost of a card
it checks the mana={1} cost line and is not joined to the other types.

    "kicker", 
    "alternative", 
    "buyback", 
    "flashback", 
    "retrace", 
    "facedown",
    "suspended"

note: all test pass in this revision.
2013-01-15 02:11:05 +00:00
anthonycalosa@gmail.com
9201860744 Added Oracle of Nectars gain life test. I have 2 tests failed, gain X life and ai proliferation. It seems there is an issue on my maxglee profile(the one i have with lots of deck, i mean a lot). Now I changed my profile to default profile(the one with a demo deck), restarted and run the tests a couple of times and my tests are all succesful 100%. 2013-01-15 01:59:48 +00:00
omegablast2002@yahoo.com
a608de3b73 corrected stasis test to follow the new coding which actually works :)
corrected steelclad_serpent2 test missing choice 0 and p2.

ai proliferate test was not failing for me. it was sucessful on each run.

note 100% pass on this rev.
2013-01-14 23:39:08 +00:00
anthonycalosa@gmail.com
0a8a88f817 fixed kudzu, master of etherium, nevinyrrals disk tests. 3 failed tests remains (phase problems which i really don't know why it fails). all other tests are succesful. 2013-01-14 17:40:07 +00:00
anthonycalosa@gmail.com
e1d2bf56c5 fixed hanna's custody shroud test.(i just changed the rack and black vise to rackling and viseling...gotta get some sleep...:(..) 2013-01-14 17:00:52 +00:00
anthonycalosa@gmail.com
98ea63485d updated kudzu, kudzu2 test. change all(mytgt) to all(trigger) for kudzu. now for kudzu_i168.txt i don't quite understand what is the expected output for this so i leave it unchanged. 2013-01-14 16:46:17 +00:00
anthonycalosa@gmail.com
598ffb1f9b Fixed rampant growth & orcish lumberjack tests (missing choice 0) 2013-01-14 16:03:11 +00:00
anthonycalosa@gmail.com
c3586126a5 Fixed Gamble and Gamble test(it failed because the command has a missing choose 0). Soft coded Insolence, Mana Short, Sacrifice and Touch of Vitae. Changed Rot Wulf to Rot Wolf.
TODO: there are several test that needs updating prior to changes in card primitives (the ones that failed 11 are left).
2013-01-14 15:26:00 +00:00
wagic.the.homebrew@gmail.com
cbcc5a57ca Fixing Gamble (I am aware that this makes the card less close to the rules in theory, but now the test passes. Let's not break some parts of a card when we fix other parts, please).
It is possible revision 4519 introduced other similar issues in other cards, but that revision was so big that I didn't want to revert it entirely
2013-01-14 12:37:53 +00:00
wagic.the.homebrew@gmail.com
9b47a64fd9 reverting r4569. This fixes Flare, and potentially other cards using the same mechanism 2013-01-14 12:14:19 +00:00
wagic.the.homebrew@gmail.com
83c0ee2c28 Fixed "Animate Artifact" tests 2013-01-14 11:26:22 +00:00
wagic.the.homebrew@gmail.com
4be2c39566 Fixed Test for Black Vise 2013-01-14 11:19:04 +00:00
wagic.the.homebrew@gmail.com
1f8e1179cc Fix for issue 930 (Farmstead can be used more than once per turn) 2013-01-14 11:10:01 +00:00
wagic.the.homebrew@gmail.com
2d11392e47 Fixed famrstead test. Sadly, this doesn't fix the card 2013-01-14 08:06:12 +00:00
anthonycalosa@gmail.com
0fcfb43d3a Softcoded Storm Seeker, Traumatize, Venomous Dragonfly 2013-01-14 03:23:33 +00:00
anthonycalosa@gmail.com
2a1f29aebc Fixed remaining transform cards to creatures that uses */* 2013-01-13 15:58:06 +00:00
anthonycalosa@gmail.com
e7dd2e02d6 Fixed some cards that transforms into creature (must use setpower and settoughness, if not the effects are like +1/+1). TODO.... 2013-01-13 14:31:15 +00:00
anthonycalosa@gmail.com
da15bb7427 Fixed Rot Wolf, Revised @next upkeep card draw. 2013-01-13 13:59:24 +00:00
anthonycalosa@gmail.com
6410e25bcc Added check for Ali from Cairo, if you are dealt damage to reduce your life less than 1 from your life total, and you gain life greater than 1, it will not set your life to 1. 2013-01-12 14:44:26 +00:00
anthonycalosa@gmail.com
14e0093eaf Added 16 cards from unsupported.txt
------------------------------------

Abeyance
Agadeem Occultist
Ali from Cairo
Antagonism
Aphetto Dredging
Aquitect's Will
Aura Barbs
Beseech the Queen
Blazing Shoal
Blind Seer
Budoka Gardener
Dokai, Weaver of Life
Builder's Bane
Burrenton Forge-Tender
Cauldron Dance
Cephalid Constable
2013-01-12 14:30:55 +00:00
anthonycalosa@gmail.com
3b08a05421 Fixed all cards that transform cards into new color as an additional color. Added Indigo Faerie. 2013-01-12 14:04:48 +00:00
punkeduard@gmail.com
f74e2019cc Fixed some AVR cards reported on the forums 2013-01-12 04:55:01 +00:00
punkeduard@gmail.com
93c9f12eff Added Dwarven Hold, fixed typo in Curse of the Nightly Hunt, removed sxtra blank space 2013-01-12 04:28:00 +00:00
anthonycalosa@gmail.com
80a3e37961 removed unnecesary spaces in primitives/mtg.txt. 2013-01-11 17:21:10 +00:00
anthonycalosa@gmail.com
4e9dc2c3b1 Added Wurm Token for Garruk, Primal Hunter because it produces 2 different tokens. Change Glory and Zombie Boa chooseacolor to activatechooseacolor. 2013-01-11 12:55:57 +00:00
anthonycalosa@gmail.com
b78c8084be Card Fixes:
------------

Dragon Broodmother - change token id to source card token id
Kjeldoran Javelineer - revised code
Malignant Growth - Growth counter damage
Marsh Crocodile - revised code
Mindslash Sliver - revised code
Phyrexian Etchings - revised code
Psychic Vortex - revised code
Sheltering Ancient - dynamicability<!agecountersoneone!>
Wall of Shards - revised code

updated ARB/_cards.dat (pls. update your ARB set folder)
2013-01-11 07:43:29 +00:00
anthonycalosa@gmail.com
8119f3bc05 fixes includes some card id of tokens be change to display image in game. please update your sets folder and images.
Card Fixes:
--------------

Ajani Goldmane - moved token id to dat file
Army of the Damned - change token id to source token id
Black Vise -  can choose opponent
Chromium - upcost sacrifice
Elephant Resurgence - change token id to source token id
Melancholy - upcost sacrifice
Midnight Ritual - change token id to source token id
Polar Kraken - fix upcost
Rackling - soft coded
Skeletonize - must target beforehand and fix token color & id
Storm World - fix. can't use foreach..<4 because X is 4 minus the cards
Tatsumasa, the Dragon's Fang - revised workaround
Terastodon - change token id to source token id
Tetravus - change token id to source token id
The Rack - soft coded
Thirst - upcost sacrifice
Tombstone Stairwell - revised ability, removed tombspawn primitive
Varchild's War-Riders - fix cumulative upcost
Venser, the Sojourner - fix loyalty counters
Vexing Sphinx - upcost sacrifice
Vraska the Unseen - moved token id
Wall of Shards - fix cumulative upcost
Waylay - generic token coded
Wheel of Torture - fix. can't use foreach..<3 because X is 3 minus the cards

updated necessary dat files for the token ids.
2013-01-10 17:36:22 +00:00
anthonycalosa@gmail.com
0e4994c22c Added 6 Legendary Dragons
-------------------------
Crosis, the Purger
Dromar, the Banisher
Numot, the Devastator
Rith, the Awakener
Treva, the Renewer
Vorosh, the Hunter

Fixed 2 Legendary Dragons
-------------------------
Oros, the Avenger
Teneb, the Harvester


If we have like UEOP ( until end of phase| until end of step ) keyword this will be perfect, but for now I use oneshot. :)
2013-01-10 07:44:55 +00:00
anthonycalosa@gmail.com
c6117fdfb3 Revised Goblin Clearcutter, Manamorphose, Orcish Lumberjack and Terrarion ability. 2013-01-09 11:44:44 +00:00
anthonycalosa@gmail.com
1ff10ed4c7 Added Blinding Powder, Heartseeker and Leonin Bola.
Fixed Finest Hour missing ability, Fire Dragon and Godo, Bandit Warlord typo
2013-01-09 08:05:40 +00:00
anthonycalosa@gmail.com
d83415ed3b fixed Umezawa Jitte menu ability, Centaur Glade token typo, Ghitu-Fire eater missing player target and Flame Elemental dynamic ability typo. 2013-01-09 03:32:11 +00:00
anthonycalosa@gmail.com
e69e002c1a Revised code for Atalya, Samite Master, Crimson Hellkite and Crypt Rats to use {X:color}
Cleaned Manacost.cpp

My observation so far when paying X in activated abilities, when X doesn't work, I press escape to get in the main menu and play another game(test again), then X activated ability will work. I really don't know where to start/look for the cause of it.
2013-01-08 13:26:42 +00:00
anthonycalosa@gmail.com
e5b56cfffb Added 16 cards
---------------
Lure Cards:
Alluring Scent
Bloodscent
Elvish Bard
Gift of the Deity
Golgari Decoy
Lure
Mortipede
Nemesis Mask
Prized Unicorn
Seton's Desire
Shinen of Life's Roar
Stone-Tongue Basilisk
Taunting Challenge
Taunting Elf
---------------
No Legend Cards:
Brothers Yamazaki
Mirror Gallery
2013-01-08 04:01:25 +00:00
anthonycalosa@gmail.com
eeb5a4235b Angel of Serenity - fix ability (like mesmeric fiend, blinked cards return to owners hand if source leaves play)
Angel's Tomb - added may

Archaeomancer - added check

Cathedral of War - removed space

Defang - revised code

Dismal Failure - revised code

Gallows at Willow Hill - removed extra activation cost

Ghostly Flicker - target fix

Hidden Retreat - fix targeted card ability
2013-01-08 03:35:36 +00:00
omegablast2002@yahoo.com
2aed88a44f fixed the simplemenu scrolling bug, the scrolling will no longer jump to the final selection you made when scrolling down and up. 2013-01-07 21:33:59 +00:00
anthonycalosa@gmail.com
b007190d98 updated CHK dat file. 2013-01-07 09:29:43 +00:00
anthonycalosa@gmail.com
510a8c4222 added nolegend ability. this doesn't remove legend rule, it only makes a card thas has nolegend ability excluded from check. 2013-01-07 06:46:56 +00:00
Xawotihs@gmail.com
e2be750780 Adding boost random support and system libs 2013-01-06 19:44:18 +00:00
Xawotihs@gmail.com
38ebdde6ed Adding boost uuid support 2013-01-06 17:53:29 +00:00
Xawotihs@gmail.com
579a651e3d Adding boost weak pointer support 2013-01-06 17:49:55 +00:00
punkeduard@gmail.com
a95a2c4dc2 fixed tribute to hunger, far wandering 2013-01-06 17:32:50 +00:00
punkeduard@gmail.com
edb3295af0 Updated crappy, borderline and mtg to include/fix some cards related to chosen discard 2013-01-06 17:08:21 +00:00
anthonycalosa@gmail.com
3b07ad6b7f Merge RTR card primitives to mtg.txt
187 cards merged:

Abrupt Decay
Aerial Predation
Angel of Serenity
Annihilating Fire
Aquus Steed
Archon of the Triumvirate
Archweaver
Armada Wurm
Armory Guard
Ash Zealot
Assassin's Strike
Auger Spree
Avenging Arrow
Axebane Guardian
Axebane Stag
Azorius Arrester
Azorius Charm
Azorius Guildgate
Azorius Justiciar
Azorius Keyrune
Azor's Elocutors
Batterhorn
Bazaar Krovod
Bellows Lizard
Blistercoil Weird
Bloodfray Giant
Brushstrider
Call of the Conclave
Carnival Hellsteed
Catacomb Slug
Centaur Healer
Centaur's Herald
Chaos Imps
Chorus of Might
Chromatic Lantern
Chronic Flooding
Civic Saber
Cobblebrute
Codex Shredder
Collective Blessing
Common Bond
Concordia Pegasus
Coursers' Accord
Crosstown Courier
Cryptborn Horror
Daggerdrome Imp
Dark Revenant
Dead Reveler
Deadbridge Goliath
Deathrite Shaman
Death's Presence
Detention Sphere
Deviant Glee
Doorkeeper
Dramatic Rescue
Dreadbore
Dreg Mangler
Drudge Beetle
Druid's Deliverance
Dryad Militant
Essence Backlash
Ethereal Armor
Explosive Impact
Eyes in the Skies
Faerie Impostor
Fall of the Gavel
Fencing Ace
Frostburn Weird
Gatecreeper Vine
Gobbling Ooze
Goblin Electromancer
Goblin Rally
Golgari Charm
Golgari Guildgate
Golgari Keyrune
Golgari Longlegs
Gore-House Chainwalker
Grim Roustabout
Grove of the Guardian
Growing Ranks
Guttersnipe
Hellhole Flailer
Horncaller's Chant
Hover Barrier
Hussar Patrol
Hypersonic Dragon
Inaction Injunction
Isperia, Supreme Judge
Isperia's Skywatch
Izzet Guildgate
Izzet Keyrune
Jarad, Golgari Lich Lord
Jarad's Orders
Keening Apparition
Knightly Valor
Korozda Guildmage
Korozda Monitor
Launch Party
Lobber Crew
Lotleth Troll
Lyev Skyknight
Mana Bloom
Martial Law
Mercurial Chemister
Minotaur Aggressor
Necropolis Regent
New Prahv Guildmage
Niv-Mizzet, Dracogenius
Ogre Jailbreaker
Pack Rat
Perilous Shadow
Phantom General
Precinct Captain
Psychic Spiral
Pursuit of Flight
Pyroconvergence
Racecourse Fury
Rakdos Cackler
Rakdos Charm
Rakdos Guildgate
Rakdos Keyrune
Rakdos Ragemutt
Rakdos Ringleader
Rakdos Shred-Freak
Rakdos's Return
Righteous Authority
Risen Sanctuary
Rogue's Passage
Rootborn Defenses
Rubbleback Rhino
Runewing
Savage Surge
Search Warrant
Security Blockade
Selesnya Charm
Selesnya Guildgate
Selesnya Keyrune
Selesnya Sentry
Seller of Songbirds
Sewer Shambler
Shrieking Affliction
Skull Rend
Skyline Predator
Skymark Roc
Slime Molding
Slitherhead
Sluiceway Scorpion
Soul Tithe
Soulsworn Spirit
Spawn of Rix Maadi
Sphinx's Revelation
Splatter Thug
Stab Wound
Stealer of Secrets
Stonefare Crocodile
Street Sweeper
Sundering Growth
Sunspire Griffin
Supreme Verdict
Survey the Wreckage
Swift Justice
Tavern Swindler
Tenement Crasher
Terrus Wurm
Thoughtflare
Thrill-Kill Assassin
Towering Indrik
Trained Caracal
Transguild Promenade
Treasured Find
Trestle Troll
Trostani, Selesnya's Voice
Trostani's Judgment
Ultimate Price
Underworld Connections
Urban Burgeoning
Utvara Hellkite
Vassal Soul
Viashino Racketeer
Vitu-Ghazi Guildmage
Voidwielder
Volatile Rig
Vraska the Unseen
Wayfaring Temple
Wild Beastmaster
Worldspine Wurm
Zanikev Locust
2013-01-06 16:41:52 +00:00
anthonycalosa@gmail.com
5c0a69ea54 Merge AVR, M13, PC2 card primitives to MTG.txt
284 cards merged:

Abundant Growth
Aggravate
Ajani, Caller of the Pride
Ajani's Sunstriker
Alchemist's Apprentice
Alchemist's Refuge
Amass the Components
Angel of Glory's Rise
Angel's Tomb
Angelic Armaments
Appetite for Brains
Arcane Melee
Archaeomancer
Archwing Dragon
Arctic Aven
Attended Knight
Avacyn, Angel of Hope
Baleful Strix
Banners Raised
Battle Hymn
Battleflight Eagle
Beetleback Chief
Bladed Bracers
Blood Artist
Blood Reckoning
Bloodflow Connoisseur
Bloodhunter Bat
Bond Beetle
Boundless Realms
Bower Passage
Brindle Shoat
Bruna, Light of Alabaster
Builder's Blessing
Butcher Ghoul
Call to Serve
Captain of the Mists
Captain's Call
Cathars' Crusade
Cathedral of War
Cathedral Sanctifier
Chandra's Fury
Chronomaton
Cleaver Riot
Cloudshift
Commander's Authority
Human Token
Conjurer's Closet
Corpse Traders
Cower in Fear
Craterhoof Behemoth
Craterize
Crimson Muckwader
Crippling Blight
Crippling Chill
Crusader of Odric
Cursebreak
Dangerous Wager
Deadeye Navigator
Death Wind
Defang
Defy Death
Demonic Rising
Demonic Taskmaster
Demonlord of Ashmouth
Desolate Lighthouse
Devout Chaplain
Diabolic Revelation
Diregraf Escort
Disciple of Bolas
Downpour
Dragon Hatchling
Dragonlair Spider
Dread Slaver
Dreadwaters
Dreampod Druid
Driver of the Dead
Druid's Familiar
Druids' Repository
Duskmantle Prowler
Duty-Bound Dead
Eaten by Spiders
Elderscale Wurm
Elgaud Shieldmate
Emancipation Angel
Encrust
Essence Harvest
Evernight Shade
Exquisite Blood
Faerie Invaders
Faith's Reward
Falkenrath Exterminator
Farbog Explorer
Favorable Winds
Fervent Cathar
Fettergeist
Firewing Phoenix
Flames of the Firebrand
Flinthoof Boar
Fungal Sprouting
Gallows at Willow Hill
Spirit Token
Galvanic Alchemist
Geist Snatch
Geist Trappers
Ghostform
Ghostly Flicker
Ghostly Touch
Ghoulflesh
Goblin Battle Jester
Goldnight Commander
Goldnight Redeemer
Grave Exchange
Griffin Protector
Griselbrand
Grounded
Gryff Vanguard
Guardian Lions
Guise of Fire
Hanweir Lancer
Harbor Bandit
Harvester of Souls
Haunted Guardian
Havengul Skaab
Havengul Vampire
Healer of the Pride
Heirs of Stromkirk
Hellion Crucible
Herald of War
Holy Justiciar
Homicidal Seclusion
Hound of Griselbrand
Howlgeist
Human Frailty
Hunted Ghoul
Hydrosurge
Illusory Angel
Into the Void
Jace's Phantasm
Kessig Malcontents
Knight of Glory
Knight of Infamy
Krenko, Mob Boss
Krenko's Command
Krond the Dawn-Clad
Kruin Striker
Latch Seeker
Leap of Faith
Lightning Mauler
Lightning Prowess
Liliana of the Dark Realms
Liliana's Shade
Maalfeld Twins
Mad Prophet
Magmaquake
Malicious Intent
Mark of the Vampire
Marrow Bats
Mass Appeal
Mass Mutiny
Master of the Pearl Trident
Mental Agony
Midnight Duelist
Midvast Protector
Mind Sculpt
Mist Raven
Moonlight Geist
Moonsilver Spear
Moorland Inquisitor
Murder
Mwonvuli Beast Tracker
Narstad Scrapper
Natural End
Nearheath Pilgrim
Necrobite
Nefarox, Overlord of Grixis
Nephalia Smuggler
Nettle Swine
Nightshade Peddler
Otherworld Atlas
Pathbreaker Wurm
Pillar of Flame
Polluted Dead
Predator's Gambit
Preyseizer Dragon
Primal Huntbeast
Prized Elephant
Public Execution
Raging Poltergeist
Ranger's Path
Reckless Brute
Renegade Demon
Restoration Angel
Riders of Gavony
Righteous Blow
Ring of Evos Isle
Ring of Kalonia
Ring of Thune
Ring of Valkas
Ring of Xathrid
Riot Ringleader
Roaring Primadox
Rotcrown Ghoul
Rummaging Goblin
Rush of Blood
Sai of the Shinobi
Sakashima's Student
Sands of Delirium
Scalding Devil
Scrapskin Drake
Scroll of Avacyn
Scroll of Griselbrand
Searchlight Geist
Searing Spear
Sentinel Spider
Seraph of Dawn
Seraph Sanctuary
Serpent's Gift
Servant of Nefarox
Sheltering Word
Show of Valor
Silverblade Paladin
Slayers' Stronghold
Slumbering Dragon
Smelt
Snare the Skies
Somberwald Vigilante
Soul of the Harvest
Soulcage Fiend
Spectral Gateguards
Spectral Prison
Spiked Baloth
Spirit Away
Staff of Nin
Stern Mentor
Stonewright
Sublime Archangel
Talrand, Sky Summoner
Talrand's Invocation
Tamiyo, the Moon Sage
Tandem Lookout
Terrifying Presence
Thatcher Revolt
Thraben Valiant
Thragtusk
Thundermaw Hellkite
Tibalt, the Fiend-Blooded
Timberland Guide
Timberpack Wolf
Tormentor's Trident
Touch of the Eternal
Trading Post
Treacherous Pit-Dweller
Tricks of the Trade
Triumph of Cruelty
Triumph of Ferocity
Trusted Forcemage
Ulvenwald Tracker
Uncanny Speed
Undead Executioner
Unhallowed Pact
Veilborn Ghoul
Vela the Night-Clad
Vessel of Endless Rest
Vigilante Justice
Vile Rebirth
Voice of the Provinces
Void Stalker
Vorstclaw
Wandering Wolf
War Falcon
Warclamp Mastiff
Watercourser
Wild Defiance
Wild Guess
Wingcrafter
Wolfir Avenger
Wolfir Silverheart
Worldfire
Xathrid Gorgon
Yeva, Nature's Herald
Yeva's Forcemage
Yew Spirit
Zealous Conscripts
Zealous Strike
2013-01-06 09:30:29 +00:00
anthonycalosa@gmail.com
747eec8692 Chill of Foreboding type change to sorcery
Scourge of the Nobilis ability fix 1/0
2013-01-05 15:36:31 +00:00
omegablast2002@yahoo.com
972e2b1ec2 added abilities=lure
"all creatures able to block blah must do so."
2013-01-05 05:01:31 +00:00
omegablast2002@yahoo.com
4960969640 added {unattach} cost
this can also be used for "equipped creature has unattach and blah" cards using 
auto=teach(creature) {unattach}:blah

also corrected a long standing guiupdating issue. a long long time ago a replace was removed from GuiPlay::Update in hopes to increase performance no amount of performance increase is worth having cards not updating thier position after an event recieve happens. this means curse will finally go to the correctly choosen players battlefield, equipment will no longer just linger after its target dies, auras won't stay on battlefield after a card is exiled. ect. no preformance decrease noticed, if anyone else notices one let me know.
2013-01-05 03:05:53 +00:00
omegablast2002@yahoo.com
2fa626b80e adding more strings to translation 2013-01-05 00:38:12 +00:00
Xawotihs@gmail.com
1049f90aa2 Fixed simultaneous access to the card DB. 2013-01-02 16:15:52 +00:00
omegablast2002@yahoo.com
a3017c215f corrected the translation of the phase names string in guiphasebar 2013-01-01 02:00:34 +00:00
omegablast2002@yahoo.com
ad50ce1d48 added a few items to translate on card gui. names and text should now correctly translate in trophy room and shop. 2012-12-31 16:17:38 +00:00
anthonycalosa@gmail.com
153203fba6 adjust alignment 2012-12-29 14:31:28 +00:00
anthonycalosa@gmail.com
780afb6e0c added missing damagecount reset for opponent. this should fix odcount this turn value 2012-12-29 14:25:49 +00:00
anthonycalosa@gmail.com
0ebb151a66 fix some flip cards:
Ichiga, Who Topples Oaks
Cunning Bandit
Garruk the Veil-Cursed
Homura's Essence
Rune-Tail's Essence
Rampaging Werewolf
2012-12-29 09:14:45 +00:00
anthonycalosa@gmail.com
0b1a88e3d7 Added unsupported cards from PC2, M13, RTR. 2012-12-29 03:21:51 +00:00
anthonycalosa@gmail.com
1ad4948594 Updated unsupported.txt, added unsupported cards from AVR.txt. 2012-12-29 01:20:23 +00:00
anthonycalosa@gmail.com
227cfc93f1 fix rarities for CMD, M11, ME4, PD2 2012-12-28 17:47:08 +00:00
anthonycalosa@gmail.com
d9ec37e096 RTR rarities correction 2012-12-28 17:00:02 +00:00
anthonycalosa@gmail.com
fd1becf59c added RTR dat 2012-12-28 16:51:25 +00:00
anthonycalosa@gmail.com
b3195d6111 Added RTR primitives, fix rarities in M12/_cards.dat, fix primitives/PC2.txt 2012-12-28 16:45:18 +00:00
anthonycalosa@gmail.com
755a43bb2a fix AVR, M13 codes and added some cards 2012-12-28 15:52:28 +00:00
anthonycalosa@gmail.com
08a7df0f19 fix M13/_cards.dat and fix M13 codes 2012-12-28 15:08:21 +00:00
anthonycalosa@gmail.com
02a7a7670a fix NPH/_cards.dat 2012-12-28 14:28:19 +00:00
anthonycalosa@gmail.com
2aae7d2c17 fix MBS/_cards.dat 2012-12-28 14:17:07 +00:00
anthonycalosa@gmail.com
35d32ff8fe fix AVR/_cards.dat and ISD/_cards.dat 2012-12-28 13:51:43 +00:00
anthonycalosa@gmail.com
05b775f50e Fix ISD/_cards.dat
change Séance to Seance
2012-12-28 13:38:23 +00:00
anthonycalosa@gmail.com
76efffb295 fix DKA/_cards.dat 2012-12-28 12:40:57 +00:00
anthonycalosa@gmail.com
fa5da87a98 revised primitives/mtg.txt.
-kevlahnota
Issue: 914,920,921
2012-12-28 10:00:23 +00:00
omegablast2002@yahoo.com
238cd124ae corrected the spelling of evolve. thanks kf1 2012-12-27 21:07:20 +00:00
Xawotihs@gmail.com
123a6aa21f Fixed remote hash retrieval 2012-12-26 18:14:27 +00:00
omegablast2002@yahoo.com
651d0b4623 added gatecrash "evole" mechanic.
auto=evole
2012-12-24 16:19:32 +00:00
omegablast2002@yahoo.com
2b4df1cc68 corrected helix pennicle to include a set of extra brackets wrapping the restriction. 2012-11-27 02:47:04 +00:00
omegablast2002@yahoo.com
4ad4689603 allowing restriction to also search for
restriction{{ }} incases where we will have squiqqly brackets in a tc.

this corrects the bug where helix pennicle restricted trigger was not triggering.
2012-11-27 02:45:01 +00:00
omegablast2002@yahoo.com
a87377b25a fixed an error in the reseting of setToughness, kind of a dumb error on my part because i was originally the coder :P
a creatures life and toughness are tied together, if you do not change both then the creature lives on.
2012-11-27 01:53:41 +00:00
omegablast2002@yahoo.com
ca446adf75 fixed a bug in sacrificed trigger. 2012-11-25 05:00:42 +00:00
omegablast2002@yahoo.com
92a8ccebd8 added a new tag to transforms(( keyword ... uynt ...meaning until your(the sources controller) next turn.
this should allow players to code cards with the detain ability of rtr correctly, as well as a handful of similar cards in the unsupported text.

detain is coded 
auto={1}{t}:target(creature|opponentBattlefield) transforms((Detained,newability[cantattack],newability[cantblock],newability[noactivatedability])) uynt

enjoy
2012-11-10 05:08:23 +00:00
punkeduard@gmail.com
8ac44677b8 Removed wild defiance, druids repository, abundant growth 2012-10-07 05:55:40 +00:00
punkeduard@gmail.com
a60a8af2b0 Primitives bug fixes 2012-09-24 02:49:32 +00:00
punkeduard@gmail.com
e809190a82 Added izzet vs golgari duel decks, updates some primitives and bug fixing in cards 2012-09-22 15:55:27 +00:00
punkeduard@gmail.com
901abd688a Fixed Yeva, Nature's Herald and Yeva's forcemage 2012-09-03 00:24:13 +00:00
omegablast2002@yahoo.com
ad055ad0b7 missed this file 2012-08-26 08:10:15 +00:00
omegablast2002@yahoo.com
3b447135fb fixed soulbond and testsuite issue, fixed crash from combohint not being int'ed to some AIStats(which are considered "human" 2012-08-26 08:08:36 +00:00
wagic.the.homebrew@gmail.com
7583e61510 remove non ascii characters from ZipFS 2012-08-26 06:07:48 +00:00
wagic.the.homebrew@gmail.com
8035d0f3fc Remove non ascii characters from WFont 2012-08-26 06:06:32 +00:00
omegablast2002@yahoo.com
38cdec5126 corrected a issue with "eachother" tag in adyanmic class...the damager should be the target to take into account triggers and deathtouch...thanks dopple. 2012-08-25 00:38:59 +00:00
omegablast2002@yahoo.com
78f5b11919 removed ABasilik class, this ability is completely soft codable now. 2012-08-25 00:27:22 +00:00
omegablast2002@yahoo.com
f5403b0e03 softcoded the final basilisk.... 2012-08-25 00:25:29 +00:00
omegablast2002@yahoo.com
a42c6b00a8 changed farmstead to softcode. 2012-08-25 00:07:47 +00:00
omegablast2002@yahoo.com
68f76fbaff removed farmstead hardcode, this card can now be soft coded 2012-08-25 00:07:10 +00:00
omegablast2002@yahoo.com
14695e7e5b removed kudzu hardcode, that card can be done with soft code...corrected frostbeast, it was incorrectly ignoring walls...it should destroy all even walls. 2012-08-24 23:59:35 +00:00
omegablast2002@yahoo.com
63ea7f88e2 soft coded kudzu. 2012-08-24 23:52:17 +00:00
omegablast2002@yahoo.com
0b89f0571e corrected elder cather code. 2012-08-24 23:43:15 +00:00
omegablast2002@yahoo.com
0f5754c75a many reported issue tracker bugs fixed. 2012-08-24 01:32:06 +00:00
omegablast2002@yahoo.com
101582e37e increased life delta bonus to 10k, it seems the general consensus is people think it is bugged becuase they dont gain over 500 points from it. after seeing multiple people reporting it I think it would be best to increase the bonus just to avoid confusion. 2012-08-24 00:24:26 +00:00
omegablast2002@yahoo.com
fffe739ec1 setting Tc->targetter to Null on countByCanTarget() the functions that call this don't care about protection, it is used to find a number of objects which are considered valid even with protections to the source. thanks Dopple for finding this bug. 2012-08-23 23:24:55 +00:00
omegablast2002@yahoo.com
d078872dfc this is the first draft of a simple ai combo system,
format is as follows

HINT#combo hold(blah|myhand)^until(blah|mygraveyard)^until(blah|opponentshand)^restriction{type(creature|mybattlefield)~morethan~2}^cast(blah) targeting(blah|mygraveyard)^totalmananneeded({g}{g}{r}{u}{2})

the ai can be told to hold more then one card, until as many condiations as you want are met, until( is a TC and can basically be used in a fasion of saying "hold arbor elf until you have a lord of atlantas in play and a gaint growth in you hand" 

once the condiations are met you can later tell it to cast(gaint growth) targeting(arbor elf[fresh]|mybattlefield)...

I also included the whole of the games restrictions system...
so you can get really really creative with this so far.

the next thing I will do is ability targeting and card favoring.
2012-08-19 21:53:57 +00:00
rolzad73@gmail.com
6d4e677711 * Stopped Android version from completely destroying/recreating SDLActivity when the device is locked.
Fixes multiple identical issue entries in tracker:
issue 696 (was marked fixed then restarted)
issue 876, issue 886, issue 894
2012-08-19 16:19:56 +00:00
punkeduard@gmail.com
4c74ae06fd Fixes on AVR, M13, mtg, bug reports on the forums, another try on the rings 2012-08-11 04:00:22 +00:00
punkeduard@gmail.com
db2d3b895e Bug fixes for m13 reported in the forums
mark of the vampire, dragon hatchling, Ranger's Path
2012-08-05 22:05:00 +00:00
punkeduard@gmail.com
51a6ac54f4 Several bug fixes, this cards are not working 100% correcly: will be removed if not fixed soon Ulvenwald Tracker,Wild Defiance, Thatcher Revolt, Spectral Prison, Druids' Repository, Abundant Growth 2012-08-05 20:26:40 +00:00
punkeduard@gmail.com
1454550a7b Thraben Heretic, Fyndhorn Pollen, knight of glory card code fixes 2012-07-26 02:30:59 +00:00
omegablast2002@yahoo.com
c85d07f890 tweaks to ai use of cast order, we had instance where "land" would get an over-ride and not cast. 2012-07-25 12:10:25 +00:00
punkeduard@gmail.com
23e4002a9a reverted the rings 2012-07-25 03:11:07 +00:00
punkeduard@gmail.com
e38582a89a Fixes to the five rings, mana cost knight of glory 2012-07-25 02:29:38 +00:00
omegablast2002@yahoo.com
cf5a6f9059 fix to my fix, commited the wrong version of it :) 2012-07-24 11:02:29 +00:00
omegablast2002@yahoo.com
bbf1de5134 fix for may menus not stacking if multi cards with may effects come into play at the same time.
although I tested this fix, it will require extremely indepth testing which I can not do alone to ensure that doing this does not screw up something else.
I think however that we are safe, becuase we test the same condition under test destroy and gameobserver update without any negitive recourse.
2012-07-23 22:44:02 +00:00
omegablast2002@yahoo.com
ecdc1481b0 added grade crappy to M13, pc2, avr, to exclude them from 99% support, until they are corrected, verified, and completely working, then combined with MTG.txt where they belong. already started receiving bug reports for cards in these. 2012-07-21 19:49:09 +00:00
punkeduard@gmail.com
b3d28744c4 Bug fixes in cards from avr and m13
hellion crubicle, Archwing Dragon, Defy Death, Otherworld Atlas
2012-07-21 18:14:31 +00:00
omegablast2002@yahoo.com
6172a0ade6 the rules txt change for soulbond. 2012-07-16 15:00:32 +00:00
omegablast2002@yahoo.com
0dbcd86b89 this commit adds AVRs new ability soulbond.
it requires an update to your mtg rules txt...
the coding is as follows

[card]
name=Arbor Elf
mana={g}
auto=soulbond 1/3
auto=soulbond {t}:add{g}
abilities=soulbond
type=Creature
subtype=Elf Druid
power=1
toughness=1
[/card]

auto=soulbond *any ability supported by wagic*
abilities=soulbond

the above arbor elf gives itself and its soulbond creature a 1/3 bonus and the ability to tap for green mana.
2012-07-16 14:59:46 +00:00
omegablast2002@yahoo.com
7024d195fa never got around to commiting this deck, have a couple others also. this deck show cases ai's ability to counterspell. 2012-07-15 23:12:01 +00:00
punkeduard@gmail.com
591b1535a6 Fixed Agility, Chlorophant. Fixed typos in Auriok Windwalker, Akki Underminer, Brass Squire, Cabal Slaver, Kor Outfitter,Pillar Tombs of Aku in 'battefield', added burning vengeance. 2012-07-14 16:44:19 +00:00
punkeduard@gmail.com
e29f95cb6c Added Avacyn Restored, Wagic 13 and Plancechase 2 primitives, each in separate text files, TODO merge into mtg, test more extensive and fix bugs. 2012-07-14 16:24:36 +00:00
punkeduard@gmail.com
973a835181 Adding Wagic 13 and Planechase 2 Folders and _cards.dat to the sets 2012-07-14 16:06:02 +00:00
Xawotihs@gmail.com
a8492b7c5a Fixed compilation with mingwin 2012-06-01 23:36:18 +00:00
Xawotihs@gmail.com
6dafc098cb and again 2012-05-20 14:18:24 +00:00
Xawotihs@gmail.com
f87a81f7ea Fixed meego changelog 2012-05-20 14:08:57 +00:00
Xawotihs@gmail.com
e14ec67a84 Updated meego changelog 2012-05-19 20:52:00 +00:00
Xawotihs@gmail.com
4540499b38 and again 2012-05-19 19:40:32 +00:00
Xawotihs@gmail.com
c10b5ce220 and again 2012-05-19 19:35:23 +00:00
Xawotihs@gmail.com
298231add1 and again 2012-05-19 19:30:20 +00:00
Xawotihs@gmail.com
113e5ba2b4 Fixed format of the maemo changelog 2012-05-19 19:25:35 +00:00
Xawotihs@gmail.com
f9795661b8 Updated maemo changelog 2012-05-19 19:20:02 +00:00
Xawotihs@gmail.com
a5195409c4 Added automatic generation of maemo and meego debian changelog based on the new version tools 2012-05-14 21:41:21 +00:00
Xawotihs@gmail.com
d37f44724b Revert previous commit, it does not do what I want. 2012-05-13 20:34:56 +00:00
Xawotihs@gmail.com
0d5e8e39c5 Activated revision property 2012-05-13 19:53:37 +00:00
643 changed files with 89366 additions and 44276 deletions

243
.gitignore vendored Normal file
View File

@@ -0,0 +1,243 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlog
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
#for XCode and MacOS
## Mac OS X
*.DS_Store
# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/
# Generated files
*.o
*.pyc
#Python modules
MANIFEST
dist/
build/
# Backup files
*~.nib

60
.travis.yml Normal file
View File

@@ -0,0 +1,60 @@
language: cpp
branches:
except:
- latest-master
before_install:
- export BUILD_PSP=YES
- export BUILD_ANDROID=YES
- export BUILD_Qt=YES
- export BUILD_MAC=YES
- sudo apt-get update -qq
# Building for PSP here
- if [ "$BUILD_PSP" == "YES" ]; then
export PSPDEV="$TRAVIS_BUILD_DIR/opt/pspsdk" &&
export PSPSDK="$PSPDEV/psp/sdk" &&
export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin" &&
wget -O sdk.lzma http://sourceforge.net/projects/minpspw/files/SDK%20%2B%20devpak/pspsdk%200.11.2/minpspw_0.11.2-amd64.tar.lzma/download;
fi
# Building for Android here
- if [ "$BUILD_ANDROID" == "YES" ]; then
export ANDROID="android-sdk-linux/tools/android" &&
if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch jq; fi &&
wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv &&
wget http://dl.google.com/android/android-sdk_r24.3.3-linux.tgz -nv;
fi
# Building for Qt here
- if [ "$BUILD_Qt" == "YES" ]; then
sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa &&
sudo apt-get update -qq &&
sudo apt-get install -qq qt5-qmake qtbase5-dev qtdeclarative5-dev qttools5-dev qtmultimedia5-dev pulseaudio libpulse-dev &&
export QMAKE="qmake -qt=qt5";
fi
install:
- if [ "$BUILD_PSP" == "YES" ]; then
tar -x --xz -f sdk.lzma;
fi
- if [ "$BUILD_ANDROID" == "YES" ]; then
tar --absolute-names -jxf android-ndk-r9-linux-x86_64.tar.bz2 &&
tar -zxf android-sdk_r24.3.3-linux.tgz &&
$ANDROID list sdk --extended -a &&
echo yes | $ANDROID update sdk -a -t tools,platform-tools,build-tools-22.0.1,android-10 --no-ui --force --no-https;
fi
- sudo pip install pyjavaproperties
- sudo pip install github3.py
- sudo pip install cpp-coveralls
env:
global:
- secure: "EBzr1+qjQsOhn0s+tcFmXR1jP9B0xiOSXuXbRXWZ1OEHNvp8+A5/pS84LYVFlaZqmxr5dApxvPtwhgLIUbQ3EPXm8LpC3KgSD4dS+9/QMbxhe5TK4oczgFRGcDTMJQZsCzhOh7hp3tbcbJg5Gp+VT7aFjFQSHDGwhzSJXsXwh/8="
- secure: "X5dTQfofqAutnXxmu11Ep2MQ5QYnMN8m0AITRtwymhEF2UclcOudI1+skPtuhAGbWQnSO+lhunV3cvMfw2/Ml3k/VDz6VdFSKFrzAu7ja1VLJfcxr7chi0s8q30pVBb66tGydjIBac3B+RQyqgmZQW1frbRrhC/kPFQ6wPWOJdQ="
- secure: "T97NUPnxCpVZ/c5HH0zfo0FO3DPSRMSmze58ubW5EUTZOjAMtEt+OFdsrNZvUTCugUj2M1agtonZbAbczpaAL+lgZcHDgXgWMkfO0pMnsWX1yyCNqMuE/iTMpJr/xsLQeyWlftWjJLsseQU45abZsd1XVmda/G+ZhrDLF1y55SA="
script: "tools/travis-script.sh"
after_success:
- coveralls -b . -e JGE/src -e JGE/include -i projects/mtg/include -i projects/mtg/src --gcov-options '\-lp'
- python tools/upload-binaries.py -t $GH_TOKEN -s $TRAVIS_COMMIT -l core.zip -r Wagic-core.zip -b $TRAVIS_BRANCH
- python tools/upload-binaries.py -t $GH_TOKEN -s $TRAVIS_COMMIT -l projects/mtg/Android/bin/Wagic-debug.apk -r Wagic-android.apk -b $TRAVIS_BRANCH
- python tools/upload-binaries.py -t $GH_TOKEN -s $TRAVIS_COMMIT -l projects/mtg/psprelease.zip -r Wagic-psp.zip -b $TRAVIS_BRANCH

View File

@@ -71,7 +71,7 @@ namespace boost {
};
template<typename InputT, typename FindResultT>
bool check_find_result(InputT& Input, FindResultT& FindResult)
bool check_find_result(InputT&, FindResultT& FindResult)
{
typedef BOOST_STRING_TYPENAME
range_const_iterator<InputT>::type input_iterator_type;

84
Boost/boost/random.hpp Normal file
View File

@@ -0,0 +1,84 @@
/* boost random.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/random for documentation.
*
* $Id: random.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2000-02-18 portability fixes (thanks to Beman Dawes)
* 2000-02-21 shuffle_output, inversive_congruential_schrage,
* generator_iterator, uniform_smallint
* 2000-02-23 generic modulus arithmetic helper, removed *_schrage classes,
* implemented Streamable and EqualityComparable concepts for
* generators, added Bernoulli distribution and Box-Muller
* transform
* 2000-03-01 cauchy, lognormal, triangle distributions; fixed
* uniform_smallint; renamed gaussian to normal distribution
* 2000-03-05 implemented iterator syntax for distribution functions
* 2000-04-21 removed some optimizations for better BCC/MSVC compatibility
* 2000-05-10 adapted to BCC and MSVC
* 2000-06-13 incorporated review results
* 2000-07-06 moved basic templates from namespace detail to random
* 2000-09-23 warning removals and int64 fixes (Ed Brey)
* 2000-09-24 added lagged_fibonacci generator (Matthias Troyer)
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_HPP
#define BOOST_RANDOM_HPP
// generators
#include <boost/random/linear_congruential.hpp>
#include <boost/random/additive_combine.hpp>
#include <boost/random/inversive_congruential.hpp>
#include <boost/random/shuffle_output.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/lagged_fibonacci.hpp>
#include <boost/random/ranlux.hpp>
#include <boost/random/linear_feedback_shift.hpp>
#include <boost/random/xor_combine.hpp>
#include <boost/random/discard_block.hpp>
#include <boost/random/subtract_with_carry.hpp>
#include <boost/random/variate_generator.hpp>
namespace boost {
/**
* The specialization taus88 was suggested in
*
* @blockquote
* "Maximally Equidistributed Combined Tausworthe Generators",
* Pierre L'Ecuyer, Mathematics of Computation, Volume 65,
* Number 213, January 1996, Pages 203-213
* @endblockquote
*/
typedef random::xor_combine<random::xor_combine<random::linear_feedback_shift<uint32_t, 32, 31, 13, 12, 0>, 0,
random::linear_feedback_shift<uint32_t, 32, 29, 2, 4, 0>, 0, 0>, 0,
random::linear_feedback_shift<uint32_t, 32, 28, 3, 17, 0>, 0, 0> taus88;
} // namespace boost
// misc
#include <boost/random/random_number_generator.hpp>
// distributions
#include <boost/random/uniform_smallint.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/uniform_real.hpp>
#include <boost/random/triangle_distribution.hpp>
#include <boost/random/bernoulli_distribution.hpp>
#include <boost/random/cauchy_distribution.hpp>
#include <boost/random/exponential_distribution.hpp>
#include <boost/random/geometric_distribution.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/lognormal_distribution.hpp>
#include <boost/random/poisson_distribution.hpp>
#include <boost/random/gamma_distribution.hpp>
#include <boost/random/binomial_distribution.hpp>
#include <boost/random/uniform_on_sphere.hpp>
#endif // BOOST_RANDOM_HPP

View File

@@ -0,0 +1,234 @@
/* boost random/additive_combine.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: additive_combine.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_ADDITIVE_COMBINE_HPP
#define BOOST_RANDOM_ADDITIVE_COMBINE_HPP
#include <iostream>
#include <algorithm> // for std::min and std::max
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/linear_congruential.hpp>
namespace boost {
namespace random {
/**
* An instantiation of class template \additive_combine model a
* \pseudo_random_number_generator. It combines two multiplicative
* \linear_congruential number generators, i.e. those with @c c = 0.
* It is described in
*
* @blockquote
* "Efficient and Portable Combined Random Number Generators", Pierre L'Ecuyer,
* Communications of the ACM, Vol. 31, No. 6, June 1988, pp. 742-749, 774
* @endblockquote
*
* The template parameters MLCG1 and MLCG2 shall denote two different
* \linear_congruential number generators, each with c = 0. Each invocation
* returns a random number X(n) := (MLCG1(n) - MLCG2(n)) mod (m1 - 1), where
* m1 denotes the modulus of MLCG1.
*
* The template parameter @c val is the validation value checked by validation.
*/
template<class MLCG1, class MLCG2,
#ifndef BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
typename MLCG1::result_type
#else
int32_t
#endif
val>
class additive_combine
{
public:
typedef MLCG1 first_base;
typedef MLCG2 second_base;
typedef typename MLCG1::result_type result_type;
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
static const bool has_fixed_range = true;
static const result_type min_value = 1;
static const result_type max_value = MLCG1::max_value-1;
#else
enum { has_fixed_range = false };
#endif
/**
* Returns: The smallest value that the generator can produce
*/
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 1; }
/**
* Returns: The largest value that the generator can produce
*/
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (_mlcg1.max)()-1; }
/**
* Constructs an \additive_combine generator using the
* default constructors of the two base generators.
*/
additive_combine() : _mlcg1(), _mlcg2() { }
/**
* Constructs an \additive_combine generator, using aseed as
* the constructor argument for both base generators.
*/
explicit additive_combine(result_type aseed)
: _mlcg1(aseed), _mlcg2(aseed) { }
/**
* Constructs an \additive_combine generator, using
* @c seed1 and @c seed2 as the constructor argument to
* the first and second base generators, respectively.
*/
additive_combine(typename MLCG1::result_type seed1,
typename MLCG2::result_type seed2)
: _mlcg1(seed1), _mlcg2(seed2) { }
/**
* Contructs an \additive_combine generator with
* values from the range defined by the input iterators first
* and last. first will be modified to point to the element
* after the last one used.
*
* Throws: @c std::invalid_argument if the input range is too small.
*
* Exception Safety: Basic
*/
template<class It> additive_combine(It& first, It last)
: _mlcg1(first, last), _mlcg2(first, last) { }
/**
* Seeds an \additive_combine generator using the default
* seeds of the two base generators.
*/
void seed()
{
_mlcg1.seed();
_mlcg2.seed();
}
/**
* Seeds an \additive_combine generator, using @c aseed as the
* seed for both base generators.
*/
void seed(result_type aseed)
{
_mlcg1.seed(aseed);
_mlcg2.seed(aseed);
}
/**
* Seeds an \additive_combine generator, using @c seed1 and @c seed2 as
* the seeds to the first and second base generators, respectively.
*/
void seed(typename MLCG1::result_type seed1,
typename MLCG2::result_type seed2)
{
_mlcg1.seed(seed1);
_mlcg2.seed(seed2);
}
/**
* Seeds an \additive_combine generator with
* values from the range defined by the input iterators first
* and last. first will be modified to point to the element
* after the last one used.
*
* Throws: @c std::invalid_argument if the input range is too small.
*
* Exception Safety: Basic
*/
template<class It> void seed(It& first, It last)
{
_mlcg1.seed(first, last);
_mlcg2.seed(first, last);
}
/**
* Returns: the next value of the generator
*/
result_type operator()() {
result_type z = _mlcg1() - _mlcg2();
if(z < 1)
z += MLCG1::modulus-1;
return z;
}
static bool validation(result_type x) { return val == x; }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/**
* Writes the state of an \additive_combine generator to a @c
* std::ostream. The textual representation of an \additive_combine
* generator is the textual representation of the first base
* generator followed by the textual representation of the
* second base generator.
*/
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const additive_combine& r)
{ os << r._mlcg1 << " " << r._mlcg2; return os; }
/**
* Reads the state of an \additive_combine generator from a
* @c std::istream.
*/
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, additive_combine& r)
{ is >> r._mlcg1 >> std::ws >> r._mlcg2; return is; }
#endif
/**
* Returns: true iff the two \additive_combine generators will
* produce the same sequence of values.
*/
friend bool operator==(const additive_combine& x, const additive_combine& y)
{ return x._mlcg1 == y._mlcg1 && x._mlcg2 == y._mlcg2; }
/**
* Returns: true iff the two \additive_combine generators will
* produce different sequences of values.
*/
friend bool operator!=(const additive_combine& x, const additive_combine& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const additive_combine& rhs) const
{ return _mlcg1 == rhs._mlcg1 && _mlcg2 == rhs._mlcg2; }
bool operator!=(const additive_combine& rhs) const
{ return !(*this == rhs); }
#endif
private:
MLCG1 _mlcg1;
MLCG2 _mlcg2;
};
} // namespace random
/**
* The specialization \ecuyer1988 was suggested in
*
* @blockquote
* "Efficient and Portable Combined Random Number Generators", Pierre L'Ecuyer,
* Communications of the ACM, Vol. 31, No. 6, June 1988, pp. 742-749, 774
* @endblockquote
*/
typedef random::additive_combine<
random::linear_congruential<int32_t, 40014, 0, 2147483563, 0>,
random::linear_congruential<int32_t, 40692, 0, 2147483399, 0>,
2060321752> ecuyer1988;
} // namespace boost
#endif // BOOST_RANDOM_ADDITIVE_COMBINE_HPP

View File

@@ -0,0 +1,109 @@
/* boost random/bernoulli_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: bernoulli_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_BERNOULLI_DISTRIBUTION_HPP
#define BOOST_RANDOM_BERNOULLI_DISTRIBUTION_HPP
#include <cassert>
#include <iostream>
#include <boost/random/detail/config.hpp>
namespace boost {
/**
* Instantiations of class template \bernoulli_distribution model a
* \random_distribution. Such a random distribution produces bool values
* distributed with probabilities P(true) = p and P(false) = 1-p. p is
* the parameter of the distribution.
*/
template<class RealType = double>
class bernoulli_distribution
{
public:
// In principle, this could work with both integer and floating-point
// types. Generating floating-point random numbers in the first
// place is probably more expensive, so use integer as input.
typedef int input_type;
typedef bool result_type;
/**
* Constructs a \bernoulli_distribution object.
* p is the parameter of the distribution.
*
* Requires: 0 <= p <= 1
*/
explicit bernoulli_distribution(const RealType& p_arg = RealType(0.5))
: _p(p_arg)
{
assert(_p >= 0);
assert(_p <= 1);
}
// compiler-generated copy ctor and assignment operator are fine
/**
* Returns: The "p" parameter of the distribution.
*/
RealType p() const { return _p; }
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
*/
void reset() { }
/**
* Returns: a random variate distributed according to the
* \bernoulli_distribution.
*/
template<class Engine>
result_type operator()(Engine& eng)
{
if(_p == RealType(0))
return false;
else
return RealType(eng() - (eng.min)()) <= _p * RealType((eng.max)()-(eng.min)());
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/**
* Writes the parameters of the distribution to a @c std::ostream.
*/
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const bernoulli_distribution& bd)
{
os << bd._p;
return os;
}
/**
* Reads the parameters of the distribution from a @c std::istream.
*/
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, bernoulli_distribution& bd)
{
is >> std::ws >> bd._p;
return is;
}
#endif
private:
RealType _p;
};
} // namespace boost
#endif // BOOST_RANDOM_BERNOULLI_DISTRIBUTION_HPP

View File

@@ -0,0 +1,111 @@
/* boost random/binomial_distribution.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: binomial_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
*/
#ifndef BOOST_RANDOM_BINOMIAL_DISTRIBUTION_HPP
#define BOOST_RANDOM_BINOMIAL_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <cassert>
#include <boost/random/detail/config.hpp>
#include <boost/random/bernoulli_distribution.hpp>
namespace boost {
/**
* The binomial distribution is an integer valued distribution with
* two parameters, @c t and @c p. The values of the distribution
* are within the range [0,t].
*
* The probability that the distribution produces a value k is
* \f${t \choose k}p^k(1-p)^{t-k}\f$.
*/
template<class IntType = int, class RealType = double>
class binomial_distribution
{
public:
typedef typename bernoulli_distribution<RealType>::input_type input_type;
typedef IntType result_type;
/**
* Construct an @c binomial_distribution object. @c t and @c p
* are the parameters of the distribution.
*
* Requires: t >=0 && 0 <= p <= 1
*/
explicit binomial_distribution(IntType t = 1,
const RealType& p = RealType(0.5))
: _bernoulli(p), _t(t)
{
assert(_t >= 0);
assert(RealType(0) <= p && p <= RealType(1));
}
// compiler-generated copy ctor and assignment operator are fine
/** Returns: the @c t parameter of the distribution */
IntType t() const { return _t; }
/** Returns: the @c p parameter of the distribution */
RealType p() const { return _bernoulli.p(); }
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
*/
void reset() { }
/**
* Returns: a random variate distributed according to the
* binomial distribution.
*/
template<class Engine>
result_type operator()(Engine& eng)
{
// TODO: This is O(_t), but it should be O(log(_t)) for large _t
result_type n = 0;
for(IntType i = 0; i < _t; ++i)
if(_bernoulli(eng))
++n;
return n;
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/**
* Writes the parameters of the distribution to a @c std::ostream.
*/
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const binomial_distribution& bd)
{
os << bd._bernoulli << " " << bd._t;
return os;
}
/**
* Reads the parameters of the distribution from a @c std::istream.
*/
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, binomial_distribution& bd)
{
is >> std::ws >> bd._bernoulli >> std::ws >> bd._t;
return is;
}
#endif
private:
bernoulli_distribution<RealType> _bernoulli;
IntType _t;
};
} // namespace boost
#endif // BOOST_RANDOM_BINOMIAL_DISTRIBUTION_HPP

View File

@@ -0,0 +1,121 @@
/* boost random/cauchy_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: cauchy_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_CAUCHY_DISTRIBUTION_HPP
#define BOOST_RANDOM_CAUCHY_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <iostream>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
namespace boost {
#if defined(__GNUC__) && (__GNUC__ < 3)
// Special gcc workaround: gcc 2.95.x ignores using-declarations
// in template classes (confirmed by gcc author Martin v. Loewis)
using std::tan;
#endif
// Cauchy distribution:
/**
* The cauchy distribution is a continuous distribution with two
* parameters, sigma and median.
*
* It has \f$p(x) = \frac{\sigma}{\pi(\sigma^2 + (x-m)^2)}\f$
*/
template<class RealType = double>
class cauchy_distribution
{
public:
typedef RealType input_type;
typedef RealType result_type;
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
#endif
/**
* Constructs a \cauchy_distribution with the paramters @c median
* and @c sigma.
*/
explicit cauchy_distribution(result_type median_arg = result_type(0),
result_type sigma_arg = result_type(1))
: _median(median_arg), _sigma(sigma_arg) { }
// compiler-generated copy ctor and assignment operator are fine
/**
* Returns: the "median" parameter of the distribution
*/
result_type median() const { return _median; }
/**
* Returns: the "sigma" parameter of the distribution
*/
result_type sigma() const { return _sigma; }
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
*/
void reset() { }
/**
* Returns: A random variate distributed according to the
* cauchy distribution.
*/
template<class Engine>
result_type operator()(Engine& eng)
{
// Can we have a boost::mathconst please?
const result_type pi = result_type(3.14159265358979323846);
#ifndef BOOST_NO_STDC_NAMESPACE
using std::tan;
#endif
return _median + _sigma * tan(pi*(eng()-result_type(0.5)));
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/**
* Writes the parameters of the distribution to a @c std::ostream.
*/
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const cauchy_distribution& cd)
{
os << cd._median << " " << cd._sigma;
return os;
}
/**
* Reads the parameters of the distribution from a @c std::istream.
*/
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, cauchy_distribution& cd)
{
is >> std::ws >> cd._median >> std::ws >> cd._sigma;
return is;
}
#endif
private:
result_type _median, _sigma;
};
} // namespace boost
#endif // BOOST_RANDOM_CAUCHY_DISTRIBUTION_HPP

View File

@@ -0,0 +1,42 @@
/* boost random auto_link.hpp header file
*
* Copyright Steven Watanabe 2010
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* $Id: auto_link.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*/
#ifndef BOOST_RANDOM_DETAIL_AUTO_LINK_HPP
#define BOOST_RANDOM_DETAIL_AUTO_LINK_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_DECLSPEC
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_RANDOM_DYN_LINK)
#if defined(BOOST_RANDOM_SOURCE)
#define BOOST_RANDOM_DECL __declspec(dllexport)
#else
#define BOOST_RANDOM_DECL __declspec(dllimport)
#endif
#endif
#endif
#ifndef BOOST_RANDOM_DECL
#define BOOST_RANDOM_DECL
#endif
#if !defined(BOOST_RANDOM_NO_LIB) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_RANDOM_SOURCE)
#define BOOST_LIB_NAME boost_random
#if defined(BOOST_RANDOM_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
#define BOOST_DYN_LINK
#endif
#include <boost/config/auto_link.hpp>
#endif
#endif

View File

@@ -0,0 +1,18 @@
/* boost random/detail/config.hpp header file
*
* Copyright Steven Watanabe 2009
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: config.hpp 52492 2009-04-19 14:55:57Z steven_watanabe $
*/
#include <boost/config.hpp>
#if (defined(BOOST_NO_OPERATORS_IN_NAMESPACE) || defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)) \
&& !defined(BOOST_MSVC)
#define BOOST_RANDOM_NO_STREAM_OPERATORS
#endif

View File

@@ -0,0 +1,363 @@
/* boost random/detail/const_mod.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: const_mod.hpp 58649 2010-01-02 21:23:17Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_CONST_MOD_HPP
#define BOOST_RANDOM_CONST_MOD_HPP
#include <cassert>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/integer_traits.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
namespace random {
/*
* Some random number generators require modular arithmetic. Put
* everything we need here.
* IntType must be an integral type.
*/
namespace detail {
template<bool is_signed>
struct do_add
{ };
template<>
struct do_add<true>
{
template<class IntType>
static IntType add(IntType m, IntType x, IntType c)
{
if (x < m - c)
return x + c;
else
return x - (m-c);
}
};
template<>
struct do_add<false>
{
template<class IntType>
static IntType add(IntType, IntType, IntType)
{
// difficult
assert(!"const_mod::add with c too large");
return 0;
}
};
} // namespace detail
#if !(defined(__BORLANDC__) && (__BORLANDC__ == 0x560))
template<class IntType, IntType m>
class const_mod
{
public:
static IntType add(IntType x, IntType c)
{
if(c == 0)
return x;
else if(c <= traits::const_max - m) // i.e. m+c < max
return add_small(x, c);
else
return detail::do_add<traits::is_signed>::add(m, x, c);
}
static IntType mult(IntType a, IntType x)
{
if(a == 1)
return x;
else if(m <= traits::const_max/a) // i.e. a*m <= max
return mult_small(a, x);
else if(traits::is_signed && (m%a < m/a))
return mult_schrage(a, x);
else {
// difficult
assert(!"const_mod::mult with a too large");
return 0;
}
}
static IntType mult_add(IntType a, IntType x, IntType c)
{
if(m <= (traits::const_max-c)/a) // i.e. a*m+c <= max
return (a*x+c) % m;
else
return add(mult(a, x), c);
}
static IntType invert(IntType x)
{ return x == 0 ? 0 : invert_euclidian(x); }
private:
typedef integer_traits<IntType> traits;
const_mod(); // don't instantiate
static IntType add_small(IntType x, IntType c)
{
x += c;
if(x >= m)
x -= m;
return x;
}
static IntType mult_small(IntType a, IntType x)
{
return a*x % m;
}
static IntType mult_schrage(IntType a, IntType value)
{
const IntType q = m / a;
const IntType r = m % a;
assert(r < q); // check that overflow cannot happen
value = a*(value%q) - r*(value/q);
// An optimizer bug in the SGI MIPSpro 7.3.1.x compiler requires this
// convoluted formulation of the loop (Synge Todo)
for(;;) {
if (value > 0)
break;
value += m;
}
return value;
}
// invert c in the finite field (mod m) (m must be prime)
static IntType invert_euclidian(IntType c)
{
// we are interested in the gcd factor for c, because this is our inverse
BOOST_STATIC_ASSERT(m > 0);
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
assert(boost::integer_traits<IntType>::is_signed);
#elif !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS)
BOOST_STATIC_ASSERT(boost::integer_traits<IntType>::is_signed);
#endif
assert(c > 0);
IntType l1 = 0;
IntType l2 = 1;
IntType n = c;
IntType p = m;
for(;;) {
IntType q = p / n;
l1 -= q * l2; // this requires a signed IntType!
p -= q * n;
if(p == 0)
return (l2 < 1 ? l2 + m : l2);
IntType q2 = n / p;
l2 -= q2 * l1;
n -= q2 * p;
if(n == 0)
return (l1 < 1 ? l1 + m : l1);
}
}
};
// The modulus is exactly the word size: rely on machine overflow handling.
// Due to a GCC bug, we cannot partially specialize in the presence of
// template value parameters.
template<>
class const_mod<unsigned int, 0>
{
typedef unsigned int IntType;
public:
static IntType add(IntType x, IntType c) { return x+c; }
static IntType mult(IntType a, IntType x) { return a*x; }
static IntType mult_add(IntType a, IntType x, IntType c) { return a*x+c; }
// m is not prime, thus invert is not useful
private: // don't instantiate
const_mod();
};
template<>
class const_mod<unsigned long, 0>
{
typedef unsigned long IntType;
public:
static IntType add(IntType x, IntType c) { return x+c; }
static IntType mult(IntType a, IntType x) { return a*x; }
static IntType mult_add(IntType a, IntType x, IntType c) { return a*x+c; }
// m is not prime, thus invert is not useful
private: // don't instantiate
const_mod();
};
// the modulus is some power of 2: rely partly on machine overflow handling
// we only specialize for rand48 at the moment
#ifndef BOOST_NO_INT64_T
template<>
class const_mod<uint64_t, uint64_t(1) << 48>
{
typedef uint64_t IntType;
public:
static IntType add(IntType x, IntType c) { return c == 0 ? x : mod(x+c); }
static IntType mult(IntType a, IntType x) { return mod(a*x); }
static IntType mult_add(IntType a, IntType x, IntType c)
{ return mod(a*x+c); }
static IntType mod(IntType x) { return x &= ((uint64_t(1) << 48)-1); }
// m is not prime, thus invert is not useful
private: // don't instantiate
const_mod();
};
#endif /* !BOOST_NO_INT64_T */
#else
//
// for some reason Borland C++ Builder 6 has problems with
// the full specialisations of const_mod, define a generic version
// instead, the compiler will optimise away the const-if statements:
//
template<class IntType, IntType m>
class const_mod
{
public:
static IntType add(IntType x, IntType c)
{
if(0 == m)
{
return x+c;
}
else
{
if(c == 0)
return x;
else if(c <= traits::const_max - m) // i.e. m+c < max
return add_small(x, c);
else
return detail::do_add<traits::is_signed>::add(m, x, c);
}
}
static IntType mult(IntType a, IntType x)
{
if(x == 0)
{
return a*x;
}
else
{
if(a == 1)
return x;
else if(m <= traits::const_max/a) // i.e. a*m <= max
return mult_small(a, x);
else if(traits::is_signed && (m%a < m/a))
return mult_schrage(a, x);
else {
// difficult
assert(!"const_mod::mult with a too large");
return 0;
}
}
}
static IntType mult_add(IntType a, IntType x, IntType c)
{
if(m == 0)
{
return a*x+c;
}
else
{
if(m <= (traits::const_max-c)/a) // i.e. a*m+c <= max
return (a*x+c) % m;
else
return add(mult(a, x), c);
}
}
static IntType invert(IntType x)
{ return x == 0 ? 0 : invert_euclidian(x); }
private:
typedef integer_traits<IntType> traits;
const_mod(); // don't instantiate
static IntType add_small(IntType x, IntType c)
{
x += c;
if(x >= m)
x -= m;
return x;
}
static IntType mult_small(IntType a, IntType x)
{
return a*x % m;
}
static IntType mult_schrage(IntType a, IntType value)
{
const IntType q = m / a;
const IntType r = m % a;
assert(r < q); // check that overflow cannot happen
value = a*(value%q) - r*(value/q);
while(value <= 0)
value += m;
return value;
}
// invert c in the finite field (mod m) (m must be prime)
static IntType invert_euclidian(IntType c)
{
// we are interested in the gcd factor for c, because this is our inverse
BOOST_STATIC_ASSERT(m > 0);
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(boost::integer_traits<IntType>::is_signed);
#endif
assert(c > 0);
IntType l1 = 0;
IntType l2 = 1;
IntType n = c;
IntType p = m;
for(;;) {
IntType q = p / n;
l1 -= q * l2; // this requires a signed IntType!
p -= q * n;
if(p == 0)
return (l2 < 1 ? l2 + m : l2);
IntType q2 = n / p;
l2 -= q2 * l1;
n -= q2 * p;
if(n == 0)
return (l1 < 1 ? l1 + m : l1);
}
}
};
#endif
} // namespace random
} // namespace boost
#include <boost/random/detail/enable_warnings.hpp>
#endif // BOOST_RANDOM_CONST_MOD_HPP

View File

@@ -0,0 +1,23 @@
/* boost random/detail/disable_warnings.hpp header file
*
* Copyright Steven Watanabe 2009
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: disable_warnings.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
*/
// No #include guard. This header is intended to be included multiple times.
#include <boost/config.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4512)
#pragma warning(disable:4127)
#pragma warning(disable:4724)
#endif

View File

@@ -0,0 +1,18 @@
/* boost random/detail/enable_warnings.hpp header file
*
* Copyright Steven Watanabe 2009
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: enable_warnings.hpp 58649 2010-01-02 21:23:17Z steven_watanabe $
*
*/
// No #include guard. This header is intended to be included multiple times.
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif

View File

@@ -0,0 +1,45 @@
/* boost random/detail/iterator_mixin.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* Revision history
*/
#ifndef BOOST_ITERATOR_MIXIN_HPP
#define BOOST_ITERATOR_MIXIN_HPP
#include <boost/operators.hpp>
namespace boost {
// must be in boost namespace, otherwise the inline friend trick fails
template<class Generator, class ResultType>
class generator_iterator_mixin_adapter
: incrementable<Generator>, equality_comparable<Generator>
{
public:
typedef std::input_iterator_tag iterator_category;
typedef ResultType value_type;
typedef std::ptrdiff_t difference_type;
typedef const value_type * pointer;
typedef const value_type & reference;
Generator& operator++() { v = cast()(); return cast(); }
const value_type& operator*() const { return v; }
protected:
// instantiate from derived classes only
generator_iterator_mixin_adapter() { }
void iterator_init() { operator++(); }
private:
Generator & cast() { return static_cast<Generator&>(*this); }
value_type v;
};
} // namespace boost
#endif // BOOST_ITERATOR_MIXIN_HPP

View File

@@ -0,0 +1,100 @@
/* boost random/detail/uniform_int_float.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: pass_through_engine.hpp 58649 2010-01-02 21:23:17Z steven_watanabe $
*
*/
#ifndef BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP
#define BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP
#include <boost/config.hpp>
#include <boost/random/detail/ptr_helper.hpp>
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
namespace random {
namespace detail {
template<class UniformRandomNumberGenerator>
class pass_through_engine
{
private:
typedef ptr_helper<UniformRandomNumberGenerator> helper_type;
public:
typedef typename helper_type::value_type base_type;
typedef typename base_type::result_type result_type;
explicit pass_through_engine(UniformRandomNumberGenerator rng)
// make argument an rvalue to avoid matching Generator& constructor
: _rng(static_cast<typename helper_type::rvalue_type>(rng))
{ }
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (base().min)(); }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (base().max)(); }
base_type& base() { return helper_type::ref(_rng); }
const base_type& base() const { return helper_type::ref(_rng); }
result_type operator()() { return base()(); }
private:
UniformRandomNumberGenerator _rng;
};
#ifndef BOOST_NO_STD_LOCALE
template<class UniformRandomNumberGenerator, class CharT, class Traits>
std::basic_ostream<CharT,Traits>&
operator<<(
std::basic_ostream<CharT,Traits>& os
, const pass_through_engine<UniformRandomNumberGenerator>& ud
)
{
return os << ud.base();
}
template<class UniformRandomNumberGenerator, class CharT, class Traits>
std::basic_istream<CharT,Traits>&
operator>>(
std::basic_istream<CharT,Traits>& is
, const pass_through_engine<UniformRandomNumberGenerator>& ud
)
{
return is >> ud.base();
}
#else // no new streams
template<class UniformRandomNumberGenerator>
inline std::ostream&
operator<<(std::ostream& os,
const pass_through_engine<UniformRandomNumberGenerator>& ud)
{
return os << ud.base();
}
template<class UniformRandomNumberGenerator>
inline std::istream&
operator>>(std::istream& is,
const pass_through_engine<UniformRandomNumberGenerator>& ud)
{
return is >> ud.base();
}
#endif
} // namespace detail
} // namespace random
} // namespace boost
#include <boost/random/detail/enable_warnings.hpp>
#endif // BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP

View File

@@ -0,0 +1,94 @@
/* boost random/detail/ptr_helper.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: ptr_helper.hpp 24096 2004-07-27 03:43:34Z dgregor $
*
*/
#ifndef BOOST_RANDOM_DETAIL_PTR_HELPER_HPP
#define BOOST_RANDOM_DETAIL_PTR_HELPER_HPP
#include <boost/config.hpp>
namespace boost {
namespace random {
namespace detail {
// type_traits could help here, but I don't want to depend on type_traits.
template<class T>
struct ptr_helper
{
typedef T value_type;
typedef T& reference_type;
typedef const T& rvalue_type;
static reference_type ref(T& r) { return r; }
static const T& ref(const T& r) { return r; }
};
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template<class T>
struct ptr_helper<T&>
{
typedef T value_type;
typedef T& reference_type;
typedef T& rvalue_type;
static reference_type ref(T& r) { return r; }
static const T& ref(const T& r) { return r; }
};
template<class T>
struct ptr_helper<T*>
{
typedef T value_type;
typedef T& reference_type;
typedef T* rvalue_type;
static reference_type ref(T * p) { return *p; }
static const T& ref(const T * p) { return *p; }
};
#endif
} // namespace detail
} // namespace random
} // namespace boost
//
// BOOST_RANDOM_PTR_HELPER_SPEC --
//
// Helper macro for broken compilers defines specializations of
// ptr_helper.
//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
# define BOOST_RANDOM_PTR_HELPER_SPEC(T) \
namespace boost { namespace random { namespace detail { \
template<> \
struct ptr_helper<T&> \
{ \
typedef T value_type; \
typedef T& reference_type; \
typedef T& rvalue_type; \
static reference_type ref(T& r) { return r; } \
static const T& ref(const T& r) { return r; } \
}; \
\
template<> \
struct ptr_helper<T*> \
{ \
typedef T value_type; \
typedef T& reference_type; \
typedef T* rvalue_type; \
static reference_type ref(T * p) { return *p; } \
static const T& ref(const T * p) { return *p; } \
}; \
}}}
#else
# define BOOST_RANDOM_PTR_HELPER_SPEC(T)
#endif
#endif // BOOST_RANDOM_DETAIL_PTR_HELPER_HPP

View File

@@ -0,0 +1,89 @@
/* boost random/detail/seed.hpp header file
*
* Copyright Steven Watanabe 2009
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: seed.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*/
#ifndef BOOST_RANDOM_DETAIL_SEED_HPP
#define BOOST_RANDOM_DETAIL_SEED_HPP
#include <boost/config.hpp>
// Sun seems to have trouble with the use of SFINAE for the
// templated constructor. So does Borland.
#if !defined(BOOST_NO_SFINAE) && !defined(__SUNPRO_CC) && !defined(__BORLANDC__)
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
namespace boost {
namespace random {
namespace detail {
template<class T>
struct disable_seed : boost::disable_if<boost::is_arithmetic<T> > {};
template<class Engine, class T>
struct disable_constructor : disable_seed<T> {};
template<class Engine>
struct disable_constructor<Engine, Engine> {};
#define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \
template<class Generator> \
explicit Self(Generator& gen, typename ::boost::random::detail::disable_constructor<Self, Generator>::type* = 0)
#define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \
template<class Generator> \
void seed(Generator& gen, typename ::boost::random::detail::disable_seed<Generator>::type* = 0)
#define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \
explicit Self(const T& x)
#define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \
void seed(const T& x)
}
}
}
#else
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/mpl/bool.hpp>
#define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \
Self(Self& other) { *this = other; } \
Self(const Self& other) { *this = other; } \
template<class Generator> \
explicit Self(Generator& gen) { \
boost_random_constructor_impl(gen, ::boost::is_arithmetic<Generator>());\
} \
template<class Generator> \
void boost_random_constructor_impl(Generator& gen, ::boost::mpl::false_)
#define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \
template<class Generator> \
void seed(Generator& gen) { \
boost_random_seed_impl(gen, ::boost::is_arithmetic<Generator>());\
}\
template<class Generator>\
void boost_random_seed_impl(Generator& gen, ::boost::mpl::false_)
#define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \
explicit Self(const T& x) { boost_random_constructor_impl(x, ::boost::mpl::true_()); }\
void boost_random_constructor_impl(const T& x, ::boost::mpl::true_)
#define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \
void seed(const T& x) { boost_random_seed_impl(x, ::boost::mpl::true_()); }\
void boost_random_seed_impl(const T& x, ::boost::mpl::true_)
#endif
#endif

View File

@@ -0,0 +1,89 @@
/* boost random/detail/signed_unsigned_tools.hpp header file
*
* Copyright Jens Maurer 2006
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*/
#ifndef BOOST_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS
#define BOOST_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS
#include <boost/limits.hpp>
#include <boost/config.hpp>
#include <boost/type_traits/make_unsigned.hpp>
namespace boost {
namespace random {
namespace detail {
/*
* Compute x - y, we know that x >= y, return an unsigned value.
*/
template<class T, bool sgn = std::numeric_limits<T>::is_signed>
struct subtract { };
template<class T>
struct subtract<T, /* signed */ false>
{
typedef T result_type;
result_type operator()(T x, T y) { return x - y; }
};
template<class T>
struct subtract<T, /* signed */ true>
{
typedef typename make_unsigned<T>::type result_type;
result_type operator()(T x, T y)
{
if (y >= 0) // because x >= y, it follows that x >= 0, too
return result_type(x) - result_type(y);
if (x >= 0) // y < 0
// avoid the nasty two's complement case for y == min()
return result_type(x) + result_type(-(y+1)) + 1;
// both x and y are negative: no signed overflow
return result_type(x - y);
}
};
/*
* Compute x + y, x is unsigned, result fits in type of "y".
*/
template<class T1, class T2, bool sgn = std::numeric_limits<T2>::is_signed>
struct add { };
template<class T1, class T2>
struct add<T1, T2, /* signed */ false>
{
typedef T2 result_type;
result_type operator()(T1 x, T2 y) { return T2(x) + y; }
};
template<class T1, class T2>
struct add<T1, T2, /* signed */ true>
{
typedef T2 result_type;
result_type operator()(T1 x, T2 y)
{
if (y >= 0)
return T2(x) + y;
// y < 0
if (x >= T1(-(y+1))) // result >= 0 after subtraction
// avoid the nasty two's complement edge case for y == min()
return T2(x - T1(-(y+1)) - 1);
// abs(x) < abs(y), thus T2 able to represent x
return T2(x) + y;
}
};
} // namespace detail
} // namespace random
} // namespace boost
#endif // BOOST_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS

View File

@@ -0,0 +1,85 @@
/* boost random/detail/uniform_int_float.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: uniform_int_float.hpp 52492 2009-04-19 14:55:57Z steven_watanabe $
*
*/
#ifndef BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP
#define BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP
#include <boost/config.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/uniform_01.hpp>
namespace boost {
namespace random {
namespace detail {
template<class UniformRandomNumberGenerator, class IntType = unsigned long>
class uniform_int_float
{
public:
typedef UniformRandomNumberGenerator base_type;
typedef IntType result_type;
uniform_int_float(base_type rng, IntType min_arg = 0, IntType max_arg = 0xffffffff)
: _rng(rng), _min(min_arg), _max(max_arg)
{
init();
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
base_type& base() { return _rng.base(); }
const base_type& base() const { return _rng.base(); }
result_type operator()()
{
return static_cast<IntType>(_rng() * _range) + _min;
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_int_float& ud)
{
os << ud._min << " " << ud._max;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, uniform_int_float& ud)
{
is >> std::ws >> ud._min >> std::ws >> ud._max;
ud.init();
return is;
}
#endif
private:
void init()
{
_range = static_cast<base_result>(_max-_min)+1;
}
typedef typename base_type::result_type base_result;
uniform_01<base_type> _rng;
result_type _min, _max;
base_result _range;
};
} // namespace detail
} // namespace random
} // namespace boost
#endif // BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP

View File

@@ -0,0 +1,132 @@
/* boost random/discard_block.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: discard_block.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-03-02 created
*/
#ifndef BOOST_RANDOM_DISCARD_BLOCK_HPP
#define BOOST_RANDOM_DISCARD_BLOCK_HPP
#include <iostream>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
namespace boost {
namespace random {
/**
* The class template \discard_block is a model of
* \pseudo_random_number_generator. It modifies
* another generator by discarding parts of its output.
* Out of every block of @c r results, the first @c p
* will be returned and the rest discarded.
*
* Requires: 0 < p <= r
*/
template<class UniformRandomNumberGenerator, unsigned int p, unsigned int r>
class discard_block
{
public:
typedef UniformRandomNumberGenerator base_type;
typedef typename base_type::result_type result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
BOOST_STATIC_CONSTANT(unsigned int, total_block = p);
BOOST_STATIC_CONSTANT(unsigned int, returned_block = r);
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(total_block >= returned_block);
#endif
discard_block() : _rng(), _n(0) { }
explicit discard_block(const base_type & rng) : _rng(rng), _n(0) { }
template<class T> explicit discard_block(T s) : _rng(s), _n(0) {}
template<class It> discard_block(It& first, It last)
: _rng(first, last), _n(0) { }
void seed() { _rng.seed(); _n = 0; }
template<class T> void seed(T s) { _rng.seed(s); _n = 0; }
template<class It> void seed(It& first, It last)
{ _n = 0; _rng.seed(first, last); }
const base_type& base() const { return _rng; }
result_type operator()()
{
if(_n >= returned_block) {
// discard values of random number generator
for( ; _n < total_block; ++_n)
_rng();
_n = 0;
}
++_n;
return _rng();
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (_rng.min)(); }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (_rng.max)(); }
static bool validation(result_type x) { return true; } // dummy
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const discard_block& s)
{
os << s._rng << " " << s._n << " ";
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, discard_block& s)
{
is >> s._rng >> std::ws >> s._n >> std::ws;
return is;
}
#endif
friend bool operator==(const discard_block& x, const discard_block& y)
{ return x._rng == y._rng && x._n == y._n; }
friend bool operator!=(const discard_block& x, const discard_block& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const discard_block& rhs) const
{ return _rng == rhs._rng && _n == rhs._n; }
bool operator!=(const discard_block& rhs) const
{ return !(*this == rhs); }
#endif
private:
base_type _rng;
unsigned int _n;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class UniformRandomNumberGenerator, unsigned int p, unsigned int r>
const bool discard_block<UniformRandomNumberGenerator, p, r>::has_fixed_range;
template<class UniformRandomNumberGenerator, unsigned int p, unsigned int r>
const unsigned int discard_block<UniformRandomNumberGenerator, p, r>::total_block;
template<class UniformRandomNumberGenerator, unsigned int p, unsigned int r>
const unsigned int discard_block<UniformRandomNumberGenerator, p, r>::returned_block;
#endif
} // namespace random
} // namespace boost
#endif // BOOST_RANDOM_DISCARD_BLOCK_HPP

View File

@@ -0,0 +1,86 @@
/* boost random/exponential_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: exponential_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP
#define BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <cassert>
#include <iostream>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
namespace boost {
/**
* The exponential distribution has a single parameter lambda.
*
* It has \f$p(x) = \lambda e^{-\lambda x}\f$
*/
template<class RealType = double>
class exponential_distribution
{
public:
typedef RealType input_type;
typedef RealType result_type;
#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) && !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300)
BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
#endif
explicit exponential_distribution(result_type lambda_arg = result_type(1))
: _lambda(lambda_arg) { assert(_lambda > result_type(0)); }
// compiler-generated copy ctor and assignment operator are fine
result_type lambda() const { return _lambda; }
void reset() { }
template<class Engine>
result_type operator()(Engine& eng)
{
#ifndef BOOST_NO_STDC_NAMESPACE
using std::log;
#endif
return -result_type(1) / _lambda * log(result_type(1)-eng());
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const exponential_distribution& ed)
{
os << ed._lambda;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, exponential_distribution& ed)
{
is >> std::ws >> ed._lambda;
return is;
}
#endif
private:
result_type _lambda;
};
} // namespace boost
#endif // BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP

View File

@@ -0,0 +1,143 @@
/* boost random/gamma_distribution.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: gamma_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
*/
#ifndef BOOST_RANDOM_GAMMA_DISTRIBUTION_HPP
#define BOOST_RANDOM_GAMMA_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <cassert>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/exponential_distribution.hpp>
namespace boost {
// The algorithm is taken from Knuth
/**
* The gamma distribution is a continuous distribution with a single
* parameter alpha.
*
* It has \f$p(x) = x^{\alpha-1}\frac{e^{-x}}{\Gamma(\alpha)}\f$.
*/
template<class RealType = double>
class gamma_distribution
{
public:
typedef RealType input_type;
typedef RealType result_type;
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
#endif
explicit gamma_distribution(const result_type& alpha_arg = result_type(1))
: _exp(result_type(1)), _alpha(alpha_arg)
{
assert(_alpha > result_type(0));
init();
}
// compiler-generated copy ctor and assignment operator are fine
RealType alpha() const { return _alpha; }
void reset() { _exp.reset(); }
template<class Engine>
result_type operator()(Engine& eng)
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::tan; using std::sqrt; using std::exp; using std::log;
using std::pow;
#endif
if(_alpha == result_type(1)) {
return _exp(eng);
} else if(_alpha > result_type(1)) {
// Can we have a boost::mathconst please?
const result_type pi = result_type(3.14159265358979323846);
for(;;) {
result_type y = tan(pi * eng());
result_type x = sqrt(result_type(2)*_alpha-result_type(1))*y
+ _alpha-result_type(1);
if(x <= result_type(0))
continue;
if(eng() >
(result_type(1)+y*y) * exp((_alpha-result_type(1))
*log(x/(_alpha-result_type(1)))
- sqrt(result_type(2)*_alpha
-result_type(1))*y))
continue;
return x;
}
} else /* alpha < 1.0 */ {
for(;;) {
result_type u = eng();
result_type y = _exp(eng);
result_type x, q;
if(u < _p) {
x = exp(-y/_alpha);
q = _p*exp(-x);
} else {
x = result_type(1)+y;
q = _p + (result_type(1)-_p) * pow(x, _alpha-result_type(1));
}
if(u >= q)
continue;
return x;
}
}
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const gamma_distribution& gd)
{
os << gd._alpha;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, gamma_distribution& gd)
{
is >> std::ws >> gd._alpha;
gd.init();
return is;
}
#endif
private:
/// \cond hide_private_members
void init()
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::exp;
#endif
_p = exp(result_type(1)) / (_alpha + exp(result_type(1)));
}
/// \endcond
exponential_distribution<RealType> _exp;
result_type _alpha;
// some data precomputed from the parameters
result_type _p;
};
} // namespace boost
#endif // BOOST_RANDOM_GAMMA_DISTRIBUTION_HPP

View File

@@ -0,0 +1,118 @@
/* boost random/geometric_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: geometric_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
#define BOOST_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp> // std::log
#include <cassert>
#include <iostream>
#include <boost/random/detail/config.hpp>
#include <boost/random/uniform_01.hpp>
namespace boost {
#if defined(__GNUC__) && (__GNUC__ < 3)
// Special gcc workaround: gcc 2.95.x ignores using-declarations
// in template classes (confirmed by gcc author Martin v. Loewis)
using std::log;
#endif
/**
* An instantiation of the class template @c geometric_distribution models
* a \random_distribution. The distribution produces positive
* integers which are the number of bernoulli trials
* with probability @c p required to get one that fails.
*
* For the geometric distribution, \f$p(i) = (1-p) p^{i-1}\f$.
*/
template<class IntType = int, class RealType = double>
class geometric_distribution
{
public:
typedef RealType input_type;
typedef IntType result_type;
/**
* Contructs a new geometric_distribution with the paramter @c p.
*
* Requires: 0 < p < 1
*/
explicit geometric_distribution(const RealType& p = RealType(0.5))
: _p(p)
{
assert(RealType(0) < _p && _p < RealType(1));
init();
}
// compiler-generated copy ctor and assignment operator are fine
/**
* Returns: the distribution parameter @c p
*/
RealType p() const { return _p; }
void reset() { }
template<class Engine>
result_type operator()(Engine& eng)
{
#ifndef BOOST_NO_STDC_NAMESPACE
using std::log;
using std::floor;
#endif
return IntType(floor(log(RealType(1)-eng()) / _log_p)) + IntType(1);
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const geometric_distribution& gd)
{
os << gd._p;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, geometric_distribution& gd)
{
is >> std::ws >> gd._p;
gd.init();
return is;
}
#endif
private:
/// \cond hide_private_functions
void init()
{
#ifndef BOOST_NO_STDC_NAMESPACE
using std::log;
#endif
_log_p = log(_p);
}
/// \endcond
RealType _p;
RealType _log_p;
};
} // namespace boost
#endif // BOOST_RANDOM_GEOMETRIC_DISTRIBUTION_HPP

View File

@@ -0,0 +1,173 @@
/* boost random/inversive_congruential.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: inversive_congruential.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_INVERSIVE_CONGRUENTIAL_HPP
#define BOOST_RANDOM_INVERSIVE_CONGRUENTIAL_HPP
#include <iostream>
#include <cassert>
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/const_mod.hpp>
namespace boost {
namespace random {
// Eichenauer and Lehn 1986
/**
* Instantiations of class template @c inversive_congruential model a
* \pseudo_random_number_generator. It uses the inversive congruential
* algorithm (ICG) described in
*
* @blockquote
* "Inversive pseudorandom number generators: concepts, results and links",
* Peter Hellekalek, In: "Proceedings of the 1995 Winter Simulation
* Conference", C. Alexopoulos, K. Kang, W.R. Lilegdon, and D. Goldsman
* (editors), 1995, pp. 255-262. ftp://random.mat.sbg.ac.at/pub/data/wsc95.ps
* @endblockquote
*
* The output sequence is defined by x(n+1) = (a*inv(x(n)) - b) (mod p),
* where x(0), a, b, and the prime number p are parameters of the generator.
* The expression inv(k) denotes the multiplicative inverse of k in the
* field of integer numbers modulo p, with inv(0) := 0.
*
* The template parameter IntType shall denote a signed integral type large
* enough to hold p; a, b, and p are the parameters of the generators. The
* template parameter val is the validation value checked by validation.
*
* @xmlnote
* The implementation currently uses the Euclidian Algorithm to compute
* the multiplicative inverse. Therefore, the inversive generators are about
* 10-20 times slower than the others (see section"performance"). However,
* the paper talks of only 3x slowdown, so the Euclidian Algorithm is probably
* not optimal for calculating the multiplicative inverse.
* @endxmlnote
*/
template<class IntType, IntType a, IntType b, IntType p, IntType val>
class inversive_congruential
{
public:
typedef IntType result_type;
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
static const bool has_fixed_range = true;
static const result_type min_value = (b == 0 ? 1 : 0);
static const result_type max_value = p-1;
#else
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
#endif
BOOST_STATIC_CONSTANT(result_type, multiplier = a);
BOOST_STATIC_CONSTANT(result_type, increment = b);
BOOST_STATIC_CONSTANT(result_type, modulus = p);
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return b == 0 ? 1 : 0; }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return p-1; }
/**
* Constructs an inversive_congruential generator with
* @c y0 as the initial state.
*/
explicit inversive_congruential(IntType y0 = 1) : value(y0)
{
BOOST_STATIC_ASSERT(b >= 0);
BOOST_STATIC_ASSERT(p > 1);
BOOST_STATIC_ASSERT(a >= 1);
if(b == 0)
assert(y0 > 0);
}
template<class It> inversive_congruential(It& first, It last)
{ seed(first, last); }
/** Changes the current state to y0. */
void seed(IntType y0 = 1) { value = y0; if(b == 0) assert(y0 > 0); }
template<class It> void seed(It& first, It last)
{
if(first == last)
throw std::invalid_argument("inversive_congruential::seed");
value = *first++;
}
IntType operator()()
{
typedef const_mod<IntType, p> do_mod;
value = do_mod::mult_add(a, do_mod::invert(value), b);
return value;
}
static bool validation(result_type x) { return val == x; }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, inversive_congruential x)
{ os << x.value; return os; }
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, inversive_congruential& x)
{ is >> x.value; return is; }
#endif
friend bool operator==(inversive_congruential x, inversive_congruential y)
{ return x.value == y.value; }
friend bool operator!=(inversive_congruential x, inversive_congruential y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(inversive_congruential rhs) const
{ return value == rhs.value; }
bool operator!=(inversive_congruential rhs) const
{ return !(*this == rhs); }
#endif
private:
IntType value;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class IntType, IntType a, IntType b, IntType p, IntType val>
const bool inversive_congruential<IntType, a, b, p, val>::has_fixed_range;
template<class IntType, IntType a, IntType b, IntType p, IntType val>
const typename inversive_congruential<IntType, a, b, p, val>::result_type inversive_congruential<IntType, a, b, p, val>::min_value;
template<class IntType, IntType a, IntType b, IntType p, IntType val>
const typename inversive_congruential<IntType, a, b, p, val>::result_type inversive_congruential<IntType, a, b, p, val>::max_value;
template<class IntType, IntType a, IntType b, IntType p, IntType val>
const typename inversive_congruential<IntType, a, b, p, val>::result_type inversive_congruential<IntType, a, b, p, val>::multiplier;
template<class IntType, IntType a, IntType b, IntType p, IntType val>
const typename inversive_congruential<IntType, a, b, p, val>::result_type inversive_congruential<IntType, a, b, p, val>::increment;
template<class IntType, IntType a, IntType b, IntType p, IntType val>
const typename inversive_congruential<IntType, a, b, p, val>::result_type inversive_congruential<IntType, a, b, p, val>::modulus;
#endif
} // namespace random
/**
* The specialization hellekalek1995 was suggested in
*
* @blockquote
* "Inversive pseudorandom number generators: concepts, results and links",
* Peter Hellekalek, In: "Proceedings of the 1995 Winter Simulation
* Conference", C. Alexopoulos, K. Kang, W.R. Lilegdon, and D. Goldsman
* (editors), 1995, pp. 255-262. ftp://random.mat.sbg.ac.at/pub/data/wsc95.ps
* @endblockquote
*/
typedef random::inversive_congruential<int32_t, 9102, 2147483647-36884165,
2147483647, 0> hellekalek1995;
} // namespace boost
#endif // BOOST_RANDOM_INVERSIVE_CONGRUENTIAL_HPP

View File

@@ -0,0 +1,605 @@
/* boost random/lagged_fibonacci.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: lagged_fibonacci.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_LAGGED_FIBONACCI_HPP
#define BOOST_RANDOM_LAGGED_FIBONACCI_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <iostream>
#include <algorithm> // std::max
#include <iterator>
#include <boost/config/no_tr1/cmath.hpp> // std::pow
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/cstdint.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/random/linear_congruential.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/seed.hpp>
#include <boost/random/detail/pass_through_engine.hpp>
namespace boost {
namespace random {
#if BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292)) && BOOST_MSVC > 1300
# define BOOST_RANDOM_EXTRACT_LF
#endif
#if defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ <= 3)
# define BOOST_RANDOM_EXTRACT_LF
#endif
# ifdef BOOST_RANDOM_EXTRACT_LF
namespace detail
{
template<class IStream, class F, class RealType>
IStream&
extract_lagged_fibonacci_01(
IStream& is
, F const& f
, unsigned int& i
, RealType* x
, RealType modulus)
{
is >> i >> std::ws;
for(unsigned int i = 0; i < f.long_lag; ++i)
{
RealType value;
is >> value >> std::ws;
x[i] = value / modulus;
}
return is;
}
template<class IStream, class F, class UIntType>
IStream&
extract_lagged_fibonacci(
IStream& is
, F const& f
, unsigned int& i
, UIntType* x)
{
is >> i >> std::ws;
for(unsigned int i = 0; i < f.long_lag; ++i)
is >> x[i] >> std::ws;
return is;
}
}
# endif
/**
* Instantiations of class template \lagged_fibonacci model a
* \pseudo_random_number_generator. It uses a lagged Fibonacci
* algorithm with two lags @c p and @c q:
* x(i) = x(i-p) + x(i-q) (mod 2<sup>w</sup>) with p > q.
*/
template<class UIntType, int w, unsigned int p, unsigned int q,
UIntType val = 0>
class lagged_fibonacci
{
public:
typedef UIntType result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
BOOST_STATIC_CONSTANT(int, word_size = w);
BOOST_STATIC_CONSTANT(unsigned int, long_lag = p);
BOOST_STATIC_CONSTANT(unsigned int, short_lag = q);
/**
* Returns: the smallest value that the generator can produce
*/
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
/**
* Returns: the largest value that the generator can produce
*/
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return wordmask; }
/**
* Creates a new @c lagged_fibonacci generator and calls @c seed()
*/
lagged_fibonacci() { init_wordmask(); seed(); }
/**
* Creates a new @c lagged_fibonacci generator and calls @c seed(value)
*/
explicit lagged_fibonacci(uint32_t value) { init_wordmask(); seed(value); }
/**
* Creates a new @c lagged_fibonacci generator and calls @c seed(first, last)
*/
template<class It> lagged_fibonacci(It& first, It last)
{ init_wordmask(); seed(first, last); }
// compiler-generated copy ctor and assignment operator are fine
private:
/// \cond hide_private_members
void init_wordmask()
{
wordmask = 0;
for(int j = 0; j < w; ++j)
wordmask |= (1u << j);
}
/// \endcond
public:
/**
* Sets the state of the generator to values produced by
* a \minstd_rand generator.
*/
void seed(uint32_t value = 331u)
{
minstd_rand0 gen(value);
for(unsigned int j = 0; j < long_lag; ++j)
x[j] = gen() & wordmask;
i = long_lag;
}
/**
* Sets the state of the generator to values from the iterator
* range [first, last). If there are not enough elements in the
* range [first, last) throws @c std::invalid_argument.
*/
template<class It>
void seed(It& first, It last)
{
// word size could be smaller than the seed values
unsigned int j;
for(j = 0; j < long_lag && first != last; ++j, ++first)
x[j] = *first & wordmask;
i = long_lag;
if(first == last && j < long_lag)
throw std::invalid_argument("lagged_fibonacci::seed");
}
/**
* Returns: the next value of the generator
*/
result_type operator()()
{
if(i >= long_lag)
fill();
return x[i++];
}
static bool validation(result_type x)
{
return x == val;
}
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const lagged_fibonacci& f)
{
os << f.i << " ";
for(unsigned int i = 0; i < f.long_lag; ++i)
os << f.x[i] << " ";
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, lagged_fibonacci& f)
{
# ifdef BOOST_RANDOM_EXTRACT_LF
return detail::extract_lagged_fibonacci(is, f, f.i, f.x);
# else
is >> f.i >> std::ws;
for(unsigned int i = 0; i < f.long_lag; ++i)
is >> f.x[i] >> std::ws;
return is;
# endif
}
#endif
friend bool operator==(const lagged_fibonacci& x, const lagged_fibonacci& y)
{ return x.i == y.i && std::equal(x.x, x.x+long_lag, y.x); }
friend bool operator!=(const lagged_fibonacci& x,
const lagged_fibonacci& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const lagged_fibonacci& rhs) const
{ return i == rhs.i && std::equal(x, x+long_lag, rhs.x); }
bool operator!=(const lagged_fibonacci& rhs) const
{ return !(*this == rhs); }
#endif
private:
/// \cond hide_private_members
void fill();
/// \endcond
UIntType wordmask;
unsigned int i;
UIntType x[long_lag];
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class UIntType, int w, unsigned int p, unsigned int q, UIntType val>
const bool lagged_fibonacci<UIntType, w, p, q, val>::has_fixed_range;
template<class UIntType, int w, unsigned int p, unsigned int q, UIntType val>
const unsigned int lagged_fibonacci<UIntType, w, p, q, val>::long_lag;
template<class UIntType, int w, unsigned int p, unsigned int q, UIntType val>
const unsigned int lagged_fibonacci<UIntType, w, p, q, val>::short_lag;
#endif
/// \cond hide_private_members
template<class UIntType, int w, unsigned int p, unsigned int q, UIntType val>
void lagged_fibonacci<UIntType, w, p, q, val>::fill()
{
// two loops to avoid costly modulo operations
{ // extra scope for MSVC brokenness w.r.t. for scope
for(unsigned int j = 0; j < short_lag; ++j)
x[j] = (x[j] + x[j+(long_lag-short_lag)]) & wordmask;
}
for(unsigned int j = short_lag; j < long_lag; ++j)
x[j] = (x[j] + x[j-short_lag]) & wordmask;
i = 0;
}
// lagged Fibonacci generator for the range [0..1)
// contributed by Matthias Troyer
// for p=55, q=24 originally by G. J. Mitchell and D. P. Moore 1958
template<class T, unsigned int p, unsigned int q>
struct fibonacci_validation
{
BOOST_STATIC_CONSTANT(bool, is_specialized = false);
static T value() { return 0; }
static T tolerance() { return 0; }
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class T, unsigned int p, unsigned int q>
const bool fibonacci_validation<T, p, q>::is_specialized;
#endif
#define BOOST_RANDOM_FIBONACCI_VAL(T,P,Q,V,E) \
template<> \
struct fibonacci_validation<T, P, Q> \
{ \
BOOST_STATIC_CONSTANT(bool, is_specialized = true); \
static T value() { return V; } \
static T tolerance() \
{ return (std::max)(E, static_cast<T>(5*std::numeric_limits<T>::epsilon())); } \
};
// (The extra static_cast<T> in the std::max call above is actually
// unnecessary except for HP aCC 1.30, which claims that
// numeric_limits<double>::epsilon() doesn't actually return a double.)
BOOST_RANDOM_FIBONACCI_VAL(double, 607, 273, 0.4293817707235914, 1e-14)
BOOST_RANDOM_FIBONACCI_VAL(double, 1279, 418, 0.9421630240437659, 1e-14)
BOOST_RANDOM_FIBONACCI_VAL(double, 2281, 1252, 0.1768114046909004, 1e-14)
BOOST_RANDOM_FIBONACCI_VAL(double, 3217, 576, 0.1956232694868209, 1e-14)
BOOST_RANDOM_FIBONACCI_VAL(double, 4423, 2098, 0.9499762202147172, 1e-14)
BOOST_RANDOM_FIBONACCI_VAL(double, 9689, 5502, 0.05737836943695162, 1e-14)
BOOST_RANDOM_FIBONACCI_VAL(double, 19937, 9842, 0.5076528587449834, 1e-14)
BOOST_RANDOM_FIBONACCI_VAL(double, 23209, 13470, 0.5414473810619185, 1e-14)
BOOST_RANDOM_FIBONACCI_VAL(double, 44497,21034, 0.254135073399297, 1e-14)
#undef BOOST_RANDOM_FIBONACCI_VAL
/// \endcond
/**
* Instantiations of class template @c lagged_fibonacci_01 model a
* \pseudo_random_number_generator. It uses a lagged Fibonacci
* algorithm with two lags @c p and @c q, evaluated in floating-point
* arithmetic: x(i) = x(i-p) + x(i-q) (mod 1) with p > q. See
*
* @blockquote
* "Uniform random number generators for supercomputers", Richard Brent,
* Proc. of Fifth Australian Supercomputer Conference, Melbourne,
* Dec. 1992, pp. 704-706.
* @endblockquote
*
* @xmlnote
* The quality of the generator crucially depends on the choice
* of the parameters. User code should employ one of the sensibly
* parameterized generators such as \lagged_fibonacci607 instead.
* @endxmlnote
*
* The generator requires considerable amounts of memory for the storage
* of its state array. For example, \lagged_fibonacci607 requires about
* 4856 bytes and \lagged_fibonacci44497 requires about 350 KBytes.
*/
template<class RealType, int w, unsigned int p, unsigned int q>
class lagged_fibonacci_01
{
public:
typedef RealType result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
BOOST_STATIC_CONSTANT(int, word_size = w);
BOOST_STATIC_CONSTANT(unsigned int, long_lag = p);
BOOST_STATIC_CONSTANT(unsigned int, short_lag = q);
/** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(). */
lagged_fibonacci_01() { init_modulus(); seed(); }
/** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(value). */
BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(lagged_fibonacci_01, uint32_t, value)
{ init_modulus(); seed(value); }
/** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(gen). */
BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(lagged_fibonacci_01, Generator, gen)
{ init_modulus(); seed(gen); }
template<class It> lagged_fibonacci_01(It& first, It last)
{ init_modulus(); seed(first, last); }
// compiler-generated copy ctor and assignment operator are fine
private:
/// \cond hide_private_members
void init_modulus()
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::pow;
#endif
_modulus = pow(RealType(2), word_size);
}
/// \endcond
public:
/** Calls seed(331u). */
void seed() { seed(331u); }
/**
* Constructs a \minstd_rand0 generator with the constructor parameter
* value and calls seed with it. Distinct seeds in the range
* [1, 2147483647) will produce generators with different states. Other
* seeds will be equivalent to some seed within this range. See
* \linear_congruential for details.
*/
BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(lagged_fibonacci_01, uint32_t, value)
{
minstd_rand0 intgen(value);
seed(intgen);
}
/**
* Sets the state of this @c lagged_fibonacci_01 to the values returned
* by p invocations of \uniform_01<code>\<RealType\>()(gen)</code>.
*
* Complexity: Exactly p invocations of gen.
*/
BOOST_RANDOM_DETAIL_GENERATOR_SEED(lagged_fibonacci, Generator, gen)
{
// use pass-by-reference, but wrap argument in pass_through_engine
typedef detail::pass_through_engine<Generator&> ref_gen;
uniform_01<ref_gen, RealType> gen01 =
uniform_01<ref_gen, RealType>(ref_gen(gen));
// I could have used std::generate_n, but it takes "gen" by value
for(unsigned int j = 0; j < long_lag; ++j)
x[j] = gen01();
i = long_lag;
}
template<class It>
void seed(It& first, It last)
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::fmod;
using std::pow;
#endif
unsigned long mask = ~((~0u) << (w%32)); // now lowest w bits set
RealType two32 = pow(RealType(2), 32);
unsigned int j;
for(j = 0; j < long_lag && first != last; ++j) {
x[j] = RealType(0);
for(int k = 0; k < w/32 && first != last; ++k, ++first)
x[j] += *first / pow(two32,k+1);
if(first != last && mask != 0) {
x[j] += fmod((*first & mask) / _modulus, RealType(1));
++first;
}
}
i = long_lag;
if(first == last && j < long_lag)
throw std::invalid_argument("lagged_fibonacci_01::seed");
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(0); }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(1); }
result_type operator()()
{
if(i >= long_lag)
fill();
return x[i++];
}
static bool validation(result_type x)
{
result_type v = fibonacci_validation<result_type, p, q>::value();
result_type epsilon = fibonacci_validation<result_type, p, q>::tolerance();
// std::abs is a source of trouble: sometimes, it's not overloaded
// for double, plus the usual namespace std noncompliance -> avoid it
// using std::abs;
// return abs(x - v) < 5 * epsilon
return x > v - epsilon && x < v + epsilon;
}
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const lagged_fibonacci_01&f)
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::pow;
#endif
os << f.i << " ";
std::ios_base::fmtflags oldflags = os.flags(os.dec | os.fixed | os.left);
for(unsigned int i = 0; i < f.long_lag; ++i)
os << f.x[i] * f._modulus << " ";
os.flags(oldflags);
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, lagged_fibonacci_01& f)
{
# ifdef BOOST_RANDOM_EXTRACT_LF
return detail::extract_lagged_fibonacci_01(is, f, f.i, f.x, f._modulus);
# else
is >> f.i >> std::ws;
for(unsigned int i = 0; i < f.long_lag; ++i) {
typename lagged_fibonacci_01::result_type value;
is >> value >> std::ws;
f.x[i] = value / f._modulus;
}
return is;
# endif
}
#endif
friend bool operator==(const lagged_fibonacci_01& x,
const lagged_fibonacci_01& y)
{ return x.i == y.i && std::equal(x.x, x.x+long_lag, y.x); }
friend bool operator!=(const lagged_fibonacci_01& x,
const lagged_fibonacci_01& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const lagged_fibonacci_01& rhs) const
{ return i == rhs.i && std::equal(x, x+long_lag, rhs.x); }
bool operator!=(const lagged_fibonacci_01& rhs) const
{ return !(*this == rhs); }
#endif
private:
/// \cond hide_private_members
void fill();
/// \endcond
unsigned int i;
RealType x[long_lag];
RealType _modulus;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class RealType, int w, unsigned int p, unsigned int q>
const bool lagged_fibonacci_01<RealType, w, p, q>::has_fixed_range;
template<class RealType, int w, unsigned int p, unsigned int q>
const unsigned int lagged_fibonacci_01<RealType, w, p, q>::long_lag;
template<class RealType, int w, unsigned int p, unsigned int q>
const unsigned int lagged_fibonacci_01<RealType, w, p, q>::short_lag;
template<class RealType, int w, unsigned int p, unsigned int q>
const int lagged_fibonacci_01<RealType,w,p,q>::word_size;
#endif
/// \cond hide_private_members
template<class RealType, int w, unsigned int p, unsigned int q>
void lagged_fibonacci_01<RealType, w, p, q>::fill()
{
// two loops to avoid costly modulo operations
{ // extra scope for MSVC brokenness w.r.t. for scope
for(unsigned int j = 0; j < short_lag; ++j) {
RealType t = x[j] + x[j+(long_lag-short_lag)];
if(t >= RealType(1))
t -= RealType(1);
x[j] = t;
}
}
for(unsigned int j = short_lag; j < long_lag; ++j) {
RealType t = x[j] + x[j-short_lag];
if(t >= RealType(1))
t -= RealType(1);
x[j] = t;
}
i = 0;
}
/// \endcond
} // namespace random
#ifdef BOOST_RANDOM_DOXYGEN
namespace detail {
/**
* The specializations lagged_fibonacci607 ... lagged_fibonacci44497
* use well tested lags.
*
* See
*
* @blockquote
* "On the Periods of Generalized Fibonacci Recurrences", Richard P. Brent
* Computer Sciences Laboratory Australian National University, December 1992
* @endblockquote
*
* The lags used here can be found in
*
* @blockquote
* "Uniform random number generators for supercomputers", Richard Brent,
* Proc. of Fifth Australian Supercomputer Conference, Melbourne,
* Dec. 1992, pp. 704-706.
* @endblockquote
*/
struct lagged_fibonacci_doc {};
}
#endif
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 607, 273> lagged_fibonacci607;
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 1279, 418> lagged_fibonacci1279;
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 2281, 1252> lagged_fibonacci2281;
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 3217, 576> lagged_fibonacci3217;
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 4423, 2098> lagged_fibonacci4423;
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 9689, 5502> lagged_fibonacci9689;
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 19937, 9842> lagged_fibonacci19937;
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 23209, 13470> lagged_fibonacci23209;
/**
* @copydoc boost::detail::lagged_fibonacci_doc
*/
typedef random::lagged_fibonacci_01<double, 48, 44497, 21034> lagged_fibonacci44497;
// It is possible to partially specialize uniform_01<> on lagged_fibonacci_01<>
// to help the compiler generate efficient code. For GCC, this seems useless,
// because GCC optimizes (x-0)/(1-0) to (x-0). This is good enough for now.
} // namespace boost
#endif // BOOST_RANDOM_LAGGED_FIBONACCI_HPP

View File

@@ -0,0 +1,403 @@
/* boost random/linear_congruential.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: linear_congruential.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_LINEAR_CONGRUENTIAL_HPP
#define BOOST_RANDOM_LINEAR_CONGRUENTIAL_HPP
#include <iostream>
#include <cassert>
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/const_mod.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
namespace random {
/**
* Instantiations of class template linear_congruential model a
* \pseudo_random_number_generator. Linear congruential pseudo-random
* number generators are described in:
*
* "Mathematical methods in large-scale computing units", D. H. Lehmer,
* Proc. 2nd Symposium on Large-Scale Digital Calculating Machines,
* Harvard University Press, 1951, pp. 141-146
*
* Let x(n) denote the sequence of numbers returned by some pseudo-random
* number generator. Then for the linear congruential generator,
* x(n+1) := (a * x(n) + c) mod m. Parameters for the generator are
* x(0), a, c, m. The template parameter IntType shall denote an integral
* type. It must be large enough to hold values a, c, and m. The template
* parameters a and c must be smaller than m.
*
* Note: The quality of the generator crucially depends on the choice of
* the parameters. User code should use one of the sensibly parameterized
* generators such as minstd_rand instead.
*/
template<class IntType, IntType a, IntType c, IntType m, IntType val>
class linear_congruential
{
public:
typedef IntType result_type;
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
static const bool has_fixed_range = true;
static const result_type min_value = ( c == 0 ? 1 : 0 );
static const result_type max_value = m-1;
#else
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
#endif
BOOST_STATIC_CONSTANT(IntType, multiplier = a);
BOOST_STATIC_CONSTANT(IntType, increment = c);
BOOST_STATIC_CONSTANT(IntType, modulus = m);
// MSVC 6 and possibly others crash when encountering complicated integral
// constant expressions. Avoid the check for now.
// BOOST_STATIC_ASSERT(m == 0 || a < m);
// BOOST_STATIC_ASSERT(m == 0 || c < m);
/**
* Constructs a linear_congruential generator, seeding it with @c x0.
*/
explicit linear_congruential(IntType x0 = 1)
{
seed(x0);
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(std::numeric_limits<IntType>::is_integer);
#endif
}
/**
* Constructs a @c linear_congruential generator and seeds it
* with values taken from the itrator range [first, last)
* and adjusts first to point to the element after the last one
* used. If there are not enough elements, throws @c std::invalid_argument.
*
* first and last must be input iterators.
*/
template<class It>
linear_congruential(It& first, It last)
{
seed(first, last);
}
// compiler-generated copy constructor and assignment operator are fine
/**
* If c mod m is zero and x0 mod m is zero, changes the current value of
* the generator to 1. Otherwise, changes it to x0 mod m. If c is zero,
* distinct seeds in the range [1,m) will leave the generator in distinct
* states. If c is not zero, the range is [0,m).
*/
void seed(IntType x0 = 1)
{
// wrap _x if it doesn't fit in the destination
if(modulus == 0) {
_x = x0;
} else {
_x = x0 % modulus;
}
// handle negative seeds
if(_x <= 0 && _x != 0) {
_x += modulus;
}
// adjust to the correct range
if(increment == 0 && _x == 0) {
_x = 1;
}
assert(_x >= (min)());
assert(_x <= (max)());
}
/**
* seeds a @c linear_congruential generator with values taken
* from the itrator range [first, last) and adjusts @c first to
* point to the element after the last one used. If there are
* not enough elements, throws @c std::invalid_argument.
*
* @c first and @c last must be input iterators.
*/
template<class It>
void seed(It& first, It last)
{
if(first == last)
throw std::invalid_argument("linear_congruential::seed");
seed(*first++);
}
/**
* Returns the smallest value that the @c linear_congruential generator
* can produce.
*/
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return c == 0 ? 1 : 0; }
/**
* Returns the largest value that the @c linear_congruential generator
* can produce.
*/
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return modulus-1; }
/** Returns the next value of the @c linear_congruential generator. */
IntType operator()()
{
_x = const_mod<IntType, m>::mult_add(a, _x, c);
return _x;
}
static bool validation(IntType x) { return val == x; }
#ifdef BOOST_NO_OPERATORS_IN_NAMESPACE
// Use a member function; Streamable concept not supported.
bool operator==(const linear_congruential& rhs) const
{ return _x == rhs._x; }
bool operator!=(const linear_congruential& rhs) const
{ return !(*this == rhs); }
#else
friend bool operator==(const linear_congruential& x,
const linear_congruential& y)
{ return x._x == y._x; }
friend bool operator!=(const linear_congruential& x,
const linear_congruential& y)
{ return !(x == y); }
#if !defined(BOOST_RANDOM_NO_STREAM_OPERATORS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os,
const linear_congruential& lcg)
{
return os << lcg._x;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is,
linear_congruential& lcg)
{
return is >> lcg._x;
}
private:
#endif
#endif
IntType _x;
};
// probably needs the "no native streams" caveat for STLPort
#if !defined(__SGI_STL_PORT) && BOOST_WORKAROUND(__GNUC__, == 2)
template<class IntType, IntType a, IntType c, IntType m, IntType val>
std::ostream&
operator<<(std::ostream& os,
const linear_congruential<IntType,a,c,m,val>& lcg)
{
return os << lcg._x;
}
template<class IntType, IntType a, IntType c, IntType m, IntType val>
std::istream&
operator>>(std::istream& is,
linear_congruential<IntType,a,c,m,val>& lcg)
{
return is >> lcg._x;
}
#elif defined(BOOST_RANDOM_NO_STREAM_OPERATORS) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
template<class CharT, class Traits, class IntType, IntType a, IntType c, IntType m, IntType val>
std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os,
const linear_congruential<IntType,a,c,m,val>& lcg)
{
return os << lcg._x;
}
template<class CharT, class Traits, class IntType, IntType a, IntType c, IntType m, IntType val>
std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is,
linear_congruential<IntType,a,c,m,val>& lcg)
{
return is >> lcg._x;
}
#endif
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class IntType, IntType a, IntType c, IntType m, IntType val>
const bool linear_congruential<IntType, a, c, m, val>::has_fixed_range;
template<class IntType, IntType a, IntType c, IntType m, IntType val>
const typename linear_congruential<IntType, a, c, m, val>::result_type linear_congruential<IntType, a, c, m, val>::min_value;
template<class IntType, IntType a, IntType c, IntType m, IntType val>
const typename linear_congruential<IntType, a, c, m, val>::result_type linear_congruential<IntType, a, c, m, val>::max_value;
template<class IntType, IntType a, IntType c, IntType m, IntType val>
const IntType linear_congruential<IntType,a,c,m,val>::modulus;
#endif
} // namespace random
// validation values from the publications
/**
* The specialization \minstd_rand0 was originally suggested in
*
* @blockquote
* A pseudo-random number generator for the System/360, P.A. Lewis,
* A.S. Goodman, J.M. Miller, IBM Systems Journal, Vol. 8, No. 2,
* 1969, pp. 136-146
* @endblockquote
*
* It is examined more closely together with \minstd_rand in
*
* @blockquote
* "Random Number Generators: Good ones are hard to find",
* Stephen K. Park and Keith W. Miller, Communications of
* the ACM, Vol. 31, No. 10, October 1988, pp. 1192-1201
* @endblockquote
*/
typedef random::linear_congruential<int32_t, 16807, 0, 2147483647,
1043618065> minstd_rand0;
/** The specialization \minstd_rand was suggested in
*
* @blockquote
* "Random Number Generators: Good ones are hard to find",
* Stephen K. Park and Keith W. Miller, Communications of
* the ACM, Vol. 31, No. 10, October 1988, pp. 1192-1201
* @endblockquote
*/
typedef random::linear_congruential<int32_t, 48271, 0, 2147483647,
399268537> minstd_rand;
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
/** Class @c rand48 models a \pseudo_random_number_generator. It uses
* the linear congruential algorithm with the parameters a = 0x5DEECE66D,
* c = 0xB, m = 2**48. It delivers identical results to the @c lrand48()
* function available on some systems (assuming lcong48 has not been called).
*
* It is only available on systems where @c uint64_t is provided as an
* integral type, so that for example static in-class constants and/or
* enum definitions with large @c uint64_t numbers work.
*/
class rand48
{
public:
typedef int32_t result_type;
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
static const bool has_fixed_range = true;
static const int32_t min_value = 0;
static const int32_t max_value = integer_traits<int32_t>::const_max;
#else
enum { has_fixed_range = false };
#endif
/**
* Returns the smallest value that the generator can produce
*/
int32_t min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
/**
* Returns the largest value that the generator can produce
*/
int32_t max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return std::numeric_limits<int32_t>::max BOOST_PREVENT_MACRO_SUBSTITUTION (); }
#ifdef BOOST_RANDOM_DOXYGEN
/**
* If T is an integral type smaller than int46_t, constructs
* a \rand48 generator with x(0) := (x0 << 16) | 0x330e. Otherwise
* constructs a \rand48 generator with x(0) = x0.
*/
template<class T> explicit rand48(T x0 = 1);
#else
rand48() : lcf(cnv(static_cast<int32_t>(1))) {}
template<class T> explicit rand48(T x0) : lcf(cnv(x0)) { }
#endif
template<class It> rand48(It& first, It last) : lcf(first, last) { }
// compiler-generated copy ctor and assignment operator are fine
#ifdef BOOST_RANDOM_DOXYGEN
/**
* If T is an integral type smaller than int46_t, changes
* the current value x(n) of the generator to (x0 << 16) | 0x330e.
* Otherwise changes the current value x(n) to x0.
*/
template<class T> void seed(T x0 = 1);
#else
void seed() { seed(static_cast<int32_t>(1)); }
template<class T> void seed(T x0) { lcf.seed(cnv(x0)); }
#endif
template<class It> void seed(It& first, It last) { lcf.seed(first,last); }
/**
* Returns the next value of the generator.
*/
int32_t operator()() { return static_cast<int32_t>(lcf() >> 17); }
// by experiment from lrand48()
static bool validation(int32_t x) { return x == 1993516219; }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT,class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const rand48& r)
{ os << r.lcf; return os; }
template<class CharT,class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, rand48& r)
{ is >> r.lcf; return is; }
#endif
friend bool operator==(const rand48& x, const rand48& y)
{ return x.lcf == y.lcf; }
friend bool operator!=(const rand48& x, const rand48& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const rand48& rhs) const
{ return lcf == rhs.lcf; }
bool operator!=(const rand48& rhs) const
{ return !(*this == rhs); }
#endif
private:
/// \cond hide_private_members
random::linear_congruential<uint64_t,
uint64_t(0xDEECE66DUL) | (uint64_t(0x5) << 32), // xxxxULL is not portable
0xB, uint64_t(1)<<48, /* unknown */ 0> lcf;
template<class T>
static uint64_t cnv(T x)
{
if(sizeof(T) < sizeof(uint64_t)) {
return (static_cast<uint64_t>(x) << 16) | 0x330e;
} else {
return(static_cast<uint64_t>(x));
}
}
static uint64_t cnv(float x) { return(static_cast<uint64_t>(x)); }
static uint64_t cnv(double x) { return(static_cast<uint64_t>(x)); }
static uint64_t cnv(long double x) { return(static_cast<uint64_t>(x)); }
/// \endcond
};
#endif /* !BOOST_NO_INT64_T && !BOOST_NO_INTEGRAL_INT64_T */
} // namespace boost
#include <boost/random/detail/enable_warnings.hpp>
#endif // BOOST_RANDOM_LINEAR_CONGRUENTIAL_HPP

View File

@@ -0,0 +1,160 @@
/* boost random/tausworthe.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: linear_feedback_shift.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
*/
#ifndef BOOST_RANDOM_LINEAR_FEEDBACK_SHIFT_HPP
#define BOOST_RANDOM_LINEAR_FEEDBACK_SHIFT_HPP
#include <iostream>
#include <cassert>
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/limits.hpp>
#include <boost/random/detail/config.hpp>
namespace boost {
namespace random {
/**
* Instatiation of @c linear_feedback_shift model a
* \pseudo_random_number_generator. It was originally
* proposed in
*
* @blockquote
* "Random numbers generated by linear recurrence modulo two.",
* Tausworthe, R. C.(1965), Mathematics of Computation 19, 201-209.
* @endblockquote
*/
template<class UIntType, int w, int k, int q, int s, UIntType val>
class linear_feedback_shift
{
public:
typedef UIntType result_type;
// avoid the warning trouble when using (1<<w) on 32 bit machines
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
BOOST_STATIC_CONSTANT(int, word_size = w);
BOOST_STATIC_CONSTANT(int, exponent1 = k);
BOOST_STATIC_CONSTANT(int, exponent2 = q);
BOOST_STATIC_CONSTANT(int, step_size = s);
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return wordmask; }
// MSVC 6 and possibly others crash when encountering complicated integral
// constant expressions. Avoid the checks for now.
// BOOST_STATIC_ASSERT(w > 0);
// BOOST_STATIC_ASSERT(q > 0);
// BOOST_STATIC_ASSERT(k < w);
// BOOST_STATIC_ASSERT(0 < 2*q && 2*q < k);
// BOOST_STATIC_ASSERT(0 < s && s <= k-q);
explicit linear_feedback_shift(UIntType s0 = 341) : wordmask(0)
{
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(std::numeric_limits<UIntType>::is_integer);
BOOST_STATIC_ASSERT(!std::numeric_limits<UIntType>::is_signed);
#endif
// avoid "left shift count >= with of type" warning
for(int i = 0; i < w; ++i)
wordmask |= (1u << i);
seed(s0);
}
template<class It> linear_feedback_shift(It& first, It last) : wordmask(0)
{
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(std::numeric_limits<UIntType>::is_integer);
BOOST_STATIC_ASSERT(!std::numeric_limits<UIntType>::is_signed);
#endif
// avoid "left shift count >= with of type" warning
for(int i = 0; i < w; ++i)
wordmask |= (1u << i);
seed(first, last);
}
void seed(UIntType s0 = 341) {
if(s0 < (1 << (w-k))) {
s0 += 1 << (w-k);
}
value = s0;
}
template<class It> void seed(It& first, It last)
{
if(first == last)
throw std::invalid_argument("linear_feedback_shift::seed");
value = *first++;
assert(value >= (1 << (w-k)));
}
result_type operator()()
{
const UIntType b = (((value << q) ^ value) & wordmask) >> (k-s);
const UIntType mask = ( (~static_cast<UIntType>(0)) << (w-k) ) & wordmask;
value = ((value & mask) << s) ^ b;
return value;
}
static bool validation(result_type x) { return val == x; }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, linear_feedback_shift x)
{ os << x.value; return os; }
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, linear_feedback_shift& x)
{ is >> x.value; return is; }
#endif
friend bool operator==(linear_feedback_shift x, linear_feedback_shift y)
{ return x.value == y.value; }
friend bool operator!=(linear_feedback_shift x, linear_feedback_shift y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(linear_feedback_shift rhs) const
{ return value == rhs.value; }
bool operator!=(linear_feedback_shift rhs) const
{ return !(*this == rhs); }
#endif
private:
UIntType wordmask; // avoid "left shift count >= width of type" warnings
UIntType value;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class UIntType, int w, int k, int q, int s, UIntType val>
const bool linear_feedback_shift<UIntType, w, k, q, s, val>::has_fixed_range;
template<class UIntType, int w, int k, int q, int s, UIntType val>
const int linear_feedback_shift<UIntType, w, k, q, s, val>::word_size;
template<class UIntType, int w, int k, int q, int s, UIntType val>
const int linear_feedback_shift<UIntType, w, k, q, s, val>::exponent1;
template<class UIntType, int w, int k, int q, int s, UIntType val>
const int linear_feedback_shift<UIntType, w, k, q, s, val>::exponent2;
template<class UIntType, int w, int k, int q, int s, UIntType val>
const int linear_feedback_shift<UIntType, w, k, q, s, val>::step_size;
#endif
} // namespace random
} // namespace boost
#endif // BOOST_RANDOM_LINEAR_FEEDBACK_SHIFT_HPP

View File

@@ -0,0 +1,129 @@
/* boost random/lognormal_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: lognormal_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_LOGNORMAL_DISTRIBUTION_HPP
#define BOOST_RANDOM_LOGNORMAL_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp> // std::exp, std::sqrt
#include <cassert>
#include <iostream>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/normal_distribution.hpp>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std {
using ::log;
using ::sqrt;
}
#endif
namespace boost {
#if defined(__GNUC__) && (__GNUC__ < 3)
// Special gcc workaround: gcc 2.95.x ignores using-declarations
// in template classes (confirmed by gcc author Martin v. Loewis)
using std::sqrt;
using std::exp;
#endif
/**
* Instantiations of class template lognormal_distribution model a
* \random_distribution. Such a distribution produces random numbers
* with \f$p(x) = \frac{1}{x \sigma_N \sqrt{2\pi}} e^{\frac{-\left(\log(x)-\mu_N\right)^2}{2\sigma_N^2}}\f$
* for x > 0, where \f$\mu_N = \log\left(\frac{\mu^2}{\sqrt{\sigma^2 + \mu^2}}\right)\f$ and
* \f$\sigma_N = \sqrt{\log\left(1 + \frac{\sigma^2}{\mu^2}\right)}\f$.
*/
template<class RealType = double>
class lognormal_distribution
{
public:
typedef typename normal_distribution<RealType>::input_type input_type;
typedef RealType result_type;
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
#endif
/**
* Constructs a lognormal_distribution. @c mean and @c sigma are the
* mean and standard deviation of the lognormal distribution.
*/
explicit lognormal_distribution(result_type mean_arg = result_type(1),
result_type sigma_arg = result_type(1))
: _mean(mean_arg), _sigma(sigma_arg)
{
assert(_mean > result_type(0));
init();
}
// compiler-generated copy ctor and assignment operator are fine
RealType mean() const { return _mean; }
RealType sigma() const { return _sigma; }
void reset() { _normal.reset(); }
template<class Engine>
result_type operator()(Engine& eng)
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::exp;
#endif
return exp(_normal(eng) * _nsigma + _nmean);
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const lognormal_distribution& ld)
{
os << ld._normal << " " << ld._mean << " " << ld._sigma;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, lognormal_distribution& ld)
{
is >> std::ws >> ld._normal >> std::ws >> ld._mean >> std::ws >> ld._sigma;
ld.init();
return is;
}
#endif
private:
/// \cond hide_private_members
void init()
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::exp; using std::log; using std::sqrt;
#endif
_nmean = log(_mean*_mean/sqrt(_sigma*_sigma + _mean*_mean));
_nsigma = sqrt(log(_sigma*_sigma/_mean/_mean+result_type(1)));
}
/// \endcond
RealType _mean, _sigma;
RealType _nmean, _nsigma;
normal_distribution<result_type> _normal;
};
} // namespace boost
#endif // BOOST_RANDOM_LOGNORMAL_DISTRIBUTION_HPP

View File

@@ -0,0 +1,367 @@
/* boost random/mersenne_twister.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: mersenne_twister.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_MERSENNE_TWISTER_HPP
#define BOOST_RANDOM_MERSENNE_TWISTER_HPP
#include <iostream>
#include <algorithm> // std::copy
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/integer_traits.hpp>
#include <boost/cstdint.hpp>
#include <boost/random/linear_congruential.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/ptr_helper.hpp>
#include <boost/random/detail/seed.hpp>
namespace boost {
namespace random {
/**
* Instantiations of class template mersenne_twister model a
* \pseudo_random_number_generator. It uses the algorithm described in
*
* @blockquote
* "Mersenne Twister: A 623-dimensionally equidistributed uniform
* pseudo-random number generator", Makoto Matsumoto and Takuji Nishimura,
* ACM Transactions on Modeling and Computer Simulation: Special Issue on
* Uniform Random Number Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
* @endblockquote
*
* @xmlnote
* The boost variant has been implemented from scratch and does not
* derive from or use mt19937.c provided on the above WWW site. However, it
* was verified that both produce identical output.
* @endxmlnote
*
* The seeding from an integer was changed in April 2005 to address a
* <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html">weakness</a>.
*
* The quality of the generator crucially depends on the choice of the
* parameters. User code should employ one of the sensibly parameterized
* generators such as \mt19937 instead.
*
* The generator requires considerable amounts of memory for the storage of
* its state array. For example, \mt11213b requires about 1408 bytes and
* \mt19937 requires about 2496 bytes.
*/
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
class mersenne_twister
{
public:
typedef UIntType result_type;
BOOST_STATIC_CONSTANT(int, word_size = w);
BOOST_STATIC_CONSTANT(int, state_size = n);
BOOST_STATIC_CONSTANT(int, shift_size = m);
BOOST_STATIC_CONSTANT(int, mask_bits = r);
BOOST_STATIC_CONSTANT(UIntType, parameter_a = a);
BOOST_STATIC_CONSTANT(int, output_u = u);
BOOST_STATIC_CONSTANT(int, output_s = s);
BOOST_STATIC_CONSTANT(UIntType, output_b = b);
BOOST_STATIC_CONSTANT(int, output_t = t);
BOOST_STATIC_CONSTANT(UIntType, output_c = c);
BOOST_STATIC_CONSTANT(int, output_l = l);
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
/**
* Constructs a @c mersenne_twister and calls @c seed().
*/
mersenne_twister() { seed(); }
/**
* Constructs a @c mersenne_twister and calls @c seed(value).
*/
BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(mersenne_twister, UIntType, value)
{ seed(value); }
template<class It> mersenne_twister(It& first, It last) { seed(first,last); }
/**
* Constructs a mersenne_twister and calls @c seed(gen).
*
* @xmlnote
* The copy constructor will always be preferred over
* the templated constructor.
* @endxmlnote
*/
BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(mersenne_twister, Generator, gen)
{ seed(gen); }
// compiler-generated copy ctor and assignment operator are fine
/** Calls @c seed(result_type(5489)). */
void seed() { seed(UIntType(5489)); }
/**
* Sets the state x(0) to v mod 2w. Then, iteratively,
* sets x(i) to (i + 1812433253 * (x(i-1) xor (x(i-1) rshift w-2))) mod 2<sup>w</sup>
* for i = 1 .. n-1. x(n) is the first value to be returned by operator().
*/
BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(mersenne_twister, UIntType, value)
{
// New seeding algorithm from
// http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
// In the previous versions, MSBs of the seed affected only MSBs of the
// state x[].
const UIntType mask = ~0u;
x[0] = value & mask;
for (i = 1; i < n; i++) {
// See Knuth "The Art of Computer Programming" Vol. 2, 3rd ed., page 106
x[i] = (1812433253UL * (x[i-1] ^ (x[i-1] >> (w-2))) + i) & mask;
}
}
/**
* Sets the state of this mersenne_twister to the values
* returned by n invocations of gen.
*
* Complexity: Exactly n invocations of gen.
*/
BOOST_RANDOM_DETAIL_GENERATOR_SEED(mersenne_twister, Generator, gen)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(!std::numeric_limits<result_type>::is_signed);
#endif
// I could have used std::generate_n, but it takes "gen" by value
for(int j = 0; j < n; j++)
x[j] = gen();
i = n;
}
template<class It>
void seed(It& first, It last)
{
int j;
for(j = 0; j < n && first != last; ++j, ++first)
x[j] = *first;
i = n;
if(first == last && j < n)
throw std::invalid_argument("mersenne_twister::seed");
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
// avoid "left shift count >= with of type" warning
result_type res = 0;
for(int j = 0; j < w; ++j)
res |= (1u << j);
return res;
}
result_type operator()();
static bool validation(result_type v) { return val == v; }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const mersenne_twister& mt)
{
for(int j = 0; j < mt.state_size; ++j)
os << mt.compute(j) << " ";
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, mersenne_twister& mt)
{
for(int j = 0; j < mt.state_size; ++j)
is >> mt.x[j] >> std::ws;
// MSVC (up to 7.1) and Borland (up to 5.64) don't handle the template
// value parameter "n" available from the class template scope, so use
// the static constant with the same value
mt.i = mt.state_size;
return is;
}
#endif
friend bool operator==(const mersenne_twister& x, const mersenne_twister& y)
{
for(int j = 0; j < state_size; ++j)
if(x.compute(j) != y.compute(j))
return false;
return true;
}
friend bool operator!=(const mersenne_twister& x, const mersenne_twister& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const mersenne_twister& rhs) const
{
for(int j = 0; j < state_size; ++j)
if(compute(j) != rhs.compute(j))
return false;
return true;
}
bool operator!=(const mersenne_twister& rhs) const
{ return !(*this == rhs); }
#endif
private:
/// \cond hide_private_members
// returns x(i-n+index), where index is in 0..n-1
UIntType compute(unsigned int index) const
{
// equivalent to (i-n+index) % 2n, but doesn't produce negative numbers
return x[ (i + n + index) % (2*n) ];
}
void twist(int block);
/// \endcond
// state representation: next output is o(x(i))
// x[0] ... x[k] x[k+1] ... x[n-1] x[n] ... x[2*n-1] represents
// x(i-k) ... x(i) x(i+1) ... x(i-k+n-1) x(i-k-n) ... x[i(i-k-1)]
// The goal is to always have x(i-n) ... x(i-1) available for
// operator== and save/restore.
UIntType x[2*n];
int i;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const bool mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::has_fixed_range;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const int mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::state_size;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const int mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::shift_size;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const int mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::mask_bits;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const UIntType mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::parameter_a;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const int mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::output_u;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const int mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::output_s;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const UIntType mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::output_b;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const int mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::output_t;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const UIntType mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::output_c;
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
const int mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::output_l;
#endif
/// \cond hide_private_members
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
void mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::twist(int block)
{
const UIntType upper_mask = (~0u) << r;
const UIntType lower_mask = ~upper_mask;
if(block == 0) {
for(int j = n; j < 2*n; j++) {
UIntType y = (x[j-n] & upper_mask) | (x[j-(n-1)] & lower_mask);
x[j] = x[j-(n-m)] ^ (y >> 1) ^ (y&1 ? a : 0);
}
} else if (block == 1) {
// split loop to avoid costly modulo operations
{ // extra scope for MSVC brokenness w.r.t. for scope
for(int j = 0; j < n-m; j++) {
UIntType y = (x[j+n] & upper_mask) | (x[j+n+1] & lower_mask);
x[j] = x[j+n+m] ^ (y >> 1) ^ (y&1 ? a : 0);
}
}
for(int j = n-m; j < n-1; j++) {
UIntType y = (x[j+n] & upper_mask) | (x[j+n+1] & lower_mask);
x[j] = x[j-(n-m)] ^ (y >> 1) ^ (y&1 ? a : 0);
}
// last iteration
UIntType y = (x[2*n-1] & upper_mask) | (x[0] & lower_mask);
x[n-1] = x[m-1] ^ (y >> 1) ^ (y&1 ? a : 0);
i = 0;
}
}
/// \endcond
template<class UIntType, int w, int n, int m, int r, UIntType a, int u,
int s, UIntType b, int t, UIntType c, int l, UIntType val>
inline typename mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::result_type
mersenne_twister<UIntType,w,n,m,r,a,u,s,b,t,c,l,val>::operator()()
{
if(i == n)
twist(0);
else if(i >= 2*n)
twist(1);
// Step 4
UIntType z = x[i];
++i;
z ^= (z >> u);
z ^= ((z << s) & b);
z ^= ((z << t) & c);
z ^= (z >> l);
return z;
}
} // namespace random
/**
* The specializations \mt11213b and \mt19937 are from
*
* @blockquote
* "Mersenne Twister: A 623-dimensionally equidistributed
* uniform pseudo-random number generator", Makoto Matsumoto
* and Takuji Nishimura, ACM Transactions on Modeling and
* Computer Simulation: Special Issue on Uniform Random Number
* Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
* @endblockquote
*/
typedef random::mersenne_twister<uint32_t,32,351,175,19,0xccab8ee7,11,
7,0x31b6ab00,15,0xffe50000,17, 0xa37d3c92> mt11213b;
/**
* The specializations \mt11213b and \mt19937 are from
*
* @blockquote
* "Mersenne Twister: A 623-dimensionally equidistributed
* uniform pseudo-random number generator", Makoto Matsumoto
* and Takuji Nishimura, ACM Transactions on Modeling and
* Computer Simulation: Special Issue on Uniform Random Number
* Generation, Vol. 8, No. 1, January 1998, pp. 3-30.
* @endblockquote
*/
typedef random::mersenne_twister<uint32_t,32,624,397,31,0x9908b0df,11,
7,0x9d2c5680,15,0xefc60000,18, 3346425566U> mt19937;
} // namespace boost
BOOST_RANDOM_PTR_HELPER_SPEC(boost::mt19937)
#endif // BOOST_RANDOM_MERSENNE_TWISTER_HPP

View File

@@ -0,0 +1,131 @@
/* boost random/normal_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: normal_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_NORMAL_DISTRIBUTION_HPP
#define BOOST_RANDOM_NORMAL_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <cassert>
#include <iostream>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
namespace boost {
/**
* Instantiations of class template normal_distribution model a
* \random_distribution. Such a distribution produces random numbers
* @c x distributed with probability density function
* \f$p(x) = \frac{1}{\sqrt{2\pi\sigma}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}\f$,
* where mean and sigma are the parameters of the distribution.
*/
// deterministic Box-Muller method, uses trigonometric functions
template<class RealType = double>
class normal_distribution
{
public:
typedef RealType input_type;
typedef RealType result_type;
#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) && !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300)
BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
#endif
/**
* Constructs a normal_distribution object. @c mean and @c sigma are
* the parameters for the distribution.
*
* Requires: sigma > 0
*/
explicit normal_distribution(const result_type& mean_arg = result_type(0),
const result_type& sigma_arg = result_type(1))
: _mean(mean_arg), _sigma(sigma_arg), _valid(false)
{
assert(_sigma >= result_type(0));
}
// compiler-generated copy constructor is NOT fine, need to purge cache
normal_distribution(const normal_distribution& other)
: _mean(other._mean), _sigma(other._sigma), _valid(false)
{
}
// compiler-generated copy ctor and assignment operator are fine
/**
* Returns: The "mean" parameter of the distribution.
*/
RealType mean() const { return _mean; }
/**
* Returns: The "sigma" parameter of the distribution.
*/
RealType sigma() const { return _sigma; }
void reset() { _valid = false; }
template<class Engine>
result_type operator()(Engine& eng)
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::sqrt; using std::log; using std::sin; using std::cos;
#endif
if(!_valid) {
_r1 = eng();
_r2 = eng();
_cached_rho = sqrt(-result_type(2) * log(result_type(1)-_r2));
_valid = true;
} else {
_valid = false;
}
// Can we have a boost::mathconst please?
const result_type pi = result_type(3.14159265358979323846);
return _cached_rho * (_valid ?
cos(result_type(2)*pi*_r1) :
sin(result_type(2)*pi*_r1))
* _sigma + _mean;
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const normal_distribution& nd)
{
os << nd._mean << " " << nd._sigma << " "
<< nd._valid << " " << nd._cached_rho << " " << nd._r1;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, normal_distribution& nd)
{
is >> std::ws >> nd._mean >> std::ws >> nd._sigma
>> std::ws >> nd._valid >> std::ws >> nd._cached_rho
>> std::ws >> nd._r1;
return is;
}
#endif
private:
result_type _mean, _sigma;
result_type _r1, _r2, _cached_rho;
bool _valid;
};
} // namespace boost
#endif // BOOST_RANDOM_NORMAL_DISTRIBUTION_HPP

View File

@@ -0,0 +1,116 @@
/* boost random/poisson_distribution.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: poisson_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
*/
#ifndef BOOST_RANDOM_POISSON_DISTRIBUTION_HPP
#define BOOST_RANDOM_POISSON_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <cassert>
#include <iostream>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
namespace boost {
// Knuth
/**
* An instantiation of the class template @c poisson_distribution is a
* model of \random_distribution. The poisson distribution has
* \f$p(i) = \frac{e^{-\lambda}\lambda^i}{i!}\f$
*/
template<class IntType = int, class RealType = double>
class poisson_distribution
{
public:
typedef RealType input_type;
typedef IntType result_type;
/**
* Constructs a @c poisson_distribution with the parameter @c mean.
*
* Requires: mean > 0
*/
explicit poisson_distribution(const RealType& mean_arg = RealType(1))
: _mean(mean_arg)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
BOOST_STATIC_ASSERT(std::numeric_limits<IntType>::is_integer);
BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
#endif
assert(_mean > RealType(0));
init();
}
// compiler-generated copy ctor and assignment operator are fine
/**
* Returns: the "mean" parameter of the distribution.
*/
RealType mean() const { return _mean; }
void reset() { }
template<class Engine>
result_type operator()(Engine& eng)
{
// TODO: This is O(_mean), but it should be O(log(_mean)) for large _mean
RealType product = RealType(1);
for(result_type m = 0; ; ++m) {
product *= eng();
if(product <= _exp_mean)
return m;
}
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const poisson_distribution& pd)
{
os << pd._mean;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, poisson_distribution& pd)
{
is >> std::ws >> pd._mean;
pd.init();
return is;
}
#endif
private:
/// \cond hide_private_members
void init()
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::exp;
#endif
_exp_mean = exp(-_mean);
}
/// \endcond
RealType _mean;
// some precomputed data from the parameters
RealType _exp_mean;
};
} // namespace boost
#endif // BOOST_RANDOM_POISSON_DISTRIBUTION_HPP

View File

@@ -0,0 +1,71 @@
/* boost random/random_number_generator.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: random_number_generator.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
#define BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/variate_generator.hpp>
namespace boost {
/**
* Instantiations of class template random_number_generator model a
* RandomNumberGenerator (std:25.2.11 [lib.alg.random.shuffle]). On
* each invocation, it returns a uniformly distributed integer in
* the range [0..n).
*
* The template parameter IntType shall denote some integer-like value type.
*/
template<class UniformRandomNumberGenerator, class IntType = long>
class random_number_generator
{
public:
typedef UniformRandomNumberGenerator base_type;
typedef IntType argument_type;
typedef IntType result_type;
/**
* Constructs a random_number_generator functor with the given
* \uniform_random_number_generator as the underlying source of
* random numbers.
*/
random_number_generator(base_type& rng) : _rng(rng)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(std::numeric_limits<result_type>::is_integer);
#endif
}
// compiler-generated copy ctor is fine
// assignment is disallowed because there is a reference member
/**
* Returns a value in the range [0, n)
*/
result_type operator()(argument_type n)
{
typedef uniform_int<IntType> dist_type;
return variate_generator<base_type&, dist_type>(_rng, dist_type(0, n-1))();
}
private:
base_type& _rng;
};
} // namespace boost
#endif // BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP

View File

@@ -0,0 +1,81 @@
/* boost random/ranlux.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: ranlux.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 created
*/
#ifndef BOOST_RANDOM_RANLUX_HPP
#define BOOST_RANDOM_RANLUX_HPP
#include <boost/config.hpp>
#include <boost/random/subtract_with_carry.hpp>
#include <boost/random/discard_block.hpp>
namespace boost {
namespace random {
typedef subtract_with_carry<int, (1<<24), 10, 24, 0> ranlux_base;
typedef subtract_with_carry_01<float, 24, 10, 24> ranlux_base_01;
typedef subtract_with_carry_01<double, 48, 10, 24> ranlux64_base_01;
}
namespace random {
namespace detail {
/**
* The ranlux family of generators are described in
*
* @blockquote
* "A portable high-quality random number generator for lattice field theory
* calculations", M. Luescher, Computer Physics Communications, 79 (1994)
* pp 100-110.
* @endblockquote
*
* The levels are given in
*
* @blockquote
* "RANLUX: A Fortran implementation ofthe high-quality
* pseudorandom number generator of Luescher", F. James,
* Computer Physics Communications 79 (1994) 111-114
* @endblockquote
*/
class ranlux_documentation {};
}
}
/** @copydoc boost::random::detail::ranlux_documentation */
typedef random::discard_block<random::ranlux_base, 223, 24> ranlux3;
/** @copydoc boost::random::detail::ranlux_documentation */
typedef random::discard_block<random::ranlux_base, 389, 24> ranlux4;
/** @copydoc boost::random::detail::ranlux_documentation */
typedef random::discard_block<random::ranlux_base_01, 223, 24> ranlux3_01;
/** @copydoc boost::random::detail::ranlux_documentation */
typedef random::discard_block<random::ranlux_base_01, 389, 24> ranlux4_01;
/** @copydoc boost::random::detail::ranlux_documentation */
typedef random::discard_block<random::ranlux64_base_01, 223, 24> ranlux64_3_01;
/** @copydoc boost::random::detail::ranlux_documentation */
typedef random::discard_block<random::ranlux64_base_01, 389, 24> ranlux64_4_01;
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
namespace random {
typedef random::subtract_with_carry<int64_t, (int64_t(1)<<48), 10, 24, 0> ranlux64_base;
}
/** @copydoc boost::random::detail::ranlux_documentation */
typedef random::discard_block<random::ranlux64_base, 223, 24> ranlux64_3;
/** @copydoc boost::random::detail::ranlux_documentation */
typedef random::discard_block<random::ranlux64_base, 389, 24> ranlux64_4;
#endif /* !BOOST_NO_INT64_T && !BOOST_NO_INTEGRAL_INT64_T */
} // namespace boost
#endif // BOOST_RANDOM_LINEAR_CONGRUENTIAL_HPP

View File

@@ -0,0 +1,234 @@
/* boost random/shuffle_output.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: shuffle_output.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_SHUFFLE_OUTPUT_HPP
#define BOOST_RANDOM_SHUFFLE_OUTPUT_HPP
#include <iostream>
#include <algorithm> // std::copy
#include <cassert>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/random/linear_congruential.hpp>
namespace boost {
namespace random {
/**
* Instatiations of class template shuffle_output model a
* \pseudo_random_number_generator. It mixes the output
* of some (usually \linear_congruential) \uniform_random_number_generator
* to get better statistical properties.
* The algorithm is described in
*
* @blockquote
* "Improving a poor random number generator", Carter Bays
* and S.D. Durham, ACM Transactions on Mathematical Software,
* Vol 2, No. 1, March 1976, pp. 59-64.
* http://doi.acm.org/10.1145/355666.355670
* @endblockquote
*
* The output of the base generator is buffered in an array of
* length k. Every output X(n) has a second role: It gives an
* index into the array where X(n+1) will be retrieved. Used
* array elements are replaced with fresh output from the base
* generator.
*
* Template parameters are the base generator and the array
* length k, which should be around 100. The template parameter
* val is the validation value checked by validation.
*/
template<class UniformRandomNumberGenerator, int k,
#ifndef BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
typename UniformRandomNumberGenerator::result_type
#else
uint32_t
#endif
val = 0>
class shuffle_output
{
public:
typedef UniformRandomNumberGenerator base_type;
typedef typename base_type::result_type result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
BOOST_STATIC_CONSTANT(int, buffer_size = k);
/**
* Constructs a @c shuffle_output generator by invoking the
* default constructor of the base generator.
*
* Complexity: Exactly k+1 invocations of the base generator.
*/
shuffle_output() : _rng() { init(); }
#if defined(BOOST_MSVC) && _MSC_VER < 1300
// MSVC does not implicitly generate the copy constructor here
shuffle_output(const shuffle_output & x)
: _rng(x._rng), y(x.y) { std::copy(x.v, x.v+k, v); }
#endif
/**
* Constructs a shuffle_output generator by invoking the one-argument
* constructor of the base generator with the parameter seed.
*
* Complexity: Exactly k+1 invocations of the base generator.
*/
template<class T>
explicit shuffle_output(T s) : _rng(s) { init(); }
/**
* Constructs a shuffle_output generator by using a copy
* of the provided generator.
*
* Precondition: The template argument UniformRandomNumberGenerator
* shall denote a CopyConstructible type.
*
* Complexity: Exactly k+1 invocations of the base generator.
*/
explicit shuffle_output(const base_type & rng) : _rng(rng) { init(); }
template<class It> shuffle_output(It& first, It last)
: _rng(first, last) { init(); }
void seed() { _rng.seed(); init(); }
/**
* Invokes the one-argument seed method of the base generator
* with the parameter seed and re-initializes the internal buffer array.
*
* Complexity: Exactly k+1 invocations of the base generator.
*/
template<class T>
void seed(T s) { _rng.seed(s); init(); }
template<class It> void seed(It& first, It last)
{
_rng.seed(first, last);
init();
}
const base_type& base() const { return _rng; }
result_type operator()() {
// calculating the range every time may seem wasteful. However, this
// makes the information locally available for the optimizer.
result_type range = (max)()-(min)()+1;
int j = k*(y-(min)())/range;
// assert(0 <= j && j < k);
y = v[j];
v[j] = _rng();
return y;
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (_rng.min)(); }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (_rng.max)(); }
static bool validation(result_type x) { return val == x; }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const shuffle_output& s)
{
os << s._rng << " " << s.y << " ";
for(int i = 0; i < s.buffer_size; ++i)
os << s.v[i] << " ";
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, shuffle_output& s)
{
is >> s._rng >> std::ws >> s.y >> std::ws;
for(int i = 0; i < s.buffer_size; ++i)
is >> s.v[i] >> std::ws;
return is;
}
#endif
friend bool operator==(const shuffle_output& x, const shuffle_output& y)
{ return x._rng == y._rng && x.y == y.y && std::equal(x.v, x.v+k, y.v); }
friend bool operator!=(const shuffle_output& x, const shuffle_output& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const shuffle_output& rhs) const
{ return _rng == rhs._rng && y == rhs.y && std::equal(v, v+k, rhs.v); }
bool operator!=(const shuffle_output& rhs) const
{ return !(*this == rhs); }
#endif
private:
void init()
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(std::numeric_limits<result_type>::is_integer);
#endif
result_type range = (max)()-(min)();
assert(range > 0); // otherwise there would be little choice
if(static_cast<unsigned long>(k * range) <
static_cast<unsigned long>(range)) // not a sufficient condition
// likely overflow with bucket number computation
assert(!"overflow will occur");
// we cannot use std::generate, because it uses pass-by-value for _rng
for(result_type * p = v; p != v+k; ++p)
*p = _rng();
y = _rng();
}
base_type _rng;
result_type v[k];
result_type y;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class UniformRandomNumberGenerator, int k,
#ifndef BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
typename UniformRandomNumberGenerator::result_type
#else
uint32_t
#endif
val>
const bool shuffle_output<UniformRandomNumberGenerator, k, val>::has_fixed_range;
template<class UniformRandomNumberGenerator, int k,
#ifndef BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
typename UniformRandomNumberGenerator::result_type
#else
uint32_t
#endif
val>
const int shuffle_output<UniformRandomNumberGenerator, k, val>::buffer_size;
#endif
} // namespace random
// validation by experiment from Harry Erwin's generator.h (private e-mail)
/**
* According to Harry Erwin (private e-mail), the specialization
* @c kreutzer1986 was suggested in:
*
* @blockquote
* "System Simulation: Programming Styles and Languages (International
* Computer Science Series)", Wolfgang Kreutzer, Addison-Wesley, December 1986.
* @endblockquote
*/
typedef random::shuffle_output<
random::linear_congruential<uint32_t, 1366, 150889, 714025, 0>,
97, 139726> kreutzer1986;
} // namespace boost
#endif // BOOST_RANDOM_SHUFFLE_OUTPUT_HPP

View File

@@ -0,0 +1,465 @@
/* boost random/subtract_with_carry.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: subtract_with_carry.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2002-03-02 created
*/
#ifndef BOOST_RANDOM_SUBTRACT_WITH_CARRY_HPP
#define BOOST_RANDOM_SUBTRACT_WITH_CARRY_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <iostream>
#include <algorithm> // std::equal
#include <stdexcept>
#include <boost/config/no_tr1/cmath.hpp> // std::pow
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/seed.hpp>
#include <boost/random/linear_congruential.hpp>
namespace boost {
namespace random {
#if BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292)) && BOOST_MSVC > 1300
# define BOOST_RANDOM_EXTRACT_SWC_01
#endif
#if defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ <= 3)
# define BOOST_RANDOM_EXTRACT_SWC_01
#endif
# ifdef BOOST_RANDOM_EXTRACT_SWC_01
namespace detail
{
template <class IStream, class SubtractWithCarry, class RealType>
void extract_subtract_with_carry_01(
IStream& is
, SubtractWithCarry& f
, RealType& carry
, RealType* x
, RealType modulus)
{
RealType value;
for(unsigned int j = 0; j < f.long_lag; ++j) {
is >> value >> std::ws;
x[j] = value / modulus;
}
is >> value >> std::ws;
carry = value / modulus;
}
}
# endif
/**
* Instantiations of @c subtract_with_carry model a
* \pseudo_random_number_generator. The algorithm is
* described in
*
* @blockquote
* "A New Class of Random Number Generators", George
* Marsaglia and Arif Zaman, Annals of Applied Probability,
* Volume 1, Number 3 (1991), 462-480.
* @endblockquote
*/
template<class IntType, IntType m, unsigned int s, unsigned int r,
IntType val>
class subtract_with_carry
{
public:
typedef IntType result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = true);
BOOST_STATIC_CONSTANT(result_type, min_value = 0);
BOOST_STATIC_CONSTANT(result_type, max_value = m-1);
BOOST_STATIC_CONSTANT(result_type, modulus = m);
BOOST_STATIC_CONSTANT(unsigned int, long_lag = r);
BOOST_STATIC_CONSTANT(unsigned int, short_lag = s);
subtract_with_carry() {
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(std::numeric_limits<result_type>::is_signed);
BOOST_STATIC_ASSERT(std::numeric_limits<result_type>::is_integer);
#endif
seed();
}
BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(subtract_with_carry, uint32_t, value)
{ seed(value); }
BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(subtract_with_carry, Generator, gen)
{ seed(gen); }
template<class It> subtract_with_carry(It& first, It last) { seed(first,last); }
// compiler-generated copy ctor and assignment operator are fine
void seed() { seed(19780503u); }
BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(subtract_with_carry, uint32_t, value)
{
random::linear_congruential<int32_t, 40014, 0, 2147483563, 0> intgen(value);
seed(intgen);
}
// For GCC, moving this function out-of-line prevents inlining, which may
// reduce overall object code size. However, MSVC does not grok
// out-of-line template member functions.
BOOST_RANDOM_DETAIL_GENERATOR_SEED(subtract_with_carry, Generator, gen)
{
// I could have used std::generate_n, but it takes "gen" by value
for(unsigned int j = 0; j < long_lag; ++j)
x[j] = gen() % modulus;
carry = (x[long_lag-1] == 0);
k = 0;
}
template<class It>
void seed(It& first, It last)
{
unsigned int j;
for(j = 0; j < long_lag && first != last; ++j, ++first)
x[j] = *first % modulus;
if(first == last && j < long_lag)
throw std::invalid_argument("subtract_with_carry::seed");
carry = (x[long_lag-1] == 0);
k = 0;
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return min_value; }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return max_value; }
result_type operator()()
{
int short_index = k - short_lag;
if(short_index < 0)
short_index += long_lag;
IntType delta;
if (x[short_index] >= x[k] + carry) {
// x(n) >= 0
delta = x[short_index] - (x[k] + carry);
carry = 0;
} else {
// x(n) < 0
delta = modulus - x[k] - carry + x[short_index];
carry = 1;
}
x[k] = delta;
++k;
if(k >= long_lag)
k = 0;
return delta;
}
public:
static bool validation(result_type x) { return x == val; }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os,
const subtract_with_carry& f)
{
for(unsigned int j = 0; j < f.long_lag; ++j)
os << f.compute(j) << " ";
os << f.carry << " ";
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, subtract_with_carry& f)
{
for(unsigned int j = 0; j < f.long_lag; ++j)
is >> f.x[j] >> std::ws;
is >> f.carry >> std::ws;
f.k = 0;
return is;
}
#endif
friend bool operator==(const subtract_with_carry& x, const subtract_with_carry& y)
{
for(unsigned int j = 0; j < r; ++j)
if(x.compute(j) != y.compute(j))
return false;
return true;
}
friend bool operator!=(const subtract_with_carry& x, const subtract_with_carry& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const subtract_with_carry& rhs) const
{
for(unsigned int j = 0; j < r; ++j)
if(compute(j) != rhs.compute(j))
return false;
return true;
}
bool operator!=(const subtract_with_carry& rhs) const
{ return !(*this == rhs); }
#endif
private:
/// \cond hide_private_members
// returns x(i-r+index), where index is in 0..r-1
IntType compute(unsigned int index) const
{
return x[(k+index) % long_lag];
}
/// \endcond
// state representation; next output (state) is x(i)
// x[0] ... x[k] x[k+1] ... x[long_lag-1] represents
// x(i-k) ... x(i) x(i+1) ... x(i-k+long_lag-1)
// speed: base: 20-25 nsec
// ranlux_4: 230 nsec, ranlux_7: 430 nsec, ranlux_14: 810 nsec
// This state representation makes operator== and save/restore more
// difficult, because we've already computed "too much" and thus
// have to undo some steps to get at x(i-r) etc.
// state representation: next output (state) is x(i)
// x[0] ... x[k] x[k+1] ... x[long_lag-1] represents
// x(i-k) ... x(i) x(i-long_lag+1) ... x(i-k-1)
// speed: base 28 nsec
// ranlux_4: 370 nsec, ranlux_7: 688 nsec, ranlux_14: 1343 nsec
IntType x[long_lag];
unsigned int k;
int carry;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class IntType, IntType m, unsigned int s, unsigned int r, IntType val>
const bool subtract_with_carry<IntType, m, s, r, val>::has_fixed_range;
template<class IntType, IntType m, unsigned int s, unsigned int r, IntType val>
const IntType subtract_with_carry<IntType, m, s, r, val>::min_value;
template<class IntType, IntType m, unsigned int s, unsigned int r, IntType val>
const IntType subtract_with_carry<IntType, m, s, r, val>::max_value;
template<class IntType, IntType m, unsigned int s, unsigned int r, IntType val>
const IntType subtract_with_carry<IntType, m, s, r, val>::modulus;
template<class IntType, IntType m, unsigned int s, unsigned int r, IntType val>
const unsigned int subtract_with_carry<IntType, m, s, r, val>::long_lag;
template<class IntType, IntType m, unsigned int s, unsigned int r, IntType val>
const unsigned int subtract_with_carry<IntType, m, s, r, val>::short_lag;
#endif
// use a floating-point representation to produce values in [0..1)
/** @copydoc boost::random::subtract_with_carry */
template<class RealType, int w, unsigned int s, unsigned int r, int val=0>
class subtract_with_carry_01
{
public:
typedef RealType result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
BOOST_STATIC_CONSTANT(int, word_size = w);
BOOST_STATIC_CONSTANT(unsigned int, long_lag = r);
BOOST_STATIC_CONSTANT(unsigned int, short_lag = s);
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(!std::numeric_limits<result_type>::is_integer);
#endif
subtract_with_carry_01() { init_modulus(); seed(); }
explicit subtract_with_carry_01(uint32_t value)
{ init_modulus(); seed(value); }
template<class It> subtract_with_carry_01(It& first, It last)
{ init_modulus(); seed(first,last); }
private:
/// \cond hide_private_members
void init_modulus()
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::pow;
#endif
_modulus = pow(RealType(2), word_size);
}
/// \endcond hide_private_members
public:
// compiler-generated copy ctor and assignment operator are fine
void seed(uint32_t value = 19780503u)
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::fmod;
#endif
random::linear_congruential<int32_t, 40014, 0, 2147483563, 0> gen(value);
unsigned long array[(w+31)/32 * long_lag];
for(unsigned int j = 0; j < sizeof(array)/sizeof(unsigned long); ++j)
array[j] = gen();
unsigned long * start = array;
seed(start, array + sizeof(array)/sizeof(unsigned long));
}
template<class It>
void seed(It& first, It last)
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::fmod;
using std::pow;
#endif
unsigned long mask = ~((~0u) << (w%32)); // now lowest (w%32) bits set
RealType two32 = pow(RealType(2), 32);
unsigned int j;
for(j = 0; j < long_lag && first != last; ++j) {
x[j] = RealType(0);
for(int i = 0; i < w/32 && first != last; ++i, ++first)
x[j] += *first / pow(two32,i+1);
if(first != last && mask != 0) {
x[j] += fmod((*first & mask) / _modulus, RealType(1));
++first;
}
}
if(first == last && j < long_lag)
throw std::invalid_argument("subtract_with_carry_01::seed");
carry = (x[long_lag-1] ? 0 : 1 / _modulus);
k = 0;
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(0); }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(1); }
result_type operator()()
{
int short_index = k - short_lag;
if(short_index < 0)
short_index += long_lag;
RealType delta = x[short_index] - x[k] - carry;
if(delta < 0) {
delta += RealType(1);
carry = RealType(1)/_modulus;
} else {
carry = 0;
}
x[k] = delta;
++k;
if(k >= long_lag)
k = 0;
return delta;
}
static bool validation(result_type x)
{ return x == val/pow(RealType(2), word_size); }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os,
const subtract_with_carry_01& f)
{
#ifndef BOOST_NO_STDC_NAMESPACE
// allow for Koenig lookup
using std::pow;
#endif
std::ios_base::fmtflags oldflags = os.flags(os.dec | os.fixed | os.left);
for(unsigned int j = 0; j < f.long_lag; ++j)
os << (f.compute(j) * f._modulus) << " ";
os << (f.carry * f._modulus);
os.flags(oldflags);
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, subtract_with_carry_01& f)
{
# ifdef BOOST_RANDOM_EXTRACT_SWC_01
detail::extract_subtract_with_carry_01(is, f, f.carry, f.x, f._modulus);
# else
// MSVC (up to 7.1) and Borland (up to 5.64) don't handle the template type
// parameter "RealType" available from the class template scope, so use
// the member typedef
typename subtract_with_carry_01::result_type value;
for(unsigned int j = 0; j < long_lag; ++j) {
is >> value >> std::ws;
f.x[j] = value / f._modulus;
}
is >> value >> std::ws;
f.carry = value / f._modulus;
# endif
f.k = 0;
return is;
}
#endif
friend bool operator==(const subtract_with_carry_01& x,
const subtract_with_carry_01& y)
{
for(unsigned int j = 0; j < r; ++j)
if(x.compute(j) != y.compute(j))
return false;
return true;
}
friend bool operator!=(const subtract_with_carry_01& x,
const subtract_with_carry_01& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const subtract_with_carry_01& rhs) const
{
for(unsigned int j = 0; j < r; ++j)
if(compute(j) != rhs.compute(j))
return false;
return true;
}
bool operator!=(const subtract_with_carry_01& rhs) const
{ return !(*this == rhs); }
#endif
private:
/// \cond hide_private_members
RealType compute(unsigned int index) const;
/// \endcond
unsigned int k;
RealType carry;
RealType x[long_lag];
RealType _modulus;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class RealType, int w, unsigned int s, unsigned int r, int val>
const bool subtract_with_carry_01<RealType, w, s, r, val>::has_fixed_range;
template<class RealType, int w, unsigned int s, unsigned int r, int val>
const int subtract_with_carry_01<RealType, w, s, r, val>::word_size;
template<class RealType, int w, unsigned int s, unsigned int r, int val>
const unsigned int subtract_with_carry_01<RealType, w, s, r, val>::long_lag;
template<class RealType, int w, unsigned int s, unsigned int r, int val>
const unsigned int subtract_with_carry_01<RealType, w, s, r, val>::short_lag;
#endif
/// \cond hide_private_members
template<class RealType, int w, unsigned int s, unsigned int r, int val>
RealType subtract_with_carry_01<RealType, w, s, r, val>::compute(unsigned int index) const
{
return x[(k+index) % long_lag];
}
/// \endcond
} // namespace random
} // namespace boost
#endif // BOOST_RANDOM_SUBTRACT_WITH_CARRY_HPP

View File

@@ -0,0 +1,118 @@
/* boost random/triangle_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: triangle_distribution.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_TRIANGLE_DISTRIBUTION_HPP
#define BOOST_RANDOM_TRIANGLE_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <cassert>
#include <boost/random/detail/config.hpp>
#include <boost/random/uniform_01.hpp>
namespace boost {
/**
* Instantiations of @c triangle_distribution model a \random_distribution.
* A @c triangle_distribution has three parameters, @c a, @c b, and @c c,
* which are the smallest, the most probable and the largest values of
* the distribution respectively.
*/
template<class RealType = double>
class triangle_distribution
{
public:
typedef RealType input_type;
typedef RealType result_type;
/**
* Constructs a @c triangle_distribution with the parameters
* @c a, @c b, and @c c.
*
* Preconditions: a <= b <= c.
*/
explicit triangle_distribution(result_type a_arg = result_type(0),
result_type b_arg = result_type(0.5),
result_type c_arg = result_type(1))
: _a(a_arg), _b(b_arg), _c(c_arg)
{
assert(_a <= _b && _b <= _c);
init();
}
// compiler-generated copy ctor and assignment operator are fine
/** Returns the @c a parameter of the distribution */
result_type a() const { return _a; }
/** Returns the @c b parameter of the distribution */
result_type b() const { return _b; }
/** Returns the @c c parameter of the distribution */
result_type c() const { return _c; }
void reset() { }
template<class Engine>
result_type operator()(Engine& eng)
{
#ifndef BOOST_NO_STDC_NAMESPACE
using std::sqrt;
#endif
result_type u = eng();
if( u <= q1 )
return _a + p1*sqrt(u);
else
return _c - d3*sqrt(d2*u-d1);
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const triangle_distribution& td)
{
os << td._a << " " << td._b << " " << td._c;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, triangle_distribution& td)
{
is >> std::ws >> td._a >> std::ws >> td._b >> std::ws >> td._c;
td.init();
return is;
}
#endif
private:
/// \cond hide_private_members
void init()
{
#ifndef BOOST_NO_STDC_NAMESPACE
using std::sqrt;
#endif
d1 = _b - _a;
d2 = _c - _a;
d3 = sqrt(_c - _b);
q1 = d1 / d2;
p1 = sqrt(d1 * d2);
}
/// \endcond
result_type _a, _b, _c;
result_type d1, d2, d3, q1, p1;
};
} // namespace boost
#endif // BOOST_RANDOM_TRIANGLE_DISTRIBUTION_HPP

View File

@@ -0,0 +1,273 @@
/* boost random/uniform_01.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: uniform_01.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_UNIFORM_01_HPP
#define BOOST_RANDOM_UNIFORM_01_HPP
#include <iostream>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/pass_through_engine.hpp>
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
#ifdef BOOST_RANDOM_DOXYGEN
/**
* The distribution function uniform_01 models a \random_distribution.
* On each invocation, it returns a random floating-point value
* uniformly distributed in the range [0..1).
*
* The template parameter RealType shall denote a float-like value type
* with support for binary operators +, -, and /.
*
* Note: The current implementation is buggy, because it may not fill
* all of the mantissa with random bits. I'm unsure how to fill a
* (to-be-invented) @c boost::bigfloat class with random bits efficiently.
* It's probably time for a traits class.
*/
template<class RealType = double>
class uniform_01
{
public:
typedef RealType input_type;
typedef RealType result_type;
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const;
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const;
void reset();
template<class Engine>
result_type operator()(Engine& eng);
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const new_uniform_01&)
{
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, new_uniform_01&)
{
return is;
}
#endif
};
#else
namespace detail {
template<class RealType>
class new_uniform_01
{
public:
typedef RealType input_type;
typedef RealType result_type;
// compiler-generated copy ctor and copy assignment are fine
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(0); }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(1); }
void reset() { }
template<class Engine>
result_type operator()(Engine& eng) {
for (;;) {
typedef typename Engine::result_type base_result;
result_type factor = result_type(1) /
(result_type((eng.max)()-(eng.min)()) +
result_type(std::numeric_limits<base_result>::is_integer ? 1 : 0));
result_type result = result_type(eng() - (eng.min)()) * factor;
if (result < result_type(1))
return result;
}
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const new_uniform_01&)
{
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, new_uniform_01&)
{
return is;
}
#endif
};
template<class UniformRandomNumberGenerator, class RealType>
class backward_compatible_uniform_01
{
typedef boost::random::detail::ptr_helper<UniformRandomNumberGenerator> traits;
typedef boost::random::detail::pass_through_engine<UniformRandomNumberGenerator> internal_engine_type;
public:
typedef UniformRandomNumberGenerator base_type;
typedef RealType result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) && !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300)
BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
#endif
explicit backward_compatible_uniform_01(typename traits::rvalue_type rng)
: _rng(rng),
_factor(result_type(1) /
(result_type((_rng.max)()-(_rng.min)()) +
result_type(std::numeric_limits<base_result>::is_integer ? 1 : 0)))
{
}
// compiler-generated copy ctor and copy assignment are fine
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(0); }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(1); }
typename traits::value_type& base() { return _rng.base(); }
const typename traits::value_type& base() const { return _rng.base(); }
void reset() { }
result_type operator()() {
for (;;) {
result_type result = result_type(_rng() - (_rng.min)()) * _factor;
if (result < result_type(1))
return result;
}
}
#if !defined(BOOST_NO_OPERATORS_IN_NAMESPACE) && !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const backward_compatible_uniform_01& u)
{
os << u._rng;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, backward_compatible_uniform_01& u)
{
is >> u._rng;
return is;
}
#endif
private:
typedef typename internal_engine_type::result_type base_result;
internal_engine_type _rng;
result_type _factor;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class UniformRandomNumberGenerator, class RealType>
const bool backward_compatible_uniform_01<UniformRandomNumberGenerator, RealType>::has_fixed_range;
#endif
template<class UniformRandomNumberGenerator>
struct select_uniform_01
{
template<class RealType>
struct apply
{
typedef backward_compatible_uniform_01<UniformRandomNumberGenerator, RealType> type;
};
};
template<>
struct select_uniform_01<float>
{
template<class RealType>
struct apply
{
typedef new_uniform_01<float> type;
};
};
template<>
struct select_uniform_01<double>
{
template<class RealType>
struct apply
{
typedef new_uniform_01<double> type;
};
};
template<>
struct select_uniform_01<long double>
{
template<class RealType>
struct apply
{
typedef new_uniform_01<long double> type;
};
};
}
// Because it is so commonly used: uniform distribution on the real [0..1)
// range. This allows for specializations to avoid a costly int -> float
// conversion plus float multiplication
template<class UniformRandomNumberGenerator = double, class RealType = double>
class uniform_01
: public detail::select_uniform_01<UniformRandomNumberGenerator>::BOOST_NESTED_TEMPLATE apply<RealType>::type
{
typedef typename detail::select_uniform_01<UniformRandomNumberGenerator>::BOOST_NESTED_TEMPLATE apply<RealType>::type impl_type;
typedef boost::random::detail::ptr_helper<UniformRandomNumberGenerator> traits;
public:
uniform_01() {}
explicit uniform_01(typename traits::rvalue_type rng)
: impl_type(rng)
{
}
#if !defined(BOOST_NO_OPERATORS_IN_NAMESPACE) && !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_01& u)
{
os << static_cast<const impl_type&>(u);
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, uniform_01& u)
{
is >> static_cast<impl_type&>(u);
return is;
}
#endif
};
#endif
} // namespace boost
#include <boost/random/detail/enable_warnings.hpp>
#endif // BOOST_RANDOM_UNIFORM_01_HPP

View File

@@ -0,0 +1,300 @@
/* boost random/uniform_int.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: uniform_int.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-04-08 added min<max assertion (N. Becker)
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_UNIFORM_INT_HPP
#define BOOST_RANDOM_UNIFORM_INT_HPP
#include <cassert>
#include <iostream>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/signed_unsigned_tools.hpp>
#include <boost/type_traits/make_unsigned.hpp>
namespace boost {
/**
* The distribution function uniform_int models a \random_distribution.
* On each invocation, it returns a random integer value uniformly
* distributed in the set of integer numbers {min, min+1, min+2, ..., max}.
*
* The template parameter IntType shall denote an integer-like value type.
*/
template<class IntType = int>
class uniform_int
{
public:
typedef IntType input_type;
typedef IntType result_type;
/// \cond hide_private_members
typedef typename make_unsigned<result_type>::type range_type;
/// \endcond
/**
* Constructs a uniform_int object. @c min and @c max are
* the parameters of the distribution.
*
* Requires: min <= max
*/
explicit uniform_int(IntType min_arg = 0, IntType max_arg = 9)
: _min(min_arg), _max(max_arg)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
BOOST_STATIC_ASSERT(std::numeric_limits<IntType>::is_integer);
#endif
assert(min_arg <= max_arg);
init();
}
/**
* Returns: The "min" parameter of the distribution
*/
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
/**
* Returns: The "max" parameter of the distribution
*/
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
void reset() { }
// can't have member function templates out-of-line due to MSVC bugs
template<class Engine>
result_type operator()(Engine& eng)
{
return generate(eng, _min, _max, _range);
}
template<class Engine>
result_type operator()(Engine& eng, result_type n)
{
assert(n > 0);
if (n == 1)
{
return 0;
}
return generate(eng, 0, n - 1, n - 1);
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_int& ud)
{
os << ud._min << " " << ud._max;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, uniform_int& ud)
{
is >> std::ws >> ud._min >> std::ws >> ud._max;
ud.init();
return is;
}
#endif
private:
#ifdef BOOST_MSVC
#pragma warning(push)
// disable division by zero warning, since we can't
// actually divide by zero.
#pragma warning(disable:4723)
#endif
/// \cond hide_private_members
template<class Engine>
static result_type generate(Engine& eng, result_type min_value, result_type /*max_value*/, range_type range)
{
typedef typename Engine::result_type base_result;
// ranges are always unsigned
typedef typename make_unsigned<base_result>::type base_unsigned;
const base_result bmin = (eng.min)();
const base_unsigned brange =
random::detail::subtract<base_result>()((eng.max)(), (eng.min)());
if(range == 0) {
return min_value;
} else if(brange == range) {
// this will probably never happen in real life
// basically nothing to do; just take care we don't overflow / underflow
base_unsigned v = random::detail::subtract<base_result>()(eng(), bmin);
return random::detail::add<base_unsigned, result_type>()(v, min_value);
} else if(brange < range) {
// use rejection method to handle things like 0..3 --> 0..4
for(;;) {
// concatenate several invocations of the base RNG
// take extra care to avoid overflows
// limit == floor((range+1)/(brange+1))
// Therefore limit*(brange+1) <= range+1
range_type limit;
if(range == (std::numeric_limits<range_type>::max)()) {
limit = range/(range_type(brange)+1);
if(range % (range_type(brange)+1) == range_type(brange))
++limit;
} else {
limit = (range+1)/(range_type(brange)+1);
}
// We consider "result" as expressed to base (brange+1):
// For every power of (brange+1), we determine a random factor
range_type result = range_type(0);
range_type mult = range_type(1);
// loop invariants:
// result < mult
// mult <= range
while(mult <= limit) {
// Postcondition: result <= range, thus no overflow
//
// limit*(brange+1)<=range+1 def. of limit (1)
// eng()-bmin<=brange eng() post. (2)
// and mult<=limit. loop condition (3)
// Therefore mult*(eng()-bmin+1)<=range+1 by (1),(2),(3) (4)
// Therefore mult*(eng()-bmin)+mult<=range+1 rearranging (4) (5)
// result<mult loop invariant (6)
// Therefore result+mult*(eng()-bmin)<range+1 by (5), (6) (7)
//
// Postcondition: result < mult*(brange+1)
//
// result<mult loop invariant (1)
// eng()-bmin<=brange eng() post. (2)
// Therefore result+mult*(eng()-bmin) <
// mult+mult*(eng()-bmin) by (1) (3)
// Therefore result+(eng()-bmin)*mult <
// mult+mult*brange by (2), (3) (4)
// Therefore result+(eng()-bmin)*mult <
// mult*(brange+1) by (4)
result += static_cast<range_type>(random::detail::subtract<base_result>()(eng(), bmin) * mult);
// equivalent to (mult * (brange+1)) == range+1, but avoids overflow.
if(mult * range_type(brange) == range - mult + 1) {
// The destination range is an integer power of
// the generator's range.
return(result);
}
// Postcondition: mult <= range
//
// limit*(brange+1)<=range+1 def. of limit (1)
// mult<=limit loop condition (2)
// Therefore mult*(brange+1)<=range+1 by (1), (2) (3)
// mult*(brange+1)!=range+1 preceding if (4)
// Therefore mult*(brange+1)<range+1 by (3), (4) (5)
//
// Postcondition: result < mult
//
// See the second postcondition on the change to result.
mult *= range_type(brange)+range_type(1);
}
// loop postcondition: range/mult < brange+1
//
// mult > limit loop condition (1)
// Suppose range/mult >= brange+1 Assumption (2)
// range >= mult*(brange+1) by (2) (3)
// range+1 > mult*(brange+1) by (3) (4)
// range+1 > (limit+1)*(brange+1) by (1), (4) (5)
// (range+1)/(brange+1) > limit+1 by (5) (6)
// limit < floor((range+1)/(brange+1)) by (6) (7)
// limit==floor((range+1)/(brange+1)) def. of limit (8)
// not (2) reductio (9)
//
// loop postcondition: (range/mult)*mult+(mult-1) >= range
//
// (range/mult)*mult + range%mult == range identity (1)
// range%mult < mult def. of % (2)
// (range/mult)*mult+mult > range by (1), (2) (3)
// (range/mult)*mult+(mult-1) >= range by (3) (4)
//
// Note that the maximum value of result at this point is (mult-1),
// so after this final step, we generate numbers that can be
// at least as large as range. We have to really careful to avoid
// overflow in this final addition and in the rejection. Anything
// that overflows is larger than range and can thus be rejected.
// range/mult < brange+1 -> no endless loop
range_type result_increment = uniform_int<range_type>(0, range/mult)(eng);
if((std::numeric_limits<range_type>::max)() / mult < result_increment) {
// The multiplcation would overflow. Reject immediately.
continue;
}
result_increment *= mult;
// unsigned integers are guaranteed to wrap on overflow.
result += result_increment;
if(result < result_increment) {
// The addition overflowed. Reject.
continue;
}
if(result > range) {
// Too big. Reject.
continue;
}
return random::detail::add<range_type, result_type>()(result, min_value);
}
} else { // brange > range
base_unsigned bucket_size;
// it's safe to add 1 to range, as long as we cast it first,
// because we know that it is less than brange. However,
// we do need to be careful not to cause overflow by adding 1
// to brange.
if(brange == (std::numeric_limits<base_unsigned>::max)()) {
bucket_size = brange / (static_cast<base_unsigned>(range)+1);
if(brange % (static_cast<base_unsigned>(range)+1) == static_cast<base_unsigned>(range)) {
++bucket_size;
}
} else {
bucket_size = (brange+1) / (static_cast<base_unsigned>(range)+1);
}
for(;;) {
base_unsigned result =
random::detail::subtract<base_result>()(eng(), bmin);
result /= bucket_size;
// result and range are non-negative, and result is possibly larger
// than range, so the cast is safe
if(result <= static_cast<base_unsigned>(range))
return random::detail::add<base_unsigned, result_type>()(result, min_value);
}
}
}
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
void init()
{
_range = random::detail::subtract<result_type>()(_max, _min);
}
/// \endcond
// The result_type may be signed or unsigned, but the _range is always
// unsigned.
result_type _min, _max;
range_type _range;
};
} // namespace boost
#endif // BOOST_RANDOM_UNIFORM_INT_HPP

View File

@@ -0,0 +1,101 @@
/* boost random/uniform_on_sphere.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: uniform_on_sphere.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_UNIFORM_ON_SPHERE_HPP
#define BOOST_RANDOM_UNIFORM_ON_SPHERE_HPP
#include <vector>
#include <algorithm> // std::transform
#include <functional> // std::bind2nd, std::divides
#include <boost/random/detail/config.hpp>
#include <boost/random/normal_distribution.hpp>
namespace boost {
/**
* Instantiations of class template uniform_on_sphere model a
* \random_distribution. Such a distribution produces random
* numbers uniformly distributed on the unit sphere of arbitrary
* dimension @c dim. The @c Cont template parameter must be a STL-like
* container type with begin and end operations returning non-const
* ForwardIterators of type @c Cont::iterator. Each invocation of the
* @c UniformRandomNumberGenerator shall result in a floating-point
* value in the range [0,1).
*/
template<class RealType = double, class Cont = std::vector<RealType> >
class uniform_on_sphere
{
public:
typedef RealType input_type;
typedef Cont result_type;
/**
* Constructs a @c uniform_on_sphere distribution.
* @c dim is the dimension of the sphere.
*/
explicit uniform_on_sphere(int dim = 2) : _container(dim), _dim(dim) { }
// compiler-generated copy ctor and assignment operator are fine
void reset() { _normal.reset(); }
template<class Engine>
const result_type & operator()(Engine& eng)
{
RealType sqsum = 0;
for(typename Cont::iterator it = _container.begin();
it != _container.end();
++it) {
RealType val = _normal(eng);
*it = val;
sqsum += val * val;
}
#ifndef BOOST_NO_STDC_NAMESPACE
using std::sqrt;
#endif
// for all i: result[i] /= sqrt(sqsum)
std::transform(_container.begin(), _container.end(), _container.begin(),
std::bind2nd(std::divides<RealType>(), sqrt(sqsum)));
return _container;
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_on_sphere& sd)
{
os << sd._dim;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, uniform_on_sphere& sd)
{
is >> std::ws >> sd._dim;
sd._container.resize(sd._dim);
return is;
}
#endif
private:
normal_distribution<RealType> _normal;
result_type _container;
int _dim;
};
} // namespace boost
#endif // BOOST_RANDOM_UNIFORM_ON_SPHERE_HPP

View File

@@ -0,0 +1,108 @@
/* boost random/uniform_real.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: uniform_real.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-04-08 added min<max assertion (N. Becker)
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_UNIFORM_REAL_HPP
#define BOOST_RANDOM_UNIFORM_REAL_HPP
#include <cassert>
#include <iostream>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
namespace boost {
/**
* The distribution function uniform_real models a random distribution.
* On each invocation, it returns a random floating-point value uniformly
* distributed in the range [min..max). The value is computed using
* std::numeric_limits<RealType>::digits random binary digits, i.e.
* the mantissa of the floating-point value is completely filled with
* random bits.
*
* Note: The current implementation is buggy, because it may not fill
* all of the mantissa with random bits.
*/
template<class RealType = double>
class uniform_real
{
public:
typedef RealType input_type;
typedef RealType result_type;
/**
* Constructs a uniform_real object. @c min and @c max are the
* parameters of the distribution.
*
* Requires: min <= max
*/
explicit uniform_real(RealType min_arg = RealType(0),
RealType max_arg = RealType(1))
: _min(min_arg), _max(max_arg)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
#endif
assert(min_arg <= max_arg);
}
// compiler-generated copy ctor and assignment operator are fine
/**
* Returns: The "min" parameter of the distribution
*/
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
/**
* Returns: The "max" parameter of the distribution
*/
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
void reset() { }
template<class Engine>
result_type operator()(Engine& eng) {
result_type numerator = static_cast<result_type>(eng() - eng.min BOOST_PREVENT_MACRO_SUBSTITUTION());
result_type divisor = static_cast<result_type>(eng.max BOOST_PREVENT_MACRO_SUBSTITUTION() - eng.min BOOST_PREVENT_MACRO_SUBSTITUTION());
assert(divisor > 0);
assert(numerator >= 0 && numerator <= divisor);
return numerator / divisor * (_max - _min) + _min;
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_real& ud)
{
os << ud._min << " " << ud._max;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, uniform_real& ud)
{
is >> std::ws >> ud._min >> std::ws >> ud._max;
return is;
}
#endif
private:
RealType _min, _max;
};
} // namespace boost
#endif // BOOST_RANDOM_UNIFORM_REAL_HPP

View File

@@ -0,0 +1,158 @@
/* boost random/uniform_smallint.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: uniform_smallint.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
* Revision history
* 2001-04-08 added min<max assertion (N. Becker)
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_UNIFORM_SMALLINT_HPP
#define BOOST_RANDOM_UNIFORM_SMALLINT_HPP
#include <cassert>
#include <iostream>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/detail/workaround.hpp>
namespace boost {
// uniform integer distribution on a small range [min, max]
/**
* The distribution function uniform_smallint models a \random_distribution.
* On each invocation, it returns a random integer value uniformly distributed
* in the set of integer numbers {min, min+1, min+2, ..., max}. It assumes
* that the desired range (max-min+1) is small compared to the range of the
* underlying source of random numbers and thus makes no attempt to limit
* quantization errors.
*
* Let r<sub>out</sub>=(max-min+1) the desired range of integer numbers, and
* let r<sub>base</sub> be the range of the underlying source of random
* numbers. Then, for the uniform distribution, the theoretical probability
* for any number i in the range r<sub>out</sub> will be p<sub>out</sub>(i) =
* 1/r<sub>out</sub>. Likewise, assume a uniform distribution on r<sub>base</sub> for
* the underlying source of random numbers, i.e. p<sub>base</sub>(i) =
* 1/r<sub>base</sub>. Let p<sub>out_s</sub>(i) denote the random
* distribution generated by @c uniform_smallint. Then the sum over all
* i in r<sub>out</sub> of (p<sub>out_s</sub>(i)/p<sub>out</sub>(i) - 1)<sup>2</sup>
* shall not exceed r<sub>out</sub>/r<sub>base</sub><sup>2</sup>
* (r<sub>base</sub> mod r<sub>out</sub>)(r<sub>out</sub> -
* r<sub>base</sub> mod r<sub>out</sub>).
*
* The template parameter IntType shall denote an integer-like value type.
*
* Note: The property above is the square sum of the relative differences
* in probabilities between the desired uniform distribution
* p<sub>out</sub>(i) and the generated distribution p<sub>out_s</sub>(i).
* The property can be fulfilled with the calculation
* (base_rng mod r<sub>out</sub>), as follows: Let r = r<sub>base</sub> mod
* r<sub>out</sub>. The base distribution on r<sub>base</sub> is folded onto the
* range r<sub>out</sub>. The numbers i < r have assigned (r<sub>base</sub>
* div r<sub>out</sub>)+1 numbers of the base distribution, the rest has
* only (r<sub>base</sub> div r<sub>out</sub>). Therefore,
* p<sub>out_s</sub>(i) = ((r<sub>base</sub> div r<sub>out</sub>)+1) /
* r<sub>base</sub> for i < r and p<sub>out_s</sub>(i) = (r<sub>base</sub>
* div r<sub>out</sub>)/r<sub>base</sub> otherwise. Substituting this in the
* above sum formula leads to the desired result.
*
* Note: The upper bound for (r<sub>base</sub> mod r<sub>out</sub>)
* (r<sub>out</sub> - r<sub>base</sub> mod r<sub>out</sub>) is
* r<sub>out</sub><sup>2</sup>/4. Regarding the upper bound for the
* square sum of the relative quantization error of
* r<sub>out</sub><sup>3</sup>/(4*r<sub>base</sub><sup>2</sup>), it
* seems wise to either choose r<sub>base</sub> so that r<sub>base</sub> >
* 10*r<sub>out</sub><sup>2</sup> or ensure that r<sub>base</sub> is
* divisible by r<sub>out</sub>.
*/
template<class IntType = int>
class uniform_smallint
{
public:
typedef IntType input_type;
typedef IntType result_type;
/**
* Constructs a @c uniform_smallint. @c min and @c max are the
* lower and upper bounds of the output range, respectively.
*/
explicit uniform_smallint(IntType min_arg = 0, IntType max_arg = 9)
: _min(min_arg), _max(max_arg)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
BOOST_STATIC_ASSERT(std::numeric_limits<IntType>::is_integer);
#endif
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
void reset() { }
template<class Engine>
result_type operator()(Engine& eng)
{
typedef typename Engine::result_type base_result;
base_result _range = static_cast<base_result>(_max-_min)+1;
base_result _factor = 1;
// LCGs get bad when only taking the low bits.
// (probably put this logic into a partial template specialization)
// Check how many low bits we can ignore before we get too much
// quantization error.
base_result r_base = (eng.max)() - (eng.min)();
if(r_base == (std::numeric_limits<base_result>::max)()) {
_factor = 2;
r_base /= 2;
}
r_base += 1;
if(r_base % _range == 0) {
// No quantization effects, good
_factor = r_base / _range;
} else {
// carefully avoid overflow; pessimizing here
for( ; r_base/_range/32 >= _range; _factor *= 2)
r_base /= 2;
}
return static_cast<result_type>(((eng() - (eng.min)()) / _factor) % _range + _min);
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_smallint& ud)
{
os << ud._min << " " << ud._max;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, uniform_smallint& ud)
{
is >> std::ws >> ud._min >> std::ws >> ud._max;
return is;
}
#endif
private:
result_type _min;
result_type _max;
};
} // namespace boost
#endif // BOOST_RANDOM_UNIFORM_SMALLINT_HPP

View File

@@ -0,0 +1,220 @@
/* boost random/variate_generator.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: variate_generator.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
*/
#ifndef BOOST_RANDOM_RANDOM_GENERATOR_HPP
#define BOOST_RANDOM_RANDOM_GENERATOR_HPP
#include <boost/config.hpp>
// implementation details
#include <boost/detail/workaround.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/detail/pass_through_engine.hpp>
#include <boost/random/detail/uniform_int_float.hpp>
#include <boost/random/detail/ptr_helper.hpp>
// Borland C++ 5.6.0 has problems using its numeric_limits traits as
// template parameters
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x564)
#include <boost/type_traits/is_integral.hpp>
#endif
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
/// \cond hide_private_members
namespace random {
namespace detail {
template<bool have_int, bool want_int>
struct engine_helper;
// for consistency, always have two levels of decorations
template<>
struct engine_helper<true, true>
{
template<class Engine, class DistInputType>
struct impl
{
typedef pass_through_engine<Engine> type;
};
};
template<>
struct engine_helper<false, false>
{
template<class Engine, class DistInputType>
struct impl
{
typedef uniform_01<Engine, DistInputType> type;
};
};
template<>
struct engine_helper<true, false>
{
template<class Engine, class DistInputType>
struct impl
{
typedef uniform_01<Engine, DistInputType> type;
};
};
template<>
struct engine_helper<false, true>
{
template<class Engine, class DistInputType>
struct impl
{
typedef uniform_int_float<Engine, unsigned long> type;
};
};
} // namespace detail
} // namespace random
///\endcond
/**
* A random variate generator is used to join a random number
* generator together with a random number distribution.
* Boost.Random provides a vast choice of \generators as well
* as \distributions.
*
* Instantations of class template @c variate_generator model
* a \number_generator.
*
* The argument for the template parameter Engine shall be of
* the form U, U&, or U*, where U models a
* \uniform_random_number_generator. Then, the member
* engine_value_type names U (not the pointer or reference to U).
*
* Specializations of @c variate_generator satisfy the
* requirements of CopyConstructible. They also satisfy the
* requirements of Assignable unless the template parameter
* Engine is of the form U&.
*
* The complexity of all functions specified in this section
* is constant. No function described in this section except
* the constructor throws an exception.
*/
template<class Engine, class Distribution>
class variate_generator
{
private:
typedef random::detail::pass_through_engine<Engine> decorated_engine;
public:
typedef typename decorated_engine::base_type engine_value_type;
typedef Engine engine_type;
typedef Distribution distribution_type;
typedef typename Distribution::result_type result_type;
/**
* Constructs a @c variate_generator object with the associated
* \uniform_random_number_generator eng and the associated
* \random_distribution d.
*
* Throws: If and what the copy constructor of Engine or
* Distribution throws.
*/
variate_generator(Engine e, Distribution d)
: _eng(decorated_engine(e)), _dist(d) { }
/**
* Returns: distribution()(e)
*
* Notes: The sequence of numbers produced by the
* \uniform_random_number_generator e, s<sub>e</sub>, is
* obtained from the sequence of numbers produced by the
* associated \uniform_random_number_generator eng, s<sub>eng</sub>,
* as follows: Consider the values of @c numeric_limits<T>::is_integer
* for @c T both @c Distribution::input_type and
* @c engine_value_type::result_type. If the values for both types are
* true, then se is identical to s<sub>eng</sub>. Otherwise, if the
* values for both types are false, then the numbers in s<sub>eng</sub>
* are divided by engine().max()-engine().min() to obtain the numbers
* in s<sub>e</sub>. Otherwise, if the value for
* @c engine_value_type::result_type is true and the value for
* @c Distribution::input_type is false, then the numbers in s<sub>eng</sub>
* are divided by engine().max()-engine().min()+1 to obtain the numbers in
* s<sub>e</sub>. Otherwise, the mapping from s<sub>eng</sub> to
* s<sub>e</sub> is implementation-defined. In all cases, an
* implicit conversion from @c engine_value_type::result_type to
* @c Distribution::input_type is performed. If such a conversion does
* not exist, the program is ill-formed.
*/
result_type operator()() { return _dist(_eng); }
/**
* Returns: distribution()(e, value).
* For the semantics of e, see the description of operator()().
*/
template<class T>
result_type operator()(T value) { return _dist(_eng, value); }
/**
* Returns: A reference to the associated uniform random number generator.
*/
engine_value_type& engine() { return _eng.base().base(); }
/**
* Returns: A reference to the associated uniform random number generator.
*/
const engine_value_type& engine() const { return _eng.base().base(); }
/**
* Returns: A reference to the associated random distribution.
*/
distribution_type& distribution() { return _dist; }
/**
* Returns: A reference to the associated random distribution.
*/
const distribution_type& distribution() const { return _dist; }
/**
* Precondition: distribution().min() is well-formed
*
* Returns: distribution().min()
*/
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (distribution().min)(); }
/**
* Precondition: distribution().max() is well-formed
*
* Returns: distribution().max()
*/
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (distribution().max)(); }
private:
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x564)
typedef typename random::detail::engine_helper<
::boost::is_integral<typename decorated_engine::result_type>::value,
::boost::is_integral<typename Distribution::input_type>::value
>::BOOST_NESTED_TEMPLATE impl<decorated_engine, typename Distribution::input_type>::type internal_engine_type;
#else
enum {
have_int = std::numeric_limits<typename decorated_engine::result_type>::is_integer,
want_int = std::numeric_limits<typename Distribution::input_type>::is_integer
};
typedef typename random::detail::engine_helper<have_int, want_int>::BOOST_NESTED_TEMPLATE impl<decorated_engine, typename Distribution::input_type>::type internal_engine_type;
#endif
internal_engine_type _eng;
distribution_type _dist;
};
} // namespace boost
#include <boost/random/detail/disable_warnings.hpp>
#endif // BOOST_RANDOM_RANDOM_GENERATOR_HPP

View File

@@ -0,0 +1,184 @@
/* boost random/xor_combine.hpp header file
*
* Copyright Jens Maurer 2002
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: xor_combine.hpp 60755 2010-03-22 00:45:06Z steven_watanabe $
*
*/
#ifndef BOOST_RANDOM_XOR_COMBINE_HPP
#define BOOST_RANDOM_XOR_COMBINE_HPP
#include <iostream>
#include <cassert>
#include <algorithm> // for std::min and std::max
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp> // uint32_t
#include <boost/random/detail/config.hpp>
namespace boost {
namespace random {
/// \cond hide_private_members
#ifndef BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
#define BOOST_RANDOM_VAL_TYPE typename URNG1::result_type
#else
#define BOOST_RANDOM_VAL_TYPE uint32_t
#endif
/// \endcond
/**
* Instantiations of @c xor_combine model a \pseudo_random_number_generator.
* To produce its output it invokes each of the base generators, shifts
* their results and xors them together.
*/
template<class URNG1, int s1, class URNG2, int s2
#ifndef BOOST_RANDOM_DOXYGEN
, BOOST_RANDOM_VAL_TYPE val = 0
#endif
>
class xor_combine
{
public:
typedef URNG1 base1_type;
typedef URNG2 base2_type;
typedef typename base1_type::result_type result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
BOOST_STATIC_CONSTANT(int, shift1 = s1);
BOOST_STATIC_CONSTANT(int, shift2 = s2);
/**
* Constructors a @c xor_combine by default constructing
* both base generators.
*/
xor_combine() : _rng1(), _rng2()
{ }
/**
* Constructs a @c xor_combine by copying two base generators.
*/
xor_combine(const base1_type & rng1, const base2_type & rng2)
: _rng1(rng1), _rng2(rng2) { }
/**
* Constructs a @c xor_combine, seeding both base generators
* with @c v.
*/
xor_combine(const result_type & v)
: _rng1(v), _rng2(v) { }
/**
* Constructs a @c xor_combine, seeding both base generators
* with values from the iterator range [first, last) and changes
* first to point to the element after the last one used. If there
* are not enough elements in the range to seed both generators,
* throws @c std::invalid_argument.
*/
template<class It> xor_combine(It& first, It last)
: _rng1(first, last), _rng2( /* advanced by other call */ first, last) { }
/**
* Calls @c seed() for both base generators.
*/
void seed() { _rng1.seed(); _rng2.seed(); }
/**
* @c seeds both base generators with @c v.
*/
void seed(const result_type & v) { _rng1.seed(v); _rng2.seed(v); }
/**
* seeds both base generators with values from the iterator
* range [first, last) and changes first to point to the element
* after the last one used. If there are not enough elements in
* the range to seed both generators, throws @c std::invalid_argument.
*/
template<class It> void seed(It& first, It last)
{
_rng1.seed(first, last);
_rng2.seed(first, last);
}
/** Returns the first base generator. */
const base1_type& base1() { return _rng1; }
/** Returns the second base generator. */
const base2_type& base2() { return _rng2; }
/** Returns the next value of the generator. */
result_type operator()()
{
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) && !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300)
BOOST_STATIC_ASSERT(std::numeric_limits<typename base1_type::result_type>::is_integer);
BOOST_STATIC_ASSERT(std::numeric_limits<typename base2_type::result_type>::is_integer);
BOOST_STATIC_ASSERT(std::numeric_limits<typename base1_type::result_type>::digits >= std::numeric_limits<typename base2_type::result_type>::digits);
#endif
return (_rng1() << s1) ^ (_rng2() << s2);
}
/**
* Returns the smallest value that the generator can produce.
*/
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return std::min BOOST_PREVENT_MACRO_SUBSTITUTION((_rng1.min)(), (_rng2.min)()); }
/**
* Returns the largest value that the generator can produce.
*/
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return std::max BOOST_PREVENT_MACRO_SUBSTITUTION((_rng1.min)(), (_rng2.max)()); }
static bool validation(result_type x) { return val == x; }
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const xor_combine& s)
{
os << s._rng1 << " " << s._rng2 << " ";
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, xor_combine& s)
{
is >> s._rng1 >> std::ws >> s._rng2 >> std::ws;
return is;
}
#endif
friend bool operator==(const xor_combine& x, const xor_combine& y)
{ return x._rng1 == y._rng1 && x._rng2 == y._rng2; }
friend bool operator!=(const xor_combine& x, const xor_combine& y)
{ return !(x == y); }
#else
// Use a member function; Streamable concept not supported.
bool operator==(const xor_combine& rhs) const
{ return _rng1 == rhs._rng1 && _rng2 == rhs._rng2; }
bool operator!=(const xor_combine& rhs) const
{ return !(*this == rhs); }
#endif
private:
base1_type _rng1;
base2_type _rng2;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class URNG1, int s1, class URNG2, int s2, BOOST_RANDOM_VAL_TYPE val>
const bool xor_combine<URNG1, s1, URNG2, s2, val>::has_fixed_range;
template<class URNG1, int s1, class URNG2, int s2, BOOST_RANDOM_VAL_TYPE val>
const int xor_combine<URNG1, s1, URNG2, s2, val>::shift1;
template<class URNG1, int s1, class URNG2, int s2, BOOST_RANDOM_VAL_TYPE val>
const int xor_combine<URNG1, s1, URNG2, s2, val>::shift2;
#endif
#undef BOOST_RANDOM_VAL_TYPE
} // namespace random
} // namespace boost
#endif // BOOST_RANDOM_XOR_COMBINE_HPP

View File

@@ -0,0 +1,125 @@
// Boost name_generator.hpp header file ----------------------------------------------//
// Copyright 2010 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_UUID_NAME_GENERATOR_HPP
#define BOOST_UUID_NAME_GENERATOR_HPP
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/sha1.hpp>
#include <boost/assert.hpp>
#include <string>
#include <cstring> // for strlen, wcslen
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std {
using ::strlen;
using ::wcslen;
} //namespace std
#endif //BOOST_NO_STDC_NAMESPACE
namespace boost {
namespace uuids {
// generate a name-based uuid
// TODO: add in common namesspace uuids
class name_generator {
public:
typedef uuid result_type;
explicit name_generator(uuid const& namespace_uuid)
: namespace_uuid(namespace_uuid)
{}
uuid operator()(const char* name) {
reset();
process_characters(name, std::strlen(name));
return sha_to_uuid();
}
uuid operator()(const wchar_t* name) {
reset();
process_characters(name, std::wcslen(name));
return sha_to_uuid();
}
template <typename ch, typename char_traits, typename alloc>
uuid operator()(std::basic_string<ch, char_traits, alloc> const& name) {
reset();
process_characters(name.c_str(), name.length());
return sha_to_uuid();
}
uuid operator()(void const* buffer, std::size_t byte_count) {
reset();
sha.process_bytes(buffer, byte_count);
return sha_to_uuid();
};
private:
// we convert all characters to uint32_t so that each
// character is 4 bytes reguardless of sizeof(char) or
// sizeof(wchar_t). We want the name string on any
// platform / compiler to generate the same uuid
// except for char
template <typename char_type>
void process_characters(char_type const*const characters, size_t count) {
BOOST_ASSERT(sizeof(uint32_t) >= sizeof(char_type));
for (size_t i=0; i<count; i++) {
uint32_t c = characters[i];
sha.process_byte( (c >> 0) && 0xFF );
sha.process_byte( (c >> 8) && 0xFF );
sha.process_byte( (c >> 16) && 0xFF );
sha.process_byte( (c >> 24) && 0xFF );
}
}
void process_characters(char const*const characters, size_t count) {
sha.process_bytes(characters, count);
}
void reset()
{
sha.reset();
sha.process_bytes(namespace_uuid.begin(), namespace_uuid.size());
}
uuid sha_to_uuid()
{
unsigned int digest[5];
sha.get_digest(digest);
uuid u;
for (int i=0; i<4; ++i) {
*(u.begin() + i*4+0) = ((digest[i] >> 24) & 0xFF);
*(u.begin() + i*4+1) = ((digest[i] >> 16) & 0xFF);
*(u.begin() + i*4+2) = ((digest[i] >> 8) & 0xFF);
*(u.begin() + i*4+3) = ((digest[i] >> 0) & 0xFF);
}
// set variant
// must be 0b10xxxxxx
*(u.begin()+8) &= 0xBF;
*(u.begin()+8) |= 0x80;
// set version
// must be 0b0101xxxx
*(u.begin()+6) &= 0x5F; //0b01011111
*(u.begin()+6) |= 0x50; //0b01010000
return u;
}
private:
uuid namespace_uuid;
detail::sha1 sha;
};
}} // namespace boost::uuids
#endif // BOOST_UUID_NAME_GENERATOR_HPP

View File

@@ -0,0 +1,34 @@
// Boost nil_generator.hpp header file ----------------------------------------------//
// Copyright 2010 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_UUID_NIL_GENERATOR_HPP
#define BOOST_UUID_NIL_GENERATOR_HPP
#include <boost/uuid/uuid.hpp>
namespace boost {
namespace uuids {
// generate a nil uuid
struct nil_generator {
typedef uuid result_type;
uuid operator()() const {
// initialize to all zeros
uuid u = {{0}};
return u;
}
};
inline uuid nil_uuid() {
return nil_generator()();
}
}} // namespace boost::uuids
#endif // BOOST_UUID_NIL_GENERATOR_HPP

View File

@@ -0,0 +1,118 @@
// Boost random_generator.hpp header file ----------------------------------------------//
// Copyright 2010 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_UUID_RANDOM_GENERATOR_HPP
#define BOOST_UUID_RANDOM_GENERATOR_HPP
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/seed_rng.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <limits>
namespace boost {
namespace uuids {
// generate a random-based uuid
template <typename UniformRandomNumberGenerator>
class basic_random_generator {
private:
typedef uniform_int<unsigned long> distribution_type;
typedef variate_generator<UniformRandomNumberGenerator*, distribution_type> generator_type;
struct null_deleter
{
void operator()(void const *) const {}
};
public:
typedef uuid result_type;
// default constructor creates the random number generator
basic_random_generator()
: pURNG(new UniformRandomNumberGenerator)
, generator
( pURNG.get()
, distribution_type
( (std::numeric_limits<unsigned long>::min)()
, (std::numeric_limits<unsigned long>::max)()
)
)
{
// seed the random number generator
detail::seed(*pURNG);
}
// keep a reference to a random number generator
// don't seed a given random number generator
explicit basic_random_generator(UniformRandomNumberGenerator& gen)
: pURNG(&gen, null_deleter())
, generator
( pURNG.get()
, distribution_type
( (std::numeric_limits<unsigned long>::min)()
, (std::numeric_limits<unsigned long>::max)()
)
)
{}
// keep a pointer to a random number generator
// don't seed a given random number generator
explicit basic_random_generator(UniformRandomNumberGenerator* pGen)
: pURNG(pGen, null_deleter())
, generator
( pURNG.get()
, distribution_type
( (std::numeric_limits<unsigned long>::min)()
, (std::numeric_limits<unsigned long>::max)()
)
)
{
BOOST_ASSERT(pURNG);
}
uuid operator()()
{
uuid u;
int i=0;
unsigned long random_value = generator();
for (uuid::iterator it=u.begin(); it!=u.end(); ++it, ++i) {
if (i==sizeof(unsigned long)) {
random_value = generator();
i = 0;
}
*it = ((random_value >> (i*8)) & 0xFF);
}
// set variant
// must be 0b10xxxxxx
*(u.begin()+8) &= 0xBF;
*(u.begin()+8) |= 0x80;
// set version
// must be 0b0100xxxx
*(u.begin()+6) &= 0x4F; //0b01001111
*(u.begin()+6) |= 0x40; //0b01000000
return u;
}
private:
shared_ptr<UniformRandomNumberGenerator> pURNG;
generator_type generator;
};
typedef basic_random_generator<mt19937> random_generator;
}} // namespace boost::uuids
#endif //BOOST_UUID_RANDOM_GENERATOR_HPP

View File

@@ -0,0 +1,262 @@
// Boost seed_rng.hpp header file ----------------------------------------------//
// Copyright 2007 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Revision History
// 09 Nov 2007 - Initial Revision
// 25 Feb 2008 - moved to namespace boost::uuids::detail
// 28 Nov 2009 - disabled deprecated warnings for MSVC
// seed_rng models a UniformRandomNumberGenerator (see Boost.Random).
// Random number generators are hard to seed well. This is intended to provide
// good seed values for random number generators.
// It creates random numbers from a sha1 hash of data from a variary of sources,
// all of which are standard function calls. It produces random numbers slowly.
// Peter Dimov provided the details of sha1_random_digest_().
// see http://archives.free.net.ph/message/20070507.175609.4c4f503a.en.html
#ifndef BOOST_UUID_SEED_RNG_HPP
#define BOOST_UUID_SEED_RNG_HPP
#include <boost/config.hpp>
#include <cstring> // for memcpy
#include <limits>
#include <memory.h>
#include <ctime> // for time_t, time, clock_t, clock
#include <cstdlib> // for rand
#include <cstdio> // for FILE, fopen, fread, fclose
#include <boost/uuid/sha1.hpp>
//#include <boost/nondet_random.hpp> //forward declare boost::random_device
// can't use boost::generator_iterator since boost::random number seed(Iter&, Iter)
// functions need a last iterator
//#include <boost/generator_iterator.hpp>
# include <boost/iterator/iterator_facade.hpp>
#if defined(_MSC_VER)
#pragma warning(push) // Save warning settings.
#pragma warning(disable : 4996) // Disable deprecated std::fopen
#endif
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std {
using ::memcpy;
using ::time_t;
using ::time;
using ::clock_t;
using ::clock;
using ::rand;
using ::FILE;
using ::fopen;
using ::fread;
using ::fclose;
} //namespace std
#endif
// forward declare random number generators
namespace boost {
class random_device;
} //namespace boost
namespace boost {
namespace uuids {
namespace detail {
// should this be part of Boost.Random?
class seed_rng
{
public:
typedef unsigned int result_type;
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
//BOOST_STATIC_CONSTANT(unsigned int, min_value = 0);
//BOOST_STATIC_CONSTANT(unsigned int, max_value = UINT_MAX);
public:
// note: rd_ intentionally left uninitialized
seed_rng()
: rd_index_(5)
, random_(std::fopen( "/dev/urandom", "rb" ))
{}
~seed_rng()
{
if (random_) {
std::fclose(random_);
}
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return (std::numeric_limits<result_type>::min)();
}
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return (std::numeric_limits<result_type>::max)();
}
result_type operator()()
{
if (rd_index_ >= 5) {
//get new digest
sha1_random_digest_();
rd_index_ = 0;
}
return rd_[rd_index_++];
}
private:
static unsigned int * sha1_random_digest_state_()
{
// intentionally left uninitialized
static unsigned int state[ 5 ];
return state;
}
void sha1_random_digest_()
{
boost::uuids::detail::sha1 sha;
unsigned int * ps = sha1_random_digest_state_();
unsigned int state[ 5 ];
std::memcpy( state, ps, sizeof( state ) ); // harmless data race
sha.process_bytes( (unsigned char const*)state, sizeof( state ) );
sha.process_bytes( (unsigned char const*)&ps, sizeof( ps ) );
{
std::time_t tm = std::time( 0 );
sha.process_bytes( (unsigned char const*)&tm, sizeof( tm ) );
}
{
std::clock_t ck = std::clock();
sha.process_bytes( (unsigned char const*)&ck, sizeof( ck ) );
}
{
unsigned int rn[] = { std::rand(), std::rand(), std::rand() };
sha.process_bytes( (unsigned char const*)rn, sizeof( rn ) );
}
{
// intentionally left uninitialized
unsigned char buffer[ 20 ];
if(random_)
{
std::fread( buffer, 1, 20, random_ );
}
// using an uninitialized buffer[] if fopen fails
// intentional, we rely on its contents being random
sha.process_bytes( buffer, sizeof( buffer ) );
}
{
// *p is intentionally left uninitialized
unsigned int * p = new unsigned int;
sha.process_bytes( (unsigned char const*)p, sizeof( *p ) );
sha.process_bytes( (unsigned char const*)&p, sizeof( p ) );
delete p;
}
sha.process_bytes( (unsigned char const*)rd_, sizeof( rd_ ) );
unsigned int digest[ 5 ];
sha.get_digest( digest );
for( int i = 0; i < 5; ++i )
{
// harmless data race
ps[ i ] ^= digest[ i ];
rd_[ i ] ^= digest[ i ];
}
}
private:
unsigned int rd_[5];
int rd_index_;
std::FILE * random_;
private: // make seed_rng noncopyable
seed_rng(seed_rng const&);
seed_rng& operator=(seed_rng const&);
};
// almost a copy of boost::generator_iterator
// but default constructor sets m_g to NULL
template <class Generator>
class generator_iterator
: public iterator_facade<
generator_iterator<Generator>
, typename Generator::result_type
, single_pass_traversal_tag
, typename Generator::result_type const&
>
{
typedef iterator_facade<
generator_iterator<Generator>
, typename Generator::result_type
, single_pass_traversal_tag
, typename Generator::result_type const&
> super_t;
public:
generator_iterator() : m_g(NULL) {}
generator_iterator(Generator* g) : m_g(g), m_value((*m_g)()) {}
void increment()
{
m_value = (*m_g)();
}
const typename Generator::result_type&
dereference() const
{
return m_value;
}
bool equal(generator_iterator const& y) const
{
return this->m_g == y.m_g && this->m_value == y.m_value;
}
private:
Generator* m_g;
typename Generator::result_type m_value;
};
// seed() seeds a random number generator with good seed values
template <typename UniformRandomNumberGenerator>
inline void seed(UniformRandomNumberGenerator& rng)
{
seed_rng seed_gen;
generator_iterator<seed_rng> begin(&seed_gen);
generator_iterator<seed_rng> end;
rng.seed(begin, end);
}
// random_device does not / can not be seeded
template <>
inline void seed<boost::random_device>(boost::random_device&) {}
// random_device does not / can not be seeded
template <>
inline void seed<seed_rng>(seed_rng&) {}
}}} //namespace boost::uuids::detail
#if defined(_MSC_VER)
#pragma warning(pop) // Restore warnings to previous state.
#endif
#endif

208
Boost/boost/uuid/sha1.hpp Normal file
View File

@@ -0,0 +1,208 @@
// boost/uuid/sha1.hpp header file ----------------------------------------------//
// Copyright 2007 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Revision History
// 29 May 2007 - Initial Revision
// 25 Feb 2008 - moved to namespace boost::uuids::detail
// This is a byte oriented implementation
// Note: this implementation does not handle message longer than
// 2^32 bytes.
#ifndef BOOST_UUID_SHA1_H
#define BOOST_UUID_SHA1_H
#include <boost/static_assert.hpp>
#include <cstddef>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std {
using ::size_t;
} // namespace std
#endif
namespace boost {
namespace uuids {
namespace detail {
BOOST_STATIC_ASSERT(sizeof(unsigned char)*8 == 8);
BOOST_STATIC_ASSERT(sizeof(unsigned int)*8 == 32);
inline unsigned int left_rotate(unsigned int x, std::size_t n)
{
return (x<<n) ^ (x>> (32-n));
}
class sha1
{
public:
typedef unsigned int(&digest_type)[5];
public:
sha1();
void reset();
void process_byte(unsigned char byte);
void process_block(void const* bytes_begin, void const* bytes_end);
void process_bytes(void const* buffer, std::size_t byte_count);
void get_digest(digest_type digest);
private:
void process_block();
private:
unsigned int h_[5];
unsigned char block_[64];
std::size_t block_byte_index_;
std::size_t byte_count_;
};
inline sha1::sha1()
{
reset();
}
inline void sha1::reset()
{
h_[0] = 0x67452301;
h_[1] = 0xEFCDAB89;
h_[2] = 0x98BADCFE;
h_[3] = 0x10325476;
h_[4] = 0xC3D2E1F0;
block_byte_index_ = 0;
byte_count_ = 0;
}
inline void sha1::process_byte(unsigned char byte)
{
block_[block_byte_index_++] = byte;
++byte_count_;
if (block_byte_index_ == 64) {
block_byte_index_ = 0;
process_block();
}
}
inline void sha1::process_block(void const* bytes_begin, void const* bytes_end)
{
unsigned char const* begin = static_cast<unsigned char const*>(bytes_begin);
unsigned char const* end = static_cast<unsigned char const*>(bytes_end);
for(; begin != end; ++begin) {
process_byte(*begin);
}
}
inline void sha1::process_bytes(void const* buffer, std::size_t byte_count)
{
unsigned char const* b = static_cast<unsigned char const*>(buffer);
process_block(b, b+byte_count);
}
inline void sha1::process_block()
{
unsigned int w[80];
for (std::size_t i=0; i<16; ++i) {
w[i] = (block_[i*4 + 0] << 24);
w[i] |= (block_[i*4 + 1] << 16);
w[i] |= (block_[i*4 + 2] << 8);
w[i] |= (block_[i*4 + 3]);
}
for (std::size_t i=16; i<80; ++i) {
w[i] = left_rotate((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1);
}
unsigned int a = h_[0];
unsigned int b = h_[1];
unsigned int c = h_[2];
unsigned int d = h_[3];
unsigned int e = h_[4];
for (std::size_t i=0; i<80; ++i) {
unsigned int f;
unsigned int k;
if (i<20) {
f = (b & c) | (~b & d);
k = 0x5A827999;
} else if (i<40) {
f = b ^ c ^ d;
k = 0x6ED9EBA1;
} else if (i<60) {
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDC;
} else {
f = b ^ c ^ d;
k = 0xCA62C1D6;
}
unsigned temp = left_rotate(a, 5) + f + e + k + w[i];
e = d;
d = c;
c = left_rotate(b, 30);
b = a;
a = temp;
}
h_[0] += a;
h_[1] += b;
h_[2] += c;
h_[3] += d;
h_[4] += e;
}
inline void sha1::get_digest(digest_type digest)
{
std::size_t bit_count = byte_count_*8;
// append the bit '1' to the message
process_byte(0x80);
// append k bits '0', where k is the minimum number >= 0
// such that the resulting message length is congruent to 56 (mod 64)
// check if there is enough space for padding and bit_count
if (block_byte_index_ > 56) {
// finish this block
while (block_byte_index_ != 0) {
process_byte(0);
}
// one more block
while (block_byte_index_ < 56) {
process_byte(0);
}
} else {
while (block_byte_index_ < 56) {
process_byte(0);
}
}
// append length of message (before pre-processing)
// as a 64-bit big-endian integer
process_byte(0);
process_byte(0);
process_byte(0);
process_byte(0);
process_byte( static_cast<unsigned char>((bit_count>>24) & 0xFF));
process_byte( static_cast<unsigned char>((bit_count>>16) & 0xFF));
process_byte( static_cast<unsigned char>((bit_count>>8 ) & 0xFF));
process_byte( static_cast<unsigned char>((bit_count) & 0xFF));
// get final digest
digest[0] = h_[0];
digest[1] = h_[1];
digest[2] = h_[2];
digest[3] = h_[3];
digest[4] = h_[4];
}
}}} // namespace boost::uuids::detail
#endif

View File

@@ -0,0 +1,184 @@
// Boost string_generator.hpp header file ----------------------------------------------//
// Copyright 2010 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_UUID_STRING_GENERATOR_HPP
#define BOOST_UUID_STRING_GENERATOR_HPP
#include <boost/uuid/uuid.hpp>
#include <string>
#include <cstring> // for strlen, wcslen
#include <iterator>
#include <algorithm> // for find
#include <stdexcept>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std {
using ::strlen;
using ::wcslen;
} //namespace std
#endif //BOOST_NO_STDC_NAMESPACE
namespace boost {
namespace uuids {
// generate a uuid from a string
// lexical_cast works fine using uuid_io.hpp
// but this generator should accept more forms
// and be more efficient
// would like to accept the following forms:
// 0123456789abcdef0123456789abcdef
// 01234567-89ab-cdef-0123456789abcdef
// {01234567-89ab-cdef-0123456789abcdef}
// {0123456789abcdef0123456789abcdef}
// others?
struct string_generator {
typedef uuid result_type;
template <typename ch, typename char_traits, typename alloc>
uuid operator()(std::basic_string<ch, char_traits, alloc> const& s) const {
return operator()(s.begin(), s.end());
};
uuid operator()(char const*const s) const {
return operator()(s, s+std::strlen(s));
}
uuid operator()(wchar_t const*const s) const {
return operator()(s, s+std::wcslen(s));
}
template <typename CharIterator>
uuid operator()(CharIterator begin, CharIterator end) const
{
typedef typename std::iterator_traits<CharIterator>::value_type char_type;
// check open brace
char_type c = get_next_char(begin, end);
bool has_open_brace = is_open_brace(c);
char_type open_brace_char = c;
if (has_open_brace) {
c = get_next_char(begin, end);
}
bool has_dashes = false;
uuid u;
int i=0;
for (uuid::iterator it_byte=u.begin(); it_byte!=u.end(); ++it_byte, ++i) {
if (it_byte != u.begin()) {
c = get_next_char(begin, end);
}
if (i == 4) {
has_dashes = is_dash(c);
if (has_dashes) {
c = get_next_char(begin, end);
}
}
if (has_dashes) {
if (i == 6 || i == 8 || i == 10) {
if (is_dash(c)) {
c = get_next_char(begin, end);
} else {
throw_invalid();
}
}
}
*it_byte = get_value(c);
c = get_next_char(begin, end);
*it_byte <<= 4;
*it_byte |= get_value(c);
}
// check close brace
if (has_open_brace) {
c = get_next_char(begin, end);
check_close_brace(c, open_brace_char);
}
return u;
}
private:
template <typename CharIterator>
typename std::iterator_traits<CharIterator>::value_type
get_next_char(CharIterator& begin, CharIterator end) const {
if (begin == end) {
throw_invalid();
}
return *begin++;
}
unsigned char get_value(char c) const {
static char const*const digits_begin = "0123456789abcdefABCDEF";
static char const*const digits_end = digits_begin + 22;
static unsigned char const values[] =
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15
, static_cast<unsigned char>(-1) };
char const* d = std::find(digits_begin, digits_end, c);
return values[d - digits_begin];
}
unsigned char get_value(wchar_t c) const {
static wchar_t const*const digits_begin = L"0123456789abcdefABCDEF";
static wchar_t const*const digits_end = digits_begin + 22;
static unsigned char const values[] =
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15
, static_cast<unsigned char>(-1) };
wchar_t const* d = std::find(digits_begin, digits_end, c);
return values[d - digits_begin];
}
bool is_dash(char c) const {
return c == '-';
}
bool is_dash(wchar_t c) const {
return c == L'-';
}
// return closing brace
bool is_open_brace(char c) const {
return (c == '{');
}
bool is_open_brace(wchar_t c) const {
return (c == L'{');
}
void check_close_brace(char c, char open_brace) const {
if (open_brace == '{' && c == '}') {
//great
} else {
throw_invalid();
}
}
void check_close_brace(wchar_t c, wchar_t open_brace) const {
if (open_brace == L'{' && c == L'}') {
// great
} else {
throw_invalid();
}
}
void throw_invalid() const {
throw std::runtime_error("invalid uuid string");
}
};
}} // namespace boost::uuids
#endif //BOOST_UUID_STRING_GENERATOR_HPP

221
Boost/boost/uuid/uuid.hpp Normal file
View File

@@ -0,0 +1,221 @@
// Boost uuid.hpp header file ----------------------------------------------//
// Copyright 2006 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Revision History
// 06 Feb 2006 - Initial Revision
// 09 Nov 2006 - fixed variant and version bits for v4 guids
// 13 Nov 2006 - added serialization
// 17 Nov 2006 - added name-based guid creation
// 20 Nov 2006 - add fixes for gcc (from Tim Blechmann)
// 07 Mar 2007 - converted to header only
// 10 May 2007 - removed need for Boost.Thread
// - added better seed - thanks Peter Dimov
// - removed null()
// - replaced byte_count() and output_bytes() with size() and begin() and end()
// 11 May 2007 - fixed guid(ByteInputIterator first, ByteInputIterator last)
// - optimized operator>>
// 14 May 2007 - converted from guid to uuid
// 29 May 2007 - uses new implementation of sha1
// 01 Jun 2007 - removed using namespace directives
// 09 Nov 2007 - moved implementation to uuid.ipp file
// 12 Nov 2007 - moved serialize code to uuid_serialize.hpp file
// 25 Feb 2008 - moved to namespace boost::uuids
// 19 Mar 2009 - changed to a POD, reorganized files
// 28 Nov 2009 - disabled deprecated warnings for MSVC
// 30 Nov 2009 - used BOOST_STATIC_CONSTANT
// 02 Dec 2009 - removed BOOST_STATIC_CONSTANT - not all compilers like it
#ifndef BOOST_UUID_HPP
#define BOOST_UUID_HPP
#include <boost/config.hpp>
#include <stddef.h>
#include <boost/cstdint.hpp>
#include <algorithm>
#include <boost/config.hpp> // for static assert
#ifndef BOOST_UUID_NO_TYPE_TRAITS
#include <boost/type_traits/is_pod.hpp>
#include <boost/type_traits/integral_constant.hpp>
#endif
#if defined(_MSC_VER)
#pragma warning(push) // Save warning settings.
#pragma warning(disable : 4996) // Disable deprecated std::swap_ranges, std::equal
#endif
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std {
using ::size_t;
using ::ptrdiff_t;
} //namespace std
#endif //BOOST_NO_STDC_NAMESPACE
namespace boost {
namespace uuids {
struct uuid
{
public:
typedef uint8_t value_type;
typedef uint8_t& reference;
typedef uint8_t const& const_reference;
typedef uint8_t* iterator;
typedef uint8_t const* const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// This does not work on some compilers
// They seem to want the variable definec in
// a cpp file
//BOOST_STATIC_CONSTANT(size_type, static_size = 16);
static size_type static_size() { return 16; }
public:
iterator begin() { return data; } /* throw() */
const_iterator begin() const { return data; } /* throw() */
iterator end() { return data+size(); } /* throw() */
const_iterator end() const { return data+size(); } /* throw() */
size_type size() const { return static_size(); } /* throw() */
bool is_nil() const /* throw() */
{
for(size_t i=0; i<static_size(); i++) {
if (data[i] != 0U) {
return false;
}
}
return true;
}
enum variant_type
{
variant_ncs, // NCS backward compatibility
variant_rfc_4122, // defined in RFC 4122 document
variant_microsoft, // Microsoft Corporation backward compatibility
variant_future // future definition
};
variant_type variant() const /* throw() */
{
// variant is stored in octet 7
// which is index 8, since indexes count backwards
unsigned char octet7 = data[8]; // octet 7 is array index 8
if ( (octet7 & 0x80) == 0x00 ) { // 0b0xxxxxxx
return variant_ncs;
} else if ( (octet7 & 0xC0) == 0x80 ) { // 0b10xxxxxx
return variant_rfc_4122;
} else if ( (octet7 & 0xE0) == 0xC0 ) { // 0b110xxxxx
return variant_microsoft;
} else {
//assert( (octet7 & 0xE0) == 0xE0 ) // 0b111xxxx
return variant_future;
}
}
enum version_type
{
version_unknown = -1,
version_time_based = 1,
version_dce_security = 2,
version_name_based_md5 = 3,
version_random_number_based = 4,
version_name_based_sha1 = 5
};
version_type version() const /* throw() */
{
//version is stored in octet 9
// which is index 6, since indexes count backwards
unsigned char octet9 = data[6];
if ( (octet9 & 0xF0) == 0x10 ) {
return version_time_based;
} else if ( (octet9 & 0xF0) == 0x20 ) {
return version_dce_security;
} else if ( (octet9 & 0xF0) == 0x30 ) {
return version_name_based_md5;
} else if ( (octet9 & 0xF0) == 0x40 ) {
return version_random_number_based;
} else if ( (octet9 & 0xF0) == 0x50 ) {
return version_name_based_sha1;
} else {
return version_unknown;
}
}
// note: linear complexity
void swap(uuid& rhs) /* throw() */
{
std::swap_ranges(begin(), end(), rhs.begin());
}
public:
// or should it be array<uint8_t, 16>
uint8_t data[16];
};
inline bool operator==(uuid const& lhs, uuid const& rhs) /* throw() */
{
return std::equal(lhs.begin(), lhs.end(), rhs.begin());
}
inline bool operator!=(uuid const& lhs, uuid const& rhs) /* throw() */
{
return !(lhs == rhs);
}
inline bool operator<(uuid const& lhs, uuid const& rhs) /* throw() */
{
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
inline bool operator>(uuid const& lhs, uuid const& rhs) /* throw() */
{
return rhs < lhs;
}
inline bool operator<=(uuid const& lhs, uuid const& rhs) /* throw() */
{
return !(rhs < lhs);
}
inline bool operator>=(uuid const& lhs, uuid const& rhs) /* throw() */
{
return !(lhs < rhs);
}
inline void swap(uuid& lhs, uuid& rhs) /* throw() */
{
lhs.swap(rhs);
}
// This is equivalent to boost::hash_range(u.begin(), u.end());
inline std::size_t hash_value(uuid const& u) /* throw() */
{
std::size_t seed = 0;
for(uuid::const_iterator i=u.begin(); i != u.end(); ++i)
{
seed ^= static_cast<std::size_t>(*i) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
return seed;
}
}} //namespace boost::uuids
#ifndef BOOST_UUID_NO_TYPE_TRAITS
// type traits specializations
namespace boost {
template <>
struct is_pod<uuids::uuid> : true_type {};
} // namespace boost
#endif
#if defined(_MSC_VER)
#pragma warning(pop) // Restore warnings to previous state.
#endif
#endif // BOOST_UUID_HPP

View File

@@ -0,0 +1,19 @@
// Boost uuid_generators.hpp header file ----------------------------------------------//
// Copyright 2006 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Revision History
// 06 Feb 2006 - Initial Revision
#ifndef BOOST_UUID_GENERATORS_HPP
#define BOOST_UUID_GENERATORS_HPP
#include <boost/uuid/nil_generator.hpp>
#include <boost/uuid/string_generator.hpp>
#include <boost/uuid/name_generator.hpp>
#include <boost/uuid/random_generator.hpp>
#endif //BOOST_UUID_GENERATORS_HPP

View File

@@ -0,0 +1,198 @@
// Boost uuid_io.hpp header file ----------------------------------------------//
// Copyright 2009 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Revision History
// 20 Mar 2009 - Initial Revision
// 28 Nov 2009 - disabled deprecated warnings for MSVC
#ifndef BOOST_UUID_IO_HPP
#define BOOST_UUID_IO_HPP
#include <boost/uuid/uuid.hpp>
#include <ios>
#include <ostream>
#include <istream>
#include <boost/io/ios_state.hpp>
#include <locale>
#include <algorithm>
#if defined(_MSC_VER)
#pragma warning(push) // Save warning settings.
#pragma warning(disable : 4996) // Disable deprecated std::ctype<char>::widen, std::copy
#endif
namespace boost {
namespace uuids {
template <typename ch, typename char_traits>
std::basic_ostream<ch, char_traits>& operator<<(std::basic_ostream<ch, char_traits> &os, uuid const& u)
{
io::ios_flags_saver flags_saver(os);
io::basic_ios_fill_saver<ch, char_traits> fill_saver(os);
const typename std::basic_ostream<ch, char_traits>::sentry ok(os);
if (ok) {
const std::streamsize width = os.width(0);
const std::streamsize uuid_width = 36;
const std::ios_base::fmtflags flags = os.flags();
const typename std::basic_ios<ch, char_traits>::char_type fill = os.fill();
if (flags & (std::ios_base::right | std::ios_base::internal)) {
for (std::streamsize i=uuid_width; i<width; i++) {
os << fill;
}
}
os << std::hex;
os.fill(os.widen('0'));
std::size_t i=0;
for (uuid::const_iterator i_data = u.begin(); i_data!=u.end(); ++i_data, ++i) {
os.width(2);
os << static_cast<unsigned int>(*i_data);
if (i == 3 || i == 5 || i == 7 || i == 9) {
os << os.widen('-');
}
}
if (flags & std::ios_base::left) {
for (std::streamsize i=uuid_width; i<width; i++) {
os << fill;
}
}
os.width(0); //used the width so reset it
}
return os;
}
template <typename ch, typename char_traits>
std::basic_istream<ch, char_traits>& operator>>(std::basic_istream<ch, char_traits> &is, uuid &u)
{
const typename std::basic_istream<ch, char_traits>::sentry ok(is);
if (ok) {
unsigned char data[16];
typedef std::ctype<ch> ctype_t;
ctype_t const& ctype = std::use_facet<ctype_t>(is.getloc());
ch xdigits[16];
{
char szdigits[] = "0123456789ABCDEF";
ctype.widen(szdigits, szdigits+16, xdigits);
}
ch*const xdigits_end = xdigits+16;
ch c;
for (std::size_t i=0; i<u.size() && is; ++i) {
is >> c;
c = ctype.toupper(c);
ch* f = std::find(xdigits, xdigits_end, c);
if (f == xdigits_end) {
is.setstate(std::ios_base::failbit);
break;
}
unsigned char byte = static_cast<unsigned char>(std::distance(&xdigits[0], f));
is >> c;
c = ctype.toupper(c);
f = std::find(xdigits, xdigits_end, c);
if (f == xdigits_end) {
is.setstate(std::ios_base::failbit);
break;
}
byte <<= 4;
byte |= static_cast<unsigned char>(std::distance(&xdigits[0], f));
data[i] = byte;
if (is) {
if (i == 3 || i == 5 || i == 7 || i == 9) {
is >> c;
if (c != is.widen('-')) is.setstate(std::ios_base::failbit);
}
}
}
if (is) {
std::copy(data, data+16, u.begin());
}
}
return is;
}
namespace detail {
inline char to_char(size_t i) {
if (i <= 9) {
return static_cast<char>('0' + i);
} else {
return static_cast<char>('a' + (i-10));
}
}
inline wchar_t to_wchar(size_t i) {
if (i <= 9) {
return static_cast<wchar_t>(L'0' + i);
} else {
return static_cast<wchar_t>(L'a' + (i-10));
}
}
} // namespace detail
inline std::string to_string(uuid const& u)
{
std::string result;
result.reserve(36);
std::size_t i=0;
for (uuid::const_iterator it_data = u.begin(); it_data!=u.end(); ++it_data, ++i) {
const size_t hi = ((*it_data) >> 4) & 0x0F;
result += detail::to_char(hi);
const size_t lo = (*it_data) & 0x0F;
result += detail::to_char(lo);
if (i == 3 || i == 5 || i == 7 || i == 9) {
result += '-';
}
}
return result;
}
#ifndef BOOST_NO_STD_WSTRING
inline std::wstring to_wstring(uuid const& u)
{
std::wstring result;
result.reserve(36);
std::size_t i=0;
for (uuid::const_iterator it_data = u.begin(); it_data!=u.end(); ++it_data, ++i) {
const size_t hi = ((*it_data) >> 4) & 0x0F;
result += detail::to_wchar(hi);
const size_t lo = (*it_data) & 0x0F;
result += detail::to_wchar(lo);
if (i == 3 || i == 5 || i == 7 || i == 9) {
result += L'-';
}
}
return result;
}
#endif
}} //namespace boost::uuids
#if defined(_MSC_VER)
#pragma warning(pop) // Restore warnings to previous state.
#endif
#endif // BOOST_UUID_IO_HPP

View File

@@ -0,0 +1,20 @@
// Boost uuid_serialize.hpp header file ----------------------------------------------//
// Copyright 2007 Andy Tompkins.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Revision History
// 12 Nov 2007 - Initial Revision
// 25 Feb 2008 - moved to namespace boost::uuids::detail
#ifndef BOOST_UUID_SERIALIZE_HPP
#define BOOST_UUID_SERIALIZE_HPP
#include <boost/uuid/uuid.hpp>
#include <boost/serialization/level.hpp>
BOOST_CLASS_IMPLEMENTATION(boost::uuids::uuid, boost::serialization::primitive_type)
#endif // BOOST_UUID_SERIALIZE_HPP

18
Boost/boost/weak_ptr.hpp Normal file
View File

@@ -0,0 +1,18 @@
#ifndef BOOST_WEAK_PTR_HPP_INCLUDED
#define BOOST_WEAK_PTR_HPP_INCLUDED
//
// weak_ptr.hpp
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://www.boost.org/libs/smart_ptr/weak_ptr.htm for documentation.
//
#include <boost/smart_ptr/weak_ptr.hpp>
#endif // #ifndef BOOST_WEAK_PTR_HPP_INCLUDED

Binary file not shown.

Binary file not shown.

80
CHANGELOG.md Normal file
View File

@@ -0,0 +1,80 @@
# Changelog
## [latest-master] (https://github.com/WagicProject/wagic/tree/latest-master)
#### 08/12/14
- *Merged pull-request:* Fix for guild_keywords Devotion, added some "Chroma" cards [\#606](https://github.com/WagicProject/wagic/pull/606) ([kevlahnota](https://github.com/kevlahnota))
- *Merged pull-request:* added guild keywords, added specific life cost [\#605](https://github.com/WagicProject/wagic/pull/605) ([kevlahnota](https://github.com/kevlahnota))
- *Merged pull-request:* Buyback issue and a fix [\#604](https://github.com/WagicProject/wagic/pull/604) ([apollovy](https://github.com/apollovy))
- *Merged pull-request:* Feature/ios update xcode5.1 [\#602](https://github.com/WagicProject/wagic/pull/602) ([mjnguyen](https://github.com/mjnguyen))
- *Merged pull-request:* Remove dead code and fix circular initialization [\#601](https://github.com/WagicProject/wagic/pull/601) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* update android build tools version [\#600](https://github.com/WagicProject/wagic/pull/600) ([Rolzad73](https://github.com/Rolzad73))
- *Merged pull-request:* Attempt to make android tools fetching for TravisCI explicit and futureproof [\#599](https://github.com/WagicProject/wagic/pull/599) ([Rolzad73](https://github.com/Rolzad73))
- *Merged pull-request:* Damager keyword [\#598](https://github.com/WagicProject/wagic/pull/598) ([bjornsnoen](https://github.com/bjornsnoen))
- *Merged pull-request:* Fix a rarity mistake and a grammatical error [\#596](https://github.com/WagicProject/wagic/pull/596) ([bjornsnoen](https://github.com/bjornsnoen))
- *Merged pull-request:* Fix bug where the phase wheel got out of sync [\#588](https://github.com/WagicProject/wagic/pull/588) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* More easing [\#586](https://github.com/WagicProject/wagic/pull/586) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Added Avatar Tokens created by Ajani Goldmane. [\#585](https://github.com/WagicProject/wagic/pull/585) ([bjornsnoen](https://github.com/bjornsnoen))
- *Merged pull-request:* Cleanup, usability fixes and source code documentation for DeckView.h and GridDeckView.h [\#583](https://github.com/WagicProject/wagic/pull/583) ([ZobyTwo](https://github.com/ZobyTwo))
- *Fixed bug:* Blight does not destroy at the end of turn but right now [\#592](https://github.com/WagicProject/wagic/issues/592)
- *Fixed bug:* game freezes on Android when the phone returns from "sleep mode" [\#544](https://github.com/WagicProject/wagic/issues/544)
- *Fixed bug:* Android port needs to be able to respond to attaching/detaching devices to it [\#522](https://github.com/WagicProject/wagic/issues/522)
## [alpha-195] (https://github.com/WagicProject/wagic/tree/alpha-195)
#### 07/12/13
- *Merged pull-request:* Reset positions and filters when reopening the editor [\#578](https://github.com/WagicProject/wagic/pull/578) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Deck viewer [\#577](https://github.com/WagicProject/wagic/pull/577) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Do not specify the system directory in JGE [\#576](https://github.com/WagicProject/wagic/pull/576) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Changed Travis build file to use Android API 10 and Android build tools 18.1.1 [\#575](https://github.com/WagicProject/wagic/pull/575) ([Rolzad73](https://github.com/Rolzad73))
- *Merged pull-request:* Feature/play from grave [\#574](https://github.com/WagicProject/wagic/pull/574) ([pankdm](https://github.com/pankdm))
- *Merged pull-request:* Fix Valgrind warnings appearing during the test suit. [\#573](https://github.com/WagicProject/wagic/pull/573) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Strings 2 [\#572](https://github.com/WagicProject/wagic/pull/572) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Android travis ci [\#570](https://github.com/WagicProject/wagic/pull/570) ([xawotihs](https://github.com/xawotihs))
- *Merged pull-request:* Android NDK build fix [\#569](https://github.com/WagicProject/wagic/pull/569) ([Rolzad73](https://github.com/Rolzad73))
- *Merged pull-request:* Add a few namespaces and fix header guards. [\#564](https://github.com/WagicProject/wagic/pull/564) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Updated deckmenu.cpp to properly render deck description and summary [\#562](https://github.com/WagicProject/wagic/pull/562) ([citiral](https://github.com/citiral))
- *Merged pull-request:* Fix some valgrind memcheck warnings. However there remains one... [\#561](https://github.com/WagicProject/wagic/pull/561) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Remove some dead code [\#560](https://github.com/WagicProject/wagic/pull/560) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Show output only for failing tests [\#559](https://github.com/WagicProject/wagic/pull/559) ([pankdm](https://github.com/pankdm))
- *Merged pull-request:* Defines/Typos [\#557](https://github.com/WagicProject/wagic/pull/557) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Simplify Damage::resolve a bit [\#556](https://github.com/WagicProject/wagic/pull/556) ([ZobyTwo](https://github.com/ZobyTwo))
- *Merged pull-request:* Fix cranial plating [\#555](https://github.com/WagicProject/wagic/pull/555) ([pankdm](https://github.com/pankdm))
- *Merged pull-request:* Android cleanup [\#1](https://github.com/WagicProject/wagic/pull/1) ([Rolzad73](https://github.com/Rolzad73))
- *Fixed bug:* Iona and Nin don't work [\#527](https://github.com/WagicProject/wagic/issues/527)
- *Closed issue:* Less verbose output of tests at Travis [\#558](https://github.com/WagicProject/wagic/issues/558)
## [wagic-0.19.2] (https://github.com/WagicProject/wagic/tree/wagic-v0.19.2)
#### 28/10/13

View File

@@ -73,7 +73,7 @@
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>SDL_CONFIG;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TIXML_USE_STL; SDL_CONFIG;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
@@ -101,7 +101,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>SDL_CONFIG;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TIXML_USE_STL; SDL_CONFIG;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
@@ -129,7 +129,7 @@
<Optimization>Full</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>SDL_CONFIG;WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TIXML_USE_STL; SDL_CONFIG;WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>

View File

@@ -31,6 +31,7 @@ HGE_OBJS = src/hge/hgecolor.o src/hge/hgeparticle.o \
CXXFLAGS = -W -Wall -Werror -Wno-unused
CXXFLAGS += -DTIXML_USE_STL
ifdef DEBUG
CXXFLAGS += -ggdb3

View File

@@ -4,6 +4,8 @@
// dirty, but I get OS header includes this way
#include "JGE.h"
#include "OutputCapturer.h"
#include <ostream>
#include <iostream>
#include <iomanip>
@@ -29,12 +31,23 @@ std::string ToHex(T* pointer)
#if defined (WIN32) || defined (LINUX)
#ifdef QT_CONFIG
#ifdef CAPTURE_STDERR
#define DebugTrace(inString) \
{ \
std::ostringstream stream; \
stream << inString << std::endl; \
qDebug(stream.str().c_str()); \
stream << inString; \
OutputCapturer::add(stream.str()); \
}
#else // CAPTURE_STDERR
#define DebugTrace(inString) \
{ \
std::ostringstream stream; \
stream << inString; \
qDebug("%s", stream.str().c_str()); \
}
#endif // CAPTURE_STDERR
#elif defined (ANDROID)
#include <android/log.h>
#define DebugTrace(inString) \
@@ -48,7 +61,7 @@ std::string ToHex(T* pointer)
{ \
std::ostringstream stream; \
stream << inString << std::endl; \
OutputDebugString(stream.str().c_str()); \
OutputDebugStringA(stream.str().c_str()); \
}
#endif // QT_CONFIG
#endif // Win32, Linux

128
JGE/include/Downloader.h Normal file
View File

@@ -0,0 +1,128 @@
#ifndef DOWNLOADER_H
#define DOWNLOADER_H
//-------------------------------------------------------------------------------------
//
// This class handles download of remote resources (any kind of file)
// All the resources are stored locally in the userPath
// For every resources, the downloader verifies if the resource was modifed
// on the server before downloading the update. The Downloader maintains a catalogue
// of resource downloaded to be able to check if they need to be updated.
//
// The interface can be used completly synchronously by the application and some
// context or message loop is needed in the implementation of this interface
//
// Note that the Downloader could in theory by implemented on top of JNetwork.
//
//-------------------------------------------------------------------------------------
#include <string>
#include <ostream>
#include <istream>
#include <fstream>
#include <map>
#include "Threading.h"
#ifdef QT_CONFIG
#include <QObject>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#endif
using namespace std;
class DownloadRequest
#ifdef QT_CONFIG
: public QObject
#endif
{
#ifdef QT_CONFIG
Q_OBJECT
private slots:
#endif
void fileDownloaded();
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
#ifdef QT_CONFIG
signals:
void percentChanged(int percent);
void statusChanged(int);
#endif
public:
typedef enum {
NOT_PRESENT,
DOWNLOADING,
DOWNLOADED,
DOWNLOAD_ERROR
} DownloadStatus;
protected:
string mLocalPath;
string mRemoteResourceURL;
// previous one is the original, next one can change after redirection
string mRequestedRemoteResourceURL;
string mETag;
DownloadStatus mDownloadStatus;
bool mUpgradeAvailable;
size_t mTotalSize;
size_t mCurrentSize;
ofstream mFile;
#ifdef QT_CONFIG
QNetworkReply* mNetworkReply;
static QNetworkAccessManager networkAccessManager;
#endif
public:
DownloadRequest(string localPath="",
string remoteResourceURL="",
string ETag = "",
DownloadStatus downloadStatus=NOT_PRESENT,
size_t totalSize = 0,
size_t currentSize = 0);
~DownloadRequest();
static bool NetworkIsAccessible();
string getTempLocalPath() const { return (mLocalPath+".tmp"); };
string getLocalPath() const { return mLocalPath; };
string getRemoteResource() const { return mRemoteResourceURL; };
string getETag() const { return mETag; };
void startGet();
void startHead();
DownloadStatus getDownloadStatus() const { return mDownloadStatus; };
bool upgradeAvailable() const { return mUpgradeAvailable; };
void getSizes(size_t& totalSize, size_t&currentSize) {
totalSize = mTotalSize;
currentSize = mCurrentSize;
};
friend ostream& operator<<(ostream& out, const DownloadRequest& d);
friend istream& operator>>(istream&, DownloadRequest&);
friend class Downloader;
};
class Downloader
{
protected:
Downloader(string globalRemoteURL="", string localCacheRecords="");
virtual ~Downloader();
static Downloader* mInstance;
string mGlobalRemoteURL;
string mLocalCacheRecords;
boost::mutex mMutex;
map<string, DownloadRequest*> mRequestMap;
public:
static Downloader* GetInstance();
static void Release();
void Update();
DownloadRequest* Get(string localPath, string remoteResourceURL="");
friend ostream& operator<<(ostream& out, const Downloader& d);
friend istream& operator>>(istream&, Downloader&);
};
#endif // DOWNLOADER_H

View File

@@ -297,7 +297,6 @@ public:
private:
float mTimer;
float mFrameTime;
JAnimator* mAnimator;
vector<JAnimatorObject *> mObjects;
};

View File

@@ -37,7 +37,6 @@ private:
float mTexY;
float mTexWidth;
float mTexHeight;
JTexture* mTexture;
JQuad* mQuad;

View File

@@ -128,6 +128,7 @@ public:
bool readIntoString(const string & FilePath, string & target);
bool openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode = ios_base::out );
bool Rename(string from, string to);
bool Remove(string aFile);
//Returns true if strFilename exists somewhere in the fileSystem
bool FileExists(const string& strFilename);
@@ -163,4 +164,4 @@ protected:
#endif
#endif

View File

@@ -44,6 +44,17 @@ typedef WPARAM LocalKeySym;
#include <X11/keysym.h>
typedef KeySym LocalKeySym;
#define LOCAL_KEY_NONE XK_VoidSymbol
#undef Status
#undef Bool
#undef None
#undef CursorShape
#undef KeyPress
#undef KeyRelease
#undef FocusIn
#undef FocusOut
#undef FontChange
#undef Unsorted
#undef GrayScale
#elif defined(ANDROID) // This is temporary until we understand how to send real key events from Java
typedef long unsigned int LocalKeySym;

View File

@@ -61,7 +61,7 @@ public:
virtual bool ButtonPressed(); // action button pressed, return false to ignore
// Used for mouse support so that the GUI engine can found out which Object was selected
virtual bool getTopLeft(float& top, float& left)
virtual bool getTopLeft(float&, float&)
{
return false;
}
@@ -104,7 +104,7 @@ public:
int mCount;
JGuiController(JGE* jge, int id, JGuiListener* listener);
~JGuiController();
virtual ~JGuiController();
virtual void Render();
virtual void Update(float dt);

View File

@@ -172,6 +172,7 @@ private:
float mHeight;
float mScale;
float mTextureScale;
float mRotation;
float mTracking;
float mSpacing;

View File

@@ -13,34 +13,42 @@ class JSocket;
#include <sstream>
#include "Threading.h"
typedef void(*processCmd)(istream&, ostream&);
typedef void(*processCmd)(void*, stringstream&, stringstream&);
class JNetwork {
private:
private:
boost::thread *mpWorkerThread;
struct CommandStruc{
void* object;
string command;
processCmd processCommand;
};
string serverIP;
int connected_to_ap;
JSocket* socket;
boost::mutex sendMutex;
boost::mutex receiveMutex;
stringstream received;
stringstream toSend;
static map<string, processCmd> sCommandMap;
static map<string, CommandStruc> sCommandMap;
public:
JNetwork();
~JNetwork();
string serverIP;
void Update();
void getServerIp(string& aString);
int connect(string serverIP = "");
int connect(const string& serverIP = "");
bool isConnected();
bool isServer() { return serverIP == ""; };
static void ThreadProc(void* param);
#if !defined (WIN32) && !defined (LINUX)
static int connect_to_apctl(int config);
#endif
bool sendCommand(string command);
static void registerCommand(string command, processCmd processCommand, processCmd processResponse);
private:
boost::thread *mpWorkerThread;
bool sendCommand(const string& command, const string& payload = "", const string& suffix = "Request");
static void registerCommand(string command, void* object, processCmd processRequest, processCmd processResponse);
};
#endif

View File

@@ -578,7 +578,7 @@ private:
#if (!defined PSP)
GLuint mCurrentTex;
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) || (defined WIN32)
#if ((defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) || (defined WIN32)) && (!defined CONSOLE_CONFIG)
// MVP matrix
ESMatrix theMvpMatrix;

View File

@@ -5,6 +5,8 @@
#include "Threading.h"
using namespace std;
#define SERVER_PORT 5001
class JSocket{
public:
typedef enum {
@@ -19,10 +21,11 @@ public:
} SOCKET_STATE;
// Server creation
JSocket(string ipAddr);
// Client creation
JSocket(string ipAddr);
// Server creation
JSocket();
~JSocket();
JSocket* Accept();
@@ -32,6 +35,8 @@ public:
void Disconnect();
private:
// socket state
SOCKET_STATE state;
// socket creation when server accepts a connection
JSocket(int fd);
// convert the socket into non-blocking state
@@ -39,11 +44,9 @@ private:
// socket handle
#ifdef WIN32
SOCKET mfd;
#elif LINUX
#elif LINUX || PSP
int mfd;
#endif
// socket state
SOCKET_STATE state;
};
#endif

View File

@@ -23,29 +23,32 @@
#include "SLES/OpenSLES_Android.h"
#elif defined USE_PHONON
#include <phonon/AudioOutput>
#include <phonon/MediaObject>
#else
#ifdef WIN32
#include <windows.h>
#include <phonon/AudioOutput>
#include <phonon/MediaObject>
#elif (defined QT_CONFIG)
#include "QMediaPlayer"
#include "QMediaPlaylist"
#include "QSoundEffect"
#elif defined WIN32
#include <windows.h>
#define WITH_FMOD
#elif defined (PSP)
#include <pspgu.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <time.h>
#include <string.h>
#include <pspaudiolib.h>
#include <psprtc.h>
#include <pspgu.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <time.h>
#include <string.h>
#include <pspaudiolib.h>
#include <psprtc.h>
#include "JAudio.h"
#include "JMP3.h"
#include "JAudio.h"
#include "JMP3.h"
#endif
#ifdef WITH_FMOD
#include "../Dependencies/include/fmod.h"
#endif
#include "../Dependencies/include/fmod.h"
#endif
//------------------------------------------------------------------------------------------------
@@ -68,7 +71,7 @@ public:
#ifdef USE_PHONON
Phonon::AudioOutput* mOutput;
Phonon::MediaObject* mMediaObject;
public slots:
public slots:
void seekAtTheBegining();
#elif defined (PSP)
JMP3* mTrack;
@@ -83,6 +86,10 @@ public:
SLPlayItf playInterface;
SLSeekItf seekInterface;
SLVolumeItf musicVolumeInterface;
#elif (defined QT_CONFIG)
QMediaPlaylist* playlist;
QMediaPlayer* player;
string fullpath;
#else
void* mTrack;
#endif //WITH_FMOD
@@ -93,13 +100,15 @@ public:
//------------------------------------------------------------------------------------------------
class JSample
{
public:
public:
JSample();
~JSample();
unsigned long fileSize();
#if defined (PSP)
#if (defined QT_CONFIG) && (!defined USE_PHONON)
QMediaPlayer* effect;
void* mSample;
#elif defined (PSP)
WAVDATA *mSample;
#elif defined (IOS)
std::string filename;
@@ -134,126 +143,128 @@ class JSoundSystem
public:
//////////////////////////////////////////////////////////////////////////
/// Get the singleton instance
///
//////////////////////////////////////////////////////////////////////////
static JSoundSystem* GetInstance();
//////////////////////////////////////////////////////////////////////////
/// Get the singleton instance
///
//////////////////////////////////////////////////////////////////////////
static JSoundSystem* GetInstance();
static void Destroy();
static void Destroy();
//////////////////////////////////////////////////////////////////////////
/// Load music.
///
/// @note MP3 is the only supported format for the moment.
///
/// @param filename - Name of the music file.
///
//////////////////////////////////////////////////////////////////////////
JMusic *LoadMusic(const char *fileName);
//////////////////////////////////////////////////////////////////////////
/// Load music.
///
/// @note MP3 is the only supported format for the moment.
///
/// @param filename - Name of the music file.
///
//////////////////////////////////////////////////////////////////////////
JMusic *LoadMusic(const char *fileName);
//////////////////////////////////////////////////////////////////////////
/// Delete music from memory.
///
/// @param music - Music to be deleted.
///
//////////////////////////////////////////////////////////////////////////
//void FreeMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Delete music from memory.
///
/// @param music - Music to be deleted.
///
//////////////////////////////////////////////////////////////////////////
//void FreeMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Play music.
///
/// @param music - Music to be played.
/// @param looping - Play the music in a loop.
///
//////////////////////////////////////////////////////////////////////////
void PlayMusic(JMusic *music, bool looping = false);
//////////////////////////////////////////////////////////////////////////
/// Play music.
///
/// @param music - Music to be played.
/// @param looping - Play the music in a loop.
///
//////////////////////////////////////////////////////////////////////////
void PlayMusic(JMusic *music, bool looping = false);
//////////////////////////////////////////////////////////////////////////
/// Stop playing.
///
/// @param music - Music to be stopped.
///
//////////////////////////////////////////////////////////////////////////
void StopMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Stop playing.
///
/// @param music - Music to be stopped.
///
//////////////////////////////////////////////////////////////////////////
void StopMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Resume playing.
///
/// @param music - Music to be resumed.
///
//////////////////////////////////////////////////////////////////////////
void ResumeMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Resume playing.
///
/// @param music - Music to be resumed.
///
//////////////////////////////////////////////////////////////////////////
void ResumeMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Pause playing.
///
/// @param music - Music to be paused.
///
//////////////////////////////////////////////////////////////////////////
void PauseMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Pause playing.
///
/// @param music - Music to be paused.
///
//////////////////////////////////////////////////////////////////////////
void PauseMusic(JMusic *music);
//////////////////////////////////////////////////////////////////////////
/// Load sound effect.
///
/// @note WAV sound effect only.
///
/// @param fileName - Sound effect for loading.
///
//////////////////////////////////////////////////////////////////////////
JSample *LoadSample(const char *fileName);
//////////////////////////////////////////////////////////////////////////
/// Load sound effect.
///
/// @note WAV sound effect only.
///
/// @param fileName - Sound effect for loading.
///
//////////////////////////////////////////////////////////////////////////
JSample *LoadSample(const char *fileName);
//////////////////////////////////////////////////////////////////////////
/// Delete sound effect from memory.
///
/// @param sample - Sound to be deleted.
///
//////////////////////////////////////////////////////////////////////////
//void FreeSample(JSample *sample);
//////////////////////////////////////////////////////////////////////////
/// Delete sound effect from memory.
///
/// @param sample - Sound to be deleted.
///
//////////////////////////////////////////////////////////////////////////
//void FreeSample(JSample *sample);
//////////////////////////////////////////////////////////////////////////
/// Play sound effect.
///
/// @param sample - Sound for playing.
///
//////////////////////////////////////////////////////////////////////////
void PlaySample(JSample *sample);
//////////////////////////////////////////////////////////////////////////
/// Play sound effect.
///
/// @param sample - Sound for playing.
///
//////////////////////////////////////////////////////////////////////////
void PlaySample(JSample *sample);
//////////////////////////////////////////////////////////////////////////
/// Set volume for audio playback.
///
/// @param volume - New volume.
///
//////////////////////////////////////////////////////////////////////////
void SetVolume(int volume);
//////////////////////////////////////////////////////////////////////////
/// Set volume for audio playback.
///
/// @param volume - New volume.
///
//////////////////////////////////////////////////////////////////////////
void SetVolume(int volume);
void SetMusicVolume(int volume);
void SetMusicVolume(int volume);
void SetSfxVolume(int volume);
void SetSfxVolume(int volume);
int mChannel;
int mChannel;
protected:
JSoundSystem();
~JSoundSystem();
JSoundSystem();
~JSoundSystem();
void InitSoundSystem();
void DestroySoundSystem();
void InitSoundSystem();
void DestroySoundSystem();
private:
JMusic *mCurrentMusic;
#if (defined PSP || defined ANDROID)
JMusic *mCurrentMusic;
JSample *mCurrentSample;
#endif
int mVolume;
int mMusicVolume;
int mSampleVolume;
int mVolume;
int mMusicVolume;
int mSampleVolume;
static JSoundSystem* mInstance;
static JSoundSystem* mInstance;
};
#endif

View File

@@ -39,10 +39,10 @@
#define MAX_CHANNEL 128
enum {
JGE_ERR_CANT_OPEN_FILE = -1,
JGE_ERR_PNG = -2,
JGE_ERR_MALLOC_FAILED = -4,
JGE_ERR_GENERIC = -5,
JGE_ERR_CANT_OPEN_FILE = -1,
JGE_ERR_PNG = -2,
JGE_ERR_MALLOC_FAILED = -4,
JGE_ERR_GENERIC = -5,
};
#ifdef PSP
@@ -75,45 +75,76 @@ enum {
#define SCREEN_HEIGHT_F 272.0f
#ifdef CONSOLE_CONFIG
#define DEFAULT_BLEND 0
#define BLEND_OPTION_ADD 0
#define BLEND_OPTION_BLEND 0
#define BLEND_ZERO 0
#define BLEND_ONE 0
#define BLEND_SRC_COLOR 0
#define BLEND_ONE_MINUS_SRC_COLOR 0
#define BLEND_SRC_ALPHA 0
#define BLEND_ONE_MINUS_SRC_ALPHA 0
#define BLEND_DST_ALPHA 0
#define BLEND_ONE_MINUS_DST_ALPHA 0
#define BLEND_DST_COLOR 0
#define BLEND_ONE_MINUS_DST_COLOR 0
#define BLEND_SRC_ALPHA_SATURATE 0
#define GU_PSM_5551 0
#else
#ifdef WIN32
// #define DEFAULT_BLEND BLEND_DEFAULT
// #define BLEND_OPTION_ADD BLEND_COLORADD
// #define BLEND_OPTION_BLEND (BLEND_COLORADD | BLEND_ALPHABLEND | BLEND_NOZWRITE)
#else
#define DEFAULT_BLEND GU_TFX_MODULATE
#define BLEND_OPTION_ADD GU_TFX_ADD
#define BLEND_OPTION_BLEND GU_TFX_BLEND
#define DEFAULT_BLEND GU_TFX_MODULATE
#define BLEND_OPTION_ADD GU_TFX_ADD
#define BLEND_OPTION_BLEND GU_TFX_BLEND
#endif
#endif // CONSOLE_CONFIG
#if (defined WIN32) && (!defined LINUX)
#include <windows.h>
#endif
#if defined(LINUX) || defined(IOS) || defined (ANDROID)
typedef uint8_t byte;
typedef uint32_t DWORD;
typedef uint8_t BYTE;
#if defined(LINUX) && (!defined WIN32) || defined(IOS) || defined (ANDROID)
typedef uint8_t byte;
typedef uint32_t DWORD;
typedef uint8_t BYTE;
#ifndef IOS
typedef bool BOOL;
typedef bool BOOL;
#endif
#endif
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
#define PIXEL_TYPE DWORD
#define ARGB(a, r, g, b) ((PIXEL_TYPE)((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
#define RGBA(r, g, b, a) ((PIXEL_TYPE)((a) << 24) | ((b) << 16) | ((g) << 8) | (r))
#ifndef PSP
#define TEXTURE_FORMAT 0
#endif //PSP
#ifndef CONSOLE_CONFIG
#ifndef QT_CONFIG
#if defined (IOS)
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <OpenGLES/ES1/gl.h>
# import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#elif defined (ANDROID)
#include <GLES/gl.h>
#include <GLES/glext.h>
#elif defined (WIN32) || defined (LINUX)
#include <GL/gl.h>
#include <GL/glu.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#elif defined (WIN32) || defined (LINUX)
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#else
# include <QtOpenGL>
#include <QtOpenGL>
#endif
#if (defined FORCE_GLES)
@@ -127,152 +158,115 @@ enum {
#endif
#if defined (PSP)
#ifndef ABGR8888
#define ABGR8888
#endif
#ifndef ABGR8888
#define ABGR8888
#endif
#if defined (ABGR8888)
#define PIXEL_TYPE u32
#ifndef ARGB
#define ARGB(a, r, g, b) (PIXEL_TYPE)((a << 24) | (b << 16) | (g << 8) | r) // macro to assemble pixels in correct format
#endif
#define MAKE_COLOR(a, c) (a << 24 | c)
#define MASK_ALPHA 0xFF000000 // masks for accessing individual pixels
#define MASK_BLUE 0x00FF0000
#define MASK_GREEN 0x0000FF00
#define MASK_RED 0x000000FF
#if defined (ABGR8888)
#ifndef ARGB
#define ARGB(a, r, g, b) (PIXEL_TYPE)((a << 24) | (b << 16) | (g << 8) | r) // macro to assemble pixels in correct format
#endif
#define MAKE_COLOR(a, c) (a << 24 | c)
#define MASK_ALPHA 0xFF000000 // masks for accessing individual pixels
#define MASK_BLUE 0x00FF0000
#define MASK_GREEN 0x0000FF00
#define MASK_RED 0x000000FF
#define PIXEL_SIZE 4
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_8888
#define PIXEL_SIZE 4
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_8888
#define BUFFER_FORMAT GU_PSM_8888
#define TEXTURE_FORMAT GU_PSM_8888
#define TEXTURE_COLOR_FORMAT GU_COLOR_8888
#define BUFFER_FORMAT GU_PSM_8888
#define TEXTURE_FORMAT GU_PSM_8888
#define TEXTURE_COLOR_FORMAT GU_COLOR_8888
#elif defined (ABGR5551)
#elif defined (ABGR5551)
#ifndef ARGB
#define ARGB(a, r, g, b) ((r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | ((a >> 7) << 15))
#endif
#define MAKE_COLOR(a, c) (((a>>7)<<15) | c)
#define MASK_ALPHA 0x8000
#define MASK_BLUE 0x7C00
#define MASK_GREEN 0x03E0
#define MASK_RED 0x001F
#define PIXEL_TYPE u16
#define PIXEL_SIZE 2
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_5551
#ifndef ARGB
#define ARGB(a, r, g, b) ((r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | ((a >> 7) << 15))
#endif
#define MAKE_COLOR(a, c) (((a>>7)<<15) | c)
#define MASK_ALPHA 0x8000
#define MASK_BLUE 0x7C00
#define MASK_GREEN 0x03E0
#define MASK_RED 0x001F
#define PIXEL_TYPE u16
#define PIXEL_SIZE 2
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_5551
#define BUFFER_FORMAT GU_PSM_8888
#define TEXTURE_FORMAT GU_PSM_5551
#define TEXTURE_COLOR_FORMAT GU_COLOR_5551
#define BUFFER_FORMAT GU_PSM_8888
#define TEXTURE_FORMAT GU_PSM_5551
#define TEXTURE_COLOR_FORMAT GU_COLOR_5551
#elif defined (ABGR4444)
#ifndef ARGB
#define ARGB(a, r, g, b) ((r >> 4) | ((g >> 4) << 4) | ((b >> 4) << 8) | ((a >> 4) << 12))
#endif
#define MAKE_COLOR(a, c) (((a>>4)<<12) | c)
#define MASK_ALPHA 0xF000
#define MASK_BLUE 0x0F00
#define MASK_GREEN 0x00F0
#define MASK_RED 0x000F
#define PIXEL_TYPE u16
#define PIXEL_SIZE 2
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_4444
#elif defined (ABGR4444)
#ifndef ARGB
#define ARGB(a, r, g, b) ((r >> 4) | ((g >> 4) << 4) | ((b >> 4) << 8) | ((a >> 4) << 12))
#endif
#define MAKE_COLOR(a, c) (((a>>4)<<12) | c)
#define MASK_ALPHA 0xF000
#define MASK_BLUE 0x0F00
#define MASK_GREEN 0x00F0
#define MASK_RED 0x000F
#define PIXEL_TYPE u16
#define PIXEL_SIZE 2
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_4444
#define BUFFER_FORMAT GU_PSM_4444
#define TEXTURE_FORMAT GU_PSM_4444
#define TEXTURE_COLOR_FORMAT GU_COLOR_4444
#define BUFFER_FORMAT GU_PSM_4444
#define TEXTURE_FORMAT GU_PSM_4444
#define TEXTURE_COLOR_FORMAT GU_COLOR_4444
#endif
#endif
#define FRAME_BUFFER_WIDTH 512
#define FRAME_BUFFER_SIZE FRAME_BUFFER_WIDTH*SCREEN_HEIGHT*PIXEL_SIZE
#define FRAME_BUFFER_WIDTH 512
#define FRAME_BUFFER_SIZE FRAME_BUFFER_WIDTH*SCREEN_HEIGHT*PIXEL_SIZE
#define SLICE_SIZE_F 64.0f
typedef unsigned int DWORD;
#define SLICE_SIZE_F 64.0f
typedef unsigned int DWORD;
#define BLEND_ZERO 0x1000
#define BLEND_ONE 0x1002
#define BLEND_SRC_COLOR GU_SRC_COLOR
#define BLEND_ONE_MINUS_SRC_COLOR GU_ONE_MINUS_SRC_COLOR
#define BLEND_SRC_ALPHA GU_SRC_ALPHA
#define BLEND_ONE_MINUS_SRC_ALPHA GU_ONE_MINUS_SRC_ALPHA
#define BLEND_DST_ALPHA GU_DST_ALPHA
#define BLEND_ONE_MINUS_DST_ALPHA GU_ONE_MINUS_DST_ALPHA
#define BLEND_DST_COLOR GU_DST_COLOR
#define BLEND_ONE_MINUS_DST_COLOR GU_ONE_MINUS_DST_COLOR
#define BLEND_SRC_ALPHA_SATURATE BLEND_ONE
#define BLEND_ZERO 0x1000
#define BLEND_ONE 0x1002
#define BLEND_SRC_COLOR GU_SRC_COLOR
#define BLEND_ONE_MINUS_SRC_COLOR GU_ONE_MINUS_SRC_COLOR
#define BLEND_SRC_ALPHA GU_SRC_ALPHA
#define BLEND_ONE_MINUS_SRC_ALPHA GU_ONE_MINUS_SRC_ALPHA
#define BLEND_DST_ALPHA GU_DST_ALPHA
#define BLEND_ONE_MINUS_DST_ALPHA GU_ONE_MINUS_DST_ALPHA
#define BLEND_DST_COLOR GU_DST_COLOR
#define BLEND_ONE_MINUS_DST_COLOR GU_ONE_MINUS_DST_COLOR
#define BLEND_SRC_ALPHA_SATURATE BLEND_ONE
typedef struct
{
ScePspFVector2 texture;
ScePspFVector3 pos;
} PSPVertex3D;
typedef struct
{
ScePspFVector2 texture;
ScePspFVector3 pos;
} PSPVertex3D;
#else //non PSP
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
#define BLEND_ZERO GL_ZERO
#define BLEND_ONE GL_ONE
#define BLEND_SRC_COLOR GL_SRC_COLOR
#define BLEND_ONE_MINUS_SRC_COLOR GL_ONE_MINUS_SRC_COLOR
#define BLEND_SRC_ALPHA GL_SRC_ALPHA
#define BLEND_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
#define BLEND_DST_ALPHA GL_DST_ALPHA
#define BLEND_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
#define BLEND_DST_COLOR GL_DST_COLOR
#define BLEND_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_COLOR
#define BLEND_SRC_ALPHA_SATURATE GL_SRC_ALPHA_SATURATE
#define BLEND_ZERO GL_ZERO
#define BLEND_ONE GL_ONE
#define BLEND_SRC_COLOR GL_SRC_COLOR
#define BLEND_ONE_MINUS_SRC_COLOR GL_ONE_MINUS_SRC_COLOR
#define BLEND_SRC_ALPHA GL_SRC_ALPHA
#define BLEND_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
#define BLEND_DST_ALPHA GL_DST_ALPHA
#define BLEND_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
#define BLEND_DST_COLOR GL_DST_COLOR
#define BLEND_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_COLOR
#define BLEND_SRC_ALPHA_SATURATE GL_SRC_ALPHA_SATURATE
#define ARGB(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
#define RGBA(r, g, b, a) (((a) << 24) | ((b) << 16) | ((g) << 8) | (r))
#define TEXTURE_FORMAT 0
#define GU_PSM_8888 0
#define GU_PSM_5551 0
#define GU_PSM_4444 0
#define GU_PSM_5650 0
#define PIXEL_TYPE DWORD
#endif
typedef enum Buttons
{
JGE_BTN_NONE = 0, // No button pressed
JGE_BTN_QUIT, // Home on PSP
JGE_BTN_MENU, // Start on PSP
JGE_BTN_CTRL, // Select
JGE_BTN_POWER, // Hold
JGE_BTN_SOUND, // Music note
JGE_BTN_RIGHT,
JGE_BTN_LEFT,
JGE_BTN_UP,
JGE_BTN_DOWN,
JGE_BTN_OK, // Circle in Japan, Cross in Europe
JGE_BTN_CANCEL, // Triangle
JGE_BTN_PRI, // Square (primary)
JGE_BTN_SEC, // Cross or Circle (secondary)
JGE_BTN_PREV, // Left trigger
JGE_BTN_NEXT, // Right trigger
JGE_BTN_FULLSCREEN, // Switch to fullscreen (obviously, PC only)
JGE_BTN_MAX = JGE_BTN_FULLSCREEN + 1
} JButton;
#else
typedef uint32_t GLuint;
typedef float GLfloat;
#endif //CONSOLE_CONFIG
//------------------------------------------------------------------------------------------------
struct Vertex
@@ -357,7 +351,7 @@ public:
int mFilter;
#if defined (PSP)
#if defined (PSP)
int mTextureFormat;
int mTexId;
bool mInVideoRAM;
@@ -542,5 +536,28 @@ public:
};
typedef enum Buttons
{
JGE_BTN_NONE = 0, // No button pressed
JGE_BTN_QUIT, // Home on PSP
JGE_BTN_MENU, // Start on PSP
JGE_BTN_CTRL, // Select
JGE_BTN_POWER, // Hold
JGE_BTN_SOUND, // Music note
JGE_BTN_RIGHT,
JGE_BTN_LEFT,
JGE_BTN_UP,
JGE_BTN_DOWN,
JGE_BTN_OK, // Circle in Japan, Cross in Europe
JGE_BTN_CANCEL, // Triangle
JGE_BTN_PRI, // Square (primary)
JGE_BTN_SEC, // Cross or Circle (secondary)
JGE_BTN_PREV, // Left trigger
JGE_BTN_NEXT, // Right trigger
JGE_BTN_FULLSCREEN, // Switch to fullscreen (obviously, PC only)
JGE_BTN_MAX = JGE_BTN_FULLSCREEN + 1
} JButton;
#endif

View File

@@ -0,0 +1,23 @@
#ifndef OUTPUTCAPTURER_H
#define OUTPUTCAPTURER_H
#if defined(QT_CONFIG)
#include <Qt>
#include <string>
#include <sstream>
#include "Threading.h"
class OutputCapturer
{
private:
static std::ostringstream stream;
static boost::mutex mMutex;
public:
static void add(const std::string& s);
static void debugAndClear();
static void clear();
};
#endif
#endif // OUTPUTCAPTURER_H

View File

@@ -1,7 +1,7 @@
#ifndef THREADING_H
#define THREADING_H
#if !defined(PSP) && !defined(QT_CONFIG)
#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L)
#include <boost/date_time.hpp>
#ifdef WIN32
@@ -14,7 +14,7 @@
#endif
#include <boost/thread/mutex.hpp>
#elif !defined(QT_CONFIG)
#elif defined(PSP)
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
@@ -26,7 +26,7 @@
namespace boost
{
/**
** PSP specific variant of a boost mutex & scoped_lock
** PSP specific variant of a boost mutex & scoped_lock
*/
template <class Mutex>
@@ -60,7 +60,7 @@ namespace boost
{
sceKernelDeleteSema(mID);
}
void lock()
{
int result = sceKernelWaitSema(mID, 1, 0);
@@ -142,7 +142,7 @@ namespace boost
}
}
int mID;
int mThreadID;
volatile int mRecursionCount;
@@ -164,7 +164,7 @@ namespace boost
/**
** Emulating boost::thread configuration glue, with some shortcuts
** Emulating boost::thread configuration glue, with some shortcuts
** This detail namespace is a distillation of boost's thread.hpp, thread_data.hpp.
*/
namespace detail
@@ -212,13 +212,13 @@ namespace boost
**
** The intent of its usage is this form only:
** mWorkerThread = boost::thread(ThreadProc, this);
** where ThreadProc is a static member function of the 'this' class,eg:
** static void FOO::ThreadProc(void* inParam)
** {
** FOO* instance = reinterpret_cast<FOO*>(inParam);
** // now you have class instance data available...
** }
**
** where ThreadProc is a static member function of the 'this' class,eg:
** static void FOO::ThreadProc(void* inParam)
** {
** FOO* instance = reinterpret_cast<FOO*>(inParam);
** // now you have class instance data available...
** }
**
** Any other variant of a thread proc with more than one param is unimplemented.
*/
class thread
@@ -227,7 +227,7 @@ namespace boost
** Helper class for sceKernelStartThread, which passes args by value, not by reference
** We use this struct to wrap any pointers that we want to pass to the worker thread.
*/
struct CallbackData
struct CallbackData
{
CallbackData(detail::thread_data_ptr inThreadInfo)
: mThreadInfo(inThreadInfo)
@@ -307,7 +307,7 @@ namespace boost
}
}
#elif defined(QT_CONFIG)
#elif defined(QT_CONFIG) && (__cplusplus <= 199711L)
#include <QMutex>
#include <QThread>
@@ -315,7 +315,6 @@ namespace boost
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include "../include/DebugRoutines.h"
#include "../include/JLogger.h"
namespace boost
@@ -538,6 +537,80 @@ namespace boost
}
}
#elif (__cplusplus > 199711L)
#include <thread>
#include <mutex>
namespace boost
{
typedef std::thread thread;
template <class Mutex>
struct unique_lock
{
unique_lock(Mutex& inMutex) : mMutex(&inMutex)
{
mMutex->lock();
}
~unique_lock()
{
mMutex->unlock();
}
Mutex* mMutex;
};
class mutex
{
public:
typedef unique_lock<mutex> scoped_lock;
mutex()
: mQMutex()
{
}
~mutex()
{
}
void lock()
{
mQMutex.lock();
}
void unlock()
{
mQMutex.unlock();
}
std::mutex mQMutex;
private:
mutex(mutex const&);
mutex& operator=(mutex const&);
};
namespace posix_time
{
typedef unsigned int milliseconds;
}
/**
** boost's platform neutral sleep call.
*/
namespace this_thread
{
inline void sleep(boost::posix_time::milliseconds const& time)
{
std::this_thread::sleep_for(std::chrono::milliseconds(time));
}
}
}
#endif
#endif // THREADING_H

View File

@@ -3,15 +3,6 @@
#include <math.h>
/*************************** Macros and constants ***************************/
// returns a number ranging from -1.0 to 1.0
#define FRAND (((float)rand()-(float)rand())/RAND_MAX)
#define Clamp(x, min, max) x = (x<min ? min : x<max ? x : max);
#define SQUARE(x) (x)*(x)
struct Vector3D
{
Vector3D(float x, float y, float z) : x(x), y(y), z(z) {}
@@ -63,7 +54,7 @@ struct Vector3D
float Length()
{
float length = (float)sqrt(SQUARE(x) + SQUARE(y) + SQUARE(z));
float length = sqrt(x*x + y*y + z*z);
return (length != 0.0f) ? length : 1.0f;
}

View File

@@ -23,6 +23,19 @@
#include <QDBusInterface>
#endif //Q_WS_MAEMO_5
class WagicWrapper
{
public:
WagicWrapper();
virtual ~WagicWrapper();
private:
JGE* m_engine;
JApp* m_app;
JGameLauncher* m_launcher;
};
#ifdef QT_WIDGET
class WagicCore : public QGLWidget
#else
@@ -35,6 +48,7 @@ private:
#else
typedef QDeclarativeItem super;
#endif //QT_WIDGET
void initApp();
public:
Q_OBJECT
@@ -47,7 +61,7 @@ public:
public:
explicit WagicCore(super *parent = 0);
virtual ~WagicCore();
void initApp();
static int runTestSuite();
Q_INVOKABLE void doOK() {
doAndEnqueue(JGE_BTN_OK);
@@ -73,7 +87,7 @@ public:
Q_INVOKABLE qint64 getTick() {
return g_startTimer.elapsed();
};
Q_INVOKABLE void doScroll(int x, int y, int magnitude) {
Q_INVOKABLE void doScroll(int x, int y, int) {
m_engine->Scroll(x, y);
};
int getNominalHeight(){ return SCREEN_HEIGHT;};
@@ -122,6 +136,20 @@ signals:
private slots:
private:
int lastPosx(){
#if QT_VERSION >= 0x050100
return m_lastPos.x()*devicePixelRatio();
#else
return m_lastPos.x();
#endif
}
int lastPosy(){
#if QT_VERSION >= 0x050100
return m_lastPos.y()*devicePixelRatio();
#else
return m_lastPos.y();
#endif
}
void timerEvent( QTimerEvent* );
void doAndEnqueue(JButton action) {
m_engine->HoldKey_NoRepeat(action);
@@ -140,6 +168,7 @@ private:
int m_timerId;
bool m_active;
QRect m_viewPort;
QPoint m_lastPos;
#ifdef QT_WIDGET
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
int mMouseDownX;

298
JGE/src/Downloader.cpp Normal file
View File

@@ -0,0 +1,298 @@
#include "DebugRoutines.h"
#include "JFileSystem.h"
#include "Downloader.h"
#define RECORDS_DEFAULT_FILE "cache/records.txt"
#ifdef QT_CONFIG
QNetworkAccessManager DownloadRequest::networkAccessManager;
#endif
DownloadRequest::DownloadRequest(string localPath,
string remoteResourceURL,
string ETag,
DownloadStatus downloadStatus,
size_t totalSize,
size_t currentSize):
mLocalPath(localPath),
mRemoteResourceURL(remoteResourceURL),
mRequestedRemoteResourceURL(remoteResourceURL),
mETag(ETag),
mDownloadStatus(downloadStatus),
mUpgradeAvailable(false),
mTotalSize(totalSize),
mCurrentSize(currentSize)
{
}
DownloadRequest::~DownloadRequest()
{
}
void DownloadRequest::startHead()
{
#ifdef QT_CONFIG
QNetworkRequest request(QUrl(QString(mRequestedRemoteResourceURL.c_str())));
request.setRawHeader("If-None-Match", mETag.c_str());
mNetworkReply = networkAccessManager.head(request);
connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded()));
#endif
}
void DownloadRequest::startGet()
{
#ifdef QT_CONFIG
mNetworkReply = networkAccessManager.get(QNetworkRequest(QUrl(QString(mRequestedRemoteResourceURL.c_str()))));
#endif
mFile.close();
JFileSystem::GetInstance()->Remove(getTempLocalPath());
JFileSystem::GetInstance()->openForWrite(mFile, getTempLocalPath());
#ifdef QT_CONFIG
connect(mNetworkReply, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(downloadProgress(qint64, qint64)));
connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded()));
#endif
}
void DownloadRequest::fileDownloaded()
{
do {
QByteArray eTagByteArray = mNetworkReply->rawHeader("ETag");
if(!eTagByteArray.isEmpty()) {
string oldETag = mETag;
mETag = QString(eTagByteArray).toStdString();
if(oldETag!="" && oldETag != mETag)
mUpgradeAvailable = true;
}
// let's check some error
if(mNetworkReply->error() != QNetworkReply::NoError) {
DebugTrace(mNetworkReply->errorString().toStdString());
mDownloadStatus = DownloadRequest::DOWNLOAD_ERROR;
mFile.close();
JFileSystem::GetInstance()->Remove(getTempLocalPath());
break;
}
// check if we're getting redirected
QVariant redirectionTarget = mNetworkReply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (!redirectionTarget.isNull()) {
QUrl newUrl = QUrl(mRequestedRemoteResourceURL.c_str()).resolved(redirectionTarget.toUrl());
DebugTrace(string("Redirect to ")+ newUrl.toString().toStdString());
mRequestedRemoteResourceURL = newUrl.toString().toStdString();
mNetworkReply->deleteLater();
if(mFile.is_open())
startGet();
else
startHead();
return;
}
if(mFile.is_open())
{
QByteArray byteArray = mNetworkReply->readAll();
mFile.write(byteArray.constData(), byteArray.size());
mFile.close();
if(!JFileSystem::GetInstance()->Rename(getTempLocalPath(), mLocalPath)) {
mDownloadStatus = DownloadRequest::DOWNLOAD_ERROR;
break;
}
}
mDownloadStatus = DownloadRequest::DOWNLOADED;
} while(0);
Downloader::GetInstance()->Update();
mNetworkReply->deleteLater();
emit statusChanged((int)mDownloadStatus);
}
void DownloadRequest::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
QByteArray byteArray = mNetworkReply->readAll();
mFile.write(byteArray.constData(), byteArray.size());
mCurrentSize = bytesReceived;
mTotalSize = bytesTotal;
int percent = 0;
if(bytesTotal)
percent = (bytesReceived/bytesTotal)*100;
emit percentChanged(percent);
}
Downloader* Downloader::mInstance = 0;
Downloader::Downloader(string globalRemoteURL, string localcacheRecords):
mGlobalRemoteURL(globalRemoteURL),
mLocalCacheRecords(localcacheRecords)
{
JFileSystem::GetInstance()->MakeDir("cache");
izfstream downloadRecords;
if(mLocalCacheRecords.empty())
mLocalCacheRecords = RECORDS_DEFAULT_FILE;
if(JFileSystem::GetInstance()->openForRead(downloadRecords, mLocalCacheRecords))
{// File exists, let's read it.
downloadRecords >> (*this);
}
JFileSystem::GetInstance()->CloseFile();
}
Downloader::~Downloader()
{
map<string, DownloadRequest*>::iterator ite;
for(ite = mRequestMap.begin(); ite != mRequestMap.end(); ite++)
{
delete (*ite).second;
}
mRequestMap.erase(mRequestMap.begin(), mRequestMap.end());
}
Downloader* Downloader::GetInstance()
{
if(!mInstance)
{
mInstance = new Downloader();
}
return mInstance;
}
void Downloader::Release()
{
if(mInstance)
{
delete mInstance;
mInstance = 0;
}
}
bool DownloadRequest::NetworkIsAccessible()
{
bool result = false;
#ifdef QT_CONFIG
networkAccessManager.setNetworkAccessible(QNetworkAccessManager::Accessible);
result = networkAccessManager.networkAccessible();
#endif
return result;
}
DownloadRequest* Downloader::Get(string localPath, string remoteResourceURL)
{
map<string, DownloadRequest*>::iterator ite = mRequestMap.find(localPath);
if(ite == mRequestMap.end())
{ // request does not exist, let's create it
DownloadRequest* request = new DownloadRequest(localPath, remoteResourceURL);
std::pair<std::map<string,DownloadRequest*>::iterator,bool> ret;
ret = mRequestMap.insert ( std::pair<string,DownloadRequest*>(localPath, request) );
if (ret.second==false) {
DebugTrace("Downloader::Get Error inserting request in Map");
return 0;
}
ite = ret.first;
}
// Now, we can check the server
if((*ite).second->getDownloadStatus() == DownloadRequest::NOT_PRESENT ||
(*ite).second->upgradeAvailable())
{ // File is not here or an update is available, let's get it
(*ite).second->startGet();
(*ite).second->mDownloadStatus = DownloadRequest::DOWNLOADING;
}
else if ((*ite).second->getDownloadStatus() == DownloadRequest::DOWNLOADED)
{ // File is here, let's check if there is some update without blocking the playback
(*ite).second->startHead();
}
return (*ite).second;
}
void Downloader::Update()
{
ofstream downloadRecords;
if(JFileSystem::GetInstance()->openForWrite(downloadRecords, mLocalCacheRecords))
{
downloadRecords << (*this);
}
downloadRecords.close();
}
ostream& operator<<(ostream& out, const DownloadRequest& d)
{
// HEAD request fails, so this line erase cache record after upgrade check :(
// if(d.getDownloadStatus() == DownloadRequest::DOWNLOADED)
{
out << "localPath=" << d.mLocalPath << endl;
out << "remoteResource=" << d.mRemoteResourceURL << endl;
out << "ETag=" << d.mETag << endl;
out << "upgradeAvailable=" << d.mUpgradeAvailable <<endl;
}
return out;
}
istream& operator>>(istream& in, DownloadRequest& d)
{
string s;
while(std::getline(in, s))
{
size_t limiter = s.find("=");
string areaS;
if (limiter != string::npos)
{
areaS = s.substr(0, limiter);
if (areaS.compare("localPath") == 0)
{
d.mLocalPath = s.substr(limiter + 1);
}
else if (areaS.compare("remoteResource") == 0)
{
d.mRemoteResourceURL = s.substr(limiter + 1);
d.mRequestedRemoteResourceURL = d.mRemoteResourceURL;
}
else if (areaS.compare("ETag") == 0)
{
d.mETag = s.substr(limiter + 1);
d.mDownloadStatus = DownloadRequest::DOWNLOADED;
}
else if (areaS.compare("upgradeAvailable") == 0)
{
d.mUpgradeAvailable = (bool)atoi(s.substr(limiter + 1).c_str());
break;
}
}
}
return in;
}
ostream& operator<<(ostream& out, const Downloader& d)
{
map<string, DownloadRequest*>::const_iterator ite;
for(ite = d.mRequestMap.begin(); ite != d.mRequestMap.end(); ite++)
{
out << (*(*ite).second) << endl;
}
return out;
}
istream& operator>>(istream& in, Downloader& d)
{
while(!in.eof())
{
DownloadRequest* downloadRequest = new DownloadRequest();
in >> (*downloadRequest);
if(!downloadRequest->getLocalPath().empty() &&
!downloadRequest->getRemoteResource().empty() &&
!downloadRequest->getETag().empty()) {
d.mRequestMap[downloadRequest->getLocalPath()] = downloadRequest;
} else {
delete downloadRequest;
}
}
return in;
}

View File

@@ -67,7 +67,7 @@ bool JAnimator::Load(const char* scriptFile)
element = script->ToElement();
printf("---- Loading %s:%s\n", element->Value(), element->Attribute("name"));
const char *type[] =
string type[] =
{
"ANIMATION_TYPE_LOOPING",
"ANIMATION_TYPE_ONCE_AND_STAY",
@@ -78,7 +78,7 @@ bool JAnimator::Load(const char* scriptFile)
const char* aniType = element->Attribute("type");
for (int i=0;i<5;i++)
if (strcmp(type[i], aniType)==0)
if (type[i] == aniType)
{
SetAnimationType(i);
break;
@@ -108,7 +108,7 @@ bool JAnimator::Load(const char* scriptFile)
element = param->ToElement();
if (element != NULL)
{
if (strcmp(element->Value(), "settings")==0)
if (element->ValueStr() == "settings")
{
const char* quadName = element->Attribute("quad");
JQuad* quad = mResource->GetQuad(quadName);

View File

@@ -16,9 +16,9 @@ User folder is the only one that is really needed to guarantee both read and wri
The content that users should not be touching.
*/
#if defined(ANDROID)
#include "../../include/PrecompiledHeader.h"
#endif
#ifndef PSP
#include "PrecompiledHeader.h"
#endif //PSP
#ifdef WIN32
#pragma warning(disable : 4786)
@@ -34,6 +34,10 @@ The content that users should not be touching.
#include "../include/JLogger.h"
#include <dirent.h>
#ifdef QT_CONFIG
#include <QDir>
#endif
JFileSystem* JFileSystem::mInstance = NULL;
JZipCache::JZipCache()
@@ -121,11 +125,18 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
DebugTrace("User path " << userPath);
#elif defined (QT_CONFIG)
QDir sysDir(RESDIR);
QDir dir(QDir::homePath());
dir.mkdir(USERDIR);
dir.cd(USERDIR);
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
systemPath = "";
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
DebugTrace("User path " << userPath);
DebugTrace("System path " << systemPath);
DebugTrace("Current path " << QDir::currentPath().toStdString());
#else
//Find the Res.txt file and matching Res folders for backwards compatibility
ifstream mfile("Res.txt");
@@ -237,7 +248,7 @@ void JFileSystem::clearZipCache()
bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL */)
{
if (mZipAvailable && mZipFile != NULL)
if (mZipAvailable && mZipFile.is_open())
{
if (mZipFileName != zipfile)
DetachZipFile(); // close the previous zip file
@@ -302,11 +313,15 @@ bool JFileSystem::readIntoString(const string & FilePath, string & target)
int fileSize = GetFileSize(file);
#ifndef __MINGW32__
try {
#endif
target.resize((std::string::size_type) fileSize);
#ifndef __MINGW32__
} catch (bad_alloc&) {
return false;
}
#endif
if (fileSize)
@@ -320,6 +335,36 @@ bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_bas
{
string filename = mUserFSPath;
filename.append(FilePath);
#if defined(ANDROID)
DebugTrace("ANDROID");
std::vector<string> dirs;
string path = filename.substr( 0, filename.find_last_of( '/' ) + 1 );
// put it into list
dirs.push_back(path);
//make list of directories that need to be created
do
{
path = path.substr( 0, path.find_last_of( '/', path.size() - 2 ) + 1 );
dirs.push_back(path);
} while (path.compare(mUserFSPath) != 0);
// remove mUserFSPath from list
dirs.pop_back();
// create missing directories
for (std::vector<string>::reverse_iterator it = dirs.rbegin(); it != dirs.rend(); ++it)
{
if(!DirExists(*it))
{
MAKEDIR((*it).c_str());
}
}
#endif
File.open(filename.c_str(), mode);
if (File)
@@ -512,7 +557,13 @@ bool JFileSystem::Rename(string _from, string _to)
string from = mUserFSPath + _from;
string to = mUserFSPath + _to;
std::remove(to.c_str());
return rename(from.c_str(), to.c_str()) ? true: false;
return (rename(from.c_str(), to.c_str()) == 0);
}
bool JFileSystem::Remove(string aFile)
{
string toRemove = mUserFSPath + aFile;
return (std::remove(toRemove.c_str()) == 0);
}
int JFileSystem::GetFileSize(izfstream & file)

View File

@@ -591,6 +591,8 @@ void JGE::SendCommand(string command)
sendJNICommand(command);
#elif defined (IOS)
SendCommand(command, "");
#else
cerr << command;
#endif
}
@@ -602,6 +604,8 @@ void JGE::SendCommand(std::string command, std::string parameter)
[delegate handleWEngineCommand:[NSString stringWithCString: command.c_str() encoding: NSUTF8StringEncoding]
withParameter: [NSString stringWithCString: parameter.c_str() encoding:NSUTF8StringEncoding]];
#else
cerr << command << " " << parameter;
#endif
}
@@ -613,6 +617,8 @@ void JGE::SendCommand(std::string command, float& x, float& y, float& width, flo
#elif IOS
wagicAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate handleWEngineCommand: [NSString stringWithCString: command.c_str() encoding: NSUTF8StringEncoding] withUIParameters: x yCoordinate: y width: width height: height];
#else
cerr << command << " " << x << " " << y << " " << width << " " << height;
#endif
}
@@ -656,7 +662,6 @@ JNIEnv * JGE::getJNIEnv()
string JGE::getFileSystemLocation()
{
char result[512];
JNIEnv * env = getJNIEnv();
if (env == NULL)
{

506
JGE/src/JGfx-fake.cpp Normal file
View File

@@ -0,0 +1,506 @@
//-------------------------------------------------------------------------------------
//
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
#include "../../include/JGE.h"
#include "../../include/JRenderer.h"
#include "../../include/JResourceManager.h"
#include "../../include/JFileSystem.h"
#include "../../include/JAssert.h"
JQuad::JQuad(JTexture *tex, float x, float y, float width, float height)
:mTex(tex), mX(x), mY(y), mWidth(width), mHeight(height)
{
JASSERT(tex != NULL);
JRenderer::GetInstance()->TransferTextureToGLContext(*tex);
mHotSpotX = 0.0f;
mHotSpotY = 0.0f;
//mBlend = BLEND_DEFAULT;
for (int i=0;i<4;i++)
mColor[i].color = 0xFFFFFFFF;
mHFlipped = false;
mVFlipped = false;
SetTextureRect(x, y, width, height);
}
void JQuad::SetTextureRect(float x, float y, float w, float h)
{
mX = x;
mY = y;
mWidth = w;
mHeight = h;
if(mTex)
{
mTX0 = x/mTex->mTexWidth;
mTY0 = y/mTex->mTexHeight;
mTX1 = (x+w)/mTex->mTexWidth;
mTY1 = (y+h)/mTex->mTexHeight;
}
}
void JQuad::GetTextureRect(float *x, float *y, float *w, float *h)
{
*x=mX; *y=mY; *w=mWidth; *h=mHeight;
}
void JQuad::SetColor(PIXEL_TYPE color)
{
for (int i=0;i<4;i++)
mColor[i].color = color;
}
void JQuad::SetHotSpot(float x, float y)
{
mHotSpotX = x;
mHotSpotY = y;
}
//////////////////////////////////////////////////////////////////////////
JTexture::JTexture() : mWidth(0), mHeight(0), mBuffer(NULL)
{
mTexId = -1;
}
JTexture::~JTexture()
{
if (mBuffer)
{
delete [] mBuffer;
mBuffer = NULL;
}
}
void JTexture::UpdateBits(int x, int y, int width, int height, PIXEL_TYPE* bits)
{
JRenderer::GetInstance()->BindTexture(this);
}
//////////////////////////////////////////////////////////////////////////
JRenderer* JRenderer::mInstance = NULL;
bool JRenderer::m3DEnabled = false;
void JRenderer::Set3DFlag(bool flag) { m3DEnabled = flag; }
JRenderer* JRenderer::GetInstance()
{
if (mInstance == NULL)
{
mInstance = new JRenderer();
JASSERT(mInstance != NULL);
mInstance->InitRenderer();
}
return mInstance;
}
void JRenderer::Destroy()
{
if (mInstance)
{
mInstance->DestroyRenderer();
delete mInstance;
mInstance = NULL;
}
}
JRenderer::JRenderer() : mActualWidth(SCREEN_WIDTH_F), mActualHeight(SCREEN_HEIGHT_F)
{
}
JRenderer::~JRenderer()
{
}
void JRenderer::InitRenderer()
{
mCurrentTextureFilter = TEX_FILTER_NONE;
mImageFilter = NULL;
mCurrTexBlendSrc = BLEND_SRC_ALPHA;
mCurrTexBlendDest = BLEND_ONE_MINUS_SRC_ALPHA;
// mLineWidth = 1.0f;
mCurrentTex = -1;
mFOV = 75.0f;
#ifdef USING_MATH_TABLE
for (int i=0;i<360;i++)
{
mSinTable[i] = sinf(i*DEG2RAD);
mCosTable[i] = cosf(i*DEG2RAD);
}
#endif
mCurrentRenderMode = MODE_UNKNOWN;
}
void JRenderer::DestroyRenderer()
{
}
void JRenderer::BeginScene()
{
}
void JRenderer::EndScene()
{
}
void JRenderer::BindTexture(JTexture *tex)
{
}
void JRenderer::EnableTextureFilter(bool flag)
{
if (flag)
mCurrentTextureFilter = TEX_FILTER_LINEAR;
else
mCurrentTextureFilter = TEX_FILTER_NEAREST;
mCurrentTex = -1;
}
void Swap(float *a, float *b)
{
float n=*a;
*a = *b;
*b = n;
}
void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float xScale, float yScale)
{
//yo = SCREEN_HEIGHT-yo-1;//-(quad->mHeight);
float width = quad->mWidth;
float height = quad->mHeight;
float x = -quad->mHotSpotX;
float y = quad->mHotSpotY;
Vector2D pt[4];
pt[3] = Vector2D(x, y);
pt[2] = Vector2D(x+width, y);
pt[1] = Vector2D(x+width, y-height);
pt[0] = Vector2D(x, y-height);
Vector2D uv[4];
uv[0] = Vector2D(quad->mTX0, quad->mTY1);
uv[1] = Vector2D(quad->mTX1, quad->mTY1);
uv[2] = Vector2D(quad->mTX1, quad->mTY0);
uv[3] = Vector2D(quad->mTX0, quad->mTY0);
if (quad->mHFlipped)
{
Swap(&uv[0].x, &uv[1].x);
Swap(&uv[2].x, &uv[3].x);
}
if (quad->mVFlipped)
{
Swap(&uv[0].y, &uv[2].y);
Swap(&uv[1].y, &uv[3].y);
}
BindTexture(quad->mTex);
yo = SCREEN_HEIGHT_F - yo;
}
void JRenderer::RenderQuad(JQuad* quad, VertexColor* pt)
{
for (int i=0;i<4;i++)
{
pt[i].y = SCREEN_HEIGHT_F - pt[i].y;
quad->mColor[i].color = pt[i].color;
}
Vector2D uv[4];
uv[0] = Vector2D(quad->mTX0, quad->mTY1);
uv[1] = Vector2D(quad->mTX1, quad->mTY1);
uv[2] = Vector2D(quad->mTX1, quad->mTY0);
uv[3] = Vector2D(quad->mTX0, quad->mTY0);
BindTexture(quad->mTex);
}
void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE color)
{
y = SCREEN_HEIGHT_F - y - height;
JColor col;
col.color = color;
}
void JRenderer::DrawRect(float x, float y, float width, float height, PIXEL_TYPE color)
{
y = SCREEN_HEIGHT_F - y - height;
JColor col;
col.color = color;
}
void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE* colors)
{
JColor col[4];
for (int i=0;i<4;i++)
col[i].color = colors[i];
FillRect(x, y, width, height, col);
}
void JRenderer::FillRect(float x, float y, float width, float height, JColor* colors)
{
y = SCREEN_HEIGHT_F - y - height;
}
void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE color)
{
// glLineWidth (mLineWidth);
JColor col;
col.color = color;
}
void JRenderer::Plot(float x, float y, PIXEL_TYPE color)
{
}
void JRenderer::PlotArray(float *x, float *y, int count, PIXEL_TYPE color)
{
}
void JRenderer::ScreenShot(const char* filename __attribute__((unused)))
{
}
void JRenderer::TransferTextureToGLContext(JTexture& inTexture)
{
}
JTexture* JRenderer::CreateTexture(int width, int height, int mode __attribute__((unused)))
{
JTexture *tex = new JTexture();
return tex;
}
JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureFormat)
{
JTexture *tex = new JTexture();
return tex;
}
void JRenderer::EnableVSync(bool flag __attribute__((unused)))
{
// if (flag)
// hge->System_SetState(HGE_FPS, 60); // HGEFPS_VSYNC
// else
// hge->System_SetState(HGE_FPS, HGEFPS_UNLIMITED);
}
void JRenderer::ClearScreen(PIXEL_TYPE color)
{
}
void JRenderer::SetTexBlend(int src, int dest)
{
}
void JRenderer::SetTexBlendSrc(int src)
{
}
void JRenderer::SetTexBlendDest(int dest)
{
}
void JRenderer::Enable2D()
{
}
void JRenderer::Enable3D()
{ /* NOT USED
if (!m3DEnabled)
return;
if (mCurrentRenderMode == MODE_3D)
return;
mCurrentRenderMode = MODE_3D;
glViewport (0, 0, (GLsizei)SCREEN_WIDTH, (GLsizei)SCREEN_HEIGHT); // Reset The Current Viewport
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
gluPerspective (mFOV, (GLfloat)SCREEN_WIDTH/(GLfloat)SCREEN_HEIGHT, // Calculate The Aspect Ratio Of The Window
0.5f, 1000.0f);
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity (); // Reset The Modelview Matrix
glEnable (GL_DEPTH_TEST); */
}
void JRenderer::SetClip(int, int, int, int)
{// NOT USED
//glScissor(x, y, width, height);
}
void JRenderer::LoadIdentity()
{// NOT USED
//glLoadIdentity();
}
void JRenderer::Translate(float, float, float)
{// NOT USED
//glTranslatef(x, y, z);
}
void JRenderer::RotateX(float)
{// NOT USED
//glRotatef(angle*RAD2DEG, 1.0f, 0.0f, 0.0f);
}
void JRenderer::RotateY(float)
{// NOT USED
//glRotatef(angle*RAD2DEG, 0.0f, 1.0f, 0.0f);
}
void JRenderer::RotateZ(float)
{// NOT USED
//glRotatef(angle*RAD2DEG, 0.0f, 0.0f, 1.0f);
}
void JRenderer::PushMatrix()
{// NOT USED
//glPushMatrix();
}
void JRenderer::PopMatrix()
{// NOT USED
//glPopMatrix();
}
void JRenderer::RenderTriangles(JTexture* texture, Vertex3D *vertices, int start, int count)
{
}
void JRenderer::SetFOV(float fov)
{
mFOV = fov;
}
void JRenderer::FillPolygon(float* x, float* y, int count, PIXEL_TYPE color)
{
}
void JRenderer::DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color)
{
}
void JRenderer::DrawLine(float x1, float y1, float x2, float y2, float lineWidth, PIXEL_TYPE color)
{
float dy=y2-y1;
float dx=x2-x1;
if(dy==0 && dx==0)
return;
float l=(float)hypot(dx,dy);
float x[4];
float y[4];
x[0]=x1+lineWidth*(y2-y1)/l;
y[0]=y1-lineWidth*(x2-x1)/l;
x[1]=x1-lineWidth*(y2-y1)/l;
y[1]=y1+lineWidth*(x2-x1)/l;
x[2]=x2-lineWidth*(y2-y1)/l;
y[2]=y2+lineWidth*(x2-x1)/l;
x[3]=x2+lineWidth*(y2-y1)/l;
y[3]=y2-lineWidth*(x2-x1)/l;
FillPolygon(x, y, 4, color);
}
void JRenderer::DrawCircle(float x, float y, float radius, PIXEL_TYPE color)
{
}
void JRenderer::FillCircle(float x, float y, float radius, PIXEL_TYPE color)
{
}
void JRenderer::DrawPolygon(float x, float y, float size, int count, float startingAngle, PIXEL_TYPE color)
{
}
void JRenderer::FillPolygon(float x, float y, float size, int count, float startingAngle, PIXEL_TYPE color)
{
}
void JRenderer::SetImageFilter(JImageFilter* imageFilter)
{
mImageFilter = imageFilter;
}
void JRenderer::DrawRoundRect(float x, float y, float w, float h, float radius, PIXEL_TYPE color)
{
}
void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius, PIXEL_TYPE color)
{
}

View File

@@ -49,12 +49,13 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
sprintf(filename, "%s.png", fontname);
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
mTextureScale = (float) lineheight/ (mTexture->mHeight/16);
if (mTexture == NULL) return;
if (mTexture == NULL) return;
mHeight = (float) lineheight;
mQuad = new JQuad(mTexture, 0.0f, 0.0f, 16.0f, mHeight);
mQuad = new JQuad(mTexture, 0.0f, 0.0f, 16.0f/mTextureScale, mHeight/mTextureScale);
float a, b, c;
@@ -158,7 +159,7 @@ void JLBFont::DrawString(const char *string, float x, float y, int align, float
index = (*p - 32)+mBase;
float charWidth = mCharWidth[index];
float charWidth = mCharWidth[index]*mTextureScale;
float delta = (charWidth + mTracking) * mScale;
float xPos = mXPos[index];
if (leftOffset)
@@ -194,8 +195,8 @@ void JLBFont::DrawString(const char *string, float x, float y, int align, float
charWidth = (delta/mScale) - mTracking;
}
}
mQuad->SetTextureRect(xPos, mYPos[index], charWidth , mHeight);
mRenderer->RenderQuad(mQuad, dx, dy, mRotation, mScale, mScale);
mQuad->SetTextureRect(xPos, mYPos[index], charWidth/mTextureScale, mHeight/mTextureScale);
mRenderer->RenderQuad(mQuad, dx, dy, mRotation, mScale*mTextureScale, mScale*mTextureScale);
dx += delta;
p++;
}
@@ -235,7 +236,7 @@ float JLBFont::GetStringWidth(const char *string) const
ch = *p - 32;
p++;
if (ch < 0) continue;
len += mCharWidth[ch+mBase] + mTracking;
len += (mCharWidth[ch+mBase]*mTextureScale) + mTracking;
}
len -= mTracking;
return len*mScale;

View File

@@ -257,6 +257,8 @@ void JMD2Model::CalculateNormal(float *p1, float *p2, float *p3)
#else
// FIXME
#endif
#else
cerr << p1 << " " << p2 << " " << p3 << endl;
#endif
}

View File

@@ -33,15 +33,43 @@
#include <sstream>
#include "../include/JSocket.h"
map<string, processCmd> JNetwork::sCommandMap;
map<string, JNetwork::CommandStruc> JNetwork::sCommandMap;
bool JNetwork::isConnected(){
if (connected_to_ap !=1) return false;
if (connected_to_ap !=1 || !socket) return false;
return socket->isConnected();
}
void JNetwork::getServerIp(string& aString)
{
#ifdef WIN32
char ac[80];
if (gethostname(ac, sizeof(ac)) == SOCKET_ERROR) {
DebugTrace("Error " << WSAGetLastError() <<
" when getting local host name.\n");
return;
}
DebugTrace( "Host name is " << ac << ".\n");
struct hostent *phe = gethostbyname(ac);
if (phe == 0) {
DebugTrace("Yow! Bad host lookup.\n");
return;
}
for (int i = 0; phe->h_addr_list[i] != 0; ++i) {
struct in_addr addr;
memcpy(&addr, phe->h_addr_list[i], sizeof(struct in_addr));
aString = inet_ntoa(addr);
}
#else
aString = "No clue";
#endif
}
JNetwork::JNetwork()
: mpWorkerThread(NULL)
: mpWorkerThread(NULL), socket(0)
{
#if (defined WIN32) || (defined LINUX)
connected_to_ap = 1;
@@ -62,30 +90,68 @@ JNetwork::~JNetwork()
delete socket;
}
bool JNetwork::sendCommand(string xString)
bool JNetwork::sendCommand(const string& xString, const string& payload, const string& suffix)
{
string aString = xString;
string aString;
boost::mutex::scoped_lock l(sendMutex);
if(!socket) {
DebugTrace("sendCommand failed: no sockeet");
DebugTrace("sendCommand failed: no socket");
return false;
}
aString = aString + "Command";
aString = xString + suffix;
if(sCommandMap.find(aString) == sCommandMap.end()) {
DebugTrace("sendCommand failed: command not registered");
return false;
}
aString = aString + "\n";
aString = "<" + aString + ">" + "\n" + payload + "\n" + "<" + aString + "/>";
toSend << aString;
return true;
}
void JNetwork::registerCommand(string command, processCmd processCommand, processCmd processResponse)
void JNetwork::registerCommand(string command, void* object, processCmd processCommand, processCmd processResponse)
{
sCommandMap[command + "Command"] = processCommand;
sCommandMap[command + "Response"] = processResponse;
CommandStruc struc;
struc.object = object;
struc.command = command;
struc.processCommand = processCommand;
sCommandMap[command + "Request"] = struc;
struc.processCommand = processResponse;
sCommandMap[command + "Response"] = struc;
}
void JNetwork::Update()
{
boost::mutex::scoped_lock r(receiveMutex);
// Checking for some command to execute
size_t begin_start_tag = received.str().find("<");
size_t end_start_tag = received.str().find(">");
string command = received.str().substr(begin_start_tag+1, end_start_tag-(begin_start_tag+1));
size_t begin_end_tag = received.str().find(command + "/>");
size_t end_end_tag = received.str().find("/>");
if(begin_start_tag != string::npos && begin_end_tag != string::npos )
{
map<string, CommandStruc>::iterator ite = sCommandMap.find(command);
if(ite != sCommandMap.end())
{
DebugTrace("begin of command received : " + received.str() );
DebugTrace("begin of command toSend : " + toSend.str() );
processCmd theMethod = (ite)->second.processCommand;
stringstream input(received.str().substr(end_start_tag+1, (begin_end_tag-1)-(end_start_tag+1)));
stringstream output;
theMethod((ite)->second.object, input, output);
string aString = received.str().substr(end_end_tag+2, string::npos);
received.str(aString);
if(output.str().size())
sendCommand((ite)->second.command, output.str(), "Response");
DebugTrace("end of command received : "<< received.str() );
DebugTrace("end of command toSend : "<< toSend.str() );
}
}
}
void JNetwork::ThreadProc(void* param)
@@ -105,71 +171,33 @@ void JNetwork::ThreadProc(void* param)
}
while(pSocket && pSocket->isConnected()) {
char buff[1024];
char buff[4096];
{
boost::mutex::scoped_lock l(pThis->receiveMutex);
int len = pSocket->Read(buff, sizeof(buff));
if(len) {
if(len > 0) {
boost::mutex::scoped_lock l(pThis->receiveMutex);
DebugTrace("receiving " << len << " bytes : " << buff);
pThis->received << buff;
}
// Checking for some command to execute
size_t found = pThis->received.str().find("Command");
if(found != string::npos)
{
map<string, processCmd>::iterator ite = sCommandMap.find((pThis->received.str()).substr(0, found) + "Command");
if(ite != sCommandMap.end())
{
DebugTrace("begin of command received : "<< pThis->received.str() );
DebugTrace("begin of command toSend : "<< pThis->toSend.str() );
boost::mutex::scoped_lock l(pThis->sendMutex);
pThis->toSend << pThis->received.str().substr(0, found) + "Response ";
pThis->received.str("");
processCmd theMethod = (ite)->second;
theMethod(pThis->received, pThis->toSend);
DebugTrace("end of command received : "<< pThis->received.str() );
DebugTrace("end of command toSend : "<< pThis->toSend.str() );
}
}
// Checking for some response to execute
found = pThis->received.str().find("Response");
if(found != string::npos)
{
map<string, processCmd>::iterator ite = sCommandMap.find((pThis->received.str()).substr(0, found) + "Response");
if(ite != sCommandMap.end())
{
DebugTrace("begin of response received : "<< pThis->received.str() );
DebugTrace("begin of response toSend : "<< pThis->toSend.str() );
boost::mutex::scoped_lock l(pThis->sendMutex);
string aString;
pThis->received >> aString;
processCmd theMethod = (ite)->second;
theMethod(pThis->received, pThis->toSend);
pThis->received.str("");
DebugTrace("end of response received : "<< pThis->received.str() );
DebugTrace("end of response toSend : "<< pThis->toSend.str() );
}
pThis->received.str(pThis->received.str() + buff);
DebugTrace("received " << pThis->received.str().size() << " bytes : " << pThis->received.str());
}
}
boost::mutex::scoped_lock l(pThis->sendMutex);
if(!pThis->toSend.str().empty())
{
DebugTrace("sending " << pThis->toSend.str().size() << " bytes : " << pThis->toSend.str());
pSocket->Write((char*)pThis->toSend.str().c_str(), pThis->toSend.str().size()+1);
pThis->toSend.str("");
}
{
boost::mutex::scoped_lock l(pThis->sendMutex);
if(!pThis->toSend.str().empty())
{
DebugTrace("sending " << pThis->toSend.str().size() << " bytes : " << pThis->toSend.str());
pSocket->Write((char*)pThis->toSend.str().c_str(), pThis->toSend.str().size()+1);
pThis->toSend.str("");
}
}
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
}
DebugTrace("Quitting Thread");
}
#if defined (WIN32) || defined (LINUX)
int JNetwork::connect(string ip)
int JNetwork::connect(const string& ip)
{
if (mpWorkerThread) return 0;
serverIP = ip;
@@ -179,7 +207,7 @@ int JNetwork::connect(string ip)
#else
int JNetwork::connect(string serverIP){
int JNetwork::connect(const string& serverIP){
#ifdef NETWORK_SUPPORT
int err;
char buffer[4096];

View File

@@ -75,10 +75,10 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
int count;
while (filePtr < size)
{
while (filePtr < size)
{
filePtr = ReadLine(tmpLine, buffer, filePtr, size);
{
{
if ((tmpLine[0] == '#') || (strlen(tmpLine) < 3))
{
@@ -89,19 +89,19 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
if (count == 4)
{
if (strcmp(s1, "vn") == 0)
if (string("vn") == s1)
normalList.push_back(vert);
else if (strcmp(s1, "vt") == 0)
else if (string("vt") == s1)
texList.push_back(vert);
else if (strcmp(s1, "v") == 0)
else if (string("v") == s1)
vertList.push_back(vert);
}
else if (count == 3)
{
if (strcmp(s1, "vt") == 0)
if (string("vt") == s1)
texList.push_back(vert);
}
}
else if (tmpLine[0] == 'f')
{
@@ -211,7 +211,7 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
if (textureName != NULL)
mTexture = JRenderer::GetInstance()->LoadTexture(textureName);
return true;
return true;
}

View File

@@ -90,7 +90,7 @@ bool JParticleEffect::Load(const char* filename)
// FIELD_COUNT
// };
const char* lifeValues[] =
const string lifeValues[] =
{
"speed",
"size",
@@ -104,7 +104,7 @@ bool JParticleEffect::Load(const char* filename)
"gravity"
};
const char* typeNames[] =
const string typeNames[] =
{
"POINT",
"AREA",
@@ -113,7 +113,7 @@ bool JParticleEffect::Load(const char* filename)
"CIRCLE"
};
const char* modeNames[] =
const string modeNames[] =
{
"REPEAT",
"ONCE",
@@ -149,32 +149,32 @@ bool JParticleEffect::Load(const char* filename)
{
element = param->ToElement();
if (strcmp(element->Attribute("name"), "settings")==0)
if (string("settings") == element->Attribute("name"))
{
if (strcmp(element->Attribute("blend"), "NORMAL")==0)
if (string("NORMAL") == element->Attribute("blend"))
mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
else if (strcmp(element->Attribute("blend"), "ADDITIVE")==0)
else if (string("ADDITIVE") == element->Attribute("blend"))
mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE);
for (unsigned int i=0;i<sizeof(modeNames)/sizeof(char*);i++)
{
if (strcmp(element->Attribute("mode"), modeNames[i])==0)
if (modeNames[i] == element->Attribute("mode"))
{
mParticleEmitters[mEmitterCount]->mEmitterMode = i;
#if defined (_DEBUG)
printf("emitter mode:%s\n", modeNames[i]);
printf("emitter mode:%s\n", modeNames[i].c_str());
#endif
break;
}
}
for (unsigned i=0;i<sizeof(typeNames)/sizeof(char*);i++)
{
if (strcmp(element->Attribute("type"), typeNames[i])==0)
if (typeNames[i] == element->Attribute("type"))
{
mParticleEmitters[mEmitterCount]->mType = i;
#if defined (_DEBUG)
printf("emitter type:%s\n", typeNames[i]);
printf("emitter type:%s\n", typeNames[i].c_str());
#endif
break;
}
@@ -213,7 +213,7 @@ bool JParticleEffect::Load(const char* filename)
}
}
else if (strcmp(element->Attribute("name"), "quantity")==0)
else if (string("quantity") == element->Attribute("name"))
{
for (key = param->FirstChild(); key; key = key->NextSibling())
{
@@ -227,7 +227,7 @@ bool JParticleEffect::Load(const char* filename)
}
}
else if (strcmp(element->Attribute("name"), "lifex")==0)
else if (string("lifex") == element->Attribute("name"))
{
if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS &&
element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS)
@@ -236,7 +236,7 @@ bool JParticleEffect::Load(const char* filename)
mParticleEmitters[mEmitterCount]->mLifeMax= value;
}
}
else if (strcmp(element->Attribute("name"), "anglex")==0)
else if (string("anglex") == element->Attribute("name"))
{
if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS &&
element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS)
@@ -245,7 +245,7 @@ bool JParticleEffect::Load(const char* filename)
mParticleEmitters[mEmitterCount]->mAngleMax= value*DEG2RAD;
}
}
else if (strcmp(element->Attribute("name"), "speedx")==0)
else if (string("speedx") == element->Attribute("name"))
{
if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS &&
element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS)
@@ -254,7 +254,7 @@ bool JParticleEffect::Load(const char* filename)
mParticleEmitters[mEmitterCount]->mSpeedMax= value;
}
}
else if (strcmp(element->Attribute("name"), "sizex")==0)
else if (string("sizex") == element->Attribute("name"))
{
if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS &&
element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS)
@@ -267,7 +267,7 @@ bool JParticleEffect::Load(const char* filename)
{
for (int i=0;i<FIELD_COUNT;i++)
{
if (strcmp(element->Attribute("name"), lifeValues[i])==0)
if (lifeValues[i] == element->Attribute("name"))
{
for (key = param->FirstChild(); key; key = key->NextSibling())
{

View File

@@ -16,7 +16,7 @@
#include "../include/JLBFont.h"
#include "tinyxml/tinyxml.h"
#if defined (_DEBUG) && defined (WIN32)
#if defined (_DEBUG) && defined (WIN32) && (!defined LINUX)
#include "crtdbg.h"
#define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#else
@@ -119,11 +119,11 @@ bool JResourceManager::LoadResource(const string& resourceName)
element = node->ToElement();
if (element != NULL)
{
if (strcmp(element->Value(), "texture")==0)
if (element->ValueStr() == "texture")
{
CreateTexture(element->Attribute("name"));
}
else if (strcmp(element->Value(), "quad")==0)
else if (element->ValueStr() == "quad")
{
string quadName = element->Attribute("name");
string textureName = element->Attribute("texture");
@@ -170,7 +170,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
GetQuad(id)->SetHotSpot(hotspotX, hotspotY);
}
}
else if (strcmp(element->Value(), "font")==0)
else if (element->ValueStr() == "font")
{
}

View File

@@ -1,4 +1,3 @@
#if 0
// need a complete rewrite to comply to the new interface
#ifdef NETWORK_SUPPORT
@@ -21,23 +20,21 @@
#endif
#include "../include/JGE.h"
#include "../include/JSocket.h"
JSocket * JSocket::mInstance = NULL;
#define SERVER_PORT 20666
int JSocket::connected = 0;
void JSocket::init(){
JSocket::JSocket(){
#ifdef NETWORK_SUPPORT
sceUtilityLoadNetModule(1);
sceUtilityLoadNetModule(3);
#endif
}
JSocket::JSocket(){
init();
JSocket::JSocket(string ipAddr)
{
}
JSocket::JSocket(int fd)
{
}
JSocket::~JSocket(){
@@ -48,7 +45,27 @@ JSocket::~JSocket(){
#endif
}
void JSocket::Disconnect()
{
}
JSocket* JSocket::Accept()
{
return 0;
}
int JSocket::Read(char* buff, int size)
{
return 0;
}
int JSocket::Write(char* buff, int size)
{
return 0;
}
#if 0
int JSocket::make_socket(uint16_t port)
{
int sock = -1;

View File

@@ -0,0 +1,22 @@
#include "../include/OutputCapturer.h"
std::ostringstream OutputCapturer::stream;
boost::mutex OutputCapturer::mMutex;
void OutputCapturer::add(const std::string& s)
{
boost::mutex::scoped_lock lock(mMutex);
stream << s << "\n";
}
void OutputCapturer::debugAndClear()
{
stream.flush();
qDebug("%s", stream.str().c_str());
stream.str("");
}
void OutputCapturer::clear()
{
stream.str("");
}

105
JGE/src/Qtconsole.cpp Normal file
View File

@@ -0,0 +1,105 @@
#include "../include/JGE.h"
#include "../include/JTypes.h"
#include "../include/JApp.h"
#include "../include/JFileSystem.h"
#include "../include/JRenderer.h"
#include "../include/JGameLauncher.h"
#include "TestSuiteAI.h"
#include "GameOptions.h"
#include "MTGDeck.h"
#include "DebugRoutines.h"
#include <QCoreApplication>
#include <QElapsedTimer>
class WagicWrapper
{
public:
WagicWrapper();
virtual ~WagicWrapper();
public:
// used mainly to mesure the delta between 2 updates
static QElapsedTimer g_startTimer;
private:
JGE* m_engine;
JApp* m_app;
JGameLauncher* m_launcher;
};
QElapsedTimer WagicWrapper::g_startTimer;
int JGEGetTime()
{
return (int)WagicWrapper::g_startTimer.elapsed();
}
bool JGEToggleFullscreen()
{
return true;
}
void JGECreateDefaultBindings()
{
}
WagicWrapper::WagicWrapper()
{
m_launcher = new JGameLauncher();
u32 flags = m_launcher->GetInitFlags();
if ((flags&JINIT_FLAG_ENABLE3D)!=0)
{
JRenderer::Set3DFlag(true);
}
JGECreateDefaultBindings();
m_engine = JGE::GetInstance();
m_app = m_launcher->GetGameApp();
m_app->Create();
m_engine->SetApp(m_app);
JRenderer::GetInstance()->Enable2D();
g_startTimer.restart();
}
WagicWrapper::~WagicWrapper()
{
if(m_launcher)
{
delete m_launcher;
m_launcher = NULL;
}
if(m_engine)
m_engine->SetApp(NULL);
if (m_app)
{
m_app->Destroy();
delete m_app;
m_app = NULL;
}
JGE::Destroy();
m_engine = NULL;
}
int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
int result = 0;
WagicWrapper* wagicCore = new WagicWrapper();
MTGCollection()->loadFolder("sets/primitives/");
MTGCollection()->loadFolder("sets/", "_cards.dat");
options.reloadProfile();
TestSuite testSuite("test/_tests.txt");
result = testSuite.run();
delete wagicCore;
DebugTrace("TestSuite done: failed test: " << result << " out of " << testSuite.nbTests + testSuite.nbAITests << " total");
#ifdef CAPTURE_STDERR
OutputCapturer::debugAndClear();
#endif
return result;
}

View File

@@ -1,7 +1,7 @@
#define GL_GLEXT_PROTOTYPES
#include <QtOpenGL>
#include <QTime>
#include <QtGui/QApplication>
#include <QApplication>
#include <QScopedPointer>
#ifdef QT_WIDGET
#include <QWidget>
@@ -9,11 +9,11 @@
#include <QtDeclarative>
#include "qmlapplicationviewer.h"
#endif //QT_WIDGET
#include "filedownloader.h"
#include "Downloader.h"
#include "GameApp.h"
#include "corewrapper.h"
QWidget* g_glwidget = NULL;
WagicCore* g_glwidget = NULL;
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
{
@@ -68,11 +68,26 @@ int main(int argc, char* argv[])
(createApplication(argc, argv));
#endif //QT_WIDGET
app->setApplicationName(WagicCore::getApplicationName());
FileDownloader fileDownloader(USERDIR, WAGIC_RESOURCE_NAME);
DownloadRequest* downloadRequest = NULL;
#ifdef WAGIC_RESOURCE_URL
Downloader*downloader = Downloader::GetInstance();
downloadRequest = downloader->Get(
"core.zip",
WAGIC_RESOURCE_URL
);
#endif
#ifdef QT_WIDGET
g_glwidget = new WagicCore();
g_glwidget->connect(&fileDownloader, SIGNAL(finished(int)), SLOT(start(int)));
if(!downloadRequest || downloadRequest->getDownloadStatus() == DownloadRequest::DOWNLOADED)
{
g_glwidget->start(0);
}
else
{
g_glwidget->connect(downloadRequest, SIGNAL(statusChanged(int)), SLOT(start(int)));
}
#else
qmlRegisterType<WagicCore>("CustomComponents", 1, 0, "WagicCore");

View File

@@ -78,7 +78,20 @@ extern "C" void Java_org_libsdl_app_SDLActivity_nativeResume(
{
if (!g_engine)
return;
g_engine->Resume();
g_engine->Resume();
}
#include "Wagic_Version.h"
extern "C" jstring Java_org_libsdl_app_SDLActivity_getResourceName(
JNIEnv* env, jclass cls)
{
return env->NewStringUTF (WAGIC_RESOURCE_NAME);
}
extern "C" jstring Java_org_libsdl_app_SDLActivity_getResourceUrl(
JNIEnv* env, jclass cls)
{
return env->NewStringUTF (WAGIC_RESOURCE_URL);
}
#endif

View File

@@ -10,6 +10,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
//////////////////////////////////////////////////////////////////////////
@@ -158,46 +159,53 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
{
// we should use the native asset manager instead
string fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
int fd = open(fullpath.c_str(), O_RDONLY);
FILE* file = fdopen(fd, "r");
off_t start = 0;
off_t length;
fseek(file, 0, SEEK_END);
length = ftell(file);
SLresult result;
// configure audio source
SLDataLocator_AndroidFD loc_fd = {SL_DATALOCATOR_ANDROIDFD, fd, start, length};
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
SLDataSource audioSrc = {&loc_fd, &format_mime};
if(fullpath.compare("") != 0)
{
int fd = open(fullpath.c_str(), O_RDONLY);
FILE* file = fdopen(fd, "r");
off_t start = 0;
off_t length;
fseek(file, 0, SEEK_END);
length = ftell(file);
SLresult result;
// configure audio sink
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject};
SLDataSink audioSnk = {&loc_outmix, NULL};
// configure audio source
SLDataLocator_AndroidFD loc_fd = {SL_DATALOCATOR_ANDROIDFD, fd, start, length};
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
SLDataSource audioSrc = {&loc_fd, &format_mime};
// create audio player
const SLInterfaceID ids[2] = {SL_IID_SEEK, SL_IID_VOLUME};
const SLboolean req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &music->playerObject, &audioSrc, &audioSnk,
2, ids, req);
DebugTrace("result " << result);
// configure audio sink
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject};
SLDataSink audioSnk = {&loc_outmix, NULL};
// realize the player
result = (*music->playerObject)->Realize(music->playerObject, SL_BOOLEAN_FALSE);
DebugTrace("result " << result);
// create audio player
const SLInterfaceID ids[2] = {SL_IID_SEEK, SL_IID_VOLUME};
const SLboolean req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &music->playerObject, &audioSrc, &audioSnk, 2, ids, req);
DebugTrace("result " << result);
// get the play interface
result = (*music->playerObject)->GetInterface(music->playerObject, SL_IID_PLAY, &music->playInterface);
DebugTrace("result " << result);
// realize the player
result = (*music->playerObject)->Realize(music->playerObject, SL_BOOLEAN_FALSE);
DebugTrace("result " << result);
// get the seek interface
result = (*music->playerObject)->GetInterface(music->playerObject, SL_IID_SEEK, &music->seekInterface);
DebugTrace("result " << result);
// get the play interface
result = (*music->playerObject)->GetInterface(music->playerObject, SL_IID_PLAY, &music->playInterface);
DebugTrace("result " << result);
// get the volume interface
//result = (*music->playerObject)->GetInterface(music->playerObject, SL_IID_VOLUME, (void *)&music->musicVolumeInterface);
DebugTrace("result " << result);
// get the seek interface
result = (*music->playerObject)->GetInterface(music->playerObject, SL_IID_SEEK, &music->seekInterface);
DebugTrace("result " << result);
// get the volume interface
//result = (*music->playerObject)->GetInterface(music->playerObject, SL_IID_VOLUME, (void *)&music->musicVolumeInterface);
DebugTrace("result " << result);
}
else
{
DebugTrace("Bad path to music file");
}
}
mCurrentMusic = music;
@@ -215,12 +223,10 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
//(*music->musicVolumeInterface)->SetVolumeLevel(music->musicVolumeInterface, -1 * mVolume);
// enable whole file looping
result = (*music->seekInterface)->SetLoop(music->seekInterface,
looping?SL_BOOLEAN_TRUE:SL_BOOLEAN_FALSE, 0, SL_TIME_UNKNOWN);
result = (*music->seekInterface)->SetLoop(music->seekInterface, looping ? SL_BOOLEAN_TRUE : SL_BOOLEAN_FALSE, 0, SL_TIME_UNKNOWN);
assert(SL_RESULT_SUCCESS == result);
result = (*music->playInterface)->SetPlayState(music->playInterface,
SL_PLAYSTATE_PLAYING);
result = (*music->playInterface)->SetPlayState(music->playInterface, SL_PLAYSTATE_PLAYING);
assert(SL_RESULT_SUCCESS == result);
}
}

View File

@@ -1,6 +1,5 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "AdWhirlDelegateProtocol.h"
#import "EAGLViewController.h"
#import "EAGLView.h"
#import "ESRenderer.h"
@@ -8,9 +7,8 @@
// This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
// The view content is basically an EAGL surface you render your OpenGL scene into.
// Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
@interface EAGLView : UIView<AdWhirlDelegate,UIGestureRecognizerDelegate>
@interface EAGLView : UIView<UIGestureRecognizerDelegate>
{
AdWhirlView *adView;
//This is a trick, AdMob uses a viewController to display its Ads, trust me, you'll need this
EAGLViewController *viewController;
@@ -27,7 +25,6 @@
id displayLink;
CGPoint currentLocation;
}
@property (nonatomic, retain) AdWhirlView *adView;
@property (readonly, nonatomic, getter=isAnimating) BOOL animating;
@property (nonatomic) NSInteger animationFrameInterval;
@property (nonatomic, readwrite) CGPoint currentLocation;
@@ -37,8 +34,6 @@
- (void)drawView:(id)sender;
- (void)updateKeyboard: (NSString *) inputString;
- (void)removeAds;
- (void)displayAds;
- (void)destroyGame;

View File

@@ -12,7 +12,6 @@
#include "GameApp.h"
#import "AdWhirlView.h"
#import "wagicAppDelegate.h"
@@ -67,15 +66,10 @@ void DestroyGame(void)
}
#pragma mark Ad management constants
static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPHONE = @"b86aba511597401ca6b41c1626aa3013";
static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170c8d268f";
#pragma mark -
@implementation EAGLView
@synthesize adView;
@synthesize animating;
@dynamic animationFrameInterval;
@synthesize currentLocation;
@@ -91,7 +85,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
- (void)dealloc
{
[renderer release];
[self removeAds];
[super dealloc];
}
@@ -635,30 +628,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
}
//These are the methods for the AdWhirl Delegate, you have to implement them
#pragma mark AdWhirlDelegate methods
- (void)adWhirlWillPresentFullScreenModal {
//It's recommended to invoke whatever you're using as a "Pause Menu" so your
//game won't keep running while the user is "playing" with the Ad (for example, iAds)
[self pauseGame];
}
- (void)adWhirlDidDismissFullScreenModal {
//Once the user closes the Ad he'll want to return to the game and continue where
//he left it
[self resumeGame];
}
- (NSString *)adWhirlApplicationKey {
if ((UI_USER_INTERFACE_IDIOM()) == UIUserInterfaceIdiomPad)
return _MY_AD_WHIRL_APPLICATION_KEY_IPAD;
return _MY_AD_WHIRL_APPLICATION_KEY_IPHONE;
}
- (UIViewController *)viewControllerForPresentingModalView {
//Remember that UIViewController we created in the Game.h file? AdMob will use it.
//If you want to use "return self;" instead, AdMob will cancel the Ad requests.
@@ -666,101 +635,5 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
}
- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView {
[UIView beginAnimations:@"AdWhirlDelegate.adWhirlDidReceiveAd:"
context:nil];
BOOL isLandscape = UIDeviceOrientationIsLandscape( [UIDevice currentDevice].orientation);
[UIView setAnimationDuration:0.7];
CGSize adSize = [adWhirlView actualAdSize];
CGRect newFrame = [adWhirlView frame];
CGSize screenSize = [self.window bounds].size;
newFrame.size = adSize;
// ads are 320 x 50
newFrame.origin.x = ( (isLandscape ? screenSize.height : screenSize.width) - adSize.width)/ 2;
newFrame.origin.y = ( (isLandscape ? screenSize.width : screenSize.height) - 50);
[adWhirlView setFrame: newFrame];
[UIView commitAnimations];
}
-(void)adWhirlDidFailToReceiveAd:(AdWhirlView *)adWhirlView usingBackup:(BOOL)yesOrNo {
//The code to show my own Ad banner again
NSLog(@"failed to get an Ad");
}
-(void) removeAds {
//There's something weird about AdWhirl because setting the adView delegate
//to "nil" doesn't stops the Ad requests and also it doesn't remove the adView
//from superView; do the following to remove AdWhirl from your scene.
//
//If adView exists, remove everything
if (adView) {
//Remove adView from superView
[adView removeFromSuperview];
//Replace adView's view with "nil"
[adView replaceBannerViewWith:nil];
//Tell AdWhirl to stop requesting Ads
[adView ignoreNewAdRequests];
//Set adView delegate to "nil"
[adView setDelegate:nil];
//Release adView
[adView release];
//set adView to "nil"
adView = nil;
}
}
-(void) displayAds
{
BOOL isLandscape = UIDeviceOrientationIsLandscape( [UIDevice currentDevice].orientation);
//Assign the AdWhirl Delegate to our adView
if ( adView != nil )
[self removeAds];
//Let's allocate the viewController (it's the same RootViewController as declared
//in our AppDelegate; will be used for the Ads)
viewController = [(wagicAppDelegate *)[[UIApplication sharedApplication] delegate] glViewController];
self.adView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
//Set auto-resizing mask
self.adView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
//This isn't really needed but also it makes no harm. It just retrieves the configuration
//from adwhirl.com so it knows what Ad networks to use
[adView updateAdWhirlConfig];
//Get the actual size for the requested Ad
CGSize adSize = [adView actualAdSize];
//
//Set the position; remember that we are using 4 values (in this order): X, Y, Width, Height
//You can comment this line if your game is in portrait mode and you want your Ad on the top
//if you want the Ad in other position (portrait or landscape), use the following code,
//for this example, the Ad will be positioned in the bottom+center of the screen
//(in landscape mode):
//Same explanation as the one in the method "adjustAdSize" for the Ad's width
int screenWidth = [viewController.parentViewController.view bounds].size.width;
float yOffset = [viewController.parentViewController.view bounds].size.height - adSize.height;
if ( isLandscape )
{
screenWidth = [viewController.parentViewController.view bounds].size.height;
yOffset = screenWidth - adSize.height;
}
self.adView.frame = CGRectMake((screenWidth - adSize.width) / 2, yOffset, adSize.width, adSize.height);
//Trying to keep everything inside the Ad bounds
self.adView.clipsToBounds = YES;
//Adding the adView (used for our Ads) to our viewController
[viewController.view addSubview:adView];
//Bring our view to front
[viewController.view bringSubviewToFront:adView];
}
@end

View File

@@ -1,5 +1,4 @@
#import <UIKit/UIKit.h>
#import "AdWhirlDelegateProtocol.h"
@interface EAGLViewController : UIViewController<UITextFieldDelegate> {

View File

@@ -25,10 +25,13 @@
[inputField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[inputField setAutocorrectionType:UITextAutocorrectionTypeNo];
[inputField setKeyboardType: UIKeyboardTypeNamePhonePad];
CGRect frame = [[UIScreen mainScreen] applicationFrame];
eaglView = [[EAGLView alloc] initWithFrame:frame];
[self setView: eaglView];
[self.view addSubview: inputField];
[inputField release];
}
return self;
@@ -50,7 +53,7 @@
- (void)viewWillAppear:(BOOL)animated {
NSLog(@"EAGL ViewController - view Will Appear");
[self.view resumeGame];
[self.view resumeGame];
}
@@ -75,14 +78,14 @@
}
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"EAGL ViewController - view Did Appear");
UIDeviceOrientation currentDeviceOrientation = [UIDevice currentDevice].orientation;
UIInterfaceOrientation currentInterfaceOrientation = self.interfaceOrientation;
NSLog(@"Current Interface: %@. Current Device: %@",
[self interfaceOrientationName:currentInterfaceOrientation],
NSLog(@"Current Interface: %@. Current Device: %@",
[self interfaceOrientationName:currentInterfaceOrientation],
[self deviceOrientationName:currentDeviceOrientation]);
}
@@ -91,7 +94,7 @@
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
@@ -103,6 +106,25 @@
}
#pragma mark - device orientation handlers
- (NSUInteger)supportedInterfaceOrientations
{
//I want to support portrait in ABCView at iPhone only.
//and support all orientation in other views and iPad.
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
return UIInterfaceOrientationMaskLandscape;
}
//support all
return UIInterfaceOrientationMaskAll;
}
-(BOOL)shouldAutorotate {
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
@@ -110,23 +132,23 @@
if ( isSmallScreen && UIInterfaceOrientationIsPortrait(interfaceOrientation))
return NO;
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[[eaglView adView] rotateToOrientation: toInterfaceOrientation];
// [[eaglView adView] rotateToOrientation: toInterfaceOrientation];
}
#pragma mark -
#pragma mark Orientation Information
- (NSString*)interfaceOrientationName:(UIInterfaceOrientation) interfaceOrientation {
NSString* result = nil;
switch (interfaceOrientation) {
case UIInterfaceOrientationPortrait:
result = @"Portrait";
break;
@@ -142,16 +164,16 @@
default:
result = @"Unknown Interface Orientation";
}
return result;
};
- (NSString*)deviceOrientationName:(UIDeviceOrientation) deviceOrientation {
NSString* result = nil;
switch (deviceOrientation) {
case UIDeviceOrientationUnknown:
result = @"Unknown";
break;
@@ -176,7 +198,7 @@
default:
result = @"Unknown Device Orientation";
}
return result;
};
@@ -205,7 +227,7 @@
[eaglView updateKeyboard: @"CLEAR"];
else
[eaglView updateKeyboard: string];
return YES;
}
@@ -215,7 +237,7 @@
}
- (BOOL) textFieldShouldReturn:(UITextField *)textField
- (BOOL) textFieldShouldReturn:(UITextField *)textField
{
[eaglView updateKeyboard: @"SAVE"];
[textField resignFirstResponder];

View File

@@ -33,7 +33,7 @@ bool checkFramebufferStatus();
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if ( context == nil)
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
if (!context || ![EAGLContext setCurrentContext:context])
{
[self release];
@@ -46,20 +46,29 @@ bool checkFramebufferStatus();
- (void)render
{
// NSLog(@"Renderer - render");
struct timeval tv;
uint dt;
// This application only creates a single context which is already set current at this point.
// This call is redundant, but needed if dealing with multiple contexts.
[EAGLContext setCurrentContext:context];
// This application only creates a single default framebuffer which is already bound at this point.
// This call is redundant, but needed if dealing with multiple framebuffers.
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
GLfloat currentRatio = (GLfloat) backingWidth / (GLfloat) backingHeight;
if ((GLfloat)backingWidth / (GLfloat)backingHeight < ACTUAL_RATIO)
// for retina devices. because of the 568 px, the ratio between height-width skews the
// frame a bit
if ( backingHeight == 568 || backingWidth == 568) {
viewPort.left = 0;
viewPort.top = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + 22; // account for status bar
viewPort.right = backingWidth;
viewPort.bottom = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + backingWidth / ACTUAL_RATIO - 22;
}
else if (currentRatio < ACTUAL_RATIO)
{
viewPort.left = 0;
viewPort.top = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2;
@@ -73,21 +82,21 @@ bool checkFramebufferStatus();
viewPort.right = backingHeight * ACTUAL_RATIO;
viewPort.bottom = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + backingWidth / ACTUAL_RATIO + backingHeight;
}
glViewport(viewPort.left, viewPort.top, viewPort.right-viewPort.left, viewPort.bottom-viewPort.top);
JRenderer::GetInstance()->SetActualWidth(viewPort.right-viewPort.left);
JRenderer::GetInstance()->SetActualHeight(viewPort.bottom-viewPort.top);
gettimeofday(&tv, NULL);
uint64_t tickCount = tv.tv_sec * 1000 + tv.tv_usec / 1000;
dt = (tickCount - lastTickCount);
lastTickCount = tickCount;
g_engine->SetDelta((float)dt / 1000.0f);
g_engine->Update((float)dt / 1000.0f);
g_engine->Render();
// This application only creates a single color renderbuffer which is already bound at this point.
@@ -103,18 +112,18 @@ bool checkFramebufferStatus();
glDeleteFramebuffers(1, &defaultFramebuffer);
defaultFramebuffer = 0;
}
if(colorRenderbuffer) {
glDeleteRenderbuffers(1, &colorRenderbuffer);
colorRenderbuffer = 0;
}
glGenFramebuffers(1, &defaultFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
glGenRenderbuffers(1, &colorRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
// Allocate color buffer backing based on the current layer size
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer];
@@ -127,41 +136,41 @@ bool checkFramebufferStatus();
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE); // do not calculate inside of poly's
glFrontFace(GL_CCW);
glFrontFace(GL_CCW);
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glEnable(GL_SCISSOR_TEST); // Enable Clipping
// glEnable(GL_SCISSOR_TEST); // Enable Clipping
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background (yes that's the way fuckers)
glClearDepthf(1.0f); // Depth Buffer Setup
return YES;
}
bool checkFramebufferStatus() {
GLenum status = (GLenum)glCheckFramebufferStatus(GL_FRAMEBUFFER);
switch(status) {
case GL_FRAMEBUFFER_COMPLETE:
return true;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
printf("Framebuffer incomplete,incomplete attachment\n");
return false;
case GL_FRAMEBUFFER_UNSUPPORTED:
printf("Unsupported framebuffer format\n");
return false;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
printf("Framebuffer incomplete,missing attachment\n");
return false;
}
return false;
}
@@ -187,7 +196,7 @@ bool checkFramebufferStatus() {
[context release];
context = nil;
[super dealloc];
}

Some files were not shown because too many files have changed in this diff Show More