History

fix windows warnings

Brad Hefta-Gaub committed 12 years ago

Commit 825c1c81 parent 1358f6810 files · +459 −459Browse files

Showing the changes to interface/src/DataServerClient.cpp (1 of 10 files). Show all

Unified · Split

interface/src/DataServerClient.cpp+36−36
@@ -34,33 +34,33 @@ const HifiSockAddr& DataServerClient::dataServerSockAddr() { · 33 unmodified lines
3434 void DataServerClient::putValueForKey(const QString& key, const char* value) {
3535 QString clientString = Application::getInstance()->getProfile()->getUserString();
3636 if (!clientString.isEmpty()) {
37−
37+
3838 unsigned char* putPacket = new unsigned char[MAX_PACKET_SIZE];
39−
39+
4040 // setup the header for this packet
4141 int numPacketBytes = populateTypeAndVersion(putPacket, PACKET_TYPE_DATA_SERVER_PUT);
42−
42+
4343 // pack the client UUID, null terminated
4444 memcpy(putPacket + numPacketBytes, clientString.toLocal8Bit().constData(), clientString.toLocal8Bit().size());
4545 numPacketBytes += clientString.toLocal8Bit().size();
4646 putPacket[numPacketBytes++] = '\0';
47−
47+
4848 // pack a 1 to designate that we are putting a single value
4949 putPacket[numPacketBytes++] = 1;
50−
50+
5151 // pack the key, null terminated
5252 strcpy((char*) putPacket + numPacketBytes, key.toLocal8Bit().constData());
5353 numPacketBytes += key.size();
5454 putPacket[numPacketBytes++] = '\0';
55−
55+
5656 // pack the value, null terminated
5757 strcpy((char*) putPacket + numPacketBytes, value);
5858 numPacketBytes += strlen(value);
5959 putPacket[numPacketBytes++] = '\0';
60−
60+
6161 // add the putPacket to our vector of unconfirmed packets, will be deleted once put is confirmed
6262 // _unmatchedPackets.insert(std::pair<unsigned char*, int>(putPacket, numPacketBytes));
63−
63+
6464 // send this put request to the data server
6565 NodeList::getInstance()->getNodeSocket().writeDatagram((char*) putPacket, numPacketBytes,
6666 dataServerSockAddr().getAddress(),
@@ -81,27 +81,27 @@ void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QU · 14 unmodified lines
8181 void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, const QString& userString) {
8282 if (!userString.isEmpty() && keys.size() <= UCHAR_MAX) {
8383 unsigned char* getPacket = new unsigned char[MAX_PACKET_SIZE];
84−
84+
8585 // setup the header for this packet
8686 int numPacketBytes = populateTypeAndVersion(getPacket, PACKET_TYPE_DATA_SERVER_GET);
87−
87+
8888 // pack the user string (could be username or UUID string), null-terminate
8989 memcpy(getPacket + numPacketBytes, userString.toLocal8Bit().constData(), userString.toLocal8Bit().size());
9090 numPacketBytes += userString.toLocal8Bit().size();
9191 getPacket[numPacketBytes++] = '\0';
92−
92+
9393 // pack one byte to designate the number of keys
9494 getPacket[numPacketBytes++] = keys.size();
95−
95+
9696 QString keyString = keys.join(MULTI_KEY_VALUE_SEPARATOR);
97−
97+
9898 // pack the key string, null terminated
9999 strcpy((char*) getPacket + numPacketBytes, keyString.toLocal8Bit().constData());
100100 numPacketBytes += keyString.size() + sizeof('\0');
101−
101+
102102 // add the getPacket to our vector of uncofirmed packets, will be deleted once we get a response from the nameserver
103103 // _unmatchedPackets.insert(std::pair<unsigned char*, int>(getPacket, numPacketBytes));
104−
104+
105105 // send the get to the data server
106106 NodeList::getInstance()->getNodeSocket().writeDatagram((char*) getPacket, numPacketBytes,
107107 dataServerSockAddr().getAddress(),
@@ -120,25 +120,25 @@ void DataServerClient::processConfirmFromDataServer(unsigned char* packetData, i · 12 unmodified lines
120120 void DataServerClient::processSendFromDataServer(unsigned char* packetData, int numPacketBytes) {
121121 // pull the user string from the packet so we know who to associate this with
122122 int numHeaderBytes = numBytesForPacketHeader(packetData);
123−
123+
124124 char* userStringPosition = (char*) packetData + numHeaderBytes;
125−
125+
126126 QString userString(QByteArray(userStringPosition, strlen(userStringPosition)));
127−
127+
128128 QUuid userUUID(userString);
129−
129+
130130 char* keysPosition = (char*) packetData + numHeaderBytes + strlen(userStringPosition)
131131 + sizeof('\0') + sizeof(unsigned char);
132132 char* valuesPosition = keysPosition + strlen(keysPosition) + sizeof('\0');
133−
133+
134134 QStringList keyList = QString(keysPosition).split(MULTI_KEY_VALUE_SEPARATOR);
135135 QStringList valueList = QString(valuesPosition).split(MULTI_KEY_VALUE_SEPARATOR);
136−
136+
137137 // user string was UUID, find matching avatar and associate data
138− for (int i = 0; i < keyList.size(); i++) {
138+ for (size_t i = 0; i < keyList.size(); i++) {
139139 if (valueList[i] != " ") {
140140 if (keyList[i] == DataServerKey::FaceMeshURL) {
141−
141+
142142 if (userUUID.isNull() || userUUID == Application::getInstance()->getProfile()->getUUID()) {
143143 qDebug("Changing user's face model URL to %s\n", valueList[i].toLocal8Bit().constData());
144144 Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[i]));
@@ -148,7 +148,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 3 unmodified lines
148148 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
149149 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
150150 Avatar* avatar = (Avatar *) node->getLinkedData();
151−
151+
152152 if (avatar->getUUID() == userUUID) {
153153 QMetaObject::invokeMethod(&avatar->getHead().getFaceModel(),
154154 "setURL", Q_ARG(QUrl, QUrl(valueList[i])));
@@ -157,7 +157,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 2 unmodified lines
157157 }
158158 }
159159 } else if (keyList[i] == DataServerKey::SkeletonURL) {
160−
160+
161161 if (userUUID.isNull() || userUUID == Application::getInstance()->getProfile()->getUUID()) {
162162 qDebug("Changing user's skeleton URL to %s\n", valueList[i].toLocal8Bit().constData());
163163 Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i]));
@@ -167,7 +167,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 3 unmodified lines
167167 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
168168 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
169169 Avatar* avatar = (Avatar *) node->getLinkedData();
170−
170+
171171 if (avatar->getUUID() == userUUID) {
172172 QMetaObject::invokeMethod(&avatar->getSkeletonModel(), "setURL",
173173 Q_ARG(QUrl, QUrl(valueList[i])));
@@ -177,33 +177,33 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 3 unmodified lines
177177 }
178178 } else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position
179179 && valueList[i] != " " && valueList[i + 1] != " ") {
180−
180+
181181 QStringList coordinateItems = valueList[i + 1].split(',');
182−
182+
183183 if (coordinateItems.size() == 3) {
184−
184+
185185 // send a node kill request, indicating to other clients that they should play the "disappeared" effect
186186 NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
187−
187+
188188 qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<
189189 "and position to" << valueList[i + 1].toLocal8Bit().constData() <<
190190 "to go to" << userString << "\n";
191−
191+
192192 NodeList::getInstance()->setDomainHostname(valueList[i]);
193−
193+
194194 glm::vec3 newPosition(coordinateItems[0].toFloat(),
195195 coordinateItems[1].toFloat(),
196196 coordinateItems[2].toFloat());
197197 Application::getInstance()->getAvatar()->setPosition(newPosition);
198198 }
199−
199+
200200 } else if (keyList[i] == DataServerKey::UUID) {
201201 // this is the user's UUID - set it on the profile
202202 Application::getInstance()->getProfile()->setUUID(valueList[i]);
203203 }
204204 }
205205 }
206−
206+
207207 // remove the matched packet from our map so it isn't re-sent to the data-server
208208 // removeMatchedPacketFromMap(packetData, numPacketBytes);
209209 }
@@ -228,12 +228,12 @@ void DataServerClient::removeMatchedPacketFromMap(unsigned char* packetData, int · 18 unmodified lines
228228 if (memcmp(mapIterator->first + sizeof(PACKET_TYPE),
229229 packetData + sizeof(PACKET_TYPE),
230230 numPacketBytes - sizeof(PACKET_TYPE)) == 0) {
231−
231+
232232 // this is a match - remove the confirmed packet from the vector and delete associated member
233233 // so it isn't sent back out
234234 delete[] mapIterator->first;
235235 _unmatchedPackets.erase(mapIterator);
236−
236+
237237 // we've matched the packet - bail out
238238 break;
239239 }