- Timestamp:
- May 18, 2013, 8:14:14 PM (12 years ago)
- Branches:
- master
- Children:
- d69eb32
- Parents:
- a72bbde
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
ra72bbde r430c80e 74 74 75 75 return NULL; 76 }77 78 void broadcastPlayerPositions(map<unsigned int, Player> &m, int sock)79 {80 map<unsigned int, Player>::iterator it, it2;81 NETWORK_MSG serverMsg;82 83 serverMsg.type = MSG_TYPE_PLAYER;84 85 for (it = m.begin(); it != m.end(); it++)86 {87 it->second.serialize(serverMsg.buffer);88 89 for (it2 = m.begin(); it2 != m.end(); it2++)90 {91 if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 )92 error("sendMessage");93 }94 }95 76 } 96 77 … … 129 110 bool broadcastResponse; 130 111 timespec ts; 131 longtimeLastUpdated = 0, curTime = 0, timeLastBroadcast = 0;112 int timeLastUpdated = 0, curTime = 0, timeLastBroadcast = 0; 132 113 while (true) { 133 114 … … 135 116 136 117 clock_gettime(CLOCK_REALTIME, &ts); 137 curTime = ts.tv_sec + ts.tv_nsec*1000000000; 138 139 if (timeLastUpdated == 0 || (curTime-timeLastUpdated) >= 50000) { 118 // make the number smaller so millis can fit in an int 119 ts.tv_sec = ts.tv_sec & 0x3fffff; 120 curTime = ts.tv_sec*1000 + ts.tv_nsec/1000000; 121 122 if (timeLastUpdated == 0 || (curTime-timeLastUpdated) >= 50) { 140 123 timeLastUpdated = curTime; 141 124
Note:
See TracChangeset
for help on using the changeset viewer.