mirror of
https://github.com/glest/glest-source.git
synced 2025-08-30 19:29:47 +02:00
- added new LUA method getFactionPlayerType
This commit is contained in:
@@ -393,6 +393,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
|||||||
luaScript.registerFunction(storeSaveGameData, "storeSaveGameData");
|
luaScript.registerFunction(storeSaveGameData, "storeSaveGameData");
|
||||||
luaScript.registerFunction(loadSaveGameData, "loadSaveGameData");
|
luaScript.registerFunction(loadSaveGameData, "loadSaveGameData");
|
||||||
|
|
||||||
|
luaScript.registerFunction(getFactionPlayerType, "getFactionPlayerType");
|
||||||
|
|
||||||
//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);
|
||||||
@@ -1999,6 +2001,13 @@ string ScriptManager::loadSaveGameData(string name) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ControlType ScriptManager::getFactionPlayerType(int factionIndex) {
|
||||||
|
Faction *faction = world->getFaction(factionIndex);
|
||||||
|
if(faction != NULL) {
|
||||||
|
return faction->getControlType();
|
||||||
|
}
|
||||||
|
return ctClosed;
|
||||||
|
}
|
||||||
// ========================== lua callbacks ===============================================
|
// ========================== lua callbacks ===============================================
|
||||||
|
|
||||||
int ScriptManager::showMessage(LuaHandle* luaHandle){
|
int ScriptManager::showMessage(LuaHandle* luaHandle){
|
||||||
@@ -4892,6 +4901,26 @@ int ScriptManager::loadSaveGameData(LuaHandle* luaHandle) {
|
|||||||
return luaArguments.getReturnCount();
|
return luaArguments.getReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::getFactionPlayerType(LuaHandle* luaHandle) {
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
try {
|
||||||
|
luaArguments.returnInt(thisScriptManager->getFactionPlayerType(luaArguments.getInt(-1)));
|
||||||
|
}
|
||||||
|
catch(const megaglest_runtime_error &ex) {
|
||||||
|
char szErrBuf[8096]="";
|
||||||
|
snprintf(szErrBuf,8096,"In [%s::%s %d]",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
string sErrBuf = string(szErrBuf) + string("\nThe game may no longer be stable!\nerror [") + string(ex.what()) + string("]\n");
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugError,sErrBuf.c_str());
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,sErrBuf.c_str());
|
||||||
|
|
||||||
|
thisScriptManager->addMessageToQueue(ScriptManagerMessage(sErrBuf.c_str(), "error",-1,-1,true));
|
||||||
|
thisScriptManager->onMessageBoxOk(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptManager::saveGame(XmlNode *rootNode) {
|
void ScriptManager::saveGame(XmlNode *rootNode) {
|
||||||
std::map<string,string> mapTagReplacements;
|
std::map<string,string> mapTagReplacements;
|
||||||
|
@@ -423,6 +423,7 @@ private:
|
|||||||
void storeSaveGameData(string name, string value);
|
void storeSaveGameData(string name, string value);
|
||||||
string loadSaveGameData(string name);
|
string loadSaveGameData(string name);
|
||||||
|
|
||||||
|
ControlType getFactionPlayerType(int factionIndex);
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
//callbacks, commands
|
//callbacks, commands
|
||||||
@@ -591,6 +592,8 @@ private:
|
|||||||
|
|
||||||
static int storeSaveGameData(LuaHandle* luaHandle);
|
static int storeSaveGameData(LuaHandle* luaHandle);
|
||||||
static int loadSaveGameData(LuaHandle* luaHandle);
|
static int loadSaveGameData(LuaHandle* luaHandle);
|
||||||
|
|
||||||
|
static int getFactionPlayerType(LuaHandle* luaHandle);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
Reference in New Issue
Block a user