From 29a2e905fb2c9bb79b0ed9895de83bef8b0293f9 Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 26 Sep 2014 02:42:10 +0000 Subject: [PATCH] Propagate for variables in similar/main/polyobj.cpp --- similar/main/polyobj.cpp | 47 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/similar/main/polyobj.cpp b/similar/main/polyobj.cpp index 05e7f7447..fc5a92c1b 100644 --- a/similar/main/polyobj.cpp +++ b/similar/main/polyobj.cpp @@ -131,9 +131,7 @@ static short pof_read_short(ubyte *bufp) static void pof_read_string(char *buf,int max_char, ubyte *bufp) { - int i; - - for (i=0; i= 1); - for (i = 1; i < no_chunks; i++) + for (int i = 1; i < no_chunks; i++) if (old_dest(chunk_list[i]) < old_dest(chunk_list[first_index])) first_index = i; return first_index; @@ -205,7 +203,7 @@ int get_first_chunks_index(chunk *chunk_list, int no_chunks) void align_polygon_model_data(polymodel *pm) { - int i, chunk_len; + int chunk_len; int total_correction = 0; ubyte *cur_old, *cur_new; chunk cur_ch; @@ -226,7 +224,7 @@ void align_polygon_model_data(polymodel *pm) cur_ch = ch_list[first_index]; // remove first chunk from array: no_chunks--; - for (i = first_index; i < no_chunks; i++) + for (int i = first_index; i < no_chunks; i++) ch_list[i] = ch_list[i + 1]; // if (new) address unaligned: if ((u_int32_t)new_dest(cur_ch) % 4L != 0) { @@ -234,7 +232,7 @@ void align_polygon_model_data(polymodel *pm) short to_shift = 4 - (u_int32_t)new_dest(cur_ch) % 4L; // correct chunks' addresses cur_ch.correction += to_shift; - for (i = 0; i < no_chunks; i++) + for (int i = 0; i < no_chunks; i++) ch_list[i].correction += to_shift; total_correction += to_shift; Assert((u_int32_t)new_dest(cur_ch) % 4L == 0); @@ -250,7 +248,7 @@ void align_polygon_model_data(polymodel *pm) chunk_len = get_chunks(cur_old, cur_new, ch_list, &no_chunks); memcpy(cur_new, cur_old, chunk_len); //correct submodel_ptr's for pm, too - for (i = 0; i < MAX_SUBMODELS; i++) + for (int i = 0; i < MAX_SUBMODELS; i++) if (&pm->model_data[pm->submodel_ptrs[i]] >= cur_old && &pm->model_data[pm->submodel_ptrs[i]] < cur_old + chunk_len) pm->submodel_ptrs[i] += (cur_new - tmp) - (cur_old - pm->model_data.get()); @@ -336,14 +334,13 @@ static polymodel *read_model_file(polymodel *pm,const char *filename,robot_info case ID_GUNS: { //List of guns on this object if (r) { - int i; vms_vector gun_dir; r->n_guns = pof_read_int(model_buf); Assert(r->n_guns <= MAX_GUNS); - for (i=0;in_guns;i++) { + for (int i=0;in_guns;i++) { uint_fast32_t id; id = pof_read_short(model_buf); @@ -369,14 +366,14 @@ static polymodel *read_model_file(polymodel *pm,const char *filename,robot_info case ID_ANIM: //Animation data if (r) { - int n_frames,f,m; + int n_frames; n_frames = pof_read_short(model_buf); Assert(n_frames == N_ANIM_STATES); - for (m=0;mn_models;m++) - for (f=0;fn_models;m++) + for (int f=0;fn_textures;i++) { + for (int i=0;in_textures;i++) { texture_list_index[i] = alt_textures[i]; texture_list[i] = &GameBitmaps[alt_textures[i].index]; } } else { - for (i=0;in_textures;i++) { + for (int i=0;in_textures;i++) { texture_list_index[i] = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]]; texture_list[i] = &GameBitmaps[ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index]; } @@ -550,13 +542,13 @@ void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angl // Make sure the textures for this object are paged in... piggy_page_flushed = 0; - for (i=0;in_textures;i++) + for (int i=0;in_textures;i++) PIGGY_PAGE_IN( texture_list_index[i] ); // Hmmm... cache got flushed in the middle of paging all these in, // so we need to reread them all in. if (piggy_page_flushed) { piggy_page_flushed = 0; - for (i=0;in_textures;i++) + for (int i=0;in_textures;i++) PIGGY_PAGE_IN( texture_list_index[i] ); } // Make sure that they can all fit in memory. @@ -571,9 +563,7 @@ void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angl g3_draw_polygon_model(po->model_data.get(),&texture_list[0],anim_angles,light,glow_values); else { - int i; - - for (i=0;flags;flags>>=1,i++) + for (int i=0;flags;flags>>=1,i++) if (flags & 1) { vms_vector ofs; @@ -605,13 +595,12 @@ static void polyobj_find_min_max(polymodel *pm) ushort nverts; vms_vector *vp; ushort *data,type; - int m; vms_vector *big_mn,*big_mx; big_mn = &pm->mins; big_mx = &pm->maxs; - for (m=0;mn_models;m++) { + for (int m=0;mn_models;m++) { vms_vector *mn,*mx,*ofs; mn = &pm->submodel_mins[m];