Closed BlueHydrangea2908 closed 1 year ago
Greetings,
I do not provide zlib within this repository, you need to provide that yourself to link against so it is correct that its missing. I recommend linking against zlib 1.2.3 since that is the version the game used itself back then (might have changed tho)
Which code compilation error do you mean? The code is 5 years old by now and was compiled against C++17 back then. So it might throw compilation errors when using a newer standard.
Unpacking the gamefiles will not give you access to the c++ source - but it will provide you with sources for the lua scripts for example. Everything which is inside the container files will be unpacked (textures, lua as I mentioned, video files, ..). Although there is a chance that the structure of the container files changed since, I did not unpack the game files in a long time.
Best Regards Mydayyy
I just cloned it and did a test run of the compilation without errors. Whether its still compatible with the game is a different question.
i need few minute to take the screen capture. can you wait? I have delete the old file already and that why i need a little of time.
This is the first error when try to build. Also, I'm using windows, install c++ via visual studio 2022 and cmake also it too. I have downloaded the zlib source code 1.3 (I can only found it), unpack, open with visual studio and build everything in it. After that, I changed your cmakelists.txt to something like this (note that i set manually two flag/variable - cmake still too new for me - ZLIB_INCLUDE_DIR and ZLIB_LIBRARY):
cmake_minimum_required(VERSION 3.7) project(ThisWarOfMineUnpacker)
set(CMAKE_CXX_STANDARD 17)
set(ZLIB_INCLUDE_DIR "H:/This War of Mine Final Cut/ThisWarOfMineUnpacker/zlib-1.3/out/build/x64-Release") set(ZLIB_LIBRARY "H:/This War of Mine Final Cut/ThisWarOfMineUnpacker/zlib-1.3/out/build/x64-Release/zlib.lib")
find_package(ZLIB REQUIRED) if (ZLIB_FOUND) include_directories(${ZLIB_INCLUDE_DIRS}) endif()
set(SOURCE_FILES main.cpp GameFile.cpp GameFile.h Z.cpp Z.h murmur.h) add_executable(ThisWarOfMineUnpacker ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES}) target_link_libraries(${PROJECT_NAME} stdc++fs)
So if I'm doing something wrong, please tell me. And, sr, my english is so bad too :v.
Also, how can you know this game writtten by c++? I want to decompile this game for writing new mod with new mechanics so every piece of information is greate help now. I hope you can share it to me.
Greetings,
dealing with the image first:
It is complaining that it is using the experimental file system API. This is correct, back in 2018 there was no stable API. The experimental API has since been deprecated and stabilized, that is why you are getting this error. You can try suppressing it like it is proposing. If that still leads to errors you would need to replace the experimental API with the new stable API which has been introduced since. This is just the microsoft compiler being annoying, it is still perfectly compileable tho.
See here: https://en.cppreference.com/w/cpp/header/filesystem and here: https://en.cppreference.com/w/cpp/header/experimental/filesystem
For the zlib dir: Are you sure the ZLIB_INCLUDE_DIR is pointing to the headers? Since it complains about not being able to find the headers. It needs to point to the *.h files of zlib.
Also, how can you know this game writtten by c++? I want to decompile this game for writing new mod with new mechanics so every piece of information is greate help now. I hope you can share it to me.
I know since I have reversed the game pretty much completely 5 years ago. Also, since it is written in c++ you can't decompile the game, best you can do is write hooks for it or unpack gamefiles - thats about it.
I detailed the steps of how I wrote the unpacker in my blogpost: https://blog.mydayyy.eu/2018/12/18/This-War-of-Mine-Unpacking-gamefiles.html
Actually through chatgpt I found the solution that solved the problem of filesystem syntax is remove the expremental in #include syntax and the declare of fs namespace in GameFile.h. But, even when i fix all of that, there are more problem wait after that, which lead the problem of a c++ library cannot be loaded name stdc++fs.lib. So, if we can, I don't know, is the result of this process is a exe file that can pack/unpack game file? Or i need to run it from the visual studio in a cmake project? I think it is much better if i just need to run something that can be moved without worry about any dependency like an exe file or something like that.
And about the ZLIB_INCLUDE_DIR, i really don't know how to install the zlib for this project can use it. After build it with release config in visual studio, it seem doesn't work too. I hope you can help me at this problem too.
Unpacking one by one:
Actually through chatgpt I found the solution that solved the problem of filesystem syntax is remove the expremental in #include syntax and the declare of fs namespace in GameFile.h
Correct, by doing that you decided to switch to the stabilized filesystem API. The signatures of the functions I used need to be identical tho - I don't know how much has changed in the stabilized version, but I assume it should not be too much.
But, even when i fix all of that, there are more problem wait after that, which lead the problem of a c++ library cannot be loaded name stdc++fs.lib
You might need to adapt the stdc++fs line in the cmake file: https://github.com/Mydayyy/ThisWarOfMineUnpacker/blob/master/CMakeLists.txt#L14C1-L14C48
Since you switched to the stabilized version, I don't know if that is still required or needs to be changed. Back then you needed to link against that library. This might also depend on your compiler version.
So, if we can, I don't know, is the result of this process is a exe file that can pack/unpack game file?
Terminology: You won't be and will never be able to unpack the game executable itself. This is a compiled game so it will never be possible to get the original source code from it. All you can do is view and modify the assembler code of it. You would however be able to unpack the game data files, like textures, lua scripts, voices, videos, ..
That is, assuming the structure has not changed in the last 5 years which is a long time to introduce changes. I can assure you that the unpacker worked 5 years ago, I cannot guarantee it for the current game version, which I assume got updated a lot.
Or i need to run it from the visual studio in a cmake project? I think it is much better if i just need to run something that can be moved without worry about any dependency like an exe file or something like that.
Not quite sure about the question here. This repositories compiles an executable which allows you to pack and unpack the game data files. For example you can (mind the warning above) unpack the game files, changes textures or lua scripts and repack the game files and replace the original game files with the new ones to load the edited versions.
And about the ZLIB_INCLUDE_DIR, i really don't know how to install the zlib for this project can use it. After build it with release config in visual studio, it seem doesn't work too. I hope you can help me at this problem too.
I don't use windows, so I cannot tell you how you typically set up compilation requirements in windows. The important part here is to provide the zlib.lib and the header files, which I am assuming are somewhere in your downloaded release. You can also try to check out the zlib specific cmake documentation here: https://cmake.org/cmake/help/latest/module/FindZLIB.html
You should be able to set the variable ZLIB_ROOT
to tell cmake where to find your zlib installation, you just need to hit the right folder and set it before the call to FIND_PACKAGE for zlib.
In addition: You would need to remove your manual set of the ZLIB_INCLUDE_DIR and ZLIB_LIBRARY. Those are the result variables from the find_package call, but I am not sure whether cmake still throws an error if it can't find the package but the resul variables already exist. In any case setting ZLIB_ROOT correctly should be enough.
I just wonder, but what is the result after succesful run cmake on this project? Is it a project file base on the debugger or something else? If it's true, after that you use the debugger to run?
I just wonder, but what is the result after succesful run cmake on this project
Terminology: cmake only creates a makefile based on the CMakelists.txt. After you ran cmake you still need to run make to actually build the project and get the executable.
Is it a project file base on the debugger or something else? If it's true, after that you use the debugger to run?
The result of building this repository is an executable file which is able (heed the warnings above) to pack and unpack the game data files. It has no connection to any kind of debugger nor do you run the game with this executable. Its sole purpose is to unpack and pack the game data files (obligatory warning disclaimer)
If that, can you send me the executable file to give it a try on my computer?
I would be able to send you an ELF binary only, if that fits your purposes. I cannot provide a windows binary since I use linux exclusively and avoid windows at all costs.
I don't think i can use an ELF binary, but thank you for let me know. Now my problem is how to install the zlib for the project. How you do it on linux?
On Linux it varies by distro; but usually it is enough to just install it via the package manager.
But as I mentioned - it should be enough to set the ZLIB_ROOT inside the cmake file to the correct path. If you're not sure about the path you can experiment with it, but assuming you downloaded the correct files it should be somewhere inside that release you downloaded.
Do i need to build the zlib source code to get zlib.lib file?
It does depend on what you dowloaded. Zlib also provides a prebuilt version basically including only the required files zlib.h as well as the zlib.lib.
Edit: The newest versions appear to only be distributed as sources, in that case you would need to compile it.
In the current file, with note as source code of zlib, I cannot found any file that call "zlib.lib". I can only get that file after build from visual studio. So, in Cmake-gui, I set two variable/flag called ZLIB_INCLUDE_DIR to the zlib source code directory: "H:\This War of Mine Final Cut\zlib-1.3" and the ZLIB_LIBRARY_RELEASE to "H:/This War of Mine Final Cut/zlib-1.3/out/build/x64-Release/zlib.lib". Do you think it is enough? Also, after setup that, after I generate, what I get a sln file for visual studio. Does it go the same way in Linux?
In the current file, with note as source code of zlib, I cannot found any file that call "zlib.lib" ZLIB_LIBRARY_RELEASE to "H:/This War of Mine Final Cut/zlib-1.3/out/build/x64-Release/zlib.lib"
Those two sentences are kinda contradicting :D
ZLIB_LIBRARY_RELEASE to "H:/This War of Mine Final Cut/zlib-1.3/out/build/x64-Release/zlib.lib"
The correct variable is called ZLIB_LIBRARIES
But in any case, I cannot tell you what cmake puts in those variables exactly, which is why I would recommend to stop settings those manually and point cmake to the zlib installation via the ZLIB_ROOT
variable and using find_package. Find package is fairly standard and pretty flexible. But as I mentioned if you don't have precompiled binaries you need to compile those yourself. You might be able to find a package manager for visual studio which provides zlib - but since I don't use windows I cannot tell you what is popular there.
You can check out the find zlib function here to see what it is doing exactly: https://github.com/Kitware/CMake/blob/master/Modules/FindZLIB.cmake
Sr, my english is terible. But what i mean in there is, the zlib file i donwloaded is the source code in a zip file. Before I build it, no zlib.lib file can be found in that source code directory, so I guess I have to build at least one time.
I cannot found any variable name ZLIB_LIBRARIES. I think this picture will help you some how see what problem I met:
There is two button named "Configure" and "Generate" in below? (ps: i don't know how to describe it here :v). So, if i go with this setting, I will get a sln file of, i guess, cmake project of visual studio. And that is where the nightmare begin. T_T
Also, i go to that link you provided earlier, but i don't how it could help.
Oh boi, I have never worked with the cmake GUI lol. Can you copy paste the full error from the bottom view?
sr, I has taken quick snap. This is the error in the bottom view: "Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.19045. CMake Error at D:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) Call Stack (most recent call first): D:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE) D:/Program Files/CMake/share/cmake-3.27/Modules/FindZLIB.cmake:199 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:6 (find_package)
Configuring incomplete, errors occurred!"
It appears it is still not able to find zlib.
As mentioned I have never worked with the cmake GUI, only with the command line. But you're setting the ZLIB_LIBRARY_RELEASE variable. Apparently it is legal to set the ZLIB_LIBRARY according to the source code: https://github.com/Kitware/CMake/blob/master/Modules/FindZLIB.cmake#L126
But it is not documented.
I would recommend to edit the CMakeLists.txt from this project and just set the ZLIB_ROOT there. What you are trying to do right now is to set the result variables. The ZLIB_ROOT variable is officially documented and find_package will search there first when trying to find zlib. Of course you can also set the ZLIB_ROOT variable outside of this projects CMakeLists.txt, but I can only tell you the command line way of doing that.
I don't think try to set ZLIB_ROOT is good idea.
That is the official endorsed way and its documented.
For compatibility, CMake is ignoring the variable. This warning is for project developers. Use -Wno-dev to suppress it."
This is only a warning. Does it compile if you set ZLIB_ROOT? If not, what is the error?
Sorry, somehow I create the project.
Can we move next or it's ok now?
What do you mean by create? If you compiled it successfully you have an executable now. Check your Release folder for that
It is empty :v
Did it compile successfully? You should see that on the output. What about the x64 dir and all the other directories which don't belong to the original source code distribution. If you compiled it where did you store the result?
Maybe my generator is problem? In cmake-gui, i see that i'm using visual studio 17 2022 as generator?
Did it compile successfully? You should see that on the output. What about the x64 dir and all the other directories which don't belong to the original source code distribution. If you compiled it where did you store the result?
No, there is no error after generator. Even if I try to run cmake .. in cmd, i will have same result too.
Cmake is only responsible for generating the build files, e.g turning the CMakeLists into input files for your native build system. After you ran cmake successfully you still need to built it as mentioned earlier here:
Terminology: cmake only creates a makefile based on the CMakelists.txt. After you ran cmake you still need to run make to actually build the project and get the executable.
I also now understand what you meant by create. Yes, you have created the project files for the application now and you may proceed to built it.
And that is where nightmare come. Wait a minute, I need to ask you here
What should I do in here? Should i replace stint-gcc.h to stdint.h?
I'd recommend to use cstdint since that is part of the c++ standard now. stdint and stdint-gcc both are not
That where i worry. Is it ok to change like that? Is it posible to get runtime error or wrong result here?
It should be ok. I fixed it just now here: https://github.com/Mydayyy/ThisWarOfMineUnpacker/commit/716916b1893fa873e4b102bf6b89d1a283bd37fa
this piece is the next error: "
uint32_t chunkSize = 1024*16;
unsigned char buff[chunkSize];
". It's in GameFile.cpp. That error is "C2131 expression did not evaluate to a constant" in line 53
"
In line 67, 68 of GameFile.cpp, i met the error of using "std::to_string..." too. How should i change this? The previous try i using the library string.
this piece is the next error: " uint32_t chunkSize = 1024*16; unsigned char buff[chunkSize]; ". It's in GameFile.cpp. That error is "C2131 expression did not evaluate to a constant" in line 53 "
Once again a MSVC limitation, they do not support variable length arrays: https://en.wikipedia.org/wiki/Variable-length_array
You either need to switch to new or you can just simply enter the result of the calculation (since its all static const anyways) as the size and avoid the variable length
In line 67, 68 of GameFile.cpp, i met the error of using "std::to_string..." too. How should i change this? The previous try i using the library string.
Whats the full error?
this piece is the next error: " uint32_t chunkSize = 1024*16; unsigned char buff[chunkSize]; ". It's in GameFile.cpp. That error is "C2131 expression did not evaluate to a constant" in line 53 "
Once again a MSVC limitation, they do not support variable length arrays: https://en.wikipedia.org/wiki/Variable-length_array
You either need to switch to new or you can just simply enter the result of the calculation (since its all static const anyways) as the size and avoid the variable length
this is what chatgpt suggest: "
// ...
uint32_t chunkSize = 1024 * 16;
std::vector
// Pass the address of the first element to the function some_function(buff.data(), chunkSize); // Replace some_function with the actual function name "
In line 67, 68 of GameFile.cpp, i met the error of using "std::to_string..." too. How should i change this? The previous try i using the library string.
Whats the full error?
'to_string" is not a member of std and 'to_string' is not found.
this piece is the next error: " uint32_t chunkSize = 1024*16; unsigned char buff[chunkSize]; ". It's in GameFile.cpp. That error is "C2131 expression did not evaluate to a constant" in line 53 "
Once again a MSVC limitation, they do not support variable length arrays: https://en.wikipedia.org/wiki/Variable-length_array You either need to switch to new or you can just simply enter the result of the calculation (since its all static const anyways) as the size and avoid the variable length
this is what chatgpt suggest: " #include
// ...
uint32_t chunkSize = 1024 * 16; std::vector buff(chunkSize);
// Pass the address of the first element to the function some_function(buff.data(), chunkSize); // Replace some_function with the actual function name "
I mean the error is pretty clear. Rewrite that piece of code to avoid variable length allocation of the error. There are two ways to do that, which one you chose is up to you.
In line 67, 68 of GameFile.cpp, i met the error of using "std::to_string..." too. How should i change this? The previous try i using the library string.
Whats the full error?
'to_string" is not a member of std and 'to_string' is not found.
You probably need to include <string>
as an additional header.
I met this last strange error:" LNK1181 cannot open input file 'path_to_zlib_library.lib' ThisWarOfMineUnpacker H:\This War of Mine Final Cut\ThisWarOfMineUnpacker\out\LINK 1". Also, there is a warning: " Warning C6262 Function uses '17144' bytes of stack. Consider moving some data to heap. ThisWarOfMineUnpacker H:\This War of Mine Final Cut\ThisWarOfMineUnpacker\GameFile.cpp 40 "
I don't unstand the error at all. What the hell is "path_to_zlib_library"? It is so weird for that error.
Warning C6262 Function uses '17144' bytes of stack. Consider moving some data to heap. ThisWarOfMineUnpacker H:\This War of Mine Final Cut\ThisWarOfMineUnpacker\GameFile.cpp 40 "
Yea, that huge array is created on the stack. You can always move it to a dynamic allocation which moves it to the heap. I do not know what the maximum stack size is on windows, but I believe this should still be fine.
LNK1181 cannot open input file 'path_to_zlib_library.lib' ThisWarOfMineUnpacker H:\This War of Mine Final Cut\ThisWarOfMineUnpacker\out\LINK 1".
That means there was misconfiguration during the cmake project generation. It is literally trying to open and link a file named path_to_zlib_library
which, obviously does not exist. In that case fix your cmake setup and rerun the compilation
Do you have any idea of this problem? What should I do now?
Well, I do not know your setup nor do I know windows. It appears at some point you somewhere set path_to_zlib_library
literally somewhere. The cmake part should be straight forward. Tell cmake where to find zlib and generate the project files, its fairly standard and battle tested. So I guess at some point you put path_to_zlib_library
into a variable somewhere
There are too much problems in this project:
I just give up to try for this project, but if you want to fix these issue, i want to show you. Also, i want to know is this project will give me the source code of game or it will do something else instead?