Skip to content

Commit

Permalink
Merge pull request #214 from LynxAbraxas/dbgEmbargo
Browse files Browse the repository at this point in the history
Listing a standing embargo in the diplomacy manager
  • Loading branch information
MartinGuehmann committed Dec 1, 2019
2 parents 4be6722 + d2ccba8 commit 23218fd
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 1,517 deletions.
9 changes: 9 additions & 0 deletions ctp2_code/ai/diplomacy/diplomat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,15 @@ void Diplomat::SetEmbargo(const PLAYER_INDEX foreignerId, const bool state)
}

g_theTradePool->BreakOffTrade(m_playerId, foreignerId);

ai::Agreement agreement;
agreement.senderId = foreignerId;
agreement.receiverId = m_playerId;
agreement.start = static_cast<sint16>(NewTurnCount::GetCurrentRound());
agreement.end = -1;
agreement.proposal.first_type = PROPOSAL_REQUEST_END_EMBARGO; //agreement type used in the sense of DECLARE_EMBARGO see diplomacyproposal.txt

AgreementMatrix::s_agreements.SetAgreement(agreement);
}

m_foreigners[foreignerId].SetEmbargo(state);
Expand Down
113 changes: 49 additions & 64 deletions ctp2_code/ui/interface/DiplomacyDetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,71 +860,56 @@ AUI_ERRCODE DiplomacyDetails::DrawEmbassy(ctp2_Static *control,
return AUI_ERRCODE_OK;
}

AUI_ERRCODE DiplomacyDetails::DrawTreaties(ctp2_Static *control,
aui_Surface *surface,
RECT &rect,
void *cookie)
{
sint32 p = (sint32)cookie;
sint32 visP = g_selected_item->GetVisiblePlayer();

sint32 x = 0;

sint32 ag;
sint32 slot;
for(ag = 1; ag < PROPOSAL_MAX; ag++) {






const DiplomacyProposalRecord *rec =
g_theDiplomacyProposalDB->Get(diplomacyutil_GetDBIndex((PROPOSAL_TYPE)ag));

if (!rec->GetImageSlot(slot))
continue;

if (p == visP)
{
if (slot > 4)
continue;
}
else
{

if (slot < 4)
slot = 0;
else
slot -= 3;
}

if(AgreementMatrix::s_agreements.HasAgreement(detailPlayer, p, (PROPOSAL_TYPE)ag)) {
aui_Image *image = g_c3ui->LoadImage((char *)rec->GetImage());
Assert(image);
if(!image)
continue;
RECT srcRect = {
0, 0,
image->TheSurface()->Width(),
image->TheSurface()->Height()
};

image->SetChromakey(255,0,255);

x = image->TheSurface()->Width() * slot;

g_c3ui->TheBlitter()->Blt(surface, rect.left + x,
rect.top + (((rect.bottom - rect.top) - image->TheSurface()->Height()) / 2),
image->TheSurface(),
&srcRect,
k_AUI_BLITTER_FLAG_CHROMAKEY);

g_c3ui->UnloadImage(image);
}
AUI_ERRCODE DiplomacyDetails::DrawTreaties(ctp2_Static *control, aui_Surface *surface, RECT &rect, void *cookie)
{
//// similar to IntelligenceWindow::DrawTreaties
sint32 p = (sint32)cookie;
sint32 visP = g_selected_item->GetVisiblePlayer();

sint32 x = 0;

sint32 ag;
sint32 slot;
for(ag = 1; ag < PROPOSAL_MAX; ag++) {
const DiplomacyProposalRecord *rec =
g_theDiplomacyProposalDB->Get(diplomacyutil_GetDBIndex((PROPOSAL_TYPE)ag));

if (!rec->GetImageSlot(slot))
continue;

if (rec->GetHasEmbargo())
{
if (!Diplomat::GetDiplomat(p).GetEmbargo(detailPlayer))
continue;
}
else if(!AgreementMatrix::s_agreements.HasAgreement(detailPlayer, p, (PROPOSAL_TYPE)ag))
continue;

aui_Image *image = g_c3ui->LoadImage((char *)rec->GetImage());
Assert(image);
if(!image)
continue;
RECT srcRect = {
0, 0,
image->TheSurface()->Width(),
image->TheSurface()->Height()
};

image->SetChromakey(255,0,255);

x = image->TheSurface()->Width() * slot;

g_c3ui->TheBlitter()->Blt(surface, rect.left + x,
rect.top + (((rect.bottom - rect.top) - image->TheSurface()->Height()) / 2),
image->TheSurface(),
&srcRect,
k_AUI_BLITTER_FLAG_CHROMAKEY);

g_c3ui->UnloadImage(image);
}
return AUI_ERRCODE_OK;
}

return AUI_ERRCODE_OK;
}

sint32 DiplomacyDetails::GetRegardThreshold(sint32 ofPlayer, sint32 forPlayer)
{
Expand Down
Loading

0 comments on commit 23218fd

Please sign in to comment.