diff --git a/src/libs/tgf/params.cpp b/src/libs/tgf/params.cpp index cd5b50f4..fba6af69 100644 --- a/src/libs/tgf/params.cpp +++ b/src/libs/tgf/params.cpp @@ -1762,6 +1762,37 @@ GfParmRemove (void *parmHandle, const char *sectionName, const char *paramName) } +/** Remove a section with given path. + @ingroup conf + @param handle handle of parameters + @param path path of section + @return 0 Ok +
-1 Error + */ +int +GfParmRemoveSection (void *handle, const char *path) +{ + struct parmHandle *parmHandle = (struct parmHandle *)handle; + struct parmHeader *conf; + struct section *section; + + if ((parmHandle == NULL) || (parmHandle->magic != PARM_MAGIC)) { + GfLogError ("GfParmRemoveSection: bad handle (%p)\n", parmHandle); + return -1; + } + + conf = parmHandle->conf; + + section = (struct section *)GfHashGetStr (conf->sectionHash, path); + if (!section) { + GfLogError ("GfParmRemoveSection: Section \"%s\" not found\n", path); + return -1; + } + removeSection (conf, section); + return 0; +} + + static void parmClean (struct parmHeader *conf) { struct section *section; @@ -1868,8 +1899,9 @@ void GfParmReleaseHandle (void *parmHandle) static void evalUnit (char *unit, tdble *dest, int invert) { + // TODO: Use a static std::map to make this code faster ? tdble coeff = 1.0; - + // SI units. if (strcmp(unit, "m") == 0) return; if (strcmp(unit, "N") == 0) return; @@ -1882,7 +1914,7 @@ evalUnit (char *unit, tdble *dest, int invert) if ((strcmp(unit, "l") == 0) || (strcmp(unit, "litre") == 0)) return; // Non-SI units conversion - // (please keep the order of the following tests : it is staticstically optimized). + // (please keep the order of the following tests : it is statistically optimized). if (strcmp(unit, "deg") == 0) { coeff = (float) (M_PI/180.0); /* rad */ } else if ((strcmp(unit, "lbs") == 0) || (strcmp(unit, "lb") == 0)) { @@ -2168,10 +2200,10 @@ GfParmGetEltNb (void *handle, const char *path) @ingroup paramsdata @param handle handle of parameters @param path path of section - @return 0 if doesn't exist, not 0 otherwise. + @return 0 if doesn't exist, 1 otherwise. */ int -GfParmExists (void *handle, const char *path) +GfParmExistsSection (void *handle, const char *path) { struct parmHandle *parmHandle = (struct parmHandle *)handle; struct parmHeader *conf; @@ -2186,7 +2218,7 @@ GfParmExists (void *handle, const char *path) section = (struct section *)GfHashGetStr (conf->sectionHash, path); - return section != 0; + return section != 0 ? 1 : 0; } diff --git a/src/libs/tgf/tgf.cpp b/src/libs/tgf/tgf.cpp index 36a03a15..dbe07bb0 100644 --- a/src/libs/tgf/tgf.cpp +++ b/src/libs/tgf/tgf.cpp @@ -473,6 +473,9 @@ void GfShutdown(void) // Shutdown the active profilers and dump the report if any. GfProfStopActiveProfiles(); GfProfPrintReport(); + + // Shutdown the params system. + GfParmShutdown(); } /** Restart the gaming framework (restart the current process). diff --git a/src/libs/tgf/tgf.h b/src/libs/tgf/tgf.h index caaa394f..a4c60107 100644 --- a/src/libs/tgf/tgf.h +++ b/src/libs/tgf/tgf.h @@ -367,7 +367,8 @@ TGF_API void *GfParmMergeHandles(void *ref, void *tgt, int mode); TGF_API int GfParmGetNumBoundaries(void *handle, char *path, char *key, tdble *min, tdble *max); TGF_API void GfParmRemove(void *handle, const char *path, const char *key); -TGF_API int GfParmExists(void *handle, const char *path); +TGF_API int GfParmRemoveSection (void *handle, const char *path); +TGF_API int GfParmExistsSection(void *handle, const char *path); TGF_API int GfParmGetEltNb(void *handle, const char *path); TGF_API int GfParmListSeekFirst(void *handle, const char *path); TGF_API int GfParmListSeekNext(void *handle, const char *path); @@ -380,6 +381,8 @@ TGF_API void GfParmSetVariable(void *handle, char const *path, char const *key, TGF_API void GfParmRemoveVariable(void *handle, char const *path, char const *key); TGF_API tdble GfParmGetVariable(void *handle, char const *path, char const *key); +TGF_API void GfParmShutdown (void); + /******************************************************************************** * Log/Trace Interface * * - Write formated string messages at run-time to the log stream, * diff --git a/src/modules/userinterface/legacymenu/confscreens/playerconfig.cpp b/src/modules/userinterface/legacymenu/confscreens/playerconfig.cpp index 8b5530a7..f762defe 100644 --- a/src/modules/userinterface/legacymenu/confscreens/playerconfig.cpp +++ b/src/modules/userinterface/legacymenu/confscreens/playerconfig.cpp @@ -332,7 +332,7 @@ PutPlayerSettings(unsigned index) GraphHdle = GfParmReadFile(pszGraphFileName, GFPARM_RMODE_REREAD); } - if (GfParmExists(GraphHdle, drvDispSecPath)) { // Change section name. + if (GfParmExistsSection(GraphHdle, drvDispSecPath)) { // Change section name. GfParmListRenameElt(GraphHdle, GR_SCT_DISPMODE, pszOldDispName, player->dispName()); }