Skip to content

Commit

Permalink
Merge branch 'release/v0.6.21-alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed Aug 18, 2016
2 parents 9ee1562 + c48fde1 commit e5b830c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ apply plugin: 'distribution'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

version = '0.6.20-alpha'
version = '0.6.21-alpha'

class HttpBuilder extends HTTPBuilder {

Expand Down
18 changes: 1 addition & 17 deletions downlords-faf-client.install4j
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
</applications>
</installerGui>
<mediaSets>
<windows name="Windows" id="26" customizedId="" mediaFileName="" installDir="${compiler:sys.fullName}" overridePrincipalLanguage="false" jreBitType="32" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" useLegacyMediaFileIds="false" legacyMediaFileIds="" downloadURL="" includeAllDownloadableComponents="false" includedJRE="windows-x86-1.8.0_92" manualJREEntry="false" bundleType="2" jreURL="https://github.com/micheljung/jre-bundles/raw/master/windows-x86-1.8.0_92.tar.gz" jreShared="false" directDownload="true" installOnlyIfNecessary="false" customInstallBaseDir="" contentFilesType="1" verifyIntegrity="true">
<windows name="Windows" id="26" customizedId="" mediaFileName="" installDir="${compiler:sys.fullName}" overridePrincipalLanguage="false" jreBitType="32" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" useLegacyMediaFileIds="false" legacyMediaFileIds="" downloadURL="" includeAllDownloadableComponents="false" includedJRE="windows-x86-1.8.0_102" manualJREEntry="false" bundleType="2" jreURL="https://github.com/micheljung/jre-bundles/blob/master/windows-x86-1.8.0_102.tar.gz" jreShared="false" directDownload="true" installOnlyIfNecessary="false" customInstallBaseDir="" contentFilesType="1" verifyIntegrity="true">
<excludedComponents />
<includedDownloadableComponents />
<excludedLaunchers />
Expand All @@ -485,22 +485,6 @@
<customAttributes />
</autoUpdate>
</windows>
<macosFolder name="Mac OS X Folder" id="158" customizedId="" mediaFileName="" installDir="${compiler:sys.fullName}" overridePrincipalLanguage="false" jreBitType="all" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" useLegacyMediaFileIds="false" legacyMediaFileIds="" downloadURL="" includeAllDownloadableComponents="false" includedJRE="macosx-amd64-1.8.0_92" manualJREEntry="false" bundleType="2" jreURL="https://github.com/micheljung/jre-bundles/blob/master/macosx-amd64-1.8.0_92.tar.gz" jreShared="false" directDownload="false" installOnlyIfNecessary="false" appleJre="false" requiredVmIdPrefix="" customInstallBaseDir="" contentFilesType="1" installerName="${i18n:InstallerName(${compiler:sys.fullName})}" volumeName="${compiler:sys.shortName}" compressDmg="false" signLaunchers="false">
<excludedComponents />
<includedDownloadableComponents />
<excludedLaunchers />
<excludedBeans />
<overriddenPrincipalLanguage id="en" customLocalizationFile="" />
<exclude>
<entry location="lib/uid.exe" fileType="regular" />
</exclude>
<variables />
<autoUpdate useMinUpdatableVersion="false" minUpdatableVersion="" useMaxUpdatableVersion="false" maxUpdatableVersion="">
<commentFiles />
<customAttributes />
</autoUpdate>
<topLevelFiles />
</macosFolder>
</mediaSets>
<buildIds buildAll="true" />
<buildOptions verbose="false" faster="false" disableSigning="false" disableJreBundling="false" debug="false" />
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/faforever/client/game/GameInfoBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class GameInfoBean {
private static final Pattern MAX_RATING_PATTERN = Pattern.compile("<\\s*(" + RATING_NUMBER + ")");
private static final Pattern ABOUT_RATING_PATTERN = Pattern.compile("~\\s*(" + RATING_NUMBER + ")");
private static final Pattern BETWEEN_RATING_PATTERN = Pattern.compile("(" + RATING_NUMBER + ")\\s*-\\s*(" + RATING_NUMBER + ")");
private static final Pattern INTEGER_PATTERN_MATCHER = Pattern.compile("\\d+");

private final StringProperty host;
private final StringProperty title;
Expand Down Expand Up @@ -144,10 +143,9 @@ public void updateFromGameInfo(GameInfoMessage gameInfoMessage) {
}

private int parseRating(String string) {
Matcher matcher = INTEGER_PATTERN_MATCHER.matcher(string);
if (matcher.matches()) {
try {
return Integer.parseInt(string);
} else {
} catch (NumberFormatException e) {
int rating;
String[] split = string.replace("k", "").split("\\.");
rating = Integer.parseInt(split[0]) * 1000;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/faforever/client/game/GameServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ public CompletionStage<Void> startSearchRanked1v1(Faction faction) {
.thenRun(() -> localRelayServer.start(connectivityService))
.thenCompose(aVoid -> fafService.startSearchRanked1v1(faction, port))
.thenAccept((gameLaunchInfo) -> {
// TODO this should be sent by the server!
gameLaunchInfo.setArgs(new ArrayList<>(gameLaunchInfo.getArgs()));
gameLaunchInfo.getArgs().add("/team 1");
gameLaunchInfo.getArgs().add("/players 2");

searchExpansionFuture.cancel(true);
startGame(gameLaunchInfo, faction, RatingMode.RANKED_1V1, localRelayServer.getPort());
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public GameLaunchMessage() {
}

/**
* Stores game launch arguments, like "/ratingcolor d8d8d8d8 /numgames 236".
* Stores game launch arguments, like "/ratingcolor d8d8d8d8", "/numgames 236".
*/
public List<String> getArgs() {
return args;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public ClientUpdateServiceImpl() {
currentVersion = new ComparableVersion(
defaultString(getClass().getPackage().getImplementationVersion(), DEVELOPMENT_VERSION_STRING)
);
logger.info("Current version: {}", currentVersion);
}

@Override
Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/theme/map_tile.fxml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<GridPane xmlns:fx="http://javafx.com/fxml/1" fx:id="mapTileRoot" onMouseClicked="#onShowMapDetail" prefWidth="200.0"
styleClass="tile,pointable" xmlns="http://javafx.com/javafx/8.0.60"
fx:controller="com.faforever.client.map.MapTileController">
Expand All @@ -23,7 +26,7 @@
<Label fx:id="nameLabel" text="Label" GridPane.columnSpan="2147483647" GridPane.rowIndex="1"/>
<Label fx:id="downloadsLabel" text="1" GridPane.columnIndex="0" GridPane.halignment="RIGHT" GridPane.rowIndex="3">
<graphic>
<Label styleClass="fontawesome" text=""/>
<Label styleClass="fontawesome" text=""/>
</graphic>
</Label>
<Label fx:id="playsLabel" text="1" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3">
Expand Down
24 changes: 15 additions & 9 deletions src/test/java/com/faforever/client/game/GameServiceImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.springframework.context.ApplicationContext;

import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand All @@ -40,8 +39,12 @@
import java.util.function.Consumer;

import static com.faforever.client.fa.RatingMode.GLOBAL;
import static com.faforever.client.fa.RatingMode.RANKED_1V1;
import static com.faforever.client.game.Faction.AEON;
import static com.faforever.client.game.Faction.CYBRAN;
import static com.faforever.client.remote.domain.GameState.CLOSED;
import static com.faforever.client.remote.domain.GameState.PLAYING;
import static java.util.Arrays.asList;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
Expand All @@ -59,6 +62,7 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -235,12 +239,12 @@ public void testAddOnGameStartedListener() throws Exception {

NewGameInfo newGameInfo = NewGameInfoBuilder.create().defaultValues().get();
GameLaunchMessage gameLaunchMessage = GameLaunchMessageBuilder.create().defaultValues().get();
gameLaunchMessage.setArgs(Arrays.asList("/foo bar", "/bar foo"));
gameLaunchMessage.setArgs(asList("/foo bar", "/bar foo"));
InetSocketAddress externalSocketAddress = new InetSocketAddress(123);

when(localRelayServer.getPort()).thenReturn(gpgPort);
when(forgedAllianceService.startGame(
gameLaunchMessage.getUid(), gameLaunchMessage.getMod(), null, Arrays.asList("/foo", "bar", "/bar", "foo"), GLOBAL, gpgPort)
gameLaunchMessage.getUid(), gameLaunchMessage.getMod(), null, asList("/foo", "bar", "/bar", "foo"), GLOBAL, gpgPort)
).thenReturn(process);
when(connectivityService.getExternalSocketAddress()).thenReturn(externalSocketAddress);
when(gameUpdateService.updateInBackground(any(), any(), any(), any())).thenReturn(completedFuture(null));
Expand Down Expand Up @@ -270,7 +274,7 @@ public void testAddOnGameStartedListener() throws Exception {

gameTerminatedLatch.await(TIMEOUT, TIME_UNIT);
verify(forgedAllianceService).startGame(
gameLaunchMessage.getUid(), gameLaunchMessage.getMod(), null, Arrays.asList("/foo", "bar", "/bar", "foo"), GLOBAL,
gameLaunchMessage.getUid(), gameLaunchMessage.getMod(), null, asList("/foo", "bar", "/bar", "foo"), GLOBAL,
gpgPort);
verify(replayService).startReplayServer(gameLaunchMessage.getUid());
}
Expand Down Expand Up @@ -301,7 +305,7 @@ public void testOnGames() throws Exception {
assertThat(instance.getGameInfoBeans(), empty());

GameInfoMessage multiGameInfoMessage = new GameInfoMessage();
multiGameInfoMessage.setGames(Arrays.asList(
multiGameInfoMessage.setGames(asList(
GameInfoMessageBuilder.create(1).defaultValues().get(),
GameInfoMessageBuilder.create(2).defaultValues().get()
));
Expand Down Expand Up @@ -388,20 +392,22 @@ public void testOnGameInfoRemove() {
@Test
public void testStartSearchRanked1v1() throws Exception {
GameLaunchMessage gameLaunchMessage = new GameLaunchMessage();
gameLaunchMessage.setMod("ladder1v1");
gameLaunchMessage.setUid(123);
gameLaunchMessage.setArgs(Collections.emptyList());
when(fafService.startSearchRanked1v1(Faction.CYBRAN, GAME_PORT)).thenReturn(CompletableFuture.completedFuture(gameLaunchMessage));
when(fafService.startSearchRanked1v1(CYBRAN, GAME_PORT)).thenReturn(CompletableFuture.completedFuture(gameLaunchMessage));
when(gameUpdateService.updateInBackground(GameType.LADDER_1V1.getString(), null, Collections.emptyMap(), Collections.emptySet())).thenReturn(CompletableFuture.completedFuture(null));
when(applicationContext.getBean(SearchExpansionTask.class)).thenReturn(searchExpansionTask);
when(scheduledExecutorService.scheduleWithFixedDelay(any(), anyLong(), anyLong(), any())).thenReturn(mock(ScheduledFuture.class));
when(localRelayServer.getPort()).thenReturn(111);

CompletableFuture<Void> future = instance.startSearchRanked1v1(Faction.CYBRAN).toCompletableFuture();
CompletableFuture<Void> future = instance.startSearchRanked1v1(CYBRAN).toCompletableFuture();

verify(searchExpansionTask).setMaxRadius(SEARCH_MAX_RADIUS);
verify(searchExpansionTask).setRadiusIncrement(SEARCH_RADIUS_INCREMENT);
verify(scheduledExecutorService).scheduleWithFixedDelay(searchExpansionTask, SEARCH_EXPANSION_DELAY, SEARCH_EXPANSION_DELAY, TimeUnit.MILLISECONDS);
verify(fafService).startSearchRanked1v1(Faction.CYBRAN, GAME_PORT);
verify(fafService).startSearchRanked1v1(CYBRAN, GAME_PORT);
verify(forgedAllianceService, timeout(5)).startGame(eq(123), eq("ladder1v1"), eq(CYBRAN), eq(asList("/team", "1", "/players", "2")), eq(RANKED_1V1), anyInt());
assertThat(future.get(TIMEOUT, TIME_UNIT), is(nullValue()));
}

Expand Down Expand Up @@ -432,7 +438,7 @@ public void testStartSearchRanked1v1GameRunningDoesNothing() throws Exception {
instance.hostGame(newGameInfo);
gameRunningLatch.await(TIMEOUT, TIME_UNIT);

instance.startSearchRanked1v1(Faction.AEON);
instance.startSearchRanked1v1(AEON);

assertThat(instance.searching1v1Property().get(), is(false));
}
Expand Down

0 comments on commit e5b830c

Please sign in to comment.