Skip to content

Commit 576f8fd

Browse files
committed
reg-only changes
1 parent 47e96a5 commit 576f8fd

File tree

6 files changed

+50
-20
lines changed

6 files changed

+50
-20
lines changed

cfg/lcfg.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type localOptions struct {
6262
HideAutosaves bool
6363
HideResearch bool
6464
RegularsOnly bool
65-
Whitelist bool
65+
MembersOnly bool
6666
CustomWhitelist bool
6767
ModUpdate bool
6868
SkipReset bool
@@ -165,8 +165,10 @@ func setLocalDefaults() {
165165

166166
os.Mkdir(path, os.ModePerm)
167167
}
168-
if !Local.Options.Whitelist {
168+
if !Local.Options.RegularsOnly {
169169
Local.Settings.AdminOnlyPause = true
170+
} else {
171+
Local.Settings.AdminOnlyPause = false
170172
}
171173
}
172174

@@ -215,7 +217,9 @@ func ReadLCfg() bool {
215217
cwlog.DoLogCW("ReadLCfg: MapPreset not valid, setting to " + Local.Settings.MapPreset)
216218
}
217219

218-
if newcfg.Options.Whitelist {
220+
if newcfg.Options.RegularsOnly {
221+
ServerPrefix = constants.RegularsPrefix
222+
} else if newcfg.Options.MembersOnly {
219223
ServerPrefix = constants.MembersPrefix
220224
} else {
221225
ServerPrefix = ""

commands/moderator/util.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,17 @@ var SettingList = []SettingListData{
286286

287287
DefBool: false,
288288

289-
BData: &cfg.Local.Options.Whitelist,
289+
BData: &cfg.Local.Options.MembersOnly,
290+
},
291+
{
292+
Name: "regulars-only",
293+
ShortDesc: "regulars only",
294+
Desc: "Only regulars and moderators can connect.",
295+
Type: TYPE_BOOL,
296+
297+
DefBool: false,
298+
299+
BData: &cfg.Local.Options.RegularsOnly,
290300
},
291301
{
292302
Name: "restrict-new-players",

commands/user/newRegister.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ func Register(s *discordgo.Session, i *discordgo.InteractionCreate) {
6464
}
6565

6666
buf = buf + "\nThe reason this is necessary:\nYour Discord and Factorio names can be different, so this is the only way to find your player-level in Factorio.\n"
67-
if cfg.Local.Options.Whitelist {
67+
if cfg.Local.Options.RegularsOnly {
68+
buf = buf + "**NOTICE: This is a REGULARS-ONLY server, if you haven't reached the REGULAR level in-game, you will be unable to connect. If this is the case, use the /register command on a PUBLIC server.**\n"
69+
} else if cfg.Local.Options.MembersOnly {
6870
buf = buf + "**NOTICE: This is a MEMBERS-ONLY server, if you haven't reached the MEMBER level in-game, you will be unable to connect. If this is the case, use the /register command on a PUBLIC server.**\n"
6971
}
7072

fact/factConfGen.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func GenerateFactorioConfig() bool {
5757
constants.ServSettingsName
5858

5959
var servName string
60-
if cfg.Local.Options.Whitelist {
60+
if cfg.Local.Options.MembersOnly || cfg.Local.Options.RegularsOnly {
6161
if cfg.Local.Options.RegularsOnly {
6262
cfg.ServerPrefix = constants.RegularsPrefix
6363
} else {
@@ -96,7 +96,9 @@ func GenerateFactorioConfig() bool {
9696

9797
if cfg.Local.Options.CustomWhitelist {
9898
descrLines = append(descrLines, AddFactColor("red", "INVITE-ONLY"))
99-
} else if cfg.Local.Options.Whitelist {
99+
} else if cfg.Local.Options.RegularsOnly {
100+
descrLines = append(descrLines, AddFactColor("red", "REGULARS-ONLY"))
101+
} else if cfg.Local.Options.MembersOnly {
100102
descrLines = append(descrLines, AddFactColor("red", "MEMBERS-ONLY"))
101103
}
102104

@@ -136,12 +138,10 @@ func GenerateFactorioConfig() bool {
136138

137139
if cfg.Local.Options.CustomWhitelist {
138140
tags = append(tags, "INVITE-ONLY")
139-
} else if cfg.Local.Options.Whitelist {
140-
if cfg.Local.Options.RegularsOnly {
141-
tags = append(tags, "REGULARS-ONLY")
142-
} else {
143-
tags = append(tags, "MEMBERS-ONLY")
144-
}
141+
} else if cfg.Local.Options.MembersOnly {
142+
tags = append(tags, "MEMBERS-ONLY")
143+
} else if cfg.Local.Options.RegularsOnly {
144+
tags = append(tags, "REGULARS-ONLY")
145145
}
146146
tags = append(tags, cfg.Global.Paths.URLs.Domain)
147147

fact/factUtils.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,19 @@ func GetGuildName() string {
260260
/* Whitelist a specifc player. */
261261
func WhitelistPlayer(pname string, level int) {
262262
if FactorioBooted && FactIsRunning {
263-
if cfg.Local.Options.Whitelist && !cfg.Local.Options.CustomWhitelist {
263+
if !cfg.Local.Options.CustomWhitelist {
264+
return
265+
}
266+
if cfg.Local.Options.MembersOnly {
264267
if level > 0 {
265268
WriteFact(fmt.Sprintf("/whitelist add %s", pname))
266269
}
267270
}
271+
if cfg.Local.Options.RegularsOnly {
272+
if level > 1 {
273+
WriteFact(fmt.Sprintf("/whitelist add %s", pname))
274+
}
275+
}
268276
}
269277
}
270278

@@ -326,7 +334,7 @@ func WriteWhitelist() int {
326334
cfg.Global.Paths.Folders.FactorioDir + "/" +
327335
constants.WhitelistName
328336

329-
if cfg.Local.Options.Whitelist {
337+
if cfg.Local.Options.MembersOnly || cfg.Local.Options.RegularsOnly {
330338
glob.PlayerListLock.RLock()
331339

332340
var count = 0
@@ -576,10 +584,16 @@ func UpdateChannelName() {
576584

577585
var newchname string
578586
nump := NumPlayers
579-
icon := "🔵"
587+
icon := ""
580588

581-
if cfg.Local.Options.Whitelist {
582-
icon = "🟣"
589+
if cfg.Local.Options.CustomWhitelist {
590+
icon = "🔴"
591+
}
592+
if cfg.Local.Options.MembersOnly {
593+
icon = "🟢"
594+
}
595+
if cfg.Local.Options.RegularsOnly {
596+
icon = "🟠"
583597
}
584598
if nump == 0 {
585599
icon = "⚫"

support/factLauncher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,15 @@ func launchFactorio() {
343343
}
344344

345345
/* Whitelist */
346-
if cfg.Local.Options.Whitelist || cfg.Local.Options.CustomWhitelist {
346+
if cfg.Local.Options.MembersOnly || cfg.Local.Options.RegularsOnly || cfg.Local.Options.CustomWhitelist {
347347
tempargs = append(tempargs, "--use-server-whitelist")
348348
tempargs = append(tempargs, "true")
349349
}
350350

351351
/* Write or delete whitelist */
352352
if !cfg.Local.Options.CustomWhitelist {
353353
count := fact.WriteWhitelist()
354-
if count > 0 && cfg.Local.Options.Whitelist {
354+
if count > 0 && (cfg.Local.Options.MembersOnly || cfg.Local.Options.RegularsOnly) {
355355
cwlog.DoLogCW(fmt.Sprintf("Whitelist of %v players written.", count))
356356
}
357357
}

0 commit comments

Comments
 (0)