mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 05:13:59 +02:00
Added setPlayerType function
This commit is contained in:
@@ -7705,7 +7705,14 @@ namespace Game {
|
|||||||
case ctCpuGlest:
|
case ctCpuGlest:
|
||||||
factionInfo += " CPU Glest" + multiplier;
|
factionInfo += " CPU Glest" + multiplier;
|
||||||
break;
|
break;
|
||||||
|
case ctNetwork:
|
||||||
|
factionInfo += " (Network)";
|
||||||
|
break;
|
||||||
|
case ctHuman:
|
||||||
|
factionInfo += " (Human)";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
factionInfo += " (Closed)";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -556,6 +556,7 @@ namespace Game {
|
|||||||
luaScript.registerFunction(loadSaveGameData, "loadSaveGameData");
|
luaScript.registerFunction(loadSaveGameData, "loadSaveGameData");
|
||||||
|
|
||||||
luaScript.registerFunction(getPlayerType, "getPlayerType");
|
luaScript.registerFunction(getPlayerType, "getPlayerType");
|
||||||
|
luaScript.registerFunction(setPlayerType, "setPlayerType");
|
||||||
|
|
||||||
map<string, pair<Script, vector<string>>> scripts;
|
map<string, pair<Script, vector<string>>> scripts;
|
||||||
map<string, pair<Script, vector<string>>>::iterator iter;
|
map<string, pair<Script, vector<string>>>::iterator iter;
|
||||||
@@ -3406,6 +3407,23 @@ namespace Game {
|
|||||||
}
|
}
|
||||||
return ctClosed;
|
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 ===============================================
|
// ========================== lua callbacks ===============================================
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -6115,9 +6133,19 @@ namespace Game {
|
|||||||
} catch (const game_runtime_error & ex) {
|
} catch (const game_runtime_error & ex) {
|
||||||
error(luaHandle, &ex, __FILE__, __FUNCTION__, __LINE__);
|
error(luaHandle, &ex, __FILE__, __FUNCTION__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
return luaArguments.getReturnCount();
|
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
|
void
|
||||||
|
@@ -769,6 +769,8 @@ namespace Game {
|
|||||||
loadSaveGameData(string name);
|
loadSaveGameData(string name);
|
||||||
|
|
||||||
ControlType getPlayerType(int factionIndex);
|
ControlType getPlayerType(int factionIndex);
|
||||||
|
void setPlayerType(int factionIndex, ControlType playerType);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1091,6 +1093,7 @@ namespace Game {
|
|||||||
loadSaveGameData(LuaHandle * luaHandle);
|
loadSaveGameData(LuaHandle * luaHandle);
|
||||||
|
|
||||||
static int getPlayerType(LuaHandle * luaHandle);
|
static int getPlayerType(LuaHandle * luaHandle);
|
||||||
|
static int setPlayerType(LuaHandle * luaHandle);
|
||||||
};
|
};
|
||||||
|
|
||||||
} //end namespace
|
} //end namespace
|
||||||
|
Reference in New Issue
Block a user