static int deactivatePlat(thinker_t *th, void *context) { plat_t *plat = (plat_t *) th; deactivateplatparams_t *params = (deactivateplatparams_t *) context; #if __JHEXEN__ // For THE one with the tag. if(plat->tag == params->tag) { // Destroy it. stopPlat(plat); params->count++; return true; // Stop iteration. } #else // For one with the tag and not in stasis. if(plat->tag == (int) params->tag && !Thinker_InStasis(&plat->thinker)) { // Put it in stasis. plat->oldState = plat->state; Thinker_SetStasis(&plat->thinker, true); params->count++; } #endif return false; // Continue iteration. }
static int activatePlat(thinker_t *th, void *context) { plat_t *plat = (plat_t *) th; activateplatparams_t *params = (activateplatparams_t *) context; if(plat->tag == (int) params->tag && Thinker_InStasis(&plat->thinker)) { plat->state = plat->oldState; Thinker_SetStasis(&plat->thinker, false); params->count++; } return false; // Contiue iteration. }
static int SV_ReadPlat(plat_t *plat) { /* Original Heretic format: typedef struct { thinker_t thinker; // was 12 bytes Sector *sector; fixed_t speed; fixed_t low; fixed_t high; int wait; int count; platstate_e status; // was 32bit int platstate_e oldStatus; // was 32bit int boolean crush; int tag; plattype_e type; // was 32bit int } v13_plat_t; */ byte temp[SIZEOF_V13_THINKER_T]; // Padding at the start (an old thinker_t struct) Reader_Read(svReader, &temp, SIZEOF_V13_THINKER_T); // Start of used data members. // A 32bit pointer to sector, serialized. plat->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader)); if(!plat->sector) Con_Error("tc_plat: bad sector number\n"); plat->speed = FIX2FLT(Reader_ReadInt32(svReader)); plat->low = FIX2FLT(Reader_ReadInt32(svReader)); plat->high = FIX2FLT(Reader_ReadInt32(svReader)); plat->wait = Reader_ReadInt32(svReader); plat->count = Reader_ReadInt32(svReader); plat->state = Reader_ReadInt32(svReader); plat->oldState = Reader_ReadInt32(svReader); plat->crush = Reader_ReadInt32(svReader); plat->tag = Reader_ReadInt32(svReader); plat->type = Reader_ReadInt32(svReader); plat->thinker.function = T_PlatRaise; if(!(temp + V13_THINKER_T_FUNC_OFFSET)) Thinker_SetStasis(&plat->thinker, true); P_ToXSector(plat->sector)->specialData = T_PlatRaise; return true; // Add this thinker. }
static int SV_ReadCeiling(ceiling_t *ceiling) { /* Original Heretic format: typedef struct { thinker_t thinker; ///< 12 bytes ceilingtype_e type; ///< 32bit int Sector* sector; fixed_t bottomheight, topheight; fixed_t speed; boolean crush; int direction; /// 1= up, 0= waiting, -1= down int tag' int olddirection; } v13_ceiling_t; */ byte temp[SIZEOF_V13_THINKER_T]; // Padding at the start (an old thinker_t struct) Reader_Read(svReader, &temp, SIZEOF_V13_THINKER_T); // Start of used data members. ceiling->type = Reader_ReadInt32(svReader); // A 32bit pointer to sector, serialized. ceiling->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader)); if(!ceiling->sector) Con_Error("tc_ceiling: bad sector number\n"); ceiling->bottomHeight = FIX2FLT(Reader_ReadInt32(svReader)); ceiling->topHeight = FIX2FLT(Reader_ReadInt32(svReader)); ceiling->speed = FIX2FLT(Reader_ReadInt32(svReader)); ceiling->crush = Reader_ReadInt32(svReader); ceiling->state = (Reader_ReadInt32(svReader) == -1? CS_DOWN : CS_UP); ceiling->tag = Reader_ReadInt32(svReader); ceiling->oldState = (Reader_ReadInt32(svReader) == -1? CS_DOWN : CS_UP); ceiling->thinker.function = T_MoveCeiling; if(!(temp + V13_THINKER_T_FUNC_OFFSET)) Thinker_SetStasis(&ceiling->thinker, true); P_ToXSector(ceiling->sector)->specialData = T_MoveCeiling; return true; // Add this thinker. }
int plat_t::read(MapStateReader *msr) { Reader *reader = msr->reader(); int mapVersion = msr->mapVersion(); #if __JHEXEN__ if(mapVersion >= 4) #else if(mapVersion >= 5) #endif { // Note: the thinker class byte has already been read. /*int ver =*/ Reader_ReadByte(reader); // version byte. thinker.function = T_PlatRaise; #if !__JHEXEN__ // Should we put this into stasis? if(mapVersion == 5) { if(!Reader_ReadByte(reader)) Thinker_SetStasis(&thinker, true); } #endif type = plattype_e(Reader_ReadByte(reader)); sector = (Sector *)P_ToPtr(DMU_SECTOR, Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); speed = FIX2FLT(Reader_ReadInt32(reader)); low = (float) Reader_ReadInt16(reader); high = (float) Reader_ReadInt16(reader); wait = Reader_ReadInt32(reader); count = Reader_ReadInt32(reader); state = platstate_e(Reader_ReadByte(reader)); oldState = platstate_e(Reader_ReadByte(reader)); crush = (dd_bool) Reader_ReadByte(reader); tag = Reader_ReadInt32(reader); } else { // Its in the old format which serialized plat_t // Padding at the start (an old thinker_t struct) int32_t junk[4]; // sizeof thinker_t Reader_Read(reader, (byte *)junk, 16); // Start of used data members. // A 32bit pointer to sector, serialized. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); speed = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); low = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); high = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); wait = Reader_ReadInt32(reader); count = Reader_ReadInt32(reader); state = platstate_e(Reader_ReadInt32(reader)); oldState = platstate_e(Reader_ReadInt32(reader)); crush = Reader_ReadInt32(reader); tag = Reader_ReadInt32(reader); type = plattype_e(Reader_ReadInt32(reader)); thinker.function = T_PlatRaise; #if !__JHEXEN__ if(junk[2] == 0) { Thinker_SetStasis(&thinker, true); } #endif } P_ToXSector(sector)->specialData = this; return true; // Add this thinker. }