mirror of
https://github.com/Retera/WarsmashModEngine.git
synced 2022-07-31 17:38:59 +02:00
Updates for jass and triggers to attempt to open fun elves map
This commit is contained in:
parent
92fc60eb45
commit
50164d8ef7
@ -218,8 +218,15 @@ public class WarsmashGdxMenuScreen implements InputProcessor, Screen, SingleMode
|
||||
singleModelScene(WarsmashGdxMenuScreen.this.scene, War3MapViewer.mdx(rootFrame
|
||||
.getSkinField("GlueSpriteLayerBackground_V" + WarsmashConstants.GAME_VERSION)),
|
||||
"Stand");
|
||||
WarsmashGdxMenuScreen.this.modelCamera = WarsmashGdxMenuScreen.this.mainModel.cameras
|
||||
.get(0);
|
||||
if (!WarsmashGdxMenuScreen.this.mainModel.cameras.isEmpty()) {
|
||||
WarsmashGdxMenuScreen.this.modelCamera = WarsmashGdxMenuScreen.this.mainModel.cameras
|
||||
.get(0);
|
||||
}
|
||||
else {
|
||||
WarsmashGdxMenuScreen.this.mainInstance.detach();
|
||||
WarsmashGdxMenuScreen.this.mainInstance.setLocation(0, 0, 0);
|
||||
WarsmashGdxMenuScreen.this.mainInstance.setScene(WarsmashGdxMenuScreen.this.uiScene);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -344,7 +351,14 @@ public class WarsmashGdxMenuScreen implements InputProcessor, Screen, SingleMode
|
||||
}
|
||||
else {
|
||||
singleModelScene(this.scene, War3MapViewer.mdx(path), "birth");
|
||||
WarsmashGdxMenuScreen.this.modelCamera = WarsmashGdxMenuScreen.this.mainModel.cameras.get(0);
|
||||
if (!WarsmashGdxMenuScreen.this.mainModel.cameras.isEmpty()) {
|
||||
WarsmashGdxMenuScreen.this.modelCamera = WarsmashGdxMenuScreen.this.mainModel.cameras.get(0);
|
||||
}
|
||||
else {
|
||||
WarsmashGdxMenuScreen.this.mainInstance.detach();
|
||||
WarsmashGdxMenuScreen.this.mainInstance.setLocation(0, 0, 1024);
|
||||
WarsmashGdxMenuScreen.this.mainInstance.setScene(WarsmashGdxMenuScreen.this.uiScene);
|
||||
}
|
||||
// this hack is because we only have the queued animation system in RenderWidget
|
||||
// which is stupid and back and needs to get moved to the model instance
|
||||
// itself... our model instance class is a
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayerJass;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.region.CRegion;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimerJass;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.ui.dialog.CScriptDialog;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.ui.dialog.CScriptDialogButton;
|
||||
|
||||
@ -69,6 +70,7 @@ public class CommonTriggerExecutionScope extends TriggerExecutionScope {
|
||||
private CWidget triggerWidget;
|
||||
private CScriptDialog clickedDialog;
|
||||
private CScriptDialogButton clickedButton;
|
||||
private JassGameEventsWar3 triggerEventId;
|
||||
|
||||
public CommonTriggerExecutionScope(final Trigger triggeringTrigger) {
|
||||
super(triggeringTrigger);
|
||||
@ -142,6 +144,7 @@ public class CommonTriggerExecutionScope extends TriggerExecutionScope {
|
||||
this.triggerWidget = parentScope.triggerWidget;
|
||||
this.clickedDialog = parentScope.clickedDialog;
|
||||
this.clickedButton = parentScope.clickedButton;
|
||||
this.triggerEventId = parentScope.triggerEventId;
|
||||
}
|
||||
|
||||
public CUnit getEnumUnit() {
|
||||
@ -368,6 +371,10 @@ public class CommonTriggerExecutionScope extends TriggerExecutionScope {
|
||||
return this.clickedDialog;
|
||||
}
|
||||
|
||||
public JassGameEventsWar3 getTriggerEventId() {
|
||||
return this.triggerEventId;
|
||||
}
|
||||
|
||||
public static CommonTriggerExecutionScope filterScope(final TriggerExecutionScope parentScope,
|
||||
final CUnit filterUnit) {
|
||||
final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(parentScope.getTriggeringTrigger(),
|
||||
@ -436,67 +443,79 @@ public class CommonTriggerExecutionScope extends TriggerExecutionScope {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static CommonTriggerExecutionScope unitEnterRegionScope(final Trigger trigger,
|
||||
final TriggerExecutionScope parentScope, final CUnit enteringUnit, final CRegion triggeringRegion) {
|
||||
public static CommonTriggerExecutionScope unitEnterRegionScope(final JassGameEventsWar3 triggerEventId,
|
||||
final Trigger trigger, final TriggerExecutionScope parentScope, final CUnit enteringUnit,
|
||||
final CRegion triggeringRegion) {
|
||||
final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, parentScope);
|
||||
scope.enteringUnit = enteringUnit;
|
||||
scope.triggeringUnit = enteringUnit;
|
||||
scope.triggeringRegion = triggeringRegion;
|
||||
scope.triggerEventId = triggerEventId;
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static CommonTriggerExecutionScope unitLeaveRegionScope(final Trigger trigger,
|
||||
final TriggerExecutionScope parentScope, final CUnit leavingUnit, final CRegion triggeringRegion) {
|
||||
public static CommonTriggerExecutionScope unitLeaveRegionScope(final JassGameEventsWar3 triggerEventId,
|
||||
final Trigger trigger, final TriggerExecutionScope parentScope, final CUnit leavingUnit,
|
||||
final CRegion triggeringRegion) {
|
||||
final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, parentScope);
|
||||
scope.leavingUnit = leavingUnit;
|
||||
scope.triggeringUnit = leavingUnit;
|
||||
scope.triggeringRegion = triggeringRegion;
|
||||
scope.triggerEventId = triggerEventId;
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static CommonTriggerExecutionScope playerHeroLevelScope(final Trigger trigger, final CUnit hero) {
|
||||
public static CommonTriggerExecutionScope playerHeroLevelScope(final JassGameEventsWar3 triggerEventId,
|
||||
final Trigger trigger, final CUnit hero) {
|
||||
final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY);
|
||||
scope.triggeringUnit = hero;
|
||||
scope.levelingUnit = hero;
|
||||
scope.triggerEventId = triggerEventId;
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static CommonTriggerExecutionScope playerHeroRevivableScope(final Trigger trigger, final CUnit hero) {
|
||||
public static CommonTriggerExecutionScope playerHeroRevivableScope(final JassGameEventsWar3 triggerEventId,
|
||||
final Trigger trigger, final CUnit hero) {
|
||||
final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY);
|
||||
scope.triggeringUnit = hero;
|
||||
scope.revivableUnit = hero;
|
||||
scope.triggerEventId = triggerEventId;
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static CommonTriggerExecutionScope unitDeathScope(final Trigger trigger, final CUnit dyingUnit,
|
||||
final CUnit killingUnit) {
|
||||
public static CommonTriggerExecutionScope unitDeathScope(final JassGameEventsWar3 triggerEventId,
|
||||
final Trigger trigger, final CUnit dyingUnit, final CUnit killingUnit) {
|
||||
final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY);
|
||||
scope.dyingUnit = dyingUnit;
|
||||
scope.triggerWidget = dyingUnit;
|
||||
scope.triggeringUnit = dyingUnit;
|
||||
scope.killingUnit = killingUnit;
|
||||
scope.triggerEventId = triggerEventId;
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static CommonTriggerExecutionScope widgetTriggerScope(final Trigger trigger, final CWidget triggerWidget) {
|
||||
public static CommonTriggerExecutionScope widgetTriggerScope(final JassGameEventsWar3 triggerEventId,
|
||||
final Trigger trigger, final CWidget triggerWidget) {
|
||||
final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY);
|
||||
scope.triggerWidget = triggerWidget;
|
||||
scope.triggerEventId = triggerEventId;
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static CommonTriggerExecutionScope triggerDialogScope(final Trigger trigger,
|
||||
final CScriptDialog clickedDialog, final CScriptDialogButton clickedButton) {
|
||||
public static CommonTriggerExecutionScope triggerDialogScope(final JassGameEventsWar3 triggerEventId,
|
||||
final Trigger trigger, final CScriptDialog clickedDialog, final CScriptDialogButton clickedButton) {
|
||||
final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY);
|
||||
scope.clickedDialog = clickedDialog;
|
||||
scope.clickedButton = clickedButton;
|
||||
scope.triggerEventId = triggerEventId;
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static interface UnitEventScopeBuilder {
|
||||
CommonTriggerExecutionScope create(Trigger trigger, CUnit unit);
|
||||
CommonTriggerExecutionScope create(JassGameEventsWar3 triggerEventId, Trigger trigger, CUnit unit);
|
||||
}
|
||||
|
||||
public static interface WidgetEventScopeBuilder {
|
||||
CommonTriggerExecutionScope create(Trigger trigger, CWidget unit);
|
||||
CommonTriggerExecutionScope create(JassGameEventsWar3 triggerEventId, Trigger trigger, CWidget unit);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.etheller.interpreter.ast.function.JassFunction;
|
||||
import com.etheller.interpreter.ast.scope.GlobalScope;
|
||||
import com.etheller.interpreter.ast.scope.TriggerExecutionScope;
|
||||
import com.etheller.interpreter.ast.scope.trigger.TriggerBooleanExpression;
|
||||
import com.etheller.interpreter.ast.util.JassSettings;
|
||||
import com.etheller.interpreter.ast.value.JassValue;
|
||||
import com.etheller.interpreter.ast.value.visitor.BooleanJassValueVisitor;
|
||||
|
||||
@ -27,6 +28,9 @@ public class BoolExprCondition implements TriggerBooleanExpression {
|
||||
catch (final Exception e) {
|
||||
throw new JassException(globalScope, "Exception during BoolExprCondition.evaluate()", e);
|
||||
}
|
||||
if ((booleanJassReturnValue == null) && JassSettings.CONTINUE_EXECUTING_ON_ERROR) {
|
||||
return false;
|
||||
}
|
||||
final Boolean booleanReturnValue = booleanJassReturnValue.visit(BooleanJassValueVisitor.getInstance());
|
||||
return booleanReturnValue.booleanValue();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.etheller.interpreter.ast.function.JassFunction;
|
||||
import com.etheller.interpreter.ast.scope.GlobalScope;
|
||||
import com.etheller.interpreter.ast.scope.TriggerExecutionScope;
|
||||
import com.etheller.interpreter.ast.scope.trigger.TriggerBooleanExpression;
|
||||
import com.etheller.interpreter.ast.util.JassSettings;
|
||||
import com.etheller.interpreter.ast.value.JassValue;
|
||||
import com.etheller.interpreter.ast.value.visitor.BooleanJassValueVisitor;
|
||||
|
||||
@ -20,6 +21,9 @@ public class BoolExprFilter implements TriggerBooleanExpression {
|
||||
@Override
|
||||
public boolean evaluate(final GlobalScope globalScope, final TriggerExecutionScope triggerScope) {
|
||||
final JassValue booleanJassReturnValue;
|
||||
if (this.takesNothingReturnsBooleanFunction == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
booleanJassReturnValue = this.takesNothingReturnsBooleanFunction.call(Collections.EMPTY_LIST, globalScope,
|
||||
triggerScope);
|
||||
@ -27,6 +31,9 @@ public class BoolExprFilter implements TriggerBooleanExpression {
|
||||
catch (final Exception e) {
|
||||
throw new JassException(globalScope, "Exception during BoolExprFilter.evaluate()", e);
|
||||
}
|
||||
if ((booleanJassReturnValue == null) && JassSettings.CONTINUE_EXECUTING_ON_ERROR) {
|
||||
return false;
|
||||
}
|
||||
final Boolean booleanReturnValue = booleanJassReturnValue.visit(BooleanJassValueVisitor.getInstance());
|
||||
return booleanReturnValue.booleanValue();
|
||||
}
|
||||
|
7
core/src/com/etheller/warsmash/util/Test2.java
Normal file
7
core/src/com/etheller/warsmash/util/Test2.java
Normal file
@ -0,0 +1,7 @@
|
||||
package com.etheller.warsmash.util;
|
||||
|
||||
public class Test2 {
|
||||
public static void main(final String[] args) {
|
||||
System.out.println(new War3ID(1786017909));
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package com.etheller.warsmash.util;
|
||||
|
||||
public class WarsmashConstants {
|
||||
public static final int MAX_PLAYERS = 28;
|
||||
public static final int MAX_PLAYERS = 16;
|
||||
/*
|
||||
* With version, we use 0 for RoC, 1 for TFT emulation, and probably 2+ or
|
||||
* whatever for custom mods and other stuff
|
||||
*/
|
||||
public static int GAME_VERSION = 0;
|
||||
public static int GAME_VERSION = 1;
|
||||
public static final int REPLACEABLE_TEXTURE_LIMIT = 64;
|
||||
public static final float SIMULATION_STEP_TIME = 1 / 20f;
|
||||
public static final int PORT_NUMBER = 6115;
|
||||
@ -36,7 +36,7 @@ public class WarsmashConstants {
|
||||
// workaround to fix it if you need the local files
|
||||
// to take priority over built-ins for tilesets.
|
||||
public static final boolean FIX_FLAT_FILES_TILESET_LOADING = false;
|
||||
public static final boolean ENABLE_MUSIC = true;
|
||||
public static final boolean ENABLE_MUSIC = false;
|
||||
public static final boolean LOAD_UNITS_FROM_WORLDEDIT_DATA = false;
|
||||
public static final boolean LOCAL_TEMP_TEST_ALL_PLAYERS_PLAYING = true;
|
||||
public static final boolean CRASH_ON_INCOMPATIBLE_132_FEATURES = false;
|
||||
|
@ -559,12 +559,11 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
final War3ID typeId = source.getTypeId();
|
||||
final int projectileSpeed = unitAttack.getProjectileSpeed();
|
||||
final float projectileArc = unitAttack.getProjectileArc();
|
||||
String missileArt = unitAttack.getProjectileArt();
|
||||
final String missileArt = unitAttack.getProjectileArt();
|
||||
final float projectileLaunchX = simulation.getUnitData().getProjectileLaunchX(typeId);
|
||||
final float projectileLaunchY = simulation.getUnitData().getProjectileLaunchY(typeId);
|
||||
final float projectileLaunchZ = simulation.getUnitData().getProjectileLaunchZ(typeId);
|
||||
|
||||
missileArt = mdx(missileArt);
|
||||
final float facing = launchFacing;
|
||||
final float sinFacing = (float) Math.sin(facing);
|
||||
final float cosFacing = (float) Math.cos(facing);
|
||||
@ -576,8 +575,7 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
final CAttackProjectile simulationAttackProjectile = new CAttackProjectile(x, y,
|
||||
projectileSpeed, target, source, damage, unitAttack, bounceIndex, attackListener);
|
||||
|
||||
final MdxModel model = (MdxModel) load(missileArt, War3MapViewer.this.mapPathSolver,
|
||||
War3MapViewer.this.solverParams);
|
||||
final MdxModel model = loadModelMdx(missileArt);
|
||||
final MdxComplexInstance modelInstance = (MdxComplexInstance) model.addInstance();
|
||||
modelInstance.setTeamColor(source.getPlayerIndex());
|
||||
modelInstance.setScene(War3MapViewer.this.worldScene);
|
||||
@ -601,12 +599,11 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
final CUnitAttackInstant unitAttack, final CWidget target) {
|
||||
final War3ID typeId = source.getTypeId();
|
||||
|
||||
String missileArt = unitAttack.getProjectileArt();
|
||||
final String missileArt = unitAttack.getProjectileArt();
|
||||
final float projectileLaunchX = War3MapViewer.this.simulation.getUnitData()
|
||||
.getProjectileLaunchX(typeId);
|
||||
final float projectileLaunchY = War3MapViewer.this.simulation.getUnitData()
|
||||
.getProjectileLaunchY(typeId);
|
||||
missileArt = mdx(missileArt);
|
||||
final float facing = (float) Math.toRadians(source.getFacing());
|
||||
final float sinFacing = (float) Math.sin(facing);
|
||||
final float cosFacing = (float) Math.cos(facing);
|
||||
@ -622,8 +619,7 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
final float height = War3MapViewer.this.terrain.getGroundHeight(targetX, targetY)
|
||||
+ target.getFlyHeight() + target.getImpactZ();
|
||||
|
||||
final MdxModel model = (MdxModel) load(missileArt, War3MapViewer.this.mapPathSolver,
|
||||
War3MapViewer.this.solverParams);
|
||||
final MdxModel model = loadModelMdx(missileArt);
|
||||
final MdxComplexInstance modelInstance = (MdxComplexInstance) model.addInstance();
|
||||
modelInstance.setTeamColor(source.getPlayerIndex());
|
||||
SequenceUtils.randomBirthSequence(modelInstance);
|
||||
@ -818,7 +814,7 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
@Override
|
||||
public void spawnEffectOnUnit(final CUnit unit, final String effectPath) {
|
||||
final RenderUnit renderUnit = War3MapViewer.this.unitToRenderPeer.get(unit);
|
||||
final MdxModel spawnedEffectModel = (MdxModel) load(mdx(effectPath), PathSolver.DEFAULT, null);
|
||||
final MdxModel spawnedEffectModel = loadModelMdx(effectPath);
|
||||
if (spawnedEffectModel != null) {
|
||||
final MdxComplexInstance modelInstance = (MdxComplexInstance) spawnedEffectModel
|
||||
.addInstance();
|
||||
@ -925,7 +921,7 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
}
|
||||
|
||||
public void spawnFxOnOrigin(final RenderUnit renderUnit, final String heroLevelUpArt) {
|
||||
final MdxModel heroLevelUpModel = loadModel(heroLevelUpArt);
|
||||
final MdxModel heroLevelUpModel = loadModelMdx(heroLevelUpArt);
|
||||
if (heroLevelUpModel != null) {
|
||||
final MdxComplexInstance modelInstance = (MdxComplexInstance) heroLevelUpModel.addInstance();
|
||||
modelInstance.setTeamColor(renderUnit.playerIndex);
|
||||
@ -1433,8 +1429,7 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
MdxModel specialArtModel;
|
||||
if (unitSpecialArtPath != null) {
|
||||
try {
|
||||
specialArtModel = (MdxModel) this.load(mdx(unitSpecialArtPath), this.mapPathSolver,
|
||||
this.solverParams);
|
||||
specialArtModel = loadModelMdx(unitSpecialArtPath);
|
||||
}
|
||||
catch (final Exception exc) {
|
||||
exc.printStackTrace();
|
||||
@ -1444,11 +1439,11 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
else {
|
||||
specialArtModel = null;
|
||||
}
|
||||
final MdxModel model = (MdxModel) this.load(path, this.mapPathSolver, this.solverParams);
|
||||
final MdxModel model = loadModelMdx(path);
|
||||
MdxModel portraitModel;
|
||||
final String portraitPath = path.substring(0, path.length() - 4) + "_portrait.mdx";
|
||||
if (this.dataSource.has(portraitPath)) {
|
||||
portraitModel = (MdxModel) this.load(portraitPath, this.mapPathSolver, this.solverParams);
|
||||
portraitModel = loadModelMdx(portraitPath);
|
||||
}
|
||||
else {
|
||||
portraitModel = model;
|
||||
@ -2118,17 +2113,16 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
}
|
||||
|
||||
public void setDayNightModels(final String terrainDNCFile, final String unitDNCFile) {
|
||||
final MdxModel terrainDNCModel = (MdxModel) load(mdx(terrainDNCFile), PathSolver.DEFAULT, null);
|
||||
final MdxModel terrainDNCModel = loadModelMdx(terrainDNCFile);
|
||||
this.dncTerrain = (MdxComplexInstance) terrainDNCModel.addInstance();
|
||||
this.dncTerrain.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP);
|
||||
this.dncTerrain.setSequence(0);
|
||||
final MdxModel unitDNCModel = (MdxModel) load(mdx(unitDNCFile), PathSolver.DEFAULT, null);
|
||||
final MdxModel unitDNCModel = loadModelMdx(unitDNCFile);
|
||||
this.dncUnit = (MdxComplexInstance) unitDNCModel.addInstance();
|
||||
this.dncUnit.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP);
|
||||
this.dncUnit.setSequence(0);
|
||||
final MdxModel targetDNCModel = (MdxModel) load(
|
||||
mdx("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTarget\\DNCLordaeronTarget.mdl"), PathSolver.DEFAULT,
|
||||
null);
|
||||
final MdxModel targetDNCModel = loadModelMdx(
|
||||
"Environment\\DNC\\DNCLordaeron\\DNCLordaeronTarget\\DNCLordaeronTarget.mdl");
|
||||
this.dncTarget = (MdxComplexInstance) targetDNCModel.addInstance();
|
||||
this.dncTarget.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP);
|
||||
this.dncTarget.setSequence(0);
|
||||
@ -2165,10 +2159,6 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
return iconPath;
|
||||
}
|
||||
|
||||
public MdxModel loadModel(final String path) {
|
||||
return (MdxModel) load(mdx(path), PathSolver.DEFAULT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneLightManager createLightManager(final boolean simple) {
|
||||
if (simple) {
|
||||
@ -2337,7 +2327,7 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
final String attachPointName) {
|
||||
if (targetWidget instanceof CUnit) {
|
||||
final RenderUnit renderUnit = War3MapViewer.this.unitToRenderPeer.get(targetWidget);
|
||||
final MdxModel spawnedEffectModel = (MdxModel) load(mdx(modelName), PathSolver.DEFAULT, null);
|
||||
final MdxModel spawnedEffectModel = loadModelMdx(modelName);
|
||||
if (spawnedEffectModel != null) {
|
||||
final MdxComplexInstance modelInstance = (MdxComplexInstance) spawnedEffectModel.addInstance();
|
||||
modelInstance.setTeamColor(renderUnit.playerIndex);
|
||||
@ -2360,4 +2350,18 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MdxModel loadModelMdx(final String path) {
|
||||
final String mdxPath = mdx(path);
|
||||
if (this.dataSource.has(mdxPath)) {
|
||||
return (MdxModel) load(mdxPath, War3MapViewer.this.mapPathSolver, War3MapViewer.this.solverParams);
|
||||
}
|
||||
else {
|
||||
final String mdlPath = mdl(mdxPath);
|
||||
if (this.dataSource.has(mdlPath)) {
|
||||
return (MdxModel) load(mdlPath, War3MapViewer.this.mapPathSolver, War3MapViewer.this.solverParams);
|
||||
}
|
||||
}
|
||||
return (MdxModel) load(mdxPath, War3MapViewer.this.mapPathSolver, War3MapViewer.this.solverParams);
|
||||
}
|
||||
}
|
||||
|
@ -249,11 +249,17 @@ public class PathingGrid {
|
||||
|
||||
public short getCellPathing(final int cellX, final int cellY) {
|
||||
final int index = (cellY * this.pathingGridSizes[0]) + cellX;
|
||||
if (index >= this.pathingGrid.length) {
|
||||
return 0;
|
||||
}
|
||||
return (short) (this.pathingGrid[index] | this.dynamicPathingOverlay[index]);
|
||||
}
|
||||
|
||||
public void setCellPathing(final int cellX, final int cellY, final short pathingValue) {
|
||||
final int index = (cellY * this.pathingGridSizes[0]) + cellX;
|
||||
if (index >= this.pathingGrid.length) {
|
||||
return;
|
||||
}
|
||||
this.pathingGrid[index] = pathingValue;
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,8 @@ public class CUnit extends CWidget {
|
||||
private int foodMade;
|
||||
private int foodUsed;
|
||||
|
||||
private int triggerEditorCustomValue;
|
||||
|
||||
private List<CUnitAttack> unitSpecificAttacks;
|
||||
private transient Set<CRegion> containingRegions = new LinkedHashSet<>();
|
||||
private transient Set<CRegion> priorContainingRegions = new LinkedHashSet<>();
|
||||
@ -1065,7 +1067,8 @@ public class CUnit extends CWidget {
|
||||
final List<CWidgetEvent> eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_DEATH);
|
||||
if (eventList != null) {
|
||||
for (final CWidgetEvent event : eventList) {
|
||||
event.fire(this, CommonTriggerExecutionScope.unitDeathScope(event.getTrigger(), this, source));
|
||||
event.fire(this, CommonTriggerExecutionScope.unitDeathScope(JassGameEventsWar3.EVENT_UNIT_DEATH,
|
||||
event.getTrigger(), this, source));
|
||||
}
|
||||
}
|
||||
simulation.getPlayer(this.playerIndex).fireUnitDeathEvents(this, source);
|
||||
@ -1979,4 +1982,11 @@ public class CUnit extends CWidget {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTriggerEditorCustomValue() {
|
||||
return this.triggerEditorCustomValue;
|
||||
}
|
||||
|
||||
public void setTriggerEditorCustomValue(final int triggerEditorCustomValue) {
|
||||
this.triggerEditorCustomValue = triggerEditorCustomValue;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public abstract class CWidget implements AbilityTarget, CHandle {
|
||||
final List<CWidgetEvent> eventList = getEventList(eventType);
|
||||
if (eventList != null) {
|
||||
for (final CWidgetEvent event : eventList) {
|
||||
event.fire(this, eventScopeBuilder.create(event.getTrigger(), this));
|
||||
event.fire(this, eventScopeBuilder.create(eventType, event.getTrigger(), this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public class CPlayer extends CBasePlayer {
|
||||
final List<CPlayerEvent> eventList = getEventList(eventType);
|
||||
if (eventList != null) {
|
||||
for (final CPlayerEvent event : eventList) {
|
||||
event.fire(hero, eventScopeBuilder.create(event.getTrigger(), hero));
|
||||
event.fire(hero, eventScopeBuilder.create(eventType, event.getTrigger(), hero));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -248,8 +248,8 @@ public class CPlayer extends CBasePlayer {
|
||||
final List<CPlayerEvent> eventList = getEventList(JassGameEventsWar3.EVENT_PLAYER_UNIT_DEATH);
|
||||
if (eventList != null) {
|
||||
for (final CPlayerEvent event : eventList) {
|
||||
event.fire(dyingUnit,
|
||||
CommonTriggerExecutionScope.unitDeathScope(event.getTrigger(), dyingUnit, killingUnit));
|
||||
event.fire(dyingUnit, CommonTriggerExecutionScope.unitDeathScope(
|
||||
JassGameEventsWar3.EVENT_PLAYER_UNIT_DEATH, event.getTrigger(), dyingUnit, killingUnit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,13 +39,7 @@ public class CPlayerEvent implements RemovableTriggerEvent {
|
||||
}
|
||||
|
||||
public void fire(final CUnit hero, final TriggerExecutionScope scope) {
|
||||
if (this.filter != null) {
|
||||
if (!this.filter.evaluate(this.globalScope, CommonTriggerExecutionScope.filterScope(scope, hero))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.trigger.evaluate(this.globalScope, scope)) {
|
||||
this.trigger.execute(this.globalScope, scope);
|
||||
}
|
||||
this.globalScope.queueTrigger(this.filter, CommonTriggerExecutionScope.filterScope(scope, hero), this.trigger,
|
||||
scope, scope);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.etheller.interpreter.ast.scope.trigger.Trigger;
|
||||
import com.etheller.interpreter.ast.scope.trigger.TriggerBooleanExpression;
|
||||
import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3;
|
||||
|
||||
public class CRegionTriggerEnter {
|
||||
private final GlobalScope globalScope;
|
||||
@ -20,13 +21,10 @@ public class CRegionTriggerEnter {
|
||||
}
|
||||
|
||||
public void fire(final CUnit unit, final CRegion region) {
|
||||
if ((this.filter == null) || this.filter.evaluate(this.globalScope,
|
||||
CommonTriggerExecutionScope.filterScope(TriggerExecutionScope.EMPTY, unit))) {
|
||||
final CommonTriggerExecutionScope eventScope = CommonTriggerExecutionScope
|
||||
.unitEnterRegionScope(this.trigger, TriggerExecutionScope.EMPTY, unit, region);
|
||||
if (this.trigger.evaluate(this.globalScope, eventScope)) {
|
||||
this.trigger.execute(this.globalScope, eventScope);
|
||||
}
|
||||
}
|
||||
final CommonTriggerExecutionScope eventScope = CommonTriggerExecutionScope.unitEnterRegionScope(
|
||||
JassGameEventsWar3.EVENT_GAME_ENTER_REGION, this.trigger, TriggerExecutionScope.EMPTY, unit, region);
|
||||
this.globalScope.queueTrigger(this.filter,
|
||||
CommonTriggerExecutionScope.filterScope(TriggerExecutionScope.EMPTY, unit), this.trigger, eventScope,
|
||||
eventScope);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.etheller.interpreter.ast.scope.trigger.Trigger;
|
||||
import com.etheller.interpreter.ast.scope.trigger.TriggerBooleanExpression;
|
||||
import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3;
|
||||
|
||||
public class CRegionTriggerLeave {
|
||||
private final GlobalScope globalScope;
|
||||
@ -20,13 +21,10 @@ public class CRegionTriggerLeave {
|
||||
}
|
||||
|
||||
public void fire(final CUnit unit, final CRegion region) {
|
||||
if ((this.filter == null) || this.filter.evaluate(this.globalScope,
|
||||
CommonTriggerExecutionScope.filterScope(TriggerExecutionScope.EMPTY, unit))) {
|
||||
final CommonTriggerExecutionScope eventScope = CommonTriggerExecutionScope
|
||||
.unitLeaveRegionScope(this.trigger, TriggerExecutionScope.EMPTY, unit, region);
|
||||
if (this.trigger.evaluate(this.globalScope, eventScope)) {
|
||||
this.trigger.execute(this.globalScope, eventScope);
|
||||
}
|
||||
}
|
||||
final CommonTriggerExecutionScope eventScope = CommonTriggerExecutionScope.unitLeaveRegionScope(
|
||||
JassGameEventsWar3.EVENT_GAME_LEAVE_REGION, this.trigger, TriggerExecutionScope.EMPTY, unit, region);
|
||||
this.globalScope.queueTrigger(this.filter,
|
||||
CommonTriggerExecutionScope.filterScope(TriggerExecutionScope.EMPTY, unit), this.trigger, eventScope,
|
||||
eventScope);
|
||||
}
|
||||
}
|
||||
|
@ -35,13 +35,11 @@ public class CTimerJass extends CTimer implements CHandle {
|
||||
}
|
||||
}
|
||||
catch (final Exception e) {
|
||||
throw new JassException(this.jassGlobalScope, "Exception during jass time fire", e);
|
||||
throw new JassException(this.jassGlobalScope, "Exception during jass timer fire", e);
|
||||
}
|
||||
for (final Trigger trigger : this.eventTriggers) {
|
||||
final CommonTriggerExecutionScope executionScope = CommonTriggerExecutionScope.expiringTimer(trigger, this);
|
||||
if (trigger.evaluate(this.jassGlobalScope, executionScope)) {
|
||||
trigger.execute(this.jassGlobalScope, executionScope);
|
||||
}
|
||||
this.jassGlobalScope.queueTrigger(null, null, trigger, executionScope, executionScope);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,7 @@ public class CTimerNativeEvent extends CTimer {
|
||||
@Override
|
||||
public void onFire() {
|
||||
final TriggerExecutionScope triggerScope = new TriggerExecutionScope(this.trigger);
|
||||
if (this.trigger.evaluate(this.jassGlobalScope, triggerScope)) {
|
||||
this.trigger.execute(this.jassGlobalScope, triggerScope);
|
||||
}
|
||||
this.jassGlobalScope.queueTrigger(null, null, this.trigger, triggerScope, triggerScope);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,14 +44,8 @@ public class CWidgetEvent implements RemovableTriggerEvent {
|
||||
}
|
||||
|
||||
public void fire(final CWidget triggerWidget, final TriggerExecutionScope scope) {
|
||||
if (this.filter != null) {
|
||||
if (!this.filter.evaluate(this.globalScope, triggerWidget.visit(ScopeBuilder.INSTANCE.reset(scope)))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.trigger.evaluate(this.globalScope, scope)) {
|
||||
this.trigger.execute(this.globalScope, scope);
|
||||
}
|
||||
this.globalScope.queueTrigger(this.filter, triggerWidget.visit(ScopeBuilder.INSTANCE.reset(scope)),
|
||||
this.trigger, scope, scope);
|
||||
}
|
||||
|
||||
private static final class ScopeBuilder implements AbilityTargetVisitor<CommonTriggerExecutionScope> {
|
||||
|
@ -1097,18 +1097,14 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
|
||||
this.war3MapViewer.getUiSounds().getSound(this.rootFrame.getSkinField("NoFoodSound"))),
|
||||
new AbilityActivationErrorHandler("", this.war3MapViewer.getUiSounds().getSound("InterfaceError")));
|
||||
|
||||
final MdxModel rallyModel = (MdxModel) this.war3MapViewer.load(
|
||||
War3MapViewer.mdx(this.rootFrame.getSkinField("RallyIndicatorDst")), this.war3MapViewer.mapPathSolver,
|
||||
this.war3MapViewer.solverParams);
|
||||
final MdxModel rallyModel = this.war3MapViewer.loadModelMdx(this.rootFrame.getSkinField("RallyIndicatorDst"));
|
||||
this.rallyPointInstance = (MdxComplexInstance) rallyModel.addInstance();
|
||||
this.rallyPointInstance.rotate(RenderUnit.tempQuat.setFromAxis(RenderMathUtils.VEC3_UNIT_Z,
|
||||
this.war3MapViewer.simulation.getGameplayConstants().getBuildingAngle()));
|
||||
this.rallyPointInstance.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP);
|
||||
SequenceUtils.randomStandSequence(this.rallyPointInstance);
|
||||
this.rallyPointInstance.hide();
|
||||
this.waypointModel = (MdxModel) this.war3MapViewer.load(
|
||||
War3MapViewer.mdx(this.rootFrame.getSkinField("WaypointIndicator")), this.war3MapViewer.mapPathSolver,
|
||||
this.war3MapViewer.solverParams);
|
||||
this.waypointModel = this.war3MapViewer.loadModelMdx(this.rootFrame.getSkinField("WaypointIndicator"));
|
||||
|
||||
final FreeTypeFontParameter fontParam = new FreeTypeFontParameter();
|
||||
fontParam.size = (int) GameUI.convertY(this.uiViewport, 0.012f);
|
||||
@ -1823,7 +1819,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
|
||||
final War3ID buildingTypeId = new War3ID(MeleeUI.this.activeCommandOrderId);
|
||||
MeleeUI.this.cursorBuildingUnitType = viewer.simulation.getUnitData().getUnitType(buildingTypeId);
|
||||
final String unitModelPath = viewer.getUnitModelPath(unitData.get(buildingTypeId));
|
||||
final MdxModel model = (MdxModel) viewer.load(unitModelPath, viewer.mapPathSolver, viewer.solverParams);
|
||||
final MdxModel model = viewer.loadModelMdx(unitModelPath);
|
||||
MeleeUI.this.cursorModelInstance = (MdxComplexInstance) model.addInstance();
|
||||
// MeleeUI.this.cursorModelInstance.setVertexColor(new float[] { 1, 1, 1, 0.5f });
|
||||
final int playerColorIndex = viewer.simulation
|
||||
|
@ -14,6 +14,7 @@ import com.etheller.warsmash.parsers.fdf.frames.SimpleFrame;
|
||||
import com.etheller.warsmash.parsers.fdf.frames.StringFrame;
|
||||
import com.etheller.warsmash.parsers.fdf.frames.UIFrame;
|
||||
import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope;
|
||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3;
|
||||
|
||||
public class CScriptDialog {
|
||||
private final GlobalScope globalScope;
|
||||
@ -69,11 +70,9 @@ public class CScriptDialog {
|
||||
public void onButtonClick(final CScriptDialogButton cScriptDialogButton) {
|
||||
this.scriptDialogFrame.setVisible(false);
|
||||
for (final Trigger trigger : this.eventTriggers) {
|
||||
final CommonTriggerExecutionScope scope = CommonTriggerExecutionScope.triggerDialogScope(trigger, this,
|
||||
cScriptDialogButton);
|
||||
if (trigger.evaluate(this.globalScope, scope)) {
|
||||
trigger.execute(this.globalScope, scope);
|
||||
}
|
||||
final CommonTriggerExecutionScope scope = CommonTriggerExecutionScope
|
||||
.triggerDialogScope(JassGameEventsWar3.EVENT_DIALOG_CLICK, trigger, this, cScriptDialogButton);
|
||||
this.globalScope.queueTrigger(null, null, trigger, scope, scope);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,12 @@ public class DebuggingJassFunction implements JassFunction {
|
||||
final TriggerExecutionScope triggerScope) {
|
||||
globalScope.pushJassStack(new JassStackElement(this.sourceFile, this.functionName, this.lineNo));
|
||||
globalScope.setLineNumber(this.lineNo);
|
||||
final JassValue returnValue = this.delegate.call(arguments, globalScope, triggerScope);
|
||||
globalScope.popJassStack();
|
||||
return returnValue;
|
||||
try {
|
||||
return this.delegate.call(arguments, globalScope, triggerScope);
|
||||
}
|
||||
finally {
|
||||
globalScope.popJassStack();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.etheller.interpreter.ast.expression;
|
||||
import com.etheller.interpreter.ast.scope.GlobalScope;
|
||||
import com.etheller.interpreter.ast.scope.LocalScope;
|
||||
import com.etheller.interpreter.ast.scope.TriggerExecutionScope;
|
||||
import com.etheller.interpreter.ast.value.IntegerJassValue;
|
||||
import com.etheller.interpreter.ast.value.JassValue;
|
||||
import com.etheller.interpreter.ast.value.visitor.ArithmeticJassValueVisitor;
|
||||
import com.etheller.interpreter.ast.value.visitor.ArithmeticLeftHandNullJassValueVisitor;
|
||||
@ -25,14 +26,20 @@ public class ArithmeticJassExpression implements JassExpression {
|
||||
final TriggerExecutionScope triggerScope) {
|
||||
final JassValue leftValue = this.leftExpression.evaluate(globalScope, localScope, triggerScope);
|
||||
final JassValue rightValue = this.rightExpression.evaluate(globalScope, localScope, triggerScope);
|
||||
if (leftValue == null) {
|
||||
if (rightValue == null) {
|
||||
return this.arithmeticSign.apply((String) null, (String) null);
|
||||
}
|
||||
else {
|
||||
return rightValue.visit(ArithmeticLeftHandNullJassValueVisitor.INSTANCE.reset(this.arithmeticSign));
|
||||
try {
|
||||
if (leftValue == null) {
|
||||
if (rightValue == null) {
|
||||
return this.arithmeticSign.apply((String) null, (String) null);
|
||||
}
|
||||
else {
|
||||
return rightValue.visit(ArithmeticLeftHandNullJassValueVisitor.INSTANCE.reset(this.arithmeticSign));
|
||||
}
|
||||
}
|
||||
return leftValue.visit(ArithmeticJassValueVisitor.INSTANCE.reset(rightValue, this.arithmeticSign));
|
||||
}
|
||||
catch (final ArithmeticException exception) {
|
||||
exception.printStackTrace();
|
||||
return IntegerJassValue.ZERO;
|
||||
}
|
||||
return leftValue.visit(ArithmeticJassValueVisitor.INSTANCE.reset(rightValue, this.arithmeticSign));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.etheller.interpreter.ast.scope;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -13,6 +14,7 @@ import com.etheller.interpreter.ast.debug.JassStackElement;
|
||||
import com.etheller.interpreter.ast.function.JassFunction;
|
||||
import com.etheller.interpreter.ast.scope.trigger.RemovableTriggerEvent;
|
||||
import com.etheller.interpreter.ast.scope.trigger.Trigger;
|
||||
import com.etheller.interpreter.ast.scope.trigger.TriggerBooleanExpression;
|
||||
import com.etheller.interpreter.ast.scope.variableevent.CLimitOp;
|
||||
import com.etheller.interpreter.ast.scope.variableevent.VariableEvent;
|
||||
import com.etheller.interpreter.ast.util.JassSettings;
|
||||
@ -31,6 +33,7 @@ public final class GlobalScope {
|
||||
private final Map<String, JassFunction> functions = new HashMap<>();
|
||||
private final Map<String, JassType> types = new HashMap<>();
|
||||
private final HandleTypeSuperTypeLoadingVisitor handleTypeSuperTypeLoadingVisitor = new HandleTypeSuperTypeLoadingVisitor();
|
||||
private final ArrayDeque<QueuedCallback> triggerQueue = new ArrayDeque<>();
|
||||
|
||||
public final HandleJassType handleType;
|
||||
|
||||
@ -214,4 +217,70 @@ public final class GlobalScope {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void queueTrigger(final TriggerBooleanExpression filter, final TriggerExecutionScope filterScope,
|
||||
final Trigger trigger, final TriggerExecutionScope evaluateScope,
|
||||
final TriggerExecutionScope executeScope) {
|
||||
this.triggerQueue.add(new QueuedTrigger(filter, filterScope, trigger, evaluateScope, executeScope));
|
||||
}
|
||||
|
||||
public void queueFunction(final JassFunction function, final TriggerExecutionScope scope) {
|
||||
this.triggerQueue.add(new QueuedFunction(function, scope));
|
||||
}
|
||||
|
||||
public void replayQueuedTriggers() {
|
||||
for (final QueuedCallback trigger : this.triggerQueue) {
|
||||
trigger.fire(this);
|
||||
}
|
||||
this.triggerQueue.clear();
|
||||
}
|
||||
|
||||
private static interface QueuedCallback {
|
||||
void fire(GlobalScope globalScope);
|
||||
}
|
||||
|
||||
private static final class QueuedFunction implements QueuedCallback {
|
||||
private final JassFunction function;
|
||||
private final TriggerExecutionScope scope;
|
||||
|
||||
public QueuedFunction(final JassFunction function, final TriggerExecutionScope scope) {
|
||||
this.function = function;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fire(final GlobalScope globalScope) {
|
||||
this.function.call(Collections.<JassValue>emptyList(), globalScope, this.scope);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class QueuedTrigger implements QueuedCallback {
|
||||
private final TriggerBooleanExpression filter;
|
||||
private final TriggerExecutionScope filterScope;
|
||||
private final Trigger trigger;
|
||||
private final TriggerExecutionScope evaluateScope;
|
||||
private final TriggerExecutionScope executeScope;
|
||||
|
||||
public QueuedTrigger(final TriggerBooleanExpression filter, final TriggerExecutionScope filterScope,
|
||||
final Trigger trigger, final TriggerExecutionScope evaluateScope,
|
||||
final TriggerExecutionScope executeScope) {
|
||||
this.filter = filter;
|
||||
this.filterScope = filterScope;
|
||||
this.trigger = trigger;
|
||||
this.evaluateScope = evaluateScope;
|
||||
this.executeScope = executeScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fire(final GlobalScope globalScope) {
|
||||
if (this.filter != null) {
|
||||
if (!this.filter.evaluate(globalScope, this.filterScope)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.trigger.evaluate(globalScope, this.evaluateScope)) {
|
||||
this.trigger.execute(globalScope, this.executeScope);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,10 @@ public class Trigger {
|
||||
this.conditions.remove(conditionIndex);
|
||||
}
|
||||
|
||||
public void clearConditions() {
|
||||
this.conditions.clear();
|
||||
}
|
||||
|
||||
public int getEvalCount() {
|
||||
return this.evalCount;
|
||||
}
|
||||
|
@ -48,8 +48,6 @@ public class VariableEvent {
|
||||
|
||||
public void fire(final GlobalScope globalScope) {
|
||||
final TriggerExecutionScope triggerScope = new TriggerExecutionScope(this.trigger);
|
||||
if (this.trigger.evaluate(globalScope, triggerScope)) {
|
||||
this.trigger.execute(globalScope, triggerScope);
|
||||
}
|
||||
globalScope.queueTrigger(null, null, this.trigger, triggerScope, triggerScope);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.etheller.interpreter.ast.statement;
|
||||
|
||||
import com.etheller.interpreter.ast.Assignable;
|
||||
import com.etheller.interpreter.ast.debug.JassException;
|
||||
import com.etheller.interpreter.ast.expression.JassExpression;
|
||||
import com.etheller.interpreter.ast.scope.GlobalScope;
|
||||
import com.etheller.interpreter.ast.scope.LocalScope;
|
||||
@ -31,16 +32,22 @@ public class JassArrayedAssignmentStatement implements JassStatement {
|
||||
variable = globalScope.getAssignableGlobal(this.identifier);
|
||||
}
|
||||
if (variable.getValue() == null) {
|
||||
|
||||
throw new RuntimeException("Unable to assign uninitialized array");
|
||||
throw new JassException(globalScope, "Unable to assign uninitialized array", null);
|
||||
}
|
||||
final ArrayJassValue arrayValue = variable.getValue().visit(ArrayJassValueVisitor.getInstance());
|
||||
if (arrayValue != null) {
|
||||
arrayValue.set(index.visit(IntegerJassValueVisitor.getInstance()),
|
||||
this.expression.evaluate(globalScope, localScope, triggerScope));
|
||||
final Integer indexInt = index.visit(IntegerJassValueVisitor.getInstance());
|
||||
if ((indexInt != null) && (indexInt >= 0)) {
|
||||
arrayValue.set(indexInt, this.expression.evaluate(globalScope, localScope, triggerScope));
|
||||
}
|
||||
else {
|
||||
throw new JassException(globalScope,
|
||||
"Attempted to assign " + this.identifier + "[" + indexInt + "], which was an illegal index",
|
||||
null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RuntimeException("Not an array");
|
||||
throw new JassException(globalScope, "Not an array", null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.etheller.interpreter.ast.statement;
|
||||
|
||||
import com.etheller.interpreter.ast.Assignable;
|
||||
import com.etheller.interpreter.ast.debug.JassException;
|
||||
import com.etheller.interpreter.ast.expression.JassExpression;
|
||||
import com.etheller.interpreter.ast.scope.GlobalScope;
|
||||
import com.etheller.interpreter.ast.scope.LocalScope;
|
||||
@ -10,6 +11,7 @@ import com.etheller.interpreter.ast.value.JassValue;
|
||||
public class JassSetStatement implements JassStatement {
|
||||
private final String identifier;
|
||||
private final JassExpression expression;
|
||||
private static JassException zeroGuy = null;
|
||||
|
||||
public JassSetStatement(final String identifier, final JassExpression expression) {
|
||||
this.identifier = identifier;
|
||||
|
Loading…
Reference in New Issue
Block a user