Abs function

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
georgido
Space Floater
Posts: 24
Joined: Sat Jan 12, 2013 4:56 pm

Abs function

#1 Post by georgido »

not sure if there are some other files that need changes, seems ok to me and compiled just fine... have a look and tell me if i missed something...

EDIT: any code provided here by me is released under GPL 2.0
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Last edited by georgido on Wed Jan 23, 2013 8:37 am, edited 1 time in total.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12771
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Abs function

#2 Post by Geoff the Medio »

Please edit your post to note that you release any changes under the GPL 2.0 or later.

georgido
Space Floater
Posts: 24
Joined: Sat Jan 12, 2013 4:56 pm

Re: Abs function

#3 Post by georgido »

Geoff the Medio wrote:Please edit your post to note that you release any changes under the GPL 2.0 or later.
done

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12771
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Abs function

#4 Post by Geoff the Medio »

Have you tested using the new Abs function in a content script?

georgido
Space Floater
Posts: 24
Joined: Sat Jan 12, 2013 4:56 pm

Re: Abs function

#5 Post by georgido »

Geoff the Medio wrote:Have you tested using the new Abs function in a content script?
should have mentioned it before, not sure how to test it...

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12771
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Abs function

#6 Post by Geoff the Medio »

Use it in a content script for an effect on a building, ship, tech, or similar. There are examples of using sin and cos in buildings.txt

georgido
Space Floater
Posts: 24
Joined: Sat Jan 12, 2013 4:56 pm

Re: Abs function

#7 Post by georgido »

Geoff the Medio wrote:Use it in a content script for an effect on a building, ship, tech, or similar. There are examples of using sin and cos in buildings.txt
ook tested it and worked fine... changed the buildcost of the evacuation building in buildings.txt from 10 to abs(50) and then to abs(-50) and both times the cost appeared as 50.0 in the building list... tried also for abs(0) and cost appeared as 0.0
also tried for non-integer values (abs(0.5) and abs(-0.5)) and got the results expected (0.50)... if there's any other case you'd like me to test, tell me...

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12771
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Abs function

#8 Post by Geoff the Medio »

Couple things about the patch:
* Replace tabs with four spaces.
* You could probably use std::abs or similar to simplify the implementation of the actual absolute value calculation.

georgido
Space Floater
Posts: 24
Joined: Sat Jan 12, 2013 4:56 pm

Re: Abs function

#9 Post by georgido »

Geoff the Medio wrote:Couple things about the patch:
* Replace tabs with four spaces.
* You could probably use std::abs or similar to simplify the implementation of the actual absolute value calculation.
there you are... tested as well...
again, any code provided is released under GPL 2.0
Attachments

[The extension patch has been deactivated and can no longer be displayed.]


Post Reply