Olá, estou aprendendo a programar e não sei muita coisa ainda. Tenho um código de um programa que preciso em console aplication, e não concigo compila-lo. Já perdi noites tentando e nada. Se alguem puder dar um help, ou compilar e postar o link para download seria de muita grande ajuda. Já que preciso urgente disso rsrs. Já procurei tutoriais de como compilar código assim mas não achei.
O código está abaixo:
/*
* Copyright (c) 2006-2008 Benjamin "Evil-Devil" Behrendt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LastChaos Tool' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace LastChaosTool.IO {
public abstract class LodItem {
protected int _id;
protected string _name;
public int ID {
get {
return this._id;
}
set {
this._id = value;
}
}
public string Name {
get {
return this._name;
}
set {
this._name = value;
}
}
}
public class SimpleItem : LodItem {
private string _type;
public string Type {
get {
return _type;
}
set {
this._type = value;
}
}
public override string ToString() {
return "\r\nLastChaosTool.IO.SimpleItem" +
"\r\nID: " + this._id +
"\r\nNameLength: " + this._name.Length +
"\r\nName: " + this._name +
"\r\nTypeLength: " + this._type.Length +
"\r\nType: " + this._type;
}
}
public class ComplexItem : LodItem {
private string _smc;
private string _description;
public string SMC {
get {
return this._smc;
}
set {
this._smc = value;
}
}
public string Description {
get {
return this._description;
}
set {
this._description = value;
}
}
public override string ToString() {
return "\r\nLastChaosTool.IO.ComplexItem" +
"\r\nID: " + this._id +
"\r\nNameLength: " + this._name.Length +
"\r\nName: " + this._name +
"\r\nSMCLength: " + this._smc.Length +
"\r\nSMC: " + this._smc +
"\r\nDescriptionLength: " + this._description.Length +
"\r\nDescription: " + this._description;;
}
}
public class SimpleMob {
private int _id;
private string _name;
public int ID {
get {
return this._id;
}
set {
this._id = value;
}
}
public string Name {
get {
return this._name;
}
set {
this._name = value;
}
}
public override string ToString() {
return "\r\nLastChaosTool.IO.SimpleMob" +
"\r\nID: " + this._id +
"\r\nNameLength: " + this._name.Length +
"\r\nName: " + this._name;
}
}
public struct ComplexMob {
public int id;
public int nameLength;
public string name;
public int level;
public string[] anims;
public string model;
public string[] magic;
public int health;
public ComplexMob(int size) {
this.id = 0;
this.nameLength = 0;
this.name = "";
this.level = 0;
this.anims = new string[size];
this.model = "";
this.magic = new string[4];
this.health = 0;
}
public override string ToString() {
string anims = "";
for (int i = 0; i < this.anims.Length; i++) {
anims += "\r\nAnimation (" + i + ") : " + this.anims[i];
}
string magic = "";
for (int i = 0; i < this.magic.Length; i++) {
magic += "\r\nMagic Attack (" + i + ") : " + this.magic[i];
}
return "\r\nIO.ComplexMob" +
"\r\nID: " + this.id +
"\r\nName: " + this.name +
"\r\nLevel: " + this.level +
"\r\nHealth: " + this.health +
anims +
"\r\nModel: " + this.model +
magic;
}
}
public class Skill : LodItem {
}
public class LOD {
private string fileName = null;
public LOD() {
#if (DEBUG)
Console.WriteLine("LOD file \"" + this.fileName + "\" requested");
#endif
}
public LOD(string fileName)
: base() {
this.fileName = fileName;
#if (DEBUG)
Console.WriteLine("LOD create for \"" + fileName + "\"");
#endif
}
public void setFileName(string fileName) {
this.fileName = fileName;
#if (DEBUG)
Console.WriteLine("LOD FileName set to \"" + fileName + "\"");
#endif
}
public SimpleMob[] loadSimpleMob() {
BinaryReader br = null;
List<SimpleMob> lodList = new List<SimpleMob>(300);
int count = 0;
try {
br = new BinaryReader(new FileStream(
this.fileName,FileMode.Open,FileAccess.Read));
// some info output
//Console.WriteLine("Trying to read from LOD \"" + this.fileName + "\"");
// read the last id
#if (DEBUG)
Console.WriteLine("Last ID: " + br.ReadInt32());
#else
br.ReadInt32();
#endif
// read the rest of the file
int tmpStrLength = 0;
SimpleMob lod = null;
while (br.BaseStream.Position < br.BaseStream.Length) {
lod = new SimpleMob();
lod.ID = br.ReadInt32(); // the ID
tmpStrLength = br.ReadInt32();
//lod.name = new String(br.ReadChars(lod.nameLength)); // the name
lod.Name = new String(byteArrayToCharArray(br.ReadBytes(tmpStrLength)));
//Console.WriteLine(lod);
Console.WriteLine(lod.ID + ";" + lod.Name);
//count++;
lodList.Add(lod);
}
Console.WriteLine("Elemets in file: "+count);
} catch (FileNotFoundException fnfe) {
Console.WriteLine(fnfe.StackTrace);
} catch (IOException ioe) {
Console.WriteLine(ioe.StackTrace);
} finally {
br.Close();
}
return lodList.ToArray();
}
public SimpleItem[] loadSimpleItem() {
BinaryReader br = null;
List<SimpleItem> lodList = new List<SimpleItem>(2000);
try {
br = new BinaryReader(new FileStream(
this.fileName,FileMode.Open,FileAccess.Read));
// some info output
//Console.WriteLine("Trying to read from LOD \"" + this.fileName + "\"");
// read the last id
#if (DEBUG)
Console.WriteLine("Last ID: " + br.ReadInt32());
#else
br.ReadInt32();
#endif
// read the read of the file
int tmpStrLength = 0;
SimpleItem lod = null;
//Console.WriteLine("ID;NAME;DESCRIPTION");
while (br.BaseStream.Position < br.BaseStream.Length) {
lod = new SimpleItem();
lod.ID = br.ReadInt32(); // the ID
tmpStrLength = br.ReadInt32();
lod.Name = new String(byteArrayToCharArray(br.ReadBytes(tmpStrLength)));
tmpStrLength = br.ReadInt32();
lod.Type = new String(byteArrayToCharArray(br.ReadBytes(tmpStrLength)));
//lod.name = new String(br.ReadChars(br.ReadInt32())); // the name
//lod.type = new String(br.ReadChars(br.ReadInt32())); // the type of item
#if (DEBUG)
Console.WriteLine(lod);
#endif
lodList.Add(lod);
}
} catch (FileNotFoundException fnfe) {
Console.WriteLine(fnfe.StackTrace);
} catch (IOException ioe) {
Console.WriteLine(ioe.StackTrace);
} finally {
br.Close();
br = null;
}
return lodList.ToArray();
}
public ComplexItem[] loadComplexItem() {
BinaryReader br = null;
List<ComplexItem> lodList = new List<ComplexItem>(2000);
try {
br = new BinaryReader(new FileStream(
this.fileName,FileMode.Open,FileAccess.Read));
// some info output
//Console.WriteLine("Trying to read from LOD \"" + this.fileName + "\"");
// read the last id
#if (DEBUG)
Console.WriteLine("Last ID: " + br.ReadInt32());
#else
br.ReadInt32();
#endif
int tmpStrLength = 0;
ComplexItem lod = null;
while (br.BaseStream.Position < br.BaseStream.Length) {
lod = new ComplexItem();
lod.ID = br.ReadInt32(); // the ID
tmpStrLength = br.ReadInt32();
lod.Name = new String(byteArrayToCharArray(br.ReadBytes(tmpStrLength)));
// Unknown - skip them (26 bytes)
br.BaseStream.Seek(148,SeekOrigin.Current);
// SMC
tmpStrLength = br.ReadInt32();
lod.SMC = new String(byteArrayToCharArray(br.ReadBytes(tmpStrLength)));
lod.Description = "";
// Unknown - skip them (26 bytes)
br.BaseStream.Seek(12,SeekOrigin.Current);
// description available?
tmpStrLength = br.ReadInt32();
if (tmpStrLength > 0) {
// read the description
lod.Description = new String(byteArrayToCharArray(br.ReadBytes(tmpStrLength)));
}
#if (DEBUG)
Console.WriteLine(lod);
#endif
lodList.Add(lod);
}
} catch (FileNotFoundException fnfe) {
Console.WriteLine(fnfe.StackTrace);
} catch (IOException ioe) {
Console.WriteLine(ioe.StackTrace);
} finally {
br.Close();
br = null;
}
return lodList.ToArray();
}
public void loadComplexMob() {
BinaryReader br = null;
try {
br = new BinaryReader(new FileStream(
this.fileName,FileMode.Open,FileAccess.Read));
ComplexMob lod = new ComplexMob(8);
int count = 0;
// last element ID
#if (DEBUG)
Console.WriteLine("Last ID: " + br.ReadInt32());
#else
br.ReadInt32();
#endif
int animeNameLength = 0;
while (br.BaseStream.Position < br.BaseStream.Length) {
lod.id = br.ReadInt32(); // the ID
lod.nameLength = br.ReadInt32();
lod.name = new String(byteArrayToCharArray(br.ReadBytes(lod.nameLength)));
//lod.name = new String(br.ReadChars(br.ReadInt32())); // the name
lod.level = br.ReadInt32(); // the level
// Unknown - skip them (28 bytes)
br.BaseStream.Seek(28,SeekOrigin.Current);
//Console.WriteLine(br.ReadInt32());
/*Console.WriteLine("Byte: "+br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
//Console.WriteLine(br.ReadInt32());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
//Console.WriteLine(br.ReadInt32());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
//Console.WriteLine(br.ReadInt32());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
//Console.WriteLine(br.ReadInt32());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
//Console.WriteLine(br.ReadInt32());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
//Console.WriteLine(br.ReadInt32());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());
Console.WriteLine("Byte: " + br.ReadByte());*/
lod.health = br.ReadInt32();
// Unknown - skip them (26 bytes)
br.BaseStream.Seek(26,SeekOrigin.Current);
/*Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadInt32());*/
// Unknown
/*Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());*/
// Animation Slots
// skip the animation slots (10 bytes)
br.BaseStream.Seek(10,SeekOrigin.Current);
/*Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte()); // Free Slot, maybe placeholder or seperator?
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte()); // Free Slot, maybe placeholder or seperator?
*/
// Animations
//Console.WriteLine("Animations");
for (int i = 0; i < lod.anims.Length; i++) {
lod.anims[i] = new String(br.ReadChars(br.ReadInt32()));
}
// Modelfile
//Console.WriteLine("Modelfile");
lod.model = new String(br.ReadChars(br.ReadInt32()));
// there can be magic attacks ^^ (6bytes) at least
if (br.PeekChar() > 0) {
Console.WriteLine(lod);
int magCount = 0;
int tmp = 0;
tmp = br.ReadByte();
//Console.WriteLine("1: " + tmp);
magCount += tmp; // first value
//Console.WriteLine("1a: " + magCount);
tmp = br.ReadByte();
//Console.WriteLine("2: " + tmp);
magCount += tmp; // second value
//Console.WriteLine("2a: " + magCount);
// skip this stuff (16 bytes)
br.BaseStream.Seek(16,SeekOrigin.Current);
//Console.WriteLine("MagCount: " + magCount);
/*Console.WriteLine("\r\n" + br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadInt32());
Console.WriteLine(br.ReadInt32());*/
//br.BaseStream.Seek(6,SeekOrigin.Current);
// next are the attack strings
for (int i = 0; i < 3; i++) {
animeNameLength = br.ReadInt32();
lod.magic[i] = new String(byteArrayToCharArray(br.ReadBytes(animeNameLength)));
animeNameLength = 0;
}
/*Console.WriteLine(new String(br.ReadChars(br.ReadInt32())));
Console.WriteLine(new String(br.ReadChars(br.ReadInt32())));
Console.WriteLine(new String(br.ReadChars(br.ReadInt32())));*/
// unknown (5 bytes) - skip
br.BaseStream.Seek(5,SeekOrigin.Current);
/*Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());
Console.WriteLine(br.ReadByte());*/
Console.WriteLine(lod);
} else {
// no magic - Whitebytes (35 bytes) - skip them
br.BaseStream.Seek(35,SeekOrigin.Current);
}
Console.WriteLine(lod);
count++;
}
Console.WriteLine("Elements in file: " + count);
} catch (FileNotFoundException fnfe) {
Console.WriteLine(fnfe.StackTrace);
} catch (IOException ioe) {
Console.WriteLine(ioe.StackTrace);
}
}
public void loadSkill() {
BinaryReader br = null;
try {
br = new BinaryReader(new FileStream(
this.fileName,FileMode.Open,FileAccess.Read));
// some info output
//Console.WriteLine("Trying to read from LOD \"" + this.fileName + "\"");
// read the last id
#if (DEBUG)
Console.WriteLine("Last ID: " + br.ReadInt32());
#else
br.ReadInt32();
#endif
// read the read of the file
int tmpStrLength = 0;
SimpleItem lod = null;
//Console.WriteLine("ID;NAME;DESCRIPTION");
while (br.BaseStream.Position < br.BaseStream.Length) {
lod = new SimpleItem();
lod.ID = br.ReadInt32(); // the ID
tmpStrLength = br.ReadInt32();
lod.Name = new String(byteArrayToCharArray(br.ReadBytes(tmpStrLength)));
// skip data
br.BaseStream.Seek(12,SeekOrigin.Current);
#if (DEBUG)
Console.WriteLine(lod);
#endif
//lodList.Add(lod);
}
} catch (FileNotFoundException fnfe) {
Console.WriteLine(fnfe.StackTrace);
} catch (IOException ioe) {
Console.WriteLine(ioe.StackTrace);
} finally {
br.Close();
br = null;
}
}
private char[] byteArrayToCharArray(byte[] inArray) {
// AWFUL!!!
char[] outArray = new char[inArray.Length];
for (int i = 0; i < inArray.Length; i++) {
outArray[i] = (char)inArray[i];
}
return outArray;
}
}
}