DetourStatus.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
  3. //
  4. // This software is provided 'as-is', without any express or implied
  5. // warranty. In no event will the authors be held liable for any damages
  6. // arising from the use of this software.
  7. // Permission is granted to anyone to use this software for any purpose,
  8. // including commercial applications, and to alter it and redistribute it
  9. // freely, subject to the following restrictions:
  10. // 1. The origin of this software must not be misrepresented; you must not
  11. // claim that you wrote the original software. If you use this software
  12. // in a product, an acknowledgment in the product documentation would be
  13. // appreciated but is not required.
  14. // 2. Altered source versions must be plainly marked as such, and must not be
  15. // misrepresented as being the original software.
  16. // 3. This notice may not be removed or altered from any source distribution.
  17. //
  18. #ifndef DETOURSTATUS_H
  19. #define DETOURSTATUS_H
  20. typedef unsigned int dtStatus;
  21. // High level status.
  22. static const unsigned int DT_FAILURE = 1u << 31; // Operation failed.
  23. static const unsigned int DT_SUCCESS = 1u << 30; // Operation succeed.
  24. static const unsigned int DT_IN_PROGRESS = 1u << 29; // Operation still in progress.
  25. // Detail information for status.
  26. static const unsigned int DT_STATUS_DETAIL_MASK = 0x0ffffff;
  27. static const unsigned int DT_WRONG_MAGIC = 1 << 0; // Input data is not recognized.
  28. static const unsigned int DT_WRONG_VERSION = 1 << 1; // Input data is in wrong version.
  29. static const unsigned int DT_OUT_OF_MEMORY = 1 << 2; // Operation ran out of memory.
  30. static const unsigned int DT_INVALID_PARAM = 1 << 3; // An input parameter was invalid.
  31. static const unsigned int DT_BUFFER_TOO_SMALL = 1 << 4; // Result buffer for the query was too small to store all results.
  32. static const unsigned int DT_OUT_OF_NODES = 1 << 5; // Query ran out of nodes during search.
  33. static const unsigned int DT_PARTIAL_RESULT = 1 << 6; // Query did not reach the end location, returning best guess.
  34. static const unsigned int DT_ALREADY_OCCUPIED = 1 << 7; // A tile has already been assigned to the given x,y coordinate
  35. // Returns true of status is success.
  36. inline bool dtStatusSucceed(dtStatus status)
  37. {
  38. return (status & DT_SUCCESS) != 0;
  39. }
  40. // Returns true of status is failure.
  41. inline bool dtStatusFailed(dtStatus status)
  42. {
  43. return (status & DT_FAILURE) != 0;
  44. }
  45. // Returns true of status is in progress.
  46. inline bool dtStatusInProgress(dtStatus status)
  47. {
  48. return (status & DT_IN_PROGRESS) != 0;
  49. }
  50. // Returns true if specific detail is set.
  51. inline bool dtStatusDetail(dtStatus status, unsigned int detail)
  52. {
  53. return (status & detail) != 0;
  54. }
  55. #endif // DETOURSTATUS_H