On this page
Timers and handlers
9 functions of the host module. Generated from the bf2-rs sources; see the reference index for the cross-game table.
timer_getWallTime#
host.timer_getWallTime()| Fact | Detail |
|---|---|
| Arguments (as parsed) | - |
| Returns | float |
| Original code | bf2_w32ded.exe!0x00429b80, BF2.exe!0x0045dbc0, BFHeroes.exe (1.89)!0x0049219b |
| bf2-rs | crates/bf2-server/src/hostfns.rs:496 |
What it does (from the original code). Clock (DAT_0083b120) vt+0x14() as double. Same clock drives timer firing.
Shipped scripts use it like this:
return host.timer_getWallTime()return host.timer_getWallTime()return host.timer_getWallTime()timer_getTimers#
host.timer_getTimers()| Fact | Detail |
|---|---|
| Arguments (as parsed) | - |
| Returns | tuple |
| Original code | bf2_w32ded.exe!0x0042ada0, BF2.exe!0x0045f510, BFHeroes.exe (1.89)!0x00493239 |
| bf2-rs | crates/bf2-python/src/host_state.rs:538 |
What it does (from the original code). Bug: tuple has len(timer set) but every element is stored into slot 0 (last timer wins), other slots stay NULL. Unused by retail scripts.
timer_created#
host.timer_created(timer)| Fact | Detail |
|---|---|
| Arguments (as parsed) | args[0] raw |
| Returns | None |
| Errors | no arguments,IndexError |
| Original code | bf2_w32ded.exe!0x0042b1d0, BF2.exe!0x00460360, BFHeroes.exe (1.89)!0x00493495 |
| bf2-rs | crates/bf2-python/src/host_state.rs:540 |
What it does (from the original code). Inserts timer (incref) into the timer std::set<PyObject*> (state+0x20), ordered by object address.
Shipped scripts use it like this:
host.timer_created(self)host.timer_created(self)host.timer_created(self)timer_destroy#
host.timer_destroy(timer)| Fact | Detail |
|---|---|
| Arguments (as parsed) | args[0] raw |
| Returns | None |
| Errors | no arguments,IndexError |
| Original code | bf2_w32ded.exe!0x0042b260, BF2.exe!0x004603f0, BFHeroes.exe (1.89)!0x004934ca |
| bf2-rs | crates/bf2-python/src/host_state.rs:542 |
What it does (from the original code). Queues timer on the pending-destroy list (state+0x2c); it is erased from the set after the next updateTimers pass, so a due timer still fires once more.
Shipped scripts use it like this:
host.timer_destroy(self)host.timer_destroy(self)host.timer_destroy(self)registerHandler#
host.registerHandler(eventName, callable[, alwaysTrigger])| Fact | Detail |
|---|---|
| Arguments (as parsed) | s@0 O@1 [i@2 if len(args)>=3] |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg,"not callable","illegal event name" |
| Original code | bf2_w32ded.exe!0x0042ba50, BF2.exe!0x00461ec0, BFHeroes.exe (1.89)!0x00493bff |
| bf2-rs | crates/bf2-python/src/host_state.rs:544 |
What it does (from the original code). No-op returning None in minimal mode (state+1). eventName matched case-sensitively against s_eventNames; appends {callable, alwaysTrigger>0} to the per-event vector unless that callable object is already registered for the event.
Shipped scripts use it like this:
host.registerHandler('Reset', onReset, 1)host.registerHandler('Emp', onEmp)host.registerHandler( 'Stomp', onStomp )registerGameStatusHandler#
host.registerGameStatusHandler(callable)| Fact | Detail |
|---|---|
| Arguments (as parsed) | O@0 |
| Returns | None |
| Errors | TypeError (wrong arg type),"not callable" |
| Original code | bf2_w32ded.exe!0x0042b2c0, BF2.exe!0x00460450, BFHeroes.exe (1.89)!0x004934ff |
| bf2-rs | crates/bf2-python/src/host_state.rs:549 |
What it does (from the original code). No-op in minimal mode. push_back onto the status-handler std::list (state+0x18); duplicates allowed.
Shipped scripts use it like this:
host.registerGameStatusHandler(onGameStatusChanged)host.registerGameStatusHandler(onGameStatusChanged)host.registerGameStatusHandler(onGameStatusChanged)unregisterGameStatusHandler#
host.unregisterGameStatusHandler(callable)| Fact | Detail |
|---|---|
| Arguments (as parsed) | O@0 |
| Returns | None |
| Errors | TypeError (wrong arg type),"not callable" |
| Original code | bf2_w32ded.exe!0x0042b370, BF2.exe!0x00460500, BFHeroes.exe (1.89)!0x0049358e |
| bf2-rs | crates/bf2-python/src/host_state.rs:551 |
What it does (from the original code). No-op in minimal mode. Removes every list entry whose PyObject* is identical to callable.
Shipped scripts use it like this:
host.unregisterGameStatusHandler(onGameStatusChanged)host.unregisterGameStatusHandler(onGameStatusChanged)host.unregisterGameStatusHandler(onGameStatusChanged)timer_getGameSpyTime#
host.timer_getGameSpyTime(...)| Fact | Detail |
|---|---|
| bf2-rs | crates/bf2-server/src/hostfns_2142.rs:66 |
What it does (from the bf2-rs port). timer_getGameSpyTime (bf2142ded!0x0816ede0, BF2142.exe!0x004424b0): time(NULL) plus the "GameSpyAuth" service's vt+0x14 offset (GameSpyAuth::getTimeDiff, set from getbackendinfo.aspx).
unregisterHandler#
host.unregisterHandler(...)| Fact | Detail |
|---|---|
| Original code | BFHeroes.exe (1.89)!0x004938c5 |
| bf2-rs | crates/bf2-python/src/host_state.rs:547 |
What it does (from the bf2-rs port). BFHeroes.exe!0x004938c5: same behaviour (the key chain and calls match, vtable offsets shifted). Only in 2142's table (crate::pythonhost::HOST_FUNCTIONS_2142).
Shipped scripts use it like this:
host.unregisterHandler('PlayerSpawn', onPlayerSpawn)host.unregisterHandler('PlayerSpawn', onPlayerSpawn)tools/devwiki/refs_python.py · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.