Author Topic: [FIXED] It is possible to go into negative global funds, when selling a facility  (Read 789 times)

Offline Extremator

  • Squaddie
  • *
  • Posts: 9
    • View Profile
Modders actively use the negative cost of demolishing structures for their own insidious purposes!
If a negative price is specified, then you can destroy the structure by losing more money than you had. Is it possible to somehow prevent this and block this type of operation?

As an option: At the game engine level, change "Return -$100000" to "Costs $100000" if the cost of this action is less than 0.

Offline Delian

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: Return to negative cost
« Reply #1 on: March 18, 2025, 01:06:16 pm »
Might also be useful to colorize the cost number red or green.

Offline Extremator

  • Squaddie
  • *
  • Posts: 9
    • View Profile
Re: Return to negative cost
« Reply #2 on: March 18, 2025, 01:10:17 pm »
I support this!

As well as the ability to enter colortags for text.
|c00ff0000to_red_text|r or [ color=#ff0000]to_red_text[ /color] > to_red_text
« Last Edit: March 18, 2025, 01:13:58 pm by Extremator »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9487
    • View Profile
Re: Return to negative cost
« Reply #3 on: March 18, 2025, 01:14:10 pm »
Is it possible to somehow prevent this and block this type of operation?

Read, and don't click the button?

Might also be useful to colorize the cost number red or green.

There is no red or green text color in basescape.

The only available colors are:
- UFO: white, lightblue, gold, pink, purple
- TFTD: white, lightblue, lightgreen

Offline Extremator

  • Squaddie
  • *
  • Posts: 9
    • View Profile
Re: Return to negative cost
« Reply #4 on: March 18, 2025, 01:18:54 pm »
Read, and don't click the button?

I can't build structures if I don't have the money for them. But I can make "improvements" if I don't have the money for them. Do you understand the difference? Or am I expressing myself incorrectly?

(I am not a student of English, sorry...)

Offline Delian

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: Return to negative cost
« Reply #5 on: March 18, 2025, 02:09:51 pm »
There is no red or green text color in basescape.

Elaborate. The "dismantleFacility" has only those 5 colors defined for the elements but, isn't it possible to add more colors to an interface? The basescape palette does have red and green colors, no?

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9487
    • View Profile
Re: Return to negative cost
« Reply #6 on: March 18, 2025, 02:31:18 pm »
Elaborate. The "dismantleFacility" has only those 5 colors defined for the elements but, isn't it possible to add more colors to an interface? The basescape palette does have red and green colors, no?

the UFO basescape palette has only 5 text colors (or better said color ranges):
1. white: 208 (209-213)
2. lightblue: 218 (219-223)
3. gold: 213 (214-218)
4. pink: 241 (242-246)
5. purple: 246 (247-251)

All other color ranges were not meant for text and look like shit (or worse).

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9487
    • View Profile
Here visually.

Offline Extremator

  • Squaddie
  • *
  • Posts: 9
    • View Profile
Please note that the original discussion was not about a color palette for text, but about a message about "return -$100,000", which I would like to replace with "need $100,000". And if nothing is returned - then a completely different text (as an alternative for styling the mod).

Also, I would like to draw attention to the fact that sometimes some items are needed, and this is visible during construction. Is it possible to expand and add this information in case of demolition of buildings? (show what will be returned)

And what about negative expenses for the maintenance of buildings? Is it possible to also replace the display of this line with "Income" and remove the negative sign? ;)

Offline Yankes

  • Commander
  • Global Moderator
  • Commander
  • *****
  • Posts: 3462
  • Posts: 421
    • View Profile
One solution I would see is simply add optional transnational like:
Code: [Select]
translation = "STR_REFUND_VALUE";
negative_translation = "STR_REFUND_VALUE_NEGATIVE";
if (tr(negative_translation).exist() and value < 0)
{
    value *= -1;
    translation= negative_translation;
}
setText(tr(translation).arg(value));

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9487
    • View Profile
I can't build structures if I don't have the money for them. But I can make "improvements" if I don't have the money for them. Do you understand the difference? Or am I expressing myself incorrectly?

Yes, understood.
It will be fixed.

Please note that the original discussion was not about a color palette for text, but about a message about "return -$100,000", which I would like to replace with "need $100,000".

Can be done.

And if nothing is returned - then a completely different text (as an alternative for styling the mod).

When nothing is returned, nothing is shown, for vanilla backwards-compatibility.

Also, I would like to draw attention to the fact that sometimes some items are needed, and this is visible during construction. Is it possible to expand and add this information in case of demolition of buildings? (show what will be returned)

Yes, it is possible.
Please note that the original discussion was not about this.

And what about negative expenses for the maintenance of buildings? Is it possible to also replace the display of this line with "Income" and remove the negative sign? ;)

Yes, it is possible.
Please note that the original discussion was not about this.

I support this!

As well as the ability to enter colortags for text.
|c00ff0000to_red_text|r or [ color=#ff0000]to_red_text[ /color] > to_red_text


Not doable.
Please note that the original discussion was not about this.

Offline Delian

  • Commander
  • *****
  • Posts: 685
    • View Profile
Here visually.

I see. So we'd need to extend the existing Text surface, because it's currently hardcoded to 5(4?)-size color ranges, but the two color ranges that are interesting (red and green) have 16 colors each.

Offline Extremator

  • Squaddie
  • *
  • Posts: 9
    • View Profile
Please note that the original discussion was not about this.
Yes, I understand that.

I have a lot of ideas, but I can't describe them all in detail and separately. So I mention something close in meaning.

Offline Yankes

  • Commander
  • Global Moderator
  • Commander
  • *****
  • Posts: 3462
  • Posts: 421
    • View Profile
I see. So we'd need to extend the existing Text surface, because it's currently hardcoded to 5(4?)-size color ranges, but the two color ranges that are interesting (red and green) have 16 colors each.
Not text surface, surface have 255 colors like any other graphic, problem is font have limited range of values set, and if you apply offset to mach some range
of colors from 255, only one that Meridian show look right as they where designed to used by fonts.

Final color of font character color is `common_offset + pixel` and fonts have `pixel` range of 0-4 values. Offset can be `200` or different depending what color you want.
If I understand correctly to allow other colors we would need add multiplier to `pixel` to have it bigger range than now to have better gradient.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9487
    • View Profile
Fixed: https://github.com/MeridianOXC/OpenXcom/commit/94d3f3825b31a84167fe2db05e319dce25f82733

Code: [Select]
  STR_REFUND_VALUE: "Sales value> {ALT}{0}"
  STR_REFUND_VALUE_NEGATIVE: "Expenses> {ALT}{0}"