Author Topic: ADD_SECTYPE oddity  (Read 743 times)

Offline DavidW

  • Planewalker
  • *****
  • Posts: 316
ADD_SECTYPE oddity
« on: June 02, 2020, 01:36:29 PM »
I'm not quite 100% sure of this, but it looks to me as if ADD_SECTYPE will check the main game directory for msectype.2da, and will use that version in preference to the one in the override if it finds it. If so, I assume that isn't an intended feature? It's quite an edge case, to be sure, but I got an odd SCS bug that eventually I (think I) tracked to the user having a bespoke copy of msectype.2da in the main game directory.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: ADD_SECTYPE oddity
« Reply #1 on: June 02, 2020, 02:47:51 PM »
I cannot reproduce this. Can you provide any more information?

Looking at the code, ADD_SECTYPE uses common resource-loading code, so I don't think it could behave the way you describe unless you use --search to specifically include "." or equivalent. I could, of course, be overlooking something.

Offline DavidW

  • Planewalker
  • *****
  • Posts: 316
Re: ADD_SECTYPE oddity
« Reply #2 on: June 08, 2020, 01:14:08 PM »
Sorry, only just saw your reply. I'll see if I can put together a stable reproduction case.

Offline DavidW

  • Planewalker
  • *****
  • Posts: 316
Re: ADD_SECTYPE oddity
« Reply #3 on: June 08, 2020, 01:34:04 PM »
OK, here's a micro-mod that reproduces the problem.

Code: [Select]
BACKUP ~sectype_demo/backup~
AUTHOR ~blah~
VERSION ~v1~
AUTO_EVAL_STRINGS

ALWAYS

// copy over a fresh msectype.2da for reliable reproducibility

<<<<<<<< .../stratagems-inline/msectype.2da
2DA V1.0
4294967296
            RES_REF
None 4294967296
SpellProtections 27980
SpecificProtections 27981
IllusionaryProtections 27982
MagicAttack 27983
DivinationAttack 27984
Conjuration 27986
CombatProtections 34558
Contingency 34559
Battleground 34560
OffensiveDamage 34561
Disabling 34562
Combination 34564
Non-combat 34565
>>>>>>>>

COPY ".../stratagems-inline/msectype.2da" "override"



END

BEGIN "component_1" DESIGNATED 10

ADD_SECTYPE "demo_sectype" "a_string"

ADD_SECTYPE "demo_sectype" "another_string"




BEGIN "component_2" DESIGNATED 20

ADD_SECTYPE "demo_sectype" "a_string"

COPY_EXISTING "msectype.2da" "msectype.2da"
REPLACE_TEXTUALLY "demo_sectype.*" ""

ADD_SECTYPE "demo_sectype" "another_string"

Component 1 attempts to install two copies of the same sectype. If you run it, you get 'MSECTYPE.2DA [demo_sectype] already present! Skipping!', and only one copy of 'demo_sectype' added to msectype.2da.

Component 2 does the same, but in between the two ADD_SECTYPEs, msectype.2da is copied to the game directory and the new sectype is deleted. If you run this one, it installs two copies of 'demo_sectype' (in 'override/msectype.2da').

My inference is that while ADD_SECTYPE always adds to the override version, it preferentially checks the game-directory version when it looks to see if the sectype is present already.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: ADD_SECTYPE oddity
« Reply #4 on: June 08, 2020, 04:20:02 PM »
Ah, that did it. Thank you. What happens is that when ADD_SECTYPE checks to see if the sectype is already present, it uses code that checks the file system first, before attempting to load the game resource. So it sees that ./msectype.2da does not contain the search term and appends to override/msectype.2da.

Offline Angel

  • Planewalker
  • *****
  • Posts: 138
Re: ADD_SECTYPE oddity
« Reply #5 on: June 09, 2020, 05:26:52 AM »
I would be the one who reported that bug.  Can confirm that it was due to a different msectype.2da sitting in the main game directory.  I had left it there after extracting it with weidu --biff-get for examination.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: ADD_SECTYPE oddity
« Reply #6 on: August 22, 2020, 06:42:44 AM »
Fixed. Next WeiDU will include the value RESOURCE_CONTAINS which will be used in these types of internal look-ups. RESOURCE_CONTAINS works like FILE_CONTAINS_EVALUATED but does not search files that are not biffed or in an override directory.
« Last Edit: August 22, 2020, 06:44:38 AM by Wisp »

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: