GooborgStudios / synglechance

The engine for the award-winning game, OneShot
http://www.oneshot-game.com
GNU General Public License v2.0
37 stars 5 forks source link

"Script 'i18n_Language' line 55: NameError occured." #4

Closed kforney closed 6 years ago

kforney commented 6 years ago

I compiled synglechance on Arch Linux, and no errors occurred during the compilation, but immediately upon launching the game, I receive this error: "Script 'i18n_Language' line 55: NameError occured. uninitialized constant #::Zlib"

Below is the complete log:

./OneShot 
ALC_SOFT_pause_device present 
GL Vendor    : NVIDIA Corporation 
GL Renderer  : GeForce GTX 1050 Ti/PCIe/SSE2 
GL Version   : 4.6.0 NVIDIA 387.34 
GLSL Version : 4.60 NVIDIA 
libpng warning: iCCP: known incorrect sRGB profile
Load locale: en 
091:i18n_Language:55:in 'tr': uninitialized constant #<Class:Language>::Zlib (NameError)
        from 091:i18n_Language:48:in 'set'
        from 090:Persistent:39:in 'lang='
        from 090:Persistent:26:in 'initialize'
        from 090:Persistent:68:in 'new'
        from 090:Persistent:68:in 'load'
        from 110:Main:18:in '<main>' 
Traceback (most recent call last):
110:Main:9:in 'block in <main>': undefined method '[]' for nil:NilClass (NoMethodError)
EventThread termination requested 
RGSS thread ack'd request after 0 ms 
Shutting down.
queengooborg commented 6 years ago

It's been awhile since I've touched SyngleChance (as the game I was enhancing OneShot-MKXP for, I haven't heard from in a long time). Will look into this and see what's going on, sorry about that!

kforney commented 6 years ago

Oh, no problem! Thanks for looking into it!

I was linked to your repo from the OneShot Steam community: link

I've been wanting to play OneShot for a while now, but I'd rather play a native Linux version if possible. The main mkxp-oneshot port project seems to have been stuck working on translations for a really long time now, so I thought I'd try your fork.

queengooborg commented 6 years ago

(Yay, this fork is being shared around~ 😄)

queengooborg commented 6 years ago

To give some context upon what the exact issue is: the translations rely on Zlib to obtain generated dictionary/map keys (which seems like redundant work to me). They're doing something to link Zlib on Windows that they're not doing for macOS and Linux, though I'm not sure what. If English is all you care about, you can patch scripts/i18n_Language.rb and comment out a few lines:

Lines 51-61 of scripts/i18n_Language.rb

    # Translate some text
    def tr(string)
      #dbg_print(caller_locations(1, 1).first.tap{|loc| puts "#{loc.path}:#{loc.lineno}"})
-     if @data
-       rv = @data[Zlib::crc32(string)] || string
-     else
+     # if @data
+     #   rv = @data[Zlib::crc32(string)] || string
+     # else
        rv = string
-     end
+     # end
      dbg_print(string + " -> " + rv)
      return String.new(rv)
    end

However, I want to find a more permanent fix for this, and one that works for non-English speakers as well. patches/ruby/static_zlib.patch looks interesting, I wonder if that may have some positive benefit...

I posted on Stack Overflow in regards to this -- my knowledge of Ruby is very little, and my head's hurting, sadly. Hopefully someone can help!

popkirby commented 6 years ago

I compiled ruby-2.3.6 with the patch below (almost same as patches/ruby/static_zlib.patch) and replaced OneShot.app/Contents/Libraries/libruby.2.3.0.dylib with new one. This makes translations work correctly.

diff --git ruby-2.3.6 2/common.mk ruby-2.3.6/common.mk
index da4608b..29e35f5 100644
--- ruby-2.3.6 2/common.mk  
+++ ruby-2.3.6/common.mk
@@ -111,6 +111,7 @@ COMMONOBJS    = array.$(OBJEXT) \
        vm_trace.$(OBJEXT) \
        thread.$(OBJEXT) \
        cont.$(OBJEXT) \
+       ext/zlib/zlib.$(OBJEXT) \
        $(DTRACE_OBJ) \
        $(BUILTIN_ENCOBJS) \
        $(BUILTIN_TRANSOBJS) \
diff --git ruby-2.3.6 2/configure ruby-2.3.6/configure
index c38814a..0c9b440 100755
--- ruby-2.3.6 2/configure  
+++ ruby-2.3.6/configure
@@ -2878,6 +2878,8 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.

+LIBS="$LIBS -lz"
+
 { # environment section

diff --git ruby-2.3.6 2/configure.in ruby-2.3.6/configure.in
index 2cd0f27..3214e50 100644
--- ruby-2.3.6 2/configure.in   
+++ ruby-2.3.6/configure.in
@@ -35,6 +35,8 @@ rm() {
 }
 ])])])

+LIBS="$LIBS -lz"
+
 { # environment section

 AC_ARG_WITH(baseruby,
diff --git ruby-2.3.6 2/inits.c ruby-2.3.6/inits.c
index 6da80bf..fad2bcd 100644
--- ruby-2.3.6 2/inits.c    
+++ ruby-2.3.6/inits.c
@@ -61,5 +61,6 @@ rb_call_inits(void)
     CALL(Complex);
     CALL(version);
     CALL(vm_trace);
+    CALL(zlib);
 }
 #undef CALL

Maybe mkxp needs patched version of Ruby, but compilation of patched Ruby is not included in the Makefile.

queengooborg commented 6 years ago

@popkirby Thank you for your research on this! I just tried it out myself, and it's fully functional, I'm happy to say~ And now, with this, SyngleChance 1.0 for macOS can now be released!

queengooborg commented 6 years ago

I was wrong. I apparently was copying an old xScripts over, which had the translations disabled entirely. I just tried compiling a newer version, and sadly it crashed in a similar way. Unfortunately, that also means that the patch didn't work... ☹️

queengooborg commented 6 years ago

I'm happy to say that 332fc3d fixes translations! I decided to go a different route altogether, and have the CRC32 generated on a C++ level. I double-checked to make sure there weren't incompatibilities between Zlib's and Boost's output as well, and all translations are working perfectly! So, @kforney, you should be able to compile for Linux now. :)