mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-21 11:59:37 -06:00
Compare commits
12 Commits
fixDestCom
...
better-bit
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d874d5157 | |||
| 0dc4ad6a17 | |||
| 043d7366d7 | |||
| 6dfd5ca933 | |||
| 50ac686b7f | |||
| f10e45a2dd | |||
| 612d0d6a56 | |||
| 845e499510 | |||
| 7a0b245cb5 | |||
| 5c4a174691 | |||
| 820d7f7093 | |||
| e145d237e4 |
@@ -1,5 +1,5 @@
|
||||
PROJECT_VERSION_MAJOR=1
|
||||
PROJECT_VERSION_MINOR=1
|
||||
PROJECT_VERSION_MINOR=0
|
||||
PROJECT_VERSION_PATCH=1
|
||||
# LICENSE
|
||||
LICENSE=AGPL-3.0
|
||||
@@ -18,5 +18,3 @@ __maria_db_connector_compile_jobs__=1
|
||||
__enable_testing__=1
|
||||
# The path to OpenSSL. Change this if your OpenSSL install path is different than the default.
|
||||
OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3/
|
||||
# Uncomment the below line to cache the entire CDClient into memory
|
||||
# CDCLIENT_CACHE_ALL=1
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
components = {
|
||||
'COMPONENT_TYPE_CONTROLLABLE_PHYSICS': 1,
|
||||
'COMPONENT_TYPE_RENDER': 2,
|
||||
'COMPONENT_TYPE_SIMPLE_PHYSICS': 3,
|
||||
'COMPONENT_TYPE_CHARACTER': 4,
|
||||
'COMPONENT_TYPE_SCRIPT': 5,
|
||||
'COMPONENT_TYPE_BOUNCER': 6,
|
||||
'COMPONENT_TYPE_DESTROYABLE': 7,
|
||||
'COMPONENT_TYPE_GHOST': 8,
|
||||
'COMPONENT_TYPE_SKILL': 9,
|
||||
'COMPONENT_TYPE_SPAWNER': 10,
|
||||
'COMPONENT_TYPE_ITEM': 11,
|
||||
'COMPONENT_TYPE_MODULAR_BUILD': 12,
|
||||
'COMPONENT_TYPE_BUILD_CONTROLLER': 13,
|
||||
'COMPONENT_TYPE_REBUILD_ACTIVATOR': 14,
|
||||
'COMPONENT_TYPE_ICON_ONLY': 15,
|
||||
'COMPONENT_TYPE_VENDOR': 16,
|
||||
'COMPONENT_TYPE_INVENTORY': 17,
|
||||
'COMPONENT_TYPE_PROJECTILE_PHYSICS': 18,
|
||||
'COMPONENT_TYPE_SHOOTING_GALLERY': 19,
|
||||
'COMPONENT_TYPE_RIGID_BODY_PHANTOM_PHYSICS': 20,
|
||||
'COMPONENT_TYPE_DROP_EFFECT': 21,
|
||||
'COMPONENT_TYPE_CHEST': 22,
|
||||
'COMPONENT_TYPE_COLLECTIBLE': 23,
|
||||
'COMPONENT_TYPE_BLUEPRINT': 24,
|
||||
'COMPONENT_TYPE_MOVING_PLATFORM': 25,
|
||||
'COMPONENT_TYPE_PET': 26,
|
||||
'COMPONENT_TYPE_PLATFORM_BOUNDARY': 27,
|
||||
'COMPONENT_TYPE_MODULE': 28,
|
||||
'COMPONENT_TYPE_ARCADE': 29,
|
||||
'COMPONENT_TYPE_HAVOK_VEHICLE_PHYSICS': 30,
|
||||
'COMPONENT_TYPE_MOVEMENT_AI': 31,
|
||||
'COMPONENT_TYPE_EXHIBIT': 32,
|
||||
'COMPONENT_TYPE_OVERHEAD_ICON': 33,
|
||||
'COMPONENT_TYPE_PET_CONTROL': 34,
|
||||
'COMPONENT_TYPE_MINIFIG': 35,
|
||||
'COMPONENT_TYPE_PROPERTY': 36,
|
||||
'COMPONENT_TYPE_PET_CREATOR': 37,
|
||||
'COMPONENT_TYPE_MODEL_BUILDER': 38,
|
||||
'COMPONENT_TYPE_SCRIPTED_ACTIVITY': 39,
|
||||
'COMPONENT_TYPE_PHANTOM_PHYSICS': 40,
|
||||
'COMPONENT_TYPE_SPRING_PAD': 41,
|
||||
'COMPONENT_TYPE_MODEL': 42,
|
||||
'COMPONENT_TYPE_PROPERTY_ENTRANCE': 43,
|
||||
'COMPONENT_TYPE_FX': 44,
|
||||
'COMPONENT_TYPE_PROPERTY_MANAGEMENT': 45,
|
||||
'COMPONENT_TYPE_VEHICLE_PHYSICS': 46,
|
||||
'COMPONENT_TYPE_PHYSICS_SYSTEM': 47,
|
||||
'COMPONENT_TYPE_REBUILD': 48,
|
||||
'COMPONENT_TYPE_SWITCH': 49,
|
||||
'COMPONENT_TYPE_ZONE_CONTROL': 50,
|
||||
'COMPONENT_TYPE_CHANGELING': 51,
|
||||
'COMPONENT_TYPE_CHOICE_BUILD': 52,
|
||||
'COMPONENT_TYPE_PACKAGE': 53,
|
||||
'COMPONENT_TYPE_SOUND_REPEATER': 54,
|
||||
'COMPONENT_TYPE_SOUND_AMBIENT_2D': 55,
|
||||
'COMPONENT_TYPE_SOUND_AMBIENT_3D': 56,
|
||||
'COMPONENT_TYPE_PRECONDITION': 57,
|
||||
'COMPONENT_TYPE_PLAYER_FLAG': 58,
|
||||
'COMPONENT_TYPE_CUSTOM_BUILD_ASSEMBLY': 59,
|
||||
'COMPONENT_TYPE_BASE_COMBAT_AI': 60,
|
||||
'COMPONENT_TYPE_MODULE_ASSEMBLY': 61,
|
||||
'COMPONENT_TYPE_SHOWCASE_MODEL_HANDLER': 62,
|
||||
'COMPONENT_TYPE_RACING_MODULE': 63,
|
||||
'COMPONENT_TYPE_GENERIC_ACTIVATOR': 64,
|
||||
'COMPONENT_TYPE_PROPERTY_VENDOR': 65,
|
||||
'COMPONENT_TYPE_HF_LIGHT_DIRECTION_GADGET': 66,
|
||||
'COMPONENT_TYPE_ROCKET_LAUNCH': 67,
|
||||
'COMPONENT_TYPE_ROCKET_LANDING_COMPONENT': 68,
|
||||
'COMPONENT_TYPE_TRIGGER': 69,
|
||||
'COMPONENT_TYPE_DROPPED_LOOT': 70,
|
||||
'COMPONENT_TYPE_RACING_CONTROL': 71,
|
||||
'COMPONENT_TYPE_FACTION_TRIGGER': 72,
|
||||
'COMPONENT_TYPE_MISSION_OFFER': 73,
|
||||
'COMPONENT_TYPE_RACING_STATS': 74,
|
||||
'COMPONENT_TYPE_LUP_EXHIBIT': 75,
|
||||
'COMPONENT_TYPE_BBB': 76,
|
||||
'COMPONENT_TYPE_SOUND_TRIGGER': 77,
|
||||
'COMPONENT_TYPE_PROXIMITY_MONITOR': 78,
|
||||
'COMPONENT_TYPE_RACING_SOUND_TRIGGER': 79,
|
||||
'COMPONENT_TYPE_CHAT': 80,
|
||||
'COMPONENT_TYPE_FRIENDS_LIST': 81,
|
||||
'COMPONENT_TYPE_GUILD': 82,
|
||||
'COMPONENT_TYPE_LOCAL_SYSTEM': 83,
|
||||
'COMPONENT_TYPE_MISSION': 84,
|
||||
'COMPONENT_TYPE_MUTUABLE_MODEL_BEHAVIORS': 85,
|
||||
'COMPONENT_TYPE_PATHFINDING_CONTROL': 86,
|
||||
'COMPONENT_TYPE_PLAYER_PET_TAMING': 87,
|
||||
'COMPONENT_TYPE_PROPERTY_EDITOR': 88,
|
||||
'COMPONENT_TYPE_SKINNED_RENDER': 89,
|
||||
'COMPONENT_TYPE_SLASH_COMMAND': 90,
|
||||
'COMPONENT_TYPE_STATUS_EFFECT': 91,
|
||||
'COMPONENT_TYPE_TEAMS': 92,
|
||||
'COMPONENT_TYPE_TEXT_EFFECT': 93,
|
||||
'COMPONENT_TYPE_TRADE': 94,
|
||||
'COMPONENT_TYPE_USER_CONTROL': 95,
|
||||
'COMPONENT_TYPE_IGNORE_LIST': 96,
|
||||
'COMPONENT_TYPE_ROCKET_LAUNCH_LUP': 97,
|
||||
'COMPONENT_TYPE_BUFF': 98,
|
||||
'COMPONENT_TYPE_INTERACTION_MANAGER': 99,
|
||||
'COMPONENT_TYPE_DONATION_VENDOR': 100,
|
||||
'COMPONENT_TYPE_COMBAT_MEDIATOR': 101,
|
||||
'COMPONENT_TYPE_ACHIEVEMENT_VENDOR': 102,
|
||||
'COMPONENT_TYPE_GATE_RUSH': 103,
|
||||
'COMPONENT_TYPE_RAIL_ACTIVATOR': 104,
|
||||
'COMPONENT_TYPE_ROLLER': 105,
|
||||
'COMPONENT_TYPE_PLAYER_FORCED_MOVEMENT': 106,
|
||||
'COMPONENT_TYPE_CRAFTING': 107,
|
||||
'COMPONENT_TYPE_POSSESSABLE': 108,
|
||||
'COMPONENT_TYPE_LEVEL_PROGRESSION': 109,
|
||||
'COMPONENT_TYPE_POSSESSOR': 110,
|
||||
'COMPONENT_TYPE_MOUNT_CONTROL': 111,
|
||||
'UNKNOWN_112': 112,
|
||||
'COMPONENT_TYPE_PROPERTY_PLAQUE': 113,
|
||||
'COMPONENT_TYPE_BUILD_BORDER': 114,
|
||||
'UNKNOWN_115': 115,
|
||||
'COMPONENT_TYPE_CULLING_PLANE': 116,
|
||||
'INVALID': 4294967295
|
||||
}
|
||||
|
||||
component_initialization_order = [
|
||||
'COMPONENT_TYPE_POSSESSABLE',
|
||||
'COMPONENT_TYPE_BLUEPRINT',
|
||||
'COMPONENT_TYPE_MODULE_ASSEMBLY',
|
||||
'COMPONENT_TYPE_CONTROLLABLE_PHYSICS',
|
||||
'COMPONENT_TYPE_PROJECTILE_PHYSICS',
|
||||
'COMPONENT_TYPE_PHYSICS_SYSTEM',
|
||||
'COMPONENT_TYPE_VEHICLE_PHYSICS',
|
||||
'COMPONENT_TYPE_HAVOK_VEHICLE_PHYSICS',
|
||||
'COMPONENT_TYPE_RIGID_BODY_PHANTOM_PHYSICS',
|
||||
'COMPONENT_TYPE_SIMPLE_PHYSICS',
|
||||
'COMPONENT_TYPE_PHANTOM_PHYSICS',
|
||||
'COMPONENT_TYPE_DESTROYABLE',
|
||||
'COMPONENT_TYPE_MINIFIG',
|
||||
'COMPONENT_TYPE_CHARACTER',
|
||||
'COMPONENT_TYPE_PLAYER_FORCED_MOVEMENT',
|
||||
'COMPONENT_TYPE_POSSESSOR',
|
||||
'COMPONENT_TYPE_MOUNT_CONTROL',
|
||||
'COMPONENT_TYPE_PET',
|
||||
'COMPONENT_TYPE_INVENTORY',
|
||||
'COMPONENT_TYPE_PROXIMITY_MONITOR',
|
||||
'COMPONENT_TYPE_MOVEMENT_AI',
|
||||
'COMPONENT_TYPE_SCRIPT',
|
||||
'COMPONENT_TYPE_SKILL',
|
||||
'COMPONENT_TYPE_BASE_COMBAT_AI',
|
||||
'COMPONENT_TYPE_SPAWNER',
|
||||
'COMPONENT_TYPE_ITEM',
|
||||
'COMPONENT_TYPE_REBUILD',
|
||||
'COMPONENT_TYPE_BUILD_BORDER',
|
||||
'COMPONENT_TYPE_MODULE',
|
||||
'COMPONENT_TYPE_BUILD_CONTROLLER',
|
||||
'COMPONENT_TYPE_REBUILD_ACTIVATOR',
|
||||
'COMPONENT_TYPE_MODULAR_BUILD',
|
||||
'COMPONENT_TYPE_MISSION_OFFER',
|
||||
'COMPONENT_TYPE_VENDOR',
|
||||
'COMPONENT_TYPE_DONATION_VENDOR',
|
||||
'COMPONENT_TYPE_ACHIEVEMENT_VENDOR',
|
||||
'COMPONENT_TYPE_SHOOTING_GALLERY',
|
||||
'COMPONENT_TYPE_ROLLER',
|
||||
'COMPONENT_TYPE_SCRIPTED_ACTIVITY',
|
||||
'COMPONENT_TYPE_COLLECTIBLE',
|
||||
'COMPONENT_TYPE_MOVING_PLATFORM',
|
||||
'COMPONENT_TYPE_CHANGELING',
|
||||
'COMPONENT_TYPE_CHOICE_BUILD',
|
||||
'COMPONENT_TYPE_PACKAGE',
|
||||
'COMPONENT_TYPE_PLATFORM_BOUNDARY',
|
||||
'COMPONENT_TYPE_HF_LIGHT_DIRECTION_GADGET',
|
||||
'COMPONENT_TYPE_CULLING_PLANE',
|
||||
'COMPONENT_TYPE_EXHIBIT',
|
||||
'COMPONENT_TYPE_LUP_EXHIBIT',
|
||||
'COMPONENT_TYPE_PROPERTY',
|
||||
'COMPONENT_TYPE_PROPERTY_PLAQUE',
|
||||
'COMPONENT_TYPE_MODEL',
|
||||
'COMPONENT_TYPE_PROPERTY_ENTRANCE',
|
||||
'COMPONENT_TYPE_ROCKET_LAUNCH_LUP',
|
||||
'COMPONENT_TYPE_PROPERTY_MANAGEMENT',
|
||||
'COMPONENT_TYPE_RAIL_ACTIVATOR',
|
||||
'COMPONENT_TYPE_BOUNCER',
|
||||
'COMPONENT_TYPE_SPRING_PAD',
|
||||
'COMPONENT_TYPE_SWITCH',
|
||||
'COMPONENT_TYPE_ZONE_CONTROL',
|
||||
'COMPONENT_TYPE_MODEL_BUILDER',
|
||||
'COMPONENT_TYPE_SOUND_REPEATER',
|
||||
'COMPONENT_TYPE_CHEST',
|
||||
'COMPONENT_TYPE_SHOWCASE_MODEL_HANDLER',
|
||||
'COMPONENT_TYPE_ARCADE',
|
||||
'COMPONENT_TYPE_RENDER',
|
||||
'COMPONENT_TYPE_SOUND_AMBIENT_2D',
|
||||
'COMPONENT_TYPE_SOUND_AMBIENT_3D',
|
||||
'COMPONENT_TYPE_SOUND_TRIGGER',
|
||||
'COMPONENT_TYPE_RACING_SOUND_TRIGGER',
|
||||
'COMPONENT_TYPE_CUSTOM_BUILD_ASSEMBLY',
|
||||
'COMPONENT_TYPE_GENERIC_ACTIVATOR',
|
||||
'COMPONENT_TYPE_PROPERTY_VENDOR',
|
||||
'COMPONENT_TYPE_ROCKET_LAUNCH',
|
||||
'COMPONENT_TYPE_ROCKET_LANDING_COMPONENT',
|
||||
'COMPONENT_TYPE_FACTION_TRIGGER',
|
||||
'COMPONENT_TYPE_RACING_CONTROL',
|
||||
'COMPONENT_TYPE_GATE_RUSH',
|
||||
'COMPONENT_TYPE_BBB',
|
||||
'COMPONENT_TYPE_CRAFTING'
|
||||
]
|
||||
component_order_as_ints = {}
|
||||
|
||||
component_int_to_name = {}
|
||||
|
||||
for component in component_initialization_order:
|
||||
component_order_as_ints[components[component]] = component
|
||||
|
||||
for component in components:
|
||||
component_int_to_name[components[component]] = component
|
||||
|
||||
class GameObject:
|
||||
type = ""
|
||||
|
||||
class ObjectLoadState:
|
||||
createdGameObject = GameObject()
|
||||
components = []
|
||||
hasPhysicsComponent = False
|
||||
hasDestroyable = False
|
||||
hasPathfindingComponent = False
|
||||
hasProximityMonitorComponent = False
|
||||
hasScriptComponent = False
|
||||
hasDroppedLootComponent = False
|
||||
hasModelbehaviors = False
|
||||
somethingOrNothing = False
|
||||
physicsComponentId = -1
|
||||
|
||||
# Begin custom attributes
|
||||
serializedOrder = []
|
||||
hasMissionOffer = False
|
||||
|
||||
class NiPoint3:
|
||||
x = 0.0
|
||||
y = 0.0
|
||||
z = 0.0
|
||||
|
||||
class NiQuaternion:
|
||||
w = 0.0
|
||||
x = 0.0
|
||||
y = 0.0
|
||||
z = 0.0
|
||||
|
||||
class LoadObject:
|
||||
objId = 0
|
||||
owner = 0
|
||||
lotToSpawn = 0
|
||||
isLocalPlayer = False
|
||||
hasDropEffect = False
|
||||
bIsSmashable = False
|
||||
dynamicPhysics = False
|
||||
spawnPosition = NiPoint3()
|
||||
spawnRotation = NiQuaternion()
|
||||
scale = 0.0
|
||||
legoBrickID = 0
|
||||
legoColorID = 0
|
||||
configData = {}
|
||||
isHFPaletteObject = False
|
||||
objType = 0
|
||||
useSimplePhysics = False
|
||||
bDelayedLoad = False
|
||||
|
||||
# Don't know the name yet of this
|
||||
field8_0x20 = True
|
||||
@@ -1,408 +0,0 @@
|
||||
import ComponentDefinitions as cd
|
||||
|
||||
def ApplyComponentWhitelist():
|
||||
# Dont care to actually do this, just want the call for now.
|
||||
pass
|
||||
|
||||
def ControllablePhysFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if not objectLoadState.hasModelbehaviors:
|
||||
if not loadObject.hasDropEffect:
|
||||
if not loadObject.useSimplePhysics:
|
||||
objectLoadState.components.append('CONTROLLABLE_PHYSICS')
|
||||
else:
|
||||
objectLoadState.components.append('SIMPLE_PHYSICS')
|
||||
else:
|
||||
loadObject.physicsComponentId = componentId
|
||||
|
||||
def RenderFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if loadObject.lotToSpawn == 176:
|
||||
return
|
||||
gmlevel = loadObject.configData.get('gmlevel', 0)
|
||||
if gmlevel > 0 and gmlevel < 6:
|
||||
componentId = 9940 # Override the componentId of the render component to be 9940, the Mythran Render Component
|
||||
renderDisabled = loadObject.configData.get('renderDisabled', False)
|
||||
if renderDisabled:
|
||||
return
|
||||
if objectLoadState.createdGameObject.type == 'BlockingVolume':
|
||||
return
|
||||
rejectedLots = [5937, 5938, 9741, 9742, 9862, 9863]
|
||||
if loadObject.lotToSpawn in rejectedLots:
|
||||
return
|
||||
if loadObject.lotToSpawn == 6368:
|
||||
FxFactory(loadObject, objectLoadState, componentId)
|
||||
return
|
||||
FxFactory(loadObject, objectLoadState, componentId)
|
||||
defaultWrapperAsset = ""
|
||||
hasNifAsset = False
|
||||
hasKfmAsset = False
|
||||
allowRenderWrapping = False
|
||||
nifName = loadObject.configData.get('nif_name', '')
|
||||
if nifName == '':
|
||||
print('TODO query cdc for this data in the Render component')
|
||||
nifName = 'mesh/something.nif' # if empty get nifname as the render_asset column of the RenderComponent table from the database
|
||||
if nifName[-1] == 'f':
|
||||
hasNifAsset = True
|
||||
elif nifName[-1] == 'm':
|
||||
hasKfmAsset = True
|
||||
if defaultWrapperAsset != '':
|
||||
if defaultWrapperAsset[-1] == 'm':
|
||||
allowRenderWrapping = not loadObject.configData.get('preventRenderWrapping', False)
|
||||
if allowRenderWrapping or hasKfmAsset or (not defaultWrapperAsset == 'PrimitiveModels' and not hasNifAsset and not loadObject.configData.get('CreateNULLRender', False)):
|
||||
objectLoadState.components.append('SKINNED_RENDER')
|
||||
else:
|
||||
objectLoadState.components.append('RENDER')
|
||||
|
||||
def FxFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('FX')
|
||||
|
||||
def SimplePhysFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if not objectLoadState.hasModelbehaviors:
|
||||
objectLoadState.physicsComponentId = componentId
|
||||
return
|
||||
if not loadObject.hasDropEffect:
|
||||
return
|
||||
markedAsPhantom = loadObject.configData.get('markedAsPhantom', False)
|
||||
if markedAsPhantom:
|
||||
objectLoadState.components.append('PHANTOM_PHYSICS')
|
||||
else:
|
||||
objectLoadState.components.append('SIMPLE_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
|
||||
def CharacterFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('POSSESSOR')
|
||||
objectLoadState.components.append('MOUNT_CONTROL')
|
||||
objectLoadState.components.append('PET_CREATOR')
|
||||
objectLoadState.components.append('LEVEL_PROGRESSION')
|
||||
objectLoadState.components.append('PLAYER_FORCED_MOVEMENT')
|
||||
objectLoadState.components.append('CHARACTER')
|
||||
|
||||
def ScriptFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int, add_pathfinding_control: bool):
|
||||
custom_script_client = loadObject.configData.get('custom_script_client', '')
|
||||
custom_script_server = loadObject.configData.get('custom_script_server', '')
|
||||
if componentId == 0 and custom_script_client == '' and custom_script_server == '':
|
||||
return
|
||||
objectLoadState.components.append('SCRIPT')
|
||||
|
||||
if not objectLoadState.hasProximityMonitorComponent:
|
||||
objectLoadState.components.append('PROXIMITY_MONITOR')
|
||||
objectLoadState.hasProximityMonitorComponent = True
|
||||
|
||||
if not objectLoadState.hasPathfindingComponent and add_pathfinding_control:
|
||||
objectLoadState.components.append('PATHFINDING_CONTROL')
|
||||
objectLoadState.hasPathfindingComponent = True
|
||||
|
||||
def BouncerFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('BOUNCER')
|
||||
|
||||
def DestroyableFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('STATUS_EFFECT')
|
||||
objectLoadState.components.append('BUFF')
|
||||
objectLoadState.components.append('DESTROYABLE')
|
||||
objectLoadState.hasDestroyable = True
|
||||
|
||||
def SkillFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SKILL')
|
||||
|
||||
def SpawnerFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SPAWNER')
|
||||
# If game state is happy flower
|
||||
spawntemplate = loadObject.configData.get('spawntemplate', '')
|
||||
|
||||
print('TODO query cdc for this data in the Spawner component')
|
||||
render_asset = loadObject.configData.get('render_asset', 'test.nif') # Get this from RenderComponent table
|
||||
render_id = loadObject.configData.get('render_id', '') # Get this from RenderComponent table
|
||||
|
||||
if render_asset[-1] == 'f':
|
||||
objectLoadState.components.append('SKINNED_RENDER')
|
||||
else:
|
||||
objectLoadState.components.append('RENDER')
|
||||
|
||||
def ItemFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('ITEM')
|
||||
|
||||
def ModularBuildFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('MODULAR_BUILD')
|
||||
|
||||
def BuildControllerFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('BUILD_CONTROLLER')
|
||||
|
||||
def VendorFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if not objectLoadState.hasProximityMonitorComponent:
|
||||
objectLoadState.components.append('PROXIMITY_MONITOR')
|
||||
objectLoadState.hasProximityMonitorComponent = True
|
||||
objectLoadState.components.append('VENDOR')
|
||||
|
||||
def InventoryFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('INVENTORY')
|
||||
|
||||
def ProjectilePhysicsFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if not loadObject.hasDropEffect:
|
||||
objectLoadState.components.append('PROJECTILE_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
|
||||
def ShootingGalleryFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SHOOTING_GALLERY')
|
||||
|
||||
def RigibBodyPhantomPhysicsFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('RIGID_BODY_PHANTOM_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
|
||||
def ChestFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('CHEST')
|
||||
|
||||
def CollectibleFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('COLLECTIBLE')
|
||||
if not objectLoadState.hasDestroyable:
|
||||
objectLoadState.components.append('DESTROYABLE')
|
||||
objectLoadState.hasDestroyable = True
|
||||
|
||||
def BlueprintFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('BLUEPRINT')
|
||||
|
||||
def MovingPlatformFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('MOVING_PLATFORM')
|
||||
|
||||
def PetFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
inInventory = loadObject.configData.get('inInventory', False)
|
||||
if inInventory:
|
||||
return
|
||||
|
||||
if not objectLoadState.hasPathfindingComponent:
|
||||
objectLoadState.components.append('PATHFINDING_CONTROL')
|
||||
objectLoadState.hasPathfindingComponent = True
|
||||
objectLoadState.components.append('PET')
|
||||
|
||||
def PlatformBoundaryFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('PLATFORM_BOUNDARY')
|
||||
|
||||
def ModuleFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('MODULE')
|
||||
|
||||
def ArcadeFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('ARCADE')
|
||||
|
||||
def HavokVehiclePhysicsFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
use_simple_physics = loadObject.configData.get('use_simple_physics', False)
|
||||
if use_simple_physics:
|
||||
objectLoadState.components.append('SIMPLE_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
else:
|
||||
objectWorldState = loadObject.configData.get('objectWorldState', '')
|
||||
if objectWorldState == 0 or objectWorldState != 2:
|
||||
objectLoadState.components.append('HAVOK_VEHICLE_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
|
||||
def MovementAiFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('MOVEMENT_AI')
|
||||
|
||||
def ExhibitFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
# Sorry aron, doesnt do anything :(
|
||||
pass
|
||||
|
||||
def MinifigFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('MINIFIG')
|
||||
|
||||
def PropertyFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('PROPERTY')
|
||||
|
||||
def ModelBuilderFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('MODEL_BUILDER')
|
||||
|
||||
def ScriptedActivityFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SCRIPTED_ACTIVITY')
|
||||
|
||||
def PhantomPhysicsFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if not loadObject.hasDropEffect:
|
||||
objectLoadState.components.append('PHANTOM_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
|
||||
def SpringPadFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SPRING_PAD')
|
||||
|
||||
def ModelFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
modelType = loadObject.configData.get('modelType', 0)
|
||||
if not objectLoadState.hasModelbehaviors:
|
||||
if not objectLoadState.hasPhysicsComponent:
|
||||
objectLoadState.components.append('SIMPLE_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
elif not objectLoadState.hasPhysicsComponent:
|
||||
if modelType == 0:
|
||||
objectLoadState.components.append('CONTROLLABLE_PHYSICS')
|
||||
else:
|
||||
objectLoadState.components.append('SIMPLE_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
if modelType != 0 and not objectLoadState.hasPathfindingComponent:
|
||||
objectLoadState.components.append('PATHFINDING_CONTROL')
|
||||
objectLoadState.hasPathfindingComponent = True
|
||||
|
||||
hasPropertyObjectID = loadObject.configData.get('propertyObjectID', 0) != 0
|
||||
inInventory = loadObject.configData.get('inInventory', False)
|
||||
if hasPropertyObjectID and inInventory:
|
||||
objectLoadState.components.append('MODEL_BEHAVIORS')
|
||||
else:
|
||||
objectLoadState.components.append('MUTABLE_MODEL_BEHAVIORS')
|
||||
|
||||
def PropertyEntranceFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('PROPERTY_ENTRANCE')
|
||||
|
||||
def PropertyManagementFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('PROPERTY_MANAGEMENT')
|
||||
|
||||
def VehiclePhysicsFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('VEHICLE_PHYSICS')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
|
||||
def PhysicsSystemFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if not objectLoadState.hasModelbehaviors:
|
||||
if not loadObject.hasDropEffect:
|
||||
objectLoadState.components.append('PHYSICS_SYSTEM')
|
||||
objectLoadState.hasPhysicsComponent = True
|
||||
|
||||
def RebuildFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('REBUILD')
|
||||
if not objectLoadState.hasDestroyable:
|
||||
objectLoadState.components.append('DESTROYABLE')
|
||||
objectLoadState.hasDestroyable = True
|
||||
loadObject.bIsSmashable = True
|
||||
|
||||
def BaseCombatAiFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int, add_pathfinding_control: bool):
|
||||
if not objectLoadState.hasProximityMonitorComponent:
|
||||
objectLoadState.components.append('PROXIMITY_MONITOR')
|
||||
objectLoadState.hasProximityMonitorComponent = True
|
||||
|
||||
if not objectLoadState.hasPathfindingComponent and add_pathfinding_control:
|
||||
objectLoadState.components.append('PATHFINDING_CONTROL')
|
||||
objectLoadState.hasPathfindingComponent = True
|
||||
|
||||
objectLoadState.components.append('BASE_COMBAT_AI')
|
||||
|
||||
def ProximityMonitorFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
print('TODO query cdc for this data in prox mon')
|
||||
# There must be a row for this component in the ProximityMonitorComponent table to get this component
|
||||
LoadOnClient = loadObject.configData.get('LoadOnClient', False) # Get this from ProximityMonitorComponent table if you know there is a column for it
|
||||
if LoadOnClient:
|
||||
objectLoadState.components.append('PROXIMITY_MONITOR')
|
||||
objectLoadState.hasProximityMonitorComponent = True
|
||||
|
||||
def DonationVendorFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if not objectLoadState.hasProximityMonitorComponent:
|
||||
objectLoadState.components.append('PROXIMITY_MONITOR')
|
||||
objectLoadState.hasProximityMonitorComponent = True
|
||||
objectLoadState.components.append('DONATION_VENDOR')
|
||||
|
||||
def AchievmentVendorFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if not objectLoadState.hasProximityMonitorComponent:
|
||||
objectLoadState.components.append('PROXIMITY_MONITOR')
|
||||
objectLoadState.hasProximityMonitorComponent = True
|
||||
|
||||
objectLoadState.components.append('ACHIEVEMENT_VENDOR')
|
||||
|
||||
def CraftingFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
# Game verson must be above 999 for this to work!
|
||||
gameVersion = 1000
|
||||
if gameVersion > 999:
|
||||
objectLoadState.components.append('CRAFTING')
|
||||
|
||||
# Technically Possessable and Possessor are the exact same thing
|
||||
def PossessableFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('POSSESSABLE')
|
||||
|
||||
def PossessorFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('POSSESSOR')
|
||||
|
||||
def PropertyPlaqueFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('PROPERTY_PLAQUE')
|
||||
|
||||
def BuildBorderFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('BUILD_BORDER')
|
||||
|
||||
def CullingPlaneFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('CULLING_PLANE')
|
||||
|
||||
def GateRushFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('GATE_RUSH')
|
||||
|
||||
def RailActivatorFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('RAIL_ACTIVATOR')
|
||||
|
||||
def RollerFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('ROLLER')
|
||||
|
||||
def PlayerForcedMovementFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('PLAYER_FORCED_MOVEMENT')
|
||||
|
||||
def RacingSoundTriggerFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('RACING_SOUND_TRIGGER')
|
||||
|
||||
def RocketLaunchLupFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('ROCKET_LAUNCH_LUP')
|
||||
|
||||
|
||||
def ModuleAssemblyFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('MODULE_ASSEMBLY')
|
||||
|
||||
def ShowcaseModelHandlerFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SHOWCASE_MODEL_HANDLER')
|
||||
|
||||
def GenericActivatorFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('GENERIC_ACTIVATOR')
|
||||
|
||||
def PropertyVendorFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('PROPERTY_VENDOR')
|
||||
|
||||
def RocketLaunchFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('ROCKET_LAUNCH')
|
||||
|
||||
def RocketLandingComponentFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('ROCKET_LANDING_COMPONENT')
|
||||
|
||||
def RacingControlFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('RACING_CONTROL')
|
||||
|
||||
def FactionTriggerFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('FACTION_TRIGGER')
|
||||
|
||||
def MissionOfferFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('MISSION_OFFER')
|
||||
objectLoadState.hasMissionOffer = True
|
||||
|
||||
def RacingStatsFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('RACING_STATS')
|
||||
|
||||
def LupExhibitFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('LUP_EXHIBIT')
|
||||
|
||||
def BBBFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('BBB')
|
||||
|
||||
def SoundTriggerFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SOUND_TRIGGER')
|
||||
|
||||
def SwitchFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SWITCH')
|
||||
|
||||
def ZoneControlFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('ZONE_CONTROL')
|
||||
|
||||
def ChanglingFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('CHANGELING')
|
||||
|
||||
def ChoiceBuildFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('CHOICE_BUILD')
|
||||
|
||||
def PackageFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
# Literally returns nothing
|
||||
pass
|
||||
|
||||
def SoundRepeaterFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SOUND_REPEATER')
|
||||
|
||||
def SoundAmbient2DFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
if loadObject.isLocalPlayer:
|
||||
objectLoadState.components.append('SOUND_AMBIENT_2D')
|
||||
|
||||
def SoundAmbient3DFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('SOUND_AMBIENT_3D')
|
||||
|
||||
def CustomBuildAssemblyFactory(loadObject: cd.LoadObject, objectLoadState: cd.ObjectLoadState, componentId: int):
|
||||
objectLoadState.components.append('CUSTOM_BUILD_ASSEMBLY')
|
||||
@@ -1,306 +0,0 @@
|
||||
import ComponentDefinitions as cd
|
||||
import ComponentFactories as cf
|
||||
|
||||
# If we have any of these components, we need pathfinding control
|
||||
def CheckIfNeedsPathfindingControl(components_to_load: dict):
|
||||
add_pathfinding_control = cd.components['COMPONENT_TYPE_CONTROLLABLE_PHYSICS'] in components_to_load
|
||||
add_pathfinding_control |= cd.components['COMPONENT_TYPE_PROJECTILE_PHYSICS'] in components_to_load
|
||||
add_pathfinding_control |= cd.components['COMPONENT_TYPE_HAVOK_VEHICLE_PHYSICS'] in components_to_load
|
||||
add_pathfinding_control |= cd.components['COMPONENT_TYPE_VEHICLE_PHYSICS'] in components_to_load
|
||||
return add_pathfinding_control
|
||||
|
||||
def DoObjectPreLoad(components_to_load: dict):
|
||||
isHfActive = False
|
||||
cf.ApplyComponentWhitelist()
|
||||
objectLoadState = cd.ObjectLoadState()
|
||||
loadObject = cd.LoadObject()
|
||||
|
||||
for componentType in cd.component_order_as_ints.keys():
|
||||
try:
|
||||
componentId = components_to_load[componentType]
|
||||
except KeyError:
|
||||
continue
|
||||
try:
|
||||
match cd.component_int_to_name[componentType]:
|
||||
case 'COMPONENT_TYPE_CONTROLLABLE_PHYSICS':
|
||||
if objectLoadState.hasDroppedLootComponent: continue
|
||||
cf.ControllablePhysFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_RENDER':
|
||||
cf.RenderFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SIMPLE_PHYSICS':
|
||||
if objectLoadState.hasDroppedLootComponent: continue
|
||||
cf.SimplePhysFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_CHARACTER':
|
||||
cf.CharacterFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SCRIPT':
|
||||
cf.ScriptFactory(loadObject, objectLoadState, componentId, CheckIfNeedsPathfindingControl(components_to_load))
|
||||
|
||||
case 'COMPONENT_TYPE_BOUNCER':
|
||||
cf.BouncerFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_DESTROYABLE':
|
||||
cf.DestroyableFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SKILL':
|
||||
cf.SkillFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SPAWNER':
|
||||
cf.SpawnerFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_ITEM':
|
||||
cf.ItemFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_MODULAR_BUILD':
|
||||
cf.ModularBuildFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_BUILD_CONTROLLER':
|
||||
cf.BuildControllerFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_VENDOR':
|
||||
cf.VendorFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_INVENTORY':
|
||||
cf.InventoryFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PROJECTILE_PHYSICS':
|
||||
if objectLoadState.hasDroppedLootComponent: continue
|
||||
cf.ProjectilePhysicsFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SHOOTING_GALLERY':
|
||||
cf.ShootingGalleryFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_RIGID_BODY_PHANTOM_PHYSICS':
|
||||
cf.RigibBodyPhantomPhysicsFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_CHEST':
|
||||
cf.ChestFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_COLLECTIBLE':
|
||||
cf.CollectibleFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_BLUEPRINT':
|
||||
cf.BlueprintFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_MOVING_PLATFORM':
|
||||
cf.MovingPlatformFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PET':
|
||||
cf.PetFactory(loadObject, objectLoadState, componentId)
|
||||
print('Deleting COMPONENT_TYPE_MODEL and COMPONENT_TYPE_ITEM due to COMPONENT_TYPE_PET being loaded')
|
||||
toDel = cd.components['COMPONENT_TYPE_MODEL']
|
||||
del components_to_load[toDel]
|
||||
toDel = cd.components['COMPONENT_TYPE_ITEM']
|
||||
del components_to_load[toDel]
|
||||
|
||||
case 'COMPONENT_TYPE_PLATFORM_BOUNDARY':
|
||||
cf.PlatformBoundaryFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_MODULE':
|
||||
cf.ModuleFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_ARCADE':
|
||||
cf.ArcadeFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_HAVOK_VEHICLE_PHYSICS':
|
||||
cf.HavokVehiclePhysicsFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_MOVEMENT_AI':
|
||||
cf.MovementAiFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_EXHIBIT':
|
||||
cf.ExhibitFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_MINIFIG':
|
||||
cf.MinifigFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PROPERTY':
|
||||
cf.PropertyFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_MODEL_BUILDER':
|
||||
cf.ModelBuilderFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SCRIPTED_ACTIVITY':
|
||||
cf.ScriptedActivityFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PHANTOM_PHYSICS':
|
||||
if objectLoadState.hasDroppedLootComponent: continue
|
||||
cf.PhantomPhysicsFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SPRING_PAD':
|
||||
cf.SpringPadFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_MODEL':
|
||||
cf.ModelFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PROPERTY_ENTRANCE':
|
||||
cf.PropertyEntranceFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PROPERTY_MANAGEMENT':
|
||||
cf.PropertyManagementFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_VEHICLE_PHYSICS':
|
||||
cf.VehiclePhysicsFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PHYSICS_SYSTEM':
|
||||
cf.PhysicsSystemFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_REBUILD':
|
||||
cf.RebuildFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SWITCH':
|
||||
cf.SwitchFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_ZONE_CONTROL':
|
||||
cf.ZoneControlFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_CHANGELING':
|
||||
cf.ChanglingFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_CHOICE_BUILD':
|
||||
cf.ChoiceBuildFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PACKAGE':
|
||||
cf.PackageFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SOUND_REPEATER':
|
||||
cf.SoundRepeaterFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SOUND_AMBIENT_2D':
|
||||
cf.SoundAmbient2DFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SOUND_AMBIENT_3D':
|
||||
cf.SoundAmbient3DFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_CUSTOM_BUILD_ASSEMBLY':
|
||||
cf.CustomBuildAssemblyFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_BASE_COMBAT_AI':
|
||||
cf.BaseCombatAiFactory(loadObject, objectLoadState, componentId, CheckIfNeedsPathfindingControl(components_to_load))
|
||||
|
||||
case 'COMPONENT_TYPE_MODULE_ASSEMBLY':
|
||||
cf.ModuleAssemblyFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SHOWCASE_MODEL_HANDLER':
|
||||
cf.ShowcaseModelHandlerFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_GENERIC_ACTIVATOR':
|
||||
cf.GenericActivatorFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PROPERTY_VENDOR':
|
||||
cf.PropertyVendorFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_ROCKET_LAUNCH':
|
||||
cf.RocketLaunchFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_ROCKET_LANDING_COMPONENT':
|
||||
cf.RocketLandingComponentFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_RACING_CONTROL':
|
||||
cf.RacingControlFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_FACTION_TRIGGER':
|
||||
cf.FactionTriggerFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_MISSION_OFFER':
|
||||
cf.MissionOfferFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_RACING_STATS':
|
||||
cf.RacingStatsFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_LUP_EXHIBIT':
|
||||
cf.LupExhibitFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_BBB':
|
||||
cf.BBBFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_SOUND_TRIGGER':
|
||||
cf.SoundTriggerFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PROXIMITY_MONITOR':
|
||||
cf.ProximityMonitorFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_RACING_SOUND_TRIGGER':
|
||||
cf.RacingSoundTriggerFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_ROCKET_LAUNCH_LUP':
|
||||
cf.RocketLaunchLupFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_DONATION_VENDOR':
|
||||
cf.DonationVendorFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_ACHIEVEMENT_VENDOR':
|
||||
cf.AchievmentVendorFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_GATE_RUSH':
|
||||
cf.GateRushFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_RAIL_ACTIVATOR':
|
||||
cf.RailActivatorFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_ROLLER':
|
||||
cf.RollerFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PLAYER_FORCED_MOVEMENT':
|
||||
cf.PlayerForcedMovementFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_CRAFTING':
|
||||
cf.CraftingFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_POSSESSABLE':
|
||||
cf.PossessableFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_POSSESSOR':
|
||||
cf.PossessorFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_PROPERTY_PLAQUE':
|
||||
cf.PropertyPlaqueFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_BUILD_BORDER':
|
||||
cf.BuildBorderFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
case 'COMPONENT_TYPE_CULLING_PLANE':
|
||||
cf.CullingPlaneFactory(loadObject, objectLoadState, componentId)
|
||||
|
||||
except KeyError:
|
||||
print(f'Unknown component: {componentType}')
|
||||
|
||||
if not 'is_smashable' in loadObject.configData and loadObject.bIsSmashable:
|
||||
loadObject.configData['is_smashable'] = True
|
||||
|
||||
is_smashable = loadObject.configData['is_smashable']
|
||||
if is_smashable and not objectLoadState.hasDestroyable and loadObject.lotToSpawn != 176:
|
||||
objectLoadState.components.append('DESTROYABLE')
|
||||
|
||||
if objectLoadState.hasMissionOffer and not objectLoadState.hasProximityMonitorComponent:
|
||||
objectLoadState.components.append('PROXIMITY_MONITOR')
|
||||
objectLoadState.hasProximityMonitorComponent = True
|
||||
|
||||
if loadObject.field8_0x20 and loadObject.owner != 0:
|
||||
objectLoadState.components.append('OVERHEAD_ICON')
|
||||
|
||||
trigger_id = loadObject.configData.get('trigger_id', 0)
|
||||
if trigger_id != 0:
|
||||
objectLoadState.components.append('TRIGGER')
|
||||
|
||||
return objectLoadState
|
||||
|
||||
components_to_load = {}
|
||||
|
||||
# Testing code to load all components
|
||||
for i in range(110):
|
||||
components_to_load[i] = i
|
||||
|
||||
objectLoadState = DoObjectPreLoad(components_to_load)
|
||||
|
||||
# Convert the components to ints
|
||||
components_to_int = []
|
||||
for component in objectLoadState.components:
|
||||
components_to_int.append([cd.components[f'COMPONENT_TYPE_{component}'], component])
|
||||
|
||||
# Print out the components in a more readable format
|
||||
for comp in components_to_int:
|
||||
print(comp[0], comp[1])
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,8 +2,7 @@
|
||||
#include "PlayerContainer.h"
|
||||
#include "Database.h"
|
||||
#include <vector>
|
||||
#include "PacketUtils.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "BitstreamUtils.h"
|
||||
#include "Game.h"
|
||||
#include "dServer.h"
|
||||
#include "GeneralUtils.h"
|
||||
@@ -76,11 +75,11 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
|
||||
|
||||
//Now, we need to send the friendlist to the server they came from:
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GET_FRIENDS_LIST_RESPONSE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GET_FRIENDS_LIST_RESPONSE);
|
||||
bitStream.Write<uint8_t>(0);
|
||||
bitStream.Write<uint16_t>(1); //Length of packet -- just writing one as it doesn't matter, client skips it.
|
||||
bitStream.Write((uint16_t)friends.size());
|
||||
@@ -104,30 +103,23 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
|
||||
inStream.Read(requestorPlayerID);
|
||||
uint32_t spacing{};
|
||||
inStream.Read(spacing);
|
||||
std::string playerName = "";
|
||||
uint16_t character;
|
||||
bool noMoreLettersInName = false;
|
||||
|
||||
for (uint32_t j = 0; j < 33; j++) {
|
||||
inStream.Read(character);
|
||||
if (character == '\0') noMoreLettersInName = true;
|
||||
if (!noMoreLettersInName) playerName.push_back(static_cast<char>(character));
|
||||
}
|
||||
LUWString playerName(33);
|
||||
inStream.Read(playerName);
|
||||
|
||||
char isBestFriendRequest{};
|
||||
inStream.Read(isBestFriendRequest);
|
||||
|
||||
auto requestor = playerContainer.GetPlayerData(requestorPlayerID);
|
||||
if (requestor->playerName == playerName) {
|
||||
if (requestor->playerName == playerName.GetAsString()) {
|
||||
SendFriendResponse(requestor, requestor, eAddFriendResponseType::MYTHRAN);
|
||||
return;
|
||||
};
|
||||
std::unique_ptr<PlayerData> requestee(playerContainer.GetPlayerData(playerName));
|
||||
std::unique_ptr<PlayerData> requestee(playerContainer.GetPlayerData(playerName.GetAsString()));
|
||||
|
||||
// Check if player is online first
|
||||
if (isBestFriendRequest && !requestee) {
|
||||
for (auto friendDataCandidate : requestor->friends) {
|
||||
if (friendDataCandidate.friendName == playerName) {
|
||||
if (friendDataCandidate.friendName == playerName.GetAsString()) {
|
||||
requestee.reset(new PlayerData());
|
||||
// Setup the needed info since you can add a best friend offline.
|
||||
requestee->playerID = friendDataCandidate.friendID;
|
||||
@@ -151,11 +143,11 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
|
||||
// Send the response code that corresponds to what the error is.
|
||||
if (!requestee) {
|
||||
std::unique_ptr<sql::PreparedStatement> nameQuery(Database::CreatePreppedStmt("SELECT name from charinfo where name = ?;"));
|
||||
nameQuery->setString(1, playerName);
|
||||
nameQuery->setString(1, playerName.GetAsString());
|
||||
std::unique_ptr<sql::ResultSet> result(nameQuery->executeQuery());
|
||||
|
||||
requestee.reset(new PlayerData());
|
||||
requestee->playerName = playerName;
|
||||
requestee->playerName = playerName.GetAsString();
|
||||
|
||||
SendFriendResponse(requestor, requestee.get(), result->next() ? eAddFriendResponseType::NOTONLINE : eAddFriendResponseType::INVALIDCHARACTER);
|
||||
return;
|
||||
@@ -249,13 +241,15 @@ void ChatPacketHandler::HandleFriendResponse(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerID;
|
||||
inStream.Read(playerID);
|
||||
|
||||
eAddFriendResponseCode clientResponseCode = static_cast<eAddFriendResponseCode>(packet->data[0x14]);
|
||||
std::string friendName = PacketUtils::ReadString(0x15, packet, true);
|
||||
inStream.IgnoreBytes(4);
|
||||
eAddFriendResponseCode clientResponseCode;
|
||||
inStream.Read(clientResponseCode);
|
||||
LUWString friendName(33);
|
||||
inStream.Read(friendName);
|
||||
|
||||
//Now to try and find both of these:
|
||||
auto requestor = playerContainer.GetPlayerData(playerID);
|
||||
auto requestee = playerContainer.GetPlayerData(friendName);
|
||||
auto requestee = playerContainer.GetPlayerData(friendName.GetAsString());
|
||||
if (!requestor || !requestee) return;
|
||||
|
||||
eAddFriendResponseType serverResponseCode{};
|
||||
@@ -324,12 +318,14 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerID;
|
||||
inStream.Read(playerID);
|
||||
std::string friendName = PacketUtils::ReadString(0x14, packet, true);
|
||||
inStream.IgnoreBytes(4);
|
||||
LUWString friendName(33);
|
||||
inStream.Read(friendName);
|
||||
|
||||
//we'll have to query the db here to find the user, since you can delete them while they're offline.
|
||||
//First, we need to find their ID:
|
||||
std::unique_ptr<sql::PreparedStatement> stmt(Database::CreatePreppedStmt("SELECT id FROM charinfo WHERE name=? LIMIT 1;"));
|
||||
stmt->setString(1, friendName.c_str());
|
||||
stmt->setString(1, friendName.GetAsString().c_str());
|
||||
|
||||
LWOOBJID friendID = 0;
|
||||
std::unique_ptr<sql::ResultSet> res(stmt->executeQuery());
|
||||
@@ -359,7 +355,8 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
SendRemoveFriend(goonA, friendName, true);
|
||||
auto friendString = friendName.GetAsString();
|
||||
SendRemoveFriend(goonA, friendString, true);
|
||||
}
|
||||
|
||||
auto goonB = playerContainer.GetPlayerData(friendID);
|
||||
@@ -381,28 +378,31 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||
inStream.Read(playerID);
|
||||
|
||||
auto* sender = playerContainer.GetPlayerData(playerID);
|
||||
|
||||
if (sender == nullptr) return;
|
||||
|
||||
if (playerContainer.GetIsMuted(sender)) return;
|
||||
|
||||
const auto senderName = std::string(sender->playerName.c_str());
|
||||
|
||||
inStream.SetReadOffset(0x14 * 8);
|
||||
inStream.IgnoreBytes(20);
|
||||
eChatChannel chatchannel;
|
||||
inStream.Read(chatchannel);
|
||||
LUWString senderNameLU(33);
|
||||
inStream.Read(senderNameLU);
|
||||
LWOOBJID senderID;
|
||||
inStream.Read(senderID);
|
||||
uint16_t sourceID;
|
||||
inStream.Read(sourceID);
|
||||
uint8_t senderGMLevel;
|
||||
inStream.Read(senderGMLevel);
|
||||
LUWString message(512);
|
||||
inStream.Read(message);
|
||||
Game::logger->Log("ChatPacketHandler", "channel %i sender %s, senderID %llu and %llu, sourceID %i, sendergmlevel %i, message %s", chatchannel, senderNameLU.GetAsString().c_str(), playerID, senderID,sourceID, senderGMLevel, message.GetAsString().c_str());
|
||||
|
||||
uint8_t channel = 0;
|
||||
inStream.Read(channel);
|
||||
|
||||
std::string message = PacketUtils::ReadString(0x66, packet, true, 512);
|
||||
|
||||
Game::logger->Log("ChatPacketHandler", "Got a message from (%s) [%d]: %s", senderName.c_str(), channel, message.c_str());
|
||||
|
||||
if (channel != 8) return;
|
||||
Game::logger->Log("ChatPacketHandler", "Got a message from (%s) [%d]: %s", senderName.c_str(), chatchannel, message.GetAsString().c_str());
|
||||
|
||||
if (chatchannel != eChatChannel::Team) {
|
||||
auto* team = playerContainer.GetTeam(playerID);
|
||||
|
||||
if (team == nullptr) return;
|
||||
|
||||
for (const auto memberId : team->memberIDs) {
|
||||
@@ -413,12 +413,12 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet) {
|
||||
const auto otherName = std::string(otherMember->playerName.c_str());
|
||||
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(otherMember->playerID);
|
||||
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
bitStream.Write(otherMember->playerID);
|
||||
bitStream.Write<uint8_t>(8);
|
||||
bitStream.Write(eChatChannel::Team);
|
||||
bitStream.Write<unsigned int>(69);
|
||||
bitStream.Write(LUWString(senderName));
|
||||
bitStream.Write(sender->playerID);
|
||||
@@ -426,22 +426,45 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet) {
|
||||
bitStream.Write<uint8_t>(0); //not mythran nametag
|
||||
bitStream.Write(LUWString(otherName));
|
||||
bitStream.Write<uint8_t>(0); //not mythran for receiver
|
||||
bitStream.Write<uint8_t>(0); //teams?
|
||||
bitStream.Write(LUWString(message, 512));
|
||||
bitStream.Write(eChatMessageResponseCode::Sent);
|
||||
bitStream.Write(message);
|
||||
|
||||
SystemAddress sysAddr = otherMember->sysAddr;
|
||||
SEND_PACKET;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
||||
LWOOBJID senderID = PacketUtils::ReadS64(0x08, packet);
|
||||
std::string receiverName = PacketUtils::ReadString(0x66, packet, true);
|
||||
std::string message = PacketUtils::ReadString(0xAA, packet, true, 512);
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID senderID;
|
||||
inStream.Read(senderID);
|
||||
inStream.IgnoreBytes(4);
|
||||
|
||||
eChatChannel chatchannel;
|
||||
inStream.Read(chatchannel);
|
||||
// is there something extra here?
|
||||
LUWString senderName(33);
|
||||
inStream.Read(senderName);
|
||||
LWOOBJID senderID2;
|
||||
inStream.Read(senderID2);
|
||||
uint16_t sourceID;
|
||||
inStream.Read(sourceID);
|
||||
uint8_t senderGMLevel;
|
||||
inStream.Read(senderGMLevel);
|
||||
LUWString receiverName(33);
|
||||
inStream.Read(receiverName);
|
||||
uint8_t receiverGMLevel;
|
||||
inStream.Read(receiverGMLevel);
|
||||
eChatMessageResponseCode responseCode;
|
||||
inStream.Read(responseCode);
|
||||
LUWString message(512);
|
||||
inStream.Read(message);
|
||||
Game::logger->Log("ChatPacketHandler", "channel %i sender %s, senderID %llu and %llu, sourceID %i, sendergmlevel %i", chatchannel, senderName.GetAsString().c_str(), senderID, senderID2,sourceID, senderGMLevel);
|
||||
Game::logger->Log("ChatPacketHandler", "receiver %s, receivergmlevel %i, responsecode %i, message %s", receiverName.GetAsString().c_str(), receiverGMLevel, responseCode, message.GetAsString().c_str());
|
||||
//Get the bois:
|
||||
auto goonA = playerContainer.GetPlayerData(senderID);
|
||||
auto goonB = playerContainer.GetPlayerData(receiverName);
|
||||
auto goonB = playerContainer.GetPlayerData(receiverName.GetAsString());
|
||||
if (!goonA || !goonB) return;
|
||||
|
||||
if (playerContainer.GetIsMuted(goonA)) return;
|
||||
@@ -452,12 +475,12 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
||||
//To the sender:
|
||||
{
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(goonA->playerID);
|
||||
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
bitStream.Write(goonA->playerID);
|
||||
bitStream.Write<uint8_t>(7);
|
||||
bitStream.Write(eChatChannel::Private);
|
||||
bitStream.Write<unsigned int>(69);
|
||||
bitStream.Write(LUWString(goonAName));
|
||||
bitStream.Write(goonA->playerID);
|
||||
@@ -465,8 +488,8 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
||||
bitStream.Write<uint8_t>(0); //not mythran nametag
|
||||
bitStream.Write(LUWString(goonBName));
|
||||
bitStream.Write<uint8_t>(0); //not mythran for receiver
|
||||
bitStream.Write<uint8_t>(0); //success
|
||||
bitStream.Write(LUWString(message, 512));
|
||||
bitStream.Write(eChatMessageResponseCode::Sent);
|
||||
bitStream.Write(message);
|
||||
|
||||
SystemAddress sysAddr = goonA->sysAddr;
|
||||
SEND_PACKET;
|
||||
@@ -475,12 +498,12 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
||||
//To the receiver:
|
||||
{
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(goonB->playerID);
|
||||
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE);
|
||||
bitStream.Write(goonA->playerID);
|
||||
bitStream.Write<uint8_t>(7);
|
||||
bitStream.Write(eChatChannel::Private);
|
||||
bitStream.Write<unsigned int>(69);
|
||||
bitStream.Write(LUWString(goonAName));
|
||||
bitStream.Write(goonA->playerID);
|
||||
@@ -488,8 +511,8 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
||||
bitStream.Write<uint8_t>(0); //not mythran nametag
|
||||
bitStream.Write(LUWString(goonBName));
|
||||
bitStream.Write<uint8_t>(0); //not mythran for receiver
|
||||
bitStream.Write<uint8_t>(3); //new whisper
|
||||
bitStream.Write(LUWString(message, 512));
|
||||
bitStream.Write(eChatMessageResponseCode::ReceivedNewWhisper);
|
||||
bitStream.Write(LUWString(message.string, 512));
|
||||
|
||||
SystemAddress sysAddr = goonB->sysAddr;
|
||||
SEND_PACKET;
|
||||
@@ -500,7 +523,9 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerID;
|
||||
inStream.Read(playerID);
|
||||
std::string invitedPlayer = PacketUtils::ReadString(0x14, packet, true);
|
||||
inStream.IgnoreBytes(4);
|
||||
LUWString invitedPlayer(33);
|
||||
inStream.Read(invitedPlayer);
|
||||
|
||||
auto* player = playerContainer.GetPlayerData(playerID);
|
||||
|
||||
@@ -514,7 +539,7 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet) {
|
||||
team = playerContainer.CreateTeam(playerID);
|
||||
}
|
||||
|
||||
auto* other = playerContainer.GetPlayerData(invitedPlayer);
|
||||
auto* other = playerContainer.GetPlayerData(invitedPlayer.GetAsString());
|
||||
|
||||
if (other == nullptr) {
|
||||
return;
|
||||
@@ -533,7 +558,7 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet) {
|
||||
|
||||
SendTeamInvite(other, player);
|
||||
|
||||
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.c_str());
|
||||
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.GetAsString().c_str());
|
||||
}
|
||||
|
||||
void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) {
|
||||
@@ -590,18 +615,18 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet) {
|
||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||
inStream.Read(playerID);
|
||||
|
||||
std::string kickedPlayer = PacketUtils::ReadString(0x14, packet, true);
|
||||
LUWString kickedPlayer(33);
|
||||
inStream.Read(kickedPlayer);
|
||||
Game::logger->Log("ChatPacketHandler", "(%llu) kicking (%s) from team", playerID, kickedPlayer.GetAsString().c_str());
|
||||
|
||||
Game::logger->Log("ChatPacketHandler", "(%llu) kicking (%s) from team", playerID, kickedPlayer.c_str());
|
||||
|
||||
auto* kicked = playerContainer.GetPlayerData(kickedPlayer);
|
||||
auto* kicked = playerContainer.GetPlayerData(kickedPlayer.GetAsString());
|
||||
|
||||
LWOOBJID kickedId = LWOOBJID_EMPTY;
|
||||
|
||||
if (kicked != nullptr) {
|
||||
kickedId = kicked->playerID;
|
||||
} else {
|
||||
kickedId = playerContainer.GetId(GeneralUtils::UTF8ToUTF16(kickedPlayer));
|
||||
kickedId = playerContainer.GetId(GeneralUtils::UTF8ToUTF16(kickedPlayer.GetAsString()));
|
||||
}
|
||||
|
||||
if (kickedId == LWOOBJID_EMPTY) return;
|
||||
@@ -620,11 +645,12 @@ void ChatPacketHandler::HandleTeamPromote(Packet* packet) {
|
||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||
inStream.Read(playerID);
|
||||
|
||||
std::string promotedPlayer = PacketUtils::ReadString(0x14, packet, true);
|
||||
LUWString promotedPlayer(33);
|
||||
inStream.Read(promotedPlayer);
|
||||
|
||||
Game::logger->Log("ChatPacketHandler", "(%llu) promoting (%s) to team leader", playerID, promotedPlayer.c_str());
|
||||
Game::logger->Log("ChatPacketHandler", "(%llu) promoting (%s) to team leader", playerID, promotedPlayer.GetAsString().c_str());
|
||||
|
||||
auto* promoted = playerContainer.GetPlayerData(promotedPlayer);
|
||||
auto* promoted = playerContainer.GetPlayerData(promotedPlayer.GetAsString());
|
||||
|
||||
if (promoted == nullptr) return;
|
||||
|
||||
@@ -710,11 +736,11 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) {
|
||||
|
||||
void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::TEAM_INVITE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::TEAM_INVITE);
|
||||
|
||||
bitStream.Write(LUWString(sender->playerName.c_str()));
|
||||
bitStream.Write(sender->playerID);
|
||||
@@ -725,7 +751,7 @@ void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender)
|
||||
|
||||
void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@@ -752,7 +778,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
|
||||
|
||||
void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@@ -777,7 +803,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
|
||||
|
||||
void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@@ -794,7 +820,7 @@ void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64Play
|
||||
|
||||
void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@@ -823,7 +849,7 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
|
||||
|
||||
void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@@ -849,7 +875,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
|
||||
|
||||
void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
@@ -883,11 +909,11 @@ void ChatPacketHandler::SendFriendUpdate(PlayerData* friendData, PlayerData* pla
|
||||
[bool] - is FTP*/
|
||||
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(friendData->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::UPDATE_FRIEND_NOTIFY);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::UPDATE_FRIEND_NOTIFY);
|
||||
bitStream.Write<uint8_t>(notifyType);
|
||||
|
||||
std::string playerName = playerData->playerName.c_str();
|
||||
@@ -922,11 +948,11 @@ void ChatPacketHandler::SendFriendRequest(PlayerData* receiver, PlayerData* send
|
||||
}
|
||||
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_REQUEST);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_REQUEST);
|
||||
bitStream.Write(LUWString(sender->playerName.c_str()));
|
||||
bitStream.Write<uint8_t>(0); // This is a BFF flag however this is unused in live and does not have an implementation client side.
|
||||
|
||||
@@ -938,11 +964,11 @@ void ChatPacketHandler::SendFriendResponse(PlayerData* receiver, PlayerData* sen
|
||||
if (!receiver || !sender) return;
|
||||
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
// Portion that will get routed:
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_RESPONSE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_RESPONSE);
|
||||
bitStream.Write(responseCode);
|
||||
// For all requests besides accepted, write a flag that says whether or not we are already best friends with the receiver.
|
||||
bitStream.Write<uint8_t>(responseCode != eAddFriendResponseType::ACCEPTED ? isBestFriendsAlready : sender->sysAddr != UNASSIGNED_SYSTEM_ADDRESS);
|
||||
@@ -963,11 +989,11 @@ void ChatPacketHandler::SendRemoveFriend(PlayerData* receiver, std::string& pers
|
||||
if (!receiver) return;
|
||||
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||
bitStream.Write(receiver->playerID);
|
||||
|
||||
//portion that will get routed:
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::REMOVE_FRIEND_RESPONSE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::REMOVE_FRIEND_RESPONSE);
|
||||
bitStream.Write<uint8_t>(isSuccessful); //isOnline
|
||||
bitStream.Write(LUWString(personToRemove));
|
||||
|
||||
|
||||
@@ -6,6 +6,42 @@
|
||||
struct PlayerData;
|
||||
enum class eAddFriendResponseType : uint8_t;
|
||||
|
||||
enum class eChatChannel : uint8_t {
|
||||
SystemNotify,
|
||||
SystemWarning,
|
||||
SystemError,
|
||||
Broadcast,
|
||||
Local,
|
||||
LocalNoanim,
|
||||
Emote,
|
||||
Private,
|
||||
Team,
|
||||
TeamLocal,
|
||||
Guild,
|
||||
GuildNotify,
|
||||
Property,
|
||||
Admin,
|
||||
CombatDamage,
|
||||
CombatHealing,
|
||||
CombatLoot,
|
||||
CombatExp,
|
||||
CombatDeath,
|
||||
General,
|
||||
Trade,
|
||||
Lfg,
|
||||
User
|
||||
};
|
||||
|
||||
enum class eChatMessageResponseCode : uint8_t {
|
||||
Sent,
|
||||
NotOnline,
|
||||
GeneralError,
|
||||
ReceivedNewWhisper,
|
||||
NotFriends,
|
||||
SenderFreeTrial,
|
||||
ReceiverFreeTrial,
|
||||
};
|
||||
|
||||
namespace ChatPacketHandler {
|
||||
void HandleFriendlistRequest(Packet* packet);
|
||||
void HandleFriendRequest(Packet* packet);
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
#include "dLogger.h"
|
||||
#include "ChatPacketHandler.h"
|
||||
#include "GeneralUtils.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "BitstreamUtils.h"
|
||||
#include "Database.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eChatInternalMessageType.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
PlayerContainer::PlayerContainer() {
|
||||
}
|
||||
@@ -20,10 +18,6 @@ PlayerContainer::~PlayerContainer() {
|
||||
mPlayers.clear();
|
||||
}
|
||||
|
||||
TeamData::TeamData() {
|
||||
lootFlag = Game::config->GetValue("default_team_loot") == "0" ? 0 : 1;
|
||||
}
|
||||
|
||||
void PlayerContainer::InsertPlayer(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
PlayerData* data = new PlayerData();
|
||||
@@ -152,7 +146,7 @@ void PlayerContainer::CreateTeamServer(Packet* packet) {
|
||||
|
||||
void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::MUTE_UPDATE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::MUTE_UPDATE);
|
||||
|
||||
bitStream.Write(player);
|
||||
bitStream.Write(time);
|
||||
@@ -213,14 +207,6 @@ TeamData* PlayerContainer::GetTeam(LWOOBJID playerID) {
|
||||
}
|
||||
|
||||
void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
|
||||
if (team->memberIDs.size() >= 4){
|
||||
Game::logger->Log("PlayerContainer", "Tried to add player to team that already had 4 players");
|
||||
auto* player = GetPlayerData(playerID);
|
||||
if (!player) return;
|
||||
ChatPackets::SendSystemMessage(player->sysAddr, u"The teams is full! You have not been added to a team!");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);
|
||||
|
||||
if (index != team->memberIDs.end()) return;
|
||||
@@ -359,7 +345,7 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team) {
|
||||
|
||||
void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::TEAM_UPDATE);
|
||||
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::TEAM_UPDATE);
|
||||
|
||||
bitStream.Write(team->teamID);
|
||||
bitStream.Write(deleteTeam);
|
||||
|
||||
@@ -18,7 +18,6 @@ struct PlayerData {
|
||||
};
|
||||
|
||||
struct TeamData {
|
||||
TeamData();
|
||||
LWOOBJID teamID = LWOOBJID_EMPTY; // Internal use
|
||||
LWOOBJID leaderID = LWOOBJID_EMPTY;
|
||||
std::vector<LWOOBJID> memberIDs{};
|
||||
|
||||
@@ -12,7 +12,7 @@ set(DCOMMON_SOURCES
|
||||
"NiPoint3.cpp"
|
||||
"NiQuaternion.cpp"
|
||||
"SHA512.cpp"
|
||||
"Demangler.cpp"
|
||||
"Type.cpp"
|
||||
"ZCompression.cpp"
|
||||
"BrickByBrickFix.cpp"
|
||||
"BinaryPathFinder.cpp"
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#include "Demangler.h"
|
||||
#ifdef __GNUG__
|
||||
#include <cstdlib>
|
||||
#include <cxxabi.h>
|
||||
#include <memory>
|
||||
#include <typeinfo>
|
||||
|
||||
std::string Demangler::Demangle(const char* name) {
|
||||
// some arbitrary value to eliminate the compiler warning
|
||||
// -4 is not a valid return value for __cxa_demangle so we'll use that.
|
||||
int status = -4;
|
||||
|
||||
// __cxa_demangle requires that we free the returned char*
|
||||
std::unique_ptr<char, void (*)(void*)> res{
|
||||
abi::__cxa_demangle(name, NULL, NULL, &status),
|
||||
std::free
|
||||
};
|
||||
|
||||
return (status == 0) ? res.get() : "";
|
||||
}
|
||||
|
||||
#else // __GNUG__
|
||||
|
||||
// does nothing if not g++
|
||||
std::string Demangler::Demangle(const char* name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
#endif // __GNUG__
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Demangler {
|
||||
// Given a char* containing a mangled name, return a std::string containing the demangled name.
|
||||
// If the function fails for any reason, it returns an empty string.
|
||||
std::string Demangle(const char* name);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ static void ErrorCallback(void* data, const char* msg, int errnum) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "Demangler.h"
|
||||
#include "Type.h"
|
||||
|
||||
void GenerateDump() {
|
||||
std::string cmd = "sudo gcore " + std::to_string(getpid());
|
||||
@@ -122,43 +122,41 @@ void CatchUnhandled(int sig) {
|
||||
if (Diagnostics::GetProduceMemoryDump()) {
|
||||
GenerateDump();
|
||||
}
|
||||
constexpr uint8_t MaxStackTrace = 32;
|
||||
void* array[MaxStackTrace];
|
||||
|
||||
void* array[10];
|
||||
size_t size;
|
||||
|
||||
// get void*'s for all entries on the stack
|
||||
size = backtrace(array, MaxStackTrace);
|
||||
size = backtrace(array, 10);
|
||||
|
||||
# if defined(__GNUG__)
|
||||
#if defined(__GNUG__) and defined(__dynamic)
|
||||
|
||||
// Loop through the returned addresses, and get the symbols to be demangled
|
||||
char** strings = backtrace_symbols(array, size);
|
||||
|
||||
// Print the stack trace
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
// Take a string like './WorldServer(_ZN19SlashCommandHandler17HandleChatCommandERKSbIDsSt11char_traitsIDsESaIDsEEP6EntityRK13SystemAddress+0x6187) [0x55869c44ecf7]'
|
||||
// and extract '_ZN19SlashCommandHandler17HandleChatCommandERKSbIDsSt11char_traitsIDsESaIDsEEP6EntityRK13SystemAddress' from it to be demangled into a proper name
|
||||
// Take a string like './WorldServer(_ZN19SlashCommandHandler17HandleChatCommandERKSbIDsSt11char_traitsIDsESaIDsEEP6EntityRK13SystemAddress+0x6187) [0x55869c44ecf7]' and extract the function name
|
||||
std::string functionName = strings[i];
|
||||
std::string::size_type start = functionName.find('(');
|
||||
std::string::size_type end = functionName.find('+');
|
||||
if (start != std::string::npos && end != std::string::npos) {
|
||||
std::string demangled = functionName.substr(start + 1, end - start - 1);
|
||||
|
||||
demangled = Demangler::Demangle(demangled.c_str());
|
||||
|
||||
// If the demangled string is not empty, then we can replace the mangled string with the demangled one
|
||||
if (!demangled.empty()) {
|
||||
demangled.push_back('(');
|
||||
demangled += functionName.substr(end);
|
||||
functionName = demangled;
|
||||
}
|
||||
}
|
||||
demangled = demangle(functionName.c_str());
|
||||
|
||||
if (demangled.empty()) {
|
||||
Game::logger->Log("Diagnostics", "[%02zu] %s", i, demangled.c_str());
|
||||
} else {
|
||||
Game::logger->Log("Diagnostics", "[%02zu] %s", i, functionName.c_str());
|
||||
}
|
||||
# else // defined(__GNUG__)
|
||||
} else {
|
||||
Game::logger->Log("Diagnostics", "[%02zu] %s", i, functionName.c_str());
|
||||
}
|
||||
}
|
||||
#else
|
||||
backtrace_symbols_fd(array, size, STDOUT_FILENO);
|
||||
# endif // defined(__GNUG__)
|
||||
#endif
|
||||
|
||||
FILE* file = fopen(fileName.c_str(), "w+");
|
||||
if (file != NULL) {
|
||||
@@ -168,7 +166,7 @@ void CatchUnhandled(int sig) {
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
#else // __include_backtrace__
|
||||
#else
|
||||
|
||||
struct backtrace_state* state = backtrace_create_state(
|
||||
Diagnostics::GetProcessFileName().c_str(),
|
||||
@@ -179,7 +177,7 @@ void CatchUnhandled(int sig) {
|
||||
struct bt_ctx ctx = { state, 0 };
|
||||
Bt(state);
|
||||
|
||||
#endif // __include_backtrace__
|
||||
#endif
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -126,11 +126,6 @@ namespace GeneralUtils {
|
||||
template <typename T>
|
||||
T Parse(const char* value);
|
||||
|
||||
template <>
|
||||
inline bool Parse(const char* value) {
|
||||
return std::stoi(value);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline int32_t Parse(const char* value) {
|
||||
return std::stoi(value);
|
||||
|
||||
@@ -61,33 +61,35 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) {
|
||||
}
|
||||
|
||||
case LDF_TYPE_S32: {
|
||||
int32_t data;
|
||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
||||
try {
|
||||
int32_t data = static_cast<int32_t>(strtoul(ldfTypeAndValue.second.data(), &storage, 10));
|
||||
returnValue = new LDFData<int32_t>(key, data);
|
||||
} catch (std::exception) {
|
||||
Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid int32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||
return nullptr;
|
||||
}
|
||||
returnValue = new LDFData<int32_t>(key, data);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case LDF_TYPE_FLOAT: {
|
||||
float data;
|
||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
||||
try {
|
||||
float data = strtof(ldfTypeAndValue.second.data(), &storage);
|
||||
returnValue = new LDFData<float>(key, data);
|
||||
} catch (std::exception) {
|
||||
Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid float value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||
return nullptr;
|
||||
}
|
||||
returnValue = new LDFData<float>(key, data);
|
||||
break;
|
||||
}
|
||||
|
||||
case LDF_TYPE_DOUBLE: {
|
||||
double data;
|
||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
||||
try {
|
||||
double data = strtod(ldfTypeAndValue.second.data(), &storage);
|
||||
returnValue = new LDFData<double>(key, data);
|
||||
} catch (std::exception) {
|
||||
Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid double value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||
return nullptr;
|
||||
}
|
||||
returnValue = new LDFData<double>(key, data);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -100,7 +102,9 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) {
|
||||
} else if (ldfTypeAndValue.second == "false") {
|
||||
data = 0;
|
||||
} else {
|
||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
||||
try {
|
||||
data = static_cast<uint32_t>(strtoul(ldfTypeAndValue.second.data(), &storage, 10));
|
||||
} catch (std::exception) {
|
||||
Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid uint32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||
return nullptr;
|
||||
}
|
||||
@@ -118,7 +122,9 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) {
|
||||
} else if (ldfTypeAndValue.second == "false") {
|
||||
data = false;
|
||||
} else {
|
||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
||||
try {
|
||||
data = static_cast<bool>(strtol(ldfTypeAndValue.second.data(), &storage, 10));
|
||||
} catch (std::exception) {
|
||||
Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid bool value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||
return nullptr;
|
||||
}
|
||||
@@ -129,22 +135,24 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) {
|
||||
}
|
||||
|
||||
case LDF_TYPE_U64: {
|
||||
uint64_t data;
|
||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
||||
try {
|
||||
uint64_t data = static_cast<uint64_t>(strtoull(ldfTypeAndValue.second.data(), &storage, 10));
|
||||
returnValue = new LDFData<uint64_t>(key, data);
|
||||
} catch (std::exception) {
|
||||
Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid uint64 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||
return nullptr;
|
||||
}
|
||||
returnValue = new LDFData<uint64_t>(key, data);
|
||||
break;
|
||||
}
|
||||
|
||||
case LDF_TYPE_OBJID: {
|
||||
LWOOBJID data;
|
||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
||||
try {
|
||||
LWOOBJID data = static_cast<LWOOBJID>(strtoll(ldfTypeAndValue.second.data(), &storage, 10));
|
||||
returnValue = new LDFData<LWOOBJID>(key, data);
|
||||
} catch (std::exception) {
|
||||
Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid LWOOBJID value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||
return nullptr;
|
||||
}
|
||||
returnValue = new LDFData<LWOOBJID>(key, data);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,13 +136,6 @@ NiPoint3& NiPoint3::operator+=(const NiPoint3& point) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
NiPoint3& NiPoint3::operator*=(const float scalar) {
|
||||
this->x *= scalar;
|
||||
this->y *= scalar;
|
||||
this->z *= scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Operator for subtraction of vectors
|
||||
NiPoint3 NiPoint3::operator-(const NiPoint3& point) const {
|
||||
return NiPoint3(this->x - point.x, this->y - point.y, this->z - point.z);
|
||||
|
||||
@@ -138,8 +138,6 @@ public:
|
||||
//! Operator for addition of vectors
|
||||
NiPoint3& operator+=(const NiPoint3& point);
|
||||
|
||||
NiPoint3& operator*=(const float scalar);
|
||||
|
||||
//! Operator for subtraction of vectors
|
||||
NiPoint3 operator-(const NiPoint3& point) const;
|
||||
|
||||
|
||||
27
dCommon/Type.cpp
Normal file
27
dCommon/Type.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "Type.h"
|
||||
#ifdef __GNUG__
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <cxxabi.h>
|
||||
|
||||
std::string demangle(const char* name) {
|
||||
|
||||
int status = -4; // some arbitrary value to eliminate the compiler warning
|
||||
|
||||
// enable c++11 by passing the flag -std=c++11 to g++
|
||||
std::unique_ptr<char, void(*)(void*)> res{
|
||||
abi::__cxa_demangle(name, NULL, NULL, &status),
|
||||
std::free
|
||||
};
|
||||
|
||||
return (status == 0) ? res.get() : name;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// does nothing if not g++
|
||||
std::string demangle(const char* name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
#endif
|
||||
12
dCommon/Type.h
Normal file
12
dCommon/Type.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
|
||||
std::string demangle(const char* name);
|
||||
|
||||
template <class T>
|
||||
std::string type(const T& t) {
|
||||
|
||||
return demangle(typeid(t).name());
|
||||
}
|
||||
@@ -42,7 +42,7 @@ struct AssetMemoryBuffer : std::streambuf {
|
||||
}
|
||||
|
||||
void close() {
|
||||
free(m_Base);
|
||||
delete m_Base;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "BitStream.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eClientMessageType.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "BitstreamUtils.h"
|
||||
|
||||
#pragma warning (disable:4251) //Disables SQL warnings
|
||||
|
||||
@@ -33,7 +33,7 @@ constexpr uint32_t lowFrameDelta = FRAMES_TO_MS(lowFramerate);
|
||||
#define CBITSTREAM RakNet::BitStream bitStream;
|
||||
#define CINSTREAM RakNet::BitStream inStream(packet->data, packet->length, false);
|
||||
#define CINSTREAM_SKIP_HEADER CINSTREAM if (inStream.GetNumberOfUnreadBits() >= BYTES_TO_BITS(HEADER_SIZE)) inStream.IgnoreBytes(HEADER_SIZE); else inStream.IgnoreBits(inStream.GetNumberOfUnreadBits());
|
||||
#define CMSGHEADER BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
#define CMSGHEADER BitstreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
#define SEND_PACKET Game::server->Send(&bitStream, sysAddr, false);
|
||||
#define SEND_PACKET_BROADCAST Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||
|
||||
|
||||
@@ -1152,7 +1152,7 @@ enum class eGameMessageType : uint16_t {
|
||||
COLLISION_POINT_REMOVED = 1269,
|
||||
SET_ATTACHED = 1270,
|
||||
SET_DESTROYABLE_MODEL_BRICKS = 1271,
|
||||
VEHICLE_SET_POWERSLIDE_LOCK_WHEELS = 1272,
|
||||
VEHICLE_SET_POWERSLIDE_LOCK_WHEELS = 1273,
|
||||
VEHICLE_SET_WHEEL_LOCK_STATE = 1273,
|
||||
SHOW_HEALTH_BAR = 1274,
|
||||
GET_SHOWS_HEALTH_BAR = 1275,
|
||||
|
||||
@@ -101,7 +101,7 @@ enum class eReplicaComponentType : uint32_t {
|
||||
TRADE,
|
||||
USER_CONTROL,
|
||||
IGNORE_LIST,
|
||||
MULTI_ZONE_ENTRANCE,
|
||||
ROCKET_LAUNCH_LUP,
|
||||
BUFF_REAL, // the real buff component, should just be name BUFF
|
||||
INTERACTION_MANAGER,
|
||||
DONATION_VENDOR,
|
||||
|
||||
48
dCommon/dEnums/eStamps.h
Normal file
48
dCommon/dEnums/eStamps.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef __ESTAMPS__H__
|
||||
#define __ESTAMPS__H__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum class eStamps : uint32_t {
|
||||
PASSPORT_AUTH_START,
|
||||
PASSPORT_AUTH_BYPASS,
|
||||
PASSPORT_AUTH_ERROR,
|
||||
PASSPORT_AUTH_DB_SELECT_START,
|
||||
PASSPORT_AUTH_DB_SELECT_FINISH,
|
||||
PASSPORT_AUTH_DB_INSERT_START,
|
||||
PASSPORT_AUTH_DB_INSERT_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_LEGOINT_RECEIVED,
|
||||
PASSPORT_AUTH_LEGOINT_THREAD_SPAWN,
|
||||
PASSPORT_AUTH_LEGOINT_WEBSERVICE_START,
|
||||
PASSPORT_AUTH_LEGOINT_WEBSERVICE_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_LEGOCLUB_START,
|
||||
PASSPORT_AUTH_LEGOINT_LEGOCLUB_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_THREAD_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_REPLY,
|
||||
PASSPORT_AUTH_LEGOINT_ERROR,
|
||||
PASSPORT_AUTH_LEGOINT_COMMUNICATION_END,
|
||||
PASSPORT_AUTH_LEGOINT_DISCONNECT,
|
||||
PASSPORT_AUTH_WORLD_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_CLIENT_OS,
|
||||
PASSPORT_AUTH_WORLD_PACKET_RECEIVED,
|
||||
PASSPORT_AUTH_IM_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_IM_LOGIN_START,
|
||||
PASSPORT_AUTH_IM_LOGIN_ALREADY_LOGGED_IN,
|
||||
PASSPORT_AUTH_IM_OTHER_LOGIN_REMOVED,
|
||||
PASSPORT_AUTH_IM_LOGIN_QUEUED,
|
||||
PASSPORT_AUTH_IM_LOGIN_RESPONSE,
|
||||
PASSPORT_AUTH_IM_COMMUNICATION_END,
|
||||
PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH,
|
||||
PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH,
|
||||
PASSPORT_AUTH_WORLD_DISCONNECT,
|
||||
NO_LEGO_INTERFACE,
|
||||
DB_ERROR,
|
||||
GM_REQUIRED,
|
||||
NO_LEGO_WEBSERVICE_XML,
|
||||
LEGO_WEBSERVICE_TIMEOUT,
|
||||
LEGO_WEBSERVICE_ERROR,
|
||||
NO_WORLD_SERVER
|
||||
};
|
||||
|
||||
#endif //!__ESTAMPS__H__
|
||||
@@ -13,6 +13,14 @@
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
// Enable this to cache all entries in each table for fast access, comes with more memory cost
|
||||
//#define CDCLIENT_CACHE_ALL
|
||||
|
||||
/*!
|
||||
\file CDClientDatabase.hpp
|
||||
\brief An interface between the CDClient.sqlite file and the server
|
||||
*/
|
||||
|
||||
//! The CDClient Database namespace
|
||||
namespace CDClientDatabase {
|
||||
|
||||
|
||||
@@ -38,53 +38,43 @@
|
||||
#include "CDFeatureGatingTable.h"
|
||||
#include "CDRailActivatorComponent.h"
|
||||
|
||||
// Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory.
|
||||
// A vanilla CDClient takes about 46MB of memory + the regular world data.
|
||||
// #define CDCLIENT_CACHE_ALL
|
||||
|
||||
#ifdef CDCLIENT_CACHE_ALL
|
||||
#define CDCLIENT_DONT_CACHE_TABLE(x) x
|
||||
#else
|
||||
#define CDCLIENT_DONT_CACHE_TABLE(x)
|
||||
#endif
|
||||
|
||||
CDClientManager::CDClientManager() {
|
||||
CDActivityRewardsTable::Instance().LoadValuesFromDatabase();
|
||||
CDActivitiesTable::Instance().LoadValuesFromDatabase();
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase());
|
||||
CDBehaviorParameterTable::Instance().LoadValuesFromDatabase();
|
||||
CDBehaviorTemplateTable::Instance().LoadValuesFromDatabase();
|
||||
CDBrickIDTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDComponentsRegistryTable::Instance().LoadValuesFromDatabase());
|
||||
CDCurrencyTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDDestructibleComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDEmoteTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDFeatureGatingTable::Instance().LoadValuesFromDatabase();
|
||||
CDInventoryComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDItemComponentTable::Instance().LoadValuesFromDatabase());
|
||||
CDItemSetSkillsTable::Instance().LoadValuesFromDatabase();
|
||||
CDItemSetsTable::Instance().LoadValuesFromDatabase();
|
||||
CDLevelProgressionLookupTable::Instance().LoadValuesFromDatabase();
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDLootMatrixTable::Instance().LoadValuesFromDatabase());
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDLootTableTable::Instance().LoadValuesFromDatabase());
|
||||
CDMissionEmailTable::Instance().LoadValuesFromDatabase();
|
||||
CDMissionNPCComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDMissionTasksTable::Instance().LoadValuesFromDatabase();
|
||||
CDMissionsTable::Instance().LoadValuesFromDatabase();
|
||||
CDMovementAIComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDObjectSkillsTable::Instance().LoadValuesFromDatabase();
|
||||
CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase());
|
||||
CDPhysicsComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDPackageComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDPropertyTemplateTable::Instance().LoadValuesFromDatabase();
|
||||
CDRailActivatorComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDRarityTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDRebuildComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDRewardsTable::Instance().LoadValuesFromDatabase();
|
||||
CDScriptComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDSkillBehaviorTable::Instance().LoadValuesFromDatabase();
|
||||
CDVendorComponentTable::Instance().LoadValuesFromDatabase();
|
||||
CDZoneTableTable::Instance().LoadValuesFromDatabase();
|
||||
CDActivityRewardsTable::Instance();
|
||||
CDAnimationsTable::Instance();
|
||||
CDBehaviorParameterTable::Instance();
|
||||
CDBehaviorTemplateTable::Instance();
|
||||
CDComponentsRegistryTable::Instance();
|
||||
CDCurrencyTableTable::Instance();
|
||||
CDDestructibleComponentTable::Instance();
|
||||
CDEmoteTableTable::Instance();
|
||||
CDInventoryComponentTable::Instance();
|
||||
CDItemComponentTable::Instance();
|
||||
CDItemSetsTable::Instance();
|
||||
CDItemSetSkillsTable::Instance();
|
||||
CDLevelProgressionLookupTable::Instance();
|
||||
CDLootMatrixTable::Instance();
|
||||
CDLootTableTable::Instance();
|
||||
CDMissionNPCComponentTable::Instance();
|
||||
CDMissionTasksTable::Instance();
|
||||
CDMissionsTable::Instance();
|
||||
CDObjectSkillsTable::Instance();
|
||||
CDObjectsTable::Instance();
|
||||
CDPhysicsComponentTable::Instance();
|
||||
CDRebuildComponentTable::Instance();
|
||||
CDScriptComponentTable::Instance();
|
||||
CDSkillBehaviorTable::Instance();
|
||||
CDZoneTableTable::Instance();
|
||||
CDVendorComponentTable::Instance();
|
||||
CDActivitiesTable::Instance();
|
||||
CDPackageComponentTable::Instance();
|
||||
CDProximityMonitorComponentTable::Instance();
|
||||
CDMovementAIComponentTable::Instance();
|
||||
CDBrickIDTableTable::Instance();
|
||||
CDRarityTableTable::Instance();
|
||||
CDMissionEmailTable::Instance();
|
||||
CDRewardsTable::Instance();
|
||||
CDPropertyEntranceComponentTable::Instance();
|
||||
CDPropertyTemplateTable::Instance();
|
||||
CDFeatureGatingTable::Instance();
|
||||
CDRailActivatorComponentTable::Instance();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDActivitiesTable.h"
|
||||
|
||||
void CDActivitiesTable::LoadValuesFromDatabase() {
|
||||
CDActivitiesTable::CDActivitiesTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities");
|
||||
@@ -54,3 +55,8 @@ std::vector<CDActivities> CDActivitiesTable::Query(std::function<bool(CDActiviti
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDActivities> CDActivitiesTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,9 @@ private:
|
||||
std::vector<CDActivities> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
CDActivitiesTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDActivities> Query(std::function<bool(CDActivities)> predicate);
|
||||
|
||||
const std::vector<CDActivities>& GetEntries() const { return this->entries; }
|
||||
std::vector<CDActivities> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "CDActivityRewardsTable.h"
|
||||
|
||||
void CDActivityRewardsTable::LoadValuesFromDatabase() {
|
||||
CDActivityRewardsTable::CDActivityRewardsTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -43,3 +43,8 @@ std::vector<CDActivityRewards> CDActivityRewardsTable::Query(std::function<bool(
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<CDActivityRewards> CDActivityRewardsTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ private:
|
||||
std::vector<CDActivityRewards> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDActivityRewardsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDActivityRewards> Query(std::function<bool(CDActivityRewards)> predicate);
|
||||
|
||||
std::vector<CDActivityRewards> GetEntries() const;
|
||||
std::vector<CDActivityRewards> GetEntries(void) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -2,35 +2,6 @@
|
||||
#include "GeneralUtils.h"
|
||||
#include "Game.h"
|
||||
|
||||
|
||||
void CDAnimationsTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Animations");
|
||||
while (!tableData.eof()) {
|
||||
std::string animation_type = tableData.getStringField("animation_type", "");
|
||||
DluAssert(!animation_type.empty());
|
||||
AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1);
|
||||
DluAssert(animationGroupID != -1);
|
||||
|
||||
CDAnimation entry;
|
||||
entry.animation_name = tableData.getStringField("animation_name", "");
|
||||
entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f);
|
||||
UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);)
|
||||
UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);)
|
||||
entry.animation_length = tableData.getFloatField("animation_length", 0.0f);
|
||||
UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;)
|
||||
UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", "");)
|
||||
UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);)
|
||||
UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);)
|
||||
|
||||
this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) {
|
||||
auto tableData = queryToCache.execQuery();
|
||||
// If we received a bad lookup, cache it anyways so we do not run the query again.
|
||||
|
||||
@@ -27,7 +27,6 @@ class CDAnimationsTable : public CDTable<CDAnimationsTable> {
|
||||
typedef std::string AnimationID;
|
||||
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
/**
|
||||
* Given an animationType and the previousAnimationName played, return the next animationType to play.
|
||||
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#include "CDBehaviorParameterTable.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
uint64_t GetKey(const uint32_t behaviorID, const uint32_t parameterID) {
|
||||
uint64_t key = behaviorID;
|
||||
key <<= 31U;
|
||||
key |= parameterID;
|
||||
uint64_t GetHash(const uint32_t behaviorID, const uint32_t parameterID) {
|
||||
uint64_t hash = behaviorID;
|
||||
hash <<= 31U;
|
||||
hash |= parameterID;
|
||||
|
||||
return key;
|
||||
return hash;
|
||||
}
|
||||
|
||||
void CDBehaviorParameterTable::LoadValuesFromDatabase() {
|
||||
CDBehaviorParameterTable::CDBehaviorParameterTable() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter");
|
||||
while (!tableData.eof()) {
|
||||
uint32_t behaviorID = tableData.getIntField("behaviorID", -1);
|
||||
@@ -21,7 +21,7 @@ void CDBehaviorParameterTable::LoadValuesFromDatabase() {
|
||||
} else {
|
||||
parameterId = m_ParametersList.insert(std::make_pair(candidateStringToAdd, m_ParametersList.size())).first->second;
|
||||
}
|
||||
uint64_t hash = GetKey(behaviorID, parameterId);
|
||||
uint64_t hash = GetHash(behaviorID, parameterId);
|
||||
float value = tableData.getFloatField("value", -1.0f);
|
||||
|
||||
m_Entries.insert(std::make_pair(hash, value));
|
||||
@@ -34,7 +34,7 @@ void CDBehaviorParameterTable::LoadValuesFromDatabase() {
|
||||
float CDBehaviorParameterTable::GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue) {
|
||||
auto parameterID = this->m_ParametersList.find(name);
|
||||
if (parameterID == this->m_ParametersList.end()) return defaultValue;
|
||||
auto hash = GetKey(behaviorID, parameterID->second);
|
||||
auto hash = GetHash(behaviorID, parameterID->second);
|
||||
|
||||
// Search for specific parameter
|
||||
auto it = m_Entries.find(hash);
|
||||
@@ -45,7 +45,7 @@ std::map<std::string, float> CDBehaviorParameterTable::GetParametersByBehaviorID
|
||||
uint64_t hashBase = behaviorID;
|
||||
std::map<std::string, float> returnInfo;
|
||||
for (auto& [parameterString, parameterId] : m_ParametersList) {
|
||||
uint64_t hash = GetKey(hashBase, parameterId);
|
||||
uint64_t hash = GetHash(hashBase, parameterId);
|
||||
auto infoCandidate = m_Entries.find(hash);
|
||||
if (infoCandidate != m_Entries.end()) {
|
||||
returnInfo.insert(std::make_pair(parameterString, infoCandidate->second));
|
||||
|
||||
@@ -12,7 +12,7 @@ private:
|
||||
std::unordered_map<BehaviorParameterHash, BehaviorParameterValue> m_Entries;
|
||||
std::unordered_map<std::string, uint32_t> m_ParametersList;
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDBehaviorParameterTable();
|
||||
|
||||
float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "CDBehaviorTemplateTable.h"
|
||||
|
||||
void CDBehaviorTemplateTable::LoadValuesFromDatabase() {
|
||||
CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -48,7 +48,7 @@ std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::Query(std::function<boo
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDBehaviorTemplate>& CDBehaviorTemplateTable::GetEntries() const {
|
||||
std::vector<CDBehaviorTemplate> CDBehaviorTemplateTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
@@ -64,3 +64,4 @@ const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behav
|
||||
return entry->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,11 @@ private:
|
||||
std::unordered_map<uint32_t, CDBehaviorTemplate> entriesMappedByBehaviorID;
|
||||
std::unordered_set<std::string> m_EffectHandles;
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
CDBehaviorTemplateTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDBehaviorTemplate> Query(std::function<bool(CDBehaviorTemplate)> predicate);
|
||||
|
||||
const std::vector<CDBehaviorTemplate>& GetEntries(void) const;
|
||||
std::vector<CDBehaviorTemplate> GetEntries(void) const;
|
||||
|
||||
const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "CDBrickIDTableTable.h"
|
||||
|
||||
void CDBrickIDTableTable::LoadValuesFromDatabase() {
|
||||
CDBrickIDTableTable::CDBrickIDTableTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -39,7 +39,7 @@ std::vector<CDBrickIDTable> CDBrickIDTableTable::Query(std::function<bool(CDBric
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDBrickIDTable>& CDBrickIDTableTable::GetEntries() const {
|
||||
std::vector<CDBrickIDTable> CDBrickIDTableTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ private:
|
||||
std::vector<CDBrickIDTable> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDBrickIDTableTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDBrickIDTable> Query(std::function<bool(CDBrickIDTable)> predicate);
|
||||
|
||||
const std::vector<CDBrickIDTable>& GetEntries() const;
|
||||
std::vector<CDBrickIDTable> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
void CDComponentsRegistryTable::LoadValuesFromDatabase() {
|
||||
#define CDCLIENT_CACHE_ALL
|
||||
|
||||
CDComponentsRegistryTable::CDComponentsRegistryTable(void) {
|
||||
|
||||
#ifdef CDCLIENT_CACHE_ALL
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ComponentsRegistry");
|
||||
while (!tableSize.eof()) {
|
||||
size = tableSize.getIntField(0, 0);
|
||||
|
||||
tableSize.nextRow();
|
||||
}
|
||||
|
||||
tableSize.finalize();
|
||||
|
||||
// Reserve the size
|
||||
//this->entries.reserve(size);
|
||||
|
||||
// Now get the data
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry");
|
||||
while (!tableData.eof()) {
|
||||
@@ -11,42 +29,65 @@ void CDComponentsRegistryTable::LoadValuesFromDatabase() {
|
||||
entry.component_id = tableData.getIntField("component_id", -1);
|
||||
|
||||
this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id);
|
||||
this->mappedEntries.insert_or_assign(entry.id, 0);
|
||||
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) {
|
||||
auto exists = mappedEntries.find(id);
|
||||
if (exists != mappedEntries.end()) {
|
||||
auto iter = mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||
return iter == mappedEntries.end() ? defaultValue : iter->second;
|
||||
const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||
|
||||
if (iter == this->mappedEntries.end()) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
// Now get the data. Get all components of this entity so we dont do a query for each component
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ComponentsRegistry WHERE id = ?;");
|
||||
query.bind(1, static_cast<int32_t>(id));
|
||||
return iter->second;
|
||||
|
||||
auto tableData = query.execQuery();
|
||||
#ifndef CDCLIENT_CACHE_ALL
|
||||
// Now get the data
|
||||
std::stringstream query;
|
||||
|
||||
query << "SELECT * FROM ComponentsRegistry WHERE id = " << std::to_string(id);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||
while (!tableData.eof()) {
|
||||
CDComponentsRegistry entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.component_type = static_cast<eReplicaComponentType>(tableData.getIntField("component_type", 0));
|
||||
entry.component_type = tableData.getIntField("component_type", -1);
|
||||
entry.component_id = tableData.getIntField("component_id", -1);
|
||||
|
||||
this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id);
|
||||
//this->entries.push_back(entry);
|
||||
|
||||
//Darwin's stuff:
|
||||
const auto& it = this->mappedEntries.find(entry.id);
|
||||
if (it != mappedEntries.end()) {
|
||||
const auto& iter = it->second.find(entry.component_type);
|
||||
if (iter == it->second.end()) {
|
||||
it->second.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||
}
|
||||
} else {
|
||||
std::map<unsigned int, unsigned int> map;
|
||||
map.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||
this->mappedEntries.insert(std::make_pair(entry.id, map));
|
||||
}
|
||||
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
mappedEntries.insert_or_assign(id, 0);
|
||||
tableData.finalize();
|
||||
|
||||
auto iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||
|
||||
return iter == this->mappedEntries.end() ? defaultValue : iter->second;
|
||||
const auto& it2 = this->mappedEntries.find(id);
|
||||
if (it2 != mappedEntries.end()) {
|
||||
const auto& iter = it2->second.find(componentType);
|
||||
if (iter != it2->second.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ struct CDComponentsRegistry {
|
||||
|
||||
class CDComponentsRegistryTable : public CDTable<CDComponentsRegistryTable> {
|
||||
private:
|
||||
std::unordered_map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
|
||||
std::map<uint64_t, uint32_t> mappedEntries; //id, component_type, component_id
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDComponentsRegistryTable();
|
||||
int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "CDCurrencyTableTable.h"
|
||||
|
||||
//! Constructor
|
||||
void CDCurrencyTableTable::LoadValuesFromDatabase() {
|
||||
CDCurrencyTableTable::CDCurrencyTableTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -43,7 +43,7 @@ std::vector<CDCurrencyTable> CDCurrencyTableTable::Query(std::function<bool(CDCu
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDCurrencyTable>& CDCurrencyTableTable::GetEntries() const {
|
||||
std::vector<CDCurrencyTable> CDCurrencyTableTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ private:
|
||||
std::vector<CDCurrencyTable> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDCurrencyTableTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDCurrencyTable> Query(std::function<bool(CDCurrencyTable)> predicate);
|
||||
|
||||
const std::vector<CDCurrencyTable>& GetEntries() const;
|
||||
std::vector<CDCurrencyTable> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "CDDestructibleComponentTable.h"
|
||||
|
||||
void CDDestructibleComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDDestructibleComponentTable::CDDestructibleComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM DestructibleComponent");
|
||||
@@ -50,7 +52,7 @@ std::vector<CDDestructibleComponent> CDDestructibleComponentTable::Query(std::fu
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDDestructibleComponent>& CDDestructibleComponentTable::GetEntries() const {
|
||||
std::vector<CDDestructibleComponent> CDDestructibleComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ private:
|
||||
std::vector<CDDestructibleComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDDestructibleComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDDestructibleComponent> Query(std::function<bool(CDDestructibleComponent)> predicate);
|
||||
|
||||
const std::vector<CDDestructibleComponent>& GetEntries(void) const;
|
||||
std::vector<CDDestructibleComponent> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,26 +1,40 @@
|
||||
#include "CDEmoteTable.h"
|
||||
|
||||
void CDEmoteTableTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDEmoteTableTable::CDEmoteTableTable(void) {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes");
|
||||
while (!tableData.eof()) {
|
||||
CDEmoteTable entry;
|
||||
entry.ID = tableData.getIntField("id", -1);
|
||||
entry.animationName = tableData.getStringField("animationName", "");
|
||||
entry.iconFilename = tableData.getStringField("iconFilename", "");
|
||||
entry.channel = tableData.getIntField("channel", -1);
|
||||
entry.locked = tableData.getIntField("locked", -1) != 0;
|
||||
entry.localize = tableData.getIntField("localize", -1) != 0;
|
||||
entry.locState = tableData.getIntField("locStatus", -1);
|
||||
entry.gateVersion = tableData.getStringField("gate_version", "");
|
||||
CDEmoteTable* entry = new CDEmoteTable();
|
||||
entry->ID = tableData.getIntField("id", -1);
|
||||
entry->animationName = tableData.getStringField("animationName", "");
|
||||
entry->iconFilename = tableData.getStringField("iconFilename", "");
|
||||
entry->channel = tableData.getIntField("channel", -1);
|
||||
entry->locked = tableData.getIntField("locked", -1) != 0;
|
||||
entry->localize = tableData.getIntField("localize", -1) != 0;
|
||||
entry->locState = tableData.getIntField("locStatus", -1);
|
||||
entry->gateVersion = tableData.getStringField("gate_version", "");
|
||||
|
||||
entries.insert(std::make_pair(entry.ID, entry));
|
||||
entries.insert(std::make_pair(entry->ID, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
|
||||
auto itr = entries.find(id);
|
||||
return itr != entries.end() ? &itr->second : nullptr;
|
||||
//! Destructor
|
||||
CDEmoteTableTable::~CDEmoteTableTable(void) {
|
||||
for (auto e : entries) {
|
||||
if (e.second) delete e.second;
|
||||
}
|
||||
|
||||
entries.clear();
|
||||
}
|
||||
|
||||
CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
|
||||
for (auto e : entries) {
|
||||
if (e.first == id) return e.second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,11 @@ struct CDEmoteTable {
|
||||
|
||||
class CDEmoteTableTable : public CDTable<CDEmoteTableTable> {
|
||||
private:
|
||||
std::map<int, CDEmoteTable> entries;
|
||||
std::map<int, CDEmoteTable*> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDEmoteTableTable();
|
||||
~CDEmoteTableTable();
|
||||
// Returns an emote by ID
|
||||
CDEmoteTable* GetEmote(int id);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDFeatureGatingTable.h"
|
||||
|
||||
void CDFeatureGatingTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDFeatureGatingTable::CDFeatureGatingTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -52,7 +53,7 @@ bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<CDFeatureGating>& CDFeatureGatingTable::GetEntries() const {
|
||||
std::vector<CDFeatureGating> CDFeatureGatingTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@ private:
|
||||
std::vector<CDFeatureGating> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
CDFeatureGatingTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDFeatureGating> Query(std::function<bool(CDFeatureGating)> predicate);
|
||||
|
||||
bool FeatureUnlocked(const std::string& feature) const;
|
||||
|
||||
const std::vector<CDFeatureGating>& GetEntries(void) const;
|
||||
std::vector<CDFeatureGating> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDInventoryComponentTable.h"
|
||||
|
||||
void CDInventoryComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDInventoryComponentTable::CDInventoryComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -41,7 +42,7 @@ std::vector<CDInventoryComponent> CDInventoryComponentTable::Query(std::function
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDInventoryComponent>& CDInventoryComponentTable::GetEntries() const {
|
||||
std::vector<CDInventoryComponent> CDInventoryComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ private:
|
||||
std::vector<CDInventoryComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDInventoryComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDInventoryComponent> Query(std::function<bool(CDInventoryComponent)> predicate);
|
||||
|
||||
const std::vector<CDInventoryComponent>& GetEntries() const;
|
||||
std::vector<CDInventoryComponent> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
|
||||
CDItemComponent CDItemComponentTable::Default = {};
|
||||
|
||||
void CDItemComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDItemComponentTable::CDItemComponentTable(void) {
|
||||
Default = CDItemComponent();
|
||||
|
||||
#ifdef CDCLIENT_CACHE_ALL
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent");
|
||||
@@ -51,13 +55,13 @@ void CDItemComponentTable::LoadValuesFromDatabase() {
|
||||
entry.currencyLOT = tableData.getIntField("currencyLOT", -1);
|
||||
entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1);
|
||||
entry.subItems = tableData.getStringField("subItems", "");
|
||||
UNUSED_COLUMN(entry.audioEventUse = tableData.getStringField("audioEventUse", ""));
|
||||
entry.audioEventUse = tableData.getStringField("audioEventUse", "");
|
||||
entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false;
|
||||
entry.commendationLOT = tableData.getIntField("commendationLOT", -1);
|
||||
entry.commendationCost = tableData.getIntField("commendationCost", -1);
|
||||
UNUSED_COLUMN(entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", ""));
|
||||
entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", "");
|
||||
entry.currencyCosts = tableData.getStringField("currencyCosts", "");
|
||||
UNUSED_COLUMN(entry.ingredientInfo = tableData.getStringField("ingredientInfo", ""));
|
||||
entry.ingredientInfo = tableData.getStringField("ingredientInfo", "");
|
||||
entry.locStatus = tableData.getIntField("locStatus", -1);
|
||||
entry.forgeType = tableData.getIntField("forgeType", -1);
|
||||
entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f);
|
||||
@@ -67,6 +71,7 @@ void CDItemComponentTable::LoadValuesFromDatabase() {
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
#endif
|
||||
}
|
||||
|
||||
const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) {
|
||||
@@ -75,10 +80,12 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
|
||||
return it->second;
|
||||
}
|
||||
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ItemComponent WHERE id = ?;");
|
||||
query.bind(1, static_cast<int32_t>(skillID));
|
||||
#ifndef CDCLIENT_CACHE_ALL
|
||||
std::stringstream query;
|
||||
|
||||
auto tableData = query.execQuery();
|
||||
query << "SELECT * FROM ItemComponent WHERE id = " << std::to_string(skillID);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||
if (tableData.eof()) {
|
||||
entries.insert(std::make_pair(skillID, Default));
|
||||
return Default;
|
||||
@@ -137,6 +144,7 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s
|
||||
if (it2 != this->entries.end()) {
|
||||
return it2->second;
|
||||
}
|
||||
#endif
|
||||
|
||||
return Default;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ private:
|
||||
std::map<unsigned int, CDItemComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDItemComponentTable();
|
||||
static std::map<LOT, uint32_t> ParseCraftingCurrencies(const CDItemComponent& itemComponent);
|
||||
|
||||
// Gets an entry by ID
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDItemSetSkillsTable.h"
|
||||
|
||||
void CDItemSetSkillsTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDItemSetSkillsTable::CDItemSetSkillsTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -40,7 +41,7 @@ std::vector<CDItemSetSkills> CDItemSetSkillsTable::Query(std::function<bool(CDIt
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDItemSetSkills>& CDItemSetSkillsTable::GetEntries() const {
|
||||
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ private:
|
||||
std::vector<CDItemSetSkills> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDItemSetSkillsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDItemSetSkills> Query(std::function<bool(CDItemSetSkills)> predicate);
|
||||
|
||||
const std::vector<CDItemSetSkills>& GetEntries() const;
|
||||
std::vector<CDItemSetSkills> GetEntries(void) const;
|
||||
|
||||
std::vector<CDItemSetSkills> GetBySkillID(unsigned int SkillSetID);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDItemSetsTable.h"
|
||||
|
||||
void CDItemSetsTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDItemSetsTable::CDItemSetsTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -52,7 +53,7 @@ std::vector<CDItemSets> CDItemSetsTable::Query(std::function<bool(CDItemSets)> p
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDItemSets>& CDItemSetsTable::GetEntries() const {
|
||||
std::vector<CDItemSets> CDItemSetsTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ private:
|
||||
std::vector<CDItemSets> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDItemSetsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDItemSets> Query(std::function<bool(CDItemSets)> predicate);
|
||||
|
||||
const std::vector<CDItemSets>& GetEntries(void) const;
|
||||
std::vector<CDItemSets> GetEntries(void) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDLevelProgressionLookupTable.h"
|
||||
|
||||
void CDLevelProgressionLookupTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -31,6 +32,7 @@ void CDLevelProgressionLookupTable::LoadValuesFromDatabase() {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::function<bool(CDLevelProgressionLookup)> predicate) {
|
||||
|
||||
std::vector<CDLevelProgressionLookup> data = cpplinq::from(this->entries)
|
||||
@@ -40,7 +42,8 @@ std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::Query(std::
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDLevelProgressionLookup>& CDLevelProgressionLookupTable::GetEntries() const {
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDLevelProgressionLookup> CDLevelProgressionLookupTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ private:
|
||||
std::vector<CDLevelProgressionLookup> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
CDLevelProgressionLookupTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDLevelProgressionLookup> Query(std::function<bool(CDLevelProgressionLookup)> predicate);
|
||||
|
||||
const std::vector<CDLevelProgressionLookup>& GetEntries() const;
|
||||
// Gets all the entries in the table
|
||||
std::vector<CDLevelProgressionLookup> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
#include "CDLootMatrixTable.h"
|
||||
|
||||
CDLootMatrix CDLootMatrixTable::ReadRow(CppSQLite3Query& tableData) const {
|
||||
CDLootMatrix entry{};
|
||||
if (tableData.eof()) return entry;
|
||||
entry.LootTableIndex = tableData.getIntField("LootTableIndex", -1);
|
||||
entry.RarityTableIndex = tableData.getIntField("RarityTableIndex", -1);
|
||||
entry.percent = tableData.getFloatField("percent", -1.0f);
|
||||
entry.minToDrop = tableData.getIntField("minToDrop", -1);
|
||||
entry.maxToDrop = tableData.getIntField("maxToDrop", -1);
|
||||
entry.flagID = tableData.getIntField("flagID", -1);
|
||||
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
||||
return entry;
|
||||
}
|
||||
|
||||
void CDLootMatrixTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDLootMatrixTable::CDLootMatrixTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -24,6 +12,8 @@ void CDLootMatrixTable::LoadValuesFromDatabase() {
|
||||
tableSize.nextRow();
|
||||
}
|
||||
|
||||
tableSize.finalize();
|
||||
|
||||
// Reserve the size
|
||||
this->entries.reserve(size);
|
||||
|
||||
@@ -31,28 +21,33 @@ void CDLootMatrixTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM LootMatrix");
|
||||
while (!tableData.eof()) {
|
||||
CDLootMatrix entry;
|
||||
uint32_t lootMatrixIndex = tableData.getIntField("LootMatrixIndex", -1);
|
||||
entry.LootMatrixIndex = tableData.getIntField("LootMatrixIndex", -1);
|
||||
entry.LootTableIndex = tableData.getIntField("LootTableIndex", -1);
|
||||
entry.RarityTableIndex = tableData.getIntField("RarityTableIndex", -1);
|
||||
entry.percent = tableData.getFloatField("percent", -1.0f);
|
||||
entry.minToDrop = tableData.getIntField("minToDrop", -1);
|
||||
entry.maxToDrop = tableData.getIntField("maxToDrop", -1);
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.flagID = tableData.getIntField("flagID", -1);
|
||||
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
||||
|
||||
this->entries[lootMatrixIndex].push_back(ReadRow(tableData));
|
||||
tableData.nextRow();
|
||||
}
|
||||
}
|
||||
|
||||
const LootMatrixEntries& CDLootMatrixTable::GetMatrix(uint32_t matrixId) {
|
||||
auto itr = this->entries.find(matrixId);
|
||||
if (itr != this->entries.end()) {
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM LootMatrix where LootMatrixIndex = ?;");
|
||||
query.bind(1, static_cast<int32_t>(matrixId));
|
||||
|
||||
auto tableData = query.execQuery();
|
||||
while (!tableData.eof()) {
|
||||
this->entries[matrixId].push_back(ReadRow(tableData));
|
||||
this->entries.push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
return this->entries[matrixId];
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
std::vector<CDLootMatrix> CDLootMatrixTable::Query(std::function<bool(CDLootMatrix)> predicate) {
|
||||
|
||||
std::vector<CDLootMatrix> data = cpplinq::from(this->entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDLootMatrix>& CDLootMatrixTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,26 +4,26 @@
|
||||
#include "CDTable.h"
|
||||
|
||||
struct CDLootMatrix {
|
||||
unsigned int LootMatrixIndex; //!< The Loot Matrix Index
|
||||
unsigned int LootTableIndex; //!< The Loot Table Index
|
||||
unsigned int RarityTableIndex; //!< The Rarity Table Index
|
||||
float percent; //!< The percent that this matrix is used?
|
||||
unsigned int minToDrop; //!< The minimum amount of loot from this matrix to drop
|
||||
unsigned int maxToDrop; //!< The maximum amount of loot from this matrix to drop
|
||||
unsigned int id; //!< The ID of the Loot Matrix
|
||||
unsigned int flagID; //!< ???
|
||||
UNUSED(std::string gate_version); //!< The Gate Version
|
||||
};
|
||||
|
||||
typedef uint32_t LootMatrixIndex;
|
||||
typedef std::vector<CDLootMatrix> LootMatrixEntries;
|
||||
|
||||
class CDLootMatrixTable : public CDTable<CDLootMatrixTable> {
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Gets a matrix by ID or inserts a blank one if none existed.
|
||||
const LootMatrixEntries& GetMatrix(uint32_t matrixId);
|
||||
private:
|
||||
CDLootMatrix ReadRow(CppSQLite3Query& tableData) const;
|
||||
std::unordered_map<LootMatrixIndex, LootMatrixEntries> entries;
|
||||
std::vector<CDLootMatrix> entries;
|
||||
|
||||
public:
|
||||
CDLootMatrixTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDLootMatrix> Query(std::function<bool(CDLootMatrix)> predicate);
|
||||
|
||||
const std::vector<CDLootMatrix>& GetEntries(void) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,44 +1,7 @@
|
||||
#include "CDLootTableTable.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "CDItemComponentTable.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
// Sort the tables by their rarity so the highest rarity items are first.
|
||||
void SortTable(LootTableEntries& table) {
|
||||
auto* componentsRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
auto* itemComponentTable = CDClientManager::Instance().GetTable<CDItemComponentTable>();
|
||||
// We modify the table in place so the outer loop keeps track of what is sorted
|
||||
// and the inner loop finds the highest rarity item and swaps it with the current position
|
||||
// of the outer loop.
|
||||
for (auto oldItrOuter = table.begin(); oldItrOuter != table.end(); oldItrOuter++) {
|
||||
auto lootToInsert = oldItrOuter;
|
||||
// Its fine if this starts at 0, even if this doesnt match lootToInsert as the actual highest will
|
||||
// either be found and overwrite these values, or the original is somehow zero and is still the highest rarity.
|
||||
uint32_t highestLootRarity = 0;
|
||||
for (auto oldItrInner = oldItrOuter; oldItrInner != table.end(); oldItrInner++) {
|
||||
uint32_t itemComponentId = componentsRegistryTable->GetByIDAndType(oldItrInner->itemid, eReplicaComponentType::ITEM);
|
||||
uint32_t rarity = itemComponentTable->GetItemComponentByID(itemComponentId).rarity;
|
||||
if (rarity > highestLootRarity) {
|
||||
highestLootRarity = rarity;
|
||||
lootToInsert = oldItrInner;
|
||||
}
|
||||
}
|
||||
Game::logger->LogDebug("CDLootTableTable", "highest rarity %i item id %i", highestLootRarity, lootToInsert->itemid);
|
||||
std::swap(*oldItrOuter, *lootToInsert);
|
||||
}
|
||||
}
|
||||
|
||||
CDLootTable CDLootTableTable::ReadRow(CppSQLite3Query& tableData) const {
|
||||
CDLootTable entry{};
|
||||
if (tableData.eof()) return entry;
|
||||
entry.itemid = tableData.getIntField("itemid", -1);
|
||||
entry.MissionDrop = tableData.getIntField("MissionDrop", -1) == 1 ? true : false;
|
||||
entry.sortPriority = tableData.getIntField("sortPriority", -1);
|
||||
return entry;
|
||||
}
|
||||
|
||||
void CDLootTableTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDLootTableTable::CDLootTableTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -49,6 +12,8 @@ void CDLootTableTable::LoadValuesFromDatabase() {
|
||||
tableSize.nextRow();
|
||||
}
|
||||
|
||||
tableSize.finalize();
|
||||
|
||||
// Reserve the size
|
||||
this->entries.reserve(size);
|
||||
|
||||
@@ -56,32 +21,32 @@ void CDLootTableTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM LootTable");
|
||||
while (!tableData.eof()) {
|
||||
CDLootTable entry;
|
||||
uint32_t lootTableIndex = tableData.getIntField("LootTableIndex", -1);
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.itemid = tableData.getIntField("itemid", -1);
|
||||
entry.LootTableIndex = tableData.getIntField("LootTableIndex", -1);
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.MissionDrop = tableData.getIntField("MissionDrop", -1) == 1 ? true : false;
|
||||
entry.sortPriority = tableData.getIntField("sortPriority", -1);
|
||||
|
||||
this->entries[lootTableIndex].push_back(ReadRow(tableData));
|
||||
this->entries.push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
for (auto& [id, table] : this->entries) {
|
||||
SortTable(table);
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
const LootTableEntries& CDLootTableTable::GetTable(uint32_t tableId) {
|
||||
auto itr = this->entries.find(tableId);
|
||||
if (itr != this->entries.end()) {
|
||||
return itr->second;
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDLootTable> CDLootTableTable::Query(std::function<bool(CDLootTable)> predicate) {
|
||||
|
||||
std::vector<CDLootTable> data = cpplinq::from(this->entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM LootTable WHERE LootTableIndex = ?;");
|
||||
query.bind(1, static_cast<int32_t>(tableId));
|
||||
auto tableData = query.execQuery();
|
||||
|
||||
while (!tableData.eof()) {
|
||||
CDLootTable entry;
|
||||
this->entries[tableId].push_back(ReadRow(tableData));
|
||||
tableData.nextRow();
|
||||
//! Gets all the entries in the table
|
||||
const std::vector<CDLootTable>& CDLootTableTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
SortTable(this->entries[tableId]);
|
||||
|
||||
return this->entries[tableId];
|
||||
}
|
||||
|
||||
@@ -6,21 +6,20 @@
|
||||
struct CDLootTable {
|
||||
unsigned int itemid; //!< The LOT of the item
|
||||
unsigned int LootTableIndex; //!< The Loot Table Index
|
||||
unsigned int id; //!< The ID
|
||||
bool MissionDrop; //!< Whether or not this loot table is a mission drop
|
||||
unsigned int sortPriority; //!< The sorting priority
|
||||
};
|
||||
|
||||
typedef uint32_t LootTableIndex;
|
||||
typedef std::vector<CDLootTable> LootTableEntries;
|
||||
|
||||
class CDLootTableTable : public CDTable<CDLootTableTable> {
|
||||
private:
|
||||
CDLootTable ReadRow(CppSQLite3Query& tableData) const;
|
||||
std::unordered_map<LootTableIndex, LootTableEntries> entries;
|
||||
std::vector<CDLootTable> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDLootTableTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
const LootTableEntries& GetTable(uint32_t tableId);
|
||||
std::vector<CDLootTable> Query(std::function<bool(CDLootTable)> predicate);
|
||||
|
||||
const std::vector<CDLootTable>& GetEntries(void) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDMissionEmailTable.h"
|
||||
|
||||
void CDMissionEmailTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDMissionEmailTable::CDMissionEmailTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -47,7 +48,7 @@ std::vector<CDMissionEmail> CDMissionEmailTable::Query(std::function<bool(CDMiss
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
const std::vector<CDMissionEmail>& CDMissionEmailTable::GetEntries() const {
|
||||
std::vector<CDMissionEmail> CDMissionEmailTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ private:
|
||||
std::vector<CDMissionEmail> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDMissionEmailTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionEmail> Query(std::function<bool(CDMissionEmail)> predicate);
|
||||
|
||||
const std::vector<CDMissionEmail>& GetEntries() const;
|
||||
std::vector<CDMissionEmail> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDMissionNPCComponentTable.h"
|
||||
|
||||
void CDMissionNPCComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDMissionNPCComponentTable::CDMissionNPCComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -44,7 +45,7 @@ std::vector<CDMissionNPCComponent> CDMissionNPCComponentTable::Query(std::functi
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
const std::vector<CDMissionNPCComponent>& CDMissionNPCComponentTable::GetEntries() const {
|
||||
std::vector<CDMissionNPCComponent> CDMissionNPCComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@ private:
|
||||
std::vector<CDMissionNPCComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDMissionNPCComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionNPCComponent> Query(std::function<bool(CDMissionNPCComponent)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
const std::vector<CDMissionNPCComponent>& GetEntries() const;
|
||||
std::vector<CDMissionNPCComponent> GetEntries(void) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDMissionTasksTable.h"
|
||||
|
||||
void CDMissionTasksTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDMissionTasksTable::CDMissionTasksTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -55,14 +56,16 @@ std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missio
|
||||
|
||||
for (auto& entry : this->entries) {
|
||||
if (entry.id == missionID) {
|
||||
tasks.push_back(&entry);
|
||||
CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry);
|
||||
|
||||
tasks.push_back(task);
|
||||
}
|
||||
}
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
||||
const std::vector<CDMissionTasks>& CDMissionTasksTable::GetEntries() const {
|
||||
const std::vector<CDMissionTasks>& CDMissionTasksTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ private:
|
||||
std::vector<CDMissionTasks> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDMissionTasksTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate);
|
||||
|
||||
std::vector<CDMissionTasks*> GetByMissionID(uint32_t missionID);
|
||||
|
||||
const std::vector<CDMissionTasks>& GetEntries() const;
|
||||
const std::vector<CDMissionTasks>& GetEntries(void) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
CDMissions CDMissionsTable::Default = {};
|
||||
|
||||
void CDMissionsTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDMissionsTable::CDMissionsTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
|
||||
@@ -65,12 +65,12 @@ private:
|
||||
std::vector<CDMissions> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDMissionsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMissions> Query(std::function<bool(CDMissions)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
const std::vector<CDMissions>& GetEntries() const;
|
||||
const std::vector<CDMissions>& GetEntries(void) const;
|
||||
|
||||
const CDMissions* GetPtrByMissionID(uint32_t missionID) const;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDMovementAIComponentTable.h"
|
||||
|
||||
void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDMovementAIComponentTable::CDMovementAIComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -36,6 +37,7 @@ void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::function<bool(CDMovementAIComponent)> predicate) {
|
||||
|
||||
std::vector<CDMovementAIComponent> data = cpplinq::from(this->entries)
|
||||
@@ -45,7 +47,8 @@ std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::functi
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDMovementAIComponent>& CDMovementAIComponentTable::GetEntries(void) const {
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ private:
|
||||
std::vector<CDMovementAIComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDMovementAIComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDMovementAIComponent> Query(std::function<bool(CDMovementAIComponent)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
const std::vector<CDMovementAIComponent>& GetEntries() const;
|
||||
std::vector<CDMovementAIComponent> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDObjectSkillsTable.h"
|
||||
|
||||
void CDObjectSkillsTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDObjectSkillsTable::CDObjectSkillsTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -32,6 +33,7 @@ void CDObjectSkillsTable::LoadValuesFromDatabase() {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObjectSkills)> predicate) {
|
||||
|
||||
std::vector<CDObjectSkills> data = cpplinq::from(this->entries)
|
||||
@@ -41,6 +43,7 @@ std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObje
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDObjectSkills>& CDObjectSkillsTable::GetEntries() const {
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDObjectSkills> CDObjectSkillsTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ private:
|
||||
std::vector<CDObjectSkills> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDObjectSkillsTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDObjectSkills> Query(std::function<bool(CDObjectSkills)> predicate);
|
||||
|
||||
// Gets all the entries in the table
|
||||
const std::vector<CDObjectSkills>& GetEntries() const;
|
||||
std::vector<CDObjectSkills> GetEntries(void) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "CDObjectsTable.h"
|
||||
|
||||
void CDObjectsTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDObjectsTable::CDObjectsTable(void) {
|
||||
#ifdef CDCLIENT_CACHE_ALL
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Objects");
|
||||
@@ -18,24 +20,25 @@ void CDObjectsTable::LoadValuesFromDatabase() {
|
||||
CDObjects entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.name = tableData.getStringField("name", "");
|
||||
UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1);)
|
||||
entry.placeable = tableData.getIntField("placeable", -1);
|
||||
entry.type = tableData.getStringField("type", "");
|
||||
UNUSED_COLUMN(entry.description = tableData.getStringField("description", "");)
|
||||
UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1);)
|
||||
UNUSED_COLUMN(entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1);)
|
||||
UNUSED_COLUMN(entry.displayName = tableData.getStringField("displayName", "");)
|
||||
entry.description = tableData.getStringField("description", "");
|
||||
entry.localize = tableData.getIntField("localize", -1);
|
||||
entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1);
|
||||
entry.displayName = tableData.getStringField("displayName", "");
|
||||
entry.interactionDistance = tableData.getFloatField("interactionDistance", -1.0f);
|
||||
UNUSED_COLUMN(entry.nametag = tableData.getIntField("nametag", -1);)
|
||||
UNUSED_COLUMN(entry._internalNotes = tableData.getStringField("_internalNotes", "");)
|
||||
UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1);)
|
||||
UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "");)
|
||||
UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1);)
|
||||
entry.nametag = tableData.getIntField("nametag", -1);
|
||||
entry._internalNotes = tableData.getStringField("_internalNotes", "");
|
||||
entry.locStatus = tableData.getIntField("locStatus", -1);
|
||||
entry.gate_version = tableData.getStringField("gate_version", "");
|
||||
entry.HQ_valid = tableData.getIntField("HQ_valid", -1);
|
||||
|
||||
this->entries.insert(std::make_pair(entry.id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
#endif
|
||||
|
||||
m_default.id = 0;
|
||||
}
|
||||
@@ -46,10 +49,12 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Objects WHERE id = ?;");
|
||||
query.bind(1, static_cast<int32_t>(LOT));
|
||||
#ifndef CDCLIENT_CACHE_ALL
|
||||
std::stringstream query;
|
||||
|
||||
auto tableData = query.execQuery();
|
||||
query << "SELECT * FROM Objects WHERE id = " << std::to_string(LOT);
|
||||
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(query.str());
|
||||
if (tableData.eof()) {
|
||||
this->entries.insert(std::make_pair(LOT, m_default));
|
||||
return m_default;
|
||||
@@ -83,6 +88,7 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
|
||||
if (it2 != entries.end()) {
|
||||
return it2->second;
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_default;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ private:
|
||||
CDObjects m_default;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDObjectsTable();
|
||||
// Gets an entry by ID
|
||||
const CDObjects& GetByID(unsigned int LOT);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDPackageComponentTable.h"
|
||||
|
||||
void CDPackageComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDPackageComponentTable::CDPackageComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -42,7 +43,7 @@ std::vector<CDPackageComponent> CDPackageComponentTable::Query(std::function<boo
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
const std::vector<CDPackageComponent>& CDPackageComponentTable::GetEntries() const {
|
||||
std::vector<CDPackageComponent> CDPackageComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ private:
|
||||
std::vector<CDPackageComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDPackageComponentTable(void);
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDPackageComponent> Query(std::function<bool(CDPackageComponent)> predicate);
|
||||
|
||||
const std::vector<CDPackageComponent>& GetEntries() const;
|
||||
std::vector<CDPackageComponent> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,35 +1,46 @@
|
||||
#include "CDPhysicsComponentTable.h"
|
||||
|
||||
void CDPhysicsComponentTable::LoadValuesFromDatabase() {
|
||||
CDPhysicsComponentTable::CDPhysicsComponentTable(void) {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
|
||||
while (!tableData.eof()) {
|
||||
CDPhysicsComponent entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.bStatic = tableData.getIntField("static", -1) != 0;
|
||||
entry.physicsAsset = tableData.getStringField("physics_asset", "");
|
||||
CDPhysicsComponent* entry = new CDPhysicsComponent();
|
||||
entry->id = tableData.getIntField("id", -1);
|
||||
entry->bStatic = tableData.getIntField("static", -1) != 0;
|
||||
entry->physicsAsset = tableData.getStringField("physics_asset", "");
|
||||
UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0);
|
||||
UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0);
|
||||
entry.speed = tableData.getFloatField("speed", -1);
|
||||
entry->speed = tableData.getFloatField("speed", -1);
|
||||
UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1));
|
||||
entry.playerHeight = tableData.getFloatField("playerHeight");
|
||||
entry.playerRadius = tableData.getFloatField("playerRadius");
|
||||
entry.pcShapeType = tableData.getIntField("pcShapeType");
|
||||
entry.collisionGroup = tableData.getIntField("collisionGroup");
|
||||
entry->playerHeight = tableData.getFloatField("playerHeight");
|
||||
entry->playerRadius = tableData.getFloatField("playerRadius");
|
||||
entry->pcShapeType = tableData.getIntField("pcShapeType");
|
||||
entry->collisionGroup = tableData.getIntField("collisionGroup");
|
||||
UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed"));
|
||||
UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset"));
|
||||
UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed"));
|
||||
UNUSED(entry->friction = tableData.getFloatField("friction"));
|
||||
UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset"));
|
||||
|
||||
m_entries.insert(std::make_pair(entry.id, entry));
|
||||
m_entries.insert(std::make_pair(entry->id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
|
||||
auto itr = m_entries.find(componentID);
|
||||
return itr != m_entries.end() ? &itr->second : nullptr;
|
||||
CDPhysicsComponentTable::~CDPhysicsComponentTable() {
|
||||
for (auto e : m_entries) {
|
||||
if (e.second) delete e.second;
|
||||
}
|
||||
|
||||
m_entries.clear();
|
||||
}
|
||||
|
||||
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
|
||||
for (auto e : m_entries) {
|
||||
if (e.first == componentID) return e.second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,12 @@ struct CDPhysicsComponent {
|
||||
|
||||
class CDPhysicsComponentTable : public CDTable<CDPhysicsComponentTable> {
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDPhysicsComponentTable();
|
||||
~CDPhysicsComponentTable();
|
||||
|
||||
static const std::string GetTableName() { return "PhysicsComponent"; };
|
||||
CDPhysicsComponent* GetByID(unsigned int componentID);
|
||||
|
||||
private:
|
||||
std::map<unsigned int, CDPhysicsComponent> m_entries;
|
||||
std::map<unsigned int, CDPhysicsComponent*> m_entries;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "CDPropertyEntranceComponentTable.h"
|
||||
|
||||
void CDPropertyEntranceComponentTable::LoadValuesFromDatabase() {
|
||||
CDPropertyEntranceComponentTable::CDPropertyEntranceComponentTable() {
|
||||
|
||||
// First, get the size of the table
|
||||
size_t size = 0;
|
||||
|
||||
@@ -11,12 +11,12 @@ struct CDPropertyEntranceComponent {
|
||||
|
||||
class CDPropertyEntranceComponentTable : public CDTable<CDPropertyEntranceComponentTable> {
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDPropertyEntranceComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
CDPropertyEntranceComponent GetByID(uint32_t id);
|
||||
|
||||
// Gets all the entries in the table
|
||||
[[nodiscard]] const std::vector<CDPropertyEntranceComponent>& GetEntries() const { return entries; }
|
||||
[[nodiscard]] std::vector<CDPropertyEntranceComponent> GetEntries() const { return entries; }
|
||||
private:
|
||||
std::vector<CDPropertyEntranceComponent> entries{};
|
||||
CDPropertyEntranceComponent defaultEntry{};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "CDPropertyTemplateTable.h"
|
||||
|
||||
void CDPropertyTemplateTable::LoadValuesFromDatabase() {
|
||||
CDPropertyTemplateTable::CDPropertyTemplateTable() {
|
||||
|
||||
// First, get the size of the table
|
||||
size_t size = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@ struct CDPropertyTemplate {
|
||||
|
||||
class CDPropertyTemplateTable : public CDTable<CDPropertyTemplateTable> {
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDPropertyTemplateTable();
|
||||
|
||||
static const std::string GetTableName() { return "PropertyTemplate"; };
|
||||
CDPropertyTemplate GetByMapID(uint32_t mapID);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDProximityMonitorComponentTable.h"
|
||||
|
||||
void CDProximityMonitorComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -32,6 +33,7 @@ void CDProximityMonitorComponentTable::LoadValuesFromDatabase() {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query(std::function<bool(CDProximityMonitorComponent)> predicate) {
|
||||
|
||||
std::vector<CDProximityMonitorComponent> data = cpplinq::from(this->entries)
|
||||
@@ -41,7 +43,8 @@ std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::Query
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDProximityMonitorComponent>& CDProximityMonitorComponentTable::GetEntries() const {
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDProximityMonitorComponent> CDProximityMonitorComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ private:
|
||||
std::vector<CDProximityMonitorComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDProximityMonitorComponentTable(void);
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDProximityMonitorComponent> Query(std::function<bool(CDProximityMonitorComponent)> predicate);
|
||||
|
||||
const std::vector<CDProximityMonitorComponent>& GetEntries() const;
|
||||
std::vector<CDProximityMonitorComponent> GetEntries(void) const;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "CDRailActivatorComponent.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
void CDRailActivatorComponentTable::LoadValuesFromDatabase() {
|
||||
CDRailActivatorComponentTable::CDRailActivatorComponentTable() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RailActivatorComponent;");
|
||||
while (!tableData.eof()) {
|
||||
CDRailActivatorComponent entry;
|
||||
@@ -52,7 +52,7 @@ CDRailActivatorComponent CDRailActivatorComponentTable::GetEntryByID(int32_t id)
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::vector<CDRailActivatorComponent>& CDRailActivatorComponentTable::GetEntries() const {
|
||||
std::vector<CDRailActivatorComponent> CDRailActivatorComponentTable::GetEntries() const {
|
||||
return m_Entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ struct CDRailActivatorComponent {
|
||||
|
||||
class CDRailActivatorComponentTable : public CDTable<CDRailActivatorComponentTable> {
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDRailActivatorComponentTable();
|
||||
static const std::string GetTableName() { return "RailActivatorComponent"; };
|
||||
[[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const;
|
||||
[[nodiscard]] const std::vector<CDRailActivatorComponent>& GetEntries() const;
|
||||
[[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const;
|
||||
private:
|
||||
static std::pair<uint32_t, std::u16string> EffectPairFromString(std::string& str);
|
||||
std::vector<CDRailActivatorComponent> m_Entries{};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDRarityTableTable.h"
|
||||
|
||||
void CDRarityTableTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDRarityTableTable::CDRarityTableTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -17,18 +18,33 @@ void CDRarityTableTable::LoadValuesFromDatabase() {
|
||||
this->entries.reserve(size);
|
||||
|
||||
// Now get the data
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RarityTable order by randmax desc;");
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RarityTable");
|
||||
while (!tableData.eof()) {
|
||||
uint32_t rarityTableIndex = tableData.getIntField("RarityTableIndex", -1);
|
||||
|
||||
CDRarityTable entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.randmax = tableData.getFloatField("randmax", -1);
|
||||
entry.rarity = tableData.getIntField("rarity", -1);
|
||||
entries[rarityTableIndex].push_back(entry);
|
||||
entry.RarityTableIndex = tableData.getIntField("RarityTableIndex", -1);
|
||||
|
||||
this->entries.push_back(entry);
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
const std::vector<CDRarityTable>& CDRarityTableTable::GetRarityTable(uint32_t id) {
|
||||
return entries[id];
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDRarityTable> CDRarityTableTable::Query(std::function<bool(CDRarityTable)> predicate) {
|
||||
|
||||
std::vector<CDRarityTable> data = cpplinq::from(this->entries)
|
||||
>> cpplinq::where(predicate)
|
||||
>> cpplinq::to_vector();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
const std::vector<CDRarityTable>& CDRarityTableTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,20 +4,37 @@
|
||||
#include "CDTable.h"
|
||||
|
||||
struct CDRarityTable {
|
||||
unsigned int id;
|
||||
float randmax;
|
||||
unsigned int rarity;
|
||||
};
|
||||
unsigned int RarityTableIndex;
|
||||
|
||||
typedef std::vector<CDRarityTable> RarityTable;
|
||||
friend bool operator> (const CDRarityTable& c1, const CDRarityTable& c2) {
|
||||
return c1.rarity > c2.rarity;
|
||||
}
|
||||
|
||||
friend bool operator>= (const CDRarityTable& c1, const CDRarityTable& c2) {
|
||||
return c1.rarity >= c2.rarity;
|
||||
}
|
||||
|
||||
friend bool operator< (const CDRarityTable& c1, const CDRarityTable& c2) {
|
||||
return c1.rarity < c2.rarity;
|
||||
}
|
||||
|
||||
friend bool operator<= (const CDRarityTable& c1, const CDRarityTable& c2) {
|
||||
return c1.rarity <= c2.rarity;
|
||||
}
|
||||
};
|
||||
|
||||
class CDRarityTableTable : public CDTable<CDRarityTableTable> {
|
||||
private:
|
||||
typedef uint32_t RarityTableIndex;
|
||||
std::unordered_map<RarityTableIndex, std::vector<CDRarityTable>> entries;
|
||||
std::vector<CDRarityTable> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDRarityTableTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDRarityTable> Query(std::function<bool(CDRarityTable)> predicate);
|
||||
|
||||
const std::vector<CDRarityTable>& GetRarityTable(uint32_t predicate);
|
||||
const std::vector<CDRarityTable>& GetEntries() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDRebuildComponentTable.h"
|
||||
|
||||
void CDRebuildComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDRebuildComponentTable::CDRebuildComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -38,6 +39,7 @@ void CDRebuildComponentTable::LoadValuesFromDatabase() {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDRebuildComponent> CDRebuildComponentTable::Query(std::function<bool(CDRebuildComponent)> predicate) {
|
||||
|
||||
std::vector<CDRebuildComponent> data = cpplinq::from(this->entries)
|
||||
@@ -47,7 +49,8 @@ std::vector<CDRebuildComponent> CDRebuildComponentTable::Query(std::function<boo
|
||||
return data;
|
||||
}
|
||||
|
||||
const std::vector<CDRebuildComponent>& CDRebuildComponentTable::GetEntries() const {
|
||||
//! Gets all the entries in the table
|
||||
std::vector<CDRebuildComponent> CDRebuildComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ private:
|
||||
std::vector<CDRebuildComponent> entries;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDRebuildComponentTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDRebuildComponent> Query(std::function<bool(CDRebuildComponent)> predicate);
|
||||
|
||||
const std::vector<CDRebuildComponent>& GetEntries() const;
|
||||
std::vector<CDRebuildComponent> GetEntries() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,27 +1,35 @@
|
||||
#include "CDRewardsTable.h"
|
||||
|
||||
void CDRewardsTable::LoadValuesFromDatabase() {
|
||||
CDRewardsTable::CDRewardsTable(void) {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards");
|
||||
while (!tableData.eof()) {
|
||||
CDRewards entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.levelID = tableData.getIntField("LevelID", -1);
|
||||
entry.missionID = tableData.getIntField("MissionID", -1);
|
||||
entry.rewardType = tableData.getIntField("RewardType", -1);
|
||||
entry.value = tableData.getIntField("value", -1);
|
||||
entry.count = tableData.getIntField("count", -1);
|
||||
CDRewards* entry = new CDRewards();
|
||||
entry->id = tableData.getIntField("id", -1);
|
||||
entry->levelID = tableData.getIntField("LevelID", -1);
|
||||
entry->missionID = tableData.getIntField("MissionID", -1);
|
||||
entry->rewardType = tableData.getIntField("RewardType", -1);
|
||||
entry->value = tableData.getIntField("value", -1);
|
||||
entry->count = tableData.getIntField("count", -1);
|
||||
|
||||
m_entries.insert(std::make_pair(entry.id, entry));
|
||||
m_entries.insert(std::make_pair(entry->id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
std::vector<CDRewards> CDRewardsTable::GetByLevelID(uint32_t levelID) {
|
||||
std::vector<CDRewards> result{};
|
||||
CDRewardsTable::~CDRewardsTable(void) {
|
||||
for (auto e : m_entries) {
|
||||
if (e.second) delete e.second;
|
||||
}
|
||||
|
||||
m_entries.clear();
|
||||
}
|
||||
|
||||
std::vector<CDRewards*> CDRewardsTable::GetByLevelID(uint32_t levelID) {
|
||||
std::vector<CDRewards*> result{};
|
||||
for (const auto& e : m_entries) {
|
||||
if (e.second.levelID == levelID) result.push_back(e.second);
|
||||
if (e.second->levelID == levelID) result.push_back(e.second);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -13,11 +13,12 @@ struct CDRewards {
|
||||
|
||||
class CDRewardsTable : public CDTable<CDRewardsTable> {
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDRewardsTable();
|
||||
~CDRewardsTable();
|
||||
|
||||
static const std::string GetTableName() { return "Rewards"; };
|
||||
std::vector<CDRewards> GetByLevelID(uint32_t levelID);
|
||||
std::vector<CDRewards*> GetByLevelID(uint32_t levelID);
|
||||
|
||||
private:
|
||||
std::map<uint32_t, CDRewards> m_entries;
|
||||
std::map<uint32_t, CDRewards*> m_entries;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDScriptComponentTable.h"
|
||||
|
||||
void CDScriptComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDScriptComponentTable::CDScriptComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
CDScriptComponent m_ToReturnWhenNoneFound;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDScriptComponentTable();
|
||||
// Gets an entry by scriptID
|
||||
const CDScriptComponent& GetByID(unsigned int id);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
//#include "Logger.hpp"
|
||||
|
||||
void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDSkillBehaviorTable::CDSkillBehaviorTable(void) {
|
||||
m_empty = CDSkillBehavior();
|
||||
|
||||
// First, get the size of the table
|
||||
@@ -49,6 +51,13 @@ void CDSkillBehaviorTable::LoadValuesFromDatabase() {
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
//! Queries the table with a custom "where" clause
|
||||
std::vector<CDSkillBehavior> CDSkillBehaviorTable::Query(std::function<bool(CDSkillBehavior)> predicate) {
|
||||
std::vector<CDSkillBehavior> data; //So MSVC shuts up
|
||||
return data;
|
||||
}
|
||||
|
||||
//! Gets an entry by ID
|
||||
const CDSkillBehavior& CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) {
|
||||
std::map<unsigned int, CDSkillBehavior>::iterator it = this->entries.find(skillID);
|
||||
if (it != this->entries.end()) {
|
||||
|
||||
@@ -31,7 +31,9 @@ private:
|
||||
CDSkillBehavior m_empty;
|
||||
|
||||
public:
|
||||
void LoadValuesFromDatabase();
|
||||
CDSkillBehaviorTable();
|
||||
// Queries the table with a custom "where" clause
|
||||
std::vector<CDSkillBehavior> Query(std::function<bool(CDSkillBehavior)> predicate);
|
||||
|
||||
// Gets an entry by skillID
|
||||
const CDSkillBehavior& GetSkillByID(unsigned int skillID);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CDVendorComponentTable.h"
|
||||
|
||||
void CDVendorComponentTable::LoadValuesFromDatabase() {
|
||||
//! Constructor
|
||||
CDVendorComponentTable::CDVendorComponentTable(void) {
|
||||
|
||||
// First, get the size of the table
|
||||
unsigned int size = 0;
|
||||
@@ -44,7 +45,7 @@ std::vector<CDVendorComponent> CDVendorComponentTable::Query(std::function<bool(
|
||||
}
|
||||
|
||||
//! Gets all the entries in the table
|
||||
const std::vector<CDVendorComponent>& CDVendorComponentTable::GetEntries() const {
|
||||
std::vector<CDVendorComponent> CDVendorComponentTable::GetEntries(void) const {
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user