Commit 9220dd46 authored by fallenstardust's avatar fallenstardust

fix makeMd5 边界溢出

是卡包的场合下extra和side边界设为0
parent 64780612
...@@ -403,7 +403,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement ...@@ -403,7 +403,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
if (deckinfo != null) { if (deckinfo != null) {
loadData(deckinfo, isPack); loadData(deckinfo, isPack);
} }
if (!isPack) mDeckMd5 = DeckItemUtils.makeMd5(mItems); mDeckMd5 = DeckItemUtils.makeMd5(mItems);
} }
public DeckInfo read(CardLoader cardLoader, File file, LimitList limitList) { public DeckInfo read(CardLoader cardLoader, File file, LimitList limitList) {
......
...@@ -19,19 +19,25 @@ public class DeckItem { ...@@ -19,19 +19,25 @@ public class DeckItem {
public static void resetLabel(DeckInfo deckInfo, boolean isPack) { public static void resetLabel(DeckInfo deckInfo, boolean isPack) {
if (!isPack) { if (!isPack) {
MainEnd = MainStart + Constants.DECK_MAIN_MAX - 1; MainEnd = MainStart + Constants.DECK_MAIN_MAX - 1;
ExtraLabel = MainEnd + 1;
ExtraStart = ExtraLabel + 1;
ExtraEnd = ExtraStart + Constants.DECK_EXTRA_COUNT - 1;
SideLabel = ExtraEnd + 1;
SideStart = SideLabel + 1;
SideEnd = SideStart + Constants.DECK_SIDE_COUNT - 1;
} else { } else {
if(deckInfo.getMainCount() <= Constants.DECK_MAIN_MAX) { if(deckInfo.getMainCount() <= Constants.DECK_MAIN_MAX) {
MainEnd = MainStart + Constants.DECK_MAIN_MAX - 1; MainEnd = MainStart + Constants.DECK_MAIN_MAX - 1;
} else { } else {
MainEnd = MainStart + deckInfo.getMainCount() - 1; MainEnd = MainStart + deckInfo.getMainCount() - 1;
} }
ExtraLabel = 0;
ExtraStart = 0;
ExtraEnd = 0;
SideLabel = 0;
SideStart = 0;
SideEnd = 0;
} }
ExtraLabel = MainEnd + 1;
ExtraStart = ExtraLabel + 1;
ExtraEnd = ExtraStart + Constants.DECK_EXTRA_COUNT - 1;
SideLabel = ExtraEnd + 1;
SideStart = SideLabel + 1;
SideEnd = SideStart + Constants.DECK_SIDE_COUNT - 1;
} }
private DeckItemType mType; private DeckItemType mType;
......
...@@ -18,7 +18,7 @@ class DeckItemUtils { ...@@ -18,7 +18,7 @@ class DeckItemUtils {
public static String makeMd5(List<DeckItem> items) { public static String makeMd5(List<DeckItem> items) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("#main"); stringBuilder.append("#main");
for (int i = DeckItem.MainStart; i < DeckItem.MainStart + Constants.DECK_MAIN_MAX; i++) { for (int i = DeckItem.MainStart; i < DeckItem.MainStart + items.size(); i++) {
DeckItem deckItem = items.get(i); DeckItem deckItem = items.get(i);
if (deckItem.getType() == DeckItemType.Space) { if (deckItem.getType() == DeckItemType.Space) {
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment