- added a bit more lua and updated capture enemy flag
This commit is contained in:
parent
0180aa6bba
commit
e63e634e1e
|
@ -3725,6 +3725,20 @@ void Game::exitGameState(Program *program, Stats &endStats) {
|
||||||
|
|
||||||
// ==================== PRIVATE ====================
|
// ==================== PRIVATE ====================
|
||||||
|
|
||||||
|
void Game::highlightUnit(int unitId,float radius, float thickness, Vec4f color) {
|
||||||
|
HighlightSpecialUnitInfo info;
|
||||||
|
info.radius = radius;
|
||||||
|
info.thickness = thickness;
|
||||||
|
info.color = color;
|
||||||
|
unitHighlightList[unitId] = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::unhighlightUnit(int unitId) {
|
||||||
|
if(unitHighlightList.find(unitId) != unitHighlightList.end()) {
|
||||||
|
unitHighlightList.erase(unitId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== render ====================
|
// ==================== render ====================
|
||||||
|
|
||||||
void Game::render3d(){
|
void Game::render3d(){
|
||||||
|
@ -3781,6 +3795,8 @@ void Game::render3d(){
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderer.renderSpecialHighlightUnits(unitHighlightList);
|
||||||
|
|
||||||
// renderTeamColorCircle
|
// renderTeamColorCircle
|
||||||
renderer.renderMorphEffects();
|
renderer.renderMorphEffects();
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "game_settings.h"
|
#include "game_settings.h"
|
||||||
#include "network_interface.h"
|
#include "network_interface.h"
|
||||||
#include "data_types.h"
|
#include "data_types.h"
|
||||||
|
#include "selection.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
@ -193,6 +194,8 @@ private:
|
||||||
|
|
||||||
Unit *currentCameraFollowUnit;
|
Unit *currentCameraFollowUnit;
|
||||||
|
|
||||||
|
std::map<int,HighlightSpecialUnitInfo> unitHighlightList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game();
|
Game();
|
||||||
Game(Program *program, const GameSettings *gameSettings, bool masterserverMode);
|
Game(Program *program, const GameSettings *gameSettings, bool masterserverMode);
|
||||||
|
@ -304,6 +307,9 @@ public:
|
||||||
void removeCellMarker(Vec2i surfaceCellPos, const Faction *faction);
|
void removeCellMarker(Vec2i surfaceCellPos, const Faction *faction);
|
||||||
void showMarker(Vec2i cellPos, MarkedCell cellData);
|
void showMarker(Vec2i cellPos, MarkedCell cellData);
|
||||||
|
|
||||||
|
void highlightUnit(int unitId,float radius, float thickness, Vec4f color);
|
||||||
|
void unhighlightUnit(int unitId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//render
|
//render
|
||||||
void render3d();
|
void render3d();
|
||||||
|
|
|
@ -371,6 +371,9 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
||||||
|
|
||||||
luaScript.registerFunction(getHumanFactionId, "humanFaction");
|
luaScript.registerFunction(getHumanFactionId, "humanFaction");
|
||||||
|
|
||||||
|
luaScript.registerFunction(highlightUnit, "highlightUnit");
|
||||||
|
luaScript.registerFunction(unhighlightUnit, "unhighlightUnit");
|
||||||
|
|
||||||
//load code
|
//load code
|
||||||
for(int i= 0; i<scenario->getScriptCount(); ++i){
|
for(int i= 0; i<scenario->getScriptCount(); ++i){
|
||||||
const Script* script= scenario->getScript(i);
|
const Script* script= scenario->getScript(i);
|
||||||
|
@ -683,6 +686,19 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
{
|
{
|
||||||
if(movingUnit->getId() == event.sourceId) {
|
if(movingUnit->getId() == event.sourceId) {
|
||||||
bool srcInDst = false;
|
bool srcInDst = false;
|
||||||
|
|
||||||
|
// Cache area lookup so for each unitsize and pos its done only once
|
||||||
|
bool foundInCache = false;
|
||||||
|
std::map<int,std::map<Vec2i,bool> >::iterator iterFind1 = event.eventLookupCache.find(movingUnit->getType()->getSize());
|
||||||
|
if(iterFind1 != event.eventLookupCache.end()) {
|
||||||
|
std::map<Vec2i,bool>::iterator iterFind2 = iterFind1->second.find(movingUnit->getPos());
|
||||||
|
if(iterFind2 != iterFind1->second.end()) {
|
||||||
|
foundInCache = true;
|
||||||
|
srcInDst = iterFind2->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(foundInCache == false) {
|
||||||
for(int x = event.destPos.x; srcInDst == false && x <= event.destPosEnd.x; ++x) {
|
for(int x = event.destPos.x; srcInDst == false && x <= event.destPosEnd.x; ++x) {
|
||||||
for(int y = event.destPos.y; srcInDst == false && y <= event.destPosEnd.y; ++y) {
|
for(int y = event.destPos.y; srcInDst == false && y <= event.destPosEnd.y; ++y) {
|
||||||
srcInDst = world->getMap()->isInUnitTypeCells(movingUnit->getType(), Vec2i(x,y),movingUnit->getPos());
|
srcInDst = world->getMap()->isInUnitTypeCells(movingUnit->getType(), Vec2i(x,y),movingUnit->getPos());
|
||||||
|
@ -691,6 +707,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.eventLookupCache[movingUnit->getType()->getSize()][movingUnit->getPos()] = srcInDst;
|
||||||
|
}
|
||||||
|
|
||||||
if(srcInDst == true) {
|
if(srcInDst == true) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
@ -750,6 +769,19 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
//if(event.sourceId == 1) printf("ctet_FactionPos event.destPos = [%s], movingUnit->getPos() [%s] Unit id = %d\n",event.destPos.getString().c_str(),movingUnit->getPos().getString().c_str(),movingUnit->getId());
|
//if(event.sourceId == 1) printf("ctet_FactionPos event.destPos = [%s], movingUnit->getPos() [%s] Unit id = %d\n",event.destPos.getString().c_str(),movingUnit->getPos().getString().c_str(),movingUnit->getId());
|
||||||
|
|
||||||
bool srcInDst = false;
|
bool srcInDst = false;
|
||||||
|
|
||||||
|
// Cache area lookup so for each unitsize and pos its done only once
|
||||||
|
bool foundInCache = false;
|
||||||
|
std::map<int,std::map<Vec2i,bool> >::iterator iterFind1 = event.eventLookupCache.find(movingUnit->getType()->getSize());
|
||||||
|
if(iterFind1 != event.eventLookupCache.end()) {
|
||||||
|
std::map<Vec2i,bool>::iterator iterFind2 = iterFind1->second.find(movingUnit->getPos());
|
||||||
|
if(iterFind2 != iterFind1->second.end()) {
|
||||||
|
foundInCache = true;
|
||||||
|
srcInDst = iterFind2->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(foundInCache == false) {
|
||||||
for(int x = event.destPos.x; srcInDst == false && x <= event.destPosEnd.x; ++x) {
|
for(int x = event.destPos.x; srcInDst == false && x <= event.destPosEnd.x; ++x) {
|
||||||
for(int y = event.destPos.y; srcInDst == false && y <= event.destPosEnd.y; ++y) {
|
for(int y = event.destPos.y; srcInDst == false && y <= event.destPosEnd.y; ++y) {
|
||||||
|
|
||||||
|
@ -759,6 +791,10 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.eventLookupCache[movingUnit->getType()->getSize()][movingUnit->getPos()] = srcInDst;
|
||||||
|
}
|
||||||
|
|
||||||
triggerEvent = srcInDst;
|
triggerEvent = srcInDst;
|
||||||
if(triggerEvent == true) {
|
if(triggerEvent == true) {
|
||||||
//printf("!!!UNIT IN AREA!!! Faction area pos, moving unit faction= %d, trigger faction = %d, unit id = %d\n",movingUnit->getFactionIndex(),event.sourceId,movingUnit->getId());
|
//printf("!!!UNIT IN AREA!!! Faction area pos, moving unit faction= %d, trigger faction = %d, unit id = %d\n",movingUnit->getFactionIndex(),event.sourceId,movingUnit->getId());
|
||||||
|
@ -1680,6 +1716,20 @@ int ScriptManager::getHumanFactionId() {
|
||||||
return this->world->getThisFactionIndex();
|
return this->world->getThisFactionIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptManager::highlightUnit(int unitId, float radius, float thickness, Vec4f color) {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
|
||||||
|
world->highlightUnit(unitId, radius, thickness, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptManager::unhighlightUnit(int unitId) {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
|
||||||
|
world->unhighlightUnit(unitId);
|
||||||
|
}
|
||||||
|
|
||||||
// ========================== lua callbacks ===============================================
|
// ========================== lua callbacks ===============================================
|
||||||
|
|
||||||
int ScriptManager::showMessage(LuaHandle* luaHandle){
|
int ScriptManager::showMessage(LuaHandle* luaHandle){
|
||||||
|
@ -2659,6 +2709,18 @@ int ScriptManager::getHumanFactionId(LuaHandle* luaHandle) {
|
||||||
return luaArguments.getReturnCount();
|
return luaArguments.getReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::highlightUnit(LuaHandle* luaHandle) {
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
thisScriptManager->highlightUnit(luaArguments.getInt(-4), luaArguments.getFloat(-3), luaArguments.getFloat(-2), luaArguments.getVec4f(-1));
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScriptManager::unhighlightUnit(LuaHandle* luaHandle) {
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
thisScriptManager->unhighlightUnit(luaArguments.getInt(-1));
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptManager::saveGame(XmlNode *rootNode) {
|
void ScriptManager::saveGame(XmlNode *rootNode) {
|
||||||
std::map<string,string> mapTagReplacements;
|
std::map<string,string> mapTagReplacements;
|
||||||
XmlNode *scriptManagerNode = rootNode->addChild("ScriptManager");
|
XmlNode *scriptManagerNode = rootNode->addChild("ScriptManager");
|
||||||
|
|
|
@ -119,6 +119,8 @@ public:
|
||||||
|
|
||||||
std::map<int,string> eventStateInfo;
|
std::map<int,string> eventStateInfo;
|
||||||
|
|
||||||
|
std::map<int,std::map<Vec2i, bool> > eventLookupCache;
|
||||||
|
|
||||||
void saveGame(XmlNode *rootNode);
|
void saveGame(XmlNode *rootNode);
|
||||||
void loadGame(const XmlNode *rootNode);
|
void loadGame(const XmlNode *rootNode);
|
||||||
};
|
};
|
||||||
|
@ -367,6 +369,8 @@ private:
|
||||||
int isFreeCells(int unitSize, int field,Vec2i pos);
|
int isFreeCells(int unitSize, int field,Vec2i pos);
|
||||||
|
|
||||||
int getHumanFactionId();
|
int getHumanFactionId();
|
||||||
|
void highlightUnit(int unitId, float radius, float thickness, Vec4f color);
|
||||||
|
void unhighlightUnit(int unitId);
|
||||||
|
|
||||||
//callbacks, commands
|
//callbacks, commands
|
||||||
static int networkShowMessageForFaction(LuaHandle* luaHandle);
|
static int networkShowMessageForFaction(LuaHandle* luaHandle);
|
||||||
|
@ -503,6 +507,8 @@ private:
|
||||||
|
|
||||||
static int getHumanFactionId(LuaHandle* luaHandle);
|
static int getHumanFactionId(LuaHandle* luaHandle);
|
||||||
|
|
||||||
|
static int highlightUnit(LuaHandle* luaHandle);
|
||||||
|
static int unhighlightUnit(LuaHandle* luaHandle);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -4817,6 +4817,60 @@ void Renderer::renderTeamColorCircle(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::renderSpecialHighlightUnits(std::map<int,HighlightSpecialUnitInfo> unitHighlightList) {
|
||||||
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true || unitHighlightList.empty() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||||
|
if(qCache.visibleQuadUnitList.empty() == false) {
|
||||||
|
|
||||||
|
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glDepthFunc(GL_ALWAYS);
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glLineWidth(2.f);
|
||||||
|
|
||||||
|
for(int visibleUnitIndex = 0;
|
||||||
|
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
|
||||||
|
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
||||||
|
|
||||||
|
std::map<int,HighlightSpecialUnitInfo>::iterator iterFindSpecialUnit = unitHighlightList.find(unit->getId());
|
||||||
|
if(iterFindSpecialUnit != unitHighlightList.end()) {
|
||||||
|
Vec3f color=unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0);
|
||||||
|
float radius = 1.0f;
|
||||||
|
float thickness = 0.1f;
|
||||||
|
float alpha = 0.65f;
|
||||||
|
|
||||||
|
HighlightSpecialUnitInfo &specialInfo = iterFindSpecialUnit->second;
|
||||||
|
if(specialInfo.color.x >= 0) {
|
||||||
|
color.x = specialInfo.color.x;
|
||||||
|
color.y = specialInfo.color.y;
|
||||||
|
color.z = specialInfo.color.z;
|
||||||
|
}
|
||||||
|
if(specialInfo.color.w >= 0) {
|
||||||
|
alpha = specialInfo.color.w;
|
||||||
|
}
|
||||||
|
if(specialInfo.radius > 0) {
|
||||||
|
radius = specialInfo.radius;
|
||||||
|
}
|
||||||
|
if(specialInfo.thickness > 0) {
|
||||||
|
thickness = specialInfo.thickness;
|
||||||
|
}
|
||||||
|
|
||||||
|
glColor4f(color.x, color.y, color.z, alpha);
|
||||||
|
|
||||||
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
|
renderSelectionCircle(currVec, unit->getType()->getSize(), radius, thickness);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::renderTeamColorPlane(){
|
void Renderer::renderTeamColorPlane(){
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -559,6 +559,7 @@ public:
|
||||||
inline Quad2i getVisibleQuad() const {return visibleQuad;}
|
inline Quad2i getVisibleQuad() const {return visibleQuad;}
|
||||||
inline Quad2i getVisibleQuadFromCamera() const {return visibleQuadFromCamera;}
|
inline Quad2i getVisibleQuadFromCamera() const {return visibleQuadFromCamera;}
|
||||||
void renderTeamColorPlane();
|
void renderTeamColorPlane();
|
||||||
|
void renderSpecialHighlightUnits(std::map<int,HighlightSpecialUnitInfo> unitHighlightList);
|
||||||
void renderTeamColorCircle();
|
void renderTeamColorCircle();
|
||||||
void renderMorphEffects();
|
void renderMorphEffects();
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,13 @@ namespace Glest{ namespace Game{
|
||||||
class Gui;
|
class Gui;
|
||||||
class World;
|
class World;
|
||||||
|
|
||||||
|
class HighlightSpecialUnitInfo {
|
||||||
|
public:
|
||||||
|
float radius;
|
||||||
|
float thickness;
|
||||||
|
Vec4f color;
|
||||||
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Selection
|
// class Selection
|
||||||
//
|
//
|
||||||
|
|
|
@ -1367,6 +1367,23 @@ void World::showMarker(Vec2i pos, int factionIndex, const string ¬e, const st
|
||||||
game->showMarker(surfaceCellPos, mc);
|
game->showMarker(surfaceCellPos, mc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::highlightUnit(int unitId,float radius, float thickness, Vec4f color) {
|
||||||
|
Unit* unit= findUnitById(unitId);
|
||||||
|
if(unit == NULL) {
|
||||||
|
throw megaglest_runtime_error("Can not find unit to set highlight unitId = " + intToStr(unitId));
|
||||||
|
}
|
||||||
|
game->highlightUnit(unitId,radius, thickness, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::unhighlightUnit(int unitId) {
|
||||||
|
Unit* unit= findUnitById(unitId);
|
||||||
|
if(unit == NULL) {
|
||||||
|
throw megaglest_runtime_error("Can not find unit to set highlight unitId = " + intToStr(unitId));
|
||||||
|
}
|
||||||
|
game->unhighlightUnit(unitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int World::getUnitFactionIndex(int unitId) {
|
int World::getUnitFactionIndex(int unitId) {
|
||||||
Unit* unit= findUnitById(unitId);
|
Unit* unit= findUnitById(unitId);
|
||||||
if(unit == NULL) {
|
if(unit == NULL) {
|
||||||
|
|
|
@ -258,6 +258,9 @@ public:
|
||||||
const string getSystemMacroValue(const string key);
|
const string getSystemMacroValue(const string key);
|
||||||
const string getPlayerName(int factionIndex);
|
const string getPlayerName(int factionIndex);
|
||||||
|
|
||||||
|
void highlightUnit(int unitId,float radius, float thickness, Vec4f color);
|
||||||
|
void unhighlightUnit(int unitId);
|
||||||
|
|
||||||
inline Game * getGame() { return game; }
|
inline Game * getGame() { return game; }
|
||||||
const GameSettings * getGameSettings() const;
|
const GameSettings * getGameSettings() const;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@ using std::string;
|
||||||
|
|
||||||
using Shared::Graphics::Vec2i;
|
using Shared::Graphics::Vec2i;
|
||||||
using Shared::Graphics::Vec4i;
|
using Shared::Graphics::Vec4i;
|
||||||
|
using Shared::Graphics::Vec2f;
|
||||||
|
using Shared::Graphics::Vec3f;
|
||||||
|
using Shared::Graphics::Vec4f;
|
||||||
|
|
||||||
using Shared::Xml::XmlNode;
|
using Shared::Xml::XmlNode;
|
||||||
|
|
||||||
namespace Shared { namespace Lua {
|
namespace Shared { namespace Lua {
|
||||||
|
@ -87,6 +91,12 @@ public:
|
||||||
void * getGenericData(int argumentIndex) const;
|
void * getGenericData(int argumentIndex) const;
|
||||||
Vec2i getVec2i(int argumentIndex) const;
|
Vec2i getVec2i(int argumentIndex) const;
|
||||||
Vec4i getVec4i(int argumentIndex) const;
|
Vec4i getVec4i(int argumentIndex) const;
|
||||||
|
|
||||||
|
float getFloat(int argumentIndex) const;
|
||||||
|
Vec2f getVec2f(int argumentIndex) const;
|
||||||
|
Vec3f getVec3f(int argumentIndex) const;
|
||||||
|
Vec4f getVec4f(int argumentIndex) const;
|
||||||
|
|
||||||
int getReturnCount() const {return returnCount;}
|
int getReturnCount() const {return returnCount;}
|
||||||
|
|
||||||
void returnInt(int value);
|
void returnInt(int value);
|
||||||
|
|
|
@ -635,6 +635,159 @@ int LuaArguments::getInt(int argumentIndex) const{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float LuaArguments::getFloat(int argumentIndex) const {
|
||||||
|
Lua_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
|
||||||
|
if(!lua_isnumber(luaState, argumentIndex)) {
|
||||||
|
throwLuaError("Can not get int from Lua state");
|
||||||
|
}
|
||||||
|
float result = luaL_checknumber(luaState, argumentIndex);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Vec2f LuaArguments::getVec2f(int argumentIndex) const {
|
||||||
|
Lua_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
|
||||||
|
Vec2f v;
|
||||||
|
|
||||||
|
if(!lua_istable(luaState, argumentIndex)){
|
||||||
|
throwLuaError("Can not get vec2f from Lua state, value on the stack is not a table");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LUA_VERSION_NUM > 501
|
||||||
|
if(lua_rawlen(luaState, argumentIndex)!=2){
|
||||||
|
#else
|
||||||
|
if(luaL_getn(luaState, argumentIndex)!=2){
|
||||||
|
#endif
|
||||||
|
throwLuaError("Can not get vec2f from Lua state, array size not 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
//string stackString = getStackText();
|
||||||
|
//printf("Lua Stack:\n%s\n",stackString.c_str());
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 1);
|
||||||
|
//printf("xa = %s argumentIndex = %d\n",lua_tostring(luaState, argumentIndex),argumentIndex);
|
||||||
|
|
||||||
|
//v.x= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.x= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
//printf("X = %d\n",v.x);
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 2);
|
||||||
|
//printf("ya = %s\n",lua_tostring(luaState, argumentIndex));
|
||||||
|
|
||||||
|
//v.y= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.y= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
//printf("Y = %d\n",v.y);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3f LuaArguments::getVec3f(int argumentIndex) const {
|
||||||
|
Lua_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
|
||||||
|
Vec3f v;
|
||||||
|
|
||||||
|
if(!lua_istable(luaState, argumentIndex)){
|
||||||
|
throwLuaError("Can not get vec3f from Lua state, value on the stack is not a table");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LUA_VERSION_NUM > 501
|
||||||
|
if(lua_rawlen(luaState, argumentIndex)!=3){
|
||||||
|
#else
|
||||||
|
if(luaL_getn(luaState, argumentIndex)!=3){
|
||||||
|
#endif
|
||||||
|
throwLuaError("Can not get vec3f from Lua state, array size not 3");
|
||||||
|
}
|
||||||
|
|
||||||
|
//string stackString = getStackText();
|
||||||
|
//printf("Lua Stack:\n%s\n",stackString.c_str());
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 1);
|
||||||
|
//printf("xa = %s argumentIndex = %d\n",lua_tostring(luaState, argumentIndex),argumentIndex);
|
||||||
|
|
||||||
|
//v.x= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.x= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
//printf("X = %d\n",v.x);
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 2);
|
||||||
|
//printf("ya = %s\n",lua_tostring(luaState, argumentIndex));
|
||||||
|
|
||||||
|
//v.y= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.y= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
//printf("Y = %d\n",v.y);
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 3);
|
||||||
|
//printf("ya = %s\n",lua_tostring(luaState, argumentIndex));
|
||||||
|
|
||||||
|
//v.y= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.z= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec4f LuaArguments::getVec4f(int argumentIndex) const {
|
||||||
|
Lua_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
|
||||||
|
Vec4f v;
|
||||||
|
|
||||||
|
if(!lua_istable(luaState, argumentIndex)){
|
||||||
|
throwLuaError("Can not get vec4f from Lua state, value on the stack is not a table");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LUA_VERSION_NUM > 501
|
||||||
|
if(lua_rawlen(luaState, argumentIndex)!=4){
|
||||||
|
#else
|
||||||
|
if(luaL_getn(luaState, argumentIndex)!=4){
|
||||||
|
#endif
|
||||||
|
throwLuaError("Can not get vec4f from Lua state, array size not 4");
|
||||||
|
}
|
||||||
|
|
||||||
|
//string stackString = getStackText();
|
||||||
|
//printf("Lua Stack:\n%s\n",stackString.c_str());
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 1);
|
||||||
|
//printf("xa = %s argumentIndex = %d\n",lua_tostring(luaState, argumentIndex),argumentIndex);
|
||||||
|
|
||||||
|
//v.x= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.x= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
//printf("X = %d\n",v.x);
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 2);
|
||||||
|
//printf("ya = %s\n",lua_tostring(luaState, argumentIndex));
|
||||||
|
|
||||||
|
//v.y= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.y= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
//printf("Y = %d\n",v.y);
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 3);
|
||||||
|
//printf("ya = %s\n",lua_tostring(luaState, argumentIndex));
|
||||||
|
|
||||||
|
//v.y= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.z= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
lua_rawgeti(luaState, argumentIndex, 4);
|
||||||
|
//printf("ya = %s\n",lua_tostring(luaState, argumentIndex));
|
||||||
|
|
||||||
|
//v.y= luaL_checkint(luaState, argumentIndex);
|
||||||
|
v.w= lua_tonumber(luaState, argumentIndex);
|
||||||
|
lua_pop(luaState, 1);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
string LuaArguments::getString(int argumentIndex) const{
|
string LuaArguments::getString(int argumentIndex) const{
|
||||||
Lua_STREFLOP_Wrapper streflopWrapper;
|
Lua_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user