diff --git a/Data/Actors.rxdata b/Data/Actors.rxdata index 41edc8e26..7967a5432 100644 Binary files a/Data/Actors.rxdata and b/Data/Actors.rxdata differ diff --git a/Data/Animations.rxdata b/Data/Animations.rxdata index a311b9b5e..ece08c031 100644 Binary files a/Data/Animations.rxdata and b/Data/Animations.rxdata differ diff --git a/Data/Armors.rxdata b/Data/Armors.rxdata index 901f2bb2b..2249bec14 100644 Binary files a/Data/Armors.rxdata and b/Data/Armors.rxdata differ diff --git a/Data/CommonEvents.rxdata b/Data/CommonEvents.rxdata index 1e9f13efe..3e6c953cb 100644 Binary files a/Data/CommonEvents.rxdata and b/Data/CommonEvents.rxdata differ diff --git a/Data/Enemies.rxdata b/Data/Enemies.rxdata index be622f513..004ee903d 100644 Binary files a/Data/Enemies.rxdata and b/Data/Enemies.rxdata differ diff --git a/Data/Items.rxdata b/Data/Items.rxdata index fe767fa0b..3e62ba6d2 100644 Binary files a/Data/Items.rxdata and b/Data/Items.rxdata differ diff --git a/Data/MapInfos.rxdata b/Data/MapInfos.rxdata index b57e969e5..86c30e4d2 100644 Binary files a/Data/MapInfos.rxdata and b/Data/MapInfos.rxdata differ diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index 3e31a8104..c52a275a6 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -79,6 +79,11 @@ module Settings VAR_2_PLACEHOLDER_SPECIES = :PALKIA VAR_3_PLACEHOLDER_SPECIES = :GIRATINA + + CUSTOMSPRITES_RATE_MAX_NB_REQUESTS = 5 #Nb. requests allowed in each time window + CUSTOMSPRITES_ENTRIES_RATE_TIME_WINDOW = 120 # In seconds + CUSTOMSPRITES_RATE_LOG_FILE = 'Data/sprites/sprites_rate_limit.log' # Path to the log file + RIVAL_STARTER_PLACEHOLDER_VARIABLE = 250 OVERRIDE_BATTLE_LEVEL_SWITCH = 785 diff --git a/Data/Scripts/051_AddOns/HttpCalls.rb b/Data/Scripts/051_AddOns/HttpCalls.rb index 407cc4657..6dbbd0380 100644 --- a/Data/Scripts/051_AddOns/HttpCalls.rb +++ b/Data/Scripts/051_AddOns/HttpCalls.rb @@ -103,6 +103,7 @@ def download_autogen_sprite(head_id, body_id,spriteformBody_suffix=nil,spritefor end def download_custom_sprite(head_id, body_id, spriteformBody_suffix = "", spriteformHead_suffix = "", alt_letter="") + return nil if requestRateExceeded?(Settings::CUSTOMSPRITES_RATE_LOG_FILE,Settings::CUSTOMSPRITES_ENTRIES_RATE_TIME_WINDOW,Settings::CUSTOMSPRITES_RATE_MAX_NB_REQUESTS) head_id = (head_id.to_s) + spriteformHead_suffix.to_s body_id = (body_id.to_s) + spriteformBody_suffix.to_s return nil if $PokemonSystem.download_sprites != 0 @@ -117,6 +118,7 @@ def download_custom_sprite(head_id, body_id, spriteformBody_suffix = "", spritef end def download_custom_sprite_filename(filename) + return nil if requestRateExceeded?(Settings::CUSTOMSPRITES_RATE_LOG_FILE,Settings::CUSTOMSPRITES_ENTRIES_RATE_TIME_WINDOW,Settings::CUSTOMSPRITES_RATE_MAX_NB_REQUESTS) head_id = (head_id.to_s) + spriteformHead_suffix.to_s body_id = (body_id.to_s) + spriteformBody_suffix.to_s return nil if $PokemonSystem.download_sprites != 0 @@ -246,3 +248,25 @@ def fetch_latest_game_version end end + +def requestRateExceeded?(logFile,timeWindow, maxRequests) + # Read or initialize the request log + if File.exist?(logFile) + log_data = File.read(logFile).split("\n") + request_timestamps = log_data.map(&:to_i) + else + request_timestamps = [] + end + current_time = Time.now.to_i + # Remove old timestamps that are outside the time window + request_timestamps.reject! { |timestamp| (current_time - timestamp) > timeWindow } + # Update the log with the current request + request_timestamps << current_time + # Write the updated log back to the file + File.write(logFile, request_timestamps.join("\n")) + # Check if the number of requests in the time window exceeds the limit + echoln request_timestamps.size > maxRequests + echoln request_timestamps + echoln maxRequests + return request_timestamps.size > maxRequests +end diff --git a/Data/Skills.rxdata b/Data/Skills.rxdata index a45219f5e..61cba7ea2 100644 Binary files a/Data/Skills.rxdata and b/Data/Skills.rxdata differ diff --git a/Data/States.rxdata b/Data/States.rxdata index 868d49e59..0f9b4ae5d 100644 Binary files a/Data/States.rxdata and b/Data/States.rxdata differ diff --git a/Data/System.rxdata b/Data/System.rxdata index ed349dcfb..5003532bf 100644 Binary files a/Data/System.rxdata and b/Data/System.rxdata differ diff --git a/Data/Tilesets.rxdata b/Data/Tilesets.rxdata index d54a94d58..906241a32 100644 Binary files a/Data/Tilesets.rxdata and b/Data/Tilesets.rxdata differ diff --git a/Data/VERSION b/Data/VERSION index 913671cdf..31b44b032 100644 --- a/Data/VERSION +++ b/Data/VERSION @@ -1 +1 @@ -6.2 \ No newline at end of file +6.2.4 \ No newline at end of file diff --git a/Data/Weapons.rxdata b/Data/Weapons.rxdata index c7ea19a7a..d9bd35260 100644 Binary files a/Data/Weapons.rxdata and b/Data/Weapons.rxdata differ diff --git a/Data/sprites/sprites_rate_limit.log b/Data/sprites/sprites_rate_limit.log new file mode 100644 index 000000000..183c19e73 --- /dev/null +++ b/Data/sprites/sprites_rate_limit.log @@ -0,0 +1,2 @@ +1728172794 +1728172795 \ No newline at end of file