增加自动修复道具缺失itemId异常的问题

master_0.05
DESKTOP-C3M45P4\dengdan 2024-09-23 22:03:03 +08:00
parent 3cdd5403c8
commit 662eb2aa92
2 changed files with 19 additions and 0 deletions

View File

@ -177,6 +177,8 @@ public class GetPlayerInfoHandler extends BaseHandler{
List<CommonProto.PracticeSkillInfo> practiceSkillInfos = getPracticeSkillInfos(heroManager); List<CommonProto.PracticeSkillInfo> practiceSkillInfos = getPracticeSkillInfos(heroManager);
List<CommonProto.FaBaoSoulInfo> faBaoSoulInfos = getFaBaoSoulInfos(heroManager); List<CommonProto.FaBaoSoulInfo> faBaoSoulInfos = getFaBaoSoulInfos(heroManager);
// 道具修复
user.getItemManager().checkItem();
// 开服时间戳 // 开服时间戳
long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime()); long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime());
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse = PlayerInfoProto.GetPlayerInfoResponse.newBuilder() PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse = PlayerInfoProto.GetPlayerInfoResponse.newBuilder()

View File

@ -83,4 +83,21 @@ public class ItemManager extends MongoBase {
addItem(item); addItem(item);
return item; return item;
} }
/**
* itemId
*/
public void checkItem(){
if(itemMap != null){
for(int itemId : itemMap.keySet()){
Item item= itemMap.get(itemId);
if(item != null){
//itemId缺失或者不匹配,需重构
if(item.getItemId() == 0 || item.getItemId() != itemId){
item = this.newItem(itemId,item.getItemNum());
}
}
}
}
}
} }