Fixed gswe_sign_info_table creation

This is a fixup for commit a1f8d1f7da
This commit is contained in:
Gergely Polonkai 2013-09-30 22:17:52 +02:00
parent bc9ff2fc09
commit 3a06d4bcee
2 changed files with 9 additions and 16 deletions

View File

@ -531,12 +531,13 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
* GsweHouseSystem, and all other house systems have exactly 12 houses, so
* this should not cause trouble yet, though) */
for (i = 12; i >= 1; i--) {
GsweSignInfo *sign_info;
GsweHouseData *house_data = g_new0(GsweHouseData, 1);
house_data->house = i;
house_data->cusp_position = cusps[i];
if ((house_data->sign = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)))) == NULL) {
if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)))) == NULL) {
g_list_free_full(moment->priv->house_list, g_free);
moment->priv->house_list = NULL;
moment->priv->house_revision = 0;
@ -545,6 +546,7 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
return;
}
house_data->sign_info = gswe_sign_info_ref(sign_info);
moment->priv->house_list = g_list_prepend(moment->priv->house_list, house_data);
}
@ -754,7 +756,7 @@ gswe_moment_get_sign_planets(GsweMoment *moment, GsweZodiac sign)
for (planet = moment->priv->planet_list; planet; planet = g_list_next(planet)) {
GswePlanetData *pd = planet->data;
if (pd->sign->sign == sign) {
if (pd->sign_info->sign == sign) {
ret = g_list_prepend(ret, pd);
}
}
@ -880,13 +882,11 @@ add_points(GswePlanetData *planet_data, GsweMoment *moment)
gswe_moment_calculate_planet(moment, planet_data->planet_info->planet, NULL);
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign->element))) + planet_data->planet_info->points;
g_hash_table_replace(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign->element), GINT_TO_POINTER(point));
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign_info->element))) + planet_data->planet_info->points;
g_hash_table_replace(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign_info->element), GINT_TO_POINTER(point));
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign->quality)));
point += planet_data->planet_info->points;
g_hash_table_replace(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign->quality), GINT_TO_POINTER(point));
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign_info->quality))) + planet_data->planet_info->points;
g_hash_table_replace(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign_info->quality), GINT_TO_POINTER(point));
}
static void

View File

@ -96,13 +96,6 @@ GsweTimestamp *gswe_full_moon_base_date;
*/
G_DEFINE_QUARK(gswe-error-quark, gswe_error);
void
gswe_free_sign_info(gpointer sign_info)
{
g_free(((GsweSignInfo *)sign_info)->name);
g_free(sign_info);
}
void
gswe_free_house_system_info(gpointer house_system_info)
{
@ -155,7 +148,7 @@ gswe_init(void)
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MC, -1, FALSE, _("Midheaven"), 5.0, 1);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VERTEX, -1, FALSE, _("Vertex"), 2.0, 0);
gswe_sign_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_sign_info);
gswe_sign_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_sign_info_unref);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_ARIES, _("Aries"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_CARDINAL);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_TAURUS, _("Taurus"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_FIX);