Цитата:
Сообщение от slawa560
CM_ENTER - Packet
|
what must fix in this packet CM_ENTER :
/*
* Java Server Emulator Project Blackout / PointBlank
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Authors: DarkSkeleton, sjke, Felixx
* Copyright (C) 2013 PBDevâ„¢
*/
package ru.pb.game.network.client.packets.client;
import ru.pb.game.Application;
import ru.pb.game.network.client.packets.ClientPacket;
import ru.pb.game.network.client.packets.server.SM_ENTER;
import ru.pb.global.enums.item.ItemType;
import ru.pb.global.models.Event;
import ru.pb.global.models.FriendUpdate;
import ru.pb.global.models.Player;
import ru.pb.global.models.PlayerItem;
import ru.pb.global.service.AccountDaoService;
import ru.pb.global.service.PlayerDaoService;
import ru.pb.global.utils.DateTimeUtil;
import ru.pb.global.utils.NetworkUtil;
/**
* Ð�еизвР;µÑ‚ный пакет
*
* @author sjke
*/
public class CM_ENTER extends ClientPacket {
private String login;
public CM_ENTER(int opcode) {
super(opcode);
}
@Override
public void readImpl() {
int length = readC(); // Длинн а логиÐ& #189;а
login = readS(length).trim(); // Ð�ккауР;½Ñ‚
readQ(); // unk
readC(); // unk
getConnection().setLocalIP(NetworkUtil.parseIp((re adB(4)))); // IP Ð°Ð´Ð´Ñ€ÐµÑ ;�
}
@Override
public void runImpl() {
if(getConnection().getAccount() == null) {
getConnection().setAccount(AccountDaoService.getIn stance().readByLogin(login));
Player player = PlayerDaoService.getInstance().read(getConnection( ).getAccount().getId());
if(player != null) {
getConnection().setPlayer(player);
player.setCoupon1(0);
player.setCoupon2(0);
player.setCoupon3(0);
player.setCoupon4(0);
player.setCoupon5(0);
player.setCouponExp(0);
player.setCouponGp(0);
player.getConnection().account = getConnection().getAccount();
for(PlayerItem item : player.getEqipment().getItemsByType(ItemType.COUPO N)) {
int Level = item.getItem().getC_Level();
int Value = item.getItem().getC_Value();
if(Level == 1 && item.getStatus() == 2)
player.setCoupon1(player.getCoupon1() + Value);
if(Level == 3 && item.getStatus() == 2)
player.setCoupon3(player.getCoupon3() + Value);
if(Level == 4 && item.getStatus() == 2)
player.setCoupon4(player.getCoupon4() + Value);
if(Level == 5 && item.getStatus() == 2)
player.setCoupon5(player.getCoupon5() + Value);
if(Level == 2 && item.getStatus() == 2)
player.setCoupon2(player.getCoupon2() + Value);
if(Level == 6 && item.getStatus() == 2) {
if(Value == 1) { // 200
player.HelpExp200 = 1;
} else if(Value == 2) { // 50
player.HelpExp150 = 1;
} else if(Value == 3) { // 30
player.HelpExp130 = 1;
}
}
if(Level == 7 && item.getStatus() == 2) {
if(Value == 1) { // 200
player.HelpGp200 = 1;
} else if(Value == 2) { // 50
player.HelpGp150 = 1;
} else if(Value == 3) { // 30
player.HelpGp130 = 1;
}
}
}
}
}
if(getConnection().getPlayer().TotalPlayMinutes == -1) {
getConnection().getPlayer().TotalPlayMinutes = -2;
for(Event c : Application.play60Min) {
if(c.startTime < DateTimeUtil.getDateTime() && c.finishTime > DateTimeUtil.getDateTime()) {
getConnection().getPlayer().TotalPlayMinutes = c.time;
}
}
}
sendPacket(new SM_ENTER());
FriendUpdate.sendFriendUpdate(getConnection());
}
}