Re #138 : Fixed temporary Ruin'dows / MSWC port workaround for r2595 commit

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2604 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 4d83cae523702258c781f6f8c67fb2fafba83d0d
Former-commit-id: 2fa177c3fbfdb4b663fa934ae082d5a1477c03a2
This commit is contained in:
pouillot 2010-08-04 08:35:35 +00:00
parent 7fcc493b58
commit fe9666aa23
3 changed files with 12 additions and 180 deletions

View file

@ -37,13 +37,12 @@
// Some consts.
const char* rmdStdSkinName = "standard";
// Temporary workaround for MS shit : moved to driverselect.cpp
// static const char* pszSkinFileExt = ".png";
// static const char* pszPreviewFileSuffix = "-preview.png";
static const char* pszSkinFileExt = ".png";
static const char* pszPreviewFileSuffix = "-preview.png";
// static const char* apszExcludedSkinFileSuffixes[] =
// { "-rpm.png", "-speed.png", pszPreviewFileSuffix };
// static const int nExcludedSkinFileSuffixes = sizeof(apszExcludedSkinFileSuffixes) / sizeof(char*);
static const char* apszExcludedSkinFileSuffixes[] =
{ "-rpm.png", "-speed.png", pszPreviewFileSuffix };
static const int nExcludedSkinFileSuffixes = sizeof(apszExcludedSkinFileSuffixes) / sizeof(char*);
int rmdDriverMatchesFilters(const trmdDrvElt *drv, const char* carCat, const char* drvTyp,
@ -58,7 +57,7 @@ void rmdGetDriverType(const char* moduleName, char* driverType, size_t maxSize)
char* pos;
strncpy(driverType, moduleName, maxSize);
driverType[maxSize-1] = 0; // Guarantee 0 termination
driverType[maxSize-1] = 0; // Ensure 0 termination
// Parse module name for last '_' char :
// assumed to be the separator between type and instance name for ubiquitous robots (ex: simplix)
@ -78,8 +77,6 @@ void rmdGetDriverType(const char* moduleName, char* driverType, size_t maxSize)
}
}
// Temporary workaround for MS shit : moved to driverselect.cpp
#if 0
void rmdGetCarSkinsInFolder(const trmdDrvElt *pDriver, const char* pszFolderPath,
std::vector<std::string>& lstSkinNames,
std::vector<std::string>& lstPreviewFiles)
@ -233,4 +230,3 @@ void rmdGetCarSkinsInSearchPath(const trmdDrvElt *pDriver,
}
}
}
#endif

View file

@ -53,13 +53,13 @@ extern void rmdGetDriverType(const char* moduleName, char* driverType, size_t ma
extern int rmdDriverMatchesFilters(const trmdDrvElt *drv, const char* carCat, const char* drvTyp,
const char* anyCarCat, const char* anyDrvTyp);
/* extern void rmdGetCarSkinsInFolder(const trmdDrvElt *pDriver, const char* pszFolderPath, */
/* std::vector<std::string>& lstSkinNames, */
/* std::vector<std::string>& lstPreviewFiles); */
extern void rmdGetCarSkinsInFolder(const trmdDrvElt *pDriver, const char* pszFolderPath,
std::vector<std::string>& lstSkinNames,
std::vector<std::string>& lstPreviewFiles);
/* extern void rmdGetCarSkinsInSearchPath(const trmdDrvElt *pDriver, */
/* std::vector<std::string>& lstSkinNames, */
/* std::vector<std::string>& lstPreviewFiles); */
extern void rmdGetCarSkinsInSearchPath(const trmdDrvElt *pDriver,
std::vector<std::string>& lstSkinNames,
std::vector<std::string>& lstPreviewFiles);
#endif /* __DRIVER_H__ */

View file

@ -92,170 +92,6 @@ static size_t CurSkinIndex = 0;
GF_TAILQ_HEAD(DriverListHead, trmdDrvElt);
static tDriverListHead DriverList;
// Functions and constants that should be in driver.h/cpp (temporary workaround for MS shit)
static const char* pszSkinFileExt = ".png";
static const char* pszPreviewFileSuffix = "-preview.png";
static const char* apszExcludedSkinFileSuffixes[] =
{ "-rpm.png", "-speed.png", pszPreviewFileSuffix };
static const int nExcludedSkinFileSuffixes = sizeof(apszExcludedSkinFileSuffixes) / sizeof(char*);
void rmdGetCarSkinsInFolder(const trmdDrvElt *pDriver, const char* pszFolderPath,
std::vector<std::string>& lstSkinNames,
std::vector<std::string>& lstPreviewFiles)
{
//struct stat st;
tFList *pSkinFileList, *pCurSkinFile;
GfOut("rmdGetCarSkinsInFolder(%s) :\n", pszFolderPath);
pCurSkinFile = pSkinFileList =
GfDirGetListFiltered(pszFolderPath, pDriver->carName, pszSkinFileExt);
if (pSkinFileList)
do
{
pCurSkinFile = pCurSkinFile->next;
// Ignore files with an excluded suffix.
int nExclSfxInd = 0;
for (; nExclSfxInd < nExcludedSkinFileSuffixes; nExclSfxInd++)
if (strstr(pCurSkinFile->name, apszExcludedSkinFileSuffixes[nExclSfxInd]))
break;
if (nExclSfxInd < nExcludedSkinFileSuffixes)
continue;
// Extract the skin name from the skin file name.
const int nSkinNameLen = // Expecting "<car name>-<skin name>.png"
strlen(pCurSkinFile->name) - strlen(pDriver->carName) - 1 - strlen(pszSkinFileExt);
std::string strSkinName;
if (nSkinNameLen > 0)
strSkinName =
std::string(pCurSkinFile->name)
.substr(strlen(pDriver->carName) + 1, nSkinNameLen);
else // Assuming default/standard "<car name>.png"
strSkinName = rmdStdSkinName;
// Ignore skins that are already in the list (path search priority).
if (std::find(lstSkinNames.begin(), lstSkinNames.end(), strSkinName)
== lstSkinNames.end())
{
// Add found skin in the list
lstSkinNames.push_back(strSkinName);
// Add associated preview image
// (don't check file existence now, will be needed only at display time).
std::ostringstream ossPreviewName;
ossPreviewName << pszFolderPath << '/' << pDriver->carName;
if (strSkinName != rmdStdSkinName)
ossPreviewName << '-' << strSkinName;
ossPreviewName << pszPreviewFileSuffix;
//if (!stat(ossPreviewName.str().c_str(), &st))
{
lstPreviewFiles.push_back(ossPreviewName.str());
GfOut("* found skin=%s, preview=%s\n",
strSkinName.c_str(), ossPreviewName.str().c_str());
}
// else
// GfError("Ignoring '%s' skin for %s/%d/%s because preview file %s not found\n",
// strSkinName.c_str(), pDriver->moduleName, pDriver->interfaceIndex,
// pDriver->carName, ossPreviewName.str().c_str());
}
} while (pCurSkinFile != pSkinFileList);
GfDirFreeList(pSkinFileList, NULL);
}
void rmdGetCarSkinsInSearchPath(const trmdDrvElt *pDriver,
std::vector<std::string>& lstSkinNames,
std::vector<std::string>& lstPreviewFiles)
{
std::ostringstream ossDirPath;
std::string strPreviewName;
GfOut("rmdGetCarSkinsInSearchPath : module=%s, idx=%d, car=%s ...\n",
pDriver->moduleName, pDriver->interfaceIndex, pDriver->carName);
// Clear the skin and preview lists.
lstSkinNames.clear();
lstPreviewFiles.clear();
// Get skins/previews from the directories in the search path
// (WARNING: Must be consistent with the search path passed to ssgTexturePath in grcar.cpp,
// at least for the car skin file search).
ossDirPath.str("");
ossDirPath << GetLocalDir() << "drivers/" << pDriver->moduleName
<< '/' << pDriver->carName;
rmdGetCarSkinsInFolder(pDriver, ossDirPath.str().c_str(),
lstSkinNames, lstPreviewFiles);
ossDirPath.str("");
ossDirPath << "drivers/" << pDriver->moduleName
<< '/' << pDriver->interfaceIndex << '/' << pDriver->carName;
rmdGetCarSkinsInFolder(pDriver, ossDirPath.str().c_str(),
lstSkinNames, lstPreviewFiles);
ossDirPath.str("");
ossDirPath << "drivers/" << pDriver->moduleName
<< '/' << pDriver->interfaceIndex;
rmdGetCarSkinsInFolder(pDriver, ossDirPath.str().c_str(),
lstSkinNames, lstPreviewFiles);
ossDirPath.str("");
ossDirPath << "drivers/" << pDriver->moduleName
<< '/' << pDriver->carName;
rmdGetCarSkinsInFolder(pDriver, ossDirPath.str().c_str(),
lstSkinNames, lstPreviewFiles);
ossDirPath.str("");
ossDirPath << "drivers/" << pDriver->moduleName;
rmdGetCarSkinsInFolder(pDriver, ossDirPath.str().c_str(),
lstSkinNames, lstPreviewFiles);
ossDirPath.str("");
ossDirPath << "cars/" << pDriver->carName;
rmdGetCarSkinsInFolder(pDriver, ossDirPath.str().c_str(),
lstSkinNames, lstPreviewFiles);
// // If no skin was found, add the car's standard one, should always be there !
// if (lstSkinNames.empty())
// {
// // Skin.
// lstSkinNames.push_back(rmdStdSkinName);
// // Associated preview image.
// std::ostringstream ossPreviewName;
// ossPreviewName << "cars/" << pDriver->carName << '/' << pDriver->carName
// << pszPreviewFileSuffix;
// lstPreviewFiles.push_back(ossPreviewName.str());
// GfOut("... skin=<%s>, preview=%s\n",
// rmdStdSkinName, ossPreviewName.str().c_str());
// }
// If we have at least 1 skin, make sure that if the standard one is inside,
// it is the first one.
if (!lstSkinNames.empty())
{
std::vector<std::string>::iterator iterSkin =
std::find(lstSkinNames.begin(), lstSkinNames.end(), rmdStdSkinName);
if (iterSkin != lstSkinNames.end() && iterSkin != lstSkinNames.begin())
{
std::vector<std::string>::iterator iterPreview =
lstPreviewFiles.begin() + (iterSkin - lstSkinNames.begin());
strPreviewName = *iterPreview;
lstSkinNames.erase(iterSkin);
lstPreviewFiles.erase(iterPreview);
lstSkinNames.insert(lstSkinNames.begin(), rmdStdSkinName);
lstPreviewFiles.insert(lstPreviewFiles.begin(), strPreviewName);
}
}
}
// Local functions.
static void rmdsCleanup(void);
static void rmdsFilterDriverScrollList(const char* carCat, const char* driverType);