To Fice & SaiNt

  • Thread starter Thread starter Alhexx
  • Start date Start date
Status
Not open for further replies.
A

Alhexx

Guest
Okay, I need a Source Code translation for Melissa, my Parasite Eve ripper. Could you please do me a favor and translate those two types into C++ and Pascal?

Code: [Select]
Code:
'Melissa Index File HeaderPublic Type MelHeader   'Offset Len     Description  ID As String * 8      ' 0      8      = "MELISSA1"  FLen As Long          ' 8     12      Length of File  NumEntries As Long    '12     16      Count of EntriesEnd Type'Melissa Index File EntryPublic Type MelEntry  ID As String * 4      ' 0      4      Type / Extension (e.g. "TIM ")  Offset As Long        ' 4      8      Offset of File in IMG  Length As Long        ' 8     12      Length of File  Dummy As String * 4   '12     16      = "MLSA" End Type

 - Alhexx
 
Code: [Select]
Code:
// Melissa Index File Headertypedef struct {    // Offset Len Description char ID[8];  // 0 8 = "MELISSA1" long FLen;  // 8 12      Length of File long NumEntries; // 12 16      Count of Entries} MelHeader;// Melissa Index File Entrytypedef struct { char ID[4];  // 0      4      Type / Extension (e.g. "TIM ") long offset;  // 4      8      Offset of File in IMG long Length;  // 8     12      Length of File char Dummy[4];  // 12     16      = "MLSA"} MelEntry;
[edited] 1 2002-03-02 13:46
 
if youre planning on using strings in c++, i would use string classes rather than standard character arrays. They are SO MUCH easier to handle. It adds more memory if the string goes beyond
  • . you can also use standard operators such as + = and ==. to append, initialize, and compare. (respectively)


saint-> theres ways to do that without typedef :)
 
Darkness: String classes also don't necessarily read into/out of files as well, certainly not in this situation where the strings ARE fixed length.

Alhexx:

Type
  MelHeader = packed record
    ID:     Array[0..7] of Char;
    FLen: Integer;
    NumEntries: Integer;
  end;

  MelEntry = packed record
    ID:    Array[0..3] of Char;
    Offset, Length: Integer;
    Dummy: Array[0..3] of Char;
  end;
 
Darkness :

Are you refering to CString?
Have you ever made a memory dump of a program that uses CString?
You'll notice that there will be extra space allocated before the string.
If you use char Apple[] = "This here's a string";
and the string was stored at offset 0xABCDEF00, your memory dump would probably look like this.
Code: [Select]
Code:
ABCDEF00  54 68 69 73 20 68 65 72 65 27 This here'ABCDEF0F  73 20 61 20 73 74 72 69 6E 67 s a string
If you were to use CString Apple = "This here's a string";
you would probably get something like this.
Code: [Select]
Code:
ABCDEEF6  01 00 00 00 10 00 00 00 00 00 ..........ABCDEF00  54 68 69 73 20 68 65 72 65 27 This here'ABCDEF0F  73 20 61 20 73 74 72 69 6E 67 s a string
See the extra memory used? This is the place where the class instance is setting aside for all the housekeeping chores ;)
So like fice said, for fixed length strings, char arrays work better :)
I agree with you though that CString makes it easier to manipulate strings.
About typedef, Alhexx's was defining a type so I did the same ;)
 
Fice & SaiNt:

tankyou.jpg


 - Alhexx
 
Status
Not open for further replies.
Back
Top