SDL: Use dynamic cast instead of C cast to get screenshot path

This commit is contained in:
Thierry Crozat 2017-04-24 00:28:37 +01:00
parent 3849a3e90e
commit 438f23f272
2 changed files with 8 additions and 2 deletions

View File

@ -625,7 +625,10 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
if (event.kbd.keycode == Common::KEYCODE_s) {
Common::String filename;
Common::String screenshotsPath = ((OSystem_SDL *)g_system)->getScreenshotsPath();
Common::String screenshotsPath;
OSystem_SDL *sdl_g_system = dynamic_cast<OSystem_SDL*>(g_system);
if (sdl_g_system)
screenshotsPath = sdl_g_system->getScreenshotsPath();
for (int n = 0;; n++) {
SDL_RWops *file;

View File

@ -2526,7 +2526,10 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
if (event.kbd.hasFlags(Common::KBD_ALT) && event.kbd.keycode == 's') {
Common::String filename;
Common::String screenshotsPath = ((OSystem_SDL *)g_system)->getScreenshotsPath();
Common::String screenshotsPath;
OSystem_SDL *sdl_g_system = dynamic_cast<OSystem_SDL*>(g_system);
if (sdl_g_system)
screenshotsPath = sdl_g_system->getScreenshotsPath();
for (int n = 0;; n++) {
SDL_RWops *file;