44
14
time_t **scoretimes);
45
</pre></div><div class="refsect1" lang="en"><a name="id2723752"></a><h2>Description</h2><p>
15
</pre></div><div class="refsect1" lang="en"><a name="id2556664"></a><h2>Description</h2><p>
46
16
The routines in this module provide a simple way to keep track of users' scores
49
19
In order to acommodate file ownership permissions, the game application should
50
be installed setgid <i class="wordasword">games</i> and the scoretable should
51
only be writable by the <i class="wordasword">games</i> group. The program
52
should call <a href="libgnome-gnome-score.html#gnome-score-init"><tt class="function">gnome_score_init()</tt></a> as soon as possible inside the <tt class="function">main()</tt> routine.
20
be installed setgid <em class="wordasword">games</em> and the scoretable should
21
only be writable by the <em class="wordasword">games</em> group. The program
22
should call <a href="libgnome-gnome-score.html#gnome-score-init"><code class="function">gnome_score_init()</code></a> as soon as possible inside the <code class="function">main()</code> routine.
53
23
This will open a pair of pipes to a child process which can read and write the
54
24
score table and then will drop the group privileges of the main program back to
55
25
the user's normal group id.
56
</p></div><div class="refsect1" lang="en"><a name="id2723803"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2723808"></a><h3><a name="gnome-score-init"></a>gnome_score_init ()</h3><a class="indexterm" name="id2723819"></a><pre class="programlisting">gint gnome_score_init (const gchar *gamename);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><tt class="literal">gnome_score_init</tt> is deprecated and should not be used in newly-written code.</p></div><p>
26
</p></div><div class="refsect1" lang="en"><a name="id2556715"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2556720"></a><h3><a name="gnome-score-init"></a>gnome_score_init ()</h3><a class="indexterm" name="id2556731"></a><pre class="programlisting">gint gnome_score_init (const gchar *gamename);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_score_init</code> is deprecated and should not be used in newly-written code.</p></div><p>
57
27
GNOME games should call this routine as the first statement
58
in <tt class="function">main()</tt> if they have been installed setgid to the "games" group. It
28
in <code class="function">main()</code> if they have been installed setgid to the "games" group. It
59
29
performs the intialization required to later record information in the
60
30
scores table and then drops the groups privileges.</p><p>
62
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>gamename</tt></i>�:</span></td><td> Identifies the game name.
63
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <tt class="literal">0</tt> on success, returns <tt class="literal">-1</tt> on failure.
64
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2723915"></a><h3><a name="gnome-score-log"></a>gnome_score_log ()</h3><a class="indexterm" name="id2723926"></a><pre class="programlisting">gint gnome_score_log (gfloat score,
32
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>gamename</code></em>�:</span></td><td> Identifies the game name.
33
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>�:</span></td><td> <code class="literal">0</code> on success, returns <code class="literal">-1</code> on failure.
34
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2556829"></a><h3><a name="gnome-score-log"></a>gnome_score_log ()</h3><a class="indexterm" name="id2556840"></a><pre class="programlisting">gint gnome_score_log (gfloat score,
65
35
const gchar *level,
66
gboolean higher_to_lower_score_order);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><tt class="literal">gnome_score_log</tt> is deprecated and should not be used in newly-written code.</p></div><p>
36
gboolean higher_to_lower_score_order);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_score_log</code> is deprecated and should not be used in newly-written code.</p></div><p>
67
37
Logs a score entry for the user. You should call this every time a game
68
38
ends. This function takes care of working out whether the user's score made
69
39
it into the ten best scores and, if so, records it in the table.</p><p>
71
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>score</tt></i>�:</span></td><td> The score achieved by the user in this game
72
</td></tr><tr><td><span class="term"><i class="parameter"><tt>level</tt></i>�:</span></td><td> The level on which the score was obtained
73
</td></tr><tr><td><span class="term"><i class="parameter"><tt>higher_to_lower_score_order</tt></i>�:</span></td><td> Set to <tt class="literal">TRUE</tt> if high scores are better than
41
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>score</code></em>�:</span></td><td> The score achieved by the user in this game
42
</td></tr><tr><td><span class="term"><em class="parameter"><code>level</code></em>�:</span></td><td> The level on which the score was obtained
43
</td></tr><tr><td><span class="term"><em class="parameter"><code>higher_to_lower_score_order</code></em>�:</span></td><td> Set to <code class="literal">TRUE</code> if high scores are better than
75
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <tt class="literal">0</tt> on failure or the status from the gnome-score helper
45
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>�:</span></td><td> <code class="literal">0</code> on failure or the status from the gnome-score helper
77
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2724057"></a><h3><a name="gnome-score-get-notable"></a>gnome_score_get_notable ()</h3><a class="indexterm" name="id2724068"></a><pre class="programlisting">gint gnome_score_get_notable (const gchar *gamename,
47
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2556973"></a><h3><a name="gnome-score-get-notable"></a>gnome_score_get_notable ()</h3><a class="indexterm" name="id2556984"></a><pre class="programlisting">gint gnome_score_get_notable (const gchar *gamename,
78
48
const gchar *level,
81
time_t **scoretimes);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><tt class="literal">gnome_score_get_notable</tt> is deprecated and should not be used in newly-written code.</p></div><p>
82
Fetches the most notable players on <i class="parameter"><tt>gamename</tt></i> at level <i class="parameter"><tt>level</tt></i>.</p><p>
51
time_t **scoretimes);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_score_get_notable</code> is deprecated and should not be used in newly-written code.</p></div><p>
52
Fetches the most notable players on <em class="parameter"><code>gamename</code></em> at level <em class="parameter"><code>level</code></em>.</p><p>
84
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>gamename</tt></i>�:</span></td><td> The name of the game we want to fetch information from.
85
</td></tr><tr><td><span class="term"><i class="parameter"><tt>level</tt></i>�:</span></td><td> The level for which we want to pull information.
86
</td></tr><tr><td><span class="term"><i class="parameter"><tt>names</tt></i>�:</span></td><td> An array of strings is returned at the address pointed here
87
</td></tr><tr><td><span class="term"><i class="parameter"><tt>scores</tt></i>�:</span></td><td> An array of gfloats is returned at the address pointed here
88
</td></tr><tr><td><span class="term"><i class="parameter"><tt>scoretimes</tt></i>�:</span></td><td> An array of time_t is returned at the address pointed here
89
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> The number of scores returned. The <i class="parameter"><tt>names</tt></i>, <i class="parameter"><tt>scores</tt></i> and <i class="parameter"><tt>scoretime</tt></i>
90
pointers point to regions that were allocated with <tt class="function">g_malloc()</tt> with the
54
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>gamename</code></em>�:</span></td><td> The name of the game we want to fetch information from.
55
</td></tr><tr><td><span class="term"><em class="parameter"><code>level</code></em>�:</span></td><td> The level for which we want to pull information.
56
</td></tr><tr><td><span class="term"><em class="parameter"><code>names</code></em>�:</span></td><td> An array of strings is returned at the address pointed here
57
</td></tr><tr><td><span class="term"><em class="parameter"><code>scores</code></em>�:</span></td><td> An array of gfloats is returned at the address pointed here
58
</td></tr><tr><td><span class="term"><em class="parameter"><code>scoretimes</code></em>�:</span></td><td> An array of time_t is returned at the address pointed here
59
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>�:</span></td><td> The number of scores returned. The <em class="parameter"><code>names</code></em>, <em class="parameter"><code>scores</code></em> and <em class="parameter"><code>scoretime</code></em>
60
pointers point to regions that were allocated with <code class="function">g_malloc()</code> with the
92
62
</td></tr></tbody></table></div></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="libgnome-gnome-url.html"><b><<�gnome-url</b></a></td><td align="right"><a accesskey="n" href="ch01s04.html"><b>Miscellaneous�>></b></a></td></tr></table></body></html>