XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

fix: reproducible oids for unlockAllSkins (#769)

2cd47c8a
Sainan <sainan@calamity.inc>
提交于

代码差异

1 个文件 +11 -3
Modified src/controllers/api/inventoryController.ts +11 -3
@@ -158,12 +158,10 @@ export const inventoryController: RequestHandler = async (request, response) =>
158 158
159 159 if (config.unlockAllSkins) {
160 160 inventoryResponse.WeaponSkins = [];
161 let i = 0;
162 161 for (const uniqueName in ExportCustoms) {
163 i++;
164 162 inventoryResponse.WeaponSkins.push({
165 163 ItemId: {
166 $oid: i.toString().padStart(24, "0")
164 $oid: "ca70ca70ca70ca70" + catBreadHash(uniqueName).toString(16).padStart(8, "0")
167 165 },
168 166 ItemType: uniqueName
169 167 });
@@ -251,3 +249,13 @@ const resourceGetParent = (resourceName: string): string | undefined => {
251 249 }
252 250 return ExportVirtuals[resourceName]?.parentName;
253 251 };
252
253 // This is FNV1a-32 except operating under modulus 2^31 because JavaScript is stinky and likes producing negative integers out of nowhere.
254 const catBreadHash = (name: string): number => {
255 let hash = 2166136261;
256 for (let i = 0; i != name.length; ++i) {
257 hash = (hash ^ name.charCodeAt(i)) & 0x7fffffff;
258 hash = (hash * 16777619) & 0x7fffffff;
259 }
260 return hash;
261 };