Mafia versioning & scripts

dj_d

Member
I'd like my scripts to notify the user if they're being run under an old version of mafia where they're unlikely to work (or at least untested). The problem is that if the script calls a function that isn't present in the current version, it will give an error before it has a chance to run - so a get_mafia_version() function wouldn't solve the problem.

Could we get a way, at the top of the script, to do something like <minver = 6666>? If Mafia version 6665 attempted to run the script, it would first pop up something that said, "This script is designed for Mafia version 6666 or higher. Continue?"

Of course, this would only be helpful in the future, if the "old" version of mafia had this implemented already... still, better than the situation today, I think.
 

jasonharper

Developer
The problem with this idea is that there are two independent version numbers involved - the release version (now 12.7) and the svn revision number (currently 6589). The official releases do NOT contain any information about the svn revision number, and daily builds might not either (depending on exactly how they were built). Your <minver> tag could therefore only work in terms of release versions, which change far too infrequently to really help with the problem you describe.

The simplest solution I can think of would be to allow something like #uses autosell_price(int) at the top of the file; if the indicated function doesn't exist in the user's version, it would give a "need to upgrade" rather than "function does not exist" message. You wouldn't need to know the exact revision in which that function was introduced (and the user is probably going to want to upgrade to the current version, rather than that particular revision, anyway). The downside is that this cannot express a need for a revision in which a bug was fixed, or a behavioral change was made to an existing function. I don't know how practical this would be to implement.
 

Bale

Minion
Caveat emptor!

When someone downloads a mafia script there is usually (always?) a forum post from which they download it. Just say there that it requires a build of mafia after-such-and-such-or-so and they should download a recent build. If they can't update their mafia after they've already been warned, I hardly think that the script is sufficient to remedy their lack of comprehension.

Let the downloader fend for himself if he's that dense. Forewarned should be forearmed
 

dj_d

Member
@Bale: You're certainly correct, but I like to make my scripts user-friendly, and this seems like a nice way to do so. I hate scripts that have dense paragraphs that must be read and understood before running. Nevermind that I've written a few of them myself. :)

@jh: You're right, but I think the problem is surmountable. Since the version checking is internal to Mafia, the release builds could simply have a "virtual" SVN number that equals the SVN number just prior to their release. In this approach you'd always use the SVN number in your script (never 12.7).

Your suggestion would definitely work, but seems tricky to scale since you have to inventory all the stuff that's been added recently to put at the top of your script.

Not perfect, since SVN and release builds are probably measurably different, but since at the end of the day all this is doing is suggesting the user upgrade, it's probably OK if it's not perfect.
 

jasonharper

Developer
[quote author=dangerpin link=topic=2061.msg10288#msg10288 date=1228722228]
SVN and release builds are identical. SVN version 6588 exactly matches 12.7
[/quote]
Right, but the official 12.7 build doesn't know that it's revision 6588 - that information is simply not present in the file.
 

dangerpin

Member
Yes, but I was responding to the idea that "SVN and release builds are probably measurable different", I should have quoted for clarity.
 

dj_d

Member
So each build (SVN or release) would have to have an "equal_or_greater_than" number to compare against - and it'd have to be manually created for release builds, it sounds like. Seems possible? Anyway, humble request and all that, not the end of the world if it doesn't happen. :)
 

zarqon

Well-known member
If scripts produce errors because of references to unknown ASH functions, users will have to download the latest version. This is good. In the interest of a) helping mafia develop, and 2) user satisfaction with mafia, script authors ought to give users these little nudges by incorporating the latest functionality.

As a user, I would rather be aware of an available update than have a script perform some suboptimal workaround because I haven't updated.

The #uses function solution suggested by jason would enable scripts to gracefully handle older (and most likely handicapped) versions of mafia, but even this is unneccessary -- there is no reason for a user not to update.
 

dj_d

Member
@Z: That makes sense... it argues for a "you need a more current version of Mafia to run this script, get it here" message solution.
 

zarqon

Well-known member
That is the implied message with any error. :) Unless you're running the current build, at which point it becomes an error in the script or a mafia bug.

Mafia would have no way of knowing if the nonexistent function being called was a brand new ASH function, or just a scripting mistake, so the current "Undefined reference to function" error tells users all they need to know, methinks.

Perhaps someday an auto-compiling version of mafia will exist, where changes in SVN can be applied instantly by clicking a button. :D But then danger would be out of a job, and the scripting community would miss his fun comments on daily build threads.
 

dj_d

Member
Bumpity bump bump. This has been happening quite a bit lately (example) thanks the the ever-expanding pace of awesomeness of the mafia devs. I would really like the ability to give a clear error message of "Your version is older than the version I tested on, so this script won't run until you upgrade". Pretty please?
 

Catch-22

Active member
Bumpity bump bump. This has been happening quite a bit lately (example) thanks the the ever-expanding pace of awesomeness of the mafia devs. I would really like the ability to give a clear error message of "Your version is older than the version I tested on, so this script won't run until you upgrade". Pretty please?

Doesn't the CLI command "version" already tell you the current version? You could then check that against a constant in your script :)
 

Bale

Minion
It would be nice if cli_execute would return a string, that string being the CLI output of the command it is executing.
 

Alhifar

Member
That will probably never happen; for one, it would allow unrestricted mall searches. I know jason had a few other reasons as well in some other topic that it came up in.
 

Catch-22

Active member
I don't think that works for major numbers like 13.5, does it?

It will say the major number. As far as I can tell, the major builds aren't built from a stable tree, they're more like a "Hey.. It's been a while since we had a major number.. Let's do one!" kinda thing.

Yeah, I know, but it would be useful for many, many things...

Tell me about it. Alhifar lurks well, I have asked for this before. It's likely never going to happen, although maybe now that you have asked for it the devs will have a change of heart implement it, haha ;)

You can, however, interpret debug log results to determine CLI output, which as it so happens can also be used for unrestricted mall searches. Go figure.

Obviously an ASH version() function would be better...
 
Last edited:

Bale

Minion
The problem with a version() function is that sometimes it would return a release number and other times it would return a revision number. It's rather troublesome, but I suppose that decoding the meaning of the output could be left to teh script writer.

I'll still stick to the concept of caveat emptor. Anyone downloading scripts from this site should be able to download the latest version or else he gets what he deserves for his foolishness. It's not so hard to figure out after all. (Yes, I know how many people complain when they can't figure out that they need to upgrade mafiia, but I have no pity for anyone acts that way.)
 
Top