Check Banshee's first post here. Somewhat confusing thanks to Banshee using 'sections' and 'lines' as unit of measure for offsets etc. but it's pretty easy to convert those to bytes. That's the only piece of information on the subject I could find for now, I remember seeing it explained somewhere else as well but can't remember where .
I don't think you're just wanting to change radar color of few tiles, are you? I mean, IcySon's TMP Builder can do that, but manually editing the colors with it especially for a large amount of files can be bit cumbersome. _________________ QUICK_EDIT
Joined: 22 Nov 2010 Location: Iszkaszentgyorgy, Hungary
Posted: Thu Mar 22, 2012 12:52 pm Post subject:
http://xhp.xwis.net/documents/TMP_TS_Format.html _________________ "If you didn't get angry and mad and frustrated, that means you don't care about the end result, and are doing something wrong." - Greg Kroah-Hartman
=======================
Past C&C projects: Attacque Supérior (2010-2019); Valiant Shades (2019-2021)
=======================
WeiDU mods: Random Graion Tweaks | Graion's Soundsets
Maintainance: Extra Expanded Enhanced Encounters! | BGEESpawn
Contributions: EE Fixpack | Enhanced Edition Trilogy | DSotSC (Trilogy) | UB_IWD | SotSC & a lot more... QUICK_EDIT
Thanks for the infos GD and Starkku
These should be enough to finish the tool.
Starkku wrote:
I don't think you're just wanting to change radar color of few tiles, are you?
Correct. It's for a small tool to edit thousands of files in one operation. Like the situation we currently face in TI, where we want the complete radar map reorganized.
RadarColorizer.png
Description:
all the functionality to group tmp files, set the groups color and save the groups etc works. It just now needs the actual tmp-editing routine to be finish
void Ctmp_ts_file::get_rect(int& x, int& y, int& cx, int& cy) const
{
x = INT_MAX;
y = INT_MAX;
cx = INT_MIN;
cy = INT_MIN;
for (int i = 0; i < get_c_tiles(); i++)
{
if (get_index()[i])
{
int x_t = get_x(i);
int y_t = get_y(i);
int x2_t = x_t + 48;
int y2_t = y_t + 24;
if (has_extra_graphics(i))
{
int y_t_extra = get_y_extra(i);
int y2_t_extra = y_t_extra + get_cy_extra(i);
if (y_t_extra <y> cy)
cy = y2_t_extra;
}
if (x_t <x> cx)
cx = x2_t;
if (y_t <y> cy)
cy = y2_t;
}
}
cx -= x;
cy -= y;
}
What does "if (get_index()[i])" do or how does that work?
get_index() returns a pointer and not a boolean and [i] actually needs afaik an underlying array/list and not a pointer to work. So how can this work?
This array index on a pointer doesn't makes any sense to me.
Even if there would be an underlying array, get_index would still return only an address and i don't see any way how this can be used as a boolean expression in the "if()" statement.
If someone can explain the above code in text and how it measures the TMP file it would be really helpful. _________________ SHP Artist of Twisted Insurrection: Nod buildings
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Mon Mar 26, 2012 2:25 pm Post subject:
XCC code is a nightmare, isn't it?
Ok, get rect will probably get the 'bounding rectangle' of your image. So, he starts by initializing the rectangle (x,y,cx,cy) with some absurd value. Then, for each tile, if the tile has data, (x_t, y_t) are the initial position of the tile while the end of the rectangle is (x_t + 48, y_t + 24). If the tile has extra graphics, it uses an extra operator to compare the y from the extra graphics with the cy to figure out if the y from the extra graphics replace it or not. And, then, this operator is used to compare if the x2_t and y2_t from the current tile replaces cx and cy. In the end, it deduces x from cx and y from cy. The funciton returns the values from x, y, cx and cy.
I don't know the value of INT_MAX and INT_MIN.
Quote:
get_index() returns a pointer and not a boolean and [i] actually needs afaik an underlying array/list and not a pointer to work. So how can this work?
This is the magic of C/C++. 0 is false and anything different than 0 is true. So, if the data at the address returned by get_index()[i] is 0, then it returns false. I think it just checks if the tile is really valid. QUICK_EDIT
INT_MAX and MIN are constants with the maximum possible integer value.
It somehow works by setting the x and y to the maximum possible positive integer value (2.147.483.647) and the width/height to the max possible negative value (-2.147.483.648). Then it slowly narrows down the bounds during each step while comparing with the current tile in the tmp.
C# has equivalents for these (int.MaxValue and int.MinValue) and since i don't want to use unsafe c++ code, i rewrite the code completely in C# syntax.
Since it's not really calculating the image size but merely laying the bounds slowly around it, maybe i can find something more "intuitive".
Banshee wrote:
This is the magic of C/C++. 0 is false and anything different than 0 is true. So, if the data at the address returned by get_index()[i] is 0, then it returns false. I think it just checks if the tile is really valid.
wow. thanks for the info. What a coding style.
Even if this works, i would still have written something more clear/safe like (get_index[i]!=0).
But respect for Olaf for writing code like that and then having so few "buffer overflows", "index of bounds" and other exceptions. _________________ SHP Artist of Twisted Insurrection: Nod buildings
While you're at it LKO, would you mind looking at the 'Copy as MAP (TS) Preview' function codes in XCC? It always crashes (for me, not sure about everybody else) and maybe you could fix it? _________________
Team Black wrote:
interesting seeing your voxel work. They're still better than Aro's!
I know Mig. I was just wondering that maybe his tool is based on some of the XCC codes, so maybe LKO could help. But if I'm wrong, I appologise. And I'm quite sure there's no one at the XCC site. _________________
Team Black wrote:
interesting seeing your voxel work. They're still better than Aro's!
sorry Krow, but i write a new tool and don't fix/modify an existing xcc tool.
I only try to get the tmp image format done, so i can show tmp files in my small tool. _________________ SHP Artist of Twisted Insurrection: Nod buildings
Joined: 22 Nov 2010 Location: Iszkaszentgyorgy, Hungary
Posted: Mon Mar 26, 2012 8:00 pm Post subject:
Lin Kuei Ominae wrote:
Banshee wrote:
This is the magic of C/C++. 0 is false and anything different than 0 is true. So, if the data at the address returned by get_index()[i] is 0, then it returns false. I think it just checks if the tile is really valid.
wow. thanks for the info. What a coding style.
Even if this works, i would still have written something more clear/safe like (get_index[i]!=0).
And that's what I hate... in C#. That thing is actually pretty useful and I am tempted to create myself an operation overload to recreate it in C#, because this would make my codes easier.
Calling C++ unsafe is IMO stupid, since it's not C++ what is unsafe it's the programmer who wrote the code. And C++ can live without .NET. _________________ "If you didn't get angry and mad and frustrated, that means you don't care about the end result, and are doing something wrong." - Greg Kroah-Hartman
=======================
Past C&C projects: Attacque Supérior (2010-2019); Valiant Shades (2019-2021)
=======================
WeiDU mods: Random Graion Tweaks | Graion's Soundsets
Maintainance: Extra Expanded Enhanced Encounters! | BGEESpawn
Contributions: EE Fixpack | Enhanced Edition Trilogy | DSotSC (Trilogy) | UB_IWD | SotSC & a lot more... QUICK_EDIT
unsafe = possibility to write direct in unallocated memory with all the "unsafe" pointer operations.
When using .NET, the CLR prevents in most cases bad pointer operations that can lead to unexpected results like buffer overflows.
So everything has its pros and cons
C++
-fast (if written correct of course)
-runs without .NET
-prone to cause critical errors due to direct hardware access
C# (.NET)
-slower
-more safe, as code runs on CLR, which provides a "layer" of security (no direct hardware access; except you use p/invoke operations)
Joined: 22 Nov 2010 Location: Iszkaszentgyorgy, Hungary
Posted: Tue Mar 27, 2012 11:29 am Post subject:
Lin Kuei Ominae wrote:
unsafe = possibility to write direct in unallocated memory with all the "unsafe" pointer operations.
When using .NET, the CLR prevents in most cases bad pointer operations that can lead to unexpected results like buffer overflows.
So everything has its pros and cons
C++
-fast (if written correct of course)
-runs without .NET
-prone to cause critical errors due to direct hardware access
C# (.NET)
-slower
-more safe, as code runs on CLR, which provides a "layer" of security (no direct hardware access; except you use p/invoke operations)
Well, if C# then references, I don't trust in .NET that it'll make the arrays as simply and followable positioned like ye olde C/C++. And in most cases references can be used like pointers so what? _________________ "If you didn't get angry and mad and frustrated, that means you don't care about the end result, and are doing something wrong." - Greg Kroah-Hartman
=======================
Past C&C projects: Attacque Supérior (2010-2019); Valiant Shades (2019-2021)
=======================
WeiDU mods: Random Graion Tweaks | Graion's Soundsets
Maintainance: Extra Expanded Enhanced Encounters! | BGEESpawn
Contributions: EE Fixpack | Enhanced Edition Trilogy | DSotSC (Trilogy) | UB_IWD | SotSC & a lot more... QUICK_EDIT
It is true that C#(and Java) is significantly slower than C++, but unless you are going to develop a super strong engine like GTA4, Battlefield 3 or photopshop, you are not going to need C++. For normal programs, that speed boost on C++ isn't noticeable. QUICK_EDIT
You mean you don't know C++ (well) and thus have trouble reading it?
Quote:
wow. thanks for the info. What a coding style.
Even if this works, i would still have written something more clear/safe like (get_index[i]!=0).
Safety is the same and clearity is debatable.
Quote:
But respect for Olaf for writing code like that and then having so few "buffer overflows", "index of bounds" and other exceptions.
C++ doesn't have any such exceptions, so that's easy. :p
That said, C++ isn't C. Modern C++ code can be clean and safe. Of course the developer writing the code matters more than the language used. QUICK_EDIT
C++ doesn't have any such exceptions, so that's easy. :p
well, even if the error dialog isn't there, it doesn't mean you don't/can't write/read in/from non-allocated memory.
Krow wrote:
So, when are we getting this LKO?
And will it work with YR's desert terrain? I mean tmps with .des extension.
Sorry, had a lot to do at work, so no time for further development.
Basically it reads already the necessary values, but i hadn't the time to test and edit the read values.
In theory, it should also work with YR terrain files, as the tmp header tells the tool the size of the tile, so the tool knows where each tile in the tmp starts. But i'm not sure if the radarcolor has the same offset beginning from the tile header as in TS. Last edited by Lin Kuei Ominae on Fri May 11, 2012 3:12 pm; edited 1 time in total QUICK_EDIT
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Fri May 11, 2012 3:09 pm Post subject:
Quote:
You mean you don't know C++ (well) and thus have trouble reading it?
The logic of the code is not documented in a proper way, demanding time from a programmer who is not familiar with XCC code (specially the ones who doesn't know about the file formats that it uses) to understand your code. QUICK_EDIT
I'm actually quite surprised to see that Olaf is still around. So, while you're here O' Great Master of XCC, would you please tell us what's wrong with your Copy as MAP (TS) preview function in the latest XCC Mixer? _________________
Team Black wrote:
interesting seeing your voxel work. They're still better than Aro's!
Last edited by Krow on Sat May 12, 2012 1:14 am; edited 1 time in total QUICK_EDIT
would you please tell us what's wrong with your Copy as MAP (TS) preview function in the latest XCC Mixer?
Yeah, that function seems to malfunction in every version of XCC Mixer after 1.22.
Whenever you use that function it causes XCC Mixer to crash, although occasionally it will still manage to convert an image to map preview just before crashing; sometimes it takes 2 tries, sometimes it takes 5 and sometimes it can take like 10 or more...
I personally downloaded XCC Mixer 1.22 just to create map previews, but it would indeed be a lot more convenient if I'd be able to just use the latest version of XCC Mixer to do that so that I won't need different versions of the program to different things. _________________ QUICK_EDIT
I'm actually quite surprised to see that Olaf is still around. So, while you're here O' Great Master of XCC, would you please tell us what's wrong with your Copy as MAP (TS) preview function in the latest XCC Mixer?
Don't know. What's the problem?
Works fine for me. What version are you using? QUICK_EDIT
Yup. I didn't know it too. Starkku was the one that told me about the latest version, and I think he deserves some credit for giving us that info.
The download link is on Olaf's site. And why don't you be a dear LKO and do just that.
The community really ought to know about this. _________________
Team Black wrote:
interesting seeing your voxel work. They're still better than Aro's!
Sorry. But you're here know and the problem is already fixed with the latest version so all is well.
So, got anymore update for XCC Mixer? _________________
Team Black wrote:
interesting seeing your voxel work. They're still better than Aro's!
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum