AGS 3.6.0 - Beta 15

Started by Crimson Wizard, Sun 20/03/2022 20:23:39

Previous topic - Next topic

Crimson Wizard

About the Beta, I think we'll have another update soon, but because we haven't found any more critical bugs, and there are no more game features planned, we're taking time just doing less important fixes and improving some things.

FanOfHumor

QuoteIf this error happens during compilation, "Undefined token" means the script does not see the function. The usual case is that your module with function "overplay" is located below the module that tries to use it ("fishtank") in the list of modules. In AGS script modules can only see functions declared above them.
QuoteAbout the Beta, I think we'll have another update soon, but because we haven't found any more critical bugs, and there are no more game features planned, we're taking time just doing less important fixes and improving some things.
Oh ok.Thanks for letting me know. :)

Baguettator

Hi there !

I just tried the new version (beta 5), and I tried to change the text format in the general settings pannel : I switched from ANSII to UTF-8. As I'm french, with special characters like éàÉÈ I thought it was better do to that. But when I change the format, the game crashes during a function that "reads" some txt files. It seems the txt files can't be read, so the functions like ReadRawLineBack return an empty string (so it crashes in my function). These txt files are in UTF-8 format.

Any idea why it happens ?

eri0o

This is weird. Can you share a text file that causes the empty ReadRawLineBack ?


Crimson Wizard

Quote from: Baguettator on Sat 28/05/2022 16:41:17
I just tried the new version (beta 5), and I tried to change the text format in the general settings pannel : I switched from ANSII to UTF-8. As I'm french, with special characters like éàÉÈ I thought it was better do to that. But when I change the format, the game crashes during a function that "reads" some txt files. It seems the txt files can't be read, so the functions like ReadRawLineBack return an empty string (so it crashes in my function). These txt files are in UTF-8 format.

I made a new test game in UTF-8 format, and tried your file, and it worked well. Please post a script that crashes?

Here's a simple script i used:
Code: ags

function room_AfterFadeIn()
{
	File *f = File.Open("test.txt",eFileRead);
	if (f == null) return;
	while (!f.EOF) {
		String s = f.ReadRawLineBack();
		Display("%s", s);
	}
}

eri0o

My guess is the location of the text file is incorrect... Where are you placing this file?

Also if this is going to be an internal game file, you can now since 3.6.0 package the file inside the game package and also read from it. More on this here.

Baguettator

Hmm, the file is located in the savegame directory (so in windows 10 : "saved games/[my game's directory]".

Here is the function that needs to read the file to save the attribute of something in the game (like a character for example) when the game is launching :

Code: ags
File *f=File.Open("$SAVEGAMEDIR$/cartesinvasion.txt", eFileRead);
  int c=1;
  while (!f.EOF)
  {
    String s=f.ReadRawLineBack();
    if (c==n)
    {
      String t="";
      this.nom=LectureStringCustom(s, 1);
      t=LectureStringCustom(s, 2);
      this.famille=t.AsInt;
      t=LectureStringCustom(s, 3);
      this.valeur[0]=t.AsInt;
      t=LectureStringCustom(s, 4);
      this.typezombie[0]=t.AsInt;
      t=LectureStringCustom(s, 5);
      this.valeur[1]=t.AsInt;
      t=LectureStringCustom(s, 6);
      this.typezombie[1]=t.AsInt;
      t=LectureStringCustom(s, 7);
      this.valeur[2]=t.AsInt;
      t=LectureStringCustom(s, 8);
      this.typezombie[2]=t.AsInt;
      t=LectureStringCustom(s, 9);
      this.valeur[3]=t.AsInt;
      t=LectureStringCustom(s, 10);
      this.typezombie[3]=t.AsInt;
      t=LectureStringCustom(s, 11);
      if (t.AsInt==1) this.egouts=true;
      else this.egouts=false;
      t=LectureStringCustom(s, 12);
      if (t.AsInt==1) this.reactivation=true;
      else this.reactivation=false;
      t=LectureStringCustom(s, 13);
      if (t.AsInt==1) this.litsbleus=true;
      else this.litsbleus=false;
      t=LectureStringCustom(s, 14);
      if (t.AsInt==1) this.litsverts=true;
      else this.litsverts=false;
    }
    c++;
  }
  f.Close();


Here is the function that read the informations. Each information is separated in the file by a ";". So between each ";", there is 1 information.

Code: ags
String LectureStringCustom(String s, int pos)
{
  String e=";";
  int r, rr;
  String nouvelle;
  for (int i=0 ; i<pos ; i++)
  {
    int p=s.IndexOf(e);
    if (i==pos-2) r=p+1;
    if (i==pos-1)
    {
      rr=p;
      nouvelle=s.Substring(r, rr-r); // Error indicates : String.Substring : invalid length
    }
    s=s.ReplaceCharAt(p, 'm');
  }
  
  return nouvelle;
}


I have to say that before I tried AGS 3.6 beta 5 (I was before on AGS 3.6.0.15), everything was OK.

Any idea ? Thanks a lot for helping ;)

Crimson Wizard

#108
Code: ags
nouvelle=s.Substring(r, rr-r); // Error indicates : String.Substring : invalid length


So it fails at Substring?

I tested your code with random "n" to trigger "if (c==n)" condition, and there was no errors. I guess "n" means a line. Could you tell at which "n" it happens, does it occur at any or particular lines?

I need to narrow the situation down to know which exactly conditions cause this error.

EDIT: actually, I ran this code in a loop, from n = 0 to 500, and met no error... tried in both ASCII and UTF-8 mode.

eri0o

While I also couldn't reproduce the error, I noticed the last line of the .txt is an empty line, so if that line is read and you don't notice there's no ; at all in the line perhaps there's some way it could fail in the code.

I would break the code in two parts, have a tried and tested csv parser and then use a result from that to move the data to the game object.

Crimson Wizard

#110
Updated to Beta 6
(use download links in the first post)

Common features:
- Increased Room Objects limit to 256 (was 40). (This is as much as possible without changing game data format)

Editor:
- When creating new room objects they will now have their script names set to some default value.
- In sprite manager's "export all" dialog added "skip if local" option.
- In sprite manager's context menu added command "Create source files for all sprites with missing / external sources...".
- Fixed going to a "find all" result in dialog script did not highlight the found text, and sometimes did not scroll down to it.

Script API:
- Added InputType enum which defines input devices and lets create their sets as flags.
- Added WaitInput(), a more generic and extendable function that accepts a combination of flags telling which input types to wait for.
- All Wait* functions now return the reason they were skipped: a combination of InputType flag and a respective key or button code.

Engine:
- Upgraded SDL_Sound library, presumably fixes some issues with MIDI sounds.
- Improved file writing times (e.g. when doing a game save) by using buffered file stream. Initial tests showed 50% faster file writing.
- Engine now shares the video texture data for all game objects on screen sharing same sprite. This improves perfomance in case there are multiple objects which use same image.
- Made Animate() function's volume be relative to Character.AnimateVolume for characters.
- Implemented debug key controls for calling a built-in save and restore game dialogs. These controls have to be set in user config as "save_game_key" and "restore_game_key" in "[override]" category. These may be used by testers if the game is missing a save function or one is bugged.
- Added "cache_size" and "stream_threshold" options to config in "[sound]" category, they setup the rules for sound caching and choosing whether to load a clip fully into mem or stream one.
- Fixed dialog script's "goto-previous" command not working if used from the first sub-topic run using "goto-dialog" (a very-very old bug).
- Fixed renderer error occuring if room background frames are of different sizes.
- Fixed game fps sped up if SetGameSpeed() is called repeatedly in game script.
- Fixed Overlay.CreateRoomTextual() creating a screen overlay instead.
- Fixed WFN fonts rendered with misplaced letters if the text is drawn with negative coordinates.
- Fixed TheoraPlayer stopping too early on some videos.
- Fixed sprite cache size was never set from config.
- Fixed game not closing while window is minimized.
- Fixed crash when quitting with error during restoring a save.
- Fixed potential crash on exit on Windows when built in "release" configuration.





In regards to the WaitInput, and other Wait functions. Previously in this version we had a change that let them return the skip result like:
Quote
positive value means a key code, negative value means an inverted mouse code, and 0 means skipped by a timer or script command.
When planning on how a new input device could be supported (e.g. Gamepad, or joystick, etc), I realized that such approach was a mistake, and instead we now have this changed to using a combination of flags:
Code: ags

enum InputType
{
  eInputNone       = 0x00000000,
  eInputKeyboard = 0x00020000,
  eInputMouse     = 0x00040000,
  eInputAny         = 0xFFFF0000
};

The Wait's return value now is a mix of a InputType and key/button code. To retrieve one or another you should be using bitwise operations.
Code: ags

int result = WaitMouseKey(1000);
InputType how = result & eInputAny;
int keycode = result & 0xFFFF;

That's a bit complicated at the first glance, but lets to combine both values, and also easily add more devices to these return values.

The newest WaitInput also accepts a combination of InputType flags, so you can do this:
Code: ags

WaitInput(eInputTime + eInputKeyboard);


When the gamepad, or other devices are supported inside the engine, this InputType enum will be expanded.




eri0o

I had the impression any changes in Wait return value was done in 3.6 itself, is the need to return 0 when in time skip something that was present in 3.5.1?

Crimson Wizard

#112
Quote from: eri0o on Sun 29/05/2022 23:26:57
I had the impression any changes in Wait return value was done in 3.6 itself, is the need to return 0 when in time skip something that was present in 3.5.1?

Yes, it was a historical behavior since the beginning to have return value 0 for timeout and non-0 for other, working similar to boolean; this was purposedly left untouched in 3.6.0.

Crimson Wizard

I reuploaded the Beta 6 without eInputTime flag, so Wait functions are kept returning 0 for timeout as before.

Please download again (same links), if you've already installed Beta 6 earlier.

Pax Animo

#114
Hey there,

Something odd is going on when having two characters SayBackground at the same time.

Code: ags
function cRat_Look()
{
  if (Game.DoOnceOnly("ratlookat1")) {
    player.SayBackground("Shoo, go away!");
    cRat.SayBackground("?");
  }
}


This shuts down the game with a "appears not to have shut down properly error"

Update: actually this happens when any cCharacters.SayBackground, but works fine for player.SayBackground
Misunderstood

Baguettator

Quote from: Crimson Wizard on Sun 29/05/2022 12:04:45
Code: ags
nouvelle=s.Substring(r, rr-r); // Error indicates : String.Substring : invalid length


So it fails at Substring?

I tested your code with random "n" to trigger "if (c==n)" condition, and there was no errors. I guess "n" means a line. Could you tell at which "n" it happens, does it occur at any or particular lines?

I need to narrow the situation down to know which exactly conditions cause this error.

EDIT: actually, I ran this code in a loop, from n = 0 to 500, and met no error... tried in both ASCII and UTF-8 mode.

So I debugged it and I found what happenned : in one of the file (the one who made the game crashing), there were some "É" characters. And this made the game crash during the substring function.

The thing is : why ? The file is in UTF-8, and the game too. Or I'm misundersting something ? (which is surely the main reason of my problems I think ;) ).

Crimson Wizard

#116
Quote from: Pax Animo on Mon 30/05/2022 17:30:23
Hey there,

Something odd is going on when having two characters SayBackground at the same time.

There seem to be a bug there. There will be a temp build with a fix here in roughly 20-30 minutes:
https://cirrus-ci.com/task/5199731981811712
EDIT: ready


Quote from: Baguettator on Mon 30/05/2022 18:28:57
So I debugged it and I found what happenned : in one of the file (the one who made the game crashing), there were some "É" characters. And this made the game crash during the substring function.

Could you please post a file? I'd really prefer to test real case rather than trying to reproduce this by luck.
EDIT: well, i tried to put random É in the file, but nothing happened.

Quote from: Baguettator on Mon 30/05/2022 18:28:57
The thing is : why ? The file is in UTF-8, and the game too.

The file format does not have a direct relation to the game. File can be read differently, what matters is how it is read and what you do with the data in script. Whether engine works correctly too.

Crimson Wizard

Updated to Beta 7
(use download links in the first post)

Script API:
- Implemented `dialog_options_close` callback which is called when custom dialog options are removed from the screen. This allows to perform any required cleanup.
- Added `eEventEnterRoomAfterFadein` event for `on_event` callback, which corresponds to "enter after fade-in" room event.

Engine:
- Fixed rendering scaled up WFN fonts.
- Fixed crash occuring when background speech is removed (found by Pax Animo).

Baguettator

Quote from: Crimson Wizard on Mon 30/05/2022 19:38:37
Quote from: Pax Animo on Mon 30/05/2022 17:30:23
Hey there,

Something odd is going on when having two characters SayBackground at the same time.

There seem to be a bug there. There will be a temp build with a fix here in roughly 20-30 minutes:
https://cirrus-ci.com/task/5199731981811712
EDIT: ready


Quote from: Baguettator on Mon 30/05/2022 18:28:57
So I debugged it and I found what happenned : in one of the file (the one who made the game crashing), there were some "É" characters. And this made the game crash during the substring function.

Could you please post a file? I'd really prefer to test real case rather than trying to reproduce this by luck.
EDIT: well, i tried to put random É in the file, but nothing happened.

Quote from: Baguettator on Mon 30/05/2022 18:28:57
The thing is : why ? The file is in UTF-8, and the game too.

The file format does not have a direct relation to the game. File can be read differently, what matters is how it is read and what you do with the data in script. Whether engine works correctly too.

Thanks for helping !

Did you displayed the String (with the Display function) that you obtained each time with the ReadRawLineback function ? I remember that all the É characters were not correctly displayed (something like ^A"< you know when the character is not properly read).

I will send you my files later (something like tomorrow or monday, I don't have any time before). Remember that in my code, I use a function which locates the ";" characters, and extract the informations between two ";". So it could be that each É or È was putting a new ";" and so it breaks the code.

eri0o

Could you make a small project that reproduces this issue? I haven't been able to trigger any of the mentioned crash using either the script you posted or the file.

You previously said it crashes, now you are saying it displays incorrectly, does it crashes or does it displays incorrectly?

SMF spam blocked by CleanTalk