static Entry resources[MAX_RESOURCES];
static Block *blocks[MAX_RESOURCES];
+static int s_start, s_end;
+
static int check_header (Stream *r) {
assert(r != NULL);
char ident[4];
ok = 0;
}
}
+ s_start = WADRES_find("S_START");
+ s_end = WADRES_find("S_END");
return ok;
}
return n_resources;
}
+int WADRES_findsprite (const char n[4], int s, int d, char *dir) {
+ s += 'A';
+ d += '0';
+ for (int i = s_start + 1; i < s_end; i++) {
+ char a, b;
+ char *wn = resources[i].name;
+ if (cp866_strncasecmp(wn, n, 4) == 0 && (wn[4] == s || wn[6] == s)) {
+ a = wn[4] == s ? wn[5] : 0;
+ b = wn[6] == s ? wn[7] : 0;
+ if (a == '0' || b == '0' || a == d || b == d) {
+ if (dir != NULL) {
+ *dir = (a != '0' && b == '0') || (a != d && b == d);
+ }
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
Stream *WADRES_getbasereader (int id) {
assert(id >= 0 && id < n_resources);
return wads[resources[id].f];
int WADRES_find (const char name[8]);
int WADRES_maxids (void);
+// Get sprite resource id.
+// Sprite name has following format:
+// (nnnn)('A'+s)('0'+d)[('A'+s)('0'+d)]
+// Letter means animation frame
+// A for first, B for second...
+// Number means direction
+// 0 = front
+// 1 = left
+// 2 = right
+// Optional part means that this file can be used for differnt frame/direction.
+// Note that if found FRONT direction for this frame than it UNCONDITIONALLY used.
+// Note that search performed between markers S_START and S_END in order as paced in wad.
+// int n[4] -- sprite name
+// int s -- sprite frame
+// int d -- sprite direction
+// char *dir -- out flag "alternative used"
+int WADRES_findsprite (const char n[4], int s, int d, char *dir);
+
Stream *WADRES_getbasereader (int id);
long WADRES_getoffset (int id);
long WADRES_getsize (int id);
}
int F_getsprid (const char n[4], int s, int d, char *dir) {
- s += 'A';
- d += '0';
- for (int i = s_start + 1; i < s_end; i++) {
- char wn[8];
- byte a, b;
- WADRES_getname(i, wn);
- if (cp866_strncasecmp(wn, n, 4) == 0 && (wn[4] == s || wn[6] == s)) {
- a = wn[4] == s ? wn[5] : 0;
- b = wn[6] == s ? wn[7] : 0;
- if (a == '0' || b == '0' || a == d || b == d) {
- if (dir != NULL) {
- *dir = (a != '0' && b == '0') || (a != d && b == d);
- }
- return i;
- }
- }
+ int i = WADRES_findsprite(n, s, d, dir);
+ if (i == -1) {
+ ERR_fatal("F_getsprid: image %.4s%c%c not found", n, s, d);
}
- ERR_fatal("F_getsprid: image %.4s%c%c not found", n, s, d);
- return -1;
+ return i;
}
int F_getreslen (int r) {
}
int F_getsprid (const char n[4], int s, int d, char *dir) {
- s += 'A';
- d += '0';
- for (int i = s_start + 1; i < s_end; i++) {
- char wn[8];
- byte a, b;
- WADRES_getname(i, wn);
- if (cp866_strncasecmp(wn, n, 4) == 0 && (wn[4] == s || wn[6] == s)) {
- a = wn[4] == s ? wn[5] : 0;
- b = wn[6] == s ? wn[7] : 0;
- if (a == '0' || b == '0' || a == d || b == d) {
- if (dir != NULL) {
- *dir = (a != '0' && b == '0') || (a != d && b == d);
- }
- return i;
- }
- }
+ int i = WADRES_findsprite(n, s, d, dir);
+ if (i == -1) {
+ ERR_fatal("F_getsprid: image %.4s%c%c not found", n, s, d);
}
- ERR_fatal("F_getsprid: image %.4s%c%c not found", n, s, d);
- return -1;
+ return i;
}
int F_getreslen (int r) {
}
int F_getsprid (const char n[4], int s, int d, char *dir) {
- s += 'A';
- d += '0';
- for (int i = s_start + 1; i < s_end; i++) {
- char wn[8];
- byte a, b;
- WADRES_getname(i, wn);
- if (cp866_strncasecmp(wn, n, 4) == 0 && (wn[4] == s || wn[6] == s)) {
- a = wn[4] == s ? wn[5] : 0;
- b = wn[6] == s ? wn[7] : 0;
- if (a == '0' || b == '0' || a == d || b == d) {
- if (dir != NULL) {
- *dir = (a != '0' && b == '0') || (a != d && b == d);
- }
- return i;
- }
- }
+ int i = WADRES_findsprite(n, s, d, dir);
+ if (i == -1) {
+ ERR_fatal("F_getsprid: image %.4s%c%c not found", n, s, d);
}
- ERR_fatal("F_getsprid: image %.4s%c%c not found", n, s, d);
- return -1;
+ return i;
}
int F_getreslen (int r) {