| 1322 | |
| 1323 | |
| 1324 | bool PhysicsDirect::processCustomCommand(const struct SharedMemoryCommand& orgCommand) |
| 1325 | { |
| 1326 | SharedMemoryCommand command = orgCommand; |
| 1327 | |
| 1328 | const SharedMemoryStatus& serverCmd = m_data->m_serverStatus; |
| 1329 | |
| 1330 | int remaining = 0; |
| 1331 | do |
| 1332 | { |
| 1333 | bool hasStatus = m_data->m_commandProcessor->processCommand(command, m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE); |
| 1334 | |
| 1335 | b3Clock clock; |
| 1336 | double startTime = clock.getTimeInSeconds(); |
| 1337 | double timeOutInSeconds = m_data->m_timeOutInSeconds; |
| 1338 | |
| 1339 | while ((!hasStatus) && (clock.getTimeInSeconds() - startTime < timeOutInSeconds)) |
| 1340 | { |
| 1341 | const SharedMemoryStatus* stat = processServerStatus(); |
| 1342 | if (stat) |
| 1343 | { |
| 1344 | hasStatus = true; |
| 1345 | } |
| 1346 | } |
| 1347 | |
| 1348 | m_data->m_hasStatus = hasStatus; |
| 1349 | |
| 1350 | if (hasStatus) |
| 1351 | { |
| 1352 | |
| 1353 | if (m_data->m_verboseOutput) |
| 1354 | { |
| 1355 | b3Printf("Success receiving %d return data\n", |
| 1356 | serverCmd.m_numDataStreamBytes); |
| 1357 | } |
| 1358 | |
| 1359 | |
| 1360 | btAssert(m_data->m_serverStatus.m_type == CMD_CUSTOM_COMMAND_COMPLETED); |
| 1361 | |
| 1362 | if (m_data->m_serverStatus.m_type == CMD_CUSTOM_COMMAND_COMPLETED) |
| 1363 | { |
| 1364 | m_data->m_cachedReturnData.resize(serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes); |
| 1365 | m_data->m_cachedReturnDataValue.m_length = serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes; |
| 1366 | |
| 1367 | if (serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes) |
| 1368 | { |
| 1369 | m_data->m_cachedReturnDataValue.m_type = serverCmd.m_customCommandResultArgs.m_returnDataType; |
| 1370 | m_data->m_cachedReturnDataValue.m_data1 = &m_data->m_cachedReturnData[0]; |
| 1371 | for (int i = 0; i < serverCmd.m_numDataStreamBytes; i++) |
| 1372 | { |
| 1373 | m_data->m_cachedReturnData[i+ serverCmd.m_customCommandResultArgs.m_returnDataStart] = m_data->m_bulletStreamDataServerToClient[i]; |
| 1374 | } |
| 1375 | } |
| 1376 | int totalReceived = serverCmd.m_numDataStreamBytes + serverCmd.m_customCommandResultArgs.m_returnDataStart; |
| 1377 | remaining = serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes - totalReceived; |
| 1378 | |
| 1379 | if (remaining > 0) |
| 1380 | { |
| 1381 | m_data->m_hasStatus = false; |
nothing calls this directly
no test coverage detected