source: abuse/trunk/src/seq.cpp @ 527

Last change on this file since 527 was 527, checked in by Sam Hocevar, 11 years ago

imlib: some cleaning up in trans_image before I templatise half of it.

File size: 2.3 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com or
8 *  Jonathan Clark.
9 */
10
11#include "config.h"
12
13#include "common.h"
14
15#include "seq.h"
16#include "lisp.h"
17
18size_t sequence::MemUsage()
19{
20    size_t t = 0;
21    for (int i = 0; i < total; i++)
22        if (cache.loaded(seq[i]))
23            t += cache.fig(seq[i])->MemUsage();
24    return t;
25}
26
27int sequence::cache_in()
28{
29  int i;
30  for (i=0; i<total; i++)
31  {
32    cache.note_need(seq[i]);
33  }
34  return 1;
35}
36
37sequence::sequence(char *filename, void *pict_list, void *advance_list)
38{
39  if (item_type(pict_list)==L_STRING)
40    total=1;
41  else
42    total = ((LList *)pict_list)->GetLength();
43
44  seq=(int *) malloc(sizeof(int)*total);
45  if (item_type(pict_list)==L_STRING)
46    seq[0]=cache.reg_object(filename,(LObject *)pict_list,SPEC_CHARACTER2,1);
47  else
48  {
49    int i;
50    for (i=0; i<total; i++)
51    {
52      seq[i]=cache.reg_object(filename,lcar(pict_list),SPEC_CHARACTER2,1);
53      pict_list=lcdr(pict_list);
54    }
55  }
56}
57
58sequence::~sequence()
59{
60  free(seq);
61}
62
63/*sequence::sequence(char *filename, char *picts)
64{
65  char t[100],*s=picts,imname[100];
66  int i,j;
67  total=0;
68
69  // first count the images
70  while (token_type(s)!=sRIGHT_PAREN)
71  {
72    if (token_type(s)==sLEFT_PAREN)
73    {
74      get_token(s,t);    // left paren
75      get_token(s,t);    // seq
76      get_token(s,t);    // name
77      i=get_number(s);
78      total+=get_number(s)-i+1;
79      get_token(s,t);    // right paren
80    }
81    else
82    { get_token(s,t);
83      total++;
84    }
85  }
86
87
88  s=picts;
89  seq=(int *) malloc(sizeof(int)*total);
90
91  for (i=0; i<total; )
92  {
93    if (get_token(s,t)==sLEFT_PAREN)
94    {
95      get_token(s,t);      // left paren
96      if (strcmp(t,"seq"))
97      {
98    printf("Expected seq at %s\n",s);
99    exit(0);
100      }
101      get_token(s,t);
102      int start,end;
103      start=get_number(s);
104      end=get_number(s);
105      for (j=start; j<=end; j++)
106      {
107    sprintf(imname,"%s%04d.pcx",t,j);
108    seq[i++]=cache.reg(filename,imname,SPEC_CHARACTER,1);
109      }
110      get_token(s,t);      // right paren
111    }
112    else
113      seq[i++]=cache.reg(filename,t,SPEC_CHARACTER,1);
114  }
115}*/
116
117
118
119
120
Note: See TracBrowser for help on using the repository browser.