summaryrefslogtreecommitdiff
path: root/indra/newview/llpathfindingnavmeshstatus.cpp
blob: 4bb0bc5a18a5cb46138c361525322ff98f052260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/** 
* @file llpathfindingnavmeshstatus.cpp
* @brief Implementation of llpathfindingnavmeshstatus
* @author Stinson@lindenlab.com
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
* $/LicenseInfo$
*/


#include "llviewerprecompiledheaders.h"

#include "llpathfindingnavmeshstatus.h"

#include <string>

#include "llsd.h"
#include "lluuid.h"
#include "llstring.h"

#define REGION_FIELD  "region_id"
#define STATUS_FIELD  "status"
#define VERSION_FIELD "version"

const std::string LLPathfindingNavMeshStatus::sStatusPending("pending");
const std::string LLPathfindingNavMeshStatus::sStatusBuilding("building");
const std::string LLPathfindingNavMeshStatus::sStatusComplete("complete");
const std::string LLPathfindingNavMeshStatus::sStatusRepending("repending");


//---------------------------------------------------------------------------
// LLPathfindingNavMeshStatus
//---------------------------------------------------------------------------

LLPathfindingNavMeshStatus::LLPathfindingNavMeshStatus()
	: mIsValid(false),
	mRegionUUID(),
	mVersion(0U),
	mStatus(kComplete)
{
}

LLPathfindingNavMeshStatus::LLPathfindingNavMeshStatus(const LLUUID &pRegionUUID)
	: mIsValid(false),
	mRegionUUID(pRegionUUID),
	mVersion(0U),
	mStatus(kComplete)
{
}

LLPathfindingNavMeshStatus::LLPathfindingNavMeshStatus(const LLUUID &pRegionUUID, const LLSD &pContent)
	: mIsValid(true),
	mRegionUUID(pRegionUUID),
	mVersion(0U),
	mStatus(kComplete)
{
	parseStatus(pContent);
}

LLPathfindingNavMeshStatus::LLPathfindingNavMeshStatus(const LLSD &pContent)
	: mIsValid(true),
	mRegionUUID(),
	mVersion(0U),
	mStatus(kComplete)
{
	llassert(pContent.has(REGION_FIELD));
	llassert(pContent.get(REGION_FIELD).isUUID());
	mRegionUUID = pContent.get(REGION_FIELD).asUUID();

	parseStatus(pContent);
}

LLPathfindingNavMeshStatus::LLPathfindingNavMeshStatus(const LLPathfindingNavMeshStatus &pOther)
	: mIsValid(pOther.mIsValid),
	mRegionUUID(pOther.mRegionUUID),
	mVersion(pOther.mVersion),
	mStatus(pOther.mStatus)
{
}

LLPathfindingNavMeshStatus::~LLPathfindingNavMeshStatus()
{
}

LLPathfindingNavMeshStatus &LLPathfindingNavMeshStatus::operator =(const LLPathfindingNavMeshStatus &pOther)
{
	mIsValid = pOther.mIsValid;
	mRegionUUID = pOther.mRegionUUID;
	mVersion = pOther.mVersion;
	mStatus = pOther.mStatus;

	return *this;
}

void LLPathfindingNavMeshStatus::parseStatus(const LLSD &pContent)
{
	llassert(pContent.has(VERSION_FIELD));
	llassert(pContent.get(VERSION_FIELD).isInteger());
	llassert(pContent.get(VERSION_FIELD).asInteger() >= 0);
	mVersion = static_cast<U32>(pContent.get(VERSION_FIELD).asInteger());

	llassert(pContent.has(STATUS_FIELD));
	llassert(pContent.get(STATUS_FIELD).isString());
	std::string status = pContent.get(STATUS_FIELD).asString();

	if (LLStringUtil::compareStrings(status, sStatusPending) == 0)
	{
		mStatus = kPending;
	}
	else if (LLStringUtil::compareStrings(status, sStatusBuilding) == 0)
	{
		mStatus = kBuilding;
	}
	else if (LLStringUtil::compareStrings(status, sStatusComplete) == 0)
	{
		mStatus = kComplete;
	}
	else if (LLStringUtil::compareStrings(status, sStatusRepending) == 0)
	{
		mStatus = kRepending;
	}
	else
	{
		mStatus = kComplete;
		llassert(0);
	}
}