rofl0r / agsutils

contains utils for AGS: game extractor, repacker, disassembler and assembler
44 stars 14 forks source link

Issue with agsprite and spritecache version #24

Closed abohl69 closed 2 years ago

abohl69 commented 2 years ago

Hello, I am trying to update a language patch for a video game. And it seems that I have a problem with the spritecache version. The game seems working with version 11 of spritecache but agsprite converts the spritecache to version 6. I have the message : warning: converting spritecache version 11 to version 6. The game I am trying to modify seems working with version 11. It crashes if we give it a spr file with spritecache version 6. What is the difference between version11 and 6. And how to get a workaround for this issue ? Thank you in advance.

rofl0r commented 2 years ago

can you tell me which game it is ? and is the spr file > 2 GB ? spritecache versions > 6 are using 64 bit offsets, which is needed for files > 2 GB (or 4GB, in later engine versions). also, which agsutils version are you running, and on which platform ?

abohl69 commented 2 years ago

The spr file 544 Mb. The game is ShardLight by Wadjet Eye. The game is in English. But there already exists a French language Patch. But Wadjet Eye changed their version of AGS and the French patch make the game crashing. I am using the last version of agsprite.exe (0.9.7). acsprset.7z.zip

If I unpack the original (English) spr file and re-pack it with agsprite I got the message "warning: converting spritecache version 11 to version 6" and the game is stuck when launching. I send you the original spr file 7-zipped attached (with extension zip to be accepted here.

rofl0r commented 2 years ago

i finally got around to test this with shardlight demo (which uses the old format), but what i noticed is that after repack the game hangs. however, this is expected because one also needs to recreate the spriteindex like so agsprite i F/acsprset.spr F/sprindex.dat, because if you keep the old sprindex, the indices dont match the actual data. with that done, and injectecting both files into the game pack, the game runs without issues. did you try that ?

abohl69 commented 2 years ago

Hello ! Yes I have tried it. But it does not work for me. I have the GoG version of the game. If I add the u option for the creation of the acsprset.spr file it crashes completely. Without the u option it hangs. My script is :

agsprite c resO/acsprset.spr spr/ agsprite i resO/acsprset.spr resO/sprindex.dat

One thing that is very strange is the size of the .spr file :

the original sprindex.dat file is 317 Ko. when repacked the sprindex.dat file is always 212 Ko. Does it suggest you any idea ?

rofl0r commented 2 years ago

If I add the u option for the creation of the acsprset.spr file it crashes completely.

you mean the exe supplied by GOG crashes ? also, do you use agspack with the option to recreate the exe stub ?

repack without the u option : 103 797 Ko

that's roughly identical to the contents of the folder with the extracted sprites, it appears they compress quite well with rle which agsprite automatically does for the tga's when the compressed filesize is smaller than the original filesize, so it doesn't seem surprising.

repack with the u option : 543 995 Ko

that indicates the original is saved uncompressed, as the filesize is identical. which is a bit surprising in that the repack should be at least a little bit smaller due to using only 32bit offsets

when repacked the sprindex.dat file is always 212 Ko.

this again is not surprising as we write 32bit indexes instead of 64bit, and the file consists to a big percentage only of offsets.

did you try whether the repacked exe/.ags file works with the standalone ags engine (after injecting both new .spr and sprindex) ?

abohl69 commented 2 years ago

I have learned to repack with agspack. And I have tested all the possibilities. It does not change anything. Same behaviour. If you copy acsprset.spr/sprindex.dat files in the game folder or if you repack all in an exe with agspack you have the same behaviour. With u option or without u option. The only one that works is the original acsprset.spr/sprindex.dat couple files copied in the folder game or repack with agspack in an exe file. I don't known what to do. The unpacking/repacking of acsprset.spr/sprindex.dat files seems to be problematic.

rofl0r commented 2 years ago

you can also try to remove the sprindex.dat - ags works without it too.

did you try the standalone ags engine https://github.com/adventuregamestudio/ags/releases/download/v.3.6.0.27/AGS-3.6.0.27-Beta7.zip to load the repacked exe/.ags ?

if you have an IRC client (e.g. mirc) you may come to #ags on irc.libera.chat so we can discuss in real time.

abohl69 commented 2 years ago

I have tried the acwin.exe of AGC 3.6.0.27 Beta 7 and the result is the same. I have tried also scummvm which is able to play AGS games : the game is reckognized as a variant of Shardlight steam and it refuses to play it. Nevertheless, it plays the demo of the game. My conclusion is : the GoG version I have is no more compatible with AGS. I don't known what thez have done but it is a broken AGS game. I don't have an IRC client. I think I give up. Thanks for your help.

rofl0r commented 2 years ago

please don't give up yet. it's possible there's a bug only manifesting in the windows build. use https://web.libera.chat/ webchat to connect and go to channel #ags, thanks. i need a certain information from you which i can't publically disclose in order to debug this.

abohl69 commented 2 years ago

I am connected to Libera Chat room #ags

rofl0r commented 2 years ago

turned out that agsprite.exe in "i" (sprite index) mode didn't use binary mode for fopen, so windows build replaced all occurences of "\n" (i.e. 0xa) with "\r\n" and created an invalid sprindex.dat file. fixed version is in this zip file: https://0x0.st/ouVN.zip