Skip to content

Commit

Permalink
Merge PR #81: fix critical griefing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
narc0tiq committed Sep 24, 2018
2 parents 0c540af + 904d616 commit 07540f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions locale/en/base.cfg
Expand Up @@ -6,6 +6,7 @@ YARM-warn-not-in-real-body=Oops! You can't view a remote site while you're not i
YARM-warn-in-vehicle=Oops! You can't view a remote site while you're riding a vehicle. Please finish driving first, then try again.

YARM-err-sand-is-bad=Oops! Sand really shouldn't be tracked, for performance reasons. There's way too much of it!
YARM-err-site-name-too-long=Oops! Site names aren't allowed to be longer than __1__ characters, please try a shorter name!
YARM-site-submitted=Added site "__1__" with __2__ __3__.
YARM-site-expanded=Site "__1__" updated, now has __2__ __3__ (__4__).
Expand Down
9 changes: 9 additions & 0 deletions resmon.lua
@@ -1,6 +1,10 @@
require "util"
require "libs/array_pair"

-- Sanity: site names aren't allowed to be longer than this, to prevent them
-- kicking the buttons off the right edge of the screen
local MAX_SITE_NAME_LENGTH = 50

resmon = {
on_click = {},
endless_resources = {},
Expand Down Expand Up @@ -666,6 +670,11 @@ function resmon.on_click.YARM_rename_confirm(event)
local old_name = player_data.renaming_site
local new_name = player.gui.center.YARM_site_rename.new_name.text

if string.len(new_name) > MAX_SITE_NAME_LENGTH then
player.print{'YARM-err-site-name-too-long', MAX_SITE_NAME_LENGTH}
return
end

local site = force_data.ore_sites[old_name]
force_data.ore_sites[old_name] = nil
force_data.ore_sites[new_name] = site
Expand Down

0 comments on commit 07540f3

Please sign in to comment.