Recast Navigation
Navigation-mesh Toolset for Games
DetourStatus.h
Go to the documentation of this file.
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 
19 #ifndef DETOURSTATUS_H
20 #define DETOURSTATUS_H
21 
22 typedef unsigned int dtStatus;
23 
24 // High level status.
25 static const unsigned int DT_FAILURE = 1u << 31; // Operation failed.
26 static const unsigned int DT_SUCCESS = 1u << 30; // Operation succeed.
27 static const unsigned int DT_IN_PROGRESS = 1u << 29; // Operation still in progress.
28 
29 // Detail information for status.
30 static const unsigned int DT_STATUS_DETAIL_MASK = 0x0ffffff;
31 static const unsigned int DT_WRONG_MAGIC = 1 << 0; // Input data is not recognized.
32 static const unsigned int DT_WRONG_VERSION = 1 << 1; // Input data is in wrong version.
33 static const unsigned int DT_OUT_OF_MEMORY = 1 << 2; // Operation ran out of memory.
34 static const unsigned int DT_INVALID_PARAM = 1 << 3; // An input parameter was invalid.
35 static const unsigned int DT_BUFFER_TOO_SMALL = 1 << 4; // Result buffer for the query was too small to store all results.
36 static const unsigned int DT_OUT_OF_NODES = 1 << 5; // Query ran out of nodes during search.
37 static const unsigned int DT_PARTIAL_RESULT = 1 << 6; // Query did not reach the end location, returning best guess.
38 static const unsigned int DT_ALREADY_OCCUPIED = 1 << 7; // A tile has already been assigned to the given x,y coordinate
39 
40 
41 // Returns true of status is success.
42 inline bool dtStatusSucceed(dtStatus status)
43 {
44  return (status & DT_SUCCESS) != 0;
45 }
46 
47 // Returns true of status is failure.
48 inline bool dtStatusFailed(dtStatus status)
49 {
50  return (status & DT_FAILURE) != 0;
51 }
52 
53 // Returns true of status is in progress.
54 inline bool dtStatusInProgress(dtStatus status)
55 {
56  return (status & DT_IN_PROGRESS) != 0;
57 }
58 
59 // Returns true if specific detail is set.
60 inline bool dtStatusDetail(dtStatus status, unsigned int detail)
61 {
62  return (status & detail) != 0;
63 }
64 
65 #endif // DETOURSTATUS_H
static const unsigned int DT_OUT_OF_NODES
Definition: DetourStatus.h:36
static const unsigned int DT_ALREADY_OCCUPIED
Definition: DetourStatus.h:38
bool dtStatusDetail(dtStatus status, unsigned int detail)
Definition: DetourStatus.h:60
static const unsigned int DT_OUT_OF_MEMORY
Definition: DetourStatus.h:33
unsigned int dtStatus
Definition: DetourStatus.h:22
static const unsigned int DT_WRONG_VERSION
Definition: DetourStatus.h:32
static const unsigned int DT_PARTIAL_RESULT
Definition: DetourStatus.h:37
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
static const unsigned int DT_BUFFER_TOO_SMALL
Definition: DetourStatus.h:35
static const unsigned int DT_STATUS_DETAIL_MASK
Definition: DetourStatus.h:30
bool dtStatusInProgress(dtStatus status)
Definition: DetourStatus.h:54
bool dtStatusSucceed(dtStatus status)
Definition: DetourStatus.h:42
static const unsigned int DT_IN_PROGRESS
Definition: DetourStatus.h:27
bool dtStatusFailed(dtStatus status)
Definition: DetourStatus.h:48
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
static const unsigned int DT_WRONG_MAGIC
Definition: DetourStatus.h:31
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25