diff --git a/libraries/shared/src/NodeList.h b/libraries/shared/src/NodeList.h index 47cdbac99d..8c1972f2e9 100644 --- a/libraries/shared/src/NodeList.h +++ b/libraries/shared/src/NodeList.h @@ -12,7 +12,8 @@ #include #include #include -#include + +//#include // not on windows, not needed for mac or windows #include #include @@ -62,81 +63,81 @@ class NodeList : public QObject { public: static NodeList* createInstance(char ownerType, unsigned short int socketListenPort = 0); static NodeList* getInstance(); - + typedef NodeListIterator iterator; - + NodeListIterator begin() const; NodeListIterator end() const; - + NODE_TYPE getOwnerType() const { return _ownerType; } void setOwnerType(NODE_TYPE ownerType) { _ownerType = ownerType; } const QString& getDomainHostname() const { return _domainHostname; } void setDomainHostname(const QString& domainHostname); - + const QHostAddress& getDomainIP() const { return _domainSockAddr.getAddress(); } void setDomainIPToLocalhost() { _domainSockAddr.setAddress(QHostAddress(INADDR_LOOPBACK)); } - + void setDomainSockAddr(const HifiSockAddr& domainSockAddr) { _domainSockAddr = domainSockAddr; } - + unsigned short getDomainPort() const { return _domainSockAddr.getPort(); } - + const QUuid& getOwnerUUID() const { return _ownerUUID; } void setOwnerUUID(const QUuid& ownerUUID) { _ownerUUID = ownerUUID; } - + QUdpSocket& getNodeSocket() { return _nodeSocket; } - + void(*linkedDataCreateCallback)(Node *); - + int size() { return _numNodes; } int getNumAliveNodes() const; - + int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; } - + void clear(); void reset(); - + void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest); - + int processDomainServerList(unsigned char *packetData, size_t dataBytes); - + void setAssignmentServerSocket(const HifiSockAddr& serverSocket) { _assignmentServerSocket = serverSocket; } void sendAssignment(Assignment& assignment); - + int fillPingPacket(unsigned char* buffer); int fillPingReplyPacket(unsigned char* pingBuffer, unsigned char* replyBuffer); void pingPublicAndLocalSocketsForInactiveNode(Node* node); - + void sendKillNode(const char* nodeTypes, int numNodeTypes); - + Node* nodeWithAddress(const HifiSockAddr& senderSockAddr); Node* nodeWithUUID(const QUuid& nodeUUID); - + Node* addOrUpdateNode(const QUuid& uuid, char nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket); void killNode(Node* node, bool mustLockNode = true); - + void processNodeData(const HifiSockAddr& senderSockAddr, unsigned char *packetData, size_t dataBytes); void processBulkNodeData(const HifiSockAddr& senderSockAddr, unsigned char *packetData, int numTotalBytes); - + int updateNodeWithData(Node *node, const HifiSockAddr& senderSockAddr, unsigned char *packetData, int dataBytes); - + unsigned broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes); - + Node* soloNodeOfType(char nodeType); - + void loadData(QSettings* settings); void saveData(QSettings* settings); - + friend class NodeListIterator; - + void addHook(NodeListHook* hook); void removeHook(NodeListHook* hook); void notifyHooksOfAddedNode(Node* node); void notifyHooksOfKilledNode(Node* node); - + void addDomainListener(DomainChangeListener* listener); void removeDomainListener(DomainChangeListener* listener); - + const HifiSockAddr* getNodeActiveSocketOrPing(Node* node); public slots: void sendDomainServerCheckIn(); @@ -144,19 +145,19 @@ public slots: void removeSilentNodes(); private: static NodeList* _sharedInstance; - + NodeList(char ownerType, unsigned short int socketListenPort); ~NodeList(); NodeList(NodeList const&); // Don't implement, needed to avoid copies of singleton void operator=(NodeList const&); // Don't implement, needed to avoid copies of singleton - + void addNodeToList(Node* newNode); - + void sendSTUNRequest(); void processSTUNResponse(unsigned char* packetData, size_t dataBytes); - + void processKillNode(unsigned char* packetData, size_t dataBytes); - + QString _domainHostname; HifiSockAddr _domainSockAddr; Node** _nodeBuckets[MAX_NUM_NODES / NODES_PER_BUCKET]; @@ -170,13 +171,13 @@ private: HifiSockAddr _publicSockAddr; bool _hasCompletedInitialSTUNFailure; unsigned int _stunRequestsSinceSuccess; - + void activateSocketFromNodeCommunication(const HifiSockAddr& nodeSockAddr); void timePingReply(const HifiSockAddr& nodeAddress, unsigned char *packetData); - + std::vector _hooks; std::vector _domainListeners; - + void resetDomainData(char domainField[], const char* domainData); void notifyDomainChanged(); void domainLookup(); @@ -185,22 +186,22 @@ private: class NodeListIterator : public std::iterator { public: NodeListIterator(const NodeList* nodeList, int nodeIndex); - + int getNodeIndex() { return _nodeIndex; } - + NodeListIterator& operator=(const NodeListIterator& otherValue); - + bool operator==(const NodeListIterator& otherValue); bool operator!= (const NodeListIterator& otherValue); - + Node& operator*(); Node* operator->(); - + NodeListIterator& operator++(); NodeListIterator operator++(int); private: void skipDeadAndStopIncrement(); - + const NodeList* _nodeList; int _nodeIndex; }; diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index df04475eba..d86ed4f244 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -11,7 +11,8 @@ #include #include -#include + +//#include // not on windows, not needed for mac or windows #include #include @@ -46,8 +47,8 @@ static const float PIE = 3.141592f; static const float PI_TIMES_TWO = 3.141592f * 2.0f; static const float PI_OVER_180 = 3.141592f / 180.0f; static const float EPSILON = 0.000001f; //smallish positive number - used as margin of error for some computations -static const float SQUARE_ROOT_OF_2 = (float)sqrt(2); -static const float SQUARE_ROOT_OF_3 = (float)sqrt(3); +static const float SQUARE_ROOT_OF_2 = (float)sqrt(2.f); +static const float SQUARE_ROOT_OF_3 = (float)sqrt(3.f); static const float METER = 1.0f; static const float DECIMETER = 0.1f; static const float CENTIMETER = 0.01f; @@ -105,29 +106,29 @@ unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r unsigned char* pointToOctalCode(float x, float y, float z, float s); // Creates a full Voxel edit message, including command header, sequence, and details -bool createVoxelEditMessage(unsigned char command, short int sequence, +bool createVoxelEditMessage(unsigned char command, short int sequence, int voxelCount, VoxelDetail* voxelDetails, unsigned char*& bufferOut, int& sizeOut); /// encodes the voxel details portion of a voxel edit message -bool encodeVoxelEditMessageDetails(unsigned char command, int voxelCount, VoxelDetail* voxelDetails, +bool encodeVoxelEditMessageDetails(unsigned char command, int voxelCount, VoxelDetail* voxelDetails, unsigned char* bufferOut, int sizeIn, int& sizeOut); #ifdef _WIN32 void usleep(int waitTime); #endif -int insertIntoSortedArrays(void* value, float key, int originalIndex, - void** valueArray, float* keyArray, int* originalIndexArray, +int insertIntoSortedArrays(void* value, float key, int originalIndex, + void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount); -int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int* originalIndexArray, +int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount); // Helper Class for debugging class debug { -public: +public: static const char* valueOf(bool checkValue) { return checkValue ? "yes" : "no"; } static void setDeadBeef(void* memoryVoid, int size); static void checkDeadBeef(void* memoryVoid, int size); @@ -146,7 +147,7 @@ bool isBetween(int64_t value, int64_t max, int64_t min); int packFloatAngleToTwoByte(unsigned char* buffer, float angle); int unpackFloatAngleFromTwoByte(uint16_t* byteAnglePointer, float* destinationPointer); -// Orientation Quats are known to have 4 normalized components be between -1.0 and 1.0 +// Orientation Quats are known to have 4 normalized components be between -1.0 and 1.0 // this allows us to encode each component in 16bits with great accuracy int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput); int unpackOrientationQuatFromBytes(unsigned char* buffer, glm::quat& quatOutput); diff --git a/libraries/shared/src/Systime.h b/libraries/shared/src/Systime.h index 7c59785750..cab5137ce4 100644 --- a/libraries/shared/src/Systime.h +++ b/libraries/shared/src/Systime.h @@ -2,19 +2,24 @@ #define __Systime__ #ifdef _WIN32 + #ifdef _WINSOCK2API_ #define _timeval_ #endif + #ifndef _timeval_ #define _timeval_ /* * Structure returned by gettimeofday(2) system call, * and used in other calls. */ + +#if 0 // not needed for VC2010 struct timeval { long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ }; +#endif #endif _timeval_