- fix segfault when converting models
- fix segfault when mod menu cannot connect to masterserver
This commit is contained in:
parent
a6af5b96af
commit
04e16819aa
|
@ -2228,13 +2228,14 @@ void Renderer::renderSelectionQuad() {
|
||||||
|
|
||||||
Vec2i computeCenteredPos(const string &text, Font2D *font, int x, int y) {
|
Vec2i computeCenteredPos(const string &text, Font2D *font, int x, int y) {
|
||||||
if(font == NULL) {
|
if(font == NULL) {
|
||||||
throw runtime_error("font == NULL");
|
//abort();
|
||||||
|
throw runtime_error("font == NULL (1)");
|
||||||
}
|
}
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
FontMetrics *fontMetrics= font->getMetrics();
|
FontMetrics *fontMetrics= font->getMetrics();
|
||||||
|
|
||||||
if(fontMetrics == NULL) {
|
if(fontMetrics == NULL) {
|
||||||
throw runtime_error("fontMetrics == NULL");
|
throw runtime_error("fontMetrics == NULL (1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
int virtualX = (fontMetrics->getTextWidth(text) > 0 ? static_cast<int>(fontMetrics->getTextWidth(text)/2.f) : 5);
|
int virtualX = (fontMetrics->getTextWidth(text) > 0 ? static_cast<int>(fontMetrics->getTextWidth(text)/2.f) : 5);
|
||||||
|
@ -2251,13 +2252,13 @@ Vec2i computeCenteredPos(const string &text, Font2D *font, int x, int y) {
|
||||||
|
|
||||||
Vec2i computeCenteredPos(const string &text, Font3D *font, int x, int y) {
|
Vec2i computeCenteredPos(const string &text, Font3D *font, int x, int y) {
|
||||||
if(font == NULL) {
|
if(font == NULL) {
|
||||||
throw runtime_error("font == NULL");
|
throw runtime_error("font == NULL (2)");
|
||||||
}
|
}
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
FontMetrics *fontMetrics= font->getMetrics();
|
FontMetrics *fontMetrics= font->getMetrics();
|
||||||
|
|
||||||
if(fontMetrics == NULL) {
|
if(fontMetrics == NULL) {
|
||||||
throw runtime_error("fontMetrics == NULL");
|
throw runtime_error("fontMetrics == NULL (2)");
|
||||||
}
|
}
|
||||||
|
|
||||||
int virtualX = (fontMetrics->getTextWidth(text) > 0 ? static_cast<int>(fontMetrics->getTextWidth(text) / 2.f) : 5);
|
int virtualX = (fontMetrics->getTextWidth(text) > 0 ? static_cast<int>(fontMetrics->getTextWidth(text) / 2.f) : 5);
|
||||||
|
@ -2525,7 +2526,7 @@ void Renderer::renderTextShadow3D(const string &text, Font3D *font,const Vec4f &
|
||||||
}
|
}
|
||||||
|
|
||||||
if(font == NULL) {
|
if(font == NULL) {
|
||||||
throw runtime_error("font == NULL");
|
throw runtime_error("font == NULL (3)");
|
||||||
}
|
}
|
||||||
|
|
||||||
glPushAttrib(GL_CURRENT_BIT);
|
glPushAttrib(GL_CURRENT_BIT);
|
||||||
|
@ -2554,7 +2555,7 @@ void Renderer::renderTextShadow(const string &text, Font2D *font,const Vec4f &co
|
||||||
}
|
}
|
||||||
|
|
||||||
if(font == NULL) {
|
if(font == NULL) {
|
||||||
throw runtime_error("font == NULL");
|
throw runtime_error("font == NULL (4)");
|
||||||
}
|
}
|
||||||
|
|
||||||
glPushAttrib(GL_CURRENT_BIT);
|
glPushAttrib(GL_CURRENT_BIT);
|
||||||
|
|
|
@ -3397,6 +3397,8 @@ int glestMain(int argc, char** argv) {
|
||||||
printf("About to convert using keepsmallest = %d\n",keepsmallest);
|
printf("About to convert using keepsmallest = %d\n",keepsmallest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CoreData::getInstance().load();
|
||||||
|
|
||||||
showCursor(true);
|
showCursor(true);
|
||||||
mainWindow->setUseDefaultCursorOnly(true);
|
mainWindow->setUseDefaultCursorOnly(true);
|
||||||
|
|
||||||
|
@ -3404,11 +3406,21 @@ int glestMain(int argc, char** argv) {
|
||||||
renderer.clearBuffers();
|
renderer.clearBuffers();
|
||||||
renderer.clearZBuffer();
|
renderer.clearZBuffer();
|
||||||
renderer.reset2d();
|
renderer.reset2d();
|
||||||
|
|
||||||
|
if(CoreData::getInstance().getMenuFontBig3D() != NULL) {
|
||||||
|
renderer.renderText3D(
|
||||||
|
"Please wait, converting models...",
|
||||||
|
CoreData::getInstance().getMenuFontBig3D(),
|
||||||
|
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2) - 400,
|
||||||
|
(metrics.getScreenH() / 2), true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderText(
|
renderer.renderText(
|
||||||
"Please wait, converting models...",
|
"Please wait, converting models...",
|
||||||
CoreData::getInstance().getMenuFontBig(),
|
CoreData::getInstance().getMenuFontBig(),
|
||||||
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2) - 400,
|
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2) - 400,
|
||||||
(metrics.getScreenH() / 2), true);
|
(metrics.getScreenH() / 2), true);
|
||||||
|
}
|
||||||
renderer.swapBuffers();
|
renderer.swapBuffers();
|
||||||
|
|
||||||
std::vector<string> models;
|
std::vector<string> models;
|
||||||
|
@ -3432,11 +3444,21 @@ int glestMain(int argc, char** argv) {
|
||||||
renderer.clearZBuffer();
|
renderer.clearZBuffer();
|
||||||
renderer.reset2d();
|
renderer.reset2d();
|
||||||
sprintf(szTextBuf,"Please wait, converting models [%d of %lu] ...",i,(long int)models.size());
|
sprintf(szTextBuf,"Please wait, converting models [%d of %lu] ...",i,(long int)models.size());
|
||||||
|
|
||||||
|
if(CoreData::getInstance().getMenuFontBig3D() != NULL) {
|
||||||
|
renderer.renderText3D(
|
||||||
|
szTextBuf,
|
||||||
|
CoreData::getInstance().getMenuFontBig3D(),
|
||||||
|
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2) - 400,
|
||||||
|
(metrics.getScreenH() / 2), true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderText(
|
renderer.renderText(
|
||||||
szTextBuf,
|
szTextBuf,
|
||||||
CoreData::getInstance().getMenuFontBig(),
|
CoreData::getInstance().getMenuFontBig(),
|
||||||
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2) - 400,
|
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2) - 400,
|
||||||
(metrics.getScreenH() / 2), true);
|
(metrics.getScreenH() / 2), true);
|
||||||
|
}
|
||||||
renderer.swapBuffers();
|
renderer.swapBuffers();
|
||||||
|
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
|
|
@ -851,7 +851,7 @@ void MenuStateMods::getTechsLocalList() {
|
||||||
string MenuStateMods::refreshTechModInfo(string techInfo) {
|
string MenuStateMods::refreshTechModInfo(string techInfo) {
|
||||||
std::vector<std::string> techInfoList;
|
std::vector<std::string> techInfoList;
|
||||||
Tokenize(techInfo,techInfoList,"|");
|
Tokenize(techInfo,techInfoList,"|");
|
||||||
if(techInfoList.size() >= 5) {
|
if(techInfoList.size() >= 6) {
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
ModInfo modinfo;
|
ModInfo modinfo;
|
||||||
modinfo.name = techInfoList[0];
|
modinfo.name = techInfoList[0];
|
||||||
|
@ -861,6 +861,7 @@ string MenuStateMods::refreshTechModInfo(string techInfo) {
|
||||||
modinfo.url = techInfoList[4];
|
modinfo.url = techInfoList[4];
|
||||||
modinfo.imageUrl = techInfoList[5];
|
modinfo.imageUrl = techInfoList[5];
|
||||||
modinfo.type = mt_Techtree;
|
modinfo.type = mt_Techtree;
|
||||||
|
|
||||||
string itemPath = config.getPathListForType(ptTechs,"")[1] + "/" + modinfo.name + string("/*");
|
string itemPath = config.getPathListForType(ptTechs,"")[1] + "/" + modinfo.name + string("/*");
|
||||||
if(itemPath.empty()==false){
|
if(itemPath.empty()==false){
|
||||||
bool forceRefresh = (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end());
|
bool forceRefresh = (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end());
|
||||||
|
@ -901,7 +902,7 @@ void MenuStateMods::getTilesetsLocalList() {
|
||||||
string MenuStateMods::refreshTilesetModInfo(string tilesetInfo) {
|
string MenuStateMods::refreshTilesetModInfo(string tilesetInfo) {
|
||||||
std::vector<std::string> tilesetInfoList;
|
std::vector<std::string> tilesetInfoList;
|
||||||
Tokenize(tilesetInfo,tilesetInfoList,"|");
|
Tokenize(tilesetInfo,tilesetInfoList,"|");
|
||||||
if(tilesetInfoList.size() >= 4) {
|
if(tilesetInfoList.size() >= 5) {
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
ModInfo modinfo;
|
ModInfo modinfo;
|
||||||
modinfo.name = tilesetInfoList[0];
|
modinfo.name = tilesetInfoList[0];
|
||||||
|
@ -990,7 +991,7 @@ void MenuStateMods::getMapsLocalList() {
|
||||||
string MenuStateMods::refreshMapModInfo(string mapInfo) {
|
string MenuStateMods::refreshMapModInfo(string mapInfo) {
|
||||||
std::vector<std::string> mapInfoList;
|
std::vector<std::string> mapInfoList;
|
||||||
Tokenize(mapInfo,mapInfoList,"|");
|
Tokenize(mapInfo,mapInfoList,"|");
|
||||||
if(mapInfoList.size() >= 5) {
|
if(mapInfoList.size() >= 6) {
|
||||||
//Config &config = Config::getInstance();
|
//Config &config = Config::getInstance();
|
||||||
ModInfo modinfo;
|
ModInfo modinfo;
|
||||||
modinfo.name = mapInfoList[0];
|
modinfo.name = mapInfoList[0];
|
||||||
|
@ -1052,7 +1053,7 @@ void MenuStateMods::getScenariosLocalList() {
|
||||||
string MenuStateMods::refreshScenarioModInfo(string scenarioInfo) {
|
string MenuStateMods::refreshScenarioModInfo(string scenarioInfo) {
|
||||||
std::vector<std::string> scenarioInfoList;
|
std::vector<std::string> scenarioInfoList;
|
||||||
Tokenize(scenarioInfo,scenarioInfoList,"|");
|
Tokenize(scenarioInfo,scenarioInfoList,"|");
|
||||||
if(scenarioInfoList.size() >= 4) {
|
if(scenarioInfoList.size() >= 5) {
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
ModInfo modinfo;
|
ModInfo modinfo;
|
||||||
modinfo.name = scenarioInfoList[0];
|
modinfo.name = scenarioInfoList[0];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user