use sbstring for make_movement_order.

This commit is contained in:
Enno Rehling 2018-04-22 18:12:55 +01:00
parent 2f7637f953
commit b868a54f0b
1 changed files with 6 additions and 12 deletions

View File

@ -1133,25 +1133,19 @@ order * cycle_route(order * ord, const struct locale *lang, int gereist)
order * make_movement_order(const struct locale *lang, direction_t steps[], int length)
{
char zOrder[128], *bufp = zOrder;
size_t size = sizeof(zOrder) - 1;
sbstring sbs;
char zOrder[128];
int i;
sbs_init(&sbs, zOrder, sizeof(zOrder));
for (i = 0; i != length; ++i) {
int bytes;
direction_t dir = steps[i];
if (size > 1 && bufp != zOrder) {
*bufp++ = ' ';
--size;
if (i > 0) {
sbs_strcat(&sbs, " ");
}
bytes =
(int)str_strlcpy(bufp,
(const char *)LOC(lang, directions[dir]), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
sbs_strcat(&sbs, LOC(lang, directions[dir]));
}
*bufp = 0;
return create_order(K_MOVE, lang, zOrder);
}