Jump to content

Dune 2 Legacy source code?


XTF

Recommended Posts

actually my experience is, even if you use any license like thingy , or sourceforge or whatever. Your source will always be ripped and claimed as someone elses work. I think its hard to fight it. Thats why my point of view is with several projects "I give it, and i dont give a damn if you use my code and claim as if its yours".

Only do this if you code for your own fun and you REALLY dont give a damn ;)

Link to comment
Share on other sites

indeed that was my experience with bot programming. I saw every bot who was releasing their source being ripped. Thats why i never will release the code of mine.

It wont happen that fast with Dune 2 Legacy ofcourse, but then again, its about the principle. You have to face it that there will be people ripping off code...

Link to comment
Share on other sites

some good points raised here.

There are some parts of my code that I am quite proud of and wouldn't want any one ripping, but most of it I wouldn't really care what any one does with it... But if I released only part, how much use is a portion of the code, people wouldn't be able to compile it, let alone help with the game development.

I am also not quite sure what I want to do with it as well, I have plans to add support for 3d objects and terrain much like newer similar games do, such as warcraft3, emperor and such, also networking, and good ai.

Decisions, decisions.....

BTW theres a patch out, which changes only a few significant things, although I have upped it to 0.15 because it seems very stable.

Link to comment
Share on other sites

Hey Olaf,

theres a program on this page with source that manages to extract the icon files from the icon.icn file. If you adjust the palette file in the same way your mixer does for the app, some of the tiles come out looking almost correct, however I can't make sense of the src, it seems not to match the app. Do you think this could be any help for you in decoding the icn format?

http://students.soros.karelia.ru/~xhacker/worktable.htm

Link to comment
Share on other sites

What's your goal? My goal for XCC was to develop utilities so I could edit the game. That goal was met. Whether somebody else would release other utilities didn't matter.

some good points raised here.

There are some parts of my code that I am quite proud of and wouldn't want any one ripping, but most of it I wouldn't really care what any one does with it... But if I released only part, how much use is a portion of the code, people wouldn't be able to compile it, let alone help with the game development.

If you use Visual C++ 6 too, you could release OBJs instead of Cs to protect part of the source code.

Hey Olaf,

theres a program on this page with source that manages to extract the icon files from the icon.icn file. If you adjust the palette file in the same way your mixer does for the app, some of the tiles come out looking almost correct, however I can't make sense of the src, it seems not to match the app. Do you think this could be any help for you in decoding the icn format?

http://students.soros.karelia.ru/~xhacker/worktable.htm

Why do you think the source doesn't match the EXE? I guess it's a great help, but I can't find my Dune 2 files to test it now.

Link to comment
Share on other sites

i sent Olaf an IM about this btw ;)

the source code of that icon extractor is not compiling to well on my MSVC6. It gives some warnings, but then it also does NOT create any good bmp's anymore. They are not even read as a good BMP format. I guess you really need a C compiler. (an older one?, other one? i dunno).

Link to comment
Share on other sites

i sent Olaf an IM about this btw ;)

the source code of that icon extractor is not compiling to well on my MSVC6. It gives some warnings, but then it also does NOT create any good bmp's anymore. They are not even read as a good BMP format. I guess you really need a C compiler. (an older one?, other one? i dunno).

I thought u may have, but wanted to be sure he knew about it....

Anyways, I think the code is wrong because I had a look at some of the offset definitions, and some seem to be way beyond the length of the icon.icn file - it seems something is deffinately wrong with this unless I am not understanding the code in it correctly.

Link to comment
Share on other sites

iconconv.c(34) : warning C4013: 'exit' undefined; assuming extern returning int

iconconv.c(46) : warning C4013: 'writebmp' undefined; assuming extern returning int

iconconv.c(54) : warning C4101: 'z' : unreferenced local variable

iconconv.c(111) : warning C4101: 'k' : unreferenced local variable

iconconv.c(81) : warning C4716: 'decode' : must return a value

iconconv.c(165) : warning C4716: 'writebmp' : must return a value

That's 'normal'. You probably need to add "#pragma pack(push, 1)" at the top.

Link to comment
Share on other sites

Working code:


#include  <dos.h>
#include  <io.h>
#include  <stdio.h>

#define  FNAME "c:/temp/icon.icn"
char  palname[]="c:/temp/ibm.pal";
#define  ICONNUM 0x18f
#define  ICONOFFS 0x28
#define  TABLEOFFS 0xc7b0
#define  TABLESIZE 0xa90
#define  INDEXOFFS 0xd248

int  in;

unsigned char  table[TABLESIZE];
unsigned char  index[ICONNUM];
unsigned char  inbuf[0x80];
unsigned char  outbuf[0x100];

#pragma pack(push, 1)

struct
{
 unsigned __int16  ftype; // 'BM' - BMP
 unsigned __int32  fsize; // Size of file
 unsigned __int32  rez; // Reserved
 unsigned __int32  bitoffs;  // Offset of bit image
 unsigned __int32  ssize; // Size to rest of structure, includes this field
 unsigned __int32  width; // Width of image
 unsigned __int32  height; // Height of image
 unsigned __int16  planes; // Count of bit planes = 1
 unsigned __int16  bits; // Bit per pixel
 unsigned __int32  compr; // Type of compression
 unsigned __int32  imgsize;  // Size of image
 unsigned __int32  sux1;
 unsigned __int32  sux2;
 unsigned __int32  clrused;  // Count of used colors
 unsigned __int32  clrimp; // Count of impotant colors
} bmphead;

char  pal[768];
char  destpal[1024];

int  writebmp(char *name)
{
 bmphead.ftype = 0x4D42;
 bmphead.rez = 0;
 bmphead.ssize = 0x28;
 bmphead.width = 0x10;
 bmphead.height = 0x10;
 bmphead.planes = 1;
 bmphead.bits = 8;
 bmphead.compr = 0;
 bmphead.sux1 = bmphead.sux1 = bmphead.clrused = bmphead.clrimp = 0;
 bmphead.bitoffs = 0x36+0x400;
 bmphead.imgsize = 0x100;
 bmphead.fsize = 0x36+0x400+0x100;
 
 int i = _open(palname,0);
 if (i == -1)
 {
printf("%s open failedn",palname);
return 1;
 }  
 read(i,pal,768);
 close(i);
 
 int j;
 for(i = 0, j = 0; i < 768;)
 {
destpal[j++] = pal[i++] * 255 / 63;
destpal[j++] = pal[i++] * 255 / 63;
destpal[j++] = pal[i++] * 255 / 63;
destpal[j++] = 0;
 }
 
 i = _creat(name,0);
 if (i == -1)
 {
printf("Unable to create "%s"n",name);
return 1;
 }  
 
 write(i, &bmphead, sizeof(bmphead));
 write(i, destpal,1024);  
 
 for(j = 0xf0; j >= 0; j -= 0x10)
write(i, outbuf + j, 0x10);
 close(i);
 return 0;
}

void decode(int n)
{
 char  t[16];
 
 lseek(in,ICONOFFS + 128 * n, SEEK_SET);
 _read(in, inbuf, 0x80);
 
 int k = 16 * index[n];
 for (int i = 0; i < 16; i++)
 {

if (table[k + i] >= 0x90 && table[k + i] <= 0xa0)
 t[i] = table[k + i] + 0x30;
else
 t[i] = table[k + i];
 }
 
 int j = 0;
 for(i = 0; i < 0x80; i++)
 {
int l = inbuf[i];
outbuf[j++] = t[l >> 4];
outbuf[j++] = t[l & 0xf];
 }
}

int  main()
{
 in = _open(FNAME,0);
 
 if (in == -1)
 {
printf("Unable to open "FNAME"n");
return 1;
 }
 
 lseek(in, TABLEOFFS, SEEK_SET);
 _read(in, table, TABLESIZE);
 lseek(in, INDEXOFFS, SEEK_SET);
 _read(in, index, ICONNUM);
 
 for (int i = 0; i < ICONNUM; i ++)
 {
decode(i);
char buff[100];
sprintf(buff,"icon %04d.bmp", i);
writebmp(buff);
 }
 return 0;
}

Link to comment
Share on other sites

I think you misunderstood my last post Olaf.

The code did compile, yes, with these errors, indeed. But, the output of the program was totally garbage. No program would read the bmp files at all.

thats all what i meant ;)

I know. And I fixed both the warnings and the garbarge creation.

Link to comment
Share on other sites

It's 0xd3d7 (54231) bytes long.

Am I do something really stupid, both windows and my hex editor show it as being only 52,893 (0xCE9D) bytes long. Pehaps somehow I have gotten a wrong version or something,

does your code create the tiles looking correctly as they should as well with your version of the icn file?

I have version 1.07 of dune2, perhaps there is a difference.

Ah ic yes, I had a look and it seems this has been the reason why I couldn't do this all along, stupid me, thanks Olaf.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...