Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work under MKXP-Z (Part 2, with solution) #88

Closed
Fuyukai opened this issue Feb 7, 2021 · 0 comments
Closed

Doesn't work under MKXP-Z (Part 2, with solution) #88

Fuyukai opened this issue Feb 7, 2021 · 0 comments

Comments

@Fuyukai
Copy link

Fuyukai commented Feb 7, 2021

Crashes due to an error trying to load a folder:

Is a directory @ rb_sysopen - Graphics/Characters/

001_FileTests.rb:370:in `initialize'
001_FileTests.rb:370:in `open'
001_FileTests.rb:370:in `pbGetFileChar'
008_AnimatedBitmap.rb:206:in `initialize'
008_AnimatedBitmap.rb:35:in `new'
008_AnimatedBitmap.rb:35:in `initialize'
003_Sprite_Character.rb:122:in `new'
003_Sprite_Character.rb:122:in `update'
009_Sprite_DynamicShadows.rb:154:in `update'
002_Tilemap_Perspective.rb:436:in `update'
003_Sprite_Character.rb:70:in `initialize'
009_Sprite_DynamicShadows.rb:131:in `initialize'
002_Tilemap_Perspective.rb:430:in `initialize'
007_Spriteset_Global.rb:8:in `new'
007_Spriteset_Global.rb:8:in `initialize'
002_Scene_Map.rb:17:in `new'
002_Scene_Map.rb:17:in `createSpritesets'
002_Scene_Map.rb:220:in `main'
999_Main.rb:62:in `mainFunctionDebug'
999_Main.rb:45:in `mainFunction'
999_Main.rb:73:in `block (2 levels) in load_scripts_from_folder'
999_Main.rb:72:in `loop'
999_Main.rb:72:in `block in load_scripts_from_folder'
000:Main:31:in `eval'
000:Main:31:in `block in load_scripts_from_folder'
000:Main:28:in `each'
000:Main:28:in `load_scripts_from_folder'
000:Main:41:in `block in load_scripts_from_folder'
000:Main:40:in `each'
000:Main:40:in `load_scripts_from_folder'
000:Main:45:in `<main>'
ruby:in `eval'

In Ruby 1.9, string indexing was changed to return codepoints rather than bytes, so the != 0x2F check never fires. I believe this patch should fix it on both vanilla Game.exe and MKXP:

diff --git a/Data/Scripts/009_Objects and windows/008_AnimatedBitmap.rb b/Data/Scripts/009_Objects and windows/008_AnimatedBitmap.rb
index dbad67c..530b0ed 100644
--- a/Data/Scripts/009_Objects and windows/008_AnimatedBitmap.rb
+++ b/Data/Scripts/009_Objects and windows/008_AnimatedBitmap.rb
@@ -196,8 +196,10 @@ class GifBitmap
     rescue
       bitmap = nil
     end
+
     if !bitmap || (bitmap.width == 32 && bitmap.height == 32)
-      if !file || file.length < 1 || file[file.length - 1] != 0x2F
+      lastchar = file[file.length - 1]
+      if !file || file.length < 1 || (lastchar != 0x2F && lastchar != "/")
         if (filestring = pbGetFileChar(file))
           filestrName = file
         elsif (filestring = pbGetFileChar(file + ".gif"))

Apologies if it's a bit of a hack, I'm not too familiar with Ruby.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants