On this page
Game logic (sgl_, gl_, ss_, sh_)
23 functions of the host module. Generated from the bf2-rs sources; see the reference index for the cross-game table.
sgl_getModDirectory#
host.sgl_getModDirectory()| Fact | Detail |
|---|---|
| Arguments (as parsed) | - |
| Returns | str |
| Original code | bf2_w32ded.exe!0x005330f0, BF2.exe!0x0058f720, BFHeroes.exe (1.89)!0x0066c79c |
| bf2-rs | crates/bf2-server/src/hostfns.rs:530 |
What it does (from the original code). Settings (DAT_00837fb8) vt+0x40("GSModDirectory", "").
Shipped scripts use it like this:
config.read(host.sgl_getModDirectory() + str(file))def getModDir(self): return host.sgl_getModDirectory()def getModDir(self): return host.sgl_getModDirectory()sgl_getMapName#
host.sgl_getMapName()| Fact | Detail |
|---|---|
| Arguments (as parsed) | - |
| Returns | str |
| Original code | bf2_w32ded.exe!0x00533180, BF2.exe!0x0058f7a0, BFHeroes.exe (1.89)!0x0066c82e |
| bf2-rs | crates/bf2-server/src/hostfns.rs:536 |
What it does (from the original code). GameServer (DAT_0083b1b0) vt+0xec(); if empty, settings string "GSLoadLevel".
Shipped scripts use it like this:
def getMapName(self): return host.sgl_getMapName()def getMapName(self): return host.sgl_getMapName()def getMapName(self): return host.sgl_getMapName()sgl_getWorldSize#
host.sgl_getWorldSize()| Fact | Detail |
|---|---|
| Arguments (as parsed) | - |
| Returns | (int,int) |
| Original code | bf2_w32ded.exe!0x00533230, BF2.exe!0x0058f840, BFHeroes.exe (1.89)!0x0066c8e2 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:547 |
What it does (from the original code). Settings vt+0x10("GLSWorldSizeX", 0x400), ("GLSWorldSizeZ", 0x400).
Shipped scripts use it like this:
def getWorldSize(self): return host.sgl_getWorldSize()def getWorldSize(self): return host.sgl_getWorldSize()def getWorldSize(self): return host.sgl_getWorldSize()sgl_setParam#
host.sgl_setParam(key, team, value, id)| Fact | Detail |
|---|---|
| Arguments (as parsed) | s@0, then i@3 f@2 i@1 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg(key only),"function needs team, value and id parameter","bad attribute" |
| Original code | bf2_w32ded.exe!0x005332e0, BF2.exe!0x0058f8f0, BFHeroes.exe (1.89)!0x0066ca35 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:559 |
What it does (from the original code). tickets 0x00454cb0(team,(int)value); ticketLimit 0x00456f50(team,(int)value,id); ticketState GameLogic(DAT_0083bf50) vt8c(team,(int)value); ticketChangePerSecond 0x004545f0(team,(float)value); healScoreLimit/repairScoreLimit/giveAmmoScoreLimit/teamDamageScoreLimit/teamVehicleDamageScoreLimit ScoreManager (DAT_008627f8) vt28/30/38/40/48((float)value). All keys need all 4 args.
Shipped scripts use it like this:
def setTickets(self, team, value): return host.sgl_setParam('tickets', team, value, 0)def setTickets(self, team, value): return host.sgl_setParam('tickets', team, value, 0)def setTimeLeft(self, value): return host.sgl_setParam('timeLeft', 0, value, 0)sgl_getParam#
host.sgl_getParam(key, team, id)| Fact | Detail | ||
|---|---|---|---|
| Arguments (as parsed) | s@0, then i@2 i@1 | ||
| Returns | `int | float | str` |
| Errors | TypeError (wrong arg type),missing arg(key only),"function needs team an id parameter","bad attribute" | ||
| Original code | bf2_w32ded.exe!0x00533580, BF2.exe!0x0058fb70, BFHeroes.exe (1.89)!0x0066cca1 | ||
| bf2-rs | crates/bf2-server/src/hostfns.rs:589 |
What it does (from the original code). tickets 0x00454ce0 int; startTickets GameLogic vt98 int; ticketLimit 0x00456af0(team, id) int (argument order unverified); ticketState vt90 int; ticketChangePerSecond 0x00454640 float; defaultTicketLossPerMin vtb8 float; defaultTicketLossAtEndPerMin vtb0 float; teamName vt48 str; winner ScoreManager vt18 int; victoryType vt24 int. Extra args ignored.
Shipped scripts use it like this:
def getWinner(self): return host.sgl_getParam('winner', 0, 0)def getWinner(self): return host.sgl_getParam('winner', 0, 0)def getWinner(self): return host.sgl_getParam('winner', 0, 0)sgl_endGame#
host.sgl_endGame(winner, victoryType)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@1 i@0 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg |
| Original code | bf2_w32ded.exe!0x00533810, BF2.exe!0x0058fe00, BFHeroes.exe (1.89)!0x0066cfaf |
| bf2-rs | crates/bf2-server/src/hostfns.rs:623 |
What it does (from the original code). 0x0045a620(winner, victoryType).
Shipped scripts use it like this:
host.sgl_endGame(0,0)host.sgl_endGame(0, 0, 0)host.sgl_endGame(team, 3, 1)sgl_getControlPointsInGroup#
host.sgl_getControlPointsInGroup(group)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@0 |
| Returns | tuple(host.Object) |
| Errors | TypeError (wrong arg type),missing arg |
| Original code | bf2_w32ded.exe!0x00534280, BF2.exe!0x00590960, BFHeroes.exe (1.89)!0x0066da15 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:650 |
What it does (from the original code). GameLogic vt+0x180(&vector, group).
Shipped scripts use it like this:
cpsInGroup = host.sgl_getControlPointsInGroup(grp)cpsInGroup = host.sgl_getControlPointsInGroup(grp)sgl_getIsAIGame#
host.sgl_getIsAIGame()| Fact | Detail |
|---|---|
| Arguments (as parsed) | - |
| Returns | int(0/1) |
| Original code | bf2_w32ded.exe!0x005330d0, BF2.exe!0x0058f700, BFHeroes.exe (1.89)!0x0066c792 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:665, crates/bfh-server/src/lib.rs:511 |
What it does (from the original code). DAT_008b25b0 != NULL.
Shipped scripts use it like this:
if host.sgl_getIsAIGame():if host.sgl_getIsAIGame():if host.sgl_getIsAIGame() == 1:sgl_sendGameLogicEvent#
host.sgl_sendGameLogicEvent(playerIndex, eventId, data)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@0 i@1 i@2 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg,"only one event ID byte allowed" |
| Original code | bf2_w32ded.exe!0x00533870, BF2.exe!0x0058fea0, BFHeroes.exe (1.89)!0x0066d063 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:678 |
What it does (from the original code). eventId must be 0..24. Event 0x0053a2d0(0, eventId, playerIndex, &data, 4, 0) sent with GameServer vt+0x94(playerIndex, ev).
Shipped scripts use it like this:
def sendGameEvent(self, player, event, data): return host.sgl_sendGameLogicEvent(player.index, event, data)def sendGameEvent(self, player, event, data): return host.sgl_sendGameLogicEvent(player.index, event, data)def sendGameEvent(self, player, event, data): return host.sgl_sendGameLogicEvent(player.index, event, data)sgl_sendPythonEvent#
host.sgl_sendPythonEvent(playerIndex, command, args)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@0 i@1, args[2] raw tuple |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg,"expected an integer" |
| Original code | bf2_w32ded.exe!0x00533930, BF2.exe!0x0058ff60, BFHeroes.exe (1.89)!0x0066d117 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:717 |
What it does (from the original code). Up to 4 ints from args tuple copied with no bounds check (more than 4 overwrite playerIndex). playerIndex==-1: broadcast GameServer vt+0x90 of event 0x005403e0(cmd,-1,1,1,a0..a3); else vt+0x94(player, 0x005403e0(cmd, player, isLocalPlayer, 1, a0..a3)).
Shipped scripts use it like this:
def sendClientCommand(self, playerId, command, args): return host.sgl_sendPythonEvent(playerId, command, args)def sendClientCommand(self, playerId, command, args): return host.sgl_sendPythonEvent(playerId, command, args)def sendClientCommand(self, playerId, command, args): return host.sgl_sendPythonEvent(playerId, command, args)sgl_sendMedalEvent#
host.sgl_sendMedalEvent(playerIndex, type, value)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@0 i@1 i@2 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg |
| Original code | bf2_w32ded.exe!0x00533b40, BF2.exe!0x00590170, BFHeroes.exe (1.89)!0x0066d26e |
| bf2-rs | crates/bf2-server/src/hostfns.rs:789 |
What it does (from the original code). GameServer vt+0x80(0x0053ef20(type, playerIndex, value)) broadcast.
Shipped scripts use it like this:
def sendMedalEvent(self, player, type, value): return host.sgl_sendMedalEvent(player.index, type, value)def sendMedalEvent(self, player, type, value, points, credits): return host.sgl_sendMedalEvent(player.index, type, value, points, credits)def sendMedalEvent(self, player, type, value, points, credits): return host.sgl_sendMedalEvent(player.index, type, value, points, credits)sgl_sendRankEvent#
host.sgl_sendRankEvent(playerIndex, rank, score)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@0 i@1 i@2 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg |
| Original code | bf2_w32ded.exe!0x00533bd0, BF2.exe!0x00590200, BFHeroes.exe (1.89)!0x0066d2fe |
| bf2-rs | crates/bf2-server/src/hostfns.rs:833 |
What it does (from the original code). GameServer vt+0x80(0x0053b8f0(1, rank, score, playerIndex)) broadcast.
Shipped scripts use it like this:
def sendRankEvent(self, player, rank, score): return host.sgl_sendRankEvent(player.index, rank, score)def sendRankEvent(self, player, rank, score): return host.sgl_sendRankEvent(player.index, rank, score)def sendRankEvent(self, player, rank, score, vp, hp): return host.sgl_sendRankEvent(player.index, rank, score, vp, hp)sgl_sendHudEvent#
host.sgl_sendHudEvent(playerIndex, eventId, data)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@0 i@1 i@2 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg,"only one event ID byte allowed" |
| Original code | bf2_w32ded.exe!0x00533c60, BF2.exe!0x00590290, BFHeroes.exe (1.89)!0x0066d404 |
What it does (from the original code). eventId must be 0..78. Event 0x0053a2d0(2, eventId, playerIndex, &data, 4, 0) via GameServer vt+0x94(playerIndex, ev).
Shipped scripts use it like this:
def sendHudEvent(self, player, event, data): return host.sgl_sendHudEvent(player.index, event, data)def sendHudEvent(self, player, event, data): return host.sgl_sendHudEvent(player.index, event, data)def sendHudEvent(self, player, event, data): return host.sgl_sendHudEvent(player.index, event, data)sgl_sendTextMessage#
host.sgl_sendTextMessage(playerIndex, a, b, text, c)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@4 i@2 i@1 i@0 s@3 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg |
| Original code | bf2_w32ded.exe!0x00533d20, BF2.exe!0x00590350, BFHeroes.exe (1.89)!0x0066d4b9 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:871 |
What it does (from the original code). All 5 args required (bf2.GameLogic.sendServerMessage passes 4 and therefore raises IndexError). x = c, or playerIndex if a == 14. Calls (GameServer vt+0xc(0x1d4c1)) vt+0x94(text, a, b, playerIndex, x).
Shipped scripts use it like this:
host.sgl_sendTextMessage(0, 12, 1, message, 0)host.sgl_sendTextMessage(0, 12, 1, message, 0)def sendServerMessage(self, playerId, message): return host.sgl_sendTextMessage(playerId, 10, 1, message, 0)gl_sendEndOfRoundData#
host.gl_sendEndOfRoundData(data)| Fact | Detail |
|---|---|
| Arguments (as parsed) | s@0 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg |
| Original code | bf2_w32ded.exe!0x00534320, BF2.exe!0x00590e60, BFHeroes.exe (1.89)!0x0066da08 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:884, crates/bfh-server/src/lib.rs:513 |
What it does (from the original code). Builds an end-of-round record: data string, map name (GameServer vtec), literal "$gamemode_fixme", victoryType, winner, GameServer vtf8, per team 1..2 name (GameLogic vt48) and ScoreManager vt10(team)+0x84; GameLogic vt278; sends via 0x004467b0(8, ...).
Shipped scripts use it like this:
host.gl_sendEndOfRoundData(dataString)host.gl_sendEndOfRoundData(dataString)ss_getParam#
host.ss_getParam(key)| Fact | Detail | ||
|---|---|---|---|
| Arguments (as parsed) | s@0 | ||
| Returns | `int | float | str` |
| Errors | TypeError (wrong arg type),missing arg,"unknown serversetting" | ||
| Original code | bf2_w32ded.exe!0x00533e20, BF2.exe!0x00590430, BFHeroes.exe (1.89)!0x0066d5c4 | ||
| bf2-rs | crates/bf2-server/src/hostfns.rs:890 |
What it does (from the original code). ServerSettings (DAT_00841620): ticketRatio 0x00425770 int; maxPlayers 0x00425d40 int; gameMode GameServer vtf0 str; mapName GameServer vtec str; timeLimit +0x120 int; scoreLimit +0x124 int; autoBalance int; teamRatioPct 0x00425790 float; tkpEnabled byte +0x140; tkpNeeded +0x144; tkpDefault int; globRank 0x00425840; globUnlocks 0x00425810 (string compared twice); noVehicles 0x004258a0; ranked 0x00425360 (also calls 0x00424e80 vtd4(0,1)); hosted 0x00424e80 vtd4(1,1).
Shipped scripts use it like this:
if host.ss_getParam('ranked'):if host.ss_getParam('ranked'):if host.ss_getParam('ranked'):sgl_getSettingsBool#
host.sgl_getSettingsBool(name)| Fact | Detail |
|---|---|
| Arguments (as parsed) | s@0 |
| Returns | int(0/1) |
| Errors | TypeError (wrong arg type),missing arg |
| Original code | bf2_w32ded.exe!0x005341f0, BF2.exe!0x005907e0, BFHeroes.exe (1.89)!0x0066d896 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:897 |
What it does (from the original code). Settings vt+0x50(name, false).
sh_setEnableCommander#
host.sh_setEnableCommander(flag)| Fact | Detail |
|---|---|
| Arguments (as parsed) | i@0 |
| Returns | None |
| Errors | TypeError (wrong arg type),missing arg |
| Original code | bf2_w32ded.exe!0x005341a0, BF2.exe!0x00590790, BFHeroes.exe (1.89)!0x0066d855 |
| bf2-rs | crates/bf2-server/src/hostfns.rs:906 |
What it does (from the original code). EventManager vt+0x10(2, 0x3f, &flag, 0).
Shipped scripts use it like this:
host.sh_setEnableCommander(1)host.sh_setEnableCommander(1)host.sh_setEnableCommander(1)sgl_getOverlayDirectory#
host.sgl_getOverlayDirectory(...)| Fact | Detail |
|---|---|
| Original code | BFHeroes.exe (1.89)!0x0066c9a3 |
| bf2-rs | crates/bf2-server/src/hostfns_2142.rs:28 |
What it does (from the bf2-rs port). BFHeroes.exe!0x0066c9a3: same behaviour (getString("GSOverlayPath")). sgl_getOverlayDirectory (bf2142ded!0x08162780): the settings repository's getString("GSOverlayPath", "") as a Python string.
Shipped scripts use it like this:
fn = host.sgl_getOverlayDirectory() + 'admin/default.cfg'def getOverlayDir(self): return host.sgl_getOverlayDirectory()sgl_getInGameEventIdList#
host.sgl_getInGameEventIdList(...)| Fact | Detail |
|---|---|
| Original code | BFHeroes.exe (1.89)!0x0066daa0 |
| bf2-rs | crates/bfh-server/src/lib.rs:423 |
What it does (from the bf2-rs port). BFHeroes.exe@bfh126!0x006a0f70 (1.89 BFHeroes.exe!0x0066daa0): the manager's ids as ints.
Shipped scripts use it like this:
def getInGameEventIdList(self) : return host.sgl_getInGameEventIdList()sgl_isDailyMission#
host.sgl_isDailyMission(...)| Fact | Detail |
|---|---|
| Original code | BFHeroes.exe (1.89)!0x0066d56b |
| bf2-rs | crates/bfh-server/src/lib.rs:428 |
What it does (from the bf2-rs port). BFHeroes.exe!0x0066d56b (stub).
Shipped scripts use it like this:
def isDailyMission(self, missionId) : return host.sgl_isDailyMission(missionId)sgl_sendPrestigeLevelEvent#
host.sgl_sendPrestigeLevelEvent(...)| Fact | Detail |
|---|---|
| Original code | BFHeroes.exe (1.89)!0x0066d399 |
| bf2-rs | crates/bfh-server/src/lib.rs:438 |
What it does (from the bf2-rs port). BFHeroes.exe!0x0066d399 is a stub on 1.89; 1.126's BFHeroes.exe@bfh126!0x006a0860 reads argInt(2), argInt(1), argInt(0) and sends the PrestigeLevelEvent (rank::send_level_event).
sgl_getIsFlagCarrier#
host.sgl_getIsFlagCarrier(...)| Fact | Detail |
|---|---|
| Original code | BFHeroes.exe (1.89)!0x0066d019 |
| bf2-rs | crates/bfh-server/src/lib.rs:430 |
What it does (from the bf2-rs port). BFHeroes.exe!0x0066d019: argInt(0) the player index; 0 without that player.
Shipped scripts use it like this:
def getIsFlagCarrier(self, playerId): return host.sgl_getIsFlagCarrier(playerId)tools/devwiki/refs_python.py · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.