temnix Posted May 22, 2021 Share Posted May 22, 2021 I need to go through areas, check their containers and, if some flags are set and not set and the "Key" field is empty, enter something in that field. The first part I know how to do, on the monkey-see-monkey-do level, thanks to Luke... COPY_EXISTING_REGEXP GLOB ~.*\.ARE~ ~override~ PATCH_IF (SOURCE_SIZE > 228) THEN BEGIN GET_OFFSET_ARRAY "containers" ARE_V10_CONTAINERS PHP_EACH "containers" AS "ind" => "cont_offset" BEGIN ... I know how to go about changing all containers or, say, all items in them. But now it comes to reading container flags and the Key field, and I can't do that without knowing their offsets. If I could find out, I would do for all containers something like this for the first: READ_LONG 0x4AC flags PATCH_IF ((flags & BIT0) == BIT0) & ((flags & BIT2) != BIT2) THEN BEGIN Then a check for an empty Key field, and after that - to write into that field. Can someone tell me for a big sapphire how to get those offsets? The opposite approach is to use LPF ALTER_AREA_CONTAINER, where I probably don't even need to know the required STR_VAR container_name, if I use INT_VAR silent = 1. I could just make an enormous list beyond the number of containers any area has and shoot in the dark. But even here I would need to know about the flags and the Key field content before patching, or it would be like shooting in the dark with Confucius. Quote Link to comment
Luke Posted May 23, 2021 Share Posted May 23, 2021 18 hours ago, temnix said: But now it comes to reading container flags and the Key field, and I can't do that without knowing their offsets You know the offset, it's "%cont_offset%". So: COPY_EXISTING_REGEXP GLOB ~.*\.ARE~ ~override~ PATCH_IF (SOURCE_SIZE > 228) THEN BEGIN GET_OFFSET_ARRAY "containers" ARE_V10_CONTAINERS PHP_EACH "containers" AS "ind" => "cont_offset" BEGIN READ_LONG ("%cont_offset%" + 0x28) "flags" READ_ASCII ("%cont_offset%" + 0x78) "key_item" Quote Link to comment
temnix Posted May 25, 2021 Author Share Posted May 25, 2021 This is right. Thanks. But where do you get the hex intervals between offsets? I can find out what they are in bytes from the resource file, but people around here seem to have an uncanny ability to count in hexadecimal off the top of their heads. You are all cyborgs, most likely... But helpful sometimes. Quote Link to comment
Luke Posted May 26, 2021 Share Posted May 26, 2021 (edited) 21 hours ago, temnix said: This is right. Thanks. But where do you get the hex intervals between offsets? I can find out what they are in bytes from the resource file, but people around here seem to have an uncanny ability to count in hexadecimal off the top of their heads. The following instruction GET_OFFSET_ARRAY "containers" ARE_V10_CONTAINERS collects all containers' info (i.e., offset, hex intervals between offsets, iterations, and so forth) into the array "containers". Let us consider "AR0016.ARE" as an example. The following code COPY_EXISTING - ~AR0016.ARE~ ~override~ PATCH_IF (SOURCE_SIZE > 228) THEN BEGIN GET_OFFSET_ARRAY "containers" ARE_V10_CONTAINERS PHP_EACH "containers" AS "ind" => "cont_offset" BEGIN PATCH_PRINT "%ind% => %cont_offset%" END END BUT_ONLY will print "current container index => current container offset". In this case: 0 => 1876 1 => 2068 As you can see, there's no need to compute those values manually (from the resource file). PHP_EACH loops through all containers and at each iteration "%cont_offset%" contains the current container offset. Anyway, more info here and here. Edited May 26, 2021 by Luke Quote Link to comment
temnix Posted May 26, 2021 Author Share Posted May 26, 2021 That's more detailed than I care to read. I prefer making mods to that great science. My point is, you still need to count the bytes between the offset for the container name (start) and the one for whether it's locked or its key field. PHP_EACH writes there automatically for all containers, but you have to tell it to do it 20 bytes to the right or 55 bytes to the right of the main value, and I'm mystified how people count from 0x12C to 0x5AE with ease. This is not important, however. Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.