Erwan
- various optimization fixes
This commit is contained in:
@@ -26,7 +26,7 @@ class ActionLayer: public GuiLayer, public JGuiListener{
|
||||
virtual void Update(float dt);
|
||||
int unstoppableRenderInProgress();
|
||||
bool CheckUserInput(u32 key);
|
||||
ActionLayer(){ menuObject = NULL; abilitiesMenu = NULL; stuffHappened = 0;};
|
||||
ActionLayer();
|
||||
~ActionLayer();
|
||||
int cancelCurrentAction();
|
||||
ActionElement * isWaitingForAnswer();
|
||||
@@ -42,9 +42,12 @@ class ActionLayer: public GuiLayer, public JGuiListener{
|
||||
void ButtonPressed(int controllerid, int controlid);
|
||||
void doReactTo(int menuIndex);
|
||||
TargetChooser * getCurrentTargetChooser();
|
||||
void setCurrentWaitingAction(ActionElement * ae);
|
||||
MTGAbility * getAbility(int type);
|
||||
int moveToGarbage(ActionElement * e);
|
||||
int cleanGarbage();
|
||||
protected:
|
||||
ActionElement * currentWaitingAction;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -579,11 +579,11 @@ public:
|
||||
while (s.size()){
|
||||
unsigned int found = s.find(" ");
|
||||
if (found != string::npos){
|
||||
int id = Subtypes::subtypesList->Add(s.substr(0,found));
|
||||
int id = Subtypes::subtypesList->find(s.substr(0,found));
|
||||
types.push_back(id);
|
||||
s = s.substr(found+1);
|
||||
}else{
|
||||
int id = Subtypes::subtypesList->Add(s);
|
||||
int id = Subtypes::subtypesList->find(s);
|
||||
types.push_back(id);
|
||||
s = "";
|
||||
}
|
||||
@@ -1502,7 +1502,7 @@ class AConvertLandToCreatures:public ListMaintainerAbility{
|
||||
int type;
|
||||
int power, toughness;
|
||||
AConvertLandToCreatures(int _id, MTGCardInstance * _source, const char * _type, int _power = 1, int _toughness = 1):ListMaintainerAbility(_id, _source),power(_power),toughness(_toughness){
|
||||
type = Subtypes::subtypesList->Add(_type);
|
||||
type = Subtypes::subtypesList->find(_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -2054,11 +2054,11 @@ public:
|
||||
while (s.size()){
|
||||
unsigned int found = s.find(" ");
|
||||
if (found != string::npos){
|
||||
int id = Subtypes::subtypesList->Add(s.substr(0,found));
|
||||
int id = Subtypes::subtypesList->find(s.substr(0,found));
|
||||
types.push_back(id);
|
||||
s = s.substr(found+1);
|
||||
}else{
|
||||
int id = Subtypes::subtypesList->Add(s);
|
||||
int id = Subtypes::subtypesList->find(s);
|
||||
types.push_back(id);
|
||||
s = "";
|
||||
}
|
||||
@@ -2243,7 +2243,7 @@ class AAnkhOfMishra: public ListMaintainerAbility{
|
||||
}
|
||||
|
||||
int canBeInList(MTGCardInstance * card){
|
||||
if (card->hasType("land") && game->isInPlay(card)) return 1;
|
||||
if (card->hasType(Subtypes::TYPE_LAND) && game->isInPlay(card)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2541,7 +2541,7 @@ class ADingusEgg: public ListMaintainerAbility{
|
||||
}
|
||||
|
||||
int canBeInList(MTGCardInstance * card){
|
||||
if (card->hasType("land") && game->isInPlay(card)) return 1;
|
||||
if (card->hasType(Subtypes::TYPE_LAND) && game->isInPlay(card)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2581,9 +2581,12 @@ class ADisruptingScepter:public TargetAbility{
|
||||
void Update(float dt){
|
||||
if (game->opponent()->isAI()){
|
||||
if(waitingForAnswer){
|
||||
MTGCardInstance * card = ((AIPlayer *)game->opponent())->chooseCard(tc, source);
|
||||
if (card) tc->toggleTarget(card);
|
||||
if (!card || tc->targetsReadyCheck() == TARGET_OK) waitingForAnswer = 0;
|
||||
MTGCardInstance * card = ((AIPlayer *)game->opponent())->chooseCard(tc, source);
|
||||
if (card) tc->toggleTarget(card);
|
||||
if (!card || tc->targetsReadyCheck() == TARGET_OK) {
|
||||
waitingForAnswer = 0;
|
||||
game->mLayers->actionLayer()->setCurrentWaitingAction(NULL);
|
||||
}
|
||||
}
|
||||
TargetAbility::Update(dt);
|
||||
}else{
|
||||
@@ -3138,7 +3141,7 @@ class AKudzu: public TargetAbility{
|
||||
int testDestroy(){
|
||||
int stillLandsInPlay = 0;
|
||||
for (int i = 0; i < 2; i++){
|
||||
if (game->players[i]->game->inPlay->hasType("land")) stillLandsInPlay = 1;
|
||||
if (game->players[i]->game->inPlay->hasType("Land")) stillLandsInPlay = 1;
|
||||
}
|
||||
if (!stillLandsInPlay){
|
||||
source->controller()->game->putInGraveyard(source);
|
||||
@@ -4051,7 +4054,7 @@ class AAngelicChorus: public ListMaintainerAbility{
|
||||
}
|
||||
|
||||
int canBeInList(MTGCardInstance * card){
|
||||
if (card->hasType("creature") && game->isInPlay(card)) return 1;
|
||||
if (card->hasType(Subtypes::TYPE_CREATURE) && game->isInPlay(card)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,10 @@ class GameApp: public JApp
|
||||
{
|
||||
|
||||
private:
|
||||
#ifdef DEBUG
|
||||
int nbUpdates;
|
||||
float totalFPS;
|
||||
#endif
|
||||
bool mShowDebugInfo;
|
||||
int mScreenShotCount;
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ class GameStateShop: public GameState, public JGuiListener
|
||||
ShopItems * shop;
|
||||
JLBFont * menuFont;
|
||||
JLBFont * itemFont;
|
||||
JQuad * mBg;
|
||||
JTexture * bgTexture;
|
||||
JTexture * altThumb[8];
|
||||
JQuad * mBack;
|
||||
SimpleMenu * menu;
|
||||
|
||||
@@ -29,6 +29,7 @@ class MTGCard {
|
||||
char image_name[MTGCARD_NAME_SIZE];
|
||||
vector<string> ftdText;
|
||||
int init();
|
||||
string lcname;
|
||||
|
||||
public:
|
||||
string text;
|
||||
@@ -77,6 +78,7 @@ class MTGCard {
|
||||
|
||||
void setName(string value);
|
||||
const string getName() const;
|
||||
const string getLCName() const;
|
||||
|
||||
void addType(char * type_text);
|
||||
void addType(int id);
|
||||
|
||||
@@ -4,22 +4,31 @@
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
using std::string;
|
||||
using std::map;
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
|
||||
class Subtypes{
|
||||
public:
|
||||
enum {
|
||||
TYPE_CREATURE = 1,
|
||||
TYPE_ENCHANTMENT = 2,
|
||||
TYPE_SORCERY = 3,
|
||||
TYPE_INSTANT = 4,
|
||||
TYPE_LAND = 5,
|
||||
TYPE_ARTIFACT = 6,
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
map<string,int> values;
|
||||
map<int,string> valuesById;
|
||||
int nb_items;
|
||||
vector<string> valuesById;
|
||||
public:
|
||||
static Subtypes * subtypesList;
|
||||
Subtypes();
|
||||
int Add(const char * subtype);
|
||||
int find(const char * subtype);
|
||||
int Add(string subtype);
|
||||
int find(string subtype);
|
||||
string find(int id);
|
||||
int find(const char * subtype, bool forceAdd = true);
|
||||
int find(string subtype, bool forceAdd = true);
|
||||
string find(unsigned int id);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ public:
|
||||
|
||||
virtual ~WCachedResource() {};
|
||||
|
||||
virtual void Refresh(string filename)=0; //Basically calls Attempt(filename) and remaps in situ.
|
||||
string mFilename;
|
||||
virtual void Refresh()=0; //Basically calls Attempt(filename) and remaps in situ.
|
||||
virtual bool Attempt(string filename, int submode, int & error)=0; //Returns true if we've loaded our data and isGood().
|
||||
};
|
||||
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
WCachedTexture();
|
||||
~WCachedTexture();
|
||||
|
||||
void Refresh(string filename);
|
||||
void Refresh();
|
||||
unsigned long size();
|
||||
bool isGood();
|
||||
bool isLocked();
|
||||
@@ -98,7 +99,7 @@ public:
|
||||
|
||||
void Nullify();
|
||||
void Trash();
|
||||
void Refresh(string filename);
|
||||
void Refresh();
|
||||
unsigned long size();
|
||||
|
||||
bool isGood();
|
||||
@@ -121,7 +122,7 @@ public:
|
||||
bool compare(JSample * s) {return (s == sample);};
|
||||
unsigned long size();
|
||||
bool isGood();
|
||||
void Refresh(string filename);
|
||||
void Refresh();
|
||||
bool Attempt(string filename, int submode, int & error);
|
||||
|
||||
JSample * Actual(); //Return this sample.
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
#define TEXTURES_CACHE_MINSIZE 2000000 // Minimum size of the cache on the PSP. The program should complain if the cache ever gets smaller than this
|
||||
#define OPERATIONAL_SIZE 5000000 // Size required by Wagic for operational stuff. 3MB is not enough. The cache will usually try to take (Total Ram - Operational size)
|
||||
#define MIN_LINEAR_RAM 1000000
|
||||
|
||||
#define THUMBNAILS_OFFSET 100000000
|
||||
#define OTHERS_OFFSET 2000000000
|
||||
|
||||
//Hard Limits.
|
||||
#define MAX_CACHE_OBJECTS 300
|
||||
#define MAX_CACHE_ATTEMPTS 10
|
||||
@@ -70,9 +74,9 @@ public:
|
||||
WCache();
|
||||
~WCache();
|
||||
|
||||
cacheItem* Retrieve(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); //Primary interface function.
|
||||
cacheItem* Retrieve(int id, string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); //Primary interface function.
|
||||
bool Release(cacheActual* actual); //Releases an item, and deletes it if unlocked.
|
||||
bool RemoveMiss(string id=""); //Removes a cache miss.
|
||||
bool RemoveMiss(int id=0); //Removes a cache miss.
|
||||
bool RemoveOldest(); //Remove oldest unlocked item.
|
||||
bool Cleanup(); //Repeats RemoveOldest() until cache fits in size limits
|
||||
void Clear(); //Removes everything cached. Not lock safe, does not remove managed items.
|
||||
@@ -86,14 +90,14 @@ protected:
|
||||
bool RemoveItem(cacheItem * item, bool force = true); //Removes an item, deleting it. if(force), ignores locks / permanent
|
||||
bool UnlinkCache(cacheItem * item); //Removes an item from our cache, does not delete it. Use with care.
|
||||
bool Delete(cacheItem * item); //SAFE_DELETE and garbage collect. If maxCached == 0, nullify first. (This means you have to free that cacheActual later!)
|
||||
cacheItem* Get(string id, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); //Subordinate to Retrieve.
|
||||
cacheItem* Get(int id, string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); //Subordinate to Retrieve.
|
||||
cacheItem* AttemptNew(string filename, int submode); //Attempts a new cache item, progressively clearing cache if it fails.
|
||||
|
||||
string makeID(string filename, int submode); //Makes an ID appropriate to the submode.
|
||||
string makeFilename(string id, int submode); //Makes a filename from an ID.
|
||||
int makeID(int id, string filename, int submode); //Makes an ID appropriate to the submode.
|
||||
|
||||
map<string,cacheItem*> cache;
|
||||
map<string,cacheItem*> managed; //Cache can be arbitrarily large, so managed items are seperate.
|
||||
map<string,int> ids;
|
||||
map<int,cacheItem*> cache;
|
||||
map<int,cacheItem*> managed; //Cache can be arbitrarily large, so managed items are seperate.
|
||||
unsigned long totalSize;
|
||||
unsigned long cacheSize;
|
||||
|
||||
@@ -104,8 +108,10 @@ protected:
|
||||
unsigned int cacheItems;
|
||||
int mError;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct WManagedQuad {
|
||||
WCachedTexture * texture;
|
||||
string resname;
|
||||
@@ -121,7 +127,7 @@ public:
|
||||
JQuad * RetrieveCard(MTGCard * card, int style = RETRIEVE_NORMAL,int submode = CACHE_NORMAL);
|
||||
JSample * RetrieveSample(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
|
||||
JTexture * RetrieveTexture(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
|
||||
JQuad * RetrieveQuad(string filename, float offX=0.0f, float offY=0.0f, float width=0.0f, float height=0.0f, string resname="", int style = RETRIEVE_LOCK, int submode = CACHE_NORMAL);
|
||||
JQuad * RetrieveQuad(string filename, float offX=0.0f, float offY=0.0f, float width=0.0f, float height=0.0f, string resname="", int style = RETRIEVE_LOCK, int submode = CACHE_NORMAL, int id = 0);
|
||||
JQuad * RetrieveTempQuad(string filename);
|
||||
hgeParticleSystemInfo * RetrievePSI(string filename, JQuad * texture, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
|
||||
int RetrieveError();
|
||||
|
||||
Reference in New Issue
Block a user