Warning the user about missing dependencies

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
bvanevery
Posts: 338
Joined: August 27th, 2009, 12:47 am
Location: Winston-Salem, NC

Warning the user about missing dependencies

Post by bvanevery »

Is there some WML that will warn the user that they're missing a dependency, such as an Era or a music library? Ideally the warning would issue very clear instructions that the user needs to download the missing dependency. What happens instead, is users see an error, don't know what the problem is, and think the campaign is broken. If we're lucky, they show up in the campaign's feedback forum, we say "Do you have Era of Magic installed?" and they say, "Oh shoot! I'm dumb billy goat!" Problem solved. I hate to think how many don't show up in the forums.
To Lands Unknown, an Arabesque adventure of stunning background art, mobile summoning, and strong storytelling.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Warning the user about missing dependencies

Post by Anonymissimus »

For campaign dependant on an era isn't there some require_era key ? Then the BfW engine should know about the dependency and ideally display an informative error message if it isn't fulfilled. (IIRC there is such a warning - when downloading the addon.)

Other than that - you can use the #ifhave preprocessor directive to check for existance of addons. You could do #ifhave ~add-ons/Some_Era/_main.cfg in your first (dummy, not loading units from that era ?) scenario, and if the era isn't there - message "please get era xy since it's required" + [endlevel]result=defeat. But ideally this should be done by the BfW engine. (Isn't there a warning when starting the campaign too ?)

Btw, in TEG and TSoG the #ifhave directive is used to use the UMC music addon, but only if it is present (so it's not required!).

EDIT
The #ifhave directive is BfW 1.9 only.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: Warning the user about missing dependencies

Post by silene »

Anonymissimus wrote:Btw, in TEG and TSoG the #ifhave directive is used to use the UMC music addon, but only if it is present (so it's not required!).
Also note that, for a multiplayer game, the #ifhave directive works only for the host, not for the other clients.
User avatar
Iris
Site Administrator
Posts: 6797
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: Warning the user about missing dependencies

Post by Iris »

Anonymissimus wrote:(IIRC there is such a warning - when downloading the addon.)
That’d be the .dependencies attribute that may be specified in the publishing info file, _server.pbl. Users can still choose to ignore the dependency resolution warning when downloading the dependant add-on though.

For that matter, I merged a patch from FAAB at the start of the 1.9.x development cycle that makes the confirmation dialog significantly more prominent and potentially more helpful.
Attachments
depsrsv.png
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
User avatar
bvanevery
Posts: 338
Joined: August 27th, 2009, 12:47 am
Location: Winston-Salem, NC

Re: Warning the user about missing dependencies

Post by bvanevery »

I am thinking that the dependencies should be available to the campaign when it runs, not just when it is downloaded from the add-on server. For instance, one might install the campaign manually. I'm actually not sure what's in the _server.pbl for the "To Lands Unknown" campaign because we don't have it under source control at present. The lead developer has it, he only just got back from exams, and he hasn't gone up the Mercurial learning curve yet. I know that once I've downloaded the campaign, I don't have a _server.pbl file or any dependency information anywhere derived from it.
To Lands Unknown, an Arabesque adventure of stunning background art, mobile summoning, and strong storytelling.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Warning the user about missing dependencies

Post by Anonymissimus »

silene wrote:
Anonymissimus wrote:Btw, in TEG and TSoG the #ifhave directive is used to use the UMC music addon, but only if it is present (so it's not required!).
Also note that, for a multiplayer game, the #ifhave directive works only for the host, not for the other clients.
What does "works only for the host" mean ?
Does it mean that the result of the #ifhave evaluation on the host is transferred to the other clients, idependently from whether these actually have or not have the particular file, so that the use case from above (using UMC music only if it's there) would result in stderr message about missing music file and silence on the other clients in the case that only the host has the queried file (whos BfW instance would play the music fine I guess) ?
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
doofus-01
Art Director
Posts: 4122
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Warning the user about missing dependencies

Post by doofus-01 »

All you need to do is #define some empty macro in the era, then have an #ifdef statment at the beginning of the campaign that directs the player to some dummy scenario with a warning in the introduction if that macro is not defined. This is already done in some eras (Archaic and Myths, I think), last I checked it worked fine.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: Warning the user about missing dependencies

Post by silene »

Anonymissimus wrote:Does it mean that the result of the #ifhave evaluation on the host is transferred to the other clients, idependently from whether these actually have or not have the particular file, so that the use case from above (using UMC music only if it's there) would result in stderr message about missing music file and silence on the other clients in the case that only the host has the queried file (whos BfW instance would play the music fine I guess) ?
More precisely, only the host preprocesses the scenario; it is then sent to all the other clients through the server. So only the host is actually testing #ifhave. There is no difference between starting a game and loading one from a savegame: only the host reads the WML data of the scenario.

If the addon had a dummy or innocuous Lua file, you could try to load it instead and see whether it succeeds.
doofus-01 wrote:All you need to do is #define some empty macro in the era, then have an #ifdef statment at the beginning of the campaign that directs the player to some dummy scenario with a warning in the introduction if that macro is not defined.
No. See above. It only works for the host.
User avatar
doofus-01
Art Director
Posts: 4122
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Warning the user about missing dependencies

Post by doofus-01 »

silene wrote: It only works for the host.
Which is good enough for SP campaigns (which is what bvanevery is talking about, as far as I know).
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Warning the user about missing dependencies

Post by Anonymissimus »

Doofus' suggestion is a workaround for 1.8. In 1.9 #ifhave is better - simpler and needs no cooperation with the dependency author (or no need to be the same person...). Neither are usable in MP.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Post Reply