Post reply

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:
Subject:
Message icon:

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)?:

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: Wisp
« on: July 22, 2021, 05:11:30 AM »

Thanks. Implemented.
Posted by: DavidW
« on: July 21, 2021, 12:44:55 AM »

Repeated uses of GET_UNIQUE_FILE_NAME just return the same string. Reproduce it like this:

Code: [Select]
OUTER_FOR (n=0;n<10;++n) BEGIN
LAF GET_UNIQUE_FILE_NAME STR_VAR extension=bcs RET filename END
PRINT "returning %filename%"
COPY_EXISTING "wtasight.bcs" "override/%filename%.bcs"
END

The problem is that even when 'base' is set to "", WEIDU still appends a blank entry to GET_UNIQUE_FILE_NAME's ids file, and thereafter just returns that entry.

Here's a fix:

Code: [Select]
DEFINE_PATCH_FUNCTION ~GET_UNIQUE_FILE_NAME~
  STR_VAR
          extension = ""
          base = ""
  RET filename
  BEGIN
    PATCH_IF ~%extension%~ STRING_EQUAL_CASE ~~ THEN BEGIN
      PATCH_FAIL ~GET_UNIQUE_FILE_NAME requires to define the extension variable.~
    END

    INNER_ACTION BEGIN
      ACTION_IF ! FILE_EXISTS_IN_GAME ~get_unique_filename_%extension%.ids~ THEN BEGIN
        <<<<<<<< empty
        >>>>>>>>
        COPY + empty ~override/get_unique_filename_%extension%.ids~
      END
    END

    value = ("%base%" STR_CMP "")? IDS_OF_SYMBOL (~get_unique_filename_%extension%~ ~%base%~): 0 - 1
PATCH_IF value = 0 - 1 THEN BEGIN
      found = 0
      WHILE !found BEGIN
        ++value
        LPF ~BASE36~ INT_VAR value = value RET maybe = base36 END
        LOOKUP_IDS_SYMBOL_OF_INT exists ~get_unique_filename_%extension%~ value
        PATCH_IF IS_AN_INT exists
          && !FILE_EXISTS_IN_GAME ~__%maybe%.%extension%~ THEN BEGIN
          found = 1
        END
      END
      PATCH_IF "%base%" STR_CMP "" BEGIN
  INNER_ACTION BEGIN
APPEND + ~get_unique_filename_%extension%.ids~ ~%value% %base%~
  END
  END
    END ELSE BEGIN
      LPF ~BASE36~ INT_VAR value = value RET maybe = base36 END
    END

    SPRINT filename ~__%maybe%~
END

Now if "base" is blank, we just bypass the IDS lookup altogether.