Language and common lib updates

This commit is contained in:
Eric Froemling 2021-03-27 13:58:22 -07:00
parent 8abed4d461
commit 8c2c586811
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
9 changed files with 98 additions and 61 deletions

View File

@ -420,7 +420,7 @@
"assets/build/ba_data/audio/zoeOw.ogg": "https://files.ballistica.net/cache/ba1/a9/71/9286d55c45c37877f3267850f90b",
"assets/build/ba_data/audio/zoePickup01.ogg": "https://files.ballistica.net/cache/ba1/2f/09/36e691de67eb8f155449a7170861",
"assets/build/ba_data/audio/zoeScream01.ogg": "https://files.ballistica.net/cache/ba1/fd/a8/ad50785ce206e8dc3dcc7358b173",
"assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/91/b8/a48083094a02608f5dff387d3469",
"assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/71/ba/b0301976534619d1ef1256ca8334",
"assets/build/ba_data/data/languages/arabic.json": "https://files.ballistica.net/cache/ba1/ac/3e/c50dc4e98df47f858c3a73ac4272",
"assets/build/ba_data/data/languages/belarussian.json": "https://files.ballistica.net/cache/ba1/44/ed/5b972fa848cffb73723533c2ccb7",
"assets/build/ba_data/data/languages/chinese.json": "https://files.ballistica.net/cache/ba1/9d/63/d360eeff63bc64e098427498880d",
@ -435,11 +435,11 @@
"assets/build/ba_data/data/languages/german.json": "https://files.ballistica.net/cache/ba1/e5/31/88fb3898d5b35412d4f4ea5e81b2",
"assets/build/ba_data/data/languages/gibberish.json": "https://files.ballistica.net/cache/ba1/43/f3/9e88a199337b7913cb5e7961b1c6",
"assets/build/ba_data/data/languages/greek.json": "https://files.ballistica.net/cache/ba1/51/31/64479524c0ee990b3e97ffdca068",
"assets/build/ba_data/data/languages/hindi.json": "https://files.ballistica.net/cache/ba1/ed/98/37d9457755f7e86e2f2875e3b055",
"assets/build/ba_data/data/languages/hindi.json": "https://files.ballistica.net/cache/ba1/32/a4/fae7a30ead18c6cb97db60dd9445",
"assets/build/ba_data/data/languages/hungarian.json": "https://files.ballistica.net/cache/ba1/87/2d/027aa239eb66ea8f496562f4fd83",
"assets/build/ba_data/data/languages/indonesian.json": "https://files.ballistica.net/cache/ba1/69/cf/4a1e297b73613fd1b87fed8d2565",
"assets/build/ba_data/data/languages/italian.json": "https://files.ballistica.net/cache/ba1/fb/2b/4c875a40e176079dedaacf1362c7",
"assets/build/ba_data/data/languages/korean.json": "https://files.ballistica.net/cache/ba1/0a/84/bbb6ed2abf66509406f534cbbb52",
"assets/build/ba_data/data/languages/korean.json": "https://files.ballistica.net/cache/ba1/78/d3/16b37707d4ce4df826d0b0bc1766",
"assets/build/ba_data/data/languages/persian.json": "https://files.ballistica.net/cache/ba1/16/83/5a815f0e73dbac1d8cce337bff1b",
"assets/build/ba_data/data/languages/polish.json": "https://files.ballistica.net/cache/ba1/cd/c1/82bf70c3ee4894791506f4da1a15",
"assets/build/ba_data/data/languages/portuguese.json": "https://files.ballistica.net/cache/ba1/98/45/ddeb7e797c02fb967e0c8b0dff7d",
@ -3932,26 +3932,26 @@
"assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/b5/85/f8b6d0558ddb87267f34254b1450",
"assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e",
"assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f",
"build/prefab/full/linux_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b0/d7/24342e98d034071f2b7e758f6ad3",
"build/prefab/full/linux_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/15/b9/283697524fd145a82d07896cb103",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/28/55/bf5c45962c2546e3ee3ab29699a5",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/2e/55/9d88c3f8b2f81dadd71556a5f5a9",
"build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c0/58/8c56ef4020936c0b038a3e97989c",
"build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/76/c3/dc3b86bb4808f62b5cb1b52869ca",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/cf/95/f90763272edcfdeff466869b7b1b",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b3/c9/8142691865cbadfe9aa5f877ab0d",
"build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b5/c0/950b9a835cfe61e57ce3e75151e4",
"build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/93/56/582749266831fb8c4e1d2350ae39",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/72/5d/bcab78126983ce1effc042961f3a",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/22/05/369c8aeb1df2840d4196ad721d23",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/41/1e/dcc3596268cccfadbf3bdde83f96",
"build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/c4/ca/4aaa4497be67887dae3299f99bf7",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/89/e1/5767f709124f71b2ba54f5ba120f",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3c/87/19a4d5ccc73507a54911b5e0a44c",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/44/b2/129b5e75753e1a3e540d5ec6147b",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/5d/71/0e16a0cbbe894122b34a7ea90547",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/25/4b/ff892aed0e05ef23f2d63b4356ba",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/f3/de/5d8129e6c294ec8390067688f401",
"build/prefab/full/linux_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/6f/17/74c8bd726bd901195fdae8dd0fbe",
"build/prefab/full/linux_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/32/ba/c77d623353db193c44ba0978022b",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/70/fe/9d2421a2c17a1b0ad26762d34748",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ac/14/b202360bb5742b878a0f34cd62fa",
"build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/20/37/0ad1019b02fd6e485714d7392a98",
"build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/4c/48/2bffaaeec82f2d42bcdd0cb87d6d",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d7/94/d6bb4566373ef89dd51c864528c6",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1d/6e/d58e1ad047234e4cb35f24e728a2",
"build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/85/e7/e9ae4f1b4348a76732c9767e204d",
"build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/d2/3d/3f3e077b232061d9a02dadff54c2",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d0/67/d8e96765ab46bfcca09b3c945a07",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/82/0d/164affb9fa291c1421354814c6f0",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/be/98/8d9b0c00c2ed6e0cc3c357e453b7",
"build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/77/f7/06724fd59b21eacda722deca592f",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0b/5f/90f47f7537d2044e23b0b351790f",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/13/a6/a81408bf7335ff367383d212b973",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/0f/6e/048445f26896d22b02438900f84b",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/1f/68/5d143b4819d6c0ca5758fb3712ed",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/fa/ab/f2528d3865a55feeae68681b7088",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/83/8d/d6b300ffb0c945d322a1fea0163a",
"build/prefab/lib/linux_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8c/39/85f77a12d141db9af737df376913",
"build/prefab/lib/linux_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a1/a1/3b82daf3a84bfaf3d64d166cac3a",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7a/fc/38e48816e9d9cd64baebbb30deb6",
@ -3960,12 +3960,12 @@
"build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/02/49/3b28ad61d548c23e6780c4f88bed",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/07/99/9f5c09f44372348c267fb39ddd05",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/63/83/0ffe340483547e20baa8fd1293b9",
"build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a5/a1/ca42c662cac3c6285cbcc2c7885b",
"build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e6/b3/91da761495aa2303d1b0e5b02094",
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1b/f2/b4eb460cee9f2e75c94c61dd0e24",
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/52/ff/637bbb859b4ccc73f34f7a77903f",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7c/78/c981aaec70ca0072587506509c62",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/33/96/d1755c352b6cbf7921e145f651e7",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/64/0f/b4560263bce797949caa824d11cd",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/50/16/62b4e23c92d31a053913f450a302"
"build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f1/4d/fbb63516eef0a36459b38b776c34",
"build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a2/f6/b0998583e32973b9b659dbc8f2bd",
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d9/9a/4690381fc373a68470013d97d3c4",
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3b/3c/92242a26cfaa8f547eab85021cd3",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/19/a5/8c64f85edf99d26a34b981b8ec53",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/52/22/b150364818dcae27ff224efd88d8",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/14/4b/112f8e404f89afe1881afd97f6c7",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/30/dd/47705c9acb255bec5a1bb3641183"
}

View File

@ -252,6 +252,7 @@
<w>btnv</w>
<w>btnx</w>
<w>btype</w>
<w>bucketnum</w>
<w>buildblessing</w>
<w>buildblessingcheck</w>
<w>builddir</w>
@ -2050,6 +2051,7 @@
<w>strippable</w>
<w>strobing</w>
<w>strptime</w>
<w>strs</w>
<w>strt</w>
<w>strval</w>
<w>subargs</w>

View File

@ -119,6 +119,7 @@
<w>bstat</w>
<w>bsuuid</w>
<w>btnlabel</w>
<w>bucketnum</w>
<w>bufs</w>
<w>buildconfig</w>
<w>buildnumber</w>
@ -892,6 +893,7 @@
<w>strdup</w>
<w>stringi</w>
<w>strlen</w>
<w>strs</w>
<w>strtof</w>
<w>subargs</w>
<w>subclsssing</w>

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2021-03-19 for Ballistica version 1.6.0 build 20324</em></h4>
<h4><em>last updated on 2021-03-27 for Ballistica version 1.6.0 build 20328</em></h4>
<p>This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
<hr>

View File

@ -21,7 +21,7 @@
namespace ballistica {
// These are set automatically via script; don't change here.
const int kAppBuildNumber = 20327;
const int kAppBuildNumber = 20328;
const char* kAppVersion = "1.6.0";
// Our standalone globals.

View File

@ -339,17 +339,17 @@ class Utils {
// Simple lists of pre-calculated random values between 0 and 1
// (with no particular distribution)
static float precalc_rand_1(int index) {
static float precalc_rand_1(int64_t index) {
assert(index >= 0);
assert(index < kPrecalcRandsCount);
return precalc_rands_1_[index];
}
static float precalc_rand_2(int index) {
static float precalc_rand_2(int64_t index) {
assert(index >= 0);
assert(index < kPrecalcRandsCount);
return precalc_rands_2_[index];
}
static float precalc_rand_3(int index) {
static float precalc_rand_3(int64_t index) {
assert(index >= 0);
assert(index < kPrecalcRandsCount);
return precalc_rands_3_[index];

View File

@ -141,8 +141,11 @@ def test_entity_values() -> None:
# And set with incorrect value type should do same.
with pytest.raises(TypeError):
ent.enum_int_dict[EnumTest.FIRST] = 'bar' # type: ignore
# Make sure is stored as underlying type.
assert ent.d_data['ed'] == {0: 234}
# Make sure is stored as underlying type (though we convert ints to strs).
assert ent.d_data['ed'] == {'0': 234}
# Make sure assignment as dict works correctly with enum keys.
ent.enum_int_dict = {EnumTest.FIRST: 235}
assert ent.enum_int_dict[EnumTest.FIRST] == 235
# Make sure invalid raw enum values are caught.
ent2 = EntityTest()
@ -221,7 +224,11 @@ def test_entity_values_2() -> None:
ent.compounddict4[0].isubval = 222 # type: ignore
assert static_type_equals(ent.compounddict4[EnumTest.FIRST], CompoundTest)
# Make sure enum keys are stored as underlying type.
assert ent.d_data['td4'] == {0: {'i': 222, 'l': []}}
# (though with ints converted to strs)
assert ent.d_data['td4'] == {'0': {'i': 222, 'l': []}}
# Make sure assignment as dict works correctly with enum keys.
ent.compounddict4 = {EnumTest.SECOND: ent.compounddict4[EnumTest.FIRST]}
assert ent.compounddict4[EnumTest.SECOND].isubval == 222
# Optional Enum value
ent.enumval2 = None

View File

@ -7,6 +7,8 @@ from __future__ import annotations
from enum import Enum
from typing import TYPE_CHECKING
from efro.util import enum_by_value
if TYPE_CHECKING:
from typing import Any, Type
@ -17,14 +19,24 @@ def dict_key_to_raw(key: Any, keytype: Type) -> Any:
raise TypeError(
f'Invalid key type; expected {keytype}, got {type(key)}.')
if issubclass(keytype, Enum):
return key.value
val = key.value
# We convert int enums to string since that is what firestore supports.
if isinstance(val, int):
val = str(val)
return val
return key
def dict_key_from_raw(key: Any, keytype: Type) -> Any:
"""Given internal key, filter to world visible type."""
if issubclass(keytype, Enum):
return keytype(key)
# We store all enum keys as strings; if the enum uses
# int keys, convert back.
for enumval in keytype:
if isinstance(enumval.value, int):
return enum_by_value(keytype, int(key))
break
return enum_by_value(keytype, key)
return key

View File

@ -9,8 +9,8 @@ import logging
from enum import Enum
from typing import TYPE_CHECKING, Generic, TypeVar, overload
from efro.util import enum_by_value
from efro.entity._base import BaseField
# from efro.util import enum_by_value
from efro.entity._base import BaseField, dict_key_to_raw, dict_key_from_raw
from efro.entity._support import (BoundCompoundValue, BoundListField,
BoundDictField, BoundCompoundListField,
BoundCompoundDictField)
@ -250,15 +250,22 @@ class DictField(BaseField, Generic[TK, T]):
# For enum keys, make sure its a valid enum.
if issubclass(self._keytype, Enum):
try:
_enumval = enum_by_value(self._keytype, key)
except Exception as exc:
if error:
raise ValueError(f'No enum of type {self._keytype}'
f' exists with value {key}') from exc
logging.error('Ignoring invalid key type for %s: %s', self,
data)
continue
# Our input data can either be an enum or the underlying type.
if isinstance(key, self._keytype):
key = dict_key_to_raw(key, self._keytype)
# key = key.value
else:
try:
_enumval = dict_key_from_raw(key, self._keytype)
# _enumval = enum_by_value(self._keytype, key)
except Exception as exc:
if error:
raise ValueError(
f'No enum of type {self._keytype}'
f' exists with value {key}') from exc
logging.error('Ignoring invalid key type for %s: %s',
self, data)
continue
# For all other keys we can check for exact types.
elif not isinstance(key, self._keytype):
@ -466,15 +473,22 @@ class CompoundDictField(BaseField, Generic[TK, TC]):
# For enum keys, make sure its a valid enum.
if issubclass(self.d_keytype, Enum):
try:
_enumval = enum_by_value(self.d_keytype, key)
except Exception as exc:
if error:
raise ValueError(f'No enum of type {self.d_keytype}'
f' exists with value {key}') from exc
logging.error('Ignoring invalid key type for %s: %s', self,
data)
continue
# Our input data can either be an enum or the underlying type.
if isinstance(key, self.d_keytype):
key = dict_key_to_raw(key, self.d_keytype)
# key = key.value
else:
try:
_enumval = dict_key_from_raw(key, self.d_keytype)
# _enumval = enum_by_value(self.d_keytype, key)
except Exception as exc:
if error:
raise ValueError(
f'No enum of type {self.d_keytype}'
f' exists with value {key}') from exc
logging.error('Ignoring invalid key type for %s: %s',
self, data)
continue
# For all other keys we can check for exact types.
elif not isinstance(key, self.d_keytype):