Changeset d05086b in network-game for common/Common.cpp


Ignore:
Timestamp:
Aug 1, 2013, 1:56:17 AM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
8271c78
Parents:
b35b2b2
Message:

Support for logging to a textfile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Common.cpp

    rb35b2b2 rd05086b  
    11#include "Common.h"
    22
    3 #include <iostream>
     3#include <sstream>
    44#include <cmath>
    55
     
    77   #include <Windows.h>
    88#elif defined LINUX
    9    #include <time.h>
     9   #include <ctime>
    1010#endif
    1111
    1212using 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 */
    2313
    2414void set_nonblock(int sock)
     
    5141}
    5242
     43string getCurrentDateTimeString() {
     44   time_t millis = time(NULL);
     45   struct tm *time = localtime(&millis);
     46
     47   ostringstream timeString;
     48   timeString << time->tm_hour << ":" << time->tm_min << ":"<< time->tm_sec << " " << (time->tm_mon+1) << "/" << time->tm_mday << "/" << (time->tm_year+1900);
     49
     50   return timeString.str();
     51}
     52
    5353float posDistance(FLOAT_POSITION pos1, FLOAT_POSITION pos2) {
    5454   float xDiff = pos2.x - pos1.x;
Note: See TracChangeset for help on using the changeset viewer.