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

SpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/SpaceNinjaServer

fix: treat ExtraRemaining from U7 clients like an absolute value (#3723)

Closes #3721 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3723 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

ffec3489
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

3 个文件 +26 -5
Modified src/controllers/custom/addXpController.ts +1 -1
@@ -22,7 +22,7 @@ export const addXpController: RequestHandler = async (req, res) => {
22 22 }
23 23 }
24 24 }
25 applyClientEquipmentUpdates(inventory, gear, category as TEquipmentKey);
25 applyClientEquipmentUpdates(inventory, gear, category as TEquipmentKey, undefined);
26 26 }
27 27 await inventory.save();
28 28 res.end();
Modified src/services/inventoryService.ts +19 -3
@@ -2175,7 +2175,8 @@ const xpEarningParts: readonly string[] = [
2175 2175 export const applyClientEquipmentUpdates = (
2176 2176 inventory: TInventoryDatabaseDocument,
2177 2177 gearArray: IEquipmentClient[],
2178 categoryName: TEquipmentKey
2178 categoryName: TEquipmentKey,
2179 buildLabel: string | undefined
2179 2180 ): void => {
2180 2181 const category = inventory[categoryName];
2181 2182
@@ -2228,8 +2229,23 @@ export const applyClientEquipmentUpdates = (
2228 2229 }
2229 2230
2230 2231 if (ExtraRemaining) {
2231 item.ExtraRemaining ??= 4;
2232 item.ExtraRemaining += ExtraRemaining;
2232 if (!buildLabel || version_compare(buildLabel, gameToBuildVersion["8.0.0"]) >= 0) {
2233 if (ExtraRemaining > 0) {
2234 throw new Error(
2235 `unexpected value for ExtraRemaining (${ExtraRemaining}); expected a delta from this client`
2236 );
2237 }
2238 item.ExtraRemaining ??= 4;
2239 item.ExtraRemaining += ExtraRemaining;
2240 } else {
2241 // U7 still provided an absolute value; unclear when this changed.
2242 if (ExtraRemaining < 0) {
2243 throw new Error(
2244 `unexpected value for ExtraRemaining (${ExtraRemaining}); expected an absolute value from this client`
2245 );
2246 }
2247 item.ExtraRemaining = ExtraRemaining;
2248 }
2233 2249 }
2234 2250 });
2235 2251 };
Modified src/services/missionInventoryUpdateService.ts +6 -1
@@ -1062,7 +1062,12 @@ export const addMissionInventoryUpdates = async (
1062 1062 break;
1063 1063 default:
1064 1064 if (equipmentKeys.includes(key as TEquipmentKey)) {
1065 applyClientEquipmentUpdates(inventory, value as IEquipmentClient[], key as TEquipmentKey);
1065 applyClientEquipmentUpdates(
1066 inventory,
1067 value as IEquipmentClient[],
1068 key as TEquipmentKey,
1069 account.BuildLabel
1070 );
1066 1071 } else if (allDailyAffiliationKeys.includes(key as keyof IDailyAffiliations)) {
1067 1072 inventory[key as keyof IDailyAffiliations] -= value as number;
1068 1073 }