Erwan
- fixed sfx issues on the psp - removed a few debug strings
This commit is contained in:
@@ -1,50 +1,50 @@
|
|||||||
0
|
30
|
||||||
100
|
100
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
|
|||||||
@@ -1,92 +1,96 @@
|
|||||||
1167
|
1167
|
||||||
460
|
460
|
||||||
1202
|
1202
|
||||||
525
|
525
|
||||||
1340
|
1340
|
||||||
92
|
92
|
||||||
1284
|
1284
|
||||||
101
|
101
|
||||||
1149
|
1149
|
||||||
20
|
20
|
||||||
1264
|
1264
|
||||||
20
|
20
|
||||||
1321
|
1321
|
||||||
20
|
20
|
||||||
1272
|
1272
|
||||||
437
|
437
|
||||||
1126
|
1126
|
||||||
485
|
485
|
||||||
1334
|
1334
|
||||||
107
|
107
|
||||||
1352
|
1352
|
||||||
91
|
91
|
||||||
1279
|
1279
|
||||||
20
|
20
|
||||||
1154
|
1154
|
||||||
481
|
481
|
||||||
1328
|
1328
|
||||||
551
|
551
|
||||||
1335
|
1335
|
||||||
20
|
20
|
||||||
1227
|
1227
|
||||||
500
|
500
|
||||||
1236
|
1236
|
||||||
489
|
489
|
||||||
1186
|
1186
|
||||||
20
|
20
|
||||||
1219
|
1219
|
||||||
20
|
20
|
||||||
1175
|
1175
|
||||||
459
|
459
|
||||||
1136
|
1136
|
||||||
111
|
111
|
||||||
1332
|
1332
|
||||||
545
|
545
|
||||||
1250
|
1250
|
||||||
21
|
21
|
||||||
1204
|
1204
|
||||||
19
|
19
|
||||||
1381
|
1381
|
||||||
499
|
499
|
||||||
1170
|
1170
|
||||||
484
|
484
|
||||||
1097
|
1097
|
||||||
102
|
102
|
||||||
1102
|
1102
|
||||||
46
|
46
|
||||||
1282
|
1282
|
||||||
485
|
485
|
||||||
1378
|
1378
|
||||||
490
|
490
|
||||||
1300
|
1300
|
||||||
20
|
20
|
||||||
1363
|
1363
|
||||||
495
|
495
|
||||||
129665
|
129665
|
||||||
90
|
90
|
||||||
1387
|
1387
|
||||||
4
|
4
|
||||||
129652
|
129652
|
||||||
5
|
5
|
||||||
174957
|
174957
|
||||||
108
|
108
|
||||||
175030
|
175030
|
||||||
5
|
5
|
||||||
130378
|
130378
|
||||||
107
|
107
|
||||||
175031
|
175031
|
||||||
5
|
5
|
||||||
1312
|
1312
|
||||||
19
|
19
|
||||||
130386
|
130386
|
||||||
97
|
97
|
||||||
1275
|
1275
|
||||||
21
|
21
|
||||||
1148
|
1148
|
||||||
103
|
103
|
||||||
135185
|
135185
|
||||||
20
|
20
|
||||||
1100
|
1100
|
||||||
109
|
109
|
||||||
153441
|
153441
|
||||||
19
|
19
|
||||||
|
1318
|
||||||
|
499
|
||||||
|
146746
|
||||||
|
509
|
||||||
|
|||||||
@@ -480,6 +480,7 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
|
|||||||
|
|
||||||
class AManaProducer: public MTGAbility{
|
class AManaProducer: public MTGAbility{
|
||||||
protected:
|
protected:
|
||||||
|
static int currentlyTapping;
|
||||||
ManaCost * cost;
|
ManaCost * cost;
|
||||||
ManaCost * output;
|
ManaCost * output;
|
||||||
string menutext;
|
string menutext;
|
||||||
@@ -533,9 +534,10 @@ class AManaProducer: public MTGAbility{
|
|||||||
if (mParticleSys && animation == 1.f) mParticleSys->Fire();
|
if (mParticleSys && animation == 1.f) mParticleSys->Fire();
|
||||||
animation -= 4 *dt;
|
animation -= 4 *dt;
|
||||||
if (animation < 0){
|
if (animation < 0){
|
||||||
animation = 0;
|
animation = 0;
|
||||||
controller->getManaPool()->add(output);
|
currentlyTapping--;
|
||||||
if (mParticleSys) mParticleSys->Stop();
|
controller->getManaPool()->add(output);
|
||||||
|
if (mParticleSys) mParticleSys->Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,6 +565,7 @@ class AManaProducer: public MTGAbility{
|
|||||||
int reactToClick(MTGCardInstance * _card){
|
int reactToClick(MTGCardInstance * _card){
|
||||||
if (!isReactingToClick( _card)) return 0;
|
if (!isReactingToClick( _card)) return 0;
|
||||||
source->tapped = 1;
|
source->tapped = 1;
|
||||||
|
currentlyTapping++;
|
||||||
if (cost) GameObserver::GetInstance()->currentlyActing()->getManaPool()->pay(cost);
|
if (cost) GameObserver::GetInstance()->currentlyActing()->getManaPool()->pay(cost);
|
||||||
animation = 1.f;
|
animation = 1.f;
|
||||||
CardGui * cardg = game->mLayers->playLayer()->getByCard(source);
|
CardGui * cardg = game->mLayers->playLayer()->getByCard(source);
|
||||||
@@ -572,7 +575,7 @@ class AManaProducer: public MTGAbility{
|
|||||||
}
|
}
|
||||||
controller = source->controller();
|
controller = source->controller();
|
||||||
|
|
||||||
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME] > 0){
|
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME] > 0 && currentlyTapping < 3){
|
||||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
|
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
|
||||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
||||||
}
|
}
|
||||||
@@ -630,7 +633,7 @@ class AManaProducer: public MTGAbility{
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
int AManaProducer::currentlyTapping = 0;
|
||||||
|
|
||||||
/* Lifelink Ability */
|
/* Lifelink Ability */
|
||||||
class ALifeLink:public MTGAbility{
|
class ALifeLink:public MTGAbility{
|
||||||
|
|||||||
@@ -58,14 +58,25 @@ class TexturesCache{
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SampleCached{
|
||||||
|
public:
|
||||||
|
int lastTime;
|
||||||
|
JSample * sample;
|
||||||
|
SampleCached(int _lastTime, JSample * _sample):lastTime(_lastTime),sample(_sample){};
|
||||||
|
~SampleCached(){delete sample;};
|
||||||
|
};
|
||||||
|
|
||||||
class SampleCache{
|
class SampleCache{
|
||||||
protected:
|
protected:
|
||||||
map<string, JSample *> cache;
|
int lastTime;
|
||||||
|
map<string, SampleCached *> cache;
|
||||||
static SampleCache * mInstance;
|
static SampleCache * mInstance;
|
||||||
void cleanCache();
|
void cleanCache();
|
||||||
|
void cleanOldest();
|
||||||
~SampleCache();
|
~SampleCache();
|
||||||
public:
|
public:
|
||||||
static SampleCache * GetInstance();
|
static SampleCache * GetInstance();
|
||||||
|
SampleCache(){lastTime = 0;};
|
||||||
JSample * getSample(string filename);
|
JSample * getSample(string filename);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,34 +55,22 @@ void AIPlayer::tapLandsForMana(ManaCost * potentialMana, ManaCost * cost){
|
|||||||
|
|
||||||
MTGCardInstance * card = NULL;
|
MTGCardInstance * card = NULL;
|
||||||
while((card = cd.nextmatch(game->inPlay, card))){
|
while((card = cd.nextmatch(game->inPlay, card))){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("Found mana card\n");
|
|
||||||
#endif
|
|
||||||
int doTap = 1;
|
int doTap = 1;
|
||||||
for (int i=MTG_NB_COLORS-1; i>= 0; i--){
|
for (int i=MTG_NB_COLORS-1; i>= 0; i--){
|
||||||
if (diff->getCost(i) && card->hasSubtype(MTG_LAND_TEXTS[i]) ){
|
if (diff->getCost(i) && card->hasSubtype(MTG_LAND_TEXTS[i]) ){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
diff->remove(i,1);
|
||||||
OutputDebugString("Not Gonna Tap\n");
|
doTap = 0;
|
||||||
#endif
|
break;
|
||||||
diff->remove(i,1);
|
|
||||||
doTap = 0;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doTap){
|
if (doTap){
|
||||||
gameObs->cardClick(card);
|
gameObs->cardClick(card);
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("Tapped\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(diff);
|
delete(diff);
|
||||||
|
|
||||||
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("ok land tapped");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
//TODO a better function that does not take into account only basic lands
|
//TODO a better function that does not take into account only basic lands
|
||||||
ManaCost * AIPlayer::getPotentialMana(){
|
ManaCost * AIPlayer::getPotentialMana(){
|
||||||
@@ -95,24 +83,12 @@ ManaCost * AIPlayer::getPotentialMana(){
|
|||||||
while((card = cd.nextmatch(game->inPlay, card))){
|
while((card = cd.nextmatch(game->inPlay, card))){
|
||||||
|
|
||||||
if (card->hasSubtype("plains")){
|
if (card->hasSubtype("plains")){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("Found Potential plain\n");
|
|
||||||
#endif
|
|
||||||
potentialMana->add(MTG_COLOR_WHITE,1);
|
potentialMana->add(MTG_COLOR_WHITE,1);
|
||||||
}else if(card->hasSubtype("swamp")){
|
}else if(card->hasSubtype("swamp")){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("Found Potential swamp\n");
|
|
||||||
#endif
|
|
||||||
potentialMana->add(MTG_COLOR_BLACK,1);
|
potentialMana->add(MTG_COLOR_BLACK,1);
|
||||||
}else if(card->hasSubtype("forest")){
|
}else if(card->hasSubtype("forest")){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("Found Potential forestn\n");
|
|
||||||
#endif
|
|
||||||
potentialMana->add(MTG_COLOR_GREEN,1);
|
potentialMana->add(MTG_COLOR_GREEN,1);
|
||||||
}else if(card->hasSubtype("mountain")){
|
}else if(card->hasSubtype("mountain")){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("Found Potential Mountain\n");
|
|
||||||
#endif
|
|
||||||
potentialMana->add(MTG_COLOR_RED,1);
|
potentialMana->add(MTG_COLOR_RED,1);
|
||||||
}else if(card->hasSubtype("island")){
|
}else if(card->hasSubtype("island")){
|
||||||
potentialMana->add(MTG_COLOR_BLUE,1);
|
potentialMana->add(MTG_COLOR_BLUE,1);
|
||||||
@@ -504,21 +480,7 @@ int AIPlayerBaka::Act(float dt){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
initTimer();
|
initTimer();
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("==========\nNew Act CALL\n================\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("==========\nCombat Damages ?\n================\n");
|
|
||||||
#endif
|
|
||||||
if (combatDamages()) return 0;
|
if (combatDamages()) return 0;
|
||||||
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
OutputDebugString("==========\nChoose Target ?\n================\n");
|
|
||||||
#endif
|
|
||||||
if (chooseTarget()) return 0;
|
if (chooseTarget()) return 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -552,12 +514,6 @@ int AIPlayerBaka::Act(float dt){
|
|||||||
|
|
||||||
//No mana, try to get some
|
//No mana, try to get some
|
||||||
getPotentialMana();
|
getPotentialMana();
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
char buffe[4096];
|
|
||||||
|
|
||||||
sprintf(buffe,"potentail mana %i\n",potentialMana->getConvertedCost() );
|
|
||||||
OutputDebugString(buffe);
|
|
||||||
#endif
|
|
||||||
if (potentialMana->getConvertedCost() > 0){
|
if (potentialMana->getConvertedCost() > 0){
|
||||||
|
|
||||||
|
|
||||||
@@ -570,6 +526,7 @@ int AIPlayerBaka::Act(float dt){
|
|||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(potentialMana, "sorcery");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(potentialMana, "sorcery");
|
||||||
if (nextCardToPlay){
|
if (nextCardToPlay){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
|
char buffe[4096];
|
||||||
sprintf(buffe, "Putting Card Into Play: %s", nextCardToPlay->getName());
|
sprintf(buffe, "Putting Card Into Play: %s", nextCardToPlay->getName());
|
||||||
OutputDebugString(buffe);
|
OutputDebugString(buffe);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -33,28 +33,16 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
|
|||||||
}
|
}
|
||||||
|
|
||||||
MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card){
|
MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card){
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString("Match AND\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MTGCardInstance * match = card;
|
MTGCardInstance * match = card;
|
||||||
for (int i = 0; i< nb_types; i++){
|
for (int i = 0; i< nb_types; i++){
|
||||||
|
|
||||||
if (!card->hasSubtype(types[i])){
|
if (!card->hasSubtype(types[i])){
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString(card->name.c_str());
|
|
||||||
OutputDebugString("Subtype No Match\n");
|
|
||||||
#endif
|
|
||||||
match = NULL;
|
match = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i< MTG_NB_COLORS; i++){
|
for (int i = 0; i< MTG_NB_COLORS; i++){
|
||||||
if ((colors[i] == 1 && !card->hasColor(i))||(colors[i] == -1 && card->hasColor(i))){
|
if ((colors[i] == 1 && !card->hasColor(i))||(colors[i] == -1 && card->hasColor(i))){
|
||||||
match = NULL;
|
match = NULL;
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString(card->name.c_str());
|
|
||||||
OutputDebugString("Color No Match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return match;
|
return match;
|
||||||
@@ -116,11 +104,6 @@ MTGCardInstance * CardDescriptor::nextmatch(MTGGameZone * zone, MTGCardInstance
|
|||||||
if (NULL == previous) found = 1;
|
if (NULL == previous) found = 1;
|
||||||
for(int i=0; i < zone->nb_cards; i++){
|
for(int i=0; i < zone->nb_cards; i++){
|
||||||
if(found && match(zone->cards[i])){
|
if(found && match(zone->cards[i])){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
char buf[4096];
|
|
||||||
sprintf(buf,"Card Descriptor MATCH!: %s \n" ,(zone->cards[i])->getName());
|
|
||||||
OutputDebugString(buf);
|
|
||||||
#endif
|
|
||||||
return zone->cards[i];
|
return zone->cards[i];
|
||||||
}
|
}
|
||||||
if (zone->cards[i] == previous){
|
if (zone->cards[i] == previous){
|
||||||
|
|||||||
@@ -126,22 +126,40 @@ SampleCache * SampleCache::GetInstance(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSample * SampleCache::getSample(string filename){
|
JSample * SampleCache::getSample(string filename){
|
||||||
map<string,JSample *>::iterator it = cache.find(filename);
|
map<string,SampleCached *>::iterator it = cache.find(filename);
|
||||||
if (it == cache.end()){
|
if (it == cache.end()){
|
||||||
if (cache.size() >10) cleanCache(); //Poor man's limit
|
if (cache.size() >10) cleanOldest(); //Poor man's limit
|
||||||
JSample * sample = JSoundSystem::GetInstance()->LoadSample(filename.c_str());
|
JSample * sample = JSoundSystem::GetInstance()->LoadSample(filename.c_str());
|
||||||
if (!sample && fileExists(filename.c_str())){ //Out of Ram ??
|
if (!sample && fileExists(filename.c_str())){ //Out of Ram ??
|
||||||
cleanCache();
|
cleanCache();
|
||||||
sample = JSoundSystem::GetInstance()->LoadSample(filename.c_str());
|
sample = JSoundSystem::GetInstance()->LoadSample(filename.c_str());
|
||||||
}
|
}
|
||||||
|
lastTime++;
|
||||||
|
cache[filename] = NEW SampleCached(lastTime, sample);
|
||||||
return sample;
|
return sample;
|
||||||
}else{
|
}else{
|
||||||
return (it->second);
|
return (it->second->sample);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SampleCache::cleanOldest(){
|
||||||
|
int smallest = lastTime;
|
||||||
|
map<string,SampleCached *>::iterator found = cache.end();
|
||||||
|
map<string,SampleCached *>::iterator it;
|
||||||
|
for (it = cache.begin(); it != cache.end(); it++){
|
||||||
|
if(it->second->lastTime <= smallest){
|
||||||
|
smallest = it->second->lastTime;
|
||||||
|
found = it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found != cache.end()){
|
||||||
|
delete (found->second);
|
||||||
|
cache.erase(found);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SampleCache::cleanCache(){
|
void SampleCache::cleanCache(){
|
||||||
map<string,JSample *>::iterator it;
|
map<string,SampleCached *>::iterator it;
|
||||||
for (it = cache.begin(); it != cache.end(); it++){
|
for (it = cache.begin(); it != cache.end(); it++){
|
||||||
delete(it->second);
|
delete(it->second);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user