Skip to content

Commit d6905a9

Browse files
committed
Added some documentation to movement and fixed some warnings
1 parent 7eef6f9 commit d6905a9

13 files changed

+783
-697
lines changed

src/game/movement/MoveSpline.cpp

+56
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ namespace Movement
3333
extern float computeFallElevation(float time_passed, bool isSafeFall, float start_velocy);
3434
extern float computeFallElevation(float time_passed);
3535

36+
/**
37+
* @brief Computes the current position on the spline.
38+
* @return The computed location.
39+
*/
3640
Location MoveSpline::ComputePosition() const
3741
{
3842
MANGOS_ASSERT(Initialized());
@@ -72,6 +76,10 @@ namespace Movement
7276
return c;
7377
}
7478

79+
/**
80+
* @brief Computes the elevation during a fall.
81+
* @param el The elevation to be computed.
82+
*/
7583
void MoveSpline::computeFallElevation(float& el) const
7684
{
7785
float z_now = spline.getPoint(spline.first()).z - Movement::computeFallElevation(MSToSec(time_passed));
@@ -86,11 +94,20 @@ namespace Movement
8694
}
8795
}
8896

97+
/**
98+
* @brief Computes the duration of the movement.
99+
* @param length The length of the path.
100+
* @param velocity The velocity of the movement.
101+
* @return The computed duration in milliseconds.
102+
*/
89103
inline uint32 computeDuration(float length, float velocity)
90104
{
91105
return SecToMS(length / velocity);
92106
}
93107

108+
/**
109+
* @brief Struct for initializing fall parameters.
110+
*/
94111
struct FallInitializer
95112
{
96113
FallInitializer(float _start_elevation) : start_elevation(_start_elevation) {}
@@ -106,6 +123,9 @@ namespace Movement
106123
minimal_duration = 1,
107124
};
108125

126+
/**
127+
* @brief Struct for initializing common parameters.
128+
*/
109129
struct CommonInitializer
110130
{
111131
CommonInitializer(float _velocity) : velocityInv(1000.f / _velocity), time(minimal_duration) {}
@@ -118,6 +138,10 @@ namespace Movement
118138
}
119139
};
120140

141+
/**
142+
* @brief Initializes the spline with the given arguments.
143+
* @param args The initialization arguments.
144+
*/
121145
void MoveSpline::init_spline(const MoveSplineInitArgs& args)
122146
{
123147
const SplineBase::EvaluationMode modes[2] = {SplineBase::ModeLinear, SplineBase::ModeCatmullrom};
@@ -155,6 +179,10 @@ namespace Movement
155179
point_Idx = spline.first();
156180
}
157181

182+
/**
183+
* @brief Initializes the MoveSpline with the given arguments.
184+
* @param args The initialization arguments.
185+
*/
158186
void MoveSpline::Initialize(const MoveSplineInitArgs& args)
159187
{
160188
splineflags = args.flags;
@@ -173,13 +201,21 @@ namespace Movement
173201
init_spline(args);
174202
}
175203

204+
/**
205+
* @brief Default constructor for MoveSpline.
206+
*/
176207
MoveSpline::MoveSpline() : m_Id(0), time_passed(0), point_Idx(0), point_Idx_offset(0)
177208
{
178209
splineflags.done = true;
179210
}
180211

181212
/// ============================================================================================
182213

214+
/**
215+
* @brief Validates the MoveSpline initialization arguments.
216+
* @param unit The unit to validate against.
217+
* @return True if the arguments are valid, false otherwise.
218+
*/
183219
bool MoveSplineInitArgs::Validate(Unit* unit) const
184220
{
185221
#define CHECK(exp) \
@@ -197,6 +233,10 @@ namespace Movement
197233

198234
// MONSTER_MOVE packet format limitation for not CatmullRom movement:
199235
// each vertex offset packed into 11 bytes
236+
/**
237+
* @brief Checks the bounds of the path for non-CatmullRom movement.
238+
* @return True if the path bounds are valid, false otherwise.
239+
*/
200240
bool MoveSplineInitArgs::_checkPathBounds() const
201241
{
202242
if (!(flags & MoveSplineFlag::Mask_CatmullRom) && path.size() > 2)
@@ -222,6 +262,11 @@ namespace Movement
222262

223263
/// ============================================================================================
224264

265+
/**
266+
* @brief Updates the state of the MoveSpline.
267+
* @param ms_time_diff The time difference in milliseconds.
268+
* @return The result of the update.
269+
*/
225270
MoveSpline::UpdateResult MoveSpline::_updateState(int32& ms_time_diff)
226271
{
227272
if (Finalized())
@@ -264,6 +309,10 @@ namespace Movement
264309
return result;
265310
}
266311

312+
/**
313+
* @brief Converts the MoveSpline to a string representation.
314+
* @return The string representation of the MoveSpline.
315+
*/
267316
std::string MoveSpline::ToString() const
268317
{
269318
std::stringstream str;
@@ -291,13 +340,20 @@ namespace Movement
291340
return str.str();
292341
}
293342

343+
/**
344+
* @brief Finalizes the MoveSpline.
345+
*/
294346
void MoveSpline::_Finalize()
295347
{
296348
splineflags.done = true;
297349
point_Idx = spline.last() - 1;
298350
time_passed = Duration();
299351
}
300352

353+
/**
354+
* @brief Gets the current path index.
355+
* @return The current path index.
356+
*/
301357
int32 MoveSpline::currentPathIdx() const
302358
{
303359
int32 point = point_Idx_offset + point_Idx - spline.first() + (int)Finalized();

0 commit comments

Comments
 (0)