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
34void DataServerClient::putValueForKey(const QString& key, const char* value) {34void DataServerClient::putValueForKey(const QString& key, const char* value) {
35 QString clientString = Application::getInstance()->getProfile()->getUserString();35 QString clientString = Application::getInstance()->getProfile()->getUserString();
36 if (!clientString.isEmpty()) {36 if (!clientString.isEmpty()) {
37 37
38 unsigned char* putPacket = new unsigned char[MAX_PACKET_SIZE];38 unsigned char* putPacket = new unsigned char[MAX_PACKET_SIZE];
39 39
40 // setup the header for this packet40 // setup the header for this packet
41 int numPacketBytes = populateTypeAndVersion(putPacket, PACKET_TYPE_DATA_SERVER_PUT);41 int numPacketBytes = populateTypeAndVersion(putPacket, PACKET_TYPE_DATA_SERVER_PUT);
42 42
43 // pack the client UUID, null terminated43 // pack the client UUID, null terminated
44 memcpy(putPacket + numPacketBytes, clientString.toLocal8Bit().constData(), clientString.toLocal8Bit().size());44 memcpy(putPacket + numPacketBytes, clientString.toLocal8Bit().constData(), clientString.toLocal8Bit().size());
45 numPacketBytes += clientString.toLocal8Bit().size();45 numPacketBytes += clientString.toLocal8Bit().size();
46 putPacket[numPacketBytes++] = '\0';46 putPacket[numPacketBytes++] = '\0';
47 47
48 // pack a 1 to designate that we are putting a single value48 // pack a 1 to designate that we are putting a single value
49 putPacket[numPacketBytes++] = 1;49 putPacket[numPacketBytes++] = 1;
50 50
51 // pack the key, null terminated51 // pack the key, null terminated
52 strcpy((char*) putPacket + numPacketBytes, key.toLocal8Bit().constData());52 strcpy((char*) putPacket + numPacketBytes, key.toLocal8Bit().constData());
53 numPacketBytes += key.size();53 numPacketBytes += key.size();
54 putPacket[numPacketBytes++] = '\0';54 putPacket[numPacketBytes++] = '\0';
55 55
56 // pack the value, null terminated56 // pack the value, null terminated
57 strcpy((char*) putPacket + numPacketBytes, value);57 strcpy((char*) putPacket + numPacketBytes, value);
58 numPacketBytes += strlen(value);58 numPacketBytes += strlen(value);
59 putPacket[numPacketBytes++] = '\0';59 putPacket[numPacketBytes++] = '\0';
60 60
61 // add the putPacket to our vector of unconfirmed packets, will be deleted once put is confirmed61 // add the putPacket to our vector of unconfirmed packets, will be deleted once put is confirmed
62 // _unmatchedPackets.insert(std::pair<unsigned char*, int>(putPacket, numPacketBytes));62 // _unmatchedPackets.insert(std::pair<unsigned char*, int>(putPacket, numPacketBytes));
63 63
64 // send this put request to the data server64 // send this put request to the data server
65 NodeList::getInstance()->getNodeSocket().writeDatagram((char*) putPacket, numPacketBytes,65 NodeList::getInstance()->getNodeSocket().writeDatagram((char*) putPacket, numPacketBytes,
66 dataServerSockAddr().getAddress(),66 dataServerSockAddr().getAddress(),
@@ -81,27 +81,27 @@ void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QU · 14 unmodified lines
81void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, const QString& userString) {81void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, const QString& userString) {
82 if (!userString.isEmpty() && keys.size() <= UCHAR_MAX) {82 if (!userString.isEmpty() && keys.size() <= UCHAR_MAX) {
83 unsigned char* getPacket = new unsigned char[MAX_PACKET_SIZE];83 unsigned char* getPacket = new unsigned char[MAX_PACKET_SIZE];
84 84
85 // setup the header for this packet85 // setup the header for this packet
86 int numPacketBytes = populateTypeAndVersion(getPacket, PACKET_TYPE_DATA_SERVER_GET);86 int numPacketBytes = populateTypeAndVersion(getPacket, PACKET_TYPE_DATA_SERVER_GET);
87 87
88 // pack the user string (could be username or UUID string), null-terminate88 // pack the user string (could be username or UUID string), null-terminate
89 memcpy(getPacket + numPacketBytes, userString.toLocal8Bit().constData(), userString.toLocal8Bit().size());89 memcpy(getPacket + numPacketBytes, userString.toLocal8Bit().constData(), userString.toLocal8Bit().size());
90 numPacketBytes += userString.toLocal8Bit().size();90 numPacketBytes += userString.toLocal8Bit().size();
91 getPacket[numPacketBytes++] = '\0';91 getPacket[numPacketBytes++] = '\0';
92 92
93 // pack one byte to designate the number of keys93 // pack one byte to designate the number of keys
94 getPacket[numPacketBytes++] = keys.size();94 getPacket[numPacketBytes++] = keys.size();
95 95
96 QString keyString = keys.join(MULTI_KEY_VALUE_SEPARATOR);96 QString keyString = keys.join(MULTI_KEY_VALUE_SEPARATOR);
97 97
98 // pack the key string, null terminated98 // pack the key string, null terminated
99 strcpy((char*) getPacket + numPacketBytes, keyString.toLocal8Bit().constData());99 strcpy((char*) getPacket + numPacketBytes, keyString.toLocal8Bit().constData());
100 numPacketBytes += keyString.size() + sizeof('\0');100 numPacketBytes += keyString.size() + sizeof('\0');
101 101
102 // add the getPacket to our vector of uncofirmed packets, will be deleted once we get a response from the nameserver102 // add the getPacket to our vector of uncofirmed packets, will be deleted once we get a response from the nameserver
103 // _unmatchedPackets.insert(std::pair<unsigned char*, int>(getPacket, numPacketBytes));103 // _unmatchedPackets.insert(std::pair<unsigned char*, int>(getPacket, numPacketBytes));
104 104
105 // send the get to the data server105 // send the get to the data server
106 NodeList::getInstance()->getNodeSocket().writeDatagram((char*) getPacket, numPacketBytes,106 NodeList::getInstance()->getNodeSocket().writeDatagram((char*) getPacket, numPacketBytes,
107 dataServerSockAddr().getAddress(),107 dataServerSockAddr().getAddress(),
@@ -120,25 +120,25 @@ void DataServerClient::processConfirmFromDataServer(unsigned char* packetData, i · 12 unmodified lines
120void DataServerClient::processSendFromDataServer(unsigned char* packetData, int numPacketBytes) {120void DataServerClient::processSendFromDataServer(unsigned char* packetData, int numPacketBytes) {
121 // pull the user string from the packet so we know who to associate this with121 // pull the user string from the packet so we know who to associate this with
122 int numHeaderBytes = numBytesForPacketHeader(packetData);122 int numHeaderBytes = numBytesForPacketHeader(packetData);
123 123
124 char* userStringPosition = (char*) packetData + numHeaderBytes;124 char* userStringPosition = (char*) packetData + numHeaderBytes;
125 125
126 QString userString(QByteArray(userStringPosition, strlen(userStringPosition)));126 QString userString(QByteArray(userStringPosition, strlen(userStringPosition)));
127 127
128 QUuid userUUID(userString);128 QUuid userUUID(userString);
129 129
130 char* keysPosition = (char*) packetData + numHeaderBytes + strlen(userStringPosition)130 char* keysPosition = (char*) packetData + numHeaderBytes + strlen(userStringPosition)
131 + sizeof('\0') + sizeof(unsigned char);131 + sizeof('\0') + sizeof(unsigned char);
132 char* valuesPosition = keysPosition + strlen(keysPosition) + sizeof('\0');132 char* valuesPosition = keysPosition + strlen(keysPosition) + sizeof('\0');
133 133
134 QStringList keyList = QString(keysPosition).split(MULTI_KEY_VALUE_SEPARATOR);134 QStringList keyList = QString(keysPosition).split(MULTI_KEY_VALUE_SEPARATOR);
135 QStringList valueList = QString(valuesPosition).split(MULTI_KEY_VALUE_SEPARATOR);135 QStringList valueList = QString(valuesPosition).split(MULTI_KEY_VALUE_SEPARATOR);
136 136
137 // user string was UUID, find matching avatar and associate data137 // 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++) {
139 if (valueList[i] != " ") {139 if (valueList[i] != " ") {
140 if (keyList[i] == DataServerKey::FaceMeshURL) {140 if (keyList[i] == DataServerKey::FaceMeshURL) {
141 141
142 if (userUUID.isNull() || userUUID == Application::getInstance()->getProfile()->getUUID()) {142 if (userUUID.isNull() || userUUID == Application::getInstance()->getProfile()->getUUID()) {
143 qDebug("Changing user's face model URL to %s\n", valueList[i].toLocal8Bit().constData());143 qDebug("Changing user's face model URL to %s\n", valueList[i].toLocal8Bit().constData());
144 Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[i]));144 Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[i]));
@@ -148,7 +148,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 3 unmodified lines
148 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {148 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
149 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {149 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
150 Avatar* avatar = (Avatar *) node->getLinkedData();150 Avatar* avatar = (Avatar *) node->getLinkedData();
151 151
152 if (avatar->getUUID() == userUUID) {152 if (avatar->getUUID() == userUUID) {
153 QMetaObject::invokeMethod(&avatar->getHead().getFaceModel(),153 QMetaObject::invokeMethod(&avatar->getHead().getFaceModel(),
154 "setURL", Q_ARG(QUrl, QUrl(valueList[i])));154 "setURL", Q_ARG(QUrl, QUrl(valueList[i])));
@@ -157,7 +157,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 2 unmodified lines
157 }157 }
158 }158 }
159 } else if (keyList[i] == DataServerKey::SkeletonURL) {159 } else if (keyList[i] == DataServerKey::SkeletonURL) {
160 160
161 if (userUUID.isNull() || userUUID == Application::getInstance()->getProfile()->getUUID()) {161 if (userUUID.isNull() || userUUID == Application::getInstance()->getProfile()->getUUID()) {
162 qDebug("Changing user's skeleton URL to %s\n", valueList[i].toLocal8Bit().constData());162 qDebug("Changing user's skeleton URL to %s\n", valueList[i].toLocal8Bit().constData());
163 Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i]));163 Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i]));
@@ -167,7 +167,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 3 unmodified lines
167 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {167 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
168 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {168 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
169 Avatar* avatar = (Avatar *) node->getLinkedData();169 Avatar* avatar = (Avatar *) node->getLinkedData();
170 170
171 if (avatar->getUUID() == userUUID) {171 if (avatar->getUUID() == userUUID) {
172 QMetaObject::invokeMethod(&avatar->getSkeletonModel(), "setURL",172 QMetaObject::invokeMethod(&avatar->getSkeletonModel(), "setURL",
173 Q_ARG(QUrl, QUrl(valueList[i])));173 Q_ARG(QUrl, QUrl(valueList[i])));
@@ -177,33 +177,33 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 3 unmodified lines
177 }177 }
178 } else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position178 } else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position
179 && valueList[i] != " " && valueList[i + 1] != " ") {179 && valueList[i] != " " && valueList[i + 1] != " ") {
180 180
181 QStringList coordinateItems = valueList[i + 1].split(',');181 QStringList coordinateItems = valueList[i + 1].split(',');
182 182
183 if (coordinateItems.size() == 3) {183 if (coordinateItems.size() == 3) {
184 184
185 // send a node kill request, indicating to other clients that they should play the "disappeared" effect185 // send a node kill request, indicating to other clients that they should play the "disappeared" effect
186 NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);186 NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
187 187
188 qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<188 qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<
189 "and position to" << valueList[i + 1].toLocal8Bit().constData() <<189 "and position to" << valueList[i + 1].toLocal8Bit().constData() <<
190 "to go to" << userString << "\n";190 "to go to" << userString << "\n";
191 191
192 NodeList::getInstance()->setDomainHostname(valueList[i]);192 NodeList::getInstance()->setDomainHostname(valueList[i]);
193 193
194 glm::vec3 newPosition(coordinateItems[0].toFloat(),194 glm::vec3 newPosition(coordinateItems[0].toFloat(),
195 coordinateItems[1].toFloat(),195 coordinateItems[1].toFloat(),
196 coordinateItems[2].toFloat());196 coordinateItems[2].toFloat());
197 Application::getInstance()->getAvatar()->setPosition(newPosition);197 Application::getInstance()->getAvatar()->setPosition(newPosition);
198 }198 }
199 199
200 } else if (keyList[i] == DataServerKey::UUID) {200 } else if (keyList[i] == DataServerKey::UUID) {
201 // this is the user's UUID - set it on the profile201 // this is the user's UUID - set it on the profile
202 Application::getInstance()->getProfile()->setUUID(valueList[i]);202 Application::getInstance()->getProfile()->setUUID(valueList[i]);
203 }203 }
204 }204 }
205 }205 }
206 206
207 // remove the matched packet from our map so it isn't re-sent to the data-server207 // remove the matched packet from our map so it isn't re-sent to the data-server
208 // removeMatchedPacketFromMap(packetData, numPacketBytes);208 // removeMatchedPacketFromMap(packetData, numPacketBytes);
209}209}
@@ -228,12 +228,12 @@ void DataServerClient::removeMatchedPacketFromMap(unsigned char* packetData, int · 18 unmodified lines
228 if (memcmp(mapIterator->first + sizeof(PACKET_TYPE),228 if (memcmp(mapIterator->first + sizeof(PACKET_TYPE),
229 packetData + sizeof(PACKET_TYPE),229 packetData + sizeof(PACKET_TYPE),
230 numPacketBytes - sizeof(PACKET_TYPE)) == 0) {230 numPacketBytes - sizeof(PACKET_TYPE)) == 0) {
231 231
232 // this is a match - remove the confirmed packet from the vector and delete associated member232 // this is a match - remove the confirmed packet from the vector and delete associated member
233 // so it isn't sent back out233 // so it isn't sent back out
234 delete[] mapIterator->first;234 delete[] mapIterator->first;
235 _unmatchedPackets.erase(mapIterator);235 _unmatchedPackets.erase(mapIterator);
236 236
237 // we've matched the packet - bail out237 // we've matched the packet - bail out
238 break;238 break;
239 }239 }