Finished ALCH, APPA, BOOK, CLOT, CREC, ENCH, GLOB, INGR, LIGH, MISC, RACE, SKIL, SNDG, SSCR and STAT. Phew!

pull/7/head
Nicolay Korslund 15 years ago
parent ae6136816d
commit fb690cce9b

@ -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.
*/

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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,

@ -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;

@ -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;

@ -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;

@ -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;

@ -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();
}
}
}

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;
Loading…
Cancel
Save