* Fixes for compilation on 64-bit architectures :
  string position-returning functions return size_t, not uint.
  Fix that.
* Fixes warnings with new gcc about non-fixed string AND no arguments.

NOTE : 64-bit architectures still do not compile. There are 2 different places
where printf is used with a specifier that is not large enough on 64-bit because
size_t is now a ulong and not a uint. The solution on GNU systems is the %zu
specifier, but as I'm not sure it is supported on windows I don't want to
introduce a huge hard-to-notice bug, so I'll do it at a time when I got a
windowser to back me up.
This commit is contained in:
jean.chalard
2010-01-25 09:58:30 +00:00
parent 9b91fab61b
commit 0a083f4385
13 changed files with 48 additions and 49 deletions

View File

@@ -649,14 +649,14 @@ public:
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
unsigned int found = sabilities.find(Constants::MTGBasicAbilities[j]);
size_t found = sabilities.find(Constants::MTGBasicAbilities[j]);
if (found != string::npos){
abilities.push_back(j);
}
}
for (int j = 0; j < Constants::MTG_NB_COLORS; j++){
unsigned int found = sabilities.find(Constants::MTGColorStrings[j]);
size_t found = sabilities.find(Constants::MTGColorStrings[j]);
if (found != string::npos){
colors.push_back(j);
}
@@ -664,7 +664,7 @@ public:
string s = stypes;
while (s.size()){
unsigned int found = s.find(" ");
size_t found = s.find(" ");
if (found != string::npos){
int id = Subtypes::subtypesList->find(s.substr(0,found));
types.push_back(id);
@@ -2154,14 +2154,14 @@ public:
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
unsigned int found = sabilities.find(Constants::MTGBasicAbilities[j]);
size_t found = sabilities.find(Constants::MTGBasicAbilities[j]);
if (found != string::npos){
abilities.push_back(j);
}
}
for (int j = 0; j < Constants::MTG_NB_COLORS; j++){
unsigned int found = sabilities.find(Constants::MTGColorStrings[j]);
size_t found = sabilities.find(Constants::MTGColorStrings[j]);
if (found != string::npos){
colors.push_back(j);
}
@@ -2169,7 +2169,7 @@ public:
string s = stypes;
while (s.size()){
unsigned int found = s.find(" ");
size_t found = s.find(" ");
if (found != string::npos){
int id = Subtypes::subtypesList->find(s.substr(0,found));
types.push_back(id);

View File

@@ -565,10 +565,10 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op
char deckFileSmall[512];
if (deckid == -1){ //Evil twin
sprintf(deckFile, opponent->deckFile.c_str());
sprintf(deckFile, "%s", opponent->deckFile.c_str());
OutputDebugString(opponent->deckFile.c_str());
sprintf(avatarFile, "baka.jpg");
sprintf(deckFileSmall, "ai_baka_eviltwin");
sprintf(avatarFile, "%s", "baka.jpg");
sprintf(deckFileSmall, "%s", "ai_baka_eviltwin");
}else{
if (!deckid){
int nbdecks = 0;

View File

@@ -771,17 +771,17 @@ void ActionStack::Render(){
// seconds if the user disables auto progressing interrupts by setting the seconds
// value to zero in Options.
if (options[Options::INTERRUPT_SECONDS].number == 0)
sprintf(buffer, _("Interrupt?").c_str());
sprintf(buffer, "%s", _("Interrupt?").c_str());
else
sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast<int>(timer));
sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast<int>(timer));
//WALDORF - removed all the unnecessary math. just display the prompt at the
// top of the box.
mFont->DrawString(buffer, x0 + 5, y0);
if (mCount > 1) sprintf(buffer, _("X Interrupt - 0 No - [] No to All").c_str());
else sprintf(buffer, _("X Interrupt - 0 No").c_str());
if (mCount > 1) sprintf(buffer, "%s", _("X Interrupt - 0 No - [] No to All").c_str());
else sprintf(buffer, "%s", _("X Interrupt - 0 No").c_str());
// WALDORF - puts the button legend right under the prompt. the stack
// will be displayed below it now. no more need to do wierd currY math.

View File

@@ -185,7 +185,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
{
char name[4096];
sprintf(name, _(card->data->getName()).c_str());
sprintf(name, "%s", _(card->data->getName()).c_str());
float w = font->GetStringWidth(name) * 0.8 * pos.actZ;
if (w > BigWidth - 30)
font->SetScale((BigWidth - 30) / w);

View File

@@ -179,7 +179,7 @@ void Credits::Render(){
f3->SetColor(ARGB(255,255,255,255));
char buffer[512];
if (!g->turn){
sprintf(buffer, _("Please check your deck (not enough cards?)").c_str() );
sprintf(buffer, "%s", _("Please check your deck (not enough cards?)").c_str() );
}else{
if (!p1->isAI() && p2->isAI() ){
if (g->gameOver != p1){
@@ -192,7 +192,7 @@ void Credits::Render(){
f2->DrawString(unlockedString.c_str(),SCREEN_WIDTH/2, 80,JGETEXT_CENTER);
}
}else{
sprintf (buffer, _("You have been defeated").c_str());
sprintf (buffer, "%s", _("You have been defeated").c_str());
}
}else{
int winner = 2;

View File

@@ -71,7 +71,7 @@ void SacrificeCost::Render(){
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255));
char buffer[200];
sprintf(buffer, _("sacrifice").c_str());
sprintf(buffer, "%s", _("sacrifice").c_str());
mFont->DrawString(buffer, 20 ,20, JGETEXT_LEFT);
}

View File

@@ -273,7 +273,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
}
int limit = 0;
unsigned int limit_str = sWithoutTc.find("limit:");
size_t limit_str = sWithoutTc.find("limit:");
if (limit_str != string::npos){
limit = atoi(sWithoutTc.substr(limit_str+6).c_str());
}
@@ -577,9 +577,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
//Damage
found = s.find("damage");
if (found != string::npos){
unsigned int start = s.find(":",found);
size_t start = s.find(":",found);
if (start == string::npos) start = s.find(" ",found);
unsigned int end = s.find(" ",start);
size_t end = s.find(" ",start);
string d;
if (end != string::npos){
d = s.substr(start+1,end-start-1);
@@ -598,8 +598,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
//gain/lose life
found = s.find("life:");
if (found != string::npos){
unsigned int start = found+4;
unsigned int end = s.find(" ",start);
size_t start = found+4;
size_t end = s.find(" ",start);
string life_s;
if (end != string::npos){
life_s = s.substr(start+1,end-start-1);
@@ -617,8 +617,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
//Draw
found = s.find("draw:");
if (found != string::npos){
unsigned int start = s.find(":",found);
unsigned int end = s.find(" ",start);
size_t start = s.find(":",found);
size_t end = s.find(" ",start);
string nbcardsStr;
if (end != string::npos){
nbcardsStr = s.substr(start+1,end-start-1);
@@ -636,8 +636,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
//Deplete
found = s.find("deplete:");
if (found != string::npos){
unsigned int start = s.find(":",found);
unsigned int end = s.find(" ",start);
size_t start = s.find(":",found);
size_t end = s.find(" ",start);
int nbcards;
if (end != string::npos){
nbcards = atoi(s.substr(start+1,end-start-1).c_str());
@@ -665,8 +665,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
//Discard
found = s.find("discard:");
if (found != string::npos){
unsigned int start = s.find(":",found);
unsigned int end = s.find(" ",start);
size_t start = s.find(":",found);
size_t end = s.find(" ",start);
int nbcards;
if (end != string::npos){
nbcards = atoi(s.substr(start+1,end-start-1).c_str());
@@ -971,7 +971,7 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
string line;
int size = magicText.size();
if (size == 0) return 0;
unsigned int found;
size_t found;
int result = id;
while (magicText.size()){

View File

@@ -17,7 +17,7 @@ using std::string;
//MTGAllCards
int MTGAllCards::processConfLine(string s, MTGCard *card, CardPrimitive * primitive){
if (s.size() && s[0] == '#') return 0;
unsigned int i = s.find_first_of("=");
size_t i = s.find_first_of("=");
if (i == string::npos){
#if defined (_DEBUG)
char buffer[4096];
@@ -114,7 +114,7 @@ int MTGAllCards::processConfLine(string s, MTGCard *card, CardPrimitive * primit
case 's': //subtype
if(!primitive) primitive = NEW CardPrimitive();
while (value.size()){
unsigned int found = value.find(" ");
size_t found = value.find(" ");
if (found != string::npos){
primitive->setSubtype(value.substr(0,found));
value = value.substr(found+1);
@@ -136,7 +136,7 @@ int MTGAllCards::processConfLine(string s, MTGCard *card, CardPrimitive * primit
}else if (key.compare("type")==0) {
if(!primitive) primitive = NEW CardPrimitive();
while (value.size()){
unsigned int found = value.find(" ");
size_t found = value.find(" ");
if (found != string::npos){
primitive->setType(value.substr(0,found).c_str());
value = value.substr(found+1);
@@ -514,7 +514,7 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
char subtype[4096];
if (_subtype)
sprintf(subtype, _subtype);
sprintf(subtype, "%s", _subtype);
vector<int> subcollection;
@@ -832,7 +832,7 @@ string MTGSetInfo::getBlock(){
void MTGSetInfo::processConfLine(string line){
unsigned int i = line.find_first_of("=");
size_t i = line.find_first_of("=");
if (i == string::npos)
return;
@@ -848,4 +848,4 @@ void MTGSetInfo::processConfLine(string line){
block = setlist.findBlock(value.c_str());
else if(key.compare("year") == 0)
year = atoi(value.c_str());
}
}

View File

@@ -20,8 +20,8 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
manaCost = NEW ManaCost();
}
int state = 0;
unsigned int start = 0;
unsigned int end = 0;
size_t start = 0;
size_t end = 0;
while (!s.empty() && state != -1){
switch(state){
case 0:
@@ -464,4 +464,4 @@ int ManaPool::pay (ManaCost * _cost){
}
}
return result;
}
}

View File

@@ -87,11 +87,10 @@ void OptionInteger::Render(){
mFont->DrawString(_(displayValue).c_str(),x,y);
char buf[512];
if (maxValue == 1){
if (value){
sprintf(buf, _("Yes").c_str());
}else{
sprintf(buf,_("No").c_str());
}
if (value)
sprintf(buf, "%s", _("Yes").c_str());
else
sprintf(buf, "%s", _("No").c_str());
}else{
if(value == defValue && strDefault.size())
sprintf(buf, "%s", _(strDefault).c_str());

View File

@@ -330,7 +330,7 @@ void ShopItems::Render(){
mFont->SetColor(ARGB(255,255,255,255));
char c[4096];
r->FillRect(0,SCREEN_HEIGHT-17,SCREEN_WIDTH,17,ARGB(128,0,0,0));
sprintf(c, _("[]:other cards").c_str());
sprintf(c, "%s", _("[]:other cards").c_str());
unsigned int len = 4 + mFont->GetStringWidth(c);
mFont->DrawString(c,SCREEN_WIDTH-len,SCREEN_HEIGHT-14);

View File

@@ -31,7 +31,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
found = s.find("player");
if (found != string::npos){
int maxtargets = 1;
unsigned int several = s.find_first_of('s',5);
size_t several = s.find_first_of('s',5);
if (several != string::npos) maxtargets = -1;
found = s.find("creature");
if (found != string::npos) return NEW DamageableTargetChooser(card,maxtargets,other); //Any Damageable target (player, creature)
@@ -106,7 +106,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
string attributes = typeName.substr(found+1,end-found-1);
cd = NEW CardDescriptor();
while(attributes.size()){
unsigned int found2 = attributes.find(";");
size_t found2 = attributes.find(";");
string attribute;
if (found2 != string::npos){
cd->mode = CD_OR;
@@ -736,4 +736,4 @@ bool DamageTargetChooser::canTarget(Targetable * target){
DamageTargetChooser* DamageTargetChooser::clone() const{
DamageTargetChooser * a = NEW DamageTargetChooser(*this);
return a;
}
}

View File

@@ -123,7 +123,7 @@ int TestSuiteAI::Act(float dt){
g->mLayers->actionLayer()->stuffHappened = 1;
}else if(action.find("p1")!=string::npos || action.find("p2")!=string::npos){
Player * p = g->players[1];
unsigned int start = action.find("p1");
size_t start = action.find("p1");
if (start != string::npos) p = g->players[0];
g->cardClick(NULL, p);
}else{
@@ -186,7 +186,7 @@ TestSuiteState::TestSuiteState(){
}
void TestSuiteState::parsePlayerState(int playerId, string s){
unsigned int limiter = s.find(":");
size_t limiter = s.find(":");
string areaS;
int area;
if (limiter != string::npos){