mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +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();
|
||||
// initialiseLobbyControllerThread();
|
||||
// initialiseImageView(); // parrot gif init
|
||||
initialiseImageView(); // parrot gif init
|
||||
|
||||
// set up client state query thread, so that when it receives the race-started packet
|
||||
// it can switch to the race view
|
||||
|
||||
@@ -86,40 +86,40 @@ public class GameState {
|
||||
|
||||
public static void updateBoat(Integer sourceId, BoatActionType actionType) {
|
||||
Yacht playerYacht = yachts.get(sourceId);
|
||||
System.out.println("-----------------------");
|
||||
// System.out.println("-----------------------");
|
||||
switch (actionType) {
|
||||
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
|
||||
break;
|
||||
case SAILS_IN:
|
||||
playerYacht.toggleSailIn();
|
||||
System.out.println("Toggling Sails");
|
||||
// System.out.println("Toggling Sails");
|
||||
break;
|
||||
case SAILS_OUT:
|
||||
playerYacht.toggleSailIn();
|
||||
System.out.println("Toggling Sails");
|
||||
// System.out.println("Toggling Sails");
|
||||
break;
|
||||
case TACK_GYBE:
|
||||
playerYacht.tackGybe(windDirection);
|
||||
System.out.println("Tack/Gybe");
|
||||
// System.out.println("Tack/Gybe");
|
||||
break;
|
||||
case UPWIND:
|
||||
playerYacht.turnUpwind();
|
||||
System.out.println("Moving upwind");
|
||||
// System.out.println("Moving upwind");
|
||||
break;
|
||||
case DOWNWIND:
|
||||
playerYacht.turnDownwind();
|
||||
System.out.println("Moving downwind");
|
||||
// System.out.println("Moving downwind");
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println("-----------------------");
|
||||
System.out.println("Heading: " + playerYacht.getHeading());
|
||||
System.out.println("Sails are in: " + playerYacht.getSailIn());
|
||||
System.out.println("Lat: " + playerYacht.getLocation().getLat());
|
||||
System.out.println("Lng: " + playerYacht.getLocation().getLng());
|
||||
System.out.println("-----------------------\n");
|
||||
// System.out.println("-----------------------");
|
||||
// System.out.println("Heading: " + playerYacht.getHeading());
|
||||
// System.out.println("Sails are in: " + playerYacht.getSailIn());
|
||||
// System.out.println("Lat: " + playerYacht.getLocation().getLat());
|
||||
// System.out.println("Lng: " + playerYacht.getLocation().getLng());
|
||||
// System.out.println("-----------------------\n");
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.util.zip.Checksum;
|
||||
import seng302.server.messages.RaceStatus;
|
||||
import seng302.server.messages.RaceStatusMessage;
|
||||
import seng302.server.messages.RaceType;
|
||||
import seng302.server.messages.WindDirection;
|
||||
import seng302.server.messages.XMLMessage;
|
||||
import seng302.server.messages.XMLMessageSubType;
|
||||
import seng302.server.messages.XMLMessage;
|
||||
@@ -410,7 +409,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
raceStatus = RaceStatus.WARNING;
|
||||
}
|
||||
|
||||
sendMessage(new RaceStatusMessage(1, raceStatus, startTime, WindDirection.SOUTH,
|
||||
100, GameState.getPlayers().size(), RaceType.MATCH_RACE, 1, boatSubMessages));
|
||||
sendMessage(new RaceStatusMessage(1, raceStatus, startTime, GameState.getWindDirection(),
|
||||
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 int MESSAGE_VERSION = 2; //Always set to 1
|
||||
private final int MESSAGE_BASE_SIZE = 24;
|
||||
private final double windDirFactor = 0x4000 / 90;
|
||||
|
||||
private long currentTime;
|
||||
private long raceId;
|
||||
private RaceStatus raceStatus;
|
||||
private long expectedStartTime;
|
||||
private WindDirection raceWindDirection;
|
||||
private double raceWindDirection;
|
||||
private long windSpeed;
|
||||
private long numBoatsInRace;
|
||||
private RaceType raceType;
|
||||
@@ -33,13 +34,13 @@ public class RaceStatusMessage extends Message{
|
||||
* @param sourceId The source of this message
|
||||
* @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){
|
||||
currentTime = System.currentTimeMillis();
|
||||
this.raceId = raceId;
|
||||
this.raceStatus = raceStatus;
|
||||
this.expectedStartTime = expectedStartTime;
|
||||
this.raceWindDirection = raceWindDirection;
|
||||
this.raceWindDirection = raceWindDirection * windDirFactor;
|
||||
this.windSpeed = windSpeed;
|
||||
this.numBoatsInRace = numBoatsInRace;
|
||||
this.raceType = raceType;
|
||||
@@ -55,7 +56,7 @@ public class RaceStatusMessage extends Message{
|
||||
putInt((int) raceId, 4);
|
||||
putByte((byte) raceStatus.getCode());
|
||||
putInt(expectedStartTime, 6);
|
||||
putInt((int) raceWindDirection.getCode(), 2);
|
||||
putInt((int) this.raceWindDirection, 2);
|
||||
putInt((int) windSpeed, 2);
|
||||
putByte((byte) numBoatsInRace);
|
||||
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>
|
||||
<Modified>2012-05-17T07:49:40+0200</Modified>
|
||||
<Version>12</Version>
|
||||
|
||||
<Settings>
|
||||
<RaceBoatType Type="AC45" />
|
||||
<BoatDimension BoatLength="14.019" HullLength="13.449" />
|
||||
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347" />
|
||||
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100" />
|
||||
</Settings>
|
||||
|
||||
<BoatShapes>
|
||||
<#-- Not used -->
|
||||
</BoatShapes>
|
||||
|
||||
<Boats>
|
||||
<#list boats as boat>
|
||||
<Boat Type="Yacht" SourceID="${boat.sourceId}" ShapeID="4" HullNum="${boat.hullID}" StoweName="${boat.shortName}" ShortName="${boat.shortName}"
|
||||
BoatName="${boat.boatName}" Country="${boat.country}">
|
||||
|
||||
<GPSposition Z="0" Y="3.7" X="0" />
|
||||
<MastTop Z="0" Y="6.2" X="0" />
|
||||
</Boat>
|
||||
|
||||
Reference in New Issue
Block a user