mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Fixed wind speed and direction being sent correctly.
#pair[kre39,mra106] #story[1036]
This commit is contained in:
@@ -115,7 +115,7 @@ public class LobbyController implements Initializable, Observer{
|
|||||||
}
|
}
|
||||||
initialiseListView();
|
initialiseListView();
|
||||||
// initialiseLobbyControllerThread();
|
// initialiseLobbyControllerThread();
|
||||||
// initialiseImageView(); // parrot gif init
|
initialiseImageView(); // parrot gif init
|
||||||
|
|
||||||
// set up client state query thread, so that when it receives the race-started packet
|
// set up client state query thread, so that when it receives the race-started packet
|
||||||
// it can switch to the race view
|
// it can switch to the race view
|
||||||
|
|||||||
@@ -86,40 +86,40 @@ public class GameState {
|
|||||||
|
|
||||||
public static void updateBoat(Integer sourceId, BoatActionType actionType) {
|
public static void updateBoat(Integer sourceId, BoatActionType actionType) {
|
||||||
Yacht playerYacht = yachts.get(sourceId);
|
Yacht playerYacht = yachts.get(sourceId);
|
||||||
System.out.println("-----------------------");
|
// System.out.println("-----------------------");
|
||||||
switch (actionType) {
|
switch (actionType) {
|
||||||
case VMG:
|
case VMG:
|
||||||
System.out.println("Snapping to VMG");
|
// System.out.println("Snapping to VMG");
|
||||||
// TODO: 22/07/17 wmu16 - Add in the vmg calculation code here
|
// TODO: 22/07/17 wmu16 - Add in the vmg calculation code here
|
||||||
break;
|
break;
|
||||||
case SAILS_IN:
|
case SAILS_IN:
|
||||||
playerYacht.toggleSailIn();
|
playerYacht.toggleSailIn();
|
||||||
System.out.println("Toggling Sails");
|
// System.out.println("Toggling Sails");
|
||||||
break;
|
break;
|
||||||
case SAILS_OUT:
|
case SAILS_OUT:
|
||||||
playerYacht.toggleSailIn();
|
playerYacht.toggleSailIn();
|
||||||
System.out.println("Toggling Sails");
|
// System.out.println("Toggling Sails");
|
||||||
break;
|
break;
|
||||||
case TACK_GYBE:
|
case TACK_GYBE:
|
||||||
playerYacht.tackGybe(windDirection);
|
playerYacht.tackGybe(windDirection);
|
||||||
System.out.println("Tack/Gybe");
|
// System.out.println("Tack/Gybe");
|
||||||
break;
|
break;
|
||||||
case UPWIND:
|
case UPWIND:
|
||||||
playerYacht.turnUpwind();
|
playerYacht.turnUpwind();
|
||||||
System.out.println("Moving upwind");
|
// System.out.println("Moving upwind");
|
||||||
break;
|
break;
|
||||||
case DOWNWIND:
|
case DOWNWIND:
|
||||||
playerYacht.turnDownwind();
|
playerYacht.turnDownwind();
|
||||||
System.out.println("Moving downwind");
|
// System.out.println("Moving downwind");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("-----------------------");
|
// System.out.println("-----------------------");
|
||||||
System.out.println("Heading: " + playerYacht.getHeading());
|
// System.out.println("Heading: " + playerYacht.getHeading());
|
||||||
System.out.println("Sails are in: " + playerYacht.getSailIn());
|
// System.out.println("Sails are in: " + playerYacht.getSailIn());
|
||||||
System.out.println("Lat: " + playerYacht.getLocation().getLat());
|
// System.out.println("Lat: " + playerYacht.getLocation().getLat());
|
||||||
System.out.println("Lng: " + playerYacht.getLocation().getLng());
|
// System.out.println("Lng: " + playerYacht.getLocation().getLng());
|
||||||
System.out.println("-----------------------\n");
|
// System.out.println("-----------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void update() {
|
public static void update() {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import java.util.zip.Checksum;
|
|||||||
import seng302.server.messages.RaceStatus;
|
import seng302.server.messages.RaceStatus;
|
||||||
import seng302.server.messages.RaceStatusMessage;
|
import seng302.server.messages.RaceStatusMessage;
|
||||||
import seng302.server.messages.RaceType;
|
import seng302.server.messages.RaceType;
|
||||||
import seng302.server.messages.WindDirection;
|
|
||||||
import seng302.server.messages.XMLMessage;
|
import seng302.server.messages.XMLMessage;
|
||||||
import seng302.server.messages.XMLMessageSubType;
|
import seng302.server.messages.XMLMessageSubType;
|
||||||
import seng302.server.messages.XMLMessage;
|
import seng302.server.messages.XMLMessage;
|
||||||
@@ -410,7 +409,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
|||||||
raceStatus = RaceStatus.WARNING;
|
raceStatus = RaceStatus.WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(new RaceStatusMessage(1, raceStatus, startTime, WindDirection.SOUTH,
|
sendMessage(new RaceStatusMessage(1, raceStatus, startTime, GameState.getWindDirection(),
|
||||||
100, GameState.getPlayers().size(), RaceType.MATCH_RACE, 1, boatSubMessages));
|
GameState.getWindSpeed().longValue(), GameState.getPlayers().size(), RaceType.MATCH_RACE, 1, boatSubMessages));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ public class RaceStatusMessage extends Message{
|
|||||||
private final MessageType MESSAGE_TYPE = MessageType.RACE_STATUS;
|
private final MessageType MESSAGE_TYPE = MessageType.RACE_STATUS;
|
||||||
private final int MESSAGE_VERSION = 2; //Always set to 1
|
private final int MESSAGE_VERSION = 2; //Always set to 1
|
||||||
private final int MESSAGE_BASE_SIZE = 24;
|
private final int MESSAGE_BASE_SIZE = 24;
|
||||||
|
private final double windDirFactor = 0x4000 / 90;
|
||||||
|
|
||||||
private long currentTime;
|
private long currentTime;
|
||||||
private long raceId;
|
private long raceId;
|
||||||
private RaceStatus raceStatus;
|
private RaceStatus raceStatus;
|
||||||
private long expectedStartTime;
|
private long expectedStartTime;
|
||||||
private WindDirection raceWindDirection;
|
private double raceWindDirection;
|
||||||
private long windSpeed;
|
private long windSpeed;
|
||||||
private long numBoatsInRace;
|
private long numBoatsInRace;
|
||||||
private RaceType raceType;
|
private RaceType raceType;
|
||||||
@@ -33,13 +34,13 @@ public class RaceStatusMessage extends Message{
|
|||||||
* @param sourceId The source of this message
|
* @param sourceId The source of this message
|
||||||
* @param boats A list of boat status sub messages
|
* @param boats A list of boat status sub messages
|
||||||
*/
|
*/
|
||||||
public RaceStatusMessage(long raceId, RaceStatus raceStatus, long expectedStartTime, WindDirection raceWindDirection,
|
public RaceStatusMessage(long raceId, RaceStatus raceStatus, long expectedStartTime, double raceWindDirection,
|
||||||
long windSpeed, long numBoatsInRace, RaceType raceType, long sourceId, List<BoatSubMessage> boats){
|
long windSpeed, long numBoatsInRace, RaceType raceType, long sourceId, List<BoatSubMessage> boats){
|
||||||
currentTime = System.currentTimeMillis();
|
currentTime = System.currentTimeMillis();
|
||||||
this.raceId = raceId;
|
this.raceId = raceId;
|
||||||
this.raceStatus = raceStatus;
|
this.raceStatus = raceStatus;
|
||||||
this.expectedStartTime = expectedStartTime;
|
this.expectedStartTime = expectedStartTime;
|
||||||
this.raceWindDirection = raceWindDirection;
|
this.raceWindDirection = raceWindDirection * windDirFactor;
|
||||||
this.windSpeed = windSpeed;
|
this.windSpeed = windSpeed;
|
||||||
this.numBoatsInRace = numBoatsInRace;
|
this.numBoatsInRace = numBoatsInRace;
|
||||||
this.raceType = raceType;
|
this.raceType = raceType;
|
||||||
@@ -55,7 +56,7 @@ public class RaceStatusMessage extends Message{
|
|||||||
putInt((int) raceId, 4);
|
putInt((int) raceId, 4);
|
||||||
putByte((byte) raceStatus.getCode());
|
putByte((byte) raceStatus.getCode());
|
||||||
putInt(expectedStartTime, 6);
|
putInt(expectedStartTime, 6);
|
||||||
putInt((int) raceWindDirection.getCode(), 2);
|
putInt((int) this.raceWindDirection, 2);
|
||||||
putInt((int) windSpeed, 2);
|
putInt((int) windSpeed, 2);
|
||||||
putByte((byte) numBoatsInRace);
|
putByte((byte) numBoatsInRace);
|
||||||
putByte((byte) raceType.getCode());
|
putByte((byte) raceType.getCode());
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package seng302.server.messages;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum containing the supported wind directions
|
|
||||||
*/
|
|
||||||
public enum WindDirection {
|
|
||||||
NORTH(0x0000L),
|
|
||||||
EAST(0x4000L),
|
|
||||||
SOUTH(0x8000L);
|
|
||||||
|
|
||||||
private long code;
|
|
||||||
|
|
||||||
WindDirection(long code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
|
|
||||||
<BoatConfig>
|
<BoatConfig>
|
||||||
<Modified>2012-05-17T07:49:40+0200</Modified>
|
<Modified>2012-05-17T07:49:40+0200</Modified>
|
||||||
<Version>12</Version>
|
<Version>12</Version>
|
||||||
|
|
||||||
<Settings>
|
<Settings>
|
||||||
<RaceBoatType Type="AC45" />
|
<RaceBoatType Type="AC45" />
|
||||||
<BoatDimension BoatLength="14.019" HullLength="13.449" />
|
<BoatDimension BoatLength="14.019" HullLength="13.449" />
|
||||||
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347" />
|
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347" />
|
||||||
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100" />
|
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100" />
|
||||||
</Settings>
|
</Settings>
|
||||||
|
|
||||||
<BoatShapes>
|
<BoatShapes>
|
||||||
<#-- Not used -->
|
<#-- Not used -->
|
||||||
</BoatShapes>
|
</BoatShapes>
|
||||||
|
|
||||||
<Boats>
|
<Boats>
|
||||||
<#list boats as boat>
|
<#list boats as boat>
|
||||||
<Boat Type="Yacht" SourceID="${boat.sourceId}" ShapeID="4" HullNum="${boat.hullID}" StoweName="${boat.shortName}" ShortName="${boat.shortName}"
|
<Boat Type="Yacht" SourceID="${boat.sourceId}" ShapeID="4" HullNum="${boat.hullID}" StoweName="${boat.shortName}" ShortName="${boat.shortName}"
|
||||||
BoatName="${boat.boatName}" Country="${boat.country}">
|
BoatName="${boat.boatName}" Country="${boat.country}">
|
||||||
|
|
||||||
<GPSposition Z="0" Y="3.7" X="0" />
|
<GPSposition Z="0" Y="3.7" X="0" />
|
||||||
<MastTop Z="0" Y="6.2" X="0" />
|
<MastTop Z="0" Y="6.2" X="0" />
|
||||||
</Boat>
|
</Boat>
|
||||||
|
|||||||
Reference in New Issue
Block a user