Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
fix: revert client crash fix; fix dual pistol ammo
Browse files Browse the repository at this point in the history
  • Loading branch information
leia-uwu committed Sep 11, 2024
1 parent 47c67c1 commit 7804315
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 5 additions & 1 deletion server/src/game/objects/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2798,7 +2798,11 @@ export class Player extends BaseGameObject {
gunType = obj.type;
}
if (gunType) {
this.weaponManager.setWeapon(newGunIdx, gunType, 0);
this.weaponManager.setWeapon(
newGunIdx,
gunType,
freeGunSlot.isDualWield ? this.weapons[newGunIdx].ammo : 0,
);

// if "preloaded" gun add ammo to inventory
if (obj.isPreloadedGun) {
Expand Down
8 changes: 2 additions & 6 deletions server/src/game/weaponManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ export class WeaponManager {
}> = [];

get activeWeapon(): string {
// HACK: possible fix for client crash?
// active weapon seems to be undefined/empty string in the client
// idk why it also doesn't crash the server lol
// TODO: investigate this
return this.weapons[this.curWeapIdx].type || "fists";
return this.weapons[this.curWeapIdx].type;
}

constructor(player: Player) {
Expand Down Expand Up @@ -477,7 +473,7 @@ export class WeaponManager {

if (weaponDef.isDual) {
item = item.replace("_dual", "");
this.player.dropLoot(item, 0);
this.player.dropLoot(item, 0, true);
}
this.player.dropLoot(item, amountToDrop, true);
this.player.weapsDirty = true;
Expand Down

0 comments on commit 7804315

Please sign in to comment.