📄 p_saveg.c
字号:
memcpy (plat, save_p, sizeof(*plat)); save_p += sizeof(*plat); plat->sector = §ors[(int)plat->sector]; plat->sector->floordata = 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: PADSAVEP(); flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL); memcpy (flash, save_p, sizeof(*flash)); save_p += sizeof(*flash); flash->sector = §ors[(int)flash->sector]; flash->thinker.function.acp1 = (actionf_p1)T_LightFlash; P_AddThinker (&flash->thinker); break; case tc_strobe: PADSAVEP(); strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL); memcpy (strobe, save_p, sizeof(*strobe)); save_p += sizeof(*strobe); strobe->sector = §ors[(int)strobe->sector]; strobe->thinker.function.acp1 = (actionf_p1)T_StrobeFlash; P_AddThinker (&strobe->thinker); break; case tc_glow: PADSAVEP(); glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL); memcpy (glow, save_p, sizeof(*glow)); save_p += sizeof(*glow); glow->sector = §ors[(int)glow->sector]; glow->thinker.function.acp1 = (actionf_p1)T_Glow; P_AddThinker (&glow->thinker); break; case tc_fireflicker: PADSAVEP(); fireflicker = Z_Malloc (sizeof(*fireflicker), PU_LEVEL, NULL); memcpy (fireflicker, save_p, sizeof(*fireflicker)); save_p += sizeof(*fireflicker); fireflicker->sector = §ors[(int)fireflicker->sector]; fireflicker->thinker.function.acp1 = (actionf_p1)T_FireFlicker; P_AddThinker (&fireflicker->thinker); break; case tc_elevator: PADSAVEP(); elevator = Z_Malloc (sizeof(elevator_t), PU_LEVEL, NULL); memcpy (elevator, save_p, sizeof(elevator_t)); save_p += sizeof(elevator_t); elevator->sector = §ors[(int)elevator->sector]; elevator->sector->floordata = elevator; //jff 2/22/98 elevator->sector->ceilingdata = elevator; //jff 2/22/98 elevator->thinker.function.acp1 = (actionf_p1) T_MoveElevator; P_AddThinker (&elevator->thinker); break; case tc_scroll: scroll = Z_Malloc (sizeof(scroll_t), PU_LEVEL, NULL); memcpy (scroll, save_p, sizeof(scroll_t)); save_p += sizeof(scroll_t); scroll->thinker.function.acp1 = (actionf_p1) T_Scroll; P_AddThinker(&scroll->thinker); break; case tc_friction: friction = Z_Malloc (sizeof(friction_t), PU_LEVEL, NULL); memcpy (friction, save_p, sizeof(friction_t)); save_p += sizeof(friction_t); friction->thinker.function.acp1 = (actionf_p1) T_Friction; P_AddThinker(&friction->thinker); break; case tc_pusher: pusher = Z_Malloc (sizeof(pusher_t), PU_LEVEL, NULL); memcpy (pusher, save_p, sizeof(pusher_t)); save_p += sizeof(pusher_t); pusher->thinker.function.acp1 = (actionf_p1) T_Pusher; pusher->source = P_GetPushThing(pusher->affectee); P_AddThinker(&pusher->thinker); break; default: I_Error ("P_UnarchiveSpecials:Unknown tclass %i " "in savegame",tclass); } } // use info field (value = oldposition) to relink mobjs for (currentthinker = thinkercap.next ; currentthinker != &thinkercap ; currentthinker=currentthinker->next) { if( currentthinker->function.acp1 == (actionf_p1)P_MobjThinker ) { mobj = (mobj_t *)currentthinker; if (mobj->tracer) { mobj->tracer = FindNewPosition(mobj->tracer); if( !mobj->tracer ) DEBFILE(va("tracer not found on %d\n",mobj->type)); } if (mobj->target) { mobj->target = FindNewPosition(mobj->target); if( !mobj->target ) DEBFILE(va("target not found on %d\n",mobj->target)); } } }}//// P_FinishMobjs// SoM: Delay this until AFTER we load fragglescript because FS needs this// data!void P_FinishMobjs(){ thinker_t* currentthinker; mobj_t* mobj; // put info field there real value for (currentthinker = thinkercap.next ; currentthinker != &thinkercap ; currentthinker=currentthinker->next) { if( currentthinker->function.acp1 == (actionf_p1)P_MobjThinker ) { mobj = (mobj_t *)currentthinker; mobj->info = &mobjinfo[mobj->type]; } }}//// P_ArchiveSpecials//// BP: added : itemrespawnqueue//void P_ArchiveSpecials (void){ int i; // BP: added save itemrespawn queue for deathmatch i = iquetail; while (iquehead != i) { WRITELONG(save_p,itemrespawnque[i]-mapthings); WRITELONG(save_p,itemrespawntime[i]); i = (i+1)&(ITEMQUESIZE-1); } // end delimiter WRITELONG(save_p,0xffffffff);}//// P_UnArchiveSpecials//void P_UnArchiveSpecials (void){ int i; // BP: added save itemrespawn queue for deathmatch iquetail = iquehead = 0 ; while ((i = READLONG(save_p))!=0xffffffff) { itemrespawnque[iquehead]=&mapthings[i]; itemrespawntime[iquehead++]=READLONG(save_p); }}/////////////////////////////////////////////////////////////////////////////// BIG NOTE FROM SOM!//// SMMU/MBF use the CheckSaveGame function to dynamically expand the savegame// buffer which would eliminate all limits on savegames... Could/Should we// use this method?/////////////////////////////////////////////////////////////////////////////// SoM: Added FraggleScript stuff.// Save all the neccesary FraggleScript data.// we need to save the levelscript(all global// variables) and the runningscripts (scripts// currently suspended)/***************** save the levelscript *************/// make sure we remember all the global// variables.void P_ArchiveLevelScript(){ short *short_p; int num_variables = 0; int i; // all we really need to do is save the variables // count the variables first // count number of variables num_variables = 0; for(i=0; i<VARIABLESLOTS; i++) { svariable_t *sv = levelscript.variables[i]; while(sv && sv->type != svt_label) { num_variables++; sv = sv->next; } } //CheckSaveGame(sizeof(short)); short_p = (short *) save_p; *short_p++ = num_variables; // write num_variables save_p = (char*) short_p; // restore save_p // go thru hash chains, store each variable for(i=0; i<VARIABLESLOTS; i++) { // go thru this hashchain svariable_t *sv = levelscript.variables[i]; // once we get to a label there can be no more actual // variables in the list to store while(sv && sv->type != svt_label) { //CheckSaveGame(strlen(sv->name)+10); // 10 for type and safety // write svariable: name strcpy(save_p, sv->name); save_p += strlen(sv->name) + 1; // 1 extra for ending NULL // type *save_p++ = sv->type; // store type; switch(sv->type) // store depending on type { case svt_string: { //CheckSaveGame(strlen(sv->value.s)+5); // 5 for safety strcpy(save_p, sv->value.s); save_p += strlen(sv->value.s) + 1; break; } case svt_int: { long *long_p; //CheckSaveGame(sizeof(long)); long_p = (long *) save_p; *long_p++ = sv->value.i; save_p = (char *)long_p; break; } case svt_mobj: { ULONG *long_p; //CheckSaveGame(sizeof(long)); long_p = (ULONG *) save_p; *long_p++ = (ULONG)sv->value.mobj; save_p = (char *)long_p; break; } case svt_fixed: { fixed_t *fixed_p; fixed_p = (fixed_t *)save_p; *fixed_p++ = sv->value.fixed; save_p = (char *)fixed_p; break; } } sv = sv->next; } }}void P_UnArchiveLevelScript(){ short *short_p; int i; int num_variables; // free all the variables in the current levelscript first for(i=0; i<VARIABLESLOTS; i++) { svariable_t *sv = levelscript.variables[i]; while(sv && sv->type != svt_label) { svariable_t *next = sv->next; Z_Free(sv); sv = next; } levelscript.variables[i] = sv; // null or label } // now read the number of variables from the savegame file short_p = (short *)save_p; num_variables = *short_p++; save_p = (char *)short_p; for(i=0; i<num_variables; i++) { svariable_t *sv = Z_Malloc(sizeof(svariable_t), PU_LEVEL, 0); int hashkey; // name sv->name = Z_Strdup(save_p, PU_LEVEL, 0); save_p += strlen(sv->name) + 1; sv->type = *save_p++; switch(sv->type) // read depending on type { case svt_string: { sv->value.s = Z_Strdup(save_p, PU_LEVEL, 0); save_p += strlen(sv->value.s) + 1; break; } case svt_int: { long *long_p = (long *) save_p; sv->value.i = *long_p++; save_p = (char *)long_p; break; } case svt_mobj: { ULONG *long_p = (ULONG *) save_p; sv->value.mobj = FindNewPosition((mobj_t *)long_p); long_p++; save_p = (char *)long_p; break; } case svt_fixed: { fixed_t *fixed_p = (fixed_t *) save_p; sv->value.fixed = *fixed_p++; save_p = (char *)fixed_p; break; } default: break; } // link in the new variable hashkey = variable_hash(sv->name); sv->next = levelscript.variables[hashkey]; levelscript.variables[hashkey] = sv; }}/**************** save the runningscripts ***************/extern runningscript_t runningscripts; // t_script.crunningscript_t *new_runningscript(); // t_script.cvoid clear_runningscripts(); // t_script.c// save a given runningscriptvoid P_ArchiveRunningScript(runningscript_t *rs)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -