2
0

RequestSaveKeyMapping.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.clientpackets;
  16. import java.util.List;
  17. import java.util.Map;
  18. import javolution.util.FastList;
  19. import javolution.util.FastMap;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.entity.ActionKey;
  23. import com.l2jserver.gameserver.network.L2GameClient.GameClientState;
  24. /**
  25. *
  26. * @author mrTJO
  27. */
  28. public class RequestSaveKeyMapping extends L2GameClientPacket
  29. {
  30. int _tabNum;
  31. Map<Integer, List<ActionKey>> _keyMap = new FastMap<Integer, List<ActionKey>>();
  32. Map<Integer, List<Integer>> _catMap = new FastMap<Integer, List<Integer>>();
  33. /**
  34. * @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
  35. */
  36. @Override
  37. public String getType()
  38. {
  39. return "[C] D0:22 RequestSaveKeyMapping";
  40. }
  41. /**
  42. * @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
  43. */
  44. @Override
  45. protected void readImpl()
  46. {
  47. int category = 0;
  48. readD(); // Unknown
  49. readD(); // Unknown
  50. _tabNum = readD();
  51. for (int i = 0; i < _tabNum; i++)
  52. {
  53. int cmd1Size = readC();
  54. for (int j = 0; j < cmd1Size; j++)
  55. {
  56. int cmdId = readC();
  57. insertCategory(category, cmdId);
  58. }
  59. category++;
  60. int cmd2Size = readC();
  61. for (int j = 0; j < cmd2Size; j++)
  62. {
  63. int cmdId = readC();
  64. insertCategory(category, cmdId);
  65. }
  66. category++;
  67. int cmdSize = readD();
  68. for (int j = 0; j < cmdSize; j++)
  69. {
  70. int cmd = readD();
  71. int key = readD();
  72. int tgKey1 = readD();
  73. int tgKey2 = readD();
  74. int show = readD();
  75. insertKey(i, cmd, key, tgKey1, tgKey2, show);
  76. }
  77. }
  78. readD();
  79. readD();
  80. }
  81. public void insertCategory(int cat, int cmd)
  82. {
  83. if (_catMap.containsKey(cat))
  84. _catMap.get(cat).add(cmd);
  85. else
  86. {
  87. List<Integer> tmp = new FastList<Integer>();
  88. tmp.add(cmd);
  89. _catMap.put(cat, tmp);
  90. }
  91. }
  92. public void insertKey(int cat, int cmdId, int key, int tgKey1, int tgKey2, int show)
  93. {
  94. ActionKey tmk = new ActionKey(cat, cmdId, key, tgKey1, tgKey2, show);
  95. if (_keyMap.containsKey(cat))
  96. _keyMap.get(cat).add(tmk);
  97. else
  98. {
  99. List<ActionKey> tmp = new FastList<ActionKey>();
  100. tmp.add(tmk);
  101. _keyMap.put(cat, tmp);
  102. }
  103. }
  104. /**
  105. * @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
  106. */
  107. @Override
  108. protected void runImpl()
  109. {
  110. L2PcInstance player = getClient().getActiveChar();
  111. if (player == null)
  112. return;
  113. if (getClient().getState() != GameClientState.IN_GAME)
  114. return;
  115. if (Config.STORE_UI_SETTINGS)
  116. player.getUISettings().storeAll(_catMap, _keyMap);
  117. }
  118. }