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

Persistence and stats (pers_)

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

pers_plrAwardMedal#

BF22142
python
host.pers_plrAwardMedal(a, b, c, d)
FactDetail
Arguments (as parsed)i@3 i@2 i@1 i@0 into one slot
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg,"no such player"
Original codebf2_w32ded.exe!0x005328b0, BF2.exe!0x0058ef50
bf2-rscrates/bf2-server/src/hostfns.rs:913

What it does (from the original code). Stub: only checks that player args[0] exists.

pers_plrSetUnlocks#

BF22142Heroes
python
host.pers_plrSetUnlocks(index, list1, list2)
FactDetail
Arguments (as parsed)args[1] raw, O@2 (list), i@0
ReturnsNone
ErrorsTypeError (wrong arg type),missing arg,"no such player","expected an integer"
Original codebf2_w32ded.exe!0x00532ed0, BF2.exe!0x0058f500, BFHeroes.exe (1.89)!0x0066c77b
bf2-rscrates/bf2-server/src/players_host.rs:95, crates/bfh-server/src/lib.rs:500

What it does (from the original code). Two int lists (PyList_GetItem) copied into std::set<int> pair and passed to 0x00458040(player, sets).

Shipped scripts use it like this:

BF2: python/bf2/stats/unlocks.py:99
host.pers_plrSetUnlocks(player.index, kitUnlocks, kitUnlocks)

pers_plrRequestUnlocks#

BF22142Heroes
python
host.pers_plrRequestUnlocks(index, flag)
FactDetail
Arguments (as parsed)i@0 i@1
Returnsint(0/1)
ErrorsTypeError (wrong arg type),missing arg,"no such player"
Original codebf2_w32ded.exe!0x00532db0, BF2.exe!0x0058f3e0, BFHeroes.exe (1.89)!0x0066c788
bf2-rscrates/bf2-server/src/hostfns.rs:948, crates/bfh-server/src/lib.rs:502
bf2-rs statusanswers without the backend: player lookup as retail; returns pid != 0 without a request (no GameSpy stats backend)

What it does (from the original code). Creates request 0x005d5a00 (size 0x44), registers it with the persistence object (GameServer vtc(0x1d4c1) vt+0xa8), then req vt+0x14 with the player's profile id (vt2a8) and flag!=0 (argument order unverified). Result -> PlayerUnlocksResponse.

Shipped scripts use it like this:

BF2: python/bf2/stats/unlocks.py:74
success = host.pers_plrRequestUnlocks(player.index, 1)
2142: python/bf2/stats/unlocks.py:25
success = host.pers_plrRequestUnlocks(player.index, 1)

pers_plrRequestStats#

BF22142
python
host.pers_plrRequestStats(indexOrPid, flag, query)
FactDetail
Arguments (as parsed)i@0 i@1 s@2
Returnsint(0/1)
ErrorsTypeError (wrong arg type),missing arg,"no such player"
Original codebf2_w32ded.exe!0x00532950, BF2.exe!0x0058eff0
bf2-rscrates/bf2-server/src/hostfns.rs:997
bf2-rs statusanswers without the backend: player lookup as retail; returns pid != 0 without a request (no GameSpy stats backend)

What it does (from the original code). indexOrPid < 256 is a player index (pid = player vt2a8) else a profile id. Request 0x005d6910 vt+0x10(pid, query, flag!=0, 1). Result -> PlayerStatsResponse.

Shipped scripts use it like this:

BF2: python/bf2/stats/rank.py:53
success = host.pers_plrRequestStats(player.index, 1, "&info=rank")
2142: python/bf2/stats/rank.py:53
success = host.pers_plrRequestStats(player.index, 1, "&mode=base", 0)

pers_plrRequestAwards#

BF22142
python
host.pers_plrRequestAwards(indexOrPid, flag, query)
FactDetail
Arguments (as parsed)i@0 i@1 s@2
Returnsint(0/1)
ErrorsTypeError (wrong arg type),missing arg,"no such player"
Original codebf2_w32ded.exe!0x00532a90, BF2.exe!0x0058f110
bf2-rs statusanswers without the backend: player lookup as retail; returns pid != 0 without a request (no GameSpy stats backend)

What it does (from the original code). Same as pers_plrRequestStats with request 0x005cf4a0 and query ignored (0). Result -> PlayerAwardsResponse.

pers_getStatsKeyVal#

BF22142Heroes
python
host.pers_getStatsKeyVal(key)
FactDetail
Arguments (as parsed)s@0
Returnsstr
ErrorsTypeError (wrong arg type),missing arg,"there is no current persistence object downloaded"
Original codebf2_w32ded.exe!0x00532bd0, BF2.exe!0x0058f230, BFHeroes.exe (1.89)!0x0066c603
bf2-rscrates/bf2-server/src/hostfns.rs:1050
bf2-rs statusanswers without the backend: '' for a requested PlayerStats (never downloaded), else the retail error

What it does (from the original code). (GameServer vtc(0x1d4c1) vtb4)->vtc(0x1d8dd) vt+0x24(&out, 0, key).

Shipped scripts use it like this:

BF2: python/bf2/stats/rank.py:81
value = host.pers_getStatsKeyVal("rank")
2142: python/bf2/stats/rank.py:76
value = int( host.pers_getStatsKeyVal("rnk", player.getProfileId()) )
Heroes: python/bf2/stats/medals.py:548
xp = host.pers_getStatsKeyVal('xp', player.getProfileId())

pers_gamespyStatsSendSnapshotUpdate#

BF22142
python
host.pers_gamespyStatsSendSnapshotUpdate(snapshot)
FactDetail
Arguments (as parsed)s@0 (result unchecked)
ReturnsNone
Original codebf2_w32ded.exe!0x00532cb0, BF2.exe!0x0058f300
bf2-rscrates/bf2-server/src/hostfns.rs:1072
bf2-rs statusanswers without the backend: None (GameSpy stats SDK, not called by the retail scripts)

What it does (from the original code). (GameServer vtc(0x1d4c1) vt74) vt+0x30(snapshot).

pers_gamespyStatsSendSnapshotFinal#

BF22142
python
host.pers_gamespyStatsSendSnapshotFinal(snapshot)
FactDetail
Arguments (as parsed)s@0 (result unchecked)
ReturnsNone
Original codebf2_w32ded.exe!0x00532d30, BF2.exe!0x0058f370
bf2-rs statusanswers without the backend: None (GameSpy stats SDK, not called by the retail scripts)

What it does (from the original code). ... vt74 vt+0x34(snapshot).

pers_gamespyStatsEndGame#

BF22142
python
host.pers_gamespyStatsEndGame()
FactDetail
Arguments (as parsed)-
ReturnsNone
Original codebf2_w32ded.exe!0x00532830, BF2.exe!0x0058eed0
bf2-rscrates/bf2-server/src/hostfns.rs:1077
bf2-rs statusanswers without the backend: None (GameSpy stats SDK, not called by the retail scripts)

What it does (from the original code). ... vt74 vt+0x1c().

pers_gamespyStatsNewGame#

BF22142
python
host.pers_gamespyStatsNewGame()
FactDetail
Arguments (as parsed)-
ReturnsNone
Original codebf2_w32ded.exe!0x00532870, BF2.exe!0x0058ef10
bf2-rs statusanswers without the backend: None (GameSpy stats SDK, not called by the retail scripts)

What it does (from the original code). ... vt74 vt+0x18() (unverified offset; mirrors EndGame).

pers_plrSetRank#

2142
python
host.pers_plrSetRank(...)
FactDetail
bf2-rscrates/bf2-server/src/hostfns_2142.rs:129

What it does (from the bf2-rs port). pers_plrSetRank (bf2142ded!0x08166f60, BF2142.exe!0x00566cd0): eight argInt; a profile id below 2000 is "no such player"; else a new SetPlayerRank (the server's current persistence object, game vt+0xac) and its request (vt+0x10). pers_plrDisconnect (bf2142ded!0x08167150, BF2142.exe!0x00566e30): seven, PlayerDisconnect likewise. The answer is whether the request started.

pers_plrDisconnect#

2142
python
host.pers_plrDisconnect(...)

pers_plrGiveFieldUnlock#

2142Heroes
python
host.pers_plrGiveFieldUnlock(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c761
bf2-rscrates/bf2-server/src/hostfns_2142.rs:155

What it does (from the bf2-rs port). pers_plrGiveFieldUnlock (bf2142ded!0x081662c0) and pers_plrResetFieldUnlocks (bf2142ded!0x08166340): argInt(0), the player lookup ("no such player"), then gameLogic vt+0x68 giveFieldUnlock / vt+0x6c resetFieldUnlocks (field_unlocks_2142).

Shipped scripts use it like this:

2142: python/bf2/stats/stats.py:960
host.pers_plrGiveFieldUnlock(p.index)

pers_plrResetFieldUnlocks#

2142Heroes
python
host.pers_plrResetFieldUnlocks(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c76e

pers_getRankExperience#

2142Heroes
python
host.pers_getRankExperience(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c664
bf2-rscrates/bf2-server/src/hostfns_2142.rs:95

What it does (from the bf2-rs port). BFHeroes.exe!0x0066c664: same behaviour (the rank table DAT_011c1108's entry, 0 without it). pers_getRankExperience (0x08167310, BF2142.exe!0x00566f70): with the instance argInt(0) and RankSettings::getRank's experience; 0 for a rank it does not have or without the instance.

pers_getNumRanks#

2142Heroes
python
host.pers_getNumRanks(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c3db
bf2-rscrates/bf2-server/src/hostfns_2142.rs:84

pers_getPlayerToken#

2142Heroes
python
host.pers_getPlayerToken(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c72c
bf2-rscrates/bf2-server/src/hostfns_2142.rs:108, crates/bfh-server/src/lib.rs:504

What it does (from the bf2-rs port). pers_getPlayerToken (bf2142ded!0x08167430, BF2142.exe!0x00566ff0): argInt(0) a profile id (PlayerManager vt+0x28 getPlayerFromProfileId); that player's vt+0x330 string (Player::getGameSpyAuth bf2142ded!0x080fdd80), "" without one.

pers_getServerGUID#

2142
python
host.pers_getServerGUID(...)
FactDetail
bf2-rscrates/bf2-server/src/hostfns_2142.rs:119

What it does (from the bf2-rs port). pers_getServerGUID (bf2142ded!0x081676a0, BF2142.exe!0x00566740): the "GameSpyAuth" service's vt+0x20(0) (getServerGUID(false)).

pers_getPrestigePointsNeeded#

Heroes
python
host.pers_getPrestigePointsNeeded(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c6e1
bf2-rscrates/bfh-server/src/lib.rs:454

What it does (from the bf2-rs port). The RankSettings instance (DAT_011c1108) exists from the start-up load on, so the getters' null branch (0) is not modelled. BFHeroes.exe!0x0066c6e1: argInt(0), the level's points (0x00487419), 0 without the level.

Shipped scripts use it like this:

Heroes: python/bf2/stats/stats.py:760
prestigePointsNeeded = host.pers_getPrestigePointsNeeded(player.score.prestigeLevel)

pers_getMaxPrestigeLevel#

Heroes
python
host.pers_getMaxPrestigeLevel(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c387
bf2-rscrates/bfh-server/src/lib.rs:461

What it does (from the bf2-rs port). BFHeroes.exe!0x0066c387 -> 0x004871cb: the number of prestige levels.

Shipped scripts use it like this:

Heroes: python/bf2/stats/stats.py:769
if player.score.prestigeLevel >= host.pers_getMaxPrestigeLevel() - 1:

pers_getMaxPrestigeRotations#

Heroes
python
host.pers_getMaxPrestigeRotations(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c3bf
bf2-rscrates/bfh-server/src/lib.rs:463

What it does (from the bf2-rs port). BFHeroes.exe!0x0066c3bf -> 0x004870f9.

Shipped scripts use it like this:

Heroes: python/bf2/stats/stats.py:774
if player.score.prestigeRotation < host.pers_getMaxPrestigeRotations():

pers_getMinLevelForPrestigePoints#

Heroes
python
host.pers_getMinLevelForPrestigePoints(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c3a3
bf2-rscrates/bfh-server/src/lib.rs:465

What it does (from the bf2-rs port). BFHeroes.exe!0x0066c3a3 -> 0x00487107.

Shipped scripts use it like this:

Heroes: python/bf2/stats/stats.py:739
if player.score.rank < host.pers_getMinLevelForPrestigePoints():

pers_eloGetExpectedScore#

Heroes
python
host.pers_eloGetExpectedScore(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c3f7
bf2-rscrates/bfh-server/src/lib.rs:468

What it does (from the bf2-rs port). host.pers_eloGetExpectedScore(killerRank, victimRank) (BFHeroes.exe@bfh126!0x0069f75a): argFloat(1), then argFloat(0) unless that failed, then [elo::expected_score_native] as a Python float.

pers_eloGetKillerAdjustment#

Heroes
python
host.pers_eloGetKillerAdjustment(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c495
bf2-rscrates/bfh-server/src/lib.rs:469

What it does (from the bf2-rs port). host.pers_eloGetKillerAdjustment / pers_eloGetVictimAdjustment(rank, ownGames, otherGames) (BFHeroes.exe@bfh126!0x0069f7f7 / 0x0069f8ac): argInt(2), argInt(1), argFloat(0), each after the previous one parsed, then f as a Python float.

pers_eloGetVictimAdjustment#

Heroes
python
host.pers_eloGetVictimAdjustment(...)
FactDetail
Original codeBFHeroes.exe (1.89)!0x0066c54c
bf2-rscrates/bfh-server/src/lib.rs:470

What it does (from the bf2-rs port). host.pers_eloGetKillerAdjustment / pers_eloGetVictimAdjustment(rank, ownGames, otherGames) (BFHeroes.exe@bfh126!0x0069f7f7 / 0x0069f8ac): argInt(2), argInt(1), argFloat(0), each after the previous one parsed, then f as a Python float.

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.