Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Crimson Wizard

#2521
This is a known issue with how AGS draws some fonts historically.

I believe this should be fixed in 3.6.0, where it calculates font sizes better.
Also, since AGS 3.6.0 there's a setting called "TTF font adjustment", that lets fix fonts that were previously drawn too low. It should normally be set to "Do nothing".

If you're using a previous version, like 3.5.1, there are few possible workarounds:
* try adjusting font's Vertical Offset (but this may lead to upper part cut, if you're unlucky);
* try finding another font;
* script custom speech / display text, where you create a textual overlay yourself, instead of relying on AGS calculations.
* upgrading to 3.6.0, if you like.
#2522
From what I understand, newer editors do not provide any means to edit the Global messages.
The relevant article in the manual:
https://adventuregamestudio.github.io/ags-manual/UpgradeTo30.html

QuoteGlobal Messages

Global Messages are no longer supported and should be considered obsolete -- there's really no need for them now that the interaction editor has gone. Any global messages that you had will be retained and will still work, however the AGS 3 editor provides no way to edit them.

So, they simply stay in data, and may be edited by hand in Game.agf (if you're careful, but it is simply an XML). They may also be completely removed using "File -> Remove Global messages" command. Unfortunately, Editor also does not let automatically copy these messages over to some supported form, like into a script, or Global Variables, which is a shame, and clearly an oversight in the upgrade process.

Strangely, Room Messages can still be accessed (from the room properties), and seem to retain all the old options.


EDIT: I opened a ticket regarding this, but it's probably going to be low priority for the dev team.
#2523
Quote from: Dave Gilbert on Fri 09/12/2022 14:40:16I feel like if it there was a memory leak, the crash would happen at random spots. But my my case it consistently happens at the same point.

Both situations are possible. If in your case it happens exactly at the same spot, that, in my opinion, might mean one of a few things:
1) In that spot you do some actions that allocate lots of memory at once. For example, create dynamic sprites or dynamic arrays in a loop.
2) Your game constantly requires a lot of memory, but in that particular case it allocates bit more and crosses the limit.
3) There's some bug in the engine, and you do something that triggers it, which in turn leads to engine allocating abnormal amount of memory.

How exact is the "point"? Is it certain interaction, a dialog, a cutscene?

EDIT: On a side note, I might remind again, that Windows version of the engine is still distributed as 32-bit, limiting the RAM usage to around 2 GB (iirc). If your game requires more memory under normal circumstance (if that is not a mistake), then it might need a 64-bit version of the engine.
#2524
The problem with the "out of mem" error, is that when it happens nothing is safe anymore. The state of the program objects may be invalid, and any tiny extra allocation may fail in these circumstances.

Looking at the code now, it seems that I'd have to rewrite all the code related to getting the script location again, because at the moment it also allocates memory for the strings which store function call lists, etc.

But then, asking scripts about their current locations may also not be reliable and lead to a program crash, because "out of mem" could have happened while script was being created, or was allocating something during its run.

EDIT: I guess, theoretically this may be done by having a global preallocated buffer, and store this information there, updating as the game and scripts run... Then such buffer may be used when reporting error.
#2525
Quote from: Dave Gilbert on Thu 08/12/2022 17:44:03Is it possible for these error messages to spit out where in the script the crash happened?

I think it may be possible to print the last known script location, but that won't necessarily help, as the "out of memory error" may occur virtually anytime, such as during game update or render, and not the script execution. Also, some actions in AGS are scheduled and postponed until after current script finishes.

For instance, PP=379 is in the middle of GUI redraw.

#2526
Quote from: Snarky on Tue 06/12/2022 10:30:03I'm curious why you decided to make the acceleration multiplicative, @Crimson Wizard? It's not physically accurate, as now the actual acceleration is dependent on the speed (contrary to Newton's second law).

Maybe I began to forget these things. I'll change to addition.
#2527
Added some code example above.
#2528
You need to store Velocity in a variable, and increase velocity over time too.

So each game update you:
* increase Velocity by acceleration;
* change coordinates by velocity.

An example, using floats for more precision (smoother movement):
(this code assumes blocking animation, if you need non-blocking, then it should be updated inside repeatedly_execute instead)
Code: ags
float Accel = 0.2;
float Velocity = 1.0;
float YPos = IntToFloat(oRocket.Y); // current position of a rocket object
float YTop = SOME_NUMBER_YOU_WANT;

while (YPos > YTop)
{
    YPos -= Velocity;
    Velocity += Accel;
    oRocket.Y = FloatToInt(YPos, eRoundNearest);
    Wait(1); // let the game update and redraw
}
#2529
Ok, so, after speaking with NeoDement a little more on Discord, it appeared that the clips were labeled wrong, the other way around, and that the problem is not what I thought at first.

The problem is that the endings of the clips are audibly cut off a bit, so that half of the last word is lost.

This is actually "opposite" (in a way) to the problem I was thinking about.

EDIT: more info: the voice clips are WAVs, and windows player also cuts them off (according to NeoDement), so this may be a WAV playback issue.

EDIT2: this sound also gets its end cut off when played as a regular sound clip, so this is not a dialog/speech problem, but a particular sound clip problem.
#2530
Quote from: eri0o on Mon 05/12/2022 15:18:56It appears the sample rate would be slightly wrong when using the Windows in some case and the distortion is almost imperceptible except by being slightly slower from icculus description above. I had not notice it in AGS before, but thought maybe it could be relevant.

I would expect that the whole clip would be slower then, but in above example the difference is in the moment when the second clip starts, relatively to the previous one's end.
#2531
Quote from: eri0o on Mon 05/12/2022 15:10:34@Crimson Wizard I wonder if it could be a problem in SDL2: https://github.com/libsdl-org/SDL/issues/6326#issuecomment-1267599472

Are not they are talking about distortions there? Here the issue is in timing of a playback start.
#2532
Quote from: NeoDement on Mon 05/12/2022 14:51:41Hi! I've noticed some dialogue timing issues when compiling my game in the latest build:

This may be related to changes to the audio code in 3.6.0, where it actually starts the new clip playback only once the game frame updates (therefore related to fps).

Another possible cause (or maybe an additional one that sums with the first one), is that bufferization may work slightly differently.
#2533
Quote from: Snarky on Tue 29/11/2022 23:09:09With the replacement SDL2.dll it fails to crash. (laugh)
Thanks @Crimson Wizard! Though I don't suppose that is very helpful to isolate the problem.

So, I guess we need to
1) find out what's the difference between SDL2.dll that I built and SDL2.dll that is supplied with the AGS.
2) report to SDL2 team, as this is a SDL2 error, not AGS error.

I built from a release-2.24.1 tag from their repository, and built using provided SDL.sln with MSVS 2015.
#2534
Quote from: Zrezal on Sun 04/12/2022 10:22:06It is now fixed, I downloaded version 3.6 and it works perfectly.

You did not have to, and 3.6.0 is not fully complete and may have new bugs which are still not fixed.

Like I mentioned, the solution in 3.5.1 is to split the text into several lines. It's done like this:
Code: ags
String s = String.Format("%s%s%s%s",
 "first part of the long string",
 "second part of the long string",
 "third part of the long string",
 "fourth part of the long string");

Or this:
Code: ags
String s = "first part of the long string";
s = s.Append("second part of the long string");
// and so on
#2535
Please tell which version of AGS are you using, and what error message do you get? Also, do you get error in the editor or when running the game?

If this is a error you're getting when compiling the script, that's likely a limitation of compiler, and may be avoided by splitting the text into 2 or more parts, and appending them together using String.Append or String.Format.
EDIT: Ah, it looks like this limit was also removed in 3.6.0 already. But it may still exist in previous versions.
#2536
Quote from: Snarky on Fri 02/12/2022 15:30:32No, variadic function calls, including calls to AGS functions like Display, Character.Say and String.Format, are not "safe" (but then again, no programming language can prevent users from writing code that breaks) because they cannot be fully checked at compile time, but if it was the only way to write functions that could accept different argument types, that would still be very useful.

For these kinds of functions being variadic is the typical way to achieve what they need. The other way would be to accept an array of "variant" type. In any case they must have a list of "variant" kind of args, that is a list of arguments where neither number, nor order, nor types of arguments is predefined.

Naturally, if this is what your script function is intended for, then it also has to be variadic.

But common overloaded functions and generic functions do not require "variant" args, they require a strict argument list where the number, order and types are predefined (types are not predefined in the case of generic functions, but rather a context which determines whether particular types will be suitable).

In my opinion, using variadic functions as a implementation of function overloading and generic functions will shift AGS towards completely different kind of scripting, with less type safety, obscure function prototypes, and unreliable function behavior.
#2537
AGS 3.5.1 - Patch 16
Full release number: 3.5.1.23


For Editor
Spoiler

For Android
Spoiler

For Engine/Editor developers
Spoiler

Released: 2nd December 2022

Previous stable version: AGS 3.5.0 P10 forum thread


This release is brought to you by:

- Alan v. Drake
- Crimson Wizard
- Donovan Watteau (fix for big-endian systems)
- eri0o
- fernewelten (fixes)
- James Duong (implemented "--console-attach" option for Windows)
- Morgan Willcock
- Nick Sonneveld
- rofl0r
- Pablo Navarro (fixes)
- Thierry Crozat (bug fixing)
- vga256 (bug fixing)



Summary

3.5.1 is a minor update after 3.5.0, which contains mostly utility additions, fixes and perfomance improvements.

Changes in the Patch 16:

Editor:
- Fixed autocomplete crashing the editor if there was an import declared with type and variable having identical names, and user tries to type that variable's name and a dot to access its members.
- Fixed newly created Views taking free IDs in the middle of the list in random order instead of a straight one (after you previously deleted some Views).

Engine:
- Added missing "DrawSprite" function for "agsblend" plugin stubs.
- Fixed loading pre-3.5.0 games on big endian systems.
- Fixed GUI buttons not displaying the mouse-over image if the interface state was toggled to enabled state while the mouse was over the button.

Updated the manual with certain fixes and corrected examples of using Camera and Viewport structs.


Changes in the Patch 15:

Editor:
- Fixed crash that could occur when changing View's ID to an unused number in the middle.
- Fixed comments and string literals were styled incorrectly in dialog scripts.
- Fixed unterminated string literals in script were not considered as errors when processing scripts for translation update and autonumbering of speech lines, leading to wrong results.
- Fixed Editor was updating translation file even if errors were found while scanning the scripts, which could cause a TRS corruption.
- Fixed Editor could overwrite changes done manually to TRS while the editor is open and if you run a translation update right after.
- Fixed potential program crash on exit in case an editor's plugin has mistakes in "shutdown" callback. Instead editor will report a component's error, but still close properly after.

Script API:
- Removed a rule that Viewport and Camera with ID 0 can't be deleted.


Changes in the Patch 14:

Editor:
- Do not error when compiling a 256 colors game if Direct3D or OpenGL are selected as a default graphics driver (display a warning instead).
- Fixed crash when trying to import pre-2.60 game projects.


Changes in the Patch 13:

Engine:
- Fixed room object does not update its texture if it had a dynamic sprite assigned to it, and that sprite was unassigned, modified or recreated with same ID, and then reassigned again, - all within the same game frame.
- Fixed normal font renderer is not reinitialized correctly in the engine if a plugin uses IAGSEngine::ReplaceFontRenderer(), passing original renderer's pointer (which it received from the previous ReplaceFontRenderer call).


Changes in the Patch 12:

Engine:
- Fixed GUI textual controls don't redraw when the game translation changes until player clicks on GUI (regression since previous 3.5.1 updates).
- Fixed multitasking mode persisting if the game was switched from windowed to fullscreen mode (even though it's not supposed to work in fullscreen).


Changes in the Patch 11:

Editor:
- Fixed batch sprite export with "Set exported file as sprite source" option was assigning new source paths without file extension.

Engine:
- Perfomance fix: GUIs changing Transparency or Visible state should not redraw their surface.

Compatibility:
- Allow AudioClip.Play to to place clips on a crossfade channel, which is normally unaccessible from script. This prevents errors in some games that relied on this behavior.


Changes in the Patch 10:

Engine:
- Fixed crash when visible viewport does not have any linked camera.
- Fixed ListBox.FillSaveGameList() may include save slots with negative slot number (e.g. when the save file has "*.-01" extension).
- Fixed potential crash after failed RunAGSGame() call.
- Fixed search for the game data by GUID when restoring a save belonging to another game;
  this was implemented in 3.5.1, but appeared to not work correctly.


Changes in the Patch 9:

Editor:
- Removed restriction on max dialog topics in the project. The dialog limit in the engine was removed in 3.4.1, but remained in the Editor by oversight.
- Fixed Audio Clip items in the project tree not displaying their IDs right after being renamed.

Compiler:
- Fixed crash occuring when compiler tries to report "Already referenced name as import" error.

Engine:
- Added "--translation" and "--no-translation" command-line arguments.


Changes in the Patch 8:

Engine:
- Clearer error messages for Get/SetProperty functions.
- Fixed PlayFlic() command fails to start the video (regression in 3.5.1).
- Fixed DrawingSurface.DrawSurface() not applying transparency parameter correctly if the drawn surface has alpha channel.
- Fixed OVERHOTSPOT is not updated immediately when character's name changes while cursor is above that character.

Templates:
- In BASS template fixed right click not dropping currently selected item if cursor was hovering over another item.


Changes in the Patch 7:

Editor:
- Added "Layout -> Reset to Defaults" menu command.
- Editor will now reset panel layout to default state if loading layout fail for any reason.
- Default config is now saved also when the game is run in debug mode (F5). This ensures that the test run is using the latest Default Setup, if the user's config has not been created yet.
- Editor will now display an error if user tried to reserve too many channels for audio types.
- Fixed Editor failing to start if user preferences file is corrupted.
- Fixed "Use old-style custom dialog options API" was not set when importing pre-3.4.0 projects.
- Fixed comboboxes' drop-down arrows were not painted with the right color from a color theme.

Engine:
- Fixed program crash occuring if the game reserved too many channels for audio types.
- Fixed potential crash occuring when player loads a save made in a multi-frame room, but the room was since edited and no longer has as many frames.
- Fixed character may have incorrect Frame (property) values while turning.


Changes in the Patch 6:

Editor:
- Added line numbers in the dialog script editor.
- Fixed Dialog script loosing changes if the pane is closed or redocked.
- Fixed controls arrangement on the Dialog pane getting broken when it's redocked.

Engine:
- Fixed filepaths in scripts that have backslashes ('\') fail on non-Windows systems.
  All the (script) File functions will now convert backslashes in filepaths into forward slashes for compatibility.
- Fixed engine was still creating standard directories for game saves and data, even if user provided the custom paths for these.
- Fixed TextBox control crashing the game if it's empty and player presses Backspace.
- Fixed controls on a fully transparent GUI were not interactive (this is an original AGS behavior, which was unintentionally changed in 3.5.0 by mistake).

Compatibility:
- When running 3.5.0 games, treat fully transparent GUI as non-interactable.
  In AGS transparent GUIs may be still interacted with, but 3.5.0 introduced an unintentional (and undocumented) change to this, which was reverted in 3.5.1.

Android:
- Support global engine's config file when the game is run from the Launcher: it's located in the AGS games' parent directory, same place where android.cfg is.

WinSetup:
- Added "Custom game shared data path" to complement "Custom save path" option.


Changes in the Patch 5:

Contained no changes and was a formal re-release with only fixed program build instructions for Linux.


Changes in the Patch 4:

Editor:
- Fixed swapping of inventory item's numeric ID could lead to errors.
- Fixed crash when importing pre-3.* games with multiple script modules.
- Renamed "Enforce object-based scripting" setting to "Enforce post-2.62 scripting". This is for clarity.

Compiler:
- Fixed potential memory corruption when user script reaches max nested if/else blocks.

Engine:
- Also tell module name and approximate source line when reporting script import errors for the variables and local functions.


Changes in the Patch 3:

Editor:
- Fixed sprite file over 2 GB could not be loaded (regression since the last patch).

Engine:
- Further improvement to GUI perfomance: don't redraw GUI when the mouse cursor is hovering over or interacting with controls not leading to an actual visual change.
- Fixed ListBox items could become unaccessible if its font or height is changed leading to a disabled scrollbar.


Changes in the Patch 2:

Engine:
- Fixed speech lipsync getting disabled after loading another game with RunAGSGame().
- Fixed MOD/XM clips fail to play (regression).
- Fixed certain OGV videos fail to play (regression).
- Fixed software renderer was not updating game screen correctly when running a game with legacy "letterboxed" feature (regression).


Changes in the Patch 1:

Editor:
- Fixed script compiler sometimes was not specifying actual Dialog number when reporting errors in the dialog scripts.

Engine:
- Fixed Game.TranslationFilename always returning empty string (regression).
- Fixed GUI controls which were toggled from disabled to enabled state not responding to the mouse clicks until the mouse is moved (regression).
- Fixed OpenGL did not apply a Linear filter when "Render sprites in screen resolution" option is off.


What is new in 3.5.1

Editor:
- Added "Attach game data to exe" option to General Settings. This lets you to package game data separately from the game.exe (only important on Windows at the moment).
- Deprecated "Limit display mode to 16-bit" property in Runtime Setup as it's no longer used by the engine.
- Display aspect ratio in game resolution dialog.
- Implemented classic Color Picker dialog for the Color type values in the property grid, instead of the default one which does not allow user-defined colors.
- Improved tab switching performance for script windows.
- Editor will now enforce full game rebuild after upgrading an older project, this ensures that all scripts are recompiled with the new version rules.
- Fixed room lists in property editor were not updated after room number is changed.
- Fixed importing pre-3.* projects broken by incorrect assignment of "Game file name" property.
- Fixed importing Characters and GUI without sprites still created empty sprite folders.
- Fixed crash when exporting/importing Characters with no Normal View.
- Fixed translation compiler did not correctly save some of the escaped sequences, such as "\n".

Scripting:
- Implemented correct parsing of a "const string" function return type.
- Fixed implementing imported functions was forbidden in the room scripts.

Script API:
- Added GUI.Shown readonly property that tells whether GUI is active on screen. This is primarily for GUIs with "Popup At Y" style, because they hide themselves regardless of Visible property. Note that since 3.5.0 GUI.Visible only tells a script-set value.
- File.Open() now supports $CONFIGFILE$ tag which will try to open user config file for reading or writing regardless of where config is located on disk.
- Added System.SaveConfigToFile() which writes current engine settings to the user config file. Only the options that can be changed at runtime are written back at the moment.
- GetTranslation() now returns "const string" (was "string"). This is to prevent modifying returned string using old-style string functions, such as StrCat(), as this string may be allocated in the internal engine memory for its own use.

Engine:
- Support loading audio and video from data packages larger than 2 GB.
- Improved game data loading times by introducing buffered file stream. Initial tests showed 3-4 times faster file reading.
- Improved game perfomance by not reupdating all of the GUIs each time anything changes, instead only affected GUI will be updated each time.
- Some improvement to general script perfomance.
- Some improvement to script Dictionary and Set types perfomance.
- Room Object's Graphic property now can be assigned a sprite with index over 32767 and up to 65535. This restriction is due to internal data format, which cannot be fully fixed without breaking compatibility with plugin API. This may still be worked around by assigning a View, as View's frames may contain sprites of any index available.
- Similarily, Object's View, Loop and Frame can now be assigned a value over 32767 and up to 65535; not that this was ever an issue...
- Removed arbitrary limit of 1000000 dynamic array elements (now supports over 2 billion).
- Dialogs with no enabled options left will be now stopped, instead of raising script error.
- Engine will not longer quit the game when failing to write a save, but simply display an error on screen (...why this was a thing in the first place?!).
- When restoring a save engine will now try to match game pack by GUID rather than using exe/pack name. This resolves potential problems when game package may have different name in distribution to another system. Also makes saves in multi-game collections more reliable.
- In Debug game mode allow to toggle infinite FPS mode (prior it could not be turned off).
- Expanded text parser error messages for easier debugging.
- Adjusted all the command-line options to have consistent prefix convention, where all full-name options must be preceded by double-dash, and one-letter options by single dash.
- Added "--localuserconf" command and similar global config option which tells engine to read and write user config in the game's directory rather than using standard platform path. Game dir must be writeable for this to work.
- Added "--conf" command which forces engine to read only explicit config file on startup.
- Added "--user-data-dir" and "--shared-data-dir" commands for setting save game directory and shared app data directory from command line (this corresponds to existing options in config).
- Fully configurable log output (in both game config and command line) allows to set up which message types and groups are printed by which output methods (sinks), including: file, system console, in-game console. "warnings.log" is now created only if file log was not requested by user.
- Added "--log-" set of command line options for setting up log output.
- Added "--tell-filepath" option for printing known engine's and game's file locations.
- Added "--tell-gameproperties" option for printing some of the game's general settings.
More information on log config and --tell commands currently may be found in following text file: OPTIONS.md
This has to be added to the manual eventually.
- Support proper lookup for Allegro 4 library resources (such as its own config and digital MIDI patches) in the game directory.
- Engine will no longer precreate directories for common files: saves, user config, shared files and so forth, - before actually having to write these. This ensures that no new directories are created on your disk without actual need. Also this fixed a problem that could happen if someone deleted e.g. a game's save directory while game was running.
- Fixed running game from another directory by passing its relative filename as command-line argument: in this case engine was incorrectly using its own directory to search for external game data, opening files for reading by script command, and so on.
- Fixed some of the engine's own hotkeys (such windowed/fullscreen mode toggle) not working during certain skippable game states.
- Fixed overlay was set to wrong position if it were using TextWindow gui and either its text or X, Y properties got changed.
- Fixed crash occuring when the speech is using text window gui with zero Padding and the speech text is an empty line.
- Fixed characters and room objects were not updating their looks if their current graphic was a Dynamic Sprite, and that sprite was modified with ChangeCanvasSize, CopyTransparencyMask, Crop, Flip, Resize, Rotate or Tint function.
- Fixed Views' frames keeping reference to deleted Dynamic Sprites causing crashes. Now they will be reset to dummy sprite 0 for safety.
- Fixed engine crash when button's graphic is set to sprite out of range.
- Fixed animated cursor's normal graphic reappearing in between animation frames if mouse mode is being repeatedly reassigned, for example in rep-exec script.
- Fixed certain interactions did not work with GUI if it was made fully transparent.
- Fixed ListBox.FillSaveGameList() search pattern, it included files which contain save filename pattern but do not exactly match; for example: "agssave.001_".
- Fixed engine was ignoring audio files in game directory when running games which use old audio system.
- Fixed crash in Direct3D and OpenGL renderers that occured if game uses a plugin that performs software drawing on screen, and one of the rooms is smaller than the game's resolution.
- Fixed Direct3D was assigning wrong fullscreen refresh rate sometimes, slowing alt-tabbing.
- Fixed "--test" mode was lost upon restoring a save.

Engine Plugin API:
- Added IAGSEngine::GetRenderStageDesc() function which returns current render stage parameters. As of this version these parameters include 3 transformation matrixes, allowing any 3D render plugin to stay compliant to engine's scene rendering.

Compatibility:
- Fixed engine was trying to read unnecessary data when loading pre-2.72 games.
- Fixed "upscale" mode for old games (was broken in 3.5.0). Also engine will now try to detect if "upscale" mode wanted by reading old config options (if they are present).
- Fixed GUI.Visible not returning expected values for GUIs with "Popup At Y" style in pre-3.5.0 games, breaking some older games logic.
- Fixed potential buffer overflow when reading pre-3.1.0 games with old dialog script texts.
- Fixed engine was applying player's position too early when ChangeRoom was called for 2.72 and earlier games, which could result in wrong placement in the new room if the character was walking right before the transition.

Android:
- Corrected game scanning in AGS launcher, now it will work consistently with the desktop ports, and detect any compatible game data files named "*.ags" or "*.exe".

OSX:
- When looking for game files engine will no longer use hardcoded filename, will search for any compatible pack file instead.

Windows:
- Windows version of the engine now reads global configuration file. It is looked up in "%USERPROFILE%/Saved Games/Adventure Game Studio/acsetup.cfg"
- Default log file location is now also in "%USERPROFILE%/Saved Games/Adventure Game Studio".
- Added "--no-message-box" command line option to hide message boxes when alerts are raised. These messages will be still printed to log (if one is enabled).
- Added "--console-attach" command line option to try attach to the parent process's console. This is useful if you run game from command line and want to see engine's log in the console.

WinSetup:
- Fixed changing fullscreen mode from "use current desktop" to explicit resolution on save.







Thanks to everyone who contributed to and tested this version!



#2538
Quote from: Snarky on Fri 02/12/2022 14:27:11This would allow you to do a lot of things that can be done by function overloading or generic functions (though not different return types in one function, and probably not support for custom types as arguments), at some slight inconvenience. Of course, you couldn't guarantee at compile time that each function call has the right number and types of arguments, but that's not necessarily a huge problem.

I'm so strongly disagreeing with this paragraph, that apparently we have a difference in views on programming at the fundamental level.
#2539
Trying to make a very quick overview of the problem.

1. Variadic function:
Code: ags
function VarFunc(<optional strict args>, ...)
Number and type of arguments cannot be known at the time of compilation, so user may pass virtually anything, in any order. This makes this an uneasy function to write.
Will require a way to iterate through the arguments (access them by index like array, or using "get next arg" syntax).
It's not clear whether getting argument's type, or rather - argument as certain type - any type, - is a feasible thing in AGS script, as in AGS variables must have strict types, they are not variants (like in Lua or Python etc). It's quite possible that this would require to have a function that retrieves an arg casted to the wanted type, which in turn requires a generic function (so - generic functions support).

If above is implemented, somehow, the common use of the variadic function will likely be operations that work on arrays of random types of data. Like logging, for example. Using variadic functions for operations that require strict types and number of args will require args checking and failing if types and number of args don't match certain requirements. Also, in the latter case, calling such function will be very bug prone (and may be difficult to explain to users).

One thing that variadic script function may be definitely useful for - is for forwarding variadic arg list further into the engine API, without knowing its actual contents.
For a hypothetical example:
Code: ags
function CustomSay(<some args>, ...)
{
     // do some stuff
     Display(text, __var_args__); // forward unknown arg list further into the engine
}

2. Function overloading.
Code: ags
function DoSomething(int i);
function DoSomething(float f);
function DoSomething(String s);
This means having multiple separate functions of same name but with different arguments. Besides that these are just regular functions, each having its own body. This is useful to have a set of functions that do similar thing, but may do so this way or another.

Personally, I think this may be easiest to implement in the new compiler, because this may require only extending how the function registration works internally: for example, besides just the function name (and number of args) also have argument list description in the internal function name. This way it will be possible to distinguish them in both compiler and the engine.

3. Generic functions.
Code: ags
T Sum<T>(T a, T b)
{
    return a + b;
}
The point of the generic function is to have a single operation that can be performed over a multitude of different types. The argument list (and return value) enables types that match certain requirements. Like, in above example: can be summed together. If user tries to call this function with types that cannot be summed, then the compilation should fail.

Generic functions in script are best for the simple algorithms that don't depend on types too strictly. Like: may be performed over any kind of number, or iterating over any kind of array, and so forth.

Personally, I have no idea how possible or difficult that may be to implement this in AGS script.
#2540
Quote from: Snarky on Fri 02/12/2022 10:04:57They all enable you to create functions that can take different argument types, though.

My meaning is, that you should not implement function overloading and generic functions with variadic function. That's not safe and probably won't work correctly. They are meant for separate kinds of situations too. They have to be 3 separate language features.
SMF spam blocked by CleanTalk