校验地图操作合法性

back_recharge
wangyuan 2019-06-14 15:24:10 +08:00
parent b0d91d6e6a
commit 16434c21ce
2 changed files with 59 additions and 0 deletions

View File

@ -17,15 +17,55 @@ import com.ljsd.jieling.util.MessageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
public class HandlerLogicThread extends Thread{
private static final Logger LOGGER = LoggerFactory.getLogger(HandlerLogicThread.class);
private static Set<Integer> whiteMsg = new HashSet<>();
static {
whiteMsg.add(MessageTypeProto.MessageType.MAP_ENTER_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_START_EXPLORE_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_UDPATE_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.EVENT_UPDATE_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_FAST_FIGHT_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.FIGHT_START_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.FIGHT_END_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_OUT_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_PLAYERINFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_VIP_MISSION_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ITEMINFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_EQUIP_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_POKEMON_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_HEROINFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_TEAMPOS_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_WORKSHOP_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_MAIL_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_LEVE_DIFFICULTT_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_ACTIVITY_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_FUNCTIONOFTIME_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_SECRETBOX_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_DAILY_MISSION_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ADVENTURE_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_FRIEND_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_STARE_INFOS_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ARENA_INFO_REQUEST_VALUE);
//日后删除
whiteMsg.add(MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE);
}
public ConcurrentLinkedQueue<PacketNetData> handlerLinkedQueue = new ConcurrentLinkedQueue();
@Override
public void run() {
while (GameApplication.start) {
@ -58,6 +98,11 @@ public class HandlerLogicThread extends Thread{
MessageUtil.sendErrorResponse(session,0,msgId+1,"funciton not");
return;
}
b = checkIsPermit(msgId, session);
if(!b){
MessageUtil.sendErrorResponse(session,0,msgId+1,"在地图探索中,不可以操作");
return;
}
}
@ -73,6 +118,17 @@ public class HandlerLogicThread extends Thread{
}
private boolean checkIsPermit(int msgId,ISession session) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
int curMapId = user.getMapManager().getCurMapId();
if(curMapId!=0 && !whiteMsg.contains(msgId)){
return false;
}
return true;
}
private boolean checkFunctionIsOpen(int msgId,ISession session ) {
int uid = session.getUid();
try {

View File

@ -159,6 +159,9 @@ public class MapLogic {
mapManager.setCurMapId(mapId);
initMap(mapManager, user);
user.setMapManager(mapManager);
}else if(mapManager.getCurMapId()!=mapId){
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "地图错误,应进入" + mapManager.getCurMapId());
return;
}
List<CommonProto.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size());
for (Map.Entry<Integer, Cell> entry : mapManager.getMapInfo().entrySet()) {