1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2019 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "outpost_manager.h"
24 #include "net_manager.h"
25 #include "interface_v3/interface_manager.h"
26 #include "nel/gui/group_container.h"
27 #include "nel/misc/bit_mem_stream.h"
28 #include "game_share/generic_xml_msg_mngr.h"
30 COutpostManager OutpostManager
;
32 using namespace NLMISC
;
35 // ***************************************************************************
36 COutpostManager::COutpostManager()
38 _EndTickForPvpJoinProposal
= 0;
42 // ***************************************************************************
43 void COutpostManager::startPvpJoinProposal(OUTPOSTENUMS::TPVPType type
, bool outpostInFire
, bool playerGuildInConflict
, bool playerGuildIsAttacker
,
44 uint32 ownerGuildNameId
, uint32 attackerGuildNameId
, uint32 declTimer
)
46 // reset counter that force player to be neutral (eg: 10 seconds)
47 _EndTickForPvpJoinProposal
= NetMngr
.getCurrentServerTick() + declTimer
;
50 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
52 CCDBNodeLeaf
*node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_PLAYER_GUILD_IN_CONFLICT");
53 if(node
) node
->setValueBool(playerGuildInConflict
);
54 node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_PLAYER_GUILD_IS_ATTACKER");
55 if(node
) node
->setValueBool(playerGuildIsAttacker
);
56 node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_ATTACKER");
57 if(node
) node
->setValue32(attackerGuildNameId
);
58 node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_DEFENDER");
59 if(node
) node
->setValue32(ownerGuildNameId
);
60 node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_TICK_END");
61 if(node
) node
->setValue32(_EndTickForPvpJoinProposal
);
66 CCtrlBase
*ctrl
= dynamic_cast<CCtrlBase
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:random"));
68 ctrl
->setActive(false);
70 ctrl
= dynamic_cast<CCtrlBase
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:neutral"));
72 ctrl
->setActive(true);
74 // GvE: only attacker guild can have the option
75 ctrl
= dynamic_cast<CCtrlBase
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:attack"));
76 if (ctrl
&& (type
== OUTPOSTENUMS::GVE
|| type
== OUTPOSTENUMS::PVE
|| type
== OUTPOSTENUMS::GVG
))
77 ctrl
->setActive(playerGuildIsAttacker
);
79 // GvE : No defend option
80 ctrl
= dynamic_cast<CCtrlBase
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:defend"));
81 if (ctrl
&& (type
== OUTPOSTENUMS::GVE
|| type
== OUTPOSTENUMS::PVE
))
82 ctrl
->setActive(false);
83 if (ctrl
&& (type
== OUTPOSTENUMS::GVG
))
84 ctrl
->setActive(playerGuildInConflict
&& !playerGuildIsAttacker
);
87 CGroupContainer
*pGC
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal"));
91 CWidgetManager::getInstance()->setTopWindow(pGC
);
100 // ***************************************************************************
101 void COutpostManager::endPvpJoinProposal(bool bNeutral
, OUTPOSTENUMS::TPVPSide pvpSide
)
104 string sMsg
= "OUTPOST:SIDE_CHOSEN";
106 if(GenericMsgHeaderMngr
.pushNameToStream(sMsg
, out
))
108 //nlinfo("impulseCallBack : %s %d %s sent", sMsg.c_str(), bNeutral, OUTPOSTENUMS::toString(pvpSide).c_str());
109 out
.serial(bNeutral
);
110 uint8 sideAsInt
= (uint8
)pvpSide
;
111 out
.serial(sideAsInt
);
116 nlwarning("command : unknown message name : '%s'.", sMsg
.c_str());
120 _EndTickForPvpJoinProposal
= 0;
123 // ***************************************************************************
124 void COutpostManager::update()
126 // *** If there is a join proposal running
127 if(_EndTickForPvpJoinProposal
!=0)
129 if(_EndTickForPvpJoinProposal
<NetMngr
.getCurrentServerTick())
131 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
133 // Force the neutral choose
134 CAHManager::getInstance()->runActionHandler("outpost_pvp_join", NULL
, "neutral");
137 CGroupContainer
*pGC
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal"));
139 pGC
->setActive(false);
142 _EndTickForPvpJoinProposal
= 0;