diff options
author | rodri <rgl@antares-labs.eu> | 2023-08-30 22:07:50 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-08-30 22:07:50 +0000 |
commit | be547a2dba10292fb3191bc5fec42212d2391660 (patch) | |
tree | 4f8771a774d0a947f39aea1c9e92e4c768f87bb9 /util.c | |
parent | 3d93e42d0e854a3bb7c3a380a0635cf927d59ab7 (diff) | |
download | battleship-be547a2dba10292fb3191bc5fec42212d2391660.tar.gz battleship-be547a2dba10292fb3191bc5fec42212d2391660.tar.bz2 battleship-be547a2dba10292fb3191bc5fec42212d2391660.zip |
forbid placing ships after being done with the layout.
show the current ship and its length during placement.
also made changes to some of the info banners.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -16,6 +16,13 @@ static int shiplentab[] = { [Ssubmarine] 3, [Sdestroyer] 2, }; +static char *shipnametab[] = { + [Scarrier] "carrier", + [Sbattleship] "battleship", + [Scruiser] "cruiser", + [Ssubmarine] "submarine", + [Sdestroyer] "destroyer", +}; char * @@ -109,6 +116,15 @@ countshipcells(Map *m) int shiplen(int stype) { - assert(stype >= 0 && stype < NSHIPS); + if(stype < 0 || stype >= NSHIPS) + return -1; return shiplentab[stype]; } + +char * +shipname(int stype) +{ + if(stype < 0 || stype >= NSHIPS) + return nil; + return shipnametab[stype]; +} |