2012-09-23 22:11:08 +04:00
|
|
|
#ifndef OPENMW_ESM_SCPT_H
|
|
|
|
#define OPENMW_ESM_SCPT_H
|
2010-02-22 14:09:43 +01:00
|
|
|
|
2012-09-17 11:37:50 +04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-06-04 16:07:59 +02:00
|
|
|
#include "components/esm/defs.hpp"
|
2022-01-22 15:58:41 +01:00
|
|
|
#include "components/esm/esmcommon.hpp"
|
2010-02-22 14:09:43 +01:00
|
|
|
|
2011-04-08 17:58:21 +04:00
|
|
|
namespace ESM
|
|
|
|
{
|
2010-02-22 14:09:43 +01:00
|
|
|
|
2012-10-01 00:51:54 +04:00
|
|
|
class ESMReader;
|
|
|
|
class ESMWriter;
|
|
|
|
|
2010-02-22 14:09:43 +01:00
|
|
|
/*
|
|
|
|
* Script definitions
|
|
|
|
*/
|
|
|
|
|
2012-09-30 23:34:53 +04:00
|
|
|
class Script
|
2010-02-22 14:09:43 +01:00
|
|
|
{
|
2010-07-04 20:17:10 -07:00
|
|
|
public:
|
2022-06-04 16:07:59 +02:00
|
|
|
constexpr static unsigned int sRecordId = REC_SCPT;
|
|
|
|
|
2015-06-14 02:31:00 +02:00
|
|
|
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
2021-10-12 00:18:23 +02:00
|
|
|
static std::string_view getRecordType() { return "Script"; }
|
2013-09-24 13:17:28 +02:00
|
|
|
|
2011-04-08 17:58:21 +04:00
|
|
|
struct SCHDstruct
|
|
|
|
{
|
2014-07-25 10:37:34 +02:00
|
|
|
/// Data from script-precompling in the editor.
|
|
|
|
/// \warning Do not use them. OpenCS currently does not precompile scripts.
|
2012-09-17 11:37:50 +04:00
|
|
|
int mNumShorts, mNumLongs, mNumFloats, mScriptDataSize, mStringTableSize;
|
2015-01-22 03:54:33 +01:00
|
|
|
};
|
|
|
|
struct SCHD
|
|
|
|
{
|
2019-10-10 13:29:25 +04:00
|
|
|
std::string mName;
|
2015-01-22 03:54:33 +01:00
|
|
|
Script::SCHDstruct mData;
|
2019-10-28 18:58:16 +04:00
|
|
|
};
|
2011-04-08 17:58:21 +04:00
|
|
|
|
2021-07-25 19:53:41 +10:00
|
|
|
unsigned int mRecordFlags;
|
2012-10-26 22:22:55 +04:00
|
|
|
std::string mId;
|
|
|
|
|
2012-09-17 11:37:50 +04:00
|
|
|
SCHDstruct mData;
|
2011-04-08 17:58:21 +04:00
|
|
|
|
2014-07-25 10:37:34 +02:00
|
|
|
/// Variable names generated by script-precompiling in the editor.
|
|
|
|
/// \warning Do not use this field. OpenCS currently does not precompile scripts.
|
|
|
|
std::vector<std::string> mVarNames;
|
|
|
|
|
|
|
|
/// Bytecode generated from script-precompiling in the editor.
|
|
|
|
/// \warning Do not use this field. OpenCS currently does not precompile scripts.
|
|
|
|
std::vector<unsigned char> mScriptData;
|
|
|
|
|
|
|
|
/// Script source code
|
|
|
|
std::string mScriptText;
|
2011-04-08 17:58:21 +04:00
|
|
|
|
2015-07-20 17:23:14 +03:00
|
|
|
void load(ESMReader &esm, bool &isDeleted);
|
|
|
|
void save(ESMWriter &esm, bool isDeleted = false) const;
|
2013-04-07 15:17:35 +02:00
|
|
|
|
|
|
|
void blank();
|
|
|
|
///< Set record to default state (does not touch the ID/index).
|
2015-02-12 04:56:05 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void loadSCVR(ESMReader &esm);
|
2010-02-22 14:09:43 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|