Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 3 additions & 16 deletions Generals/Code/Tools/WorldBuilder/src/OpenMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,12 @@ void OpenMap::populateMapListbox( Bool systemMaps )
strcpy(dirBuf, "Maps\\");
else
{
strcpy(dirBuf, TheGlobalData->getPath_UserData().str());
strlcat(dirBuf, "Maps\\", ARRAY_SIZE(dirBuf));
}

int len = strlen(dirBuf);

if (len > 0 && dirBuf[len - 1] != '\\') {
dirBuf[len++] = '\\';
dirBuf[len] = 0;
snprintf(dirBuf, ARRAY_SIZE(dirBuf), "%sMaps\\", TheGlobalData->getPath_UserData().str());
}
CListBox *pList = (CListBox *)this->GetDlgItem(IDC_OPEN_LIST);
if (pList == NULL) return;
pList->ResetContent();
strcpy(findBuf, dirBuf);
strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf));
snprintf(findBuf, ARRAY_SIZE(findBuf), "%s*.*", dirBuf);

Bool found = false;

Expand All @@ -145,11 +136,7 @@ void OpenMap::populateMapListbox( Bool systemMaps )
continue;
}

strcpy(fileBuf, dirBuf);
strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(findBuf));
strlcat(fileBuf, "\\", ARRAY_SIZE(findBuf));
strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(findBuf));
strlcat(fileBuf, ".map", ARRAY_SIZE(findBuf));
snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s\\%s.map", dirBuf, findData.cFileName, findData.cFileName);
try {
CFileStatus status;
if (CFile::GetStatus(fileBuf, status)) {
Expand Down
11 changes: 3 additions & 8 deletions Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ void SaveMap::populateMapListbox( Bool systemMaps )
CListBox *pList = (CListBox *)this->GetDlgItem(IDC_SAVE_LIST);
if (pList == NULL) return;
pList->ResetContent();
strcpy(findBuf, dirBuf);
strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf));
snprintf(findBuf, ARRAY_SIZE(findBuf), "%s*.*", dirBuf);

hFindFile = FindFirstFile(findBuf, &findData);
if (hFindFile != INVALID_HANDLE_VALUE) {
Expand All @@ -149,11 +148,7 @@ void SaveMap::populateMapListbox( Bool systemMaps )
if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
continue;
}
strcpy(fileBuf, dirBuf);
strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(fileBuf));
strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf));
strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(fileBuf));
strlcat(fileBuf, ".map", ARRAY_SIZE(fileBuf));
snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s\\%s.map", dirBuf, findData.cFileName, findData.cFileName);
try {
CFileStatus status;
if (CFile::GetStatus(fileBuf, status)) {
Expand All @@ -169,7 +164,7 @@ void SaveMap::populateMapListbox( Bool systemMaps )
}
CEdit *pEdit = (CEdit*)GetDlgItem(IDC_SAVE_MAP_EDIT);
if (pEdit != NULL) {
strcpy(fileBuf, m_pInfo->filename);
strlcpy(fileBuf, m_pInfo->filename, ARRAY_SIZE(fileBuf));
Int len = strlen(fileBuf);
if (len>4 && stricmp(".map", fileBuf+(len-4)) == 0) {
// strip of the .map
Expand Down
9 changes: 3 additions & 6 deletions Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,18 @@ void WorldHeightMapEdit::loadBaseImages(void)
void WorldHeightMapEdit::loadDirectoryOfImages(const char *pFilePath)
{
char dirBuf[_MAX_PATH];
char findBuf[_MAX_PATH];
char fileBuf[_MAX_PATH];

strcpy(dirBuf, pFilePath);
strlcpy(dirBuf, pFilePath, ARRAY_SIZE(dirBuf));
int len = strlen(dirBuf);

if (len > 0 && dirBuf[len - 1] != '\\') {
dirBuf[len++] = '\\';
dirBuf[len] = 0;
}
strcpy(findBuf, dirBuf);

FilenameList filenameList;
TheFileSystem->getFileListInDirectory(AsciiString(findBuf), AsciiString("*.*"), filenameList, TRUE);
TheFileSystem->getFileListInDirectory(AsciiString(dirBuf), AsciiString("*.*"), filenameList, TRUE);

if (filenameList.size() == 0) {
return;
Expand All @@ -436,8 +434,7 @@ void WorldHeightMapEdit::loadDirectoryOfImages(const char *pFilePath)
do {
AsciiString filename = *it;

strcpy(fileBuf, dirBuf);
strcat(fileBuf, filename.str());
snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s", dirBuf, filename.str());
loadBitmap(fileBuf, filename.str());

++it;
Expand Down
19 changes: 3 additions & 16 deletions GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,12 @@ void OpenMap::populateMapListbox( Bool systemMaps )
strcpy(dirBuf, "Maps\\");
else
{
strcpy(dirBuf, TheGlobalData->getPath_UserData().str());
strlcat(dirBuf, "Maps\\", ARRAY_SIZE(dirBuf));
}

int len = strlen(dirBuf);

if (len > 0 && dirBuf[len - 1] != '\\') {
dirBuf[len++] = '\\';
dirBuf[len] = 0;
snprintf(dirBuf, ARRAY_SIZE(dirBuf), "%sMaps\\", TheGlobalData->getPath_UserData().str());
}
CListBox *pList = (CListBox *)this->GetDlgItem(IDC_OPEN_LIST);
if (pList == NULL) return;
pList->ResetContent();
strcpy(findBuf, dirBuf);
strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf));
snprintf(findBuf, ARRAY_SIZE(findBuf), "%s*.*", dirBuf);

Bool found = false;

Expand All @@ -145,11 +136,7 @@ void OpenMap::populateMapListbox( Bool systemMaps )
continue;
}

strcpy(fileBuf, dirBuf);
strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(findBuf));
strlcat(fileBuf, "\\", ARRAY_SIZE(findBuf));
strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(findBuf));
strlcat(fileBuf, ".map", ARRAY_SIZE(findBuf));
snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s\\%s.map", dirBuf, findData.cFileName, findData.cFileName);
try {
CFileStatus status;
if (CFile::GetStatus(fileBuf, status)) {
Expand Down
11 changes: 3 additions & 8 deletions GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ void SaveMap::populateMapListbox( Bool systemMaps )
CListBox *pList = (CListBox *)this->GetDlgItem(IDC_SAVE_LIST);
if (pList == NULL) return;
pList->ResetContent();
strcpy(findBuf, dirBuf);
strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf));
snprintf(findBuf, ARRAY_SIZE(findBuf), "%s*.*", dirBuf);

hFindFile = FindFirstFile(findBuf, &findData);
if (hFindFile != INVALID_HANDLE_VALUE) {
Expand All @@ -149,11 +148,7 @@ void SaveMap::populateMapListbox( Bool systemMaps )
if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
continue;
}
strcpy(fileBuf, dirBuf);
strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(fileBuf));
strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf));
strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(fileBuf));
strlcat(fileBuf, ".map", ARRAY_SIZE(fileBuf));
snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s\\%s.map", dirBuf, findData.cFileName, findData.cFileName);
try {
CFileStatus status;
if (CFile::GetStatus(fileBuf, status)) {
Expand All @@ -169,7 +164,7 @@ void SaveMap::populateMapListbox( Bool systemMaps )
}
CEdit *pEdit = (CEdit*)GetDlgItem(IDC_SAVE_MAP_EDIT);
if (pEdit != NULL) {
strcpy(fileBuf, m_pInfo->filename);
strlcpy(fileBuf, m_pInfo->filename, ARRAY_SIZE(fileBuf));
Int len = strlen(fileBuf);
if (len>4 && stricmp(".map", fileBuf+(len-4)) == 0) {
// strip of the .map
Expand Down
9 changes: 3 additions & 6 deletions GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,29 +415,26 @@ void WorldHeightMapEdit::loadBaseImages(void)
void WorldHeightMapEdit::loadDirectoryOfImages(const char *pFilePath)
{
char dirBuf[_MAX_PATH];
char findBuf[_MAX_PATH];
char fileBuf[_MAX_PATH];

strcpy(dirBuf, pFilePath);
strlcpy(dirBuf, pFilePath, ARRAY_SIZE(dirBuf));
int len = strlen(dirBuf);

if (len > 0 && dirBuf[len - 1] != '\\') {
dirBuf[len++] = '\\';
dirBuf[len] = 0;
}
strcpy(findBuf, dirBuf);

FilenameList filenameList;
TheFileSystem->getFileListInDirectory(AsciiString(findBuf), AsciiString("*.*"), filenameList, TRUE);
TheFileSystem->getFileListInDirectory(AsciiString(dirBuf), AsciiString("*.*"), filenameList, TRUE);

if (filenameList.size() == 0) {
return;
}
FilenameList::iterator it = filenameList.begin();
do {
AsciiString filename = *it;
//strcpy(fileBuf, dirBuf);
strcpy(fileBuf, filename.str());
snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s", dirBuf, filename.str());
loadBitmap(fileBuf, filename.str());

++it;
Expand Down
Loading