/usr/share/ecere/extras/tiles/sequence.ec is in ecere-extras 0.44.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | /****************************************************************************
ECERE Tile Engine
Copyright (c) 1997-2001 Jerome Jacovella-St-Louis
All Rights Reserved.
sequence.c - Sprite Sequence System
****************************************************************************/
import "ecere"
struct SequenceFrame
{
uint16 frame,wait,walk;
uint16 hit;
};
struct Sequence
{
uint16 numEvents;
uint16 *numFrames;
SequenceFrame **frames;
};
void SequenceFree(Sequence *sequence)
{
if(sequence)
{
int c;
if(sequence->frames)
{
for(c=0; c<sequence->numEvents; c++)
{
if(sequence->frames[c])
delete sequence->frames[c];
}
delete sequence->frames;
}
if(sequence->numFrames)
delete sequence->numFrames;
delete sequence;
}
}
Sequence * SequenceInit(uint16 numEvents)
{
Sequence * result = null;
Sequence * sequence = new0 Sequence[1];
if(sequence)
{
sequence->numEvents = numEvents;
sequence->numFrames = new0 uint16[numEvents];
if(sequence->numFrames)
{
sequence->frames = new0 SequenceFrame *[numEvents];
if(sequence->frames)
result = sequence;
}
}
if(!result)
SequenceFree(sequence);
return result;
}
bool SequenceLoadTable(Sequence **sequences, int count, const char * fileName)
{
bool result = false;
File f = FileOpen(fileName, read);
FillBytes(sequences, 0, sizeof(Sequence *) * count);
if(f)
{
int c;
result = true;
for(c=0; c<count; c++)
{
uint16 numEvents = 0;
Sequence * sequence;
if(f.Read(&numEvents, sizeof(uint16), 1) && (sequence = SequenceInit(numEvents)) )
{
int e;
sequences[c] = sequence;
for(e=0; e<numEvents; e++)
{
if(f.Read(&sequence->numFrames[e],sizeof(uint16), 1))
{
if(sequence->numFrames[e])
{
sequence->frames[e] = new0 SequenceFrame[sequence->numFrames[e]];
if(sequence->frames[e])
{
int r;
for(r=0; r<sequence->numFrames[e]; r++)
{
if(!f.Read(&sequence->frames[e][r].frame,sizeof(uint16), 1) ||
!f.Read(&sequence->frames[e][r].wait, sizeof(uint16), 1) ||
!f.Read(&sequence->frames[e][r].walk, sizeof(uint16), 1) ||
!f.Read(&sequence->frames[e][r].hit, sizeof(uint16), 1))
{ sequences[c] = null; break; }
}
}
else { sequences[c] = null; break; }
}
}
else { sequences[c] = null; break; }
}
if(!sequences[c])
{
result = false;
SequenceFree(sequence);
break;
}
}
}
if(!result)
{
for(c = 0; c<count; c++)
{
if(sequences[c])
{
SequenceFree(sequences[c]);
sequences[c] = null;
}
}
Logf("Error reading sequence table file (%s).\n", fileName);
}
delete f;
}
else
Logf("Couldn't open sequence table file (%s).\n", fileName);
return result;
}
void SequenceSaveTable(Sequence **sequences, int count, char *fileName)
{
File f = FileOpen(fileName, write);
if(f)
{
int c;
for(c=0; c<count; c++)
{
int e;
Sequence * sequence = sequences[c];
f.Write(&sequence->numEvents, sizeof(uint16), 1);
for(e=0; e<sequence->numEvents; e++)
{
int r;
f.Write(&sequence->numFrames[e],sizeof(uint16), 1);
for(r = 0; r<sequence->numFrames[e]; r++)
{
f.Write(&sequence->frames[e][r].frame,sizeof(uint16), 1);
f.Write(&sequence->frames[e][r].wait, sizeof(uint16), 1);
f.Write(&sequence->frames[e][r].walk, sizeof(uint16), 1);
f.Write(&sequence->frames[e][r].hit, sizeof(uint16), 1);
}
}
}
delete f;
}
}
Sequence *SequenceLoad(char *fileName)
{
Sequence * result = null;
File f = FileOpen(fileName, read);
if(f)
{
Sequence * sequence;
uint16 numEvents = 0;
if(f.Read(&numEvents, sizeof(uint16), 1) &&
(sequence = SequenceInit(numEvents)) )
{
int e;
result = sequence;
for(e=0; e<sequence->numEvents; e++)
{
int r;
if(f.Read(&sequence->numFrames[e],sizeof(uint16), 1))
{
if(sequence->numFrames[e])
{
if((sequence->frames[e] = new0 SequenceFrame[sequence->numFrames[e]]))
{
for(r = 0; r<sequence->numFrames[e]; r++)
{
if(!f.Read(&sequence->frames[e][r].frame,sizeof(uint16), 1) ||
!f.Read(&sequence->frames[e][r].wait, sizeof(uint16), 1) ||
!f.Read(&sequence->frames[e][r].walk, sizeof(uint16), 1) ||
!f.Read(&sequence->frames[e][r].hit, sizeof(uint16), 1) )
{ result = null; break; }
}
}
else { result = null; break; }
}
}
else { result = null; break; }
}
if(!result)
SequenceFree(sequence);
}
delete f;
if(!result)
Logf("Error loading sequence file (%s).\n", fileName);
}
else
Logf("Couldn't open sequence file (%s).\n", fileName);
return result;
}
void SequenceSave(Sequence *sequence, char *filename)
{
File f;
uint16 e,r;
f=FileOpen(filename, write);
if(!f) return;
f.Write(&sequence->numEvents, sizeof(uint16), 1);
for(e=0; e<sequence->numEvents; e++)
{
f.Write(&sequence->numFrames[e],sizeof(uint16), 1);
for(r=0; r<sequence->numFrames[e]; r++)
{
f.Write(&sequence->frames[e][r].frame,sizeof(uint16), 1);
f.Write(&sequence->frames[e][r].wait, sizeof(uint16), 1);
f.Write(&sequence->frames[e][r].walk, sizeof(uint16), 1);
f.Write(&sequence->frames[e][r].hit, sizeof(uint16), 1);
}
}
delete f;
}
|