|
|
@@ -4,9 +4,9 @@
|
|
|
*/
|
|
|
|
|
|
#include "lua_system.h"
|
|
|
-#include "lua.hpp"
|
|
|
#include "config.h"
|
|
|
#include "lua_stack.h"
|
|
|
+#include "lua_assert.h"
|
|
|
#include "assert.h"
|
|
|
#include "vector2.h"
|
|
|
#include "vector3.h"
|
|
|
@@ -18,6 +18,7 @@
|
|
|
#include "lua_environment.h"
|
|
|
#include "lua_stack.h"
|
|
|
#include "log.h"
|
|
|
+#include "lua.hpp"
|
|
|
|
|
|
namespace crown
|
|
|
{
|
|
|
@@ -152,20 +153,12 @@ namespace lua_globals
|
|
|
Vector3& v = stack.get_vector3(1);
|
|
|
const char* s = stack.get_string(2);
|
|
|
|
|
|
- if (strcmp(s, "x") == 0)
|
|
|
- {
|
|
|
- stack.push_float(v.x);
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else if (strcmp(s, "y") == 0)
|
|
|
+ switch (s[0])
|
|
|
{
|
|
|
- stack.push_float(v.y);
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else if (strcmp(s, "z") == 0)
|
|
|
- {
|
|
|
- stack.push_float(v.z);
|
|
|
- return 1;
|
|
|
+ case 'x': stack.push_float(v.x); return 1;
|
|
|
+ case 'y': stack.push_float(v.y); return 1;
|
|
|
+ case 'z': stack.push_float(v.z); return 1;
|
|
|
+ default: LUA_ASSERT(false, stack, "Bad index: '%c'", s[0]); break;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
@@ -178,9 +171,13 @@ namespace lua_globals
|
|
|
const char* s = stack.get_string(2);
|
|
|
const float value = stack.get_float(3);
|
|
|
|
|
|
- if (strcmp(s, "x") == 0) v.x = value;
|
|
|
- else if (strcmp(s, "y") == 0) v.y = value;
|
|
|
- else if (strcmp(s, "z") == 0) v.z = value;
|
|
|
+ switch (s[0])
|
|
|
+ {
|
|
|
+ case 'x': v.x = value; break;
|
|
|
+ case 'y': v.y = value; break;
|
|
|
+ case 'z': v.z = value; break;
|
|
|
+ default: LUA_ASSERT(false, stack, "Bad index: '%c'", s[0]); break;
|
|
|
+ }
|
|
|
|
|
|
return 0;
|
|
|
}
|