//----------------------------------------------------------------------------- // V12 Engine // // Copyright (c) 2001 GarageGames.Com // Portions Copyright (c) 2001 by Sierra Online, Inc. //----------------------------------------------------------------------------- #include "ts/tsShapeConstruct.h" #include "console/consoleTypes.h" #include "Core/fileStream.h" #include "Core/bitStream.h" IMPLEMENT_CO_DATABLOCK_V1(TSShapeConstructor); const char * TSShapeConstructor::csmShapeDirectory = "shapes/"; S32 gNumTransforms = 0; S32 gRotTransforms = 0; S32 gTransTransforms = 0; TSShapeConstructor::TSShapeConstructor() { mShape = NULL; for (S32 i = 0; iload(fileBuf); if(!bool(hShape)) return false; if (hShape->getSequencesConstructed()) return true; // we want to write into the resource: TSShape * shape = const_cast((const TSShape*)hShape); Stream * f; for (S32 i=0; ifindSequence(nameStart)) // continue; // } // look for sequences in same directory as shapes... dSprintf(fileBuf, sizeof(fileBuf), "%s%s", csmShapeDirectory, mSequence[i]); // spaces and tabs indicate the end of the file name: char * terminate1 = dStrchr(fileBuf,' '); char * terminate2 = dStrchr(fileBuf,'\t'); if (terminate1 && terminate2) // select the earliest one: *(terminate1openStream(fileBuf); if (!f || f->getStatus() != Stream::Ok) { Con::errorf(ConsoleLogEntry::General,"Missing sequence %s for %s",mSequence[i],mShape); continue; } if (!shape->importSequences(f) || f->getStatus()!=Stream::Ok) { Con::errorf(ConsoleLogEntry::General,"Load sequence %s failed for %s",mSequence[i],mShape); return false; } ResourceManager->closeStream(f); // if there was a space or tab in mSequence[i], then a new name was supplied for it // change it here...will still be in fileBuf if (terminate1 || terminate2) { // select the latter one: char * nameStart = terminate1sequences.last().nameIndex = shape->findName(nameStart); if (shape->sequences.last().nameIndex == -1) { shape->sequences.last().nameIndex = shape->names.size(); shape->names.increment(); shape->names.last() = StringTable->insert(nameStart,false); } } } else break; } hShape->setSequencesConstructed(true); return true; } void TSShapeConstructor::packData(BitStream* stream) { Parent::packData(stream); stream->writeString(mShape); S32 count = 0; for (S32 b=0; bwriteInt(count,NumSequenceBits); for (S32 i=0; iwriteString(mSequence[i]); } void TSShapeConstructor::unpackData(BitStream* stream) { Parent::unpackData(stream); mShape = stream->readSTString(); S32 i = 0, count = stream->readInt(NumSequenceBits); for (; ireadSTString(); while (i