mirror of
https://github.com/glest/glest-source.git
synced 2025-08-14 12:23:59 +02:00
Added setPlayerType function
This commit is contained in:
@@ -7705,7 +7705,14 @@ namespace Game {
|
||||
case ctCpuGlest:
|
||||
factionInfo += " CPU Glest" + multiplier;
|
||||
break;
|
||||
case ctNetwork:
|
||||
factionInfo += " (Network)";
|
||||
break;
|
||||
case ctHuman:
|
||||
factionInfo += " (Human)";
|
||||
break;
|
||||
default:
|
||||
factionInfo += " (Closed)";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -556,6 +556,7 @@ namespace Game {
|
||||
luaScript.registerFunction(loadSaveGameData, "loadSaveGameData");
|
||||
|
||||
luaScript.registerFunction(getPlayerType, "getPlayerType");
|
||||
luaScript.registerFunction(setPlayerType, "setPlayerType");
|
||||
|
||||
map<string, pair<Script, vector<string>>> scripts;
|
||||
map<string, pair<Script, vector<string>>>::iterator iter;
|
||||
@@ -3406,6 +3407,23 @@ namespace Game {
|
||||
}
|
||||
return ctClosed;
|
||||
}
|
||||
|
||||
void
|
||||
ScriptManager::setPlayerType(int factionIndex, ControlType playerType) {
|
||||
if (factionIndex < 0 || factionIndex >= world->getFactionCount() || playerType < ctClosed || playerType > ctHuman)
|
||||
return;
|
||||
Faction *
|
||||
faction = world->getFaction(factionIndex);
|
||||
if (faction != NULL) {
|
||||
faction->setControlType(playerType);
|
||||
GameSettings* settings = world->getGameSettingsPtr();
|
||||
if (settings != NULL)
|
||||
settings->setFactionControl(factionIndex, playerType);
|
||||
Stats* stats = world->getStats();
|
||||
if (stats != NULL)
|
||||
stats->setControl(factionIndex, playerType);
|
||||
}
|
||||
}
|
||||
// ========================== lua callbacks ===============================================
|
||||
|
||||
int
|
||||
@@ -6115,9 +6133,19 @@ namespace Game {
|
||||
} catch (const game_runtime_error & ex) {
|
||||
error(luaHandle, &ex, __FILE__, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int
|
||||
ScriptManager::setPlayerType(LuaHandle * luaHandle) {
|
||||
LuaArguments
|
||||
luaArguments(luaHandle);
|
||||
try {
|
||||
thisScriptManager->setPlayerType(luaArguments.getInt(-2), static_cast<ControlType>(luaArguments.getInt(-1)));
|
||||
} catch (const game_runtime_error & ex) {
|
||||
error(luaHandle, &ex, __FILE__, __FUNCTION__, __LINE__);
|
||||
}
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -769,6 +769,8 @@ namespace Game {
|
||||
loadSaveGameData(string name);
|
||||
|
||||
ControlType getPlayerType(int factionIndex);
|
||||
void setPlayerType(int factionIndex, ControlType playerType);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
@@ -1091,6 +1093,7 @@ namespace Game {
|
||||
loadSaveGameData(LuaHandle * luaHandle);
|
||||
|
||||
static int getPlayerType(LuaHandle * luaHandle);
|
||||
static int setPlayerType(LuaHandle * luaHandle);
|
||||
};
|
||||
|
||||
} //end namespace
|
||||
|
Reference in New Issue
Block a user