@@ -81,15 +81,15 @@ function GwConfig:initialize_state()
81
81
}
82
82
self .comember_cache = GwHoldDownCache :new (GW_CACHE_COMEMBER_HOLD ,
83
83
GW_CACHE_COMEMBER_SOFT_MAX , GW_CACHE_COMEMBER_HARD_MAX )
84
-
84
+
85
85
return self
86
86
end
87
87
88
88
89
89
--- Dump configuration attributes.
90
90
function GwConfig :dump (keep )
91
91
local function dump_tier (t , level )
92
- level = level == nil and 0 or level
92
+ level = level == nil and 0 or level
93
93
local indent = strrep (' ' , level )
94
94
local index = {}
95
95
for i in pairs (t ) do
@@ -110,10 +110,10 @@ function GwConfig:dump(keep)
110
110
else
111
111
gw .Write (" %s%s = %s" , indent , k , tostring (t [k ]))
112
112
end
113
- end
113
+ end
114
114
end
115
115
end
116
-
116
+
117
117
gw .Write (' [Options]' )
118
118
dump_tier (GreenWall , 0 )
119
119
gw .Write (' [Configuration]' )
@@ -140,12 +140,12 @@ function GwConfig:load()
140
140
end
141
141
return estr
142
142
end
143
-
143
+
144
144
local function get_gm_officer_note ()
145
145
if not gw .IsOfficer () then
146
146
return
147
147
end
148
-
148
+
149
149
local n = GetNumGuildMembers ();
150
150
local name , rank , note
151
151
for i = 1 , n do
@@ -157,7 +157,7 @@ function GwConfig:load()
157
157
end
158
158
return
159
159
end
160
-
160
+
161
161
local xlat = {} -- Translation table for string substitution.
162
162
163
163
-- Abort if current configuration is valid
@@ -174,60 +174,64 @@ function GwConfig:load()
174
174
gw .Debug (GW_LOG_WARNING , ' not in a guild.' )
175
175
return false
176
176
end
177
-
177
+
178
178
-- Abort if configuration is not yet available
179
179
local info = GetGuildInfoText () -- Guild information text.
180
180
if info == ' ' then
181
181
gw .Debug (GW_LOG_WARNING , ' guild configuration not available.' )
182
182
return false
183
183
end
184
-
184
+
185
185
gw .Debug (GW_LOG_INFO , ' parsing guild configuration.' )
186
-
186
+
187
187
188
188
189
189
-- Soft reset of configuration
190
190
self :initialize_param ()
191
191
for k , channel in pairs (self .channel ) do
192
192
channel :age ()
193
193
end
194
-
194
+
195
195
-- Update the channel hold-down
196
196
self .timer .channel :set (GreenWall .joindelay )
197
-
197
+
198
198
--
199
199
-- Check configuration version
200
200
--
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
206
210
end
207
-
211
+
208
212
if self .cversion == 1 then
209
213
--
210
214
-- Parse version 1 configuration
211
215
--
212
216
for buffer in gmatch (info , ' GW:?(%l:[^\n ]*)' ) do
213
-
217
+
214
218
if buffer ~= nil then
215
-
219
+
216
220
self .cversion = 1
217
221
buffer = strtrim (buffer )
218
222
local field = { strsplit (' :' , buffer ) }
219
-
223
+
220
224
if field [1 ] == ' c' then
221
225
-- Guild channel configuration
222
226
if field [2 ] and field [2 ] ~= ' ' then
223
227
self .channel .guild :configure (1 , field [2 ], field [3 ])
224
228
else
225
229
gw .Error (' invalid common channel name specified' )
226
230
end
227
-
231
+
228
232
elseif field [1 ] == ' p' then
229
233
-- Peer guild
230
- local peer_name = gw .GlobalName (substitute (field [2 ], xlat ))
234
+ local peer_name = gw .GlobalName (substitute (field [2 ], xlat ))
231
235
local peer_id = substitute (field [3 ], xlat )
232
236
if gw .iCmp (guild_name , peer_name ) then
233
237
self .guild_id = peer_id
@@ -271,7 +275,7 @@ function GwConfig:load()
271
275
272
276
self .valid = true
273
277
end
274
-
278
+
275
279
-- Officer note
276
280
if GreenWall .ochat then
277
281
local note = get_gm_officer_note ()
@@ -288,7 +292,7 @@ function GwConfig:load()
288
292
else
289
293
self .channel .officer :clear ()
290
294
end
291
-
295
+
292
296
--
293
297
-- Version check
294
298
--
@@ -299,7 +303,7 @@ function GwConfig:load()
299
303
gw .Error (' Guild configuration specifies a minimum version of %s (%s currently installed).' , tostring (min ), tostring (cur ))
300
304
end
301
305
end
302
-
306
+
303
307
--
304
308
-- Clean up.
305
309
--
@@ -311,9 +315,9 @@ function GwConfig:load()
311
315
if self .valid then
312
316
self .timer .config :start ()
313
317
end
314
-
318
+
315
319
return true ;
316
-
320
+
317
321
end
318
322
319
323
0 commit comments