source: abuse/branches/lol/src/seq.cpp @ 732

Last change on this file since 732 was 732, checked in by Sam Hocevar, 8 years ago

build: SDL2 compilation fixes.

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