mirror of
https://github.com/aap/librw.git
synced 2025-12-19 00:49:50 +00:00
started implementing linked lists
This commit is contained in:
@@ -28,17 +28,11 @@ RslMatrixSetIdentity(RslMatrix *matrix)
|
||||
void
|
||||
rslObjectHasFrameSetFrame(RslObjectHasFrame *object, RslFrame *f)
|
||||
{
|
||||
if(object->object.parent){
|
||||
object->lFrame.prev->next = object->lFrame.next;
|
||||
object->lFrame.next->prev = object->lFrame.prev;
|
||||
}
|
||||
object->object.parent = f;
|
||||
if(object->object.parent)
|
||||
rslLinkListRemoveLLLink(&object->lFrame);
|
||||
rslObjectSetParent(object, f);
|
||||
if(f){
|
||||
object->lFrame.prev = &f->objectList.link;
|
||||
object->lFrame.next = f->objectList.link.next;
|
||||
f->objectList.link.next->prev = &object->lFrame;
|
||||
f->objectList.link.next = &object->lFrame;
|
||||
|
||||
rslLinkListAddLLLink(&f->objectList, &object->lFrame);
|
||||
f->root->object.privateFlags |= 1;
|
||||
f->object.privateFlags |= 2;
|
||||
}
|
||||
@@ -49,8 +43,7 @@ RslFrameCreate(void)
|
||||
{
|
||||
RslFrame *f = new RslFrame;
|
||||
rslObjectInitialize(&f->object, 0, 0);
|
||||
f->objectList.link.prev = &f->objectList.link;
|
||||
f->objectList.link.next = &f->objectList.link;
|
||||
rslLinkListInitialize(&f->objectList);
|
||||
RslMatrixSetIdentity(&f->modelling);
|
||||
RslMatrixSetIdentity(&f->ltm);
|
||||
f->child = NULL;
|
||||
@@ -327,8 +320,7 @@ RslClumpCreate(void)
|
||||
{
|
||||
RslClump *clump = new RslClump;
|
||||
rslObjectInitialize(&clump->object, 2, 0);
|
||||
clump->atomicList.link.prev = &clump->atomicList.link;
|
||||
clump->atomicList.link.next = &clump->atomicList.link;
|
||||
rslLinkListInitialize(&clump->atomicList);
|
||||
return clump;
|
||||
}
|
||||
|
||||
@@ -373,10 +365,7 @@ RslClumpStreamRead(Stream *stream)
|
||||
RslClump*
|
||||
RslClumpAddAtomic(RslClump *clump, RslAtomic *a)
|
||||
{
|
||||
a->inClumpLink.prev = &clump->atomicList.link;
|
||||
a->inClumpLink.next = clump->atomicList.link.next;
|
||||
clump->atomicList.link.next->prev = &a->inClumpLink;
|
||||
clump->atomicList.link.next = &a->inClumpLink;
|
||||
rslLinkListAddLLLink(&clump->atomicList, &a->inClumpLink);
|
||||
a->clump = clump;
|
||||
return clump;
|
||||
}
|
||||
@@ -387,7 +376,7 @@ RslClumpForAllAtomics(RslClump *clump, RslAtomicCallBack callback, void *pData)
|
||||
RslAtomic *a;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&clump->atomicList.link);
|
||||
link != &clump->atomicList.link;
|
||||
link != rslLinkListGetTerminator(&clump->atomicList);
|
||||
link = link->next){
|
||||
a = rslLLLinkGetData(link, RslAtomic, inClumpLink);
|
||||
if(callback(a, pData) == NULL)
|
||||
@@ -402,7 +391,7 @@ RslClumpGetNumAtomics(RslClump *clump)
|
||||
int32 n = 0;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&clump->atomicList.link);
|
||||
link != &clump->atomicList.link;
|
||||
link != rslLinkListGetTerminator(&clump->atomicList);
|
||||
link = link->next)
|
||||
n++;
|
||||
return n;
|
||||
@@ -561,23 +550,17 @@ RslTexDictionaryCreate(void)
|
||||
RslTexDictionary *dict = new RslTexDictionary;
|
||||
memset(dict, 0, sizeof(RslTexDictionary));
|
||||
rslObjectInitialize(&dict->object, 6, 0);
|
||||
dict->texturesInDict.link.prev = &dict->texturesInDict.link;
|
||||
dict->texturesInDict.link.next = &dict->texturesInDict.link;
|
||||
rslLinkListInitialize(&dict->texturesInDict);
|
||||
return dict;
|
||||
}
|
||||
|
||||
RslTexture*
|
||||
RslTexDictionaryAddTexture(RslTexDictionary *dict, RslTexture *tex)
|
||||
{
|
||||
if(tex->dict){
|
||||
tex->lInDictionary.prev->next = tex->lInDictionary.next;
|
||||
tex->lInDictionary.next->prev = tex->lInDictionary.prev;
|
||||
}
|
||||
if(tex->dict)
|
||||
rslLinkListRemoveLLLink(&tex->lInDictionary);
|
||||
tex->dict = dict;
|
||||
tex->lInDictionary.prev = &dict->texturesInDict.link;
|
||||
tex->lInDictionary.next = dict->texturesInDict.link.next;
|
||||
dict->texturesInDict.link.next->prev = &tex->lInDictionary;
|
||||
dict->texturesInDict.link.next = &tex->lInDictionary;
|
||||
rslLinkListAddLLLink(&dict->texturesInDict, &tex->lInDictionary);
|
||||
return tex;
|
||||
}
|
||||
|
||||
@@ -587,7 +570,7 @@ RslTexDictionaryForAllTextures(RslTexDictionary *dict, RslTextureCallBack fpCall
|
||||
RslTexture *t;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&dict->texturesInDict.link);
|
||||
link != &dict->texturesInDict.link;
|
||||
link != rslLinkListGetTerminator(&dict->texturesInDict);
|
||||
link = link->next){
|
||||
t = rslLLLinkGetData(link, RslTexture, lInDictionary);
|
||||
if(fpCallBack(t, pData) == NULL)
|
||||
|
||||
@@ -75,26 +75,43 @@ struct RslLLLink
|
||||
RslLLLink *prev;
|
||||
};
|
||||
|
||||
#define rslLLLinkGetData(linkvar,type,entry) \
|
||||
((type*)(((uint8*)(linkvar))-offsetof(type,entry)))
|
||||
#define rslLLLinkGetNext(linkvar) \
|
||||
((linkvar)->next)
|
||||
#define rslLLLinkGetPrevious(linkvar) \
|
||||
((linkvar)->prev)
|
||||
#define rslLLLinkInitialize(linkvar) \
|
||||
((linkvar)->prev = (RslLLLink*)NULL, \
|
||||
(linkvar)->next = (RslLLLink*)NULL)
|
||||
#define rslLLLinkAttached(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
struct RslLinkList
|
||||
{
|
||||
RslLLLink link;
|
||||
};
|
||||
|
||||
#define rslLLLinkGetData(linkvar,type,entry) \
|
||||
((type *)(((uint8 *)(linkvar))-offsetof(type,entry)))
|
||||
#define rslLinkListInitialize(list) \
|
||||
((list)->link.next = ((RslLLLink*)(list)), \
|
||||
(list)->link.prev = ((RslLLLink*)(list)))
|
||||
#define rslLinkListEmpty(list) \
|
||||
(((list)->link.next) == (&(list)->link))
|
||||
#define rslLinkListAddLLLink(list, linkvar) \
|
||||
((linkvar)->next = (list)->link.next, \
|
||||
(linkvar)->prev = (&(list)->link), \
|
||||
((list)->link.next)->prev = (linkvar), \
|
||||
(list)->link.next = (linkvar) )
|
||||
#define rslLinkListRemoveLLLink(linkvar) \
|
||||
(((linkvar)->prev)->next = (linkvar)->next, \
|
||||
((linkvar)->next)->prev = (linkvar)->prev)
|
||||
#define rslLinkListGetFirstLLLink(list) \
|
||||
((list)->link.next)
|
||||
#define rslLinkListGetLastLLLink(list) \
|
||||
((list)->link.prev)
|
||||
#define rslLinkListGetTerminator(list) \
|
||||
(&((list)->link))
|
||||
|
||||
#define rslLLLinkGetNext(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
#define rslLLLinkGetPrevious(linkvar) \
|
||||
((linkvar)->prev)
|
||||
|
||||
#define rslLLLinkInitialize(linkvar) \
|
||||
( (linkvar)->prev = (RslLLLink *)NULL, \
|
||||
(linkvar)->next = (RslLLLink *)NULL )
|
||||
|
||||
#define rslLLLinkAttached(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
struct RslObject {
|
||||
uint8 type;
|
||||
|
||||
@@ -407,7 +407,7 @@ convertClump(RslClump *c)
|
||||
if(parent >= 0)
|
||||
rwframes[parent]->addChild(rwf);
|
||||
}
|
||||
rwc->parent = rwframes[0];
|
||||
rwc->object.parent = rwframes[0];
|
||||
|
||||
rwc->numAtomics = RslClumpGetNumAtomics(c);
|
||||
rwc->atomicList = new Atomic*[rwc->numAtomics];
|
||||
@@ -418,7 +418,7 @@ convertClump(RslClump *c)
|
||||
rwa = convertAtomic(alist[i]);
|
||||
rwc->atomicList[i] = rwa;
|
||||
int32 fi = findPointer(alist[i]->object.object.parent, (void**)frameList.frames, frameList.numFrames);
|
||||
rwa->frame = rwframes[fi];
|
||||
rwa->object.parent = rwframes[fi];
|
||||
rwa->clump = rwc;
|
||||
}
|
||||
|
||||
@@ -823,14 +823,14 @@ main(int argc, char *argv[])
|
||||
rslstr->relocate();
|
||||
|
||||
bool32 largefile;
|
||||
largefile = rslstr->dataSize > 0x100000;
|
||||
largefile = rslstr->dataSize > 0x1000000;
|
||||
|
||||
if(rslstr->ident == WRLD_IDENT && largefile){ // hack
|
||||
world = (World*)rslstr->data;
|
||||
|
||||
int len = strlen(argv[1])+1;
|
||||
int len = strlen(argv[0])+1;
|
||||
char filename[1024];
|
||||
strncpy(filename, argv[1], len);
|
||||
strncpy(filename, argv[0], len);
|
||||
filename[len-3] = 'i';
|
||||
filename[len-2] = 'm';
|
||||
filename[len-1] = 'g';
|
||||
@@ -874,16 +874,21 @@ main(int argc, char *argv[])
|
||||
stream.close();
|
||||
}else if(rslstr->ident == WRLD_IDENT){ // sector
|
||||
sector = (Sector*)rslstr->data;
|
||||
printf("resources\n");
|
||||
for(uint32 i = 0; i < sector->numResources; i++){
|
||||
OverlayResource *r = §or->resources[i];
|
||||
printf(" %d %p\n", r->id, r->raw);
|
||||
}
|
||||
printf("placement\n");
|
||||
fprintf(stderr, "%d\n",sector->unk1);
|
||||
//printf("resources\n");
|
||||
//for(uint32 i = 0; i < sector->numResources; i++){
|
||||
// OverlayResource *r = §or->resources[i];
|
||||
// printf(" %d %p\n", r->id, r->raw);
|
||||
//}
|
||||
//printf("placement\n");
|
||||
if(sector->unk1 == 0)
|
||||
return 0;
|
||||
Placement *p;
|
||||
for(p = sector->sectionA; p < sector->sectionEnd; p++){
|
||||
printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
}
|
||||
//for(p = sector->sectionA; p < sector->sectionEnd; p++){
|
||||
// printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
//}
|
||||
for(p = sector->sectionA; p < sector->sectionEnd; p++)
|
||||
printf("%f %f %f\n", p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
}else if(rslstr->ident == MDL_IDENT){
|
||||
uint8 *p;
|
||||
p = *rslstr->hashTab;
|
||||
|
||||
Reference in New Issue
Block a user