In my experience, the path should be canonicalized to make it work properly in an encrypted archive. RGSS will not accept paths like:
Graphics/Windowskins/../Pictures/menu-background.png
However, it can accept such paths if the path is canonicalized to remove the "/../", thus making it to:
Graphics/Pictures/menu-background.png
The following function "canonicalize" will do this:
def strsplit(str,re)
ret=[]
tstr=str
while re=~tstr
ret[ret.length]=$~.pre_match
tstr=$~.post_match
end
ret[ret.length]=tstr if ret.length
return ret
end
def canonicalize(c)
csplit=strsplit(c,/[\/\\]/)
pos=-1
ret=[]
retstr=""
for x in csplit
if x=="."
elsif x==".."
if pos>=0
ret.delete_at(pos)
pos-=1
end
else
ret.push(x)
pos+=1
end
end
for i in 0...ret.length
retstr+="/" if i>0
retstr+=ret[i]
end
return retstr
end
Afterwards, the load_bitmap method of RPG::Cache (see the help file) can be modified as follows:
def self.load_bitmap(folder_name, filename, hue = 0)
path = folder_name + filename
# line added
path=canonicalize(path)
# line added
if not @cache.include?(path) or @cache[path].disposed?
if filename != ""
@cache[path] = Bitmap.new(path)
else
@cache[path] = Bitmap.new(32, 32)
end
end
if hue == 0
@cache[path]
else
key = [path, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = @cache[path].clone
@cache[key].hue_change(hue)
end
@cache[key]
end
end
With these changes, calls like the one below would be acceptable:
RPG::Cache.windowskin("../Graphics/Pictures/menu-background.png")
I hope this helps.