Fixed bug related to replacing data tiles

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 7dfd9bd4e3
commit 2d2b6d0844
  1. BIN
      maps/world1.map
  2. 8
      src/sig/events/WaterEvent.java
  3. 9
      src/sig/map/Map.java

Binary file not shown.

@ -6,7 +6,13 @@ public class WaterEvent implements Event{
@Override @Override
public boolean perform(int x, int y) { public boolean perform(int x, int y) {
RabiClone.CURRENT_MAP.getMap().setWaterLevel(RabiClone.CURRENT_MAP.getMap().getDataTileValue(x+1, y)); char val1=RabiClone.CURRENT_MAP.getMap().getDataTileValue(x+1, y);
char val2=RabiClone.CURRENT_MAP.getMap().getDataTileValue(x, y+1);
if (val1!=0) {
RabiClone.CURRENT_MAP.getMap().setWaterLevel(val1);
} else {
RabiClone.CURRENT_MAP.getMap().setWaterLevel(val2);
}
return true; return true;
} }

@ -35,7 +35,7 @@ public class Map {
byte[] backgrounds = new byte[MAP_SCREENS_X*MAP_SCREENS_Y]; byte[] backgrounds = new byte[MAP_SCREENS_X*MAP_SCREENS_Y];
byte[] colors = new byte[MAP_SCREENS_X*MAP_SCREENS_Y]; byte[] colors = new byte[MAP_SCREENS_X*MAP_SCREENS_Y];
byte[] types = new byte[MAP_SCREENS_X*MAP_SCREENS_Y]; byte[] types = new byte[MAP_SCREENS_X*MAP_SCREENS_Y];
char[] data = new char[MAP_WIDTH*MAP_HEIGHT]; char[] data = new char[MAP_WIDTH*MAP_HEIGHT]; //While it's stored in a char, the map format only reads 14 bits for this value!! Value is between 0-16384!
char waterLevel = 144; char waterLevel = 144;
@ -247,7 +247,10 @@ public class Map {
} }
public void ModifyDataTile(int x, int y, char value) { public void ModifyDataTile(int x, int y, char value) {
char prevTile = data[y*Map.MAP_WIDTH+x];
if (prevTile==0) {
eventTileCount++; eventTileCount++;
}
if (value>8192) { if (value>8192) {
value=8192; value=8192;
} }
@ -264,11 +267,11 @@ public class Map {
} }
/* /*
* This will return the tile's value minus 32768. * This will return the tile's value minus 8192.
* This value represents a data tile value, but not * This value represents a data tile value, but not
* necessarily a data tile. * necessarily a data tile.
*/ */
public char getDataTileValue(int x,int y) { public char getDataTileValue(int x,int y) {
return (char)(data[y*Map.MAP_WIDTH+x]-32768); return (char)(data[y*Map.MAP_WIDTH+x]-8192);
} }
} }

Loading…
Cancel
Save