• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
For those interested, here is the conversion code I use to convert an ID into a colour:

Code:
// Move bits around
int result = (((id & 0x200)>>1) | ((id & 0x40)<<3) | ((id & 0x8)<<7) | ((id & 0x1)<<11) |
	((id & 0x400)>>6) | ((id & 0x80)>>2) | ((id & 0x10)<<2) | ((id & 0x2)<<6) |
	((id & 0x800)>>11) | ((id & 0x100)>>7) | ((id & 0x20)>>3) | ((id & 0x4)<<1));

// Distribute over R, G and B.
result = ((result & 0xF00) << 3) | ((result & 0xF0) << 2) | ((result & 0xF) << 1);

Not really complicated, is it? ;)

Here's the code for the other direction: converting a colour to an id.

Code:
// Compact distributed bits
rgb = ((rgb & 0xF00000) >> 12) | ((rgb & 0xF000) >> 8) | ((rgb & 0xF0) >> 4);

// And move them to their correct places.
rgb = (((rgb & 0x8)>>1) | ((rgb & 0x4)<<3) | ((rgb & 0x2)<<7) | ((rgb & 0x1)<<11) |
	((rgb & 0x80)>>6) | ((rgb & 0x40)>>2) | ((rgb & 0x20)<<2) | ((rgb & 0x10)<<6) |
	((rgb& 0x800)>>11) | ((rgb & 0x400)>>7) | ((rgb & 0x200)>>3) | ((rgb & 0x100)<<1));
 
Inferis said:
For those interested, here is the conversion code I use to convert an ID into a colour:

Code:
// Move bits around
int result = (((id & 0x200)>>1) | ((id & 0x40)<<3) | ((id & 0x8)<<7) | ((id & 0x1)<<11) |
	((id & 0x400)>>6) | ((id & 0x80)>>2) | ((id & 0x10)<<2) | ((id & 0x2)<<6) |
	((id & 0x800)>>11) | ((id & 0x100)>>7) | ((id & 0x20)>>3) | ((id & 0x4)<<1));

// Distribute over R, G and B.
result = ((result & 0xF00) << [COLOR=DarkRed]12[/COLOR]) | ((result & 0xF0) << [COLOR=DarkRed]8[/COLOR]) | ((result & 0xF) << [COLOR=DarkRed]4[/COLOR]);

Not really complicated, is it? ;)

Here's the code for the other direction: converting a colour to an id.

Code:
// Compact distributed bits
rgb = ((rgb & 0xF00000) >> 12) | ((rgb & 0xF000) >> 8) | ((rgb & 0xF0) >> 4);

// And move them to their correct places.
rgb = (((rgb & 0x8)>>1) | ((rgb & 0x4)<<3) | ((rgb & 0x2)<<7) | ((rgb & 0x1)<<11) |
	((rgb & 0x80)>>6) | ((rgb & 0x40)>>2) | ((rgb & 0x20)<<2) | ((rgb & 0x10)<<6) |
	((rgb& 0x800)>>11) | ((rgb & 0x400)>>7) | ((rgb & 0x200)>>3) | ((rgb & 0x100)<<1));


Thanks
it seems to be 12, 8, 4 instead of 3, 2, 1.
 
Inferis said:
No, the 3, 2 and 1 are correct. I'll leave it as an exercise to the reader why. ;)

Becuase the bits come in groups of four in one of the directions but individually the other way?
 
Why did Inferis get a new avatar he only has 603 posts
 
Inferis said:
No, the 3, 2 and 1 are correct. I'll leave it as an exercise to the reader why. ;)

cos in ratios its still the same?

12:8:4
3:2:1

duh....i guess...i know nothing of this.
 
Mezzo said:
Why did Inferis get a new avatar he only has 603 posts
Because he's "important and famous":
Nikolai II said:
Just be important and famous on the forums, then ask an Administrator nicely and you should be set :)
 
First visit to this thread...

Thank you Infreris,
The detailed information you offer at your website enables:
1) Japanese fan to fix bugs of EU2 Asian Chapter
(eg. Congo is isolated from the rest of the world.)

2) me to fix some missing link bugs of Victoria :)

FYI, the layout of adjacent.tbl in Victoria is the same as EU2's but simpler.
For each province, IDs of adjacent province are listed from smaller to larger inregard of land/ocean.


To jdrou:
Aren't you familier with coding? I'm almost certain that layout of adjacent.tbl is the same as EU2's or Vicky's. With Infreris's information at hand, it's not difficult to code your own.
At least you can edit the file with hex editor to add/remove links, though it'll take hours.
 
unknown said:
To jdrou:
Aren't you familier with coding? I'm almost certain that layout of adjacent.tbl is the same as EU2's or Vicky's. With Infreris's information at hand, it's not difficult to code your own.
At least you can edit the file with hex editor to add/remove links, though it'll take hours.
I assume this is a response to some old post of mine in this thread where I asked about modifying adjacency in HoI. While I am familiar with coding I'm also lazy; I hate writing programs from scratch. I'd much rather modify existing source code. I believe I PMed Tanone to ask for source to his editor but never heard back. I've been meaning to work on HoI adjacency ever since it came out but never got around to it. (There are a number of adjacency bugs in HoI1 in addition to the obvious mod potential.)
 
jdrou said:
While I am familiar with coding I'm also lazy

As I pointed out, you can edit adjacent.tbl with a hex editor alone if you don't like to create a program for that purpose. Yes, you're lazy, man. :) You should experience the disappointment and frustration of mine, too. What a surprise it is that I found out edited adjacent.tbl was corrupted (CTD on loading) after hours of renumbering offset values! I had to start over the whole process.

Back to the topic:
jdrou said:
There are a number of adjacency bugs in HoI1 in addition to the obvious mod potential.

I'll fix them for you if you can gather the whole known bugs. If you like the idea, PM the list to me. If you want some alterations (for C.O.R.E.?), send them in a different list as well.
Though I have my own adjacency editor, it has bugs and I'm reluctant to release it. O good old user unfriendly command line program with varied arguments.

Please make sure those bugs are caused by adjacent.tbl. Various Land / Ocean adjacency bugs in Victoria were caused by wrong definition in province.csv (wrong port number etc.)
 
The HoI1 adjacent.tbl is the same as the EU2 version (structure-wise, that is). Any existing tools should be easily adjustable by just changing the number of provinces from 1615/2020 to 2201.

On a related note:

enigmashot1.jpg


;)
 
Nice work, Inferis.

Inferis said:
Any existing tools should be easily adjustable by just changing the number of provinces from 1615/2020 to 2201.

It'll be better to remove such definitions from those tools. If you can use some information(file size, certain byte values, etc.) to determine # of data, they'll be more flexible and (may be more important to coder) maintenance free.

eg.
You can pick up # of provinces from adjacent.tbl by seeking the first address of 4*CD DWORD value.
 
how do your files work every time i run them it says no files specified and it closes instantly afterward
 
Mezzo said:
how do your files work every time i run them it says no files specified and it closes instantly afterward

You need to run them from a command-prompt.
 
Hallsten said:
You need to run them from a command-prompt.

When run them with a command prompt I typem image/I and then the dirsctory of the file I want to import, but it says Illegal syntax or something like that