Skip to content

Commit a961400

Browse files
committed
Replicate in Generals
1 parent d47b786 commit a961400

File tree

88 files changed

+316
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+316
-346
lines changed

Generals/Code/GameEngine/Include/Common/DamageFX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class DamageFXStore : public SubsystemInterface
147147
/**
148148
Find the DamageFX with the given name. If no such DamageFX exists, return null.
149149
*/
150-
const DamageFX *findDamageFX( AsciiString name ) const;
150+
const DamageFX *findDamageFX( const char* name ) const;
151151

152152
static void parseDamageFXDefinition(INI* ini);
153153

Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ class NameKeyGenerator : public SubsystemInterface
9191
virtual void reset();
9292
virtual void update() { }
9393

94-
/// Given a string, convert into a unique integer key.
95-
NameKeyType nameToKey(const AsciiString& name) { return nameToKey(name.str()); }
96-
NameKeyType nameToLowercaseKey(const AsciiString& name) { return nameToLowercaseKey(name.str()); }
97-
9894
/// Given a string, convert into a unique integer key.
9995
NameKeyType nameToKey(const char* name);
10096
NameKeyType nameToLowercaseKey(const char *name);
@@ -140,7 +136,7 @@ class NameKeyGenerator : public SubsystemInterface
140136
extern NameKeyGenerator *TheNameKeyGenerator; ///< just one namespace for now
141137

142138
// typing "TheNameKeyGenerator->nameToKey()" is awfully wordy. Here are shorter synonyms:
143-
inline NameKeyType NAMEKEY(const AsciiString& name) { return TheNameKeyGenerator->nameToKey(name); }
139+
144140
inline NameKeyType NAMEKEY(const char* name) { return TheNameKeyGenerator->nameToKey(name); }
145141

146142
inline AsciiString KEYNAME(NameKeyType nk) { return TheNameKeyGenerator->keyToName(nk); }

Generals/Code/GameEngine/Include/Common/Upgrade.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class UpgradeCenter : public SubsystemInterface
234234

235235
UpgradeTemplate *firstUpgradeTemplate( void ); ///< return the first upgrade template
236236
const UpgradeTemplate *findUpgradeByKey( NameKeyType key ) const; ///< find upgrade by name key
237-
const UpgradeTemplate *findUpgrade( const AsciiString& name ) const; ///< find and return upgrade by name
237+
const UpgradeTemplate *findUpgrade( const char* name ) const; ///< find and return upgrade by name
238238
const UpgradeTemplate *findVeterancyUpgrade(VeterancyLevel level) const; ///< find and return upgrade by name
239239

240240
UpgradeTemplate *newUpgrade( const AsciiString& name ); ///< allocate, link, and return new upgrade

Generals/Code/GameEngine/Include/GameClient/Image.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ friend class ImageCollection;
116116
//-------------------------------------------------------------------------------------------------
117117
class ImageCollection : public SubsystemInterface
118118
{
119+
typedef std::map<NameKeyType, Image *> ImageMap;
119120

120121
public:
121122

@@ -128,22 +129,22 @@ class ImageCollection : public SubsystemInterface
128129

129130
void load( Int textureSize ); ///< load images
130131

131-
const Image *findImageByName( const AsciiString& name ); ///< find image based on name
132+
const Image *findImageByName( const char* name ) const; ///< find image based on name
132133

133134
/// adds the given image to the collection, transfers ownership to this object
134135
void addImage(Image *image);
135136

136137
/// enumerates the list of existing images
137138
Image *Enum(unsigned index)
138139
{
139-
for (std::map<unsigned,Image *>::iterator i=m_imageMap.begin();i!=m_imageMap.end();++i)
140+
for (ImageMap::iterator i=m_imageMap.begin();i!=m_imageMap.end();++i)
140141
if (!index--)
141142
return i->second;
142143
return NULL;
143144
}
144145

145146
protected:
146-
std::map<unsigned,Image *> m_imageMap; ///< maps named keys to images
147+
ImageMap m_imageMap; ///< maps named keys to images
147148
};
148149

149150
// INLINING ///////////////////////////////////////////////////////////////////////////////////////

Generals/Code/GameEngine/Include/GameLogic/Armor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class ArmorStore : public SubsystemInterface
108108
/**
109109
Find the Armor with the given name. If no such Armor exists, return null.
110110
*/
111-
const ArmorTemplate* findArmorTemplate(AsciiString name) const;
111+
const ArmorTemplate* findArmorTemplate(const char* name) const;
112112

113113
inline Armor makeArmor(const ArmorTemplate *tmpl) const
114114
{

Generals/Code/GameEngine/Include/GameLogic/Weapon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ class WeaponStore : public SubsystemInterface
814814
/**
815815
Find the WeaponTemplate with the given name. If no such WeaponTemplate exists, return null.
816816
*/
817-
const WeaponTemplate *findWeaponTemplate(AsciiString name) const;
817+
const WeaponTemplate *findWeaponTemplate(const char* name) const;
818818
const WeaponTemplate *findWeaponTemplateByNameKey( NameKeyType key ) const { return findWeaponTemplatePrivate( key ); }
819819

820820
// this dynamically allocates a new Weapon, which is owned (and must be freed!) by the caller.

Generals/Code/GameEngine/Source/Common/DamageFX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ DamageFXStore::~DamageFXStore()
274274
}
275275

276276
//-------------------------------------------------------------------------------------------------
277-
const DamageFX *DamageFXStore::findDamageFX(AsciiString name) const
277+
const DamageFX *DamageFXStore::findDamageFX(const char* name) const
278278
{
279279
NameKeyType namekey = TheNameKeyGenerator->nameToKey(name);
280280
DamageFXMap::const_iterator it = m_dfxmap.find(namekey);

Generals/Code/GameEngine/Source/Common/INI/INI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ void INI::parseMappedImage( INI *ini, void * /*instance*/, void *store, const vo
872872
if( TheMappedImageCollection )
873873
{
874874
typedef const Image* ConstImagePtr;
875-
*(ConstImagePtr*)store = TheMappedImageCollection->findImageByName( AsciiString( token ) );
875+
*(ConstImagePtr*)store = TheMappedImageCollection->findImageByName( token );
876876
}
877877

878878
//KM: If we are in the worldbuilder, we want to parse commandbuttons for informational purposes,
@@ -1377,7 +1377,7 @@ void INI::parseUpgradeTemplate( INI* ini, void * /*instance*/, void *store, cons
13771377
throw ERROR_BUG;
13781378
}
13791379

1380-
const UpgradeTemplate *uu = TheUpgradeCenter->findUpgrade( AsciiString( token ) );
1380+
const UpgradeTemplate *uu = TheUpgradeCenter->findUpgrade( token );
13811381
DEBUG_ASSERTCRASH( uu || stricmp( token, "None" ) == 0, ("Upgrade %s not found!",token) );
13821382

13831383
typedef const UpgradeTemplate* ConstUpgradeTemplatePtr;

Generals/Code/GameEngine/Source/Common/INI/INIMappedImage.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@
4242
//-------------------------------------------------------------------------------------------------
4343
void INI::parseMappedImageDefinition( INI* ini )
4444
{
45-
AsciiString name;
46-
4745
// read the name
48-
const char* c = ini->getNextToken();
49-
name.set( c );
46+
const char* name = ini->getNextToken();
5047

5148
//
5249
// find existing item if present, note that we do not support overrides
@@ -66,11 +63,10 @@ void INI::parseMappedImageDefinition( INI* ini )
6663
{
6764

6865
// image not found, create a new one
69-
image = newInstance(Image);
66+
image = newInstance(Image);
7067
image->setName( name );
7168
TheMappedImageCollection->addImage(image);
72-
DEBUG_ASSERTCRASH( image, ("parseMappedImage: unable to allocate image for '%s'",
73-
name.str()) );
69+
DEBUG_ASSERTCRASH( image, ("parseMappedImage: unable to allocate image for '%s'", name) );
7470

7571
}
7672

Generals/Code/GameEngine/Source/Common/RTS/Handicap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void Handicap::readFromDict(const Dict* d)
9999
c.concat(htNames[i]);
100100
c.concat("_");
101101
c.concat(ttNames[j]);
102-
NameKeyType k = TheNameKeyGenerator->nameToKey(c);
102+
NameKeyType k = TheNameKeyGenerator->nameToKey(c.str());
103103
Bool exists;
104104
Real r = d->getReal(k, &exists);
105105
if (exists)

0 commit comments

Comments
 (0)