-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha_cache.cpp
63 lines (49 loc) · 1.41 KB
/
a_cache.cpp
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
#include <string.h>
#include <malloc.h>
#include "a_cache.h"
// -- Generic Cache Entry System --
// I suspect that this could be used for pretty much any portion of the BlackStar
// engine. With that in mind I have coded it in a pretty modular fashion. You can
// overload this class and put your own specific per-resource information in it.
// Unfortunately I didn't have a full understanding of constructors, and more spec-
// ifically constructor interitence, so there isn't one. Yet.
CacheEntry::~CacheEntry()
{
if(prev) prev->next = next;
if(next) next->prev = prev;
if(name) free(name);
}
bool CacheEntry::CheckFor(const CacheEntry *targ)
// See if the cache entry 'targ' exists in the given list!
// Returns: 0 if not found. 1 if found.
{
CacheEntry *cruise;
cruise = this;
while(cruise)
{ if(!strcmp(cruise->name, targ->name)) return 1;
cruise = cruise->next;
}
return 0;
}
bool CacheEntry::CheckFor(const char *res)
// See if the resource name 'res exists in the given cache list.
// Returns: 0 if not found. 1 if found.
{
CacheEntry *cruise;
cruise = this;
while(cruise)
{ if(!strcmp(cruise->name, res)) return 1;
cruise = cruise->next;
}
return 0;
}
void CacheEntry::FreeList()
{
CacheEntry *cruise;
cruise = this;
while(cruise)
{ CacheEntry *old = cruise->next;
delete cruise;
cruise = old;
}
}