File tree Expand file tree Collapse file tree 3 files changed +25
-41
lines changed
Core/GameEngine/Include/Common
GeneralsMD/Code/GameEngine/Source/GameNetwork Expand file tree Collapse file tree 3 files changed +25
-41
lines changed Original file line number Diff line number Diff line change @@ -382,25 +382,19 @@ class AsciiString
382382 AsciiString& operator =(const AsciiString& stringSrc); // /< the same as set()
383383 AsciiString& operator =(const char * s); // /< the same as set()
384384
385- struct CharProxy {
386- AsciiString& str;
387- Int index;
388-
389- CharProxy (AsciiString& string, const Int index) : str(string), index(index) {};
390- void operator = (Char rhs)
391- {
392- Int length = str.getLength ();
393- DEBUG_ASSERTCRASH (index >= 0 && index < length, (" bad index in CharProxy::operator=" ));
394- str.ensureUniqueBufferOfSize (length + 1 , true , NULL , NULL );
395- str.peek ()[index] = rhs;
396- }
397-
398- operator Char () const { return str.getCharAt (index); }
399- };
400-
401- friend struct CharProxy ;
385+ const Char& operator [](Int index) const
386+ {
387+ DEBUG_ASSERTCRASH (index >= 0 && index < getLength (), (" bad index in AsciiString::operator[]" ));
388+ return peek ()[index];
389+ }
402390
403- CharProxy operator [](const Int index) { return CharProxy (*this , index); }
391+ Char& operator [](Int index)
392+ {
393+ Int length = getLength ();
394+ DEBUG_ASSERTCRASH (index >= 0 && index < length, (" bad index in AsciiString::operator[]" ));
395+ ensureUniqueBufferOfSize (length + 1 , true , NULL , NULL );
396+ return peek ()[index];
397+ }
404398
405399 void debugIgnoreLeaks ();
406400
Original file line number Diff line number Diff line change @@ -334,24 +334,19 @@ class UnicodeString
334334 UnicodeString& operator =(const UnicodeString& stringSrc); // /< the same as set()
335335 UnicodeString& operator =(const WideChar* s); // /< the same as set()
336336
337- struct WideCharProxy {
338- UnicodeString& str;
339- Int index;
340-
341- WideCharProxy (UnicodeString& string, const Int index) : str(string), index(index) {};
342- void operator = (WideChar rhs)
343- {
344- Int length = str.getLength ();
345- DEBUG_ASSERTCRASH (index >= 0 && index < length, (" bad index in WideCharProxy::operator=" ));
346- str.ensureUniqueBufferOfSize (length + 1 , true , NULL , NULL );
347- str.peek ()[index] = rhs;
348- }
349-
350- operator WideChar () const { return str.getCharAt (index); }
351- };
337+ const WideChar& operator [](Int index) const
338+ {
339+ DEBUG_ASSERTCRASH (index >= 0 && index < getLength (), (" bad index in UnicodeString::operator[]" ));
340+ return peek ()[index];
341+ }
352342
353- friend struct WideCharProxy ;
354- WideCharProxy operator [](const Int index) { return WideCharProxy (*this , index); }
343+ WideChar& operator [](Int index)
344+ {
345+ Int length = getLength ();
346+ DEBUG_ASSERTCRASH (index >= 0 && index < length, (" bad index in UnicodeString::operator[]" ));
347+ ensureUniqueBufferOfSize (length + 1 , true , NULL , NULL );
348+ return peek ()[index];
349+ }
355350};
356351
357352
Original file line number Diff line number Diff line change @@ -998,17 +998,12 @@ static void EnsureUniqueNames(AsciiStringVec& playerNames)
998998 continue ;
999999
10001000 Int charOffset = -1 ;
1001- Int nameLength = - 1 ;
1001+ Int nameLength = playerName. getLength () ;
10021002 while (uniqueNames.insert (playerName).second == false )
10031003 {
10041004 // The name already exists, so change the last char to the number index of the player in the game.
10051005 // If that fails to be unique, iterate through 0-9 and change the last char to ensure differentiation.
10061006 // Guaranteed to find a unique name as the number of slots is less than 10.
1007- if (nameLength == -1 )
1008- {
1009- nameLength = playerName.getLength ();
1010- }
1011-
10121007 char charToTry = ' 0' + static_cast <char >(charOffset == -1 ? i : charOffset);
10131008 playerName[nameLength - 1 ] = charToTry;
10141009 ++charOffset;
You can’t perform that action at this time.
0 commit comments