• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Converting .wtg and .wtc files to readable text?

Status
Not open for further replies.
Level 29
Joined
Jul 29, 2007
Messages
5,174
You should probably ask Ralle to write updated specs or share his code, he said the specs have issues and he needed to fix stuff (which isn't surprising, considering I had to fix stuff with the MDX specs even though they were much more known).

Handling binary data is a lot easier and neater than textual data.
 
Level 19
Joined
Jul 14, 2011
Messages
875
Sooo, I ran into a bit of a problem. wc3lib requires kdelibs (4.9.1) but everything for Windows I can find links to www.winkde.org which is unavailable (and apparently had broken download links or something).

Any chance someone knows where I can get it (for Windows 7)?

There is also the possibility that I am being stupid. Not gonna lie, happens very often.
 
Level 25
Joined
Feb 2, 2006
Messages
1,686
Hi, wc3lib only requires KDE and Qt if you build it with the EDITOR and/or PLUGINS options. The core layer doesn't require this.
What exactly do you want to achieve? I started to develop a trigger editor emulation: http://wc3lib.org/screenshots/triggereditor.png

Do you want to have only some readable text from a trigger? If so you could just copy it in the editor.

I really would like to provide Windows builds but unfortunately I ran into multiple problems building it on Windows with CMake (all module paths have to be set) but I really would like to fix this since most wc3 modders use Windows for modding.

The following class supports loading wtg files: http://wc3lib.org/api/html/classwc3lib_1_1map_1_1_triggers.html
This class supports loading wct files: http://wc3lib.org/api/html/classwc3lib_1_1map_1_1_custom_text_triggers.html
For a whole map simply use: http://wc3lib.org/api/html/classwc3lib_1_1map_1_1_w3m.html

The Frozen Throne support isn't really done yet, so you will have to start with Reign of Chaos maps.
 
Level 19
Joined
Jul 14, 2011
Messages
875
Yeah, I saw the trigger editor and I thought it was really cool, so I wanted to try it out. Unfortunately, KDE doesnt support Qt5 (as far as I could understand) and I dont want to downgrade.

Also, as far as I remember, building it went very smooth (Im on Windows 7).
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
I also think the library will not build in MSVC or many modern compilers as it relies heavily on implementation dependent struct mechanics. Specifically bitfields and struct packing which are not well defined. Though use of some compiler flags it may be possible to build it but it will certainly not build working out of the box.
 
Level 25
Joined
Feb 2, 2006
Messages
1,686
omg not again. It does NOT heavily rely on implementation dependent struct mechanics. There is some bitfields I think for the environment: http://en.cppreference.com/w/cpp/language/bit_field As you can see they are part of the Standard.

Could you please tell me what the problem is?
Are you talking about big endian and little endian?

I just read the formats as specified in the specification. It certainly builds with GCC and Clang, both compilers are Open Source and available for Windows.

@Gismo359: Can't you just install both Qt versions?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
As you can see they are part of the Standard.
Yes but there is still the problem of this.
Adjacent bit field members may be packed to share and straddle the individual bytes.
Which means they equally may not be packed to share and straddle the individual bytes.

Here is the proof.
From C++03, 9.6 Bitfields (pg. 163):

Allocation of bit-fields within a class object is implementation-defined. Alignment of bit-fields is implementation-defined. Bit-fields are packed into some addressable allocation unit. [Note:bit-fields straddle allocation units on some machines and not on others. Bit-fields are assigned right-to-left on some machines, left-to-right on others. ]

GCC seems to have a more micro-controller implementation of bitfields where they get packed together very well. MSVC on the other hand has a much more loose implementation of bitfields where at times no attempt to pack them may be made at all. Equally well struct sizes in MSVC default to being either 4 byte (32 bit build) or 8 byte (64 bit build) aligned unless compiler macros are used to explicitly instruct it to align smaller.
The actual packing of structs is poorly defined and compiler dependant. Bit fields are a required and well defined part of the standard, but they way they are implemented is not.

The only way to portably read binary files is to read in bytes (8 bit data units) into a buffer then explicitly code how to interpret those bytes. Like wise the only way to portably write binary files is to explicitly code how to pack data into a byte buffer which you write out. The resulting machine code could often end up being the same after compiler optimizations are applied.
 
Level 25
Joined
Feb 2, 2006
Messages
1,686
You could have read the same stuff from my link too. No need to bring up the Standard (btw. it is the old one). There is exactly one point where bitfiels are used and this is for TilepointData and as I wrote it works with both compilers.

Where is the problem now? He doesn't use it and since there is still no unit test for the environment it has to be tested anyway. You wrote "as it relies heavily on implementation dependent struct mechanics". What do you mean by that? What does rely heavily? The whole library?

Btw. why do you even use MSVC if there are better Open Source compilers? Microsoft products are commonly known for not working as expected.
Just look at this: http://stackoverflow.com/questions/18212873/c11-on-windows
It probably would not work with some C++11 stuff either and I certainly do not care.

I will try to get a Windows build done using mingw or Clang but certainly not using a Microsoft compiler.

Sorry but I get upset because the last time I wrote about wc3lib in this forum which is really some time ago you wrote exactly the same stuff.
wc3lib is far from being finished but you're bringing up some minor stuff here. What is the purpose? To me it seems that you want to spread around how much you know about the Standard and alignment.

Of course it could be ported to all platforms/architectures with some macros since everywhere the same read and write functions are used but what would be the purpose of this when in the first place basic functionality must be provided?

You're welcome to add some of this functionality and maybe one day we get a library with all the required customizable tools.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
structs/classes have to be aligned to word size, so GCC will do that too.

struct s{ int i; bool b; }; std::cout << sizeof(s); will print 4/8 even on GCC. Seems that if you only store bool in struct, it will inline into 1 for some reason(Too lazy to go through the monster standard)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
Btw. why do you even use MSVC if there are better Open Source compilers? Microsoft products are commonly known for not working as expected.
Because those "better Open Source compilers" are a pain to use on Windows. GCC is designed for Linux so although ports for Windows do exist they either depend on Linux simulation (mingw) or they are a usability nightmare. Visual C++ also has amazing interactive debug support (no command line nonsense). I am unsure if that needs the compiler or not however.

Next version of MSVC supports C++11.

Something portable should build with pretty much any C++ compiler. An example would be the open source game Simutrans which although they mostly use GCC to build, it can be built with MSVC as well.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
it really depends on what you mean by c++11 support in MVSC.

They actually support C++17 when it comes to library(filesystem is there for instance).

They dont support C98 nor C++03 in core as of yet, even tho they have even some C++14 features in the compier as of now(2013).

There are nightly builds for gcc, and it shouldnt be problem to build it, neither it should be heavily OS dependant, since the source code is available.

MinGW has shitty old version of GCC afaik.
 
Status
Not open for further replies.
Top