Fix mud_update_map()

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2018-05-05 12:38:30 +00:00
parent c8d949733a
commit db7f48890a

7
mud.c
View File

@@ -349,10 +349,15 @@ mud_update_map(struct mud *mud)
unsigned w = 0;
for (unsigned i = 0; i < mud->count; i++) {
struct mud_path *path = &mud->paths[i];
if (path->state <= MUD_DOWN)
continue;
if (w < sizeof(mud->map))
memset(&mud->map[w], i, sizeof(mud->map) - w);
w += (((mud->paths[i].r_ratemax + mud->paths[i].ratevar) << 10) + (n >> 1)) / n;
w += (((path->r_ratemax + path->ratevar) << 10) + (n >> 1)) / n;
}
return 0;