1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-09 18:40:14 +00:00
OpenMW/apps/openmw/mwscript/locals.hpp
fteppe 125b21de20 Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID

Slowly going through all the changes to make, still hundreds of errors

a lot of functions/structures use std::string or stringview to designate an ID. So it takes time

Continues slowly replacing ids. There are technically more and more compilation errors

I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type

Continue moving forward, changes to the stores

slowly moving along

Starting to see the fruit of those changes.

still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.

More replacements. Things are starting to get easier

I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.

Still moving forward, and for the first time error count is going down!

Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably

Cells are back to using string for the name, haven't fixed everything yet. Many other changes

Under the bar of 400 compilation errors.

more good progress <100 compile errors!

More progress

Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string

some more progress on other fronts

Mostly game settings clean

one error opened a lot of other errors. Down to 18, but more will prbably appear

only link errors left??

Fixed link errors

OpenMW compiles, and launches, with some issues, but still!
2022-12-27 19:15:54 +01:00

74 lines
2.2 KiB
C++

#ifndef GAME_SCRIPT_LOCALS_H
#define GAME_SCRIPT_LOCALS_H
#include <string>
#include <string_view>
#include <vector>
#include <components/interpreter/types.hpp>
namespace ESM
{
class Script;
struct Locals;
struct RefId;
}
namespace MWScript
{
class Locals
{
bool mInitialised;
void ensure(const ESM::RefId& scriptName);
public:
std::vector<Interpreter::Type_Short> mShorts;
std::vector<Interpreter::Type_Integer> mLongs;
std::vector<Interpreter::Type_Float> mFloats;
Locals();
/// Are there any locals?
///
/// \note Will return false, if locals have not been configured yet.
bool isEmpty() const;
/// \return Did the state of *this change from uninitialised to initialised?
bool configure(const ESM::Script& script);
/// @note var needs to be in lowercase
///
/// \note Locals will be automatically configured first, if necessary
bool setVarByInt(const ESM::RefId& script, std::string_view var, int val);
/// \note Locals will be automatically configured first, if necessary
//
// \note If it can not be determined if the variable exists, the error will be
// ignored and false will be returned.
bool hasVar(const ESM::RefId& script, std::string_view var);
/// if var does not exist, returns 0
/// @note var needs to be in lowercase
///
/// \note Locals will be automatically configured first, if necessary
int getIntVar(const ESM::RefId& script, std::string_view var);
/// if var does not exist, returns 0
/// @note var needs to be in lowercase
///
/// \note Locals will be automatically configured first, if necessary
float getFloatVar(ESM::RefId& script, std::string_view var);
/// \note If locals have not been configured yet, no data is written.
///
/// \return Locals written?
bool write(ESM::Locals& locals, const ESM::RefId& script) const;
/// \note Locals will be automatically configured first, if necessary
void read(const ESM::Locals& locals, const ESM::RefId& script);
};
}
#endif