aboutsummaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
Diffstat (limited to 'gst')
-rw-r--r--gst/info.c7
-rw-r--r--gst/units.c6
2 files changed, 6 insertions, 7 deletions
diff --git a/gst/info.c b/gst/info.c
index 2329baf..0eaecb3 100644
--- a/gst/info.c
+++ b/gst/info.c
@@ -240,13 +240,14 @@ float info_unit_get_range(infos *info, info_unit *u, int w) {
float info_unit_get_maxrange(infos *info, info_unit *u) {
int lc = u->levels[LEVEL_CHASSIS];
- float sum = 0;
+ float max = 0;
for(int i=0; i<info->chassis[u->chassis].slot_weapon[lc]; i++) {
if (u->weapons[i] != -1) {
- sum += info_unit_get_range(info, u, i);
+ float range = info_unit_get_range(info, u, i);
+ if (range > max) { max = range; }
}
}
- return sum;
+ return max;
}
float info_unit_get_charge_per_shot (infos *info, info_unit *u, int w) {
diff --git a/gst/units.c b/gst/units.c
index 409f9b1..89c9489 100644
--- a/gst/units.c
+++ b/gst/units.c
@@ -64,7 +64,6 @@ void unit_remove (army *ar, map *m, unit *u) {
ar->uslen--;
ar->grid[xytoi(m, tx, ty)] = u;
ar->grid[xytoi(m, ux, uy)] = NULL;
- printf("ar->uslen: %d\n", ar->uslen);
}
void unit_dead (army *ar, map *m, unit *u) {
@@ -76,7 +75,6 @@ void unit_search (infos *info, army *ar, map *m, unit *u,
{
for (int f=0; f<32; t[f] = NULL, f++);
int mult[4][2] = { {1, 1},{1,-1},{-1,-1},{-1,1} }, x, y, dx, dy, tmp;
- *t = NULL;
for (int r=1; r<range*1.42 && *t==NULL; r++) {
for (int k=0; k<4 && *t==NULL; k++) {
for (int j=0; j<r && *t==NULL; j++) {
@@ -96,8 +94,8 @@ void unit_search (infos *info, army *ar, map *m, unit *u,
float diff[2] = {
u->gridpos[0] - (*t)->gridpos[0],
u->gridpos[1] - (*t)->gridpos[1]
- }; float mag = vec2_mag(diff);
- if (mag > range) *t = NULL;
+ }; float mag = vec2_mag2(diff);
+ if (mag > range*range) *t = NULL;
}
}}}
}