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

Last change on this file since 481 was 481, checked in by Sam Hocevar, 10 years ago

Fuck the history, I'm renaming all .hpp files to .h for my own sanity.

File size: 2.2 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12#include "seq.h"
13#include "macs.h"
14#include "lisp.h"
15
16int sequence::size()
17{
18  int t=0;
19  for (int i=0;i<total;i++)
20  {
21    if (cache.loaded(seq[i]))
22      t+=cache.fig(seq[i])->size();
23  }
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=list_length(pict_list);
43
44  seq=(int *) malloc(sizeof(int)*total);
45  if (item_type(pict_list)==L_STRING)
46    seq[0]=cache.reg_object(filename,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.