Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
rpolzer committed Jun 16, 2018
1 parent 3018fb8 commit 9bd830a
Show file tree
Hide file tree
Showing 38 changed files with 349 additions and 334 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ All the options above can also be specified as command line options. For this, y
3. Download the newest stable JSettlers-Android_v*.apk onto your Android device.
4. Install JSettlers by running the downloaded file.

## Developer's Guide
The [Developer's Guide](https://github.com/jsettlers/settlers-remake/wiki/Developer's%20Guide) can be found in our wiki.
## Build instructions and developer's guide
The [build instructions](https://github.com/jsettlers/settlers-remake/wiki/Compiling-using-gradle) and the [developer's guide](https://github.com/jsettlers/settlers-remake/wiki/Developer's%20Guide) can be found in our wiki.

## Getting in Touch
Besides the possibility to report bugs on Github you can also join our [JSettlers Discord](https://discord.gg/2hVV4u6). Here you can discuss on development questions and find other players to meet with.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@

<constructionStack dx="1" dy="5" material="PLANK" buildrequired="5" />
<constructionStack dx="3" dy="5" material="STONE" buildrequired="4" />

<requestStack dx="-3" dy="2" material="COAL" />
<requestStack dx="3" dy="3" material="GOLDORE" />

<offerStack dx="4" dy="1" material="GOLD" />

<bricklayer dx="-2" dy="2" direction="NORTH_EAST" />
<bricklayer dx="0" dy="4" direction="NORTH_EAST" />
<bricklayer dx="2" dy="3" direction="NORTH_WEST" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void testShapeIterator(IMapArea circle) {

for (int x = 0; x < TEST_WIDTH; x++) {
for (int y = 0; y < TEST_WIDTH; y++) {
assertEquals("contains() incosistent with iterator for " + x + "," + y, circle.contains(new ShortPoint2D(x, y)),
assertEquals("contains() inconsistent with iterator for " + x + "," + y, circle.contains(new ShortPoint2D(x, y)),
foundByIterator[x][y]);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
/*******************************************************************************
* Copyright (c) 2015
*
* Copyright (c) 2018
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* <p>
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*******************************************************************************/
package jsettlers.common.statistics;

/**
* This class specifies how many bearers may be converted to a given type.
*
* @author michael
*/
public interface IConversionRate {
/**
* How many bearers may be converted to this type at maximum
*
* @return A value from 0..1, defining a relative ammount to the sum of all non-military people.
*/
float getMaximumRate();

/**
* Sets the rate of bearers that may be converted at maximum.
*
* @param rate
*/
void setMaximumRate(float rate);
package jsettlers.common.map.shapes;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class MapRectangleTest {
@Test
public void containsBorders() {
MapRectangle mapRectangle = new MapRectangle(0, 0, 10, 10);

assertTrue(mapRectangle.contains(0, 0));
assertTrue(mapRectangle.contains(9, 0));
assertTrue(mapRectangle.contains(4, 9));
assertTrue(mapRectangle.contains(13, 9));
}

@Test
public void containsNotOutsideBorders() {
MapRectangle mapRectangle = new MapRectangle(0, 0, 10, 10);

assertFalse(mapRectangle.contains(0 - 1, 0));
assertFalse(mapRectangle.contains(0, -1));
assertFalse(mapRectangle.contains(-1, -1));

assertFalse(mapRectangle.contains(10, 0));
assertFalse(mapRectangle.contains(9, -1));
assertFalse(mapRectangle.contains(10, -1));

assertFalse(mapRectangle.contains(4 - 1, 9));
assertFalse(mapRectangle.contains(4, 9 + 1));
assertFalse(mapRectangle.contains(4 - 1, 9 + 1));

assertFalse(mapRectangle.contains(13 + 1, 9));
assertFalse(mapRectangle.contains(13, 9 + 1));
assertFalse(mapRectangle.contains(13 + 1, 9 + 1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private void drawMain(FloatRectangle screen) {
double bottomDrawY = screen.getMinY() - OVERDRAW_BOTTOM_PX;

boolean linePartiallyVisible = true;
for (int line = 0; line < area.getLines() + 50 && linePartiallyVisible; line++) {
for (int line = 0; line < area.getHeight() + 50 && linePartiallyVisible; line++) {
int y = area.getLineY(line);
if (y < 0) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ private void goBack() {

public void setMapViewport(MapRectangle screenArea, IGraphicsGrid grid) {
this.grid = grid;
displayCenter = new ShortPoint2D(screenArea.getLineStartX(screenArea.getLines() / 2)
+ screenArea.getLineLength() / 2, screenArea
.getLineY(screenArea.getLines() / 2));
short x = (short) (screenArea.getMinX() + (screenArea.getWidth() / 2));
short y = (short) (screenArea.getMinY() + (screenArea.getHeight() / 2));
displayCenter = new ShortPoint2D(x, y);
sendMapPositionChange();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ public void drawMapContent(MapDrawContext context, FloatRectangle screen) {
try {
GLDrawContext gl = context.getGl();
MapRectangle screenArea = context.getConverter().getMapForScreen(screen);
mapViewResized = geometryhandle == null || !geometryhandle.isValid() || screenArea.getLineLength() + 1 != bufferWidth || screenArea.getLines() != bufferHeight;
mapViewResized = geometryhandle == null || !geometryhandle.isValid() || screenArea.getWidth() + 1 != bufferWidth || screenArea.getHeight() != bufferHeight;
if (mapViewResized) {
regenerateGeometry(gl, screenArea);
}
Expand Down Expand Up @@ -1221,8 +1221,8 @@ private void regenerateGeometry(GLDrawContext gl, MapRectangle screenArea) {
if (geometryhandle != null && geometryhandle.isValid()) {
geometryhandle.delete();
}
bufferWidth = niceRoundUp(screenArea.getLineLength() + 1);
bufferHeight = niceRoundUp(screenArea.getLines());
bufferWidth = niceRoundUp(screenArea.getWidth() + 1);
bufferHeight = niceRoundUp(screenArea.getHeight());
int count = bufferHeight * bufferWidth;
fogOfWarStatus = new byte[count * 4];
geometryInvalid = new BitSet(count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ private void drawShip(IMovable ship, int x, int y) {
drawShipLink(SHIP_IMAGE_FILE, baseSequence, shipImageDirection, glDrawContext, drawBuffer, viewX, viewY, color, shade);
// prepare freight drawing
List<? extends IMovable> passengerList = ship.getPassengers();
byte[] dx = EDirection.getXDeltaArray();
byte[] dy = EDirection.getYDeltaArray();

float baseViewX = mapCoordinateConverter.getViewX(x, y, height);
float baseViewY = mapCoordinateConverter.getViewY(x, y, height);
float xShiftForward = mapCoordinateConverter.getViewX(x + dx[direction.ordinal], y + dy[direction.ordinal], height) - baseViewX;
float yShiftForward = mapCoordinateConverter.getViewY(x + dx[direction.ordinal], y + dy[direction.ordinal], height) - baseViewY;
int xRight = x + dx[direction.rotateRight(1).ordinal] + dx[direction.rotateRight(2).ordinal];
int yRight = y + dy[direction.rotateRight(1).ordinal] + dy[direction.rotateRight(2).ordinal];
float xShiftForward = mapCoordinateConverter.getViewX(x + direction.gridDeltaX, y + direction.gridDeltaY, height) - baseViewX;
float yShiftForward = mapCoordinateConverter.getViewY(x + direction.gridDeltaX, y + direction.gridDeltaY, height) - baseViewY;
int xRight = x + direction.rotateRight(1).gridDeltaX + direction.rotateRight(2).gridDeltaX;
int yRight = y + direction.rotateRight(1).gridDeltaY + direction.rotateRight(2).gridDeltaY;

float xShiftRight = (mapCoordinateConverter.getViewX(xRight, yRight, height) - baseViewX) / 2;
float yShiftRight = (mapCoordinateConverter.getViewY(xRight, yRight, height) - baseViewY) / 2;
ArrayList<FloatIntObject> freightY = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ public MapCoordinateConverter(short mapwidth, short mapheight,
* The x coordinate in map space.
* @param y
* The y coordinate in map space.
* @param height
* The height of the tile.
* @param width
* The width of the tile.
* @return The view x coordinate
*/
public float getViewX(float x, float y, float height) {
public float getViewX(float x, float y, float width) {
return x * this.heightmatrix[M_00] + y * this.heightmatrix[M_01]
+ height * this.heightmatrix[M_HX] + this.heightmatrix[M_02];
+ width * this.heightmatrix[M_HX] + this.heightmatrix[M_02];
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2018
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

package jsettlers.graphics.map.minimap;

import jsettlers.common.map.shapes.MapRectangle;
import jsettlers.graphics.map.geometry.MapCoordinateConverter;

/**
* Calculates the shape of the screen displayed on the minimap.
* the origin of coordinates is in the bottom left and values increase to the top right.
*/
class MiniMapShapeCalculator {

private float width;
private float height;
private float stride;
private MapRectangle mapViewport;
private final MapCoordinateConverter converter;


MiniMapShapeCalculator(float stride, MapCoordinateConverter converter) {
this.stride = stride;

this.converter = converter;
}

float[] getMiniMapShapeNodes() {
if (mapViewport == null) {
return new float[0];
}
int offset = 50;
int minX = mapViewport.getMinX();
int minY = mapViewport.getMinY();
int maxX = minX + mapViewport.getWidth();
int maxY = minY + mapViewport.getHeight() - offset;
float minViewX = converter.getViewX(minX, minY, 0) * width;
float maxViewY = converter.getViewY(minX, minY, 0) * height;
float maxViewX = converter.getViewX(maxX, maxY + offset, 0) * width;
float minViewY = converter.getViewY(maxX, maxY, 0) * height;

return new float[] {
// bottom left
minViewX,
minViewY,
0,
// bottom right
Math.min(maxViewX, (minViewY / height * stride + 1) * width),
minViewY,
0,
// mid right
maxViewX,
Math.max(minViewY, (maxViewX - width) / width / stride * height),
0,
// top right
maxViewX,
maxViewY,
0,
// top left
Math.max(minViewX, (maxViewY / height * stride ) * width),
maxViewY,
0,
// mid left
minViewX,
Math.min(maxViewY, minViewX / stride / width * height + 10),
0,
};
}

void setMapViewport(MapRectangle mapViewport) {
this.mapViewport = mapViewport;
}

void setWidth(float width) {
this.width = width;
}

void setHeight(float height) {
this.height = height;
}
}
Loading

0 comments on commit 9bd830a

Please sign in to comment.