source: golgotha/src/golg/selection.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.5 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "selection.hh"
10#include "memory/malloc.hh"
11#include "g1_object.hh"
12
13g1_selection_list::~g1_selection_list()
14{
15  if (list)
16    i4_free(list);
17}
18
19g1_selection_list::g1_selection_list()
20{
21  list=0;
22  list_size=0;
23  t=0;
24}
25
26void g1_selection_list::add(g1_object_class *o)
27{
28  if (t==list_size)
29  {
30    list_size+=64;
31    list=(g1_object_class **)i4_realloc(list,
32                                       list_size * sizeof(g1_object_class *),
33                                       "selection list");
34  }
35
36  list[t++]=o;
37  o->flags |= (~g1_object_class::SELECTED);
38}
39
40void g1_selection_list::remove(g1_object_class *o)
41{
42  for (w32 i=0; i<t; i++)
43  {
44    if (list[i]==o)
45    {
46      t--;
47      memmove(list+i, list+i+1, t-i);
48      o->flags &= (~g1_object_class::SELECTED);
49      return ;
50    }
51  }
52  i4_error("list remove : object not found");
53}
54
55void g1_selection_list::clear()
56{
57  for (w32 i=0; i<t; i++)
58    list[i]->flags &= (~g1_object_class::SELECTED);
59  t=0;
60}
Note: See TracBrowser for help on using the repository browser.