Mercurial > hg > batmud > maputils
changeset 1469:3142cbc3c072
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 13 May 2014 17:03:42 +0300 |
parents | 1c44f8b1ad40 |
children | e5502fc43a7d |
files | libmaputils.c |
diffstat | 1 files changed, 20 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libmaputils.c Sun May 04 21:57:44 2014 +0300 +++ b/libmaputils.c Tue May 13 17:03:42 2014 +0300 @@ -329,17 +329,13 @@ { int i; - if (getOld) + for (i = 0; i < npieces; i++) { - for (i = 0; i < npieces; i++) - if (pieces[i].oldSymbol == symbol) - return i; + if ((getOld && pieces[i].oldSymbol == symbol) || + (!getOld && pieces[i].symbol == symbol)) + return i; } - for (i = 0; i < npieces; i++) - if (pieces[i].symbol == symbol) - return i; - return -1; } @@ -362,23 +358,23 @@ if (getOld) { for (i = 0; i < npieces; i++) - if (pieces[i].oldSymbol == symbol) - { - if (pieces[i].oldColor >= 0) - return pieces[i].oldColor; - else - return pieces[i].color; - } - } - - for (i = 0; i < npieces; i++) - if (pieces[i].symbol == symbol) + if (pieces[i].oldSymbol == symbol) { - if (getOld && pieces[i].oldColor >= 0) + if (pieces[i].oldColor >= 0) return pieces[i].oldColor; else return pieces[i].color; } + } + + for (i = 0; i < npieces; i++) + if (pieces[i].symbol == symbol) + { + if (getOld && pieces[i].oldColor >= 0) + return pieces[i].oldColor; + else + return pieces[i].color; + } return -1; } @@ -391,10 +387,7 @@ if (getCity && (n = mcGetColorFromList(mapCityPieces, nmapCityPieces, symbol, getOld)) >= 0) return n; - if ((n = mcGetColorFromList(mapPieces, nmapPieces, symbol, getOld)) >= 0) - return n; - else - return 0; + return ((n = mcGetColorFromList(mapPieces, nmapPieces, symbol, getOld)) >= 0) ? n : 0; } @@ -411,7 +404,9 @@ "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n", strCharSet); /* - } else { + } + else + { fprintf(outFile, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" "<html>\n"