Converted star browser code to use plain old sprintf instead of string streams

due to apparent bugs in some versions of the g++ libraries.
ver1_5_1
Chris Laurel 2002-01-16 03:04:36 +00:00
parent 990dbf7ee6
commit 3a130ef031
1 changed files with 74 additions and 73 deletions

View File

@ -15,7 +15,6 @@
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <time.h>
#include <unistd.h>
#include <celengine/gl.h>
@ -345,6 +344,7 @@ static void menuAbout()
const gchar* authors[] = {
"Chris Laurel <claurel@shatters.net>",
"Deon Ramsey <miavir@furry.de>",
"Clint Weisbrod <cweisbrod@adelphia.net>",
NULL
};
const gchar* logo = gnome_pixmap_file("gnome-hello-logo.png");
@ -360,7 +360,7 @@ static void menuAbout()
{
about = gnome_about_new("Celestia",
VERSION,
"(c) 2001 Chris Laurel",
"(c) 2001-2002 Chris Laurel",
authors,
"3D Space Simulation",
logo);
@ -1169,27 +1169,26 @@ static void addStars()
currentLength=(*stars).size();
browserSel.select((Star *)(*stars)[0]);
UniversalCoord ucPos = appSim->getObserver().getPosition();
for (unsigned int i = 0; i < currentLength; i++)
{
char buf[20];
const Star *star=(*stars)[i];
tmp[0] = g_strdup((stardb->getStarName(*star)).c_str());
ostringstream dstr("", ios::ate);
dstr.precision(3);
dstr.setf(ios::fixed, ios::floatfield);
dstr << ' ' << (ucPos.distanceTo(star->getPosition())) << ' ';
tmp[1]=g_strdup(dstr.str().c_str());
dstr.seekp(0);
dstr.precision(2);
sprintf(buf, " %.3f ", ucPos.distanceTo(star->getPosition()));
tmp[1] = g_strdup(buf);
Vec3f r = star->getPosition() - ucPos;
dstr << " " << astro::absToAppMag(star->getAbsoluteMagnitude(),r.length()) << " \0";
tmp[2]=g_strdup(dstr.str().c_str());
dstr.seekp(0);
dstr.precision(2);
dstr << ' ' << star->getAbsoluteMagnitude() << " \0";
tmp[3]=g_strdup(dstr.str().c_str());
dstr.seekp(0);
dstr << ' ' << star->getStellarClass();
tmp[4]=g_strdup(dstr.str().c_str());
sprintf(buf, " %.2f ", astro::absToAppMag(star->getAbsoluteMagnitude(),r.length()));
tmp[2] = g_strdup(buf);
sprintf(buf, " %.2f ", star->getAbsoluteMagnitude());
tmp[3] = g_strdup(buf);
star->getStellarClass().str(buf, sizeof buf);
tmp[4] = g_strdup(buf);
gint row = gtk_clist_append(GTK_CLIST(clist), (char**) tmp);
gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer) star);
for (unsigned int j = 0; j < 5; j++)
@ -1202,7 +1201,7 @@ static void addStars()
static int radioClicked(GtkButton *button, int pred)
{
if(!sbrowser.setPred(pred))
if (!sbrowser.setPredicate(pred))
return FALSE;
addStars();
return TRUE;
@ -1227,15 +1226,17 @@ static void loadNearestStarSystem()
nearestStar=solarSys->getStar();
else
nearestStar=sbrowser.nearestStar();
tmp[0]=g_strdup((stardb->getStarName(*nearestStar)).c_str());
ostringstream ostr("", ios::ate);
ostr << nearestStar->getStellarClass() << " Class Star";
tmp[1]=(char *)(ostr.str()).c_str();
tmp[0] = const_cast<char*>(stardb->getStarName(*nearestStar).c_str());
char buf[30];
sprintf(buf, "%s Star", (nearestStar->getStellarClass().str().c_str()));
tmp[1] = buf;
GtkCTreeNode *top = gtk_ctree_insert_node (GTK_CTREE(ctree), NULL, NULL,
(char**) tmp , 0 , NULL, NULL,
NULL, NULL, FALSE, TRUE);
gtk_ctree_node_set_row_data(GTK_CTREE(ctree), top, (gpointer)nearestStar);
g_free((gpointer)tmp[0]);
if (solarSys != NULL)
{
const PlanetarySystem* planets = solarSys->getPlanets();