1#include <game/bases/d_wm_en_path.hpp>
2#include <lib/MSL_C/string.h>
4dWmEnPath_c::dWmEnPath_c() : mpCurrentPoint(nullptr) {
5 for (
int i = 0; i < ARRAY_SIZE(mPoints); i++) {
6 mPoints[i].mpName =
nullptr;
7 mPoints[i].mPointIndex = -1;
8 mPoints[i].mIndex = -1;
9 mPoints[i].mpPrev =
nullptr;
10 mPoints[i].mpNext =
nullptr;
15dWmEnPath_c::~dWmEnPath_c() {}
18 for (
int i = 0; i < count; i++) {
19 mPoints[i].mpName = names[i];
20 mPoints[i].mIndex = i;
23 mPoints[i].mpPrev = &mPoints[count - 1];
25 mPoints[i].mpPrev =
nullptr;
28 mPoints[i].mpPrev = &mPoints[i - 1];
32 mPoints[i].mpNext = &mPoints[0];
34 mPoints[i].mpNext =
nullptr;
37 mPoints[i].mpNext = &mPoints[i + 1];
41 if (strcmp(names[i], connect->GetPointFromIndex(pointIdx)->name) == 0) {
42 mPoints[i].mPointIndex = pointIdx;
54void dWmEnPath_c::SetStartPoint(
int i) {
55 mpCurrentPoint = &mPoints[i];
58int dWmEnPath_c::GetNextPointIdx() {
59 return GetNextPointInfo(
false)->mPointIndex;
62int dWmEnPath_c::GetPathPointNo(
const char *name) {
63 for (
int i = 0; i < (int) ARRAY_SIZE(mPoints); i++) {
64 if (strcmp(mPoints[i].mpName, name) == 0) {
67 if (mPoints[i].mpNext ==
nullptr) {
74dWmPathPoint_s *dWmEnPath_c::GetNextPointInfo(
bool updateDirection) {
76 return mpCurrentPoint;
78 dWmPathPoint_s *res =
nullptr;
79 if (mDir1 == PATH_DIR_NORMAL) {
80 res = mpCurrentPoint->mpNext;
82 res = mpCurrentPoint->mpPrev;
83 if (updateDirection) {
84 mDir1 = PATH_DIR_REVERSE;
87 }
else if (mDir1 == PATH_DIR_REVERSE) {
88 res = mpCurrentPoint->mpPrev;
90 res = mpCurrentPoint->mpNext;
91 if (updateDirection) {
92 mDir1 = PATH_DIR_NORMAL;
99void dWmEnPath_c::UpdatePoint() {
100 mpCurrentPoint = GetNextPointInfo(
true);
103bool dWmEnPath_c::isPointIn(
int pointIndex) {
104 for (
int i = 0; i < ARRAY_SIZE(mPoints); i++) {
105 if (mPoints[i].mPointIndex == pointIndex) {
bool init(const char **names, int count, dWmConnect_c *connect, bool cyclic, PATH_DIRECTION_e dir)