Erwan
- Added some outputs in debug mode for bad formatted _cards.dat
This commit is contained in:
@@ -793,7 +793,7 @@ text=All lands are 1/1 creatures that are still lands.
|
|||||||
id=1533
|
id=1533
|
||||||
name=Living Plane
|
name=Living Plane
|
||||||
rarity=R
|
rarity=R
|
||||||
type=World Enchantment
|
type=Enchantment
|
||||||
mana={2}{G}{G}
|
mana={2}{G}{G}
|
||||||
[/card]
|
[/card]
|
||||||
[card]
|
[card]
|
||||||
|
|||||||
@@ -228,8 +228,8 @@ rarity=C
|
|||||||
id=152720
|
id=152720
|
||||||
name=Stream of Unconsciousness
|
name=Stream of Unconsciousness
|
||||||
mana={U}
|
mana={U}
|
||||||
type=Tribal Instant
|
type=Instant
|
||||||
subtype=Wizard
|
subtype=Wizard Tribal
|
||||||
text=Target creature gets -4/-0 until end of turn. If you control a Wizard, draw a card.
|
text=Target creature gets -4/-0 until end of turn. If you control a Wizard, draw a card.
|
||||||
target=creature
|
target=creature
|
||||||
auto=-4/0
|
auto=-4/0
|
||||||
@@ -258,8 +258,8 @@ auto=token(Faerie Rogue,Creature Faerie,1/1,flying black)
|
|||||||
name=Violet Pall
|
name=Violet Pall
|
||||||
rarity=C
|
rarity=C
|
||||||
mana={4}{B}
|
mana={4}{B}
|
||||||
type=Tribal Instant
|
type=Instant
|
||||||
subtype=Faerie
|
subtype=Faerie Tribal
|
||||||
[/card]
|
[/card]
|
||||||
[card]
|
[card]
|
||||||
text={3}{B}, Sacrifice a Goblin: Put two 1/1 black Goblin Rogue creature tokens onto the battlefield.
|
text={3}{B}, Sacrifice a Goblin: Put two 1/1 black Goblin Rogue creature tokens onto the battlefield.
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ class MtgSets{
|
|||||||
class MTGAllCards {
|
class MTGAllCards {
|
||||||
private:
|
private:
|
||||||
MTGCard * tempCard;
|
MTGCard * tempCard;
|
||||||
|
#if defined (_DEBUG)
|
||||||
|
bool committed;
|
||||||
|
#endif
|
||||||
protected:
|
protected:
|
||||||
int conf_read_mode;
|
int conf_read_mode;
|
||||||
int colorsCount[Constants::MTG_NB_COLORS];
|
int colorsCount[Constants::MTG_NB_COLORS];
|
||||||
|
|||||||
@@ -43,7 +43,15 @@ int MtgSets::find(string name){
|
|||||||
|
|
||||||
int MTGAllCards::processConfLine(string s, MTGCard *card){
|
int MTGAllCards::processConfLine(string s, MTGCard *card){
|
||||||
unsigned int i = s.find_first_of("=");
|
unsigned int i = s.find_first_of("=");
|
||||||
if (i == string::npos) return 0;
|
if (i == string::npos){
|
||||||
|
#if defined (_DEBUG)
|
||||||
|
if (s.size() && s[0] == '#') return 0;
|
||||||
|
char buffer[4096];
|
||||||
|
sprintf(buffer, "MTGDECK: Bad Line in %s/_cards.dat:\n %s\n", MtgSets::SetsList->values[card->setId].c_str(), s.c_str());
|
||||||
|
OutputDebugString(buffer);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
string key = s.substr(0,i);
|
string key = s.substr(0,i);
|
||||||
string value = s.substr(i+1);
|
string value = s.substr(i+1);
|
||||||
|
|
||||||
@@ -95,34 +103,46 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
|
|||||||
}else if(key.compare("type")==0){
|
}else if(key.compare("type")==0){
|
||||||
switch(value.c_str()[0]){
|
switch(value.c_str()[0]){
|
||||||
case 'C':
|
case 'C':
|
||||||
|
case 'c':
|
||||||
card->setType( "Creature");
|
card->setType( "Creature");
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
|
case 'a':
|
||||||
card->setType( "Artifact");
|
card->setType( "Artifact");
|
||||||
card->setColor(Constants::MTG_COLOR_ARTIFACT);
|
card->setColor(Constants::MTG_COLOR_ARTIFACT);
|
||||||
if (value.c_str()[8] == ' ' && value.c_str()[9] == 'C')
|
if (value.c_str()[8] == ' ' && value.c_str()[9] == 'C')
|
||||||
card->setSubtype("Creature");
|
card->setSubtype("Creature");
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
|
case 'e':
|
||||||
card->setType( "Enchantment");
|
card->setType( "Enchantment");
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
|
case 's':
|
||||||
card->setType( "Sorcery");
|
card->setType( "Sorcery");
|
||||||
break;
|
break;
|
||||||
case 'B'://Basic Land
|
case 'B'://Basic Land
|
||||||
|
case 'b':
|
||||||
card->setColor(Constants::MTG_COLOR_LAND);
|
card->setColor(Constants::MTG_COLOR_LAND);
|
||||||
card->setType("Land");
|
card->setType("Land");
|
||||||
card->setType("Basic");
|
card->setType("Basic");
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
|
case 'l':
|
||||||
card->setColor(Constants::MTG_COLOR_LAND);
|
card->setColor(Constants::MTG_COLOR_LAND);
|
||||||
card->setType( "Land");
|
card->setType( "Land");
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
|
case 'i':
|
||||||
card->setType( "Instant");
|
card->setType( "Instant");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
card->setType( "Error");
|
card->setType( "Error");
|
||||||
|
#if defined (_DEBUG)
|
||||||
|
char buffer[4096];
|
||||||
|
sprintf(buffer, "MTGDECK: Bad Card Type in %s/_cards.dat:\n %s\n", MtgSets::SetsList->values[card->setId].c_str(), s.c_str());
|
||||||
|
OutputDebugString(buffer);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -167,6 +187,9 @@ void MTGAllCards::init(){
|
|||||||
total_cards = 0;
|
total_cards = 0;
|
||||||
initCounters();
|
initCounters();
|
||||||
srand(time(0)); // initialize random
|
srand(time(0)); // initialize random
|
||||||
|
#if defined (_DEBUG)
|
||||||
|
committed = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -274,6 +297,14 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
|
|||||||
switch(conf_read_mode) {
|
switch(conf_read_mode) {
|
||||||
case 0:
|
case 0:
|
||||||
if (s[0] == '['){
|
if (s[0] == '['){
|
||||||
|
#if defined (_DEBUG)
|
||||||
|
if (!committed){
|
||||||
|
OutputDebugString("MTGDECK: Card not committed before creating new one, Memory leak risk\n ");
|
||||||
|
OutputDebugString(tempCard->getName().c_str());
|
||||||
|
OutputDebugString("\n");
|
||||||
|
}
|
||||||
|
committed = false;
|
||||||
|
#endif
|
||||||
tempCard = NEW MTGCard(set_id);
|
tempCard = NEW MTGCard(set_id);
|
||||||
conf_read_mode = 1;
|
conf_read_mode = 1;
|
||||||
}
|
}
|
||||||
@@ -291,6 +322,9 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
|
|||||||
ids.push_back(newId);
|
ids.push_back(newId);
|
||||||
collection[newId] = tempCard;
|
collection[newId] = tempCard;
|
||||||
total_cards++;
|
total_cards++;
|
||||||
|
#if defined (_DEBUG)
|
||||||
|
committed = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
processConfLine(s, tempCard);
|
processConfLine(s, tempCard);
|
||||||
|
|||||||
Reference in New Issue
Block a user