SiegeInfo.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.network.serverpackets;
  16. import java.util.Calendar;
  17. import java.util.logging.Logger;
  18. import com.l2jserver.gameserver.datatables.ClanTable;
  19. import com.l2jserver.gameserver.model.L2Clan;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.entity.Castle;
  22. /**
  23. * Shows the Siege Info<BR>
  24. * <BR>
  25. * packet type id 0xc9<BR>
  26. * format: cdddSSdSdd<BR>
  27. * <BR>
  28. * c = c9<BR>
  29. * d = CastleID<BR>
  30. * d = Show Owner Controls (0x00 default || >=0x02(mask?) owner)<BR>
  31. * d = Owner ClanID<BR>
  32. * S = Owner ClanName<BR>
  33. * S = Owner Clan LeaderName<BR>
  34. * d = Owner AllyID<BR>
  35. * S = Owner AllyName<BR>
  36. * d = current time (seconds)<BR>
  37. * d = Siege time (seconds) (0 for selectable)<BR>
  38. * d = (UNKNOW) Siege Time Select Related?
  39. *
  40. * @author KenM
  41. */
  42. public class SiegeInfo extends L2GameServerPacket
  43. {
  44. private static final String _S__C9_SIEGEINFO = "[S] c9 SiegeInfo";
  45. private static Logger _log = Logger.getLogger(SiegeInfo.class.getName());
  46. private Castle _castle;
  47. public SiegeInfo(Castle castle)
  48. {
  49. _castle = castle;
  50. }
  51. @Override
  52. protected final void writeImpl()
  53. {
  54. L2PcInstance activeChar = getClient().getActiveChar();
  55. if (activeChar == null) return;
  56. writeC(0xc9);
  57. writeD(_castle.getCastleId());
  58. writeD(((_castle.getOwnerId() == activeChar.getClanId()) && (activeChar.isClanLeader())) ? 0x01 : 0x00);
  59. writeD(_castle.getOwnerId());
  60. if (_castle.getOwnerId() > 0)
  61. {
  62. L2Clan owner = ClanTable.getInstance().getClan(_castle.getOwnerId());
  63. if (owner != null)
  64. {
  65. writeS(owner.getName()); // Clan Name
  66. writeS(owner.getLeaderName()); // Clan Leader Name
  67. writeD(owner.getAllyId()); // Ally ID
  68. writeS(owner.getAllyName()); // Ally Name
  69. }
  70. else
  71. _log.warning("Null owner for castle: " + _castle.getName());
  72. }
  73. else
  74. {
  75. writeS("NPC"); // Clan Name
  76. writeS(""); // Clan Leader Name
  77. writeD(0); // Ally ID
  78. writeS(""); // Ally Name
  79. }
  80. writeD((int) (Calendar.getInstance().getTimeInMillis()/1000));
  81. writeD((int) (_castle.getSiege().getSiegeDate().getTimeInMillis()/1000));
  82. writeD(0x00); //number of choices?
  83. }
  84. /* (non-Javadoc)
  85. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  86. */
  87. @Override
  88. public String getType()
  89. {
  90. return _S__C9_SIEGEINFO;
  91. }
  92. }