BytesSlice MappedFile::data() const { return BytesSlice(_data, _size); }
void read_from(ReadSource in, objectActionType& action) { uint8_t section[24]; read(in, action.verb); read(in, action.reflexive); read(in, action.inclusiveFilter); read(in, action.exclusiveFilter); read(in, action.owner); read(in, action.delay); read(in, action.initialSubjectOverride); read(in, action.initialDirectOverride); in.shift(4); read(in, section, 24); BytesSlice sub(BytesSlice(section, 24)); switch (action.verb) { case kNoAction: case kSetDestination: case kActivateSpecial: case kActivatePulse: case kActivateBeam: case kNilTarget: break; case kCreateObject: case kCreateObjectSetDest: read(sub, action.argument.createObject); break; case kPlaySound: read(sub, action.argument.playSound); break; case kAlter: read(sub, action.argument.alterObject); break; case kMakeSparks: read(sub, action.argument.makeSparks); break; case kReleaseEnergy: read(sub, action.argument.releaseEnergy); break; case kLandAt: read(sub, action.argument.landAt); break; case kEnterWarp: read(sub, action.argument.enterWarp); break; case kDisplayMessage: read(sub, action.argument.displayMessage); break; case kChangeScore: read(sub, action.argument.changeScore); break; case kDeclareWinner: read(sub, action.argument.declareWinner); break; case kDie: read(sub, action.argument.killObject); break; case kColorFlash: read(sub, action.argument.colorFlash); break; case kDisableKeys: case kEnableKeys: read(sub, action.argument.keys); break; case kSetZoom: read(sub, action.argument.zoom); break; case kComputerSelect: read(sub, action.argument.computerSelect); break; case kAssumeInitialObject: read(sub, action.argument.assumeInitial); break; } }
void ScopedFd::push(size_t num, uint8_t byte) { for (int i: range(num)) { static_cast<void>(i); push(BytesSlice(&byte, 1)); } }
void read_from(ReadSource in, baseObjectType& object) { uint8_t section[32]; read(in, object.attributes); if ((object.attributes & kIsSelfAnimated) && (object.attributes & kShapeFromDirection)) { object.attributes ^= kShapeFromDirection; } read(in, object.baseClass); read(in, object.baseRace); read(in, object.price); read(in, object.offenseValue); read(in, object.destinationClass); read(in, object.maxVelocity); read(in, object.warpSpeed); read(in, object.warpOutDistance); read(in, object.initialVelocity); read(in, object.initialVelocityRange); read(in, object.mass); read(in, object.maxThrust); read(in, object.health); read(in, object.damage); read(in, object.energy); read(in, object.initialAge); read(in, object.initialAgeRange); read(in, object.naturalScale); read(in, object.pixLayer); read(in, object.pixResID); read(in, object.tinySize); read(in, object.shieldColor); in.shift(1); read(in, object.initialDirection); read(in, object.initialDirectionRange); read(in, object.pulse); read(in, object.beam); read(in, object.special); read(in, object.pulsePositionNum); read(in, object.beamPositionNum); read(in, object.specialPositionNum); read(in, object.pulsePosition, kMaxWeaponPosition); read(in, object.beamPosition, kMaxWeaponPosition); read(in, object.specialPosition, kMaxWeaponPosition); read(in, object.friendDefecit); read(in, object.dangerThreshold); read(in, object.specialDirection); read(in, object.arriveActionDistance); read(in, object.destroyAction); read(in, object.destroyActionNum); read(in, object.expireAction); read(in, object.expireActionNum); read(in, object.createAction); read(in, object.createActionNum); read(in, object.collideAction); read(in, object.collideActionNum); read(in, object.activateAction); read(in, object.activateActionNum); read(in, object.arriveAction); read(in, object.arriveActionNum); read(in, section, 32); read(in, object.buildFlags); read(in, object.orderFlags); read(in, object.buildRatio); read(in, object.buildTime); read(in, object.skillNum); read(in, object.skillDen); read(in, object.skillNumAdj); read(in, object.skillDenAdj); read(in, object.pictPortraitResID); in.shift(6); read(in, object.internalFlags); BytesSlice sub(BytesSlice(section, 32)); if (object.attributes & kShapeFromDirection) { read(sub, object.frame.rotation); } else if (object.attributes & kIsSelfAnimated) { read(sub, object.frame.animation); } else if (object.attributes & kIsBeam) { read(sub, object.frame.beam); } else { read(sub, object.frame.weapon); } }