示例#1
0
void FreeMatRefs(SMtl *m) {
	int k;
	if (m->appdata) XMFreeAndZero(&m->appdata);
	for (k=0; k<NMAPTYPES; k++) {
		if (m->map[k]) {
			FreeMapDataRefs(&m->map[k]->map);
			FreeMapDataRefs(&m->map[k]->mask);
			XMFreeAndZero((void **)&m->map[k]);
			}
		}
	}
示例#2
0
void FreeMapDataRefs(MapData *md) {
//	Cubmap *cm,*nextcm;
	switch(md->kind) {
		case 0:
			XMFreeAndZero(&md->p.tex.sxp_data);
			break;
		case 1:
#if 0
			if (md->p.ref.acb.flags&AC_ON) {
				for (cm =(Cubmap *)md->p.ref.bm; cm!=NULL; cm=nextcm) {
					nextcm = cm->next;
					XMFree(cm);
					}
				}
			else{
				char ext[5];
				split_fext(md->name,NULL,ext);
				if(stricmp(ext,".CUB")==0) {
					if (md->p.ref .bm!=NULL)
						XMFree(md->p.ref.bm);
					}
				}
#endif
			break;
		}	
	}
示例#3
0
//===========================================================
int load_app_data(FILE *stream,void **pdata, int size) {
	ULONG *plong;
	if (*pdata!=NULL) 
		XMFreeAndZero(pdata);
	*pdata = (void *)XMAlloc(size+4);
	if (*pdata==NULL) {
		MtlError();
		return(0);	
		}		
	plong = (ULONG *)(*pdata);
	plong[0] = size;
	RDERR((void *)&plong[1],size);
	return(1);
	}
示例#4
0
int get_sxp_data(FILE *stream, int n, int size, int isMask) {
	ULONG **pp,*ptr;
	Mapping *m = loadmtl->map[n];
#ifdef DBGLDMLI
	if (dbgldmli)
		printf("GET_SXP_DATA: n=%d, size = %d, isMask = %d, m=%X\n",
			n,size,isMask,m);
#endif
	if (size==0) return(1);
	if (m==NULL) {
		m = NewMapping(n,0);
		if (m==NULL) {
			MtlError();
			return(0);
			}
		loadmtl->map[n] = m;
		}
	if (isMask)
		pp = (ULONG **)&m->mask.p.tex.sxp_data;
	else 
		pp = (ULONG **)&m->map.p.tex.sxp_data;
	if (*pp!=NULL) XMFreeAndZero((void **)pp);
	ptr = (ULONG *)XMAlloc(size+4);
	if (ptr==NULL)  {
		MtlError();
		return(0);   
		}
	ptr[0] = size;

#ifdef DBGLDMLI
	if (dbgldmli)
		printf("  sxp_data: addr = %X,  size = %X\n", ptr, ptr[0]);
#endif
	RDERR(&ptr[1],size);
	*pp = ptr;
	return(1);
	}