Explorar o código

Merge pull request #475 from seanpaultaylor/next

Fixes Linux bugs for sample05-lua and sample06-racer
Sean Paul Taylor %!s(int64=13) %!d(string=hai) anos
pai
achega
91f3061b5d

+ 1 - 1
gameplay/src/AudioSource.cpp

@@ -34,7 +34,7 @@ AudioSource* AudioSource::create(const char* url)
 {
     // Load from a .audio file.
     std::string pathStr = url;
-    if (pathStr.find(".audio") != pathStr.npos)
+    if (pathStr.find(".audio") != std::string::npos)
     {
         Properties* properties = Properties::create(url);
         if (properties == NULL)

+ 1 - 3
gameplay/src/FileSystem.cpp

@@ -134,7 +134,6 @@ const char* FileSystem::resolvePath(const char* path)
 
 bool FileSystem::listFiles(const char* dirPath, std::vector<std::string>& files)
 {
-    // TODO make this method work with absolute and relative paths.
 #ifdef WIN32
     std::string path(FileSystem::getResourcePath());
     if (dirPath && strlen(dirPath) > 0)
@@ -211,7 +210,7 @@ bool FileSystem::fileExists(const char* filePath)
     createFileFromAsset(filePath);
 
     gp_stat_struct s;
-// Win32 doesn't support an asset or bundle definitions.
+
 #ifdef WIN32
     if (stat(fullPath.c_str(), &s) != 0)
     {
@@ -246,7 +245,6 @@ FILE* FileSystem::openFile(const char* path, const char* mode)
     
     FILE* fp = fopen(fullPath.c_str(), mode);
     
-// Win32 doesn't support an asset or bundle definitions.
 #ifdef WIN32
     if (fp == NULL)
     {

+ 3 - 1
gameplay/src/PlatformLinux.cpp

@@ -687,7 +687,9 @@ int Platform::enterMessagePump()
             }
         }
 
-        _game->frame();
+        if (_game)
+            _game->frame();
+
         glXSwapBuffers(__display, __window);
     }
 

+ 2 - 2
gameplay/src/Properties.cpp

@@ -976,11 +976,11 @@ void calculateNamespacePath(const std::string& urlString, std::string& fileStrin
     // If the url references a specific namespace within the file,
     // calculate the full namespace path to the final namespace.
     size_t loc = urlString.rfind("#");
-    if (loc != urlString.npos)
+    if (loc != std::string::npos)
     {
         fileString = urlString.substr(0, loc);
         std::string namespacePathString = urlString.substr(loc + 1);
-        while ((loc = namespacePathString.find("/")) != namespacePathString.npos)
+        while ((loc = namespacePathString.find("/")) != std::string::npos)
         {
             namespacePath.push_back(namespacePathString.substr(0, loc));
             namespacePathString = namespacePathString.substr(loc + 1);

+ 4 - 4
gameplay/src/SceneLoader.cpp

@@ -135,7 +135,7 @@ void SceneLoader::addSceneNodeProperty(SceneNode& sceneNode, SceneNodeProperty::
 
     // If there is a non-GPB file that needs to be loaded later, add an 
     // empty entry to the properties table to signify it.
-    if (urlStr.length() > 0 && urlStr.find(".") != urlStr.npos && urlStr.find(".gpb") == urlStr.npos && _properties.count(urlStr) == 0)
+    if (urlStr.length() > 0 && urlStr.find(".") != std::string::npos && urlStr.find(".gpb") == std::string::npos && _properties.count(urlStr) == 0)
         _properties[urlStr] = NULL;
 
     SceneNodeProperty prop(type, urlStr, index);
@@ -1071,14 +1071,14 @@ void splitURL(const std::string& url, std::string* file, std::string* id)
     }
 
     // Check if the url references a file (otherwise, it only references a node within the main GPB).
-    unsigned int loc = url.rfind(".");
-    if (loc != url.npos)
+    size_t loc = url.rfind(".");
+    if (loc != std::string::npos)
     {
         // If the url references a specific namespace within the file,
         // set the id out parameter appropriately. Otherwise, set the id out
         // parameter to the empty string so we know to load the first namespace.
         loc = url.rfind("#");
-        if (loc != url.npos)
+        if (loc != std::string::npos)
         {
             *file = url.substr(0, loc);
             *id = url.substr(loc + 1);

+ 4 - 4
gameplay/src/ScriptController.cpp

@@ -172,7 +172,7 @@ void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CF
         // Strip off the scope path part of the name.
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         std::size_t index = tablename.find(scopePath[0]);
-        if (index != tablename.npos)
+        if (index != std::string::npos)
             tablename = tablename.substr(index + scopePath[0].size());
         
         for (unsigned int i = 1; i < scopePath.size(); i++)
@@ -181,7 +181,7 @@ void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CF
             lua_gettable(sc->_lua, -2);
 
             index = tablename.find(scopePath[i]);
-            if (index != tablename.npos)
+            if (index != std::string::npos)
                 tablename = tablename.substr(index + scopePath[i].size());
         }
 
@@ -544,7 +544,7 @@ static const char* lua_print_function =
     "    ScriptController.print(table.concat({...},\"\\t\"), \"\\n\")\n"
     "end\n";
 
-#ifndef WIN32
+#ifndef WIN32 
 static const char* lua_loadfile_function = 
     "do\n"
     "    local oldLoadfile = loadfile\n"
@@ -746,7 +746,7 @@ void ScriptController::executeFunctionHelper(int resultCount, const char* func,
 
                 // Calculate the unique Lua type name.
                 size_t i = type.find("::");
-                while (i != type.npos)
+                while (i != std::string::npos)
                 {
                     // We use "" as the replacement here-this must match the preprocessor
                     // define SCOPE_REPLACEMENT from the gameplay-luagen project.