Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef XASH_BIG_ENDIAN
- // swap all fields in ibuffer starting given field (4byte type)
- #define SWAP_INTS(type, startfield) \
- for( i = offsetof(type, startfield)/4; i < sizeof(type)/4; i++ ) \
- LittleLongSW(ibuffer[i])
- // swap all fields in sbuffer starting given field (2byte type)
- #define SWAP_SHORTS(type, startfield) \
- for( i = offsetof(type, startfield)/2; i < sizeof(type)/2; i++ ) \
- LittleShortSW(sbuffer[i])
- /*
- =========================
- Mod_StudioBigEndian
- Swap all model fields for big endian system
- =========================
- */
- void Mod_StudioBigEndian( model_t *model, byte *buffer )
- {
- studiohdr_t *phdr = buffer;
- int *ibuffer = buffer;
- short *sbuffer;
- int i,j,k, bodyCount = 0;
- mstudiomodel_t *pSubModel;
- if( LittleLong(phdr->ident) != IDSTUDIOHEADER )
- return;
- LittleLongSW(phdr->ident);
- LittleLongSW(phdr->length);
- SWAP_INTS(studiohdr_t,eyeposition);
- for( j = 0; j < phdr->numbones; j++ )
- {
- ibuffer = (byte*)phdr + phdr->boneindex + sizeof(mstudiobone_t) * j;
- SWAP_INTS(mstudiobone_t,parent);
- }
- for( j = 0; j < phdr->numbonecontrollers; j++ )
- {
- ibuffer = (byte*)phdr + phdr->bonecontrollerindex + sizeof(mstudiobonecontroller_t) * j;
- SWAP_INTS(mstudiobonecontroller_t,bone);
- }
- for( j = 0; j < phdr->numhitboxes; j++ )
- {
- ibuffer = (byte*)phdr + phdr->hitboxindex + sizeof(mstudiobbox_t) * j;
- SWAP_INTS(mstudiobbox_t,bone);
- }
- for( j = 0; j < phdr->numtextures; j++ )
- {
- ibuffer = (byte*)phdr + phdr->textureindex + sizeof(mstudiotexture_t) * j;
- SWAP_INTS(mstudiotexture_t,flags);
- }
- for( j = 0; j < phdr->numseq; j++ )
- {
- mstudioseqdesc_t *pseqdesc = (byte*)phdr + phdr->seqindex + sizeof(mstudioseqdesc_t) * j;
- mstudioanim_t *panim;//, *panimend;
- int m;
- ibuffer = (byte*)phdr + phdr->seqindex + sizeof(mstudioseqdesc_t) * j;
- SWAP_INTS(mstudioseqdesc_t,fps);
- for( k = 0; k < pseqdesc->numpivots; k++ )
- {
- ibuffer = (byte*)phdr + pseqdesc->pivotindex + sizeof(mstudiopivot_t) * j;
- SWAP_INTS(mstudiopivot_t,org);
- }
- // preload and swap external seqgroups
- if( pseqdesc->seqgroup )
- {
- mstudioseqgroup_t *pseqgroup;
- fs_offset_t filesize;
- byte *buf;
- cache_user_t *paSequences;
- if( !model )
- continue; // not loading model
- pseqgroup = (mstudioseqgroup_t *)((byte *)phdr + phdr->seqgroupindex) + pseqdesc->seqgroup;
- paSequences = (cache_user_t *)model->submodels;
- if( paSequences == NULL )
- {
- paSequences = (cache_user_t *)Mem_Alloc( com_studiocache, MAXSTUDIOGROUPS * sizeof( cache_user_t ));
- model->submodels = (void *)paSequences;
- }
- // check for already loaded
- if( !paSequences[pseqdesc->seqgroup].data )
- {
- string filepath, modelname, modelpath;
- FS_FileBase( model->name, modelname );
- FS_ExtractFilePath( model->name, modelpath );
- // NOTE: here we build real sub-animation filename because stupid user may rename model without recompile
- Q_snprintf( filepath, sizeof( filepath ), "%s/%s%i%i.mdl", modelpath, modelname, pseqdesc->seqgroup / 10, pseqdesc->seqgroup % 10 );
- buf = FS_LoadFile( filepath, &filesize, false );
- if( !buf || !filesize )
- Host_Error( "StudioGetAnim: can't load %s\n", filepath );
- else if( IDSEQGRPHEADER != LittleLong(*(uint *)buf ))
- Host_Error( "StudioGetAnim: %s is corrupted\n", filepath );
- MsgDev( D_INFO, "loading: %s\n", filepath );
- paSequences[pseqdesc->seqgroup].data = Mem_Alloc( com_studiocache, filesize );
- Q_memcpy( paSequences[pseqdesc->seqgroup].data, buf, (size_t)filesize );
- Mem_Free( buf );
- }
- panim = (mstudioanim_t *)((byte *)paSequences[pseqdesc->seqgroup].data + pseqdesc->animindex);
- //panimend = (mstudioanim_t *)((byte *)paSequences[pseqdesc->seqgroup].data + filesize);
- }
- else
- {
- panim = (byte*)phdr + pseqdesc->animindex;
- //panimend = pseqdesc;
- }
- // swap animations
- for( m = 0; m < phdr->numbones * pseqdesc->numblends; m++ )
- {
- /*mstudioanimvalue_t *panim1 = panimend;
- if( m < phdr->numbones * pseqdesc->numblends -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement