Substitute more char arrays with strings

This commit is contained in:
Tobias Loose
2013-11-23 12:57:31 +01:00
parent 3f0dd987f0
commit 9ee44ca091
22 changed files with 61 additions and 50 deletions

View File

@@ -103,7 +103,7 @@ public:
bool hasSubtype(int _subtype);
bool hasSubtype(const string& _subtype);
bool hasType(int _type);
bool hasType(const char * type);
bool hasType(const string& type);
void setManaCost(const string& value);
ManaCost * getManaCost();

View File

@@ -17,7 +17,7 @@ private:
StatsWrapper *stw;
public:
DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const char * _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL);
DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const string& _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL);
void Render();
virtual ~DeckEditorMenu();
};

View File

@@ -79,7 +79,7 @@ public:
virtual void Render();
virtual void Update(float dt);
using JGuiController::Add;
virtual void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
virtual void Add(int id, const string& Text, const string& desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
virtual void Close();
void updateScroller();
void RenderBackground();

View File

@@ -77,9 +77,7 @@ public:
}
// Setters
void setDescription( const string description ) { mDescription = description; };
;
void setDescription( const string& description ) { mDescription = description; }
};
#endif

View File

@@ -98,7 +98,7 @@ public:
string getManaColorIndex();
void updateStats(string filename, MTGAllCards * collection);
void updateStats(DeckDataWrapper *mtgDeck);
int countCardsByType(const char * _type, DeckDataWrapper * myDeck);
int countCardsByType(const string& _type, DeckDataWrapper * myDeck);
float noLuck(int n, int a, int x);
vector<string> aiDeckNames;

View File

@@ -98,8 +98,8 @@ class GameObserver{
int cardClick(MTGCardInstance * card,Targetable * _object = NULL, bool log = true);
GamePhase getCurrentGamePhase();
void setCurrentGamePhase(GamePhase phase) { mCurrentGamePhase = phase; };
const char * getCurrentGamePhaseName();
const char * getNextGamePhaseName();
const string& getCurrentGamePhaseName();
const string& getNextGamePhaseName();
void nextCombatStep();
void userRequestNextGamePhase(bool allowInterrupt = true, bool log = true);
void cleanupPhase();

View File

@@ -129,11 +129,11 @@ public:
//types
void addType(char * type_text);
void addType(const string& type_text);
virtual void addType(int id);
void setType(const char * type_text);
void setSubtype( string value);
int removeType(string value, int removeAll = 0);
void setType(const string& type_text);
void setSubtype(const string &value);
int removeType(const string &value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
//dangerranking is a hint to Ai which creatures are the ones it should be targetting for effects.

View File

@@ -19,7 +19,7 @@ class MTGPack;
class MTGSetInfo
{
public:
MTGSetInfo(string _id);
MTGSetInfo(const string& _id);
~MTGSetInfo();
string id; //Short name: 10E, RAV, etc. Automatic from folder.
string author; //Author of set, for crediting mod makers, etc.
@@ -70,7 +70,7 @@ public:
MTGSets();
~MTGSets();
int Add(const char * subtype);
int Add(const string& subtype);
int findSet(string value);
int findBlock(string s);
int size();
@@ -127,8 +127,10 @@ public:
MTGCard * getCardByName(string name);
void loadFolder(const string& folder, const string& filename="" );
int load(const char * config_file, const char * setName = NULL, int autoload = 1);
int countByType(const char * _type);
int load(const string& config_file);
int load(const string& config_file, const string& setName);
int load(const string& config_file, int set_id);
int countByType(const string& _type);
int countByColor(int color);
int countBySet(int setId);
int totalCards();
@@ -218,8 +220,8 @@ public:
int totalCards();
int totalPrice();
MTGDeck(MTGAllCards * _allcards);
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL,
MTGDeck(const string& config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const string& subtype = "",
int * colors = NULL, int nbcolors = 0);
int add(int cardid);
int add(MTGDeck * deck); // adds the contents of "deck" into myself

View File

@@ -293,7 +293,7 @@ class Constants
static map<string,int> MTGBasicAbilitiesMap;
static const char* MTGBasicAbilities[];
static const char* MTGPhaseNames[];
static const string MTGPhaseNames[];
static const char* MTGPhaseCodeNames[];
static int GetBasicAbilityIndex(string mtgAbility);

View File

@@ -62,7 +62,7 @@ public:
int addCombatAfter(Player* player, int after_id, bool withMain = false);
int addPhaseAfter(GamePhase id, Player* player, int after_id);
int removePhase(int id);
const char * phaseName(int id);
const string& phaseName(int id);
static GamePhase phaseStrToInt(string s);
static string phaseIntToStr(int id);