Game crashes when displaying custom font but only on the hotspot label

Started by doctorhibert, Wed 13/02/2019 15:02:53

Previous topic - Next topic

doctorhibert

Hi again. So I'm translating a game to chinese, and to do that I'm using a plugin called "AGSBMFont Renderer"https://github.com/bggd/AGSBMFontRenderer

Now I know what you're thinking: We don't know how to use this, just ask the guy who made it. The answer is that a. The guy who made it can't even remember how to use it, and b. I already know how to use it, and have gotten it working. As you can see here, I've managed to display the chinese font in both the speech and GUI.
[imgzoom]https://i.imgur.com/VMywjW2.png[/imgzoom] [imgzoom]https://i.imgur.com/j07CbvN.png[/imgzoom]

Now my only problem is displaying the hotspot descriptions in chinese. However, when I try to do this, the game crashes. I've tried doing this two ways: One is going into GUIs, then gActionText, then inside that clicking on the label and setting it to font 4 (my custom font) in the categories. The other one I tried was putting a line of code in room load that just said:
Code: ags

lblActionText.Font= 4;

In both cases, the game starts up normally without showing any errors, but whenever I mouse over a hotspot that has a description the game crashes, citing this problem:

---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x6AF228E1 ; program pointer is +379, ACI version 3.4.1.12, gtags (0,0)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.



Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
Aceptar   
---------------------------
And here is the .dmp file: https://my.mixtape.moe/xqcvdu.dmp

So why can I show chinese characters just fine in speech and GUIs, but if I try to show it in a label it instantly crashes the game? Thanks in advance for the help, and I'm sorry for bringing such a weird problem to these forums. If this would be better in advanced technical questions, just let me know and I'll post it there

Crimson Wizard

Hm, yes, this does not make much sense, since labels and buttons draw text pretty similarily, and I can see you already have text on GUI anyway.

I think it will be fastest to debug the actual game, if you could send me compiled files somehow. Otherwise this may take much time of guessing and analyzing the code, since there's plugin involved.

doctorhibert

Yes. Do you need the project file or just the compiled/windows folder?

doctorhibert

Alright, well great news, while the game shows the chinese dialogue perfectly in the editor, for some unknown reason it just doesn't work in the .exe. I seriously have no idea why, I've tried putting the .dll in the compiled and in the windows folder but it still does nothing. I've just uploaded the whole game folder, you can check it out in the editor. Make sure the plugin is installed.

Here is the link: https://peronjames.itch.io/chinese-test?secret=UO99WM8enUhxdqhkwbsDq2cklA

May god help us all

Crimson Wizard

As far as I can tell there are mistakes in this plugin. Under some conditions it may try drawing font character outside of bitmap that AGS provides it with.

It seem to have something to do with font characters being higher than expected, but I cannot tell more without doing more research. Unfortunately I don't have spare time for that right now.

I've built a plugin DLL with a trivial fix that prevents drawing outside bitmap. Affected texts will be "cut", but game won't crash.
https://www.dropbox.com/s/61c920bphtzo4qk/agsbmfontrenderer-fixed.zip?dl=0

EDIT: for the reference, this is what I changed in code:
Spoiler

Code: cpp

for (int iy=c->y; iy < (c->y+c->height); ++iy)
          for (int ix=c->x; ix < (c->x+c->width); ++ix) {
            Font::Texture tex = fnt->pages[c->page];
            if (tex.data[iy*tex.w+ix]) {
              int dx = x + xpos + c->xoffset + (ix - c->x);
              int dy = y + c->yoffset + (iy - c->y);
/* ==> */ if (dx < 0 || dx >= dw || dy < 0 || dy >= dh) continue; // <========== MY FIX
              
              if (depth == 8) line_8[dy][dx] = dc;
              else if (depth == 16) line_16[dy][dx] = dc;
              else if (depth == 32) line_32[dy][dx] = dc;
            }
          }

[close]

Imho you better contact original author about this, maybe try opening a bug report on plugin's github page.
If author is not available perhaps someone else could take on maintaining it and fixing bugs.

doctorhibert

Thank you so much. I can actually show the labels in the editor now, but the game still crashes in the .exe
I will ask the original creator if he wants to continue working on it, but I have a feeling he's not gonna be interested.
Do you have any idea of someone who would be interested in taking over this plugin? I don't know anyone in the AGS community

Crimson Wizard

Quote from: doctorhibert on Sun 17/02/2019 18:44:17
Thank you so much. I can actually show the labels in the editor now, but the game still crashes in the .exe

Have you rebuilt the game files just in case to make sure new plugin is copied over? It did work for me with your very game project without crashing.

doctorhibert

Yep. I rebuilt the project files and the exe. If I run the .exe it crashes with this message:

Quote---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x6AF13A83 ; program pointer is +155, ACI version 3.4.1.12, gtags (0,0)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.

in "room1.asc", line 28


Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
Aceptar   
---------------------------
Which is just the first chinese character I show when the game starts


If I run it in the editor with the debugger it works fine, but if I try to run it in the editor without the debugger it shows this:
Quote
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x6AF14A79 ; program pointer is +6, ACI version 3.4.1.12, gtags (0,0)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.

in "room1.asc", line 42


Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
Aceptar   
---------------------------
Which is the line where I set the font to the chinese one


What confuses me is that in the .exe it can set the font, but crashes when displaying it, but on the editor without the debugger it crashes when trying to set the font.
What could be causing this?

SMF spam blocked by CleanTalk