Skip to content

Commit

Permalink
fix(random_shop): Do not put minimum player limited equip in random shop
Browse files Browse the repository at this point in the history
This fixes #1679, very well aware that other limitations (team/global
limited) are still not respected and might still show up.
  • Loading branch information
Histalek committed Nov 27, 2024
1 parent 2493ff1 commit 5145c05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
- Fixed spectating player still being visible through thermalvision after killing that player (by @MrXonte)
- Fixed Magneto-stick not using C_Hands (by @SvveetMavis)
- Fixed console error when dropping ammo for weapons with no AmmoEnt (by @MrXonte)
- Fixed randomshop containing equipment which minimum playeramount was not satisfied (by @Histalek)

### Changed

Expand Down
8 changes: 8 additions & 0 deletions gamemodes/terrortown/gamemode/shared/sh_equip_items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ if SERVER then
RANDOMSHOP[ply] = RANDOMTEAMSHOPS[GetShopFallback(srd.index)]
end
else -- every player has his own shop
local activePlys = util.GetActivePlayers()

for i = 1, #tmpTbl do
local ply = tmpTbl[i]
local srd = ply:GetSubRoleData()
Expand All @@ -590,6 +592,12 @@ if SERVER then
continue
end

if equip.minPlayers and equip.minPlayers > 1 then
if #activePlys < equip.minPlayers then
continue

Check warning on line 597 in gamemodes/terrortown/gamemode/shared/sh_equip_items.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
end

Check warning on line 598 in gamemodes/terrortown/gamemode/shared/sh_equip_items.lua

View workflow job for this annotation

GitHub Actions / lint

"Double if-statement"

Double if statement. Please combine the condition of this if statement with that of the outer if statement using `and`.
end

if equip.NoRandom then
amount = amount - 1

Expand Down

0 comments on commit 5145c05

Please sign in to comment.