fix(shim): make the generated DrussGT bot dir runnable by hand

Running /tmp/tr_bots/DrussGT/DrussGT.sh manually failed with:
  BotException: Required bot property 'name' is missing.
The Tank Royale Java bot API reads bot identity from BOT_* environment
variables (EnvVars: BOT_NAME, BOT_VERSION, BOT_AUTHORS, BOT_DESCRIPTION,
BOT_HOMEPAGE, BOT_COUNTRY_CODES, BOT_GAME_TYPES, BOT_PLATFORM, BOT_PROG_LANG,
BOT_INITIAL_POS). When the TR booter launches the directory it supplies those,
derived from the .json - which is why every headless battle worked - but
launching the script directly supplies nothing, so the API rejects the
handshake.

make_botdir.sh now exports them in the generated <dir>.sh (kept in sync with
the .json it writes), so the script works standalone as well as under the
booter.

Verified against a server started for the test: before, the exact error above;
after, 'Connected to: ws://localhost:4599' and the server logs
'Bot joined: DrussGT 3.1.4159'.
This commit is contained in:
2026-09-21 08:16:09 +02:00
parent 013b9fe01e
commit e6653199bb
+17
View File
@@ -30,9 +30,26 @@ cat > "$TARGET/$NAME.json" <<JSON
} }
JSON JSON
# The Tank Royale bot API reads bot identity from BOT_* environment variables.
# When the TR booter launches this directory it supplies them (derived from the
# .json above), but running this script BY HAND does not - and the API then
# rejects the handshake with "Required bot property 'name' is missing".
# Exporting them here makes the script work standalone as well.
cat > "$TARGET/$NAME.sh" <<SH cat > "$TARGET/$NAME.sh" <<SH
#!/bin/sh #!/bin/sh
cd "\$(dirname "\$0")" cd "\$(dirname "\$0")"
# Bot identity - keep in sync with $NAME.json
export BOT_NAME="DrussGT"
export BOT_VERSION="3.1.4159"
export BOT_AUTHORS="Jacob"
export BOT_DESCRIPTION="Real classic DrussGT running on Tank Royale via the robocode_shim bridge"
export BOT_HOMEPAGE=""
export BOT_COUNTRY_CODES="se"
export BOT_GAME_TYPES="classic,1v1"
export BOT_PLATFORM="JVM"
export BOT_PROG_LANG="Java 8"
exec java -cp "$OUT:$ROBOCODE_JAR:$TR_BOT_API_JAR" robocode_shim.DrussGTBridge exec java -cp "$OUT:$ROBOCODE_JAR:$TR_BOT_API_JAR" robocode_shim.DrussGTBridge
SH SH
chmod +x "$TARGET/$NAME.sh" chmod +x "$TARGET/$NAME.sh"