BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
generated from the code
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#

BF22142Heroes
python
host.sgl_getModDirectory()
FactDetail
Arguments (as parsed)-
Returnsstr
Original codebf2_w32ded.exe!0x005330f0, BF2.exe!0x0058f720, BFHeroes.exe (1.89)!0x0066c79c
bf2-rscrates/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:

BF2: mods/sandbox/python/game/gamemodes/sbxSettings.py:119
config.read(host.sgl_getModDirectory() + str(file))
2142: python/bf2/GameLogic.py:10
def getModDir(self): return host.sgl_getModDirectory()
Heroes: python/bf2/GameLogic.py:10
def getModDir(self): return host.sgl_getModDirectory()

sgl_getMapName#

BF22142Heroes
python
host.sgl_getMapName()
FactDetail
Arguments (as parsed)-
Returnsstr
Original codebf2_w32ded.exe!0x00533180, BF2.exe!0x0058f7a0, BFHeroes.exe (1.89)!0x0066c82e
bf2-rscrates/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:

BF2: python/bf2/GameLogic.py:11
def getMapName(self): return host.sgl_getMapName()
2142: python/bf2/GameLogic.py:11
def getMapName(self): return host.sgl_getMapName()
Heroes: python/bf2/GameLogic.py:11
def getMapName(self): return host.sgl_getMapName()

sgl_getWorldSize#

BF22142Heroes
python
host.sgl_getWorldSize()
FactDetail
Arguments (as parsed)-
Returns(int,int)
Original codebf2_w32ded.exe!0x00533230, BF2.exe!0x0058f840, BFHeroes.exe (1.89)!0x0066c8e2
bf2-rscrates/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:

BF2: python/bf2/GameLogic.py:12
def getWorldSize(self): return host.sgl_getWorldSize()
2142: python/bf2/GameLogic.py:12
def getWorldSize(self): return host.sgl_getWorldSize()
Heroes: python/bf2/GameLogic.py:12
def getWorldSize(self): return host.sgl_getWorldSize()

sgl_setParam#

BF22142Heroes
python
host.sgl_setParam(key, team, value, id)
FactDetail
Arguments (as parsed)s@0, then i@3 f@2 i@1
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg(key only),"function needs team, value and id parameter","bad attribute"
Original codebf2_w32ded.exe!0x005332e0, BF2.exe!0x0058f8f0, BFHeroes.exe (1.89)!0x0066ca35
bf2-rscrates/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:

BF2: python/bf2/GameLogic.py:28
def setTickets(self, team, value): return host.sgl_setParam('tickets', team, value, 0)
2142: python/bf2/GameLogic.py:30
def setTickets(self, team, value): return host.sgl_setParam('tickets', team, value, 0)
Heroes: python/bf2/GameLogic.py:30
def setTimeLeft(self, value): return host.sgl_setParam('timeLeft', 0, value, 0)

sgl_getParam#

BF22142Heroes
python
host.sgl_getParam(key, team, id)
FactDetail
Arguments (as parsed)s@0, then i@2 i@1
Returns`intfloatstr`
ErrorsTypeError (wrong arg type),missing arg(key only),"function needs team an id parameter","bad attribute"
Original codebf2_w32ded.exe!0x00533580, BF2.exe!0x0058fb70, BFHeroes.exe (1.89)!0x0066cca1
bf2-rscrates/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:

BF2: python/bf2/GameLogic.py:41
def getWinner(self): return host.sgl_getParam('winner', 0, 0)
2142: python/bf2/GameLogic.py:43
def getWinner(self): return host.sgl_getParam('winner', 0, 0)
Heroes: python/bf2/GameLogic.py:52
def getWinner(self): return host.sgl_getParam('winner', 0, 0)

sgl_endGame#

BF22142Heroes
python
host.sgl_endGame(winner, victoryType)
FactDetail
Arguments (as parsed)i@1 i@0
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x00533810, BF2.exe!0x0058fe00, BFHeroes.exe (1.89)!0x0066cfaf
bf2-rscrates/bf2-server/src/hostfns.rs:623

What it does (from the original code). 0x0045a620(winner, victoryType).

Shipped scripts use it like this:

BF2: mods/sandbox/python/game/gamemodes/addons/clear.py:37
host.sgl_endGame(0,0)
2142: mods/bf2142/python/game/gamemodes/gpm_ti.py:243
host.sgl_endGame(0, 0, 0)
Heroes: mods/bfheroes/python/game/gamemodes/gpm_ctf.py:272
host.sgl_endGame(team, 3, 1)

sgl_getControlPointsInGroup#

BF22142Heroes
python
host.sgl_getControlPointsInGroup(group)
FactDetail
Arguments (as parsed)i@0
Returnstuple(host.Object)
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x00534280, BF2.exe!0x00590960, BFHeroes.exe (1.89)!0x0066da15
bf2-rscrates/bf2-server/src/hostfns.rs:650

What it does (from the original code). GameLogic vt+0x180(&vector, group).

Shipped scripts use it like this:

2142: mods/bf2142/python/game/gamemodes/gpm_sl.py:149
cpsInGroup = host.sgl_getControlPointsInGroup(grp)
Heroes: mods/bfheroes/python/game/gamemodes/gpm_tut.py:148
cpsInGroup = host.sgl_getControlPointsInGroup(grp)

sgl_getIsAIGame#

BF22142Heroes
python
host.sgl_getIsAIGame()
FactDetail
Arguments (as parsed)-
Returnsint(0/1)
Original codebf2_w32ded.exe!0x005330d0, BF2.exe!0x0058f700, BFHeroes.exe (1.89)!0x0066c792
bf2-rscrates/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:

BF2: Admin/standard_admin/autobalance.py:67
if host.sgl_getIsAIGame():
2142: Admin/standard_admin/autobalance.py:67
if host.sgl_getIsAIGame():
Heroes: mods/bfheroes/python/game/gamemodes/gpm_cdm.py:73
if host.sgl_getIsAIGame() == 1:

sgl_sendGameLogicEvent#

BF22142Heroes
python
host.sgl_sendGameLogicEvent(playerIndex, eventId, data)
FactDetail
Arguments (as parsed)i@0 i@1 i@2
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg,"only one event ID byte allowed"
Original codebf2_w32ded.exe!0x00533870, BF2.exe!0x0058fea0, BFHeroes.exe (1.89)!0x0066d063
bf2-rscrates/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:

BF2: python/bf2/GameLogic.py:17
def sendGameEvent(self, player, event, data): return host.sgl_sendGameLogicEvent(player.index, event, data)
2142: python/bf2/GameLogic.py:18
def sendGameEvent(self, player, event, data): return host.sgl_sendGameLogicEvent(player.index, event, data)
Heroes: python/bf2/GameLogic.py:18
def sendGameEvent(self, player, event, data): return host.sgl_sendGameLogicEvent(player.index, event, data)

sgl_sendPythonEvent#

BF22142Heroes
python
host.sgl_sendPythonEvent(playerIndex, command, args)
FactDetail
Arguments (as parsed)i@0 i@1, args[2] raw tuple
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg,"expected an integer"
Original codebf2_w32ded.exe!0x00533930, BF2.exe!0x0058ff60, BFHeroes.exe (1.89)!0x0066d117
bf2-rscrates/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:

BF2: python/bf2/GameLogic.py:16
def sendClientCommand(self, playerId, command, args): return host.sgl_sendPythonEvent(playerId, command, args)
2142: python/bf2/GameLogic.py:17
def sendClientCommand(self, playerId, command, args): return host.sgl_sendPythonEvent(playerId, command, args)
Heroes: python/bf2/GameLogic.py:17
def sendClientCommand(self, playerId, command, args): return host.sgl_sendPythonEvent(playerId, command, args)

sgl_sendMedalEvent#

BF22142Heroes
python
host.sgl_sendMedalEvent(playerIndex, type, value)
FactDetail
Arguments (as parsed)i@0 i@1 i@2
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x00533b40, BF2.exe!0x00590170, BFHeroes.exe (1.89)!0x0066d26e
bf2-rscrates/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:

BF2: python/bf2/GameLogic.py:18
def sendMedalEvent(self, player, type, value): return host.sgl_sendMedalEvent(player.index, type, value)
2142: python/bf2/GameLogic.py:19
def sendMedalEvent(self, player, type, value, points, credits): return host.sgl_sendMedalEvent(player.index, type, value, points, credits)
Heroes: python/bf2/GameLogic.py:20
def sendMedalEvent(self, player, type, value, points, credits): return host.sgl_sendMedalEvent(player.index, type, value, points, credits)

sgl_sendRankEvent#

BF22142Heroes
python
host.sgl_sendRankEvent(playerIndex, rank, score)
FactDetail
Arguments (as parsed)i@0 i@1 i@2
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x00533bd0, BF2.exe!0x00590200, BFHeroes.exe (1.89)!0x0066d2fe
bf2-rscrates/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:

BF2: python/bf2/GameLogic.py:19
def sendRankEvent(self, player, rank, score): return host.sgl_sendRankEvent(player.index, rank, score)
2142: python/bf2/GameLogic.py:20
def sendRankEvent(self, player, rank, score): return host.sgl_sendRankEvent(player.index, rank, score)
Heroes: python/bf2/GameLogic.py:21
def sendRankEvent(self, player, rank, score, vp, hp): return host.sgl_sendRankEvent(player.index, rank, score, vp, hp)

sgl_sendHudEvent#

BF22142Heroes
python
host.sgl_sendHudEvent(playerIndex, eventId, data)
FactDetail
Arguments (as parsed)i@0 i@1 i@2
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg,"only one event ID byte allowed"
Original codebf2_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:

BF2: python/bf2/GameLogic.py:20
def sendHudEvent(self, player, event, data): return host.sgl_sendHudEvent(player.index, event, data)
2142: python/bf2/GameLogic.py:21
def sendHudEvent(self, player, event, data): return host.sgl_sendHudEvent(player.index, event, data)
Heroes: python/bf2/GameLogic.py:22
def sendHudEvent(self, player, event, data): return host.sgl_sendHudEvent(player.index, event, data)

sgl_sendTextMessage#

BF22142Heroes
python
host.sgl_sendTextMessage(playerIndex, a, b, text, c)
FactDetail
Arguments (as parsed)i@4 i@2 i@1 i@0 s@3
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x00533d20, BF2.exe!0x00590350, BFHeroes.exe (1.89)!0x0066d4b9
bf2-rscrates/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:

BF2: Admin/standard_admin/playerconnect.py:28
host.sgl_sendTextMessage(0, 12, 1, message, 0)
2142: Admin/standard_admin/playerconnect.py:58
host.sgl_sendTextMessage(0, 12, 1, message, 0)
Heroes: python/bf2/GameLogic.py:24
def sendServerMessage(self, playerId, message): return host.sgl_sendTextMessage(playerId, 10, 1, message, 0)

gl_sendEndOfRoundData#

BF22142Heroes
python
host.gl_sendEndOfRoundData(data)
FactDetail
Arguments (as parsed)s@0
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x00534320, BF2.exe!0x00590e60, BFHeroes.exe (1.89)!0x0066da08
bf2-rscrates/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:

BF2: python/bf2/stats/endofround.py:82
host.gl_sendEndOfRoundData(dataString)
2142: python/bf2/stats/endofround.py:161
host.gl_sendEndOfRoundData(dataString)

ss_getParam#

BF22142Heroes
python
host.ss_getParam(key)
FactDetail
Arguments (as parsed)s@0
Returns`intfloatstr`
ErrorsTypeError (wrong arg type),missing arg,"unknown serversetting"
Original codebf2_w32ded.exe!0x00533e20, BF2.exe!0x00590430, BFHeroes.exe (1.89)!0x0066d5c4
bf2-rscrates/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:

BF2: python/bf2/stats/stats.py:338
if host.ss_getParam('ranked'):
2142: python/bf2/stats/stats.py:41
if host.ss_getParam('ranked'):
Heroes: python/bf2/stats/stats.py:68
if host.ss_getParam('ranked'):

sgl_getSettingsBool#

BF22142Heroes
python
host.sgl_getSettingsBool(name)
FactDetail
Arguments (as parsed)s@0
Returnsint(0/1)
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x005341f0, BF2.exe!0x005907e0, BFHeroes.exe (1.89)!0x0066d896
bf2-rscrates/bf2-server/src/hostfns.rs:897

What it does (from the original code). Settings vt+0x50(name, false).

sh_setEnableCommander#

BF22142Heroes
python
host.sh_setEnableCommander(flag)
FactDetail
Arguments (as parsed)i@0
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg
Original codebf2_w32ded.exe!0x005341a0, BF2.exe!0x00590790, BFHeroes.exe (1.89)!0x0066d855
bf2-rscrates/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:

BF2: mods/bf2/python/game/gamemodes/gpm_coop.py:30
host.sh_setEnableCommander(1)
2142: mods/bf2142/python/game/gamemodes/gpm_ca.py:30
host.sh_setEnableCommander(1)
Heroes: mods/bfheroes/python/game/gamemodes/gpm_cdm.py:74
host.sh_setEnableCommander(1)

sgl_getOverlayDirectory#

2142Heroes
python
host.sgl_getOverlayDirectory(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c9a3
bf2-rscrates/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:

2142: Admin/default.py:69
fn = host.sgl_getOverlayDirectory() + 'admin/default.cfg'
Heroes: python/bf2/GameLogic.py:15
def getOverlayDir(self): return host.sgl_getOverlayDirectory()

sgl_getInGameEventIdList#

Heroes
python
host.sgl_getInGameEventIdList(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066daa0
bf2-rscrates/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:

Heroes: python/bf2/GameLogic.py:55
def getInGameEventIdList(self) : return host.sgl_getInGameEventIdList()

sgl_isDailyMission#

Heroes
python
host.sgl_isDailyMission(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066d56b
bf2-rscrates/bfh-server/src/lib.rs:428

What it does (from the bf2-rs port). BFHeroes.exe!0x0066d56b (stub).

Shipped scripts use it like this:

Heroes: python/bf2/GameLogic.py:72
def isDailyMission(self, missionId) : return host.sgl_isDailyMission(missionId)

sgl_sendPrestigeLevelEvent#

Heroes
python
host.sgl_sendPrestigeLevelEvent(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066d399
bf2-rscrates/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#

Heroes
python
host.sgl_getIsFlagCarrier(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066d019
bf2-rscrates/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:

Heroes: python/bf2/GameLogic.py:76
def getIsFlagCarrier(self, playerId): return host.sgl_getIsFlagCarrier(playerId)
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.