diff --git a/Data/Scripts/001_Technical/002_RubyUtilities.rb b/Data/Scripts/001_Technical/002_RubyUtilities.rb index 3fd261494..1b796b039 100644 --- a/Data/Scripts/001_Technical/002_RubyUtilities.rb +++ b/Data/Scripts/001_Technical/002_RubyUtilities.rb @@ -144,14 +144,14 @@ class File # Copies the source file to the destination path. def self.copy(source, destination) data = "" - t = Time.now + t = System.uptime File.open(source, "rb") do |f| loop do r = f.read(4096) break if !r - if Time.now - t > 1 + if System.uptime - t >= 5 + t += 5 Graphics.update - t = Time.now end data += r end diff --git a/Data/Scripts/001_Technical/003_Intl_Messages.rb b/Data/Scripts/001_Technical/003_Intl_Messages.rb index 1cdd00024..fecc79a69 100644 --- a/Data/Scripts/001_Technical/003_Intl_Messages.rb +++ b/Data/Scripts/001_Technical/003_Intl_Messages.rb @@ -7,12 +7,12 @@ module Translator def gather_script_and_event_texts Graphics.update begin - t = Time.now.to_i + t = System.uptime texts = [] # Get script texts from Scripts.rxdata $RGSS_SCRIPTS.each do |script| - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end scr = Zlib::Inflate.inflate(script[2]) @@ -22,8 +22,8 @@ module Translator # script texts from .rb files in Data/Scripts if $RGSS_SCRIPTS.length == 1 Dir.all("Data/Scripts").each do |script_file| - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end File.open(script_file, "rb") do |f| @@ -36,8 +36,8 @@ module Translator plugin_scripts = load_data("Data/PluginScripts.rxdata") plugin_scripts.each do |plugin| plugin[2].each do |script| - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end scr = Zlib::Inflate.inflate(script[1]).force_encoding(Encoding::UTF_8) @@ -51,8 +51,8 @@ module Translator items = [] choices = [] commonevents.compact.each do |event| - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end begin @@ -99,8 +99,8 @@ module Translator end end end - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end items |= [] @@ -110,8 +110,8 @@ module Translator # Find all text in map events and add them to messages mapinfos = pbLoadMapInfos mapinfos.each_key do |id| - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end filename = sprintf("Data/Map%03d.rxdata", id) @@ -120,8 +120,8 @@ module Translator items = [] choices = [] map.events.each_value do |event| - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end begin @@ -170,16 +170,16 @@ module Translator end end end - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end items |= [] choices |= [] items.concat(choices) MessageTypes.setMapMessagesAsHash(id, items) if items.length > 0 - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end end diff --git a/Data/Scripts/012_Overworld/001_Overworld.rb b/Data/Scripts/012_Overworld/001_Overworld.rb index ba6fc6b6a..4c01b5088 100644 --- a/Data/Scripts/012_Overworld/001_Overworld.rb +++ b/Data/Scripts/012_Overworld/001_Overworld.rb @@ -4,7 +4,7 @@ # Pokérus check EventHandlers.add(:on_frame_update, :pokerus_counter, proc { - next if !$player + next if !$player&.party.any? { |pkmn| pkmn.pokerusStage == 1 } last = $PokemonGlobal.pokerusTime next if !last now = pbGetTimeNow @@ -48,7 +48,7 @@ EventHandlers.add(:on_frame_update, :low_battery_warning, next if $game_temp.warned_low_battery || !pbBatteryLow? next if $game_temp.in_menu || $game_temp.in_battle || $game_player.move_route_forcing || $game_temp.message_window_showing || pbMapInterpreterRunning? - next if pbGetTimeNow.sec != 0 + next if Time.now.sec != 0 $game_temp.warned_low_battery = true pbMessage(_INTL("The game has detected that the battery is low. You should save soon to avoid losing your progress.")) } diff --git a/Data/Scripts/014_Pokemon/001_Pokemon.rb b/Data/Scripts/014_Pokemon/001_Pokemon.rb index 5f8ce4cb6..86e5143a7 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon.rb @@ -1207,7 +1207,7 @@ class Pokemon @obtain_text = nil @obtain_level = level @hatched_map = 0 - @timeReceived = pbGetTimeNow.to_i + @timeReceived = Time.now.to_i @timeEggHatched = nil @fused = nil @personalID = rand(2**16) | (rand(2**16) << 16) diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb index d78ecb7b1..16d8a4cf9 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb @@ -209,7 +209,7 @@ def pbHatch(pokemon) pokemon.name = nil pokemon.owner = Pokemon::Owner.new_from_trainer($player) pokemon.happiness = 120 - pokemon.timeEggHatched = pbGetTimeNow + pokemon.timeEggHatched = Time.now.to_i pokemon.obtain_method = 1 # hatched from egg pokemon.hatched_map = $game_map.map_id pokemon.record_first_moves diff --git a/Data/Scripts/016_UI/012_UI_TrainerCard.rb b/Data/Scripts/016_UI/012_UI_TrainerCard.rb index d787ab116..b8ca55a90 100644 --- a/Data/Scripts/016_UI/012_UI_TrainerCard.rb +++ b/Data/Scripts/016_UI/012_UI_TrainerCard.rb @@ -43,7 +43,7 @@ class PokemonTrainerCard_Scene hour = totalsec / 60 / 60 min = totalsec / 60 % 60 time = (hour > 0) ? _INTL("{1}h {2}m", hour, min) : _INTL("{1}m", min) - $PokemonGlobal.startTime = pbGetTimeNow if !$PokemonGlobal.startTime + $PokemonGlobal.startTime = Time.now if !$PokemonGlobal.startTime starttime = _INTL("{1} {2}, {3}", pbGetAbbrevMonthName($PokemonGlobal.startTime.mon), $PokemonGlobal.startTime.day, diff --git a/Data/Scripts/016_UI/024_UI_MysteryGift.rb b/Data/Scripts/016_UI/024_UI_MysteryGift.rb index e10255fb6..ccad05433 100644 --- a/Data/Scripts/016_UI/024_UI_MysteryGift.rb +++ b/Data/Scripts/016_UI/024_UI_MysteryGift.rb @@ -378,8 +378,7 @@ def pbReceiveMysteryGift(id) if gift[1] == 0 # Pokémon gift[2].personalID = rand(2**16) | (rand(2**16) << 16) gift[2].calc_stats - time = pbGetTimeNow - gift[2].timeReceived = time.getgm.to_i + gift[2].timeReceived = Time.now.to_i gift[2].obtain_method = 4 # Fateful encounter gift[2].record_first_moves gift[2].obtain_level = gift[2].level diff --git a/Data/Scripts/018_Alternate battle modes/002_BugContest.rb b/Data/Scripts/018_Alternate battle modes/002_BugContest.rb index 9144a23a9..8756870b3 100644 --- a/Data/Scripts/018_Alternate battle modes/002_BugContest.rb +++ b/Data/Scripts/018_Alternate battle modes/002_BugContest.rb @@ -27,8 +27,7 @@ class BugContestState # Returns whether the last contest ended less than 24 hours ago. def pbContestHeld? return false if !@lastContest - timenow = pbGetTimeNow - return timenow.to_i - @lastContest < 24 * 60 * 60 # 24 hours + return pbGetTimeNow.to_i - @lastContest < 24 * 60 * 60 # 24 hours end def expired? @@ -222,8 +221,7 @@ class BugContestState @otherparty = [] @contestMaps = [] @reception = [] - timenow = pbGetTimeNow - @lastContest = timenow.to_i + @lastContest = pbGetTimeNow.to_i $game_map.need_refresh = true end end diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb index 46a4bbcd9..7fb8c0682 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb @@ -320,16 +320,16 @@ def pbWriteCup(id, rules) when 2 # Yes, use new return if !pbConfirmMessage(_INTL("This may take a long time. Are you sure?")) mw = pbCreateMessageWindow - t = Time.now + t = System.uptime pbGenerateChallenge(rules, id) do |message| - if Time.now - t >= 5 + if System.uptime - t >= 5 + t += 5 Graphics.update - t = Time.now end if message pbMessageDisplay(mw, message, false) + t = System.uptime Graphics.update - t = Time.now end end pbDisposeMessageWindow(mw) diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index 4809ea972..6a18dc2d3 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -609,7 +609,7 @@ def pbChooseLanguage end def pbScreenCapture - t = pbGetTimeNow + t = Time.now filestart = t.strftime("[%Y-%m-%d] %H_%M_%S.%L") capturefile = RTP.getSaveFileName(sprintf("%s.png", filestart)) Graphics.screenshot(capturefile) diff --git a/Data/Scripts/020_Debug/001_Editor screens/004_EditorScreens_SpritePositioning.rb b/Data/Scripts/020_Debug/001_Editor screens/004_EditorScreens_SpritePositioning.rb index 4673ffb94..8f93c325b 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/004_EditorScreens_SpritePositioning.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/004_EditorScreens_SpritePositioning.rb @@ -12,10 +12,10 @@ def findBottom(bitmap) end def pbAutoPositionAll - t = Time.now.to_i + t = System.uptime GameData::Species.each do |sp| - if Time.now.to_i - t >= 5 - t = Time.now.to_i + if System.uptime - t >= 5 + t += 5 Graphics.update end metrics = GameData::SpeciesMetrics.get_species_form(sp.species, sp.form) diff --git a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb index 1970e131b..15ef08d98 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb @@ -670,14 +670,14 @@ def pbDebugFixInvalidTiles num_error_maps = 0 tilesets = $data_tilesets mapData = Compiler::MapData.new - t = Time.now.to_i + t = System.uptime Graphics.update total_maps = mapData.mapinfos.keys.length Console.echo_h1(_INTL("Checking {1} maps for invalid tiles", total_maps)) mapData.mapinfos.keys.sort.each do |id| - if Time.now.to_i - t >= 5 + if System.uptime - t >= 5 + t += 5 Graphics.update - t = Time.now.to_i end map_errors = 0 map = mapData.getMap(id) diff --git a/Data/Scripts/020_Debug/003_Debug menus/008_Debug_FilenameUpdater.rb b/Data/Scripts/020_Debug/003_Debug menus/008_Debug_FilenameUpdater.rb index 92ab574aa..a15153303 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/008_Debug_FilenameUpdater.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/008_Debug_FilenameUpdater.rb @@ -36,7 +36,7 @@ module FilenameUpdater def update_berry_tree_event_charsets ret = [] mapData = Compiler::MapData.new - t = Time.now.to_i + t = System.uptime Graphics.update Console.echo_li(_INTL("Checking {1} maps for used berry tree charsets...", mapData.mapinfos.keys.length)) idx = 0 @@ -48,9 +48,9 @@ module FilenameUpdater next if !map || !mapData.mapinfos[id] changed = false map.events.each_key do |key| - if Time.now.to_i - t >= 5 + if System.uptime - t >= 5 + t += 5 Graphics.update - t = Time.now.to_i end map.events[key].pages.each do |page| next if nil_or_empty?(page.graphic.character_name) diff --git a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb index bf7f6a9be..282501333 100644 --- a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb @@ -1682,7 +1682,7 @@ module Compiler #============================================================================= def compile_trainer_events(_mustcompile) mapData = MapData.new - t = Time.now.to_i + t = System.uptime Graphics.update trainerChecker = TrainerChecker.new change_record = [] @@ -1696,9 +1696,9 @@ module Compiler map = mapData.getMap(id) next if !map || !mapData.mapinfos[id] map.events.each_key do |key| - if Time.now.to_i - t >= 5 + if System.uptime - t >= 5 + t += 5 Graphics.update - t = Time.now.to_i end newevent = convert_to_trainer_event(map.events[key], trainerChecker) if newevent @@ -1718,9 +1718,9 @@ module Compiler changed = true end end - if Time.now.to_i - t >= 5 + if System.uptime - t >= 5 + t += 5 Graphics.update - t = Time.now.to_i end changed = true if check_counters(map, id, mapData) if changed