Skip to content

Commit 8c6ea0a

Browse files
committed
Merge remote-tracking branch 'origin/2013' into 2014
2 parents 93f9b2d + 5f76f9c commit 8c6ea0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+347
-157
lines changed

.github/workflows/maven.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on: [ push, pull_request ]
88
jobs:
99
build:
1010
strategy:
11+
fail-fast: false
1112
matrix:
1213
os: [ ubuntu-latest, windows-latest, macos-latest ]
1314
distribution: [ temurin, zulu ]

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
11
# PS2 PES 2014 Option File Editor
22

3+
[![Java CI](https://github.com/nthachus/pes-editor/actions/workflows/maven.yml/badge.svg)](https://github.com/nthachus/pes-editor/actions/workflows/maven.yml)
4+
35
PlayStation 2 - Pro Evolution Soccer 2014 Option File Editor
46

57
- Fix almost bugs of original version.
68
- Multilingual support
79

810
## CONTRIBUTING
911

10-
### Using [Docker](https://docs.docker.com/)
12+
### Development using [Docker](https://docs.docker.com/)
13+
14+
Build this project with the command:
1115

1216
```batch
1317
docker run --rm -it -v "%PWD%/.mvn:/root/.m2" -v "%PWD%:/usr/src/app" -w /usr/src/app openjdk:7-jdk-alpine ./mvnw -B clean verify
1418
```
1519

1620
**Note** that `%PWD%` is the project working directory in `Unix` format, such as: `/c/Users/source/repos/pes-editor`
1721

22+
### Analyze source code with [SonarQube](https://www.sonarqube.org/)
23+
24+
Download [SonarQube Docker image](https://hub.docker.com/_/sonarqube/) and start the server:
25+
26+
```batch
27+
docker pull sonarqube:community
28+
docker run --rm -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube -Dsonar.telemetry.enable=false
29+
```
30+
31+
Login to http://localhost:9000/ using `Administrator` account (admin/admin) and configure the project to analyze.
32+
For more details, see: https://docs.sonarqube.org/latest/setup/get-started-2-minutes/
33+
34+
Then run Maven goal `sonar:sonar` to analyze the project:
35+
36+
```batch
37+
docker run --rm -it --link sonarqube -v "%PWD%/.mvn:/root/.m2" -v "%PWD%:/usr/src/app" -w /usr/src/app openjdk:11-jre-slim ^
38+
./mvnw -B sonar:sonar "-Dsonar.host.url=http://sonarqube:9000" -Dsonar.projectKey=pes-editor -Dsonar.login=<projectToken>
39+
```
40+
1841
## DONATIONS
1942

2043
[![](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=46LYJ44VJXAB6)

pom.xml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
<artifactId>maven-clean-plugin</artifactId>
3434
<version>2.6.1</version>
3535
</plugin>
36-
<!-- TODO: check -->
36+
<plugin>
37+
<groupId>org.sonarsource.scanner.maven</groupId>
38+
<artifactId>sonar-maven-plugin</artifactId>
39+
<version>3.3.0.603</version>
40+
</plugin>
41+
3742
<plugin>
3843
<artifactId>maven-resources-plugin</artifactId>
3944
<version>2.7</version>
@@ -139,4 +144,43 @@
139144
<scope>test</scope>
140145
</dependency>
141146
</dependencies>
147+
148+
<profiles>
149+
<!-- Global settings of SonarScanner for Maven -->
150+
<profile>
151+
<id>sonar</id>
152+
<activation>
153+
<property>
154+
<name>sonar.login</name>
155+
</property>
156+
</activation>
157+
<properties>
158+
<sonar.issue.ignore.multicriteria>commentBlock,constantName,dupString,declareLine, complexMethod,publicMutable,
159+
tooManyParams,dupCodeBlock,subExpression,rawGeneric</sonar.issue.ignore.multicriteria>
160+
161+
<sonar.issue.ignore.multicriteria.commentBlock.ruleKey>java:S125</sonar.issue.ignore.multicriteria.commentBlock.ruleKey>
162+
<sonar.issue.ignore.multicriteria.commentBlock.resourceKey>**</sonar.issue.ignore.multicriteria.commentBlock.resourceKey>
163+
<sonar.issue.ignore.multicriteria.constantName.ruleKey>java:S115</sonar.issue.ignore.multicriteria.constantName.ruleKey>
164+
<sonar.issue.ignore.multicriteria.constantName.resourceKey>**</sonar.issue.ignore.multicriteria.constantName.resourceKey>
165+
<sonar.issue.ignore.multicriteria.dupString.ruleKey>java:S1192</sonar.issue.ignore.multicriteria.dupString.ruleKey>
166+
<sonar.issue.ignore.multicriteria.dupString.resourceKey>**</sonar.issue.ignore.multicriteria.dupString.resourceKey>
167+
<sonar.issue.ignore.multicriteria.declareLine.ruleKey>java:S1659</sonar.issue.ignore.multicriteria.declareLine.ruleKey>
168+
<sonar.issue.ignore.multicriteria.declareLine.resourceKey>**</sonar.issue.ignore.multicriteria.declareLine.resourceKey>
169+
<sonar.issue.ignore.multicriteria.complexMethod.ruleKey>java:S3776</sonar.issue.ignore.multicriteria.complexMethod.ruleKey>
170+
<sonar.issue.ignore.multicriteria.complexMethod.resourceKey>**</sonar.issue.ignore.multicriteria.complexMethod.resourceKey>
171+
<sonar.issue.ignore.multicriteria.publicMutable.ruleKey>java:S2386</sonar.issue.ignore.multicriteria.publicMutable.ruleKey>
172+
<sonar.issue.ignore.multicriteria.publicMutable.resourceKey>**</sonar.issue.ignore.multicriteria.publicMutable.resourceKey>
173+
174+
<sonar.issue.ignore.multicriteria.tooManyParams.ruleKey>java:S107</sonar.issue.ignore.multicriteria.tooManyParams.ruleKey>
175+
<sonar.issue.ignore.multicriteria.tooManyParams.resourceKey>**</sonar.issue.ignore.multicriteria.tooManyParams.resourceKey>
176+
<sonar.issue.ignore.multicriteria.dupCodeBlock.ruleKey>java:S1871</sonar.issue.ignore.multicriteria.dupCodeBlock.ruleKey>
177+
<sonar.issue.ignore.multicriteria.dupCodeBlock.resourceKey>**</sonar.issue.ignore.multicriteria.dupCodeBlock.resourceKey>
178+
<sonar.issue.ignore.multicriteria.subExpression.ruleKey>java:S1121</sonar.issue.ignore.multicriteria.subExpression.ruleKey>
179+
<sonar.issue.ignore.multicriteria.subExpression.resourceKey>**</sonar.issue.ignore.multicriteria.subExpression.resourceKey>
180+
<sonar.issue.ignore.multicriteria.rawGeneric.ruleKey>java:S3740</sonar.issue.ignore.multicriteria.rawGeneric.ruleKey>
181+
<sonar.issue.ignore.multicriteria.rawGeneric.resourceKey>**</sonar.issue.ignore.multicriteria.rawGeneric.resourceKey>
182+
</properties>
183+
</profile>
184+
</profiles>
185+
142186
</project>

src/main/java/editor/SplashWindow.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public final class SplashWindow extends Window implements MouseListener {
4949
/**
5050
* The current instance of the splash window. (Singleton design pattern).
5151
*/
52-
private static volatile SplashWindow instance = null;
52+
private static/* volatile*/ SplashWindow instance = null;
5353

5454
/**
5555
* The splash image which is displayed on the splash window.
@@ -84,7 +84,7 @@ private SplashWindow(Frame parent, Image image) {
8484
mt.addImage(image, 0);
8585
try {
8686
mt.waitForID(0);
87-
} catch (InterruptedException ie) {
87+
} catch (InterruptedException ie) { //NOSONAR java:S2142
8888
log.warn(ie.toString());
8989
}
9090

@@ -123,20 +123,25 @@ public void mouseClicked(MouseEvent e) {
123123
}
124124

125125
public void mousePressed(MouseEvent e) {
126+
// Handle mouse click event only
126127
}
127128

128129
public void mouseReleased(MouseEvent e) {
130+
// Handle mouse click event only
129131
}
130132

131133
public void mouseEntered(MouseEvent e) {
134+
// Handle mouse click event only
132135
}
133136

134137
public void mouseExited(MouseEvent e) {
138+
// Handle mouse click event only
135139
}
136140

137141
/**
138142
* Updates the display area of the window.
139143
*/
144+
@Override
140145
public void update(Graphics g) {
141146
// [*] Since the paint method is going to draw an
142147
// image that covers the complete area of the component we
@@ -147,6 +152,7 @@ public void update(Graphics g) {
147152
/**
148153
* Paints the image on the window.
149154
*/
155+
@Override
150156
public void paint(Graphics g) {
151157
if (null == g) {
152158
throw new NullArgumentException("g");
@@ -168,14 +174,19 @@ public void paint(Graphics g) {
168174
*
169175
* @param image The splash image.
170176
*/
171-
@SuppressWarnings("SynchronizeOnNonFinalField")
172177
public static void splash(Image image) {
173178
if (instance != null || image == null) {
174179
return;
175180
}
176181

177182
// Create the splash image
178-
instance = new SplashWindow(new Frame(), image);
183+
SplashWindow splasher = new SplashWindow(new Frame(), image);
184+
synchronized (log) {
185+
if (instance != null) {
186+
return;
187+
}
188+
instance = splasher;
189+
}
179190

180191
// Show the window.
181192
instance.setVisible(true);
@@ -186,11 +197,11 @@ public static void splash(Image image) {
186197
// If more than one processor is available, we don't wait,
187198
// and maximize CPU throughput instead.
188199
if (!EventQueue.isDispatchThread() && Runtime.getRuntime().availableProcessors() == 1) {
189-
synchronized (instance) {
200+
synchronized (log) {
190201
while (!instance.isPaintCalled) {
191202
try {
192203
instance.wait();
193-
} catch (InterruptedException e) {
204+
} catch (InterruptedException e) { //NOSONAR java:S2142
194205
log.warn(e.toString());
195206
}
196207
}

src/main/java/editor/data/Clubs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static int getStadium(OptionFile of, int club) {
179179
int adr = getOffset(club) + 81;
180180

181181
// auto-fix club stadium ID
182-
return (int) Bits.toInt(of.getData(), adr, 1, Stadiums.TOTAL - 1);
182+
return (int) Bits.toInt(of.getData(), adr, 1, -1L + Stadiums.TOTAL);
183183
}
184184

185185
public static void setStadium(OptionFile of, int club, int stadium) {
@@ -207,7 +207,7 @@ public static int getBackFlag(OptionFile of, int club) {
207207
int adr = getOffset(club) + 70;
208208

209209
// auto-fix club background-flag ID
210-
return (int) Bits.toInt(of.getData(), adr, 1, TOTAL_BACK_FLAGS - 1);
210+
return (int) Bits.toInt(of.getData(), adr, 1, -1L + TOTAL_BACK_FLAGS);
211211
}
212212

213213
public static void setBackFlag(OptionFile of, int club, int backFlag) {

src/main/java/editor/data/CsvMaker.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ private void writePlayer(OptionFile of, DataOutput out, int player, String[] clu
104104
out.write(separator);
105105
int v = Stats.getValue(of, player, Stats.REG_POS);
106106
//assert (v >= 0 && v <= Stats.ROLES.length) : "Invalid registered position #" + v + " of player #" + player;
107-
out.writeBytes(v > Stats.ROLES.length ? v + "?" : Stats.ROLES[Stats.regPosToRole(v)] + (v == 1 ? "*" : Strings.EMPTY));
107+
if (v > Stats.ROLES.length) {
108+
out.writeBytes(v + "?");
109+
} else {
110+
out.writeBytes(Stats.ROLES[Stats.regPosToRole(v)] + (v == 1 ? "*" : Strings.EMPTY));
111+
}
108112

109113
out.write(separator);
110114
out.writeBytes(Stats.getString(of, player, Stats.INJURY));
@@ -215,16 +219,18 @@ private void writeTeam(OptionFile of, DataOutput out, int player, String[] clubN
215219
int playerClubNo = 0;
216220
String club = Strings.EMPTY;
217221

218-
outerLoop:
219-
for (int c = 0; c < Clubs.TOTAL; c++) {
222+
boolean found = false;
223+
for (int c = 0; c < Clubs.TOTAL && !found; c++) {
220224
for (int np = 0; np < Formations.CLUB_TEAM_SIZE; np++) {
221225

222226
int p = Squads.getTeamPlayer(of, c + Squads.FIRST_CLUB, np);
223227
if (p == player) {
224228
// get squad number
225229
playerClubNo = Squads.getTeamSquadNum(of, c + Squads.FIRST_CLUB, np);
226230
club = clubNames[c];
227-
break outerLoop;
231+
232+
found = true;
233+
break;
228234
}
229235
}
230236
}

src/main/java/editor/data/Emblems.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ public static boolean fixIndexesTable(OptionFile of) {
414414
/*|| highResIndexes.contains(location)*/
415415
// overwritten emblems
416416
|| lowResIndexes.contains(swapLocation = (TOTAL - 2 * (location + 1)))
417-
|| lowResIndexes.contains(swapLocation + 1)) {
417+
|| lowResIndexes.contains(swapLocation + 1)
418+
) {
418419
setLocationInternal(of, i, EMPTY_IDX_VALUE);
419420
isUpdated = true;
420421
} else {

src/main/java/editor/data/Hairs.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,23 +326,23 @@ public int start() {
326326

327327
public abstract int total();
328328

329-
public Integer getShape(int hair) {
329+
public Integer getShape(int hair) { //NOSONAR java:S1172
330330
return null;
331331
}
332332

333-
public Integer getFront(int hair) {
333+
public Integer getFront(int hair) { //NOSONAR java:S1172
334334
return null;
335335
}
336336

337-
public Integer getVolume(int hair) {
337+
public Integer getVolume(int hair) { //NOSONAR java:S1172
338338
return null;
339339
}
340340

341-
public Integer getDarkness(int hair) {
341+
public Integer getDarkness(int hair) { //NOSONAR java:S1172
342342
return null;
343343
}
344344

345-
public Integer getBandana(int hair) {
345+
public Integer getBandana(int hair) { //NOSONAR java:S1172
346346
return null;
347347
}
348348

src/main/java/editor/data/OptionFile.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public String getSaveName() {
5858
return saveName;
5959
}
6060

61-
@SuppressWarnings("unused")
6261
public void setSaveName(String saveName) {
6362
this.saveName = saveName;
6463
}
@@ -156,7 +155,9 @@ private void loadARMaxFile(RandomAccessFile in) throws IOException {
156155
long crc = crc32.getValue();
157156

158157
if ((int) crc != chk) {
159-
log.warn("Invalid ARMax CRC32 0x{}, expected: 0x{}", Integer.toHexString(chk), Long.toHexString(crc));
158+
if (log.isWarnEnabled()) {
159+
log.warn("Invalid ARMax CRC32 0x{}, expected: 0x{}", Integer.toHexString(chk), Long.toHexString(crc));
160+
}
160161
return;
161162
}
162163

src/main/java/editor/data/Player.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ public int compareTo(Player other) {
149149

150150
int cmp = getName().compareTo(other.getName());
151151
if (cmp == 0) {
152-
cmp = Integer.valueOf(Stats.getValue(of, index, Stats.AGE)).compareTo(
152+
cmp = Integer.valueOf(Stats.getValue(of, index, Stats.AGE)).compareTo( //NOSONAR java:S1158
153153
Stats.getValue(of, other.index, Stats.AGE));
154154

155155
if (cmp == 0) {
156-
cmp = Integer.valueOf(index).compareTo(other.index);
156+
cmp = Integer.valueOf(index).compareTo(other.index); //NOSONAR java:S1158
157157
}
158158
}
159159

0 commit comments

Comments
 (0)