mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
Finished SPEL, added defs.hpp
This commit is contained in:
parent
288b9362ae
commit
ae6136816d
8 changed files with 93 additions and 200 deletions
60
esm/defs.hpp
Normal file
60
esm/defs.hpp
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#ifndef _ESM_DEFS_H
|
||||||
|
#define _ESM_DEFS_H
|
||||||
|
|
||||||
|
#include "esm_reader.hpp"
|
||||||
|
|
||||||
|
namespace ESM {
|
||||||
|
|
||||||
|
/** A list of references to spells and spell effects. This is shared
|
||||||
|
between the records BSGN, NPC and RACE.
|
||||||
|
*/
|
||||||
|
struct SpellList
|
||||||
|
{
|
||||||
|
std::vector<std::string> list;
|
||||||
|
|
||||||
|
void load(ESMReader &esm)
|
||||||
|
{
|
||||||
|
while(esm.isNextSub("NPCS"))
|
||||||
|
list.push_back(esm.getHString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Defines a spell effect. Shared between SPEL (Spells), ALCH
|
||||||
|
(Potions) and ENCH (Item enchantments) records
|
||||||
|
*/
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(1)
|
||||||
|
struct ENAMstruct
|
||||||
|
{
|
||||||
|
// Magical effect, hard-coded ID
|
||||||
|
short effectID;
|
||||||
|
|
||||||
|
// Which skills/attributes are affected (for restore/drain spells
|
||||||
|
// etc.)
|
||||||
|
char skill, attribute; // -1 if N/A
|
||||||
|
|
||||||
|
// Other spell parameters
|
||||||
|
int range; // 0 - self, 1 - touch, 2 - target
|
||||||
|
int area, duration, magnMin, magnMax;
|
||||||
|
|
||||||
|
// Struct size should be 24 bytes
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
struct EffectList
|
||||||
|
{
|
||||||
|
std::vector<ENAMstruct> list;
|
||||||
|
|
||||||
|
void load(ESMReader &esm)
|
||||||
|
{
|
||||||
|
ENAMstruct s;
|
||||||
|
while(esm.isNextSub("ENAM"))
|
||||||
|
{
|
||||||
|
esm.getHT(s, 24);
|
||||||
|
list.push_back(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -279,6 +279,15 @@ public:
|
||||||
getT(x);
|
getT(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Version with extra size checking, to make sure the compiler
|
||||||
|
// doesn't mess up our struct padding.
|
||||||
|
template <typename X>
|
||||||
|
void getHT(X &x, int size)
|
||||||
|
{
|
||||||
|
assert(sizeof(X) == size);
|
||||||
|
getHT(x);
|
||||||
|
}
|
||||||
|
|
||||||
// Read a string by the given name if it is the next record.
|
// Read a string by the given name if it is the next record.
|
||||||
std::string getHNOString(const char* name)
|
std::string getHNOString(const char* name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef _ESM_BSGN_H
|
#ifndef _ESM_BSGN_H
|
||||||
#define _ESM_BSGN_H
|
#define _ESM_BSGN_H
|
||||||
|
|
||||||
|
#include "defs.hpp"
|
||||||
#include "esm_reader.hpp"
|
#include "esm_reader.hpp"
|
||||||
#include "loadspel.hpp"
|
|
||||||
|
|
||||||
namespace ESM {
|
namespace ESM {
|
||||||
|
|
||||||
|
|
|
@ -5,25 +5,6 @@
|
||||||
|
|
||||||
namespace ESM {
|
namespace ESM {
|
||||||
|
|
||||||
/** A list of references to spells and spell effects. This is shared
|
|
||||||
between the records BSGN, NPC and RACE.
|
|
||||||
|
|
||||||
TODO: This should also be part of a shared definition file
|
|
||||||
*/
|
|
||||||
struct SpellList
|
|
||||||
{
|
|
||||||
std::vector<std::string> list;
|
|
||||||
|
|
||||||
void load(ESMReader &esm)
|
|
||||||
{
|
|
||||||
while(esm.isNextSub("NPCS"))
|
|
||||||
list.push_back(esm.getHString());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* TODO: Not completely ported yet - depends on EffectList, which
|
|
||||||
should be defined in a shared definition file.
|
|
||||||
|
|
||||||
struct Spell
|
struct Spell
|
||||||
{
|
{
|
||||||
enum SpellType
|
enum SpellType
|
||||||
|
@ -51,26 +32,15 @@ struct Spell
|
||||||
};
|
};
|
||||||
|
|
||||||
SPDTstruct data;
|
SPDTstruct data;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
EffectList effects;
|
EffectList effects;
|
||||||
|
|
||||||
void load()
|
void load(ESMReader &esm)
|
||||||
{with(esFile){
|
{
|
||||||
name = getHNOString("FNAM");
|
name = esm.getHNOString("FNAM");
|
||||||
getHNT(data, "SPDT", 12);
|
esm.getHNT(data, "SPDT", 12);
|
||||||
|
effects.load(esm);
|
||||||
effects = getRegion().getBuffer!(ENAMstruct)(0,1);
|
}
|
||||||
|
};
|
||||||
while(isNextSub("ENAM"))
|
|
||||||
{
|
|
||||||
effects.length = effects.length + 1;
|
|
||||||
readHExact(&effects.array[$-1], effects.array[$-1].sizeof);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,6 +64,15 @@ int main(int argc, char**argv)
|
||||||
|
|
||||||
switch(n.val)
|
switch(n.val)
|
||||||
{
|
{
|
||||||
|
case REC_ACTI:
|
||||||
|
{
|
||||||
|
Activator ac;
|
||||||
|
ac.load(esm);
|
||||||
|
cout << " Name: " << ac.name << endl;
|
||||||
|
cout << " Mesh: " << ac.model << endl;
|
||||||
|
cout << " Script: " << ac.script << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case REC_ARMO:
|
case REC_ARMO:
|
||||||
{
|
{
|
||||||
Armor am;
|
Armor am;
|
||||||
|
@ -113,6 +122,13 @@ int main(int argc, char**argv)
|
||||||
cout << " Volume: " << (int)d.data.volume << endl;
|
cout << " Volume: " << (int)d.data.volume << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case REC_SPEL:
|
||||||
|
{
|
||||||
|
Spell s;
|
||||||
|
s.load(esm);
|
||||||
|
cout << " Name: " << s.name << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
cout << " Skipping\n";
|
cout << " Skipping\n";
|
||||||
esm.skipRecord();
|
esm.skipRecord();
|
||||||
|
|
|
@ -1,53 +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 (loadacti.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.loadacti;
|
|
||||||
|
|
||||||
import esm.imports;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Activator
|
|
||||||
*
|
|
||||||
* Activators are static in-world objects that pop up a caption when
|
|
||||||
* you stand close and look at them, for example signs. Some
|
|
||||||
* activators have scrips, such as beds that let you sleep when you
|
|
||||||
* activate them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct Activator
|
|
||||||
{
|
|
||||||
mixin LoadT;
|
|
||||||
|
|
||||||
Script *script;
|
|
||||||
MeshIndex model;
|
|
||||||
|
|
||||||
void load()
|
|
||||||
{with(esFile){
|
|
||||||
model = getMesh();
|
|
||||||
name = getHNString("FNAM");
|
|
||||||
script = getHNOPtr!(Script)("SCRI", scripts);
|
|
||||||
|
|
||||||
makeProto();
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
ListID!(Activator) activators;
|
|
|
@ -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 (loadbsgn.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.loadbsgn;
|
|
||||||
import esm.imports;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Birth signs
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct BirthSign
|
|
||||||
{
|
|
||||||
char[] description;
|
|
||||||
|
|
||||||
mixin LoadT;
|
|
||||||
|
|
||||||
TextureIndex texture;
|
|
||||||
|
|
||||||
// List of powers and abilities that come with this birth sign.
|
|
||||||
SpellList powers;
|
|
||||||
|
|
||||||
void load()
|
|
||||||
{with(esFile){
|
|
||||||
name = getHNString("FNAM");
|
|
||||||
|
|
||||||
texture = getOTexture();
|
|
||||||
|
|
||||||
description = getHNOString("DESC");
|
|
||||||
|
|
||||||
powers.load();
|
|
||||||
|
|
||||||
// No monster class equivalent yet
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
ListID!(BirthSign) birthSigns;
|
|
|
@ -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 (loadsoun.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.loadsoun;
|
|
||||||
|
|
||||||
import esm.imports;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sounds
|
|
||||||
*/
|
|
||||||
|
|
||||||
align(1) struct SOUNstruct
|
|
||||||
{
|
|
||||||
ubyte volume, minRange, maxRange;
|
|
||||||
}
|
|
||||||
static assert(SOUNstruct.sizeof == 3);
|
|
||||||
|
|
||||||
struct Sound
|
|
||||||
{
|
|
||||||
LoadState state;
|
|
||||||
char[] id;
|
|
||||||
|
|
||||||
SOUNstruct data;
|
|
||||||
|
|
||||||
SoundIndex sound;
|
|
||||||
|
|
||||||
void load()
|
|
||||||
{
|
|
||||||
sound = esFile.getSound();
|
|
||||||
esFile.readHNExact(&data, data.sizeof, "DATA");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ListID!(Sound) sounds;
|
|
Loading…
Reference in a new issue