Load Effects.cfg, ModTypes.cfg and CompoundCurves.cfg at world boot
CompoundCurveParser keeps every curve segment (the CompoundCurveType enum holds one value per curve). ModTypeParser keeps each mod type's Behavior, which decides the argument layout of a MODS line. EffectParser loads Effects.cfg into EffectTemplate._effects: header, the four flag keys (case-insensitive, as in the client), SOURCE lines, every MODS line in order, and CONDITION lines. Mod layouts follow the client's ArcMod*_Parse functions; curve names in effects and power actions must exist in CompoundCurves.cfg. Boot order: curves, mod types, power actions, effects. No consumers change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c820940d3
commit
623f7c4ae6
9 files changed
+584
-3
No files matched your search
@@ -0,0 +1,101 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2026
|
||||
// https://www.magicbane.com
|
||||
|
||||
package engine.parsers.wpak;
|
||||
|
||||
import engine.parsers.objects.wpak.CompoundCurveTemplate;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
// Loads CompoundCurves.cfg.
|
||||
|
||||
public class CompoundCurveParser {
|
||||
|
||||
private static final String fileName = "CompoundCurves.cfg";
|
||||
|
||||
// Segments run back to back on one line, so the param count per simple curve
|
||||
// is what tells where the next segment starts.
|
||||
private static final HashMap<String, Integer> paramCounts = new HashMap<>();
|
||||
|
||||
static {
|
||||
paramCounts.put("FlatLine", 0);
|
||||
paramCounts.put("SlopedLine", 1);
|
||||
paramCounts.put("SlopedInitValLine", 1);
|
||||
}
|
||||
|
||||
public static HashMap<String, CompoundCurveTemplate> parseCompoundCurvesFile() {
|
||||
|
||||
HashMap<String, CompoundCurveTemplate> curves = new HashMap<>();
|
||||
ArrayList<WpakLine> lines;
|
||||
CompoundCurveTemplate curve;
|
||||
int failedCount = 0;
|
||||
|
||||
try {
|
||||
lines = WpakFileReader.readLines(fileName);
|
||||
} catch (Exception e) {
|
||||
Logger.error(fileName + ": " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
for (WpakLine line : lines) {
|
||||
try {
|
||||
curve = parseCurveLine(line);
|
||||
|
||||
if (curves.containsKey(curve.name))
|
||||
throw line.error("duplicate curve " + curve.name);
|
||||
|
||||
curves.put(curve.name, curve);
|
||||
} catch (WpakFormatException e) {
|
||||
Logger.error(e.getMessage());
|
||||
failedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.info("Loaded " + curves.size() + " of " + lines.size() + " compound curves");
|
||||
|
||||
if (failedCount > 0)
|
||||
return null;
|
||||
|
||||
return curves;
|
||||
}
|
||||
|
||||
private static CompoundCurveTemplate parseCurveLine(WpakLine line) {
|
||||
|
||||
CompoundCurveTemplate curve = new CompoundCurveTemplate();
|
||||
CompoundCurveTemplate.Segment segment;
|
||||
Integer paramCount;
|
||||
int index = 1;
|
||||
|
||||
curve.name = line.token(0);
|
||||
|
||||
while (line.has(index)) {
|
||||
segment = new CompoundCurveTemplate.Segment();
|
||||
segment.down_per_range = line.intToken(index);
|
||||
segment.simple_curve = line.token(index + 1);
|
||||
paramCount = paramCounts.get(segment.simple_curve);
|
||||
|
||||
if (paramCount == null)
|
||||
throw line.error("unknown simple curve " + segment.simple_curve);
|
||||
|
||||
segment.params = new float[paramCount];
|
||||
|
||||
for (int i = 0; i < paramCount; i++)
|
||||
segment.params[i] = line.floatToken(index + 2 + i);
|
||||
|
||||
curve.segments.add(segment);
|
||||
index += 2 + paramCount;
|
||||
}
|
||||
|
||||
if (curve.segments.isEmpty())
|
||||
throw line.error("curve " + curve.name + " has no segments");
|
||||
|
||||
return curve;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user