mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 21:51:17 +02:00
Added more debugging and option to disable new streflop usage.
This commit is contained in:
@@ -13,8 +13,7 @@
|
||||
#ifndef _SHARED_GRAPHICS_VEC_H_
|
||||
#define _SHARED_GRAPHICS_VEC_H_
|
||||
|
||||
#include "streflop_cond.h"
|
||||
//#include <cmath>
|
||||
#include "math_wrapper.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
@@ -127,7 +126,11 @@ public:
|
||||
}
|
||||
|
||||
float length() const{
|
||||
#ifdef USE_STREFLOP
|
||||
return static_cast<float>(streflop::sqrt(static_cast<float>(x*x + y*y)));
|
||||
#else
|
||||
return static_cast<float>(sqrt(static_cast<float>(x*x + y*y)));
|
||||
#endif
|
||||
}
|
||||
|
||||
void normalize(){
|
||||
@@ -266,7 +269,11 @@ public:
|
||||
}
|
||||
|
||||
float length() const{
|
||||
#ifdef USE_STREFLOP
|
||||
return static_cast<float>(streflop::sqrt(x*x + y*y + z*z));
|
||||
#else
|
||||
return static_cast<float>(sqrt(x*x + y*y + z*z));
|
||||
#endif
|
||||
}
|
||||
|
||||
void normalize(){
|
||||
|
@@ -108,15 +108,15 @@ private:
|
||||
int lastMouseX[3];
|
||||
int lastMouseY[3];
|
||||
|
||||
static int64 lastMouseEvent; /** for use in mouse hover calculations */
|
||||
static unsigned int lastMouseEvent; /** for use in mouse hover calculations */
|
||||
static MouseState mouseState;
|
||||
static Vec2i mousePos;
|
||||
static bool isKeyPressedDown;
|
||||
static bool isFullScreen;
|
||||
static SDL_keysym keystate;
|
||||
|
||||
static void setLastMouseEvent(int64 lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
||||
static int64 getLastMouseEvent() {return Window::lastMouseEvent;}
|
||||
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
||||
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
|
||||
|
||||
static const MouseState &getMouseState() {return Window::mouseState;}
|
||||
static void setMouseState(MouseButton b, bool state) {Window::mouseState.set(b, state);}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@@ -15,10 +15,10 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include "thread.h"
|
||||
//#include "thread.h"
|
||||
|
||||
using std::string;
|
||||
using namespace Shared::Platform;
|
||||
//using namespace Shared::Platform;
|
||||
|
||||
namespace Shared{ namespace Util{
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
this->fileStream = NULL;
|
||||
this->debugLogFileName = "";
|
||||
this->fileStreamOwner = false;
|
||||
this->mutex = NULL;
|
||||
//this->mutex = NULL;
|
||||
}
|
||||
SystemFlagsType(DebugType debugType) {
|
||||
this->debugType = debugType;
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
this->fileStream = NULL;
|
||||
this->debugLogFileName = "";
|
||||
this->fileStreamOwner = false;
|
||||
this->mutex = NULL;
|
||||
//this->mutex = NULL;
|
||||
}
|
||||
SystemFlagsType(DebugType debugType,bool enabled,
|
||||
std::ofstream *fileStream,std::string debugLogFileName) {
|
||||
@@ -62,14 +62,14 @@ public:
|
||||
this->fileStream = fileStream;
|
||||
this->debugLogFileName = debugLogFileName;
|
||||
this->fileStreamOwner = false;
|
||||
this->mutex = mutex;
|
||||
//this->mutex = mutex;
|
||||
}
|
||||
|
||||
bool enabled;
|
||||
std::ofstream *fileStream;
|
||||
std::string debugLogFileName;
|
||||
bool fileStreamOwner;
|
||||
Mutex *mutex;
|
||||
//Mutex *mutex;
|
||||
};
|
||||
|
||||
protected:
|
||||
@@ -122,6 +122,7 @@ template<typename T>
|
||||
void deleteMapValues(T beginIt, T endIt){
|
||||
for(T it= beginIt; it!=endIt; ++it){
|
||||
delete it->second;
|
||||
it->second = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "streflop_cond.h"
|
||||
#include "math_wrapper.h"
|
||||
#include "particle.h"
|
||||
|
||||
#include <cassert>
|
||||
@@ -263,12 +263,21 @@ void FireParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
ParticleSystem::initParticle(p, particleIndex);
|
||||
|
||||
float ang= random.randRange(-2.0f*pi, 2.0f*pi);
|
||||
#ifdef USE_STREFLOP
|
||||
float mod= streflop::fabsf(random.randRange(-radius, radius));
|
||||
|
||||
float x= streflop::sinf(ang)*mod;
|
||||
float y= streflop::cosf(ang)*mod;
|
||||
|
||||
float radRatio= streflop::sqrtf(streflop::sqrtf(mod/radius));
|
||||
#else
|
||||
float mod= fabsf(random.randRange(-radius, radius));
|
||||
|
||||
float x= sinf(ang)*mod;
|
||||
float y= cosf(ang)*mod;
|
||||
|
||||
float radRatio= sqrtf(sqrtf(mod/radius));
|
||||
#endif
|
||||
|
||||
p->color= colorNoEnergy*0.5f + colorNoEnergy*0.5f*radRatio;
|
||||
p->energy= static_cast<int>(maxParticleEnergy*radRatio) + random.randRange(-varParticleEnergy, varParticleEnergy);
|
||||
@@ -301,9 +310,15 @@ void FireParticleSystem::setRadius(float radius){
|
||||
}
|
||||
|
||||
void FireParticleSystem::setWind(float windAngle, float windSpeed){
|
||||
#ifdef USE_STREFLOP
|
||||
this->windSpeed.x= streflop::sinf(degToRad(windAngle))*windSpeed;
|
||||
this->windSpeed.y= 0.0f;
|
||||
this->windSpeed.z= streflop::cosf(degToRad(windAngle))*windSpeed;
|
||||
#else
|
||||
this->windSpeed.x= sinf(degToRad(windAngle))*windSpeed;
|
||||
this->windSpeed.y= 0.0f;
|
||||
this->windSpeed.z= cosf(degToRad(windAngle))*windSpeed;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -366,12 +381,21 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
ParticleSystem::initParticle(p, particleIndex);
|
||||
|
||||
float ang= random.randRange(-2.0f*pi, 2.0f*pi);
|
||||
#ifdef USE_STREFLOP
|
||||
float mod= streflop::fabsf(random.randRange(-radius, radius));
|
||||
|
||||
float x= streflop::sinf(ang)*mod;
|
||||
float y= streflop::cosf(ang)*mod;
|
||||
|
||||
float radRatio= streflop::sqrtf(streflop::sqrtf(mod/radius));
|
||||
#else
|
||||
float mod= fabsf(random.randRange(-radius, radius));
|
||||
|
||||
float x= sinf(ang)*mod;
|
||||
float y= cosf(ang)*mod;
|
||||
|
||||
float radRatio= sqrtf(sqrtf(mod/radius));
|
||||
#endif
|
||||
|
||||
//p->color= color*0.5f + color*0.5f*radRatio;
|
||||
p->color=color;
|
||||
@@ -393,10 +417,18 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
else
|
||||
{// rotate it according to rotation
|
||||
float rad=degToRad(rotation);
|
||||
#ifdef USE_STREFLOP
|
||||
p->pos= Vec3f(pos.x+x+offset.z*streflop::sinf(rad)+offset.x*streflop::cosf(rad), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*streflop::cosf(rad)-offset.x*streflop::sinf(rad)));
|
||||
if(relativeDirection){
|
||||
p->speed=Vec3f(p->speed.z*streflop::sinf(rad)+p->speed.x*streflop::cosf(rad),p->speed.y,(p->speed.z*streflop::cosf(rad)-p->speed.x*streflop::sinf(rad)));
|
||||
}
|
||||
#else
|
||||
p->pos= Vec3f(pos.x+x+offset.z*sinf(rad)+offset.x*cosf(rad), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*cosf(rad)-offset.x*sinf(rad)));
|
||||
if(relativeDirection){
|
||||
p->speed=Vec3f(p->speed.z*sinf(rad)+p->speed.x*cosf(rad),p->speed.y,(p->speed.z*cosf(rad)-p->speed.x*sinf(rad)));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,9 +481,15 @@ void UnitParticleSystem::setRadius(float radius){
|
||||
}
|
||||
|
||||
void UnitParticleSystem::setWind(float windAngle, float windSpeed){
|
||||
#ifdef USE_STREFLOP
|
||||
this->windSpeed.x= streflop::sinf(degToRad(windAngle))*windSpeed;
|
||||
this->windSpeed.y= 0.0f;
|
||||
this->windSpeed.z= streflop::cosf(degToRad(windAngle))*windSpeed;
|
||||
#else
|
||||
this->windSpeed.x= sinf(degToRad(windAngle))*windSpeed;
|
||||
this->windSpeed.y= 0.0f;
|
||||
this->windSpeed.z= cosf(degToRad(windAngle))*windSpeed;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -499,9 +537,15 @@ void RainParticleSystem::setRadius(float radius){
|
||||
}
|
||||
|
||||
void RainParticleSystem::setWind(float windAngle, float windSpeed){
|
||||
#ifdef USE_STREFLOP
|
||||
this->windSpeed.x= streflop::sinf(degToRad(windAngle))*windSpeed;
|
||||
this->windSpeed.y= 0.0f;
|
||||
this->windSpeed.z= streflop::cosf(degToRad(windAngle))*windSpeed;
|
||||
#else
|
||||
this->windSpeed.x= sinf(degToRad(windAngle))*windSpeed;
|
||||
this->windSpeed.y= 0.0f;
|
||||
this->windSpeed.z= cosf(degToRad(windAngle))*windSpeed;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -543,9 +587,15 @@ void SnowParticleSystem::setRadius(float radius){
|
||||
}
|
||||
|
||||
void SnowParticleSystem::setWind(float windAngle, float windSpeed){
|
||||
#ifdef USE_STREFLOP
|
||||
this->windSpeed.x= streflop::sinf(degToRad(windAngle))*windSpeed;
|
||||
this->windSpeed.y= 0.0f;
|
||||
this->windSpeed.z= streflop::cosf(degToRad(windAngle))*windSpeed;
|
||||
#else
|
||||
this->windSpeed.x= sinf(degToRad(windAngle))*windSpeed;
|
||||
this->windSpeed.y= 0.0f;
|
||||
this->windSpeed.z= cosf(degToRad(windAngle))*windSpeed;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -655,8 +705,13 @@ void ProjectileParticleSystem::update(){
|
||||
case tSpiral:
|
||||
{
|
||||
pos= flatPos;
|
||||
#ifdef USE_STREFLOP
|
||||
pos+= xVector * streflop::cos(t*trajectoryFrequency*targetVector.length())*trajectoryScale;
|
||||
pos+= yVector * streflop::sin(t*trajectoryFrequency*targetVector.length())*trajectoryScale;
|
||||
#else
|
||||
pos+= xVector * cos(t*trajectoryFrequency*targetVector.length())*trajectoryScale;
|
||||
pos+= yVector * sin(t*trajectoryFrequency*targetVector.length())*trajectoryScale;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "streflop_cond.h"
|
||||
#include "math_wrapper.h"
|
||||
#include "pixmap.h"
|
||||
|
||||
#include <stdexcept>
|
||||
@@ -655,12 +655,19 @@ void Pixmap2D::splat(const Pixmap2D *leftUp, const Pixmap2D *rightUp, const Pixm
|
||||
float distRd= splatDist(Vec2i(i, j), Vec2i(w, h));
|
||||
|
||||
const float powFactor= 2.0f;
|
||||
#ifdef USE_STREFLOP
|
||||
distLu= streflop::pow(distLu, powFactor);
|
||||
distRu= streflop::pow(distRu, powFactor);
|
||||
distLd= streflop::pow(distLd, powFactor);
|
||||
distRd= streflop::pow(distRd, powFactor);
|
||||
avg= streflop::pow(avg, powFactor);
|
||||
|
||||
#else
|
||||
distLu= pow(distLu, powFactor);
|
||||
distRu= pow(distRu, powFactor);
|
||||
distLd= pow(distLd, powFactor);
|
||||
distRd= pow(distRd, powFactor);
|
||||
avg= pow(avg, powFactor);
|
||||
#endif
|
||||
float lu= distLu>avg? 0: ((avg-distLu))*random.randRange(0.5f, 1.0f);
|
||||
float ru= distRu>avg? 0: ((avg-distRu))*random.randRange(0.5f, 1.0f);
|
||||
float ld= distLd>avg? 0: ((avg-distLd))*random.randRange(0.5f, 1.0f);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "streflop_cond.h"
|
||||
#include "math_wrapper.h"
|
||||
#include "quaternion.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
@@ -67,15 +67,23 @@ void Quaternion::setAddIdentity(){
|
||||
}
|
||||
|
||||
void Quaternion::setAxisAngle(const AxisAngle &axisAngle){
|
||||
#ifdef USE_STREFLOP
|
||||
w= streflop::cosf(axisAngle.angle/2.0f);
|
||||
v.x= axisAngle.axis.x * streflop::sinf(axisAngle.angle/2.0f);
|
||||
v.y= axisAngle.axis.y * streflop::sinf(axisAngle.angle/2.0f);
|
||||
v.z= axisAngle.axis.z * streflop::sinf(axisAngle.angle/2.0f);
|
||||
#else
|
||||
w= cosf(axisAngle.angle/2.0f);
|
||||
v.x= axisAngle.axis.x * sinf(axisAngle.angle/2.0f);
|
||||
v.y= axisAngle.axis.y * sinf(axisAngle.angle/2.0f);
|
||||
v.z= axisAngle.axis.z * sinf(axisAngle.angle/2.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
||||
Quaternion qx, qy, qz, qr;
|
||||
|
||||
#ifdef USE_STREFLOP
|
||||
qx.w= streflop::cosf(eulerAngles.x/2.0f);
|
||||
qx.v= Vec3f(streflop::sinf(eulerAngles.x/2.0f), 0.0f, 0.0f);
|
||||
|
||||
@@ -84,6 +92,16 @@ void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
||||
|
||||
qz.w= streflop::cosf(eulerAngles.z/2.0f);
|
||||
qz.v= Vec3f(0.0f, 0.0f, streflop::sinf(eulerAngles.z/2.0f));
|
||||
#else
|
||||
qx.w= cosf(eulerAngles.x/2.0f);
|
||||
qx.v= Vec3f(sinf(eulerAngles.x/2.0f), 0.0f, 0.0f);
|
||||
|
||||
qy.w= cosf(eulerAngles.y/2.0f);
|
||||
qy.v= Vec3f(0.0f, sinf(eulerAngles.y/2.0f), 0.0f);
|
||||
|
||||
qz.w= cosf(eulerAngles.z/2.0f);
|
||||
qz.v= Vec3f(0.0f, 0.0f, sinf(eulerAngles.z/2.0f));
|
||||
#endif
|
||||
|
||||
qr= qx*qy*qz;
|
||||
|
||||
@@ -92,7 +110,11 @@ void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
||||
}
|
||||
|
||||
float Quaternion::length(){
|
||||
#ifdef USE_STREFLOP
|
||||
return streflop::sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z);
|
||||
#else
|
||||
return sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z);
|
||||
#endif
|
||||
}
|
||||
|
||||
Quaternion Quaternion::conjugate(){
|
||||
@@ -184,7 +206,11 @@ Matrix4f Quaternion::toMatrix4() const{
|
||||
|
||||
AxisAngle Quaternion::toAxisAngle() const{
|
||||
float scale= 1.0f/(v.x*v.x + v.y*v.y + v.z*v.z);
|
||||
#ifdef USE_STREFLOP
|
||||
return AxisAngle(v*scale, 2*streflop::acosf(w));
|
||||
#else
|
||||
return AxisAngle(v*scale, 2*acosf(w));
|
||||
#endif
|
||||
}
|
||||
|
||||
Vec3f Quaternion::getLocalXAxis() const{
|
||||
|
192
source/shared_lib/sources/lua/lua_script.cpp
Normal file
192
source/shared_lib/sources/lua/lua_script.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "lua_script.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "conversion.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Shared::Util;
|
||||
|
||||
namespace Shared{ namespace Lua{
|
||||
|
||||
// =====================================================
|
||||
// class LuaScript
|
||||
// =====================================================
|
||||
|
||||
LuaScript::LuaScript(){
|
||||
luaState= luaL_newstate();
|
||||
|
||||
luaL_openlibs(luaState);
|
||||
|
||||
if(luaState==NULL){
|
||||
throw runtime_error("Can not allocate lua state");
|
||||
}
|
||||
|
||||
argumentCount= -1;
|
||||
}
|
||||
|
||||
LuaScript::~LuaScript(){
|
||||
lua_close(luaState);
|
||||
}
|
||||
|
||||
void LuaScript::loadCode(const string &code, const string &name){
|
||||
|
||||
int errorCode= luaL_loadbuffer(luaState, code.c_str(), code.size(), name.c_str());
|
||||
if(errorCode!=0){
|
||||
throw runtime_error("Error loading lua code: " + errorToString(errorCode));
|
||||
}
|
||||
|
||||
//run code
|
||||
errorCode= lua_pcall(luaState, 0, 0, 0)!=0;
|
||||
if(errorCode!=0){
|
||||
throw runtime_error("Error initializing lua: " + errorToString(errorCode));
|
||||
}
|
||||
}
|
||||
|
||||
void LuaScript::beginCall(const string& functionName){
|
||||
lua_getglobal(luaState, functionName.c_str());
|
||||
argumentCount= 0;
|
||||
}
|
||||
|
||||
void LuaScript::endCall(){
|
||||
lua_pcall(luaState, argumentCount, 0, 0);
|
||||
}
|
||||
|
||||
void LuaScript::registerFunction(LuaFunction luaFunction, const string &functionName){
|
||||
lua_pushcfunction(luaState, luaFunction);
|
||||
lua_setglobal(luaState, functionName.c_str());
|
||||
}
|
||||
|
||||
string LuaScript::errorToString(int errorCode){
|
||||
|
||||
string error;
|
||||
|
||||
switch(errorCode){
|
||||
case LUA_ERRSYNTAX:
|
||||
error+= "Syntax error";
|
||||
break;
|
||||
case LUA_ERRRUN:
|
||||
error+= "Runtime error";
|
||||
break;
|
||||
case LUA_ERRMEM:
|
||||
error+= "Memory allocation error";
|
||||
break;
|
||||
case LUA_ERRERR:
|
||||
error+= "Error while running the error handler";
|
||||
break;
|
||||
default:
|
||||
error+= "Unknown error";
|
||||
}
|
||||
|
||||
error += string(": ")+luaL_checkstring(luaState, -1);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class LuaArguments
|
||||
// =====================================================
|
||||
|
||||
LuaArguments::LuaArguments(lua_State *luaState){
|
||||
this->luaState= luaState;
|
||||
returnCount= 0;
|
||||
}
|
||||
|
||||
int LuaArguments::getInt(int argumentIndex) const{
|
||||
if(!lua_isnumber(luaState, argumentIndex)){
|
||||
throwLuaError("Can not get int from Lua state");
|
||||
}
|
||||
return luaL_checkint(luaState, argumentIndex);
|
||||
}
|
||||
|
||||
string LuaArguments::getString(int argumentIndex) const{
|
||||
if(!lua_isstring(luaState, argumentIndex)){
|
||||
throwLuaError("Can not get string from Lua state");
|
||||
}
|
||||
return luaL_checkstring(luaState, argumentIndex);
|
||||
}
|
||||
|
||||
Vec2i LuaArguments::getVec2i(int argumentIndex) const{
|
||||
Vec2i v;
|
||||
|
||||
if(!lua_istable(luaState, argumentIndex)){
|
||||
throwLuaError("Can not get vec2i from Lua state, value on the stack is not a table");
|
||||
}
|
||||
|
||||
if(luaL_getn(luaState, argumentIndex)!=2){
|
||||
throwLuaError("Can not get vec2i from Lua state, array size not 2");
|
||||
}
|
||||
|
||||
lua_rawgeti(luaState, argumentIndex, 1);
|
||||
v.x= luaL_checkint(luaState, argumentIndex);
|
||||
lua_pop(luaState, 1);
|
||||
|
||||
lua_rawgeti(luaState, argumentIndex, 2);
|
||||
v.y= luaL_checkint(luaState, argumentIndex);
|
||||
lua_pop(luaState, 1);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
void LuaArguments::returnInt(int value){
|
||||
++returnCount;
|
||||
lua_pushinteger(luaState, value);
|
||||
}
|
||||
|
||||
void LuaArguments::returnString(const string &value){
|
||||
++returnCount;
|
||||
lua_pushstring(luaState, value.c_str());
|
||||
}
|
||||
|
||||
void LuaArguments::returnVec2i(const Vec2i &value){
|
||||
++returnCount;
|
||||
|
||||
lua_newtable(luaState);
|
||||
|
||||
lua_pushnumber(luaState, value.x);
|
||||
lua_rawseti(luaState, -2, 1);
|
||||
|
||||
lua_pushnumber(luaState, value.y);
|
||||
lua_rawseti(luaState, -2, 2);
|
||||
}
|
||||
|
||||
void LuaArguments::throwLuaError(const string &message) const{
|
||||
string stackString;
|
||||
int stackSize = lua_gettop(luaState);
|
||||
|
||||
//build stack string
|
||||
for(int i= 1; i<=stackSize; ++i){
|
||||
stackString+= "-" + intToStr(i) + ": ";
|
||||
if(lua_isnumber(luaState, -i)){
|
||||
stackString+= "Number: " + doubleToStr(luaL_checknumber(luaState, -i ));
|
||||
}
|
||||
else if(lua_isstring(luaState, -i)){
|
||||
stackString+= "String: " + string(luaL_checkstring(luaState, -i));
|
||||
}
|
||||
else if(lua_istable(luaState, -i)){
|
||||
stackString+= "Table (" + intToStr(luaL_getn(luaState, -i)) + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
stackString+= "Unknown";
|
||||
}
|
||||
stackString+= "\n";
|
||||
}
|
||||
|
||||
throw runtime_error("Lua error: " + message + "\n\nLua Stack:\n" + stackString);
|
||||
}
|
||||
|
||||
}}//end namespace
|
@@ -29,6 +29,8 @@ int MessageBox(int handle, const char *msg, const char *title, int buttons) {
|
||||
int ret = system(cmd);
|
||||
//exit(0);
|
||||
//}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void message(string message) {
|
||||
|
@@ -41,7 +41,7 @@ namespace Shared{ namespace Platform{
|
||||
// Matze: hack for now...
|
||||
static Window* global_window = 0;
|
||||
static int oldX=0,oldY=0;
|
||||
int64 Window::lastMouseEvent = 0; /** for use in mouse hover calculations */
|
||||
unsigned int Window::lastMouseEvent = 0; /** for use in mouse hover calculations */
|
||||
Vec2i Window::mousePos;
|
||||
MouseState Window::mouseState;
|
||||
bool Window::isKeyPressedDown = false;
|
||||
|
@@ -13,7 +13,6 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
//#include "streflop.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
@@ -88,7 +88,7 @@ void SystemFlags::Close() {
|
||||
}
|
||||
currentDebugLog.fileStream = NULL;
|
||||
currentDebugLog.fileStreamOwner = false;
|
||||
currentDebugLog.mutex = NULL;
|
||||
//currentDebugLog.mutex = NULL;
|
||||
}
|
||||
|
||||
if(SystemFlags::lockFile != -1) {
|
||||
|
Reference in New Issue
Block a user