Style Cleanup
authorCampbell Barton <ideasman42@gmail.com>
Sun, 1 May 2011 10:14:09 +0000 (10:14 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 1 May 2011 10:14:09 +0000 (10:14 +0000)
- duplicate cases in if/else
- calc inside sizeof(...)
- redundant NULL checks.
- assignment to self.
- fix error getting text prefix for screen ID button.

13 files changed:
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/filelist.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_input.c
source/blender/render/intern/source/render_texture.c

index e2d64a78c1891051fd7a1c2438ea2c2bb2a50d0d..0b07f40cad66a338c6bf8b5db6430d87f77a985b 100644 (file)
@@ -1381,7 +1381,7 @@ void text_idbutton(struct ID *id, char *text)
        if(id) {
                if(GS(id->name)==ID_SCE)
                        strcpy(text, "SCE: ");
-               else if(GS(id->name)==ID_SCE)
+               else if(GS(id->name)==ID_SCR)
                        strcpy(text, "SCR: ");
                else if(GS(id->name)==ID_MA && ((Material*)id)->use_nodes)
                        strcpy(text, "NT: ");
index 53b66238ec0a40c85fc8f2dc46d7dcc00420c7c7..e3639dd1c51279fe5002818b61e34b8655ff573d 100644 (file)
@@ -1917,7 +1917,7 @@ static ImBuf * seq_render_scene_strip_impl(
                camera= scene->camera;
        }
 
-       if(scene && have_seq==FALSE && camera==NULL) {
+       if(have_seq==FALSE && camera==NULL) {
                scene->r.cfra= oldcfra;
                return NULL;
        }
index abc469a5355dcea2f4aca84be96249a747844b53..39fab1929da6b8eb7fc3206ff1aaa929c10dcba0 100644 (file)
@@ -206,8 +206,6 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
                        }
                } else if (bhead->code==ENDB) {
                        break;
-               } else if (bhead->code==DATA) {
-                       /* DATA blocks between IDBlock and Preview */
                } else {
                        looking = 0;
                        new_prv = NULL;
index 3db42e84b946120f2154bcbbb51bc4015f4f2733..bfec26375bb361068855e7af6d0e5b8b0719efa1 100644 (file)
@@ -3769,7 +3769,12 @@ static void lib_link_object(FileData *fd, Main *main)
                                }
                                else if(act->type==ACT_OBJECT) {
                                        bObjectActuator *oa= act->data;
-                                       oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
+                                       if(oa==NULL) {
+                                               init_actuator(act);
+                                       }
+                                       else {
+                                               oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
+                                       }
                                }
                                else if(act->type==ACT_EDIT_OBJECT) {
                                        bEditObjectActuator *eoa= act->data;
@@ -3781,15 +3786,6 @@ static void lib_link_object(FileData *fd, Main *main)
                                                eoa->me= newlibadr(fd, ob->id.lib, eoa->me);
                                        }
                                }
-                               else if(act->type==ACT_OBJECT) {
-                                       bObjectActuator *oa= act->data;
-                                       if(oa==NULL) {
-                                               init_actuator(act);
-                                       }
-                                       else {
-                                               oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
-                                       }
-                               }
                                else if(act->type==ACT_SCENE) {
                                        bSceneActuator *sa= act->data;
                                        sa->camera= newlibadr(fd, ob->id.lib, sa->camera);
@@ -8716,11 +8712,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                ima->gen_x= 256; ima->gen_y= 256;
                                ima->gen_type= 1;
                                
-                               if(0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name+2))) {
+                               if(0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name)-2)) {
                                        ima->source= IMA_SRC_VIEWER;
                                        ima->type= IMA_TYPE_COMPOSITE;
                                }
-                               if(0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name+2))) {
+                               if(0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name)-2)) {
                                        ima->source= IMA_SRC_VIEWER;
                                        ima->type= IMA_TYPE_R_RESULT;
                                }
index c9b5b9f284836fa86c6378184d61e7ce13bebd25..f9c97c36bdd2bdb5d93f97822d655ec17710ebb9 100644 (file)
@@ -1578,7 +1578,7 @@ void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, fl
 }
 
 
-void ui_dropshadow(rctf *rct, float radius, float aspect, int select)
+void ui_dropshadow(rctf *rct, float radius, float aspect, int UNUSED(select))
 {
        int i;
        float rad;
@@ -1593,7 +1593,17 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, int select)
                rad= radius;
 
        i= 12;
-       if(select) a= i*aspect; else a= i*aspect;
+#if 0
+       if(select) {
+               a= i*aspect; /* same as below */
+       }
+       else
+#endif
+       {
+               a= i*aspect;
+
+       }
+
        for(; i--; a-=aspect) {
                /* alpha ranges from 2 to 20 or so */
                glColor4ub(0, 0, 0, alpha);
index cf11effc57b25787ff2bdb955d5dcb6048982355..ae5af18544275d4b32afb0e525ab914cba16bfa2 100644 (file)
@@ -2801,10 +2801,16 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                        
                        tempf= data->value;
                        temp= (int)data->value;
-                       
-                       /* XXX useles "if", same result for f, uh??? */
-                       if(but->type==SLI) f= (float)(mx-but->x1)/(but->x2-but->x1);
-                       else f= (float)(mx- but->x1)/(but->x2-but->x1);
+
+#if 0
+                       if(but->type==SLI) {
+                               f= (float)(mx-but->x1)/(but->x2-but->x1); /* same as below */
+                       }
+                       else
+#endif
+                       {
+                               f= (float)(mx- but->x1)/(but->x2-but->x1);
+                       }
                        
                        f= softmin + f*softrange;
                        
index b5f980ab7cb4ffdad53e4e49992c5b461fb384ed..e2d7147d21f556da8753bc8f682f8e2513a8be28 100644 (file)
@@ -1795,20 +1795,22 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
        bDopeSheet ads= {NULL};
        DLRBT_Tree keys;
        ActKeyColumn *ak;
-       float cfra= (scene)? (float)(CFRA) : 0.0f;
+       float cfra;
        short next= RNA_boolean_get(op->ptr, "next");
        short done = 0;
        
        /* sanity checks */
        if (scene == NULL)
                return OPERATOR_CANCELLED;
-       
+
+       cfra= (float)(CFRA);
+
        /* init binarytree-list for getting keyframes */
        BLI_dlrbTree_init(&keys);
        
        /* populate tree with keyframe nodes */
-       if (scene)
-               scene_to_keylist(&ads, scene, &keys, NULL);
+       scene_to_keylist(&ads, scene, &keys, NULL);
+
        if (ob)
                ob_to_keylist(&ads, ob, &keys, NULL);
        
@@ -1844,7 +1846,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
        
        sound_seek_scene(C);
 
-       WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C));
+       WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
        
        return OPERATOR_FINISHED;
 }
index bf7501ae5ce1c41780fa5de34fd521646a826f4b..903af649caabd406bce0218ff1be0d6f3b823932 100644 (file)
@@ -269,8 +269,6 @@ static int get_file_icon(struct direntry *file)
                return ICON_FILE_MOVIE;
        else if (file->flags & PYSCRIPTFILE)
                return ICON_FILE_SCRIPT;
-       else if (file->flags & PYSCRIPTFILE)
-               return ICON_FILE_SCRIPT;
        else if (file->flags & SOUNDFILE) 
                return ICON_FILE_SOUND;
        else if (file->flags & FTFONTFILE) 
index 0a8ae56c29198516d6e3d1f65dd5b534f7ecaffb..b097ad0f55e3d41a421ce5dbf90882483391254f 100644 (file)
@@ -797,8 +797,6 @@ int ED_file_extension_icon(char *relname)
                return ICON_FILE_MOVIE;
        else if (type ==  PYSCRIPTFILE)
                return ICON_FILE_SCRIPT;
-       else if (type ==  PYSCRIPTFILE)
-               return ICON_FILE_SCRIPT;
        else if (type ==  SOUNDFILE) 
                return ICON_FILE_SOUND;
        else if (type ==  FTFONTFILE) 
index 5e227cba5232aa6ae852822ad3edf87a6ec531a4..614b048e0b81403dd73ad272c50e1b772bc84dce 100644 (file)
@@ -192,15 +192,18 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
                UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
        }
        else if(t->spacetype == SPACE_ACTION) {
-               SpaceAction *sact = t->sa->spacedata.first;
                int out[2] = {0, 0};
+#if 0
+               SpaceAction *sact = t->sa->spacedata.first;
 
                if (sact->flag & SACTION_DRAWTIME) {
                        //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
-
+                       /* same as below */
                        UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
                } 
-               else {
+               else
+#endif
+               {
                        UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
                }
 
index 5e960593bd730bd059040c1f4dfac6272f23ad03..6be095fa98bfec7462e0968f95932ad8a971e783 100644 (file)
@@ -4811,10 +4811,16 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                 */
                if ((saction->flag & SACTION_MARKERS_MOVE) && (cancelled == 0)) {
                        if (t->mode == TFM_TIME_TRANSLATE) {
-                               if (ELEM(t->frame_side, 'L', 'R')) /* TFM_TIME_EXTEND */
+#if 0
+                               if (ELEM(t->frame_side, 'L', 'R')) { /* TFM_TIME_EXTEND */
+                                       /* same as below */
                                        ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side);
+                               }
                                else /* TFM_TIME_TRANSLATE */
+#endif
+                               {
                                        ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side);
+                               }
                        }
                        else if (t->mode == TFM_TIME_SCALE) {
                                ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side);
index 5097c12d7851363bba3045f3f47168ecc977d035..b6c4deffe0a23d989fdcff31e5a24b83560977a6 100644 (file)
@@ -235,8 +235,8 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2]
 
        /* use doubles here, to make sure a "1.0" (no rotation) doesnt become 9.999999e-01, which gives 0.02 for acos */
        double deler = ((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3))
-               / (2.0 * (A*B?A*B:1.0));
-       /* (A*B?A*B:1.0f) this takes care of potential divide by zero errors */
+               / (2.0 * ((A*B)?(A*B):1.0));
+       /* ((A*B)?(A*B):1.0) this takes care of potential divide by zero errors */
 
        float dphi;
 
index d8b5055effd693693795e91ab5c2105581f8fb9e..5f5dab94ba31747173d7726d6c9f7e101e9c54c3 100644 (file)
@@ -2544,7 +2544,6 @@ void do_material_tex(ShadeInput *shi)
                                }
                                else { /* add or sub */
                                        if(mtex->blendtype==MTEX_SUB) factt= -factt;
-                                       else factt= factt;
                                        shi->displace[0]+= factt*shi->vn[0];
                                        shi->displace[1]+= factt*shi->vn[1];
                                        shi->displace[2]+= factt*shi->vn[2];