Merge branch 'master_test_hw' into master_test_hw_i18n
commit
0e1dad5f4a
|
@ -238,7 +238,7 @@ public class HandlerLogicThread extends Thread{
|
|||
}
|
||||
|
||||
public static boolean checkOpen(User user, SGlobalSystemConfig sGlobalSystemConfig) {
|
||||
if(!GlobalDataManaager.getInstance().checkIsOpen(sGlobalSystemConfig.getId())){
|
||||
if(sGlobalSystemConfig == null || !GlobalDataManaager.getInstance().checkIsOpen(sGlobalSystemConfig.getId())){
|
||||
return false;
|
||||
}
|
||||
int level = user.getPlayerInfoManager().getLevel();
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
public class LoginConfirmHandler extends BaseHandler{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginRequestHandler.class);
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.LOGIN_CONFIRM_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
UserManager.loginConfirm();
|
||||
MessageUtil.sendMessage(iSession,1,
|
||||
MessageTypeProto.MessageType.LOGIN_CONFIRM_RESPONSE.getNumber(),null,true);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,7 @@ public class RankHandler extends BaseHandler<PlayerInfoProto.RankRequest> {
|
|||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.RankRequest proto) throws Exception {
|
||||
RankLogic.getInstance().getRank(iSession,proto.getType(),proto.getActiviteId(),MessageTypeProto.MessageType.GET_ONE_RANK_RESPONSE);
|
||||
RankLogic.getInstance().getRank(iSession,proto.getType(),proto.getActiviteId(),
|
||||
proto.getIndex(),MessageTypeProto.MessageType.GET_ONE_RANK_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,14 @@ package com.ljsd.jieling.handler.hero;
|
|||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import config.SItem;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
@ -68,6 +71,24 @@ public class DoHeroChangeRequestHandler extends BaseHandler<HeroInfoProto.DoHer
|
|||
newHero.setJewelInfo(hero.getJewelInfo());
|
||||
user.getHeroManager().addHero(newHero);
|
||||
drop.addHero(CBean2Proto.getHero(newHero));
|
||||
//新头像
|
||||
SItem sItem = SItem.getsItemMap().get(hero.getChangeId());
|
||||
if(sItem != null){
|
||||
if(sItem.getExtraReward()!=null && sItem.getExtraReward().length>1){
|
||||
int[] drops = sItem.getExtraReward()[1];
|
||||
if(user.getItemManager().getItem(drops[0]) == null){
|
||||
int[][] extraDrops = new int[1][2];
|
||||
extraDrops[0] = new int[2];
|
||||
extraDrops[0][0] = drops[0];
|
||||
extraDrops[0][1] =1;
|
||||
if(sItem.getExtraReward()[0][0] == 0){
|
||||
ItemUtil.drop(user,extraDrops, BIReason.EXTRA_DROP_REWARD);
|
||||
}else{
|
||||
ItemUtil.drop(user,extraDrops,CommonProto.Drop.newBuilder(),BIReason.EXTRA_DROP_REWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return HeroInfoProto.DoHeroChangeResponse.newBuilder().setDrop(drop).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,17 +11,23 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
public class OnlineUserManager {
|
||||
|
||||
public static void userOnline(int uid, ISession session) {
|
||||
tokenMap.put(session.getToken(),uid);
|
||||
sessionMap.put(uid, session);
|
||||
}
|
||||
|
||||
public static Map<Integer, ISession> sessionMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static Map<Integer,Integer> tokenMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static void checkOnline(){
|
||||
UserManager.checkOffline();
|
||||
}
|
||||
|
||||
|
||||
public static void userOffline(int uid) {
|
||||
if(sessionMap.containsKey(uid)){
|
||||
tokenMap.remove(sessionMap.get(uid).getToken());
|
||||
}
|
||||
sessionMap.remove(uid);
|
||||
}
|
||||
|
||||
|
@ -50,23 +56,10 @@ public class OnlineUserManager {
|
|||
}
|
||||
return sessionMap.containsKey(uid);
|
||||
}
|
||||
|
||||
static class DefinaMap<k,v> extends HashMap<k,v>{
|
||||
|
||||
@Override
|
||||
public boolean remove(Object key, Object value) {
|
||||
return super.remove(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public v put(k key, v value) {
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
public static boolean checkOnlineByToken(int token) {
|
||||
if (tokenMap == null) {
|
||||
return true;
|
||||
}
|
||||
return tokenMap.containsKey(token);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -165,18 +165,18 @@ public class Hero extends MongoBase {
|
|||
public int getLevel(HeroManager heroManager) {
|
||||
// 英雄 配置表信息
|
||||
SCHero scHero = SCHero.getsCHero().get(templateId);
|
||||
SCHeroRankUpConfig config = STableManager.getConfig(SCHeroRankUpConfig.class).get(scHero.getMaxRank());
|
||||
int maxLevel = scHero.getMaxLevel();
|
||||
|
||||
// 如果鸿蒙碑开启 返回鸿蒙系统中神将返回鸿蒙碑等级
|
||||
if (heroManager.getHongmengTablet() > 0){
|
||||
// 存在共鸣或者使者
|
||||
if (heroManager.getResonances().values().contains(id) || heroManager.getHongmengGuards().values().contains(id)) {
|
||||
// 鸿蒙碑超过等级上限,返回鸿蒙碑等级
|
||||
if (heroManager.getHongmengTablet() <= config.getOpenLevel()){
|
||||
if (heroManager.getHongmengTablet() <= maxLevel){
|
||||
return heroManager.getHongmengTablet();
|
||||
}
|
||||
// 最高品质大于等于10的英雄,返回鸿蒙碑等级,否则返回上限等级
|
||||
return scHero.getMaxRank() >= 10?heroManager.getHongmengTablet():config.getOpenLevel();
|
||||
return scHero.getMaxRank() >= 10?heroManager.getHongmengTablet():maxLevel;
|
||||
}
|
||||
}
|
||||
if (heroManager.getResonances().values().contains(id)) {
|
||||
|
@ -184,7 +184,7 @@ public class Hero extends MongoBase {
|
|||
HongMengAddAttribute hongMengAddAttribute = heroManager.getResonanceAddition().get(HongMengAttributeEnum.LEVEL);
|
||||
if (hongMengAddAttribute != null) {
|
||||
// 是否达到限制等级
|
||||
return hongMengAddAttribute.value >= config.getOpenLevel() ? config.getOpenLevel():hongMengAddAttribute.value;
|
||||
return hongMengAddAttribute.value >= maxLevel ? maxLevel:hongMengAddAttribute.value;
|
||||
}
|
||||
}
|
||||
return level;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
|
@ -17,6 +18,7 @@ import com.ljsd.jieling.logic.hero.HeroLogic;
|
|||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.SysUtil;
|
||||
import config.SGameSetting;
|
||||
import config.SPlayerLevelConfig;
|
||||
import manager.STableManager;
|
||||
|
@ -24,17 +26,22 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UserManager {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserManager.class);
|
||||
private static Map<Integer, User> userMap = new ConcurrentHashMap<>();
|
||||
private static Map<Integer,Long> userMapPutTime = new ConcurrentHashMap<>(); //离线读入
|
||||
private static AtomicInteger login_f_num = new AtomicInteger(0);//登陆计数
|
||||
private static final int LOGIN_F_LIMIT = 100;//报警界限
|
||||
|
||||
public static void addUser(User user) {
|
||||
userMap.put(user.getId(), user);
|
||||
|
@ -194,4 +201,27 @@ public class UserManager {
|
|||
|
||||
return "33521";
|
||||
}
|
||||
|
||||
public static void loginIncrease(){
|
||||
if(login_f_num.incrementAndGet() >= LOGIN_F_LIMIT){
|
||||
String path = SysUtil.getPath("conf/loginerror/loginerror"+ GameApplication.serverId +".txt");
|
||||
File file = new File(path);
|
||||
try{
|
||||
if(!file.getParentFile().exists()){
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
if(!file.exists()){
|
||||
file.createNewFile();
|
||||
LOGGER.info("生成登陆限制文件!"+TimeUtils.getTimeStamp(System.currentTimeMillis()));
|
||||
}
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void loginConfirm(){
|
||||
login_f_num.decrementAndGet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -143,7 +143,6 @@ public class GuildLogic {
|
|||
|
||||
for(Set<Integer> members : guildInfo.getMembers().values()){
|
||||
for(int uidOfMember : members){
|
||||
LOGGER.info("errorMember:{}",uidOfMember);
|
||||
User userMember = UserManager.getUser(uidOfMember);
|
||||
builder.addFamilyWalkIndicaiton(CBean2Proto.getFamilyWalkIndicaiton(userMember));
|
||||
}
|
||||
|
|
|
@ -698,7 +698,6 @@ public class FriendLogic {
|
|||
friendManager.setHaveRewardMap(new HashMap<>());
|
||||
for (Map.Entry<Integer,Integer> entry: giveMap.entrySet()){
|
||||
Integer friendId = entry.getKey();
|
||||
LOGGER.info("FriendId:{}",friendId);
|
||||
User friendUser = UserManager.getUser(friendId);
|
||||
FriendManager friendManager1 = friendUser.getFriendManager();
|
||||
Map<Integer, Integer> haveRewardMap = friendManager1.getHaveRewardMap();
|
||||
|
|
|
@ -250,7 +250,7 @@ public class MailLogic {
|
|||
int[][] itemArr = StringUtil.parseFiledInt2(mailItem.toString());
|
||||
// 检测卡牌和装备背包
|
||||
int limit = ItemUtil.checkCardAndEquipLimit(user,itemArr);
|
||||
int state = 1;
|
||||
int state = 0;
|
||||
if (limit == 0){
|
||||
// 领取道具
|
||||
state = ItemUtil.dropByMail(user, itemArr, dropBuilder, BIReason.TAKE_MAIL_REWARD);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class RankLogic {
|
|||
public static class Instance {
|
||||
public final static RankLogic instance = new RankLogic();
|
||||
}
|
||||
public void getRank(ISession session, int type, int activityId,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
public void getRank(ISession session, int type, int activityId,int index,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
LOGGER.info("获取排行榜信息type={},activityId={}",type,activityId);
|
||||
int page = 1;
|
||||
String rkey = "";
|
||||
|
@ -73,7 +73,7 @@ public class RankLogic {
|
|||
}
|
||||
|
||||
}else{
|
||||
rankResponse = rank.getRank(session.getUid(),rkey,1, -1);
|
||||
rankResponse = rank.getRank(session.getUid(),rkey,index/20+1, 20);
|
||||
}
|
||||
ReportUtil.onReportEvent(UserManager.getUser(session.getUid()), ReportEventEnum.CHECK_RANKING.getType(),String.valueOf(type));
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),rankResponse,true);
|
||||
|
|
|
@ -47,8 +47,8 @@ public abstract class AbstractRank implements IRank {
|
|||
}
|
||||
int start = (page - 1) * rankEndLine, end = page * rankEndLine - 1;
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = getRankByKey(rkey,start,end);
|
||||
if(start==0){
|
||||
start=1;
|
||||
if(start%rankEndLine == 0){
|
||||
start++;
|
||||
}
|
||||
PlayerInfoProto.RankResponse.Builder allUserResponse = getAllUserResponse(zsetreverseRangeWithScores,start);
|
||||
//当前用户信息
|
||||
|
|
|
@ -98,8 +98,16 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
//聊天请求太多了 过滤掉
|
||||
LOGGER.info("request={} commond ={}: ", packetNetData.getUserId(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
|
||||
}
|
||||
if (packetNetData.getMsgId() == MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE ||
|
||||
packetNetData.getMsgId() == MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE) {
|
||||
if (packetNetData.getMsgId() == MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE) {
|
||||
UserManager.loginIncrease();
|
||||
if (!onLoginORReLoginRequest(session, packetNetData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//在线列表加入session
|
||||
OnlineUserManager.userOnline(session.getUid(), session);
|
||||
}
|
||||
if(packetNetData.getMsgId() == MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
|
||||
if (!onLoginORReLoginRequest(session, packetNetData)) {
|
||||
return;
|
||||
}
|
||||
|
@ -131,7 +139,7 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
|
||||
|
||||
private void dealHeartBeat(ISession session) {
|
||||
session.setHeartBreatNums(3);
|
||||
session.setHeartBreatNums(4);
|
||||
MessageUtil.sendHeartBeat(session);
|
||||
}
|
||||
|
||||
|
@ -170,7 +178,7 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
*/
|
||||
private int onRepeatLogin(ISession newSession) {
|
||||
int uid = newSession.getUid();
|
||||
if (OnlineUserManager.checkUidOnline(uid)) {
|
||||
if (OnlineUserManager.checkUidOnline(uid)&&!OnlineUserManager.checkOnlineByToken(newSession.getToken())) {
|
||||
ISession iSession = OnlineUserManager.getSessionByUid(uid);
|
||||
if (iSession == newSession) {
|
||||
return 0;
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ISession extends NettyGameSession {
|
|||
}
|
||||
}
|
||||
|
||||
private int heartBreatNums = 3;
|
||||
private int heartBreatNums = 4;
|
||||
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
|
|
|
@ -783,7 +783,7 @@ public class ItemUtil {
|
|||
*/
|
||||
public static int addItemByMail(User user, Map<Integer, Integer> itemMap,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception {
|
||||
if (itemMap.isEmpty()) {
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
List<CommonProto.Item> itemProtoList = new CopyOnWriteArrayList<>();
|
||||
ItemManager itemManager = user.getItemManager();
|
||||
|
|
|
@ -58,6 +58,8 @@ public class SCHero implements BaseConfig{
|
|||
|
||||
private int job;
|
||||
|
||||
private int maxLevel;
|
||||
|
||||
private Map<Integer,Integer> secondaryFactorMap;
|
||||
|
||||
private Map<Integer, List<Integer>> skillListByStar;
|
||||
|
@ -342,4 +344,8 @@ public class SCHero implements BaseConfig{
|
|||
public int getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue