1
by luke-jr
Unify tags/branches of modules released together |
1 |
/*
|
2 |
||
3 |
*************************************************************************
|
|
4 |
||
5 |
ArmageTron -- Just another Tron Lightcycle Game in 3D.
|
|
6 |
Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
|
|
7 |
||
8 |
**************************************************************************
|
|
9 |
||
10 |
This program is free software; you can redistribute it and/or
|
|
11 |
modify it under the terms of the GNU General Public License
|
|
12 |
as published by the Free Software Foundation; either version 2
|
|
13 |
of the License, or (at your option) any later version.
|
|
14 |
||
15 |
This program is distributed in the hope that it will be useful,
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 |
GNU General Public License for more details.
|
|
19 |
||
20 |
You should have received a copy of the GNU General Public License
|
|
21 |
along with this program; if not, write to the Free Software
|
|
22 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
699
by Kyle
DELAY_COMMAND now checks for access level of the command to delay, also ADMIN_COMMAND now only prints out valid commands for the users access level |
23 |
|
1
by luke-jr
Unify tags/branches of modules released together |
24 |
***************************************************************************
|
25 |
||
26 |
*/
|
|
27 |
||
28 |
#include "config.h" |
|
29 |
#include <fstream> |
|
30 |
#include <iomanip> |
|
31 |
#include <iostream> |
|
32 |
#include "tConfiguration.h" |
|
33 |
#include <stdlib.h> |
|
34 |
#include <ctype.h> |
|
35 |
#include <string> |
|
36 |
#include <sstream> |
|
37 |
#include "tString.h" |
|
38 |
#include "tToDo.h" |
|
39 |
#include "tConsole.h" |
|
40 |
#include "tDirectories.h" |
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
41 |
#include "tLocale.h" |
1
by luke-jr
Unify tags/branches of modules released together |
42 |
#include "tRecorder.h" |
43 |
#include "tCommandLine.h" |
|
447
by luke-jr
the rest of RInclude, since I just accidentally committed part of it; revert if you like |
44 |
#include "tResourceManager.h" |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
45 |
#include "tError.h" |
1
by luke-jr
Unify tags/branches of modules released together |
46 |
|
47 |
#include <vector> |
|
471
by z-man
GCC 4.3 patches submitted by Fedora maintainer Jon Ciesla (limb@dont.spam.jcomserv.net) |
48 |
#include <string.h> |
1
by luke-jr
Unify tags/branches of modules released together |
49 |
|
501
by z-man
Configuration files get reloaded on SIGHUP |
50 |
#ifndef WIN32
|
51 |
#include <signal.h> |
|
52 |
#endif
|
|
53 |
||
1
by luke-jr
Unify tags/branches of modules released together |
54 |
/***********************************************************************
|
55 |
* The new Configuration interface, currently not completely implemented
|
|
56 |
*/
|
|
57 |
||
58 |
#ifndef NEW_CONFIGURATION_NO_COMPILE
|
|
59 |
||
60 |
// Use this function to register your own configuration directive
|
|
61 |
// returns true if it was successful, false if not
|
|
62 |
// should return true even if it didn't register the new directive because
|
|
63 |
// it was already there
|
|
64 |
bool tConfiguration::registerDirective(string newDirective, string defValue) { |
|
65 |
// THIS IS A STUB
|
|
66 |
}
|
|
67 |
||
68 |
// Use this function to set a configuration directive from a string
|
|
69 |
bool tConfiguration::setDirective(string oldDirective, string newValue) { |
|
70 |
// THIS IS A STUB
|
|
71 |
}
|
|
72 |
||
73 |
// Use this function to set a configuration directive from an int
|
|
74 |
bool tConfiguration::setDirective(string oldDirective, int newValue) { |
|
75 |
// THIS IS A STUB
|
|
76 |
}
|
|
77 |
||
78 |
// Use this function to set a configuration directive from a float
|
|
79 |
bool tConfiguration::setDirective(string oldDirective, double newValue) { |
|
80 |
// THIS IS A STUB
|
|
81 |
}
|
|
82 |
||
83 |
// Use this function to set a configuration directive from a bool
|
|
84 |
bool tConfiguration::setDirective(string oldDirective, bool newValue) { |
|
85 |
// THIS IS A STUB
|
|
86 |
}
|
|
87 |
||
88 |
// Use this function to get a configuration directive as a string
|
|
89 |
const string& tConfiguration::getDirective(string oldDirective) { |
|
90 |
// THIS IS A STUB
|
|
91 |
}
|
|
92 |
||
93 |
// Use this function to get a configuration directive as an int
|
|
94 |
const int& tConfiguration::getDirectiveI(string oldDirective) { |
|
95 |
// THIS IS A STUB
|
|
96 |
}
|
|
97 |
||
98 |
// Use this function to get a configuration directive as a double
|
|
99 |
const double& tConfiguration::getDirectiveF(string oldDirective) { |
|
100 |
// THIS IS A STUB
|
|
101 |
}
|
|
102 |
||
103 |
// Use this function to get a configuration directive as a bool
|
|
104 |
const bool& tConfiguration::getDirectiveB(string oldDirective) { |
|
105 |
// THIS IS A STUB
|
|
106 |
}
|
|
107 |
||
108 |
// Use this function to load a file
|
|
109 |
// You *MUST* pass it a complete path from the root directory!
|
|
110 |
// Returns TRUE if it can open the file and load at least some of it
|
|
111 |
// Returns FALSE if complete failure.
|
|
112 |
bool tConfiguration::LoadFile(string filename) { |
|
113 |
// THIS IS A STUB
|
|
114 |
}
|
|
115 |
||
116 |
// Use this function to save current configuration to files
|
|
117 |
// Returns TRUE on success, FALSE on failure
|
|
118 |
bool tConfiguration::SaveFile() { |
|
119 |
// THIS IS A STUB
|
|
120 |
}
|
|
121 |
||
122 |
// This function is used internally to actually set each directive
|
|
123 |
bool tConfiguration::_setDirective(string oldDirective, tConfigurationItem& newItem) { |
|
124 |
// THIS IS A STUB
|
|
125 |
}
|
|
126 |
||
127 |
// This function registers basic configuration directives
|
|
128 |
// Create a new configuration directive by going to this function and
|
|
129 |
// putting the appropriate line, then just use it in the game
|
|
130 |
// It registers global defaults, but not object-specific defaults
|
|
131 |
void tConfiguration::_registerDefaults() { |
|
132 |
// THIS IS A STUB
|
|
133 |
}
|
|
134 |
||
135 |
tConfiguration* tConfiguration::_instance = 0; |
|
136 |
||
137 |
const tConfiguration* tConfiguration::GetConfiguration() { |
|
138 |
if(_instance = 0) { |
|
139 |
_instance = new tConfiguration; |
|
140 |
}
|
|
141 |
||
142 |
return _instance; |
|
143 |
}
|
|
144 |
||
145 |
#endif
|
|
146 |
/*
|
|
147 |
* The old stuff follows
|
|
148 |
************************************************************************/
|
|
149 |
||
150 |
bool tConfItemBase::printChange=true; |
|
151 |
bool tConfItemBase::printErrors=true; |
|
152 |
||
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
153 |
//Stolen from 0.4. Allows you to toggle boolean commands.
|
154 |
static void st_ToggleConfigItem( std::istream & s ) |
|
155 |
{
|
|
156 |
tString name; |
|
157 |
s >> name; |
|
158 |
||
159 |
if ( name.Size() == 0 ) |
|
160 |
{
|
|
161 |
con << tOutput( "$toggle_usage_error" ); |
|
162 |
return; |
|
163 |
}
|
|
164 |
||
165 |
tConfItemBase *base = tConfItemBase::FindConfigItem2( name ); |
|
166 |
||
167 |
if ( !base ) |
|
168 |
{
|
|
169 |
con << tOutput( "$config_command_unknown", name ); |
|
170 |
return; |
|
171 |
}
|
|
172 |
||
173 |
tConfItem< bool > *confItem = dynamic_cast< tConfItem< bool > * >( base ); |
|
174 |
if ( confItem && confItem->Writable() ) |
|
175 |
{
|
|
176 |
confItem->SetVal( !*confItem->GetTarget() ); |
|
177 |
}
|
|
178 |
else
|
|
179 |
{
|
|
180 |
con << tOutput( "$toggle_invalid_config_item", name ); |
|
181 |
}
|
|
182 |
}
|
|
183 |
||
184 |
static tConfItemFunc toggleConfItemFunc( "TOGGLE", st_ToggleConfigItem ); |
|
185 |
||
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
186 |
|
187 |
//! @param newLevel the new access level to set over the course of the lifetime of this object
|
|
188 |
//! @param allowElevation only if set to true, getting higher access rights is possible. Use with extreme care.
|
|
189 |
tCurrentAccessLevel::tCurrentAccessLevel( tAccessLevel newLevel, bool allowElevation ) |
|
190 |
{
|
|
191 |
// prevent elevation
|
|
192 |
if ( !allowElevation && newLevel < currentLevel_ ) |
|
193 |
{
|
|
194 |
// you probably want to know when this happens in the debugger
|
|
195 |
st_Breakpoint(); |
|
196 |
newLevel = currentLevel_; |
|
197 |
}
|
|
198 |
||
199 |
lastLevel_ = currentLevel_; |
|
200 |
currentLevel_ = newLevel; |
|
201 |
}
|
|
202 |
||
203 |
||
204 |
tCurrentAccessLevel::tCurrentAccessLevel() |
|
205 |
{
|
|
206 |
lastLevel_ = currentLevel_; |
|
207 |
}
|
|
208 |
||
209 |
tCurrentAccessLevel::~tCurrentAccessLevel() |
|
210 |
{
|
|
211 |
currentLevel_ = lastLevel_; |
|
212 |
}
|
|
213 |
||
214 |
//! returns the current access level
|
|
215 |
tAccessLevel tCurrentAccessLevel::GetAccessLevel() |
|
216 |
{
|
|
563.1.397
by Manuel Moos
Map settings are now executed with the access level of the user setting MAP_FILE. |
217 |
tASSERT( currentLevel_ != tAccessLevel_Invalid ); |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
218 |
return currentLevel_; |
219 |
}
|
|
220 |
||
221 |
// returns the name of an access level
|
|
222 |
tString tCurrentAccessLevel::GetName( tAccessLevel level ) |
|
223 |
{
|
|
224 |
std::ostringstream s; |
|
225 |
s << "$config_accesslevel_" << level; |
|
226 |
return tString( tOutput( s.str().c_str() ) ); |
|
227 |
}
|
|
228 |
||
948
by zodiacsohma1 at gmail
Updated english_base.txt with the latest (forgot to do it last time). |
229 |
tAccessLevel tCurrentAccessLevel::currentLevel_ = tAccessLevel_Invalid; //!< the current access level |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
230 |
|
231 |
tAccessLevelSetter::tAccessLevelSetter( tConfItemBase & item, tAccessLevel level ) |
|
232 |
{
|
|
563.24.17
by Manuel Moos
Without armathentication built in, now all console commands stay |
233 |
#ifdef KRAWALL_SERVER
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
234 |
item.requiredLevel = level; |
563.24.17
by Manuel Moos
Without armathentication built in, now all console commands stay |
235 |
#endif
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
236 |
}
|
237 |
||
1
by luke-jr
Unify tags/branches of modules released together |
238 |
static std::map< tString, tConfItemBase * > * st_confMap = 0; |
239 |
tConfItemBase::tConfItemMap & tConfItemBase::ConfItemMap() |
|
240 |
{
|
|
241 |
if (!st_confMap) |
|
242 |
st_confMap = tNEW( tConfItemMap ); |
|
243 |
return *st_confMap; |
|
244 |
}
|
|
245 |
||
563.24.189
by Manuel Moos
Made configuration map readable by everyone; |
246 |
tConfItemBase::tConfItemMap const & tConfItemBase::GetConfItemMap() |
247 |
{
|
|
248 |
return ConfItemMap(); |
|
249 |
}
|
|
250 |
||
563.1.404
by Manuel Moos
Oops, fixed non-krawall compilation. |
251 |
static bool st_preventCasacl = false; |
252 |
||
253 |
tCasaclPreventer::tCasaclPreventer( bool prevent ) |
|
254 |
{
|
|
255 |
previous_ = st_preventCasacl; |
|
256 |
st_preventCasacl = prevent; |
|
257 |
}
|
|
258 |
||
259 |
tCasaclPreventer::~tCasaclPreventer() |
|
260 |
{
|
|
261 |
st_preventCasacl = previous_; |
|
262 |
}
|
|
263 |
||
563.24.189
by Manuel Moos
Made configuration map readable by everyone; |
264 |
//! returns whether we're currently in an RINCLUDE file
|
265 |
bool tCasaclPreventer::InRInclude() |
|
266 |
{
|
|
267 |
return st_preventCasacl; |
|
268 |
}
|
|
269 |
||
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
270 |
// changes the access level of a configuration item
|
271 |
class tConfItemLevel: public tConfItemBase |
|
272 |
{
|
|
273 |
public: |
|
274 |
tConfItemLevel() |
|
275 |
: tConfItemBase( "ACCESS_LEVEL" ) |
|
276 |
{
|
|
277 |
requiredLevel = tAccessLevel_Owner; |
|
278 |
}
|
|
279 |
||
280 |
virtual void ReadVal(std::istream &s) |
|
281 |
{
|
|
282 |
// read name and access level
|
|
283 |
tString name; |
|
284 |
s >> name; |
|
285 |
||
286 |
int levelInt; |
|
287 |
s >> levelInt; |
|
288 |
tAccessLevel level = static_cast< tAccessLevel >( levelInt ); |
|
289 |
||
290 |
if ( s.fail() ) |
|
291 |
{
|
|
563.1.101
by wrtlprnft
No longer print successful calls to ACCESS_LEVEL and USER_LEVEL to the console when loading a config file at start |
292 |
if(printErrors) |
293 |
{
|
|
294 |
con << tOutput( "$access_level_usage" ); |
|
295 |
}
|
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
296 |
return; |
297 |
}
|
|
298 |
||
299 |
// make name uppercase:
|
|
300 |
tToUpper( name ); |
|
301 |
||
302 |
// find the item
|
|
303 |
tConfItemMap & confmap = ConfItemMap(); |
|
304 |
tConfItemMap::iterator iter = confmap.find( name ); |
|
305 |
if ( iter != confmap.end() ) |
|
306 |
{
|
|
307 |
// and change the level
|
|
308 |
tConfItemBase * ci = (*iter).second; |
|
563.24.189
by Manuel Moos
Made configuration map readable by everyone; |
309 |
|
310 |
if( ci->requiredLevel < tCurrentAccessLevel::GetAccessLevel() ) |
|
311 |
{
|
|
779
by zodiacsohma1 at gmail
Transfered MAP_ROTATION and it's supporting scripts and stuff from |
312 |
con << tOutput( "$access_level_nochange_now", |
313 |
name, |
|
563.24.189
by Manuel Moos
Made configuration map readable by everyone; |
314 |
tCurrentAccessLevel::GetName( ci->requiredLevel ), |
315 |
tCurrentAccessLevel::GetName( tCurrentAccessLevel::GetAccessLevel() ) ); |
|
316 |
}
|
|
317 |
else if( level < tCurrentAccessLevel::GetAccessLevel() ) |
|
318 |
{
|
|
779
by zodiacsohma1 at gmail
Transfered MAP_ROTATION and it's supporting scripts and stuff from |
319 |
con << tOutput( "$access_level_nochange_later", |
320 |
name, |
|
563.24.189
by Manuel Moos
Made configuration map readable by everyone; |
321 |
tCurrentAccessLevel::GetName( level ), |
322 |
tCurrentAccessLevel::GetName( tCurrentAccessLevel::GetAccessLevel() ) ); |
|
323 |
}
|
|
324 |
else if ( ci->requiredLevel != level ) |
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
325 |
{
|
947
by zodiacsohma1 at gmail
Merged with 0.4 r1516. |
326 |
if(printChange) |
327 |
{
|
|
328 |
con << tOutput( "$access_level_change", name, tCurrentAccessLevel::GetName( ci->requiredLevel ) , tCurrentAccessLevel::GetName( level ) ); |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
329 |
}
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
330 |
ci->requiredLevel = level; |
331 |
}
|
|
332 |
}
|
|
563.1.101
by wrtlprnft
No longer print successful calls to ACCESS_LEVEL and USER_LEVEL to the console when loading a config file at start |
333 |
else if(printErrors) |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
334 |
{
|
335 |
con << tOutput( "$config_command_unknown", name ); |
|
336 |
}
|
|
337 |
}
|
|
338 |
||
339 |
virtual void WriteVal(std::ostream &s) |
|
340 |
{
|
|
341 |
tASSERT(0); |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
342 |
}
|
343 |
||
913
by zodiacsohma1 at gmail
Updated the language file, english_base.txt. |
344 |
virtual void FetchVal(tString &val){}; |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
345 |
|
346 |
virtual bool Writable(){ |
|
347 |
return false; |
|
348 |
}
|
|
349 |
||
350 |
virtual bool Save(){ |
|
351 |
return false; |
|
352 |
}
|
|
563.24.189
by Manuel Moos
Made configuration map readable by everyone; |
353 |
|
354 |
// CAN this be saved at all?
|
|
355 |
virtual bool CanSave(){ |
|
356 |
return false; |
|
357 |
}
|
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
358 |
};
|
359 |
||
360 |
static tConfItemLevel st_confLevel; |
|
361 |
||
563.24.17
by Manuel Moos
Without armathentication built in, now all console commands stay |
362 |
#ifdef KRAWALL_SERVER
|
363 |
||
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
364 |
static char const *st_casacl = "CASACL"; |
365 |
||
366 |
//! casacl (Check And Set ACcess Level) command: elevates the access level for the context of the current configuration file
|
|
367 |
class tCasacl: tConfItemBase |
|
368 |
{
|
|
369 |
public: |
|
370 |
tCasacl() |
|
371 |
: tConfItemBase( st_casacl ) |
|
372 |
{
|
|
373 |
requiredLevel = tAccessLevel_Program; |
|
374 |
}
|
|
375 |
||
376 |
virtual void ReadVal( std::istream & s ) |
|
377 |
{
|
|
378 |
int required_int = 0, elevated_int = 20; |
|
379 |
||
380 |
// read required and elevated access levels
|
|
381 |
s >> required_int; |
|
382 |
s >> elevated_int; |
|
383 |
||
384 |
tAccessLevel elevated = static_cast< tAccessLevel >( elevated_int ); |
|
385 |
tAccessLevel required = static_cast< tAccessLevel >( required_int ); |
|
386 |
||
387 |
if ( s.fail() ) |
|
388 |
{
|
|
563.2.1
by wrtlprnft
Fixed two bugs regarding CASACL |
389 |
con << tOutput( "$casacl_usage" ); |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
390 |
throw tAbortLoading( st_casacl ); |
391 |
}
|
|
392 |
else if ( tCurrentAccessLevel::GetAccessLevel() > required ) |
|
393 |
{
|
|
394 |
con << tOutput( "$access_level_error", |
|
563.24.189
by Manuel Moos
Made configuration map readable by everyone; |
395 |
"CASACL", |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
396 |
tCurrentAccessLevel::GetName( required ), |
397 |
tCurrentAccessLevel::GetName( tCurrentAccessLevel::GetAccessLevel() ) |
|
398 |
);
|
|
399 |
throw tAbortLoading( st_casacl ); |
|
400 |
}
|
|
563.1.403
by Manuel Moos
Disabling CASACL during RINCLUDE. |
401 |
else if ( st_preventCasacl ) |
402 |
{
|
|
403 |
con << tOutput( "$casacl_not_allowed" ); |
|
404 |
throw tAbortLoading( st_casacl ); |
|
405 |
}
|
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
406 |
else
|
407 |
{
|
|
563.2.1
by wrtlprnft
Fixed two bugs regarding CASACL |
408 |
tString().ReadLine(s); // prevent commands following this one without a newline |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
409 |
tCurrentAccessLevel::currentLevel_ = elevated; |
410 |
}
|
|
411 |
}
|
|
412 |
||
413 |
virtual void WriteVal(std::ostream &s) |
|
414 |
{
|
|
415 |
tASSERT(0); |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
416 |
}
|
417 |
||
913
by zodiacsohma1 at gmail
Updated the language file, english_base.txt. |
418 |
virtual void FetchVal(tString &val){}; |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
419 |
|
420 |
virtual bool Writable(){ |
|
421 |
return false; |
|
422 |
}
|
|
423 |
||
424 |
virtual bool Save(){ |
|
425 |
return false; |
|
426 |
}
|
|
563.24.189
by Manuel Moos
Made configuration map readable by everyone; |
427 |
|
428 |
// CAN this be saved at all?
|
|
429 |
virtual bool CanSave(){ |
|
430 |
return false; |
|
431 |
}
|
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
432 |
};
|
433 |
||
434 |
static tCasacl st_sudo; |
|
435 |
||
436 |
#endif
|
|
437 |
||
1
by luke-jr
Unify tags/branches of modules released together |
438 |
bool st_FirstUse=true; |
439 |
static tConfItem<bool> fu("FIRST_USE",st_FirstUse); |
|
440 |
//static tConfItem<bool> fu("FIRST_USE","help_first_use",st_FirstUse);
|
|
441 |
||
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
442 |
|
443 |
tAbortLoading::tAbortLoading( char const * command ) |
|
444 |
: command_( command ) |
|
445 |
{
|
|
446 |
}
|
|
447 |
||
448 |
tString tAbortLoading::DoGetName() const |
|
449 |
{
|
|
450 |
return tString(tOutput( "$abort_loading_name")); |
|
451 |
}
|
|
452 |
||
453 |
tString tAbortLoading::DoGetDescription() const |
|
454 |
{
|
|
455 |
return tString(tOutput( "$abort_loading_description", command_ )); |
|
971
by zodiacsohma1 at gmail
Improved the racing code and the rankings system. |
456 |
}
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
457 |
|
1
by luke-jr
Unify tags/branches of modules released together |
458 |
tConfItemBase::tConfItemBase(const char *t) |
459 |
:id(-1),title(t), |
|
460 |
changed(false){ |
|
461 |
||
462 |
tConfItemMap & confmap = ConfItemMap(); |
|
463 |
if ( confmap.find( title ) != confmap.end() ) |
|
464 |
tERR_ERROR_INT("Two tConfItems with the same name " << t << "!"); |
|
465 |
||
466 |
// compose help name
|
|
467 |
tString helpname; |
|
468 |
helpname << title << "_help"; |
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
469 |
tToLower( helpname ); |
1
by luke-jr
Unify tags/branches of modules released together |
470 |
|
471 |
const_cast<tOutput&>(help).AddLocale(helpname); |
|
472 |
||
473 |
confmap[title] = this; |
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
474 |
|
971
by zodiacsohma1 at gmail
Improved the racing code and the rankings system. |
475 |
requiredLevel = tAccessLevel_Admin; |
476 |
setLevel = tAccessLevel_Owner; |
|
1
by luke-jr
Unify tags/branches of modules released together |
477 |
}
|
478 |
||
479 |
tConfItemBase::tConfItemBase(const char *t, const tOutput& h) |
|
480 |
:id(-1),title(t), help(h), |
|
481 |
changed(false){ |
|
482 |
||
483 |
tConfItemMap & confmap = ConfItemMap(); |
|
484 |
if ( confmap.find( title ) != confmap.end() ) |
|
485 |
tERR_ERROR_INT("Two tConfItems with the same name " << t << "!"); |
|
486 |
||
487 |
confmap[title] = this; |
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
488 |
|
971
by zodiacsohma1 at gmail
Improved the racing code and the rankings system. |
489 |
requiredLevel = tAccessLevel_Admin; |
490 |
setLevel = tAccessLevel_Owner; |
|
1
by luke-jr
Unify tags/branches of modules released together |
491 |
}
|
492 |
||
493 |
tConfItemBase::~tConfItemBase() |
|
494 |
{
|
|
495 |
tConfItemMap & confmap = ConfItemMap(); |
|
496 |
confmap.erase(title); |
|
497 |
if ( confmap.size() == 0 ) |
|
498 |
{
|
|
499 |
delete st_confMap; |
|
500 |
st_confMap = 0; |
|
501 |
}
|
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
502 |
}
|
503 |
||
504 |
void tConfItemBase::ExportAll(){ |
|
505 |
SaveAll(std::cout, true); |
|
1
by luke-jr
Unify tags/branches of modules released together |
506 |
}
|
507 |
||
998
by zodiacsohma1 at gmail
Merged with 0.2.8-armagetronad-sty+ct of revision 785 by Voodoo: |
508 |
void tConfItemBase::SaveAll(std::ostream &s, bool all){ |
1
by luke-jr
Unify tags/branches of modules released together |
509 |
tConfItemMap & confmap = ConfItemMap(); |
510 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
|
511 |
{
|
|
512 |
tConfItemBase * ci = (*iter).second; |
|
998
by zodiacsohma1 at gmail
Merged with 0.2.8-armagetronad-sty+ct of revision 785 by Voodoo: |
513 |
if ((!all && ci->Save())||(all && ci->CanSave())){ |
941
by zodiacsohma1 at gmail
Fixed bug in CHATTERS_* commands. |
514 |
s << ci->title << " "; |
1
by luke-jr
Unify tags/branches of modules released together |
515 |
ci->WriteVal(s); |
941
by zodiacsohma1 at gmail
Fixed bug in CHATTERS_* commands. |
516 |
s << "\n"; |
1
by luke-jr
Unify tags/branches of modules released together |
517 |
}
|
518 |
}
|
|
519 |
}
|
|
520 |
||
521 |
int tConfItemBase::EatWhitespace(std::istream &s){ |
|
522 |
int c=' '; |
|
523 |
||
109
by z-man
More isspace->isblank replacements. |
524 |
while(isblank(c) && |
1
by luke-jr
Unify tags/branches of modules released together |
525 |
c!='\n' && |
526 |
s.good() && |
|
527 |
!s.eof()) |
|
528 |
c=s.get(); |
|
529 |
||
563.24.171
by z-man
Merging gcc 4.x fixes, mostly just warnings about unread variables, plus |
530 |
if( s.good() ) |
531 |
{
|
|
532 |
s.putback(c); |
|
533 |
}
|
|
1
by luke-jr
Unify tags/branches of modules released together |
534 |
|
535 |
return c; |
|
536 |
}
|
|
537 |
||
538 |
void tConfItemBase::LoadLine(std::istream &s){ |
|
563.1.48
by Manuel Moos
Two more (redundant) fixes for the CASACL problem. |
539 |
if(!s.eof() && s.good()){ |
1
by luke-jr
Unify tags/branches of modules released together |
540 |
tString name; |
541 |
s >> name; |
|
542 |
||
543 |
// make name uppercase:
|
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
544 |
tToUpper( name ); |
1
by luke-jr
Unify tags/branches of modules released together |
545 |
|
546 |
bool found=false; |
|
547 |
||
548 |
if (name[0]=='#'){ // comment. ignore rest of line |
|
549 |
char c=' '; |
|
550 |
while(c!='\n' && s.good() && !s.eof()) c=s.get(); |
|
551 |
found=true; |
|
552 |
}
|
|
553 |
||
554 |
if (strlen(name)==0) // ignore empty lines |
|
555 |
found=true; |
|
556 |
||
557 |
tConfItemMap & confmap = ConfItemMap(); |
|
558 |
tConfItemMap::iterator iter = confmap.find( name ); |
|
559 |
if ( iter != confmap.end() ) |
|
560 |
{
|
|
561 |
tConfItemBase * ci = (*iter).second; |
|
562 |
||
563 |
bool cb=ci->changed; |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
564 |
ci->changed=false; |
565 |
||
566 |
#ifdef DEBUG
|
|
567 |
con << "Current level: " << tCurrentAccessLevel::GetAccessLevel() << "\n"; |
|
568 |
con << "Required level: " << ci->requiredLevel << "\n"; |
|
569 |
#endif
|
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
570 |
|
571 |
if ( ci->requiredLevel >= tCurrentAccessLevel::GetAccessLevel() ) |
|
572 |
{
|
|
563.1.397
by Manuel Moos
Map settings are now executed with the access level of the user setting MAP_FILE. |
573 |
ci->setLevel = tCurrentAccessLevel::GetAccessLevel(); |
574 |
||
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
575 |
ci->ReadVal(s); |
576 |
if (ci->changed) |
|
563.1.397
by Manuel Moos
Map settings are now executed with the access level of the user setting MAP_FILE. |
577 |
{
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
578 |
ci->WasChanged(); |
563.1.397
by Manuel Moos
Map settings are now executed with the access level of the user setting MAP_FILE. |
579 |
}
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
580 |
else
|
563.1.397
by Manuel Moos
Map settings are now executed with the access level of the user setting MAP_FILE. |
581 |
{
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
582 |
ci->changed=cb; |
563.1.397
by Manuel Moos
Map settings are now executed with the access level of the user setting MAP_FILE. |
583 |
}
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
584 |
}
|
1
by luke-jr
Unify tags/branches of modules released together |
585 |
else
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
586 |
{
|
587 |
tString discard; |
|
588 |
discard.ReadLine(s); |
|
699
by Kyle
DELAY_COMMAND now checks for access level of the command to delay, also ADMIN_COMMAND now only prints out valid commands for the users access level |
589 |
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
590 |
con << tOutput( "$access_level_error", |
699
by Kyle
DELAY_COMMAND now checks for access level of the command to delay, also ADMIN_COMMAND now only prints out valid commands for the users access level |
591 |
name, |
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
592 |
tCurrentAccessLevel::GetName( ci->requiredLevel ), |
593 |
tCurrentAccessLevel::GetName( tCurrentAccessLevel::GetAccessLevel() ) |
|
594 |
);
|
|
595 |
return; |
|
596 |
}
|
|
1
by luke-jr
Unify tags/branches of modules released together |
597 |
|
598 |
found=true; |
|
599 |
}
|
|
600 |
||
601 |
if (!found){ |
|
602 |
// eat rest of input line
|
|
603 |
tString rest; |
|
604 |
rest.ReadLine( s ); |
|
605 |
||
606 |
if (printErrors) |
|
607 |
{
|
|
608 |
tOutput o; |
|
609 |
o.SetTemplateParameter(1, name); |
|
610 |
o << "$config_command_unknown"; |
|
611 |
con << o; |
|
612 |
||
613 |
if (printChange) |
|
614 |
{
|
|
615 |
int sim_maxlen=-1; |
|
616 |
||
617 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
|
618 |
{
|
|
619 |
tConfItemBase * ci = (*iter).second; |
|
620 |
if (strstr(ci->title,name) && |
|
621 |
static_cast<int>(strlen(ci->title)) > sim_maxlen) |
|
622 |
sim_maxlen=strlen(ci->title); |
|
623 |
}
|
|
624 |
||
625 |
if (sim_maxlen>0 && printChange ){ |
|
626 |
int len = name.Len()-1; |
|
627 |
int printMax = 1 + 3 * len * len * len; |
|
628 |
con << tOutput("$config_command_other"); |
|
629 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
|
630 |
{
|
|
631 |
tConfItemBase * ci = (*iter).second; |
|
632 |
if (strstr(ci->title,name)) |
|
633 |
{
|
|
634 |
tString help ( ci->help ); |
|
635 |
if ( --printMax > 0 ) |
|
636 |
{
|
|
637 |
tString mess; |
|
638 |
mess << ci->title; |
|
639 |
mess.SetPos( sim_maxlen+2, false ); |
|
640 |
mess << "("; |
|
641 |
mess << help; |
|
642 |
mess << ")\n"; |
|
643 |
con << mess; |
|
644 |
}
|
|
645 |
}
|
|
646 |
}
|
|
647 |
if (printMax <= 0 ) |
|
648 |
con << tOutput("$config_command_more"); |
|
649 |
}
|
|
650 |
}
|
|
651 |
else
|
|
652 |
{
|
|
653 |
con << '\n'; |
|
654 |
}
|
|
655 |
}
|
|
656 |
}
|
|
657 |
}
|
|
658 |
||
659 |
// std::cout << line << " lines read.\n";
|
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
660 |
}
|
661 |
||
662 |
//Stolen from 0.4. Needed for "TOGGLE" function.
|
|
663 |
tConfItemBase *tConfItemBase::FindConfigItem2(tString const &name) { |
|
664 |
tConfItemMap & confmap = ConfItemMap(); |
|
665 |
tConfItemMap::iterator iter = confmap.find( name.ToUpper() ); |
|
666 |
if ( iter != confmap.end() ) { |
|
667 |
return iter->second; |
|
668 |
} else { |
|
669 |
return 0; |
|
670 |
}
|
|
671 |
}
|
|
672 |
||
673 |
tString tConfItemBase::FindConfigItem(tString name) |
|
674 |
{
|
|
675 |
tConfItemMap & confmap = ConfItemMap(); |
|
676 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
|
677 |
{
|
|
678 |
tConfItemBase * ci = (*iter).second; |
|
679 |
tString command; |
|
680 |
command << ci->title.ToLower(); |
|
681 |
if (command.Contains(name.ToLower())) |
|
682 |
{
|
|
683 |
if (command.StartsWith(name.ToLower())) |
|
684 |
{
|
|
685 |
return ci->title; |
|
686 |
}
|
|
687 |
}
|
|
688 |
}
|
|
689 |
return tString(""); |
|
690 |
}
|
|
691 |
||
692 |
/** LISTING BEGIN **/
|
|
693 |
// writes the list of all commands and their help to config_all.cfg in the var directory
|
|
694 |
void tConfItemBase::WriteAllToFile() |
|
695 |
{
|
|
696 |
tConfItemMap & confmap = ConfItemMap(); |
|
697 |
int sim_maxlen = -1; |
|
698 |
||
818
by zodiacsohma1 at gmail
Too much to explain in one go. |
699 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
700 |
{
|
|
701 |
tConfItemBase * ci = (*iter).second; |
|
702 |
if (static_cast<int>(strlen(ci->title)) > sim_maxlen) |
|
703 |
sim_maxlen = strlen(ci->title); |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
704 |
}
|
705 |
||
1003
by zodiacsohma1 at gmail
Updated english_base.txt with latest messages. |
706 |
std::ofstream w; |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
707 |
if ( tDirectories::Var().Open(w, "config_all.cfg")) |
708 |
{
|
|
709 |
/*w << "{| border=\"2\" cellspacing=\"0\" cellpadding=\"4\" rules=\"all\" style=\"margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#F9F9F9; font-size:95%; empty-cells:show;\"\n";
|
|
710 |
w << "!Command\n";
|
|
711 |
w << "!Default\n";
|
|
712 |
w << "!Meaning\n";
|
|
713 |
w << "|-\n";
|
|
714 |
*/
|
|
818
by zodiacsohma1 at gmail
Too much to explain in one go. |
715 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
716 |
{
|
|
717 |
tConfItemBase * ci = (*iter).second; |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
718 |
tString help ( ci->help ); |
719 |
||
720 |
tString mess, value; |
|
721 |
||
722 |
// fetch the value set for this setting.
|
|
723 |
ci->FetchVal(value); |
|
724 |
||
725 |
mess << ci->title << " "; |
|
726 |
||
727 |
mess.SetPos( sim_maxlen+2, false ); |
|
913
by zodiacsohma1 at gmail
Updated the language file, english_base.txt. |
728 |
mess << value << " "; |
850
by zodiacsohma1 at gmail
Please read NEWS-BRANCH for detailed information on this new update. |
729 |
mess << " # "; |
818
by zodiacsohma1 at gmail
Too much to explain in one go. |
730 |
mess << help; |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
731 |
mess << "\n"; |
850
by zodiacsohma1 at gmail
Please read NEWS-BRANCH for detailed information on this new update. |
732 |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
733 |
w << mess; |
734 |
/*w << "| " << ci->title << " || " << value << " || " << help << "\n";
|
|
956
by zodiacsohma1 at gmail
Updated the misshaped english_base.txt. |
735 |
w << "|-\n";*/
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
736 |
}
|
737 |
//w << "|}\n";
|
|
738 |
}
|
|
739 |
w.close(); |
|
740 |
}
|
|
741 |
||
742 |
static void sg_ListAllCommands(std::istream &s) |
|
743 |
{
|
|
744 |
tConfItemBase::WriteAllToFile(); |
|
745 |
}
|
|
746 |
static tConfItemFunc sg_ListAllCommandsConf("LIST_ALL_COMMANDS", &sg_ListAllCommands); |
|
747 |
||
748 |
/** LISTING END **/
|
|
749 |
||
750 |
/** LISTING ACCESS_LEVEL BEGIN **/
|
|
751 |
// writes the list of all commands and their help to config_all_levels.cfg in the var directory
|
|
752 |
void tConfItemBase::WriteAllLevelsToFile() |
|
753 |
{
|
|
754 |
tConfItemMap & confmap = ConfItemMap(); |
|
755 |
int sim_maxlen = -1; |
|
756 |
||
941
by zodiacsohma1 at gmail
Fixed bug in CHATTERS_* commands. |
757 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
758 |
{
|
|
759 |
tConfItemBase * ci = (*iter).second; |
|
760 |
if (static_cast<int>(strlen(ci->title)) > sim_maxlen) |
|
761 |
sim_maxlen = strlen(ci->title); |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
762 |
}
|
763 |
||
1003
by zodiacsohma1 at gmail
Updated english_base.txt with latest messages. |
764 |
std::ofstream w; |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
765 |
if ( tDirectories::Var().Open(w, "config_all_levels.cfg")) |
766 |
{
|
|
941
by zodiacsohma1 at gmail
Fixed bug in CHATTERS_* commands. |
767 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
768 |
{
|
|
769 |
tConfItemBase * ci = (*iter).second; |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
770 |
tString help ( ci->help ); |
771 |
||
772 |
tString mess; |
|
773 |
||
941
by zodiacsohma1 at gmail
Fixed bug in CHATTERS_* commands. |
774 |
mess << "ACCESS_LEVEL "; |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
775 |
mess << ci->title << " "; |
941
by zodiacsohma1 at gmail
Fixed bug in CHATTERS_* commands. |
776 |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
777 |
//mess.SetPos( sim_maxlen+2, false );
|
778 |
mess << ci->requiredLevel; |
|
941
by zodiacsohma1 at gmail
Fixed bug in CHATTERS_* commands. |
779 |
mess.SetPos( sim_maxlen+5, false ); |
780 |
mess << " # "; |
|
781 |
mess << help; |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
782 |
mess << "\n"; |
941
by zodiacsohma1 at gmail
Fixed bug in CHATTERS_* commands. |
783 |
|
1003
by zodiacsohma1 at gmail
Updated english_base.txt with latest messages. |
784 |
w << mess; |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
785 |
}
|
786 |
}
|
|
787 |
w.close(); |
|
788 |
}
|
|
789 |
||
790 |
static void sg_ListAllCommandsLevels(std::istream &s) |
|
791 |
{
|
|
792 |
tConfItemBase::WriteAllLevelsToFile(); |
|
793 |
}
|
|
794 |
static tConfItemFunc sg_ListAllCommandsLevelsConf("LIST_ALL_COMMANDS_LEVELS", &sg_ListAllCommandsLevels); |
|
795 |
||
796 |
/** LISTING ACCESS_LEVEL END **/
|
|
797 |
||
798 |
/** SET ALL ACCESS_LEVEL BEGIN **/
|
|
799 |
void tConfItemBase::SetAllAccessLevel(int newLevel) |
|
800 |
{
|
|
801 |
tConfItemMap & confmap = ConfItemMap(); |
|
802 |
tAccessLevel level = static_cast< tAccessLevel >( newLevel ); |
|
803 |
||
804 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
|
805 |
{
|
|
806 |
tConfItemBase * ci = (*iter).second; |
|
807 |
ci->requiredLevel = level; |
|
808 |
}
|
|
809 |
||
810 |
tString message; |
|
811 |
message << "All access levels of commands have been changed to " << tCurrentAccessLevel::GetName(level) << "!\n"; |
|
812 |
con << message; |
|
813 |
}
|
|
814 |
||
815 |
static void st_SetCommandsAccessLevel(std::istream &s) |
|
816 |
{
|
|
817 |
tString levelStr; |
|
818 |
s >> levelStr; |
|
819 |
||
820 |
int newLevel = atoi(levelStr); |
|
821 |
tConfItemBase::SetAllAccessLevel(newLevel); |
|
822 |
}
|
|
823 |
static tConfItemFunc st_SetCommandsAccessLevelConf("SET_COMMANDS_ACCESSLEVEL", &st_SetCommandsAccessLevel); |
|
824 |
/** SET ALL ACCESS_LEVEL END **/
|
|
825 |
||
826 |
void tConfItemBase::WriteChangedToFile() |
|
827 |
{
|
|
828 |
tConfItemMap & confmap = ConfItemMap(); |
|
829 |
int sim_maxlen = -1; |
|
830 |
||
1003
by zodiacsohma1 at gmail
Updated english_base.txt with latest messages. |
831 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
832 |
{
|
|
833 |
tConfItemBase * ci = (*iter).second; |
|
834 |
if (static_cast<int>(strlen(ci->title)) > sim_maxlen) |
|
835 |
sim_maxlen = strlen(ci->title); |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
836 |
}
|
837 |
||
1003
by zodiacsohma1 at gmail
Updated english_base.txt with latest messages. |
838 |
std::ofstream w; |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
839 |
if ( tDirectories::Var().Open(w, "config_changed.cfg")) |
840 |
{
|
|
1003
by zodiacsohma1 at gmail
Updated english_base.txt with latest messages. |
841 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
842 |
{
|
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
843 |
tConfItemBase * ci = (*iter).second; |
844 |
if (!ci->changed) continue; |
|
845 |
||
846 |
tString help ( ci->help ); |
|
847 |
||
848 |
tString mess, value; |
|
849 |
||
850 |
// fetch the value set for this setting.
|
|
851 |
ci->FetchVal(value); |
|
852 |
||
853 |
mess << ci->title << " "; |
|
854 |
||
855 |
mess.SetPos( sim_maxlen+2, false ); |
|
1003
by zodiacsohma1 at gmail
Updated english_base.txt with latest messages. |
856 |
mess << value << " "; |
857 |
mess << " # "; |
|
858 |
mess << help; |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
859 |
mess << "\n"; |
1003
by zodiacsohma1 at gmail
Updated english_base.txt with latest messages. |
860 |
|
861 |
w << mess; |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
862 |
}
|
863 |
}
|
|
864 |
w.close(); |
|
865 |
}
|
|
866 |
||
867 |
void tConfItemBase::DownloadSettings_Go(nMessage &m) |
|
868 |
{
|
|
869 |
// download the config if this is a client
|
|
870 |
if (sn_GetNetState() == nCLIENT) |
|
871 |
{
|
|
872 |
tString m_title; |
|
873 |
m >> m_title; |
|
874 |
if ((m_title == "DOWNLOAD_BEGIN") && m.End()) |
|
875 |
{
|
|
876 |
con << "Downloading config from server...\n"; |
|
877 |
||
878 |
// truncate the file for fresh settings
|
|
879 |
std::ofstream o; |
|
880 |
if ( tDirectories::Var().Open(o, "server_settings.cfg", std::ios::trunc) ) {} |
|
881 |
o.close(); |
|
882 |
return; |
|
883 |
}
|
|
884 |
else if ((m_title == "DOWNLOAD_END") && m.End()) |
|
885 |
{
|
|
886 |
con << "Download complete!\n"; |
|
887 |
return; |
|
888 |
}
|
|
889 |
tString m_value; |
|
890 |
m >> m_value; |
|
891 |
||
892 |
std::ofstream o; |
|
893 |
if (tDirectories::Var().Open(o, "server_settings.cfg", std::ios::app)) |
|
894 |
{
|
|
895 |
o << m_title << " " << m_value << "\n"; |
|
896 |
}
|
|
897 |
o.close(); |
|
898 |
}
|
|
899 |
}
|
|
900 |
||
901 |
static nDescriptor downloadSettings(61,tConfItemBase::DownloadSettings_Go, "download settings"); |
|
902 |
||
903 |
void tConfItemBase::DownloadSettings_To(int peer) |
|
904 |
{
|
|
905 |
// transfer the settings to the requested client
|
|
906 |
// Client ID must be greater than 0 for it to work
|
|
907 |
if ((sn_GetNetState() == nSERVER) && (peer > 0)) |
|
908 |
{
|
|
909 |
{
|
|
1039
by zodiacsohma1@gmail.com
Did a few things with the download of configs but forgot... |
910 |
nMessage *m=new nMessage(downloadSettings); |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
911 |
*m << tString("DOWNLOAD_BEGIN"); |
912 |
m->Send(peer); |
|
913 |
}
|
|
1037
by zodiacsohma1 at gmail
Updated settings_dedicated.cfg and settings_authentication.cfg |
914 |
|
915 |
tConfItemMap & confmap = ConfItemMap(); |
|
916 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
|
917 |
{
|
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
918 |
tConfItemBase * item = (*iter).second; |
919 |
if (item && item->CanSave()) |
|
1037
by zodiacsohma1 at gmail
Updated settings_dedicated.cfg and settings_authentication.cfg |
920 |
{
|
1039
by zodiacsohma1@gmail.com
Did a few things with the download of configs but forgot... |
921 |
nMessage *m=new nMessage(downloadSettings); |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
922 |
*m << item->title; |
923 |
||
924 |
tString value; |
|
925 |
item->FetchVal(value); |
|
926 |
*m << value; |
|
927 |
||
928 |
m->Send(peer); |
|
1037
by zodiacsohma1 at gmail
Updated settings_dedicated.cfg and settings_authentication.cfg |
929 |
}
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
930 |
}
|
931 |
||
932 |
{
|
|
1039
by zodiacsohma1@gmail.com
Did a few things with the download of configs but forgot... |
933 |
nMessage *m=new nMessage(downloadSettings); |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
934 |
*m << tString("DOWNLOAD_END"); |
935 |
m->Send(peer); |
|
936 |
}
|
|
937 |
}
|
|
938 |
}
|
|
939 |
||
940 |
tString configFileDownload(""); |
|
941 |
void tConfItemBase::DownloadConfig_Go(nMessage &m) |
|
942 |
{
|
|
943 |
// download the config if this is a client
|
|
944 |
if (sn_GetNetState() == nCLIENT) |
|
945 |
{
|
|
946 |
tString c_line; |
|
947 |
m >> c_line; |
|
948 |
if ((c_line == "DOWNLOAD_BEGIN") && !m.End()) |
|
949 |
{
|
|
950 |
m >> configFileDownload; |
|
951 |
con << "Downloading \"" << configFileDownload << "\" from server...\n"; |
|
952 |
||
953 |
// truncate the file for fresh settings
|
|
954 |
std::ofstream o; |
|
955 |
tString configFile; |
|
956 |
configFile << "public/" << configFileDownload; |
|
957 |
if ( tDirectories::Config().Open(o, configFile, std::ios::trunc) ) {} |
|
958 |
o.close(); |
|
959 |
return; |
|
960 |
}
|
|
961 |
else if ((c_line == "DOWNLOAD_END") && m.End()) |
|
962 |
{
|
|
963 |
con << "Download complete!\n"; |
|
964 |
configFileDownload = ""; |
|
965 |
return; |
|
966 |
}
|
|
967 |
||
968 |
if (configFileDownload == "") return; |
|
969 |
||
970 |
std::ofstream o; |
|
971 |
tString configFile; |
|
972 |
configFile << "public/" << configFileDownload; |
|
973 |
if (tDirectories::Config().Open(o, configFile, std::ios::app)) |
|
974 |
{
|
|
975 |
o << c_line << "\n"; |
|
976 |
}
|
|
977 |
o.close(); |
|
978 |
}
|
|
979 |
}
|
|
980 |
||
981 |
static nDescriptor downloadConfigs(62,tConfItemBase::DownloadConfig_Go, "download config"); |
|
982 |
||
983 |
bool st_downloadConfigProcess = false; |
|
984 |
void tConfItemBase::DownloadConfig_To(tString file, int peer) |
|
985 |
{
|
|
986 |
// don't process if its under process
|
|
987 |
if (st_downloadConfigProcess) return; |
|
988 |
st_downloadConfigProcess = true; |
|
989 |
||
1039
by zodiacsohma1@gmail.com
Did a few things with the download of configs but forgot... |
990 |
// refuse to load illegal paths
|
991 |
if( !tPath::IsValidPath( file ) ) |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
992 |
return; |
993 |
||
994 |
nMessage *m = NULL; |
|
995 |
||
996 |
std::ifstream i; |
|
997 |
tString configFile; |
|
998 |
configFile << "public/" << file; |
|
999 |
||
1000 |
// transfer the settings from config to the client
|
|
1001 |
// Client ID must be greater than 0 for it to work
|
|
1002 |
if ((sn_GetNetState() == nSERVER) && (peer > 0) && tDirectories::Config().Open(i, configFile)) |
|
1003 |
{
|
|
1039
by zodiacsohma1@gmail.com
Did a few things with the download of configs but forgot... |
1004 |
m = new nMessage(downloadConfigs); |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1005 |
*m << tString("DOWNLOAD_BEGIN"); |
1006 |
*m << file; |
|
1007 |
m->Send(peer); |
|
1008 |
||
1009 |
std::istream &s(i); |
|
1010 |
int i = 0; |
|
1011 |
while (!s.eof() && s.good()) |
|
1012 |
{
|
|
1013 |
tString line; |
|
1014 |
line.ReadLine(s); |
|
1015 |
||
1039
by zodiacsohma1@gmail.com
Did a few things with the download of configs but forgot... |
1016 |
m = new nMessage(downloadConfigs); |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1017 |
*m << line; |
1018 |
m->Send(peer); |
|
1019 |
||
1020 |
i++; |
|
1021 |
}
|
|
1022 |
||
1039
by zodiacsohma1@gmail.com
Did a few things with the download of configs but forgot... |
1023 |
m = new nMessage(downloadConfigs); |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1024 |
*m << tString("DOWNLOAD_END"); |
1025 |
m->Send(peer); |
|
1026 |
}
|
|
1027 |
i.close(); |
|
1028 |
||
1029 |
st_downloadConfigProcess = false; |
|
1030 |
}
|
|
1
by luke-jr
Unify tags/branches of modules released together |
1031 |
|
1037
by zodiacsohma1 at gmail
Updated settings_dedicated.cfg and settings_authentication.cfg |
1032 |
|
699
by Kyle
DELAY_COMMAND now checks for access level of the command to delay, also ADMIN_COMMAND now only prints out valid commands for the users access level |
1033 |
int tConfItemBase::AccessLevel(std::istream &s){ |
1034 |
if(!s.eof() && s.good()){ |
|
1035 |
tString name; |
|
1036 |
s >> name; |
|
1037 |
// make name uppercase:
|
|
1038 |
tToUpper( name ); |
|
1039 |
tConfItemMap & confmap = ConfItemMap(); |
|
1040 |
tConfItemMap::iterator iter = confmap.find( name ); |
|
1041 |
if ( iter != confmap.end() ) |
|
1042 |
{
|
|
1043 |
tConfItemBase * ci = (*iter).second; |
|
1044 |
return ci->requiredLevel; |
|
1045 |
}
|
|
1046 |
}
|
|
1047 |
return -1; |
|
1048 |
||
1049 |
}
|
|
1050 |
||
1
by luke-jr
Unify tags/branches of modules released together |
1051 |
static char const * recordingSection = "CONFIG"; |
1052 |
||
1053 |
/*
|
|
1054 |
bool LoadAllHelper(std::istream * s)
|
|
1055 |
{
|
|
1056 |
tString line;
|
|
1057 |
||
1058 |
// read line from recording
|
|
1059 |
if ( s || !tRecorder::Playback( recordingSection, line ) )
|
|
1060 |
{
|
|
1061 |
// return on failure
|
|
1062 |
if (!s)
|
|
1063 |
return false;
|
|
1064 |
||
1065 |
// read line from stream
|
|
1066 |
line.ReadLine( *s );
|
|
1067 |
||
1068 |
// write line to recording
|
|
1069 |
tRecorder::Record( recordingSection, line );
|
|
1070 |
}
|
|
1071 |
line << '\n';
|
|
1072 |
||
1073 |
// process line
|
|
1074 |
std::stringstream str(static_cast< char const * >( line ) );
|
|
1075 |
tConfItemBase::LoadLine(str);
|
|
1076 |
||
1077 |
return true;
|
|
1078 |
}
|
|
1079 |
*/
|
|
1080 |
||
1081 |
// test if a line should enter the recording; check if the line contains one of the passed
|
|
1082 |
// substrings. The array of substrings is supposed to be zero terminated.
|
|
1083 |
static bool s_Veto( tString line_in, std::vector< tString > const & vetos ) |
|
1084 |
{
|
|
1085 |
// make name uppercase:
|
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
1086 |
tToUpper( line_in ); |
1
by luke-jr
Unify tags/branches of modules released together |
1087 |
|
1088 |
// eat whitespace at the beginning
|
|
1089 |
char const * test = line_in; |
|
109
by z-man
More isspace->isblank replacements. |
1090 |
while( isblank(*test) ) |
1
by luke-jr
Unify tags/branches of modules released together |
1091 |
test++; |
1092 |
||
1093 |
// skip "LAST_"
|
|
1094 |
tString line( test ); |
|
1095 |
if ( line.StartsWith( "LAST_" ) ) |
|
1096 |
line = tString( static_cast< char const * >(line) + 5 ); |
|
1097 |
||
1098 |
// iterate throug vetoed config items and test each one
|
|
1099 |
for ( std::vector< tString >::const_iterator iter = vetos.begin(); iter != vetos.end(); ++iter ) |
|
1100 |
{
|
|
1101 |
tString const & veto = *iter; |
|
1102 |
||
1103 |
if ( line.StartsWith( veto ) ) |
|
67
by z-man
Added diagnostics for vetoed setting lines |
1104 |
{
|
156
by z-man
Disabled veto debug messages. |
1105 |
#ifdef DEBUG_X
|
84
by z-man
Refined custom glancing, there are now separate settings for the camera during custom glances. |
1106 |
if ( !line.StartsWith( "INCLUDE" ) && tRecorder::IsRunning() ) |
67
by z-man
Added diagnostics for vetoed setting lines |
1107 |
{
|
84
by z-man
Refined custom glancing, there are now separate settings for the camera during custom glances. |
1108 |
con << "Veto on config line: " << line << "\n"; |
67
by z-man
Added diagnostics for vetoed setting lines |
1109 |
}
|
156
by z-man
Disabled veto debug messages. |
1110 |
#endif
|
67
by z-man
Added diagnostics for vetoed setting lines |
1111 |
|
1
by luke-jr
Unify tags/branches of modules released together |
1112 |
return true; |
67
by z-man
Added diagnostics for vetoed setting lines |
1113 |
}
|
1
by luke-jr
Unify tags/branches of modules released together |
1114 |
}
|
1115 |
||
1116 |
return false; |
|
1117 |
}
|
|
1118 |
||
1119 |
// test if a line should be read from a recording
|
|
1120 |
// sound and video mode settings shold not
|
|
1121 |
static std::vector< tString > st_Stringify( char const * vetos[] ) |
|
1122 |
{
|
|
1123 |
std::vector< tString > ret; |
|
1124 |
||
1125 |
char const * * v = vetos; |
|
1126 |
while ( *v ) |
|
1127 |
{
|
|
1128 |
ret.push_back( tString( *v ) ); |
|
1129 |
++v; |
|
1130 |
}
|
|
1131 |
||
1132 |
return ret; |
|
1133 |
}
|
|
1134 |
||
1135 |
static bool s_VetoPlayback( tString const & line ) |
|
1136 |
{
|
|
1137 |
static char const * vetos_char[]= |
|
1138 |
{ "USE_DISPLAYLISTS", "CHECK_ERRORS", "ZDEPTH", |
|
56
by z-man
Removed "FULLSCREEN" from the veto list to make room for FULLSCREEN_MESSAGE |
1139 |
"COLORDEPTH", "FULLSCREEN ", "ARMAGETRON_LAST_WINDOWSIZE", |
1
by luke-jr
Unify tags/branches of modules released together |
1140 |
"ARMAGETRON_WINDOWSIZE", "ARMAGETRON_LAST_SCREENMODE", |
1141 |
"ARMAGETRON_SCREENMODE", "CUSTOM_SCREEN", "SOUND", |
|
563.1.469
by Manuel Moos
Fixed recording desync when a remote admin includes large config files with some settings vetoed. |
1142 |
"PASSWORD", "ADMIN_PASS", |
1
by luke-jr
Unify tags/branches of modules released together |
1143 |
"ZTRICK", "MOUSE_GRAB", "PNG_SCREENSHOT", // "WHITE_SPARKS", "SPARKS", |
1144 |
"KEEP_WINDOW_ACTIVE", "TEXTURE_MODE", "TEXTURES_HI", "LAG_O_METER", "INFINITY_PLANE", |
|
1145 |
"SKY_WOBBLE", "LOWER_SKY", "UPPER_SKY", "DITHER", "HIGH_RIM", "FLOOR_DETAIL", |
|
1146 |
"FLOOR_MIRROR", "SHOW_FPS", "TEXT_OUT", "SMOOTH_SHADING", "ALPHA_BLEND", |
|
1147 |
"PERSP_CORRECT", "POLY_ANTIALIAS", "LINE_ANTIALIAS", "FAST_FORWARD_MAXSTEP", |
|
563.1.224
by z-man
Fixed recording/playback desyncing bug with CASACL, the changed access level could leak on playback. |
1148 |
"DEBUG_GNUPLOT", "FLOOR_", "MOVIEPACK_", "RIM_WALL_", |
1
by luke-jr
Unify tags/branches of modules released together |
1149 |
0 }; |
1150 |
||
1151 |
static std::vector< tString > vetos = st_Stringify( vetos_char ); |
|
1152 |
||
1153 |
// delegate
|
|
1154 |
return s_Veto( line, vetos ); |
|
1155 |
}
|
|
1156 |
||
1157 |
// test if a line should enter the recording
|
|
1158 |
// passwords should not.
|
|
1159 |
static bool s_VetoRecording( tString const & line ) |
|
1160 |
{
|
|
1161 |
static char const * vetos_char[]= |
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
1162 |
{ "#", "PASSWORD", "ADMIN_PASS", "LOCAL_USER", "LOCAL_TEAM", |
1
by luke-jr
Unify tags/branches of modules released together |
1163 |
0 }; |
1164 |
||
1165 |
static std::vector< tString > vetos = st_Stringify( vetos_char ); |
|
1166 |
||
1167 |
// delegate
|
|
563.1.469
by Manuel Moos
Fixed recording desync when a remote admin includes large config files with some settings vetoed. |
1168 |
return s_Veto( line, vetos ) || s_VetoPlayback( line ); |
1
by luke-jr
Unify tags/branches of modules released together |
1169 |
}
|
1170 |
||
563.1.165
by Manuel Moos
Cleaned up a bit of the configuration recording and playback chaos. "Quit" console command is broken on playback currently in some situations. |
1171 |
|
1172 |
//! @param s stream to read from
|
|
1173 |
//! @param record set to true if the configuration is to be recorded and played back. That's usually only required if s is a file stream.
|
|
1174 |
void tConfItemBase::LoadAll(std::istream &s, bool record ){ |
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
1175 |
tCurrentAccessLevel levelResetter; |
1176 |
||
1177 |
try{ |
|
1178 |
||
1
by luke-jr
Unify tags/branches of modules released together |
1179 |
while(!s.eof() && s.good()) |
1180 |
{
|
|
1181 |
tString line; |
|
1182 |
||
1183 |
// read line from stream
|
|
1184 |
line.ReadLine( s ); |
|
1185 |
||
1186 |
/// concatenate lines ending in a backslash
|
|
1187 |
while ( line.Len() > 1 && line[line.Len()-2] == '\\' && s.good() && !s.eof() ) |
|
1188 |
{
|
|
1189 |
line[line.Len()-2] = '\0'; |
|
1190 |
||
1191 |
// unless it is a double backslash
|
|
1192 |
if ( line.Len() > 2 && line[line.Len()-3] == '\\' ) |
|
1193 |
{
|
|
1194 |
break; |
|
1195 |
}
|
|
1196 |
||
1197 |
line.SetLen( line.Len()-1 ); |
|
1198 |
tString rest; |
|
1199 |
rest.ReadLine( s ); |
|
1200 |
line << rest; |
|
1201 |
}
|
|
1202 |
||
1203 |
if ( line.Len() <= 1 ) |
|
1204 |
continue; |
|
1205 |
||
1206 |
// write line to recording
|
|
563.1.165
by Manuel Moos
Cleaned up a bit of the configuration recording and playback chaos. "Quit" console command is broken on playback currently in some situations. |
1207 |
if ( record && !s_VetoRecording( line ) ) |
1
by luke-jr
Unify tags/branches of modules released together |
1208 |
{
|
1209 |
// don't record supid admins' instant chat logins
|
|
1210 |
static tString instantChat("INSTANT_CHAT_STRING"); |
|
1211 |
if ( line.StartsWith( instantChat ) && strstr( line, "/login" ) ) |
|
1212 |
{
|
|
1213 |
tString newLine = line.SubStr( 0, strstr( line, "/login" ) - (char const *)line ); |
|
1214 |
newLine += "/login NONE"; |
|
1215 |
if ( line[strlen(line)-1] == '\\' ) |
|
1216 |
newLine += '\\'; |
|
1217 |
tRecorder::Record( recordingSection, newLine ); |
|
1218 |
}
|
|
1219 |
else
|
|
1220 |
tRecorder::Record( recordingSection, line ); |
|
1221 |
}
|
|
1222 |
||
1223 |
// std::cout << line << '\n';
|
|
1224 |
||
1225 |
// process line
|
|
1226 |
// line << '\n';
|
|
563.1.165
by Manuel Moos
Cleaned up a bit of the configuration recording and playback chaos. "Quit" console command is broken on playback currently in some situations. |
1227 |
if ( !record || !tRecorder::IsPlayingBack() || s_VetoPlayback( line ) ) |
1
by luke-jr
Unify tags/branches of modules released together |
1228 |
{
|
1229 |
std::stringstream str(static_cast< char const * >( line ) ); |
|
1230 |
tConfItemBase::LoadLine(str); |
|
1231 |
// std::cout << line << '\n';
|
|
1232 |
}
|
|
1233 |
}
|
|
516
by z-man
Merging branch 0.2.8-auth from revision 7558 to 7721: |
1234 |
}
|
1235 |
catch( tAbortLoading const & e ) |
|
1236 |
{
|
|
1237 |
// loading was aborted
|
|
1238 |
con << e.GetDescription() << "\n"; |
|
1239 |
}
|
|
1
by luke-jr
Unify tags/branches of modules released together |
1240 |
}
|
1241 |
||
1242 |
void tConfItemBase::DocAll(std::ostream &s){ |
|
1243 |
tConfItemMap & confmap = ConfItemMap(); |
|
1244 |
for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter) |
|
1245 |
{
|
|
1246 |
tConfItemBase * ci = (*iter).second; |
|
1247 |
||
1248 |
tString help ( ci->help ); |
|
1249 |
if ( help != "UNDOCUMENTED" ) |
|
1250 |
{
|
|
1251 |
tString line; |
|
1252 |
line << ci->title; |
|
1253 |
line.SetPos( 30, false ); |
|
1254 |
line << help; |
|
1255 |
s << line << '\n'; |
|
1256 |
}
|
|
1257 |
}
|
|
1258 |
}
|
|
1259 |
||
563.1.165
by Manuel Moos
Cleaned up a bit of the configuration recording and playback chaos. "Quit" console command is broken on playback currently in some situations. |
1260 |
//! @param s stream to read from
|
1261 |
//! @param record set to true if the configuration is to be recorded and played back. That's usually only required if s is a file stream, so it defaults to true here.
|
|
1262 |
void tConfItemBase::LoadAll(std::ifstream &s, bool record ) |
|
1263 |
{
|
|
1264 |
std::istream &ss(s); |
|
1265 |
LoadAll( ss, record ); |
|
1266 |
}
|
|
1267 |
||
1268 |
||
1269 |
//! @param s file stream to be used for reading later
|
|
1270 |
//! @param filename name of the file to open
|
|
563.24.190
by z-man
Merging branch 0.2.8.3 from revision 9740 to 9917: |
1271 |
//! @param path whether to look in var directory
|
563.1.165
by Manuel Moos
Cleaned up a bit of the configuration recording and playback chaos. "Quit" console command is broken on playback currently in some situations. |
1272 |
//! @return success flag
|
1273 |
bool tConfItemBase::OpenFile( std::ifstream & s, tString const & filename, SearchPath path ) |
|
1274 |
{
|
|
563.24.190
by z-man
Merging branch 0.2.8.3 from revision 9740 to 9917: |
1275 |
bool ret = ( ( path & Config ) && tDirectories::Config().Open(s, filename ) ) || ( ( path & Var ) && st_StringEndsWith(filename, ".cfg") && tDirectories::Var().Open(s, filename ) ); |
779
by zodiacsohma1 at gmail
Transfered MAP_ROTATION and it's supporting scripts and stuff from |
1276 |
|
563.1.165
by Manuel Moos
Cleaned up a bit of the configuration recording and playback chaos. "Quit" console command is broken on playback currently in some situations. |
1277 |
static char const * section = "INCLUDE_VOTE"; |
1278 |
tRecorder::Playback( section, ret ); |
|
1279 |
tRecorder::Record( section, ret ); |
|
699
by Kyle
DELAY_COMMAND now checks for access level of the command to delay, also ADMIN_COMMAND now only prints out valid commands for the users access level |
1280 |
|
563.1.165
by Manuel Moos
Cleaned up a bit of the configuration recording and playback chaos. "Quit" console command is broken on playback currently in some situations. |
1281 |
return ret; |
1282 |
}
|
|
1283 |
||
1284 |
//! @param s file to read from
|
|
1285 |
void tConfItemBase::ReadFile( std::ifstream & s ) |
|
1286 |
{
|
|
1287 |
if ( !tRecorder::IsPlayingBack() ) |
|
1288 |
{
|
|
1289 |
tConfItemBase::LoadAll(s, true ); |
|
1290 |
}
|
|
1291 |
else
|
|
1292 |
{
|
|
1293 |
tConfItemBase::LoadPlayback(); |
|
1294 |
}
|
|
1295 |
}
|
|
1296 |
||
1
by luke-jr
Unify tags/branches of modules released together |
1297 |
/*
|
1298 |
void tConfItemBase::ReadVal(std::istream &s);
|
|
1299 |
void tConfItemBase::WriteVal(std::istream &s);
|
|
1300 |
*/
|
|
1301 |
||
1302 |
/*
|
|
1303 |
tString configfile(){
|
|
1304 |
tString f;
|
|
1305 |
//#ifndef WIN32
|
|
1306 |
// f << static_cast<const char *>(getenv("HOME"));
|
|
699
by Kyle
DELAY_COMMAND now checks for access level of the command to delay, also ADMIN_COMMAND now only prints out valid commands for the users access level |
1307 |
// f << st_LogDir <<
|
1
by luke-jr
Unify tags/branches of modules released together |
1308 |
// f << "/.ArmageTronrc";
|
1309 |
//#else
|
|
1310 |
const tPath& vpath = tDirectories::Var();
|
|
1311 |
for ( int prio = vpath.MaxPriority(); prio>=0; --prio )
|
|
1312 |
{
|
|
1313 |
tString path = vpath.Path( prio );
|
|
1314 |
prio = -1;
|
|
1315 |
||
1316 |
f << st_LogDir << "/user.cfg";
|
|
1317 |
//#endif
|
|
1318 |
return f;
|
|
1319 |
}
|
|
1320 |
*/
|
|
1321 |
||
1322 |
bool tConfItemBase::LoadPlayback( bool print ) |
|
1323 |
{
|
|
1324 |
if ( !tRecorder::IsPlayingBack() ) |
|
1325 |
return false; |
|
1326 |
||
1327 |
// read line from recording
|
|
1328 |
tString line; |
|
1329 |
while ( tRecorder::Playback( recordingSection, line ) ) |
|
1330 |
{
|
|
1331 |
tRecorder::Record( recordingSection, line ); |
|
1332 |
if ( !s_VetoPlayback( line ) ) |
|
1333 |
{
|
|
1334 |
// process line
|
|
1335 |
if ( print ) con << "Playback input : " << line << '\n'; |
|
1336 |
std::stringstream str(static_cast< char const * >( line ) ); |
|
1337 |
tConfItemBase::LoadLine(str); |
|
1338 |
}
|
|
1339 |
}
|
|
1340 |
||
1341 |
return true; |
|
1342 |
}
|
|
1343 |
||
1344 |
static bool Load( const tPath& path, const char* filename ) |
|
1345 |
{
|
|
1346 |
// read from file
|
|
1347 |
if ( !filename ) |
|
1348 |
{
|
|
1349 |
return false; |
|
1350 |
}
|
|
1351 |
||
1352 |
std::ifstream s; |
|
1353 |
if ( path.Open( s, filename ) ) |
|
1354 |
{
|
|
563.1.165
by Manuel Moos
Cleaned up a bit of the configuration recording and playback chaos. "Quit" console command is broken on playback currently in some situations. |
1355 |
tConfItemBase::LoadAll( s, true ); |
1
by luke-jr
Unify tags/branches of modules released together |
1356 |
return true; |
1357 |
}
|
|
1358 |
else
|
|
1359 |
{
|
|
1360 |
return false; |
|
1361 |
}
|
|
1362 |
}
|
|
1363 |
||
1364 |
// flag indicating whether settings were read from a playback
|
|
1365 |
static bool st_settingsFromRecording = false; |
|
1366 |
||
1367 |
#ifdef DEDICATED
|
|
1368 |
tString extraConfig("NONE"); |
|
1369 |
||
1370 |
class tExtraConfigCommandLineAnalyzer: public tCommandLineAnalyzer |
|
1371 |
{
|
|
1372 |
private: |
|
1373 |
virtual bool DoAnalyze( tCommandLineParser & parser ) |
|
1374 |
{
|
|
1375 |
return parser.GetOption(extraConfig, "--extraconfig", "-e"); |
|
1376 |
}
|
|
1377 |
||
1378 |
virtual void DoHelp( std::ostream & s ) |
|
1379 |
{ // |
|
1380 |
s << "-e, --extraconfig : open an extra configuration file after\n" |
|
1381 |
<< " settings_dedicated.cfg\n"; |
|
1382 |
}
|
|
1383 |
};
|
|
1384 |
||
1385 |
static tExtraConfigCommandLineAnalyzer s_extraAnalyzer; |
|
1386 |
#endif
|
|
1387 |
||
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1388 |
static void st_InstallSigHupHandler(); |
1389 |
||
1390 |
static tString st_customConfigLine = tString(""); |
|
1391 |
static tSettingItem<tString> st_customConfigLineConf("CUSTOM_CONFIGS", st_customConfigLine); |
|
1392 |
||
1393 |
// CUSTOM_CONFIGS config1.cfg;config2.cfg;
|
|
1394 |
void st_LoadCustomConfigs() |
|
1395 |
{
|
|
1396 |
if (st_customConfigLine.Filter() != "") |
|
1397 |
{
|
|
1398 |
tArray<tString> configs = st_customConfigLine.Split(";"); |
|
1399 |
if (configs.Len() > 0) |
|
1400 |
{
|
|
1401 |
for(int i = 0; i < configs.Len(); i++) |
|
1402 |
{
|
|
1403 |
tString config = configs[i]; |
|
1404 |
||
1405 |
Load(tDirectories::Config(), config); |
|
1406 |
Load(tDirectories::Var(), config); |
|
1407 |
Load(tDirectories::Resource(), config); |
|
1408 |
}
|
|
1409 |
}
|
|
1410 |
}
|
|
1411 |
}
|
|
1412 |
static void st_LoadCustomConfigsStr(std::istream &s) |
|
1413 |
{
|
|
1414 |
st_LoadCustomConfigs(); |
|
1415 |
}
|
|
896
by zodiacsohma1 at gmail
Updating code with additional commands and fixes. |
1416 |
static tConfItemFunc st_LoadCustomConfigsConf("LOAD_CUSTOM_CONFIGS", &st_LoadCustomConfigsStr); |
501
by z-man
Configuration files get reloaded on SIGHUP |
1417 |
|
1418 |
void st_LoadConfig( bool printChange ) |
|
1
by luke-jr
Unify tags/branches of modules released together |
1419 |
{
|
563.1.397
by Manuel Moos
Map settings are now executed with the access level of the user setting MAP_FILE. |
1420 |
// default include files are executed at owner level
|
1421 |
tCurrentAccessLevel level( tAccessLevel_Owner, true ); |
|
1422 |
||
501
by z-man
Configuration files get reloaded on SIGHUP |
1423 |
st_InstallSigHupHandler(); |
1424 |
||
1
by luke-jr
Unify tags/branches of modules released together |
1425 |
const tPath& var = tDirectories::Var(); |
1426 |
const tPath& config = tDirectories::Config(); |
|
1427 |
const tPath& data = tDirectories::Data(); |
|
1428 |
||
501
by z-man
Configuration files get reloaded on SIGHUP |
1429 |
tConfItemBase::printChange=printChange; |
1
by luke-jr
Unify tags/branches of modules released together |
1430 |
#ifdef DEDICATED
|
1431 |
tConfItemBase::printErrors=false; |
|
1432 |
#endif
|
|
1101
by SwagTron
Nelg helped me find the reason tConfItems were not properly updating their values in the client. Previously settings.cfg was being loaded after user.cfg; this caused tConfItems listed in the setting.cfg file to overwrite the user.cfg values. |
1433 |
//Load Defaults before other configs.
|
1434 |
Load( config, "settings.cfg" ); |
|
1435 |
||
1
by luke-jr
Unify tags/branches of modules released together |
1436 |
{
|
1437 |
Load( var, "user.cfg" ); |
|
1438 |
}
|
|
1439 |
tConfItemBase::printErrors=true; |
|
1440 |
||
1441 |
#ifdef DEDICATED
|
|
1442 |
Load( config, "settings_dedicated.cfg" ); |
|
1443 |
if( extraConfig != "NONE" ) Load( config, extraConfig ); |
|
1444 |
#else
|
|
1445 |
if (st_FirstUse) |
|
1446 |
{
|
|
563.29.15
by Manuel Moos
Made it possible to repeat the initial setup. |
1447 |
Load( config, "default.cfg" ); |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1448 |
}
|
1449 |
||
951
by zodiacsohma1 at gmail
Fixed banned words being the last to identify (new line). |
1450 |
Load( config, "settings_client.cfg" ); |
1
by luke-jr
Unify tags/branches of modules released together |
1451 |
#endif
|
1452 |
||
1453 |
Load( data, "moviepack/settings.cfg" ); |
|
1454 |
||
1455 |
Load( config, "autoexec.cfg" ); |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1456 |
Load( var, "autoexec.cfg" ); |
1457 |
||
895
by zodiacsohma1 at gmail
Implemented _ROTATION_ADD|SET|REMOVE. |
1458 |
st_LoadCustomConfigs(); |
1
by luke-jr
Unify tags/branches of modules released together |
1459 |
|
1460 |
// load configuration from playback
|
|
1461 |
tConfItemBase::LoadPlayback(); |
|
1462 |
st_settingsFromRecording = tRecorder::IsPlayingBack(); |
|
1463 |
||
1464 |
tConfItemBase::printChange=true; |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1465 |
}
|
1466 |
||
1467 |
static void st_ReLoadConfig(std::istream &s) |
|
1468 |
{
|
|
1469 |
st_LoadConfig(false); |
|
1470 |
}
|
|
1471 |
static tConfItemFunc st_ReLoadConfigConf("RELOAD_CONFIG", &st_ReLoadConfig); |
|
1472 |
static tAccessLevelSetter st_ReLoadConfigConfLevel( st_ReLoadConfigConf, tAccessLevel_Moderator ); |
|
1473 |
||
1474 |
static bool st_UserCfgSave = true; |
|
933
by zodiacsohma1 at gmail
Fixed the bugging of display scores during chat. |
1475 |
static tConfItem<bool> st_UserCfgSaveConf("CFG_USER_SAVE", st_UserCfgSave); |
1
by luke-jr
Unify tags/branches of modules released together |
1476 |
|
1477 |
void st_SaveConfig() |
|
1478 |
{
|
|
1479 |
// don't save while playing back
|
|
1480 |
if ( st_settingsFromRecording ) |
|
1481 |
{
|
|
1482 |
return; |
|
1483 |
}
|
|
1484 |
||
1485 |
std::ofstream s; |
|
557
by wrtlprnft
protect user.cfg from read access by other users on linux and (hopefully) mac OS |
1486 |
if ( tDirectories::Var().Open( s, "user.cfg", std::ios::out, true ) ) |
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1487 |
{
|
933
by zodiacsohma1 at gmail
Fixed the bugging of display scores during chat. |
1488 |
if (st_UserCfgSave) |
1489 |
tConfItemBase::SaveAll(s); |
|
1
by luke-jr
Unify tags/branches of modules released together |
1490 |
}
|
1491 |
else
|
|
1492 |
{
|
|
1493 |
tOutput o("$config_file_write_error"); |
|
1494 |
con << o; |
|
1495 |
std::cerr << o; |
|
1496 |
}
|
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1497 |
}
|
1498 |
||
1499 |
void st_LoadUserConfig() |
|
1500 |
{
|
|
1501 |
const tPath& var = tDirectories::Var(); |
|
1502 |
Load(var, "user.cfg"); |
|
1
by luke-jr
Unify tags/branches of modules released together |
1503 |
}
|
1504 |
||
501
by z-man
Configuration files get reloaded on SIGHUP |
1505 |
void st_LoadConfig() |
1506 |
{
|
|
1507 |
st_LoadConfig( false ); |
|
1508 |
}
|
|
1509 |
||
1510 |
static void st_DoHandleSigHup() |
|
1511 |
{
|
|
1512 |
con << tOutput("$config_sighup"); |
|
1513 |
st_SaveConfig(); |
|
1514 |
st_LoadConfig(); |
|
1515 |
}
|
|
1516 |
||
1517 |
static void st_HandleSigHup( int signal ) |
|
1518 |
{
|
|
504
by z-man
Safer version of st_ToDo() to be called from signal handlers. |
1519 |
st_ToDo_Signal( st_DoHandleSigHup ); |
501
by z-man
Configuration files get reloaded on SIGHUP |
1520 |
}
|
1521 |
||
1522 |
static void st_InstallSigHupHandler() |
|
1523 |
{
|
|
1524 |
#ifndef WIN32
|
|
1525 |
static bool installed = false; |
|
1526 |
if ( !installed ) |
|
1527 |
{
|
|
1528 |
signal( SIGHUP, &st_HandleSigHup ); |
|
1529 |
installed = true; |
|
1530 |
}
|
|
1531 |
#endif
|
|
1532 |
}
|
|
1
by luke-jr
Unify tags/branches of modules released together |
1533 |
|
1534 |
void tConfItemLine::ReadVal(std::istream &s){ |
|
1535 |
tString dummy; |
|
1536 |
dummy.ReadLine(s, true); |
|
1537 |
if(strcmp(dummy,*target)){ |
|
1538 |
if (printChange) |
|
1539 |
{
|
|
563.1.17
by wrtlprnft
Fixed color overflow in the configuration change message (hi there K-Yo!). I hope z-man doesn't rip my head off for removing yet another color code related bug that he can use as proof that color codes aren't officially supported (they're still not!) |
1540 |
tColoredString oldval; |
1541 |
oldval << *target << tColoredString::ColorString(1,1,1); |
|
1542 |
tColoredString newval; |
|
1543 |
newval << dummy << tColoredString::ColorString(1,1,1); |
|
1
by luke-jr
Unify tags/branches of modules released together |
1544 |
tOutput o; |
1545 |
o.SetTemplateParameter(1, title); |
|
563.1.17
by wrtlprnft
Fixed color overflow in the configuration change message (hi there K-Yo!). I hope z-man doesn't rip my head off for removing yet another color code related bug that he can use as proof that color codes aren't officially supported (they're still not!) |
1546 |
o.SetTemplateParameter(2, oldval); |
1547 |
o.SetTemplateParameter(3, newval); |
|
1
by luke-jr
Unify tags/branches of modules released together |
1548 |
o << "$config_value_changed"; |
1549 |
con << o; |
|
1550 |
}
|
|
1551 |
*target=dummy; |
|
1552 |
changed=true; |
|
1553 |
}
|
|
1554 |
||
1555 |
*target=dummy; |
|
1556 |
}
|
|
1557 |
||
1558 |
||
1559 |
void tConfItemLine::WriteVal(std::ostream &s){ |
|
1560 |
tConfItem<tString>::WriteVal(s); |
|
1561 |
||
1562 |
// double trailing backslash so it is read back as a single backslash, not
|
|
1563 |
// a continued line (HACK: this would actually be the job of the calling function)
|
|
1564 |
if ( target->Len() >= 2 && |
|
1565 |
target->operator()(target->Len() - 2) == '\\' ) |
|
1566 |
s << "\\"; |
|
1567 |
}
|
|
1568 |
||
1569 |
tConfItemFunc::tConfItemFunc |
|
1570 |
(const char *title, CONF_FUNC *func) |
|
1571 |
:tConfItemBase(title),f(func){} |
|
1572 |
||
1573 |
tConfItemFunc::~tConfItemFunc(){} |
|
1574 |
||
1575 |
void tConfItemFunc::ReadVal(std::istream &s){(*f)(s);} |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1576 |
void tConfItemFunc::WriteVal(std::ostream &){} |
1037
by zodiacsohma1 at gmail
Updated settings_dedicated.cfg and settings_authentication.cfg |
1577 |
void tConfItemFunc::FetchVal(tString &val){} |
1
by luke-jr
Unify tags/branches of modules released together |
1578 |
|
1579 |
bool tConfItemFunc::Save(){return false;} |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1580 |
|
1581 |
void st_Include( tString const & file ) |
|
1582 |
{
|
|
1583 |
// refuse to load illegal paths
|
|
1584 |
if( !tPath::IsValidPath( file ) ) |
|
1585 |
return; |
|
1586 |
||
1587 |
if ( !tRecorder::IsPlayingBack() ) |
|
1588 |
{
|
|
1589 |
// really load include file
|
|
1590 |
if ( !file.EndsWith(".cfg") || !Load( tDirectories::Var(), file ) ) |
|
1591 |
{
|
|
1592 |
if (!Load( tDirectories::Config(), file ) && tConfItemBase::printErrors ) |
|
1593 |
{
|
|
1594 |
con << tOutput( "$config_include_not_found", file ); |
|
1595 |
}
|
|
1596 |
}
|
|
1597 |
}
|
|
1598 |
else
|
|
1599 |
{
|
|
1600 |
// just read configuration, and don't forget to reset the config level
|
|
1601 |
tCurrentAccessLevel levelResetter; |
|
1602 |
tConfItemBase::LoadPlayback(); |
|
1603 |
}
|
|
1604 |
||
1605 |
// mark section
|
|
1606 |
char const * section = "INCLUDE_END"; |
|
1607 |
tRecorder::Record( section ); |
|
1608 |
tRecorder::PlaybackStrict( section ); |
|
1609 |
||
1610 |
}
|
|
1
by luke-jr
Unify tags/branches of modules released together |
1611 |
|
1612 |
static void Include(std::istream& s, bool error ) |
|
1613 |
{
|
|
563.1.403
by Manuel Moos
Disabling CASACL during RINCLUDE. |
1614 |
// allow CASACL
|
1615 |
tCasaclPreventer allower(false); |
|
1616 |
||
1
by luke-jr
Unify tags/branches of modules released together |
1617 |
tString file; |
1618 |
s >> file; |
|
1619 |
||
1620 |
// refuse to load illegal paths
|
|
1621 |
if( !tPath::IsValidPath( file ) ) |
|
1622 |
return; |
|
1623 |
||
563.1.224
by z-man
Fixed recording/playback desyncing bug with CASACL, the changed access level could leak on playback. |
1624 |
if ( !tRecorder::IsPlayingBack() ) |
1
by luke-jr
Unify tags/branches of modules released together |
1625 |
{
|
563.1.224
by z-man
Fixed recording/playback desyncing bug with CASACL, the changed access level could leak on playback. |
1626 |
// really load include file
|
563.24.190
by z-man
Merging branch 0.2.8.3 from revision 9740 to 9917: |
1627 |
if ( !st_StringEndsWith(file, ".cfg") || !Load( tDirectories::Var(), file ) ) |
1
by luke-jr
Unify tags/branches of modules released together |
1628 |
{
|
563.1.224
by z-man
Fixed recording/playback desyncing bug with CASACL, the changed access level could leak on playback. |
1629 |
if (!Load( tDirectories::Config(), file ) && error ) |
1630 |
{
|
|
1631 |
con << tOutput( "$config_include_not_found", file ); |
|
1632 |
}
|
|
1
by luke-jr
Unify tags/branches of modules released together |
1633 |
}
|
1634 |
}
|
|
563.1.224
by z-man
Fixed recording/playback desyncing bug with CASACL, the changed access level could leak on playback. |
1635 |
else
|
1636 |
{
|
|
1637 |
// just read configuration, and don't forget to reset the config level
|
|
1638 |
tCurrentAccessLevel levelResetter; |
|
1639 |
tConfItemBase::LoadPlayback(); |
|
1640 |
}
|
|
1641 |
||
1642 |
// mark section
|
|
1643 |
char const * section = "INCLUDE_END"; |
|
1644 |
tRecorder::Record( section ); |
|
1645 |
tRecorder::PlaybackStrict( section ); |
|
1646 |
||
1
by luke-jr
Unify tags/branches of modules released together |
1647 |
}
|
1648 |
||
1649 |
static void Include(std::istream& s ) |
|
1650 |
{
|
|
1651 |
Include( s, true ); |
|
1652 |
}
|
|
1653 |
||
1654 |
static void SInclude(std::istream& s ) |
|
1655 |
{
|
|
1656 |
Include( s, false ); |
|
1657 |
}
|
|
1658 |
||
1659 |
static tConfItemFunc s_Include("INCLUDE", &Include); |
|
1660 |
static tConfItemFunc s_SInclude("SINCLUDE", &SInclude); |
|
1661 |
||
1662 |
// obsoleted settings that still are around in some distruted configuration files
|
|
1663 |
static void st_Dummy(std::istream &s){tString rest; rest.ReadLine(s);} |
|
1664 |
static tConfItemFunc st_DummyMpHack("MOVIEPACK_HACK",&st_Dummy); |
|
1665 |
||
1666 |
#ifdef DEDICATED
|
|
1667 |
// settings missing in the dedicated server
|
|
1668 |
static tConfItemFunc st_Dummy1("ARENA_WALL_SHADOW_NEAR", &st_Dummy); |
|
1669 |
static tConfItemFunc st_Dummy2("ARENA_WALL_SHADOW_DIST", &st_Dummy); |
|
1670 |
static tConfItemFunc st_Dummy3("ARENA_WALL_SHADOW_SIDEDIST", &st_Dummy); |
|
1671 |
static tConfItemFunc st_Dummy4("ARENA_WALL_SHADOW_SIZE", &st_Dummy); |
|
1672 |
static tConfItemFunc st_Dummy5("BUG_TRANSPARENCY_DEMAND", &st_Dummy); |
|
1673 |
static tConfItemFunc st_Dummy6("BUG_TRANSPARENCY", &st_Dummy); |
|
1674 |
static tConfItemFunc st_Dummy7("SHOW_OWN_NAME", &st_Dummy); |
|
1675 |
static tConfItemFunc st_Dummy8("FADEOUT_NAME_DELAY", &st_Dummy); |
|
1676 |
static tConfItemFunc st_Dummy9("FLOOR_MIRROR_INT", &st_Dummy); |
|
1677 |
#endif
|
|
1678 |
#ifndef DEBUG
|
|
1679 |
// settings missing in optimized mode
|
|
1680 |
static tConfItemFunc st_Dummy10("SIMULATE_RECEIVE_PACKET_LOSS", &st_Dummy); |
|
1681 |
static tConfItemFunc st_Dummy11("SIMULATE_SEND_PACKET_LOSS", &st_Dummy); |
|
1084
by SwagTron
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out) |
1682 |
#endif
|