Author Topic: Cycling through CRE files, or optimizing my code  (Read 806 times)

Offline Andrea C.

  • Planewalker
  • *****
  • Posts: 80
  • Gender: Male
Cycling through CRE files, or optimizing my code
« on: May 08, 2016, 05:04:44 AM »
Hi, everyone.

I'm currently making use of the following code to patch CRE files so they use a different animation:

Code: [Select]
ACTION_DEFINE_ASSOCIATIVE_ARRAY cd_animation_map BEGIN

0x6000 => 0x5622
[...]

END

COPY_EXISTING_REGEXP GLOB ~.*\.cre~ ~override~
  READ_LONG 0x28 current
  PATCH_PHP_EACH cd_animation_map AS old => new BEGIN
    PATCH_IF (current = old) BEGIN
      WRITE_LONG 0x28 new
    END
  END
  BUT_ONLY


So far, so good; it works.

However, this copies a disproportionate amount of CRE files into the override that don't really need to be patched, since their animation doesn't match the "old" one specified in my associative array.

So I was wondering: Is it possible to write code that cycles through existing CRE files, reads 0x28, only copies them to the override if 0x28 matches the "old" value in the array, then cycles through copied CRE files and patches from "old" to "new"?

(Probably not strictly needed as the Enhanced Editions run pretty smooth even with several files in the override, but I figured optimizing would still be a good idea.)


Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: Cycling through CRE files, or optimizing my code
« Reply #1 on: May 08, 2016, 05:12:07 AM »
Your code already does that. If the CRE is saved to the override it is because the dword at 0x28 changed during patching, which it only does if "current" matches some "old" in "cd_animation_map".
« Last Edit: May 08, 2016, 05:13:26 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)?: