mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 04:02:30 +01:00
- applied patch from MuwuM
This commit is contained in:
parent
29ed59de0b
commit
0f25276e6f
@ -309,6 +309,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
||||
luaScript.registerFunction(setUnitPosition, "setUnitPosition");
|
||||
|
||||
luaScript.registerFunction(getUnitFaction, "unitFaction");
|
||||
luaScript.registerFunction(getUnitName, "unitName");
|
||||
luaScript.registerFunction(getResourceAmount, "resourceAmount");
|
||||
|
||||
luaScript.registerFunction(getLastCreatedUnitName, "lastCreatedUnitName");
|
||||
@ -1258,6 +1259,11 @@ int ScriptManager::getUnitFaction(int unitId) {
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
return world->getUnitFactionIndex(unitId);
|
||||
}
|
||||
const string ScriptManager::getUnitName(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;
|
||||
return world->getUnitName(unitId);
|
||||
}
|
||||
|
||||
int ScriptManager::getResourceAmount(const string &resourceName, int factionIndex) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@ -1781,6 +1787,12 @@ int ScriptManager::getUnitFaction(LuaHandle* luaHandle){
|
||||
luaArguments.returnInt(factionIndex);
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
int ScriptManager::getUnitName(LuaHandle* luaHandle){
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
const string unitname = thisScriptManager->getUnitName(luaArguments.getInt(-1));
|
||||
luaArguments.returnString(unitname);
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::getResourceAmount(LuaHandle* luaHandle){
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
|
@ -304,6 +304,7 @@ private:
|
||||
Vec2i getStartLocation(int factionIndex);
|
||||
Vec2i getUnitPosition(int unitId);
|
||||
int getUnitFaction(int unitId);
|
||||
const string getUnitName(int unitId);
|
||||
int getResourceAmount(const string &resourceName, int factionIndex);
|
||||
const string &getLastCreatedUnitName();
|
||||
int getLastCreatedUnitId();
|
||||
@ -410,6 +411,7 @@ private:
|
||||
static int getStartLocation(LuaHandle* luaHandle);
|
||||
static int getUnitPosition(LuaHandle* luaHandle);
|
||||
static int getUnitFaction(LuaHandle* luaHandle);
|
||||
static int getUnitName(LuaHandle* luaHandle);
|
||||
static int getResourceAmount(LuaHandle* luaHandle);
|
||||
static int getLastCreatedUnitName(LuaHandle* luaHandle);
|
||||
static int getLastCreatedUnitId(LuaHandle* luaHandle);
|
||||
|
@ -1285,6 +1285,13 @@ int World::getUnitFactionIndex(int unitId) {
|
||||
}
|
||||
return unit->getFactionIndex();
|
||||
}
|
||||
const string World::getUnitName(int unitId) {
|
||||
Unit* unit= findUnitById(unitId);
|
||||
if(unit == NULL) {
|
||||
throw megaglest_runtime_error("Can not find Faction unit to get position unitId = " + intToStr(unitId));
|
||||
}
|
||||
return unit->getFullName();
|
||||
}
|
||||
|
||||
int World::getUnitCount(int factionIndex) {
|
||||
if(factionIndex < factions.size()) {
|
||||
|
@ -248,6 +248,7 @@ public:
|
||||
void setUnitPosition(int unitId, Vec2i pos);
|
||||
|
||||
int getUnitFactionIndex(int unitId);
|
||||
const string getUnitName(int unitId);
|
||||
int getUnitCount(int factionIndex);
|
||||
int getUnitCountOfType(int factionIndex, const string &typeName);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user