Staredit Network > Forums > SC1 Mapping Tools > Topic: Chkdraft Project
Chkdraft Project
Oct 9 2012, 12:42 am
By: jjf28
Pages: < 1 « 2 3 4 5 615 >
 

Jan 5 2013, 4:27 am Heinermann Post #61

SDE, BWAPI owner, hacker.

I noticed there aren't many cpp files, and that a lot of code is tossed into header files. DisplayName.h for example has "new char*[233];". This will create a new array for every translation unit that the header is included in. It's generally bad practice to write code in header files, unless you're writing a template.

The file DefaultCHK.h has invalid characters. You shouldn't have non-printable characters in source code.

Look at Buffer.h. You have a "char title[3];", but a loop that iterates through 4 characters in your extract method. Now by pure coincidence there is an alignment directive which gives you an extra byte, but otherwise it would overwrite your "char* data" member. You should instead make it "char title[5]" and make sure the last character is a null terminator.

You should also get into the habit of distinguishing NULL, 0, '\0', nullptr and when to use them.
NULL - In C++11 is being replaced by the type-safe nullptr. You would only use NULL or nullptr with pointers (a HANDLE and such types in the win32 api are also treated as pointers).
'\0' - Always use this when assigning or comparing to a character. It can help distinguish what is happening more quickly.
0 - Only use this when the synonyms above don't apply.

There's a whole bunch of other things as well, but I'm sure you're working on improving your abilities.


On the other hand, a while ago I started a project called Legacy Map Reader which has Starcraft/Beta/Warcraft2 map reading code. The project was incomplete, but feel free to look at the code.
[attach=9072]
This was done in 2011. It is supposed to closely resemble the way Starcraft and Warcraft II actually read map files. I've learned a lot since then though and would have designed it a bit differently with some actual C++. It would have been a better idea to create a base interface class for sections and pull it out of a map, like this:

Section.h
Code
#pragma once
#include <map>
#include <windows.h>

class Section
{
public:
 static std::map<DWORD,Section*> sectionMapping;
 Section(DWORD dwSectionId);

 static bool readSection(SomeBufferClass &buff);
 // @TODO writeSection

 virtual bool read(DWORD dwSectionId, DWORD dwSectionSize, SomeBufferClass &buff) = 0;
 virtual bool write(SomeBufferClass &buff) = 0;
protected:
 DWORD id;
};


Section.cpp
Code
#include "Section.h"

std::map<DWORD,Section*> Section::sectionMapping;

Section::Section(DWORD dwSectionId) : id(dwSectionId)
{
 Section::sectionMapping[id] = this;
}

bool Section::readSection(SomeBufferClass &buff)
{
 // Read the section header
 DWORD dwSectionId, dwSectionSize;
 dwSectionId = buff.readDword();
 dwSectionSize = buff.readDword();

 // Retrieve the section by section ID
 auto it = Section::sectionMapping.find(dwSectionId);
 if ( it == Section::sectionMapping.end() )
   return false;

 // Return true if the section was read successfully
 return it->second->read(dwSectionId, dwSectionSize, buff);
}

It's just something I came up with now and each section type would extend this base one. I'm actually doing something similar with the AI Script opcodes (here: https://code.google.com/p/bwapi/source/browse/branches/bwapi4/bwapi/BWScriptEmulator/Opcode.h ). Splitting everything up may seem like a lot of work, but the code is much cleaner that way ( https://code.google.com/p/bwapi/source/browse/branches/bwapi4/bwapi/BWScriptEmulator/Build.cpp ).

EDIT: As for drawing tiles, BWAPI has some reverse engineered drawing tile code: https://code.google.com/p/bwapi/source/browse/branches/bwapi4/bwapi/BWAPI/Source/BWDrawing.cpp#127 (includes creep rendering)

Attachments:
Legacy Map Reader.7z
Hits: 6 Size: 28.13kb

Post has been edited 2 time(s), last time on Jan 5 2013, 4:34 am by Heinermann.




Jan 5 2013, 10:31 am NudeRaider Post #62

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Quote from Heinermann
It is supposed to closely resemble the way Starcraft and Warcraft II actually read map files.
The perfect map unprotector.




Jan 5 2013, 5:17 pm jjf28 Post #63

Cartography Artisan

Quote from NudeRaider
Quote from Heinermann
It is supposed to closely resemble the way Starcraft and Warcraft II actually read map files.
The perfect map unprotector.

The ideal mapping program should be able to read all maps, but not be able to save maps the give clear indicators of protection (the only safe indicator I can think of being changes to VCOD, since this section has zero bearing on map functionality and is one of few methods that prevents staredit from opening maps) - which is the only support to legacy protections I plan to give.

Quote
I noticed there aren't many cpp files, and that a lot of code is tossed into header files. DisplayName.h for example has "new char*[233];". This will create a new array for every translation unit that the header is included in. It's generally bad practice to write code in header files, unless you're writing a template.

Though I'd read somewhere that you weren't supposed to include extra cpp files, noted!

Quote
The file DefaultCHK.h has invalid characters. You shouldn't have non-printable characters in source code.

Will try to change those to escape chars

Quote
You should instead make it "char title[5]" and make sure the last character is a null terminator.

Fixed

Quote
There's a whole bunch of other things as well, but I'm sure you're working on improving your abilities.

Half the project is me learning new code :P thanks for the tips!

Quote
As for drawing tiles, BWAPI has some reverse engineered drawing tile code

awesome, already wrote basic tiling code with Farty's help, the creep code should come in handy

Post has been edited 1 time(s), last time on Jan 5 2013, 7:57 pm by jjf28.



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Jan 6 2013, 7:20 am O)FaRTy1billion[MM] Post #64

👻 👾 👽 💪

Quote from Heinermann
EDIT: As for drawing tiles, BWAPI has some reverse engineered drawing tile code: https://code.google.com/p/bwapi/source/browse/branches/bwapi4/bwapi/BWAPI/Source/BWDrawing.cpp#127 (includes creep rendering)
Awesome, other than the creep tiles (which I didn't do at all) that is almost exactly how I did it. xD
I guess I can't think of any other way to do it, but I just like seeing that.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Jan 8 2013, 1:06 am Heinermann Post #65

SDE, BWAPI owner, hacker.

The actual code that determines which frame (creep edge) to draw is not included in that code since Starcraft takes care of it.




Jan 13 2013, 11:06 pm jjf28 Post #66

Cartography Artisan

Update: 1/3/2013 Download Latest



- Terrain display working properly
- Basic grids working, can set grid size from the menu or by hotkeys (ie: ctrl+g for normal size), also grid colors by menu
- Changing tiles by number has been re-assigned to shift+click
- Terrain selection working, click and drag to select terrain, ctrl+click to add or remove tiles (or a group of tiles) from your selection
- Can delete terrain selection (by menu or by pressing the delete key)
- SFmpq included, if your computer says MSVCR100.dll is missing, you should install: C++ 2010 Redistributable Package

Up next: copy/paste, tileset index, undo/redo, touch-ups/restructuring, units.




I didn't stick with the way SCMDraft did ctrl+selection as I thought it was plainly terrible. If there's enough demand for it, i'll work it in with a separate modifier key at a later date.

Edit: unable to find a bare copy of MSVCR100, any suggestions on how include it?

Edit2: I'm aware of severe issues with windows XP and 'am actively working to solve 'em

Post has been edited 2 time(s), last time on Jan 14 2013, 6:29 pm by jjf28.



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Jan 18 2013, 3:05 am jjf28 Post #67

Cartography Artisan

Update: 1/3/2013 - Download Latest

- Fixed several crashes on WinXP
- Modified aesthetics for WinXP
- Replaced hotkeys with a more general key listener
- Selection-dragging now scrolls when you hit the edge, dragging speeds up with additional mouse movement
- Mouse locked to current window during map and minimap dragging



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Jan 18 2013, 4:07 am theleo_ua Post #68



Good Luck with this!

Also, current SCM Draft has some annoying bugs with "incorrect displaying of scaled fonts in Win7" http://www.staredit.net/topic/8307/11/#335714 and "restrictions to change map description and some text in mission briefings in Win7", so I forced to use WinXP in virtual machines to solve these problems.

Hope, your CHKDraft will solve these problems

Quote from Oh_Man
Also take off the limit on unit names so you can more easily do overlaps

I wonder - is it possible to write additional data to the end of SCX file, so BW engine and other map editors will ignore it, but CHKDraft will use it for "Unit names, Switch names, Location names, additional Strings etc" ? So you can make a "tiny map" for BW engine and other map editors, but "normal map" for CHKDraft.

For example - a lot of maps doesnt have "names of switches", because of String limit. The way I proposed, it will be possible to name switches even if string limit reached.

Post has been edited 6 time(s), last time on Jan 18 2013, 4:39 am by theleo_ua.



None.

Jan 18 2013, 5:11 am jjf28 Post #69

Cartography Artisan

Quote
current SCM Draft has some annoying bugs with "incorrect displaying of scaled fonts in Win7"

I create the fonts/font sizes used in most parts of CHKDraft, as far as I know they aren't subject to scaling, you can try it for yourself, but this was how scaling looked on my comp

Screen Pic


Quote
"restrictions to change map description and some text in mission briefings in Win7"

I'm developing CHKDraft on windows 7 (and ensuring compatibility for windows XP), so there shouldn't be any such issues.

Quote
I wonder - is it possible to write additional data to the end of SCX file, so BW engine and other map editors will ignore it, but CHKDraft will use it for "Unit names, Switch names, Location names, additional Strings etc" ? So you can make a "tiny map" for BW engine and other map editors, but "normal map" for CHKDraft.

Certainly lots of areas I can place extra data, 'editor only' strings are on the todo list for CHKDraft



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Jan 18 2013, 5:59 am theleo_ua Post #70



Quote from jjf28
I create the fonts/font sizes used in most parts of CHKDraft, as far as I know they aren't subject to scaling, you can try it for yourself, but this was how scaling looked on my comp

Tried on my PC and yes - now it looks good. But there is one small issue: http://img191.imageshack.us/img191/1871/chkdraft.jpg

Quote from jjf28
I'm developing CHKDraft on windows 7 (and ensuring compatibility for windows XP), so there shouldn't be any such issues.

Quote from jjf28
Certainly lots of areas I can place extra data, 'editor only' strings are on the todo list for CHKDraft

Nice

Also I have some new thoughts: original SCM Draft has text trigger editor. It can be used for next:

Imagine, that I afraid, that SCM Draft will break my map. So I saving all triggers to 1.TXT, then I pressing "save map", then I saving all triggers to 2.TXT, and then I just comparing 1.txt and 2.txt byte to byte, for being assured, that triggers is not broken.

The questions are next:

1) Is it possible to implement TXT versions of all map in future? Not only triggers, but TXT locations, TXT unit names, TXT map description/properties, TXT map terrain/layout ? So each user will be assured, that CHK Draft will not break his map.

2) Do you have any other ideas regarding "how to be assured, that CHK Draft will not break your map" ?

Also, another question: SCM Draft has lack of possibility to work with extra players (for example Player 15) - do you plan to implement this?

Thanks

Post has been edited 1 time(s), last time on Jan 18 2013, 6:04 am by theleo_ua.



None.

Jan 18 2013, 6:42 am jjf28 Post #71

Cartography Artisan

Quote
Tried on my PC and yes - now it looks good. But there is one small issue: http://img191.imageshack.us/img191/1871/chkdraft.jpg
Fixed, should look like this in the next update (I don't care enough to make it centered for odd scales :P)

Quote
1) Is it possible to implement TXT versions of all map in future? Not only triggers, but TXT locations, TXT unit names, TXT map description/properties, TXT map terrain/layout ? So each user will be assured, that CHK Draft will not break his map.
Course, low-level map editing will be implemented in the future, allowing for copy-pasting of such data; also saving individual sections would be super easy to implement, so I probably will put that in.

Quote
2) Do you have any other ideas regarding "how to be assured, that CHK Draft will not break your map" ?
I built a custom buffer class that holds each section of the map that is only edited by CHKDraft through associated functions such as "add", "replace", and "del", which change the data and buffer size accordingly, upon save, the section name, followed by the section size, followed by the section data is all written out. Each section is written separately and in the order staredit writes them; this should prevent any errors that would occur due to discrepancies between section size and the amount of data in a given section, as well as any general scenario file structure errors.

As for the data content itself, there will be certain restrictions that are all turned on by default preventing data from being "irregular", or something starcraft was not built to handle (note: starcraft, not staredit); as long as you keep these turned on I don't think there will be any problems in that area.

SCMDraft does automated backups, so i'll be doing automated backups, works as a fallback for the unexpected.

Quote
Also, another question: SCM Draft has lack of possibility to work with extra players (for example Player 15) - do you plan to implement this?

All player fields should allow for manual entry of player numbers, similarly unit fields, sprite fields, etc., should allow for 'ID:' notation



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Jan 18 2013, 5:44 pm ImagoDeo Post #72



Just a quick note, in case you didn't already have this in your planning.

ChkDraft should have multiple save options. At least two: regular save, which keeps a map completely normal, and protected save, which would delete all unnecessary strings, trim the data, and essentially do the same thing as Farty's TinyMap. That utility is a wonderful tool, but built into a map editor would be better. If you really want to get in-depth, you could have a save profile system to allow the player to define as many save types as they want.

Other things that bother me about SCMDraft:

-Not being able to click and drag triggers in the trigger box;
-Not being able to have multiple windows in the trigger box and multiple tabs;
-Not being able to start a new trigger until I've finished the current one;
-General clunkiness with regard to creating triggers, both in the dialogue and in the text editor;
-No automatic error detection in the trigger text editor;
-Few options regarding the fog of war layer;
-Etc.

I figure a lot of these are already targets on your list, and for that I'm glad. Just wanted to make sure. Some day I may actually have time to do some more mapping, and I'd rather not have to deal with SCMD's quirks and weaknesses.



None.

Jan 18 2013, 11:26 pm NudeRaider Post #73

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Tiny map 2 plugin?




Jan 19 2013, 9:13 am Wormer Post #74



Hello guys! There is no use of reinventing the bicycle. We already have TinyMap for that. In my opinion we just need to teach tools we develop there on SEN to work together.

ImagoDeo, you might want to see this plugin for Vim. Among other things it includes highlighting of SCMD triggers syntax (a slightly improved version of this). For that to work you need to save triggers as a text file with extension .trigger. It will show you all imaginable errors on the fly.

In my opinion a map editor shouldn't try to be a text editor, it was much better if it was working simply as a compiler - a program that transforms one language (readable by human) into internal map triggers representation. It is very important to make tools that can be invoked from a command line, because it is the universal way of combining different programs altogether in an operating system.



Some.

Jan 23 2013, 5:01 pm jjf28 Post #75

Cartography Artisan

Quote
In my opinion a map editor shouldn't try to be a text editor, it was much better if it was working simply as a compiler - a program that transforms one language (readable by human) into internal map triggers representation.

That gives me an interesting idea; the user could choose to import triggers from a text file or a different map upon save. Text editing won't be my focus, extremely convenient GUI's for triggers will be my focus (undo, redo, copy 100 times with field x = f(t), trigger 'groupings'), ne ways all that jazz is a bit far down the line.

Quote
It is very important to make tools that can be invoked from a command line, because it is the universal way of combining different programs altogether in an operating system.
I have to agree by merit of program updates, would be extremely inconvenient to have to get the new source, translate the source in to something chkdraft could use, and release a new version every time one of the 'included' programs gets updated.



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Jan 23 2013, 6:12 pm Azrael Post #76



If you made it so it has an option to accept plug-ins, then people can develop additional features for it without the inconvenience to you.




Jan 24 2013, 8:28 pm Wormer Post #77



Quote from jjf28
...extremely convenient GUI's for triggers will be my focus (undo, redo, copy 100 times with field x = f(t), trigger 'groupings')...
That's right. I'm not sure if people really need a GUI for this kind of work. I for example happy with editing triggers in plain text. Anyways there is a note. I don't think that providing a way to "copy [triggers] 100 times with field x = f(t)" is a good design idea. Imagine one wants to change x from being f(t) to another function g(t), what should he do? Delete all 100 previous triggers? or what? Also, when one has 100 triggers it is difficult to realize from just looking at triggers that functional dependency of value x is really f(t).

If I was making an editor I would have developped a triggers language similar to MacroTriggers (or SCMD Triggers if you want). I was saving this text triggers file with the map (since maps are mpq archives you can place any file inside). There was an option to save a final version of the map without that text file included. Then I was developping a GUI that was operating on top of that language.



Some.

Jan 24 2013, 8:47 pm Lanthanide Post #78



There are already plenty of 3rd party tools, such as MacroTriggers, that deal with text triggers. All you need to use them is a way to save/load text triggers in the map editor, then you can do whatever you like using the 3rd party tools.

On the other hand, the only real GUIs available for editing triggers are those found in the map editor. The one in ScmDraft2 is actually quite good, but there is room for improvement. I'd rather see improvements made to the tool that is heavily integrated with the map editor and only the map editor provides, rather than work on features that are already provided by 3rd party tools.



None.

Jan 24 2013, 9:08 pm jjf28 Post #79

Cartography Artisan

Quote
I don't think that providing a way to "copy [triggers] 100 times with field x = f(t)" is a good design idea. Imagine one wants to change x from being f(t) to another function g(t), what should he do? Delete all 100 previous triggers? or what? Also, when one has 100 triggers it is difficult to realize from just looking at triggers that functional dependency of value x is really f(t).
Quote
... rather than work on features that are already provided by 3rd party tools.

Under my imagined design the user could simply delete the grouping (the 100 triggers would appear as one titled block), or perhaps even store the function with the grouping data and make that changeable; needless to say stuff like this is last on my list; providing support for text triggers, all the layers, and all relevant map setting comes first precisely because of the vast amount of existing support for trigger generation.



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Jan 28 2013, 4:31 am Heinermann Post #80

SDE, BWAPI owner, hacker.

I decided I'd help you out a little.
[attach=9081]

I did the following to the source:

1. Created a class called MyWndClass which is used to register the window classes at the beginning of the program. Hopefully this helps you understand classes better.
2. Replaced some boolean code that had the following redundant format:
Code
if ( CONDITION )
 return true;
else
 return false;

/// REPLACE WITH:
return CONDITION; // if CONDITION is true it returns true, otherwise false; much cleaner!

3. Fixed some memory leaks! These are important. When you use "new" you have to manage the memory yourself, and can often lose it.
4. Used some standard library functions!

I noticed you don't seem to trust the standard library very much, but you should. If something in the standard library doesn't work then you probably misused it (Don't worry! I thought the same thing when I started).

Another tip:
I also noticed some blocks of code like this:
Code
    if ( location < size )
    {
        data[location] = character;
        return true;
    }
    return false;

But don't forget you can use ! (not) and come up with this, which is the same thing with less brackets:
Code
    if ( location >= size )
        return false;
    data[location] = character;
    return true;


Attachments:
Chkdraft.7z
Hits: 3 Size: 915.74kb




Options
Pages: < 1 « 2 3 4 5 615 >
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- there are some real members mixed in those latter pages, but the *vast* majority are spam accounts
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- there are almost 3k pages
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- the real members stop around page 250
[2024-4-14. : 9:20 pm]
O)FaRTy1billion[MM] -- look at the members list
[2024-4-12. : 12:52 pm]
Oh_Man -- da real donwano
da real donwano shouted: This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
it's pretty common
[2024-4-11. : 9:53 pm]
da real donwano -- This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
[2024-4-11. : 4:18 pm]
IlyaSnopchenko -- still better than "Pakistani hookers in Sharjah" that I've seen advertised in another forum
[2024-4-11. : 4:07 pm]
Ultraviolet -- These guys are hella persistent
[2024-4-11. : 3:29 pm]
Vrael -- You know, the outdoors is overrated. Got any indoor gym and fitness equipment?
[2024-4-10. : 8:11 am]
Sylph-Of-Space -- Hello!
Please log in to shout.


Members Online: eksxo