Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class PolygonTrigger : public MemoryPoolObject,
Int getID() const {return m_triggerID;}
PolygonTrigger *getNext() {return m_nextPolygonTrigger;}
const PolygonTrigger *getNext() const {return m_nextPolygonTrigger;}
AsciiString getTriggerName() const {return m_triggerName;} ///< Gets the trigger name.
const AsciiString& getTriggerName() const {return m_triggerName;} ///< Gets the trigger name.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not allocate. But it does touch the string ref counter.

Callers should also use references then, for example:

PolygonTrigger *TerrainLogic::getTriggerAreaByName( AsciiString name )
{
	for (PolygonTrigger* pTrig = PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) {
		AsciiString trigName = pTrig->getTriggerName(); // <---- can take const ref then
		if (name == trigName)
			return pTrig;
	}
	return nullptr;
}

Bool pointInTrigger(ICoord3D &point) const;
Bool doExportWithScripts() const {return m_exportWithScripts;}
void setDoExportWithScripts(Bool val) {m_exportWithScripts = val;}
Expand Down
6 changes: 3 additions & 3 deletions Generals/Code/GameEngine/Include/GameLogic/TerrainLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ class Waypoint : public MemoryPoolObject
/// Get the waypoint's position
const Coord3D *getLocation() const { return &m_location; }
/// Get the waypoint's first path label
AsciiString getPathLabel1() const { return m_pathLabel1; }
const AsciiString& getPathLabel1() const { return m_pathLabel1; }
/// Get the waypoint's second path label
AsciiString getPathLabel2() const { return m_pathLabel2; }
const AsciiString& getPathLabel2() const { return m_pathLabel2; }
/// Get the waypoint's third path label
AsciiString getPathLabel3() const { return m_pathLabel3; }
const AsciiString& getPathLabel3() const { return m_pathLabel3; }
/// Get bi-directionality.
Bool getBiDirectional() const { return m_biDirectional; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ Bool TerrainLogic::isPurposeOfPath( Waypoint *pWay, AsciiString label )
PolygonTrigger *TerrainLogic::getTriggerAreaByName( AsciiString name )
{
for (PolygonTrigger* pTrig = PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) {
AsciiString trigName = pTrig->getTriggerName();
const AsciiString& trigName = pTrig->getTriggerName();
if (name == trigName)
return pTrig;
}
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/WaterOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void WaterOptions::OnChangeWaterEdit()
PolygonTrigger *pTrig;
for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); !didMatch && pTrig; pTrig = pTrig->getNext()) {
if (pTrig==theTrigger) continue; // don't check against yourself.
AsciiString trigName = pTrig->getTriggerName();
const AsciiString& trigName = pTrig->getTriggerName();
if (name == trigName) {
if (pTrig->isValid()) {
didMatch = true;
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/WaypointOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void WaypointOptions::OnChangeWaypointnameEdit()
PolygonTrigger *pTrig;
for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); !didMatch && pTrig; pTrig = pTrig->getNext()) {
if (pTrig==theTrigger) continue; // don't check against yourself.
AsciiString trigName = pTrig->getTriggerName();
const AsciiString& trigName = pTrig->getTriggerName();
if (name == trigName) {
if (pTrig->isValid()) {
didMatch = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class PolygonTrigger : public MemoryPoolObject,
Int getID() const {return m_triggerID;}
PolygonTrigger *getNext() {return m_nextPolygonTrigger;}
const PolygonTrigger *getNext() const {return m_nextPolygonTrigger;}
AsciiString getTriggerName() const {return m_triggerName;} ///< Gets the trigger name.
const AsciiString& getTriggerName() const {return m_triggerName;} ///< Gets the trigger name.
Bool pointInTrigger(ICoord3D &point) const;
Bool doExportWithScripts() const {return m_exportWithScripts;}
void setDoExportWithScripts(Bool val) {m_exportWithScripts = val;}
Expand Down
6 changes: 3 additions & 3 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/TerrainLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ class Waypoint : public MemoryPoolObject
/// Get the waypoint's position
const Coord3D *getLocation() const { return &m_location; }
/// Get the waypoint's first path label
AsciiString getPathLabel1() const { return m_pathLabel1; }
const AsciiString& getPathLabel1() const { return m_pathLabel1; }
/// Get the waypoint's second path label
AsciiString getPathLabel2() const { return m_pathLabel2; }
const AsciiString& getPathLabel2() const { return m_pathLabel2; }
/// Get the waypoint's third path label
AsciiString getPathLabel3() const { return m_pathLabel3; }
const AsciiString& getPathLabel3() const { return m_pathLabel3; }
/// Get bi-directionality.
Bool getBiDirectional() const { return m_biDirectional; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ Bool TerrainLogic::isPurposeOfPath( Waypoint *pWay, AsciiString label )
PolygonTrigger *TerrainLogic::getTriggerAreaByName( AsciiString name )
{
for (PolygonTrigger* pTrig = PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) {
AsciiString trigName = pTrig->getTriggerName();
const AsciiString& trigName = pTrig->getTriggerName();
if (name == trigName)
return pTrig;
}
Expand Down
10 changes: 5 additions & 5 deletions GeneralsMD/Code/Tools/WorldBuilder/src/LayersList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ void LayersList::updateUIFromList()
}

for (ListPolygonTriggerPtrIt triggerIt = layersIt->polygonTriggersInLayer.begin(); triggerIt != layersIt->polygonTriggersInLayer.end(); ++triggerIt) {
AsciiString uniqueID = (*triggerIt)->getTriggerName();
const AsciiString& uniqueID = (*triggerIt)->getTriggerName();
pTree->InsertItem(uniqueID.str(), iconToShow, iconToShow, thisBranch);
}
}
Expand Down Expand Up @@ -609,7 +609,7 @@ void LayersList::addPolygonTriggerToLayer(IN PolygonTrigger *triggerToAdd, IN Li
// only update this object.
HTREEITEM hItem = findTreeLayerNamed(layerToAddTo->layerName);
if (hItem) {
AsciiString triggerName = triggerToAdd->getTriggerName();
const AsciiString& triggerName = triggerToAdd->getTriggerName();
int iconToShow = (layerToAddTo->show ? 0 : 1);
mTree->InsertItem(triggerName.str(), iconToShow, iconToShow, hItem);
}
Expand Down Expand Up @@ -691,7 +691,7 @@ void LayersList::removePolygonTriggerFromLayer(IN PolygonTrigger *triggerToRemov
// only remove this object
HTREEITEM layer = findTreeLayerNamed(layerToRemoveFrom->layerName);
if (layer) {
AsciiString triggerUID = (*triggerBeingRemove)->getTriggerName();
const AsciiString& triggerUID = (*triggerBeingRemove)->getTriggerName();
HTREEITEM itemToDelete = findTreeObjectNamed(triggerUID.str(), layer);
if (itemToDelete) {
mTree->DeleteItem(itemToDelete);
Expand Down Expand Up @@ -1227,7 +1227,7 @@ Bool LayersList::findAndSelectPolygonTrigger(AsciiString selectedItemAsciiString
PolygonTrigger *trigger = PolygonTrigger::getFirstPolygonTrigger();

while (trigger) {
AsciiString triggerName = trigger->getTriggerName();
const AsciiString& triggerName = trigger->getTriggerName();

if (triggerName.compareNoCase(selectedItemAsciiString) == 0) {
// Found it... select this object
Expand Down Expand Up @@ -1307,7 +1307,7 @@ PolygonTrigger* LayersList::findPolygonTriggerByUID(AsciiString triggerIDToFind)
PolygonTrigger *trigger = PolygonTrigger::getFirstPolygonTrigger();

while (trigger) {
AsciiString triggerName = trigger->getTriggerName();
const AsciiString& triggerName = trigger->getTriggerName();

if (triggerName.compareNoCase(triggerIDToFind) == 0) {
return (trigger);
Expand Down
2 changes: 1 addition & 1 deletion GeneralsMD/Code/Tools/WorldBuilder/src/WaterOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void WaterOptions::OnChangeWaterEdit()
PolygonTrigger *pTrig;
for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); !didMatch && pTrig; pTrig = pTrig->getNext()) {
if (pTrig==theTrigger) continue; // don't check against yourself.
AsciiString trigName = pTrig->getTriggerName();
const AsciiString& trigName = pTrig->getTriggerName();
if (name == trigName) {
if (pTrig->isValid()) {
didMatch = true;
Expand Down
2 changes: 1 addition & 1 deletion GeneralsMD/Code/Tools/WorldBuilder/src/WaypointOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void WaypointOptions::OnChangeWaypointnameEdit()
PolygonTrigger *pTrig;
for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); !didMatch && pTrig; pTrig = pTrig->getNext()) {
if (pTrig==theTrigger) continue; // don't check against yourself.
AsciiString trigName = pTrig->getTriggerName();
const AsciiString& trigName = pTrig->getTriggerName();
if (name == trigName) {
if (pTrig->isValid()) {
didMatch = true;
Expand Down
Loading