// // P_UnArchiveSpecials // void P_UnArchiveSpecials(void) { // read in saved thinkers while (true) { byte tclass = saveg_read8(); switch (tclass) { case tc_endspecials: // end of list return; case tc_ceiling: { ceiling_t *ceiling = Z_Malloc(sizeof(*ceiling), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_ceiling_t(ceiling); ceiling->sector->ceilingdata = ceiling; ceiling->thinker.function = T_MoveCeiling; P_AddThinker(&ceiling->thinker); P_AddActiveCeiling(ceiling); break; } case tc_door: { vldoor_t *door = Z_Malloc(sizeof(*door), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_vldoor_t(door); door->sector->ceilingdata = door; door->thinker.function = T_VerticalDoor; P_AddThinker(&door->thinker); break; } case tc_floor: { floormove_t *floor = Z_Malloc(sizeof(*floor), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_floormove_t(floor); floor->sector->floordata = floor; floor->thinker.function = T_MoveFloor; P_AddThinker(&floor->thinker); break; } case tc_plat: { plat_t *plat = Z_Malloc(sizeof(*plat), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_plat_t(plat); plat->sector->floordata = plat; P_AddThinker(&plat->thinker); P_AddActivePlat(plat); break; } case tc_flash: { lightflash_t *flash = Z_Malloc(sizeof(*flash), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_lightflash_t(flash); flash->thinker.function = T_LightFlash; P_AddThinker(&flash->thinker); break; } case tc_strobe: { strobe_t *strobe = Z_Malloc(sizeof(*strobe), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_strobe_t(strobe); strobe->thinker.function = T_StrobeFlash; P_AddThinker(&strobe->thinker); break; } case tc_glow: { glow_t *glow = Z_Malloc(sizeof(*glow), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_glow_t(glow); glow->thinker.function = T_Glow; P_AddThinker(&glow->thinker); break; } case tc_fireflicker: { fireflicker_t *fireflicker = Z_Malloc(sizeof(*fireflicker), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_fireflicker_t(fireflicker); fireflicker->thinker.function = T_FireFlicker; P_AddThinker(&fireflicker->thinker); break; } case tc_elevator: { elevator_t *elevator = Z_Malloc(sizeof(*elevator), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_elevator_t(elevator); elevator->sector->ceilingdata = elevator; elevator->thinker.function = T_MoveElevator; P_AddThinker(&elevator->thinker); break; } case tc_scroll: { scroll_t *scroll = Z_Malloc(sizeof(*scroll), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_scroll_t(scroll); scroll->thinker.function = T_Scroll; P_AddThinker(&scroll->thinker); break; } case tc_pusher: { pusher_t *pusher = Z_Malloc(sizeof(*pusher), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_pusher_t(pusher); pusher->thinker.function = T_Pusher; pusher->source = P_GetPushThing(pusher->affectee); P_AddThinker(&pusher->thinker); break; } case tc_button: { button_t *button = Z_Malloc(sizeof(*button), PU_LEVEL, NULL); saveg_read_pad(); saveg_read_button_t(button); P_StartButton(button->line, button->where, button->btexture, button->btimer); break; } default: I_Error("This savegame is invalid."); } } }
// // P_UnArchiveSpecials // void P_UnArchiveSpecials (void) { byte tclass; ceiling_t* ceiling; vldoor_t* door; floormove_t* floor; plat_t* plat; lightflash_t* flash; strobe_t* strobe; glow_t* glow; // read in saved thinkers while (1) { tclass = saveg_read8(); switch (tclass) { case tc_endspecials: return; // end of list case tc_ceiling: saveg_read_pad(); ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL); saveg_read_ceiling_t(ceiling); ceiling->sector->specialdata = ceiling; if (ceiling->thinker.function.acp1) ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; P_AddThinker (&ceiling->thinker); P_AddActiveCeiling(ceiling); break; case tc_door: saveg_read_pad(); door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL); saveg_read_vldoor_t(door); door->sector->specialdata = door; door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; P_AddThinker (&door->thinker); break; case tc_floor: saveg_read_pad(); floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL); saveg_read_floormove_t(floor); floor->sector->specialdata = floor; floor->thinker.function.acp1 = (actionf_p1)T_MoveFloor; P_AddThinker (&floor->thinker); break; case tc_plat: saveg_read_pad(); plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL); saveg_read_plat_t(plat); plat->sector->specialdata = plat; if (plat->thinker.function.acp1) plat->thinker.function.acp1 = (actionf_p1)T_PlatRaise; P_AddThinker (&plat->thinker); P_AddActivePlat(plat); break; case tc_flash: saveg_read_pad(); flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL); saveg_read_lightflash_t(flash); flash->thinker.function.acp1 = (actionf_p1)T_LightFlash; P_AddThinker (&flash->thinker); break; case tc_strobe: saveg_read_pad(); strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL); saveg_read_strobe_t(strobe); strobe->thinker.function.acp1 = (actionf_p1)T_StrobeFlash; P_AddThinker (&strobe->thinker); break; case tc_glow: saveg_read_pad(); glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL); saveg_read_glow_t(glow); glow->thinker.function.acp1 = (actionf_p1)T_Glow; P_AddThinker (&glow->thinker); break; default: I_Error ("P_UnarchiveSpecials:Unknown tclass %i " "in savegame",tclass); } } }
void P_UnArchiveSpecials(void) { byte tclass; ceiling_t *ceiling; vldoor_t *door; floormove_t *floor; plat_t *plat; lightflash_t *flash; strobe_t *strobe; glow_t *glow; // read in saved thinkers while (1) { tclass = SV_ReadByte(); switch (tclass) { case tc_endspecials: return; // end of list case tc_ceiling: ceiling = Z_Malloc(sizeof(*ceiling), PU_LEVEL, NULL); saveg_read_ceiling_t(ceiling); ceiling->sector->specialdata = T_MoveCeiling; // ??? ceiling->thinker.function = T_MoveCeiling; P_AddThinker(&ceiling->thinker); P_AddActiveCeiling(ceiling); break; case tc_door: door = Z_Malloc(sizeof(*door), PU_LEVEL, NULL); saveg_read_vldoor_t(door); door->sector->specialdata = door; door->thinker.function = T_VerticalDoor; P_AddThinker(&door->thinker); break; case tc_floor: floor = Z_Malloc(sizeof(*floor), PU_LEVEL, NULL); saveg_read_floormove_t(floor); floor->sector->specialdata = T_MoveFloor; floor->thinker.function = T_MoveFloor; P_AddThinker(&floor->thinker); break; case tc_plat: plat = Z_Malloc(sizeof(*plat), PU_LEVEL, NULL); saveg_read_plat_t(plat); plat->sector->specialdata = T_PlatRaise; // In the original Heretic code this was a conditional "fix" // of the thinker function, but the save code (above) decides // whether to save a T_PlatRaise based on thinker function // anyway, so it can't be NULL. Having the conditional causes // a bug, as our saveg_read_thinker_t sets these to NULL. // if (plat->thinker.function) plat->thinker.function = T_PlatRaise; P_AddThinker(&plat->thinker); P_AddActivePlat(plat); break; case tc_flash: flash = Z_Malloc(sizeof(*flash), PU_LEVEL, NULL); saveg_read_lightflash_t(flash); flash->thinker.function = T_LightFlash; P_AddThinker(&flash->thinker); break; case tc_strobe: strobe = Z_Malloc(sizeof(*strobe), PU_LEVEL, NULL); saveg_read_strobe_t(strobe); strobe->thinker.function = T_StrobeFlash; P_AddThinker(&strobe->thinker); break; case tc_glow: glow = Z_Malloc(sizeof(*glow), PU_LEVEL, NULL); saveg_read_glow_t(glow); glow->thinker.function = T_Glow; P_AddThinker(&glow->thinker); break; default: I_Error("P_UnarchiveSpecials:Unknown tclass %i " "in savegame", tclass); } } }