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(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
);
65 CCtrlBase
*ctrl
= dynamic_cast<CCtrlBase
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:random"));
67 ctrl
->setActive(outpostInFire
);
68 ctrl
= dynamic_cast<CCtrlBase
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:neutral"));
70 ctrl
->setActive(!outpostInFire
);
72 CGroupContainer
*pGC
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal"));
76 CWidgetManager::getInstance()->setTopWindow(pGC
);
85 // ***************************************************************************
86 void COutpostManager::endPvpJoinProposal(bool bNeutral
, OUTPOSTENUMS::TPVPSide pvpSide
)
89 string sMsg
= "OUTPOST:SIDE_CHOSEN";
91 if(GenericMsgHeaderMngr
.pushNameToStream(sMsg
, out
))
93 //nlinfo("impulseCallBack : %s %d %s sent", sMsg.c_str(), bNeutral, OUTPOSTENUMS::toString(pvpSide).c_str());
95 uint8 sideAsInt
= (uint8
)pvpSide
;
96 out
.serial(sideAsInt
);
101 nlwarning("command : unknown message name : '%s'.", sMsg
.c_str());
105 _EndTickForPvpJoinProposal
= 0;
108 // ***************************************************************************
109 void COutpostManager::update()
111 // *** If there is a join proposal running
112 if(_EndTickForPvpJoinProposal
!=0)
114 if(_EndTickForPvpJoinProposal
<NetMngr
.getCurrentServerTick())
116 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
118 // Force the neutral choose
119 CAHManager::getInstance()->runActionHandler("outpost_pvp_join", NULL
, "neutral");
122 CGroupContainer
*pGC
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal"));
124 pGC
->setActive(false);
127 _EndTickForPvpJoinProposal
= 0;