-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCvDllDealAI.cpp
120 lines (117 loc) · 4.51 KB
/
CvDllDealAI.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* -------------------------------------------------------------------------------------------------------
© 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games.
Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software
and their respective logos are all trademarks of Take-Two interactive Software, Inc.
All other marks and trademarks are the property of their respective owners.
All rights reserved.
------------------------------------------------------------------------------------------------------- */
#include "CvGameCoreDLLPCH.h"
#include "CvDllDealAI.h"
#include "CvDllContext.h"
#include "CvDllDeal.h"
#include "CvDllPlayer.h"
#include "CvDealAI.h"
CvDllDealAI::CvDllDealAI(CvDealAI* pDealAI)
: m_pDealAI(pDealAI)
, m_uiRefCount(1)
{
}
//------------------------------------------------------------------------------
CvDllDealAI::~CvDllDealAI()
{
}
//------------------------------------------------------------------------------
void* CvDllDealAI::QueryInterface(GUID guidInterface)
{
if( guidInterface == ICvUnknown::GetInterfaceId() ||
guidInterface == ICvDealAI1::GetInterfaceId())
{
IncrementReference();
return this;
}
return NULL;
}
//------------------------------------------------------------------------------
unsigned int CvDllDealAI::IncrementReference()
{
++m_uiRefCount;
return m_uiRefCount;
}
//------------------------------------------------------------------------------
unsigned int CvDllDealAI::DecrementReference()
{
if(m_uiRefCount == 1)
{
delete this;
return 0;
}
else
{
--m_uiRefCount;
return m_uiRefCount;
}
}
//------------------------------------------------------------------------------
unsigned int CvDllDealAI::GetReferenceCount()
{
return m_uiRefCount;
}
//------------------------------------------------------------------------------
void CvDllDealAI::Destroy()
{
DecrementReference();
}
//------------------------------------------------------------------------------
void CvDllDealAI::operator delete(void* p)
{
CvDllGameContext::Free(p);
}
//------------------------------------------------------------------------------
void* CvDllDealAI::operator new(size_t bytes)
{
return CvDllGameContext::Allocate(bytes);
}
//------------------------------------------------------------------------------
CvDealAI* CvDllDealAI::GetInstance()
{
return m_pDealAI;
}
//------------------------------------------------------------------------------
ICvPlayer1* CvDllDealAI::GetPlayer()
{
CvPlayerAI* pkPlayer = (CvPlayerAI*)m_pDealAI->GetPlayer();
return (NULL != pkPlayer)? new CvDllPlayer(pkPlayer) : NULL;
}
//------------------------------------------------------------------------------
int CvDllDealAI::DoHumanOfferDealToThisAI(ICvDeal1* pDeal)
{
CvDeal* pkDeal = (NULL != pDeal)? static_cast<CvDllDeal*>(pDeal)->GetInstance() : NULL;
return m_pDealAI->DoHumanOfferDealToThisAI(pkDeal);
}
//------------------------------------------------------------------------------
void CvDllDealAI::DoAcceptedDeal(PlayerTypes eFromPlayer, ICvDeal1* pDeal, int iDealValueToMe, int iValueImOffering, int iValueTheyreOffering)
{
CvDeal* pkDeal = (NULL != pDeal)? static_cast<CvDllDeal*>(pDeal)->GetInstance() : NULL;
if(pkDeal != NULL)
m_pDealAI->DoAcceptedDeal(eFromPlayer, *pkDeal, iDealValueToMe, iValueImOffering, iValueTheyreOffering);
}
//------------------------------------------------------------------------------
int CvDllDealAI::DoHumanDemand(ICvDeal1* pDeal)
{
CvDeal* pkDeal = (NULL != pDeal)? static_cast<CvDllDeal*>(pDeal)->GetInstance() : NULL;
return m_pDealAI->DoHumanDemand(pkDeal);
}
//------------------------------------------------------------------------------
void CvDllDealAI::DoAcceptedDemand(PlayerTypes eFromPlayer, ICvDeal1* pDeal)
{
CvDeal* pkDeal = (NULL != pDeal)? static_cast<CvDllDeal*>(pDeal)->GetInstance() : NULL;
if(pkDeal != NULL)
m_pDealAI->DoAcceptedDemand(eFromPlayer, *pkDeal);
}
//------------------------------------------------------------------------------
bool CvDllDealAI::DoEqualizeDealWithHuman(ICvDeal1* pDeal, PlayerTypes eOtherPlayer, bool bDontChangeMyExistingItems, bool bDontChangeTheirExistingItems, bool &bDealGoodToBeginWith, bool &bCantMatchDeal)
{
CvDeal* pkDeal = (NULL != pDeal)? static_cast<CvDllDeal*>(pDeal)->GetInstance() : NULL;
return m_pDealAI->DoEqualizeDealWithHuman(pkDeal, eOtherPlayer, bDontChangeMyExistingItems, bDontChangeTheirExistingItems, bDealGoodToBeginWith, bCantMatchDeal);
}
//------------------------------------------------------------------------------