Author Topic: Locking STR_SOLDIER behind research is crashing the game.  (Read 1450 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Locking STR_SOLDIER behind research is crashing the game.
« on: December 25, 2021, 11:53:20 am »
(OXCE Version: 7.2 v2021-12-24)

I'm encountering a crash to desktop.

The crash is triggered by starting a new game from the main menu and pressing 'ok' on the difficulty selection screen while my mod is running.

The line of code that appears to be causing the problem is the following:
Code: [Select]
soldiers:
  - type: STR_SOLDIER
    requires: # <----------------------
      - DoesNotExist # <---------------

I'm getting the following error displayed in the linux terminal window I'm running OXCE from after it crashes:
"Floating point exception (core dumped)"


For some reason locking the STR_SOLDIER behind research is causing the 'Float point exception (core dumped)' error.

Is this the wrong way to prohibit the player from purchasing X-Com soldiers from the "Purchase/Recruit" menu?


The openxcom.log file doesn't appear to display any error messages:
Code: [Select]
[25-12-2021_02-40-56] [INFO] OpenXcom Version: Extended 7.2 (v2021-12-24)
[25-12-2021_02-40-56] [INFO] Platform: Linux
[25-12-2021_02-40-56] [INFO] Data folder is:
[25-12-2021_02-40-56] [INFO] Data search is:
[25-12-2021_02-40-56] [INFO] - /home/name/.local/share/openxcom/
[25-12-2021_02-40-56] [INFO] - /usr/share/mate/openxcom/
[25-12-2021_02-40-56] [INFO] - /home/name/.local/share/flatpak/exports/share/openxcom/
[25-12-2021_02-40-56] [INFO] - /var/lib/flatpak/exports/share/openxcom/
[25-12-2021_02-40-56] [INFO] - /usr/local/share/openxcom/
[25-12-2021_02-40-56] [INFO] - /usr/share/openxcom/
[25-12-2021_02-40-56] [INFO] - /usr/local/share/openxcom/
[25-12-2021_02-40-56] [INFO] - /usr/share/openxcom/
[25-12-2021_02-40-56] [INFO] - ./
[25-12-2021_02-40-56] [INFO] User folder is: ./user/
[25-12-2021_02-40-56] [INFO] Config folder is: /home/name/.config/openxcom/
[25-12-2021_02-40-56] [INFO] Options loaded successfully.
[25-12-2021_02-40-56] [INFO] SDL initialized successfully.
[25-12-2021_02-40-56] [INFO] SDL_mixer initialized successfully.
[25-12-2021_02-40-56] [INFO] Attempted locale: C.UTF-8
[25-12-2021_02-40-56] [INFO] Detected locale: C.UTF-8
[25-12-2021_02-40-56] [INFO] Attempting to set display to 1280x720x8...
[25-12-2021_02-40-56] [INFO] Display set to 1280x720x8.
[25-12-2021_02-40-56] [INFO] Loading data...
[25-12-2021_02-40-56] [INFO] Scanning standard mods in ''...
[25-12-2021_02-40-56] [INFO] Scanning user mods in './user/'...
[25-12-2021_02-40-57] [INFO] Active mods:
[25-12-2021_02-40-57] [INFO] - xcom2 v1.0
[25-12-2021_02-40-57] [INFO] - AgainTestSoldiers v0.1
[25-12-2021_02-40-58] [INFO] Loading begins...
[25-12-2021_02-40-58] [INFO] Pre-loading rulesets...
[25-12-2021_02-40-58] [INFO] Loading vanilla resources...
[25-12-2021_02-40-58] [INFO] Loading rulesets...
[25-12-2021_02-40-59] [INFO] Loading rulesets done.
[25-12-2021_02-40-59] [INFO] Loading ended.
[25-12-2021_02-40-59] [INFO] Loading fonts... Font.dat
[25-12-2021_02-40-59] [INFO] Lazy loading: 1
[25-12-2021_02-40-59] [INFO] Loading custom palettes from ruleset...
[25-12-2021_02-40-59] [INFO] Making palette backups...
[25-12-2021_02-40-59] [INFO] Data loaded successfully.
[25-12-2021_02-40-59] [INFO] Loading language...
[25-12-2021_02-40-59] [INFO] Language loaded successfully.
[25-12-2021_02-40-59] [INFO] OpenXcom started successfully!
[25-12-2021_02-40-59] [INFO] Using software scaling routine. For best results, try an OpenGL filter.
[25-12-2021_02-44-51] [INFO] SDL_mixer initialized successfully.
[25-12-2021_02-44-51] [INFO] Loading data...
[25-12-2021_02-44-51] [INFO] Scanning standard mods in ''...
[25-12-2021_02-44-51] [INFO] Scanning user mods in './user/'...
[25-12-2021_02-44-51] [INFO] Active mods:
[25-12-2021_02-44-51] [INFO] - xcom2 v1.0
[25-12-2021_02-44-52] [INFO] Loading begins...
[25-12-2021_02-44-52] [INFO] Pre-loading rulesets...
[25-12-2021_02-44-52] [INFO] Loading vanilla resources...
[25-12-2021_02-44-53] [INFO] Loading rulesets...
[25-12-2021_02-44-53] [INFO] Loading rulesets done.
[25-12-2021_02-44-53] [INFO] Loading ended.
[25-12-2021_02-44-53] [INFO] Loading fonts... Font.dat
[25-12-2021_02-44-53] [INFO] Lazy loading: 1
[25-12-2021_02-44-53] [INFO] Loading custom palettes from ruleset...
[25-12-2021_02-44-53] [INFO] Making palette backups...
[25-12-2021_02-44-53] [INFO] Data loaded successfully.
[25-12-2021_02-44-53] [INFO] Loading language...
[25-12-2021_02-44-53] [INFO] Language loaded successfully.
[25-12-2021_02-44-53] [INFO] OpenXcom started successfully!
[25-12-2021_02-47-10] [INFO] SDL_mixer initialized successfully.
[25-12-2021_02-47-10] [INFO] Loading data...
[25-12-2021_02-47-10] [INFO] Scanning standard mods in ''...
[25-12-2021_02-47-10] [INFO] Scanning user mods in './user/'...
[25-12-2021_02-47-10] [INFO] Active mods:
[25-12-2021_02-47-10] [INFO] - xcom2 v1.0
[25-12-2021_02-47-10] [INFO] - AgainTestSoldiers v0.1
[25-12-2021_02-47-12] [INFO] Loading begins...
[25-12-2021_02-47-12] [INFO] Pre-loading rulesets...
[25-12-2021_02-47-12] [INFO] Loading vanilla resources...
[25-12-2021_02-47-12] [INFO] Loading rulesets...
[25-12-2021_02-47-12] [INFO] Loading rulesets done.
[25-12-2021_02-47-12] [INFO] Loading ended.
[25-12-2021_02-47-12] [INFO] Loading fonts... Font.dat
[25-12-2021_02-47-12] [INFO] Lazy loading: 1
[25-12-2021_02-47-12] [INFO] Loading custom palettes from ruleset...
[25-12-2021_02-47-12] [INFO] Making palette backups...
[25-12-2021_02-47-12] [INFO] Data loaded successfully.
[25-12-2021_02-47-12] [INFO] Loading language...
[25-12-2021_02-47-13] [INFO] Language loaded successfully.
[25-12-2021_02-47-13] [INFO] OpenXcom started successfully!



For convenience I've attached an example mod with this code to this post:
TestMod Soldiers V0-1.zip
« Last Edit: December 25, 2021, 11:57:58 am by The Martian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: Locking STR_SOLDIER behind research is crashing the game.
« Reply #1 on: December 25, 2021, 12:39:17 pm »
Is this the wrong way to prohibit the player from purchasing X-Com soldiers from the "Purchase/Recruit" menu?

Yes, this is the wrong way.
You have disabled the soldier type completely, not just for purchase.

The game can't generate any soldiers for the starting base and crashes.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Locking STR_SOLDIER behind research is crashing the game.
« Reply #2 on: December 25, 2021, 01:11:37 pm »
Thank you very much!

I've removed the starting soldiers and the game is now loading correctly:
Code: [Select]
startingBase:
  randomSoldiers: 0

I have two questions:

(1)

Aside from buying from the "Purchase/Recruit" menu what other actions are blocked by locking a soldier type behind research?

(2)
What is the correct way to lock the STR_SOLDIER type from purchase from the "Purchase/Recruit" menu, should I use the requiresBuyBaseFunc: variable instead?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8616
    • View Profile
Re: Locking STR_SOLDIER behind research is crashing the game.
« Reply #3 on: December 25, 2021, 01:48:38 pm »
1/ everything... and what's not blocked is likely a bug

2/ there are many ways... I would need to know what you want to achieve... if you just want to block purchase, you can set `costBuy: 0`

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Locking STR_SOLDIER behind research is crashing the game.
« Reply #4 on: January 18, 2022, 08:44:41 am »
if you just want to block purchase, you can set `costBuy: 0`

Thank you that is what I will do.