From 2c63744fd3689b3c2274019fa9e4be33bb0a3b67 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 14 Feb 2015 22:48:30 +0000 Subject: [PATCH] Use array<> for jointlist --- common/main/robot.h | 3 +-- similar/main/robot.cpp | 14 ++++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/common/main/robot.h b/common/main/robot.h index 8b356d1c6..88c82dc23 100644 --- a/common/main/robot.h +++ b/common/main/robot.h @@ -146,9 +146,8 @@ struct robot_info : prohibit_void_ptr ubyte behavior; // Default behavior. ubyte aim; // 255 = perfect, less = more likely to miss. 0 != random, would look stupid. 0=45 degree spread. Specify in bitmaps.tbl in range 0.0..1.0 #endif - //animation info - jointlist anim_states[MAX_GUNS+1][N_ANIM_STATES]; + array, MAX_GUNS+1> anim_states; int always_0xabcd; // debugging }; diff --git a/similar/main/robot.cpp b/similar/main/robot.cpp index 6391984f0..73cb8336b 100644 --- a/similar/main/robot.cpp +++ b/similar/main/robot.cpp @@ -180,15 +180,13 @@ void robot_set_angles(robot_info *r,polymodel *pm,vms_angvec angs[N_ANIM_STATES] /* * reads n jointlist structs from a PHYSFS_file */ -static int jointlist_read_n(jointlist *jl, int n, PHYSFS_file *fp) +static void jointlist_read(PHYSFS_File *fp, array &jl) { - int i; - - for (i = 0; i < n; i++) { - jl[i].n_joints = PHYSFSX_readShort(fp); - jl[i].offset = PHYSFSX_readShort(fp); + range_for (auto &i, jl) + { + i.n_joints = PHYSFSX_readShort(fp); + i.offset = PHYSFSX_readShort(fp); } - return i; } /* @@ -294,7 +292,7 @@ void robot_info_read(PHYSFS_File *fp, robot_info &ri) #endif range_for (auto &j, ri.anim_states) - jointlist_read_n(j, N_ANIM_STATES, fp); + jointlist_read(fp, j); ri.always_0xabcd = PHYSFSX_readInt(fp); }