forked from Corran-Raisu/FLCompanion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jump.cpp
64 lines (57 loc) · 1.69 KB
/
Jump.cpp
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
// Gate.cpp: implementation of the CGate class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FLCompanion.h"
#include "Jump.h"
#include "Datas.h"
#include "System.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
void CJump::SetMatchingJump(CJump *matchingJump)
{
CHECK(matchingJump);
m_matchingJump = matchingJump;
}
extern DWORD FLHash (LPCTSTR string);
void CJump::Init(const CString &nickname, BOOL isgate, BOOL islocked, BOOL isfreighteronly, const CString &caption, CSystem *system)
{
//CString sCaption = isgate ? g_jumpGateCaption : g_jumpHoleCaption;
//sCaption += L": "+caption;
m_isgate = isgate;
m_islocked = islocked;
m_isfreighteronly = isfreighteronly;
CDockable::Init(nickname, caption, system);
}
CString CJump::LetterPos()
{
if (m_isgate) return CDockable::LetterPos();
// jump holes requires more precise position :
int mapmax = (int) (MAPMAX/m_system->m_navmapscale);
int x = (m_pos.x)*40/mapmax+40;
int z = (m_pos.z)*40/mapmax+40;
CString letters = CString(char('A'+x/10));
x = x%10;
if (x < 5)
letters += L"-"+CString(char('0'+5-x));
else if (x > 5)
letters += L"+"+CString(char('0'-5+x));
letters += L",";
letters += CString(char('1'+z/10),1);
z = z%10;
if (z < 5)
letters += L"-"+CString(char('0'+5-z));
else if (z > 5)
letters += L"+"+CString(char('0'-5+z));
if (m_pos.y < -1024)
letters += L" (below horizon)";
else if (m_pos.y > 1024)
letters += L" (above horizon)";
return letters;
}