1. rude
  2. love

Commits

Alex Szpakowski  committed bcb6336

Changed love.system.getPowerInfo to return -1 for battery percent and seconds remaining instead of nil, if the value can't be determined

  • Participants
  • Parent commits 483eef4
  • Branches default

Comments (0)

Files changed (2)

File changes.txt

View file
   * Updated most love.filesystem functions to return nil, error on internal failure.
   * Updated love.keypressed's second argument to be a boolean indicating key repeat.
   * Updated keyboard key constants for some more modern keyboard keys.
+  * Updated window code to use adaptive vsync when available, if vsync is enabled.
   * Updated the setFilter and setWrap methods, the second argument is now optional.
   * Updated Font and ParticleSystem rendering code, now more performant.
   * Updated SpriteBatch code, now more performant when adding/setting and (un)binding.

File src/modules/system/wrap_System.cpp

View file
 int w_getPowerInfo(lua_State *L)
 {
 	int seconds = -1, percent = -1;
-	const char *str;
+	const char *statestr;
 
 	System::PowerState state = instance->getPowerInfo(seconds, percent);
 
-	if (!System::getConstant(state, str))
-		str = "unknown";
+	if (!System::getConstant(state, statestr))
+		statestr = "unknown";
 
-	lua_pushstring(L, str);
+	lua_pushstring(L, statestr);
 
-	if (percent >= 0)
-		lua_pushinteger(L, percent);
-	else
-		lua_pushnil(L);
-
-	if (seconds >= 0)
-		lua_pushinteger(L, seconds);
-	else
-		lua_pushnil(L);
+	lua_pushinteger(L, percent);
+	lua_pushinteger(L, seconds);
 
 	return 3;
 }