Remove printMap() function
This commit is contained in:
parent
5a8e4f69e9
commit
c6affd8c21
41
common.h
41
common.h
@ -29,11 +29,6 @@
|
|||||||
// Maximum number of rounds after which the client loses the game:
|
// Maximum number of rounds after which the client loses the game:
|
||||||
#define MAX_ROUNDS 80
|
#define MAX_ROUNDS 80
|
||||||
|
|
||||||
// Suggested values to save information about the squares of the map:
|
|
||||||
#define SQUARE_UNKNOWN 0 // the square has not been targeted yet
|
|
||||||
#define SQUARE_HIT 1 // a shot at the square hit a ship
|
|
||||||
#define SQUARE_EMPTY 2 // a shot at the square was a miss (thus it is empty)
|
|
||||||
|
|
||||||
#define MIN(x,y) (x < y) ? x : y
|
#define MIN(x,y) (x < y) ? x : y
|
||||||
#define MAX(x,y) (x > y) ? x : y
|
#define MAX(x,y) (x > y) ? x : y
|
||||||
|
|
||||||
@ -56,40 +51,4 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Print a map showing the squares where ships have been hit.
|
|
||||||
*
|
|
||||||
* You might find this function useful for debugging.
|
|
||||||
*
|
|
||||||
* @param map A 2-dimensional array of unsigned 8-bit integers, where each
|
|
||||||
* element represents a square and its value indicates whether a
|
|
||||||
* shot has already been directed at this square and if a ship was
|
|
||||||
* hit by that shot, according to the values suggested above.
|
|
||||||
*
|
|
||||||
* Example usage:
|
|
||||||
* @code
|
|
||||||
* uint8_t map[MAP_SIZE][MAP_SIZE];
|
|
||||||
* memset(&map, 0, sizeof(map)); // initialize each square as unknown
|
|
||||||
* map[1][5] = SQUARE_EMPTY; // a shot at B5 did not hit anything
|
|
||||||
* map[2][3] = SQUARE_HIT; // a shot at C3 hit a ship
|
|
||||||
* print_map(map);
|
|
||||||
* @endcode
|
|
||||||
*/
|
|
||||||
static inline void print_map(uint8_t map[MAP_SIZE][MAP_SIZE])
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
printf(" ");
|
|
||||||
for (x = 0; x < MAP_SIZE; x++)
|
|
||||||
printf("%c ", 'A' + x);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
for (y = 0; y < MAP_SIZE; y++) {
|
|
||||||
printf("%c ", '0' + y);
|
|
||||||
for (x = 0; x < MAP_SIZE; x++)
|
|
||||||
printf("%c ", map[x][y] ? ((map[x][y] == 1) ? 'x' : 'o') : ' ');
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // COMMON_H
|
#endif // COMMON_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user