Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
GameObjectTransportTiming.h
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
#ifndef SKYFIRESERVER_GAMEOBJECT_TRANSPORT_TIMING_H
7
#define SKYFIRESERVER_GAMEOBJECT_TRANSPORT_TIMING_H
8
9
#include "
Define.h
"
10
#include "
SharedDefines.h
"
11
12
namespace
Skyfire
13
{
14
namespace
GameObjects
15
{
16
inline
bool
UsesControlledTransportProgress
(
uint32
gameObjectType,
uint32
transportPeriod)
17
{
18
return
gameObjectType ==
GAMEOBJECT_TYPE_MO_TRANSPORT
||
19
(gameObjectType ==
GAMEOBJECT_TYPE_TRANSPORT
&& transportPeriod != 0);
20
}
21
22
inline
uint32
GetLegacyTransportEndpoint
(
uint32
transportPeriod)
23
{
24
return
transportPeriod ? transportPeriod - 1 : 0;
25
}
26
27
inline
uint32
ClampLegacyTransportPathProgress
(
uint32
pathProgress,
uint32
transportPeriod)
28
{
29
if
(!transportPeriod)
30
return
pathProgress;
31
32
uint32
const
endpoint =
GetLegacyTransportEndpoint
(transportPeriod);
33
return
pathProgress > endpoint ? endpoint : pathProgress;
34
}
35
36
inline
uint32
WrapTransportPathProgress
(
uint32
pathProgress,
uint32
transportPeriod)
37
{
38
return
transportPeriod ? pathProgress % transportPeriod : pathProgress;
39
}
40
41
inline
uint32
AdvanceTransportPathProgress
(
uint32
pathProgress,
uint32
diff,
uint32
transportPeriod)
42
{
43
if
(!transportPeriod)
44
return
pathProgress + diff;
45
46
uint32
const
endpoint =
GetLegacyTransportEndpoint
(transportPeriod);
47
if
(pathProgress >= endpoint || diff >= endpoint - pathProgress)
48
return
endpoint;
49
50
return
pathProgress + diff;
51
}
52
53
inline
uint32
GetLegacyTransportTravelTime
(
uint32
sourceProgress,
uint32
targetProgress,
uint32
transportPeriod)
54
{
55
if
(!transportPeriod)
56
return
targetProgress >= sourceProgress ? targetProgress - sourceProgress : sourceProgress - targetProgress;
57
58
if
(targetProgress >= sourceProgress)
59
return
targetProgress - sourceProgress;
60
61
return
transportPeriod - sourceProgress + targetProgress;
62
}
63
64
inline
uint32
GetLegacyTransportTransitionTime
(
uint32
sourceProgress,
uint32
targetProgress)
65
{
66
return
targetProgress >= sourceProgress ? targetProgress - sourceProgress : sourceProgress - targetProgress;
67
}
68
69
inline
uint32
GetLegacyTransportReverseTravelTime
(
uint32
sourceProgress,
uint32
targetProgress,
uint32
transportPeriod)
70
{
71
if
(!transportPeriod)
72
return
GetLegacyTransportTransitionTime
(sourceProgress, targetProgress);
73
74
if
(sourceProgress >= targetProgress)
75
return
sourceProgress - targetProgress;
76
77
return
sourceProgress + transportPeriod - targetProgress;
78
}
79
80
inline
uint32
SetLegacyTransportStoppedFlag
(
uint32
dynamicFlags,
bool
stopped)
81
{
82
if
(stopped)
83
return
dynamicFlags |
uint32
(
GO_DYNFLAG_LO_STOPPED
);
84
85
return
dynamicFlags &
~uint32
(
GO_DYNFLAG_LO_STOPPED
);
86
}
87
88
inline
uint32
GetInitialLegacyTransportState
(
bool
/*startOpen*/
,
bool
hasStopFrames)
89
{
90
if
(hasStopFrames)
91
return
25;
92
93
return
24;
94
}
95
96
inline
uint32
InterpolateLegacyTransportPathProgress
(
uint32
sourceProgress,
uint32
targetProgress,
uint32
transportPeriod,
uint32
elapsedTime,
uint32
travelTime,
bool
invertedMovement =
false
)
97
{
98
if
(!travelTime || elapsedTime >= travelTime)
99
return
targetProgress;
100
101
uint32
const
distance = invertedMovement ?
102
GetLegacyTransportReverseTravelTime
(sourceProgress, targetProgress, transportPeriod) :
103
GetLegacyTransportTravelTime
(sourceProgress, targetProgress, transportPeriod);
104
uint32
const
advanced =
uint32
((
uint64
(distance) *
uint64
(elapsedTime)) /
uint64
(travelTime));
105
106
if
(invertedMovement)
107
return
WrapTransportPathProgress
(sourceProgress + transportPeriod - advanced, transportPeriod);
108
109
return
WrapTransportPathProgress
(sourceProgress + advanced, transportPeriod);
110
}
111
112
inline
uint32
GetInitialLegacyTransportPathProgress
(
bool
hasStopFrames,
uint32
transportPeriod,
uint32
now)
113
{
114
return
hasStopFrames ? 0 :
WrapTransportPathProgress
(now, transportPeriod);
115
}
116
117
inline
uint32
GetTransportDynamicPathProgress
(
uint32
gameObjectType,
uint32
transportPeriod,
uint32
pathProgress)
118
{
119
if
(gameObjectType ==
GAMEOBJECT_TYPE_TRANSPORT
)
120
return
ClampLegacyTransportPathProgress
(pathProgress, transportPeriod);
121
122
if
(gameObjectType ==
GAMEOBJECT_TYPE_MO_TRANSPORT
)
123
return
WrapTransportPathProgress
(pathProgress, transportPeriod);
124
125
return
pathProgress;
126
}
127
128
}
129
}
130
131
#endif
Define.h
uint32
std::uint32_t uint32
Definition
Define.h:77
uint64
std::uint64_t uint64
Definition
Define.h:76
SharedDefines.h
GAMEOBJECT_TYPE_MO_TRANSPORT
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition
SharedDefines.h:1810
GAMEOBJECT_TYPE_TRANSPORT
@ GAMEOBJECT_TYPE_TRANSPORT
Definition
SharedDefines.h:1806
GO_DYNFLAG_LO_STOPPED
@ GO_DYNFLAG_LO_STOPPED
Definition
SharedDefines.h:1857
Skyfire::GameObjects
Definition
GameObjectTransportTiming.h:15
Skyfire::GameObjects::GetLegacyTransportReverseTravelTime
uint32 GetLegacyTransportReverseTravelTime(uint32 sourceProgress, uint32 targetProgress, uint32 transportPeriod)
Definition
GameObjectTransportTiming.h:69
Skyfire::GameObjects::GetLegacyTransportEndpoint
uint32 GetLegacyTransportEndpoint(uint32 transportPeriod)
Definition
GameObjectTransportTiming.h:22
Skyfire::GameObjects::AdvanceTransportPathProgress
uint32 AdvanceTransportPathProgress(uint32 pathProgress, uint32 diff, uint32 transportPeriod)
Definition
GameObjectTransportTiming.h:41
Skyfire::GameObjects::GetLegacyTransportTransitionTime
uint32 GetLegacyTransportTransitionTime(uint32 sourceProgress, uint32 targetProgress)
Definition
GameObjectTransportTiming.h:64
Skyfire::GameObjects::GetTransportDynamicPathProgress
uint32 GetTransportDynamicPathProgress(uint32 gameObjectType, uint32 transportPeriod, uint32 pathProgress)
Definition
GameObjectTransportTiming.h:117
Skyfire::GameObjects::InterpolateLegacyTransportPathProgress
uint32 InterpolateLegacyTransportPathProgress(uint32 sourceProgress, uint32 targetProgress, uint32 transportPeriod, uint32 elapsedTime, uint32 travelTime, bool invertedMovement=false)
Definition
GameObjectTransportTiming.h:96
Skyfire::GameObjects::ClampLegacyTransportPathProgress
uint32 ClampLegacyTransportPathProgress(uint32 pathProgress, uint32 transportPeriod)
Definition
GameObjectTransportTiming.h:27
Skyfire::GameObjects::GetInitialLegacyTransportPathProgress
uint32 GetInitialLegacyTransportPathProgress(bool hasStopFrames, uint32 transportPeriod, uint32 now)
Definition
GameObjectTransportTiming.h:112
Skyfire::GameObjects::SetLegacyTransportStoppedFlag
uint32 SetLegacyTransportStoppedFlag(uint32 dynamicFlags, bool stopped)
Definition
GameObjectTransportTiming.h:80
Skyfire::GameObjects::GetInitialLegacyTransportState
uint32 GetInitialLegacyTransportState(bool, bool hasStopFrames)
Definition
GameObjectTransportTiming.h:88
Skyfire::GameObjects::UsesControlledTransportProgress
bool UsesControlledTransportProgress(uint32 gameObjectType, uint32 transportPeriod)
Definition
GameObjectTransportTiming.h:16
Skyfire::GameObjects::WrapTransportPathProgress
uint32 WrapTransportPathProgress(uint32 pathProgress, uint32 transportPeriod)
Definition
GameObjectTransportTiming.h:36
Skyfire::GameObjects::GetLegacyTransportTravelTime
uint32 GetLegacyTransportTravelTime(uint32 sourceProgress, uint32 targetProgress, uint32 transportPeriod)
Definition
GameObjectTransportTiming.h:53
Skyfire
Definition
AuthPatchTransfer.h:12
src
server
game
Entities
GameObject
GameObjectTransportTiming.h
Generated on
for Project SkyFire Core by
1.17.0