From fd8645d1a4f71cc3ceae7639d03b439a56e74156 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Sun, 11 Jul 2010 10:56:12 +0000 Subject: [PATCH] Erwan - JGE updates : main accepts argv/argc. Compilation variables for MP3 and Network support - Minor fix in Wagic (potentially fixes crashes when using activated abilities several times in onr turn. Couldn't reproduce the issue) --- JGE/include/JGE.h | 18 +++++++++++++- JGE/include/JNetwork.h | 3 ++- JGE/lib/win/jge.lib | Bin 2502836 -> 2502836 bytes JGE/src/JGE.cpp | 12 ++++++++- JGE/src/JMP3.cpp | 23 ++++++++++++++++- JGE/src/JNetwork.cpp | 17 ++++++++++--- JGE/src/JSocket.cpp | 18 ++++++++++++-- JGE/src/main.cpp | 3 ++- projects/mtg/bin/Res/test/_tests.txt | 1 + projects/mtg/bin/Res/test/firebreathing.txt | 26 ++++++++++++++++++++ projects/mtg/include/AllAbilities.h | 2 +- projects/mtg/src/GameStateMenu.cpp | 2 +- 12 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 projects/mtg/bin/Res/test/firebreathing.txt diff --git a/JGE/include/JGE.h b/JGE/include/JGE.h index 8422f0570..2a95fd0e2 100644 --- a/JGE/include/JGE.h +++ b/JGE/include/JGE.h @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "JTypes.h" @@ -96,7 +98,7 @@ class JGE bool mCriticalAssert; const char *mAssertFile; int mAssertLine; - + std::vector mArgv; static JGE* mInstance; @@ -126,6 +128,13 @@ class JGE void Pause(); void Resume(); + ////////////////////////////////////////////////////////////////////////// + /// Return argv. + /// + /// @return argv vector. + ////////////////////////////////////////////////////////////////////////// + std::vector GetARGV(); + ////////////////////////////////////////////////////////////////////////// /// Return system timer in milliseconds. /// @@ -278,6 +287,13 @@ class JGE ////////////////////////////////////////////////////////////////////////// void SetApp(JApp *app); + + ////////////////////////////////////////////////////////////////////////// + /// Setsn argv. + /// + /// + ////////////////////////////////////////////////////////////////////////// + void SetARGV(int argc, char * argv[]); ////////////////////////////////////////////////////////////////////////// /// Print debug message. diff --git a/JGE/include/JNetwork.h b/JGE/include/JNetwork.h index 40de28ee2..7dc1c8fe1 100644 --- a/JGE/include/JNetwork.h +++ b/JGE/include/JNetwork.h @@ -1,7 +1,8 @@ #ifndef _JNETWORK_H_ #define _JNETWORK_H_ - +//Network support for PSP +//#define NETWORK_SUPPORT #include "JGE.h" #include diff --git a/JGE/lib/win/jge.lib b/JGE/lib/win/jge.lib index 46aba643133d5d97a74288d91852091e6c8aacff..e88f29f18a12c740bb053fce699bf9cfe593ef94 100644 GIT binary patch delta 253 zcmXxeOAf(M6b9g1uTpQS=tb)}Z%H+GW>$$67}UO0kV*TJQSb^B`8A$svtrQqMbT4!kyiGoKwGtyxE4%vZ!|)o1#Ren0xEQ&2Ynd8Fuc*xNBjbieOBQB delta 245 zcmXxcISztg6a-*EaY1oK7IDG#07QxTPk;%Bu(R?6R2Bph3rsAq^9IBMp)ejr6Hnj? zG!6xmeAT=+(fdqCa8v{Tz_ZL!4?>fb_rxKzLl}qT9Fo5gc4ub2iyjJ4gc6jK(BvL^ zc9AZKu4i*lfhzD&gE};z2`y-Y03AqwB#;x&R-Tu@ze@vUVXO=-&4#n+HTBvG)=8wO g4;5U$eAkWDlnOoQ!vKb$!3f4Mfho+ASe^fbKUkz#j{pDw diff --git a/JGE/src/JGE.cpp b/JGE/src/JGE.cpp index a96eeed5b..a5bd47ce8 100644 --- a/JGE/src/JGE.cpp +++ b/JGE/src/JGE.cpp @@ -335,7 +335,7 @@ void JGE::Init() JRenderer::GetInstance(); JFileSystem::GetInstance(); - JSoundSystem::GetInstance(); + //JSoundSystem::GetInstance(); let's do lazy loading mDone = false; mPaused = false; @@ -459,6 +459,16 @@ void JGE::Destroy() } } +void JGE::SetARGV(int argc, char * argv[]){ + for (int i = 0; i < argc; ++i){ + string s = argv[i]; + mArgv.push_back(s); + } +} + +std::vector JGE::GetARGV() { + return mArgv; +} void JGE::SetApp(JApp *app) { diff --git a/JGE/src/JMP3.cpp b/JGE/src/JMP3.cpp index 36d027b85..01055b189 100644 --- a/JGE/src/JMP3.cpp +++ b/JGE/src/JMP3.cpp @@ -1,3 +1,9 @@ + +//MP3 support for PSP +#define MP3_SUPPORT + +#ifdef MP3_SUPPORT + #include #include #include @@ -5,6 +11,10 @@ #include #include +#else +#define PSP_AUDIO_VOLUME_MAX 100 +#endif + #include "../include/JAudio.h" #include "../include/JFileSystem.h" #include "../include/JMP3.h" @@ -31,6 +41,7 @@ JMP3::~JMP3() { bool JMP3::loadModules() { JLOG("loading Audio modules"); +#ifdef MP3_SUPPORT int loadAvCodec = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); if (loadAvCodec < 0) { return false; @@ -41,6 +52,7 @@ bool JMP3::loadModules() { return false; } JLOG("Audio modules loaded"); +#endif return true; } @@ -50,6 +62,7 @@ bool JMP3::fillBuffers() { JLOG("JMP3::fillBuffers called but init_done is false!"); return false; } +#ifdef MP3_SUPPORT SceUChar8* dest; SceInt32 length; SceInt32 pos; @@ -80,7 +93,7 @@ bool JMP3::fillBuffers() { ret = sceMp3NotifyAddStreamData(m_mp3Handle, readLength); if (ret < 0) return false; - +#endif JLOG("End JMP3::fillBuffers"); return true; } @@ -120,6 +133,7 @@ JLOG("Start JMP3::load"); JLOG("JMP3::load called but init_done is false!"); return false; } +#ifdef MP3_SUPPORT m_inBufferSize = inBufferSize; //m_inBuffer = new char[m_inBufferSize]; //if (!m_inBuffer) @@ -180,6 +194,7 @@ JLOG("Start JMP3::load"); m_numChannels = sceMp3GetMp3ChannelNum(m_mp3Handle); m_samplingRate = sceMp3GetSamplingRate(m_mp3Handle); +#endif JLOG("End JMP3::load"); return true; @@ -191,6 +206,7 @@ JLOG("Start JMP3::unload"); JLOG("JMP3::unload called but init_done is false!"); return false; } +#ifdef MP3_SUPPORT if (m_channel >= 0) sceAudioSRCChRelease(); @@ -203,6 +219,7 @@ JLOG("Start JMP3::unload"); //delete[] m_inBuffer; //delete[] m_outBuffer; +#endif JLOG("End JMP3::unload"); return true; } @@ -211,6 +228,7 @@ bool JMP3::update() { if (!init_done) { return false; } +#ifdef MP3_SUPPORT int retry = 8;//FIXME:magic number JMP3_update_start: @@ -262,6 +280,7 @@ bool JMP3::update() { } } +#endif return true; } @@ -279,7 +298,9 @@ JLOG("Start JMP3::setLoop"); JLOG("JMP3::setLoop called but init_done is false!"); return false; } +#ifdef MP3_SUPPORT sceMp3SetLoopNum(m_mp3Handle, (loop == true) ? -1 : 0); +#endif return (m_loop = loop); JLOG("End JMP3::setLoop"); } diff --git a/JGE/src/JNetwork.cpp b/JGE/src/JNetwork.cpp index 9ebc82a87..d61674631 100644 --- a/JGE/src/JNetwork.cpp +++ b/JGE/src/JNetwork.cpp @@ -5,8 +5,12 @@ */ +#include "../include/JNetwork.h" + #if defined (WIN32) || defined (LINUX) #else +#ifdef NETWORK_SUPPORT + #include #include #include @@ -24,8 +28,10 @@ #include #endif +#endif + + -#include "../include/JNetwork.h" #include "../include/JSocket.h" JNetwork* JNetwork::mInstance = NULL; @@ -139,6 +145,7 @@ int JNetwork::connect(string serverIP) #else int net_thread(SceSize args, void *argp) { +#ifdef NETWORK_SUPPORT do { JSocket::mInstance = new JSocket(); @@ -157,12 +164,13 @@ int net_thread(SceSize args, void *argp) } } while(0); - +#endif return 0; } int JNetwork::connect(string serverIP){ +#ifdef NETWORK_SUPPORT int err; char buffer[4096]; if(netthread) return 0; @@ -192,7 +200,7 @@ sceUtilityLoadNetModule(3); sceKernelStartThread(netthread, 0, NULL); return netthread; } - +#endif return 0; } @@ -200,6 +208,7 @@ sceUtilityLoadNetModule(3); /* Connect to an access point */ int JNetwork::connect_to_apctl(int config) { +#ifdef NETWORK_SUPPORT int err; int stateLast = -1; char buffer[4096]; @@ -248,7 +257,7 @@ int JNetwork::connect_to_apctl(int config) { return 0; } - +#endif return 1; } #endif diff --git a/JGE/src/JSocket.cpp b/JGE/src/JSocket.cpp index 5b5cbdffc..b06e2a602 100644 --- a/JGE/src/JSocket.cpp +++ b/JGE/src/JSocket.cpp @@ -1,3 +1,5 @@ +#ifdef NETWORK_SUPPORT + #include #include #include @@ -14,6 +16,7 @@ #include #include #include +#endif #include "../include/JGE.h" @@ -25,8 +28,10 @@ JSocket * JSocket::mInstance = NULL; int JSocket::connected = 0; void JSocket::init(){ +#ifdef NETWORK_SUPPORT sceUtilityLoadNetModule(1); sceUtilityLoadNetModule(3); +#endif } JSocket::JSocket(){ @@ -34,15 +39,18 @@ JSocket::JSocket(){ } JSocket::~JSocket(){ +#ifdef NETWORK_SUPPORT pspSdkInetTerm(); sceNetApctlDisconnect(); sceNetApctlTerm(); +#endif } int JSocket::make_socket(uint16_t port) { - int sock; + int sock = -1; + #ifdef NETWORK_SUPPORT int ret; struct sockaddr_in name; @@ -60,12 +68,13 @@ int JSocket::make_socket(uint16_t port) { return -1; } - +#endif return sock; } void JSocket::readWrite(int val){ +#ifdef NETWORK_SUPPORT char data[1024]; int readbytes; readbytes = read(val, data, sizeof(data)); @@ -93,10 +102,12 @@ void JSocket::readWrite(int val){ tosend_data.pop(); } if (size) write(val,data,size); + #endif } /* Start a client */ int JSocket::start_client(const char *szIpAddr){ +#ifdef NETWORK_SUPPORT int sock; sockaddr_in addrListen; int error; @@ -126,12 +137,14 @@ int JSocket::start_client(const char *szIpAddr){ while(1){ readWrite(sock); } + #endif return 0; } /* Start a server */ int JSocket::start_server(const char *szIpAddr) { +#ifdef NETWORK_SUPPORT int ret; int sock; int _new = -1; @@ -206,6 +219,7 @@ int JSocket::start_server(const char *szIpAddr) } close(sock); +#endif return 0; } diff --git a/JGE/src/main.cpp b/JGE/src/main.cpp index 4ba434636..4bf8e1a44 100644 --- a/JGE/src/main.cpp +++ b/JGE/src/main.cpp @@ -359,7 +359,7 @@ void Run() //------------------------------------------------------------------------------------------------ // The main loop -int main() +int main(int argc, char *argv[]) { #ifdef DOJLOG remove(JGE_LOG_FILE); @@ -382,6 +382,7 @@ int main() gTickFrequency = sceRtcGetTickResolution(); JLOG("JGE::GetInstance()"); g_engine = JGE::GetInstance(); + g_engine->SetARGV(argc, argv); JLOG("Create Game"); game = launcher->GetGameApp(); diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 7c0583fac..b10c17605 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -221,6 +221,7 @@ fastbond2.txt fault_line.txt feral_hydra.txt fire_tempest.txt +firebreathing.txt fists_of_ironwood.txt flagstones.txt flame_fusillade_i265.txt diff --git a/projects/mtg/bin/Res/test/firebreathing.txt b/projects/mtg/bin/Res/test/firebreathing.txt new file mode 100644 index 000000000..5e6fe73b1 --- /dev/null +++ b/projects/mtg/bin/Res/test/firebreathing.txt @@ -0,0 +1,26 @@ +#Testing Firebreathing twice +[INIT] +FIRSTMAIN +[PLAYER1] +hand:firebreathing +inplay:grizzly bears +manapool:{R}{R}{R} +[PLAYER2] +[DO] +firebreathing +grizzly bears +firebreathing +firebreathing +next +#begin combat +next +#attackers +grizzly bears +eot +[ASSERT] +UNTAP +[PLAYER1] +inplay:grizzly bears,firebreathing +[PLAYER2] +life:16 +[END] diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 055f11da0..faff80cda 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -403,7 +403,7 @@ class GenericActivatedAbility:public ActivatedAbility, public NestedAbility{ ManaCost * diff = abilityCost->Diff(cost); source->X = diff->hasX(); SAFE_DELETE(diff); - SAFE_DELETE(abilityCost); + //SAFE_DELETE(abilityCost); this line has been reported as a bug. removing it doesn't seem to break anything, although I didn't get any error in the test suite by leaving it either, so... leaving it for now as a comment, in case. ability->target = target; //may have been updated... if (ability) return ability->resolve(); return 0; diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index 8033d92f0..28109dd0e 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -10,7 +10,7 @@ #include "../include/PlayerData.h" #include "../include/utils.h" -static const char* GAME_VERSION = "WTH?! 0.12.0 - by wololo"; +static const char* GAME_VERSION = "WTH?! 0.12.1 - by wololo"; #define DEFAULT_ANGLE_MULTIPLIER 0.4f #define MAX_ANGLE_MULTIPLIER (3*M_PI)