0.9.2+ New WML preprocessor

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.
Invisible Philosopher
Posts: 873
Joined: July 4th, 2004, 9:14 pm
Location: My imagination
Contact:

Post by Invisible Philosopher »

I'm having serious problems with apparently valid WML. For example, using the same CVS, and having no .cfg files in {~campaigns} except this (which there exactly one newline at the end of if you can't tell):

Code: Select all

#ifdef NEVER_DEFINED
#endif

, I get errors that don't happen if that file is not there:

Code: Select all

error config: #ifdef not terminated, started at 1 /Users/isaac//Library/Preferences/Wesnoth/data/campaigns/zfinal.cfg 30 data/game.cfg
Error loading game configuration files
error general: Error loading game configuration files: 'Missing closing tag for tag campaign at data/campaigns/The_Rise_of_Wesnoth.cfg:1 included from data/game.cfg:29 at data/scenario-test.cfg:254 included from data/game.cfg:1717' (The game will now exit)
The last error is displayed in Wesnoth and the game does indeed exit.

A similar thing happens with

Code: Select all

#define A_DEFINE
#enddef

in that file instead. When trying to use some campaign cfg files, I get various errors whose cause I don't understand.
Play a Silver Mage in the Wesvoid campaign.
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Post by silene »

I can't reproduce it.

Code: Select all

$ cat ~/.wesnoth/data/campaigns/*.cfg
#define A_DEFINE
#enddef
Nothing strange happens: the cache is rebuilt, the game starts fine. Same with #ifdef.
Invisible Philosopher
Posts: 873
Joined: July 4th, 2004, 9:14 pm
Location: My imagination
Contact:

Post by Invisible Philosopher »

Very odd. It makes sense that you can't reproduce it, because then you already would have known about it. I suppose it's possible that I have something changed in my version that I'm not aware of.... is there a way I can check that?
Play a Silver Mage in the Wesvoid campaign.
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Post by silene »

Invisible Philosopher wrote:Very odd. It makes sense that you can't reproduce it, because then you already would have known about it.
Not necessarily. I didn't test the preprocessor with "empty" files. Since it was a corner-case situation, I wouldn't have been surprised if something wrong was happening.
Invisible Philosopher wrote:I suppose it's possible that I have something changed in my version that I'm not aware of.... is there a way I can check that?
If you are using a CVS repository, you can do a "cvs diff", it will give the differences between your local files and the files of Wesnoth repository at the time you last updated them. So it will only show your modifications, not the ones that have been applied since then.
Invisible Philosopher
Posts: 873
Joined: July 4th, 2004, 9:14 pm
Location: My imagination
Contact:

Post by Invisible Philosopher »

silene wrote:If you are using a CVS repository, you can do a "cvs diff", it will give the differences between your local files and the files of Wesnoth repository at the time you last updated them. So it will only show your modifications, not the ones that have been applied since then.
The only real difference I found doing that was my --preprocess command-line option, and there's no way that could be affecting normal Wesnoth use. Of course, there are other differences like OS (I use Mac OS X) and zipios (which I don't use), which shouldn't make a difference, but it's not so obvious when there are bugs...
silene wrote:
Invisible Philosopher wrote:Very odd. It makes sense that you can't reproduce it, because then you already would have known about it.
Not necessarily. I didn't test the preprocessor with "empty" files. Since it was a corner-case situation, I wouldn't have been surprised if something wrong was happening.
The thing is, I only made that file because I was experiencing errors elsewhere in normal user-made campaign cfg files. One thing I did try though (and getting more inexplicable results), was putting that problematic file in data/themes, the first place game.cfg includes. It didn't cause any error there.

EDIT: I found out that what my Wesvoid campaign file was doing "wrong" was having #ifdef on the last line without any newline after that. At least, Wesnoth didn't complain any more when I put a newline at the end of the file. At least it's some evidence, even if it doesn't explain why my simple test file fails.
EDIT 2: I'm having another problem. In abbreviated form (hopefully I didn't leave out anything important) (it's actually spread over multiple files):

Code: Select all

#define WESVOID_DATA_PATH
campaigns/Wesvoid#enddef

#define CAMPAIGN_INCLUDE PATH
{(@{WESVOID_DATA_PATH}/{PATH})}#enddef

{CAMPAIGN_INCLUDE utils}
#and some other things...
It's including data/game.cfg somehow, leading to infinite recursion. :( Although I doubt it worked under the old preprocessor either.


Also I found out that Wesnoth's cache sometimes doesn't get invalidated when it should: when I only rename files' extensions between .cfg and .cfgx to determine whether they get included, that doesn't invalidate Wesnoth's cache for me.
Play a Silver Mage in the Wesvoid campaign.
Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Post by Rhuvaen »

I was having trouble with the new preprocessor in a scenario that used EP's PSEUDORANDOM code from the wiki. The game gave a bogus error message complaining about expected characters after a variable name on a line in which there was no variable. When I cut out the following comments that included a macro name in curly braces, the game started and played the scenario without the error message:

Code: Select all

 #Instead of {RANDOM 0..155}, use {PSEUDORANDOM 156}. This is the only way to use it.
 #You can use {VARIABLE_OP random add X} afterwards to get a higher range.
Is it trying to recurse into the macro even in comments? :shock:
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Post by silene »

Rhuvaen wrote:Is it trying to recurse into the macro even in comments?
No. Please provide a self-contained testcase so that I can reproduce it.


Damn, I noticed only now that Invisible Philosopher had edited his post.
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Post by silene »

Invisible Philosopher wrote:

Code: Select all

#define WESVOID_DATA_PATH
campaigns/Wesvoid#enddef

#define CAMPAIGN_INCLUDE PATH
{(@{WESVOID_DATA_PATH}/{PATH})}#enddef

{CAMPAIGN_INCLUDE utils}
#and some other things...
It's including data/game.cfg somehow, leading to infinite recursion. :( Although I doubt it worked under the old preprocessor either.
You are right, it wouldn't have worked with the old preprocessor. And it works fine for me with the new preprocessor. I just put a file plouf.cfg in my data/campaigns directory and another one deeper in the Wesvoid/utils directory.

Code: Select all

info filesystem: streaming data/campaigns/plouf.cfg for reading.
info config: defining macro WESVOID_DATA_PATH
info config: defining macro CAMPAIGN_INCLUDE
info config: substituting macro CAMPAIGN_INCLUDE
info config: substituting (slow) macro WESVOID_DATA_PATH
info filesystem: streaming data/campaigns/Wesvoid/utils/a.cfg for reading.
But once again it may be because I use a zipios-enabled build; it uses a different way of dealing with filesystem structure. I don't see any obvious bug with the zipios-disabled version though. File localization was simply copy-pasted from the old preprocessor, I didn't rewrite a single line of it. Laziness...
ryn
Posts: 196
Joined: August 23rd, 2004, 4:01 am
Location: Israel

Post by ryn »

Something similar to what Invisible Philosopher is describing is occuring on my machine too:
"
Missing closing tag for tag scenario at /root/.wesnoth/data/campaigns/Northern_Rebirth/scenarios/Breaking_the_Chains.cfg:1 included from /root/.wesnoth/data/campaigns/Northern_Rebirth.cfg:32 included from data/game.cfg:25 at /root/.wesnoth/data/campaigns/Northern_Rebirth/scenarios/Breaking_the_Chains.cfg:43 included from /root/.wesnoth/data/campaigns/Northern_Rebirth.cfg:32 included from data/game.cfg:25
"
and it exits. It seems to happen with every user campaign. Gentoo Linux portage build
2B |! 2B = 3F
ott
Inactive Developer
Posts: 838
Joined: September 28th, 2004, 10:20 am

Post by ott »

ryn wrote:Missing closing tag for tag scenario at /root/.wesnoth/data/campaigns/Northern_Rebirth/scenarios/Breaking_the_Chains.cfg:1
This is because Northern Rebirth is buggy -- remove it, remove your cache files, restart, and you should be fine. If you are feeling energetic, you could try syntax checking the campaign and mailing the author with the fixes.
This quote is not attributable to Antoine de Saint-Exupéry.
ryn
Posts: 196
Joined: August 23rd, 2004, 4:01 am
Location: Israel

Post by ryn »

sorry, already tried that. Unsuccessfully :oops:
2B |! 2B = 3F
sanna
Posts: 425
Joined: June 5th, 2004, 9:59 am
Location: Halmstad, Sweden

Post by sanna »

ott wrote:
ryn wrote:Missing closing tag for tag scenario at /root/.wesnoth/data/campaigns/Northern_Rebirth/scenarios/Breaking_the_Chains.cfg:1
This is because Northern Rebirth is buggy -- remove it, remove your cache files, restart, and you should be fine. If you are feeling energetic, you could try syntax checking the campaign and mailing the author with the fixes.
There were 2 wrongly terminated strings in Northern Rebirth that I have notified Taurus about, and that he is fixing, and preparing to upload a new version. Not sure if it will solve this problem or not, but trying his new version once it hits the campaign server might be a good idea.
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

This topic has been changed from an announcement to a normal post. Please ensure the changes described here are properly documented in the wiki or elsewhere.
Hope springs eternal.
Wesnoth acronym guide.
Post Reply