Skip to content

Commit

Permalink
hopefully fixed buffer overflow issue when zooming out
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj42 committed May 9, 2018
1 parent e381165 commit 590eea4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/client/src/miniventure/game/client/GameClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void received (Connection connection, Object object) {

if(chunkLoaded && !entityLoaded) {
//System.out.println("client requesting entity due to validation");
client.sendTCP(new EntityRequest(list.ids[i]));
send(new EntityRequest(list.ids[i]));
}
if(entityLoaded && !chunkLoaded) {
//System.out.println("client unloading entity due to validation");
Expand Down
2 changes: 1 addition & 1 deletion core/client/src/miniventure/game/client/LevelViewport.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class LevelViewport {

private static final float DEFAULT_VIEWPORT_SIZE = 20; // in tiles

private static final int MIN_ZOOM = -2, MAX_ZOOM = 5;
private static final int MIN_ZOOM = -3, MAX_ZOOM = 5;

// these two values determine how much of the level to render in either dimension, and are also used to fit the viewport to the game window. Later, they should be customizable by the user; for now, they'll remain at 0, meaning it doesn't limit the number of tiles rendered, and the default viewport size will be used for fitting.
private float maxWorldViewWidth = 0;
Expand Down
6 changes: 4 additions & 2 deletions core/client/src/miniventure/game/world/ClientLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ public void serverUpdate(ClientTile tile, TileData data) {
@Override
protected ClientTile createTile(int x, int y, TileType[] types, String[] data) { return new ClientTile(this, x, y, types, data); }

@Override public ClientTile getTile(float x, float y) {
@Override
public ClientTile getTile(float x, float y) { return getTile(x, y, false); }
public ClientTile getTile(float x, float y, boolean loadIfNull) {
ClientTile tile = (ClientTile) super.getTile(x, y);
if(tile == null)
if(tile == null && loadIfNull)
loadChunk(Chunk.getCoords(x, y));

return tile;
Expand Down

0 comments on commit 590eea4

Please sign in to comment.