- 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

View File

@@ -18,6 +18,8 @@
#include <stdarg.h>
#include <queue>
#include <map>
#include <vector>
#include <string>
#include "JTypes.h"
@@ -96,7 +98,7 @@ class JGE
bool mCriticalAssert;
const char *mAssertFile;
int mAssertLine;
std::vector<std::string> mArgv;
static JGE* mInstance;
@@ -126,6 +128,13 @@ class JGE
void Pause();
void Resume();
//////////////////////////////////////////////////////////////////////////
/// Return argv.
///
/// @return argv vector.
//////////////////////////////////////////////////////////////////////////
std::vector<std::string> 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.

View File

@@ -1,7 +1,8 @@
#ifndef _JNETWORK_H_
#define _JNETWORK_H_
//Network support for PSP
//#define NETWORK_SUPPORT
#include "JGE.h"
#include <string>

Binary file not shown.

View File

@@ -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<std::string> JGE::GetARGV() {
return mArgv;
}
void JGE::SetApp(JApp *app)
{

View File

@@ -1,3 +1,9 @@
//MP3 support for PSP
#define MP3_SUPPORT
#ifdef MP3_SUPPORT
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
@@ -5,6 +11,10 @@
#include <pspmp3.h>
#include <psputility.h>
#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");
}

View File

@@ -5,8 +5,12 @@
*/
#include "../include/JNetwork.h"
#if defined (WIN32) || defined (LINUX)
#else
#ifdef NETWORK_SUPPORT
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
@@ -24,8 +28,10 @@
#include <errno.h>
#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

View File

@@ -1,3 +1,5 @@
#ifdef NETWORK_SUPPORT
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
@@ -14,6 +16,7 @@
#include <arpa/inet.h>
#include <sys/select.h>
#include <errno.h>
#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;
}

View File

@@ -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();

View File

@@ -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

View File

@@ -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]

View File

@@ -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;

View File

@@ -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)