Make editor scripts work again
parent
d17623f27f
commit
7d465c7e0c
|
@ -1,3 +1,7 @@
|
|||
2022-05-14 Andreas Kirschbaum
|
||||
|
||||
* Make editor scripts work again.
|
||||
|
||||
2021-08-21 Saiapatsu
|
||||
* HallOfDMs,
|
||||
* azumauindo/minatomachi/ketsueki_itsuryuu/guild_hq,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<script>
|
||||
<name>LegacySpellConverter</name>
|
||||
<code><![CDATA[import java.io.File;
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<script>
|
||||
<name>LegacySpellConverter</name>
|
||||
<code xml:space="preserve">import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import net.sf.gridarta.gameobject.ArchetypeParser;
|
||||
import net.sf.gridarta.gameobject.ArchetypeSet;
|
||||
import net.sf.gridarta.gameobject.GameObject;
|
||||
import net.sf.gridarta.io.RecursiveFileIterator;
|
||||
import net.sf.gridarta.map.MapSquare;
|
||||
import net.sf.gridarta.model.archetypeset.ArchetypeSet;
|
||||
import net.sf.gridarta.model.gameobject.GameObject;
|
||||
import net.sf.gridarta.model.io.ArchetypeParser;
|
||||
import net.sf.gridarta.model.io.RecursiveFileIterator;
|
||||
import net.sf.gridarta.model.mapmodel.MapSquare;
|
||||
|
||||
int countMapFiles = 0;
|
||||
int countSpellObjects = 0;
|
||||
|
@ -236,7 +236,7 @@ void convertGameObject(GameObject gameObject) {
|
|||
case 31: // TRIGGER_ALTAR
|
||||
case 154: // RUNE
|
||||
if (gameObject.getAttributeInt("sp") == 0) {
|
||||
// non-spellcasting object ==> skip
|
||||
// non-spellcasting object ==> skip
|
||||
break;
|
||||
}
|
||||
//fallthrough
|
||||
|
@ -249,18 +249,17 @@ void convertGameObject(GameObject gameObject) {
|
|||
|
||||
if (!gameObject.iterator().hasNext()) {
|
||||
int spellId = gameObject.getAttributeInt(spellAttribute);
|
||||
if (spellId < 0 || spellId >= spellMapping.length || spellMapping[spellId] == null) {
|
||||
if (spellId < 0 || spellId >= spellMapping.length || spellMapping[spellId] == null) {
|
||||
print("invalid spell number " + spellId + " in object " + gameObject.getBestName() + " at " + gameObject.getMapX() + "/" + gameObject.getMapY());
|
||||
} else {
|
||||
GameObject spell = archetypeSet.getOrCreateArchetype(spellMapping[spellId]).createArch();
|
||||
spell.postParseGameObject(0);
|
||||
GameObject spell = gameObjectFactory.createGameObject(archetypeSet.getOrCreateArchetype(spellMapping[spellId]));
|
||||
gameObject.addLast(spell);
|
||||
countSpellObjects++;
|
||||
}
|
||||
}
|
||||
|
||||
gameObject.removeAttribute(spellAttribute);
|
||||
if (gameObject.getArchetype().getAttributeString("randomitems").length() > 0) {
|
||||
if (gameObject.getArchetype().getAttributeString("randomitems").length() > 0) {
|
||||
gameObject.setAttributeString("randomitems", "none");
|
||||
} else {
|
||||
gameObject.removeAttribute("randomitems");
|
||||
|
@ -272,38 +271,39 @@ void convertGameObject(GameObject gameObject) {
|
|||
void convertMap(File mapFile, String mapPath) {
|
||||
print(mapPath);
|
||||
|
||||
mapControl = mapManager.openMapFile(mapFile, false);
|
||||
if (mapControl == null) {
|
||||
print("Cannot load map file");
|
||||
try {
|
||||
map = mapManager.openMapFile(mapFile, false);
|
||||
} catch (IOException ex) {
|
||||
String message = ex.getMessage();
|
||||
if (!message.startsWith("unexpected first line of map ")) {
|
||||
print("Cannot load map '"+mapFile+"': "+ex.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
mapControl.getMapModel().beginTransaction("spell conversion");
|
||||
mapModel = map.getMapModel();
|
||||
mapModel.beginTransaction("spell conversion");
|
||||
try {
|
||||
Iterator it1 = mapControl.getAllSquares().iterator();
|
||||
while (it1.hasNext()) {
|
||||
MapSquare mapSquare = it1.next();
|
||||
Iterator it2 = mapSquare.iterator();
|
||||
while (it2.hasNext()) {
|
||||
GameObject gameObject = it2.next();
|
||||
convertGameObject(gameObject);
|
||||
}
|
||||
Iterator it = mapModel.getAllGameObjects().iterator();
|
||||
while (it.hasNext()) {
|
||||
GameObject gameObject = it.next();
|
||||
convertGameObject(gameObject);
|
||||
}
|
||||
} finally {
|
||||
mapControl.getMapModel().endTransaction();
|
||||
mapModel.endTransaction();
|
||||
}
|
||||
|
||||
if (mapControl.isModified()) {
|
||||
if (mapModel.isModified()) {
|
||||
countMapFiles++;
|
||||
mapControl.save();
|
||||
map.save();
|
||||
}
|
||||
} finally {
|
||||
mapManager.release(mapControl);
|
||||
mapManager.release(map);
|
||||
}
|
||||
}
|
||||
|
||||
if (baseDirectory == null || baseDirectory.length() <= 0) {
|
||||
if (baseDirectory == null || baseDirectory.length() <= 0) {
|
||||
baseDirectory = "/";
|
||||
}
|
||||
print("Converting spellcasting objects maps below " + baseDirectory + "...");
|
||||
|
@ -316,25 +316,45 @@ String rootDirectory = mapDefaultFolder + baseDirectory;
|
|||
Iterator it = new RecursiveFileIterator(new File(rootDirectory));
|
||||
while (it.hasNext()) {
|
||||
File file = it.next();
|
||||
String name = file.getName();
|
||||
String path = file.getPath();
|
||||
if (file.isFile()
|
||||
&& file.getPath().startsWith(rootDirectory)
|
||||
&& !file.getName().equalsIgnoreCase("README")
|
||||
&& !file.getName().endsWith(".msg")) {
|
||||
&& path.startsWith(rootDirectory)
|
||||
&& !name.endsWith(".animation")
|
||||
&& !name.endsWith(".msg")
|
||||
&& !name.endsWith(".png")
|
||||
&& !name.endsWith(".ppm")
|
||||
&& !name.endsWith(".py")
|
||||
&& !name.endsWith(".pyc")
|
||||
&& !name.endsWith(".quests")
|
||||
&& !name.endsWith(".txt")
|
||||
&& !name.endsWith(".zip")
|
||||
&& !name.equals(".emergency")
|
||||
&& !name.equals(".gitignore")
|
||||
&& !name.equals("COPYING")
|
||||
&& !name.equals("ChangeLog")
|
||||
&& !name.equals("TODO")
|
||||
&& !name.equals("__pycache__")
|
||||
&& !name.equals("pshop_copier")
|
||||
&& !name.equals("pshops_changelog")
|
||||
&& !name.equalsIgnoreCase("README")
|
||||
&& !path.contains("/.git/")
|
||||
&& !path.contains("/Info/")
|
||||
&& !path.contains("/editor/scripts/")) {
|
||||
convertMap(file, file.getPath().substring(mapDefaultFolder.length()));
|
||||
}
|
||||
}
|
||||
|
||||
print("Done. Created " + countSpellObjects + " spell objects in " + countMapFiles + " map files.");]]></code>
|
||||
<mode>
|
||||
<autoboot>false</autoboot>
|
||||
<bash>false</bash>
|
||||
<filter>false</filter>
|
||||
</mode>
|
||||
<parameter>
|
||||
<name>baseDirectory</name>
|
||||
<description>Base Directory</description>
|
||||
<type>MapPathParameter</type>
|
||||
<value>/</value>
|
||||
</parameter>
|
||||
</script>
|
||||
|
||||
print("Done. Created " + countSpellObjects + " spell objects in " + countMapFiles + " map files.");</code>
|
||||
<mode>
|
||||
<autoboot>false</autoboot>
|
||||
<bash>false</bash>
|
||||
<filter>false</filter>
|
||||
</mode>
|
||||
<parameter>
|
||||
<name>baseDirectory</name>
|
||||
<description>Base Directory</description>
|
||||
<type>MapPathParameter</type>
|
||||
<value>/</value>
|
||||
</parameter>
|
||||
</script>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<script>
|
||||
<name>MapNormalizer</name>
|
||||
<code><![CDATA[import java.io.File;
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<script>
|
||||
<name>MapNormalizer</name>
|
||||
<code xml:space="preserve">import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import net.sf.gridarta.gui.dialog.shrinkmapsize.ShrinkMapSizeUtils;
|
||||
import net.sf.gridarta.map.mapmodel.MapModel;
|
||||
import net.sf.gridarta.map.mapmodel.MapSquare;
|
||||
import net.sf.gridarta.model.archetype.AttributeListUtils;
|
||||
import net.sf.gridarta.model.direction.Direction;
|
||||
import net.sf.gridarta.model.gameobject.GameObject;
|
||||
import net.sf.gridarta.model.io.AttributeListUtils;
|
||||
import net.sf.gridarta.model.io.RecursiveFileIterator;
|
||||
|
||||
void normalizeGameObject(GameObject gameObject) {
|
||||
|
@ -26,7 +26,10 @@ void normalizeMap(File mapFile, String mapPath) {
|
|||
try {
|
||||
map = mapManager.openMapFile(mapFile, false);
|
||||
} catch (IOException ex) {
|
||||
print("Cannot load map '"+mapFile+"': "+ex.getMessage());
|
||||
String message = ex.getMessage();
|
||||
if (!message.startsWith("unexpected first line of map ")) {
|
||||
print("Cannot load map '"+mapFile+"': "+ex.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -35,20 +38,22 @@ void normalizeMap(File mapFile, String mapPath) {
|
|||
mapModel.beginTransaction("Normalize");
|
||||
try {
|
||||
if (!mapPath.startsWith("/styles")
|
||||
&& !mapPath.startsWith("/editor/pickmaps")
|
||||
&& !mapPath.startsWith("/editor/walls")) {
|
||||
&& !mapPath.startsWith("/editor/pickmaps")
|
||||
&& !mapPath.startsWith("/editor/walls")
|
||||
&& !mapPath.endsWith("/.gitignore")
|
||||
&& !mapPath.endsWith("/__pycache__")) {
|
||||
mapArchObject = mapModel.getMapArchObject();
|
||||
int shrinkFlags = 0;
|
||||
if (mapArchObject.getTilePath(Direction.NORTH).length() <= 0 && mapArchObject.getTilePath(Direction.SOUTH).length() <= 0) {
|
||||
if (mapArchObject.getTilePath(Direction.NORTH).length() <= 0 && mapArchObject.getTilePath(Direction.SOUTH).length() <= 0) {
|
||||
shrinkFlags |= ShrinkMapSizeUtils.SHRINK_EAST;
|
||||
}
|
||||
if (mapArchObject.getTilePath(Direction.EAST).length() <= 0 && mapArchObject.getTilePath(Direction.WEST).length() <= 0) {
|
||||
if (mapArchObject.getTilePath(Direction.EAST).length() <= 0 && mapArchObject.getTilePath(Direction.WEST).length() <= 0) {
|
||||
shrinkFlags |= ShrinkMapSizeUtils.SHRINK_SOUTH;
|
||||
}
|
||||
ShrinkMapSizeUtils.shrinkMap(mapModel, shrinkFlags);
|
||||
}
|
||||
|
||||
Iterator it = mapModel.iterator ();
|
||||
Iterator it = mapModel.iterator();
|
||||
while (it.hasNext()) {
|
||||
Iterator it2 = it.next().iterator();
|
||||
while (it2.hasNext()) {
|
||||
|
@ -59,7 +64,7 @@ void normalizeMap(File mapFile, String mapPath) {
|
|||
mapModel.endTransaction();
|
||||
}
|
||||
|
||||
if (map.getMapModel().isModified()) {
|
||||
if (mapModel.isModified()) {
|
||||
map.save();
|
||||
}
|
||||
} finally {
|
||||
|
@ -67,7 +72,7 @@ void normalizeMap(File mapFile, String mapPath) {
|
|||
}
|
||||
}
|
||||
|
||||
if (baseDirectory == null || baseDirectory.length() <= 0) {
|
||||
if (baseDirectory == null || baseDirectory.length() <= 0) {
|
||||
baseDirectory = "/";
|
||||
}
|
||||
print("Normalizing maps below " + baseDirectory + "...");
|
||||
|
@ -83,37 +88,42 @@ while (it.hasNext()) {
|
|||
String name = file.getName();
|
||||
String path = file.getPath();
|
||||
if (file.isFile()
|
||||
&& path.startsWith(rootDirectory)
|
||||
&& !name.equalsIgnoreCase("README")
|
||||
&& !name.endsWith(".msg")
|
||||
&& !name.endsWith(".py")
|
||||
&& !name.endsWith(".png")
|
||||
&& !name.endsWith(".ppm")
|
||||
&& !name.endsWith(".quests")
|
||||
&& !name.endsWith(".animation")
|
||||
&& !name.equals("pshop_copier")
|
||||
&& !name.equals("pshops_changelog")
|
||||
&& !name.equals(".emergency")
|
||||
&& !name.equals("ChangeLog")
|
||||
&& !name.equals("COPYING")
|
||||
&& !path.contains("/.git/")
|
||||
&& !path.contains("/Info/")
|
||||
&& !path.contains("/editor/scripts/")) {
|
||||
&& path.startsWith(rootDirectory)
|
||||
&& !name.endsWith(".animation")
|
||||
&& !name.endsWith(".msg")
|
||||
&& !name.endsWith(".png")
|
||||
&& !name.endsWith(".ppm")
|
||||
&& !name.endsWith(".py")
|
||||
&& !name.endsWith(".pyc")
|
||||
&& !name.endsWith(".quests")
|
||||
&& !name.endsWith(".txt")
|
||||
&& !name.endsWith(".zip")
|
||||
&& !name.equals(".emergency")
|
||||
&& !name.equals(".gitignore")
|
||||
&& !name.equals("COPYING")
|
||||
&& !name.equals("ChangeLog")
|
||||
&& !name.equals("TODO")
|
||||
&& !name.equals("__pycache__")
|
||||
&& !name.equals("pshop_copier")
|
||||
&& !name.equals("pshops_changelog")
|
||||
&& !name.equalsIgnoreCase("README")
|
||||
&& !path.contains("/.git/")
|
||||
&& !path.contains("/Info/")
|
||||
&& !path.contains("/editor/scripts/")) {
|
||||
normalizeMap(file, file.getPath().substring(mapDefaultFolder.length()));
|
||||
}
|
||||
}
|
||||
|
||||
print("Done.");]]></code>
|
||||
<mode>
|
||||
<autoboot>false</autoboot>
|
||||
<bash>true</bash>
|
||||
<filter>false</filter>
|
||||
</mode>
|
||||
<parameter>
|
||||
<name>baseDirectory</name>
|
||||
<description>Base Directory</description>
|
||||
<type>MapPathParameter</type>
|
||||
<value>/</value>
|
||||
</parameter>
|
||||
</script>
|
||||
|
||||
print("Done.");</code>
|
||||
<mode>
|
||||
<autoboot>false</autoboot>
|
||||
<bash>true</bash>
|
||||
<filter>false</filter>
|
||||
</mode>
|
||||
<parameter>
|
||||
<name>baseDirectory</name>
|
||||
<description>Base Directory</description>
|
||||
<type>MapPathParameter</type>
|
||||
<value>/</value>
|
||||
</parameter>
|
||||
</script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<script>
|
||||
<name>MapValidator</name>
|
||||
<code><![CDATA[import java.io.BufferedWriter;
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<script>
|
||||
<name>MapValidator</name>
|
||||
<code xml:space="preserve">import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.Iterator;
|
||||
|
@ -22,12 +22,10 @@ void checkMap(File mapFile, String mapPath) {
|
|||
try {
|
||||
map = mapManager.openMapFile(mapFile, false);
|
||||
} catch (IOException ex) {
|
||||
print("Cannot load map '"+mapFile+"': "+ex.getMessage());
|
||||
return;
|
||||
}
|
||||
if (map == null) {
|
||||
log(mapPath + ":");
|
||||
log("- cannot load map file");
|
||||
String message = ex.getMessage();
|
||||
if (!message.startsWith("unexpected first line of map ")) {
|
||||
print("Cannot load map '"+mapFile+"': "+ex.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -48,8 +46,8 @@ void checkMap(File mapFile, String mapPath) {
|
|||
while (it.hasNext()) {
|
||||
ValidationError validationError = it.next();
|
||||
|
||||
if (errorLimit > 0 && numberOfErrors >= errorLimit) {
|
||||
log("- <skipping more errors>");
|
||||
if (errorLimit > 0 && numberOfErrors >= errorLimit) {
|
||||
log("- <skipping more errors>");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -83,9 +81,9 @@ void checkMap(File mapFile, String mapPath) {
|
|||
}
|
||||
}
|
||||
|
||||
Writer logFile = logFilename.length() <= 0 ? null : new BufferedWriter(new FileWriter(logFilename));
|
||||
Writer logFile = logFilename.length() <= 0 ? null : new BufferedWriter(new FileWriter(logFilename));
|
||||
try {
|
||||
if (baseDirectory == null || baseDirectory.length() <= 0) {
|
||||
if (baseDirectory == null || baseDirectory.length() <= 0) {
|
||||
baseDirectory = "/";
|
||||
}
|
||||
log("Checking maps below " + baseDirectory + "...");
|
||||
|
@ -101,26 +99,28 @@ try {
|
|||
String name = file.getName();
|
||||
String path = file.getPath();
|
||||
if (file.isFile()
|
||||
&& path.startsWith(rootDirectory)
|
||||
&& !name.equalsIgnoreCase("README")
|
||||
&& !name.endsWith(".animation")
|
||||
&& !name.endsWith(".msg")
|
||||
&& !name.endsWith(".png")
|
||||
&& !name.endsWith(".ppm")
|
||||
&& !name.endsWith(".py")
|
||||
&& !name.endsWith(".pyc")
|
||||
&& !name.endsWith(".quests")
|
||||
&& !name.endsWith(".txt")
|
||||
&& !name.endsWith(".zip")
|
||||
&& !name.equals("pshop_copier")
|
||||
&& !name.equals("pshops_changelog")
|
||||
&& !name.equals(".emergency")
|
||||
&& !name.equals("ChangeLog")
|
||||
&& !name.equals("COPYING")
|
||||
&& !name.equals("TODO")
|
||||
&& !path.contains("/.git/")
|
||||
&& !path.contains("/Info/")
|
||||
&& !path.contains("/editor/scripts/")) {
|
||||
&& path.startsWith(rootDirectory)
|
||||
&& !name.endsWith(".animation")
|
||||
&& !name.endsWith(".msg")
|
||||
&& !name.endsWith(".png")
|
||||
&& !name.endsWith(".ppm")
|
||||
&& !name.endsWith(".py")
|
||||
&& !name.endsWith(".pyc")
|
||||
&& !name.endsWith(".quests")
|
||||
&& !name.endsWith(".txt")
|
||||
&& !name.endsWith(".zip")
|
||||
&& !name.equals(".emergency")
|
||||
&& !name.equals(".gitignore")
|
||||
&& !name.equals("COPYING")
|
||||
&& !name.equals("ChangeLog")
|
||||
&& !name.equals("TODO")
|
||||
&& !name.equals("__pycache__")
|
||||
&& !name.equals("pshop_copier")
|
||||
&& !name.equals("pshops_changelog")
|
||||
&& !name.equalsIgnoreCase("README")
|
||||
&& !path.contains("/.git/")
|
||||
&& !path.contains("/Info/")
|
||||
&& !path.contains("/editor/scripts/")) {
|
||||
checkMap(file, file.getPath().substring(mapDefaultFolder.length()));
|
||||
}
|
||||
}
|
||||
|
@ -130,31 +130,30 @@ try {
|
|||
if (logFile != null) {
|
||||
logFile.close();
|
||||
}
|
||||
}]]></code>
|
||||
<mode>
|
||||
<autoboot>false</autoboot>
|
||||
<bash>true</bash>
|
||||
<filter>false</filter>
|
||||
</mode>
|
||||
<parameter>
|
||||
<name>baseDirectory</name>
|
||||
<description>Base Directory</description>
|
||||
<type>MapPathParameter</type>
|
||||
<value>/</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>errorLimit</name>
|
||||
<description>Maximum number of errors to show for each map; 0=show all errors</description>
|
||||
<type>java.lang.Integer</type>
|
||||
<value>20</value>
|
||||
<minimum>0</minimum>
|
||||
<maximum>2147483647</maximum>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>logFilename</name>
|
||||
<description>Copy errors to this file; empty=no copy to file</description>
|
||||
<type>java.lang.String</type>
|
||||
<value />
|
||||
</parameter>
|
||||
</script>
|
||||
|
||||
}</code>
|
||||
<mode>
|
||||
<autoboot>false</autoboot>
|
||||
<bash>true</bash>
|
||||
<filter>false</filter>
|
||||
</mode>
|
||||
<parameter>
|
||||
<name>baseDirectory</name>
|
||||
<description>Base Directory</description>
|
||||
<type>MapPathParameter</type>
|
||||
<value>/</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>errorLimit</name>
|
||||
<description>Maximum number of errors to show for each map; 0=show all errors</description>
|
||||
<type>java.lang.Integer</type>
|
||||
<value>20</value>
|
||||
<minimum>0</minimum>
|
||||
<maximum>2147483647</maximum>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>logFilename</name>
|
||||
<description>Copy errors to this file; empty=no copy to file</description>
|
||||
<type>java.lang.String</type>
|
||||
<value/>
|
||||
</parameter>
|
||||
</script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<script>
|
||||
<name>WorldMaker</name>
|
||||
<code><![CDATA[import cfeditor.IGUIConstants;
|
||||
<code xml:space="preserve">import cfeditor.IGUIConstants;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.RandomAccessFile;
|
||||
|
@ -13,7 +13,7 @@ import java.nio.channels.FileChannel;
|
|||
File getSimpleFilename(File mapFile) {
|
||||
String mapFilename = mapFile.getPath();
|
||||
int i = mapFilename.lastIndexOf(File.separator);
|
||||
if (i > 0) {
|
||||
if (i > 0) {
|
||||
mapFilename = mapFilename.substring(i + 1);
|
||||
}
|
||||
return new File(mapFilename);
|
||||
|
@ -27,7 +27,7 @@ boolean updateMap(File mapFile, File pictureFile) {
|
|||
if (!mapFile.exists()) {
|
||||
return false;
|
||||
}
|
||||
if (pictureFile.exists() && pictureFile.lastModified() >= mapFile.lastModified()) {
|
||||
if (pictureFile.exists() && pictureFile.lastModified() >= mapFile.lastModified()) {
|
||||
return false;
|
||||
}
|
||||
print("converting " + mapFile + " to " + pictureFile + ".");
|
||||
|
@ -94,7 +94,7 @@ void checkDaList() {
|
|||
FileOutputStream fos = new FileOutputStream(tempFile, false);
|
||||
fos.write(header);
|
||||
byte[] buf = new byte[(int) DestWidth.intValue() * bytesPerPixel];
|
||||
for (int i = 0; i < DestHeight.intValue(); i++) {
|
||||
for (int i = 0; i < DestHeight.intValue(); i++) {
|
||||
fos.write(buf);
|
||||
}
|
||||
fos.close();
|
||||
|
@ -106,22 +106,22 @@ void checkDaList() {
|
|||
byte[] buf = new byte[bytesPerPixel * TileWidth.intValue() * TileHeight.intValue()];
|
||||
|
||||
File tempImageFile = new File("/tmp/ppm.tmp");
|
||||
for (int x = 0; x < NumX.intValue(); x++) {
|
||||
for (int y = 0; y < NumY.intValue(); y++) {
|
||||
for (int x = 0; x < NumX.intValue(); x++) {
|
||||
for (int y = 0; y < NumY.intValue(); y++) {
|
||||
currentX = StartX.intValue() + x;
|
||||
currentY = StartY.intValue() + y;
|
||||
currentMap = new File(locationDir, MapFilename + "_" + currentX + "_" + currentY);
|
||||
currentPicture = getPngImageFilename(currentMap);
|
||||
didUpdate = updateMap(currentMap, currentPicture);
|
||||
if ((didUpdate || firstRun) && currentPicture.exists()) {
|
||||
runCommand("pngtopnm '" + currentPicture + "' | pnmscale -xysize " + TileWidth + " " + TileHeight + " > '" + tempImageFile + "'");
|
||||
if ((didUpdate || firstRun) && currentPicture.exists()) {
|
||||
runCommand("pngtopnm '" + currentPicture + "' | pnmscale -xysize " + TileWidth + " " + TileHeight + " > '" + tempImageFile + "'");
|
||||
FileInputStream fis = new FileInputStream(tempImageFile);
|
||||
fis.skip(toSkip);
|
||||
fis.read(buf);
|
||||
sx = x * TileWidth.intValue();
|
||||
sy = y * TileHeight.intValue();
|
||||
long index = ((long) sy * (long) DestWidth.intValue() + (long) sx) * bytesPerPixel + headerSize;
|
||||
for (long row = 0; row < TileHeight.intValue(); row++) {
|
||||
for (long row = 0; row < TileHeight.intValue(); row++) {
|
||||
MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_WRITE, index + row * DestWidth.intValue() * bytesPerPixel, TileWidth.intValue() * bytesPerPixel);
|
||||
mbb.put(buf, (int) (row * TileWidth.intValue() * bytesPerPixel), (int) (TileWidth.intValue() * bytesPerPixel));
|
||||
}
|
||||
|
@ -131,13 +131,13 @@ void checkDaList() {
|
|||
raf.close();
|
||||
runCommand("mv " + tempFile + " '" + destinationFilePpm + "'");
|
||||
print("converting to png if possible.\n");
|
||||
runCommand("pnmtopng '" + destinationFilePpm + "' > /tmp/tmp.png");
|
||||
runCommand("pnmtopng '" + destinationFilePpm + "' > /tmp/tmp.png");
|
||||
runCommand("mv /tmp/tmp.png '" + destinationFilePng + "'");
|
||||
}
|
||||
|
||||
File locationDir;
|
||||
checkDaList();
|
||||
print("Done!");]]></code>
|
||||
print("Done!");</code>
|
||||
<mode>
|
||||
<autoboot>false</autoboot>
|
||||
<bash>true</bash>
|
||||
|
@ -147,7 +147,7 @@ print("Done!");]]></code>
|
|||
<name>Location</name>
|
||||
<description>Specify the map directory to use by this script. Leave empty for maps directory</description>
|
||||
<type>java.lang.String</type>
|
||||
<value />
|
||||
<value/>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>MapFilename</name>
|
||||
|
@ -216,4 +216,3 @@ print("Done!");]]></code>
|
|||
<value>worldmap</value>
|
||||
</parameter>
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue