Cleanup of var names and comments inside addForcedLoot()
Prevent duplicate loot locations with same Id being added to client response
This commit is contained in:
parent
a657e66917
commit
ef769cf0d7
@ -673,12 +673,12 @@ export class LocationGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add forced spawn point loot into loot parameter array
|
* Add forced spawn point loot into loot parameter array
|
||||||
* @param loot array to add forced loot to
|
* @param lootLocationTemplates array to add forced loot spawn locations to
|
||||||
* @param forcedSpawnPoints forced loot to add
|
* @param forcedSpawnPoints forced Forced loot locations that must be added
|
||||||
* @param name of map currently generating forced loot for
|
* @param locationName Name of map currently having force loot created for
|
||||||
*/
|
*/
|
||||||
protected addForcedLoot(
|
protected addForcedLoot(
|
||||||
loot: SpawnpointTemplate[],
|
lootLocationTemplates: SpawnpointTemplate[],
|
||||||
forcedSpawnPoints: SpawnpointsForced[],
|
forcedSpawnPoints: SpawnpointsForced[],
|
||||||
locationName: string,
|
locationName: string,
|
||||||
): void
|
): void
|
||||||
@ -717,32 +717,47 @@ export class LocationGenerator
|
|||||||
const lootItem = itemToAdd.template;
|
const lootItem = itemToAdd.template;
|
||||||
lootItem.Root = this.objectId.generate();
|
lootItem.Root = this.objectId.generate();
|
||||||
lootItem.Items[0]._id = lootItem.Root;
|
lootItem.Items[0]._id = lootItem.Root;
|
||||||
loot.push(lootItem);
|
lootLocationTemplates.push(lootItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
||||||
const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems();
|
const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems();
|
||||||
|
|
||||||
// Add remaining forced loot to array
|
// Add remaining forced loot to array
|
||||||
for (const forcedLootItem of forcedSpawnPoints)
|
for (const forcedLootLocation of forcedSpawnPoints)
|
||||||
{
|
{
|
||||||
// Skip spawn positions processed above
|
const firstLootItemTpl = forcedLootLocation.template.Items[0]._tpl;
|
||||||
if (lootToForceSingleAmountOnMap?.includes(forcedLootItem.template.Items[0]._tpl))
|
|
||||||
|
// Skip spawn positions processed already
|
||||||
|
if (lootToForceSingleAmountOnMap?.includes(firstLootItemTpl))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip seasonal items when seasonal event is active
|
// Skip adding seasonal items when seasonal event is not active
|
||||||
if (!seasonalEventActive && seasonalItemTplBlacklist.includes(forcedLootItem.template.Items[0]._tpl))
|
if (!seasonalEventActive && seasonalItemTplBlacklist.includes(firstLootItemTpl))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const li = forcedLootItem.template;
|
const locationTemplateToAdd = forcedLootLocation.template;
|
||||||
li.Root = this.objectId.generate();
|
|
||||||
li.Items[0]._id = li.Root;
|
// Ensure root id matches the first items id
|
||||||
loot.push(li);
|
locationTemplateToAdd.Root = this.objectId.generate();
|
||||||
|
locationTemplateToAdd.Items[0]._id = locationTemplateToAdd.Root;
|
||||||
|
|
||||||
|
// Push forced location into array as long as it doesnt exist already
|
||||||
|
const existingLocation = lootLocationTemplates.find(x => x.Id === locationTemplateToAdd.Id);
|
||||||
|
if (!existingLocation)
|
||||||
|
{
|
||||||
|
lootLocationTemplates.push(locationTemplateToAdd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.logger.warning(`Attempted to add a forced loot location with Id: ${locationTemplateToAdd.Id} to map ${locationName} that already has that id in use, skipping`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user