Skip to content

Commit

Permalink
fixes some backend shipjoin stuff (#2535)
Browse files Browse the repository at this point in the history
## About The Pull Request

admin + DB flag exemptions weren't respected by the ship joining UI, but
_all_ players were assumed to have the requisite playtime to spawn /
join a ship by the code that actually handled joining. this fixes both,
technically fixing an href exploit i suppose

## Why It's Good For The Game

bugs bad + consistency good. i am bad at web dev

## Changelog

:cl:
fix: Small playtime-based ship join restriction edge cases fixed.
/:cl:
  • Loading branch information
tmtmtl30 authored Dec 6, 2023
1 parent de83f95 commit 6274f6a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions code/modules/jobs/job_exp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ GLOBAL_PROTECT(exp_to_update)
return FALSE
if(CONFIG_GET(flag/use_exp_restrictions_admin_bypass) && check_rights_for(src, R_ADMIN))
return FALSE // if admin exemption is enabled, and client is an admin, let them through
return TRUE

/client/proc/get_exp_living(pure_numeric = FALSE)
if(!prefs.exp)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/dead/new_player/ship_select.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
.["ships"] = list()
.["shipSpawnAllowed"] = SSovermap.player_ship_spawn_allowed()
.["purchaseBanned"] = is_banned_from(user.ckey, "Ship Purchasing")
// if the player has a client which is not eligible for playtime restriction (for admin + player DB flag playtime exemption), they "auto meet" playtime requirements
.["autoMeet"] = user.client && !user.client.is_playtime_restriction_eligible()
.["playMin"] = user.client ? user.client.get_exp_living(TRUE) : 0

for(var/datum/overmap/ship/controlled/S as anything in SSovermap.controlled_ships)
Expand Down
33 changes: 19 additions & 14 deletions tgui/packages/tgui/interfaces/ShipSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,11 @@ export const ShipSelect = (props, context) => {
<Button
content="Select"
tooltip={
!data.autoMeet &&
data.playMin < job.minTime &&
'You do not have enough playtime to play this job.'
}
disabled={data.playMin < job.minTime}
disabled={!data.autoMeet && data.playMin < job.minTime}
onClick={() => {
act('join', {
ship: selectedShip.ref,
Expand All @@ -204,12 +205,7 @@ export const ShipSelect = (props, context) => {
<Table.Cell>{job.name}</Table.Cell>
<Table.Cell>{job.slots}</Table.Cell>
<Table.Cell>
{(job.minTime > 0 &&
(job.minTime.toString() +
'm ' +
(data.playMin < job.minTime && '(Unmet)') ||
'(Met)')) ||
'-'}
{formatShipTime(job.minTime, data.playMin, data.autoMeet)}
</Table.Cell>
</Table.Row>
))}
Expand Down Expand Up @@ -244,7 +240,7 @@ export const ShipSelect = (props, context) => {
color={
(!data.shipSpawnAllowed && 'average') ||
((template.curNum >= template.limit ||
data.playMin < template.minTime) &&
(!data.autoMeet && data.playMin < template.minTime)) &&
'grey') ||
'default'
}
Expand All @@ -256,13 +252,14 @@ export const ShipSelect = (props, context) => {
'No more ships may be spawned at this time.') ||
(template.curNum >= template.limit &&
'There are too many ships of this type.') ||
(data.playMin < template.minTime &&
(!data.autoMeet &&
data.playMin < template.minTime &&
'You do not have enough playtime to buy this ship.')
}
disabled={
!data.shipSpawnAllowed ||
template.curNum >= template.limit ||
data.playMin < template.minTime
(!data.autoMeet && data.playMin < template.minTime)
}
onClick={() => {
act('buy', {
Expand Down Expand Up @@ -290,10 +287,11 @@ export const ShipSelect = (props, context) => {
{template.limit}
</LabeledList.Item>
<LabeledList.Item label="Min. Playtime">
{template.minTime +
'm ' +
((data.playMin < template.minTime && '(Unmet)') ||
'(Met)')}
{formatShipTime(
template.minTime,
data.playMin,
data.autoMeet
)}
</LabeledList.Item>
<LabeledList.Item label="Wiki Link">
<a
Expand All @@ -313,3 +311,10 @@ export const ShipSelect = (props, context) => {
</Window>
);
};

const formatShipTime = (minTime, playMin, autoMeet) => {
return (
(minTime <= 0 && '-') ||
minTime + 'm ' + ((!autoMeet && playMin < minTime && '(Unmet)') || '(Met)')
);
};

0 comments on commit 6274f6a

Please sign in to comment.