View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0003483 | Spring engine | AI | public | 2013-02-20 21:54 | 2013-02-26 20:21 | ||||
Reporter | cranphin | ||||||||
Assigned To | abma | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Product Version | 92.0.1+git | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0003483: Get null as unit in JavaOO-AIWrapper.jar for team 1 | ||||||||
Description | When I run a Java AI using JavaOO-AIWrapper.jar, with two teams (and one spectator), I get 'null' as first argument in the com.springrts.ai.oo.OOAI.unitCreated callback, for the first commander created. Instead it should've given a Unit instance. This happens on this build (latest I could find): spring-92.0.1-62-gc96d6b0. I think this happens because the first unit gets id '0', and the Java OO wrapper expects to get 0 for "no unit", so returns null. The reason I think this, is that if I build a minimal Java AI, without the OO wrapper, which only logs, I see a '0' id for only exactly the commander of team 1, which is where I get the null for. If I manually build something (/cheat,/godmode), later units get higher id's. I'll attach the script and (my own) log for that test run. So mayby 0 used to be 'no unit', and now it's -1, and the Java OO wrapper didn't get updated for this, could that be the case? The relevant classes from Spring are com.springrts.ai.oo.AIOO, and especially com.springrts.ai.oo.WrappUnit.getInstance(), I think, don't have the source here, since it's generated source (if I remember well). If someone wants the logging java AI I used to test, or anything else, just ask. | ||||||||
Tags | No tags attached. | ||||||||
Checked infolog.txt for Errors | |||||||||
Attached Files |
|
Notes | |
cranphin (reporter) 2013-02-20 21:56 |
Attached my little test log, note this line: init - DEBUG main com.springrts.ai.logai.LogAI - Unit created: unit: 0 builder: -1 So the unit id given is '0'. Interestingly, the builder id is -1 (no builder for a commander), so it would seem the Java OO wrapper should handle '0' as a unit, '-1' as no unit. But right now it seems to handle '0' as no unit. |
cranphin (reporter) 2013-02-20 22:03 |
The source for the AI in the little test I did: http://code.google.com/p/crans-java-ai/source/browse/#svn%2FLogJavaAI%2Ftrunk |
Kloot (developer) 2013-02-20 23:00 |
Units getting assigned sequential (instead of random as before) id's starting at 0 is a bug which I will fix, but regardless no AI wrapper code should ever treat id 0 as a special value. I don't much feel like digging into that though... |
cranphin (reporter) 2013-02-20 23:31 |
I'll dig then ^_^ https://github.com/spring/spring/blob/develop/AI/Wrappers/JavaOO/bin/wrappCallback.awk There's this bit: print("\t" "public static " clsName_c " getInstance(" ctorParams ") {") >> outFile_jni_c; print("") >> outFile_jni_c; lastParamName = ctorParamsNoTypes; sub(/^.*,[ \t]*/, "", lastParamName); if (match(lastParamName, /^[^ \t]+Id$/)) { if (clsName_c == "Unit") { # the first valid unit ID is 1 print("\t\t" "if (" lastParamName " <= 0) {") >> outFile_jni_c; } else { # ... for all other IDs, the first valid one is 0 print("\t\t" "if (" lastParamName " < 0) {") >> outFile_jni_c; } print("\t\t\t" "return null;") >> outFile_jni_c; print("\t\t" "}") >> outFile_jni_c; print("") >> outFile_jni_c; } Remove the exception for "if (clsName_c == "Unit") {", and you should be done :) |
abma (administrator) 2013-02-22 12:07 |
@cranphin: can you check if the latest build works for you? http://springrts.com/dl/buildbot/default/release/92.0-25-g0f187f0/ |
cranphin (reporter) 2013-02-26 20:17 |
Oops, didn't notice the request, still had an old (defunc) email here :) 'spring-92.0-33-g2be1d86' works for me, is that enough? Otherwise place another comment with a version, and I'll check that when I've got more time :) |
Issue History | |||
Date Modified | Username | Field | Change |
---|---|---|---|
2013-02-20 21:54 | cranphin | New Issue | |
2013-02-20 21:54 | cranphin | File Added: test_script.txt | |
2013-02-20 21:54 | cranphin | File Added: main.log | |
2013-02-20 21:56 | cranphin | Note Added: 0009868 | |
2013-02-20 22:03 | cranphin | Note Added: 0009869 | |
2013-02-20 23:00 | Kloot | Note Added: 0009870 | |
2013-02-20 23:31 | cranphin | Note Added: 0009871 | |
2013-02-21 12:56 | abma | Changeset attached | => spring release 423cdaa4 |
2013-02-21 12:56 | abma | Assigned To | => abma |
2013-02-21 12:56 | abma | Status | new => resolved |
2013-02-21 12:56 | abma | Resolution | open => fixed |
2013-02-22 01:32 | abma | Relationship added | related to 0003485 |
2013-02-22 12:07 | abma | Note Added: 0009877 | |
2013-02-22 12:07 | abma | Status | resolved => feedback |
2013-02-22 12:07 | abma | Resolution | fixed => reopened |
2013-02-26 20:17 | cranphin | Note Added: 0009940 | |
2013-02-26 20:17 | cranphin | Status | feedback => assigned |
2013-02-26 20:21 | abma | Status | assigned => resolved |
2013-02-26 20:21 | abma | Resolution | reopened => fixed |