Source Code (Use browser search to find items of interest.)
Class Index
ksokoban'InternalCollections (./kdegames/ksokoban/InternalCollections.H:28)
class InternalCollections {
public:
InternalCollections();
~InternalCollections();
int collections();
LevelCollection *operator[](int n);
private:
static int configCollection2Real(int collection);
static int realCollection2Config(int collection);
Array<LevelCollection *> collections_;
char *data_;
};
ksokoban'InternalCollections::configCollection2Real() (./kdegames/ksokoban/InternalCollections.C:23)
InternalCollections::configCollection2Real (int collection) {
for (int i=0; i < (int) (sizeof (collection_save_id) / sizeof (int)); i++) {
if (collection_save_id[i] == collection) return i;
}
return 0;
}
int
ksokoban'InternalCollections::realCollection2Config() (./kdegames/ksokoban/InternalCollections.C:31)
InternalCollections::realCollection2Config(int collection) {
assert(collection < (int) (sizeof (collection_save_id) / sizeof (int)));
return collection_save_id[collection];
}
ksokoban'InternalCollections::InternalCollections() (./kdegames/ksokoban/InternalCollections.C:37)
InternalCollections::InternalCollections() {
int datasize, levelnum=0;
#ifdef USE_LIBZ
data_ = (char *) malloc(BUFSIZE);
if (data_ == NULL) abort();
datasize = BUFSIZE;
uncompress ((unsigned char *) data_, (long unsigned int *) &datasize, level_data_, sizeof (level_data_));
data_ = (char *) realloc(data_, datasize);
if (data_ == NULL) abort ();
#else
datasize = sizeof (level_data_);
data_ = (char *) malloc(datasize);
if (data_ == NULL) abort();
memcpy(data_, level_data_, datasize);
#endif
int start=0, end=0, name=0;
enum {NAME, DATA} state=NAME;
while (end < datasize) {
switch (state) {
case NAME:
if (data_[end] == '\n') {
data_[end] = '\0';
state = DATA;
}
end++;
start = end;
break;
case DATA:
if (isalpha(data_[end])) {
collections_.add(new LevelCollection(data_+start, end-start, data_+name, collection_save_id[levelnum]));
//printf("Level found: '%s'\n", data_+name);
levelnum++;
name = end;
state = NAME;
}
end++;
break;
default:
assert(0);
}
}
if (state == DATA) {
collections_.add(new LevelCollection(data_+start, end-start, data_+name, collection_save_id[levelnum]));
//printf("***Level found: '%s'\n", data_+name);
}
//printf("numlevels: %d/%d\n", levelnum+1, collections_.size());
}
ksokoban'InternalCollections::~InternalCollections() (./kdegames/ksokoban/InternalCollections.C:90)
InternalCollections::~InternalCollections() {
for (int i=0; i<collections_.size(); i++) {
delete collections_[i];
}
free(data_);
}
int
ksokoban'InternalCollections::collections() (./kdegames/ksokoban/InternalCollections.C:99)
InternalCollections::collections() {
return collections_.size();
}
LevelCollection *