Skip to content

Commit 733e3db

Browse files
authored
refactor(maputil): Remove unused variables in MapUtil (#1767)
1 parent e7ee57b commit 733e3db

File tree

2 files changed

+10
-96
lines changed

2 files changed

+10
-96
lines changed

Generals/Code/GameEngine/Source/GameClient/MapUtil.cpp

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,12 @@ static Coord3DList m_techPositions;
8181
static Int m_mapDX = 0;
8282
static Int m_mapDY = 0;
8383

84-
static UnsignedInt calcCRC( AsciiString dirName, AsciiString fname )
84+
static UnsignedInt calcCRC( AsciiString fname )
8585
{
8686
CRC theCRC;
8787
theCRC.clear();
8888

89-
// Try the official map dir
90-
AsciiString asciiFile;
91-
char tempBuf[_MAX_PATH];
92-
char filenameBuf[_MAX_PATH];
93-
int length = 0;
94-
strcpy(tempBuf, fname.str());
95-
length = strlen( tempBuf );
96-
if( length >= 4 )
97-
{
98-
strlcpy( filenameBuf, tempBuf, length - 4 + 1);
99-
}
100-
101-
File *fp;
102-
asciiFile = fname;
103-
fp = TheFileSystem->openFile(asciiFile.str(), File::READ);
89+
File *fp = TheFileSystem->openFile(fname.str(), File::READ);
10490
if( !fp )
10591
{
10692
DEBUG_CRASH(("Couldn't open '%s'", fname.str()));
@@ -231,23 +217,9 @@ static Bool ParseSizeOnlyInChunk(DataChunkInput &file, DataChunkInfo *info, void
231217

232218
static Bool loadMap( AsciiString filename )
233219
{
234-
char tempBuf[_MAX_PATH];
235-
char filenameBuf[_MAX_PATH];
236-
AsciiString asciiFile;
237-
int length = 0;
238-
239-
strcpy(tempBuf, filename.str());
240-
241-
length = strlen( tempBuf );
242-
if( length >= 4 )
243-
{
244-
strlcpy( filenameBuf, tempBuf, length - 4 + 1);
245-
}
246-
247220
CachedFileInputStream fileStrm;
248221

249-
asciiFile = filename;
250-
if( !fileStrm.open(asciiFile) )
222+
if( !fileStrm.open(filename) )
251223
{
252224
return FALSE;
253225
}
@@ -598,17 +570,6 @@ Bool MapCache::loadUserMaps()
598570
else
599571
{
600572
if (TheFileSystem->getFileInfo(tempfilename, &fileInfo)) {
601-
char funk[_MAX_PATH];
602-
strcpy(funk, tempfilename.str());
603-
char *filenameptr = funk;
604-
char *tempchar = funk;
605-
while (*tempchar != 0) {
606-
if ((*tempchar == '\\') || (*tempchar == '/')) {
607-
filenameptr = tempchar+1;
608-
}
609-
++tempchar;
610-
}
611-
612573
m_seen[tempfilename] = TRUE;
613574
parsedAMap |= addMap(mapDir, *iter, &fileInfo, TheGlobalData->m_buildMapCache);
614575
} else {
@@ -702,7 +663,7 @@ Bool MapCache::addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInf
702663
md.m_timestamp.m_lowTimeStamp = fileInfo->timestampLow;
703664
md.m_supplyPositions = m_supplyPositions;
704665
md.m_techPositions = m_techPositions;
705-
md.m_CRC = calcCRC(dirName, fname);
666+
md.m_CRC = calcCRC(fname);
706667

707668
Bool exists = false;
708669
AsciiString munkee = worldDict.getAsciiString(TheKey_mapName, &exists);
@@ -1138,12 +1099,8 @@ Image *getMapPreviewImage( AsciiString mapName )
11381099
AsciiString tgaName = mapName;
11391100
AsciiString name;
11401101
AsciiString tempName;
1141-
AsciiString filename;
11421102
tgaName.truncateBy(4); // ".map"
1143-
name = tgaName;//.reverseFind('\\') + 1;
1144-
filename = tgaName.reverseFind('\\') + 1;
1145-
//tgaName = name;
1146-
filename.concat(".tga");
1103+
name = tgaName;
11471104
tgaName.concat(".tga");
11481105

11491106
AsciiString portableName = TheGameState->realMapPathToPortableMapPath(name);

GeneralsMD/Code/GameEngine/Source/GameClient/MapUtil.cpp

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,12 @@ static Coord3DList m_techPositions;
8181
static Int m_mapDX = 0;
8282
static Int m_mapDY = 0;
8383

84-
static UnsignedInt calcCRC( AsciiString dirName, AsciiString fname )
84+
static UnsignedInt calcCRC( AsciiString fname )
8585
{
8686
CRC theCRC;
8787
theCRC.clear();
8888

89-
// Try the official map dir
90-
AsciiString asciiFile;
91-
char tempBuf[_MAX_PATH];
92-
char filenameBuf[_MAX_PATH];
93-
int length = 0;
94-
strcpy(tempBuf, fname.str());
95-
length = strlen( tempBuf );
96-
if( length >= 4 )
97-
{
98-
strlcpy( filenameBuf, tempBuf, length - 4 + 1);
99-
}
100-
101-
File *fp;
102-
asciiFile = fname;
103-
fp = TheFileSystem->openFile(asciiFile.str(), File::READ);
89+
File *fp = TheFileSystem->openFile(fname.str(), File::READ);
10490
if( !fp )
10591
{
10692
DEBUG_CRASH(("Couldn't open '%s'", fname.str()));
@@ -231,23 +217,9 @@ static Bool ParseSizeOnlyInChunk(DataChunkInput &file, DataChunkInfo *info, void
231217

232218
static Bool loadMap( AsciiString filename )
233219
{
234-
char tempBuf[_MAX_PATH];
235-
char filenameBuf[_MAX_PATH];
236-
AsciiString asciiFile;
237-
int length = 0;
238-
239-
strcpy(tempBuf, filename.str());
240-
241-
length = strlen( tempBuf );
242-
if( length >= 4 )
243-
{
244-
strlcpy( filenameBuf, tempBuf, length - 4 + 1);
245-
}
246-
247220
CachedFileInputStream fileStrm;
248221

249-
asciiFile = filename;
250-
if( !fileStrm.open(asciiFile) )
222+
if( !fileStrm.open(filename) )
251223
{
252224
return FALSE;
253225
}
@@ -598,17 +570,6 @@ Bool MapCache::loadUserMaps()
598570
else
599571
{
600572
if (TheFileSystem->getFileInfo(tempfilename, &fileInfo)) {
601-
char funk[_MAX_PATH];
602-
strcpy(funk, tempfilename.str());
603-
char *filenameptr = funk;
604-
char *tempchar = funk;
605-
while (*tempchar != 0) {
606-
if ((*tempchar == '\\') || (*tempchar == '/')) {
607-
filenameptr = tempchar+1;
608-
}
609-
++tempchar;
610-
}
611-
612573
m_seen[tempfilename] = TRUE;
613574
parsedAMap |= addMap(mapDir, *iter, &fileInfo, TheGlobalData->m_buildMapCache);
614575
} else {
@@ -702,7 +663,7 @@ Bool MapCache::addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInf
702663
md.m_timestamp.m_lowTimeStamp = fileInfo->timestampLow;
703664
md.m_supplyPositions = m_supplyPositions;
704665
md.m_techPositions = m_techPositions;
705-
md.m_CRC = calcCRC(dirName, fname);
666+
md.m_CRC = calcCRC(fname);
706667

707668
Bool exists = false;
708669
AsciiString munkee = worldDict.getAsciiString(TheKey_mapName, &exists);
@@ -1138,12 +1099,8 @@ Image *getMapPreviewImage( AsciiString mapName )
11381099
AsciiString tgaName = mapName;
11391100
AsciiString name;
11401101
AsciiString tempName;
1141-
AsciiString filename;
11421102
tgaName.truncateBy(4); // ".map"
1143-
name = tgaName;//.reverseFind('\\') + 1;
1144-
filename = tgaName.reverseFind('\\') + 1;
1145-
//tgaName = name;
1146-
filename.concat(".tga");
1103+
name = tgaName;
11471104
tgaName.concat(".tga");
11481105

11491106
AsciiString portableName = TheGameState->realMapPathToPortableMapPath(name);

0 commit comments

Comments
 (0)