Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/Common/System/Xfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ void Xfer::xferUpgradeMask( UpgradeMaskType *upgradeMaskData )
xferAsciiString( &upgradeName );

// find this upgrade template
upgradeTemplate = TheUpgradeCenter->findUpgrade( upgradeName );
upgradeTemplate = TheUpgradeCenter->findUpgrade( upgradeName.str() );
if( upgradeTemplate == NULL )
{

Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg)

AsciiString playerName;
playerName.format("player%d", msg->getPlayerID());
const Player *player = ThePlayerList->findPlayerWithNameKey( TheNameKeyGenerator->nameToKey( playerName ) );
const Player *player = ThePlayerList->findPlayerWithNameKey( TheNameKeyGenerator->nameToKey( playerName.str() ) );
if (!player)
{
TheInGameUI->message(L"%ls", unitext.str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ AsciiString GameSpyStagingRoom::generateGameSpyGameResultsPacket( void )
{
AsciiString playerName;
playerName.format("player%d", i);
Player *p = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName));
Player *p = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName.str()));
if (p)
{
++numHumans;
Expand Down Expand Up @@ -648,7 +648,7 @@ AsciiString GameSpyStagingRoom::generateGameSpyGameResultsPacket( void )
{
AsciiString playerName;
playerName.format("player%d", i);
Player *p = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName));
Player *p = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName.str()));
if (p)
{
GameSpyGameSlot *slot = &(m_GameSpySlot[i]);
Expand Down Expand Up @@ -696,7 +696,7 @@ AsciiString GameSpyStagingRoom::generateLadderGameResultsPacket( void )
{
AsciiString playerName;
playerName.format("player%d", i);
p[i] = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName));
p[i] = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName.str()));
if (p[i])
{
++numPlayers;
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ GameMessage *NetGameCommandMsg::constructGameMessage()

AsciiString name;
name.format("player%d", getPlayerID());
retval->friend_setPlayerIndex( ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey(name))->getPlayerIndex());
retval->friend_setPlayerIndex( ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey(name.str()))->getPlayerIndex());

GameMessageArgument *arg = m_argList;
while (arg != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/GameNetwork/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ void Network::processDestroyPlayerCommand(NetDestroyPlayerCommandMsg *msg)

AsciiString playerName;
playerName.format("player%d", playerIndex);
Player *pPlayer = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName));
Player *pPlayer = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName.str()));
if (pPlayer)
{
GameMessage *msg = newInstance(GameMessage)(GameMessage::MSG_SELF_DESTRUCT);
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Include/Common/DamageFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class DamageFXStore : public SubsystemInterface
/**
Find the DamageFX with the given name. If no such DamageFX exists, return null.
*/
const DamageFX *findDamageFX( AsciiString name ) const;
const DamageFX *findDamageFX( const char* name ) const;

static void parseDamageFXDefinition(INI* ini);

Expand Down
6 changes: 1 addition & 5 deletions Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ class NameKeyGenerator : public SubsystemInterface
virtual void reset();
virtual void update() { }

/// Given a string, convert into a unique integer key.
NameKeyType nameToKey(const AsciiString& name) { return nameToKey(name.str()); }
NameKeyType nameToLowercaseKey(const AsciiString& name) { return nameToLowercaseKey(name.str()); }

/// Given a string, convert into a unique integer key.
NameKeyType nameToKey(const char* name);
NameKeyType nameToLowercaseKey(const char *name);
Expand Down Expand Up @@ -140,7 +136,7 @@ class NameKeyGenerator : public SubsystemInterface
extern NameKeyGenerator *TheNameKeyGenerator; ///< just one namespace for now

// typing "TheNameKeyGenerator->nameToKey()" is awfully wordy. Here are shorter synonyms:
inline NameKeyType NAMEKEY(const AsciiString& name) { return TheNameKeyGenerator->nameToKey(name); }

inline NameKeyType NAMEKEY(const char* name) { return TheNameKeyGenerator->nameToKey(name); }

inline AsciiString KEYNAME(NameKeyType nk) { return TheNameKeyGenerator->keyToName(nk); }
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Include/Common/Upgrade.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class UpgradeCenter : public SubsystemInterface

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

UpgradeTemplate *newUpgrade( const AsciiString& name ); ///< allocate, link, and return new upgrade
Expand Down
7 changes: 4 additions & 3 deletions Generals/Code/GameEngine/Include/GameClient/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ friend class ImageCollection;
//-------------------------------------------------------------------------------------------------
class ImageCollection : public SubsystemInterface
{
typedef std::map<NameKeyType, Image *> ImageMap;

public:

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

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

const Image *findImageByName( const AsciiString& name ); ///< find image based on name
const Image *findImageByName( const char* name ) const; ///< find image based on name

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

/// enumerates the list of existing images
Image *Enum(unsigned index)
{
for (std::map<unsigned,Image *>::iterator i=m_imageMap.begin();i!=m_imageMap.end();++i)
for (ImageMap::iterator i=m_imageMap.begin();i!=m_imageMap.end();++i)
if (!index--)
return i->second;
return NULL;
}

protected:
std::map<unsigned,Image *> m_imageMap; ///< maps named keys to images
ImageMap m_imageMap; ///< maps named keys to images
};

// INLINING ///////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Include/GameLogic/Armor.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ArmorStore : public SubsystemInterface
/**
Find the Armor with the given name. If no such Armor exists, return null.
*/
const ArmorTemplate* findArmorTemplate(AsciiString name) const;
const ArmorTemplate* findArmorTemplate(const char* name) const;

inline Armor makeArmor(const ArmorTemplate *tmpl) const
{
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Include/GameLogic/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ class WeaponStore : public SubsystemInterface
/**
Find the WeaponTemplate with the given name. If no such WeaponTemplate exists, return null.
*/
const WeaponTemplate *findWeaponTemplate(AsciiString name) const;
const WeaponTemplate *findWeaponTemplate(const char* name) const;
const WeaponTemplate *findWeaponTemplateByNameKey( NameKeyType key ) const { return findWeaponTemplatePrivate( key ); }

// this dynamically allocates a new Weapon, which is owned (and must be freed!) by the caller.
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Source/Common/DamageFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ DamageFXStore::~DamageFXStore()
}

//-------------------------------------------------------------------------------------------------
const DamageFX *DamageFXStore::findDamageFX(AsciiString name) const
const DamageFX *DamageFXStore::findDamageFX(const char* name) const
{
NameKeyType namekey = TheNameKeyGenerator->nameToKey(name);
DamageFXMap::const_iterator it = m_dfxmap.find(namekey);
Expand Down
4 changes: 2 additions & 2 deletions Generals/Code/GameEngine/Source/Common/INI/INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ void INI::parseMappedImage( INI *ini, void * /*instance*/, void *store, const vo
if( TheMappedImageCollection )
{
typedef const Image* ConstImagePtr;
*(ConstImagePtr*)store = TheMappedImageCollection->findImageByName( AsciiString( token ) );
*(ConstImagePtr*)store = TheMappedImageCollection->findImageByName( token );
}

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

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

typedef const UpgradeTemplate* ConstUpgradeTemplatePtr;
Expand Down
10 changes: 3 additions & 7 deletions Generals/Code/GameEngine/Source/Common/INI/INIMappedImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@
//-------------------------------------------------------------------------------------------------
void INI::parseMappedImageDefinition( INI* ini )
{
AsciiString name;

// read the name
const char* c = ini->getNextToken();
name.set( c );
const char* name = ini->getNextToken();

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

// image not found, create a new one
image = newInstance(Image);
image = newInstance(Image);
image->setName( name );
TheMappedImageCollection->addImage(image);
DEBUG_ASSERTCRASH( image, ("parseMappedImage: unable to allocate image for '%s'",
name.str()) );
DEBUG_ASSERTCRASH( image, ("parseMappedImage: unable to allocate image for '%s'", name) );

}

Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Source/Common/RTS/Handicap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void Handicap::readFromDict(const Dict* d)
c.concat(htNames[i]);
c.concat("_");
c.concat(ttNames[j]);
NameKeyType k = TheNameKeyGenerator->nameToKey(c);
NameKeyType k = TheNameKeyGenerator->nameToKey(c.str());
Bool exists;
Real r = d->getReal(k, &exists);
if (exists)
Expand Down
24 changes: 12 additions & 12 deletions Generals/Code/GameEngine/Source/Common/RTS/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ void Player::init(const PlayerTemplate* pt)

m_playerDisplayName = UnicodeString::TheEmptyString;
m_playerName = AsciiString::TheEmptyString;
m_playerNameKey = NAMEKEY(AsciiString::TheEmptyString);
m_playerNameKey = NAMEKEY("");
m_playerType = PLAYER_COMPUTER;

// neutral is always "allied" with self -- this is the only thing ever allied with neutral!
Expand Down Expand Up @@ -740,15 +740,15 @@ void Player::deletePlayerAI()
void Player::initFromDict(const Dict* d)
{
AsciiString tmplname = d->getAsciiString(TheKey_playerFaction);
const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(tmplname));
const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(tmplname.str()));
DEBUG_ASSERTCRASH(pt != NULL, ("PlayerTemplate %s not found -- this is an obsolete map (please open and resave in WB)",tmplname.str()));

init(pt);

m_playerDisplayName = d->getUnicodeString(TheKey_playerDisplayName);
AsciiString pname = d->getAsciiString(TheKey_playerName);
m_playerName = pname;
m_playerNameKey = NAMEKEY(pname);
m_playerNameKey = NAMEKEY(pname.str());

Bool exists;
Bool skirmish = false;
Expand All @@ -763,7 +763,7 @@ void Player::initFromDict(const Dict* d)
for (Int spIdx = 0; spIdx < TheSidesList->getNumSkirmishSides(); ++spIdx)
{
AsciiString spTemplateName = TheSidesList->getSkirmishSideInfo(spIdx)->getDict()->getAsciiString(TheKey_playerFaction);
const PlayerTemplate* spt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(spTemplateName));
const PlayerTemplate* spt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(spTemplateName.str()));
if (spt && spt->getSide() == getSide())
{
skirmish = true;
Expand Down Expand Up @@ -792,7 +792,7 @@ void Player::initFromDict(const Dict* d)
AsciiString qualTemplatePlayerName;
for (i=0; i<TheSidesList->getNumSkirmishSides(); i++) {
AsciiString templateName = TheSidesList->getSkirmishSideInfo(i)->getDict()->getAsciiString(TheKey_playerFaction);
pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(templateName));
pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(templateName.str()));
if (pt && pt->getSide() == mySide) {
qualTemplatePlayerName.format("%s%d", TheSidesList->getSkirmishSideInfo(i)->getDict()->getAsciiString(TheKey_playerName).str(), m_mpStartIndex);
found = true;
Expand Down Expand Up @@ -830,7 +830,7 @@ void Player::initFromDict(const Dict* d)
AsciiString qualTemplatePlayerName;
for (skirmishNdx=0; skirmishNdx<TheSidesList->getNumSkirmishSides(); skirmishNdx++) {
AsciiString templateName = TheSidesList->getSkirmishSideInfo(skirmishNdx)->getDict()->getAsciiString(TheKey_playerFaction);
pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(templateName));
pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(templateName.str()));
if (pt && pt->getSide() == mySide) {
qualTemplatePlayerName.format("%s%d", TheSidesList->getSkirmishSideInfo(skirmishNdx)->getDict()->getAsciiString(TheKey_playerName).str(), m_mpStartIndex);
found = true;
Expand Down Expand Up @@ -910,11 +910,11 @@ void Player::initFromDict(const Dict* d)
for (j = 0; j < MAX_GENERIC_SCRIPTS; ++j) {
AsciiString keyName;
keyName.format("%s%d", TheNameKeyGenerator->keyToName(TheKey_teamGenericScriptHook).str(), j);
tmpStr = teamDict.getAsciiString(NAMEKEY(keyName), &exists);
tmpStr = teamDict.getAsciiString(NAMEKEY(keyName.str()), &exists);
if (exists && !tmpStr.isEmpty())
{
newName.format("%s%d", tmpStr.str(), m_mpStartIndex);
teamDict.setAsciiString(NAMEKEY(keyName), newName);
teamDict.setAsciiString(NAMEKEY(keyName.str()), newName);
}
}

Expand Down Expand Up @@ -1545,7 +1545,7 @@ UnsignedInt Player::getSupplyBoxValue()
//=============================================================================
Real Player::getProductionCostChangePercent( AsciiString buildTemplateName ) const
{
ProductionChangeMap::const_iterator it = m_productionCostChanges.find(NAMEKEY(buildTemplateName));
ProductionChangeMap::const_iterator it = m_productionCostChanges.find(NAMEKEY(buildTemplateName.str()));
if (it != m_productionCostChanges.end())
{
return (*it).second;
Expand All @@ -1557,7 +1557,7 @@ Real Player::getProductionCostChangePercent( AsciiString buildTemplateName ) con
//=============================================================================
Real Player::getProductionTimeChangePercent( AsciiString buildTemplateName ) const
{
ProductionChangeMap::const_iterator it = m_productionTimeChanges.find(NAMEKEY(buildTemplateName));
ProductionChangeMap::const_iterator it = m_productionTimeChanges.find(NAMEKEY(buildTemplateName.str()));
if (it != m_productionTimeChanges.end())
{
return (*it).second;
Expand All @@ -1569,7 +1569,7 @@ Real Player::getProductionTimeChangePercent( AsciiString buildTemplateName ) con
//=============================================================================
VeterancyLevel Player::getProductionVeterancyLevel( AsciiString buildTemplateName ) const
{
NameKeyType templateNameKey = NAMEKEY(buildTemplateName);
NameKeyType templateNameKey = NAMEKEY(buildTemplateName.str());
ProductionVeterancyMap::const_iterator it = m_productionVeterancyLevels.find(templateNameKey);
if (it != m_productionVeterancyLevels.end())
{
Expand Down Expand Up @@ -3576,7 +3576,7 @@ void Player::xfer( Xfer *xfer )
xfer->xferAsciiString( &upgradeName );

// find template for this upgrade
upgradeTemplate = TheUpgradeCenter->findUpgrade( upgradeName );
upgradeTemplate = TheUpgradeCenter->findUpgrade( upgradeName.str() );

// sanity
if( upgradeTemplate == NULL )
Expand Down
6 changes: 3 additions & 3 deletions Generals/Code/GameEngine/Source/Common/RTS/PlayerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ void PlayerList::newGame()
for( i = 0; i < TheSidesList->getNumSides(); i++)
{
Dict *d = TheSidesList->getSideInfo(i)->getDict();
Player* p = findPlayerWithNameKey(NAMEKEY(d->getAsciiString(TheKey_playerName)));
Player* p = findPlayerWithNameKey(NAMEKEY(d->getAsciiString(TheKey_playerName).str()));

AsciiString tok;

AsciiString enemies = d->getAsciiString(TheKey_playerEnemies);
while (enemies.nextToken(&tok))
{
Player *p2 = findPlayerWithNameKey(NAMEKEY(tok));
Player *p2 = findPlayerWithNameKey(NAMEKEY(tok.str()));
if (p2)
{
p->setPlayerRelationship(p2, ENEMIES);
Expand All @@ -207,7 +207,7 @@ void PlayerList::newGame()
AsciiString allies = d->getAsciiString(TheKey_playerAllies);
while (allies.nextToken(&tok))
{
Player *p2 = findPlayerWithNameKey(NAMEKEY(tok));
Player *p2 = findPlayerWithNameKey(NAMEKEY(tok.str()));
if (p2)
{
p->setPlayerRelationship(p2, ALLIES);
Expand Down
14 changes: 7 additions & 7 deletions Generals/Code/GameEngine/Source/Common/RTS/PlayerTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,43 +193,43 @@ PlayerTemplate::PlayerTemplate() :
//-----------------------------------------------------------------------------
const Image *PlayerTemplate::getHeadWaterMarkImage( void ) const
{
return TheMappedImageCollection->findImageByName(m_headWaterMark);
return TheMappedImageCollection->findImageByName(m_headWaterMark.str());
}

//-----------------------------------------------------------------------------
const Image *PlayerTemplate::getFlagWaterMarkImage( void ) const
{
return TheMappedImageCollection->findImageByName(m_flagWaterMark);
return TheMappedImageCollection->findImageByName(m_flagWaterMark.str());
}

//-----------------------------------------------------------------------------
const Image *PlayerTemplate::getSideIconImage( void ) const
{
return TheMappedImageCollection->findImageByName(m_sideIconImage);
return TheMappedImageCollection->findImageByName(m_sideIconImage.str());
}

//-----------------------------------------------------------------------------
const Image *PlayerTemplate::getEnabledImage( void ) const
{
return TheMappedImageCollection->findImageByName(m_enabledImage);
return TheMappedImageCollection->findImageByName(m_enabledImage.str());
}

//-----------------------------------------------------------------------------
//const Image *PlayerTemplate::getDisabledImage( void ) const
//{
// return TheMappedImageCollection->findImageByName(m_disabledImage);
// return TheMappedImageCollection->findImageByName(m_disabledImage.str());
//}

//-----------------------------------------------------------------------------
//const Image *PlayerTemplate::getHiliteImage( void ) const
//{
// return TheMappedImageCollection->findImageByName(m_hiliteImage);
// return TheMappedImageCollection->findImageByName(m_hiliteImage.str());
//}

//-----------------------------------------------------------------------------
//const Image *PlayerTemplate::getPushedImage( void ) const
//{
// return TheMappedImageCollection->findImageByName(m_pushedImage);
// return TheMappedImageCollection->findImageByName(m_pushedImage.str());
//}

//-----------------------------------------------------------------------------
Expand Down
Loading
Loading