Update PostgresSQL code to handle fullrender resume updates

This commit is contained in:
Mike Primm 2019-12-15 01:36:59 -06:00
parent 49ea99b703
commit 40472f88fd

View File

@ -23,8 +23,11 @@ import org.dynmap.WebAuthManager;
import org.dynmap.MapType.ImageVariant; import org.dynmap.MapType.ImageVariant;
import org.dynmap.PlayerFaces.FaceType; import org.dynmap.PlayerFaces.FaceType;
import org.dynmap.storage.MapStorage; import org.dynmap.storage.MapStorage;
import org.dynmap.storage.MapStorageBaseTileEnumCB;
import org.dynmap.storage.MapStorageTile; import org.dynmap.storage.MapStorageTile;
import org.dynmap.storage.MapStorageTileEnumCB; import org.dynmap.storage.MapStorageTileEnumCB;
import org.dynmap.storage.MapStorageTileSearchEndCB;
import org.dynmap.storage.mysql.MySQLMapStorage.StorageTile;
import org.dynmap.utils.BufferInputStream; import org.dynmap.utils.BufferInputStream;
import org.dynmap.utils.BufferOutputStream; import org.dynmap.utils.BufferOutputStream;
@ -621,16 +624,19 @@ public class PostgreSQLMapStorage extends MapStorage {
for (MapType mt : mtlist) { for (MapType mt : mtlist) {
ImageVariant[] vars = mt.getVariants(); ImageVariant[] vars = mt.getVariants();
for (ImageVariant var : vars) { for (ImageVariant var : vars) {
processEnumMapTiles(world, mt, var, cb); processEnumMapTiles(world, mt, var, cb, null, null);
} }
} }
} }
private void processEnumMapTiles(DynmapWorld world, MapType map, ImageVariant var, MapStorageTileEnumCB cb, MapStorageBaseTileEnumCB cbBase, MapStorageTileSearchEndCB cbEnd) {
private void processEnumMapTiles(DynmapWorld world, MapType map, ImageVariant var, MapStorageTileEnumCB cb) {
Connection c = null; Connection c = null;
boolean err = false; boolean err = false;
Integer mapkey = getMapKey(world, map, var); Integer mapkey = getMapKey(world, map, var);
if (mapkey == null) return; if (mapkey == null) {
if(cbEnd != null)
cbEnd.searchEnded();
return;
}
try { try {
c = getConnection(); c = getConnection();
// Query tiles for given mapkey // Query tiles for given mapkey
@ -638,9 +644,15 @@ public class PostgreSQLMapStorage extends MapStorage {
ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + ";"); ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + ";");
while (rs.next()) { while (rs.next()) {
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
cb.tileFound(st, MapType.ImageEncoding.fromOrd(rs.getInt("Format"))); final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
if(cb != null)
cb.tileFound(st, encoding);
if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding);
st.cleanup(); st.cleanup();
} }
if(cbEnd != null)
cbEnd.searchEnded();
rs.close(); rs.close();
stmt.close(); stmt.close();
} catch (SQLException x) { } catch (SQLException x) {
@ -650,6 +662,23 @@ public class PostgreSQLMapStorage extends MapStorage {
releaseConnection(c, err); releaseConnection(c, err);
} }
} }
@Override
public void enumMapBaseTiles(DynmapWorld world, MapType map, MapStorageBaseTileEnumCB cbBase, MapStorageTileSearchEndCB cbEnd) {
List<MapType> mtlist;
if (map != null) {
mtlist = Collections.singletonList(map);
}
else { // Else, add all directories under world directory (for maps)
mtlist = new ArrayList<MapType>(world.maps);
}
for (MapType mt : mtlist) {
ImageVariant[] vars = mt.getVariants();
for (ImageVariant var : vars) {
processEnumMapTiles(world, mt, var, null, cbBase, cbEnd);
}
}
}
@Override @Override
public void purgeMapTiles(DynmapWorld world, MapType map) { public void purgeMapTiles(DynmapWorld world, MapType map) {