mirror of
https://github.com/Retera/WarsmashModEngine.git
synced 2022-07-31 17:38:59 +02:00
Add missing get player state function
This commit is contained in:
parent
9becca479e
commit
f2a2f2b704
@ -160,8 +160,7 @@ public class Jass2 {
|
|||||||
JassLexer lexer;
|
JassLexer lexer;
|
||||||
try {
|
try {
|
||||||
lexer = new JassLexer(CharStreams.fromStream(dataSource.getResourceAsStream(jassFile)));
|
lexer = new JassLexer(CharStreams.fromStream(dataSource.getResourceAsStream(jassFile)));
|
||||||
}
|
} catch (final IOException e) {
|
||||||
catch (final IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
final JassParser parser = new JassParser(new CommonTokenStream(lexer));
|
final JassParser parser = new JassParser(new CommonTokenStream(lexer));
|
||||||
@ -184,8 +183,7 @@ public class Jass2 {
|
|||||||
});
|
});
|
||||||
jassProgramVisitor.setCurrentFileName(jassFile);
|
jassProgramVisitor.setCurrentFileName(jassFile);
|
||||||
jassProgramVisitor.visit(parser.program());
|
jassProgramVisitor.visit(parser.program());
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,8 +202,7 @@ public class Jass2 {
|
|||||||
JassLexer lexer;
|
JassLexer lexer;
|
||||||
try {
|
try {
|
||||||
lexer = new JassLexer(CharStreams.fromStream(dataSource.getResourceAsStream(jassFile)));
|
lexer = new JassLexer(CharStreams.fromStream(dataSource.getResourceAsStream(jassFile)));
|
||||||
}
|
} catch (final IOException e) {
|
||||||
catch (final IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
final JassParser parser = new JassParser(new CommonTokenStream(lexer));
|
final JassParser parser = new JassParser(new CommonTokenStream(lexer));
|
||||||
@ -228,8 +225,7 @@ public class Jass2 {
|
|||||||
});
|
});
|
||||||
jassProgramVisitor.setCurrentFileName(jassFile);
|
jassProgramVisitor.setCurrentFileName(jassFile);
|
||||||
jassProgramVisitor.visit(parser.program());
|
jassProgramVisitor.visit(parser.program());
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,8 +244,7 @@ public class Jass2 {
|
|||||||
JassLexer lexer;
|
JassLexer lexer;
|
||||||
try {
|
try {
|
||||||
lexer = new JassLexer(CharStreams.fromStream(dataSource.getResourceAsStream(jassFile)));
|
lexer = new JassLexer(CharStreams.fromStream(dataSource.getResourceAsStream(jassFile)));
|
||||||
}
|
} catch (final IOException e) {
|
||||||
catch (final IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
final JassParser parser = new JassParser(new CommonTokenStream(lexer));
|
final JassParser parser = new JassParser(new CommonTokenStream(lexer));
|
||||||
@ -269,8 +264,7 @@ public class Jass2 {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
jassProgramVisitor.visit(parser.program());
|
jassProgramVisitor.visit(parser.program());
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,8 +331,7 @@ public class Jass2 {
|
|||||||
final String tocFileName = arguments.get(0).visit(StringJassValueVisitor.getInstance());
|
final String tocFileName = arguments.get(0).visit(StringJassValueVisitor.getInstance());
|
||||||
try {
|
try {
|
||||||
JUIEnvironment.this.gameUI.loadTOCFile(tocFileName);
|
JUIEnvironment.this.gameUI.loadTOCFile(tocFileName);
|
||||||
}
|
} catch (final IOException e) {
|
||||||
catch (final IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return BooleanJassValue.TRUE;
|
return BooleanJassValue.TRUE;
|
||||||
@ -698,11 +691,11 @@ public class Jass2 {
|
|||||||
@Override
|
@Override
|
||||||
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
|
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
|
||||||
final TriggerExecutionScope triggerScope) {
|
final TriggerExecutionScope triggerScope) {
|
||||||
final CTimerJass timer = arguments.get(0).visit(ObjectJassValueVisitor.<CTimerJass>getInstance());
|
final CTimerJass timer = nullable(arguments, 0, ObjectJassValueVisitor.<CTimerJass>getInstance());
|
||||||
final Double timeout = arguments.get(1).visit(RealJassValueVisitor.getInstance());
|
final Double timeout = arguments.get(1).visit(RealJassValueVisitor.getInstance());
|
||||||
final boolean periodic = arguments.get(2).visit(BooleanJassValueVisitor.getInstance());
|
final boolean periodic = arguments.get(2).visit(BooleanJassValueVisitor.getInstance());
|
||||||
final JassFunction handlerFunc = nullable(arguments, 3, JassFunctionJassValueVisitor.getInstance());
|
final JassFunction handlerFunc = nullable(arguments, 3, JassFunctionJassValueVisitor.getInstance());
|
||||||
if (!timer.isRunning()) {
|
if ((timer != null) && !timer.isRunning()) {
|
||||||
timer.setTimeoutTime(timeout.floatValue());
|
timer.setTimeoutTime(timeout.floatValue());
|
||||||
timer.setRepeats(periodic);
|
timer.setRepeats(periodic);
|
||||||
timer.setHandlerFunc(handlerFunc);
|
timer.setHandlerFunc(handlerFunc);
|
||||||
@ -720,6 +713,7 @@ public class Jass2 {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
jassProgramVisitor.getJassNativeManager().createNative("TimerGetRemaining", new JassFunction() {
|
jassProgramVisitor.getJassNativeManager().createNative("TimerGetRemaining", new JassFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
|
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
|
||||||
final TriggerExecutionScope triggerScope) {
|
final TriggerExecutionScope triggerScope) {
|
||||||
@ -1267,8 +1261,7 @@ public class Jass2 {
|
|||||||
callback.call(Collections.emptyList(), globalScope,
|
callback.call(Collections.emptyList(), globalScope,
|
||||||
CommonTriggerExecutionScope.enumScope(triggerScope, unit));
|
CommonTriggerExecutionScope.enumScope(triggerScope, unit));
|
||||||
}
|
}
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (final Exception e) {
|
|
||||||
throw new JassException(globalScope, "Exception during ForGroup", e);
|
throw new JassException(globalScope, "Exception during ForGroup", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -1435,8 +1428,7 @@ public class Jass2 {
|
|||||||
callback.call(Collections.<JassValue>emptyList(), globalScope,
|
callback.call(Collections.<JassValue>emptyList(), globalScope,
|
||||||
CommonTriggerExecutionScope.enumScope(triggerScope, player));
|
CommonTriggerExecutionScope.enumScope(triggerScope, player));
|
||||||
}
|
}
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (final Exception e) {
|
|
||||||
throw new JassException(globalScope, "Exception during ForForce", e);
|
throw new JassException(globalScope, "Exception during ForForce", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -2630,6 +2622,16 @@ public class Jass2 {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
jassProgramVisitor.getJassNativeManager().createNative("GetPlayerState", new JassFunction() {
|
||||||
|
@Override
|
||||||
|
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
|
||||||
|
final TriggerExecutionScope triggerScope) {
|
||||||
|
final CPlayer player = arguments.get(0).visit(ObjectJassValueVisitor.getInstance());
|
||||||
|
final CPlayerState whichPlayerState = arguments.get(1).visit(ObjectJassValueVisitor.getInstance());
|
||||||
|
return new IntegerJassValue(
|
||||||
|
player.getPlayerState(CommonEnvironment.this.simulation, whichPlayerState));
|
||||||
|
}
|
||||||
|
});
|
||||||
jassProgramVisitor.getJassNativeManager().createNative("GetPlayerTechResearched", new JassFunction() {
|
jassProgramVisitor.getJassNativeManager().createNative("GetPlayerTechResearched", new JassFunction() {
|
||||||
@Override
|
@Override
|
||||||
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
|
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
|
||||||
@ -3078,8 +3080,7 @@ public class Jass2 {
|
|||||||
CommonEnvironment.this.simulation.getHandleIdAllocator().createId()));
|
CommonEnvironment.this.simulation.getHandleIdAllocator().createId()));
|
||||||
// TODO below code is very stupid!!
|
// TODO below code is very stupid!!
|
||||||
return new IntegerJassValue(1);
|
return new IntegerJassValue(1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// TODO below code is very stupid!!
|
// TODO below code is very stupid!!
|
||||||
return new IntegerJassValue(1);
|
return new IntegerJassValue(1);
|
||||||
}
|
}
|
||||||
@ -3799,8 +3800,7 @@ public class Jass2 {
|
|||||||
try {
|
try {
|
||||||
this.jassProgramVisitor.getGlobals().getFunctionByName("config").call(Collections.emptyList(),
|
this.jassProgramVisitor.getGlobals().getFunctionByName("config").call(Collections.emptyList(),
|
||||||
this.jassProgramVisitor.getGlobals(), JassProgramVisitor.EMPTY_TRIGGER_SCOPE);
|
this.jassProgramVisitor.getGlobals(), JassProgramVisitor.EMPTY_TRIGGER_SCOPE);
|
||||||
}
|
} catch (final Exception exc) {
|
||||||
catch (final Exception exc) {
|
|
||||||
throw new JassException(this.jassProgramVisitor.getGlobals(),
|
throw new JassException(this.jassProgramVisitor.getGlobals(),
|
||||||
"Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc);
|
"Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc);
|
||||||
}
|
}
|
||||||
@ -3819,8 +3819,7 @@ public class Jass2 {
|
|||||||
try {
|
try {
|
||||||
this.jassProgramVisitor.getGlobals().getFunctionByName("main").call(Collections.emptyList(),
|
this.jassProgramVisitor.getGlobals().getFunctionByName("main").call(Collections.emptyList(),
|
||||||
this.jassProgramVisitor.getGlobals(), JassProgramVisitor.EMPTY_TRIGGER_SCOPE);
|
this.jassProgramVisitor.getGlobals(), JassProgramVisitor.EMPTY_TRIGGER_SCOPE);
|
||||||
}
|
} catch (final Exception exc) {
|
||||||
catch (final Exception exc) {
|
|
||||||
throw new JassException(this.jassProgramVisitor.getGlobals(),
|
throw new JassException(this.jassProgramVisitor.getGlobals(),
|
||||||
"Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc);
|
"Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc);
|
||||||
}
|
}
|
||||||
@ -3951,8 +3950,7 @@ public class Jass2 {
|
|||||||
try {
|
try {
|
||||||
this.jassProgramVisitor.getGlobals().getFunctionByName("config").call(Collections.emptyList(),
|
this.jassProgramVisitor.getGlobals().getFunctionByName("config").call(Collections.emptyList(),
|
||||||
this.jassProgramVisitor.getGlobals(), JassProgramVisitor.EMPTY_TRIGGER_SCOPE);
|
this.jassProgramVisitor.getGlobals(), JassProgramVisitor.EMPTY_TRIGGER_SCOPE);
|
||||||
}
|
} catch (final Exception exc) {
|
||||||
catch (final Exception exc) {
|
|
||||||
throw new JassException(this.jassProgramVisitor.getGlobals(),
|
throw new JassException(this.jassProgramVisitor.getGlobals(),
|
||||||
"Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc);
|
"Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc);
|
||||||
}
|
}
|
||||||
@ -4254,8 +4252,7 @@ public class Jass2 {
|
|||||||
JassLexer lexer;
|
JassLexer lexer;
|
||||||
try {
|
try {
|
||||||
lexer = new JassLexer(CharStreams.fromStream(dataSource.getResourceAsStream(filename)));
|
lexer = new JassLexer(CharStreams.fromStream(dataSource.getResourceAsStream(filename)));
|
||||||
}
|
} catch (final IOException e) {
|
||||||
catch (final IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
final JassParser parser = new JassParser(new CommonTokenStream(lexer));
|
final JassParser parser = new JassParser(new CommonTokenStream(lexer));
|
||||||
@ -4275,8 +4272,7 @@ public class Jass2 {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
jassProgramVisitor.visit(parser.program());
|
jassProgramVisitor.visit(parser.program());
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5449,8 +5445,7 @@ public class Jass2 {
|
|||||||
try {
|
try {
|
||||||
final int intValue = Integer.parseInt(s);
|
final int intValue = Integer.parseInt(s);
|
||||||
return new IntegerJassValue(intValue);
|
return new IntegerJassValue(intValue);
|
||||||
}
|
} catch (final Exception exc) {
|
||||||
catch (final Exception exc) {
|
|
||||||
return new IntegerJassValue(0);
|
return new IntegerJassValue(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5463,8 +5458,7 @@ public class Jass2 {
|
|||||||
try {
|
try {
|
||||||
final double parsedValue = Double.parseDouble(s);
|
final double parsedValue = Double.parseDouble(s);
|
||||||
return new RealJassValue(parsedValue);
|
return new RealJassValue(parsedValue);
|
||||||
}
|
} catch (final Exception exc) {
|
||||||
catch (final Exception exc) {
|
|
||||||
return new RealJassValue(0);
|
return new RealJassValue(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user