-
Notifications
You must be signed in to change notification settings - Fork 1
/
WalkPath.h
70 lines (51 loc) · 1.76 KB
/
WalkPath.h
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
/////////////////////////////////////////////////////////////////////////
//
// WalkPath.h
//
// Labyrinth Pathing Algorithm by Ustc_tweeg
//
// Ustc_tweeg < [email protected] >
//
/////////////////////////////////////////////////////////////////////////
#ifndef __WALKPATH_H__
#define __WALKPATH_H__
#define __IN_DIABLOII__ // Comment this line out if not used in game
#include <Windows.h>
#ifndef __IN_DIABLOII__
#include <stdio.h>
#include "ArrayEx.h"
#else
#include "ArrayEx.h"
#endif
class CWalkPath
{
public:
CWalkPath(WORD** Map, int MapSizeX, int MapSizeY);
virtual ~CWalkPath();
// return number of path points found, including the start and the end point
// return 0 if pathing fail
int FindWalkPath (POINT Start, POINT End, LPPOINT Path, DWORD dwMaxCount);
private:
WORD** m_Map;
int m_MapSizeX, m_MapSizeY;
int m_Count;
POINT m_Start,m_End,m_Meet,m_Seperate;
POINT m_LCurrent,m_RCurrent,m_LastLineDot;
CArrayEx<POINT, const POINT&> ContinuousPath;
CArrayEx<POINT, const POINT&> LeftWallPath;
CArrayEx<POINT, const POINT&> RightWallPath;
int m_LStart,m_RStart;
BOOL m_Direct,m_FollowWallSuccess;
BOOL IsBorder(POINT pt);
BOOL IsBarrier(POINT pt) const;
BOOL IsDirect(POINT pt1, POINT pt2);
void FollowTheRope(POINT Dot);
BOOL FollowTheWall(BOOL RightWall, POINT FollowEnd);
void SaveFollowWallPath();
void StraightenThePath(LPPOINT Path, DWORD dwMaxCount);
DWORD FurtherStraighten(LPPOINT lpPath, DWORD dwMaxCount);
static void CALLBACK FindPathProc(int X, int Y, LPARAM lpData);
static void CALLBACK IsDirectProc(int x, int y, LPARAM lpData);
static int Split(const POINT& pt1, const POINT& pt2, CArrayEx<POINT, const POINT&>& aSubPath);
};
#endif // __WALKPATH_H__