forked from Corran-Raisu/FLCompanion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBase.cpp
75 lines (67 loc) · 2.17 KB
/
Base.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
65
66
67
68
69
70
71
72
73
74
75
// Base.cpp: implementation of the CBase class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FLCompanion.h"
#include "FLCompanionDlg.h"
#include "Base.h"
#include "System.h"
#include "Datas.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBase g_bases[BASES_MAX];
CBase* g_miningBase;
UINT g_miningDelay;
CSortedMap<CString,LPCTSTR,CBase*,CBase*> g_basesByNick;
void CBase::Init(const CString &nickname, const CString &caption, CSystem *system, const CString &faction, BOOL isfreighteronly)
{
if (caption == L" ")
{
ProblemFound(L"Universe entry (%s, %s) is missing a name in %s", system->m_nickname, nickname, system->m_file);
}
CDockable::Init(nickname, caption, system);
m_isfreighteronly = isfreighteronly;
for (UINT i = 0; i < GOODS_MAX; i++)
m_buy[i] = g_goods[i].m_defaultPrice;
if (faction.IsEmpty())
m_faction = NULL;
else
{
m_faction = g_factionsByNick[faction];
if (m_faction == NULL)
ProblemFound(L"Base %s references an unknown faction %s", nickname, faction);
}
}
UINT CBase::GetDockingDelay()
{
if (this == g_miningBase)
return g_miningDelay;
else
return BASE_DELAY;
}
void CBase::MakeMiningBase(CSystem *system, int x, int y, int z, UINT goodIndex, double goodsPrice)
{
CDockable::Init(L"=mining operation=", L"<Mining Operation>", system);
for (UINT i = 0; i < GOODS_MAX; i++) m_buy[i] = 0;
for (UINT i = 0; i < GOODS_MAX; i++) m_sell[i] = 3.40282347e+38;
m_sell[goodIndex] = goodsPrice;
m_faction = g_factionsByNick["fc_player_grp"];
SetPos(x,y,z);
}
CBase* MakeMiningBase(CSystem* system, int x, int y, int z, UINT goodIndex, double miningSpeed, double goodsPrice)
{
if (g_miningBase == NULL)
g_miningBase = &g_bases[BASES_COUNT++];
else
g_miningBase->m_system->RemoveBase(g_miningBase);
g_miningDelay = UINT(g_mainDlg->m_cargoSize*1000/miningSpeed);
g_miningBase->MakeMiningBase(system, x, y, z, goodIndex,goodsPrice);
system->AddBase(g_miningBase);
return g_miningBase;
}