id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
35,741
|
storage.hpp
|
OpenMW_openmw/components/esmterrain/storage.hpp
|
#ifndef OPENMW_COMPONENTS_ESMTERRAIN_STORAGE_H
#define OPENMW_COMPONENTS_ESMTERRAIN_STORAGE_H
#include <cassert>
#include <mutex>
#include <components/terrain/storage.hpp>
#include <components/esm/esmterrain.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/esm3/loadltex.hpp>
namespace ESM4
{
struct Land;
}
namespace ESM
{
class LandData;
}
namespace VFS
{
class Manager;
}
namespace ESMTerrain
{
class LandCache;
/// @brief Wrapper around Land Data with reference counting. The wrapper needs to be held as long as the data is
/// still in use
class LandObject : public osg::Object
{
public:
LandObject() = default;
LandObject(const ESM::Land& land, int loadFlags);
LandObject(const ESM4::Land& land, int loadFlags);
META_Object(ESMTerrain, LandObject)
const ESM::LandData* getData(int flags) const
{
if ((mData.getLoadFlags() & flags) != flags)
return nullptr;
return &mData;
}
int getPlugin() const { return mData.getPlugin(); }
private:
ESM::LandData mData;
LandObject(const LandObject& copy, const osg::CopyOp& copyOp);
};
// Since plugins can define new texture palettes, we need to know the plugin index too
// in order to retrieve the correct texture name.
// pair <texture id, plugin id>
using UniqueTextureId = std::pair<std::uint16_t, int>;
/// @brief Feeds data from ESM terrain records (ESM::Land, ESM::LandTexture)
/// into the terrain component, converting it on the fly as needed.
class Storage : public Terrain::Storage
{
public:
Storage(const VFS::Manager* vfs, std::string_view normalMapPattern = {},
std::string_view normalHeightMapPattern = {}, bool autoUseNormalMaps = false,
std::string_view specularMapPattern = {}, bool autoUseSpecularMaps = false);
// Not implemented in this class, because we need different Store implementations for game and editor
virtual osg::ref_ptr<const LandObject> getLand(ESM::ExteriorCellLocation cellLocation) = 0;
virtual const std::string* getLandTexture(std::uint16_t index, int plugin) = 0;
/// Get bounds of the whole terrain in cell units
void getBounds(float& minX, float& maxX, float& minY, float& maxY, ESM::RefId worldspace) override = 0;
/// Get the minimum and maximum heights of a terrain region.
/// @note Will only be called for chunks with size = minBatchSize, i.e. leafs of the quad tree.
/// Larger chunks can simply merge AABB of children.
/// @param size size of the chunk in cell units
/// @param center center of the chunk in cell units
/// @param min min height will be stored here
/// @param max max height will be stored here
/// @return true if there was data available for this terrain chunk
bool getMinMaxHeights(
float size, const osg::Vec2f& center, ESM::RefId worldspace, float& min, float& max) override;
/// Fill vertex buffers for a terrain chunk.
/// @note May be called from background threads. Make sure to only call thread-safe functions from here!
/// @note Vertices should be written in row-major order (a row is defined as parallel to the x-axis).
/// The specified positions should be in local space, i.e. relative to the center of the terrain chunk.
/// @param lodLevel LOD level, 0 = most detailed
/// @param size size of the terrain chunk in cell units
/// @param center center of the chunk in cell units
/// @param positions buffer to write vertices
/// @param normals buffer to write vertex normals
/// @param colours buffer to write vertex colours
void fillVertexBuffers(int lodLevel, float size, const osg::Vec2f& center, ESM::RefId worldspace,
osg::Vec3Array& positions, osg::Vec3Array& normals, osg::Vec4ubArray& colours) override;
/// Create textures holding layer blend values for a terrain chunk.
/// @note The terrain chunk shouldn't be larger than one cell since otherwise we might
/// have to do a ridiculous amount of different layers. For larger chunks, composite maps should be used.
/// @note May be called from background threads.
/// @param chunkSize size of the terrain chunk in cell units
/// @param chunkCenter center of the chunk in cell units
/// @param blendmaps created blendmaps will be written here
/// @param layerList names of the layer textures used will be written here
void getBlendmaps(float chunkSize, const osg::Vec2f& chunkCenter, ImageVector& blendmaps,
std::vector<Terrain::LayerInfo>& layerList, ESM::RefId worldspace) override;
float getHeightAt(const osg::Vec3f& worldPos, ESM::RefId worldspace) override;
/// Get the transformation factor for mapping cell units to world units.
float getCellWorldSize(ESM::RefId worldspace) override;
/// Get the number of vertices on one side for each cell. Should be (power of two)+1
int getCellVertices(ESM::RefId worldspace) override;
int getBlendmapScale(float chunkSize) override;
float getVertexHeight(const ESM::LandData* data, int x, int y)
{
const int landSize = data->getLandSize();
assert(x < landSize);
assert(y < landSize);
return data->getHeights()[y * landSize + x];
}
private:
const VFS::Manager* mVFS;
inline void fixNormal(
osg::Vec3f& normal, ESM::ExteriorCellLocation cellLocation, int col, int row, LandCache& cache);
inline void fixColour(
osg::Vec4ub& colour, ESM::ExteriorCellLocation cellLocation, int col, int row, LandCache& cache);
inline void averageNormal(
osg::Vec3f& normal, ESM::ExteriorCellLocation cellLocation, int col, int row, LandCache& cache);
inline const LandObject* getLand(ESM::ExteriorCellLocation cellLocation, LandCache& cache);
virtual bool useAlteration() const { return false; }
virtual void adjustColor(int col, int row, const ESM::LandData* heightData, osg::Vec4ub& color) const;
virtual float getAlteredHeight(int col, int row) const;
std::string getTextureName(UniqueTextureId id);
std::map<std::string, Terrain::LayerInfo> mLayerInfoMap;
std::mutex mLayerInfoMutex;
std::string mNormalMapPattern;
std::string mNormalHeightMapPattern;
bool mAutoUseNormalMaps;
std::string mSpecularMapPattern;
bool mAutoUseSpecularMaps;
Terrain::LayerInfo getLayerInfo(const std::string& texture);
};
}
#endif
| 6,854
|
C++
|
.h
| 129
| 45.333333
| 119
| 0.682267
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,742
|
gridsampling.hpp
|
OpenMW_openmw/components/esmterrain/gridsampling.hpp
|
#ifndef OPENMW_COMPONENTS_ESMTERRAIN_GRIDSAMPLING_H
#define OPENMW_COMPONENTS_ESMTERRAIN_GRIDSAMPLING_H
#include <components/misc/mathutil.hpp>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <stdexcept>
#include <string>
#include <utility>
namespace ESMTerrain
{
inline std::pair<std::size_t, std::size_t> toCellAndLocal(
std::size_t begin, std::size_t global, std::size_t cellSize)
{
std::size_t cell = global / (cellSize - 1);
std::size_t local = global & (cellSize - 2);
if (global != begin && local == 0)
{
--cell;
local = cellSize - 1;
}
return { cell, local };
}
template <class F>
void sampleGrid(
std::size_t sampleSize, std::size_t beginX, std::size_t beginY, std::size_t endX, std::size_t endY, F&& f)
{
std::size_t vertY = 0;
for (std::size_t y = beginY; y < endY; y += sampleSize)
{
std::size_t vertX = 0;
for (std::size_t x = beginX; x < endX; x += sampleSize)
f(x, y, vertX++, vertY);
++vertY;
}
}
struct CellSample
{
int mCellX;
int mCellY;
std::size_t mSrcRow;
std::size_t mSrcCol;
std::size_t mDstRow;
std::size_t mDstCol;
};
template <class F>
void sampleCellGridSimple(std::size_t cellSize, std::size_t sampleSize, std::size_t beginX, std::size_t beginY,
std::size_t endX, std::size_t endY, F&& f)
{
assert(cellSize > 1);
assert(Misc::isPowerOfTwo(cellSize - 1));
assert(sampleSize != 0);
sampleGrid(sampleSize, beginX, beginY, endX, endY,
[&](std::size_t globalX, std::size_t globalY, std::size_t vertX, std::size_t vertY) {
const auto [cellX, x] = toCellAndLocal(beginX, globalX, cellSize);
const auto [cellY, y] = toCellAndLocal(beginY, globalY, cellSize);
f(cellX, cellY, x, y, vertX, vertY);
});
}
template <class F>
void sampleCellGrid(std::size_t cellSize, std::size_t sampleSize, std::size_t beginX, std::size_t beginY,
std::size_t distance, F&& f)
{
if (cellSize < 2 || !Misc::isPowerOfTwo(cellSize - 1))
throw std::invalid_argument("Invalid cell size for cell grid sampling: " + std::to_string(cellSize));
if (sampleSize == 0 || !Misc::isPowerOfTwo(sampleSize))
throw std::invalid_argument("Invalid sample size for cell grid sampling: " + std::to_string(sampleSize));
if (distance < 2 || !Misc::isPowerOfTwo(distance - 1))
throw std::invalid_argument("Invalid count for cell grid sampling: " + std::to_string(distance));
const std::size_t endX = beginX + distance;
const std::size_t endY = beginY + distance;
if (distance < cellSize || sampleSize > cellSize - 1)
return sampleCellGridSimple(cellSize, sampleSize, beginX, beginY, endX, endY, f);
const std::size_t beginCellX = beginX / (cellSize - 1);
const std::size_t beginCellY = beginY / (cellSize - 1);
const std::size_t endCellX = endX / (cellSize - 1);
const std::size_t endCellY = endY / (cellSize - 1);
std::size_t baseVertY = 0;
for (std::size_t cellY = beginCellY; cellY < endCellY; ++cellY)
{
const std::size_t offsetY = cellY * (cellSize - 1);
const std::size_t globalBeginY = offsetY <= beginY ? beginY : offsetY + sampleSize;
const std::size_t globalEndY = endY <= offsetY + cellSize ? endY : offsetY + cellSize;
assert(globalBeginY < globalEndY);
std::size_t baseVertX = 0;
std::size_t vertY = baseVertY;
for (std::size_t cellX = beginCellX; cellX < endCellX; ++cellX)
{
const std::size_t offsetX = cellX * (cellSize - 1);
const std::size_t globalBeginX = offsetX <= beginX ? beginX : offsetX + sampleSize;
const std::size_t globalEndX = endX <= offsetX + cellSize ? endX : offsetX + cellSize;
assert(globalBeginX < globalEndX);
vertY = baseVertY;
std::size_t vertX = baseVertX;
sampleGrid(sampleSize, globalBeginX, globalBeginY, globalEndX, globalEndY,
[&](std::size_t globalX, std::size_t globalY, std::size_t localVertX, std::size_t localVertY) {
vertX = baseVertX + localVertX;
vertY = baseVertY + localVertY;
f(cellX, cellY, globalX - offsetX, globalY - offsetY, vertX, vertY);
});
baseVertX = vertX + 1;
}
baseVertY = vertY + 1;
}
}
inline int getBlendmapSize(float size, int textureSize)
{
return static_cast<int>(textureSize * size) + 1;
}
inline std::pair<std::size_t, std::size_t> getBlendmapLocalRange(
int cell, int minCell, int textureSize, int min, int max)
{
const int cellMin = (cell - minCell) * textureSize;
const int cellMax = cellMin + textureSize - 1;
const std::size_t begin = min > cellMin ? min - cellMin : 0;
const std::size_t end = cellMax < max ? textureSize : max - cellMin + 1;
assert(begin < end);
assert(static_cast<int>(end) <= textureSize);
return { begin, end };
}
template <class F>
void sampleBlendmaps(float size, float minX, float minY, int textureSize, F&& f)
{
if (size <= 0)
throw std::invalid_argument("Invalid size for blendmap sampling: " + std::to_string(size));
if (textureSize <= 0)
throw std::invalid_argument("Invalid texture size for blendmap sampling: " + std::to_string(textureSize));
int minCellX = static_cast<int>(std::floor(minX));
const int minCellY = static_cast<int>(std::floor(minY));
int minRow = static_cast<int>((minX - minCellX) * (textureSize + 1)) - 1;
const int minCol = static_cast<int>((minY - minCellY) * (textureSize + 1));
if (minRow < 0)
{
--minCellX;
minRow += textureSize;
}
const int maxRow = minRow + static_cast<int>(textureSize * size);
const int maxCol = minCol + static_cast<int>(textureSize * size);
const int maxCellX = minCellX + maxRow / textureSize;
const int maxCellY = minCellY + maxCol / textureSize;
std::size_t baseDstCol = 0;
for (int cellY = minCellY; cellY <= maxCellY; ++cellY)
{
std::size_t baseDstRow = 0;
const auto [localBeginCol, localEndCol]
= getBlendmapLocalRange(cellY, minCellY, textureSize, minCol, maxCol);
const std::size_t colCount = localEndCol - localBeginCol;
for (int cellX = minCellX; cellX <= maxCellX; ++cellX)
{
const auto [localBeginRow, localEndRow]
= getBlendmapLocalRange(cellX, minCellX, textureSize, minRow, maxRow);
const std::size_t rowCount = localEndRow - localBeginRow;
for (std::size_t col = 0; col < colCount; ++col)
for (std::size_t row = 0; row < rowCount; ++row)
f(CellSample{
.mCellX = cellX,
.mCellY = cellY,
.mSrcRow = localBeginRow + row,
.mSrcCol = localBeginCol + col,
.mDstRow = baseDstRow + row,
.mDstCol = baseDstCol + col,
});
baseDstRow += rowCount;
}
baseDstCol += colCount;
}
}
}
#endif
| 7,829
|
C++
|
.h
| 169
| 35.35503
| 118
| 0.567755
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,743
|
version.hpp
|
OpenMW_openmw/components/version/version.hpp
|
#ifndef VERSION_HPP
#define VERSION_HPP
#include <filesystem>
#include <string>
#include <string_view>
namespace Version
{
std::string_view getVersion();
std::string_view getCommitHash();
std::string_view getTagHash();
int getLuaApiRevision();
int getPostprocessingApiRevision();
// Prepares string that contains version and commit hash.
std::string getOpenmwVersionDescription();
bool checkResourcesVersion(const std::filesystem::path& resourcePath);
std::string_view getDocumentationUrl();
}
#endif // VERSION_HPP
| 558
|
C++
|
.h
| 18
| 27.666667
| 74
| 0.7603
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,744
|
sdlmappings.hpp
|
OpenMW_openmw/components/sdlutil/sdlmappings.hpp
|
#ifndef SDLUTIL_SDLMAPPINGS
#define SDLUTIL_SDLMAPPINGS
#include <string>
#include <MyGUI_KeyCode.h>
#include <SDL_keycode.h>
namespace MyGUI
{
struct MouseButton;
}
namespace SDLUtil
{
std::string sdlControllerButtonToString(int button);
std::string sdlControllerAxisToString(int axis);
MyGUI::MouseButton sdlMouseButtonToMyGui(Uint8 button);
Uint8 myGuiMouseButtonToSdl(MyGUI::MouseButton button);
MyGUI::KeyCode sdlKeyToMyGUI(SDL_Keycode code);
SDL_Keycode myGuiKeyToSdl(MyGUI::KeyCode button);
}
#endif // !SDLUTIL_SDLMAPPINGS
| 567
|
C++
|
.h
| 19
| 26.947368
| 59
| 0.798148
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,745
|
vsyncmode.hpp
|
OpenMW_openmw/components/sdlutil/vsyncmode.hpp
|
#ifndef OPENMW_COMPONENTS_SDLUTIL_VSYNCMODE_H
#define OPENMW_COMPONENTS_SDLUTIL_VSYNCMODE_H
namespace SDLUtil
{
enum VSyncMode
{
Disabled = 0,
Enabled = 1,
Adaptive = 2
};
}
#endif
| 219
|
C++
|
.h
| 12
| 14.083333
| 45
| 0.673171
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,746
|
gl4es_init.h
|
OpenMW_openmw/components/sdlutil/gl4es_init.h
|
#ifndef OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
#define OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
#ifdef OPENMW_GL4ES_MANUAL_INIT
#include <SDL_video.h>
// Must be called once SDL video mode has been set,
// which creates a context.
//
// GL4ES can then query the context for features and extensions.
extern "C" void openmw_gl4es_init(SDL_Window* window);
#endif // OPENMW_GL4ES_MANUAL_INIT
#endif // OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
| 438
|
C++
|
.h
| 11
| 38.636364
| 64
| 0.785882
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,747
|
sdlgraphicswindow.hpp
|
OpenMW_openmw/components/sdlutil/sdlgraphicswindow.hpp
|
#ifndef OPENMW_COMPONENTS_SDLUTIL_SDLGRAPHICSWINDOW_H
#define OPENMW_COMPONENTS_SDLUTIL_SDLGRAPHICSWINDOW_H
#include <SDL_video.h>
#include <osgViewer/GraphicsWindow>
#include "vsyncmode.hpp"
namespace SDLUtil
{
class GraphicsWindowSDL2 : public osgViewer::GraphicsWindow
{
SDL_Window* mWindow;
SDL_GLContext mContext;
bool mValid;
bool mRealized;
bool mOwnsWindow;
VSyncMode mVSyncMode;
void init();
virtual ~GraphicsWindowSDL2();
public:
GraphicsWindowSDL2(osg::GraphicsContext::Traits* traits, VSyncMode vsyncMode);
bool isSameKindAs(const Object* object) const override
{
return dynamic_cast<const GraphicsWindowSDL2*>(object) != nullptr;
}
const char* libraryName() const override { return "osgViewer"; }
const char* className() const override { return "GraphicsWindowSDL2"; }
bool valid() const override { return mValid; }
/** Realise the GraphicsContext.*/
bool realizeImplementation() override;
/** Return true if the graphics context has been realised and is ready to use.*/
bool isRealizedImplementation() const override { return mRealized; }
/** Close the graphics context.*/
void closeImplementation() override;
/** Make this graphics context current.*/
bool makeCurrentImplementation() override;
/** Release the graphics context.*/
bool releaseContextImplementation() override;
/** Swap the front and back buffers.*/
void swapBuffersImplementation() override;
/** Set sync-to-vblank. */
void setSyncToVBlank(bool on) override;
void setSyncToVBlank(VSyncMode mode);
/** Set Window decoration.*/
bool setWindowDecorationImplementation(bool flag) override;
/** Raise specified window */
void raiseWindow() override;
/** Set the window's position and size.*/
bool setWindowRectangleImplementation(int x, int y, int width, int height) override;
/** Set the name of the window */
void setWindowName(const std::string& name) override;
/** Set mouse cursor to a specific shape.*/
void setCursor(MouseCursor cursor) override;
/** Get focus.*/
void grabFocus() override {}
/** Get focus on if the pointer is in this window.*/
void grabFocusIfPointerInWindow() override {}
/** WindowData is used to pass in the SDL2 window handle attached to the GraphicsContext::Traits structure. */
struct WindowData : public osg::Referenced
{
WindowData(SDL_Window* window)
: mWindow(window)
{
}
SDL_Window* mWindow;
};
private:
void setSwapInterval(VSyncMode mode);
};
}
#endif /* OSGGRAPHICSWINDOW_H */
| 2,911
|
C++
|
.h
| 69
| 33.681159
| 118
| 0.657183
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,748
|
events.hpp
|
OpenMW_openmw/components/sdlutil/events.hpp
|
#ifndef _SFO_EVENTS_H
#define _SFO_EVENTS_H
#include <SDL_events.h>
#include <SDL_types.h>
#include <SDL_version.h>
////////////
// Events //
////////////
namespace SDLUtil
{
/** Extended mouse event struct where we treat the wheel like an axis, like everyone expects */
struct MouseMotionEvent : SDL_MouseMotionEvent
{
Sint32 zrel;
Sint32 z;
};
struct TouchEvent
{
int mDevice;
int mFinger;
float mX;
float mY;
float mPressure;
#if SDL_VERSION_ATLEAST(2, 0, 14)
explicit TouchEvent(const SDL_ControllerTouchpadEvent& arg)
: mDevice(arg.touchpad)
, mFinger(arg.finger)
, mX(arg.x)
, mY(arg.y)
, mPressure(arg.pressure)
{
}
#endif
};
///////////////
// Listeners //
///////////////
class MouseListener
{
public:
virtual ~MouseListener() {}
virtual void mouseMoved(const MouseMotionEvent& arg) = 0;
virtual void mousePressed(const SDL_MouseButtonEvent& arg, Uint8 id) = 0;
virtual void mouseReleased(const SDL_MouseButtonEvent& arg, Uint8 id) = 0;
virtual void mouseWheelMoved(const SDL_MouseWheelEvent& arg) = 0;
};
class SensorListener
{
public:
virtual ~SensorListener() {}
virtual void sensorUpdated(const SDL_SensorEvent& arg) = 0;
virtual void displayOrientationChanged() = 0;
};
class KeyListener
{
public:
virtual ~KeyListener() {}
virtual void textInput(const SDL_TextInputEvent& arg) {}
virtual void keyPressed(const SDL_KeyboardEvent& arg) = 0;
virtual void keyReleased(const SDL_KeyboardEvent& arg) = 0;
};
class ControllerListener
{
public:
virtual ~ControllerListener() {}
virtual void buttonPressed(int deviceID, const SDL_ControllerButtonEvent& evt) = 0;
virtual void buttonReleased(int deviceID, const SDL_ControllerButtonEvent& evt) = 0;
virtual void axisMoved(int deviceID, const SDL_ControllerAxisEvent& arg) = 0;
virtual void controllerAdded(int deviceID, const SDL_ControllerDeviceEvent& arg) = 0;
virtual void controllerRemoved(const SDL_ControllerDeviceEvent& arg) = 0;
virtual void touchpadMoved(int deviceId, const TouchEvent& arg) = 0;
virtual void touchpadPressed(int deviceId, const TouchEvent& arg) = 0;
virtual void touchpadReleased(int deviceId, const TouchEvent& arg) = 0;
};
class WindowListener
{
public:
virtual ~WindowListener() {}
/** @remarks The window's visibility changed */
virtual void windowVisibilityChange(bool visible) {}
virtual void windowClosed() {}
virtual void windowResized(int x, int y) {}
};
}
#endif
| 2,845
|
C++
|
.h
| 85
| 26.705882
| 99
| 0.642075
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,749
|
imagetosurface.hpp
|
OpenMW_openmw/components/sdlutil/imagetosurface.hpp
|
#ifndef OPENMW_COMPONENTS_SDLUTIL_IMAGETOSURFACE_H
#define OPENMW_COMPONENTS_SDLUTIL_IMAGETOSURFACE_H
#include <memory>
struct SDL_Surface;
namespace osg
{
class Image;
}
namespace SDLUtil
{
typedef std::unique_ptr<SDL_Surface, void (*)(SDL_Surface*)> SurfaceUniquePtr;
/// Convert an osg::Image to an SDL_Surface.
SurfaceUniquePtr imageToSurface(osg::Image* image, bool flip = false);
}
#endif
| 418
|
C++
|
.h
| 15
| 25.333333
| 82
| 0.772727
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,750
|
sdlcursormanager.hpp
|
OpenMW_openmw/components/sdlutil/sdlcursormanager.hpp
|
#ifndef OPENMW_COMPONENTS_SDLUTIL_SDLCURSORMANAGER_H
#define OPENMW_COMPONENTS_SDLUTIL_SDLCURSORMANAGER_H
#include <map>
#include <string>
#include <SDL_types.h>
struct SDL_Cursor;
struct SDL_Surface;
namespace osg
{
class Image;
}
namespace SDLUtil
{
class SDLCursorManager
{
public:
SDLCursorManager();
virtual ~SDLCursorManager();
/// \brief sets whether to actively manage cursors or not
virtual void setEnabled(bool enabled);
/// \brief Tell the manager that the cursor has changed, giving the
/// name of the cursor we changed to ("arrow", "ibeam", etc)
virtual void cursorChanged(std::string_view name);
virtual void createCursor(std::string_view name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
Uint8 hotspot_y, int cursorWidth, int cursorHeight);
private:
void _createCursorFromResource(std::string_view name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
Uint8 hotspot_y, int cursorWidth, int cursorHeight);
void _putPixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
void _setGUICursor(std::string_view name);
typedef std::map<std::string, SDL_Cursor*, std::less<>> CursorMap;
CursorMap mCursorMap;
std::string mCurrentCursor;
bool mEnabled;
bool mInitialized;
};
}
#endif
| 1,401
|
C++
|
.h
| 38
| 30.894737
| 113
| 0.688889
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,751
|
sdlvideowrapper.hpp
|
OpenMW_openmw/components/sdlutil/sdlvideowrapper.hpp
|
#ifndef OPENMW_COMPONENTS_SDLUTIL_SDLVIDEOWRAPPER_H
#define OPENMW_COMPONENTS_SDLUTIL_SDLVIDEOWRAPPER_H
#include <osg/ref_ptr>
#include <SDL_types.h>
#include "vsyncmode.hpp"
struct SDL_Window;
namespace osgViewer
{
class Viewer;
}
namespace Settings
{
enum class WindowMode;
}
namespace SDLUtil
{
class VideoWrapper
{
public:
VideoWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> viewer);
~VideoWrapper();
void setSyncToVBlank(VSyncMode vsyncMode);
void setGammaContrast(float gamma, float contrast);
void setVideoMode(int width, int height, Settings::WindowMode windowMode, bool windowBorder);
void centerWindow();
private:
SDL_Window* mWindow;
osg::ref_ptr<osgViewer::Viewer> mViewer;
float mGamma;
float mContrast;
bool mHasSetGammaContrast;
// Store system gamma ramp on window creation. Restore system gamma ramp on exit
Uint16 mOldSystemGammaRamp[256 * 3];
};
}
#endif
| 1,036
|
C++
|
.h
| 36
| 23.638889
| 101
| 0.715158
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,752
|
sdlinputwrapper.hpp
|
OpenMW_openmw/components/sdlutil/sdlinputwrapper.hpp
|
#ifndef OPENMW_COMPONENTS_SDLUTIL_SDLINPUTWRAPPER_H
#define OPENMW_COMPONENTS_SDLUTIL_SDLINPUTWRAPPER_H
#include <osg/ref_ptr>
#include <SDL_events.h>
#include <SDL_version.h>
#include "events.hpp"
namespace osgViewer
{
class Viewer;
}
namespace SDLUtil
{
/// \brief A wrapper around SDL's event queue, mostly used for handling input-related events.
class InputWrapper
{
public:
InputWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> viewer, bool grab);
~InputWrapper();
void setMouseEventCallback(MouseListener* listen) { mMouseListener = listen; }
void setSensorEventCallback(SensorListener* listen) { mSensorListener = listen; }
void setKeyboardEventCallback(KeyListener* listen) { mKeyboardListener = listen; }
void setWindowEventCallback(WindowListener* listen) { mWindowListener = listen; }
void setControllerEventCallback(ControllerListener* listen) { mConListener = listen; }
void capture(bool windowEventsOnly);
bool isModifierHeld(int mod);
bool isKeyDown(SDL_Scancode key);
void setMouseVisible(bool visible);
void setMouseRelative(bool relative);
bool getMouseRelative() { return mMouseRelative; }
void setGrabPointer(bool grab);
void warpMouse(int x, int y);
void updateMouseSettings();
private:
void handleWindowEvent(const SDL_Event& evt);
bool _handleWarpMotion(const SDL_MouseMotionEvent& evt);
void _wrapMousePointer(const SDL_MouseMotionEvent& evt);
MouseMotionEvent _packageMouseMotion(const SDL_Event& evt);
void _setWindowScale();
SDL_Window* mSDLWindow;
osg::ref_ptr<osgViewer::Viewer> mViewer;
MouseListener* mMouseListener;
SensorListener* mSensorListener;
KeyListener* mKeyboardListener;
WindowListener* mWindowListener;
ControllerListener* mConListener;
Uint16 mWarpX;
Uint16 mWarpY;
bool mWarpCompensate;
bool mWrapPointer;
bool mAllowGrab;
bool mWantMouseVisible;
bool mWantGrab;
bool mWantRelative;
bool mGrabPointer;
bool mMouseRelative;
bool mFirstMouseMove;
Sint32 mMouseZ;
Sint32 mMouseX;
Sint32 mMouseY;
bool mWindowHasFocus;
bool mMouseInWindow;
Uint16 mScaleX;
Uint16 mScaleY;
};
}
#endif
| 2,454
|
C++
|
.h
| 66
| 29.848485
| 97
| 0.696957
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,753
|
processtrianglecallback.hpp
|
OpenMW_openmw/components/bullethelpers/processtrianglecallback.hpp
|
#ifndef OPENMW_COMPONENTS_BULLETHELPERS_PROCESSTRIANGLECALLBACK_H
#define OPENMW_COMPONENTS_BULLETHELPERS_PROCESSTRIANGLECALLBACK_H
#include <BulletCollision/CollisionShapes/btTriangleCallback.h>
#include <type_traits>
#include <utility>
namespace BulletHelpers
{
template <class Impl>
class ProcessTriangleCallback : public btTriangleCallback
{
public:
explicit ProcessTriangleCallback(Impl impl)
: mImpl(std::move(impl))
{
}
void processTriangle(btVector3* triangle, int partId, int triangleIndex) override
{
return mImpl(triangle, partId, triangleIndex);
}
private:
Impl mImpl;
};
template <class Impl>
ProcessTriangleCallback<typename std::decay<Impl>::type> makeProcessTriangleCallback(Impl&& impl)
{
return ProcessTriangleCallback<typename std::decay<Impl>::type>(std::forward<Impl>(impl));
}
}
#endif
| 943
|
C++
|
.h
| 29
| 26.862069
| 101
| 0.722161
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,754
|
debug.hpp
|
OpenMW_openmw/components/bullethelpers/debug.hpp
|
#ifndef OPENMW_COMPONENTS_BULLETHELPERS_DEBUG_H
#define OPENMW_COMPONENTS_BULLETHELPERS_DEBUG_H
#include <iomanip>
#include <limits>
#include <ostream>
#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
#include <LinearMath/btVector3.h>
inline std::ostream& operator<<(std::ostream& stream, const btVector3& value)
{
return stream << "btVector3(" << std::setprecision(std::numeric_limits<float>::max_exponent10) << value.x() << ", "
<< std::setprecision(std::numeric_limits<float>::max_exponent10) << value.y() << ", "
<< std::setprecision(std::numeric_limits<float>::max_exponent10) << value.z() << ')';
}
inline std::ostream& operator<<(std::ostream& stream, BroadphaseNativeTypes value)
{
switch (value)
{
#ifndef SHAPE_NAME
#define SHAPE_NAME(name) \
case name: \
return stream << #name;
SHAPE_NAME(BOX_SHAPE_PROXYTYPE)
SHAPE_NAME(TRIANGLE_SHAPE_PROXYTYPE)
SHAPE_NAME(TETRAHEDRAL_SHAPE_PROXYTYPE)
SHAPE_NAME(CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
SHAPE_NAME(CONVEX_HULL_SHAPE_PROXYTYPE)
SHAPE_NAME(CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE)
SHAPE_NAME(CUSTOM_POLYHEDRAL_SHAPE_TYPE)
SHAPE_NAME(IMPLICIT_CONVEX_SHAPES_START_HERE)
SHAPE_NAME(SPHERE_SHAPE_PROXYTYPE)
SHAPE_NAME(MULTI_SPHERE_SHAPE_PROXYTYPE)
SHAPE_NAME(CAPSULE_SHAPE_PROXYTYPE)
SHAPE_NAME(CONE_SHAPE_PROXYTYPE)
SHAPE_NAME(CONVEX_SHAPE_PROXYTYPE)
SHAPE_NAME(CYLINDER_SHAPE_PROXYTYPE)
SHAPE_NAME(UNIFORM_SCALING_SHAPE_PROXYTYPE)
SHAPE_NAME(MINKOWSKI_SUM_SHAPE_PROXYTYPE)
SHAPE_NAME(MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE)
SHAPE_NAME(BOX_2D_SHAPE_PROXYTYPE)
SHAPE_NAME(CONVEX_2D_SHAPE_PROXYTYPE)
SHAPE_NAME(CUSTOM_CONVEX_SHAPE_TYPE)
SHAPE_NAME(CONCAVE_SHAPES_START_HERE)
SHAPE_NAME(TRIANGLE_MESH_SHAPE_PROXYTYPE)
SHAPE_NAME(SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
SHAPE_NAME(FAST_CONCAVE_MESH_PROXYTYPE)
SHAPE_NAME(TERRAIN_SHAPE_PROXYTYPE)
SHAPE_NAME(GIMPACT_SHAPE_PROXYTYPE)
SHAPE_NAME(MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE)
SHAPE_NAME(EMPTY_SHAPE_PROXYTYPE)
SHAPE_NAME(STATIC_PLANE_PROXYTYPE)
SHAPE_NAME(CUSTOM_CONCAVE_SHAPE_TYPE)
SHAPE_NAME(CONCAVE_SHAPES_END_HERE)
SHAPE_NAME(COMPOUND_SHAPE_PROXYTYPE)
SHAPE_NAME(SOFTBODY_SHAPE_PROXYTYPE)
SHAPE_NAME(HFFLUID_SHAPE_PROXYTYPE)
SHAPE_NAME(HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE)
SHAPE_NAME(INVALID_SHAPE_PROXYTYPE)
SHAPE_NAME(MAX_BROADPHASE_COLLISION_TYPES)
#undef SHAPE_NAME
#endif
default:
return stream << "undefined(" << static_cast<int>(value) << ")";
}
}
#endif
| 2,969
|
C++
|
.h
| 65
| 38.738462
| 120
| 0.648378
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,755
|
aabb.hpp
|
OpenMW_openmw/components/bullethelpers/aabb.hpp
|
#ifndef OPENMW_COMPONENTS_BULLETHELPERS_AABB_H
#define OPENMW_COMPONENTS_BULLETHELPERS_AABB_H
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
#include <BulletCollision/Gimpact/btBoxCollision.h>
#include <LinearMath/btTransform.h>
inline bool operator==(const btAABB& lhs, const btAABB& rhs)
{
return lhs.m_min == rhs.m_min && lhs.m_max == rhs.m_max;
}
inline bool operator!=(const btAABB& lhs, const btAABB& rhs)
{
return !(lhs == rhs);
}
namespace BulletHelpers
{
inline btAABB getAabb(const btCollisionShape& shape, const btTransform& transform)
{
btAABB result;
shape.getAabb(transform, result.m_min, result.m_max);
return result;
}
}
#endif
| 708
|
C++
|
.h
| 23
| 27.652174
| 86
| 0.745588
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,756
|
heightfield.hpp
|
OpenMW_openmw/components/bullethelpers/heightfield.hpp
|
#ifndef OPENMW_COMPONENTS_BULLETHELPERS_HEIGHTFIELD_H
#define OPENMW_COMPONENTS_BULLETHELPERS_HEIGHTFIELD_H
#include <LinearMath/btVector3.h>
namespace BulletHelpers
{
inline btVector3 getHeightfieldShift(int x, int y, int size, float minHeight, float maxHeight)
{
return btVector3((x + 0.5f) * size, (y + 0.5f) * size, (maxHeight + minHeight) * 0.5f);
}
}
#endif
| 387
|
C++
|
.h
| 11
| 32.090909
| 98
| 0.742627
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,757
|
collisionobject.hpp
|
OpenMW_openmw/components/bullethelpers/collisionobject.hpp
|
#ifndef OPENMW_COMPONENTS_BULLETHELPERS_COLLISIONOBJECT_H
#define OPENMW_COMPONENTS_BULLETHELPERS_COLLISIONOBJECT_H
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#include <LinearMath/btQuaternion.h>
#include <LinearMath/btTransform.h>
#include <memory>
namespace BulletHelpers
{
inline std::unique_ptr<btCollisionObject> makeCollisionObject(
btCollisionShape* shape, const btVector3& position, const btQuaternion& rotation)
{
std::unique_ptr<btCollisionObject> result = std::make_unique<btCollisionObject>();
result->setCollisionShape(shape);
result->setWorldTransform(btTransform(rotation, position));
return result;
}
}
#endif
| 704
|
C++
|
.h
| 18
| 35
| 90
| 0.784457
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,758
|
operators.hpp
|
OpenMW_openmw/components/bullethelpers/operators.hpp
|
#ifndef OPENMW_COMPONENTS_BULLETHELPERS_OPERATORS_H
#define OPENMW_COMPONENTS_BULLETHELPERS_OPERATORS_H
#include <tuple>
#include <LinearMath/btTransform.h>
#include <LinearMath/btVector3.h>
inline bool operator<(const btVector3& lhs, const btVector3& rhs)
{
return std::tie(lhs.x(), lhs.y(), lhs.z()) < std::tie(rhs.x(), rhs.y(), rhs.z());
}
inline bool operator<(const btMatrix3x3& lhs, const btMatrix3x3& rhs)
{
return std::tie(lhs[0], lhs[1], lhs[2]) < std::tie(rhs[0], rhs[1], rhs[2]);
}
inline bool operator<(const btTransform& lhs, const btTransform& rhs)
{
return std::tie(lhs.getBasis(), lhs.getOrigin()) < std::tie(rhs.getBasis(), rhs.getOrigin());
}
#endif
| 686
|
C++
|
.h
| 18
| 36.111111
| 97
| 0.717523
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,759
|
transformboundingbox.hpp
|
OpenMW_openmw/components/bullethelpers/transformboundingbox.hpp
|
#ifndef OPENMW_COMPONENTS_BULLETHELPERS_TRANSFORMBOUNDINGBOX_H
#define OPENMW_COMPONENTS_BULLETHELPERS_TRANSFORMBOUNDINGBOX_H
#include <LinearMath/btTransform.h>
#include <LinearMath/btVector3.h>
#include <algorithm>
namespace BulletHelpers
{
inline btVector3 min(const btVector3& a, const btVector3& b)
{
return btVector3(std::min(a.x(), b.x()), std::min(a.y(), b.y()), std::min(a.z(), b.z()));
}
inline btVector3 max(const btVector3& a, const btVector3& b)
{
return btVector3(std::max(a.x(), b.x()), std::max(a.y(), b.y()), std::max(a.z(), b.z()));
}
// http://dev.theomader.com/transform-bounding-boxes/
inline void transformBoundingBox(const btTransform& transform, btVector3& aabbMin, btVector3& aabbMax)
{
const btVector3 xa(transform.getBasis().getColumn(0) * aabbMin.x());
const btVector3 xb(transform.getBasis().getColumn(0) * aabbMax.x());
const btVector3 ya(transform.getBasis().getColumn(1) * aabbMin.y());
const btVector3 yb(transform.getBasis().getColumn(1) * aabbMax.y());
const btVector3 za(transform.getBasis().getColumn(2) * aabbMin.z());
const btVector3 zb(transform.getBasis().getColumn(2) * aabbMax.z());
aabbMin = min(xa, xb) + min(ya, yb) + min(za, zb) + transform.getOrigin();
aabbMax = max(xa, xb) + max(ya, yb) + max(za, zb) + transform.getOrigin();
}
}
#endif
| 1,416
|
C++
|
.h
| 29
| 43.37931
| 106
| 0.669811
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,760
|
ba2dx10file.hpp
|
OpenMW_openmw/components/bsa/ba2dx10file.hpp
|
#ifndef BSA_BA2_DX10_FILE_H
#define BSA_BA2_DX10_FILE_H
#include <list>
#include <map>
#include <optional>
#include <string>
#include <vector>
#include <components/bsa/bsa_file.hpp>
namespace Bsa
{
class BA2DX10File : private BSAFile
{
private:
struct TextureChunkRecord
{
uint32_t size = 0;
uint32_t packedSize = 0;
int64_t offset = 0;
uint16_t startMip = 0;
uint16_t endMip = 0;
};
struct FileRecord
{
uint8_t unknownTex = 0;
uint16_t height = 0;
uint16_t width = 0;
uint8_t numMips = 0;
uint8_t DXGIFormat = 0;
uint16_t cubeMaps = 0;
std::vector<TextureChunkRecord> texturesChunks;
};
uint32_t mVersion{ 0u };
using FolderRecord = std::map<std::pair<uint32_t, uint32_t>, FileRecord>;
std::map<uint32_t, FolderRecord> mFolders;
std::list<std::vector<char>> mFileNames;
std::optional<FileRecord> getFileRecord(const std::string& str) const;
Files::IStreamPtr getFile(const FileRecord& fileRecord);
void loadFiles(uint32_t fileCount, std::istream& in);
public:
using BSAFile::getFilename;
using BSAFile::getList;
using BSAFile::open;
BA2DX10File();
virtual ~BA2DX10File();
/// Read header information from the input source
void readHeader() override;
Files::IStreamPtr getFile(const char* filePath);
Files::IStreamPtr getFile(const FileStruct* fileStruct);
void addFile(const std::string& filename, std::istream& file);
};
}
#endif
| 1,695
|
C++
|
.h
| 52
| 24.615385
| 81
| 0.613022
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,761
|
compressedbsafile.hpp
|
OpenMW_openmw/components/bsa/compressedbsafile.hpp
|
/*
OpenMW - The completely unofficial reimplementation of Morrowind
Copyright (C) 2008-2010 Nicolay Korslund
Email: < korslund@gmail.com >
WWW: http://openmw.sourceforge.net/
This file (compressedbsafile.hpp) 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/ .
Compressed BSA stuff added by cc9cii 2018
*/
#ifndef BSA_COMPRESSED_BSA_FILE_H
#define BSA_COMPRESSED_BSA_FILE_H
#include <limits>
#include <map>
#include <components/bsa/bsa_file.hpp>
#include <filesystem>
namespace Bsa
{
class CompressedBSAFile : private BSAFile
{
private:
enum ArchiveFlags
{
ArchiveFlag_FolderNames = 0x0001,
ArchiveFlag_FileNames = 0x0002,
ArchiveFlag_Compress = 0x0004,
ArchiveFlag_RetainDir = 0x0008,
ArchiveFlag_RetainName = 0x0010,
ArchiveFlag_RetainFileOffset = 0x0020,
ArchiveFlag_Xbox360 = 0x0040,
ArchiveFlag_StartUpStr = 0x0080,
ArchiveFlag_EmbeddedNames = 0x0100,
ArchiveFlag_XMem = 0x0200,
};
enum Version
{
Version_TES4 = 0x67,
Version_FO3 = 0x68,
Version_SSE = 0x69,
};
enum FileFlags
{
FileFlag_NIF = 0x001,
FileFlag_DDS = 0x002,
FileFlag_XML = 0x004,
FileFlag_WAV = 0x008,
FileFlag_MP3 = 0x010,
FileFlag_TXT = 0x020, // TXT, HTML, BAT, SCC
FileFlag_SPT = 0x040,
FileFlag_FNT = 0x080, // TEX, FNT
FileFlag_MISC = 0x100, // CTL and others
};
enum FileSizeFlags
{
FileSizeFlag_Compression = 0x40000000,
};
struct Header
{
std::uint32_t mFormat;
std::uint32_t mVersion;
std::uint32_t mFoldersOffset;
std::uint32_t mFlags;
std::uint32_t mFolderCount;
std::uint32_t mFileCount;
std::uint32_t mFolderNamesLength;
std::uint32_t mFileNamesLength;
std::uint32_t mFileFlags;
};
Header mHeader;
struct FileRecord
{
std::uint64_t mHash;
std::vector<char> mName;
std::uint32_t mSize{ 0u };
std::uint32_t mOffset{ std::numeric_limits<uint32_t>::max() };
};
struct FolderRecord
{
std::uint32_t mCount;
std::int64_t mOffset;
std::map<std::uint64_t, FileRecord> mFiles;
};
std::map<std::uint64_t, FolderRecord> mFolders;
FileRecord getFileRecord(const std::string& str) const;
/// \brief Normalizes given filename or folder and generates format-compatible hash.
static std::uint64_t generateHash(const std::filesystem::path& stem, std::string extension);
Files::IStreamPtr getFile(const FileRecord& fileRecord);
public:
using BSAFile::getFilename;
using BSAFile::getList;
using BSAFile::open;
CompressedBSAFile() = default;
virtual ~CompressedBSAFile() = default;
/// Read header information from the input source
void readHeader() override;
Files::IStreamPtr getFile(const char* filePath);
Files::IStreamPtr getFile(const FileStruct* fileStruct);
void addFile(const std::string& filename, std::istream& file);
};
}
#endif
| 3,991
|
C++
|
.h
| 109
| 27.889908
| 100
| 0.629246
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,762
|
bsa_file.hpp
|
OpenMW_openmw/components/bsa/bsa_file.hpp
|
/*
OpenMW - The completely unofficial reimplementation of Morrowind
Copyright (C) 2008-2010 Nicolay Korslund
Email: < korslund@gmail.com >
WWW: https://openmw.org/
This file (bsa_file.h) 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
https://www.gnu.org/licenses/ .
*/
#ifndef BSA_BSA_FILE_H
#define BSA_BSA_FILE_H
#include <cstdint>
#include <filesystem>
#include <string>
#include <vector>
#include <components/files/conversion.hpp>
#include <components/files/istreamptr.hpp>
namespace Bsa
{
enum class BsaVersion : std::uint32_t
{
Unknown = 0x0,
Uncompressed = 0x100,
Compressed = 0x415342, // B, S, A,
BA2GNRL, // used by FO4, BSA which contains files
BA2DX10 // used by FO4, BSA which contains textures
};
/**
This class is used to read "Bethesda Archive Files", or BSAs.
*/
class BSAFile
{
public:
#pragma pack(push)
#pragma pack(1)
struct Hash
{
uint32_t low, high;
};
#pragma pack(pop)
/// Represents one file entry in the archive
struct FileStruct
{
void setNameInfos(size_t index, std::vector<char>* stringBuf)
{
namesOffset = static_cast<uint32_t>(index);
namesBuffer = stringBuf;
}
// File size and offset in file. We store the offset from the
// beginning of the file, not the offset into the data buffer
// (which is what is stored in the archive.)
uint32_t fileSize, offset;
Hash hash;
// Zero-terminated file name
const char* name() const { return &(*namesBuffer)[namesOffset]; }
uint32_t namesOffset = 0;
std::vector<char>* namesBuffer = nullptr;
};
typedef std::vector<FileStruct> FileList;
protected:
bool mHasChanged = false;
/// Table of files in this archive
FileList mFiles;
/// Filename string buffer
std::vector<char> mStringBuf;
/// True when an archive has been loaded
bool mIsLoaded;
/// Used for error messages
std::filesystem::path mFilepath;
/// Error handling
[[noreturn]] void fail(const std::string& msg) const;
/// Read header information from the input source
virtual void readHeader();
virtual void writeHeader();
public:
/* -----------------------------------
* BSA management methods
* -----------------------------------
*/
BSAFile()
: mIsLoaded(false)
{
}
virtual ~BSAFile()
{
close();
}
/// Open an archive file.
void open(const std::filesystem::path& file);
void close();
/* -----------------------------------
* Archive file routines
* -----------------------------------
*/
/** Open a file contained in the archive.
* @note Thread safe.
*/
Files::IStreamPtr getFile(const FileStruct* file);
void addFile(const std::string& filename, std::istream& file);
/// Get a list of all files
/// @note Thread safe.
const FileList& getList() const
{
return mFiles;
}
std::string getFilename() const
{
return Files::pathToUnicodeString(mFilepath);
}
// checks version of BSA from file header
static BsaVersion detectVersion(const std::filesystem::path& filePath);
};
}
#endif
| 4,163
|
C++
|
.h
| 122
| 26.286885
| 79
| 0.592112
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,763
|
ba2gnrlfile.hpp
|
OpenMW_openmw/components/bsa/ba2gnrlfile.hpp
|
#ifndef BSA_BA2_GNRL_FILE_H
#define BSA_BA2_GNRL_FILE_H
#include <list>
#include <map>
#include <string>
#include <vector>
#include <components/bsa/bsa_file.hpp>
namespace Bsa
{
class BA2GNRLFile : private BSAFile
{
private:
struct FileRecord
{
FileRecord();
uint32_t size;
uint32_t offset;
uint32_t packedSize = 0;
bool isValid() const;
};
uint32_t mVersion{ 0u };
using FolderRecord = std::map<std::pair<uint32_t, uint32_t>, FileRecord>;
std::map<uint32_t, FolderRecord> mFolders;
std::list<std::vector<char>> mFileNames;
FileRecord getFileRecord(const std::string& str) const;
Files::IStreamPtr getFile(const FileRecord& fileRecord);
void loadFiles(uint32_t fileCount, std::istream& in);
public:
using BSAFile::getFilename;
using BSAFile::getList;
using BSAFile::open;
BA2GNRLFile();
virtual ~BA2GNRLFile();
/// Read header information from the input source
void readHeader() override;
Files::IStreamPtr getFile(const char* filePath);
Files::IStreamPtr getFile(const FileStruct* fileStruct);
void addFile(const std::string& filename, std::istream& file);
};
}
#endif
| 1,324
|
C++
|
.h
| 41
| 25.097561
| 81
| 0.639086
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,764
|
memorystream.hpp
|
OpenMW_openmw/components/bsa/memorystream.hpp
|
/*
OpenMW - The completely unofficial reimplementation of Morrowind
Copyright (C) 2008-2010 Nicolay Korslund
Email: < korslund@gmail.com >
WWW: http://openmw.sourceforge.net/
This file (memorystream.hpp) 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/ .
Compressed BSA upgrade added by Azdul 2019
*/
#ifndef BSA_MEMORY_STREAM_H
#define BSA_MEMORY_STREAM_H
#include <components/files/memorystream.hpp>
#include <istream>
#include <vector>
namespace Bsa
{
/**
Class replaces Ogre memory streams without introducing any new external dependencies
beyond standard library.
Allows to pass memory buffer as Files::IStreamPtr.
Memory buffer is freed once the class instance is destroyed.
*/
class MemoryInputStream : private std::vector<char>, public Files::MemBuf, public std::istream
{
public:
explicit MemoryInputStream(size_t bufferSize)
: std::vector<char>(bufferSize)
, Files::MemBuf(this->data(), this->size())
, std::istream(static_cast<std::streambuf*>(this))
{
}
char* getRawData() { return this->data(); }
};
}
#endif
| 1,740
|
C++
|
.h
| 44
| 34.659091
| 98
| 0.72549
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,765
|
ba2file.hpp
|
OpenMW_openmw/components/bsa/ba2file.hpp
|
#ifndef BSA_BA2_FILE_H
#define BSA_BA2_FILE_H
#include <cstdint>
#include <string>
namespace Bsa
{
uint32_t generateHash(const std::string& name);
uint32_t generateExtensionHash(std::string_view extension);
enum class BA2Version : std::uint32_t
{
Fallout4 = 1,
StarfieldGeneral = 2,
StarfieldDDS = 3,
Fallout4NextGen_v7 = 7,
Fallout4NextGen_v8 = 8,
};
}
#endif
| 425
|
C++
|
.h
| 18
| 19.055556
| 63
| 0.667494
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,766
|
locals.hpp
|
OpenMW_openmw/components/esm3/locals.hpp
|
#ifndef OPENMW_ESM_LOCALS_H
#define OPENMW_ESM_LOCALS_H
#include <string>
#include <vector>
#include "variant.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/// \brief Storage structure for local variables (only used in saved games)
///
/// \note This is not a top-level record.
struct Locals
{
std::vector<std::pair<std::string, Variant>> mVariables;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 495
|
C++
|
.h
| 20
| 20.6
| 79
| 0.67735
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
35,767
|
loaddial.hpp
|
OpenMW_openmw/components/esm3/loaddial.hpp
|
#ifndef OPENMW_ESM_DIAL_H
#define OPENMW_ESM_DIAL_H
#include <list>
#include <map>
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "components/esm3/infoorder.hpp"
#include "loadinfo.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Dialogue topic and journal entries. The actual data is contained in
* the INFO records following the DIAL.
*/
struct Dialogue
{
using InfoContainer = std::list<DialInfo>;
constexpr static RecNameInts sRecordId = REC_DIAL;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Dialogue"; }
enum Type : std::int8_t
{
Topic = 0,
Voice = 1,
Greeting = 2,
Persuasion = 3,
Journal = 4,
Unknown = -1 // Used for deleted dialogues
};
RefId mId;
std::string mStringId;
Type mType;
InfoContainer mInfo;
InfoOrder<DialInfo> mInfoOrder;
// Parameters: Info ID, (Info iterator, Deleted flag)
typedef std::map<ESM::RefId, std::pair<InfoContainer::iterator, bool>> LookupMap;
void load(ESMReader& esm, bool& isDeleted);
///< Loads all sub-records of Dialogue record
void loadId(ESMReader& esm);
///< Loads NAME sub-record of Dialogue record
void loadData(ESMReader& esm, bool& isDeleted);
///< Loads all sub-records of Dialogue record, except NAME sub-record
void save(ESMWriter& esm, bool isDeleted = false) const;
/// Remove all INFOs that are deleted
void setUp();
/// Read the next info record
void readInfo(ESMReader& esm);
void blank();
///< Set record to default state (does not touch the ID and does not change the type).
};
}
#endif
| 1,959
|
C++
|
.h
| 55
| 28.381818
| 108
| 0.636653
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,768
|
loadcrea.hpp
|
OpenMW_openmw/components/esm3/loadcrea.hpp
|
#ifndef OPENMW_ESM_CREA_H
#define OPENMW_ESM_CREA_H
#include <array>
#include <string>
#include "aipackage.hpp"
#include "loadcont.hpp"
#include "spelllist.hpp"
#include "transport.hpp"
#include "components/esm/attr.hpp"
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Creature definition
*
*/
struct Creature
{
constexpr static RecNameInts sRecordId = REC_CREA;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Creature"; }
// Default is 0x48?
enum Flags
{
Bipedal = 0x01,
Respawn = 0x02,
Weapon = 0x04, // Has weapon and shield
Base = 0x08, // This flag is set for every actor in Bethesda ESMs
Swims = 0x10,
Flies = 0x20, // Don't know what happens if several
Walks = 0x40, // of these are set
Essential = 0x80
};
enum Type
{
Creatures = 0,
Daedra = 1,
Undead = 2,
Humanoid = 3
};
struct NPDTstruct
{
int32_t mType;
// For creatures we obviously have to use ints, not shorts and
// bytes like we use for NPCs.... this file format just makes so
// much sense! (Still, _much_ easier to decode than the NIFs.)
int32_t mLevel;
std::array<int32_t, Attribute::Length> mAttributes;
int32_t mHealth, mMana, mFatigue; // Stats
int32_t mSoul; // The creatures soul value (used with soul gems.)
// Creatures have generalized combat, magic and stealth stats which substitute for
// the specific skills (in the same way as specializations).
int32_t mCombat, mMagic, mStealth;
int32_t mAttack[6]; // AttackMin1, AttackMax1, ditto2, ditto3
int32_t mGold;
}; // 96 byte
NPDTstruct mData;
int32_t mBloodType;
unsigned char mFlags;
float mScale;
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mModel;
std::string mName;
ESM::RefId mOriginal; // Base creature that this is a modification of
InventoryList mInventory;
SpellList mSpells;
AIData mAiData;
AIPackageList mAiPackage;
Transport mTransport;
const std::vector<Transport::Dest>& getTransport() const;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 2,831
|
C++
|
.h
| 81
| 26.333333
| 108
| 0.603372
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,769
|
variant.hpp
|
OpenMW_openmw/components/esm3/variant.hpp
|
#ifndef OPENMW_ESM_VARIANT_H
#define OPENMW_ESM_VARIANT_H
#include <iosfwd>
#include <string>
#include <tuple>
#include <variant>
namespace ESM
{
class ESMReader;
class ESMWriter;
enum VarType
{
VT_Unknown = 0,
VT_None,
VT_Short, // stored as a float, kinda
VT_Int,
VT_Long, // stored as a float
VT_Float,
VT_String
};
class Variant
{
VarType mType;
std::variant<std::monostate, int32_t, float, std::string> mData;
public:
enum Format
{
Format_Global,
Format_Gmst,
Format_Info,
Format_Local // local script variables in save game files
};
Variant()
: mType(VT_None)
, mData(std::monostate{})
{
}
explicit Variant(const std::string& value)
: mType(VT_String)
, mData(value)
{
}
explicit Variant(std::string&& value)
: mType(VT_String)
, mData(std::move(value))
{
}
explicit Variant(int32_t value)
: mType(VT_Long)
, mData(value)
{
}
explicit Variant(float value)
: mType(VT_Float)
, mData(value)
{
}
VarType getType() const { return mType; }
const std::string& getString() const;
///< Will throw an exception, if value can not be represented as a string.
int32_t getInteger() const;
///< Will throw an exception, if value can not be represented as an integer (implicit
/// casting of float values is permitted).
float getFloat() const;
///< Will throw an exception, if value can not be represented as a float value.
void read(ESMReader& esm, Format format);
void write(ESMWriter& esm, Format format) const;
void write(std::ostream& stream) const;
///< Write in text format.
void setType(VarType type);
void setString(const std::string& value);
///< Will throw an exception, if type is not compatible with string.
void setString(std::string&& value);
///< Will throw an exception, if type is not compatible with string.
void setInteger(int32_t value);
///< Will throw an exception, if type is not compatible with integer.
void setFloat(float value);
///< Will throw an exception, if type is not compatible with float.
friend bool operator==(const Variant& left, const Variant& right)
{
return std::tie(left.mType, left.mData) == std::tie(right.mType, right.mData);
}
friend bool operator!=(const Variant& left, const Variant& right) { return !(left == right); }
};
std::ostream& operator<<(std::ostream& stream, const Variant& value);
}
#endif
| 2,904
|
C++
|
.h
| 87
| 24.770115
| 102
| 0.582587
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,770
|
loadinfo.hpp
|
OpenMW_openmw/components/esm3/loadinfo.hpp
|
#ifndef OPENMW_ESM_INFO_H
#define OPENMW_ESM_INFO_H
#include <string>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "dialoguecondition.hpp"
#include "variant.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Dialogue information. A series of these follow after DIAL records,
* and form a linked list of dialogue items.
*/
struct DialInfo
{
constexpr static RecNameInts sRecordId = REC_INFO;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "DialInfo"; }
enum Gender
{
Male = 0,
Female = 1,
NA = -1
};
struct DATAstruct
{
int32_t mType = 0; // See Dialogue::Type
union
{
int32_t mDisposition = 0; // Used for dialogue responses
int32_t mJournalIndex; // Used for journal entries
};
signed char mRank = -1; // Rank of NPC
signed char mGender = Gender::NA; // See Gender enum
signed char mPCrank = -1; // Player rank
}; // 12 bytes
DATAstruct mData;
// Journal quest indices (introduced with the quest system in Tribunal)
enum QuestStatus
{
QS_None = 0,
QS_Name = 1,
QS_Finished = 2,
QS_Restart = 3
};
// Rules for when to include this item in the final list of options
// visible to the player.
std::vector<DialogueCondition> mSelects;
// Id of this, previous and next INFO items
RefId mId, mPrev, mNext;
// Various references used in determining when to select this item.
RefId mActor, mRace, mClass, mFaction, mPcFaction, mCell;
// Sound and text associated with this item
std::string mSound;
std::string mResponse;
// Result script (uncompiled) to run whenever this dialog item is
// selected
std::string mResultScript;
// ONLY include this item the NPC is not part of any faction.
bool mFactionLess;
// Status of this quest item
QuestStatus mQuestStatus;
// Hexadecimal versions of the various subrecord names.
enum SubNames
{
REC_ONAM = 0x4d414e4f,
REC_RNAM = 0x4d414e52,
REC_CNAM = 0x4d414e43,
REC_FNAM = 0x4d414e46,
REC_ANAM = 0x4d414e41,
REC_DNAM = 0x4d414e44,
REC_SNAM = 0x4d414e53,
REC_NAME = 0x454d414e,
REC_SCVR = 0x52564353,
REC_BNAM = 0x4d414e42,
REC_QSTN = 0x4e545351,
REC_QSTF = 0x46545351,
REC_QSTR = 0x52545351,
REC_DELE = 0x454c4544
};
void load(ESMReader& esm, bool& isDeleted);
///< Loads Info record
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 3,174
|
C++
|
.h
| 91
| 25.637363
| 108
| 0.586928
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,771
|
readerscache.hpp
|
OpenMW_openmw/components/esm3/readerscache.hpp
|
#ifndef OPENMW_COMPONENTS_ESM3_READERSCACHE_H
#define OPENMW_COMPONENTS_ESM3_READERSCACHE_H
#include "esmreader.hpp"
#include <cstddef>
#include <list>
#include <map>
#include <optional>
#include <string>
namespace ESM
{
class ReadersCache
{
private:
enum class State
{
Busy,
Free,
Closed,
};
struct Item
{
State mState = State::Busy;
ESMReader mReader;
std::optional<std::filesystem::path> mName;
Item() = default;
};
public:
class BusyItem
{
public:
explicit BusyItem(ReadersCache& owner, std::list<Item>::iterator item) noexcept;
BusyItem(const BusyItem& other) = delete;
~BusyItem() noexcept;
BusyItem& operator=(const BusyItem& other) = delete;
ESMReader& operator*() const noexcept { return mItem->mReader; }
ESMReader* operator->() const noexcept { return &mItem->mReader; }
private:
ReadersCache& mOwner;
std::list<Item>::iterator mItem;
};
explicit ReadersCache(std::size_t capacity = 100);
BusyItem get(std::size_t index);
void clear();
private:
const std::size_t mCapacity;
std::map<std::size_t, std::list<Item>::iterator> mIndex;
std::list<Item> mBusyItems;
std::list<Item> mFreeItems;
std::list<Item> mClosedItems;
inline void closeExtraReaders();
inline void releaseItem(std::list<Item>::iterator it) noexcept;
};
}
#endif
| 1,628
|
C++
|
.h
| 54
| 21.907407
| 92
| 0.593569
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,772
|
infoorder.hpp
|
OpenMW_openmw/components/esm3/infoorder.hpp
|
#ifndef OPENMW_COMPONENTS_ESM3_INFOORDER_H
#define OPENMW_COMPONENTS_ESM3_INFOORDER_H
#include "components/esm/refid.hpp"
#include <iterator>
#include <list>
#include <type_traits>
#include <unordered_map>
#include <utility>
namespace ESM
{
template <class T>
class InfoOrder
{
public:
const std::list<T>& getOrderedInfo() const { return mOrderedInfo; }
template <class V>
void insertInfo(V&& value, bool deleted)
{
static_assert(std::is_same_v<std::decay_t<V>, T>);
auto it = mInfoPositions.find(value.mId);
if (it != mInfoPositions.end() && it->second.mPosition->mPrev == value.mPrev)
{
*it->second.mPosition = std::forward<V>(value);
it->second.mDeleted = deleted;
return;
}
auto before = mOrderedInfo.begin();
if (!value.mPrev.empty())
{
const auto prevIt = mInfoPositions.find(value.mPrev);
if (prevIt != mInfoPositions.end())
before = std::next(prevIt->second.mPosition);
else
before = mOrderedInfo.end();
}
if (it == mInfoPositions.end())
{
const RefId id = value.mId;
mInfoPositions.emplace(id,
Item{
.mPosition = mOrderedInfo.insert(before, std::forward<V>(value)),
.mDeleted = deleted,
});
}
else
{
*it->second.mPosition = std::forward<V>(value);
it->second.mDeleted = deleted;
mOrderedInfo.splice(before, mOrderedInfo, it->second.mPosition);
}
}
void removeInfo(const RefId& infoRefId)
{
const auto it = mInfoPositions.find(infoRefId);
if (it == mInfoPositions.end())
return;
mOrderedInfo.erase(it->second.mPosition);
mInfoPositions.erase(it);
}
void removeDeleted()
{
for (auto it = mInfoPositions.begin(); it != mInfoPositions.end();)
{
if (!it->second.mDeleted)
{
++it;
continue;
}
mOrderedInfo.erase(it->second.mPosition);
it = mInfoPositions.erase(it);
}
}
void extractOrderedInfo(std::list<T>& info)
{
info = mOrderedInfo;
mInfoPositions.clear();
}
private:
struct Item
{
typename std::list<T>::iterator mPosition;
bool mDeleted = false;
};
std::list<T> mOrderedInfo;
std::unordered_map<RefId, Item> mInfoPositions;
};
}
#endif
| 2,890
|
C++
|
.h
| 88
| 21.102273
| 89
| 0.50772
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,773
|
loadlevlist.hpp
|
OpenMW_openmw/components/esm3/loadlevlist.hpp
|
#ifndef OPENMW_ESM_LEVLISTS_H
#define OPENMW_ESM_LEVLISTS_H
#include <string>
#include <vector>
#include "components/esm/refid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/esmcommon.hpp>
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Levelled lists. Since these have identical layout, I only bothered
* to implement it once.
*
* We should later implement the ability to merge levelled lists from
* several files.
*/
struct LevelledListBase
{
int32_t mFlags;
unsigned char mChanceNone; // Chance that none are selected (0-100)
uint32_t mRecordFlags;
RefId mId;
struct LevelItem
{
RefId mId;
uint16_t mLevel;
};
std::vector<LevelItem> mList;
void load(ESMReader& esm, NAME recName, bool& isDeleted);
void save(ESMWriter& esm, NAME recName, bool isDeleted) const;
void blank();
///< Set record to default state (does not touch the ID).
};
template <class Base>
struct CustomLevelledListBase : LevelledListBase
{
void load(ESMReader& esm, bool& isDeleted) { LevelledListBase::load(esm, Base::sRecName, isDeleted); }
void save(ESMWriter& esm, bool isDeleted = false) const
{
LevelledListBase::save(esm, Base::sRecName, isDeleted);
}
};
struct CreatureLevList : CustomLevelledListBase<CreatureLevList>
{
/// Record name used to read references.
static constexpr NAME sRecName{ "CNAM" };
static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVC;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "CreatureLevList"; }
enum Flags
{
AllLevels = 0x01 // Calculate from all levels <= player
// level, not just the closest below
// player.
};
};
struct ItemLevList : CustomLevelledListBase<ItemLevList>
{
/// Record name used to read references.
static constexpr NAME sRecName{ "INAM" };
static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVI;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "ItemLevList"; }
enum Flags
{
Each = 0x01, // Select a new item each time this
// list is instantiated, instead of
// giving several identical items
// (used when a container has more
// than one instance of one levelled
// list.)
AllLevels = 0x02 // Calculate from all levels <= player
// level, not just the closest below
// player.
};
};
}
#endif
| 3,054
|
C++
|
.h
| 80
| 28.6625
| 110
| 0.605548
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,774
|
containerstate.hpp
|
OpenMW_openmw/components/esm3/containerstate.hpp
|
#ifndef OPENMW_ESM_CONTAINERSTATE_H
#define OPENMW_ESM_CONTAINERSTATE_H
#include "inventorystate.hpp"
#include "objectstate.hpp"
namespace ESM
{
// format 0, saved games only
struct ContainerState final : public ObjectState
{
InventoryState mInventory;
void load(ESMReader& esm) override;
void save(ESMWriter& esm, bool inInventory = false) const override;
ContainerState& asContainerState() override { return *this; }
const ContainerState& asContainerState() const override { return *this; }
};
}
#endif
| 567
|
C++
|
.h
| 17
| 28.705882
| 81
| 0.727941
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,775
|
quickkeys.hpp
|
OpenMW_openmw/components/esm3/quickkeys.hpp
|
#ifndef OPENMW_COMPONENTS_ESM_QUICKKEYS_H
#define OPENMW_COMPONENTS_ESM_QUICKKEYS_H
#include "components/esm/refid.hpp"
#include <string>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct QuickKeys
{
enum class Type : std::uint32_t
{
Item = 0,
Magic = 1,
MagicItem = 2,
Unassigned = 3,
HandToHand = 4,
};
struct QuickKey
{
Type mType;
RefId mId; // Spell or Item ID
};
std::vector<QuickKey> mKeys;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 680
|
C++
|
.h
| 30
| 15.5
| 42
| 0.563183
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,776
|
spelllist.hpp
|
OpenMW_openmw/components/esm3/spelllist.hpp
|
#ifndef OPENMW_ESM_SPELLLIST_H
#define OPENMW_ESM_SPELLLIST_H
#include <components/esm/refid.hpp>
#include <string>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
/** A list of references to spells and spell effects. This is shared
between the records BSGN, NPC and RACE.
NPCS subrecord.
*/
struct SpellList
{
std::vector<ESM::RefId> mList;
/// Is this spell ID in mList?
bool exists(const ESM::RefId& spell) const;
/// Load one spell, assumes the subrecord name was already read
void add(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 666
|
C++
|
.h
| 24
| 22.833333
| 72
| 0.674016
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,777
|
loadspel.hpp
|
OpenMW_openmw/components/esm3/loadspel.hpp
|
#ifndef OPENMW_ESM_SPEL_H
#define OPENMW_ESM_SPEL_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "effectlist.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct Spell
{
constexpr static RecNameInts sRecordId = REC_SPEL;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Spell"; }
enum SpellType
{
ST_Spell = 0, // Normal spell, must be cast and costs mana
ST_Ability = 1, // Inert ability, always in effect
ST_Blight = 2, // Blight disease
ST_Disease = 3, // Common disease
ST_Curse = 4, // Curse (?)
ST_Power = 5 // Power, can use once a day
};
enum Flags
{
F_Autocalc = 1, // Can be selected by NPC spells auto-calc
F_PCStart = 2, // Can be selected by player spells auto-calc
F_Always = 4 // Casting always succeeds
};
struct SPDTstruct
{
int32_t mType; // SpellType
int32_t mCost; // Mana cost
int32_t mFlags; // Flags
};
SPDTstruct mData;
uint32_t mRecordFlags;
std::string mName;
RefId mId;
EffectList mEffects;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID/index).
};
}
#endif
| 1,617
|
C++
|
.h
| 48
| 25.520833
| 108
| 0.592164
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
35,779
|
loadscpt.hpp
|
OpenMW_openmw/components/esm3/loadscpt.hpp
|
#ifndef OPENMW_ESM_SCPT_H
#define OPENMW_ESM_SCPT_H
#include <cstdint>
#include <string>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Script definitions
*/
class Script
{
public:
constexpr static RecNameInts sRecordId = REC_SCPT;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Script"; }
uint32_t mRecordFlags;
RefId mId;
std::uint32_t mNumShorts;
std::uint32_t mNumLongs;
std::uint32_t mNumFloats;
/// 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;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID/index).
};
std::uint32_t computeScriptStringTableSize(const std::vector<std::string>& varNames);
}
#endif
| 1,514
|
C++
|
.h
| 41
| 30.634146
| 108
| 0.676955
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,780
|
loadprob.hpp
|
OpenMW_openmw/components/esm3/loadprob.hpp
|
#ifndef OPENMW_ESM_PROBE_H
#define OPENMW_ESM_PROBE_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct Probe
{
constexpr static RecNameInts sRecordId = REC_PROB;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Probe"; }
struct Data
{
float mWeight;
int32_t mValue;
float mQuality;
int32_t mUses;
}; // Size = 16
Data mData;
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mName, mModel, mIcon;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 978
|
C++
|
.h
| 32
| 23.5625
| 108
| 0.627409
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,781
|
loadnpc.hpp
|
OpenMW_openmw/components/esm3/loadnpc.hpp
|
#ifndef OPENMW_ESM_NPC_H
#define OPENMW_ESM_NPC_H
#include <array>
#include <string>
#include <vector>
#include "aipackage.hpp"
#include "components/esm/attr.hpp"
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "loadcont.hpp"
#include "loadskil.hpp"
#include "spelllist.hpp"
#include "transport.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* NPC definition
*/
struct NPC
{
constexpr static RecNameInts sRecordId = REC_NPC_;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "NPC"; }
// Services
enum Services
{
// This merchant buys:
Weapon = 0x00001,
Armor = 0x00002,
Clothing = 0x00004,
Books = 0x00008,
Ingredients = 0x00010,
Picks = 0x00020,
Probes = 0x00040,
Lights = 0x00080,
Apparatus = 0x00100,
RepairItem = 0x00200,
Misc = 0x00400,
Potions = 0x02000,
AllItems = Weapon | Armor | Clothing | Books | Ingredients | Picks | Probes | Lights | Apparatus
| RepairItem | Misc | Potions,
// Other services
Spells = 0x00800,
MagicItems = 0x01000,
Training = 0x04000,
Spellmaking = 0x08000,
Enchanting = 0x10000,
Repair = 0x20000
};
enum Flags
{
Female = 0x01,
Essential = 0x02,
Respawn = 0x04,
Base = 0x08,
Autocalc = 0x10
};
enum NpcType
{
NPC_WITH_AUTOCALCULATED_STATS = 12,
NPC_DEFAULT = 52
};
struct NPDTstruct52
{
int16_t mLevel;
std::array<unsigned char, Attribute::Length> mAttributes;
// mSkill can grow up to 200, it must be unsigned
std::array<unsigned char, Skill::Length> mSkills;
uint16_t mHealth, mMana, mFatigue;
unsigned char mDisposition, mReputation, mRank;
int32_t mGold;
}; // 52 bytes
unsigned char mNpdtType;
// Worth noting when saving the struct:
// Although we might read a NPDTstruct12 in, we use NPDTstruct52 internally
NPDTstruct52 mNpdt;
int getFactionRank() const; /// wrapper for mNpdt*, -1 = no rank
int32_t mBloodType;
unsigned char mFlags;
InventoryList mInventory;
SpellList mSpells;
AIData mAiData;
Transport mTransport;
const std::vector<Transport::Dest>& getTransport() const;
AIPackageList mAiPackage;
uint32_t mRecordFlags;
RefId mId, mRace, mClass, mFaction, mScript;
std::string mModel, mName;
// body parts
RefId mHair, mHead;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
bool isMale() const;
void setIsMale(bool value);
void blank();
///< Set record to default state (does not touch the ID).
/// Resets the mNpdt object
void blankNpdt();
};
}
#endif
| 3,331
|
C++
|
.h
| 103
| 23.223301
| 108
| 0.582239
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,782
|
objectstate.hpp
|
OpenMW_openmw/components/esm3/objectstate.hpp
|
#ifndef OPENMW_ESM_OBJECTSTATE_H
#define OPENMW_ESM_OBJECTSTATE_H
#include <string>
#include <vector>
#include <components/esm/luascripts.hpp>
#include <components/esm/position.hpp>
#include <components/esm3/formatversion.hpp>
#include "animationstate.hpp"
#include "cellref.hpp"
#include "locals.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct ContainerState;
struct CreatureLevListState;
struct CreatureState;
struct DoorState;
struct NpcState;
// format 0, saved games only
///< \brief Save state for objects, that do not use custom data
struct ObjectState
{
CellRef mRef;
unsigned char mHasLocals;
Locals mLocals;
LuaScripts mLuaScripts;
unsigned char mEnabled;
Position mPosition;
uint32_t mFlags;
// Is there any class-specific state following the ObjectState
bool mHasCustomState;
FormatVersion mVersion = DefaultFormatVersion;
AnimationState mAnimationState;
ObjectState()
: mHasLocals(0)
, mEnabled(0)
, mFlags(0)
, mHasCustomState(true)
{
}
/// @note Does not load the CellRef ID, it should already be loaded before calling this method
virtual void load(ESMReader& esm);
virtual void save(ESMWriter& esm, bool inInventory = false) const;
/// Initialize to default state
virtual void blank();
virtual ~ObjectState();
virtual const NpcState& asNpcState() const;
virtual NpcState& asNpcState();
virtual const CreatureState& asCreatureState() const;
virtual CreatureState& asCreatureState();
virtual const ContainerState& asContainerState() const;
virtual ContainerState& asContainerState();
virtual const DoorState& asDoorState() const;
virtual DoorState& asDoorState();
virtual const CreatureLevListState& asCreatureLevListState() const;
virtual CreatureLevListState& asCreatureLevListState();
};
}
#endif
| 2,085
|
C++
|
.h
| 60
| 27.8
| 102
| 0.689122
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,783
|
npcstats.hpp
|
OpenMW_openmw/components/esm3/npcstats.hpp
|
#ifndef OPENMW_ESM_NPCSTATS_H
#define OPENMW_ESM_NPCSTATS_H
#include "loadskil.hpp"
#include "statstate.hpp"
#include <components/esm/attr.hpp>
#include <components/esm/refid.hpp>
#include <array>
#include <map>
#include <string>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct NpcStats
{
struct Faction
{
bool mExpelled;
int32_t mRank;
int32_t mReputation;
Faction();
};
bool mIsWerewolf;
std::map<ESM::RefId, Faction> mFactions;
int32_t mDisposition;
int32_t mCrimeDispositionModifier;
std::array<StatState<float>, ESM::Skill::Length> mSkills;
int32_t mBounty;
int32_t mReputation;
int32_t mWerewolfKills;
int32_t mLevelProgress;
std::array<int32_t, ESM::Attribute::Length> mSkillIncrease;
std::array<int32_t, 3> mSpecIncreases;
std::vector<ESM::RefId> mUsedIds;
float mTimeToStartDrowning;
int32_t mCrimeId;
/// Initialize to default state
void blank();
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 1,237
|
C++
|
.h
| 45
| 20.911111
| 67
| 0.637595
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,784
|
landrecorddata.hpp
|
OpenMW_openmw/components/esm3/landrecorddata.hpp
|
#ifndef OPENMW_COMPONENTS_ESM3_LANDRECORDDATA_H
#define OPENMW_COMPONENTS_ESM3_LANDRECORDDATA_H
#include <array>
#include <cstdint>
namespace ESM
{
struct LandRecordData
{
// number of vertices per side
static constexpr unsigned sLandSize = 65;
// total number of vertices
static constexpr unsigned sLandNumVerts = sLandSize * sLandSize;
// number of textures per side of land
static constexpr unsigned sLandTextureSize = 16;
// total number of textures per land
static constexpr unsigned sLandNumTextures = sLandTextureSize * sLandTextureSize;
// Height in world space for each vertex
std::array<float, sLandNumVerts> mHeights;
float mMinHeight = 0;
float mMaxHeight = 0;
// 24-bit normals, these aren't always correct though. Edge and corner normals may be garbage.
std::array<std::int8_t, 3 * sLandNumVerts> mNormals;
// 2D array of texture indices. An index can be used to look up an LandTexture,
// but to do so you must subtract 1 from the index first!
// An index of 0 indicates the default texture.
std::array<std::uint16_t, sLandNumTextures> mTextures;
// 24-bit RGB color for each vertex
std::array<std::uint8_t, 3 * sLandNumVerts> mColours;
int mDataLoaded = 0;
};
}
#endif
| 1,376
|
C++
|
.h
| 32
| 36.03125
| 102
| 0.686422
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,785
|
loadappa.hpp
|
OpenMW_openmw/components/esm3/loadappa.hpp
|
#ifndef OPENMW_ESM_APPA_H
#define OPENMW_ESM_APPA_H
#include <cstdint>
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Alchemist apparatus
*/
struct Apparatus
{
constexpr static RecNameInts sRecordId = REC_APPA;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Apparatus"; }
enum AppaType
{
MortarPestle = 0,
Alembic = 1,
Calcinator = 2,
Retort = 3
};
struct AADTstruct
{
int32_t mType;
float mQuality;
float mWeight;
int32_t mValue;
};
AADTstruct mData;
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mName, mModel, mIcon;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 1,193
|
C++
|
.h
| 43
| 20.27907
| 108
| 0.598418
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,786
|
loadarmo.hpp
|
OpenMW_openmw/components/esm3/loadarmo.hpp
|
#ifndef OPENMW_ESM_ARMO_H
#define OPENMW_ESM_ARMO_H
#include <cstdint>
#include <string>
#include <vector>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
enum PartReferenceType
{
PRT_Head = 0,
PRT_Hair = 1,
PRT_Neck = 2,
PRT_Cuirass = 3,
PRT_Groin = 4,
PRT_Skirt = 5,
PRT_RHand = 6,
PRT_LHand = 7,
PRT_RWrist = 8,
PRT_LWrist = 9,
PRT_Shield = 10,
PRT_RForearm = 11,
PRT_LForearm = 12,
PRT_RUpperarm = 13,
PRT_LUpperarm = 14,
PRT_RFoot = 15,
PRT_LFoot = 16,
PRT_RAnkle = 17,
PRT_LAnkle = 18,
PRT_RKnee = 19,
PRT_LKnee = 20,
PRT_RLeg = 21,
PRT_LLeg = 22,
PRT_RPauldron = 23,
PRT_LPauldron = 24,
PRT_Weapon = 25,
PRT_Tail = 26,
PRT_Count = 27
};
// Reference to body parts
struct PartReference
{
unsigned char mPart; // possible values [0, 26]
RefId mMale, mFemale;
};
// A list of references to body parts
struct PartReferenceList
{
std::vector<PartReference> mParts;
/// Load one part, assumes the subrecord name was already read
void add(ESMReader& esm);
/// TODO: remove this method. The ESM format does not guarantee that all Part subrecords follow one another.
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct Armor
{
constexpr static RecNameInts sRecordId = REC_ARMO;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Armor"; }
enum Type
{
Helmet = 0,
Cuirass = 1,
LPauldron = 2,
RPauldron = 3,
Greaves = 4,
Boots = 5,
LGauntlet = 6,
RGauntlet = 7,
Shield = 8,
LBracer = 9,
RBracer = 10
};
struct AODTstruct
{
int32_t mType;
float mWeight;
int32_t mValue, mHealth, mEnchant, mArmor;
};
AODTstruct mData;
PartReferenceList mParts;
uint32_t mRecordFlags;
RefId mId, mScript, mEnchant;
std::string mName, mModel, mIcon;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 2,684
|
C++
|
.h
| 95
| 20.073684
| 116
| 0.559315
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
35,787
|
selectiongroup.hpp
|
OpenMW_openmw/components/esm3/selectiongroup.hpp
|
#ifndef COMPONENTS_ESM_SELECTIONGROUP_H
#define COMPONENTS_ESM_SELECTIONGROUP_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct SelectionGroup
{
constexpr static RecNameInts sRecordId = REC_SELG;
static constexpr std::string_view getRecordType() { return "SelectionGroup"; }
uint32_t mRecordFlags = 0;
RefId mId;
std::vector<std::string> selectedInstances;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
/// Set record to default state (does not touch the ID).
void blank();
};
}
#endif
| 742
|
C++
|
.h
| 23
| 26.782609
| 86
| 0.694915
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,788
|
activespells.hpp
|
OpenMW_openmw/components/esm3/activespells.hpp
|
#ifndef OPENMW_ESM_ACTIVESPELLS_H
#define OPENMW_ESM_ACTIVESPELLS_H
#include "cellref.hpp"
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "timestamp.hpp"
#include <string>
#include <variant>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
// Parameters of an effect concerning lasting effects.
// Note we are not using ENAMstruct since the magnitude may be modified by magic resistance, etc.
struct ActiveEffect
{
enum Flags
{
Flag_None = 0,
Flag_Applied = 1 << 0,
Flag_Remove = 1 << 1,
Flag_Ignore_Resistances = 1 << 2,
Flag_Ignore_Reflect = 1 << 3,
Flag_Ignore_SpellAbsorption = 1 << 4
};
int32_t mEffectId;
float mMagnitude;
float mMinMagnitude;
float mMaxMagnitude;
std::variant<RefId, int> mArg; // skill, attribute, or summon
float mDuration;
float mTimeLeft;
int32_t mEffectIndex;
int32_t mFlags;
RefId getSkillOrAttribute() const;
int getActorId() const;
};
// format 0, saved games only
struct ActiveSpells
{
enum Flags : uint32_t
{
Flag_Temporary = 1 << 0, //!< Effect will end automatically once its duration ends.
Flag_Equipment = 1 << 1, //!< Effect will end automatically if item is unequipped.
Flag_SpellStore = 1 << 2, //!< Effect will end automatically if removed from the actor's spell store.
Flag_AffectsBaseValues = 1 << 3, //!< Effects will affect base values instead of current values.
Flag_Stackable
= 1 << 4, //!< Effect can stack. If this flag is not set, spells from the same caster and item cannot stack.
Flag_Lua
= 1 << 5, //!< Effect was added via Lua. Should not do any vfx/sound as this is handled by Lua scripts.
};
struct ActiveSpellParams
{
RefId mActiveSpellId;
RefId mSourceSpellId;
std::vector<ActiveEffect> mEffects;
std::string mDisplayName;
int32_t mCasterActorId;
RefNum mItem;
Flags mFlags;
int32_t mWorsenings;
TimeStamp mNextWorsening;
};
std::vector<ActiveSpellParams> mSpells;
std::vector<ActiveSpellParams> mQueue;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
namespace Compatibility
{
namespace ActiveSpells
{
enum EffectType
{
Type_Temporary,
Type_Ability,
Type_Enchantment,
Type_Permanent,
Type_Consumable,
};
using Flags = ESM::ActiveSpells::Flags;
constexpr Flags Type_Temporary_Flags = Flags::Flag_Temporary;
constexpr Flags Type_Consumable_Flags = static_cast<Flags>(Flags::Flag_Temporary | Flags::Flag_Stackable);
constexpr Flags Type_Permanent_Flags = Flags::Flag_SpellStore;
constexpr Flags Type_Ability_Flags
= static_cast<Flags>(Flags::Flag_SpellStore | Flags::Flag_AffectsBaseValues);
constexpr Flags Type_Enchantment_Flags = Flags::Flag_Equipment;
}
}
}
#endif
| 3,358
|
C++
|
.h
| 92
| 27.184783
| 120
| 0.604673
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,789
|
loadskil.hpp
|
OpenMW_openmw/components/esm3/loadskil.hpp
|
#ifndef OPENMW_ESM_SKIL_H
#define OPENMW_ESM_SKIL_H
#include <array>
#include <optional>
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
using SkillId = StringRefId;
struct MagicSchool
{
ESM::RefId mAreaSound;
ESM::RefId mBoltSound;
ESM::RefId mCastSound;
ESM::RefId mFailureSound;
ESM::RefId mHitSound;
std::string mName;
int32_t mAutoCalcMax;
static constexpr int Length = 6;
static RefId indexToSkillRefId(int index);
static int skillRefIdToIndex(RefId id);
};
/*
* Skill information
*
*/
struct Skill
{
constexpr static RecNameInts sRecordId = REC_SKIL;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Skill"; }
uint32_t mRecordFlags;
SkillId mId;
//! Enum that defines the index into SKDTstruct::mUseValue for all vanilla skill uses
enum UseType
{
// These are shared by multiple skills
Armor_HitByOpponent = 0,
Block_Success = 0,
Spellcast_Success = 0,
Weapon_SuccessfulHit = 0,
// Skill-specific use types
Alchemy_CreatePotion = 0,
Alchemy_UseIngredient = 1,
Enchant_Recharge = 0,
Enchant_UseMagicItem = 1,
Enchant_CreateMagicItem = 2,
Enchant_CastOnStrike = 3,
Acrobatics_Jump = 0,
Acrobatics_Fall = 1,
Mercantile_Success = 0,
Mercantile_Bribe = 1, //!< \Note This is bugged in vanilla and is not actually in use.
Security_DisarmTrap = 0,
Security_PickLock = 1,
Sneak_AvoidNotice = 0,
Sneak_PickPocket = 1,
Speechcraft_Success = 0,
Speechcraft_Fail = 1,
Armorer_Repair = 0,
Athletics_RunOneSecond = 0,
Athletics_SwimOneSecond = 1,
};
struct SKDTstruct
{
int32_t mAttribute; // see defs.hpp
int32_t mSpecialization; // 0 - Combat, 1 - Magic, 2 - Stealth
float mUseValue[4]; // How much skill improves through use. Meaning
// of each field depends on what skill this
// is. See UseType above
}; // Total size: 24 bytes
SKDTstruct mData;
std::string mDescription;
std::string mName;
std::string mIcon;
float mWerewolfValue{};
std::optional<MagicSchool> mSchool;
static const SkillId Block;
static const SkillId Armorer;
static const SkillId MediumArmor;
static const SkillId HeavyArmor;
static const SkillId BluntWeapon;
static const SkillId LongBlade;
static const SkillId Axe;
static const SkillId Spear;
static const SkillId Athletics;
static const SkillId Enchant;
static const SkillId Destruction;
static const SkillId Alteration;
static const SkillId Illusion;
static const SkillId Conjuration;
static const SkillId Mysticism;
static const SkillId Restoration;
static const SkillId Alchemy;
static const SkillId Unarmored;
static const SkillId Security;
static const SkillId Sneak;
static const SkillId Acrobatics;
static const SkillId LightArmor;
static const SkillId ShortBlade;
static const SkillId Marksman;
static const SkillId Mercantile;
static const SkillId Speechcraft;
static const SkillId HandToHand;
static constexpr int Length = 27;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID/index).
static RefId indexToRefId(int index);
static int refIdToIndex(RefId id);
};
}
#endif
| 4,187
|
C++
|
.h
| 116
| 26.715517
| 108
| 0.617037
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,790
|
aisequence.hpp
|
OpenMW_openmw/components/esm3/aisequence.hpp
|
#ifndef OPENMW_COMPONENTS_ESM_AISEQUENCE_H
#define OPENMW_COMPONENTS_ESM_AISEQUENCE_H
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include <components/esm/refid.hpp>
#include <components/esm/vector3.hpp>
namespace ESM
{
class ESMReader;
class ESMWriter;
namespace AiSequence
{
// format 0, saved games only
// As opposed to AiPackageList, this stores the "live" version of AI packages.
enum AiPackages
{
Ai_Wander = fourCC("WAND"),
Ai_Travel = fourCC("TRAV"),
Ai_Escort = fourCC("ESCO"),
Ai_Follow = fourCC("FOLL"),
Ai_Activate = fourCC("ACTI"),
Ai_Combat = fourCC("COMB"),
Ai_Pursue = fourCC("PURS")
};
struct AiPackage
{
virtual ~AiPackage() {}
};
struct AiWanderData
{
int16_t mDistance;
int16_t mDuration;
std::uint8_t mTimeOfDay;
std::uint8_t mIdle[8];
std::uint8_t mShouldRepeat;
};
struct AiWanderDuration
{
float mRemainingDuration;
};
struct AiTravelData
{
float mX, mY, mZ;
};
struct AiEscortData
{
float mX, mY, mZ;
int16_t mDuration;
};
struct AiWander : AiPackage
{
AiWanderData mData;
AiWanderDuration mDurationData; // was TimeStamp mStartTime
bool mStoredInitialActorPosition;
Vector3 mInitialActorPosition;
/// \todo add more AiWander state
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct AiTravel : AiPackage
{
AiTravelData mData;
bool mHidden;
bool mRepeat;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct AiEscort : AiPackage
{
AiEscortData mData;
int32_t mTargetActorId;
ESM::RefId mTargetId;
std::string mCellId;
float mRemainingDuration;
bool mRepeat;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct AiFollow : AiPackage
{
AiEscortData mData;
int32_t mTargetActorId;
ESM::RefId mTargetId;
std::string mCellId;
float mRemainingDuration;
bool mAlwaysFollow;
bool mCommanded;
bool mActive;
bool mRepeat;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct AiActivate : AiPackage
{
ESM::RefId mTargetId;
bool mRepeat;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct AiCombat : AiPackage
{
int32_t mTargetActorId;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct AiPursue : AiPackage
{
int32_t mTargetActorId;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct AiPackageContainer
{
int32_t mType;
std::unique_ptr<AiPackage> mPackage;
};
struct AiSequence
{
AiSequence() { mLastAiPackage = -1; }
std::vector<AiPackageContainer> mPackages;
int32_t mLastAiPackage;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
private:
AiSequence(const AiSequence&);
AiSequence& operator=(const AiSequence&);
};
}
}
#endif
| 3,859
|
C++
|
.h
| 132
| 18.780303
| 86
| 0.537022
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,791
|
loadbook.hpp
|
OpenMW_openmw/components/esm3/loadbook.hpp
|
#ifndef OPENMW_ESM_BOOK_H
#define OPENMW_ESM_BOOK_H
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include <cstdint>
#include <string>
namespace ESM
{
/*
* Books, magic scrolls, notes and so on
*/
class ESMReader;
class ESMWriter;
struct Book
{
constexpr static RecNameInts sRecordId = REC_BOOK;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Book"; }
struct BKDTstruct
{
float mWeight;
int32_t mValue, mIsScroll, mSkillId, mEnchant;
};
BKDTstruct mData;
std::string mName, mModel, mIcon, mText;
uint32_t mRecordFlags;
RefId mId;
RefId mScript, mEnchant;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 1,057
|
C++
|
.h
| 35
| 23.828571
| 108
| 0.642292
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,792
|
loadstat.hpp
|
OpenMW_openmw/components/esm3/loadstat.hpp
|
#ifndef OPENMW_ESM_STAT_H
#define OPENMW_ESM_STAT_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* 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
{
constexpr static RecNameInts sRecordId = REC_STAT;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Static"; }
uint32_t mRecordFlags;
RefId mId;
std::string mModel;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 1,341
|
C++
|
.h
| 35
| 32.628571
| 108
| 0.685185
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,793
|
transport.hpp
|
OpenMW_openmw/components/esm3/transport.hpp
|
#ifndef OPENMW_COMPONENTS_ESM_TRANSPORT_H
#define OPENMW_COMPONENTS_ESM_TRANSPORT_H
#include <string>
#include <vector>
#include <components/esm/position.hpp>
namespace ESM
{
class ESMReader;
class ESMWriter;
/// List of travel service destination. Shared by CREA and NPC_ records.
struct Transport
{
struct Dest
{
Position mPos;
std::string mCellName;
};
std::vector<Dest> mList;
/// Load one destination, assumes the subrecord name was already read
void add(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 637
|
C++
|
.h
| 24
| 20.75
| 77
| 0.662791
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,794
|
esmwriter.hpp
|
OpenMW_openmw/components/esm3/esmwriter.hpp
|
#ifndef OPENMW_ESM_WRITER_H
#define OPENMW_ESM_WRITER_H
#include <iosfwd>
#include <list>
#include <type_traits>
#include "components/esm/decompose.hpp"
#include "components/esm/esmcommon.hpp"
#include "components/esm/refid.hpp"
#include "loadtes3.hpp"
namespace ToUTF8
{
class Utf8Encoder;
}
namespace ESM
{
class ESMWriter
{
struct RecordData
{
NAME name;
std::streampos position;
uint32_t size;
};
public:
ESMWriter();
unsigned int getVersion() const;
// Set various header data (Header::Data). All of the below functions must be called before writing,
// otherwise this data will be left uninitialized.
void setVersion(unsigned int ver = 0x3fa66666);
void setType(int type);
void setEncoder(ToUTF8::Utf8Encoder* encoding);
void setAuthor(std::string_view author);
void setDescription(std::string_view desc);
void setHeader(const Header& value) { mHeader = value; }
// Set the record count for writing it in the file header
void setRecordCount(int count);
// Counts how many records we have actually written.
// It is a good idea to compare this with the value you wrote into the header (setRecordCount)
// It should be the record count you set + 1 (1 additional record for the TES3 header)
int getRecordCount() const { return mRecordCount; }
FormatVersion getFormatVersion() const { return mHeader.mFormatVersion; }
void setFormatVersion(FormatVersion value);
void clearMaster();
void addMaster(std::string_view name, uint64_t size);
void save(std::ostream& file);
///< Start saving a file by writing the TES3 header.
void close();
///< \note Does not close the stream.
void writeHNString(NAME name, std::string_view data);
void writeHNString(NAME name, std::string_view data, size_t size);
void writeHNCString(NAME name, std::string_view data)
{
startSubRecord(name);
writeHCString(data);
endRecord(name);
}
void writeHNOString(NAME name, std::string_view data)
{
if (!data.empty())
writeHNString(name, data);
}
void writeHNOCString(NAME name, std::string_view data)
{
if (!data.empty())
writeHNCString(name, data);
}
void writeHNRefId(NAME name, RefId value);
void writeHNRefId(NAME name, RefId value, std::size_t size);
void writeHNCRefId(NAME name, RefId value)
{
startSubRecord(name);
writeHCRefId(value);
endRecord(name);
}
void writeHNORefId(NAME name, RefId value)
{
if (!value.empty())
writeHNRefId(name, value);
}
void writeHNOCRefId(NAME name, RefId value)
{
if (!value.empty())
writeHNCRefId(name, value);
}
void writeCellId(const ESM::RefId& cellId);
template <typename T>
void writeHNT(NAME name, const T& data)
{
startSubRecord(name);
writeT(data);
endRecord(name);
}
template <typename T, std::size_t size>
void writeHNT(NAME name, const T (&data)[size])
{
startSubRecord(name);
writeT(data);
endRecord(name);
}
void writeNamedComposite(NAME name, const auto& value)
{
decompose(value, [&](const auto&... args) {
startSubRecord(name);
(writeT(args), ...);
endRecord(name);
});
}
void writeComposite(const auto& value)
{
decompose(value, [&](const auto&... args) { (writeT(args), ...); });
}
// Prevent using writeHNT with strings. This already happened by accident and results in
// state being discarded without any error on writing or reading it. :(
// writeHNString and friends must be used instead.
void writeHNT(NAME name, const std::string& data) = delete;
void writeHNT(NAME name, std::string_view data) = delete;
void writeT(NAME data) = delete;
template <typename T, std::size_t size>
void writeHNT(NAME name, const T (&data)[size], int) = delete;
template <typename T>
void writeHNT(NAME name, const T& data, std::size_t size)
{
startSubRecord(name);
writeT(data, size);
endRecord(name);
}
template <typename T>
void writeT(const T& data)
{
static_assert(!std::is_pointer_v<T>);
write(reinterpret_cast<const char*>(&data), sizeof(T));
}
template <typename T, std::size_t size>
void writeT(const T (&data)[size])
{
write(reinterpret_cast<const char*>(data), size * sizeof(T));
}
template <typename T>
void writeT(const T& data, size_t size)
{
static_assert(!std::is_pointer_v<T>);
write((char*)&data, size);
}
void startRecord(NAME name, uint32_t flags = 0);
void startRecord(uint32_t name, uint32_t flags = 0);
/// @note Sub-record hierarchies are not properly supported in ESMReader. This should be fixed later.
void startSubRecord(NAME name);
void endRecord(NAME name);
void endRecord(uint32_t name);
void writeMaybeFixedSizeString(const std::string& data, std::size_t size);
void writeHString(std::string_view data);
void writeHCString(std::string_view data);
void writeMaybeFixedSizeRefId(RefId value, std::size_t size);
void writeHRefId(RefId refId);
void writeHCRefId(RefId refId);
void writeName(NAME data);
void write(const char* data, size_t size);
void writeFormId(const ESM::FormId&, bool wide = false, NAME tag = "FRMR");
private:
std::list<RecordData> mRecords;
std::ostream* mStream;
std::streampos mHeaderPos;
ToUTF8::Utf8Encoder* mEncoder;
int mRecordCount;
bool mCounting;
Header mHeader;
void writeRefId(RefId value);
};
}
#endif
| 6,406
|
C++
|
.h
| 170
| 28.282353
| 109
| 0.600129
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,795
|
stolenitems.hpp
|
OpenMW_openmw/components/esm3/stolenitems.hpp
|
#ifndef OPENMW_COMPONENTS_ESM_STOLENITEMS_H
#define OPENMW_COMPONENTS_ESM_STOLENITEMS_H
#include <components/esm/refid.hpp>
#include <map>
#include <string>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct StolenItems
{
typedef std::map<ESM::RefId, std::map<std::pair<ESM::RefId, bool>, int>> StolenItemsMap;
StolenItemsMap mStolenItems;
void load(ESMReader& esm);
void write(ESMWriter& esm) const;
};
}
#endif
| 511
|
C++
|
.h
| 19
| 22.631579
| 96
| 0.705761
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,796
|
loadench.hpp
|
OpenMW_openmw/components/esm3/loadench.hpp
|
#ifndef OPENMW_ESM_ENCH_H
#define OPENMW_ESM_ENCH_H
#include <cstdint>
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "effectlist.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Enchantments
*/
struct Enchantment
{
constexpr static RecNameInts sRecordId = REC_ENCH;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Enchantment"; }
enum Type
{
CastOnce = 0,
WhenStrikes = 1,
WhenUsed = 2,
ConstantEffect = 3
};
enum Flags
{
Autocalc = 0x01
};
struct ENDTstruct
{
int32_t mType;
int32_t mCost;
int32_t mCharge;
int32_t mFlags;
};
uint32_t mRecordFlags;
RefId mId;
ENDTstruct mData;
EffectList mEffects;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 1,266
|
C++
|
.h
| 48
| 18.8125
| 108
| 0.586722
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,797
|
loadingr.hpp
|
OpenMW_openmw/components/esm3/loadingr.hpp
|
#ifndef OPENMW_ESM_INGR_H
#define OPENMW_ESM_INGR_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Alchemy ingredient
*/
struct Ingredient
{
constexpr static RecNameInts sRecordId = REC_INGR;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Ingredient"; }
struct IRDTstruct
{
float mWeight;
int32_t mValue;
int32_t mEffectID[4]; // Effect, -1 means none
int32_t mSkills[4]; // SkillEnum related to effect
int32_t mAttributes[4]; // Attribute related to effect
};
IRDTstruct mData;
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mName, mModel, mIcon;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 1,159
|
C++
|
.h
| 36
| 25.166667
| 108
| 0.633993
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,798
|
cellstate.hpp
|
OpenMW_openmw/components/esm3/cellstate.hpp
|
#ifndef OPENMW_ESM_CELLSTATE_H
#define OPENMW_ESM_CELLSTATE_H
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "timestamp.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
/// \note Does not include references
struct CellState
{
RefId mId;
bool mIsInterior;
float mWaterLevel;
int32_t mHasFogOfWar; // Do we have fog of war state (0 or 1)? (see fogstate.hpp)
TimeStamp mLastRespawn;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 613
|
C++
|
.h
| 23
| 21.652174
| 89
| 0.678694
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,799
|
dialoguecondition.hpp
|
OpenMW_openmw/components/esm3/dialoguecondition.hpp
|
#ifndef OPENMW_ESM3_DIALOGUECONDITION_H
#define OPENMW_ESM3_DIALOGUECONDITION_H
#include <cstdint>
#include <optional>
#include <string>
#include <variant>
#include <components/esm/refid.hpp>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct DialogueCondition
{
enum Function : std::int8_t
{
Function_FacReactionLowest = 0,
Function_FacReactionHighest,
Function_RankRequirement,
Function_Reputation,
Function_Health_Percent,
Function_PcReputation,
Function_PcLevel,
Function_PcHealthPercent,
Function_PcMagicka,
Function_PcFatigue,
Function_PcStrength,
Function_PcBlock,
Function_PcArmorer,
Function_PcMediumArmor,
Function_PcHeavyArmor,
Function_PcBluntWeapon,
Function_PcLongBlade,
Function_PcAxe,
Function_PcSpear,
Function_PcAthletics,
Function_PcEnchant,
Function_PcDestruction,
Function_PcAlteration,
Function_PcIllusion,
Function_PcConjuration,
Function_PcMysticism,
Function_PcRestoration,
Function_PcAlchemy,
Function_PcUnarmored,
Function_PcSecurity,
Function_PcSneak,
Function_PcAcrobatics,
Function_PcLightArmor,
Function_PcShortBlade,
Function_PcMarksman,
Function_PcMerchantile,
Function_PcSpeechcraft,
Function_PcHandToHand,
Function_PcGender,
Function_PcExpelled,
Function_PcCommonDisease,
Function_PcBlightDisease,
Function_PcClothingModifier,
Function_PcCrimeLevel,
Function_SameSex,
Function_SameRace,
Function_SameFaction,
Function_FactionRankDifference,
Function_Detected,
Function_Alarmed,
Function_Choice,
Function_PcIntelligence,
Function_PcWillpower,
Function_PcAgility,
Function_PcSpeed,
Function_PcEndurance,
Function_PcPersonality,
Function_PcLuck,
Function_PcCorprus,
Function_Weather,
Function_PcVampire,
Function_Level,
Function_Attacked,
Function_TalkedToPc,
Function_PcHealth,
Function_CreatureTarget,
Function_FriendHit,
Function_Fight,
Function_Hello,
Function_Alarm,
Function_Flee,
Function_ShouldAttack,
Function_Werewolf,
Function_PcWerewolfKills = 73,
Function_Global,
Function_Local,
Function_Journal,
Function_Item,
Function_Dead,
Function_NotId,
Function_NotFaction,
Function_NotClass,
Function_NotRace,
Function_NotCell,
Function_NotLocal,
Function_None, // Editor only
};
enum Comparison : char
{
Comp_Eq = '0',
Comp_Ne = '1',
Comp_Gt = '2',
Comp_Ge = '3',
Comp_Ls = '4',
Comp_Le = '5',
Comp_None = ' ', // Editor only
};
std::string mVariable;
std::variant<int32_t, float> mValue = 0;
std::uint8_t mIndex = 0;
Function mFunction = Function_None;
Comparison mComparison = Comp_None;
static std::optional<DialogueCondition> load(ESMReader& esm, ESM::RefId context);
void save(ESMWriter& esm) const;
};
}
#endif
| 3,813
|
C++
|
.h
| 122
| 19.991803
| 89
| 0.565099
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,800
|
statstate.hpp
|
OpenMW_openmw/components/esm3/statstate.hpp
|
#ifndef OPENMW_ESM_STATSTATE_H
#define OPENMW_ESM_STATSTATE_H
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
template <typename T>
struct StatState
{
T mBase;
T mMod; // Note: can either be the modifier, or the modified value.
// A bit inconsistent, but we can't fix this without breaking compatibility.
T mCurrent;
float mDamage;
float mProgress;
StatState();
void load(ESMReader& esm, bool intFallback = false);
void save(ESMWriter& esm) const;
};
}
#endif
| 606
|
C++
|
.h
| 22
| 21.363636
| 92
| 0.643599
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,801
|
variantimp.hpp
|
OpenMW_openmw/components/esm3/variantimp.hpp
|
#ifndef OPENMW_ESM_VARIANTIMP_H
#define OPENMW_ESM_VARIANTIMP_H
#include <functional>
#include <string>
#include "variant.hpp"
namespace ESM
{
void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, std::string& value);
void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, float& value);
void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, int32_t& value);
void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, const std::string& value);
void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, float value);
void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, int32_t value);
struct ReadESMVariantValue
{
std::reference_wrapper<ESMReader> mReader;
Variant::Format mFormat;
VarType mType;
ReadESMVariantValue(ESMReader& reader, Variant::Format format, VarType type)
: mReader(reader)
, mFormat(format)
, mType(type)
{
}
void operator()(std::monostate) const {}
template <typename T>
void operator()(T& value) const
{
readESMVariantValue(mReader.get(), mFormat, mType, value);
}
};
struct WriteESMVariantValue
{
std::reference_wrapper<ESMWriter> mWriter;
Variant::Format mFormat;
VarType mType;
WriteESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type)
: mWriter(writer)
, mFormat(format)
, mType(type)
{
}
void operator()(std::monostate) const {}
template <typename T>
void operator()(const T& value) const
{
writeESMVariantValue(mWriter.get(), mFormat, mType, value);
}
};
}
#endif
| 1,911
|
C++
|
.h
| 51
| 29.862745
| 113
| 0.663049
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,802
|
loadcont.hpp
|
OpenMW_openmw/components/esm3/loadcont.hpp
|
#ifndef OPENMW_ESM_CONT_H
#define OPENMW_ESM_CONT_H
#include <string>
#include <vector>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Container definition
*/
struct ContItem
{
int32_t mCount{ 0 };
ESM::RefId mItem;
};
/// InventoryList, NPCO subrecord
struct InventoryList
{
std::vector<ContItem> mList;
/// Load one item, assumes subrecord name is already read
void add(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct Container
{
constexpr static RecNameInts sRecordId = REC_CONT;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Container"; }
enum Flags
{
Organic = 1, // Objects cannot be placed in this container
Respawn = 2, // Respawns after 4 months
Unknown = 8
};
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mName, mModel;
float mWeight; // Not sure, might be max total weight allowed?
int32_t mFlags;
InventoryList mInventory;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 1,516
|
C++
|
.h
| 50
| 23.52
| 108
| 0.628966
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,803
|
effectlist.hpp
|
OpenMW_openmw/components/esm3/effectlist.hpp
|
#ifndef OPENMW_ESM_EFFECTLIST_H
#define OPENMW_ESM_EFFECTLIST_H
#include <cstdint>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
/** Defines a spell effect. Shared between SPEL (Spells), ALCH
(Potions) and ENCH (Item enchantments) records
*/
struct ENAMstruct
{
// Magical effect, hard-coded ID
int16_t mEffectID;
// Which skills/attributes are affected (for restore/drain spells
// etc.)
signed char mSkill, mAttribute; // -1 if N/A
// Other spell parameters
int32_t mRange; // 0 - self, 1 - touch, 2 - target (RangeType enum)
int32_t mArea, mDuration, mMagnMin, mMagnMax;
};
struct IndexedENAMstruct
{
bool operator!=(const IndexedENAMstruct& rhs) const;
bool operator==(const IndexedENAMstruct& rhs) const { return !(this->operator!=(rhs)); }
ENAMstruct mData;
uint32_t mIndex;
};
/// EffectList, ENAM subrecord
struct EffectList
{
std::vector<IndexedENAMstruct> mList;
void populate(const std::vector<ENAMstruct>& effects);
void updateIndexes();
/// Load one effect, assumes subrecord name was already read
void add(ESMReader& esm);
/// Load all effects
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 1,386
|
C++
|
.h
| 43
| 25.790698
| 96
| 0.645379
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,804
|
loadlock.hpp
|
OpenMW_openmw/components/esm3/loadlock.hpp
|
#ifndef OPENMW_ESM_LOCK_H
#define OPENMW_ESM_LOCK_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct Lockpick
{
constexpr static RecNameInts sRecordId = REC_LOCK;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Lockpick"; }
struct Data
{
float mWeight;
int32_t mValue;
float mQuality;
int32_t mUses;
}; // Size = 16
Data mData;
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mName, mModel, mIcon;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 982
|
C++
|
.h
| 32
| 23.6875
| 108
| 0.628998
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,805
|
aipackage.hpp
|
OpenMW_openmw/components/esm3/aipackage.hpp
|
#ifndef OPENMW_ESM_AIPACKAGE_H
#define OPENMW_ESM_AIPACKAGE_H
#include <string>
#include <vector>
#include "components/esm/esmcommon.hpp"
#include "components/misc/concepts.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct AIData
{
uint16_t mHello; // This is the base value for greeting distance [0, 65535]
unsigned char mFight, mFlee, mAlarm; // These are probabilities [0, 100]
int32_t mServices; // See the Services enum
void blank();
///< Set record to default state (does not touch the ID).
}; // 12 bytes
struct AIWander
{
int16_t mDistance;
int16_t mDuration;
unsigned char mTimeOfDay;
unsigned char mIdle[8];
unsigned char mShouldRepeat;
};
struct AITravel
{
float mX, mY, mZ;
unsigned char mShouldRepeat;
};
struct AITarget
{
float mX, mY, mZ;
int16_t mDuration;
NAME32 mId;
unsigned char mShouldRepeat;
};
struct AIActivate
{
NAME32 mName;
unsigned char mShouldRepeat;
};
enum AiPackageType : std::uint32_t
{
AI_Wander = 0x575f4941,
AI_Travel = 0x545f4941,
AI_Follow = 0x465f4941,
AI_Escort = 0x455f4941,
AI_Activate = 0x415f4941,
};
inline constexpr std::uint32_t AI_CNDT = 0x54444e43;
/// \note Used for storaging packages in a single container
/// w/o manual memory allocation accordingly to policy standards
struct AIPackage
{
AiPackageType mType;
// Anonymous union
union
{
AIWander mWander;
AITravel mTravel;
AITarget mTarget;
AIActivate mActivate;
};
/// \note for AITarget only, placed here to stick with union,
/// overhead should be not so awful
std::string mCellName;
};
struct AIPackageList
{
std::vector<AIPackage> mList;
/// Add a single AIPackage, assumes subrecord name was already read
void add(ESMReader& esm);
void save(ESMWriter& esm) const;
};
template <Misc::SameAsWithoutCvref<AIData> T>
void decompose(T&& v, const auto& f)
{
char padding[3] = { 0, 0, 0 };
f(v.mHello, v.mFight, v.mFlee, v.mAlarm, padding, v.mServices);
}
}
#endif
| 2,374
|
C++
|
.h
| 84
| 21.369048
| 83
| 0.61867
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,806
|
loadmgef.hpp
|
OpenMW_openmw/components/esm3/loadmgef.hpp
|
#ifndef OPENMW_ESM_MGEF_H
#define OPENMW_ESM_MGEF_H
#include <array>
#include <map>
#include <string>
#include <string_view>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "components/misc/strings/algorithm.hpp"
#include <osg/Vec4>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct MagicEffect
{
constexpr static RecNameInts sRecordId = REC_MGEF;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "MagicEffect"; }
uint32_t mRecordFlags;
RefId mId;
enum Flags
{
// Originally fixed flags (HardcodedFlags array consists of just these)
TargetSkill = 0x1, // Affects a specific skill, which is specified elsewhere in the effect structure.
TargetAttribute
= 0x2, // Affects a specific attribute, which is specified elsewhere in the effect structure.
NoDuration = 0x4, // Has no duration. Only runs effect once on cast.
NoMagnitude = 0x8, // Has no magnitude.
Harmful = 0x10, // Counts as a negative effect. Interpreted as useful for attack, and is treated as a bad
// effect in alchemy.
ContinuousVfx = 0x20, // The effect's hit particle VFX repeats for the full duration of the spell, rather
// than occuring once on hit.
CastSelf = 0x40, // Allows range - cast on self.
CastTouch = 0x80, // Allows range - cast on touch.
CastTarget = 0x100, // Allows range - cast on target.
AppliedOnce
= 0x1000, // An effect that is applied once it lands, instead of continuously. Allows an effect to reduce an
// attribute below zero; removes the normal minimum effect duration of 1 second.
Stealth = 0x2000, // Unused
NonRecastable = 0x4000, // Does not land if parent spell is already affecting target. Shows "you cannot
// re-cast" message for self target.
IllegalDaedra = 0x8000, // Unused
Unreflectable = 0x10000, // Cannot be reflected, the effect always lands normally.
CasterLinked = 0x20000, // Must quench if caster is dead, or not an NPC/creature. Not allowed in
// containter/door trap spells.
// Originally modifiable flags
AllowSpellmaking = 0x200, // Can be used for spellmaking
AllowEnchanting = 0x400, // Can be used for enchanting
NegativeLight = 0x800 // Inverts the effect's color
};
enum MagnitudeDisplayType
{
MDT_None,
MDT_Feet,
MDT_Level,
MDT_Percentage,
MDT_Points,
MDT_TimesInt
};
struct MEDTstruct
{
RefId mSchool; // Skill id
float mBaseCost;
int32_t mFlags;
// Glow color for enchanted items with this effect
int32_t mRed, mGreen, mBlue;
float mUnknown1; // Called "Size X" in CS
float mSpeed; // Speed of fired projectile
float mUnknown2; // Called "Size Cap" in CS
}; // 36 bytes
/// Returns the effect that provides resistance against \a effect (or -1 if there's none)
static short getResistanceEffect(short effect);
/// Returns the effect that induces weakness against \a effect (or -1 if there's none)
static short getWeaknessEffect(short effect);
MagnitudeDisplayType getMagnitudeDisplayType() const;
MEDTstruct mData;
std::string mIcon, mParticle; // Textures
ESM::RefId mCasting, mHit, mArea; // Static
ESM::RefId mBolt; // Weapon
ESM::RefId mCastSound, mBoltSound, mHitSound, mAreaSound; // Sounds
std::string mDescription;
// Index of this magical effect. Corresponds to one of the
// hard-coded effects in the original engine:
// 0-136 in Morrowind
// 137 in Tribunal
// 138-140 in Bloodmoon (also changes 64?)
// 141-142 are summon effects introduced in bloodmoon, but not used
// there. They can be redefined in mods by setting the name in GMST
// sEffectSummonCreature04/05 creature id in
// sMagicCreature04ID/05ID.
int32_t mIndex;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
/// Set record to default state (does not touch the ID/index).
void blank();
osg::Vec4f getColor() const;
enum Effects
{
WaterBreathing = 0,
SwiftSwim = 1,
WaterWalking = 2,
Shield = 3,
FireShield = 4,
LightningShield = 5,
FrostShield = 6,
Burden = 7,
Feather = 8,
Jump = 9,
Levitate = 10,
SlowFall = 11,
Lock = 12,
Open = 13,
FireDamage = 14,
ShockDamage = 15,
FrostDamage = 16,
DrainAttribute = 17,
DrainHealth = 18,
DrainMagicka = 19,
DrainFatigue = 20,
DrainSkill = 21,
DamageAttribute = 22,
DamageHealth = 23,
DamageMagicka = 24,
DamageFatigue = 25,
DamageSkill = 26,
Poison = 27,
WeaknessToFire = 28,
WeaknessToFrost = 29,
WeaknessToShock = 30,
WeaknessToMagicka = 31,
WeaknessToCommonDisease = 32,
WeaknessToBlightDisease = 33,
WeaknessToCorprusDisease = 34,
WeaknessToPoison = 35,
WeaknessToNormalWeapons = 36,
DisintegrateWeapon = 37,
DisintegrateArmor = 38,
Invisibility = 39,
Chameleon = 40,
Light = 41,
Sanctuary = 42,
NightEye = 43,
Charm = 44,
Paralyze = 45,
Silence = 46,
Blind = 47,
Sound = 48,
CalmHumanoid = 49,
CalmCreature = 50,
FrenzyHumanoid = 51,
FrenzyCreature = 52,
DemoralizeHumanoid = 53,
DemoralizeCreature = 54,
RallyHumanoid = 55,
RallyCreature = 56,
Dispel = 57,
Soultrap = 58,
Telekinesis = 59,
Mark = 60,
Recall = 61,
DivineIntervention = 62,
AlmsiviIntervention = 63,
DetectAnimal = 64,
DetectEnchantment = 65,
DetectKey = 66,
SpellAbsorption = 67,
Reflect = 68,
CureCommonDisease = 69,
CureBlightDisease = 70,
CureCorprusDisease = 71,
CurePoison = 72,
CureParalyzation = 73,
RestoreAttribute = 74,
RestoreHealth = 75,
RestoreMagicka = 76,
RestoreFatigue = 77,
RestoreSkill = 78,
FortifyAttribute = 79,
FortifyHealth = 80,
FortifyMagicka = 81,
FortifyFatigue = 82,
FortifySkill = 83,
FortifyMaximumMagicka = 84,
AbsorbAttribute = 85,
AbsorbHealth = 86,
AbsorbMagicka = 87,
AbsorbFatigue = 88,
AbsorbSkill = 89,
ResistFire = 90,
ResistFrost = 91,
ResistShock = 92,
ResistMagicka = 93,
ResistCommonDisease = 94,
ResistBlightDisease = 95,
ResistCorprusDisease = 96,
ResistPoison = 97,
ResistNormalWeapons = 98,
ResistParalysis = 99,
RemoveCurse = 100,
TurnUndead = 101,
SummonScamp = 102,
SummonClannfear = 103,
SummonDaedroth = 104,
SummonDremora = 105,
SummonAncestralGhost = 106,
SummonSkeletalMinion = 107,
SummonBonewalker = 108,
SummonGreaterBonewalker = 109,
SummonBonelord = 110,
SummonWingedTwilight = 111,
SummonHunger = 112,
SummonGoldenSaint = 113,
SummonFlameAtronach = 114,
SummonFrostAtronach = 115,
SummonStormAtronach = 116,
FortifyAttack = 117,
CommandCreature = 118,
CommandHumanoid = 119,
BoundDagger = 120,
BoundLongsword = 121,
BoundMace = 122,
BoundBattleAxe = 123,
BoundSpear = 124,
BoundLongbow = 125,
ExtraSpell = 126,
BoundCuirass = 127,
BoundHelm = 128,
BoundBoots = 129,
BoundShield = 130,
BoundGloves = 131,
Corprus = 132,
Vampirism = 133,
SummonCenturionSphere = 134,
SunDamage = 135,
StuntedMagicka = 136,
// Tribunal only
SummonFabricant = 137,
// Bloodmoon only
SummonWolf = 138,
SummonBear = 139,
SummonBonewolf = 140,
SummonCreature04 = 141,
SummonCreature05 = 142,
Length
};
static const std::array<std::string, Length> sGmstEffectIds;
static const std::array<std::string_view, Length> sIndexNames;
static const std::map<std::string_view, int, Misc::StringUtils::CiComp> sGmstEffectIdToIndexMap;
static const std::map<std::string_view, int, Misc::StringUtils::CiComp> sIndexNameToIndexMap;
static const std::string& indexToGmstString(int effectID);
static std::string_view indexToName(int effectID);
static int indexNameToIndex(std::string_view effect);
static int effectGmstIdToIndex(std::string_view gmstId);
static RefId indexToRefId(int index);
};
}
#endif
| 10,133
|
C++
|
.h
| 258
| 27.406977
| 120
| 0.564131
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
35,807
|
loadtes3.hpp
|
OpenMW_openmw/components/esm3/loadtes3.hpp
|
#ifndef COMPONENT_ESM_TES3_H
#define COMPONENT_ESM_TES3_H
#include <vector>
#include "components/esm/common.hpp"
#include "components/esm/esmcommon.hpp"
#include "components/esm3/formatversion.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct Data
{
ESM::ESMVersion version;
int32_t type; // 0=esp, 1=esm, 32=ess (unused)
std::string author; // Author's name
std::string desc; // File description
int32_t records; // Number of records
};
struct GMDT
{
float mCurrentHealth;
float mMaximumHealth;
float mHour;
unsigned char unknown1[12];
NAME64 mCurrentCell;
unsigned char unknown2[4];
NAME32 mPlayerName;
};
/// \brief File header record
struct Header
{
// Defines another files (esm or esp) that this file depends upon.
struct MasterData
{
std::string name;
uint64_t size;
};
GMDT mGameData; // Used in .ess savegames only
std::vector<unsigned char> mSCRD; // Used in .ess savegames only, unknown
std::vector<unsigned char> mSCRS; // Used in .ess savegames only, screenshot
Data mData;
FormatVersion mFormatVersion;
std::vector<MasterData> mMaster;
void blank();
void load(ESMReader& esm);
void save(ESMWriter& esm);
};
}
#endif
| 1,426
|
C++
|
.h
| 49
| 22.306122
| 84
| 0.630769
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,808
|
typetraits.hpp
|
OpenMW_openmw/components/esm3/typetraits.hpp
|
#ifndef OPENMW_COMPONENTS_ESM3_TYPETRAITS
#define OPENMW_COMPONENTS_ESM3_TYPETRAITS
#include <type_traits>
namespace ESM
{
template <class T, class = std::void_t<>>
struct HasIndex : std::false_type
{
};
template <class T>
struct HasIndex<T, std::void_t<decltype(T::mIndex)>> : std::true_type
{
};
template <class T>
inline constexpr bool hasIndex = HasIndex<T>::value;
template <class T, class = std::void_t<>>
struct HasStringId : std::false_type
{
};
template <class T>
struct HasStringId<T, std::void_t<decltype(T::mStringId)>> : std::true_type
{
};
template <class T>
inline constexpr bool hasStringId = HasStringId<T>::value;
}
#endif // OPENMW_COMPONENTS_ESM3_TYPETRAITS
| 766
|
C++
|
.h
| 27
| 24.111111
| 79
| 0.674419
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,809
|
esmreader.hpp
|
OpenMW_openmw/components/esm3/esmreader.hpp
|
#ifndef OPENMW_ESM_READER_H
#define OPENMW_ESM_READER_H
#include <array>
#include <cstdint>
#include <filesystem>
#include <istream>
#include <map>
#include <memory>
#include <type_traits>
#include <vector>
#include <components/to_utf8/to_utf8.hpp>
#include "components/esm/decompose.hpp"
#include "components/esm/esmcommon.hpp"
#include "components/esm/refid.hpp"
#include "loadtes3.hpp"
namespace ESM
{
template <class T>
struct GetArray
{
using type = void;
};
template <class T, size_t N>
struct GetArray<std::array<T, N>>
{
using type = T;
};
template <class T, size_t N>
struct GetArray<T[N]>
{
using type = T;
};
template <class T>
inline constexpr bool IsReadable
= std::is_arithmetic_v<T> || std::is_enum_v<T> || IsReadable<typename GetArray<T>::type>;
template <>
inline constexpr bool IsReadable<void> = false;
class ReadersCache;
class ESMReader
{
public:
ESMReader();
/*************************************************************************
*
* Information retrieval
*
*************************************************************************/
int getVer() const { return mHeader.mData.version.ui; }
int getRecordCount() const { return mHeader.mData.records; }
float esmVersionF() const { return (mHeader.mData.version.f); }
const std::string& getAuthor() const { return mHeader.mData.author; }
const std::string& getDesc() const { return mHeader.mData.desc; }
const std::vector<Header::MasterData>& getGameFiles() const { return mHeader.mMaster; }
const Header& getHeader() const { return mHeader; }
FormatVersion getFormatVersion() const { return mHeader.mFormatVersion; }
const NAME& retSubName() const { return mCtx.subName; }
uint32_t getSubSize() const { return mCtx.leftSub; }
const std::filesystem::path& getName() const { return mCtx.filename; }
bool isOpen() const { return mEsm != nullptr; }
/*************************************************************************
*
* Opening and closing
*
*************************************************************************/
/** Save the current file position and information in a ESM_Context
struct
*/
ESM_Context getContext();
/** Restore a previously saved context */
void restoreContext(const ESM_Context& rc);
/** Close the file, resets all information. After calling close()
the structure may be reused to load a new file.
*/
void close();
/// Raw opening. Opens the file and sets everything up but doesn't
/// parse the header.
void openRaw(std::unique_ptr<std::istream>&& stream, const std::filesystem::path& name);
/// Load ES file from a new stream, parses the header. Closes the
/// currently open file first, if any.
void open(std::unique_ptr<std::istream>&& stream, const std::filesystem::path& name);
void open(const std::filesystem::path& file);
void openRaw(const std::filesystem::path& filename);
/// Get the current position in the file. Make sure that the file has been opened!
size_t getFileOffset() const { return mEsm->tellg(); }
// This is a quick hack for multiple esm/esp files. Each plugin introduces its own
// terrain palette, but ESMReader does not pass a reference to the correct plugin
// to the individual load() methods. This hack allows to pass this reference
// indirectly to the load() method.
void setIndex(const int index) { mCtx.index = index; }
int getIndex() const { return mCtx.index; }
// Assign parent esX files by tracking their indices in the global list of
// all files/readers used by the engine. This is required for correct adjustRefNum() results
// as required for handling moved, deleted and edited CellRefs.
/// @note Does not validate.
void resolveParentFileIndices(ReadersCache& readers);
const std::vector<int>& getParentFileIndices() const { return mCtx.parentFileIndices; }
// Used only when loading saves to adjust FormIds if load order was changes.
void setContentFileMapping(const std::map<int, int>* mapping) { mContentFileMapping = mapping; }
const std::map<int, int>* getContentFileMapping();
// Returns false if content file not found.
bool applyContentFileMapping(FormId& id);
/*************************************************************************
*
* Medium-level reading shortcuts
*
*************************************************************************/
// Because we want to get rid of CellId, we isolate it's uses.
ESM::RefId getCellId();
// Read data of a given type, stored in a subrecord of a given name
template <typename X>
void getHNT(X& x, NAME name)
{
getHNT(name, x);
}
template <class... Args>
void getHNT(NAME name, Args&... args)
{
constexpr size_t size = (0 + ... + sizeof(Args));
getSubNameIs(name);
getSubHeader();
if (mCtx.leftSub != size)
reportSubSizeMismatch(size, mCtx.leftSub);
(getT(args), ...);
}
// Optional version of getHNT
template <typename X>
void getHNOT(X& x, NAME name)
{
getHNOT(name, x);
}
template <class... Args>
bool getHNOT(NAME name, Args&... args)
{
if (isNextSub(name))
{
getHT(args...);
return true;
}
return false;
}
// Get data of a given type/size, including subrecord header
template <class... Args>
void getHT(Args&... args)
{
constexpr size_t size = (0 + ... + sizeof(Args));
getSubHeader();
if (mCtx.leftSub != size)
reportSubSizeMismatch(size, mCtx.leftSub);
(getT(args), ...);
}
void getNamedComposite(NAME name, auto& value)
{
decompose(value, [&](auto&... args) { getHNT(name, args...); });
}
bool getOptionalComposite(NAME name, auto& value)
{
if (isNextSub(name))
{
getSubComposite(value);
return true;
}
return false;
}
void getComposite(auto& value)
{
decompose(value, [&](auto&... args) { (getT(args), ...); });
}
void getSubComposite(auto& value)
{
decompose(value, [&](auto&... args) { getHT(args...); });
}
template <typename T, typename = std::enable_if_t<IsReadable<T>>>
void skipHT()
{
constexpr size_t size = sizeof(T);
getSubHeader();
if (mCtx.leftSub != size)
reportSubSizeMismatch(size, mCtx.leftSub);
skip(size);
}
// Read a string by the given name if it is the next record.
std::string getHNOString(NAME name);
ESM::RefId getHNORefId(NAME name);
void skipHNORefId(NAME name);
// Read a string with the given sub-record name
std::string getHNString(NAME name);
RefId getHNRefId(NAME name);
// Read a string, including the sub-record header (but not the name)
std::string getHString();
std::string_view getHStringView();
RefId getRefId();
void skipHString();
void skipHRefId();
ESM::FormId getFormId(bool wide = false, NAME tag = "FRMR");
/*************************************************************************
*
* Low level sub-record methods
*
*************************************************************************/
// Get the next subrecord name and check if it matches the parameter
void getSubNameIs(NAME name);
/** Checks if the next sub record name matches the parameter. If it
does, it is read into 'subName' just as if getSubName() was
called. If not, the read name will still be available for future
calls to getSubName(), isNextSub() and getSubNameIs().
*/
bool isNextSub(NAME name);
bool peekNextSub(NAME name);
// Store the current subrecord name for the next call of getSubName()
void cacheSubName() { mCtx.subCached = true; }
// Read subrecord name. This gets called a LOT, so I've optimized it
// slightly.
void getSubName();
// Skip current sub record, including header (but not including
// name.)
void skipHSub();
// Skip sub record and check its size
void skipHSubSize(std::size_t size);
// Skip all subrecords until the given subrecord or no more subrecords remaining
void skipHSubUntil(NAME name);
/* Sub-record header. This updates leftRec beyond the current
sub-record as well. leftSub contains size of current sub-record.
*/
void getSubHeader();
/*************************************************************************
*
* Low level record methods
*
*************************************************************************/
// Get the next record name
NAME getRecName();
// Skip the rest of this record. Assumes the name and header have
// already been read
void skipRecord();
/* Read record header. This updatesleftFile BEYOND the data that
follows the header, ie beyond the entire record. You should use
leftRec to orient yourself inside the record itself.
*/
void getRecHeader() { getRecHeader(mRecordFlags); }
void getRecHeader(uint32_t& flags);
bool hasMoreRecs() const { return mCtx.leftFile > 0; }
bool hasMoreSubs() const { return mCtx.leftRec > 0; }
/*************************************************************************
*
* Lowest level data reading and misc methods
*
*************************************************************************/
template <typename X, typename = std::enable_if_t<IsReadable<X>>>
void getT(X& x)
{
getExact(&x, sizeof(X));
}
template <typename T, typename = std::enable_if_t<IsReadable<T>>>
void skipT()
{
skip(sizeof(T));
}
void getExact(void* x, std::size_t size)
{
mEsm->read(static_cast<char*>(x), static_cast<std::streamsize>(size));
}
void getName(NAME& name) { getT(name.mData); }
void getUint(uint32_t& u) { getT(u); }
std::string getMaybeFixedStringSize(std::size_t size);
RefId getMaybeFixedRefIdSize(std::size_t size);
// Read the next 'size' bytes and return them as a string. Converts
// them from native encoding to UTF8 in the process.
std::string_view getStringView(std::size_t size);
RefId getRefId(std::size_t size);
void skip(std::size_t bytes)
{
char buffer[4096];
if (bytes > std::size(buffer))
mEsm->seekg(getFileOffset() + bytes);
else
mEsm->read(buffer, bytes);
}
/// Used for error handling
[[noreturn]] void fail(std::string_view msg);
/// Sets font encoder for ESM strings
void setEncoder(ToUTF8::Utf8Encoder* encoder) { mEncoder = encoder; }
/// Get record flags of last record
uint32_t getRecordFlags() { return mRecordFlags; }
size_t getFileSize() const { return mFileSize; }
private:
[[noreturn]] void reportSubSizeMismatch(size_t want, size_t got)
{
fail("record size mismatch, requested " + std::to_string(want) + ", got " + std::to_string(got));
}
void clearCtx();
RefId getRefIdImpl(std::size_t size);
std::unique_ptr<std::istream> mEsm;
ESM_Context mCtx;
uint32_t mRecordFlags;
// Special file signifier (see SpecialFile enum above)
// Buffer for ESM strings
std::vector<char> mBuffer;
Header mHeader;
ToUTF8::Utf8Encoder* mEncoder;
size_t mFileSize;
const std::map<int, int>* mContentFileMapping = nullptr;
};
}
#endif
| 12,797
|
C++
|
.h
| 304
| 32.746711
| 109
| 0.550621
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,810
|
debugprofile.hpp
|
OpenMW_openmw/components/esm3/debugprofile.hpp
|
#ifndef COMPONENTS_ESM_DEBUGPROFILE_H
#define COMPONENTS_ESM_DEBUGPROFILE_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct DebugProfile
{
constexpr static RecNameInts sRecordId = REC_DBGP;
static constexpr std::string_view getRecordType() { return "DebugProfile"; }
enum Flags
{
Flag_Default = 1, // add to newly opened scene subviews
Flag_BypassNewGame = 2, // bypass regular game startup
Flag_Global = 4 // make available from main menu (i.e. not location specific)
};
uint32_t mRecordFlags;
RefId mId;
std::string mDescription;
std::string mScriptText;
uint32_t mFlags;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
/// Set record to default state (does not touch the ID).
void blank();
};
}
#endif
| 1,037
|
C++
|
.h
| 31
| 26.612903
| 89
| 0.655589
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,811
|
loadligh.hpp
|
OpenMW_openmw/components/esm3/loadligh.hpp
|
#ifndef OPENMW_ESM_LIGH_H
#define OPENMW_ESM_LIGH_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Lights. Includes static light sources and also carryable candles
* and torches.
*/
struct Light
{
constexpr static RecNameInts sRecordId = REC_LIGH;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Light"; }
enum Flags
{
Dynamic = 0x001,
Carry = 0x002, // Can be carried
Negative = 0x004, // Negative light - i.e. darkness
Flicker = 0x008,
Fire = 0x010,
OffDefault
= 0x020, // Off by default - does not burn while placed in a cell, but can burn when equipped by an NPC
FlickerSlow = 0x040,
Pulse = 0x080,
PulseSlow = 0x100
};
struct LHDTstruct
{
float mWeight;
int32_t mValue;
int32_t mTime; // Duration
int32_t mRadius;
uint32_t mColor; // 4-byte rgba value
int32_t mFlags;
}; // Size = 24 bytes
LHDTstruct mData;
uint32_t mRecordFlags;
std::string mModel, mIcon, mName;
ESM::RefId mId, mSound, mScript;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 1,668
|
C++
|
.h
| 51
| 24.254902
| 115
| 0.590399
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
35,812
|
dialoguestate.hpp
|
OpenMW_openmw/components/esm3/dialoguestate.hpp
|
#ifndef OPENMW_ESM_DIALOGUESTATE_H
#define OPENMW_ESM_DIALOGUESTATE_H
#include <components/esm/refid.hpp>
#include <map>
#include <string>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct DialogueState
{
// must be lower case topic IDs
std::vector<ESM::RefId> mKnownTopics;
// must be lower case faction IDs
std::map<ESM::RefId, std::map<ESM::RefId, int>> mChangedFactionReaction;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 588
|
C++
|
.h
| 22
| 22.136364
| 80
| 0.685152
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,813
|
loadgmst.hpp
|
OpenMW_openmw/components/esm3/loadgmst.hpp
|
#ifndef OPENMW_ESM_GMST_H
#define OPENMW_ESM_GMST_H
#include <string>
#include "variant.hpp"
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Game setting
*
*/
struct GameSetting
{
constexpr static RecNameInts sRecordId = REC_GMST;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "GameSetting"; }
uint32_t mRecordFlags;
RefId mId;
Variant mValue;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
bool operator==(const GameSetting& left, const GameSetting& right);
}
#endif
| 917
|
C++
|
.h
| 30
| 25
| 108
| 0.670103
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,814
|
fogstate.hpp
|
OpenMW_openmw/components/esm3/fogstate.hpp
|
#ifndef OPENMW_ESM_FOGSTATE_H
#define OPENMW_ESM_FOGSTATE_H
#include <cstdint>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct FogTexture
{
int32_t mX, mY; // Only used for interior cells
std::vector<char> mImageData;
};
// format 0, saved games only
// Fog of war state
struct FogState
{
// Only used for interior cells
float mNorthMarkerAngle;
struct Bounds
{
float mMinX;
float mMinY;
float mMaxX;
float mMaxY;
} mBounds;
std::vector<FogTexture> mFogTextures;
void load(ESMReader& esm);
void save(ESMWriter& esm, bool interiorCell) const;
};
}
#endif
| 756
|
C++
|
.h
| 32
| 17.15625
| 59
| 0.610879
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
35,815
|
loadalch.hpp
|
OpenMW_openmw/components/esm3/loadalch.hpp
|
#ifndef OPENMW_ESM_ALCH_H
#define OPENMW_ESM_ALCH_H
#include <cstdint>
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "effectlist.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Alchemy item (potions)
*/
struct Potion
{
constexpr static RecNameInts sRecordId = REC_ALCH;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Potion"; }
enum Flags
{
Autocalc = 1 // Determines value
};
struct ALDTstruct
{
float mWeight;
int32_t mValue;
int32_t mFlags;
};
ALDTstruct mData;
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mName, mModel, mIcon;
EffectList mEffects;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 1,154
|
C++
|
.h
| 41
| 21.341463
| 108
| 0.620345
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,816
|
loadltex.hpp
|
OpenMW_openmw/components/esm3/loadltex.hpp
|
#ifndef OPENMW_ESM_LTEX_H
#define OPENMW_ESM_LTEX_H
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Texture used for texturing landscape.
* They are indexed by 'num', but still use 'id' to override base records.
* Original editor even does not allow to create new records with existing ID's.
* TODO: currently OpenMW-CS does not allow to override LTEX records at all.
*/
struct LandTexture
{
constexpr static RecNameInts sRecordId = REC_LTEX;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "LandTexture"; }
std::string mTexture;
RefId mId;
uint32_t mIndex;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
/// Sets the record to the default state. Does not touch the index. Does touch mID.
void blank();
};
}
#endif
| 1,106
|
C++
|
.h
| 30
| 31.233333
| 108
| 0.685741
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,817
|
globalscript.hpp
|
OpenMW_openmw/components/esm3/globalscript.hpp
|
#ifndef OPENMW_ESM_GLOBALSCRIPT_H
#define OPENMW_ESM_GLOBALSCRIPT_H
#include "cellref.hpp"
#include "components/esm/refid.hpp"
#include "locals.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/// \brief Storage structure for global script state (only used in saved games)
struct GlobalScript
{
RefId mId; /// \note must be lowercase
Locals mLocals;
bool mRunning;
RefId mTargetId; // for targeted scripts
RefNum mTargetRef;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 589
|
C++
|
.h
| 22
| 21.863636
| 83
| 0.688057
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,818
|
journalentry.hpp
|
OpenMW_openmw/components/esm3/journalentry.hpp
|
#ifndef OPENMW_ESM_JOURNALENTRY_H
#define OPENMW_ESM_JOURNALENTRY_H
#include <components/esm/refid.hpp>
#include <cstdint>
#include <string>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct JournalEntry
{
enum Type
{
Type_Journal = 0,
Type_Topic = 1,
Type_Quest = 2
};
int32_t mType;
ESM::RefId mTopic;
ESM::RefId mInfo;
std::string mText;
std::string mActorName; // Could also be Actor ID to allow switching of localisation, but since mText is
// plaintext anyway...
int32_t mDay; // time stamp
int32_t mMonth;
int32_t mDayOfMonth;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 847
|
C++
|
.h
| 32
| 19.09375
| 112
| 0.591078
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,819
|
loadcell.hpp
|
OpenMW_openmw/components/esm3/loadcell.hpp
|
#ifndef OPENMW_ESM_CELL_H
#define OPENMW_ESM_CELL_H
#include <list>
#include <string>
#include <vector>
#include "components/esm/defs.hpp"
#include "components/esm/esmcommon.hpp"
#include "components/esm/refid.hpp"
#include <components/misc/constants.hpp>
#include "cellref.hpp"
namespace MWWorld
{
class ESMStore;
}
namespace ESM
{
class ESMReader;
class ESMWriter;
/* Moved cell reference tracking object. This mainly stores the target cell
of the reference, so we can easily know where it has been moved when another
plugin tries to move it independently.
Unfortunately, we need to implement this here.
*/
class MovedCellRef
{
public:
RefNum mRefNum;
// Coordinates of target exterior cell
int32_t mTarget[2];
// The content file format does not support moving objects to an interior cell.
// The save game format does support moving to interior cells, but uses a different mechanism
// (see the MovedRefTracker implementation in MWWorld::CellStore for more details).
};
/// Overloaded compare operator used to search inside a list of cell refs.
bool operator==(const MovedCellRef& ref, const RefNum& refNum);
bool operator==(const CellRef& ref, const RefNum& refNum);
typedef std::list<MovedCellRef> MovedCellRefTracker;
typedef std::list<std::pair<CellRef, bool>> CellRefTracker;
struct CellRefTrackerPredicate
{
RefNum mRefNum;
CellRefTrackerPredicate(const RefNum& refNum)
: mRefNum(refNum)
{
}
bool operator()(const std::pair<CellRef, bool>& refdelPair) { return refdelPair.first == mRefNum; }
};
/* Cells hold data about objects, creatures, statics (rocks, walls,
buildings) and landscape (for exterior cells). Cells frequently
also has other associated LAND and PGRD records. Combined, all this
data can be huge, and we cannot load it all at startup. Instead,
the strategy we use is to remember the file position of each cell
(using ESMReader::getContext()) and jumping back into place
whenever we need to load a given cell.
*/
struct Cell
{
static const ESM::StringRefId sDefaultWorldspaceId;
constexpr static RecNameInts sRecordId = REC_CELL;
static constexpr int sSize = Constants::CellSizeInUnits;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Cell"; }
enum class GetNextRefMode
{
LoadAll,
LoadOnlyMoved,
LoadOnlyNotMoved,
};
enum Flags
{
Interior = 0x01, // Interior cell
HasWater = 0x02, // Does this cell have a water surface
NoSleep = 0x04, // Is it allowed to sleep here (without a bed)
QuasiEx = 0x80 // Behave like exterior (Tribunal+), with
// skybox and weather
};
struct DATAstruct
{
int32_t mFlags{ 0 };
int32_t mX{ 0 }, mY{ 0 };
};
struct AMBIstruct
{
Color mAmbient{ 0 }, mSunlight{ 0 }, mFog{ 0 };
float mFogDensity{ 0.f };
};
Cell()
: mName("")
, mRegion(ESM::RefId())
, mHasAmbi(true)
, mWater(0)
, mHasWaterHeightSub(false)
, mMapColor(0)
, mRefNumCounter(0)
{
}
ESM::RefId mId;
// Interior cells are indexed by this (it's the 'id'), for exterior
// cells it is optional.
std::string mName;
// Optional region name for exterior and quasi-exterior cells.
RefId mRegion;
std::vector<ESM_Context> mContextList; // File position; multiple positions for multiple plugin support
DATAstruct mData;
AMBIstruct mAmbi;
bool mHasAmbi;
float mWater; // Water level
bool mHasWaterHeightSub;
int32_t mMapColor;
// Counter for RefNums. This is only used during content file editing and has no impact on gameplay.
// It prevents overwriting previous refNums, even if they were deleted.
// as that would collide with refs when a content file is upgraded.
int32_t mRefNumCounter;
// References "leased" from another cell (i.e. a different cell
// introduced this ref, and it has been moved here by a plugin)
CellRefTracker mLeasedRefs;
MovedCellRefTracker mMovedRefs;
void postLoad(ESMReader& esm);
// This method is left in for compatibility with esmtool. Parsing moved references currently requires
// passing ESMStore, bit it does not know about this parameter, so we do it this way.
void load(ESMReader& esm, bool& isDeleted, bool saveContext = true); // Load everything (except references)
void loadNameAndData(ESMReader& esm, bool& isDeleted); // Load NAME and DATAstruct
void loadCell(
ESMReader& esm, bool saveContext = true); // Load everything, except NAME, DATAstruct and references
void save(ESMWriter& esm, bool isDeleted = false) const;
void saveTempMarker(ESMWriter& esm, int32_t tempCount) const;
bool isExterior() const { return !(mData.mFlags & Interior); }
int32_t getGridX() const { return mData.mX; }
int32_t getGridY() const { return mData.mY; }
bool hasWater() const { return ((mData.mFlags & HasWater) != 0) || isExterior(); }
void setHasWaterHeightSub(bool hasWater) { mHasWaterHeightSub = hasWater; }
bool hasAmbient() const { return mHasAmbi; }
void setHasAmbient(bool hasAmbi) { mHasAmbi = hasAmbi; }
// Restore the given reader to the stored position. Will try to open
// the file matching the stored file name. If you want to read from
// somewhere other than the file system, you need to pre-open the
// ESMReader, and the filename must match the stored filename
// exactly.
void restore(ESMReader& esm, size_t iCtx) const;
std::string getDescription() const;
///< Return a short string describing the cell (mostly used for debugging/logging purpose)
/* Get the next reference in this cell, if any. Returns false when
there are no more references in the cell.
All fields of the CellRef struct are overwritten. You can safely
reuse one memory location without blanking it between calls.
*/
static bool getNextRef(ESMReader& esm, CellRef& ref, bool& deleted);
static bool getNextRef(ESMReader& esm, CellRef& cellRef, bool& deleted, MovedCellRef& movedCellRef, bool& moved,
GetNextRefMode mode = GetNextRefMode::LoadAll);
/* This fetches an MVRF record, which is used to track moved references.
* Since they are comparably rare, we use a separate method for this.
*/
static bool getNextMVRF(ESMReader& esm, MovedCellRef& mref);
void blank();
///< Set record to default state (does not touch the ID/index).
const ESM::RefId& updateId();
static ESM::RefId generateIdForCell(bool exterior, std::string_view cellName, int x, int y);
};
}
#endif
| 7,412
|
C++
|
.h
| 160
| 37.68125
| 120
| 0.654871
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,820
|
filter.hpp
|
OpenMW_openmw/components/esm3/filter.hpp
|
#ifndef COMPONENTS_ESM_FILTER_H
#define COMPONENTS_ESM_FILTER_H
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include <string>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct Filter
{
constexpr static RecNameInts sRecordId = REC_FILT;
static constexpr std::string_view getRecordType() { return "Filter"; }
uint32_t mRecordFlags;
RefId mId;
std::string mDescription;
std::string mFilter;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 718
|
C++
|
.h
| 24
| 24.291667
| 78
| 0.674963
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,821
|
custommarkerstate.hpp
|
OpenMW_openmw/components/esm3/custommarkerstate.hpp
|
#ifndef OPENMW_ESM_CUSTOMMARKERSTATE_H
#define OPENMW_ESM_CUSTOMMARKERSTATE_H
#include <components/esm/refid.hpp>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct CustomMarker
{
float mWorldX;
float mWorldY;
RefId mCell;
std::string mNote;
bool operator==(const CustomMarker& other) const
{
return mNote == other.mNote && mCell == other.mCell && mWorldX == other.mWorldX && mWorldY == other.mWorldY;
}
void load(ESMReader& reader);
void save(ESMWriter& writer) const;
};
}
#endif
| 635
|
C++
|
.h
| 23
| 21.521739
| 120
| 0.646766
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,822
|
creaturestate.hpp
|
OpenMW_openmw/components/esm3/creaturestate.hpp
|
#ifndef OPENMW_ESM_CREATURESTATE_H
#define OPENMW_ESM_CREATURESTATE_H
#include "creaturestats.hpp"
#include "inventorystate.hpp"
#include "objectstate.hpp"
namespace ESM
{
// format 0, saved games only
struct CreatureState final : public ObjectState
{
InventoryState mInventory;
CreatureStats mCreatureStats;
/// Initialize to default state
void blank() override;
void load(ESMReader& esm) override;
void save(ESMWriter& esm, bool inInventory = false) const override;
CreatureState& asCreatureState() override { return *this; }
const CreatureState& asCreatureState() const override { return *this; }
};
}
#endif
| 699
|
C++
|
.h
| 21
| 28.142857
| 79
| 0.71535
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,823
|
loadpgrd.hpp
|
OpenMW_openmw/components/esm3/loadpgrd.hpp
|
#ifndef OPENMW_ESM_PGRD_H
#define OPENMW_ESM_PGRD_H
#include <string>
#include <vector>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Path grid.
*/
struct Pathgrid
{
constexpr static RecNameInts sRecordId = REC_PGRD;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Pathgrid"; }
struct DATAstruct
{
int32_t mX, mY; // Grid location, matches cell for exterior cells
int16_t mGranularity; // Granularity with which the graph was autogenerated
uint16_t mPoints; // Number of path points.
}; // 12 bytes
struct Point // path grid point
{
int32_t mX, mY, mZ; // Location of point
unsigned char mAutogenerated; // autogenerated vs. user coloring flag?
unsigned char mConnectionNum; // number of connections for this point
Point& operator=(const float[3]);
Point(const float[3]);
Point();
Point(int x, int y, int z)
: mX(x)
, mY(y)
, mZ(z)
, mAutogenerated(0)
, mConnectionNum(0)
{
}
}; // 16 bytes
struct Edge // path grid edge
{
size_t mV0, mV1; // index of points connected with this edge
};
ESM::RefId mCell; // Cell name
DATAstruct mData;
typedef std::vector<Point> PointList;
PointList mPoints;
typedef std::vector<Edge> EdgeList;
EdgeList mEdges;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
};
}
#endif
| 1,908
|
C++
|
.h
| 57
| 24.54386
| 108
| 0.581927
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,824
|
npcstate.hpp
|
OpenMW_openmw/components/esm3/npcstate.hpp
|
#ifndef OPENMW_ESM_NPCSTATE_H
#define OPENMW_ESM_NPCSTATE_H
#include "creaturestats.hpp"
#include "inventorystate.hpp"
#include "npcstats.hpp"
#include "objectstate.hpp"
namespace ESM
{
// format 0, saved games only
struct NpcState final : public ObjectState
{
InventoryState mInventory;
NpcStats mNpcStats;
CreatureStats mCreatureStats;
/// Initialize to default state
void blank() override;
void load(ESMReader& esm) override;
void save(ESMWriter& esm, bool inInventory = false) const override;
NpcState& asNpcState() override { return *this; }
const NpcState& asNpcState() const override { return *this; }
};
}
#endif
| 716
|
C++
|
.h
| 23
| 26
| 75
| 0.699708
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
35,825
|
loadregn.hpp
|
OpenMW_openmw/components/esm3/loadregn.hpp
|
#ifndef OPENMW_ESM_REGN_H
#define OPENMW_ESM_REGN_H
#include <array>
#include <string>
#include <vector>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Region data
*/
struct Region
{
constexpr static RecNameInts sRecordId = REC_REGN;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Region"; }
struct WEATstruct
{
// These are probabilities that add up to 100
// Clear, Cloudy, Foggy, Overcast, Rain, Thunder, Ash, Blight, Snow, Blizzard
std::array<uint8_t, 10> mProbabilities;
}; // 10 bytes
// Reference to a sound that is played randomly in this region
struct SoundRef
{
ESM::RefId mSound;
uint8_t mChance;
};
WEATstruct mData;
int32_t mMapColor; // RGBA
uint32_t mRecordFlags;
// sleepList refers to a leveled list of creatures you can meet if
// you sleep outside in this region.
RefId mId, mSleepList;
std::string mName;
std::vector<SoundRef> mSoundList;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID/index).
};
}
#endif
| 1,517
|
C++
|
.h
| 46
| 25.804348
| 108
| 0.630748
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,826
|
mappings.hpp
|
OpenMW_openmw/components/esm3/mappings.hpp
|
#ifndef OPENMW_ESM_MAPPINGS_H
#define OPENMW_ESM_MAPPINGS_H
#include <string>
#include <components/esm3/loadarmo.hpp>
#include <components/esm3/loadbody.hpp>
namespace ESM
{
BodyPart::MeshPart getMeshPart(PartReferenceType type);
std::string getBoneName(PartReferenceType type);
std::string getMeshFilter(PartReferenceType type);
}
#endif
| 355
|
C++
|
.h
| 12
| 27.25
| 59
| 0.80826
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,827
|
loadbody.hpp
|
OpenMW_openmw/components/esm3/loadbody.hpp
|
#ifndef OPENMW_ESM_BODY_H
#define OPENMW_ESM_BODY_H
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include <cstdint>
#include <string>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct BodyPart
{
constexpr static RecNameInts sRecordId = REC_BODY;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "BodyPart"; }
enum MeshPart
{
MP_Head = 0,
MP_Hair = 1,
MP_Neck = 2,
MP_Chest = 3,
MP_Groin = 4,
MP_Hand = 5,
MP_Wrist = 6,
MP_Forearm = 7,
MP_Upperarm = 8,
MP_Foot = 9,
MP_Ankle = 10,
MP_Knee = 11,
MP_Upperleg = 12,
MP_Clavicle = 13,
MP_Tail = 14,
MP_Count = 15
};
enum Flags
{
BPF_Female = 1,
BPF_NotPlayable = 2
};
enum MeshType
{
MT_Skin = 0,
MT_Clothing = 1,
MT_Armor = 2
};
struct BYDTstruct
{
unsigned char mPart; // mesh part
unsigned char mVampire; // boolean
unsigned char mFlags;
unsigned char mType; // mesh type
};
BYDTstruct mData;
uint32_t mRecordFlags;
RefId mId, mRace;
std::string mModel;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
bool isFirstPersonBodyPart(const BodyPart& value);
}
#endif
| 1,795
|
C++
|
.h
| 64
| 18.875
| 108
| 0.530303
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
35,828
|
cellref.hpp
|
OpenMW_openmw/components/esm3/cellref.hpp
|
#ifndef OPENMW_ESM_CELLREF_H
#define OPENMW_ESM_CELLREF_H
#include <cstdint>
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/position.hpp>
#include <components/esm/refid.hpp>
#include "refnum.hpp"
namespace ESM
{
class ESMWriter;
class ESMReader;
/* Cell reference. This represents ONE object (of many) inside the
cell. The cell references are not loaded as part of the normal
loading process, but are rather loaded later on demand when we are
setting up a specific cell.
*/
class CellRef
{
public:
static constexpr std::string_view getRecordType() { return "CellRef"; }
// Reference number
// Note: Currently unused for items in containers
RefNum mRefNum;
ESM::RefId mRefID; // ID of object being referenced
float mScale; // Scale applied to mesh
// The NPC that owns this object (and will get angry if you steal it)
ESM::RefId mOwner;
// Name of a global variable. If the global variable is set to '1', using the object is temporarily allowed
// even if it has an Owner field.
// Used by bed rent scripts to allow the player to use the bed for the duration of the rent.
std::string mGlobalVariable;
// ID of creature trapped in this soul gem
ESM::RefId mSoul;
// The faction that owns this object (and will get angry if
// you take it and are not a faction member)
ESM::RefId mFaction;
// PC faction rank required to use the item. Sometimes is -1, which means "any rank".
int32_t mFactionRank;
// For weapon or armor, this is the remaining item health.
// For tools (lockpicks, probes, repair hammer) it is the remaining uses.
// For lights it is remaining time.
// This could be -1 if the charge was not touched yet (i.e. full).
union
{
int32_t mChargeInt; // Used by everything except lights
float mChargeFloat; // Used only by lights
};
float mChargeIntRemainder; // Fractional part of mChargeInt
// Remaining enchantment charge. This could be -1 if the charge was not touched yet (i.e. full).
float mEnchantmentCharge;
int32_t mCount;
// For doors - true if this door teleports to somewhere else, false
// if it should open through animation.
bool mTeleport;
// Teleport location for the door, if this is a teleporting door.
Position mDoorDest;
// Destination cell for doors (optional)
std::string mDestCell;
// Lock level for doors and containers
int32_t mLockLevel;
bool mIsLocked{};
ESM::RefId mKey, mTrap; // Key and trap ID names, if any
// This corresponds to the "Reference Blocked" checkbox in the construction set,
// which prevents editing that reference.
// -1 is not blocked, otherwise it is blocked.
signed char mReferenceBlocked;
// Position and rotation of this object within the cell
Position mPos;
/// Calls loadId and loadData
void load(ESMReader& esm, bool& isDeleted, bool wideRefNum = false);
void loadId(ESMReader& esm, bool wideRefNum = false);
/// Implicitly called by load
void loadData(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool wideRefNum = false, bool inInventory = false, bool isDeleted = false) const;
void blank();
};
void skipLoadCellRef(ESMReader& esm, bool wideRefNum = false);
CellRef makeBlankCellRef();
}
#endif
| 3,646
|
C++
|
.h
| 81
| 37.358025
| 115
| 0.665818
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,829
|
projectilestate.hpp
|
OpenMW_openmw/components/esm3/projectilestate.hpp
|
#ifndef OPENMW_ESM_PROJECTILESTATE_H
#define OPENMW_ESM_PROJECTILESTATE_H
#include <osg/Quat>
#include <osg/Vec3f>
#include "components/esm/quaternion.hpp"
#include "components/esm/refid.hpp"
#include "components/esm/vector3.hpp"
#include "refnum.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, savegames only
struct BaseProjectileState
{
RefId mId;
Vector3 mPosition;
Quaternion mOrientation;
int32_t mActorId;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct MagicBoltState : public BaseProjectileState
{
RefId mSpellId;
float mSpeed;
RefNum mItem;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct ProjectileState : public BaseProjectileState
{
RefId mBowId;
Vector3 mVelocity;
float mAttackStrength;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 1,028
|
C++
|
.h
| 40
| 19.925
| 55
| 0.674203
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,830
|
formatversion.hpp
|
OpenMW_openmw/components/esm3/formatversion.hpp
|
#ifndef OPENMW_COMPONENTS_ESM3_FORMATVERSION_H
#define OPENMW_COMPONENTS_ESM3_FORMATVERSION_H
#include <cstdint>
namespace ESM
{
using FormatVersion = std::uint32_t;
inline constexpr FormatVersion DefaultFormatVersion = 0;
inline constexpr FormatVersion CurrentContentFormatVersion = 1;
inline constexpr FormatVersion MaxOldGoldValueFormatVersion = 5;
inline constexpr FormatVersion MaxOldFogOfWarFormatVersion = 6;
inline constexpr FormatVersion MaxUnoptimizedCharacterDataFormatVersion = 7;
inline constexpr FormatVersion MaxOldTimeLeftFormatVersion = 8;
inline constexpr FormatVersion MaxIntFallbackFormatVersion = 10;
inline constexpr FormatVersion MaxOldRestockingFormatVersion = 14;
inline constexpr FormatVersion MaxClearModifiersFormatVersion = 16;
inline constexpr FormatVersion MaxOldAiPackageFormatVersion = 17;
inline constexpr FormatVersion MaxOldSkillsAndAttributesFormatVersion = 18;
inline constexpr FormatVersion MaxOldCreatureStatsFormatVersion = 19;
inline constexpr FormatVersion MaxLimitedSizeStringsFormatVersion = 22;
inline constexpr FormatVersion MaxStringRefIdFormatVersion = 23;
inline constexpr FormatVersion MaxSavedGameCellNameAsRefIdFormatVersion = 24;
inline constexpr FormatVersion MaxNameIsRefIdOnlyFormatVersion = 25;
inline constexpr FormatVersion MaxUseEsmCellIdFormatVersion = 26;
inline constexpr FormatVersion MaxActiveSpellSlotIndexFormatVersion = 27;
inline constexpr FormatVersion MaxOldCountFormatVersion = 30;
inline constexpr FormatVersion MaxActiveSpellTypeVersion = 31;
inline constexpr FormatVersion MaxPlayerBeforeCellDataFormatVersion = 32;
inline constexpr FormatVersion CurrentSaveGameFormatVersion = 33;
inline constexpr FormatVersion MinSupportedSaveGameFormatVersion = 5;
inline constexpr FormatVersion OpenMW0_48SaveGameFormatVersion = 21;
inline constexpr FormatVersion OpenMW0_49SaveGameFormatVersion = CurrentSaveGameFormatVersion;
}
#endif
| 2,010
|
C++
|
.h
| 33
| 56.606061
| 98
| 0.843306
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,831
|
player.hpp
|
OpenMW_openmw/components/esm3/player.hpp
|
#ifndef OPENMW_ESM_PLAYER_H
#define OPENMW_ESM_PLAYER_H
#include <string>
#include <components/esm/attr.hpp>
#include <components/esm/position.hpp>
#include "loadskil.hpp"
#include "npcstate.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct Player
{
NpcState mObject;
RefId mCellId;
float mLastKnownExteriorPosition[3];
unsigned char mHasMark;
bool mSetWerewolfAcrobatics;
Position mMarkedPosition;
RefId mMarkedCell;
ESM::RefId mBirthsign;
int32_t mCurrentCrimeId;
int32_t mPaidCrimeId;
float mSaveAttributes[Attribute::Length];
float mSaveSkills[Skill::Length];
std::map<ESM::RefId, ESM::RefId> mPreviousItems; // previous equipped items, needed for bound spells
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 934
|
C++
|
.h
| 32
| 23.34375
| 108
| 0.689113
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,832
|
loadacti.hpp
|
OpenMW_openmw/components/esm3/loadacti.hpp
|
#ifndef OPENMW_ESM_ACTI_H
#define OPENMW_ESM_ACTI_H
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include <cstdint>
#include <string>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct Activator
{
constexpr static RecNameInts sRecordId = REC_ACTI;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Activator"; }
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mName, mModel;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif
| 810
|
C++
|
.h
| 25
| 27
| 108
| 0.68129
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,833
|
controlsstate.hpp
|
OpenMW_openmw/components/esm3/controlsstate.hpp
|
#ifndef OPENMW_ESM_CONTROLSSTATE_H
#define OPENMW_ESM_CONTROLSSTATE_H
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct ControlsState
{
ControlsState();
enum Flags
{
ViewSwitchDisabled = 0x1,
ControlsDisabled = 0x4,
JumpingDisabled = 0x1000,
LookingDisabled = 0x2000,
VanityModeDisabled = 0x4000,
WeaponDrawingDisabled = 0x8000,
SpellDrawingDisabled = 0x10000
};
bool mViewSwitchDisabled;
bool mControlsDisabled;
bool mJumpingDisabled;
bool mLookingDisabled;
bool mVanityModeDisabled;
bool mWeaponDrawingDisabled;
bool mSpellDrawingDisabled;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 870
|
C++
|
.h
| 32
| 19.34375
| 43
| 0.635379
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,834
|
weatherstate.hpp
|
OpenMW_openmw/components/esm3/weatherstate.hpp
|
#ifndef OPENMW_ESM_WEATHERSTATE_H
#define OPENMW_ESM_WEATHERSTATE_H
#include <components/esm/refid.hpp>
#include <map>
#include <string>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
struct RegionWeatherState
{
int32_t mWeather;
std::vector<uint8_t> mChances;
};
struct WeatherState
{
ESM::RefId mCurrentRegion;
float mTimePassed;
bool mFastForward;
float mWeatherUpdateTime;
float mTransitionFactor;
int32_t mCurrentWeather;
int32_t mNextWeather;
int32_t mQueuedWeather;
std::map<ESM::RefId, RegionWeatherState> mRegions;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 759
|
C++
|
.h
| 31
| 18.903226
| 58
| 0.674515
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,835
|
creaturestats.hpp
|
OpenMW_openmw/components/esm3/creaturestats.hpp
|
#ifndef OPENMW_ESM_CREATURESTATS_H
#define OPENMW_ESM_CREATURESTATS_H
#include <array>
#include <map>
#include <string>
#include <vector>
#include "statstate.hpp"
#include "components/esm/defs.hpp"
#include "activespells.hpp"
#include "aisequence.hpp"
#include "components/esm/attr.hpp"
#include "components/esm/refid.hpp"
#include "magiceffects.hpp"
#include "spellstate.hpp"
#include "timestamp.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct CreatureStats
{
struct CorprusStats
{
std::array<int32_t, Attribute::Length> mWorsenings;
TimeStamp mNextWorsening;
};
std::array<StatState<float>, Attribute::Length> mAttributes;
std::array<StatState<float>, 3> mDynamic;
MagicEffects mMagicEffects;
AiSequence::AiSequence mAiSequence;
bool mHasAiSettings;
std::array<StatState<int>, 4> mAiSettings;
std::map<SummonKey, int> mSummonedCreatureMap;
std::multimap<int, int> mSummonedCreatures;
std::vector<int> mSummonGraveyard;
TimeStamp mTradeTime;
int32_t mGoldPool;
int32_t mActorId;
enum Flags
{
Dead = 0x0001,
DeathAnimationFinished = 0x0002,
Died = 0x0004,
Murdered = 0x0008,
TalkedTo = 0x0010,
Alarmed = 0x0020,
Attacked = 0x0040,
Knockdown = 0x0080,
KnockdownOneFrame = 0x0100,
KnockdownOverOneFrame = 0x0200,
HitRecovery = 0x0400,
Block = 0x0800,
RecalcDynamicStats = 0x1000
};
bool mDead;
bool mDeathAnimationFinished;
bool mDied;
bool mMurdered;
bool mTalkedTo;
bool mAlarmed;
bool mAttacked;
bool mKnockdown;
bool mKnockdownOneFrame;
bool mKnockdownOverOneFrame;
bool mHitRecovery;
bool mBlock;
uint32_t mMovementFlags;
float mFallHeight;
ESM::RefId mLastHitObject;
ESM::RefId mLastHitAttemptObject;
bool mRecalcDynamicStats;
int32_t mDrawState;
int8_t mDeathAnimation;
TimeStamp mTimeOfDeath;
int32_t mLevel;
bool mMissingACDT;
std::map<ESM::RefId, CorprusStats> mCorprusSpells;
SpellState mSpells;
ActiveSpells mActiveSpells;
/// Initialize to default state
void blank();
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 2,592
|
C++
|
.h
| 87
| 21.931034
| 68
| 0.634646
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,836
|
queststate.hpp
|
OpenMW_openmw/components/esm3/queststate.hpp
|
#ifndef OPENMW_ESM_QUESTSTATE_H
#define OPENMW_ESM_QUESTSTATE_H
#include <components/esm/refid.hpp>
#include <string>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct QuestState
{
ESM::RefId mTopic; // lower case id
int32_t mState;
unsigned char mFinished;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
}
#endif
| 437
|
C++
|
.h
| 19
| 18.315789
| 43
| 0.674757
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,837
|
loadfact.hpp
|
OpenMW_openmw/components/esm3/loadfact.hpp
|
#ifndef OPENMW_ESM_FACT_H
#define OPENMW_ESM_FACT_H
#include <array>
#include <map>
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Faction definitions
*/
// Requirements for each rank
struct RankData
{
int32_t mAttribute1, mAttribute2; // Attribute level
// Skill level (faction skills given in
// skillID below.) You need one skill at
// level 'mPrimarySkill' and two skills at level
// 'mFavouredSkill' to advance to this rank.
int32_t mPrimarySkill, mFavouredSkill;
int32_t mFactReaction; // Reaction from faction members
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct Faction
{
constexpr static RecNameInts sRecordId = REC_FACT;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Faction"; }
uint32_t mRecordFlags;
std::string mName;
RefId mId;
struct FADTstruct
{
// Which attributes we like
std::array<int32_t, 2> mAttribute;
std::array<RankData, 10> mRankData;
std::array<int32_t, 7> mSkills; // IDs of skills this faction require
// Each element will either contain an Skill index, or -1.
int32_t mIsHidden; // 1 - hidden from player
int32_t& getSkill(size_t index, bool ignored = false);
///< Throws an exception for invalid values of \a index.
int32_t getSkill(size_t index, bool ignored = false) const;
///< Throws an exception for invalid values of \a index.
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
}; // 240 bytes
FADTstruct mData;
// <Faction ID, Reaction>
std::map<ESM::RefId, int32_t> mReactions;
// Name of faction ranks (may be empty for NPC factions)
std::array<std::string, 10> mRanks;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID/index).
};
}
#endif
| 2,403
|
C++
|
.h
| 62
| 30.241935
| 108
| 0.620199
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,838
|
loadclas.hpp
|
OpenMW_openmw/components/esm3/loadclas.hpp
|
#ifndef OPENMW_ESM_CLAS_H
#define OPENMW_ESM_CLAS_H
#include <array>
#include <cstdint>
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
/*
* Character class definitions
*/
struct Class
{
constexpr static RecNameInts sRecordId = REC_CLAS;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Class"; }
enum Specialization
{
Combat = 0,
Magic = 1,
Stealth = 2
};
static const std::string_view sGmstSpecializationIds[3];
static const std::array<std::string_view, 3> specializationIndexToLuaId;
struct CLDTstruct
{
std::array<int32_t, 2> mAttribute; // Attributes that get class bonus
int32_t mSpecialization; // 0 = Combat, 1 = Magic, 2 = Stealth
std::array<std::array<int32_t, 2>, 5> mSkills; // Minor and major skills.
int32_t mIsPlayable; // 0x0001 - Playable class
int32_t mServices;
int32_t& getSkill(int index, bool major);
///< Throws an exception for invalid values of \a index.
int32_t getSkill(int index, bool major) const;
///< Throws an exception for invalid values of \a index.
}; // 60 bytes
uint32_t mRecordFlags;
std::string mName, mDescription;
RefId mId;
CLDTstruct mData;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID/index).
};
}
#endif
| 1,812
|
C++
|
.h
| 50
| 28.36
| 108
| 0.622426
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,839
|
refnum.hpp
|
OpenMW_openmw/components/esm3/refnum.hpp
|
#ifndef OPENMW_COMPONENTS_ESM3_REFNUM_H
#define OPENMW_COMPONENTS_ESM3_REFNUM_H
#include <components/esm/formid.hpp>
namespace ESM
{
using RefNum = ESM::FormId;
}
#endif
| 177
|
C++
|
.h
| 8
| 20.25
| 39
| 0.795181
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,840
|
loadbsgn.hpp
|
OpenMW_openmw/components/esm3/loadbsgn.hpp
|
#ifndef OPENMW_ESM_BSGN_H
#define OPENMW_ESM_BSGN_H
#include <cstdint>
#include <string>
#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"
#include "spelllist.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
struct BirthSign
{
constexpr static RecNameInts sRecordId = REC_BSGN;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "BirthSign"; }
uint32_t mRecordFlags;
RefId mId;
std::string mName, mDescription, mTexture;
// List of powers and abilities that come with this birth sign.
SpellList mPowers;
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;
void blank();
///< Set record to default state (does not touch the ID/index).
};
}
#endif
| 947
|
C++
|
.h
| 28
| 28.321429
| 108
| 0.686469
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
35,841
|
doorstate.hpp
|
OpenMW_openmw/components/esm3/doorstate.hpp
|
#ifndef OPENMW_ESM_DOORSTATE_H
#define OPENMW_ESM_DOORSTATE_H
#include "objectstate.hpp"
namespace ESM
{
// format 0, saved games only
struct DoorState final : public ObjectState
{
int32_t mDoorState = 0;
void load(ESMReader& esm) override;
void save(ESMWriter& esm, bool inInventory = false) const override;
DoorState& asDoorState() override { return *this; }
const DoorState& asDoorState() const override { return *this; }
};
}
#endif
| 499
|
C++
|
.h
| 16
| 26.3125
| 75
| 0.691824
|
OpenMW/openmw
| 5,318
| 933
| 0
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.