Skip to content

Commit

Permalink
Correcting ASA world names
Browse files Browse the repository at this point in the history
  • Loading branch information
thommcgrath committed Aug 17, 2024
1 parent 9de9110 commit d4080e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions Website/api/v4/classes/ArkSA/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class Map extends DatabaseObject implements JsonSerializable {
protected string $mapId;
protected string $contentPackId;
protected string $label;
protected string $arkIdentifier;
protected string $worldName;
protected string $arkIdentifier; // Deprecated, needed by Beacon 2.0.0 through 2.3.0 inclusive
protected float $difficultyScale;
protected bool $isOfficial;
protected string $type;
Expand All @@ -26,6 +27,7 @@ public function __construct(BeaconRecordSet $row) {
$this->mapId = $row->Field('map_id');
$this->contentPackId = $row->Field('content_pack_id');
$this->label = $row->Field('label');
$this->worldName = $row->Field('world_name');
$this->arkIdentifier = $row->Field('ark_identifier');
$this->difficultyScale = filter_var($row->Field('difficulty_scale'), FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE) ?? 4.0;
$this->isOfficial = filter_var($row->Field('official'), FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE) ?? false;
Expand All @@ -46,6 +48,7 @@ public static function BuildDatabaseSchema(): DatabaseSchema {
new DatabaseObjectProperty('mapId', ['primaryKey' => true, 'columnName' => 'map_id']),
new DatabaseObjectProperty('contentPackId', ['columnName' => 'content_pack_id']),
new DatabaseObjectProperty('label'),
new DatabaseObjectProperty('worldName', ['columnName' => 'world_name']),
new DatabaseObjectProperty('arkIdentifier', ['columnName' => 'ark_identifier']),
new DatabaseObjectProperty('difficultyScale', ['columnName' => 'difficulty_scale']),
new DatabaseObjectProperty('isOfficial', ['columnName' => 'official']),
Expand All @@ -67,6 +70,7 @@ protected static function BuildSearchParameters(DatabaseSearchParameters $parame
$parameters->allowAll = true;
$parameters->orderBy = $schema->Accessor('isOfficial') . ' DESC, ' . $schema->Accessor('sortOrder') . ', ' . $schema->Accessor('label');
$parameters->AddFromFilter($schema, $filters, 'arkIdentifier');
$parameters->AddFromFilter($schema, $filters, 'worldName');
$parameters->AddFromFilter($schema, $filters, 'lastUpdate', '>');

if (isset($filters['mask'])) {
Expand All @@ -90,7 +94,7 @@ public static function Fetch(string $uuid): ?static {
return parent::Fetch($uuid);
}

$results = static::Search(['arkIdentifier' => $uuid], true);
$results = static::Search(['worldName' => $uuid], true);
if (count($results) === 1) {
return $results[0];
}
Expand All @@ -106,6 +110,10 @@ public function MapId(): string {
return $this->map_id;
}

public function WorldName(): string {
return $this->world_name;
}

public function Identifier(): string {
return $this->ark_identifier;
}
Expand Down Expand Up @@ -159,6 +167,7 @@ public function jsonSerialize(): mixed {
'mapId' => $this->mapId,
'contentPackId' => $this->contentPackId,
'label' => $this->label,
'worldName' => $this->worldName,
'arkIdentifier' => $this->arkIdentifier,
'difficultyScale' => $this->difficultyScale,
'isOfficial' => $this->isOfficial,
Expand Down
4 changes: 2 additions & 2 deletions Website/api/v4/classes/ArkSA/SpawnPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(BeaconRecordSet $row) {
$decoded = json_decode($row->Field('populations'), true);
$this->populations = [];
foreach ($decoded as $popdata) {
$this->populations[$popdata['arkIdentifier']] = [
$this->populations[$popdata['worldName']] = [
'instances' => $popdata['instancesOnMap'],
'targetPopulation' => $popdata['maxPopulation']
];
Expand All @@ -48,7 +48,7 @@ public static function BuildDatabaseSchema(): DatabaseSchema {
$schema->AddColumns([
new DatabaseObjectProperty('sets', ['accessor' => '(SELECT array_to_json(array_agg(row_to_json(sets_template))) FROM (SELECT spawn_point_set_id AS "spawnPointSetId", label, weight, spawn_offset AS "spawnOffset", min_distance_from_players_multiplier AS "minDistanceFromPlayersMultiplier", min_distance_from_structures_multiplier AS "minDistanceFromStructuresMultiplier", min_distance_from_tamed_dinos_multiplier AS "minDistanceFromTamedDinosMultiplier", spread_radius AS "spreadRadius", water_only_minimum_height AS "waterOnlyMinimumHeight", offset_before_multiplier AS "offsetBeforeMultiplier", (SELECT array_to_json(array_agg(row_to_json(entries_template))) FROM (SELECT spawn_point_set_entry_id AS "spawnPointSetEntryId", creature_id AS "creatureId", weight, override, min_level_multiplier AS "minLevelMultiplier", max_level_multiplier AS "maxLevelMultiplier", min_level_offset AS "minLevelOffset", max_level_offset AS "maxLevelOffset", spawn_offset AS "spawnOffset", (SELECT array_to_json(array_agg(row_to_json(levels_template))) FROM (SELECT difficulty, min_level AS "minLevel", max_level AS "maxLevel" FROM arksa.spawn_point_set_entry_levels WHERE arksa.spawn_point_set_entry_levels.spawn_point_set_entry_id = arksa.spawn_point_set_entries.spawn_point_set_entry_id) AS levels_template) AS "levelOverrides" FROM arksa.spawn_point_set_entries INNER JOIN arksa.creatures ON (spawn_point_set_entries.creature_id = creatures.object_id) WHERE arksa.spawn_point_set_entries.spawn_point_set_id = arksa.spawn_point_sets.spawn_point_set_id) AS entries_template) AS entries, (SELECT array_to_json(array_agg(row_to_json(replacements_template))) FROM (SELECT target_creature_id AS "creatureId", (SELECT array_to_json(array_agg(row_to_json(choices_template))) FROM (SELECT replacement_creature_id AS "creatureId", weight FROM arksa.spawn_point_set_replacements WHERE target_creature_id = target_creature_id AND spawn_point_set_replacements.spawn_point_set_id = spawn_point_sets.spawn_point_set_id) AS choices_template) AS choices FROM arksa.spawn_point_set_replacements INNER JOIN arksa.creatures AS targets ON (spawn_point_set_replacements.target_creature_id = targets.object_id) WHERE spawn_point_set_replacements.spawn_point_set_id = spawn_point_sets.spawn_point_set_id GROUP BY target_creature_id, targets.path, targets.class_string, targets.content_pack_id) AS replacements_template) AS replacements FROM arksa.spawn_point_sets WHERE arksa.spawn_point_sets.spawn_point_id = arksa.spawn_points.object_id) AS sets_template)', 'required' => false, 'editable' => DatabaseObjectProperty::kEditableAlways]),
new DatabaseObjectProperty('limits', ['accessor' => '(SELECT array_to_json(array_agg(row_to_json(limits_template))) FROM (SELECT spawn_point_limits.creature_id AS "creatureId", spawn_point_limits.max_percentage AS "maxPercentage" FROM arksa.spawn_point_limits INNER JOIN arksa.creatures ON (arksa.spawn_point_limits.creature_id = creatures.object_id) WHERE spawn_point_limits.spawn_point_id = spawn_points.object_id) AS limits_template)', 'required' => false, 'editable' => DatabaseObjectProperty::kEditableAlways]),
new DatabaseObjectProperty('populations', ['accessor' => '(SELECT array_to_json(array_agg(row_to_json(pop_template))) FROM (SELECT ark_identifier AS "arkIdentifier", instances_on_map AS "instancesOnMap", max_population AS "maxPopulation" FROM arksa.spawn_point_populations INNER JOIN arksa.maps ON (spawn_point_populations.map_id = maps.map_id) WHERE spawn_point_populations.spawn_point_id = spawn_points.object_id ORDER BY ark_identifier) AS pop_template)', 'required' => false, 'editable' => DatabaseObjectProperty::kEditableNever])
new DatabaseObjectProperty('populations', ['accessor' => '(SELECT array_to_json(array_agg(row_to_json(pop_template))) FROM (SELECT world_name AS "worldName", instances_on_map AS "instancesOnMap", max_population AS "maxPopulation" FROM arksa.spawn_point_populations INNER JOIN arksa.maps ON (spawn_point_populations.map_id = maps.map_id) WHERE spawn_point_populations.spawn_point_id = spawn_points.object_id ORDER BY world_name) AS pop_template)', 'required' => false, 'editable' => DatabaseObjectProperty::kEditableNever])
]);
return $schema;
}
Expand Down

0 comments on commit d4080e0

Please sign in to comment.