1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 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>
6 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "interface_manager.h"
25 #include "nel/gui/action_handler.h"
26 #include "action_handler_tools.h"
27 #include "game_share/outpost.h"
28 #include "nel/gui/interface_expr.h"
29 #include "group_map.h"
30 #include "../sheet_manager.h"
31 #include "../net_manager.h"
32 #include "../game_context_menu.h"
33 #include "../user_entity.h"
34 #include "../entities.h"
35 #include "../outpost_manager.h"
39 using namespace NLMISC
;
42 // ***************************************************************************
43 // ***************************************************************************
45 // ***************************************************************************
46 // ***************************************************************************
48 uint8
getOutpostSelection()
51 CCDBNodeLeaf
*pNL
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SELECTION",false);
53 nOutpost
= (uint8
)pNL
->getValue32();
57 uint32
getOutpostSheet()
60 uint8 outpostSel
= getOutpostSelection();
61 CCDBNodeLeaf
*pNL
= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GUILD:OUTPOST:O%d:SHEET", outpostSel
),false);
63 sheet
= pNL
->getValue32();
67 // ***************************************************************************
69 class COutpostGiveup
: public IActionHandler
72 void execute (CCtrlBase
* /* pCaller */, const std::string
&sParams
)
74 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
76 // set confirm dialog flag
77 NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(true);
80 pIM
->validMessageBox(CInterfaceManager::QuestionIconMsg
, CI18N::get("uiQConfirmGiveupOutpost"),
81 "outpost_do_giveup", sParams
, "outpost_cancel_giveup");
84 REGISTER_ACTION_HANDLER(COutpostGiveup
, "outpost_giveup");
86 class COutpostDoGiveup
: public IActionHandler
89 void execute (CCtrlBase
* /* pCaller */, const std::string
&sParams
)
91 // retrieve the sheet of this outpost
94 fromString(sParams
, outpostSel
);
95 CCDBNodeLeaf
*pNL
= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GUILD:OUTPOST:O%d:SHEET", outpostSel
),false);
98 sheet
= pNL
->getValue32();
100 // send msg to server
101 sendMsgToServer("OUTPOST:GIVEUP_OUTPOST", sheet
);
103 // reset confirm dialog flag
104 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
105 NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(false);
108 REGISTER_ACTION_HANDLER(COutpostDoGiveup
, "outpost_do_giveup");
110 class COutpostCancelGiveup
: public IActionHandler
113 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
115 // reset confirm dialog flag
116 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
117 NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(false);
120 REGISTER_ACTION_HANDLER(COutpostCancelGiveup
, "outpost_cancel_giveup");
122 // ***************************************************************************
123 // Set a squad To buy (list of squad given by the server)
124 class COutpostSetSquad
: public IActionHandler
127 void execute (CCtrlBase
* /* pCaller */, const std::string
&sParams
)
129 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
131 // get Squad slot Destination selected
132 uint8 nSquadSlot
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8();
134 // get Squad Id to buy selected
135 string sLine
= getParam(sParams
, "line");
136 CInterfaceExprValue ievLine
;
138 if (!CInterfaceExpr::eval(sLine
, ievLine
))
140 nlwarning("<COutpostBuy::execute> : Can't evaluate line");
143 if (ievLine
.getInteger() >= 0)
144 nLine
= (uint8
)ievLine
.getInteger();
147 sendMsgToServer("OUTPOST:SET_SQUAD", getOutpostSheet(), nSquadSlot
, nLine
);
150 REGISTER_ACTION_HANDLER(COutpostSetSquad
, "outpost_set_squad");
153 // ***************************************************************************
154 // Remove a squad To buy (list of squad given by the server)
155 class COutpostRemoveSquad
: public IActionHandler
158 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
160 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
162 // get Squad slot Destination selected
163 uint8 nSquadSlot
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8();
166 sendMsgToServer("OUTPOST:REMOVE_SQUAD", getOutpostSheet(), nSquadSlot
);
169 REGISTER_ACTION_HANDLER(COutpostRemoveSquad
, "outpost_remove_squad");
171 // ***************************************************************************
172 // Insert a squad To buy (list of squad given by the server)
173 class COutpostInsertSquad
: public IActionHandler
176 void execute (CCtrlBase
*pCaller
, const std::string
&sParams
)
178 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
180 // get Squad slot Destination selected
181 uint8 nSquadSlot
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8();
184 sendMsgToServer("OUTPOST:INSERT_SQUAD", getOutpostSheet(), nSquadSlot
);
186 // Then set the selected squad at this place
187 CAHManager::getInstance()->runActionHandler("outpost_set_squad", pCaller
, sParams
);
190 REGISTER_ACTION_HANDLER(COutpostInsertSquad
, "outpost_insert_squad");
192 // ***************************************************************************
194 uint8
getOutpostSquadSpawnIndex()
196 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
199 uint8 nSquadSlot
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8();
201 // So we can get the spawn index stored in the DB
202 string sDBPath
= "SERVER:GUILD:OUTPOST:O" + toString(getOutpostSelection()) + ":SQUADS:T";
203 sDBPath
+= toString(nSquadSlot
) + ":SPAWN";
204 return NLGUI::CDBManager::getInstance()->getDbProp(sDBPath
)->getValue8();
207 // ***************************************************************************
208 class COutpostInitSquadMap
: public IActionHandler
211 void execute (CCtrlBase
* /* pCaller */, const std::string
&sParams
)
213 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
214 CGroupMap
*pMap
= dynamic_cast<CGroupMap
*>(CWidgetManager::getInstance()->getElementFromId(sParams
));
218 // Get the spawn index (from selected squad)
219 uint8 nSpawnIndex
= getOutpostSquadSpawnIndex();
221 // *** Get the BBox of the outpost
222 // init map with all xy that are in SERVER:GUILD:OUTPOST:O#x:SQUAD_SPAWN_ZONE (if 0,0 not present)
223 string sDBPathSZ
= "SERVER:GUILD:OUTPOST:O" + toString(getOutpostSelection()) + ":SQUAD_SPAWN_ZONE:";
224 sint32 xMin
= 0, xMax
= 0, yMin
= 0, yMax
= 0;
227 for (i
= 0; i
< OUTPOSTENUMS::OUTPOST_MAX_SPAWN_ZONE
; ++i
)
229 sint32 x
= NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ
+ toString(i
) + ":X")->getValue32();
230 sint32 y
= NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ
+ toString(i
) + ":Y")->getValue32();
231 if ((x
!= 0) || (y
!= 0))
241 if (x
< xMin
) xMin
= x
;
242 if (x
> xMax
) xMax
= x
;
243 if (y
< yMin
) yMin
= y
;
244 if (y
> yMax
) yMax
= y
;
249 // *** Find the finest map that contains the 2 points xMin,yMin and xMax,yMax
250 CWorldSheet
*pWorldSheet
= dynamic_cast<CWorldSheet
*>(SheetMngr
.get(CSheetId("ryzom.world")));
251 if (pWorldSheet
== NULL
)
254 sint32 nMapFound
= -1;
255 for (i
= 0; i
< pWorldSheet
->Maps
.size(); ++i
)
257 SMap
&rMap
= pWorldSheet
->Maps
[i
];
259 if (!rMap
.ContinentName
.empty())
261 // Is bouding box contains the 2 points ?
262 if ((rMap
.MinX
< xMin
) && (rMap
.MinY
< yMin
) &&
263 (rMap
.MaxX
> xMax
) && (rMap
.MaxY
> yMax
))
265 // Is there a map already found ?
268 nMapFound
= i
; // No, first map found
270 else // Yes we have to compare with the previous map to keep the finest
272 SMap
&rMapFound
= pWorldSheet
->Maps
[nMapFound
];
273 if ((rMap
.MaxX
- rMap
.MinX
) < (rMapFound
.MaxX
- rMapFound
.MinX
))
280 // *** Setup the Map and zoom to outpost
283 SMap
&rMapFound
= pWorldSheet
->Maps
[nMapFound
];
284 pMap
->setMap(rMapFound
.Name
);
285 CVector2f
centerWorldCoord((xMax
+ xMin
)/2.0f
, (yMin
+ yMax
)/2.0f
);
286 CVector2f centerMapCoord
;
287 pMap
->worldToMap(centerMapCoord
, centerWorldCoord
);
288 pMap
->setScale((rMapFound
.MaxX
- rMapFound
.MinX
) / max(sint32(1), (xMax
- xMin
)) );
289 pMap
->setPlayerPos(centerMapCoord
);
290 pMap
->centerOnPlayer();
293 m
.NeedToReset
= true;
294 for (i
= 0; i
< OUTPOSTENUMS::OUTPOST_MAX_SPAWN_ZONE
; ++i
)
296 sint32 x
= NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ
+ toString(i
) + ":X")->getValue32();
297 sint32 y
= NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ
+ toString(i
) + ":Y")->getValue32();
298 if ((x
!= 0) || (y
!= 0))
300 CRespawnPointsMsg::SRespawnPoint pt
;
303 m
.RespawnPoints
.push_back(pt
);
306 pMap
->addRespawnPoints(m
);
307 pMap
->setRespawnSelected(nSpawnIndex
);
311 REGISTER_ACTION_HANDLER(COutpostInitSquadMap
, "outpost_init_squad_map");
313 // ***************************************************************************
314 class COutpostSquadMapSend
: public IActionHandler
317 void execute (CCtrlBase
* /* pCaller */, const std::string
&sParams
)
319 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
320 CGroupMap
*pMap
= dynamic_cast<CGroupMap
*>(CWidgetManager::getInstance()->getElementFromId(sParams
));
324 // Get the spawn index (from selected squad)
325 uint8 nSpawnIndex
= getOutpostSquadSpawnIndex();
327 // Get Spawn index selected by the user
328 uint8 nSpawnSelected
= (uint8
)pMap
->getRespawnSelected();
330 if (nSpawnIndex
!= nSpawnSelected
)
333 uint8 nSquadSlot
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8();
335 sendMsgToServer("OUTPOST:SET_SQUAD_SPAWN", getOutpostSheet(), nSquadSlot
, nSpawnSelected
);
339 REGISTER_ACTION_HANDLER(COutpostSquadMapSend
, "outpost_squad_map_send");
342 // ***************************************************************************
343 class COutpostSelectSquadCapital
: public IActionHandler
346 void execute(CCtrlBase
* /* pCaller */, const std::string
¶ms
)
349 fromString(params
, capital
);
350 sendMsgToServer("OUTPOST:SET_SQUAD_CAPITAL", getOutpostSheet(), capital
);
353 REGISTER_ACTION_HANDLER(COutpostSelectSquadCapital
, "outpost_select_squad_capital");
356 // ***************************************************************************
357 static sint
localToGmt(sint hour
)
359 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
361 CCDBNodeLeaf
*node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false);
363 hour
-= node
->getValue32();
369 static sint
gmtToLocal(sint hour
)
371 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
373 CCDBNodeLeaf
*node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false);
375 hour
+= node
->getValue32();
383 // ***************************************************************************
384 class CAHOutpostSelectDefPeriod
: public IActionHandler
387 void execute (CCtrlBase
* /* pCaller */, const std::string
&sParams
)
389 // The user change the defense period (edited in LOCAL TimeZone)
391 fromString(sParams
, defPeriod
);
393 // Then send request to Server
394 sendMsgToServer("OUTPOST:SET_DEF_PERIOD", getOutpostSheet(), uint8(localToGmt(defPeriod
)));
397 REGISTER_ACTION_HANDLER(CAHOutpostSelectDefPeriod
, "outpost_select_def_period");
399 // ***************************************************************************
400 class CAHOutpostSelectAttPeriod
: public IActionHandler
403 void execute (CCtrlBase
*pCaller
, const std::string
&sParams
)
405 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
407 // The user change the attack period (edited in LOCAL TimeZone)
409 fromString(sParams
, attPeriod
);
411 // Store in local DB (in LOCAL for consistency)
412 CCDBNodeLeaf
*node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false);
414 node
->setValue32(localToGmt(attPeriod
));
416 // Nead to resend a Declare War Start (because wanted Att Hour changed)
417 CAHManager::getInstance()->runActionHandler("outpost_declare_war_start", pCaller
);
420 REGISTER_ACTION_HANDLER(CAHOutpostSelectAttPeriod
, "outpost_select_att_period");
422 // ***************************************************************************
423 class CAHOutpostDeclareWarStart
: public IActionHandler
426 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
428 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
430 // read current outpost sheet
431 uint32 outpostSheet
= 0;
432 CCDBNodeLeaf
*node
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:OUTPOST_SELECTED:SHEET", false);
434 outpostSheet
= node
->getValue32();
436 // read wanted GMT attack period
437 uint8 wantedAttHour
= 0;
438 node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false);
440 wantedAttHour
= (uint8
)node
->getValue32();
442 // send a DECLARE_WAR_START message to server
443 sendMsgToServer("OUTPOST:DECLARE_WAR_START", outpostSheet
, wantedAttHour
);
446 REGISTER_ACTION_HANDLER(CAHOutpostDeclareWarStart
, "outpost_declare_war_start");
448 // ***************************************************************************
449 class CAHOutpostDeclareWarValidate
: public IActionHandler
452 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
454 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
456 // read current outpost sheet
457 uint32 outpostSheet
= 0;
458 CCDBNodeLeaf
*node
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:OUTPOST_SELECTED:SHEET", false);
460 outpostSheet
= node
->getValue32();
462 // read wanted GMT attack period
463 uint8 wantedAttHour
= 0;
464 node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false);
466 wantedAttHour
= (uint8
)node
->getValue32();
468 // read result Att Period Time (NB: for final server check: ensure that the user will get what it sees)
469 uint32 startAttackTime
= 0;
470 node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_TIME_RANGE_ATT", false);
472 startAttackTime
= node
->getValue32();
474 // send a DECLARE_WAR_VALIDATE message to server
475 const char *sMsg
= "OUTPOST:DECLARE_WAR_VALIDATE";
477 if(GenericMsgHeaderMngr
.pushNameToStream(sMsg
, out
))
479 //nlinfo("impulseCallBack : %s %d %d %d sent", sMsg.c_str(), outpostSheet, wantedAttHour, startAttackTime);
480 out
.serial(outpostSheet
);
481 out
.serial(wantedAttHour
);
482 out
.serial(startAttackTime
);
487 nlwarning("command : unknown message name : '%s'.", sMsg
);
492 REGISTER_ACTION_HANDLER(CAHOutpostDeclareWarValidate
, "outpost_declare_war_validate");
494 // ***************************************************************************
495 class CAHOutpostSelectFromBC
: public IActionHandler
498 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
500 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
502 // Copy SERVER DB to Local selection
503 uint32 outpostSheet
= 0;
504 CCDBNodeLeaf
*node
= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:OUTPOST");
505 if(node
) outpostSheet
= node
->getValue32();
506 node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:BOT_SELECTION");
507 if(node
) node
->setValue32(outpostSheet
);
509 // Send a msg to server
512 const char *sMsg
= "OUTPOST:SELECT";
514 if(GenericMsgHeaderMngr
.pushNameToStream(sMsg
, out
))
516 //nlinfo("impulseCallBack : %s %d sent", sMsg.c_str(), outpostSheet);
517 out
.serial(outpostSheet
);
522 nlwarning("command : unknown message name : '%s'.", sMsg
);
527 REGISTER_ACTION_HANDLER(CAHOutpostSelectFromBC
, "outpost_select_from_bc");
530 // ***************************************************************************
531 class CAHOutpostUnSelect
: public IActionHandler
534 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
536 // Called when the Outpost State window (the one opened from BotChat) is closed
538 // Send a msg to server
539 sendMsgToServer("OUTPOST:UNSELECT");
542 REGISTER_ACTION_HANDLER(CAHOutpostUnSelect
, "outpost_unselect");
545 // ***************************************************************************
546 class CAHOutpostPVPJoin
: public IActionHandler
549 void execute (CCtrlBase
* /* pCaller */, const std::string
&Params
)
553 OUTPOSTENUMS::TPVPSide side
= OUTPOSTENUMS::UnknownPVPSide
;
557 side
= OUTPOSTENUMS::OutpostAttacker
;
559 else if(Params
=="defend")
562 side
= OUTPOSTENUMS::OutpostOwner
;
566 OutpostManager
.endPvpJoinProposal(bNeutral
, side
);
569 REGISTER_ACTION_HANDLER(CAHOutpostPVPJoin
, "outpost_pvp_join");
571 // ***************************************************************************
572 class CAHOutpostBanPlayer
: public IActionHandler
575 void execute (CCtrlBase
* /* pCaller */, const std::string
&sParams
)
577 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
580 pIM
->validMessageBox(CInterfaceManager::QuestionIconMsg
, CI18N::get("uiQConfirmOutpostBanPlayer"),
581 "outpost_do_ban_player", sParams
, "");
584 REGISTER_ACTION_HANDLER(CAHOutpostBanPlayer
, "outpost_ban_player");
586 // ***************************************************************************
587 class CAHOutpostBanGuild
: public IActionHandler
590 void execute (CCtrlBase
* /* pCaller */, const std::string
&sParams
)
592 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
595 pIM
->validMessageBox(CInterfaceManager::QuestionIconMsg
, CI18N::get("uiQConfirmOutpostBanGuild"),
596 "outpost_do_ban_guild", sParams
, "");
599 REGISTER_ACTION_HANDLER(CAHOutpostBanGuild
, "outpost_ban_guild");
601 // ***************************************************************************
602 // Used also in game_context_menu
603 void outpostTestUserCanBan(CCDBNodeLeaf
*dbBanRight
, bool &okForBanPlayer
, bool &okForBanGuild
)
605 okForBanPlayer
= false;
606 okForBanGuild
= false;
608 /** A player can ban a player in a PVP outpost if:
609 * - The player has right to ban AND his guild attack/owns the outpost the player attacks (all this is in RIGHT_BANNISH)
610 * - The player and the target are in the same war of the outpost, and in same alliance.
611 * - The player and the target are not in same guild
613 if(dbBanRight
&& dbBanRight
->getValueBool() && UserEntity
)
615 CEntityCL
*selection
= EntitiesMngr
.entity(UserEntity
->selection());
616 if(selection
&& selection
->isPlayer())
618 // in same outpost War and Side
619 if( selection
->getOutpostId() == UserEntity
->getOutpostId() &&
620 selection
->getOutpostSide() == UserEntity
->getOutpostSide() )
623 if( selection
->getGuildNameID() != UserEntity
->getGuildNameID() )
625 okForBanPlayer
= true;
626 okForBanGuild
= selection
->getGuildNameID()!=0;
633 // ***************************************************************************
634 class CAHOutpostDoBanPlayer
: public IActionHandler
637 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
639 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
640 CCDBNodeLeaf
*dbBan
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:RIGHT_TO_BANISH", false);
642 // Re-Test if can ban the selection
643 bool okForBanPlayer
= false;
644 bool okForBanGuild
= false;
645 outpostTestUserCanBan(dbBan
, okForBanPlayer
, okForBanGuild
);
647 // if still ok to ban player
650 sendMsgToServer("OUTPOST:BANISH_PLAYER");
654 REGISTER_ACTION_HANDLER(CAHOutpostDoBanPlayer
, "outpost_do_ban_player");
656 // ***************************************************************************
657 class CAHOutpostDoBanGuild
: public IActionHandler
660 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
662 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
663 CCDBNodeLeaf
*dbBan
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:RIGHT_TO_BANISH", false);
665 // Re-Test if can ban the selection
666 bool okForBanPlayer
= false;
667 bool okForBanGuild
= false;
668 outpostTestUserCanBan(dbBan
, okForBanPlayer
, okForBanGuild
);
670 // if still ok to ban player's guild
673 sendMsgToServer("OUTPOST:BANISH_GUILD");
677 REGISTER_ACTION_HANDLER(CAHOutpostDoBanGuild
, "outpost_do_ban_guild");
679 // ***************************************************************************
680 class CAHOutpostUpdateTimeZoneAuto
: public IActionHandler
683 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
685 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
686 CCDBNodeLeaf
*dbTZ
= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false);
690 // *** must update time zone, in case of user changed it during play
693 // *** Get the difference of time => timezone
694 time_t tGmt
=0, tLocal
=0;
699 // convert into GMT time
700 timeTm
= gmtime( <ime
);
702 tGmt
= mktime(timeTm
);
703 // convert into local time
704 timeTm
= localtime( <ime
);
705 timeTm
->tm_isdst
= 0; // reset daylight saving time flag
707 tLocal
= mktime(timeTm
);
709 // Make the difference and hence compute the time zone
710 double tzSec
= difftime(tLocal
, tGmt
);
711 sint tzHour
= (sint
)floor(tzSec
/ 3600);
712 clamp(tzHour
, -12, 12);
715 dbTZ
->setValue32(tzHour
);
719 REGISTER_ACTION_HANDLER(CAHOutpostUpdateTimeZoneAuto
, "outpost_update_time_zone_auto");