- Timestamp:
- May 25, 2013, 1:45:54 AM (12 years ago)
- Branches:
- master
- Children:
- 2df63d6
- Parents:
- b81cea1
- Location:
- common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Common.cpp
rb81cea1 rb07eeac 2 2 3 3 #include <iostream> 4 using namespace std; 4 #include <cmath> 5 5 6 6 #if defined WINDOWS … … 9 9 #include <time.h> 10 10 #endif 11 12 using namespace std; 13 14 /* 15 FLOAT_POSITION POSITION::toFloat() { 16 FLOAT_POSITION floatPosition; 17 floatPosition.x = x; 18 floatPosition.y = y; 19 20 return floatPosition; 21 } 22 */ 11 23 12 24 void set_nonblock(int sock) … … 38 50 return numMilliseconds; 39 51 } 52 53 float posDistance(FLOAT_POSITION pos1, FLOAT_POSITION pos2) { 54 float xDiff = pos2.x - pos1.x; 55 float yDiff = pos2.y - pos1.y; 56 57 return sqrt( pow(xDiff,2) + pow(yDiff,2) ); 58 } -
common/Common.h
rb81cea1 rb07eeac 12 12 #endif 13 13 14 void set_nonblock(int sock);15 unsigned long long getCurrentMillis();16 17 typedef struct18 {19 int x;20 int y;21 } POSITION;22 23 14 typedef struct 24 15 { … … 27 18 } FLOAT_POSITION; 28 19 20 typedef struct 21 { 22 int x; 23 int y; 24 //FLOAT_POSITION toFloat(); 25 FLOAT_POSITION toFloat() { 26 FLOAT_POSITION floatPosition; 27 floatPosition.x = x; 28 floatPosition.y = y; 29 30 return floatPosition; 31 } 32 } POSITION; 33 34 void set_nonblock(int sock); 35 unsigned long long getCurrentMillis(); 36 float posDistance(FLOAT_POSITION pos1, FLOAT_POSITION pos2); 37 29 38 #endif -
common/Message.cpp
rb81cea1 rb07eeac 19 19 int ret = sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in)); 20 20 21 cout << "Send a message of type " << msg->type << endl; 22 21 23 return ret; 22 24 }
Note:
See TracChangeset
for help on using the changeset viewer.