This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [QUESTION] Basic ADT C# Reader  (Read 5581 times)

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
[QUESTION] Basic ADT C# Reader
« on: December 17, 2011, 12:42:01 pm »
Hey Modcraft



Now this is mainly a question for all the C++ and C# devs out there, but if anyone just so happens to know the answer, feel free to tell.
I was hoping to see if someone had a template for reading ADTs laying around. Either in C++ or C#. And of course if they'd share it. Cause I'm gonna work with it in C#, but Im somewhat sure I can convert it to C# if it is in C++.
I've had programming on the education Im on atm, and we've been playing a bit with C# console programming, and I noticed that Cryects Tools is also a console application. However that isn't really that much up-to-date anymore... :/ So anyone got a template laying around that shows how to read the info in ADT files? :)

Thanks
Keta
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

gorq

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 141
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #1 on: December 17, 2011, 01:44:24 pm »
cryectstools have a folder named sourcecode. If u dont have it i can upload it somewhere ;)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

glararan

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 162
    • View Profile
    • http://glararan.eu
Re: [QUESTION] Basic ADT C# Reader
« Reply #2 on: December 17, 2011, 02:28:23 pm »
Keta? Why you don't want to learn C++? :D Qt is rly good framework. Support cross-platform. More better than MS Net Framework. And when you use C# you must use MS Net Framework. And this doesn't working on OSX. I heard "Linux can run C# program" so here is not problem with this. But OSX users ":("
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #3 on: December 17, 2011, 02:41:05 pm »
u_u Im sure once I get further in my education, Ill be learning C++ too... But for now, I'd just like to learn C# :/ And I got the cpp folder from Cryects Tools. Thing is just, they aren't one combined file, with all the structures combined... And since I'm still not that much into C++, I don't completely know how to convert it :S

Thanks
Keta
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Solarion

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 154
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #4 on: December 17, 2011, 02:52:20 pm »
Will you please answer me on skype? You havent come online for a while.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

glararan

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 162
    • View Profile
    • http://glararan.eu
Re: [QUESTION] Basic ADT C# Reader
« Reply #5 on: December 17, 2011, 03:37:25 pm »
C++ to C# converter doesn't exists.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #6 on: December 17, 2011, 04:33:11 pm »
Quote from: "glararan"
C++ to C# converter doesn't exists.
I meant manually convert it u.u As C++ and C# is very similar when still working with the console applications. So I'm pretty sure I can "draw the lines" between the C++ and C# differences ;)

Thanks
Keta
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Steff

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 4551
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #7 on: December 18, 2011, 01:12:52 am »
All dev languages are very similar  in syntax. But c# and c++ are two different worlds.
c++ get compiled direct in an executable an c# get to bytecode that runs in the .net runtime environment. So .net is microsofts java.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Please mark as solved if solved.
Don't ask if you could ask a question... JUST ask the Question.
You can send me also offline messages. I will answer if I get online.
Skype: project.modcraft
Discord: steff#6954

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #8 on: December 18, 2011, 01:44:05 pm »
True, but you can't argue with the fact that when working in the basic of C++ and C#, its all about knowing what code means what in the other language, to convert it.
Anyway, I think this is going a little off topic tbh x)

Anyone got a C++ or C# ADT reader code I may take a look at?



Thanks
Keta
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #9 on: December 18, 2011, 02:14:06 pm »
Cryect's tools really seem to be the best start. They are small and easy to understand. Only problem here: They always only read parts of the file, not the whole file.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #10 on: December 18, 2011, 04:32:49 pm »
Quote from: "schlumpf"
Cryect's tools really seem to be the best start. They are small and easy to understand. Only problem here: They always only read parts of the file, not the whole file.
But as far as I remember, I see a lot of places where people states that CryectsTools is outdated regarding reading of ADTs. The structure has changed since then, so it doesn't work 100%.
Or is that just all rubbish?

And yeah, it only reads parts of the file, whereas I would like a source code that reads the whole file... :/

Thanks
Keta
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #11 on: December 18, 2011, 04:35:09 pm »
The only way to do it properly would be writing it yourself from the wiki and own reverse engineering. The wiki is wrong on some parts as well.

You can also try viewtopic.php?f=59&t=830.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #12 on: December 20, 2011, 03:37:04 am »
So I've come to the conclusion that after reading up on Binary and getting some help from Steff, that CryectsTools CPP files would probably be the best way to go, for a quick understanding of the structure and such. However I've encountered a roadblock :s
I was hoping someone could help me translate this piece of C++ into C#...
Code: [Select]
void LoadMTEX()
{
unsigned int TexSize;
fseek(Input,0x14+0x04+MTEX_Offset,SEEK_SET);
fread(&TexSize,sizeof(int),1,Input);
Textures=new char[TexSize];
fread(Textures,sizeof(char),TexSize,Input);

for(int i=0;i<TexSize-1;i++)
if (Textures[i]==0)
Textures[i]='n';
}

Because this is what I got so far, and its still very filled with errors, according to Visual Studio:

Code: [Select]
void LoadMTEX()
        {
            uint TexSize;
            using (BinaryReader b = new BinaryReader(File.Open("C:\Maruum_51_17.adt", FileMode.Open)))
            {
                b.BaseStream.Seek(0x14 + 0x04 + MTEX_Offset, SeekOrigin.Begin);
                TexSize = b.ReadUInt32();
                Textures = new char[TexSize];
           
            for (int i = 0; i < TexSize - 1; i++) if (Textures[i] == 0) Textures[i] = 'n';

        }

So yea, any help please? :)

Thanks
Keta
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Mjollna

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 254
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #13 on: December 20, 2011, 01:22:53 pm »
Mmmh, I've never done any C#, but I think there may be something wrong at that line :

Code: [Select]
Textures=new char[TexSize];
I tried : http://msdn.microsoft.com/en-us/library ... 53(v=vs.71).aspx
This page mentions you have to the array beforehand, something like :

Code: [Select]
char[] Textures;
Hope that helps...
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
Re: [QUESTION] Basic ADT C# Reader
« Reply #14 on: December 22, 2011, 01:22:16 am »
Quote from: "Mjollna"
Mmmh, I've never done any C#, but I think there may be something wrong at that line :

Code: [Select]
Textures=new char[TexSize];
I tried : http://msdn.microsoft.com/en-us/library ... 53(v=vs.71).aspx
This page mentions you have to the array beforehand, something like :

Code: [Select]
char[] Textures;
Hope that helps...
Oh yeah those parts I already got fixed. Thanks thought :)
Its mainly the "fread" and the "fseek" I find confusing u.u

Thanks
Keta
« Last Edit: January 01, 1970, 01:00:00 am by Admin »