- some performance improvements
- "daily build". The daily build was compiled in "profile" mode. If you have problems running the exe, or problems with Visual Studio please let me know
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-10-08 12:17:07 +00:00
parent e4a277f9ff
commit 46ef86b9d8
10 changed files with 348 additions and 35 deletions
+2 -20
View File
@@ -106,6 +106,7 @@ void MTGCardInstance::initMTGCI(){
lastController = NULL;
regenerateTokens = 0;
blocked = false;
currentZone = NULL;
}
@@ -184,16 +185,7 @@ int MTGCardInstance::destroy(){
}
MTGGameZone * MTGCardInstance::getCurrentZone(){
GameObserver * game = GameObserver::GetInstance();
for (int i = 0; i < 2; i++){
MTGPlayerCards * g = game->players[i]->game;
MTGGameZone * zones[] = {g->inPlay,g->graveyard,g->hand, g->library, g->stack, g->temp};
for (int k = 0; k < 6; k++){
MTGGameZone * zone = zones[k];
if (zone->hasCard(this)) return zone;
}
}
return NULL;
return currentZone;
}
int MTGCardInstance::has(int basicAbility){
@@ -319,16 +311,6 @@ int MTGCardInstance::reset(){
Player * MTGCardInstance::controller(){
GameObserver * game = GameObserver::GetInstance();
if (!game) return NULL;
for (int i = 0; i < 2; ++i){
if (game->players[i]->game->inPlay->hasCard(this)) return game->players[i];
if (game->players[i]->game->stack->hasCard(this)) return game->players[i];
if (game->players[i]->game->graveyard->hasCard(this)) return game->players[i];
if (game->players[i]->game->hand->hasCard(this)) return game->players[i];
if (game->players[i]->game->library->hasCard(this)) return game->players[i];
if (game->players[i]->game->temp->hasCard(this)) return game->players[i];
}
return lastController;
}
+4 -1
View File
@@ -186,6 +186,7 @@ MTGGameZone::~MTGGameZone(){
void MTGGameZone::setOwner(Player * player){
for (int i=0; i<nb_cards; i++) {
cards[i]->owner = player;
cards[i]->lastController = player;
}
owner = player;
}
@@ -195,6 +196,7 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
cardsMap.erase(card);
for (i=0; i<(nb_cards); i++) {
if (cards[i] == card){
card->currentZone = NULL;
nb_cards--;
cards.erase(cards.begin()+i);
MTGCardInstance * copy = card;
@@ -216,7 +218,7 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
}
MTGCardInstance * MTGGameZone::hasCard(MTGCardInstance * card){
if (cardsMap.find(card) != cardsMap.end()) return card;
if (card->currentZone == this) return card;
return NULL;
}
@@ -273,6 +275,7 @@ void MTGGameZone::addCard(MTGCardInstance * card){
nb_cards++;
cardsMap[card] = 1;
card->lastController = this->owner;
card->currentZone = this;
}
+4 -6
View File
@@ -17,6 +17,7 @@ int Subtypes::Add(string value){
std::transform( value.begin(), value.end(), value.begin(), ::tolower );
nb_items++;
values[value] = nb_items;
valuesById[nb_items] = value;
return nb_items;
}
@@ -39,11 +40,8 @@ int Subtypes::find(const char * subtype){
}
/*This will be slow... */
string Subtypes::find(int id){
map<string,int>::iterator it;
for (it = values.begin(); it != values.end(); it++){
if (it->second == id) return it->first;
}
return NULL;
map<int,string>::iterator it=valuesById.find(id);;
if (it != valuesById.end()) return it->second;
return "";
}