Mercurial > hg > batmud > maputils
changeset 2195:b7bfdb4caa2f
Improve error checking for some input options.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 13 Oct 2019 03:00:36 +0300 |
parents | 7acc7986ab4f |
children | 34fda0991705 |
files | mkloc.c |
diffstat | 1 files changed, 29 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mkloc.c Sun Oct 13 02:13:43 2019 +0300 +++ b/mkloc.c Sun Oct 13 03:00:36 2019 +0300 @@ -140,23 +140,37 @@ break; case 7: - f = &optLocFiles[noptLocFiles]; - f->xoffs = atoi(optArg); - THMSG(2, "Location file #%d X offset = %d\n", noptLocFiles, f->xoffs); + case 8: + case 21: + if (noptLocFiles >= 0) + { + f = &optLocFiles[noptLocFiles]; + switch (optN) + { + case 7: + f->xoffs = atoi(optArg); + THMSG(2, "Location file #%d X offset = %d\n", noptLocFiles, f->xoffs); + break; + + case 8: + f->yoffs = atoi(optArg); + THMSG(2, "Location file #%d Y offset = %d\n", noptLocFiles, f->yoffs); + break; + + case 21: + th_free(f->continent); + f->continent = th_strdup(optArg); + THMSG(2, "Using continent name '%s' for location file #%d\n", optArg, noptLocFiles); + break; + } + } + else + { + THERR("No location files specified, but location option '-%s %s' given.\n", currArg, optArg); + return FALSE; + } break; - case 8: - f = &optLocFiles[noptLocFiles]; - f->yoffs = atoi(optArg); - THMSG(2, "Location file #%d Y offset = %d\n", noptLocFiles, f->yoffs); - break; - - case 21: - f = &optLocFiles[noptLocFiles]; - th_free(f->continent); - f->continent = th_strdup(optArg); - THMSG(2, "Using continent name '%s' for location file #%d\n", optArg, noptLocFiles); - break; case 9: optScale = atof(optArg);