ManaPlus
Functions
env.h File Reference

(986a3bf)

#include "localconsts.h"

Go to the source code of this file.

Functions

void setEnv (const char *const name, const char *const value)
 
void updateEnv ()
 

Function Documentation

◆ setEnv()

void setEnv ( const char *const  name,
const char *const  value 
)

Definition at line 60 of file env.cpp.

61 {
62  if ((name == nullptr) || (value == nullptr))
63  return;
64 #ifdef WIN32
65  if (putenv(const_cast<char*>((std::string(name)
66  + "=" + value).c_str())))
67 #else // WIN32
68 
69  if (setenv(name, value, 1) != 0)
70 #endif // WIN32
71  {
72  logger->log("setenv failed: %s=%s", name, value);
73  }
74 }
void log(const char *const log_text,...)
Definition: logger.cpp:269
Logger * logger
Definition: logger.cpp:89

References Logger::log(), and logger.

Referenced by SDL::allowScreenSaver(), setLangEnv(), and updateEnv().

◆ updateEnv()

void updateEnv ( )

Definition at line 30 of file env.cpp.

31 {
32 #if defined(WIN32) || defined(__APPLE__)
33  if (config.getBoolValue("centerwindow"))
34  setEnv("SDL_VIDEO_CENTERED", "1");
35  else
36  setEnv("SDL_VIDEO_CENTERED", "0");
37 #endif // defined(WIN32) || defined(__APPLE__)
38 
39 #ifndef WIN32
40  const int vsync = settings.options.test.empty()
41  ? config.getIntValue("vsync") : 1;
42  // __GL_SYNC_TO_VBLANK is nvidia variable.
43  // vblank_mode is MESA variable.
44  switch (vsync)
45  {
46  case 1:
47  setEnv("__GL_SYNC_TO_VBLANK", "0");
48  setEnv("vblank_mode", "0");
49  break;
50  case 2:
51  setEnv("__GL_SYNC_TO_VBLANK", "1");
52  setEnv("vblank_mode", "2");
53  break;
54  default:
55  break;
56  }
57 #endif // WIN32
58 }
bool getBoolValue(const std::string &key) const
int getIntValue(const std::string &key) const
Options options
Definition: settings.h:130
Configuration config
void setEnv(const char *const name, const char *const value)
Definition: env.cpp:60
Settings settings
Definition: settings.cpp:32
std::string test
Definition: options.h:88

References config, Configuration::getBoolValue(), Configuration::getIntValue(), Settings::options, setEnv(), settings, and Options::test.

Referenced by Client::gameInit().