-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6180 from Scoppio/fix/blkfile-parser-encoding
Fix/blkfile parser encoding
- Loading branch information
Showing
3 changed files
with
43 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* MegaMek - Copyright (C) 2000-2002 Ben Mazur ([email protected]) | ||
* MegaMek - Copyright (C) 2000-2024 Ben Mazur ([email protected]) | ||
* | ||
* 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 | ||
|
@@ -385,17 +385,14 @@ public List<String> getDataAsVector(String blockName) { | |
/** | ||
* Clears the <CODE>rawData</CODE> Vector and inserts a default comment and | ||
* <I>BlockVersion</I> information. | ||
* | ||
* @return Returns true on success. | ||
*/ | ||
public boolean createNewBlock() { | ||
public void createNewBlock() { | ||
rawData.clear(); | ||
writeBlockComment("Saved from version " + SuiteConstants.VERSION + " on " + LocalDate.now()); | ||
return true; | ||
} | ||
|
||
/** | ||
* @see writeBlockData (String, Vector) | ||
* @see #writeBlockData (String, Vector) | ||
*/ | ||
public boolean writeBlockData(String blockName, String blockData) { | ||
String[] temp = new String[1]; | ||
|
@@ -405,7 +402,7 @@ public boolean writeBlockData(String blockName, String blockData) { | |
} | ||
|
||
/** | ||
* @see writeBlockData (String, Vector) | ||
* @see #writeBlockData (String, Vector) | ||
*/ | ||
public boolean writeBlockData(String blockName, int blockData) { | ||
String[] temp = new String[1]; | ||
|
@@ -414,7 +411,7 @@ public boolean writeBlockData(String blockName, int blockData) { | |
} | ||
|
||
/** | ||
* @see writeBlockData (String, Vector) | ||
* @see #writeBlockData (String, Vector) | ||
*/ | ||
public boolean writeBlockData(String blockName, int[] blockData) { | ||
String[] temp = new String[blockData.length]; | ||
|
@@ -426,7 +423,7 @@ public boolean writeBlockData(String blockName, int[] blockData) { | |
} | ||
|
||
/** | ||
* @see writeBlockData (String, Vector) | ||
* @see #writeBlockData (String, Vector) | ||
*/ | ||
public boolean writeBlockData(String blockName, float blockData) { | ||
String[] temp = new String[1]; | ||
|
@@ -435,7 +432,7 @@ public boolean writeBlockData(String blockName, float blockData) { | |
} | ||
|
||
/** | ||
* @see writeBlockData (String, Vector) | ||
* @see #writeBlockData (String, Vector) | ||
*/ | ||
public boolean writeBlockData(String blockName, double blockData) { | ||
String[] temp = new String[1]; | ||
|
@@ -444,7 +441,7 @@ public boolean writeBlockData(String blockName, double blockData) { | |
} | ||
|
||
/** | ||
* @see writeBlockData (String, Vector) | ||
* @see #writeBlockData (String, Vector) | ||
*/ | ||
public boolean writeBlockData(String blockName, float[] blockData) { | ||
String[] temp = new String[blockData.length]; | ||
|
@@ -455,7 +452,7 @@ public boolean writeBlockData(String blockName, float[] blockData) { | |
} | ||
|
||
/** | ||
* @see writeBlockData (String, Vector) | ||
* @see #writeBlockData (String, Vector) | ||
*/ | ||
public boolean writeBlockData(String blockName, String[] blockData) { | ||
return writeBlockData(blockName, makeVector(blockData)); | ||
|
@@ -497,15 +494,14 @@ public boolean writeBlockComment(String theComment) { | |
/** | ||
* Writes the buildingBlock data to a file. | ||
* | ||
* @param fileName File to write. Overwrites existing files. | ||
* @param file File to write. Overwrites existing files. | ||
* @return true on success. | ||
*/ | ||
public boolean writeBlockFile(String fileName) { | ||
File file = new File(fileName); | ||
public boolean writeBlockFile(File file) { | ||
|
||
if (file.exists()) { | ||
if (!file.delete()) { | ||
logger.error("Unable to delete file with name " + fileName); | ||
logger.error("Unable to delete file with name " + file); | ||
return false; | ||
} | ||
} | ||
|
@@ -520,7 +516,7 @@ public boolean writeBlockFile(String fileName) { | |
|
||
bw.flush(); | ||
} catch (Exception e) { | ||
logger.error("Unable to save block file " + fileName, e); | ||
logger.error("Unable to save block file " + file.getPath(), e); | ||
return false; | ||
} | ||
|
||
|
@@ -614,7 +610,7 @@ public String[] getAllDataAsString() { | |
/** | ||
* Just about the same as the <CODE>getVector()</CODE> command. | ||
* | ||
* @see getVector () | ||
* @see #getVector() | ||
* @return Returns the <CODE>rawData</CODE> Vector. | ||
*/ | ||
public Vector<String> getAllDataAsVector() { | ||
|
@@ -646,29 +642,28 @@ public int getReturnedArraySize(String[] array) { | |
|
||
// for those of us who like doing things indirectly ; -? | ||
/** | ||
* @see getReturnedArraySize (String[]) | ||
* @see #getReturnedArraySize (String[]) | ||
*/ | ||
public int getReturnedArraySize(int[] array) { | ||
return array[0]; | ||
} | ||
|
||
/** | ||
* @see getReturnedArraySize (String[]) | ||
* @see #getReturnedArraySize (String[]) | ||
* @return Returns <CODE>array.size()</CODE> | ||
*/ | ||
public int getReturnedArraySize(Vector<Object> array) { | ||
return array.size(); | ||
} | ||
|
||
/** | ||
* @see getReturnedArraySize (String[]) | ||
* @see #getReturnedArraySize (String[]) | ||
*/ | ||
public int getReturnedArraySize(float[] array) { | ||
try { | ||
return Integer.parseInt("" + array[0]); | ||
} catch (Exception ignored) { | ||
logger.error( | ||
"Couldn't find array size at [0]...is this an array I returned...? Trying to find the size anyway..."); | ||
logger.error("Couldn't find array size at [0], is this an array I returned? Trying to find the size anyway"); | ||
return this.countArray(array); | ||
} | ||
} | ||
|
@@ -685,15 +680,15 @@ public int countArray(String[] array) { | |
} | ||
|
||
/** | ||
* @see countArray( String[] ) | ||
* @see #countArray( String[] ) | ||
*/ | ||
public int countArray(float[] array) { | ||
|
||
return array.length; | ||
} | ||
|
||
/** | ||
* @see countArray( String[] ) | ||
* @see #countArray( String[] ) | ||
*/ | ||
public int countArray(int[] array) { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters