OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
spatialopcodes.hpp
Go to the documentation of this file.
1 #ifndef INTERPRETER_SPATIALOPCODES_H_INCLUDED
2 #define INTERPRETER_SPATIALOPCODES_H_INCLUDED
3 
4 #include "opcodes.hpp"
5 #include "runtime.hpp"
6 
7 namespace Interpreter
8 {
9  class OpGetDistance : public Opcode0
10  {
11  public:
12 
13  virtual void execute (Runtime& runtime)
14  {
15  std::string name = runtime.getStringLiteral (runtime[0].mInteger);
16 
17  Type_Float distance = runtime.getContext().getDistance (name);
18 
19  runtime[0].mFloat = distance;
20  }
21  };
22 
24  {
25  public:
26 
27  virtual void execute (Runtime& runtime)
28  {
29  int index = runtime[0].mInteger;
30  runtime.pop();
31  std::string id = runtime.getStringLiteral (index);
32 
33  std::string name = runtime.getStringLiteral (runtime[0].mInteger);
34 
35  Type_Float distance = runtime.getContext().getDistance (name, id);
36 
37  runtime[0].mFloat = distance;
38  }
39  };
40 }
41 
42 #endif
43 
void pop()
pop stack
Definition: runtime.cpp:94
std::string getStringLiteral(int index) const
Definition: runtime.cpp:34
virtual float getDistance(const std::string &name, const std::string &id="") const =0
Runtime data and engine interface.
Definition: runtime.hpp:15
opcode for 0 arguments
Definition: opcodes.hpp:9
Definition: spatialopcodes.hpp:9
Definition: spatialopcodes.hpp:23
float distance(const ESM::Pathgrid::Point &point, float x, float y, float z)
Definition: pathfinding.cpp:69
Context & getContext()
Definition: runtime.cpp:110
float Type_Float
Definition: types.hpp:16
virtual void execute(Runtime &runtime)
Definition: spatialopcodes.hpp:13
virtual void execute(Runtime &runtime)
Definition: spatialopcodes.hpp:27
const char * name
Definition: crashcatcher.cpp:59