-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommon.h
executable file
·104 lines (83 loc) · 1.76 KB
/
Common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* \file Common.h
* A Documented file.
*/
#ifndef COMMON_H
#define COMMON_H
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#include <stdint.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define BOARD_SIZE 10
#define EMPTY_SQUARE -1
#define TOLERANCE 2
#define MAX_OPPONENTS 20
void setLedOff(int led);
void setLedOn(int led);
#define _LED_1 0
#define _LED_2 1
#define _LED_3 2
#define _LED_4 22
#define lan
#ifdef lan
#define BCAST "10.10.255.255"
#define NMASK "255.255.0.0"
#else
#define BCAST "10.10.7.255"
#define NMASK "255.255.255.0"
#endif
//typedef unsigned char u_char;
short * Sinewave;
short * Arccos;
void assignSinewave(void);
/**
* List of different forms of shots.
* Note that the values are ASCII character codes that are used by the terminal UI to demonstrate hits and misses.
*/
enum shots
{
NO_HIT = 46, //char "."
HIT = 120, //char "x"
MISS = 111, //char "o"
GHOST_SHOT = 63, //char "?"
SUNK = 35 //char "#"
};
/**
* Coordinates.
*/
typedef struct
{
int x;
int y;
} Grids;
/**
* Command queue.
*/
typedef struct
{
short cmd;
void * next;
} Command;
int sqrt_int(int x);
int logTwo(int n);
short cosine(int rad);
short arcuscos(short div);
int absolute(int real, int imag);
/**
* \fn C_shipLength
* Determines the length of a ship, judging by the ship index.
* 0->5, 1->4, 2->3, 3->3, 4->2.
* @param shipIndex
* @return ship length
*/
int C_shipLength(int shipIndex);
/**
* Determines if the given coordinates are within the game board.
* @param x
* @param y
* @return true if the given coordinates area out of the board.
*/
bool C_outOfBoard(int x, int y);
#endif