root/trunk/AE-go_GameServer/src/com/aionemu/gameserver/services/MailService.java
| 1515 | 1528 | ||
|---|---|---|---|
71 | if(express) //TODO express mail | 71 | if(express) //TODO express mail |
72 | return; | 72 | return; |
73 | 73 | ||
74 | if(recipientName.length() > 16 || title.length() > 20 || message.length() > 1000) | ||
75 | return; | ||
76 | |||
74 | PlayerCommonData recipientCommonData = DAOManager.getDAO(PlayerDAO.class).loadPlayerCommonDataByName(recipientName, world); | 77 | PlayerCommonData recipientCommonData = DAOManager.getDAO(PlayerDAO.class).loadPlayerCommonDataByName(recipientName, world); |
75 | Player onlineRecipient; | 78 | Player onlineRecipient; |
76 | 79 | ||
... | ... | ||
165 | attachedItem = senderItem; | 168 | attachedItem = senderItem; |
166 | 169 | ||
167 | itemMailCommission = Math.round((senderItem.getItemTemplate().getPrice() * attachedItem.getItemCount()) * qualityPriceRate); | 170 | itemMailCommission = Math.round((senderItem.getItemTemplate().getPrice() * attachedItem.getItemCount()) * qualityPriceRate); |
168 | | ||
169 | DAOManager.getDAO(InventoryDAO.class).store(attachedItem, recipientCommonData.getPlayerObjId()); | ||
170 | } | 171 | } |
171 | else if(senderItem.getItemCount() > attachedItemCount) | 172 | else if(senderItem.getItemCount() > attachedItemCount) |
172 | { | 173 | { |
... | ... | ||
179 | attachedItem.setItemLocation(StorageType.MAILBOX.getId()); | 180 | attachedItem.setItemLocation(StorageType.MAILBOX.getId()); |
180 | 181 | ||
181 | itemMailCommission = Math.round((attachedItem.getItemTemplate().getPrice() * attachedItem.getItemCount()) * qualityPriceRate); | 182 | itemMailCommission = Math.round((attachedItem.getItemTemplate().getPrice() * attachedItem.getItemCount()) * qualityPriceRate); |
182 | | ||
183 | DAOManager.getDAO(InventoryDAO.class).store(attachedItem, recipientCommonData.getPlayerObjId()); | ||
184 | } | 183 | } |
185 | } | 184 | } |
186 | } | 185 | } |
... | ... | ||
190 | { | 189 | { |
191 | if(senderInventory.getKinahItem().getItemCount() - attachedKinahCount >= 0) | 190 | if(senderInventory.getKinahItem().getItemCount() - attachedKinahCount >= 0) |
192 | { | 191 | { |
193 | senderInventory.decreaseKinah(attachedKinahCount); | ||
194 | finalAttachedKinahCount = attachedKinahCount; | 192 | finalAttachedKinahCount = attachedKinahCount; |
195 | kinahMailCommission = Math.round(attachedKinahCount * 0.01f); | 193 | kinahMailCommission = Math.round(attachedKinahCount * 0.01f); |
196 | } | 194 | } |
... | ... | ||
200 | Letter newLetter = new Letter(aionObjectsIDFactory.nextId(), recipientCommonData.getPlayerObjId(), attachedItem, finalAttachedKinahCount, title, message, sender.getName(), true, express); | 198 | Letter newLetter = new Letter(aionObjectsIDFactory.nextId(), recipientCommonData.getPlayerObjId(), attachedItem, finalAttachedKinahCount, title, message, sender.getName(), true, express); |
201 | 199 | ||
202 | Timestamp time = new Timestamp(Calendar.getInstance().getTimeInMillis()); | 200 | Timestamp time = new Timestamp(Calendar.getInstance().getTimeInMillis()); |
203 | |||
204 | 201 | ||
202 | |||
203 | if(!DAOManager.getDAO(MailDAO.class).storeLetter(time, newLetter)) | ||
204 | return; | ||
205 | |||
206 | senderInventory.decreaseKinah(finalAttachedKinahCount); | ||
207 | |||
208 | if(attachedItem != null) | ||
209 | if(!DAOManager.getDAO(InventoryDAO.class).store(attachedItem, recipientCommonData.getPlayerObjId())) | ||
210 | return; | ||
211 | |||
212 | int finalMailCommission = 10 + kinahMailCommission + itemMailCommission; | ||
213 | senderInventory.decreaseKinah(finalMailCommission); | ||
214 | |||
205 | if(onlineRecipient != null) | 215 | if(onlineRecipient != null) |
206 | { | 216 | { |
207 | Mailbox recipientMailbox = onlineRecipient.getMailbox(); | 217 | Mailbox recipientMailbox = onlineRecipient.getMailbox(); |
... | ... | ||
212 | PacketSendUtility.sendPacket(onlineRecipient, new SM_MAIL_SERVICE(true, true)); | 222 | PacketSendUtility.sendPacket(onlineRecipient, new SM_MAIL_SERVICE(true, true)); |
213 | } | 223 | } |
214 | 224 | ||
215 | 225 | PacketSendUtility.sendPacket(sender, new SM_MAIL_SERVICE(MailMessage.MAIL_SEND_SECCESS)); | |
216 | int finalMailCommission = 10 + kinahMailCommission + itemMailCommission; | ||
217 | | ||
218 | senderInventory.decreaseKinah(finalMailCommission); | ||
219 | | ||
220 | | ||
221 | if(DAOManager.getDAO(MailDAO.class).storeLetter(time, newLetter)) | ||
222 | { | ||
223 | PacketSendUtility.sendPacket(sender, new SM_MAIL_SERVICE(MailMessage.MAIL_SEND_SECCESS)); | ||
224 | } | ||
225 | } | 226 | } |
226 | 227 | ||
227 | public void readMail(Player player, int letterId) | 228 | public void readMail(Player player, int letterId) |
Download diff