Code wish
Moderator: Forum Moderators
Code wish
I´ve seen the macro DEBUG_MSG MSG. But it is no real debug message. All you can do with it is to comment it out.
I would rather like to see something like:
(DEBUG:debug mode)
Is this any possible?
I would rather like to see something like:
Code: Select all
#ifdef DEBUG
(stuff)
#endif
Is this any possible?
First read, then think. Read again, think again. And then post!
You mean you want to check if the user has entered debug mode? If so, that should not be done with preprocessor commands.
The preprocessor only evaluates once, at load time.[/code]
The preprocessor only evaluates once, at load time.[/code]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
I meaned an if definition for things wich should only happen if the user is in the debug mode. Example:
Other ideas I have to solve it are
To write a macro for such stuff, put it in, and comment it out.
To make an own "difficulty" for debugging. The problem is that probably all users would play the debug mode of the campaign then.
And what would you suggest instead of an if definition?
Code: Select all
(complicated variable stuff)
#ifdef DEBUG
[message]
speaker=narrator
message=_"variableone has the value |$variableone|. Do you want to change it?"
[option]
message=_"yes"
[command]
[message]
speaker=narrator
message=_"What operation?
[option]
message=_"Addition"
[command]
{VARIABLE op add}
[/command]
[/option]
[option]
message=_"Multiply"
[command]
{VARIABLE op multiply}
[/command]
[/option] #only 2 options to show what i mean
[/message]
{VARIABLE arg 0}
[while]
[variable]
name=exitloop
equals=0
[/variable]
[do]
[message]
speaker=narrator
message=_"Do you want to do |$operation|=|$arg| with the variable or increase the argument?"
[option]
message=_"Yes"
[command]
{VARIABLE exitloop 1}
{VARIABLE_OP variableone ($operation) ($arg)}
[/command]
[/option]
[option]
message=_"No, I wanna add 1 to the argument number."
[command]
{VARIABLE_OP arg add 1}
[/command]
[/option]
[/message]
[/do]
[/while]
{CLEAR_VARIABLE exitloop}
{CLEAR_VARIABLE operation}
{CLEAR_VARIABLE arg}
[/option]
[option]
message=_"No."
[command] [/command]
[/option]
[/message]
#endif
To write a macro for such stuff, put it in, and comment it out.
To make an own "difficulty" for debugging. The problem is that probably all users would play the debug mode of the campaign then.
And what would you suggest instead of an if definition?
First read, then think. Read again, think again. And then post!
-
- Retired Developer
- Posts: 2633
- Joined: March 22nd, 2004, 11:22 pm
- Location: An Earl's Roadstead
It seems the easiest thing to do would be to make the debug variable available to WML then you could use it in an [if] tag something like:
That would probably not be too difficult a change to make to the C++ code. Anyone want to write a patch?
Code: Select all
[if]
[variable]
name=DEBUG
equals=true
[/variable]
[/if]
"you can already do that with WML"
Fight Creeeping Biggerism!
http://www.wesnoth.org/forum/viewtopic. ... 760#131760
http://www.wesnoth.org/forum/viewtopic. ... 1358#11358
To be consistent with other WML booleans, it should be yes/no instead of true/false. I'll take a look into the code. I'm still learning my way around it, though.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."