| 1 | # Copyright (C) 2011-2024 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 | '# \'Config\' windows have visible index', | ||
| 794 | $self->convert($client->configWinIndexFlag), | ||
| 795 | '# \'Config\' window indexes are simplified', | ||
| 796 | $self->convert($client->configWinSimplifyFlag), | ||
| 797 | '# Size of \'config\' window index', | ||
| 798 | $client->customConfigWinIndexWidth, | ||
| 799 | '# World command colour', | ||
| 800 | $client->customInsertCmdColour, | ||
| 801 | '# System message colour', | ||
| 802 | $client->customShowSystemTextColour, | ||
| 803 | '# System error message colour', | ||
| 804 | $client->customShowErrorColour, | ||
| 805 | '# System warning message colour', | ||
| 806 | $client->customShowWarningColour, | ||
| 807 | '# System debug message colour', | ||
| 808 | $client->customShowDebugColour, | ||
| 809 | '# System improper message colour', | ||
| 810 | $client->customShowImproperColour, | ||
| 811 | '# Convert invisible text flag', | ||
| 812 | $self->convert($client->convertInvisibleFlag), | ||
| 813 | '# Custom text buffer size', | ||
| 814 | $client->customTextBufferSize, | ||
| 815 | '# Custom panel left size', | ||
| 816 | $client->customPanelLeftSize, | ||
| 817 | '# Custom panel right size', | ||
| 818 | $client->customPanelRightSize, | ||
| 819 | '# Custom panel top size', | ||
| 820 | $client->customPanelTopSize, | ||
| 821 | '# Custom panel bottom size', | ||
| 822 | $client->customPanelBottomSize, | ||
| 823 | '# Custom window controls left size', | ||
| 824 | $client->customControlsLeftSize, | ||
| 825 | '# Custom window controls right size', | ||
| 826 | $client->customControlsRightSize, | ||
| 827 | '# Custom window controls top size', | ||
| 828 | $client->customControlsTopSize, | ||
| 829 | '# Custom window controls bottom size', | ||
| 830 | $client->customControlsBottomSize, | ||
| 831 | '# On MS Windows, tweak window size/position to compensate for unresolved issues', | ||
| 832 | $client->mswinWinPosnTweakFlag, | ||
| 833 | '# Sessions share a \'main\' window', | ||
| 834 | $self->convert($client->shareMainWinFlag), | ||
| 835 | '# (The setting to use when ' . $axmud::SCRIPT . ' next starts)', | ||
| 836 | $client->restartShareMainWinMode, | ||
| 837 | '# Workspace grids are activated', | ||
| 838 | $self->convert($client->activateGridFlag), | ||
| 839 | '# Store \'grid\' window positions', | ||
| 840 | $self->convert($client->storeGridPosnFlag), | ||
| 841 | ); | ||
| 842 | |||
| 843 | %storeGridHash = $client->storeGridPosnHash; | ||
| 844 | @storeGridList = sort {lc($a) cmp lc($b)} (keys %storeGridHash); | ||
| 845 | |||
| 846 | push (@list, | ||
| 847 | '# Number of stored \'grid\' window positions', | ||
| 848 | scalar @storeGridList, | ||
| 849 | '# Stored \'grid\' window positions', | ||
| 850 | ); | ||
| 851 | |||
| 852 | foreach my $winName (@storeGridList) { | ||
| 853 | |||
| 854 | my $listRef = $storeGridHash{$winName}; | ||
| 855 | |||
| 856 | # To make the loading code simpler, store 4 values as a line, in the form 'x y wid hei' | ||
| 857 | push (@list, | ||
| 858 | $winName, | ||
| 859 | $$listRef[0] . ' ' . $$listRef[1] . ' ' . $$listRef[2] . ' ' . $$listRef[3] . ' ', | ||
| 860 | ); | ||
| 861 | } | ||
| 862 | |||
| 863 | push (@list, | ||
| 864 | '# Direction of workspace adding', | ||
| 865 | $client->initWorkspaceDir, | ||
| 866 | ); | ||
| 867 | |||
| 868 | %workspaceHash = $client->initWorkspaceHash; | ||
| 869 | @workspaceList = sort {lc($a) cmp lc($b)} (keys %workspaceHash); | ||
| 870 | |||
| 871 | push (@list, | ||
| 872 | '# Number of initial workspaces', | ||
| 873 | scalar @workspaceList, | ||
| 874 | '# Initial workspaces', | ||
| 875 | ); | ||
| 876 | |||
| 877 | foreach my $number (@workspaceList) { | ||
| 878 | |||
| 879 | my $zonemap = $workspaceHash{$number}; | ||
| 880 | |||
| 881 | push (@list, $number, $zonemap); | ||
| 882 | } | ||
| 883 | |||
| 884 | push (@list, | ||
| 885 | '# Gridblock size', | ||
| 886 | $client->gridBlockSize, | ||
| 887 | '# Grid gap max size', | ||
| 888 | $client->gridGapMaxSize, | ||
| 889 | '# Grid adjustment flag', | ||
| 890 | $self->convert($client->gridAdjustmentFlag), | ||
| 891 | '# Grid edge correction flag', | ||
| 892 | $self->convert($client->gridEdgeCorrectionFlag), | ||
| 893 | '# Grid reshuffle flag', | ||
| 894 | $self->convert($client->gridReshuffleFlag), | ||
| 895 | '# Grid invisible windows flag', | ||
| 896 | $self->convert($client->gridInvisWinFlag), | ||
| 897 | '@@@ eos', | ||
| 898 | ); | ||
| 899 | |||
| 900 | # Instructions | ||
| 901 | push (@list, | ||
| 902 | '# INSTRUCTIONS', | ||
| 903 | '# Display buffer size', | ||
| 904 | $client->customDisplayBufferSize, | ||
| 905 | '# Command buffer size', | ||
| 906 | $client->customCmdBufferSize, | ||
| 907 | '# Instruction buffer size', | ||
| 908 | $client->customInstructBufferSize, | ||
| 909 | '# Confirm world commands in \'main\' window', | ||
| 910 | $self->convert($client->confirmWorldCmdFlag), | ||
| 911 | '# Convert single-word world commands to lower case', | ||
| 912 | $self->convert($client->convertWorldCmdFlag), | ||
| 913 | '# Preserve world commands in command entry box', | ||
| 914 | $self->convert($client->preserveWorldCmdFlag), | ||
| 915 | '# Preserve other instructions in command entry box', | ||
| 916 | $self->convert($client->preserveOtherCmdFlag), | ||
| 917 | '# Multi commands apply to all sessions', | ||
| 918 | $self->convert($client->maxMultiCmdFlag), | ||
| 919 | '# Auto-complete mode', | ||
| 920 | $client->autoCompleteMode, | ||
| 921 | '# Auto-complete type', | ||
| 922 | $client->autoCompleteType, | ||
| 923 | '# Auto-complete location', | ||
| 924 | $client->autoCompleteParent, | ||
| 925 | '@@@ eos', | ||
| 926 | ); | ||
| 927 | |||
| 928 | # External applications | ||
| 929 | push (@list, | ||
| 930 | '# EXTERNAL APPLICATIONS', | ||
| 931 | '# Web browser command', | ||
| 932 | $client->browserCmd, | ||
| 933 | '# Audio player command', | ||
| 934 | $client->audioCmd, | ||
| 935 | '# Text editor command', | ||
| 936 | $client->textEditCmd, | ||
| 937 | '@@@ eos', | ||
| 938 | ); | ||
| 939 | |||
| 940 | # Sound effects | ||
| 941 | push (@list, | ||
| 942 | '# SOUND EFFECTS', | ||
| 943 | '# Sound allowed', | ||
| 944 | $self->convert($client->allowSoundFlag), | ||
| 945 | '# ASCII beeps allowed', | ||
| 946 | $self->convert($client->allowAsciiBellFlag), | ||
| 947 | ); | ||
| 948 | |||
| 949 | %itemHash = $client->customSoundHash; | ||
| 950 | @itemList = sort {lc($a) cmp lc($b)} (keys %itemHash); | ||
| 951 | |||
| 952 | push (@list, | ||
| 953 | '# Number of sound effects', | ||
| 954 | scalar @itemList, | ||
| 955 | '# Sound effects', | ||
| 956 | ); | ||
| 957 | |||
| 958 | foreach my $item (@itemList) { | ||
| 959 | |||
| 960 | my $path = $itemHash{$item}; | ||
| 961 | |||
| 962 | push (@list, $item, $path); | ||
| 963 | } | ||
| 964 | |||
| 965 | push (@list, '@@@ eos'); | ||
| 966 | |||
| 967 | # Text-to-speech | ||
| 968 | push (@list, | ||
| 969 | '# TEXT-TO-SPEECH (TTS)', | ||
| 970 | '# TTS allowed for all users', | ||
| 971 | $self->convert($client->customAllowTTSFlag), | ||
| 972 | '# Apply TTS smoothing', | ||
| 973 | $self->convert($client->ttsSmoothFlag), | ||
| 974 | '# Hijack cursor (etc) keys in blind mode', | ||
| 975 | $self->convert($client->ttsHijackFlag), | ||
| 976 | '# Hijack cursor (etc) keys when not in blind mode', | ||
| 977 | $self->convert($client->ttsForceHijackFlag), | ||
| 978 | '# Use TTS for received text', | ||
| 979 | $self->convert($client->ttsReceiveFlag), | ||
| 980 | '# Don\'t use TTS for received text before login (except prompts)', | ||
| 981 | $self->convert($client->ttsLoginFlag), | ||
| 982 | '# Don\'t use TTS for recognised prompts in received text after a login', | ||
| 983 | $self->convert($client->ttsPromptFlag), | ||
| 984 | '# Use TTS for system messages', | ||
| 985 | $self->convert($client->ttsSystemFlag), | ||
| 986 | '# Use TTS for system error messages', | ||
| 987 | $self->convert($client->ttsSystemErrorFlag), | ||
| 988 | '# Use TTS for world commands', | ||
| 989 | $self->convert($client->ttsWorldCmdFlag), | ||
| 990 | '# Use TTS for \'dialogue\' windows', | ||
| 991 | $self->convert($client->ttsDialogueFlag), | ||
| 992 | '# Use TTS for task windows', | ||
| 993 | $self->convert($client->ttsTaskFlag), | ||
| 994 | '# TTS output is verbose', | ||
| 995 | $self->convert($client->ttsVerboseFlag), | ||
| 996 | '# Port for Festival server', | ||
| 997 | $client->ttsFestivalServerPort, | ||
| 998 | '# One-time blind mode introduction message has been shown', | ||
| 999 | $client->blindHelpMsgShownFlag, | ||
| 1000 | '@@@ eos', | ||
| 1001 | ); | ||
| 1002 | |||
| 1003 | # Telnet options/mud protocols | ||
| 1004 | push (@list, | ||
| 1005 | '# TELNET OPTION NEGOTIATION', | ||
| 1006 | '# Use ECHO', | ||
| 1007 | $self->convert($client->useEchoFlag), | ||
| 1008 | '# Use TTYPE', | ||
| 1009 | $self->convert($client->useTTypeFlag), | ||
| 1010 | '# Use NAWS', | ||
| 1011 | $self->convert($client->useNawsFlag), | ||
| 1012 | '# Use CHARSET', | ||
| 1013 | $self->convert($client->useCharSetFlag), | ||
| 1014 | '# Use EOR', | ||
| 1015 | $self->convert($client->useEorFlag), | ||
| 1016 | '# Use SGa', | ||
| 1017 | $self->convert($client->useSgaFlag), | ||
| 1018 | '# Use NEW-ENVIRON', | ||
| 1019 | $self->convert($client->useNewEnvironFlag), | ||
| 1020 | '# MUD PROTOCOLS', | ||
| 1021 | '# Use MCCP', | ||
| 1022 | $self->convert($client->useMccpFlag), | ||
| 1023 | '# Use MSDP', | ||
| 1024 | $self->convert($client->useMsdpFlag), | ||
| 1025 | '# Use MSSP', | ||
| 1026 | $self->convert($client->useMsspFlag), | ||
| 1027 | '# Use MTTS', | ||
| 1028 | $self->convert($client->useMttsFlag), | ||
| 1029 | '# Use MNES', | ||
| 1030 | $self->convert($client->useMnesFlag), | ||
| 1031 | '# Use MXP', | ||
| 1032 | $self->convert($client->useMxpFlag), | ||
| 1033 | '# Use MSP', | ||
| 1034 | $self->convert($client->useMspFlag), | ||
| 1035 | '# Use Pueblo', | ||
| 1036 | $self->convert($client->usePuebloFlag), | ||
| 1037 | '# Use ATCP', | ||
| 1038 | $self->convert($client->useAtcpFlag), | ||
| 1039 | '# Use GMCP', | ||
| 1040 | $self->convert($client->useGmcpFlag), | ||
| 1041 | '# Use ZMP', | ||
| 1042 | $self->convert($client->useZmpFlag), | ||
| 1043 | '# Use AARD102', | ||
| 1044 | $self->convert($client->useAard102Flag), | ||
| 1045 | '# Use MCP', | ||
| 1046 | $self->convert($client->useMcpFlag), | ||
| 1047 | '# MUD PROTOCOL CUSTOMISATION', | ||
| 1048 | '# Allow MXP to change font', | ||
| 1049 | $self->convert($client->allowMxpFontFlag), | ||
| 1050 | '# Allow MXP to display images', | ||
| 1051 | $self->convert($client->allowMxpImageFlag), | ||
| 1052 | '# Allow MXP to download images', | ||
| 1053 | $self->convert($client->allowMxpLoadImageFlag), | ||
| 1054 | '# Allow MXP to use images in world\'s own graphics format', | ||
| 1055 | $self->convert($client->allowMxpFilterImageFlag), | ||
| 1056 | '# Allow MXP to play sound files', | ||
| 1057 | $self->convert($client->allowMxpSoundFlag), | ||
| 1058 | '# Allow MXP to download sound files', | ||
| 1059 | $self->convert($client->allowMxpLoadSoundFlag), | ||
| 1060 | '# Allow MXP to display gauges/status bars', | ||
| 1061 | $self->convert($client->allowMxpGaugeFlag), | ||
| 1062 | '# Allow MXP to use frames', | ||
| 1063 | $self->convert($client->allowMxpFrameFlag), | ||
| 1064 | '# Allow MXP to use internal frames', | ||
| 1065 | $self->convert($client->allowMxpInteriorFlag), | ||
| 1066 | '# Allow MXP to perform crosslinking operations', | ||
| 1067 | $self->convert($client->allowMxpCrosslinkFlag), | ||
| 1068 | '# Allow Locator task to use MXP room data', | ||
| 1069 | $self->convert($client->allowMxpRoomFlag), | ||
| 1070 | '# Allow some illegal MXP keywords (e.g. those using hyphens)', | ||
| 1071 | $self->convert($client->allowMxpFlexibleFlag), | ||
| 1072 | '# Allow MXP to be artificially enabled (for IRE MUDs)', | ||
| 1073 | $self->convert($client->allowMxpPermFlag), | ||
| 1074 | '# Allow MSP to play concurrent sound triggers', | ||
| 1075 | $self->convert($client->allowMspMultipleFlag), | ||
| 1076 | '# Allow MSP to download sound files', | ||
| 1077 | $self->convert($client->allowMspLoadSoundFlag), | ||
| 1078 | '# Allow flexible MSP tag placement (not recommended)', | ||
| 1079 | $self->convert($client->allowMspFlexibleFlag), | ||
| 1080 | '# Allow MNES to send user\'s IP address', | ||
| 1081 | $self->convert($client->allowMnesSendIPFlag), | ||
| 1082 | '# TELNET OPTION NEGOTIATION CUSTOMISATION', | ||
| 1083 | '# Sending termtype mode', | ||
| 1084 | $client->termTypeMode, | ||
| 1085 | '# Customised client name', | ||
| 1086 | $client->customClientName, | ||
| 1087 | '# Customised client version', | ||
| 1088 | $client->customClientVersion, | ||
| 1089 | '# Use VT100 control sequences', | ||
| 1090 | $self->convert($client->useCtrlSeqFlag), | ||
| 1091 | '# Use visible cursor in default textview', | ||
| 1092 | $self->convert($client->useVisibleCursorFlag), | ||
| 1093 | '# Cursor blinks quickly, when visible', | ||
| 1094 | $self->convert($client->useFastCursorFlag), | ||
| 1095 | '# Use direct keyboard input in default textview', | ||
| 1096 | $self->convert($client->useDirectKeysFlag), | ||
| 1097 | '# TELNET OPTION DEBUG FLAGS', | ||
| 1098 | '# Show invalid escape sequence debug messages', | ||
| 1099 | $self->convert($client->debugEscSequenceFlag), | ||
| 1100 | '# Show option negotiation debug messages', | ||
| 1101 | $self->convert($client->debugTelnetFlag), | ||
| 1102 | '# Show option negotiation short debug messages', | ||
| 1103 | $self->convert($client->debugTelnetMiniFlag), | ||
| 1104 | '# Ask GA::Obj::Telnet to write negotiation logfile', | ||
| 1105 | $self->convert($client->debugTelnetLogFlag), | ||
| 1106 | '# Show MSDP debug messages for Status/Locator', | ||
| 1107 | $self->convert($client->debugMsdpFlag), | ||
| 1108 | '# Show debug messages for MXP problems', | ||
| 1109 | $self->convert($client->debugMxpFlag), | ||
| 1110 | '# Show debug messages for MXP comments', | ||
| 1111 | $self->convert($client->debugMxpCommentFlag), | ||
| 1112 | '# Show debug messages for Pueblo problems', | ||
| 1113 | $self->convert($client->debugPuebloFlag), | ||
| 1114 | '# Show debug messages for Pueblo comments', | ||
| 1115 | $self->convert($client->debugPuebloCommentFlag), | ||
| 1116 | '# Show debug messages for incoming ZMP data', | ||
| 1117 | $self->convert($client->debugZmpFlag), | ||
| 1118 | '# Show debug messages for incoming ATCP data', | ||
| 1119 | $self->convert($client->debugAtcpFlag), | ||
| 1120 | '# Show debug messages for incoming GMCP data', | ||
| 1121 | $self->convert($client->debugGmcpFlag), | ||
| 1122 | '# Show debug messages for MCP problems', | ||
| 1123 | $self->convert($client->debugMcpFlag), | ||
| 1124 | '@@@ eos', | ||
| 1125 | ); | ||
| 1126 | |||
| 1127 | # Misc data | ||
| 1128 | push (@list, | ||
| 1129 | '# MISC DATA', | ||
| 1130 | '# Month list', | ||
| 1131 | 12, # Don't bother stating the number of months in a year... | ||
| 1132 | $client->customMonthList, | ||
| 1133 | '# Day list', | ||
| 1134 | 7, # ...or the number of days in a week | ||
| 1135 | $client->customDayList, | ||
| 1136 | '# Number commification mode', | ||
| 1137 | $client->commifyMode, | ||
| 1138 | '# Detect short weblinks', | ||
| 1139 | $self->convert($client->shortUrlFlag), | ||
| 1140 | '# List of IP lookup services', | ||
| 1141 | scalar $client->ipLookupList, | ||
| 1142 | $client->ipLookupList, | ||
| 1143 | '# Prompt wait time (seconds)', | ||
| 1144 | $client->promptWaitTime, | ||
| 1145 | '# Login warning time (seconds)', | ||
| 1146 | $client->loginWarningTime, | ||
| 1147 | '# Show explicit line numbers in \'main\' window', | ||
| 1148 | $self->convert($client->debugLineNumsFlag), | ||
| 1149 | '# Show explicit tags in \'main\' window', | ||
| 1150 | $self->convert($client->debugLineTagsFlag), | ||
| 1151 | '# Show Locator task debug messages', | ||
| 1152 | $self->convert($client->debugLocatorFlag), | ||
| 1153 | '# Show extensive Locator task debug messages', | ||
| 1154 | $self->convert($client->debugMaxLocatorFlag), | ||
| 1155 | '# Show illegal exit direction debug messages', | ||
| 1156 | $self->convert($client->debugExitFlag), | ||
| 1157 | '# Show Locator task expected room statements', | ||
| 1158 | $self->convert($client->debugMoveListFlag), | ||
| 1159 | '# Show object parsing debug messages', | ||
| 1160 | $self->convert($client->debugParseObjFlag), | ||
| 1161 | '# Show object comparison debug messages', | ||
| 1162 | $self->convert($client->debugCompareObjFlag), | ||
| 1163 | '# Show plugin failure debug messages', | ||
| 1164 | $self->convert($client->debugExplainPluginFlag), | ||
| 1165 | '# Show non-existent IV debug messages', | ||
| 1166 | $self->convert($client->debugCheckIVFlag), | ||
| 1167 | '# Show errors when table objects can\'t be added/resized', | ||
| 1168 | $self->convert($client->debugTableFitFlag), | ||
| 1169 | '# Show Perl errors/warnings in \'main\' window', | ||
| 1170 | $self->convert($client->debugTrapErrorFlag), | ||
| 1171 | '# Show toolbar button labels', | ||
| 1172 | $self->convert($client->toolbarLabelFlag), | ||
| 1173 | '# Show irreversible icon in \'edit\' windows', | ||
| 1174 | $self->convert($client->irreversibleIconFlag), | ||
| 1175 | '# Allow popup windows showing the ' . $axmud::SCRIPT . ' logo', | ||
| 1176 | $self->convert($client->allowBusyWinFlag), | ||
| 1177 | '# Allow system messages to be displayed in the \'main\' window', | ||
| 1178 | $self->convert($client->mainWinSystemMsgFlag), | ||
| 1179 | '# Set \'main\' window\'s urgency hint when text received', | ||
| 1180 | $self->convert($client->mainWinUrgencyFlag), | ||
| 1181 | '# Show tooltips in a session\'s default tab', | ||
| 1182 | $self->convert($client->mainWinTooltipFlag), | ||
| 1183 | '# Session tab mode', | ||
| 1184 | $client->sessionTabMode, | ||
| 1185 | '# Use xterm titles', | ||
| 1186 | $self->convert($client->xTermTitleFlag), | ||
| 1187 | '# Use long world names in tab labels', | ||
| 1188 | $self->convert($client->longTabLabelFlag), | ||
| 1189 | '# Don\'t use tab labels when only one session open', | ||
| 1190 | $self->convert($client->simpleTabFlag), | ||
| 1191 | '# Prompt user before closing \'main\' window', | ||
| 1192 | $self->convert($client->confirmCloseMainWinFlag), | ||
| 1193 | '# Prompt user before closing \'main\' window tabs', | ||
| 1194 | $self->convert($client->confirmCloseTabFlag), | ||
| 1195 | '# Prompt user before closing session from the \'main\' window menu', | ||
| 1196 | $self->convert($client->confirmCloseMenuFlag), | ||
| 1197 | '# Prompt user before closing session from the \'main\' window toolbar', | ||
| 1198 | $self->convert($client->confirmCloseToolButtonFlag), | ||
| 1199 | '# Character set', | ||
| 1200 | $client->charSet, | ||
| 1201 | '# Maximum concurrent sessions', | ||
| 1202 | $client->sessionMax, | ||
| 1203 | '# Switch to \'offline\' mode on disconnection', | ||
| 1204 | $self->convert($client->offlineOnDisconnectFlag), | ||
| 1205 | '# Store connection history', | ||
| 1206 | $self->convert($client->connectHistoryFlag), | ||
| 1207 | '# Use page up (etc) to scroll in textviews', | ||
| 1208 | $self->convert($client->useScrollKeysFlag), | ||
| 1209 | '# Page up (etc) doesn\'t scroll the entire page length', | ||
| 1210 | $self->convert($client->smoothScrollKeysFlag), | ||
| 1211 | '# Page up (etc) auto-engages split mode', | ||
| 1212 | $self->convert($client->autoSplitKeysFlag), | ||
| 1213 | '# Use tab/cursor keys to auto-complete commands', | ||
| 1214 | $self->convert($client->useCompleteKeysFlag), | ||
| 1215 | '# Use tab to switch between sessions', | ||
| 1216 | $self->convert($client->useSwitchKeysFlag), | ||
| 1217 | '@@@ eos', | ||
| 1218 | ); | ||
| 1219 | |||
| 1220 | # Prepare footer | ||
| 1221 | push @list, ('@@@ eof'); | ||
| 1222 | |||
| 1223 | # Add newline characters to every entry in @list before writing the whole list to the file | ||
| 1224 | foreach my $item (@list) { | ||
| 1225 | |||
| 1226 | $item .= "\n"; | ||
| 1227 | } | ||
| 1228 | |||
| 1229 | print $fileHandle @list; | ||
| 1230 | |||
| 1231 | # Writing complete | ||
| 1232 | $result = close $fileHandle; | ||
| 1233 | |||
| 1234 | # Precautions taken when an emergency save is NOT in progress... | ||
| 1235 | if (! $emergFlag) { | ||
| 1236 | |||
| 1237 | # Release the lock on the semaphore file | ||
| 1238 | $self->releaseFileLock($semaphoreHandle); | ||
| 1239 | |||
| 1240 | if (! $result) { | ||
| 1241 | |||
| 1242 | # Restore the config file from backup | ||
| 1243 | File::Copy::copy($backupFile, $path); | ||
| 1244 | |||
| 1245 | # Set global flags and display an error message | ||
| 1246 | return $self->disableSaveLoad(FALSE); | ||
| 1247 | |||
| 1248 | } elsif (! $axmud::CLIENT->autoRetainFileFlag) { | ||
| 1249 | |||
| 1250 | # Delete the backup file, unless the user has opted to retain it | ||
| 1251 | unlink ($backupFile); | ||
| 1252 | } | ||
| 1253 | |||
| 1254 | # Save the file's header (metadata) in this object's variables | ||
| 1255 | $self->ivPoke('scriptName', $axmud::NAME_FILE); | ||
| 1256 | $self->ivPoke('scriptVersion', $axmud::VERSION); | ||
| 1257 | $self->ivPoke( | ||
| 1258 | 'scriptConvertVersion', | ||
| 1259 | $axmud::CLIENT->convertVersion($axmud::VERSION), | ||
| 1260 | ); | ||
| 1261 | $self->ivPoke('saveDate', $saveDate); | ||
| 1262 | $self->ivPoke('saveTime', $saveTime); | ||
| 1263 | $self->ivUndef('assocWorldProf'); | ||
| 1264 | |||
| 1265 | $self->ivPoke('actualFileName', $fileName); | ||
| 1266 | $self->ivPoke('actualPath', $path); | ||
| 1267 | $self->ivPoke('actualDir', $dir); | ||
| 1268 | |||
| 1269 | # If Axmud has been ported from MS Windows to Linux (or vice versa), the old config file | ||
| 1270 | # will have been read, and there will now be two. Delete the old one (which we no | ||
| 1271 | # longer need) | ||
| 1272 | if (-e $self->altFileName) { | ||
| 1273 | |||
| 1274 | unlink $self->altFileName; | ||
| 1275 | } | ||
| 1276 | |||
| 1277 | # Mark the file object's data as not needing to be saved | ||
| 1278 | $self->set_modifyFlag(FALSE, $self->_objClass . '->saveConfigFile'); | ||
| 1279 | } | ||
| 1280 | |||
| 1281 | return 1; | ||
| 1282 | } | ||
| 1283 | |||
| 1284 | sub loadConfigFile { | ||
| 1285 | |||
| 1286 | # Called by $self->setupConfigFile for the file types: | ||
| 1287 | # 'config' | ||
| 1288 | # Loads the config file | ||
| 1289 | # | ||
| 1290 | # Expected arguments | ||
| 1291 | # (none besides $self) | ||
| 1292 | # | ||
| 1293 | # Optional arguments | ||
| 1294 | # $fileName - The file name, e.g. 'axmud.conf' | ||
| 1295 | # $path - The full path, e.g. '/home/me/axmud-data/axmud.conf' | ||
| 1296 | # $dir - The directory, e.g. '/home/me/axmud-data/' | ||
| 1297 | # | ||
| 1298 | # Notes: | ||
| 1299 | # If one optional argument is specified, they must all be specified | ||
| 1300 | # If no optional arguments are specified (or are all set to 'undef'), the default | ||
| 1301 | # filename, path and directory for this file type are used | ||
| 1302 | # | ||
| 1303 | # Return values | ||
| 1304 | # 'undef' on improper arguments, or if there are any errors reading the file or in taking | ||
| 1305 | # out a lock on the semaphore file | ||
| 1306 | # 1 otherwise | ||
| 1307 | |||
| 1308 | my ($self, $fileName, $path, $dir, $check) = @_; | ||
| 1309 | |||
| 1310 | # Local variables | ||
| 1311 | my ( | ||
| 1312 | $semaphoreFile, $semaphoreHandle, $fileHandle, $word, $fileType, $headerScriptName, | ||
| 1313 | $headerScriptVersion, $headerSaveDate, $headerSaveTime, $headerAssocWorldProf, $line, | ||
| 1314 | $failFlag, $warningCount, $result, $client, $notCompatFlag, | ||
| 1315 | %dataHash, | ||
| 1316 | ); | ||
| 1317 | |||
| 1318 | # Check for improper arguments | ||
| 1319 | if ( | ||
| 1320 | defined $check | ||
| 1321 | || (defined $fileName && (! defined $path || ! defined $dir)) | ||
| 1322 | || (defined $path && (! defined $fileName || ! defined $dir)) | ||
| 1323 | || (defined $dir && (! defined $fileName || ! defined $path)) | ||
| 1324 | ) { | ||
| 1325 | return $axmud::CLIENT->writeImproper($self->_objClass . '->loadConfigFile', @_); | ||
| 1326 | } | ||
| 1327 | |||
| 1328 | # Check it's the right file type for this function | ||
| 1329 | if ($self->fileType ne 'config') { | ||
| 1330 | |||
| 1331 | return $self->writeError( | ||
| 1332 | 'Wrong file type \'' . $self->fileType . '\'', | ||
| 1333 | $self->_objClass . '->loadConfigFile', | ||
| 1334 | ); | ||
| 1335 | } | ||
| 1336 | |||
| 1337 | # Set the filename, path and directory, if not specified | ||
| 1338 | if (! defined $fileName) { | ||
| 1339 | |||
| 1340 | $fileName = $self->standardFileName; | ||
| 1341 | $path = $axmud::DATA_DIR . $self->standardPath; | ||
| 1342 | $dir = $axmud::DATA_DIR . $self->standardDir; | ||
| 1343 | } | ||
| 1344 | |||
| 1345 | # Don't load anything if the global flags forbid it | ||
| 1346 | if (! $axmud::CLIENT->loadConfigFlag) { | ||
| 1347 | |||
| 1348 | return $self->disableSaveLoad(TRUE); | ||
| 1349 | } | ||
| 1350 | |||
| 1351 | # Check that the data directory exists | ||
| 1352 | if (! (-d $dir)) { | ||
| 1353 | |||
| 1354 | return $self->disableSaveLoad(TRUE); | ||
| 1355 | } | ||
| 1356 | |||
| 1357 | # Check that the specified file exists | ||
| 1358 | if (! (-e $path)) { | ||
| 1359 | |||
| 1360 | # If the alternative file name exists (because an MS Windows config file has been ported | ||
| 1361 | # to Linux, or vice-versa), use that instead | ||
| 1362 | if (-e $self->altFileName) { | ||
| 1363 | |||
| 1364 | $fileName = $self->altFileName; | ||
| 1365 | $path = $axmud::DATA_DIR . $self->altPath; | ||
| 1366 | |||
| 1367 | } else { | ||
| 1368 | |||
| 1369 | # Config file doesn't exist at all | ||
| 1370 | return $self->disableSaveLoad(TRUE); | ||
| 1371 | } | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | # Get a shared lock on the twinned semaphore file | ||
| 1375 | $semaphoreFile = $axmud::DATA_DIR . '/data/temp/config.sem'; | ||
| 1376 | $semaphoreHandle = $self->getFileLock($semaphoreFile, FALSE, $semaphoreFile); | ||
| 1377 | # Don't try to read the config file if no lock could be taken out on the semaphore file | ||
| 1378 | if (! $semaphoreHandle) { | ||
| 1379 | |||
| 1380 | return $self->disableSaveLoad(FALSE); | ||
| 1381 | } | ||
| 1382 | |||
| 1383 | # Open the file for reading | ||
| 1384 | if (! open ($fileHandle, "<$path")) { | ||
| 1385 | |||
| 1386 | # Could not open file | ||
| 1387 | return $self->disableSaveLoad(FALSE); | ||
| 1388 | } | ||
| 1389 | |||
| 1390 | ################# | ||
| 1391 | # Read the header | ||
| 1392 | |||
| 1393 | $failFlag = FALSE; | ||
| 1394 | |||
| 1395 | ($word, $fileType) = $self->readMarker($fileHandle); | ||
| 1396 | if (! defined $word || $word ne 'file_type' || ! $fileType) {$failFlag = TRUE} | ||
| 1397 | |||
| 1398 | ($word, $headerScriptName) = $self->readMarker($fileHandle); | ||
| 1399 | if (! defined $word || $word ne 'script_name' || ! $headerScriptName) {$failFlag = TRUE} | ||
| 1400 | |||
| 1401 | ($word, $headerScriptVersion) = $self->readMarker($fileHandle); | ||
| 1402 | if (! defined $word || $word ne 'script_version' || ! $headerScriptVersion) { | ||
| 1403 | |||
| 1404 | $failFlag = TRUE; | ||
| 1405 | } | ||
| 1406 | |||
| 1407 | ($word, $headerSaveDate) = $self->readMarker($fileHandle); | ||
| 1408 | if (! defined $word || $word ne 'save_date' || ! $headerSaveDate) {$failFlag = TRUE} | ||
| 1409 | |||
| 1410 | ($word, $headerSaveTime) = $self->readMarker($fileHandle); | ||
| 1411 | if (! defined $word || $word ne 'save_time' || ! $headerSaveTime) {$failFlag = TRUE} | ||
| 1412 | |||
| 1413 | # Before v1.0.868, Axmud used 'assoc_world_defn' rather than 'assoc_world_prof' | ||
| 1414 | ($word, $headerAssocWorldProf) = $self->readMarker($fileHandle); | ||
| 1415 | if ( | ||
| 1416 | ! defined $word | ||
| 1417 | || ($word ne 'assoc_world_prof' && $word ne 'assoc_world_defn') | ||
| 1418 | || ! $headerAssocWorldProf | ||
| 1419 | ) { | ||
| 1420 | $failFlag = TRUE; | ||
| 1421 | } | ||
| 1422 | |||
| 1423 | # Read end-of-section | ||
| 1424 | ($line) = $self->readMarker($fileHandle); | ||
| 1425 | if (! defined $line || $line ne 'eos') {$failFlag = TRUE} | ||
| 1426 | |||
| 1427 | # Do basic checks on the header file information - that the file was created by Axmud, by | ||
| 1428 | # the current version of it or an earlier version of it | ||
| 1429 | if ( | ||
| 1430 | ! $self->checkCompatibility($headerScriptName) | ||
| 1431 | || $axmud::CLIENT->convertVersion($headerScriptVersion) | ||
| 1432 | > $axmud::CLIENT->convertVersion($axmud::VERSION) | ||
| 1433 | ) { | ||
| 1434 | $failFlag = TRUE; | ||
| 1435 | } | ||
| 1436 | |||
| 1437 | # If header information is incorrect, don't bother reading the rest of the file | ||
| 1438 | if ($fileType ne $self->fileType || $failFlag) { | ||
| 1439 | |||
| 1440 | # Close the file and release the lock on the semaphore file | ||
| 1441 | $result = close $fileHandle; | ||
| 1442 | $self->releaseFileLock($semaphoreHandle); | ||
| 1443 | |||
| 1444 | if (! $result) { | ||
| 1445 | return $self->disableSaveLoad(FALSE); | ||
| 1446 | } elsif ($failFlag) { | ||
| 1447 | return $self->disableSaveLoad(TRUE); | ||
| 1448 | } | ||
| 1449 | |||
| 1450 | # Otherwise, save the header information in this object | ||
| 1451 | } else { | ||
| 1452 | |||
| 1453 | $self->ivPoke('scriptName', $headerScriptName); | ||
| 1454 | $self->ivPoke('scriptVersion', $headerScriptVersion); | ||
| 1455 | $self->ivPoke( | ||
| 1456 | 'scriptConvertVersion', | ||
| 1457 | $axmud::CLIENT->convertVersion($headerScriptVersion), | ||
| 1458 | ); | ||
| 1459 | $self->ivPoke('saveDate', $headerSaveDate); | ||
| 1460 | $self->ivPoke('saveTime', $headerSaveTime); | ||
| 1461 | $self->ivUndef('assocWorldProf'); | ||
| 1462 | |||
| 1463 | $self->ivPoke('actualFileName', $fileName); | ||
| 1464 | $self->ivPoke('actualPath', $path); | ||
| 1465 | $self->ivPoke('actualDir', $dir); | ||
| 1466 | } | ||
| 1467 | |||
| 1468 | ############### | ||
| 1469 | # Read the data | ||
| 1470 | |||
| 1471 | # Read data from the file, and store it temporarily in a single hash, %dataHash. | ||
| 1472 | # The temporary hash should contain the filehandle, so that $self->readValue (etc) can use | ||
| 1473 | # it | ||
| 1474 | $dataHash{'file_handle'} = $fileHandle; | ||
| 1475 | |||
| 1476 | # Read script data (read, but not used) | ||
| 1477 | $failFlag = $self->readValue($failFlag, \%dataHash, 'script_name'); | ||
| 1478 | $failFlag = $self->readValue($failFlag, \%dataHash, 'script_version'); | ||
| 1479 | $failFlag = $self->readValue($failFlag, \%dataHash, 'script_date'); | ||
| 1480 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1481 | |||
| 1482 | # Read file object data | ||
| 1483 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'load_config_flag'); | ||
| 1484 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'save_config_flag'); | ||
| 1485 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'load_data_flag'); | ||
| 1486 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'save_data_flag'); | ||
| 1487 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'delete_files_start_flag'); | ||
| 1488 | if ($self->scriptConvertVersion >= 1_000_489) { | ||
| 1489 | |||
| 1490 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'emergency_save_flag'); | ||
| 1491 | } | ||
| 1492 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'auto_save_flag'); | ||
| 1493 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_save_wait_time'); | ||
| 1494 | if ($self->scriptConvertVersion >= 1_000_118) { | ||
| 1495 | |||
| 1496 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'auto_retain_file_flag'); | ||
| 1497 | } | ||
| 1498 | if ($self->scriptConvertVersion >= 1_001_024) { | ||
| 1499 | |||
| 1500 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_mode'); | ||
| 1501 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_dir'); | ||
| 1502 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_interval'); | ||
| 1503 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_date'); | ||
| 1504 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_backup_file_type'); | ||
| 1505 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'auto_backup_append_flag'); | ||
| 1506 | } | ||
| 1507 | if ($self->scriptConvertVersion >= 1_001_529) { | ||
| 1508 | |||
| 1509 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_model_split_flag'); | ||
| 1510 | $failFlag = $self->readValue($failFlag, \%dataHash, 'model_split_size'); | ||
| 1511 | } | ||
| 1512 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1513 | |||
| 1514 | # Read plugin data | ||
| 1515 | $failFlag = $self->readList($failFlag, \%dataHash, 'init_plugin_list'); | ||
| 1516 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1517 | |||
| 1518 | # Read instruction data | ||
| 1519 | if ($self->scriptConvertVersion >= 1_000_880) { | ||
| 1520 | |||
| 1521 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'echo_sigil_flag'); | ||
| 1522 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'perl_sigil_flag'); | ||
| 1523 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'script_sigil_flag'); | ||
| 1524 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'multi_sigil_flag'); | ||
| 1525 | } | ||
| 1526 | if ($self->scriptConvertVersion >= 1_000_912) { | ||
| 1527 | |||
| 1528 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'speed_sigil_flag'); | ||
| 1529 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'bypass_sigil_flag'); | ||
| 1530 | } | ||
| 1531 | $failFlag = $self->readValue($failFlag, \%dataHash, 'cmd_sep'); | ||
| 1532 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1533 | |||
| 1534 | # Read world profile data | ||
| 1535 | if ($self->scriptConvertVersion >= 1_001_021) { | ||
| 1536 | |||
| 1537 | $failFlag = $self->readValue($failFlag, \%dataHash, 'prev_client_version'); | ||
| 1538 | } | ||
| 1539 | $failFlag = $self->readList($failFlag, \%dataHash, 'world_prof_list'); | ||
| 1540 | $failFlag = $self->readList($failFlag, \%dataHash, 'favourite_world_list'); | ||
| 1541 | if ($self->scriptConvertVersion >= 1_001_396) { | ||
| 1542 | |||
| 1543 | $failFlag = $self->readList($failFlag, \%dataHash, 'auto_connect_list'); | ||
| 1544 | } | ||
| 1545 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1546 | |||
| 1547 | # Read logging preferences | ||
| 1548 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_logs_flag'); | ||
| 1549 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'delete_standard_logs_flag'); | ||
| 1550 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'delete_world_logs_flag'); | ||
| 1551 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_prefix_date_flag'); | ||
| 1552 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_prefix_time_flag'); | ||
| 1553 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_day_flag'); | ||
| 1554 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_client_flag'); | ||
| 1555 | if ($self->scriptConvertVersion >= 1_000_917) { | ||
| 1556 | |||
| 1557 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_image_flag'); | ||
| 1558 | } | ||
| 1559 | $failFlag = $self->readValue($failFlag, \%dataHash, 'status_before_count'); | ||
| 1560 | $failFlag = $self->readValue($failFlag, \%dataHash, 'status_after_count'); | ||
| 1561 | $failFlag = $self->readHash($failFlag, \%dataHash, 'log_pref_hash'); | ||
| 1562 | if ($self->scriptConvertVersion >= 1_001_395) { | ||
| 1563 | |||
| 1564 | $failFlag = $self->readList($failFlag, \%dataHash, 'log_preamble_list'); | ||
| 1565 | } | ||
| 1566 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1567 | |||
| 1568 | # Read colour tags | ||
| 1569 | if ($self->scriptConvertVersion >= 1_000_165) { | ||
| 1570 | |||
| 1571 | $failFlag = $self->readValue($failFlag, \%dataHash, 'current_xterm_cube'); | ||
| 1572 | } | ||
| 1573 | if ($self->scriptConvertVersion >= 1_000_203) { | ||
| 1574 | |||
| 1575 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'osc_palette_flag'); | ||
| 1576 | } | ||
| 1577 | $failFlag = $self->readHash($failFlag, \%dataHash, 'colour_tag_hash'); | ||
| 1578 | $failFlag = $self->readHash($failFlag, \%dataHash, 'bold_colour_tag_hash'); | ||
| 1579 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1580 | |||
| 1581 | # Read desktop and display settings | ||
| 1582 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_main_win_width'); | ||
| 1583 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_main_win_height'); | ||
| 1584 | if ($self->scriptConvertVersion < 1_000_800) { | ||
| 1585 | |||
| 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 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1590 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1591 | } | ||
| 1592 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_grid_win_width'); | ||
| 1593 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_grid_win_height'); | ||
| 1594 | if ($self->scriptConvertVersion < 1_000_800) { | ||
| 1595 | |||
| 1596 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1597 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1598 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1599 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1600 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1601 | } | ||
| 1602 | if ($self->scriptConvertVersion < 1_000_800) { | ||
| 1603 | |||
| 1604 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1605 | } | ||
| 1606 | if ($self->scriptConvertVersion >= 1_001_162) { | ||
| 1607 | |||
| 1608 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_free_win_width'); | ||
| 1609 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_free_win_height'); | ||
| 1610 | } | ||
| 1611 | if ($self->scriptConvertVersion >= 1_003_118) { | ||
| 1612 | |||
| 1613 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'config_win_index_flag'); | ||
| 1614 | } | ||
| 1615 | if ($self->scriptConvertVersion >= 1_003_135) { | ||
| 1616 | |||
| 1617 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'config_win_simplify_flag'); | ||
| 1618 | } | ||
| 1619 | if ($self->scriptConvertVersion >= 1_003_134) { | ||
| 1620 | |||
| 1621 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_config_win_index_width'); | ||
| 1622 | } | ||
| 1623 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_insert_cmd_colour'); | ||
| 1624 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_system_text_colour'); | ||
| 1625 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_error_colour'); | ||
| 1626 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_warning_colour'); | ||
| 1627 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_debug_colour'); | ||
| 1628 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_improper_colour'); | ||
| 1629 | if ($self->scriptConvertVersion >= 1_000_079) { | ||
| 1630 | |||
| 1631 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'convert_invisible_flag'); | ||
| 1632 | } | ||
| 1633 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 1634 | |||
| 1635 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_text_buffer_size'); | ||
| 1636 | } | ||
| 1637 | $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_left_size'); | ||
| 1638 | $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_right_size'); | ||
| 1639 | $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_top_size'); | ||
| 1640 | $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_bottom_size'); | ||
| 1641 | if ($self->scriptConvertVersion < 1_000_800) { | ||
| 1642 | |||
| 1643 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me'); | ||
| 1644 | $failFlag = $self->readHash($failFlag, \%dataHash, 'discard_me'); | ||
| 1645 | } | ||
| 1646 | $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_controls_left_size'); | ||
| 1647 | $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_controls_right_size'); | ||
| 1648 | $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_controls_top_size'); | ||
| 1649 | $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_controls_bottom_size'); | ||
| 1650 | if ($self->scriptConvertVersion >= 1_003_157) { | ||
| 1651 | |||
| 1652 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'mswin_win_posn_tweak_flag'); | ||
| 1653 | } | ||
| 1654 | if ($self->scriptConvertVersion < 1_000_800) { | ||
| 1655 | |||
| 1656 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me'); | ||
| 1657 | } | ||
| 1658 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 1659 | |||
| 1660 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'share_main_win_flag'); | ||
| 1661 | $failFlag = $self->readValue($failFlag, \%dataHash, 'restart_share_main_win_mode'); | ||
| 1662 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'activate_grid_flag'); | ||
| 1663 | } | ||
| 1664 | if ($self->scriptConvertVersion >= 1_001_164) { | ||
| 1665 | |||
| 1666 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'store_grid_posn_flag'); | ||
| 1667 | $failFlag = $self->readHash($failFlag, \%dataHash, 'store_grid_posn_hash'); | ||
| 1668 | } | ||
| 1669 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 1670 | |||
| 1671 | $failFlag = $self->readValue($failFlag, \%dataHash, 'init_workspace_dir'); | ||
| 1672 | $failFlag = $self->readHash($failFlag, \%dataHash, 'init_workspace_hash'); | ||
| 1673 | } | ||
| 1674 | $failFlag = $self->readValue($failFlag, \%dataHash, 'grid_block_size'); | ||
| 1675 | $failFlag = $self->readValue($failFlag, \%dataHash, 'grid_gap_max_size'); | ||
| 1676 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'grid_adjustment_flag'); | ||
| 1677 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'grid_edge_correction_flag'); | ||
| 1678 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'grid_reshuffle_flag'); | ||
| 1679 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'grid_invis_win_flag'); | ||
| 1680 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1681 | |||
| 1682 | if ($self->scriptConvertVersion < 1_000_800) { | ||
| 1683 | |||
| 1684 | # Read 'main' window widget flags | ||
| 1685 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me'); | ||
| 1686 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me'); | ||
| 1687 | if ($self->scriptConvertVersion >= 1_000_674) { | ||
| 1688 | |||
| 1689 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me'); | ||
| 1690 | } | ||
| 1691 | if ($self->scriptConvertVersion >= 1_000_549) { | ||
| 1692 | |||
| 1693 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me'); | ||
| 1694 | } | ||
| 1695 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1696 | } | ||
| 1697 | |||
| 1698 | # Read instructions | ||
| 1699 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_display_buffer_size'); | ||
| 1700 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_cmd_buffer_size'); | ||
| 1701 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_instruct_buffer_size'); | ||
| 1702 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'confirm_world_cmd_flag'); | ||
| 1703 | if ($self->scriptConvertVersion >= 1_000_331) { | ||
| 1704 | |||
| 1705 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'convert_world_cmd_flag'); | ||
| 1706 | } | ||
| 1707 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'preserve_world_cmd_flag'); | ||
| 1708 | if ($self->scriptConvertVersion >= 1_000_880) { | ||
| 1709 | |||
| 1710 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'preserve_other_cmd_flag'); | ||
| 1711 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'max_multi_cmd_flag'); | ||
| 1712 | } | ||
| 1713 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_complete_mode'); | ||
| 1714 | if ($self->scriptConvertVersion < 1_000_800 && ! $failFlag) { | ||
| 1715 | |||
| 1716 | if ($dataHash{'auto_complete_mode'} eq '0') { | ||
| 1717 | $dataHash{'auto_complete_mode'} = 'none'; | ||
| 1718 | } elsif ( | ||
| 1719 | $dataHash{'auto_complete_mode'} eq '1' | ||
| 1720 | || $dataHash{'auto_complete_mode'} eq '2' | ||
| 1721 | ) { | ||
| 1722 | $dataHash{'auto_complete_mode'} = 'auto'; | ||
| 1723 | } | ||
| 1724 | } | ||
| 1725 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 1726 | |||
| 1727 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_complete_type'); | ||
| 1728 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_complete_parent'); | ||
| 1729 | } | ||
| 1730 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1731 | |||
| 1732 | # Read external applications | ||
| 1733 | $failFlag = $self->readValue($failFlag, \%dataHash, 'browser_cmd'); | ||
| 1734 | $failFlag = $self->readValue($failFlag, \%dataHash, 'audio_cmd'); | ||
| 1735 | $failFlag = $self->readValue($failFlag, \%dataHash, 'text_edit_cmd'); | ||
| 1736 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1737 | |||
| 1738 | # Read sound effects | ||
| 1739 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_sound_flag'); | ||
| 1740 | if ($self->scriptConvertVersion >= 1_000_087) { | ||
| 1741 | |||
| 1742 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_ascii_bell_flag'); | ||
| 1743 | } | ||
| 1744 | $failFlag = $self->readHash($failFlag, \%dataHash, 'custom_sound_hash'); | ||
| 1745 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1746 | |||
| 1747 | # Read text-to-speech (TTS) | ||
| 1748 | if ($self->scriptConvertVersion >= 1_000_618) { | ||
| 1749 | |||
| 1750 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_tts_flag'); | ||
| 1751 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_smooth_flag'); | ||
| 1752 | if ($self->scriptConvertVersion >= 1_002_073) { | ||
| 1753 | |||
| 1754 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_hijack_flag'); | ||
| 1755 | } | ||
| 1756 | if ($self->scriptConvertVersion >= 1_002_213) { | ||
| 1757 | |||
| 1758 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_force_hijack_flag'); | ||
| 1759 | } | ||
| 1760 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_receive_flag'); | ||
| 1761 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_login_flag'); | ||
| 1762 | if ($self->scriptConvertVersion >= 1_002_212) { | ||
| 1763 | |||
| 1764 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_prompt_flag'); | ||
| 1765 | } | ||
| 1766 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_system_flag'); | ||
| 1767 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_system_error_flag'); | ||
| 1768 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_world_cmd_flag'); | ||
| 1769 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_dialogue_flag'); | ||
| 1770 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_task_flag'); | ||
| 1771 | if ($self->scriptConvertVersion >= 1_003_105) { | ||
| 1772 | |||
| 1773 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'tts_verbose_flag'); | ||
| 1774 | } | ||
| 1775 | $failFlag = $self->readValue($failFlag, \%dataHash, 'tts_festival_server_port'); | ||
| 1776 | if ($self->scriptConvertVersion < 1_002_185) { | ||
| 1777 | |||
| 1778 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'discard_me'); | ||
| 1779 | } | ||
| 1780 | if ($self->scriptConvertVersion >= 1_003_110) { | ||
| 1781 | |||
| 1782 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'blind_help_msg_shown_flag'); | ||
| 1783 | } | ||
| 1784 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1785 | } | ||
| 1786 | |||
| 1787 | # Read telnet option negotiation flags | ||
| 1788 | if ($self->scriptConvertVersion >= 1_000_156) { | ||
| 1789 | |||
| 1790 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_echo_flag'); | ||
| 1791 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_ttype_flag'); | ||
| 1792 | } | ||
| 1793 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_naws_flag'); | ||
| 1794 | if ($self->scriptConvertVersion >= 1_000_156) { | ||
| 1795 | |||
| 1796 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_charset_flag'); | ||
| 1797 | } | ||
| 1798 | if ($self->scriptConvertVersion >= 1_000_163) { | ||
| 1799 | |||
| 1800 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_eor_flag'); | ||
| 1801 | } | ||
| 1802 | if ($self->scriptConvertVersion >= 1_000_879) { | ||
| 1803 | |||
| 1804 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_sga_flag'); | ||
| 1805 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_new_environ_flag'); | ||
| 1806 | } | ||
| 1807 | # Read MUD protocol flags | ||
| 1808 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mccp_flag'); | ||
| 1809 | if ($self->scriptConvertVersion >= 1_000_156) { | ||
| 1810 | |||
| 1811 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_msdp_flag'); | ||
| 1812 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mssp_flag'); | ||
| 1813 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mtts_flag'); | ||
| 1814 | } | ||
| 1815 | if ($self->scriptConvertVersion >= 1_002_095) { | ||
| 1816 | |||
| 1817 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mnes_flag'); | ||
| 1818 | } | ||
| 1819 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mxp_flag'); | ||
| 1820 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_msp_flag'); | ||
| 1821 | if ($self->scriptConvertVersion >= 1_000_844) { | ||
| 1822 | |||
| 1823 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_pueblo_flag'); | ||
| 1824 | } | ||
| 1825 | if ($self->scriptConvertVersion >= 1_000_850) { | ||
| 1826 | |||
| 1827 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_atcp_flag'); | ||
| 1828 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_gmcp_flag'); | ||
| 1829 | } | ||
| 1830 | if ($self->scriptConvertVersion >= 1_000_879) { | ||
| 1831 | |||
| 1832 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_zmp_flag'); | ||
| 1833 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_aard102_flag'); | ||
| 1834 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'use_mcp_flag'); | ||
| 1835 | } | ||
| 1836 | if ($self->scriptConvertVersion >= 1_000_832) { | ||
| 1837 | |||
| 1838 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_font_flag'); | ||
| 1839 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_image_flag'); | ||
| 1840 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_load_image_flag'); | ||
| 1841 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_filter_image_flag'); | ||
| 1842 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_sound_flag'); | ||
| 1843 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_load_sound_flag'); | ||
| 1844 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_gauge_flag'); | ||
| 1845 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_frame_flag'); | ||
| 1846 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_interior_flag'); | ||
| 1847 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_crosslink_flag'); | ||
| 1848 | } | ||
| 1849 | if ($self->scriptConvertVersion >= 1_000_887) { | ||
| 1850 | |||
| 1851 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_room_flag'); | ||
| 1852 | } | ||
| 1853 | if ($self->scriptConvertVersion >= 1_001_510) { | ||
| 1854 | |||
| 1855 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_flexible_flag'); | ||
| 1856 | } | ||
| 1857 | if ($self->scriptConvertVersion >= 1_002_020) { | ||
| 1858 | |||
| 1859 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mxp_perm_flag'); | ||
| 1860 | } | ||
| 1861 | if ($self->scriptConvertVersion >= 1_000_678) { | ||
| 1862 | |||
| 1863 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_msp_multiple_flag'); | ||
| 1864 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_msp_load_sound_flag'); | ||
| 1865 | } | ||
| 1866 | if ($self->scriptConvertVersion >= 1_000_886) { | ||
| 1867 | |||
| 1868 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_msp_flexible_flag'); | ||
| 1869 | } | ||
| 1870 | if ($self->scriptConvertVersion >= 1_002_095) { | ||
| 1871 | |||
| 1872 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_mnes_send_ip_flag'); | ||
| 1873 | } | ||
| 1874 | # Read telnet option negotiation customisation IVs | ||
| 1875 | if ($self->scriptConvertVersion >= 1_000_160) { | ||
| 1876 | |||
| 1877 | $failFlag = $self->readValue($failFlag, \%dataHash, 'term_type_mode'); | ||
| 1878 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_client_name'); | ||
| 1879 | } | ||
| 1880 | if ($self->scriptConvertVersion >= 1_000_666) { | ||
| 1881 | |||
| 1882 | $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_client_version'); | ||
| 1883 | } | ||
| 1884 | if ($self->scriptConvertVersion >= 1_001_213) { | ||
| 1885 | |||
| 1886 | $failFlag = $self->readValue($failFlag, \%dataHash, 'use_ctrl_seq_flag'); | ||
| 1887 | $failFlag = $self->readValue($failFlag, \%dataHash, 'use_visible_cursor_flag'); | ||
| 1888 | $failFlag = $self->readValue($failFlag, \%dataHash, 'use_fast_cursor_flag'); | ||
| 1889 | $failFlag = $self->readValue($failFlag, \%dataHash, 'use_direct_keys_flag'); | ||
| 1890 | } | ||
| 1891 | # Set telnet negotiation debug flags | ||
| 1892 | if ($self->scriptConvertVersion >= 1_001_214) { | ||
| 1893 | |||
| 1894 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_esc_sequence_flag'); | ||
| 1895 | } | ||
| 1896 | if ($self->scriptConvertVersion >= 1_000_378) { | ||
| 1897 | |||
| 1898 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_telnet_flag'); | ||
| 1899 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_telnet_mini_flag'); | ||
| 1900 | } | ||
| 1901 | if ($self->scriptConvertVersion >= 1_000_895) { | ||
| 1902 | |||
| 1903 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_telnet_log_flag'); | ||
| 1904 | } | ||
| 1905 | if ($self->scriptConvertVersion >= 1_000_378) { | ||
| 1906 | |||
| 1907 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_msdp_flag'); | ||
| 1908 | } | ||
| 1909 | if ($self->scriptConvertVersion >= 1_000_405) { | ||
| 1910 | |||
| 1911 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_mxp_flag'); | ||
| 1912 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_mxp_comment_flag'); | ||
| 1913 | } | ||
| 1914 | if ($self->scriptConvertVersion >= 1_000_849) { | ||
| 1915 | |||
| 1916 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_pueblo_flag'); | ||
| 1917 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_pueblo_comment_flag'); | ||
| 1918 | } | ||
| 1919 | if ($self->scriptConvertVersion >= 1_001_140) { | ||
| 1920 | |||
| 1921 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_zmp_flag'); | ||
| 1922 | } | ||
| 1923 | if ($self->scriptConvertVersion >= 1_000_926) { | ||
| 1924 | |||
| 1925 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_atcp_flag'); | ||
| 1926 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_gmcp_flag'); | ||
| 1927 | } | ||
| 1928 | if ($self->scriptConvertVersion >= 1_001_158) { | ||
| 1929 | |||
| 1930 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_mcp_flag'); | ||
| 1931 | } | ||
| 1932 | |||
| 1933 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 1934 | |||
| 1935 | # Read misc data | ||
| 1936 | $failFlag = $self->readList($failFlag, \%dataHash, 'custom_month_list'); | ||
| 1937 | $failFlag = $self->readList($failFlag, \%dataHash, 'custom_day_list'); | ||
| 1938 | if ($self->scriptConvertVersion >= 1_001_262) { | ||
| 1939 | |||
| 1940 | $failFlag = $self->readValue($failFlag, \%dataHash, 'commify_mode'); | ||
| 1941 | } | ||
| 1942 | if ($self->scriptConvertVersion >= 1_001_284) { | ||
| 1943 | |||
| 1944 | $failFlag = $self->readValue($failFlag, \%dataHash, 'short_url_flag'); | ||
| 1945 | } | ||
| 1946 | if ($self->scriptConvertVersion <= 1_000_922) { | ||
| 1947 | |||
| 1948 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 1949 | } | ||
| 1950 | if ($self->scriptConvertVersion >= 1_002_166) { | ||
| 1951 | |||
| 1952 | $failFlag = $self->readList($failFlag, \%dataHash, 'ip_lookup_list'); | ||
| 1953 | } | ||
| 1954 | $failFlag = $self->readValue($failFlag, \%dataHash, 'prompt_wait_time'); | ||
| 1955 | $failFlag = $self->readValue($failFlag, \%dataHash, 'login_warning_time'); | ||
| 1956 | if ($self->scriptConvertVersion >= 1_000_331) { | ||
| 1957 | |||
| 1958 | if ($self->scriptConvertVersion <= 1_000_535) { | ||
| 1959 | |||
| 1960 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_world_flag'); | ||
| 1961 | |||
| 1962 | } else { | ||
| 1963 | |||
| 1964 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_line_nums_flag'); | ||
| 1965 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_line_tags_flag'); | ||
| 1966 | } | ||
| 1967 | } | ||
| 1968 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_locator_flag'); | ||
| 1969 | if ($self->scriptConvertVersion >= 1_000_482) { | ||
| 1970 | |||
| 1971 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_max_locator_flag'); | ||
| 1972 | } | ||
| 1973 | if ($self->scriptConvertVersion >= 1_001_282) { | ||
| 1974 | |||
| 1975 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_exit_flag'); | ||
| 1976 | } | ||
| 1977 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_move_list_flag'); | ||
| 1978 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_parse_obj_flag'); | ||
| 1979 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_compare_obj_flag'); | ||
| 1980 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_explain_plugin_flag'); | ||
| 1981 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_check_iv_flag'); | ||
| 1982 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 1983 | |||
| 1984 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_table_fit_flag'); | ||
| 1985 | } | ||
| 1986 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'debug_trap_error_flag'); | ||
| 1987 | if ($self->scriptConvertVersion >= 1_000_949) { | ||
| 1988 | |||
| 1989 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'toolbar_label_flag'); | ||
| 1990 | } | ||
| 1991 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'irreversible_icon_flag'); | ||
| 1992 | if ($self->scriptConvertVersion >= 1_001_136) { | ||
| 1993 | |||
| 1994 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_busy_win_flag'); | ||
| 1995 | } | ||
| 1996 | if ($self->scriptConvertVersion >= 1_001_202) { | ||
| 1997 | |||
| 1998 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'main_win_system_msg_flag'); | ||
| 1999 | } | ||
| 2000 | if ($self->scriptConvertVersion >= 1_000_344) { | ||
| 2001 | |||
| 2002 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'main_win_urgency_flag'); | ||
| 2003 | } | ||
| 2004 | if ($self->scriptConvertVersion >= 1_000_883) { | ||
| 2005 | |||
| 2006 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'main_win_tooltip_flag'); | ||
| 2007 | } | ||
| 2008 | $failFlag = $self->readValue($failFlag, \%dataHash, 'session_tab_mode'); | ||
| 2009 | if ($self->scriptConvertVersion >= 1_000_184) { | ||
| 2010 | |||
| 2011 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'xterm_title_flag'); | ||
| 2012 | } | ||
| 2013 | if ($self->scriptConvertVersion >= 1_000_365) { | ||
| 2014 | |||
| 2015 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'long_tab_label_flag'); | ||
| 2016 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'simple_tab_flag'); | ||
| 2017 | } | ||
| 2018 | if ($self->scriptConvertVersion >= 1_000_917) { | ||
| 2019 | |||
| 2020 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'confirm_close_main_win_flag'); | ||
| 2021 | $failFlag = $self->readFlag($failFlag, \%dataHash, 'confirm_close_tab_flag'); | ||
| 2022 | } | ||
| 2023 | if ($self->scriptConvertVersion >= 1_002_102) { | ||
| 2024 | |||
| 2025 | $failFlag = $self->readValue($failFlag, \%dataHash, 'confirm_close_menu_flag'); | ||
| 2026 | $failFlag = $self->readValue($failFlag, \%dataHash, 'confirm_close_tool_button_flag'); | ||
| 2027 | } | ||
| 2028 | if ($self->scriptConvertVersion >= 1_000_185) { | ||
| 2029 | |||
| 2030 | $failFlag = $self->readValue($failFlag, \%dataHash, 'char_set'); | ||
| 2031 | } | ||
| 2032 | if ($self->scriptConvertVersion >= 1_000_616) { | ||
| 2033 | |||
| 2034 | $failFlag = $self->readValue($failFlag, \%dataHash, 'session_max'); | ||
| 2035 | } | ||
| 2036 | if ($self->scriptConvertVersion >= 1_001_256) { | ||
| 2037 | |||
| 2038 | $failFlag = $self->readValue($failFlag, \%dataHash, 'offline_on_disconnect_flag'); | ||
| 2039 | } | ||
| 2040 | if ($self->scriptConvertVersion >= 1_000_884) { | ||
| 2041 | |||
| 2042 | $failFlag = $self->readValue($failFlag, \%dataHash, 'connect_history_flag'); | ||
| 2043 | } | ||
| 2044 | if ($self->scriptConvertVersion >= 1_000_338 && $self->scriptConvertVersion <= 1_000_884) { | ||
| 2045 | |||
| 2046 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 2047 | $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me'); | ||
| 2048 | } | ||
| 2049 | if ($self->scriptConvertVersion >= 1_000_338) { | ||
| 2050 | |||
| 2051 | $failFlag = $self->readValue($failFlag, \%dataHash, 'use_scroll_keys_flag'); | ||
| 2052 | } | ||
| 2053 | if ($self->scriptConvertVersion >= 1_000_884) { | ||
| 2054 | |||
| 2055 | $failFlag = $self->readValue($failFlag, \%dataHash, 'smooth_scroll_keys_flag'); | ||
| 2056 | $failFlag = $self->readValue($failFlag, \%dataHash, 'auto_split_keys_flag'); | ||
| 2057 | } | ||
| 2058 | if ($self->scriptConvertVersion >= 1_000_338) { | ||
| 2059 | |||
| 2060 | $failFlag = $self->readValue($failFlag, \%dataHash, 'use_complete_keys_flag'); | ||
| 2061 | $failFlag = $self->readValue($failFlag, \%dataHash, 'use_switch_keys_flag'); | ||
| 2062 | } | ||
| 2063 | |||
| 2064 | $failFlag = $self->readEndOfSection($failFlag, $fileHandle); | ||
| 2065 | |||
| 2066 | ################# | ||
| 2067 | # Read the footer | ||
| 2068 | |||
| 2069 | ($line) = $self->readMarker($fileHandle); | ||
| 2070 | if (! defined $line || $line ne 'eof') { | ||
| 2071 | |||
| 2072 | $failFlag = TRUE; | ||
| 2073 | } | ||
| 2074 | |||
| 2075 | # Reading complete | ||
| 2076 | $result = close $fileHandle; | ||
| 2077 | # Release the lock on the semaphore file | ||
| 2078 | $self->releaseFileLock($semaphoreHandle); | ||
| 2079 | |||
| 2080 | if (! $result) { | ||
| 2081 | |||
| 2082 | # Set global flags and display an error message | ||
| 2083 | return $self->disableSaveLoad(FALSE); | ||
| 2084 | |||
| 2085 | } elsif ($failFlag) { | ||
| 2086 | |||
| 2087 | # Error messages displayed by $self->setupConfigFile | ||
| 2088 | return $self->disableSaveLoad(TRUE); | ||
| 2089 | } | ||
| 2090 | |||
| 2091 | ############## | ||
| 2092 | # Basic checks | ||
| 2093 | |||
| 2094 | $warningCount = 0; | ||
| 2095 | |||
| 2096 | # Check header data | ||
| 2097 | |||
| 2098 | # For config files created before the first public release, display a warning that the file | ||
| 2099 | # might not be compatible with the current version of Axmud (this prevents difficult-to- | ||
| 2100 | # diagnose errors which are actually the result of old data) | ||
| 2101 | if ( | ||
| 2102 | $axmud::CLIENT->convertVersion($axmud::VERSION) < 1 | ||
| 2103 | && ( | ||
| 2104 | $axmud::CLIENT->convertVersion($headerScriptVersion) | ||
| 2105 | != $axmud::CLIENT->convertVersion($axmud::VERSION) | ||
| 2106 | ) | ||
| 2107 | ) { | ||
| 2108 | $warningCount++; | ||
| 2109 | |||
| 2110 | $self->writeWarning( | ||
| 2111 | 'Config file may be incompatible with this version of ' . $axmud::CLIENT | ||
| 2112 | . ' (file v' . $headerScriptVersion . ', client v' . $axmud::VERSION . ')', | ||
| 2113 | $self->_objClass . '->loadConfigFile', | ||
| 2114 | ); | ||
| 2115 | } | ||
| 2116 | |||
| 2117 | # Respond to any warnings | ||
| 2118 | if ($warningCount == 1) { | ||
| 2119 | |||
| 2120 | $self->writeWarning( | ||
| 2121 | 'Config file: 1 warning issued and data not loaded', | ||
| 2122 | $self->_objClass . '->loadConfigFile', | ||
| 2123 | ); | ||
| 2124 | |||
| 2125 | return $self->disableSaveLoad(TRUE); | ||
| 2126 | |||
| 2127 | } elsif ($warningCount > 1) { | ||
| 2128 | |||
| 2129 | $self->writeWarning( | ||
| 2130 | 'Config file: ' . $warningCount . ' warnings issued and data not loaded', | ||
| 2131 | $self->_objClass . '->loadConfigFile', | ||
| 2132 | ); | ||
| 2133 | |||
| 2134 | return $self->disableSaveLoad(TRUE); | ||
| 2135 | } | ||
| 2136 | |||
| 2137 | ############## | ||
| 2138 | # Data updates | ||
| 2139 | |||
| 2140 | # v1.0.908 converts some numerical mode values to string mode values | ||
| 2141 | if ($self->scriptConvertVersion < 1_000_909) { | ||
| 2142 | |||
| 2143 | # GA::Client->sessionTabMode | ||
| 2144 | if ($dataHash{'session_tab_mode'} eq '0') { | ||
| 2145 | $dataHash{'session_tab_mode'} = 'bracket'; | ||
| 2146 | } elsif ($dataHash{'session_tab_mode'} eq '1') { | ||
| 2147 | $dataHash{'session_tab_mode'} = 'hyphen'; | ||
| 2148 | } elsif ($dataHash{'session_tab_mode'} eq '2') { | ||
| 2149 | $dataHash{'session_tab_mode'} = 'world'; | ||
| 2150 | } elsif ($dataHash{'session_tab_mode'} eq '3') { | ||
| 2151 | $dataHash{'session_tab_mode'} = 'char'; | ||
| 2152 | } | ||
| 2153 | |||
| 2154 | # GA::Client->termTypeMode | ||
| 2155 | if ($self->scriptConvertVersion >= 1_000_160) { | ||
| 2156 | |||
| 2157 | if ($dataHash{'term_type_mode'} eq '0') { | ||
| 2158 | $dataHash{'term_type_mode'} = 'send_nothing'; | ||
| 2159 | } elsif ($dataHash{'term_type_mode'} eq '1') { | ||
| 2160 | $dataHash{'term_type_mode'} = 'send_client'; | ||
| 2161 | } elsif ($dataHash{'term_type_mode'} eq '2') { | ||
| 2162 | $dataHash{'term_type_mode'} = 'send_client_version'; | ||
| 2163 | } elsif ($dataHash{'term_type_mode'} eq '3') { | ||
| 2164 | $dataHash{'term_type_mode'} = 'send_custom_client'; | ||
| 2165 | } elsif ($dataHash{'term_type_mode'} eq '4') { | ||
| 2166 | $dataHash{'term_type_mode'} = 'send_default'; | ||
| 2167 | } elsif ($dataHash{'term_type_mode'} eq '5') { | ||
| 2168 | $dataHash{'term_type_mode'} = 'send_unknown'; | ||
| 2169 | } | ||
| 2170 | } | ||
| 2171 | } | ||
| 2172 | |||
| 2173 | # v1.2.0 makes window tiling available on all operating systems | ||
| 2174 | if ($self->scriptConvertVersion < 1_002_000 && $^O eq 'MSWin32') { | ||
| 2175 | |||
| 2176 | $dataHash{'store_grid_posn_flag'} = FALSE; | ||
| 2177 | |||
| 2178 | # Show the Setup 'wiz' window again, so the user can choose a layout. As of this | ||
| 2179 | # version, the 'wiz' window now checks that any initial tasks already exist and, if | ||
| 2180 | # so, updates them (usually to make their windows upon automatically) rather than | ||
| 2181 | # creating new initial tasks | ||
| 2182 | if (! $axmud::TEST_MODE_FLAG && ! $axmud::BLIND_MODE_FLAG) { | ||
| 2183 | |||
| 2184 | $axmud::CLIENT->set_showSetupWizWinFlag(TRUE); | ||
| 2185 | } | ||
| 2186 | } | ||
| 2187 | |||
| 2188 | ###################### | ||
| 2189 | # Set GA::Client IVs | ||
| 2190 | |||
| 2191 | # For convenience, import the GA::Client | ||
| 2192 | $client = $axmud::CLIENT; | ||
| 2193 | |||
| 2194 | # Set IVs directly, rather than using GA::Client's 'set' accessors (otherwise the file | ||
| 2195 | # object's ->modifyFlag will get set to TRUE again, which we obviously don't want) | ||
| 2196 | |||
| 2197 | # Set file object data | ||
| 2198 | $client->ivPoke('loadConfigFlag', $dataHash{'load_config_flag'}); | ||
| 2199 | $client->ivPoke('saveConfigFlag', $dataHash{'save_config_flag'}); | ||
| 2200 | $client->ivPoke('loadDataFlag', $dataHash{'load_data_flag'}); | ||
| 2201 | $client->ivPoke('saveDataFlag', $dataHash{'save_data_flag'}); | ||
| 2202 | $client->ivPoke('deleteFilesAtStartFlag', $dataHash{'delete_files_start_flag'}); | ||
| 2203 | if ($self->scriptConvertVersion >= 1_000_489) { | ||
| 2204 | |||
| 2205 | $client->ivPoke('emergencySaveFlag', $dataHash{'emergency_save_flag'}); | ||
| 2206 | } | ||
| 2207 | $client->ivPoke('autoSaveFlag', $dataHash{'auto_save_flag'}); | ||
| 2208 | if ($self->scriptConvertVersion < 1_000_148) { | ||
| 2209 | |||
| 2210 | # ->autoSaveWaitTime is now expressed in minutes, not seconds | ||
| 2211 | $client->ivPoke( | ||
| 2212 | 'autoSaveWaitTime', | ||
| 2213 | POSIX::ceil( ($dataHash{'auto_save_wait_time'}) / 60), | ||
| 2214 | ); | ||
| 2215 | |||
| 2216 | } else { | ||
| 2217 | |||
| 2218 | $client->ivPoke('autoSaveWaitTime', $dataHash{'auto_save_wait_time'}); | ||
| 2219 | } | ||
| 2220 | if ($self->scriptConvertVersion >= 1_000_118) { | ||
| 2221 | |||
| 2222 | $client->ivPoke('autoRetainFileFlag', $dataHash{'auto_retain_file_flag'}); | ||
| 2223 | } | ||
| 2224 | if ($self->scriptConvertVersion >= 1_001_024) { | ||
| 2225 | |||
| 2226 | $client->ivPoke('autoBackupMode', $dataHash{'auto_backup_mode'}); | ||
| 2227 | $client->ivPoke('autoBackupDir', $dataHash{'auto_backup_dir'}); | ||
| 2228 | $client->ivPoke('autoBackupInterval', $dataHash{'auto_backup_interval'}); | ||
| 2229 | $client->ivPoke('autoBackupDate', $dataHash{'auto_backup_date'}); | ||
| 2230 | $client->ivPoke('autoBackupFileType', $dataHash{'auto_backup_file_type'}); | ||
| 2231 | $client->ivPoke('autoBackupAppendFlag', $dataHash{'auto_backup_append_flag'}); | ||
| 2232 | } | ||
| 2233 | if ($self->scriptConvertVersion >= 1_001_529) { | ||
| 2234 | |||
| 2235 | $client->ivPoke('allowModelSplitFlag', $dataHash{'allow_model_split_flag'}); | ||
| 2236 | $client->ivPoke('modelSplitSize', $dataHash{'model_split_size'}); | ||
| 2237 | } | ||
| 2238 | |||
| 2239 | # Set plugin data | ||
| 2240 | $client->ivPoke('initPluginList', @{$dataHash{'init_plugin_list'}}); | ||
| 2241 | |||
| 2242 | # Set instruction data | ||
| 2243 | if ($self->scriptConvertVersion >= 1_000_880) { | ||
| 2244 | |||
| 2245 | $client->ivPoke('echoSigilFlag', $dataHash{'echo_sigil_flag'}); | ||
| 2246 | $client->ivPoke('perlSigilFlag', $dataHash{'perl_sigil_flag'}); | ||
| 2247 | $client->ivPoke('scriptSigilFlag', $dataHash{'script_sigil_flag'}); | ||
| 2248 | $client->ivPoke('multiSigilFlag', $dataHash{'multi_sigil_flag'}); | ||
| 2249 | } | ||
| 2250 | if ($self->scriptConvertVersion >= 1_000_912) { | ||
| 2251 | |||
| 2252 | $client->ivPoke('speedSigilFlag', $dataHash{'speed_sigil_flag'}); | ||
| 2253 | $client->ivPoke('bypassSigilFlag', $dataHash{'bypass_sigil_flag'}); | ||
| 2254 | } | ||
| 2255 | $client->ivPoke('cmdSep', $dataHash{'cmd_sep'}); | ||
| 2256 | |||
| 2257 | # Set world profile data | ||
| 2258 | if ($self->scriptConvertVersion >= 1_001_021) { | ||
| 2259 | |||
| 2260 | $client->ivPoke('prevClientVersion', $dataHash{'prev_client_version'}); | ||
| 2261 | } | ||
| 2262 | $client->ivPoke('configWorldProfList', @{$dataHash{'world_prof_list'}}); | ||
| 2263 | $client->ivPoke('favouriteWorldList', @{$dataHash{'favourite_world_list'}}); | ||
| 2264 | if ($self->scriptConvertVersion >= 1_001_396) { | ||
| 2265 | |||
| 2266 | $client->ivPoke('autoConnectList', @{$dataHash{'auto_connect_list'}}); | ||
| 2267 | } | ||
| 2268 | |||
| 2269 | # Set logging preferences | ||
| 2270 | $client->ivPoke('allowLogsFlag', $dataHash{'allow_logs_flag'}); | ||
| 2271 | $client->ivPoke('deleteStandardLogsFlag', $dataHash{'delete_standard_logs_flag'}); | ||
| 2272 | $client->ivPoke('deleteWorldLogsFlag', $dataHash{'delete_world_logs_flag'}); | ||
| 2273 | $client->ivPoke('logPrefixDateFlag', $dataHash{'log_prefix_date_flag'}); | ||
| 2274 | $client->ivPoke('logPrefixTimeFlag', $dataHash{'log_prefix_time_flag'}); | ||
| 2275 | $client->ivPoke('logDayFlag', $dataHash{'log_day_flag'}); | ||
| 2276 | $client->ivPoke('logClientFlag', $dataHash{'log_client_flag'}); | ||
| 2277 | if ($self->scriptConvertVersion >= 1_000_917) { | ||
| 2278 | |||
| 2279 | $client->ivPoke('logImageFlag', $dataHash{'log_image_flag'}); | ||
| 2280 | } | ||
| 2281 | $client->ivPoke('statusEventBeforeCount', $dataHash{'status_before_count'}); | ||
| 2282 | $client->ivPoke('statusEventAfterCount', $dataHash{'status_after_count'}); | ||
| 2283 | $client->ivPoke('logPrefHash', %{$dataHash{'log_pref_hash'}}); | ||
| 2284 | if ($self->scriptConvertVersion >= 1_001_395) { | ||
| 2285 | |||
| 2286 | $client->ivPoke('logPreambleList', @{$dataHash{'log_preamble_list'}}); | ||
| 2287 | } | ||
| 2288 | |||
| 2289 | # Set colour tags | ||
| 2290 | if ($self->scriptConvertVersion >= 1_000_165) { | ||
| 2291 | |||
| 2292 | $client->ivPoke('currentColourCube', $dataHash{'current_xterm_cube'}); | ||
| 2293 | } | ||
| 2294 | if ($self->scriptConvertVersion >= 1_000_203) { | ||
| 2295 | |||
| 2296 | $client->ivPoke('oscPaletteFlag', $dataHash{'osc_palette_flag'}); | ||
| 2297 | } | ||
| 2298 | $client->ivPoke('colourTagHash', %{$dataHash{'colour_tag_hash'}}); | ||
| 2299 | $client->ivPoke('boldColourTagHash', %{$dataHash{'bold_colour_tag_hash'}}); | ||
| 2300 | |||
| 2301 | # Read desktop and display settings | ||
| 2302 | $client->ivPoke('customMainWinWidth', $dataHash{'custom_main_win_width'}); | ||
| 2303 | $client->ivPoke('customMainWinHeight', $dataHash{'custom_main_win_height'}); | ||
| 2304 | $client->ivPoke('customGridWinWidth', $dataHash{'custom_grid_win_width'}); | ||
| 2305 | $client->ivPoke('customGridWinHeight', $dataHash{'custom_grid_win_height'}); | ||
| 2306 | if ($self->scriptConvertVersion >= 1_001_162) { | ||
| 2307 | |||
| 2308 | $client->ivPoke('customFreeWinWidth', $dataHash{'custom_free_win_width'}); | ||
| 2309 | $client->ivPoke('customFreeWinHeight', $dataHash{'custom_free_win_height'}); | ||
| 2310 | } | ||
| 2311 | |||
| 2312 | if ($self->scriptConvertVersion >= 1_003_118) { | ||
| 2313 | |||
| 2314 | $client->ivPoke('configWinIndexFlag', $dataHash{'config_win_index_flag'}); | ||
| 2315 | } | ||
| 2316 | if ($self->scriptConvertVersion >= 1_003_135) { | ||
| 2317 | |||
| 2318 | $client->ivPoke('configWinSimplifyFlag', $dataHash{'config_win_simplify_flag'}); | ||
| 2319 | } | ||
| 2320 | if ($self->scriptConvertVersion >= 1_003_134) { | ||
| 2321 | |||
| 2322 | $client->ivPoke( | ||
| 2323 | 'customConfigWinIndexWidth', | ||
| 2324 | $dataHash{'custom_config_win_index_width'}, | ||
| 2325 | ); | ||
| 2326 | } | ||
| 2327 | |||
| 2328 | $client->ivPoke('customInsertCmdColour', $dataHash{'custom_insert_cmd_colour'}); | ||
| 2329 | $client->ivPoke('customShowSystemTextColour', $dataHash{'custom_show_system_text_colour'}); | ||
| 2330 | $client->ivPoke('customShowErrorColour', $dataHash{'custom_show_error_colour'}); | ||
| 2331 | $client->ivPoke('customShowWarningColour', $dataHash{'custom_show_warning_colour'}); | ||
| 2332 | $client->ivPoke('customShowDebugColour', $dataHash{'custom_show_debug_colour'}); | ||
| 2333 | $client->ivPoke('customShowImproperColour', $dataHash{'custom_show_improper_colour'}); | ||
| 2334 | if ($self->scriptConvertVersion >= 1_000_079) { | ||
| 2335 | |||
| 2336 | $client->ivPoke('convertInvisibleFlag', $dataHash{'convert_invisible_flag'}); | ||
| 2337 | } | ||
| 2338 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 2339 | |||
| 2340 | $client->ivPoke('customTextBufferSize', $dataHash{'custom_text_buffer_size'}); | ||
| 2341 | } | ||
| 2342 | $client->ivPoke('customPanelLeftSize', $dataHash{'custom_panel_left_size'}); | ||
| 2343 | $client->ivPoke('customPanelRightSize', $dataHash{'custom_panel_right_size'}); | ||
| 2344 | $client->ivPoke('customPanelTopSize', $dataHash{'custom_panel_top_size'}); | ||
| 2345 | $client->ivPoke('customPanelBottomSize', $dataHash{'custom_panel_bottom_size'}); | ||
| 2346 | $client->ivPoke('customControlsLeftSize', $dataHash{'custom_controls_left_size'}); | ||
| 2347 | $client->ivPoke('customControlsRightSize', $dataHash{'custom_controls_right_size'}); | ||
| 2348 | $client->ivPoke('customControlsTopSize', $dataHash{'custom_controls_top_size'}); | ||
| 2349 | $client->ivPoke('customControlsBottomSize', $dataHash{'custom_controls_bottom_size'}); | ||
| 2350 | if ($self->scriptConvertVersion >= 1_003_157) { | ||
| 2351 | |||
| 2352 | $client->ivPoke('mswinWinPosnTweakFlag', $dataHash{'mswin_win_posn_tweak_flag'}); | ||
| 2353 | } | ||
| 2354 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 2355 | |||
| 2356 | $client->ivPoke('shareMainWinFlag', $dataHash{'share_main_win_flag'}); | ||
| 2357 | |||
| 2358 | if ($self->scriptConvertVersion < 1_001_394) { | ||
| 2359 | |||
| 2360 | # The IV now uses the values 'default', 'on' and 'off', rather than TRUE and FALSE | ||
| 2361 | # (which didn't work as intended). Just change the value to 'default' | ||
| 2362 | $client->ivPoke('restartShareMainWinMode', 'default'); | ||
| 2363 | |||
| 2364 | } elsif ($self->scriptConvertVersion < 1_002_026) { | ||
| 2365 | |||
| 2366 | # Due to a bug, the value was set as 1 or 0, rather than 'on' or 'off' | ||
| 2367 | if ($dataHash{'restart_share_main_win_mode'}) { | ||
| 2368 | $client->ivPoke('restartShareMainWinMode', 'on'); | ||
| 2369 | } else { | ||
| 2370 | $client->ivPoke('restartShareMainWinMode', 'off'); | ||
| 2371 | } | ||
| 2372 | |||
| 2373 | } else { | ||
| 2374 | |||
| 2375 | $client->ivPoke( | ||
| 2376 | 'restartShareMainWinMode', | ||
| 2377 | $dataHash{'restart_share_main_win_mode'}, | ||
| 2378 | ); | ||
| 2379 | } | ||
| 2380 | |||
| 2381 | $client->ivPoke('activateGridFlag', $dataHash{'activate_grid_flag'}); | ||
| 2382 | } | ||
| 2383 | if ($self->scriptConvertVersion >= 1_001_164) { | ||
| 2384 | |||
| 2385 | my (%thisHash, %newHash); | ||
| 2386 | |||
| 2387 | $client->ivPoke('storeGridPosnFlag', $dataHash{'store_grid_posn_flag'}); | ||
| 2388 | |||
| 2389 | # To make the saving code simpler, 4 values were stored on a line, in the form | ||
| 2390 | # 'x y wid hei' | ||
| 2391 | %thisHash = %{$dataHash{'store_grid_posn_hash'}}; | ||
| 2392 | |||
| 2393 | foreach my $key (keys %thisHash) { | ||
| 2394 | |||
| 2395 | my $listRef = [ split(/\s+/, $thisHash{$key}) ]; | ||
| 2396 | |||
| 2397 | $newHash{$key} = $listRef; | ||
| 2398 | } | ||
| 2399 | |||
| 2400 | $client->ivPoke('storeGridPosnHash', %newHash); | ||
| 2401 | } | ||
| 2402 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 2403 | |||
| 2404 | $client->ivPoke('initWorkspaceDir', $dataHash{'init_workspace_dir'}); | ||
| 2405 | $client->ivPoke('initWorkspaceHash', %{$dataHash{'init_workspace_hash'}}); | ||
| 2406 | } | ||
| 2407 | $client->ivPoke('gridBlockSize', $dataHash{'grid_block_size'}); | ||
| 2408 | $client->ivPoke('gridGapMaxSize', $dataHash{'grid_gap_max_size'}); | ||
| 2409 | $client->ivPoke('gridAdjustmentFlag', $dataHash{'grid_adjustment_flag'}); | ||
| 2410 | $client->ivPoke('gridEdgeCorrectionFlag', $dataHash{'grid_edge_correction_flag'}); | ||
| 2411 | $client->ivPoke('gridReshuffleFlag', $dataHash{'grid_reshuffle_flag'}); | ||
| 2412 | $client->ivPoke('gridInvisWinFlag', $dataHash{'grid_invis_win_flag'}); | ||
| 2413 | |||
| 2414 | # Instructions | ||
| 2415 | $client->ivPoke('customDisplayBufferSize', $dataHash{'custom_display_buffer_size'}); | ||
| 2416 | $client->ivPoke('customCmdBufferSize', $dataHash{'custom_cmd_buffer_size'}); | ||
| 2417 | $client->ivPoke('customInstructBufferSize', $dataHash{'custom_instruct_buffer_size'}); | ||
| 2418 | $client->ivPoke('confirmWorldCmdFlag', $dataHash{'confirm_world_cmd_flag'}); | ||
| 2419 | if ($self->scriptConvertVersion >= 1_000_331) { | ||
| 2420 | |||
| 2421 | $client->ivPoke('convertWorldCmdFlag', $dataHash{'convert_world_cmd_flag'}); | ||
| 2422 | } | ||
| 2423 | $client->ivPoke('preserveWorldCmdFlag', $dataHash{'preserve_world_cmd_flag'}); | ||
| 2424 | if ($self->scriptConvertVersion >= 1_000_880) { | ||
| 2425 | |||
| 2426 | $client->ivPoke('preserveOtherCmdFlag', $dataHash{'preserve_other_cmd_flag'}); | ||
| 2427 | $client->ivPoke('maxMultiCmdFlag', $dataHash{'max_multi_cmd_flag'}); | ||
| 2428 | } | ||
| 2429 | $client->ivPoke('autoCompleteMode', $dataHash{'auto_complete_mode'}); | ||
| 2430 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 2431 | |||
| 2432 | $client->ivPoke('autoCompleteType', $dataHash{'auto_complete_type'}); | ||
| 2433 | $client->ivPoke('autoCompleteParent', $dataHash{'auto_complete_parent'}); | ||
| 2434 | } | ||
| 2435 | |||
| 2436 | # Set external applications | ||
| 2437 | $client->ivPoke('browserCmd', $dataHash{'browser_cmd'}); | ||
| 2438 | $client->ivPoke('audioCmd', $dataHash{'audio_cmd'}); | ||
| 2439 | $client->ivPoke('textEditCmd', $dataHash{'text_edit_cmd'}); | ||
| 2440 | |||
| 2441 | # Set sound effects | ||
| 2442 | $client->ivPoke('allowSoundFlag', $dataHash{'allow_sound_flag'}); | ||
| 2443 | if ($self->scriptConvertVersion >= 1_000_087) { | ||
| 2444 | |||
| 2445 | $client->ivPoke('allowAsciiBellFlag', $dataHash{'allow_ascii_bell_flag'}); | ||
| 2446 | } | ||
| 2447 | $client->ivPoke('customSoundHash', %{$dataHash{'custom_sound_hash'}}); | ||
| 2448 | |||
| 2449 | # Set text-to-speech (TTS) | ||
| 2450 | if ($self->scriptConvertVersion >= 1_000_618) { | ||
| 2451 | |||
| 2452 | $client->ivPoke('customAllowTTSFlag', $dataHash{'allow_tts_flag'}); | ||
| 2453 | if ($client->customAllowTTSFlag) { | ||
| 2454 | |||
| 2455 | $client->ivPoke('systemAllowTTSFlag', TRUE); | ||
| 2456 | } | ||
| 2457 | |||
| 2458 | $client->ivPoke('ttsSmoothFlag', $dataHash{'tts_smooth_flag'}); | ||
| 2459 | if ($self->scriptConvertVersion >= 1_002_073) { | ||
| 2460 | |||
| 2461 | $client->ivPoke('ttsHijackFlag', $dataHash{'tts_hijack_flag'}); | ||
| 2462 | } | ||
| 2463 | if ($self->scriptConvertVersion >= 1_002_213) { | ||
| 2464 | |||
| 2465 | $client->ivPoke('ttsForceHijackFlag', $dataHash{'tts_force_hijack_flag'}); | ||
| 2466 | } | ||
| 2467 | $client->ivPoke('ttsReceiveFlag', $dataHash{'tts_receive_flag'}); | ||
| 2468 | $client->ivPoke('ttsLoginFlag', $dataHash{'tts_login_flag'}); | ||
| 2469 | if ($self->scriptConvertVersion >= 1_002_212) { | ||
| 2470 | |||
| 2471 | $client->ivPoke('ttsPromptFlag', $dataHash{'tts_prompt_flag'}); | ||
| 2472 | } | ||
| 2473 | $client->ivPoke('ttsSystemFlag', $dataHash{'tts_system_flag'}); | ||
| 2474 | $client->ivPoke('ttsSystemErrorFlag', $dataHash{'tts_system_error_flag'}); | ||
| 2475 | $client->ivPoke('ttsWorldCmdFlag', $dataHash{'tts_world_cmd_flag'}); | ||
| 2476 | $client->ivPoke('ttsDialogueFlag', $dataHash{'tts_dialogue_flag'}); | ||
| 2477 | $client->ivPoke('ttsTaskFlag', $dataHash{'tts_task_flag'}); | ||
| 2478 | if ($self->scriptConvertVersion >= 1_003_105) { | ||
| 2479 | |||
| 2480 | $client->ivPoke('ttsVerboseFlag', $dataHash{'tts_verbose_flag'}); | ||
| 2481 | } | ||
| 2482 | # (Prefer an 'undef' value over an empty string) | ||
| 2483 | if ($dataHash{'tts_festival_server_port'} eq '') { | ||
| 2484 | $client->ivUndef('ttsFestivalServerPort'); | ||
| 2485 | } else { | ||
| 2486 | $client->ivPoke('ttsFestivalServerPort', $dataHash{'tts_festival_server_port'}); | ||
| 2487 | } | ||
| 2488 | if ($self->scriptConvertVersion >= 1_003_110) { | ||
| 2489 | |||
| 2490 | $client->ivPoke('blindHelpMsgShownFlag', $dataHash{'blind_help_msg_shown_flag'}); | ||
| 2491 | } | ||
| 2492 | } | ||
| 2493 | |||
| 2494 | # Set telnet option negotiation flags | ||
| 2495 | if ($self->scriptConvertVersion >= 1_000_156) { | ||
| 2496 | |||
| 2497 | $client->ivPoke('useEchoFlag', $dataHash{'use_echo_flag'}); | ||
| 2498 | $client->ivPoke('useTTypeFlag', $dataHash{'use_ttype_flag'}); | ||
| 2499 | } | ||
| 2500 | $client->ivPoke('useNawsFlag', $dataHash{'use_naws_flag'}); | ||
| 2501 | if ($self->scriptConvertVersion >= 1_000_156) { | ||
| 2502 | |||
| 2503 | $client->ivPoke('useCharSetFlag', $dataHash{'use_charset_flag'}); | ||
| 2504 | } | ||
| 2505 | if ($self->scriptConvertVersion >= 1_000_163) { | ||
| 2506 | |||
| 2507 | $client->ivPoke('useEorFlag', $dataHash{'use_eor_flag'}); | ||
| 2508 | } | ||
| 2509 | if ($self->scriptConvertVersion >= 1_000_879) { | ||
| 2510 | |||
| 2511 | $client->ivPoke('useSgaFlag', $dataHash{'use_sga_flag'}); | ||
| 2512 | $client->ivPoke('useNewEnvironFlag', $dataHash{'use_new_environ_flag'}); | ||
| 2513 | } | ||
| 2514 | |||
| 2515 | # Set MUD protocol flags | ||
| 2516 | $client->ivPoke('useMccpFlag', $dataHash{'use_mccp_flag'}); | ||
| 2517 | if ($self->scriptConvertVersion >= 1_000_156) { | ||
| 2518 | |||
| 2519 | $client->ivPoke('useMsdpFlag', $dataHash{'use_msdp_flag'}); | ||
| 2520 | $client->ivPoke('useMsspFlag', $dataHash{'use_mssp_flag'}); | ||
| 2521 | $client->ivPoke('useMttsFlag', $dataHash{'use_mtts_flag'}); | ||
| 2522 | } | ||
| 2523 | if ($self->scriptConvertVersion >= 1_002_095) { | ||
| 2524 | |||
| 2525 | $client->ivPoke('useMnesFlag', $dataHash{'use_mnes_flag'}); | ||
| 2526 | } | ||
| 2527 | $client->ivPoke('useMxpFlag', $dataHash{'use_mxp_flag'}); | ||
| 2528 | $client->ivPoke('useMspFlag', $dataHash{'use_msp_flag'}); | ||
| 2529 | if ($self->scriptConvertVersion >= 1_000_844) { | ||
| 2530 | |||
| 2531 | $client->ivPoke('usePuebloFlag', $dataHash{'use_pueblo_flag'}); | ||
| 2532 | } | ||
| 2533 | if ($self->scriptConvertVersion >= 1_000_850) { | ||
| 2534 | |||
| 2535 | $client->ivPoke('useAtcpFlag', $dataHash{'use_atcp_flag'}); | ||
| 2536 | $client->ivPoke('useGmcpFlag', $dataHash{'use_gmcp_flag'}); | ||
| 2537 | } | ||
| 2538 | if ($self->scriptConvertVersion >= 1_000_879) { | ||
| 2539 | |||
| 2540 | $client->ivPoke('useZmpFlag', $dataHash{'use_zmp_flag'}); | ||
| 2541 | $client->ivPoke('useAard102Flag', $dataHash{'use_aard102_flag'}); | ||
| 2542 | $client->ivPoke('useMcpFlag', $dataHash{'use_mcp_flag'}); | ||
| 2543 | } | ||
| 2544 | if ($self->scriptConvertVersion >= 1_000_832) { | ||
| 2545 | |||
| 2546 | $client->ivPoke('allowMxpFontFlag', $dataHash{'allow_mxp_font_flag'}); | ||
| 2547 | $client->ivPoke('allowMxpImageFlag', $dataHash{'allow_mxp_image_flag'}); | ||
| 2548 | $client->ivPoke('allowMxpLoadImageFlag', $dataHash{'allow_mxp_load_image_flag'}); | ||
| 2549 | $client->ivPoke('allowMxpFilterImageFlag', $dataHash{'allow_mxp_filter_image_flag'}); | ||
| 2550 | $client->ivPoke('allowMxpSoundFlag', $dataHash{'allow_mxp_sound_flag'}); | ||
| 2551 | $client->ivPoke('allowMxpLoadSoundFlag', $dataHash{'allow_mxp_load_sound_flag'}); | ||
| 2552 | $client->ivPoke('allowMxpGaugeFlag', $dataHash{'allow_mxp_gauge_flag'}); | ||
| 2553 | $client->ivPoke('allowMxpFrameFlag', $dataHash{'allow_mxp_frame_flag'}); | ||
| 2554 | $client->ivPoke('allowMxpInteriorFlag', $dataHash{'allow_mxp_interior_flag'}); | ||
| 2555 | $client->ivPoke('allowMxpCrosslinkFlag', $dataHash{'allow_mxp_crosslink_flag'}); | ||
| 2556 | } | ||
| 2557 | if ($self->scriptConvertVersion >= 1_000_887) { | ||
| 2558 | |||
| 2559 | $client->ivPoke('allowMxpRoomFlag', $dataHash{'allow_mxp_room_flag'}); | ||
| 2560 | } | ||
| 2561 | if ($self->scriptConvertVersion >= 1_001_510) { | ||
| 2562 | |||
| 2563 | $client->ivPoke('allowMxpFlexibleFlag', $dataHash{'allow_mxp_flexible_flag'}); | ||
| 2564 | } | ||
| 2565 | if ($self->scriptConvertVersion >= 1_002_020) { | ||
| 2566 | |||
| 2567 | $client->ivPoke('allowMxpPermFlag', $dataHash{'allow_mxp_perm_flag'}); | ||
| 2568 | } | ||
| 2569 | if ($self->scriptConvertVersion >= 1_000_678) { | ||
| 2570 | |||
| 2571 | $client->ivPoke('allowMspMultipleFlag', $dataHash{'allow_msp_multiple_flag'}); | ||
| 2572 | $client->ivPoke('allowMspLoadSoundFlag', $dataHash{'allow_msp_load_sound_flag'}); | ||
| 2573 | } | ||
| 2574 | if ($self->scriptConvertVersion >= 1_000_886) { | ||
| 2575 | |||
| 2576 | $client->ivPoke('allowMspFlexibleFlag', $dataHash{'allow_msp_flexible_flag'}); | ||
| 2577 | } | ||
| 2578 | if ($self->scriptConvertVersion >= 1_002_095) { | ||
| 2579 | |||
| 2580 | $client->ivPoke('allowMnesSendIPFlag', $dataHash{'allow_mnes_send_ip_flag'}); | ||
| 2581 | } | ||
| 2582 | # Set telnet option negotiation customisation IVs | ||
| 2583 | if ($self->scriptConvertVersion >= 1_000_160) { | ||
| 2584 | |||
| 2585 | $client->ivPoke('termTypeMode', $dataHash{'term_type_mode'}); | ||
| 2586 | $client->ivPoke('customClientName', $dataHash{'custom_client_name'}); | ||
| 2587 | } | ||
| 2588 | if ($self->scriptConvertVersion >= 1_000_666) { | ||
| 2589 | |||
| 2590 | $client->ivPoke('customClientVersion', $dataHash{'custom_client_version'}); | ||
| 2591 | } | ||
| 2592 | if ($self->scriptConvertVersion >= 1_001_213) { | ||
| 2593 | |||
| 2594 | $client->ivPoke('useCtrlSeqFlag', $dataHash{'use_ctrl_seq_flag'}); | ||
| 2595 | $client->ivPoke('useVisibleCursorFlag', $dataHash{'use_visible_cursor_flag'}); | ||
| 2596 | $client->ivPoke('useFastCursorFlag', $dataHash{'use_fast_cursor_flag'}); | ||
| 2597 | $client->ivPoke('useDirectKeysFlag', $dataHash{'use_direct_keys_flag'}); | ||
| 2598 | } | ||
| 2599 | # Set telnet negotiation debug flags | ||
| 2600 | if ($self->scriptConvertVersion >= 1_001_214) { | ||
| 2601 | |||
| 2602 | $client->ivPoke('debugEscSequenceFlag', $dataHash{'debug_esc_sequence_flag'}); | ||
| 2603 | } | ||
| 2604 | if ($self->scriptConvertVersion >= 1_000_378) { | ||
| 2605 | |||
| 2606 | $client->ivPoke('debugTelnetFlag', $dataHash{'debug_telnet_flag'}); | ||
| 2607 | $client->ivPoke('debugTelnetMiniFlag', $dataHash{'debug_telnet_mini_flag'}); | ||
| 2608 | } | ||
| 2609 | if ($self->scriptConvertVersion >= 1_000_895) { | ||
| 2610 | |||
| 2611 | $client->ivPoke('debugTelnetLogFlag', $dataHash{'debug_telnet_log_flag'}); | ||
| 2612 | } | ||
| 2613 | if ($self->scriptConvertVersion >= 1_000_378) { | ||
| 2614 | |||
| 2615 | $client->ivPoke('debugMsdpFlag', $dataHash{'debug_msdp_flag'}); | ||
| 2616 | } | ||
| 2617 | if ($self->scriptConvertVersion >= 1_000_405) { | ||
| 2618 | |||
| 2619 | $client->ivPoke('debugMxpFlag', $dataHash{'debug_mxp_flag'}); | ||
| 2620 | $client->ivPoke('debugMxpCommentFlag', $dataHash{'debug_mxp_comment_flag'}); | ||
| 2621 | } | ||
| 2622 | if ($self->scriptConvertVersion >= 1_000_849) { | ||
| 2623 | |||
| 2624 | $client->ivPoke('debugPuebloFlag', $dataHash{'debug_pueblo_flag'}); | ||
| 2625 | $client->ivPoke('debugPuebloCommentFlag', $dataHash{'debug_pueblo_comment_flag'}); | ||
| 2626 | } | ||
| 2627 | if ($self->scriptConvertVersion >= 1_001_140) { | ||
| 2628 | |||
| 2629 | $client->ivPoke('debugZmpFlag', $dataHash{'debug_zmp_flag'}); | ||
| 2630 | } | ||
| 2631 | if ($self->scriptConvertVersion >= 1_000_926) { | ||
| 2632 | |||
| 2633 | $client->ivPoke('debugAtcpFlag', $dataHash{'debug_atcp_flag'}); | ||
| 2634 | $client->ivPoke('debugGmcpFlag', $dataHash{'debug_gmcp_flag'}); | ||
| 2635 | } | ||
| 2636 | if ($self->scriptConvertVersion >= 1_001_158) { | ||
| 2637 | |||
| 2638 | $client->ivPoke('debugMcpFlag', $dataHash{'debug_mcp_flag'}); | ||
| 2639 | } | ||
| 2640 | |||
| 2641 | # Set misc data | ||
| 2642 | $client->ivPoke('customMonthList', @{$dataHash{'custom_month_list'}}); | ||
| 2643 | $client->ivPoke('customDayList', @{$dataHash{'custom_day_list'}}); | ||
| 2644 | if ($self->scriptConvertVersion >= 1_001_262) { | ||
| 2645 | |||
| 2646 | $client->ivPoke('commifyMode', $dataHash{'commify_mode'}); | ||
| 2647 | } | ||
| 2648 | if ($self->scriptConvertVersion >= 1_001_284) { | ||
| 2649 | |||
| 2650 | $client->ivPoke('shortUrlFlag', $dataHash{'short_url_flag'}); | ||
| 2651 | } | ||
| 2652 | if ($self->scriptConvertVersion >= 1_002_166) { | ||
| 2653 | |||
| 2654 | $client->ivPoke('ipLookupList', @{$dataHash{'ip_lookup_list'}}); | ||
| 2655 | } | ||
| 2656 | $client->ivPoke('promptWaitTime', $dataHash{'prompt_wait_time'}); | ||
| 2657 | $client->ivPoke('loginWarningTime', $dataHash{'login_warning_time'}); | ||
| 2658 | if ($self->scriptConvertVersion >= 1_000_331) { | ||
| 2659 | |||
| 2660 | if ($self->scriptConvertVersion <= 1_000_535) { | ||
| 2661 | |||
| 2662 | $client->ivPoke('debugLineNumsFlag', $dataHash{'debug_world_flag'}); | ||
| 2663 | $client->ivPoke('debugLineTagsFlag', $dataHash{'debug_world_flag'}); | ||
| 2664 | |||
| 2665 | } else { | ||
| 2666 | |||
| 2667 | $client->ivPoke('debugLineNumsFlag', $dataHash{'debug_line_nums_flag'}); | ||
| 2668 | $client->ivPoke('debugLineTagsFlag', $dataHash{'debug_line_tags_flag'}); | ||
| 2669 | } | ||
| 2670 | } | ||
| 2671 | $client->ivPoke('debugLocatorFlag', $dataHash{'debug_locator_flag'}); | ||
| 2672 | if ($self->scriptConvertVersion >= 1_000_482) { | ||
| 2673 | |||
| 2674 | $client->ivPoke('debugMaxLocatorFlag', $dataHash{'debug_max_locator_flag'}); | ||
| 2675 | } | ||
| 2676 | if ($self->scriptConvertVersion >= 1_001_282) { | ||
| 2677 | |||
| 2678 | $client->ivPoke('debugExitFlag', $dataHash{'debug_exit_flag'}); | ||
| 2679 | } | ||
| 2680 | $client->ivPoke('debugMoveListFlag', $dataHash{'debug_move_list_flag'}); | ||
| 2681 | $client->ivPoke('debugParseObjFlag', $dataHash{'debug_parse_obj_flag'}); | ||
| 2682 | $client->ivPoke('debugCompareObjFlag', $dataHash{'debug_compare_obj_flag'}); | ||
| 2683 | $client->ivPoke('debugExplainPluginFlag', $dataHash{'debug_explain_plugin_flag'}); | ||
| 2684 | $client->ivPoke('debugCheckIVFlag', $dataHash{'debug_check_iv_flag'}); | ||
| 2685 | if ($self->scriptConvertVersion >= 1_000_800) { | ||
| 2686 | |||
| 2687 | $client->ivPoke('debugTableFitFlag', $dataHash{'debug_table_fit_flag'}); | ||
| 2688 | } | ||
| 2689 | $client->ivPoke('debugTrapErrorFlag', $dataHash{'debug_trap_error_flag'}); | ||
| 2690 | if ($self->scriptConvertVersion >= 1_000_949) { | ||
| 2691 | |||
| 2692 | $client->ivPoke('toolbarLabelFlag', $dataHash{'toolbar_label_flag'}); | ||
| 2693 | } | ||
| 2694 | $client->ivPoke('irreversibleIconFlag', $dataHash{'irreversible_icon_flag'}); | ||
| 2695 | if ($self->scriptConvertVersion >= 1_001_136) { | ||
| 2696 | |||
| 2697 | $client->ivPoke('allowBusyWinFlag', $dataHash{'allow_busy_win_flag'}); | ||
| 2698 | } | ||
| 2699 | if ($self->scriptConvertVersion >= 1_001_202) { | ||
| 2700 | |||
| 2701 | $client->ivPoke('mainWinSystemMsgFlag', $dataHash{'main_win_system_msg_flag'}); | ||
| 2702 | } | ||
| 2703 | if ($self->scriptConvertVersion >= 1_000_344) { | ||
| 2704 | |||
| 2705 | $client->ivPoke('mainWinUrgencyFlag', $dataHash{'main_win_urgency_flag'}); | ||
| 2706 | } | ||
| 2707 | if ($self->scriptConvertVersion >= 1_000_883) { | ||
| 2708 | |||
| 2709 | $client->ivPoke('mainWinTooltipFlag', $dataHash{'main_win_tooltip_flag'}); | ||
| 2710 | } | ||
| 2711 | $client->ivPoke('sessionTabMode', $dataHash{'session_tab_mode'}); | ||
| 2712 | if ($self->scriptConvertVersion >= 1_000_184) { | ||
| 2713 | |||
| 2714 | $client->ivPoke('xTermTitleFlag', $dataHash{'xterm_title_flag'}); | ||
| 2715 | } | ||
| 2716 | if ($self->scriptConvertVersion >= 1_000_365) { | ||
| 2717 | |||
| 2718 | $client->ivPoke('longTabLabelFlag', $dataHash{'long_tab_label_flag'}); | ||
| 2719 | $client->ivPoke('simpleTabFlag', $dataHash{'simple_tab_flag'}); | ||
| 2720 | } | ||
| 2721 | if ($self->scriptConvertVersion >= 1_000_917) { | ||
| 2722 | |||
| 2723 | $client->ivPoke('confirmCloseMainWinFlag', $dataHash{'confirm_close_main_win_flag'}); | ||
| 2724 | $client->ivPoke('confirmCloseTabFlag', $dataHash{'confirm_close_tab_flag'}); | ||
| 2725 | } | ||
| 2726 | if ($self->scriptConvertVersion >= 1_002_102) { | ||
| 2727 | |||
| 2728 | $client->ivPoke('confirmCloseMenuFlag', $dataHash{'confirm_close_menu_flag'}); | ||
| 2729 | $client->ivPoke( | ||
| 2730 | 'confirmCloseToolButtonFlag', | ||
| 2731 | $dataHash{'confirm_close_tool_button_flag'}, | ||
| 2732 | ); | ||
| 2733 | } | ||
| 2734 | if ($self->scriptConvertVersion >= 1_000_185) { | ||
| 2735 | |||
| 2736 | $client->ivPoke('charSet', $dataHash{'char_set'}); | ||
| 2737 | } | ||
| 2738 | if ($self->scriptConvertVersion >= 1_000_616) { | ||
| 2739 | |||
| 2740 | $client->ivPoke('sessionMax', $dataHash{'session_max'}); | ||
| 2741 | } | ||
| 2742 | if ($self->scriptConvertVersion >= 1_001_256) { | ||
| 2743 | |||
| 2744 | $client->ivPoke('offlineOnDisconnectFlag', $dataHash{'offline_on_disconnect_flag'}); | ||
| 2745 | } | ||
| 2746 | if ($self->scriptConvertVersion >= 1_000_884) { | ||
| 2747 | |||
| 2748 | $client->ivPoke('connectHistoryFlag', $dataHash{'connect_history_flag'}); | ||
| 2749 | } | ||
| 2750 | if ($self->scriptConvertVersion >= 1_000_338) { | ||
| 2751 | |||
| 2752 | $client->ivPoke('useScrollKeysFlag', $dataHash{'use_scroll_keys_flag'}); | ||
| 2753 | } | ||
| 2754 | if ($self->scriptConvertVersion >= 1_000_884) { | ||
| 2755 | |||
| 2756 | $client->ivPoke('smoothScrollKeysFlag', $dataHash{'smooth_scroll_keys_flag'}); | ||
| 2757 | $client->ivPoke('autoSplitKeysFlag', $dataHash{'auto_split_keys_flag'}); | ||
| 2758 | } | ||
| 2759 | if ($self->scriptConvertVersion >= 1_000_338) { | ||
| 2760 | |||
| 2761 | $client->ivPoke('useCompleteKeysFlag', $dataHash{'use_complete_keys_flag'}); | ||
| 2762 | $client->ivPoke('useSwitchKeysFlag', $dataHash{'use_switch_keys_flag'}); | ||
| 2763 | } | ||
| 2764 | |||
| 2765 | ###################### | ||
| 2766 | # Load complete | ||
| 2767 | |||
| 2768 | # If the loaded config file was saved by an earlier version of Axmud than the one we're | ||
| 2769 | # using now, the file object's data must be marked as needing to be saved (in case the | ||
| 2770 | # config file uses new IVs) | ||
| 2771 | if ($self->scriptConvertVersion < $axmud::CLIENT->convertVersion($axmud::VERSION)) { | ||
| 2772 | |||
| 2773 | $self->set_modifyFlag(TRUE, $self->_objClass . '->loadConfigFile'); | ||
| 2774 | |||
| 2775 | } else { | ||
| 2776 | |||
| 2777 | # Otherwise, mark the file object's data as not needing to be saved | ||
| 2778 | $self->set_modifyFlag(FALSE, $self->_objClass . '->loadConfigFile'); | ||
| 2779 | } | ||
| 2780 | |||
| 2781 | return 1; | ||
| 2782 | } | ||
| 2783 | |||
| 2784 | sub setupDataFile { | ||
| 2785 | |||
| 2786 | # Called by GA::Client->loadOtherFiles for the file types: | ||
| 2787 | # 'tasks', 'scripts', 'contacts', 'dicts', 'toolbar', 'usercmds', 'zonemaps', 'winmaps', | ||
| 2788 | # 'tts' | ||
| 2789 | # Loads a data file. If the file doesn't exist, creates it | ||
| 2790 | # | ||
| 2791 | # Expected arguments | ||
| 2792 | # (none besides $self) | ||
| 2793 | # | ||
| 2794 | # Return values | ||
| 2795 | # 'undef' on improper arguments, or if there any errors reading/writing the file, or if | ||
| 2796 | # file loading/saving isn't allowed (because of global flags) | ||
| 2797 | # 1 otherwise | ||
| 2798 | |||
| 2799 | my ($self, $check) = @_; | ||
| 2800 | |||
| 2801 | # Local variables | ||
| 2802 | my $obj; | ||
| 2803 | |||
| 2804 | # Check for improper arguments | ||
| 2805 | if (defined $check) { | ||
| 2806 | |||
| 2807 | return $axmud::CLIENT->writeImproper($self->_objClass . '->setupDataFile', @_); | ||
| 2808 | } | ||
| 2809 | |||
| 2810 | # Check it's the right file type for this function | ||
| 2811 | if ( | ||
| 2812 | $self->fileType ne 'tasks' && $self->fileType ne 'scripts' | ||
| 2813 | && $self->fileType ne 'contacts' && $self->fileType ne 'dicts' | ||
| 2814 | && $self->fileType ne 'toolbar' && $self->fileType ne 'usercmds' | ||
| 2815 | && $self->fileType ne 'zonemaps' && $self->fileType ne 'winmaps' | ||
| 2816 | && $self->fileType ne 'tts' | ||
| 2817 | ) { | ||
| 2818 | return $self->writeError( | ||
| 2819 | 'Wrong file type \'' . $self->fileType . '\'', | ||
| 2820 | $self->_objClass . '->setupDataFile', | ||
| 2821 | ); | ||
| 2822 | } | ||
| 2823 | |||
| 2824 | # Check whether the data file already exists, and if we're allowed to load it | ||
| 2825 | if ($axmud::CLIENT->loadDataFlag && -e $axmud::DATA_DIR . $self->standardPath) { | ||
| 2826 | |||
| 2827 | # The file exists and we are allowed to load it, so try to load it (in overwrite mode) | ||
| 2828 | if (! $self->loadDataFile()) { | ||
| 2829 | |||
| 2830 | # Try loading the automatic backup, i.e. 'otherprof.axm.bu' | ||
| 2831 | if (! $self->loadDataFile(undef, undef, undef, TRUE)) { | ||
| 2832 | |||
| 2833 | return $self->writeError( | ||
| 2834 | 'Error reading \'' . $self->fileType . '\' data file', | ||
| 2835 | $self->_objClass . '->setupDataFile', | ||
| 2836 | ); | ||
| 2837 | |||
| 2838 | } else { | ||
| 2839 | |||
| 2840 | # The contents of the backup, now loaded into memory, must be saved at some | ||
| 2841 | # point | ||
| 2842 | $self->ivPoke('modifyFlag', TRUE); | ||
| 2843 | # Don't overwrite the existing backup file with the faulty one | ||
| 2844 | $self->ivPoke('preserveBackupFlag', TRUE); | ||
| 2845 | |||
| 2846 | # File loaded (from backup) | ||
| 2847 | return 1; | ||
| 2848 | } | ||
| 2849 | |||
| 2850 | } else { | ||
| 2851 | |||
| 2852 | # File loaded | ||
| 2853 | return 1; | ||
| 2854 | } | ||
| 2855 | |||
| 2856 | } elsif ($axmud::CLIENT->saveDataFlag && ! (-e $axmud::DATA_DIR . $self->standardPath)) { | ||
| 2857 | |||
| 2858 | # The file doesn't exist, but we are allowed to create it | ||
| 2859 | if (! $self->saveDataFile()) { | ||
| 2860 | |||
| 2861 | return $self->writeError( | ||
| 2862 | 'Error creating \'' . $self->fileType . '\' data file', | ||
| 2863 | $self->_objClass . '->setupDataFile', | ||
| 2864 | ); | ||
| 2865 | |||
| 2866 | } else { | ||
| 2867 | |||
| 2868 | # File created | ||
| 2869 | return 1; | ||
| 2870 | } | ||
| 2871 | |||
| 2872 | } else { | ||
| 2873 | |||
| 2874 | # Cannot load or save the data file | ||
| 2875 | return undef; | ||
| 2876 | } | ||
| 2877 | } | ||
| 2878 | |||
| 2879 | sub saveDataFile { | ||
| 2880 | |||
| 2881 | # Called by $self->setupDataFile (or by any other function) for the file types: | ||
| 2882 | # 'tasks', 'scripts', 'contacts', 'dicts', 'toolbar', 'usercmds', 'zonemaps', 'winmaps', | ||
| 2883 | # 'tts' | ||
| 2884 | # Called by any function for the file types: | ||
| 2885 | # 'worldprof', 'otherprof', 'worldmodel' | ||
| 2886 | # | ||
| 2887 | # Saves a data file of the type specified by $self->fileType | ||
| 2888 | # | ||
| 2889 | # Expected arguments | ||
| 2890 | # (none besides $self) | ||
| 2891 | # | ||
| 2892 | # Optional arguments | ||
| 2893 | # $fileName - The file name, e.g. 'tasks.axm' | ||
| 2894 | # $path - The full path, e.g. '/home/me/axmud-data/data/tasks.axm' | ||
| 2895 | # $dir - The directory, e.g. '/home/me/axmud-data/data/' | ||
| 2896 | # $emergFlag - If set to TRUE, an emergency save is in progress. | ||
| 2897 | # GA::Client->saveDataFlag is ignored, $self->disableAllFileAccess is not | ||
| 2898 | # called on failure, and $self->modifyFlag is not set. Set to FALSE (or | ||
| 2899 | # 'undef') if an emergency save is not in progress | ||
| 2900 | # | ||
| 2901 | # Notes: | ||
| 2902 | # If $fileName is specified, $path and $dir must also be specified | ||
| 2903 | # If $fileName is not specified, the default filename, path and directory for this file | ||
| 2904 | # type are used | ||
| 2905 | # | ||
| 2906 | # Return values | ||
| 2907 | # 'undef' on improper arguments, if saving of data files isn't allowed (because of global | ||
| 2908 | # flags) or if there is an error saving the data file itself | ||
| 2909 | # 1 otherwise | ||
| 2910 | |||
| 2911 | my ($self, $fileName, $path, $dir, $emergFlag, $check) = @_; | ||
| 2912 | |||
| 2913 | # Local variables | ||
| 2914 | my ( | ||
| 2915 | $checkWorldObj, $count, $buPath, | ||
| 2916 | %saveHash, %preserveHash, %reverseHash, %importHash, %usrCmdHash, | ||
| 2917 | ); | ||
| 2918 | |||
| 2919 | # Check for improper arguments | ||
| 2920 | if ( | ||
| 2921 | defined $check | ||
| 2922 | || (defined $fileName && (! defined $path || ! defined $dir)) | ||
| 2923 | || (defined $path && (! defined $fileName || ! defined $dir)) | ||
| 2924 | || (defined $dir && (! defined $fileName || ! defined $path)) | ||
| 2925 | ) { | ||
| 2926 | return $axmud::CLIENT->writeImproper($self->_objClass . '->saveDataFile', @_); | ||
| 2927 | } | ||
| 2928 | |||
| 2929 | # Check it's the right file type for this function | ||
| 2930 | if ($self->fileType eq 'config') { | ||
| 2931 | |||
| 2932 | return $self->writeError( | ||
| 2933 | 'Wrong file type \'' . $self->fileType . '\'', | ||
| 2934 | $self->_objClass . '->saveDataFile', | ||
| 2935 | ); | ||
| 2936 | } | ||
| 2937 | |||
| 2938 | # Set the filename, path and directory, if not specified | ||
| 2939 | if (! defined $fileName) { | ||
| 2940 | |||
| 2941 | $fileName = $self->standardFileName; | ||
| 2942 | $path = $axmud::DATA_DIR . $self->standardPath; | ||
| 2943 | $dir = $axmud::DATA_DIR . $self->standardDir; | ||
| 2944 | } | ||
| 2945 | |||
| 2946 | # Checks made when an emergency save is NOT in progress... | ||
| 2947 | if (! $emergFlag) { | ||
| 2948 | |||
| 2949 | # Don't save anything if the global flag forbids it | ||
| 2950 | if (! $axmud::CLIENT->saveDataFlag) { | ||
| 2951 | |||
| 2952 | return undef; | ||
| 2953 | } | ||
| 2954 | |||
| 2955 | # Don't save 'worldprof', 'otherprof' and 'worldmodel' files associated with a world | ||
| 2956 | # profile whose ->noSaveFlag is set | ||
| 2957 | if ( | ||
| 2958 | $self->fileType eq 'worldprof' || $self->fileType eq 'otherprof' | ||
| 2959 | || $self->fileType eq 'worldmodel' | ||
| 2960 | ) { | ||
| 2961 | $checkWorldObj = $axmud::CLIENT->ivShow('worldProfHash', $self->assocWorldProf); | ||
| 2962 | |||
| 2963 | # (During a ';cloneworld' operation, the cloned world profile won't have been added | ||
| 2964 | # to ->worldProfHash; but ;cloneworld can't be used on (original) profiles whose | ||
| 2965 | # ->noSaveFlag is set, so if $checkWorldObj is 'undef', we don't need to check its | ||
| 2966 | # ->noSaveFlag) | ||
| 2967 | if ($checkWorldObj && $checkWorldObj->noSaveFlag) { | ||
| 2968 | |||
| 2969 | return undef; | ||
| 2970 | } | ||
| 2971 | } | ||
| 2972 | } | ||
| 2973 | |||
| 2974 | # Check that the data directory exists and, if it doesn't, try to create it | ||
| 2975 | if (! (-d $dir)) { | ||
| 2976 | |||
| 2977 | if (! mkdir ($dir, 0755)) { | ||
| 2978 | |||
| 2979 | return undef; | ||
| 2980 | } | ||
| 2981 | } | ||
| 2982 | |||
| 2983 | # For the file type 'worldmodel', we might use a single monolithic file or, if the model is | ||
| 2984 | # large, multiple smaller ones. A single monolithic file is handled by this function; | ||
| 2985 | # multiple files are handled by a call to $self->saveDataFile_worldModel | ||
| 2986 | if ($self->fileType eq 'worldmodel') { | ||
| 2987 | |||
| 2988 | if ( | ||
| 2989 | ! $emergFlag | ||
| 2990 | && $axmud::CLIENT->allowModelSplitFlag | ||
| 2991 | && $self->session->worldModelObj->ivPairs('modelHash') | ||
| 2992 | > $axmud::CLIENT->modelSplitSize | ||
| 2993 | ) { | ||
| 2994 | return $self->saveDataFile_worldModel($fileName, $path, $dir); | ||
| 2995 | } else { | ||
| 2996 | $self->session->worldModelObj->ivPoke('modelSaveFileCount', 0); | ||
| 2997 | } | ||
| 2998 | } | ||
| 2999 | |||
| 3000 | # Otherwise, compile a special hash, %saveHash, that references all the data we want to save | ||
| 3001 | |||
| 3002 | # First compile the header information (i.e. metadata)... | ||
| 3003 | $saveHash{'file_type'} = $self->fileType; | ||
| 3004 | $saveHash{'script_name'} = $axmud::NAME_FILE; | ||
| 3005 | $saveHash{'script_version'} = $axmud::VERSION; | ||
| 3006 | $saveHash{'save_date'} = $axmud::CLIENT->localDate(); | ||
| 3007 | $saveHash{'save_time'} = $axmud::CLIENT->localTime(); | ||
| 3008 | $saveHash{'assoc_world_prof'} = $self->assocWorldProf; | ||
| 3009 | |||
| 3010 | # ...then compile the data for this file type | ||
| 3011 | if ($self->fileType eq 'worldprof') { | ||
| 3012 | |||
| 3013 | $saveHash{'world_prof'} | ||
| 3014 | = $axmud::CLIENT->ivShow('worldProfHash', $self->assocWorldProf); | ||
| 3015 | |||
| 3016 | } elsif ($self->fileType eq 'otherprof') { | ||
| 3017 | |||
| 3018 | my %profHash; | ||
| 3019 | |||
| 3020 | # From GA::Session->profHash, remove the current world profile, leaving all non-world | ||
| 3021 | # profiles | ||
| 3022 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 3023 | |||
| 3024 | if ($profObj->category ne 'world') { | ||
| 3025 | |||
| 3026 | $profHash{$profObj->name} = $self->session->ivShow('profHash', $profObj->name); | ||
| 3027 | } | ||
| 3028 | } | ||
| 3029 | |||
| 3030 | $saveHash{'prof_priority_list'} = [$self->session->profPriorityList]; | ||
| 3031 | $saveHash{'template_hash'} = {$self->session->templateHash}; | ||
| 3032 | $saveHash{'prof_hash'} = \%profHash; | ||
| 3033 | $saveHash{'cage_hash'} = {$self->session->cageHash}; | ||
| 3034 | |||
| 3035 | } elsif ($self->fileType eq 'worldmodel') { | ||
| 3036 | |||
| 3037 | $saveHash{'world_model_obj'} = $self->session->worldModelObj; | ||
| 3038 | |||
| 3039 | } elsif ($self->fileType eq 'tasks') { | ||
| 3040 | |||
| 3041 | $saveHash{'task_label_hash'} = {$axmud::CLIENT->taskLabelHash}; | ||
| 3042 | $saveHash{'task_run_first_list'} = [$axmud::CLIENT->taskRunFirstList]; | ||
| 3043 | $saveHash{'task_run_last_list'} = [$axmud::CLIENT->taskRunLastList]; | ||
| 3044 | $saveHash{'init_task_hash'} = {$axmud::CLIENT->initTaskHash}; | ||
| 3045 | $saveHash{'init_task_order_list'} = [$axmud::CLIENT->initTaskOrderList]; | ||
| 3046 | $saveHash{'init_task_total'} = $axmud::CLIENT->initTaskTotal; | ||
| 3047 | $saveHash{'custom_task_hash'} = {$axmud::CLIENT->customTaskHash}; | ||
| 3048 | |||
| 3049 | } elsif ($self->fileType eq 'scripts') { | ||
| 3050 | |||
| 3051 | $saveHash{'script_dir_list'} = [$axmud::CLIENT->scriptDirList]; | ||
| 3052 | $saveHash{'init_script_hash'} = {$axmud::CLIENT->initScriptHash}; | ||
| 3053 | $saveHash{'init_script_order_list'} = [$axmud::CLIENT->initScriptOrderList]; | ||
| 3054 | |||
| 3055 | } elsif ($self->fileType eq 'contacts') { | ||
| 3056 | |||
| 3057 | $saveHash{'chat_name'} = $axmud::CLIENT->chatName; | ||
| 3058 | $saveHash{'chat_email'} = $axmud::CLIENT->chatEmail; | ||
| 3059 | $saveHash{'chat_accept_mode'} = $axmud::CLIENT->chatAcceptMode; | ||
| 3060 | $saveHash{'chat_contact_hash'} = {$axmud::CLIENT->chatContactHash}; | ||
| 3061 | $saveHash{'chat_icon'} = $axmud::CLIENT->chatIcon; | ||
| 3062 | $saveHash{'chat_smiley_hash'} = {$axmud::CLIENT->chatSmileyHash}; | ||
| 3063 | |||
| 3064 | } elsif ($self->fileType eq 'dicts') { | ||
| 3065 | |||
| 3066 | $saveHash{'dict_hash'} = {$axmud::CLIENT->dictHash}; | ||
| 3067 | |||
| 3068 | } elsif ($self->fileType eq 'toolbar') { | ||
| 3069 | |||
| 3070 | $saveHash{'toolbar_hash'} = {$axmud::CLIENT->toolbarHash}; | ||
| 3071 | $saveHash{'toolbar_list'} = [$axmud::CLIENT->toolbarList]; | ||
| 3072 | |||
| 3073 | } elsif ($self->fileType eq 'usercmds') { | ||
| 3074 | |||
| 3075 | # We don't store user commands for client commands supplied by plugins. If we do, the | ||
| 3076 | # user will get a lot of nasty errors when they try to use Axmud without loading those | ||
| 3077 | # plugins | ||
| 3078 | # However, we do still store all user commands that the user has created for standard | ||
| 3079 | # client commands like ';help' and ';about' | ||
| 3080 | %reverseHash = $axmud::CLIENT->constUserCmdHash; | ||
| 3081 | %importHash = $axmud::CLIENT->userCmdHash; | ||
| 3082 | foreach my $userCmd (keys %importHash) { | ||
| 3083 | |||
| 3084 | my $standardCmd = $importHash{$userCmd}; | ||
| 3085 | |||
| 3086 | if (exists $reverseHash{$standardCmd}) { | ||
| 3087 | |||
| 3088 | $usrCmdHash{$userCmd} = $standardCmd; | ||
| 3089 | } | ||
| 3090 | } | ||
| 3091 | |||
| 3092 | $saveHash{'user_cmd_hash'} = \%usrCmdHash; | ||
| 3093 | |||
| 3094 | } elsif ($self->fileType eq 'zonemaps') { | ||
| 3095 | |||
| 3096 | my %zonemapHash; | ||
| 3097 | |||
| 3098 | # (Temporary zonemaps can't be saved, so we must remove them before saving) | ||
| 3099 | foreach my $zonemapObj ($axmud::CLIENT->ivValues('zonemapHash')) { | ||
| 3100 | |||
| 3101 | if (! $zonemapObj->tempFlag) { | ||
| 3102 | |||
| 3103 | $zonemapHash{$zonemapObj->name} = $zonemapObj; | ||
| 3104 | } | ||
| 3105 | } | ||
| 3106 | |||
| 3107 | $saveHash{'zonemap_hash'} = \%zonemapHash; | ||
| 3108 | |||
| 3109 | # Standard zonemaps can't be temporary, so we can save that IV directly... | ||
| 3110 | $saveHash{'standard_zonemap_hash'} = {$axmud::CLIENT->standardZonemapHash}; | ||
| 3111 | |||
| 3112 | } elsif ($self->fileType eq 'winmaps') { | ||
| 3113 | |||
| 3114 | $saveHash{'winmap_hash'} = {$axmud::CLIENT->winmapHash}; | ||
| 3115 | $saveHash{'standard_winmap_hash'} = {$axmud::CLIENT->standardWinmapHash}; | ||
| 3116 | $saveHash{'default_enabled_winmap'} = $axmud::CLIENT->defaultEnabledWinmap; | ||
| 3117 | $saveHash{'default_disabled_winmap'} = $axmud::CLIENT->defaultDisabledWinmap; | ||
| 3118 | $saveHash{'default_internal_winmap'} = $axmud::CLIENT->defaultInternalWinmap; | ||
| 3119 | $saveHash{'colour_scheme_hash'} = {$axmud::CLIENT->colourSchemeHash}; | ||
| 3120 | |||
| 3121 | } elsif ($self->fileType eq 'tts') { | ||
| 3122 | |||
| 3123 | $saveHash{'tts_obj_hash'} = {$axmud::CLIENT->ttsObjHash}; | ||
| 3124 | } | ||
| 3125 | |||
| 3126 | # Glob test mode: In earlier Axmud versions, saving of data files failed (and Axmud crashed) | ||
| 3127 | # because of infinite recursions with two Perl objects referencing each other. If TRUE, | ||
| 3128 | # every save file operation (not including the config file) tests data for this problem, | ||
| 3129 | # before saving it, writing the output to the terminal | ||
| 3130 | if ($axmud::TEST_GLOB_MODE_FLAG && ! $self->globTest(%saveHash)) { | ||
| 3131 | |||
| 3132 | return undef; | ||
| 3133 | } | ||
| 3134 | |||
| 3135 | # Precautions taken when an emergency save is NOT in progress... | ||
| 3136 | if (! $emergFlag) { | ||
| 3137 | |||
| 3138 | if ($self->preserveBackupFlag) { | ||
| 3139 | |||
| 3140 | # The file itself was missing/corrupted, so data was loaded from the backup file | ||
| 3141 | # Don't replace the (good) backup file; just replace the (faulty) file itself | ||
| 3142 | # NB For the config file, nothing in the Axmud code sets this flag to TRUE. Still, | ||
| 3143 | # the code exists, for any future version that needs it | ||
| 3144 | $self->ivPoke('preserveBackupFlag', FALSE); | ||
| 3145 | |||
| 3146 | } elsif (-e $path) { | ||
| 3147 | |||
| 3148 | # If the call to ->lock_nstore fails, an existing file called $path will be | ||
| 3149 | # destroyed or corrupted (this could be disastrous, especially if it contains a | ||
| 3150 | # world profile, or something) | ||
| 3151 | # Create a backup of the file, if the file already exists, using File::Copy | ||
| 3152 | $buPath = $path . '.bu'; | ||
| 3153 | File::Copy::copy($path, $buPath); | ||
| 3154 | } | ||
| 3155 | |||
| 3156 | # Save the special hash as a single object | ||
| 3157 | eval { Storable::lock_nstore(\%saveHash, $path) }; | ||
| 3158 | if ($@) { | ||
| 3159 | |||
| 3160 | if ($buPath) { | ||
| 3161 | |||
| 3162 | # Restore the backup file | ||
| 3163 | File::Copy::copy($buPath, $path); | ||
| 3164 | # Delete the backup file, unless the user has opted to retain them | ||
| 3165 | if (! $axmud::CLIENT->autoRetainFileFlag) { | ||
| 3166 | |||
| 3167 | unlink ($buPath); | ||
| 3168 | } | ||
| 3169 | } | ||
| 3170 | |||
| 3171 | # Disable loading/saving in all sessions | ||
| 3172 | $axmud::CLIENT->disableAllFileAccess(); | ||
| 3173 | |||
| 3174 | if ($buPath) { | ||
| 3175 | |||
| 3176 | return $self->writeError( | ||
| 3177 | 'Save data failure: \'' . $path . '\' (existing file restored from backup,' | ||
| 3178 | . ' file loading/saving disabled)', | ||
| 3179 | $self->_objClass . '->saveDataFile', | ||
| 3180 | ); | ||
| 3181 | |||
| 3182 | } else { | ||
| 3183 | |||
| 3184 | return $self->writeError( | ||
| 3185 | 'Save data failure: \'' . $path . '\' (file loading/saving disabled)', | ||
| 3186 | $self->_objClass . '->saveDataFile', | ||
| 3187 | ); | ||
| 3188 | } | ||
| 3189 | |||
| 3190 | } else { | ||
| 3191 | |||
| 3192 | # Save operation successful | ||
| 3193 | if ($buPath) { | ||
| 3194 | |||
| 3195 | # Delete the backup file, unless the user has opted to retain them | ||
| 3196 | if (! $axmud::CLIENT->autoRetainFileFlag) { | ||
| 3197 | |||
| 3198 | unlink ($buPath); | ||
| 3199 | } | ||
| 3200 | } | ||
| 3201 | |||
| 3202 | # Set this file object's metadata variables | ||
| 3203 | $self->ivPoke('scriptName', $saveHash{'script_name'}); | ||
| 3204 | $self->ivPoke('scriptVersion', $saveHash{'script_version'}); | ||
| 3205 | $self->ivPoke( | ||
| 3206 | 'scriptConvertVersion', | ||
| 3207 | $axmud::CLIENT->convertVersion($saveHash{'script_version'}), | ||
| 3208 | ); | ||
| 3209 | $self->ivPoke('saveDate', $saveHash{'save_date'}); | ||
| 3210 | $self->ivPoke('saveTime', $saveHash{'save_time'}); | ||
| 3211 | $self->ivPoke('assocWorldProf', $saveHash{'assoc_world_prof'}); | ||
| 3212 | |||
| 3213 | $self->ivPoke('actualFileName', $fileName); | ||
| 3214 | $self->ivPoke('actualPath', $path); | ||
| 3215 | $self->ivPoke('actualDir', $dir); | ||
| 3216 | |||
| 3217 | # Mark the file object's data as not modified | ||
| 3218 | $self->set_modifyFlag(FALSE, $self->_objClass . '->saveDataFile'); | ||
| 3219 | |||
| 3220 | return 1; | ||
| 3221 | } | ||
| 3222 | |||
| 3223 | # (No precautions taken when an emergency save IS in progress) | ||
| 3224 | } else { | ||
| 3225 | |||
| 3226 | # Save the special hash as a single object | ||
| 3227 | eval { Storable::lock_nstore(\%saveHash, $path) }; | ||
| 3228 | if ($@) { | ||
| 3229 | |||
| 3230 | return undef; | ||
| 3231 | |||
| 3232 | } else { | ||
| 3233 | |||
| 3234 | # (Don't update the file object's metadata variables for an emergency save) | ||
| 3235 | return 1; | ||
| 3236 | } | ||
| 3237 | } | ||
| 3238 | } | ||
| 3239 | |||
| 3240 | sub saveDataFile_worldModel { | ||
| 3241 | |||
| 3242 | # Called by $self->saveDataFile | ||
| 3243 | # For the file type 'worldmodel', we might use a single monolithic file or, if the model is | ||
| 3244 | # large, multiple smaller ones. A single monolithic file is handled by | ||
| 3245 | # $self->saveDataFile; multiple files are handled by a call to this function | ||
| 3246 | # | ||
| 3247 | # Expected arguments | ||
| 3248 | # $fileName - The file name, i.e. 'worldmodel.axm' | ||
| 3249 | # $path - The full path, i.e. '/home/me/axmud-data/data/worldmodel.axm' | ||
| 3250 | # $dir - The directory, i.e. '/home/me/axmud-data/data/' | ||
| 3251 | # | ||
| 3252 | # Return values | ||
| 3253 | # 'undef' on improper arguments or if there is an error saving the data file(s) themselves | ||
| 3254 | # 1 otherwise | ||
| 3255 | |||
| 3256 | my ($self, $fileName, $path, $dir, $check) = @_; | ||
| 3257 | |||
| 3258 | # Local variables | ||
| 3259 | my ( | ||
| 3260 | $tempDir, $count, $mainSavePath, $dirHandle, | ||
| 3261 | @ivList, @objList, | ||
| 3262 | %standardHash, %storeHash, %mainSaveHash, | ||
| 3263 | ); | ||
| 3264 | |||
| 3265 | # Check for improper arguments | ||
| 3266 | if (! defined $fileName || ! defined $path || ! defined $dir || defined $check) { | ||
| 3267 | |||
| 3268 | return $axmud::CLIENT->writeImproper( | ||
| 3269 | $self->_objClass . '->saveDataFile_worldModel', | ||
| 3270 | @_, | ||
| 3271 | ); | ||
| 3272 | } | ||
| 3273 | |||
| 3274 | # When using multiple files, we use a 'main' file and multiple 'mini' files. The 'mini' | ||
| 3275 | # files each contain a limited number of model objects (regions, rooms, weapons etc) and | ||
| 3276 | # exit model objects. The 'main' file contains everything else | ||
| 3277 | |||
| 3278 | # Because we're dealing with multiple files, rather than a single one, the way this function | ||
| 3279 | # handles backup files is different. We'll create a temporary directory, save our files | ||
| 3280 | # there and, if there are no problems, we'll then move the files into their proper | ||
| 3281 | # directory | ||
| 3282 | # There's a (small) possibility that two sessions might saving their world model at the same | ||
| 3283 | # time, in which case, this save operation fails | ||
| 3284 | $tempDir = $dir . '/temp/split'; | ||
| 3285 | if (-d $tempDir || ! mkdir ($tempDir, 0755)) { | ||
| 3286 | |||
| 3287 | return undef; | ||
| 3288 | } | ||
| 3289 | |||
| 3290 | # Prepare a standard header, used by all of these files | ||
| 3291 | $standardHash{'file_type'} = $self->fileType; | ||
| 3292 | $standardHash{'script_name'} = $axmud::NAME_FILE; | ||
| 3293 | $standardHash{'script_version'} = $axmud::VERSION; | ||
| 3294 | $standardHash{'save_date'} = $axmud::CLIENT->localDate(); | ||
| 3295 | $standardHash{'save_time'} = $axmud::CLIENT->localTime(); | ||
| 3296 | $standardHash{'assoc_world_prof'} = $self->assocWorldProf; | ||
| 3297 | |||
| 3298 | # Empty all world model IVs which store model objects and exit model objects, storing them | ||
| 3299 | # in a temporary hash. Everything left in GA::Obj::WorldModel is stored in the 'main' file | ||
| 3300 | @ivList = qw ( | ||
| 3301 | modelHash | ||
| 3302 | regionModelHash roomModelHash weaponModelHash armourModelHash garmentModelHash | ||
| 3303 | charModelHash minionModelHash sentientModelHash creatureModelHash portableModelHash | ||
| 3304 | decorationModelHash customModelHash | ||
| 3305 | exitModelHash | ||
| 3306 | ); | ||
| 3307 | |||
| 3308 | foreach my $iv (@ivList) { | ||
| 3309 | |||
| 3310 | $storeHash{$iv} = $self->session->worldModelObj->{$iv}; | ||
| 3311 | $self->session->worldModelObj->{$iv} = {}; | ||
| 3312 | } | ||
| 3313 | |||
| 3314 | # Save the 'mini' files. Keep track of how many 'mini' files we've saved | ||
| 3315 | $count = 0; | ||
| 3316 | |||
| 3317 | # Move the contents of the model, and the contents of the exit model, into flat lists so | ||
| 3318 | # we can chop away at them, GA::Client->modelSplitSize objects at a time | ||
| 3319 | @objList = %{$storeHash{'modelHash'}}; | ||
| 3320 | do { | ||
| 3321 | |||
| 3322 | my ( | ||
| 3323 | $thisSavePath, | ||
| 3324 | %thiSaveHash, | ||
| 3325 | ); | ||
| 3326 | |||
| 3327 | # Set the path for this mini world model file | ||
| 3328 | $count++; | ||
| 3329 | $thisSavePath = $tempDir . '/worldmodel_' . $count . '.axm'; | ||
| 3330 | |||
| 3331 | # All the 'mini' files have the same header | ||
| 3332 | %thiSaveHash = %standardHash; | ||
| 3333 | |||
| 3334 | # @objList is a list in groups of 2, in the form (model_number, model_object...). | ||
| 3335 | # Use the first $axmud::CLIENT->modelSplitSize objects | ||
| 3336 | $thiSaveHash{'model_hash'} | ||
| 3337 | = { splice(@objList, 0, ($axmud::CLIENT->modelSplitSize * 2)) }; | ||
| 3338 | |||
| 3339 | # Glob test mode: In earlier Axmud versions, saving of data files failed (and Axmud | ||
| 3340 | # crashed) because of infinite recursions with two Perl objects referencing each | ||
| 3341 | # other. If TRUE, every save file operation (not including the config file) tests data | ||
| 3342 | # for this problem, before saving it, writing the output to the terminal | ||
| 3343 | if ($axmud::TEST_GLOB_MODE_FLAG && ! $self->globTest(%thiSaveHash)) { | ||
| 3344 | |||
| 3345 | # (Delete the temporary directory before giving up) | ||
| 3346 | File::Path::remove_tree($tempDir); | ||
| 3347 | |||
| 3348 | return undef; | ||
| 3349 | } | ||
| 3350 | |||
| 3351 | # Save the 'mini' file | ||
| 3352 | eval { Storable::lock_nstore(\%thiSaveHash, $thisSavePath) }; | ||
| 3353 | if ($@) { | ||
| 3354 | |||
| 3355 | # Disable loading/saving in all sessions | ||
| 3356 | $axmud::CLIENT->disableAllFileAccess(); | ||
| 3357 | |||
| 3358 | # Delete the temporary directory before giving up | ||
| 3359 | File::Path::remove_tree($tempDir); | ||
| 3360 | |||
| 3361 | return $self->writeError( | ||
| 3362 | 'Save data failure: \'' . $dir . '/worldmodel_' . $count . '.axm\' (existing' | ||
| 3363 | . ' world model files are not affected, file loading/saving disabled)', | ||
| 3364 | $self->_objClass . '->saveDataFile_worldModel', | ||
| 3365 | ); | ||
| 3366 | } | ||
| 3367 | |||
| 3368 | } until (! @objList); | ||
| 3369 | |||
| 3370 | @objList = %{$storeHash{'exitModelHash'}}; | ||
| 3371 | do { | ||
| 3372 | |||
| 3373 | my ( | ||
| 3374 | $thisSavePath, | ||
| 3375 | %thiSaveHash, | ||
| 3376 | ); | ||
| 3377 | |||
| 3378 | # Set the path for this mini world model file | ||
| 3379 | $count++; | ||
| 3380 | $thisSavePath = $tempDir . '/worldmodel_' . $count . '.axm'; | ||
| 3381 | |||
| 3382 | # All the 'mini' files have the same header | ||
| 3383 | %thiSaveHash = %standardHash; | ||
| 3384 | |||
| 3385 | # @objList is a list in groups of 2, in the form (model_number, model_object...). | ||
| 3386 | # Use the first $axmud::CLIENT->modelSplitSize objects | ||
| 3387 | $thiSaveHash{'exit_model_hash'} | ||
| 3388 | = { splice(@objList, 0, ($axmud::CLIENT->modelSplitSize * 2)) }; | ||
| 3389 | |||
| 3390 | # Glob check, if required | ||
| 3391 | if ($axmud::TEST_GLOB_MODE_FLAG && ! $self->globTest(%thiSaveHash)) { | ||
| 3392 | |||
| 3393 | # (Delete the temporary directory before giving up) | ||
| 3394 | File::Path::remove_tree($tempDir); | ||
| 3395 | |||
| 3396 | return undef; | ||
| 3397 | } | ||
| 3398 | |||
| 3399 | # Save the 'mini' file | ||
| 3400 | eval { Storable::lock_nstore(\%thiSaveHash, $thisSavePath) }; | ||
| 3401 | if ($@) { | ||
| 3402 | |||
| 3403 | # Disable loading/saving in all sessions | ||
| 3404 | $axmud::CLIENT->disableAllFileAccess(); | ||
| 3405 | |||
| 3406 | # Delete the temporary directory before giving up | ||
| 3407 | File::Path::remove_tree($tempDir); | ||
| 3408 | |||
| 3409 | return $self->writeError( | ||
| 3410 | 'Save data failure: \'' . $dir . '/worldmodel_' . $count . '.axm\' (existing' | ||
| 3411 | . ' world model files are not affected, file loading/saving disabled)', | ||
| 3412 | $self->_objClass . '->saveDataFile_worldModel', | ||
| 3413 | ); | ||
| 3414 | } | ||
| 3415 | |||
| 3416 | } until (! @objList); | ||
| 3417 | |||
| 3418 | # Update the world model with the number of mini files it needs, the next time it's loaded | ||
| 3419 | $self->session->worldModelObj->ivPoke('modelSaveFileCount', $count); | ||
| 3420 | |||
| 3421 | # Prepare the 'main' file | ||
| 3422 | %mainSaveHash = %standardHash; | ||
| 3423 | $mainSaveHash{'world_model_obj'} = $self->session->worldModelObj; | ||
| 3424 | |||
| 3425 | # Glob check, if required | ||
| 3426 | if ($axmud::TEST_GLOB_MODE_FLAG && ! $self->globTest(%mainSaveHash)) { | ||
| 3427 | |||
| 3428 | # (Delete the temporary directory before giving up) | ||
| 3429 | File::Path::remove_tree($tempDir); | ||
| 3430 | |||
| 3431 | return undef; | ||
| 3432 | } | ||
| 3433 | |||
| 3434 | # Save the 'main' file | ||
| 3435 | $mainSavePath = $tempDir . '/worldmodel.axm'; | ||
| 3436 | eval { Storable::lock_nstore(\%mainSaveHash, $mainSavePath) }; | ||
| 3437 | if ($@) { | ||
| 3438 | |||
| 3439 | # Disable loading/saving in all sessions | ||
| 3440 | $axmud::CLIENT->disableAllFileAccess(); | ||
| 3441 | |||
| 3442 | # Delete the temporary directory before giving up | ||
| 3443 | File::Path::remove_tree($tempDir); | ||
| 3444 | |||
| 3445 | return $self->writeError( | ||
| 3446 | 'Save data failure: \'' . $path . '\' (existing world model files are not affected,' | ||
| 3447 | . ' file loading/saving disabled)', | ||
| 3448 | $self->_objClass . '->saveDataFile_worldModel', | ||
| 3449 | ); | ||
| 3450 | } | ||
| 3451 | |||
| 3452 | # Save operations successful. Before doing anything else, restore GA::Obj::WorldModel's | ||
| 3453 | # IVs | ||
| 3454 | foreach my $iv (@ivList) { | ||
| 3455 | |||
| 3456 | $self->session->worldModelObj->{$iv} = $storeHash{$iv}; | ||
| 3457 | delete $storeHash{$iv}; | ||
| 3458 | } | ||
| 3459 | |||
| 3460 | # We can now deal with the pre-existing data files in $dir | ||
| 3461 | if ($self->preserveBackupFlag) { | ||
| 3462 | |||
| 3463 | # The files themselves were missing/corrupted, so data was loaded from the backup files | ||
| 3464 | # Don't replace the (good) backup files; just remove the (faulty) files themselves | ||
| 3465 | $self->ivPoke('preserveBackupFlag', FALSE); | ||
| 3466 | |||
| 3467 | if (opendir($dirHandle, $dir)) { | ||
| 3468 | |||
| 3469 | my @fileList = readdir($dirHandle); | ||
| 3470 | closedir $dirHandle; | ||
| 3471 | |||
| 3472 | foreach my $file (@fileList) { | ||
| 3473 | |||
| 3474 | if ( | ||
| 3475 | $file =~ m/worldmodel\.axm$/ | ||
| 3476 | || $file =~ m/worldmodel_\d+\.axm$/ | ||
| 3477 | ) { | ||
| 3478 | unlink $dir . '/' . $file; | ||
| 3479 | } | ||
| 3480 | } | ||
| 3481 | } | ||
| 3482 | |||
| 3483 | } else { | ||
| 3484 | |||
| 3485 | # Remove the existing backup files... | ||
| 3486 | if (opendir($dirHandle, $dir)) { | ||
| 3487 | |||
| 3488 | my @fileList = readdir($dirHandle); | ||
| 3489 | closedir $dirHandle; | ||
| 3490 | |||
| 3491 | foreach my $file (@fileList) { | ||
| 3492 | |||
| 3493 | if ( | ||
| 3494 | $file =~ m/worldmodel\.axm\.bu$/ | ||
| 3495 | || $file =~ m/worldmodel_\d+\.axm\.bu$/ | ||
| 3496 | ) { | ||
| 3497 | unlink $dir . '/' . $file; | ||
| 3498 | } | ||
| 3499 | } | ||
| 3500 | } | ||
| 3501 | |||
| 3502 | # ...and replace them with the pre-existing data files | ||
| 3503 | if (opendir($dirHandle, $dir)) { | ||
| 3504 | |||
| 3505 | my @fileList = readdir($dirHandle); | ||
| 3506 | closedir $dirHandle; | ||
| 3507 | |||
| 3508 | foreach my $file (@fileList) { | ||
| 3509 | |||
| 3510 | if ( | ||
| 3511 | $file =~ m/worldmodel\.axm$/ | ||
| 3512 | || $file =~ m/worldmodel_\d+\.axm$/ | ||
| 3513 | ) { | ||
| 3514 | File::Copy::move($dir . '/' . $file, $dir . '/' . $file . '.bu'); | ||
| 3515 | } | ||
| 3516 | } | ||
| 3517 | } | ||
| 3518 | } | ||
| 3519 | |||
| 3520 | # Move everything from the temporary directory into the proper directory... | ||
| 3521 | if (opendir($dirHandle, $tempDir)) { | ||
| 3522 | |||
| 3523 | my @fileList = readdir($dirHandle); | ||
| 3524 | closedir $dirHandle; | ||
| 3525 | |||
| 3526 | foreach my $file (@fileList) { | ||
| 3527 | |||
| 3528 | File::Copy::move($tempDir . '/' . $file, $dir . '/' . $file); | ||
| 3529 | } | ||
| 3530 | } | ||
| 3531 | |||
| 3532 | # ...and delete the temporary directory | ||
| 3533 | File::Path::remove_tree($tempDir); | ||
| 3534 | |||
| 3535 | # Finally, set this file object's metadata variables | ||
| 3536 | $self->ivPoke('scriptName', $mainSaveHash{'script_name'}); | ||
| 3537 | $self->ivPoke('scriptVersion', $mainSaveHash{'script_version'}); | ||
| 3538 | $self->ivPoke( | ||
| 3539 | 'scriptConvertVersion', | ||
| 3540 | $axmud::CLIENT->convertVersion($mainSaveHash{'script_version'}), | ||
| 3541 | ); | ||
| 3542 | $self->ivPoke('saveDate', $mainSaveHash{'save_date'}); | ||
| 3543 | $self->ivPoke('saveTime', $mainSaveHash{'save_time'}); | ||
| 3544 | $self->ivPoke('assocWorldProf', $mainSaveHash{'assoc_world_prof'}); | ||
| 3545 | |||
| 3546 | $self->ivPoke('actualFileName', $fileName); | ||
| 3547 | $self->ivPoke('actualPath', $path); | ||
| 3548 | $self->ivPoke('actualDir', $dir); | ||
| 3549 | |||
| 3550 | # Mark the file object's data as not modified | ||
| 3551 | $self->set_modifyFlag(FALSE, $self->_objClass . '->saveDataFile'); | ||
| 3552 | |||
| 3553 | return 1; | ||
| 3554 | } | ||
| 3555 | |||
| 3556 | sub loadDataFile { | ||
| 3557 | |||
| 3558 | # Called by $self->setupDataFile (or by any other function) for the file types: | ||
| 3559 | # 'tasks', 'scripts', 'contacts', 'dicts', 'toolbar', 'usercmds', 'zonemaps', 'winmaps', | ||
| 3560 | # 'tts' | ||
| 3561 | # Called by any function for the file types: | ||
| 3562 | # 'worldprof' | ||
| 3563 | # Called by any function for the file types: | ||
| 3564 | # 'otherprof', 'worldmodel' | ||
| 3565 | # | ||
| 3566 | # Loads a data file of the type specified by $self->fileType, replacing data in memory | ||
| 3567 | # | ||
| 3568 | # Expected arguments | ||
| 3569 | # (none besides $self) | ||
| 3570 | # | ||
| 3571 | # Optional arguments | ||
| 3572 | # $fileName - The file name, e.g. 'tasks.axm' | ||
| 3573 | # $path - The full path, e.g. '/home/me/axmud-data/data/tasks.axm' | ||
| 3574 | # $dir - The directory, e.g. '/home/me/axmud-data/data/' | ||
| 3575 | # $backupFlag - If TRUE, the function will try to load the automatic backup of the file | ||
| 3576 | # (e.g. 'tasks.axm.bu'). If FALSE (or 'undef'), the function loads the | ||
| 3577 | # normal copy of the file (e.g. 'tasks.axm') | ||
| 3578 | # | ||
| 3579 | # Notes: | ||
| 3580 | # If one optional argument is specified, they must all be specified | ||
| 3581 | # If no optional arguments are specified (or are all set to 'undef'), the default | ||
| 3582 | # filename, path and directory for this file type are used | ||
| 3583 | # | ||
| 3584 | # Return values | ||
| 3585 | # 'undef' on improper arguments, if loading of data files isn't allowed (because of global | ||
| 3586 | # flags) or if there is an error loading the data file itself | ||
| 3587 | # 1 otherwise | ||
| 3588 | |||
| 3589 | my ($self, $fileName, $path, $dir, $backupFlag, $check) = @_; | ||
| 3590 | |||
| 3591 | # Local variables | ||
| 3592 | my ( | ||
| 3593 | $matchFlag, $fileType, $scriptName, $scriptVersion, $saveDate, $saveTime, | ||
| 3594 | $assocWorldProf, $hashRef, $notCompatFlag, | ||
| 3595 | %loadHash, | ||
| 3596 | ); | ||
| 3597 | |||
| 3598 | # Check for improper arguments | ||
| 3599 | if ( | ||
| 3600 | defined $check | ||
| 3601 | || (defined $fileName && (! defined $path || ! defined $dir)) | ||
| 3602 | || (defined $path && (! defined $fileName || ! defined $dir)) | ||
| 3603 | || (defined $dir && (! defined $fileName || ! defined $path)) | ||
| 3604 | ) { | ||
| 3605 | return $axmud::CLIENT->writeImproper($self->_objClass . '->loadDataFile', @_); | ||
| 3606 | } | ||
| 3607 | |||
| 3608 | # Check it's the right file type for this function | ||
| 3609 | if ($self->fileType eq 'config') { | ||
| 3610 | |||
| 3611 | return $self->writeError( | ||
| 3612 | 'Wrong file type \'' . $self->fileType . '\'', | ||
| 3613 | $self->_objClass . '->loadDataFile', | ||
| 3614 | ); | ||
| 3615 | } | ||
| 3616 | |||
| 3617 | # Set the filename, path and directory, if not specified | ||
| 3618 | if (! defined $fileName) { | ||
| 3619 | |||
| 3620 | $fileName = $self->standardFileName; | ||
| 3621 | $path = $axmud::DATA_DIR . $self->standardPath; | ||
| 3622 | $dir = $axmud::DATA_DIR . $self->standardDir; | ||
| 3623 | } | ||
| 3624 | |||
| 3625 | # Load the automatic backup of the file, if required | ||
| 3626 | if ($backupFlag) { | ||
| 3627 | |||
| 3628 | $fileName .= '.bu'; | ||
| 3629 | $path .= '.bu'; | ||
| 3630 | } | ||
| 3631 | |||
| 3632 | # Don't load anything if the global flag forbids it | ||
| 3633 | if (! $axmud::CLIENT->loadDataFlag) { | ||
| 3634 | |||
| 3635 | return undef; | ||
| 3636 | } | ||
| 3637 | |||
| 3638 | # Check that the data directory exists | ||
| 3639 | if (! (-d $dir)) { | ||
| 3640 | |||
| 3641 | return undef; | ||
| 3642 | } | ||
| 3643 | |||
| 3644 | # Check that the specified file exists | ||
| 3645 | if (! (-e $path)) { | ||
| 3646 | |||
| 3647 | # Before v1.0.868, Axmud used different file extensions; check them all | ||
| 3648 | OUTER: foreach my $ext (@axmud::COMPAT_EXT_LIST) { | ||
| 3649 | |||
| 3650 | my $altPath = $path; | ||
| 3651 | $altPath =~ s/\.axm/.$ext/; | ||
| 3652 | |||
| 3653 | if (-e $altPath) { | ||
| 3654 | |||
| 3655 | $matchFlag = TRUE; | ||
| 3656 | $path = $altPath; | ||
| 3657 | last OUTER; | ||
| 3658 | } | ||
| 3659 | } | ||
| 3660 | |||
| 3661 | if (! $matchFlag) { | ||
| 3662 | |||
| 3663 | return undef; | ||
| 3664 | } | ||
| 3665 | } | ||
| 3666 | |||
| 3667 | # Load all the data into a hash | ||
| 3668 | eval { $hashRef = Storable::lock_retrieve($path); }; | ||
| 3669 | if (! $hashRef) { | ||
| 3670 | |||
| 3671 | # ->lock_retrieve() failed | ||
| 3672 | return undef; | ||
| 3673 | |||
| 3674 | } else { | ||
| 3675 | |||
| 3676 | # Convert the hash referenced by $hashRef into a named hash | ||
| 3677 | %loadHash = %{$hashRef}; | ||
| 3678 | |||
| 3679 | # Before v1.0.868, Axmud had a different name. Update all header data | ||
| 3680 | if ( | ||
| 3681 | defined $loadHash{'script_version'} | ||
| 3682 | && $axmud::CLIENT->convertVersion($loadHash{'script_version'}) < 1_000_868 | ||
| 3683 | ) { | ||
| 3684 | %loadHash = $self->updateHeaderAfterRename(%loadHash); | ||
| 3685 | } | ||
| 3686 | |||
| 3687 | # Extract the header information (i.e. metadata) from the hash | ||
| 3688 | $fileType = $loadHash{'file_type'}; | ||
| 3689 | $scriptName = $loadHash{'script_name'}; | ||
| 3690 | $scriptVersion = $loadHash{'script_version'}; | ||
| 3691 | $saveDate = $loadHash{'save_date'}; | ||
| 3692 | $saveTime = $loadHash{'save_time'}; | ||
| 3693 | $assocWorldProf = $loadHash{'assoc_world_prof'}; | ||
| 3694 | |||
| 3695 | # Do checks on the header information | ||
| 3696 | if (! defined $fileType || $fileType ne $self->fileType) { | ||
| 3697 | |||
| 3698 | # Wrong kind of file | ||
| 3699 | return undef; | ||
| 3700 | |||
| 3701 | } elsif ( | ||
| 3702 | ! defined $scriptName || ! defined $scriptVersion || ! defined $saveDate | ||
| 3703 | || ! defined $saveTime | ||
| 3704 | ) { | ||
| 3705 | # Missing or possibly corrupted header (NB $assocWorldProf can be 'undef') | ||
| 3706 | return undef; | ||
| 3707 | |||
| 3708 | } elsif ( | ||
| 3709 | ! $self->checkCompatibility($scriptName) | ||
| 3710 | || $axmud::CLIENT->convertVersion($scriptVersion) | ||
| 3711 | > $axmud::CLIENT->convertVersion($axmud::VERSION) | ||
| 3712 | ) { | ||
| 3713 | # Data file not created by a current or previous version of Axmud | ||
| 3714 | return undef; | ||
| 3715 | } | ||
| 3716 | |||
| 3717 | # For the file type 'worldmodel', we might use a single monolithic file or, if the model | ||
| 3718 | # is large, multiple smaller ones. Check whether multiple files exist and, if so, | ||
| 3719 | # load them, updating the world model that's currently stored in | ||
| 3720 | # $loadHash{'world_model_obj'} | ||
| 3721 | if ( | ||
| 3722 | $axmud::CLIENT->convertVersion($scriptVersion) >= 1_001_529 | ||
| 3723 | && $self->fileType eq 'worldmodel' | ||
| 3724 | && ! $self->loadDataFile_worldModel($dir, \%loadHash) | ||
| 3725 | ) { | ||
| 3726 | return undef; | ||
| 3727 | } | ||
| 3728 | |||
| 3729 | # Header information checks out. Store the values in this object | ||
| 3730 | $self->ivPoke('scriptName', $scriptName); | ||
| 3731 | $self->ivPoke('scriptVersion', $scriptVersion); | ||
| 3732 | $self->ivPoke('scriptConvertVersion', $axmud::CLIENT->convertVersion($scriptVersion)); | ||
| 3733 | $self->ivPoke('saveDate', $saveDate); | ||
| 3734 | $self->ivPoke('saveTime', $saveTime); | ||
| 3735 | $self->ivPoke('assocWorldProf', $assocWorldProf); | ||
| 3736 | |||
| 3737 | $self->ivPoke('actualFileName', $fileName); | ||
| 3738 | $self->ivPoke('actualPath', $path); | ||
| 3739 | $self->ivPoke('actualDir', $dir); | ||
| 3740 | |||
| 3741 | # Extract the rest of the data from %loadHash, replacing data in memory with data from | ||
| 3742 | # the loaded file. The TRUE argument tells ->extractData that this is the calling | ||
| 3743 | # function | ||
| 3744 | if (! $self->extractData(TRUE, %loadHash)) { | ||
| 3745 | |||
| 3746 | # Load failed | ||
| 3747 | return undef; | ||
| 3748 | } | ||
| 3749 | |||
| 3750 | # Apply patches to any pre-configured world profiles with serious problems, or whose | ||
| 3751 | # DNS/IP/port has changed | ||
| 3752 | if ( | ||
| 3753 | $fileType eq 'worldprof' | ||
| 3754 | && $axmud::CLIENT->ivExists('constWorldPatchHash', $assocWorldProf) | ||
| 3755 | ) { | ||
| 3756 | $self->patchWorldProf($assocWorldProf, $scriptVersion); | ||
| 3757 | } | ||
| 3758 | |||
| 3759 | # Load complete | ||
| 3760 | return 1; | ||
| 3761 | } | ||
| 3762 | } | ||
| 3763 | |||
| 3764 | sub loadDataFile_worldModel { | ||
| 3765 | |||
| 3766 | # Called by $self->loadDataFile | ||
| 3767 | # For the file type 'worldmodel', we might use a single monolithic file or, if the model is | ||
| 3768 | # large, multiple smaller ones (a 'main' file and several 'mini' files) | ||
| 3769 | # $self->loadDataFile loads the 'worldmodel.axm' file, which is either a monolithic file, | ||
| 3770 | # or the 'main' file | ||
| 3771 | # This function checks whether the loaded file is a 'main' file and, if so, tries to load | ||
| 3772 | # the remaining 'mini' files, merging the data from the 'main' and 'mini' files into a | ||
| 3773 | # single world model | ||
| 3774 | # | ||
| 3775 | # Expected arguments | ||
| 3776 | # $dir - The directory from which the monolothic/'main' file was loaded | ||
| 3777 | # $mainHashRef - A hash containing data loaded from the monolithic or 'main' file. | ||
| 3778 | # The loaded world model itself (GA::Obj::WorldModel) is stored in | ||
| 3779 | # $$loadHashRef{'world_model_obj'}, and has not yet replaced the | ||
| 3780 | # world model in memory (GA::Session->worldModelObj). Anything loaded | ||
| 3781 | # from the 'mini' files is incorporated into that loaded world model | ||
| 3782 | # before the complete world model is transferred to | ||
| 3783 | # GA::Session->worldModelObj | ||
| 3784 | # | ||
| 3785 | # Return values | ||
| 3786 | # 'undef' on improper arguments or if we fail to load any 'mini' files that exist | ||
| 3787 | # 1 if the file loaded was a monolithic file, or if the 'main' and 'mini' files have all | ||
| 3788 | # been loaded successfully | ||
| 3789 | |||
| 3790 | my ($self, $dir, $mainHashRef, $check) = @_; | ||
| 3791 | |||
| 3792 | # Local variables | ||
| 3793 | my ( | ||
| 3794 | $wmObj, | ||
| 3795 | @modelList, @exitList, | ||
| 3796 | ); | ||
| 3797 | |||
| 3798 | # Check for improper arguments | ||
| 3799 | if (! defined $dir || ! defined $mainHashRef || defined $check) { | ||
| 3800 | |||
| 3801 | return $axmud::CLIENT->writeImproper( | ||
| 3802 | $self->_objClass . '->loadDataFile_worldModel', | ||
| 3803 | @_, | ||
| 3804 | ); | ||
| 3805 | } | ||
| 3806 | |||
| 3807 | # Import the loaded world model | ||
| 3808 | $wmObj = $$mainHashRef{'world_model_obj'}; | ||
| 3809 | if (! defined $wmObj) { | ||
| 3810 | |||
| 3811 | # Load failure | ||
| 3812 | return undef; | ||
| 3813 | } | ||
| 3814 | |||
| 3815 | # If it's a monolithic world model file, there's nothing for this function to do | ||
| 3816 | if (! exists $wmObj->{modelSaveFileCount} || ! $wmObj->{modelSaveFileCount}) { | ||
| 3817 | |||
| 3818 | # The monolithic file's data can now be extracted into memory as normal | ||
| 3819 | return 1; | ||
| 3820 | } | ||
| 3821 | |||
| 3822 | # Some 'mini' files exist; load them all | ||
| 3823 | for (my $count = 1; $count <= $wmObj->{modelSaveFileCount}; $count++) { | ||
| 3824 | |||
| 3825 | my ( | ||
| 3826 | $loadPath, $hashRef, $fileType, $scriptName, $scriptVersion, $saveDate, $saveTime, | ||
| 3827 | $assocWorldProf, | ||
| 3828 | %loadHash, | ||
| 3829 | ); | ||
| 3830 | |||
| 3831 | # If this 'mini' file doesn't exist, loading of the whole world model fails | ||
| 3832 | $loadPath = $dir . '/worldmodel_' . $count . '.axm'; | ||
| 3833 | if (! -e $loadPath) { | ||
| 3834 | |||
| 3835 | return undef; | ||
| 3836 | } | ||
| 3837 | |||
| 3838 | # Load all the data into a hash | ||
| 3839 | eval { $hashRef = Storable::lock_retrieve($loadPath); }; | ||
| 3840 | if (! $hashRef) { | ||
| 3841 | |||
| 3842 | # ->lock_retrieve() failed | ||
| 3843 | return undef; | ||
| 3844 | } | ||
| 3845 | |||
| 3846 | # Convert the hash referenced by $hashRef into a named hash | ||
| 3847 | %loadHash = %{$hashRef}; | ||
| 3848 | |||
| 3849 | # Check that the header information in the 'mini' file is exactly the same as for the | ||
| 3850 | # 'main' file | ||
| 3851 | if ( | ||
| 3852 | $loadHash{'file_type'} ne $$mainHashRef{'file_type'} | ||
| 3853 | || $loadHash{'script_name'} ne $$mainHashRef{'script_name'} | ||
| 3854 | || $loadHash{'script_version'} ne $$mainHashRef{'script_version'} | ||
| 3855 | || $loadHash{'save_date'} ne $$mainHashRef{'save_date'} | ||
| 3856 | || $loadHash{'save_time'} ne $$mainHashRef{'save_time'} | ||
| 3857 | || $loadHash{'assoc_world_prof'} ne $$mainHashRef{'assoc_world_prof'} | ||
| 3858 | ) { | ||
| 3859 | return undef; | ||
| 3860 | } | ||
| 3861 | |||
| 3862 | # Extract the data from the 'mini' file | ||
| 3863 | if (exists $loadHash{'model_hash'}) { | ||
| 3864 | |||
| 3865 | # Extract some model objects (regions, room etc) | ||
| 3866 | push (@modelList, %{$loadHash{'model_hash'}}); | ||
| 3867 | |||
| 3868 | } elsif (exists $loadHash{'exit_model_hash'}) { | ||
| 3869 | |||
| 3870 | # Extract some exit model objects | ||
| 3871 | push (@exitList, %{$loadHash{'exit_model_hash'}}); | ||
| 3872 | |||
| 3873 | } else { | ||
| 3874 | |||
| 3875 | # If neither exist in the file, it must be corrupted | ||
| 3876 | return undef; | ||
| 3877 | } | ||
| 3878 | } | ||
| 3879 | |||
| 3880 | # All mini model files loaded successfully, so incorporate their data into the loaded | ||
| 3881 | # world model | ||
| 3882 | $wmObj->{modelHash} = {@modelList}; | ||
| 3883 | $wmObj->{exitModelHash} = {@exitList}; | ||
| 3884 | foreach my $obj (values %{$wmObj->{modelHash}}) { | ||
| 3885 | |||
| 3886 | my $iv = $obj->category . 'ModelHash'; # e.g. ->regionModelHash | ||
| 3887 | |||
| 3888 | $wmObj->{$iv}{$obj->number} = $obj; | ||
| 3889 | } | ||
| 3890 | |||
| 3891 | # Operation complete | ||
| 3892 | return 1; | ||
| 3893 | } | ||
| 3894 | |||
| 3895 | sub exportDataFile { | ||
| 3896 | |||
| 3897 | # Called by GA::Cmd::ExportData->do for the file types: | ||
| 3898 | # 'config' | ||
| 3899 | # Exports a partial data file, often containing a single Perl object. The exported partial | ||
| 3900 | # data file can be read by GA::Cmd::ImportData->do's call to $self->importDataFile | ||
| 3901 | # | ||
| 3902 | # Expected arguments | ||
| 3903 | # $session - The calling function's GA::Session | ||
| 3904 | # $switch - Switch used in the ';exportdata' command - tells us which kind of | ||
| 3905 | # object(s) to export (e.g. '-s' for profile templates) | ||
| 3906 | # $name - A name corresponding to the object(s) to export (e.g. the name of the | ||
| 3907 | # profile template) | ||
| 3908 | # | ||
| 3909 | # Notes: | ||
| 3910 | # If one optional argument is specified, they must all be specified | ||
| 3911 | # If no optional arguments are specified (or are all set to 'undef'), the default | ||
| 3912 | # filename, path and directory for this file type are used | ||
| 3913 | # | ||
| 3914 | # Return values | ||
| 3915 | # 'undef' on improper arguments, if saving of data files isn't allowed (because of global | ||
| 3916 | # flags), if the user cancels the export or if there is an error saving the data file | ||
| 3917 | # itself | ||
| 3918 | # Otherwise returns the path to the exported file | ||
| 3919 | |||
| 3920 | my ($self, $session, $switch, $name, $check) = @_; | ||
| 3921 | |||
| 3922 | # Local variables | ||
| 3923 | my ( | ||
| 3924 | $suggestFile, $exportPath, | ||
| 3925 | %saveHash, | ||
| 3926 | ); | ||
| 3927 | |||
| 3928 | # Check for improper arguments | ||
| 3929 | if (! defined $session || ! defined $switch || ! defined $name || defined $check) { | ||
| 3930 | |||
| 3931 | return $axmud::CLIENT->writeImproper($self->_objClass . '->exportDataFile', @_); | ||
| 3932 | } | ||
| 3933 | |||
| 3934 | # Check it's the right file type for this function | ||
| 3935 | if ($self->fileType ne 'config') { | ||
| 3936 | |||
| 3937 | return $self->writeError( | ||
| 3938 | 'Wrong file type \'' . $self->fileType . '\'', | ||
| 3939 | $self->_objClass . '->exportDataFile', | ||
| 3940 | ); | ||
| 3941 | } | ||
| 3942 | |||
| 3943 | # Don't save anything if the global flags forbid it | ||
| 3944 | if (! $axmud::CLIENT->saveDataFlag) { | ||
| 3945 | |||
| 3946 | return undef; | ||
| 3947 | } | ||
| 3948 | |||
| 3949 | # Compile a special hash, %saveHash, that references all the data we want to save | ||
| 3950 | |||
| 3951 | # First compile the header information (i.e. metadata)... | ||
| 3952 | # $saveHash{'file_type'} = $self->fileType; # Set below | ||
| 3953 | $saveHash{'script_name'} = $axmud::NAME_FILE; | ||
| 3954 | $saveHash{'script_version'} = $axmud::VERSION; | ||
| 3955 | $saveHash{'save_date'} = $axmud::CLIENT->localDate(); | ||
| 3956 | $saveHash{'save_time'} = $axmud::CLIENT->localTime(); | ||
| 3957 | # $saveHash{'assoc_world_prof'} = $self->assocWorldProf; # Set below | ||
| 3958 | |||
| 3959 | # ...then compile the data for this file type | ||
| 3960 | if ($switch eq '-d') { | ||
| 3961 | |||
| 3962 | # ;exd -d <profile> | ||
| 3963 | # Exports the non-world profile <profile>. If it's a custom profile, the profile | ||
| 3964 | # template is also exported. All of the profile's cages are also exported. (World | ||
| 3965 | # profiles can't be exported using this command - use ';exportfile' instead.) | ||
| 3966 | |||
| 3967 | my ( | ||
| 3968 | $profObj, | ||
| 3969 | %profHash, %cageHash, %templateHash, | ||
| 3970 | ); | ||
| 3971 | |||
| 3972 | # Prepare the data for a partial 'otherprof' file | ||
| 3973 | $profObj = $session->ivShow('profHash', $name); | ||
| 3974 | $profHash{$name} = $profObj; | ||
| 3975 | |||
| 3976 | foreach my $cageType ($axmud::CLIENT->cageTypeList) { | ||
| 3977 | |||
| 3978 | $cageHash{$name} = $session->findCage($cageType, $name); | ||
| 3979 | } | ||
| 3980 | |||
| 3981 | if ($session->ivExists('templateHash', $profObj->category)) { | ||
| 3982 | |||
| 3983 | # This is a custom profile, so we also need to export its parent profile template | ||
| 3984 | $templateHash{$profObj->category} | ||
| 3985 | = $session->ivShow('templateHash', $profObj->category); | ||
| 3986 | } | ||
| 3987 | |||
| 3988 | # Transfer everything into %saveHash | ||
| 3989 | $saveHash{'file_type'} = 'otherprof'; | ||
| 3990 | $saveHash{'assoc_world_prof'} = $session->currentWorld->name; | ||
| 3991 | $saveHash{'prof_priority_list'} = []; | ||
| 3992 | $saveHash{'template_hash'} = \%templateHash; # Possibly an empty hash | ||
| 3993 | $saveHash{'prof_hash'} = \%profHash; | ||
| 3994 | $saveHash{'cage_hash'} = \%cageHash; | ||
| 3995 | |||
| 3996 | } elsif ($switch eq '-t') { | ||
| 3997 | |||
| 3998 | # ;exd -t <cage> | ||
| 3999 | # Exports the single cage named <cage> | ||
| 4000 | |||
| 4001 | my %cageHash; | ||
| 4002 | |||
| 4003 | # Prepare the data for a partial 'otherprof' file | ||
| 4004 | $cageHash{$name} = $session->ivShow('cageHash', $name); | ||
| 4005 | |||
| 4006 | # Transfer everything into %saveHash | ||
| 4007 | $saveHash{'file_type'} = 'otherprof'; | ||
| 4008 | $saveHash{'assoc_world_prof'} = $session->currentWorld->name; | ||
| 4009 | $saveHash{'prof_priority_list'} = []; | ||
| 4010 | $saveHash{'template_hash'} = {}; | ||
| 4011 | $saveHash{'prof_hash'} = {}; | ||
| 4012 | $saveHash{'cage_hash'} = \%cageHash; | ||
| 4013 | |||
| 4014 | } elsif ($switch eq '-e') { | ||
| 4015 | |||
| 4016 | # ;exd -e <profile> | ||
| 4017 | # Exports all the cages belonging to the profile <profile>, but not the profile itself | ||
| 4018 | |||
| 4019 | my %cageHash; | ||
| 4020 | |||
| 4021 | # Prepare the data for a partial 'otherprof' file | ||
| 4022 | foreach my $cageType ($axmud::CLIENT->cageTypeList) { | ||
| 4023 | |||
| 4024 | $cageHash{$name} = $session->findCage($cageType, $name); | ||
| 4025 | } | ||
| 4026 | |||
| 4027 | # Transfer everything into %saveHash | ||
| 4028 | $saveHash{'file_type'} = 'otherprof'; | ||
| 4029 | $saveHash{'assoc_world_prof'} = $session->currentWorld->name; | ||
| 4030 | $saveHash{'prof_priority_list'} = []; | ||
| 4031 | $saveHash{'template_hash'} = {}; | ||
| 4032 | $saveHash{'prof_hash'} = {}; | ||
| 4033 | $saveHash{'cage_hash'} = \%cageHash; | ||
| 4034 | |||
| 4035 | } elsif ($switch eq '-s') { | ||
| 4036 | |||
| 4037 | # ;exd -s <skel> | ||
| 4038 | # Exports the template profile named <skel> | ||
| 4039 | |||
| 4040 | my %templateHash; | ||
| 4041 | |||
| 4042 | # Prepare the data for a partial 'otherprof' file | ||
| 4043 | $templateHash{$name} = $session->ivShow('templateHash', $name); | ||
| 4044 | |||
| 4045 | # Transfer everything into %saveHash | ||
| 4046 | $saveHash{'file_type'} = 'otherprof'; | ||
| 4047 | $saveHash{'assoc_world_prof'} = $session->currentWorld->name; | ||
| 4048 | $saveHash{'prof_priority_list'} = []; | ||
| 4049 | $saveHash{'template_hash'} = \%templateHash; | ||
| 4050 | $saveHash{'prof_hash'} = {}; | ||
| 4051 | $saveHash{'cage_hash'} = {}; | ||
| 4052 | |||
| 4053 | } elsif ($switch eq '-i') { | ||
| 4054 | |||
| 4055 | # ;exd -i <task> | ||
| 4056 | # Exports the (global) initial task named <task>. (Initial tasks belonging to a | ||
| 4057 | # profile can't be exported - you must export the whole profile) | ||
| 4058 | |||
| 4059 | my %initTaskHash; | ||
| 4060 | |||
| 4061 | # Prepare the data for a partial 'tasks' file | ||
| 4062 | $initTaskHash{$name} = $axmud::CLIENT->ivShow('initTaskHash', $name); | ||
| 4063 | |||
| 4064 | # Transfer everything into %saveHash | ||
| 4065 | $saveHash{'file_type'} = 'tasks'; | ||
| 4066 | $saveHash{'assoc_world_prof'} = undef; | ||
| 4067 | $saveHash{'task_label_hash'} = {}; | ||
| 4068 | $saveHash{'task_run_first_list'} = []; | ||
| 4069 | $saveHash{'task_run_last_list'} = []; | ||
| 4070 | $saveHash{'init_task_hash'} = \%initTaskHash; | ||
| 4071 | $saveHash{'init_task_order_list'} = []; | ||
| 4072 | $saveHash{'init_task_total'} = undef; | ||
| 4073 | $saveHash{'custom_task_hash'} = {}; | ||
| 4074 | $saveHash{'init_script_hash'} = {}; | ||
| 4075 | $saveHash{'init_script_order_list'} = []; | ||
| 4076 | |||
| 4077 | } elsif ($switch eq '-c') { | ||
| 4078 | |||
| 4079 | # ;exd -c <task> | ||
| 4080 | # Exports the custom task named <task> | ||
| 4081 | |||
| 4082 | my %customTaskHash; | ||
| 4083 | |||
| 4084 | # Prepare the data for a partial 'tasks' file | ||
| 4085 | $customTaskHash{$name} = $axmud::CLIENT->ivShow('customTaskHash', $name); | ||
| 4086 | |||
| 4087 | # Transfer everything into %saveHash | ||
| 4088 | $saveHash{'file_type'} = 'tasks'; | ||
| 4089 | $saveHash{'assoc_world_prof'} = undef; | ||
| 4090 | $saveHash{'task_label_hash'} = {}; | ||
| 4091 | $saveHash{'task_run_first_list'} = []; | ||
| 4092 | $saveHash{'task_run_last_list'} = []; | ||
| 4093 | $saveHash{'init_task_hash'} = {}; | ||
| 4094 | $saveHash{'init_task_order_list'} = []; | ||
| 4095 | $saveHash{'init_task_total'} = undef; | ||
| 4096 | $saveHash{'custom_task_hash'} = \%customTaskHash; | ||
| 4097 | $saveHash{'init_script_hash'} = {}; | ||
| 4098 | $saveHash{'init_script_order_list'} = []; | ||
| 4099 | |||
| 4100 | } elsif ($switch eq '-y') { | ||
| 4101 | |||
| 4102 | # ;exd -y <dict> | ||
| 4103 | # Exports the dictionary named <dict> | ||
| 4104 | |||
| 4105 | my %dictHash; | ||
| 4106 | |||
| 4107 | # Prepare the data for a partial 'dicts' file | ||
| 4108 | $dictHash{$name} = $axmud::CLIENT->ivShow('dictHash', $name); | ||
| 4109 | |||
| 4110 | # Transfer everything into %saveHash | ||
| 4111 | $saveHash{'file_type'} = 'dicts'; | ||
| 4112 | $saveHash{'assoc_world_prof'} = undef; | ||
| 4113 | $saveHash{'dict_hash'} = \%dictHash; | ||
| 4114 | |||
| 4115 | } elsif ($switch eq '-z') { | ||
| 4116 | |||
| 4117 | # ;exd -z <map> | ||
| 4118 | # Exports the zonemap named <map>, including all of its zone models | ||
| 4119 | |||
| 4120 | my %zonemapHash; | ||
| 4121 | |||
| 4122 | # Prepare the data for a partial 'zonemaps' file | ||
| 4123 | $zonemapHash{$name} = $axmud::CLIENT->ivShow('zonemapHash', $name); | ||
| 4124 | |||
| 4125 | # Transfer everything into %saveHash | ||
| 4126 | $saveHash{'file_type'} = 'zonemaps'; | ||
| 4127 | $saveHash{'assoc_world_prof'} = undef; | ||
| 4128 | $saveHash{'zonemap_hash'} = \%zonemapHash; | ||
| 4129 | $saveHash{'standard_zonemap_hash'} = {}; | ||
| 4130 | |||
| 4131 | } elsif ($switch eq '-p') { | ||
| 4132 | |||
| 4133 | # ;exd -p <map> | ||
| 4134 | # Exports the winmap named <map>, including all of its winzone objects | ||
| 4135 | |||
| 4136 | my %winmapHash; | ||
| 4137 | |||
| 4138 | # Prepare the data for a partial 'winmaps' file | ||
| 4139 | $winmapHash{$name} = $axmud::CLIENT->ivShow('winmapHash', $name); | ||
| 4140 | |||
| 4141 | # Transfer everything into %saveHash | ||
| 4142 | $saveHash{'file_type'} = 'winmaps'; | ||
| 4143 | $saveHash{'assoc_world_prof'} = undef; | ||
| 4144 | $saveHash{'winmap_hash'} = \%winmapHash; | ||
| 4145 | $saveHash{'standard_winmap_hash'} = {}; | ||
| 4146 | $saveHash{'default_main_winmap'} = undef; | ||
| 4147 | $saveHash{'default_internal_winmap'} = undef; | ||
| 4148 | $saveHash{'colour_scheme_hash'} = {}; | ||
| 4149 | |||
| 4150 | } elsif ($switch eq '-o') { | ||
| 4151 | |||
| 4152 | # ;exd -o <col> | ||
| 4153 | # Exports the colour scheme named <col> | ||
| 4154 | |||
| 4155 | my %colourSchemeHash; | ||
| 4156 | |||
| 4157 | # Prepare the data for a partial 'winmaps' file | ||
| 4158 | $colourSchemeHash{$name} = $axmud::CLIENT->ivShow('colourSchemeHash', $name); | ||
| 4159 | |||
| 4160 | # Transfer everything into %saveHash | ||
| 4161 | $saveHash{'file_type'} = 'winmaps'; | ||
| 4162 | $saveHash{'assoc_world_prof'} = undef; | ||
| 4163 | $saveHash{'winmap_hash'} = {}; | ||
| 4164 | $saveHash{'standard_winmap_hash'} = {}; | ||
| 4165 | $saveHash{'default_main_winmap'} = undef; | ||
| 4166 | $saveHash{'default_internal_winmap'} = undef; | ||
| 4167 | $saveHash{'colour_scheme_hash'} = \%colourSchemeHash; | ||
| 4168 | |||
| 4169 | } elsif ($switch eq '-x') { | ||
| 4170 | |||
| 4171 | # ;exd -x <obj> | ||
| 4172 | # Exports the text-to-speech object name <obj> | ||
| 4173 | |||
| 4174 | my %ttsHash; | ||
| 4175 | |||
| 4176 | # Prepare the data for a partial 'tts' file | ||
| 4177 | $ttsHash{$name} = $axmud::CLIENT->iShow('ttsObjHash', $name); | ||
| 4178 | |||
| 4179 | # Transfer everything into %saveHash | ||
| 4180 | $saveHash{'file_type'} = 'tts'; | ||
| 4181 | $saveHash{'assoc_world_prof'} = undef; | ||
| 4182 | $saveHash{'tts_obj_hash'} = \%ttsHash; | ||
| 4183 | } | ||
| 4184 | |||
| 4185 | # Set the suggested name for the data file | ||
| 4186 | $suggestFile = $name . '.amx'; | ||
| 4187 | |||
| 4188 | # Open a file chooser dialog to decide where to save the exported file | ||
| 4189 | # NB Private code, not included in the public release, sets the IV | ||
| 4190 | # GA::Client->privConfigAllWorld, in which case we use a certain file path, rather than | ||
| 4191 | # prompting the user for one | ||
| 4192 | if (! $axmud::CLIENT->privConfigAllWorld) { | ||
| 4193 | |||
| 4194 | $exportPath = $session->mainWin->showFileChooser( | ||
| 4195 | 'Export object', | ||
| 4196 | 'save', | ||
| 4197 | $suggestFile, | ||
| 4198 | ); | ||
| 4199 | |||
| 4200 | if (! $exportPath) { | ||
| 4201 | |||
| 4202 | # User canceleld | ||
| 4203 | return undef; | ||
| 4204 | } | ||
| 4205 | |||
| 4206 | } else { | ||
| 4207 | |||
| 4208 | $exportPath = $axmud::SHARE_DIR . '/items/worlds/' . $axmud::CLIENT->privConfigAllWorld | ||
| 4209 | . '/' . $axmud::CLIENT->privConfigAllWorld . '.amx'; | ||
| 4210 | } | ||
| 4211 | |||
| 4212 | # Save the special hash as a single object | ||
| 4213 | if (! Storable::lock_nstore(\%saveHash, $exportPath)) { | ||
| 4214 | |||
| 4215 | # Export failed | ||
| 4216 | return undef; | ||
| 4217 | |||
| 4218 | } else { | ||
| 4219 | |||
| 4220 | # Export complete | ||
| 4221 | return $exportPath; | ||
| 4222 | } | ||
| 4223 | } | ||
| 4224 | |||
| 4225 | sub importDataFile { | ||
| 4226 | |||
| 4227 | # Called by GA::Cmd::ImportData->do for the file types: | ||
| 4228 | # 'config' | ||
| 4229 | # | ||
| 4230 | # Loads an exported data file into memory, replacing existing data in memory only when | ||
| 4231 | # objects with the same name exist | ||
| 4232 | # | ||
| 4233 | # Expected arguments | ||
| 4234 | # $session - The calling function's GA::Session | ||
| 4235 | # $importPath - The full path of the file to import | ||
| 4236 | # | ||
| 4237 | # Return values | ||
| 4238 | # 'undef' on improper arguments, if loading of data files isn't allowed (because of global | ||
| 4239 | # flags), if the user cancels the load or if there is an error loading the data file | ||
| 4240 | # itself | ||
| 4241 | # Otherwise returns the filetype (e.g. 'worldprof' or 'tasks') | ||
| 4242 | |||
| 4243 | my ($self, $session, $importPath, $check) = @_; | ||
| 4244 | |||
| 4245 | # Local variables | ||
| 4246 | my ( | ||
| 4247 | $matchFlag, $hashRef, $fileType, $scriptName, $scriptVersion, $saveDate, $saveTime, | ||
| 4248 | $assocWorldProf, $fileObj, $result, $notCompatFlag, | ||
| 4249 | %loadHash, | ||
| 4250 | ); | ||
| 4251 | |||
| 4252 | # Check for improper arguments | ||
| 4253 | if (! defined $session || ! defined $importPath || defined $check) { | ||
| 4254 | |||
| 4255 | return $axmud::CLIENT->writeImproper($self->_objClass . '->importDataFile', @_); | ||
| 4256 | } | ||
| 4257 | |||
| 4258 | # Check it's the right file type for this function | ||
| 4259 | if ($self->fileType ne 'config') { | ||
| 4260 | |||
| 4261 | return $self->writeError( | ||
| 4262 | 'Wrong file type \'' . $self->fileType . '\'', | ||
| 4263 | $self->_objClass . '->importDataFile', | ||
| 4264 | ); | ||
| 4265 | } | ||
| 4266 | |||
| 4267 | # Don't load anything if the global flags forbid it | ||
| 4268 | if (! $axmud::CLIENT->loadDataFlag) { | ||
| 4269 | |||
| 4270 | return undef; | ||
| 4271 | } | ||
| 4272 | |||
| 4273 | # Check that the specified file exists | ||
| 4274 | if (! (-e $importPath)) { | ||
| 4275 | |||
| 4276 | # Before v1.0.868, Axmud used different file extensions; check them all | ||
| 4277 | OUTER: foreach my $ext (@axmud::COMPAT_EXT_LIST) { | ||
| 4278 | |||
| 4279 | my $altPath = $importPath; | ||
| 4280 | $altPath =~ s/\.axm/.$ext/; | ||
| 4281 | |||
| 4282 | if (-e $altPath) { | ||
| 4283 | |||
| 4284 | $matchFlag = TRUE; | ||
| 4285 | $importPath = $altPath; | ||
| 4286 | last OUTER; | ||
| 4287 | } | ||
| 4288 | } | ||
| 4289 | |||
| 4290 | if (! $matchFlag) { | ||
| 4291 | |||
| 4292 | return undef; | ||
| 4293 | } | ||
| 4294 | } | ||
| 4295 | |||
| 4296 | # Load all the data into an anonymous hash | ||
| 4297 | eval { $hashRef = Storable::lock_retrieve($importPath); }; | ||
| 4298 | if (! $hashRef) { | ||
| 4299 | |||
| 4300 | # ->lock_retrieve() failed | ||
| 4301 | return undef; | ||
| 4302 | |||
| 4303 | } else { | ||
| 4304 | |||
| 4305 | # Convert the anonymous hash referenced by $hashRef into a named hash | ||
| 4306 | %loadHash = %{$hashRef}; | ||
| 4307 | |||
| 4308 | # Before v1.0.868, Axmud had a different name. Update all header data | ||
| 4309 | if ( | ||
| 4310 | defined $loadHash{'script_version'} | ||
| 4311 | && $axmud::CLIENT->convertVersion($loadHash{'script_version'}) < 1_000_868 | ||
| 4312 | ) { | ||
| 4313 | %loadHash = $self->updateHeaderAfterRename(%loadHash); | ||
| 4314 | } | ||
| 4315 | |||
| 4316 | # Extract the header information (i.e. metadata) from the hash | ||
| 4317 | $fileType = $loadHash{'file_type'}; | ||
| 4318 | $scriptName = $loadHash{'script_name'}; | ||
| 4319 | $scriptVersion = $loadHash{'script_version'}; | ||
| 4320 | $saveDate = $loadHash{'save_date'}; | ||
| 4321 | $saveTime = $loadHash{'save_time'}; | ||
| 4322 | $assocWorldProf = $loadHash{'assoc_world_prof'}; | ||
| 4323 | |||
| 4324 | # Do checks on the header information | ||
| 4325 | if ( | ||
| 4326 | ! defined $fileType || ! defined $scriptName || ! defined $scriptVersion | ||
| 4327 | || ! defined $saveDate || ! defined $saveTime | ||
| 4328 | ) { | ||
| 4329 | # Missing or possibly corrupted header (NB $assocWorldProf can be 'undef') | ||
| 4330 | return undef; | ||
| 4331 | |||
| 4332 | } elsif ( | ||
| 4333 | ! $self->checkCompatibility($scriptName) | ||
| 4334 | || $axmud::CLIENT->convertVersion($scriptVersion) | ||
| 4335 | > $axmud::CLIENT->convertVersion($axmud::VERSION) | ||
| 4336 | ) { | ||
| 4337 | # Data file not created by a current or previous version of Axmud | ||
| 4338 | return undef; | ||
| 4339 | |||
| 4340 | } elsif ($fileType eq 'keycodes') { | ||
| 4341 | |||
| 4342 | # This type of data file was removed in v1.1.286 | ||
| 4343 | return undef; | ||
| 4344 | } | ||
| 4345 | |||
| 4346 | # Extract the rest of the data from %loadHash, incorporating data from the loaded file | ||
| 4347 | # into memory | ||
| 4348 | if ($fileType eq 'worldprof') { | ||
| 4349 | |||
| 4350 | # Call ->extractData on the file object belonging to the current world profile | ||
| 4351 | $fileObj = $session->ivShow( | ||
| 4352 | 'sessionFileObjHash', | ||
| 4353 | $session->currentWorld->name, | ||
| 4354 | ); | ||
| 4355 | |||
| 4356 | } elsif ($axmud::CLIENT->ivExists('fileObjHash', $fileType)) { | ||
| 4357 | |||
| 4358 | # Call ->extractData on the corresponding file object | ||
| 4359 | $fileObj = $axmud::CLIENT->ivShow('fileObjHash', $fileType); | ||
| 4360 | |||
| 4361 | } elsif ($session->ivExists('sessionFileObjHash', $fileType)) { | ||
| 4362 | |||
| 4363 | # Call ->extractData on the corresponding file object | ||
| 4364 | $fileObj = $session->ivShow('sessionFileObjHash', $fileType); | ||
| 4365 | |||
| 4366 | } else { | ||
| 4367 | |||
| 4368 | # No file object into which to incorporate the imported data | ||
| 4369 | return undef; | ||
| 4370 | } | ||
| 4371 | |||
| 4372 | # If the existing file object needs to be saved, asked permission before importing data | ||
| 4373 | # into it | ||
| 4374 | $result = $session->mainWin->showMsgDialogue( | ||
| 4375 | 'Overwrite unsaved data', | ||
| 4376 | 'question', | ||
| 4377 | 'The file you have specified may overwrite unsaved data in memory. Import the' | ||
| 4378 | . ' file anyway?', | ||
| 4379 | 'yes-no', | ||
| 4380 | ); | ||
| 4381 | |||
| 4382 | if ($result eq 'no') { | ||
| 4383 | |||
| 4384 | return undef; | ||
| 4385 | } | ||
| 4386 | |||
| 4387 | # Extract the imported data. The FALSE argument tells ->extractData that this is the | ||
| 4388 | # calling function | ||
| 4389 | $result = $fileObj->extractData(FALSE, %loadHash); | ||
| 4390 | if (! $result) { | ||
| 4391 | |||
| 4392 | # Import failed | ||
| 4393 | return undef; | ||
| 4394 | |||
| 4395 | } else { | ||
| 4396 | |||
| 4397 | # Return the file type of the imported file | ||
| 4398 | return $result; | ||
| 4399 | } | ||
| 4400 | } | ||
| 4401 | } | ||
| 4402 | |||
| 4403 | sub extractData { | ||
| 4404 | |||
| 4405 | # Called by $self->loadDataFile or $self->importDataFile | ||
| 4406 | # Processes an anonymous hash, referenced by %hashRef, containing data loaded from a file | ||
| 4407 | # Overwrites data in memory, then calls $self->updateExtractedData to update data from | ||
| 4408 | # previous versions of Axmud to make it work with the code in this version | ||
| 4409 | # | ||
| 4410 | # Expected arguments | ||
| 4411 | # $overWriteFlag - Set to TRUE when called by $self->loadDataFile. Overwites (most) | ||
| 4412 | # existing data in memory | ||
| 4413 | # - Set to FALSE when called by $self->importDataFile. Incorporates (most) | ||
| 4414 | # of the loaded data into memory, replacing identically named | ||
| 4415 | # objects, but retaining other existing objects in memory | ||
| 4416 | # %loadHash - A hash containing all the loaded data (including header data) | ||
| 4417 | # | ||
| 4418 | # Notes | ||
| 4419 | # $overWriteFlag works on the following general principle: | ||
| 4420 | # | ||
| 4421 | # If $overWriteFlag = TRUE, when tasks.axm contains the custom tasks 'task3' and 'task4', | ||
| 4422 | # and when the custom tasks 'task1' and 'task2' are in memory, after loading only | ||
| 4423 | # 'task3' and 'task4' are in memory. | ||
| 4424 | # If $overWriteFlag = FALSE, when tasks.axm contains the custom task 'task3', and when the | ||
| 4425 | # custom tasks 'task1' and 'task2' are in memory, all three tasks will be in memory | ||
| 4426 | # at the end of the operation. However, if tasks.amx contains 'task2', the 'task2' in | ||
| 4427 | # memory will be overwritten | ||
| 4428 | # | ||
| 4429 | # The precise behaviour for each file type is as follows: | ||
| 4430 | # 'worldprof' | ||
| 4431 | # (T) The loaded world profile replaces one in memory with the same name | ||
| 4432 | # (F) (This function should not be called) | ||
| 4433 | # 'otherprof' | ||
| 4434 | # (T) All existing non-world profiles, cages and templates are destroyed and | ||
| 4435 | # replaced with any loaded ones. The existing world profile is not replaced | ||
| 4436 | # (F) We are importing a single non-world profile, or a single template; this | ||
| 4437 | # replaces one in memory with the same name. For profiles, the cages are | ||
| 4438 | # updated | ||
| 4439 | # 'worldmodel' | ||
| 4440 | # The entire world model in memory is replaced by the loaded one, regardless of | ||
| 4441 | # the flag | ||
| 4442 | # 'tasks', 'scripts', 'contacts', 'tts' | ||
| 4443 | # Behaviour as described above | ||
| 4444 | # 'dicts' | ||
| 4445 | # (T) Any current dictionaries in use by a session are retained, if a dictionary | ||
| 4446 | # with the same name doesn't exist in the loaded file, but dictionaries | ||
| 4447 | # not in use are replaced. Otherwise, all dictionaries are replaced | ||
| 4448 | # (F) If one of the loaded dictionaries has the same name as a current dictionary | ||
| 4449 | # in use by any session, that current dictionary is replaced. Otherwise, | ||
| 4450 | # all dictionaries are incorporated | ||
| 4451 | # 'toolbar' | ||
| 4452 | # The entire list of toolbar buttons in memory is replaced by the loaded one, | ||
| 4453 | # regardless of the flag | ||
| 4454 | # 'usercmds' | ||
| 4455 | # (T) It's quite common for new commands to be added in between versions of Axmud. | ||
| 4456 | # Any user commands corresponding to standard commands that didn't exist | ||
| 4457 | # before are retained, but all other user commands are replaced | ||
| 4458 | # (F) (This function should not be called) | ||
| 4459 | # 'zonemaps' | ||
| 4460 | # (T) All zonemaps in memory are replaced. The workspace grids used by all | ||
| 4461 | # sessions are reset (when they exist). Any workspaces using a default | ||
| 4462 | # zonemap which no longer exists are given a new default zonemap. Any | ||
| 4463 | # workspace grids using a zonemap which no longer exists are reset to use | ||
| 4464 | # the workspace's default zonemap | ||
| 4465 | # (F) Loaded data incorporated into memory. Any workspace grids using a loaded | ||
| 4466 | # zonemap are reset | ||
| 4467 | # 'winmaps' | ||
| 4468 | # (T) All winmaps/colour schemes in memory are replaced; no existing windows are | ||
| 4469 | # affected, since winmaps are only applied when a window is created, and | ||
| 4470 | # colour schemes are only applied periodically | ||
| 4471 | # (F) Loaded data incorporated into memory | ||
| 4472 | # 'tts' | ||
| 4473 | # (T) All existing data in memory replaced by loaded data | ||
| 4474 | # (F) Loaded data incorporated into memory | ||
| 4475 | # | ||
| 4476 | # Return values | ||
| 4477 | # 'undef' on improper arguments | ||
| 4478 | # Otherwise returns the filetype (e.g. 'worldprof' or 'tasks') | ||
| 4479 | |||
| 4480 | my ($self, $overWriteFlag, %loadHash) = @_; | ||
| 4481 | |||
| 4482 | # Local variables | ||
| 4483 | my ( | ||
| 4484 | $client, $session, | ||
| 4485 | %hash, | ||
| 4486 | ); | ||
| 4487 | |||
| 4488 | # Check for improper arguments | ||
| 4489 | if (! defined $overWriteFlag) { | ||
| 4490 | |||
| 4491 | return $axmud::CLIENT->writeImproper($self->_objClass . '->extractData', @_); | ||
| 4492 | } | ||
| 4493 | |||
| 4494 | # Import shortcuts for the GA::Client and GA::Session | ||
| 4495 | $client = $axmud::CLIENT; | ||
| 4496 | $session = $self->session; | ||
| 4497 | |||
| 4498 | # Before v1.0.868, Axmud had a different name. Update all file data | ||
| 4499 | if ($axmud::CLIENT->convertVersion($self->scriptVersion) < 1_000_868) { | ||
| 4500 | |||
| 4501 | %loadHash = $self->updateDataAfterRename(%loadHash); | ||
| 4502 | } | ||
| 4503 | |||
| 4504 | # Extract the data | ||
| 4505 | if ($self->fileType eq 'worldprof') { | ||
| 4506 | |||
| 4507 | # 'worldprof' | ||
| 4508 | # (T) The loaded world profile replaces one in memory with the same name | ||
| 4509 | # (F) (This function should not be called) | ||
| 4510 | |||
| 4511 | if ($overWriteFlag) { | ||
| 4512 | |||
| 4513 | # (When overwriting, set IVs directly, rather than using 'set' accessors) | ||
| 4514 | |||
| 4515 | # Replace a profile in memory with the same name | ||
| 4516 | $client->ivAdd( | ||
| 4517 | 'worldProfHash', | ||
| 4518 | $self->assocWorldProf, | ||
| 4519 | $loadHash{'world_prof'}, | ||
| 4520 | ); | ||
| 4521 | |||
| 4522 | # Every session using this world must also have its profile registry updated | ||
| 4523 | foreach my $session ($axmud::CLIENT->listSessions()) { | ||
| 4524 | |||
| 4525 | if ($session->currentWorld->name eq $self->assocWorldProf) { | ||
| 4526 | |||
| 4527 | $session->ivAdd('profHash', $self->assocWorldProf, $loadHash{'world_prof'}); | ||
| 4528 | } | ||
| 4529 | } | ||
| 4530 | |||
| 4531 | # The data in memory matches the one in saved data files | ||
| 4532 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4533 | |||
| 4534 | } else { | ||
| 4535 | |||
| 4536 | # (When not overwriting, use 'set' accessors, since the data in memory no longer | ||
| 4537 | # matches the saved file) | ||
| 4538 | |||
| 4539 | # (Should not be able to import a partial 'worldprof' file, since | ||
| 4540 | # $self->exportDataFile doesn't create one) | ||
| 4541 | return undef; | ||
| 4542 | } | ||
| 4543 | |||
| 4544 | } elsif ($self->fileType eq 'otherprof') { | ||
| 4545 | |||
| 4546 | # 'otherprof' | ||
| 4547 | # (T) All existing non-world profiles, cages and templates are destroyed and replaced | ||
| 4548 | # with any loaded ones. The existing world profile is not replaced | ||
| 4549 | # (F) We are importing a single non-world profile, or a single template; this replaces | ||
| 4550 | # one in memory with the same name. For profiles, the cages are updated | ||
| 4551 | |||
| 4552 | my ($worldProfObj, $modFlag); | ||
| 4553 | |||
| 4554 | if ($overWriteFlag) { | ||
| 4555 | |||
| 4556 | # We are loading all the non-world profiles associated with a world profile, and all | ||
| 4557 | # the cages/templates associated with them | ||
| 4558 | # If GA::Session->profHash contains a world profile, it is not replaced (but | ||
| 4559 | # everything else is) | ||
| 4560 | |||
| 4561 | # Find the world profile already in memory | ||
| 4562 | OUTER: foreach my $profObj ($session->ivValues('profHash')) { | ||
| 4563 | |||
| 4564 | if ($profObj->category eq 'world') { | ||
| 4565 | |||
| 4566 | $worldProfObj = $profObj; | ||
| 4567 | last OUTER; | ||
| 4568 | } | ||
| 4569 | } | ||
| 4570 | |||
| 4571 | # Replace the contents of the profile registry | ||
| 4572 | $session->ivPoke('profHash', %{$loadHash{'prof_hash'}}); | ||
| 4573 | if ($worldProfObj) { | ||
| 4574 | |||
| 4575 | $session->ivAdd('profHash', $worldProfObj->name, $worldProfObj); | ||
| 4576 | } | ||
| 4577 | |||
| 4578 | # Replace the contents of other IVs | ||
| 4579 | $session->ivPoke('profPriorityList', @{$loadHash{'prof_priority_list'}}); | ||
| 4580 | $session->ivPoke('templateHash', %{$loadHash{'template_hash'}}); | ||
| 4581 | $session->ivPoke('cageHash', %{$loadHash{'cage_hash'}}); | ||
| 4582 | |||
| 4583 | # The data in memory matches saved data files | ||
| 4584 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4585 | # Cages for the world profile have been loaded (probably), so its file object must | ||
| 4586 | # be marked as having had its data changed | ||
| 4587 | $client->setModifyFlag( | ||
| 4588 | $loadHash{'assoc_world_prof'}, | ||
| 4589 | TRUE, | ||
| 4590 | $self->_objClass . '->extractData', | ||
| 4591 | ); | ||
| 4592 | |||
| 4593 | } else { | ||
| 4594 | |||
| 4595 | # We are loading one or more non-world profiles, templates or cages that have been | ||
| 4596 | # exported and must be re-incorporated into memory | ||
| 4597 | |||
| 4598 | # Incorporate non-world profiles and their corresponding cages | ||
| 4599 | %hash = %{$loadHash{'prof_hash'}}; | ||
| 4600 | if (%hash) { | ||
| 4601 | |||
| 4602 | foreach my $profObj (values %hash) { | ||
| 4603 | |||
| 4604 | $session->add_prof($profObj); | ||
| 4605 | } | ||
| 4606 | } | ||
| 4607 | |||
| 4608 | %hash = %{$loadHash{'cage_hash'}}; | ||
| 4609 | if (%hash) { | ||
| 4610 | |||
| 4611 | foreach my $cageObj (values %hash) { | ||
| 4612 | |||
| 4613 | $session->add_cage($cageObj); | ||
| 4614 | } | ||
| 4615 | } | ||
| 4616 | |||
| 4617 | %hash = %{$loadHash{'template_hash'}}; | ||
| 4618 | if (%hash) { | ||
| 4619 | |||
| 4620 | foreach my $templateObj (values %hash) { | ||
| 4621 | |||
| 4622 | $session->add_template($templateObj); | ||
| 4623 | } | ||
| 4624 | } | ||
| 4625 | |||
| 4626 | # (Calls to accessors will have set the right ->modifyFlag values) | ||
| 4627 | } | ||
| 4628 | |||
| 4629 | } elsif ($self->fileType eq 'worldmodel') { | ||
| 4630 | |||
| 4631 | # 'worldmodel' | ||
| 4632 | # The entire world model in memory is replaced by the loaded one, regardless of | ||
| 4633 | # the value of $overWriteFlag | ||
| 4634 | |||
| 4635 | my $swapFlag; | ||
| 4636 | |||
| 4637 | $session->ivPoke('worldModelObj', $loadHash{'world_model_obj'}); | ||
| 4638 | |||
| 4639 | if ($overWriteFlag) { | ||
| 4640 | |||
| 4641 | # The data in memory matches saved data files | ||
| 4642 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4643 | |||
| 4644 | } else { | ||
| 4645 | |||
| 4646 | # The data in memory doesn't match saved data files | ||
| 4647 | $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData'); | ||
| 4648 | } | ||
| 4649 | |||
| 4650 | # If the world model belonging to one world was imported into another using | ||
| 4651 | # ;importFiles, the world model's ->_parentWorld won't have been updated yet | ||
| 4652 | if ($session->worldModelObj->_parentWorld ne $session->currentWorld->name) { | ||
| 4653 | |||
| 4654 | # Update it now | ||
| 4655 | $session->worldModelObj->{_parentWorld} = $session->currentWorld->name; | ||
| 4656 | $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData'); | ||
| 4657 | # This file object's IV is also wrong | ||
| 4658 | $self->ivPoke('assocWorldProf', $session->currentWorld->name); | ||
| 4659 | } | ||
| 4660 | |||
| 4661 | # Delete any temporary regions from the world model | ||
| 4662 | # $self->updateExtractedData hasn't been called yet, so before v1.0.871, | ||
| 4663 | # ->regionModelHash will still be ->regionModel | ||
| 4664 | if ( | ||
| 4665 | $self->scriptConvertVersion < 1_000_871 | ||
| 4666 | && ! exists $session->worldModelObj->{regionModelHash} | ||
| 4667 | ) { | ||
| 4668 | # Swap the IV name temporarily, so ->deleteTempRegions doesn't get confused | ||
| 4669 | $session->worldModelObj->{regionModelHash} = $session->worldModelObj->{regionModel}; | ||
| 4670 | delete $session->worldModelObj->{regionModel}; | ||
| 4671 | $swapFlag = TRUE; | ||
| 4672 | } | ||
| 4673 | |||
| 4674 | $session->worldModelObj->deleteTempRegions( | ||
| 4675 | $session, | ||
| 4676 | TRUE, # Update any Automapper windows that are already open | ||
| 4677 | ); | ||
| 4678 | |||
| 4679 | if ($swapFlag) { | ||
| 4680 | |||
| 4681 | # Restore the IV names, so $self->updateExtractedData doesn't get confused | ||
| 4682 | $session->worldModelObj->{regionModel} = $session->worldModelObj->{regionModelHash}; | ||
| 4683 | delete $session->worldModelObj->{regionModelHash}; | ||
| 4684 | } | ||
| 4685 | |||
| 4686 | } elsif ($self->fileType eq 'tasks') { | ||
| 4687 | |||
| 4688 | # 'tasks' | ||
| 4689 | # (T) All existing data in memory replaced by loaded data | ||
| 4690 | # (F) Loaded data incorporated into memory | ||
| 4691 | |||
| 4692 | if ($overWriteFlag) { | ||
| 4693 | |||
| 4694 | # Replace the data in memory | ||
| 4695 | $client->ivPoke('taskLabelHash', %{$loadHash{'task_label_hash'}}); | ||
| 4696 | $client->ivPoke('taskRunFirstList', @{$loadHash{'task_run_first_list'}}); | ||
| 4697 | $client->ivPoke('taskRunLastList', @{$loadHash{'task_run_last_list'}}); | ||
| 4698 | $client->ivPoke('initTaskHash', %{$loadHash{'init_task_hash'}}); | ||
| 4699 | $client->ivPoke('initTaskOrderList', @{$loadHash{'init_task_order_list'}}); | ||
| 4700 | $client->ivPoke('initTaskTotal', $loadHash{'init_task_total'}); | ||
| 4701 | $client->ivPoke('customTaskHash', %{$loadHash{'custom_task_hash'}}); | ||
| 4702 | |||
| 4703 | # The data in memory matches saved data files | ||
| 4704 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4705 | |||
| 4706 | } else { | ||
| 4707 | |||
| 4708 | # We are loading one or more global initial task or custom task that have been | ||
| 4709 | # exported and must be re-incorporated into memory | ||
| 4710 | |||
| 4711 | # Incorporate tasks | ||
| 4712 | %hash = %{$loadHash{'init_task_hash'}}; | ||
| 4713 | foreach my $taskObj (values %hash) { | ||
| 4714 | |||
| 4715 | # Give the task a new unique name, before adding it to the client's registries | ||
| 4716 | $taskObj->updateTaskLists(); | ||
| 4717 | } | ||
| 4718 | |||
| 4719 | %hash = %{$loadHash{'custom_task_hash'}}; | ||
| 4720 | foreach my $taskObj (values %hash) { | ||
| 4721 | |||
| 4722 | # Give the task a new unique name, before adding it to the client's registries | ||
| 4723 | $taskObj->updateTaskLists(); | ||
| 4724 | } | ||
| 4725 | |||
| 4726 | # (Calls to accessors will have set the right ->modifyFlag values) | ||
| 4727 | } | ||
| 4728 | |||
| 4729 | } elsif ($self->fileType eq 'scripts') { | ||
| 4730 | |||
| 4731 | # 'scripts' | ||
| 4732 | # (T) All existing data in memory replaced by loaded data | ||
| 4733 | # (F) Loaded data incorporated into memory | ||
| 4734 | |||
| 4735 | if ($overWriteFlag) { | ||
| 4736 | |||
| 4737 | # Replace the data in memory | ||
| 4738 | $client->ivPoke('scriptDirList', @{$loadHash{'script_dir_list'}}); | ||
| 4739 | $client->ivPoke('initScriptHash', %{$loadHash{'init_script_hash'}}); | ||
| 4740 | $client->ivPoke('initScriptOrderList', @{$loadHash{'init_script_order_list'}}); | ||
| 4741 | |||
| 4742 | # The data in memory matches saved data files | ||
| 4743 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4744 | |||
| 4745 | } else { | ||
| 4746 | |||
| 4747 | # Incorporate script directories into memory | ||
| 4748 | foreach my $dir (@{$loadHash{'script_dir_list'}}) { | ||
| 4749 | |||
| 4750 | # Only add directories which aren't already in the script directory list | ||
| 4751 | if (! defined $client->ivFind('scriptDirList', $dir)) { | ||
| 4752 | |||
| 4753 | $client->ivPush('scriptDirList', $dir); | ||
| 4754 | } | ||
| 4755 | } | ||
| 4756 | |||
| 4757 | # Incorporate initial scripts into memory | ||
| 4758 | %hash = %{$loadHash{'init_script_hash'}}; | ||
| 4759 | foreach my $script (keys %hash) { | ||
| 4760 | |||
| 4761 | if ($client->ivExists('initScriptHash', $script)) { | ||
| 4762 | |||
| 4763 | # Replace the entry (the script's position in ->initScriptOrderList remains | ||
| 4764 | # unchanged) | ||
| 4765 | $client->ivAdd('initScriptHash', $script, $hash{$script}); | ||
| 4766 | |||
| 4767 | } else { | ||
| 4768 | |||
| 4769 | # Add a new entry | ||
| 4770 | $client->ivAdd('initScriptHash', $script, $hash{$script}); | ||
| 4771 | $client->ivPush('initScriptOrderList', $script); | ||
| 4772 | } | ||
| 4773 | } | ||
| 4774 | |||
| 4775 | # The data in memory doesn't match saved data files | ||
| 4776 | $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData'); | ||
| 4777 | } | ||
| 4778 | |||
| 4779 | } elsif ($self->fileType eq 'contacts') { | ||
| 4780 | |||
| 4781 | # 'contacts' | ||
| 4782 | # (T) All existing data in memory replaced by loaded data | ||
| 4783 | # (F) Loaded data incorporated into memory | ||
| 4784 | |||
| 4785 | if ($overWriteFlag) { | ||
| 4786 | |||
| 4787 | # Replace the data in memory | ||
| 4788 | $client->ivPoke('chatName', $loadHash{'chat_name'}); | ||
| 4789 | $client->ivPoke('chatEmail', $loadHash{'chat_email'}); | ||
| 4790 | $client->ivPoke('chatAcceptMode', $loadHash{'chat_accept_mode'}); | ||
| 4791 | $client->ivPoke('chatContactHash', %{$loadHash{'chat_contact_hash'}}); | ||
| 4792 | $client->ivPoke('chatIcon', $loadHash{'chat_icon'}); | ||
| 4793 | $client->ivPoke('chatSmileyHash', %{$loadHash{'chat_smiley_hash'}}); | ||
| 4794 | |||
| 4795 | # The data in memory matches saved data files | ||
| 4796 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4797 | |||
| 4798 | } else { | ||
| 4799 | |||
| 4800 | # (Should not be able to import a partial 'contacts' file, since | ||
| 4801 | # $self->exportDataFile doesn't create one) | ||
| 4802 | return undef; | ||
| 4803 | } | ||
| 4804 | |||
| 4805 | } elsif ($self->fileType eq 'dicts') { | ||
| 4806 | |||
| 4807 | # (T) Any current dictionaries in use by a session are retained, if a dictionary with | ||
| 4808 | # the same name doesn't exist in the loaded file, but dictionaries not in use are | ||
| 4809 | # replaced. Otherwise, all dictionaries are replaced | ||
| 4810 | # (F) If one of the loaded dictionaries has the same name as a current dictionary in use | ||
| 4811 | # by any session, that current dictionary is replaced. Otherwise, all dictionaries | ||
| 4812 | # are incorporated | ||
| 4813 | |||
| 4814 | my %dictHash; | ||
| 4815 | |||
| 4816 | if ($overWriteFlag) { | ||
| 4817 | |||
| 4818 | # Get a hash of dictionaries in use by all sessions | ||
| 4819 | foreach my $otherSession ($axmud::CLIENT->listSessions()) { | ||
| 4820 | |||
| 4821 | my $dictObj = $otherSession->currentDict; | ||
| 4822 | |||
| 4823 | $dictHash{$dictObj->name} = $dictObj; | ||
| 4824 | } | ||
| 4825 | |||
| 4826 | # Replace the dictionary registry... | ||
| 4827 | $client->ivPoke('dictHash', %{$loadHash{'dict_hash'}}); | ||
| 4828 | # (So far, the data in memory matches saved data files) | ||
| 4829 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4830 | # ...but retain any current dictionaries which don't appear in it | ||
| 4831 | foreach my $dictObj (values %dictHash) { | ||
| 4832 | |||
| 4833 | if (! $client->ivExists('dictHash', $dictObj->name)) { | ||
| 4834 | |||
| 4835 | $client->add_dict($dictObj); # Updates ->modifyFlag | ||
| 4836 | } | ||
| 4837 | } | ||
| 4838 | |||
| 4839 | # Update the current dictionary object stored by every session | ||
| 4840 | foreach my $otherSession ($client->listSessions()) { | ||
| 4841 | |||
| 4842 | my ($currentObj, $loadObj); | ||
| 4843 | |||
| 4844 | $currentObj = $otherSession->currentDict; | ||
| 4845 | $loadObj = $client->ivShow('dictHash', $currentObj->name); | ||
| 4846 | |||
| 4847 | if ($currentObj ne $loadObj) { | ||
| 4848 | |||
| 4849 | $otherSession->set_currentDict($loadObj); | ||
| 4850 | } | ||
| 4851 | } | ||
| 4852 | |||
| 4853 | } else { | ||
| 4854 | |||
| 4855 | # Incorporate dictionaries | ||
| 4856 | %dictHash = %{$loadHash{'dict_hash'}}; | ||
| 4857 | if (%dictHash) { | ||
| 4858 | |||
| 4859 | foreach my $dictObj (values %dictHash) { | ||
| 4860 | |||
| 4861 | $client->add_dict($dictObj); | ||
| 4862 | } | ||
| 4863 | } | ||
| 4864 | |||
| 4865 | # Update the current dictionary object stored by every session | ||
| 4866 | foreach my $otherSession ($client->listSessions()) { | ||
| 4867 | |||
| 4868 | my ($currentObj, $loadObj); | ||
| 4869 | |||
| 4870 | $currentObj = $otherSession->currentDict; | ||
| 4871 | $loadObj = $client->ivShow('dictHash', $currentObj->name); | ||
| 4872 | |||
| 4873 | if ($currentObj ne $loadObj) { | ||
| 4874 | |||
| 4875 | $otherSession->set_currentDict($loadObj); | ||
| 4876 | } | ||
| 4877 | } | ||
| 4878 | |||
| 4879 | # (Calls to accessors will have set the right ->modifyFlag values) | ||
| 4880 | } | ||
| 4881 | |||
| 4882 | } elsif ($self->fileType eq 'toolbar') { | ||
| 4883 | |||
| 4884 | # 'toolbar' | ||
| 4885 | # The entire list of toolbar buttons in memory is replaced by the loaded one, | ||
| 4886 | # regardless of the flag | ||
| 4887 | |||
| 4888 | $axmud::CLIENT->ivPoke('toolbarHash', %{$loadHash{'toolbar_hash'}}); | ||
| 4889 | $axmud::CLIENT->ivPoke('toolbarList', @{$loadHash{'toolbar_list'}}); | ||
| 4890 | |||
| 4891 | if ($overWriteFlag) { | ||
| 4892 | |||
| 4893 | # The data in memory matches saved data files | ||
| 4894 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4895 | |||
| 4896 | } else { | ||
| 4897 | |||
| 4898 | # The data in memory doesn't match saved data files | ||
| 4899 | $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData'); | ||
| 4900 | } | ||
| 4901 | |||
| 4902 | # Redraw toolbar buttons in all 'internal' windows | ||
| 4903 | foreach my $winObj ($axmud::CLIENT->desktopObj->ivValues('gridWinHash')) { | ||
| 4904 | |||
| 4905 | my $stripObj; | ||
| 4906 | |||
| 4907 | if ( | ||
| 4908 | $winObj->winType eq 'main' | ||
| 4909 | || $winObj->winType eq 'protocol' | ||
| 4910 | || $winObj->winType eq 'custom' | ||
| 4911 | ) { | ||
| 4912 | $stripObj = $winObj->ivShow('firstStripHash', 'Games::Axmud::Strip::Toolbar'); | ||
| 4913 | if ($stripObj) { | ||
| 4914 | |||
| 4915 | $stripObj->resetToolbar(); | ||
| 4916 | } | ||
| 4917 | } | ||
| 4918 | } | ||
| 4919 | |||
| 4920 | } elsif ($self->fileType eq 'usercmds') { | ||
| 4921 | |||
| 4922 | # 'usercmds' | ||
| 4923 | # (T) It's quite common for new commands to be added in newer versions of Axmud. | ||
| 4924 | # Any user commands corresponding to client commands that didn't exist before | ||
| 4925 | # are retained, but all other user commands are replaced | ||
| 4926 | # (F) (This function should not be called) | ||
| 4927 | |||
| 4928 | my ( | ||
| 4929 | $modFlag, | ||
| 4930 | %standardHash, %currentHash, %newLoadHash, %loadStandardHash, | ||
| 4931 | ); | ||
| 4932 | |||
| 4933 | if ($overWriteFlag) { | ||
| 4934 | |||
| 4935 | %hash = %{$loadHash{'user_cmd_hash'}}; | ||
| 4936 | |||
| 4937 | # Import this Axmud version's client command and user command hashes for quick | ||
| 4938 | # lookup | ||
| 4939 | %standardHash = $client->clientCmdHash; | ||
| 4940 | %currentHash = $client->userCmdHash; | ||
| 4941 | |||
| 4942 | # From the loaded hash of user commands, filter out any which relate to (standard) | ||
| 4943 | # client commands which aren't being used by this version of Axmud | ||
| 4944 | foreach my $userCmd (keys %hash) { | ||
| 4945 | |||
| 4946 | my $standardCmd = $hash{$userCmd}; | ||
| 4947 | |||
| 4948 | if (exists $standardHash{$userCmd}) { | ||
| 4949 | |||
| 4950 | $newLoadHash{$userCmd} = $standardCmd; | ||
| 4951 | # Also build a hash of all the standard commands used in the loaded file | ||
| 4952 | $loadStandardHash{$standardCmd} = undef; | ||
| 4953 | |||
| 4954 | } else { | ||
| 4955 | |||
| 4956 | # At least one command filtered out, so the data in memory won't match the | ||
| 4957 | # data file | ||
| 4958 | $modFlag = TRUE; | ||
| 4959 | } | ||
| 4960 | } | ||
| 4961 | |||
| 4962 | # From the current hash of user commands, retain any user commands which correspond | ||
| 4963 | # to (standard) client commands not used in the loaded file | ||
| 4964 | foreach my $userCmd (keys %currentHash) { | ||
| 4965 | |||
| 4966 | my $standardCmd = $currentHash{$userCmd}; | ||
| 4967 | |||
| 4968 | if (! exists $loadStandardHash{$standardCmd}) { | ||
| 4969 | |||
| 4970 | # Retain this command | ||
| 4971 | $newLoadHash{$userCmd} = $standardCmd; | ||
| 4972 | # At least one command retained, so the data in memory won't match the data | ||
| 4973 | # file | ||
| 4974 | $modFlag = TRUE; | ||
| 4975 | } | ||
| 4976 | } | ||
| 4977 | |||
| 4978 | # Replace the client's current list of user commands | ||
| 4979 | $client->ivPoke('userCmdHash', %newLoadHash); | ||
| 4980 | |||
| 4981 | if ($modFlag) { | ||
| 4982 | $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData'); | ||
| 4983 | } else { | ||
| 4984 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 4985 | } | ||
| 4986 | |||
| 4987 | } else { | ||
| 4988 | |||
| 4989 | # (Should not be able to import a partial 'usercmds' file, since | ||
| 4990 | # $self->exportDataFile doesn't create one) | ||
| 4991 | return undef; | ||
| 4992 | } | ||
| 4993 | |||
| 4994 | } elsif ($self->fileType eq 'zonemaps') { | ||
| 4995 | |||
| 4996 | # (T) All zonemaps in memory are replaced. The workspace grids used by all sessions are | ||
| 4997 | # reset (when they exist). Any workspaces using a default zonemap which no longer | ||
| 4998 | # exists are given a new default zonemap. Any workspace grids using a zonemap which no | ||
| 4999 | # longer exists are reset to use the workspace's default zonemap | ||
| 5000 | # (F) Loaded data incorporated into memory. Any workspace grids using a loaded zonemap | ||
| 5001 | # are reset | ||
| 5002 | |||
| 5003 | if ($overWriteFlag) { | ||
| 5004 | |||
| 5005 | # Replace the data in memory | ||
| 5006 | $client->ivPoke('zonemapHash', %{$loadHash{'zonemap_hash'}}); | ||
| 5007 | $client->ivPoke('standardZonemapHash', %{$loadHash{'standard_zonemap_hash'}}); | ||
| 5008 | |||
| 5009 | # Check that the default zonemap for all workspaces still exists and, if not, | ||
| 5010 | # replace it with a standard one | ||
| 5011 | foreach my $workspaceObj ($axmud::CLIENT->desktopObj->ivValues('workspaceHash')) { | ||
| 5012 | |||
| 5013 | if ( | ||
| 5014 | $workspaceObj->defaultZonemap | ||
| 5015 | && ! $axmud::CLIENT->ivExists('zonemapHash', $workspaceObj->defaultZonemap) | ||
| 5016 | ) { | ||
| 5017 | if ($axmud::CLIENT->shareMainWinFlag) { | ||
| 5018 | $workspaceObj->set_defaultZonemap('basic'); | ||
| 5019 | } else { | ||
| 5020 | $workspaceObj->set_defaultZonemap('single'); | ||
| 5021 | } | ||
| 5022 | } | ||
| 5023 | |||
| 5024 | # Reset all workspace grids, changing the zonemap used by any workspace grid | ||
| 5025 | # when that zonemap no longer exists | ||
| 5026 | foreach my $gridObj ($workspaceObj->ivValues('gridHash')) { | ||
| 5027 | |||
| 5028 | my ($obj, $defaultObj); | ||
| 5029 | |||
| 5030 | $obj = $axmud::CLIENT->ivShow('zonemapHash', $gridObj->zonemap); | ||
| 5031 | if (! $obj) { | ||
| 5032 | |||
| 5033 | $defaultObj = $axmud::CLIENT->ivShow( | ||
| 5034 | 'zonemapHash', | ||
| 5035 | $workspaceObj->defaultZonemap, | ||
| 5036 | ); | ||
| 5037 | |||
| 5038 | |||
| 5039 | $gridObj->applyZonemap($defaultObj); | ||
| 5040 | } | ||
| 5041 | } | ||
| 5042 | } | ||
| 5043 | |||
| 5044 | # The data in memory matches saved data files | ||
| 5045 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 5046 | |||
| 5047 | } else { | ||
| 5048 | |||
| 5049 | # We are loading one or more global zonemap objects that have been exported and | ||
| 5050 | # must be re-incorporated into memory | ||
| 5051 | |||
| 5052 | # Incorporate zonemap objects | ||
| 5053 | %hash = %{$loadHash{'zonemap_hash'}}; | ||
| 5054 | if (%hash) { | ||
| 5055 | |||
| 5056 | foreach my $zonemapObj (values %hash) { | ||
| 5057 | |||
| 5058 | $client->add_zonemap($zonemapObj); | ||
| 5059 | } | ||
| 5060 | } | ||
| 5061 | |||
| 5062 | # Any workspace grids using one of the incorporated zonemaps must be reset | ||
| 5063 | foreach my $gridObj ($axmud::CLIENT->desktopObj->ivValues('gridHash')) { | ||
| 5064 | |||
| 5065 | if ($gridObj->zonemap && exists $hash{$gridObj->zonemap}) { | ||
| 5066 | |||
| 5067 | $gridObj->applyZonemap( | ||
| 5068 | $axmud::CLIENT->ivShow('zonemapHash', $gridObj->zonemap), | ||
| 5069 | ); | ||
| 5070 | } | ||
| 5071 | } | ||
| 5072 | |||
| 5073 | # (Calls to accessors will have set the right ->modifyFlag values) | ||
| 5074 | } | ||
| 5075 | |||
| 5076 | } elsif ($self->fileType eq 'winmaps') { | ||
| 5077 | |||
| 5078 | # (T) All winmaps/colour schemes in memory are replaced; no existing windows are | ||
| 5079 | # affected, since winmaps are only applied when a window is created, and | ||
| 5080 | # colour schemes are only applied periodically | ||
| 5081 | # (F) Loaded data incorporated into memory | ||
| 5082 | |||
| 5083 | if ($overWriteFlag) { | ||
| 5084 | |||
| 5085 | # Replace the data in memory | ||
| 5086 | $client->ivPoke('winmapHash', %{$loadHash{'winmap_hash'}}); | ||
| 5087 | $client->ivPoke('standardWinmapHash', %{$loadHash{'standard_winmap_hash'}}); | ||
| 5088 | $client->ivPoke('defaultEnabledWinmap', $loadHash{'default_enabled_winmap'}); | ||
| 5089 | $client->ivPoke('defaultDisabledWinmap', $loadHash{'default_disabled_winmap'}); | ||
| 5090 | $client->ivPoke('defaultInternalWinmap', $loadHash{'default_internal_winmap'}); | ||
| 5091 | $client->ivPoke('colourSchemeHash', %{$loadHash{'colour_scheme_hash'}}); | ||
| 5092 | |||
| 5093 | # The data in memory matches saved data files | ||
| 5094 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 5095 | |||
| 5096 | } else { | ||
| 5097 | |||
| 5098 | # We are loading one or more global winmap objects that have been exported and | ||
| 5099 | # must be re-incorporated into memory | ||
| 5100 | |||
| 5101 | # Incorporate winmap objects | ||
| 5102 | %hash = %{$loadHash{'winmap_hash'}}; | ||
| 5103 | if (%hash) { | ||
| 5104 | |||
| 5105 | foreach my $winmapObj (values %hash) { | ||
| 5106 | |||
| 5107 | $client->add_winmap($winmapObj); | ||
| 5108 | } | ||
| 5109 | } | ||
| 5110 | |||
| 5111 | # Incorporate colour schemes | ||
| 5112 | %hash = %{$loadHash{'colour_scheme_hash'}}; | ||
| 5113 | if (%hash) { | ||
| 5114 | |||
| 5115 | foreach my $obj (values %hash) { | ||
| 5116 | |||
| 5117 | $client->add_colourScheme($obj); | ||
| 5118 | } | ||
| 5119 | } | ||
| 5120 | |||
| 5121 | # (Calls to accessors will have set the right ->modifyFlag values) | ||
| 5122 | } | ||
| 5123 | |||
| 5124 | } elsif ($self->fileType eq 'tts') { | ||
| 5125 | |||
| 5126 | # 'tts' | ||
| 5127 | # (T) All existing data in memory replaced by loaded data | ||
| 5128 | # (F) Loaded data incorporated into memory | ||
| 5129 | |||
| 5130 | if ($overWriteFlag) { | ||
| 5131 | |||
| 5132 | # Replace the data in memory | ||
| 5133 | $client->ivPoke('ttsObjHash', %{$loadHash{'tts_obj_hash'}}); | ||
| 5134 | |||
| 5135 | # The data in memory matches saved data files | ||
| 5136 | $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData'); | ||
| 5137 | |||
| 5138 | } else { | ||
| 5139 | |||
| 5140 | # We are loading one or more global TTS objects that have been exported and | ||
| 5141 | # must be re-incorporated into memory | ||
| 5142 | |||
| 5143 | # Incorporate TTS objects | ||
| 5144 | %hash = %{$loadHash{'tts_obj_hash'}}; | ||
| 5145 | if (%hash) { | ||
| 5146 | |||
| 5147 | foreach my $ttsObj (values %hash) { | ||
| 5148 | |||
| 5149 | $client->add_ttsObj($ttsObj); | ||
| 5150 | } | ||
| 5151 | } | ||
| 5152 | |||
| 5153 | # (Calls to accessors will have set the right ->modifyFlag values) | ||
| 5154 | } | ||
| 5155 | } | ||
| 5156 | |||
| 5157 | # Update the loaded data from previous versions of Axmud to conform to the current version | ||
| 5158 | # of Axmud | ||
| 5159 | $self->updateExtractedData(); | ||
| 5160 | |||
| 5161 | # Return the file type | ||
| 5162 | return $loadHash{'file_type'}; | ||
| 5163 | } | ||
| 5164 | |||
| 5165 | sub updateExtractedData { | ||
| 5166 | |||
| 5167 | # Called by $self->extractData (also called by GA::Profile::World->mergeData at the end of | ||
| 5168 | # an ';updateworld' operation) | ||
| 5169 | # Data loaded from previous versions of Axmud may be incompatible with the present version. | ||
| 5170 | # Update the loaded data, as and where necessary | ||
| 5171 | # NB Some data is also updated by $self->updateDataAfterRename | ||
| 5172 | # | ||
| 5173 | # Expected arguments | ||
| 5174 | # (none besides $self) | ||
| 5175 | # | ||
| 5176 | # Optional arguments | ||
| 5177 | # $version - When called by $self->extractData, the extracted data belongs to the Axmud | ||
| 5178 | # version stored in $self->scriptConvertVersion, and this argument is | ||
| 5179 | # 'undef'. When called by GA::Profile::World->mergeData, this argument is | ||
| 5180 | # set to the Axmud version of the imported data's file (in the same | ||
| 5181 | # format) | ||
| 5182 | # | ||
| 5183 | # Return values | ||
| 5184 | # 'undef' on improper arguments | ||
| 5185 | # 1 otherwise | ||
| 5186 | |||
| 5187 | my ($self, $version, $check) = @_; | ||
| 5188 | |||
| 5189 | # Local variables | ||
| 5190 | my $wmObj; | ||
| 5191 | |||
| 5192 | # Check for improper arguments | ||
| 5193 | if (defined $check) { | ||
| 5194 | |||
| 5195 | return $axmud::CLIENT->writeImproper($self->_objClass . '->updateExtractedData', @_); | ||
| 5196 | } | ||
| 5197 | |||
| 5198 | if (! defined $version) { | ||
| 5199 | |||
| 5200 | # This function called by $self->extractData | ||
| 5201 | $version = $self->scriptConvertVersion; | ||
| 5202 | } | ||
| 5203 | |||
| 5204 | ### worldprof / otherprof ################################################################# | ||
| 5205 | |||
| 5206 | if ($self->fileType eq 'worldprof' || $self->fileType eq 'otherprof') { | ||
| 5207 | |||
| 5208 | if ($version < 1_000_029 && $self->session) { | ||
| 5209 | |||
| 5210 | # Update every command cage with new standard commands | ||
| 5211 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 5212 | |||
| 5213 | if ($cage->{cageType} eq 'cmd') { | ||
| 5214 | |||
| 5215 | if (! $cage->ivExists('cmdHash', 'short_look')) { | ||
| 5216 | |||
| 5217 | $cage->ivAdd('cmdHash', 'short_look', 'l'); | ||
| 5218 | } | ||
| 5219 | |||
| 5220 | if (! $cage->ivExists('cmdHash', 'short_glance')) { | ||
| 5221 | |||
| 5222 | $cage->ivAdd('cmdHash', 'short_glance', 'gl'); | ||
| 5223 | } | ||
| 5224 | } | ||
| 5225 | } | ||
| 5226 | } | ||
| 5227 | |||
| 5228 | if ($version < 1_000_039) { | ||
| 5229 | |||
| 5230 | # Update world profiles with a new IV | ||
| 5231 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5232 | |||
| 5233 | if (! exists $profObj->{excessCmdDelay}) { | ||
| 5234 | |||
| 5235 | # Create the IV... | ||
| 5236 | $profObj->{excessCmdDelay} = undef; | ||
| 5237 | # By setting its default value using ->ivPoke, we make sure the correct | ||
| 5238 | # GA::Obj::File object's ->modifyFlag is set automatically | ||
| 5239 | $profObj->ivPoke('excessCmdDelay', 1); | ||
| 5240 | } | ||
| 5241 | } | ||
| 5242 | } | ||
| 5243 | |||
| 5244 | if ($version < 1_000_044) { | ||
| 5245 | |||
| 5246 | # Update room statement components with a new IV | ||
| 5247 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5248 | |||
| 5249 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 5250 | |||
| 5251 | if (! exists $compObj->{useTextColour}) { | ||
| 5252 | |||
| 5253 | $compObj->{useTextColour} = undef; | ||
| 5254 | $compObj->ivUndef('useTextColour'); | ||
| 5255 | # (This IV subsequently renamed and/or removed) | ||
| 5256 | # $compObj->{ignoreChars} = undef; | ||
| 5257 | # $compObj->ivPoke('ignoreChars', 0); | ||
| 5258 | $compObj->{ignoreChars} = 0; | ||
| 5259 | } | ||
| 5260 | } | ||
| 5261 | } | ||
| 5262 | } | ||
| 5263 | |||
| 5264 | if ($version < 1_000_066 && $self->session) { | ||
| 5265 | |||
| 5266 | # This version fixes a problem in GA::Profile::Char->fightVictimStringHash and | ||
| 5267 | # ->interactionVictimStringHash | ||
| 5268 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 5269 | |||
| 5270 | my $hashRef; | ||
| 5271 | |||
| 5272 | if ($profObj->{category} eq 'char') { | ||
| 5273 | |||
| 5274 | $hashRef = $profObj->{fightVictimStringHash}; | ||
| 5275 | if (%$hashRef) { | ||
| 5276 | |||
| 5277 | my (%oldHash, %newHash); | ||
| 5278 | |||
| 5279 | %oldHash = %$hashRef; | ||
| 5280 | foreach my $key (keys %oldHash) { | ||
| 5281 | |||
| 5282 | my $value = $oldHash{$key}; | ||
| 5283 | |||
| 5284 | # All keys must now be lower-case | ||
| 5285 | $key = lc($key); | ||
| 5286 | if (exists $newHash{$key}) { | ||
| 5287 | $newHash{$key} = $newHash{$key} + $value; | ||
| 5288 | } else { | ||
| 5289 | $newHash{$key} = $value; | ||
| 5290 | } | ||
| 5291 | } | ||
| 5292 | |||
| 5293 | $profObj->ivPoke('fightVictimStringHash', %newHash); | ||
| 5294 | } | ||
| 5295 | |||
| 5296 | $hashRef = $profObj->{interactionVictimStringHash}; | ||
| 5297 | if (%$hashRef) { | ||
| 5298 | |||
| 5299 | my (%oldHash, %newHash); | ||
| 5300 | |||
| 5301 | %oldHash = %$hashRef; | ||
| 5302 | foreach my $key (keys %oldHash) { | ||
| 5303 | |||
| 5304 | my $value = $oldHash{$key}; | ||
| 5305 | |||
| 5306 | # All keys must now be lower-case | ||
| 5307 | $key = lc($key); | ||
| 5308 | if (exists $newHash{$key}) { | ||
| 5309 | $newHash{$key} = $newHash{$key} + $value; | ||
| 5310 | } else { | ||
| 5311 | $newHash{$key} = $value; | ||
| 5312 | } | ||
| 5313 | } | ||
| 5314 | |||
| 5315 | $profObj->ivPoke('interactionVictimStringHash', %newHash); | ||
| 5316 | } | ||
| 5317 | } | ||
| 5318 | } | ||
| 5319 | } | ||
| 5320 | |||
| 5321 | if ($version < 1_000_076) { | ||
| 5322 | |||
| 5323 | # Update room statement components with new IVs | ||
| 5324 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5325 | |||
| 5326 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 5327 | |||
| 5328 | # Rename ->ignoreChars as ->ignoreFirstChars. For some reason, ->ignoreChars | ||
| 5329 | # seems to be set to 'undef' in components created in previous Axmud | ||
| 5330 | # versions; not sure why, but this code fixes it | ||
| 5331 | if (! exists $compObj->{ignoreFirstChars}) { | ||
| 5332 | |||
| 5333 | $compObj->{ignoreFirstChars} = undef; | ||
| 5334 | |||
| 5335 | if (exists $compObj->{ignoreChars}) { | ||
| 5336 | $compObj->ivPoke('ignoreFirstChars', $compObj->{ignoreChars}); | ||
| 5337 | } else { | ||
| 5338 | $compObj->ivPoke('ignoreFirstChars', 0); | ||
| 5339 | } | ||
| 5340 | } | ||
| 5341 | |||
| 5342 | if (! defined $compObj->{ignoreFirstChars}) { | ||
| 5343 | |||
| 5344 | $compObj->ivPoke('ignoreFirstChars', $compObj->{ignoreChars}); | ||
| 5345 | } | ||
| 5346 | |||
| 5347 | delete $compObj->{ignoreChars}; | ||
| 5348 | |||
| 5349 | $compObj->{useFirstChars} = undef; | ||
| 5350 | $compObj->ivPoke('useFirstChars', 0); | ||
| 5351 | # (This IV subsequently renamed and/or removed) | ||
| 5352 | # $compObj->{usePatternBackRefs} = undef; | ||
| 5353 | # $compObj->ivUndef('usePatternBackRefs'); | ||
| 5354 | $compObj->{usePatternBackRefs} = undef; | ||
| 5355 | } | ||
| 5356 | } | ||
| 5357 | } | ||
| 5358 | |||
| 5359 | if ($version < 1_000_077) { | ||
| 5360 | |||
| 5361 | # Update world profiles with new IVs | ||
| 5362 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5363 | |||
| 5364 | if (! exists $profObj->{verboseFinalPattern}) { | ||
| 5365 | |||
| 5366 | $profObj->{verboseFinalPattern} = undef; | ||
| 5367 | $profObj->ivUndef('verboseFinalPattern'); | ||
| 5368 | $profObj->{shortFinalPattern} = undef; | ||
| 5369 | $profObj->ivUndef('shortFinalPattern'); | ||
| 5370 | $profObj->{briefFinalPattern} = undef; | ||
| 5371 | $profObj->ivUndef('briefFinalPattern'); | ||
| 5372 | } | ||
| 5373 | } | ||
| 5374 | } | ||
| 5375 | |||
| 5376 | if ($version < 1_000_090) { | ||
| 5377 | |||
| 5378 | # This version updates the Status task, using a single string (e.g. | ||
| 5379 | # 'health_points_max') rather than two strings to represent the same thing (e.g. | ||
| 5380 | # 'health_max', 'health_points_max'. The Status task is updated below; here we | ||
| 5381 | # updated a parallel IV in the world profile | ||
| 5382 | my %updateHash = ( | ||
| 5383 | '@health_max@' => '@health_points_max@', | ||
| 5384 | '@magic_max@' => '@magic_points_max@', | ||
| 5385 | '@energy_max@' => '@energy_points_max@', | ||
| 5386 | '@guild_max@' => '@guild_points_max@', | ||
| 5387 | '@social_max@' => '@social_points_max@', | ||
| 5388 | ); | ||
| 5389 | |||
| 5390 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5391 | |||
| 5392 | my $listRef = $profObj->{displayFormatList}; | ||
| 5393 | foreach my $line (@$listRef) { | ||
| 5394 | |||
| 5395 | foreach my $key (keys %updateHash) { | ||
| 5396 | |||
| 5397 | my $value = $updateHash{$key}; | ||
| 5398 | |||
| 5399 | $line =~ s/$key/$value/g; | ||
| 5400 | } | ||
| 5401 | } | ||
| 5402 | } | ||
| 5403 | } | ||
| 5404 | |||
| 5405 | if ($version < 1_000_150) { | ||
| 5406 | |||
| 5407 | # Update world profiles with new stuff | ||
| 5408 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5409 | |||
| 5410 | my $listRef; | ||
| 5411 | |||
| 5412 | # New IV | ||
| 5413 | if (! exists $profObj->{currencyRounding}) { | ||
| 5414 | |||
| 5415 | $profObj->{currencyRounding} = undef; | ||
| 5416 | $profObj->ivPoke('currencyRounding', 3); | ||
| 5417 | } | ||
| 5418 | |||
| 5419 | # In ->inventoryPatternList, the type 'empty' has been replaced by | ||
| 5420 | # 'empty_purse', so update the list [in groups of 5) | ||
| 5421 | $listRef = $profObj->{inventoryPatternList}; | ||
| 5422 | if (@$listRef) { | ||
| 5423 | |||
| 5424 | my ( | ||
| 5425 | $changeFlag, | ||
| 5426 | @modList, | ||
| 5427 | ); | ||
| 5428 | |||
| 5429 | do { | ||
| 5430 | |||
| 5431 | my ($pattern, $backRef, $type, $gag, $posn); | ||
| 5432 | |||
| 5433 | $pattern = shift @$listRef; | ||
| 5434 | $backRef = shift @$listRef; | ||
| 5435 | $type = shift @$listRef; | ||
| 5436 | $gag = shift @$listRef; | ||
| 5437 | $posn = shift @$listRef; | ||
| 5438 | |||
| 5439 | if ($type eq 'empty') { | ||
| 5440 | |||
| 5441 | $type = 'empty_purse'; | ||
| 5442 | $changeFlag = TRUE; | ||
| 5443 | } | ||
| 5444 | |||
| 5445 | push (@modList, $pattern, $backRef, $type, $gag, $posn); | ||
| 5446 | |||
| 5447 | } until (! @$listRef); | ||
| 5448 | |||
| 5449 | if ($changeFlag) { | ||
| 5450 | |||
| 5451 | $profObj->ivPoke('inventoryPatternList', @modList); | ||
| 5452 | } | ||
| 5453 | } | ||
| 5454 | } | ||
| 5455 | } | ||
| 5456 | |||
| 5457 | if ($version < 1_000_159) { | ||
| 5458 | |||
| 5459 | # This version changes the way a world profile's ->termType operates; it must now be | ||
| 5460 | # one of the values in GA::Client->constTermTypeList (or 'undef') | ||
| 5461 | # Check every world profile; if its ->termType is set to a value that's not in | ||
| 5462 | # ->constTermTypeList replace it with the first item ->constTermTypeList | ||
| 5463 | OUTER: foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5464 | |||
| 5465 | my ($listRef, $matchFlag); | ||
| 5466 | |||
| 5467 | if (defined $profObj->{termType}) { | ||
| 5468 | |||
| 5469 | $listRef = $axmud::CLIENT->{constTermTypeList}; | ||
| 5470 | INNER: foreach my $termType (@$listRef) { | ||
| 5471 | |||
| 5472 | if ($termType eq $profObj->{termType}) { | ||
| 5473 | |||
| 5474 | $matchFlag = TRUE; | ||
| 5475 | last INNER; | ||
| 5476 | } | ||
| 5477 | } | ||
| 5478 | |||
| 5479 | if (! $matchFlag) { | ||
| 5480 | |||
| 5481 | # User has set an unrecognised termtype; replace it with 'ansi' | ||
| 5482 | $profObj->ivPoke( | ||
| 5483 | 'termType', | ||
| 5484 | $axmud::CLIENT->ivFirst('constTermTypeList'), | ||
| 5485 | ); | ||
| 5486 | } | ||
| 5487 | } | ||
| 5488 | |||
| 5489 | # Also rename an existing IV | ||
| 5490 | if (exists $profObj->{sendTermInfoFlag}) { | ||
| 5491 | |||
| 5492 | $profObj->{sendSizeInfoFlag} = undef; | ||
| 5493 | $profObj->ivPoke('sendSizeInfoFlag', $profObj->{sendTermInfoFlag}); | ||
| 5494 | delete $profObj->{sendTermInfoFlag}; | ||
| 5495 | } | ||
| 5496 | } | ||
| 5497 | } | ||
| 5498 | |||
| 5499 | if ($version < 1_000_163) { | ||
| 5500 | |||
| 5501 | # This version changes the default values of two IVs from 'undef' to 0 | ||
| 5502 | OUTER: foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5503 | |||
| 5504 | if (! defined $profObj->{columns}) { | ||
| 5505 | |||
| 5506 | $profObj->ivPoke('columns', 0); | ||
| 5507 | } | ||
| 5508 | |||
| 5509 | if (! defined $profObj->{rows}) { | ||
| 5510 | |||
| 5511 | $profObj->ivPoke('rows', 0); | ||
| 5512 | } | ||
| 5513 | } | ||
| 5514 | } | ||
| 5515 | |||
| 5516 | if ($version < 1_000_165) { | ||
| 5517 | |||
| 5518 | # Update world profiles with new IVs | ||
| 5519 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5520 | |||
| 5521 | if (! exists $profObj->{msspGenericValueHash}) { | ||
| 5522 | |||
| 5523 | $profObj->{msspGenericValueHash} = {}; | ||
| 5524 | $profObj->ivEmpty('msspGenericValueHash'); | ||
| 5525 | $profObj->{msspCustomValueHash} = {}; | ||
| 5526 | $profObj->ivEmpty('msspCustomValueHash'); | ||
| 5527 | } | ||
| 5528 | } | ||
| 5529 | } | ||
| 5530 | |||
| 5531 | if ($version < 1_000_181 && $self->session) { | ||
| 5532 | |||
| 5533 | # This version changes the name of two trigger attributes, and adds new ones. Update | ||
| 5534 | # every trigger cage | ||
| 5535 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 5536 | |||
| 5537 | if ($cage->{cageType} eq 'trigger') { | ||
| 5538 | |||
| 5539 | foreach my $trigObj ($cage->ivValues('interfaceHash')) { | ||
| 5540 | |||
| 5541 | $trigObj->ivAdd( | ||
| 5542 | 'attribHash', | ||
| 5543 | 'style_text', | ||
| 5544 | $trigObj->ivShow('attribHash', 'style_fg'), | ||
| 5545 | ); | ||
| 5546 | |||
| 5547 | $trigObj->ivDelete('attribHash', 'style_fg'); | ||
| 5548 | |||
| 5549 | $trigObj->ivAdd( | ||
| 5550 | 'attribHash', | ||
| 5551 | 'style_underlay', | ||
| 5552 | $trigObj->ivShow('attribHash', 'style_bg'), | ||
| 5553 | ); | ||
| 5554 | |||
| 5555 | $trigObj->ivDelete('attribHash', 'style_bg'); | ||
| 5556 | |||
| 5557 | $trigObj->ivAdd('attribHash', 'style_blink_slow', 0); | ||
| 5558 | $trigObj->ivAdd('attribHash', 'style_blink_fast', 0); | ||
| 5559 | } | ||
| 5560 | } | ||
| 5561 | } | ||
| 5562 | } | ||
| 5563 | |||
| 5564 | if ($version < 1_000_186) { | ||
| 5565 | |||
| 5566 | # Update world profiles with new IVs | ||
| 5567 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5568 | |||
| 5569 | if (! exists $profObj->{worldCharSet}) { | ||
| 5570 | |||
| 5571 | $profObj->{worldCharSet} = undef; | ||
| 5572 | $profObj->ivUndef('worldCharSet'); | ||
| 5573 | } | ||
| 5574 | } | ||
| 5575 | } | ||
| 5576 | |||
| 5577 | if ($version < 1_000_188) { | ||
| 5578 | |||
| 5579 | # Update world profiles with new IVs | ||
| 5580 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5581 | |||
| 5582 | if (! exists $profObj->{exitRemovePatternList}) { | ||
| 5583 | |||
| 5584 | $profObj->{exitRemovePatternList} = []; | ||
| 5585 | $profObj->ivEmpty('exitRemovePatternList'); | ||
| 5586 | } | ||
| 5587 | } | ||
| 5588 | } | ||
| 5589 | |||
| 5590 | if ($version < 1_000_189) { | ||
| 5591 | |||
| 5592 | # Update world profiles with new IVs | ||
| 5593 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5594 | |||
| 5595 | if (! exists $profObj->{exitStateIgnoreList}) { | ||
| 5596 | |||
| 5597 | # (This IV subsequently renamed and/or removed) | ||
| 5598 | # $profObj->{exitStateIgnoreList} = []; | ||
| 5599 | # $profObj->ivEmpty('exitStateIgnoreList'); | ||
| 5600 | $profObj->{exitStateIgnoreList} = []; | ||
| 5601 | } | ||
| 5602 | } | ||
| 5603 | } | ||
| 5604 | |||
| 5605 | if ($version < 1_000_198) { | ||
| 5606 | |||
| 5607 | # Update world profiles with new IVs | ||
| 5608 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5609 | |||
| 5610 | my $listRef; | ||
| 5611 | |||
| 5612 | if (! exists $profObj->{affectPatternList}) { | ||
| 5613 | |||
| 5614 | $profObj->{affectPatternList} = []; | ||
| 5615 | $profObj->ivEmpty('affectPatternList'); | ||
| 5616 | } | ||
| 5617 | |||
| 5618 | # In ->barPatternList, the type 'xp' has been replaced by 'xp_current', so | ||
| 5619 | # update the list [in groups of 6) | ||
| 5620 | $listRef = $profObj->{barPatternList}; | ||
| 5621 | if (@$listRef) { | ||
| 5622 | |||
| 5623 | my ( | ||
| 5624 | $changeFlag, | ||
| 5625 | @modList, | ||
| 5626 | ); | ||
| 5627 | |||
| 5628 | do { | ||
| 5629 | |||
| 5630 | my ($pattern, $backRef, $type, $gag, $string, $posn); | ||
| 5631 | |||
| 5632 | $pattern = shift @$listRef; | ||
| 5633 | $backRef = shift @$listRef; | ||
| 5634 | $type = shift @$listRef; | ||
| 5635 | $gag = shift @$listRef; | ||
| 5636 | $string = shift @$listRef; | ||
| 5637 | $posn = shift @$listRef; | ||
| 5638 | |||
| 5639 | if ($type eq 'xp') { | ||
| 5640 | |||
| 5641 | $type = 'xp_current'; | ||
| 5642 | $changeFlag = TRUE; | ||
| 5643 | } | ||
| 5644 | |||
| 5645 | push (@modList, $pattern, $backRef, $type, $gag, $string, $posn); | ||
| 5646 | |||
| 5647 | } until (! @$listRef); | ||
| 5648 | |||
| 5649 | if ($changeFlag) { | ||
| 5650 | |||
| 5651 | $profObj->ivPoke('barPatternList', @modList); | ||
| 5652 | } | ||
| 5653 | } | ||
| 5654 | } | ||
| 5655 | |||
| 5656 | if ($self->session) { | ||
| 5657 | |||
| 5658 | # Update character profiles with new IVs | ||
| 5659 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 5660 | |||
| 5661 | if ($profObj->{category} eq 'char' && ! exists $profObj->{xpNextLevel}) { | ||
| 5662 | |||
| 5663 | $profObj->{xpNextLevel} = undef; | ||
| 5664 | $profObj->ivUndef('xpNextLevel'); | ||
| 5665 | $profObj->{alignment} = undef; | ||
| 5666 | $profObj->ivUndef('alignment'); | ||
| 5667 | $profObj->{affectHash} = {}; | ||
| 5668 | $profObj->ivEmpty('affectHash'); | ||
| 5669 | } | ||
| 5670 | } | ||
| 5671 | } | ||
| 5672 | } | ||
| 5673 | |||
| 5674 | if ($version < 1_000_206) { | ||
| 5675 | |||
| 5676 | # Update room statement components with new IVs | ||
| 5677 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5678 | |||
| 5679 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 5680 | |||
| 5681 | if (! exists $compObj->{analyseMode}) { | ||
| 5682 | |||
| 5683 | $compObj->{analyseMode} = undef; | ||
| 5684 | $compObj->ivPoke('analyseMode', 0); | ||
| 5685 | } | ||
| 5686 | } | ||
| 5687 | } | ||
| 5688 | } | ||
| 5689 | |||
| 5690 | if ($version < 1_000_210 && $self->session) { | ||
| 5691 | |||
| 5692 | # Update every command cage with a new standard command | ||
| 5693 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 5694 | |||
| 5695 | if ($cage->{cageType} eq 'cmd') { | ||
| 5696 | |||
| 5697 | if (! $cage->ivExists('cmdHash', 'connect')) { | ||
| 5698 | |||
| 5699 | $cage->ivAdd('cmdHash', 'connect', 'connect name password'); | ||
| 5700 | } | ||
| 5701 | } | ||
| 5702 | } | ||
| 5703 | } | ||
| 5704 | |||
| 5705 | if ($version < 1_000_210) { | ||
| 5706 | |||
| 5707 | # Update world profiles with new IVs | ||
| 5708 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5709 | |||
| 5710 | my $listRef; | ||
| 5711 | |||
| 5712 | if (! exists $profObj->{loginConnectPatternList}) { | ||
| 5713 | |||
| 5714 | # One new IV | ||
| 5715 | $profObj->{loginConnectPatternList} = []; | ||
| 5716 | $profObj->ivEmpty('loginConnectPatternList'); | ||
| 5717 | } | ||
| 5718 | |||
| 5719 | if (exists $profObj->{loginPatternList}) { | ||
| 5720 | |||
| 5721 | # One renamed IV | ||
| 5722 | $profObj->{loginSuccessPatternList} = []; | ||
| 5723 | $listRef = $profObj->{loginPatternList}; | ||
| 5724 | $profObj->ivPoke('loginSuccessPatternList', @$listRef); | ||
| 5725 | delete $profObj->{loginPatternList}; | ||
| 5726 | } | ||
| 5727 | } | ||
| 5728 | } | ||
| 5729 | |||
| 5730 | if ($version < 1_000_212) { | ||
| 5731 | |||
| 5732 | # Update world profiles with new IVs | ||
| 5733 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5734 | |||
| 5735 | if (! exists $profObj->{customStatusVarHash}) { | ||
| 5736 | |||
| 5737 | # (This IV subsequently renamed and/or removed) | ||
| 5738 | # $profObj->{customStatusVarHash} = {}; | ||
| 5739 | # $profObj->ivEmpty('customStatusVarHash'); | ||
| 5740 | $profObj->{customStatusVarHash} = {}; | ||
| 5741 | } | ||
| 5742 | } | ||
| 5743 | } | ||
| 5744 | |||
| 5745 | if ($version < 1_000_213) { | ||
| 5746 | |||
| 5747 | # Update world profiles with a new IV | ||
| 5748 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5749 | |||
| 5750 | if (! exists $profObj->{exitInfoPatternList}) { | ||
| 5751 | |||
| 5752 | $profObj->{exitInfoPatternList} = []; | ||
| 5753 | $profObj->ivEmpty('exitInfoPatternList'); | ||
| 5754 | } | ||
| 5755 | } | ||
| 5756 | } | ||
| 5757 | |||
| 5758 | if ($version < 1_000_220) { | ||
| 5759 | |||
| 5760 | # Update world profiles with new IVs | ||
| 5761 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5762 | |||
| 5763 | if (! exists $profObj->{fightDefeatPatternList}) { | ||
| 5764 | |||
| 5765 | $profObj->{fightDefeatPatternList} = []; | ||
| 5766 | $profObj->ivEmpty('fightDefeatPatternList'); | ||
| 5767 | $profObj->{wimpyEngagedPatternList} = []; | ||
| 5768 | $profObj->ivEmpty('wimpyEngagedPatternList'); | ||
| 5769 | $profObj->{noFightDefeatPatternList} = []; | ||
| 5770 | $profObj->ivEmpty('noFightDefeatPatternList'); | ||
| 5771 | $profObj->{noWimpyEngagedPatternList} = []; | ||
| 5772 | $profObj->ivEmpty('noWimpyEngagedPatternList'); | ||
| 5773 | } | ||
| 5774 | } | ||
| 5775 | } | ||
| 5776 | |||
| 5777 | if ($version < 1_000_228 && $self->session) { | ||
| 5778 | |||
| 5779 | # This version adds a new trigger attribute. Update every trigger cage | ||
| 5780 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 5781 | |||
| 5782 | if ($cage->{cageType} eq 'trigger') { | ||
| 5783 | |||
| 5784 | foreach my $trigObj ($cage->ivValues('interfaceHash')) { | ||
| 5785 | |||
| 5786 | $trigObj->ivAdd('attribHash', 'rewrite_global', 0); | ||
| 5787 | } | ||
| 5788 | } | ||
| 5789 | } | ||
| 5790 | } | ||
| 5791 | |||
| 5792 | if ($version < 1_000_239 && $self->session) { | ||
| 5793 | |||
| 5794 | # This version adds a new trigger attribute. Update every trigger cage | ||
| 5795 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 5796 | |||
| 5797 | if ($cage->{cageType} eq 'trigger') { | ||
| 5798 | |||
| 5799 | foreach my $trigObj ($cage->ivValues('interfaceHash')) { | ||
| 5800 | |||
| 5801 | $trigObj->ivAdd('attribHash', 'need_login', 0); | ||
| 5802 | } | ||
| 5803 | } | ||
| 5804 | } | ||
| 5805 | } | ||
| 5806 | |||
| 5807 | if ($version < 1_000_252) { | ||
| 5808 | |||
| 5809 | # Update world profiles with new IVs | ||
| 5810 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5811 | |||
| 5812 | if (! exists $profObj->{strictPromptsMode}) { | ||
| 5813 | |||
| 5814 | # (This IV subsequently renamed and/or removed) | ||
| 5815 | # $profObj->{strictPromptsMode} = undef; | ||
| 5816 | # $profObj->ivPoke('strictPromptsMode', FALSE); | ||
| 5817 | $profObj->{strictPromptsMode} = undef; | ||
| 5818 | } | ||
| 5819 | } | ||
| 5820 | } | ||
| 5821 | |||
| 5822 | if ($version < 1_000_297 && $self->session) { | ||
| 5823 | |||
| 5824 | # Update every command cage with new standard commands | ||
| 5825 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 5826 | |||
| 5827 | if ($cage->{cageType} eq 'cmd') { | ||
| 5828 | |||
| 5829 | if (! $cage->ivExists('cmdHash', 'squeeze')) { | ||
| 5830 | |||
| 5831 | $cage->ivAdd('cmdHash', 'squeeze', 'squeeze direction'); | ||
| 5832 | } | ||
| 5833 | } | ||
| 5834 | } | ||
| 5835 | } | ||
| 5836 | |||
| 5837 | if ($version < 1_000_300) { | ||
| 5838 | |||
| 5839 | # Update world profiles with new IVs | ||
| 5840 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5841 | |||
| 5842 | if (! exists $profObj->{exitStateDarkList}) { | ||
| 5843 | |||
| 5844 | # (This IV subsequently renamed and/or removed) | ||
| 5845 | # $profObj->{exitStateDarkList} = []; | ||
| 5846 | # $profObj->ivEmpty('exitStateDarkList'); | ||
| 5847 | $profObj->{exitStateDarkList} = []; | ||
| 5848 | # (This IV subsequently renamed and/or removed) | ||
| 5849 | # $profObj->{exitStateDangerList} = []; | ||
| 5850 | # $profObj->ivEmpty('exitStateDangerList'); | ||
| 5851 | $profObj->{exitStateDangerList} = []; | ||
| 5852 | } | ||
| 5853 | } | ||
| 5854 | } | ||
| 5855 | |||
| 5856 | if ($version < 1_000_301) { | ||
| 5857 | |||
| 5858 | # Update world profiles with a new hash IV | ||
| 5859 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5860 | |||
| 5861 | if (! exists $profObj->{accountHash}) { | ||
| 5862 | |||
| 5863 | # Create the IV | ||
| 5864 | $profObj->{accountHash} = {}; | ||
| 5865 | $profObj->ivEmpty('accountHash'); | ||
| 5866 | |||
| 5867 | # The IV should have the same keys as the existing ->passwordHash IV, but | ||
| 5868 | # the matching values should all be 'undef' | ||
| 5869 | foreach my $key ($profObj->ivKeys('passwordHash')) { | ||
| 5870 | |||
| 5871 | $profObj->ivAdd('accountHash', $key, undef); | ||
| 5872 | } | ||
| 5873 | } | ||
| 5874 | } | ||
| 5875 | } | ||
| 5876 | |||
| 5877 | if ($version < 1_000_302) { | ||
| 5878 | |||
| 5879 | # Update world profiles with a new IV | ||
| 5880 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5881 | |||
| 5882 | if (! exists $profObj->{newAccountHash}) { | ||
| 5883 | |||
| 5884 | # Create the IV | ||
| 5885 | $profObj->{newAccountHash} = {}; | ||
| 5886 | $profObj->ivEmpty('newAccountHash'); | ||
| 5887 | } | ||
| 5888 | } | ||
| 5889 | } | ||
| 5890 | |||
| 5891 | if ($version < 1_000_306) { | ||
| 5892 | |||
| 5893 | # Update room statement components with new IVs | ||
| 5894 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5895 | |||
| 5896 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 5897 | |||
| 5898 | if (! exists $compObj->{startTagMode}) { | ||
| 5899 | |||
| 5900 | $compObj->{startTagMode} = undef; | ||
| 5901 | $compObj->ivPoke('startTagMode', 0); | ||
| 5902 | # (This IV subsequently renamed and/or removed) | ||
| 5903 | # $compObj->{stopTagMode} = undef; | ||
| 5904 | # $compObj->ivPoke('stopTagMode', 0); | ||
| 5905 | $compObj->{stopTagMode} = 0; | ||
| 5906 | $compObj->{skipTagMode} = undef; | ||
| 5907 | $compObj->ivPoke('skipTagMode', 0); | ||
| 5908 | $compObj->{stopBeforeNoTagMode} = undef; | ||
| 5909 | $compObj->ivPoke('stopBeforeNoTagMode', 0); | ||
| 5910 | $compObj->{stopBeforeTagMode} = undef; | ||
| 5911 | $compObj->ivPoke('stopBeforeTagMode', 0); | ||
| 5912 | $compObj->{stopAtNoTagMode} = undef; | ||
| 5913 | $compObj->ivPoke('stopAtNoTagMode', 0); | ||
| 5914 | $compObj->{stopAtTagMode} = undef; | ||
| 5915 | $compObj->ivPoke('stopAtTagMode', 0); | ||
| 5916 | } | ||
| 5917 | } | ||
| 5918 | } | ||
| 5919 | } | ||
| 5920 | |||
| 5921 | if ($version < 1_000_315 && $self->session) { | ||
| 5922 | |||
| 5923 | # This version adds new trigger attributes. Update every trigger cage | ||
| 5924 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 5925 | |||
| 5926 | if ($cage->{cageType} eq 'trigger') { | ||
| 5927 | |||
| 5928 | foreach my $trigObj ($cage->ivValues('interfaceHash')) { | ||
| 5929 | |||
| 5930 | $trigObj->ivAdd('attribHash', 'splitter', 0); | ||
| 5931 | $trigObj->ivAdd('attribHash', 'split_after', 0); | ||
| 5932 | $trigObj->ivAdd('attribHash', 'keep_splitting', 0); | ||
| 5933 | } | ||
| 5934 | } | ||
| 5935 | } | ||
| 5936 | } | ||
| 5937 | |||
| 5938 | if ($version < 1_000_318) { | ||
| 5939 | |||
| 5940 | # Update room statement components, adding some new IVs and removing some other | ||
| 5941 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 5942 | |||
| 5943 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 5944 | |||
| 5945 | my ($patternListRef, $tagListRef); | ||
| 5946 | |||
| 5947 | if (! exists $compObj->{startNoPatternList}) { | ||
| 5948 | |||
| 5949 | $compObj->{startNoPatternList} = []; | ||
| 5950 | $compObj->ivEmpty('startNoPatternList'); | ||
| 5951 | $compObj->{startNoTagList} = []; | ||
| 5952 | $compObj->ivEmpty('startNoTagList'); | ||
| 5953 | $compObj->{startNoAllFlag} = undef; | ||
| 5954 | $compObj->ivPoke('startNoAllFlag', FALSE); | ||
| 5955 | $compObj->{startNoTagMode} = undef; | ||
| 5956 | $compObj->ivPoke('startNoTagMode', 0); | ||
| 5957 | |||
| 5958 | # The existing contents of ->stopPatternList (etc) must be transferred | ||
| 5959 | # to ->stopAtPatternList, without duplicating anything | ||
| 5960 | $patternListRef = $compObj->{stopPatternList}; | ||
| 5961 | OUTER: foreach my $item (@$patternListRef) { | ||
| 5962 | |||
| 5963 | my ($stopListRef, $matchFlag); | ||
| 5964 | |||
| 5965 | $stopListRef = $compObj->{stopAtPatternList}; | ||
| 5966 | INNER: foreach my $other (@$stopListRef) { | ||
| 5967 | |||
| 5968 | if ($other eq $item) { | ||
| 5969 | |||
| 5970 | $matchFlag = TRUE; | ||
| 5971 | last INNER; | ||
| 5972 | } | ||
| 5973 | } | ||
| 5974 | |||
| 5975 | if (! $matchFlag) { | ||
| 5976 | |||
| 5977 | $compObj->ivPush('stopAtPatternList', $item); | ||
| 5978 | } | ||
| 5979 | } | ||
| 5980 | |||
| 5981 | $tagListRef = $compObj->{stopTagList}; | ||
| 5982 | OUTER: foreach my $item (@$tagListRef) { | ||
| 5983 | |||
| 5984 | my ($stopListRef, $matchFlag); | ||
| 5985 | |||
| 5986 | $stopListRef = $compObj->{stopAtTagList}; | ||
| 5987 | INNER: foreach my $other (@$stopListRef) { | ||
| 5988 | |||
| 5989 | if ($other eq $item) { | ||
| 5990 | |||
| 5991 | $matchFlag = TRUE; | ||
| 5992 | last INNER; | ||
| 5993 | } | ||
| 5994 | } | ||
| 5995 | |||
| 5996 | if (! $matchFlag) { | ||
| 5997 | |||
| 5998 | $compObj->ivPush('stopAtTagList', $item); | ||
| 5999 | } | ||
| 6000 | } | ||
| 6001 | |||
| 6002 | # (We'll assume that ->stopAllFlag and ->stopTagMode should override | ||
| 6003 | # the existing settings of ->stopAtAllFlag and ->stopAtTagMode, | ||
| 6004 | # since ->stop... was formerly more important thatn ->stopAt...) | ||
| 6005 | if ($compObj->{stopAllFlag}) { | ||
| 6006 | |||
| 6007 | $compObj->ivPoke('stopAtAllFlag', TRUE); | ||
| 6008 | } | ||
| 6009 | |||
| 6010 | if ($compObj->{stopTagMode}) { | ||
| 6011 | |||
| 6012 | $compObj->ivPoke('stopAtTagMode', $compObj->{stopTagMode}); | ||
| 6013 | } | ||
| 6014 | |||
| 6015 | # We can now remove the old IVs | ||
| 6016 | delete $compObj->{stopPatternList}; | ||
| 6017 | delete $compObj->{stopTagList}; | ||
| 6018 | delete $compObj->{stopAllFlag}; | ||
| 6019 | delete $compObj->{stopTagMode}; | ||
| 6020 | } | ||
| 6021 | } | ||
| 6022 | } | ||
| 6023 | } | ||
| 6024 | |||
| 6025 | if ($version < 1_000_320) { | ||
| 6026 | |||
| 6027 | # Update room statement components with a new IV | ||
| 6028 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6029 | |||
| 6030 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 6031 | |||
| 6032 | if (! exists $compObj->{useAppliedTagsFlag}) { | ||
| 6033 | |||
| 6034 | # (This IV subsequently renamed and/or removed) | ||
| 6035 | # $compObj->{useAppliedTagsFlag} = undef; | ||
| 6036 | # $compObj->ivPoke('useAppliedTagsFlag', FALSE); | ||
| 6037 | $compObj->{useAppliedTagsFlag} = FALSE; | ||
| 6038 | } | ||
| 6039 | } | ||
| 6040 | } | ||
| 6041 | } | ||
| 6042 | |||
| 6043 | if ($version < 1_000_324) { | ||
| 6044 | |||
| 6045 | # Update room statement components with a new IV, which replaces an old one, but | ||
| 6046 | # reverses its setting | ||
| 6047 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6048 | |||
| 6049 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 6050 | |||
| 6051 | if (exists $compObj->{boldInsensitiveFlag}) { | ||
| 6052 | |||
| 6053 | $compObj->{boldSensitiveFlag} = undef; | ||
| 6054 | if ($compObj->{boldInsensitiveFlag}) { | ||
| 6055 | $compObj->ivPoke('boldSensitiveFlag', FALSE); | ||
| 6056 | } else { | ||
| 6057 | $compObj->ivPoke('boldSensitiveFlag', TRUE); | ||
| 6058 | } | ||
| 6059 | |||
| 6060 | delete $compObj->{boldInsensitiveFlag}; | ||
| 6061 | } | ||
| 6062 | } | ||
| 6063 | } | ||
| 6064 | } | ||
| 6065 | |||
| 6066 | if ($version < 1_000_330) { | ||
| 6067 | |||
| 6068 | # This version replaces several IVs (->exitStateOpenList, ->exitStateClosedList, | ||
| 6069 | # etc) with a single list IV, in groups of 4 | ||
| 6070 | |||
| 6071 | my %stateHash = ( | ||
| 6072 | 'exitStateOpenList' => 'open', | ||
| 6073 | 'exitStateClosedList' => 'closed', | ||
| 6074 | 'exitStateLockedList' => 'locked', | ||
| 6075 | 'exitStateImpassList' => 'impass', | ||
| 6076 | 'exitStateDarkList' => 'dark', | ||
| 6077 | 'exitStateDangerList' => 'danger', | ||
| 6078 | 'exitStateOtherList' => 'other', | ||
| 6079 | 'exitStateIgnoreList' => 'ignore', | ||
| 6080 | ); | ||
| 6081 | |||
| 6082 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6083 | |||
| 6084 | my @newList; | ||
| 6085 | |||
| 6086 | if (! exists $profObj->{exitStateStringList}) { | ||
| 6087 | |||
| 6088 | foreach my $iv (keys %stateHash) { | ||
| 6089 | |||
| 6090 | my ($state, $listRef, $start, $middle, $end, $flag); | ||
| 6091 | |||
| 6092 | $state = $stateHash{$iv}; | ||
| 6093 | $listRef = $profObj->{$iv}; | ||
| 6094 | |||
| 6095 | if (@$listRef) { | ||
| 6096 | |||
| 6097 | ($start, $end, $flag) = @$listRef; | ||
| 6098 | # () - There are no strings for this exit state | ||
| 6099 | # ('') - There are no strings for this exit state | ||
| 6100 | # ('', '') - There are no strings for this exit state | ||
| 6101 | if ($start || $end) { | ||
| 6102 | |||
| 6103 | # (string1) - String(s) appear at the beginning of the exit | ||
| 6104 | if ($start && ! $end) { | ||
| 6105 | |||
| 6106 | push (@newList, $state, $start, '', ''); | ||
| 6107 | |||
| 6108 | # ('', string2) - String(s) appear at the end of the exit | ||
| 6109 | } elsif (! $start && $end) { | ||
| 6110 | |||
| 6111 | if ($flag) { | ||
| 6112 | push (@newList, $state, '', $end, ''); | ||
| 6113 | } else { | ||
| 6114 | push (@newList, $state, '', '', $end); | ||
| 6115 | } | ||
| 6116 | |||
| 6117 | # (string1, string2) | ||
| 6118 | # - String(s) appear at the beginning and end | ||
| 6119 | # (string1, string2, TRUE) | ||
| 6120 | # - String(s) appear at the beginning and middle | ||
| 6121 | } else { | ||
| 6122 | |||
| 6123 | if ($flag) { | ||
| 6124 | push (@newList, $state, $start, $end, ''); | ||
| 6125 | } else { | ||
| 6126 | push (@newList, $state, $start, '', $end); | ||
| 6127 | } | ||
| 6128 | } | ||
| 6129 | } | ||
| 6130 | } | ||
| 6131 | } | ||
| 6132 | |||
| 6133 | # Create the new combined list IV | ||
| 6134 | $profObj->{exitStateStringList} = []; | ||
| 6135 | $profObj->ivPoke('exitStateStringList', @newList); | ||
| 6136 | # And delete the old ones | ||
| 6137 | delete $profObj->{exitStateOpenList}; | ||
| 6138 | delete $profObj->{exitStateClosedList}; | ||
| 6139 | delete $profObj->{exitStateLockedList}; | ||
| 6140 | delete $profObj->{exitStateImpassList}; | ||
| 6141 | delete $profObj->{exitStateDarkList}; | ||
| 6142 | delete $profObj->{exitStateDangerList}; | ||
| 6143 | delete $profObj->{exitStateOtherList}; | ||
| 6144 | delete $profObj->{exitStateIgnoreList}; | ||
| 6145 | } | ||
| 6146 | } | ||
| 6147 | } | ||
| 6148 | |||
| 6149 | if ($version < 1_000_467 && $self->session) { | ||
| 6150 | |||
| 6151 | # Update every command cage with new standard commands | ||
| 6152 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 6153 | |||
| 6154 | if ($cage->{cageType} eq 'cmd') { | ||
| 6155 | |||
| 6156 | if (! $cage->ivExists('cmdHash', 'teleport')) { | ||
| 6157 | |||
| 6158 | $cage->ivAdd('cmdHash', 'teleport', 'teleport room'); | ||
| 6159 | } | ||
| 6160 | } | ||
| 6161 | } | ||
| 6162 | } | ||
| 6163 | |||
| 6164 | if ($version < 1_000_482 && $self->session) { | ||
| 6165 | |||
| 6166 | # Update world profiles for new character life statuses | ||
| 6167 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6168 | |||
| 6169 | if ($profObj->ivExists('logPrefHash', 'asleep')) { | ||
| 6170 | |||
| 6171 | $profObj->ivAdd( | ||
| 6172 | 'logPrefHash', | ||
| 6173 | 'sleep', | ||
| 6174 | $profObj->ivShow('logPrefHash', 'asleep'), | ||
| 6175 | ); | ||
| 6176 | |||
| 6177 | $profObj->ivDelete('logPrefHash', 'asleep'); | ||
| 6178 | } | ||
| 6179 | |||
| 6180 | if ($profObj->ivExists('logPrefHash', 'passed_out')) { | ||
| 6181 | |||
| 6182 | $profObj->ivAdd( | ||
| 6183 | 'logPrefHash', | ||
| 6184 | 'passout', | ||
| 6185 | $profObj->ivShow('logPrefHash', 'passed_out'), | ||
| 6186 | ); | ||
| 6187 | |||
| 6188 | $profObj->ivDelete('logPrefHash', 'passed_out'); | ||
| 6189 | } | ||
| 6190 | } | ||
| 6191 | |||
| 6192 | # Update character profiles in the same way | ||
| 6193 | if ($self->session) { | ||
| 6194 | |||
| 6195 | # Update character profiles with new IVs | ||
| 6196 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 6197 | |||
| 6198 | if ($profObj->{category} eq 'char') { | ||
| 6199 | |||
| 6200 | if ($profObj->{lifeStatus} eq 'asleep') { | ||
| 6201 | $profObj->ivPoke('lifeStatus', 'sleep'); | ||
| 6202 | } elsif ($profObj->{lifeStatus} eq 'passed_out') { | ||
| 6203 | $profObj->ivPoke('lifeStatus', 'passout'); | ||
| 6204 | } | ||
| 6205 | } | ||
| 6206 | } | ||
| 6207 | } | ||
| 6208 | } | ||
| 6209 | |||
| 6210 | if ($version < 1_000_512) { | ||
| 6211 | |||
| 6212 | # Update room statement components with a new IV | ||
| 6213 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6214 | |||
| 6215 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 6216 | |||
| 6217 | if (! exists $compObj->{noExtractList}) { | ||
| 6218 | |||
| 6219 | $compObj->{noExtractList} = []; | ||
| 6220 | $compObj->ivEmpty('noExtractList'); | ||
| 6221 | } | ||
| 6222 | } | ||
| 6223 | } | ||
| 6224 | } | ||
| 6225 | |||
| 6226 | if ($version < 1_000_515) { | ||
| 6227 | |||
| 6228 | # Update world profiles with a new IV | ||
| 6229 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6230 | |||
| 6231 | if (! exists $profObj->{exitAliasHash}) { | ||
| 6232 | |||
| 6233 | $profObj->{exitAliasHash} = {}; | ||
| 6234 | $profObj->ivEmpty('exitAliasHash'); | ||
| 6235 | } | ||
| 6236 | } | ||
| 6237 | } | ||
| 6238 | |||
| 6239 | if ($version < 1_000_517) { | ||
| 6240 | |||
| 6241 | # Update world profiles with a new IV | ||
| 6242 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6243 | |||
| 6244 | if (! exists $profObj->{basicMappingMode}) { | ||
| 6245 | |||
| 6246 | # (This IV subsequently renamed and/or removed) | ||
| 6247 | # $profObj->{basicMappingMode} = undef; | ||
| 6248 | # $profObj->ivPoke('basicMappingMode', 0); | ||
| 6249 | $profObj->{basicMappingMode} = 0; | ||
| 6250 | } | ||
| 6251 | } | ||
| 6252 | } | ||
| 6253 | |||
| 6254 | if ($version < 1_000_524) { | ||
| 6255 | |||
| 6256 | # Update world profiles with a new IV | ||
| 6257 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6258 | |||
| 6259 | if (! exists $profObj->{notAnchorPatternList}) { | ||
| 6260 | |||
| 6261 | $profObj->{notAnchorPatternList} = []; | ||
| 6262 | $profObj->ivEmpty('notAnchorPatternList'); | ||
| 6263 | } | ||
| 6264 | } | ||
| 6265 | } | ||
| 6266 | |||
| 6267 | if ($version < 1_000_526) { | ||
| 6268 | |||
| 6269 | # Update world profiles with new IVs | ||
| 6270 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6271 | |||
| 6272 | if (! exists $profObj->{verboseExitSplitCharFlag}) { | ||
| 6273 | |||
| 6274 | $profObj->{verboseExitSplitCharFlag} = undef; | ||
| 6275 | $profObj->ivPoke('verboseExitSplitCharFlag', FALSE); | ||
| 6276 | $profObj->{briefExitSplitCharFlag} = undef; | ||
| 6277 | $profObj->ivPoke('briefExitSplitCharFlag', FALSE); | ||
| 6278 | } | ||
| 6279 | } | ||
| 6280 | } | ||
| 6281 | |||
| 6282 | if ($version < 1_000_530) { | ||
| 6283 | |||
| 6284 | # Update room statement components with an IV whose name has been changed, and a | ||
| 6285 | # new IV | ||
| 6286 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6287 | |||
| 6288 | foreach my $compObj ($profObj->ivValues('componentHash')) { | ||
| 6289 | |||
| 6290 | if (! exists $compObj->{useInitialTagsFlag}) { | ||
| 6291 | |||
| 6292 | $compObj->{useInitialTagsFlag} = undef; | ||
| 6293 | $compObj->ivPoke('useInitialTagsFlag', $compObj->{useAppliedTagsFlag}); | ||
| 6294 | delete $compObj->{useAppliedTagsFlag}; | ||
| 6295 | } | ||
| 6296 | |||
| 6297 | if (! exists $compObj->{useExplicitTagsFlag}) { | ||
| 6298 | |||
| 6299 | $compObj->{useExplicitTagsFlag} = undef; | ||
| 6300 | $compObj->ivPoke('useExplicitTagsFlag', FALSE); | ||
| 6301 | } | ||
| 6302 | } | ||
| 6303 | } | ||
| 6304 | } | ||
| 6305 | |||
| 6306 | if ($version < 1_000_537) { | ||
| 6307 | |||
| 6308 | # Update world profiles with new IVs | ||
| 6309 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6310 | |||
| 6311 | if (! exists $profObj->{loginAccountMode}) { | ||
| 6312 | |||
| 6313 | $profObj->{loginAccountMode} = undef; | ||
| 6314 | $profObj->ivPoke('loginAccountMode', 0); | ||
| 6315 | } | ||
| 6316 | } | ||
| 6317 | } | ||
| 6318 | |||
| 6319 | if ($version < 1_000_538) { | ||
| 6320 | |||
| 6321 | # Update world profiles with a new IV | ||
| 6322 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6323 | |||
| 6324 | if (! exists $profObj->{loginSpecialList}) { | ||
| 6325 | |||
| 6326 | $profObj->{loginSpecialList} = []; | ||
| 6327 | $profObj->ivEmpty('loginSpecialList'); | ||
| 6328 | } | ||
| 6329 | } | ||
| 6330 | } | ||
| 6331 | |||
| 6332 | if ($version < 1_000_541) { | ||
| 6333 | |||
| 6334 | # Update world profiles with a new IV | ||
| 6335 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6336 | |||
| 6337 | if (! exists $profObj->{worldWarning}) { | ||
| 6338 | |||
| 6339 | # (This IV subsequently renamed and/or removed) | ||
| 6340 | # $profObj->{worldWarning} = undef; | ||
| 6341 | # $profObj->ivUndef('worldWarning'); | ||
| 6342 | $profObj->{worldWarning} = undef; | ||
| 6343 | } | ||
| 6344 | } | ||
| 6345 | } | ||
| 6346 | |||
| 6347 | if ($version < 1_000_542) { | ||
| 6348 | |||
| 6349 | # Update world profiles with a new IV | ||
| 6350 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6351 | |||
| 6352 | if (! exists $profObj->{statOrderList}) { | ||
| 6353 | |||
| 6354 | $profObj->{statOrderList} = []; | ||
| 6355 | $profObj->ivEmpty('statOrderList'); | ||
| 6356 | } | ||
| 6357 | } | ||
| 6358 | } | ||
| 6359 | |||
| 6360 | if ($version < 1_000_544) { | ||
| 6361 | |||
| 6362 | # Update world profiles with new IVs | ||
| 6363 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6364 | |||
| 6365 | if (! exists $profObj->{autoQuitMode}) { | ||
| 6366 | |||
| 6367 | $profObj->{autoQuitMode} = undef; | ||
| 6368 | $profObj->ivUndef('autoQuitMode'); | ||
| 6369 | $profObj->{autoQuitCmdList} = []; | ||
| 6370 | $profObj->ivEmpty('autoQuitCmdList'); | ||
| 6371 | $profObj->{autoQuitObjName} = undef; | ||
| 6372 | $profObj->ivUndef('autoQuitObjName'); | ||
| 6373 | } | ||
| 6374 | } | ||
| 6375 | } | ||
| 6376 | |||
| 6377 | if ($version < 1_000_576) { | ||
| 6378 | |||
| 6379 | # Update world profiles with a new IV | ||
| 6380 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6381 | |||
| 6382 | if (! exists $profObj->{collectContentsFlag}) { | ||
| 6383 | |||
| 6384 | $profObj->{collectContentsFlag} = undef; | ||
| 6385 | $profObj->ivPoke('collectContentsFlag', TRUE); | ||
| 6386 | } | ||
| 6387 | } | ||
| 6388 | } | ||
| 6389 | |||
| 6390 | if ($version < 1_000_577) { | ||
| 6391 | |||
| 6392 | # Update world profiles with a new IV | ||
| 6393 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6394 | |||
| 6395 | if (! exists $profObj->{multiplePattern}) { | ||
| 6396 | |||
| 6397 | $profObj->{multiplePattern} = undef; | ||
| 6398 | $profObj->ivUndef('multiplePattern'); | ||
| 6399 | } | ||
| 6400 | } | ||
| 6401 | } | ||
| 6402 | |||
| 6403 | if ($version < 1_000_578) { | ||
| 6404 | |||
| 6405 | # Update world profiles with a new IV | ||
| 6406 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6407 | |||
| 6408 | if (! exists $profObj->{followPatternList}) { | ||
| 6409 | |||
| 6410 | $profObj->{followPatternList} = []; | ||
| 6411 | $profObj->ivEmpty('followPatternList'); | ||
| 6412 | } | ||
| 6413 | } | ||
| 6414 | } | ||
| 6415 | |||
| 6416 | if ($version < 1_000_622) { | ||
| 6417 | |||
| 6418 | # Update all profiles with a new IV | ||
| 6419 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6420 | |||
| 6421 | if (! exists $profObj->{notepadList}) { | ||
| 6422 | |||
| 6423 | $profObj->{notepadList} = []; | ||
| 6424 | $profObj->ivEmpty('notepadList'); | ||
| 6425 | } | ||
| 6426 | } | ||
| 6427 | |||
| 6428 | if ($self->session) { | ||
| 6429 | |||
| 6430 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 6431 | |||
| 6432 | if ($profObj->{category} ne 'world' && ! exists $profObj->{notepadList}) { | ||
| 6433 | |||
| 6434 | $profObj->{notepadList} = []; | ||
| 6435 | $profObj->ivEmpty('notepadList'); | ||
| 6436 | } | ||
| 6437 | } | ||
| 6438 | |||
| 6439 | foreach my $templObj ($self->session->ivValues('templateHash')) { | ||
| 6440 | |||
| 6441 | if (! $templObj->ivExists('_standardHash', 'notepadList')) { | ||
| 6442 | |||
| 6443 | # (Because this IV starts with an underline, have to set it directly) | ||
| 6444 | $templObj->{'_standardHash'}{'notepadList'} = undef; | ||
| 6445 | } | ||
| 6446 | } | ||
| 6447 | } | ||
| 6448 | } | ||
| 6449 | |||
| 6450 | if ($version < 1_000_688) { | ||
| 6451 | |||
| 6452 | # Update world profiles with a new IV | ||
| 6453 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6454 | |||
| 6455 | if (! exists $profObj->{gaugeFormatList}) { | ||
| 6456 | |||
| 6457 | $profObj->{gaugeFormatList} = []; | ||
| 6458 | $profObj->ivPoke( | ||
| 6459 | 'gaugeFormatList', | ||
| 6460 | 'health_points', 'health_points_max', FALSE, 'HP', | ||
| 6461 | 'RED', 'red', 'WHITE', | ||
| 6462 | 'magic_points', 'magic_points_max', FALSE, 'MP', | ||
| 6463 | 'YELLOW', 'yellow', 'black', | ||
| 6464 | 'energy_points', 'energy_points_max', FALSE, 'EP', | ||
| 6465 | 'GREEN', 'green', 'black', | ||
| 6466 | 'guild_points', 'guild_points_max', FALSE, 'GP', | ||
| 6467 | 'BLUE', 'blue', 'WHITE', | ||
| 6468 | 'social_points', 'social_points_max', FALSE, 'SP', | ||
| 6469 | 'MAGENTA', 'magenta', 'WHITE', | ||
| 6470 | ); | ||
| 6471 | } | ||
| 6472 | } | ||
| 6473 | } | ||
| 6474 | |||
| 6475 | if ($version < 1_000_800 && $self->session) { | ||
| 6476 | |||
| 6477 | # This version adds some trigger attributes. Update every trigger cage | ||
| 6478 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 6479 | |||
| 6480 | if ($cage->{cageType} eq 'trigger') { | ||
| 6481 | |||
| 6482 | foreach my $trigObj ($cage->ivValues('interfaceHash')) { | ||
| 6483 | |||
| 6484 | $trigObj->ivAdd('attribHash', 'default_pane', TRUE); | ||
| 6485 | $trigObj->ivAdd('attribHash', 'pane_name', ''); | ||
| 6486 | } | ||
| 6487 | } | ||
| 6488 | } | ||
| 6489 | } | ||
| 6490 | |||
| 6491 | if ($version < 1_000_808) { | ||
| 6492 | |||
| 6493 | # Update world profiles' stored mission objects | ||
| 6494 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6495 | |||
| 6496 | foreach my $missionObj ($profObj->ivValues('missionHash')) { | ||
| 6497 | |||
| 6498 | if (! exists $missionObj->{quietFlag}) { | ||
| 6499 | |||
| 6500 | $missionObj->{quietFlag} = undef; | ||
| 6501 | $missionObj->ivPoke('quietFlag', FALSE); | ||
| 6502 | |||
| 6503 | # IVs used to store temporary values while a mission was running have | ||
| 6504 | # not, until now, been reset properly | ||
| 6505 | $missionObj->resetMission(); | ||
| 6506 | } | ||
| 6507 | } | ||
| 6508 | } | ||
| 6509 | } | ||
| 6510 | |||
| 6511 | if ($version < 1_000_851) { | ||
| 6512 | |||
| 6513 | my $regex = $axmud::SCRIPT . '\:\:'; | ||
| 6514 | |||
| 6515 | # Update world profiles' stored mission objects, whose ->triggerName and | ||
| 6516 | # ->timerName IVs were set wrong, which caused save file operations to fail | ||
| 6517 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6518 | |||
| 6519 | foreach my $missionObj ($profObj->ivValues('missionHash')) { | ||
| 6520 | |||
| 6521 | if (ref($missionObj->{triggerName}) =~ m/$regex/) { | ||
| 6522 | |||
| 6523 | $missionObj->ivPoke('triggerName', $missionObj->{triggerName}->{name}); | ||
| 6524 | } | ||
| 6525 | |||
| 6526 | if (ref($missionObj->{timerName}) =~ m/$regex/) { | ||
| 6527 | |||
| 6528 | $missionObj->ivPoke('timerName', $missionObj->{timerName}->{name}); | ||
| 6529 | } | ||
| 6530 | } | ||
| 6531 | } | ||
| 6532 | } | ||
| 6533 | |||
| 6534 | if ($version < 1_000_852) { | ||
| 6535 | |||
| 6536 | # Update world profiles with a new IV | ||
| 6537 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6538 | |||
| 6539 | if (! exists $profObj->{adultFlag}) { | ||
| 6540 | |||
| 6541 | $profObj->{adultFlag} = undef; | ||
| 6542 | $profObj->ivPoke('adultFlag', TRUE); | ||
| 6543 | } | ||
| 6544 | } | ||
| 6545 | } | ||
| 6546 | |||
| 6547 | if ($version < 1_000_877) { | ||
| 6548 | |||
| 6549 | # Update world profiles with a new IV | ||
| 6550 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6551 | |||
| 6552 | if (! exists $profObj->{inventoryDiscardPatternList}) { | ||
| 6553 | |||
| 6554 | $profObj->{inventoryDiscardPatternList} = []; | ||
| 6555 | $profObj->ivEmpty('inventoryDiscardPatternList'); | ||
| 6556 | } | ||
| 6557 | } | ||
| 6558 | } | ||
| 6559 | |||
| 6560 | if ($version < 1_000_879) { | ||
| 6561 | |||
| 6562 | # Update world profiles with new IVs | ||
| 6563 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6564 | |||
| 6565 | if (! exists $profObj->{telnetOverrideHash}) { | ||
| 6566 | |||
| 6567 | $profObj->{telnetOverrideHash} = {}; | ||
| 6568 | $profObj->ivEmpty('telnetOverrideHash'); | ||
| 6569 | $profObj->{termOverrideHash} = {}; | ||
| 6570 | $profObj->ivEmpty('termOverrideHash'); | ||
| 6571 | |||
| 6572 | # One or two worlds must forbid certain protocols by default | ||
| 6573 | if ($profObj->name eq 'kallisti') { | ||
| 6574 | |||
| 6575 | $profObj->ivAdd('telnetOverrideHash', 'msdp', undef); | ||
| 6576 | } | ||
| 6577 | } | ||
| 6578 | } | ||
| 6579 | } | ||
| 6580 | |||
| 6581 | if ($version < 1_000_880) { | ||
| 6582 | |||
| 6583 | # Rename a world profile IV | ||
| 6584 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6585 | |||
| 6586 | if (! exists $profObj->{worldHint}) { | ||
| 6587 | |||
| 6588 | $profObj->{worldHint} = undef; | ||
| 6589 | $profObj->ivPoke('worldHint', $profObj->{worldWarning}); | ||
| 6590 | delete $profObj->{worldWarning}; | ||
| 6591 | } | ||
| 6592 | } | ||
| 6593 | } | ||
| 6594 | |||
| 6595 | if ($version < 1_000_881) { | ||
| 6596 | |||
| 6597 | # Update world profiles with a new IV | ||
| 6598 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6599 | |||
| 6600 | if (! exists $profObj->{sigilOverrideHash}) { | ||
| 6601 | |||
| 6602 | $profObj->{sigilOverrideHash} = {}; | ||
| 6603 | $profObj->ivEmpty('sigilOverrideHash'); | ||
| 6604 | } | ||
| 6605 | } | ||
| 6606 | } | ||
| 6607 | |||
| 6608 | if ($version < 1_000_885) { | ||
| 6609 | |||
| 6610 | # Update world profiles with a new IV | ||
| 6611 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6612 | |||
| 6613 | if (! exists $profObj->{connectHistoryList}) { | ||
| 6614 | |||
| 6615 | $profObj->{connectHistoryList} = []; | ||
| 6616 | $profObj->ivEmpty('connectHistoryList'); | ||
| 6617 | } | ||
| 6618 | } | ||
| 6619 | } | ||
| 6620 | |||
| 6621 | if ($version < 1_000_888) { | ||
| 6622 | |||
| 6623 | # Update world profiles with new IVs | ||
| 6624 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6625 | |||
| 6626 | if (! exists $profObj->{mxpOverrideHash}) { | ||
| 6627 | |||
| 6628 | $profObj->{mxpOverrideHash} = {}; | ||
| 6629 | $profObj->ivEmpty('mxpOverrideHash'); | ||
| 6630 | |||
| 6631 | # One or two worlds must turn off certain options by default | ||
| 6632 | if ($profObj->name eq 'coffeemud') { | ||
| 6633 | |||
| 6634 | $profObj->ivAdd('mxpOverrideHash', 'room', FALSE); | ||
| 6635 | } | ||
| 6636 | } | ||
| 6637 | } | ||
| 6638 | } | ||
| 6639 | |||
| 6640 | if ($version < 1_000_896) { | ||
| 6641 | |||
| 6642 | # Update world profiles with new IVs | ||
| 6643 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6644 | |||
| 6645 | if (! exists $profObj->{verboseAnchorCheckList}) { | ||
| 6646 | |||
| 6647 | $profObj->{verboseAnchorCheckList} = []; | ||
| 6648 | $profObj->ivEmpty('verboseAnchorCheckList'); | ||
| 6649 | $profObj->{shortAnchorCheckList} = []; | ||
| 6650 | $profObj->ivEmpty('shortAnchorCheckList'); | ||
| 6651 | $profObj->{briefAnchorCheckList} = []; | ||
| 6652 | $profObj->ivEmpty('briefAnchorCheckList'); | ||
| 6653 | } | ||
| 6654 | |||
| 6655 | if (! exists $profObj->{roomCmdDelimiterList}) { | ||
| 6656 | |||
| 6657 | $profObj->{roomCmdDelimiterList} = []; | ||
| 6658 | $profObj->ivEmpty('roomCmdDelimiterList'); | ||
| 6659 | $profObj->{roomCmdNonDelimiterList} = []; | ||
| 6660 | $profObj->ivEmpty('roomCmdNonDelimiterList'); | ||
| 6661 | $profObj->{roomCmdSplitCharFlag} = undef; | ||
| 6662 | $profObj->ivPoke('roomCmdSplitCharFlag', FALSE); | ||
| 6663 | $profObj->{roomCmdLeftMarkerList} = []; | ||
| 6664 | $profObj->ivEmpty('roomCmdLeftMarkerList'); | ||
| 6665 | $profObj->{roomCmdRightMarkerList} = []; | ||
| 6666 | $profObj->ivEmpty('roomCmdRightMarkerList'); | ||
| 6667 | } | ||
| 6668 | |||
| 6669 | # Also remove an IV, which has moved to GA::Client->constComponentTypeList | ||
| 6670 | if (exists ($profObj->{_constComponentList})) { | ||
| 6671 | |||
| 6672 | delete $profObj->{_constComponentList}; | ||
| 6673 | } | ||
| 6674 | } | ||
| 6675 | } | ||
| 6676 | |||
| 6677 | if ($version < 1_000_909) { | ||
| 6678 | |||
| 6679 | my @profList; | ||
| 6680 | |||
| 6681 | # This version converts some numerical mode values to string mode values | ||
| 6682 | |||
| 6683 | push (@profList, $axmud::CLIENT->ivValues('worldProfHash')); | ||
| 6684 | if ($self->session) { | ||
| 6685 | |||
| 6686 | push (@profList, $self->session->ivValues('profHash')); | ||
| 6687 | } | ||
| 6688 | |||
| 6689 | foreach my $profObj (@profList) { | ||
| 6690 | |||
| 6691 | my %initScriptHash = $profObj->initScriptHash; | ||
| 6692 | |||
| 6693 | foreach my $key (keys %initScriptHash) { | ||
| 6694 | |||
| 6695 | my $value = $initScriptHash{$key}; | ||
| 6696 | |||
| 6697 | if ($value eq '0') { | ||
| 6698 | $initScriptHash{$key} = 'no_task'; | ||
| 6699 | } elsif ($value eq '1') { | ||
| 6700 | $initScriptHash{$key} = 'run_task'; | ||
| 6701 | } elsif ($value eq '2') { | ||
| 6702 | $initScriptHash{$key} = 'run_task_win'; | ||
| 6703 | } | ||
| 6704 | } | ||
| 6705 | |||
| 6706 | $profObj->ivPoke('initScriptHash', %initScriptHash); | ||
| 6707 | |||
| 6708 | if ($profObj->category eq 'world') { | ||
| 6709 | |||
| 6710 | if ($profObj->loginMode eq '0') { | ||
| 6711 | $profObj->ivPoke('loginMode', 'none'); | ||
| 6712 | } elsif ($profObj->loginMode eq '1') { | ||
| 6713 | $profObj->ivPoke('loginMode', 'immediate'); | ||
| 6714 | } elsif ($profObj->loginMode eq '2') { | ||
| 6715 | $profObj->ivPoke('loginMode', 'lp'); | ||
| 6716 | } elsif ($profObj->loginMode eq '3') { | ||
| 6717 | $profObj->ivPoke('loginMode', 'tiny'); | ||
| 6718 | } elsif ($profObj->loginMode eq '4') { | ||
| 6719 | $profObj->ivPoke('loginMode', 'world_cmd'); | ||
| 6720 | } elsif ($profObj->loginMode eq '5') { | ||
| 6721 | $profObj->ivPoke('loginMode', 'telnet'); | ||
| 6722 | } elsif ($profObj->loginMode eq '6') { | ||
| 6723 | $profObj->ivPoke('loginMode', 'task'); | ||
| 6724 | } elsif ($profObj->loginMode eq '7') { | ||
| 6725 | $profObj->ivPoke('loginMode', 'script_task'); | ||
| 6726 | } elsif ($profObj->loginMode eq '8') { | ||
| 6727 | $profObj->ivPoke('loginMode', 'script'); | ||
| 6728 | } elsif ($profObj->loginMode eq '9') { | ||
| 6729 | $profObj->ivPoke('loginMode', 'mission'); | ||
| 6730 | } | ||
| 6731 | |||
| 6732 | if ($profObj->loginAccountMode eq '0') { | ||
| 6733 | $profObj->ivPoke('loginAccountMode', 'unknown'); | ||
| 6734 | } elsif ($profObj->loginAccountMode eq '1') { | ||
| 6735 | $profObj->ivPoke('loginAccountMode', 'not_required'); | ||
| 6736 | } elsif ($profObj->loginAccountMode eq '2') { | ||
| 6737 | $profObj->ivPoke('loginAccountMode', 'required'); | ||
| 6738 | } | ||
| 6739 | |||
| 6740 | if ($version >= 1_000_543) { | ||
| 6741 | |||
| 6742 | if ($profObj->autoQuitMode eq '0') { | ||
| 6743 | $profObj->ivPoke('autoQuitMode', 'normal'); | ||
| 6744 | } elsif ($profObj->autoQuitMode eq '1') { | ||
| 6745 | $profObj->ivPoke('autoQuitMode', 'world_cmd'); | ||
| 6746 | } elsif ($profObj->autoQuitMode eq '2') { | ||
| 6747 | $profObj->ivPoke('autoQuitMode', 'task'); | ||
| 6748 | } elsif ($profObj->autoQuitMode eq '3') { | ||
| 6749 | $profObj->ivPoke('autoQuitMode', 'task_script'); | ||
| 6750 | } elsif ($profObj->autoQuitMode eq '4') { | ||
| 6751 | $profObj->ivPoke('autoQuitMode', 'script'); | ||
| 6752 | } elsif ($profObj->autoQuitMode eq '5') { | ||
| 6753 | $profObj->ivPoke('autoQuitMode', 'mission'); | ||
| 6754 | } | ||
| 6755 | } | ||
| 6756 | |||
| 6757 | if ($profObj->inventoryMode eq '0') { | ||
| 6758 | $profObj->ivPoke('inventoryMode', 'match_all'); | ||
| 6759 | } elsif ($profObj->inventoryMode eq '1') { | ||
| 6760 | $profObj->ivPoke('inventoryMode', 'start_stop'); | ||
| 6761 | } elsif ($profObj->inventoryMode eq '2') { | ||
| 6762 | $profObj->ivPoke('inventoryMode', 'start_empty'); | ||
| 6763 | } | ||
| 6764 | |||
| 6765 | # (This IV subsequently renamed and/or removed) | ||
| 6766 | if (! $profObj->basicMappingMode) { | ||
| 6767 | # $profObj->ivPoke('basicMappingMode', FALSE); | ||
| 6768 | $profObj->{'basicMappingMode'} = FALSE; | ||
| 6769 | } else { | ||
| 6770 | # $profObj->ivPoke('basicMappingMode', TRUE); | ||
| 6771 | $profObj->{'basicMappingMode'} = TRUE; | ||
| 6772 | } | ||
| 6773 | |||
| 6774 | foreach my $componentObj ($profObj->ivValues('componentHash')) { | ||
| 6775 | |||
| 6776 | foreach my $iv ( | ||
| 6777 | 'startTagMode', 'startNoTagMode', 'skipTagMode', | ||
| 6778 | 'stopBeforeTagMode', 'stopBeforeNoTagMode', 'stopAtTagMode', | ||
| 6779 | 'stopAtNoTagMode', | ||
| 6780 | ) { | ||
| 6781 | if ($componentObj->$iv eq '0') { | ||
| 6782 | $componentObj->ivPoke($iv, 'default'); | ||
| 6783 | } elsif ($componentObj->$iv eq '1') { | ||
| 6784 | $componentObj->ivPoke($iv, 'no_colour'); | ||
| 6785 | } elsif ($componentObj->$iv eq '2') { | ||
| 6786 | $componentObj->ivPoke($iv, 'no_style'); | ||
| 6787 | } elsif ($componentObj->$iv eq '3') { | ||
| 6788 | $componentObj->ivPoke($iv, 'no_colour_style'); | ||
| 6789 | } | ||
| 6790 | } | ||
| 6791 | |||
| 6792 | foreach my $iv ('stopBeforeMode', 'stopAtMode') { | ||
| 6793 | |||
| 6794 | if ($componentObj->$iv eq '0') { | ||
| 6795 | $componentObj->ivPoke($iv, 'default'); | ||
| 6796 | } elsif ($componentObj->$iv eq '1') { | ||
| 6797 | $componentObj->ivPoke($iv, 'no_char'); | ||
| 6798 | } elsif ($componentObj->$iv eq '2') { | ||
| 6799 | $componentObj->ivPoke($iv, 'no_letter_num'); | ||
| 6800 | } elsif ($componentObj->$iv eq '3') { | ||
| 6801 | $componentObj->ivPoke($iv, 'no_start_letter_num'); | ||
| 6802 | } elsif ($componentObj->$iv eq '4') { | ||
| 6803 | $componentObj->ivPoke($iv, 'no_tag'); | ||
| 6804 | } elsif ($componentObj->$iv eq '5') { | ||
| 6805 | $componentObj->ivPoke($iv, 'has_letter_num'); | ||
| 6806 | } elsif ($componentObj->$iv eq '6') { | ||
| 6807 | $componentObj->ivPoke($iv, 'has_start_letter_num'); | ||
| 6808 | } elsif ($componentObj->$iv eq '7') { | ||
| 6809 | $componentObj->ivPoke($iv, 'has_tag'); | ||
| 6810 | } | ||
| 6811 | } | ||
| 6812 | } | ||
| 6813 | } | ||
| 6814 | } | ||
| 6815 | } | ||
| 6816 | |||
| 6817 | if ($version < 1_000_915) { | ||
| 6818 | |||
| 6819 | # Update world profiles with new IVs | ||
| 6820 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6821 | |||
| 6822 | if (! exists $profObj->{followAnchorPatternList}) { | ||
| 6823 | |||
| 6824 | $profObj->{followAnchorPatternList} = []; | ||
| 6825 | $profObj->ivEmpty('followAnchorPatternList'); | ||
| 6826 | } | ||
| 6827 | } | ||
| 6828 | } | ||
| 6829 | |||
| 6830 | if ($version < 1_000_921) { | ||
| 6831 | |||
| 6832 | if ($self->session) { | ||
| 6833 | |||
| 6834 | # Remove IVs from profile templates and custom profiles | ||
| 6835 | foreach my $templObj ($self->session->ivValues('templateHash')) { | ||
| 6836 | |||
| 6837 | if (exists $templObj->{_standardHash}) { | ||
| 6838 | |||
| 6839 | delete $templObj->{_standardHash}; | ||
| 6840 | } | ||
| 6841 | |||
| 6842 | if (exists $templObj->{_fixedFlag}) { | ||
| 6843 | |||
| 6844 | $templObj->{constFixedFlag} = $templObj->{_fixedFlag}; | ||
| 6845 | delete $templObj->{_fixedFlag}; | ||
| 6846 | } | ||
| 6847 | |||
| 6848 | # (This line makes sure the correct file object's ->modifyFlag is set) | ||
| 6849 | $templObj->ivPoke('category', $templObj->category); | ||
| 6850 | } | ||
| 6851 | |||
| 6852 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 6853 | |||
| 6854 | if (exists $profObj->{_standardHash}) { | ||
| 6855 | |||
| 6856 | delete $profObj->{_standardHash}; | ||
| 6857 | |||
| 6858 | # (This line makes sure the correct file object's ->modifyFlag is set) | ||
| 6859 | $profObj->ivPoke('category', $profObj->category); | ||
| 6860 | } | ||
| 6861 | } | ||
| 6862 | } | ||
| 6863 | } | ||
| 6864 | |||
| 6865 | if ($version < 1_000_922) { | ||
| 6866 | |||
| 6867 | # This version renames a world profile IV | ||
| 6868 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6869 | |||
| 6870 | if (exists $profObj->{_localWimpyMax}) { | ||
| 6871 | |||
| 6872 | $profObj->{constLocalWimpyMax} = $profObj->{_localWimpyMax}; | ||
| 6873 | delete $profObj->{_localWimpyMax}; | ||
| 6874 | |||
| 6875 | # (This line makes sure the correct file object's ->modifyFlag is set) | ||
| 6876 | $profObj->ivPoke('category', $profObj->category); | ||
| 6877 | } | ||
| 6878 | } | ||
| 6879 | } | ||
| 6880 | |||
| 6881 | if ($version < 1_001_020) { | ||
| 6882 | |||
| 6883 | # Update world profiles with a new IV | ||
| 6884 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6885 | |||
| 6886 | if (! exists $profObj->{inventorySplitPatternList}) { | ||
| 6887 | |||
| 6888 | $profObj->{inventorySplitPatternList} = []; | ||
| 6889 | $profObj->ivEmpty('inventorySplitPatternList'); | ||
| 6890 | } | ||
| 6891 | } | ||
| 6892 | } | ||
| 6893 | |||
| 6894 | if ($version < 1_001_030) { | ||
| 6895 | |||
| 6896 | # Update world profiles with a new IV | ||
| 6897 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6898 | |||
| 6899 | if (! exists $profObj->{roomCmdIgnoreList}) { | ||
| 6900 | |||
| 6901 | $profObj->{roomCmdIgnoreList} = []; | ||
| 6902 | $profObj->ivEmpty('roomCmdIgnoreList'); | ||
| 6903 | } | ||
| 6904 | } | ||
| 6905 | } | ||
| 6906 | |||
| 6907 | if ($version < 1_001_074) { | ||
| 6908 | |||
| 6909 | # Update world profiles with a new IV | ||
| 6910 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6911 | |||
| 6912 | if (! exists $profObj->{exitStatePatternList}) { | ||
| 6913 | |||
| 6914 | $profObj->{exitStatePatternList} = []; | ||
| 6915 | $profObj->ivEmpty('exitStatePatternList'); | ||
| 6916 | } | ||
| 6917 | } | ||
| 6918 | } | ||
| 6919 | |||
| 6920 | if ($version < 1_001_082) { | ||
| 6921 | |||
| 6922 | # Update world profiles with a new IV | ||
| 6923 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6924 | |||
| 6925 | if (! exists $profObj->{transientExitPatternList}) { | ||
| 6926 | |||
| 6927 | $profObj->{transientExitPatternList} = []; | ||
| 6928 | $profObj->ivEmpty('transientExitPatternList'); | ||
| 6929 | } | ||
| 6930 | } | ||
| 6931 | } | ||
| 6932 | |||
| 6933 | if ($version < 1_001_124) { | ||
| 6934 | |||
| 6935 | my ( | ||
| 6936 | $listRef, | ||
| 6937 | @newList, @newList2, @combList, | ||
| 6938 | %hash, %checkHash, | ||
| 6939 | ); | ||
| 6940 | |||
| 6941 | # This version merges several IVs into single lists, eliminating duplicates | ||
| 6942 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 6943 | |||
| 6944 | if (! exists $profObj->{channelList}) { | ||
| 6945 | |||
| 6946 | $profObj->{channelList} = []; | ||
| 6947 | $profObj->ivEmpty('channelList'); | ||
| 6948 | $profObj->{noChannelList} = []; | ||
| 6949 | $profObj->ivEmpty('noChannelList'); | ||
| 6950 | |||
| 6951 | # Compile a hash of of patterns in the three existing IVs, sort them, then | ||
| 6952 | # compile the new IV | ||
| 6953 | # In case the same pattern exists in multiple IVs, use the 'tell' pattern | ||
| 6954 | # first | ||
| 6955 | $listRef = $profObj->{customDivertPatternList}; | ||
| 6956 | if (defined $listRef && @$listRef) { | ||
| 6957 | |||
| 6958 | do { | ||
| 6959 | |||
| 6960 | my $pattern = shift @$listRef; | ||
| 6961 | my $flag = shift @$listRef; | ||
| 6962 | |||
| 6963 | $hash{$pattern} = ['custom', $flag]; | ||
| 6964 | |||
| 6965 | } until (! @$listRef); | ||
| 6966 | } | ||
| 6967 | |||
| 6968 | $listRef = $profObj->{socialPatternList}; | ||
| 6969 | if (defined $listRef) { | ||
| 6970 | |||
| 6971 | foreach my $pattern (@$listRef) { | ||
| 6972 | |||
| 6973 | # Set TRUE because in previous versions of Axmud, social/tell | ||
| 6974 | # patterns were not displayed in the 'main' window and the task | ||
| 6975 | # window | ||
| 6976 | $hash{$pattern} = ['social', TRUE]; | ||
| 6977 | } | ||
| 6978 | } | ||
| 6979 | |||
| 6980 | if (defined $listRef) { | ||
| 6981 | |||
| 6982 | $listRef = $profObj->{tellPatternList}; | ||
| 6983 | foreach my $pattern (@$listRef) { | ||
| 6984 | |||
| 6985 | $hash{$pattern} = ['tell', TRUE]; | ||
| 6986 | } | ||
| 6987 | } | ||
| 6988 | |||
| 6989 | # Compile the new IV | ||
| 6990 | foreach my $pattern (sort {lc($a) cmp lc($b)} (keys %hash)) { | ||
| 6991 | |||
| 6992 | $listRef = $hash{$pattern}; | ||
| 6993 | |||
| 6994 | if (defined $listRef) { | ||
| 6995 | |||
| 6996 | push (@newList, $pattern, @$listRef); | ||
| 6997 | } | ||
| 6998 | } | ||
| 6999 | |||
| 7000 | $profObj->ivPoke('channelList', @newList); | ||
| 7001 | |||
| 7002 | # Repeat the process for the other IVs, eliminating duplicates using | ||
| 7003 | # %checkHash | ||
| 7004 | $listRef = $profObj->{noTellPatternList}; | ||
| 7005 | if (defined $listRef) { | ||
| 7006 | |||
| 7007 | push (@combList, @$listRef); | ||
| 7008 | } | ||
| 7009 | |||
| 7010 | $listRef = $profObj->{noSocialPatternList}; | ||
| 7011 | if (defined $listRef) { | ||
| 7012 | |||
| 7013 | push (@combList, @$listRef); | ||
| 7014 | } | ||
| 7015 | |||
| 7016 | $listRef = $profObj->{noCustomDivertPatternList}; | ||
| 7017 | if (defined $listRef) { | ||
| 7018 | |||
| 7019 | push (@combList, @$listRef); | ||
| 7020 | } | ||
| 7021 | |||
| 7022 | foreach my $pattern (@combList) { | ||
| 7023 | |||
| 7024 | if (! exists $checkHash{$pattern}) { | ||
| 7025 | |||
| 7026 | push (@newList2, $pattern); | ||
| 7027 | $checkHash{$pattern} = undef; | ||
| 7028 | } | ||
| 7029 | } | ||
| 7030 | |||
| 7031 | # While we're at it, let's sort the list | ||
| 7032 | @newList2 = sort {lc($a) cmp lc($b)} (@newList2); | ||
| 7033 | $profObj->ivPoke('noChannelList', @newList2); | ||
| 7034 | |||
| 7035 | # Delete the old IVs | ||
| 7036 | delete $profObj->{tellPatternList}; | ||
| 7037 | delete $profObj->{noTellPatternList}; | ||
| 7038 | delete $profObj->{socialPatternList}; | ||
| 7039 | delete $profObj->{noSocialPatternList}; | ||
| 7040 | delete $profObj->{customDivertPatternList}; | ||
| 7041 | delete $profObj->{noCustomDivertPatternList}; | ||
| 7042 | } | ||
| 7043 | } | ||
| 7044 | } | ||
| 7045 | |||
| 7046 | if ($version < 1_001_133) { | ||
| 7047 | |||
| 7048 | # Update world profiles with to write a new logfile | ||
| 7049 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 7050 | |||
| 7051 | if (! $profObj->ivExists('logPrefHash', 'channels')) { | ||
| 7052 | |||
| 7053 | $profObj->ivAdd( | ||
| 7054 | 'logPrefHash', | ||
| 7055 | 'channels', | ||
| 7056 | # Use the same setting as for the Divert task | ||
| 7057 | $profObj->ivShow('logPrefHash', 'divert'), | ||
| 7058 | ); | ||
| 7059 | } | ||
| 7060 | } | ||
| 7061 | } | ||
| 7062 | |||
| 7063 | if ($version < 1_001_184 && $self->session) { | ||
| 7064 | |||
| 7065 | # This version adds an (optional) attribute to triggers, aliases, macros and hooks | ||
| 7066 | # (but not timers) | ||
| 7067 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 7068 | |||
| 7069 | if ( | ||
| 7070 | $cage->{cageType} eq 'trigger' | ||
| 7071 | || $cage->{cageType} eq 'alias' | ||
| 7072 | || $cage->{cageType} eq 'macro' | ||
| 7073 | || $cage->{cageType} eq 'hook' | ||
| 7074 | ) { | ||
| 7075 | foreach my $interfaceObj ($cage->ivValues('interfaceHash')) { | ||
| 7076 | |||
| 7077 | $interfaceObj->ivAdd('attribHash', 'cooldown', 0); | ||
| 7078 | } | ||
| 7079 | } | ||
| 7080 | } | ||
| 7081 | } | ||
| 7082 | |||
| 7083 | if ($version < 1_001_191) { | ||
| 7084 | |||
| 7085 | # This version renames a world profile IV and a component object IV | ||
| 7086 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 7087 | |||
| 7088 | my (@oldList, @newList); | ||
| 7089 | |||
| 7090 | if (! exists $profObj->{groupPatternList}) { | ||
| 7091 | |||
| 7092 | $profObj->{groupPatternList} = $profObj->{singleBackRefPatternList}; | ||
| 7093 | delete $profObj->{singleBackRefPatternList}; | ||
| 7094 | |||
| 7095 | foreach my $componentObj ($profObj->ivValues('componentHash')) { | ||
| 7096 | |||
| 7097 | if (! exists $componentObj->{usePatternGroups}) { | ||
| 7098 | |||
| 7099 | $componentObj->{usePatternGroups} | ||
| 7100 | = $componentObj->{usePatternBackRefs}; | ||
| 7101 | delete $componentObj->{usePatternBackRefs}; | ||
| 7102 | } | ||
| 7103 | } | ||
| 7104 | |||
| 7105 | # ->loginSpecialList is in groups of 3. It was previously necessary to | ||
| 7106 | # surround the third item in double quotes, if it contained a group | ||
| 7107 | # substring variable like $1, but that's no longer necessary, so remove | ||
| 7108 | # the quotes | ||
| 7109 | @oldList = $profObj->loginSpecialList; | ||
| 7110 | while (@oldList) { | ||
| 7111 | |||
| 7112 | my ($item, $item2, $item3); | ||
| 7113 | |||
| 7114 | $item = shift @oldList; | ||
| 7115 | $item2 = shift @oldList; | ||
| 7116 | $item3 = shift @oldList; | ||
| 7117 | |||
| 7118 | $item3 =~ s/^\"(.*)\"$/$1/; | ||
| 7119 | |||
| 7120 | push (@newList, $item, $item2, $item3); | ||
| 7121 | |||
| 7122 | } | ||
| 7123 | |||
| 7124 | $profObj->ivPoke('loginSpecialList', @newList); | ||
| 7125 | } | ||
| 7126 | } | ||
| 7127 | } | ||
| 7128 | |||
| 7129 | if ($version < 1_001_258) { | ||
| 7130 | |||
| 7131 | # Update world profiles to a list in groups of 1 with a list in groups of 2 | ||
| 7132 | my $profObj = $axmud::CLIENT->ivShow('worldProfHash', $self->name); | ||
| 7133 | if ($profObj) { | ||
| 7134 | |||
| 7135 | my @newList; | ||
| 7136 | |||
| 7137 | foreach my $pattern ($profObj->transientExitPatternList) { | ||
| 7138 | |||
| 7139 | push (@newList, $pattern, undef); | ||
| 7140 | } | ||
| 7141 | |||
| 7142 | $profObj->ivPoke('transientExitPatternList', @newList); | ||
| 7143 | } | ||
| 7144 | } | ||
| 7145 | |||
| 7146 | if ($version < 1_001_262 && $self->session) { | ||
| 7147 | |||
| 7148 | # Update character profiles with new IVs | ||
| 7149 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 7150 | |||
| 7151 | if ($profObj->{category} eq 'char' && ! exists $profObj->{qpCurrent}) { | ||
| 7152 | |||
| 7153 | $profObj->{qpCurrent} = undef; | ||
| 7154 | $profObj->ivPoke('qpCurrent', 0); | ||
| 7155 | $profObj->{qpNextLevel} = undef; | ||
| 7156 | $profObj->ivPoke('qpNextLevel', 0); | ||
| 7157 | $profObj->{qpTotal} = undef; | ||
| 7158 | $profObj->ivPoke('qpTotal', 0); | ||
| 7159 | |||
| 7160 | $profObj->{opCurrent} = undef; | ||
| 7161 | $profObj->ivPoke('opCurrent', 0); | ||
| 7162 | $profObj->{opNextLevel} = undef; | ||
| 7163 | $profObj->ivPoke('opNextLevel', 0); | ||
| 7164 | $profObj->{opTotal} = undef; | ||
| 7165 | $profObj->ivPoke('opTotal', 0); | ||
| 7166 | } | ||
| 7167 | } | ||
| 7168 | } | ||
| 7169 | |||
| 7170 | if ($version < 1_001_263 && $self->session) { | ||
| 7171 | |||
| 7172 | # Modify some IVs in world profiles | ||
| 7173 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 7174 | |||
| 7175 | my ( | ||
| 7176 | $hashRef, $listRef, | ||
| 7177 | %newHash, | ||
| 7178 | ); | ||
| 7179 | |||
| 7180 | if (exists $profObj->{constLocalWimpyMax}) { | ||
| 7181 | |||
| 7182 | # (These are replaced by new character profile IVs) | ||
| 7183 | delete $profObj->{constLocalWimpyMax}; | ||
| 7184 | delete $profObj->{remoteWimpyMax}; | ||
| 7185 | |||
| 7186 | # (->customStatusVarHash is replaced by new ->msdpStatusVarHash, with a | ||
| 7187 | # subset of its key-value pairs, with the keys/value reversed) | ||
| 7188 | $hashRef = $profObj->{customStatusVarHash}; | ||
| 7189 | delete $profObj->{customStatusVarHash}; | ||
| 7190 | |||
| 7191 | foreach my $key (keys %$hashRef) { | ||
| 7192 | |||
| 7193 | my $value = $$hashRef{$key}; | ||
| 7194 | |||
| 7195 | # A few pre-configured worlds were using the wrong format, so ignore the | ||
| 7196 | # key-value pairs where the value is 0 | ||
| 7197 | if (defined $value && $value ne '0') { | ||
| 7198 | |||
| 7199 | $newHash{$value} = $key; | ||
| 7200 | } | ||
| 7201 | } | ||
| 7202 | |||
| 7203 | $profObj->{msdpStatusVarHash} = {}; | ||
| 7204 | $profObj->ivPoke('msdpStatusVarHash', %newHash); | ||
| 7205 | |||
| 7206 | # (->statusFormatList is just a renamed IV) | ||
| 7207 | $listRef = $profObj->{displayFormatList}; | ||
| 7208 | |||
| 7209 | # While we're at it, convert old custom variables from #var_name# to new | ||
| 7210 | # @var_name@ format | ||
| 7211 | foreach my $line (@$listRef) { | ||
| 7212 | |||
| 7213 | $line =~ s/\#([\w\_]+)\#/\@$1\@/g; | ||
| 7214 | |||
| 7215 | # In addition, some old variables have been renamed | ||
| 7216 | $line =~ s/fight_count/fight_string/; | ||
| 7217 | $line =~ s/interact_count/interact_string/; | ||
| 7218 | $line =~ s/interaction_count/interact_string/; | ||
| 7219 | $line =~ s/coward_count/coward_string/; | ||
| 7220 | $line =~ s/temp_fight_count/temp_fight_string/; | ||
| 7221 | $line =~ s/temp_interact_count/temp_interact_string/; | ||
| 7222 | $line =~ s/temp_interaction_count/temp_interact_string/; | ||
| 7223 | $line =~ s/temp_coward_count/temp_coward_string/; | ||
| 7224 | $line =~ s/quest_points/qp_current/; | ||
| 7225 | } | ||
| 7226 | |||
| 7227 | $profObj->{statusFormatList} = []; | ||
| 7228 | $profObj->ivPoke('statusFormatList', @$listRef); | ||
| 7229 | delete $profObj->{displayFormatList}; | ||
| 7230 | } | ||
| 7231 | } | ||
| 7232 | |||
| 7233 | # Update character profiles with new IVs | ||
| 7234 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 7235 | |||
| 7236 | if ($profObj->{category} eq 'char' && ! exists $profObj->{healthPoints}) { | ||
| 7237 | |||
| 7238 | # (This IV subsequently renamed and/or removed) | ||
| 7239 | # $profObj->{healthPoints} = undef; | ||
| 7240 | # $profObj->ivPoke('healthPoints', 0); | ||
| 7241 | $profObj->{healthPoints} = 0; | ||
| 7242 | # $profObj->{healthPointsMax} = undef; | ||
| 7243 | # $profObj->ivPoke('healthPointsMax', 0); | ||
| 7244 | $profObj->{healthPointsMax} = 0; | ||
| 7245 | |||
| 7246 | # $profObj->{magicPoints} = undef; | ||
| 7247 | # $profObj->ivPoke('magicPoints', 0); | ||
| 7248 | $profObj->{magicPoints} = 0; | ||
| 7249 | # $profObj->{magicPointsMax} = undef; | ||
| 7250 | # $profObj->ivPoke('magicPointsMax', 0); | ||
| 7251 | $profObj->{magicPointsMax} = 0; | ||
| 7252 | |||
| 7253 | # $profObj->{energyPoints} = undef; | ||
| 7254 | # $profObj->ivPoke('energyPoints', 0); | ||
| 7255 | $profObj->{energyPoints} = 0; | ||
| 7256 | # $profObj->{energyPointsMax} = undef; | ||
| 7257 | # $profObj->ivPoke('energyPointsMax', 0); | ||
| 7258 | $profObj->{energyPointsMax} = 0; | ||
| 7259 | |||
| 7260 | # $profObj->{guildPoints} = undef; | ||
| 7261 | # $profObj->ivPoke('guildPoints', 0); | ||
| 7262 | $profObj->{guildPoints} = 0; | ||
| 7263 | # $profObj->{guildPointsMax} = undef; | ||
| 7264 | # $profObj->ivPoke('guildPointsMax', 0); | ||
| 7265 | $profObj->{guildPointsMax} = 0; | ||
| 7266 | |||
| 7267 | # $profObj->{socialPoints} = undef; | ||
| 7268 | # $profObj->ivPoke('socialPoints', 0); | ||
| 7269 | $profObj->{socialPoints} = 0; | ||
| 7270 | # $profObj->{socialPointsMax} = undef; | ||
| 7271 | # $profObj->ivPoke('socialPointsMax', 0); | ||
| 7272 | $profObj->{socialPointsMax} = 0; | ||
| 7273 | |||
| 7274 | $profObj->{remoteWimpyMax} = undef; | ||
| 7275 | $profObj->ivPoke('remoteWimpyMax', 100); | ||
| 7276 | $profObj->{constLocalWimpyMax} = 199; | ||
| 7277 | } | ||
| 7278 | } | ||
| 7279 | } | ||
| 7280 | |||
| 7281 | if ($version < 1_001_286 && $self->session) { | ||
| 7282 | |||
| 7283 | my %hash = ( | ||
| 7284 | 'kp_up' => 'up', | ||
| 7285 | 'kp_down' => 'down', | ||
| 7286 | 'kp_left' => 'left', | ||
| 7287 | 'kp_right' => 'right', | ||
| 7288 | 'kp_page_up' => 'page_up', | ||
| 7289 | 'kp_page_down' => 'page_down', | ||
| 7290 | 'kp_home' => 'home', | ||
| 7291 | 'kp_end' => 'end', | ||
| 7292 | 'kp_insert' => 'insert', | ||
| 7293 | 'kp_delete' => 'delete', | ||
| 7294 | ); | ||
| 7295 | |||
| 7296 | # This version removes some Axmud standard keycodes | ||
| 7297 | # Check macros in each macro cage, and convert any removed keycodes to their | ||
| 7298 | # replacements | ||
| 7299 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 7300 | |||
| 7301 | if ($cage->{cageType} eq 'macro') { | ||
| 7302 | |||
| 7303 | foreach my $macroObj ($cage->ivValues('interfaceHash')) { | ||
| 7304 | |||
| 7305 | # The macro stimulus is a keycode/keycode string | ||
| 7306 | my $stimulus = $macroObj->stimulus; | ||
| 7307 | |||
| 7308 | foreach my $regex (keys %hash) { | ||
| 7309 | |||
| 7310 | my $subst = $hash{$regex}; | ||
| 7311 | |||
| 7312 | $stimulus =~ s/$regex/$subst/; | ||
| 7313 | } | ||
| 7314 | |||
| 7315 | $macroObj->ivPoke('stimulus', $stimulus); | ||
| 7316 | } | ||
| 7317 | } | ||
| 7318 | } | ||
| 7319 | } | ||
| 7320 | |||
| 7321 | if ($version < 1_001_298) { | ||
| 7322 | |||
| 7323 | # Update world profiles with a new IV | ||
| 7324 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 7325 | |||
| 7326 | if (! exists $profObj->{mxpStatusVarHash}) { | ||
| 7327 | |||
| 7328 | $profObj->{mxpStatusVarHash} = {}; | ||
| 7329 | $profObj->ivEmpty('mxpStatusVarHash'); | ||
| 7330 | } | ||
| 7331 | } | ||
| 7332 | } | ||
| 7333 | |||
| 7334 | if ($version < 1_001_308) { | ||
| 7335 | |||
| 7336 | # Update world profiles by deleting an IV | ||
| 7337 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 7338 | |||
| 7339 | delete $profObj->{'strictPromptsMode'}; | ||
| 7340 | } | ||
| 7341 | } | ||
| 7342 | |||
| 7343 | if ($version < 1_001_365) { | ||
| 7344 | |||
| 7345 | # Update world profiles with a new IV | ||
| 7346 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 7347 | |||
| 7348 | if (! exists $profObj->{exitStateTagHash}) { | ||
| 7349 | |||
| 7350 | $profObj->{exitStateTagHash} = {}; | ||
| 7351 | $profObj->ivEmpty('exitStateTagHash'); | ||
| 7352 | } | ||
| 7353 | } | ||
| 7354 | } | ||
| 7355 | |||
| 7356 | if ($version < 1_001_374) { | ||
| 7357 | |||
| 7358 | # Update world profiles with a new IV | ||
| 7359 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 7360 | |||
| 7361 | if (! exists $profObj->{duplicateReplaceString}) { | ||
| 7362 | |||
| 7363 | $profObj->{duplicateReplaceString} = undef; | ||
| 7364 | $profObj->ivUndef('duplicateReplaceString'); | ||
| 7365 | } | ||
| 7366 | } | ||
| 7367 | } | ||
| 7368 | |||
| 7369 | if ($version < 1_001_382 && $self->session) { | ||
| 7370 | |||
| 7371 | # This version adds a new trigger attribute. Update every trigger cage | ||
| 7372 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 7373 | |||
| 7374 | if ($cage->{cageType} eq 'trigger') { | ||
| 7375 | |||
| 7376 | foreach my $trigObj ($cage->ivValues('interfaceHash')) { | ||
| 7377 | |||
| 7378 | $trigObj->ivAdd('attribHash', 'ignore_response', FALSE); | ||
| 7379 | } | ||
| 7380 | } | ||
| 7381 | } | ||
| 7382 | } | ||
| 7383 | |||
| 7384 | if ($version < 1_002_056) { | ||
| 7385 | |||
| 7386 | # Update world profiles with new IVs | ||
| 7387 | foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 7388 | |||
| 7389 | if (! exists $profObj->{mxpRoomTagStart}) { | ||
| 7390 | |||
| 7391 | $profObj->{mxpRoomTagStart} = undef; | ||
| 7392 | $profObj->ivUndef('mxpRoomTagStart'); | ||
| 7393 | $profObj->{mxpRoomTagStop} = undef; | ||
| 7394 | $profObj->ivUndef('mxpRoomTagStop'); | ||
| 7395 | } | ||
| 7396 | } | ||
| 7397 | } | ||
| 7398 | |||
| 7399 | if ($version < 1_002_109 && $self->session) { | ||
| 7400 | |||
| 7401 | # This version corrects a misspelled standard hook event | ||
| 7402 | foreach my $cage ($self->session->ivValues('cageHash')) { | ||
| 7403 | |||
| 7404 | if ($cage->{cageType} eq 'hook') { | ||
| 7405 | |||
| 7406 | foreach my $interfaceObj ($cage->ivValues('interfaceHash')) { | ||
| 7407 | |||
| 7408 | if ($interfaceObj->stimulus eq 'change_vivible') { | ||
| 7409 | |||
| 7410 | $interfaceObj->ivPoke('stimulus', 'change_visible'); | ||
| 7411 | } | ||
| 7412 | } | ||
| 7413 | } | ||
| 7414 | } | ||
| 7415 | } | ||
| 7416 | |||
| 7417 | if ($version < 1_003_141 && $self->session) { | ||
| 7418 | |||
| 7419 | # Update character profiles with a new IV | ||
| 7420 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 7421 | |||
| 7422 | if ($profObj->{category} eq 'char' && ! exists $profObj->{nickname}) { | ||
| 7423 | |||
| 7424 | $profObj->{nickname} = undef; | ||
| 7425 | $profObj->ivPoke('nickname', $profObj->name); | ||
| 7426 | } | ||
| 7427 | } | ||
| 7428 | } | ||
| 7429 | |||
| 7430 | ### worldmodel ########################################################################### | ||
| 7431 | |||
| 7432 | } elsif ($self->fileType eq 'worldmodel') { | ||
| 7433 | |||
| 7434 | # (Import the world model, for convenience) | ||
| 7435 | $wmObj = $self->session->worldModelObj; | ||
| 7436 | |||
| 7437 | # (Changes that must be made before any other changes) | ||
| 7438 | |||
| 7439 | if ($version < 1_000_871) { | ||
| 7440 | |||
| 7441 | # This version renames a number of IVs | ||
| 7442 | if (! exists $wmObj->{modelHash}) { | ||
| 7443 | |||
| 7444 | $wmObj->{modelHash} = $wmObj->{model}; | ||
| 7445 | $wmObj->{regionModelHash} = $wmObj->{regionModel}; | ||
| 7446 | $wmObj->{roomModelHash} = $wmObj->{roomModel}; | ||
| 7447 | $wmObj->{weaponModelHash} = $wmObj->{weaponModel}; | ||
| 7448 | $wmObj->{armourModelHash} = $wmObj->{armourModel}; | ||
| 7449 | $wmObj->{garmentModelHash} = $wmObj->{garmentModel}; | ||
| 7450 | $wmObj->{charModelHash} = $wmObj->{charModel}; | ||
| 7451 | $wmObj->{minionModelHash} = $wmObj->{minionModel}; | ||
| 7452 | $wmObj->{sentientModelHash} = $wmObj->{sentientModel}; | ||
| 7453 | $wmObj->{creatureModelHash} = $wmObj->{creatureModel}; | ||
| 7454 | $wmObj->{portableModelHash} = $wmObj->{portableModel}; | ||
| 7455 | $wmObj->{decorationModelHash} = $wmObj->{decorationModel}; | ||
| 7456 | $wmObj->{customModelHash} = $wmObj->{customModel}; | ||
| 7457 | $wmObj->{exitModelHash} = $wmObj->{exitModel}; | ||
| 7458 | |||
| 7459 | delete $wmObj->{model}; | ||
| 7460 | delete $wmObj->{regionModel}; | ||
| 7461 | delete $wmObj->{roomModel}; | ||
| 7462 | delete $wmObj->{weaponModel}; | ||
| 7463 | delete $wmObj->{armourModel}; | ||
| 7464 | delete $wmObj->{garmentModel}; | ||
| 7465 | delete $wmObj->{charModel}; | ||
| 7466 | delete $wmObj->{minionModel}; | ||
| 7467 | delete $wmObj->{sentientModel}; | ||
| 7468 | delete $wmObj->{creatureModel}; | ||
| 7469 | delete $wmObj->{portableModel}; | ||
| 7470 | delete $wmObj->{decorationModel}; | ||
| 7471 | delete $wmObj->{customModel}; | ||
| 7472 | delete $wmObj->{exitModel}; | ||
| 7473 | } | ||
| 7474 | } | ||
| 7475 | |||
| 7476 | if ($version < 1_001_289) { | ||
| 7477 | |||
| 7478 | # This version adds new IVs to the world model | ||
| 7479 | if (! exists $wmObj->{adjacentMode}) { | ||
| 7480 | |||
| 7481 | $wmObj->{adjacentMode} = undef; | ||
| 7482 | $wmObj->ivPoke('adjacentMode', 'near'); | ||
| 7483 | $wmObj->{adjacentCount} = undef; | ||
| 7484 | $wmObj->ivPoke('adjacentCount', 1); | ||
| 7485 | } | ||
| 7486 | } | ||
| 7487 | |||
| 7488 | # (All remaining changes, in order) | ||
| 7489 | |||
| 7490 | if ($version < 1_000_006) { | ||
| 7491 | |||
| 7492 | # # Update the room flag list | ||
| 7493 | # $wmObj->updateRoomFlags($self->session); | ||
| 7494 | |||
| 7495 | # Add the new border colour IV | ||
| 7496 | $wmObj->{defaultGhostSelectBorderColour} = undef; | ||
| 7497 | $wmObj->ivPoke('defaultGhostSelectBorderColour', '#BB6E57'); | ||
| 7498 | $wmObj->{ghostSelectBorderColour} = undef; | ||
| 7499 | $wmObj->ivPoke('ghostSelectBorderColour', '#BB6E57'); | ||
| 7500 | |||
| 7501 | # Add the modified border colours (unless the user has already modified them) | ||
| 7502 | $wmObj->ivPoke('defaultLostBorderColour', '#21D221'); | ||
| 7503 | if ($wmObj->{lostBorderColour} eq '#00FF00') { | ||
| 7504 | |||
| 7505 | $wmObj->ivPoke('lostBorderColour', '#00FF00'); | ||
| 7506 | } | ||
| 7507 | } | ||
| 7508 | |||
| 7509 | if ($version < 1_000_009) { | ||
| 7510 | |||
| 7511 | # This version introduces exit tags for exits drawn as up/down. Any exits in these | ||
| 7512 | # directions, whose exit tags have not been modified by the user, should have | ||
| 7513 | # their tags updated to include the words 'up' and 'down') | ||
| 7514 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7515 | |||
| 7516 | my ($destRoomObj, $destRegionObj, $oldTag, $newTag); | ||
| 7517 | |||
| 7518 | if ($exitObj->{exitTag} && $exitObj->{mapDir}) { | ||
| 7519 | |||
| 7520 | $destRoomObj = $wmObj->ivShow('modelHash', $exitObj->{destRoom}); | ||
| 7521 | $destRegionObj = $wmObj->ivShow('modelHash', $destRoomObj->{parent}); | ||
| 7522 | $oldTag = 'to ' . $destRegionObj->{name}; | ||
| 7523 | |||
| 7524 | if ($exitObj->{exitTag} eq $oldTag) { | ||
| 7525 | |||
| 7526 | # Tag hasn't been modified by the user, so we can update it | ||
| 7527 | if ($exitObj->{mapDir} eq 'up' || $exitObj->{mapDir} eq 'down') { | ||
| 7528 | $newTag = $exitObj->{mapDir} . ' to ' . $destRegionObj->{name}; | ||
| 7529 | } else { | ||
| 7530 | $newTag = $oldTag; | ||
| 7531 | } | ||
| 7532 | |||
| 7533 | if ($exitObj->{oneWayFlag}) { | ||
| 7534 | |||
| 7535 | $newTag .= ' (>)'; | ||
| 7536 | } | ||
| 7537 | |||
| 7538 | $exitObj->ivPoke('exitTag', $newTag); | ||
| 7539 | } | ||
| 7540 | } | ||
| 7541 | } | ||
| 7542 | } | ||
| 7543 | |||
| 7544 | if ($version < 1_000_016) { | ||
| 7545 | |||
| 7546 | if (! exists $wmObj->{pathFindStepLimit}) { | ||
| 7547 | |||
| 7548 | # Add the new IV | ||
| 7549 | $wmObj->{pathFindStepLimit} = undef; | ||
| 7550 | $wmObj->ivPoke('pathFindStepLimit', 200); | ||
| 7551 | } | ||
| 7552 | } | ||
| 7553 | |||
| 7554 | # if ($version < 1_000_018) { | ||
| 7555 | # | ||
| 7556 | # # Update the room flag list | ||
| 7557 | # $wmObj->updateRoomFlags($self->session); | ||
| 7558 | # } | ||
| 7559 | |||
| 7560 | if ($version < 1_000_041) { | ||
| 7561 | |||
| 7562 | # This version fixes an error in GA::Obj::WorldModel->connectRegionBrokenExit, in | ||
| 7563 | # which exits that are connected to rooms in different regions as uncertain or | ||
| 7564 | # one-way exits are not added to the parent regionmap's list of region exits | ||
| 7565 | # First, check every region exit. If it can't be found in the parent regionmap's | ||
| 7566 | # list of region exits, add it | ||
| 7567 | |||
| 7568 | # (Only display a warning, if the model contains exits) | ||
| 7569 | if ($wmObj->{exitModelHash}) { | ||
| 7570 | |||
| 7571 | $self->writeText('Applying essential world model update. Please be patient...'); | ||
| 7572 | $axmud::CLIENT->desktopObj->updateWidgets( | ||
| 7573 | $self->_objClass . '->updateExtractedData', | ||
| 7574 | ); | ||
| 7575 | } | ||
| 7576 | |||
| 7577 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7578 | |||
| 7579 | my ($roomObj, $regionObj, $regionmapObj); | ||
| 7580 | |||
| 7581 | if ($exitObj->{regionFlag}) { | ||
| 7582 | |||
| 7583 | $roomObj = $wmObj->ivShow('modelHash', $exitObj->{parent}); | ||
| 7584 | $regionObj = $wmObj->ivShow('modelHash', $roomObj->{parent}); | ||
| 7585 | $regionmapObj = $wmObj->ivShow('regionmapHash', $regionObj->{name}); | ||
| 7586 | |||
| 7587 | if (! $regionmapObj->ivExists('regionExitHash', $exitObj->{number})) { | ||
| 7588 | |||
| 7589 | $wmObj->ivAdd( | ||
| 7590 | 'updateBoundaryHash', | ||
| 7591 | $exitObj->{number}, | ||
| 7592 | $regionObj->{name}, | ||
| 7593 | ); | ||
| 7594 | } | ||
| 7595 | } | ||
| 7596 | } | ||
| 7597 | |||
| 7598 | # Second, tell the world model to update its boundaries (which calls | ||
| 7599 | # $regionmapObj->storeRegionExit for each new region exit) | ||
| 7600 | $wmObj->updateRegionPaths($self->session); | ||
| 7601 | |||
| 7602 | # Third, recalculate all region paths | ||
| 7603 | foreach my $regionmapObj ( | ||
| 7604 | sort {lc($a->{name}) cmp lc($b->{name})} ($wmObj->ivValues('regionmapHash')) | ||
| 7605 | ) { | ||
| 7606 | $wmObj->recalculateRegionPaths( | ||
| 7607 | $self->session, | ||
| 7608 | $regionmapObj, | ||
| 7609 | ); | ||
| 7610 | } | ||
| 7611 | } | ||
| 7612 | |||
| 7613 | if ($version < 1_000_053) { | ||
| 7614 | |||
| 7615 | # Add the new IV to all exit objects | ||
| 7616 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7617 | |||
| 7618 | if (! exists $exitObj->{notSuperFlag}) { | ||
| 7619 | |||
| 7620 | $exitObj->{notSuperFlag} = undef; | ||
| 7621 | $exitObj->ivPoke('notSuperFlag', FALSE); | ||
| 7622 | } | ||
| 7623 | } | ||
| 7624 | } | ||
| 7625 | |||
| 7626 | if ($version < 1_000_094) { | ||
| 7627 | |||
| 7628 | # Add the new IV to all model objects | ||
| 7629 | foreach my $obj ($wmObj->ivValues('modelHash')) { | ||
| 7630 | |||
| 7631 | if (! exists $obj->{targetRoomNum}) { | ||
| 7632 | |||
| 7633 | $obj->{targetRoomNum} = undef; | ||
| 7634 | $obj->ivUndef('targetRoomNum'); | ||
| 7635 | } | ||
| 7636 | } | ||
| 7637 | } | ||
| 7638 | |||
| 7639 | if ($version < 1_000_108) { | ||
| 7640 | |||
| 7641 | # This version changes the initial position of room tag/room guild text on the | ||
| 7642 | # Automapper window | ||
| 7643 | # Check existing world model rooms; if any of them have room tags/room guilds, ask | ||
| 7644 | # the user if they should be updated | ||
| 7645 | my ($tagAdjust, $guildAdjust, $matchFlag, $response); | ||
| 7646 | |||
| 7647 | $tagAdjust = int ( # Default value - 5 | ||
| 7648 | ( | ||
| 7649 | $wmObj->{defaultBlockHeightPixels} | ||
| 7650 | - $wmObj->{defaultRoomHeightPixels} | ||
| 7651 | ) / 4 | ||
| 7652 | ); | ||
| 7653 | |||
| 7654 | $guildAdjust = int ( # Default value - 3 | ||
| 7655 | ( | ||
| 7656 | $wmObj->{defaultBlockHeightPixels} | ||
| 7657 | - $wmObj->{defaultRoomHeightPixels} | ||
| 7658 | ) / 6 | ||
| 7659 | ); | ||
| 7660 | |||
| 7661 | OUTER: foreach my $obj ($wmObj->ivValues('modelHash')) { | ||
| 7662 | |||
| 7663 | if ($obj->{category} eq 'room' && ($obj->{roomTag} || $obj->{roomGuild})) { | ||
| 7664 | |||
| 7665 | $matchFlag = TRUE; | ||
| 7666 | last OUTER; | ||
| 7667 | } | ||
| 7668 | } | ||
| 7669 | |||
| 7670 | if ($matchFlag && ($tagAdjust || $guildAdjust)) { | ||
| 7671 | |||
| 7672 | $response = $self->session->mainWin->showMsgDialogue( | ||
| 7673 | 'Adjust text position', | ||
| 7674 | 'question', | ||
| 7675 | 'Room tags and room guilds are now drawn in the Automapper window at a' | ||
| 7676 | . ' slightly different position. Do you want to adjust your existing' | ||
| 7677 | . ' room tags/guilds, so that they appear in the same position as before?', | ||
| 7678 | 'yes-no', | ||
| 7679 | ); | ||
| 7680 | |||
| 7681 | if (defined $response && $response eq 'yes') { | ||
| 7682 | |||
| 7683 | OUTER: foreach my $obj ($wmObj->ivValues('modelHash')) { | ||
| 7684 | |||
| 7685 | if ($obj->{category} eq 'room') { | ||
| 7686 | |||
| 7687 | if ($obj->{roomTag}) { | ||
| 7688 | |||
| 7689 | $obj->ivPlus('roomTagYOffset', $tagAdjust); | ||
| 7690 | } | ||
| 7691 | |||
| 7692 | if ($obj->{roomGuild}) { | ||
| 7693 | |||
| 7694 | $obj->ivMinus('roomGuildYOffset', $tagAdjust); | ||
| 7695 | } | ||
| 7696 | } | ||
| 7697 | } | ||
| 7698 | } | ||
| 7699 | } | ||
| 7700 | } | ||
| 7701 | |||
| 7702 | if ($version < 1_000_110) { | ||
| 7703 | |||
| 7704 | # This version corrects an error which messed up exits with bends which had been | ||
| 7705 | # dragged by the user. To correct the problem, all bends must be removed; it's up | ||
| 7706 | # to the user to reposition them, now that it's possible | ||
| 7707 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7708 | |||
| 7709 | my $listRef = $exitObj->{bendOffsetList}; | ||
| 7710 | if (@$listRef) { | ||
| 7711 | |||
| 7712 | $exitObj->ivEmpty('bendOffsetList'); | ||
| 7713 | } | ||
| 7714 | } | ||
| 7715 | } | ||
| 7716 | |||
| 7717 | if ($version < 1_000_114) { | ||
| 7718 | |||
| 7719 | # This version corrects an error in which an exit is sometimes twinned with an exit | ||
| 7720 | # that is attached to a shadow exit, rather than being twinned to the shadow exit | ||
| 7721 | # itself | ||
| 7722 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7723 | |||
| 7724 | my ($twinExitObj, $shadowExitObj, $roomObj, $otherRoomObj); | ||
| 7725 | |||
| 7726 | if ($exitObj->{twinExit} && $exitObj->{shadowExit}) { | ||
| 7727 | |||
| 7728 | $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{twinExit}); | ||
| 7729 | $shadowExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{shadowExit}); | ||
| 7730 | $roomObj = $wmObj->ivShow('modelHash', $exitObj->{parent}); | ||
| 7731 | $otherRoomObj = $wmObj->ivShow('modelHash', $twinExitObj->{parent}); | ||
| 7732 | |||
| 7733 | $wmObj->abandonTwinExit(FALSE, $exitObj, $twinExitObj); | ||
| 7734 | |||
| 7735 | # If both the exits had shadow exits, we are now dealing with a set of four | ||
| 7736 | # exits, and the call to ->abandonTwinExit above will leave one of the | ||
| 7737 | # four unabandoned | ||
| 7738 | if ($shadowExitObj->{twinExit}) { | ||
| 7739 | |||
| 7740 | $wmObj->abandonTwinExit(FALSE, $shadowExitObj); | ||
| 7741 | } | ||
| 7742 | |||
| 7743 | # Now we can reconnect the rooms, avoiding twinning exits with shadow exits | ||
| 7744 | $wmObj->connectRooms( | ||
| 7745 | $self->session, | ||
| 7746 | FALSE, | ||
| 7747 | $roomObj, | ||
| 7748 | $otherRoomObj, | ||
| 7749 | $shadowExitObj->{dir}, | ||
| 7750 | ); | ||
| 7751 | } | ||
| 7752 | } | ||
| 7753 | } | ||
| 7754 | |||
| 7755 | if ($version < 1_000_127) { | ||
| 7756 | |||
| 7757 | # This version corrects an error in which the destination room is not informed when | ||
| 7758 | # 1-way and uncertain exits are converted to incomplete exits | ||
| 7759 | # Need to check every room's hash of incoming 1-way/uncertain exits, to make sure | ||
| 7760 | # the exits still lead to their supposed destinations | ||
| 7761 | foreach my $roomObj ($wmObj->ivValues('roomModelHash')) { | ||
| 7762 | |||
| 7763 | my $hashRef = $roomObj->{uncertainExitHash}; | ||
| 7764 | if (%$hashRef) { | ||
| 7765 | |||
| 7766 | my %uncertainExitHash = %$hashRef; | ||
| 7767 | |||
| 7768 | foreach my $exitNum (keys %uncertainExitHash) { | ||
| 7769 | |||
| 7770 | my $exitObj = $wmObj->ivShow('exitModelHash', $exitNum); | ||
| 7771 | |||
| 7772 | if ( | ||
| 7773 | # Exit doesn't exit | ||
| 7774 | ! $exitObj | ||
| 7775 | # Exit doesn't lead to $roomObj | ||
| 7776 | || ! $exitObj->{destRoom} | ||
| 7777 | || $exitObj->{destRoom} != $roomObj->{number} | ||
| 7778 | # Exit is no longer an uncertain exit | ||
| 7779 | || ( | ||
| 7780 | $exitObj->{twinExit} | ||
| 7781 | || $exitObj->{retraceFlag} | ||
| 7782 | || $exitObj->{oneWayFlag} | ||
| 7783 | || $exitObj->{randomType} | ||
| 7784 | ) | ||
| 7785 | ) { | ||
| 7786 | delete $uncertainExitHash{$exitNum}; | ||
| 7787 | } | ||
| 7788 | } | ||
| 7789 | |||
| 7790 | $roomObj->ivPoke('uncertainExitHash', %uncertainExitHash); | ||
| 7791 | } | ||
| 7792 | |||
| 7793 | $hashRef = $roomObj->{oneWayExitHash}; | ||
| 7794 | if (%$hashRef) { | ||
| 7795 | |||
| 7796 | my %oneWayExitHash = %$hashRef; | ||
| 7797 | |||
| 7798 | foreach my $exitNum (keys %oneWayExitHash) { | ||
| 7799 | |||
| 7800 | my $exitObj = $wmObj->ivShow('exitModelHash', $exitNum); | ||
| 7801 | |||
| 7802 | if ( | ||
| 7803 | # Exit doesn't exit | ||
| 7804 | ! $exitObj | ||
| 7805 | # Exit doesn't lead to $roomObj | ||
| 7806 | || ! $exitObj->{destRoom} | ||
| 7807 | || $exitObj->{destRoom} != $roomObj->{number} | ||
| 7808 | # Exit is no longer a one -way exit | ||
| 7809 | || ! $exitObj->{oneWayFlag} | ||
| 7810 | ) { | ||
| 7811 | delete $oneWayExitHash{$exitNum}; | ||
| 7812 | } | ||
| 7813 | } | ||
| 7814 | |||
| 7815 | $roomObj->ivPoke('oneWayExitHash', %oneWayExitHash); | ||
| 7816 | } | ||
| 7817 | } | ||
| 7818 | } | ||
| 7819 | |||
| 7820 | if ($version < 1_000_128) { | ||
| 7821 | |||
| 7822 | # This version adds a new IV to the world model | ||
| 7823 | if (! exists $wmObj->{protectedMovesFlag}) { | ||
| 7824 | |||
| 7825 | $wmObj->{protectedMovesFlag} = undef; | ||
| 7826 | $wmObj->ivPoke('protectedMovesFlag', FALSE); | ||
| 7827 | } | ||
| 7828 | } | ||
| 7829 | |||
| 7830 | if ($version < 1_000_213) { | ||
| 7831 | |||
| 7832 | # Add the new IV to all exit objects | ||
| 7833 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7834 | |||
| 7835 | if (! exists $exitObj->{info}) { | ||
| 7836 | |||
| 7837 | # (This IV subsequently renamed and/or removed) | ||
| 7838 | # $exitObj->{info} = undef; | ||
| 7839 | # $exitObj->ivPoke('info', undef); | ||
| 7840 | $exitObj->{info} = undef; | ||
| 7841 | } | ||
| 7842 | } | ||
| 7843 | } | ||
| 7844 | |||
| 7845 | if ($version < 1_000_222) { | ||
| 7846 | |||
| 7847 | # This version fixes an issue with random exits. Make repairs to the world model | ||
| 7848 | |||
| 7849 | # Exit still has a ->randomDestList, even though its ->randomType is no longer 3 | ||
| 7850 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7851 | |||
| 7852 | my $listRef = $exitObj->{randomDestList}; | ||
| 7853 | if ($exitObj->{randomType} == 3 && @$listRef) { | ||
| 7854 | |||
| 7855 | foreach my $destRoomNum (@$listRef) { | ||
| 7856 | |||
| 7857 | my $roomObj = $wmObj->ivShow('modelHash', $destRoomNum); | ||
| 7858 | if ($roomObj && $roomObj->{category} eq 'room') { | ||
| 7859 | |||
| 7860 | $roomObj->ivDelete('randomExitHash', $exitObj->{number}); | ||
| 7861 | } | ||
| 7862 | } | ||
| 7863 | |||
| 7864 | $exitObj->ivEmpty('randomDestList'); | ||
| 7865 | } | ||
| 7866 | } | ||
| 7867 | |||
| 7868 | # Room has an incoming random exit of the wrong type | ||
| 7869 | foreach my $roomObj ($wmObj->ivValues('roomModelHash')) { | ||
| 7870 | |||
| 7871 | my $hashRef = $roomObj->{randomExitHash}; | ||
| 7872 | if (%$hashRef) { | ||
| 7873 | |||
| 7874 | my %modHash; | ||
| 7875 | |||
| 7876 | foreach my $exitNum ($roomObj->ivKeys('randomExitHash')) { | ||
| 7877 | |||
| 7878 | my $exitObj = $wmObj->ivShow('exitModelHash', $exitNum); | ||
| 7879 | if ($exitObj && $exitObj->{randomType} == 3) { | ||
| 7880 | |||
| 7881 | $modHash{$exitNum} = undef; | ||
| 7882 | } | ||
| 7883 | } | ||
| 7884 | |||
| 7885 | $roomObj->ivPoke('randomExitHash', %modHash); | ||
| 7886 | } | ||
| 7887 | } | ||
| 7888 | } | ||
| 7889 | |||
| 7890 | if ($version < 1_000_224) { | ||
| 7891 | |||
| 7892 | # Add a new IV to the world model, the date and Axmud version when the model was | ||
| 7893 | # created. Since we don't know the creation date, use the date of the v1.0.0 | ||
| 7894 | # release | ||
| 7895 | if (! exists $wmObj->{modelCreationDate}) { | ||
| 7896 | |||
| 7897 | $wmObj->{modelCreationDate} = undef; | ||
| 7898 | $wmObj->ivPoke('modelCreationDate', 'Thu Jul 31, 2014'); | ||
| 7899 | $wmObj->{modelCreationVersion} = undef; | ||
| 7900 | $wmObj->ivPoke('modelCreationVersion', '1.0.0'); | ||
| 7901 | } | ||
| 7902 | } | ||
| 7903 | |||
| 7904 | if ($version < 1_000_260) { | ||
| 7905 | |||
| 7906 | my ($regionmapObj, $regionObj); | ||
| 7907 | |||
| 7908 | # ->firstRegion could have been set to a region which has a parent; in which case | ||
| 7909 | # the specified region can't be shown at the top of the Automapper window's list. | ||
| 7910 | # Check the region specified by ->firstRegion and reset it, if it has a parent | ||
| 7911 | # region | ||
| 7912 | if ($wmObj->{firstRegion}) { | ||
| 7913 | |||
| 7914 | my $regionmapObj = $wmObj->ivShow('regionmapHash', $wmObj->{firstRegion}); | ||
| 7915 | if ($regionmapObj) { | ||
| 7916 | |||
| 7917 | $regionObj = $wmObj->ivShow('regionModelHash', $regionmapObj->{number}); | ||
| 7918 | } | ||
| 7919 | |||
| 7920 | if ($regionObj && $regionObj->{parent}) { | ||
| 7921 | |||
| 7922 | $wmObj->ivUndef('firstRegion'); | ||
| 7923 | } | ||
| 7924 | } | ||
| 7925 | } | ||
| 7926 | |||
| 7927 | if ($version < 1_000_272) { | ||
| 7928 | |||
| 7929 | # This version adds a new IV to the world model | ||
| 7930 | if (! exists $wmObj->{showAllPrimaryFlag}) { | ||
| 7931 | |||
| 7932 | $wmObj->{showAllPrimaryFlag} = undef; | ||
| 7933 | $wmObj->ivPoke('showAllPrimaryFlag', FALSE); | ||
| 7934 | } | ||
| 7935 | } | ||
| 7936 | |||
| 7937 | if ($version < 1_000_290) { | ||
| 7938 | |||
| 7939 | # Add the new IV to all exit objects | ||
| 7940 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7941 | |||
| 7942 | if (! exists $exitObj->{oneWayDir}) { | ||
| 7943 | |||
| 7944 | $exitObj->{oneWayDir} = undef; | ||
| 7945 | # The default direction at which the exit touches its destination room is | ||
| 7946 | # the opposite of the exit's existing ->mapDir | ||
| 7947 | # NB If the exit is unallocatable, ->mapDir won't be set, so we'll use | ||
| 7948 | # 'north' as an emergency default value for ->mapDir. (This same approach | ||
| 7949 | # is used elsewhere in the Axmud code) | ||
| 7950 | if ($exitObj->{mapDir}) { | ||
| 7951 | |||
| 7952 | $exitObj->ivPoke( | ||
| 7953 | 'oneWayDir', | ||
| 7954 | $axmud::CLIENT->ivShow('constOppDirHash', $exitObj->{mapDir}), | ||
| 7955 | ); | ||
| 7956 | |||
| 7957 | } else { | ||
| 7958 | |||
| 7959 | # Emergency default | ||
| 7960 | $exitObj->ivPoke('oneWayDir', 'north'); | ||
| 7961 | } | ||
| 7962 | } | ||
| 7963 | } | ||
| 7964 | } | ||
| 7965 | |||
| 7966 | if ($version < 1_000_300) { | ||
| 7967 | |||
| 7968 | # The possible values of $exitObj->state have changed. Values 0-3 are unchanged, but | ||
| 7969 | # the value 4 (other) must be converted to 6 | ||
| 7970 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 7971 | |||
| 7972 | if ($exitObj->{state} == 4) { | ||
| 7973 | |||
| 7974 | # (This IV subsequently renamed and/or removed) | ||
| 7975 | # $exitObj->ivPoke('state', 6); | ||
| 7976 | $exitObj->{state} = 6; | ||
| 7977 | } | ||
| 7978 | } | ||
| 7979 | } | ||
| 7980 | |||
| 7981 | if ($version < 1_000_309) { | ||
| 7982 | |||
| 7983 | # v1.0.308 fixes a problem, in which labels on a map disappeared when the region | ||
| 7984 | # was renamed. Check all labels, and repair any GA::Obj::MapLabel objects that | ||
| 7985 | # are broken | ||
| 7986 | # Actually, first count the problems, then ask the user to repair them, or to | ||
| 7987 | # delete the label altogether | ||
| 7988 | my ($count, $response, $string); | ||
| 7989 | |||
| 7990 | $count = 0; | ||
| 7991 | |||
| 7992 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 7993 | |||
| 7994 | foreach my $labelObj ($regionmapObj->ivValues('gridLabelHash')) { | ||
| 7995 | |||
| 7996 | if ($labelObj->{region} ne $regionmapObj->{name}) { | ||
| 7997 | |||
| 7998 | $count++; | ||
| 7999 | } | ||
| 8000 | } | ||
| 8001 | } | ||
| 8002 | |||
| 8003 | if ($count) { | ||
| 8004 | |||
| 8005 | if ($count == 1) { | ||
| 8006 | $string = '1 label'; | ||
| 8007 | } else { | ||
| 8008 | $string = $count . ' labels'; | ||
| 8009 | } | ||
| 8010 | |||
| 8011 | $response = $self->session->mainWin->showMsgDialogue( | ||
| 8012 | 'Recover missing labels', | ||
| 8013 | 'question', | ||
| 8014 | "Due to an earlier problem, $string had become invisible when region(s)" | ||
| 8015 | . " were renamed. Do you want to recover these labels? (Click \'No\' to" | ||
| 8016 | . " delete them altogether)", | ||
| 8017 | 'yes-no', | ||
| 8018 | ); | ||
| 8019 | |||
| 8020 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 8021 | |||
| 8022 | foreach my $labelObj ($regionmapObj->ivValues('gridLabelHash')) { | ||
| 8023 | |||
| 8024 | if ($labelObj->{region} ne $regionmapObj->{name}) { | ||
| 8025 | |||
| 8026 | # Recover the missing label, even if we're about to delete it | ||
| 8027 | $labelObj->ivPoke('region', $regionmapObj->{name}); | ||
| 8028 | |||
| 8029 | if (! $response || $response eq 'no') { | ||
| 8030 | |||
| 8031 | # Delete this label | ||
| 8032 | $wmObj->deleteLabels( | ||
| 8033 | FALSE, # No Automapper windows to update | ||
| 8034 | $labelObj, | ||
| 8035 | ); | ||
| 8036 | } | ||
| 8037 | } | ||
| 8038 | } | ||
| 8039 | } | ||
| 8040 | } | ||
| 8041 | } | ||
| 8042 | |||
| 8043 | if ($version < 1_000_327) { | ||
| 8044 | |||
| 8045 | # In all exit objects, replace ->state with ->exitState, and modify its value, | ||
| 8046 | # increasing all non-zero values by one | ||
| 8047 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 8048 | |||
| 8049 | if (exists $exitObj->{state}) { | ||
| 8050 | |||
| 8051 | $exitObj->{exitState} = undef; | ||
| 8052 | if ($exitObj->{state}) { | ||
| 8053 | $exitObj->ivPoke('exitState', $exitObj->{state} + 1); | ||
| 8054 | } else { | ||
| 8055 | $exitObj->ivPoke('exitState', 0); | ||
| 8056 | } | ||
| 8057 | |||
| 8058 | delete $exitObj->{state}; | ||
| 8059 | } | ||
| 8060 | } | ||
| 8061 | } | ||
| 8062 | |||
| 8063 | if ($version < 1_000_328) { | ||
| 8064 | |||
| 8065 | # This version adds a new IV to the world model | ||
| 8066 | if (! exists $wmObj->{updateOrnamentsFlag}) { | ||
| 8067 | |||
| 8068 | # (This IV subsequently renamed and/or removed) | ||
| 8069 | # $wmObj->{updateOrnamentsFlag} = undef; | ||
| 8070 | # $wmObj->ivPoke('updateOrnamentsFlag', FALSE); | ||
| 8071 | $wmObj->{updateOrnamentsFlag} = FALSE; | ||
| 8072 | } | ||
| 8073 | } | ||
| 8074 | |||
| 8075 | if ($version < 1_000_329) { | ||
| 8076 | |||
| 8077 | my %stateHash = ( | ||
| 8078 | 0 => 'normal', | ||
| 8079 | 1 => 'open', | ||
| 8080 | 2 => 'closed', | ||
| 8081 | 3 => 'locked', | ||
| 8082 | 4 => 'impass', | ||
| 8083 | 5 => 'dark', | ||
| 8084 | 6 => 'danger', | ||
| 8085 | 7 => 'other', | ||
| 8086 | ); | ||
| 8087 | |||
| 8088 | # In all exit objects, now swapping values of ->exitState from numbers to strings | ||
| 8089 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 8090 | |||
| 8091 | if (exists $stateHash{$exitObj->{exitState}}) { | ||
| 8092 | |||
| 8093 | # e.g. convert 2 to 'closed' | ||
| 8094 | $exitObj->ivPoke('exitState', $stateHash{$exitObj->{exitState}}); | ||
| 8095 | |||
| 8096 | } else { | ||
| 8097 | |||
| 8098 | # Emergency default | ||
| 8099 | $exitObj->ivPoke('exitState', 'normal'); | ||
| 8100 | } | ||
| 8101 | } | ||
| 8102 | } | ||
| 8103 | |||
| 8104 | if ($version < 1_000_341) { | ||
| 8105 | |||
| 8106 | # Add the new IV to all map label objects | ||
| 8107 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 8108 | |||
| 8109 | foreach my $mapLabelObj ($regionmapObj->ivValues('gridLabelHash')) { | ||
| 8110 | |||
| 8111 | if (! exists $mapLabelObj->{relSize}) { | ||
| 8112 | |||
| 8113 | $mapLabelObj->{relSize} = undef; | ||
| 8114 | $mapLabelObj->ivPoke('relSize', 1); | ||
| 8115 | } | ||
| 8116 | } | ||
| 8117 | } | ||
| 8118 | } | ||
| 8119 | |||
| 8120 | if ($version < 1_000_429) { | ||
| 8121 | |||
| 8122 | # This version adds a new IV to the world model | ||
| 8123 | if (! exists $wmObj->{superProtectedMovesFlag}) { | ||
| 8124 | |||
| 8125 | $wmObj->{superProtectedMovesFlag} = undef; | ||
| 8126 | $wmObj->ivPoke('superProtectedMovesFlag', FALSE); | ||
| 8127 | } | ||
| 8128 | } | ||
| 8129 | |||
| 8130 | if ($version < 1_000_467) { | ||
| 8131 | |||
| 8132 | # This version adds a new IV to the world model | ||
| 8133 | if (! exists $wmObj->{teleportHash}) { | ||
| 8134 | |||
| 8135 | $wmObj->{teleportHash} = {}; | ||
| 8136 | } | ||
| 8137 | } | ||
| 8138 | |||
| 8139 | if ($version < 1_000_545) { | ||
| 8140 | |||
| 8141 | # This version splits an existing world model IV into two new ones | ||
| 8142 | if (! exists $wmObj->{allowModelScriptFlag}) { | ||
| 8143 | |||
| 8144 | $wmObj->{allowModelScriptFlag} = undef; | ||
| 8145 | $wmObj->ivPoke('allowModelScriptFlag', $wmObj->{allowScriptFlag}); | ||
| 8146 | $wmObj->{allowRoomScriptFlag} = undef; | ||
| 8147 | $wmObj->ivPoke('allowRoomScriptFlag', $wmObj->{allowScriptFlag}); | ||
| 8148 | delete $wmObj->{allowScriptFlag}; | ||
| 8149 | } | ||
| 8150 | |||
| 8151 | # Also creates two new world model IVs | ||
| 8152 | if (! exists $wmObj->{newRoomScriptList}) { | ||
| 8153 | |||
| 8154 | $wmObj->{newRoomScriptList} = []; | ||
| 8155 | $wmObj->ivEmpty('newRoomScriptList'); | ||
| 8156 | $wmObj->{arriveScriptList} = []; | ||
| 8157 | $wmObj->ivEmpty('arriveScriptList'); | ||
| 8158 | } | ||
| 8159 | |||
| 8160 | # This version also renames a room model object IV | ||
| 8161 | foreach my $obj ($wmObj->ivValues('roomModelHash')) { | ||
| 8162 | |||
| 8163 | my $listRef; | ||
| 8164 | |||
| 8165 | if (! exists $obj->{arriveScriptList}) { | ||
| 8166 | |||
| 8167 | $obj->{arriveScriptList} = []; | ||
| 8168 | $listRef = $obj->{scriptList}; | ||
| 8169 | $obj->ivPush('arriveScriptList', @$listRef); | ||
| 8170 | delete $obj->{scriptList}; | ||
| 8171 | } | ||
| 8172 | } | ||
| 8173 | } | ||
| 8174 | |||
| 8175 | # if ($version < 1_000_572) { | ||
| 8176 | # | ||
| 8177 | # # Update the room flag list | ||
| 8178 | # $wmObj->updateRoomFlags($self->session); | ||
| 8179 | # } | ||
| 8180 | |||
| 8181 | if ($version < 1_000_573) { | ||
| 8182 | |||
| 8183 | # This version fixes an error, in which one of a pair of region exits is made a | ||
| 8184 | # super-region exit, but not the other | ||
| 8185 | # Check all super-region exits; if their twins are not super-region exits (and the | ||
| 8186 | # user hasn't deliberately marked them as not being super-region exits), update | ||
| 8187 | # them | ||
| 8188 | |||
| 8189 | my ($count, $hashRef); | ||
| 8190 | |||
| 8191 | # Only display a warning, if the model contains objects | ||
| 8192 | $count = 0; | ||
| 8193 | $hashRef = $wmObj->{modelHash}; | ||
| 8194 | if (%$hashRef) { | ||
| 8195 | |||
| 8196 | $self->writeText('Applying essential world model update. Please be patient...'); | ||
| 8197 | $axmud::CLIENT->desktopObj->updateWidgets( | ||
| 8198 | $self->_objClass . '->updateExtractedData', | ||
| 8199 | ); | ||
| 8200 | } | ||
| 8201 | |||
| 8202 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 8203 | |||
| 8204 | if ($exitObj->{superFlag} && $exitObj->{twinExit}) { | ||
| 8205 | |||
| 8206 | my $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{twinExit}); | ||
| 8207 | |||
| 8208 | if ( | ||
| 8209 | $twinExitObj->{regionFlag} | ||
| 8210 | && ! $twinExitObj->{superFlag} | ||
| 8211 | && ! $twinExitObj->{notSuperFlag} | ||
| 8212 | ) { | ||
| 8213 | $count++; | ||
| 8214 | $twinExitObj->ivPoke('superFlag', TRUE); | ||
| 8215 | |||
| 8216 | # The regionmap must also be updated (in some cases) | ||
| 8217 | my $twinRoomObj = $wmObj->ivShow('modelHash', $twinExitObj->{parent}); | ||
| 8218 | my $twinRegionObj = $wmObj->ivShow('modelHash', $twinRoomObj->{parent}); | ||
| 8219 | my $twinRegionmapObj | ||
| 8220 | = $wmObj->ivShow('regionmapHash', $twinRegionObj->{name}); | ||
| 8221 | |||
| 8222 | $twinRegionmapObj->storeRegionExit($self->session, $twinExitObj); | ||
| 8223 | } | ||
| 8224 | } | ||
| 8225 | } | ||
| 8226 | |||
| 8227 | if ($count) { | ||
| 8228 | |||
| 8229 | # Recalculate all region pahts | ||
| 8230 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 8231 | |||
| 8232 | my $number = $wmObj->recalculateRegionPaths( | ||
| 8233 | $self->session, | ||
| 8234 | $regionmapObj, | ||
| 8235 | ); | ||
| 8236 | } | ||
| 8237 | } | ||
| 8238 | } | ||
| 8239 | |||
| 8240 | if ($version < 1_000_579) { | ||
| 8241 | |||
| 8242 | # This version corrects some errors with exit bends. Redrawing the bends exactly | ||
| 8243 | # as the user intended them to be is impossible, so in some cases we must | ||
| 8244 | # remove the bends altogether | ||
| 8245 | |||
| 8246 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 8247 | |||
| 8248 | my ($listRef, $twinExitObj, $listRef2); | ||
| 8249 | |||
| 8250 | $listRef = $exitObj->{bendOffsetList}; | ||
| 8251 | |||
| 8252 | # In some cases, a one-way exit or uncertain exit is left with bend(s); so | ||
| 8253 | # remove them | ||
| 8254 | if ( | ||
| 8255 | $exitObj->{oneWayFlag} | ||
| 8256 | || ( | ||
| 8257 | $exitObj->{destRoom} | ||
| 8258 | && ( | ||
| 8259 | ! $exitObj->{twinExit} | ||
| 8260 | && ! $exitObj->{retraceFlag} | ||
| 8261 | && ! $exitObj->{randomType} | ||
| 8262 | ) | ||
| 8263 | ) | ||
| 8264 | ) { | ||
| 8265 | if (@$listRef) { | ||
| 8266 | |||
| 8267 | $exitObj->ivEmpty('bendOffsetList'); | ||
| 8268 | } | ||
| 8269 | } | ||
| 8270 | |||
| 8271 | if ($exitObj->{twinExit}) { | ||
| 8272 | |||
| 8273 | $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{twinExit}); | ||
| 8274 | $listRef2 = $twinExitObj->{bendOffsetList}; | ||
| 8275 | } | ||
| 8276 | |||
| 8277 | # In some cases, one of a pair of two-way exits has a bend, but the other | ||
| 8278 | # doesn't. Remove the bend, in this case | ||
| 8279 | if ( | ||
| 8280 | $twinExitObj | ||
| 8281 | && ( | ||
| 8282 | (! @$listRef && @$listRef2) | ||
| 8283 | || (@$listRef && ! @$listRef2) | ||
| 8284 | ) | ||
| 8285 | ) { | ||
| 8286 | $exitObj->ivEmpty('bendOffsetList'); | ||
| 8287 | $twinExitObj->ivEmpty('bendOffsetList'); | ||
| 8288 | } | ||
| 8289 | } | ||
| 8290 | } | ||
| 8291 | |||
| 8292 | # if ($version < 1_000_624) { | ||
| 8293 | # | ||
| 8294 | # # Update the room flag list | ||
| 8295 | # $wmObj->updateRoomFlags($self->session); | ||
| 8296 | # } | ||
| 8297 | |||
| 8298 | if ($version < 1_000_824) { | ||
| 8299 | |||
| 8300 | # This version adds a new IV to the world model | ||
| 8301 | if (! exists $wmObj->{pseudoWinFlag}) { | ||
| 8302 | |||
| 8303 | $wmObj->{pseudoWinFlag} = undef; | ||
| 8304 | $wmObj->ivPoke('pseudoWinFlag', TRUE); | ||
| 8305 | } | ||
| 8306 | } | ||
| 8307 | |||
| 8308 | if ($version < 1_000_840) { | ||
| 8309 | |||
| 8310 | # This version adds a new IV to all room model objects | ||
| 8311 | foreach my $obj ($wmObj->ivValues('roomModelHash')) { | ||
| 8312 | |||
| 8313 | if (! exists $obj->{protocolRoomHash}) { | ||
| 8314 | |||
| 8315 | $obj->{protocolRoomHash} = {}; | ||
| 8316 | $obj->ivEmpty('protocolRoomHash'); | ||
| 8317 | $obj->{protocolExitHash} = {}; | ||
| 8318 | $obj->ivEmpty('protocolExitHash'); | ||
| 8319 | } | ||
| 8320 | } | ||
| 8321 | } | ||
| 8322 | |||
| 8323 | if ($version < 1_000_842) { | ||
| 8324 | |||
| 8325 | # This version adds new IVs to the world model | ||
| 8326 | if (! exists $wmObj->{matchVNumFlag}) { | ||
| 8327 | |||
| 8328 | $wmObj->{matchVNumFlag} = undef; | ||
| 8329 | $wmObj->ivPoke('matchVNumFlag', TRUE); | ||
| 8330 | $wmObj->{updateVNumFlag} = undef; | ||
| 8331 | $wmObj->ivPoke('updateVNumFlag', TRUE); | ||
| 8332 | |||
| 8333 | $wmObj->{roomTerrainInitHash} = {}; | ||
| 8334 | $wmObj->ivEmpty('roomTerrainInitHash'); | ||
| 8335 | $wmObj->{roomTerrainHash} = {}; | ||
| 8336 | $wmObj->ivEmpty('roomTerrainHash'); | ||
| 8337 | } | ||
| 8338 | } | ||
| 8339 | |||
| 8340 | if ($version < 1_000_859) { | ||
| 8341 | |||
| 8342 | # This version simplifies an IV in regionmap objects | ||
| 8343 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 8344 | |||
| 8345 | my ( | ||
| 8346 | $hashRef, | ||
| 8347 | %newHash, | ||
| 8348 | ); | ||
| 8349 | |||
| 8350 | $hashRef = $regionmapObj->{gridExitTagHash}; | ||
| 8351 | foreach my $key (keys %$hashRef) { | ||
| 8352 | |||
| 8353 | $newHash{$key} = undef; | ||
| 8354 | } | ||
| 8355 | |||
| 8356 | $regionmapObj->ivPoke('gridExitTagHash', %newHash); | ||
| 8357 | } | ||
| 8358 | |||
| 8359 | # This version also changed an IV name | ||
| 8360 | foreach my $obj ($wmObj->ivValues('modelHash')) { | ||
| 8361 | |||
| 8362 | if (! exists $obj->{container}) { | ||
| 8363 | |||
| 8364 | $obj->{container} = undef; | ||
| 8365 | $obj->ivPoke('container', $obj->{containerObj}); | ||
| 8366 | |||
| 8367 | delete $obj->{container}; | ||
| 8368 | } | ||
| 8369 | } | ||
| 8370 | } | ||
| 8371 | |||
| 8372 | if ($version < 1_000_896) { | ||
| 8373 | |||
| 8374 | # This version adds a new IV to all room model objects | ||
| 8375 | foreach my $obj ($wmObj->ivValues('roomModelHash')) { | ||
| 8376 | |||
| 8377 | if (! exists $obj->{roomCmdList}) { | ||
| 8378 | |||
| 8379 | $obj->{roomCmdList} = []; | ||
| 8380 | $obj->ivEmpty('roomCmdList'); | ||
| 8381 | } | ||
| 8382 | } | ||
| 8383 | } | ||
| 8384 | |||
| 8385 | if ($version < 1_000_896) { | ||
| 8386 | |||
| 8387 | # This version adds a new IV to the world model, and renames some existing ones | ||
| 8388 | if (! exists $wmObj->{updateRoomCmdFlag}) { | ||
| 8389 | |||
| 8390 | $wmObj->{updateRoomCmdFlag} = undef; | ||
| 8391 | $wmObj->ivPoke('updateRoomCmdFlag', FALSE); | ||
| 8392 | } | ||
| 8393 | |||
| 8394 | $wmObj->{matchExitFlag} = $wmObj->{matchExitsFlag}; | ||
| 8395 | delete $wmObj->{matchExitsFlag}; | ||
| 8396 | $wmObj->{updateExitFlag} = $wmObj->{updateExitsFlag}; | ||
| 8397 | delete $wmObj->{updateExitsFlag}; | ||
| 8398 | $wmObj->{updateOrnamentFlag} = $wmObj->{updateOrnamentsFlag}; | ||
| 8399 | delete $wmObj->{updateOrnamentsFlag}; | ||
| 8400 | } | ||
| 8401 | |||
| 8402 | if ($version < 1_000_909) { | ||
| 8403 | |||
| 8404 | # This version converts some numerical mode values to string mode values | ||
| 8405 | if ($wmObj->currentRoomMode eq '0') { | ||
| 8406 | $wmObj->ivPoke('currentRoomMode', 'single'); | ||
| 8407 | } elsif ($wmObj->currentRoomMode eq '1') { | ||
| 8408 | $wmObj->ivPoke('currentRoomMode', 'double'); | ||
| 8409 | } elsif ($wmObj->currentRoomMode eq '2') { | ||
| 8410 | $wmObj->ivPoke('currentRoomMode', 'interior'); | ||
| 8411 | } | ||
| 8412 | |||
| 8413 | if ($wmObj->roomInteriorMode eq '0') { | ||
| 8414 | $wmObj->ivPoke('roomInteriorMode', 'none'); | ||
| 8415 | } elsif ($wmObj->roomInteriorMode eq '1') { | ||
| 8416 | $wmObj->ivPoke('roomInteriorMode', 'shadow_count'); | ||
| 8417 | } elsif ($wmObj->roomInteriorMode eq '2') { | ||
| 8418 | $wmObj->ivPoke('roomInteriorMode', 'region_count'); | ||
| 8419 | } elsif ($wmObj->roomInteriorMode eq '3') { | ||
| 8420 | $wmObj->ivPoke('roomInteriorMode', 'room_content'); | ||
| 8421 | } elsif ($wmObj->roomInteriorMode eq '4') { | ||
| 8422 | $wmObj->ivPoke('roomInteriorMode', 'hidden_count'); | ||
| 8423 | } elsif ($wmObj->roomInteriorMode eq '5') { | ||
| 8424 | $wmObj->ivPoke('roomInteriorMode', 'temp_count'); | ||
| 8425 | } elsif ($wmObj->roomInteriorMode eq '6') { | ||
| 8426 | $wmObj->ivPoke('roomInteriorMode', 'word_count'); | ||
| 8427 | } elsif ($wmObj->roomInteriorMode eq '7') { | ||
| 8428 | $wmObj->ivPoke('roomInteriorMode', 'room_flag'); | ||
| 8429 | } elsif ($wmObj->roomInteriorMode eq '8') { | ||
| 8430 | $wmObj->ivPoke('roomInteriorMode', 'visit_count'); | ||
| 8431 | } elsif ($wmObj->roomInteriorMode eq '9') { | ||
| 8432 | $wmObj->ivPoke('roomInteriorMode', 'profile_count'); | ||
| 8433 | } elsif ($wmObj->roomInteriorMode eq '10') { | ||
| 8434 | $wmObj->ivPoke('roomInteriorMode', 'title_descrip'); | ||
| 8435 | } elsif ($wmObj->roomInteriorMode eq '11') { | ||
| 8436 | $wmObj->ivPoke('roomInteriorMode', 'exit_pattern'); | ||
| 8437 | } elsif ($wmObj->roomInteriorMode eq '12') { | ||
| 8438 | $wmObj->ivPoke('roomInteriorMode', 'source_code'); | ||
| 8439 | } elsif ($wmObj->roomInteriorMode eq '13') { | ||
| 8440 | $wmObj->ivPoke('roomInteriorMode', 'vnum'); | ||
| 8441 | } | ||
| 8442 | |||
| 8443 | if ($wmObj->drawExitMode eq '0') { | ||
| 8444 | $wmObj->ivPoke('drawExitMode', 'ask_regionmap'); | ||
| 8445 | } elsif ($wmObj->drawExitMode eq '1') { | ||
| 8446 | $wmObj->ivPoke('drawExitMode', 'no_exit'); | ||
| 8447 | } elsif ($wmObj->drawExitMode eq '2') { | ||
| 8448 | $wmObj->ivPoke('drawExitMode', 'simple_exit'); | ||
| 8449 | } elsif ($wmObj->drawExitMode eq '3') { | ||
| 8450 | $wmObj->ivPoke('drawExitMode', 'complex_exit'); | ||
| 8451 | } | ||
| 8452 | |||
| 8453 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 8454 | |||
| 8455 | if ($regionmapObj->drawExitMode eq '1') { | ||
| 8456 | $regionmapObj->ivPoke('drawExitMode', 'no_exit'); | ||
| 8457 | } elsif ($regionmapObj->drawExitMode eq '2') { | ||
| 8458 | $regionmapObj->ivPoke('drawExitMode', 'simple_exit'); | ||
| 8459 | } elsif ($regionmapObj->drawExitMode eq '3') { | ||
| 8460 | $regionmapObj->ivPoke('drawExitMode', 'complex_exit'); | ||
| 8461 | } | ||
| 8462 | } | ||
| 8463 | |||
| 8464 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 8465 | |||
| 8466 | if ($exitObj->drawMode eq '0') { | ||
| 8467 | $exitObj->ivPoke('drawMode', 'primary'); | ||
| 8468 | } elsif ($exitObj->drawMode eq '1') { | ||
| 8469 | $exitObj->ivPoke('drawMode', 'temp_alloc'); | ||
| 8470 | } elsif ($exitObj->drawMode eq '2') { | ||
| 8471 | $exitObj->ivPoke('drawMode', 'temp_unalloc'); | ||
| 8472 | } elsif ($exitObj->drawMode eq '3') { | ||
| 8473 | $exitObj->ivPoke('drawMode', 'perm_alloc'); | ||
| 8474 | } | ||
| 8475 | |||
| 8476 | if ($exitObj->randomType eq '0') { | ||
| 8477 | $exitObj->ivPoke('randomType', 'none'); | ||
| 8478 | } elsif ($exitObj->randomType eq '1') { | ||
| 8479 | $exitObj->ivPoke('randomType', 'same_region'); | ||
| 8480 | } elsif ($exitObj->randomType eq '2') { | ||
| 8481 | $exitObj->ivPoke('randomType', 'any_region'); | ||
| 8482 | } elsif ($exitObj->randomType eq '3') { | ||
| 8483 | $exitObj->ivPoke('randomType', 'room_list'); | ||
| 8484 | } | ||
| 8485 | } | ||
| 8486 | } | ||
| 8487 | |||
| 8488 | if ($version < 1_000_913) { | ||
| 8489 | |||
| 8490 | # This version removes three IVs which have been moved to GA::Client | ||
| 8491 | if (exists $wmObj->{roomFilterStartList}) { | ||
| 8492 | |||
| 8493 | delete $wmObj->{roomFilterStartList}; | ||
| 8494 | delete $wmObj->{roomFlagStartList}; | ||
| 8495 | delete $wmObj->{roomFlagHazardHash}; | ||
| 8496 | } | ||
| 8497 | |||
| 8498 | # This version also tweaks the value of an IV in several kinds of model objects | ||
| 8499 | foreach my $obj ($wmObj->ivValues('modelHash')) { | ||
| 8500 | |||
| 8501 | if (exists $obj->{sellableFlag}) { | ||
| 8502 | |||
| 8503 | if (! $obj->{sellableFlag}) { | ||
| 8504 | $obj->ivPoke('sellableFlag', FALSE); | ||
| 8505 | } else { | ||
| 8506 | $obj->ivPoke('sellableFlag', TRUE); | ||
| 8507 | } | ||
| 8508 | } | ||
| 8509 | } | ||
| 8510 | } | ||
| 8511 | |||
| 8512 | if ($version < 1_000_915) { | ||
| 8513 | |||
| 8514 | # This version adds a new IV to the world model | ||
| 8515 | if (! exists $wmObj->{followAnchorFlag}) { | ||
| 8516 | |||
| 8517 | $wmObj->{followAnchorFlag} = undef; | ||
| 8518 | $wmObj->ivPoke('followAnchorFlag', FALSE); | ||
| 8519 | } | ||
| 8520 | } | ||
| 8521 | |||
| 8522 | if ($version < 1_000_933) { | ||
| 8523 | |||
| 8524 | # This version renames an IV in the world model | ||
| 8525 | if (exists $wmObj->{showToolBarFlag}) { | ||
| 8526 | |||
| 8527 | $wmObj->{showToolbarFlag} = undef; | ||
| 8528 | $wmObj->ivPoke('showToolbarFlag', $wmObj->{showToolBarFlag}); | ||
| 8529 | delete $wmObj->{showToolBarFlag}; | ||
| 8530 | } | ||
| 8531 | } | ||
| 8532 | |||
| 8533 | if ($version < 1_001_030) { | ||
| 8534 | |||
| 8535 | # Add the new IV to all room model objects | ||
| 8536 | foreach my $obj ($wmObj->ivValues('roomModelHash')) { | ||
| 8537 | |||
| 8538 | if (! exists $obj->{tempRoomCmdList}) { | ||
| 8539 | |||
| 8540 | $obj->{tempRoomCmdList} = []; | ||
| 8541 | $obj->ivEmpty('tempRoomCmdList'); | ||
| 8542 | } | ||
| 8543 | } | ||
| 8544 | } | ||
| 8545 | |||
| 8546 | if ($version < 1_001_063) { | ||
| 8547 | |||
| 8548 | # General update to the world model, aimed at drastically reducing its size by | ||
| 8549 | # combining rarely-used IVs into single hash IVs | ||
| 8550 | |||
| 8551 | # GA::Obj::Exit->breakHash, ->pickHash, ->unlockHash, ->openHash, ->closeHash, | ||
| 8552 | # ->lockHash and ->ornamentFlag are removed entirely | ||
| 8553 | # ->info is just renamed, not removed/merged | ||
| 8554 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 8555 | |||
| 8556 | if (! exists $exitObj->{'exitOrnament'}) { | ||
| 8557 | |||
| 8558 | $exitObj->{exitOrnament} = undef; | ||
| 8559 | |||
| 8560 | if ($exitObj->{breakFlag}) { | ||
| 8561 | $exitObj->ivPoke('exitOrnament', 'break'); | ||
| 8562 | } elsif ($exitObj->{pickFlag}) { | ||
| 8563 | $exitObj->ivPoke('exitOrnament', 'pick'); | ||
| 8564 | } elsif ($exitObj->{lockFlag}) { | ||
| 8565 | $exitObj->ivPoke('exitOrnament', 'lock'); | ||
| 8566 | } elsif ($exitObj->{openFlag}) { | ||
| 8567 | $exitObj->ivPoke('exitOrnament', 'open'); | ||
| 8568 | } elsif ($exitObj->{impassFlag}) { | ||
| 8569 | $exitObj->ivPoke('exitOrnament', 'impass'); | ||
| 8570 | } else { | ||
| 8571 | $exitObj->ivPoke('exitOrnament', 'none'); | ||
| 8572 | } | ||
| 8573 | |||
| 8574 | delete $exitObj->{breakFlag}; | ||
| 8575 | delete $exitObj->{pickFlag}; | ||
| 8576 | delete $exitObj->{lockFlag}; | ||
| 8577 | delete $exitObj->{openFlag}; | ||
| 8578 | delete $exitObj->{impassFlag}; | ||
| 8579 | delete $exitObj->{ornamentFlag}; | ||
| 8580 | |||
| 8581 | $exitObj->{exitInfo} = undef; | ||
| 8582 | $exitObj->ivPoke('exitInfo', $exitObj->{info}); | ||
| 8583 | delete $exitObj->{info}; | ||
| 8584 | |||
| 8585 | $exitObj->{doorHash} = {}; | ||
| 8586 | |||
| 8587 | if (defined $exitObj->{breakCmd}) { | ||
| 8588 | |||
| 8589 | $exitObj->ivAdd('doorHash', 'break', $exitObj->{breakCmd}); | ||
| 8590 | } | ||
| 8591 | |||
| 8592 | if (defined $exitObj->{pickCmd}) { | ||
| 8593 | |||
| 8594 | $exitObj->ivAdd('doorHash', 'pick', $exitObj->{pickCmd}); | ||
| 8595 | } | ||
| 8596 | |||
| 8597 | if (defined $exitObj->{unlockCmd}) { | ||
| 8598 | |||
| 8599 | $exitObj->ivAdd('doorHash', 'unlock', $exitObj->{unlockCmd}); | ||
| 8600 | } | ||
| 8601 | |||
| 8602 | if (defined $exitObj->{openCmd}) { | ||
| 8603 | |||
| 8604 | $exitObj->ivAdd('doorHash', 'open', $exitObj->{openCmd}); | ||
| 8605 | } | ||
| 8606 | |||
| 8607 | if (defined $exitObj->{closeCmd}) { | ||
| 8608 | |||
| 8609 | $exitObj->ivAdd('doorHash', 'close', $exitObj->{closeCmd}); | ||
| 8610 | } | ||
| 8611 | |||
| 8612 | if (defined $exitObj->{lockCmd}) { | ||
| 8613 | |||
| 8614 | $exitObj->ivAdd('doorHash', 'lock', $exitObj->{lockCmd}); | ||
| 8615 | } | ||
| 8616 | |||
| 8617 | delete $exitObj->{breakHash}; | ||
| 8618 | delete $exitObj->{pickHash}; | ||
| 8619 | delete $exitObj->{unlockHash}; | ||
| 8620 | delete $exitObj->{openHash}; | ||
| 8621 | delete $exitObj->{closeHash}; | ||
| 8622 | delete $exitObj->{lockHash}; | ||
| 8623 | |||
| 8624 | delete $exitObj->{breakCmd}; | ||
| 8625 | delete $exitObj->{pickCmd}; | ||
| 8626 | delete $exitObj->{unlockCmd}; | ||
| 8627 | delete $exitObj->{openCmd}; | ||
| 8628 | delete $exitObj->{closeCmd}; | ||
| 8629 | delete $exitObj->{lockCmd}; | ||
| 8630 | } | ||
| 8631 | } | ||
| 8632 | } | ||
| 8633 | |||
| 8634 | if ($version < 1_001_064) { | ||
| 8635 | |||
| 8636 | # This version adds a new IV to the world model | ||
| 8637 | if (! exists $wmObj->{buttonSetList}) { | ||
| 8638 | |||
| 8639 | $wmObj->{buttonSetList} = []; | ||
| 8640 | $wmObj->ivEmpty('buttonSetList'); | ||
| 8641 | } | ||
| 8642 | } | ||
| 8643 | |||
| 8644 | if ($version < 1_001_069) { | ||
| 8645 | |||
| 8646 | # This version adds a new IV to the world model | ||
| 8647 | if (! exists $wmObj->{preferRoomFlagList}) { | ||
| 8648 | |||
| 8649 | $wmObj->{preferRoomFlagList} = []; | ||
| 8650 | $wmObj->ivEmpty('preferRoomFlagList'); | ||
| 8651 | } | ||
| 8652 | } | ||
| 8653 | |||
| 8654 | if ($version < 1_001_070) { | ||
| 8655 | |||
| 8656 | # Apparently, $self->update_modelobj_all wasn't called for the world model's | ||
| 8657 | # painter object (a non-model GA::ModelObj::Room object), and this causes a crash | ||
| 8658 | # if the user tries to open the painter's edit window in a world model created | ||
| 8659 | # before ->update_modelobj_all was | ||
| 8660 | # Foolproof fix is to reset the painter, no questions asked | ||
| 8661 | $wmObj->resetPainter($self->session); | ||
| 8662 | } | ||
| 8663 | |||
| 8664 | if ($version < 1_001_071) { | ||
| 8665 | |||
| 8666 | # Add the new IV to all room model objects | ||
| 8667 | foreach my $obj ($wmObj->ivValues('roomModelHash')) { | ||
| 8668 | |||
| 8669 | if (! exists $obj->{wildMode}) { | ||
| 8670 | |||
| 8671 | $obj->{wildMode} = undef; | ||
| 8672 | $obj->ivPoke('wildMode', 'normal'); | ||
| 8673 | } | ||
| 8674 | } | ||
| 8675 | } | ||
| 8676 | |||
| 8677 | if ($version < 1_001_077) { | ||
| 8678 | |||
| 8679 | # Update and rename a world model IV | ||
| 8680 | if (! exists $wmObj->{constPainterIVList}) { | ||
| 8681 | |||
| 8682 | $wmObj->{constPainterIVList} = [ | ||
| 8683 | 'wildMode', | ||
| 8684 | 'titleList', | ||
| 8685 | 'descripHash', | ||
| 8686 | 'exclusiveFlag', | ||
| 8687 | 'exclusiveHash', | ||
| 8688 | 'roomFlagHash', | ||
| 8689 | 'roomGuild', | ||
| 8690 | 'searchHash', | ||
| 8691 | ]; | ||
| 8692 | |||
| 8693 | delete $wmObj->{painterIVList}; | ||
| 8694 | } | ||
| 8695 | } | ||
| 8696 | |||
| 8697 | if ($version < 1_001_080) { | ||
| 8698 | |||
| 8699 | # This version renames an IV to the world model | ||
| 8700 | if (exists $wmObj->{basicMappingMode}) { | ||
| 8701 | |||
| 8702 | $wmObj->{basicMappingFlag} = undef; | ||
| 8703 | $wmObj->ivPoke('basicMappingFlag', $wmObj->{basicMappingMode}); | ||
| 8704 | delete $wmObj->{basicMappingMode}; | ||
| 8705 | } | ||
| 8706 | } | ||
| 8707 | |||
| 8708 | if ($version < 1_001_082) { | ||
| 8709 | |||
| 8710 | # This version adds a new IV to the world model | ||
| 8711 | if (! exists $wmObj->{craftyMovesFlag}) { | ||
| 8712 | |||
| 8713 | $wmObj->{craftyMovesFlag} = undef; | ||
| 8714 | $wmObj->ivPoke('craftyMovesFlag', FALSE); | ||
| 8715 | } | ||
| 8716 | } | ||
| 8717 | |||
| 8718 | if ($version < 1_001_084) { | ||
| 8719 | |||
| 8720 | # This version adds new IVs to the world model | ||
| 8721 | if (! exists $wmObj->{paintFromTitleHash}) { | ||
| 8722 | |||
| 8723 | $wmObj->{paintFromTitleHash} = {}; | ||
| 8724 | $wmObj->ivEmpty('paintFromTitleHash'); | ||
| 8725 | $wmObj->{paintFromDescripHash} = {}; | ||
| 8726 | $wmObj->ivEmpty('paintFromDescripHash'); | ||
| 8727 | $wmObj->{paintFromExitHash} = {}; | ||
| 8728 | $wmObj->ivEmpty('paintFromExitHash'); | ||
| 8729 | $wmObj->{paintFromObjHash} = {}; | ||
| 8730 | $wmObj->ivEmpty('paintFromObjHash'); | ||
| 8731 | $wmObj->{paintFromRoomCmdHash} = {}; | ||
| 8732 | $wmObj->ivEmpty('paintFromRoomCmdHash'); | ||
| 8733 | } | ||
| 8734 | } | ||
| 8735 | |||
| 8736 | if ($version < 1_001_087) { | ||
| 8737 | |||
| 8738 | # This version adds a new IV to the world model | ||
| 8739 | if (! exists $wmObj->{preferBGColourList}) { | ||
| 8740 | |||
| 8741 | $wmObj->{preferBGColourList} = []; | ||
| 8742 | $wmObj->ivEmpty('preferBGColourList'); | ||
| 8743 | } | ||
| 8744 | |||
| 8745 | # This version also adds new IVs to regionmaps | ||
| 8746 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 8747 | |||
| 8748 | if (! exists $regionmapObj->{gridColourBlockHash}) { | ||
| 8749 | |||
| 8750 | $regionmapObj->{gridColourBlockHash} = {}; | ||
| 8751 | $regionmapObj->ivEmpty('gridColourBlockHash'); | ||
| 8752 | $regionmapObj->{gridColourObjHash} = {}; | ||
| 8753 | $regionmapObj->ivEmpty('gridColourObjHash'); | ||
| 8754 | $regionmapObj->{colourObjCount} = undef; | ||
| 8755 | $regionmapObj->ivPoke('colourObjCount', 0); | ||
| 8756 | } | ||
| 8757 | } | ||
| 8758 | } | ||
| 8759 | |||
| 8760 | if ($version < 1_001_089) { | ||
| 8761 | |||
| 8762 | # This version adds new IVs to the world model | ||
| 8763 | if (! exists $wmObj->{collectCheckedDirsFlag}) { | ||
| 8764 | |||
| 8765 | $wmObj->{defaultCheckedDirColour} = undef; | ||
| 8766 | $wmObj->ivPoke('defaultCheckedDirColour', '#FF96AA'); | ||
| 8767 | $wmObj->{checkedDirColour} = undef; | ||
| 8768 | $wmObj->ivPoke('checkedDirColour', '#FF96AA'); | ||
| 8769 | |||
| 8770 | $wmObj->{collectCheckedDirsFlag} = undef; | ||
| 8771 | $wmObj->ivPoke('collectCheckedDirsFlag', FALSE); | ||
| 8772 | $wmObj->{drawCheckedDirsFlag} = undef; | ||
| 8773 | $wmObj->ivPoke('drawCheckedDirsFlag', TRUE); | ||
| 8774 | $wmObj->{checkableDirMode} = undef; | ||
| 8775 | $wmObj->ivPoke('checkableDirMode', 'diku'); | ||
| 8776 | } | ||
| 8777 | |||
| 8778 | # It also adds a new IV to all room model objects | ||
| 8779 | foreach my $obj ($wmObj->ivValues('roomModelHash')) { | ||
| 8780 | |||
| 8781 | if (! exists $obj->{checkedDirHash}) { | ||
| 8782 | |||
| 8783 | $obj->{checkedDirHash} = {}; | ||
| 8784 | $obj->ivEmpty('checkedDirHash'); | ||
| 8785 | } | ||
| 8786 | } | ||
| 8787 | } | ||
| 8788 | |||
| 8789 | if ($version < 1_001_097) { | ||
| 8790 | |||
| 8791 | # This version adds new IVs to the world model | ||
| 8792 | if (! exists $wmObj->{mapLabelStyleHash}) { | ||
| 8793 | |||
| 8794 | $wmObj->{mapLabelStyleHash} = {}; | ||
| 8795 | |||
| 8796 | $wmObj->{mapLabelStyleHash}{'Style 1'} = Games::Axmud::Obj::MapLabelStyle->new( | ||
| 8797 | $self->session, | ||
| 8798 | 'Style 1', | ||
| 8799 | '#C90640', | ||
| 8800 | ); | ||
| 8801 | |||
| 8802 | $wmObj->{mapLabelStyleHash}{'Style 2'} = Games::Axmud::Obj::MapLabelStyle->new( | ||
| 8803 | $self->session, | ||
| 8804 | 'Style 2', | ||
| 8805 | '#FF40E0', | ||
| 8806 | ), | ||
| 8807 | |||
| 8808 | $wmObj->{mapLabelStyleHash}{'Style 3'} = Games::Axmud::Obj::MapLabelStyle->new( | ||
| 8809 | $self->session, | ||
| 8810 | 'Style 3', | ||
| 8811 | '#000000', | ||
| 8812 | undef, # No underlay colour | ||
| 8813 | 2, | ||
| 8814 | ); | ||
| 8815 | |||
| 8816 | $wmObj->{mapLabelStyleHash}{'Style 4'} = Games::Axmud::Obj::MapLabelStyle->new( | ||
| 8817 | $self->session, | ||
| 8818 | 'Style 4', | ||
| 8819 | '#000000', | ||
| 8820 | undef, # No underlay colour | ||
| 8821 | 4 | ||
| 8822 | ); | ||
| 8823 | |||
| 8824 | $wmObj->{mapLabelStyle} = undef; | ||
| 8825 | $wmObj->ivPoke('mapLabelStyle', 'Style 1'); | ||
| 8826 | } | ||
| 8827 | |||
| 8828 | # This version also adds new IVs to map label objects | ||
| 8829 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 8830 | |||
| 8831 | foreach my $mapLabelObj ($regionmapObj->ivValues('gridLabelHash')) { | ||
| 8832 | |||
| 8833 | if (! exists $mapLabelObj->{style}) { | ||
| 8834 | |||
| 8835 | $mapLabelObj->{style} = undef; | ||
| 8836 | |||
| 8837 | $mapLabelObj->{textColour} = undef; | ||
| 8838 | $mapLabelObj->ivPoke('textColour', $wmObj->defaultMapLabelColour); | ||
| 8839 | $mapLabelObj->{underlayColour} = undef; | ||
| 8840 | $mapLabelObj->ivUndef('underlayColour'); | ||
| 8841 | $mapLabelObj->{italicsFlag} = undef; | ||
| 8842 | $mapLabelObj->ivPoke('italicsFlag', FALSE); | ||
| 8843 | $mapLabelObj->{boldFlag} = undef; | ||
| 8844 | $mapLabelObj->ivPoke('boldFlag', FALSE); | ||
| 8845 | $mapLabelObj->{underlineFlag} = undef; | ||
| 8846 | $mapLabelObj->ivPoke('underlineFlag', FALSE); | ||
| 8847 | $mapLabelObj->{strikeFlag} = undef; | ||
| 8848 | $mapLabelObj->ivPoke('strikeFlag', FALSE); | ||
| 8849 | $mapLabelObj->{boxFlag} = undef; | ||
| 8850 | $mapLabelObj->ivPoke('boxFlag', FALSE); | ||
| 8851 | $mapLabelObj->{gravity} = undef; | ||
| 8852 | $mapLabelObj->ivPoke('gravity', 'south'); | ||
| 8853 | |||
| 8854 | if ($mapLabelObj->{relSize} == 1) { | ||
| 8855 | |||
| 8856 | $mapLabelObj->ivPoke('style', 'Style 1'); | ||
| 8857 | |||
| 8858 | } elsif ($mapLabelObj->{relSize} == 2) { | ||
| 8859 | |||
| 8860 | $mapLabelObj->ivPoke('style', 'Style 3'); | ||
| 8861 | |||
| 8862 | } elsif ($mapLabelObj->{relSize} == 4) { | ||
| 8863 | |||
| 8864 | $mapLabelObj->ivPoke('style', 'Style 4'); | ||
| 8865 | |||
| 8866 | } else { | ||
| 8867 | |||
| 8868 | # Failsafe | ||
| 8869 | $mapLabelObj->ivPoke('style', 'Style 1'); | ||
| 8870 | } | ||
| 8871 | } | ||
| 8872 | } | ||
| 8873 | } | ||
| 8874 | } | ||
| 8875 | |||
| 8876 | if ($version < 1_001_101) { | ||
| 8877 | |||
| 8878 | # This version adds new IVs to the world model | ||
| 8879 | if (! exists $wmObj->{defaultSelectBoxColour}) { | ||
| 8880 | |||
| 8881 | $wmObj->{defaultSelectBoxColour} = undef; | ||
| 8882 | $wmObj->ivPoke('defaultSelectBoxColour', '#0088FF'); | ||
| 8883 | $wmObj->{selectBoxColour} = undef; | ||
| 8884 | $wmObj->ivPoke('selectBoxColour', '#0088FF'); | ||
| 8885 | } | ||
| 8886 | } | ||
| 8887 | |||
| 8888 | if ($version < 1_001_104) { | ||
| 8889 | |||
| 8890 | # This version adds new IVs to the world model | ||
| 8891 | if (! exists $wmObj->{mapLabelAlignXFlag}) { | ||
| 8892 | |||
| 8893 | $wmObj->{mapLabelAlignXFlag} = undef; | ||
| 8894 | $wmObj->ivPoke('mapLabelAlignXFlag', FALSE); | ||
| 8895 | $wmObj->{mapLabelAlignYFlag} = undef; | ||
| 8896 | $wmObj->ivPoke('mapLabelAlignYFlag', FALSE); | ||
| 8897 | } | ||
| 8898 | } | ||
| 8899 | |||
| 8900 | if ($version < 1_001_107) { | ||
| 8901 | |||
| 8902 | my ($count, $hashRef, $listRef); | ||
| 8903 | |||
| 8904 | # This version reorganises room flag IVs. Convert data in the old format to the | ||
| 8905 | # new format | ||
| 8906 | if (! exists $wmObj->{roomFilterApplyHash}) { | ||
| 8907 | |||
| 8908 | # Add new IV definitions | ||
| 8909 | $wmObj->{roomFilterApplyHash} = {}; | ||
| 8910 | $wmObj->ivEmpty('roomFilterApplyHash'); | ||
| 8911 | $wmObj->{roomFlagHash} = {}; | ||
| 8912 | $wmObj->ivEmpty('roomFlagHash'); | ||
| 8913 | |||
| 8914 | # Set up ->roomFilterApplyHash, which replaces the old ->roomFilterHash | ||
| 8915 | foreach my $filter ($axmud::CLIENT->constRoomFilterList) { | ||
| 8916 | |||
| 8917 | if ($wmObj->{roomFilterHash}{$filter}) { | ||
| 8918 | $wmObj->ivAdd('roomFilterApplyHash', $filter, TRUE); | ||
| 8919 | } else { | ||
| 8920 | $wmObj->ivAdd('roomFilterApplyHash', $filter, FALSE); | ||
| 8921 | } | ||
| 8922 | } | ||
| 8923 | |||
| 8924 | # Create the default set of room flag objects, stored in new ->roomFlagHash | ||
| 8925 | $wmObj->setupRoomFlags($self->session); | ||
| 8926 | |||
| 8927 | # Incorporate any changes to room flag colours made by the user | ||
| 8928 | $hashRef = $wmObj->{roomFlagTextHash}; | ||
| 8929 | foreach my $oldFlag (keys %$hashRef) { | ||
| 8930 | |||
| 8931 | my ($newObj, $colour); | ||
| 8932 | |||
| 8933 | # Get the new room flag object | ||
| 8934 | $newObj = $wmObj->ivShow('roomFlagHash', $oldFlag); | ||
| 8935 | |||
| 8936 | # Update colour | ||
| 8937 | $colour = $wmObj->{roomFlagColourHash}{$oldFlag}; | ||
| 8938 | if (defined $colour) { | ||
| 8939 | |||
| 8940 | $newObj->ivPoke('colour', $colour); | ||
| 8941 | } | ||
| 8942 | } | ||
| 8943 | |||
| 8944 | # Set the priority for every room flag object, using the unchanged | ||
| 8945 | # ->roomFlagOrderedList IV | ||
| 8946 | $count = 0; | ||
| 8947 | $listRef = $wmObj->{roomFlagOrderedList}; | ||
| 8948 | foreach my $roomFlag (@$listRef) { | ||
| 8949 | |||
| 8950 | $count++; | ||
| 8951 | |||
| 8952 | my $newObj = $wmObj->ivShow('roomFlagHash', $roomFlag); | ||
| 8953 | $newObj->ivPoke('priority', $count); | ||
| 8954 | } | ||
| 8955 | |||
| 8956 | # Remove old IV definitions | ||
| 8957 | delete $wmObj->{defaultRoomFilterList}; | ||
| 8958 | delete $wmObj->{defaultRoomFilterHash}; | ||
| 8959 | delete $wmObj->{defaultRoomFlagTextHash}; | ||
| 8960 | delete $wmObj->{defaultRoomFlagPriorityHash}; | ||
| 8961 | delete $wmObj->{defaultRoomFlagFilterHash}; | ||
| 8962 | delete $wmObj->{defaultRoomFlagColourHash}; | ||
| 8963 | delete $wmObj->{defaultRoomFlagDescripHash}; | ||
| 8964 | delete $wmObj->{defaultRoomFlagOrderedList}; | ||
| 8965 | delete $wmObj->{defaultRoomFlagReverseHash}; | ||
| 8966 | |||
| 8967 | delete $wmObj->{roomFilterList}; | ||
| 8968 | delete $wmObj->{roomFilterHash}; | ||
| 8969 | delete $wmObj->{roomFlagTextHash}; | ||
| 8970 | delete $wmObj->{roomFlagPriorityHash}; | ||
| 8971 | delete $wmObj->{roomFlagFilterHash}; | ||
| 8972 | delete $wmObj->{roomFlagColourHash}; | ||
| 8973 | delete $wmObj->{roomFlagDescripHash}; | ||
| 8974 | # ( ->roomFlagOrderedList is retained) | ||
| 8975 | delete $wmObj->{roomFlagReverseHash}; | ||
| 8976 | } | ||
| 8977 | } | ||
| 8978 | |||
| 8979 | if ($version < 1_001_112) { | ||
| 8980 | |||
| 8981 | # Update the room flag list | ||
| 8982 | $wmObj->updateRoomFlags($self->session); | ||
| 8983 | } | ||
| 8984 | |||
| 8985 | if ($version < 1_001_115) { | ||
| 8986 | |||
| 8987 | # This version corrects drawing issues with unallocated exits, on which a 'confirm | ||
| 8988 | # two-way exit' operation was performed | ||
| 8989 | # Check every exit in the model, looking 2-way exits and not region exits, at least | ||
| 8990 | # one of which has been allocated a direction, whose ->mapDirs are not opposites | ||
| 8991 | # and which are not marked as broken exits | ||
| 8992 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 8993 | |||
| 8994 | my $twinExitObj; | ||
| 8995 | |||
| 8996 | if ( | ||
| 8997 | defined $exitObj->twinExit | ||
| 8998 | && ! $exitObj->regionFlag | ||
| 8999 | && $exitObj->drawMode eq 'perm_alloc' | ||
| 9000 | && ! $exitObj->brokenFlag | ||
| 9001 | ) { | ||
| 9002 | $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->twinExit); | ||
| 9003 | |||
| 9004 | if ( | ||
| 9005 | ! $twinExitObj->brokenFlag | ||
| 9006 | && $axmud::CLIENT->ivShow('constOppDirHash', $exitObj->mapDir) | ||
| 9007 | ne $twinExitObj->mapDir | ||
| 9008 | ) { | ||
| 9009 | # The problem is fixed by marking both as bent broken exits | ||
| 9010 | $exitObj->ivPoke('brokenFlag', TRUE); | ||
| 9011 | $exitObj->ivPoke('bentFlag', TRUE); | ||
| 9012 | $twinExitObj->ivPoke('brokenFlag', TRUE); | ||
| 9013 | $twinExitObj->ivPoke('bentFlag', TRUE); | ||
| 9014 | } | ||
| 9015 | } | ||
| 9016 | } | ||
| 9017 | } | ||
| 9018 | |||
| 9019 | if ($version < 1_001_118) { | ||
| 9020 | |||
| 9021 | # This version adds new IVs to the world model | ||
| 9022 | if (! exists $wmObj->{showNotesFlag}) { | ||
| 9023 | |||
| 9024 | $wmObj->{showNotesFlag} = undef; | ||
| 9025 | $wmObj->ivPoke('showNotesFlag', TRUE); | ||
| 9026 | $wmObj->{allowCtrlCopyFlag} = undef; | ||
| 9027 | $wmObj->ivPoke('allowCtrlCopyFlag', TRUE); | ||
| 9028 | } | ||
| 9029 | } | ||
| 9030 | |||
| 9031 | if ($version < 1_001_234) { | ||
| 9032 | |||
| 9033 | # This version adds a new IV to the world model | ||
| 9034 | if (! exists $wmObj->{mapLabelTextViewFlag}) { | ||
| 9035 | |||
| 9036 | $wmObj->{mapLabelTextViewFlag} = undef; | ||
| 9037 | $wmObj->ivPoke('mapLabelTextViewFlag', FALSE); | ||
| 9038 | } | ||
| 9039 | } | ||
| 9040 | |||
| 9041 | if ($version < 1_001_235) { | ||
| 9042 | |||
| 9043 | # This version adds a new IV to all room model objects | ||
| 9044 | foreach my $obj ($wmObj->ivValues('roomModelHash')) { | ||
| 9045 | |||
| 9046 | if (! exists $obj->{unspecifiedPatternList}) { | ||
| 9047 | |||
| 9048 | $obj->{unspecifiedPatternList} = []; | ||
| 9049 | $obj->ivEmpty('unspecifiedPatternList'); | ||
| 9050 | } | ||
| 9051 | } | ||
| 9052 | } | ||
| 9053 | |||
| 9054 | if ($version < 1_001_240) { | ||
| 9055 | |||
| 9056 | # This version adds new IVs to the world model | ||
| 9057 | if (! exists $wmObj->{autoSlideMode}) { | ||
| 9058 | |||
| 9059 | $wmObj->{autoSlideMode} = undef; | ||
| 9060 | $wmObj->ivPoke('autoSlideMode', 'default'); | ||
| 9061 | $wmObj->{autoSlideMax} = undef; | ||
| 9062 | $wmObj->ivPoke('autoSlideMax', 10); | ||
| 9063 | } | ||
| 9064 | } | ||
| 9065 | |||
| 9066 | if ($version < 1_001_241) { | ||
| 9067 | |||
| 9068 | # This version removes an IV from all room model objects | ||
| 9069 | foreach my $obj ($wmObj->ivValues('roomModelHash')) { | ||
| 9070 | |||
| 9071 | delete $obj->{everMatchedFlag}; | ||
| 9072 | } | ||
| 9073 | } | ||
| 9074 | |||
| 9075 | if ($version < 1_001_250) { | ||
| 9076 | |||
| 9077 | # This version adds a new IV to the world model | ||
| 9078 | if (! exists $wmObj->{autoRescueFlag}) { | ||
| 9079 | |||
| 9080 | $wmObj->{autoRescueFlag} = undef; | ||
| 9081 | $wmObj->ivPoke('autoRescueFlag', FALSE); | ||
| 9082 | $wmObj->{autoRescueFirstFlag} = undef; | ||
| 9083 | $wmObj->ivPoke('autoRescueFirstFlag', FALSE); | ||
| 9084 | $wmObj->{autoRescuePromptFlag} = undef; | ||
| 9085 | $wmObj->ivPoke('autoRescuePromptFlag', FALSE); | ||
| 9086 | } | ||
| 9087 | } | ||
| 9088 | |||
| 9089 | if ($version < 1_001_251) { | ||
| 9090 | |||
| 9091 | # This version adds new IVs to the world model | ||
| 9092 | if (! exists $wmObj->{autoCompareMode}) { | ||
| 9093 | |||
| 9094 | $wmObj->{autoCompareMode} = undef; | ||
| 9095 | if (! $wmObj->{autoCompareFlag}) { | ||
| 9096 | $wmObj->ivPoke('autoCompareMode', 'default'); | ||
| 9097 | } else { | ||
| 9098 | $wmObj->ivPoke('autoCompareMode', 'new'); | ||
| 9099 | } | ||
| 9100 | |||
| 9101 | $wmObj->{autoCompareAllFlag} = undef; | ||
| 9102 | $wmObj->ivPoke('autoCompareAllFlag', FALSE); | ||
| 9103 | $wmObj->{autoCompareMax} = undef; | ||
| 9104 | $wmObj->ivPoke('autoCompareMax', 0); | ||
| 9105 | } | ||
| 9106 | } | ||
| 9107 | |||
| 9108 | if ($version < 1_001_254) { | ||
| 9109 | |||
| 9110 | # This version adds new IVs to the world model | ||
| 9111 | if (! exists $wmObj->{autoRescueNoMoveFlag}) { | ||
| 9112 | |||
| 9113 | $wmObj->{autoRescueNoMoveFlag} = undef; | ||
| 9114 | $wmObj->ivPoke('autoRescueNoMoveFlag', FALSE); | ||
| 9115 | $wmObj->{autoRescueVisitsFlag} = undef; | ||
| 9116 | $wmObj->ivPoke('autoRescueVisitsFlag', FALSE); | ||
| 9117 | $wmObj->{autoRescueForceFlag} = undef; | ||
| 9118 | $wmObj->ivPoke('autoRescueForceFlag', FALSE); | ||
| 9119 | } | ||
| 9120 | } | ||
| 9121 | |||
| 9122 | # if ($version < 1_001_289) { | ||
| 9123 | # | ||
| 9124 | # # This version adds new IVs to the world model | ||
| 9125 | # if (! exists $wmObj->{adjacentMode}) { | ||
| 9126 | # | ||
| 9127 | # $wmObj->{adjacentMode} = undef; | ||
| 9128 | # $wmObj->ivPoke('adjacentMode', 'near'); | ||
| 9129 | # $wmObj->{adjacentCount} = undef; | ||
| 9130 | # $wmObj->ivPoke('adjacentCount', 1); | ||
| 9131 | # } | ||
| 9132 | # } | ||
| 9133 | |||
| 9134 | if ($version < 1_001_290) { | ||
| 9135 | |||
| 9136 | # This version adds a new IV to exit objects in the world model | ||
| 9137 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 9138 | |||
| 9139 | if (! exists $exitObj->{altDir}) { | ||
| 9140 | |||
| 9141 | $exitObj->{altDir} = undef; | ||
| 9142 | $exitObj->ivUndef('altDir'); | ||
| 9143 | } | ||
| 9144 | } | ||
| 9145 | } | ||
| 9146 | |||
| 9147 | if ($version < 1_001_295) { | ||
| 9148 | |||
| 9149 | # This version adds new IVs to the world model | ||
| 9150 | if (! exists $wmObj->{defaultMysteryExitColour}) { | ||
| 9151 | |||
| 9152 | $wmObj->{defaultMysteryExitColour} = undef; | ||
| 9153 | $wmObj->ivPoke('defaultMysteryExitColour', '#900700'); | ||
| 9154 | $wmObj->{mysteryExitColour} = undef; | ||
| 9155 | $wmObj->ivPoke('mysteryExitColour', '#900700'); | ||
| 9156 | } | ||
| 9157 | } | ||
| 9158 | |||
| 9159 | if ($version < 1_001_295) { | ||
| 9160 | |||
| 9161 | # This version adds a new IV to the world model | ||
| 9162 | if (! exists $wmObj->{quickPaintMultiFlag}) { | ||
| 9163 | |||
| 9164 | $wmObj->{quickPaintMultiFlag} = undef; | ||
| 9165 | $wmObj->ivPoke('quickPaintMultiFlag', FALSE); | ||
| 9166 | } | ||
| 9167 | } | ||
| 9168 | |||
| 9169 | if ($version < 1_001_306) { | ||
| 9170 | |||
| 9171 | # This version fixes a flaw in the world model, in which room tags aren't deleted | ||
| 9172 | # when a whole region is deleted | ||
| 9173 | foreach my $tag ($wmObj->ivKeys('roomTagHash')) { | ||
| 9174 | |||
| 9175 | my ($roomNum, $roomObj); | ||
| 9176 | |||
| 9177 | $roomNum = $wmObj->ivShow('roomTagHash', $tag); | ||
| 9178 | $roomObj = $wmObj->ivShow('roomModelHash', $roomNum); | ||
| 9179 | |||
| 9180 | if (! $roomObj || ! defined $roomObj->roomTag || $roomObj->roomTag ne $tag) { | ||
| 9181 | |||
| 9182 | $wmObj->ivDelete('roomTagHash', $tag); | ||
| 9183 | } | ||
| 9184 | } | ||
| 9185 | } | ||
| 9186 | |||
| 9187 | if ($version < 1_001_314) { | ||
| 9188 | |||
| 9189 | # This version adds a new IV to all map label objects | ||
| 9190 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 9191 | |||
| 9192 | foreach my $mapLabelObj ($regionmapObj->ivValues('gridLabelHash')) { | ||
| 9193 | |||
| 9194 | # e.g. 'town_42' | ||
| 9195 | $mapLabelObj->{id} = $mapLabelObj->{region} . '_' . $mapLabelObj->{number}; | ||
| 9196 | } | ||
| 9197 | } | ||
| 9198 | } | ||
| 9199 | |||
| 9200 | if ($version < 1_001_318) { | ||
| 9201 | |||
| 9202 | # Custom room flags did not have their ->customFlag IV set correctly. Fix it | ||
| 9203 | foreach my $roomFlagObj ($wmObj->ivValues('roomFlagHash')) { | ||
| 9204 | |||
| 9205 | if ($roomFlagObj->filter eq 'custom') { | ||
| 9206 | |||
| 9207 | $roomFlagObj->ivPoke('customFlag', TRUE); | ||
| 9208 | } | ||
| 9209 | } | ||
| 9210 | } | ||
| 9211 | |||
| 9212 | if ($version < 1_001_320) { | ||
| 9213 | |||
| 9214 | # This version removes an IV from region model objects | ||
| 9215 | foreach my $regionObj ($wmObj->ivValues('regionModelHash')) { | ||
| 9216 | |||
| 9217 | delete $regionObj->{regionmapObj}; | ||
| 9218 | } | ||
| 9219 | } | ||
| 9220 | |||
| 9221 | if ($version < 1_001_325) { | ||
| 9222 | |||
| 9223 | # This version adds new IVs room model objects | ||
| 9224 | foreach my $roomObj ($wmObj->ivValues('roomModelHash')) { | ||
| 9225 | |||
| 9226 | my $listRef; | ||
| 9227 | |||
| 9228 | if (! exists $roomObj->{invRepExitHash}) { | ||
| 9229 | |||
| 9230 | $roomObj->{involuntaryExitHash} = {}; | ||
| 9231 | $roomObj->ivEmpty('involuntaryExitHash'); | ||
| 9232 | $roomObj->{involuntaryExitPatternHash} = {}; | ||
| 9233 | $roomObj->ivEmpty('involuntaryExitPatternHash'); | ||
| 9234 | |||
| 9235 | # Convert ->involuntaryExitPatternList to the new IV | ||
| 9236 | $listRef = $roomObj->{involuntaryExitPatternList}; | ||
| 9237 | foreach my $pattern (@$listRef) { | ||
| 9238 | |||
| 9239 | $roomObj->ivAdd('involuntaryExitPatternHash', $pattern, undef); | ||
| 9240 | } | ||
| 9241 | |||
| 9242 | delete $roomObj->{involuntaryExitPatternList}; | ||
| 9243 | } | ||
| 9244 | } | ||
| 9245 | } | ||
| 9246 | |||
| 9247 | if ($version < 1_001_327) { | ||
| 9248 | |||
| 9249 | my %newHash; | ||
| 9250 | |||
| 9251 | # Room tags are supposed to be stored in lower-case letters. This version makes sure | ||
| 9252 | # that is so | ||
| 9253 | foreach my $tag ($wmObj->ivKeys('roomTagHash')) { | ||
| 9254 | |||
| 9255 | $newHash{lc($tag)} = $wmObj->ivShow('roomTagHash', $tag); | ||
| 9256 | } | ||
| 9257 | |||
| 9258 | $wmObj->ivPoke('roomTagHash', %newHash); | ||
| 9259 | |||
| 9260 | foreach my $roomObj ($wmObj->ivValues('roomModelHash')) { | ||
| 9261 | |||
| 9262 | my $listRef; | ||
| 9263 | |||
| 9264 | if (defined $roomObj->roomTag) { | ||
| 9265 | |||
| 9266 | $roomObj->ivPoke('roomTag', lc($roomObj->roomTag)); | ||
| 9267 | } | ||
| 9268 | |||
| 9269 | # This version also adds a new IV to room model objects, and renames an existing | ||
| 9270 | # one | ||
| 9271 | if (! exists $roomObj->{repulseExitPatternHash}) { | ||
| 9272 | |||
| 9273 | $roomObj->{repulseExitPatternHash} = {}; | ||
| 9274 | $roomObj->ivEmpty('repulseExitPatternHash'); | ||
| 9275 | |||
| 9276 | # Convert ->repulseExitPatternList to the new IV | ||
| 9277 | $listRef = $roomObj->{repulseExitPatternList}; | ||
| 9278 | foreach my $pattern (@$listRef) { | ||
| 9279 | |||
| 9280 | $roomObj->ivAdd('repulseExitPatternHash', $pattern, undef); | ||
| 9281 | } | ||
| 9282 | |||
| 9283 | delete $roomObj->{repulseExitPatternList}; | ||
| 9284 | |||
| 9285 | # Update the IV name | ||
| 9286 | $roomObj->{invRepExitHash} = $roomObj->{involuntaryExitHash}; | ||
| 9287 | delete $roomObj->{involuntaryExitHash}; | ||
| 9288 | } | ||
| 9289 | } | ||
| 9290 | } | ||
| 9291 | |||
| 9292 | if ($version < 1_001_328) { | ||
| 9293 | |||
| 9294 | my %regionHash; | ||
| 9295 | |||
| 9296 | # This version repairs some errors in exit model objects introduced in certain | ||
| 9297 | # situations | ||
| 9298 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 9299 | |||
| 9300 | my ($roomObj, $regionObj); | ||
| 9301 | |||
| 9302 | # At some point in the past, two-way exits had their ->oneWayDir IV wrongly set. | ||
| 9303 | # This problem does not apply to more recent Axmud versions. Just update all | ||
| 9304 | # exits | ||
| 9305 | if (! $exitObj->oneWayFlag && defined $exitObj->oneWayDir) { | ||
| 9306 | |||
| 9307 | $exitObj->ivUndef('oneWayDir'); | ||
| 9308 | } | ||
| 9309 | |||
| 9310 | # This error is fixed in this version | ||
| 9311 | if (! $exitObj->regionFlag && ($exitObj->superFlag || $exitObj->notSuperFlag)) { | ||
| 9312 | |||
| 9313 | $exitObj->ivPoke('superFlag', FALSE); | ||
| 9314 | $exitObj->ivPoke('notSuperFlag', FALSE); | ||
| 9315 | |||
| 9316 | $roomObj = $wmObj->ivShow('modelHash', $exitObj->parent); | ||
| 9317 | $regionObj = $wmObj->ivShow('modelHash', $roomObj->parent); | ||
| 9318 | |||
| 9319 | # Any region paths using the exits will have to be updated | ||
| 9320 | $wmObj->ivAdd('updatePathHash', $exitObj->number, $regionObj->name); | ||
| 9321 | $wmObj->ivAdd('updateBoundaryHash', $exitObj->number, $regionObj->name); | ||
| 9322 | } | ||
| 9323 | } | ||
| 9324 | } | ||
| 9325 | |||
| 9326 | if ($version < 1_001_329) { | ||
| 9327 | |||
| 9328 | my %checkHash; | ||
| 9329 | |||
| 9330 | $self->writeText('Applying essential world model update. Please be patient...'); | ||
| 9331 | $axmud::CLIENT->desktopObj->updateWidgets( | ||
| 9332 | $self->_objClass . '->updateExtractedData', | ||
| 9333 | ); | ||
| 9334 | |||
| 9335 | # When pathfinding routines were updated to allow paths through adjacent regions, | ||
| 9336 | # region paths may have been affected. In addition, there were some problems with | ||
| 9337 | # 'safe' region paths which are supposed to avoid rooms with hazardous room flags, | ||
| 9338 | # but which didn't (in certain situations) | ||
| 9339 | # Check all region paths and replace any whose rooms are not in the same region | ||
| 9340 | OUTER: foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 9341 | |||
| 9342 | INNER: foreach my $regionPathObj ($regionmapObj->ivValues('regionPathHash')) { | ||
| 9343 | |||
| 9344 | if (! exists $checkHash{$regionPathObj->startExit}) { | ||
| 9345 | |||
| 9346 | foreach my $roomNum ($regionPathObj->roomList) { | ||
| 9347 | |||
| 9348 | my ($roomObj, $firstExitObj); | ||
| 9349 | |||
| 9350 | # (For speed, don't use ->ivShow) | ||
| 9351 | $roomObj = $wmObj->{modelHash}{$roomNum}; | ||
| 9352 | $firstExitObj = $wmObj->{exitModelHash}{$regionPathObj->startExit}; | ||
| 9353 | |||
| 9354 | if ( | ||
| 9355 | $roomObj | ||
| 9356 | && $firstExitObj | ||
| 9357 | && $roomObj->parent ne $regionmapObj->number | ||
| 9358 | ) { | ||
| 9359 | # Any region paths using the first exit will have to be updated | ||
| 9360 | $wmObj->ivAdd( | ||
| 9361 | 'updatePathHash', | ||
| 9362 | $firstExitObj->number, | ||
| 9363 | $regionmapObj->name, | ||
| 9364 | ); | ||
| 9365 | |||
| 9366 | # (Only need to add each exit once) | ||
| 9367 | $checkHash{$regionPathObj->startExit} = undef; | ||
| 9368 | |||
| 9369 | # (Don't need to check the rest of the rooms in this path) | ||
| 9370 | next INNER; | ||
| 9371 | } | ||
| 9372 | } | ||
| 9373 | } | ||
| 9374 | } | ||
| 9375 | |||
| 9376 | # Update those region paths now | ||
| 9377 | if ($wmObj->updatePathHash) { | ||
| 9378 | |||
| 9379 | $wmObj->updateRegionPaths($self->session); | ||
| 9380 | } | ||
| 9381 | |||
| 9382 | # Now check for 'safe' region paths which should not have room with hazardous | ||
| 9383 | # room flags, but do | ||
| 9384 | INNER: foreach my $regionPathObj ( | ||
| 9385 | $regionmapObj->ivValues('safeRegionPathHash') | ||
| 9386 | ) { | ||
| 9387 | if (! exists $checkHash{$regionPathObj->startExit}) { | ||
| 9388 | |||
| 9389 | foreach my $roomNum ($regionPathObj->roomList) { | ||
| 9390 | |||
| 9391 | my ($roomObj, $firstExitObj); | ||
| 9392 | |||
| 9393 | # (For speed, don't use ->ivShow) | ||
| 9394 | $roomObj = $wmObj->{modelHash}{$roomNum}; | ||
| 9395 | $firstExitObj = $wmObj->{exitModelHash}{$regionPathObj->startExit}; | ||
| 9396 | |||
| 9397 | foreach my $roomFlag ($roomObj->ivKeys('roomFlagHash')) { | ||
| 9398 | |||
| 9399 | if ( | ||
| 9400 | $axmud::CLIENT->ivExists('constRoomHazardHash', $roomFlag) | ||
| 9401 | ) { | ||
| 9402 | $regionmapObj->removePaths( | ||
| 9403 | $regionPathObj->startExit . '_' | ||
| 9404 | . $regionPathObj->stopExit, | ||
| 9405 | 'safeRegionPathHash', | ||
| 9406 | ); | ||
| 9407 | |||
| 9408 | # (Don't need to check the rest of the rooms in this path) | ||
| 9409 | next INNER; | ||
| 9410 | } | ||
| 9411 | } | ||
| 9412 | } | ||
| 9413 | } | ||
| 9414 | } | ||
| 9415 | } | ||
| 9416 | } | ||
| 9417 | |||
| 9418 | if ($version < 1_001_335) { | ||
| 9419 | |||
| 9420 | # This version fixes a bug in which each regionmap's highest and lowest occupied | ||
| 9421 | # levels were set only with rooms, not with rooms and labels | ||
| 9422 | # Reset all highest/lowest levels | ||
| 9423 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 9424 | |||
| 9425 | $wmObj->ivAdd('checkLevelsHash', $regionmapObj->name, undef); | ||
| 9426 | } | ||
| 9427 | |||
| 9428 | $wmObj->updateRegionLevels(); | ||
| 9429 | } | ||
| 9430 | |||
| 9431 | if ($version < 1_001_358) { | ||
| 9432 | |||
| 9433 | # This version adds new IVs to the world model | ||
| 9434 | if (! exists $wmObj->{preDrawMinRooms}) { | ||
| 9435 | |||
| 9436 | $wmObj->{preDrawMinRooms} = undef; | ||
| 9437 | $wmObj->ivPoke('preDrawMinRooms', 500); | ||
| 9438 | $wmObj->{queueDrawMaxObjs} = undef; | ||
| 9439 | $wmObj->ivPoke('queueDrawMaxObjs', 500); | ||
| 9440 | } | ||
| 9441 | } | ||
| 9442 | |||
| 9443 | # if ($version < 1_001_358) { | ||
| 9444 | # | ||
| 9445 | # # This version adds new IVs to the world model | ||
| 9446 | # if (! exists $wmObj->{fixedRoomTagFlag}) { | ||
| 9447 | # | ||
| 9448 | # $wmObj->{fixedRoomTagFlag} = undef; | ||
| 9449 | # $wmObj->ivPoke('fixedRoomTagFlag', FALSE); | ||
| 9450 | # $wmObj->{fixedRoomGuildFlag} = undef; | ||
| 9451 | # $wmObj->ivPoke('fixedRoomGuildFlag', FALSE); | ||
| 9452 | # $wmObj->{fixedExitTagFlag} = undef; | ||
| 9453 | # $wmObj->ivPoke('fixedExitTagFlag', FALSE); | ||
| 9454 | # $wmObj->{fixedLabelFlag} = undef; | ||
| 9455 | # $wmObj->ivPoke('fixedLabelFlag', FALSE); | ||
| 9456 | # } | ||
| 9457 | # } | ||
| 9458 | |||
| 9459 | if ($version < 1_001_376) { | ||
| 9460 | |||
| 9461 | # This version adds a new IV to the world model | ||
| 9462 | if (! exists $wmObj->{retainDrawMinRooms}) { | ||
| 9463 | |||
| 9464 | $wmObj->{retainDrawMinRooms} = undef; | ||
| 9465 | $wmObj->ivPoke('retainDrawMinRooms', 500); | ||
| 9466 | } | ||
| 9467 | } | ||
| 9468 | |||
| 9469 | if ($version < 1_001_408) { | ||
| 9470 | |||
| 9471 | # This version compresses the world model. Before we do that, the ->_objName and | ||
| 9472 | # ->name IVs for room model object have become standardised, no longer depending | ||
| 9473 | # on the room's title or verbose description; update all room objects | ||
| 9474 | foreach my $roomObj ($wmObj->ivValues('roomModelHash')) { | ||
| 9475 | |||
| 9476 | $roomObj->{_objName} = 'room'; | ||
| 9477 | $roomObj->{name} = 'room'; | ||
| 9478 | } | ||
| 9479 | |||
| 9480 | # Same for exit object, which no longer take the exit's direction as its ->name | ||
| 9481 | # (since the direction can change anyway) | ||
| 9482 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 9483 | |||
| 9484 | $exitObj->{_objName} = 'exit'; | ||
| 9485 | $exitObj->{name} = 'exit'; | ||
| 9486 | } | ||
| 9487 | |||
| 9488 | # Now we can compress the world model. For each room object and exit object, any IVs | ||
| 9489 | # which are set to default values can be completely removed. The new code gets its | ||
| 9490 | # default values from the room object and the exit object stored in the global | ||
| 9491 | # variables $DEFAULT_ROOM and $DEFAULT EXIT | ||
| 9492 | if ($wmObj->{modelHash}) { | ||
| 9493 | |||
| 9494 | $self->writeText('Applying essential world model update. Please be patient...'); | ||
| 9495 | $axmud::CLIENT->desktopObj->updateWidgets( | ||
| 9496 | $self->_objClass . '->updateExtractedData', | ||
| 9497 | ); | ||
| 9498 | } | ||
| 9499 | |||
| 9500 | foreach my $roomObj ($wmObj->ivValues('roomModelHash')) { | ||
| 9501 | |||
| 9502 | $roomObj->compress(); | ||
| 9503 | } | ||
| 9504 | |||
| 9505 | foreach my $exitObj ($wmObj->ivValues('exitModelHash')) { | ||
| 9506 | |||
| 9507 | $exitObj->compress(); | ||
| 9508 | } | ||
| 9509 | |||
| 9510 | # (This line makes sure the correct file object's ->modifyFlag is set) | ||
| 9511 | $wmObj->ivPoke('author', $wmObj->author); | ||
| 9512 | } | ||
| 9513 | |||
| 9514 | if ($version < 1_001_409) { | ||
| 9515 | |||
| 9516 | # This version adds a new IV to the world model | ||
| 9517 | if (! exists $wmObj->{roomFlagShowMode}) { | ||
| 9518 | |||
| 9519 | $wmObj->{roomFlagShowMode} = undef; | ||
| 9520 | $wmObj->ivPoke('roomFlagShowMode', 'default'); | ||
| 9521 | } | ||
| 9522 | } | ||
| 9523 | |||
| 9524 | if ($version < 1_001_450) { | ||
| 9525 | |||
| 9526 | # This version removes IVs from the world model | ||
| 9527 | delete $wmObj->{fixedRoomTagFlag}; | ||
| 9528 | delete $wmObj->{fixedRoomGuildFlag}; | ||
| 9529 | delete $wmObj->{fixedExitTagFlag}; | ||
| 9530 | delete $wmObj->{fixedLabelFlag}; | ||
| 9531 | |||
| 9532 | # Also, the ->_objClass for room objects was set to the class of an exit object | ||
| 9533 | # instead, so let's fix that | ||
| 9534 | foreach my $roomObj ($wmObj->ivValues('roomModelHash')) { | ||
| 9535 | |||
| 9536 | $roomObj->{_objClass} = ref $roomObj; | ||
| 9537 | } | ||
| 9538 | |||
| 9539 | if ($wmObj->{painterObj}) { | ||
| 9540 | |||
| 9541 | $wmObj->{painterObj}->{_objClass} = ref $wmObj->{painterObj}; | ||
| 9542 | } | ||
| 9543 | } | ||
| 9544 | |||
| 9545 | if ($version < 1_001_453) { | ||
| 9546 | |||
| 9547 | # This version adds a new IV to the world model | ||
| 9548 | if (! exists $wmObj->{blockUnselectFlag}) { | ||
| 9549 | |||
| 9550 | $wmObj->{blockUnselectFlag} = undef; | ||
| 9551 | $wmObj->ivPoke('blockUnselectFlag', TRUE); | ||
| 9552 | } | ||
| 9553 | } | ||
| 9554 | |||
| 9555 | if ($version < 1_001_456) { | ||
| 9556 | |||
| 9557 | # This version adds a new IV to the world model | ||
| 9558 | if (! exists $wmObj->{queueDrawMaxExits}) { | ||
| 9559 | |||
| 9560 | $wmObj->{queueDrawMaxExits} = undef; | ||
| 9561 | $wmObj->ivPoke('queueDrawMaxExits', 150); | ||
| 9562 | } | ||
| 9563 | } | ||
| 9564 | |||
| 9565 | if ($version < 1_001_465) { | ||
| 9566 | |||
| 9567 | # This version replaces an IV in map labels and map label styles | ||
| 9568 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 9569 | |||
| 9570 | foreach my $labelObj ($regionmapObj->ivValues('gridLabelHash')) { | ||
| 9571 | |||
| 9572 | delete $labelObj->{gravity}; | ||
| 9573 | |||
| 9574 | $labelObj->{rotateAngle} = undef; | ||
| 9575 | $labelObj->ivPoke('rotateAngle', 0); | ||
| 9576 | } | ||
| 9577 | } | ||
| 9578 | |||
| 9579 | foreach my $styleObj ($wmObj->ivValues('mapLabelStyleHash')) { | ||
| 9580 | |||
| 9581 | delete $styleObj->{gravity}; | ||
| 9582 | |||
| 9583 | $styleObj->{rotateAngle} = undef; | ||
| 9584 | $styleObj->ivPoke('rotateAngle', 0); | ||
| 9585 | } | ||
| 9586 | |||
| 9587 | } | ||
| 9588 | |||
| 9589 | if ($version < 1_001_517) { | ||
| 9590 | |||
| 9591 | # This version changes the IVs used in pre-drawing operations | ||
| 9592 | if (! exists $wmObj->{preDrawAllowFlag}) { | ||
| 9593 | |||
| 9594 | $wmObj->{preDrawAllowFlag} = undef; | ||
| 9595 | $wmObj->ivPoke('preDrawAllowFlag', TRUE); | ||
| 9596 | |||
| 9597 | $wmObj->{preDrawRetainRooms} = undef; | ||
| 9598 | $wmObj->ivPoke('preDrawRetainRooms', $wmObj->{retainDrawMinRooms}); | ||
| 9599 | delete $wmObj->{retainDrawMinRooms}; | ||
| 9600 | |||
| 9601 | delete $wmObj->{queueDrawMaxObjs}; | ||
| 9602 | delete $wmObj->{queueDrawMaxExits}; | ||
| 9603 | |||
| 9604 | $wmObj->{preDrawAllocation} = undef; | ||
| 9605 | $wmObj->ivPoke('preDrawAllocation', 50); | ||
| 9606 | } | ||
| 9607 | } | ||
| 9608 | |||
| 9609 | if ($version < 1_001_529) { | ||
| 9610 | |||
| 9611 | # This version adds a new IV to the world model | ||
| 9612 | if (! exists $wmObj->{modelSaveFileCount}) { | ||
| 9613 | |||
| 9614 | $wmObj->{modelSaveFileCount} = undef; | ||
| 9615 | $wmObj->ivPoke('modelSaveFileCount', 0); | ||
| 9616 | } | ||
| 9617 | } | ||
| 9618 | |||
| 9619 | if ($version < 1_002_091) { | ||
| 9620 | |||
| 9621 | # This version adds new IVs to the world model | ||
| 9622 | if (! exists $wmObj->{obscuredExitFlag}) { | ||
| 9623 | |||
| 9624 | $wmObj->{obscuredExitFlag} = undef; | ||
| 9625 | $wmObj->ivPoke('obscuredExitFlag', FALSE); | ||
| 9626 | $wmObj->{obscuredExitRadius} = undef; | ||
| 9627 | $wmObj->ivPoke('obscuredExitRadius', 3); | ||
| 9628 | $wmObj->{maxObscuredExitRadius} = undef; | ||
| 9629 | $wmObj->ivPoke('maxObscuredExitRadius', 9); | ||
| 9630 | $wmObj->{obscuredExitRedrawFlag} = undef; | ||
| 9631 | $wmObj->ivPoke('obscuredExitRedrawFlag', FALSE); | ||
| 9632 | } | ||
| 9633 | |||
| 9634 | # ...and to regionmaps | ||
| 9635 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 9636 | |||
| 9637 | if (! exists $regionmapObj->{obscuredExitFlag}) { | ||
| 9638 | |||
| 9639 | $regionmapObj->{obscuredExitFlag} = undef; | ||
| 9640 | $regionmapObj->ivPoke('obscuredExitFlag', FALSE); | ||
| 9641 | $regionmapObj->{obscuredExitRadius} = undef; | ||
| 9642 | $regionmapObj->ivPoke('obscuredExitRadius', 3); | ||
| 9643 | |||
| 9644 | $regionmapObj->{drawOrnamentsFlag} = undef; | ||
| 9645 | if ($wmObj->drawExitMode eq 'ask_regionmap') { | ||
| 9646 | $regionmapObj->ivPoke('drawOrnamentsFlag', $wmObj->drawOrnamentsFlag); | ||
| 9647 | } else { | ||
| 9648 | $regionmapObj->ivPoke('drawOrnamentsFlag', FALSE); | ||
| 9649 | } | ||
| 9650 | |||
| 9651 | $regionmapObj->{obscuredExitRedrawFlag} = undef; | ||
| 9652 | $regionmapObj->ivPoke('obscuredExitRedrawFlag', FALSE); | ||
| 9653 | } | ||
| 9654 | } | ||
| 9655 | } | ||
| 9656 | |||
| 9657 | if ($version < 1_002_150) { | ||
| 9658 | |||
| 9659 | # This version adds region schemes | ||
| 9660 | if (! exists $wmObj->{regionSchemeHash}) { | ||
| 9661 | |||
| 9662 | # Remove colour IVs from the world model, and transfer them to a new 'default' | ||
| 9663 | # region scheme | ||
| 9664 | $wmObj->{regionSchemeHash} = {}; | ||
| 9665 | |||
| 9666 | $wmObj->{defaultSchemeObj} = undef; | ||
| 9667 | $wmObj->ivPoke( | ||
| 9668 | 'defaultSchemeObj', | ||
| 9669 | Games::Axmud::Obj::RegionScheme->new($self->session, $wmObj, 'default'), | ||
| 9670 | ); | ||
| 9671 | |||
| 9672 | $wmObj->ivAdd('regionSchemeHash', 'default', $wmObj->defaultSchemeObj); | ||
| 9673 | |||
| 9674 | foreach my $iv ( | ||
| 9675 | qw( | ||
| 9676 | backgroundColour roomColour roomTextColour selectBoxColour borderColour | ||
| 9677 | currentBorderColour currentFollowBorderColour currentWaitBorderColour | ||
| 9678 | currentSelectBorderColour lostBorderColour lostSelectBorderColour | ||
| 9679 | ghostBorderColour ghostSelectBorderColour selectBorderColour | ||
| 9680 | roomAboveColour roomBelowColour roomTagColour selectRoomTagColour | ||
| 9681 | roomGuildColour selectRoomGuildColour exitColour selectExitColour | ||
| 9682 | selectExitTwinColour selectExitShadowColour randomExitColour | ||
| 9683 | impassableExitColour mysteryExitColour checkedDirColour dragExitColour | ||
| 9684 | exitTagColour selectExitTagColour mapLabelColour selectMapLabelColour | ||
| 9685 | ) | ||
| 9686 | ) { | ||
| 9687 | # (All but on IV is copied to the new scheme object) | ||
| 9688 | if ($iv ne 'noBackgroundColour') { | ||
| 9689 | |||
| 9690 | $wmObj->defaultSchemeObj->{$iv} = $wmObj->{$iv}; | ||
| 9691 | } | ||
| 9692 | |||
| 9693 | delete $wmObj->{$iv}; | ||
| 9694 | } | ||
| 9695 | |||
| 9696 | # Add a new IV to regionmaps | ||
| 9697 | foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) { | ||
| 9698 | |||
| 9699 | if (! exists $regionmapObj->{regionScheme}) { | ||
| 9700 | |||
| 9701 | $regionmapObj->{regionScheme} = undef; | ||
| 9702 | $regionmapObj->ivUndef('regionScheme'); | ||
| 9703 | } | ||
| 9704 | } | ||
| 9705 | } | ||
| 9706 | } | ||
| 9707 | |||
| 9708 | if ($version < 1_003_003) { | ||
| 9709 | |||
| 9710 | # This version fixes a typo in a world model IV | ||
| 9711 | if (! exists $wmObj->{maxObscuredExitRadius}) { | ||
| 9712 | |||
| 9713 | $wmObj->{maxObscuredExitRadius} = undef; | ||
| 9714 | $wmObj->ivPoke('maxObscuredExitRadius', 9); | ||
| 9715 | delete $wmObj->{maxobscuredExitRadius}; | ||
| 9716 | } | ||
| 9717 | } | ||
| 9718 | |||
| 9719 | if ($version < 1_003_017) { | ||
| 9720 | |||
| 9721 | # This version adds new IVs to the world model | ||
| 9722 | if (! exists $wmObj->{roomInteriorXOffset}) { | ||
| 9723 | |||
| 9724 | $wmObj->{roomInteriorXOffset} = undef; | ||
| 9725 | $wmObj->ivPoke('roomInteriorXOffset', 0); | ||
| 9726 | $wmObj->{roomInteriorYOffset} = undef; | ||
| 9727 | $wmObj->ivPoke('roomInteriorYOffset', 0); | ||
| 9728 | } | ||
| 9729 | } | ||
| 9730 | |||
| 9731 | if ($version < 1_003_080) { | ||
| 9732 | |||
| 9733 | # This version adds new IVs to the all regions | ||
| 9734 | foreach my $regionObj ($wmObj->ivValues('regionModelHash')) { | ||
| 9735 | |||
| 9736 | if (! exists $regionObj->{finishedFlag}) { | ||
| 9737 | |||
| 9738 | $regionObj->{finishedFlag} = undef; | ||
| 9739 | $regionObj->ivPoke('finishedFlag', FALSE); | ||
| 9740 | } | ||
| 9741 | } | ||
| 9742 | } | ||
| 9743 | } | ||
| 9744 | |||
| 9745 | ### new built-in tasks (new IVs for existing tasks are below) ############################# | ||
| 9746 | |||
| 9747 | if ($self->fileType eq 'tasks') { | ||
| 9748 | |||
| 9749 | if ($version < 1_000_342) { | ||
| 9750 | |||
| 9751 | # This version adds a new built-in task. GA::Client->taskLabelHash must be updated, | ||
| 9752 | # but don't overwrite existing entries | ||
| 9753 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'debug')) { | ||
| 9754 | |||
| 9755 | $axmud::CLIENT->ivAdd('taskLabelHash', 'debug', 'debugger_task'); | ||
| 9756 | } | ||
| 9757 | |||
| 9758 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'debugger')) { | ||
| 9759 | |||
| 9760 | $axmud::CLIENT->ivAdd('taskLabelHash', 'debugger', 'debugger_task'); | ||
| 9761 | } | ||
| 9762 | } | ||
| 9763 | |||
| 9764 | if ($version < 1_000_424) { | ||
| 9765 | |||
| 9766 | # This version adds two new built-in tasks | ||
| 9767 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'raw')) { | ||
| 9768 | |||
| 9769 | $axmud::CLIENT->ivAdd('taskLabelHash', 'raw', 'raw_text_task'); | ||
| 9770 | } | ||
| 9771 | |||
| 9772 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'rawtext')) { | ||
| 9773 | |||
| 9774 | $axmud::CLIENT->ivAdd('taskLabelHash', 'rawtext', 'raw_text_task'); | ||
| 9775 | } | ||
| 9776 | |||
| 9777 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'token')) { | ||
| 9778 | |||
| 9779 | $axmud::CLIENT->ivAdd('taskLabelHash', 'token', 'raw_token_task'); | ||
| 9780 | } | ||
| 9781 | |||
| 9782 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'rawtoken')) { | ||
| 9783 | |||
| 9784 | $axmud::CLIENT->ivAdd('taskLabelHash', 'rawtoken', 'raw_token_task'); | ||
| 9785 | } | ||
| 9786 | } | ||
| 9787 | |||
| 9788 | if ($version < 1_000_622) { | ||
| 9789 | |||
| 9790 | # This version adds a new built-in task | ||
| 9791 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'note')) { | ||
| 9792 | |||
| 9793 | $axmud::CLIENT->ivAdd('taskLabelHash', 'note', 'notepad_task'); | ||
| 9794 | } | ||
| 9795 | |||
| 9796 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'notes')) { | ||
| 9797 | |||
| 9798 | $axmud::CLIENT->ivAdd('taskLabelHash', 'notes', 'notepad_task'); | ||
| 9799 | } | ||
| 9800 | |||
| 9801 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'notepad')) { | ||
| 9802 | |||
| 9803 | $axmud::CLIENT->ivAdd('taskLabelHash', 'notepad', 'notepad_task'); | ||
| 9804 | } | ||
| 9805 | } | ||
| 9806 | |||
| 9807 | if ($version < 1_000_827) { | ||
| 9808 | |||
| 9809 | # This version adds a new built-in task | ||
| 9810 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'frame')) { | ||
| 9811 | |||
| 9812 | $axmud::CLIENT->ivAdd('taskLabelHash', 'frame', 'frame_task'); | ||
| 9813 | } | ||
| 9814 | } | ||
| 9815 | |||
| 9816 | if ($version < 1_000_881) { | ||
| 9817 | |||
| 9818 | # This version adds a new built-in task | ||
| 9819 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'launch')) { | ||
| 9820 | |||
| 9821 | $axmud::CLIENT->ivAdd('taskLabelHash', 'launch', 'launch_task'); | ||
| 9822 | $axmud::CLIENT->ivAdd('taskLabelHash', 'launcher', 'launch_task'); | ||
| 9823 | } | ||
| 9824 | } | ||
| 9825 | |||
| 9826 | if ($version < 1_001_127) { | ||
| 9827 | |||
| 9828 | # This version adds a new built-in task | ||
| 9829 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'channels')) { | ||
| 9830 | |||
| 9831 | $axmud::CLIENT->ivAdd('taskLabelHash', 'chan', 'channels_task'); | ||
| 9832 | $axmud::CLIENT->ivAdd('taskLabelHash', 'channel', 'channels_task'); | ||
| 9833 | $axmud::CLIENT->ivAdd('taskLabelHash', 'channels', 'channels_task'); | ||
| 9834 | } | ||
| 9835 | } | ||
| 9836 | |||
| 9837 | if ($version < 1_001_164) { | ||
| 9838 | |||
| 9839 | # This version renames the built-in Debugger task as the System task. Existing | ||
| 9840 | # Debugger tasks are updated below | ||
| 9841 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'debugger')) { | ||
| 9842 | |||
| 9843 | $axmud::CLIENT->ivDelete('taskLabelHash', 'debug'); | ||
| 9844 | $axmud::CLIENT->ivDelete('taskLabelHash', 'debugger'); | ||
| 9845 | |||
| 9846 | $axmud::CLIENT->ivAdd('taskLabelHash', 'sys', 'system_task'); | ||
| 9847 | $axmud::CLIENT->ivAdd('taskLabelHash', 'system', 'system_task'); | ||
| 9848 | } | ||
| 9849 | } | ||
| 9850 | |||
| 9851 | if ($version < 1_001_386) { | ||
| 9852 | |||
| 9853 | # This version adds new built-in tasks | ||
| 9854 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'countdown')) { | ||
| 9855 | |||
| 9856 | $axmud::CLIENT->ivAdd('taskLabelHash', 'cd', 'countdown_task'); | ||
| 9857 | $axmud::CLIENT->ivAdd('taskLabelHash', 'count', 'countdown_task'); | ||
| 9858 | $axmud::CLIENT->ivAdd('taskLabelHash', 'countdown', 'countdown_task'); | ||
| 9859 | |||
| 9860 | $axmud::CLIENT->ivAdd('taskLabelHash', 'mc', 'map_check_task'); | ||
| 9861 | $axmud::CLIENT->ivAdd('taskLabelHash', 'map', 'map_check_task'); | ||
| 9862 | $axmud::CLIENT->ivAdd('taskLabelHash', 'mapcheck', 'map_check_task'); | ||
| 9863 | } | ||
| 9864 | } | ||
| 9865 | |||
| 9866 | if ($version < 1_001_388) { | ||
| 9867 | |||
| 9868 | # This version adds a new built-in task | ||
| 9869 | if (! $axmud::CLIENT->ivExists('taskLabelHash', 'connections')) { | ||
| 9870 | |||
| 9871 | $axmud::CLIENT->ivAdd('taskLabelHash', 'conn', 'connections_task'); | ||
| 9872 | $axmud::CLIENT->ivAdd('taskLabelHash', 'connect', 'connections_task'); | ||
| 9873 | $axmud::CLIENT->ivAdd('taskLabelHash', 'connections', 'connections_task'); | ||
| 9874 | } | ||
| 9875 | } | ||
| 9876 | } | ||
| 9877 | |||
| 9878 | ### worldprof / otherprof / tasks ######################################################### | ||
| 9879 | |||
| 9880 | if ( | ||
| 9881 | $self->fileType eq 'worldprof' | ||
| 9882 | || $self->fileType eq 'otherprof' | ||
| 9883 | || $self->fileType eq 'tasks' | ||
| 9884 | ) { | ||
| 9885 | if ($version < 1_000_037 && $self->session) { | ||
| 9886 | |||
| 9887 | # This version updated the Locator task with a new IV. Update all initial/custom | ||
| 9888 | # tasks | ||
| 9889 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 9890 | |||
| 9891 | if (! exists $taskObj->{lastStatementEndLine}) { | ||
| 9892 | |||
| 9893 | $taskObj->{lastStatementEndLine} = undef; | ||
| 9894 | $taskObj->ivUndef('lastStatementEndLine'); | ||
| 9895 | } | ||
| 9896 | } | ||
| 9897 | } | ||
| 9898 | |||
| 9899 | if ($version < 1_000_066 && $self->session) { | ||
| 9900 | |||
| 9901 | # This version updated the Attack task with a new IV. Update all initial/custom | ||
| 9902 | # tasks | ||
| 9903 | foreach my $taskObj ($self->compileTasks('attack_task')) { | ||
| 9904 | |||
| 9905 | if (! exists $taskObj->{announceFlag}) { | ||
| 9906 | |||
| 9907 | $taskObj->{announceFlag} = undef; | ||
| 9908 | $taskObj->ivPoke('announceFlag', TRUE); | ||
| 9909 | } | ||
| 9910 | } | ||
| 9911 | } | ||
| 9912 | |||
| 9913 | if ($version < 1_000_078 && $self->session) { | ||
| 9914 | |||
| 9915 | # This version updated the Locator task with a new IV. Update all initial/custom | ||
| 9916 | # tasks | ||
| 9917 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 9918 | |||
| 9919 | if (! exists $taskObj->{restartBufferLine}) { | ||
| 9920 | |||
| 9921 | $taskObj->{restartBufferLine} = undef; | ||
| 9922 | $taskObj->ivUndef('restartBufferLine'); | ||
| 9923 | } | ||
| 9924 | } | ||
| 9925 | } | ||
| 9926 | |||
| 9927 | if ($version < 1_000_081 && $self->session) { | ||
| 9928 | |||
| 9929 | # This version updated the Inventory task with a new IV. Update all initial/custom | ||
| 9930 | # tasks | ||
| 9931 | foreach my $taskObj ($self->compileTasks('inventory_task')) { | ||
| 9932 | |||
| 9933 | if (! exists $taskObj->{resetInventoryFlag}) { | ||
| 9934 | |||
| 9935 | $taskObj->{resetInventoryFlag} = undef; | ||
| 9936 | $taskObj->ivPoke('resetInventoryFlag', FALSE); | ||
| 9937 | } | ||
| 9938 | } | ||
| 9939 | } | ||
| 9940 | |||
| 9941 | if ($version < 1_000_090 && $self->session) { | ||
| 9942 | |||
| 9943 | # This version updates the Status task, using a single string (e.g. | ||
| 9944 | # 'health_points_max') rather than two strings to represent the same thing (e.g. | ||
| 9945 | # 'health_max', 'health_points_max' | ||
| 9946 | my %updateHash = ( | ||
| 9947 | '@health_max@' => '@health_points_max@', | ||
| 9948 | '@magic_max@' => '@magic_points_max@', | ||
| 9949 | '@energy_max@' => '@energy_points_max@', | ||
| 9950 | '@guild_max@' => '@guild_points_max@', | ||
| 9951 | '@social_max@' => '@social_points_max@', | ||
| 9952 | ); | ||
| 9953 | |||
| 9954 | # Update all initial/custom tasks | ||
| 9955 | # (NB The world profile themselves were updated above) | ||
| 9956 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 9957 | |||
| 9958 | my $listRef; | ||
| 9959 | |||
| 9960 | $listRef = $taskObj->{defaultFormatList}; | ||
| 9961 | foreach my $line (@$listRef) { | ||
| 9962 | |||
| 9963 | foreach my $key (keys %updateHash) { | ||
| 9964 | |||
| 9965 | my $value = $updateHash{$key}; | ||
| 9966 | |||
| 9967 | $line =~ s/$key/$value/g; | ||
| 9968 | } | ||
| 9969 | } | ||
| 9970 | |||
| 9971 | $listRef = $taskObj->{displayVarList}; | ||
| 9972 | foreach my $line (@$listRef) { | ||
| 9973 | |||
| 9974 | foreach my $key (keys %updateHash) { | ||
| 9975 | |||
| 9976 | my $value = $updateHash{$key}; | ||
| 9977 | |||
| 9978 | $line =~ s/$key/$value/g; | ||
| 9979 | } | ||
| 9980 | } | ||
| 9981 | } | ||
| 9982 | } | ||
| 9983 | |||
| 9984 | if ($version < 1_000_119 && $self->session) { | ||
| 9985 | |||
| 9986 | # This version updates all tasks with a new flag IV. Its value is set to TRUE for | ||
| 9987 | # the Inventory, Locator, Status and TaskList tasks, FALSE for everything else | ||
| 9988 | my %trueHash = ( | ||
| 9989 | 'inventory_task' => undef, | ||
| 9990 | 'locator_task' => undef, | ||
| 9991 | 'status_task' => undef, | ||
| 9992 | 'tasklist_task' => undef, | ||
| 9993 | ); | ||
| 9994 | |||
| 9995 | foreach my $taskObj ($self->compileTasks()) { | ||
| 9996 | |||
| 9997 | if (! exists $taskObj->{noScrollFlag}) { | ||
| 9998 | |||
| 9999 | $taskObj->{noScrollFlag} = undef; | ||
| 10000 | |||
| 10001 | if (exists $trueHash{$taskObj->{name}}) { | ||
| 10002 | $taskObj->{noScrollFlag} = TRUE; | ||
| 10003 | } else { | ||
| 10004 | $taskObj->{noScrollFlag} = FALSE; | ||
| 10005 | } | ||
| 10006 | } | ||
| 10007 | } | ||
| 10008 | } | ||
| 10009 | |||
| 10010 | if ($version < 1_000_155 && $self->session) { | ||
| 10011 | |||
| 10012 | # This version updated the Locator task with a new IV. Update all initial/custom | ||
| 10013 | # tasks | ||
| 10014 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 10015 | |||
| 10016 | if (! exists $taskObj->{lastStatementStartLine}) { | ||
| 10017 | |||
| 10018 | $taskObj->{lastStatementStartLine} = undef; | ||
| 10019 | $taskObj->ivUndef('lastStatementStartLine'); | ||
| 10020 | } | ||
| 10021 | } | ||
| 10022 | } | ||
| 10023 | |||
| 10024 | if ($version < 1_000_198 && $self->session) { | ||
| 10025 | |||
| 10026 | # This version updated the Status task with new IVs. Update all initial/custom | ||
| 10027 | # tasks | ||
| 10028 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10029 | |||
| 10030 | if (! exists $taskObj->{xpNextLevel}) { | ||
| 10031 | |||
| 10032 | # (This IV subsequently renamed and/or removed) | ||
| 10033 | # $taskObj->{xpNextLevel} = undef; | ||
| 10034 | # $taskObj->ivUndef('xpNextLevel'); | ||
| 10035 | $taskObj->{xpNextLevel} = undef; | ||
| 10036 | # (This IV subsequently renamed and/or removed) | ||
| 10037 | # $taskObj->{alignment} = undef; | ||
| 10038 | # $taskObj->ivUndef('alignment'); | ||
| 10039 | $taskObj->{alignment} = undef; | ||
| 10040 | $taskObj->{affectHash} = {}; | ||
| 10041 | $taskObj->ivEmpty('affectHash'); | ||
| 10042 | |||
| 10043 | $taskObj->{oppName} = undef; | ||
| 10044 | $taskObj->ivUndef('oppName'); | ||
| 10045 | $taskObj->{oppHealth} = undef; | ||
| 10046 | $taskObj->ivUndef('oppHealth'); | ||
| 10047 | $taskObj->{oppHealthMax} = undef; | ||
| 10048 | $taskObj->ivUndef('oppHealthMax'); | ||
| 10049 | $taskObj->{oppLevel} = undef; | ||
| 10050 | $taskObj->ivUndef('oppLevel'); | ||
| 10051 | $taskObj->{oppStrength} = undef; | ||
| 10052 | $taskObj->ivUndef('oppStrength'); | ||
| 10053 | } | ||
| 10054 | } | ||
| 10055 | } | ||
| 10056 | |||
| 10057 | if ($version < 1_000_200 && $self->session) { | ||
| 10058 | |||
| 10059 | # This version updated the Locator task with a new IV. Update all initial/custom | ||
| 10060 | # tasks | ||
| 10061 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 10062 | |||
| 10063 | if (! exists $taskObj->{msdpRoomHash}) { | ||
| 10064 | |||
| 10065 | # (This IV subsequently renamed and/or removed) | ||
| 10066 | # $taskObj->{msdpRoomHash} = {}; | ||
| 10067 | # $taskObj->ivEmpty('msdpRoomHash'); | ||
| 10068 | $taskObj->{msdpRoomHash} = {}; | ||
| 10069 | # $taskObj->{msdpExitHash} = {}; | ||
| 10070 | # $taskObj->ivEmpty('msdpExitHash'); | ||
| 10071 | $taskObj->{msdpExitHash} = {}; | ||
| 10072 | } | ||
| 10073 | } | ||
| 10074 | } | ||
| 10075 | |||
| 10076 | if ($version < 1_000_212 && $self->session) { | ||
| 10077 | |||
| 10078 | # This version updated the Status task with a new IV. Update all initial/custom | ||
| 10079 | # tasks | ||
| 10080 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10081 | |||
| 10082 | if (! exists $taskObj->{customVarHash}) { | ||
| 10083 | |||
| 10084 | $taskObj->{customVarHash} = {}; | ||
| 10085 | $taskObj->ivEmpty('customVarHash'); | ||
| 10086 | } | ||
| 10087 | } | ||
| 10088 | } | ||
| 10089 | |||
| 10090 | if ($version < 1_000_344 && $self->session) { | ||
| 10091 | |||
| 10092 | # This version updated the Divert task with new IVs. Update all initial/custom | ||
| 10093 | # tasks | ||
| 10094 | foreach my $taskObj ($self->compileTasks('divert_task')) { | ||
| 10095 | |||
| 10096 | if (! exists $taskObj->{tellRoomFlag}) { | ||
| 10097 | |||
| 10098 | $taskObj->{tellRoomFlag} = undef; | ||
| 10099 | $taskObj->ivPoke('tellRoomFlag', FALSE); | ||
| 10100 | $taskObj->{socialRoomFlag} = undef; | ||
| 10101 | $taskObj->ivPoke('socialRoomFlag', FALSE); | ||
| 10102 | $taskObj->{customRoomFlag} = undef; | ||
| 10103 | $taskObj->ivPoke('customRoomFlag', FALSE); | ||
| 10104 | $taskObj->{warningRoomFlag} = undef; | ||
| 10105 | $taskObj->ivPoke('warningRoomFlag', FALSE); | ||
| 10106 | |||
| 10107 | $taskObj->{tellUrgencyFlag} = undef; | ||
| 10108 | $taskObj->ivPoke('tellUrgencyFlag', TRUE); | ||
| 10109 | $taskObj->{socialUrgencyFlag} = undef; | ||
| 10110 | $taskObj->ivPoke('socialUrgencyFlag', TRUE); | ||
| 10111 | $taskObj->{customUrgencyFlag} = undef; | ||
| 10112 | $taskObj->ivPoke('customUrgencyFlag', TRUE); | ||
| 10113 | $taskObj->{warningUrgencyFlag} = undef; | ||
| 10114 | $taskObj->ivPoke('warningUrgencyFlag', TRUE); | ||
| 10115 | } | ||
| 10116 | } | ||
| 10117 | } | ||
| 10118 | |||
| 10119 | if ($version < 1_000_424 && $self->session) { | ||
| 10120 | |||
| 10121 | # This version updated the Debugger task by changing its window type from 'entry' | ||
| 10122 | # to 'text'. Update all initial/custom tasks | ||
| 10123 | foreach my $taskObj ($self->compileTasks('debugger_task')) { | ||
| 10124 | |||
| 10125 | # (This IV subsequently renamed and/or removed) | ||
| 10126 | # $taskObj->{winType} = undef; | ||
| 10127 | # $taskObj->ivPoke('winType', 'text'); | ||
| 10128 | $taskObj->{winType} = 'text'; | ||
| 10129 | } | ||
| 10130 | } | ||
| 10131 | |||
| 10132 | if ($version < 1_000_482 && $self->session) { | ||
| 10133 | |||
| 10134 | # This version changes character life status. Update all initial/custom tasks | ||
| 10135 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10136 | |||
| 10137 | # (This IV subsequently renamed and/or removed) | ||
| 10138 | if ($taskObj->{lifeStatus} eq 'asleep') { | ||
| 10139 | # $taskObj->ivPoke('lifeStatus', 'sleep'); | ||
| 10140 | $taskObj->{lifeStatus} = 'sleep'; | ||
| 10141 | } elsif ($taskObj->{lifeStatus} eq 'passed_out') { | ||
| 10142 | # $taskObj->ivPoke('lifeStatus', 'passout'); | ||
| 10143 | $taskObj->{lifeStatus} = 'passout'; | ||
| 10144 | } | ||
| 10145 | } | ||
| 10146 | } | ||
| 10147 | |||
| 10148 | if ($version < 1_000_509 && $self->session) { | ||
| 10149 | |||
| 10150 | # This version updated the Status task with a new IV. Update all initial/custom | ||
| 10151 | # tasks | ||
| 10152 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10153 | |||
| 10154 | if (! exists $taskObj->{commifyMode}) { | ||
| 10155 | |||
| 10156 | $taskObj->{commifyMode} = undef; | ||
| 10157 | $taskObj->ivPoke('commifyMode', 0); | ||
| 10158 | } | ||
| 10159 | } | ||
| 10160 | } | ||
| 10161 | |||
| 10162 | if ($version < 1_000_572 && $self->session) { | ||
| 10163 | |||
| 10164 | # This version updated the Locator task with a new IV. Update all initial/custom | ||
| 10165 | # tasks | ||
| 10166 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 10167 | |||
| 10168 | if (! exists $taskObj->{autoLookMode}) { | ||
| 10169 | |||
| 10170 | $taskObj->{autoLookMode} = undef; | ||
| 10171 | $taskObj->ivPoke('autoLookMode', 1); | ||
| 10172 | } | ||
| 10173 | } | ||
| 10174 | } | ||
| 10175 | |||
| 10176 | if ($version < 1_000_577 && $self->session) { | ||
| 10177 | |||
| 10178 | # This version updated the Divert task with new IVs. Update all initial/custom | ||
| 10179 | # tasks | ||
| 10180 | foreach my $taskObj ($self->compileTasks('divert_task')) { | ||
| 10181 | |||
| 10182 | if (! exists $taskObj->{lastLine}) { | ||
| 10183 | |||
| 10184 | $taskObj->{lastLine} = undef; | ||
| 10185 | $taskObj->ivPoke('lastLine', 0); | ||
| 10186 | # (This IV subsequently renamed and/or removed) | ||
| 10187 | # $taskObj->{gagFlag} = undef; | ||
| 10188 | # $taskObj->ivPoke('gagFlag', TRUE); | ||
| 10189 | $taskObj->{gagFlag} = TRUE; | ||
| 10190 | } | ||
| 10191 | } | ||
| 10192 | } | ||
| 10193 | |||
| 10194 | if ($version < 1_000_580 && $self->session) { | ||
| 10195 | |||
| 10196 | # This version updated the Inventory task with a new IV. Update all initial/custom | ||
| 10197 | # tasks | ||
| 10198 | foreach my $taskObj ($self->compileTasks('inventory_task')) { | ||
| 10199 | |||
| 10200 | if (! exists $taskObj->{lastLine}) { | ||
| 10201 | |||
| 10202 | $taskObj->{lastLine} = undef; | ||
| 10203 | $taskObj->ivPoke('lastLine', 0); | ||
| 10204 | } | ||
| 10205 | } | ||
| 10206 | } | ||
| 10207 | |||
| 10208 | if ($version < 1_000_599 && $self->session) { | ||
| 10209 | |||
| 10210 | # This version updated the Locator and Status tasks with new IVs. Update all | ||
| 10211 | # initial/custom tasks | ||
| 10212 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 10213 | |||
| 10214 | if (! exists $taskObj->{ttsToReadHash}) { | ||
| 10215 | |||
| 10216 | $taskObj->{ttsToReadHash} = {}; | ||
| 10217 | $taskObj->ivEmpty('ttsToReadHash'); | ||
| 10218 | } | ||
| 10219 | } | ||
| 10220 | |||
| 10221 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10222 | |||
| 10223 | if (! exists $taskObj->{ttsPointsAlertHash}) { | ||
| 10224 | |||
| 10225 | $taskObj->{ttsPointsAlertHash} = {}; | ||
| 10226 | $taskObj->ivEmpty('ttsPointsAlertHash'); | ||
| 10227 | $taskObj->{ttsPointsAlertMsgHash} = {}; | ||
| 10228 | $taskObj->ivEmpty('ttsPointsAlertMsgHash'); | ||
| 10229 | } | ||
| 10230 | } | ||
| 10231 | } | ||
| 10232 | |||
| 10233 | if ($version < 1_000_606 && $self->session) { | ||
| 10234 | |||
| 10235 | # This version updated the Compass task with a new IV. Update all initial/custom | ||
| 10236 | # tasks | ||
| 10237 | foreach my $taskObj ($self->compileTasks('compass_task')) { | ||
| 10238 | |||
| 10239 | if (! exists $taskObj->{enabledFlag}) { | ||
| 10240 | |||
| 10241 | # (Existing users expect the task to start disabled, but new users will | ||
| 10242 | # see the task start enabled) | ||
| 10243 | $taskObj->{enabledFlag} = undef; | ||
| 10244 | $taskObj->ivPoke('enabledFlag', FALSE); | ||
| 10245 | |||
| 10246 | # (This IV subsequently renamed and/or removed) | ||
| 10247 | # $taskObj->{radioButton2} = undef; | ||
| 10248 | # $taskObj->ivUndef('radioButton2'); | ||
| 10249 | $taskObj->{radioButton2} = undef; | ||
| 10250 | } | ||
| 10251 | } | ||
| 10252 | } | ||
| 10253 | |||
| 10254 | if ($version < 1_000_607 && $self->session) { | ||
| 10255 | |||
| 10256 | # This version updates all tasks with a new IV, and removes another IV | ||
| 10257 | foreach my $taskObj ($self->compileTasks()) { | ||
| 10258 | |||
| 10259 | if (! exists $taskObj->{winUpdateFunc}) { | ||
| 10260 | |||
| 10261 | $taskObj->{winUpdateFunc} = undef; | ||
| 10262 | |||
| 10263 | if ($taskObj->{name} eq 'compass_task') { | ||
| 10264 | $taskObj->ivPoke('winUpdateFunc', 'createWidgets'); | ||
| 10265 | } elsif ($taskObj->{name} eq 'divert_task') { | ||
| 10266 | $taskObj->ivPoke('winUpdateFunc', 'restoreWin'); | ||
| 10267 | } elsif ($taskObj->{name} eq 'locator_task') { | ||
| 10268 | $taskObj->ivPoke('winUpdateFunc', 'updateWin'); | ||
| 10269 | } elsif ($taskObj->{name} eq 'status_task') { | ||
| 10270 | $taskObj->ivPoke('winUpdateFunc', 'updateWin'); | ||
| 10271 | } else { | ||
| 10272 | $taskObj->ivUndef('winUpdateFunc'); | ||
| 10273 | } | ||
| 10274 | |||
| 10275 | delete $taskObj->{winOpenFlag}; | ||
| 10276 | } | ||
| 10277 | } | ||
| 10278 | } | ||
| 10279 | |||
| 10280 | if ($version < 1_000_608 && $self->session) { | ||
| 10281 | |||
| 10282 | # This version updated the Divert task with a new IV. Update all initial/custom | ||
| 10283 | # tasks | ||
| 10284 | foreach my $taskObj ($self->compileTasks('divert_task')) { | ||
| 10285 | |||
| 10286 | if (! exists $taskObj->{lineList}) { | ||
| 10287 | |||
| 10288 | $taskObj->{lineList} = []; | ||
| 10289 | $taskObj->ivEmpty('lineList'); | ||
| 10290 | } | ||
| 10291 | } | ||
| 10292 | } | ||
| 10293 | |||
| 10294 | if ($version < 1_000_618 && $self->session) { | ||
| 10295 | |||
| 10296 | # This version updates all tasks with new IVs | ||
| 10297 | foreach my $taskObj ($self->compileTasks()) { | ||
| 10298 | |||
| 10299 | if (! exists $taskObj->{ttsFlag}) { | ||
| 10300 | |||
| 10301 | $taskObj->{ttsFlag} = undef; | ||
| 10302 | |||
| 10303 | if ( | ||
| 10304 | $taskObj->{name} eq 'attack_task' | ||
| 10305 | || $taskObj->{name} eq 'chat_task' | ||
| 10306 | || $taskObj->{name} eq 'divert_task' | ||
| 10307 | || $taskObj->{name} eq 'locator_task' | ||
| 10308 | || $taskObj->{name} eq 'status_task' | ||
| 10309 | || $taskObj->{name} eq 'watch_task' | ||
| 10310 | ) { | ||
| 10311 | $taskObj->ivPoke('ttsFlag', TRUE); | ||
| 10312 | } else { | ||
| 10313 | $taskObj->ivPoke('ttsFlag', FALSE); | ||
| 10314 | } | ||
| 10315 | |||
| 10316 | $taskObj->{ttsProfile} = undef; | ||
| 10317 | $taskObj->ivUndef('ttsProfile'); | ||
| 10318 | |||
| 10319 | $taskObj->{ttsAttribHash} = {}; | ||
| 10320 | $taskObj->{ttsFlagAttribHash} = {}; | ||
| 10321 | $taskObj->{ttsAlertAttribHash} = {}; | ||
| 10322 | |||
| 10323 | if ($taskObj->{name} eq 'attack_task') { | ||
| 10324 | |||
| 10325 | $taskObj->ivEmpty('ttsAttribHash'); | ||
| 10326 | |||
| 10327 | $taskObj->ivPoke( | ||
| 10328 | 'ttsFlagAttribHash', | ||
| 10329 | 'fight', FALSE, | ||
| 10330 | 'interact', FALSE, | ||
| 10331 | 'interaction', FALSE, | ||
| 10332 | ); | ||
| 10333 | |||
| 10334 | $taskObj->ivEmpty('ttsAlertAttribHash'); | ||
| 10335 | |||
| 10336 | } elsif ($taskObj->{name} eq 'chat_task') { | ||
| 10337 | |||
| 10338 | $taskObj->ivEmpty('ttsAttribHash'); | ||
| 10339 | |||
| 10340 | $taskObj->ivPoke( | ||
| 10341 | 'ttsFlagAttribHash', | ||
| 10342 | 'chat', FALSE, | ||
| 10343 | 'chatout', FALSE, | ||
| 10344 | 'chatin', FALSE, | ||
| 10345 | 'chatecho', FALSE, | ||
| 10346 | 'chatsystem', FALSE, | ||
| 10347 | 'chatremote', FALSE, | ||
| 10348 | 'chatsnoop', FALSE, | ||
| 10349 | ); | ||
| 10350 | |||
| 10351 | $taskObj->ivEmpty('ttsAlertAttribHash'); | ||
| 10352 | |||
| 10353 | } elsif ($taskObj->{name} eq 'divert_task') { | ||
| 10354 | |||
| 10355 | $taskObj->ivEmpty('ttsAttribHash'); | ||
| 10356 | |||
| 10357 | $taskObj->ivPoke( | ||
| 10358 | 'ttsFlagAttribHash', | ||
| 10359 | 'divert', FALSE, | ||
| 10360 | 'tell', FALSE, | ||
| 10361 | 'social', FALSE, | ||
| 10362 | 'custom', FALSE, | ||
| 10363 | 'warning', FALSE, | ||
| 10364 | ); | ||
| 10365 | |||
| 10366 | $taskObj->ivEmpty('ttsAlertAttribHash'); | ||
| 10367 | |||
| 10368 | } elsif ($taskObj->{name} eq 'locator_task') { | ||
| 10369 | |||
| 10370 | $taskObj->ivPoke( | ||
| 10371 | 'ttsAttribHash', | ||
| 10372 | 'title', undef, | ||
| 10373 | 'descrip', undef, | ||
| 10374 | 'description', undef, | ||
| 10375 | 'exit', undef, | ||
| 10376 | 'exits', undef, | ||
| 10377 | 'content', undef, | ||
| 10378 | 'contents', undef, | ||
| 10379 | ); | ||
| 10380 | |||
| 10381 | $taskObj->ivPoke( | ||
| 10382 | 'ttsFlagAttribHash', | ||
| 10383 | 'title', FALSE, | ||
| 10384 | 'descrip', FALSE, | ||
| 10385 | 'description', FALSE, | ||
| 10386 | 'exit', FALSE, | ||
| 10387 | 'exits', FALSE, | ||
| 10388 | 'content', FALSE, | ||
| 10389 | 'contents', FALSE, | ||
| 10390 | ); | ||
| 10391 | |||
| 10392 | $taskObj->ivEmpty('ttsAlertAttribHash'); | ||
| 10393 | |||
| 10394 | } elsif ($taskObj->{name} eq 'status_task') { | ||
| 10395 | |||
| 10396 | $taskObj->ivPoke( | ||
| 10397 | 'ttsAttribHash', | ||
| 10398 | 'status' => undef, | ||
| 10399 | 'life' => undef, | ||
| 10400 | 'lives' => undef, | ||
| 10401 | 'health' => undef, | ||
| 10402 | 'magic' => undef, | ||
| 10403 | 'energy' => undef, | ||
| 10404 | 'guild' => undef, | ||
| 10405 | 'social' => undef, | ||
| 10406 | 'xp' => undef, | ||
| 10407 | 'experience' => undef, | ||
| 10408 | 'level' => undef, | ||
| 10409 | 'align' => undef, | ||
| 10410 | 'alignment' => undef, | ||
| 10411 | 'age' => undef, | ||
| 10412 | 'time' => undef, | ||
| 10413 | 'bank' => undef, | ||
| 10414 | 'purse' => undef, | ||
| 10415 | ); | ||
| 10416 | |||
| 10417 | $taskObj->ivPoke( | ||
| 10418 | 'ttsFlagAttribHash', | ||
| 10419 | 'life' => FALSE, | ||
| 10420 | ); | ||
| 10421 | |||
| 10422 | $taskObj->ivPoke( | ||
| 10423 | 'ttsAlertAttribHash', | ||
| 10424 | 'healthup', undef, | ||
| 10425 | 'healthdown', undef, | ||
| 10426 | 'magicup', undef, | ||
| 10427 | 'magicdown', undef, | ||
| 10428 | 'energyup', undef, | ||
| 10429 | 'energydown', undef, | ||
| 10430 | 'guildup', undef, | ||
| 10431 | 'guilddown', undef, | ||
| 10432 | 'socialup', undef, | ||
| 10433 | 'socialdown', undef, | ||
| 10434 | ); | ||
| 10435 | |||
| 10436 | } elsif ($taskObj->{name} eq 'watch_task') { | ||
| 10437 | |||
| 10438 | $taskObj->ivEmpty('ttsAttribHash'); | ||
| 10439 | |||
| 10440 | $taskObj->ivPoke( | ||
| 10441 | 'ttsFlagAttribHash', | ||
| 10442 | 'watch', FALSE, | ||
| 10443 | ); | ||
| 10444 | |||
| 10445 | $taskObj->ivEmpty('ttsAlertAttribHash'); | ||
| 10446 | |||
| 10447 | } else { | ||
| 10448 | |||
| 10449 | $taskObj->ivEmpty('ttsAttribHash'); | ||
| 10450 | $taskObj->ivEmpty('ttsFlagAttribHash'); | ||
| 10451 | $taskObj->ivEmpty('ttsAlertAttribHash'); | ||
| 10452 | } | ||
| 10453 | } | ||
| 10454 | } | ||
| 10455 | } | ||
| 10456 | |||
| 10457 | if ($version < 1_000_619 && $self->session) { | ||
| 10458 | |||
| 10459 | # This version updates all tasks with a new flag IV. Its value is set to TRUE for | ||
| 10460 | # the Divert, Script and Watch tasks, FALSE for everything else | ||
| 10461 | my %trueHash = ( | ||
| 10462 | 'divert_task' => undef, | ||
| 10463 | 'script_task' => undef, | ||
| 10464 | 'watch_task' => undef, | ||
| 10465 | ); | ||
| 10466 | |||
| 10467 | foreach my $taskObj ($self->compileTasks()) { | ||
| 10468 | |||
| 10469 | if (! exists $taskObj->{allowLinkFlag}) { | ||
| 10470 | |||
| 10471 | $taskObj->{allowLinkFlag} = undef; | ||
| 10472 | |||
| 10473 | if (exists $trueHash{$taskObj->{name}}) { | ||
| 10474 | $taskObj->{allowLinkFlag} = TRUE; | ||
| 10475 | } else { | ||
| 10476 | $taskObj->{allowLinkFlag} = FALSE; | ||
| 10477 | } | ||
| 10478 | } | ||
| 10479 | } | ||
| 10480 | } | ||
| 10481 | |||
| 10482 | if ($version < 1_000_684 && $self->session) { | ||
| 10483 | |||
| 10484 | # This version updated the Status task with new IVs. Update all initial/custom | ||
| 10485 | # tasks | ||
| 10486 | my %varHash = ( | ||
| 10487 | 'health_points' => 'healthPoints', | ||
| 10488 | 'health_points_max' => 'healthPointsMax', | ||
| 10489 | 'magic_points' => 'magicPoints', | ||
| 10490 | 'magic_points_max' => 'magicPointsMax', | ||
| 10491 | 'energy_points' => 'energyPoints', | ||
| 10492 | 'energy_points_max' => 'energyPointsMax', | ||
| 10493 | 'guild_points' => 'guildPoints', | ||
| 10494 | 'guild_points_max' => 'guildPointsMax', | ||
| 10495 | 'social_points' => 'socialPoints', | ||
| 10496 | 'social_points_max' => 'socialPointsMax', | ||
| 10497 | 'xp_current' => 'xpCurrent', | ||
| 10498 | 'xp_next_level' => 'xpNextLevel', | ||
| 10499 | 'xp_total' => 'xpTotal', | ||
| 10500 | 'quest_points' => 'questPointCount', | ||
| 10501 | 'quest_points_max' => 'worldQuestPointCount', | ||
| 10502 | 'quest_count' => 'questCount', | ||
| 10503 | 'quest_count_max' => 'worldQuestCount', | ||
| 10504 | 'level' => 'level', | ||
| 10505 | 'life_count' => 'lifeCount', | ||
| 10506 | 'death_count' => 'deathCount', | ||
| 10507 | 'life_max' => 'lifeMax', | ||
| 10508 | 'local_wimpy' => 'localWimpy', | ||
| 10509 | 'remote_wimpy' => 'remoteWimpy', | ||
| 10510 | 'remote_wimpy_max' => 'remoteWimpyMax', | ||
| 10511 | 'local_wimpy_max' => '_localWimpyMax', | ||
| 10512 | 'bank_balance' => 'bankBalance', | ||
| 10513 | 'purse_contents' => 'purseContents', | ||
| 10514 | 'opp_health' => 'oppHealth', | ||
| 10515 | 'opp_health_max' => 'oppHealthMax', | ||
| 10516 | 'opp_level' => 'oppLevel', | ||
| 10517 | 'opp_strength' => 'oppStrength', | ||
| 10518 | ); | ||
| 10519 | |||
| 10520 | my @varList = ( | ||
| 10521 | 'health_points', 'health_points_max', FALSE, 'HP', | ||
| 10522 | 'RED', 'red', 'WHITE', | ||
| 10523 | 'magic_points', 'magic_points_max', FALSE, 'MP', | ||
| 10524 | 'YELLOW', 'yellow', 'black', | ||
| 10525 | 'energy_points', 'energy_points_max', FALSE, 'EP', | ||
| 10526 | 'GREEN', 'green', 'black', | ||
| 10527 | 'guild_points', 'guild_points_max', FALSE, 'GP', | ||
| 10528 | 'BLUE', 'blue', 'WHITE', | ||
| 10529 | 'social_points', 'social_points_max', FALSE, 'SP', | ||
| 10530 | 'MAGENTA', 'magenta', 'WHITE', | ||
| 10531 | ); | ||
| 10532 | |||
| 10533 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10534 | |||
| 10535 | if (! exists $taskObj->{singleBackRefVarHash}) { | ||
| 10536 | |||
| 10537 | # (This IV subsequently renamed and/or removed) | ||
| 10538 | # $taskObj->{singleBackRefVarHash} = {}; | ||
| 10539 | # $taskObj->ivPoke('singleBackRefVarHash', %varHash); | ||
| 10540 | $taskObj->{singleBackRefVarHash} = {%varHash}; | ||
| 10541 | |||
| 10542 | $taskObj->{gaugeFlag} = undef; | ||
| 10543 | $taskObj->ivPoke('gaugeFlag', FALSE); | ||
| 10544 | $taskObj->{gaugeValueFlag} = undef; | ||
| 10545 | $taskObj->ivPoke('gaugeValueFlag', TRUE); | ||
| 10546 | |||
| 10547 | # (This IV subsequently renamed and/or removed) | ||
| 10548 | # $taskObj->{defaultGaugeFormatList} = []; | ||
| 10549 | # $taskObj->ivPoke('defaultGaugeFormatList', @varList); | ||
| 10550 | $taskObj->{defaultGaugeFormatList} = [@varList]; | ||
| 10551 | $taskObj->{gaugeObjList} = []; | ||
| 10552 | $taskObj->ivEmpty('gaugeObjList'); | ||
| 10553 | } | ||
| 10554 | } | ||
| 10555 | } | ||
| 10556 | |||
| 10557 | if ($version < 1_000_689 && $self->session) { | ||
| 10558 | |||
| 10559 | # This version updated the Status task with a new IV. Update all initial/custom | ||
| 10560 | # tasks | ||
| 10561 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10562 | |||
| 10563 | if (! exists $taskObj->{gaugeResetFlag}) { | ||
| 10564 | |||
| 10565 | $taskObj->{gaugeResetFlag} = undef; | ||
| 10566 | $taskObj->ivPoke('gaugeResetFlag', FALSE); | ||
| 10567 | } | ||
| 10568 | } | ||
| 10569 | } | ||
| 10570 | |||
| 10571 | # (These IVs subsequently renamed and/or removed) | ||
| 10572 | # if ($version < 1_000_691 && $self->session) { | ||
| 10573 | # | ||
| 10574 | # # This version switched the order of some IVs in the Status task. Update all | ||
| 10575 | # # initial/custom tasks | ||
| 10576 | # foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10577 | # | ||
| 10578 | # my $string; | ||
| 10579 | # | ||
| 10580 | # $string = $taskObj->ivIndex('defaultFormatList', 1); | ||
| 10581 | # | ||
| 10582 | # # (No reason why any of these conditions should fail; these IVs aren't | ||
| 10583 | # # supposed to be altered) | ||
| 10584 | # if ($string =~ m/^HP\: \@health_points\@.*\(\@social_points_max\@\)$/) { | ||
| 10585 | # | ||
| 10586 | # $taskObj->ivReplace( | ||
| 10587 | # 'defaultFormatList', | ||
| 10588 | # 1, | ||
| 10589 | # 'HP: @health_points@ (@health_points_max@) MP: @magic_points@' | ||
| 10590 | # . ' (@magic_points_max@) EP: @energy_points@ (@energy_points_max@)' | ||
| 10591 | # . ' GP: @guild_points@ (@guild_points_max@) SP: @social_points@' | ||
| 10592 | # . ' (@social_points_max@)', | ||
| 10593 | # ); | ||
| 10594 | # } | ||
| 10595 | # | ||
| 10596 | # if ( | ||
| 10597 | # $taskObj->ivIndex('displayVarList', 4) eq 'health_points' | ||
| 10598 | # && $taskObj->ivIndex('displayVarList', 6) eq 'energy_points' | ||
| 10599 | # ) { | ||
| 10600 | # $taskObj->ivReplace('displayVarList', 6, 'magic_points'); | ||
| 10601 | # $taskObj->ivReplace('displayVarList', 7, 'magic_points_max'); | ||
| 10602 | # $taskObj->ivReplace('displayVarList', 8, 'energy_points'); | ||
| 10603 | # $taskObj->ivReplace('displayVarList', 9, 'energy_points_max'); | ||
| 10604 | # } | ||
| 10605 | # | ||
| 10606 | # if ( | ||
| 10607 | # $taskObj->ivIndex('singleBackRefVarList', 2) eq 'energy_points' | ||
| 10608 | # && $taskObj->ivIndex('singleBackRefVarList', 4) eq 'magic_points' | ||
| 10609 | # ) { | ||
| 10610 | # $taskObj->ivReplace('singleBackRefVarList', 2, 'magic_points'); | ||
| 10611 | # $taskObj->ivReplace('singleBackRefVarList', 3, 'magic_points_max'); | ||
| 10612 | # $taskObj->ivReplace('singleBackRefVarList', 4, 'energy_points'); | ||
| 10613 | # $taskObj->ivReplace('singleBackRefVarList', 5, 'energy_points_max'); | ||
| 10614 | # } | ||
| 10615 | # } | ||
| 10616 | # } | ||
| 10617 | |||
| 10618 | if ($version < 1_000_692 && $self->session) { | ||
| 10619 | |||
| 10620 | # This version updated the Status task with a new IV. Update all initial/custom | ||
| 10621 | # tasks | ||
| 10622 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10623 | |||
| 10624 | if (! exists $taskObj->{gaugeLevel}) { | ||
| 10625 | |||
| 10626 | $taskObj->{gaugeLevel} = undef; | ||
| 10627 | $taskObj->ivUndef('gaugeLevel'); | ||
| 10628 | } | ||
| 10629 | } | ||
| 10630 | } | ||
| 10631 | |||
| 10632 | if ($version < 1_000_693 && $self->session) { | ||
| 10633 | |||
| 10634 | # This version updated the Script task with new IVs. Update all initial/custom | ||
| 10635 | # tasks | ||
| 10636 | foreach my $taskObj ($self->compileTasks('script_task')) { | ||
| 10637 | |||
| 10638 | if (! exists $taskObj->{gaugeLevel}) { | ||
| 10639 | |||
| 10640 | $taskObj->{gaugeLevel} = undef; | ||
| 10641 | $taskObj->ivUndef('gaugeLevel'); | ||
| 10642 | $taskObj->{gaugeHash} = {}; | ||
| 10643 | $taskObj->ivEmpty('gaugeHash'); | ||
| 10644 | } | ||
| 10645 | } | ||
| 10646 | } | ||
| 10647 | |||
| 10648 | if ($version < 1_000_700 && $self->session) { | ||
| 10649 | |||
| 10650 | # This version updated the Script task with a new IV. Update all initial/custom | ||
| 10651 | # tasks | ||
| 10652 | foreach my $taskObj ($self->compileTasks('script_task')) { | ||
| 10653 | |||
| 10654 | if (! exists $taskObj->{statusBarHash}) { | ||
| 10655 | |||
| 10656 | $taskObj->{statusBarHash} = {}; | ||
| 10657 | $taskObj->ivEmpty('statusBarHash'); | ||
| 10658 | } | ||
| 10659 | } | ||
| 10660 | } | ||
| 10661 | |||
| 10662 | if ($version < 1_000_800 && $self->session) { | ||
| 10663 | |||
| 10664 | # This version updates all tasks, modifying some IVs and adding/removing others. | ||
| 10665 | # Update all initial/custom tasks | ||
| 10666 | foreach my $taskObj ($self->compileTasks()) { | ||
| 10667 | |||
| 10668 | if (exists $taskObj->{allowLinkFlag}) { | ||
| 10669 | |||
| 10670 | $taskObj->{defaultTabObj} = undef; | ||
| 10671 | $taskObj->{tableObj} = undef; | ||
| 10672 | $taskObj->{taskWinFlag} = FALSE; | ||
| 10673 | $taskObj->{taskWinEntryFlag} = FALSE; | ||
| 10674 | |||
| 10675 | $taskObj->{winPreferList} = []; | ||
| 10676 | if ( | ||
| 10677 | $taskObj->{name} eq 'compass_task' || $taskObj->{name} eq 'notepad_task' | ||
| 10678 | || $taskObj->{name} eq 'script_task' | ||
| 10679 | ) { | ||
| 10680 | $taskObj->{winPreferList} = ['pseudo', 'grid']; | ||
| 10681 | } elsif ( | ||
| 10682 | $taskObj->{name} eq 'debugger_task' | ||
| 10683 | || $taskObj->{name} eq 'inventory_task' | ||
| 10684 | || $taskObj->{name} eq 'locator' | ||
| 10685 | || $taskObj->{name} eq 'raw_text_task' | ||
| 10686 | || $taskObj->{name} eq 'raw_token_task' | ||
| 10687 | || $taskObj->{name} eq 'status_task' | ||
| 10688 | || $taskObj->{name} eq 'tasklist_task' | ||
| 10689 | || $taskObj->{name} eq 'watch_task' | ||
| 10690 | ) { | ||
| 10691 | $taskObj->{winPreferList} = ['pane', 'grid']; | ||
| 10692 | } elsif ( | ||
| 10693 | $taskObj->{name} eq 'divert_task' || $taskObj->{name} eq 'chat_task' | ||
| 10694 | ) { | ||
| 10695 | $taskObj->{winPreferList} = ['entry', 'grid']; | ||
| 10696 | } | ||
| 10697 | |||
| 10698 | delete $taskObj->{allowLinkFlag}; | ||
| 10699 | delete $taskObj->{settingsHash}; | ||
| 10700 | |||
| 10701 | $taskObj->{monochromeFlag} = $taskObj->{ownColourSchemeFlag}; | ||
| 10702 | delete $taskObj->{ownColourSchemeFlag}; | ||
| 10703 | |||
| 10704 | if ($taskObj->{winType} eq 'text') { | ||
| 10705 | $taskObj->{winmap} = 'basic_fill'; | ||
| 10706 | } elsif ($taskObj->{winType} eq 'entry') { | ||
| 10707 | $taskObj->{winmap} = 'entry_fill'; | ||
| 10708 | } elsif ($taskObj->{winType} eq 'graphics') { | ||
| 10709 | $taskObj->{winmap} = 'basic_empty'; | ||
| 10710 | } | ||
| 10711 | |||
| 10712 | delete $taskObj->{winType}; | ||
| 10713 | } | ||
| 10714 | } | ||
| 10715 | |||
| 10716 | # This version renames IVs in the Compass task | ||
| 10717 | foreach my $taskObj ($self->compileTasks('compass_task')) { | ||
| 10718 | |||
| 10719 | my $hashRef; | ||
| 10720 | |||
| 10721 | if (exists $taskObj->{radioButton}) { | ||
| 10722 | |||
| 10723 | $taskObj->{radioTableObj} = undef; | ||
| 10724 | $taskObj->{radioTableObj2} = undef; | ||
| 10725 | $taskObj->{comboTableObj} = undef; | ||
| 10726 | |||
| 10727 | delete $taskObj->{radioButton}; | ||
| 10728 | delete $taskObj->{radioButton2}; | ||
| 10729 | delete $taskObj->{comboBox}; | ||
| 10730 | |||
| 10731 | # Also modify the contents of one of the constant hashes, so it doesn't | ||
| 10732 | # cause a pango error | ||
| 10733 | $hashRef = $taskObj->{keypadHintHash}; | ||
| 10734 | $$hashRef{'kp_enter'} = 'ENTER key'; | ||
| 10735 | $taskObj->{radioTableObj} = $hashRef; | ||
| 10736 | } | ||
| 10737 | } | ||
| 10738 | |||
| 10739 | # This version updates IVs in the Debugger task | ||
| 10740 | foreach my $taskObj ($self->compileTasks('debugger_task')) { | ||
| 10741 | |||
| 10742 | if ($taskObj->{errorMode} == 0) { | ||
| 10743 | $taskObj->{errorMode} = 'original'; | ||
| 10744 | } elsif ($taskObj->{errorMode} == 1) { | ||
| 10745 | $taskObj->{errorMode} = 'both'; | ||
| 10746 | } elsif ($taskObj->{errorMode} == 2) { | ||
| 10747 | $taskObj->{errorMode} = 'task'; | ||
| 10748 | } | ||
| 10749 | |||
| 10750 | if ($taskObj->{warningMode} == 0) { | ||
| 10751 | $taskObj->{warningMode} = 'original'; | ||
| 10752 | } elsif ($taskObj->{warningMode} == 1) { | ||
| 10753 | $taskObj->{warningMode} = 'both'; | ||
| 10754 | } elsif ($taskObj->{warningMode} == 2) { | ||
| 10755 | $taskObj->{warningMode} = 'task'; | ||
| 10756 | } | ||
| 10757 | |||
| 10758 | if ($taskObj->{debugMode} == 0) { | ||
| 10759 | $taskObj->{debugMode} = 'original'; | ||
| 10760 | } elsif ($taskObj->{debugMode} == 1) { | ||
| 10761 | $taskObj->{debugMode} = 'both'; | ||
| 10762 | } elsif ($taskObj->{debugMode} == 2) { | ||
| 10763 | $taskObj->{debugMode} = 'task'; | ||
| 10764 | } | ||
| 10765 | |||
| 10766 | if ($taskObj->{improperMode} == 0) { | ||
| 10767 | $taskObj->{improperMode} = 'original'; | ||
| 10768 | } elsif ($taskObj->{improperMode} == 1) { | ||
| 10769 | $taskObj->{improperMode} = 'both'; | ||
| 10770 | } elsif ($taskObj->{improperMode} == 2) { | ||
| 10771 | $taskObj->{improperMode} = 'task'; | ||
| 10772 | } | ||
| 10773 | } | ||
| 10774 | |||
| 10775 | # This version renames an IV in the Inventory task | ||
| 10776 | foreach my $taskObj ($self->compileTasks('inventory_task')) { | ||
| 10777 | |||
| 10778 | if (exists $taskObj->{updateWinflag}) { | ||
| 10779 | |||
| 10780 | $taskObj->{refreshWinFlag} = $taskObj->{updateWinFlag}; | ||
| 10781 | delete $taskObj->{updateWinFlag}; | ||
| 10782 | } | ||
| 10783 | } | ||
| 10784 | |||
| 10785 | # This version renames IVs in the Notepad task (and removes one, too) | ||
| 10786 | foreach my $taskObj ($self->compileTasks('notepad_task')) { | ||
| 10787 | |||
| 10788 | if (exists $taskObj->{textView}) { | ||
| 10789 | |||
| 10790 | $taskObj->{textTableObj} = undef; | ||
| 10791 | $taskObj->{comboTableObj} = undef; | ||
| 10792 | |||
| 10793 | delete $taskObj->{textView}; | ||
| 10794 | delete $taskObj->{buffer}; | ||
| 10795 | delete $taskObj->{comboBox}; | ||
| 10796 | } | ||
| 10797 | } | ||
| 10798 | |||
| 10799 | # This function updates IVs in the Locator and Status tasks | ||
| 10800 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 10801 | |||
| 10802 | $taskObj->{winUpdateFunc} = 'refreshWin'; | ||
| 10803 | } | ||
| 10804 | |||
| 10805 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10806 | |||
| 10807 | $taskObj->{winUpdateFunc} = 'refreshWin'; | ||
| 10808 | $taskObj->{gaugeStripObj} = undef; | ||
| 10809 | } | ||
| 10810 | } | ||
| 10811 | |||
| 10812 | if ($version < 1_000_813 && $self->session) { | ||
| 10813 | |||
| 10814 | # This version removes an IV from all tasks. Update all initial/custom tasks | ||
| 10815 | foreach my $taskObj ($self->compileTasks()) { | ||
| 10816 | |||
| 10817 | if (exists $taskObj->{statusTypeHash}) { | ||
| 10818 | |||
| 10819 | delete $taskObj->{statusTypeHash}; | ||
| 10820 | } | ||
| 10821 | } | ||
| 10822 | } | ||
| 10823 | |||
| 10824 | if ($version < 1_000_840 && $self->session) { | ||
| 10825 | |||
| 10826 | # This version removes some IVs from the Locator task. Update all initial/custom | ||
| 10827 | # tasks | ||
| 10828 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 10829 | |||
| 10830 | if (exists $taskObj->{useMxpFlag}) { | ||
| 10831 | |||
| 10832 | $taskObj->{useMxpFlag} = undef; | ||
| 10833 | $taskObj->ivFalse('useMxpFlag'); | ||
| 10834 | |||
| 10835 | $taskObj->{mxpPropHash} = {}; | ||
| 10836 | $taskObj->ivPoke( | ||
| 10837 | 'mxpPropHash', | ||
| 10838 | 'RoomName' => undef, | ||
| 10839 | 'RoomDesc' => undef, | ||
| 10840 | 'RoomExit' => undef, | ||
| 10841 | 'RoomNum' => undef, | ||
| 10842 | ); | ||
| 10843 | } | ||
| 10844 | } | ||
| 10845 | } | ||
| 10846 | |||
| 10847 | if ($version < 1_000_841 && $self->session) { | ||
| 10848 | |||
| 10849 | # This version removes an IV from all tasks | ||
| 10850 | foreach my $taskObj ($self->compileTasks()) { | ||
| 10851 | |||
| 10852 | if (exists $taskObj->{msdpRoomHash}) { | ||
| 10853 | |||
| 10854 | delete $taskObj->{msdpRoomHash}; | ||
| 10855 | delete $taskObj->{msdpExitHash}; | ||
| 10856 | } | ||
| 10857 | } | ||
| 10858 | } | ||
| 10859 | |||
| 10860 | if ($version < 1_000_879 && $self->session) { | ||
| 10861 | |||
| 10862 | # This version removes an IV from the Status task | ||
| 10863 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10864 | |||
| 10865 | if (! exists $taskObj->{defaultGaugeFormatList}) { | ||
| 10866 | |||
| 10867 | delete $taskObj->{defaultGaugeFormatList}; | ||
| 10868 | } | ||
| 10869 | } | ||
| 10870 | } | ||
| 10871 | |||
| 10872 | if ($version < 1_000_904 && $self->session) { | ||
| 10873 | |||
| 10874 | # This version adds an IV to all tasks. Update all initial/custom tasks | ||
| 10875 | foreach my $taskObj ($self->compileTasks()) { | ||
| 10876 | |||
| 10877 | if (! exists $taskObj->{hasResetFlag}) { | ||
| 10878 | |||
| 10879 | $taskObj->{hasResetFlag} = undef; | ||
| 10880 | $taskObj->ivUndef('hasResetFlag'); | ||
| 10881 | } | ||
| 10882 | } | ||
| 10883 | } | ||
| 10884 | |||
| 10885 | if ($version < 1_000_909) { | ||
| 10886 | |||
| 10887 | # This version converts some numerical mode values to string mode values | ||
| 10888 | foreach my $taskObj ($self->compileTasks('advance_task')) { | ||
| 10889 | |||
| 10890 | if ($taskObj->advanceMode eq '0') { | ||
| 10891 | $taskObj->ivPoke('advanceMode', 'named_skill'); | ||
| 10892 | } elsif ($taskObj->advanceMode eq '1') { | ||
| 10893 | $taskObj->ivPoke('advanceMode', 'order_list'); | ||
| 10894 | } elsif ($taskObj->advanceMode eq '2') { | ||
| 10895 | $taskObj->ivPoke('advanceMode', 'cycle_list'); | ||
| 10896 | } | ||
| 10897 | } | ||
| 10898 | |||
| 10899 | foreach my $taskObj ($self->compileTasks('chat_task')) { | ||
| 10900 | |||
| 10901 | if ($taskObj->entryMode eq '0') { | ||
| 10902 | $taskObj->ivPoke('entryMode', 'chat'); | ||
| 10903 | } elsif ($taskObj->entryMode eq '1') { | ||
| 10904 | $taskObj->ivPoke('entryMode', 'emote'); | ||
| 10905 | } elsif ($taskObj->entryMode eq '2') { | ||
| 10906 | $taskObj->ivPoke('entryMode', 'cmd'); | ||
| 10907 | } | ||
| 10908 | } | ||
| 10909 | |||
| 10910 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 10911 | |||
| 10912 | if ($taskObj->autoLookMode eq '0') { | ||
| 10913 | $taskObj->ivPoke('autoLookMode', 'do_nothing'); | ||
| 10914 | } elsif ($taskObj->autoLookMode eq '1') { | ||
| 10915 | $taskObj->ivPoke('autoLookMode', 'search_back'); | ||
| 10916 | } elsif ($taskObj->autoLookMode eq '2') { | ||
| 10917 | $taskObj->ivPoke('autoLookMode', 'send_look'); | ||
| 10918 | } | ||
| 10919 | } | ||
| 10920 | |||
| 10921 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10922 | |||
| 10923 | if ($taskObj->commifyMode eq '0') { | ||
| 10924 | $taskObj->ivPoke('commifyMode', 'none'); | ||
| 10925 | } elsif ($taskObj->commifyMode eq '1') { | ||
| 10926 | $taskObj->ivPoke('commifyMode', 'use_comma'); | ||
| 10927 | } elsif ($taskObj->commifyMode eq '2') { | ||
| 10928 | $taskObj->ivPoke('commifyMode', 'use_europe'); | ||
| 10929 | } elsif ($taskObj->commifyMode eq '3') { | ||
| 10930 | $taskObj->ivPoke('commifyMode', 'use_brit'); | ||
| 10931 | } elsif ($taskObj->commifyMode eq '4') { | ||
| 10932 | $taskObj->ivPoke('commifyMode', 'use_underline'); | ||
| 10933 | } | ||
| 10934 | } | ||
| 10935 | } | ||
| 10936 | |||
| 10937 | if ($version < 1_000_922 && $self->session) { | ||
| 10938 | |||
| 10939 | # This version renames an IV in the Status task | ||
| 10940 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 10941 | |||
| 10942 | if (exists $taskObj->{_localWimpyMax}) { | ||
| 10943 | |||
| 10944 | $taskObj->{constLocalWimpyMax} = $taskObj->{_localWimpyMax}; | ||
| 10945 | delete $taskObj->{_localWimpyMax}; | ||
| 10946 | |||
| 10947 | # (This line makes sure the correct file object's ->modifyFlag is set) | ||
| 10948 | $taskObj->ivPoke('category', $taskObj->category); | ||
| 10949 | } | ||
| 10950 | } | ||
| 10951 | } | ||
| 10952 | |||
| 10953 | if ($version < 1_000_923 && $self->session) { | ||
| 10954 | |||
| 10955 | # This version renames an IV in the Chat task | ||
| 10956 | foreach my $taskObj ($self->compileTasks('chat_task')) { | ||
| 10957 | |||
| 10958 | if (exists $taskObj->{constantHash}) { | ||
| 10959 | |||
| 10960 | $taskObj->{constOptHash} = $taskObj->{constantHash}; | ||
| 10961 | delete $taskObj->{constantHash}; | ||
| 10962 | |||
| 10963 | # (This line makes sure the correct file object's ->modifyFlag is set) | ||
| 10964 | $taskObj->ivPoke('category', $taskObj->category); | ||
| 10965 | } | ||
| 10966 | } | ||
| 10967 | } | ||
| 10968 | |||
| 10969 | if ($version < 1_000_924 && $self->session) { | ||
| 10970 | |||
| 10971 | # This version renames an IV in the Locator task | ||
| 10972 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 10973 | |||
| 10974 | if (exists $taskObj->{oldRoomObj}) { | ||
| 10975 | |||
| 10976 | $taskObj->{prevRoomObj} = undef; | ||
| 10977 | $taskObj->ivPoke('prevRoomObj', $taskObj->{oldRoomObj}); | ||
| 10978 | |||
| 10979 | delete $taskObj->{oldRoomObj}; | ||
| 10980 | } | ||
| 10981 | } | ||
| 10982 | } | ||
| 10983 | |||
| 10984 | if ($version < 1_000_928 && $self->session) { | ||
| 10985 | |||
| 10986 | # This version replaces an IV in the Launch task | ||
| 10987 | foreach my $taskObj ($self->compileTasks('launch_task')) { | ||
| 10988 | |||
| 10989 | if (exists $taskObj->{simpleList}) { | ||
| 10990 | |||
| 10991 | $taskObj->{slTableObj} = undef; | ||
| 10992 | $taskObj->ivPoke('slTableObj', undef); | ||
| 10993 | |||
| 10994 | delete $taskObj->{simpleList}; | ||
| 10995 | } | ||
| 10996 | } | ||
| 10997 | } | ||
| 10998 | |||
| 10999 | if ($version < 1_001_031 && $self->session) { | ||
| 11000 | |||
| 11001 | # This version updates all tasks by renaming an IV | ||
| 11002 | foreach my $taskObj ($self->compileTasks()) { | ||
| 11003 | |||
| 11004 | if (! exists $taskObj->{taskType}) { | ||
| 11005 | |||
| 11006 | $taskObj->{taskType} = undef; | ||
| 11007 | $taskObj->ivPoke('taskType', $taskObj->{taskList}); | ||
| 11008 | |||
| 11009 | delete $taskObj->{taskList}; | ||
| 11010 | } | ||
| 11011 | } | ||
| 11012 | } | ||
| 11013 | |||
| 11014 | if ($version < 1_001_093 && $self->session) { | ||
| 11015 | |||
| 11016 | # This version updated the Locator task with a new IV, and renames some existing | ||
| 11017 | # IVs. Update all initial/custom tasks | ||
| 11018 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 11019 | |||
| 11020 | if (! exists $taskObj->{prevCmdBufferNum}) { | ||
| 11021 | |||
| 11022 | $taskObj->{prevCmdBufferNum} = undef; | ||
| 11023 | $taskObj->ivUndef('prevCmdBufferNum'); | ||
| 11024 | |||
| 11025 | $taskObj->{prevMoveObj} = undef; | ||
| 11026 | $taskObj->ivPoke('prevMoveObj', $taskObj->{previousMoveObj}); | ||
| 11027 | delete $taskObj->{previousMoveObj}; | ||
| 11028 | |||
| 11029 | $taskObj->{prevMove} = undef; | ||
| 11030 | $taskObj->ivPoke('prevMove', $taskObj->{previousMove}); | ||
| 11031 | delete $taskObj->{previousMove}; | ||
| 11032 | } | ||
| 11033 | } | ||
| 11034 | } | ||
| 11035 | |||
| 11036 | if ($version < 1_000_094 && $self->session) { | ||
| 11037 | |||
| 11038 | # This version removes an IV in the Locator task | ||
| 11039 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 11040 | |||
| 11041 | if (exists $taskObj->{resetTitleBarFlag}) { | ||
| 11042 | |||
| 11043 | delete $taskObj->{resetTitleBarFlag}; | ||
| 11044 | } | ||
| 11045 | } | ||
| 11046 | } | ||
| 11047 | |||
| 11048 | if ($version < 1_001_118 && $self->session) { | ||
| 11049 | |||
| 11050 | # This version updated the Locator task with new IVs. Update all initial/custom | ||
| 11051 | # tasks | ||
| 11052 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 11053 | |||
| 11054 | if (! exists $taskObj->{weatherHash}) { | ||
| 11055 | |||
| 11056 | $taskObj->{weatherHash} = {}; | ||
| 11057 | $taskObj->ivEmpty('weatherHash'); | ||
| 11058 | $taskObj->{showParsedFlag} = undef; | ||
| 11059 | $taskObj->ivPoke('showParsedFlag', FALSE); | ||
| 11060 | } | ||
| 11061 | } | ||
| 11062 | } | ||
| 11063 | |||
| 11064 | if ($version < 1_001_120 && $self->session) { | ||
| 11065 | |||
| 11066 | # This version fixes an error in which tasks in the global initial tasklist, created | ||
| 11067 | # by GA::Client->addGlobalInitTask, did not have their ->taskType IV set correctly | ||
| 11068 | foreach my $taskObj ($axmud::CLIENT->ivValues('initTaskHash')) { | ||
| 11069 | |||
| 11070 | $taskObj->ivPoke('taskType', 'initial'); | ||
| 11071 | } | ||
| 11072 | } | ||
| 11073 | |||
| 11074 | if ($version < 1_001_121 && $self->session) { | ||
| 11075 | |||
| 11076 | # This version adds an IV to all tasks | ||
| 11077 | foreach my $taskObj ($self->compileTasks()) { | ||
| 11078 | |||
| 11079 | if (! exists $taskObj->{colourScheme}) { | ||
| 11080 | |||
| 11081 | $taskObj->{colourScheme} = undef; | ||
| 11082 | $taskObj->ivUndef('colourScheme'); | ||
| 11083 | } | ||
| 11084 | } | ||
| 11085 | } | ||
| 11086 | |||
| 11087 | if ($version < 1_001_125 && $self->session) { | ||
| 11088 | |||
| 11089 | # This version updated the Divert task, adding some new IVs and removing some | ||
| 11090 | # existing ones. Update all initial/custom tasks | ||
| 11091 | foreach my $taskObj ($self->compileTasks('divert_task')) { | ||
| 11092 | |||
| 11093 | if (! exists $taskObj->{otherAlertColour}) { | ||
| 11094 | |||
| 11095 | $taskObj->{otherAlertColour} = undef; | ||
| 11096 | $taskObj->ivPoke('otherAlertColour', 'magenta'); | ||
| 11097 | $taskObj->{otherAlertInterval} = undef; | ||
| 11098 | $taskObj->ivPoke('otherAlertInterval', 10); | ||
| 11099 | $taskObj->{otherAlertSound} = undef; | ||
| 11100 | $taskObj->ivPoke('otherAlertSound', 'notify'); | ||
| 11101 | |||
| 11102 | $taskObj->{warningCharLimit} = undef; | ||
| 11103 | $taskObj->ivPoke('warningCharLimit', 0); | ||
| 11104 | $taskObj->{otherCharLimit} = undef; | ||
| 11105 | $taskObj->ivPoke('otherCharLimit', 0); | ||
| 11106 | |||
| 11107 | $taskObj->{otherRoomFlag} = undef; | ||
| 11108 | $taskObj->ivPoke('otherRoomFlag', FALSE); | ||
| 11109 | $taskObj->{otherUrgencyFlag} = undef; | ||
| 11110 | $taskObj->ivPoke('otherUrgencyFlag', TRUE); | ||
| 11111 | |||
| 11112 | delete $taskObj->{gagFlag}; | ||
| 11113 | } | ||
| 11114 | } | ||
| 11115 | } | ||
| 11116 | |||
| 11117 | if ($version < 1_001_128 && $self->session) { | ||
| 11118 | |||
| 11119 | # This version updates all tasks with a new IV | ||
| 11120 | foreach my $taskObj ($self->compileTasks()) { | ||
| 11121 | |||
| 11122 | if (! exists $taskObj->{tabMode}) { | ||
| 11123 | |||
| 11124 | $taskObj->{tabMode} = undef; | ||
| 11125 | |||
| 11126 | if ( | ||
| 11127 | $taskObj->{allowWinFlag} | ||
| 11128 | && defined $taskObj->{winmap} | ||
| 11129 | && ( | ||
| 11130 | $taskObj->{winmap} eq 'basic_fill' | ||
| 11131 | || $taskObj->{winmap} eq 'basic_part' | ||
| 11132 | || $taskObj->{winmap} eq 'entry_fill' | ||
| 11133 | || $taskObj->{winmap} eq 'entry_part' | ||
| 11134 | ) | ||
| 11135 | ) { | ||
| 11136 | # At the current time, there are no tasks whose ->tabMode is 'multi' | ||
| 11137 | $taskObj->ivPoke('tabMode', 'simple'); | ||
| 11138 | |||
| 11139 | } else { | ||
| 11140 | |||
| 11141 | $taskObj->ivUndef('tabMode'); | ||
| 11142 | } | ||
| 11143 | } | ||
| 11144 | } | ||
| 11145 | } | ||
| 11146 | |||
| 11147 | if ($version < 1_001_133 && $self->session) { | ||
| 11148 | |||
| 11149 | # This version updated the Watch task with new IVs. Update all initial/custom tasks | ||
| 11150 | foreach my $taskObj ($self->compileTasks('watch_task')) { | ||
| 11151 | |||
| 11152 | if (! exists $taskObj->{channelsAlertColour}) { | ||
| 11153 | |||
| 11154 | $taskObj->{channelsAlertColour} = undef; | ||
| 11155 | $taskObj->ivPoke('channelsAlertColour', 'YELLOW'); | ||
| 11156 | $taskObj->{channelsAlertInterval} = undef; | ||
| 11157 | $taskObj->ivPoke('channelsAlertInterval', 10); | ||
| 11158 | } | ||
| 11159 | } | ||
| 11160 | } | ||
| 11161 | |||
| 11162 | if ($version < 1_001_164 && $self->session) { | ||
| 11163 | |||
| 11164 | my $class = 'Games::Axmud::Task::System'; | ||
| 11165 | |||
| 11166 | # This version renames the built-in Debugger task as the System task | ||
| 11167 | foreach my $taskObj ($self->compileTasks('debugger_task')) { | ||
| 11168 | |||
| 11169 | # Rebless the task object into its new class | ||
| 11170 | bless $taskObj, $class; | ||
| 11171 | |||
| 11172 | # Rename some existing IVs | ||
| 11173 | $taskObj->{_objName} = 'system_task'; | ||
| 11174 | $taskObj->{_objClass} = $class; | ||
| 11175 | $taskObj->{name} = 'system_task'; | ||
| 11176 | $taskObj->{prettyName} = 'System'; | ||
| 11177 | $taskObj->{shortName} = 'Sy'; | ||
| 11178 | $taskObj->{shortCutIV} = 'systemTask'; | ||
| 11179 | $taskObj->{descrip} = 'Diverts system messages into a new window'; | ||
| 11180 | |||
| 11181 | # Change one task setting to fix an issue that prevented the window showing | ||
| 11182 | # coloured text | ||
| 11183 | $taskObj->{monochromeFlag} = FALSE; | ||
| 11184 | |||
| 11185 | # Add new IVs | ||
| 11186 | $taskObj->{systemMode} = undef; | ||
| 11187 | $taskObj->ivPoke('systemMode', 'both'); | ||
| 11188 | $taskObj->{colourFlag} = undef; | ||
| 11189 | $taskObj->ivPoke('colourFlag', TRUE); | ||
| 11190 | } | ||
| 11191 | } | ||
| 11192 | |||
| 11193 | if ($version < 1_001_191 && $self->session) { | ||
| 11194 | |||
| 11195 | # This version renames some Status task IVs. Update all initial/custom tasks | ||
| 11196 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 11197 | |||
| 11198 | if (! exists $taskObj->{groupVarList}) { | ||
| 11199 | |||
| 11200 | $taskObj->{groupVarList} = $taskObj->{singleBackRefVarList}; | ||
| 11201 | delete $taskObj->{singleBackRefVarList}; | ||
| 11202 | |||
| 11203 | $taskObj->{groupVarHash} = $taskObj->{singleBackRefVarHash}; | ||
| 11204 | delete $taskObj->{singleBackRefVarHash}; | ||
| 11205 | } | ||
| 11206 | } | ||
| 11207 | } | ||
| 11208 | |||
| 11209 | if ($version < 1_001_200 && $self->session) { | ||
| 11210 | |||
| 11211 | # This version updated the RawToken task with new IVs. Update all initial/custom | ||
| 11212 | # tasks | ||
| 11213 | foreach my $taskObj ($self->compileTasks('raw_token_task')) { | ||
| 11214 | |||
| 11215 | if (! exists $taskObj->{splitLineFlag}) { | ||
| 11216 | |||
| 11217 | $taskObj->{splitLineFlag} = undef; | ||
| 11218 | $taskObj->ivPoke('splitLineFlag', FALSE); | ||
| 11219 | $taskObj->{showTypeFlag} = undef; | ||
| 11220 | $taskObj->ivPoke('showTypeFlag', FALSE); | ||
| 11221 | $taskObj->{countPacketFlag} = undef; | ||
| 11222 | $taskObj->ivPoke('countPacketFlag', FALSE); | ||
| 11223 | } | ||
| 11224 | } | ||
| 11225 | } | ||
| 11226 | |||
| 11227 | if ($version < 1_001_263 && $self->session) { | ||
| 11228 | |||
| 11229 | my $tempTask; | ||
| 11230 | |||
| 11231 | # This version completes a major rewrite of the Status task | ||
| 11232 | |||
| 11233 | # Create a temporary task so we can access its IVs | ||
| 11234 | $tempTask = Games::Axmud::Task::Status->new($axmud::CLIENT); | ||
| 11235 | |||
| 11236 | # Update IVs in all initial/custom tasks | ||
| 11237 | foreach my $taskObj ($self->compileTasks('status_task')) { | ||
| 11238 | |||
| 11239 | if (! exists $taskObj->{constCharVarHash}) { | ||
| 11240 | |||
| 11241 | # (New IVs) | ||
| 11242 | $taskObj->{constCharVarHash} = {$tempTask->constCharVarHash}; | ||
| 11243 | $taskObj->{constFixedVarHash} = {$tempTask->constFixedVarHash}; | ||
| 11244 | $taskObj->{constPseudoVarHash} = {$tempTask->constPseudoVarHash}; | ||
| 11245 | $taskObj->{constLocalVarHash} = {$tempTask->constLocalVarHash}; | ||
| 11246 | $taskObj->{constCounterVarHash} = {$tempTask->constCounterVarHash}; | ||
| 11247 | $taskObj->{constCounterRevHash} = {$tempTask->constCounterRevHash}; | ||
| 11248 | $taskObj->{constPointHash} = {$tempTask->constPointHash}; | ||
| 11249 | |||
| 11250 | $taskObj->{localVarHash} = {}; | ||
| 11251 | $taskObj->ivPoke('localVarHash', $tempTask->localVarHash); | ||
| 11252 | $taskObj->{counterVarHash} = {}; | ||
| 11253 | $taskObj->ivPoke('counterVarHash', $tempTask->counterVarHash); | ||
| 11254 | $taskObj->{counterBaseHash} = {}; | ||
| 11255 | $taskObj->ivPoke('counterBaseHash', $tempTask->counterBaseHash); | ||
| 11256 | |||
| 11257 | # (Renamed IV) | ||
| 11258 | $taskObj->{counterStartTime} = undef; | ||
| 11259 | $taskObj->ivPoke('counterStartTime', $tempTask->{tempTimerBaseline}); | ||
| 11260 | delete $taskObj->{tempTimerBaseline}; | ||
| 11261 | |||
| 11262 | # (Removed IVs) | ||
| 11263 | delete $taskObj->{defaultFormatList}; | ||
| 11264 | delete $taskObj->{displayVarList}; | ||
| 11265 | delete $taskObj->{groupVarList}; | ||
| 11266 | delete $taskObj->{groupVarHash}; | ||
| 11267 | |||
| 11268 | delete $taskObj->{lifeStatusOverrideFlag}; | ||
| 11269 | |||
| 11270 | delete $taskObj->{lifeStatus}; | ||
| 11271 | delete $taskObj->{lifeCount}; | ||
| 11272 | delete $taskObj->{deathCount}; | ||
| 11273 | delete $taskObj->{lifeMax}; | ||
| 11274 | |||
| 11275 | delete $taskObj->{healthPoints}; | ||
| 11276 | delete $taskObj->{healthPointsMax}; | ||
| 11277 | delete $taskObj->{magicPoints}; | ||
| 11278 | delete $taskObj->{magicPointsMax}; | ||
| 11279 | delete $taskObj->{energyPoints}; | ||
| 11280 | delete $taskObj->{energyPointsMax}; | ||
| 11281 | delete $taskObj->{guildPoints}; | ||
| 11282 | delete $taskObj->{guildPointsMax}; | ||
| 11283 | delete $taskObj->{socialPoints}; | ||
| 11284 | delete $taskObj->{socialPointsMax}; | ||
| 11285 | |||
| 11286 | delete $taskObj->{xpCurrent}; | ||
| 11287 | delete $taskObj->{xpNextLevel}; | ||
| 11288 | delete $taskObj->{xpTotal}; | ||
| 11289 | |||
| 11290 | delete $taskObj->{worldQuestCount}; | ||
| 11291 | delete $taskObj->{worldQuestPointCount}; | ||
| 11292 | delete $taskObj->{worldQuestXPCount}; | ||
| 11293 | delete $taskObj->{worldQuestCashCount}; | ||
| 11294 | |||
| 11295 | delete $taskObj->{questCount}; | ||
| 11296 | delete $taskObj->{questPointCount}; | ||
| 11297 | delete $taskObj->{questXPCount}; | ||
| 11298 | delete $taskObj->{questCashCount}; | ||
| 11299 | |||
| 11300 | delete $taskObj->{level}; | ||
| 11301 | delete $taskObj->{alignment}; | ||
| 11302 | |||
| 11303 | delete $taskObj->{localWimpy}; | ||
| 11304 | delete $taskObj->{constLocalWimpyMax}; | ||
| 11305 | delete $taskObj->{remoteWimpy}; | ||
| 11306 | delete $taskObj->{remoteWimpyMax}; | ||
| 11307 | |||
| 11308 | delete $taskObj->{age}; | ||
| 11309 | delete $taskObj->{time}; | ||
| 11310 | |||
| 11311 | delete $taskObj->{bankBalance}; | ||
| 11312 | delete $taskObj->{purseContents}; | ||
| 11313 | |||
| 11314 | delete $taskObj->{fightCountFlag}; | ||
| 11315 | delete $taskObj->{fightCount}; | ||
| 11316 | delete $taskObj->{killCount}; | ||
| 11317 | delete $taskObj->{wimpyCount}; | ||
| 11318 | delete $taskObj->{fightDefeatCount}; | ||
| 11319 | delete $taskObj->{interactCountFlag}; | ||
| 11320 | delete $taskObj->{interactCount}; | ||
| 11321 | delete $taskObj->{interactSuccessCount}; | ||
| 11322 | delete $taskObj->{interactFailCount}; | ||
| 11323 | delete $taskObj->{interactFightCount}; | ||
| 11324 | delete $taskObj->{interactDisasterCount}; | ||
| 11325 | |||
| 11326 | delete $taskObj->{fleeCount}; | ||
| 11327 | delete $taskObj->{escapeCount}; | ||
| 11328 | |||
| 11329 | delete $taskObj->{tempXPCount}; | ||
| 11330 | delete $taskObj->{tempXPBaseline}; | ||
| 11331 | delete $taskObj->{tempQuestCount}; | ||
| 11332 | delete $taskObj->{tempQuestBaseline}; | ||
| 11333 | delete $taskObj->{tempBankCount}; | ||
| 11334 | delete $taskObj->{tempBankBaseline}; | ||
| 11335 | delete $taskObj->{tempPurseCount}; | ||
| 11336 | delete $taskObj->{tempPurseBaseline}; | ||
| 11337 | } | ||
| 11338 | } | ||
| 11339 | } | ||
| 11340 | |||
| 11341 | if ($version < 1_002_058 && $self->session) { | ||
| 11342 | |||
| 11343 | # This version updated the Locator task with new IVs. Update all initial/custom | ||
| 11344 | # tasks | ||
| 11345 | foreach my $taskObj ($self->compileTasks('locator_task')) { | ||
| 11346 | |||
| 11347 | if (! exists $taskObj->{mxpPropCurrentHash}) { | ||
| 11348 | |||
| 11349 | $taskObj->{mxpPropCurrentHash} = {}; | ||
| 11350 | $taskObj->ivEmpty('mxpPropCurrentHash'); | ||
| 11351 | $taskObj->{mxpPropStartLine} = undef; | ||
| 11352 | $taskObj->ivUndef('mxpPropStartLine'); | ||
| 11353 | } | ||
| 11354 | } | ||
| 11355 | } | ||
| 11356 | |||
| 11357 | if ($version < 1_003_095 && $self->session) { | ||
| 11358 | |||
| 11359 | # This version updated the Countdown task IVs. Update all initial/custom tasks | ||
| 11360 | foreach my $taskObj ($self->compileTasks('countdown_task')) { | ||
| 11361 | |||
| 11362 | if (! exists $taskObj->{textLen}) { | ||
| 11363 | |||
| 11364 | delete $taskObj->{textLen}; | ||
| 11365 | delete $taskObj->{labelTableObj}; | ||
| 11366 | |||
| 11367 | $taskObj->{textViewTableObj} = undef; | ||
| 11368 | $taskObj->ivUndef('textViewTableObj'); | ||
| 11369 | $taskObj->{previousColour} = undef; | ||
| 11370 | $taskObj->ivUndef('previousColour'); | ||
| 11371 | } | ||
| 11372 | } | ||
| 11373 | } | ||
| 11374 | } | ||
| 11375 | |||
| 11376 | ### scripts ############################################################################### | ||
| 11377 | |||
| 11378 | if ($self->fileType eq 'scripts') { | ||
| 11379 | |||
| 11380 | if ($version < 1_000_909) { | ||
| 11381 | |||
| 11382 | # This version converts some numerical mode values to string mode values | ||
| 11383 | |||
| 11384 | my %initScriptHash = $axmud::CLIENT->initScriptHash; | ||
| 11385 | |||
| 11386 | foreach my $key (keys %initScriptHash) { | ||
| 11387 | |||
| 11388 | my $value = $initScriptHash{$key}; | ||
| 11389 | |||
| 11390 | if ($value eq '0') { | ||
| 11391 | $initScriptHash{$key} = 'no_task'; | ||
| 11392 | } elsif ($value eq '1') { | ||
| 11393 | $initScriptHash{$key} = 'run_task'; | ||
| 11394 | } elsif ($value eq '2') { | ||
| 11395 | $initScriptHash{$key} = 'run_task_win'; | ||
| 11396 | } | ||
| 11397 | } | ||
| 11398 | |||
| 11399 | $axmud::CLIENT->ivPoke('initScriptHash', %initScriptHash); | ||
| 11400 | } | ||
| 11401 | |||
| 11402 | ### contacts ############################################################################## | ||
| 11403 | |||
| 11404 | } elsif ($self->fileType eq 'contacts') { | ||
| 11405 | |||
| 11406 | if ($version < 1_000_909) { | ||
| 11407 | |||
| 11408 | # This version converts some numerical mode values to string mode values | ||
| 11409 | if ($axmud::CLIENT->chatAcceptMode eq '0') { | ||
| 11410 | $axmud::CLIENT->ivPoke('chatAcceptMode', 'prompt'); | ||
| 11411 | } elsif ($axmud::CLIENT->chatAcceptMode eq '1') { | ||
| 11412 | $axmud::CLIENT->ivPoke('chatAcceptMode', 'accept_contact'); | ||
| 11413 | } elsif ($axmud::CLIENT->chatAcceptMode eq '2') { | ||
| 11414 | $axmud::CLIENT->ivPoke('chatAcceptMode', 'accept_all'); | ||
| 11415 | } | ||
| 11416 | } | ||
| 11417 | |||
| 11418 | ### dicts ################################################################################# | ||
| 11419 | |||
| 11420 | } elsif ($self->fileType eq 'dicts') { | ||
| 11421 | |||
| 11422 | if ($version < 1_000_037) { | ||
| 11423 | |||
| 11424 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11425 | |||
| 11426 | # Add 'portal' as a new type of decoration, if it's not already there | ||
| 11427 | if (! defined $dictObj->ivMatch('constDecorationTypeList', 'portal')) { | ||
| 11428 | |||
| 11429 | $dictObj->ivPush('constDecorationTypeList', 'portal'); | ||
| 11430 | } | ||
| 11431 | |||
| 11432 | if (! defined $dictObj->ivMatch('decorationTypeList', 'portal')) { | ||
| 11433 | |||
| 11434 | $dictObj->ivPush('decorationTypeList', 'portal'); | ||
| 11435 | } | ||
| 11436 | |||
| 11437 | # Add 'portal' to the decoration lists | ||
| 11438 | if (! $dictObj->ivExists('decorationHash', 'portal')) { | ||
| 11439 | |||
| 11440 | $dictObj->ivAdd('decorationHash', 'portal', 'decoration'); | ||
| 11441 | $dictObj->ivAdd('decorationTypeHash', 'portal', 'portal'); | ||
| 11442 | } | ||
| 11443 | } | ||
| 11444 | } | ||
| 11445 | |||
| 11446 | if ($version < 1_000_271) { | ||
| 11447 | |||
| 11448 | # This version adds eight new primary directions. $self->session is not necessarily | ||
| 11449 | # set, so we can't create a temporary dictionary and copy IVs to existing | ||
| 11450 | # dictionaries; need to update IVs the hard way | ||
| 11451 | # (Unfortunately, non-English dictionaries will be updated with English words; | ||
| 11452 | # hopefully only a tiny number of users will be affected) | ||
| 11453 | |||
| 11454 | my ( | ||
| 11455 | @primaryDirList, @shortPrimaryDirList, | ||
| 11456 | %shortPrimaryDirHash, %primaryAbbrevHash, %primaryOppHash, | ||
| 11457 | %primaryOppAbbrevHash, | ||
| 11458 | ); | ||
| 11459 | |||
| 11460 | @primaryDirList = ( | ||
| 11461 | 'north', | ||
| 11462 | 'northnortheast', | ||
| 11463 | 'northeast', | ||
| 11464 | 'eastnortheast', | ||
| 11465 | 'east', | ||
| 11466 | 'eastsoutheast', | ||
| 11467 | 'southeast', | ||
| 11468 | 'southsoutheast', | ||
| 11469 | 'south', | ||
| 11470 | 'southsouthwest', | ||
| 11471 | 'southwest', | ||
| 11472 | 'westsouthwest', | ||
| 11473 | 'west', | ||
| 11474 | 'westnorthwest', | ||
| 11475 | 'northwest', | ||
| 11476 | 'northnorthwest', | ||
| 11477 | 'up', | ||
| 11478 | 'down', | ||
| 11479 | ); | ||
| 11480 | |||
| 11481 | @shortPrimaryDirList = ( | ||
| 11482 | 'north', | ||
| 11483 | 'northeast', | ||
| 11484 | 'east', | ||
| 11485 | 'southeast', | ||
| 11486 | 'south', | ||
| 11487 | 'southwest', | ||
| 11488 | 'west', | ||
| 11489 | 'northwest', | ||
| 11490 | 'up', | ||
| 11491 | 'down', | ||
| 11492 | ); | ||
| 11493 | |||
| 11494 | %shortPrimaryDirHash = ( | ||
| 11495 | 'north' => undef, | ||
| 11496 | 'northeast' => undef, | ||
| 11497 | 'east' => undef, | ||
| 11498 | 'southeast' => undef, | ||
| 11499 | 'south' => undef, | ||
| 11500 | 'southwest' => undef, | ||
| 11501 | 'west' => undef, | ||
| 11502 | 'northwest' => undef, | ||
| 11503 | 'up' => undef, | ||
| 11504 | 'down' => undef, | ||
| 11505 | ); | ||
| 11506 | |||
| 11507 | %primaryAbbrevHash = ( | ||
| 11508 | northnortheast => 'nne', # Only new key-value pairs | ||
| 11509 | eastnortheast => 'ene', | ||
| 11510 | eastsoutheast => 'ese', | ||
| 11511 | southsoutheast => 'sse', | ||
| 11512 | southsouthwest => 'ssw', | ||
| 11513 | westsouthwest => 'wsw', | ||
| 11514 | westnorthwest => 'wnw', | ||
| 11515 | northnorthwest => 'nnw', | ||
| 11516 | ); | ||
| 11517 | |||
| 11518 | %primaryOppHash = ( | ||
| 11519 | northnortheast => 'southsouthwest', # Only new key-value pairs | ||
| 11520 | eastnortheast => 'westsouthwest', | ||
| 11521 | eastsoutheast => 'westnorthwest', | ||
| 11522 | southsoutheast => 'northnorthwest', | ||
| 11523 | southsouthwest => 'northnortheast', | ||
| 11524 | westsouthwest => 'eastnortheast', | ||
| 11525 | westnorthwest => 'eastsoutheast', | ||
| 11526 | northnorthwest => 'southsoutheast', | ||
| 11527 | ); | ||
| 11528 | |||
| 11529 | %primaryOppAbbrevHash = ( | ||
| 11530 | northnortheast => 'ssw', | ||
| 11531 | eastnortheast => 'wsw', | ||
| 11532 | eastsoutheast => 'wnw', | ||
| 11533 | southsoutheast => 'nnw', | ||
| 11534 | southsouthwest => 'nne', | ||
| 11535 | westsouthwest => 'ene', | ||
| 11536 | westnorthwest => 'ese', | ||
| 11537 | northnorthwest => 'sse', | ||
| 11538 | ); | ||
| 11539 | |||
| 11540 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11541 | |||
| 11542 | if (! $dictObj->ivExists('primaryDirHash', 'northnortheast')) { | ||
| 11543 | |||
| 11544 | # Update this dictionary's IVs | ||
| 11545 | # (This IV subsequently renamed and/or removed) | ||
| 11546 | # $dictObj->ivPoke('primaryDirList', @primaryDirList); | ||
| 11547 | $dictObj->{primaryDirList} = [@primaryDirList]; | ||
| 11548 | # $dictObj->{shortPrimaryDirList} = []; | ||
| 11549 | # $dictObj->ivPoke('shortPrimaryDirList', @shortPrimaryDirList); | ||
| 11550 | $dictObj->{shortPrimaryDirList} = [@shortPrimaryDirList]; | ||
| 11551 | # $dictObj->{shortPrimaryDirHash} = {}; | ||
| 11552 | # $dictObj->ivPoke('shortPrimaryDirHash', %shortPrimaryDirHash); | ||
| 11553 | $dictObj->{shortPrimaryDirHash} = {%shortPrimaryDirHash}; | ||
| 11554 | |||
| 11555 | foreach my $dir (@primaryDirList) { | ||
| 11556 | |||
| 11557 | if (! exists $shortPrimaryDirHash{$dir}) { | ||
| 11558 | |||
| 11559 | $dictObj->ivAdd( | ||
| 11560 | 'primaryDirHash', | ||
| 11561 | $dir, # Standard and custom dirs are initially the same | ||
| 11562 | $dir, | ||
| 11563 | ); | ||
| 11564 | } | ||
| 11565 | } | ||
| 11566 | |||
| 11567 | foreach my $key (keys %primaryAbbrevHash) { | ||
| 11568 | |||
| 11569 | $dictObj->ivAdd('primaryAbbrevHash', $key, $primaryAbbrevHash{$key}); | ||
| 11570 | } | ||
| 11571 | |||
| 11572 | foreach my $key (keys %primaryOppHash) { | ||
| 11573 | |||
| 11574 | $dictObj->ivAdd('primaryOppHash', $key, $primaryOppHash{$key}); | ||
| 11575 | } | ||
| 11576 | |||
| 11577 | foreach my $key (keys %primaryOppAbbrevHash) { | ||
| 11578 | |||
| 11579 | $dictObj->ivAdd( | ||
| 11580 | 'primaryOppAbbrevHash', | ||
| 11581 | $key, | ||
| 11582 | $primaryOppAbbrevHash{$key}, | ||
| 11583 | ); | ||
| 11584 | } | ||
| 11585 | |||
| 11586 | # We also have to update the combined hashes the hard way | ||
| 11587 | foreach my $key (keys %primaryAbbrevHash) { | ||
| 11588 | |||
| 11589 | # Standard and custom dirs are initially the same | ||
| 11590 | $dictObj->ivAdd('combDirHash', $key, 'primaryDir'); | ||
| 11591 | } | ||
| 11592 | |||
| 11593 | foreach my $value (values %primaryAbbrevHash) { | ||
| 11594 | |||
| 11595 | # Standard and custom dirs are initially the same | ||
| 11596 | $dictObj->ivAdd('combDirHash', $value, 'primaryAbbrev'); | ||
| 11597 | } | ||
| 11598 | |||
| 11599 | foreach my $key (keys %primaryOppHash) { | ||
| 11600 | |||
| 11601 | # Standard and custom dirs are initially the same | ||
| 11602 | $dictObj->ivAdd('combOppDirHash', $key, $primaryOppHash{$key}); | ||
| 11603 | } | ||
| 11604 | |||
| 11605 | foreach my $key (keys %primaryAbbrevHash) { | ||
| 11606 | |||
| 11607 | # Standard and custom dirs are initially the same | ||
| 11608 | $dictObj->ivAdd('combRevDirHash', $key, $key); | ||
| 11609 | } | ||
| 11610 | } | ||
| 11611 | } | ||
| 11612 | } | ||
| 11613 | |||
| 11614 | if ($version < 1_000_275) { | ||
| 11615 | |||
| 11616 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11617 | |||
| 11618 | # Update this dictionary's IVs | ||
| 11619 | $dictObj->{secondaryAutoHash} = {}; | ||
| 11620 | # Create a key-value pair for every existing secondary direction | ||
| 11621 | foreach my $dir ($dictObj->ivKeys('secondaryDirHash')) { | ||
| 11622 | |||
| 11623 | $dictObj->ivAdd('secondaryAutoHash', $dir, undef); | ||
| 11624 | } | ||
| 11625 | } | ||
| 11626 | } | ||
| 11627 | |||
| 11628 | if ($version < 1_000_278) { | ||
| 11629 | |||
| 11630 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11631 | |||
| 11632 | # Update this dictionary's IVs | ||
| 11633 | $dictObj->{secondaryAbbrevHash} = {}; | ||
| 11634 | $dictObj->{secondaryOppAbbrevHash} = {}; | ||
| 11635 | # Create a key-value pair for every existing secondary direction | ||
| 11636 | foreach my $dir ($dictObj->ivKeys('secondaryDirHash')) { | ||
| 11637 | |||
| 11638 | $dictObj->ivAdd('secondaryAbbrevHash', $dir, undef); | ||
| 11639 | $dictObj->ivAdd('secondaryOppAbbrevHash', $dir, ''); | ||
| 11640 | } | ||
| 11641 | } | ||
| 11642 | } | ||
| 11643 | |||
| 11644 | if ($version < 1_000_582) { | ||
| 11645 | |||
| 11646 | # Update dictionary with a new IV | ||
| 11647 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11648 | |||
| 11649 | if (! exists $dictObj->{contentsLinesHash}) { | ||
| 11650 | |||
| 11651 | $dictObj->{contentsLinesHash} = {}; | ||
| 11652 | $dictObj->ivEmpty('contentsLinesHash'); | ||
| 11653 | } | ||
| 11654 | } | ||
| 11655 | |||
| 11656 | # An error in ';addword' added key-value pairs with the wrong value. Here's the fix | ||
| 11657 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11658 | |||
| 11659 | foreach my $key ($dictObj->ivKeys('adjHash')) { | ||
| 11660 | |||
| 11661 | my $value = $dictObj->ivShow('adjHash', $key); | ||
| 11662 | |||
| 11663 | if ($value ne 'adj') { | ||
| 11664 | |||
| 11665 | $dictObj->ivAdd('adjHash', $key, 'adj'); | ||
| 11666 | } | ||
| 11667 | } | ||
| 11668 | } | ||
| 11669 | } | ||
| 11670 | |||
| 11671 | if ($version < 1_000_897) { | ||
| 11672 | |||
| 11673 | # Update dictionary by removing some IVs, which have moved to GA::Client | ||
| 11674 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11675 | |||
| 11676 | if (exists $dictObj->{primaryDirList}) { | ||
| 11677 | |||
| 11678 | delete $dictObj->{primaryDirList}; | ||
| 11679 | delete $dictObj->{shortPrimaryDirList}; | ||
| 11680 | delete $dictObj->{shortPrimaryDirHash}; | ||
| 11681 | |||
| 11682 | # (This line makes sure the correct file object's ->modifyFlag is set) | ||
| 11683 | $dictObj->ivPoke('name', $dictObj->name); | ||
| 11684 | } | ||
| 11685 | } | ||
| 11686 | } | ||
| 11687 | |||
| 11688 | if ($version < 1_000_909) { | ||
| 11689 | |||
| 11690 | # This version converts some numerical mode values to string mode values | ||
| 11691 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11692 | |||
| 11693 | if ($dictObj->nounPosn eq '0') { | ||
| 11694 | $dictObj->ivPoke('nounPosn', 'noun_adj'); | ||
| 11695 | } elsif ($dictObj->nounPosn eq '1') { | ||
| 11696 | $dictObj->ivPoke('nounPosn', 'adj_noun'); | ||
| 11697 | } | ||
| 11698 | } | ||
| 11699 | } | ||
| 11700 | |||
| 11701 | if ($version < 1_000_911) { | ||
| 11702 | |||
| 11703 | # Update dictionary with some new IVs | ||
| 11704 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11705 | |||
| 11706 | if (! exists $dictObj->{speedDirHash}) { | ||
| 11707 | |||
| 11708 | $dictObj->{speedDirHash} = {}; | ||
| 11709 | $dictObj->ivPoke( | ||
| 11710 | 'speedDirHash', | ||
| 11711 | 'n' => 'north', | ||
| 11712 | 's' => 'south', | ||
| 11713 | 'e' => 'east', | ||
| 11714 | 'w' => 'west', | ||
| 11715 | 'u' => 'up', | ||
| 11716 | 'd' => 'down', | ||
| 11717 | 'l' => 'look', | ||
| 11718 | 't' => 'northwest', | ||
| 11719 | 'y' => 'northeast', | ||
| 11720 | 'g' => 'southwest', | ||
| 11721 | 'h' => 'southeast', | ||
| 11722 | ); | ||
| 11723 | |||
| 11724 | $dictObj->{speedModifierHash} = {}; | ||
| 11725 | $dictObj->ivPoke( | ||
| 11726 | 'speedModifierHash', | ||
| 11727 | # Movement commands | ||
| 11728 | 'G' => 'go_dir', | ||
| 11729 | 'N' => 'run', | ||
| 11730 | 'A' => 'walk', | ||
| 11731 | 'F' => 'fly', | ||
| 11732 | 'W' => 'swim', | ||
| 11733 | 'V' => 'dive', | ||
| 11734 | 'S' => 'sail', | ||
| 11735 | 'I' => 'ride', | ||
| 11736 | 'D' => 'drive', | ||
| 11737 | 'R' => 'creep', | ||
| 11738 | 'E' => 'sneak', | ||
| 11739 | 'Q' => 'squeeze', | ||
| 11740 | # Non-movement commands | ||
| 11741 | 'O' => 'open_dir', | ||
| 11742 | 'C' => 'close_dir', | ||
| 11743 | 'K' => 'unlock', | ||
| 11744 | 'L' => 'lock', | ||
| 11745 | 'P' => 'pick', | ||
| 11746 | 'B' => 'break', | ||
| 11747 | ); | ||
| 11748 | } | ||
| 11749 | } | ||
| 11750 | } | ||
| 11751 | |||
| 11752 | if ($version < 1_001_299) { | ||
| 11753 | |||
| 11754 | # This version adds a new IV | ||
| 11755 | foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 11756 | |||
| 11757 | |||
| 11758 | if (! exists $dictObj->{relativeDirHash}) { | ||
| 11759 | |||
| 11760 | $dictObj->{relativeDirHash} = {}; | ||
| 11761 | $dictObj->ivEmpty('relativeDirHash'); | ||
| 11762 | $dictObj->{relativeAbbrevHash} = {}; | ||
| 11763 | $dictObj->ivEmpty('relativeAbbrevHash'); | ||
| 11764 | } | ||
| 11765 | } | ||
| 11766 | } | ||
| 11767 | |||
| 11768 | ### toolbar ############################################################################### | ||
| 11769 | |||
| 11770 | } elsif ($self->fileType eq 'toolbar') { | ||
| 11771 | |||
| 11772 | if ($version < 1_000_927) { | ||
| 11773 | |||
| 11774 | my ( | ||
| 11775 | $oldName, | ||
| 11776 | @buttonList, | ||
| 11777 | %buttonHash, | ||
| 11778 | ); | ||
| 11779 | |||
| 11780 | # This version renames one of the toolbar buttons, because of clashes with | ||
| 11781 | # GA::Client->constReservedHash | ||
| 11782 | foreach my $buttonObj ($axmud::CLIENT->ivValues('toolbarHash')) { | ||
| 11783 | |||
| 11784 | if ($buttonObj->name eq 'connect') { | ||
| 11785 | |||
| 11786 | $oldName = $buttonObj->name; | ||
| 11787 | $buttonObj->ivPoke('name', 'connect_me'); | ||
| 11788 | |||
| 11789 | } elsif ($buttonObj->name eq 'help') { | ||
| 11790 | |||
| 11791 | $oldName = $buttonObj->name; | ||
| 11792 | $buttonObj->ivPoke('name', 'help_me'); | ||
| 11793 | |||
| 11794 | } elsif ($buttonObj->name eq 'login') { | ||
| 11795 | |||
| 11796 | $oldName = $buttonObj->name; | ||
| 11797 | $buttonObj->ivPoke('name', 'login_me'); | ||
| 11798 | |||
| 11799 | } elsif ($buttonObj->name eq 'save') { | ||
| 11800 | |||
| 11801 | $oldName = $buttonObj->name; | ||
| 11802 | $buttonObj->ivPoke('name', 'save_me'); | ||
| 11803 | } | ||
| 11804 | |||
| 11805 | $buttonHash{$buttonObj->name} = $buttonObj; | ||
| 11806 | delete $buttonHash{$oldName}; | ||
| 11807 | } | ||
| 11808 | |||
| 11809 | foreach my $name ($axmud::CLIENT->toolbarList) { | ||
| 11810 | |||
| 11811 | if ($name eq 'connect') { | ||
| 11812 | push (@buttonList, 'connect_me'); | ||
| 11813 | } elsif ($name eq 'help') { | ||
| 11814 | push (@buttonList, 'help_me'); | ||
| 11815 | } elsif ($name eq 'login') { | ||
| 11816 | push (@buttonList, 'login_me'); | ||
| 11817 | } elsif ($name eq 'save') { | ||
| 11818 | push (@buttonList, 'save_me'); | ||
| 11819 | } else { | ||
| 11820 | push (@buttonList, $name); | ||
| 11821 | } | ||
| 11822 | } | ||
| 11823 | |||
| 11824 | $axmud::CLIENT->ivPoke('toolbarHash', %buttonHash); | ||
| 11825 | $axmud::CLIENT->ivPoke('toolbarList', @buttonList); | ||
| 11826 | } | ||
| 11827 | |||
| 11828 | if ($version < 1_001_017) { | ||
| 11829 | |||
| 11830 | # This version adds a toolbar button for the new quick preferences window. If the | ||
| 11831 | # user still has a toolbar button for client preference window, and a new button | ||
| 11832 | # before it | ||
| 11833 | |||
| 11834 | my ( | ||
| 11835 | $obj, | ||
| 11836 | @buttonList, | ||
| 11837 | ); | ||
| 11838 | |||
| 11839 | foreach my $item ($axmud::CLIENT->toolbarList) { | ||
| 11840 | |||
| 11841 | if ($item eq 'edit_client') { | ||
| 11842 | |||
| 11843 | # Insert the new button here | ||
| 11844 | $obj = Games::Axmud::Obj::Toolbar->new( | ||
| 11845 | 'edit_quick', | ||
| 11846 | 'Set quick preferences', | ||
| 11847 | FALSE, # Default, not custom, toolbar button | ||
| 11848 | 'book_edit.png', | ||
| 11849 | ';editquick', | ||
| 11850 | TRUE, | ||
| 11851 | TRUE, | ||
| 11852 | ); | ||
| 11853 | |||
| 11854 | if ($obj) { | ||
| 11855 | |||
| 11856 | push (@buttonList, $obj->name); | ||
| 11857 | $axmud::CLIENT->ivAdd('toolbarHash', $obj->name, $obj); | ||
| 11858 | } | ||
| 11859 | } | ||
| 11860 | |||
| 11861 | # The existing button is added after the new one | ||
| 11862 | push (@buttonList, $item); | ||
| 11863 | } | ||
| 11864 | |||
| 11865 | $axmud::CLIENT->ivPoke('toolbarList', @buttonList); | ||
| 11866 | } | ||
| 11867 | |||
| 11868 | if ($version < 1_001_507) { | ||
| 11869 | |||
| 11870 | my ( | ||
| 11871 | @newList, | ||
| 11872 | %checkHash, | ||
| 11873 | ); | ||
| 11874 | |||
| 11875 | # This version removes a toolbar button, as the client command has been removed | ||
| 11876 | foreach my $name ($axmud::CLIENT->ivKeys('toolbarHash')) { | ||
| 11877 | |||
| 11878 | my $obj = $axmud::CLIENT->ivShow('toolbarHash', $name); | ||
| 11879 | |||
| 11880 | if ($obj->instruct eq ';screenshot') { | ||
| 11881 | |||
| 11882 | $axmud::CLIENT->ivDelete('toolbarHash', $name); | ||
| 11883 | $checkHash{$name} = undef; | ||
| 11884 | } | ||
| 11885 | } | ||
| 11886 | |||
| 11887 | foreach my $name ($axmud::CLIENT->toolbarList) { | ||
| 11888 | |||
| 11889 | if (! exists $checkHash{$name}) { | ||
| 11890 | |||
| 11891 | push (@newList, $name); | ||
| 11892 | } | ||
| 11893 | } | ||
| 11894 | |||
| 11895 | $axmud::CLIENT->ivPoke('toolbarList', @newList); | ||
| 11896 | } | ||
| 11897 | |||
| 11898 | if ($version < 1_003_137) { | ||
| 11899 | |||
| 11900 | my ( | ||
| 11901 | $buttonObj, | ||
| 11902 | @buttonList, | ||
| 11903 | ); | ||
| 11904 | |||
| 11905 | # This version renames one of the toolbar buttons, as the window it opens has also | ||
| 11906 | # been renamed | ||
| 11907 | $buttonObj = $axmud::CLIENT->ivShow('toolbarHash', 'open_gui'); | ||
| 11908 | if ($buttonObj) { | ||
| 11909 | |||
| 11910 | $buttonObj->ivPoke('name', 'open_viewer'); | ||
| 11911 | |||
| 11912 | $buttonObj->ivPoke('descrip', 'Open data viewer window'); | ||
| 11913 | $buttonObj->ivPoke('iconPath', 'watermark_table.png'); | ||
| 11914 | $buttonObj->ivPoke('instruct', ';opendataviewer'); | ||
| 11915 | |||
| 11916 | $axmud::CLIENT->ivDelete('toolbarHash', 'open_gui'); | ||
| 11917 | $axmud::CLIENT->ivAdd('toolbarHash', 'open_viewer', $buttonObj); | ||
| 11918 | |||
| 11919 | foreach my $name ($axmud::CLIENT->toolbarList) { | ||
| 11920 | |||
| 11921 | if ($name eq 'open_gui') { | ||
| 11922 | push (@buttonList, 'open_viewer'); | ||
| 11923 | } else { | ||
| 11924 | push (@buttonList, $name); | ||
| 11925 | } | ||
| 11926 | } | ||
| 11927 | |||
| 11928 | $axmud::CLIENT->ivPoke('toolbarList', @buttonList); | ||
| 11929 | } | ||
| 11930 | } | ||
| 11931 | |||
| 11932 | ### usercmds ############################################################################## | ||
| 11933 | |||
| 11934 | } elsif ($self->fileType eq 'usercmds') { | ||
| 11935 | |||
| 11936 | if ($version < 1_000_507) { | ||
| 11937 | |||
| 11938 | # This version removes the ;screenshot command | ||
| 11939 | foreach my $userCmd ($axmud::CLIENT->ivKeys('userCmdHash')) { | ||
| 11940 | |||
| 11941 | my $standardCmd = $axmud::CLIENT->ivShow('userCmdHash', $userCmd); | ||
| 11942 | |||
| 11943 | if ($standardCmd eq 'screenshot') { | ||
| 11944 | |||
| 11945 | $axmud::CLIENT->ivDelete('userCmdHash', $userCmd); | ||
| 11946 | } | ||
| 11947 | } | ||
| 11948 | } | ||
| 11949 | |||
| 11950 | ## zonemaps ############################################################################### | ||
| 11951 | |||
| 11952 | } elsif ($self->fileType eq 'zonemaps') { | ||
| 11953 | |||
| 11954 | if ($version < 1_000_653) { | ||
| 11955 | |||
| 11956 | # This version adds new IVs to zonemaps | ||
| 11957 | foreach my $zonemapObj ($axmud::CLIENT->ivValues('zonemapHash')) { | ||
| 11958 | |||
| 11959 | if (! exists $zonemapObj->{tempFlag}) { | ||
| 11960 | |||
| 11961 | $zonemapObj->{tempFlag} = undef; | ||
| 11962 | $zonemapObj->ivFalse('tempFlag'); | ||
| 11963 | $zonemapObj->{tempSession} = undef; | ||
| 11964 | $zonemapObj->ivUndef('tempSession'); | ||
| 11965 | } | ||
| 11966 | } | ||
| 11967 | } | ||
| 11968 | |||
| 11969 | if ($version < 1_000_800) { | ||
| 11970 | |||
| 11971 | # This version modifies several zonemap and zone model IVs | ||
| 11972 | foreach my $zonemapObj ($axmud::CLIENT->ivValues('zonemapHash')) { | ||
| 11973 | |||
| 11974 | my (%oldReservedHash, %newReservedHash, %newModelHash); | ||
| 11975 | |||
| 11976 | if (exists $zonemapObj->{_zonemap}) { | ||
| 11977 | |||
| 11978 | delete $zonemapObj->{_zonemap}; | ||
| 11979 | |||
| 11980 | $zonemapObj->{modelCount} = $zonemapObj->{zoneModelCount}; | ||
| 11981 | delete $zonemapObj->{zoneModelCount}; | ||
| 11982 | |||
| 11983 | $zonemapObj->{gridSize} = 60; | ||
| 11984 | |||
| 11985 | foreach my $modelObj ($zonemapObj->ivValues('zoneModelHash')) { | ||
| 11986 | |||
| 11987 | $modelObj->{left} = $modelObj->{zonemapLeft}; | ||
| 11988 | delete $modelObj->{zonemapLeft}; | ||
| 11989 | |||
| 11990 | $modelObj->{top} = $modelObj->{zonemapTop}; | ||
| 11991 | delete $modelObj->{zonemapTop}; | ||
| 11992 | |||
| 11993 | $modelObj->{right} = $modelObj->{zonemapRight}; | ||
| 11994 | delete $modelObj->{zonemapRight}; | ||
| 11995 | |||
| 11996 | $modelObj->{bottom} = $modelObj->{zonemapBottom}; | ||
| 11997 | delete $modelObj->{zonemapBottom}; | ||
| 11998 | |||
| 11999 | $modelObj->{width} = $modelObj->{zonemapWidth}; | ||
| 12000 | delete $modelObj->{zonemapWidth}; | ||
| 12001 | |||
| 12002 | $modelObj->{height} = $modelObj->{zonemapHeight}; | ||
| 12003 | delete $modelObj->{zonemapHeight}; | ||
| 12004 | |||
| 12005 | $modelObj->{zonemapObj} = $modelObj->{parentZonemap}; | ||
| 12006 | delete $modelObj->{parentZonemap}; | ||
| 12007 | |||
| 12008 | $modelObj->{areaMax} = $modelObj->{winMax}; | ||
| 12009 | delete $modelObj->{winMax}; | ||
| 12010 | |||
| 12011 | $modelObj->{visibleAreaMax} = $modelObj->{winVisibleMax}; | ||
| 12012 | delete $modelObj->{winVisibleMax}; | ||
| 12013 | |||
| 12014 | $modelObj->{defaultAreaWidth} = $modelObj->{defaultWinWidth}; | ||
| 12015 | delete $modelObj->{defaultWinWidth}; | ||
| 12016 | |||
| 12017 | $modelObj->{defaultAreaHeight} = $modelObj->{defaultWinHeight}; | ||
| 12018 | delete $modelObj->{defaultWinHeight}; | ||
| 12019 | |||
| 12020 | $modelObj->{reservedFlag} = $modelObj->{reservedZoneFlag}; | ||
| 12021 | delete $modelObj->{reservedZoneFlag}; | ||
| 12022 | |||
| 12023 | # Values stored in ->reservedHash have changed | ||
| 12024 | %oldReservedHash = $modelObj->reservedHash; | ||
| 12025 | foreach my $name (keys %oldReservedHash) { | ||
| 12026 | |||
| 12027 | my $type = $oldReservedHash{$name}; | ||
| 12028 | |||
| 12029 | if ($type eq 'main' || $type eq 'map' || $type eq 'external') { | ||
| 12030 | |||
| 12031 | $newReservedHash{$name} = $type; | ||
| 12032 | |||
| 12033 | } else { | ||
| 12034 | |||
| 12035 | $newReservedHash{$name} = 'custom'; | ||
| 12036 | } | ||
| 12037 | } | ||
| 12038 | |||
| 12039 | $modelObj->{reservedHash} = \%newReservedHash; | ||
| 12040 | |||
| 12041 | $modelObj->{ownerString} = undef; | ||
| 12042 | $modelObj->{defaultEnabledWinmap} = undef; | ||
| 12043 | $modelObj->{defaultDisabledWinmap} = undef; | ||
| 12044 | $modelObj->{defaultInternalWinmap} = undef; | ||
| 12045 | |||
| 12046 | $newModelHash{$modelObj->{number}} = $modelObj; | ||
| 12047 | } | ||
| 12048 | |||
| 12049 | $zonemapObj->{modelHash} = \%newModelHash; | ||
| 12050 | delete $zonemapObj->{zoneModelHash}; | ||
| 12051 | } | ||
| 12052 | } | ||
| 12053 | } | ||
| 12054 | |||
| 12055 | ## winmaps ################################################################################ | ||
| 12056 | |||
| 12057 | } elsif ($self->fileType eq 'winmaps') { | ||
| 12058 | |||
| 12059 | if ($version < 1_001_028) { | ||
| 12060 | |||
| 12061 | my $obj; | ||
| 12062 | |||
| 12063 | # Change the name of the colour scheme for 'viewer' windows, which used to be called | ||
| 12064 | # 'gui' windows | ||
| 12065 | $obj = $axmud::CLIENT->ivShow('colourSchemeHash', 'gui'); | ||
| 12066 | if ($obj) { | ||
| 12067 | |||
| 12068 | $obj->ivPoke('name', 'viewer'); | ||
| 12069 | |||
| 12070 | $axmud::CLIENT->ivDelete('colourSchemeHash', 'gui'); | ||
| 12071 | $axmud::CLIENT->ivAdd('colourSchemeHash', 'viewer', $obj); | ||
| 12072 | } | ||
| 12073 | } | ||
| 12074 | |||
| 12075 | if ($version < 1_001_122) { | ||
| 12076 | |||
| 12077 | # This version adds an IV to colour schemes | ||
| 12078 | foreach my $obj ($axmud::CLIENT->ivValues('colourSchemeHash')) { | ||
| 12079 | |||
| 12080 | if (! exists $obj->{overrideHash}) { | ||
| 12081 | |||
| 12082 | $obj->{overrideHash} = {}; | ||
| 12083 | $obj->ivEmpty('overrideHash'); | ||
| 12084 | $obj->{overrideAllFlag} = undef; | ||
| 12085 | $obj->ivPoke('overrideAllFlag', FALSE); | ||
| 12086 | } | ||
| 12087 | } | ||
| 12088 | } | ||
| 12089 | |||
| 12090 | if ($version < 1_001_129) { | ||
| 12091 | |||
| 12092 | # This version removes an initialisation setting from pane objects (GA::Table::Pane) | ||
| 12093 | # The IV modified is in the winzone object (GA::Obj::Winzone) | ||
| 12094 | foreach my $winmapObj ($axmud::CLIENT->ivValues('winmapHash')) { | ||
| 12095 | |||
| 12096 | foreach my $zoneObj ($winmapObj->ivValues('zoneHash')) { | ||
| 12097 | |||
| 12098 | if ($zoneObj->packageName eq 'Games::Axmud::Table::Pane') { | ||
| 12099 | |||
| 12100 | $zoneObj->ivDelete('initHash', 'no_label_flag'); | ||
| 12101 | } | ||
| 12102 | } | ||
| 12103 | } | ||
| 12104 | } | ||
| 12105 | |||
| 12106 | if ($version < 1_001_203) { | ||
| 12107 | |||
| 12108 | # This version adds a new button in 'main' windows, for which we must update the | ||
| 12109 | # equivalent winmaps | ||
| 12110 | foreach my $winmapObj ($axmud::CLIENT->ivValues('winmapHash')) { | ||
| 12111 | |||
| 12112 | my (@oldList, @newList); | ||
| 12113 | |||
| 12114 | if ( | ||
| 12115 | $winmapObj->name eq 'main_fill' | ||
| 12116 | || $winmapObj->name eq 'main_part' | ||
| 12117 | || $winmapObj->name eq 'main_empty' | ||
| 12118 | ) { | ||
| 12119 | @oldList = $winmapObj->stripInitList; | ||
| 12120 | if (@oldList) { | ||
| 12121 | |||
| 12122 | do { | ||
| 12123 | |||
| 12124 | my ($package, $hashRef); | ||
| 12125 | |||
| 12126 | $package = shift @oldList; | ||
| 12127 | $hashRef = shift @oldList; | ||
| 12128 | |||
| 12129 | if ( | ||
| 12130 | $package eq 'Games::Axmud::Strip::Entry' | ||
| 12131 | && defined $hashRef | ||
| 12132 | ) { | ||
| 12133 | $$hashRef{'console_flag'} = TRUE; | ||
| 12134 | } | ||
| 12135 | |||
| 12136 | push (@newList, $package, $hashRef); | ||
| 12137 | |||
| 12138 | } until (! @oldList); | ||
| 12139 | |||
| 12140 | $winmapObj->{stripInitList} = \@newList; | ||
| 12141 | } | ||
| 12142 | } | ||
| 12143 | } | ||
| 12144 | } | ||
| 12145 | |||
| 12146 | if ($version < 1_001_393) { | ||
| 12147 | |||
| 12148 | # This version adds a new strip object, for which we must update the equivalent | ||
| 12149 | # winmaps | ||
| 12150 | # This version adds a new button in 'main' windows, for which we must update the | ||
| 12151 | # equivalent winmaps | ||
| 12152 | foreach my $winmapObj ($axmud::CLIENT->ivValues('winmapHash')) { | ||
| 12153 | |||
| 12154 | my (@oldList, @newList); | ||
| 12155 | |||
| 12156 | if ( | ||
| 12157 | $winmapObj->name eq 'main_fill' | ||
| 12158 | || $winmapObj->name eq 'main_part' | ||
| 12159 | || $winmapObj->name eq 'main_empty' | ||
| 12160 | ) { | ||
| 12161 | @oldList = $winmapObj->stripInitList; | ||
| 12162 | if (@oldList) { | ||
| 12163 | |||
| 12164 | do { | ||
| 12165 | |||
| 12166 | my ($package, $hashRef); | ||
| 12167 | |||
| 12168 | $package = shift @oldList; | ||
| 12169 | $hashRef = shift @oldList; | ||
| 12170 | |||
| 12171 | if ($package eq 'Games::Axmud::Strip::Entry') { | ||
| 12172 | |||
| 12173 | # Add the search box just above the entry strip object (which | ||
| 12174 | # we'll assume still exists) | ||
| 12175 | push (@newList, 'Games::Axmud::Strip::SearchBox', undef); | ||
| 12176 | |||
| 12177 | # The entry strip object itself gets two new flags | ||
| 12178 | $$hashRef{'add_flag'} = TRUE; | ||
| 12179 | $$hashRef{'search_flag'} = TRUE; | ||
| 12180 | } | ||
| 12181 | |||
| 12182 | push (@newList, $package, $hashRef); | ||
| 12183 | |||
| 12184 | } until (! @oldList); | ||
| 12185 | |||
| 12186 | $winmapObj->{stripInitList} = \@newList; | ||
| 12187 | } | ||
| 12188 | } | ||
| 12189 | } | ||
| 12190 | } | ||
| 12191 | |||
| 12192 | if ($version < 1_001_400) { | ||
| 12193 | |||
| 12194 | # This version adds an IV to colour scheme objects | ||
| 12195 | foreach my $obj ($axmud::CLIENT->ivValues('colourSchemeHash')) { | ||
| 12196 | |||
| 12197 | if (! exists $obj->{wrapMode}) { | ||
| 12198 | |||
| 12199 | $obj->{wrapMode} = undef; | ||
| 12200 | $obj->ivPoke('wrapMode', 'wrap_word_char'); | ||
| 12201 | } | ||
| 12202 | } | ||
| 12203 | } | ||
| 12204 | |||
| 12205 | ## tts #################################################################################### | ||
| 12206 | |||
| 12207 | } elsif ($self->fileType eq 'tts') { | ||
| 12208 | |||
| 12209 | if ($version < 1_001_005) { | ||
| 12210 | |||
| 12211 | # This version adds support for a new TTS engine. Extremely unlikely that anyone has | ||
| 12212 | # created a configuration object with the same name, but we'll overwrite it, if so | ||
| 12213 | my $obj = Games::Axmud::Obj::Tts->new( | ||
| 12214 | 'esng', | ||
| 12215 | 'esng', | ||
| 12216 | 'en', | ||
| 12217 | 150, | ||
| 12218 | undef, | ||
| 12219 | 50, | ||
| 12220 | undef, | ||
| 12221 | ); | ||
| 12222 | |||
| 12223 | if ($obj) { | ||
| 12224 | |||
| 12225 | $axmud::CLIENT->add_ttsObj($obj); | ||
| 12226 | } | ||
| 12227 | |||
| 12228 | # Also update the default values for the TTS configuration for the swift engine, as | ||
| 12229 | # they use different values on MS Windows and Linux | ||
| 12230 | my $obj2 = $axmud::CLIENT->ivShow('ttsObjHash', 'swift'); | ||
| 12231 | if ($obj2) { | ||
| 12232 | |||
| 12233 | $obj2->ivUndef('speed'); | ||
| 12234 | $obj2->ivUndef('rate'); | ||
| 12235 | $obj2->ivUndef('pitch'); | ||
| 12236 | $obj2->ivUndef('volume'); | ||
| 12237 | } | ||
| 12238 | } | ||
| 12239 | |||
| 12240 | if ($version < 1_001_133) { | ||
| 12241 | |||
| 12242 | my ($chanObj, $divObj); | ||
| 12243 | |||
| 12244 | # Add a TTS configuration object for the new Channels task, by cloning the object | ||
| 12245 | # for the existing Divert task | ||
| 12246 | if (! $axmud::CLIENT->ivShow('ttsObjHash', 'channels')) { | ||
| 12247 | |||
| 12248 | $divObj = $axmud::CLIENT->ivShow('ttsObjHash', 'divert'); | ||
| 12249 | if ($divObj) { | ||
| 12250 | |||
| 12251 | $chanObj = $divObj->clone('channels'); | ||
| 12252 | if ($chanObj) { | ||
| 12253 | |||
| 12254 | $axmud::CLIENT->add_ttsObj($chanObj); | ||
| 12255 | } | ||
| 12256 | } | ||
| 12257 | |||
| 12258 | # Update other Client hashes | ||
| 12259 | $axmud::CLIENT->ivAdd('ttsFlagAttribHash', 'channels', 'channels_task'); | ||
| 12260 | } | ||
| 12261 | } | ||
| 12262 | |||
| 12263 | if ($version < 1_001_401) { | ||
| 12264 | |||
| 12265 | # This version changes the scale used for speed, rate, pitch and volume. We now use | ||
| 12266 | # a standard range of 0-100 for all speech engines | ||
| 12267 | # Update all TTS configuration objects | ||
| 12268 | foreach my $ttsObj ($axmud::CLIENT->ivValues('ttsObjHash')) { | ||
| 12269 | |||
| 12270 | my ($speed, $rate, $pitch, $volume); | ||
| 12271 | |||
| 12272 | if ($ttsObj->engine eq 'espeak') { | ||
| 12273 | |||
| 12274 | $speed = int(($ttsObj->speed - 10) / 1.9); | ||
| 12275 | $pitch = int($ttsObj->pitch); | ||
| 12276 | |||
| 12277 | } elsif ($ttsObj->engine eq 'esng') { | ||
| 12278 | |||
| 12279 | $speed = int(($ttsObj->speed - 10) / 1.9); | ||
| 12280 | $pitch = int($ttsObj->pitch); | ||
| 12281 | |||
| 12282 | # Some default values seem to have been missing from | ||
| 12283 | # GA::Client->constTtsDefaultList; fill them in as we go | ||
| 12284 | if (! defined $ttsObj->volume) { | ||
| 12285 | $volume = 80; | ||
| 12286 | } else { | ||
| 12287 | $volume = int($ttsObj->volume / 2); | ||
| 12288 | } | ||
| 12289 | |||
| 12290 | # (flite doesn't use speed/rate/pitch/volume) | ||
| 12291 | |||
| 12292 | } elsif ($ttsObj->engine eq 'festival') { | ||
| 12293 | |||
| 12294 | $rate = int(($ttsObj->rate - 0.5) * 66); | ||
| 12295 | $volume = int(($ttsObj->volume - 0.33) * 17.6); | ||
| 12296 | |||
| 12297 | } elsif ($ttsObj->engine eq 'swift') { | ||
| 12298 | |||
| 12299 | if ($^O eq 'MSWin32') { | ||
| 12300 | |||
| 12301 | if (! defined $ttsObj->speed) { | ||
| 12302 | $speed = 30; | ||
| 12303 | } else { | ||
| 12304 | $speed = int(($ttsObj->speed - 100) / 3); | ||
| 12305 | } | ||
| 12306 | |||
| 12307 | } else { | ||
| 12308 | |||
| 12309 | if (! defined $ttsObj->rate) { | ||
| 12310 | $rate = 50; | ||
| 12311 | } else { | ||
| 12312 | $rate = int(($ttsObj->rate - 0.5) * 66); | ||
| 12313 | } | ||
| 12314 | } | ||
| 12315 | |||
| 12316 | if (! defined $ttsObj->pitch) { | ||
| 12317 | $pitch = 50; | ||
| 12318 | } else { | ||
| 12319 | $pitch = int($ttsObj->pitch * 20); | ||
| 12320 | } | ||
| 12321 | |||
| 12322 | if (! defined $ttsObj->volume) { | ||
| 12323 | $volume = 80; | ||
| 12324 | } elsif ($^O eq 'MSWin32') { | ||
| 12325 | $volume = int($ttsObj->volume); | ||
| 12326 | } else { | ||
| 12327 | $volume = int(($ttsObj->volume - 0.33) * 17.6); | ||
| 12328 | } | ||
| 12329 | } | ||
| 12330 | |||
| 12331 | # For all four values, take care of rounding errors by increasing value of 98 | ||
| 12332 | # or above to 100 | ||
| 12333 | if (defined $speed && $speed >= 98) { | ||
| 12334 | |||
| 12335 | $speed = 100; | ||
| 12336 | } | ||
| 12337 | |||
| 12338 | if (defined $rate && $rate >= 98) { | ||
| 12339 | |||
| 12340 | $rate = 100; | ||
| 12341 | } | ||
| 12342 | |||
| 12343 | if (defined $pitch && $pitch >= 98) { | ||
| 12344 | |||
| 12345 | $pitch = 100; | ||
| 12346 | } | ||
| 12347 | |||
| 12348 | if (defined $volume && $volume >= 98) { | ||
| 12349 | |||
| 12350 | $volume = 100; | ||
| 12351 | } | ||
| 12352 | |||
| 12353 | # Update the configuration. Some of these values may still be 'undef' | ||
| 12354 | $ttsObj->ivPoke('speed', $speed); | ||
| 12355 | $ttsObj->ivPoke('rate', $rate); | ||
| 12356 | $ttsObj->ivPoke('pitch', $pitch); | ||
| 12357 | $ttsObj->ivPoke('volume', $volume); | ||
| 12358 | } | ||
| 12359 | } | ||
| 12360 | } | ||
| 12361 | |||
| 12362 | return 1; | ||
| 12363 | } | ||
| 12364 | |||
| 12365 | sub patchWorldProf { | ||
| 12366 | |||
| 12367 | # Called by $self->loadDataFile for a world profile that must be patched due to serious | ||
| 12368 | # problems, or whose DNS/IP/port has changed | ||
| 12369 | # Checks the version number of the loaded file against the version number specified by the | ||
| 12370 | # GA::Client IV, and applies the patch, if required | ||
| 12371 | # | ||
| 12372 | # Expected arguments | ||
| 12373 | # $world - The name of the world profile | ||
| 12374 | # $fileVersion - The Axmud version used to save the file that the calling function has | ||
| 12375 | # just loaded | ||
| 12376 | # | ||
| 12377 | # Return values | ||
| 12378 | # 'undef' on improper arguments, if the world profile doesn't need to be patched or if the | ||
| 12379 | # user declines to apply a patch | ||
| 12380 | # 1 if the world profile is patched | ||
| 12381 | |||
| 12382 | my ($self, $world, $fileVersion, $check) = @_; | ||
| 12383 | |||
| 12384 | # Local variables | ||
| 12385 | my ($worldObj, $patchVersion, $choice); | ||
| 12386 | |||
| 12387 | # Check for improper arguments | ||
| 12388 | if (! defined $world || ! defined $fileVersion || defined $check) { | ||
| 12389 | |||
| 12390 | return $axmud::CLIENT->writeImproper($self->_objClass . '->patchWorldProf', @_); | ||
| 12391 | } | ||
| 12392 | |||
| 12393 | # Import the world profile | ||
| 12394 | $worldObj = $axmud::CLIENT->ivShow('worldProfHash', $world); | ||
| 12395 | |||
| 12396 | # Convert versions, e.g. '1.1.0' to '1_001_000' (the calling function has already checked | ||
| 12397 | # that $world exists in GA::Client->constWorldPatchHash | ||
| 12398 | $fileVersion = $axmud::CLIENT->convertVersion($fileVersion); | ||
| 12399 | $patchVersion = $axmud::CLIENT->convertVersion( | ||
| 12400 | $axmud::CLIENT->ivShow('constWorldPatchHash', $world), | ||
| 12401 | ); | ||
| 12402 | |||
| 12403 | if ($fileVersion >= $patchVersion) { | ||
| 12404 | |||
| 12405 | # No patch required | ||
| 12406 | return undef; | ||
| 12407 | } | ||
| 12408 | |||
| 12409 | # If the user has ever connected to this world, ask permission before patching it | ||
| 12410 | # Exception: if GA::Client->mainWin is undefined, it's because the global variable | ||
| 12411 | # $TEST_MODE_FLAG is TRUE; in that case, don't bother asking for permission | ||
| 12412 | if ($worldObj->numberConnects && $axmud::CLIENT->mainWin) { | ||
| 12413 | |||
| 12414 | # If the existing file object needs to be saved, asked permission before importing data | ||
| 12415 | # into it | ||
| 12416 | $choice = $axmud::CLIENT->mainWin->showMsgDialogue( | ||
| 12417 | 'Patch pre-configured world', | ||
| 12418 | 'question', | ||
| 12419 | 'The world profile \'' . $world . '\' requires a patch. Do you want to apply this' | ||
| 12420 | . ' patch now? (Click \'Yes\' unless you have modified the world profile yourself' | ||
| 12421 | . ' and you are CERTAIN that it is working properly)', | ||
| 12422 | 'yes-no', | ||
| 12423 | ); | ||
| 12424 | |||
| 12425 | if ($choice eq 'no') { | ||
| 12426 | |||
| 12427 | return undef; | ||
| 12428 | } | ||
| 12429 | } | ||
| 12430 | |||
| 12431 | |||
| 12432 | if ($world eq 'archipelago' && $fileVersion < 1_003_000) { | ||
| 12433 | |||
| 12434 | $worldObj->ivPoke('referURL', 'http://mudstats.com/World/ArchipelagoMUD'); | ||
| 12435 | } | ||
| 12436 | |||
| 12437 | if ( | ||
| 12438 | ( | ||
| 12439 | $world eq 'achaea' || $world eq 'aetolia' || $world eq 'imperian' | ||
| 12440 | || $world eq 'lusternia' | ||
| 12441 | ) && $fileVersion < 1_002_041 | ||
| 12442 | ) { | ||
| 12443 | my $compObj; | ||
| 12444 | |||
| 12445 | # Fix for IRE's odd habit of sending a single EOR and a single SGA, which permanently | ||
| 12446 | # disables the prompt-checking code in GA::Session->processLinePortion | ||
| 12447 | $worldObj->ivAdd('telnetOverrideHash', 'sga', undef); | ||
| 12448 | $worldObj->ivAdd('telnetOverrideHash', 'eor', undef); | ||
| 12449 | # Fix for IRE's refusal to do MXP telnet negotiation | ||
| 12450 | $worldObj->ivAdd('mxpOverrideHash', 'perm', TRUE); | ||
| 12451 | |||
| 12452 | # Also remove the '(road)' in Achaea room titles | ||
| 12453 | if ($world eq 'achaea') { | ||
| 12454 | |||
| 12455 | $compObj = $worldObj->ivShow('componentHash', 'verb_title'); | ||
| 12456 | if ($compObj) { | ||
| 12457 | |||
| 12458 | $compObj->{usePatternGroups} = '(.*)\.'; | ||
| 12459 | } | ||
| 12460 | } | ||
| 12461 | } | ||
| 12462 | |||
| 12463 | if ($world eq 'alteraeon' && $fileVersion < 1_001_270) { | ||
| 12464 | |||
| 12465 | # Patch to fix bad regex in the 'verb_exit' component | ||
| 12466 | my $compObj = $worldObj->ivShow('componentHash', 'verb_exit'); | ||
| 12467 | if ($compObj) { | ||
| 12468 | |||
| 12469 | $compObj->ivPoke('startPatternList', '^\[Exits: '); | ||
| 12470 | } | ||
| 12471 | } | ||
| 12472 | |||
| 12473 | if ($world eq 'avalonrpg' && $fileVersion < 1_001_012) { | ||
| 12474 | |||
| 12475 | my ($compObj, $missionObj); | ||
| 12476 | |||
| 12477 | # Patch to fix handling of room statements, which doesn't work at night, and to fix the | ||
| 12478 | # login mission, which no longer works at all | ||
| 12479 | $worldObj->ivDelete('componentHash', 'ignore_line'); | ||
| 12480 | |||
| 12481 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 12482 | $axmud::CLIENT, | ||
| 12483 | $worldObj, | ||
| 12484 | 'ignore_line', | ||
| 12485 | 'ignore_line', | ||
| 12486 | ); | ||
| 12487 | |||
| 12488 | if ($compObj) { | ||
| 12489 | |||
| 12490 | $compObj->{size} = 0; | ||
| 12491 | $compObj->{minSize} = 0; # Optional | ||
| 12492 | $compObj->{maxSize} = 1; | ||
| 12493 | $compObj->{analyseMode} = 'check_line'; | ||
| 12494 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 12495 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 12496 | $compObj->{combineLinesFlag} = FALSE; | ||
| 12497 | |||
| 12498 | $compObj->{startPatternList} = [ | ||
| 12499 | '^The sky ', | ||
| 12500 | ]; | ||
| 12501 | $compObj->{startTagList} = []; | ||
| 12502 | $compObj->{startAllFlag} = FALSE; | ||
| 12503 | $compObj->{startTagMode} = 'default'; | ||
| 12504 | |||
| 12505 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 12506 | } | ||
| 12507 | |||
| 12508 | $missionObj = $worldObj->ivShow('missionHash', 'avalon_login'); | ||
| 12509 | if ($missionObj) { | ||
| 12510 | |||
| 12511 | $missionObj->ivPoke( | ||
| 12512 | 'missionList', | ||
| 12513 | 't What is the name', | ||
| 12514 | 'n', # Send char name | ||
| 12515 | 't What is the password', | ||
| 12516 | 'w', # Send account password | ||
| 12517 | 't Land of Avalon', | ||
| 12518 | '> ', | ||
| 12519 | ';login', | ||
| 12520 | ); | ||
| 12521 | } | ||
| 12522 | } | ||
| 12523 | |||
| 12524 | if ($world eq 'darkrealms' && $fileVersion < 1_003_000) { | ||
| 12525 | |||
| 12526 | $worldObj->ivPoke('ipv4', '64.227.89.30 1138'); | ||
| 12527 | $worldObj->ivPoke('worldURL', 'http://darkrealmscos.com/'); | ||
| 12528 | } | ||
| 12529 | |||
| 12530 | if ($world eq 'dawn' && $fileVersion < 1_003_000) { | ||
| 12531 | |||
| 12532 | $worldObj->ivPoke('dns', 'dawnmud.com'); | ||
| 12533 | $worldObj->ivPoke('ipv4', '76.91.216.39'); | ||
| 12534 | } | ||
| 12535 | |||
| 12536 | if ( | ||
| 12537 | ($world eq 'dsdev' || $world eq 'dslocal' || $world eq 'dsprime') | ||
| 12538 | && $fileVersion < 1_001_270 | ||
| 12539 | ) { | ||
| 12540 | my $compObj; | ||
| 12541 | |||
| 12542 | # Patch to turn off VT100 control sequences, which are just annoying in a test | ||
| 12543 | # environment | ||
| 12544 | $worldObj->ivAdd('termOverrideHash', 'useCtrlSeqFlag', FALSE); | ||
| 12545 | |||
| 12546 | # Also use an excess command delay that doesn't cause a DS refusal | ||
| 12547 | $worldObj->ivPoke('excessCmdDelay', 1.5); | ||
| 12548 | |||
| 12549 | # Also solved problem of command prompts being added to room titles, after several | ||
| 12550 | # simultaneous movement commands | ||
| 12551 | $compObj = $worldObj->ivShow('componentHash', 'verb_title'); | ||
| 12552 | if ($compObj) { | ||
| 12553 | |||
| 12554 | $compObj->ivPoke('usePatternGroups', 'hp\:.*mp\:.*sp\:.*\>\s(.*)'); | ||
| 12555 | } | ||
| 12556 | } | ||
| 12557 | |||
| 12558 | if ($world eq 'discworld' && $fileVersion < 1_001_343) { | ||
| 12559 | |||
| 12560 | my $compObj; | ||
| 12561 | |||
| 12562 | # Patch to fix various issues over several versions of Axmud | ||
| 12563 | $worldObj->ivPush( | ||
| 12564 | 'lockedPatternList', | ||
| 12565 | '^The .* swings shut in your face', | ||
| 12566 | ); | ||
| 12567 | |||
| 12568 | $worldObj->ivPush( | ||
| 12569 | 'failExitPatternList', | ||
| 12570 | '^You just crawled\. Give your arms a break', | ||
| 12571 | '^You are too tall to go that way', | ||
| 12572 | '^You struggle to leave (.*), but you can\'t make any headway', | ||
| 12573 | ); | ||
| 12574 | |||
| 12575 | # (Replace existing regex) | ||
| 12576 | $worldObj->ivPoke( | ||
| 12577 | 'darkRoomPatternList', | ||
| 12578 | 'It\'s dark here, isn\'t it', | ||
| 12579 | ); | ||
| 12580 | |||
| 12581 | $worldObj->ivPoke( | ||
| 12582 | 'transientExitPatternList', | ||
| 12583 | 'enter (.*) carriage', | ||
| 12584 | undef, | ||
| 12585 | 'enter door', | ||
| 12586 | undef, | ||
| 12587 | ); | ||
| 12588 | |||
| 12589 | # (MXP supplies gauge data, so the Status task doesn't need to create its own gauge | ||
| 12590 | # level) | ||
| 12591 | $worldObj->ivEmpty('gaugeFormatList'); | ||
| 12592 | # (Translate gauge entities into Status task variables) | ||
| 12593 | $worldObj->ivPoke( | ||
| 12594 | 'mxpStatusVarHash', | ||
| 12595 | 'hp' => 'health_points', | ||
| 12596 | 'maxhp' => 'health_points_max', | ||
| 12597 | 'gp' => 'guild_points', | ||
| 12598 | 'maxgp' => 'guild_points_max', | ||
| 12599 | 'sp' => 'social_points', | ||
| 12600 | 'maxsp' => 'social_points_max', | ||
| 12601 | 'xp' => 'xp_current', | ||
| 12602 | ); | ||
| 12603 | |||
| 12604 | $worldObj->ivPoke( | ||
| 12605 | 'verboseAnchorPatternList', | ||
| 12606 | '^.*There are (.*) obvious exits\: (.*)', | ||
| 12607 | '^.*There is one obvious exit\: (.*)', | ||
| 12608 | '^.*There are no obvious exits\.', | ||
| 12609 | ); | ||
| 12610 | |||
| 12611 | $worldObj->ivPoke( | ||
| 12612 | 'verboseExitLeftMarkerList', | ||
| 12613 | '^.*There are (.*) obvious exits\: ', | ||
| 12614 | '^.*There is one obvious exit\: ', | ||
| 12615 | '^.*There are no obvious exits\.', | ||
| 12616 | ); | ||
| 12617 | |||
| 12618 | $worldObj->ivPoke( | ||
| 12619 | 'briefAnchorPatternList', | ||
| 12620 | '\ \[(.*)\]\.\s*$', | ||
| 12621 | ); | ||
| 12622 | |||
| 12623 | $worldObj->ivDelete('componentHash', 'verb_descrip'); | ||
| 12624 | $worldObj->ivDelete('componentHash', 'verb_descrip_1'); | ||
| 12625 | $worldObj->ivDelete('componentHash', 'verb_descrip_2'); | ||
| 12626 | $worldObj->ivDelete('componentHash', 'ignore_line'); | ||
| 12627 | $worldObj->ivDelete('componentHash', 'verb_exit'); | ||
| 12628 | $worldObj->ivDelete('componentHash', 'brief_title_exit'); | ||
| 12629 | |||
| 12630 | $worldObj->ivPoke( | ||
| 12631 | 'verboseComponentList', | ||
| 12632 | 'verb_descrip_1', # no MXP | ||
| 12633 | 'verb_descrip_2', # MXP | ||
| 12634 | 'ignore_line', | ||
| 12635 | 'anchor', | ||
| 12636 | 'verb_exit', | ||
| 12637 | ); | ||
| 12638 | |||
| 12639 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 12640 | $axmud::CLIENT, | ||
| 12641 | $worldObj, | ||
| 12642 | 'verb_descrip_1', | ||
| 12643 | 'verb_descrip', | ||
| 12644 | ); | ||
| 12645 | |||
| 12646 | if ($compObj) { | ||
| 12647 | |||
| 12648 | $compObj->{size} = 0; | ||
| 12649 | $compObj->{minSize} = 0; | ||
| 12650 | $compObj->{maxSize} = 16; | ||
| 12651 | $compObj->{analyseMode} = 'check_line'; | ||
| 12652 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 12653 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 12654 | $compObj->{combineLinesFlag} = FALSE; | ||
| 12655 | |||
| 12656 | $compObj->{usePatternBackRefs} = '^\s[\s\-\|\\\/\&\$\@\+\*]{10}\s(.*)', | ||
| 12657 | |||
| 12658 | $compObj->{startPatternList} = [ | ||
| 12659 | '^\s[\s\-\|\\\/\&\$\@\+\*]{10}\s(.*)', | ||
| 12660 | ], | ||
| 12661 | $compObj->{startTagList} = []; | ||
| 12662 | $compObj->{startAllFlag} = FALSE; | ||
| 12663 | $compObj->{startTagMode} = 'default'; | ||
| 12664 | |||
| 12665 | $compObj->{stopBeforeNoPatternList} = [ | ||
| 12666 | '^\s[\s\-\|\\\/\&\$\@\+\*]{10}\s(.*)', | ||
| 12667 | ], | ||
| 12668 | $compObj->{stopBeforeNoTagList} = []; | ||
| 12669 | $compObj->{stopBeforeNoAllFlag} = FALSE; | ||
| 12670 | $compObj->{stopBeforeNoTagMode} = 'default'; | ||
| 12671 | |||
| 12672 | $compObj->{stopBeforePatternList} = [ | ||
| 12673 | '^\s..........\sIt is ', | ||
| 12674 | '^\s..........\sThe land is lit up ', | ||
| 12675 | ], | ||
| 12676 | $compObj->{stopBeforeTagList} = []; | ||
| 12677 | $compObj->{stopBeforeAllFlag} = FALSE; | ||
| 12678 | $compObj->{stopBeforeTagMode} = 'default'; | ||
| 12679 | |||
| 12680 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 12681 | } | ||
| 12682 | |||
| 12683 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 12684 | $axmud::CLIENT, | ||
| 12685 | $worldObj, | ||
| 12686 | 'verb_descrip_2', | ||
| 12687 | 'verb_descrip', | ||
| 12688 | ); | ||
| 12689 | |||
| 12690 | if ($compObj) { | ||
| 12691 | |||
| 12692 | $compObj->{size} = 0; | ||
| 12693 | $compObj->{minSize} = 0; | ||
| 12694 | $compObj->{maxSize} = 16; | ||
| 12695 | $compObj->{analyseMode} = 'check_line'; | ||
| 12696 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 12697 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 12698 | $compObj->{combineLinesFlag} = FALSE; | ||
| 12699 | |||
| 12700 | $compObj->{startPatternList} = [ | ||
| 12701 | '^\w', | ||
| 12702 | ], | ||
| 12703 | $compObj->{startTagList} = []; | ||
| 12704 | $compObj->{startAllFlag} = FALSE; | ||
| 12705 | $compObj->{startTagMode} = 'default'; | ||
| 12706 | |||
| 12707 | $compObj->{stopBeforeNoPatternList} = [ | ||
| 12708 | '^\w', | ||
| 12709 | ], | ||
| 12710 | $compObj->{stopBeforeNoTagList} = []; | ||
| 12711 | $compObj->{stopBeforeNoAllFlag} = FALSE; | ||
| 12712 | $compObj->{stopBeforeNoTagMode} = 'default'; | ||
| 12713 | |||
| 12714 | $compObj->{stopBeforePatternList} = [ | ||
| 12715 | '^It is ', | ||
| 12716 | '^The land is lit up ', | ||
| 12717 | ], | ||
| 12718 | $compObj->{stopBeforeTagList} = []; | ||
| 12719 | $compObj->{stopBeforeAllFlag} = FALSE; | ||
| 12720 | $compObj->{stopBeforeTagMode} = 'default'; | ||
| 12721 | |||
| 12722 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 12723 | } | ||
| 12724 | |||
| 12725 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 12726 | $axmud::CLIENT, | ||
| 12727 | $worldObj, | ||
| 12728 | 'ignore_line', | ||
| 12729 | 'ignore_line', | ||
| 12730 | ); | ||
| 12731 | |||
| 12732 | if ($compObj) { | ||
| 12733 | |||
| 12734 | $compObj->{size} = 0; | ||
| 12735 | $compObj->{minSize} = 0; | ||
| 12736 | $compObj->{maxSize} = 16; | ||
| 12737 | $compObj->{analyseMode} = 'check_line'; | ||
| 12738 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 12739 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 12740 | $compObj->{combineLinesFlag} = FALSE; | ||
| 12741 | |||
| 12742 | $compObj->{startPatternList} = []; | ||
| 12743 | $compObj->{startTagList} = [ | ||
| 12744 | 'yellow', # no mxp | ||
| 12745 | '#FF8700', # mxp | ||
| 12746 | 'x208', # xterm256 | ||
| 12747 | ]; | ||
| 12748 | $compObj->{startAllFlag} = FALSE; | ||
| 12749 | $compObj->{startTagMode} = 'default'; | ||
| 12750 | |||
| 12751 | $compObj->{stopBeforeNoPatternList} = []; | ||
| 12752 | $compObj->{stopBeforeNoTagList} = [ | ||
| 12753 | 'yellow', | ||
| 12754 | '#FF8700', | ||
| 12755 | 'x208', | ||
| 12756 | ]; | ||
| 12757 | $compObj->{stopBeforeNoAllFlag} = FALSE; | ||
| 12758 | $compObj->{stopBeforeNoTagMode} = 'default'; | ||
| 12759 | |||
| 12760 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 12761 | } | ||
| 12762 | |||
| 12763 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 12764 | $axmud::CLIENT, | ||
| 12765 | $worldObj, | ||
| 12766 | 'verb_exit', | ||
| 12767 | 'verb_exit', | ||
| 12768 | ); | ||
| 12769 | |||
| 12770 | if ($compObj) { | ||
| 12771 | |||
| 12772 | $compObj->{size} = 1; | ||
| 12773 | $compObj->{analyseMode} = 'check_line'; | ||
| 12774 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 12775 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 12776 | $compObj->{combineLinesFlag} = TRUE; | ||
| 12777 | |||
| 12778 | $compObj->{startPatternList} = [ | ||
| 12779 | '^.*There are (.*) obvious exits\: (.*)', | ||
| 12780 | '^.*There is one obvious exit\: (.*)', | ||
| 12781 | '^.*There are no obvious exits\.', | ||
| 12782 | ]; | ||
| 12783 | $compObj->{startTagList} = []; | ||
| 12784 | $compObj->{startAllFlag} = FALSE; | ||
| 12785 | $compObj->{startTagMode} = 'default'; | ||
| 12786 | |||
| 12787 | $compObj->{stopBeforeNoPatternList} = []; | ||
| 12788 | $compObj->{stopBeforeNoTagList} = []; | ||
| 12789 | $compObj->{stopBeforeNoAllFlag} = FALSE; | ||
| 12790 | $compObj->{stopBeforeNoTagMode} = 'default'; | ||
| 12791 | |||
| 12792 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 12793 | } | ||
| 12794 | |||
| 12795 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 12796 | $axmud::CLIENT, | ||
| 12797 | $worldObj, | ||
| 12798 | 'brief_title_exit', | ||
| 12799 | 'brief_title_exit', | ||
| 12800 | ); | ||
| 12801 | |||
| 12802 | if ($compObj) { | ||
| 12803 | |||
| 12804 | $compObj->{size} = 1; | ||
| 12805 | $compObj->{analyseMode} = 'check_line'; | ||
| 12806 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 12807 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 12808 | $compObj->{combineLinesFlag} = FALSE; | ||
| 12809 | |||
| 12810 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 12811 | } | ||
| 12812 | } | ||
| 12813 | |||
| 12814 | if ($world eq 'dunemud' && $fileVersion < 1_002_000) { | ||
| 12815 | |||
| 12816 | $worldObj->ivPoke('dns', 'dunemud.net'); | ||
| 12817 | $worldObj->ivPoke('ipv4', '68.183.23.43'); | ||
| 12818 | } | ||
| 12819 | |||
| 12820 | if ($world eq 'edmud' && $fileVersion < 1_003_000) { | ||
| 12821 | |||
| 12822 | $worldObj->ivPoke('dns', 'eternaldarkness.net'); | ||
| 12823 | $worldObj->ivPoke('ipv4', '216.136.9.8'); | ||
| 12824 | $worldObj->ivPoke('worldURL', 'eternaldarkness.net'); | ||
| 12825 | } | ||
| 12826 | |||
| 12827 | if ($world eq 'fkindgoms' && $fileVersion < 1_003_000) { | ||
| 12828 | |||
| 12829 | $worldObj->ivPoke('port', 4000); | ||
| 12830 | } | ||
| 12831 | |||
| 12832 | if ($world eq 'forestsedge' && $fileVersion < 1_003_000) { | ||
| 12833 | |||
| 12834 | $worldObj->ivPoke('dns', 'mud.theforestsedge.com'); | ||
| 12835 | $worldObj->ivPoke('ipv4', '167.114.137.18'); | ||
| 12836 | $worldObj->ivPoke('port', 4000); | ||
| 12837 | } | ||
| 12838 | |||
| 12839 | if ($world eq 'icesus' && $fileVersion < 1_003_000) { | ||
| 12840 | |||
| 12841 | $worldObj->ivPoke('dns', 'naga.icesus.org'); | ||
| 12842 | $worldObj->ivPoke('ipv4', '95.216.243.162'); | ||
| 12843 | $worldObj->ivPoke('port', 4000); | ||
| 12844 | $worldObj->ivPoke('worldURL', 'http://www.icesus.org/'); | ||
| 12845 | } | ||
| 12846 | |||
| 12847 | if ($world eq 'islands' && $fileVersion < 1_002_000) { | ||
| 12848 | |||
| 12849 | $worldObj->ivPoke('dns', 'play.islands-game.live'); | ||
| 12850 | $worldObj->ivPoke('ipv4', '45.79.14.59'); | ||
| 12851 | } | ||
| 12852 | |||
| 12853 | if ($world eq 'kallisti' && $fileVersion < 1_002_041) { | ||
| 12854 | |||
| 12855 | # Auto-disconnections no longer a problem so re-enabled MSDP | ||
| 12856 | $worldObj->ivDelete('telnetOverrideHash', 'msdp'); | ||
| 12857 | |||
| 12858 | # Looks like output for 'score' command and prompt have been updated, too | ||
| 12859 | $worldObj->ivPush( | ||
| 12860 | 'groupPatternList', | ||
| 12861 | '^\< \w+ \| (\d+)h (\d+)m (\d+)s', | ||
| 12862 | 1, | ||
| 12863 | 'health_points', | ||
| 12864 | 'show', | ||
| 12865 | '^\< \w+ \| (\d+)h (\d+)m (\d+)s', | ||
| 12866 | 2, | ||
| 12867 | 'magic_points', | ||
| 12868 | 'show', | ||
| 12869 | '^\< \w+ \| (\d+)h (\d+)m (\d+)s', | ||
| 12870 | 3, | ||
| 12871 | 'energy_points', | ||
| 12872 | 'show', | ||
| 12873 | 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s' | ||
| 12874 | . '(\d+)\s\/\s(\d+)', | ||
| 12875 | 1, | ||
| 12876 | 'health_points', | ||
| 12877 | 'show', | ||
| 12878 | 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s' | ||
| 12879 | . '(\d+)\s\/\s(\d+)', | ||
| 12880 | 2, | ||
| 12881 | 'health_points_max', | ||
| 12882 | 'show', | ||
| 12883 | 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s' | ||
| 12884 | . '(\d+)\s\/\s(\d+)', | ||
| 12885 | 3, | ||
| 12886 | 'magic_points', | ||
| 12887 | 'show', | ||
| 12888 | 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s' | ||
| 12889 | . '(\d+)\s\/\s(\d+)', | ||
| 12890 | 4, | ||
| 12891 | 'magic_points_max', | ||
| 12892 | 'show', | ||
| 12893 | 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s' | ||
| 12894 | . '(\d+)\s\/\s(\d+)', | ||
| 12895 | 5, | ||
| 12896 | 'energy_points', | ||
| 12897 | 'show', | ||
| 12898 | 'Hitpoints\:\s(\d+)\s\/\s(\d+)\s+Mana\:\s(\d+)\s\/\s(\d+)\s+Stamina\:\s' | ||
| 12899 | . '(\d+)\s\/\s(\d+)', | ||
| 12900 | 6, | ||
| 12901 | 'energy_points_max', | ||
| 12902 | 'show', | ||
| 12903 | ); | ||
| 12904 | |||
| 12905 | # Replace the command prompt pattern | ||
| 12906 | $worldObj->ivPoke( | ||
| 12907 | 'cmdPromptPatternList', | ||
| 12908 | '^\< \w+ \| (\d+)h (\d+)m (\d+)s \> .', | ||
| 12909 | ); | ||
| 12910 | |||
| 12911 | # Add a very common fail exit message | ||
| 12912 | $worldObj->ivPush( | ||
| 12913 | 'failExitPatternList', | ||
| 12914 | 'Alas, you cannot go .*\.\.\.', | ||
| 12915 | ); | ||
| 12916 | } | ||
| 12917 | |||
| 12918 | if ($world eq 'luminari' && $fileVersion < 1_001_270) { | ||
| 12919 | |||
| 12920 | # Patch to fix bad regex in the ->channelList | ||
| 12921 | $worldObj->ivPoke( | ||
| 12922 | 'channelList', | ||
| 12923 | '^\w+ chats, \'', | ||
| 12924 | 'tell', TRUE, | ||
| 12925 | '^You chat, \'', | ||
| 12926 | 'tell', TRUE, | ||
| 12927 | '^\[INFO\] ', | ||
| 12928 | 'social', TRUE, | ||
| 12929 | ); | ||
| 12930 | } | ||
| 12931 | |||
| 12932 | if ($world eq 'mud1' && $fileVersion < 1_001_270) { | ||
| 12933 | |||
| 12934 | my $compObj; | ||
| 12935 | |||
| 12936 | # Update overrides | ||
| 12937 | $worldObj->ivAdd('termOverrideHash', 'useVisibleCursorFlag', TRUE); | ||
| 12938 | |||
| 12939 | # Update problems with room statement detection | ||
| 12940 | $worldObj->ivPoke( | ||
| 12941 | 'notAnchorPatternList', | ||
| 12942 | '^\*', | ||
| 12943 | '^\w+$', | ||
| 12944 | ); | ||
| 12945 | |||
| 12946 | $compObj = $worldObj->ivShow('componentHash', 'verb_descrip'); | ||
| 12947 | if ($compObj) { | ||
| 12948 | |||
| 12949 | $compObj->{startNoPatternList} = [ | ||
| 12950 | '^\*', | ||
| 12951 | ]; | ||
| 12952 | $compObj->{startNoTagList} = []; | ||
| 12953 | $compObj->{startNoAllFlag} = FALSE; | ||
| 12954 | $compObj->{startNoTagMode} = 'default'; | ||
| 12955 | } | ||
| 12956 | } | ||
| 12957 | |||
| 12958 | if ($world eq 'mudii' && $fileVersion < 1_001_270) { | ||
| 12959 | |||
| 12960 | my ($missionObj, $compObj, $compObj2); | ||
| 12961 | |||
| 12962 | # Update overrides | ||
| 12963 | $worldObj->ivAdd('termOverrideHash', 'useVisibleCursorFlag', TRUE); | ||
| 12964 | |||
| 12965 | # Update login mission | ||
| 12966 | $missionObj = $worldObj->ivShow('missionHash', 'mudii_login'); | ||
| 12967 | if ($missionObj) { | ||
| 12968 | |||
| 12969 | $missionObj->ivPoke( | ||
| 12970 | 'missionList', | ||
| 12971 | 't ^\w+ login\:', | ||
| 12972 | '> mud', | ||
| 12973 | 't ^Account ID\:', | ||
| 12974 | 'a', | ||
| 12975 | 't ^Password\:', | ||
| 12976 | 'w', | ||
| 12977 | 't Checking your mail', | ||
| 12978 | '> ', | ||
| 12979 | 't Option', | ||
| 12980 | '> p', | ||
| 12981 | 't By what name shall I call you', | ||
| 12982 | 'n', | ||
| 12983 | 't Elizabethan tearoom', | ||
| 12984 | ';login', | ||
| 12985 | ); | ||
| 12986 | } | ||
| 12987 | |||
| 12988 | # Update problems with room statement detection | ||
| 12989 | $worldObj->ivPoke( | ||
| 12990 | 'notAnchorPatternList', | ||
| 12991 | '^\*', | ||
| 12992 | '^\w+$', | ||
| 12993 | ); | ||
| 12994 | |||
| 12995 | $compObj = $worldObj->ivShow('componentHash', 'ignore_line'); | ||
| 12996 | if ($compObj) { | ||
| 12997 | |||
| 12998 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 12999 | |||
| 13000 | $compObj->{startPatternList} = []; | ||
| 13001 | $compObj->{startTagList} = []; | ||
| 13002 | $compObj->{startAllFlag} = FALSE; | ||
| 13003 | $compObj->{startTagMode} = 'default'; | ||
| 13004 | |||
| 13005 | $compObj->{startNoPatternList} = []; | ||
| 13006 | $compObj->{startNoTagList} = [ | ||
| 13007 | 'green', | ||
| 13008 | ]; | ||
| 13009 | $compObj->{startNoAllFlag} = FALSE; | ||
| 13010 | $compObj->{startNoTagMode} = 'default'; | ||
| 13011 | |||
| 13012 | $compObj->{stopBeforePatternList} = []; | ||
| 13013 | $compObj->{stopBeforeTagList} = [ | ||
| 13014 | 'green', | ||
| 13015 | ]; | ||
| 13016 | $compObj->{stopBeforeAllFlag} = FALSE; | ||
| 13017 | $compObj->{stopBeforeTagMode} = 'default'; | ||
| 13018 | } | ||
| 13019 | |||
| 13020 | $compObj2 = $worldObj->ivShow('componentHash', 'verb_descrip'); | ||
| 13021 | if ($compObj2) { | ||
| 13022 | |||
| 13023 | $compObj2->{startNoPatternList} = [ | ||
| 13024 | '^It is raining\.', | ||
| 13025 | ]; | ||
| 13026 | $compObj2->{startNoTagList} = []; | ||
| 13027 | $compObj2->{startNoAllFlag} = FALSE; | ||
| 13028 | $compObj2->{startNoTagMode} = 'default'; | ||
| 13029 | } | ||
| 13030 | } | ||
| 13031 | |||
| 13032 | if ($world eq 'mud2' && $fileVersion < 1_001_270) { | ||
| 13033 | |||
| 13034 | my ($missionObj, $compObj, $compObj2); | ||
| 13035 | |||
| 13036 | # Update overrides | ||
| 13037 | $worldObj->ivAdd('termOverrideHash', 'useVisibleCursorFlag', TRUE); | ||
| 13038 | |||
| 13039 | # Update login mission | ||
| 13040 | $missionObj = $worldObj->ivShow('missionHash', 'mud2_login'); | ||
| 13041 | if ($missionObj) { | ||
| 13042 | |||
| 13043 | $missionObj->ivPoke( | ||
| 13044 | 'missionList', | ||
| 13045 | 't ^\w+ login\:', | ||
| 13046 | '> mud', | ||
| 13047 | 't ^Account ID\:', | ||
| 13048 | 'a', | ||
| 13049 | 't ^Password\:', | ||
| 13050 | 'w', | ||
| 13051 | 't Hit return', | ||
| 13052 | '> ', | ||
| 13053 | 't Option', | ||
| 13054 | '> p', | ||
| 13055 | 't By what name shall I call you', | ||
| 13056 | 'n', | ||
| 13057 | 't Elizabethan tearoom', | ||
| 13058 | ';login', | ||
| 13059 | ); | ||
| 13060 | } | ||
| 13061 | |||
| 13062 | # Update problems with room statement detection | ||
| 13063 | $worldObj->ivPoke( | ||
| 13064 | 'notAnchorPatternList', | ||
| 13065 | '^\*', | ||
| 13066 | '^\w+$', | ||
| 13067 | ); | ||
| 13068 | |||
| 13069 | $compObj = $worldObj->ivShow('componentHash', 'ignore_line'); | ||
| 13070 | if ($compObj) { | ||
| 13071 | |||
| 13072 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13073 | |||
| 13074 | $compObj->{startPatternList} = []; | ||
| 13075 | $compObj->{startTagList} = []; | ||
| 13076 | $compObj->{startAllFlag} = FALSE; | ||
| 13077 | $compObj->{startTagMode} = 'default'; | ||
| 13078 | |||
| 13079 | $compObj->{startNoPatternList} = []; | ||
| 13080 | $compObj->{startNoTagList} = [ | ||
| 13081 | 'green', | ||
| 13082 | ]; | ||
| 13083 | $compObj->{startNoAllFlag} = FALSE; | ||
| 13084 | $compObj->{startNoTagMode} = 'default'; | ||
| 13085 | |||
| 13086 | $compObj->{stopBeforePatternList} = []; | ||
| 13087 | $compObj->{stopBeforeTagList} = [ | ||
| 13088 | 'green', | ||
| 13089 | ]; | ||
| 13090 | $compObj->{stopBeforeAllFlag} = FALSE; | ||
| 13091 | $compObj->{stopBeforeTagMode} = 'default'; | ||
| 13092 | } | ||
| 13093 | |||
| 13094 | $compObj2 = $worldObj->ivShow('componentHash', 'verb_descrip'); | ||
| 13095 | if ($compObj2) { | ||
| 13096 | |||
| 13097 | $compObj2->{startNoPatternList} = [ | ||
| 13098 | '^It is raining\.', | ||
| 13099 | ]; | ||
| 13100 | $compObj2->{startNoTagList} = []; | ||
| 13101 | $compObj2->{startNoAllFlag} = FALSE; | ||
| 13102 | $compObj2->{startNoTagMode} = 'default'; | ||
| 13103 | } | ||
| 13104 | } | ||
| 13105 | |||
| 13106 | if ($world eq 'nanvaent' && $fileVersion < 1_001_343) { | ||
| 13107 | |||
| 13108 | # Remove follow patterns, which conflict with some room descriptions, causing automapper | ||
| 13109 | # to get lost | ||
| 13110 | $worldObj->ivEmpty('followPatternList'); | ||
| 13111 | } | ||
| 13112 | |||
| 13113 | if ($world eq 'nanvaent' && $fileVersion < 1_001_405) { | ||
| 13114 | |||
| 13115 | # Update exit states | ||
| 13116 | $worldObj->ivPoke( | ||
| 13117 | 'exitStateTagHash', | ||
| 13118 | 'cyan', | ||
| 13119 | 'emphasis', | ||
| 13120 | ); | ||
| 13121 | } | ||
| 13122 | |||
| 13123 | if ($world eq 'pict' && $fileVersion < 1_001_174) { | ||
| 13124 | |||
| 13125 | $worldObj->ivPoke('dns', undef); | ||
| 13126 | $worldObj->ivPoke('ipv4', '136.62.89.155'); | ||
| 13127 | } | ||
| 13128 | |||
| 13129 | if ($world eq 'swmud' && $fileVersion < 1_001_012) { | ||
| 13130 | |||
| 13131 | my $compObj; | ||
| 13132 | |||
| 13133 | # Patch to fix handling of room statements, which doesn't work very well at all | ||
| 13134 | $worldObj->ivPoke( | ||
| 13135 | 'verboseAnchorPatternList', | ||
| 13136 | '^There are (.*) obvious exits\: (.*)', | ||
| 13137 | '^The only obvious exit is (.*)\.', | ||
| 13138 | '^There are no obvious exits\.', | ||
| 13139 | ); | ||
| 13140 | |||
| 13141 | $worldObj->ivPoke( | ||
| 13142 | 'verboseExitDelimiterList', | ||
| 13143 | ', and ', | ||
| 13144 | ' and ', | ||
| 13145 | ', ', | ||
| 13146 | ); | ||
| 13147 | |||
| 13148 | $worldObj->ivDelete('componentHash', 'verb_title'); | ||
| 13149 | $worldObj->ivDelete('componentHash', 'verb_descrip'); | ||
| 13150 | $worldObj->ivDelete('componentHash', 'ignore_line'); | ||
| 13151 | $worldObj->ivDelete('componentHash', 'ignore_line_1'); | ||
| 13152 | $worldObj->ivDelete('componentHash', 'ignore_line_2'); | ||
| 13153 | $worldObj->ivDelete('componentHash', 'verb_exit'); | ||
| 13154 | |||
| 13155 | $worldObj->ivPoke( | ||
| 13156 | 'verboseComponentList', | ||
| 13157 | 'verb_descrip', | ||
| 13158 | 'ignore_line_1', | ||
| 13159 | 'ignore_line_2', | ||
| 13160 | 'anchor', | ||
| 13161 | 'verb_exit', | ||
| 13162 | ); | ||
| 13163 | |||
| 13164 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 13165 | $axmud::CLIENT, | ||
| 13166 | $worldObj, | ||
| 13167 | 'verb_descrip', | ||
| 13168 | 'verb_descrip', | ||
| 13169 | ); | ||
| 13170 | |||
| 13171 | if ($compObj) { | ||
| 13172 | |||
| 13173 | $compObj->{size} = 0; | ||
| 13174 | $compObj->{minSize} = 0; | ||
| 13175 | $compObj->{maxSize} = 16; | ||
| 13176 | $compObj->{analyseMode} = 'check_line'; | ||
| 13177 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13178 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 13179 | $compObj->{combineLinesFlag} = FALSE; | ||
| 13180 | |||
| 13181 | $compObj->{stopBeforePatternList} = [ | ||
| 13182 | '^\>', | ||
| 13183 | ]; | ||
| 13184 | $compObj->{stopBeforeTagList} = []; | ||
| 13185 | $compObj->{stopBeforeAllFlag} = FALSE; | ||
| 13186 | $compObj->{stopBeforeTagMode} = 'default'; | ||
| 13187 | |||
| 13188 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 13189 | } | ||
| 13190 | |||
| 13191 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 13192 | $axmud::CLIENT, | ||
| 13193 | $worldObj, | ||
| 13194 | 'ignore_line_1', | ||
| 13195 | 'ignore_line', | ||
| 13196 | ); | ||
| 13197 | |||
| 13198 | if ($compObj) { | ||
| 13199 | |||
| 13200 | $compObj->{size} = 0; | ||
| 13201 | $compObj->{minSize} = 0; | ||
| 13202 | $compObj->{maxSize} = 16; | ||
| 13203 | $compObj->{analyseMode} = 'check_line'; | ||
| 13204 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13205 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 13206 | $compObj->{combineLinesFlag} = FALSE; | ||
| 13207 | |||
| 13208 | $compObj->{startPatternList} = []; | ||
| 13209 | $compObj->{startTagList} = ['green']; | ||
| 13210 | $compObj->{startAllFlag} = FALSE; | ||
| 13211 | $compObj->{startTagMode} = 'default'; | ||
| 13212 | |||
| 13213 | $compObj->{stopAtMode} = 'no_letter_num'; | ||
| 13214 | |||
| 13215 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 13216 | } | ||
| 13217 | |||
| 13218 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 13219 | $axmud::CLIENT, | ||
| 13220 | $worldObj, | ||
| 13221 | 'ignore_line_2', | ||
| 13222 | 'ignore_line', | ||
| 13223 | ); | ||
| 13224 | |||
| 13225 | if ($compObj) { | ||
| 13226 | |||
| 13227 | $compObj->{size} = 1; # Fixed size | ||
| 13228 | $compObj->{analyseMode} = 'check_line'; | ||
| 13229 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13230 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 13231 | $compObj->{combineLinesFlag} = FALSE; | ||
| 13232 | |||
| 13233 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 13234 | } | ||
| 13235 | |||
| 13236 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 13237 | $axmud::CLIENT, | ||
| 13238 | $worldObj, | ||
| 13239 | 'verb_exit', | ||
| 13240 | 'verb_exit', | ||
| 13241 | ); | ||
| 13242 | |||
| 13243 | if ($compObj) { | ||
| 13244 | |||
| 13245 | $compObj->{size} = 0; | ||
| 13246 | $compObj->{minSize} = 1; | ||
| 13247 | $compObj->{maxSize} = 16; | ||
| 13248 | $compObj->{analyseMode} = 'check_line'; | ||
| 13249 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13250 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 13251 | $compObj->{combineLinesFlag} = TRUE; | ||
| 13252 | |||
| 13253 | $compObj->{startPatternList} = [ | ||
| 13254 | '^There are (.*) obvious exits\: (.*)', | ||
| 13255 | '^The only obvious exit is (.*)\.', | ||
| 13256 | '^There are no obvious exits\.', | ||
| 13257 | ]; | ||
| 13258 | $compObj->{startTagList} = []; | ||
| 13259 | $compObj->{startAllFlag} = FALSE; | ||
| 13260 | $compObj->{startTagMode} = 'default'; | ||
| 13261 | |||
| 13262 | $compObj->{stopPatternList} = [ | ||
| 13263 | '\.\s*$', | ||
| 13264 | ]; | ||
| 13265 | $compObj->{stopTagList} = []; | ||
| 13266 | $compObj->{stopAllFlag} = FALSE; | ||
| 13267 | $compObj->{stopTagMode} = 'default'; | ||
| 13268 | |||
| 13269 | $compObj->{stopAtMode} = 'no_letter_num'; | ||
| 13270 | |||
| 13271 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 13272 | } | ||
| 13273 | } | ||
| 13274 | |||
| 13275 | if ($world eq 'threekingdoms' && $fileVersion < 1_001_270) { | ||
| 13276 | |||
| 13277 | my $compObj; | ||
| 13278 | |||
| 13279 | # Patch to fix handling of verbose descriptions in room statements | ||
| 13280 | $compObj = $worldObj->ivShow('componentHash', 'verb_descrip'); | ||
| 13281 | if ($compObj) { | ||
| 13282 | |||
| 13283 | $compObj->{useExplicitTagsFlag} = TRUE; | ||
| 13284 | } | ||
| 13285 | } | ||
| 13286 | |||
| 13287 | if ($world eq 'threescapes' && $fileVersion < 1_001_270) { | ||
| 13288 | |||
| 13289 | my $compObj; | ||
| 13290 | |||
| 13291 | # Patch to fix handling of verbose descriptions in room statements | ||
| 13292 | $compObj = $worldObj->ivShow('componentHash', 'verb_descrip'); | ||
| 13293 | if ($compObj) { | ||
| 13294 | |||
| 13295 | $compObj->{useExplicitTagsFlag} = TRUE; | ||
| 13296 | } | ||
| 13297 | } | ||
| 13298 | |||
| 13299 | if ($world eq 'twotowers' && $fileVersion < 1_001_343) { | ||
| 13300 | |||
| 13301 | my @newList; | ||
| 13302 | |||
| 13303 | # Fix wrong channels regex | ||
| 13304 | foreach my $item ($worldObj->channelList) { | ||
| 13305 | |||
| 13306 | if ($item eq '^You tell \w\: ') { | ||
| 13307 | push (@newList, '^You tell \w+\: '); | ||
| 13308 | } else { | ||
| 13309 | push (@newList, $item); | ||
| 13310 | } | ||
| 13311 | } | ||
| 13312 | |||
| 13313 | # Patch to fix handling of brief room statements | ||
| 13314 | $worldObj->ivPoke( | ||
| 13315 | 'briefAnchorPatternList', | ||
| 13316 | '[^\s]\(([^\(\)]+\)\s\[[^\[\]]+)\]\s*$', # Rooms with swimming | ||
| 13317 | '[^\s]\(([^\(\)]+)\)\s*$', # Rooms without swimming | ||
| 13318 | ); | ||
| 13319 | } | ||
| 13320 | |||
| 13321 | if ($world eq 'twotowers' && $fileVersion < 1_001_405) { | ||
| 13322 | |||
| 13323 | my $compObj; | ||
| 13324 | |||
| 13325 | # Add a new failed exit | ||
| 13326 | $worldObj->ivPush('failExitPatternList', '^You\'re too tired to swim right now'); | ||
| 13327 | |||
| 13328 | # Update exit states | ||
| 13329 | $worldObj->ivPoke( | ||
| 13330 | 'exitStateTagHash', | ||
| 13331 | 'BLUE', | ||
| 13332 | 'swim @@@', | ||
| 13333 | ); | ||
| 13334 | |||
| 13335 | # Set a duplicate exit replacement | ||
| 13336 | $worldObj->ivPoke('duplicateReplaceString', 'swim @@@'); | ||
| 13337 | |||
| 13338 | # Fix handling of room statements, after a Locator reset, in rooms with water exits | ||
| 13339 | $worldObj->ivPoke( | ||
| 13340 | 'verboseAnchorPatternList', | ||
| 13341 | '^\s\s\s\sThe only obvious exits are (.*)\.', | ||
| 13342 | '^\s\s\s\sThe only obvious exit is (.*)\.', | ||
| 13343 | ); | ||
| 13344 | |||
| 13345 | $worldObj->ivDelete('componentHash', 'verb_exit'); | ||
| 13346 | |||
| 13347 | $worldObj->ivPoke( | ||
| 13348 | 'verboseComponentList', | ||
| 13349 | 'verb_descrip', | ||
| 13350 | 'verb_exit_1', | ||
| 13351 | 'anchor', | ||
| 13352 | 'verb_exit_2', | ||
| 13353 | ); | ||
| 13354 | |||
| 13355 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 13356 | $axmud::CLIENT, | ||
| 13357 | $worldObj, | ||
| 13358 | 'verb_exit_1', | ||
| 13359 | 'verb_exit', | ||
| 13360 | ); | ||
| 13361 | |||
| 13362 | if ($compObj) { | ||
| 13363 | |||
| 13364 | $compObj->{size} = 0; | ||
| 13365 | $compObj->{minSize} = 0; # Optional | ||
| 13366 | $compObj->{maxSize} = 16; | ||
| 13367 | $compObj->{analyseMode} = 'check_line'; | ||
| 13368 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13369 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 13370 | $compObj->{combineLinesFlag} = FALSE; # Water & normal exits on separate lines | ||
| 13371 | |||
| 13372 | $compObj->{startPatternList} = []; | ||
| 13373 | $compObj->{startTagList} = [ | ||
| 13374 | 'blue', | ||
| 13375 | ]; | ||
| 13376 | $compObj->{startAllFlag} = FALSE; | ||
| 13377 | $compObj->{startTagMode} = 'default'; | ||
| 13378 | |||
| 13379 | $compObj->{stopAtPatternList} = [ | ||
| 13380 | '^\s\s\s\sThere is water to the (.*)\.', | ||
| 13381 | ]; | ||
| 13382 | $compObj->{stopAtTagList} = []; | ||
| 13383 | $compObj->{stopAtAllFlag} = FALSE; | ||
| 13384 | $compObj->{stopAtTagMode} = 'default'; | ||
| 13385 | |||
| 13386 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 13387 | } | ||
| 13388 | |||
| 13389 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 13390 | $axmud::CLIENT, | ||
| 13391 | $worldObj, | ||
| 13392 | 'verb_exit_2', | ||
| 13393 | 'verb_exit', | ||
| 13394 | ); | ||
| 13395 | |||
| 13396 | if ($compObj) { | ||
| 13397 | |||
| 13398 | $compObj->{size} = 0; | ||
| 13399 | $compObj->{minSize} = 1; | ||
| 13400 | $compObj->{maxSize} = 16; | ||
| 13401 | $compObj->{analyseMode} = 'check_line'; | ||
| 13402 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13403 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 13404 | $compObj->{combineLinesFlag} = FALSE; # Water & normal exits on separate lines | ||
| 13405 | |||
| 13406 | $compObj->{startPatternList} = [ | ||
| 13407 | '^\s\s\s\sThe only obvious exits are (.*)\.', | ||
| 13408 | '^\s\s\s\sThe only obvious exit is (.*)\.', | ||
| 13409 | ]; | ||
| 13410 | $compObj->{startTagList} = []; | ||
| 13411 | $compObj->{startAllFlag} = FALSE; | ||
| 13412 | $compObj->{startTagMode} = 'default'; | ||
| 13413 | |||
| 13414 | $compObj->{stopBeforeNoPatternList} = [ | ||
| 13415 | '^\s\s\s\sThe only obvious exits are (.*)\.', | ||
| 13416 | '^\s\s\s\sThe only obvious exit is (.*)\.', | ||
| 13417 | ]; | ||
| 13418 | $compObj->{stopBeforeNoTagList} = []; | ||
| 13419 | $compObj->{stopBeforeNoAllFlag} = FALSE; | ||
| 13420 | $compObj->{stopBeforeNoTagMode} = 'default'; | ||
| 13421 | |||
| 13422 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 13423 | } | ||
| 13424 | } | ||
| 13425 | |||
| 13426 | if ($world eq 'twotowers' && $fileVersion < 1_002_000) { | ||
| 13427 | |||
| 13428 | my $compObj; | ||
| 13429 | |||
| 13430 | # Further fix to handling of room statements | ||
| 13431 | |||
| 13432 | $worldObj->ivPoke( | ||
| 13433 | 'verboseAnchorPatternList', | ||
| 13434 | '^\s\s\s\sThe only obvious exits are (.*)', | ||
| 13435 | '^\s\s\s\sThe only obvious exit is (.*)', | ||
| 13436 | ); | ||
| 13437 | |||
| 13438 | $worldObj->ivDelete('componentHash', 'verb_exit_1'); | ||
| 13439 | $worldObj->ivDelete('componentHash', 'verb_exit_2'); | ||
| 13440 | |||
| 13441 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 13442 | $axmud::CLIENT, | ||
| 13443 | $worldObj, | ||
| 13444 | 'verb_exit_1', | ||
| 13445 | 'verb_exit', | ||
| 13446 | ); | ||
| 13447 | |||
| 13448 | if ($compObj) { | ||
| 13449 | |||
| 13450 | $compObj->{size} = 0; | ||
| 13451 | $compObj->{minSize} = 0; # Optional | ||
| 13452 | $compObj->{maxSize} = 16; | ||
| 13453 | $compObj->{analyseMode} = 'check_line'; | ||
| 13454 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13455 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 13456 | $compObj->{combineLinesFlag} = TRUE; | ||
| 13457 | |||
| 13458 | $compObj->{startPatternList} = []; | ||
| 13459 | $compObj->{startTagList} = [ | ||
| 13460 | 'blue', | ||
| 13461 | ]; | ||
| 13462 | $compObj->{startAllFlag} = FALSE; | ||
| 13463 | $compObj->{startTagMode} = 'default'; | ||
| 13464 | |||
| 13465 | $compObj->{stopAtPatternList} = [ | ||
| 13466 | '^\s\s\s\sThere is water to the', | ||
| 13467 | ]; | ||
| 13468 | $compObj->{stopAtTagList} = []; | ||
| 13469 | $compObj->{stopAtAllFlag} = FALSE; | ||
| 13470 | $compObj->{stopAtTagMode} = 'default'; | ||
| 13471 | |||
| 13472 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 13473 | } | ||
| 13474 | |||
| 13475 | $compObj = Games::Axmud::Obj::Component->new( | ||
| 13476 | $axmud::CLIENT, | ||
| 13477 | $worldObj, | ||
| 13478 | 'verb_exit_2', | ||
| 13479 | 'verb_exit', | ||
| 13480 | ); | ||
| 13481 | |||
| 13482 | if ($compObj) { | ||
| 13483 | |||
| 13484 | $compObj->{size} = 0; | ||
| 13485 | $compObj->{minSize} = 1; | ||
| 13486 | $compObj->{maxSize} = 16; | ||
| 13487 | $compObj->{analyseMode} = 'check_line'; | ||
| 13488 | $compObj->{boldSensitiveFlag} = FALSE; | ||
| 13489 | $compObj->{useInitialTagsFlag} = FALSE; | ||
| 13490 | $compObj->{combineLinesFlag} = TRUE; | ||
| 13491 | |||
| 13492 | $compObj->{startPatternList} = [ | ||
| 13493 | '^\s\s\s\sThe only obvious exits are', | ||
| 13494 | '^\s\s\s\sThe only obvious exit is', | ||
| 13495 | ]; | ||
| 13496 | $compObj->{startTagList} = []; | ||
| 13497 | $compObj->{startAllFlag} = FALSE; | ||
| 13498 | $compObj->{startTagMode} = 'default'; | ||
| 13499 | |||
| 13500 | $compObj->{stopAtPatternList} = [ | ||
| 13501 | '\.\s*$', | ||
| 13502 | ]; | ||
| 13503 | $compObj->{stopAtTagList} = []; | ||
| 13504 | $compObj->{stopAtAllFlag} = FALSE; | ||
| 13505 | $compObj->{stopAtTagMode} = 'default'; | ||
| 13506 | |||
| 13507 | $worldObj->ivAdd('componentHash', $compObj->name, $compObj); | ||
| 13508 | } | ||
| 13509 | } | ||
| 13510 | |||
| 13511 | return 1; | ||
| 13512 | } | ||
| 13513 | |||
| 13514 | sub checkCompatibility { | ||
| 13515 | |||
| 13516 | # Called by $self->loadConfigFile, $self->loadDataFile and ->importDataFile | ||
| 13517 | # The data file's header states which programme created the data file. This function checks | ||
| 13518 | # that the programme was either Axmud or something compatible with Axmud (specifically, an | ||
| 13519 | # earlier version of it) | ||
| 13520 | # | ||
| 13521 | # Expected arguments | ||
| 13522 | # $scriptName - The name of the programme that created the data file | ||
| 13523 | # | ||
| 13524 | # Return values | ||
| 13525 | # 'undef' on improper arguments or if the data file is incompatible with Axmud | ||
| 13526 | # 1 if the data file is compatible with Axmud | ||
| 13527 | |||
| 13528 | my ($self, $scriptName, $check) = @_; | ||
| 13529 | |||
| 13530 | # Check for improper arguments | ||
| 13531 | if (! defined $scriptName || defined $check) { | ||
| 13532 | |||
| 13533 | return $axmud::CLIENT->writeImproper($self->_objClass . '->checkCompatibility', @_); | ||
| 13534 | } | ||
| 13535 | |||
| 13536 | OUTER: foreach my $item (@axmud::COMPAT_FILE_LIST) { | ||
| 13537 | |||
| 13538 | if ($scriptName eq $item) { | ||
| 13539 | |||
| 13540 | # Data file is compatible | ||
| 13541 | return 1; | ||
| 13542 | } | ||
| 13543 | } | ||
| 13544 | |||
| 13545 | # Data file is not compatible | ||
| 13546 | return undef; | ||
| 13547 | } | ||
| 13548 | |||
| 13549 | sub compileTasks { | ||
| 13550 | |||
| 13551 | # Called by $self->updateExtractedData to compile a list of tasks of a certain type; the | ||
| 13552 | # returned list includes tasks from all profile's initial tasklists as well as the global | ||
| 13553 | # initial tasklist and the custom tasklist | ||
| 13554 | # | ||
| 13555 | # Expected arguments | ||
| 13556 | # (none besides $self) | ||
| 13557 | # | ||
| 13558 | # Optional arguments | ||
| 13559 | # $name - A task's ->name, e.g. 'locator_task'. If set to 'undef', all tasks are | ||
| 13560 | # included in the returned list | ||
| 13561 | # | ||
| 13562 | # Return values | ||
| 13563 | # An empty list on improper arguments | ||
| 13564 | # Otherwise, returns the list of matching initial/custom tasks | ||
| 13565 | |||
| 13566 | my ($self, $name, $check) = @_; | ||
| 13567 | |||
| 13568 | # Local variables | ||
| 13569 | my (@emptyList, @taskList); | ||
| 13570 | |||
| 13571 | # Check for improper arguments | ||
| 13572 | if (defined $check) { | ||
| 13573 | |||
| 13574 | $axmud::CLIENT->writeImproper($self->_objClass . '->compileTasks', @_); | ||
| 13575 | return @emptyList; | ||
| 13576 | } | ||
| 13577 | |||
| 13578 | # Profile initial tasklists | ||
| 13579 | if ($self->session) { | ||
| 13580 | |||
| 13581 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 13582 | |||
| 13583 | foreach my $taskObj ($profObj->ivValues('initTaskHash')) { | ||
| 13584 | |||
| 13585 | if (! $name || $taskObj->{name} eq $name) { | ||
| 13586 | |||
| 13587 | push (@taskList, $taskObj); | ||
| 13588 | } | ||
| 13589 | } | ||
| 13590 | } | ||
| 13591 | } | ||
| 13592 | |||
| 13593 | # Global initial tasklist | ||
| 13594 | foreach my $taskObj ($axmud::CLIENT->ivValues('initTaskHash')) { | ||
| 13595 | |||
| 13596 | if (! $name || $taskObj->{name} eq $name) { | ||
| 13597 | |||
| 13598 | push (@taskList, $taskObj); | ||
| 13599 | } | ||
| 13600 | } | ||
| 13601 | |||
| 13602 | # Custom tasklist | ||
| 13603 | foreach my $taskObj ($axmud::CLIENT->ivValues('customTaskHash')) { | ||
| 13604 | |||
| 13605 | if (! $name || $taskObj->{name} eq $name) { | ||
| 13606 | |||
| 13607 | push (@taskList, $taskObj); | ||
| 13608 | } | ||
| 13609 | } | ||
| 13610 | |||
| 13611 | return @taskList; | ||
| 13612 | } | ||
| 13613 | |||
| 13614 | sub examineDataFile { | ||
| 13615 | |||
| 13616 | # Called by GA::Cmd::TestFile->do, or by any other function (this is a debug function) | ||
| 13617 | # Loads a specified file as if it were a genuine Axmud data file (but not a config file). | ||
| 13618 | # Returns information about the file | ||
| 13619 | # NB This function works even when the global flags forbidding the loading or importing of | ||
| 13620 | # files are set | ||
| 13621 | # NB This function works, even if the file's header specifies an older version of Axmud | ||
| 13622 | # NB Because the Perl Storable module doesn't seem to offer a way to check that the file | ||
| 13623 | # really was created by it, this function now only tests .axm files | ||
| 13624 | # | ||
| 13625 | # Expected arguments | ||
| 13626 | # $path - The full path of the file to check | ||
| 13627 | # $mode - 'return_header' returns just the header information (metadata), | ||
| 13628 | # - 'remove_values' returns the hash, with all the values in the key-value | ||
| 13629 | # pairs set to 'undef' (removing all the references) | ||
| 13630 | # - 'return_key' returns the value of a single specified key (returns a hash | ||
| 13631 | # containing a single key-value pair) | ||
| 13632 | # - 'return_hash' returns the entire contents of the file as the original hash | ||
| 13633 | # | ||
| 13634 | # Optional arguments | ||
| 13635 | # $selectKey - In mode 'return_key' - the key whose value should be returned (the value | ||
| 13636 | # will be a scalar, or a scalar reference) | ||
| 13637 | # | ||
| 13638 | # Return values | ||
| 13639 | # An empty hash on improper arguments, if the file doesn't exist, if it is unreadable or | ||
| 13640 | # if it is in the wrong format | ||
| 13641 | # Otherwise, returns the hash specified above | ||
| 13642 | |||
| 13643 | my ($self, $path, $mode, $selectKey, $check) = @_; | ||
| 13644 | |||
| 13645 | # Local variables | ||
| 13646 | my ( | ||
| 13647 | $matchFlag, $hashRef, $fileType, $scriptName, $scriptVersion, $saveDate, $saveTime, | ||
| 13648 | $assocWorldProf, | ||
| 13649 | %emptyHash, %loadHash, %returnHash, | ||
| 13650 | ); | ||
| 13651 | |||
| 13652 | # Check for improper arguments | ||
| 13653 | if ( | ||
| 13654 | ! defined $path | ||
| 13655 | || ! defined $mode | ||
| 13656 | || ( | ||
| 13657 | defined $mode && $mode ne 'return_header' && $mode ne 'remove_values' | ||
| 13658 | && $mode ne 'return_key' && $mode ne 'return_hash' | ||
| 13659 | ) | ||
| 13660 | || ($mode eq 'return_key' && ! defined $selectKey) | ||
| 13661 | || defined $check | ||
| 13662 | ) { | ||
| 13663 | $axmud::CLIENT->writeImproper($self->_objClass . '->importDataFile', @_); | ||
| 13664 | return %emptyHash; | ||
| 13665 | } | ||
| 13666 | |||
| 13667 | # Check that the specified file exists | ||
| 13668 | if (! (-e $path)) { | ||
| 13669 | |||
| 13670 | return %emptyHash; | ||
| 13671 | } | ||
| 13672 | |||
| 13673 | # The Perl Storable module doesn't seem to offer a way to check that the file really was | ||
| 13674 | # created by it. To avoid an ugly Perl error, limit operations to files with compatible | ||
| 13675 | # extensions | ||
| 13676 | OUTER: foreach my $ext (@axmud::COMPAT_EXT_LIST) { | ||
| 13677 | |||
| 13678 | if ($path =~ m/\.$ext$/) { | ||
| 13679 | |||
| 13680 | $matchFlag = TRUE; | ||
| 13681 | last OUTER; | ||
| 13682 | } | ||
| 13683 | } | ||
| 13684 | |||
| 13685 | if (! $matchFlag) { | ||
| 13686 | |||
| 13687 | return %emptyHash; | ||
| 13688 | } | ||
| 13689 | |||
| 13690 | # Load all the data into a hash | ||
| 13691 | eval { $hashRef = Storable::lock_retrieve($path); }; | ||
| 13692 | if (! $hashRef || (ref $hashRef) ne 'HASH') { | ||
| 13693 | |||
| 13694 | # ->lock_retrieve() failed | ||
| 13695 | return %emptyHash; | ||
| 13696 | |||
| 13697 | } else { | ||
| 13698 | |||
| 13699 | # Convert the hash referenced by $hashRef into a named hash | ||
| 13700 | %loadHash = %{$hashRef}; | ||
| 13701 | |||
| 13702 | # Extract the header information (metadata) from the hash | ||
| 13703 | $fileType = $loadHash{'file_type'}; | ||
| 13704 | $scriptName = $loadHash{'script_name'}; | ||
| 13705 | $scriptVersion = $loadHash{'script_version'}; | ||
| 13706 | $saveDate = $loadHash{'save_date'}; | ||
| 13707 | $saveTime = $loadHash{'save_time'}; | ||
| 13708 | |||
| 13709 | # Before v1.0.868, Axmud used 'assoc_world_defn' rather than 'assoc_world_prof', and | ||
| 13710 | # the file_types 'worldprof'/'otherprof' were 'worlddefn'/'otherdefn' | ||
| 13711 | if ($loadHash{'file_type'} eq 'worlddefn') { | ||
| 13712 | $loadHash{'file_type'} = 'worldprof'; | ||
| 13713 | } elsif ($loadHash{'file_type'} eq 'otherdefn') { | ||
| 13714 | $loadHash{'file_type'} = 'otherprof'; | ||
| 13715 | } | ||
| 13716 | |||
| 13717 | if ($loadHash{'assoc_world_defn'}) { | ||
| 13718 | $assocWorldProf = $loadHash{'assoc_world_defn'}; | ||
| 13719 | } else { | ||
| 13720 | $assocWorldProf = $loadHash{'assoc_world_prof'}; | ||
| 13721 | } | ||
| 13722 | |||
| 13723 | # Do basic checks on the header information | ||
| 13724 | if ( | ||
| 13725 | ! defined $fileType || ! defined $scriptName || ! defined $scriptVersion | ||
| 13726 | || ! defined $saveDate || ! defined $saveTime | ||
| 13727 | ) { | ||
| 13728 | # Wrong kind of file, or missing (or possibly corrupted) header (NB $assocWorldProf | ||
| 13729 | # is 'undef' for some types of file) | ||
| 13730 | return %emptyHash; | ||
| 13731 | } | ||
| 13732 | |||
| 13733 | # 'return_header' - just return the header (metadata) | ||
| 13734 | if ($mode eq 'return_header') { | ||
| 13735 | |||
| 13736 | $returnHash{'file_type'} = $fileType; | ||
| 13737 | $returnHash{'script_name'} = $scriptName; | ||
| 13738 | $returnHash{'script_version'} = $scriptVersion; | ||
| 13739 | $returnHash{'save_date'} = $saveDate; | ||
| 13740 | $returnHash{'save_time'} = $saveTime; | ||
| 13741 | $returnHash{'assoc_world_prof'} = $assocWorldProf; | ||
| 13742 | |||
| 13743 | return %returnHash; | ||
| 13744 | |||
| 13745 | # 'remove_values' - return all the keys in the hash, but not the values (set the values | ||
| 13746 | # to 'undef') | ||
| 13747 | } elsif ($mode eq 'remove_values') { | ||
| 13748 | |||
| 13749 | foreach my $key (keys %loadHash) { | ||
| 13750 | |||
| 13751 | $returnHash{$key} = undef; | ||
| 13752 | } | ||
| 13753 | |||
| 13754 | return %returnHash; | ||
| 13755 | |||
| 13756 | # 'return_key' - return the specified key | ||
| 13757 | } elsif ($mode eq 'return_key') { | ||
| 13758 | |||
| 13759 | if (! exists $loadHash{$selectKey}) { | ||
| 13760 | |||
| 13761 | # Return an empty hash | ||
| 13762 | return %emptyHash; | ||
| 13763 | |||
| 13764 | } else { | ||
| 13765 | |||
| 13766 | # Return a hash containing the single key-value pair | ||
| 13767 | $returnHash{$selectKey} = $loadHash{$selectKey}; | ||
| 13768 | |||
| 13769 | return %returnHash; | ||
| 13770 | } | ||
| 13771 | |||
| 13772 | # 'return_hash' - return the entire loaded hash | ||
| 13773 | } elsif ($mode eq 'return_hash') { | ||
| 13774 | |||
| 13775 | return %loadHash; | ||
| 13776 | } | ||
| 13777 | } | ||
| 13778 | } | ||
| 13779 | |||
| 13780 | sub disableSaveLoad { | ||
| 13781 | |||
| 13782 | # Called by $self->loadConfigFile or $self->saveConfigFile whenever a call to File::close() | ||
| 13783 | # returns false, or whenever there's an error reading/writing the config file | ||
| 13784 | # Sets some GA::Client flags to prevent other files from being loaded/saved | ||
| 13785 | # | ||
| 13786 | # Expected arguemnts | ||
| 13787 | # $readFlag - Set to FALSE when called because of File::open or File::close returning | ||
| 13788 | # 'false', or if a lock can't be taken out or released on a semaphore | ||
| 13789 | # file; this disables loading/saving of all files | ||
| 13790 | # - Set to TRUE when called because of an error reading the config file | ||
| 13791 | # ($self->saveConfigFile doesn't have its own non-fatal errors, so there | ||
| 13792 | # is no need to check for that) | ||
| 13793 | # | ||
| 13794 | # Return values | ||
| 13795 | # 'undef' | ||
| 13796 | |||
| 13797 | my ($self, $readFlag, $check) = @_; | ||
| 13798 | |||
| 13799 | # Check for improper arguments | ||
| 13800 | if (! defined $readFlag || defined $check) { | ||
| 13801 | |||
| 13802 | return $axmud::CLIENT->writeImproper($self->_objClass . '->disableSaveLoad', @_); | ||
| 13803 | } | ||
| 13804 | |||
| 13805 | # Set GA::Client flags | ||
| 13806 | if (! $readFlag) { | ||
| 13807 | |||
| 13808 | $axmud::CLIENT->set_loadConfigFlag(FALSE); | ||
| 13809 | } | ||
| 13810 | |||
| 13811 | $axmud::CLIENT->set_saveConfigFlag(FALSE); | ||
| 13812 | $axmud::CLIENT->set_loadDataFlag(FALSE); | ||
| 13813 | $axmud::CLIENT->set_saveDataFlag(FALSE); | ||
| 13814 | |||
| 13815 | |||
| 13816 | if (! $readFlag) { | ||
| 13817 | |||
| 13818 | return $self->writeError( | ||
| 13819 | 'OS failed to open/close file (possible buffering problem) - loading/saving of' | ||
| 13820 | . ' files disabled', | ||
| 13821 | $self->_objClass . '->disableSaveLoad', | ||
| 13822 | ); | ||
| 13823 | |||
| 13824 | } else { | ||
| 13825 | |||
| 13826 | # $self->setupConfigFile displays an error message | ||
| 13827 | return undef; | ||
| 13828 | } | ||
| 13829 | } | ||
| 13830 | |||
| 13831 | sub getFileLock { | ||
| 13832 | |||
| 13833 | # Can be called by any file-writing or file-reading function within GA::Obj::File | ||
| 13834 | # (currently only called by ->loadConfigFile and ->saveConfigFile) | ||
| 13835 | # Takes out a lock on the semaphore file $sempahoreFile twinned with the data file | ||
| 13836 | # $dataFile, so that the file can be either open for reading by one or more instances | ||
| 13837 | # of Axmud (and one or more sessions), or open for writing by a single instance of Axmud | ||
| 13838 | # (or by a single session) | ||
| 13839 | # If the semaphore file doesn't exist yet, it is created | ||
| 13840 | # | ||
| 13841 | # Expected arguments | ||
| 13842 | # $semaphoreFile - The path to the semaphore file, e.g. '/home/myname/file.txt' | ||
| 13843 | # | ||
| 13844 | # Optional arguments | ||
| 13845 | # $exclusiveFlag - If set to TRUE, an exclusive lock is taken out (for writing to the | ||
| 13846 | # file). | ||
| 13847 | # - If set to FALSE (or 'undef'), a shared lock is taken out (for reading | ||
| 13848 | # from the file) | ||
| 13849 | # $dataFile - The path to the data file. If specified, the semaphore file is marked | ||
| 13850 | # with the data file's name | ||
| 13851 | # | ||
| 13852 | # Return values | ||
| 13853 | # 'undef' on improper arguments, or if the semaphore file can't be opened, or if a lock | ||
| 13854 | # can't be taken out on it (at all) | ||
| 13855 | # Otherwise returns the file handle of the locked semaphore file (required by | ||
| 13856 | # $self->releaseFileLock) | ||
| 13857 | |||
| 13858 | my ($self, $semaphoreFile, $exclusiveFlag, $dataFile, $check) = @_; | ||
| 13859 | |||
| 13860 | # Local variables | ||
| 13861 | my $semaphoreHandle; | ||
| 13862 | |||
| 13863 | # Check for improper arguments | ||
| 13864 | if (! defined $semaphoreFile || defined $check) { | ||
| 13865 | |||
| 13866 | return $axmud::CLIENT->writeImproper($self->_objClass . '->getFileLock', @_); | ||
| 13867 | } | ||
| 13868 | |||
| 13869 | # If the semaphore file doesn't yet exist (because the main file being saved is actually | ||
| 13870 | # new), create the semaphore file | ||
| 13871 | if (! (-e $semaphoreFile)) { | ||
| 13872 | |||
| 13873 | my @list; | ||
| 13874 | |||
| 13875 | if (! open ($semaphoreHandle, ">$semaphoreFile")) { | ||
| 13876 | |||
| 13877 | return undef; | ||
| 13878 | } | ||
| 13879 | |||
| 13880 | if ($dataFile) { | ||
| 13881 | @list = ($axmud::SCRIPT . ' semaphore file for ' . $dataFile); | ||
| 13882 | } else { | ||
| 13883 | @list = ($axmud::SCRIPT . ' semaphore file'); | ||
| 13884 | } | ||
| 13885 | |||
| 13886 | print $semaphoreHandle @list; | ||
| 13887 | close $semaphoreHandle; | ||
| 13888 | } | ||
| 13889 | |||
| 13890 | # Get a lock on the semaphore file | ||
| 13891 | if (! open ($semaphoreHandle, ">>$semaphoreFile")) { | ||
| 13892 | |||
| 13893 | return undef; | ||
| 13894 | } | ||
| 13895 | |||
| 13896 | if ($exclusiveFlag && ! flock ($semaphoreHandle, Fcntl::LOCK_EX)) { | ||
| 13897 | return undef; | ||
| 13898 | } elsif (! flock ($semaphoreHandle, Fcntl::LOCK_SH)) { | ||
| 13899 | return undef; | ||
| 13900 | } | ||
| 13901 | |||
| 13902 | # Return the filehandle to the locked semaphore file | ||
| 13903 | return $semaphoreHandle; | ||
| 13904 | } | ||
| 13905 | |||
| 13906 | sub releaseFileLock { | ||
| 13907 | |||
| 13908 | # Can be called by any file-writing or file-reading function within GA::Obj::File | ||
| 13909 | # (currently only called by ->loadConfigFile and ->saveConfigFile) | ||
| 13910 | # Releases a lock taken out on a semaphore file twinned with a data file | ||
| 13911 | # | ||
| 13912 | # Expected arguments | ||
| 13913 | # $semaphoreHandle - Opened handle of the semaphore file | ||
| 13914 | # | ||
| 13915 | # Return values | ||
| 13916 | # 'undef' on improper arguments | ||
| 13917 | # 1 otherwise | ||
| 13918 | |||
| 13919 | my ($self, $semaphoreHandle, $check) = @_; | ||
| 13920 | |||
| 13921 | # Check for improper arguments | ||
| 13922 | if (! defined $semaphoreHandle || defined $check) { | ||
| 13923 | |||
| 13924 | return $axmud::CLIENT->writeImproper($self->_objClass . '->releaseFileLock', @_); | ||
| 13925 | } | ||
| 13926 | |||
| 13927 | # Release the lock by closing the open filehandle | ||
| 13928 | close $semaphoreHandle; | ||
| 13929 | |||
| 13930 | return 1; | ||
| 13931 | } | ||
| 13932 | |||
| 13933 | sub readMarker { | ||
| 13934 | |||
| 13935 | # Called by $self->loadConfigFile | ||
| 13936 | # Reads lines from an opened config file until it finds one that doesn't begin with the | ||
| 13937 | # comment marker # | ||
| 13938 | # That line should begin with the status marker @@@ | ||
| 13939 | # Returns the text after the status marker @@@ as a two-element list | ||
| 13940 | # e.g. for '@@@ date Mon Aug 8, 2011', returns the list ('date', 'Mon Aug 8, 2011') | ||
| 13941 | # e.g. for '@@@ time 12:23:22' returns the list ('time', '12:23:22') | ||
| 13942 | # e.g. for '@@@ eos' (meaning end of section), returns the list ('eos', undef) | ||
| 13943 | # e.g. for '@@@ eof' (meaning end of file), returns the list ('eof', undef) | ||
| 13944 | # | ||
| 13945 | # Expected arguments | ||
| 13946 | # $fileHandle - filehandle of the config file (opened for reading) | ||
| 13947 | # | ||
| 13948 | # Return values | ||
| 13949 | # An empty list on improper arguments, if the file can't be read, the end of the file is | ||
| 13950 | # reached, the line can't be read, the line doesn't begin with @@@ or the @@@ isn't | ||
| 13951 | # followed by at least one character | ||
| 13952 | # or the @@@ isn't followed by at least one character, returns 'undef' | ||
| 13953 | |||
| 13954 | |||
| 13955 | # Otherwise, the list described above | ||
| 13956 | |||
| 13957 | my ($self, $fileHandle, $check) = @_; | ||
| 13958 | |||
| 13959 | # Local variables | ||
| 13960 | my ( | ||
| 13961 | $line, $position, | ||
| 13962 | @emptyList, @returnArray, | ||
| 13963 | ); | ||
| 13964 | |||
| 13965 | # Check for improper arguments | ||
| 13966 | if (! defined $fileHandle || defined $check) { | ||
| 13967 | |||
| 13968 | $axmud::CLIENT->writeImproper($self->_objClass . '->readMarker', @_); | ||
| 13969 | return @emptyList; | ||
| 13970 | } | ||
| 13971 | |||
| 13972 | # Read an entry from the file | ||
| 13973 | OUTER: while (1) { | ||
| 13974 | |||
| 13975 | $line = <$fileHandle>; | ||
| 13976 | chomp $line; | ||
| 13977 | |||
| 13978 | if (! defined $line) { | ||
| 13979 | |||
| 13980 | # File can't be read, or end of file | ||
| 13981 | return @emptyList; | ||
| 13982 | } | ||
| 13983 | |||
| 13984 | if (substr ($line, 0, 1) ne '#') { | ||
| 13985 | |||
| 13986 | # $line should start with @@@ | ||
| 13987 | if (substr ($line, 0, 4) ne '@@@ ') { | ||
| 13988 | |||
| 13989 | return @emptyList; | ||
| 13990 | } | ||
| 13991 | |||
| 13992 | # $line starts with @@@, so continue processing it | ||
| 13993 | last OUTER; | ||
| 13994 | } | ||
| 13995 | } | ||
| 13996 | |||
| 13997 | # Remove the @@@ | ||
| 13998 | $line = substr($line, 4); | ||
| 13999 | |||
| 14000 | # Extract the first word | ||
| 14001 | $position = index($line, ' '); | ||
| 14002 | |||
| 14003 | if ($position < 1) { | ||
| 14004 | |||
| 14005 | # Line consists of just one word | ||
| 14006 | return ($line, undef); | ||
| 14007 | |||
| 14008 | } else { | ||
| 14009 | |||
| 14010 | # Line consists of a word, plus an argument string | ||
| 14011 | return (substr($line, 0, $position), substr($line, $position + 1)); | ||
| 14012 | } | ||
| 14013 | } | ||
| 14014 | |||
| 14015 | sub readLine { | ||
| 14016 | |||
| 14017 | # Called by $self->loadConfigFile and its sub-functions | ||
| 14018 | # Reads lines from an opened config file until it finds one that doesn't begin with the | ||
| 14019 | # comment marker # | ||
| 14020 | # If that line begins with the status marker @@@, returns 'undef' (because we are expecting | ||
| 14021 | # some readable data, not a marker) | ||
| 14022 | # | ||
| 14023 | # Expected arguments | ||
| 14024 | # $fileHandle - filehandle of the config file (opened for reading) | ||
| 14025 | # | ||
| 14026 | # Return values | ||
| 14027 | # 'undef' on improper arguments, if the file can't be read, the end of the file is | ||
| 14028 | # reached, of if there's a status marker where data should be | ||
| 14029 | # Otherwise, returns the first line of data read from the file that doesn't begin with | ||
| 14030 | # the comment marker # | ||
| 14031 | |||
| 14032 | my ($self, $fileHandle, $check) = @_; | ||
| 14033 | |||
| 14034 | # Local variables | ||
| 14035 | my $line; | ||
| 14036 | |||
| 14037 | # Check for improper arguments | ||
| 14038 | if (! defined $fileHandle || defined $check) { | ||
| 14039 | |||
| 14040 | return $axmud::CLIENT->writeImproper($self->_objClass . '->readLine', @_); | ||
| 14041 | } | ||
| 14042 | |||
| 14043 | # Read a line of data from the file | ||
| 14044 | while (1) { | ||
| 14045 | |||
| 14046 | $line = <$fileHandle>; | ||
| 14047 | chomp $line; | ||
| 14048 | |||
| 14049 | if (! defined $line || substr ($line, 0, 4) eq '@@@ ') { | ||
| 14050 | |||
| 14051 | # File can't be read, or end of file; or there's a status marker where a line of | ||
| 14052 | # data should be | ||
| 14053 | return undef; | ||
| 14054 | |||
| 14055 | } elsif (substr ($line, 0, 2) ne '# ') { | ||
| 14056 | |||
| 14057 | # This is a line of data. Return it | ||
| 14058 | return $line; | ||
| 14059 | } | ||
| 14060 | } | ||
| 14061 | } | ||
| 14062 | |||
| 14063 | sub readValue { | ||
| 14064 | |||
| 14065 | # Called by $self->loadConfigFile | ||
| 14066 | # Reads a single value from an opened config file, and stores it in the temporary hash of | ||
| 14067 | # loaded data | ||
| 14068 | # | ||
| 14069 | # Expected arguments | ||
| 14070 | # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag, | ||
| 14071 | # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE, | ||
| 14072 | # this function does nothing. If none of the calls have failed so far, | ||
| 14073 | # set to TRUE. | ||
| 14074 | # $hashRef - Reference to the temporary hash of loaded data | ||
| 14075 | # $key - The key in the temporary hash where the value read by this function is | ||
| 14076 | # stored | ||
| 14077 | # | ||
| 14078 | # Return values | ||
| 14079 | # Returns the new value of $failFlag: | ||
| 14080 | # TRUE if $failFlag is already set to TRUE, or if this function can't read a value | ||
| 14081 | # FALSE otherwise (meaning that the function succeeded) | ||
| 14082 | |||
| 14083 | my ($self, $failFlag, $hashRef, $key, $check) = @_; | ||
| 14084 | |||
| 14085 | # Local variables | ||
| 14086 | my $value; | ||
| 14087 | |||
| 14088 | # Check for improper arguments | ||
| 14089 | if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) { | ||
| 14090 | |||
| 14091 | $axmud::CLIENT->writeImproper($self->_objClass . '->readValue', @_); | ||
| 14092 | return TRUE; | ||
| 14093 | } | ||
| 14094 | |||
| 14095 | # Do nothing, if previous calls failed | ||
| 14096 | if ($failFlag) { | ||
| 14097 | |||
| 14098 | return TRUE; | ||
| 14099 | } | ||
| 14100 | |||
| 14101 | # Read the value | ||
| 14102 | $value = $self->readLine($$hashRef{'file_handle'}); | ||
| 14103 | |||
| 14104 | if (! defined $value) { | ||
| 14105 | |||
| 14106 | # Operation failed | ||
| 14107 | $self->writeError( | ||
| 14108 | 'Config file load error at item \'' . $key . '\'', | ||
| 14109 | $self->_objClass . '->readValue', | ||
| 14110 | ); | ||
| 14111 | |||
| 14112 | return TRUE; | ||
| 14113 | |||
| 14114 | } else { | ||
| 14115 | |||
| 14116 | # Operation succeeded. Store the value in the temporary data hash | ||
| 14117 | $$hashRef{$key} = $value; | ||
| 14118 | return FALSE; | ||
| 14119 | } | ||
| 14120 | } | ||
| 14121 | |||
| 14122 | sub readValueOrUndef { | ||
| 14123 | |||
| 14124 | # Called by $self->loadConfigFile | ||
| 14125 | # Reads a single value from an opened config file, and stores it in the temporary hash of | ||
| 14126 | # loaded data | ||
| 14127 | # Unlike $self->readValue, if the code reads an empty string, it uses the value 'undef' | ||
| 14128 | # rather than an empty string | ||
| 14129 | # | ||
| 14130 | # Expected arguments | ||
| 14131 | # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag, | ||
| 14132 | # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE, | ||
| 14133 | # this function does nothing. If none of the calls have failed so far, | ||
| 14134 | # set to TRUE. | ||
| 14135 | # $hashRef - Reference to the temporary hash of loaded data | ||
| 14136 | # $key - The key in the temporary hash where the value read by this function is | ||
| 14137 | # stored | ||
| 14138 | # | ||
| 14139 | # Return values | ||
| 14140 | # Returns the new value of $failFlag: | ||
| 14141 | # TRUE if $failFlag is already set to TRUE, or if this function can't read a value | ||
| 14142 | # FALSE otherwise (meaning that the function succeeded) | ||
| 14143 | |||
| 14144 | my ($self, $failFlag, $hashRef, $key, $check) = @_; | ||
| 14145 | |||
| 14146 | # Local variables | ||
| 14147 | my $value; | ||
| 14148 | |||
| 14149 | # Check for improper arguments | ||
| 14150 | if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) { | ||
| 14151 | |||
| 14152 | $axmud::CLIENT->writeImproper($self->_objClass . '->readValue', @_); | ||
| 14153 | return TRUE; | ||
| 14154 | } | ||
| 14155 | |||
| 14156 | # Do nothing, if previous calls failed | ||
| 14157 | if ($failFlag) { | ||
| 14158 | |||
| 14159 | return TRUE; | ||
| 14160 | } | ||
| 14161 | |||
| 14162 | # Read the value | ||
| 14163 | $value = $self->readLine($$hashRef{'file_handle'}); | ||
| 14164 | |||
| 14165 | if (! defined $value) { | ||
| 14166 | |||
| 14167 | # Operation failed | ||
| 14168 | $self->writeError( | ||
| 14169 | 'Config file load error at item \'' . $key . '\'', | ||
| 14170 | $self->_objClass . '->readValueOrUndef', | ||
| 14171 | ); | ||
| 14172 | |||
| 14173 | return TRUE; | ||
| 14174 | |||
| 14175 | } else { | ||
| 14176 | |||
| 14177 | # Operation succeeded. Store the value in the temporary data hash | ||
| 14178 | if ($value eq '') { | ||
| 14179 | $$hashRef{$key} = undef; | ||
| 14180 | } else { | ||
| 14181 | $$hashRef{$key} = $value; | ||
| 14182 | } | ||
| 14183 | |||
| 14184 | return FALSE; | ||
| 14185 | } | ||
| 14186 | } | ||
| 14187 | |||
| 14188 | sub readFlag { | ||
| 14189 | |||
| 14190 | # Called by $self->loadConfigFile | ||
| 14191 | # Reads a single flag from an opened config file, and stores it in the temporary hash of | ||
| 14192 | # loaded data | ||
| 14193 | # | ||
| 14194 | # Expected arguments | ||
| 14195 | # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag, | ||
| 14196 | # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE, | ||
| 14197 | # this function does nothing. If none of the calls have failed so far, | ||
| 14198 | # set to TRUE. | ||
| 14199 | # $hashRef - Reference to the temporary hash of loaded data | ||
| 14200 | # $key - The key in the temporary hash where the flag read by this function is | ||
| 14201 | # stored | ||
| 14202 | # | ||
| 14203 | # Return values | ||
| 14204 | # Returns the new value of $failFlag: | ||
| 14205 | # TRUE if $failFlag is already set to TRUE, or if this function can't read a flag | ||
| 14206 | # FALSE otherwise (meaning that the function succeeded) | ||
| 14207 | |||
| 14208 | my ($self, $failFlag, $hashRef, $key, $check) = @_; | ||
| 14209 | |||
| 14210 | # Local variables | ||
| 14211 | my $flag; | ||
| 14212 | |||
| 14213 | # Check for improper arguments | ||
| 14214 | if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) { | ||
| 14215 | |||
| 14216 | $axmud::CLIENT->writeImproper($self->_objClass . '->readFlag', @_); | ||
| 14217 | return TRUE; | ||
| 14218 | } | ||
| 14219 | |||
| 14220 | # Do nothing, if previous calls failed | ||
| 14221 | if ($failFlag) { | ||
| 14222 | |||
| 14223 | return TRUE; | ||
| 14224 | } | ||
| 14225 | |||
| 14226 | # Read the flag | ||
| 14227 | $flag = $self->readLine($$hashRef{'file_handle'}); | ||
| 14228 | |||
| 14229 | if (! defined $flag) { | ||
| 14230 | |||
| 14231 | # Operation failed | ||
| 14232 | $self->writeError( | ||
| 14233 | 'Config file load error at item \'' . $key . '\'', | ||
| 14234 | $self->_objClass . '->readFlag', | ||
| 14235 | ); | ||
| 14236 | |||
| 14237 | return TRUE; | ||
| 14238 | |||
| 14239 | } else { | ||
| 14240 | |||
| 14241 | # Operation succeeded. Store the flag in the temporary data hash | ||
| 14242 | if ($flag) { | ||
| 14243 | $$hashRef{$key} = TRUE; | ||
| 14244 | } else { | ||
| 14245 | $$hashRef{$key} = FALSE; | ||
| 14246 | } | ||
| 14247 | |||
| 14248 | return FALSE; | ||
| 14249 | } | ||
| 14250 | } | ||
| 14251 | |||
| 14252 | sub readList { | ||
| 14253 | |||
| 14254 | # Called by $self->loadConfigFile | ||
| 14255 | # Reads a list from an opened config file - consisting of the number of value to read, | ||
| 14256 | # followed by the values themselves - and stores the values themselves in the temporary | ||
| 14257 | # hash of loaded data | ||
| 14258 | # | ||
| 14259 | # Expected arguments | ||
| 14260 | # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag, | ||
| 14261 | # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE, | ||
| 14262 | # this function does nothing. If none of the calls have failed so far, | ||
| 14263 | # set to TRUE. | ||
| 14264 | # $hashRef - Reference to the temporary hash of loaded data | ||
| 14265 | # $key - The key in the temporary hash where the list read by this function is | ||
| 14266 | # stored | ||
| 14267 | # | ||
| 14268 | # Return values | ||
| 14269 | # Returns the new value of $failFlag: | ||
| 14270 | # TRUE if $failFlag is already set to TRUE, if this function can't read a list or if | ||
| 14271 | # the list contains the wrong number of values | ||
| 14272 | # FALSE otherwise (meaning that the function succeeded) | ||
| 14273 | |||
| 14274 | my ($self, $failFlag, $hashRef, $key, $check) = @_; | ||
| 14275 | |||
| 14276 | # Local variables | ||
| 14277 | my ( | ||
| 14278 | $number, | ||
| 14279 | @list, | ||
| 14280 | ); | ||
| 14281 | |||
| 14282 | # Check for improper arguments | ||
| 14283 | if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) { | ||
| 14284 | |||
| 14285 | $axmud::CLIENT->writeImproper($self->_objClass . '->readList', @_); | ||
| 14286 | return TRUE; | ||
| 14287 | } | ||
| 14288 | |||
| 14289 | # Do nothing, if previous calls failed | ||
| 14290 | if ($failFlag) { | ||
| 14291 | |||
| 14292 | return TRUE; | ||
| 14293 | } | ||
| 14294 | |||
| 14295 | # Read the number of items in the list | ||
| 14296 | $number = $self->readLine($$hashRef{'file_handle'}); | ||
| 14297 | if (! defined $number || ! $axmud::CLIENT->intCheck($number, 0)) { | ||
| 14298 | |||
| 14299 | # Operation failed | ||
| 14300 | $self->writeError( | ||
| 14301 | 'Config file load error at item \'' . $key . '\'', | ||
| 14302 | $self->_objClass . '->readList', | ||
| 14303 | ); | ||
| 14304 | |||
| 14305 | return TRUE; | ||
| 14306 | |||
| 14307 | } else { | ||
| 14308 | |||
| 14309 | for (my $count = 0; $count < $number; $count++) { | ||
| 14310 | |||
| 14311 | my $value = $self->readLine($$hashRef{'file_handle'}); | ||
| 14312 | if (! defined $value) { | ||
| 14313 | |||
| 14314 | # Missing value; operation failed | ||
| 14315 | $self->writeError( | ||
| 14316 | 'Config file load error at item \'' . $key . '\' - missing value(s)', | ||
| 14317 | $self->_objClass . '->readList', | ||
| 14318 | ); | ||
| 14319 | |||
| 14320 | return TRUE; | ||
| 14321 | |||
| 14322 | } else { | ||
| 14323 | |||
| 14324 | push (@list, $value); | ||
| 14325 | } | ||
| 14326 | } | ||
| 14327 | |||
| 14328 | # Operation succeeded. Store the list in the temporary data hash | ||
| 14329 | $$hashRef{$key} = \@list; | ||
| 14330 | return FALSE; | ||
| 14331 | } | ||
| 14332 | } | ||
| 14333 | |||
| 14334 | sub readHash { | ||
| 14335 | |||
| 14336 | # Called by $self->loadConfigFile | ||
| 14337 | # Reads a hash from an opened config file - consisting of the number of key-value pairs to | ||
| 14338 | # read, followed by the keys and values themselves - and stores the complete hash in the | ||
| 14339 | # temporary hash of loaded data | ||
| 14340 | # | ||
| 14341 | # Expected arguments | ||
| 14342 | # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag, | ||
| 14343 | # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE, | ||
| 14344 | # this function does nothing. If none of the calls have failed so far, | ||
| 14345 | # set to TRUE. | ||
| 14346 | # $hashRef - Reference to the temporary hash of loaded data | ||
| 14347 | # $key - The key in the temporary hash where the hash read by this function is | ||
| 14348 | # stored | ||
| 14349 | # | ||
| 14350 | # Return values | ||
| 14351 | # Returns the new value of $failFlag: | ||
| 14352 | # TRUE if $failFlag is already set to TRUE, if this function can't read a hash or if | ||
| 14353 | # the list contains the wrong number of key-value pairs | ||
| 14354 | # FALSE otherwise (meaning that the function succeeded) | ||
| 14355 | |||
| 14356 | my ($self, $failFlag, $hashRef, $key, $check) = @_; | ||
| 14357 | |||
| 14358 | # Local variables | ||
| 14359 | my ( | ||
| 14360 | $number, | ||
| 14361 | %hash, | ||
| 14362 | ); | ||
| 14363 | |||
| 14364 | # Check for improper arguments | ||
| 14365 | if (! defined $failFlag || ! defined $hashRef || ! defined $key || defined $check) { | ||
| 14366 | |||
| 14367 | $axmud::CLIENT->writeImproper($self->_objClass . '->readHash', @_); | ||
| 14368 | return TRUE; | ||
| 14369 | } | ||
| 14370 | |||
| 14371 | # Do nothing, if previous calls failed | ||
| 14372 | if ($failFlag) { | ||
| 14373 | |||
| 14374 | return TRUE; | ||
| 14375 | } | ||
| 14376 | |||
| 14377 | # Read the number of key-value pairs in the hash | ||
| 14378 | $number = $self->readLine($$hashRef{'file_handle'}); | ||
| 14379 | if (! defined $number || ! $axmud::CLIENT->intCheck($number, 0)) { | ||
| 14380 | |||
| 14381 | # Operation failed | ||
| 14382 | $self->writeError( | ||
| 14383 | 'Config file load error at item \'' . $key . '\'', | ||
| 14384 | $self->_objClass . '->readHash', | ||
| 14385 | ); | ||
| 14386 | |||
| 14387 | return TRUE; | ||
| 14388 | |||
| 14389 | } else { | ||
| 14390 | |||
| 14391 | for (my $count = 0; $count < $number; $count++) { | ||
| 14392 | |||
| 14393 | my ($key, $value); | ||
| 14394 | |||
| 14395 | $key = $self->readLine($$hashRef{'file_handle'}); | ||
| 14396 | if (! defined $key) { | ||
| 14397 | |||
| 14398 | # Missing value; operation failed | ||
| 14399 | $self->writeError( | ||
| 14400 | 'Config file load error at item \'' . $key . '\' - missing value(s)', | ||
| 14401 | $self->_objClass . '->readHash', | ||
| 14402 | ); | ||
| 14403 | |||
| 14404 | return TRUE; | ||
| 14405 | } | ||
| 14406 | |||
| 14407 | $value = $self->readLine($$hashRef{'file_handle'}); | ||
| 14408 | if (! defined $value) { | ||
| 14409 | |||
| 14410 | # Missing value; operation failed | ||
| 14411 | $self->writeError( | ||
| 14412 | 'Config file load error at item \'' . $key . '\' - missing value(s)', | ||
| 14413 | $self->_objClass . '->readHash', | ||
| 14414 | ); | ||
| 14415 | |||
| 14416 | return TRUE; | ||
| 14417 | } | ||
| 14418 | |||
| 14419 | $hash{$key} = $value; | ||
| 14420 | } | ||
| 14421 | |||
| 14422 | # Operation succeeded. Store the list in the temporary data hash | ||
| 14423 | $$hashRef{$key} = \%hash; | ||
| 14424 | return FALSE; | ||
| 14425 | } | ||
| 14426 | } | ||
| 14427 | |||
| 14428 | sub readEndOfSection { | ||
| 14429 | |||
| 14430 | # Called by $self->loadConfigFile | ||
| 14431 | # Reads a single end-of-section line from an opened config file | ||
| 14432 | # | ||
| 14433 | # Expected arguments | ||
| 14434 | # $failFlag - Flag set to TRUE if any previous calls to $self->readValue, ->readFlag, | ||
| 14435 | # ->readList, ->readHash or ->readEndOfSection failed. If set to TRUE, | ||
| 14436 | # this function does nothing. If none of the calls have failed so far, | ||
| 14437 | # set to TRUE. | ||
| 14438 | # $fileHandle - The config file's filehandle | ||
| 14439 | # | ||
| 14440 | # Return values | ||
| 14441 | # Returns the new value of $failFlag: | ||
| 14442 | # TRUE if $failFlag is already set to TRUE, or if this function can't read the | ||
| 14443 | # end-of-section | ||
| 14444 | # FALSE otherwise (meaning that the function succeeded) | ||
| 14445 | |||
| 14446 | my ($self, $failFlag, $fileHandle, $check) = @_; | ||
| 14447 | |||
| 14448 | # Local variables | ||
| 14449 | my $line; | ||
| 14450 | |||
| 14451 | # Check for improper arguments | ||
| 14452 | if (! defined $failFlag || ! defined $fileHandle || defined $check) { | ||
| 14453 | |||
| 14454 | $axmud::CLIENT->writeImproper($self->_objClass . '->readEndOfSection', @_); | ||
| 14455 | return FALSE; | ||
| 14456 | } | ||
| 14457 | |||
| 14458 | # Do nothing, if previous calls failed | ||
| 14459 | if ($failFlag) { | ||
| 14460 | |||
| 14461 | return TRUE; | ||
| 14462 | } | ||
| 14463 | |||
| 14464 | # Read the end of section | ||
| 14465 | ($line) = $self->readMarker($fileHandle); | ||
| 14466 | |||
| 14467 | if (! defined $line || $line ne 'eos') { | ||
| 14468 | |||
| 14469 | # Operation failed | ||
| 14470 | return TRUE; | ||
| 14471 | |||
| 14472 | } else { | ||
| 14473 | |||
| 14474 | # Operation succeeded | ||
| 14475 | return FALSE; | ||
| 14476 | } | ||
| 14477 | } | ||
| 14478 | |||
| 14479 | sub convert { | ||
| 14480 | |||
| 14481 | # Called by $self->saveConfigFile | ||
| 14482 | # Converts an Axmud flag (TRUE or FALSE) into the values 1 or 0, so it can be written to the | ||
| 14483 | # 'config' file | ||
| 14484 | # | ||
| 14485 | # Expected arguments | ||
| 14486 | # (none besides $self) | ||
| 14487 | # | ||
| 14488 | # Optional arguments | ||
| 14489 | # $flag - The flag to convert (should be TRUE or FALSE). If 'undef', treated as FALSE | ||
| 14490 | # | ||
| 14491 | # Return values | ||
| 14492 | # 1 or 0 | ||
| 14493 | |||
| 14494 | my ($self, $flag, $check) = @_; | ||
| 14495 | |||
| 14496 | # (No improper arguments to check) | ||
| 14497 | |||
| 14498 | if ($flag) { | ||
| 14499 | return 1; | ||
| 14500 | } else { | ||
| 14501 | return 0; | ||
| 14502 | } | ||
| 14503 | } | ||
| 14504 | |||
| 14505 | sub destroyStandardDir { | ||
| 14506 | |||
| 14507 | # Called by GA::Cmd::DeleteWorld, or by any other code | ||
| 14508 | # Deletes the whole directory in which this object's file is stored - in the case of a | ||
| 14509 | # 'worldprof' file, deleting the directory $self->actualDir will also cause the | ||
| 14510 | # 'otherprof' and 'worldmodel' files, which are in the same directory, to be deleted | ||
| 14511 | # (If $self->actualDir hasn't been set yet, $self->standardDir is used) | ||
| 14512 | # No warning dialogue is shown - it's up to the calling code to do that | ||
| 14513 | # | ||
| 14514 | # Expected arguments | ||
| 14515 | # (none besides $self) | ||
| 14516 | # | ||
| 14517 | # Return values | ||
| 14518 | # 'undef' on improper arguments, if $self->actualDir isn't set or if it doesn't exist | ||
| 14519 | # 1 otherwise | ||
| 14520 | |||
| 14521 | my ($self, $check) = @_; | ||
| 14522 | |||
| 14523 | # Local variables | ||
| 14524 | my $dir; | ||
| 14525 | |||
| 14526 | # Check for improper arguments | ||
| 14527 | if (defined $check) { | ||
| 14528 | |||
| 14529 | return $axmud::CLIENT->writeImproper($self->_objClass . '->destroyStandardDir', @_); | ||
| 14530 | } | ||
| 14531 | |||
| 14532 | # Decide which directory to delete | ||
| 14533 | if ($self->actualDir) { | ||
| 14534 | $dir = $self->actualDir; | ||
| 14535 | } else { | ||
| 14536 | $dir = $axmud::DATA_DIR . $self->standardDir; | ||
| 14537 | } | ||
| 14538 | |||
| 14539 | if (! $dir || ! (-e $dir)) { | ||
| 14540 | |||
| 14541 | # Directory not set or doesn't exist | ||
| 14542 | return undef; | ||
| 14543 | |||
| 14544 | } else { | ||
| 14545 | |||
| 14546 | # Delete the directory and everything it contains | ||
| 14547 | File::Path::remove_tree($dir); | ||
| 14548 | |||
| 14549 | return 1; | ||
| 14550 | } | ||
| 14551 | } | ||
| 14552 | |||
| 14553 | # Glob test mode | ||
| 14554 | |||
| 14555 | sub globTest { | ||
| 14556 | |||
| 14557 | # Called by $self->saveDataFile | ||
| 14558 | # Glob test mode: In earlier Axmud versions, saving of data files failed (and Axmud crashed) | ||
| 14559 | # because of infinite recursions with two Perl objects referencing each other. If TRUE, | ||
| 14560 | # ever save file operation (not including the config file) tests data for this problem, | ||
| 14561 | # before saving it, writing the output to the terminal | ||
| 14562 | # | ||
| 14563 | # Expected arguments | ||
| 14564 | # %saveHash - A hash of data about to be saved to a data file | ||
| 14565 | # | ||
| 14566 | # Return values | ||
| 14567 | # 'undef' if the test fails (data file must not be saved) | ||
| 14568 | # 1 if the test succeeds (data file can be saved) | ||
| 14569 | |||
| 14570 | my ($self, %saveHash) = @_; | ||
| 14571 | |||
| 14572 | # Local variables | ||
| 14573 | my ($string, $line); | ||
| 14574 | |||
| 14575 | # (no improper arguments to check) | ||
| 14576 | |||
| 14577 | $string = $axmud::SCRIPT . " SAVE DATA TEST"; | ||
| 14578 | print "$string\n"; | ||
| 14579 | $line = "=" x length($string); | ||
| 14580 | print "$line\n"; | ||
| 14581 | |||
| 14582 | if (! $self->globTest_hash(1, \%saveHash)) { | ||
| 14583 | |||
| 14584 | print "TEST FAILED\n"; | ||
| 14585 | return undef; | ||
| 14586 | |||
| 14587 | } else { | ||
| 14588 | |||
| 14589 | print "TEST SUCCEEDED\n"; | ||
| 14590 | return 1; | ||
| 14591 | } | ||
| 14592 | } | ||
| 14593 | |||
| 14594 | sub globTest_list { | ||
| 14595 | |||
| 14596 | # Called by $self->globTest or recursively by this function and/or $self->globTest_hash | ||
| 14597 | |||
| 14598 | my ($self, $count, $listRef) = @_; | ||
| 14599 | |||
| 14600 | $count++; | ||
| 14601 | if ($count >= 50) { | ||
| 14602 | |||
| 14603 | # Likely infinite recursion; give up | ||
| 14604 | return undef; | ||
| 14605 | } | ||
| 14606 | |||
| 14607 | foreach my $item (@$listRef) { | ||
| 14608 | |||
| 14609 | my ($column, $result); | ||
| 14610 | |||
| 14611 | $column = " " x $count; | ||
| 14612 | |||
| 14613 | if (defined $item) { | ||
| 14614 | print "$column item $item\n"; | ||
| 14615 | } else { | ||
| 14616 | print "$column item <undef>\n"; | ||
| 14617 | } | ||
| 14618 | |||
| 14619 | if (ref ($item) eq 'HASH' || ref ($item) =~ m/Axmud\:\:/) { | ||
| 14620 | $result = $self->globTest_hash($count, $item); | ||
| 14621 | } elsif (ref ($item) eq 'ARRAY') { | ||
| 14622 | $result = $self->globTest_list($count, $item); | ||
| 14623 | } else { | ||
| 14624 | $result = TRUE; | ||
| 14625 | } | ||
| 14626 | |||
| 14627 | if (! $result) { | ||
| 14628 | |||
| 14629 | return undef; | ||
| 14630 | } | ||
| 14631 | } | ||
| 14632 | |||
| 14633 | return 1; | ||
| 14634 | } | ||
| 14635 | |||
| 14636 | sub globTest_hash { | ||
| 14637 | |||
| 14638 | # Called by $self->globTest or recursively by this function and/or $self->globTest_list | ||
| 14639 | |||
| 14640 | my ($self, $count, $hashRef) = @_; | ||
| 14641 | |||
| 14642 | $count++; | ||
| 14643 | if ($count >= 50) { | ||
| 14644 | |||
| 14645 | # Likely infinite recursion; give up | ||
| 14646 | return undef; | ||
| 14647 | } | ||
| 14648 | |||
| 14649 | foreach my $key (keys %$hashRef) { | ||
| 14650 | |||
| 14651 | my ($value, $column, $result); | ||
| 14652 | |||
| 14653 | $value = $$hashRef{$key}; | ||
| 14654 | $column = " " x $count; | ||
| 14655 | |||
| 14656 | if (defined $value) { | ||
| 14657 | print "$column key $key value $value\n"; | ||
| 14658 | } else { | ||
| 14659 | print "$column key $key value <undef>\n"; | ||
| 14660 | } | ||
| 14661 | |||
| 14662 | if (ref ($value) eq 'HASH' || ref ($value) =~ m/Axmud\:\:/) { | ||
| 14663 | $result = $self->globTest_hash($count, $value); | ||
| 14664 | } elsif (ref ($value) eq 'ARRAY') { | ||
| 14665 | $result = $self->globTest_list($count, $value); | ||
| 14666 | } else { | ||
| 14667 | $result = TRUE; | ||
| 14668 | } | ||
| 14669 | |||
| 14670 | if (! $result) { | ||
| 14671 | |||
| 14672 | return undef; | ||
| 14673 | } | ||
| 14674 | } | ||
| 14675 | |||
| 14676 | return 1; | ||
| 14677 | } | ||
| 14678 | |||
| 14679 | # Client-renaming operations | ||
| 14680 | |||
| 14681 | sub updateHeaderAfterRename { | ||
| 14682 | |||
| 14683 | # In version v1.0.868, the client was renamed to Axmud, and ABasic was renamed to Axbasic. | ||
| 14684 | # Some internal data structures were also renamed | ||
| 14685 | # This function is called by $self->loadDataFile and ->importDataFile to update the file's | ||
| 14686 | # header data (the remaining data is update by the call to $self->updateDataAfterRename | ||
| 14687 | # Also called by GA::Client->copyPreConfigWorlds | ||
| 14688 | # | ||
| 14689 | # This code will probably be moved to an optional plugin at some point in the future | ||
| 14690 | # | ||
| 14691 | # Expected arguments | ||
| 14692 | # %loadHash - A hash of data that's just been loaded from this data file, before it has | ||
| 14693 | # been extracted and stored in memory | ||
| 14694 | # | ||
| 14695 | # Return values | ||
| 14696 | # %loadHash, which has been updated (or not) as required | ||
| 14697 | |||
| 14698 | my ($self, %loadHash) = @_; | ||
| 14699 | |||
| 14700 | # (no improper arguments to check) | ||
| 14701 | |||
| 14702 | if (exists $loadHash{'file_type'}) { | ||
| 14703 | |||
| 14704 | if ($loadHash{'file_type'} eq 'worlddefn') { | ||
| 14705 | $loadHash{'file_type'} = 'worldprof'; | ||
| 14706 | } elsif ($loadHash{'file_type'} eq 'otherdefn') { | ||
| 14707 | $loadHash{'file_type'} = 'otherprof'; | ||
| 14708 | } | ||
| 14709 | } | ||
| 14710 | |||
| 14711 | if (exists $loadHash{'assoc_world_defn'}) { | ||
| 14712 | |||
| 14713 | $loadHash{'assoc_world_prof'} = $loadHash{'assoc_world_defn'}; | ||
| 14714 | delete $loadHash{'assoc_world_defn'}; | ||
| 14715 | } | ||
| 14716 | |||
| 14717 | return %loadHash; | ||
| 14718 | } | ||
| 14719 | |||
| 14720 | sub updateDataAfterRename { | ||
| 14721 | |||
| 14722 | # In version v1.0.868, the client was renamed to Axmud, and ABasic was renamed to Axbasic. | ||
| 14723 | # Some internal data structures were also renamed | ||
| 14724 | # This function is called by $self->extractData to update the file's data (not including the | ||
| 14725 | # header data, which was updated in the earlier call to $self->updateHeaderAfterRename) | ||
| 14726 | # This code will probably be moved to an optional plugin at some point in the future | ||
| 14727 | # | ||
| 14728 | # Expected arguments | ||
| 14729 | # %loadHash - A hash of data that's just been loaded from this data file, before it has | ||
| 14730 | # been extracted and stored in memory | ||
| 14731 | # | ||
| 14732 | # Return values | ||
| 14733 | # %loadHash, which has been updated (or not) as required | ||
| 14734 | |||
| 14735 | my ($self, %loadHash) = @_; | ||
| 14736 | |||
| 14737 | # Local variables | ||
| 14738 | my ($obj, $hashRef, $subHashRef); | ||
| 14739 | |||
| 14740 | # (no improper arguments to check) | ||
| 14741 | |||
| 14742 | if ($self->fileType eq 'worldprof') { | ||
| 14743 | |||
| 14744 | if (exists $loadHash{'world_defn'}) { | ||
| 14745 | |||
| 14746 | $loadHash{'world_prof'} = $loadHash{'world_defn'}; | ||
| 14747 | delete $loadHash{'world_defn'}; | ||
| 14748 | } | ||
| 14749 | |||
| 14750 | if (exists $loadHash{'world_prof'}) { | ||
| 14751 | |||
| 14752 | $loadHash{'world_prof'} = $self->update_profile_world($loadHash{'world_prof'}); | ||
| 14753 | } | ||
| 14754 | |||
| 14755 | } elsif ($self->fileType eq 'otherprof') { | ||
| 14756 | |||
| 14757 | if (exists $loadHash{'defn_priority_list'}) { | ||
| 14758 | |||
| 14759 | $loadHash{'prof_priority_list'} = $loadHash{'defn_priority_list'}; | ||
| 14760 | delete $loadHash{'defn_priority_list'}; | ||
| 14761 | } | ||
| 14762 | |||
| 14763 | if (exists $loadHash{'defn_hash'}) { | ||
| 14764 | |||
| 14765 | $loadHash{'prof_hash'} = $loadHash{'defn_hash'}; | ||
| 14766 | delete $loadHash{'defn_hash'}; | ||
| 14767 | } | ||
| 14768 | |||
| 14769 | # no update required for 'prof_priority_list' | ||
| 14770 | |||
| 14771 | if (exists $loadHash{'skeleton_hash'}) { | ||
| 14772 | |||
| 14773 | $hashRef = $loadHash{'skeleton_hash'}; | ||
| 14774 | foreach my $key (keys %$hashRef) { | ||
| 14775 | |||
| 14776 | $$hashRef{$key} = $self->update_profile_template($$hashRef{$key}); | ||
| 14777 | } | ||
| 14778 | |||
| 14779 | $loadHash{'template_hash'} = $hashRef; | ||
| 14780 | delete $loadHash{'skeleton_hash'}; | ||
| 14781 | } | ||
| 14782 | |||
| 14783 | if (exists $loadHash{'prof_hash'}) { | ||
| 14784 | |||
| 14785 | $hashRef = $loadHash{'prof_hash'}; | ||
| 14786 | foreach my $key (keys %$hashRef) { | ||
| 14787 | |||
| 14788 | $$hashRef{$key} = $self->update_profile_other($$hashRef{$key}); | ||
| 14789 | } | ||
| 14790 | |||
| 14791 | $loadHash{'prof_hash'} = $hashRef; | ||
| 14792 | } | ||
| 14793 | |||
| 14794 | if (exists $loadHash{'templ_hash'}) { | ||
| 14795 | |||
| 14796 | $hashRef = $loadHash{'templ_hash'}; | ||
| 14797 | foreach my $key (keys %$hashRef) { | ||
| 14798 | |||
| 14799 | $$hashRef{$key} = $self->update_cage_all($$hashRef{$key}); | ||
| 14800 | } | ||
| 14801 | |||
| 14802 | $loadHash{'cage_hash'} = $hashRef; | ||
| 14803 | } | ||
| 14804 | |||
| 14805 | } elsif ($self->fileType eq 'worldmodel') { | ||
| 14806 | |||
| 14807 | if (exists $loadHash{'world_model_obj'}) { | ||
| 14808 | |||
| 14809 | $loadHash{'world_model_obj'} | ||
| 14810 | = $self->update_obj_world_model($loadHash{'world_model_obj'}); | ||
| 14811 | } | ||
| 14812 | |||
| 14813 | } elsif ($self->fileType eq 'tasks') { | ||
| 14814 | |||
| 14815 | # no update required for 'task_label_hash' | ||
| 14816 | # no update required for 'task_run_first_list' | ||
| 14817 | # no update required for 'task_run_last_list' | ||
| 14818 | |||
| 14819 | if (exists $loadHash{'init_task_hash'}) { | ||
| 14820 | |||
| 14821 | $hashRef = $loadHash{'init_task_hash'}; | ||
| 14822 | foreach my $key (keys %$hashRef) { | ||
| 14823 | |||
| 14824 | $$hashRef{$key} = $self->update_task_all($$hashRef{$key}); | ||
| 14825 | } | ||
| 14826 | |||
| 14827 | $loadHash{'init_task_hash'} = $hashRef; | ||
| 14828 | } | ||
| 14829 | |||
| 14830 | # no update required for 'init_task_order_list' | ||
| 14831 | # no update required for 'init_task_total' | ||
| 14832 | |||
| 14833 | if (exists $loadHash{'custom_task_hash'}) { | ||
| 14834 | |||
| 14835 | $hashRef = $loadHash{'custom_task_hash'}; | ||
| 14836 | foreach my $key (keys %$hashRef) { | ||
| 14837 | |||
| 14838 | $$hashRef{$key} = $self->update_task_all($$hashRef{$key}); | ||
| 14839 | } | ||
| 14840 | |||
| 14841 | $loadHash{'custom_task_hash'} = $hashRef; | ||
| 14842 | } | ||
| 14843 | |||
| 14844 | } elsif ($self->fileType eq 'scripts') { | ||
| 14845 | |||
| 14846 | # no update required for 'script_dir_list' | ||
| 14847 | # no update required for 'init_script_hash' | ||
| 14848 | # no update required for 'init_script_order_list' | ||
| 14849 | |||
| 14850 | } elsif ($self->fileType eq 'contacts') { | ||
| 14851 | |||
| 14852 | # no update required for 'chat_name' | ||
| 14853 | # no update required for 'chat_email' | ||
| 14854 | # no update required for 'chat_accept_mode' | ||
| 14855 | |||
| 14856 | if (exists $loadHash{'chat_contact_hash'}) { | ||
| 14857 | |||
| 14858 | $hashRef = $loadHash{'chat_contact_hash'}; | ||
| 14859 | foreach my $key (keys %$hashRef) { | ||
| 14860 | |||
| 14861 | $$hashRef{$key} = $self->update_obj_chat_contact($$hashRef{$key}); | ||
| 14862 | } | ||
| 14863 | |||
| 14864 | $loadHash{'chat_contact_hash'} = $hashRef; | ||
| 14865 | } | ||
| 14866 | |||
| 14867 | # no update required for 'chat_icon' | ||
| 14868 | # no update required for 'chat_smiley_hash' | ||
| 14869 | |||
| 14870 | } elsif ($self->fileType eq 'dicts') { | ||
| 14871 | |||
| 14872 | if (exists $loadHash{'dict_hash'}) { | ||
| 14873 | |||
| 14874 | $hashRef = $loadHash{'dict_hash'}; | ||
| 14875 | foreach my $key (keys %$hashRef) { | ||
| 14876 | |||
| 14877 | $$hashRef{$key} = $self->update_obj_dict($$hashRef{$key}); | ||
| 14878 | } | ||
| 14879 | |||
| 14880 | $loadHash{'dict_hash'} = $hashRef; | ||
| 14881 | } | ||
| 14882 | |||
| 14883 | } elsif ($self->fileType eq 'toolbar') { | ||
| 14884 | |||
| 14885 | if (exists $loadHash{'toolbar_hash'}) { | ||
| 14886 | |||
| 14887 | $hashRef = $loadHash{'toolbar_hash'}; | ||
| 14888 | foreach my $key (keys %$hashRef) { | ||
| 14889 | |||
| 14890 | $$hashRef{$key} = $self->update_obj_toolbar($$hashRef{$key}); | ||
| 14891 | } | ||
| 14892 | |||
| 14893 | $loadHash{'toolbar_hash'} = $hashRef; | ||
| 14894 | } | ||
| 14895 | |||
| 14896 | # no update required for 'toolbar_list' | ||
| 14897 | |||
| 14898 | } elsif ($self->fileType eq 'usercmds') { | ||
| 14899 | |||
| 14900 | # no update required for 'user_cmd_hash' | ||
| 14901 | |||
| 14902 | } elsif ($self->fileType eq 'zonemaps') { | ||
| 14903 | |||
| 14904 | if (exists $loadHash{'zonemap_hash'}) { | ||
| 14905 | |||
| 14906 | $hashRef = $loadHash{'zonemap_hash'}; | ||
| 14907 | foreach my $key (keys %$hashRef) { | ||
| 14908 | |||
| 14909 | $$hashRef{$key} = $self->update_obj_zonemap($$hashRef{$key}); | ||
| 14910 | } | ||
| 14911 | |||
| 14912 | $loadHash{'zonemap_hash'} = $hashRef; | ||
| 14913 | } | ||
| 14914 | |||
| 14915 | # ($subHashRef represents a subset of key-value pairs in $hashRef) | ||
| 14916 | if (exists $loadHash{'standard_zonemap_hash'}) { | ||
| 14917 | |||
| 14918 | $subHashRef = $loadHash{'standard_zonemap_hash'}; | ||
| 14919 | foreach my $key (keys %$subHashRef) { | ||
| 14920 | |||
| 14921 | # If the zonemap is missing from GA::Client->zonemapHash (for some reason), | ||
| 14922 | # don't let it be added to GA::Client->standardZonemapHash | ||
| 14923 | if (exists $$hashRef{$key}) { | ||
| 14924 | |||
| 14925 | $$subHashRef{$key} = $$hashRef{$key}; | ||
| 14926 | } | ||
| 14927 | } | ||
| 14928 | |||
| 14929 | $loadHash{'standard_zonemap_hash'} = $subHashRef; | ||
| 14930 | } | ||
| 14931 | |||
| 14932 | } elsif ($self->fileType eq 'winmaps') { | ||
| 14933 | |||
| 14934 | if (exists $loadHash{'winmap_hash'}) { | ||
| 14935 | |||
| 14936 | $hashRef = $loadHash{'winmap_hash'}; | ||
| 14937 | foreach my $key (keys %$hashRef) { | ||
| 14938 | |||
| 14939 | $$hashRef{$key} = $self->update_obj_winmap($$hashRef{$key}); | ||
| 14940 | } | ||
| 14941 | |||
| 14942 | $loadHash{'winmap_hash'} = $hashRef; | ||
| 14943 | } | ||
| 14944 | |||
| 14945 | # ($subHashRef represents a subset of key-value pairs in $hashRef) | ||
| 14946 | if (exists $loadHash{'standard_winmap_hash'}) { | ||
| 14947 | |||
| 14948 | $subHashRef = $loadHash{'standard_winmap_hash'}; | ||
| 14949 | foreach my $key (keys %$subHashRef) { | ||
| 14950 | |||
| 14951 | # If the winmap is missing from GA::Client->winmapHash (for some reason), | ||
| 14952 | # don't let it be added to GA::Client->standardWinmapHash | ||
| 14953 | if (exists $$hashRef{$key}) { | ||
| 14954 | |||
| 14955 | $$subHashRef{$key} = $$hashRef{$key}; | ||
| 14956 | } | ||
| 14957 | } | ||
| 14958 | |||
| 14959 | $loadHash{'standard_winmap_hash'} = $subHashRef; | ||
| 14960 | } | ||
| 14961 | |||
| 14962 | if (exists $loadHash{'colour_scheme_hash'}) { | ||
| 14963 | |||
| 14964 | $hashRef = $loadHash{'colour_scheme_hash'}; | ||
| 14965 | foreach my $key (keys %$hashRef) { | ||
| 14966 | |||
| 14967 | $$hashRef{$key} = $self->update_obj_colourscheme($$hashRef{$key}); | ||
| 14968 | } | ||
| 14969 | |||
| 14970 | $loadHash{'colour_scheme_hash'} = $hashRef; | ||
| 14971 | } | ||
| 14972 | |||
| 14973 | } elsif ($self->fileType eq 'tts') { | ||
| 14974 | |||
| 14975 | if (exists $loadHash{'tts_obj_hash'}) { | ||
| 14976 | |||
| 14977 | $hashRef = $loadHash{'tts_obj_hash'}; | ||
| 14978 | foreach my $key (keys %$hashRef) { | ||
| 14979 | |||
| 14980 | $$hashRef{$key} = $self->update_obj_tts($$hashRef{$key}); | ||
| 14981 | } | ||
| 14982 | |||
| 14983 | $loadHash{'tts_obj_hash'} = $hashRef; | ||
| 14984 | } | ||
| 14985 | } | ||
| 14986 | |||
| 14987 | # Mark this data file as needing to be saved, whether the data it contains has actually been | ||
| 14988 | # updated or not | ||
| 14989 | $self->ivPoke('modifyFlag', TRUE); | ||
| 14990 | |||
| 14991 | return %loadHash; | ||
| 14992 | } | ||
| 14993 | |||
| 14994 | sub update_cage_all { | ||
| 14995 | |||
| 14996 | # Called by $self->updateDataAfterRename | ||
| 14997 | # Converts AMud::Templ::XXX > Games::Axmud::Cage::XXX | ||
| 14998 | # Converts AMud::MaskTempl::XXX > Games::Axmud::CageMask::XXX | ||
| 14999 | |||
| 15000 | my ($self, $obj) = @_; | ||
| 15001 | |||
| 15002 | # Local variables | ||
| 15003 | my ($class, $flag, $hashRef); | ||
| 15004 | |||
| 15005 | # (no improper arguments to check) | ||
| 15006 | |||
| 15007 | # Update class | ||
| 15008 | $class = ref $obj; | ||
| 15009 | if ($class =~ m/^AMud\:\:Templ\:\:/) { | ||
| 15010 | |||
| 15011 | $class =~ s/^AMud\:\:Templ/Games::Axmud::Cage/; | ||
| 15012 | $flag = TRUE; | ||
| 15013 | |||
| 15014 | } elsif ($class =~ m/^AMud\:\:MaskTempl\:\:/) { | ||
| 15015 | |||
| 15016 | $class =~ s/^AMud\:\:MaskTempl/Games::Axmud::CageMask/; | ||
| 15017 | $flag = TRUE; | ||
| 15018 | } | ||
| 15019 | |||
| 15020 | # Updated ->_objName | ||
| 15021 | $obj->{_objName} = $obj->{_name}; | ||
| 15022 | delete $obj->{_name}; | ||
| 15023 | |||
| 15024 | if ($flag) { | ||
| 15025 | |||
| 15026 | bless $obj, $class; | ||
| 15027 | $obj->{_objClass} = $class; | ||
| 15028 | |||
| 15029 | $obj->{_objName} = $obj->{_name}; | ||
| 15030 | delete $obj->{_name}; | ||
| 15031 | |||
| 15032 | # (->_parentFile is 'otherprof') | ||
| 15033 | if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') { | ||
| 15034 | |||
| 15035 | $obj->{_parentFile} = 'otherprof'; | ||
| 15036 | } | ||
| 15037 | |||
| 15038 | # Update IVs | ||
| 15039 | if ($class =~ m/Route$/) { | ||
| 15040 | |||
| 15041 | $hashRef = $obj->{routeHash}; | ||
| 15042 | foreach my $key (keys %$hashRef) { | ||
| 15043 | |||
| 15044 | $$hashRef{$key} = $self->update_obj_route($$hashRef{$key}); | ||
| 15045 | } | ||
| 15046 | |||
| 15047 | $obj->{routeHash} = $hashRef; | ||
| 15048 | |||
| 15049 | } elsif ($class =~ m/(Trigger|Alias|Macro|Timer|Hook)$/) { | ||
| 15050 | |||
| 15051 | $hashRef = $obj->{interfaceHash}; | ||
| 15052 | foreach my $key (keys %$hashRef) { | ||
| 15053 | |||
| 15054 | $$hashRef{$key} = $self->update_interface_all($$hashRef{$key}); | ||
| 15055 | } | ||
| 15056 | |||
| 15057 | $obj->{interfaceHash} = $hashRef; | ||
| 15058 | } | ||
| 15059 | |||
| 15060 | $obj->{cageType} = $obj->{templType}; | ||
| 15061 | delete $obj->{templType}; | ||
| 15062 | |||
| 15063 | $obj->{profName} = $obj->{defnName}; | ||
| 15064 | delete $obj->{defnName}; | ||
| 15065 | |||
| 15066 | $obj->{profCategory} = $obj->{defnCategory}; | ||
| 15067 | delete $obj->{defnCategory}; | ||
| 15068 | |||
| 15069 | # Update @ISA | ||
| 15070 | if ($class =~ m/(Cmd|Route)$/) { | ||
| 15071 | |||
| 15072 | @obj::ISA = qw(Games::Axmud::Generic::Cage Games::Axmud); | ||
| 15073 | |||
| 15074 | } else { | ||
| 15075 | |||
| 15076 | @obj::ISA = qw( | ||
| 15077 | Games::Axmud::Generic::InterfaceCage Games::Axmud::Generic::Cage | ||
| 15078 | Games::Axmud | ||
| 15079 | ); | ||
| 15080 | } | ||
| 15081 | } | ||
| 15082 | |||
| 15083 | return $obj; | ||
| 15084 | } | ||
| 15085 | |||
| 15086 | sub update_interface_all { | ||
| 15087 | |||
| 15088 | # Called by $self->updateDataAfterRename | ||
| 15089 | # Converts AMud::Interface::XXX > Games::Axmud::Interface:::XXX | ||
| 15090 | |||
| 15091 | my ($self, $obj) = @_; | ||
| 15092 | |||
| 15093 | # Local variables | ||
| 15094 | my $class; | ||
| 15095 | |||
| 15096 | # (no improper arguments to check) | ||
| 15097 | |||
| 15098 | # Update class | ||
| 15099 | $class = ref $obj; | ||
| 15100 | if ($class =~ m/^AMud\:\:Interface\:\:/) { | ||
| 15101 | |||
| 15102 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15103 | bless $obj, $class; | ||
| 15104 | $obj->{_objClass} = $class; | ||
| 15105 | |||
| 15106 | $obj->{_objName} = $obj->{_name}; | ||
| 15107 | delete $obj->{_name}; | ||
| 15108 | |||
| 15109 | # (->_parentFile is 'undef') | ||
| 15110 | |||
| 15111 | # Update IVs | ||
| 15112 | $obj->{assocProf} = $obj->{assocDefn}; | ||
| 15113 | delete $obj->{assocDefn}; | ||
| 15114 | |||
| 15115 | $obj->{assocProfCategory} = $obj->{assocDefnCategory}; | ||
| 15116 | delete $obj->{assocDefnCategory}; | ||
| 15117 | |||
| 15118 | # Update @ISA | ||
| 15119 | @obj::ISA = qw(Games::Axmud::Generic::Interface Games::Axmud); | ||
| 15120 | } | ||
| 15121 | |||
| 15122 | return $obj; | ||
| 15123 | } | ||
| 15124 | |||
| 15125 | sub update_modelobj_all { | ||
| 15126 | |||
| 15127 | # Called by $self->updateDataAfterRename | ||
| 15128 | # Converts AMud::ModelObj::Region > Games::Axmud::ModelObj::Region, etc | ||
| 15129 | |||
| 15130 | my ($self, $obj) = @_; | ||
| 15131 | |||
| 15132 | # Local variables | ||
| 15133 | my $class; | ||
| 15134 | |||
| 15135 | # (no improper arguments to check) | ||
| 15136 | |||
| 15137 | # Update class | ||
| 15138 | $class = ref $obj; | ||
| 15139 | if ($class =~ m/^AMud\:\:ModelObj\:\:/) { | ||
| 15140 | |||
| 15141 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15142 | bless $obj, $class; | ||
| 15143 | $obj->{_objClass} = $class; | ||
| 15144 | |||
| 15145 | $obj->{_objName} = $obj->{_name}; | ||
| 15146 | delete $obj->{_name}; | ||
| 15147 | |||
| 15148 | # (->_parentFile is 'undef' or 'worldmodel') | ||
| 15149 | |||
| 15150 | # (No IVs to update) | ||
| 15151 | # Games::Axmud::ModelObj::Region->regionmapObj is handled by ->update_obj_world_model | ||
| 15152 | |||
| 15153 | # Update @ISA | ||
| 15154 | @obj::ISA = qw(Games::Axmud); | ||
| 15155 | } | ||
| 15156 | |||
| 15157 | return $obj; | ||
| 15158 | } | ||
| 15159 | |||
| 15160 | sub update_obj_chat_contact { | ||
| 15161 | |||
| 15162 | # Called by $self->updateDataAfterRename | ||
| 15163 | # Converts AMud::Obj::ChatContact > Games::Axmud::Obj::ChatContact | ||
| 15164 | |||
| 15165 | my ($self, $obj) = @_; | ||
| 15166 | |||
| 15167 | # Local variables | ||
| 15168 | my $class; | ||
| 15169 | |||
| 15170 | # (no improper arguments to check) | ||
| 15171 | |||
| 15172 | # Update class | ||
| 15173 | $class = ref $obj; | ||
| 15174 | if ($class =~ m/^AMud\:\:Obj\:\:ChatContact/) { | ||
| 15175 | |||
| 15176 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15177 | bless $obj, $class; | ||
| 15178 | $obj->{_objClass} = $class; | ||
| 15179 | |||
| 15180 | $obj->{_objName} = $obj->{_name}; | ||
| 15181 | delete $obj->{_name}; | ||
| 15182 | |||
| 15183 | # (->_parentFile is 'contacts') | ||
| 15184 | |||
| 15185 | # (No IVs to update) | ||
| 15186 | |||
| 15187 | # Update @ISA | ||
| 15188 | @obj::ISA = qw(Games::Axmud); | ||
| 15189 | } | ||
| 15190 | |||
| 15191 | return $obj; | ||
| 15192 | } | ||
| 15193 | |||
| 15194 | sub update_obj_component { | ||
| 15195 | |||
| 15196 | # Called by $self->updateDataAfterRename | ||
| 15197 | # Converts AMud::Obj::Component > Games::Axmud::Obj::Component | ||
| 15198 | |||
| 15199 | my ($self, $obj) = @_; | ||
| 15200 | |||
| 15201 | # Local variables | ||
| 15202 | my $class; | ||
| 15203 | |||
| 15204 | # (no improper arguments to check) | ||
| 15205 | |||
| 15206 | # Update class | ||
| 15207 | $class = ref $obj; | ||
| 15208 | if ($class =~ m/^AMud\:\:Obj\:\:Component/) { | ||
| 15209 | |||
| 15210 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15211 | bless $obj, $class; | ||
| 15212 | $obj->{_objClass} = $class; | ||
| 15213 | |||
| 15214 | $obj->{_objName} = $obj->{_name}; | ||
| 15215 | delete $obj->{_name}; | ||
| 15216 | |||
| 15217 | # (->_parentFile is world name) | ||
| 15218 | |||
| 15219 | # (No IVs to update) | ||
| 15220 | |||
| 15221 | # Update @ISA | ||
| 15222 | @obj::ISA = qw(Games::Axmud); | ||
| 15223 | } | ||
| 15224 | |||
| 15225 | return $obj; | ||
| 15226 | } | ||
| 15227 | |||
| 15228 | sub update_obj_colourscheme { | ||
| 15229 | |||
| 15230 | # Called by $self->updateDataAfterRename | ||
| 15231 | # Converts AMud::Obj::ColourScheme > Games::Axmud::Obj::ColourScheme | ||
| 15232 | |||
| 15233 | my ($self, $obj) = @_; | ||
| 15234 | |||
| 15235 | # Local variables | ||
| 15236 | my $class; | ||
| 15237 | |||
| 15238 | # (no improper arguments to check) | ||
| 15239 | |||
| 15240 | # Update class | ||
| 15241 | $class = ref $obj; | ||
| 15242 | if ($class =~ m/^AMud\:\:Obj\:\:ColourScheme/) { | ||
| 15243 | |||
| 15244 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15245 | bless $obj, $class; | ||
| 15246 | $obj->{_objClass} = $class; | ||
| 15247 | |||
| 15248 | $obj->{_objName} = $obj->{_name}; | ||
| 15249 | delete $obj->{_name}; | ||
| 15250 | |||
| 15251 | # (->_parentFile is 'winmaps') | ||
| 15252 | |||
| 15253 | # (No IVs to update) | ||
| 15254 | |||
| 15255 | # Update @ISA | ||
| 15256 | @obj::ISA = qw(Games::Axmud); | ||
| 15257 | } | ||
| 15258 | |||
| 15259 | return $obj; | ||
| 15260 | } | ||
| 15261 | |||
| 15262 | sub update_obj_dict { | ||
| 15263 | |||
| 15264 | # Called by $self->updateDataAfterRename (and also by GA::Client->copyPreConfigWorlds) | ||
| 15265 | # Converts AMud::Obj::Dict > Games::Axmud::Obj::Dict | ||
| 15266 | |||
| 15267 | my ($self, $obj) = @_; | ||
| 15268 | |||
| 15269 | # Local variables | ||
| 15270 | my $class; | ||
| 15271 | |||
| 15272 | # (no improper arguments to check) | ||
| 15273 | |||
| 15274 | # Update class | ||
| 15275 | $class = ref $obj; | ||
| 15276 | if ($class =~ m/^AMud\:\:Obj\:\:Dict/) { | ||
| 15277 | |||
| 15278 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15279 | bless $obj, $class; | ||
| 15280 | $obj->{_objClass} = $class; | ||
| 15281 | |||
| 15282 | $obj->{_objName} = $obj->{_name}; | ||
| 15283 | delete $obj->{_name}; | ||
| 15284 | |||
| 15285 | # (->_parentFile is 'dicts') | ||
| 15286 | |||
| 15287 | # (No IVs to update) | ||
| 15288 | |||
| 15289 | # Update @ISA | ||
| 15290 | @obj::ISA = qw(Games::Axmud); | ||
| 15291 | } | ||
| 15292 | |||
| 15293 | return $obj; | ||
| 15294 | } | ||
| 15295 | |||
| 15296 | sub update_obj_exit { | ||
| 15297 | |||
| 15298 | # Called by $self->updateDataAfterRename | ||
| 15299 | # Converts AMud::Obj::Exit > Games::Axmud::Obj::Exit | ||
| 15300 | |||
| 15301 | my ($self, $obj) = @_; | ||
| 15302 | |||
| 15303 | # Local variables | ||
| 15304 | my $class; | ||
| 15305 | |||
| 15306 | # (no improper arguments to check) | ||
| 15307 | |||
| 15308 | # Update class | ||
| 15309 | $class = ref $obj; | ||
| 15310 | if ($class =~ m/^AMud\:\:Obj\:\:Exit/) { | ||
| 15311 | |||
| 15312 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15313 | bless $obj, $class; | ||
| 15314 | $obj->{_objClass} = $class; | ||
| 15315 | |||
| 15316 | $obj->{_objName} = $obj->{_name}; | ||
| 15317 | delete $obj->{_name}; | ||
| 15318 | |||
| 15319 | # (->_parentFile is 'undef' or 'worldmodel') | ||
| 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_maplabel { | ||
| 15331 | |||
| 15332 | # Called by $self->updateDataAfterRename | ||
| 15333 | # Converts AMud::Obj::MapLabel > Games::Axmud::Obj::MapLabel | ||
| 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\:\:MapLabel/) { | ||
| 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 'worldmodel') | ||
| 15354 | |||
| 15355 | # (No IVs to update) | ||
| 15356 | |||
| 15357 | # Update @ISA | ||
| 15358 | @obj::ISA = qw(Games::Axmud); | ||
| 15359 | } | ||
| 15360 | |||
| 15361 | return $obj; | ||
| 15362 | } | ||
| 15363 | |||
| 15364 | sub update_obj_mission { | ||
| 15365 | |||
| 15366 | # Called by $self->updateDataAfterRename | ||
| 15367 | # Converts AMud::Obj::Mission > Games::Axmud::Obj::Mission | ||
| 15368 | |||
| 15369 | my ($self, $obj) = @_; | ||
| 15370 | |||
| 15371 | # Local variables | ||
| 15372 | my $class; | ||
| 15373 | |||
| 15374 | # (no improper arguments to check) | ||
| 15375 | |||
| 15376 | # Update class | ||
| 15377 | $class = ref $obj; | ||
| 15378 | if ($class =~ m/^AMud\:\:Obj\:\:Mission/) { | ||
| 15379 | |||
| 15380 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15381 | bless $obj, $class; | ||
| 15382 | $obj->{_objClass} = $class; | ||
| 15383 | |||
| 15384 | $obj->{_objName} = $obj->{_name}; | ||
| 15385 | delete $obj->{_name}; | ||
| 15386 | |||
| 15387 | # (->_parentFile is world name) | ||
| 15388 | |||
| 15389 | # (No IVs to update) | ||
| 15390 | |||
| 15391 | # Update @ISA | ||
| 15392 | @obj::ISA = qw(Games::Axmud); | ||
| 15393 | } | ||
| 15394 | |||
| 15395 | return $obj; | ||
| 15396 | } | ||
| 15397 | |||
| 15398 | sub update_obj_monitor { | ||
| 15399 | |||
| 15400 | # Called by $self->updateDataAfterRename | ||
| 15401 | # Converts AMud::Obj::Monitor > Games::Axmud::Obj::Monitor | ||
| 15402 | |||
| 15403 | my ($self, $obj) = @_; | ||
| 15404 | |||
| 15405 | # Local variables | ||
| 15406 | my $class; | ||
| 15407 | |||
| 15408 | # (no improper arguments to check) | ||
| 15409 | |||
| 15410 | # Update class | ||
| 15411 | $class = ref $obj; | ||
| 15412 | if ($class =~ m/^AMud\:\:Obj\:\:Monitor/) { | ||
| 15413 | |||
| 15414 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15415 | bless $obj, $class; | ||
| 15416 | $obj->{_objClass} = $class; | ||
| 15417 | |||
| 15418 | $obj->{_objName} = $obj->{_name}; | ||
| 15419 | delete $obj->{_name}; | ||
| 15420 | |||
| 15421 | # (->_parentFile is 'otherprof') | ||
| 15422 | if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') { | ||
| 15423 | |||
| 15424 | $obj->{_parentFile} = 'otherprof'; | ||
| 15425 | } | ||
| 15426 | |||
| 15427 | # (No IVs to update) | ||
| 15428 | |||
| 15429 | # Update @ISA | ||
| 15430 | @obj::ISA = qw(Games::Axmud); | ||
| 15431 | } | ||
| 15432 | |||
| 15433 | return $obj; | ||
| 15434 | } | ||
| 15435 | |||
| 15436 | sub update_obj_protect { | ||
| 15437 | |||
| 15438 | # Called by $self->updateDataAfterRename | ||
| 15439 | # Converts AMud::Obj::Protect > Games::Axmud::Obj::Protect | ||
| 15440 | |||
| 15441 | my ($self, $obj) = @_; | ||
| 15442 | |||
| 15443 | # Local variables | ||
| 15444 | my $class; | ||
| 15445 | |||
| 15446 | # (no improper arguments to check) | ||
| 15447 | |||
| 15448 | # Update class | ||
| 15449 | $class = ref $obj; | ||
| 15450 | if ($class =~ m/^AMud\:\:Obj\:\:Protect/) { | ||
| 15451 | |||
| 15452 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15453 | bless $obj, $class; | ||
| 15454 | $obj->{_objClass} = $class; | ||
| 15455 | |||
| 15456 | $obj->{_objName} = $obj->{_name}; | ||
| 15457 | delete $obj->{_name}; | ||
| 15458 | |||
| 15459 | # (->_parentFile is 'otherprof') | ||
| 15460 | if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') { | ||
| 15461 | |||
| 15462 | $obj->{_parentFile} = 'otherprof'; | ||
| 15463 | } | ||
| 15464 | |||
| 15465 | # (No IVs to update) | ||
| 15466 | |||
| 15467 | # Update @ISA | ||
| 15468 | @obj::ISA = qw(Games::Axmud); | ||
| 15469 | } | ||
| 15470 | |||
| 15471 | return $obj; | ||
| 15472 | } | ||
| 15473 | |||
| 15474 | sub update_obj_quest { | ||
| 15475 | |||
| 15476 | # Called by $self->updateDataAfterRename | ||
| 15477 | # Converts AMud::Obj::Quest > Games::Axmud::Obj::Quest | ||
| 15478 | |||
| 15479 | my ($self, $obj) = @_; | ||
| 15480 | |||
| 15481 | # Local variables | ||
| 15482 | my $class; | ||
| 15483 | |||
| 15484 | # (no improper arguments to check) | ||
| 15485 | |||
| 15486 | # Update class | ||
| 15487 | $class = ref $obj; | ||
| 15488 | if ($class =~ m/^AMud\:\:Obj\:\:Quest/) { | ||
| 15489 | |||
| 15490 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15491 | bless $obj, $class; | ||
| 15492 | $obj->{_objClass} = $class; | ||
| 15493 | |||
| 15494 | $obj->{_objName} = $obj->{_name}; | ||
| 15495 | delete $obj->{_name}; | ||
| 15496 | |||
| 15497 | # (->_parentFile is world name) | ||
| 15498 | |||
| 15499 | # (No IVs to update) | ||
| 15500 | |||
| 15501 | # Update @ISA | ||
| 15502 | @obj::ISA = qw(Games::Axmud); | ||
| 15503 | } | ||
| 15504 | |||
| 15505 | return $obj; | ||
| 15506 | } | ||
| 15507 | |||
| 15508 | sub update_obj_regionmap { | ||
| 15509 | |||
| 15510 | # Called by $self->updateDataAfterRename | ||
| 15511 | # Converts AMud::Obj::Regionmap > Games::Axmud::Obj::Regionmap | ||
| 15512 | |||
| 15513 | my ($self, $obj) = @_; | ||
| 15514 | |||
| 15515 | # Local variables | ||
| 15516 | my ($class, $hashRef, $pathHashRef); | ||
| 15517 | |||
| 15518 | # (no improper arguments to check) | ||
| 15519 | |||
| 15520 | # Update class | ||
| 15521 | $class = ref $obj; | ||
| 15522 | if ($class =~ m/^AMud\:\:Obj\:\:Regionmap/) { | ||
| 15523 | |||
| 15524 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15525 | bless $obj, $class; | ||
| 15526 | $obj->{_objClass} = $class; | ||
| 15527 | |||
| 15528 | $obj->{_objName} = $obj->{_name}; | ||
| 15529 | delete $obj->{_name}; | ||
| 15530 | |||
| 15531 | # (->_parentFile is 'worldmodel') | ||
| 15532 | |||
| 15533 | # Update IVs | ||
| 15534 | $hashRef = $obj->{gridLabelHash}; | ||
| 15535 | foreach my $key (keys %$hashRef) { | ||
| 15536 | |||
| 15537 | $$hashRef{$key} = $self->update_obj_maplabel($$hashRef{$key}); | ||
| 15538 | } | ||
| 15539 | |||
| 15540 | $obj->{gridLabelHash} = $hashRef; | ||
| 15541 | |||
| 15542 | $pathHashRef = $obj->{regionPathHash}; | ||
| 15543 | foreach my $key (keys %$pathHashRef) { | ||
| 15544 | |||
| 15545 | $$pathHashRef{$key} = $self->update_obj_regionpath($$pathHashRef{$key}); | ||
| 15546 | } | ||
| 15547 | |||
| 15548 | $obj->{regionPathHash} = $pathHashRef; | ||
| 15549 | |||
| 15550 | $hashRef = $obj->{safeRegionPathHash}; | ||
| 15551 | foreach my $key (keys %$hashRef) { | ||
| 15552 | |||
| 15553 | $$hashRef{$key} = $$pathHashRef{$key}; | ||
| 15554 | } | ||
| 15555 | |||
| 15556 | $obj->{safeRegionPathHash} = $pathHashRef; | ||
| 15557 | |||
| 15558 | # Update @ISA | ||
| 15559 | @obj::ISA = qw(Games::Axmud); | ||
| 15560 | } | ||
| 15561 | |||
| 15562 | return $obj; | ||
| 15563 | } | ||
| 15564 | |||
| 15565 | sub update_obj_regionpath { | ||
| 15566 | |||
| 15567 | # Called by $self->updateDataAfterRename | ||
| 15568 | # Converts AMud::Obj::RegionPath > Games::Axmud::Obj::RegionPath | ||
| 15569 | |||
| 15570 | my ($self, $obj) = @_; | ||
| 15571 | |||
| 15572 | # Local variables | ||
| 15573 | my $class; | ||
| 15574 | |||
| 15575 | # (no improper arguments to check) | ||
| 15576 | |||
| 15577 | # Update class | ||
| 15578 | $class = ref $obj; | ||
| 15579 | if ($class =~ m/^AMud\:\:Obj\:\:RegionPath/) { | ||
| 15580 | |||
| 15581 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15582 | bless $obj, $class; | ||
| 15583 | $obj->{_objClass} = $class; | ||
| 15584 | |||
| 15585 | $obj->{_objName} = $obj->{_name}; | ||
| 15586 | delete $obj->{_name}; | ||
| 15587 | |||
| 15588 | # (->_parentFile is 'worldmodel') | ||
| 15589 | |||
| 15590 | # (No IVs to update) | ||
| 15591 | |||
| 15592 | # Update @ISA | ||
| 15593 | @obj::ISA = qw(Games::Axmud); | ||
| 15594 | } | ||
| 15595 | |||
| 15596 | return $obj; | ||
| 15597 | } | ||
| 15598 | |||
| 15599 | sub update_obj_route { | ||
| 15600 | |||
| 15601 | # Called by $self->updateDataAfterRename | ||
| 15602 | # Converts AMud::Obj::Route > Games::Axmud::Obj::Route | ||
| 15603 | |||
| 15604 | my ($self, $obj) = @_; | ||
| 15605 | |||
| 15606 | # Local variables | ||
| 15607 | my $class; | ||
| 15608 | |||
| 15609 | # (no improper arguments to check) | ||
| 15610 | |||
| 15611 | # Update class | ||
| 15612 | $class = ref $obj; | ||
| 15613 | if ($class =~ m/^AMud\:\:Obj\:\:Route/) { | ||
| 15614 | |||
| 15615 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15616 | bless $obj, $class; | ||
| 15617 | $obj->{_objClass} = $class; | ||
| 15618 | |||
| 15619 | $obj->{_objName} = $obj->{_name}; | ||
| 15620 | delete $obj->{_name}; | ||
| 15621 | |||
| 15622 | # (->_parentFile is 'otherprof') | ||
| 15623 | if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') { | ||
| 15624 | |||
| 15625 | $obj->{_parentFile} = 'otherprof'; | ||
| 15626 | } | ||
| 15627 | |||
| 15628 | # (No IVs to update) | ||
| 15629 | |||
| 15630 | # Update @ISA | ||
| 15631 | @obj::ISA = qw(Games::Axmud); | ||
| 15632 | } | ||
| 15633 | |||
| 15634 | return $obj; | ||
| 15635 | } | ||
| 15636 | |||
| 15637 | sub update_obj_skillhistory { | ||
| 15638 | |||
| 15639 | # Called by $self->updateDataAfterRename | ||
| 15640 | # Converts AMud::Obj::SkillHistory > Games::Axmud::Obj::SkillHistory | ||
| 15641 | |||
| 15642 | my ($self, $obj) = @_; | ||
| 15643 | |||
| 15644 | # Local variables | ||
| 15645 | my $class; | ||
| 15646 | |||
| 15647 | # (no improper arguments to check) | ||
| 15648 | |||
| 15649 | # Update class | ||
| 15650 | $class = ref $obj; | ||
| 15651 | if ($class =~ m/^AMud\:\:Obj\:\:SkillHistory/) { | ||
| 15652 | |||
| 15653 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15654 | bless $obj, $class; | ||
| 15655 | $obj->{_objClass} = $class; | ||
| 15656 | |||
| 15657 | $obj->{_objName} = $obj->{_name}; | ||
| 15658 | delete $obj->{_name}; | ||
| 15659 | |||
| 15660 | # (->_parentFile is 'otherprof') | ||
| 15661 | if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') { | ||
| 15662 | |||
| 15663 | $obj->{_parentFile} = 'otherprof'; | ||
| 15664 | } | ||
| 15665 | |||
| 15666 | # (No IVs to update) | ||
| 15667 | |||
| 15668 | # Update @ISA | ||
| 15669 | @obj::ISA = qw(Games::Axmud); | ||
| 15670 | } | ||
| 15671 | |||
| 15672 | return $obj; | ||
| 15673 | } | ||
| 15674 | |||
| 15675 | sub update_obj_toolbar { | ||
| 15676 | |||
| 15677 | # Called by $self->updateDataAfterRename | ||
| 15678 | # Converts AMud::Obj::Toolbar > Games::Axmud::Obj::Toolbar | ||
| 15679 | |||
| 15680 | my ($self, $obj) = @_; | ||
| 15681 | |||
| 15682 | # Local variables | ||
| 15683 | my ($class, $instruct); | ||
| 15684 | |||
| 15685 | # (no improper arguments to check) | ||
| 15686 | |||
| 15687 | # Update class | ||
| 15688 | $class = ref $obj; | ||
| 15689 | if ($class =~ m/^AMud\:\:Obj\:\:Toolbar/) { | ||
| 15690 | |||
| 15691 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15692 | bless $obj, $class; | ||
| 15693 | $obj->{_objClass} = $class; | ||
| 15694 | |||
| 15695 | $obj->{_objName} = $obj->{_name}; | ||
| 15696 | delete $obj->{_name}; | ||
| 15697 | |||
| 15698 | # (->_parentFile is 'toolbar') | ||
| 15699 | |||
| 15700 | # Update IVs. Many ->instruct values are client commands; convert any client commands | ||
| 15701 | # that are used with a default Axmud installation | ||
| 15702 | $instruct = $obj->{instruct}; | ||
| 15703 | $instruct =~ s/^\;edittemplate\s/;editcage/; | ||
| 15704 | $obj->{instruct} = $instruct; | ||
| 15705 | |||
| 15706 | # Update @ISA | ||
| 15707 | @obj::ISA = qw(Games::Axmud); | ||
| 15708 | } | ||
| 15709 | |||
| 15710 | return $obj; | ||
| 15711 | } | ||
| 15712 | |||
| 15713 | sub update_obj_tts { | ||
| 15714 | |||
| 15715 | # Called by $self->updateDataAfterRename | ||
| 15716 | # Converts AMud::Obj::Tts > Games::Axmud::Obj::Tts | ||
| 15717 | |||
| 15718 | my ($self, $obj) = @_; | ||
| 15719 | |||
| 15720 | # Local variables | ||
| 15721 | my $class; | ||
| 15722 | |||
| 15723 | # (no improper arguments to check) | ||
| 15724 | |||
| 15725 | # Update class | ||
| 15726 | $class = ref $obj; | ||
| 15727 | if ($class =~ m/^AMud\:\:Obj\:\:Tts/) { | ||
| 15728 | |||
| 15729 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15730 | bless $obj, $class; | ||
| 15731 | $obj->{_objClass} = $class; | ||
| 15732 | |||
| 15733 | $obj->{_objName} = $obj->{_name}; | ||
| 15734 | delete $obj->{_name}; | ||
| 15735 | |||
| 15736 | # (->_parentFile is 'tts') | ||
| 15737 | |||
| 15738 | # (No IVs to update) | ||
| 15739 | |||
| 15740 | # Update @ISA | ||
| 15741 | @obj::ISA = qw(Games::Axmud); | ||
| 15742 | } | ||
| 15743 | |||
| 15744 | return $obj; | ||
| 15745 | } | ||
| 15746 | |||
| 15747 | sub update_obj_winmap { | ||
| 15748 | |||
| 15749 | # Called by $self->updateDataAfterRename | ||
| 15750 | # Converts AMud::Obj::Winmap > Games::Axmud::Obj::Winmap | ||
| 15751 | |||
| 15752 | my ($self, $obj) = @_; | ||
| 15753 | |||
| 15754 | # Local variables | ||
| 15755 | my ( | ||
| 15756 | $class, $listRef, $hashRef, | ||
| 15757 | @list, | ||
| 15758 | ); | ||
| 15759 | |||
| 15760 | # (no improper arguments to check) | ||
| 15761 | |||
| 15762 | # Update class | ||
| 15763 | $class = ref $obj; | ||
| 15764 | if ($class =~ m/^AMud\:\:Obj\:\:Winmap/) { | ||
| 15765 | |||
| 15766 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15767 | bless $obj, $class; | ||
| 15768 | $obj->{_objClass} = $class; | ||
| 15769 | |||
| 15770 | $obj->{_objName} = $obj->{_name}; | ||
| 15771 | delete $obj->{_name}; | ||
| 15772 | |||
| 15773 | # (->_parentFile is 'winmaps') | ||
| 15774 | |||
| 15775 | # Update IVs | ||
| 15776 | $hashRef = $obj->{zoneHash}; | ||
| 15777 | foreach my $key (keys %$hashRef) { | ||
| 15778 | |||
| 15779 | $$hashRef{$key} = $self->update_obj_winzone($$hashRef{$key}, $obj); | ||
| 15780 | } | ||
| 15781 | |||
| 15782 | $obj->{zoneHash} = $hashRef; | ||
| 15783 | |||
| 15784 | $listRef = $obj->{stripInitList}; | ||
| 15785 | if (@$listRef) { | ||
| 15786 | |||
| 15787 | do { | ||
| 15788 | |||
| 15789 | my ($string, $hashRef); | ||
| 15790 | |||
| 15791 | $string = shift @$listRef; | ||
| 15792 | $hashRef = shift @$listRef; | ||
| 15793 | |||
| 15794 | $string =~ s/^AMud/Games::Axmud/; | ||
| 15795 | push (@list, $string, $hashRef); | ||
| 15796 | |||
| 15797 | } until (! @$listRef); | ||
| 15798 | |||
| 15799 | $obj->{stripInitList} = \@list; | ||
| 15800 | } | ||
| 15801 | |||
| 15802 | # Update @ISA | ||
| 15803 | @obj::ISA = qw(Games::Axmud); | ||
| 15804 | } | ||
| 15805 | |||
| 15806 | return $obj; | ||
| 15807 | } | ||
| 15808 | |||
| 15809 | sub update_obj_winzone { | ||
| 15810 | |||
| 15811 | # Called by $self->updateDataAfterRename | ||
| 15812 | # Converts AMud::Obj::Winzone > Games::Axmud::Obj::Winzone | ||
| 15813 | |||
| 15814 | my ($self, $obj, $parent) = @_; | ||
| 15815 | |||
| 15816 | # Local variables | ||
| 15817 | my ($class, $string); | ||
| 15818 | |||
| 15819 | # (no improper arguments to check) | ||
| 15820 | |||
| 15821 | # Update class | ||
| 15822 | $class = ref $obj; | ||
| 15823 | if ($class =~ m/^AMud\:\:Obj\:\:Winzone/) { | ||
| 15824 | |||
| 15825 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15826 | bless $obj, $class; | ||
| 15827 | $obj->{_objClass} = $class; | ||
| 15828 | |||
| 15829 | $obj->{_objName} = $obj->{_name}; | ||
| 15830 | delete $obj->{_name}; | ||
| 15831 | |||
| 15832 | # (->_parentFile is 'winmaps') | ||
| 15833 | |||
| 15834 | # Update IVs | ||
| 15835 | if (defined $parent) { | ||
| 15836 | |||
| 15837 | $obj->{winmapObj} = $parent; | ||
| 15838 | } | ||
| 15839 | |||
| 15840 | if (defined $obj->{packageName}) { | ||
| 15841 | |||
| 15842 | $string = $obj->{packageName}; | ||
| 15843 | $string =~ s/^AMud/Games::Axmud/; | ||
| 15844 | $obj->{packageName} = $string; | ||
| 15845 | } | ||
| 15846 | |||
| 15847 | # Update @ISA | ||
| 15848 | @obj::ISA = qw(Games::Axmud); | ||
| 15849 | } | ||
| 15850 | |||
| 15851 | return $obj; | ||
| 15852 | } | ||
| 15853 | |||
| 15854 | sub update_obj_world_model { | ||
| 15855 | |||
| 15856 | # Called by $self->updateDataAfterRename | ||
| 15857 | # Converts AMud::Obj::WorldModel > Games::Axmud::Obj::WorldModel | ||
| 15858 | |||
| 15859 | my ($self, $obj) = @_; | ||
| 15860 | |||
| 15861 | # Local variables | ||
| 15862 | my ($class, $flag, $hashRef, $modelHashRef, $mapHashRef); | ||
| 15863 | |||
| 15864 | # (no improper arguments to check) | ||
| 15865 | |||
| 15866 | # Update class | ||
| 15867 | $class = ref $obj; | ||
| 15868 | if ($class =~ m/^AMud:\:WorldModel/) { | ||
| 15869 | |||
| 15870 | $class =~ s/^AMud/Games::Axmud::Obj/; | ||
| 15871 | $flag = TRUE; | ||
| 15872 | |||
| 15873 | } elsif ($class =~ m/^AMud\:\:Obj\:\:WorldModel/) { | ||
| 15874 | |||
| 15875 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15876 | $flag = TRUE; | ||
| 15877 | } | ||
| 15878 | |||
| 15879 | if ($flag) { | ||
| 15880 | |||
| 15881 | bless $obj, $class; | ||
| 15882 | $obj->{_objClass} = $class; | ||
| 15883 | |||
| 15884 | $obj->{_objName} = $obj->{_name}; | ||
| 15885 | delete $obj->{_name}; | ||
| 15886 | |||
| 15887 | # (->_parentFile is 'worldmodel') | ||
| 15888 | |||
| 15889 | # Update IVs | ||
| 15890 | $modelHashRef = $obj->{model}; | ||
| 15891 | foreach my $key (keys %$modelHashRef) { | ||
| 15892 | |||
| 15893 | $$modelHashRef{$key} = $self->update_modelobj_all($$modelHashRef{$key}); | ||
| 15894 | } | ||
| 15895 | |||
| 15896 | $obj->{model} = $modelHashRef; | ||
| 15897 | |||
| 15898 | my @ivList = qw( | ||
| 15899 | regionModel roomModel weaponModel armourModel garmentModel charModel minionModel | ||
| 15900 | sentientModel creatureModel portableModel decorationModel customModel | ||
| 15901 | ); | ||
| 15902 | |||
| 15903 | foreach my $iv (@ivList) { | ||
| 15904 | |||
| 15905 | my $subHashRef = $obj->{$iv}; | ||
| 15906 | foreach my $key (keys %$subHashRef) { | ||
| 15907 | |||
| 15908 | $$subHashRef{$key} = $$modelHashRef{$key}; | ||
| 15909 | } | ||
| 15910 | |||
| 15911 | $obj->{$iv} = $subHashRef; | ||
| 15912 | } | ||
| 15913 | |||
| 15914 | $hashRef = $obj->{exitModel}; | ||
| 15915 | foreach my $key (keys %$hashRef) { | ||
| 15916 | |||
| 15917 | $$hashRef{$key} = $self->update_obj_exit($$hashRef{$key}); | ||
| 15918 | } | ||
| 15919 | |||
| 15920 | $obj->{exitModel} = $hashRef; | ||
| 15921 | |||
| 15922 | $mapHashRef = $obj->{regionmapHash}; | ||
| 15923 | foreach my $key (keys %$mapHashRef) { | ||
| 15924 | |||
| 15925 | $$mapHashRef{$key} = $self->update_obj_regionmap($$mapHashRef{$key}); | ||
| 15926 | } | ||
| 15927 | |||
| 15928 | $obj->{regionmapHash} = $mapHashRef; | ||
| 15929 | |||
| 15930 | # (We can now do Games::Axmud::ModelObj::Room->regionmapObj) | ||
| 15931 | $hashRef = $obj->{regionModel}; | ||
| 15932 | foreach my $thisObj (values %$hashRef) { | ||
| 15933 | |||
| 15934 | $thisObj->{regionmapObj} = $$mapHashRef{$thisObj->{name}}; | ||
| 15935 | } | ||
| 15936 | |||
| 15937 | $hashRef = $obj->{knownCharHash}; | ||
| 15938 | foreach my $key (keys %$hashRef) { | ||
| 15939 | |||
| 15940 | my $oldObj = $$hashRef{$key}; | ||
| 15941 | |||
| 15942 | $$hashRef{$key} = $$modelHashRef{$oldObj->{number}}; | ||
| 15943 | } | ||
| 15944 | |||
| 15945 | $obj->{knownCharHash} = $hashRef; | ||
| 15946 | |||
| 15947 | $hashRef = $obj->{minionStringHash}; | ||
| 15948 | foreach my $key (keys %$hashRef) { | ||
| 15949 | |||
| 15950 | my $oldObj = $$hashRef{$key}; | ||
| 15951 | |||
| 15952 | # Values in this hash can be model or non-model objects | ||
| 15953 | if (defined $oldObj->{number}) { | ||
| 15954 | |||
| 15955 | # Model object | ||
| 15956 | $$hashRef{$key} = $$modelHashRef{$oldObj->{number}}; | ||
| 15957 | |||
| 15958 | } else { | ||
| 15959 | |||
| 15960 | # Non-model object | ||
| 15961 | $$hashRef{$key} = $self->update_modelobj_all($oldObj); | ||
| 15962 | } | ||
| 15963 | } | ||
| 15964 | |||
| 15965 | $obj->{minionStringHash} = $hashRef; | ||
| 15966 | |||
| 15967 | # Update @ISA | ||
| 15968 | @obj::ISA = qw(Games::Axmud); | ||
| 15969 | } | ||
| 15970 | |||
| 15971 | return $obj; | ||
| 15972 | } | ||
| 15973 | |||
| 15974 | sub update_obj_zone_model { | ||
| 15975 | |||
| 15976 | # Called by $self->updateDataAfterRename | ||
| 15977 | # Converts AMud::Obj::ZoneModel > Games::Axmud::Obj::ZoneModel | ||
| 15978 | |||
| 15979 | my ($self, $obj, $parent) = @_; | ||
| 15980 | |||
| 15981 | # Local variables | ||
| 15982 | my $class; | ||
| 15983 | |||
| 15984 | # (no improper arguments to check) | ||
| 15985 | |||
| 15986 | # Update class | ||
| 15987 | $class = ref $obj; | ||
| 15988 | if ($class =~ m/^AMud\:\:Obj\:\:ZoneModel/) { | ||
| 15989 | |||
| 15990 | $class =~ s/^AMud/Games::Axmud/; | ||
| 15991 | bless $obj, $class; | ||
| 15992 | $obj->{_objClass} = $class; | ||
| 15993 | |||
| 15994 | $obj->{_objName} = $obj->{_name}; | ||
| 15995 | delete $obj->{_name}; | ||
| 15996 | |||
| 15997 | # (->_parentFile is 'zonemaps') | ||
| 15998 | |||
| 15999 | # Update IVs | ||
| 16000 | if (defined $parent) { | ||
| 16001 | |||
| 16002 | $obj->{zonemapObj} = $parent; | ||
| 16003 | } | ||
| 16004 | } | ||
| 16005 | |||
| 16006 | # Update @ISA | ||
| 16007 | @obj::ISA = qw(Games::Axmud); | ||
| 16008 | |||
| 16009 | return $obj; | ||
| 16010 | } | ||
| 16011 | |||
| 16012 | sub update_obj_zonemap { | ||
| 16013 | |||
| 16014 | # Called by $self->updateDataAfterRename | ||
| 16015 | # Converts AMud::Obj::Zonemap > Games::Axmud::Obj::Zonemap | ||
| 16016 | |||
| 16017 | my ($self, $obj) = @_; | ||
| 16018 | |||
| 16019 | # Local variables | ||
| 16020 | my ($class, $hashRef); | ||
| 16021 | |||
| 16022 | # (no improper arguments to check) | ||
| 16023 | |||
| 16024 | # Update class | ||
| 16025 | $class = ref $obj; | ||
| 16026 | if ($class =~ m/^AMud\:\:Obj\:\:Zonemap/) { | ||
| 16027 | |||
| 16028 | $class =~ s/^AMud/Games::Axmud/; | ||
| 16029 | bless $obj, $class; | ||
| 16030 | $obj->{_objClass} = $class; | ||
| 16031 | |||
| 16032 | $obj->{_objName} = $obj->{_name}; | ||
| 16033 | delete $obj->{_name}; | ||
| 16034 | |||
| 16035 | # (->_parentFile is 'zonemaps') | ||
| 16036 | |||
| 16037 | # Update IVs | ||
| 16038 | $hashRef = $obj->{modelHash}; | ||
| 16039 | foreach my $key (keys %$hashRef) { | ||
| 16040 | |||
| 16041 | $$hashRef{$key} = $self->update_obj_zone_model($$hashRef{$key}, $obj); | ||
| 16042 | } | ||
| 16043 | |||
| 16044 | $obj->{modelHash} = $hashRef; | ||
| 16045 | |||
| 16046 | # Just to be safe | ||
| 16047 | $obj->{tempSession} = undef; | ||
| 16048 | |||
| 16049 | # Update @ISA | ||
| 16050 | @obj::ISA = qw(Games::Axmud); | ||
| 16051 | } | ||
| 16052 | |||
| 16053 | return $obj; | ||
| 16054 | } | ||
| 16055 | |||
| 16056 | sub update_profile_world { | ||
| 16057 | |||
| 16058 | # Called by $self->updateDataAfterRename | ||
| 16059 | # Converts Converts AMud::Defn::World > Games::Axmud::Profile::World | ||
| 16060 | |||
| 16061 | my ($self, $obj) = @_; | ||
| 16062 | |||
| 16063 | # Local variables | ||
| 16064 | my ($class, $hashRef); | ||
| 16065 | |||
| 16066 | # (no improper arguments to check) | ||
| 16067 | |||
| 16068 | # Update class | ||
| 16069 | $class = ref $obj; | ||
| 16070 | if ($class =~ m/^AMud\:\:Defn\:\:World/) { | ||
| 16071 | |||
| 16072 | $class =~ s/^AMud\:\:Defn/Games::Axmud::Profile/; | ||
| 16073 | bless $obj, $class; | ||
| 16074 | $obj->{_objClass} = $class; | ||
| 16075 | |||
| 16076 | $obj->{_objName} = $obj->{_name}; | ||
| 16077 | delete $obj->{_name}; | ||
| 16078 | |||
| 16079 | # (->_parentFile is world name) | ||
| 16080 | |||
| 16081 | # Update IVs | ||
| 16082 | $hashRef = $obj->{initTaskHash}; | ||
| 16083 | foreach my $key (keys %$hashRef) { | ||
| 16084 | |||
| 16085 | $$hashRef{$key} = $self->update_task_all($$hashRef{$key}); | ||
| 16086 | } | ||
| 16087 | |||
| 16088 | $obj->{initTaskHash} = $hashRef; | ||
| 16089 | |||
| 16090 | $hashRef = $obj->{missionHash}; | ||
| 16091 | foreach my $key (keys %$hashRef) { | ||
| 16092 | |||
| 16093 | $$hashRef{$key} = $self->update_obj_mission($$hashRef{$key}); | ||
| 16094 | } | ||
| 16095 | |||
| 16096 | $obj->{missionHash} = $hashRef; | ||
| 16097 | |||
| 16098 | $hashRef = $obj->{questHash}; | ||
| 16099 | foreach my $key (keys %$hashRef) { | ||
| 16100 | |||
| 16101 | $$hashRef{$key} = $self->update_obj_quest($$hashRef{$key}); | ||
| 16102 | } | ||
| 16103 | |||
| 16104 | $obj->{questHash} = $hashRef; | ||
| 16105 | |||
| 16106 | $hashRef = $obj->{componentHash}; | ||
| 16107 | foreach my $key (keys %$hashRef) { | ||
| 16108 | |||
| 16109 | $$hashRef{$key} = $self->update_obj_component($$hashRef{$key}); | ||
| 16110 | } | ||
| 16111 | |||
| 16112 | $obj->{componentHash} = $hashRef; | ||
| 16113 | |||
| 16114 | $obj->{profName} = $obj->{defnName}; | ||
| 16115 | delete $obj->{defnName}; | ||
| 16116 | |||
| 16117 | $obj->{profCategory} = $obj->{defnCategory}; | ||
| 16118 | delete $obj->{defnCategory}; | ||
| 16119 | |||
| 16120 | $obj->{profSensitivityFlag} = $obj->{defnSensitivityFlag}; | ||
| 16121 | delete $obj->{defnSensitivityFlag}; | ||
| 16122 | |||
| 16123 | $obj->{profHash} = $obj->{defnHash}; | ||
| 16124 | delete $obj->{defnHash}; | ||
| 16125 | |||
| 16126 | # Update @ISA | ||
| 16127 | @obj::ISA = qw(Games::Axmud::Generic::Profile Games::Axmud); | ||
| 16128 | } | ||
| 16129 | |||
| 16130 | return $obj; | ||
| 16131 | } | ||
| 16132 | |||
| 16133 | sub update_profile_other { | ||
| 16134 | |||
| 16135 | # Called by $self->updateDataAfterRename | ||
| 16136 | # Converts AMud::Defn::XXX > Games::Axmud::Profile::XXX | ||
| 16137 | |||
| 16138 | my ($self, $obj) = @_; | ||
| 16139 | |||
| 16140 | # Local variables | ||
| 16141 | my ( | ||
| 16142 | $class, $listRef, $hashRef, | ||
| 16143 | @list, @list2, @list3, | ||
| 16144 | ); | ||
| 16145 | |||
| 16146 | # (no improper arguments to check) | ||
| 16147 | |||
| 16148 | # Update class | ||
| 16149 | $class = ref $obj; | ||
| 16150 | if ($class =~ m/^AMud\:\:Defn\:\:/) { | ||
| 16151 | |||
| 16152 | $class =~ s/^AMud\:\:Defn/Games::Axmud::Profile/; | ||
| 16153 | bless $obj, $class; | ||
| 16154 | $obj->{_objClass} = $class; | ||
| 16155 | |||
| 16156 | $obj->{_objName} = $obj->{_name}; | ||
| 16157 | delete $obj->{_name}; | ||
| 16158 | |||
| 16159 | # (->_parentFile is 'otherprof') | ||
| 16160 | if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') { | ||
| 16161 | |||
| 16162 | $obj->{_parentFile} = 'otherprof'; | ||
| 16163 | } | ||
| 16164 | |||
| 16165 | # Update IVs | ||
| 16166 | $hashRef = $obj->{initTaskHash}; | ||
| 16167 | foreach my $key (keys %$hashRef) { | ||
| 16168 | |||
| 16169 | $$hashRef{$key} = $self->update_task_all($$hashRef{$key}); | ||
| 16170 | } | ||
| 16171 | |||
| 16172 | $obj->{initTaskHash} = $hashRef; | ||
| 16173 | |||
| 16174 | if ($class =~ m/Char$/) { | ||
| 16175 | |||
| 16176 | $listRef = $obj->{skillHistoryList}; | ||
| 16177 | foreach my $thisObj (@$listRef) { | ||
| 16178 | |||
| 16179 | push (@list, $self->update_obj_skillhistory($thisObj)); | ||
| 16180 | } | ||
| 16181 | |||
| 16182 | $obj->{skillHistoryList} = \@list; | ||
| 16183 | |||
| 16184 | $listRef = $obj->{protectObjList}; | ||
| 16185 | foreach my $thisObj (@$listRef) { | ||
| 16186 | |||
| 16187 | push (@list2, $self->update_obj_protect($thisObj)); | ||
| 16188 | } | ||
| 16189 | |||
| 16190 | $obj->{protectObjList} = \@list2; | ||
| 16191 | |||
| 16192 | $listRef = $obj->{monitorObjList}; | ||
| 16193 | foreach my $thisObj (@$listRef) { | ||
| 16194 | |||
| 16195 | push (@list3, $self->update_obj_monitor($thisObj)); | ||
| 16196 | } | ||
| 16197 | |||
| 16198 | $obj->{monitorObjList} = \@list3; | ||
| 16199 | } | ||
| 16200 | |||
| 16201 | $obj->{profName} = $obj->{defnName}; | ||
| 16202 | delete $obj->{defnName}; | ||
| 16203 | |||
| 16204 | $obj->{profCategory} = $obj->{defnCategory}; | ||
| 16205 | delete $obj->{defnCategory}; | ||
| 16206 | |||
| 16207 | $obj->{profSensitivityFlag} = $obj->{defnSensitivityFlag}; | ||
| 16208 | delete $obj->{defnSensitivityFlag}; | ||
| 16209 | |||
| 16210 | if ($class =~ m/Char$/) { | ||
| 16211 | |||
| 16212 | $obj->{customProfHash} = $obj->{customDefnHash}; | ||
| 16213 | delete $obj->{customDefnHash}; | ||
| 16214 | } | ||
| 16215 | |||
| 16216 | # Update @ISA | ||
| 16217 | @obj::ISA = qw(Games::Axmud::Generic::Profile Games::Axmud); | ||
| 16218 | } | ||
| 16219 | |||
| 16220 | return $obj; | ||
| 16221 | } | ||
| 16222 | |||
| 16223 | sub update_profile_template { | ||
| 16224 | |||
| 16225 | # Called by $self->updateDataAfterRename | ||
| 16226 | # Converts AMud::Defn::Skeleton > Games::Axmud::Profile::Template | ||
| 16227 | |||
| 16228 | my ($self, $obj) = @_; | ||
| 16229 | |||
| 16230 | # Local variables | ||
| 16231 | my $class; | ||
| 16232 | |||
| 16233 | # (no improper arguments to check) | ||
| 16234 | |||
| 16235 | # Update class | ||
| 16236 | $class = ref $obj; | ||
| 16237 | if ($class =~ m/^AMud\:\:Defn\:\:Skeleton/) { | ||
| 16238 | |||
| 16239 | $class =~ s/^AMud\:\:Defn\:\:Skeleton/Games::Axmud::Profile::Template/; | ||
| 16240 | bless $obj, $class; | ||
| 16241 | $obj->{_objClass} = $class; | ||
| 16242 | |||
| 16243 | $obj->{_objName} = $obj->{_name}; | ||
| 16244 | delete $obj->{_name}; | ||
| 16245 | |||
| 16246 | # (->_parentFile is 'otherprof') | ||
| 16247 | if ($obj->{_parentFile} && $obj->{_parentFile} eq 'otherdefn') { | ||
| 16248 | |||
| 16249 | $obj->{_parentFile} = 'otherprof'; | ||
| 16250 | } | ||
| 16251 | |||
| 16252 | # (No IVs to update) | ||
| 16253 | |||
| 16254 | # Update @ISA | ||
| 16255 | @obj::ISA = qw(Games::Axmud::Generic::Profile Games::Axmud); | ||
| 16256 | } | ||
| 16257 | |||
| 16258 | return $obj; | ||
| 16259 | } | ||
| 16260 | |||
| 16261 | sub update_task_all { | ||
| 16262 | |||
| 16263 | # Called by $self->updateDataAfterRename | ||
| 16264 | # Converts AMud::Task::XXX > Games::Axmud::Task::XXX | ||
| 16265 | |||
| 16266 | my ($self, $obj) = @_; | ||
| 16267 | |||
| 16268 | # Local variables | ||
| 16269 | my $class; | ||
| 16270 | |||
| 16271 | # (no improper arguments to check) | ||
| 16272 | |||
| 16273 | # Update class | ||
| 16274 | $class = ref $obj; | ||
| 16275 | if ($class =~ m/^AMud\:\:Task\:\:/) { | ||
| 16276 | |||
| 16277 | $class =~ s/^AMud/Games::Axmud/; | ||
| 16278 | bless $obj, $class; | ||
| 16279 | $obj->{_objClass} = $class; | ||
| 16280 | |||
| 16281 | $obj->{_objName} = $obj->{_name}; | ||
| 16282 | delete $obj->{_name}; | ||
| 16283 | |||
| 16284 | # (->_parentFile is 'undef') | ||
| 16285 | |||
| 16286 | # Update IVs | ||
| 16287 | if (exists $obj->{ttsProfile}) { | ||
| 16288 | |||
| 16289 | $obj->{ttsConfig} = $obj->{ttsProfile}; | ||
| 16290 | delete $obj->{ttsProfile}; | ||
| 16291 | } | ||
| 16292 | |||
| 16293 | if ($obj->{name} eq 'notepad_task') { | ||
| 16294 | |||
| 16295 | $obj->{profNoteHash} = $obj->{defnNoteHash}; | ||
| 16296 | delete $obj->{defnNoteHash}; | ||
| 16297 | } | ||
| 16298 | |||
| 16299 | # Update @ISA | ||
| 16300 | @obj::ISA = qw(Games::Axmud::Generic::Task Games::Axmud); | ||
| 16301 | } | ||
| 16302 | |||
| 16303 | return $obj; | ||
| 16304 | } | ||
| 16305 | |||
| 16306 | ################## | ||
| 16307 | # Accessors - set | ||
| 16308 | |||
| 16309 | sub set_modifyFlag { | ||
| 16310 | |||
| 16311 | # NB The calling function, $func, is disregarded if specified | ||
| 16312 | |||
| 16313 | my ($self, $flag, $func, $check) = @_; | ||
| 16314 | |||
| 16315 | # Check for improper arguments | ||
| 16316 | if (! defined $flag || defined $check) { | ||
| 16317 | |||
| 16318 | return $axmud::CLIENT->writeImproper($self->_objClass . '->set_modifyFlag', @_); | ||
| 16319 | } | ||
| 16320 | |||
| 16321 | if ($flag) { | ||
| 16322 | $self->{modifyFlag} = TRUE; | ||
| 16323 | } else { | ||
| 16324 | $self->{modifyFlag} = FALSE; | ||
| 16325 | } | ||
| 16326 | |||
| 16327 | return $self->modifyFlag; | ||
| 16328 | } | ||
| 16329 | |||
| 16330 | sub set_preserveBackupFlag { | ||
| 16331 | |||
| 16332 | # NB The calling function, $func, is disregarded if specified | ||
| 16333 | |||
| 16334 | my ($self, $flag, $func, $check) = @_; | ||
| 16335 | |||
| 16336 | # Check for improper arguments | ||
| 16337 | if (! defined $flag || defined $check) { | ||
| 16338 | |||
| 16339 | return $axmud::CLIENT->writeImproper($self->_objClass . '->set_preserveBackupFlag', @_); | ||
| 16340 | } | ||
| 16341 | |||
| 16342 | if ($flag) { | ||
| 16343 | $self->{preserveBackupFlag} = TRUE; | ||
| 16344 | } else { | ||
| 16345 | $self->{preserveBackupFlag} = FALSE; | ||
| 16346 | } | ||
| 16347 | |||
| 16348 | return $self->preserveBackupFlag; | ||
| 16349 | } | ||
| 16350 | |||
| 16351 | ################## | ||
| 16352 | # Accessors - get | ||
| 16353 | |||
| 16354 | sub session | ||
| 16355 | { $_[0]->{session} } | ||
| 16356 | |||
| 16357 | sub name | ||
| 16358 | { $_[0]->{name} } | ||
| 16359 | |||
| 16360 | sub fileType | ||
| 16361 | { $_[0]->{fileType} } | ||
| 16362 | sub scriptName | ||
| 16363 | { $_[0]->{scriptName} } | ||
| 16364 | sub scriptVersion | ||
| 16365 | { $_[0]->{scriptVersion} } | ||
| 16366 | sub scriptConvertVersion | ||
| 16367 | { $_[0]->{scriptConvertVersion} } | ||
| 16368 | sub saveDate | ||
| 16369 | { $_[0]->{saveDate} } | ||
| 16370 | sub saveTime | ||
| 16371 | { $_[0]->{saveTime} } | ||
| 16372 | sub assocWorldProf | ||
| 16373 | { $_[0]->{assocWorldProf} } | ||
| 16374 | |||
| 16375 | sub actualFileName | ||
| 16376 | { $_[0]->{actualFileName} } | ||
| 16377 | sub actualPath | ||
| 16378 | { $_[0]->{actualPath} } | ||
| 16379 | sub actualDir | ||
| 16380 | { $_[0]->{actualDir} } | ||
| 16381 | |||
| 16382 | sub standardFileName | ||
| 16383 | { $_[0]->{standardFileName} } | ||
| 16384 | sub standardPath | ||
| 16385 | { $_[0]->{standardPath} } | ||
| 16386 | sub standardDir | ||
| 16387 | { $_[0]->{standardDir} } | ||
| 16388 | |||
| 16389 | sub altFileName | ||
| 16390 | { $_[0]->{altFileName} } | ||
| 16391 | sub altPath | ||
| 16392 | { $_[0]->{altPath} } | ||
| 16393 | |||
| 16394 | sub modifyFlag | ||
| 16395 | { $_[0]->{modifyFlag} } | ||
| 16396 | sub preserveBackupFlag | ||
| 16397 | { $_[0]->{preserveBackupFlag} } | ||
| 16398 | } | ||
| 16399 | |||
| 16400 | # Package must return a true value | ||
| 16401 | 1 |