Maximum length to faction names

This commit is contained in:
shamoanjac 2016-08-18 15:26:19 +02:00
parent 565608876b
commit c552a58b63
1 changed files with 7 additions and 1 deletions

View File

@ -33,12 +33,15 @@ factions.power_per_death = .25
factions.power_per_tick = .125 factions.power_per_tick = .125
factions.tick_time = 60. factions.tick_time = 60.
factions.power_per_attack = 2. factions.power_per_attack = 2.
factions.faction_name_max_length = 50
--------------------- ---------------------
--! @brief returns whether a faction can be created or not (allows for implementation of blacklists and the like) --! @brief returns whether a faction can be created or not (allows for implementation of blacklists and the like)
--! @param name String containing the faction's name --! @param name String containing the faction's name
factions.can_create_faction = function(name) factions.can_create_faction = function(name)
if factions.factions[name] then if #name > factions.faction_name_max_length then
return false
elseif factions.factions[name] then
return false return false
else else
return true return true
@ -627,6 +630,9 @@ function factions.load()
if not faction.usedpower then if not faction.usedpower then
faction.usedpower = faction:count_land() * factions.power_per_parcel faction.usedpower = faction:count_land() * factions.power_per_parcel
end end
if #faction.name > factions.faction_name_max_length then
faction:disband()
end
end end
file:close() file:close()
end end