36 OutGauge::OutGauge(
void) :
60 #if defined(_WIN32) && defined(USE_SOCKETW)
61 SWBaseSocket::SWBaseError error;
65 if (WSAStartup(MAKEWORD(2, 2), &wsd) != 0)
67 LOG(
"[RoR|OutGauge] Error starting up winsock. OutGauge disabled.");
72 if ((
sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
74 LOG(String(
"[RoR|OutGauge] Error creating socket for OutGauge: ").append(strerror(errno)));
80 char* ip = inet_ntoa(*(
struct in_addr *)*remoteHost->h_addr_list);
83 struct sockaddr_in sendaddr;
84 memset(&sendaddr, 0,
sizeof(sendaddr));
85 sendaddr.sin_family = AF_INET;
86 sendaddr.sin_addr.s_addr = inet_addr(ip);
90 if (connect(
sockfd, (
struct sockaddr *) &sendaddr,
sizeof(sendaddr)) == SOCKET_ERROR)
92 LOG(String(
"[RoR|OutGauge] Error connecting socket for OutGauge: ").append(strerror(errno)));
96 LOG(
"[RoR|OutGauge] Connected successfully");
105 #if defined(_WIN32) && defined(USE_SOCKETW)
121 memset(&gd, 0,
sizeof(gd));
124 gd.Time = Root::getSingleton().getTimer()->getMilliseconds();
126 gd.Flags = 0 |
OG_KM;
127 sprintf(gd.Car,
"RoR");
132 sprintf(gd.Display2,
"not in vehicle");
137 sprintf(gd.Display2,
"no engine");
163 gd.DashLights |=
DL_TC;
181 gd.ShowLights |=
DL_TC;
196 send(
sockfd, (
const char*)&gd,
sizeof(gd), NULL);