Merge pull request #16 from gergelypolonkai/bug-15

Add error reporting to add_points()
This commit is contained in:
Gergely Polonkai 2014-09-02 12:47:30 +02:00
commit f21ce84b17

View File

@ -1144,6 +1144,10 @@ static void
add_points(GswePlanetData *planet_data, GsweMoment *moment) add_points(GswePlanetData *planet_data, GsweMoment *moment)
{ {
guint point; guint point;
GsweSignInfo *sign_info;
GswePlanetInfo *planet_info;
GsweElement element;
GsweQuality quality;
gswe_moment_calculate_planet( gswe_moment_calculate_planet(
moment, moment,
@ -1151,23 +1155,37 @@ add_points(GswePlanetData *planet_data, GsweMoment *moment)
NULL NULL
); );
sign_info = gswe_planet_data_get_sign_info(planet_data);
if (G_UNLIKELY(sign_info == NULL)) {
g_error("Planet data calculation failed");
}
planet_info = gswe_planet_data_get_planet_info(planet_data);
if (G_UNLIKELY(planet_info == NULL)) {
g_error("Planet data calculation failed. No planet info.");
}
element = gswe_sign_info_get_element(sign_info);
point = GPOINTER_TO_INT(g_hash_table_lookup( point = GPOINTER_TO_INT(g_hash_table_lookup(
moment->priv->element_points, moment->priv->element_points,
GINT_TO_POINTER(planet_data->sign_info->element) GINT_TO_POINTER(element)
)) + planet_data->planet_info->points; )) + gswe_planet_info_get_points(planet_info);
g_hash_table_replace( g_hash_table_replace(
moment->priv->element_points, moment->priv->element_points,
GINT_TO_POINTER(planet_data->sign_info->element), GINT_TO_POINTER(element),
GINT_TO_POINTER(point) GINT_TO_POINTER(point)
); );
quality = gswe_sign_info_get_quality(sign_info);
point = GPOINTER_TO_INT(g_hash_table_lookup( point = GPOINTER_TO_INT(g_hash_table_lookup(
moment->priv->quality_points, moment->priv->quality_points,
GINT_TO_POINTER(planet_data->sign_info->quality) GINT_TO_POINTER(quality)
)) + planet_data->planet_info->points; )) + gswe_planet_info_get_points(planet_info);
g_hash_table_replace( g_hash_table_replace(
moment->priv->quality_points, moment->priv->quality_points,
GINT_TO_POINTER(planet_data->sign_info->quality), GINT_TO_POINTER(quality),
GINT_TO_POINTER(point) GINT_TO_POINTER(point)
); );
} }