Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
PlayerRestState.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
PlayerRestState.h
"
7
8
#include <cmath>
9
#include <iomanip>
10
#include <sstream>
11
12
namespace
Skyfire
13
{
14
namespace
Rest
15
{
16
namespace
17
{
18
constexpr
double
TwoPi = 6.28318530717958647692;
19
}
20
21
bool
HasInnAreaBounds
(
InnAreaBounds
const
& bounds)
22
{
23
return
bounds.
Radius
> 0.0f || bounds.
BoxX
> 0.0f || bounds.
BoxY
> 0.0f || bounds.
BoxZ
> 0.0f;
24
}
25
26
bool
IsInsideInnArea
(
InnAreaBounds
const
& bounds,
uint32
mapId,
float
x,
float
y,
float
z,
float
padding)
27
{
28
if
(mapId != bounds.
MapId
)
29
return
false
;
30
31
if
(bounds.
Radius
> 0.0f)
32
{
33
float
const
dx = x - bounds.
X
;
34
float
const
dy = y - bounds.
Y
;
35
float
const
dz = z - bounds.
Z
;
36
float
const
distanceSquared = dx * dx + dy * dy + dz * dz;
37
float
const
allowedDistance = bounds.
Radius
+ padding;
38
return
distanceSquared <= allowedDistance * allowedDistance;
39
}
40
41
if
(bounds.
BoxX
<= 0.0f || bounds.
BoxY
<= 0.0f || bounds.
BoxZ
<= 0.0f)
42
return
false
;
43
44
double
const
rotation = TwoPi - bounds.
BoxOrientation
;
45
double
const
sinVal = std::sin(rotation);
46
double
const
cosVal = std::cos(rotation);
47
48
float
const
boxDistX = x - bounds.
X
;
49
float
const
boxDistY = y - bounds.
Y
;
50
51
float
const
rotatedX = float(bounds.
X
+ boxDistX * cosVal - boxDistY * sinVal);
52
float
const
rotatedY = float(bounds.
Y
+ boxDistY * cosVal + boxDistX * sinVal);
53
54
return
std::fabs(rotatedX - bounds.
X
) <= bounds.
BoxX
/ 2.0f + padding &&
55
std::fabs(rotatedY - bounds.
Y
) <= bounds.
BoxY
/ 2.0f + padding &&
56
std::fabs(z - bounds.
Z
) <= bounds.
BoxZ
/ 2.0f + padding;
57
}
58
59
std::string
FormatInnAreaBounds
(
InnAreaBounds
const
& bounds)
60
{
61
std::ostringstream output;
62
output << std::fixed << std::setprecision(2);
63
output <<
"map="
<< bounds.
MapId
64
<<
" center=("
<< bounds.
X
<<
','
<< bounds.
Y
<<
','
<< bounds.
Z
<<
')'
65
<<
" radius="
<< bounds.
Radius
66
<<
" box=("
<< bounds.
BoxX
<<
','
<< bounds.
BoxY
<<
','
<< bounds.
BoxZ
<<
','
<< bounds.
BoxOrientation
<<
')'
;
67
return
output.str();
68
}
69
}
70
}
uint32
std::uint32_t uint32
Definition
Define.h:77
PlayerRestState.h
Skyfire::Rest
Definition
PlayerRestState.cpp:15
Skyfire::Rest::FormatInnAreaBounds
std::string FormatInnAreaBounds(InnAreaBounds const &bounds)
Definition
PlayerRestState.cpp:59
Skyfire::Rest::HasInnAreaBounds
bool HasInnAreaBounds(InnAreaBounds const &bounds)
Definition
PlayerRestState.cpp:21
Skyfire::Rest::IsInsideInnArea
bool IsInsideInnArea(InnAreaBounds const &bounds, uint32 mapId, float x, float y, float z, float padding)
Definition
PlayerRestState.cpp:26
Skyfire
Definition
AuthPatchTransfer.h:12
Skyfire::Rest::InnAreaBounds
Definition
PlayerRestState.h:18
Skyfire::Rest::InnAreaBounds::X
float X
Definition
PlayerRestState.h:20
Skyfire::Rest::InnAreaBounds::BoxZ
float BoxZ
Definition
PlayerRestState.h:26
Skyfire::Rest::InnAreaBounds::BoxY
float BoxY
Definition
PlayerRestState.h:25
Skyfire::Rest::InnAreaBounds::Radius
float Radius
Definition
PlayerRestState.h:23
Skyfire::Rest::InnAreaBounds::MapId
uint32 MapId
Definition
PlayerRestState.h:19
Skyfire::Rest::InnAreaBounds::BoxOrientation
float BoxOrientation
Definition
PlayerRestState.h:27
Skyfire::Rest::InnAreaBounds::BoxX
float BoxX
Definition
PlayerRestState.h:24
Skyfire::Rest::InnAreaBounds::Z
float Z
Definition
PlayerRestState.h:22
Skyfire::Rest::InnAreaBounds::Y
float Y
Definition
PlayerRestState.h:21
src
server
game
Entities
Player
PlayerRestState.cpp
Generated on
for Project SkyFire Core by
1.17.0