[Freeciv-Dev] Re: Question about attributes
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Tue, Jan 08, 2002 at 07:26:05PM +0200, Teemu Kurppa wrote:
> On Tue, 8 Jan 2002, Raimar Falke wrote:
>
> > On Tue, Jan 08, 2002 at 02:51:30PM +0200, Teemu Kurppa wrote:
> > > This makes coding a little bit cumbersome compared to solution, in
> > > which persistent data is restored to client side data structures,
> > > when client reconnects.
> >
> > Can you save the client side data structures directly in the
> > attributes?
>
> With a current data structure, list, no. And I think that a list is a
> natural choice for markers. I'd like to keep them in list instead of
> an array.
You do something like this:
+struct tile_marker* find_marker_at(int x, int y)
+{
int i, size, markers;
struct tile_marker *p;
size=attr_player_get(ATTR_TILE_MARKERS, game.player_idx, 0, NULL);
markers=size/sizeof(struct tile_marker);
p=malloc(size);
attr_player_get(ATTR_TILE_MARKERS, game.player_idx, size, p);
for(i=0;i<markers;i++)
{
if(p[i]->x == x && p[i]->y == y) {
return marker_clone(p[i]); // needed because p gets freed
}
}
free(p);
}
and
+void add_marker(struct tile_marker* pnew)
{
int i, old_size, new_size, new_marker;
struct tile_marker *p;
old_size=attr_player_get(ATTR_TILE_MARKERS, game.player_idx, 0, NULL);
new_size=old_size+sizeof(struct tile_marker);
new_marker=old_size/sizeof(struct tile_marker);
p=malloc(new_size);
attr_player_get(ATTR_TILE_MARKERS, game.player_idx, old_size, p);
p[new_marker]->x=pnew->x;
p[new_marker]->y=pnew->y;
p[new_marker]->num=pnew->num;
attr_player_get(ATTR_TILE_MARKERS, game.player_idx, new_size, p);
}
> > > Another concern: I think that a client should flush attributes to a
> > > server, when a player decides to disconnect. Currently it flushes them
> > > only at the end of turn.
> >
> > Same as above: attributes aren't yet used. I agree. Note that you can
> > also manually flush them.
>
> Yeah I know, and attached "patch" will flush attributes, when player
> disconnects ;)
Applied.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Life is too short for reboots."
[Freeciv-Dev] Re: Question about attributes, Raimar Falke, 2002/01/08
- [Freeciv-Dev] Re: Question about attributes, Teemu Kurppa, 2002/01/08
- [Freeciv-Dev] Re: Question about attributes,
Raimar Falke <=
- [Freeciv-Dev] Re: Question about attributes, Teemu Kurppa, 2002/01/10
- [Freeciv-Dev] Re: Question about attributes, Raimar Falke, 2002/01/10
- [Freeciv-Dev] Re: Question about attributes, Jason Short, 2002/01/10
- [Freeciv-Dev] Re: Question about attributes, Raimar Falke, 2002/01/10
- [Freeciv-Dev] Re: Question about attributes, Jason Short, 2002/01/10
- [Freeciv-Dev] Re: Question about attributes, Raimar Falke, 2002/01/10
- [Freeciv-Dev] Re: Question about attributes, Mike Kaufman, 2002/01/10
- [Freeciv-Dev] Re: Question about attributes, Raimar Falke, 2002/01/10
|
|