Skip to content

Commit

Permalink
Fixed compile errors in 'camera', 'decal', 'distribute', 'game', 'gam…
Browse files Browse the repository at this point in the history
…eModel', 'metaParticle', 'particle', and 'sequence' effects. Fixed compile error in .pollen_metadata. Fixed compile error in .summary
  • Loading branch information
emd4600 committed Jun 20, 2023
1 parent 05534cf commit bc2191d
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/sporemodder/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

public class Launcher {

public static final String VERSION = "2.2.1";
public static final String VERSION = "2.2.2";

public static void main(String[] args) throws InterruptedException {
if (args.length == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/sporemodder/file/effects/CameraEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public void toArgScript(ArgScriptWriter writer) {
writer.command("flags").arguments(HashManager.get().hexToString(maskedFlags));
}
if (maskedControlFlags != 0) {
writer.option("controlFlags").arguments(HashManager.get().hexToString(maskedControlFlags));
writer.command("controlFlags").arguments(HashManager.get().hexToString(maskedControlFlags));
}

writer.endBlock().commandEND();
Expand Down
8 changes: 5 additions & 3 deletions src/sporemodder/file/effects/DecalEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,12 @@ public void toArgScript(ArgScriptWriter writer) {

writer.command("type").arguments(ENUM_TYPE.get(type));

if (!(color.size() == 1 && color.get(0).isWhite())) writer.command("color").colors(color);
if (!writer.isDefaultColor(color)) writer.command("color").colors(color);

if (!(alpha.size() == 1 && alpha.get(0) == 1.0f)) writer.command("alpha").floats(alpha);
if (alphaVary != 0.0f) writer.option("vary").floats(alphaVary);
if (!writer.isDefault(alpha, 1.0f) || alphaVary != 0.0f) {
writer.command("alpha").floats(alpha);
if (alphaVary != 0.0f) writer.option("vary").floats(alphaVary);
}

writer.command("size").floats(size);
if (sizeVary != 0.0f) writer.option("vary").floats(sizeVary);
Expand Down
11 changes: 6 additions & 5 deletions src/sporemodder/file/effects/DistributeEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,12 @@ private void writeTransform(StreamWriter out) throws IOException {
out.writeInt(flags);
out.writeInt(density);
if (component != null) {
out.writeInt(effectDirectory.getIndex(component.getFactory().getTypeCode(), component));
out.writeByte(component.getFactory().getTypeCode());
int typeCode = component.getFactory() == null ? VisualEffect.TYPE_CODE : component.getFactory().getTypeCode();
out.writeInt(effectDirectory.getIndex(typeCode, component));
out.writeByte(typeCode);
}
else {
out.writeInt(0);
out.writeInt(-1);
out.writeByte(0);
}
out.writeInt(start);
Expand Down Expand Up @@ -807,7 +808,7 @@ public void toArgScript(ArgScriptWriter writer) {

if ((flags & FLAGS_ATTACH) != 0) {
writer.command("attach");
if (component instanceof VisualEffect) {
if (component.getFactory() == null || component.getFactory().getTypeCode() == VisualEffect.TYPE_CODE) {
writer.arguments(component.getName());
}
else {
Expand All @@ -816,7 +817,7 @@ public void toArgScript(ArgScriptWriter writer) {
transform.toArgScriptNoDefault(writer, false);
}
else if (component != null) {
if (component instanceof VisualEffect) {
if (component.getFactory() == null || component.getFactory().getTypeCode() == VisualEffect.TYPE_CODE) {
writer.command("effect").arguments(component.getName());
}
else {
Expand Down
40 changes: 40 additions & 0 deletions src/sporemodder/file/effects/EffectDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -31,9 +32,11 @@
import java.util.Set;

import sporemodder.HashManager;
import sporemodder.MainApp;
import sporemodder.file.argscript.ArgScriptStream;
import sporemodder.file.argscript.ArgScriptWriter;
import sporemodder.file.dbpf.DBPFPacker;
import sporemodder.file.filestructures.FileStream;
import sporemodder.file.filestructures.StreamReader;
import sporemodder.file.filestructures.StreamWriter;

Expand Down Expand Up @@ -805,4 +808,41 @@ public static void copyArray(int[] dest, int[] source) {
public static <T> void copyArray(T[] dest, T[] source) {
for (int i = 0; i < dest.length; ++i) dest[i] = source[i];
}

public static void main(String[] args) throws FileNotFoundException, IOException {
MainApp.testInit();

String path = "E:\\Eric\\Eclipse Projects\\SporeModder FX\\Projects\\Effects\\gameEffects_3~";

for (File file : new File(path).listFiles()) {
if (file.getName().endsWith(".effdir")) {
File outputFolder = new File(path, file.getName() + ".unpacked");
try (StreamReader stream = new FileStream(file, "r")) {
EffectDirectory effdir = new EffectDirectory();
effdir.read(stream);
effdir.toArgScript(outputFolder);
}

for (File pfxFile : outputFolder.listFiles()) {
EffectDirectory effdir = new EffectDirectory();
EffectUnit unit = new EffectUnit(effdir);
ArgScriptStream<EffectUnit> stream = unit.generateStream();
stream.process(pfxFile);

if (!stream.getErrors().isEmpty()) {
System.out.println("ERROR: " + pfxFile.getAbsolutePath());
}
if (!stream.getWarnings().isEmpty()) {
System.out.println("WARNING: " + pfxFile.getAbsolutePath());
}
}

EffectDirectory effdir = new EffectDirectory();
effdir.process(outputFolder, null);
try (StreamWriter stream = new FileStream(outputFolder.getPath() + ".effdir", "rw")) {
effdir.write(stream);
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/sporemodder/file/effects/GameEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ else if (line.getOptionArguments(args, "message", 1)) {
effect.messageString = args.get(0);
}

if (line.hasOption("onStop")) {
if (line.hasFlag("onStop")) {
effect.flags |= FLAGS_MESSAGE_ON_STOP;
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/sporemodder/file/effects/GameModelEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ public void toArgScript(ArgScriptWriter writer) {
boolean isFixed = (flags & FLAGS_FIXED_SIZE) != 0;
if (size != 1.0f || isFixed) {
writer.command("size").floats(size);
writer.flag("flag", isFixed);
writer.flag("fixed", isFixed);
}

if (!color.isWhite()) writer.command("color").color(color);
Expand Down
12 changes: 6 additions & 6 deletions src/sporemodder/file/effects/MetaParticleEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,9 @@ void writeEffect(String fieldName, StreamWriter out, Object value) throws IOExce
out.writeInt(-1);
out.writeInt(0);
} else {
out.writeInt(effectDirectory.getIndex(component.getFactory().getTypeCode(), component));
out.writeInt(component.getFactory().getTypeCode());
int typeCode = component.getFactory() == null ? VisualEffect.TYPE_CODE : component.getFactory().getTypeCode();
out.writeInt(effectDirectory.getIndex(typeCode, component));
out.writeInt(typeCode);
}
}

Expand Down Expand Up @@ -1522,7 +1523,7 @@ public void toArgScript(ArgScriptWriter writer) {
writeRate(writer);

if (component != null) {
if (component.getFactory().getTypeCode() == VisualEffect.TYPE_CODE) {
if (component.getFactory() == null || component.getFactory().getTypeCode() == VisualEffect.TYPE_CODE) {
writer.command("effect").arguments(component.getName());
}
else {
Expand Down Expand Up @@ -1756,11 +1757,10 @@ private void writeWarp(ArgScriptWriter writer) {
commandWritten = true;
writer.option("bloomSize").floats(screenBloomScaleBase / 255.0f, (screenBloomScaleRate / 255.0f) / 0.0625f);
}

if (!wiggles.isEmpty()) {
if (!commandWritten) writer.command("warp");
commandWritten = true;
for (ParticleWiggle w : wiggles) {
writer.option("wiggleDir").floats(w.timeRate).vector(w.wiggleDirection);
writer.command("warp").option("wiggleDir").floats(w.timeRate).vector(w.wiggleDirection);
if (w.rateDirection[0] != 0 || w.rateDirection[1] != 0 || w.rateDirection[2] != 0) {
writer.vector(w.rateDirection);
}
Expand Down
4 changes: 2 additions & 2 deletions src/sporemodder/file/effects/ParticleEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -1730,8 +1730,8 @@ private void writeWalk(ArgScriptWriter writer) {
writer.option("strength").floats(value);
if (vary != 0) writer.floats(vary);

if (randomWalk.turnRange != 0 || randomWalk.turnOffset != 0) {
writer.option("turn").floats(randomWalk.turnRange);
if (randomWalk.turnRange != 0.25f || randomWalk.turnOffset != 0) {
writer.option(isDirectedWalk ? "randomTurn" : "turn").floats(randomWalk.turnRange);
if (randomWalk.turnOffset != 0) writer.floats(randomWalk.turnOffset);
}

Expand Down
2 changes: 0 additions & 2 deletions src/sporemodder/file/effects/SequenceEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ public void toArgScript(ArgScriptWriter writer) {
}
}
}

if (ins.timeRange[0] != -1 || ins.timeRange[1] != -1) writer.option("range").floats(ins.timeRange);
}

int maskedFlags = flags & ~MASK_FLAGS;
Expand Down
3 changes: 3 additions & 0 deletions src/sporemodder/file/otdb/PollenMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,18 +400,21 @@ public ArgScriptStream<PollenMetadata> generateStream() {
if (line.getArguments(args, 1)) {
authorNameLocale = new ResourceID();
authorNameLocale.parse(args, 0);
useLocale = 1;
}
}));
stream.addParser("nameLocale", ArgScriptParser.create((parser, line) -> {
if (line.getArguments(args, 1)) {
nameLocale = new ResourceID();
nameLocale.parse(args, 0);
useLocale = 1;
}
}));
stream.addParser("descriptionLocale", ArgScriptParser.create((parser, line) -> {
if (line.getArguments(args, 1)) {
descriptionLocale = new ResourceID();
descriptionLocale.parse(args, 0);
useLocale = 1;
}
}));

Expand Down
7 changes: 6 additions & 1 deletion src/sporemodder/file/otdb/SummaryFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public class SummaryFile {
ENUM_PARAMETERS.add(0x5AC2B98, "sprintCapRange");
ENUM_PARAMETERS.add(0x68DE3E8, "senseCapRange");
ENUM_PARAMETERS.add(0x5AC2B99, "healthCapRange");

ENUM_PARAMETERS.add(0x2E0FCC74, "editorModelSaveLastChild");
ENUM_PARAMETERS.add(0x99524FAF, "editorModelForceSaveOver");
ENUM_PARAMETERS.add(0xAE773A29, "editorModelCopyConsequence");
ENUM_PARAMETERS.add(0xEC2942CD, "isMyCaptain");
}

public static final ArgScriptEnum ENUM_AMTAGS = new ArgScriptEnum();
Expand Down Expand Up @@ -156,7 +161,7 @@ public void toArgScript(ArgScriptWriter writer) {

String parameterString = ENUM_PARAMETERS.get(entry.getKey());
if (parameterString == null) {
parameterString = HashManager.get().getFileName(entry.getKey());
parameterString = HashManager.get().hexToString(entry.getKey());
}

writer.command("parameter").arguments(
Expand Down

0 comments on commit bc2191d

Please sign in to comment.