diff --git a/esm/defs.hpp b/esm/defs.hpp index 9f89add7b..a9af4cd30 100644 --- a/esm/defs.hpp +++ b/esm/defs.hpp @@ -5,6 +5,25 @@ namespace ESM { +enum VarType + { + VT_Unknown, + VT_None, + VT_Short, + VT_Int, + VT_Long, + VT_Float, + VT_String, + VT_Ignored + }; + +enum Specialization + { + SPC_Combat = 0, + SPC_Magic = 1, + SPC_Stealth = 2 + }; + /** A list of references to spells and spell effects. This is shared between the records BSGN, NPC and RACE. */ diff --git a/esm/loadalch.hpp b/esm/loadalch.hpp new file mode 100644 index 000000000..7fc649b45 --- /dev/null +++ b/esm/loadalch.hpp @@ -0,0 +1,37 @@ +#ifndef _ESM_ALCH_H +#define _ESM_ALCH_H + +#include "esm_reader.hpp" +#include "defs.hpp" + +namespace ESM { + +/* + * Alchemy item (potions) + */ + +struct Potion +{ + struct ALDTstruct + { + float weight; + int value; + int autoCalc; + }; + ALDTstruct data; + + std::string name, model, icon, script; + EffectList effects; + + void load(ESMReader &esm) + { + model = esm.getHNString("MODL"); + icon = esm.getHNString("TEXT"); // not ITEX here for some reason + script = esm.getHNOString("SCRI"); + name = esm.getHNOString("FNAM"); + esm.getHNT(data, "ALDT", 12); + effects.load(esm); + } +}; +} +#endif diff --git a/esm/loadappa.hpp b/esm/loadappa.hpp new file mode 100644 index 000000000..1109461aa --- /dev/null +++ b/esm/loadappa.hpp @@ -0,0 +1,43 @@ +#ifndef _ESM_APPA_H +#define _ESM_APPA_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Alchemist apparatus + */ + +struct Apparatus +{ + enum AppaType + { + MortarPestle = 0, + Albemic = 1, + Calcinator = 2, + Retort = 3 + }; + + struct AADTstruct + { + int type; + float quality; + float weight; + int value; + }; + + AADTstruct data; + std::string model, icon, script, name; + + void load(ESMReader &esm) + { + model = esm.getHNString("MODL"); + name = esm.getHNString("FNAM"); + esm.getHNT(data, "AADT", 16); + script = esm.getHNOString("SCRI"); + icon = esm.getHNString("ITEX"); + } +}; +} +#endif diff --git a/esm/loadbook.hpp b/esm/loadbook.hpp new file mode 100644 index 000000000..8bff9d22f --- /dev/null +++ b/esm/loadbook.hpp @@ -0,0 +1,35 @@ +#ifndef _ESM_BOOK_H +#define _ESM_BOOK_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Books + */ + +struct Book +{ + struct BKDTstruct + { + float weight; + int value, isScroll, skillID, enchant; + }; + + BKDTstruct data; + std::string name, model, icon, script, enchant, text; + + void load(ESMReader &esm) + { + model = esm.getHNString("MODL"); + name = esm.getHNOString("FNAM"); + esm.getHNT(data, "BKDT", 20); + script = esm.getHNOString("SCRI"); + icon = esm.getHNOString("ITEX"); + text = esm.getHNOString("TEXT"); + enchant = esm.getHNOString("ENAM"); + } +}; +} +#endif diff --git a/esm/loadclot.hpp b/esm/loadclot.hpp new file mode 100644 index 000000000..35ac266d4 --- /dev/null +++ b/esm/loadclot.hpp @@ -0,0 +1,57 @@ +#ifndef _ESM_CLOT_H +#define _ESM_CLOT_H + +#include "esm_reader.hpp" +#include "loadarmo.hpp" + +namespace ESM { + +/* + * Clothing + */ + +struct Clothing +{ + enum Type + { + Pants = 0, + Shoes = 1, + Shirt = 2, + Belt = 3, + Robe = 4, + RGlove = 5, + LGlove = 6, + Skirt = 7, + Ring = 8, + Amulet = 9 + }; + + struct CTDTstruct + { + int type; + float weight; + short value; + short enchant; + }; + CTDTstruct data; + + PartReferenceList parts; + + std::string name, model, icon, enchant, script; + + void load(ESMReader &esm) + { + model = esm.getHNString("MODL"); + name = esm.getHNOString("FNAM"); + esm.getHNT(data, "CTDT", 12); + + script = esm.getHNOString("SCRI"); + icon = esm.getHNOString("ITEX"); + + parts.load(esm); + + enchant = esm.getHNOString("ENAM"); + } +}; +} +#endif diff --git a/esm/loadcrec.hpp b/esm/loadcrec.hpp new file mode 100644 index 000000000..4d38d4a23 --- /dev/null +++ b/esm/loadcrec.hpp @@ -0,0 +1,29 @@ +#ifndef _ESM_CREC_H +#define _ESM_CREC_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* These two are only used in save games. They are not decoded yet. + */ + +/// Changes a creature +struct LoadCREC +{ + void load(ESMReader &esm) + { + esm.skipRecord(); + } +}; + +/// Changes an item list / container +struct LoadCNTC +{ + void load(ESMReader &esm) + { + esm.skipRecord(); + } +}; +} +#endif diff --git a/esm/loadench.hpp b/esm/loadench.hpp new file mode 100644 index 000000000..3669cf5a2 --- /dev/null +++ b/esm/loadench.hpp @@ -0,0 +1,41 @@ +#ifndef _ESM_ENCH_H +#define _ESM_ENCH_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Enchantments + */ + +struct Enchantment +{ + enum Type + { + CastOnce = 0, + WhenStrikes = 1, + WhenUsed = 2, + ConstantEffect = 3 + }; + + struct ENDTstruct + { + int type; + int cost; + int charge; + int autocalc; // Guessing this is 1 if we are supposed to auto + // calculate + }; + + ENDTstruct data; + EffectList effects; + + void load(ESMReader &esm) + { + esm.getHNT(data, "ENDT", 16); + effects.load(esm); + } +}; +} +#endif diff --git a/esm/loadglob.hpp b/esm/loadglob.hpp new file mode 100644 index 000000000..ca1675097 --- /dev/null +++ b/esm/loadglob.hpp @@ -0,0 +1,33 @@ +#ifndef _ESM_GLOB_H +#define _ESM_GLOB_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Global script variables + */ + +struct Global +{ + float value; + VarType type; + + void load(ESMReader &esm) + { + VarType t; + std::string tmp = esm.getHNString("FNAM"); + if(tmp == "s") t = VT_Short; + else if(tmp == "l") t = VT_Int; + else if(tmp == "f") t = VT_Float; + else esm.fail("Illegal global variable type " + tmp); + type = t; + + // The value looks like a float in many cases, and like an integer + // in others (for the s type at least.) Figure it out. + esm.getHNT(value, "FLTV"); + } +}; +} +#endif diff --git a/esm/loadingr.hpp b/esm/loadingr.hpp new file mode 100644 index 000000000..5845cb570 --- /dev/null +++ b/esm/loadingr.hpp @@ -0,0 +1,36 @@ +#ifndef _ESM_INGR_H +#define _ESM_INGR_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Alchemy ingredient + */ + +struct Ingredient +{ + struct IRDTstruct + { + float weight; + int value; + int effectID[4]; // Effect, 0 or -1 means none + int skills[4]; // SkillEnum related to effect + int attributes[4]; // Attribute related to effect + }; + + IRDTstruct data; + std::string name, model, icon, script; + + void load(ESMReader &esm) + { + model = esm.getHNString("MODL"); + name = esm.getHNString("FNAM"); + esm.getHNT(data, "IRDT", 56); + script = esm.getHNOString("SCRI"); + icon = esm.getHNOString("ITEX"); + } +}; +} +#endif diff --git a/esm/loadligh.hpp b/esm/loadligh.hpp new file mode 100644 index 000000000..30b4fe774 --- /dev/null +++ b/esm/loadligh.hpp @@ -0,0 +1,53 @@ +#ifndef _ESM_LIGH_H +#define _ESM_LIGH_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Lights. Includes static light sources and also carryable candles + * and torches. + */ + +struct Light +{ + enum Flags + { + Dynamic = 0x001, + Carry = 0x002, // Can be carried + Negative = 0x004, // Negative light? + Flicker = 0x008, + Fire = 0x010, + OffDefault = 0x020, // Off by default + FlickerSlow = 0x040, + Pulse = 0x080, + PulseSlow = 0x100 + }; + + struct LHDTstruct + { + float weight; + int value; + int time; // Duration + int radius; + int color; // 4-byte rgba value + int flags; + }; // Size = 24 bytes + + LHDTstruct data; + + std::string sound, script, model, icon, name; + + void load(ESMReader &esm) + { + model = esm.getHNString("MODL"); + name = esm.getHNOString("FNAM"); + icon = esm.getHNOString("ITEX"); + esm.getHNT(data, "LHDT", 24); + script = esm.getHNOString("SCRI"); + sound = esm.getHNOString("SNAM"); + } +}; +} +#endif diff --git a/esm/loadmisc.hpp b/esm/loadmisc.hpp new file mode 100644 index 000000000..80513b9e4 --- /dev/null +++ b/esm/loadmisc.hpp @@ -0,0 +1,37 @@ +#ifndef _ESM_MISC_H +#define _ESM_MISC_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Misc inventory items, basically things that have no use but can be + * carried, bought and sold. It also includes keys. + */ + +struct Misc +{ + struct MCDTstruct + { + float weight; + int value; + int isKey; // There are many keys in Morrowind.esm that has this + // set to 0. TODO: Check what this field corresponds to + // in the editor. + }; + MCDTstruct data; + + std::string name, model, icon, script; + + void load(ESMReader &esm) + { + model = esm.getHNString("MODL"); + name = esm.getHNOString("FNAM"); + esm.getHNT(data, "MCDT", 12); + script = esm.getHNOString("SCRI"); + icon = esm.getHNOString("ITEX"); + } +}; +} +#endif diff --git a/esm/loadrace.hpp b/esm/loadrace.hpp new file mode 100644 index 000000000..05e41170d --- /dev/null +++ b/esm/loadrace.hpp @@ -0,0 +1,68 @@ +#ifndef _ESM_RACE_H +#define _ESM_RACE_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Race definition + */ + +struct Race +{ + struct SkillBonus + { + int skill; // SkillEnum + int bonus; + }; + + struct MaleFemale + { + int male, female; + }; + + struct MaleFemaleF + { + float male, female; + }; + + enum Flags + { + Playable = 0x01, + Beast = 0x02 + }; + + struct RADTstruct + { + // List of skills that get a bonus + SkillBonus bonus[7]; + + // Attribute values for male/female + MaleFemale strength, intelligence, willpower, agility, + speed, endurance, personality, luck; + + // The actual eye level height (in game units) is (probably) given + // as 'height' times 128. This has not been tested yet. + MaleFemaleF height, weight; + + int flags; // 0x1 - playable, 0x2 - beast race + + // Size = 140 bytes + }; + + RADTstruct data; + + std::string name, description; + SpellList powers; + + void load(ESMReader &esm) + { + name = esm.getHNString("FNAM"); + esm.getHNT(data, "RADT", 140); + powers.load(esm); + description = esm.getHNOString("DESC"); + } +}; +} +#endif diff --git a/esm/loadskil.hpp b/esm/loadskil.hpp new file mode 100644 index 000000000..0e5585ac6 --- /dev/null +++ b/esm/loadskil.hpp @@ -0,0 +1,40 @@ +#ifndef _ESM_SKIL_H +#define _ESM_SKIL_H + +#include "esm_reader.hpp" +#include "defs.hpp" + +namespace ESM { + +/* + * Skill information + * + */ + +struct Skill +{ + struct SKDTstruct + { + int attribute; // see defs.hpp + int specialization;// 0 - Combat, 1 - Magic, 2 - Stealth + float useValue[4]; // How much skill improves through use. Meaning + // of each field depends on what skill this + // is. We should document this better later. + }; // Total size: 24 bytes + SKDTstruct data; + + // Skill index. Skils don't have an id ("NAME") like most records, + // they only have a numerical index that matches one of the + // hard-coded skills in the game. + int index; + + std::string description; + + void load(ESMReader &esm) + { + esm.getHNT(data, "SKDT", 24); + description = esm.getHNOString("DESC"); + } +}; +} +#endif diff --git a/esm/loadsndg.hpp b/esm/loadsndg.hpp new file mode 100644 index 000000000..1b5d73f78 --- /dev/null +++ b/esm/loadsndg.hpp @@ -0,0 +1,40 @@ +#ifndef _ESM_SNDG_H +#define _ESM_SNDG_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Sound generator. This describes the sounds a creature make. + */ + +struct SoundGenerator +{ + enum Type + { + LeftFoot = 0, + RightFoot = 1, + SwimLeft = 2, + SwimRight = 3, + Moan = 4, + Roar = 5, + Scream = 6, + Land = 7 + }; + + // Type + int type; + + std::string creature, sound; + + void load(ESMReader &esm) + { + esm.getHNT(type, "DATA", 4); + + creature = esm.getHNOString("CNAM"); + sound = esm.getHNOString("SNAM"); + } +}; +} +#endif diff --git a/esm/loadsscr.hpp b/esm/loadsscr.hpp new file mode 100644 index 000000000..e06fd6c70 --- /dev/null +++ b/esm/loadsscr.hpp @@ -0,0 +1,30 @@ +#ifndef _ESM_SSCR_H +#define _ESM_SSCR_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + Startup script. I think this is simply a 'main' script that is run + from the begining. The SSCR records contain a DATA identifier which + is totally useless (TODO: don't remember what it contains exactly, + document it below later.), and a NAME which is simply a script + reference. + */ + +struct StartScript +{ + std::string script; + + // Load a record and add it to the list + void load(ESMReader &esm) + { + esm.getSubNameIs("DATA"); + esm.skipHSub(); + script = esm.getHNString("NAME"); + } +}; + +} +#endif diff --git a/esm/loadstat.hpp b/esm/loadstat.hpp new file mode 100644 index 000000000..7b00df406 --- /dev/null +++ b/esm/loadstat.hpp @@ -0,0 +1,30 @@ +#ifndef _ESM_STAT_H +#define _ESM_STAT_H + +#include "esm_reader.hpp" + +namespace ESM { + +/* + * Definition of static object. + * + * A stat record is basically just a reference to a nif file. Some + * esps seem to contain copies of the STAT entries from the esms, and + * the esms themselves contain several identical entries. Perhaps all + * statics referenced in a file is also put in the file? Since we are + * only reading files it doesn't much matter to us, but it would if we + * were writing our own ESM/ESPs. You can check some files later when + * you decode the CELL blocks, if you want to test this hypothesis. + */ + +struct Static +{ + std::string model; + + void load(ESMReader &esm) + { + model = esm.getHNString("MODL"); + } +}; +} +#endif diff --git a/esm/records.hpp b/esm/records.hpp index 499f1d90f..17051e752 100644 --- a/esm/records.hpp +++ b/esm/records.hpp @@ -2,12 +2,27 @@ #define _ESM_RECORDS_H #include "loadacti.hpp" +#include "loadalch.hpp" +#include "loadappa.hpp" #include "loadarmo.hpp" #include "loadbody.hpp" +#include "loadbook.hpp" #include "loadbsgn.hpp" +#include "loadclot.hpp" +#include "loadcrec.hpp" #include "loaddoor.hpp" +#include "loadench.hpp" +#include "loadglob.hpp" +#include "loadingr.hpp" +#include "loadligh.hpp" +#include "loadmisc.hpp" +#include "loadrace.hpp" +#include "loadskil.hpp" +#include "loadsndg.hpp" #include "loadsoun.hpp" #include "loadspel.hpp" +#include "loadsscr.hpp" +#include "loadstat.hpp" namespace ESM { @@ -24,6 +39,7 @@ enum RecNameInts REC_CELL = 0x4c4c4543, REC_CLAS = 0x53414c43, REC_CLOT = 0x544f4c43, + REC_CNTC = 0x43544e43, REC_CONT = 0x544e4f43, REC_CREA = 0x41455243, REC_CREC = 0x43455243, diff --git a/old_d_version/esm/loadalch.d b/old_d_version/esm/loadalch.d deleted file mode 100644 index 150f0de72..000000000 --- a/old_d_version/esm/loadalch.d +++ /dev/null @@ -1,73 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadalch.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadalch; -import esm.imports; - -/* - * Alchemy item (potions) - */ - -struct Potion -{ - align(1) struct ALDTstruct - { - float weight; - int value; - int autoCalc; - static assert(ALDTstruct.sizeof == 12); - } - - ALDTstruct data; - - mixin LoadT!(); - - MeshIndex model; - IconIndex icon; - - Script *script; - - EffectList effects; - - void load() - {with(esFile){ - model = getMesh(); - icon = getIcon("TEXT"); - script = getHNOPtr!(Script)("SCRI", scripts); - name = getHNOString("FNAM"); - - readHNExact(&data, data.sizeof, "ALDT"); - - effects = getRegion().getBuffer!(ENAMstruct)(0,1); - - while(isNextSub("ENAM")) - { - effects.length = effects.length + 1; - readHExact(&effects.array[$-1], effects.array[$-1].sizeof); - } - - makeProto(); - proto.setInt("autoCalc", data.autoCalc); - }} -} -ListID!(Potion) potions; diff --git a/old_d_version/esm/loadappa.d b/old_d_version/esm/loadappa.d deleted file mode 100644 index f2ee09217..000000000 --- a/old_d_version/esm/loadappa.d +++ /dev/null @@ -1,71 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadappa.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadappa; -import esm.imports; - -/* - * Alchemist apparatus - */ - -struct Apparatus -{ - enum AppaType : int - { - MortarPestle = 0, - Albemic = 1, - Calcinator = 2, - Retort = 3 - } - - align(1) struct AADTstruct - { - AppaType type; - float quality; - float weight; - int value; - - static assert(AADTstruct.sizeof == 16); - } - mixin LoadT!(); - - AADTstruct data; - MeshIndex model; - IconIndex icon; - Script *script; - - void load() - {with(esFile){ - model = getMesh(); - name = getHNString("FNAM"); - readHNExact(&data, data.sizeof, "AADT"); - script = getHNOPtr!(Script)("SCRI", scripts); - icon = getIcon(); - - makeProto(); - - proto.setFloat("quality", data.quality); - proto.setInt("type", data.type); - }} -} -ListID!(Apparatus) appas; diff --git a/old_d_version/esm/loadbook.d b/old_d_version/esm/loadbook.d deleted file mode 100644 index 11bec8373..000000000 --- a/old_d_version/esm/loadbook.d +++ /dev/null @@ -1,69 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadbook.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadbook; -import esm.imports; - -/* - * Books - */ - -struct Book -{ - align(1) struct BKDTstruct - { - float weight; - int value, isScroll, skillID, enchant; - - static assert(BKDTstruct.sizeof == 20); - } - - BKDTstruct data; - - MeshIndex model; - IconIndex icon; - Script *script; - Enchantment *enchant; - - mixin LoadT; - char[] text; - - LoadState state; - - void load() - {with(esFile){ - model = getMesh(); - name = getHNOString("FNAM"); - readHNExact(&data, data.sizeof, "BKDT"); - script = getHNOPtr!(Script)("SCRI", scripts); - icon = getOIcon(); - text = getHNOString("TEXT"); - enchant = getHNOPtr!(Enchantment)("ENAM", enchants); - - makeProto(); - - proto.setInt("skillID", data.skillID); - proto.setBool("isScroll", data.isScroll != 0); - }} -} -ListID!(Book) books; diff --git a/old_d_version/esm/loadclot.d b/old_d_version/esm/loadclot.d deleted file mode 100644 index 6a953025f..000000000 --- a/old_d_version/esm/loadclot.d +++ /dev/null @@ -1,86 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadclot.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadclot; -import esm.imports; -import esm.loadarmo; - -/* - * Clothing - */ - -struct Clothing -{ - enum Type : int - { - Pants = 0, - Shoes = 1, - Shirt = 2, - Belt = 3, - Robe = 4, - RGlove = 5, - LGlove = 6, - Skirt = 7, - Ring = 8, - Amulet = 9 - } - - struct CTDTstruct - { - Type type; - float weight; - short value; - short enchant; - - static assert(CTDTstruct.sizeof == 12); - } - - CTDTstruct data; - - mixin LoadT; - - PartReferenceList parts; - - MeshIndex model; - IconIndex icon; - Enchantment *enchant; - Script *script; - - void load() - {with(esFile){ - model = getMesh(); - name = getHNOString("FNAM"); - readHNExact(&data, data.sizeof, "CTDT"); - - script = getHNOPtr!(Script)("SCRI", scripts); - icon = getOIcon(); - - parts.load(); - - enchant = getHNOPtr!(Enchantment)("ENAM", enchants); - - makeProto(); - proto.setInt("type", data.type); - }} -} -ListID!(Clothing) clothes; diff --git a/old_d_version/esm/loadcrec.d b/old_d_version/esm/loadcrec.d deleted file mode 100644 index 2ce223b1f..000000000 --- a/old_d_version/esm/loadcrec.d +++ /dev/null @@ -1,59 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadcrec.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadcrec; -import esm.imports; - -/* - * Creature and container change information? Used in save games only. - */ - -struct LoadCREC -{ - void load(TES3File f) - { - writefln("Creature-changer %s", f.getHNString("NAME")); - writefln(" Index: ", f.getHNInt("INDX")); - - while(f.hasMoreSubs) - { - f.getSubName(); - f.skipHSub(); - } - } -} - -struct LoadCNTC -{ - void load(TES3File f) - { - writefln("Itemlist-changer %s", f.getHNString("NAME")); - writefln(" Index: ", f.getHNInt("INDX")); - - while(f.hasMoreSubs) - { - f.getSubName(); - f.skipHSub(); - } - } -} diff --git a/old_d_version/esm/loadench.d b/old_d_version/esm/loadench.d deleted file mode 100644 index 3a882d3b7..000000000 --- a/old_d_version/esm/loadench.d +++ /dev/null @@ -1,70 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadench.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadench; -import esm.imports; - -/* - * Enchantments - */ - -struct Enchantment -{ - enum Type : int - { - CastOnce = 0, - WhenStrikes = 1, - WhenUsed = 2, - ConstantEffect = 3 - } - - align(1) struct ENDTstruct - { - Type type; - int cost; - int charge; - int autocalc; // Guessing this is 1 if we are supposed to auto - // calculate - - static assert(ENDTstruct.sizeof == 16); - } - ENDTstruct data; - - EffectList effects; - - char[] id; - LoadState state; - - void load() - {with(esFile){ - readHNExact(&data, data.sizeof, "ENDT"); - - effects = getRegion().getBuffer!(ENAMstruct)(0,1); - while(isNextSub("ENAM")) - { - effects.length = effects.length + 1; - readHExact(&effects.array[$-1], effects.array[$-1].sizeof); - } - }} -} -ListID!(Enchantment) enchants; diff --git a/old_d_version/esm/loadglob.d b/old_d_version/esm/loadglob.d deleted file mode 100644 index aa2a8c767..000000000 --- a/old_d_version/esm/loadglob.d +++ /dev/null @@ -1,63 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadglob.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadglob; -import esm.imports; - -/* - * Global script variables - */ - -struct Global -{ - LoadState state; - char[] id; - - float value; - - VarType type; - - void load() - { - VarType t; - char[] tmp = esFile.getHNString("FNAM"); - switch(tmp) - { - case "s": t = VarType.Short; break; - case "l": t = VarType.Int; break; - case "f": t = VarType.Float; break; - default: - esFile.fail("Illegal global variable type " ~ tmp); - } - if(state == LoadState.Previous && t != type) - esFile.fail(format("Variable changed type from %d to %d", - cast(int)type, cast(int)t)); - - type = t; - - // The value looks like a float in many cases, and like an integer - // in others (for the s type at least.) Figure it out. - value = esFile.getHNFloat("FLTV"); - } -} -ListID!(Global) globals; diff --git a/old_d_version/esm/loadingr.d b/old_d_version/esm/loadingr.d deleted file mode 100644 index a76bddff3..000000000 --- a/old_d_version/esm/loadingr.d +++ /dev/null @@ -1,64 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadingr.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadingr; -import esm.imports; - -/* - * Alchemy ingredient - */ - -struct Ingredient -{ - align(1) struct IRDTstruct - { - float weight; - int value; - int[4] effectID; // Effect, 0 or -1 means none - SkillEnum[4] skills; // Skill related to effect - Attribute[4] attributes; // Attribute related to effect - - static assert(IRDTstruct.sizeof==56); - } - - IRDTstruct data; - - mixin LoadT; - - MeshIndex model; - IconIndex icon; - Script *script; - - void load() - {with(esFile){ - model = getMesh(); - name = getHNString("FNAM"); - readHNExact(&data, data.sizeof, "IRDT"); - - script = getHNOPtr!(Script)("SCRI", scripts); - icon = getOIcon(); - - makeProto(); - }} -} -ListID!(Ingredient) ingreds; diff --git a/old_d_version/esm/loadligh.d b/old_d_version/esm/loadligh.d deleted file mode 100644 index ce583a9b3..000000000 --- a/old_d_version/esm/loadligh.d +++ /dev/null @@ -1,87 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadligh.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ -module esm.loadligh; -import esm.imports; - -/* - * Lights - */ - -struct Light -{ - enum Flags : uint - { - Dynamic = 0x001, - Carry = 0x002, // Can be carried - Negative = 0x004, // Negative light? - Flicker = 0x008, - Fire = 0x010, - OffDefault = 0x020, // Off by default - FlickerSlow = 0x040, - Pulse = 0x080, - PulseSlow = 0x100 - } - - align(1) struct LHDTstruct - { - float weight; - int value; - int time; // Duration - int radius; - Color color; - Flags flags; - - static assert(LHDTstruct.sizeof == 24); - } - - LHDTstruct data; - - mixin LoadT!(); - - Sound* sound; - Script* script; - - MeshIndex model; - IconIndex icon; - - void load() - {with(esFile){ - model = getMesh(); - name = getHNOString("FNAM"); - icon = getOIcon(); - - readHNExact(&data, data.sizeof, "LHDT"); - - script = getHNOPtr!(Script)("SCRI", scripts); - sound = getHNOPtr!(Sound)("SNAM", sounds); - - // Stash the data in the Monster object prototype - - makeProto(); - - proto.setUint("flags", data.flags); - proto.setFloat("lifetime", data.time); - proto.setInt("radius", data.radius); - }} -} -ListID!(Light) lights; diff --git a/old_d_version/esm/loadmisc.d b/old_d_version/esm/loadmisc.d deleted file mode 100644 index 602c19c80..000000000 --- a/old_d_version/esm/loadmisc.d +++ /dev/null @@ -1,64 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadmisc.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadmisc; -import esm.imports; - -/* - * Misc inventory items, basically things that have no use but can be - * carried, bought and sold. It also includes keys. - */ - -struct Misc -{ - struct MCDTstruct - { - float weight; - int value; - int isKey; // There are many keys in Morrowind.esm that has this - // set to 0. TODO: Check what this field corresponds to - // in the editor. - - static assert(MCDTstruct.sizeof == 12); - } - MCDTstruct data; - - mixin LoadT; - - MeshIndex model; - IconIndex icon; - Script *script; - - void load() - {with(esFile){ - model = getMesh(); - name = getHNOString("FNAM"); - readHNExact(&data, data.sizeof, "MCDT"); - script = getHNOPtr!(Script)("SCRI", scripts); - icon = getOIcon(); - - makeProto(); - proto.setInt("isKey", data.isKey); - }} -} -ListID!(Misc) miscItems; diff --git a/old_d_version/esm/loadrace.d b/old_d_version/esm/loadrace.d deleted file mode 100644 index f0179c750..000000000 --- a/old_d_version/esm/loadrace.d +++ /dev/null @@ -1,85 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadrace.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadrace; - -import esm.imports; - -import esm.loadbsgn; // Defines PowerList - -/* - * Race definition - */ - -struct Race -{ - align(1) struct SkillBonus - { - SkillEnum skill; - int bonus; - } - static assert(SkillBonus.sizeof == 8); - - enum Flags - { - Playable = 0x01, - Beast = 0x02 - } - - align(1) struct RADTstruct - { - // List of skills that get a bonus - SkillBonus bonus[7]; - - // Attribute values for male/female - int[2] strength, intelligence, willpower, agility, - speed, endurance, personality, luck; - - // The actual eye level height (in game units) is (probably) given - // as 'height' times 128. This has not been tested yet. - float[2] height, weight; - - Flags flags; // 0x1 - playable, 0x2 - beast race - - static assert(RADTstruct.sizeof == 140); - } - - RADTstruct data; - - LoadState state; - - char[] id, name, description; - - SpellList powers; - - void load() - {with(esFile){ - name = getHNString("FNAM"); - readHNExact(&data, data.sizeof, "RADT"); - - powers.load(); - - description = getHNOString("DESC"); - }} -} -ListID!(Race) races; diff --git a/old_d_version/esm/loadskil.d b/old_d_version/esm/loadskil.d deleted file mode 100644 index fe3b999cf..000000000 --- a/old_d_version/esm/loadskil.d +++ /dev/null @@ -1,85 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadskil.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadskil; - -import esm.imports; - -/* - * Skill information - */ - -enum Specialization : int - { - Combat = 0, - Magic = 1, - Stealth = 2 - } - -struct Skill -{ - align(1) struct SKDTstruct - { - Attribute attribute; - Specialization specialization; // 0 - Combat, 1 - Magic, 2 - Stealth - float useValue[4]; // How much skill improves. Meaning of each - // field depends on what skill this is. - } - static assert(SKDTstruct.sizeof == 24); - - SKDTstruct data; - - char[] description; - - void load() - { - esFile.readHNExact(&data, data.sizeof, "SKDT"); - description = esFile.getHNOString("DESC"); - } -} - -class SkillList : ListKeeper -{ - // See SkillEnum in defs.d for a definition of skills - Skill[SkillEnum.Length] list; - static assert(list.length == 27); - - override: - - void load() - { - int index = esFile.getHNInt("INDX"); - - if(index < 0 || index >= list.length) - esFile.fail("Invalid skill number " ~ .toString(index)); - - list[index].load(); - } - - void endFile() {} - - uint length() { return list.length; } - - void *lookup(char[] s) { assert(0); } -} -SkillList skills; diff --git a/old_d_version/esm/loadsndg.d b/old_d_version/esm/loadsndg.d deleted file mode 100644 index c966c7a17..000000000 --- a/old_d_version/esm/loadsndg.d +++ /dev/null @@ -1,66 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadsndg.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadsndg; -import esm.imports; - -import esm.loadcrea; - -/* - * Sound generator. This describes the sounds a creature make. - */ - -struct SoundGenerator -{ - enum Type - { - LeftFoot = 0, - RightFoot = 1, - SwimLeft = 2, - SwimRight = 3, - Moan = 4, - Roar = 5, - Scream = 6, - Land = 7 - } - - // Type - Type type; - - char[] id; - LoadState state; - - // Which creature this applies to, if any. - Creature *creature; - - Sound *sound; - - void load() - {with(esFile){ - this.type = cast(Type)getHNInt("DATA"); - - creature = getHNOPtr!(Creature)("CNAM", creatures); - sound = getHNPtr!(Sound)("SNAM", sounds); - }} -} -ListID!(SoundGenerator) soundGens; diff --git a/old_d_version/esm/loadsscr.d b/old_d_version/esm/loadsscr.d deleted file mode 100644 index 7c1b97c41..000000000 --- a/old_d_version/esm/loadsscr.d +++ /dev/null @@ -1,55 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadsscr.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadsscr; -import esm.imports; - -/* - * Startup script. I think this is simply a 'main' script that is run - * from the begining. The SSCR records contain a DATA identifier which - * is totally useless, and a NAME which is simply a script reference. - */ - -struct StartScriptList -{ - RegionBuffer!(Script*) list; - - void init() - { - // Set up the list - list = esmRegion.getBuffer!(Script*)(0,1); - } - - // Load a record and add it to the list - void load() - {with(esFile){ - getSubNameIs("DATA"); - skipHSub(); - list ~= getHNPtr!(Script)("NAME", scripts); - }} - - uint length() - { return list.length; } -} - -StartScriptList startScripts; diff --git a/old_d_version/esm/loadstat.d b/old_d_version/esm/loadstat.d deleted file mode 100644 index 5b6092910..000000000 --- a/old_d_version/esm/loadstat.d +++ /dev/null @@ -1,54 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.snaptoad.com/ - - This file (loadstat.d) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -module esm.loadstat; - -import esm.imports; - -/* - * Definition of static object. - * - * A stat record is basically just a reference to a nif file. Some - * esps seem to contain copies of the STAT entries from the esms, and - * the esms themselves contain several identical entries. Perhaps all - * statics referenced in a file is also put in the file? Since we are - * only reading files it doesn't much matter to us, but it would if we - * were writing. You can check some files later, when you decode the - * CELL blocks, if you want to test this hypothesis. - */ - -struct Static -{ - mixin LoadT; - - MeshIndex model; - - void load() - { - model = esFile.getMesh(); - - makeProto(); - } -} - -ListID!(Static) statics;