BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
generated from the code
On this page

Console, log and RCON

3 functions of the host module. Generated from the bf2-rs sources; see the reference index for the cross-game table.

log#

BF22142Heroes
python
host.log(text)
FactDetail
Arguments (as parsed)s@0
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x0042a050, BF2.exe!0x0045e3a0, BFHeroes.exe (1.89)!0x004923e3

What it does (from the original code). Appends text+"\n" to the error-capture stream (state+0x48) only while PythonHost::fetchErrorString (0x00429db0) runs PyErr_Print; otherwise the text is dropped. bf2.fake_stream routes sys.stdout/sys.stderr here, so print output never reaches a log in retail except inside captured tracebacks.

Shipped scripts use it like this:

BF2: python/bf2/__init__.py:64
host.log("".join (self.buf))
2142: python/bf2/__init__.py:31
host.log("".join (self.buf))
Heroes: python/bf2/__init__.py:65
host.log("".join (self.buf))

rcon_invoke#

BF22142Heroes
python
host.rcon_invoke(cmd)
FactDetail
Arguments (as parsed)s@0
Returnsstr
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x00429ba0, BF2.exe!0x0045de70, BFHeroes.exe (1.89)!0x00493618
bf2-rscrates/bf2-server/src/hostfns.rs:422

What it does (from the original code). returns "" (0x0078375c). Otherwise appends "\n" if missing, runs the console command line through console vt+0x08(cmd, &out, 0,0,0,0,0) (PTR_DAT_00834ce4) and returns the captured output, forced to end with "\n" (empty output -> "\n").

Shipped scripts use it like this:

BF2: Admin/default.py:364
ctx.write(host.rcon_invoke(cmd))
2142: Admin/default.py:365
ctx.write(host.rcon_invoke(cmd))

rcon_feedback#

BF22142Heroes
python
host.rcon_feedback(playerId, text)
FactDetail
Arguments (as parsed)i@0 s@1
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x00429cb0, BF2.exe!0x0045df60, BFHeroes.exe (1.89)!0x004921b4
bf2-rscrates/bf2-server/src/hostfns.rs:463

What it does (from the original code). Posts EventManager (DAT_00892d5c) vt+0x10(6, 0x13, &{int playerId; std::string "rcon: "+text}, 0).

Shipped scripts use it like this:

BF2: Admin/default.py:260
host.rcon_feedback(ctx.player, feedback)
2142: Admin/default.py:261
host.rcon_feedback(ctx.player, feedback)
Source: tools/devwiki/refs_python.py · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.