blib/lib/Games/Axmud/Obj/File.pm untested

filter: Statementstmt 0.0% 0 / 5899 Branchbran 0.0% 0 / 3008 Conditioncond 0.0% 0 / 1170 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 89 Podpod 0.0% 0 / 84 totaltotal 0.0% 0 / 10250 CC 1505 SCAR 128.3
CC
1505
Cov
0%
updateExtractedData
699732.0
loadConfigFile
47742.0
patchWorldProf
3906.0
CRAP 374100.2
1 # Copyright (C) 2011-2021 A S Lewis
2 #
3 # This program is free software: you can redistribute it and/or modify it under the terms of the GNU
4 # General Public License as published by the Free Software Foundation, either version 3 of the
5 # License, or (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License along with this program. If not,
12 # see <http://www.gnu.org/licenses/>.
13 #
14 #
15 # Games::Axmud::Obj::File
16 # The code that handles a single data file
17  
18 { package Games::Axmud::Obj::File;
19  
20 use strict;
21 use warnings;
22 use diagnostics;
23  
24 use Glib qw(TRUE FALSE);
25 # Include module here, as well as in axmud.pl, so that .../t/00-compile.t won't fail
26 use Fcntl qw(:flock);
27  
28 our @ISA = qw(Games::Axmud);
29  
30 ##################
31 # Constructors
32  
33 sub new {
34  
35 # Called by GA::Client->createFileObjs and ->loadWorldProfs
36 # Also called by GA::Session->createFileObj and GA::Cmd::Save->do
37 #
38 # Expected arguments
39 # $fileType - one of the types listed below
40 # TYPE PATH
41 # config <DATA_DIR>/axmud.conf
42 # worldprof <DATA_DIR>/data/worlds/<WORLD>/worldprof.axm
43 # otherprof <DATA_DIR>/data/worlds/<WORLD>/otherprof.axm
44 # worldmodel <DATA_DIR>/data/worlds/<WORLD>/worldmodel.axm
45 # tasks <DATA_DIR>/data/tasks.axm
46 # scripts <DATA_DIR>/data/scripts.axm
47 # contacts <DATA_DIR>/data/contacts.axm
48 # dicts <DATA_DIR>/data/dicts.axm
49 # toolbar <DATA_DIR>/data/toolbar.axm
50 # usercmds <DATA_DIR>/data/usercmds.axm
51 # zonemaps <DATA_DIR>/data/zonemaps.axm
52 # winmaps <DATA_DIR>/data/winmaps.axm
53 # tts <DATA_DIR>/data/tts.axm
54 #
55 # Optional arguments
56 # $assocWorldProf - For the file types 'worldprof', 'otherprof' and 'worldmodel', the name
57 # of the associated world profile - needed so we can set the path and
58 # directory ('undef' for other file types)
59 # $session - For the file types 'otherprof' and 'worldmodel', the name of the
60 # calling GA::Session ('undef' for other files types)
61 #
62 # Return values
63 # 'undef' on improper arguments or if $fileType isn't recognised
64 # Blessed reference to the newly-created object on success
65  
66 my ($class, $fileType, $assocWorldProf, $session, $check) = @_;
67  
68 # Local variables
69 my (
70 $name, $standardFileName, $standardPath, $standardDir, $altFileName,
71 $altPath,
72 );
73  
74 # Check for improper arguments
75 if (
76 ! defined $class
77 || ! defined $fileType
78 || (
79 defined $assocWorldProf && $fileType ne 'worldprof' && $fileType ne 'otherprof'
80 && $fileType ne 'worldmodel'
81 ) || (
82 ! defined $assocWorldProf && (
83 $fileType eq 'worldprof' || $fileType eq 'otherprof'
84 || $fileType eq 'worldmodel'
85 )
86 ) || (defined $session && $fileType ne 'otherprof' && $fileType ne 'worldmodel')
87 || (! defined $session && ($fileType eq 'otherprof' || $fileType eq 'worldmodel'))
88 ) {
89 return $axmud::CLIENT->writeImproper($class . '->new', @_);
90 }
91  
92 # Prepare variables this file type
93 if ($fileType eq 'config') {
94  
95 if ($^O eq 'MSWin32') {
96  
97 $standardFileName = $axmud::NAME_SHORT . '.ini';
98 $standardPath = '\\' . $axmud::NAME_SHORT . '.ini';
99 $altFileName = $axmud::NAME_SHORT . '.conf';
100 $altPath = '\\' . $axmud::NAME_SHORT . '.conf';
101  
102 } else {
103  
104 $standardFileName = $axmud::NAME_SHORT . '.conf';
105 $standardPath = '/' . $axmud::NAME_SHORT . '.conf';
106 $altFileName = $axmud::NAME_SHORT . '.ini';
107 $altPath = '/' . $axmud::NAME_SHORT . '.ini';
108 }
109  
110 $standardDir = '';
111  
112 } elsif ($fileType eq 'worldprof') {
113  
114 $standardFileName = 'worldprof.axm';
115 $standardPath = '/data/worlds/' . $assocWorldProf . '/' . $standardFileName;
116 $standardDir = '/data/worlds/' . $assocWorldProf;
117  
118 } elsif ($fileType eq 'otherprof') {
119  
120 $standardFileName = 'otherprof.axm';
121 $standardPath = '/data/worlds/' . $assocWorldProf . '/' . $standardFileName;
122 $standardDir = '/data/worlds/' . $assocWorldProf;
123  
124 } elsif ($fileType eq 'worldmodel') {
125  
126 $standardFileName = 'worldmodel.axm';
127 $standardPath = '/data/worlds/' . $assocWorldProf . '/' . $standardFileName;
128 $standardDir = '/data/worlds/' . $assocWorldProf;
129  
130 } elsif ($fileType eq 'tasks') {
131  
132 $standardFileName = 'tasks.axm';
133 $standardPath = '/data/tasks.axm';
134 $standardDir = '/data';
135  
136 } elsif ($fileType eq 'scripts') {
137  
138 $standardFileName = 'scripts.axm';
139 $standardPath = '/data/scripts.axm';
140 $standardDir = '/data';
141  
142 } elsif ($fileType eq 'contacts') {
143  
144 $standardFileName = 'contacts.axm';
145 $standardPath = '/data/contacts.axm';
146 $standardDir = '/data';
147  
148 } elsif ($fileType eq 'dicts') {
149  
150 $standardFileName = 'dicts.axm';
151 $standardPath = '/data/dicts.axm';
152 $standardDir = '/data';
153  
154 } elsif ($fileType eq 'toolbar') {
155  
156 $standardFileName = 'toolbar.axm';
157 $standardPath = '/data/toolbar.axm';
158 $standardDir = '/data';
159  
160 } elsif ($fileType eq 'usercmds') {
161  
162 $standardFileName = 'usercmds.axm';
163 $standardPath = '/data/usercmds.axm';
164 $standardDir = '/data';
165  
166 } elsif ($fileType eq 'zonemaps') {
167  
168 $standardFileName = 'zonemaps.axm';
169 $standardPath = '/data/zonemaps.axm';
170 $standardDir = '/data';
171  
172 } elsif ($fileType eq 'winmaps') {
173  
174 $standardFileName = 'winmaps.axm';
175 $standardPath = '/data/winmaps.axm';
176 $standardDir = '/data';
177  
178 } elsif ($fileType eq 'tts') {
179  
180 $standardFileName = 'tts.axm';
181 $standardPath = '/data/tts.axm';
182 $standardDir = '/data';
183  
184 } else {
185  
186 # Unrecognised file type
187 return $axmud::CLIENT->writeImproper($class . '->new', @_);
188 }
189  
190 # (Convert forward slashes to backwards slashes on MS Windows)
191 if ($^O eq 'MSWin32') {
192  
193 $standardFileName =~ s/\//\\/g;
194 $standardPath =~ s/\//\\/g;
195 $standardDir =~ s/\//\\/g;
196 }
197  
198 if ($fileType eq 'worldprof') {
199 $name = $assocWorldProf;
200 } else {
201 $name = $fileType;
202 }
203  
204 # Setup
205 my $self = {
206 _objName => $name,
207 _parentFile => undef, # File objects don't have parent file object
208 _parentWorld => undef, # See above
209 _objClass => $class,
210 _privFlag => TRUE, # All IVs are private
211  
212 # Perl object components
213 # ----------------------
214  
215 # The parent GA::Session object (only set for 'otherprof' and 'worldmodel' file types)
216 session => $session,
217  
218 # Other IVs
219 # ---------
220  
221 # Unique name for the FileObj
222 name => $name,
223  
224 # The information included in a file's header (i.e. the meta-data)
225 fileType => $fileType,
226 scriptName => undef,
227 scriptVersion => undef, # e.g. '1.2.345'
228 scriptConvertVersion => undef, # Set by call to GA::Client->convertVersion
229 saveDate => undef,
230 saveTime => undef,
231 # For file types 'worldprof', 'otherprof' and 'worldmodel', the name of the associated
232 # world profile (e.g. 'myworld') (default: 'undef')
233 assocWorldProf => $assocWorldProf,
234  
235 # File name, e.g. 'tasks.axm'
236 actualFileName => undef,
237 # Full path of the file, e.g. '/home/me/axmud/data/tasks.axm'
238 actualPath => undef,
239 # Directory
240 actualDir => undef,
241  
242 # The standard paths for this file type
243 standardFileName => $standardFileName,
244 # (Relative to script's directory)
245 standardPath => $standardPath,
246 # (Relative to script's directory)
247 standardDir => $standardDir,
248  
249 # For file type 'config', ->standardFileName ends .ini on MS Windows, .conf on Linux.
250 # For portability, these variables contains the standard filename on the operating
251 # system currently NOT in use
252 altFileName => $altFileName,
253 altPath => $altPath,
254  
255 # This flag should be set to TRUE (by the accessor functions inherited from the generic
256 # object Games::Axmud) whenever some of the data it contains is modified
257 modifyFlag => FALSE,
258 # This flag can be set to TRUE when a backup file (e.g. 'tasks.axm.bu') rather than the
259 # normal file (e.g. 'tasks.axm') is loaded
260 # When TRUE, the next time this file is saved, the existing backup file is not replaced,
261 # and the flag is then set back to FALSE
262 # In this way, if a file can't be loaded and the backup file is loaded instead, the
263 # faulty file is discarded (never becomes a backup file)
264 preserveBackupFlag => FALSE,
265 };
266  
267 # Bless the object into existence
268 bless $self, $class;
269 return $self;
270 }
271  
272 ##################
273 # Methods
274  
275 sub setupConfigFile {
276  
277 # Called by GA::Client->start for the file types:
278 # 'config'
279 # Loads the config file. If the file doesn't exist, creates it
280 #
281 # Expected arguments
282 # (none besides $self)
283 #
284 # Return values
285 # 'undef' on improper arguments, or if there any errors reading/writing the file, or if
286 # file loading/saving isn't allowed (because of global flags)
287 # 1 otherwise
288  
289 my ($self, $check) = @_;
290  
291 # Check for improper arguments
292 if (defined $check) {
293  
294 return $axmud::CLIENT->writeImproper($self->_objClass . '->setupConfigFile', @_);
295 }
296  
297 # Check it's the right file type for this function
298 if ($self->fileType ne 'config') {
299  
300 return $self->writeError(
301 'Wrong file type \'' . $self->fileType . '\'',
302 $self->_objClass . '->setupConfigFile',
303 );
304 }
305  
306 # Delete all data and logfiles, if the flag is set
307 if ($axmud::CLIENT->deleteFilesAtStartFlag) {
308  
309 # Need to delete the config file, so that a brand new one can be written (as if none had
310 # existed before)
311 if (-e $axmud::DATA_DIR . $self->standardPath) {
312  
313 # Config file on this operating system
314 unlink ($axmud::DATA_DIR . $self->standardPath);
315 }
316  
317 if (-e $axmud::DATA_DIR . $self->altPath) {
318  
319 # Config file on the other operating system
320 unlink ($axmud::DATA_DIR . $self->altPath);
321 }
322  
323 # Also delete the /data directory
324 if (-e $axmud::DATA_DIR . '/data' ) {
325  
326 File::Path::remove_tree($axmud::DATA_DIR . '/data');
327 }
328  
329 # Also delete /logs directory
330 if (-e $axmud::DATA_DIR . '/logs') {
331  
332 File::Path::remove_tree($axmud::DATA_DIR . '/logs');
333 }
334  
335 # Re-create all standard directories
336 $axmud::CLIENT->createDataDirs();
337 }
338  
339 # Check whether the config file already exists, and if we're allowed to load it
340 if (
341 $axmud::CLIENT->loadConfigFlag
342 && (
343 -e $axmud::DATA_DIR . $self->standardPath
344 || -e $axmud::DATA_DIR . $self->altPath
345 )
346 ) {
347 # The file exists and we are allowed to load it, so try to load it
348 if (! $self->loadConfigFile()) {
349  
350 return $self->writeError(
351 'Error reading \'' . $self->fileType . '\' data file',
352 $self->_objClass . '->setupConfigFile',
353 );
354  
355 } else {
356  
357 return 1;
358 }
359  
360 } elsif (
361 $axmud::CLIENT->saveConfigFlag
362 && ! (
363 -e $axmud::DATA_DIR . $self->standardPath
364 || -e $axmud::DATA_DIR . $self->altPath
365 )
366 ) {
367 # The file doesn't exist, but we are allowed to create it
368  
369 # Move files from Axmud's base sub-directories (default sound effects, default icons,
370 # etc) into its data directories
371 $axmud::CLIENT->fillDataDirs();
372  
373 # Copy pre-configured worlds into the data directory, and add entries for each of them
374 # in the GA::Client's directories. The TRUE argument signals that this function is the
375 # calling function
376 OUTER: foreach my $world ($axmud::CLIENT->constWorldList) {
377  
378 if (! defined $axmud::CLIENT->copyPreConfigWorld($world, TRUE)) {
379  
380 return $self->writeError(
381 'Error setting up \'' . $self->fileType . '\' data file',
382 $self->_objClass . '->setupConfigFile',
383 );
384 }
385 }
386  
387 # Try to create a config file
388 if (! $self->saveConfigFile()) {
389  
390 return $self->writeError(
391 'Error creating \'' . $self->fileType . '\' data file',
392 $self->_objClass . '->setupConfigFile',
393 );
394 }
395  
396 # The call to ->copyPreConfigWorlds will have added some dummy entries to the client's
397 # world registry; remove them (but create new entries in
398 # GA::Client->configWorldProfList, as if we had just read the config file, rather
399 # than delete it)
400 $axmud::CLIENT->cleanPreConfigWorlds();
401  
402 # Set a flag to show the 'dialogue' window which invites the user to add tasks to the
403 # global initial tasklist, the first time the script is run
404 if ($axmud::CLIENT->allowSetupWizWinFlag) {
405  
406 $axmud::CLIENT->set_showSetupWizWinFlag(TRUE);
407 }
408  
409 return 1;
410  
411 } else {
412  
413 # Cannot load or save the config file
414 return undef;
415 }
416 }
417  
418 sub saveConfigFile {
419  
420 # Called by $self->setupConfigFile for the file types:
421 # 'config'
422 # Saves the config file
423 #
424 # Expected arguments
425 # (none besides $self)
426 #
427 # Optional arguments
428 # $fileName - The file name, e.g. 'axmud.conf'
429 # $path - The full path, e.g. '/home/me/axmud-data/axmud.conf'
430 # $dir - The directory, e.g. '/home/me/axmud-data/'
431 # $emergFlag - If set to TRUE, an emergency save is in progress.
432 # GA::Client->saveConfigFlag is ignored, $self->disableAllFileAccess is
433 # not called on failure, and $self->modifyFlag is not set. Set to FALSE
434 # (or 'undef') if an emergency save is not in progress
435 #
436 # Notes:
437 # If $fileName is specified, $path and $dir must also be specified
438 # If $fileName is not specified, the default filename, path and directory for this file
439 # type are used
440 #
441 # Return values
442 # 'undef' on improper arguments, or if there any errors writing the file or in taking out
443 # a lock on the semaphore file
444 # 1 otherwise
445  
446 my ($self, $fileName, $path, $dir, $emergFlag, $check) = @_;
447  
448 # Local variables
449 my (
450 $backupFile, $semaphoreFile, $semaphoreHandle, $saveDate, $saveTime, $fileHandle,
451 $client, $result,
452 @list, @workspaceList, @storeGridList, @itemList, @modList,
453 %workspaceHash, %storeGridHash, %itemHash, %worldHash,
454 );
455  
456 # Check for improper arguments
457 if (
458 defined $check
459 || (defined $fileName && (! defined $path || ! defined $dir))
460 || (defined $path && (! defined $fileName || ! defined $dir))
461 || (defined $dir && (! defined $fileName || ! defined $path))
462 ) {
463 return $axmud::CLIENT->writeImproper($self->_objClass . '->saveConfigFile', @_);
464 }
465  
466 # Check it's the right file type for this function
467 if ($self->fileType ne 'config') {
468  
469 return $self->writeError(
470 'Wrong file type \'' . $self->fileType . '\'',
471 $self->_objClass . '->saveConfigFile',
472 );
473 }
474  
475 # Set the filename, path and directory, if not specified
476 if (! defined $fileName) {
477  
478 $fileName = $self->standardFileName;
479 $path = $axmud::DATA_DIR . $self->standardPath;
480 $dir = $axmud::DATA_DIR . $self->standardDir;
481 }
482  
483 # Checks made when an emergency save is NOT in progress...
484 if (! $emergFlag) {
485  
486 # Don't save anything if the global flags forbid it
487 if (! $axmud::CLIENT->saveConfigFlag) {
488  
489 return $self->disableSaveLoad(TRUE);
490 }
491  
492 # Check that the data directory exists
493 if (! (-d $dir)) {
494  
495 return $self->disableSaveLoad(TRUE);
496 }
497 }
498  
499 # Precautions taken when an emergency save is NOT in progress...
500 if (! $emergFlag) {
501  
502 if ($self->preserveBackupFlag) {
503  
504 # The file itself was missing/corrupted, so data was loaded from the backup file
505 # Don't replace the (good) backup file; just replace the (faulty) file itself
506 # NB For the config file, nothing in the Axmud code sets this flag to TRUE. Still,
507 # the code exists, for any future version that needs it
508 $self->ivPoke('preserveBackupFlag', FALSE);
509  
510 } elsif (-e $path) {
511  
512 # If the config file already exists, make a backup copy (it's not really necessary
513 # for the config file, which is so small, but for larger data files which take a
514 # long time to save, it's necessary to have a backup before overwriting an
515 # existing file)
516 if ($axmud::CLIENT->autoRetainFileFlag) {
517  
518 # Retain this backup file where the user can easily find it
519 $backupFile = $path . '.bu';
520  
521 } else {
522  
523 # This is a temporary backup file, so store it in the temporary files directory
524 # directory
525 $backupFile = $axmud::DATA_DIR . '/data/temp/config.bu';
526 }
527  
528 File::Copy::copy($path, $backupFile);
529 }
530  
531 # Get an exclusive lock on the twinned semaphore file
532 $semaphoreFile = $axmud::DATA_DIR . '/data/temp/config.sem';
533 $semaphoreHandle = $self->getFileLock($semaphoreFile, TRUE, $semaphoreFile);
534 # Don't try to write the config file if no lock could be taken out on the semaphore file
535 if (! $semaphoreHandle) {
536  
537 return $self->disableSaveLoad(FALSE);
538 }
539  
540 # Open the file for writing, overwriting previous contents
541 if (! open ($fileHandle, ">$path")) {
542  
543 # Could not open file
544 return $self->disableSaveLoad(FALSE);
545 }
546  
547 # (No precautions taken when an emergency save IS in progress)
548 } else {
549  
550 # Open the file for writing, overwriting previous contents
551 if (! open ($fileHandle, ">$path")) {
552  
553 return undef;
554 }
555 }
556  
557 # Need to add some values both to the file, and also to its header
558 $saveDate = $axmud::CLIENT->localDate();
559 $saveTime = $axmud::CLIENT->localTime();
560  
561 # Prepare header
562 push (@list,
563 '@@@ file_type config',
564 '@@@ script_name ' . $axmud::NAME_FILE,
565 '@@@ script_version ' . $axmud::VERSION,
566 '@@@ save_date ' . $saveDate,
567 '@@@ save_time ' . $saveTime,
568 '@@@ assoc_world_prof not_applicable',
569 '@@@ eos',
570 );
571  
572 # Script data (for information - not used, when the config file is loaded)
573 push (@list,
574 '# SCRIPT DATA',
575 '# Script name',
576 $axmud::NAME_FILE,
577 '# Script version',
578 $axmud::VERSION,
579 '# Script date',
580 $axmud::DATE,
581 '@@@ eos',
582 );
583  
584 # For convenience, import the GA::Client
585 $client = $axmud::CLIENT;
586  
587 # File object data
588 push (@list,
589 '# FILE OBJECTS',
590 '# Allow config file load',
591 $self->convert($client->loadConfigFlag),
592 '# Allow config file save',
593 $self->convert($client->saveConfigFlag),
594 '# Allow data file load',
595 $self->convert($client->loadDataFlag),
596 '# Allow data file load',
597 $self->convert($client->saveDataFlag),
598 '# Delete data directory at startup',
599 $self->convert($client->deleteFilesAtStartFlag),
600 '# Prompt user to do emergency saves',
601 $self->convert($client->emergencySaveFlag),
602 '# Auto-saves turned on',
603 $self->convert($client->autoSaveFlag),
604 '# Auto-save wait time (minutes)',
605 $client->autoSaveWaitTime,
606 '# Auto-retain most recent temporary backup file',
607 $self->convert($client->autoRetainFileFlag),
608 '# Auto-backup mode',
609 $client->autoBackupMode,
610 '# Auto-backup directory',
611 $client->autoBackupDir,
612 '# Auto-backup interval (days)',
613 $client->autoBackupInterval,
614 '# Time of last auto-backup (string in form \'Thu Dec 18, 2010\')',
615 $client->autoBackupDate,
616 '# Auto-backup file type',
617 $client->autoBackupFileType,
618 '# Append time to auto-backup files',
619 $self->convert($client->autoBackupAppendFlag),
620 '# Store large world models as multiple files',
621 $self->convert($client->modelSplitSize),
622 '# Approximate size of multiple world model files',
623 $client->modelSplitSize,
624 '@@@ eos',
625 );
626  
627 # Plugin data
628 push (@list,
629 '# PLUGINS',
630 '# Number of initial plugin files',
631 scalar $client->initPluginList,
632 '# List of initial plugin files',
633 $client->initPluginList,
634 '@@@ eos',
635 );
636  
637 # Instruction data
638 push (@list,
639 '# INSTRUCTIONS',
640 '# Enable echo commands',
641 $self->convert($client->echoSigilFlag),
642 '# Enable Perl commands',
643 $self->convert($client->perlSigilFlag),
644 '# Enable script commands',
645 $self->convert($client->scriptSigilFlag),
646 '# Enable multi commands',
647 $self->convert($client->multiSigilFlag),
648 '# Enable speedwalk commands',
649 $self->convert($client->speedSigilFlag),
650 '# Enable bypass commands',
651 $self->convert($client->bypassSigilFlag),
652 '# Command separator',
653 $client->cmdSep,
654 '@@@ eos',
655 );
656  
657 # World profile data. Extract a list of world profile names and sort it alphabetically
658 %worldHash = $axmud::CLIENT->worldProfHash;
659 @itemList = sort {lc($a) cmp lc($b)} (keys %worldHash);
660 # Filter out any unsaveable worlds, but use worlds (keys in %worldHash) with no
661 # corresponding profile objects (values in %worldHash), because those entries were
662 # probably created by GA::Client->copyPreConfigWorlds - and they must be saved in the
663 # config file
664 foreach my $world (@itemList) {
665  
666 my $worldObj = $worldHash{$world};
667 if (! $worldObj || ! $worldObj->noSaveFlag) {
668  
669 push (@modList, $world);
670 }
671 }
672  
673 push (@list,
674 '# WORLD PROFILES',
675 '# Previous client version',
676 $client->prevClientVersion,
677 '# Number of world profiles',
678 scalar @modList,
679 '# World profile list',
680 @modList,
681 '# Number of favourite worlds',
682 scalar $client->favouriteWorldList,
683 '# Favourite world list',
684 $client->favouriteWorldList,
685 '# Number of auto-connecting worlds',
686 scalar $client->autoConnectList,
687 '# Auto-connect list (world profile name followed by 0, 1 or more characters)',
688 $client->autoConnectList,
689 '@@@ eos',
690 );
691  
692 # Logging preferences
693 push (@list,
694 '# LOGGING PREFERENCES',
695 '# Allow logging',
696 $self->convert($client->allowLogsFlag),
697 '# Delete standard logs on startup',
698 $self->convert($client->deleteStandardLogsFlag),
699 '# Delete world logs on startup',
700 $self->convert($client->deleteWorldLogsFlag),
701 '# Prefix lines with date',
702 $self->convert($client->logPrefixDateFlag),
703 '# Prefix lines with time',
704 $self->convert($client->logPrefixTimeFlag),
705 '# Start new logfiles each day',
706 $self->convert($client->logDayFlag),
707 '# Start new logfiles on startup',
708 $self->convert($client->logClientFlag),
709 '# Display image names in logfiles',
710 $self->convert($client->logImageFlag),
711 '# Status task event number of lines recorded',
712 $client->statusEventBeforeCount,
713 $client->statusEventAfterCount,
714 );
715  
716 %itemHash = $client->logPrefHash;
717 @itemList = sort {lc($a) cmp lc($b)} (keys %itemHash);
718  
719 push (@list,
720 '# Number of log preferences',
721 scalar @itemList,
722 '# Log preferences',
723 );
724  
725 foreach my $item (@itemList) {
726  
727 my $flag = $itemHash{$item};
728  
729 push (@list, $item, $self->convert($flag));
730 }
731  
732 push (@list,
733 '# Number of lines in log preamble',
734 scalar $axmud::CLIENT->logPreambleList,
735 '# Log preamble',
736 $client->logPreambleList,
737 );
738  
739 push (@list, '@@@ eos');
740  
741 # Colour tags
742 %itemHash = $client->colourTagHash;
743 @itemList = sort {$a cmp $b} (keys %itemHash); # Don't use lc()
744  
745 push (@list,
746 '# COLOUR TAGS',
747 '# Current xterm colour cube',
748 $client->currentColourCube,
749 '# Allow OSC colour palette',
750 $self->convert($client->oscPaletteFlag),
751 '# Number of standard (normal) colour tags',
752 scalar @itemList,
753 '# Standard (normal) colour tags',
754 );
755  
756 foreach my $item (@itemList) {
757  
758 my $rgb = $itemHash{$item};
759  
760 push (@list, $item, $rgb);
761 }
762  
763 %itemHash = $client->boldColourTagHash;
764 @itemList = sort {$a cmp $b} (keys %itemHash); # Don't use lc()
765  
766 push (@list,
767 '# Number of standard (bold) colour tags',
768 scalar @itemList,
769 '# Standard (bold) colour tags',
770 );
771  
772 foreach my $item (@itemList) {
773  
774 my $rgb = $itemHash{$item};
775  
776 push (@list, $item, $rgb);
777 }
778  
779 push (@list, '@@@ eos');
780  
781 # Desktop and display settings
782 push (@list,
783 '# DESKTOP AND DISPLAY SETTINGS',
784 '# \'Main\' window default size',
785 $client->customMainWinWidth,
786 $client->customMainWinHeight,
787 '# \'Grid\' window default size',
788 $client->customGridWinWidth,
789 $client->customGridWinHeight,
790 '# \'Free\' window default size',
791 $client->customFreeWinWidth,
792 $client->customFreeWinHeight,
793 '# World command colour',
794 $client->customInsertCmdColour,
795 '# System message colour',
796 $client->customShowSystemTextColour,
797 '# System error message colour',
798 $client->customShowErrorColour,
799 '# System warning message colour',
800 $client->customShowWarningColour,
801 '# System debug message colour',
802 $client->customShowDebugColour,
803 '# System improper message colour',
804 $client->customShowImproperColour,
805 '# Convert invisible text flag',
806 $self->convert($client->convertInvisibleFlag),
807 '# Custom text buffer size',
808 $client->customTextBufferSize,
809 '# Custom panel left size',
810 $client->customPanelLeftSize,
811 '# Custom panel right size',
812 $client->customPanelRightSize,
813 '# Custom panel top size',
814 $client->customPanelTopSize,
815 '# Custom panel bottom size',
816 $client->customPanelBottomSize,
817 '# Custom window controls left size',
818 $client->customControlsLeftSize,
819 '# Custom window controls right size',
820 $client->customControlsRightSize,
821 '# Custom window controls top size',
822 $client->customControlsTopSize,
823 '# Custom window controls bottom size',
824 $client->customControlsBottomSize,
825 '# Sessions share a \'main\' window',
826 $self->convert($client->shareMainWinFlag),
827 '# (The setting to use when ' . $axmud::SCRIPT . ' next starts)',
828 $client->restartShareMainWinMode,
829 '# Workspace grids are activated',
830 $self->convert($client->activateGridFlag),
831 '# Store \'grid\' window positions',
832 $self->convert($client->storeGridPosnFlag),
833 );
834  
835 %storeGridHash = $client->storeGridPosnHash;
836 @storeGridList = sort {lc($a) cmp lc($b)} (keys %storeGridHash);
837  
838 push (@list,
839 '# Number of stored \'grid\' window positions',
840 scalar @storeGridList,
841 '# Stored \'grid\' window positions',
842 );
843  
844 foreach my $winName (@storeGridList) {
845  
846 my $listRef = $storeGridHash{$winName};
847  
848 # To make the loading code simpler, store 4 values as a line, in the form 'x y wid hei'
849 push (@list,
850 $winName,
851 $$listRef[0] . ' ' . $$listRef[1] . ' ' . $$listRef[2] . ' ' . $$listRef[3] . ' ',
852 );
853 }
854  
855 push (@list,
856 '# Direction of workspace adding',
857 $client->initWorkspaceDir,
858 );
859  
860 %workspaceHash = $client->initWorkspaceHash;
861 @workspaceList = sort {lc($a) cmp lc($b)} (keys %workspaceHash);
862  
863 push (@list,
864 '# Number of initial workspaces',
865 scalar @workspaceList,
866 '# Initial workspaces',
867 );
868  
869 foreach my $number (@workspaceList) {
870  
871 my $zonemap = $workspaceHash{$number};
872  
873 push (@list, $number, $zonemap);
874 }
875  
876 push (@list,
877 '# Gridblock size',
878 $client->gridBlockSize,
879 '# Grid gap max size',
880 $client->gridGapMaxSize,
881 '# Grid adjustment flag',
882 $self->convert($client->gridAdjustmentFlag),
883 '# Grid edge correction flag',
884 $self->convert($client->gridEdgeCorrectionFlag),
885 '# Grid reshuffle flag',
886 $self->convert($client->gridReshuffleFlag),
887 '# Grid invisible windows flag',
888 $self->convert($client->gridInvisWinFlag),
889 '@@@ eos',
890 );
891  
892 # Instructions
893 push (@list,
894 '# INSTRUCTIONS',
895 '# Display buffer size',
896 $client->customDisplayBufferSize,
897 '# Command buffer size',
898 $client->customCmdBufferSize,
899 '# Instruction buffer size',
900 $client->customInstructBufferSize,
901 '# Confirm world commands in \'main\' window',
902 $self->convert($client->confirmWorldCmdFlag),
903 '# Convert single-word world commands to lower case',
904 $self->convert($client->convertWorldCmdFlag),
905 '# Preserve world commands in command entry box',
906 $self->convert($client->preserveWorldCmdFlag),
907 '# Preserve other instructions in command entry box',
908 $self->convert($client->preserveOtherCmdFlag),
909 '# Multi commands apply to all sessions',
910 $self->convert($client->maxMultiCmdFlag),
911 '# Auto-complete mode',
912 $client->autoCompleteMode,
913 '# Auto-complete type',
914 $client->autoCompleteType,
915 '# Auto-complete location',
916 $client->autoCompleteParent,
917 '@@@ eos',
918 );
919  
920 # External applications
921 push (@list,
922 '# EXTERNAL APPLICATIONS',
923 '# Web browser command',
924 $client->browserCmd,
925 '# Audio player command',
926 $client->audioCmd,
927 '# Text editor command',
928 $client->textEditCmd,
929 '@@@ eos',
930 );
931  
932 # Sound effects
933 push (@list,
934 '# SOUND EFFECTS',
935 '# Sound allowed',
936 $self->convert($client->allowSoundFlag),
937 '# ASCII beeps allowed',
938 $self->convert($client->allowAsciiBellFlag),
939 );
940  
941 %itemHash = $client->customSoundHash;
942 @itemList = sort {lc($a) cmp lc($b)} (keys %itemHash);
943  
944 push (@list,
945 '# Number of sound effects',
946 scalar @itemList,
947 '# Sound effects',
948 );
949  
950 foreach my $item (@itemList) {
951  
952 my $path = $itemHash{$item};
953  
954 push (@list, $item, $path);
955 }
956  
957 push (@list, '@@@ eos');
958  
959 # Text-to-speech
960 push (@list,
961 '# TEXT-TO-SPEECH (TTS)',
962 '# TTS allowed for all users',
963 $self->convert($client->customAllowTTSFlag),
964 '# Apply TTS smoothing',
965 $self->convert($client->ttsSmoothFlag),
966 '# Hijack cursor (etc) keys in blind mode',
967 $self->convert($client->ttsHijackFlag),
968 '# Hijack cursor (etc) keys when not in blind mode',
969 $self->convert($client->ttsForceHijackFlag),
970 '# Use TTS for received text',
971 $self->convert($client->ttsReceiveFlag),
972 '# Don\'t use TTS for received text before login (except prompts)',
973 $self->convert($client->ttsLoginFlag),
974 '# Don\'t use TTS for recognised prompts in received text after a login',
975 $self->convert($client->ttsPromptFlag),
976 '# Use TTS for system messages',
977 $self->convert($client->ttsSystemFlag),
978 '# Use TTS for system error messages',
979 $self->convert($client->ttsSystemErrorFlag),
980 '# Use TTS for world commands',
981 $self->convert($client->ttsWorldCmdFlag),
982 '# Use TTS for \'dialogue\' windows',
983 $self->convert($client->ttsDialogueFlag),
984 '# Use TTS for task windows',
985 $self->convert($client->ttsTaskFlag),
986 '# Port for Festival server',
987 $client->ttsFestivalServerPort,
988 '@@@ eos',
989 );
990  
991 # Telnet options/mud protocols
992 push (@list,
993 '# TELNET OPTION NEGOTIATION',
994 '# Use ECHO',
995 $self->convert($client->useEchoFlag),
996 '# Use TTYPE',
997 $self->convert($client->useTTypeFlag),
998 '# Use NAWS',
999 $self->convert($client->useNawsFlag),
1000 '# Use CHARSET',
1001 $self->convert($client->useCharSetFlag),
1002 '# Use EOR',
1003 $self->convert($client->useEorFlag),
1004 '# Use SGa',
1005 $self->convert($client->useSgaFlag),
1006 '# Use NEW-ENVIRON',
1007 $self->convert($client->useNewEnvironFlag),
1008 '# MUD PROTOCOLS',
1009 '# Use MCCP',
1010 $self->convert($client->useMccpFlag),
1011 '# Use MSDP',
1012 $self->convert($client->useMsdpFlag),
1013 '# Use MSSP',
1014 $self->convert($client->useMsspFlag),
1015 '# Use MTTS',
1016 $self->convert($client->useMttsFlag),
1017 '# Use MNES',
1018 $self->convert($client->useMnesFlag),
1019 '# Use MXP',
1020 $self->convert($client->useMxpFlag),
1021 '# Use MSP',
1022 $self->convert($client->useMspFlag),
1023 '# Use Pueblo',
1024 $self->convert($client->usePuebloFlag),
1025 '# Use ATCP',
1026 $self->convert($client->useAtcpFlag),
1027 '# Use GMCP',
1028 $self->convert($client->useGmcpFlag),
1029 '# Use ZMP',
1030 $self->convert($client->useZmpFlag),
1031 '# Use AARD102',
1032 $self->convert($client->useAard102Flag),
1033 '# Use MCP',
1034 $self->convert($client->useMcpFlag),
1035 '# MUD PROTOCOL CUSTOMISATION',
1036 '# Allow MXP to change font',
1037 $self->convert($client->allowMxpFontFlag),
1038 '# Allow MXP to display images',
1039 $self->convert($client->allowMxpImageFlag),
1040 '# Allow MXP to download images',
1041 $self->convert($client->allowMxpLoadImageFlag),
1042 '# Allow MXP to use images in world\'s own graphics format',
1043 $self->convert($client->allowMxpFilterImageFlag),
1044 '# Allow MXP to play sound files',
1045 $self->convert($client->allowMxpSoundFlag),
1046 '# Allow MXP to download sound files',
1047 $self->convert($client->allowMxpLoadSoundFlag),
1048 '# Allow MXP to display gauges/status bars',
1049 $self->convert($client->allowMxpGaugeFlag),
1050 '# Allow MXP to use frames',
1051 $self->convert($client->allowMxpFrameFlag),
1052 '# Allow MXP to use internal frames',
1053 $self->convert($client->allowMxpInteriorFlag),
1054 '# Allow MXP to perform crosslinking operations',
1055 $self->convert($client->allowMxpCrosslinkFlag),
1056 '# Allow Locator task to use MXP room data',
1057 $self->convert($client->allowMxpRoomFlag),
1058 '# Allow some illegal MXP keywords (e.g. those using hyphens)',
1059 $self->convert($client->allowMxpFlexibleFlag),
1060 '# Allow MXP to be artificially enabled (for IRE MUDs)',
1061 $self->convert($client->allowMxpPermFlag),
1062 '# Allow MSP to play concurrent sound triggers',
1063 $self->convert($client->allowMspMultipleFlag),
1064 '# Allow MSP to download sound files',
1065 $self->convert($client->allowMspLoadSoundFlag),
1066 '# Allow flexible MSP tag placement (not recommended)',
1067 $self->convert($client->allowMspFlexibleFlag),
1068 '# Allow MNES to send user\'s IP address',
1069 $self->convert($client->allowMnesSendIPFlag),
1070 '# TELNET OPTION NEGOTIATION CUSTOMISATION',
1071 '# Sending termtype mode',
1072 $client->termTypeMode,
1073 '# Customised client name',
1074 $client->customClientName,
1075 '# Customised client version',
1076 $client->customClientVersion,
1077 '# Use VT100 control sequences',
1078 $self->convert($client->useCtrlSeqFlag),
1079 '# Use visible cursor in default textview',
1080 $self->convert($client->useVisibleCursorFlag),
1081 '# Cursor blinks quickly, when visible',
1082 $self->convert($client->useFastCursorFlag),
1083 '# Use direct keyboard input in default textview',
1084 $self->convert($client->useDirectKeysFlag),
1085 '# TELNET OPTION DEBUG FLAGS',
1086 '# Show invalid escape sequence debug messages',
1087 $self->convert($client->debugEscSequenceFlag),
1088 '# Show option negotiation debug messages',
1089 $self->convert($client->debugTelnetFlag),
1090 '# Show option negotiation short debug messages',
1091 $self->convert($client->debugTelnetMiniFlag),
1092 '# Ask GA::Obj::Telnet to write negotiation logfile',
1093 $self->convert($client->debugTelnetLogFlag),
1094 '# Show MSDP debug messages for Status/Locator',
1095 $self->convert($client->debugMsdpFlag),
1096 '# Show debug messages for MXP problems',
1097 $self->convert($client->debugMxpFlag),
1098 '# Show debug messages for MXP comments',
1099 $self->convert($client->debugMxpCommentFlag),
1100 '# Show debug messages for Pueblo problems',
1101 $self->convert($client->debugPuebloFlag),
1102 '# Show debug messages for Pueblo comments',
1103 $self->convert($client->debugPuebloCommentFlag),
1104 '# Show debug messages for incoming ZMP data',
1105 $self->convert($client->debugZmpFlag),
1106 '# Show debug messages for incoming ATCP data',
1107 $self->convert($client->debugAtcpFlag),
1108 '# Show debug messages for incoming GMCP data',
1109 $self->convert($client->debugGmcpFlag),
1110 '# Show debug messages for MCP problems',
1111 $self->convert($client->debugMcpFlag),
1112 '@@@ eos',
1113 );
1114  
1115 # Misc data
1116 push (@list,
1117 '# MISC DATA',
1118 '# Month list',
1119 12, # Don't bother stating the number of months in a year...
1120 $client->customMonthList,
1121 '# Day list',
1122 7, # ...or the number of days in a week
1123 $client->customDayList,
1124 '# Number commification mode',
1125 $client->commifyMode,
1126 '# Detect short weblinks',
1127 $self->convert($client->shortUrlFlag),
1128 '# List of IP lookup services',
1129 scalar $client->ipLookupList,
1130 $client->ipLookupList,
1131 '# Prompt wait time (seconds)',
1132 $client->promptWaitTime,
1133 '# Login warning time (seconds)',
1134 $client->loginWarningTime,
1135 '# Show explicit line numbers in \'main\' window',
1136 $self->convert($client->debugLineNumsFlag),
1137 '# Show explicit tags in \'main\' window',
1138 $self->convert($client->debugLineTagsFlag),
1139 '# Show Locator task debug messages',
1140 $self->convert($client->debugLocatorFlag),
1141 '# Show extensive Locator task debug messages',
1142 $self->convert($client->debugMaxLocatorFlag),
1143 '# Show illegal exit direction debug messages',
1144 $self->convert($client->debugExitFlag),
1145 '# Show Locator task expected room statements',
1146 $self->convert($client->debugMoveListFlag),
1147 '# Show object parsing debug messages',
1148 $self->convert($client->debugParseObjFlag),
1149 '# Show object comparison debug messages',
1150 $self->convert($client->debugCompareObjFlag),
1151 '# Show plugin failure debug messages',
1152 $self->convert($client->debugExplainPluginFlag),
1153 '# Show non-existent IV debug messages',
1154 $self->convert($client->debugCheckIVFlag),
1155 '# Show errors when table objects can\'t be added/resized',
1156 $self->convert($client->debugTableFitFlag),
1157 '# Show Perl errors/warnings in \'main\' window',
1158 $self->convert($client->debugTrapErrorFlag),
1159 '# Show toolbar button labels',
1160 $self->convert($client->toolbarLabelFlag),
1161 '# Show irreversible icon in \'edit\' windows',
1162 $self->convert($client->irreversibleIconFlag),
1163 '# Allow popup windows showing the ' . $axmud::SCRIPT . ' logo',
1164 $self->convert($client->allowBusyWinFlag),
1165 '# Allow system messages to be displayed in the \'main\' window',
1166 $self->convert($client->mainWinSystemMsgFlag),
1167 '# Set \'main\' window\'s urgency hint when text received',
1168 $self->convert($client->mainWinUrgencyFlag),
1169 '# Show tooltips in a session\'s default tab',
1170 $self->convert($client->mainWinTooltipFlag),
1171 '# Session tab mode',
1172 $client->sessionTabMode,
1173 '# Use xterm titles',
1174 $self->convert($client->xTermTitleFlag),
1175 '# Use long world names in tab labels',
1176 $self->convert($client->longTabLabelFlag),
1177 '# Don\'t use tab labels when only one session open',
1178 $self->convert($client->simpleTabFlag),
1179 '# Prompt user before closing \'main\' window',
1180 $self->convert($client->confirmCloseMainWinFlag),
1181 '# Prompt user before closing \'main\' window tabs',
1182 $self->convert($client->confirmCloseTabFlag),
1183 '# Prompt user before closing session from the \'main\' window menu',
1184 $self->convert($client->confirmCloseMenuFlag),
1185 '# Prompt user before closing session from the \'main\' window toolbar',
1186 $self->convert($client->confirmCloseToolButtonFlag),
1187 '# Character set',
1188 $client->charSet,
1189 '# Maximum concurrent sessions',
1190 $client->sessionMax,
1191 '# Switch to \'offline\' mode on disconnection',
1192 $self->convert($client->offlineOnDisconnectFlag),
1193 '# Store connection history',
1194 $self->convert($client->connectHistoryFlag),
1195 '# Use page up (etc) to scroll in textviews',
1196 $self->convert($client->useScrollKeysFlag),
1197 '# Page up (etc) doesn\'t scroll the entire page length',
1198 $self->convert($client->smoothScrollKeysFlag),
1199 '# Page up (etc) auto-engages split mode',
1200 $self->convert($client->autoSplitKeysFlag),
1201 '# Use tab/cursor keys to auto-complete commands',
1202 $self->convert($client->useCompleteKeysFlag),
1203 '# Use tab to switch between sessions',
1204 $self->convert($client->useSwitchKeysFlag),
1205 '@@@ eos',
1206 );
1207  
1208 # Prepare footer
1209 push @list, ('@@@ eof');
1210  
1211 # Add newline characters to every entry in @list before writing the whole list to the file
1212 foreach my $item (@list) {
1213  
1214 $item .= "\n";
1215 }
1216  
1217 print $fileHandle @list;
1218  
1219 # Writing complete
1220 $result = close $fileHandle;
1221  
1222 # Precautions taken when an emergency save is NOT in progress...
1223 if (! $emergFlag) {
1224  
1225 # Release the lock on the semaphore file
1226 $self->releaseFileLock($semaphoreHandle);
1227  
1228 if (! $result) {
1229  
1230 # Restore the config file from backup
1231 File::Copy::copy($backupFile, $path);
1232  
1233 # Set global flags and display an error message
1234 return $self->disableSaveLoad(FALSE);
1235  
1236 } elsif (! $axmud::CLIENT->autoRetainFileFlag) {
1237  
1238 # Delete the backup file, unless the user has opted to retain it
1239 unlink ($backupFile);
1240 }
1241  
1242 # Save the file's header (metadata) in this object's variables
1243 $self->ivPoke('scriptName', $axmud::NAME_FILE);
1244 $self->ivPoke('scriptVersion', $axmud::VERSION);
1245 $self->ivPoke(
1246 'scriptConvertVersion',
1247 $axmud::CLIENT->convertVersion($axmud::VERSION),
1248 );
1249 $self->ivPoke('saveDate', $saveDate);
1250 $self->ivPoke('saveTime', $saveTime);
1251 $self->ivUndef('assocWorldProf');
1252  
1253 $self->ivPoke('actualFileName', $fileName);
1254 $self->ivPoke('actualPath', $path);
1255 $self->ivPoke('actualDir', $dir);
1256  
1257 # If Axmud has been ported from MS Windows to Linux (or vice versa), the old config file
1258 # will have been read, and there will now be two. Delete the old one (which we no
1259 # longer need)
1260 if (-e $self->altFileName) {
1261  
1262 unlink $self->altFileName;
1263 }
1264  
1265 # Mark the file object's data as not needing to be saved
1266 $self->set_modifyFlag(FALSE, $self->_objClass . '->saveConfigFile');
1267 }
1268  
1269 return 1;
1270 }
1271  
1272 sub loadConfigFile {
1273  
1274 # Called by $self->setupConfigFile for the file types:
1275 # 'config'
1276 # Loads the config file
1277 #
1278 # Expected arguments
1279 # (none besides $self)
1280 #
1281 # Optional arguments
1282 # $fileName - The file name, e.g. 'axmud.conf'
1283 # $path - The full path, e.g. '/home/me/axmud-data/axmud.conf'
1284 # $dir - The directory, e.g. '/home/me/axmud-data/'
1285 #
1286 # Notes:
1287 # If one optional argument is specified, they must all be specified
1288 # If no optional arguments are specified (or are all set to 'undef'), the default
1289 # filename, path and directory for this file type are used
1290 #
1291 # Return values
1292 # 'undef' on improper arguments, or if there are any errors reading the file or in taking
1293 # out a lock on the semaphore file
1294 # 1 otherwise
1295  
1296 my ($self, $fileName, $path, $dir, $check) = @_;
1297  
1298 # Local variables
1299 my (
1300 $semaphoreFile, $semaphoreHandle, $fileHandle, $word, $fileType, $headerScriptName,
1301 $headerScriptVersion, $headerSaveDate, $headerSaveTime, $headerAssocWorldProf, $line,
1302 $failFlag, $warningCount, $result, $client, $notCompatFlag,
1303 %dataHash,
1304 );
1305  
1306 # Check for improper arguments
1307 if (
1308 defined $check
1309 || (defined $fileName && (! defined $path || ! defined $dir))
1310 || (defined $path && (! defined $fileName || ! defined $dir))
1311 || (defined $dir && (! defined $fileName || ! defined $path))
1312 ) {
1313 return $axmud::CLIENT->writeImproper($self->_objClass . '->loadConfigFile', @_);
1314 }
1315  
1316 # Check it's the right file type for this function
1317 if ($self->fileType ne 'config') {
1318  
1319 return $self->writeError(
1320 'Wrong file type \'' . $self->fileType . '\'',
1321 $self->_objClass . '->loadConfigFile',
1322 );
1323 }
1324  
1325 # Set the filename, path and directory, if not specified
1326 if (! defined $fileName) {
1327  
1328 $fileName = $self->standardFileName;
1329 $path = $axmud::DATA_DIR . $self->standardPath;
1330 $dir = $axmud::DATA_DIR . $self->standardDir;
1331 }
1332  
1333 # Don't load anything if the global flags forbid it
1334 if (! $axmud::CLIENT->loadConfigFlag) {
1335  
1336 return $self->disableSaveLoad(TRUE);
1337 }
1338  
1339 # Check that the data directory exists
1340 if (! (-d $dir)) {
1341  
1342 return $self->disableSaveLoad(TRUE);
1343 }
1344  
1345 # Check that the specified file exists
1346 if (! (-e $path)) {
1347  
1348 # If the alternative file name exists (because an MS Windows config file has been ported
1349 # to Linux, or vice-versa), use that instead
1350 if (-e $self->altFileName) {
1351  
1352 $fileName = $self->altFileName;
1353 $path = $axmud::DATA_DIR . $self->altPath;
1354  
1355 } else {
1356  
1357 # Config file doesn't exist at all
1358 return $self->disableSaveLoad(TRUE);
1359 }
1360 }
1361  
1362 # Get a shared lock on the twinned semaphore file
1363 $semaphoreFile = $axmud::DATA_DIR . '/data/temp/config.sem';
1364 $semaphoreHandle = $self->getFileLock($semaphoreFile, FALSE, $semaphoreFile);
1365 # Don't try to read the config file if no lock could be taken out on the semaphore file
1366 if (! $semaphoreHandle) {
1367  
1368 return $self->disableSaveLoad(FALSE);
1369 }
1370  
1371 # Open the file for reading
1372 if (! open ($fileHandle, "<$path")) {
1373  
1374 # Could not open file
1375 return $self->disableSaveLoad(FALSE);
1376 }
1377  
1378 #################
1379 # Read the header
1380  
1381 $failFlag = FALSE;
1382  
1383 ($word, $fileType) = $self->readMarker($fileHandle);
1384 if (! defined $word || $word ne 'file_type' || ! $fileType) {$failFlag = TRUE}
1385  
1386 ($word, $headerScriptName) = $self->readMarker($fileHandle);
1387 if (! defined $word || $word ne 'script_name' || ! $headerScriptName) {$failFlag = TRUE}
1388  
1389 ($word, $headerScriptVersion) = $self->readMarker($fileHandle);
1390 if (! defined $word || $word ne 'script_version' || ! $headerScriptVersion) {
1391  
1392 $failFlag = TRUE;
1393 }
1394  
1395 ($word, $headerSaveDate) = $self->readMarker($fileHandle);
1396 if (! defined $word || $word ne 'save_date' || ! $headerSaveDate) {$failFlag = TRUE}
1397  
1398 ($word, $headerSaveTime) = $self->readMarker($fileHandle);
1399 if (! defined $word || $word ne 'save_time' || ! $headerSaveTime) {$failFlag = TRUE}
1400  
1401 # Before v1.0.868, Axmud used 'assoc_world_defn' rather than 'assoc_world_prof'
1402 ($word, $headerAssocWorldProf) = $self->readMarker($fileHandle);
1403 if (
1404 ! defined $word
1405 || ($word ne 'assoc_world_prof' && $word ne 'assoc_world_defn')
1406 || ! $headerAssocWorldProf
1407 ) {
1408 $failFlag = TRUE;
1409 }
1410  
1411 # Read end-of-section
1412 ($line) = $self->readMarker($fileHandle);
1413 if (! defined $line || $line ne 'eos') {$failFlag = TRUE}
1414  
1415 # Do basic checks on the header file information - that the file was created by Axmud, by
1416 # the current version of it or an earlier version of it
1417 if (
1418 ! $self->checkCompatibility($headerScriptName)
1419 || $axmud::CLIENT->convertVersion($headerScriptVersion)
1420 > $axmud::CLIENT->convertVersion($axmud::VERSION)
1421 ) {
1422 $failFlag = TRUE;
1423 }
1424  
1425 # If header information is incorrect, don't bother reading the rest of the file
1426 if ($fileType ne $self->fileType || $failFlag) {
1427  
1428 # Close the file and release the lock on the semaphore file
1429 $result = close $fileHandle;
1430 $self->releaseFileLock($semaphoreHandle);
1431  
1432 if (! $result) {
1433 return $self->disableSaveLoad(FALSE);
1434 } elsif ($failFlag) {
1435 return $self->disableSaveLoad(TRUE);
1436 }
1437  
1438 # Otherwise, save the header information in this object
1439 } else {
1440  
1441 $self->ivPoke('scriptName', $headerScriptName);
1442 $self->ivPoke('scriptVersion', $headerScriptVersion);
1443 $self->ivPoke(
1444 'scriptConvertVersion',
1445 $axmud::CLIENT->convertVersion($headerScriptVersion),
1446 );
1447 $self->ivPoke('saveDate', $headerSaveDate);
1448 $self->ivPoke('saveTime', $headerSaveTime);
1449 $self->ivUndef('assocWorldProf');
1450  
1451 $self->ivPoke('actualFileName', $fileName);
1452 $self->ivPoke('actualPath', $path);
1453 $self->ivPoke('actualDir', $dir);
1454 }
1455  
1456 ###############
1457 # Read the data
1458  
1459 # Read data from the file, and store it temporarily in a single hash, %dataHash.
1460 # The temporary hash should contain the filehandle, so that $self->readValue (etc) can use
1461 # it
1462 $dataHash{'file_handle'} = $fileHandle;
1463  
1464 # Read script data (read, but not used)
1465 $failFlag = $self->readValue($failFlag, \%dataHash, 'script_name');
1466 $failFlag = $self->readValue($failFlag, \%dataHash, 'script_version');
1467 $failFlag = $self->readValue($failFlag, \%dataHash, 'script_date');
1468 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1469  
1470 # Read file object data
1471 $failFlag = $self->readFlag($failFlag, \%dataHash, 'load_config_flag');
1472 $failFlag = $self->readFlag($failFlag, \%dataHash, 'save_config_flag');
1473 $failFlag = $self->readFlag($failFlag, \%dataHash, 'load_data_flag');
1474 $failFlag = $self->readFlag($failFlag, \%dataHash, 'save_data_flag');
1475 $failFlag = $self->readFlag($failFlag, \%dataHash, 'delete_files_start_flag');
1476 if ($self->scriptConvertVersion >= 1_000_489) {
1477  
1478 $failFlag = $self->readFlag($failFlag, \%dataHash, 'emergency_save_flag');
1479 }
1480 $failFlag = $self->readFlag($failFlag, \%dataHash, 'auto_save_flag');
1481 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_save_wait_time');
1482 if ($self->scriptConvertVersion >= 1_000_118) {
1483  
1484 $failFlag = $self->readFlag($failFlag, \%dataHash, 'auto_retain_file_flag');
1485 }
1486 if ($self->scriptConvertVersion >= 1_001_024) {
1487  
1488 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_mode');
1489 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_dir');
1490 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_interval');
1491 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_date');
1492 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_file_type');
1493 $failFlag = $self->readFlag($failFlag, \%dataHash, 'auto_backup_append_flag');
1494 }
1495 if ($self->scriptConvertVersion >= 1_001_529) {
1496  
1497 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_model_split_flag');
1498 $failFlag = $self->readValue($failFlag, \%dataHash, 'model_split_size');
1499 }
1500 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1501  
1502 # Read plugin data
1503 $failFlag = $self->readList($failFlag, \%dataHash, 'init_plugin_list');
1504 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1505  
1506 # Read instruction data
1507 if ($self->scriptConvertVersion >= 1_000_880) {
1508  
1509 $failFlag = $self->readFlag($failFlag, \%dataHash, 'echo_sigil_flag');
1510 $failFlag = $self->readFlag($failFlag, \%dataHash, 'perl_sigil_flag');
1511 $failFlag = $self->readFlag($failFlag, \%dataHash, 'script_sigil_flag');
1512 $failFlag = $self->readFlag($failFlag, \%dataHash, 'multi_sigil_flag');
1513 }
1514 if ($self->scriptConvertVersion >= 1_000_912) {
1515  
1516 $failFlag = $self->readFlag($failFlag, \%dataHash, 'speed_sigil_flag');
1517 $failFlag = $self->readFlag($failFlag, \%dataHash, 'bypass_sigil_flag');
1518 }
1519 $failFlag = $self->readValue($failFlag, \%dataHash, 'cmd_sep');
1520 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1521  
1522 # Read world profile data
1523 if ($self->scriptConvertVersion >= 1_001_021) {
1524  
1525 $failFlag = $self->readValue($failFlag, \%dataHash, 'prev_client_version');
1526 }
1527 $failFlag = $self->readList($failFlag, \%dataHash, 'world_prof_list');
1528 $failFlag = $self->readList($failFlag, \%dataHash, 'favourite_world_list');
1529 if ($self->scriptConvertVersion >= 1_001_396) {
1530  
1531 $failFlag = $self->readList($failFlag, \%dataHash, 'auto_connect_list');
1532 }
1533 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1534  
1535 # Read logging preferences
1536 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_logs_flag');
1537 $failFlag = $self->readFlag($failFlag, \%dataHash, 'delete_standard_logs_flag');
1538 $failFlag = $self->readFlag($failFlag, \%dataHash, 'delete_world_logs_flag');
1539 $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_prefix_date_flag');
1540 $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_prefix_time_flag');
1541 $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_day_flag');
1542 $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_client_flag');
1543 if ($self->scriptConvertVersion >= 1_000_917) {
1544  
1545 $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_image_flag');
1546 }
1547 $failFlag = $self->readValue($failFlag, \%dataHash, 'status_before_count');
1548 $failFlag = $self->readValue($failFlag, \%dataHash, 'status_after_count');
1549 $failFlag = $self->readHash($failFlag, \%dataHash, 'log_pref_hash');
1550 if ($self->scriptConvertVersion >= 1_001_395) {
1551  
1552 $failFlag = $self->readList($failFlag, \%dataHash, 'log_preamble_list');
1553 }
1554 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1555  
1556 # Read colour tags
1557 if ($self->scriptConvertVersion >= 1_000_165) {
1558  
1559 $failFlag = $self->readValue($failFlag, \%dataHash, 'current_xterm_cube');
1560 }
1561 if ($self->scriptConvertVersion >= 1_000_203) {
1562  
1563 $failFlag = $self->readFlag($failFlag, \%dataHash, 'osc_palette_flag');
1564 }
1565 $failFlag = $self->readHash($failFlag, \%dataHash, 'colour_tag_hash');
1566 $failFlag = $self->readHash($failFlag, \%dataHash, 'bold_colour_tag_hash');
1567 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1568  
1569 # Read desktop and display settings
1570 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_main_win_width');
1571 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_main_win_height');
1572 if ($self->scriptConvertVersion < 1_000_800) {
1573  
1574 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1575 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1576 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1577 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1578 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1579 }
1580 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_grid_win_width');
1581 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_grid_win_height');
1582 if ($self->scriptConvertVersion < 1_000_800) {
1583  
1584 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1585 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1586 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1587 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1588 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1589 }
1590 if ($self->scriptConvertVersion < 1_000_800) {
1591  
1592 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1593 }
1594 if ($self->scriptConvertVersion >= 1_001_162) {
1595  
1596 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_free_win_width');
1597 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_free_win_height');
1598 }
1599 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_insert_cmd_colour');
1600 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_system_text_colour');
1601 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_error_colour');
1602 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_warning_colour');
1603 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_debug_colour');
1604 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_improper_colour');
1605 if ($self->scriptConvertVersion >= 1_000_079) {
1606  
1607 $failFlag = $self->readFlag($failFlag, \%dataHash, 'convert_invisible_flag');
1608 }
1609 if ($self->scriptConvertVersion >= 1_000_800) {
1610  
1611 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_text_buffer_size');
1612 }
1613 $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_left_size');
1614 $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_right_size');
1615 $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_top_size');
1616 $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_bottom_size');
1617 if ($self->scriptConvertVersion < 1_000_800) {
1618  
1619 $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me');
1620 $failFlag = $self->readHash($failFlag, \%dataHash, 'discard_me');
1621 }
1622 $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_controls_left_size');
1623 $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_controls_right_size');
1624 $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_controls_top_size');
1625 $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_controls_bottom_size');
1626 if ($self->scriptConvertVersion < 1_000_800) {
1627  
1628 $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me');
1629 }
1630 if ($self->scriptConvertVersion >= 1_000_800) {
1631  
1632 $failFlag = $self->readFlag($failFlag, \%dataHash, 'share_main_win_flag');
1633 $failFlag = $self->readValue($failFlag, \%dataHash, 'restart_share_main_win_mode');
1634 $failFlag = $self->readFlag($failFlag, \%dataHash, 'activate_grid_flag');
1635 }
1636 if ($self->scriptConvertVersion >= 1_001_164) {
1637  
1638 $failFlag = $self->readFlag($failFlag, \%dataHash, 'store_grid_posn_flag');
1639 $failFlag = $self->readHash($failFlag, \%dataHash, 'store_grid_posn_hash');
1640 }
1641 if ($self->scriptConvertVersion >= 1_000_800) {
1642  
1643 $failFlag = $self->readValue($failFlag, \%dataHash, 'init_workspace_dir');
1644 $failFlag = $self->readHash($failFlag, \%dataHash, 'init_workspace_hash');
1645 }
1646 $failFlag = $self->readValue($failFlag, \%dataHash, 'grid_block_size');
1647 $failFlag = $self->readValue($failFlag, \%dataHash, 'grid_gap_max_size');
1648 $failFlag = $self->readFlag($failFlag, \%dataHash, 'grid_adjustment_flag');
1649 $failFlag = $self->readFlag($failFlag, \%dataHash, 'grid_edge_correction_flag');
1650 $failFlag = $self->readFlag($failFlag, \%dataHash, 'grid_reshuffle_flag');
1651 $failFlag = $self->readFlag($failFlag, \%dataHash, 'grid_invis_win_flag');
1652 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1653  
1654 if ($self->scriptConvertVersion < 1_000_800) {
1655  
1656 # Read 'main' window widget flags
1657 $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me');
1658 $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me');
1659 if ($self->scriptConvertVersion >= 1_000_674) {
1660  
1661 $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me');
1662 }
1663 if ($self->scriptConvertVersion >= 1_000_549) {
1664  
1665 $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me');
1666 }
1667 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1668 }
1669  
1670 # Read instructions
1671 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_display_buffer_size');
1672 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_cmd_buffer_size');
1673 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_instruct_buffer_size');
1674 $failFlag = $self->readFlag($failFlag, \%dataHash, 'confirm_world_cmd_flag');
1675 if ($self->scriptConvertVersion >= 1_000_331) {
1676  
1677 $failFlag = $self->readFlag($failFlag, \%dataHash, 'convert_world_cmd_flag');
1678 }
1679 $failFlag = $self->readFlag($failFlag, \%dataHash, 'preserve_world_cmd_flag');
1680 if ($self->scriptConvertVersion >= 1_000_880) {
1681  
1682 $failFlag = $self->readFlag($failFlag, \%dataHash, 'preserve_other_cmd_flag');
1683 $failFlag = $self->readFlag($failFlag, \%dataHash, 'max_multi_cmd_flag');
1684 }
1685 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_complete_mode');
1686 if ($self->scriptConvertVersion < 1_000_800 && ! $failFlag) {
1687  
1688 if ($dataHash{'auto_complete_mode'} eq '0') {
1689 $dataHash{'auto_complete_mode'} = 'none';
1690 } elsif (
1691 $dataHash{'auto_complete_mode'} eq '1'
1692 || $dataHash{'auto_complete_mode'} eq '2'
1693 ) {
1694 $dataHash{'auto_complete_mode'} = 'auto';
1695 }
1696 }
1697 if ($self->scriptConvertVersion >= 1_000_800) {
1698  
1699 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_complete_type');
1700 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_complete_parent');
1701 }
1702 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1703  
1704 # Read external applications
1705 $failFlag = $self->readValue($failFlag, \%dataHash, 'browser_cmd');
1706 $failFlag = $self->readValue($failFlag, \%dataHash, 'audio_cmd');
1707 $failFlag = $self->readValue($failFlag, \%dataHash, 'text_edit_cmd');
1708 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1709  
1710 # Read sound effects
1711 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_sound_flag');
1712 if ($self->scriptConvertVersion >= 1_000_087) {
1713  
1714 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_ascii_bell_flag');
1715 }
1716 $failFlag = $self->readHash($failFlag, \%dataHash, 'custom_sound_hash');
1717 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1718  
1719 # Read text-to-speech (TTS)
1720 if ($self->scriptConvertVersion >= 1_000_618) {
1721  
1722 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_tts_flag');
1723 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_smooth_flag');
1724 if ($self->scriptConvertVersion >= 1_002_073) {
1725  
1726 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_hijack_flag');
1727 }
1728 if ($self->scriptConvertVersion >= 1_002_213) {
1729  
1730 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_force_hijack_flag');
1731 }
1732 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_receive_flag');
1733 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_login_flag');
1734 if ($self->scriptConvertVersion >= 1_002_212) {
1735  
1736 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_prompt_flag');
1737 }
1738 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_system_flag');
1739 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_system_error_flag');
1740 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_world_cmd_flag');
1741 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_dialogue_flag');
1742 $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_task_flag');
1743 $failFlag = $self->readValue($failFlag, \%dataHash, 'tts_festival_server_port');
1744 if ($self->scriptConvertVersion < 1_002_185) {
1745  
1746 $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me');
1747 }
1748 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1749 }
1750  
1751 # Read telnet option negotiation flags
1752 if ($self->scriptConvertVersion >= 1_000_156) {
1753  
1754 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_echo_flag');
1755 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_ttype_flag');
1756 }
1757 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_naws_flag');
1758 if ($self->scriptConvertVersion >= 1_000_156) {
1759  
1760 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_charset_flag');
1761 }
1762 if ($self->scriptConvertVersion >= 1_000_163) {
1763  
1764 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_eor_flag');
1765 }
1766 if ($self->scriptConvertVersion >= 1_000_879) {
1767  
1768 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_sga_flag');
1769 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_new_environ_flag');
1770 }
1771 # Read MUD protocol flags
1772 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mccp_flag');
1773 if ($self->scriptConvertVersion >= 1_000_156) {
1774  
1775 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_msdp_flag');
1776 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mssp_flag');
1777 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mtts_flag');
1778 }
1779 if ($self->scriptConvertVersion >= 1_002_095) {
1780  
1781 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mnes_flag');
1782 }
1783 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mxp_flag');
1784 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_msp_flag');
1785 if ($self->scriptConvertVersion >= 1_000_844) {
1786  
1787 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_pueblo_flag');
1788 }
1789 if ($self->scriptConvertVersion >= 1_000_850) {
1790  
1791 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_atcp_flag');
1792 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_gmcp_flag');
1793 }
1794 if ($self->scriptConvertVersion >= 1_000_879) {
1795  
1796 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_zmp_flag');
1797 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_aard102_flag');
1798 $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mcp_flag');
1799 }
1800 if ($self->scriptConvertVersion >= 1_000_832) {
1801  
1802 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_font_flag');
1803 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_image_flag');
1804 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_load_image_flag');
1805 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_filter_image_flag');
1806 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_sound_flag');
1807 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_load_sound_flag');
1808 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_gauge_flag');
1809 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_frame_flag');
1810 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_interior_flag');
1811 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_crosslink_flag');
1812 }
1813 if ($self->scriptConvertVersion >= 1_000_887) {
1814  
1815 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_room_flag');
1816 }
1817 if ($self->scriptConvertVersion >= 1_001_510) {
1818  
1819 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_flexible_flag');
1820 }
1821 if ($self->scriptConvertVersion >= 1_002_020) {
1822  
1823 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_perm_flag');
1824 }
1825 if ($self->scriptConvertVersion >= 1_000_678) {
1826  
1827 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_msp_multiple_flag');
1828 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_msp_load_sound_flag');
1829 }
1830 if ($self->scriptConvertVersion >= 1_000_886) {
1831  
1832 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_msp_flexible_flag');
1833 }
1834 if ($self->scriptConvertVersion >= 1_002_095) {
1835  
1836 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mnes_send_ip_flag');
1837 }
1838 # Read telnet option negotiation customisation IVs
1839 if ($self->scriptConvertVersion >= 1_000_160) {
1840  
1841 $failFlag = $self->readValue($failFlag, \%dataHash, 'term_type_mode');
1842 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_client_name');
1843 }
1844 if ($self->scriptConvertVersion >= 1_000_666) {
1845  
1846 $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_client_version');
1847 }
1848 if ($self->scriptConvertVersion >= 1_001_213) {
1849  
1850 $failFlag = $self->readValue($failFlag, \%dataHash, 'use_ctrl_seq_flag');
1851 $failFlag = $self->readValue($failFlag, \%dataHash, 'use_visible_cursor_flag');
1852 $failFlag = $self->readValue($failFlag, \%dataHash, 'use_fast_cursor_flag');
1853 $failFlag = $self->readValue($failFlag, \%dataHash, 'use_direct_keys_flag');
1854 }
1855 # Set telnet negotiation debug flags
1856 if ($self->scriptConvertVersion >= 1_001_214) {
1857  
1858 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_esc_sequence_flag');
1859 }
1860 if ($self->scriptConvertVersion >= 1_000_378) {
1861  
1862 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_telnet_flag');
1863 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_telnet_mini_flag');
1864 }
1865 if ($self->scriptConvertVersion >= 1_000_895) {
1866  
1867 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_telnet_log_flag');
1868 }
1869 if ($self->scriptConvertVersion >= 1_000_378) {
1870  
1871 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_msdp_flag');
1872 }
1873 if ($self->scriptConvertVersion >= 1_000_405) {
1874  
1875 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_mxp_flag');
1876 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_mxp_comment_flag');
1877 }
1878 if ($self->scriptConvertVersion >= 1_000_849) {
1879  
1880 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_pueblo_flag');
1881 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_pueblo_comment_flag');
1882 }
1883 if ($self->scriptConvertVersion >= 1_001_140) {
1884  
1885 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_zmp_flag');
1886 }
1887 if ($self->scriptConvertVersion >= 1_000_926) {
1888  
1889 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_atcp_flag');
1890 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_gmcp_flag');
1891 }
1892 if ($self->scriptConvertVersion >= 1_001_158) {
1893  
1894 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_mcp_flag');
1895 }
1896  
1897 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
1898  
1899 # Read misc data
1900 $failFlag = $self->readList($failFlag, \%dataHash, 'custom_month_list');
1901 $failFlag = $self->readList($failFlag, \%dataHash, 'custom_day_list');
1902 if ($self->scriptConvertVersion >= 1_001_262) {
1903  
1904 $failFlag = $self->readValue($failFlag, \%dataHash, 'commify_mode');
1905 }
1906 if ($self->scriptConvertVersion >= 1_001_284) {
1907  
1908 $failFlag = $self->readValue($failFlag, \%dataHash, 'short_url_flag');
1909 }
1910 if ($self->scriptConvertVersion <= 1_000_922) {
1911  
1912 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
1913 }
1914 if ($self->scriptConvertVersion >= 1_002_166) {
1915  
1916 $failFlag = $self->readList($failFlag, \%dataHash, 'ip_lookup_list');
1917 }
1918 $failFlag = $self->readValue($failFlag, \%dataHash, 'prompt_wait_time');
1919 $failFlag = $self->readValue($failFlag, \%dataHash, 'login_warning_time');
1920 if ($self->scriptConvertVersion >= 1_000_331) {
1921  
1922 if ($self->scriptConvertVersion <= 1_000_535) {
1923  
1924 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_world_flag');
1925  
1926 } else {
1927  
1928 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_line_nums_flag');
1929 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_line_tags_flag');
1930 }
1931 }
1932 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_locator_flag');
1933 if ($self->scriptConvertVersion >= 1_000_482) {
1934  
1935 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_max_locator_flag');
1936 }
1937 if ($self->scriptConvertVersion >= 1_001_282) {
1938  
1939 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_exit_flag');
1940 }
1941 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_move_list_flag');
1942 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_parse_obj_flag');
1943 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_compare_obj_flag');
1944 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_explain_plugin_flag');
1945 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_check_iv_flag');
1946 if ($self->scriptConvertVersion >= 1_000_800) {
1947  
1948 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_table_fit_flag');
1949 }
1950 $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_trap_error_flag');
1951 if ($self->scriptConvertVersion >= 1_000_949) {
1952  
1953 $failFlag = $self->readFlag($failFlag, \%dataHash, 'toolbar_label_flag');
1954 }
1955 $failFlag = $self->readFlag($failFlag, \%dataHash, 'irreversible_icon_flag');
1956 if ($self->scriptConvertVersion >= 1_001_136) {
1957  
1958 $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_busy_win_flag');
1959 }
1960 if ($self->scriptConvertVersion >= 1_001_202) {
1961  
1962 $failFlag = $self->readFlag($failFlag, \%dataHash, 'main_win_system_msg_flag');
1963 }
1964 if ($self->scriptConvertVersion >= 1_000_344) {
1965  
1966 $failFlag = $self->readFlag($failFlag, \%dataHash, 'main_win_urgency_flag');
1967 }
1968 if ($self->scriptConvertVersion >= 1_000_883) {
1969  
1970 $failFlag = $self->readFlag($failFlag, \%dataHash, 'main_win_tooltip_flag');
1971 }
1972 $failFlag = $self->readValue($failFlag, \%dataHash, 'session_tab_mode');
1973 if ($self->scriptConvertVersion >= 1_000_184) {
1974  
1975 $failFlag = $self->readFlag($failFlag, \%dataHash, 'xterm_title_flag');
1976 }
1977 if ($self->scriptConvertVersion >= 1_000_365) {
1978  
1979 $failFlag = $self->readFlag($failFlag, \%dataHash, 'long_tab_label_flag');
1980 $failFlag = $self->readFlag($failFlag, \%dataHash, 'simple_tab_flag');
1981 }
1982 if ($self->scriptConvertVersion >= 1_000_917) {
1983  
1984 $failFlag = $self->readFlag($failFlag, \%dataHash, 'confirm_close_main_win_flag');
1985 $failFlag = $self->readFlag($failFlag, \%dataHash, 'confirm_close_tab_flag');
1986 }
1987 if ($self->scriptConvertVersion >= 1_002_102) {
1988  
1989 $failFlag = $self->readValue($failFlag, \%dataHash, 'confirm_close_menu_flag');
1990 $failFlag = $self->readValue($failFlag, \%dataHash, 'confirm_close_tool_button_flag');
1991 }
1992 if ($self->scriptConvertVersion >= 1_000_185) {
1993  
1994 $failFlag = $self->readValue($failFlag, \%dataHash, 'char_set');
1995 }
1996 if ($self->scriptConvertVersion >= 1_000_616) {
1997  
1998 $failFlag = $self->readValue($failFlag, \%dataHash, 'session_max');
1999 }
2000 if ($self->scriptConvertVersion >= 1_001_256) {
2001  
2002 $failFlag = $self->readValue($failFlag, \%dataHash, 'offline_on_disconnect_flag');
2003 }
2004 if ($self->scriptConvertVersion >= 1_000_884) {
2005  
2006 $failFlag = $self->readValue($failFlag, \%dataHash, 'connect_history_flag');
2007 }
2008 if ($self->scriptConvertVersion >= 1_000_338 && $self->scriptConvertVersion <= 1_000_884) {
2009  
2010 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
2011 $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
2012 }
2013 if ($self->scriptConvertVersion >= 1_000_338) {
2014  
2015 $failFlag = $self->readValue($failFlag, \%dataHash, 'use_scroll_keys_flag');
2016 }
2017 if ($self->scriptConvertVersion >= 1_000_884) {
2018  
2019 $failFlag = $self->readValue($failFlag, \%dataHash, 'smooth_scroll_keys_flag');
2020 $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_split_keys_flag');
2021 }
2022 if ($self->scriptConvertVersion >= 1_000_338) {
2023  
2024 $failFlag = $self->readValue($failFlag, \%dataHash, 'use_complete_keys_flag');
2025 $failFlag = $self->readValue($failFlag, \%dataHash, 'use_switch_keys_flag');
2026 }
2027  
2028 $failFlag = $self->readEndOfSection($failFlag, $fileHandle);
2029  
2030 #################
2031 # Read the footer
2032  
2033 ($line) = $self->readMarker($fileHandle);
2034 if (! defined $line || $line ne 'eof') {
2035  
2036 $failFlag = TRUE;
2037 }
2038  
2039 # Reading complete
2040 $result = close $fileHandle;
2041 # Release the lock on the semaphore file
2042 $self->releaseFileLock($semaphoreHandle);
2043  
2044 if (! $result) {
2045  
2046 # Set global flags and display an error message
2047 return $self->disableSaveLoad(FALSE);
2048  
2049 } elsif ($failFlag) {
2050  
2051 # Error messages displayed by $self->setupConfigFile
2052 return $self->disableSaveLoad(TRUE);
2053 }
2054  
2055 ##############
2056 # Basic checks
2057  
2058 $warningCount = 0;
2059  
2060 # Check header data
2061  
2062 # For config files created before the first public release, display a warning that the file
2063 # might not be compatible with the current version of Axmud (this prevents difficult-to-
2064 # diagnose errors which are actually the result of old data)
2065 if (
2066 $axmud::CLIENT->convertVersion($axmud::VERSION) < 1
2067 && (
2068 $axmud::CLIENT->convertVersion($headerScriptVersion)
2069 != $axmud::CLIENT->convertVersion($axmud::VERSION)
2070 )
2071 ) {
2072 $warningCount++;
2073  
2074 $self->writeWarning(
2075 'Config file may be incompatible with this version of ' . $axmud::CLIENT
2076 . ' (file v' . $headerScriptVersion . ', client v' . $axmud::VERSION . ')',
2077 $self->_objClass . '->loadConfigFile',
2078 );
2079 }
2080  
2081 # Respond to any warnings
2082 if ($warningCount == 1) {
2083  
2084 $self->writeWarning(
2085 'Config file: 1 warning issued and data not loaded',
2086 $self->_objClass . '->loadConfigFile',
2087 );
2088  
2089 return $self->disableSaveLoad(TRUE);
2090  
2091 } elsif ($warningCount > 1) {
2092  
2093 $self->writeWarning(
2094 'Config file: ' . $warningCount . ' warnings issued and data not loaded',
2095 $self->_objClass . '->loadConfigFile',
2096 );
2097  
2098 return $self->disableSaveLoad(TRUE);
2099 }
2100  
2101 ##############
2102 # Data updates
2103  
2104 # v1.0.908 converts some numerical mode values to string mode values
2105 if ($self->scriptConvertVersion < 1_000_909) {
2106  
2107 # GA::Client->sessionTabMode
2108 if ($dataHash{'session_tab_mode'} eq '0') {
2109 $dataHash{'session_tab_mode'} = 'bracket';
2110 } elsif ($dataHash{'session_tab_mode'} eq '1') {
2111 $dataHash{'session_tab_mode'} = 'hyphen';
2112 } elsif ($dataHash{'session_tab_mode'} eq '2') {
2113 $dataHash{'session_tab_mode'} = 'world';
2114 } elsif ($dataHash{'session_tab_mode'} eq '3') {
2115 $dataHash{'session_tab_mode'} = 'char';
2116 }
2117  
2118 # GA::Client->termTypeMode
2119 if ($self->scriptConvertVersion >= 1_000_160) {
2120  
2121 if ($dataHash{'term_type_mode'} eq '0') {
2122 $dataHash{'term_type_mode'} = 'send_nothing';
2123 } elsif ($dataHash{'term_type_mode'} eq '1') {
2124 $dataHash{'term_type_mode'} = 'send_client';
2125 } elsif ($dataHash{'term_type_mode'} eq '2') {
2126 $dataHash{'term_type_mode'} = 'send_client_version';
2127 } elsif ($dataHash{'term_type_mode'} eq '3') {
2128 $dataHash{'term_type_mode'} = 'send_custom_client';
2129 } elsif ($dataHash{'term_type_mode'} eq '4') {
2130 $dataHash{'term_type_mode'} = 'send_default';
2131 } elsif ($dataHash{'term_type_mode'} eq '5') {
2132 $dataHash{'term_type_mode'} = 'send_unknown';
2133 }
2134 }
2135 }
2136  
2137 # v1.2.0 makes window tiling available on all operating systems
2138 if ($self->scriptConvertVersion < 1_002_000 && $^O eq 'MSWin32') {
2139  
2140 $dataHash{'store_grid_posn_flag'} = FALSE;
2141  
2142 # Show the Setup 'wiz' window again, so the user can choose a layout. As of this
2143 # version, the 'wiz' window now checks that any initial tasks already exist and, if
2144 # so, updates them (usually to make their windows upon automatically) rather than
2145 # creating new initial tasks
2146 if (! $axmud::TEST_MODE_FLAG && ! $axmud::BLIND_MODE_FLAG) {
2147  
2148 $axmud::CLIENT->set_showSetupWizWinFlag(TRUE);
2149 }
2150 }
2151  
2152 ######################
2153 # Set GA::Client IVs
2154  
2155 # For convenience, import the GA::Client
2156 $client = $axmud::CLIENT;
2157  
2158 # Set IVs directly, rather than using GA::Client's 'set' accessors (otherwise the file
2159 # object's ->modifyFlag will get set to TRUE again, which we obviously don't want)
2160  
2161 # Set file object data
2162 $client->ivPoke('loadConfigFlag', $dataHash{'load_config_flag'});
2163 $client->ivPoke('saveConfigFlag', $dataHash{'save_config_flag'});
2164 $client->ivPoke('loadDataFlag', $dataHash{'load_data_flag'});
2165 $client->ivPoke('saveDataFlag', $dataHash{'save_data_flag'});
2166 $client->ivPoke('deleteFilesAtStartFlag', $dataHash{'delete_files_start_flag'});
2167 if ($self->scriptConvertVersion >= 1_000_489) {
2168  
2169 $client->ivPoke('emergencySaveFlag', $dataHash{'emergency_save_flag'});
2170 }
2171 $client->ivPoke('autoSaveFlag', $dataHash{'auto_save_flag'});
2172 if ($self->scriptConvertVersion < 1_000_148) {
2173  
2174 # ->autoSaveWaitTime is now expressed in minutes, not seconds
2175 $client->ivPoke(
2176 'autoSaveWaitTime',
2177 POSIX::ceil( ($dataHash{'auto_save_wait_time'}) / 60),
2178 );
2179  
2180 } else {
2181  
2182 $client->ivPoke('autoSaveWaitTime', $dataHash{'auto_save_wait_time'});
2183 }
2184 if ($self->scriptConvertVersion >= 1_000_118) {
2185  
2186 $client->ivPoke('autoRetainFileFlag', $dataHash{'auto_retain_file_flag'});
2187 }
2188 if ($self->scriptConvertVersion >= 1_001_024) {
2189  
2190 $client->ivPoke('autoBackupMode', $dataHash{'auto_backup_mode'});
2191 $client->ivPoke('autoBackupDir', $dataHash{'auto_backup_dir'});
2192 $client->ivPoke('autoBackupInterval', $dataHash{'auto_backup_interval'});
2193 $client->ivPoke('autoBackupDate', $dataHash{'auto_backup_date'});
2194 $client->ivPoke('autoBackupFileType', $dataHash{'auto_backup_file_type'});
2195 $client->ivPoke('autoBackupAppendFlag', $dataHash{'auto_backup_append_flag'});
2196 }
2197 if ($self->scriptConvertVersion >= 1_001_529) {
2198  
2199 $client->ivPoke('allowModelSplitFlag', $dataHash{'allow_model_split_flag'});
2200 $client->ivPoke('modelSplitSize', $dataHash{'model_split_size'});
2201 }
2202  
2203 # Set plugin data
2204 $client->ivPoke('initPluginList', @{$dataHash{'init_plugin_list'}});
2205  
2206 # Set instruction data
2207 if ($self->scriptConvertVersion >= 1_000_880) {
2208  
2209 $client->ivPoke('echoSigilFlag', $dataHash{'echo_sigil_flag'});
2210 $client->ivPoke('perlSigilFlag', $dataHash{'perl_sigil_flag'});
2211 $client->ivPoke('scriptSigilFlag', $dataHash{'script_sigil_flag'});
2212 $client->ivPoke('multiSigilFlag', $dataHash{'multi_sigil_flag'});
2213 }
2214 if ($self->scriptConvertVersion >= 1_000_912) {
2215  
2216 $client->ivPoke('speedSigilFlag', $dataHash{'speed_sigil_flag'});
2217 $client->ivPoke('bypassSigilFlag', $dataHash{'bypass_sigil_flag'});
2218 }
2219 $client->ivPoke('cmdSep', $dataHash{'cmd_sep'});
2220  
2221 # Set world profile data
2222 if ($self->scriptConvertVersion >= 1_001_021) {
2223  
2224 $client->ivPoke('prevClientVersion', $dataHash{'prev_client_version'});
2225 }
2226 $client->ivPoke('configWorldProfList', @{$dataHash{'world_prof_list'}});
2227 $client->ivPoke('favouriteWorldList', @{$dataHash{'favourite_world_list'}});
2228 if ($self->scriptConvertVersion >= 1_001_396) {
2229  
2230 $client->ivPoke('autoConnectList', @{$dataHash{'auto_connect_list'}});
2231 }
2232  
2233 # Set logging preferences
2234 $client->ivPoke('allowLogsFlag', $dataHash{'allow_logs_flag'});
2235 $client->ivPoke('deleteStandardLogsFlag', $dataHash{'delete_standard_logs_flag'});
2236 $client->ivPoke('deleteWorldLogsFlag', $dataHash{'delete_world_logs_flag'});
2237 $client->ivPoke('logPrefixDateFlag', $dataHash{'log_prefix_date_flag'});
2238 $client->ivPoke('logPrefixTimeFlag', $dataHash{'log_prefix_time_flag'});
2239 $client->ivPoke('logDayFlag', $dataHash{'log_day_flag'});
2240 $client->ivPoke('logClientFlag', $dataHash{'log_client_flag'});
2241 if ($self->scriptConvertVersion >= 1_000_917) {
2242  
2243 $client->ivPoke('logImageFlag', $dataHash{'log_image_flag'});
2244 }
2245 $client->ivPoke('statusEventBeforeCount', $dataHash{'status_before_count'});
2246 $client->ivPoke('statusEventAfterCount', $dataHash{'status_after_count'});
2247 $client->ivPoke('logPrefHash', %{$dataHash{'log_pref_hash'}});
2248 if ($self->scriptConvertVersion >= 1_001_395) {
2249  
2250 $client->ivPoke('logPreambleList', @{$dataHash{'log_preamble_list'}});
2251 }
2252  
2253 # Set colour tags
2254 if ($self->scriptConvertVersion >= 1_000_165) {
2255  
2256 $client->ivPoke('currentColourCube', $dataHash{'current_xterm_cube'});
2257 }
2258 if ($self->scriptConvertVersion >= 1_000_203) {
2259  
2260 $client->ivPoke('oscPaletteFlag', $dataHash{'osc_palette_flag'});
2261 }
2262 $client->ivPoke('colourTagHash', %{$dataHash{'colour_tag_hash'}});
2263 $client->ivPoke('boldColourTagHash', %{$dataHash{'bold_colour_tag_hash'}});
2264  
2265 # Read desktop and display settings
2266 $client->ivPoke('customMainWinWidth', $dataHash{'custom_main_win_width'});
2267 $client->ivPoke('customMainWinHeight', $dataHash{'custom_main_win_height'});
2268 $client->ivPoke('customGridWinWidth', $dataHash{'custom_grid_win_width'});
2269 $client->ivPoke('customGridWinHeight', $dataHash{'custom_grid_win_height'});
2270 if ($self->scriptConvertVersion >= 1_001_162) {
2271  
2272 $client->ivPoke('customFreeWinWidth', $dataHash{'custom_free_win_width'});
2273 $client->ivPoke('customFreeWinHeight', $dataHash{'custom_free_win_height'});
2274 }
2275  
2276 $client->ivPoke('customInsertCmdColour', $dataHash{'custom_insert_cmd_colour'});
2277 $client->ivPoke('customShowSystemTextColour', $dataHash{'custom_show_system_text_colour'});
2278 $client->ivPoke('customShowErrorColour', $dataHash{'custom_show_error_colour'});
2279 $client->ivPoke('customShowWarningColour', $dataHash{'custom_show_warning_colour'});
2280 $client->ivPoke('customShowDebugColour', $dataHash{'custom_show_debug_colour'});
2281 $client->ivPoke('customShowImproperColour', $dataHash{'custom_show_improper_colour'});
2282 if ($self->scriptConvertVersion >= 1_000_079) {
2283  
2284 $client->ivPoke('convertInvisibleFlag', $dataHash{'convert_invisible_flag'});
2285 }
2286 if ($self->scriptConvertVersion >= 1_000_800) {
2287  
2288 $client->ivPoke('customTextBufferSize', $dataHash{'custom_text_buffer_size'});
2289 }
2290 $client->ivPoke('customPanelLeftSize', $dataHash{'custom_panel_left_size'});
2291 $client->ivPoke('customPanelRightSize', $dataHash{'custom_panel_right_size'});
2292 $client->ivPoke('customPanelTopSize', $dataHash{'custom_panel_top_size'});
2293 $client->ivPoke('customPanelBottomSize', $dataHash{'custom_panel_bottom_size'});
2294 $client->ivPoke('customControlsLeftSize', $dataHash{'custom_controls_left_size'});
2295 $client->ivPoke('customControlsRightSize', $dataHash{'custom_controls_right_size'});
2296 $client->ivPoke('customControlsTopSize', $dataHash{'custom_controls_top_size'});
2297 $client->ivPoke('customControlsBottomSize', $dataHash{'custom_controls_bottom_size'});
2298 if ($self->scriptConvertVersion >= 1_000_800) {
2299  
2300 $client->ivPoke('shareMainWinFlag', $dataHash{'share_main_win_flag'});
2301  
2302 if ($self->scriptConvertVersion < 1_001_394) {
2303  
2304 # The IV now uses the values 'default', 'on' and 'off', rather than TRUE and FALSE
2305 # (which didn't work as intended). Just change the value to 'default'
2306 $client->ivPoke('restartShareMainWinMode', 'default');
2307  
2308 } elsif ($self->scriptConvertVersion < 1_002_026) {
2309  
2310 # Due to a bug, the value was set as 1 or 0, rather than 'on' or 'off'
2311 if ($dataHash{'restart_share_main_win_mode'}) {
2312 $client->ivPoke('restartShareMainWinMode', 'on');
2313 } else {
2314 $client->ivPoke('restartShareMainWinMode', 'off');
2315 }
2316  
2317 } else {
2318  
2319 $client->ivPoke(
2320 'restartShareMainWinMode',
2321 $dataHash{'restart_share_main_win_mode'},
2322 );
2323 }
2324  
2325 $client->ivPoke('activateGridFlag', $dataHash{'activate_grid_flag'});
2326 }
2327 if ($self->scriptConvertVersion >= 1_001_164) {
2328  
2329 my (%thisHash, %newHash);
2330  
2331 $client->ivPoke('storeGridPosnFlag', $dataHash{'store_grid_posn_flag'});
2332  
2333 # To make the saving code simpler, 4 values were stored on a line, in the form
2334 # 'x y wid hei'
2335 %thisHash = %{$dataHash{'store_grid_posn_hash'}};
2336  
2337 foreach my $key (keys %thisHash) {
2338  
2339 my $listRef = [ split(/\s+/, $thisHash{$key}) ];
2340  
2341 $newHash{$key} = $listRef;
2342 }
2343  
2344 $client->ivPoke('storeGridPosnHash', %newHash);
2345 }
2346 if ($self->scriptConvertVersion >= 1_000_800) {
2347  
2348 $client->ivPoke('initWorkspaceDir', $dataHash{'init_workspace_dir'});
2349 $client->ivPoke('initWorkspaceHash', %{$dataHash{'init_workspace_hash'}});
2350 }
2351 $client->ivPoke('gridBlockSize', $dataHash{'grid_block_size'});
2352 $client->ivPoke('gridGapMaxSize', $dataHash{'grid_gap_max_size'});
2353 $client->ivPoke('gridAdjustmentFlag', $dataHash{'grid_adjustment_flag'});
2354 $client->ivPoke('gridEdgeCorrectionFlag', $dataHash{'grid_edge_correction_flag'});
2355 $client->ivPoke('gridReshuffleFlag', $dataHash{'grid_reshuffle_flag'});
2356 $client->ivPoke('gridInvisWinFlag', $dataHash{'grid_invis_win_flag'});
2357  
2358 # Instructions
2359 $client->ivPoke('customDisplayBufferSize', $dataHash{'custom_display_buffer_size'});
2360 $client->ivPoke('customCmdBufferSize', $dataHash{'custom_cmd_buffer_size'});
2361 $client->ivPoke('customInstructBufferSize', $dataHash{'custom_instruct_buffer_size'});
2362 $client->ivPoke('confirmWorldCmdFlag', $dataHash{'confirm_world_cmd_flag'});
2363 if ($self->scriptConvertVersion >= 1_000_331) {
2364  
2365 $client->ivPoke('convertWorldCmdFlag', $dataHash{'convert_world_cmd_flag'});
2366 }
2367 $client->ivPoke('preserveWorldCmdFlag', $dataHash{'preserve_world_cmd_flag'});
2368 if ($self->scriptConvertVersion >= 1_000_880) {
2369  
2370 $client->ivPoke('preserveOtherCmdFlag', $dataHash{'preserve_other_cmd_flag'});
2371 $client->ivPoke('maxMultiCmdFlag', $dataHash{'max_multi_cmd_flag'});
2372 }
2373 $client->ivPoke('autoCompleteMode', $dataHash{'auto_complete_mode'});
2374 if ($self->scriptConvertVersion >= 1_000_800) {
2375  
2376 $client->ivPoke('autoCompleteType', $dataHash{'auto_complete_type'});
2377 $client->ivPoke('autoCompleteParent', $dataHash{'auto_complete_parent'});
2378 }
2379  
2380 # Set external applications
2381 $client->ivPoke('browserCmd', $dataHash{'browser_cmd'});
2382 $client->ivPoke('audioCmd', $dataHash{'audio_cmd'});
2383 $client->ivPoke('textEditCmd', $dataHash{'text_edit_cmd'});
2384  
2385 # Set sound effects
2386 $client->ivPoke('allowSoundFlag', $dataHash{'allow_sound_flag'});
2387 if ($self->scriptConvertVersion >= 1_000_087) {
2388  
2389 $client->ivPoke('allowAsciiBellFlag', $dataHash{'allow_ascii_bell_flag'});
2390 }
2391 $client->ivPoke('customSoundHash', %{$dataHash{'custom_sound_hash'}});
2392  
2393 # Set text-to-speech (TTS)
2394 if ($self->scriptConvertVersion >= 1_000_618) {
2395  
2396 $client->ivPoke('customAllowTTSFlag', $dataHash{'allow_tts_flag'});
2397 if ($client->customAllowTTSFlag) {
2398  
2399 $client->ivPoke('systemAllowTTSFlag', TRUE);
2400 }
2401  
2402 $client->ivPoke('ttsSmoothFlag', $dataHash{'tts_smooth_flag'});
2403 if ($self->scriptConvertVersion >= 1_002_073) {
2404  
2405 $client->ivPoke('ttsHijackFlag', $dataHash{'tts_hijack_flag'});
2406 }
2407 if ($self->scriptConvertVersion >= 1_002_213) {
2408  
2409 $client->ivPoke('ttsForceHijackFlag', $dataHash{'tts_force_hijack_flag'});
2410 }
2411 $client->ivPoke('ttsReceiveFlag', $dataHash{'tts_receive_flag'});
2412 $client->ivPoke('ttsLoginFlag', $dataHash{'tts_login_flag'});
2413 if ($self->scriptConvertVersion >= 1_002_212) {
2414  
2415 $client->ivPoke('ttsPromptFlag', $dataHash{'tts_prompt_flag'});
2416 }
2417 $client->ivPoke('ttsSystemFlag', $dataHash{'tts_system_flag'});
2418 $client->ivPoke('ttsSystemErrorFlag', $dataHash{'tts_system_error_flag'});
2419 $client->ivPoke('ttsWorldCmdFlag', $dataHash{'tts_world_cmd_flag'});
2420 $client->ivPoke('ttsDialogueFlag', $dataHash{'tts_dialogue_flag'});
2421 $client->ivPoke('ttsTaskFlag', $dataHash{'tts_task_flag'});
2422 # (Prefer an 'undef' value over an empty string)
2423 if ($dataHash{'tts_festival_server_port'} eq '') {
2424 $client->ivUndef('ttsFestivalServerPort');
2425 } else {
2426 $client->ivPoke('ttsFestivalServerPort', $dataHash{'tts_festival_server_port'});
2427 }
2428 }
2429  
2430 # Set telnet option negotiation flags
2431 if ($self->scriptConvertVersion >= 1_000_156) {
2432  
2433 $client->ivPoke('useEchoFlag', $dataHash{'use_echo_flag'});
2434 $client->ivPoke('useTTypeFlag', $dataHash{'use_ttype_flag'});
2435 }
2436 $client->ivPoke('useNawsFlag', $dataHash{'use_naws_flag'});
2437 if ($self->scriptConvertVersion >= 1_000_156) {
2438  
2439 $client->ivPoke('useCharSetFlag', $dataHash{'use_charset_flag'});
2440 }
2441 if ($self->scriptConvertVersion >= 1_000_163) {
2442  
2443 $client->ivPoke('useEorFlag', $dataHash{'use_eor_flag'});
2444 }
2445 if ($self->scriptConvertVersion >= 1_000_879) {
2446  
2447 $client->ivPoke('useSgaFlag', $dataHash{'use_sga_flag'});
2448 $client->ivPoke('useNewEnvironFlag', $dataHash{'use_new_environ_flag'});
2449 }
2450  
2451 # Set MUD protocol flags
2452 $client->ivPoke('useMccpFlag', $dataHash{'use_mccp_flag'});
2453 if ($self->scriptConvertVersion >= 1_000_156) {
2454  
2455 $client->ivPoke('useMsdpFlag', $dataHash{'use_msdp_flag'});
2456 $client->ivPoke('useMsspFlag', $dataHash{'use_mssp_flag'});
2457 $client->ivPoke('useMttsFlag', $dataHash{'use_mtts_flag'});
2458 }
2459 if ($self->scriptConvertVersion >= 1_002_095) {
2460  
2461 $client->ivPoke('useMnesFlag', $dataHash{'use_mnes_flag'});
2462 }
2463 $client->ivPoke('useMxpFlag', $dataHash{'use_mxp_flag'});
2464 $client->ivPoke('useMspFlag', $dataHash{'use_msp_flag'});
2465 if ($self->scriptConvertVersion >= 1_000_844) {
2466  
2467 $client->ivPoke('usePuebloFlag', $dataHash{'use_pueblo_flag'});
2468 }
2469 if ($self->scriptConvertVersion >= 1_000_850) {
2470  
2471 $client->ivPoke('useAtcpFlag', $dataHash{'use_atcp_flag'});
2472 $client->ivPoke('useGmcpFlag', $dataHash{'use_gmcp_flag'});
2473 }
2474 if ($self->scriptConvertVersion >= 1_000_879) {
2475  
2476 $client->ivPoke('useZmpFlag', $dataHash{'use_zmp_flag'});
2477 $client->ivPoke('useAard102Flag', $dataHash{'use_aard102_flag'});
2478 $client->ivPoke('useMcpFlag', $dataHash{'use_mcp_flag'});
2479 }
2480 if ($self->scriptConvertVersion >= 1_000_832) {
2481  
2482 $client->ivPoke('allowMxpFontFlag', $dataHash{'allow_mxp_font_flag'});
2483 $client->ivPoke('allowMxpImageFlag', $dataHash{'allow_mxp_image_flag'});
2484 $client->ivPoke('allowMxpLoadImageFlag', $dataHash{'allow_mxp_load_image_flag'});
2485 $client->ivPoke('allowMxpFilterImageFlag', $dataHash{'allow_mxp_filter_image_flag'});
2486 $client->ivPoke('allowMxpSoundFlag', $dataHash{'allow_mxp_sound_flag'});
2487 $client->ivPoke('allowMxpLoadSoundFlag', $dataHash{'allow_mxp_load_sound_flag'});
2488 $client->ivPoke('allowMxpGaugeFlag', $dataHash{'allow_mxp_gauge_flag'});
2489 $client->ivPoke('allowMxpFrameFlag', $dataHash{'allow_mxp_frame_flag'});
2490 $client->ivPoke('allowMxpInteriorFlag', $dataHash{'allow_mxp_interior_flag'});
2491 $client->ivPoke('allowMxpCrosslinkFlag', $dataHash{'allow_mxp_crosslink_flag'});
2492 }
2493 if ($self->scriptConvertVersion >= 1_000_887) {
2494  
2495 $client->ivPoke('allowMxpRoomFlag', $dataHash{'allow_mxp_room_flag'});
2496 }
2497 if ($self->scriptConvertVersion >= 1_001_510) {
2498  
2499 $client->ivPoke('allowMxpFlexibleFlag', $dataHash{'allow_mxp_flexible_flag'});
2500 }
2501 if ($self->scriptConvertVersion >= 1_002_020) {
2502  
2503 $client->ivPoke('allowMxpPermFlag', $dataHash{'allow_mxp_perm_flag'});
2504 }
2505 if ($self->scriptConvertVersion >= 1_000_678) {
2506  
2507 $client->ivPoke('allowMspMultipleFlag', $dataHash{'allow_msp_multiple_flag'});
2508 $client->ivPoke('allowMspLoadSoundFlag', $dataHash{'allow_msp_load_sound_flag'});
2509 }
2510 if ($self->scriptConvertVersion >= 1_000_886) {
2511  
2512 $client->ivPoke('allowMspFlexibleFlag', $dataHash{'allow_msp_flexible_flag'});
2513 }
2514 if ($self->scriptConvertVersion >= 1_002_095) {
2515  
2516 $client->ivPoke('allowMnesSendIPFlag', $dataHash{'allow_mnes_send_ip_flag'});
2517 }
2518 # Set telnet option negotiation customisation IVs
2519 if ($self->scriptConvertVersion >= 1_000_160) {
2520  
2521 $client->ivPoke('termTypeMode', $dataHash{'term_type_mode'});
2522 $client->ivPoke('customClientName', $dataHash{'custom_client_name'});
2523 }
2524 if ($self->scriptConvertVersion >= 1_000_666) {
2525  
2526 $client->ivPoke('customClientVersion', $dataHash{'custom_client_version'});
2527 }
2528 if ($self->scriptConvertVersion >= 1_001_213) {
2529  
2530 $client->ivPoke('useCtrlSeqFlag', $dataHash{'use_ctrl_seq_flag'});
2531 $client->ivPoke('useVisibleCursorFlag', $dataHash{'use_visible_cursor_flag'});
2532 $client->ivPoke('useFastCursorFlag', $dataHash{'use_fast_cursor_flag'});
2533 $client->ivPoke('useDirectKeysFlag', $dataHash{'use_direct_keys_flag'});
2534 }
2535 # Set telnet negotiation debug flags
2536 if ($self->scriptConvertVersion >= 1_001_214) {
2537  
2538 $client->ivPoke('debugEscSequenceFlag', $dataHash{'debug_esc_sequence_flag'});
2539 }
2540 if ($self->scriptConvertVersion >= 1_000_378) {
2541  
2542 $client->ivPoke('debugTelnetFlag', $dataHash{'debug_telnet_flag'});
2543 $client->ivPoke('debugTelnetMiniFlag', $dataHash{'debug_telnet_mini_flag'});
2544 }
2545 if ($self->scriptConvertVersion >= 1_000_895) {
2546  
2547 $client->ivPoke('debugTelnetLogFlag', $dataHash{'debug_telnet_log_flag'});
2548 }
2549 if ($self->scriptConvertVersion >= 1_000_378) {
2550  
2551 $client->ivPoke('debugMsdpFlag', $dataHash{'debug_msdp_flag'});
2552 }
2553 if ($self->scriptConvertVersion >= 1_000_405) {
2554  
2555 $client->ivPoke('debugMxpFlag', $dataHash{'debug_mxp_flag'});
2556 $client->ivPoke('debugMxpCommentFlag', $dataHash{'debug_mxp_comment_flag'});
2557 }
2558 if ($self->scriptConvertVersion >= 1_000_849) {
2559  
2560 $client->ivPoke('debugPuebloFlag', $dataHash{'debug_pueblo_flag'});
2561 $client->ivPoke('debugPuebloCommentFlag', $dataHash{'debug_pueblo_comment_flag'});
2562 }
2563 if ($self->scriptConvertVersion >= 1_001_140) {
2564  
2565 $client->ivPoke('debugZmpFlag', $dataHash{'debug_zmp_flag'});
2566 }
2567 if ($self->scriptConvertVersion >= 1_000_926) {
2568  
2569 $client->ivPoke('debugAtcpFlag', $dataHash{'debug_atcp_flag'});
2570 $client->ivPoke('debugGmcpFlag', $dataHash{'debug_gmcp_flag'});
2571 }
2572 if ($self->scriptConvertVersion >= 1_001_158) {
2573  
2574 $client->ivPoke('debugMcpFlag', $dataHash{'debug_mcp_flag'});
2575 }
2576  
2577 # Set misc data
2578 $client->ivPoke('customMonthList', @{$dataHash{'custom_month_list'}});
2579 $client->ivPoke('customDayList', @{$dataHash{'custom_day_list'}});
2580 if ($self->scriptConvertVersion >= 1_001_262) {
2581  
2582 $client->ivPoke('commifyMode', $dataHash{'commify_mode'});
2583 }
2584 if ($self->scriptConvertVersion >= 1_001_284) {
2585  
2586 $client->ivPoke('shortUrlFlag', $dataHash{'short_url_flag'});
2587 }
2588 if ($self->scriptConvertVersion >= 1_002_166) {
2589  
2590 $client->ivPoke('ipLookupList', @{$dataHash{'ip_lookup_list'}});
2591 }
2592 $client->ivPoke('promptWaitTime', $dataHash{'prompt_wait_time'});
2593 $client->ivPoke('loginWarningTime', $dataHash{'login_warning_time'});
2594 if ($self->scriptConvertVersion >= 1_000_331) {
2595  
2596 if ($self->scriptConvertVersion <= 1_000_535) {
2597  
2598 $client->ivPoke('debugLineNumsFlag', $dataHash{'debug_world_flag'});
2599 $client->ivPoke('debugLineTagsFlag', $dataHash{'debug_world_flag'});
2600  
2601 } else {
2602  
2603 $client->ivPoke('debugLineNumsFlag', $dataHash{'debug_line_nums_flag'});
2604 $client->ivPoke('debugLineTagsFlag', $dataHash{'debug_line_tags_flag'});
2605 }
2606 }
2607 $client->ivPoke('debugLocatorFlag', $dataHash{'debug_locator_flag'});
2608 if ($self->scriptConvertVersion >= 1_000_482) {
2609  
2610 $client->ivPoke('debugMaxLocatorFlag', $dataHash{'debug_max_locator_flag'});
2611 }
2612 if ($self->scriptConvertVersion >= 1_001_282) {
2613  
2614 $client->ivPoke('debugExitFlag', $dataHash{'debug_exit_flag'});
2615 }
2616 $client->ivPoke('debugMoveListFlag', $dataHash{'debug_move_list_flag'});
2617 $client->ivPoke('debugParseObjFlag', $dataHash{'debug_parse_obj_flag'});
2618 $client->ivPoke('debugCompareObjFlag', $dataHash{'debug_compare_obj_flag'});
2619 $client->ivPoke('debugExplainPluginFlag', $dataHash{'debug_explain_plugin_flag'});
2620 $client->ivPoke('debugCheckIVFlag', $dataHash{'debug_check_iv_flag'});
2621 if ($self->scriptConvertVersion >= 1_000_800) {
2622  
2623 $client->ivPoke('debugTableFitFlag', $dataHash{'debug_table_fit_flag'});
2624 }
2625 $client->ivPoke('debugTrapErrorFlag', $dataHash{'debug_trap_error_flag'});
2626 if ($self->scriptConvertVersion >= 1_000_949) {
2627  
2628 $client->ivPoke('toolbarLabelFlag', $dataHash{'toolbar_label_flag'});
2629 }
2630 $client->ivPoke('irreversibleIconFlag', $dataHash{'irreversible_icon_flag'});
2631 if ($self->scriptConvertVersion >= 1_001_136) {
2632  
2633 $client->ivPoke('allowBusyWinFlag', $dataHash{'allow_busy_win_flag'});
2634 }
2635 if ($self->scriptConvertVersion >= 1_001_202) {
2636  
2637 $client->ivPoke('mainWinSystemMsgFlag', $dataHash{'main_win_system_msg_flag'});
2638 }
2639 if ($self->scriptConvertVersion >= 1_000_344) {
2640  
2641 $client->ivPoke('mainWinUrgencyFlag', $dataHash{'main_win_urgency_flag'});
2642 }
2643 if ($self->scriptConvertVersion >= 1_000_883) {
2644  
2645 $client->ivPoke('mainWinTooltipFlag', $dataHash{'main_win_tooltip_flag'});
2646 }
2647 $client->ivPoke('sessionTabMode', $dataHash{'session_tab_mode'});
2648 if ($self->scriptConvertVersion >= 1_000_184) {
2649  
2650 $client->ivPoke('xTermTitleFlag', $dataHash{'xterm_title_flag'});
2651 }
2652 if ($self->scriptConvertVersion >= 1_000_365) {
2653  
2654 $client->ivPoke('longTabLabelFlag', $dataHash{'long_tab_label_flag'});
2655 $client->ivPoke('simpleTabFlag', $dataHash{'simple_tab_flag'});
2656 }
2657 if ($self->scriptConvertVersion >= 1_000_917) {
2658  
2659 $client->ivPoke('confirmCloseMainWinFlag', $dataHash{'confirm_close_main_win_flag'});
2660 $client->ivPoke('confirmCloseTabFlag', $dataHash{'confirm_close_tab_flag'});
2661 }
2662 if ($self->scriptConvertVersion >= 1_002_102) {
2663  
2664 $client->ivPoke('confirmCloseMenuFlag', $dataHash{'confirm_close_menu_flag'});
2665 $client->ivPoke(
2666 'confirmCloseToolButtonFlag',
2667 $dataHash{'confirm_close_tool_button_flag'},
2668 );
2669 }
2670 if ($self->scriptConvertVersion >= 1_000_185) {
2671  
2672 $client->ivPoke('charSet', $dataHash{'char_set'});
2673 }
2674 if ($self->scriptConvertVersion >= 1_000_616) {
2675  
2676 $client->ivPoke('sessionMax', $dataHash{'session_max'});
2677 }
2678 if ($self->scriptConvertVersion >= 1_001_256) {
2679  
2680 $client->ivPoke('offlineOnDisconnectFlag', $dataHash{'offline_on_disconnect_flag'});
2681 }
2682 if ($self->scriptConvertVersion >= 1_000_884) {
2683  
2684 $client->ivPoke('connectHistoryFlag', $dataHash{'connect_history_flag'});
2685 }
2686 if ($self->scriptConvertVersion >= 1_000_338) {
2687  
2688 $client->ivPoke('useScrollKeysFlag', $dataHash{'use_scroll_keys_flag'});
2689 }
2690 if ($self->scriptConvertVersion >= 1_000_884) {
2691  
2692 $client->ivPoke('smoothScrollKeysFlag', $dataHash{'smooth_scroll_keys_flag'});
2693 $client->ivPoke('autoSplitKeysFlag', $dataHash{'auto_split_keys_flag'});
2694 }
2695 if ($self->scriptConvertVersion >= 1_000_338) {
2696  
2697 $client->ivPoke('useCompleteKeysFlag', $dataHash{'use_complete_keys_flag'});
2698 $client->ivPoke('useSwitchKeysFlag', $dataHash{'use_switch_keys_flag'});
2699 }
2700  
2701 ######################
2702 # Load complete
2703  
2704 # If the loaded config file was saved by an earlier version of Axmud than the one we're
2705 # using now, the file object's data must be marked as needing to be saved (in case the
2706 # config file uses new IVs)
2707 if ($self->scriptConvertVersion < $axmud::CLIENT->convertVersion($axmud::VERSION)) {
2708  
2709 $self->set_modifyFlag(TRUE, $self->_objClass . '->loadConfigFile');
2710  
2711 } else {
2712  
2713 # Otherwise, mark the file object's data as not needing to be saved
2714 $self->set_modifyFlag(FALSE, $self->_objClass . '->loadConfigFile');
2715 }
2716  
2717 return 1;
2718 }
2719  
2720 sub setupDataFile {
2721  
2722 # Called by GA::Client->loadOtherFiles for the file types:
2723 # 'tasks', 'scripts', 'contacts', 'dicts', 'toolbar', 'usercmds', 'zonemaps', 'winmaps',
2724 # 'tts'
2725 # Loads a data file. If the file doesn't exist, creates it
2726 #
2727 # Expected arguments
2728 # (none besides $self)
2729 #
2730 # Return values
2731 # 'undef' on improper arguments, or if there any errors reading/writing the file, or if
2732 # file loading/saving isn't allowed (because of global flags)
2733 # 1 otherwise
2734  
2735 my ($self, $check) = @_;
2736  
2737 # Local variables
2738 my $obj;
2739  
2740 # Check for improper arguments
2741 if (defined $check) {
2742  
2743 return $axmud::CLIENT->writeImproper($self->_objClass . '->setupDataFile', @_);
2744 }
2745  
2746 # Check it's the right file type for this function
2747 if (
2748 $self->fileType ne 'tasks' && $self->fileType ne 'scripts'
2749 && $self->fileType ne 'contacts' && $self->fileType ne 'dicts'
2750 && $self->fileType ne 'toolbar' && $self->fileType ne 'usercmds'
2751 && $self->fileType ne 'zonemaps' && $self->fileType ne 'winmaps'
2752 && $self->fileType ne 'tts'
2753 ) {
2754 return $self->writeError(
2755 'Wrong file type \'' . $self->fileType . '\'',
2756 $self->_objClass . '->setupDataFile',
2757 );
2758 }
2759  
2760 # Check whether the data file already exists, and if we're allowed to load it
2761 if ($axmud::CLIENT->loadDataFlag && -e $axmud::DATA_DIR . $self->standardPath) {
2762  
2763 # The file exists and we are allowed to load it, so try to load it (in overwrite mode)
2764 if (! $self->loadDataFile()) {
2765  
2766 # Try loading the automatic backup, i.e. 'otherprof.axm.bu'
2767 if (! $self->loadDataFile(undef, undef, undef, TRUE)) {
2768  
2769 return $self->writeError(
2770 'Error reading \'' . $self->fileType . '\' data file',
2771 $self->_objClass . '->setupDataFile',
2772 );
2773  
2774 } else {
2775  
2776 # The contents of the backup, now loaded into memory, must be saved at some
2777 # point
2778 $self->ivPoke('modifyFlag', TRUE);
2779 # Don't overwrite the existing backup file with the faulty one
2780 $self->ivPoke('preserveBackupFlag', TRUE);
2781  
2782 # File loaded (from backup)
2783 return 1;
2784 }
2785  
2786 } else {
2787  
2788 # File loaded
2789 return 1;
2790 }
2791  
2792 } elsif ($axmud::CLIENT->saveDataFlag && ! (-e $axmud::DATA_DIR . $self->standardPath)) {
2793  
2794 # The file doesn't exist, but we are allowed to create it
2795 if (! $self->saveDataFile()) {
2796  
2797 return $self->writeError(
2798 'Error creating \'' . $self->fileType . '\' data file',
2799 $self->_objClass . '->setupDataFile',
2800 );
2801  
2802 } else {
2803  
2804 # File created
2805 return 1;
2806 }
2807  
2808 } else {
2809  
2810 # Cannot load or save the data file
2811 return undef;
2812 }
2813 }
2814  
2815 sub saveDataFile {
2816  
2817 # Called by $self->setupDataFile (or by any other function) for the file types:
2818 # 'tasks', 'scripts', 'contacts', 'dicts', 'toolbar', 'usercmds', 'zonemaps', 'winmaps',
2819 # 'tts'
2820 # Called by any function for the file types:
2821 # 'worldprof', 'otherprof', 'worldmodel'
2822 #
2823 # Saves a data file of the type specified by $self->fileType
2824 #
2825 # Expected arguments
2826 # (none besides $self)
2827 #
2828 # Optional arguments
2829 # $fileName - The file name, e.g. 'tasks.axm'
2830 # $path - The full path, e.g. '/home/me/axmud-data/data/tasks.axm'
2831 # $dir - The directory, e.g. '/home/me/axmud-data/data/'
2832 # $emergFlag - If set to TRUE, an emergency save is in progress.
2833 # GA::Client->saveDataFlag is ignored, $self->disableAllFileAccess is not
2834 # called on failure, and $self->modifyFlag is not set. Set to FALSE (or
2835 # 'undef') if an emergency save is not in progress
2836 #
2837 # Notes:
2838 # If $fileName is specified, $path and $dir must also be specified
2839 # If $fileName is not specified, the default filename, path and directory for this file
2840 # type are used
2841 #
2842 # Return values
2843 # 'undef' on improper arguments, if saving of data files isn't allowed (because of global
2844 # flags) or if there is an error saving the data file itself
2845 # 1 otherwise
2846  
2847 my ($self, $fileName, $path, $dir, $emergFlag, $check) = @_;
2848  
2849 # Local variables
2850 my (
2851 $checkWorldObj, $count, $buPath,
2852 %saveHash, %preserveHash, %reverseHash, %importHash, %usrCmdHash,
2853 );
2854  
2855 # Check for improper arguments
2856 if (
2857 defined $check
2858 || (defined $fileName && (! defined $path || ! defined $dir))
2859 || (defined $path && (! defined $fileName || ! defined $dir))
2860 || (defined $dir && (! defined $fileName || ! defined $path))
2861 ) {
2862 return $axmud::CLIENT->writeImproper($self->_objClass . '->saveDataFile', @_);
2863 }
2864  
2865 # Check it's the right file type for this function
2866 if ($self->fileType eq 'config') {
2867  
2868 return $self->writeError(
2869 'Wrong file type \'' . $self->fileType . '\'',
2870 $self->_objClass . '->saveDataFile',
2871 );
2872 }
2873  
2874 # Set the filename, path and directory, if not specified
2875 if (! defined $fileName) {
2876  
2877 $fileName = $self->standardFileName;
2878 $path = $axmud::DATA_DIR . $self->standardPath;
2879 $dir = $axmud::DATA_DIR . $self->standardDir;
2880 }
2881  
2882 # Checks made when an emergency save is NOT in progress...
2883 if (! $emergFlag) {
2884  
2885 # Don't save anything if the global flag forbids it
2886 if (! $axmud::CLIENT->saveDataFlag) {
2887  
2888 return undef;
2889 }
2890  
2891 # Don't save 'worldprof', 'otherprof' and 'worldmodel' files associated with a world
2892 # profile whose ->noSaveFlag is set
2893 if (
2894 $self->fileType eq 'worldprof' || $self->fileType eq 'otherprof'
2895 || $self->fileType eq 'worldmodel'
2896 ) {
2897 $checkWorldObj = $axmud::CLIENT->ivShow('worldProfHash', $self->assocWorldProf);
2898  
2899 # (During a ';cloneworld' operation, the cloned world profile won't have been added
2900 # to ->worldProfHash; but ;cloneworld can't be used on (original) profiles whose
2901 # ->noSaveFlag is set, so if $checkWorldObj is 'undef', we don't need to check its
2902 # ->noSaveFlag)
2903 if ($checkWorldObj && $checkWorldObj->noSaveFlag) {
2904  
2905 return undef;
2906 }
2907 }
2908 }
2909  
2910 # Check that the data directory exists and, if it doesn't, try to create it
2911 if (! (-d $dir)) {
2912  
2913 if (! mkdir ($dir, 0755)) {
2914  
2915 return undef;
2916 }
2917 }
2918  
2919 # For the file type 'worldmodel', we might use a single monolithic file or, if the model is
2920 # large, multiple smaller ones. A single monolithic file is handled by this function;
2921 # multiple files are handled by a call to $self->saveDataFile_worldModel
2922 if ($self->fileType eq 'worldmodel') {
2923  
2924 if (
2925 ! $emergFlag
2926 && $axmud::CLIENT->allowModelSplitFlag
2927 && $self->session->worldModelObj->ivPairs('modelHash')
2928 > $axmud::CLIENT->modelSplitSize
2929 ) {
2930 return $self->saveDataFile_worldModel($fileName, $path, $dir);
2931 } else {
2932 $self->session->worldModelObj->ivPoke('modelSaveFileCount', 0);
2933 }
2934 }
2935  
2936 # Otherwise, compile a special hash, %saveHash, that references all the data we want to save
2937  
2938 # First compile the header information (i.e. metadata)...
2939 $saveHash{'file_type'} = $self->fileType;
2940 $saveHash{'script_name'} = $axmud::NAME_FILE;
2941 $saveHash{'script_version'} = $axmud::VERSION;
2942 $saveHash{'save_date'} = $axmud::CLIENT->localDate();
2943 $saveHash{'save_time'} = $axmud::CLIENT->localTime();
2944 $saveHash{'assoc_world_prof'} = $self->assocWorldProf;
2945  
2946 # ...then compile the data for this file type
2947 if ($self->fileType eq 'worldprof') {
2948  
2949 $saveHash{'world_prof'}
2950 = $axmud::CLIENT->ivShow('worldProfHash', $self->assocWorldProf);
2951  
2952 } elsif ($self->fileType eq 'otherprof') {
2953  
2954 my %profHash;
2955  
2956 # From GA::Session->profHash, remove the current world profile, leaving all non-world
2957 # profiles
2958 foreach my $profObj ($self->session->ivValues('profHash')) {
2959  
2960 if ($profObj->category ne 'world') {
2961  
2962 $profHash{$profObj->name} = $self->session->ivShow('profHash', $profObj->name);
2963 }
2964 }
2965  
2966 $saveHash{'prof_priority_list'} = [$self->session->profPriorityList];
2967 $saveHash{'template_hash'} = {$self->session->templateHash};
2968 $saveHash{'prof_hash'} = \%profHash;
2969 $saveHash{'cage_hash'} = {$self->session->cageHash};
2970  
2971 } elsif ($self->fileType eq 'worldmodel') {
2972  
2973 $saveHash{'world_model_obj'} = $self->session->worldModelObj;
2974  
2975 } elsif ($self->fileType eq 'tasks') {
2976  
2977 $saveHash{'task_label_hash'} = {$axmud::CLIENT->taskLabelHash};
2978 $saveHash{'task_run_first_list'} = [$axmud::CLIENT->taskRunFirstList];
2979 $saveHash{'task_run_last_list'} = [$axmud::CLIENT->taskRunLastList];
2980 $saveHash{'init_task_hash'} = {$axmud::CLIENT->initTaskHash};
2981 $saveHash{'init_task_order_list'} = [$axmud::CLIENT->initTaskOrderList];
2982 $saveHash{'init_task_total'} = $axmud::CLIENT->initTaskTotal;
2983 $saveHash{'custom_task_hash'} = {$axmud::CLIENT->customTaskHash};
2984  
2985 } elsif ($self->fileType eq 'scripts') {
2986  
2987 $saveHash{'script_dir_list'} = [$axmud::CLIENT->scriptDirList];
2988 $saveHash{'init_script_hash'} = {$axmud::CLIENT->initScriptHash};
2989 $saveHash{'init_script_order_list'} = [$axmud::CLIENT->initScriptOrderList];
2990  
2991 } elsif ($self->fileType eq 'contacts') {
2992  
2993 $saveHash{'chat_name'} = $axmud::CLIENT->chatName;
2994 $saveHash{'chat_email'} = $axmud::CLIENT->chatEmail;
2995 $saveHash{'chat_accept_mode'} = $axmud::CLIENT->chatAcceptMode;
2996 $saveHash{'chat_contact_hash'} = {$axmud::CLIENT->chatContactHash};
2997 $saveHash{'chat_icon'} = $axmud::CLIENT->chatIcon;
2998 $saveHash{'chat_smiley_hash'} = {$axmud::CLIENT->chatSmileyHash};
2999  
3000 } elsif ($self->fileType eq 'dicts') {
3001  
3002 $saveHash{'dict_hash'} = {$axmud::CLIENT->dictHash};
3003  
3004 } elsif ($self->fileType eq 'toolbar') {
3005  
3006 $saveHash{'toolbar_hash'} = {$axmud::CLIENT->toolbarHash};
3007 $saveHash{'toolbar_list'} = [$axmud::CLIENT->toolbarList];
3008  
3009 } elsif ($self->fileType eq 'usercmds') {
3010  
3011 # We don't store user commands for client commands supplied by plugins. If we do, the
3012 # user will get a lot of nasty errors when they try to use Axmud without loading those
3013 # plugins
3014 # However, we do still store all user commands that the user has created for standard
3015 # client commands like ';help' and ';about'
3016 %reverseHash = $axmud::CLIENT->constUserCmdHash;
3017 %importHash = $axmud::CLIENT->userCmdHash;
3018 foreach my $userCmd (keys %importHash) {
3019  
3020 my $standardCmd = $importHash{$userCmd};
3021  
3022 if (exists $reverseHash{$standardCmd}) {
3023  
3024 $usrCmdHash{$userCmd} = $standardCmd;
3025 }
3026 }
3027  
3028 $saveHash{'user_cmd_hash'} = \%usrCmdHash;
3029  
3030 } elsif ($self->fileType eq 'zonemaps') {
3031  
3032 my %zonemapHash;
3033  
3034 # (Temporary zonemaps can't be saved, so we must remove them before saving)
3035 foreach my $zonemapObj ($axmud::CLIENT->ivValues('zonemapHash')) {
3036  
3037 if (! $zonemapObj->tempFlag) {
3038  
3039 $zonemapHash{$zonemapObj->name} = $zonemapObj;
3040 }
3041 }
3042  
3043 $saveHash{'zonemap_hash'} = \%zonemapHash;
3044  
3045 # Standard zonemaps can't be temporary, so we can save that IV directly...
3046 $saveHash{'standard_zonemap_hash'} = {$axmud::CLIENT->standardZonemapHash};
3047  
3048 } elsif ($self->fileType eq 'winmaps') {
3049  
3050 $saveHash{'winmap_hash'} = {$axmud::CLIENT->winmapHash};
3051 $saveHash{'standard_winmap_hash'} = {$axmud::CLIENT->standardWinmapHash};
3052 $saveHash{'default_enabled_winmap'} = $axmud::CLIENT->defaultEnabledWinmap;
3053 $saveHash{'default_disabled_winmap'} = $axmud::CLIENT->defaultDisabledWinmap;
3054 $saveHash{'default_internal_winmap'} = $axmud::CLIENT->defaultInternalWinmap;
3055 $saveHash{'colour_scheme_hash'} = {$axmud::CLIENT->colourSchemeHash};
3056  
3057 } elsif ($self->fileType eq 'tts') {
3058  
3059 $saveHash{'tts_obj_hash'} = {$axmud::CLIENT->ttsObjHash};
3060 }
3061  
3062 # Glob test mode: In earlier Axmud versions, saving of data files failed (and Axmud crashed)
3063 # because of infinite recursions with two Perl objects referencing each other. If TRUE,
3064 # every save file operation (not including the config file) tests data for this problem,
3065 # before saving it, writing the output to the terminal
3066 if ($axmud::TEST_GLOB_MODE_FLAG && ! $self->globTest(%saveHash)) {
3067  
3068 return undef;
3069 }
3070  
3071 # Precautions taken when an emergency save is NOT in progress...
3072 if (! $emergFlag) {
3073  
3074 if ($self->preserveBackupFlag) {
3075  
3076 # The file itself was missing/corrupted, so data was loaded from the backup file
3077 # Don't replace the (good) backup file; just replace the (faulty) file itself
3078 # NB For the config file, nothing in the Axmud code sets this flag to TRUE. Still,
3079 # the code exists, for any future version that needs it
3080 $self->ivPoke('preserveBackupFlag', FALSE);
3081  
3082 } elsif (-e $path) {
3083  
3084 # If the call to ->lock_nstore fails, an existing file called $path will be
3085 # destroyed or corrupted (this could be disastrous, especially if it contains a
3086 # world profile, or something)
3087 # Create a backup of the file, if the file already exists, using File::Copy
3088 $buPath = $path . '.bu';
3089 File::Copy::copy($path, $buPath);
3090 }
3091  
3092 # Save the special hash as a single object
3093 eval { Storable::lock_nstore(\%saveHash, $path) };
3094 if ($@) {
3095  
3096 if ($buPath) {
3097  
3098 # Restore the backup file
3099 File::Copy::copy($buPath, $path);
3100 # Delete the backup file, unless the user has opted to retain them
3101 if (! $axmud::CLIENT->autoRetainFileFlag) {
3102  
3103 unlink ($buPath);
3104 }
3105 }
3106  
3107 # Disable loading/saving in all sessions
3108 $axmud::CLIENT->disableAllFileAccess();
3109  
3110 if ($buPath) {
3111  
3112 return $self->writeError(
3113 'Save data failure: \'' . $path . '\' (existing file restored from backup,'
3114 . ' file loading/saving disabled)',
3115 $self->_objClass . '->saveDataFile',
3116 );
3117  
3118 } else {
3119  
3120 return $self->writeError(
3121 'Save data failure: \'' . $path . '\' (file loading/saving disabled)',
3122 $self->_objClass . '->saveDataFile',
3123 );
3124 }
3125  
3126 } else {
3127  
3128 # Save operation successful
3129 if ($buPath) {
3130  
3131 # Delete the backup file, unless the user has opted to retain them
3132 if (! $axmud::CLIENT->autoRetainFileFlag) {
3133  
3134 unlink ($buPath);
3135 }
3136 }
3137  
3138 # Set this file object's metadata variables
3139 $self->ivPoke('scriptName', $saveHash{'script_name'});
3140 $self->ivPoke('scriptVersion', $saveHash{'script_version'});
3141 $self->ivPoke(
3142 'scriptConvertVersion',
3143 $axmud::CLIENT->convertVersion($saveHash{'script_version'}),
3144 );
3145 $self->ivPoke('saveDate', $saveHash{'save_date'});
3146 $self->ivPoke('saveTime', $saveHash{'save_time'});
3147 $self->ivPoke('assocWorldProf', $saveHash{'assoc_world_prof'});
3148  
3149 $self->ivPoke('actualFileName', $fileName);
3150 $self->ivPoke('actualPath', $path);
3151 $self->ivPoke('actualDir', $dir);
3152  
3153 # Mark the file object's data as not modified
3154 $self->set_modifyFlag(FALSE, $self->_objClass . '->saveDataFile');
3155  
3156 return 1;
3157 }
3158  
3159 # (No precautions taken when an emergency save IS in progress)
3160 } else {
3161  
3162 # Save the special hash as a single object
3163 eval { Storable::lock_nstore(\%saveHash, $path) };
3164 if ($@) {
3165  
3166 return undef;
3167  
3168 } else {
3169  
3170 # (Don't update the file object's metadata variables for an emergency save)
3171 return 1;
3172 }
3173 }
3174 }
3175  
3176 sub saveDataFile_worldModel {
3177  
3178 # Called by $self->saveDataFile
3179 # For the file type 'worldmodel', we might use a single monolithic file or, if the model is
3180 # large, multiple smaller ones. A single monolithic file is handled by
3181 # $self->saveDataFile; multiple files are handled by a call to this function
3182 #
3183 # Expected arguments
3184 # $fileName - The file name, i.e. 'worldmodel.axm'
3185 # $path - The full path, i.e. '/home/me/axmud-data/data/worldmodel.axm'
3186 # $dir - The directory, i.e. '/home/me/axmud-data/data/'
3187 #
3188 # Return values
3189 # 'undef' on improper arguments or if there is an error saving the data file(s) themselves
3190 # 1 otherwise
3191  
3192 my ($self, $fileName, $path, $dir, $check) = @_;
3193  
3194 # Local variables
3195 my (
3196 $tempDir, $count, $mainSavePath, $dirHandle,
3197 @ivList, @objList,
3198 %standardHash, %storeHash, %mainSaveHash,
3199 );
3200  
3201 # Check for improper arguments
3202 if (! defined $fileName || ! defined $path || ! defined $dir || defined $check) {
3203  
3204 return $axmud::CLIENT->writeImproper(
3205 $self->_objClass . '->saveDataFile_worldModel',
3206 @_,
3207 );
3208 }
3209  
3210 # When using multiple files, we use a 'main' file and multiple 'mini' files. The 'mini'
3211 # files each contain a limited number of model objects (regions, rooms, weapons etc) and
3212 # exit model objects. The 'main' file contains everything else
3213  
3214 # Because we're dealing with multiple files, rather than a single one, the way this function
3215 # handles backup files is different. We'll create a temporary directory, save our files
3216 # there and, if there are no problems, we'll then move the files into their proper
3217 # directory
3218 # There's a (small) possibility that two sessions might saving their world model at the same
3219 # time, in which case, this save operation fails
3220 $tempDir = $dir . '/temp/';
3221 if (-d $tempDir || ! mkdir ($tempDir, 0755)) {
3222  
3223 return undef;
3224 }
3225  
3226 # Prepare a standard header, used by all of these files
3227 $standardHash{'file_type'} = $self->fileType;
3228 $standardHash{'script_name'} = $axmud::NAME_FILE;
3229 $standardHash{'script_version'} = $axmud::VERSION;
3230 $standardHash{'save_date'} = $axmud::CLIENT->localDate();
3231 $standardHash{'save_time'} = $axmud::CLIENT->localTime();
3232 $standardHash{'assoc_world_prof'} = $self->assocWorldProf;
3233  
3234 # Empty all world model IVs which store model objects and exit model objects, storing them
3235 # in a temporary hash. Everything left in GA::Obj::WorldModel is stored in the 'main' file
3236 @ivList = qw (
3237 modelHash
3238 regionModelHash roomModelHash weaponModelHash armourModelHash garmentModelHash
3239 charModelHash minionModelHash sentientModelHash creatureModelHash portableModelHash
3240 decorationModelHash customModelHash
3241 exitModelHash
3242 );
3243  
3244 foreach my $iv (@ivList) {
3245  
3246 $storeHash{$iv} = $self->session->worldModelObj->{$iv};
3247 $self->session->worldModelObj->{$iv} = {};
3248 }
3249  
3250 # Save the 'mini' files. Keep track of how many 'mini' files we've saved
3251 $count = 0;
3252  
3253 # Move the contents of the model, and the contents of the exit model, into flat lists so
3254 # we can chop away at them, GA::Client->modelSplitSize objects at a time
3255 @objList = %{$storeHash{'modelHash'}};
3256 do {
3257  
3258 my (
3259 $thisSavePath,
3260 %thiSaveHash,
3261 );
3262  
3263 # Set the path for this mini world model file
3264 $count++;
3265 $thisSavePath = $tempDir . '/worldmodel_' . $count . '.axm';
3266  
3267 # All the 'mini' files have the same header
3268 %thiSaveHash = %standardHash;
3269  
3270 # @objList is a list in groups of 2, in the form (model_number, model_object...).
3271 # Use the first $axmud::CLIENT->modelSplitSize objects
3272 $thiSaveHash{'model_hash'}
3273 = { splice(@objList, 0, ($axmud::CLIENT->modelSplitSize * 2)) };
3274  
3275 # Glob test mode: In earlier Axmud versions, saving of data files failed (and Axmud
3276 # crashed) because of infinite recursions with two Perl objects referencing each
3277 # other. If TRUE, every save file operation (not including the config file) tests data
3278 # for this problem, before saving it, writing the output to the terminal
3279 if ($axmud::TEST_GLOB_MODE_FLAG && ! $self->globTest(%thiSaveHash)) {
3280  
3281 # (Delete the temporary directory before giving up)
3282 File::Path::remove_tree($tempDir);
3283  
3284 return undef;
3285 }
3286  
3287 # Save the 'mini' file
3288 eval { Storable::lock_nstore(\%thiSaveHash, $thisSavePath) };
3289 if ($@) {
3290  
3291 # Disable loading/saving in all sessions
3292 $axmud::CLIENT->disableAllFileAccess();
3293  
3294 # Delete the temporary directory before giving up
3295 File::Path::remove_tree($tempDir);
3296  
3297 return $self->writeError(
3298 'Save data failure: \'' . $dir . '/worldmodel_' . $count . '.axm\' (existing'
3299 . ' world model files are not affected, file loading/saving disabled)',
3300 $self->_objClass . '->saveDataFile_worldModel',
3301 );
3302 }
3303  
3304 } until (! @objList);
3305  
3306 @objList = %{$storeHash{'exitModelHash'}};
3307 do {
3308  
3309 my (
3310 $thisSavePath,
3311 %thiSaveHash,
3312 );
3313  
3314 # Set the path for this mini world model file
3315 $count++;
3316 $thisSavePath = $tempDir . '/worldmodel_' . $count . '.axm';
3317  
3318 # All the 'mini' files have the same header
3319 %thiSaveHash = %standardHash;
3320  
3321 # @objList is a list in groups of 2, in the form (model_number, model_object...).
3322 # Use the first $axmud::CLIENT->modelSplitSize objects
3323 $thiSaveHash{'exit_model_hash'}
3324 = { splice(@objList, 0, ($axmud::CLIENT->modelSplitSize * 2)) };
3325  
3326 # Glob check, if required
3327 if ($axmud::TEST_GLOB_MODE_FLAG && ! $self->globTest(%thiSaveHash)) {
3328  
3329 # (Delete the temporary directory before giving up)
3330 File::Path::remove_tree($tempDir);
3331  
3332 return undef;
3333 }
3334  
3335 # Save the 'mini' file
3336 eval { Storable::lock_nstore(\%thiSaveHash, $thisSavePath) };
3337 if ($@) {
3338  
3339 # Disable loading/saving in all sessions
3340 $axmud::CLIENT->disableAllFileAccess();
3341  
3342 # Delete the temporary directory before giving up
3343 File::Path::remove_tree($tempDir);
3344  
3345 return $self->writeError(
3346 'Save data failure: \'' . $dir . '/worldmodel_' . $count . '.axm\' (existing'
3347 . ' world model files are not affected, file loading/saving disabled)',
3348 $self->_objClass . '->saveDataFile_worldModel',
3349 );
3350 }
3351  
3352 } until (! @objList);
3353  
3354 # Update the world model with the number of mini files it needs, the next time it's loaded
3355 $self->session->worldModelObj->ivPoke('modelSaveFileCount', $count);
3356  
3357 # Prepare the 'main' file
3358 %mainSaveHash = %standardHash;
3359 $mainSaveHash{'world_model_obj'} = $self->session->worldModelObj;
3360  
3361 # Glob check, if required
3362 if ($axmud::TEST_GLOB_MODE_FLAG && ! $self->globTest(%mainSaveHash)) {
3363  
3364 # (Delete the temporary directory before giving up)
3365 File::Path::remove_tree($tempDir);
3366  
3367 return undef;
3368 }
3369  
3370 # Save the 'main' file
3371 $mainSavePath = $tempDir . 'worldmodel.axm';
3372 eval { Storable::lock_nstore(\%mainSaveHash, $mainSavePath) };
3373 if ($@) {
3374  
3375 # Disable loading/saving in all sessions
3376 $axmud::CLIENT->disableAllFileAccess();
3377  
3378 # Delete the temporary directory before giving up
3379 File::Path::remove_tree($tempDir);
3380  
3381 return $self->writeError(
3382 'Save data failure: \'' . $path . '\' (existing world model files are not affected,'
3383 . ' file loading/saving disabled)',
3384 $self->_objClass . '->saveDataFile_worldModel',
3385 );
3386 }
3387  
3388 # Save operations successful. Before doing anything else, restore GA::Obj::WorldModel's
3389 # IVs
3390 foreach my $iv (@ivList) {
3391  
3392 $self->session->worldModelObj->{$iv} = $storeHash{$iv};
3393 delete $storeHash{$iv};
3394 }
3395  
3396 # We can now deal with the pre-existing data files in $dir
3397 if ($self->preserveBackupFlag) {
3398  
3399 # The files themselves were missing/corrupted, so data was loaded from the backup files
3400 # Don't replace the (good) backup files; just remove the (faulty) files themselves
3401 $self->ivPoke('preserveBackupFlag', FALSE);
3402  
3403 if (opendir($dirHandle, $dir)) {
3404  
3405 my @fileList = readdir($dirHandle);
3406 closedir $dirHandle;
3407  
3408 foreach my $file (@fileList) {
3409  
3410 if (
3411 $file =~ m/worldmodel\.axm$/
3412 || $file =~ m/worldmodel_\d+\.axm$/
3413 ) {
3414 unlink $dir . '/' . $file;
3415 }
3416 }
3417 }
3418  
3419 } else {
3420  
3421 # Remove the existing backup files...
3422 if (opendir($dirHandle, $dir)) {
3423  
3424 my @fileList = readdir($dirHandle);
3425 closedir $dirHandle;
3426  
3427 foreach my $file (@fileList) {
3428  
3429 if (
3430 $file =~ m/worldmodel\.axm\.bu$/
3431 || $file =~ m/worldmodel_\d+\.axm\.bu$/
3432 ) {
3433 unlink $dir . '/' . $file;
3434 }
3435 }
3436 }
3437  
3438 # ...and replace them with the pre-existing data files
3439 if (opendir($dirHandle, $dir)) {
3440  
3441 my @fileList = readdir($dirHandle);
3442 closedir $dirHandle;
3443  
3444 foreach my $file (@fileList) {
3445  
3446 if (
3447 $file =~ m/worldmodel\.axm$/
3448 || $file =~ m/worldmodel_\d+\.axm$/
3449 ) {
3450 File::Copy::move($dir . '/' . $file, $dir . '/' . $file . '.bu');
3451 }
3452 }
3453 }
3454 }
3455  
3456 # Move everything from the temporary directory into the proper directory...
3457 if (opendir($dirHandle, $tempDir)) {
3458  
3459 my @fileList = readdir($dirHandle);
3460 closedir $dirHandle;
3461  
3462 foreach my $file (@fileList) {
3463  
3464 File::Copy::move($tempDir . $file, $dir . '/' . $file);
3465 }
3466 }
3467  
3468 # ...and delete the temporary directory
3469 File::Path::remove_tree($tempDir);
3470  
3471 # Finally, set this file object's metadata variables
3472 $self->ivPoke('scriptName', $mainSaveHash{'script_name'});
3473 $self->ivPoke('scriptVersion', $mainSaveHash{'script_version'});
3474 $self->ivPoke(
3475 'scriptConvertVersion',
3476 $axmud::CLIENT->convertVersion($mainSaveHash{'script_version'}),
3477 );
3478 $self->ivPoke('saveDate', $mainSaveHash{'save_date'});
3479 $self->ivPoke('saveTime', $mainSaveHash{'save_time'});
3480 $self->ivPoke('assocWorldProf', $mainSaveHash{'assoc_world_prof'});
3481  
3482 $self->ivPoke('actualFileName', $fileName);
3483 $self->ivPoke('actualPath', $path);
3484 $self->ivPoke('actualDir', $dir);
3485  
3486 # Mark the file object's data as not modified
3487 $self->set_modifyFlag(FALSE, $self->_objClass . '->saveDataFile');
3488  
3489 return 1;
3490 }
3491  
3492 sub loadDataFile {
3493  
3494 # Called by $self->setupDataFile (or by any other function) for the file types:
3495 # 'tasks', 'scripts', 'contacts', 'dicts', 'toolbar', 'usercmds', 'zonemaps', 'winmaps',
3496 # 'tts'
3497 # Called by any function for the file types:
3498 # 'worldprof'
3499 # Called by any function for the file types:
3500 # 'otherprof', 'worldmodel'
3501 #
3502 # Loads a data file of the type specified by $self->fileType, replacing data in memory
3503 #
3504 # Expected arguments
3505 # (none besides $self)
3506 #
3507 # Optional arguments
3508 # $fileName - The file name, e.g. 'tasks.axm'
3509 # $path - The full path, e.g. '/home/me/axmud-data/data/tasks.axm'
3510 # $dir - The directory, e.g. '/home/me/axmud-data/data/'
3511 # $backupFlag - If TRUE, the function will try to load the automatic backup of the file
3512 # (e.g. 'tasks.axm.bu'). If FALSE (or 'undef'), the function loads the
3513 # normal copy of the file (e.g. 'tasks.axm')
3514 #
3515 # Notes:
3516 # If one optional argument is specified, they must all be specified
3517 # If no optional arguments are specified (or are all set to 'undef'), the default
3518 # filename, path and directory for this file type are used
3519 #
3520 # Return values
3521 # 'undef' on improper arguments, if loading of data files isn't allowed (because of global
3522 # flags) or if there is an error loading the data file itself
3523 # 1 otherwise
3524  
3525 my ($self, $fileName, $path, $dir, $backupFlag, $check) = @_;
3526  
3527 # Local variables
3528 my (
3529 $matchFlag, $fileType, $scriptName, $scriptVersion, $saveDate, $saveTime,
3530 $assocWorldProf, $hashRef, $notCompatFlag,
3531 %loadHash,
3532 );
3533  
3534 # Check for improper arguments
3535 if (
3536 defined $check
3537 || (defined $fileName && (! defined $path || ! defined $dir))
3538 || (defined $path && (! defined $fileName || ! defined $dir))
3539 || (defined $dir && (! defined $fileName || ! defined $path))
3540 ) {
3541 return $axmud::CLIENT->writeImproper($self->_objClass . '->loadDataFile', @_);
3542 }
3543  
3544 # Check it's the right file type for this function
3545 if ($self->fileType eq 'config') {
3546  
3547 return $self->writeError(
3548 'Wrong file type \'' . $self->fileType . '\'',
3549 $self->_objClass . '->loadDataFile',
3550 );
3551 }
3552  
3553 # Set the filename, path and directory, if not specified
3554 if (! defined $fileName) {
3555  
3556 $fileName = $self->standardFileName;
3557 $path = $axmud::DATA_DIR . $self->standardPath;
3558 $dir = $axmud::DATA_DIR . $self->standardDir;
3559 }
3560  
3561 # Load the automatic backup of the file, if required
3562 if ($backupFlag) {
3563  
3564 $fileName .= '.bu';
3565 $path .= '.bu';
3566 }
3567  
3568 # Don't load anything if the global flag forbids it
3569 if (! $axmud::CLIENT->loadDataFlag) {
3570  
3571 return undef;
3572 }
3573  
3574 # Check that the data directory exists
3575 if (! (-d $dir)) {
3576  
3577 return undef;
3578 }
3579  
3580 # Check that the specified file exists
3581 if (! (-e $path)) {
3582  
3583 # Before v1.0.868, Axmud used different file extensions; check them all
3584 OUTER: foreach my $ext (@axmud::COMPAT_EXT_LIST) {
3585  
3586 my $altPath = $path;
3587 $altPath =~ s/\.axm/.$ext/;
3588  
3589 if (-e $altPath) {
3590  
3591 $matchFlag = TRUE;
3592 $path = $altPath;
3593 last OUTER;
3594 }
3595 }
3596  
3597 if (! $matchFlag) {
3598  
3599 return undef;
3600 }
3601 }
3602  
3603 # Load all the data into a hash
3604 eval { $hashRef = Storable::lock_retrieve($path); };
3605 if (! $hashRef) {
3606  
3607 # ->lock_retrieve() failed
3608 return undef;
3609  
3610 } else {
3611  
3612 # Convert the hash referenced by $hashRef into a named hash
3613 %loadHash = %{$hashRef};
3614  
3615 # Before v1.0.868, Axmud had a different name. Update all header data
3616 if (
3617 defined $loadHash{'script_version'}
3618 && $axmud::CLIENT->convertVersion($loadHash{'script_version'}) < 1_000_868
3619 ) {
3620 %loadHash = $self->updateHeaderAfterRename(%loadHash);
3621 }
3622  
3623 # Extract the header information (i.e. metadata) from the hash
3624 $fileType = $loadHash{'file_type'};
3625 $scriptName = $loadHash{'script_name'};
3626 $scriptVersion = $loadHash{'script_version'};
3627 $saveDate = $loadHash{'save_date'};
3628 $saveTime = $loadHash{'save_time'};
3629 $assocWorldProf = $loadHash{'assoc_world_prof'};
3630  
3631 # Do checks on the header information
3632 if (! defined $fileType || $fileType ne $self->fileType) {
3633  
3634 # Wrong kind of file
3635 return undef;
3636  
3637 } elsif (
3638 ! defined $scriptName || ! defined $scriptVersion || ! defined $saveDate
3639 || ! defined $saveTime
3640 ) {
3641 # Missing or possibly corrupted header (NB $assocWorldProf can be 'undef')
3642 return undef;
3643  
3644 } elsif (
3645 ! $self->checkCompatibility($scriptName)
3646 || $axmud::CLIENT->convertVersion($scriptVersion)
3647 > $axmud::CLIENT->convertVersion($axmud::VERSION)
3648 ) {
3649 # Data file not created by a current or previous version of Axmud
3650 return undef;
3651 }
3652  
3653 # For the file type 'worldmodel', we might use a single monolithic file or, if the model
3654 # is large, multiple smaller ones. Check whether multiple files exist and, if so,
3655 # load them, updating the world model that's currently stored in
3656 # $loadHash{'world_model_obj'}
3657 if (
3658 $axmud::CLIENT->convertVersion($scriptVersion) >= 1_001_529
3659 && $self->fileType eq 'worldmodel'
3660 && ! $self->loadDataFile_worldModel($dir, \%loadHash)
3661 ) {
3662 return undef;
3663 }
3664  
3665 # Header information checks out. Store the values in this object
3666 $self->ivPoke('scriptName', $scriptName);
3667 $self->ivPoke('scriptVersion', $scriptVersion);
3668 $self->ivPoke('scriptConvertVersion', $axmud::CLIENT->convertVersion($scriptVersion));
3669 $self->ivPoke('saveDate', $saveDate);
3670 $self->ivPoke('saveTime', $saveTime);
3671 $self->ivPoke('assocWorldProf', $assocWorldProf);
3672  
3673 $self->ivPoke('actualFileName', $fileName);
3674 $self->ivPoke('actualPath', $path);
3675 $self->ivPoke('actualDir', $dir);
3676  
3677 # Extract the rest of the data from %loadHash, replacing data in memory with data from
3678 # the loaded file. The TRUE argument tells ->extractData that this is the calling
3679 # function
3680 if (! $self->extractData(TRUE, %loadHash)) {
3681  
3682 # Load failed
3683 return undef;
3684 }
3685  
3686 # Apply patches to any pre-configured world profiles with serious problems, or whose
3687 # DNS/IP/port has changed
3688 if (
3689 $fileType eq 'worldprof'
3690 && $axmud::CLIENT->ivExists('constWorldPatchHash', $assocWorldProf)
3691 ) {
3692 $self->patchWorldProf($assocWorldProf, $scriptVersion);
3693 }
3694  
3695 # Load complete
3696 return 1;
3697 }
3698 }
3699  
3700 sub loadDataFile_worldModel {
3701  
3702 # Called by $self->loadDataFile
3703 # For the file type 'worldmodel', we might use a single monolithic file or, if the model is
3704 # large, multiple smaller ones (a 'main' file and several 'mini' files)
3705 # $self->loadDataFile loads the 'worldmodel.axm' file, which is either a monolithic file,
3706 # or the 'main' file
3707 # This function checks whether the loaded file is a 'main' file and, if so, tries to load
3708 # the remaining 'mini' files, merging the data from the 'main' and 'mini' files into a
3709 # single world model
3710 #
3711 # Expected arguments
3712 # $dir - The directory from which the monolothic/'main' file was loaded
3713 # $mainHashRef - A hash containing data loaded from the monolithic or 'main' file.
3714 # The loaded world model itself (GA::Obj::WorldModel) is stored in
3715 # $$loadHashRef{'world_model_obj'}, and has not yet replaced the
3716 # world model in memory (GA::Session->worldModelObj). Anything loaded
3717 # from the 'mini' files is incorporated into that loaded world model
3718 # before the complete world model is transferred to
3719 # GA::Session->worldModelObj
3720 #
3721 # Return values
3722 # 'undef' on improper arguments or if we fail to load any 'mini' files that exist
3723 # 1 if the file loaded was a monolithic file, or if the 'main' and 'mini' files have all
3724 # been loaded successfully
3725  
3726 my ($self, $dir, $mainHashRef, $check) = @_;
3727  
3728 # Local variables
3729 my (
3730 $wmObj,
3731 @modelList, @exitList,
3732 );
3733  
3734 # Check for improper arguments
3735 if (! defined $dir || ! defined $mainHashRef || defined $check) {
3736  
3737 return $axmud::CLIENT->writeImproper(
3738 $self->_objClass . '->loadDataFile_worldModel',
3739 @_,
3740 );
3741 }
3742  
3743 # Import the loaded world model
3744 $wmObj = $$mainHashRef{'world_model_obj'};
3745 if (! defined $wmObj) {
3746  
3747 # Load failure
3748 return undef;
3749 }
3750  
3751 # If it's a monolithic world model file, there's nothing for this function to do
3752 if (! exists $wmObj->{modelSaveFileCount} || ! $wmObj->{modelSaveFileCount}) {
3753  
3754 # The monolithic file's data can now be extracted into memory as normal
3755 return 1;
3756 }
3757  
3758 # Some 'mini' files exist; load them all
3759 for (my $count = 1; $count <= $wmObj->{modelSaveFileCount}; $count++) {
3760  
3761 my (
3762 $loadPath, $hashRef, $fileType, $scriptName, $scriptVersion, $saveDate, $saveTime,
3763 $assocWorldProf,
3764 %loadHash,
3765 );
3766  
3767 # If this 'mini' file doesn't exist, loading of the whole world model fails
3768 $loadPath = $dir . '/worldmodel_' . $count . '.axm';
3769 if (! -e $loadPath) {
3770  
3771 return undef;
3772 }
3773  
3774 # Load all the data into a hash
3775 eval { $hashRef = Storable::lock_retrieve($loadPath); };
3776 if (! $hashRef) {
3777  
3778 # ->lock_retrieve() failed
3779 return undef;
3780 }
3781  
3782 # Convert the hash referenced by $hashRef into a named hash
3783 %loadHash = %{$hashRef};
3784  
3785 # Check that the header information in the 'mini' file is exactly the same as for the
3786 # 'main' file
3787 if (
3788 $loadHash{'file_type'} ne $$mainHashRef{'file_type'}
3789 || $loadHash{'script_name'} ne $$mainHashRef{'script_name'}
3790 || $loadHash{'script_version'} ne $$mainHashRef{'script_version'}
3791 || $loadHash{'save_date'} ne $$mainHashRef{'save_date'}
3792 || $loadHash{'save_time'} ne $$mainHashRef{'save_time'}
3793 || $loadHash{'assoc_world_prof'} ne $$mainHashRef{'assoc_world_prof'}
3794 ) {
3795 return undef;
3796 }
3797  
3798 # Extract the data from the 'mini' file
3799 if (exists $loadHash{'model_hash'}) {
3800  
3801 # Extract some model objects (regions, room etc)
3802 push (@modelList, %{$loadHash{'model_hash'}});
3803  
3804 } elsif (exists $loadHash{'exit_model_hash'}) {
3805  
3806 # Extract some exit model objects
3807 push (@exitList, %{$loadHash{'exit_model_hash'}});
3808  
3809 } else {
3810  
3811 # If neither exist in the file, it must be corrupted
3812 return undef;
3813 }
3814 }
3815  
3816 # All mini model files loaded successfully, so incorporate their data into the loaded
3817 # world model
3818 $wmObj->{modelHash} = {@modelList};
3819 $wmObj->{exitModelHash} = {@exitList};
3820 foreach my $obj (values %{$wmObj->{modelHash}}) {
3821  
3822 my $iv = $obj->category . 'ModelHash'; # e.g. ->regionModelHash
3823  
3824 $wmObj->{$iv}{$obj->number} = $obj;
3825 }
3826  
3827 # Operation complete
3828 return 1;
3829 }
3830  
3831 sub exportDataFile {
3832  
3833 # Called by GA::Cmd::ExportData->do for the file types:
3834 # 'config'
3835 # Exports a partial data file, often containing a single Perl object. The exported partial
3836 # data file can be read by GA::Cmd::ImportData->do's call to $self->importDataFile
3837 #
3838 # Expected arguments
3839 # $session - The calling function's GA::Session
3840 # $switch - Switch used in the ';exportdata' command - tells us which kind of
3841 # object(s) to export (e.g. '-s' for profile templates)
3842 # $name - A name corresponding to the object(s) to export (e.g. the name of the
3843 # profile template)
3844 #
3845 # Notes:
3846 # If one optional argument is specified, they must all be specified
3847 # If no optional arguments are specified (or are all set to 'undef'), the default
3848 # filename, path and directory for this file type are used
3849 #
3850 # Return values
3851 # 'undef' on improper arguments, if saving of data files isn't allowed (because of global
3852 # flags), if the user cancels the export or if there is an error saving the data file
3853 # itself
3854 # Otherwise returns the path to the exported file
3855  
3856 my ($self, $session, $switch, $name, $check) = @_;
3857  
3858 # Local variables
3859 my (
3860 $suggestFile, $exportPath,
3861 %saveHash,
3862 );
3863  
3864 # Check for improper arguments
3865 if (! defined $session || ! defined $switch || ! defined $name || defined $check) {
3866  
3867 return $axmud::CLIENT->writeImproper($self->_objClass . '->exportDataFile', @_);
3868 }
3869  
3870 # Check it's the right file type for this function
3871 if ($self->fileType ne 'config') {
3872  
3873 return $self->writeError(
3874 'Wrong file type \'' . $self->fileType . '\'',
3875 $self->_objClass . '->exportDataFile',
3876 );
3877 }
3878  
3879 # Don't save anything if the global flags forbid it
3880 if (! $axmud::CLIENT->saveDataFlag) {
3881  
3882 return undef;
3883 }
3884  
3885 # Compile a special hash, %saveHash, that references all the data we want to save
3886  
3887 # First compile the header information (i.e. metadata)...
3888 # $saveHash{'file_type'} = $self->fileType; # Set below
3889 $saveHash{'script_name'} = $axmud::NAME_FILE;
3890 $saveHash{'script_version'} = $axmud::VERSION;
3891 $saveHash{'save_date'} = $axmud::CLIENT->localDate();
3892 $saveHash{'save_time'} = $axmud::CLIENT->localTime();
3893 # $saveHash{'assoc_world_prof'} = $self->assocWorldProf; # Set below
3894  
3895 # ...then compile the data for this file type
3896 if ($switch eq '-d') {
3897  
3898 # ;exd -d <profile>
3899 # Exports the non-world profile <profile>. If it's a custom profile, the profile
3900 # template is also exported. All of the profile's cages are also exported. (World
3901 # profiles can't be exported using this command - use ';exportfile' instead.)
3902  
3903 my (
3904 $profObj,
3905 %profHash, %cageHash, %templateHash,
3906 );
3907  
3908 # Prepare the data for a partial 'otherprof' file
3909 $profObj = $session->ivShow('profHash', $name);
3910 $profHash{$name} = $profObj;
3911  
3912 foreach my $cageType ($axmud::CLIENT->cageTypeList) {
3913  
3914 $cageHash{$name} = $session->findCage($cageType, $name);
3915 }
3916  
3917 if ($session->ivExists('templateHash', $profObj->category)) {
3918  
3919 # This is a custom profile, so we also need to export its parent profile template
3920 $templateHash{$profObj->category}
3921 = $session->ivShow('templateHash', $profObj->category);
3922 }
3923  
3924 # Transfer everything into %saveHash
3925 $saveHash{'file_type'} = 'otherprof';
3926 $saveHash{'assoc_world_prof'} = $session->currentWorld->name;
3927 $saveHash{'prof_priority_list'} = [];
3928 $saveHash{'template_hash'} = \%templateHash; # Possibly an empty hash
3929 $saveHash{'prof_hash'} = \%profHash;
3930 $saveHash{'cage_hash'} = \%cageHash;
3931  
3932 } elsif ($switch eq '-t') {
3933  
3934 # ;exd -t <cage>
3935 # Exports the single cage named <cage>
3936  
3937 my %cageHash;
3938  
3939 # Prepare the data for a partial 'otherprof' file
3940 $cageHash{$name} = $session->ivShow('cageHash', $name);
3941  
3942 # Transfer everything into %saveHash
3943 $saveHash{'file_type'} = 'otherprof';
3944 $saveHash{'assoc_world_prof'} = $session->currentWorld->name;
3945 $saveHash{'prof_priority_list'} = [];
3946 $saveHash{'template_hash'} = {};
3947 $saveHash{'prof_hash'} = {};
3948 $saveHash{'cage_hash'} = \%cageHash;
3949  
3950 } elsif ($switch eq '-e') {
3951  
3952 # ;exd -e <profile>
3953 # Exports all the cages belonging to the profile <profile>, but not the profile itself
3954  
3955 my %cageHash;
3956  
3957 # Prepare the data for a partial 'otherprof' file
3958 foreach my $cageType ($axmud::CLIENT->cageTypeList) {
3959  
3960 $cageHash{$name} = $session->findCage($cageType, $name);
3961 }
3962  
3963 # Transfer everything into %saveHash
3964 $saveHash{'file_type'} = 'otherprof';
3965 $saveHash{'assoc_world_prof'} = $session->currentWorld->name;
3966 $saveHash{'prof_priority_list'} = [];
3967 $saveHash{'template_hash'} = {};
3968 $saveHash{'prof_hash'} = {};
3969 $saveHash{'cage_hash'} = \%cageHash;
3970  
3971 } elsif ($switch eq '-s') {
3972  
3973 # ;exd -s <skel>
3974 # Exports the template profile named <skel>
3975  
3976 my %templateHash;
3977  
3978 # Prepare the data for a partial 'otherprof' file
3979 $templateHash{$name} = $session->ivShow('templateHash', $name);
3980  
3981 # Transfer everything into %saveHash
3982 $saveHash{'file_type'} = 'otherprof';
3983 $saveHash{'assoc_world_prof'} = $session->currentWorld->name;
3984 $saveHash{'prof_priority_list'} = [];
3985 $saveHash{'template_hash'} = \%templateHash;
3986 $saveHash{'prof_hash'} = {};
3987 $saveHash{'cage_hash'} = {};
3988  
3989 } elsif ($switch eq '-i') {
3990  
3991 # ;exd -i <task>
3992 # Exports the (global) initial task named <task>. (Initial tasks belonging to a
3993 # profile can't be exported - you must export the whole profile)
3994  
3995 my %initTaskHash;
3996  
3997 # Prepare the data for a partial 'tasks' file
3998 $initTaskHash{$name} = $axmud::CLIENT->ivShow('initTaskHash', $name);
3999  
4000 # Transfer everything into %saveHash
4001 $saveHash{'file_type'} = 'tasks';
4002 $saveHash{'assoc_world_prof'} = undef;
4003 $saveHash{'task_label_hash'} = {};
4004 $saveHash{'task_run_first_list'} = [];
4005 $saveHash{'task_run_last_list'} = [];
4006 $saveHash{'init_task_hash'} = \%initTaskHash;
4007 $saveHash{'init_task_order_list'} = [];
4008 $saveHash{'init_task_total'} = undef;
4009 $saveHash{'custom_task_hash'} = {};
4010 $saveHash{'init_script_hash'} = {};
4011 $saveHash{'init_script_order_list'} = [];
4012  
4013 } elsif ($switch eq '-c') {
4014  
4015 # ;exd -c <task>
4016 # Exports the custom task named <task>
4017  
4018 my %customTaskHash;
4019  
4020 # Prepare the data for a partial 'tasks' file
4021 $customTaskHash{$name} = $axmud::CLIENT->ivShow('customTaskHash', $name);
4022  
4023 # Transfer everything into %saveHash
4024 $saveHash{'file_type'} = 'tasks';
4025 $saveHash{'assoc_world_prof'} = undef;
4026 $saveHash{'task_label_hash'} = {};
4027 $saveHash{'task_run_first_list'} = [];
4028 $saveHash{'task_run_last_list'} = [];
4029 $saveHash{'init_task_hash'} = {};
4030 $saveHash{'init_task_order_list'} = [];
4031 $saveHash{'init_task_total'} = undef;
4032 $saveHash{'custom_task_hash'} = \%customTaskHash;
4033 $saveHash{'init_script_hash'} = {};
4034 $saveHash{'init_script_order_list'} = [];
4035  
4036 } elsif ($switch eq '-y') {
4037  
4038 # ;exd -y <dict>
4039 # Exports the dictionary named <dict>
4040  
4041 my %dictHash;
4042  
4043 # Prepare the data for a partial 'dicts' file
4044 $dictHash{$name} = $axmud::CLIENT->ivShow('dictHash', $name);
4045  
4046 # Transfer everything into %saveHash
4047 $saveHash{'file_type'} = 'dicts';
4048 $saveHash{'assoc_world_prof'} = undef;
4049 $saveHash{'dict_hash'} = \%dictHash;
4050  
4051 } elsif ($switch eq '-z') {
4052  
4053 # ;exd -z <map>
4054 # Exports the zonemap named <map>, including all of its zone models
4055  
4056 my %zonemapHash;
4057  
4058 # Prepare the data for a partial 'zonemaps' file
4059 $zonemapHash{$name} = $axmud::CLIENT->ivShow('zonemapHash', $name);
4060  
4061 # Transfer everything into %saveHash
4062 $saveHash{'file_type'} = 'zonemaps';
4063 $saveHash{'assoc_world_prof'} = undef;
4064 $saveHash{'zonemap_hash'} = \%zonemapHash;
4065 $saveHash{'standard_zonemap_hash'} = {};
4066  
4067 } elsif ($switch eq '-p') {
4068  
4069 # ;exd -p <map>
4070 # Exports the winmap named <map>, including all of its winzone objects
4071  
4072 my %winmapHash;
4073  
4074 # Prepare the data for a partial 'winmaps' file
4075 $winmapHash{$name} = $axmud::CLIENT->ivShow('winmapHash', $name);
4076  
4077 # Transfer everything into %saveHash
4078 $saveHash{'file_type'} = 'winmaps';
4079 $saveHash{'assoc_world_prof'} = undef;
4080 $saveHash{'winmap_hash'} = \%winmapHash;
4081 $saveHash{'standard_winmap_hash'} = {};
4082 $saveHash{'default_main_winmap'} = undef;
4083 $saveHash{'default_internal_winmap'} = undef;
4084 $saveHash{'colour_scheme_hash'} = {};
4085  
4086 } elsif ($switch eq '-o') {
4087  
4088 # ;exd -o <col>
4089 # Exports the colour scheme named <col>
4090  
4091 my %colourSchemeHash;
4092  
4093 # Prepare the data for a partial 'winmaps' file
4094 $colourSchemeHash{$name} = $axmud::CLIENT->ivShow('colourSchemeHash', $name);
4095  
4096 # Transfer everything into %saveHash
4097 $saveHash{'file_type'} = 'winmaps';
4098 $saveHash{'assoc_world_prof'} = undef;
4099 $saveHash{'winmap_hash'} = {};
4100 $saveHash{'standard_winmap_hash'} = {};
4101 $saveHash{'default_main_winmap'} = undef;
4102 $saveHash{'default_internal_winmap'} = undef;
4103 $saveHash{'colour_scheme_hash'} = \%colourSchemeHash;
4104  
4105 } elsif ($switch eq '-x') {
4106  
4107 # ;exd -x <obj>
4108 # Exports the text-to-speech object name <obj>
4109  
4110 my %ttsHash;
4111  
4112 # Prepare the data for a partial 'tts' file
4113 $ttsHash{$name} = $axmud::CLIENT->iShow('ttsObjHash', $name);
4114  
4115 # Transfer everything into %saveHash
4116 $saveHash{'file_type'} = 'tts';
4117 $saveHash{'assoc_world_prof'} = undef;
4118 $saveHash{'tts_obj_hash'} = \%ttsHash;
4119 }
4120  
4121 # Set the suggested name for the data file
4122 $suggestFile = $name . '.amx';
4123  
4124 # Open a file chooser dialog to decide where to save the exported file
4125 # NB Private code, not included in the public release, sets the IV
4126 # GA::Client->privConfigAllWorld, in which case we use a certain file path, rather than
4127 # prompting the user for one
4128 if (! $axmud::CLIENT->privConfigAllWorld) {
4129  
4130 $exportPath = $session->mainWin->showFileChooser(
4131 'Export object',
4132 'save',
4133 $suggestFile,
4134 );
4135  
4136 if (! $exportPath) {
4137  
4138 # User canceleld
4139 return undef;
4140 }
4141  
4142 } else {
4143  
4144 $exportPath = $axmud::SHARE_DIR . '/items/worlds/' . $axmud::CLIENT->privConfigAllWorld
4145 . '/' . $axmud::CLIENT->privConfigAllWorld . '.amx';
4146 }
4147  
4148 # Save the special hash as a single object
4149 if (! Storable::lock_nstore(\%saveHash, $exportPath)) {
4150  
4151 # Export failed
4152 return undef;
4153  
4154 } else {
4155  
4156 # Export complete
4157 return $exportPath;
4158 }
4159 }
4160  
4161 sub importDataFile {
4162  
4163 # Called by GA::Cmd::ImportData->do for the file types:
4164 # 'config'
4165 #
4166 # Loads an exported data file into memory, replacing existing data in memory only when
4167 # objects with the same name exist
4168 #
4169 # Expected arguments
4170 # $session - The calling function's GA::Session
4171 # $importPath - The full path of the file to import
4172 #
4173 # Return values
4174 # 'undef' on improper arguments, if loading of data files isn't allowed (because of global
4175 # flags), if the user cancels the load or if there is an error loading the data file
4176 # itself
4177 # Otherwise returns the filetype (e.g. 'worldprof' or 'tasks')
4178  
4179 my ($self, $session, $importPath, $check) = @_;
4180  
4181 # Local variables
4182 my (
4183 $matchFlag, $hashRef, $fileType, $scriptName, $scriptVersion, $saveDate, $saveTime,
4184 $assocWorldProf, $fileObj, $result, $notCompatFlag,
4185 %loadHash,
4186 );
4187  
4188 # Check for improper arguments
4189 if (! defined $session || ! defined $importPath || defined $check) {
4190  
4191 return $axmud::CLIENT->writeImproper($self->_objClass . '->importDataFile', @_);
4192 }
4193  
4194 # Check it's the right file type for this function
4195 if ($self->fileType ne 'config') {
4196  
4197 return $self->writeError(
4198 'Wrong file type \'' . $self->fileType . '\'',
4199 $self->_objClass . '->importDataFile',
4200 );
4201 }
4202  
4203 # Don't load anything if the global flags forbid it
4204 if (! $axmud::CLIENT->loadDataFlag) {
4205  
4206 return undef;
4207 }
4208  
4209 # Check that the specified file exists
4210 if (! (-e $importPath)) {
4211  
4212 # Before v1.0.868, Axmud used different file extensions; check them all
4213 OUTER: foreach my $ext (@axmud::COMPAT_EXT_LIST) {
4214  
4215 my $altPath = $importPath;
4216 $altPath =~ s/\.axm/.$ext/;
4217  
4218 if (-e $altPath) {
4219  
4220 $matchFlag = TRUE;
4221 $importPath = $altPath;
4222 last OUTER;
4223 }
4224 }
4225  
4226 if (! $matchFlag) {
4227  
4228 return undef;
4229 }
4230 }
4231  
4232 # Load all the data into an anonymous hash
4233 eval { $hashRef = Storable::lock_retrieve($importPath); };
4234 if (! $hashRef) {
4235  
4236 # ->lock_retrieve() failed
4237 return undef;
4238  
4239 } else {
4240  
4241 # Convert the anonymous hash referenced by $hashRef into a named hash
4242 %loadHash = %{$hashRef};
4243  
4244 # Before v1.0.868, Axmud had a different name. Update all header data
4245 if (
4246 defined $loadHash{'script_version'}
4247 && $axmud::CLIENT->convertVersion($loadHash{'script_version'}) < 1_000_868
4248 ) {
4249 %loadHash = $self->updateHeaderAfterRename(%loadHash);
4250 }
4251  
4252 # Extract the header information (i.e. metadata) from the hash
4253 $fileType = $loadHash{'file_type'};
4254 $scriptName = $loadHash{'script_name'};
4255 $scriptVersion = $loadHash{'script_version'};
4256 $saveDate = $loadHash{'save_date'};
4257 $saveTime = $loadHash{'save_time'};
4258 $assocWorldProf = $loadHash{'assoc_world_prof'};
4259  
4260 # Do checks on the header information
4261 if (
4262 ! defined $fileType || ! defined $scriptName || ! defined $scriptVersion
4263 || ! defined $saveDate || ! defined $saveTime
4264 ) {
4265 # Missing or possibly corrupted header (NB $assocWorldProf can be 'undef')
4266 return undef;
4267  
4268 } elsif (
4269 ! $self->checkCompatibility($scriptName)
4270 || $axmud::CLIENT->convertVersion($scriptVersion)
4271 > $axmud::CLIENT->convertVersion($axmud::VERSION)
4272 ) {
4273 # Data file not created by a current or previous version of Axmud
4274 return undef;
4275  
4276 } elsif ($fileType eq 'keycodes') {
4277  
4278 # This type of data file was removed in v1.1.286
4279 return undef;
4280 }
4281  
4282 # Extract the rest of the data from %loadHash, incorporating data from the loaded file
4283 # into memory
4284 if ($fileType eq 'worldprof') {
4285  
4286 # Call ->extractData on the file object belonging to the current world profile
4287 $fileObj = $session->ivShow(
4288 'sessionFileObjHash',
4289 $session->currentWorld->name,
4290 );
4291  
4292 } elsif ($axmud::CLIENT->ivExists('fileObjHash', $fileType)) {
4293  
4294 # Call ->extractData on the corresponding file object
4295 $fileObj = $axmud::CLIENT->ivShow('fileObjHash', $fileType);
4296  
4297 } elsif ($session->ivExists('sessionFileObjHash', $fileType)) {
4298  
4299 # Call ->extractData on the corresponding file object
4300 $fileObj = $session->ivShow('sessionFileObjHash', $fileType);
4301  
4302 } else {
4303  
4304 # No file object into which to incorporate the imported data
4305 return undef;
4306 }
4307  
4308 # If the existing file object needs to be saved, asked permission before importing data
4309 # into it
4310 $result = $session->mainWin->showMsgDialogue(
4311 'Overwrite unsaved data',
4312 'question',
4313 'The file you have specified may overwrite unsaved data in memory. Import the'
4314 . ' file anyway?',
4315 'yes-no',
4316 );
4317  
4318 if ($result eq 'no') {
4319  
4320 return undef;
4321 }
4322  
4323 # Extract the imported data. The FALSE argument tells ->extractData that this is the
4324 # calling function
4325 $result = $fileObj->extractData(FALSE, %loadHash);
4326 if (! $result) {
4327  
4328 # Import failed
4329 return undef;
4330  
4331 } else {
4332  
4333 # Return the file type of the imported file
4334 return $result;
4335 }
4336 }
4337 }
4338  
4339 sub extractData {
4340  
4341 # Called by $self->loadDataFile or $self->importDataFile
4342 # Processes an anonymous hash, referenced by %hashRef, containing data loaded from a file
4343 # Overwrites data in memory, then calls $self->updateExtractedData to update data from
4344 # previous versions of Axmud to make it work with the code in this version
4345 #
4346 # Expected arguments
4347 # $overWriteFlag - Set to TRUE when called by $self->loadDataFile. Overwites (most)
4348 # existing data in memory
4349 # - Set to FALSE when called by $self->importDataFile. Incorporates (most)
4350 # of the loaded data into memory, replacing identically named
4351 # objects, but retaining other existing objects in memory
4352 # %loadHash - A hash containing all the loaded data (including header data)
4353 #
4354 # Notes
4355 # $overWriteFlag works on the following general principle:
4356 #
4357 # If $overWriteFlag = TRUE, when tasks.axm contains the custom tasks 'task3' and 'task4',
4358 # and when the custom tasks 'task1' and 'task2' are in memory, after loading only
4359 # 'task3' and 'task4' are in memory.
4360 # If $overWriteFlag = FALSE, when tasks.axm contains the custom task 'task3', and when the
4361 # custom tasks 'task1' and 'task2' are in memory, all three tasks will be in memory
4362 # at the end of the operation. However, if tasks.amx contains 'task2', the 'task2' in
4363 # memory will be overwritten
4364 #
4365 # The precise behaviour for each file type is as follows:
4366 # 'worldprof'
4367 # (T) The loaded world profile replaces one in memory with the same name
4368 # (F) (This function should not be called)
4369 # 'otherprof'
4370 # (T) All existing non-world profiles, cages and templates are destroyed and
4371 # replaced with any loaded ones. The existing world profile is not replaced
4372 # (F) We are importing a single non-world profile, or a single template; this
4373 # replaces one in memory with the same name. For profiles, the cages are
4374 # updated
4375 # 'worldmodel'
4376 # The entire world model in memory is replaced by the loaded one, regardless of
4377 # the flag
4378 # 'tasks', 'scripts', 'contacts', 'tts'
4379 # Behaviour as described above
4380 # 'dicts'
4381 # (T) Any current dictionaries in use by a session are retained, if a dictionary
4382 # with the same name doesn't exist in the loaded file, but dictionaries
4383 # not in use are replaced. Otherwise, all dictionaries are replaced
4384 # (F) If one of the loaded dictionaries has the same name as a current dictionary
4385 # in use by any session, that current dictionary is replaced. Otherwise,
4386 # all dictionaries are incorporated
4387 # 'toolbar'
4388 # The entire list of toolbar buttons in memory is replaced by the loaded one,
4389 # regardless of the flag
4390 # 'usercmds'
4391 # (T) It's quite common for new commands to be added in between versions of Axmud.
4392 # Any user commands corresponding to standard commands that didn't exist
4393 # before are retained, but all other user commands are replaced
4394 # (F) (This function should not be called)
4395 # 'zonemaps'
4396 # (T) All zonemaps in memory are replaced. The workspace grids used by all
4397 # sessions are reset (when they exist). Any workspaces using a default
4398 # zonemap which no longer exists are given a new default zonemap. Any
4399 # workspace grids using a zonemap which no longer exists are reset to use
4400 # the workspace's default zonemap
4401 # (F) Loaded data incorporated into memory. Any workspace grids using a loaded
4402 # zonemap are reset
4403 # 'winmaps'
4404 # (T) All winmaps/colour schemes in memory are replaced; no existing windows are
4405 # affected, since winmaps are only applied when a window is created, and
4406 # colour schemes are only applied periodically
4407 # (F) Loaded data incorporated into memory
4408 # 'tts'
4409 # (T) All existing data in memory replaced by loaded data
4410 # (F) Loaded data incorporated into memory
4411 #
4412 # Return values
4413 # 'undef' on improper arguments
4414 # Otherwise returns the filetype (e.g. 'worldprof' or 'tasks')
4415  
4416 my ($self, $overWriteFlag, %loadHash) = @_;
4417  
4418 # Local variables
4419 my (
4420 $client, $session,
4421 %hash,
4422 );
4423  
4424 # Check for improper arguments
4425 if (! defined $overWriteFlag) {
4426  
4427 return $axmud::CLIENT->writeImproper($self->_objClass . '->extractData', @_);
4428 }
4429  
4430 # Import shortcuts for the GA::Client and GA::Session
4431 $client = $axmud::CLIENT;
4432 $session = $self->session;
4433  
4434 # Before v1.0.868, Axmud had a different name. Update all file data
4435 if ($axmud::CLIENT->convertVersion($self->scriptVersion) < 1_000_868) {
4436  
4437 %loadHash = $self->updateDataAfterRename(%loadHash);
4438 }
4439  
4440 # Extract the data
4441 if ($self->fileType eq 'worldprof') {
4442  
4443 # 'worldprof'
4444 # (T) The loaded world profile replaces one in memory with the same name
4445 # (F) (This function should not be called)
4446  
4447 if ($overWriteFlag) {
4448  
4449 # (When overwriting, set IVs directly, rather than using 'set' accessors)
4450  
4451 # Replace a profile in memory with the same name
4452 $client->ivAdd(
4453 'worldProfHash',
4454 $self->assocWorldProf,
4455 $loadHash{'world_prof'},
4456 );
4457  
4458 # Every session using this world must also have its profile registry updated
4459 foreach my $session ($axmud::CLIENT->listSessions()) {
4460  
4461 if ($session->currentWorld->name eq $self->assocWorldProf) {
4462  
4463 $session->ivAdd('profHash', $self->assocWorldProf, $loadHash{'world_prof'});
4464 }
4465 }
4466  
4467 # The data in memory matches the one in saved data files
4468 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4469  
4470 } else {
4471  
4472 # (When not overwriting, use 'set' accessors, since the data in memory no longer
4473 # matches the saved file)
4474  
4475 # (Should not be able to import a partial 'worldprof' file, since
4476 # $self->exportDataFile doesn't create one)
4477 return undef;
4478 }
4479  
4480 } elsif ($self->fileType eq 'otherprof') {
4481  
4482 # 'otherprof'
4483 # (T) All existing non-world profiles, cages and templates are destroyed and replaced
4484 # with any loaded ones. The existing world profile is not replaced
4485 # (F) We are importing a single non-world profile, or a single template; this replaces
4486 # one in memory with the same name. For profiles, the cages are updated
4487  
4488 my ($worldProfObj, $modFlag);
4489  
4490 if ($overWriteFlag) {
4491  
4492 # We are loading all the non-world profiles associated with a world profile, and all
4493 # the cages/templates associated with them
4494 # If GA::Session->profHash contains a world profile, it is not replaced (but
4495 # everything else is)
4496  
4497 # Find the world profile already in memory
4498 OUTER: foreach my $profObj ($session->ivValues('profHash')) {
4499  
4500 if ($profObj->category eq 'world') {
4501  
4502 $worldProfObj = $profObj;
4503 last OUTER;
4504 }
4505 }
4506  
4507 # Replace the contents of the profile registry
4508 $session->ivPoke('profHash', %{$loadHash{'prof_hash'}});
4509 if ($worldProfObj) {
4510  
4511 $session->ivAdd('profHash', $worldProfObj->name, $worldProfObj);
4512 }
4513  
4514 # Replace the contents of other IVs
4515 $session->ivPoke('profPriorityList', @{$loadHash{'prof_priority_list'}});
4516 $session->ivPoke('templateHash', %{$loadHash{'template_hash'}});
4517 $session->ivPoke('cageHash', %{$loadHash{'cage_hash'}});
4518  
4519 # The data in memory matches saved data files
4520 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4521 # Cages for the world profile have been loaded (probably), so its file object must
4522 # be marked as having had its data changed
4523 $client->setModifyFlag(
4524 $loadHash{'assoc_world_prof'},
4525 TRUE,
4526 $self->_objClass . '->extractData',
4527 );
4528  
4529 } else {
4530  
4531 # We are loading one or more non-world profiles, templates or cages that have been
4532 # exported and must be re-incorporated into memory
4533  
4534 # Incorporate non-world profiles and their corresponding cages
4535 %hash = %{$loadHash{'prof_hash'}};
4536 if (%hash) {
4537  
4538 foreach my $profObj (values %hash) {
4539  
4540 $session->add_prof($profObj);
4541 }
4542 }
4543  
4544 %hash = %{$loadHash{'cage_hash'}};
4545 if (%hash) {
4546  
4547 foreach my $cageObj (values %hash) {
4548  
4549 $session->add_cage($cageObj);
4550 }
4551 }
4552  
4553 %hash = %{$loadHash{'template_hash'}};
4554 if (%hash) {
4555  
4556 foreach my $templateObj (values %hash) {
4557  
4558 $session->add_template($templateObj);
4559 }
4560 }
4561  
4562 # (Calls to accessors will have set the right ->modifyFlag values)
4563 }
4564  
4565 } elsif ($self->fileType eq 'worldmodel') {
4566  
4567 # 'worldmodel'
4568 # The entire world model in memory is replaced by the loaded one, regardless of
4569 # the value of $overWriteFlag
4570  
4571 my $swapFlag;
4572  
4573 $session->ivPoke('worldModelObj', $loadHash{'world_model_obj'});
4574  
4575 if ($overWriteFlag) {
4576  
4577 # The data in memory matches saved data files
4578 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4579  
4580 } else {
4581  
4582 # The data in memory doesn't match saved data files
4583 $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData');
4584 }
4585  
4586 # If the world model belonging to one world was imported into another using
4587 # ;importFiles, the world model's ->_parentWorld won't have been updated yet
4588 if ($session->worldModelObj->_parentWorld ne $session->currentWorld->name) {
4589  
4590 # Update it now
4591 $session->worldModelObj->{_parentWorld} = $session->currentWorld->name;
4592 $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData');
4593 # This file object's IV is also wrong
4594 $self->ivPoke('assocWorldProf', $session->currentWorld->name);
4595 }
4596  
4597 # Delete any temporary regions from the world model
4598 # $self->updateExtractedData hasn't been called yet, so before v1.0.871,
4599 # ->regionModelHash will still be ->regionModel
4600 if (
4601 $self->scriptConvertVersion < 1_000_871
4602 && ! exists $session->worldModelObj->{regionModelHash}
4603 ) {
4604 # Swap the IV name temporarily, so ->deleteTempRegions doesn't get confused
4605 $session->worldModelObj->{regionModelHash} = $session->worldModelObj->{regionModel};
4606 delete $session->worldModelObj->{regionModel};
4607 $swapFlag = TRUE;
4608 }
4609  
4610 $session->worldModelObj->deleteTempRegions(
4611 $session,
4612 TRUE, # Update any Automapper windows that are already open
4613 );
4614  
4615 if ($swapFlag) {
4616  
4617 # Restore the IV names, so $self->updateExtractedData doesn't get confused
4618 $session->worldModelObj->{regionModel} = $session->worldModelObj->{regionModelHash};
4619 delete $session->worldModelObj->{regionModelHash};
4620 }
4621  
4622 } elsif ($self->fileType eq 'tasks') {
4623  
4624 # 'tasks'
4625 # (T) All existing data in memory replaced by loaded data
4626 # (F) Loaded data incorporated into memory
4627  
4628 if ($overWriteFlag) {
4629  
4630 # Replace the data in memory
4631 $client->ivPoke('taskLabelHash', %{$loadHash{'task_label_hash'}});
4632 $client->ivPoke('taskRunFirstList', @{$loadHash{'task_run_first_list'}});
4633 $client->ivPoke('taskRunLastList', @{$loadHash{'task_run_last_list'}});
4634 $client->ivPoke('initTaskHash', %{$loadHash{'init_task_hash'}});
4635 $client->ivPoke('initTaskOrderList', @{$loadHash{'init_task_order_list'}});
4636 $client->ivPoke('initTaskTotal', $loadHash{'init_task_total'});
4637 $client->ivPoke('customTaskHash', %{$loadHash{'custom_task_hash'}});
4638  
4639 # The data in memory matches saved data files
4640 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4641  
4642 } else {
4643  
4644 # We are loading one or more global initial task or custom task that have been
4645 # exported and must be re-incorporated into memory
4646  
4647 # Incorporate tasks
4648 %hash = %{$loadHash{'init_task_hash'}};
4649 foreach my $taskObj (values %hash) {
4650  
4651 # Give the task a new unique name, before adding it to the client's registries
4652 $taskObj->updateTaskLists();
4653 }
4654  
4655 %hash = %{$loadHash{'custom_task_hash'}};
4656 foreach my $taskObj (values %hash) {
4657  
4658 # Give the task a new unique name, before adding it to the client's registries
4659 $taskObj->updateTaskLists();
4660 }
4661  
4662 # (Calls to accessors will have set the right ->modifyFlag values)
4663 }
4664  
4665 } elsif ($self->fileType eq 'scripts') {
4666  
4667 # 'scripts'
4668 # (T) All existing data in memory replaced by loaded data
4669 # (F) Loaded data incorporated into memory
4670  
4671 if ($overWriteFlag) {
4672  
4673 # Replace the data in memory
4674 $client->ivPoke('scriptDirList', @{$loadHash{'script_dir_list'}});
4675 $client->ivPoke('initScriptHash', %{$loadHash{'init_script_hash'}});
4676 $client->ivPoke('initScriptOrderList', @{$loadHash{'init_script_order_list'}});
4677  
4678 # The data in memory matches saved data files
4679 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4680  
4681 } else {
4682  
4683 # Incorporate script directories into memory
4684 foreach my $dir (@{$loadHash{'script_dir_list'}}) {
4685  
4686 # Only add directories which aren't already in the script directory list
4687 if (! defined $client->ivFind('scriptDirList', $dir)) {
4688  
4689 $client->ivPush('scriptDirList', $dir);
4690 }
4691 }
4692  
4693 # Incorporate initial scripts into memory
4694 %hash = %{$loadHash{'init_script_hash'}};
4695 foreach my $script (keys %hash) {
4696  
4697 if ($client->ivExists('initScriptHash', $script)) {
4698  
4699 # Replace the entry (the script's position in ->initScriptOrderList remains
4700 # unchanged)
4701 $client->ivAdd('initScriptHash', $script, $hash{$script});
4702  
4703 } else {
4704  
4705 # Add a new entry
4706 $client->ivAdd('initScriptHash', $script, $hash{$script});
4707 $client->ivPush('initScriptOrderList', $script);
4708 }
4709 }
4710  
4711 # The data in memory doesn't match saved data files
4712 $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData');
4713 }
4714  
4715 } elsif ($self->fileType eq 'contacts') {
4716  
4717 # 'contacts'
4718 # (T) All existing data in memory replaced by loaded data
4719 # (F) Loaded data incorporated into memory
4720  
4721 if ($overWriteFlag) {
4722  
4723 # Replace the data in memory
4724 $client->ivPoke('chatName', $loadHash{'chat_name'});
4725 $client->ivPoke('chatEmail', $loadHash{'chat_email'});
4726 $client->ivPoke('chatAcceptMode', $loadHash{'chat_accept_mode'});
4727 $client->ivPoke('chatContactHash', %{$loadHash{'chat_contact_hash'}});
4728 $client->ivPoke('chatIcon', $loadHash{'chat_icon'});
4729 $client->ivPoke('chatSmileyHash', %{$loadHash{'chat_smiley_hash'}});
4730  
4731 # The data in memory matches saved data files
4732 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4733  
4734 } else {
4735  
4736 # (Should not be able to import a partial 'contacts' file, since
4737 # $self->exportDataFile doesn't create one)
4738 return undef;
4739 }
4740  
4741 } elsif ($self->fileType eq 'dicts') {
4742  
4743 # (T) Any current dictionaries in use by a session are retained, if a dictionary with
4744 # the same name doesn't exist in the loaded file, but dictionaries not in use are
4745 # replaced. Otherwise, all dictionaries are replaced
4746 # (F) If one of the loaded dictionaries has the same name as a current dictionary in use
4747 # by any session, that current dictionary is replaced. Otherwise, all dictionaries
4748 # are incorporated
4749  
4750 my %dictHash;
4751  
4752 if ($overWriteFlag) {
4753  
4754 # Get a hash of dictionaries in use by all sessions
4755 foreach my $otherSession ($axmud::CLIENT->listSessions()) {
4756  
4757 my $dictObj = $otherSession->currentDict;
4758  
4759 $dictHash{$dictObj->name} = $dictObj;
4760 }
4761  
4762 # Replace the dictionary registry...
4763 $client->ivPoke('dictHash', %{$loadHash{'dict_hash'}});
4764 # (So far, the data in memory matches saved data files)
4765 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4766 # ...but retain any current dictionaries which don't appear in it
4767 foreach my $dictObj (values %dictHash) {
4768  
4769 if (! $client->ivExists('dictHash', $dictObj->name)) {
4770  
4771 $client->add_dict($dictObj); # Updates ->modifyFlag
4772 }
4773 }
4774  
4775 # Update the current dictionary object stored by every session
4776 foreach my $otherSession ($client->listSessions()) {
4777  
4778 my ($currentObj, $loadObj);
4779  
4780 $currentObj = $otherSession->currentDict;
4781 $loadObj = $client->ivShow('dictHash', $currentObj->name);
4782  
4783 if ($currentObj ne $loadObj) {
4784  
4785 $otherSession->set_currentDict($loadObj);
4786 }
4787 }
4788  
4789 } else {
4790  
4791 # Incorporate dictionaries
4792 %dictHash = %{$loadHash{'dict_hash'}};
4793 if (%dictHash) {
4794  
4795 foreach my $dictObj (values %dictHash) {
4796  
4797 $client->add_dict($dictObj);
4798 }
4799 }
4800  
4801 # Update the current dictionary object stored by every session
4802 foreach my $otherSession ($client->listSessions()) {
4803  
4804 my ($currentObj, $loadObj);
4805  
4806 $currentObj = $otherSession->currentDict;
4807 $loadObj = $client->ivShow('dictHash', $currentObj->name);
4808  
4809 if ($currentObj ne $loadObj) {
4810  
4811 $otherSession->set_currentDict($loadObj);
4812 }
4813 }
4814  
4815 # (Calls to accessors will have set the right ->modifyFlag values)
4816 }
4817  
4818 } elsif ($self->fileType eq 'toolbar') {
4819  
4820 # 'toolbar'
4821 # The entire list of toolbar buttons in memory is replaced by the loaded one,
4822 # regardless of the flag
4823  
4824 $axmud::CLIENT->ivPoke('toolbarHash', %{$loadHash{'toolbar_hash'}});
4825 $axmud::CLIENT->ivPoke('toolbarList', @{$loadHash{'toolbar_list'}});
4826  
4827 if ($overWriteFlag) {
4828  
4829 # The data in memory matches saved data files
4830 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4831  
4832 } else {
4833  
4834 # The data in memory doesn't match saved data files
4835 $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData');
4836 }
4837  
4838 # Redraw toolbar buttons in all 'internal' windows
4839 foreach my $winObj ($axmud::CLIENT->desktopObj->ivValues('gridWinHash')) {
4840  
4841 my $stripObj;
4842  
4843 if (
4844 $winObj->winType eq 'main'
4845 || $winObj->winType eq 'protocol'
4846 || $winObj->winType eq 'custom'
4847 ) {
4848 $stripObj = $winObj->ivShow('firstStripHash', 'Games::Axmud::Strip::Toolbar');
4849 if ($stripObj) {
4850  
4851 $stripObj->resetToolbar();
4852 }
4853 }
4854 }
4855  
4856 } elsif ($self->fileType eq 'usercmds') {
4857  
4858 # 'usercmds'
4859 # (T) It's quite common for new commands to be added in newer versions of Axmud.
4860 # Any user commands corresponding to client commands that didn't exist before
4861 # are retained, but all other user commands are replaced
4862 # (F) (This function should not be called)
4863  
4864 my (
4865 $modFlag,
4866 %standardHash, %currentHash, %newLoadHash, %loadStandardHash,
4867 );
4868  
4869 if ($overWriteFlag) {
4870  
4871 %hash = %{$loadHash{'user_cmd_hash'}};
4872  
4873 # Import this Axmud version's client command and user command hashes for quick
4874 # lookup
4875 %standardHash = $client->clientCmdHash;
4876 %currentHash = $client->userCmdHash;
4877  
4878 # From the loaded hash of user commands, filter out any which relate to (standard)
4879 # client commands which aren't being used by this version of Axmud
4880 foreach my $userCmd (keys %hash) {
4881  
4882 my $standardCmd = $hash{$userCmd};
4883  
4884 if (exists $standardHash{$userCmd}) {
4885  
4886 $newLoadHash{$userCmd} = $standardCmd;
4887 # Also build a hash of all the standard commands used in the loaded file
4888 $loadStandardHash{$standardCmd} = undef;
4889  
4890 } else {
4891  
4892 # At least one command filtered out, so the data in memory won't match the
4893 # data file
4894 $modFlag = TRUE;
4895 }
4896 }
4897  
4898 # From the current hash of user commands, retain any user commands which correspond
4899 # to (standard) client commands not used in the loaded file
4900 foreach my $userCmd (keys %currentHash) {
4901  
4902 my $standardCmd = $currentHash{$userCmd};
4903  
4904 if (! exists $loadStandardHash{$standardCmd}) {
4905  
4906 # Retain this command
4907 $newLoadHash{$userCmd} = $standardCmd;
4908 # At least one command retained, so the data in memory won't match the data
4909 # file
4910 $modFlag = TRUE;
4911 }
4912 }
4913  
4914 # Replace the client's current list of user commands
4915 $client->ivPoke('userCmdHash', %newLoadHash);
4916  
4917 if ($modFlag) {
4918 $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData');
4919 } else {
4920 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4921 }
4922  
4923 } else {
4924  
4925 # (Should not be able to import a partial 'usercmds' file, since
4926 # $self->exportDataFile doesn't create one)
4927 return undef;
4928 }
4929  
4930 } elsif ($self->fileType eq 'zonemaps') {
4931  
4932 # (T) All zonemaps in memory are replaced. The workspace grids used by all sessions are
4933 # reset (when they exist). Any workspaces using a default zonemap which no longer
4934 # exists are given a new default zonemap. Any workspace grids using a zonemap which no
4935 # longer exists are reset to use the workspace's default zonemap
4936 # (F) Loaded data incorporated into memory. Any workspace grids using a loaded zonemap
4937 # are reset
4938  
4939 if ($overWriteFlag) {
4940  
4941 # Replace the data in memory
4942 $client->ivPoke('zonemapHash', %{$loadHash{'zonemap_hash'}});
4943 $client->ivPoke('standardZonemapHash', %{$loadHash{'standard_zonemap_hash'}});
4944  
4945 # Check that the default zonemap for all workspaces still exists and, if not,
4946 # replace it with a standard one
4947 foreach my $workspaceObj ($axmud::CLIENT->desktopObj->ivValues('workspaceHash')) {
4948  
4949 if (
4950 $workspaceObj->defaultZonemap
4951 && ! $axmud::CLIENT->ivExists('zonemapHash', $workspaceObj->defaultZonemap)
4952 ) {
4953 if ($axmud::CLIENT->shareMainWinFlag) {
4954 $workspaceObj->set_defaultZonemap('basic');
4955 } else {
4956 $workspaceObj->set_defaultZonemap('single');
4957 }
4958 }
4959  
4960 # Reset all workspace grids, changing the zonemap used by any workspace grid
4961 # when that zonemap no longer exists
4962 foreach my $gridObj ($workspaceObj->ivValues('gridHash')) {
4963  
4964 my ($obj, $defaultObj);
4965  
4966 $obj = $axmud::CLIENT->ivShow('zonemapHash', $gridObj->zonemap);
4967 if (! $obj) {
4968  
4969 $defaultObj = $axmud::CLIENT->ivShow(
4970 'zonemapHash',
4971 $workspaceObj->defaultZonemap,
4972 );
4973  
4974  
4975 $gridObj->applyZonemap($defaultObj);
4976 }
4977 }
4978 }
4979  
4980 # The data in memory matches saved data files
4981 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
4982  
4983 } else {
4984  
4985 # We are loading one or more global zonemap objects that have been exported and
4986 # must be re-incorporated into memory
4987  
4988 # Incorporate zonemap objects
4989 %hash = %{$loadHash{'zonemap_hash'}};
4990 if (%hash) {
4991  
4992 foreach my $zonemapObj (values %hash) {
4993  
4994 $client->add_zonemap($zonemapObj);
4995 }
4996 }
4997  
4998 # Any workspace grids using one of the incorporated zonemaps must be reset
4999 foreach my $gridObj ($axmud::CLIENT->desktopObj->ivValues('gridHash')) {
5000  
5001 if ($gridObj->zonemap && exists $hash{$gridObj->zonemap}) {
5002  
5003 $gridObj->applyZonemap(
5004 $axmud::CLIENT->ivShow('zonemapHash', $gridObj->zonemap),
5005 );
5006 }
5007 }
5008  
5009 # (Calls to accessors will have set the right ->modifyFlag values)
5010 }
5011  
5012 } elsif ($self->fileType eq 'winmaps') {
5013  
5014 # (T) All winmaps/colour schemes in memory are replaced; no existing windows are
5015 # affected, since winmaps are only applied when a window is created, and
5016 # colour schemes are only applied periodically
5017 # (F) Loaded data incorporated into memory
5018  
5019 if ($overWriteFlag) {
5020  
5021 # Replace the data in memory
5022 $client->ivPoke('winmapHash', %{$loadHash{'winmap_hash'}});
5023 $client->ivPoke('standardWinmapHash', %{$loadHash{'standard_winmap_hash'}});
5024 $client->ivPoke('defaultEnabledWinmap', $loadHash{'default_enabled_winmap'});
5025 $client->ivPoke('defaultDisabledWinmap', $loadHash{'default_disabled_winmap'});
5026 $client->ivPoke('defaultInternalWinmap', $loadHash{'default_internal_winmap'});
5027 $client->ivPoke('colourSchemeHash', %{$loadHash{'colour_scheme_hash'}});
5028  
5029 # The data in memory matches saved data files
5030 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
5031  
5032 } else {
5033  
5034 # We are loading one or more global winmap objects that have been exported and
5035 # must be re-incorporated into memory
5036  
5037 # Incorporate winmap objects
5038 %hash = %{$loadHash{'winmap_hash'}};
5039 if (%hash) {
5040  
5041 foreach my $winmapObj (values %hash) {
5042  
5043 $client->add_winmap($winmapObj);
5044 }
5045 }
5046  
5047 # Incorporate colour schemes
5048 %hash = %{$loadHash{'colour_scheme_hash'}};
5049 if (%hash) {
5050  
5051 foreach my $obj (values %hash) {
5052  
5053 $client->add_colourScheme($obj);
5054 }
5055 }
5056  
5057 # (Calls to accessors will have set the right ->modifyFlag values)
5058 }
5059  
5060 } elsif ($self->fileType eq 'tts') {
5061  
5062 # 'tts'
5063 # (T) All existing data in memory replaced by loaded data
5064 # (F) Loaded data incorporated into memory
5065  
5066 if ($overWriteFlag) {
5067  
5068 # Replace the data in memory
5069 $client->ivPoke('ttsObjHash', %{$loadHash{'tts_obj_hash'}});
5070  
5071 # The data in memory matches saved data files
5072 $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
5073  
5074 } else {
5075  
5076 # We are loading one or more global TTS objects that have been exported and
5077 # must be re-incorporated into memory
5078  
5079 # Incorporate TTS objects
5080 %hash = %{$loadHash{'tts_obj_hash'}};
5081 if (%hash) {
5082  
5083 foreach my $ttsObj (values %hash) {
5084  
5085 $client->add_ttsObj($ttsObj);
5086 }
5087 }
5088  
5089 # (Calls to accessors will have set the right ->modifyFlag values)
5090 }
5091 }
5092  
5093 # Update the loaded data from previous versions of Axmud to conform to the current version
5094 # of Axmud
5095 $self->updateExtractedData();
5096  
5097 # Return the file type
5098 return $loadHash{'file_type'};
5099 }
5100  
5101 sub updateExtractedData {
5102  
5103 # Called by $self->extractData (also called by GA::Profile::World->mergeData at the end of
5104 # an ';updateworld' operation)
5105 # Data loaded from previous versions of Axmud may be incompatible with the present version.
5106 # Update the loaded data, as and where necessary
5107 # NB Some data is also updated by $self->updateDataAfterRename
5108 #
5109 # Expected arguments
5110 # (none besides $self)
5111 #
5112 # Optional arguments
5113 # $version - When called by $self->extractData, the extracted data belongs to the Axmud
5114 # version stored in $self->scriptConvertVersion, and this argument is
5115 # 'undef'. When called by GA::Profile::World->mergeData, this argument is
5116 # set to the Axmud version of the imported data's file (in the same
5117 # format)
5118 #
5119 # Return values
5120 # 'undef' on improper arguments
5121 # 1 otherwise
5122  
5123 my ($self, $version, $check) = @_;
5124  
5125 # Local variables
5126 my $wmObj;
5127  
5128 # Check for improper arguments
5129 if (defined $check) {
5130  
5131 return $axmud::CLIENT->writeImproper($self->_objClass . '->updateExtractedData', @_);
5132 }
5133  
5134 if (! defined $version) {
5135  
5136 # This function called by $self->extractData
5137 $version = $self->scriptConvertVersion;
5138 }
5139  
5140 ### worldprof / otherprof #################################################################
5141  
5142 if ($self->fileType eq 'worldprof' || $self->fileType eq 'otherprof') {
5143  
5144 if ($version < 1_000_029 && $self->session) {
5145  
5146 # Update every command cage with new standard commands
5147 foreach my $cage ($self->session->ivValues('cageHash')) {
5148  
5149 if ($cage->{cageType} eq 'cmd') {
5150  
5151 if (! $cage->ivExists('cmdHash', 'short_look')) {
5152  
5153 $cage->ivAdd('cmdHash', 'short_look', 'l');
5154 }
5155  
5156 if (! $cage->ivExists('cmdHash', 'short_glance')) {
5157  
5158 $cage->ivAdd('cmdHash', 'short_glance', 'gl');
5159 }
5160 }
5161 }
5162 }
5163  
5164 if ($version < 1_000_039) {
5165  
5166 # Update world profiles with a new IV
5167 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5168  
5169 if (! exists $profObj->{excessCmdDelay}) {
5170  
5171 # Create the IV...
5172 $profObj->{excessCmdDelay} = undef;
5173 # By setting its default value using ->ivPoke, we make sure the correct
5174 # GA::Obj::File object's ->modifyFlag is set automatically
5175 $profObj->ivPoke('excessCmdDelay', 1);
5176 }
5177 }
5178 }
5179  
5180 if ($version < 1_000_044) {
5181  
5182 # Update room statement components with a new IV
5183 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5184  
5185 foreach my $compObj ($profObj->ivValues('componentHash')) {
5186  
5187 if (! exists $compObj->{useTextColour}) {
5188  
5189 $compObj->{useTextColour} = undef;
5190 $compObj->ivUndef('useTextColour');
5191 # (This IV subsequently renamed and/or removed)
5192 # $compObj->{ignoreChars} = undef;
5193 # $compObj->ivPoke('ignoreChars', 0);
5194 $compObj->{ignoreChars} = 0;
5195 }
5196 }
5197 }
5198 }
5199  
5200 if ($version < 1_000_066 && $self->session) {
5201  
5202 # This version fixes a problem in GA::Profile::Char->fightVictimStringHash and
5203 # ->interactionVictimStringHash
5204 foreach my $profObj ($self->session->ivValues('profHash')) {
5205  
5206 my $hashRef;
5207  
5208 if ($profObj->{category} eq 'char') {
5209  
5210 $hashRef = $profObj->{fightVictimStringHash};
5211 if (%$hashRef) {
5212  
5213 my (%oldHash, %newHash);
5214  
5215 %oldHash = %$hashRef;
5216 foreach my $key (keys %oldHash) {
5217  
5218 my $value = $oldHash{$key};
5219  
5220 # All keys must now be lower-case
5221 $key = lc($key);
5222 if (exists $newHash{$key}) {
5223 $newHash{$key} = $newHash{$key} + $value;
5224 } else {
5225 $newHash{$key} = $value;
5226 }
5227 }
5228  
5229 $profObj->ivPoke('fightVictimStringHash', %newHash);
5230 }
5231  
5232 $hashRef = $profObj->{interactionVictimStringHash};
5233 if (%$hashRef) {
5234  
5235 my (%oldHash, %newHash);
5236  
5237 %oldHash = %$hashRef;
5238 foreach my $key (keys %oldHash) {
5239  
5240 my $value = $oldHash{$key};
5241  
5242 # All keys must now be lower-case
5243 $key = lc($key);
5244 if (exists $newHash{$key}) {
5245 $newHash{$key} = $newHash{$key} + $value;
5246 } else {
5247 $newHash{$key} = $value;
5248 }
5249 }
5250  
5251 $profObj->ivPoke('interactionVictimStringHash', %newHash);
5252 }
5253 }
5254 }
5255 }
5256  
5257 if ($version < 1_000_076) {
5258  
5259 # Update room statement components with new IVs
5260 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5261  
5262 foreach my $compObj ($profObj->ivValues('componentHash')) {
5263  
5264 # Rename ->ignoreChars as ->ignoreFirstChars. For some reason, ->ignoreChars
5265 # seems to be set to 'undef' in components created in previous Axmud
5266 # versions; not sure why, but this code fixes it
5267 if (! exists $compObj->{ignoreFirstChars}) {
5268  
5269 $compObj->{ignoreFirstChars} = undef;
5270  
5271 if (exists $compObj->{ignoreChars}) {
5272 $compObj->ivPoke('ignoreFirstChars', $compObj->{ignoreChars});
5273 } else {
5274 $compObj->ivPoke('ignoreFirstChars', 0);
5275 }
5276 }
5277  
5278 if (! defined $compObj->{ignoreFirstChars}) {
5279  
5280 $compObj->ivPoke('ignoreFirstChars', $compObj->{ignoreChars});
5281 }
5282  
5283 delete $compObj->{ignoreChars};
5284  
5285 $compObj->{useFirstChars} = undef;
5286 $compObj->ivPoke('useFirstChars', 0);
5287 # (This IV subsequently renamed and/or removed)
5288 # $compObj->{usePatternBackRefs} = undef;
5289 # $compObj->ivUndef('usePatternBackRefs');
5290 $compObj->{usePatternBackRefs} = undef;
5291 }
5292 }
5293 }
5294  
5295 if ($version < 1_000_077) {
5296  
5297 # Update world profiles with new IVs
5298 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5299  
5300 if (! exists $profObj->{verboseFinalPattern}) {
5301  
5302 $profObj->{verboseFinalPattern} = undef;
5303 $profObj->ivUndef('verboseFinalPattern');
5304 $profObj->{shortFinalPattern} = undef;
5305 $profObj->ivUndef('shortFinalPattern');
5306 $profObj->{briefFinalPattern} = undef;
5307 $profObj->ivUndef('briefFinalPattern');
5308 }
5309 }
5310 }
5311  
5312 if ($version < 1_000_090) {
5313  
5314 # This version updates the Status task, using a single string (e.g.
5315 # 'health_points_max') rather than two strings to represent the same thing (e.g.
5316 # 'health_max', 'health_points_max'. The Status task is updated below; here we
5317 # updated a parallel IV in the world profile
5318 my %updateHash = (
5319 '@health_max@' => '@health_points_max@',
5320 '@magic_max@' => '@magic_points_max@',
5321 '@energy_max@' => '@energy_points_max@',
5322 '@guild_max@' => '@guild_points_max@',
5323 '@social_max@' => '@social_points_max@',
5324 );
5325  
5326 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5327  
5328 my $listRef = $profObj->{displayFormatList};
5329 foreach my $line (@$listRef) {
5330  
5331 foreach my $key (keys %updateHash) {
5332  
5333 my $value = $updateHash{$key};
5334  
5335 $line =~ s/$key/$value/g;
5336 }
5337 }
5338 }
5339 }
5340  
5341 if ($version < 1_000_150) {
5342  
5343 # Update world profiles with new stuff
5344 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5345  
5346 my $listRef;
5347  
5348 # New IV
5349 if (! exists $profObj->{currencyRounding}) {
5350  
5351 $profObj->{currencyRounding} = undef;
5352 $profObj->ivPoke('currencyRounding', 3);
5353 }
5354  
5355 # In ->inventoryPatternList, the type 'empty' has been replaced by
5356 # 'empty_purse', so update the list [in groups of 5)
5357 $listRef = $profObj->{inventoryPatternList};
5358 if (@$listRef) {
5359  
5360 my (
5361 $changeFlag,
5362 @modList,
5363 );
5364  
5365 do {
5366  
5367 my ($pattern, $backRef, $type, $gag, $posn);
5368  
5369 $pattern = shift @$listRef;
5370 $backRef = shift @$listRef;
5371 $type = shift @$listRef;
5372 $gag = shift @$listRef;
5373 $posn = shift @$listRef;
5374  
5375 if ($type eq 'empty') {
5376  
5377 $type = 'empty_purse';
5378 $changeFlag = TRUE;
5379 }
5380  
5381 push (@modList, $pattern, $backRef, $type, $gag, $posn);
5382  
5383 } until (! @$listRef);
5384  
5385 if ($changeFlag) {
5386  
5387 $profObj->ivPoke('inventoryPatternList', @modList);
5388 }
5389 }
5390 }
5391 }
5392  
5393 if ($version < 1_000_159) {
5394  
5395 # This version changes the way a world profile's ->termType operates; it must now be
5396 # one of the values in GA::Client->constTermTypeList (or 'undef')
5397 # Check every world profile; if its ->termType is set to a value that's not in
5398 # ->constTermTypeList replace it with the first item ->constTermTypeList
5399 OUTER: foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5400  
5401 my ($listRef, $matchFlag);
5402  
5403 if (defined $profObj->{termType}) {
5404  
5405 $listRef = $axmud::CLIENT->{constTermTypeList};
5406 INNER: foreach my $termType (@$listRef) {
5407  
5408 if ($termType eq $profObj->{termType}) {
5409  
5410 $matchFlag = TRUE;
5411 last INNER;
5412 }
5413 }
5414  
5415 if (! $matchFlag) {
5416  
5417 # User has set an unrecognised termtype; replace it with 'ansi'
5418 $profObj->ivPoke(
5419 'termType',
5420 $axmud::CLIENT->ivFirst('constTermTypeList'),
5421 );
5422 }
5423 }
5424  
5425 # Also rename an existing IV
5426 if (exists $profObj->{sendTermInfoFlag}) {
5427  
5428 $profObj->{sendSizeInfoFlag} = undef;
5429 $profObj->ivPoke('sendSizeInfoFlag', $profObj->{sendTermInfoFlag});
5430 delete $profObj->{sendTermInfoFlag};
5431 }
5432 }
5433 }
5434  
5435 if ($version < 1_000_163) {
5436  
5437 # This version changes the default values of two IVs from 'undef' to 0
5438 OUTER: foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5439  
5440 if (! defined $profObj->{columns}) {
5441  
5442 $profObj->ivPoke('columns', 0);
5443 }
5444  
5445 if (! defined $profObj->{rows}) {
5446  
5447 $profObj->ivPoke('rows', 0);
5448 }
5449 }
5450 }
5451  
5452 if ($version < 1_000_165) {
5453  
5454 # Update world profiles with new IVs
5455 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5456  
5457 if (! exists $profObj->{msspGenericValueHash}) {
5458  
5459 $profObj->{msspGenericValueHash} = {};
5460 $profObj->ivEmpty('msspGenericValueHash');
5461 $profObj->{msspCustomValueHash} = {};
5462 $profObj->ivEmpty('msspCustomValueHash');
5463 }
5464 }
5465 }
5466  
5467 if ($version < 1_000_181 && $self->session) {
5468  
5469 # This version changes the name of two trigger attributes, and adds new ones. Update
5470 # every trigger cage
5471 foreach my $cage ($self->session->ivValues('cageHash')) {
5472  
5473 if ($cage->{cageType} eq 'trigger') {
5474  
5475 foreach my $trigObj ($cage->ivValues('interfaceHash')) {
5476  
5477 $trigObj->ivAdd(
5478 'attribHash',
5479 'style_text',
5480 $trigObj->ivShow('attribHash', 'style_fg'),
5481 );
5482  
5483 $trigObj->ivDelete('attribHash', 'style_fg');
5484  
5485 $trigObj->ivAdd(
5486 'attribHash',
5487 'style_underlay',
5488 $trigObj->ivShow('attribHash', 'style_bg'),
5489 );
5490  
5491 $trigObj->ivDelete('attribHash', 'style_bg');
5492  
5493 $trigObj->ivAdd('attribHash', 'style_blink_slow', 0);
5494 $trigObj->ivAdd('attribHash', 'style_blink_fast', 0);
5495 }
5496 }
5497 }
5498 }
5499  
5500 if ($version < 1_000_186) {
5501  
5502 # Update world profiles with new IVs
5503 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5504  
5505 if (! exists $profObj->{worldCharSet}) {
5506  
5507 $profObj->{worldCharSet} = undef;
5508 $profObj->ivUndef('worldCharSet');
5509 }
5510 }
5511 }
5512  
5513 if ($version < 1_000_188) {
5514  
5515 # Update world profiles with new IVs
5516 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5517  
5518 if (! exists $profObj->{exitRemovePatternList}) {
5519  
5520 $profObj->{exitRemovePatternList} = [];
5521 $profObj->ivEmpty('exitRemovePatternList');
5522 }
5523 }
5524 }
5525  
5526 if ($version < 1_000_189) {
5527  
5528 # Update world profiles with new IVs
5529 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5530  
5531 if (! exists $profObj->{exitStateIgnoreList}) {
5532  
5533 # (This IV subsequently renamed and/or removed)
5534 # $profObj->{exitStateIgnoreList} = [];
5535 # $profObj->ivEmpty('exitStateIgnoreList');
5536 $profObj->{exitStateIgnoreList} = [];
5537 }
5538 }
5539 }
5540  
5541 if ($version < 1_000_198) {
5542  
5543 # Update world profiles with new IVs
5544 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5545  
5546 my $listRef;
5547  
5548 if (! exists $profObj->{affectPatternList}) {
5549  
5550 $profObj->{affectPatternList} = [];
5551 $profObj->ivEmpty('affectPatternList');
5552 }
5553  
5554 # In ->barPatternList, the type 'xp' has been replaced by 'xp_current', so
5555 # update the list [in groups of 6)
5556 $listRef = $profObj->{barPatternList};
5557 if (@$listRef) {
5558  
5559 my (
5560 $changeFlag,
5561 @modList,
5562 );
5563  
5564 do {
5565  
5566 my ($pattern, $backRef, $type, $gag, $string, $posn);
5567  
5568 $pattern = shift @$listRef;
5569 $backRef = shift @$listRef;
5570 $type = shift @$listRef;
5571 $gag = shift @$listRef;
5572 $string = shift @$listRef;
5573 $posn = shift @$listRef;
5574  
5575 if ($type eq 'xp') {
5576  
5577 $type = 'xp_current';
5578 $changeFlag = TRUE;
5579 }
5580  
5581 push (@modList, $pattern, $backRef, $type, $gag, $string, $posn);
5582  
5583 } until (! @$listRef);
5584  
5585 if ($changeFlag) {
5586  
5587 $profObj->ivPoke('barPatternList', @modList);
5588 }
5589 }
5590 }
5591  
5592 if ($self->session) {
5593  
5594 # Update character profiles with new IVs
5595 foreach my $profObj ($self->session->ivValues('profHash')) {
5596  
5597 if ($profObj->{category} eq 'char' && ! exists $profObj->{xpNextLevel}) {
5598  
5599 $profObj->{xpNextLevel} = undef;
5600 $profObj->ivUndef('xpNextLevel');
5601 $profObj->{alignment} = undef;
5602 $profObj->ivUndef('alignment');
5603 $profObj->{affectHash} = {};
5604 $profObj->ivEmpty('affectHash');
5605 }
5606 }
5607 }
5608 }
5609  
5610 if ($version < 1_000_206) {
5611  
5612 # Update room statement components with new IVs
5613 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5614  
5615 foreach my $compObj ($profObj->ivValues('componentHash')) {
5616  
5617 if (! exists $compObj->{analyseMode}) {
5618  
5619 $compObj->{analyseMode} = undef;
5620 $compObj->ivPoke('analyseMode', 0);
5621 }
5622 }
5623 }
5624 }
5625  
5626 if ($version < 1_000_210 && $self->session) {
5627  
5628 # Update every command cage with a new standard command
5629 foreach my $cage ($self->session->ivValues('cageHash')) {
5630  
5631 if ($cage->{cageType} eq 'cmd') {
5632  
5633 if (! $cage->ivExists('cmdHash', 'connect')) {
5634  
5635 $cage->ivAdd('cmdHash', 'connect', 'connect name password');
5636 }
5637 }
5638 }
5639 }
5640  
5641 if ($version < 1_000_210) {
5642  
5643 # Update world profiles with new IVs
5644 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5645  
5646 my $listRef;
5647  
5648 if (! exists $profObj->{loginConnectPatternList}) {
5649  
5650 # One new IV
5651 $profObj->{loginConnectPatternList} = [];
5652 $profObj->ivEmpty('loginConnectPatternList');
5653 }
5654  
5655 if (exists $profObj->{loginPatternList}) {
5656  
5657 # One renamed IV
5658 $profObj->{loginSuccessPatternList} = [];
5659 $listRef = $profObj->{loginPatternList};
5660 $profObj->ivPoke('loginSuccessPatternList', @$listRef);
5661 delete $profObj->{loginPatternList};
5662 }
5663 }
5664 }
5665  
5666 if ($version < 1_000_212) {
5667  
5668 # Update world profiles with new IVs
5669 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5670  
5671 if (! exists $profObj->{customStatusVarHash}) {
5672  
5673 # (This IV subsequently renamed and/or removed)
5674 # $profObj->{customStatusVarHash} = {};
5675 # $profObj->ivEmpty('customStatusVarHash');
5676 $profObj->{customStatusVarHash} = {};
5677 }
5678 }
5679 }
5680  
5681 if ($version < 1_000_213) {
5682  
5683 # Update world profiles with a new IV
5684 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5685  
5686 if (! exists $profObj->{exitInfoPatternList}) {
5687  
5688 $profObj->{exitInfoPatternList} = [];
5689 $profObj->ivEmpty('exitInfoPatternList');
5690 }
5691 }
5692 }
5693  
5694 if ($version < 1_000_220) {
5695  
5696 # Update world profiles with new IVs
5697 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5698  
5699 if (! exists $profObj->{fightDefeatPatternList}) {
5700  
5701 $profObj->{fightDefeatPatternList} = [];
5702 $profObj->ivEmpty('fightDefeatPatternList');
5703 $profObj->{wimpyEngagedPatternList} = [];
5704 $profObj->ivEmpty('wimpyEngagedPatternList');
5705 $profObj->{noFightDefeatPatternList} = [];
5706 $profObj->ivEmpty('noFightDefeatPatternList');
5707 $profObj->{noWimpyEngagedPatternList} = [];
5708 $profObj->ivEmpty('noWimpyEngagedPatternList');
5709 }
5710 }
5711 }
5712  
5713 if ($version < 1_000_228 && $self->session) {
5714  
5715 # This version adds a new trigger attribute. Update every trigger cage
5716 foreach my $cage ($self->session->ivValues('cageHash')) {
5717  
5718 if ($cage->{cageType} eq 'trigger') {
5719  
5720 foreach my $trigObj ($cage->ivValues('interfaceHash')) {
5721  
5722 $trigObj->ivAdd('attribHash', 'rewrite_global', 0);
5723 }
5724 }
5725 }
5726 }
5727  
5728 if ($version < 1_000_239 && $self->session) {
5729  
5730 # This version adds a new trigger attribute. Update every trigger cage
5731 foreach my $cage ($self->session->ivValues('cageHash')) {
5732  
5733 if ($cage->{cageType} eq 'trigger') {
5734  
5735 foreach my $trigObj ($cage->ivValues('interfaceHash')) {
5736  
5737 $trigObj->ivAdd('attribHash', 'need_login', 0);
5738 }
5739 }
5740 }
5741 }
5742  
5743 if ($version < 1_000_252) {
5744  
5745 # Update world profiles with new IVs
5746 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5747  
5748 if (! exists $profObj->{strictPromptsMode}) {
5749  
5750 # (This IV subsequently renamed and/or removed)
5751 # $profObj->{strictPromptsMode} = undef;
5752 # $profObj->ivPoke('strictPromptsMode', FALSE);
5753 $profObj->{strictPromptsMode} = undef;
5754 }
5755 }
5756 }
5757  
5758 if ($version < 1_000_297 && $self->session) {
5759  
5760 # Update every command cage with new standard commands
5761 foreach my $cage ($self->session->ivValues('cageHash')) {
5762  
5763 if ($cage->{cageType} eq 'cmd') {
5764  
5765 if (! $cage->ivExists('cmdHash', 'squeeze')) {
5766  
5767 $cage->ivAdd('cmdHash', 'squeeze', 'squeeze direction');
5768 }
5769 }
5770 }
5771 }
5772  
5773 if ($version < 1_000_300) {
5774  
5775 # Update world profiles with new IVs
5776 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5777  
5778 if (! exists $profObj->{exitStateDarkList}) {
5779  
5780 # (This IV subsequently renamed and/or removed)
5781 # $profObj->{exitStateDarkList} = [];
5782 # $profObj->ivEmpty('exitStateDarkList');
5783 $profObj->{exitStateDarkList} = [];
5784 # (This IV subsequently renamed and/or removed)
5785 # $profObj->{exitStateDangerList} = [];
5786 # $profObj->ivEmpty('exitStateDangerList');
5787 $profObj->{exitStateDangerList} = [];
5788 }
5789 }
5790 }
5791  
5792 if ($version < 1_000_301) {
5793  
5794 # Update world profiles with a new hash IV
5795 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5796  
5797 if (! exists $profObj->{accountHash}) {
5798  
5799 # Create the IV
5800 $profObj->{accountHash} = {};
5801 $profObj->ivEmpty('accountHash');
5802  
5803 # The IV should have the same keys as the existing ->passwordHash IV, but
5804 # the matching values should all be 'undef'
5805 foreach my $key ($profObj->ivKeys('passwordHash')) {
5806  
5807 $profObj->ivAdd('accountHash', $key, undef);
5808 }
5809 }
5810 }
5811 }
5812  
5813 if ($version < 1_000_302) {
5814  
5815 # Update world profiles with a new IV
5816 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5817  
5818 if (! exists $profObj->{newAccountHash}) {
5819  
5820 # Create the IV
5821 $profObj->{newAccountHash} = {};
5822 $profObj->ivEmpty('newAccountHash');
5823 }
5824 }
5825 }
5826  
5827 if ($version < 1_000_306) {
5828  
5829 # Update room statement components with new IVs
5830 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5831  
5832 foreach my $compObj ($profObj->ivValues('componentHash')) {
5833  
5834 if (! exists $compObj->{startTagMode}) {
5835  
5836 $compObj->{startTagMode} = undef;
5837 $compObj->ivPoke('startTagMode', 0);
5838 # (This IV subsequently renamed and/or removed)
5839 # $compObj->{stopTagMode} = undef;
5840 # $compObj->ivPoke('stopTagMode', 0);
5841 $compObj->{stopTagMode} = 0;
5842 $compObj->{skipTagMode} = undef;
5843 $compObj->ivPoke('skipTagMode', 0);
5844 $compObj->{stopBeforeNoTagMode} = undef;
5845 $compObj->ivPoke('stopBeforeNoTagMode', 0);
5846 $compObj->{stopBeforeTagMode} = undef;
5847 $compObj->ivPoke('stopBeforeTagMode', 0);
5848 $compObj->{stopAtNoTagMode} = undef;
5849 $compObj->ivPoke('stopAtNoTagMode', 0);
5850 $compObj->{stopAtTagMode} = undef;
5851 $compObj->ivPoke('stopAtTagMode', 0);
5852 }
5853 }
5854 }
5855 }
5856  
5857 if ($version < 1_000_315 && $self->session) {
5858  
5859 # This version adds new trigger attributes. Update every trigger cage
5860 foreach my $cage ($self->session->ivValues('cageHash')) {
5861  
5862 if ($cage->{cageType} eq 'trigger') {
5863  
5864 foreach my $trigObj ($cage->ivValues('interfaceHash')) {
5865  
5866 $trigObj->ivAdd('attribHash', 'splitter', 0);
5867 $trigObj->ivAdd('attribHash', 'split_after', 0);
5868 $trigObj->ivAdd('attribHash', 'keep_splitting', 0);
5869 }
5870 }
5871 }
5872 }
5873  
5874 if ($version < 1_000_318) {
5875  
5876 # Update room statement components, adding some new IVs and removing some other
5877 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5878  
5879 foreach my $compObj ($profObj->ivValues('componentHash')) {
5880  
5881 my ($patternListRef, $tagListRef);
5882  
5883 if (! exists $compObj->{startNoPatternList}) {
5884  
5885 $compObj->{startNoPatternList} = [];
5886 $compObj->ivEmpty('startNoPatternList');
5887 $compObj->{startNoTagList} = [];
5888 $compObj->ivEmpty('startNoTagList');
5889 $compObj->{startNoAllFlag} = undef;
5890 $compObj->ivPoke('startNoAllFlag', FALSE);
5891 $compObj->{startNoTagMode} = undef;
5892 $compObj->ivPoke('startNoTagMode', 0);
5893  
5894 # The existing contents of ->stopPatternList (etc) must be transferred
5895 # to ->stopAtPatternList, without duplicating anything
5896 $patternListRef = $compObj->{stopPatternList};
5897 OUTER: foreach my $item (@$patternListRef) {
5898  
5899 my ($stopListRef, $matchFlag);
5900  
5901 $stopListRef = $compObj->{stopAtPatternList};
5902 INNER: foreach my $other (@$stopListRef) {
5903  
5904 if ($other eq $item) {
5905  
5906 $matchFlag = TRUE;
5907 last INNER;
5908 }
5909 }
5910  
5911 if (! $matchFlag) {
5912  
5913 $compObj->ivPush('stopAtPatternList', $item);
5914 }
5915 }
5916  
5917 $tagListRef = $compObj->{stopTagList};
5918 OUTER: foreach my $item (@$tagListRef) {
5919  
5920 my ($stopListRef, $matchFlag);
5921  
5922 $stopListRef = $compObj->{stopAtTagList};
5923 INNER: foreach my $other (@$stopListRef) {
5924  
5925 if ($other eq $item) {
5926  
5927 $matchFlag = TRUE;
5928 last INNER;
5929 }
5930 }
5931  
5932 if (! $matchFlag) {
5933  
5934 $compObj->ivPush('stopAtTagList', $item);
5935 }
5936 }
5937  
5938 # (We'll assume that ->stopAllFlag and ->stopTagMode should override
5939 # the existing settings of ->stopAtAllFlag and ->stopAtTagMode,
5940 # since ->stop... was formerly more important thatn ->stopAt...)
5941 if ($compObj->{stopAllFlag}) {
5942  
5943 $compObj->ivPoke('stopAtAllFlag', TRUE);
5944 }
5945  
5946 if ($compObj->{stopTagMode}) {
5947  
5948 $compObj->ivPoke('stopAtTagMode', $compObj->{stopTagMode});
5949 }
5950  
5951 # We can now remove the old IVs
5952 delete $compObj->{stopPatternList};
5953 delete $compObj->{stopTagList};
5954 delete $compObj->{stopAllFlag};
5955 delete $compObj->{stopTagMode};
5956 }
5957 }
5958 }
5959 }
5960  
5961 if ($version < 1_000_320) {
5962  
5963 # Update room statement components with a new IV
5964 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5965  
5966 foreach my $compObj ($profObj->ivValues('componentHash')) {
5967  
5968 if (! exists $compObj->{useAppliedTagsFlag}) {
5969  
5970 # (This IV subsequently renamed and/or removed)
5971 # $compObj->{useAppliedTagsFlag} = undef;
5972 # $compObj->ivPoke('useAppliedTagsFlag', FALSE);
5973 $compObj->{useAppliedTagsFlag} = FALSE;
5974 }
5975 }
5976 }
5977 }
5978  
5979 if ($version < 1_000_324) {
5980  
5981 # Update room statement components with a new IV, which replaces an old one, but
5982 # reverses its setting
5983 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
5984  
5985 foreach my $compObj ($profObj->ivValues('componentHash')) {
5986  
5987 if (exists $compObj->{boldInsensitiveFlag}) {
5988  
5989 $compObj->{boldSensitiveFlag} = undef;
5990 if ($compObj->{boldInsensitiveFlag}) {
5991 $compObj->ivPoke('boldSensitiveFlag', FALSE);
5992 } else {
5993 $compObj->ivPoke('boldSensitiveFlag', TRUE);
5994 }
5995  
5996 delete $compObj->{boldInsensitiveFlag};
5997 }
5998 }
5999 }
6000 }
6001  
6002 if ($version < 1_000_330) {
6003  
6004 # This version replaces several IVs (->exitStateOpenList, ->exitStateClosedList,
6005 # etc) with a single list IV, in groups of 4
6006  
6007 my %stateHash = (
6008 'exitStateOpenList' => 'open',
6009 'exitStateClosedList' => 'closed',
6010 'exitStateLockedList' => 'locked',
6011 'exitStateImpassList' => 'impass',
6012 'exitStateDarkList' => 'dark',
6013 'exitStateDangerList' => 'danger',
6014 'exitStateOtherList' => 'other',
6015 'exitStateIgnoreList' => 'ignore',
6016 );
6017  
6018 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6019  
6020 my @newList;
6021  
6022 if (! exists $profObj->{exitStateStringList}) {
6023  
6024 foreach my $iv (keys %stateHash) {
6025  
6026 my ($state, $listRef, $start, $middle, $end, $flag);
6027  
6028 $state = $stateHash{$iv};
6029 $listRef = $profObj->{$iv};
6030  
6031 if (@$listRef) {
6032  
6033 ($start, $end, $flag) = @$listRef;
6034 # () - There are no strings for this exit state
6035 # ('') - There are no strings for this exit state
6036 # ('', '') - There are no strings for this exit state
6037 if ($start || $end) {
6038  
6039 # (string1) - String(s) appear at the beginning of the exit
6040 if ($start && ! $end) {
6041  
6042 push (@newList, $state, $start, '', '');
6043  
6044 # ('', string2) - String(s) appear at the end of the exit
6045 } elsif (! $start && $end) {
6046  
6047 if ($flag) {
6048 push (@newList, $state, '', $end, '');
6049 } else {
6050 push (@newList, $state, '', '', $end);
6051 }
6052  
6053 # (string1, string2)
6054 # - String(s) appear at the beginning and end
6055 # (string1, string2, TRUE)
6056 # - String(s) appear at the beginning and middle
6057 } else {
6058  
6059 if ($flag) {
6060 push (@newList, $state, $start, $end, '');
6061 } else {
6062 push (@newList, $state, $start, '', $end);
6063 }
6064 }
6065 }
6066 }
6067 }
6068  
6069 # Create the new combined list IV
6070 $profObj->{exitStateStringList} = [];
6071 $profObj->ivPoke('exitStateStringList', @newList);
6072 # And delete the old ones
6073 delete $profObj->{exitStateOpenList};
6074 delete $profObj->{exitStateClosedList};
6075 delete $profObj->{exitStateLockedList};
6076 delete $profObj->{exitStateImpassList};
6077 delete $profObj->{exitStateDarkList};
6078 delete $profObj->{exitStateDangerList};
6079 delete $profObj->{exitStateOtherList};
6080 delete $profObj->{exitStateIgnoreList};
6081 }
6082 }
6083 }
6084  
6085 if ($version < 1_000_467 && $self->session) {
6086  
6087 # Update every command cage with new standard commands
6088 foreach my $cage ($self->session->ivValues('cageHash')) {
6089  
6090 if ($cage->{cageType} eq 'cmd') {
6091  
6092 if (! $cage->ivExists('cmdHash', 'teleport')) {
6093  
6094 $cage->ivAdd('cmdHash', 'teleport', 'teleport room');
6095 }
6096 }
6097 }
6098 }
6099  
6100 if ($version < 1_000_482 && $self->session) {
6101  
6102 # Update world profiles for new character life statuses
6103 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6104  
6105 if ($profObj->ivExists('logPrefHash', 'asleep')) {
6106  
6107 $profObj->ivAdd(
6108 'logPrefHash',
6109 'sleep',
6110 $profObj->ivShow('logPrefHash', 'asleep'),
6111 );
6112  
6113 $profObj->ivDelete('logPrefHash', 'asleep');
6114 }
6115  
6116 if ($profObj->ivExists('logPrefHash', 'passed_out')) {
6117  
6118 $profObj->ivAdd(
6119 'logPrefHash',
6120 'passout',
6121 $profObj->ivShow('logPrefHash', 'passed_out'),
6122 );
6123  
6124 $profObj->ivDelete('logPrefHash', 'passed_out');
6125 }
6126 }
6127  
6128 # Update character profiles in the same way
6129 if ($self->session) {
6130  
6131 # Update character profiles with new IVs
6132 foreach my $profObj ($self->session->ivValues('profHash')) {
6133  
6134 if ($profObj->{category} eq 'char') {
6135  
6136 if ($profObj->{lifeStatus} eq 'asleep') {
6137 $profObj->ivPoke('lifeStatus', 'sleep');
6138 } elsif ($profObj->{lifeStatus} eq 'passed_out') {
6139 $profObj->ivPoke('lifeStatus', 'passout');
6140 }
6141 }
6142 }
6143 }
6144 }
6145  
6146 if ($version < 1_000_512) {
6147  
6148 # Update room statement components with a new IV
6149 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6150  
6151 foreach my $compObj ($profObj->ivValues('componentHash')) {
6152  
6153 if (! exists $compObj->{noExtractList}) {
6154  
6155 $compObj->{noExtractList} = [];
6156 $compObj->ivEmpty('noExtractList');
6157 }
6158 }
6159 }
6160 }
6161  
6162 if ($version < 1_000_515) {
6163  
6164 # Update world profiles with a new IV
6165 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6166  
6167 if (! exists $profObj->{exitAliasHash}) {
6168  
6169 $profObj->{exitAliasHash} = {};
6170 $profObj->ivEmpty('exitAliasHash');
6171 }
6172 }
6173 }
6174  
6175 if ($version < 1_000_517) {
6176  
6177 # Update world profiles with a new IV
6178 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6179  
6180 if (! exists $profObj->{basicMappingMode}) {
6181  
6182 # (This IV subsequently renamed and/or removed)
6183 # $profObj->{basicMappingMode} = undef;
6184 # $profObj->ivPoke('basicMappingMode', 0);
6185 $profObj->{basicMappingMode} = 0;
6186 }
6187 }
6188 }
6189  
6190 if ($version < 1_000_524) {
6191  
6192 # Update world profiles with a new IV
6193 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6194  
6195 if (! exists $profObj->{notAnchorPatternList}) {
6196  
6197 $profObj->{notAnchorPatternList} = [];
6198 $profObj->ivEmpty('notAnchorPatternList');
6199 }
6200 }
6201 }
6202  
6203 if ($version < 1_000_526) {
6204  
6205 # Update world profiles with new IVs
6206 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6207  
6208 if (! exists $profObj->{verboseExitSplitCharFlag}) {
6209  
6210 $profObj->{verboseExitSplitCharFlag} = undef;
6211 $profObj->ivPoke('verboseExitSplitCharFlag', FALSE);
6212 $profObj->{briefExitSplitCharFlag} = undef;
6213 $profObj->ivPoke('briefExitSplitCharFlag', FALSE);
6214 }
6215 }
6216 }
6217  
6218 if ($version < 1_000_530) {
6219  
6220 # Update room statement components with an IV whose name has been changed, and a
6221 # new IV
6222 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6223  
6224 foreach my $compObj ($profObj->ivValues('componentHash')) {
6225  
6226 if (! exists $compObj->{useInitialTagsFlag}) {
6227  
6228 $compObj->{useInitialTagsFlag} = undef;
6229 $compObj->ivPoke('useInitialTagsFlag', $compObj->{useAppliedTagsFlag});
6230 delete $compObj->{useAppliedTagsFlag};
6231 }
6232  
6233 if (! exists $compObj->{useExplicitTagsFlag}) {
6234  
6235 $compObj->{useExplicitTagsFlag} = undef;
6236 $compObj->ivPoke('useExplicitTagsFlag', FALSE);
6237 }
6238 }
6239 }
6240 }
6241  
6242 if ($version < 1_000_537) {
6243  
6244 # Update world profiles with new IVs
6245 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6246  
6247 if (! exists $profObj->{loginAccountMode}) {
6248  
6249 $profObj->{loginAccountMode} = undef;
6250 $profObj->ivPoke('loginAccountMode', 0);
6251 }
6252 }
6253 }
6254  
6255 if ($version < 1_000_538) {
6256  
6257 # Update world profiles with a new IV
6258 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6259  
6260 if (! exists $profObj->{loginSpecialList}) {
6261  
6262 $profObj->{loginSpecialList} = [];
6263 $profObj->ivEmpty('loginSpecialList');
6264 }
6265 }
6266 }
6267  
6268 if ($version < 1_000_541) {
6269  
6270 # Update world profiles with a new IV
6271 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6272  
6273 if (! exists $profObj->{worldWarning}) {
6274  
6275 # (This IV subsequently renamed and/or removed)
6276 # $profObj->{worldWarning} = undef;
6277 # $profObj->ivUndef('worldWarning');
6278 $profObj->{worldWarning} = undef;
6279 }
6280 }
6281 }
6282  
6283 if ($version < 1_000_542) {
6284  
6285 # Update world profiles with a new IV
6286 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6287  
6288 if (! exists $profObj->{statOrderList}) {
6289  
6290 $profObj->{statOrderList} = [];
6291 $profObj->ivEmpty('statOrderList');
6292 }
6293 }
6294 }
6295  
6296 if ($version < 1_000_544) {
6297  
6298 # Update world profiles with new IVs
6299 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6300  
6301 if (! exists $profObj->{autoQuitMode}) {
6302  
6303 $profObj->{autoQuitMode} = undef;
6304 $profObj->ivUndef('autoQuitMode');
6305 $profObj->{autoQuitCmdList} = [];
6306 $profObj->ivEmpty('autoQuitCmdList');
6307 $profObj->{autoQuitObjName} = undef;
6308 $profObj->ivUndef('autoQuitObjName');
6309 }
6310 }
6311 }
6312  
6313 if ($version < 1_000_576) {
6314  
6315 # Update world profiles with a new IV
6316 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6317  
6318 if (! exists $profObj->{collectContentsFlag}) {
6319  
6320 $profObj->{collectContentsFlag} = undef;
6321 $profObj->ivPoke('collectContentsFlag', TRUE);
6322 }
6323 }
6324 }
6325  
6326 if ($version < 1_000_577) {
6327  
6328 # Update world profiles with a new IV
6329 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6330  
6331 if (! exists $profObj->{multiplePattern}) {
6332  
6333 $profObj->{multiplePattern} = undef;
6334 $profObj->ivUndef('multiplePattern');
6335 }
6336 }
6337 }
6338  
6339 if ($version < 1_000_578) {
6340  
6341 # Update world profiles with a new IV
6342 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6343  
6344 if (! exists $profObj->{followPatternList}) {
6345  
6346 $profObj->{followPatternList} = [];
6347 $profObj->ivEmpty('followPatternList');
6348 }
6349 }
6350 }
6351  
6352 if ($version < 1_000_622) {
6353  
6354 # Update all profiles with a new IV
6355 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6356  
6357 if (! exists $profObj->{notepadList}) {
6358  
6359 $profObj->{notepadList} = [];
6360 $profObj->ivEmpty('notepadList');
6361 }
6362 }
6363  
6364 if ($self->session) {
6365  
6366 foreach my $profObj ($self->session->ivValues('profHash')) {
6367  
6368 if ($profObj->{category} ne 'world' && ! exists $profObj->{notepadList}) {
6369  
6370 $profObj->{notepadList} = [];
6371 $profObj->ivEmpty('notepadList');
6372 }
6373 }
6374  
6375 foreach my $templObj ($self->session->ivValues('templateHash')) {
6376  
6377 if (! $templObj->ivExists('_standardHash', 'notepadList')) {
6378  
6379 # (Because this IV starts with an underline, have to set it directly)
6380 $templObj->{'_standardHash'}{'notepadList'} = undef;
6381 }
6382 }
6383 }
6384 }
6385  
6386 if ($version < 1_000_688) {
6387  
6388 # Update world profiles with a new IV
6389 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6390  
6391 if (! exists $profObj->{gaugeFormatList}) {
6392  
6393 $profObj->{gaugeFormatList} = [];
6394 $profObj->ivPoke(
6395 'gaugeFormatList',
6396 'health_points', 'health_points_max', FALSE, 'HP',
6397 'RED', 'red', 'WHITE',
6398 'magic_points', 'magic_points_max', FALSE, 'MP',
6399 'YELLOW', 'yellow', 'black',
6400 'energy_points', 'energy_points_max', FALSE, 'EP',
6401 'GREEN', 'green', 'black',
6402 'guild_points', 'guild_points_max', FALSE, 'GP',
6403 'BLUE', 'blue', 'WHITE',
6404 'social_points', 'social_points_max', FALSE, 'SP',
6405 'MAGENTA', 'magenta', 'WHITE',
6406 );
6407 }
6408 }
6409 }
6410  
6411 if ($version < 1_000_800 && $self->session) {
6412  
6413 # This version adds some trigger attributes. Update every trigger cage
6414 foreach my $cage ($self->session->ivValues('cageHash')) {
6415  
6416 if ($cage->{cageType} eq 'trigger') {
6417  
6418 foreach my $trigObj ($cage->ivValues('interfaceHash')) {
6419  
6420 $trigObj->ivAdd('attribHash', 'default_pane', TRUE);
6421 $trigObj->ivAdd('attribHash', 'pane_name', '');
6422 }
6423 }
6424 }
6425 }
6426  
6427 if ($version < 1_000_808) {
6428  
6429 # Update world profiles' stored mission objects
6430 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6431  
6432 foreach my $missionObj ($profObj->ivValues('missionHash')) {
6433  
6434 if (! exists $missionObj->{quietFlag}) {
6435  
6436 $missionObj->{quietFlag} = undef;
6437 $missionObj->ivPoke('quietFlag', FALSE);
6438  
6439 # IVs used to store temporary values while a mission was running have
6440 # not, until now, been reset properly
6441 $missionObj->resetMission();
6442 }
6443 }
6444 }
6445 }
6446  
6447 if ($version < 1_000_851) {
6448  
6449 my $regex = $axmud::SCRIPT . '\:\:';
6450  
6451 # Update world profiles' stored mission objects, whose ->triggerName and
6452 # ->timerName IVs were set wrong, which caused save file operations to fail
6453 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6454  
6455 foreach my $missionObj ($profObj->ivValues('missionHash')) {
6456  
6457 if (ref($missionObj->{triggerName}) =~ m/$regex/) {
6458  
6459 $missionObj->ivPoke('triggerName', $missionObj->{triggerName}->{name});
6460 }
6461  
6462 if (ref($missionObj->{timerName}) =~ m/$regex/) {
6463  
6464 $missionObj->ivPoke('timerName', $missionObj->{timerName}->{name});
6465 }
6466 }
6467 }
6468 }
6469  
6470 if ($version < 1_000_852) {
6471  
6472 # Update world profiles with a new IV
6473 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6474  
6475 if (! exists $profObj->{adultFlag}) {
6476  
6477 $profObj->{adultFlag} = undef;
6478 $profObj->ivPoke('adultFlag', TRUE);
6479 }
6480 }
6481 }
6482  
6483 if ($version < 1_000_877) {
6484  
6485 # Update world profiles with a new IV
6486 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6487  
6488 if (! exists $profObj->{inventoryDiscardPatternList}) {
6489  
6490 $profObj->{inventoryDiscardPatternList} = [];
6491 $profObj->ivEmpty('inventoryDiscardPatternList');
6492 }
6493 }
6494 }
6495  
6496 if ($version < 1_000_879) {
6497  
6498 # Update world profiles with new IVs
6499 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6500  
6501 if (! exists $profObj->{telnetOverrideHash}) {
6502  
6503 $profObj->{telnetOverrideHash} = {};
6504 $profObj->ivEmpty('telnetOverrideHash');
6505 $profObj->{termOverrideHash} = {};
6506 $profObj->ivEmpty('termOverrideHash');
6507  
6508 # One or two worlds must forbid certain protocols by default
6509 if ($profObj->name eq 'kallisti') {
6510  
6511 $profObj->ivAdd('telnetOverrideHash', 'msdp', undef);
6512 }
6513 }
6514 }
6515 }
6516  
6517 if ($version < 1_000_880) {
6518  
6519 # Rename a world profile IV
6520 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6521  
6522 if (! exists $profObj->{worldHint}) {
6523  
6524 $profObj->{worldHint} = undef;
6525 $profObj->ivPoke('worldHint', $profObj->{worldWarning});
6526 delete $profObj->{worldWarning};
6527 }
6528 }
6529 }
6530  
6531 if ($version < 1_000_881) {
6532  
6533 # Update world profiles with a new IV
6534 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6535  
6536 if (! exists $profObj->{sigilOverrideHash}) {
6537  
6538 $profObj->{sigilOverrideHash} = {};
6539 $profObj->ivEmpty('sigilOverrideHash');
6540 }
6541 }
6542 }
6543  
6544 if ($version < 1_000_885) {
6545  
6546 # Update world profiles with a new IV
6547 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6548  
6549 if (! exists $profObj->{connectHistoryList}) {
6550  
6551 $profObj->{connectHistoryList} = [];
6552 $profObj->ivEmpty('connectHistoryList');
6553 }
6554 }
6555 }
6556  
6557 if ($version < 1_000_888) {
6558  
6559 # Update world profiles with new IVs
6560 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6561  
6562 if (! exists $profObj->{mxpOverrideHash}) {
6563  
6564 $profObj->{mxpOverrideHash} = {};
6565 $profObj->ivEmpty('mxpOverrideHash');
6566  
6567 # One or two worlds must turn off certain options by default
6568 if ($profObj->name eq 'coffeemud') {
6569  
6570 $profObj->ivAdd('mxpOverrideHash', 'room', FALSE);
6571 }
6572 }
6573 }
6574 }
6575  
6576 if ($version < 1_000_896) {
6577  
6578 # Update world profiles with new IVs
6579 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6580  
6581 if (! exists $profObj->{verboseAnchorCheckList}) {
6582  
6583 $profObj->{verboseAnchorCheckList} = [];
6584 $profObj->ivEmpty('verboseAnchorCheckList');
6585 $profObj->{shortAnchorCheckList} = [];
6586 $profObj->ivEmpty('shortAnchorCheckList');
6587 $profObj->{briefAnchorCheckList} = [];
6588 $profObj->ivEmpty('briefAnchorCheckList');
6589 }
6590  
6591 if (! exists $profObj->{roomCmdDelimiterList}) {
6592  
6593 $profObj->{roomCmdDelimiterList} = [];
6594 $profObj->ivEmpty('roomCmdDelimiterList');
6595 $profObj->{roomCmdNonDelimiterList} = [];
6596 $profObj->ivEmpty('roomCmdNonDelimiterList');
6597 $profObj->{roomCmdSplitCharFlag} = undef;
6598 $profObj->ivPoke('roomCmdSplitCharFlag', FALSE);
6599 $profObj->{roomCmdLeftMarkerList} = [];
6600 $profObj->ivEmpty('roomCmdLeftMarkerList');
6601 $profObj->{roomCmdRightMarkerList} = [];
6602 $profObj->ivEmpty('roomCmdRightMarkerList');
6603 }
6604  
6605 # Also remove an IV, which has moved to GA::Client->constComponentTypeList
6606 if (exists ($profObj->{_constComponentList})) {
6607  
6608 delete $profObj->{_constComponentList};
6609 }
6610 }
6611 }
6612  
6613 if ($version < 1_000_909) {
6614  
6615 my @profList;
6616  
6617 # This version converts some numerical mode values to string mode values
6618  
6619 push (@profList, $axmud::CLIENT->ivValues('worldProfHash'));
6620 if ($self->session) {
6621  
6622 push (@profList, $self->session->ivValues('profHash'));
6623 }
6624  
6625 foreach my $profObj (@profList) {
6626  
6627 my %initScriptHash = $profObj->initScriptHash;
6628  
6629 foreach my $key (keys %initScriptHash) {
6630  
6631 my $value = $initScriptHash{$key};
6632  
6633 if ($value eq '0') {
6634 $initScriptHash{$key} = 'no_task';
6635 } elsif ($value eq '1') {
6636 $initScriptHash{$key} = 'run_task';
6637 } elsif ($value eq '2') {
6638 $initScriptHash{$key} = 'run_task_win';
6639 }
6640 }
6641  
6642 $profObj->ivPoke('initScriptHash', %initScriptHash);
6643  
6644 if ($profObj->category eq 'world') {
6645  
6646 if ($profObj->loginMode eq '0') {
6647 $profObj->ivPoke('loginMode', 'none');
6648 } elsif ($profObj->loginMode eq '1') {
6649 $profObj->ivPoke('loginMode', 'immediate');
6650 } elsif ($profObj->loginMode eq '2') {
6651 $profObj->ivPoke('loginMode', 'lp');
6652 } elsif ($profObj->loginMode eq '3') {
6653 $profObj->ivPoke('loginMode', 'tiny');
6654 } elsif ($profObj->loginMode eq '4') {
6655 $profObj->ivPoke('loginMode', 'world_cmd');
6656 } elsif ($profObj->loginMode eq '5') {
6657 $profObj->ivPoke('loginMode', 'telnet');
6658 } elsif ($profObj->loginMode eq '6') {
6659 $profObj->ivPoke('loginMode', 'task');
6660 } elsif ($profObj->loginMode eq '7') {
6661 $profObj->ivPoke('loginMode', 'script_task');
6662 } elsif ($profObj->loginMode eq '8') {
6663 $profObj->ivPoke('loginMode', 'script');
6664 } elsif ($profObj->loginMode eq '9') {
6665 $profObj->ivPoke('loginMode', 'mission');
6666 }
6667  
6668 if ($profObj->loginAccountMode eq '0') {
6669 $profObj->ivPoke('loginAccountMode', 'unknown');
6670 } elsif ($profObj->loginAccountMode eq '1') {
6671 $profObj->ivPoke('loginAccountMode', 'not_required');
6672 } elsif ($profObj->loginAccountMode eq '2') {
6673 $profObj->ivPoke('loginAccountMode', 'required');
6674 }
6675  
6676 if ($version >= 1_000_543) {
6677  
6678 if ($profObj->autoQuitMode eq '0') {
6679 $profObj->ivPoke('autoQuitMode', 'normal');
6680 } elsif ($profObj->autoQuitMode eq '1') {
6681 $profObj->ivPoke('autoQuitMode', 'world_cmd');
6682 } elsif ($profObj->autoQuitMode eq '2') {
6683 $profObj->ivPoke('autoQuitMode', 'task');
6684 } elsif ($profObj->autoQuitMode eq '3') {
6685 $profObj->ivPoke('autoQuitMode', 'task_script');
6686 } elsif ($profObj->autoQuitMode eq '4') {
6687 $profObj->ivPoke('autoQuitMode', 'script');
6688 } elsif ($profObj->autoQuitMode eq '5') {
6689 $profObj->ivPoke('autoQuitMode', 'mission');
6690 }
6691 }
6692  
6693 if ($profObj->inventoryMode eq '0') {
6694 $profObj->ivPoke('inventoryMode', 'match_all');
6695 } elsif ($profObj->inventoryMode eq '1') {
6696 $profObj->ivPoke('inventoryMode', 'start_stop');
6697 } elsif ($profObj->inventoryMode eq '2') {
6698 $profObj->ivPoke('inventoryMode', 'start_empty');
6699 }
6700  
6701 # (This IV subsequently renamed and/or removed)
6702 if (! $profObj->basicMappingMode) {
6703 # $profObj->ivPoke('basicMappingMode', FALSE);
6704 $profObj->{'basicMappingMode'} = FALSE;
6705 } else {
6706 # $profObj->ivPoke('basicMappingMode', TRUE);
6707 $profObj->{'basicMappingMode'} = TRUE;
6708 }
6709  
6710 foreach my $componentObj ($profObj->ivValues('componentHash')) {
6711  
6712 foreach my $iv (
6713 'startTagMode', 'startNoTagMode', 'skipTagMode',
6714 'stopBeforeTagMode', 'stopBeforeNoTagMode', 'stopAtTagMode',
6715 'stopAtNoTagMode',
6716 ) {
6717 if ($componentObj->$iv eq '0') {
6718 $componentObj->ivPoke($iv, 'default');
6719 } elsif ($componentObj->$iv eq '1') {
6720 $componentObj->ivPoke($iv, 'no_colour');
6721 } elsif ($componentObj->$iv eq '2') {
6722 $componentObj->ivPoke($iv, 'no_style');
6723 } elsif ($componentObj->$iv eq '3') {
6724 $componentObj->ivPoke($iv, 'no_colour_style');
6725 }
6726 }
6727  
6728 foreach my $iv ('stopBeforeMode', 'stopAtMode') {
6729  
6730 if ($componentObj->$iv eq '0') {
6731 $componentObj->ivPoke($iv, 'default');
6732 } elsif ($componentObj->$iv eq '1') {
6733 $componentObj->ivPoke($iv, 'no_char');
6734 } elsif ($componentObj->$iv eq '2') {
6735 $componentObj->ivPoke($iv, 'no_letter_num');
6736 } elsif ($componentObj->$iv eq '3') {
6737 $componentObj->ivPoke($iv, 'no_start_letter_num');
6738 } elsif ($componentObj->$iv eq '4') {
6739 $componentObj->ivPoke($iv, 'no_tag');
6740 } elsif ($componentObj->$iv eq '5') {
6741 $componentObj->ivPoke($iv, 'has_letter_num');
6742 } elsif ($componentObj->$iv eq '6') {
6743 $componentObj->ivPoke($iv, 'has_start_letter_num');
6744 } elsif ($componentObj->$iv eq '7') {
6745 $componentObj->ivPoke($iv, 'has_tag');
6746 }
6747 }
6748 }
6749 }
6750 }
6751 }
6752  
6753 if ($version < 1_000_915) {
6754  
6755 # Update world profiles with new IVs
6756 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6757  
6758 if (! exists $profObj->{followAnchorPatternList}) {
6759  
6760 $profObj->{followAnchorPatternList} = [];
6761 $profObj->ivEmpty('followAnchorPatternList');
6762 }
6763 }
6764 }
6765  
6766 if ($version < 1_000_921) {
6767  
6768 if ($self->session) {
6769  
6770 # Remove IVs from profile templates and custom profiles
6771 foreach my $templObj ($self->session->ivValues('templateHash')) {
6772  
6773 if (exists $templObj->{_standardHash}) {
6774  
6775 delete $templObj->{_standardHash};
6776 }
6777  
6778 if (exists $templObj->{_fixedFlag}) {
6779  
6780 $templObj->{constFixedFlag} = $templObj->{_fixedFlag};
6781 delete $templObj->{_fixedFlag};
6782 }
6783  
6784 # (This line makes sure the correct file object's ->modifyFlag is set)
6785 $templObj->ivPoke('category', $templObj->category);
6786 }
6787  
6788 foreach my $profObj ($self->session->ivValues('profHash')) {
6789  
6790 if (exists $profObj->{_standardHash}) {
6791  
6792 delete $profObj->{_standardHash};
6793  
6794 # (This line makes sure the correct file object's ->modifyFlag is set)
6795 $profObj->ivPoke('category', $profObj->category);
6796 }
6797 }
6798 }
6799 }
6800  
6801 if ($version < 1_000_922) {
6802  
6803 # This version renames a world profile IV
6804 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6805  
6806 if (exists $profObj->{_localWimpyMax}) {
6807  
6808 $profObj->{constLocalWimpyMax} = $profObj->{_localWimpyMax};
6809 delete $profObj->{_localWimpyMax};
6810  
6811 # (This line makes sure the correct file object's ->modifyFlag is set)
6812 $profObj->ivPoke('category', $profObj->category);
6813 }
6814 }
6815 }
6816  
6817 if ($version < 1_001_020) {
6818  
6819 # Update world profiles with a new IV
6820 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6821  
6822 if (! exists $profObj->{inventorySplitPatternList}) {
6823  
6824 $profObj->{inventorySplitPatternList} = [];
6825 $profObj->ivEmpty('inventorySplitPatternList');
6826 }
6827 }
6828 }
6829  
6830 if ($version < 1_001_030) {
6831  
6832 # Update world profiles with a new IV
6833 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6834  
6835 if (! exists $profObj->{roomCmdIgnoreList}) {
6836  
6837 $profObj->{roomCmdIgnoreList} = [];
6838 $profObj->ivEmpty('roomCmdIgnoreList');
6839 }
6840 }
6841 }
6842  
6843 if ($version < 1_001_074) {
6844  
6845 # Update world profiles with a new IV
6846 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6847  
6848 if (! exists $profObj->{exitStatePatternList}) {
6849  
6850 $profObj->{exitStatePatternList} = [];
6851 $profObj->ivEmpty('exitStatePatternList');
6852 }
6853 }
6854 }
6855  
6856 if ($version < 1_001_082) {
6857  
6858 # Update world profiles with a new IV
6859 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6860  
6861 if (! exists $profObj->{transientExitPatternList}) {
6862  
6863 $profObj->{transientExitPatternList} = [];
6864 $profObj->ivEmpty('transientExitPatternList');
6865 }
6866 }
6867 }
6868  
6869 if ($version < 1_001_124) {
6870  
6871 my (
6872 $listRef,
6873 @newList, @newList2, @combList,
6874 %hash, %checkHash,
6875 );
6876  
6877 # This version merges several IVs into single lists, eliminating duplicates
6878 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6879  
6880 if (! exists $profObj->{channelList}) {
6881  
6882 $profObj->{channelList} = [];
6883 $profObj->ivEmpty('channelList');
6884 $profObj->{noChannelList} = [];
6885 $profObj->ivEmpty('noChannelList');
6886  
6887 # Compile a hash of of patterns in the three existing IVs, sort them, then
6888 # compile the new IV
6889 # In case the same pattern exists in multiple IVs, use the 'tell' pattern
6890 # first
6891 $listRef = $profObj->{customDivertPatternList};
6892 if (defined $listRef && @$listRef) {
6893  
6894 do {
6895  
6896 my $pattern = shift @$listRef;
6897 my $flag = shift @$listRef;
6898  
6899 $hash{$pattern} = ['custom', $flag];
6900  
6901 } until (! @$listRef);
6902 }
6903  
6904 $listRef = $profObj->{socialPatternList};
6905 if (defined $listRef) {
6906  
6907 foreach my $pattern (@$listRef) {
6908  
6909 # Set TRUE because in previous versions of Axmud, social/tell
6910 # patterns were not displayed in the 'main' window and the task
6911 # window
6912 $hash{$pattern} = ['social', TRUE];
6913 }
6914 }
6915  
6916 if (defined $listRef) {
6917  
6918 $listRef = $profObj->{tellPatternList};
6919 foreach my $pattern (@$listRef) {
6920  
6921 $hash{$pattern} = ['tell', TRUE];
6922 }
6923 }
6924  
6925 # Compile the new IV
6926 foreach my $pattern (sort {lc($a) cmp lc($b)} (keys %hash)) {
6927  
6928 $listRef = $hash{$pattern};
6929  
6930 if (defined $listRef) {
6931  
6932 push (@newList, $pattern, @$listRef);
6933 }
6934 }
6935  
6936 $profObj->ivPoke('channelList', @newList);
6937  
6938 # Repeat the process for the other IVs, eliminating duplicates using
6939 # %checkHash
6940 $listRef = $profObj->{noTellPatternList};
6941 if (defined $listRef) {
6942  
6943 push (@combList, @$listRef);
6944 }
6945  
6946 $listRef = $profObj->{noSocialPatternList};
6947 if (defined $listRef) {
6948  
6949 push (@combList, @$listRef);
6950 }
6951  
6952 $listRef = $profObj->{noCustomDivertPatternList};
6953 if (defined $listRef) {
6954  
6955 push (@combList, @$listRef);
6956 }
6957  
6958 foreach my $pattern (@combList) {
6959  
6960 if (! exists $checkHash{$pattern}) {
6961  
6962 push (@newList2, $pattern);
6963 $checkHash{$pattern} = undef;
6964 }
6965 }
6966  
6967 # While we're at it, let's sort the list
6968 @newList2 = sort {lc($a) cmp lc($b)} (@newList2);
6969 $profObj->ivPoke('noChannelList', @newList2);
6970  
6971 # Delete the old IVs
6972 delete $profObj->{tellPatternList};
6973 delete $profObj->{noTellPatternList};
6974 delete $profObj->{socialPatternList};
6975 delete $profObj->{noSocialPatternList};
6976 delete $profObj->{customDivertPatternList};
6977 delete $profObj->{noCustomDivertPatternList};
6978 }
6979 }
6980 }
6981  
6982 if ($version < 1_001_133) {
6983  
6984 # Update world profiles with to write a new logfile
6985 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
6986  
6987 if (! $profObj->ivExists('logPrefHash', 'channels')) {
6988  
6989 $profObj->ivAdd(
6990 'logPrefHash',
6991 'channels',
6992 # Use the same setting as for the Divert task
6993 $profObj->ivShow('logPrefHash', 'divert'),
6994 );
6995 }
6996 }
6997 }
6998  
6999 if ($version < 1_001_184 && $self->session) {
7000  
7001 # This version adds an (optional) attribute to triggers, aliases, macros and hooks
7002 # (but not timers)
7003 foreach my $cage ($self->session->ivValues('cageHash')) {
7004  
7005 if (
7006 $cage->{cageType} eq 'trigger'
7007 || $cage->{cageType} eq 'alias'
7008 || $cage->{cageType} eq 'macro'
7009 || $cage->{cageType} eq 'hook'
7010 ) {
7011 foreach my $interfaceObj ($cage->ivValues('interfaceHash')) {
7012  
7013 $interfaceObj->ivAdd('attribHash', 'cooldown', 0);
7014 }
7015 }
7016 }
7017 }
7018  
7019 if ($version < 1_001_191) {
7020  
7021 # This version renames a world profile IV and a component object IV
7022 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
7023  
7024 my (@oldList, @newList);
7025  
7026 if (! exists $profObj->{groupPatternList}) {
7027  
7028 $profObj->{groupPatternList} = $profObj->{singleBackRefPatternList};
7029 delete $profObj->{singleBackRefPatternList};
7030  
7031 foreach my $componentObj ($profObj->ivValues('componentHash')) {
7032  
7033 if (! exists $componentObj->{usePatternGroups}) {
7034  
7035 $componentObj->{usePatternGroups}
7036 = $componentObj->{usePatternBackRefs};
7037 delete $componentObj->{usePatternBackRefs};
7038 }
7039 }
7040  
7041 # ->loginSpecialList is in groups of 3. It was previously necessary to
7042 # surround the third item in double quotes, if it contained a group
7043 # substring variable like $1, but that's no longer necessary, so remove
7044 # the quotes
7045 @oldList = $profObj->loginSpecialList;
7046 while (@oldList) {
7047  
7048 my ($item, $item2, $item3);
7049  
7050 $item = shift @oldList;
7051 $item2 = shift @oldList;
7052 $item3 = shift @oldList;
7053  
7054 $item3 =~ s/^\"(.*)\"$/$1/;
7055  
7056 push (@newList, $item, $item2, $item3);
7057  
7058 }
7059  
7060 $profObj->ivPoke('loginSpecialList', @newList);
7061 }
7062 }
7063 }
7064  
7065 if ($version < 1_001_258) {
7066  
7067 # Update world profiles to a list in groups of 1 with a list in groups of 2
7068 my $profObj = $axmud::CLIENT->ivShow('worldProfHash', $self->name);
7069 if ($profObj) {
7070  
7071 my @newList;
7072  
7073 foreach my $pattern ($profObj->transientExitPatternList) {
7074  
7075 push (@newList, $pattern, undef);
7076 }
7077  
7078 $profObj->ivPoke('transientExitPatternList', @newList);
7079 }
7080 }
7081  
7082 if ($version < 1_001_262 && $self->session) {
7083  
7084 # Update character profiles with new IVs
7085 foreach my $profObj ($self->session->ivValues('profHash')) {
7086  
7087 if ($profObj->{category} eq 'char' && ! exists $profObj->{qpCurrent}) {
7088  
7089 $profObj->{qpCurrent} = undef;
7090 $profObj->ivPoke('qpCurrent', 0);
7091 $profObj->{qpNextLevel} = undef;
7092 $profObj->ivPoke('qpNextLevel', 0);
7093 $profObj->{qpTotal} = undef;
7094 $profObj->ivPoke('qpTotal', 0);
7095  
7096 $profObj->{opCurrent} = undef;
7097 $profObj->ivPoke('opCurrent', 0);
7098 $profObj->{opNextLevel} = undef;
7099 $profObj->ivPoke('opNextLevel', 0);
7100 $profObj->{opTotal} = undef;
7101 $profObj->ivPoke('opTotal', 0);
7102 }
7103 }
7104 }
7105  
7106 if ($version < 1_001_263 && $self->session) {
7107  
7108 # Modify some IVs in world profiles
7109 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
7110  
7111 my (
7112 $hashRef, $listRef,
7113 %newHash,
7114 );
7115  
7116 if (exists $profObj->{constLocalWimpyMax}) {
7117  
7118 # (These are replaced by new character profile IVs)
7119 delete $profObj->{constLocalWimpyMax};
7120 delete $profObj->{remoteWimpyMax};
7121  
7122 # (->customStatusVarHash is replaced by new ->msdpStatusVarHash, with a
7123 # subset of its key-value pairs, with the keys/value reversed)
7124 $hashRef = $profObj->{customStatusVarHash};
7125 delete $profObj->{customStatusVarHash};
7126  
7127 foreach my $key (keys %$hashRef) {
7128  
7129 my $value = $$hashRef{$key};
7130  
7131 # A few pre-configured worlds were using the wrong format, so ignore the
7132 # key-value pairs where the value is 0
7133 if (defined $value && $value ne '0') {
7134  
7135 $newHash{$value} = $key;
7136 }
7137 }
7138  
7139 $profObj->{msdpStatusVarHash} = {};
7140 $profObj->ivPoke('msdpStatusVarHash', %newHash);
7141  
7142 # (->statusFormatList is just a renamed IV)
7143 $listRef = $profObj->{displayFormatList};
7144  
7145 # While we're at it, convert old custom variables from #var_name# to new
7146 # @var_name@ format
7147 foreach my $line (@$listRef) {
7148  
7149 $line =~ s/\#([\w\_]+)\#/\@$1\@/g;
7150  
7151 # In addition, some old variables have been renamed
7152 $line =~ s/fight_count/fight_string/;
7153 $line =~ s/interact_count/interact_string/;
7154 $line =~ s/interaction_count/interact_string/;
7155 $line =~ s/coward_count/coward_string/;
7156 $line =~ s/temp_fight_count/temp_fight_string/;
7157 $line =~ s/temp_interact_count/temp_interact_string/;
7158 $line =~ s/temp_interaction_count/temp_interact_string/;
7159 $line =~ s/temp_coward_count/temp_coward_string/;
7160 $line =~ s/quest_points/qp_current/;
7161 }
7162  
7163 $profObj->{statusFormatList} = [];
7164 $profObj->ivPoke('statusFormatList', @$listRef);
7165 delete $profObj->{displayFormatList};
7166 }
7167 }
7168  
7169 # Update character profiles with new IVs
7170 foreach my $profObj ($self->session->ivValues('profHash')) {
7171  
7172 if ($profObj->{category} eq 'char' && ! exists $profObj->{healthPoints}) {
7173  
7174 # (This IV subsequently renamed and/or removed)
7175 # $profObj->{healthPoints} = undef;
7176 # $profObj->ivPoke('healthPoints', 0);
7177 $profObj->{healthPoints} = 0;
7178 # $profObj->{healthPointsMax} = undef;
7179 # $profObj->ivPoke('healthPointsMax', 0);
7180 $profObj->{healthPointsMax} = 0;
7181  
7182 # $profObj->{magicPoints} = undef;
7183 # $profObj->ivPoke('magicPoints', 0);
7184 $profObj->{magicPoints} = 0;
7185 # $profObj->{magicPointsMax} = undef;
7186 # $profObj->ivPoke('magicPointsMax', 0);
7187 $profObj->{magicPointsMax} = 0;
7188  
7189 # $profObj->{energyPoints} = undef;
7190 # $profObj->ivPoke('energyPoints', 0);
7191 $profObj->{energyPoints} = 0;
7192 # $profObj->{energyPointsMax} = undef;
7193 # $profObj->ivPoke('energyPointsMax', 0);
7194 $profObj->{energyPointsMax} = 0;
7195  
7196 # $profObj->{guildPoints} = undef;
7197 # $profObj->ivPoke('guildPoints', 0);
7198 $profObj->{guildPoints} = 0;
7199 # $profObj->{guildPointsMax} = undef;
7200 # $profObj->ivPoke('guildPointsMax', 0);
7201 $profObj->{guildPointsMax} = 0;
7202  
7203 # $profObj->{socialPoints} = undef;
7204 # $profObj->ivPoke('socialPoints', 0);
7205 $profObj->{socialPoints} = 0;
7206 # $profObj->{socialPointsMax} = undef;
7207 # $profObj->ivPoke('socialPointsMax', 0);
7208 $profObj->{socialPointsMax} = 0;
7209  
7210 $profObj->{remoteWimpyMax} = undef;
7211 $profObj->ivPoke('remoteWimpyMax', 100);
7212 $profObj->{constLocalWimpyMax} = 199;
7213 }
7214 }
7215 }
7216  
7217 if ($version < 1_001_286 && $self->session) {
7218  
7219 my %hash = (
7220 'kp_up' => 'up',
7221 'kp_down' => 'down',
7222 'kp_left' => 'left',
7223 'kp_right' => 'right',
7224 'kp_page_up' => 'page_up',
7225 'kp_page_down' => 'page_down',
7226 'kp_home' => 'home',
7227 'kp_end' => 'end',
7228 'kp_insert' => 'insert',
7229 'kp_delete' => 'delete',
7230 );
7231  
7232 # This version removes some Axmud standard keycodes
7233 # Check macros in each macro cage, and convert any removed keycodes to their
7234 # replacements
7235 foreach my $cage ($self->session->ivValues('cageHash')) {
7236  
7237 if ($cage->{cageType} eq 'macro') {
7238  
7239 foreach my $macroObj ($cage->ivValues('interfaceHash')) {
7240  
7241 # The macro stimulus is a keycode/keycode string
7242 my $stimulus = $macroObj->stimulus;
7243  
7244 foreach my $regex (keys %hash) {
7245  
7246 my $subst = $hash{$regex};
7247  
7248 $stimulus =~ s/$regex/$subst/;
7249 }
7250  
7251 $macroObj->ivPoke('stimulus', $stimulus);
7252 }
7253 }
7254 }
7255 }
7256  
7257 if ($version < 1_001_298) {
7258  
7259 # Update world profiles with a new IV
7260 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
7261  
7262 if (! exists $profObj->{mxpStatusVarHash}) {
7263  
7264 $profObj->{mxpStatusVarHash} = {};
7265 $profObj->ivEmpty('mxpStatusVarHash');
7266 }
7267 }
7268 }
7269  
7270 if ($version < 1_001_308) {
7271  
7272 # Update world profiles by deleting an IV
7273 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
7274  
7275 delete $profObj->{'strictPromptsMode'};
7276 }
7277 }
7278  
7279 if ($version < 1_001_365) {
7280  
7281 # Update world profiles with a new IV
7282 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
7283  
7284 if (! exists $profObj->{exitStateTagHash}) {
7285  
7286 $profObj->{exitStateTagHash} = {};
7287 $profObj->ivEmpty('exitStateTagHash');
7288 }
7289 }
7290 }
7291  
7292 if ($version < 1_001_374) {
7293  
7294 # Update world profiles with a new IV
7295 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
7296  
7297 if (! exists $profObj->{duplicateReplaceString}) {
7298  
7299 $profObj->{duplicateReplaceString} = undef;
7300 $profObj->ivUndef('duplicateReplaceString');
7301 }
7302 }
7303 }
7304  
7305 if ($version < 1_001_382 && $self->session) {
7306  
7307 # This version adds a new trigger attribute. Update every trigger cage
7308 foreach my $cage ($self->session->ivValues('cageHash')) {
7309  
7310 if ($cage->{cageType} eq 'trigger') {
7311  
7312 foreach my $trigObj ($cage->ivValues('interfaceHash')) {
7313  
7314 $trigObj->ivAdd('attribHash', 'ignore_response', FALSE);
7315 }
7316 }
7317 }
7318 }
7319  
7320 if ($version < 1_002_056) {
7321  
7322 # Update world profiles with new IVs
7323 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
7324  
7325 if (! exists $profObj->{mxpRoomTagStart}) {
7326  
7327 $profObj->{mxpRoomTagStart} = undef;
7328 $profObj->ivUndef('mxpRoomTagStart');
7329 $profObj->{mxpRoomTagStop} = undef;
7330 $profObj->ivUndef('mxpRoomTagStop');
7331 }
7332 }
7333 }
7334  
7335 if ($version < 1_002_109 && $self->session) {
7336  
7337 # This version corrects a misspelled standard hook event
7338 foreach my $cage ($self->session->ivValues('cageHash')) {
7339  
7340 if ($cage->{cageType} eq 'hook') {
7341  
7342 foreach my $interfaceObj ($cage->ivValues('interfaceHash')) {
7343  
7344 if ($interfaceObj->stimulus eq 'change_vivible') {
7345  
7346 $interfaceObj->ivPoke('stimulus', 'change_visible');
7347 }
7348 }
7349 }
7350 }
7351 }
7352  
7353 ### worldmodel ###########################################################################
7354  
7355 } elsif ($self->fileType eq 'worldmodel') {
7356  
7357 # (Import the world model, for convenience)
7358 $wmObj = $self->session->worldModelObj;
7359  
7360 # (Changes that must be made before any other changes)
7361  
7362 if ($version < 1_000_871) {
7363  
7364 # This version renames a number of IVs
7365 if (! exists $wmObj->{modelHash}) {
7366  
7367 $wmObj->{modelHash} = $wmObj->{model};
7368 $wmObj->{regionModelHash} = $wmObj->{regionModel};
7369 $wmObj->{roomModelHash} = $wmObj->{roomModel};
7370 $wmObj->{weaponModelHash} = $wmObj->{weaponModel};
7371 $wmObj->{armourModelHash} = $wmObj->{armourModel};
7372 $wmObj->{garmentModelHash} = $wmObj->{garmentModel};
7373 $wmObj->{charModelHash} = $wmObj->{charModel};
7374 $wmObj->{minionModelHash} = $wmObj->{minionModel};
7375 $wmObj->{sentientModelHash} = $wmObj->{sentientModel};
7376 $wmObj->{creatureModelHash} = $wmObj->{creatureModel};
7377 $wmObj->{portableModelHash} = $wmObj->{portableModel};
7378 $wmObj->{decorationModelHash} = $wmObj->{decorationModel};
7379 $wmObj->{customModelHash} = $wmObj->{customModel};
7380 $wmObj->{exitModelHash} = $wmObj->{exitModel};
7381  
7382 delete $wmObj->{model};
7383 delete $wmObj->{regionModel};
7384 delete $wmObj->{roomModel};
7385 delete $wmObj->{weaponModel};
7386 delete $wmObj->{armourModel};
7387 delete $wmObj->{garmentModel};
7388 delete $wmObj->{charModel};
7389 delete $wmObj->{minionModel};
7390 delete $wmObj->{sentientModel};
7391 delete $wmObj->{creatureModel};
7392 delete $wmObj->{portableModel};
7393 delete $wmObj->{decorationModel};
7394 delete $wmObj->{customModel};
7395 delete $wmObj->{exitModel};
7396 }
7397 }
7398  
7399 if ($version < 1_001_289) {
7400  
7401 # This version adds new IVs to the world model
7402 if (! exists $wmObj->{adjacentMode}) {
7403  
7404 $wmObj->{adjacentMode} = undef;
7405 $wmObj->ivPoke('adjacentMode', 'near');
7406 $wmObj->{adjacentCount} = undef;
7407 $wmObj->ivPoke('adjacentCount', 1);
7408 }
7409 }
7410  
7411 # (All remaining changes, in order)
7412  
7413 if ($version < 1_000_006) {
7414  
7415 # # Update the room flag list
7416 # $wmObj->updateRoomFlags($self->session);
7417  
7418 # Add the new border colour IV
7419 $wmObj->{defaultGhostSelectBorderColour} = undef;
7420 $wmObj->ivPoke('defaultGhostSelectBorderColour', '#BB6E57');
7421 $wmObj->{ghostSelectBorderColour} = undef;
7422 $wmObj->ivPoke('ghostSelectBorderColour', '#BB6E57');
7423  
7424 # Add the modified border colours (unless the user has already modified them)
7425 $wmObj->ivPoke('defaultLostBorderColour', '#21D221');
7426 if ($wmObj->{lostBorderColour} eq '#00FF00') {
7427  
7428 $wmObj->ivPoke('lostBorderColour', '#00FF00');
7429 }
7430 }
7431  
7432 if ($version < 1_000_009) {
7433  
7434 # This version introduces exit tags for exits drawn as up/down. Any exits in these
7435 # directions, whose exit tags have not been modified by the user, should have
7436 # their tags updated to include the words 'up' and 'down')
7437 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7438  
7439 my ($destRoomObj, $destRegionObj, $oldTag, $newTag);
7440  
7441 if ($exitObj->{exitTag} && $exitObj->{mapDir}) {
7442  
7443 $destRoomObj = $wmObj->ivShow('modelHash', $exitObj->{destRoom});
7444 $destRegionObj = $wmObj->ivShow('modelHash', $destRoomObj->{parent});
7445 $oldTag = 'to ' . $destRegionObj->{name};
7446  
7447 if ($exitObj->{exitTag} eq $oldTag) {
7448  
7449 # Tag hasn't been modified by the user, so we can update it
7450 if ($exitObj->{mapDir} eq 'up' || $exitObj->{mapDir} eq 'down') {
7451 $newTag = $exitObj->{mapDir} . ' to ' . $destRegionObj->{name};
7452 } else {
7453 $newTag = $oldTag;
7454 }
7455  
7456 if ($exitObj->{oneWayFlag}) {
7457  
7458 $newTag .= ' (>)';
7459 }
7460  
7461 $exitObj->ivPoke('exitTag', $newTag);
7462 }
7463 }
7464 }
7465 }
7466  
7467 if ($version < 1_000_016) {
7468  
7469 if (! exists $wmObj->{pathFindStepLimit}) {
7470  
7471 # Add the new IV
7472 $wmObj->{pathFindStepLimit} = undef;
7473 $wmObj->ivPoke('pathFindStepLimit', 200);
7474 }
7475 }
7476  
7477 # if ($version < 1_000_018) {
7478 #
7479 # # Update the room flag list
7480 # $wmObj->updateRoomFlags($self->session);
7481 # }
7482  
7483 if ($version < 1_000_041) {
7484  
7485 # This version fixes an error in GA::Obj::WorldModel->connectRegionBrokenExit, in
7486 # which exits that are connected to rooms in different regions as uncertain or
7487 # one-way exits are not added to the parent regionmap's list of region exits
7488 # First, check every region exit. If it can't be found in the parent regionmap's
7489 # list of region exits, add it
7490  
7491 # (Only display a warning, if the model contains exits)
7492 if ($wmObj->{exitModelHash}) {
7493  
7494 $self->writeText('Applying essential world model update. Please be patient...');
7495 $axmud::CLIENT->desktopObj->updateWidgets(
7496 $self->_objClass . '->updateExtractedData',
7497 );
7498 }
7499  
7500 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7501  
7502 my ($roomObj, $regionObj, $regionmapObj);
7503  
7504 if ($exitObj->{regionFlag}) {
7505  
7506 $roomObj = $wmObj->ivShow('modelHash', $exitObj->{parent});
7507 $regionObj = $wmObj->ivShow('modelHash', $roomObj->{parent});
7508 $regionmapObj = $wmObj->ivShow('regionmapHash', $regionObj->{name});
7509  
7510 if (! $regionmapObj->ivExists('regionExitHash', $exitObj->{number})) {
7511  
7512 $wmObj->ivAdd(
7513 'updateBoundaryHash',
7514 $exitObj->{number},
7515 $regionObj->{name},
7516 );
7517 }
7518 }
7519 }
7520  
7521 # Second, tell the world model to update its boundaries (which calls
7522 # $regionmapObj->storeRegionExit for each new region exit)
7523 $wmObj->updateRegionPaths($self->session);
7524  
7525 # Third, recalculate all region paths
7526 foreach my $regionmapObj (
7527 sort {lc($a->{name}) cmp lc($b->{name})} ($wmObj->ivValues('regionmapHash'))
7528 ) {
7529 $wmObj->recalculateRegionPaths(
7530 $self->session,
7531 $regionmapObj,
7532 );
7533 }
7534 }
7535  
7536 if ($version < 1_000_053) {
7537  
7538 # Add the new IV to all exit objects
7539 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7540  
7541 if (! exists $exitObj->{notSuperFlag}) {
7542  
7543 $exitObj->{notSuperFlag} = undef;
7544 $exitObj->ivPoke('notSuperFlag', FALSE);
7545 }
7546 }
7547 }
7548  
7549 if ($version < 1_000_094) {
7550  
7551 # Add the new IV to all model objects
7552 foreach my $obj ($wmObj->ivValues('modelHash')) {
7553  
7554 if (! exists $obj->{targetRoomNum}) {
7555  
7556 $obj->{targetRoomNum} = undef;
7557 $obj->ivUndef('targetRoomNum');
7558 }
7559 }
7560 }
7561  
7562 if ($version < 1_000_108) {
7563  
7564 # This version changes the initial position of room tag/room guild text on the
7565 # Automapper window
7566 # Check existing world model rooms; if any of them have room tags/room guilds, ask
7567 # the user if they should be updated
7568 my ($tagAdjust, $guildAdjust, $matchFlag, $response);
7569  
7570 $tagAdjust = int ( # Default value - 5
7571 (
7572 $wmObj->{defaultBlockHeightPixels}
7573 - $wmObj->{defaultRoomHeightPixels}
7574 ) / 4
7575 );
7576  
7577 $guildAdjust = int ( # Default value - 3
7578 (
7579 $wmObj->{defaultBlockHeightPixels}
7580 - $wmObj->{defaultRoomHeightPixels}
7581 ) / 6
7582 );
7583  
7584 OUTER: foreach my $obj ($wmObj->ivValues('modelHash')) {
7585  
7586 if ($obj->{category} eq 'room' && ($obj->{roomTag} || $obj->{roomGuild})) {
7587  
7588 $matchFlag = TRUE;
7589 last OUTER;
7590 }
7591 }
7592  
7593 if ($matchFlag && ($tagAdjust || $guildAdjust)) {
7594  
7595 $response = $self->session->mainWin->showMsgDialogue(
7596 'Adjust text position',
7597 'question',
7598 'Room tags and room guilds are now drawn in the Automapper window at a'
7599 . ' slightly different position. Do you want to adjust your existing'
7600 . ' room tags/guilds, so that they appear in the same position as before?',
7601 'yes-no',
7602 );
7603  
7604 if (defined $response && $response eq 'yes') {
7605  
7606 OUTER: foreach my $obj ($wmObj->ivValues('modelHash')) {
7607  
7608 if ($obj->{category} eq 'room') {
7609  
7610 if ($obj->{roomTag}) {
7611  
7612 $obj->ivPlus('roomTagYOffset', $tagAdjust);
7613 }
7614  
7615 if ($obj->{roomGuild}) {
7616  
7617 $obj->ivMinus('roomGuildYOffset', $tagAdjust);
7618 }
7619 }
7620 }
7621 }
7622 }
7623 }
7624  
7625 if ($version < 1_000_110) {
7626  
7627 # This version corrects an error which messed up exits with bends which had been
7628 # dragged by the user. To correct the problem, all bends must be removed; it's up
7629 # to the user to reposition them, now that it's possible
7630 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7631  
7632 my $listRef = $exitObj->{bendOffsetList};
7633 if (@$listRef) {
7634  
7635 $exitObj->ivEmpty('bendOffsetList');
7636 }
7637 }
7638 }
7639  
7640 if ($version < 1_000_114) {
7641  
7642 # This version corrects an error in which an exit is sometimes twinned with an exit
7643 # that is attached to a shadow exit, rather than being twinned to the shadow exit
7644 # itself
7645 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7646  
7647 my ($twinExitObj, $shadowExitObj, $roomObj, $otherRoomObj);
7648  
7649 if ($exitObj->{twinExit} && $exitObj->{shadowExit}) {
7650  
7651 $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{twinExit});
7652 $shadowExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{shadowExit});
7653 $roomObj = $wmObj->ivShow('modelHash', $exitObj->{parent});
7654 $otherRoomObj = $wmObj->ivShow('modelHash', $twinExitObj->{parent});
7655  
7656 $wmObj->abandonTwinExit(FALSE, $exitObj, $twinExitObj);
7657  
7658 # If both the exits had shadow exits, we are now dealing with a set of four
7659 # exits, and the call to ->abandonTwinExit above will leave one of the
7660 # four unabandoned
7661 if ($shadowExitObj->{twinExit}) {
7662  
7663 $wmObj->abandonTwinExit(FALSE, $shadowExitObj);
7664 }
7665  
7666 # Now we can reconnect the rooms, avoiding twinning exits with shadow exits
7667 $wmObj->connectRooms(
7668 $self->session,
7669 FALSE,
7670 $roomObj,
7671 $otherRoomObj,
7672 $shadowExitObj->{dir},
7673 );
7674 }
7675 }
7676 }
7677  
7678 if ($version < 1_000_127) {
7679  
7680 # This version corrects an error in which the destination room is not informed when
7681 # 1-way and uncertain exits are converted to incomplete exits
7682 # Need to check every room's hash of incoming 1-way/uncertain exits, to make sure
7683 # the exits still lead to their supposed destinations
7684 foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {
7685  
7686 my $hashRef = $roomObj->{uncertainExitHash};
7687 if (%$hashRef) {
7688  
7689 my %uncertainExitHash = %$hashRef;
7690  
7691 foreach my $exitNum (keys %uncertainExitHash) {
7692  
7693 my $exitObj = $wmObj->ivShow('exitModelHash', $exitNum);
7694  
7695 if (
7696 # Exit doesn't exit
7697 ! $exitObj
7698 # Exit doesn't lead to $roomObj
7699 || ! $exitObj->{destRoom}
7700 || $exitObj->{destRoom} != $roomObj->{number}
7701 # Exit is no longer an uncertain exit
7702 || (
7703 $exitObj->{twinExit}
7704 || $exitObj->{retraceFlag}
7705 || $exitObj->{oneWayFlag}
7706 || $exitObj->{randomType}
7707 )
7708 ) {
7709 delete $uncertainExitHash{$exitNum};
7710 }
7711 }
7712  
7713 $roomObj->ivPoke('uncertainExitHash', %uncertainExitHash);
7714 }
7715  
7716 $hashRef = $roomObj->{oneWayExitHash};
7717 if (%$hashRef) {
7718  
7719 my %oneWayExitHash = %$hashRef;
7720  
7721 foreach my $exitNum (keys %oneWayExitHash) {
7722  
7723 my $exitObj = $wmObj->ivShow('exitModelHash', $exitNum);
7724  
7725 if (
7726 # Exit doesn't exit
7727 ! $exitObj
7728 # Exit doesn't lead to $roomObj
7729 || ! $exitObj->{destRoom}
7730 || $exitObj->{destRoom} != $roomObj->{number}
7731 # Exit is no longer a one -way exit
7732 || ! $exitObj->{oneWayFlag}
7733 ) {
7734 delete $oneWayExitHash{$exitNum};
7735 }
7736 }
7737  
7738 $roomObj->ivPoke('oneWayExitHash', %oneWayExitHash);
7739 }
7740 }
7741 }
7742  
7743 if ($version < 1_000_128) {
7744  
7745 # This version adds a new IV to the world model
7746 if (! exists $wmObj->{protectedMovesFlag}) {
7747  
7748 $wmObj->{protectedMovesFlag} = undef;
7749 $wmObj->ivPoke('protectedMovesFlag', FALSE);
7750 }
7751 }
7752  
7753 if ($version < 1_000_213) {
7754  
7755 # Add the new IV to all exit objects
7756 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7757  
7758 if (! exists $exitObj->{info}) {
7759  
7760 # (This IV subsequently renamed and/or removed)
7761 # $exitObj->{info} = undef;
7762 # $exitObj->ivPoke('info', undef);
7763 $exitObj->{info} = undef;
7764 }
7765 }
7766 }
7767  
7768 if ($version < 1_000_222) {
7769  
7770 # This version fixes an issue with random exits. Make repairs to the world model
7771  
7772 # Exit still has a ->randomDestList, even though its ->randomType is no longer 3
7773 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7774  
7775 my $listRef = $exitObj->{randomDestList};
7776 if ($exitObj->{randomType} == 3 && @$listRef) {
7777  
7778 foreach my $destRoomNum (@$listRef) {
7779  
7780 my $roomObj = $wmObj->ivShow('modelHash', $destRoomNum);
7781 if ($roomObj && $roomObj->{category} eq 'room') {
7782  
7783 $roomObj->ivDelete('randomExitHash', $exitObj->{number});
7784 }
7785 }
7786  
7787 $exitObj->ivEmpty('randomDestList');
7788 }
7789 }
7790  
7791 # Room has an incoming random exit of the wrong type
7792 foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {
7793  
7794 my $hashRef = $roomObj->{randomExitHash};
7795 if (%$hashRef) {
7796  
7797 my %modHash;
7798  
7799 foreach my $exitNum ($roomObj->ivKeys('randomExitHash')) {
7800  
7801 my $exitObj = $wmObj->ivShow('exitModelHash', $exitNum);
7802 if ($exitObj && $exitObj->{randomType} == 3) {
7803  
7804 $modHash{$exitNum} = undef;
7805 }
7806 }
7807  
7808 $roomObj->ivPoke('randomExitHash', %modHash);
7809 }
7810 }
7811 }
7812  
7813 if ($version < 1_000_224) {
7814  
7815 # Add a new IV to the world model, the date and Axmud version when the model was
7816 # created. Since we don't know the creation date, use the date of the v1.0.0
7817 # release
7818 if (! exists $wmObj->{modelCreationDate}) {
7819  
7820 $wmObj->{modelCreationDate} = undef;
7821 $wmObj->ivPoke('modelCreationDate', 'Thu Jul 31, 2014');
7822 $wmObj->{modelCreationVersion} = undef;
7823 $wmObj->ivPoke('modelCreationVersion', '1.0.0');
7824 }
7825 }
7826  
7827 if ($version < 1_000_260) {
7828  
7829 my ($regionmapObj, $regionObj);
7830  
7831 # ->firstRegion could have been set to a region which has a parent; in which case
7832 # the specified region can't be shown at the top of the Automapper window's list.
7833 # Check the region specified by ->firstRegion and reset it, if it has a parent
7834 # region
7835 if ($wmObj->{firstRegion}) {
7836  
7837 my $regionmapObj = $wmObj->ivShow('regionmapHash', $wmObj->{firstRegion});
7838 if ($regionmapObj) {
7839  
7840 $regionObj = $wmObj->ivShow('regionModelHash', $regionmapObj->{number});
7841 }
7842  
7843 if ($regionObj && $regionObj->{parent}) {
7844  
7845 $wmObj->ivUndef('firstRegion');
7846 }
7847 }
7848 }
7849  
7850 if ($version < 1_000_272) {
7851  
7852 # This version adds a new IV to the world model
7853 if (! exists $wmObj->{showAllPrimaryFlag}) {
7854  
7855 $wmObj->{showAllPrimaryFlag} = undef;
7856 $wmObj->ivPoke('showAllPrimaryFlag', FALSE);
7857 }
7858 }
7859  
7860 if ($version < 1_000_290) {
7861  
7862 # Add the new IV to all exit objects
7863 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7864  
7865 if (! exists $exitObj->{oneWayDir}) {
7866  
7867 $exitObj->{oneWayDir} = undef;
7868 # The default direction at which the exit touches its destination room is
7869 # the opposite of the exit's existing ->mapDir
7870 # NB If the exit is unallocatable, ->mapDir won't be set, so we'll use
7871 # 'north' as an emergency default value for ->mapDir. (This same approach
7872 # is used elsewhere in the Axmud code)
7873 if ($exitObj->{mapDir}) {
7874  
7875 $exitObj->ivPoke(
7876 'oneWayDir',
7877 $axmud::CLIENT->ivShow('constOppDirHash', $exitObj->{mapDir}),
7878 );
7879  
7880 } else {
7881  
7882 # Emergency default
7883 $exitObj->ivPoke('oneWayDir', 'north');
7884 }
7885 }
7886 }
7887 }
7888  
7889 if ($version < 1_000_300) {
7890  
7891 # The possible values of $exitObj->state have changed. Values 0-3 are unchanged, but
7892 # the value 4 (other) must be converted to 6
7893 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7894  
7895 if ($exitObj->{state} == 4) {
7896  
7897 # (This IV subsequently renamed and/or removed)
7898 # $exitObj->ivPoke('state', 6);
7899 $exitObj->{state} = 6;
7900 }
7901 }
7902 }
7903  
7904 if ($version < 1_000_309) {
7905  
7906 # v1.0.308 fixes a problem, in which labels on a map disappeared when the region
7907 # was renamed. Check all labels, and repair any GA::Obj::MapLabel objects that
7908 # are broken
7909 # Actually, first count the problems, then ask the user to repair them, or to
7910 # delete the label altogether
7911 my ($count, $response, $string);
7912  
7913 $count = 0;
7914  
7915 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
7916  
7917 foreach my $labelObj ($regionmapObj->ivValues('gridLabelHash')) {
7918  
7919 if ($labelObj->{region} ne $regionmapObj->{name}) {
7920  
7921 $count++;
7922 }
7923 }
7924 }
7925  
7926 if ($count) {
7927  
7928 if ($count == 1) {
7929 $string = '1 label';
7930 } else {
7931 $string = $count . ' labels';
7932 }
7933  
7934 $response = $self->session->mainWin->showMsgDialogue(
7935 'Recover missing labels',
7936 'question',
7937 "Due to an earlier problem, $string had become invisible when region(s)"
7938 . " were renamed. Do you want to recover these labels? (Click \'No\' to"
7939 . " delete them altogether)",
7940 'yes-no',
7941 );
7942  
7943 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
7944  
7945 foreach my $labelObj ($regionmapObj->ivValues('gridLabelHash')) {
7946  
7947 if ($labelObj->{region} ne $regionmapObj->{name}) {
7948  
7949 # Recover the missing label, even if we're about to delete it
7950 $labelObj->ivPoke('region', $regionmapObj->{name});
7951  
7952 if (! $response || $response eq 'no') {
7953  
7954 # Delete this label
7955 $wmObj->deleteLabels(
7956 FALSE, # No Automapper windows to update
7957 $labelObj,
7958 );
7959 }
7960 }
7961 }
7962 }
7963 }
7964 }
7965  
7966 if ($version < 1_000_327) {
7967  
7968 # In all exit objects, replace ->state with ->exitState, and modify its value,
7969 # increasing all non-zero values by one
7970 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
7971  
7972 if (exists $exitObj->{state}) {
7973  
7974 $exitObj->{exitState} = undef;
7975 if ($exitObj->{state}) {
7976 $exitObj->ivPoke('exitState', $exitObj->{state} + 1);
7977 } else {
7978 $exitObj->ivPoke('exitState', 0);
7979 }
7980  
7981 delete $exitObj->{state};
7982 }
7983 }
7984 }
7985  
7986 if ($version < 1_000_328) {
7987  
7988 # This version adds a new IV to the world model
7989 if (! exists $wmObj->{updateOrnamentsFlag}) {
7990  
7991 # (This IV subsequently renamed and/or removed)
7992 # $wmObj->{updateOrnamentsFlag} = undef;
7993 # $wmObj->ivPoke('updateOrnamentsFlag', FALSE);
7994 $wmObj->{updateOrnamentsFlag} = FALSE;
7995 }
7996 }
7997  
7998 if ($version < 1_000_329) {
7999  
8000 my %stateHash = (
8001 0 => 'normal',
8002 1 => 'open',
8003 2 => 'closed',
8004 3 => 'locked',
8005 4 => 'impass',
8006 5 => 'dark',
8007 6 => 'danger',
8008 7 => 'other',
8009 );
8010  
8011 # In all exit objects, now swapping values of ->exitState from numbers to strings
8012 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
8013  
8014 if (exists $stateHash{$exitObj->{exitState}}) {
8015  
8016 # e.g. convert 2 to 'closed'
8017 $exitObj->ivPoke('exitState', $stateHash{$exitObj->{exitState}});
8018  
8019 } else {
8020  
8021 # Emergency default
8022 $exitObj->ivPoke('exitState', 'normal');
8023 }
8024 }
8025 }
8026  
8027 if ($version < 1_000_341) {
8028  
8029 # Add the new IV to all map label objects
8030 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
8031  
8032 foreach my $mapLabelObj ($regionmapObj->ivValues('gridLabelHash')) {
8033  
8034 if (! exists $mapLabelObj->{relSize}) {
8035  
8036 $mapLabelObj->{relSize} = undef;
8037 $mapLabelObj->ivPoke('relSize', 1);
8038 }
8039 }
8040 }
8041 }
8042  
8043 if ($version < 1_000_429) {
8044  
8045 # This version adds a new IV to the world model
8046 if (! exists $wmObj->{superProtectedMovesFlag}) {
8047  
8048 $wmObj->{superProtectedMovesFlag} = undef;
8049 $wmObj->ivPoke('superProtectedMovesFlag', FALSE);
8050 }
8051 }
8052  
8053 if ($version < 1_000_467) {
8054  
8055 # This version adds a new IV to the world model
8056 if (! exists $wmObj->{teleportHash}) {
8057  
8058 $wmObj->{teleportHash} = {};
8059 }
8060 }
8061  
8062 if ($version < 1_000_545) {
8063  
8064 # This version splits an existing world model IV into two new ones
8065 if (! exists $wmObj->{allowModelScriptFlag}) {
8066  
8067 $wmObj->{allowModelScriptFlag} = undef;
8068 $wmObj->ivPoke('allowModelScriptFlag', $wmObj->{allowScriptFlag});
8069 $wmObj->{allowRoomScriptFlag} = undef;
8070 $wmObj->ivPoke('allowRoomScriptFlag', $wmObj->{allowScriptFlag});
8071 delete $wmObj->{allowScriptFlag};
8072 }
8073  
8074 # Also creates two new world model IVs
8075 if (! exists $wmObj->{newRoomScriptList}) {
8076  
8077 $wmObj->{newRoomScriptList} = [];
8078 $wmObj->ivEmpty('newRoomScriptList');
8079 $wmObj->{arriveScriptList} = [];
8080 $wmObj->ivEmpty('arriveScriptList');
8081 }
8082  
8083 # This version also renames a room model object IV
8084 foreach my $obj ($wmObj->ivValues('roomModelHash')) {
8085  
8086 my $listRef;
8087  
8088 if (! exists $obj->{arriveScriptList}) {
8089  
8090 $obj->{arriveScriptList} = [];
8091 $listRef = $obj->{scriptList};
8092 $obj->ivPush('arriveScriptList', @$listRef);
8093 delete $obj->{scriptList};
8094 }
8095 }
8096 }
8097  
8098 # if ($version < 1_000_572) {
8099 #
8100 # # Update the room flag list
8101 # $wmObj->updateRoomFlags($self->session);
8102 # }
8103  
8104 if ($version < 1_000_573) {
8105  
8106 # This version fixes an error, in which one of a pair of region exits is made a
8107 # super-region exit, but not the other
8108 # Check all super-region exits; if their twins are not super-region exits (and the
8109 # user hasn't deliberately marked them as not being super-region exits), update
8110 # them
8111  
8112 my ($count, $hashRef);
8113  
8114 # Only display a warning, if the model contains objects
8115 $count = 0;
8116 $hashRef = $wmObj->{modelHash};
8117 if (%$hashRef) {
8118  
8119 $self->writeText('Applying essential world model update. Please be patient...');
8120 $axmud::CLIENT->desktopObj->updateWidgets(
8121 $self->_objClass . '->updateExtractedData',
8122 );
8123 }
8124  
8125 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
8126  
8127 if ($exitObj->{superFlag} && $exitObj->{twinExit}) {
8128  
8129 my $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{twinExit});
8130  
8131 if (
8132 $twinExitObj->{regionFlag}
8133 && ! $twinExitObj->{superFlag}
8134 && ! $twinExitObj->{notSuperFlag}
8135 ) {
8136 $count++;
8137 $twinExitObj->ivPoke('superFlag', TRUE);
8138  
8139 # The regionmap must also be updated (in some cases)
8140 my $twinRoomObj = $wmObj->ivShow('modelHash', $twinExitObj->{parent});
8141 my $twinRegionObj = $wmObj->ivShow('modelHash', $twinRoomObj->{parent});
8142 my $twinRegionmapObj
8143 = $wmObj->ivShow('regionmapHash', $twinRegionObj->{name});
8144  
8145 $twinRegionmapObj->storeRegionExit($self->session, $twinExitObj);
8146 }
8147 }
8148 }
8149  
8150 if ($count) {
8151  
8152 # Recalculate all region pahts
8153 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
8154  
8155 my $number = $wmObj->recalculateRegionPaths(
8156 $self->session,
8157 $regionmapObj,
8158 );
8159 }
8160 }
8161 }
8162  
8163 if ($version < 1_000_579) {
8164  
8165 # This version corrects some errors with exit bends. Redrawing the bends exactly
8166 # as the user intended them to be is impossible, so in some cases we must
8167 # remove the bends altogether
8168  
8169 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
8170  
8171 my ($listRef, $twinExitObj, $listRef2);
8172  
8173 $listRef = $exitObj->{bendOffsetList};
8174  
8175 # In some cases, a one-way exit or uncertain exit is left with bend(s); so
8176 # remove them
8177 if (
8178 $exitObj->{oneWayFlag}
8179 || (
8180 $exitObj->{destRoom}
8181 && (
8182 ! $exitObj->{twinExit}
8183 && ! $exitObj->{retraceFlag}
8184 && ! $exitObj->{randomType}
8185 )
8186 )
8187 ) {
8188 if (@$listRef) {
8189  
8190 $exitObj->ivEmpty('bendOffsetList');
8191 }
8192 }
8193  
8194 if ($exitObj->{twinExit}) {
8195  
8196 $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{twinExit});
8197 $listRef2 = $twinExitObj->{bendOffsetList};
8198 }
8199  
8200 # In some cases, one of a pair of two-way exits has a bend, but the other
8201 # doesn't. Remove the bend, in this case
8202 if (
8203 $twinExitObj
8204 && (
8205 (! @$listRef && @$listRef2)
8206 || (@$listRef && ! @$listRef2)
8207 )
8208 ) {
8209 $exitObj->ivEmpty('bendOffsetList');
8210 $twinExitObj->ivEmpty('bendOffsetList');
8211 }
8212 }
8213 }
8214  
8215 # if ($version < 1_000_624) {
8216 #
8217 # # Update the room flag list
8218 # $wmObj->updateRoomFlags($self->session);
8219 # }
8220  
8221 if ($version < 1_000_824) {
8222  
8223 # This version adds a new IV to the world model
8224 if (! exists $wmObj->{pseudoWinFlag}) {
8225  
8226 $wmObj->{pseudoWinFlag} = undef;
8227 $wmObj->ivPoke('pseudoWinFlag', TRUE);
8228 }
8229 }
8230  
8231 if ($version < 1_000_840) {
8232  
8233 # This version adds a new IV to all room model objects
8234 foreach my $obj ($wmObj->ivValues('roomModelHash')) {
8235  
8236 if (! exists $obj->{protocolRoomHash}) {
8237  
8238 $obj->{protocolRoomHash} = {};
8239 $obj->ivEmpty('protocolRoomHash');
8240 $obj->{protocolExitHash} = {};
8241 $obj->ivEmpty('protocolExitHash');
8242 }
8243 }
8244 }
8245  
8246 if ($version < 1_000_842) {
8247  
8248 # This version adds new IVs to the world model
8249 if (! exists $wmObj->{matchVNumFlag}) {
8250  
8251 $wmObj->{matchVNumFlag} = undef;
8252 $wmObj->ivPoke('matchVNumFlag', TRUE);
8253 $wmObj->{updateVNumFlag} = undef;
8254 $wmObj->ivPoke('updateVNumFlag', TRUE);
8255  
8256 $wmObj->{roomTerrainInitHash} = {};
8257 $wmObj->ivEmpty('roomTerrainInitHash');
8258 $wmObj->{roomTerrainHash} = {};
8259 $wmObj->ivEmpty('roomTerrainHash');
8260 }
8261 }
8262  
8263 if ($version < 1_000_859) {
8264  
8265 # This version simplifies an IV in regionmap objects
8266 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
8267  
8268 my (
8269 $hashRef,
8270 %newHash,
8271 );
8272  
8273 $hashRef = $regionmapObj->{gridExitTagHash};
8274 foreach my $key (keys %$hashRef) {
8275  
8276 $newHash{$key} = undef;
8277 }
8278  
8279 $regionmapObj->ivPoke('gridExitTagHash', %newHash);
8280 }
8281  
8282 # This version also changed an IV name
8283 foreach my $obj ($wmObj->ivValues('modelHash')) {
8284  
8285 if (! exists $obj->{container}) {
8286  
8287 $obj->{container} = undef;
8288 $obj->ivPoke('container', $obj->{containerObj});
8289  
8290 delete $obj->{container};
8291 }
8292 }
8293 }
8294  
8295 if ($version < 1_000_896) {
8296  
8297 # This version adds a new IV to all room model objects
8298 foreach my $obj ($wmObj->ivValues('roomModelHash')) {
8299  
8300 if (! exists $obj->{roomCmdList}) {
8301  
8302 $obj->{roomCmdList} = [];
8303 $obj->ivEmpty('roomCmdList');
8304 }
8305 }
8306 }
8307  
8308 if ($version < 1_000_896) {
8309  
8310 # This version adds a new IV to the world model, and renames some existing ones
8311 if (! exists $wmObj->{updateRoomCmdFlag}) {
8312  
8313 $wmObj->{updateRoomCmdFlag} = undef;
8314 $wmObj->ivPoke('updateRoomCmdFlag', FALSE);
8315 }
8316  
8317 $wmObj->{matchExitFlag} = $wmObj->{matchExitsFlag};
8318 delete $wmObj->{matchExitsFlag};
8319 $wmObj->{updateExitFlag} = $wmObj->{updateExitsFlag};
8320 delete $wmObj->{updateExitsFlag};
8321 $wmObj->{updateOrnamentFlag} = $wmObj->{updateOrnamentsFlag};
8322 delete $wmObj->{updateOrnamentsFlag};
8323 }
8324  
8325 if ($version < 1_000_909) {
8326  
8327 # This version converts some numerical mode values to string mode values
8328 if ($wmObj->currentRoomMode eq '0') {
8329 $wmObj->ivPoke('currentRoomMode', 'single');
8330 } elsif ($wmObj->currentRoomMode eq '1') {
8331 $wmObj->ivPoke('currentRoomMode', 'double');
8332 } elsif ($wmObj->currentRoomMode eq '2') {
8333 $wmObj->ivPoke('currentRoomMode', 'interior');
8334 }
8335  
8336 if ($wmObj->roomInteriorMode eq '0') {
8337 $wmObj->ivPoke('roomInteriorMode', 'none');
8338 } elsif ($wmObj->roomInteriorMode eq '1') {
8339 $wmObj->ivPoke('roomInteriorMode', 'shadow_count');
8340 } elsif ($wmObj->roomInteriorMode eq '2') {
8341 $wmObj->ivPoke('roomInteriorMode', 'region_count');
8342 } elsif ($wmObj->roomInteriorMode eq '3') {
8343 $wmObj->ivPoke('roomInteriorMode', 'room_content');
8344 } elsif ($wmObj->roomInteriorMode eq '4') {
8345 $wmObj->ivPoke('roomInteriorMode', 'hidden_count');
8346 } elsif ($wmObj->roomInteriorMode eq '5') {
8347 $wmObj->ivPoke('roomInteriorMode', 'temp_count');
8348 } elsif ($wmObj->roomInteriorMode eq '6') {
8349 $wmObj->ivPoke('roomInteriorMode', 'word_count');
8350 } elsif ($wmObj->roomInteriorMode eq '7') {
8351 $wmObj->ivPoke('roomInteriorMode', 'room_flag');
8352 } elsif ($wmObj->roomInteriorMode eq '8') {
8353 $wmObj->ivPoke('roomInteriorMode', 'visit_count');
8354 } elsif ($wmObj->roomInteriorMode eq '9') {
8355 $wmObj->ivPoke('roomInteriorMode', 'profile_count');
8356 } elsif ($wmObj->roomInteriorMode eq '10') {
8357 $wmObj->ivPoke('roomInteriorMode', 'title_descrip');
8358 } elsif ($wmObj->roomInteriorMode eq '11') {
8359 $wmObj->ivPoke('roomInteriorMode', 'exit_pattern');
8360 } elsif ($wmObj->roomInteriorMode eq '12') {
8361 $wmObj->ivPoke('roomInteriorMode', 'source_code');
8362 } elsif ($wmObj->roomInteriorMode eq '13') {
8363 $wmObj->ivPoke('roomInteriorMode', 'vnum');
8364 }
8365  
8366 if ($wmObj->drawExitMode eq '0') {
8367 $wmObj->ivPoke('drawExitMode', 'ask_regionmap');
8368 } elsif ($wmObj->drawExitMode eq '1') {
8369 $wmObj->ivPoke('drawExitMode', 'no_exit');
8370 } elsif ($wmObj->drawExitMode eq '2') {
8371 $wmObj->ivPoke('drawExitMode', 'simple_exit');
8372 } elsif ($wmObj->drawExitMode eq '3') {
8373 $wmObj->ivPoke('drawExitMode', 'complex_exit');
8374 }
8375  
8376 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
8377  
8378 if ($regionmapObj->drawExitMode eq '1') {
8379 $regionmapObj->ivPoke('drawExitMode', 'no_exit');
8380 } elsif ($regionmapObj->drawExitMode eq '2') {
8381 $regionmapObj->ivPoke('drawExitMode', 'simple_exit');
8382 } elsif ($regionmapObj->drawExitMode eq '3') {
8383 $regionmapObj->ivPoke('drawExitMode', 'complex_exit');
8384 }
8385 }
8386  
8387 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
8388  
8389 if ($exitObj->drawMode eq '0') {
8390 $exitObj->ivPoke('drawMode', 'primary');
8391 } elsif ($exitObj->drawMode eq '1') {
8392 $exitObj->ivPoke('drawMode', 'temp_alloc');
8393 } elsif ($exitObj->drawMode eq '2') {
8394 $exitObj->ivPoke('drawMode', 'temp_unalloc');
8395 } elsif ($exitObj->drawMode eq '3') {
8396 $exitObj->ivPoke('drawMode', 'perm_alloc');
8397 }
8398  
8399 if ($exitObj->randomType eq '0') {
8400 $exitObj->ivPoke('randomType', 'none');
8401 } elsif ($exitObj->randomType eq '1') {
8402 $exitObj->ivPoke('randomType', 'same_region');
8403 } elsif ($exitObj->randomType eq '2') {
8404 $exitObj->ivPoke('randomType', 'any_region');
8405 } elsif ($exitObj->randomType eq '3') {
8406 $exitObj->ivPoke('randomType', 'room_list');
8407 }
8408 }
8409 }
8410  
8411 if ($version < 1_000_913) {
8412  
8413 # This version removes three IVs which have been moved to GA::Client
8414 if (exists $wmObj->{roomFilterStartList}) {
8415  
8416 delete $wmObj->{roomFilterStartList};
8417 delete $wmObj->{roomFlagStartList};
8418 delete $wmObj->{roomFlagHazardHash};
8419 }
8420  
8421 # This version also tweaks the value of an IV in several kinds of model objects
8422 foreach my $obj ($wmObj->ivValues('modelHash')) {
8423  
8424 if (exists $obj->{sellableFlag}) {
8425  
8426 if (! $obj->{sellableFlag}) {
8427 $obj->ivPoke('sellableFlag', FALSE);
8428 } else {
8429 $obj->ivPoke('sellableFlag', TRUE);
8430 }
8431 }
8432 }
8433 }
8434  
8435 if ($version < 1_000_915) {
8436  
8437 # This version adds a new IV to the world model
8438 if (! exists $wmObj->{followAnchorFlag}) {
8439  
8440 $wmObj->{followAnchorFlag} = undef;
8441 $wmObj->ivPoke('followAnchorFlag', FALSE);
8442 }
8443 }
8444  
8445 if ($version < 1_000_933) {
8446  
8447 # This version renames an IV in the world model
8448 if (exists $wmObj->{showToolBarFlag}) {
8449  
8450 $wmObj->{showToolbarFlag} = undef;
8451 $wmObj->ivPoke('showToolbarFlag', $wmObj->{showToolBarFlag});
8452 delete $wmObj->{showToolBarFlag};
8453 }
8454 }
8455  
8456 if ($version < 1_001_030) {
8457  
8458 # Add the new IV to all room model objects
8459 foreach my $obj ($wmObj->ivValues('roomModelHash')) {
8460  
8461 if (! exists $obj->{tempRoomCmdList}) {
8462  
8463 $obj->{tempRoomCmdList} = [];
8464 $obj->ivEmpty('tempRoomCmdList');
8465 }
8466 }
8467 }
8468  
8469 if ($version < 1_001_063) {
8470  
8471 # General update to the world model, aimed at drastically reducing its size by
8472 # combining rarely-used IVs into single hash IVs
8473  
8474 # GA::Obj::Exit->breakHash, ->pickHash, ->unlockHash, ->openHash, ->closeHash,
8475 # ->lockHash and ->ornamentFlag are removed entirely
8476 # ->info is just renamed, not removed/merged
8477 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
8478  
8479 if (! exists $exitObj->{'exitOrnament'}) {
8480  
8481 $exitObj->{exitOrnament} = undef;
8482  
8483 if ($exitObj->{breakFlag}) {
8484 $exitObj->ivPoke('exitOrnament', 'break');
8485 } elsif ($exitObj->{pickFlag}) {
8486 $exitObj->ivPoke('exitOrnament', 'pick');
8487 } elsif ($exitObj->{lockFlag}) {
8488 $exitObj->ivPoke('exitOrnament', 'lock');
8489 } elsif ($exitObj->{openFlag}) {
8490 $exitObj->ivPoke('exitOrnament', 'open');
8491 } elsif ($exitObj->{impassFlag}) {
8492 $exitObj->ivPoke('exitOrnament', 'impass');
8493 } else {
8494 $exitObj->ivPoke('exitOrnament', 'none');
8495 }
8496  
8497 delete $exitObj->{breakFlag};
8498 delete $exitObj->{pickFlag};
8499 delete $exitObj->{lockFlag};
8500 delete $exitObj->{openFlag};
8501 delete $exitObj->{impassFlag};
8502 delete $exitObj->{ornamentFlag};
8503  
8504 $exitObj->{exitInfo} = undef;
8505 $exitObj->ivPoke('exitInfo', $exitObj->{info});
8506 delete $exitObj->{info};
8507  
8508 $exitObj->{doorHash} = {};
8509  
8510 if (defined $exitObj->{breakCmd}) {
8511  
8512 $exitObj->ivAdd('doorHash', 'break', $exitObj->{breakCmd});
8513 }
8514  
8515 if (defined $exitObj->{pickCmd}) {
8516  
8517 $exitObj->ivAdd('doorHash', 'pick', $exitObj->{pickCmd});
8518 }
8519  
8520 if (defined $exitObj->{unlockCmd}) {
8521  
8522 $exitObj->ivAdd('doorHash', 'unlock', $exitObj->{unlockCmd});
8523 }
8524  
8525 if (defined $exitObj->{openCmd}) {
8526  
8527 $exitObj->ivAdd('doorHash', 'open', $exitObj->{openCmd});
8528 }
8529  
8530 if (defined $exitObj->{closeCmd}) {
8531  
8532 $exitObj->ivAdd('doorHash', 'close', $exitObj->{closeCmd});
8533 }
8534  
8535 if (defined $exitObj->{lockCmd}) {
8536  
8537 $exitObj->ivAdd('doorHash', 'lock', $exitObj->{lockCmd});
8538 }
8539  
8540 delete $exitObj->{breakHash};
8541 delete $exitObj->{pickHash};
8542 delete $exitObj->{unlockHash};
8543 delete $exitObj->{openHash};
8544 delete $exitObj->{closeHash};
8545 delete $exitObj->{lockHash};
8546  
8547 delete $exitObj->{breakCmd};
8548 delete $exitObj->{pickCmd};
8549 delete $exitObj->{unlockCmd};
8550 delete $exitObj->{openCmd};
8551 delete $exitObj->{closeCmd};
8552 delete $exitObj->{lockCmd};
8553 }
8554 }
8555 }
8556  
8557 if ($version < 1_001_064) {
8558  
8559 # This version adds a new IV to the world model
8560 if (! exists $wmObj->{buttonSetList}) {
8561  
8562 $wmObj->{buttonSetList} = [];
8563 $wmObj->ivEmpty('buttonSetList');
8564 }
8565 }
8566  
8567 if ($version < 1_001_069) {
8568  
8569 # This version adds a new IV to the world model
8570 if (! exists $wmObj->{preferRoomFlagList}) {
8571  
8572 $wmObj->{preferRoomFlagList} = [];
8573 $wmObj->ivEmpty('preferRoomFlagList');
8574 }
8575 }
8576  
8577 if ($version < 1_001_070) {
8578  
8579 # Apparently, $self->update_modelobj_all wasn't called for the world model's
8580 # painter object (a non-model GA::ModelObj::Room object), and this causes a crash
8581 # if the user tries to open the painter's edit window in a world model created
8582 # before ->update_modelobj_all was
8583 # Foolproof fix is to reset the painter, no questions asked
8584 $wmObj->resetPainter($self->session);
8585 }
8586  
8587 if ($version < 1_001_071) {
8588  
8589 # Add the new IV to all room model objects
8590 foreach my $obj ($wmObj->ivValues('roomModelHash')) {
8591  
8592 if (! exists $obj->{wildMode}) {
8593  
8594 $obj->{wildMode} = undef;
8595 $obj->ivPoke('wildMode', 'normal');
8596 }
8597 }
8598 }
8599  
8600 if ($version < 1_001_077) {
8601  
8602 # Update and rename a world model IV
8603 if (! exists $wmObj->{constPainterIVList}) {
8604  
8605 $wmObj->{constPainterIVList} = [
8606 'wildMode',
8607 'titleList',
8608 'descripHash',
8609 'exclusiveFlag',
8610 'exclusiveHash',
8611 'roomFlagHash',
8612 'roomGuild',
8613 'searchHash',
8614 ];
8615  
8616 delete $wmObj->{painterIVList};
8617 }
8618 }
8619  
8620 if ($version < 1_001_080) {
8621  
8622 # This version renames an IV to the world model
8623 if (exists $wmObj->{basicMappingMode}) {
8624  
8625 $wmObj->{basicMappingFlag} = undef;
8626 $wmObj->ivPoke('basicMappingFlag', $wmObj->{basicMappingMode});
8627 delete $wmObj->{basicMappingMode};
8628 }
8629 }
8630  
8631 if ($version < 1_001_082) {
8632  
8633 # This version adds a new IV to the world model
8634 if (! exists $wmObj->{craftyMovesFlag}) {
8635  
8636 $wmObj->{craftyMovesFlag} = undef;
8637 $wmObj->ivPoke('craftyMovesFlag', FALSE);
8638 }
8639 }
8640  
8641 if ($version < 1_001_084) {
8642  
8643 # This version adds new IVs to the world model
8644 if (! exists $wmObj->{paintFromTitleHash}) {
8645  
8646 $wmObj->{paintFromTitleHash} = {};
8647 $wmObj->ivEmpty('paintFromTitleHash');
8648 $wmObj->{paintFromDescripHash} = {};
8649 $wmObj->ivEmpty('paintFromDescripHash');
8650 $wmObj->{paintFromExitHash} = {};
8651 $wmObj->ivEmpty('paintFromExitHash');
8652 $wmObj->{paintFromObjHash} = {};
8653 $wmObj->ivEmpty('paintFromObjHash');
8654 $wmObj->{paintFromRoomCmdHash} = {};
8655 $wmObj->ivEmpty('paintFromRoomCmdHash');
8656 }
8657 }
8658  
8659 if ($version < 1_001_087) {
8660  
8661 # This version adds a new IV to the world model
8662 if (! exists $wmObj->{preferBGColourList}) {
8663  
8664 $wmObj->{preferBGColourList} = [];
8665 $wmObj->ivEmpty('preferBGColourList');
8666 }
8667  
8668 # This version also adds new IVs to regionmaps
8669 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
8670  
8671 if (! exists $regionmapObj->{gridColourBlockHash}) {
8672  
8673 $regionmapObj->{gridColourBlockHash} = {};
8674 $regionmapObj->ivEmpty('gridColourBlockHash');
8675 $regionmapObj->{gridColourObjHash} = {};
8676 $regionmapObj->ivEmpty('gridColourObjHash');
8677 $regionmapObj->{colourObjCount} = undef;
8678 $regionmapObj->ivPoke('colourObjCount', 0);
8679 }
8680 }
8681 }
8682  
8683 if ($version < 1_001_089) {
8684  
8685 # This version adds new IVs to the world model
8686 if (! exists $wmObj->{collectCheckedDirsFlag}) {
8687  
8688 $wmObj->{defaultCheckedDirColour} = undef;
8689 $wmObj->ivPoke('defaultCheckedDirColour', '#FF96AA');
8690 $wmObj->{checkedDirColour} = undef;
8691 $wmObj->ivPoke('checkedDirColour', '#FF96AA');
8692  
8693 $wmObj->{collectCheckedDirsFlag} = undef;
8694 $wmObj->ivPoke('collectCheckedDirsFlag', FALSE);
8695 $wmObj->{drawCheckedDirsFlag} = undef;
8696 $wmObj->ivPoke('drawCheckedDirsFlag', TRUE);
8697 $wmObj->{checkableDirMode} = undef;
8698 $wmObj->ivPoke('checkableDirMode', 'diku');
8699 }
8700  
8701 # It also adds a new IV to all room model objects
8702 foreach my $obj ($wmObj->ivValues('roomModelHash')) {
8703  
8704 if (! exists $obj->{checkedDirHash}) {
8705  
8706 $obj->{checkedDirHash} = {};
8707 $obj->ivEmpty('checkedDirHash');
8708 }
8709 }
8710 }
8711  
8712 if ($version < 1_001_097) {
8713  
8714 # This version adds new IVs to the world model
8715 if (! exists $wmObj->{mapLabelStyleHash}) {
8716  
8717 $wmObj->{mapLabelStyleHash} = {};
8718  
8719 $wmObj->{mapLabelStyleHash}{'Style 1'} = Games::Axmud::Obj::MapLabelStyle->new(
8720 $self->session,
8721 'Style 1',
8722 '#C90640',
8723 );
8724  
8725 $wmObj->{mapLabelStyleHash}{'Style 2'} = Games::Axmud::Obj::MapLabelStyle->new(
8726 $self->session,
8727 'Style 2',
8728 '#FF40E0',
8729 ),
8730  
8731 $wmObj->{mapLabelStyleHash}{'Style 3'} = Games::Axmud::Obj::MapLabelStyle->new(
8732 $self->session,
8733 'Style 3',
8734 '#000000',
8735 undef, # No underlay colour
8736 2,
8737 );
8738  
8739 $wmObj->{mapLabelStyleHash}{'Style 4'} = Games::Axmud::Obj::MapLabelStyle->new(
8740 $self->session,
8741 'Style 4',
8742 '#000000',
8743 undef, # No underlay colour
8744 4
8745 );
8746  
8747 $wmObj->{mapLabelStyle} = undef;
8748 $wmObj->ivPoke('mapLabelStyle', 'Style 1');
8749 }
8750  
8751 # This version also adds new IVs to map label objects
8752 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
8753  
8754 foreach my $mapLabelObj ($regionmapObj->ivValues('gridLabelHash')) {
8755  
8756 if (! exists $mapLabelObj->{style}) {
8757  
8758 $mapLabelObj->{style} = undef;
8759  
8760 $mapLabelObj->{textColour} = undef;
8761 $mapLabelObj->ivPoke('textColour', $wmObj->defaultMapLabelColour);
8762 $mapLabelObj->{underlayColour} = undef;
8763 $mapLabelObj->ivUndef('underlayColour');
8764 $mapLabelObj->{italicsFlag} = undef;
8765 $mapLabelObj->ivPoke('italicsFlag', FALSE);
8766 $mapLabelObj->{boldFlag} = undef;
8767 $mapLabelObj->ivPoke('boldFlag', FALSE);
8768 $mapLabelObj->{underlineFlag} = undef;
8769 $mapLabelObj->ivPoke('underlineFlag', FALSE);
8770 $mapLabelObj->{strikeFlag} = undef;
8771 $mapLabelObj->ivPoke('strikeFlag', FALSE);
8772 $mapLabelObj->{boxFlag} = undef;
8773 $mapLabelObj->ivPoke('boxFlag', FALSE);
8774 $mapLabelObj->{gravity} = undef;
8775 $mapLabelObj->ivPoke('gravity', 'south');
8776  
8777 if ($mapLabelObj->{relSize} == 1) {
8778  
8779 $mapLabelObj->ivPoke('style', 'Style 1');
8780  
8781 } elsif ($mapLabelObj->{relSize} == 2) {
8782  
8783 $mapLabelObj->ivPoke('style', 'Style 3');
8784  
8785 } elsif ($mapLabelObj->{relSize} == 4) {
8786  
8787 $mapLabelObj->ivPoke('style', 'Style 4');
8788  
8789 } else {
8790  
8791 # Failsafe
8792 $mapLabelObj->ivPoke('style', 'Style 1');
8793 }
8794 }
8795 }
8796 }
8797 }
8798  
8799 if ($version < 1_001_101) {
8800  
8801 # This version adds new IVs to the world model
8802 if (! exists $wmObj->{defaultSelectBoxColour}) {
8803  
8804 $wmObj->{defaultSelectBoxColour} = undef;
8805 $wmObj->ivPoke('defaultSelectBoxColour', '#0088FF');
8806 $wmObj->{selectBoxColour} = undef;
8807 $wmObj->ivPoke('selectBoxColour', '#0088FF');
8808 }
8809 }
8810  
8811 if ($version < 1_001_104) {
8812  
8813 # This version adds new IVs to the world model
8814 if (! exists $wmObj->{mapLabelAlignXFlag}) {
8815  
8816 $wmObj->{mapLabelAlignXFlag} = undef;
8817 $wmObj->ivPoke('mapLabelAlignXFlag', FALSE);
8818 $wmObj->{mapLabelAlignYFlag} = undef;
8819 $wmObj->ivPoke('mapLabelAlignYFlag', FALSE);
8820 }
8821 }
8822  
8823 if ($version < 1_001_107) {
8824  
8825 my ($count, $hashRef, $listRef);
8826  
8827 # This version reorganises room flag IVs. Convert data in the old format to the
8828 # new format
8829 if (! exists $wmObj->{roomFilterApplyHash}) {
8830  
8831 # Add new IV definitions
8832 $wmObj->{roomFilterApplyHash} = {};
8833 $wmObj->ivEmpty('roomFilterApplyHash');
8834 $wmObj->{roomFlagHash} = {};
8835 $wmObj->ivEmpty('roomFlagHash');
8836  
8837 # Set up ->roomFilterApplyHash, which replaces the old ->roomFilterHash
8838 foreach my $filter ($axmud::CLIENT->constRoomFilterList) {
8839  
8840 if ($wmObj->{roomFilterHash}{$filter}) {
8841 $wmObj->ivAdd('roomFilterApplyHash', $filter, TRUE);
8842 } else {
8843 $wmObj->ivAdd('roomFilterApplyHash', $filter, FALSE);
8844 }
8845 }
8846  
8847 # Create the default set of room flag objects, stored in new ->roomFlagHash
8848 $wmObj->setupRoomFlags($self->session);
8849  
8850 # Incorporate any changes to room flag colours made by the user
8851 $hashRef = $wmObj->{roomFlagTextHash};
8852 foreach my $oldFlag (keys %$hashRef) {
8853  
8854 my ($newObj, $colour);
8855  
8856 # Get the new room flag object
8857 $newObj = $wmObj->ivShow('roomFlagHash', $oldFlag);
8858  
8859 # Update colour
8860 $colour = $wmObj->{roomFlagColourHash}{$oldFlag};
8861 if (defined $colour) {
8862  
8863 $newObj->ivPoke('colour', $colour);
8864 }
8865 }
8866  
8867 # Set the priority for every room flag object, using the unchanged
8868 # ->roomFlagOrderedList IV
8869 $count = 0;
8870 $listRef = $wmObj->{roomFlagOrderedList};
8871 foreach my $roomFlag (@$listRef) {
8872  
8873 $count++;
8874  
8875 my $newObj = $wmObj->ivShow('roomFlagHash', $roomFlag);
8876 $newObj->ivPoke('priority', $count);
8877 }
8878  
8879 # Remove old IV definitions
8880 delete $wmObj->{defaultRoomFilterList};
8881 delete $wmObj->{defaultRoomFilterHash};
8882 delete $wmObj->{defaultRoomFlagTextHash};
8883 delete $wmObj->{defaultRoomFlagPriorityHash};
8884 delete $wmObj->{defaultRoomFlagFilterHash};
8885 delete $wmObj->{defaultRoomFlagColourHash};
8886 delete $wmObj->{defaultRoomFlagDescripHash};
8887 delete $wmObj->{defaultRoomFlagOrderedList};
8888 delete $wmObj->{defaultRoomFlagReverseHash};
8889  
8890 delete $wmObj->{roomFilterList};
8891 delete $wmObj->{roomFilterHash};
8892 delete $wmObj->{roomFlagTextHash};
8893 delete $wmObj->{roomFlagPriorityHash};
8894 delete $wmObj->{roomFlagFilterHash};
8895 delete $wmObj->{roomFlagColourHash};
8896 delete $wmObj->{roomFlagDescripHash};
8897 # ( ->roomFlagOrderedList is retained)
8898 delete $wmObj->{roomFlagReverseHash};
8899 }
8900 }
8901  
8902 if ($version < 1_001_112) {
8903  
8904 # Update the room flag list
8905 $wmObj->updateRoomFlags($self->session);
8906 }
8907  
8908 if ($version < 1_001_115) {
8909  
8910 # This version corrects drawing issues with unallocated exits, on which a 'confirm
8911 # two-way exit' operation was performed
8912 # Check every exit in the model, looking 2-way exits and not region exits, at least
8913 # one of which has been allocated a direction, whose ->mapDirs are not opposites
8914 # and which are not marked as broken exits
8915 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
8916  
8917 my $twinExitObj;
8918  
8919 if (
8920 defined $exitObj->twinExit
8921 && ! $exitObj->regionFlag
8922 && $exitObj->drawMode eq 'perm_alloc'
8923 && ! $exitObj->brokenFlag
8924 ) {
8925 $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->twinExit);
8926  
8927 if (
8928 ! $twinExitObj->brokenFlag
8929 && $axmud::CLIENT->ivShow('constOppDirHash', $exitObj->mapDir)
8930 ne $twinExitObj->mapDir
8931 ) {
8932 # The problem is fixed by marking both as bent broken exits
8933 $exitObj->ivPoke('brokenFlag', TRUE);
8934 $exitObj->ivPoke('bentFlag', TRUE);
8935 $twinExitObj->ivPoke('brokenFlag', TRUE);
8936 $twinExitObj->ivPoke('bentFlag', TRUE);
8937 }
8938 }
8939 }
8940 }
8941  
8942 if ($version < 1_001_118) {
8943  
8944 # This version adds new IVs to the world model
8945 if (! exists $wmObj->{showNotesFlag}) {
8946  
8947 $wmObj->{showNotesFlag} = undef;
8948 $wmObj->ivPoke('showNotesFlag', TRUE);
8949 $wmObj->{allowCtrlCopyFlag} = undef;
8950 $wmObj->ivPoke('allowCtrlCopyFlag', TRUE);
8951 }
8952 }
8953  
8954 if ($version < 1_001_234) {
8955  
8956 # This version adds a new IV to the world model
8957 if (! exists $wmObj->{mapLabelTextViewFlag}) {
8958  
8959 $wmObj->{mapLabelTextViewFlag} = undef;
8960 $wmObj->ivPoke('mapLabelTextViewFlag', FALSE);
8961 }
8962 }
8963  
8964 if ($version < 1_001_235) {
8965  
8966 # This version adds a new IV to all room model objects
8967 foreach my $obj ($wmObj->ivValues('roomModelHash')) {
8968  
8969 if (! exists $obj->{unspecifiedPatternList}) {
8970  
8971 $obj->{unspecifiedPatternList} = [];
8972 $obj->ivEmpty('unspecifiedPatternList');
8973 }
8974 }
8975 }
8976  
8977 if ($version < 1_001_240) {
8978  
8979 # This version adds new IVs to the world model
8980 if (! exists $wmObj->{autoSlideMode}) {
8981  
8982 $wmObj->{autoSlideMode} = undef;
8983 $wmObj->ivPoke('autoSlideMode', 'default');
8984 $wmObj->{autoSlideMax} = undef;
8985 $wmObj->ivPoke('autoSlideMax', 10);
8986 }
8987 }
8988  
8989 if ($version < 1_001_241) {
8990  
8991 # This version removes an IV from all room model objects
8992 foreach my $obj ($wmObj->ivValues('roomModelHash')) {
8993  
8994 delete $obj->{everMatchedFlag};
8995 }
8996 }
8997  
8998 if ($version < 1_001_250) {
8999  
9000 # This version adds a new IV to the world model
9001 if (! exists $wmObj->{autoRescueFlag}) {
9002  
9003 $wmObj->{autoRescueFlag} = undef;
9004 $wmObj->ivPoke('autoRescueFlag', FALSE);
9005 $wmObj->{autoRescueFirstFlag} = undef;
9006 $wmObj->ivPoke('autoRescueFirstFlag', FALSE);
9007 $wmObj->{autoRescuePromptFlag} = undef;
9008 $wmObj->ivPoke('autoRescuePromptFlag', FALSE);
9009 }
9010 }
9011  
9012 if ($version < 1_001_251) {
9013  
9014 # This version adds new IVs to the world model
9015 if (! exists $wmObj->{autoCompareMode}) {
9016  
9017 $wmObj->{autoCompareMode} = undef;
9018 if (! $wmObj->{autoCompareFlag}) {
9019 $wmObj->ivPoke('autoCompareMode', 'default');
9020 } else {
9021 $wmObj->ivPoke('autoCompareMode', 'new');
9022 }
9023  
9024 $wmObj->{autoCompareAllFlag} = undef;
9025 $wmObj->ivPoke('autoCompareAllFlag', FALSE);
9026 $wmObj->{autoCompareMax} = undef;
9027 $wmObj->ivPoke('autoCompareMax', 0);
9028 }
9029 }
9030  
9031 if ($version < 1_001_254) {
9032  
9033 # This version adds new IVs to the world model
9034 if (! exists $wmObj->{autoRescueNoMoveFlag}) {
9035  
9036 $wmObj->{autoRescueNoMoveFlag} = undef;
9037 $wmObj->ivPoke('autoRescueNoMoveFlag', FALSE);
9038 $wmObj->{autoRescueVisitsFlag} = undef;
9039 $wmObj->ivPoke('autoRescueVisitsFlag', FALSE);
9040 $wmObj->{autoRescueForceFlag} = undef;
9041 $wmObj->ivPoke('autoRescueForceFlag', FALSE);
9042 }
9043 }
9044  
9045 # if ($version < 1_001_289) {
9046 #
9047 # # This version adds new IVs to the world model
9048 # if (! exists $wmObj->{adjacentMode}) {
9049 #
9050 # $wmObj->{adjacentMode} = undef;
9051 # $wmObj->ivPoke('adjacentMode', 'near');
9052 # $wmObj->{adjacentCount} = undef;
9053 # $wmObj->ivPoke('adjacentCount', 1);
9054 # }
9055 # }
9056  
9057 if ($version < 1_001_290) {
9058  
9059 # This version adds a new IV to exit objects in the world model
9060 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
9061  
9062 if (! exists $exitObj->{altDir}) {
9063  
9064 $exitObj->{altDir} = undef;
9065 $exitObj->ivUndef('altDir');
9066 }
9067 }
9068 }
9069  
9070 if ($version < 1_001_295) {
9071  
9072 # This version adds new IVs to the world model
9073 if (! exists $wmObj->{defaultMysteryExitColour}) {
9074  
9075 $wmObj->{defaultMysteryExitColour} = undef;
9076 $wmObj->ivPoke('defaultMysteryExitColour', '#900700');
9077 $wmObj->{mysteryExitColour} = undef;
9078 $wmObj->ivPoke('mysteryExitColour', '#900700');
9079 }
9080 }
9081  
9082 if ($version < 1_001_295) {
9083  
9084 # This version adds a new IV to the world model
9085 if (! exists $wmObj->{quickPaintMultiFlag}) {
9086  
9087 $wmObj->{quickPaintMultiFlag} = undef;
9088 $wmObj->ivPoke('quickPaintMultiFlag', FALSE);
9089 }
9090 }
9091  
9092 if ($version < 1_001_306) {
9093  
9094 # This version fixes a flaw in the world model, in which room tags aren't deleted
9095 # when a whole region is deleted
9096 foreach my $tag ($wmObj->ivKeys('roomTagHash')) {
9097  
9098 my ($roomNum, $roomObj);
9099  
9100 $roomNum = $wmObj->ivShow('roomTagHash', $tag);
9101 $roomObj = $wmObj->ivShow('roomModelHash', $roomNum);
9102  
9103 if (! $roomObj || ! defined $roomObj->roomTag || $roomObj->roomTag ne $tag) {
9104  
9105 $wmObj->ivDelete('roomTagHash', $tag);
9106 }
9107 }
9108 }
9109  
9110 if ($version < 1_001_314) {
9111  
9112 # This version adds a new IV to all map label objects
9113 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
9114  
9115 foreach my $mapLabelObj ($regionmapObj->ivValues('gridLabelHash')) {
9116  
9117 # e.g. 'town_42'
9118 $mapLabelObj->{id} = $mapLabelObj->{region} . '_' . $mapLabelObj->{number};
9119 }
9120 }
9121 }
9122  
9123 if ($version < 1_001_318) {
9124  
9125 # Custom room flags did not have their ->customFlag IV set correctly. Fix it
9126 foreach my $roomFlagObj ($wmObj->ivValues('roomFlagHash')) {
9127  
9128 if ($roomFlagObj->filter eq 'custom') {
9129  
9130 $roomFlagObj->ivPoke('customFlag', TRUE);
9131 }
9132 }
9133 }
9134  
9135 if ($version < 1_001_320) {
9136  
9137 # This version removes an IV from region model objects
9138 foreach my $regionObj ($wmObj->ivValues('regionModelHash')) {
9139  
9140 delete $regionObj->{regionmapObj};
9141 }
9142 }
9143  
9144 if ($version < 1_001_325) {
9145  
9146 # This version adds new IVs room model objects
9147 foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {
9148  
9149 my $listRef;
9150  
9151 if (! exists $roomObj->{invRepExitHash}) {
9152  
9153 $roomObj->{involuntaryExitHash} = {};
9154 $roomObj->ivEmpty('involuntaryExitHash');
9155 $roomObj->{involuntaryExitPatternHash} = {};
9156 $roomObj->ivEmpty('involuntaryExitPatternHash');
9157  
9158 # Convert ->involuntaryExitPatternList to the new IV
9159 $listRef = $roomObj->{involuntaryExitPatternList};
9160 foreach my $pattern (@$listRef) {
9161  
9162 $roomObj->ivAdd('involuntaryExitPatternHash', $pattern, undef);
9163 }
9164  
9165 delete $roomObj->{involuntaryExitPatternList};
9166 }
9167 }
9168 }
9169  
9170 if ($version < 1_001_327) {
9171  
9172 my %newHash;
9173  
9174 # Room tags are supposed to be stored in lower-case letters. This version makes sure
9175 # that is so
9176 foreach my $tag ($wmObj->ivKeys('roomTagHash')) {
9177  
9178 $newHash{lc($tag)} = $wmObj->ivShow('roomTagHash', $tag);
9179 }
9180  
9181 $wmObj->ivPoke('roomTagHash', %newHash);
9182  
9183 foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {
9184  
9185 my $listRef;
9186  
9187 if (defined $roomObj->roomTag) {
9188  
9189 $roomObj->ivPoke('roomTag', lc($roomObj->roomTag));
9190 }
9191  
9192 # This version also adds a new IV to room model objects, and renames an existing
9193 # one
9194 if (! exists $roomObj->{repulseExitPatternHash}) {
9195  
9196 $roomObj->{repulseExitPatternHash} = {};
9197 $roomObj->ivEmpty('repulseExitPatternHash');
9198  
9199 # Convert ->repulseExitPatternList to the new IV
9200 $listRef = $roomObj->{repulseExitPatternList};
9201 foreach my $pattern (@$listRef) {
9202  
9203 $roomObj->ivAdd('repulseExitPatternHash', $pattern, undef);
9204 }
9205  
9206 delete $roomObj->{repulseExitPatternList};
9207  
9208 # Update the IV name
9209 $roomObj->{invRepExitHash} = $roomObj->{involuntaryExitHash};
9210 delete $roomObj->{involuntaryExitHash};
9211 }
9212 }
9213 }
9214  
9215 if ($version < 1_001_328) {
9216  
9217 my %regionHash;
9218  
9219 # This version repairs some errors in exit model objects introduced in certain
9220 # situations
9221 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
9222  
9223 my ($roomObj, $regionObj);
9224  
9225 # At some point in the past, two-way exits had their ->oneWayDir IV wrongly set.
9226 # This problem does not apply to more recent Axmud versions. Just update all
9227 # exits
9228 if (! $exitObj->oneWayFlag && defined $exitObj->oneWayDir) {
9229  
9230 $exitObj->ivUndef('oneWayDir');
9231 }
9232  
9233 # This error is fixed in this version
9234 if (! $exitObj->regionFlag && ($exitObj->superFlag || $exitObj->notSuperFlag)) {
9235  
9236 $exitObj->ivPoke('superFlag', FALSE);
9237 $exitObj->ivPoke('notSuperFlag', FALSE);
9238  
9239 $roomObj = $wmObj->ivShow('modelHash', $exitObj->parent);
9240 $regionObj = $wmObj->ivShow('modelHash', $roomObj->parent);
9241  
9242 # Any region paths using the exits will have to be updated
9243 $wmObj->ivAdd('updatePathHash', $exitObj->number, $regionObj->name);
9244 $wmObj->ivAdd('updateBoundaryHash', $exitObj->number, $regionObj->name);
9245 }
9246 }
9247 }
9248  
9249 if ($version < 1_001_329) {
9250  
9251 my %checkHash;
9252  
9253 $self->writeText('Applying essential world model update. Please be patient...');
9254 $axmud::CLIENT->desktopObj->updateWidgets(
9255 $self->_objClass . '->updateExtractedData',
9256 );
9257  
9258 # When pathfinding routines were updated to allow paths through adjacent regions,
9259 # region paths may have been affected. In addition, there were some problems with
9260 # 'safe' region paths which are supposed to avoid rooms with hazardous room flags,
9261 # but which didn't (in certain situations)
9262 # Check all region paths and replace any whose rooms are not in the same region
9263 OUTER: foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
9264  
9265 INNER: foreach my $regionPathObj ($regionmapObj->ivValues('regionPathHash')) {
9266  
9267 if (! exists $checkHash{$regionPathObj->startExit}) {
9268  
9269 foreach my $roomNum ($regionPathObj->roomList) {
9270  
9271 my ($roomObj, $firstExitObj);
9272  
9273 # (For speed, don't use ->ivShow)
9274 $roomObj = $wmObj->{modelHash}{$roomNum};
9275 $firstExitObj = $wmObj->{exitModelHash}{$regionPathObj->startExit};
9276  
9277 if (
9278 $roomObj
9279 && $firstExitObj
9280 && $roomObj->parent ne $regionmapObj->number
9281 ) {
9282 # Any region paths using the first exit will have to be updated
9283 $wmObj->ivAdd(
9284 'updatePathHash',
9285 $firstExitObj->number,
9286 $regionmapObj->name,
9287 );
9288  
9289 # (Only need to add each exit once)
9290 $checkHash{$regionPathObj->startExit} = undef;
9291  
9292 # (Don't need to check the rest of the rooms in this path)
9293 next INNER;
9294 }
9295 }
9296 }
9297 }
9298  
9299 # Update those region paths now
9300 if ($wmObj->updatePathHash) {
9301  
9302 $wmObj->updateRegionPaths($self->session);
9303 }
9304  
9305 # Now check for 'safe' region paths which should not have room with hazardous
9306 # room flags, but do
9307 INNER: foreach my $regionPathObj (
9308 $regionmapObj->ivValues('safeRegionPathHash')
9309 ) {
9310 if (! exists $checkHash{$regionPathObj->startExit}) {
9311  
9312 foreach my $roomNum ($regionPathObj->roomList) {
9313  
9314 my ($roomObj, $firstExitObj);
9315  
9316 # (For speed, don't use ->ivShow)
9317 $roomObj = $wmObj->{modelHash}{$roomNum};
9318 $firstExitObj = $wmObj->{exitModelHash}{$regionPathObj->startExit};
9319  
9320 foreach my $roomFlag ($roomObj->ivKeys('roomFlagHash')) {
9321  
9322 if (
9323 $axmud::CLIENT->ivExists('constRoomHazardHash', $roomFlag)
9324 ) {
9325 $regionmapObj->removePaths(
9326 $regionPathObj->startExit . '_'
9327 . $regionPathObj->stopExit,
9328 'safeRegionPathHash',
9329 );
9330  
9331 # (Don't need to check the rest of the rooms in this path)
9332 next INNER;
9333 }
9334 }
9335 }
9336 }
9337 }
9338 }
9339 }
9340  
9341 if ($version < 1_001_335) {
9342  
9343 # This version fixes a bug in which each regionmap's highest and lowest occupied
9344 # levels were set only with rooms, not with rooms and labels
9345 # Reset all highest/lowest levels
9346 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
9347  
9348 $wmObj->ivAdd('checkLevelsHash', $regionmapObj->name, undef);
9349 }
9350  
9351 $wmObj->updateRegionLevels();
9352 }
9353  
9354 if ($version < 1_001_358) {
9355  
9356 # This version adds new IVs to the world model
9357 if (! exists $wmObj->{preDrawMinRooms}) {
9358  
9359 $wmObj->{preDrawMinRooms} = undef;
9360 $wmObj->ivPoke('preDrawMinRooms', 500);
9361 $wmObj->{queueDrawMaxObjs} = undef;
9362 $wmObj->ivPoke('queueDrawMaxObjs', 500);
9363 }
9364 }
9365  
9366 # if ($version < 1_001_358) {
9367 #
9368 # # This version adds new IVs to the world model
9369 # if (! exists $wmObj->{fixedRoomTagFlag}) {
9370 #
9371 # $wmObj->{fixedRoomTagFlag} = undef;
9372 # $wmObj->ivPoke('fixedRoomTagFlag', FALSE);
9373 # $wmObj->{fixedRoomGuildFlag} = undef;
9374 # $wmObj->ivPoke('fixedRoomGuildFlag', FALSE);
9375 # $wmObj->{fixedExitTagFlag} = undef;
9376 # $wmObj->ivPoke('fixedExitTagFlag', FALSE);
9377 # $wmObj->{fixedLabelFlag} = undef;
9378 # $wmObj->ivPoke('fixedLabelFlag', FALSE);
9379 # }
9380 # }
9381  
9382 if ($version < 1_001_376) {
9383  
9384 # This version adds a new IV to the world model
9385 if (! exists $wmObj->{retainDrawMinRooms}) {
9386  
9387 $wmObj->{retainDrawMinRooms} = undef;
9388 $wmObj->ivPoke('retainDrawMinRooms', 500);
9389 }
9390 }
9391  
9392 if ($version < 1_001_408) {
9393  
9394 # This version compresses the world model. Before we do that, the ->_objName and
9395 # ->name IVs for room model object have become standardised, no longer depending
9396 # on the room's title or verbose description; update all room objects
9397 foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {
9398  
9399 $roomObj->{_objName} = 'room';
9400 $roomObj->{name} = 'room';
9401 }
9402  
9403 # Same for exit object, which no longer take the exit's direction as its ->name
9404 # (since the direction can change anyway)
9405 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
9406  
9407 $exitObj->{_objName} = 'exit';
9408 $exitObj->{name} = 'exit';
9409 }
9410  
9411 # Now we can compress the world model. For each room object and exit object, any IVs
9412 # which are set to default values can be completely removed. The new code gets its
9413 # default values from the room object and the exit object stored in the global
9414 # variables $DEFAULT_ROOM and $DEFAULT EXIT
9415 if ($wmObj->{modelHash}) {
9416  
9417 $self->writeText('Applying essential world model update. Please be patient...');
9418 $axmud::CLIENT->desktopObj->updateWidgets(
9419 $self->_objClass . '->updateExtractedData',
9420 );
9421 }
9422  
9423 foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {
9424  
9425 $roomObj->compress();
9426 }
9427  
9428 foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {
9429  
9430 $exitObj->compress();
9431 }
9432  
9433 # (This line makes sure the correct file object's ->modifyFlag is set)
9434 $wmObj->ivPoke('author', $wmObj->author);
9435 }
9436  
9437 if ($version < 1_001_409) {
9438  
9439 # This version adds a new IV to the world model
9440 if (! exists $wmObj->{roomFlagShowMode}) {
9441  
9442 $wmObj->{roomFlagShowMode} = undef;
9443 $wmObj->ivPoke('roomFlagShowMode', 'default');
9444 }
9445 }
9446  
9447 if ($version < 1_001_450) {
9448  
9449 # This version removes IVs from the world model
9450 delete $wmObj->{fixedRoomTagFlag};
9451 delete $wmObj->{fixedRoomGuildFlag};
9452 delete $wmObj->{fixedExitTagFlag};
9453 delete $wmObj->{fixedLabelFlag};
9454  
9455 # Also, the ->_objClass for room objects was set to the class of an exit object
9456 # instead, so let's fix that
9457 foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {
9458  
9459 $roomObj->{_objClass} = ref $roomObj;
9460 }
9461  
9462 if ($wmObj->{painterObj}) {
9463  
9464 $wmObj->{painterObj}->{_objClass} = ref $wmObj->{painterObj};
9465 }
9466 }
9467  
9468 if ($version < 1_001_453) {
9469  
9470 # This version adds a new IV to the world model
9471 if (! exists $wmObj->{blockUnselectFlag}) {
9472  
9473 $wmObj->{blockUnselectFlag} = undef;
9474 $wmObj->ivPoke('blockUnselectFlag', TRUE);
9475 }
9476 }
9477  
9478 if ($version < 1_001_456) {
9479  
9480 # This version adds a new IV to the world model
9481 if (! exists $wmObj->{queueDrawMaxExits}) {
9482  
9483 $wmObj->{queueDrawMaxExits} = undef;
9484 $wmObj->ivPoke('queueDrawMaxExits', 150);
9485 }
9486 }
9487  
9488 if ($version < 1_001_465) {
9489  
9490 # This version replaces an IV in map labels and map label styles
9491 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
9492  
9493 foreach my $labelObj ($regionmapObj->ivValues('gridLabelHash')) {
9494  
9495 delete $labelObj->{gravity};
9496  
9497 $labelObj->{rotateAngle} = undef;
9498 $labelObj->ivPoke('rotateAngle', 0);
9499 }
9500 }
9501  
9502 foreach my $styleObj ($wmObj->ivValues('mapLabelStyleHash')) {
9503  
9504 delete $styleObj->{gravity};
9505  
9506 $styleObj->{rotateAngle} = undef;
9507 $styleObj->ivPoke('rotateAngle', 0);
9508 }
9509  
9510 }
9511  
9512 if ($version < 1_001_517) {
9513  
9514 # This version changes the IVs used in pre-drawing operations
9515 if (! exists $wmObj->{preDrawAllowFlag}) {
9516  
9517 $wmObj->{preDrawAllowFlag} = undef;
9518 $wmObj->ivPoke('preDrawAllowFlag', TRUE);
9519  
9520 $wmObj->{preDrawRetainRooms} = undef;
9521 $wmObj->ivPoke('preDrawRetainRooms', $wmObj->{retainDrawMinRooms});
9522 delete $wmObj->{retainDrawMinRooms};
9523  
9524 delete $wmObj->{queueDrawMaxObjs};
9525 delete $wmObj->{queueDrawMaxExits};
9526  
9527 $wmObj->{preDrawAllocation} = undef;
9528 $wmObj->ivPoke('preDrawAllocation', 50);
9529 }
9530 }
9531  
9532 if ($version < 1_001_529) {
9533  
9534 # This version adds a new IV to the world model
9535 if (! exists $wmObj->{modelSaveFileCount}) {
9536  
9537 $wmObj->{modelSaveFileCount} = undef;
9538 $wmObj->ivPoke('modelSaveFileCount', 0);
9539 }
9540 }
9541  
9542 if ($version < 1_002_091) {
9543  
9544 # This version adds new IVs to the world model
9545 if (! exists $wmObj->{obscuredExitFlag}) {
9546  
9547 $wmObj->{obscuredExitFlag} = undef;
9548 $wmObj->ivPoke('obscuredExitFlag', FALSE);
9549 $wmObj->{obscuredExitRadius} = undef;
9550 $wmObj->ivPoke('obscuredExitRadius', 3);
9551 $wmObj->{maxObscuredExitRadius} = undef;
9552 $wmObj->ivPoke('maxObscuredExitRadius', 9);
9553 $wmObj->{obscuredExitRedrawFlag} = undef;
9554 $wmObj->ivPoke('obscuredExitRedrawFlag', FALSE);
9555 }
9556  
9557 # ...and to regionmaps
9558 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
9559  
9560 if (! exists $regionmapObj->{obscuredExitFlag}) {
9561  
9562 $regionmapObj->{obscuredExitFlag} = undef;
9563 $regionmapObj->ivPoke('obscuredExitFlag', FALSE);
9564 $regionmapObj->{obscuredExitRadius} = undef;
9565 $regionmapObj->ivPoke('obscuredExitRadius', 3);
9566  
9567 $regionmapObj->{drawOrnamentsFlag} = undef;
9568 if ($wmObj->drawExitMode eq 'ask_regionmap') {
9569 $regionmapObj->ivPoke('drawOrnamentsFlag', $wmObj->drawOrnamentsFlag);
9570 } else {
9571 $regionmapObj->ivPoke('drawOrnamentsFlag', FALSE);
9572 }
9573  
9574 $regionmapObj->{obscuredExitRedrawFlag} = undef;
9575 $regionmapObj->ivPoke('obscuredExitRedrawFlag', FALSE);
9576 }
9577 }
9578  
9579 }
9580  
9581 if ($version < 1_002_150) {
9582  
9583 # This version adds region schemes
9584 if (! exists $wmObj->{regionSchemeHash}) {
9585  
9586 # Remove colour IVs from the world model, and transfer them to a new 'default'
9587 # region scheme
9588 $wmObj->{regionSchemeHash} = {};
9589  
9590 $wmObj->{defaultSchemeObj} = undef;
9591 $wmObj->ivPoke(
9592 'defaultSchemeObj',
9593 Games::Axmud::Obj::RegionScheme->new($self->session, $wmObj, 'default'),
9594 );
9595  
9596 $wmObj->ivAdd('regionSchemeHash', 'default', $wmObj->defaultSchemeObj);
9597  
9598 foreach my $iv (
9599 qw(
9600 backgroundColour roomColour roomTextColour selectBoxColour borderColour
9601 currentBorderColour currentFollowBorderColour currentWaitBorderColour
9602 currentSelectBorderColour lostBorderColour lostSelectBorderColour
9603 ghostBorderColour ghostSelectBorderColour selectBorderColour
9604 roomAboveColour roomBelowColour roomTagColour selectRoomTagColour
9605 roomGuildColour selectRoomGuildColour exitColour selectExitColour
9606 selectExitTwinColour selectExitShadowColour randomExitColour
9607 impassableExitColour mysteryExitColour checkedDirColour dragExitColour
9608 exitTagColour selectExitTagColour mapLabelColour selectMapLabelColour
9609 )
9610 ) {
9611 # (All but on IV is copied to the new scheme object)
9612 if ($iv ne 'noBackgroundColour') {
9613  
9614 $wmObj->defaultSchemeObj->{$iv} = $wmObj->{$iv};
9615 }
9616  
9617 delete $wmObj->{$iv};
9618 }
9619  
9620 # Add a new IV to regionmaps
9621 foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {
9622  
9623 if (! exists $regionmapObj->{regionScheme}) {
9624  
9625 $regionmapObj->{regionScheme} = undef;
9626 $regionmapObj->ivUndef('regionScheme');
9627 }
9628 }
9629 }
9630 }
9631  
9632 if ($version < 1_003_003) {
9633  
9634 # This version fixes a typo in a world model IV
9635 if (! exists $wmObj->{maxObscuredExitRadius}) {
9636  
9637 $wmObj->{maxObscuredExitRadius} = undef;
9638 $wmObj->ivPoke('maxObscuredExitRadius', 9);
9639 delete $wmObj->{maxobscuredExitRadius};
9640 }
9641 }
9642  
9643 if ($version < 1_003_017) {
9644  
9645 # This version adds new IVs to the world model
9646 if (! exists $wmObj->{roomInteriorXOffset}) {
9647  
9648 $wmObj->{roomInteriorXOffset} = undef;
9649 $wmObj->ivPoke('roomInteriorXOffset', 0);
9650 $wmObj->{roomInteriorYOffset} = undef;
9651 $wmObj->ivPoke('roomInteriorYOffset', 0);
9652 }
9653 }
9654 }
9655  
9656 ### new built-in tasks (new IVs for existing tasks are below) #############################
9657  
9658 if ($self->fileType eq 'tasks') {
9659  
9660 if ($version < 1_000_342) {
9661  
9662 # This version adds a new built-in task. GA::Client->taskLabelHash must be updated,
9663 # but don't overwrite existing entries
9664 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'debug')) {
9665  
9666 $axmud::CLIENT->ivAdd('taskLabelHash', 'debug', 'debugger_task');
9667 }
9668  
9669 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'debugger')) {
9670  
9671 $axmud::CLIENT->ivAdd('taskLabelHash', 'debugger', 'debugger_task');
9672 }
9673 }
9674  
9675 if ($version < 1_000_424) {
9676  
9677 # This version adds two new built-in tasks
9678 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'raw')) {
9679  
9680 $axmud::CLIENT->ivAdd('taskLabelHash', 'raw', 'raw_text_task');
9681 }
9682  
9683 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'rawtext')) {
9684  
9685 $axmud::CLIENT->ivAdd('taskLabelHash', 'rawtext', 'raw_text_task');
9686 }
9687  
9688 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'token')) {
9689  
9690 $axmud::CLIENT->ivAdd('taskLabelHash', 'token', 'raw_token_task');
9691 }
9692  
9693 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'rawtoken')) {
9694  
9695 $axmud::CLIENT->ivAdd('taskLabelHash', 'rawtoken', 'raw_token_task');
9696 }
9697 }
9698  
9699 if ($version < 1_000_622) {
9700  
9701 # This version adds a new built-in task
9702 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'note')) {
9703  
9704 $axmud::CLIENT->ivAdd('taskLabelHash', 'note', 'notepad_task');
9705 }
9706  
9707 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'notes')) {
9708  
9709 $axmud::CLIENT->ivAdd('taskLabelHash', 'notes', 'notepad_task');
9710 }
9711  
9712 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'notepad')) {
9713  
9714 $axmud::CLIENT->ivAdd('taskLabelHash', 'notepad', 'notepad_task');
9715 }
9716 }
9717  
9718 if ($version < 1_000_827) {
9719  
9720 # This version adds a new built-in task
9721 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'frame')) {
9722  
9723 $axmud::CLIENT->ivAdd('taskLabelHash', 'frame', 'frame_task');
9724 }
9725 }
9726  
9727 if ($version < 1_000_881) {
9728  
9729 # This version adds a new built-in task
9730 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'launch')) {
9731  
9732 $axmud::CLIENT->ivAdd('taskLabelHash', 'launch', 'launch_task');
9733 $axmud::CLIENT->ivAdd('taskLabelHash', 'launcher', 'launch_task');
9734 }
9735 }
9736  
9737 if ($version < 1_001_127) {
9738  
9739 # This version adds a new built-in task
9740 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'channels')) {
9741  
9742 $axmud::CLIENT->ivAdd('taskLabelHash', 'chan', 'channels_task');
9743 $axmud::CLIENT->ivAdd('taskLabelHash', 'channel', 'channels_task');
9744 $axmud::CLIENT->ivAdd('taskLabelHash', 'channels', 'channels_task');
9745 }
9746 }
9747  
9748 if ($version < 1_001_164) {
9749  
9750 # This version renames the built-in Debugger task as the System task. Existing
9751 # Debugger tasks are updated below
9752 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'debugger')) {
9753  
9754 $axmud::CLIENT->ivDelete('taskLabelHash', 'debug');
9755 $axmud::CLIENT->ivDelete('taskLabelHash', 'debugger');
9756  
9757 $axmud::CLIENT->ivAdd('taskLabelHash', 'sys', 'system_task');
9758 $axmud::CLIENT->ivAdd('taskLabelHash', 'system', 'system_task');
9759 }
9760 }
9761  
9762 if ($version < 1_001_386) {
9763  
9764 # This version adds new built-in tasks
9765 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'countdown')) {
9766  
9767 $axmud::CLIENT->ivAdd('taskLabelHash', 'cd', 'countdown_task');
9768 $axmud::CLIENT->ivAdd('taskLabelHash', 'count', 'countdown_task');
9769 $axmud::CLIENT->ivAdd('taskLabelHash', 'countdown', 'countdown_task');
9770  
9771 $axmud::CLIENT->ivAdd('taskLabelHash', 'mc', 'map_check_task');
9772 $axmud::CLIENT->ivAdd('taskLabelHash', 'map', 'map_check_task');
9773 $axmud::CLIENT->ivAdd('taskLabelHash', 'mapcheck', 'map_check_task');
9774 }
9775 }
9776  
9777 if ($version < 1_001_388) {
9778  
9779 # This version adds a new built-in task
9780 if (! $axmud::CLIENT->ivExists('taskLabelHash', 'connections')) {
9781  
9782 $axmud::CLIENT->ivAdd('taskLabelHash', 'conn', 'connections_task');
9783 $axmud::CLIENT->ivAdd('taskLabelHash', 'connect', 'connections_task');
9784 $axmud::CLIENT->ivAdd('taskLabelHash', 'connections', 'connections_task');
9785 }
9786 }
9787 }
9788  
9789 ### worldprof / otherprof / tasks #########################################################
9790  
9791 if (
9792 $self->fileType eq 'worldprof'
9793 || $self->fileType eq 'otherprof'
9794 || $self->fileType eq 'tasks'
9795 ) {
9796 if ($version < 1_000_037 && $self->session) {
9797  
9798 # This version updated the Locator task with a new IV. Update all initial/custom
9799 # tasks
9800 foreach my $taskObj ($self->compileTasks('locator_task')) {
9801  
9802 if (! exists $taskObj->{lastStatementEndLine}) {
9803  
9804 $taskObj->{lastStatementEndLine} = undef;
9805 $taskObj->ivUndef('lastStatementEndLine');
9806 }
9807 }
9808 }
9809  
9810 if ($version < 1_000_066 && $self->session) {
9811  
9812 # This version updated the Attack task with a new IV. Update all initial/custom
9813 # tasks
9814 foreach my $taskObj ($self->compileTasks('attack_task')) {
9815  
9816 if (! exists $taskObj->{announceFlag}) {
9817  
9818 $taskObj->{announceFlag} = undef;
9819 $taskObj->ivPoke('announceFlag', TRUE);
9820 }
9821 }
9822 }
9823  
9824 if ($version < 1_000_078 && $self->session) {
9825  
9826 # This version updated the Locator task with a new IV. Update all initial/custom
9827 # tasks
9828 foreach my $taskObj ($self->compileTasks('locator_task')) {
9829  
9830 if (! exists $taskObj->{restartBufferLine}) {
9831  
9832 $taskObj->{restartBufferLine} = undef;
9833 $taskObj->ivUndef('restartBufferLine');
9834 }
9835 }
9836 }
9837  
9838 if ($version < 1_000_081 && $self->session) {
9839  
9840 # This version updated the Inventory task with a new IV. Update all initial/custom
9841 # tasks
9842 foreach my $taskObj ($self->compileTasks('inventory_task')) {
9843  
9844 if (! exists $taskObj->{resetInventoryFlag}) {
9845  
9846 $taskObj->{resetInventoryFlag} = undef;
9847 $taskObj->ivPoke('resetInventoryFlag', FALSE);
9848 }
9849 }
9850 }
9851  
9852 if ($version < 1_000_090 && $self->session) {
9853  
9854 # This version updates the Status task, using a single string (e.g.
9855 # 'health_points_max') rather than two strings to represent the same thing (e.g.
9856 # 'health_max', 'health_points_max'
9857 my %updateHash = (
9858 '@health_max@' => '@health_points_max@',
9859 '@magic_max@' => '@magic_points_max@',
9860 '@energy_max@' => '@energy_points_max@',
9861 '@guild_max@' => '@guild_points_max@',
9862 '@social_max@' => '@social_points_max@',
9863 );
9864  
9865 # Update all initial/custom tasks
9866 # (NB The world profile themselves were updated above)
9867 foreach my $taskObj ($self->compileTasks('status_task')) {
9868  
9869 my $listRef;
9870  
9871 $listRef = $taskObj->{defaultFormatList};
9872 foreach my $line (@$listRef) {
9873  
9874 foreach my $key (keys %updateHash) {
9875  
9876 my $value = $updateHash{$key};
9877  
9878 $line =~ s/$key/$value/g;
9879 }
9880 }
9881  
9882 $listRef = $taskObj->{displayVarList};
9883 foreach my $line (@$listRef) {
9884  
9885 foreach my $key (keys %updateHash) {
9886  
9887 my $value = $updateHash{$key};
9888  
9889 $line =~ s/$key/$value/g;
9890 }
9891 }
9892 }
9893 }
9894  
9895 if ($version < 1_000_119 && $self->session) {
9896  
9897 # This version updates all tasks with a new flag IV. Its value is set to TRUE for
9898 # the Inventory, Locator, Status and TaskList tasks, FALSE for everything else
9899 my %trueHash = (
9900 'inventory_task' => undef,
9901 'locator_task' => undef,
9902 'status_task' => undef,
9903 'tasklist_task' => undef,
9904 );
9905  
9906 foreach my $taskObj ($self->compileTasks()) {
9907  
9908 if (! exists $taskObj->{noScrollFlag}) {
9909  
9910 $taskObj->{noScrollFlag} = undef;
9911  
9912 if (exists $trueHash{$taskObj->{name}}) {
9913 $taskObj->{noScrollFlag} = TRUE;
9914 } else {
9915 $taskObj->{noScrollFlag} = FALSE;
9916 }
9917 }
9918 }
9919 }
9920  
9921 if ($version < 1_000_155 && $self->session) {
9922  
9923 # This version updated the Locator task with a new IV. Update all initial/custom
9924 # tasks
9925 foreach my $taskObj ($self->compileTasks('locator_task')) {
9926  
9927 if (! exists $taskObj->{lastStatementStartLine}) {
9928  
9929 $taskObj->{lastStatementStartLine} = undef;
9930 $taskObj->ivUndef('lastStatementStartLine');
9931 }
9932 }
9933 }
9934  
9935 if ($version < 1_000_198 && $self->session) {
9936  
9937 # This version updated the Status task with new IVs. Update all initial/custom
9938 # tasks
9939 foreach my $taskObj ($self->compileTasks('status_task')) {
9940  
9941 if (! exists $taskObj->{xpNextLevel}) {
9942  
9943 # (This IV subsequently renamed and/or removed)
9944 # $taskObj->{xpNextLevel} = undef;
9945 # $taskObj->ivUndef('xpNextLevel');
9946 $taskObj->{xpNextLevel} = undef;
9947 # (This IV subsequently renamed and/or removed)
9948 # $taskObj->{alignment} = undef;
9949 # $taskObj->ivUndef('alignment');
9950 $taskObj->{alignment} = undef;
9951 $taskObj->{affectHash} = {};
9952 $taskObj->ivEmpty('affectHash');
9953  
9954 $taskObj->{oppName} = undef;
9955 $taskObj->ivUndef('oppName');
9956 $taskObj->{oppHealth} = undef;
9957 $taskObj->ivUndef('oppHealth');
9958 $taskObj->{oppHealthMax} = undef;
9959 $taskObj->ivUndef('oppHealthMax');
9960 $taskObj->{oppLevel} = undef;
9961 $taskObj->ivUndef('oppLevel');
9962 $taskObj->{oppStrength} = undef;
9963 $taskObj->ivUndef('oppStrength');
9964 }
9965 }
9966 }
9967  
9968 if ($version < 1_000_200 && $self->session) {
9969  
9970 # This version updated the Locator task with a new IV. Update all initial/custom
9971 # tasks
9972 foreach my $taskObj ($self->compileTasks('locator_task')) {
9973  
9974 if (! exists $taskObj->{msdpRoomHash}) {
9975  
9976 # (This IV subsequently renamed and/or removed)
9977 # $taskObj->{msdpRoomHash} = {};
9978 # $taskObj->ivEmpty('msdpRoomHash');
9979 $taskObj->{msdpRoomHash} = {};
9980 # $taskObj->{msdpExitHash} = {};
9981 # $taskObj->ivEmpty('msdpExitHash');
9982 $taskObj->{msdpExitHash} = {};
9983 }
9984 }
9985 }
9986  
9987 if ($version < 1_000_212 && $self->session) {
9988  
9989 # This version updated the Status task with a new IV. Update all initial/custom
9990 # tasks
9991 foreach my $taskObj ($self->compileTasks('status_task')) {
9992  
9993 if (! exists $taskObj->{customVarHash}) {
9994  
9995 $taskObj->{customVarHash} = {};
9996 $taskObj->ivEmpty('customVarHash');
9997 }
9998 }
9999 }
10000  
10001 if ($version < 1_000_344 && $self->session) {
10002  
10003 # This version updated the Divert task with new IVs. Update all initial/custom
10004 # tasks
10005 foreach my $taskObj ($self->compileTasks('divert_task')) {
10006  
10007 if (! exists $taskObj->{tellRoomFlag}) {
10008  
10009 $taskObj->{tellRoomFlag} = undef;
10010 $taskObj->ivPoke('tellRoomFlag', FALSE);
10011 $taskObj->{socialRoomFlag} = undef;
10012 $taskObj->ivPoke('socialRoomFlag', FALSE);
10013 $taskObj->{customRoomFlag} = undef;
10014 $taskObj->ivPoke('customRoomFlag', FALSE);
10015 $taskObj->{warningRoomFlag} = undef;
10016 $taskObj->ivPoke('warningRoomFlag', FALSE);
10017  
10018 $taskObj->{tellUrgencyFlag} = undef;
10019 $taskObj->ivPoke('tellUrgencyFlag', TRUE);
10020 $taskObj->{socialUrgencyFlag} = undef;
10021 $taskObj->ivPoke('socialUrgencyFlag', TRUE);
10022 $taskObj->{customUrgencyFlag} = undef;
10023 $taskObj->ivPoke('customUrgencyFlag', TRUE);
10024 $taskObj->{warningUrgencyFlag} = undef;
10025 $taskObj->ivPoke('warningUrgencyFlag', TRUE);
10026 }
10027 }
10028 }
10029  
10030 if ($version < 1_000_424 && $self->session) {
10031  
10032 # This version updated the Debugger task by changing its window type from 'entry'
10033 # to 'text'. Update all initial/custom tasks
10034 foreach my $taskObj ($self->compileTasks('debugger_task')) {
10035  
10036 # (This IV subsequently renamed and/or removed)
10037 # $taskObj->{winType} = undef;
10038 # $taskObj->ivPoke('winType', 'text');
10039 $taskObj->{winType} = 'text';
10040 }
10041 }
10042  
10043 if ($version < 1_000_482 && $self->session) {
10044  
10045 # This version changes character life status. Update all initial/custom tasks
10046 foreach my $taskObj ($self->compileTasks('status_task')) {
10047  
10048 # (This IV subsequently renamed and/or removed)
10049 if ($taskObj->{lifeStatus} eq 'asleep') {
10050 # $taskObj->ivPoke('lifeStatus', 'sleep');
10051 $taskObj->{lifeStatus} = 'sleep';
10052 } elsif ($taskObj->{lifeStatus} eq 'passed_out') {
10053 # $taskObj->ivPoke('lifeStatus', 'passout');
10054 $taskObj->{lifeStatus} = 'passout';
10055 }
10056 }
10057 }
10058  
10059 if ($version < 1_000_509 && $self->session) {
10060  
10061 # This version updated the Status task with a new IV. Update all initial/custom
10062 # tasks
10063 foreach my $taskObj ($self->compileTasks('status_task')) {
10064  
10065 if (! exists $taskObj->{commifyMode}) {
10066  
10067 $taskObj->{commifyMode} = undef;
10068 $taskObj->ivPoke('commifyMode', 0);
10069 }
10070 }
10071 }
10072  
10073 if ($version < 1_000_572 && $self->session) {
10074  
10075 # This version updated the Locator task with a new IV. Update all initial/custom
10076 # tasks
10077 foreach my $taskObj ($self->compileTasks('locator_task')) {
10078  
10079 if (! exists $taskObj->{autoLookMode}) {
10080  
10081 $taskObj->{autoLookMode} = undef;
10082 $taskObj->ivPoke('autoLookMode', 1);
10083 }
10084 }
10085 }
10086  
10087 if ($version < 1_000_577 && $self->session) {
10088  
10089 # This version updated the Divert task with new IVs. Update all initial/custom
10090 # tasks
10091 foreach my $taskObj ($self->compileTasks('divert_task')) {
10092  
10093 if (! exists $taskObj->{lastLine}) {
10094  
10095 $taskObj->{lastLine} = undef;
10096 $taskObj->ivPoke('lastLine', 0);
10097 # (This IV subsequently renamed and/or removed)
10098 # $taskObj->{gagFlag} = undef;
10099 # $taskObj->ivPoke('gagFlag', TRUE);
10100 $taskObj->{gagFlag} = TRUE;
10101 }
10102 }
10103 }
10104  
10105 if ($version < 1_000_580 && $self->session) {
10106  
10107 # This version updated the Inventory task with a new IV. Update all initial/custom
10108 # tasks
10109 foreach my $taskObj ($self->compileTasks('inventory_task')) {
10110  
10111 if (! exists $taskObj->{lastLine}) {
10112  
10113 $taskObj->{lastLine} = undef;
10114 $taskObj->ivPoke('lastLine', 0);
10115 }
10116 }
10117 }
10118  
10119 if ($version < 1_000_599 && $self->session) {
10120  
10121 # This version updated the Locator and Status tasks with new IVs. Update all
10122 # initial/custom tasks
10123 foreach my $taskObj ($self->compileTasks('locator_task')) {
10124  
10125 if (! exists $taskObj->{ttsToReadHash}) {
10126  
10127 $taskObj->{ttsToReadHash} = {};
10128 $taskObj->ivEmpty('ttsToReadHash');
10129 }
10130 }
10131  
10132 foreach my $taskObj ($self->compileTasks('status_task')) {
10133  
10134 if (! exists $taskObj->{ttsPointsAlertHash}) {
10135  
10136 $taskObj->{ttsPointsAlertHash} = {};
10137 $taskObj->ivEmpty('ttsPointsAlertHash');
10138 $taskObj->{ttsPointsAlertMsgHash} = {};
10139 $taskObj->ivEmpty('ttsPointsAlertMsgHash');
10140 }
10141 }
10142 }
10143  
10144 if ($version < 1_000_606 && $self->session) {
10145  
10146 # This version updated the Compass task with a new IV. Update all initial/custom
10147 # tasks
10148 foreach my $taskObj ($self->compileTasks('compass_task')) {
10149  
10150 if (! exists $taskObj->{enabledFlag}) {
10151  
10152 # (Existing users expect the task to start disabled, but new users will
10153 # see the task start enabled)
10154 $taskObj->{enabledFlag} = undef;
10155 $taskObj->ivPoke('enabledFlag', FALSE);
10156  
10157 # (This IV subsequently renamed and/or removed)
10158 # $taskObj->{radioButton2} = undef;
10159 # $taskObj->ivUndef('radioButton2');
10160 $taskObj->{radioButton2} = undef;
10161 }
10162 }
10163 }
10164  
10165 if ($version < 1_000_607 && $self->session) {
10166  
10167 # This version updates all tasks with a new IV, and removes another IV
10168 foreach my $taskObj ($self->compileTasks()) {
10169  
10170 if (! exists $taskObj->{winUpdateFunc}) {
10171  
10172 $taskObj->{winUpdateFunc} = undef;
10173  
10174 if ($taskObj->{name} eq 'compass_task') {
10175 $taskObj->ivPoke('winUpdateFunc', 'createWidgets');
10176 } elsif ($taskObj->{name} eq 'divert_task') {
10177 $taskObj->ivPoke('winUpdateFunc', 'restoreWin');
10178 } elsif ($taskObj->{name} eq 'locator_task') {
10179 $taskObj->ivPoke('winUpdateFunc', 'updateWin');
10180 } elsif ($taskObj->{name} eq 'status_task') {
10181 $taskObj->ivPoke('winUpdateFunc', 'updateWin');
10182 } else {
10183 $taskObj->ivUndef('winUpdateFunc');
10184 }
10185  
10186 delete $taskObj->{winOpenFlag};
10187 }
10188 }
10189 }
10190  
10191 if ($version < 1_000_608 && $self->session) {
10192  
10193 # This version updated the Divert task with a new IV. Update all initial/custom
10194 # tasks
10195 foreach my $taskObj ($self->compileTasks('divert_task')) {
10196  
10197 if (! exists $taskObj->{lineList}) {
10198  
10199 $taskObj->{lineList} = [];
10200 $taskObj->ivEmpty('lineList');
10201 }
10202 }
10203 }
10204  
10205 if ($version < 1_000_618 && $self->session) {
10206  
10207 # This version updates all tasks with new IVs
10208 foreach my $taskObj ($self->compileTasks()) {
10209  
10210 if (! exists $taskObj->{ttsFlag}) {
10211  
10212 $taskObj->{ttsFlag} = undef;
10213  
10214 if (
10215 $taskObj->{name} eq 'attack_task'
10216 || $taskObj->{name} eq 'chat_task'
10217 || $taskObj->{name} eq 'divert_task'
10218 || $taskObj->{name} eq 'locator_task'
10219 || $taskObj->{name} eq 'status_task'
10220 || $taskObj->{name} eq 'watch_task'
10221 ) {
10222 $taskObj->ivPoke('ttsFlag', TRUE);
10223 } else {
10224 $taskObj->ivPoke('ttsFlag', FALSE);
10225 }
10226  
10227 $taskObj->{ttsProfile} = undef;
10228 $taskObj->ivUndef('ttsProfile');
10229  
10230 $taskObj->{ttsAttribHash} = {};
10231 $taskObj->{ttsFlagAttribHash} = {};
10232 $taskObj->{ttsAlertAttribHash} = {};
10233  
10234 if ($taskObj->{name} eq 'attack_task') {
10235  
10236 $taskObj->ivEmpty('ttsAttribHash');
10237  
10238 $taskObj->ivPoke(
10239 'ttsFlagAttribHash',
10240 'fight', FALSE,
10241 'interact', FALSE,
10242 'interaction', FALSE,
10243 );
10244  
10245 $taskObj->ivEmpty('ttsAlertAttribHash');
10246  
10247 } elsif ($taskObj->{name} eq 'chat_task') {
10248  
10249 $taskObj->ivEmpty('ttsAttribHash');
10250  
10251 $taskObj->ivPoke(
10252 'ttsFlagAttribHash',
10253 'chat', FALSE,
10254 'chatout', FALSE,
10255 'chatin', FALSE,
10256 'chatecho', FALSE,
10257 'chatsystem', FALSE,
10258 'chatremote', FALSE,
10259 'chatsnoop', FALSE,
10260 );
10261  
10262 $taskObj->ivEmpty('ttsAlertAttribHash');
10263  
10264 } elsif ($taskObj->{name} eq 'divert_task') {
10265  
10266 $taskObj->ivEmpty('ttsAttribHash');
10267  
10268 $taskObj->ivPoke(
10269 'ttsFlagAttribHash',
10270 'divert', FALSE,
10271 'tell', FALSE,
10272 'social', FALSE,
10273 'custom', FALSE,
10274 'warning', FALSE,
10275 );
10276  
10277 $taskObj->ivEmpty('ttsAlertAttribHash');
10278  
10279 } elsif ($taskObj->{name} eq 'locator_task') {
10280  
10281 $taskObj->ivPoke(
10282 'ttsAttribHash',
10283 'title', undef,
10284 'descrip', undef,
10285 'description', undef,
10286 'exit', undef,
10287 'exits', undef,
10288 'content', undef,
10289 'contents', undef,
10290 );
10291  
10292 $taskObj->ivPoke(
10293 'ttsFlagAttribHash',
10294 'title', FALSE,
10295 'descrip', FALSE,
10296 'description', FALSE,
10297 'exit', FALSE,
10298 'exits', FALSE,
10299 'content', FALSE,
10300 'contents', FALSE,
10301 );
10302  
10303 $taskObj->ivEmpty('ttsAlertAttribHash');
10304  
10305 } elsif ($taskObj->{name} eq 'status_task') {
10306  
10307 $taskObj->ivPoke(
10308 'ttsAttribHash',
10309 'status' => undef,
10310 'life' => undef,
10311 'lives' => undef,
10312 'health' => undef,
10313 'magic' => undef,
10314 'energy' => undef,
10315 'guild' => undef,
10316 'social' => undef,
10317 'xp' => undef,
10318 'experience' => undef,
10319 'level' => undef,
10320 'align' => undef,
10321 'alignment' => undef,
10322 'age' => undef,
10323 'time' => undef,
10324 'bank' => undef,
10325 'purse' => undef,
10326 );
10327  
10328 $taskObj->ivPoke(
10329 'ttsFlagAttribHash',
10330 'life' => FALSE,
10331 );
10332  
10333 $taskObj->ivPoke(
10334 'ttsAlertAttribHash',
10335 'healthup', undef,
10336 'healthdown', undef,
10337 'magicup', undef,
10338 'magicdown', undef,
10339 'energyup', undef,
10340 'energydown', undef,
10341 'guildup', undef,
10342 'guilddown', undef,
10343 'socialup', undef,
10344 'socialdown', undef,
10345 );
10346  
10347 } elsif ($taskObj->{name} eq 'watch_task') {
10348  
10349 $taskObj->ivEmpty('ttsAttribHash');
10350  
10351 $taskObj->ivPoke(
10352 'ttsFlagAttribHash',
10353 'watch', FALSE,
10354 );
10355  
10356 $taskObj->ivEmpty('ttsAlertAttribHash');
10357  
10358 } else {
10359  
10360 $taskObj->ivEmpty('ttsAttribHash');
10361 $taskObj->ivEmpty('ttsFlagAttribHash');
10362 $taskObj->ivEmpty('ttsAlertAttribHash');
10363 }
10364 }
10365 }
10366 }
10367  
10368 if ($version < 1_000_619 && $self->session) {
10369  
10370 # This version updates all tasks with a new flag IV. Its value is set to TRUE for
10371 # the Divert, Script and Watch tasks, FALSE for everything else
10372 my %trueHash = (
10373 'divert_task' => undef,
10374 'script_task' => undef,
10375 'watch_task' => undef,
10376 );
10377  
10378 foreach my $taskObj ($self->compileTasks()) {
10379  
10380 if (! exists $taskObj->{allowLinkFlag}) {
10381  
10382 $taskObj->{allowLinkFlag} = undef;
10383  
10384 if (exists $trueHash{$taskObj->{name}}) {
10385 $taskObj->{allowLinkFlag} = TRUE;
10386 } else {
10387 $taskObj->{allowLinkFlag} = FALSE;
10388 }
10389 }
10390 }
10391 }
10392  
10393 if ($version < 1_000_684 && $self->session) {
10394  
10395 # This version updated the Status task with new IVs. Update all initial/custom
10396 # tasks
10397 my %varHash = (
10398 'health_points' => 'healthPoints',
10399 'health_points_max' => 'healthPointsMax',
10400 'magic_points' => 'magicPoints',
10401 'magic_points_max' => 'magicPointsMax',
10402 'energy_points' => 'energyPoints',
10403 'energy_points_max' => 'energyPointsMax',
10404 'guild_points' => 'guildPoints',
10405 'guild_points_max' => 'guildPointsMax',
10406 'social_points' => 'socialPoints',
10407 'social_points_max' => 'socialPointsMax',
10408 'xp_current' => 'xpCurrent',
10409 'xp_next_level' => 'xpNextLevel',
10410 'xp_total' => 'xpTotal',
10411 'quest_points' => 'questPointCount',
10412 'quest_points_max' => 'worldQuestPointCount',
10413 'quest_count' => 'questCount',
10414 'quest_count_max' => 'worldQuestCount',
10415 'level' => 'level',
10416 'life_count' => 'lifeCount',
10417 'death_count' => 'deathCount',
10418 'life_max' => 'lifeMax',
10419 'local_wimpy' => 'localWimpy',
10420 'remote_wimpy' => 'remoteWimpy',
10421 'remote_wimpy_max' => 'remoteWimpyMax',
10422 'local_wimpy_max' => '_localWimpyMax',
10423 'bank_balance' => 'bankBalance',
10424 'purse_contents' => 'purseContents',
10425 'opp_health' => 'oppHealth',
10426 'opp_health_max' => 'oppHealthMax',
10427 'opp_level' => 'oppLevel',
10428 'opp_strength' => 'oppStrength',
10429 );
10430  
10431 my @varList = (
10432 'health_points', 'health_points_max', FALSE, 'HP',
10433 'RED', 'red', 'WHITE',
10434 'magic_points', 'magic_points_max', FALSE, 'MP',
10435 'YELLOW', 'yellow', 'black',
10436 'energy_points', 'energy_points_max', FALSE, 'EP',
10437 'GREEN', 'green', 'black',
10438 'guild_points', 'guild_points_max', FALSE, 'GP',
10439 'BLUE', 'blue', 'WHITE',
10440 'social_points', 'social_points_max', FALSE, 'SP',
10441 'MAGENTA', 'magenta', 'WHITE',
10442 );
10443  
10444 foreach my $taskObj ($self->compileTasks('status_task')) {
10445  
10446 if (! exists $taskObj->{singleBackRefVarHash}) {
10447  
10448 # (This IV subsequently renamed and/or removed)
10449 # $taskObj->{singleBackRefVarHash} = {};
10450 # $taskObj->ivPoke('singleBackRefVarHash', %varHash);
10451 $taskObj->{singleBackRefVarHash} = {%varHash};
10452  
10453 $taskObj->{gaugeFlag} = undef;
10454 $taskObj->ivPoke('gaugeFlag', FALSE);
10455 $taskObj->{gaugeValueFlag} = undef;
10456 $taskObj->ivPoke('gaugeValueFlag', TRUE);
10457  
10458 # (This IV subsequently renamed and/or removed)
10459 # $taskObj->{defaultGaugeFormatList} = [];
10460 # $taskObj->ivPoke('defaultGaugeFormatList', @varList);
10461 $taskObj->{defaultGaugeFormatList} = [@varList];
10462 $taskObj->{gaugeObjList} = [];
10463 $taskObj->ivEmpty('gaugeObjList');
10464 }
10465 }
10466 }
10467  
10468 if ($version < 1_000_689 && $self->session) {
10469  
10470 # This version updated the Status task with a new IV. Update all initial/custom
10471 # tasks
10472 foreach my $taskObj ($self->compileTasks('status_task')) {
10473  
10474 if (! exists $taskObj->{gaugeResetFlag}) {
10475  
10476 $taskObj->{gaugeResetFlag} = undef;
10477 $taskObj->ivPoke('gaugeResetFlag', FALSE);
10478 }
10479 }
10480 }
10481  
10482 # (These IVs subsequently renamed and/or removed)
10483 # if ($version < 1_000_691 && $self->session) {
10484 #
10485 # # This version switched the order of some IVs in the Status task. Update all
10486 # # initial/custom tasks
10487 # foreach my $taskObj ($self->compileTasks('status_task')) {
10488 #
10489 # my $string;
10490 #
10491 # $string = $taskObj->ivIndex('defaultFormatList', 1);
10492 #
10493 # # (No reason why any of these conditions should fail; these IVs aren't
10494 # # supposed to be altered)
10495 # if ($string =~ m/^HP\: \@health_points\@.*\(\@social_points_max\@\)$/) {
10496 #
10497 # $taskObj->ivReplace(
10498 # 'defaultFormatList',
10499 # 1,
10500 # 'HP: @health_points@ (@health_points_max@) MP: @magic_points@'
10501 # . ' (@magic_points_max@) EP: @energy_points@ (@energy_points_max@)'
10502 # . ' GP: @guild_points@ (@guild_points_max@) SP: @social_points@'
10503 # . ' (@social_points_max@)',
10504 # );
10505 # }
10506 #
10507 # if (
10508 # $taskObj->ivIndex('displayVarList', 4) eq 'health_points'
10509 # && $taskObj->ivIndex('displayVarList', 6) eq 'energy_points'
10510 # ) {
10511 # $taskObj->ivReplace('displayVarList', 6, 'magic_points');
10512 # $taskObj->ivReplace('displayVarList', 7, 'magic_points_max');
10513 # $taskObj->ivReplace('displayVarList', 8, 'energy_points');
10514 # $taskObj->ivReplace('displayVarList', 9, 'energy_points_max');
10515 # }
10516 #
10517 # if (
10518 # $taskObj->ivIndex('singleBackRefVarList', 2) eq 'energy_points'
10519 # && $taskObj->ivIndex('singleBackRefVarList', 4) eq 'magic_points'
10520 # ) {
10521 # $taskObj->ivReplace('singleBackRefVarList', 2, 'magic_points');
10522 # $taskObj->ivReplace('singleBackRefVarList', 3, 'magic_points_max');
10523 # $taskObj->ivReplace('singleBackRefVarList', 4, 'energy_points');
10524 # $taskObj->ivReplace('singleBackRefVarList', 5, 'energy_points_max');
10525 # }
10526 # }
10527 # }
10528  
10529 if ($version < 1_000_692 && $self->session) {
10530  
10531 # This version updated the Status task with a new IV. Update all initial/custom
10532 # tasks
10533 foreach my $taskObj ($self->compileTasks('status_task')) {
10534  
10535 if (! exists $taskObj->{gaugeLevel}) {
10536  
10537 $taskObj->{gaugeLevel} = undef;
10538 $taskObj->ivUndef('gaugeLevel');
10539 }
10540 }
10541 }
10542  
10543 if ($version < 1_000_693 && $self->session) {
10544  
10545 # This version updated the Script task with new IVs. Update all initial/custom
10546 # tasks
10547 foreach my $taskObj ($self->compileTasks('script_task')) {
10548  
10549 if (! exists $taskObj->{gaugeLevel}) {
10550  
10551 $taskObj->{gaugeLevel} = undef;
10552 $taskObj->ivUndef('gaugeLevel');
10553 $taskObj->{gaugeHash} = {};
10554 $taskObj->ivEmpty('gaugeHash');
10555 }
10556 }
10557 }
10558  
10559 if ($version < 1_000_700 && $self->session) {
10560  
10561 # This version updated the Script task with a new IV. Update all initial/custom
10562 # tasks
10563 foreach my $taskObj ($self->compileTasks('script_task')) {
10564  
10565 if (! exists $taskObj->{statusBarHash}) {
10566  
10567 $taskObj->{statusBarHash} = {};
10568 $taskObj->ivEmpty('statusBarHash');
10569 }
10570 }
10571 }
10572  
10573 if ($version < 1_000_800 && $self->session) {
10574  
10575 # This version updates all tasks, modifying some IVs and adding/removing others.
10576 # Update all initial/custom tasks
10577 foreach my $taskObj ($self->compileTasks()) {
10578  
10579 if (exists $taskObj->{allowLinkFlag}) {
10580  
10581 $taskObj->{defaultTabObj} = undef;
10582 $taskObj->{tableObj} = undef;
10583 $taskObj->{taskWinFlag} = FALSE;
10584 $taskObj->{taskWinEntryFlag} = FALSE;
10585  
10586 $taskObj->{winPreferList} = [];
10587 if (
10588 $taskObj->{name} eq 'compass_task' || $taskObj->{name} eq 'notepad_task'
10589 || $taskObj->{name} eq 'script_task'
10590 ) {
10591 $taskObj->{winPreferList} = ['pseudo', 'grid'];
10592 } elsif (
10593 $taskObj->{name} eq 'debugger_task'
10594 || $taskObj->{name} eq 'inventory_task'
10595 || $taskObj->{name} eq 'locator'
10596 || $taskObj->{name} eq 'raw_text_task'
10597 || $taskObj->{name} eq 'raw_token_task'
10598 || $taskObj->{name} eq 'status_task'
10599 || $taskObj->{name} eq 'tasklist_task'
10600 || $taskObj->{name} eq 'watch_task'
10601 ) {
10602 $taskObj->{winPreferList} = ['pane', 'grid'];
10603 } elsif (
10604 $taskObj->{name} eq 'divert_task' || $taskObj->{name} eq 'chat_task'
10605 ) {
10606 $taskObj->{winPreferList} = ['entry', 'grid'];
10607 }
10608  
10609 delete $taskObj->{allowLinkFlag};
10610 delete $taskObj->{settingsHash};
10611  
10612 $taskObj->{monochromeFlag} = $taskObj->{ownColourSchemeFlag};
10613 delete $taskObj->{ownColourSchemeFlag};
10614  
10615 if ($taskObj->{winType} eq 'text') {
10616 $taskObj->{winmap} = 'basic_fill';
10617 } elsif ($taskObj->{winType} eq 'entry') {
10618 $taskObj->{winmap} = 'entry_fill';
10619 } elsif ($taskObj->{winType} eq 'graphics') {
10620 $taskObj->{winmap} = 'basic_empty';
10621 }
10622  
10623 delete $taskObj->{winType};
10624 }
10625 }
10626  
10627 # This version renames IVs in the Compass task
10628 foreach my $taskObj ($self->compileTasks('compass_task')) {
10629  
10630 my $hashRef;
10631  
10632 if (exists $taskObj->{radioButton}) {
10633  
10634 $taskObj->{radioTableObj} = undef;
10635 $taskObj->{radioTableObj2} = undef;
10636 $taskObj->{comboTableObj} = undef;
10637  
10638 delete $taskObj->{radioButton};
10639 delete $taskObj->{radioButton2};
10640 delete $taskObj->{comboBox};
10641  
10642 # Also modify the contents of one of the constant hashes, so it doesn't
10643 # cause a pango error
10644 $hashRef = $taskObj->{keypadHintHash};
10645 $$hashRef{'kp_enter'} = 'ENTER key';
10646 $taskObj->{radioTableObj} = $hashRef;
10647 }
10648 }
10649  
10650 # This version updates IVs in the Debugger task
10651 foreach my $taskObj ($self->compileTasks('debugger_task')) {
10652  
10653 if ($taskObj->{errorMode} == 0) {
10654 $taskObj->{errorMode} = 'original';
10655 } elsif ($taskObj->{errorMode} == 1) {
10656 $taskObj->{errorMode} = 'both';
10657 } elsif ($taskObj->{errorMode} == 2) {
10658 $taskObj->{errorMode} = 'task';
10659 }
10660  
10661 if ($taskObj->{warningMode} == 0) {
10662 $taskObj->{warningMode} = 'original';
10663 } elsif ($taskObj->{warningMode} == 1) {
10664 $taskObj->{warningMode} = 'both';
10665 } elsif ($taskObj->{warningMode} == 2) {
10666 $taskObj->{warningMode} = 'task';
10667 }
10668  
10669 if ($taskObj->{debugMode} == 0) {
10670 $taskObj->{debugMode} = 'original';
10671 } elsif ($taskObj->{debugMode} == 1) {
10672 $taskObj->{debugMode} = 'both';
10673 } elsif ($taskObj->{debugMode} == 2) {
10674 $taskObj->{debugMode} = 'task';
10675 }
10676  
10677 if ($taskObj->{improperMode} == 0) {
10678 $taskObj->{improperMode} = 'original';
10679 } elsif ($taskObj->{improperMode} == 1) {
10680 $taskObj->{improperMode} = 'both';
10681 } elsif ($taskObj->{improperMode} == 2) {
10682 $taskObj->{improperMode} = 'task';
10683 }
10684 }
10685  
10686 # This version renames an IV in the Inventory task
10687 foreach my $taskObj ($self->compileTasks('inventory_task')) {
10688  
10689 if (exists $taskObj->{updateWinflag}) {
10690  
10691 $taskObj->{refreshWinFlag} = $taskObj->{updateWinFlag};
10692 delete $taskObj->{updateWinFlag};
10693 }
10694 }
10695  
10696 # This version renames IVs in the Notepad task (and removes one, too)
10697 foreach my $taskObj ($self->compileTasks('notepad_task')) {
10698  
10699 if (exists $taskObj->{textView}) {
10700  
10701 $taskObj->{textTableObj} = undef;
10702 $taskObj->{comboTableObj} = undef;
10703  
10704 delete $taskObj->{textView};
10705 delete $taskObj->{buffer};
10706 delete $taskObj->{comboBox};
10707 }
10708 }
10709  
10710 # This function updates IVs in the Locator and Status tasks
10711 foreach my $taskObj ($self->compileTasks('locator_task')) {
10712  
10713 $taskObj->{winUpdateFunc} = 'refreshWin';
10714 }
10715  
10716 foreach my $taskObj ($self->compileTasks('status_task')) {
10717  
10718 $taskObj->{winUpdateFunc} = 'refreshWin';
10719 $taskObj->{gaugeStripObj} = undef;
10720 }
10721 }
10722  
10723 if ($version < 1_000_813 && $self->session) {
10724  
10725 # This version removes an IV from all tasks. Update all initial/custom tasks
10726 foreach my $taskObj ($self->compileTasks()) {
10727  
10728 if (exists $taskObj->{statusTypeHash}) {
10729  
10730 delete $taskObj->{statusTypeHash};
10731 }
10732 }
10733 }
10734  
10735 if ($version < 1_000_840 && $self->session) {
10736  
10737 # This version removes some IVs from the Locator task. Update all initial/custom
10738 # tasks
10739 foreach my $taskObj ($self->compileTasks('locator_task')) {
10740  
10741 if (exists $taskObj->{useMxpFlag}) {
10742  
10743 $taskObj->{useMxpFlag} = undef;
10744 $taskObj->ivFalse('useMxpFlag');
10745  
10746 $taskObj->{mxpPropHash} = {};
10747 $taskObj->ivPoke(
10748 'mxpPropHash',
10749 'RoomName' => undef,
10750 'RoomDesc' => undef,
10751 'RoomExit' => undef,
10752 'RoomNum' => undef,
10753 );
10754 }
10755 }
10756 }
10757  
10758 if ($version < 1_000_841 && $self->session) {
10759  
10760 # This version removes an IV from all tasks
10761 foreach my $taskObj ($self->compileTasks()) {
10762  
10763 if (exists $taskObj->{msdpRoomHash}) {
10764  
10765 delete $taskObj->{msdpRoomHash};
10766 delete $taskObj->{msdpExitHash};
10767 }
10768 }
10769 }
10770  
10771 if ($version < 1_000_879 && $self->session) {
10772  
10773 # This version removes an IV from the Status task
10774 foreach my $taskObj ($self->compileTasks('status_task')) {
10775  
10776 if (! exists $taskObj->{defaultGaugeFormatList}) {
10777  
10778 delete $taskObj->{defaultGaugeFormatList};
10779 }
10780 }
10781 }
10782  
10783 if ($version < 1_000_904 && $self->session) {
10784  
10785 # This version adds an IV to all tasks. Update all initial/custom tasks
10786 foreach my $taskObj ($self->compileTasks()) {
10787  
10788 if (! exists $taskObj->{hasResetFlag}) {
10789  
10790 $taskObj->{hasResetFlag} = undef;
10791 $taskObj->ivUndef('hasResetFlag');
10792 }
10793 }
10794 }
10795  
10796 if ($version < 1_000_909) {
10797  
10798 # This version converts some numerical mode values to string mode values
10799 foreach my $taskObj ($self->compileTasks('advance_task')) {
10800  
10801 if ($taskObj->advanceMode eq '0') {
10802 $taskObj->ivPoke('advanceMode', 'named_skill');
10803 } elsif ($taskObj->advanceMode eq '1') {
10804 $taskObj->ivPoke('advanceMode', 'order_list');
10805 } elsif ($taskObj->advanceMode eq '2') {
10806 $taskObj->ivPoke('advanceMode', 'cycle_list');
10807 }
10808 }
10809  
10810 foreach my $taskObj ($self->compileTasks('chat_task')) {
10811  
10812 if ($taskObj->entryMode eq '0') {
10813 $taskObj->ivPoke('entryMode', 'chat');
10814 } elsif ($taskObj->entryMode eq '1') {
10815 $taskObj->ivPoke('entryMode', 'emote');
10816 } elsif ($taskObj->entryMode eq '2') {
10817 $taskObj->ivPoke('entryMode', 'cmd');
10818 }
10819 }
10820  
10821 foreach my $taskObj ($self->compileTasks('locator_task')) {
10822  
10823 if ($taskObj->autoLookMode eq '0') {
10824 $taskObj->ivPoke('autoLookMode', 'do_nothing');
10825 } elsif ($taskObj->autoLookMode eq '1') {
10826 $taskObj->ivPoke('autoLookMode', 'search_back');
10827 } elsif ($taskObj->autoLookMode eq '2') {
10828 $taskObj->ivPoke('autoLookMode', 'send_look');
10829 }
10830 }
10831  
10832 foreach my $taskObj ($self->compileTasks('status_task')) {
10833  
10834 if ($taskObj->commifyMode eq '0') {
10835 $taskObj->ivPoke('commifyMode', 'none');
10836 } elsif ($taskObj->commifyMode eq '1') {
10837 $taskObj->ivPoke('commifyMode', 'use_comma');
10838 } elsif ($taskObj->commifyMode eq '2') {
10839 $taskObj->ivPoke('commifyMode', 'use_europe');
10840 } elsif ($taskObj->commifyMode eq '3') {
10841 $taskObj->ivPoke('commifyMode', 'use_brit');
10842 } elsif ($taskObj->commifyMode eq '4') {
10843 $taskObj->ivPoke('commifyMode', 'use_underline');
10844 }
10845 }
10846 }
10847  
10848 if ($version < 1_000_922 && $self->session) {
10849  
10850 # This version renames an IV in the Status task
10851 foreach my $taskObj ($self->compileTasks('status_task')) {
10852  
10853 if (exists $taskObj->{_localWimpyMax}) {
10854  
10855 $taskObj->{constLocalWimpyMax} = $taskObj->{_localWimpyMax};
10856 delete $taskObj->{_localWimpyMax};
10857  
10858 # (This line makes sure the correct file object's ->modifyFlag is set)
10859 $taskObj->ivPoke('category', $taskObj->category);
10860 }
10861 }
10862 }
10863  
10864 if ($version < 1_000_923 && $self->session) {
10865  
10866 # This version renames an IV in the Chat task
10867 foreach my $taskObj ($self->compileTasks('chat_task')) {
10868  
10869 if (exists $taskObj->{constantHash}) {
10870  
10871 $taskObj->{constOptHash} = $taskObj->{constantHash};
10872 delete $taskObj->{constantHash};
10873  
10874 # (This line makes sure the correct file object's ->modifyFlag is set)
10875 $taskObj->ivPoke('category', $taskObj->category);
10876 }
10877 }
10878 }
10879  
10880 if ($version < 1_000_924 && $self->session) {
10881  
10882 # This version renames an IV in the Locator task
10883 foreach my $taskObj ($self->compileTasks('locator_task')) {
10884  
10885 if (exists $taskObj->{oldRoomObj}) {
10886  
10887 $taskObj->{prevRoomObj} = undef;
10888 $taskObj->ivPoke('prevRoomObj', $taskObj->{oldRoomObj});
10889  
10890 delete $taskObj->{oldRoomObj};
10891 }
10892 }
10893 }
10894  
10895 if ($version < 1_000_928 && $self->session) {
10896  
10897 # This version replaces an IV in the Launch task
10898 foreach my $taskObj ($self->compileTasks('launch_task')) {
10899  
10900 if (exists $taskObj->{simpleList}) {
10901  
10902 $taskObj->{slTableObj} = undef;
10903 $taskObj->ivPoke('slTableObj', undef);
10904  
10905 delete $taskObj->{simpleList};
10906 }
10907 }
10908 }
10909  
10910 if ($version < 1_001_031 && $self->session) {
10911  
10912 # This version updates all tasks by renaming an IV
10913 foreach my $taskObj ($self->compileTasks()) {
10914  
10915 if (! exists $taskObj->{taskType}) {
10916  
10917 $taskObj->{taskType} = undef;
10918 $taskObj->ivPoke('taskType', $taskObj->{taskList});
10919  
10920 delete $taskObj->{taskList};
10921 }
10922 }
10923 }
10924  
10925 if ($version < 1_001_093 && $self->session) {
10926  
10927 # This version updated the Locator task with a new IV, and renames some existing
10928 # IVs. Update all initial/custom tasks
10929 foreach my $taskObj ($self->compileTasks('locator_task')) {
10930  
10931 if (! exists $taskObj->{prevCmdBufferNum}) {
10932  
10933 $taskObj->{prevCmdBufferNum} = undef;
10934 $taskObj->ivUndef('prevCmdBufferNum');
10935  
10936 $taskObj->{prevMoveObj} = undef;
10937 $taskObj->ivPoke('prevMoveObj', $taskObj->{previousMoveObj});
10938 delete $taskObj->{previousMoveObj};
10939  
10940 $taskObj->{prevMove} = undef;
10941 $taskObj->ivPoke('prevMove', $taskObj->{previousMove});
10942 delete $taskObj->{previousMove};
10943 }
10944 }
10945 }
10946  
10947 if ($version < 1_000_094 && $self->session) {
10948  
10949 # This version removes an IV in the Locator task
10950 foreach my $taskObj ($self->compileTasks('locator_task')) {
10951  
10952 if (exists $taskObj->{resetTitleBarFlag}) {
10953  
10954 delete $taskObj->{resetTitleBarFlag};
10955 }
10956 }
10957 }
10958  
10959 if ($version < 1_001_118 && $self->session) {
10960  
10961 # This version updated the Locator task with new IVs. Update all initial/custom
10962 # tasks
10963 foreach my $taskObj ($self->compileTasks('locator_task')) {
10964  
10965 if (! exists $taskObj->{weatherHash}) {
10966  
10967 $taskObj->{weatherHash} = {};
10968 $taskObj->ivEmpty('weatherHash');
10969 $taskObj->{showParsedFlag} = undef;
10970 $taskObj->ivPoke('showParsedFlag', FALSE);
10971 }
10972 }
10973 }
10974  
10975 if ($version < 1_001_120 && $self->session) {
10976  
10977 # This version fixes an error in which tasks in the global initial tasklist, created
10978 # by GA::Client->addGlobalInitTask, did not have their ->taskType IV set correctly
10979 foreach my $taskObj ($axmud::CLIENT->ivValues('initTaskHash')) {
10980  
10981 $taskObj->ivPoke('taskType', 'initial');
10982 }
10983 }
10984  
10985 if ($version < 1_001_121 && $self->session) {
10986  
10987 # This version adds an IV to all tasks
10988 foreach my $taskObj ($self->compileTasks()) {
10989  
10990 if (! exists $taskObj->{colourScheme}) {
10991  
10992 $taskObj->{colourScheme} = undef;
10993 $taskObj->ivUndef('colourScheme');
10994 }
10995 }
10996 }
10997  
10998 if ($version < 1_001_125 && $self->session) {
10999  
11000 # This version updated the Divert task, adding some new IVs and removing some
11001 # existing ones. Update all initial/custom tasks
11002 foreach my $taskObj ($self->compileTasks('divert_task')) {
11003  
11004 if (! exists $taskObj->{otherAlertColour}) {
11005  
11006 $taskObj->{otherAlertColour} = undef;
11007 $taskObj->ivPoke('otherAlertColour', 'magenta');
11008 $taskObj->{otherAlertInterval} = undef;
11009 $taskObj->ivPoke('otherAlertInterval', 10);
11010 $taskObj->{otherAlertSound} = undef;
11011 $taskObj->ivPoke('otherAlertSound', 'notify');
11012  
11013 $taskObj->{warningCharLimit} = undef;
11014 $taskObj->ivPoke('warningCharLimit', 0);
11015 $taskObj->{otherCharLimit} = undef;
11016 $taskObj->ivPoke('otherCharLimit', 0);
11017  
11018 $taskObj->{otherRoomFlag} = undef;
11019 $taskObj->ivPoke('otherRoomFlag', FALSE);
11020 $taskObj->{otherUrgencyFlag} = undef;
11021 $taskObj->ivPoke('otherUrgencyFlag', TRUE);
11022  
11023 delete $taskObj->{gagFlag};
11024 }
11025 }
11026 }
11027  
11028 if ($version < 1_001_128 && $self->session) {
11029  
11030 # This version updates all tasks with a new IV
11031 foreach my $taskObj ($self->compileTasks()) {
11032  
11033 if (! exists $taskObj->{tabMode}) {
11034  
11035 $taskObj->{tabMode} = undef;
11036  
11037 if (
11038 $taskObj->{allowWinFlag}
11039 && defined $taskObj->{winmap}
11040 && (
11041 $taskObj->{winmap} eq 'basic_fill'
11042 || $taskObj->{winmap} eq 'basic_part'
11043 || $taskObj->{winmap} eq 'entry_fill'
11044 || $taskObj->{winmap} eq 'entry_part'
11045 )
11046 ) {
11047 # At the current time, there are no tasks whose ->tabMode is 'multi'
11048 $taskObj->ivPoke('tabMode', 'simple');
11049  
11050 } else {
11051  
11052 $taskObj->ivUndef('tabMode');
11053 }
11054 }
11055 }
11056 }
11057  
11058 if ($version < 1_001_133 && $self->session) {
11059  
11060 # This version updated the Watch task with new IVs. Update all initial/custom tasks
11061 foreach my $taskObj ($self->compileTasks('watch_task')) {
11062  
11063 if (! exists $taskObj->{channelsAlertColour}) {
11064  
11065 $taskObj->{channelsAlertColour} = undef;
11066 $taskObj->ivPoke('channelsAlertColour', 'YELLOW');
11067 $taskObj->{channelsAlertInterval} = undef;
11068 $taskObj->ivPoke('channelsAlertInterval', 10);
11069 }
11070 }
11071 }
11072  
11073 if ($version < 1_001_164 && $self->session) {
11074  
11075 my $class = 'Games::Axmud::Task::System';
11076  
11077 # This version renames the built-in Debugger task as the System task
11078 foreach my $taskObj ($self->compileTasks('debugger_task')) {
11079  
11080 # Rebless the task object into its new class
11081 bless $taskObj, $class;
11082  
11083 # Rename some existing IVs
11084 $taskObj->{_objName} = 'system_task';
11085 $taskObj->{_objClass} = $class;
11086 $taskObj->{name} = 'system_task';
11087 $taskObj->{prettyName} = 'System';
11088 $taskObj->{shortName} = 'Sy';
11089 $taskObj->{shortCutIV} = 'systemTask';
11090 $taskObj->{descrip} = 'Diverts system messages into a new window';
11091  
11092 # Change one task setting to fix an issue that prevented the window showing
11093 # coloured text
11094 $taskObj->{monochromeFlag} = FALSE;
11095  
11096 # Add new IVs
11097 $taskObj->{systemMode} = undef;
11098 $taskObj->ivPoke('systemMode', 'both');
11099 $taskObj->{colourFlag} = undef;
11100 $taskObj->ivPoke('colourFlag', TRUE);
11101 }
11102 }
11103  
11104 if ($version < 1_001_191 && $self->session) {
11105  
11106 # This version renames some Status task IVs. Update all initial/custom tasks
11107 foreach my $taskObj ($self->compileTasks('status_task')) {
11108  
11109 if (! exists $taskObj->{groupVarList}) {
11110  
11111 $taskObj->{groupVarList} = $taskObj->{singleBackRefVarList};
11112 delete $taskObj->{singleBackRefVarList};
11113  
11114 $taskObj->{groupVarHash} = $taskObj->{singleBackRefVarHash};
11115 delete $taskObj->{singleBackRefVarHash};
11116 }
11117 }
11118 }
11119  
11120 if ($version < 1_001_200 && $self->session) {
11121  
11122 # This version updated the RawToken task with new IVs. Update all initial/custom
11123 # tasks
11124 foreach my $taskObj ($self->compileTasks('raw_token_task')) {
11125  
11126 if (! exists $taskObj->{splitLineFlag}) {
11127  
11128 $taskObj->{splitLineFlag} = undef;
11129 $taskObj->ivPoke('splitLineFlag', FALSE);
11130 $taskObj->{showTypeFlag} = undef;
11131 $taskObj->ivPoke('showTypeFlag', FALSE);
11132 $taskObj->{countPacketFlag} = undef;
11133 $taskObj->ivPoke('countPacketFlag', FALSE);
11134 }
11135 }
11136 }
11137  
11138 if ($version < 1_001_263 && $self->session) {
11139  
11140 my $tempTask;
11141  
11142 # This version completes a major rewrite of the Status task
11143  
11144 # Create a temporary task so we can access its IVs
11145 $tempTask = Games::Axmud::Task::Status->new($axmud::CLIENT);
11146  
11147 # Update IVs in all initial/custom tasks
11148 foreach my $taskObj ($self->compileTasks('status_task')) {
11149  
11150 if (! exists $taskObj->{constCharVarHash}) {
11151  
11152 # (New IVs)
11153 $taskObj->{constCharVarHash} = {$tempTask->constCharVarHash};
11154 $taskObj->{constFixedVarHash} = {$tempTask->constFixedVarHash};
11155 $taskObj->{constPseudoVarHash} = {$tempTask->constPseudoVarHash};
11156 $taskObj->{constLocalVarHash} = {$tempTask->constLocalVarHash};
11157 $taskObj->{constCounterVarHash} = {$tempTask->constCounterVarHash};
11158 $taskObj->{constCounterRevHash} = {$tempTask->constCounterRevHash};
11159 $taskObj->{constPointHash} = {$tempTask->constPointHash};
11160  
11161 $taskObj->{localVarHash} = {};
11162 $taskObj->ivPoke('localVarHash', $tempTask->localVarHash);
11163 $taskObj->{counterVarHash} = {};
11164 $taskObj->ivPoke('counterVarHash', $tempTask->counterVarHash);
11165 $taskObj->{counterBaseHash} = {};
11166 $taskObj->ivPoke('counterBaseHash', $tempTask->counterBaseHash);
11167  
11168 # (Renamed IV)
11169 $taskObj->{counterStartTime} = undef;
11170 $taskObj->ivPoke('counterStartTime', $tempTask->{tempTimerBaseline});
11171 delete $taskObj->{tempTimerBaseline};
11172  
11173 # (Removed IVs)
11174 delete $taskObj->{defaultFormatList};
11175 delete $taskObj->{displayVarList};
11176 delete $taskObj->{groupVarList};
11177 delete $taskObj->{groupVarHash};
11178  
11179 delete $taskObj->{lifeStatusOverrideFlag};
11180  
11181 delete $taskObj->{lifeStatus};
11182 delete $taskObj->{lifeCount};
11183 delete $taskObj->{deathCount};
11184 delete $taskObj->{lifeMax};
11185  
11186 delete $taskObj->{healthPoints};
11187 delete $taskObj->{healthPointsMax};
11188 delete $taskObj->{magicPoints};
11189 delete $taskObj->{magicPointsMax};
11190 delete $taskObj->{energyPoints};
11191 delete $taskObj->{energyPointsMax};
11192 delete $taskObj->{guildPoints};
11193 delete $taskObj->{guildPointsMax};
11194 delete $taskObj->{socialPoints};
11195 delete $taskObj->{socialPointsMax};
11196  
11197 delete $taskObj->{xpCurrent};
11198 delete $taskObj->{xpNextLevel};
11199 delete $taskObj->{xpTotal};
11200  
11201 delete $taskObj->{worldQuestCount};
11202 delete $taskObj->{worldQuestPointCount};
11203 delete $taskObj->{worldQuestXPCount};
11204 delete $taskObj->{worldQuestCashCount};
11205  
11206 delete $taskObj->{questCount};
11207 delete $taskObj->{questPointCount};
11208 delete $taskObj->{questXPCount};
11209 delete $taskObj->{questCashCount};
11210  
11211 delete $taskObj->{level};
11212 delete $taskObj->{alignment};
11213  
11214 delete $taskObj->{localWimpy};
11215 delete $taskObj->{constLocalWimpyMax};
11216 delete $taskObj->{remoteWimpy};
11217 delete $taskObj->{remoteWimpyMax};
11218  
11219 delete $taskObj->{age};
11220 delete $taskObj->{time};
11221  
11222 delete $taskObj->{bankBalance};
11223 delete $taskObj->{purseContents};
11224  
11225 delete $taskObj->{fightCountFlag};
11226 delete $taskObj->{fightCount};
11227 delete $taskObj->{killCount};
11228 delete $taskObj->{wimpyCount};
11229 delete $taskObj->{fightDefeatCount};
11230 delete $taskObj->{interactCountFlag};
11231 delete $taskObj->{interactCount};
11232 delete $taskObj->{interactSuccessCount};
11233 delete $taskObj->{interactFailCount};
11234 delete $taskObj->{interactFightCount};
11235 delete $taskObj->{interactDisasterCount};
11236  
11237 delete $taskObj->{fleeCount};
11238 delete $taskObj->{escapeCount};
11239  
11240 delete $taskObj->{tempXPCount};
11241 delete $taskObj->{tempXPBaseline};
11242 delete $taskObj->{tempQuestCount};
11243 delete $taskObj->{tempQuestBaseline};
11244 delete $taskObj->{tempBankCount};
11245 delete $taskObj->{tempBankBaseline};
11246 delete $taskObj->{tempPurseCount};
11247 delete $taskObj->{tempPurseBaseline};
11248 }
11249 }
11250 }
11251  
11252 if ($version < 1_002_058 && $self->session) {
11253  
11254 # This version updated the Locator task with new IVs. Update all initial/custom
11255 # tasks
11256 foreach my $taskObj ($self->compileTasks('locator_task')) {
11257  
11258 if (! exists $taskObj->{mxpPropCurrentHash}) {
11259  
11260 $taskObj->{mxpPropCurrentHash} = {};
11261 $taskObj->ivEmpty('mxpPropCurrentHash');
11262 $taskObj->{mxpPropStartLine} = undef;
11263 $taskObj->ivUndef('mxpPropStartLine');
11264 }
11265 }
11266 }
11267 }
11268  
11269 ### scripts ###############################################################################
11270  
11271 if ($self->fileType eq 'scripts') {
11272  
11273 if ($version < 1_000_909) {
11274  
11275 # This version converts some numerical mode values to string mode values
11276  
11277 my %initScriptHash = $axmud::CLIENT->initScriptHash;
11278  
11279 foreach my $key (keys %initScriptHash) {
11280  
11281 my $value = $initScriptHash{$key};
11282  
11283 if ($value eq '0') {
11284 $initScriptHash{$key} = 'no_task';
11285 } elsif ($value eq '1') {
11286 $initScriptHash{$key} = 'run_task';
11287 } elsif ($value eq '2') {
11288 $initScriptHash{$key} = 'run_task_win';
11289 }
11290 }
11291  
11292 $axmud::CLIENT->ivPoke('initScriptHash', %initScriptHash);
11293 }
11294  
11295 ### contacts ##############################################################################
11296  
11297 } elsif ($self->fileType eq 'contacts') {
11298  
11299 if ($version < 1_000_909) {
11300  
11301 # This version converts some numerical mode values to string mode values
11302 if ($axmud::CLIENT->chatAcceptMode eq '0') {
11303 $axmud::CLIENT->ivPoke('chatAcceptMode', 'prompt');
11304 } elsif ($axmud::CLIENT->chatAcceptMode eq '1') {
11305 $axmud::CLIENT->ivPoke('chatAcceptMode', 'accept_contact');
11306 } elsif ($axmud::CLIENT->chatAcceptMode eq '2') {
11307 $axmud::CLIENT->ivPoke('chatAcceptMode', 'accept_all');
11308 }
11309 }
11310  
11311 ### dicts #################################################################################
11312  
11313 } elsif ($self->fileType eq 'dicts') {
11314  
11315 if ($version < 1_000_037) {
11316  
11317 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11318  
11319 # Add 'portal' as a new type of decoration, if it's not already there
11320 if (! defined $dictObj->ivMatch('constDecorationTypeList', 'portal')) {
11321  
11322 $dictObj->ivPush('constDecorationTypeList', 'portal');
11323 }
11324  
11325 if (! defined $dictObj->ivMatch('decorationTypeList', 'portal')) {
11326  
11327 $dictObj->ivPush('decorationTypeList', 'portal');
11328 }
11329  
11330 # Add 'portal' to the decoration lists
11331 if (! $dictObj->ivExists('decorationHash', 'portal')) {
11332  
11333 $dictObj->ivAdd('decorationHash', 'portal', 'decoration');
11334 $dictObj->ivAdd('decorationTypeHash', 'portal', 'portal');
11335 }
11336 }
11337 }
11338  
11339 if ($version < 1_000_271) {
11340  
11341 # This version adds eight new primary directions. $self->session is not necessarily
11342 # set, so we can't create a temporary dictionary and copy IVs to existing
11343 # dictionaries; need to update IVs the hard way
11344 # (Unfortunately, non-English dictionaries will be updated with English words;
11345 # hopefully only a tiny number of users will be affected)
11346  
11347 my (
11348 @primaryDirList, @shortPrimaryDirList,
11349 %shortPrimaryDirHash, %primaryAbbrevHash, %primaryOppHash,
11350 %primaryOppAbbrevHash,
11351 );
11352  
11353 @primaryDirList = (
11354 'north',
11355 'northnortheast',
11356 'northeast',
11357 'eastnortheast',
11358 'east',
11359 'eastsoutheast',
11360 'southeast',
11361 'southsoutheast',
11362 'south',
11363 'southsouthwest',
11364 'southwest',
11365 'westsouthwest',
11366 'west',
11367 'westnorthwest',
11368 'northwest',
11369 'northnorthwest',
11370 'up',
11371 'down',
11372 );
11373  
11374 @shortPrimaryDirList = (
11375 'north',
11376 'northeast',
11377 'east',
11378 'southeast',
11379 'south',
11380 'southwest',
11381 'west',
11382 'northwest',
11383 'up',
11384 'down',
11385 );
11386  
11387 %shortPrimaryDirHash = (
11388 'north' => undef,
11389 'northeast' => undef,
11390 'east' => undef,
11391 'southeast' => undef,
11392 'south' => undef,
11393 'southwest' => undef,
11394 'west' => undef,
11395 'northwest' => undef,
11396 'up' => undef,
11397 'down' => undef,
11398 );
11399  
11400 %primaryAbbrevHash = (
11401 northnortheast => 'nne', # Only new key-value pairs
11402 eastnortheast => 'ene',
11403 eastsoutheast => 'ese',
11404 southsoutheast => 'sse',
11405 southsouthwest => 'ssw',
11406 westsouthwest => 'wsw',
11407 westnorthwest => 'wnw',
11408 northnorthwest => 'nnw',
11409 );
11410  
11411 %primaryOppHash = (
11412 northnortheast => 'southsouthwest', # Only new key-value pairs
11413 eastnortheast => 'westsouthwest',
11414 eastsoutheast => 'westnorthwest',
11415 southsoutheast => 'northnorthwest',
11416 southsouthwest => 'northnortheast',
11417 westsouthwest => 'eastnortheast',
11418 westnorthwest => 'eastsoutheast',
11419 northnorthwest => 'southsoutheast',
11420 );
11421  
11422 %primaryOppAbbrevHash = (
11423 northnortheast => 'ssw',
11424 eastnortheast => 'wsw',
11425 eastsoutheast => 'wnw',
11426 southsoutheast => 'nnw',
11427 southsouthwest => 'nne',
11428 westsouthwest => 'ene',
11429 westnorthwest => 'ese',
11430 northnorthwest => 'sse',
11431 );
11432  
11433 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11434  
11435 if (! $dictObj->ivExists('primaryDirHash', 'northnortheast')) {
11436  
11437 # Update this dictionary's IVs
11438 # (This IV subsequently renamed and/or removed)
11439 # $dictObj->ivPoke('primaryDirList', @primaryDirList);
11440 $dictObj->{primaryDirList} = [@primaryDirList];
11441 # $dictObj->{shortPrimaryDirList} = [];
11442 # $dictObj->ivPoke('shortPrimaryDirList', @shortPrimaryDirList);
11443 $dictObj->{shortPrimaryDirList} = [@shortPrimaryDirList];
11444 # $dictObj->{shortPrimaryDirHash} = {};
11445 # $dictObj->ivPoke('shortPrimaryDirHash', %shortPrimaryDirHash);
11446 $dictObj->{shortPrimaryDirHash} = {%shortPrimaryDirHash};
11447  
11448 foreach my $dir (@primaryDirList) {
11449  
11450 if (! exists $shortPrimaryDirHash{$dir}) {
11451  
11452 $dictObj->ivAdd(
11453 'primaryDirHash',
11454 $dir, # Standard and custom dirs are initially the same
11455 $dir,
11456 );
11457 }
11458 }
11459  
11460 foreach my $key (keys %primaryAbbrevHash) {
11461  
11462 $dictObj->ivAdd('primaryAbbrevHash', $key, $primaryAbbrevHash{$key});
11463 }
11464  
11465 foreach my $key (keys %primaryOppHash) {
11466  
11467 $dictObj->ivAdd('primaryOppHash', $key, $primaryOppHash{$key});
11468 }
11469  
11470 foreach my $key (keys %primaryOppAbbrevHash) {
11471  
11472 $dictObj->ivAdd(
11473 'primaryOppAbbrevHash',
11474 $key,
11475 $primaryOppAbbrevHash{$key},
11476 );
11477 }
11478  
11479 # We also have to update the combined hashes the hard way
11480 foreach my $key (keys %primaryAbbrevHash) {
11481  
11482 # Standard and custom dirs are initially the same
11483 $dictObj->ivAdd('combDirHash', $key, 'primaryDir');
11484 }
11485  
11486 foreach my $value (values %primaryAbbrevHash) {
11487  
11488 # Standard and custom dirs are initially the same
11489 $dictObj->ivAdd('combDirHash', $value, 'primaryAbbrev');
11490 }
11491  
11492 foreach my $key (keys %primaryOppHash) {
11493  
11494 # Standard and custom dirs are initially the same
11495 $dictObj->ivAdd('combOppDirHash', $key, $primaryOppHash{$key});
11496 }
11497  
11498 foreach my $key (keys %primaryAbbrevHash) {
11499  
11500 # Standard and custom dirs are initially the same
11501 $dictObj->ivAdd('combRevDirHash', $key, $key);
11502 }
11503 }
11504 }
11505 }
11506  
11507 if ($version < 1_000_275) {
11508  
11509 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11510  
11511 # Update this dictionary's IVs
11512 $dictObj->{secondaryAutoHash} = {};
11513 # Create a key-value pair for every existing secondary direction
11514 foreach my $dir ($dictObj->ivKeys('secondaryDirHash')) {
11515  
11516 $dictObj->ivAdd('secondaryAutoHash', $dir, undef);
11517 }
11518 }
11519 }
11520  
11521 if ($version < 1_000_278) {
11522  
11523 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11524  
11525 # Update this dictionary's IVs
11526 $dictObj->{secondaryAbbrevHash} = {};
11527 $dictObj->{secondaryOppAbbrevHash} = {};
11528 # Create a key-value pair for every existing secondary direction
11529 foreach my $dir ($dictObj->ivKeys('secondaryDirHash')) {
11530  
11531 $dictObj->ivAdd('secondaryAbbrevHash', $dir, undef);
11532 $dictObj->ivAdd('secondaryOppAbbrevHash', $dir, '');
11533 }
11534 }
11535 }
11536  
11537 if ($version < 1_000_582) {
11538  
11539 # Update dictionary with a new IV
11540 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11541  
11542 if (! exists $dictObj->{contentsLinesHash}) {
11543  
11544 $dictObj->{contentsLinesHash} = {};
11545 $dictObj->ivEmpty('contentsLinesHash');
11546 }
11547 }
11548  
11549 # An error in ';addword' added key-value pairs with the wrong value. Here's the fix
11550 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11551  
11552 foreach my $key ($dictObj->ivKeys('adjHash')) {
11553  
11554 my $value = $dictObj->ivShow('adjHash', $key);
11555  
11556 if ($value ne 'adj') {
11557  
11558 $dictObj->ivAdd('adjHash', $key, 'adj');
11559 }
11560 }
11561 }
11562 }
11563  
11564 if ($version < 1_000_897) {
11565  
11566 # Update dictionary by removing some IVs, which have moved to GA::Client
11567 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11568  
11569 if (exists $dictObj->{primaryDirList}) {
11570  
11571 delete $dictObj->{primaryDirList};
11572 delete $dictObj->{shortPrimaryDirList};
11573 delete $dictObj->{shortPrimaryDirHash};
11574  
11575 # (This line makes sure the correct file object's ->modifyFlag is set)
11576 $dictObj->ivPoke('name', $dictObj->name);
11577 }
11578 }
11579 }
11580  
11581 if ($version < 1_000_909) {
11582  
11583 # This version converts some numerical mode values to string mode values
11584 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11585  
11586 if ($dictObj->nounPosn eq '0') {
11587 $dictObj->ivPoke('nounPosn', 'noun_adj');
11588 } elsif ($dictObj->nounPosn eq '1') {
11589 $dictObj->ivPoke('nounPosn', 'adj_noun');
11590 }
11591 }
11592 }
11593  
11594 if ($version < 1_000_911) {
11595  
11596 # Update dictionary with some new IVs
11597 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11598  
11599 if (! exists $dictObj->{speedDirHash}) {
11600  
11601 $dictObj->{speedDirHash} = {};
11602 $dictObj->ivPoke(
11603 'speedDirHash',
11604 'n' => 'north',
11605 's' => 'south',
11606 'e' => 'east',
11607 'w' => 'west',
11608 'u' => 'up',
11609 'd' => 'down',
11610 'l' => 'look',
11611 't' => 'northwest',
11612 'y' => 'northeast',
11613 'g' => 'southwest',
11614 'h' => 'southeast',
11615 );
11616  
11617 $dictObj->{speedModifierHash} = {};
11618 $dictObj->ivPoke(
11619 'speedModifierHash',
11620 # Movement commands
11621 'G' => 'go_dir',
11622 'N' => 'run',
11623 'A' => 'walk',
11624 'F' => 'fly',
11625 'W' => 'swim',
11626 'V' => 'dive',
11627 'S' => 'sail',
11628 'I' => 'ride',
11629 'D' => 'drive',
11630 'R' => 'creep',
11631 'E' => 'sneak',
11632 'Q' => 'squeeze',
11633 # Non-movement commands
11634 'O' => 'open_dir',
11635 'C' => 'close_dir',
11636 'K' => 'unlock',
11637 'L' => 'lock',
11638 'P' => 'pick',
11639 'B' => 'break',
11640 );
11641 }
11642 }
11643 }
11644  
11645 if ($version < 1_001_299) {
11646  
11647 # This version adds a new IV
11648 foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
11649  
11650  
11651 if (! exists $dictObj->{relativeDirHash}) {
11652  
11653 $dictObj->{relativeDirHash} = {};
11654 $dictObj->ivEmpty('relativeDirHash');
11655 $dictObj->{relativeAbbrevHash} = {};
11656 $dictObj->ivEmpty('relativeAbbrevHash');
11657 }
11658 }
11659 }
11660  
11661 ### toolbar ###############################################################################
11662  
11663 } elsif ($self->fileType eq 'toolbar') {
11664  
11665 if ($version < 1_000_927) {
11666  
11667 my (
11668 $oldName,
11669 @buttonList,
11670 %buttonHash,
11671 );
11672  
11673 # This version renames one of the toolbar buttons, because of clashes with
11674 # GA::Client->constReservedHash
11675 foreach my $buttonObj ($axmud::CLIENT->ivValues('toolbarHash')) {
11676  
11677 if ($buttonObj->name eq 'connect') {
11678  
11679 $oldName = $buttonObj->name;
11680 $buttonObj->ivPoke('name', 'connect_me');
11681  
11682 } elsif ($buttonObj->name eq 'help') {
11683  
11684 $oldName = $buttonObj->name;
11685 $buttonObj->ivPoke('name', 'help_me');
11686  
11687 } elsif ($buttonObj->name eq 'login') {
11688  
11689 $oldName = $buttonObj->name;
11690 $buttonObj->ivPoke('name', 'login_me');
11691  
11692 } elsif ($buttonObj->name eq 'save') {
11693  
11694 $oldName = $buttonObj->name;
11695 $buttonObj->ivPoke('name', 'save_me');
11696 }
11697  
11698 $buttonHash{$buttonObj->name} = $buttonObj;
11699 delete $buttonHash{$oldName};
11700 }
11701  
11702 foreach my $name ($axmud::CLIENT->toolbarList) {
11703  
11704 if ($name eq 'connect') {
11705 push (@buttonList, 'connect_me');
11706 } elsif ($name eq 'help') {
11707 push (@buttonList, 'help_me');
11708 } elsif ($name eq 'login') {
11709 push (@buttonList, 'login_me');
11710 } elsif ($name eq 'save') {
11711 push (@buttonList, 'save_me');
11712 } else {
11713 push (@buttonList, $name);
11714 }
11715 }
11716  
11717 $axmud::CLIENT->ivPoke('toolbarHash', %buttonHash);
11718 $axmud::CLIENT->ivPoke('toolbarList', @buttonList);
11719 }
11720  
11721 if ($version < 1_001_017) {
11722  
11723 # This version adds a toolbar button for the new quick preferences window. If the
11724 # user still has a toolbar button for client preference window, and a new button
11725 # before it
11726  
11727 my (
11728 $obj,
11729 @buttonList,
11730 );
11731  
11732 foreach my $item ($axmud::CLIENT->toolbarList) {
11733  
11734 if ($item eq 'edit_client') {
11735  
11736 # Insert the new button here
11737 $obj = Games::Axmud::Obj::Toolbar->new(
11738 'edit_quick',
11739 'Set quick preferences',
11740 FALSE, # Default, not custom, toolbar button
11741 'book_edit.png',
11742 ';editquick',
11743 TRUE,
11744 TRUE,
11745 );
11746  
11747 if ($obj) {
11748  
11749 push (@buttonList, $obj->name);
11750 $axmud::CLIENT->ivAdd('toolbarHash', $obj->name, $obj);
11751 }
11752 }
11753  
11754 # The existing button is added after the new one
11755 push (@buttonList, $item);
11756 }
11757  
11758 $axmud::CLIENT->ivPoke('toolbarList', @buttonList);
11759 }
11760  
11761 if ($version < 1_001_028) {
11762  
11763 my (
11764 $buttonObj,
11765 @buttonList,
11766 );
11767  
11768 # This version renames one of the toolbar buttons, as the window it opens has also
11769 # been renamed
11770 $buttonObj = $axmud::CLIENT->ivShow('toolbarHash', 'open_gui');
11771 if ($buttonObj) {
11772  
11773 $buttonObj->ivPoke('name', 'open_viewer');
11774  
11775 $buttonObj->ivPoke('descrip', 'Open object viewer window');
11776 $buttonObj->ivPoke('iconPath', 'watermark_table.png');
11777 $buttonObj->ivPoke('instruct', ';openobjectviewer');
11778  
11779 $axmud::CLIENT->ivDelete('toolbarHash', 'open_gui');
11780 $axmud::CLIENT->ivAdd('toolbarHash', 'open_viewer', $buttonObj);
11781  
11782 foreach my $name ($axmud::CLIENT->toolbarList) {
11783  
11784 if ($name eq 'open_gui') {
11785 push (@buttonList, 'open_viewer');
11786 } else {
11787 push (@buttonList, $name);
11788 }
11789 }
11790  
11791 $axmud::CLIENT->ivPoke('toolbarList', @buttonList);
11792 }
11793 }
11794  
11795 if ($version < 1_001_507) {
11796  
11797 my (
11798 @newList,
11799 %checkHash,
11800 );
11801  
11802 # This version removes a toolbar button, as the client command has been removed
11803 foreach my $name ($axmud::CLIENT->ivKeys('toolbarHash')) {
11804  
11805 my $obj = $axmud::CLIENT->ivShow('toolbarHash', $name);
11806  
11807 if ($obj->instruct eq ';screenshot') {
11808  
11809 $axmud::CLIENT->ivDelete('toolbarHash', $name);
11810 $checkHash{$name} = undef;
11811 }
11812 }
11813  
11814 foreach my $name ($axmud::CLIENT->toolbarList) {
11815  
11816 if (! exists $checkHash{$name}) {
11817  
11818 push (@newList, $name);
11819 }
11820 }
11821  
11822 $axmud::CLIENT->ivPoke('toolbarList', @newList);
11823 }
11824  
11825  
11826 ### usercmds ##############################################################################
11827  
11828 } elsif ($self->fileType eq 'usercmds') {
11829  
11830 if ($version < 1_000_507) {
11831  
11832 # This version removes the ;screenshot command
11833 foreach my $userCmd ($axmud::CLIENT->ivKeys('userCmdHash')) {
11834  
11835 my $standardCmd = $axmud::CLIENT->ivShow('userCmdHash', $userCmd);
11836  
11837 if ($standardCmd eq 'screenshot') {
11838  
11839 $axmud::CLIENT->ivDelete('userCmdHash', $userCmd);
11840 }
11841 }
11842 }
11843  
11844 ## zonemaps ###############################################################################
11845  
11846 } elsif ($self->fileType eq 'zonemaps') {
11847  
11848 if ($version < 1_000_653) {
11849  
11850 # This version adds new IVs to zonemaps
11851 foreach my $zonemapObj ($axmud::CLIENT->ivValues('zonemapHash')) {
11852  
11853 if (! exists $zonemapObj->{tempFlag}) {
11854  
11855 $zonemapObj->{tempFlag} = undef;
11856 $zonemapObj->ivFalse('tempFlag');
11857 $zonemapObj->{tempSession} = undef;
11858 $zonemapObj->ivUndef('tempSession');
11859 }
11860 }
11861 }
11862  
11863 if ($version < 1_000_800) {
11864  
11865 # This version modifies several zonemap and zone model IVs
11866 foreach my $zonemapObj ($axmud::CLIENT->ivValues('zonemapHash')) {
11867  
11868 my (%oldReservedHash, %newReservedHash, %newModelHash);
11869  
11870 if (exists $zonemapObj->{_zonemap}) {
11871  
11872 delete $zonemapObj->{_zonemap};
11873  
11874 $zonemapObj->{modelCount} = $zonemapObj->{zoneModelCount};
11875 delete $zonemapObj->{zoneModelCount};
11876  
11877 $zonemapObj->{gridSize} = 60;
11878  
11879 foreach my $modelObj ($zonemapObj->ivValues('zoneModelHash')) {
11880  
11881 $modelObj->{left} = $modelObj->{zonemapLeft};
11882 delete $modelObj->{zonemapLeft};
11883  
11884 $modelObj->{top} = $modelObj->{zonemapTop};
11885 delete $modelObj->{zonemapTop};
11886  
11887 $modelObj->{right} = $modelObj->{zonemapRight};
11888 delete $modelObj->{zonemapRight};
11889  
11890 $modelObj->{bottom} = $modelObj->{zonemapBottom};
11891 delete $modelObj->{zonemapBottom};
11892  
11893 $modelObj->{width} = $modelObj->{zonemapWidth};
11894 delete $modelObj->{zonemapWidth};
11895  
11896 $modelObj->{height} = $modelObj->{zonemapHeight};
11897 delete $modelObj->{zonemapHeight};
11898  
11899 $modelObj->{zonemapObj} = $modelObj->{parentZonemap};
11900 delete $modelObj->{parentZonemap};
11901  
11902 $modelObj->{areaMax} = $modelObj->{winMax};
11903 delete $modelObj->{winMax};
11904  
11905 $modelObj->{visibleAreaMax} = $modelObj->{winVisibleMax};
11906 delete $modelObj->{winVisibleMax};
11907  
11908 $modelObj->{defaultAreaWidth} = $modelObj->{defaultWinWidth};
11909 delete $modelObj->{defaultWinWidth};
11910  
11911 $modelObj->{defaultAreaHeight} = $modelObj->{defaultWinHeight};
11912 delete $modelObj->{defaultWinHeight};
11913  
11914 $modelObj->{reservedFlag} = $modelObj->{reservedZoneFlag};
11915 delete $modelObj->{reservedZoneFlag};
11916  
11917 # Values stored in ->reservedHash have changed
11918 %oldReservedHash = $modelObj->reservedHash;
11919 foreach my $name (keys %oldReservedHash) {
11920  
11921 my $type = $oldReservedHash{$name};
11922  
11923 if ($type eq 'main' || $type eq 'map' || $type eq 'external') {
11924  
11925 $newReservedHash{$name} = $type;
11926  
11927 } else {
11928  
11929 $newReservedHash{$name} = 'custom';
11930 }
11931 }
11932  
11933 $modelObj->{reservedHash} = \%newReservedHash;
11934  
11935 $modelObj->{ownerString} = undef;
11936 $modelObj->{defaultEnabledWinmap} = undef;
11937 $modelObj->{defaultDisabledWinmap} = undef;
11938 $modelObj->{defaultInternalWinmap} = undef;
11939  
11940 $newModelHash{$modelObj->{number}} = $modelObj;
11941 }
11942  
11943 $zonemapObj->{modelHash} = \%newModelHash;
11944 delete $zonemapObj->{zoneModelHash};
11945 }
11946 }
11947 }
11948  
11949 ## winmaps ################################################################################
11950  
11951 } elsif ($self->fileType eq 'winmaps') {
11952  
11953 if ($version < 1_001_028) {
11954  
11955 my $obj;
11956  
11957 # Change the name of the colour scheme for 'viewer' windows, which used to be called
11958 # 'gui' windows
11959 $obj = $axmud::CLIENT->ivShow('colourSchemeHash', 'gui');
11960 if ($obj) {
11961  
11962 $obj->ivPoke('name', 'viewer');
11963  
11964 $axmud::CLIENT->ivDelete('colourSchemeHash', 'gui');
11965 $axmud::CLIENT->ivAdd('colourSchemeHash', 'viewer', $obj);
11966 }
11967 }
11968  
11969 if ($version < 1_001_122) {
11970  
11971 # This version adds an IV to colour schemes
11972 foreach my $obj ($axmud::CLIENT->ivValues('colourSchemeHash')) {
11973  
11974 if (! exists $obj->{overrideHash}) {
11975  
11976 $obj->{overrideHash} = {};
11977 $obj->ivEmpty('overrideHash');
11978 $obj->{overrideAllFlag} = undef;
11979 $obj->ivPoke('overrideAllFlag', FALSE);
11980 }
11981 }
11982 }
11983  
11984 if ($version < 1_001_129) {
11985  
11986 # This version removes an initialisation setting from pane objects (GA::Table::Pane)
11987 # The IV modified is in the winzone object (GA::Obj::Winzone)
11988 foreach my $winmapObj ($axmud::CLIENT->ivValues('winmapHash')) {
11989  
11990 foreach my $zoneObj ($winmapObj->ivValues('zoneHash')) {
11991  
11992 if ($zoneObj->packageName eq 'Games::Axmud::Table::Pane') {
11993  
11994 $zoneObj->ivDelete('initHash', 'no_label_flag');
11995 }
11996 }
11997 }
11998 }
11999  
12000 if ($version < 1_001_203) {
12001  
12002 # This version adds a new button in 'main' windows, for which we must update the
12003 # equivalent winmaps
12004 foreach my $winmapObj ($axmud::CLIENT->ivValues('winmapHash')) {
12005  
12006 my (@oldList, @newList);
12007  
12008 if (
12009 $winmapObj->name eq 'main_fill'
12010 || $winmapObj->name eq 'main_part'
12011 || $winmapObj->name eq 'main_empty'
12012 ) {
12013 @oldList = $winmapObj->stripInitList;
12014 if (@oldList) {
12015  
12016 do {
12017  
12018 my ($package, $hashRef);
12019  
12020 $package = shift @oldList;
12021 $hashRef = shift @oldList;
12022  
12023 if (
12024 $package eq 'Games::Axmud::Strip::Entry'
12025 && defined $hashRef
12026 ) {
12027 $$hashRef{'console_flag'} = TRUE;
12028 }
12029  
12030 push (@newList, $package, $hashRef);
12031  
12032 } until (! @oldList);
12033  
12034 $winmapObj->{stripInitList} = \@newList;
12035 }
12036 }
12037 }
12038 }
12039  
12040 if ($version < 1_001_393) {
12041  
12042 # This version adds a new strip object, for which we must update the equivalent
12043 # winmaps
12044 # This version adds a new button in 'main' windows, for which we must update the
12045 # equivalent winmaps
12046 foreach my $winmapObj ($axmud::CLIENT->ivValues('winmapHash')) {
12047  
12048 my (@oldList, @newList);
12049  
12050 if (
12051 $winmapObj->name eq 'main_fill'
12052 || $winmapObj->name eq 'main_part'
12053 || $winmapObj->name eq 'main_empty'
12054 ) {
12055 @oldList = $winmapObj->stripInitList;
12056 if (@oldList) {
12057  
12058 do {
12059  
12060 my ($package, $hashRef);
12061  
12062 $package = shift @oldList;
12063 $hashRef = shift @oldList;
12064  
12065 if ($package eq 'Games::Axmud::Strip::Entry') {
12066  
12067 # Add the search box just above the entry strip object (which
12068 # we'll assume still exists)
12069 push (@newList, 'Games::Axmud::Strip::SearchBox', undef);
12070  
12071 # The entry strip object itself gets two new flags
12072 $$hashRef{'add_flag'} = TRUE;
12073 $$hashRef{'search_flag'} = TRUE;
12074 }
12075  
12076 push (@newList, $package, $hashRef);
12077  
12078 } until (! @oldList);
12079  
12080 $winmapObj->{stripInitList} = \@newList;
12081 }
12082 }
12083 }
12084 }
12085  
12086 if ($version < 1_001_400) {
12087  
12088 # This version adds an IV to colour scheme objects
12089 foreach my $obj ($axmud::CLIENT->ivValues('colourSchemeHash')) {
12090  
12091 if (! exists $obj->{wrapMode}) {
12092  
12093 $obj->{wrapMode} = undef;
12094 $obj->ivPoke('wrapMode', 'wrap_word_char');
12095 }
12096 }
12097 }
12098  
12099 ## tts ####################################################################################
12100  
12101 } elsif ($self->fileType eq 'tts') {
12102  
12103 if ($version < 1_001_005) {
12104  
12105 # This version adds support for a new TTS engine. Extremely unlikely that anyone has
12106 # created a configuration object with the same name, but we'll overwrite it, if so
12107 my $obj = Games::Axmud::Obj::Tts->new(
12108 'esng',
12109 'esng',
12110 'en',
12111 150,
12112 undef,
12113 50,
12114 undef,
12115 );
12116  
12117 if ($obj) {
12118  
12119 $axmud::CLIENT->add_ttsObj($obj);
12120 }
12121  
12122 # Also update the default values for the TTS configuration for the swift engine, as
12123 # they use different values on MS Windows and Linux
12124 my $obj2 = $axmud::CLIENT->ivShow('ttsObjHash', 'swift');
12125 if ($obj2) {
12126  
12127 $obj2->ivUndef('speed');
12128 $obj2->ivUndef('rate');
12129 $obj2->ivUndef('pitch');
12130 $obj2->ivUndef('volume');
12131 }
12132 }
12133  
12134 if ($version < 1_001_133) {
12135  
12136 my ($chanObj, $divObj);
12137  
12138 # Add a TTS configuration object for the new Channels task, by cloning the object
12139 # for the existing Divert task
12140 if (! $axmud::CLIENT->ivShow('ttsObjHash', 'channels')) {
12141  
12142 $divObj = $axmud::CLIENT->ivShow('ttsObjHash', 'divert');
12143 if ($divObj) {
12144  
12145 $chanObj = $divObj->clone('channels');
12146 if ($chanObj) {
12147  
12148 $axmud::CLIENT->add_ttsObj($chanObj);
12149 }
12150 }
12151  
12152 # Update other Client hashes
12153 $axmud::CLIENT->ivAdd('ttsFlagAttribHash', 'channels', 'channels_task');
12154 }
12155 }
12156  
12157 if ($version < 1_001_401) {
12158  
12159 # This version changes the scale used for speed, rate, pitch and volume. We now use
12160 # a standard range of 0-100 for all speech engines
12161 # Update all TTS configuration objects
12162 foreach my $ttsObj ($axmud::CLIENT->ivValues('ttsObjHash')) {
12163  
12164 my ($speed, $rate, $pitch, $volume);
12165  
12166 if ($ttsObj->engine eq 'espeak') {
12167  
12168 $speed = int(($ttsObj->speed - 10) / 1.9);
12169 $pitch = int($ttsObj->pitch);
12170  
12171 } elsif ($ttsObj->engine eq 'esng') {
12172  
12173 $speed = int(($ttsObj->speed - 10) / 1.9);
12174 $pitch = int($ttsObj->pitch);
12175  
12176 # Some default values seem to have been missing from
12177 # GA::Client->constTtsDefaultList; fill them in as we go
12178 if (! defined $ttsObj->volume) {
12179 $volume = 80;
12180 } else {
12181 $volume = int($ttsObj->volume / 2);
12182 }
12183  
12184 # (flite doesn't use speed/rate/pitch/volume)
12185  
12186 } elsif ($ttsObj->engine eq 'festival') {
12187  
12188 $rate = int(($ttsObj->rate - 0.5) * 66);
12189 $volume = int(($ttsObj->volume - 0.33) * 17.6);
12190  
12191 } elsif ($ttsObj->engine eq 'swift') {
12192  
12193 if ($^O eq 'MSWin32') {
12194  
12195 if (! defined $ttsObj->speed) {
12196 $speed = 30;
12197 } else {
12198 $speed = int(($ttsObj->speed - 100) / 3);
12199 }
12200  
12201 } else {
12202  
12203 if (! defined $ttsObj->rate) {
12204 $rate = 50;
12205 } else {
12206 $rate = int(($ttsObj->rate - 0.5) * 66);
12207 }
12208 }
12209  
12210 if (! defined $ttsObj->pitch) {
12211 $pitch = 50;
12212 } else {
12213 $pitch = int($ttsObj->pitch * 20);
12214 }
12215  
12216 if (! defined $ttsObj->volume) {
12217 $volume = 80;
12218 } elsif ($^O eq 'MSWin32') {
12219 $volume = int($ttsObj->volume);
12220 } else {
12221 $volume = int(($ttsObj->volume - 0.33) * 17.6);
12222 }
12223 }
12224  
12225 # For all four values, take care of rounding errors by increasing value of 98
12226 # or above to 100
12227 if (defined $speed && $speed >= 98) {
12228  
12229 $speed = 100;
12230 }
12231  
12232 if (defined $rate && $rate >= 98) {
12233  
12234 $rate = 100;
12235 }
12236  
12237 if (defined $pitch && $pitch >= 98) {
12238  
12239 $pitch = 100;
12240 }
12241  
12242 if (defined $volume && $volume >= 98) {
12243  
12244 $volume = 100;
12245 }
12246  
12247 # Update the configuration. Some of these values may still be 'undef'
12248 $ttsObj->ivPoke('speed', $speed);
12249 $ttsObj->ivPoke('rate', $rate);
12250 $ttsObj->ivPoke('pitch', $pitch);
12251 $ttsObj->ivPoke('volume', $volume);
12252 }
12253 }
12254 }
12255  
12256 return 1;
12257 }
12258  
12259 sub patchWorldProf {
12260  
12261 # Called by $self->loadDataFile for a world profile that must be patched due to serious
12262 # problems, or whose DNS/IP/port has changed
12263 # Checks the version number of the loaded file against the version number specified by the
12264 # GA::Client IV, and applies the patch, if required
12265 #
12266 # Expected arguments
12267 # $world - The name of the world profile
12268 # $fileVersion - The Axmud version used to save the file that the calling function has
12269 # just loaded
12270 #
12271 # Return values
12272 # 'undef' on improper arguments, if the world profile doesn't need to be patched or if the
12273 # user declines to apply a patch
12274 # 1 if the world profile is patched
12275  
12276 my ($self, $world, $fileVersion, $check) = @_;
12277  
12278 # Local variables
12279 my ($worldObj, $patchVersion, $choice);
12280  
12281 # Check for improper arguments
12282 if (! defined $world || ! defined $fileVersion || defined $check) {
12283  
12284 return $axmud::CLIENT->writeImproper($self->_objClass . '->patchWorldProf', @_);
12285 }
12286  
12287 # Import the world profile
12288 $worldObj = $axmud::CLIENT->ivShow('worldProfHash', $world);
12289  
12290 # Convert versions, e.g. '1.1.0' to '1_001_000' (the calling function has already checked
12291 # that $world exists in GA::Client->constWorldPatchHash
12292 $fileVersion = $axmud::CLIENT->convertVersion($fileVersion);
12293 $patchVersion = $axmud::CLIENT->convertVersion(
12294 $axmud::CLIENT->ivShow('constWorldPatchHash', $world),
12295 );
12296  
12297 if ($fileVersion >= $patchVersion) {
12298  
12299 # No patch required
12300 return undef;
12301 }
12302  
12303 # If the user has ever connected to this world, ask permission before patching it
12304 # Exception: if GA::Client->mainWin is undefined, it's because the global variable
12305 # $TEST_MODE_FLAG is TRUE; in that case, don't bother asking for permission
12306 if ($worldObj->numberConnects && $axmud::CLIENT->mainWin) {
12307  
12308 # If the existing file object needs to be saved, asked permission before importing data
12309 # into it
12310 $choice = $axmud::CLIENT->mainWin->showMsgDialogue(
12311 'Patch pre-configured world',
12312 'question',
12313 'The world profile \'' . $world . '\' requires a patch. Do you want to apply this'
12314 . ' patch now? (Click \'Yes\' unless you have modified the world profile yourself'
12315 . ' and you are CERTAIN that it is working properly)',
12316 'yes-no',
12317 );
12318  
12319 if ($choice eq 'no') {
12320  
12321 return undef;
12322 }
12323 }
12324  
12325  
12326 if ($world eq 'archipelago' && $fileVersion < 1_003_000) {
12327  
12328 $worldObj->ivPoke('referURL', 'http://mudstats.com/World/ArchipelagoMUD');
12329 }
12330  
12331 if (
12332 (
12333 $world eq 'achaea' || $world eq 'aetolia' || $world eq 'imperian'
12334 || $world eq 'lusternia'
12335 ) && $fileVersion < 1_002_041
12336 ) {
12337 my $compObj;
12338  
12339 # Fix for IRE's odd habit of sending a single EOR and a single SGA, which permanently
12340 # disables the prompt-checking code in GA::Session->processLinePortion
12341 $worldObj->ivAdd('telnetOverrideHash', 'sga', undef);
12342 $worldObj->ivAdd('telnetOverrideHash', 'eor', undef);
12343 # Fix for IRE's refusal to do MXP telnet negotiation
12344 $worldObj->ivAdd('mxpOverrideHash', 'perm', TRUE);
12345  
12346 # Also remove the '(road)' in Achaea room titles
12347 if ($world eq 'achaea') {
12348  
12349 $compObj = $worldObj->ivShow('componentHash', 'verb_title');
12350 if ($compObj) {
12351  
12352 $compObj->{usePatternGroups} = '(.*)\.';
12353 }
12354 }
12355 }
12356  
12357 if ($world eq 'alteraeon' && $fileVersion < 1_001_270) {
12358  
12359 # Patch to fix bad regex in the 'verb_exit' component
12360 my $compObj = $worldObj->ivShow('componentHash', 'verb_exit');
12361 if ($compObj) {
12362  
12363 $compObj->ivPoke('startPatternList', '^\[Exits: ');
12364 }
12365 }
12366  
12367 if ($world eq 'avalonrpg' && $fileVersion < 1_001_012) {
12368  
12369 my ($compObj, $missionObj);
12370  
12371 # Patch to fix handling of room statements, which doesn't work at night, and to fix the
12372 # login mission, which no longer works at all
12373 $worldObj->ivDelete('componentHash', 'ignore_line');
12374  
12375 $compObj = Games::Axmud::Obj::Component->new(
12376 $axmud::CLIENT,
12377 $worldObj,
12378 'ignore_line',
12379 'ignore_line',
12380 );
12381  
12382 if ($compObj) {
12383  
12384 $compObj->{size} = 0;
12385 $compObj->{minSize} = 0; # Optional
12386 $compObj->{maxSize} = 1;
12387 $compObj->{analyseMode} = 'check_line';
12388 $compObj->{boldSensitiveFlag} = FALSE;
12389 $compObj->{useInitialTagsFlag} = FALSE;
12390 $compObj->{combineLinesFlag} = FALSE;
12391  
12392 $compObj->{startPatternList} = [
12393 '^The sky ',
12394 ];
12395 $compObj->{startTagList} = [];
12396 $compObj->{startAllFlag} = FALSE;
12397 $compObj->{startTagMode} = 'default';
12398  
12399 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
12400 }
12401  
12402 $missionObj = $worldObj->ivShow('missionHash', 'avalon_login');
12403 if ($missionObj) {
12404  
12405 $missionObj->ivPoke(
12406 'missionList',
12407 't What is the name',
12408 'n', # Send char name
12409 't What is the password',
12410 'w', # Send account password
12411 't Land of Avalon',
12412 '> ',
12413 ';login',
12414 );
12415 }
12416 }
12417  
12418 if ($world eq 'darkrealms' && $fileVersion < 1_003_000) {
12419  
12420 $worldObj->ivPoke('ipv4', '64.227.89.30 1138');
12421 $worldObj->ivPoke('worldURL', 'http://darkrealmscos.com/');
12422 }
12423  
12424 if ($world eq 'dawn' && $fileVersion < 1_003_000) {
12425  
12426 $worldObj->ivPoke('dns', 'dawnmud.com');
12427 $worldObj->ivPoke('ipv4', '76.91.216.39');
12428 }
12429  
12430 if (
12431 ($world eq 'dsdev' || $world eq 'dslocal' || $world eq 'dsprime')
12432 && $fileVersion < 1_001_270
12433 ) {
12434 my $compObj;
12435  
12436 # Patch to turn off VT100 control sequences, which are just annoying in a test
12437 # environment
12438 $worldObj->ivAdd('termOverrideHash', 'useCtrlSeqFlag', FALSE);
12439  
12440 # Also use an excess command delay that doesn't cause a DS refusal
12441 $worldObj->ivPoke('excessCmdDelay', 1.5);
12442  
12443 # Also solved problem of command prompts being added to room titles, after several
12444 # simultaneous movement commands
12445 $compObj = $worldObj->ivShow('componentHash', 'verb_title');
12446 if ($compObj) {
12447  
12448 $compObj->ivPoke('usePatternGroups', 'hp\:.*mp\:.*sp\:.*\>\s(.*)');
12449 }
12450 }
12451  
12452 if ($world eq 'discworld' && $fileVersion < 1_001_343) {
12453  
12454 my $compObj;
12455  
12456 # Patch to fix various issues over several versions of Axmud
12457 $worldObj->ivPush(
12458 'lockedPatternList',
12459 '^The .* swings shut in your face',
12460 );
12461  
12462 $worldObj->ivPush(
12463 'failExitPatternList',
12464 '^You just crawled\. Give your arms a break',
12465 '^You are too tall to go that way',
12466 '^You struggle to leave (.*), but you can\'t make any headway',
12467 );
12468  
12469 # (Replace existing regex)
12470 $worldObj->ivPoke(
12471 'darkRoomPatternList',
12472 'It\'s dark here, isn\'t it',
12473 );
12474  
12475 $worldObj->ivPoke(
12476 'transientExitPatternList',
12477 'enter (.*) carriage',
12478 undef,
12479 'enter door',
12480 undef,
12481 );
12482  
12483 # (MXP supplies gauge data, so the Status task doesn't need to create its own gauge
12484 # level)
12485 $worldObj->ivEmpty('gaugeFormatList');
12486 # (Translate gauge entities into Status task variables)
12487 $worldObj->ivPoke(
12488 'mxpStatusVarHash',
12489 'hp' => 'health_points',
12490 'maxhp' => 'health_points_max',
12491 'gp' => 'guild_points',
12492 'maxgp' => 'guild_points_max',
12493 'sp' => 'social_points',
12494 'maxsp' => 'social_points_max',
12495 'xp' => 'xp_current',
12496 );
12497  
12498 $worldObj->ivPoke(
12499 'verboseAnchorPatternList',
12500 '^.*There are (.*) obvious exits\: (.*)',
12501 '^.*There is one obvious exit\: (.*)',
12502 '^.*There are no obvious exits\.',
12503 );
12504  
12505 $worldObj->ivPoke(
12506 'verboseExitLeftMarkerList',
12507 '^.*There are (.*) obvious exits\: ',
12508 '^.*There is one obvious exit\: ',
12509 '^.*There are no obvious exits\.',
12510 );
12511  
12512 $worldObj->ivPoke(
12513 'briefAnchorPatternList',
12514 '\ \[(.*)\]\.\s*$',
12515 );
12516  
12517 $worldObj->ivDelete('componentHash', 'verb_descrip');
12518 $worldObj->ivDelete('componentHash', 'verb_descrip_1');
12519 $worldObj->ivDelete('componentHash', 'verb_descrip_2');
12520 $worldObj->ivDelete('componentHash', 'ignore_line');
12521 $worldObj->ivDelete('componentHash', 'verb_exit');
12522 $worldObj->ivDelete('componentHash', 'brief_title_exit');
12523  
12524 $worldObj->ivPoke(
12525 'verboseComponentList',
12526 'verb_descrip_1', # no MXP
12527 'verb_descrip_2', # MXP
12528 'ignore_line',
12529 'anchor',
12530 'verb_exit',
12531 );
12532  
12533 $compObj = Games::Axmud::Obj::Component->new(
12534 $axmud::CLIENT,
12535 $worldObj,
12536 'verb_descrip_1',
12537 'verb_descrip',
12538 );
12539  
12540 if ($compObj) {
12541  
12542 $compObj->{size} = 0;
12543 $compObj->{minSize} = 0;
12544 $compObj->{maxSize} = 16;
12545 $compObj->{analyseMode} = 'check_line';
12546 $compObj->{boldSensitiveFlag} = FALSE;
12547 $compObj->{useInitialTagsFlag} = FALSE;
12548 $compObj->{combineLinesFlag} = FALSE;
12549  
12550 $compObj->{usePatternBackRefs} = '^\s[\s\-\|\\\/\&\$\@\+\*]{10}\s(.*)',
12551  
12552 $compObj->{startPatternList} = [
12553 '^\s[\s\-\|\\\/\&\$\@\+\*]{10}\s(.*)',
12554 ],
12555 $compObj->{startTagList} = [];
12556 $compObj->{startAllFlag} = FALSE;
12557 $compObj->{startTagMode} = 'default';
12558  
12559 $compObj->{stopBeforeNoPatternList} = [
12560 '^\s[\s\-\|\\\/\&\$\@\+\*]{10}\s(.*)',
12561 ],
12562 $compObj->{stopBeforeNoTagList} = [];
12563 $compObj->{stopBeforeNoAllFlag} = FALSE;
12564 $compObj->{stopBeforeNoTagMode} = 'default';
12565  
12566 $compObj->{stopBeforePatternList} = [
12567 '^\s..........\sIt is ',
12568 '^\s..........\sThe land is lit up ',
12569 ],
12570 $compObj->{stopBeforeTagList} = [];
12571 $compObj->{stopBeforeAllFlag} = FALSE;
12572 $compObj->{stopBeforeTagMode} = 'default';
12573  
12574 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
12575 }
12576  
12577 $compObj = Games::Axmud::Obj::Component->new(
12578 $axmud::CLIENT,
12579 $worldObj,
12580 'verb_descrip_2',
12581 'verb_descrip',
12582 );
12583  
12584 if ($compObj) {
12585  
12586 $compObj->{size} = 0;
12587 $compObj->{minSize} = 0;
12588 $compObj->{maxSize} = 16;
12589 $compObj->{analyseMode} = 'check_line';
12590 $compObj->{boldSensitiveFlag} = FALSE;
12591 $compObj->{useInitialTagsFlag} = FALSE;
12592 $compObj->{combineLinesFlag} = FALSE;
12593  
12594 $compObj->{startPatternList} = [
12595 '^\w',
12596 ],
12597 $compObj->{startTagList} = [];
12598 $compObj->{startAllFlag} = FALSE;
12599 $compObj->{startTagMode} = 'default';
12600  
12601 $compObj->{stopBeforeNoPatternList} = [
12602 '^\w',
12603 ],
12604 $compObj->{stopBeforeNoTagList} = [];
12605 $compObj->{stopBeforeNoAllFlag} = FALSE;
12606 $compObj->{stopBeforeNoTagMode} = 'default';
12607  
12608 $compObj->{stopBeforePatternList} = [
12609 '^It is ',
12610 '^The land is lit up ',
12611 ],
12612 $compObj->{stopBeforeTagList} = [];
12613 $compObj->{stopBeforeAllFlag} = FALSE;
12614 $compObj->{stopBeforeTagMode} = 'default';
12615  
12616 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
12617 }
12618  
12619 $compObj = Games::Axmud::Obj::Component->new(
12620 $axmud::CLIENT,
12621 $worldObj,
12622 'ignore_line',
12623 'ignore_line',
12624 );
12625  
12626 if ($compObj) {
12627  
12628 $compObj->{size} = 0;
12629 $compObj->{minSize} = 0;
12630 $compObj->{maxSize} = 16;
12631 $compObj->{analyseMode} = 'check_line';
12632 $compObj->{boldSensitiveFlag} = FALSE;
12633 $compObj->{useInitialTagsFlag} = FALSE;
12634 $compObj->{combineLinesFlag} = FALSE;
12635  
12636 $compObj->{startPatternList} = [];
12637 $compObj->{startTagList} = [
12638 'yellow', # no mxp
12639 '#FF8700', # mxp
12640 'x208', # xterm256
12641 ];
12642 $compObj->{startAllFlag} = FALSE;
12643 $compObj->{startTagMode} = 'default';
12644  
12645 $compObj->{stopBeforeNoPatternList} = [];
12646 $compObj->{stopBeforeNoTagList} = [
12647 'yellow',
12648 '#FF8700',
12649 'x208',
12650 ];
12651 $compObj->{stopBeforeNoAllFlag} = FALSE;
12652 $compObj->{stopBeforeNoTagMode} = 'default';
12653  
12654 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
12655 }
12656  
12657 $compObj = Games::Axmud::Obj::Component->new(
12658 $axmud::CLIENT,
12659 $worldObj,
12660 'verb_exit',
12661 'verb_exit',
12662 );
12663  
12664 if ($compObj) {
12665  
12666 $compObj->{size} = 1;
12667 $compObj->{analyseMode} = 'check_line';
12668 $compObj->{boldSensitiveFlag} = FALSE;
12669 $compObj->{useInitialTagsFlag} = FALSE;
12670 $compObj->{combineLinesFlag} = TRUE;
12671  
12672 $compObj->{startPatternList} = [
12673 '^.*There are (.*) obvious exits\: (.*)',
12674 '^.*There is one obvious exit\: (.*)',
12675 '^.*There are no obvious exits\.',
12676 ];
12677 $compObj->{startTagList} = [];
12678 $compObj->{startAllFlag} = FALSE;
12679 $compObj->{startTagMode} = 'default';
12680  
12681 $compObj->{stopBeforeNoPatternList} = [];
12682 $compObj->{stopBeforeNoTagList} = [];
12683 $compObj->{stopBeforeNoAllFlag} = FALSE;
12684 $compObj->{stopBeforeNoTagMode} = 'default';
12685  
12686 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
12687 }
12688  
12689 $compObj = Games::Axmud::Obj::Component->new(
12690 $axmud::CLIENT,
12691 $worldObj,
12692 'brief_title_exit',
12693 'brief_title_exit',
12694 );
12695  
12696 if ($compObj) {
12697  
12698 $compObj->{size} = 1;
12699 $compObj->{analyseMode} = 'check_line';
12700 $compObj->{boldSensitiveFlag} = FALSE;
12701 $compObj->{useInitialTagsFlag} = FALSE;
12702 $compObj->{combineLinesFlag} = FALSE;
12703  
12704 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
12705 }
12706 }
12707  
12708 if ($world eq 'dunemud' && $fileVersion < 1_002_000) {
12709  
12710 $worldObj->ivPoke('dns', 'dunemud.net');
12711 $worldObj->ivPoke('ipv4', '68.183.23.43');
12712 }
12713  
12714 if ($world eq 'edmud' && $fileVersion < 1_003_000) {
12715  
12716 $worldObj->ivPoke('dns', 'eternaldarkness.net');
12717 $worldObj->ivPoke('ipv4', '216.136.9.8');
12718 $worldObj->ivPoke('worldURL', 'eternaldarkness.net');
12719 }
12720  
12721 if ($world eq 'fkindgoms' && $fileVersion < 1_003_000) {
12722  
12723 $worldObj->ivPoke('port', 4000);
12724 }
12725
12726 if ($world eq 'forestsedge' && $fileVersion < 1_003_000) {
12727  
12728 $worldObj->ivPoke('dns', 'mud.theforestsedge.com');
12729 $worldObj->ivPoke('ipv4', '167.114.137.18');
12730 $worldObj->ivPoke('port', 4000);
12731 }
12732  
12733 if ($world eq 'icesus' && $fileVersion < 1_003_000) {
12734  
12735 $worldObj->ivPoke('dns', 'naga.icesus.org');
12736 $worldObj->ivPoke('ipv4', '95.216.243.162');
12737 $worldObj->ivPoke('port', 4000);
12738 $worldObj->ivPoke('worldURL', 'http://www.icesus.org/');
12739 }
12740  
12741 if ($world eq 'islands' && $fileVersion < 1_002_000) {
12742  
12743 $worldObj->ivPoke('dns', 'play.islands-game.live');
12744 $worldObj->ivPoke('ipv4', '45.79.14.59');
12745 }
12746  
12747 if ($world eq 'kallisti' && $fileVersion < 1_002_041) {
12748  
12749 # Auto-disconnections no longer a problem so re-enabled MSDP
12750 $worldObj->ivDelete('telnetOverrideHash', 'msdp');
12751  
12752 # Looks like output for 'score' command and prompt have been updated, too
12753 $worldObj->ivPush(
12754 'groupPatternList',
12755 '^\< \w+ \| (\d+)h (\d+)m (\d+)s',
12756 1,
12757 'health_points',
12758 'show',
12759 '^\< \w+ \| (\d+)h (\d+)m (\d+)s',
12760 2,
12761 'magic_points',
12762 'show',
12763 '^\< \w+ \| (\d+)h (\d+)m (\d+)s',
12764 3,
12765 'energy_points',
12766 'show',
12767 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s'
12768 . '(\d+)\s\/\s(\d+)',
12769 1,
12770 'health_points',
12771 'show',
12772 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s'
12773 . '(\d+)\s\/\s(\d+)',
12774 2,
12775 'health_points_max',
12776 'show',
12777 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s'
12778 . '(\d+)\s\/\s(\d+)',
12779 3,
12780 'magic_points',
12781 'show',
12782 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s'
12783 . '(\d+)\s\/\s(\d+)',
12784 4,
12785 'magic_points_max',
12786 'show',
12787 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s'
12788 . '(\d+)\s\/\s(\d+)',
12789 5,
12790 'energy_points',
12791 'show',
12792 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s'
12793 . '(\d+)\s\/\s(\d+)',
12794 6,
12795 'energy_points_max',
12796 'show',
12797 );
12798  
12799 # Replace the command prompt pattern
12800 $worldObj->ivPoke(
12801 'cmdPromptPatternList',
12802 '^\< \w+ \| (\d+)h (\d+)m (\d+)s \> .',
12803 );
12804  
12805 # Add a very common fail exit message
12806 $worldObj->ivPush(
12807 'failExitPatternList',
12808 'Alas, you cannot go .*\.\.\.',
12809 );
12810 }
12811  
12812 if ($world eq 'luminari' && $fileVersion < 1_001_270) {
12813  
12814 # Patch to fix bad regex in the ->channelList
12815 $worldObj->ivPoke(
12816 'channelList',
12817 '^\w+ chats, \'',
12818 'tell', TRUE,
12819 '^You chat, \'',
12820 'tell', TRUE,
12821 '^\[INFO\] ',
12822 'social', TRUE,
12823 );
12824 }
12825  
12826 if ($world eq 'mud1' && $fileVersion < 1_001_270) {
12827  
12828 my $compObj;
12829  
12830 # Update overrides
12831 $worldObj->ivAdd('termOverrideHash', 'useVisibleCursorFlag', TRUE);
12832  
12833 # Update problems with room statement detection
12834 $worldObj->ivPoke(
12835 'notAnchorPatternList',
12836 '^\*',
12837 '^\w+$',
12838 );
12839  
12840 $compObj = $worldObj->ivShow('componentHash', 'verb_descrip');
12841 if ($compObj) {
12842  
12843 $compObj->{startNoPatternList} = [
12844 '^\*',
12845 ];
12846 $compObj->{startNoTagList} = [];
12847 $compObj->{startNoAllFlag} = FALSE;
12848 $compObj->{startNoTagMode} = 'default';
12849 }
12850 }
12851  
12852 if ($world eq 'mudii' && $fileVersion < 1_001_270) {
12853  
12854 my ($missionObj, $compObj, $compObj2);
12855  
12856 # Update overrides
12857 $worldObj->ivAdd('termOverrideHash', 'useVisibleCursorFlag', TRUE);
12858  
12859 # Update login mission
12860 $missionObj = $worldObj->ivShow('missionHash', 'mudii_login');
12861 if ($missionObj) {
12862  
12863 $missionObj->ivPoke(
12864 'missionList',
12865 't ^\w+ login\:',
12866 '> mud',
12867 't ^Account ID\:',
12868 'a',
12869 't ^Password\:',
12870 'w',
12871 't Checking your mail',
12872 '> ',
12873 't Option',
12874 '> p',
12875 't By what name shall I call you',
12876 'n',
12877 't Elizabethan tearoom',
12878 ';login',
12879 );
12880 }
12881  
12882 # Update problems with room statement detection
12883 $worldObj->ivPoke(
12884 'notAnchorPatternList',
12885 '^\*',
12886 '^\w+$',
12887 );
12888  
12889 $compObj = $worldObj->ivShow('componentHash', 'ignore_line');
12890 if ($compObj) {
12891  
12892 $compObj->{boldSensitiveFlag} = FALSE;
12893  
12894 $compObj->{startPatternList} = [];
12895 $compObj->{startTagList} = [];
12896 $compObj->{startAllFlag} = FALSE;
12897 $compObj->{startTagMode} = 'default';
12898  
12899 $compObj->{startNoPatternList} = [];
12900 $compObj->{startNoTagList} = [
12901 'green',
12902 ];
12903 $compObj->{startNoAllFlag} = FALSE;
12904 $compObj->{startNoTagMode} = 'default';
12905  
12906 $compObj->{stopBeforePatternList} = [];
12907 $compObj->{stopBeforeTagList} = [
12908 'green',
12909 ];
12910 $compObj->{stopBeforeAllFlag} = FALSE;
12911 $compObj->{stopBeforeTagMode} = 'default';
12912 }
12913  
12914 $compObj2 = $worldObj->ivShow('componentHash', 'verb_descrip');
12915 if ($compObj2) {
12916  
12917 $compObj2->{startNoPatternList} = [
12918 '^It is raining\.',
12919 ];
12920 $compObj2->{startNoTagList} = [];
12921 $compObj2->{startNoAllFlag} = FALSE;
12922 $compObj2->{startNoTagMode} = 'default';
12923 }
12924 }
12925  
12926 if ($world eq 'mud2' && $fileVersion < 1_001_270) {
12927  
12928 my ($missionObj, $compObj, $compObj2);
12929  
12930 # Update overrides
12931 $worldObj->ivAdd('termOverrideHash', 'useVisibleCursorFlag', TRUE);
12932  
12933 # Update login mission
12934 $missionObj = $worldObj->ivShow('missionHash', 'mud2_login');
12935 if ($missionObj) {
12936  
12937 $missionObj->ivPoke(
12938 'missionList',
12939 't ^\w+ login\:',
12940 '> mud',
12941 't ^Account ID\:',
12942 'a',
12943 't ^Password\:',
12944 'w',
12945 't Hit return',
12946 '> ',
12947 't Option',
12948 '> p',
12949 't By what name shall I call you',
12950 'n',
12951 't Elizabethan tearoom',
12952 ';login',
12953 );
12954 }
12955  
12956 # Update problems with room statement detection
12957 $worldObj->ivPoke(
12958 'notAnchorPatternList',
12959 '^\*',
12960 '^\w+$',
12961 );
12962  
12963 $compObj = $worldObj->ivShow('componentHash', 'ignore_line');
12964 if ($compObj) {
12965  
12966 $compObj->{boldSensitiveFlag} = FALSE;
12967  
12968 $compObj->{startPatternList} = [];
12969 $compObj->{startTagList} = [];
12970 $compObj->{startAllFlag} = FALSE;
12971 $compObj->{startTagMode} = 'default';
12972  
12973 $compObj->{startNoPatternList} = [];
12974 $compObj->{startNoTagList} = [
12975 'green',
12976 ];
12977 $compObj->{startNoAllFlag} = FALSE;
12978 $compObj->{startNoTagMode} = 'default';
12979  
12980 $compObj->{stopBeforePatternList} = [];
12981 $compObj->{stopBeforeTagList} = [
12982 'green',
12983 ];
12984 $compObj->{stopBeforeAllFlag} = FALSE;
12985 $compObj->{stopBeforeTagMode} = 'default';
12986 }
12987  
12988 $compObj2 = $worldObj->ivShow('componentHash', 'verb_descrip');
12989 if ($compObj2) {
12990  
12991 $compObj2->{startNoPatternList} = [
12992 '^It is raining\.',
12993 ];
12994 $compObj2->{startNoTagList} = [];
12995 $compObj2->{startNoAllFlag} = FALSE;
12996 $compObj2->{startNoTagMode} = 'default';
12997 }
12998 }
12999  
13000 if ($world eq 'nanvaent' && $fileVersion < 1_001_343) {
13001  
13002 # Remove follow patterns, which conflict with some room descriptions, causing automapper
13003 # to get lost
13004 $worldObj->ivEmpty('followPatternList');
13005 }
13006  
13007 if ($world eq 'nanvaent' && $fileVersion < 1_001_405) {
13008  
13009 # Update exit states
13010 $worldObj->ivPoke(
13011 'exitStateTagHash',
13012 'cyan',
13013 'emphasis',
13014 );
13015 }
13016  
13017 if ($world eq 'pict' && $fileVersion < 1_001_174) {
13018  
13019 $worldObj->ivPoke('dns', undef);
13020 $worldObj->ivPoke('ipv4', '136.62.89.155');
13021 }
13022  
13023 if ($world eq 'swmud' && $fileVersion < 1_001_012) {
13024  
13025 my $compObj;
13026  
13027 # Patch to fix handling of room statements, which doesn't work very well at all
13028 $worldObj->ivPoke(
13029 'verboseAnchorPatternList',
13030 '^There are (.*) obvious exits\: (.*)',
13031 '^The only obvious exit is (.*)\.',
13032 '^There are no obvious exits\.',
13033 );
13034  
13035 $worldObj->ivPoke(
13036 'verboseExitDelimiterList',
13037 ', and ',
13038 ' and ',
13039 ', ',
13040 );
13041  
13042 $worldObj->ivDelete('componentHash', 'verb_title');
13043 $worldObj->ivDelete('componentHash', 'verb_descrip');
13044 $worldObj->ivDelete('componentHash', 'ignore_line');
13045 $worldObj->ivDelete('componentHash', 'ignore_line_1');
13046 $worldObj->ivDelete('componentHash', 'ignore_line_2');
13047 $worldObj->ivDelete('componentHash', 'verb_exit');
13048  
13049 $worldObj->ivPoke(
13050 'verboseComponentList',
13051 'verb_descrip',
13052 'ignore_line_1',
13053 'ignore_line_2',
13054 'anchor',
13055 'verb_exit',
13056 );
13057  
13058 $compObj = Games::Axmud::Obj::Component->new(
13059 $axmud::CLIENT,
13060 $worldObj,
13061 'verb_descrip',
13062 'verb_descrip',
13063 );
13064  
13065 if ($compObj) {
13066  
13067 $compObj->{size} = 0;
13068 $compObj->{minSize} = 0;
13069 $compObj->{maxSize} = 16;
13070 $compObj->{analyseMode} = 'check_line';
13071 $compObj->{boldSensitiveFlag} = FALSE;
13072 $compObj->{useInitialTagsFlag} = FALSE;
13073 $compObj->{combineLinesFlag} = FALSE;
13074  
13075 $compObj->{stopBeforePatternList} = [
13076 '^\>',
13077 ];
13078 $compObj->{stopBeforeTagList} = [];
13079 $compObj->{stopBeforeAllFlag} = FALSE;
13080 $compObj->{stopBeforeTagMode} = 'default';
13081  
13082 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
13083 }
13084  
13085 $compObj = Games::Axmud::Obj::Component->new(
13086 $axmud::CLIENT,
13087 $worldObj,
13088 'ignore_line_1',
13089 'ignore_line',
13090 );
13091  
13092 if ($compObj) {
13093  
13094 $compObj->{size} = 0;
13095 $compObj->{minSize} = 0;
13096 $compObj->{maxSize} = 16;
13097 $compObj->{analyseMode} = 'check_line';
13098 $compObj->{boldSensitiveFlag} = FALSE;
13099 $compObj->{useInitialTagsFlag} = FALSE;
13100 $compObj->{combineLinesFlag} = FALSE;
13101  
13102 $compObj->{startPatternList} = [];
13103 $compObj->{startTagList} = ['green'];
13104 $compObj->{startAllFlag} = FALSE;
13105 $compObj->{startTagMode} = 'default';
13106  
13107 $compObj->{stopAtMode} = 'no_letter_num';
13108  
13109 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
13110 }
13111  
13112 $compObj = Games::Axmud::Obj::Component->new(
13113 $axmud::CLIENT,
13114 $worldObj,
13115 'ignore_line_2',
13116 'ignore_line',
13117 );
13118  
13119 if ($compObj) {
13120  
13121 $compObj->{size} = 1; # Fixed size
13122 $compObj->{analyseMode} = 'check_line';
13123 $compObj->{boldSensitiveFlag} = FALSE;
13124 $compObj->{useInitialTagsFlag} = FALSE;
13125 $compObj->{combineLinesFlag} = FALSE;
13126  
13127 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
13128 }
13129  
13130 $compObj = Games::Axmud::Obj::Component->new(
13131 $axmud::CLIENT,
13132 $worldObj,
13133 'verb_exit',
13134 'verb_exit',
13135 );
13136  
13137 if ($compObj) {
13138  
13139 $compObj->{size} = 0;
13140 $compObj->{minSize} = 1;
13141 $compObj->{maxSize} = 16;
13142 $compObj->{analyseMode} = 'check_line';
13143 $compObj->{boldSensitiveFlag} = FALSE;
13144 $compObj->{useInitialTagsFlag} = FALSE;
13145 $compObj->{combineLinesFlag} = TRUE;
13146  
13147 $compObj->{startPatternList} = [
13148 '^There are (.*) obvious exits\: (.*)',
13149 '^The only obvious exit is (.*)\.',
13150 '^There are no obvious exits\.',
13151 ];
13152 $compObj->{startTagList} = [];
13153 $compObj->{startAllFlag} = FALSE;
13154 $compObj->{startTagMode} = 'default';
13155  
13156 $compObj->{stopPatternList} = [
13157 '\.\s*$',
13158 ];
13159 $compObj->{stopTagList} = [];
13160 $compObj->{stopAllFlag} = FALSE;
13161 $compObj->{stopTagMode} = 'default';
13162  
13163 $compObj->{stopAtMode} = 'no_letter_num';
13164  
13165 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
13166 }
13167 }
13168  
13169 if ($world eq 'threekingdoms' && $fileVersion < 1_001_270) {
13170  
13171 my $compObj;
13172  
13173 # Patch to fix handling of verbose descriptions in room statements
13174 $compObj = $worldObj->ivShow('componentHash', 'verb_descrip');
13175 if ($compObj) {
13176  
13177 $compObj->{useExplicitTagsFlag} = TRUE;
13178 }
13179 }
13180  
13181 if ($world eq 'threescapes' && $fileVersion < 1_001_270) {
13182  
13183 my $compObj;
13184  
13185 # Patch to fix handling of verbose descriptions in room statements
13186 $compObj = $worldObj->ivShow('componentHash', 'verb_descrip');
13187 if ($compObj) {
13188  
13189 $compObj->{useExplicitTagsFlag} = TRUE;
13190 }
13191 }
13192  
13193 if ($world eq 'twotowers' && $fileVersion < 1_001_343) {
13194  
13195 my @newList;
13196  
13197 # Fix wrong channels regex
13198 foreach my $item ($worldObj->channelList) {
13199  
13200 if ($item eq '^You tell \w\: ') {
13201 push (@newList, '^You tell \w+\: ');
13202 } else {
13203 push (@newList, $item);
13204 }
13205 }
13206  
13207 # Patch to fix handling of brief room statements
13208 $worldObj->ivPoke(
13209 'briefAnchorPatternList',
13210 '[^\s]\(([^\(\)]+\)\s\[[^\[\]]+)\]\s*$', # Rooms with swimming
13211 '[^\s]\(([^\(\)]+)\)\s*$', # Rooms without swimming
13212 );
13213 }
13214  
13215 if ($world eq 'twotowers' && $fileVersion < 1_001_405) {
13216  
13217 my $compObj;
13218  
13219 # Add a new failed exit
13220 $worldObj->ivPush('failExitPatternList', '^You\'re too tired to swim right now');
13221  
13222 # Update exit states
13223 $worldObj->ivPoke(
13224 'exitStateTagHash',
13225 'BLUE',
13226 'swim @@@',
13227 );
13228  
13229 # Set a duplicate exit replacement
13230 $worldObj->ivPoke('duplicateReplaceString', 'swim @@@');
13231  
13232 # Fix handling of room statements, after a Locator reset, in rooms with water exits
13233 $worldObj->ivPoke(
13234 'verboseAnchorPatternList',
13235 '^\s\s\s\sThe only obvious exits are (.*)\.',
13236 '^\s\s\s\sThe only obvious exit is (.*)\.',
13237 );
13238  
13239 $worldObj->ivDelete('componentHash', 'verb_exit');
13240  
13241 $worldObj->ivPoke(
13242 'verboseComponentList',
13243 'verb_descrip',
13244 'verb_exit_1',
13245 'anchor',
13246 'verb_exit_2',
13247 );
13248  
13249 $compObj = Games::Axmud::Obj::Component->new(
13250 $axmud::CLIENT,
13251 $worldObj,
13252 'verb_exit_1',
13253 'verb_exit',
13254 );
13255  
13256 if ($compObj) {
13257  
13258 $compObj->{size} = 0;
13259 $compObj->{minSize} = 0; # Optional
13260 $compObj->{maxSize} = 16;
13261 $compObj->{analyseMode} = 'check_line';
13262 $compObj->{boldSensitiveFlag} = FALSE;
13263 $compObj->{useInitialTagsFlag} = FALSE;
13264 $compObj->{combineLinesFlag} = FALSE; # Water & normal exits on separate lines
13265  
13266 $compObj->{startPatternList} = [];
13267 $compObj->{startTagList} = [
13268 'blue',
13269 ];
13270 $compObj->{startAllFlag} = FALSE;
13271 $compObj->{startTagMode} = 'default';
13272  
13273 $compObj->{stopAtPatternList} = [
13274 '^\s\s\s\sThere is water to the (.*)\.',
13275 ];
13276 $compObj->{stopAtTagList} = [];
13277 $compObj->{stopAtAllFlag} = FALSE;
13278 $compObj->{stopAtTagMode} = 'default';
13279  
13280 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
13281 }
13282  
13283 $compObj = Games::Axmud::Obj::Component->new(
13284 $axmud::CLIENT,
13285 $worldObj,
13286 'verb_exit_2',
13287 'verb_exit',
13288 );
13289  
13290 if ($compObj) {
13291  
13292 $compObj->{size} = 0;
13293 $compObj->{minSize} = 1;
13294 $compObj->{maxSize} = 16;
13295 $compObj->{analyseMode} = 'check_line';
13296 $compObj->{boldSensitiveFlag} = FALSE;
13297 $compObj->{useInitialTagsFlag} = FALSE;
13298 $compObj->{combineLinesFlag} = FALSE; # Water & normal exits on separate lines
13299  
13300 $compObj->{startPatternList} = [
13301 '^\s\s\s\sThe only obvious exits are (.*)\.',
13302 '^\s\s\s\sThe only obvious exit is (.*)\.',
13303 ];
13304 $compObj->{startTagList} = [];
13305 $compObj->{startAllFlag} = FALSE;
13306 $compObj->{startTagMode} = 'default';
13307  
13308 $compObj->{stopBeforeNoPatternList} = [
13309 '^\s\s\s\sThe only obvious exits are (.*)\.',
13310 '^\s\s\s\sThe only obvious exit is (.*)\.',
13311 ];
13312 $compObj->{stopBeforeNoTagList} = [];
13313 $compObj->{stopBeforeNoAllFlag} = FALSE;
13314 $compObj->{stopBeforeNoTagMode} = 'default';
13315  
13316 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
13317 }
13318 }
13319  
13320 if ($world eq 'twotowers' && $fileVersion < 1_002_000) {
13321  
13322 my $compObj;
13323  
13324 # Further fix to handling of room statements
13325  
13326 $worldObj->ivPoke(
13327 'verboseAnchorPatternList',
13328 '^\s\s\s\sThe only obvious exits are (.*)',
13329 '^\s\s\s\sThe only obvious exit is (.*)',
13330 );
13331  
13332 $worldObj->ivDelete('componentHash', 'verb_exit_1');
13333 $worldObj->ivDelete('componentHash', 'verb_exit_2');
13334  
13335 $compObj = Games::Axmud::Obj::Component->new(
13336 $axmud::CLIENT,
13337 $worldObj,
13338 'verb_exit_1',
13339 'verb_exit',
13340 );
13341  
13342 if ($compObj) {
13343  
13344 $compObj->{size} = 0;
13345 $compObj->{minSize} = 0; # Optional
13346 $compObj->{maxSize} = 16;
13347 $compObj->{analyseMode} = 'check_line';
13348 $compObj->{boldSensitiveFlag} = FALSE;
13349 $compObj->{useInitialTagsFlag} = FALSE;
13350 $compObj->{combineLinesFlag} = TRUE;
13351  
13352 $compObj->{startPatternList} = [];
13353 $compObj->{startTagList} = [
13354 'blue',
13355 ];
13356 $compObj->{startAllFlag} = FALSE;
13357 $compObj->{startTagMode} = 'default';
13358  
13359 $compObj->{stopAtPatternList} = [
13360 '^\s\s\s\sThere is water to the',
13361 ];
13362 $compObj->{stopAtTagList} = [];
13363 $compObj->{stopAtAllFlag} = FALSE;
13364 $compObj->{stopAtTagMode} = 'default';
13365  
13366 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
13367 }
13368  
13369 $compObj = Games::Axmud::Obj::Component->new(
13370 $axmud::CLIENT,
13371 $worldObj,
13372 'verb_exit_2',
13373 'verb_exit',
13374 );
13375  
13376 if ($compObj) {
13377  
13378 $compObj->{size} = 0;
13379 $compObj->{minSize} = 1;
13380 $compObj->{maxSize} = 16;
13381 $compObj->{analyseMode} = 'check_line';
13382 $compObj->{boldSensitiveFlag} = FALSE;
13383 $compObj->{useInitialTagsFlag} = FALSE;
13384 $compObj->{combineLinesFlag} = TRUE;
13385  
13386 $compObj->{startPatternList} = [
13387 '^\s\s\s\sThe only obvious exits are',
13388 '^\s\s\s\sThe only obvious exit is',
13389 ];
13390 $compObj->{startTagList} = [];
13391 $compObj->{startAllFlag} = FALSE;
13392 $compObj->{startTagMode} = 'default';
13393  
13394 $compObj->{stopAtPatternList} = [
13395 '\.\s*$',
13396 ];
13397 $compObj->{stopAtTagList} = [];
13398 $compObj->{stopAtAllFlag} = FALSE;
13399 $compObj->{stopAtTagMode} = 'default';
13400  
13401 $worldObj->ivAdd('componentHash', $compObj->name, $compObj);
13402 }
13403 }
13404  
13405 return 1;
13406 }
13407  
13408 sub checkCompatibility {
13409  
13410 # Called by $self->loadConfigFile, $self->loadDataFile and ->importDataFile
13411 # The data file's header states which programme created the data file. This function checks
13412 # that the programme was either Axmud or something compatible with Axmud (specifically, an
13413 # earlier version of it)
13414 #
13415 # Expected arguments
13416 # $scriptName - The name of the programme that created the data file
13417 #
13418 # Return values
13419 # 'undef' on improper arguments or if the data file is incompatible with Axmud
13420 # 1 if the data file is compatible with Axmud
13421  
13422 my ($self, $scriptName, $check) = @_;
13423  
13424 # Check for improper arguments
13425 if (! defined $scriptName || defined $check) {
13426  
13427 return $axmud::CLIENT->writeImproper($self->_objClass . '->checkCompatibility', @_);
13428 }
13429  
13430 OUTER: foreach my $item (@axmud::COMPAT_FILE_LIST) {
13431  
13432 if ($scriptName eq $item) {
13433  
13434 # Data file is compatible
13435 return 1;
13436 }
13437 }
13438  
13439 # Data file is not compatible
13440 return undef;
13441 }
13442  
13443 sub compileTasks {
13444  
13445 # Called by $self->updateExtractedData to compile a list of tasks of a certain type; the
13446 # returned list includes tasks from all profile's initial tasklists as well as the global
13447 # initial tasklist and the custom tasklist
13448 #
13449 # Expected arguments
13450 # (none besides $self)
13451 #
13452 # Optional arguments
13453 # $name - A task's ->name, e.g. 'locator_task'. If set to 'undef', all tasks are
13454 # included in the returned list
13455 #
13456 # Return values
13457 # An empty list on improper arguments
13458 # Otherwise, returns the list of matching initial/custom tasks
13459  
13460 my ($self, $name, $check) = @_;
13461  
13462 # Local variables
13463 my (@emptyList, @taskList);
13464  
13465 # Check for improper arguments
13466 if (defined $check) {
13467  
13468 $axmud::CLIENT->writeImproper($self->_objClass . '->compileTasks', @_);
13469 return @emptyList;
13470 }
13471  
13472 # Profile initial tasklists
13473 if ($self->session) {
13474  
13475 foreach my $profObj ($self->session->ivValues('profHash')) {
13476  
13477 foreach my $taskObj ($profObj->ivValues('initTaskHash')) {
13478  
13479 if (! $name || $taskObj->{name} eq $name) {
13480  
13481 push (@taskList, $taskObj);
13482 }
13483 }
13484 }
13485 }
13486  
13487 # Global initial tasklist
13488 foreach my $taskObj ($axmud::CLIENT->ivValues('initTaskHash')) {
13489  
13490 if (! $name || $taskObj->{name} eq $name) {
13491  
13492 push (@taskList, $taskObj);
13493 }
13494 }
13495  
13496 # Custom tasklist
13497 foreach my $taskObj ($axmud::CLIENT->ivValues('customTaskHash')) {
13498  
13499 if (! $name || $taskObj->{name} eq $name) {
13500  
13501 push (@taskList, $taskObj);
13502 }
13503 }
13504  
13505 return @taskList;
13506 }
13507  
13508 sub examineDataFile {
13509  
13510 # Called by GA::Cmd::TestFile->do, or by any other function (this is a debug function)
13511 # Loads a specified file as if it were a genuine Axmud data file (but not a config file).
13512 # Returns information about the file
13513 # NB This function works even when the global flags forbidding the loading or importing of
13514 # files are set
13515 # NB This function works, even if the file's header specifies an older version of Axmud
13516 # NB Because the Perl Storable module doesn't seem to offer a way to check that the file
13517 # really was created by it, this function now only tests .axm files
13518 #
13519 # Expected arguments
13520 # $path - The full path of the file to check
13521 # $mode - 'return_header' returns just the header information (metadata),
13522 # - 'remove_values' returns the hash, with all the values in the key-value
13523 # pairs set to 'undef' (removing all the references)
13524 # - 'return_key' returns the value of a single specified key (returns a hash
13525 # containing a single key-value pair)
13526 # - 'return_hash' returns the entire contents of the file as the original hash
13527 #
13528 # Optional arguments
13529 # $selectKey - In mode 'return_key' - the key whose value should be returned (the value
13530 # will be a scalar, or a scalar reference)
13531 #
13532 # Return values
13533 # An empty hash on improper arguments, if the file doesn't exist, if it is unreadable or
13534 # if it is in the wrong format
13535 # Otherwise, returns the hash specified above
13536  
13537 my ($self, $path, $mode, $selectKey, $check) = @_;
13538  
13539 # Local variables
13540 my (
13541 $matchFlag, $hashRef, $fileType, $scriptName, $scriptVersion, $saveDate, $saveTime,
13542 $assocWorldProf,
13543 %emptyHash, %loadHash, %returnHash,
13544 );
13545  
13546 # Check for improper arguments
13547 if (
13548 ! defined $path
13549 || ! defined $mode
13550 || (
13551 defined $mode && $mode ne 'return_header' && $mode ne 'remove_values'
13552 && $mode ne 'return_key' && $mode ne 'return_hash'
13553 )
13554 || ($mode eq 'return_key' && ! defined $selectKey)
13555 || defined $check
13556 ) {
13557 $axmud::CLIENT->writeImproper($self->_objClass . '->importDataFile', @_);
13558 return %emptyHash;
13559 }
13560  
13561 # Check that the specified file exists
13562 if (! (-e $path)) {
13563  
13564 return %emptyHash;
13565 }
13566  
13567 # The Perl Storable module doesn't seem to offer a way to check that the file really was
13568 # created by it. To avoid an ugly Perl error, limit operations to files with compatible
13569 # extensions
13570 OUTER: foreach my $ext (@axmud::COMPAT_EXT_LIST) {
13571  
13572 if ($path =~ m/\.$ext$/) {
13573  
13574 $matchFlag = TRUE;
13575 last OUTER;
13576 }
13577 }
13578  
13579 if (! $matchFlag) {
13580  
13581 return %emptyHash;
13582 }
13583  
13584 # Load all the data into a hash
13585 eval { $hashRef = Storable::lock_retrieve($path); };
13586 if (! $hashRef || (ref $hashRef) ne 'HASH') {
13587  
13588 # ->lock_retrieve() failed
13589 return %emptyHash;
13590  
13591 } else {
13592  
13593 # Convert the hash referenced by $hashRef into a named hash
13594 %loadHash = %{$hashRef};
13595  
13596 # Extract the header information (metadata) from the hash
13597 $fileType = $loadHash{'file_type'};
13598 $scriptName = $loadHash{'script_name'};
13599 $scriptVersion = $loadHash{'script_version'};
13600 $saveDate = $loadHash{'save_date'};
13601 $saveTime = $loadHash{'save_time'};
13602  
13603 # Before v1.0.868, Axmud used 'assoc_world_defn' rather than 'assoc_world_prof', and
13604 # the file_types 'worldprof'/'otherprof' were 'worlddefn'/'otherdefn'
13605 if ($loadHash{'file_type'} eq 'worlddefn') {
13606 $loadHash{'file_type'} = 'worldprof';
13607 } elsif ($loadHash{'file_type'} eq 'otherdefn') {
13608 $loadHash{'file_type'} = 'otherprof';
13609 }
13610  
13611 if ($loadHash{'assoc_world_defn'}) {
13612 $assocWorldProf = $loadHash{'assoc_world_defn'};
13613 } else {
13614 $assocWorldProf = $loadHash{'assoc_world_prof'};
13615 }
13616  
13617 # Do basic checks on the header information
13618 if (
13619 ! defined $fileType || ! defined $scriptName || ! defined $scriptVersion
13620 || ! defined $saveDate || ! defined $saveTime
13621 ) {
13622 # Wrong kind of file, or missing (or possibly corrupted) header (NB $assocWorldProf
13623 # is 'undef' for some types of file)
13624 return %emptyHash;
13625 }
13626  
13627 # 'return_header' - just return the header (metadata)
13628 if ($mode eq 'return_header') {
13629  
13630 $returnHash{'file_type'} = $fileType;
13631 $returnHash{'script_name'} = $scriptName;
13632 $returnHash{'script_version'} = $scriptVersion;
13633 $returnHash{'save_date'} = $saveDate;
13634 $returnHash{'save_time'} = $saveTime;
13635 $returnHash{'assoc_world_prof'} = $assocWorldProf;
13636  
13637 return %returnHash;
13638  
13639 # 'remove_values' - return all the keys in the hash, but not the values (set the values
13640 # to 'undef')
13641 } elsif ($mode eq 'remove_values') {
13642  
13643 foreach my $key (keys %loadHash) {
13644  
13645 $returnHash{$key} = undef;
13646 }
13647  
13648 return %returnHash;
13649  
13650 # 'return_key' - return the specified key
13651 } elsif ($mode eq 'return_key') {
13652  
13653 if (! exists $loadHash{$selectKey}) {
13654  
13655 # Return an empty hash
13656 return %emptyHash;
13657  
13658 } else {
13659  
13660 # Return a hash containing the single key-value pair
13661 $returnHash{$selectKey} = $loadHash{$selectKey};
13662  
13663 return %returnHash;
13664 }
13665  
13666 # 'return_hash' - return the entire loaded hash
13667 } elsif ($mode eq 'return_hash') {
13668  
13669 return %loadHash;
13670 }
13671 }
13672 }
13673  
13674 sub disableSaveLoad {
13675  
13676 # Called by $self->loadConfigFile or $self->saveConfigFile whenever a call to File::close()
13677 # returns false, or whenever there's an error reading/writing the config file
13678 # Sets some GA::Client flags to prevent other files from being loaded/saved
13679 #
13680 # Expected arguemnts
13681 # $readFlag - Set to FALSE when called because of File::open or File::close returning
13682 # 'false', or if a lock can't be taken out or released on a semaphore
13683 # file; this disables loading/saving of all files
13684 # - Set to TRUE when called because of an error reading the config file
13685 # ($self->saveConfigFile doesn't have its own non-fatal errors, so there
13686 # is no need to check for that)
13687 #
13688 # Return values
13689 # 'undef'
13690  
13691 my ($self, $readFlag, $check) = @_;
13692  
13693 # Check for improper arguments
13694 if (! defined $readFlag || defined $check) {
13695  
13696 return $axmud::CLIENT::writeImproper($self->_objClass . '->disableSaveLoad', @_);
13697 }
13698  
13699 # Set GA::Client flags
13700 if (! $readFlag) {
13701  
13702 $axmud::CLIENT->set_loadConfigFlag(FALSE);
13703 }
13704  
13705 $axmud::CLIENT->set_saveConfigFlag(FALSE);
13706 $axmud::CLIENT->set_loadDataFlag(FALSE);
13707 $axmud::CLIENT->set_saveDataFlag(FALSE);
13708  
13709  
13710 if (! $readFlag) {
13711  
13712 return $self->writeError(
13713 'OS failed to open/close file (possible buffering problem) - loading/saving of'
13714 . ' files disabled',
13715 $self->_objClass . '->disableSaveLoad',
13716 );
13717  
13718 } else {
13719  
13720 # $self->setupConfigFile displays an error message
13721 return undef;
13722 }
13723 }
13724  
13725 sub getFileLock {
13726  
13727 # Can be called by any file-writing or file-reading function within GA::Obj::File
13728 # (currently only called by ->loadConfigFile and ->saveConfigFile)
13729 # Takes out a lock on the semaphore file $sempahoreFile twinned with the data file
13730 # $dataFile, so that the file can be either open for reading by one or more instances
13731 # of Axmud (and one or more sessions), or open for writing by a single instance of Axmud
13732 # (or by a single session)
13733 # If the semaphore file doesn't exist yet, it is created
13734 #
13735 # Expected arguments
13736 # $semaphoreFile - The path to the semaphore file, e.g. '/home/myname/file.txt'
13737 #
13738 # Optional arguments
13739 # $exclusiveFlag - If set to TRUE, an exclusive lock is taken out (for writing to the
13740 # file).
13741 # - If set to FALSE (or 'undef'), a shared lock is taken out (for reading
13742 # from the file)
13743 # $dataFile - The path to the data file. If specified, the semaphore file is marked
13744 # with the data file's name
13745 #
13746 # Return values
13747 # 'undef' on improper arguments, or if the semaphore file can't be opened, or if a lock
13748 # can't be taken out on it (at all)
13749 # Otherwise returns the file handle of the locked semaphore file (required by
13750 # $self->releaseFileLock)
13751  
13752 my ($self, $semaphoreFile, $exclusiveFlag, $dataFile, $check) = @_;
13753  
13754 # Local variables
13755 my $semaphoreHandle;
13756  
13757 # Check for improper arguments
13758 if (! defined $semaphoreFile || defined $check) {
13759  
13760 return $axmud::CLIENT->writeImproper($self->_objClass . '->getFileLock', @_);
13761 }
13762  
13763 # If the semaphore file doesn't yet exist (because the main file being saved is actually
13764 # new), create the semaphore file
13765 if (! (-e $semaphoreFile)) {
13766  
13767 my @list;
13768  
13769 if (! open ($semaphoreHandle, ">$semaphoreFile")) {
13770  
13771 return undef;
13772 }
13773  
13774 if ($dataFile) {
13775 @list = ($axmud::SCRIPT . ' semaphore file for ' . $dataFile);
13776 } else {
13777 @list = ($axmud::SCRIPT . ' semaphore file');
13778 }
13779  
13780 print $semaphoreHandle @list;
13781 close $semaphoreHandle;
13782 }
13783  
13784 # Get a lock on the semaphore file
13785 if (! open ($semaphoreHandle, ">>$semaphoreFile")) {
13786  
13787 return undef;
13788 }
13789  
13790 if ($exclusiveFlag && ! flock ($semaphoreHandle, Fcntl::LOCK_EX)) {
13791 return undef;
13792 } elsif (! flock ($semaphoreHandle, Fcntl::LOCK_SH)) {
13793 return undef;
13794 }
13795  
13796 # Return the filehandle to the locked semaphore file
13797 return $semaphoreHandle;
13798 }
13799  
13800 sub releaseFileLock {
13801  
13802 # Can be called by any file-writing or file-reading function within GA::Obj::File
13803 # (currently only called by ->loadConfigFile and ->saveConfigFile)
13804 # Releases a lock taken out on a semaphore file twinned with a data file
13805 #
13806 # Expected arguments
13807 # $semaphoreHandle - Opened handle of the semaphore file
13808 #
13809 # Return values
13810 # 'undef' on improper arguments
13811 # 1 otherwise
13812  
13813 my ($self, $semaphoreHandle, $check) = @_;
13814  
13815 # Check for improper arguments
13816 if (! defined $semaphoreHandle || defined $check) {
13817  
13818 return $axmud::CLIENT->writeImproper($self->_objClass . '->releaseFileLock', @_);
13819 }
13820  
13821 # Release the lock by closing the open filehandle
13822 close $semaphoreHandle;
13823  
13824 return 1;
13825 }
13826  
13827 sub readMarker {
13828  
13829 # Called by $self->loadConfigFile
13830 # Reads lines from an opened config file until it finds one that doesn't begin with the
13831 # comment marker #
13832 # That line should begin with the status marker @@@
13833 # Returns the text after the status marker @@@ as a two-element list
13834 # e.g. for '@@@ date Mon Aug 8, 2011', returns the list ('date', 'Mon Aug 8, 2011')
13835 # e.g. for '@@@ time 12:23:22' returns the list ('time', '12:23:22')
13836 # e.g. for '@@@ eos' (meaning end of section), returns the list ('eos', undef)
13837 # e.g. for '@@@ eof' (meaning end of file), returns the list ('eof', undef)
13838 #
13839 # Expected arguments
13840 # $fileHandle - filehandle of the config file (opened for reading)
13841 #
13842 # Return values
13843 # An empty list on improper arguments, if the file can't be read, the end of the file is
13844 # reached, the line can't be read, the line doesn't begin with @@@ or the @@@ isn't
13845 # followed by at least one character
13846 # or the @@@ isn't followed by at least one character, returns 'undef'
13847  
13848  
13849 # Otherwise, the list described above
13850  
13851 my ($self, $fileHandle, $check) = @_;
13852  
13853 # Local variables
13854 my (
13855 $line, $position,
13856 @emptyList, @returnArray,
13857 );
13858  
13859 # Check for improper arguments
13860 if (! defined $fileHandle || defined $check) {
13861  
13862 $axmud::CLIENT->writeImproper($self->_objClass . '->readMarker', @_);
13863 return @emptyList;
13864 }
13865  
13866 # Read an entry from the file
13867 OUTER: while (1) {
13868  
13869 $line = <$fileHandle>;
13870 chomp $line;
13871  
13872 if (! defined $line) {
13873  
13874 # File can't be read, or end of file
13875 return @emptyList;
13876 }
13877  
13878 if (substr ($line, 0, 1) ne '#') {
13879  
13880 # $line should start with @@@
13881 if (substr ($line, 0, 4) ne '@@@ ') {
13882  
13883 return @emptyList;
13884 }
13885  
13886 # $line starts with @@@, so continue processing it
13887 last OUTER;
13888 }
13889 }
13890  
13891 # Remove the @@@
13892 $line = substr($line, 4);
13893  
13894 # Extract the first word
13895 $position = index($line, ' ');
13896  
13897 if ($position < 1) {
13898  
13899 # Line consists of just one word
13900 return ($line, undef);
13901  
13902 } else {
13903  
13904 # Line consists of a word, plus an argument string
13905 return (substr($line, 0, $position), substr($line, $position + 1));
13906 }
13907 }
13908  
13909 sub readLine {
13910  
13911 # Called by $self->loadConfigFile and its sub-functions
13912 # Reads lines from an opened config file until it finds one that doesn't begin with the
13913 # comment marker #
13914 # If that line begins with the status marker @@@, returns 'undef' (because we are expecting
13915 # some readable data, not a marker)
13916 #
13917 # Expected arguments
13918 # $fileHandle - filehandle of the config file (opened for reading)
13919 #
13920 # Return values
13921 # 'undef' on improper arguments, if the file can't be read, the end of the file is
13922 # reached, of if there's a status marker where data should be
13923 # Otherwise, returns the first line of data read from the file that doesn't begin with
13924 # the comment marker #
13925  
13926 my ($self, $fileHandle, $check) = @_;
13927  
13928 # Local variables
13929 my $line;
13930  
13931 # Check for improper arguments
13932 if (! defined $fileHandle || defined $check) {
13933  
13934 return $axmud::CLIENT->writeImproper($self->_objClass . '->readLine', @_);
13935 }
13936  
13937 # Read a line of data from the file
13938 while (1) {
13939  
13940 $line = <$fileHandle>;
13941 chomp $line;
13942  
13943 if (! defined $line || substr ($line, 0, 4) eq '@@@ ') {
13944  
13945 # File can't be read, or end of file; or there's a status marker where a line of
13946 # data should be
13947 return undef;
13948  
13949 } elsif (substr ($line, 0, 2) ne '# ') {
13950  
13951 # This is a line of data. Return it
13952 return $line;
13953 }
13954 }
13955 }
13956  
13957 sub readValue {
13958  
13959 # Called by $self->loadConfigFile
13960 # Reads a single value from an opened config file, and stores it in the temporary hash of
13961 # loaded data
13962 #
13963 # Expected arguments
13964 # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag,
13965 # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE,
13966 # this function does nothing. If none of the calls have failed so far,
13967 # set to TRUE.
13968 # $hashRef - Reference to the temporary hash of loaded data
13969 # $key - The key in the temporary hash where the value read by this function is
13970 # stored
13971 #
13972 # Return values
13973 # Returns the new value of $failFlag:
13974 # TRUE if $failFlag is already set to TRUE, or if this function can't read a value
13975 # FALSE otherwise (meaning that the function succeeded)
13976  
13977 my ($self, $failFlag, $hashRef, $key, $check) = @_;
13978  
13979 # Local variables
13980 my $value;
13981  
13982 # Check for improper arguments
13983 if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) {
13984  
13985 $axmud::CLIENT->writeImproper($self->_objClass . '->readValue', @_);
13986 return TRUE;
13987 }
13988  
13989 # Do nothing, if previous calls failed
13990 if ($failFlag) {
13991  
13992 return TRUE;
13993 }
13994  
13995 # Read the value
13996 $value = $self->readLine($$hashRef{'file_handle'});
13997  
13998 if (! defined $value) {
13999  
14000 # Operation failed
14001 $self->writeError(
14002 'Config file load error at item \'' . $key . '\'',
14003 $self->_objClass . '->readValue',
14004 );
14005  
14006 return TRUE;
14007  
14008 } else {
14009  
14010 # Operation succeeded. Store the value in the temporary data hash
14011 $$hashRef{$key} = $value;
14012 return FALSE;
14013 }
14014 }
14015  
14016 sub readValueOrUndef {
14017  
14018 # Called by $self->loadConfigFile
14019 # Reads a single value from an opened config file, and stores it in the temporary hash of
14020 # loaded data
14021 # Unlike $self->readValue, if the code reads an empty string, it uses the value 'undef'
14022 # rather than an empty string
14023 #
14024 # Expected arguments
14025 # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag,
14026 # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE,
14027 # this function does nothing. If none of the calls have failed so far,
14028 # set to TRUE.
14029 # $hashRef - Reference to the temporary hash of loaded data
14030 # $key - The key in the temporary hash where the value read by this function is
14031 # stored
14032 #
14033 # Return values
14034 # Returns the new value of $failFlag:
14035 # TRUE if $failFlag is already set to TRUE, or if this function can't read a value
14036 # FALSE otherwise (meaning that the function succeeded)
14037  
14038 my ($self, $failFlag, $hashRef, $key, $check) = @_;
14039  
14040 # Local variables
14041 my $value;
14042  
14043 # Check for improper arguments
14044 if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) {
14045  
14046 $axmud::CLIENT->writeImproper($self->_objClass . '->readValue', @_);
14047 return TRUE;
14048 }
14049  
14050 # Do nothing, if previous calls failed
14051 if ($failFlag) {
14052  
14053 return TRUE;
14054 }
14055  
14056 # Read the value
14057 $value = $self->readLine($$hashRef{'file_handle'});
14058  
14059 if (! defined $value) {
14060  
14061 # Operation failed
14062 $self->writeError(
14063 'Config file load error at item \'' . $key . '\'',
14064 $self->_objClass . '->readValueOrUndef',
14065 );
14066  
14067 return TRUE;
14068  
14069 } else {
14070  
14071 # Operation succeeded. Store the value in the temporary data hash
14072 if ($value eq '') {
14073 $$hashRef{$key} = undef;
14074 } else {
14075 $$hashRef{$key} = $value;
14076 }
14077  
14078 return FALSE;
14079 }
14080 }
14081  
14082 sub readFlag {
14083  
14084 # Called by $self->loadConfigFile
14085 # Reads a single flag from an opened config file, and stores it in the temporary hash of
14086 # loaded data
14087 #
14088 # Expected arguments
14089 # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag,
14090 # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE,
14091 # this function does nothing. If none of the calls have failed so far,
14092 # set to TRUE.
14093 # $hashRef - Reference to the temporary hash of loaded data
14094 # $key - The key in the temporary hash where the flag read by this function is
14095 # stored
14096 #
14097 # Return values
14098 # Returns the new value of $failFlag:
14099 # TRUE if $failFlag is already set to TRUE, or if this function can't read a flag
14100 # FALSE otherwise (meaning that the function succeeded)
14101  
14102 my ($self, $failFlag, $hashRef, $key, $check) = @_;
14103  
14104 # Local variables
14105 my $flag;
14106  
14107 # Check for improper arguments
14108 if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) {
14109  
14110 $axmud::CLIENT->writeImproper($self->_objClass . '->readFlag', @_);
14111 return TRUE;
14112 }
14113  
14114 # Do nothing, if previous calls failed
14115 if ($failFlag) {
14116  
14117 return TRUE;
14118 }
14119  
14120 # Read the flag
14121 $flag = $self->readLine($$hashRef{'file_handle'});
14122  
14123 if (! defined $flag) {
14124  
14125 # Operation failed
14126 $self->writeError(
14127 'Config file load error at item \'' . $key . '\'',
14128 $self->_objClass . '->readFlag',
14129 );
14130  
14131 return TRUE;
14132  
14133 } else {
14134  
14135 # Operation succeeded. Store the flag in the temporary data hash
14136 if ($flag) {
14137 $$hashRef{$key} = TRUE;
14138 } else {
14139 $$hashRef{$key} = FALSE;
14140 }
14141  
14142 return FALSE;
14143 }
14144 }
14145  
14146 sub readList {
14147  
14148 # Called by $self->loadConfigFile
14149 # Reads a list from an opened config file - consisting of the number of value to read,
14150 # followed by the values themselves - and stores the values themselves in the temporary
14151 # hash of loaded data
14152 #
14153 # Expected arguments
14154 # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag,
14155 # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE,
14156 # this function does nothing. If none of the calls have failed so far,
14157 # set to TRUE.
14158 # $hashRef - Reference to the temporary hash of loaded data
14159 # $key - The key in the temporary hash where the list read by this function is
14160 # stored
14161 #
14162 # Return values
14163 # Returns the new value of $failFlag:
14164 # TRUE if $failFlag is already set to TRUE, if this function can't read a list or if
14165 # the list contains the wrong number of values
14166 # FALSE otherwise (meaning that the function succeeded)
14167  
14168 my ($self, $failFlag, $hashRef, $key, $check) = @_;
14169  
14170 # Local variables
14171 my (
14172 $number,
14173 @list,
14174 );
14175  
14176 # Check for improper arguments
14177 if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) {
14178  
14179 $axmud::CLIENT->writeImproper($self->_objClass . '->readList', @_);
14180 return TRUE;
14181 }
14182  
14183 # Do nothing, if previous calls failed
14184 if ($failFlag) {
14185  
14186 return TRUE;
14187 }
14188  
14189 # Read the number of items in the list
14190 $number = $self->readLine($$hashRef{'file_handle'});
14191 if (! defined $number || ! $axmud::CLIENT->intCheck($number, 0)) {
14192  
14193 # Operation failed
14194 $self->writeError(
14195 'Config file load error at item \'' . $key . '\'',
14196 $self->_objClass . '->readList',
14197 );
14198  
14199 return TRUE;
14200  
14201 } else {
14202  
14203 for (my $count = 0; $count < $number; $count++) {
14204  
14205 my $value = $self->readLine($$hashRef{'file_handle'});
14206 if (! defined $value) {
14207  
14208 # Missing value; operation failed
14209 $self->writeError(
14210 'Config file load error at item \'' . $key . '\' - missing value(s)',
14211 $self->_objClass . '->readList',
14212 );
14213  
14214 return TRUE;
14215  
14216 } else {
14217  
14218 push (@list, $value);
14219 }
14220 }
14221  
14222 # Operation succeeded. Store the list in the temporary data hash
14223 $$hashRef{$key} = \@list;
14224 return FALSE;
14225 }
14226 }
14227  
14228 sub readHash {
14229  
14230 # Called by $self->loadConfigFile
14231 # Reads a hash from an opened config file - consisting of the number of key-value pairs to
14232 # read, followed by the keys and values themselves - and stores the complete hash in the
14233 # temporary hash of loaded data
14234 #
14235 # Expected arguments
14236 # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag,
14237 # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE,
14238 # this function does nothing. If none of the calls have failed so far,
14239 # set to TRUE.
14240 # $hashRef - Reference to the temporary hash of loaded data
14241 # $key - The key in the temporary hash where the hash read by this function is
14242 # stored
14243 #
14244 # Return values
14245 # Returns the new value of $failFlag:
14246 # TRUE if $failFlag is already set to TRUE, if this function can't read a hash or if
14247 # the list contains the wrong number of key-value pairs
14248 # FALSE otherwise (meaning that the function succeeded)
14249  
14250 my ($self, $failFlag, $hashRef, $key, $check) = @_;
14251  
14252 # Local variables
14253 my (
14254 $number,
14255 %hash,
14256 );
14257  
14258 # Check for improper arguments
14259 if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) {
14260  
14261 $axmud::CLIENT->writeImproper($self->_objClass . '->readHash', @_);
14262 return TRUE;
14263 }
14264  
14265 # Do nothing, if previous calls failed
14266 if ($failFlag) {
14267  
14268 return TRUE;
14269 }
14270  
14271 # Read the number of key-value pairs in the hash
14272 $number = $self->readLine($$hashRef{'file_handle'});
14273 if (! defined $number || ! $axmud::CLIENT->intCheck($number, 0)) {
14274  
14275 # Operation failed
14276 $self->writeError(
14277 'Config file load error at item \'' . $key . '\'',
14278 $self->_objClass . '->readHash',
14279 );
14280  
14281 return TRUE;
14282  
14283 } else {
14284  
14285 for (my $count = 0; $count < $number; $count++) {
14286  
14287 my ($key, $value);
14288  
14289 $key = $self->readLine($$hashRef{'file_handle'});
14290 if (! defined $key) {
14291  
14292 # Missing value; operation failed
14293 $self->writeError(
14294 'Config file load error at item \'' . $key . '\' - missing value(s)',
14295 $self->_objClass . '->readHash',
14296 );
14297  
14298 return TRUE;
14299 }
14300  
14301 $value = $self->readLine($$hashRef{'file_handle'});
14302 if (! defined $value) {
14303  
14304 # Missing value; operation failed
14305 $self->writeError(
14306 'Config file load error at item \'' . $key . '\' - missing value(s)',
14307 $self->_objClass . '->readHash',
14308 );
14309  
14310 return TRUE;
14311 }
14312  
14313 $hash{$key} = $value;
14314 }
14315  
14316 # Operation succeeded. Store the list in the temporary data hash
14317 $$hashRef{$key} = \%hash;
14318 return FALSE;
14319 }
14320 }
14321  
14322 sub readEndOfSection {
14323  
14324 # Called by $self->loadConfigFile
14325 # Reads a single end-of-section line from an opened config file
14326 #
14327 # Expected arguments
14328 # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag,
14329 # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE,
14330 # this function does nothing. If none of the calls have failed so far,
14331 # set to TRUE.
14332 # $fileHandle - The config file's filehandle
14333 #
14334 # Return values
14335 # Returns the new value of $failFlag:
14336 # TRUE if $failFlag is already set to TRUE, or if this function can't read the
14337 # end-of-section
14338 # FALSE otherwise (meaning that the function succeeded)
14339  
14340 my ($self, $failFlag, $fileHandle, $check) = @_;
14341  
14342 # Local variables
14343 my $line;
14344  
14345 # Check for improper arguments
14346 if (! defined $failFlag || ! defined $fileHandle || defined $check) {
14347  
14348 $axmud::CLIENT->writeImproper($self->_objClass . '->readEndOfSection', @_);
14349 return FALSE;
14350 }
14351  
14352 # Do nothing, if previous calls failed
14353 if ($failFlag) {
14354  
14355 return TRUE;
14356 }
14357  
14358 # Read the end of section
14359 ($line) = $self->readMarker($fileHandle);
14360  
14361 if (! defined $line || $line ne 'eos') {
14362  
14363 # Operation failed
14364 return TRUE;
14365  
14366 } else {
14367  
14368 # Operation succeeded
14369 return FALSE;
14370 }
14371 }
14372  
14373 sub convert {
14374  
14375 # Called by $self->saveConfigFile
14376 # Converts an Axmud flag (TRUE or FALSE) into the values 1 or 0, so it can be written to the
14377 # 'config' file
14378 #
14379 # Expected arguments
14380 # (none besides $self)
14381 #
14382 # Optional arguments
14383 # $flag - The flag to convert (should be TRUE or FALSE). If 'undef', treated as FALSE
14384 #
14385 # Return values
14386 # 1 or 0
14387  
14388 my ($self, $flag, $check) = @_;
14389  
14390 # (No improper arguments to check)
14391  
14392 if ($flag) {
14393 return 1;
14394 } else {
14395 return 0;
14396 }
14397 }
14398  
14399 sub destroyStandardDir {
14400  
14401 # Called by GA::Cmd::DeleteWorld, or by any other code
14402 # Deletes the whole directory in which this object's file is stored - in the case of a
14403 # 'worldprof' file, deleting the directory $self->actualDir will also cause the
14404 # 'otherprof' and 'worldmodel' files, which are in the same directory, to be deleted
14405 # (If $self->actualDir hasn't been set yet, $self->standardDir is used)
14406 # No warning dialogue is shown - it's up to the calling code to do that
14407 #
14408 # Expected arguments
14409 # (none besides $self)
14410 #
14411 # Return values
14412 # 'undef' on improper arguments, if $self->actualDir isn't set or if it doesn't exist
14413 # 1 otherwise
14414  
14415 my ($self, $check) = @_;
14416  
14417 # Local variables
14418 my $dir;
14419  
14420 # Check for improper arguments
14421 if (defined $check) {
14422  
14423 return $axmud::CLIENT->writeImproper($self->_objClass . '->destroyStandardDir', @_);
14424 }
14425  
14426 # Decide which directory to delete
14427 if ($self->actualDir) {
14428 $dir = $self->actualDir;
14429 } else {
14430 $dir = $axmud::DATA_DIR . $self->standardDir;
14431 }
14432  
14433 if (! $dir || ! (-e $dir)) {
14434  
14435 # Directory not set or doesn't exist
14436 return undef;
14437  
14438 } else {
14439  
14440 # Delete the directory and everything it contains
14441 File::Path::remove_tree($dir);
14442  
14443 return 1;
14444 }
14445 }
14446  
14447 # Glob test mode
14448  
14449 sub globTest {
14450  
14451 # Called by $self->saveDataFile
14452 # Glob test mode: In earlier Axmud versions, saving of data files failed (and Axmud crashed)
14453 # because of infinite recursions with two Perl objects referencing each other. If TRUE,
14454 # ever save file operation (not including the config file) tests data for this problem,
14455 # before saving it, writing the output to the terminal
14456 #
14457 # Expected arguments
14458 # %saveHash - A hash of data about to be saved to a data file
14459 #
14460 # Return values
14461 # 'undef' if the test fails (data file must not be saved)
14462 # 1 if the test succeeds (data file can be saved)
14463  
14464 my ($self, %saveHash) = @_;
14465  
14466 # Local variables
14467 my ($string, $line);
14468  
14469 # (no improper arguments to check)
14470  
14471 $string = $axmud::SCRIPT . " SAVE DATA TEST";
14472 print "$string\n";
14473 $line = "=" x length($string);
14474 print "$line\n";
14475  
14476 if (! $self->globTest_hash(1, \%saveHash)) {
14477  
14478 print "TEST FAILED\n";
14479 return undef;
14480  
14481 } else {
14482  
14483 print "TEST SUCCEEDED\n";
14484 return 1;
14485 }
14486 }
14487  
14488 sub globTest_list {
14489  
14490 # Called by $self->globTest or recursively by this function and/or $self->globTest_hash
14491  
14492 my ($self, $count, $listRef) = @_;
14493  
14494 $count++;
14495 if ($count >= 50) {
14496  
14497 # Likely infinite recursion; give up
14498 return undef;
14499 }
14500  
14501 foreach my $item (@$listRef) {
14502  
14503 my ($column, $result);
14504  
14505 $column = " " x $count;
14506  
14507 if (defined $item) {
14508 print "$column item $item\n";
14509 } else {
14510 print "$column item <undef>\n";
14511 }
14512  
14513 if (ref ($item) eq 'HASH' || ref ($item) =~ m/Axmud\:\:/) {
14514 $result = $self->globTest_hash($count, $item);
14515 } elsif (ref ($item) eq 'ARRAY') {
14516 $result = $self->globTest_list($count, $item);
14517 } else {
14518 $result = TRUE;
14519 }
14520  
14521 if (! $result) {
14522  
14523 return undef;
14524 }
14525 }
14526  
14527 return 1;
14528 }
14529  
14530 sub globTest_hash {
14531  
14532 # Called by $self->globTest or recursively by this function and/or $self->globTest_list
14533  
14534 my ($self, $count, $hashRef) = @_;
14535  
14536 $count++;
14537 if ($count >= 50) {
14538  
14539 # Likely infinite recursion; give up
14540 return undef;
14541 }
14542  
14543 foreach my $key (keys %$hashRef) {
14544  
14545 my ($value, $column, $result);
14546  
14547 $value = $$hashRef{$key};
14548 $column = " " x $count;
14549  
14550 if (defined $value) {
14551 print "$column key $key value $value\n";
14552 } else {
14553 print "$column key $key value <undef>\n";
14554 }
14555  
14556 if (ref ($value) eq 'HASH' || ref ($value) =~ m/Axmud\:\:/) {
14557 $result = $self->globTest_hash($count, $value);
14558 } elsif (ref ($value) eq 'ARRAY') {
14559 $result = $self->globTest_list($count, $value);
14560 } else {
14561 $result = TRUE;
14562 }
14563  
14564 if (! $result) {
14565  
14566 return undef;
14567 }
14568 }
14569  
14570 return 1;
14571 }
14572  
14573 # Client-renaming operations
14574  
14575 sub updateHeaderAfterRename {
14576  
14577 # In version v1.0.868, the client was renamed to Axmud, and ABasic was renamed to Axbasic.
14578 # Some internal data structures were also renamed
14579 # This function is called by $self->loadDataFile and ->importDataFile to update the file's
14580 # header data (the remaining data is update by the call to $self->updateDataAfterRename
14581 # Also called by GA::Client->copyPreConfigWorlds
14582 #
14583 # This code will probably be moved to an optional plugin at some point in the future
14584 #
14585 # Expected arguments
14586 # %loadHash - A hash of data that's just been loaded from this data file, before it has
14587 # been extracted and stored in memory
14588 #
14589 # Return values
14590 # %loadHash, which has been updated (or not) as required
14591  
14592 my ($self, %loadHash) = @_;
14593  
14594 # (no improper arguments to check)
14595  
14596 if (exists $loadHash{'file_type'}) {
14597  
14598 if ($loadHash{'file_type'} eq 'worlddefn') {
14599 $loadHash{'file_type'} = 'worldprof';
14600 } elsif ($loadHash{'file_type'} eq 'otherdefn') {
14601 $loadHash{'file_type'} = 'otherprof';
14602 }
14603 }
14604  
14605 if (exists $loadHash{'assoc_world_defn'}) {
14606  
14607 $loadHash{'assoc_world_prof'} = $loadHash{'assoc_world_defn'};
14608 delete $loadHash{'assoc_world_defn'};
14609 }
14610  
14611 return %loadHash;
14612 }
14613  
14614 sub updateDataAfterRename {
14615  
14616 # In version v1.0.868, the client was renamed to Axmud, and ABasic was renamed to Axbasic.
14617 # Some internal data structures were also renamed
14618 # This function is called by $self->extractData to update the file's data (not including the
14619 # header data, which was updated in the earlier call to $self->updateHeaderAfterRename)
14620 # This code will probably be moved to an optional plugin at some point in the future
14621 #
14622 # Expected arguments
14623 # %loadHash - A hash of data that's just been loaded from this data file, before it has
14624 # been extracted and stored in memory
14625 #
14626 # Return values
14627 # %loadHash, which has been updated (or not) as required
14628  
14629 my ($self, %loadHash) = @_;
14630  
14631 # Local variables
14632 my ($obj, $hashRef, $subHashRef);
14633  
14634 # (no improper arguments to check)
14635  
14636 if ($self->fileType eq 'worldprof') {
14637  
14638 if (exists $loadHash{'world_defn'}) {
14639  
14640 $loadHash{'world_prof'} = $loadHash{'world_defn'};
14641 delete $loadHash{'world_defn'};
14642 }
14643  
14644 if (exists $loadHash{'world_prof'}) {
14645  
14646 $loadHash{'world_prof'} = $self->update_profile_world($loadHash{'world_prof'});
14647 }
14648  
14649 } elsif ($self->fileType eq 'otherprof') {
14650  
14651 if (exists $loadHash{'defn_priority_list'}) {
14652  
14653 $loadHash{'prof_priority_list'} = $loadHash{'defn_priority_list'};
14654 delete $loadHash{'defn_priority_list'};
14655 }
14656  
14657 if (exists $loadHash{'defn_hash'}) {
14658  
14659 $loadHash{'prof_hash'} = $loadHash{'defn_hash'};
14660 delete $loadHash{'defn_hash'};
14661 }
14662  
14663 # no update required for 'prof_priority_list'
14664  
14665 if (exists $loadHash{'skeleton_hash'}) {
14666  
14667 $hashRef = $loadHash{'skeleton_hash'};
14668 foreach my $key (keys %$hashRef) {
14669  
14670 $$hashRef{$key} = $self->update_profile_template($$hashRef{$key});
14671 }
14672  
14673 $loadHash{'template_hash'} = $hashRef;
14674 delete $loadHash{'skeleton_hash'};
14675 }
14676  
14677 if (exists $loadHash{'prof_hash'}) {
14678  
14679 $hashRef = $loadHash{'prof_hash'};
14680 foreach my $key (keys %$hashRef) {
14681  
14682 $$hashRef{$key} = $self->update_profile_other($$hashRef{$key});
14683 }
14684  
14685 $loadHash{'prof_hash'} = $hashRef;
14686 }
14687  
14688 if (exists $loadHash{'templ_hash'}) {
14689  
14690 $hashRef = $loadHash{'templ_hash'};
14691 foreach my $key (keys %$hashRef) {
14692  
14693 $$hashRef{$key} = $self->update_cage_all($$hashRef{$key});
14694 }
14695  
14696 $loadHash{'cage_hash'} = $hashRef;
14697 }
14698  
14699 } elsif ($self->fileType eq 'worldmodel') {
14700  
14701 if (exists $loadHash{'world_model_obj'}) {
14702  
14703 $loadHash{'world_model_obj'}
14704 = $self->update_obj_world_model($loadHash{'world_model_obj'});
14705 }
14706  
14707 } elsif ($self->fileType eq 'tasks') {
14708  
14709 # no update required for 'task_label_hash'
14710 # no update required for 'task_run_first_list'
14711 # no update required for 'task_run_last_list'
14712  
14713 if (exists $loadHash{'init_task_hash'}) {
14714  
14715 $hashRef = $loadHash{'init_task_hash'};
14716 foreach my $key (keys %$hashRef) {
14717  
14718 $$hashRef{$key} = $self->update_task_all($$hashRef{$key});
14719 }
14720  
14721 $loadHash{'init_task_hash'} = $hashRef;
14722 }
14723  
14724 # no update required for 'init_task_order_list'
14725 # no update required for 'init_task_total'
14726  
14727 if (exists $loadHash{'custom_task_hash'}) {
14728  
14729 $hashRef = $loadHash{'custom_task_hash'};
14730 foreach my $key (keys %$hashRef) {
14731  
14732 $$hashRef{$key} = $self->update_task_all($$hashRef{$key});
14733 }
14734  
14735 $loadHash{'custom_task_hash'} = $hashRef;
14736 }
14737  
14738 } elsif ($self->fileType eq 'scripts') {
14739  
14740 # no update required for 'script_dir_list'
14741 # no update required for 'init_script_hash'
14742 # no update required for 'init_script_order_list'
14743  
14744 } elsif ($self->fileType eq 'contacts') {
14745  
14746 # no update required for 'chat_name'
14747 # no update required for 'chat_email'
14748 # no update required for 'chat_accept_mode'
14749  
14750 if (exists $loadHash{'chat_contact_hash'}) {
14751  
14752 $hashRef = $loadHash{'chat_contact_hash'};
14753 foreach my $key (keys %$hashRef) {
14754  
14755 $$hashRef{$key} = $self->update_obj_chat_contact($$hashRef{$key});
14756 }
14757  
14758 $loadHash{'chat_contact_hash'} = $hashRef;
14759 }
14760  
14761 # no update required for 'chat_icon'
14762 # no update required for 'chat_smiley_hash'
14763  
14764 } elsif ($self->fileType eq 'dicts') {
14765  
14766 if (exists $loadHash{'dict_hash'}) {
14767  
14768 $hashRef = $loadHash{'dict_hash'};
14769 foreach my $key (keys %$hashRef) {
14770  
14771 $$hashRef{$key} = $self->update_obj_dict($$hashRef{$key});
14772 }
14773  
14774 $loadHash{'dict_hash'} = $hashRef;
14775 }
14776  
14777 } elsif ($self->fileType eq 'toolbar') {
14778  
14779 if (exists $loadHash{'toolbar_hash'}) {
14780  
14781 $hashRef = $loadHash{'toolbar_hash'};
14782 foreach my $key (keys %$hashRef) {
14783  
14784 $$hashRef{$key} = $self->update_obj_toolbar($$hashRef{$key});
14785 }
14786  
14787 $loadHash{'toolbar_hash'} = $hashRef;
14788 }
14789  
14790 # no update required for 'toolbar_list'
14791  
14792 } elsif ($self->fileType eq 'usercmds') {
14793  
14794 # no update required for 'user_cmd_hash'
14795  
14796 } elsif ($self->fileType eq 'zonemaps') {
14797  
14798 if (exists $loadHash{'zonemap_hash'}) {
14799  
14800 $hashRef = $loadHash{'zonemap_hash'};
14801 foreach my $key (keys %$hashRef) {
14802  
14803 $$hashRef{$key} = $self->update_obj_zonemap($$hashRef{$key});
14804 }
14805  
14806 $loadHash{'zonemap_hash'} = $hashRef;
14807 }
14808  
14809 # ($subHashRef represents a subset of key-value pairs in $hashRef)
14810 if (exists $loadHash{'standard_zonemap_hash'}) {
14811  
14812 $subHashRef = $loadHash{'standard_zonemap_hash'};
14813 foreach my $key (keys %$subHashRef) {
14814  
14815 # If the zonemap is missing from GA::Client->zonemapHash (for some reason),
14816 # don't let it be added to GA::Client->standardZonemapHash
14817 if (exists $$hashRef{$key}) {
14818  
14819 $$subHashRef{$key} = $$hashRef{$key};
14820 }
14821 }
14822  
14823 $loadHash{'standard_zonemap_hash'} = $subHashRef;
14824 }
14825  
14826 } elsif ($self->fileType eq 'winmaps') {
14827  
14828 if (exists $loadHash{'winmap_hash'}) {
14829  
14830 $hashRef = $loadHash{'winmap_hash'};
14831 foreach my $key (keys %$hashRef) {
14832  
14833 $$hashRef{$key} = $self->update_obj_winmap($$hashRef{$key});
14834 }
14835  
14836 $loadHash{'winmap_hash'} = $hashRef;
14837 }
14838  
14839 # ($subHashRef represents a subset of key-value pairs in $hashRef)
14840 if (exists $loadHash{'standard_winmap_hash'}) {
14841  
14842 $subHashRef = $loadHash{'standard_winmap_hash'};
14843 foreach my $key (keys %$subHashRef) {
14844  
14845 # If the winmap is missing from GA::Client->winmapHash (for some reason),
14846 # don't let it be added to GA::Client->standardWinmapHash
14847 if (exists $$hashRef{$key}) {
14848  
14849 $$subHashRef{$key} = $$hashRef{$key};
14850 }
14851 }
14852  
14853 $loadHash{'standard_winmap_hash'} = $subHashRef;
14854 }
14855  
14856 if (exists $loadHash{'colour_scheme_hash'}) {
14857  
14858 $hashRef = $loadHash{'colour_scheme_hash'};
14859 foreach my $key (keys %$hashRef) {
14860  
14861 $$hashRef{$key} = $self->update_obj_colourscheme($$hashRef{$key});
14862 }
14863  
14864 $loadHash{'colour_scheme_hash'} = $hashRef;
14865 }
14866  
14867 } elsif ($self->fileType eq 'tts') {
14868  
14869 if (exists $loadHash{'tts_obj_hash'}) {
14870  
14871 $hashRef = $loadHash{'tts_obj_hash'};
14872 foreach my $key (keys %$hashRef) {
14873  
14874 $$hashRef{$key} = $self->update_obj_tts($$hashRef{$key});
14875 }
14876  
14877 $loadHash{'tts_obj_hash'} = $hashRef;
14878 }
14879 }
14880  
14881 # Mark this data file as needing to be saved, whether the data it contains has actually been
14882 # updated or not
14883 $self->ivPoke('modifyFlag', TRUE);
14884  
14885 return %loadHash;
14886 }
14887  
14888 sub update_cage_all {
14889  
14890 # Called by $self->updateDataAfterRename
14891 # Converts AMud::Templ::XXX > Games::Axmud::Cage::XXX
14892 # Converts AMud::MaskTempl::XXX > Games::Axmud::CageMask::XXX
14893  
14894 my ($self, $obj) = @_;
14895  
14896 # Local variables
14897 my ($class, $flag, $hashRef);
14898  
14899 # (no improper arguments to check)
14900  
14901 # Update class
14902 $class = ref $obj;
14903 if ($class =~ m/^AMud\:\:Templ\:\:/) {
14904  
14905 $class =~ s/^AMud\:\:Templ/Games::Axmud::Cage/;
14906 $flag = TRUE;
14907  
14908 } elsif ($class =~ m/^AMud\:\:MaskTempl\:\:/) {
14909  
14910 $class =~ s/^AMud\:\:MaskTempl/Games::Axmud::CageMask/;
14911 $flag = TRUE;
14912 }
14913  
14914 # Updated ->_objName
14915 $obj->{_objName} = $obj->{_name};
14916 delete $obj->{_name};
14917  
14918 if ($flag) {
14919  
14920 bless $obj, $class;
14921 $obj->{_objClass} = $class;
14922  
14923 $obj->{_objName} = $obj->{_name};
14924 delete $obj->{_name};
14925  
14926 # (->_parentFile is 'otherprof')
14927 if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') {
14928  
14929 $obj->{_parentFile} = 'otherprof';
14930 }
14931  
14932 # Update IVs
14933 if ($class =~ m/Route$/) {
14934  
14935 $hashRef = $obj->{routeHash};
14936 foreach my $key (keys %$hashRef) {
14937  
14938 $$hashRef{$key} = $self->update_obj_route($$hashRef{$key});
14939 }
14940  
14941 $obj->{routeHash} = $hashRef;
14942  
14943 } elsif ($class =~ m/(Trigger|Alias|Macro|Timer|Hook)$/) {
14944  
14945 $hashRef = $obj->{interfaceHash};
14946 foreach my $key (keys %$hashRef) {
14947  
14948 $$hashRef{$key} = $self->update_interface_all($$hashRef{$key});
14949 }
14950  
14951 $obj->{interfaceHash} = $hashRef;
14952 }
14953  
14954 $obj->{cageType} = $obj->{templType};
14955 delete $obj->{templType};
14956  
14957 $obj->{profName} = $obj->{defnName};
14958 delete $obj->{defnName};
14959  
14960 $obj->{profCategory} = $obj->{defnCategory};
14961 delete $obj->{defnCategory};
14962  
14963 # Update @ISA
14964 if ($class =~ m/(Cmd|Route)$/) {
14965  
14966 @obj::ISA = qw(Games::Axmud::Generic::Cage Games::Axmud);
14967  
14968 } else {
14969  
14970 @obj::ISA = qw(
14971 Games::Axmud::Generic::InterfaceCage Games::Axmud::Generic::Cage
14972 Games::Axmud
14973 );
14974 }
14975 }
14976  
14977 return $obj;
14978 }
14979  
14980 sub update_interface_all {
14981  
14982 # Called by $self->updateDataAfterRename
14983 # Converts AMud::Interface::XXX > Games::Axmud::Interface:::XXX
14984  
14985 my ($self, $obj) = @_;
14986  
14987 # Local variables
14988 my $class;
14989  
14990 # (no improper arguments to check)
14991  
14992 # Update class
14993 $class = ref $obj;
14994 if ($class =~ m/^AMud\:\:Interface\:\:/) {
14995  
14996 $class =~ s/^AMud/Games::Axmud/;
14997 bless $obj, $class;
14998 $obj->{_objClass} = $class;
14999  
15000 $obj->{_objName} = $obj->{_name};
15001 delete $obj->{_name};
15002  
15003 # (->_parentFile is 'undef')
15004  
15005 # Update IVs
15006 $obj->{assocProf} = $obj->{assocDefn};
15007 delete $obj->{assocDefn};
15008  
15009 $obj->{assocProfCategory} = $obj->{assocDefnCategory};
15010 delete $obj->{assocDefnCategory};
15011  
15012 # Update @ISA
15013 @obj::ISA = qw(Games::Axmud::Generic::Interface Games::Axmud);
15014 }
15015  
15016 return $obj;
15017 }
15018  
15019 sub update_modelobj_all {
15020  
15021 # Called by $self->updateDataAfterRename
15022 # Converts AMud::ModelObj::Region > Games::Axmud::ModelObj::Region, etc
15023  
15024 my ($self, $obj) = @_;
15025  
15026 # Local variables
15027 my $class;
15028  
15029 # (no improper arguments to check)
15030  
15031 # Update class
15032 $class = ref $obj;
15033 if ($class =~ m/^AMud\:\:ModelObj\:\:/) {
15034  
15035 $class =~ s/^AMud/Games::Axmud/;
15036 bless $obj, $class;
15037 $obj->{_objClass} = $class;
15038  
15039 $obj->{_objName} = $obj->{_name};
15040 delete $obj->{_name};
15041  
15042 # (->_parentFile is 'undef' or 'worldmodel')
15043  
15044 # (No IVs to update)
15045 # Games::Axmud::ModelObj::Region->regionmapObj is handled by ->update_obj_world_model
15046  
15047 # Update @ISA
15048 @obj::ISA = qw(Games::Axmud);
15049 }
15050  
15051 return $obj;
15052 }
15053  
15054 sub update_obj_chat_contact {
15055  
15056 # Called by $self->updateDataAfterRename
15057 # Converts AMud::Obj::ChatContact > Games::Axmud::Obj::ChatContact
15058  
15059 my ($self, $obj) = @_;
15060  
15061 # Local variables
15062 my $class;
15063  
15064 # (no improper arguments to check)
15065  
15066 # Update class
15067 $class = ref $obj;
15068 if ($class =~ m/^AMud\:\:Obj\:\:ChatContact/) {
15069  
15070 $class =~ s/^AMud/Games::Axmud/;
15071 bless $obj, $class;
15072 $obj->{_objClass} = $class;
15073  
15074 $obj->{_objName} = $obj->{_name};
15075 delete $obj->{_name};
15076  
15077 # (->_parentFile is 'contacts')
15078  
15079 # (No IVs to update)
15080  
15081 # Update @ISA
15082 @obj::ISA = qw(Games::Axmud);
15083 }
15084  
15085 return $obj;
15086 }
15087  
15088 sub update_obj_component {
15089  
15090 # Called by $self->updateDataAfterRename
15091 # Converts AMud::Obj::Component > Games::Axmud::Obj::Component
15092  
15093 my ($self, $obj) = @_;
15094  
15095 # Local variables
15096 my $class;
15097  
15098 # (no improper arguments to check)
15099  
15100 # Update class
15101 $class = ref $obj;
15102 if ($class =~ m/^AMud\:\:Obj\:\:Component/) {
15103  
15104 $class =~ s/^AMud/Games::Axmud/;
15105 bless $obj, $class;
15106 $obj->{_objClass} = $class;
15107  
15108 $obj->{_objName} = $obj->{_name};
15109 delete $obj->{_name};
15110  
15111 # (->_parentFile is world name)
15112  
15113 # (No IVs to update)
15114  
15115 # Update @ISA
15116 @obj::ISA = qw(Games::Axmud);
15117 }
15118  
15119 return $obj;
15120 }
15121  
15122 sub update_obj_colourscheme {
15123  
15124 # Called by $self->updateDataAfterRename
15125 # Converts AMud::Obj::ColourScheme > Games::Axmud::Obj::ColourScheme
15126  
15127 my ($self, $obj) = @_;
15128  
15129 # Local variables
15130 my $class;
15131  
15132 # (no improper arguments to check)
15133  
15134 # Update class
15135 $class = ref $obj;
15136 if ($class =~ m/^AMud\:\:Obj\:\:ColourScheme/) {
15137  
15138 $class =~ s/^AMud/Games::Axmud/;
15139 bless $obj, $class;
15140 $obj->{_objClass} = $class;
15141  
15142 $obj->{_objName} = $obj->{_name};
15143 delete $obj->{_name};
15144  
15145 # (->_parentFile is 'winmaps')
15146  
15147 # (No IVs to update)
15148  
15149 # Update @ISA
15150 @obj::ISA = qw(Games::Axmud);
15151 }
15152  
15153 return $obj;
15154 }
15155  
15156 sub update_obj_dict {
15157  
15158 # Called by $self->updateDataAfterRename (and also by GA::Client->copyPreConfigWorlds)
15159 # Converts AMud::Obj::Dict > Games::Axmud::Obj::Dict
15160  
15161 my ($self, $obj) = @_;
15162  
15163 # Local variables
15164 my $class;
15165  
15166 # (no improper arguments to check)
15167  
15168 # Update class
15169 $class = ref $obj;
15170 if ($class =~ m/^AMud\:\:Obj\:\:Dict/) {
15171  
15172 $class =~ s/^AMud/Games::Axmud/;
15173 bless $obj, $class;
15174 $obj->{_objClass} = $class;
15175  
15176 $obj->{_objName} = $obj->{_name};
15177 delete $obj->{_name};
15178  
15179 # (->_parentFile is 'dicts')
15180  
15181 # (No IVs to update)
15182  
15183 # Update @ISA
15184 @obj::ISA = qw(Games::Axmud);
15185 }
15186  
15187 return $obj;
15188 }
15189  
15190 sub update_obj_exit {
15191  
15192 # Called by $self->updateDataAfterRename
15193 # Converts AMud::Obj::Exit > Games::Axmud::Obj::Exit
15194  
15195 my ($self, $obj) = @_;
15196  
15197 # Local variables
15198 my $class;
15199  
15200 # (no improper arguments to check)
15201  
15202 # Update class
15203 $class = ref $obj;
15204 if ($class =~ m/^AMud\:\:Obj\:\:Exit/) {
15205  
15206 $class =~ s/^AMud/Games::Axmud/;
15207 bless $obj, $class;
15208 $obj->{_objClass} = $class;
15209  
15210 $obj->{_objName} = $obj->{_name};
15211 delete $obj->{_name};
15212  
15213 # (->_parentFile is 'undef' or 'worldmodel')
15214  
15215 # (No IVs to update)
15216  
15217 # Update @ISA
15218 @obj::ISA = qw(Games::Axmud);
15219 }
15220  
15221 return $obj;
15222 }
15223  
15224 sub update_obj_maplabel {
15225  
15226 # Called by $self->updateDataAfterRename
15227 # Converts AMud::Obj::MapLabel > Games::Axmud::Obj::MapLabel
15228  
15229 my ($self, $obj) = @_;
15230  
15231 # Local variables
15232 my $class;
15233  
15234 # (no improper arguments to check)
15235  
15236 # Update class
15237 $class = ref $obj;
15238 if ($class =~ m/^AMud\:\:Obj\:\:MapLabel/) {
15239  
15240 $class =~ s/^AMud/Games::Axmud/;
15241 bless $obj, $class;
15242 $obj->{_objClass} = $class;
15243  
15244 $obj->{_objName} = $obj->{_name};
15245 delete $obj->{_name};
15246  
15247 # (->_parentFile is 'worldmodel')
15248  
15249 # (No IVs to update)
15250  
15251 # Update @ISA
15252 @obj::ISA = qw(Games::Axmud);
15253 }
15254  
15255 return $obj;
15256 }
15257  
15258 sub update_obj_mission {
15259  
15260 # Called by $self->updateDataAfterRename
15261 # Converts AMud::Obj::Mission > Games::Axmud::Obj::Mission
15262  
15263 my ($self, $obj) = @_;
15264  
15265 # Local variables
15266 my $class;
15267  
15268 # (no improper arguments to check)
15269  
15270 # Update class
15271 $class = ref $obj;
15272 if ($class =~ m/^AMud\:\:Obj\:\:Mission/) {
15273  
15274 $class =~ s/^AMud/Games::Axmud/;
15275 bless $obj, $class;
15276 $obj->{_objClass} = $class;
15277  
15278 $obj->{_objName} = $obj->{_name};
15279 delete $obj->{_name};
15280  
15281 # (->_parentFile is world name)
15282  
15283 # (No IVs to update)
15284  
15285 # Update @ISA
15286 @obj::ISA = qw(Games::Axmud);
15287 }
15288  
15289 return $obj;
15290 }
15291  
15292 sub update_obj_monitor {
15293  
15294 # Called by $self->updateDataAfterRename
15295 # Converts AMud::Obj::Monitor > Games::Axmud::Obj::Monitor
15296  
15297 my ($self, $obj) = @_;
15298  
15299 # Local variables
15300 my $class;
15301  
15302 # (no improper arguments to check)
15303  
15304 # Update class
15305 $class = ref $obj;
15306 if ($class =~ m/^AMud\:\:Obj\:\:Monitor/) {
15307  
15308 $class =~ s/^AMud/Games::Axmud/;
15309 bless $obj, $class;
15310 $obj->{_objClass} = $class;
15311  
15312 $obj->{_objName} = $obj->{_name};
15313 delete $obj->{_name};
15314  
15315 # (->_parentFile is 'otherprof')
15316 if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') {
15317  
15318 $obj->{_parentFile} = 'otherprof';
15319 }
15320  
15321 # (No IVs to update)
15322  
15323 # Update @ISA
15324 @obj::ISA = qw(Games::Axmud);
15325 }
15326  
15327 return $obj;
15328 }
15329  
15330 sub update_obj_protect {
15331  
15332 # Called by $self->updateDataAfterRename
15333 # Converts AMud::Obj::Protect > Games::Axmud::Obj::Protect
15334  
15335 my ($self, $obj) = @_;
15336  
15337 # Local variables
15338 my $class;
15339  
15340 # (no improper arguments to check)
15341  
15342 # Update class
15343 $class = ref $obj;
15344 if ($class =~ m/^AMud\:\:Obj\:\:Protect/) {
15345  
15346 $class =~ s/^AMud/Games::Axmud/;
15347 bless $obj, $class;
15348 $obj->{_objClass} = $class;
15349  
15350 $obj->{_objName} = $obj->{_name};
15351 delete $obj->{_name};
15352  
15353 # (->_parentFile is 'otherprof')
15354 if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') {
15355  
15356 $obj->{_parentFile} = 'otherprof';
15357 }
15358  
15359 # (No IVs to update)
15360  
15361 # Update @ISA
15362 @obj::ISA = qw(Games::Axmud);
15363 }
15364  
15365 return $obj;
15366 }
15367  
15368 sub update_obj_quest {
15369  
15370 # Called by $self->updateDataAfterRename
15371 # Converts AMud::Obj::Quest > Games::Axmud::Obj::Quest
15372  
15373 my ($self, $obj) = @_;
15374  
15375 # Local variables
15376 my $class;
15377  
15378 # (no improper arguments to check)
15379  
15380 # Update class
15381 $class = ref $obj;
15382 if ($class =~ m/^AMud\:\:Obj\:\:Quest/) {
15383  
15384 $class =~ s/^AMud/Games::Axmud/;
15385 bless $obj, $class;
15386 $obj->{_objClass} = $class;
15387  
15388 $obj->{_objName} = $obj->{_name};
15389 delete $obj->{_name};
15390  
15391 # (->_parentFile is world name)
15392  
15393 # (No IVs to update)
15394  
15395 # Update @ISA
15396 @obj::ISA = qw(Games::Axmud);
15397 }
15398  
15399 return $obj;
15400 }
15401  
15402 sub update_obj_regionmap {
15403  
15404 # Called by $self->updateDataAfterRename
15405 # Converts AMud::Obj::Regionmap > Games::Axmud::Obj::Regionmap
15406  
15407 my ($self, $obj) = @_;
15408  
15409 # Local variables
15410 my ($class, $hashRef, $pathHashRef);
15411  
15412 # (no improper arguments to check)
15413  
15414 # Update class
15415 $class = ref $obj;
15416 if ($class =~ m/^AMud\:\:Obj\:\:Regionmap/) {
15417  
15418 $class =~ s/^AMud/Games::Axmud/;
15419 bless $obj, $class;
15420 $obj->{_objClass} = $class;
15421  
15422 $obj->{_objName} = $obj->{_name};
15423 delete $obj->{_name};
15424  
15425 # (->_parentFile is 'worldmodel')
15426  
15427 # Update IVs
15428 $hashRef = $obj->{gridLabelHash};
15429 foreach my $key (keys %$hashRef) {
15430  
15431 $$hashRef{$key} = $self->update_obj_maplabel($$hashRef{$key});
15432 }
15433  
15434 $obj->{gridLabelHash} = $hashRef;
15435  
15436 $pathHashRef = $obj->{regionPathHash};
15437 foreach my $key (keys %$pathHashRef) {
15438  
15439 $$pathHashRef{$key} = $self->update_obj_regionpath($$pathHashRef{$key});
15440 }
15441  
15442 $obj->{regionPathHash} = $pathHashRef;
15443  
15444 $hashRef = $obj->{safeRegionPathHash};
15445 foreach my $key (keys %$hashRef) {
15446  
15447 $$hashRef{$key} = $$pathHashRef{$key};
15448 }
15449  
15450 $obj->{safeRegionPathHash} = $pathHashRef;
15451  
15452 # Update @ISA
15453 @obj::ISA = qw(Games::Axmud);
15454 }
15455  
15456 return $obj;
15457 }
15458  
15459 sub update_obj_regionpath {
15460  
15461 # Called by $self->updateDataAfterRename
15462 # Converts AMud::Obj::RegionPath > Games::Axmud::Obj::RegionPath
15463  
15464 my ($self, $obj) = @_;
15465  
15466 # Local variables
15467 my $class;
15468  
15469 # (no improper arguments to check)
15470  
15471 # Update class
15472 $class = ref $obj;
15473 if ($class =~ m/^AMud\:\:Obj\:\:RegionPath/) {
15474  
15475 $class =~ s/^AMud/Games::Axmud/;
15476 bless $obj, $class;
15477 $obj->{_objClass} = $class;
15478  
15479 $obj->{_objName} = $obj->{_name};
15480 delete $obj->{_name};
15481  
15482 # (->_parentFile is 'worldmodel')
15483  
15484 # (No IVs to update)
15485  
15486 # Update @ISA
15487 @obj::ISA = qw(Games::Axmud);
15488 }
15489  
15490 return $obj;
15491 }
15492  
15493 sub update_obj_route {
15494  
15495 # Called by $self->updateDataAfterRename
15496 # Converts AMud::Obj::Route > Games::Axmud::Obj::Route
15497  
15498 my ($self, $obj) = @_;
15499  
15500 # Local variables
15501 my $class;
15502  
15503 # (no improper arguments to check)
15504  
15505 # Update class
15506 $class = ref $obj;
15507 if ($class =~ m/^AMud\:\:Obj\:\:Route/) {
15508  
15509 $class =~ s/^AMud/Games::Axmud/;
15510 bless $obj, $class;
15511 $obj->{_objClass} = $class;
15512  
15513 $obj->{_objName} = $obj->{_name};
15514 delete $obj->{_name};
15515  
15516 # (->_parentFile is 'otherprof')
15517 if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') {
15518  
15519 $obj->{_parentFile} = 'otherprof';
15520 }
15521  
15522 # (No IVs to update)
15523  
15524 # Update @ISA
15525 @obj::ISA = qw(Games::Axmud);
15526 }
15527  
15528 return $obj;
15529 }
15530  
15531 sub update_obj_skillhistory {
15532  
15533 # Called by $self->updateDataAfterRename
15534 # Converts AMud::Obj::SkillHistory > Games::Axmud::Obj::SkillHistory
15535  
15536 my ($self, $obj) = @_;
15537  
15538 # Local variables
15539 my $class;
15540  
15541 # (no improper arguments to check)
15542  
15543 # Update class
15544 $class = ref $obj;
15545 if ($class =~ m/^AMud\:\:Obj\:\:SkillHistory/) {
15546  
15547 $class =~ s/^AMud/Games::Axmud/;
15548 bless $obj, $class;
15549 $obj->{_objClass} = $class;
15550  
15551 $obj->{_objName} = $obj->{_name};
15552 delete $obj->{_name};
15553  
15554 # (->_parentFile is 'otherprof')
15555 if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') {
15556  
15557 $obj->{_parentFile} = 'otherprof';
15558 }
15559  
15560 # (No IVs to update)
15561  
15562 # Update @ISA
15563 @obj::ISA = qw(Games::Axmud);
15564 }
15565  
15566 return $obj;
15567 }
15568  
15569 sub update_obj_toolbar {
15570  
15571 # Called by $self->updateDataAfterRename
15572 # Converts AMud::Obj::Toolbar > Games::Axmud::Obj::Toolbar
15573  
15574 my ($self, $obj) = @_;
15575  
15576 # Local variables
15577 my ($class, $instruct);
15578  
15579 # (no improper arguments to check)
15580  
15581 # Update class
15582 $class = ref $obj;
15583 if ($class =~ m/^AMud\:\:Obj\:\:Toolbar/) {
15584  
15585 $class =~ s/^AMud/Games::Axmud/;
15586 bless $obj, $class;
15587 $obj->{_objClass} = $class;
15588  
15589 $obj->{_objName} = $obj->{_name};
15590 delete $obj->{_name};
15591  
15592 # (->_parentFile is 'toolbar')
15593  
15594 # Update IVs. Many ->instruct values are client commands; convert any client commands
15595 # that are used with a default Axmud installation
15596 $instruct = $obj->{instruct};
15597 $instruct =~ s/^\;edittemplate\s/;editcage/;
15598 $obj->{instruct} = $instruct;
15599  
15600 # Update @ISA
15601 @obj::ISA = qw(Games::Axmud);
15602 }
15603  
15604 return $obj;
15605 }
15606  
15607 sub update_obj_tts {
15608  
15609 # Called by $self->updateDataAfterRename
15610 # Converts AMud::Obj::Tts > Games::Axmud::Obj::Tts
15611  
15612 my ($self, $obj) = @_;
15613  
15614 # Local variables
15615 my $class;
15616  
15617 # (no improper arguments to check)
15618  
15619 # Update class
15620 $class = ref $obj;
15621 if ($class =~ m/^AMud\:\:Obj\:\:Tts/) {
15622  
15623 $class =~ s/^AMud/Games::Axmud/;
15624 bless $obj, $class;
15625 $obj->{_objClass} = $class;
15626  
15627 $obj->{_objName} = $obj->{_name};
15628 delete $obj->{_name};
15629  
15630 # (->_parentFile is 'tts')
15631  
15632 # (No IVs to update)
15633  
15634 # Update @ISA
15635 @obj::ISA = qw(Games::Axmud);
15636 }
15637  
15638 return $obj;
15639 }
15640  
15641 sub update_obj_winmap {
15642  
15643 # Called by $self->updateDataAfterRename
15644 # Converts AMud::Obj::Winmap > Games::Axmud::Obj::Winmap
15645  
15646 my ($self, $obj) = @_;
15647  
15648 # Local variables
15649 my (
15650 $class, $listRef, $hashRef,
15651 @list,
15652 );
15653  
15654 # (no improper arguments to check)
15655  
15656 # Update class
15657 $class = ref $obj;
15658 if ($class =~ m/^AMud\:\:Obj\:\:Winmap/) {
15659  
15660 $class =~ s/^AMud/Games::Axmud/;
15661 bless $obj, $class;
15662 $obj->{_objClass} = $class;
15663  
15664 $obj->{_objName} = $obj->{_name};
15665 delete $obj->{_name};
15666  
15667 # (->_parentFile is 'winmaps')
15668  
15669 # Update IVs
15670 $hashRef = $obj->{zoneHash};
15671 foreach my $key (keys %$hashRef) {
15672  
15673 $$hashRef{$key} = $self->update_obj_winzone($$hashRef{$key}, $obj);
15674 }
15675  
15676 $obj->{zoneHash} = $hashRef;
15677  
15678 $listRef = $obj->{stripInitList};
15679 if (@$listRef) {
15680  
15681 do {
15682  
15683 my ($string, $hashRef);
15684  
15685 $string = shift @$listRef;
15686 $hashRef = shift @$listRef;
15687  
15688 $string =~ s/^AMud/Games::Axmud/;
15689 push (@list, $string, $hashRef);
15690  
15691 } until (! @$listRef);
15692  
15693 $obj->{stripInitList} = \@list;
15694 }
15695  
15696 # Update @ISA
15697 @obj::ISA = qw(Games::Axmud);
15698 }
15699  
15700 return $obj;
15701 }
15702  
15703 sub update_obj_winzone {
15704  
15705 # Called by $self->updateDataAfterRename
15706 # Converts AMud::Obj::Winzone > Games::Axmud::Obj::Winzone
15707  
15708 my ($self, $obj, $parent) = @_;
15709  
15710 # Local variables
15711 my ($class, $string);
15712  
15713 # (no improper arguments to check)
15714  
15715 # Update class
15716 $class = ref $obj;
15717 if ($class =~ m/^AMud\:\:Obj\:\:Winzone/) {
15718  
15719 $class =~ s/^AMud/Games::Axmud/;
15720 bless $obj, $class;
15721 $obj->{_objClass} = $class;
15722  
15723 $obj->{_objName} = $obj->{_name};
15724 delete $obj->{_name};
15725  
15726 # (->_parentFile is 'winmaps')
15727  
15728 # Update IVs
15729 if (defined $parent) {
15730  
15731 $obj->{winmapObj} = $parent;
15732 }
15733  
15734 if (defined $obj->{packageName}) {
15735  
15736 $string = $obj->{packageName};
15737 $string =~ s/^AMud/Games::Axmud/;
15738 $obj->{packageName} = $string;
15739 }
15740  
15741 # Update @ISA
15742 @obj::ISA = qw(Games::Axmud);
15743 }
15744  
15745 return $obj;
15746 }
15747  
15748 sub update_obj_world_model {
15749  
15750 # Called by $self->updateDataAfterRename
15751 # Converts AMud::Obj::WorldModel > Games::Axmud::Obj::WorldModel
15752  
15753 my ($self, $obj) = @_;
15754  
15755 # Local variables
15756 my ($class, $flag, $hashRef, $modelHashRef, $mapHashRef);
15757  
15758 # (no improper arguments to check)
15759  
15760 # Update class
15761 $class = ref $obj;
15762 if ($class =~ m/^AMud:\:WorldModel/) {
15763  
15764 $class =~ s/^AMud/Games::Axmud::Obj/;
15765 $flag = TRUE;
15766  
15767 } elsif ($class =~ m/^AMud\:\:Obj\:\:WorldModel/) {
15768  
15769 $class =~ s/^AMud/Games::Axmud/;
15770 $flag = TRUE;
15771 }
15772  
15773 if ($flag) {
15774  
15775 bless $obj, $class;
15776 $obj->{_objClass} = $class;
15777  
15778 $obj->{_objName} = $obj->{_name};
15779 delete $obj->{_name};
15780  
15781 # (->_parentFile is 'worldmodel')
15782  
15783 # Update IVs
15784 $modelHashRef = $obj->{model};
15785 foreach my $key (keys %$modelHashRef) {
15786  
15787 $$modelHashRef{$key} = $self->update_modelobj_all($$modelHashRef{$key});
15788 }
15789  
15790 $obj->{model} = $modelHashRef;
15791  
15792 my @ivList = qw(
15793 regionModel roomModel weaponModel armourModel garmentModel charModel minionModel
15794 sentientModel creatureModel portableModel decorationModel customModel
15795 );
15796  
15797 foreach my $iv (@ivList) {
15798  
15799 my $subHashRef = $obj->{$iv};
15800 foreach my $key (keys %$subHashRef) {
15801  
15802 $$subHashRef{$key} = $$modelHashRef{$key};
15803 }
15804  
15805 $obj->{$iv} = $subHashRef;
15806 }
15807  
15808 $hashRef = $obj->{exitModel};
15809 foreach my $key (keys %$hashRef) {
15810  
15811 $$hashRef{$key} = $self->update_obj_exit($$hashRef{$key});
15812 }
15813  
15814 $obj->{exitModel} = $hashRef;
15815  
15816 $mapHashRef = $obj->{regionmapHash};
15817 foreach my $key (keys %$mapHashRef) {
15818  
15819 $$mapHashRef{$key} = $self->update_obj_regionmap($$mapHashRef{$key});
15820 }
15821  
15822 $obj->{regionmapHash} = $mapHashRef;
15823  
15824 # (We can now do Games::Axmud::ModelObj::Room->regionmapObj)
15825 $hashRef = $obj->{regionModel};
15826 foreach my $thisObj (values %$hashRef) {
15827  
15828 $thisObj->{regionmapObj} = $$mapHashRef{$thisObj->{name}};
15829 }
15830  
15831 $hashRef = $obj->{knownCharHash};
15832 foreach my $key (keys %$hashRef) {
15833  
15834 my $oldObj = $$hashRef{$key};
15835  
15836 $$hashRef{$key} = $$modelHashRef{$oldObj->{number}};
15837 }
15838  
15839 $obj->{knownCharHash} = $hashRef;
15840  
15841 $hashRef = $obj->{minionStringHash};
15842 foreach my $key (keys %$hashRef) {
15843  
15844 my $oldObj = $$hashRef{$key};
15845  
15846 # Values in this hash can be model or non-model objects
15847 if (defined $oldObj->{number}) {
15848  
15849 # Model object
15850 $$hashRef{$key} = $$modelHashRef{$oldObj->{number}};
15851  
15852 } else {
15853  
15854 # Non-model object
15855 $$hashRef{$key} = $self->update_modelobj_all($oldObj);
15856 }
15857 }
15858  
15859 $obj->{minionStringHash} = $hashRef;
15860  
15861 # Update @ISA
15862 @obj::ISA = qw(Games::Axmud);
15863 }
15864  
15865 return $obj;
15866 }
15867  
15868 sub update_obj_zone_model {
15869  
15870 # Called by $self->updateDataAfterRename
15871 # Converts AMud::Obj::ZoneModel > Games::Axmud::Obj::ZoneModel
15872  
15873 my ($self, $obj, $parent) = @_;
15874  
15875 # Local variables
15876 my $class;
15877  
15878 # (no improper arguments to check)
15879  
15880 # Update class
15881 $class = ref $obj;
15882 if ($class =~ m/^AMud\:\:Obj\:\:ZoneModel/) {
15883  
15884 $class =~ s/^AMud/Games::Axmud/;
15885 bless $obj, $class;
15886 $obj->{_objClass} = $class;
15887  
15888 $obj->{_objName} = $obj->{_name};
15889 delete $obj->{_name};
15890  
15891 # (->_parentFile is 'zonemaps')
15892  
15893 # Update IVs
15894 if (defined $parent) {
15895  
15896 $obj->{zonemapObj} = $parent;
15897 }
15898 }
15899  
15900 # Update @ISA
15901 @obj::ISA = qw(Games::Axmud);
15902  
15903 return $obj;
15904 }
15905  
15906 sub update_obj_zonemap {
15907  
15908 # Called by $self->updateDataAfterRename
15909 # Converts AMud::Obj::Zonemap > Games::Axmud::Obj::Zonemap
15910  
15911 my ($self, $obj) = @_;
15912  
15913 # Local variables
15914 my ($class, $hashRef);
15915  
15916 # (no improper arguments to check)
15917  
15918 # Update class
15919 $class = ref $obj;
15920 if ($class =~ m/^AMud\:\:Obj\:\:Zonemap/) {
15921  
15922 $class =~ s/^AMud/Games::Axmud/;
15923 bless $obj, $class;
15924 $obj->{_objClass} = $class;
15925  
15926 $obj->{_objName} = $obj->{_name};
15927 delete $obj->{_name};
15928  
15929 # (->_parentFile is 'zonemaps')
15930  
15931 # Update IVs
15932 $hashRef = $obj->{modelHash};
15933 foreach my $key (keys %$hashRef) {
15934  
15935 $$hashRef{$key} = $self->update_obj_zone_model($$hashRef{$key}, $obj);
15936 }
15937  
15938 $obj->{modelHash} = $hashRef;
15939  
15940 # Just to be safe
15941 $obj->{tempSession} = undef;
15942  
15943 # Update @ISA
15944 @obj::ISA = qw(Games::Axmud);
15945 }
15946  
15947 return $obj;
15948 }
15949  
15950 sub update_profile_world {
15951  
15952 # Called by $self->updateDataAfterRename
15953 # Converts Converts AMud::Defn::World > Games::Axmud::Profile::World
15954  
15955 my ($self, $obj) = @_;
15956  
15957 # Local variables
15958 my ($class, $hashRef);
15959  
15960 # (no improper arguments to check)
15961  
15962 # Update class
15963 $class = ref $obj;
15964 if ($class =~ m/^AMud\:\:Defn\:\:World/) {
15965  
15966 $class =~ s/^AMud\:\:Defn/Games::Axmud::Profile/;
15967 bless $obj, $class;
15968 $obj->{_objClass} = $class;
15969  
15970 $obj->{_objName} = $obj->{_name};
15971 delete $obj->{_name};
15972  
15973 # (->_parentFile is world name)
15974  
15975 # Update IVs
15976 $hashRef = $obj->{initTaskHash};
15977 foreach my $key (keys %$hashRef) {
15978  
15979 $$hashRef{$key} = $self->update_task_all($$hashRef{$key});
15980 }
15981  
15982 $obj->{initTaskHash} = $hashRef;
15983  
15984 $hashRef = $obj->{missionHash};
15985 foreach my $key (keys %$hashRef) {
15986  
15987 $$hashRef{$key} = $self->update_obj_mission($$hashRef{$key});
15988 }
15989  
15990 $obj->{missionHash} = $hashRef;
15991  
15992 $hashRef = $obj->{questHash};
15993 foreach my $key (keys %$hashRef) {
15994  
15995 $$hashRef{$key} = $self->update_obj_quest($$hashRef{$key});
15996 }
15997  
15998 $obj->{questHash} = $hashRef;
15999  
16000 $hashRef = $obj->{componentHash};
16001 foreach my $key (keys %$hashRef) {
16002  
16003 $$hashRef{$key} = $self->update_obj_component($$hashRef{$key});
16004 }
16005  
16006 $obj->{componentHash} = $hashRef;
16007  
16008 $obj->{profName} = $obj->{defnName};
16009 delete $obj->{defnName};
16010  
16011 $obj->{profCategory} = $obj->{defnCategory};
16012 delete $obj->{defnCategory};
16013  
16014 $obj->{profSensitivityFlag} = $obj->{defnSensitivityFlag};
16015 delete $obj->{defnSensitivityFlag};
16016  
16017 $obj->{profHash} = $obj->{defnHash};
16018 delete $obj->{defnHash};
16019  
16020 # Update @ISA
16021 @obj::ISA = qw(Games::Axmud::Generic::Profile Games::Axmud);
16022 }
16023  
16024 return $obj;
16025 }
16026  
16027 sub update_profile_other {
16028  
16029 # Called by $self->updateDataAfterRename
16030 # Converts AMud::Defn::XXX > Games::Axmud::Profile::XXX
16031  
16032 my ($self, $obj) = @_;
16033  
16034 # Local variables
16035 my (
16036 $class, $listRef, $hashRef,
16037 @list, @list2, @list3,
16038 );
16039  
16040 # (no improper arguments to check)
16041  
16042 # Update class
16043 $class = ref $obj;
16044 if ($class =~ m/^AMud\:\:Defn\:\:/) {
16045  
16046 $class =~ s/^AMud\:\:Defn/Games::Axmud::Profile/;
16047 bless $obj, $class;
16048 $obj->{_objClass} = $class;
16049  
16050 $obj->{_objName} = $obj->{_name};
16051 delete $obj->{_name};
16052  
16053 # (->_parentFile is 'otherprof')
16054 if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') {
16055  
16056 $obj->{_parentFile} = 'otherprof';
16057 }
16058  
16059 # Update IVs
16060 $hashRef = $obj->{initTaskHash};
16061 foreach my $key (keys %$hashRef) {
16062  
16063 $$hashRef{$key} = $self->update_task_all($$hashRef{$key});
16064 }
16065  
16066 $obj->{initTaskHash} = $hashRef;
16067  
16068 if ($class =~ m/Char$/) {
16069  
16070 $listRef = $obj->{skillHistoryList};
16071 foreach my $thisObj (@$listRef) {
16072  
16073 push (@list, $self->update_obj_skillhistory($thisObj));
16074 }
16075  
16076 $obj->{skillHistoryList} = \@list;
16077  
16078 $listRef = $obj->{protectObjList};
16079 foreach my $thisObj (@$listRef) {
16080  
16081 push (@list2, $self->update_obj_protect($thisObj));
16082 }
16083  
16084 $obj->{protectObjList} = \@list2;
16085  
16086 $listRef = $obj->{monitorObjList};
16087 foreach my $thisObj (@$listRef) {
16088  
16089 push (@list3, $self->update_obj_monitor($thisObj));
16090 }
16091  
16092 $obj->{monitorObjList} = \@list3;
16093 }
16094  
16095 $obj->{profName} = $obj->{defnName};
16096 delete $obj->{defnName};
16097  
16098 $obj->{profCategory} = $obj->{defnCategory};
16099 delete $obj->{defnCategory};
16100  
16101 $obj->{profSensitivityFlag} = $obj->{defnSensitivityFlag};
16102 delete $obj->{defnSensitivityFlag};
16103  
16104 if ($class =~ m/Char$/) {
16105  
16106 $obj->{customProfHash} = $obj->{customDefnHash};
16107 delete $obj->{customDefnHash};
16108 }
16109  
16110 # Update @ISA
16111 @obj::ISA = qw(Games::Axmud::Generic::Profile Games::Axmud);
16112 }
16113  
16114 return $obj;
16115 }
16116  
16117 sub update_profile_template {
16118  
16119 # Called by $self->updateDataAfterRename
16120 # Converts AMud::Defn::Skeleton > Games::Axmud::Profile::Template
16121  
16122 my ($self, $obj) = @_;
16123  
16124 # Local variables
16125 my $class;
16126  
16127 # (no improper arguments to check)
16128  
16129 # Update class
16130 $class = ref $obj;
16131 if ($class =~ m/^AMud\:\:Defn\:\:Skeleton/) {
16132  
16133 $class =~ s/^AMud\:\:Defn\:\:Skeleton/Games::Axmud::Profile::Template/;
16134 bless $obj, $class;
16135 $obj->{_objClass} = $class;
16136  
16137 $obj->{_objName} = $obj->{_name};
16138 delete $obj->{_name};
16139  
16140 # (->_parentFile is 'otherprof')
16141 if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') {
16142  
16143 $obj->{_parentFile} = 'otherprof';
16144 }
16145  
16146 # (No IVs to update)
16147  
16148 # Update @ISA
16149 @obj::ISA = qw(Games::Axmud::Generic::Profile Games::Axmud);
16150 }
16151  
16152 return $obj;
16153 }
16154  
16155 sub update_task_all {
16156  
16157 # Called by $self->updateDataAfterRename
16158 # Converts AMud::Task::XXX > Games::Axmud::Task::XXX
16159  
16160 my ($self, $obj) = @_;
16161  
16162 # Local variables
16163 my $class;
16164  
16165 # (no improper arguments to check)
16166  
16167 # Update class
16168 $class = ref $obj;
16169 if ($class =~ m/^AMud\:\:Task\:\:/) {
16170  
16171 $class =~ s/^AMud/Games::Axmud/;
16172 bless $obj, $class;
16173 $obj->{_objClass} = $class;
16174  
16175 $obj->{_objName} = $obj->{_name};
16176 delete $obj->{_name};
16177  
16178 # (->_parentFile is 'undef')
16179  
16180 # Update IVs
16181 if (exists $obj->{ttsProfile}) {
16182  
16183 $obj->{ttsConfig} = $obj->{ttsProfile};
16184 delete $obj->{ttsProfile};
16185 }
16186  
16187 if ($obj->{name} eq 'notepad_task') {
16188  
16189 $obj->{profNoteHash} = $obj->{defnNoteHash};
16190 delete $obj->{defnNoteHash};
16191 }
16192  
16193 # Update @ISA
16194 @obj::ISA = qw(Games::Axmud::Generic::Task Games::Axmud);
16195 }
16196  
16197 return $obj;
16198 }
16199  
16200 ##################
16201 # Accessors - set
16202  
16203 sub set_modifyFlag {
16204  
16205 # NB The calling function, $func, is disregarded if specified
16206  
16207 my ($self, $flag, $func, $check) = @_;
16208  
16209 # Check for improper arguments
16210 if (! defined $flag || defined $check) {
16211  
16212 return $axmud::CLIENT->writeImproper($self->_objClass . '->set_modifyFlag', @_);
16213 }
16214  
16215 if ($flag) {
16216 $self->{modifyFlag} = TRUE;
16217 } else {
16218 $self->{modifyFlag} = FALSE;
16219 }
16220  
16221 return $self->modifyFlag;
16222 }
16223  
16224 sub set_preserveBackupFlag {
16225  
16226 # NB The calling function, $func, is disregarded if specified
16227  
16228 my ($self, $flag, $func, $check) = @_;
16229  
16230 # Check for improper arguments
16231 if (! defined $flag || defined $check) {
16232  
16233 return $axmud::CLIENT->writeImproper($self->_objClass . '->set_preserveBackupFlag', @_);
16234 }
16235  
16236 if ($flag) {
16237 $self->{preserveBackupFlag} = TRUE;
16238 } else {
16239 $self->{preserveBackupFlag} = FALSE;
16240 }
16241  
16242 return $self->preserveBackupFlag;
16243 }
16244  
16245 ##################
16246 # Accessors - get
16247  
16248 sub session
16249 { $_[0]->{session} }
16250  
16251 sub name
16252 { $_[0]->{name} }
16253  
16254 sub fileType
16255 { $_[0]->{fileType} }
16256 sub scriptName
16257 { $_[0]->{scriptName} }
16258 sub scriptVersion
16259 { $_[0]->{scriptVersion} }
16260 sub scriptConvertVersion
16261 { $_[0]->{scriptConvertVersion} }
16262 sub saveDate
16263 { $_[0]->{saveDate} }
16264 sub saveTime
16265 { $_[0]->{saveTime} }
16266 sub assocWorldProf
16267 { $_[0]->{assocWorldProf} }
16268  
16269 sub actualFileName
16270 { $_[0]->{actualFileName} }
16271 sub actualPath
16272 { $_[0]->{actualPath} }
16273 sub actualDir
16274 { $_[0]->{actualDir} }
16275  
16276 sub standardFileName
16277 { $_[0]->{standardFileName} }
16278 sub standardPath
16279 { $_[0]->{standardPath} }
16280 sub standardDir
16281 { $_[0]->{standardDir} }
16282  
16283 sub altFileName
16284 { $_[0]->{altFileName} }
16285 sub altPath
16286 { $_[0]->{altPath} }
16287  
16288 sub modifyFlag
16289 { $_[0]->{modifyFlag} }
16290 sub preserveBackupFlag
16291 { $_[0]->{preserveBackupFlag} }
16292 }
16293  
16294 # Package must return a true value
16295 1