Titan Quest Fans Forum

Titan Quest - Anniversary Edition => Modifications => Maps and the Editor => Topic started by: epinter on 05 December 2021, 06:12:28

Title: Mapdecompiler updated (Eternal Embers)
Post by: epinter on 05 December 2021, 06:12:28
Hi,

I was trying to extract the map from Eternal Embers, and the mapdecompiler didn't work. I found an old source code here at titanquestfans.net and managed to make a quick change to extract all files from new maps. Editor opened the maps, so I think everything should work... I don't know if there's any other fix needed, feel free to clone the repo and update.

Unfortunately, I didn't found a way to contact the original authors, I only found a link to the source code. I think there's no problem posting on github (the code was already public on mega.nz). If the author wants I can remove from github, no problem, I'm just trying to contribute.


All credits goes to p0a (original author I think) and knightsouldier.

Source code available at github:

https://github.com/epinter/tq-mapdecompiler


Download:

https://github.com/epinter/tq-mapdecompiler/releases

Hope this helps.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: xiaorantu on 05 December 2021, 08:56:54
I download the zip. but don't know how to use it

CMakelists.txt
CMakesetting.json
MAPDecomp.cpp
README.md
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: epinter on 05 December 2021, 09:00:37
Download the mapdecompiler.7z from releases page: https://github.com/epinter/tq-mapdecompiler/releases
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: sauruz on 05 December 2021, 12:18:58
just to say its works out!

Thank you!
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: Medea Fleecestealer on 05 December 2021, 13:48:24
epinter, just had a report that there's a Trojan on the .7z
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: sauruz on 05 December 2021, 13:54:34
its a false positive, i just did had sucess decompile the new map
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: Medea Fleecestealer on 05 December 2021, 14:11:28
Maybe, but he's literally just tried and seen it so the latest fixes haven't worked for false positives.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: epinter on 05 December 2021, 15:49:15
Maybe, but he's literally just tried and seen it so the latest fixes haven't worked for false positives.

I had problem with false positives in Windows Defender, but last commit fixed for me. Using virustotal.com before, I consistently saw Defender and MaxSecure detecting as trojan. After the fix, everything is green on virustotal:

https://www.virustotal.com/gui/file/5296e70c5a1d2549537b648b729ad9ee15d90bba6c40b65f4bca056f317d647a

What antivirus do you have?
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: Medea Fleecestealer on 05 December 2021, 16:09:46
It's not me epinter, but one of my fellow mods.  He's getting it with Windows Defender.  Fine for him with virustotal.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: epinter on 05 December 2021, 16:13:45
It's not me epinter, but one of my fellow mods.  He's getting it with Windows Defender.  Fine for him with virustotal.

Before I published the last version I uploaded some .7z with false positives. Maybe he downloaded the file as soon as I posted here ?
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: Wagi on 05 December 2021, 16:18:32
Hey o/

It's me

Last release 10hours ago
Last edit 8 hours ago

You did not update the release, it seems.

Also, I checked the source and there are issues and lots of warnings using MSVS2019 because you're playing with the memory manually without checks and safety, although it's fine this is hard to read and can be source of issues.
It's working fine though so let's hope it stays like this.

What changed btw ? From Ragnarok to Eternal Embers ? I'm curious.

Wagi
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: epinter on 05 December 2021, 16:42:44
Hey o/

It's me

Last release 10hours ago
Last edit 8 hours ago

You did not update the release, it seems.

Also, I checked the source and there are issues and lots of warnings using MSVS2019 because you're playing with the memory manually without checks and safety, although it's fine this is hard to read and can be source of issues.
It's working fine though so let's hope it stays like this.

What changed btw ? From Ragnarok to Eternal Embers ? I'm curious.

Wagi

The release is updated, I just committed after I built the exe.

Actually I changed just a few lines of code. I saw there's a lot of warnings, but to solve everything would require a time I don't have.

Looks like on every release of the game, somebody got this source and increased the "char fileNames[1024][256]" to 2048 or only a little above. But on every release of dlc, there are always a lot of new files, then the change is needed again... The stack limits the array size, so I used malloc to increase the array to 65535.

Code: [Select]
diff --git a/MAPDecomp.cpp b/MAPDecomp.cpp
index e1ee25d..cd2097d 100644
--- a/MAPDecomp.cpp
+++ b/MAPDecomp.cpp
@@ -10,6 +10,8 @@
 #define SHR_SIZE 2 /*sizeof(unsigned short)*/
 #define FLT_SIZE 4 /*sizeof(float)*/
 #define PTR_SIZE sizeof(void*)
+#define FILENAMES_BUFFER_SIZE 65535
+#define FILENAME_SIZE 256
 
 void mkdirtofile(char* path) {
  size_t length = strlen(path);
@@ -67,7 +69,13 @@ void main(int argc, char **argv) {
  fwrite(sec, INT_SIZE, 1, wrlFile);
 
  bool outOfOrder = true;
- char fileNames[1024][256];
+
+ char ** fileNames = (char **) malloc(FILENAMES_BUFFER_SIZE * sizeof(char*));
+
+ for (int i = 0; i < FILENAMES_BUFFER_SIZE; i++) {
+ fileNames[i] = (char *) malloc(FILENAME_SIZE);
+ }
+
  eofdetect = fgetc(mapFile);
  unsigned char* buffer;
  while (!feof(mapFile) && !ferror(mapFile)) {
@@ -318,12 +326,12 @@ void main(int argc, char **argv) {
  }
  //.sd
  else if (0x18 == sec[0]) {
- sprintf_s(fileNames[1023], 255, "%s", argv[2]);
- *(fileNames[1023]+strlen(fileNames[1023])-3) = 's';
- *(fileNames[1023]+strlen(fileNames[1023])-2) = 'd';
- *(fileNames[1023]+strlen(fileNames[1023])-1) = 0;
+ sprintf_s(fileNames[FILENAMES_BUFFER_SIZE-1], 255, "%s", argv[2]);
+ *(fileNames[FILENAMES_BUFFER_SIZE-1]+strlen(fileNames[FILENAMES_BUFFER_SIZE-1])-3) = 's';
+ *(fileNames[FILENAMES_BUFFER_SIZE-1]+strlen(fileNames[FILENAMES_BUFFER_SIZE-1])-2) = 'd';
+ *(fileNames[FILENAMES_BUFFER_SIZE-1]+strlen(fileNames[FILENAMES_BUFFER_SIZE-1])-1) = 0;
 
- writeBuffer(buffer, CHR_SIZE, sec[1], fileNames[1023], "wb");
+ writeBuffer(buffer, CHR_SIZE, sec[1], fileNames[FILENAMES_BUFFER_SIZE-1], "wb");
  }
 
  //Data chunks. Output by other sections.
@@ -341,6 +349,12 @@ void main(int argc, char **argv) {
  eofdetect = fgetc(mapFile);
  }
 
+
+ for (int i = 0; i < FILENAMES_BUFFER_SIZE; i++) {
+ free(fileNames[i]);
+ }
+
+
  //close the world. open the nExt.
  fflush(wrlFile);
  fclose(wrlFile);

EDIT: I will take a look at those code issues when I have some time, at least those that are more critical
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: BioHazardN7 on 10 December 2021, 16:33:27
Hello, I have a problem with unpacking the map. When I decompiled the map, the information about the zones that the player cannot enter (the "Passable" brush on the level editor panel) is not imported.
Screen #1 (https://i.ibb.co/Zd46QKh/2021-12-09-22-51-01.jpg)
P.S. I applied this zone myself, it was not in the decompiled map

For example, in the original, it is not possible to go into the river. After decompiled a level with river, do a Rebuld patch and compile the map, I can freely move into these zones.
Screen: #2 (https://i.ibb.co/Jz3bXdH/2021-12-09-18-46-47.jpg), #3 (https://i.ibb.co/N3DkG9F/2021-12-09-18-46-49.jpg)

Can you say something about this situation?

P.S.2. Sory for my bad English.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: nargil66 on 12 December 2021, 14:52:22
@epinter
A little offtopic - is it possible for the old TQCam Tool to be updated for EE? It was a total blast to play with, but it got broken after Atlantis. Koderkrazy's cheat engine table can still edit the camera angle, but it isn't interactive as the old tool:
https://www.youtube.com/watch?v=qe4wjhcJ7qY&t
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: epinter on 13 December 2021, 16:58:03
Hello, I have a problem with unpacking the map. When I decompiled the map, the information about the zones that the player cannot enter (the "Passable" brush on the level editor panel) is not imported.
Screen #1 (https://i.ibb.co/Zd46QKh/2021-12-09-22-51-01.jpg)
P.S. I applied this zone myself, it was not in the decompiled map

For example, in the original, it is not possible to go into the river. After decompiled a level with river, do a Rebuld patch and compile the map, I can freely move into these zones.
Screen: #2 (https://i.ibb.co/Jz3bXdH/2021-12-09-18-46-47.jpg), #3 (https://i.ibb.co/N3DkG9F/2021-12-09-18-46-49.jpg)

Can you say something about this situation?

P.S.2. Sory for my bad English.

Hi,

I didn't have access to mapdecompiler source code until few days ago, so I can't guarantee there's nothing to be done about this. But for what I have seen in it, there's nothing specific about this kind of zones. Maybe could be something that changed in the Editor, I don't know.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: epinter on 13 December 2021, 17:03:56
@epinter
A little offtopic - is it possible for the old TQCam Tool to be updated for EE? It was a total blast to play with, but it got broken after Atlantis. Koderkrazy's cheat engine table can still edit the camera angle, but it isn't interactive as the old tool:
https://www.youtube.com/watch?v=qe4wjhcJ7qY&t

I think it is possible if there's a source code, and the time available.  :)

To rewrite a tool like TQCam from scratch is hard, and in my opinion it's a tool that makes the game ugly, you see everything you shouldn't. The game itself have a much better camera than TQIT, THQ Nordic have done an amazing job.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: sauruz on 13 December 2021, 17:06:25
Hello, I have a problem with unpacking the map. When I decompiled the map, the information about the zones that the player cannot enter (the "Passable" brush on the level editor panel) is not imported.
Screen #1 (https://i.ibb.co/Zd46QKh/2021-12-09-22-51-01.jpg)
P.S. I applied this zone myself, it was not in the decompiled map

For example, in the original, it is not possible to go into the river. After decompiled a level with river, do a Rebuld patch and compile the map, I can freely move into these zones.
Screen: #2 (https://i.ibb.co/Jz3bXdH/2021-12-09-18-46-47.jpg), #3 (https://i.ibb.co/N3DkG9F/2021-12-09-18-46-49.jpg)

Can you say something about this situation?

P.S.2. Sory for my bad English.

This appears because you rebuild the pathing in that area, you need to paint again
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: BioHazardN7 on 13 December 2021, 20:04:53
This appears because you rebuild the pathing in that area, you need to paint again
I understand it. It would be nice if the author could import these zones, if it is possible in principle.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: nargil66 on 14 December 2021, 19:45:55
I think it is possible if there's a source code, and the time available.  :)

To rewrite a tool like TQCam from scratch is hard, and in my opinion it's a tool that makes the game ugly, you see everything you shouldn't. The game itself have a much better camera than TQIT, THQ Nordic have done an amazing job.
Thank you for your answer. If you ever have the time or desire to do it, please give it a try. I'll think of some way to repay you, that's a word given :)
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: xiaorantu on 15 December 2021, 09:34:24
I use the tool open the map,and add sometings,every going on.
but when I assets and build the map,here's a error:
Unsupported version for:xxxxx  /world/greece/area002/valley01.lvl
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: sauruz on 17 May 2022, 00:08:55
With the recent update (wich changed the game map) i cant extract the map using the decompiler, as im having a error.

Any ideias ?
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: Medea Fleecestealer on 22 May 2022, 20:00:18
Did you solve this sauruz? 
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: sauruz on 22 May 2022, 20:13:25
Yhea , during today morning i found the first version of the map decompiler epinter did last December , on my laptop , i tried and it worked!

Just saying the current version epinter have in the link doesnt work at all , as it gives a error.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: Medea Fleecestealer on 22 May 2022, 20:18:57
Good to know.  :)
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: Bumbleguppy on 03 November 2022, 20:55:04
@sauruz could you dm me the version that worked? The one from github throws a couple .dll error I can't resolve.

Of course all the old versions don't work on eternal embers, I mean I got up to Ragnarok decompiled but it then barfed.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: soa on 15 November 2022, 22:58:59
@Bumbleguppy I don't know if you have figured it out since then.
Basically here there are two releases :
https://github.com/epinter/tq-mapdecompiler/releases
Use the link at the bottom (v0.1), not the top link v0.1.1 which is bugged. Download mapdecompiler.7z from v0.1 on December 5th, 2021.
https://imgur.com/B5oHpCF

I had a dll error (ucrtbased.dll) solved with
https://fr.dll-files.com/ucrtbased.dll.html
Put 32 bits version in C:\Windows\System32   and/or 64 bits version in C:\Windows\SysWOW64

The correct command is:           mapdecompiler.exe world01.map world01.wrl
Writing ".exe" seems necessary.
Title: Re: Mapdecompiler updated (Eternal Embers)
Post by: Dugie98 on 09 February 2023, 18:24:09
@Bumbleguppy I don't know if you have figured it out since then.
Basically here there are two releases :
https://github.com/epinter/tq-mapdecompiler/releases
Use the link at the bottom (v0.1), not the top link v0.1.1 which is bugged. Download mapdecompiler.7z from v0.1 on December 5th, 2021.
https://imgur.com/B5oHpCF

I had a dll error (ucrtbased.dll) solved with
https://fr.dll-files.com/ucrtbased.dll.html
Put 32 bits version in C:\Windows\System32   and/or 64 bits version in C:\Windows\SysWOW64

The correct command is:           mapdecompiler.exe world01.map world01.wrl
Writing ".exe" seems necessary.

EDIT: I solved it.

(((I tried this method (and also got the ucrtbased.dll error, which I got rid off with your fix), but I am still getting another Error after putting the command line:
VCRUNTIME140D.dll could not be found.

After a google search, I tried to fix it by installing Visual C++ Redistributable for Visual Studio to see if that solves the problem, but I still get the error message.

Can anyone help me with that?)))
SimplePortal 2.3.7 © 2008-2024, SimplePortal