Skip to content

Commit 3cf26df

Browse files
committed
Added cpref switch. (#98)
1 parent 3b4fb3e commit 3cf26df

File tree

5 files changed

+1297
-1290
lines changed

5 files changed

+1297
-1290
lines changed

Config.lua

+32-28
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ function GwConfig:initialize_state()
8181
}
8282
self.comember_cache = GwHoldDownCache:new(GW_CACHE_COMEMBER_HOLD,
8383
GW_CACHE_COMEMBER_SOFT_MAX, GW_CACHE_COMEMBER_HARD_MAX)
84-
84+
8585
return self
8686
end
8787

8888

8989
--- Dump configuration attributes.
9090
function GwConfig:dump(keep)
9191
local function dump_tier(t, level)
92-
level = level == nil and 0 or level
92+
level = level == nil and 0 or level
9393
local indent = strrep(' ', level)
9494
local index = {}
9595
for i in pairs(t) do
@@ -110,10 +110,10 @@ function GwConfig:dump(keep)
110110
else
111111
gw.Write("%s%s = %s", indent, k, tostring(t[k]))
112112
end
113-
end
113+
end
114114
end
115115
end
116-
116+
117117
gw.Write('[Options]')
118118
dump_tier(GreenWall, 0)
119119
gw.Write('[Configuration]')
@@ -140,12 +140,12 @@ function GwConfig:load()
140140
end
141141
return estr
142142
end
143-
143+
144144
local function get_gm_officer_note()
145145
if not gw.IsOfficer() then
146146
return
147147
end
148-
148+
149149
local n = GetNumGuildMembers();
150150
local name, rank, note
151151
for i = 1, n do
@@ -157,7 +157,7 @@ function GwConfig:load()
157157
end
158158
return
159159
end
160-
160+
161161
local xlat = {} -- Translation table for string substitution.
162162

163163
-- Abort if current configuration is valid
@@ -174,60 +174,64 @@ function GwConfig:load()
174174
gw.Debug(GW_LOG_WARNING, 'not in a guild.')
175175
return false
176176
end
177-
177+
178178
-- Abort if configuration is not yet available
179179
local info = GetGuildInfoText() -- Guild information text.
180180
if info == '' then
181181
gw.Debug(GW_LOG_WARNING, 'guild configuration not available.')
182182
return false
183183
end
184-
184+
185185
gw.Debug(GW_LOG_INFO, 'parsing guild configuration.')
186-
186+
187187

188188

189189
-- Soft reset of configuration
190190
self:initialize_param()
191191
for k, channel in pairs(self.channel) do
192192
channel:age()
193193
end
194-
194+
195195
-- Update the channel hold-down
196196
self.timer.channel:set(GreenWall.joindelay)
197-
197+
198198
--
199199
-- Check configuration version
200200
--
201-
if strmatch(info, 'GWc=".*"') then
202-
gw.Error('Guild configuration uses a format not supported by this version.')
203-
end
204-
if strmatch(info, 'GW:?c:') then
205-
self.cversion = 1
201+
if self.cpref == 0 then
202+
if strmatch(info, 'GWc=".*"') then
203+
gw.Error('Guild configuration uses a format not supported by this version.')
204+
end
205+
if strmatch(info, 'GW:?c:') then
206+
self.cversion = 1
207+
end
208+
else
209+
self.cversion = cpref
206210
end
207-
211+
208212
if self.cversion == 1 then
209213
--
210214
-- Parse version 1 configuration
211215
--
212216
for buffer in gmatch(info, 'GW:?(%l:[^\n]*)') do
213-
217+
214218
if buffer ~= nil then
215-
219+
216220
self.cversion = 1
217221
buffer = strtrim(buffer)
218222
local field = { strsplit(':', buffer) }
219-
223+
220224
if field[1] == 'c' then
221225
-- Guild channel configuration
222226
if field[2] and field[2] ~= '' then
223227
self.channel.guild:configure(1, field[2], field[3])
224228
else
225229
gw.Error('invalid common channel name specified')
226230
end
227-
231+
228232
elseif field[1] == 'p' then
229233
-- Peer guild
230-
local peer_name = gw.GlobalName(substitute(field[2], xlat))
234+
local peer_name = gw.GlobalName(substitute(field[2], xlat))
231235
local peer_id = substitute(field[3], xlat)
232236
if gw.iCmp(guild_name, peer_name) then
233237
self.guild_id = peer_id
@@ -271,7 +275,7 @@ function GwConfig:load()
271275

272276
self.valid = true
273277
end
274-
278+
275279
-- Officer note
276280
if GreenWall.ochat then
277281
local note = get_gm_officer_note()
@@ -288,7 +292,7 @@ function GwConfig:load()
288292
else
289293
self.channel.officer:clear()
290294
end
291-
295+
292296
--
293297
-- Version check
294298
--
@@ -299,7 +303,7 @@ function GwConfig:load()
299303
gw.Error('Guild configuration specifies a minimum version of %s (%s currently installed).', tostring(min), tostring(cur))
300304
end
301305
end
302-
306+
303307
--
304308
-- Clean up.
305309
--
@@ -311,9 +315,9 @@ function GwConfig:load()
311315
if self.valid then
312316
self.timer.config:start()
313317
end
314-
318+
315319
return true;
316-
320+
317321
end
318322

319323

Globals.lua

+10-7
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,21 @@ gw.option = {
6969
redact = { default=true,
7070
desc="obfuscate sensitive data in debug output" },
7171
joindelay = { default=30, min=0, max=120, step=1,
72-
desc="channel join delay" }
72+
desc="channel join delay" },
73+
-- Development switch to force preferred configuration version.
74+
cpref = { default=0, min=0, max=2,
75+
desc="force the configuration version" }
7376
}
7477

7578
gw.usage = [[
76-
79+
7780
Usage:
78-
81+
7982
/greenwall <command> or /gw <command>
80-
83+
8184
Commands:
82-
83-
help
85+
86+
help
8487
-- Print this message.
8588
version
8689
-- Print the add-on version.
@@ -114,6 +117,6 @@ gw.usage = [[
114117
-- Specify the maximum number of log entries to keep.
115118
admin reload
116119
-- (officer only) Force a reload of the configuration by all online guild members.
117-
120+
118121
]]
119122

GreenWall.toc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## Interface: 60200
22
## Title: GreenWall
3-
## Notes: Common communication channel as a replacement for guild chat in guild confederations.
3+
## Notes: Common communication channel as a replacement for guild chat in guild confederations.
44
## Author: Mark Rogaski <[email protected]>
5-
## Version: 1.7.0
5+
## Version: 2.0.0-dev
66
## URL: https://github.com/AIE-Guild/GreenWall
77
## URL: http://wow.curse.com/downloads/wow-addons/details/greenwall.aspx
88
## DefaultState: enabled

0 commit comments

Comments
 (0)