Changeset 34bd549 in network-game for common


Ignore:
Timestamp:
Jun 19, 2014, 1:34:15 AM (10 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
master
Children:
3ea1839
Parents:
883bb5d
Message:

Make client compile on a Mac

Location:
common
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • common/Common.cpp

    r883bb5d r34bd549  
    88   #include <fcntl.h>
    99   #include <assert.h>
     10#elif defined MAC
     11   #include <fcntl.h>
     12   #include <assert.h>
     13   #include <mach/clock.h>
     14   #include <mach/mach.h>
    1015#endif
    1116
     
    5055      assert(flags != -1);
    5156      fcntl(sock, F_SETFL, flags | O_NONBLOCK);
     57   #elif defined MAC
     58      int flags = fcntl(sock, F_GETFL,0);
     59      assert(flags != -1);
     60      fcntl(sock, F_SETFL, flags | O_NONBLOCK);
    5261   #endif
    5362}
     
    6271      timespec curTime;
    6372      clock_gettime(CLOCK_REALTIME, &curTime);
     73
     74      numMilliseconds = curTime.tv_sec*(unsigned long long)1000+curTime.tv_nsec/(unsigned long long)1000000;
     75   # elif defined MAC
     76      timespec curTime;
     77
     78      clock_serv_t cclock;
     79      mach_timespec_t mts;
     80      host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
     81      clock_get_time(cclock, &mts);
     82      mach_port_deallocate(mach_task_self(), cclock);
     83      curTime.tv_sec = mts.tv_sec;
     84      curTime.tv_nsec = mts.tv_nsec;
    6485
    6586      numMilliseconds = curTime.tv_sec*(unsigned long long)1000+curTime.tv_nsec/(unsigned long long)1000000;
  • common/Compiler.h

    r883bb5d r34bd549  
    99#elif defined __posix
    1010   #define LINUX
     11#elif defined __APPLE__
     12   #define MAC
    1113#endif
  • common/MessageContainer.h

    r883bb5d r34bd549  
    99   #include <winsock2.h>
    1010#elif defined LINUX
     11   #include <netinet/in.h>
     12#elif defined MAC
    1113   #include <netinet/in.h>
    1214#endif
  • common/MessageProcessor.cpp

    r883bb5d r34bd549  
    5050
    5151   // assume we don't care about the value of socklen
     52   cout << "Waiting for message from server" << endl;
    5253   int ret =  recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)source, &socklen);
     54   cout << "Returned from wait" << endl;
    5355
    5456   if (ret == -1)
  • common/Player.h

    r883bb5d r34bd549  
    1010   #include <winsock2.h>
    1111#elif defined LINUX
     12   #include <netinet/in.h>
     13#elif defined MAC
    1214   #include <netinet/in.h>
    1315#endif
Note: See TracChangeset for help on using the changeset viewer.