Code wish

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Code wish

Post by toms »

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:

Code: Select all

#ifdef DEBUG
 (stuff)
#endif
(DEBUG:debug mode)
Is this any possible?
First read, then think. Read again, think again. And then post!
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient »

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]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

I meaned an if definition for things wich should only happen if the user is in the debug mode. Example:

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
Other ideas I have to solve it are
:arrow: To write a macro for such stuff, put it in, and comment it out.
:arrow: 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!
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

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:

Code: Select all

[if]
  [variable]
    name=DEBUG
    equals=true
  [/variable]
[/if]
That would probably not be too difficult a change to make to the C++ code. Anyone want to write a patch?
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient »

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."
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Darth Fool wrote: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:
[if]'s can only be used in events, so that kind of solution would enable "debugging" of only some things, not all.
Post Reply