Games-Axmud

 view release on metacpan or  search on metacpan

lib/Games/Axmud/Obj/File.pm  view on Meta::CPAN

            $failFlag = $self->readFlag($failFlag, \%dataHash, 'echo_sigil_flag');
            $failFlag = $self->readFlag($failFlag, \%dataHash, 'perl_sigil_flag');
            $failFlag = $self->readFlag($failFlag, \%dataHash, 'script_sigil_flag');
            $failFlag = $self->readFlag($failFlag, \%dataHash, 'multi_sigil_flag');
        }
        if ($self->scriptConvertVersion >= 1_000_912) {

            $failFlag = $self->readFlag($failFlag, \%dataHash, 'speed_sigil_flag');
            $failFlag = $self->readFlag($failFlag, \%dataHash, 'bypass_sigil_flag');
        }
        $failFlag = $self->readValue($failFlag, \%dataHash, 'cmd_sep');
        $failFlag = $self->readEndOfSection($failFlag, $fileHandle);

        # Read world profile data
        if ($self->scriptConvertVersion >= 1_001_021) {

            $failFlag = $self->readValue($failFlag, \%dataHash, 'prev_client_version');
        }
        $failFlag = $self->readList($failFlag, \%dataHash, 'world_prof_list');
        $failFlag = $self->readList($failFlag, \%dataHash, 'favourite_world_list');
        if ($self->scriptConvertVersion >= 1_001_396) {

            $failFlag = $self->readList($failFlag, \%dataHash, 'auto_connect_list');
        }
        $failFlag = $self->readEndOfSection($failFlag, $fileHandle);

        # Read logging preferences
        $failFlag = $self->readFlag($failFlag, \%dataHash, 'allow_logs_flag');
        $failFlag = $self->readFlag($failFlag, \%dataHash, 'delete_standard_logs_flag');
        $failFlag = $self->readFlag($failFlag, \%dataHash, 'delete_world_logs_flag');
        $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_prefix_date_flag');
        $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_prefix_time_flag');
        $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_day_flag');
        $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_client_flag');
        if ($self->scriptConvertVersion >= 1_000_917) {

            $failFlag = $self->readFlag($failFlag, \%dataHash, 'log_image_flag');
        }
        $failFlag = $self->readValue($failFlag, \%dataHash, 'status_before_count');
        $failFlag = $self->readValue($failFlag, \%dataHash, 'status_after_count');
        $failFlag = $self->readHash($failFlag, \%dataHash, 'log_pref_hash');
        if ($self->scriptConvertVersion >= 1_001_395) {

            $failFlag = $self->readList($failFlag, \%dataHash, 'log_preamble_list');
        }
        $failFlag = $self->readEndOfSection($failFlag, $fileHandle);

        # Read colour tags
        if ($self->scriptConvertVersion >= 1_000_165) {

            $failFlag = $self->readValue($failFlag, \%dataHash, 'current_xterm_cube');
        }
        if ($self->scriptConvertVersion >= 1_000_203) {

            $failFlag = $self->readFlag($failFlag, \%dataHash, 'osc_palette_flag');
        }
        $failFlag = $self->readHash($failFlag, \%dataHash, 'colour_tag_hash');
        $failFlag = $self->readHash($failFlag, \%dataHash, 'bold_colour_tag_hash');
        $failFlag = $self->readEndOfSection($failFlag, $fileHandle);

        # Read desktop and display settings
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_main_win_width');
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_main_win_height');
        if ($self->scriptConvertVersion < 1_000_800) {

            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
        }
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_grid_win_width');
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_grid_win_height');
        if ($self->scriptConvertVersion < 1_000_800) {

            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
        }
        if ($self->scriptConvertVersion < 1_000_800) {

            $failFlag = $self->readValue($failFlag, \%dataHash, 'discard_me');
        }
        if ($self->scriptConvertVersion >= 1_001_162) {

            $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_free_win_width');
            $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_free_win_height');
        }
        if ($self->scriptConvertVersion >= 1_003_118) {

            $failFlag = $self->readFlag($failFlag, \%dataHash, 'config_win_index_flag');
        }
        if ($self->scriptConvertVersion >= 1_003_135) {

            $failFlag = $self->readFlag($failFlag, \%dataHash, 'config_win_simplify_flag');
        }
        if ($self->scriptConvertVersion >= 1_003_134) {

            $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_config_win_index_width');
        }
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_insert_cmd_colour');
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_system_text_colour');
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_error_colour');
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_warning_colour');
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_debug_colour');
        $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_show_improper_colour');
        if ($self->scriptConvertVersion >= 1_000_079) {

            $failFlag = $self->readFlag($failFlag, \%dataHash, 'convert_invisible_flag');
        }
        if ($self->scriptConvertVersion >= 1_000_800) {

            $failFlag = $self->readValue($failFlag, \%dataHash, 'custom_text_buffer_size');
        }
        $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_left_size');
        $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_right_size');
        $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_top_size');
        $failFlag = $self->readValueOrUndef($failFlag, \%dataHash, 'custom_panel_bottom_size');
        if ($self->scriptConvertVersion < 1_000_800) {

lib/Games/Axmud/Obj/File.pm  view on Meta::CPAN


        # Set instruction data
        if ($self->scriptConvertVersion >= 1_000_880) {

            $client->ivPoke('echoSigilFlag', $dataHash{'echo_sigil_flag'});
            $client->ivPoke('perlSigilFlag', $dataHash{'perl_sigil_flag'});
            $client->ivPoke('scriptSigilFlag', $dataHash{'script_sigil_flag'});
            $client->ivPoke('multiSigilFlag', $dataHash{'multi_sigil_flag'});
        }
        if ($self->scriptConvertVersion >= 1_000_912) {

            $client->ivPoke('speedSigilFlag', $dataHash{'speed_sigil_flag'});
            $client->ivPoke('bypassSigilFlag', $dataHash{'bypass_sigil_flag'});
        }
        $client->ivPoke('cmdSep', $dataHash{'cmd_sep'});

        # Set world profile data
        if ($self->scriptConvertVersion >= 1_001_021) {

            $client->ivPoke('prevClientVersion', $dataHash{'prev_client_version'});
        }
        $client->ivPoke('configWorldProfList', @{$dataHash{'world_prof_list'}});
        $client->ivPoke('favouriteWorldList', @{$dataHash{'favourite_world_list'}});
        if ($self->scriptConvertVersion >= 1_001_396) {

            $client->ivPoke('autoConnectList', @{$dataHash{'auto_connect_list'}});
        }

        # Set logging preferences
        $client->ivPoke('allowLogsFlag', $dataHash{'allow_logs_flag'});
        $client->ivPoke('deleteStandardLogsFlag', $dataHash{'delete_standard_logs_flag'});
        $client->ivPoke('deleteWorldLogsFlag', $dataHash{'delete_world_logs_flag'});
        $client->ivPoke('logPrefixDateFlag', $dataHash{'log_prefix_date_flag'});
        $client->ivPoke('logPrefixTimeFlag', $dataHash{'log_prefix_time_flag'});
        $client->ivPoke('logDayFlag', $dataHash{'log_day_flag'});
        $client->ivPoke('logClientFlag', $dataHash{'log_client_flag'});
        if ($self->scriptConvertVersion >= 1_000_917) {

            $client->ivPoke('logImageFlag', $dataHash{'log_image_flag'});
        }
        $client->ivPoke('statusEventBeforeCount', $dataHash{'status_before_count'});
        $client->ivPoke('statusEventAfterCount', $dataHash{'status_after_count'});
        $client->ivPoke('logPrefHash', %{$dataHash{'log_pref_hash'}});
        if ($self->scriptConvertVersion >= 1_001_395) {

            $client->ivPoke('logPreambleList', @{$dataHash{'log_preamble_list'}});
        }

        # Set colour tags
        if ($self->scriptConvertVersion >= 1_000_165) {

            $client->ivPoke('currentColourCube', $dataHash{'current_xterm_cube'});
        }
        if ($self->scriptConvertVersion >= 1_000_203) {

            $client->ivPoke('oscPaletteFlag', $dataHash{'osc_palette_flag'});
        }
        $client->ivPoke('colourTagHash', %{$dataHash{'colour_tag_hash'}});
        $client->ivPoke('boldColourTagHash', %{$dataHash{'bold_colour_tag_hash'}});

        # Read desktop and display settings
        $client->ivPoke('customMainWinWidth', $dataHash{'custom_main_win_width'});
        $client->ivPoke('customMainWinHeight', $dataHash{'custom_main_win_height'});
        $client->ivPoke('customGridWinWidth', $dataHash{'custom_grid_win_width'});
        $client->ivPoke('customGridWinHeight', $dataHash{'custom_grid_win_height'});
        if ($self->scriptConvertVersion >= 1_001_162) {

            $client->ivPoke('customFreeWinWidth', $dataHash{'custom_free_win_width'});
            $client->ivPoke('customFreeWinHeight', $dataHash{'custom_free_win_height'});
        }

        if ($self->scriptConvertVersion >= 1_003_118) {

            $client->ivPoke('configWinIndexFlag', $dataHash{'config_win_index_flag'});
        }
        if ($self->scriptConvertVersion >= 1_003_135) {

            $client->ivPoke('configWinSimplifyFlag', $dataHash{'config_win_simplify_flag'});
        }
        if ($self->scriptConvertVersion >= 1_003_134) {

            $client->ivPoke(
                'customConfigWinIndexWidth',
                $dataHash{'custom_config_win_index_width'},
            );
        }

        $client->ivPoke('customInsertCmdColour', $dataHash{'custom_insert_cmd_colour'});
        $client->ivPoke('customShowSystemTextColour', $dataHash{'custom_show_system_text_colour'});
        $client->ivPoke('customShowErrorColour', $dataHash{'custom_show_error_colour'});
        $client->ivPoke('customShowWarningColour', $dataHash{'custom_show_warning_colour'});
        $client->ivPoke('customShowDebugColour', $dataHash{'custom_show_debug_colour'});
        $client->ivPoke('customShowImproperColour', $dataHash{'custom_show_improper_colour'});
        if ($self->scriptConvertVersion >= 1_000_079) {

            $client->ivPoke('convertInvisibleFlag', $dataHash{'convert_invisible_flag'});
        }
        if ($self->scriptConvertVersion >= 1_000_800) {

            $client->ivPoke('customTextBufferSize', $dataHash{'custom_text_buffer_size'});
        }
        $client->ivPoke('customPanelLeftSize', $dataHash{'custom_panel_left_size'});
        $client->ivPoke('customPanelRightSize', $dataHash{'custom_panel_right_size'});
        $client->ivPoke('customPanelTopSize', $dataHash{'custom_panel_top_size'});
        $client->ivPoke('customPanelBottomSize', $dataHash{'custom_panel_bottom_size'});
        $client->ivPoke('customControlsLeftSize', $dataHash{'custom_controls_left_size'});
        $client->ivPoke('customControlsRightSize', $dataHash{'custom_controls_right_size'});
        $client->ivPoke('customControlsTopSize', $dataHash{'custom_controls_top_size'});
        $client->ivPoke('customControlsBottomSize', $dataHash{'custom_controls_bottom_size'});
        if ($self->scriptConvertVersion >= 1_003_157) {

            $client->ivPoke('mswinWinPosnTweakFlag', $dataHash{'mswin_win_posn_tweak_flag'});
        }
        if ($self->scriptConvertVersion >= 1_000_800) {

            $client->ivPoke('shareMainWinFlag', $dataHash{'share_main_win_flag'});

            if ($self->scriptConvertVersion < 1_001_394) {

                # The IV now uses the values 'default', 'on' and 'off', rather than TRUE and FALSE
                #   (which didn't work as intended). Just change the value to 'default'

lib/Games/Axmud/Obj/File.pm  view on Meta::CPAN


                    $currentObj = $otherSession->currentDict;
                    $loadObj = $client->ivShow('dictHash', $currentObj->name);

                    if ($currentObj ne $loadObj) {

                        $otherSession->set_currentDict($loadObj);
                    }
                }

            } else {

                # Incorporate dictionaries
                %dictHash = %{$loadHash{'dict_hash'}};
                if (%dictHash) {

                    foreach my $dictObj (values %dictHash) {

                        $client->add_dict($dictObj);
                    }
                }

                # Update the current dictionary object stored by every session
                foreach my $otherSession ($client->listSessions()) {

                    my ($currentObj, $loadObj);

                    $currentObj = $otherSession->currentDict;
                    $loadObj = $client->ivShow('dictHash', $currentObj->name);

                    if ($currentObj ne $loadObj) {

                        $otherSession->set_currentDict($loadObj);
                    }
                }

                # (Calls to accessors will have set the right ->modifyFlag values)
            }

        } elsif ($self->fileType eq 'toolbar') {

            # 'toolbar'
            #   The entire list of toolbar buttons in memory is replaced by the loaded one,
            #       regardless of the flag

            $axmud::CLIENT->ivPoke('toolbarHash', %{$loadHash{'toolbar_hash'}});
            $axmud::CLIENT->ivPoke('toolbarList', @{$loadHash{'toolbar_list'}});

            if ($overWriteFlag) {

                # The data in memory matches saved data files
                $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');

            } else {

                # The data in memory doesn't match saved data files
                $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData');
            }

            # Redraw toolbar buttons in all 'internal' windows
            foreach my $winObj ($axmud::CLIENT->desktopObj->ivValues('gridWinHash')) {

                my $stripObj;

                if (
                    $winObj->winType eq 'main'
                    || $winObj->winType eq 'protocol'
                    || $winObj->winType eq 'custom'
                ) {
                    $stripObj = $winObj->ivShow('firstStripHash', 'Games::Axmud::Strip::Toolbar');
                    if ($stripObj) {

                        $stripObj->resetToolbar();
                    }
                }
            }

        } elsif ($self->fileType eq 'usercmds') {

            # 'usercmds'
            #   (T) It's quite common for new commands to be added in newer versions of Axmud.
            #       Any user commands corresponding to client commands that didn't exist before
            #       are retained, but all other user commands are replaced
            #   (F) (This function should not be called)

            my (
                $modFlag,
                %standardHash, %currentHash, %newLoadHash, %loadStandardHash,
            );

            if ($overWriteFlag) {

                %hash = %{$loadHash{'user_cmd_hash'}};

                # Import this Axmud version's client command and user command hashes for quick
                #   lookup
                %standardHash = $client->clientCmdHash;
                %currentHash = $client->userCmdHash;

                # From the loaded hash of user commands, filter out any which relate to (standard)
                #   client commands which aren't being used by this version of Axmud
                foreach my $userCmd (keys %hash) {

                    my $standardCmd = $hash{$userCmd};

                    if (exists $standardHash{$userCmd}) {

                        $newLoadHash{$userCmd} = $standardCmd;
                        # Also build a hash of all the standard commands used in the loaded file
                        $loadStandardHash{$standardCmd} = undef;

                    } else {

                        # At least one command filtered out, so the data in memory won't match the
                        #   data file
                        $modFlag = TRUE;
                    }
                }

                # From the current hash of user commands, retain any user commands which correspond
                #   to (standard) client commands not used in the loaded file
                foreach my $userCmd (keys %currentHash) {

                    my $standardCmd = $currentHash{$userCmd};

                    if (! exists $loadStandardHash{$standardCmd}) {

                        # Retain this command
                        $newLoadHash{$userCmd} = $standardCmd;
                        # At least one command retained, so the data in memory won't match the data
                        #   file
                        $modFlag = TRUE;
                    }
                }

                # Replace the client's current list of user commands
                $client->ivPoke('userCmdHash', %newLoadHash);

                if ($modFlag) {
                    $self->set_modifyFlag(TRUE, $self->_objClass . '->extractData');
                } else {
                    $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');
                }

            } else {

                # (Should not be able to import a partial 'usercmds' file, since
                #   $self->exportDataFile doesn't create one)
                return undef;
            }

        } elsif ($self->fileType eq 'zonemaps') {

            # (T) All zonemaps in memory are replaced. The workspace grids used by all sessions are
            #   reset (when they exist). Any workspaces using a default zonemap which no longer
            #   exists are given a new default zonemap. Any workspace grids using a zonemap which no
            #   longer exists are reset to use the workspace's default zonemap
            # (F) Loaded data incorporated into memory. Any workspace grids using a loaded zonemap
            #   are reset

            if ($overWriteFlag) {

                # Replace the data in memory
                $client->ivPoke('zonemapHash', %{$loadHash{'zonemap_hash'}});
                $client->ivPoke('standardZonemapHash', %{$loadHash{'standard_zonemap_hash'}});

                # Check that the default zonemap for all workspaces still exists and, if not,
                #   replace it with a standard one
                foreach my $workspaceObj ($axmud::CLIENT->desktopObj->ivValues('workspaceHash')) {

                    if (
                        $workspaceObj->defaultZonemap
                        && ! $axmud::CLIENT->ivExists('zonemapHash', $workspaceObj->defaultZonemap)
                    ) {
                        if ($axmud::CLIENT->shareMainWinFlag) {
                            $workspaceObj->set_defaultZonemap('basic');
                        } else {
                            $workspaceObj->set_defaultZonemap('single');
                        }
                    }

                    # Reset all workspace grids, changing the zonemap used by any workspace grid
                    #   when that zonemap no longer exists
                    foreach my $gridObj ($workspaceObj->ivValues('gridHash')) {

                        my ($obj, $defaultObj);

                        $obj = $axmud::CLIENT->ivShow('zonemapHash', $gridObj->zonemap);
                        if (! $obj) {

                            $defaultObj = $axmud::CLIENT->ivShow(
                                'zonemapHash',
                                $workspaceObj->defaultZonemap,
                            );


                            $gridObj->applyZonemap($defaultObj);
                        }
                    }
                }

                # The data in memory matches saved data files
                $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');

            } else {

                # We are loading one or more global zonemap objects that have been exported and
                #   must be re-incorporated into memory

                # Incorporate zonemap objects
                %hash = %{$loadHash{'zonemap_hash'}};
                if (%hash) {

                    foreach my $zonemapObj (values %hash) {

                        $client->add_zonemap($zonemapObj);
                    }
                }

                # Any workspace grids using one of the incorporated zonemaps must be reset
                foreach my $gridObj ($axmud::CLIENT->desktopObj->ivValues('gridHash')) {

                    if ($gridObj->zonemap && exists $hash{$gridObj->zonemap}) {

                        $gridObj->applyZonemap(
                            $axmud::CLIENT->ivShow('zonemapHash', $gridObj->zonemap),
                        );
                    }
                }

                # (Calls to accessors will have set the right ->modifyFlag values)
            }

        } elsif ($self->fileType eq 'winmaps') {

                # (T) All winmaps/colour schemes in memory are replaced; no existing windows are
                #       affected, since winmaps are only applied when a window is created, and
                #       colour schemes are only applied periodically
                # (F) Loaded data incorporated into memory

            if ($overWriteFlag) {

                # Replace the data in memory
                $client->ivPoke('winmapHash', %{$loadHash{'winmap_hash'}});
                $client->ivPoke('standardWinmapHash', %{$loadHash{'standard_winmap_hash'}});
                $client->ivPoke('defaultEnabledWinmap', $loadHash{'default_enabled_winmap'});
                $client->ivPoke('defaultDisabledWinmap', $loadHash{'default_disabled_winmap'});
                $client->ivPoke('defaultInternalWinmap', $loadHash{'default_internal_winmap'});
                $client->ivPoke('colourSchemeHash', %{$loadHash{'colour_scheme_hash'}});

                # The data in memory matches saved data files
                $self->set_modifyFlag(FALSE, $self->_objClass . '->extractData');

            } else {

                # We are loading one or more global winmap objects that have been exported and
                #   must be re-incorporated into memory

                # Incorporate winmap objects
                %hash = %{$loadHash{'winmap_hash'}};
                if (%hash) {

                    foreach my $winmapObj (values %hash) {

                        $client->add_winmap($winmapObj);
                    }
                }

                # Incorporate colour schemes
                %hash = %{$loadHash{'colour_scheme_hash'}};
                if (%hash) {

                    foreach my $obj (values %hash) {

                        $client->add_colourScheme($obj);
                    }
                }

                # (Calls to accessors will have set the right ->modifyFlag values)
            }

lib/Games/Axmud/Obj/File.pm  view on Meta::CPAN

                #   directions, whose exit tags have not been modified by the user, should have
                #   their tags updated to include the words 'up' and 'down')
                foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {

                    my ($destRoomObj, $destRegionObj, $oldTag, $newTag);

                    if ($exitObj->{exitTag} && $exitObj->{mapDir}) {

                        $destRoomObj = $wmObj->ivShow('modelHash', $exitObj->{destRoom});
                        $destRegionObj = $wmObj->ivShow('modelHash', $destRoomObj->{parent});
                        $oldTag = 'to ' . $destRegionObj->{name};

                        if ($exitObj->{exitTag} eq $oldTag) {

                            # Tag hasn't been modified by the user, so we can update it
                            if ($exitObj->{mapDir} eq 'up' || $exitObj->{mapDir} eq 'down') {
                                $newTag = $exitObj->{mapDir} . ' to ' . $destRegionObj->{name};
                            } else {
                                $newTag = $oldTag;
                            }

                            if ($exitObj->{oneWayFlag}) {

                                $newTag .= ' (>)';
                            }

                            $exitObj->ivPoke('exitTag', $newTag);
                        }
                    }
                }
            }

            if ($version < 1_000_016) {

                if (! exists $wmObj->{pathFindStepLimit}) {

                    # Add the new IV
                    $wmObj->{pathFindStepLimit} = undef;
                    $wmObj->ivPoke('pathFindStepLimit', 200);
                }
            }

#            if ($version < 1_000_018) {
#
#                # Update the room flag list
#                $wmObj->updateRoomFlags($self->session);
#            }

            if ($version < 1_000_041) {

                # This version fixes an error in GA::Obj::WorldModel->connectRegionBrokenExit, in
                #   which exits that are connected to rooms in different regions as uncertain or
                #   one-way exits are not added to the parent regionmap's list of region exits
                # First, check every region exit. If it can't be found in the parent regionmap's
                #   list of region exits, add it

                # (Only display a warning, if the model contains exits)
                if ($wmObj->{exitModelHash}) {

                    $self->writeText('Applying essential world model update. Please be patient...');
                    $axmud::CLIENT->desktopObj->updateWidgets(
                        $self->_objClass . '->updateExtractedData',
                    );
                }

                foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {

                    my ($roomObj, $regionObj, $regionmapObj);

                    if ($exitObj->{regionFlag}) {

                        $roomObj = $wmObj->ivShow('modelHash', $exitObj->{parent});
                        $regionObj = $wmObj->ivShow('modelHash', $roomObj->{parent});
                        $regionmapObj = $wmObj->ivShow('regionmapHash', $regionObj->{name});

                        if (! $regionmapObj->ivExists('regionExitHash', $exitObj->{number})) {

                            $wmObj->ivAdd(
                                'updateBoundaryHash',
                                $exitObj->{number},
                                $regionObj->{name},
                            );
                        }
                    }
                }

                # Second, tell the world model to update its boundaries (which calls
                #   $regionmapObj->storeRegionExit for each new region exit)
                $wmObj->updateRegionPaths($self->session);

                # Third, recalculate all region paths
                foreach my $regionmapObj (
                    sort {lc($a->{name}) cmp lc($b->{name})} ($wmObj->ivValues('regionmapHash'))
                ) {
                    $wmObj->recalculateRegionPaths(
                        $self->session,
                        $regionmapObj,
                    );
                }
            }

            if ($version < 1_000_053) {

                # Add the new IV to all exit objects
                foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {

                    if (! exists $exitObj->{notSuperFlag}) {

                        $exitObj->{notSuperFlag} = undef;
                        $exitObj->ivPoke('notSuperFlag', FALSE);
                    }
                }
            }

            if ($version < 1_000_094) {

                # Add the new IV to all model objects
                foreach my $obj ($wmObj->ivValues('modelHash')) {

                    if (! exists $obj->{targetRoomNum}) {

lib/Games/Axmud/Obj/File.pm  view on Meta::CPAN

            }

            if ($version < 1_000_545) {

                # This version splits an existing world model IV into two new ones
                if (! exists $wmObj->{allowModelScriptFlag}) {

                    $wmObj->{allowModelScriptFlag} = undef;
                    $wmObj->ivPoke('allowModelScriptFlag', $wmObj->{allowScriptFlag});
                    $wmObj->{allowRoomScriptFlag} = undef;
                    $wmObj->ivPoke('allowRoomScriptFlag', $wmObj->{allowScriptFlag});
                    delete $wmObj->{allowScriptFlag};
                }

                # Also creates two new world model IVs
                if (! exists $wmObj->{newRoomScriptList}) {

                    $wmObj->{newRoomScriptList} = [];
                    $wmObj->ivEmpty('newRoomScriptList');
                    $wmObj->{arriveScriptList} = [];
                    $wmObj->ivEmpty('arriveScriptList');
                }

                # This version also renames a room model object IV
                foreach my $obj ($wmObj->ivValues('roomModelHash')) {

                    my $listRef;

                    if (! exists $obj->{arriveScriptList}) {

                        $obj->{arriveScriptList} = [];
                        $listRef = $obj->{scriptList};
                        $obj->ivPush('arriveScriptList', @$listRef);
                        delete $obj->{scriptList};
                    }
                }
            }

#            if ($version < 1_000_572) {
#
#                # Update the room flag list
#                $wmObj->updateRoomFlags($self->session);
#            }

            if ($version < 1_000_573) {

                # This version fixes an error, in which one of a pair of region exits is made a
                #   super-region exit, but not the other
                # Check all super-region exits; if their twins are not super-region exits (and the
                #   user hasn't deliberately marked them as not being super-region exits), update
                #   them

                my ($count, $hashRef);

                # Only display a warning, if the model contains objects
                $count = 0;
                $hashRef = $wmObj->{modelHash};
                if (%$hashRef) {

                    $self->writeText('Applying essential world model update. Please be patient...');
                    $axmud::CLIENT->desktopObj->updateWidgets(
                        $self->_objClass . '->updateExtractedData',
                    );
                }

                foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {

                    if ($exitObj->{superFlag} && $exitObj->{twinExit}) {

                        my $twinExitObj = $wmObj->ivShow('exitModelHash', $exitObj->{twinExit});

                        if (
                            $twinExitObj->{regionFlag}
                            && ! $twinExitObj->{superFlag}
                            && ! $twinExitObj->{notSuperFlag}
                        ) {
                            $count++;
                            $twinExitObj->ivPoke('superFlag', TRUE);

                            # The regionmap must also be updated (in some cases)
                            my $twinRoomObj = $wmObj->ivShow('modelHash', $twinExitObj->{parent});
                            my $twinRegionObj = $wmObj->ivShow('modelHash', $twinRoomObj->{parent});
                            my $twinRegionmapObj
                                = $wmObj->ivShow('regionmapHash', $twinRegionObj->{name});

                            $twinRegionmapObj->storeRegionExit($self->session, $twinExitObj);
                        }
                    }
                }

                if ($count) {

                    # Recalculate all region pahts
                    foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {

                        my $number = $wmObj->recalculateRegionPaths(
                            $self->session,
                            $regionmapObj,
                        );
                    }
                }
            }

            if ($version < 1_000_579) {

                # This version corrects some errors with exit bends. Redrawing the bends exactly
                #   as the user intended them to be is impossible, so in some cases we must
                #   remove the bends altogether

                foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {

                    my ($listRef, $twinExitObj, $listRef2);

                    $listRef = $exitObj->{bendOffsetList};

                    # In some cases, a one-way exit or uncertain exit is left with bend(s); so
                    #   remove them
                    if (
                        $exitObj->{oneWayFlag}
                        || (
                            $exitObj->{destRoom}

lib/Games/Axmud/Obj/File.pm  view on Meta::CPAN

                    if (! exists $roomObj->{repulseExitPatternHash}) {

                        $roomObj->{repulseExitPatternHash} = {};
                        $roomObj->ivEmpty('repulseExitPatternHash');

                        # Convert ->repulseExitPatternList to the new IV
                        $listRef = $roomObj->{repulseExitPatternList};
                        foreach my $pattern (@$listRef) {

                            $roomObj->ivAdd('repulseExitPatternHash', $pattern, undef);
                        }

                        delete $roomObj->{repulseExitPatternList};

                        # Update the IV name
                        $roomObj->{invRepExitHash} = $roomObj->{involuntaryExitHash};
                        delete $roomObj->{involuntaryExitHash};
                    }
                }
            }

            if ($version < 1_001_328) {

                my %regionHash;

                # This version repairs some errors in exit model objects introduced in certain
                #   situations
                foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {

                    my ($roomObj, $regionObj);

                    # At some point in the past, two-way exits had their ->oneWayDir IV wrongly set.
                    #   This problem does not apply to more recent Axmud versions. Just update all
                    #   exits
                    if (! $exitObj->oneWayFlag && defined $exitObj->oneWayDir) {

                        $exitObj->ivUndef('oneWayDir');
                    }

                    # This error is fixed in this version
                    if (! $exitObj->regionFlag && ($exitObj->superFlag || $exitObj->notSuperFlag)) {

                        $exitObj->ivPoke('superFlag', FALSE);
                        $exitObj->ivPoke('notSuperFlag', FALSE);

                        $roomObj = $wmObj->ivShow('modelHash', $exitObj->parent);
                        $regionObj = $wmObj->ivShow('modelHash', $roomObj->parent);

                        # Any region paths using the exits will have to be updated
                        $wmObj->ivAdd('updatePathHash', $exitObj->number, $regionObj->name);
                        $wmObj->ivAdd('updateBoundaryHash', $exitObj->number, $regionObj->name);
                    }
                }
            }

            if ($version < 1_001_329) {

                my %checkHash;

                $self->writeText('Applying essential world model update. Please be patient...');
                $axmud::CLIENT->desktopObj->updateWidgets(
                    $self->_objClass . '->updateExtractedData',
                );

                # When pathfinding routines were updated to allow paths through adjacent regions,
                #   region paths may have been affected. In addition, there were some problems with
                #   'safe' region paths which are supposed to avoid rooms with hazardous room flags,
                #   but which didn't (in certain situations)
                # Check all region paths and replace any whose rooms are not in the same region
                OUTER: foreach my $regionmapObj ($wmObj->ivValues('regionmapHash')) {

                    INNER: foreach my $regionPathObj ($regionmapObj->ivValues('regionPathHash')) {

                        if (! exists $checkHash{$regionPathObj->startExit}) {

                            foreach my $roomNum ($regionPathObj->roomList) {

                                my ($roomObj, $firstExitObj);

                                # (For speed, don't use ->ivShow)
                                $roomObj = $wmObj->{modelHash}{$roomNum};
                                $firstExitObj = $wmObj->{exitModelHash}{$regionPathObj->startExit};

                                if (
                                    $roomObj
                                    && $firstExitObj
                                    && $roomObj->parent ne $regionmapObj->number
                                ) {
                                    # Any region paths using the first exit will have to be updated
                                    $wmObj->ivAdd(
                                        'updatePathHash',
                                        $firstExitObj->number,
                                        $regionmapObj->name,
                                    );

                                    # (Only need to add each exit once)
                                    $checkHash{$regionPathObj->startExit} = undef;

                                    # (Don't need to check the rest of the rooms in this path)
                                    next INNER;
                                }
                            }
                        }
                    }

                    # Update those region paths now
                    if ($wmObj->updatePathHash) {

                        $wmObj->updateRegionPaths($self->session);
                    }

                    # Now check for 'safe' region paths which should not have room with hazardous
                    #   room flags, but do
                    INNER: foreach my $regionPathObj (
                        $regionmapObj->ivValues('safeRegionPathHash')
                    ) {
                        if (! exists $checkHash{$regionPathObj->startExit}) {

                            foreach my $roomNum ($regionPathObj->roomList) {

                                my ($roomObj, $firstExitObj);

lib/Games/Axmud/Obj/File.pm  view on Meta::CPAN


                    $wmObj->{preDrawMinRooms} = undef;
                    $wmObj->ivPoke('preDrawMinRooms', 500);
                    $wmObj->{queueDrawMaxObjs} = undef;
                    $wmObj->ivPoke('queueDrawMaxObjs', 500);
                }
            }

#            if ($version < 1_001_358) {
#
#                # This version adds new IVs to the world model
#                if (! exists $wmObj->{fixedRoomTagFlag}) {
#
#                    $wmObj->{fixedRoomTagFlag} = undef;
#                    $wmObj->ivPoke('fixedRoomTagFlag', FALSE);
#                    $wmObj->{fixedRoomGuildFlag} = undef;
#                    $wmObj->ivPoke('fixedRoomGuildFlag', FALSE);
#                    $wmObj->{fixedExitTagFlag} = undef;
#                    $wmObj->ivPoke('fixedExitTagFlag', FALSE);
#                    $wmObj->{fixedLabelFlag} = undef;
#                    $wmObj->ivPoke('fixedLabelFlag', FALSE);
#                }
#            }

            if ($version < 1_001_376) {

                # This version adds a new IV to the world model
                if (! exists $wmObj->{retainDrawMinRooms}) {

                    $wmObj->{retainDrawMinRooms} = undef;
                    $wmObj->ivPoke('retainDrawMinRooms', 500);
                }
            }

            if ($version < 1_001_408) {

                # This version compresses the world model. Before we do that, the ->_objName and
                #   ->name IVs for room model object have become standardised, no longer depending
                #   on the room's title or verbose description; update all room objects
                foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {

                    $roomObj->{_objName} = 'room';
                    $roomObj->{name} = 'room';
                }

                # Same for exit object, which no longer take the exit's direction as its ->name
                #   (since the direction can change anyway)
                foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {

                    $exitObj->{_objName} = 'exit';
                    $exitObj->{name} = 'exit';
                }

                # Now we can compress the world model. For each room object and exit object, any IVs
                #   which are set to default values can be completely removed. The new code gets its
                #   default values from the room object and the exit object stored in the global
                #   variables $DEFAULT_ROOM and $DEFAULT EXIT
                if ($wmObj->{modelHash}) {

                    $self->writeText('Applying essential world model update. Please be patient...');
                    $axmud::CLIENT->desktopObj->updateWidgets(
                        $self->_objClass . '->updateExtractedData',
                    );
                }

                foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {

                    $roomObj->compress();
                }

                foreach my $exitObj ($wmObj->ivValues('exitModelHash')) {

                    $exitObj->compress();
                }

                # (This line makes sure the correct file object's ->modifyFlag is set)
                $wmObj->ivPoke('author', $wmObj->author);
            }

            if ($version < 1_001_409) {

                # This version adds a new IV to the world model
                if (! exists $wmObj->{roomFlagShowMode}) {

                    $wmObj->{roomFlagShowMode} = undef;
                    $wmObj->ivPoke('roomFlagShowMode', 'default');
                }
            }

            if ($version < 1_001_450) {

                # This version removes IVs from the world model
                delete $wmObj->{fixedRoomTagFlag};
                delete $wmObj->{fixedRoomGuildFlag};
                delete $wmObj->{fixedExitTagFlag};
                delete $wmObj->{fixedLabelFlag};

                # Also, the ->_objClass for room objects was set to the class of an exit object
                #   instead, so let's fix that
                foreach my $roomObj ($wmObj->ivValues('roomModelHash')) {

                    $roomObj->{_objClass} = ref $roomObj;
                }

                if ($wmObj->{painterObj}) {

                    $wmObj->{painterObj}->{_objClass} = ref $wmObj->{painterObj};
                }
            }

            if ($version < 1_001_453) {

                # This version adds a new IV to the world model
                if (! exists $wmObj->{blockUnselectFlag}) {

                    $wmObj->{blockUnselectFlag} = undef;
                    $wmObj->ivPoke('blockUnselectFlag', TRUE);
                }
            }

            if ($version < 1_001_456) {



( run in 0.589 second using v1.01-cache-2.11-cpan-0d23b851a93 )