mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Merge branch 'main' of https://github.com/infinitefusion/infinitefusion-e18 into releases
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -79,6 +79,11 @@ module Settings
|
|||||||
VAR_2_PLACEHOLDER_SPECIES = :PALKIA
|
VAR_2_PLACEHOLDER_SPECIES = :PALKIA
|
||||||
VAR_3_PLACEHOLDER_SPECIES = :GIRATINA
|
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
|
RIVAL_STARTER_PLACEHOLDER_VARIABLE = 250
|
||||||
|
|
||||||
OVERRIDE_BATTLE_LEVEL_SWITCH = 785
|
OVERRIDE_BATTLE_LEVEL_SWITCH = 785
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ def download_autogen_sprite(head_id, body_id,spriteformBody_suffix=nil,spritefor
|
|||||||
end
|
end
|
||||||
|
|
||||||
def download_custom_sprite(head_id, body_id, spriteformBody_suffix = "", spriteformHead_suffix = "", alt_letter="")
|
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
|
head_id = (head_id.to_s) + spriteformHead_suffix.to_s
|
||||||
body_id = (body_id.to_s) + spriteformBody_suffix.to_s
|
body_id = (body_id.to_s) + spriteformBody_suffix.to_s
|
||||||
return nil if $PokemonSystem.download_sprites != 0
|
return nil if $PokemonSystem.download_sprites != 0
|
||||||
@@ -117,6 +118,7 @@ def download_custom_sprite(head_id, body_id, spriteformBody_suffix = "", spritef
|
|||||||
end
|
end
|
||||||
|
|
||||||
def download_custom_sprite_filename(filename)
|
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
|
head_id = (head_id.to_s) + spriteformHead_suffix.to_s
|
||||||
body_id = (body_id.to_s) + spriteformBody_suffix.to_s
|
body_id = (body_id.to_s) + spriteformBody_suffix.to_s
|
||||||
return nil if $PokemonSystem.download_sprites != 0
|
return nil if $PokemonSystem.download_sprites != 0
|
||||||
@@ -246,3 +248,25 @@ def fetch_latest_game_version
|
|||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
6.2
|
6.2.4
|
||||||
Binary file not shown.
2
Data/sprites/sprites_rate_limit.log
Normal file
2
Data/sprites/sprites_rate_limit.log
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
1728172794
|
||||||
|
1728172795
|
||||||
Reference in New Issue
Block a user