- 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)
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-07-11 10:56:12 +00:00
parent 672e53d58c
commit fd8645d1a4
12 changed files with 112 additions and 13 deletions
+17 -1
View File
@@ -18,6 +18,8 @@
#include <stdarg.h> #include <stdarg.h>
#include <queue> #include <queue>
#include <map> #include <map>
#include <vector>
#include <string>
#include "JTypes.h" #include "JTypes.h"
@@ -96,7 +98,7 @@ class JGE
bool mCriticalAssert; bool mCriticalAssert;
const char *mAssertFile; const char *mAssertFile;
int mAssertLine; int mAssertLine;
std::vector<std::string> mArgv;
static JGE* mInstance; static JGE* mInstance;
@@ -126,6 +128,13 @@ class JGE
void Pause(); void Pause();
void Resume(); void Resume();
//////////////////////////////////////////////////////////////////////////
/// Return argv.
///
/// @return argv vector.
//////////////////////////////////////////////////////////////////////////
std::vector<std::string> GetARGV();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Return system timer in milliseconds. /// Return system timer in milliseconds.
/// ///
@@ -278,6 +287,13 @@ class JGE
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetApp(JApp *app); void SetApp(JApp *app);
//////////////////////////////////////////////////////////////////////////
/// Setsn argv.
///
///
//////////////////////////////////////////////////////////////////////////
void SetARGV(int argc, char * argv[]);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Print debug message. /// Print debug message.
+2 -1
View File
@@ -1,7 +1,8 @@
#ifndef _JNETWORK_H_ #ifndef _JNETWORK_H_
#define _JNETWORK_H_ #define _JNETWORK_H_
//Network support for PSP
//#define NETWORK_SUPPORT
#include "JGE.h" #include "JGE.h"
#include <string> #include <string>
Binary file not shown.
+11 -1
View File
@@ -335,7 +335,7 @@ void JGE::Init()
JRenderer::GetInstance(); JRenderer::GetInstance();
JFileSystem::GetInstance(); JFileSystem::GetInstance();
JSoundSystem::GetInstance(); //JSoundSystem::GetInstance(); let's do lazy loading
mDone = false; mDone = false;
mPaused = 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<std::string> JGE::GetARGV() {
return mArgv;
}
void JGE::SetApp(JApp *app) void JGE::SetApp(JApp *app)
{ {
+22 -1
View File
@@ -1,3 +1,9 @@
//MP3 support for PSP
#define MP3_SUPPORT
#ifdef MP3_SUPPORT
#include <pspkernel.h> #include <pspkernel.h>
#include <pspdebug.h> #include <pspdebug.h>
#include <stdio.h> #include <stdio.h>
@@ -5,6 +11,10 @@
#include <pspmp3.h> #include <pspmp3.h>
#include <psputility.h> #include <psputility.h>
#else
#define PSP_AUDIO_VOLUME_MAX 100
#endif
#include "../include/JAudio.h" #include "../include/JAudio.h"
#include "../include/JFileSystem.h" #include "../include/JFileSystem.h"
#include "../include/JMP3.h" #include "../include/JMP3.h"
@@ -31,6 +41,7 @@ JMP3::~JMP3() {
bool JMP3::loadModules() { bool JMP3::loadModules() {
JLOG("loading Audio modules"); JLOG("loading Audio modules");
#ifdef MP3_SUPPORT
int loadAvCodec = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); int loadAvCodec = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC);
if (loadAvCodec < 0) { if (loadAvCodec < 0) {
return false; return false;
@@ -41,6 +52,7 @@ bool JMP3::loadModules() {
return false; return false;
} }
JLOG("Audio modules loaded"); JLOG("Audio modules loaded");
#endif
return true; return true;
} }
@@ -50,6 +62,7 @@ bool JMP3::fillBuffers() {
JLOG("JMP3::fillBuffers called but init_done is false!"); JLOG("JMP3::fillBuffers called but init_done is false!");
return false; return false;
} }
#ifdef MP3_SUPPORT
SceUChar8* dest; SceUChar8* dest;
SceInt32 length; SceInt32 length;
SceInt32 pos; SceInt32 pos;
@@ -80,7 +93,7 @@ bool JMP3::fillBuffers() {
ret = sceMp3NotifyAddStreamData(m_mp3Handle, readLength); ret = sceMp3NotifyAddStreamData(m_mp3Handle, readLength);
if (ret < 0) if (ret < 0)
return false; return false;
#endif
JLOG("End JMP3::fillBuffers"); JLOG("End JMP3::fillBuffers");
return true; return true;
} }
@@ -120,6 +133,7 @@ JLOG("Start JMP3::load");
JLOG("JMP3::load called but init_done is false!"); JLOG("JMP3::load called but init_done is false!");
return false; return false;
} }
#ifdef MP3_SUPPORT
m_inBufferSize = inBufferSize; m_inBufferSize = inBufferSize;
//m_inBuffer = new char[m_inBufferSize]; //m_inBuffer = new char[m_inBufferSize];
//if (!m_inBuffer) //if (!m_inBuffer)
@@ -180,6 +194,7 @@ JLOG("Start JMP3::load");
m_numChannels = sceMp3GetMp3ChannelNum(m_mp3Handle); m_numChannels = sceMp3GetMp3ChannelNum(m_mp3Handle);
m_samplingRate = sceMp3GetSamplingRate(m_mp3Handle); m_samplingRate = sceMp3GetSamplingRate(m_mp3Handle);
#endif
JLOG("End JMP3::load"); JLOG("End JMP3::load");
return true; return true;
@@ -191,6 +206,7 @@ JLOG("Start JMP3::unload");
JLOG("JMP3::unload called but init_done is false!"); JLOG("JMP3::unload called but init_done is false!");
return false; return false;
} }
#ifdef MP3_SUPPORT
if (m_channel >= 0) if (m_channel >= 0)
sceAudioSRCChRelease(); sceAudioSRCChRelease();
@@ -203,6 +219,7 @@ JLOG("Start JMP3::unload");
//delete[] m_inBuffer; //delete[] m_inBuffer;
//delete[] m_outBuffer; //delete[] m_outBuffer;
#endif
JLOG("End JMP3::unload"); JLOG("End JMP3::unload");
return true; return true;
} }
@@ -211,6 +228,7 @@ bool JMP3::update() {
if (!init_done) { if (!init_done) {
return false; return false;
} }
#ifdef MP3_SUPPORT
int retry = 8;//FIXME:magic number int retry = 8;//FIXME:magic number
JMP3_update_start: JMP3_update_start:
@@ -262,6 +280,7 @@ bool JMP3::update() {
} }
} }
#endif
return true; return true;
} }
@@ -279,7 +298,9 @@ JLOG("Start JMP3::setLoop");
JLOG("JMP3::setLoop called but init_done is false!"); JLOG("JMP3::setLoop called but init_done is false!");
return false; return false;
} }
#ifdef MP3_SUPPORT
sceMp3SetLoopNum(m_mp3Handle, (loop == true) ? -1 : 0); sceMp3SetLoopNum(m_mp3Handle, (loop == true) ? -1 : 0);
#endif
return (m_loop = loop); return (m_loop = loop);
JLOG("End JMP3::setLoop"); JLOG("End JMP3::setLoop");
} }
+13 -4
View File
@@ -5,8 +5,12 @@
*/ */
#include "../include/JNetwork.h"
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
#else #else
#ifdef NETWORK_SUPPORT
#include <pspkernel.h> #include <pspkernel.h>
#include <pspdebug.h> #include <pspdebug.h>
#include <pspsdk.h> #include <pspsdk.h>
@@ -24,8 +28,10 @@
#include <errno.h> #include <errno.h>
#endif #endif
#endif
#include "../include/JNetwork.h"
#include "../include/JSocket.h" #include "../include/JSocket.h"
JNetwork* JNetwork::mInstance = NULL; JNetwork* JNetwork::mInstance = NULL;
@@ -139,6 +145,7 @@ int JNetwork::connect(string serverIP)
#else #else
int net_thread(SceSize args, void *argp) int net_thread(SceSize args, void *argp)
{ {
#ifdef NETWORK_SUPPORT
do do
{ {
JSocket::mInstance = new JSocket(); JSocket::mInstance = new JSocket();
@@ -157,12 +164,13 @@ int net_thread(SceSize args, void *argp)
} }
} }
while(0); while(0);
#endif
return 0; return 0;
} }
int JNetwork::connect(string serverIP){ int JNetwork::connect(string serverIP){
#ifdef NETWORK_SUPPORT
int err; int err;
char buffer[4096]; char buffer[4096];
if(netthread) return 0; if(netthread) return 0;
@@ -192,7 +200,7 @@ sceUtilityLoadNetModule(3);
sceKernelStartThread(netthread, 0, NULL); sceKernelStartThread(netthread, 0, NULL);
return netthread; return netthread;
} }
#endif
return 0; return 0;
} }
@@ -200,6 +208,7 @@ sceUtilityLoadNetModule(3);
/* Connect to an access point */ /* Connect to an access point */
int JNetwork::connect_to_apctl(int config) int JNetwork::connect_to_apctl(int config)
{ {
#ifdef NETWORK_SUPPORT
int err; int err;
int stateLast = -1; int stateLast = -1;
char buffer[4096]; char buffer[4096];
@@ -248,7 +257,7 @@ int JNetwork::connect_to_apctl(int config)
{ {
return 0; return 0;
} }
#endif
return 1; return 1;
} }
#endif #endif
+16 -2
View File
@@ -1,3 +1,5 @@
#ifdef NETWORK_SUPPORT
#include <pspkernel.h> #include <pspkernel.h>
#include <pspdebug.h> #include <pspdebug.h>
#include <pspdisplay.h> #include <pspdisplay.h>
@@ -14,6 +16,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/select.h> #include <sys/select.h>
#include <errno.h> #include <errno.h>
#endif
#include "../include/JGE.h" #include "../include/JGE.h"
@@ -25,8 +28,10 @@ JSocket * JSocket::mInstance = NULL;
int JSocket::connected = 0; int JSocket::connected = 0;
void JSocket::init(){ void JSocket::init(){
#ifdef NETWORK_SUPPORT
sceUtilityLoadNetModule(1); sceUtilityLoadNetModule(1);
sceUtilityLoadNetModule(3); sceUtilityLoadNetModule(3);
#endif
} }
JSocket::JSocket(){ JSocket::JSocket(){
@@ -34,15 +39,18 @@ JSocket::JSocket(){
} }
JSocket::~JSocket(){ JSocket::~JSocket(){
#ifdef NETWORK_SUPPORT
pspSdkInetTerm(); pspSdkInetTerm();
sceNetApctlDisconnect(); sceNetApctlDisconnect();
sceNetApctlTerm(); sceNetApctlTerm();
#endif
} }
int JSocket::make_socket(uint16_t port) int JSocket::make_socket(uint16_t port)
{ {
int sock; int sock = -1;
#ifdef NETWORK_SUPPORT
int ret; int ret;
struct sockaddr_in name; struct sockaddr_in name;
@@ -60,12 +68,13 @@ int JSocket::make_socket(uint16_t port)
{ {
return -1; return -1;
} }
#endif
return sock; return sock;
} }
void JSocket::readWrite(int val){ void JSocket::readWrite(int val){
#ifdef NETWORK_SUPPORT
char data[1024]; char data[1024];
int readbytes; int readbytes;
readbytes = read(val, data, sizeof(data)); readbytes = read(val, data, sizeof(data));
@@ -93,10 +102,12 @@ void JSocket::readWrite(int val){
tosend_data.pop(); tosend_data.pop();
} }
if (size) write(val,data,size); if (size) write(val,data,size);
#endif
} }
/* Start a client */ /* Start a client */
int JSocket::start_client(const char *szIpAddr){ int JSocket::start_client(const char *szIpAddr){
#ifdef NETWORK_SUPPORT
int sock; int sock;
sockaddr_in addrListen; sockaddr_in addrListen;
int error; int error;
@@ -126,12 +137,14 @@ int JSocket::start_client(const char *szIpAddr){
while(1){ while(1){
readWrite(sock); readWrite(sock);
} }
#endif
return 0; return 0;
} }
/* Start a server */ /* Start a server */
int JSocket::start_server(const char *szIpAddr) int JSocket::start_server(const char *szIpAddr)
{ {
#ifdef NETWORK_SUPPORT
int ret; int ret;
int sock; int sock;
int _new = -1; int _new = -1;
@@ -206,6 +219,7 @@ int JSocket::start_server(const char *szIpAddr)
} }
close(sock); close(sock);
#endif
return 0; return 0;
} }
+2 -1
View File
@@ -359,7 +359,7 @@ void Run()
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
// The main loop // The main loop
int main() int main(int argc, char *argv[])
{ {
#ifdef DOJLOG #ifdef DOJLOG
remove(JGE_LOG_FILE); remove(JGE_LOG_FILE);
@@ -382,6 +382,7 @@ int main()
gTickFrequency = sceRtcGetTickResolution(); gTickFrequency = sceRtcGetTickResolution();
JLOG("JGE::GetInstance()"); JLOG("JGE::GetInstance()");
g_engine = JGE::GetInstance(); g_engine = JGE::GetInstance();
g_engine->SetARGV(argc, argv);
JLOG("Create Game"); JLOG("Create Game");
game = launcher->GetGameApp(); game = launcher->GetGameApp();
+1
View File
@@ -221,6 +221,7 @@ fastbond2.txt
fault_line.txt fault_line.txt
feral_hydra.txt feral_hydra.txt
fire_tempest.txt fire_tempest.txt
firebreathing.txt
fists_of_ironwood.txt fists_of_ironwood.txt
flagstones.txt flagstones.txt
flame_fusillade_i265.txt flame_fusillade_i265.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]
+1 -1
View File
@@ -403,7 +403,7 @@ class GenericActivatedAbility:public ActivatedAbility, public NestedAbility{
ManaCost * diff = abilityCost->Diff(cost); ManaCost * diff = abilityCost->Diff(cost);
source->X = diff->hasX(); source->X = diff->hasX();
SAFE_DELETE(diff); 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... ability->target = target; //may have been updated...
if (ability) return ability->resolve(); if (ability) return ability->resolve();
return 0; return 0;
+1 -1
View File
@@ -10,7 +10,7 @@
#include "../include/PlayerData.h" #include "../include/PlayerData.h"
#include "../include/utils.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 DEFAULT_ANGLE_MULTIPLIER 0.4f
#define MAX_ANGLE_MULTIPLIER (3*M_PI) #define MAX_ANGLE_MULTIPLIER (3*M_PI)