use BLI_findstring in more places & remove some warnings, no functional changes.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 22 Feb 2010 09:22:36 +0000 (09:22 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 22 Feb 2010 09:22:36 +0000 (09:22 +0000)
source/blender/blenloader/intern/readfile.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Rasterizer/RAS_CameraData.h

index 61f101d..591ec96 100644 (file)
@@ -32,6 +32,7 @@
 #include <limits.h>
 #include <stdio.h> // for printf fopen fwrite fclose sprintf FILE
 #include <stdlib.h> // for getenv atoi
+#include <stddef.h> // for offsetof
 #include <fcntl.h> // for open
 #include <string.h> // for strrchr strncmp strstr
 #include <math.h> // for fabs
@@ -10882,20 +10883,9 @@ char *bhead_id_name(FileData *fd, BHead *bhead)
 
 static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
 {
-       ListBase *lb;
-       char *idname= bhead_id_name(fd, bhead);
-
-       lb= wich_libbase(mainvar, GS(idname));
-       
-       if(lb) {
-               ID *id= lb->first;
-               while(id) {
-                       if( strcmp(id->name, idname)==0 ) 
-                               return id;
-                       id= id->next;
-               }
-       }
-       return NULL;
+       const char *idname= bhead_id_name(fd, bhead);
+       /* wich_libbase can be NULL, intentionally not using idname+2 */
+       return BLI_findstring(wich_libbase(mainvar, GS(idname)), idname, offsetof(ID, name));
 }
 
 static void expand_doit(FileData *fd, Main *mainvar, void *old)
index 8a2aea4..d06fc28 100644 (file)
@@ -316,22 +316,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
                                exitrequested = KX_EXIT_REQUEST_QUIT_GAME;
                        }
                }
-               
-               Scene *blscene = NULL;
-               if (!bfd)
-               {
-                       blscene = (Scene*) blenderdata->scene.first;
-                       for (Scene *sce= (Scene*) blenderdata->scene.first; sce; sce= (Scene*) sce->id.next)
-                       {
-                               if (startscenename == (sce->id.name+2))
-                               {
-                                       blscene = sce;
-                                       break;
-                               }
-                       }
-               } else {
-                       blscene = bfd->curscene;
-               }
+
+               Scene *blscene= bfd ? bfd->curscene : (Scene *)BLI_findstring(&blenderdata->scene, startscenename, offsetof(ID, name) + 2);
 
                if (blscene)
                {
@@ -457,7 +443,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
                                                        * should this really be?
                                                */
                                                if (event->type==MOUSEMOVE) {
-                                                       /* Note nice! XXX 2.5 event hack */
+                                                       /* Note, not nice! XXX 2.5 event hack */
                                                        val = event->x - ar->winrct.xmin;
                                                        mousedevice->ConvertBlenderEvent(MOUSEX, val);
                                                        
index 5852d61..411ddc5 100644 (file)
@@ -208,17 +208,14 @@ Scene *KX_BlenderSceneConverter::GetBlenderSceneForName(const STR_String& name)
         * Find the specified scene by name, or the first
         * scene if nothing matches (shouldn't happen).
         */
-
-       for (sce= (Scene*) m_maggie->scene.first; sce; sce= (Scene*) sce->id.next)
-               if (name == (sce->id.name+2))
-                       return sce;
+       if((sce= (Scene *)BLI_findstring(&m_maggie->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
+               return sce;
 
        for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++) {
                Main *main= *it;
 
-               for (sce= (Scene*) main->scene.first; sce; sce= (Scene*) sce->id.next)
-                       if (name == (sce->id.name+2))
-                               return sce;
+               if((sce= (Scene *)BLI_findstring(&main->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
+                       return sce;
        }
 
        return (Scene*)m_maggie->scene.first;
index 562d67b..0275c3e 100644 (file)
@@ -504,7 +504,6 @@ static PyObject* gPyAddScene(PyObject*, PyObject* args)
 {
        char* name;
        int overlay = 1;
-       KX_Scene* scene = NULL;
        
        if (!PyArg_ParseTuple(args, "s|i:addScene", &name , &overlay))
                return NULL;
index addbd2b..01f8d49 100644 (file)
@@ -51,12 +51,12 @@ struct RAS_CameraData
                m_clipstart(clipstart),
                m_clipend(clipend),
                m_perspective(perspective),
-               m_focallength(focallength),
                m_viewport(viewport),
                m_viewportleft(viewportleft),
                m_viewportbottom(viewportbottom),
                m_viewportright(viewportright),
-               m_viewporttop(viewporttop)
+               m_viewporttop(viewporttop),
+        m_focallength(focallength)
        {
        }
 };