mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 22:21:18 +02:00
- restore timeflow and gamecamera on load game
This commit is contained in:
@@ -870,19 +870,21 @@ void Game::init(bool initForPreviewOnly) {
|
||||
console.clearStoredLines();
|
||||
}
|
||||
|
||||
gameCamera.init(map->getW(), map->getH());
|
||||
if(this->loadGameNode == NULL) {
|
||||
gameCamera.init(map->getW(), map->getH());
|
||||
|
||||
// camera default height calculation
|
||||
if(map->getCameraHeight()>0 && gameCamera.getCalculatedDefault()<map->getCameraHeight()){
|
||||
gameCamera.setCalculatedDefault(map->getCameraHeight());
|
||||
}
|
||||
else if(gameCamera.getCalculatedDefault()<map->getMaxMapHeight()+13.0f){
|
||||
gameCamera.setCalculatedDefault(map->getMaxMapHeight()+13.0f);
|
||||
}
|
||||
// camera default height calculation
|
||||
if(map->getCameraHeight()>0 && gameCamera.getCalculatedDefault()<map->getCameraHeight()){
|
||||
gameCamera.setCalculatedDefault(map->getCameraHeight());
|
||||
}
|
||||
else if(gameCamera.getCalculatedDefault()<map->getMaxMapHeight()+13.0f){
|
||||
gameCamera.setCalculatedDefault(map->getMaxMapHeight()+13.0f);
|
||||
}
|
||||
|
||||
if(world.getThisFaction() != NULL) {
|
||||
const Vec2i &v= map->getStartLocation(world.getThisFaction()->getStartLocationIndex());
|
||||
gameCamera.setPos(Vec2f(v.x, v.y));
|
||||
if(world.getThisFaction() != NULL) {
|
||||
const Vec2i &v= map->getStartLocation(world.getThisFaction()->getStartLocationIndex());
|
||||
gameCamera.setPos(Vec2f(v.x, v.y));
|
||||
}
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
@@ -1488,8 +1490,10 @@ void Game::render() {
|
||||
if(isFirstRender == true) {
|
||||
isFirstRender = false;
|
||||
|
||||
gameCamera.resetPosition();
|
||||
this->restoreToStartXY();
|
||||
if(this->loadGameNode == NULL) {
|
||||
gameCamera.resetPosition();
|
||||
this->restoreToStartXY();
|
||||
}
|
||||
}
|
||||
|
||||
canRender();
|
||||
@@ -3615,6 +3619,7 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) {
|
||||
|
||||
Game *newGame = new Game(programPtr, &newGameSettings, isMasterserverMode);
|
||||
newGame->loadGameNode = gameNode;
|
||||
newGame->gameCamera.loadGame(gameNode);
|
||||
|
||||
const XmlNode *worldNode = gameNode->getChild("World");
|
||||
newGame->world.loadGame(worldNode);
|
||||
|
@@ -466,4 +466,62 @@ void GameCamera::saveGame(XmlNode *rootNode) {
|
||||
// int MaxVisibleQuadItemCache;
|
||||
gamecameraNode->addAttribute("MaxVisibleQuadItemCache",intToStr(MaxVisibleQuadItemCache), mapTagReplacements);
|
||||
}
|
||||
|
||||
void GameCamera::loadGame(const XmlNode *rootNode) {
|
||||
const XmlNode *gamecameraNode = rootNode->getChild("GameCamera");
|
||||
|
||||
//firstTime = timeflowNode->getAttribute("firstTime")->getFloatValue();
|
||||
|
||||
// Vec3f pos;
|
||||
pos = Vec3f::strToVec3(gamecameraNode->getAttribute("pos")->getValue());
|
||||
// Vec3f destPos;
|
||||
destPos = Vec3f::strToVec3(gamecameraNode->getAttribute("destPos")->getValue());
|
||||
//
|
||||
// float hAng; //YZ plane positive -Z axis
|
||||
hAng = gamecameraNode->getAttribute("hAng")->getFloatValue();
|
||||
// float vAng; //XZ plane positive +Z axis
|
||||
vAng = gamecameraNode->getAttribute("vAng")->getFloatValue();
|
||||
// float lastHAng;
|
||||
lastHAng = gamecameraNode->getAttribute("lastHAng")->getFloatValue();
|
||||
|
||||
// float lastVAng;
|
||||
lastVAng = gamecameraNode->getAttribute("lastVAng")->getFloatValue();
|
||||
// Vec2f destAng;
|
||||
destAng = Vec2f::strToVec2(gamecameraNode->getAttribute("destAng")->getValue());
|
||||
// float rotate;
|
||||
rotate = gamecameraNode->getAttribute("rotate")->getFloatValue();
|
||||
// Vec3f move;
|
||||
move = Vec3f::strToVec3(gamecameraNode->getAttribute("move")->getValue());
|
||||
// State state;
|
||||
state = static_cast<State>(gamecameraNode->getAttribute("state")->getIntValue());
|
||||
// int limitX;
|
||||
limitX = gamecameraNode->getAttribute("limitX")->getIntValue();
|
||||
// int limitY;
|
||||
limitY = gamecameraNode->getAttribute("limitY")->getIntValue();
|
||||
// //config
|
||||
// float speed;
|
||||
speed = gamecameraNode->getAttribute("speed")->getFloatValue();
|
||||
// bool clampBounds;
|
||||
clampBounds = gamecameraNode->getAttribute("clampBounds")->getIntValue();
|
||||
// //float maxRenderDistance;
|
||||
// float maxHeight;
|
||||
maxHeight = gamecameraNode->getAttribute("maxHeight")->getFloatValue();
|
||||
// float minHeight;
|
||||
minHeight = gamecameraNode->getAttribute("minHeight")->getFloatValue();
|
||||
// //float maxCameraDist;
|
||||
// //float minCameraDist;
|
||||
// float minVAng;
|
||||
minVAng = gamecameraNode->getAttribute("minVAng")->getFloatValue();
|
||||
// float maxVAng;
|
||||
maxVAng = gamecameraNode->getAttribute("maxVAng")->getFloatValue();
|
||||
// float fov;
|
||||
fov = gamecameraNode->getAttribute("fov")->getFloatValue();
|
||||
// float calculatedDefault;
|
||||
calculatedDefault = gamecameraNode->getAttribute("calculatedDefault")->getFloatValue();
|
||||
// std::map<float, std::map<float, std::map<Vec3f, Quad2i> > > cacheVisibleQuad;
|
||||
// int MaxVisibleQuadItemCache;
|
||||
MaxVisibleQuadItemCache = gamecameraNode->getAttribute("MaxVisibleQuadItemCache")->getIntValue();
|
||||
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -144,6 +144,7 @@ public:
|
||||
void setMaxVAng(float value) { maxVAng = value; }
|
||||
|
||||
void saveGame(XmlNode *rootNode);
|
||||
void loadGame(const XmlNode *rootNode);
|
||||
|
||||
private:
|
||||
void clampPosXYZ(float x1, float x2, float y1, float y2, float z1, float z2);
|
||||
|
@@ -145,7 +145,7 @@ void TimeFlow::loadGame(const XmlNode *rootNode) {
|
||||
const XmlNode *timeflowNode = rootNode->getChild("TimeFlow");
|
||||
|
||||
firstTime = timeflowNode->getAttribute("firstTime")->getFloatValue();
|
||||
time = timeflowNode->getAttribute("time")->getIntValue();
|
||||
time = timeflowNode->getAttribute("time")->getFloatValue();
|
||||
lastTime = timeflowNode->getAttribute("lastTime")->getFloatValue();
|
||||
timeInc = timeflowNode->getAttribute("timeInc")->getFloatValue();
|
||||
}
|
||||
|
@@ -451,6 +451,42 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
// playerColor="x [1] y [0] z [0]"
|
||||
static inline Vec3<T> strToVec3(std::string value) {
|
||||
Vec3<T> result;
|
||||
|
||||
std::vector<std::string> tokens = TokenizeString(value,"[");
|
||||
//for(unsigned int i = 0; i < tokens.size(); ++i) {
|
||||
//printf("#1 Vec2T i = %d [%s]\n",i,tokens[i].c_str());
|
||||
//}
|
||||
if(tokens.size() == 4) {
|
||||
std::vector<std::string> tokens2 = TokenizeString(tokens[1],"]");
|
||||
//for(unsigned int i = 0; i < tokens2.size(); ++i) {
|
||||
//printf("#2 Vec2T i = %d [%s]\n",i,tokens2[i].c_str());
|
||||
//}
|
||||
std::vector<std::string> tokens3 = TokenizeString(tokens[2],"]");
|
||||
//for(unsigned int i = 0; i < tokens3.size(); ++i) {
|
||||
//printf("#3 Vec2T i = %d [%s]\n",i,tokens3[i].c_str());
|
||||
//}
|
||||
|
||||
std::vector<std::string> tokens4 = TokenizeString(tokens[3],"]");
|
||||
//for(unsigned int i = 0; i < tokens3.size(); ++i) {
|
||||
//printf("#3 Vec2T i = %d [%s]\n",i,tokens3[i].c_str());
|
||||
//}
|
||||
|
||||
if(tokens2.size() == 2 && tokens3.size() == 2 && tokens4.size() == 2) {
|
||||
result.x = (T)strToType<T>(tokens2[0]);
|
||||
result.y = (T)strToType<T>(tokens3[0]);
|
||||
result.z = (T)strToType<T>(tokens4[0]);
|
||||
|
||||
//printf("#3 Vec2T [%s]\n",result.getString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef Vec3<int> Vec3i;
|
||||
|
Reference in New Issue
Block a user