⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p_saveg.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 5 页
字号:
            if( diff & MD_MOVECOUNT  )   WRITELONG (save_p, mobj->movecount   );            if( diff & MD_THRESHOLD  )   WRITELONG (save_p, mobj->threshold   );            if( diff & MD_LASTLOOK   )   WRITELONG (save_p, mobj->lastlook    );            if( diff & MD_TARGET     )   WRITEULONG(save_p, (ULONG)mobj->target      );            if( diff & MD_TRACER     )   WRITEULONG(save_p, (ULONG)mobj->tracer      );            if( diff & MD_FRICTION   )   WRITELONG (save_p, mobj->friction    );            if( diff & MD_MOVEFACTOR )   WRITELONG (save_p, mobj->movefactor  );            if( diff & MD_SPECIAL1   )   WRITELONG (save_p, mobj->special1    );            if( diff & MD_SPECIAL2   )   WRITELONG (save_p, mobj->special2    );        }        if (th->function.acv == (actionf_v)NULL)        {             //SoM: 3/15/2000: Boom stuff...            ceilinglist_t* cl;                        for (cl = activeceilings; cl; cl = cl->next)                if (cl->ceiling == (ceiling_t *)th)                {                    ceiling_t*          ceiling;                    WRITEBYTE(save_p, tc_ceiling);                    PADSAVEP();                    ceiling = (ceiling_t *)save_p;                    memcpy (save_p, th, sizeof(*ceiling));                    save_p += sizeof(*ceiling);                    ceiling->sector = (sector_t *)(ceiling->sector - sectors);                }                            continue;        }        if (th->function.acp1 == (actionf_p1)T_MoveCeiling)        {            ceiling_t*          ceiling;            WRITEBYTE(save_p, tc_ceiling);            PADSAVEP();            ceiling = (ceiling_t *)save_p;            memcpy (ceiling, th, sizeof(*ceiling));            save_p += sizeof(*ceiling);            ceiling->sector = (sector_t *)(ceiling->sector - sectors);            continue;        }        if (th->function.acp1 == (actionf_p1)T_VerticalDoor)        {            vldoor_t*           door;            WRITEBYTE(save_p, tc_door);            PADSAVEP();            door = (vldoor_t *)save_p;            memcpy (door, th, sizeof(*door));            save_p += sizeof(*door);            door->sector = (sector_t *)(door->sector - sectors);            door->line   = (line_t *)(door->line - lines);            continue;        }        if (th->function.acp1 == (actionf_p1)T_MoveFloor)        {            floormove_t*        floor;            WRITEBYTE(save_p, tc_floor);            PADSAVEP();            floor = (floormove_t *)save_p;            memcpy (floor, th, sizeof(*floor));            save_p += sizeof(*floor);            floor->sector = (sector_t *)(floor->sector - sectors);            continue;        }        if (th->function.acp1 == (actionf_p1)T_PlatRaise)        {            plat_t*             plat;            WRITEBYTE(save_p, tc_plat);            PADSAVEP();            plat = (plat_t *)save_p;            memcpy (plat, th, sizeof(*plat));            save_p += sizeof(*plat);            plat->sector = (sector_t *)(plat->sector - sectors);            continue;        }        if (th->function.acp1 == (actionf_p1)T_LightFlash)        {            lightflash_t*       flash;            WRITEBYTE(save_p, tc_flash);            PADSAVEP();            flash = (lightflash_t *)save_p;            memcpy (flash, th, sizeof(*flash));            save_p += sizeof(*flash);            flash->sector = (sector_t *)(flash->sector - sectors);            continue;        }        if (th->function.acp1 == (actionf_p1)T_StrobeFlash)        {            strobe_t*           strobe;            WRITEBYTE(save_p, tc_strobe);            PADSAVEP();            strobe = (strobe_t *)save_p;            memcpy (strobe, th, sizeof(*strobe));            save_p += sizeof(*strobe);            strobe->sector = (sector_t *)(strobe->sector - sectors);            continue;        }        if (th->function.acp1 == (actionf_p1)T_Glow)        {            glow_t*             glow;            WRITEBYTE(save_p, tc_glow);            PADSAVEP();            glow = (glow_t *)save_p;            memcpy (glow, th, sizeof(*glow));            save_p += sizeof(*glow);            glow->sector = (sector_t *)(glow->sector - sectors);            continue;        }        // BP added T_FireFlicker        if (th->function.acp1 == (actionf_p1)T_FireFlicker)        {            fireflicker_t*      fireflicker;            WRITEBYTE(save_p, tc_fireflicker);            PADSAVEP();            fireflicker = (fireflicker_t *)save_p;            memcpy (fireflicker, th, sizeof(*fireflicker));            save_p += sizeof(*fireflicker);            fireflicker->sector = (sector_t *)(fireflicker->sector - sectors);            continue;        }        //SoM: 3/15/2000: Added extra Boom thinker types.        if (th->function.acp1 == (actionf_p1) T_MoveElevator)        {          elevator_t  *elevator;          WRITEBYTE(save_p, tc_elevator);          PADSAVEP();          elevator = (elevator_t *)save_p;          memcpy (elevator, th, sizeof(*elevator));          save_p += sizeof(*elevator);          elevator->sector = (sector_t *)(elevator->sector - sectors);          continue;        }        if (th->function.acp1 == (actionf_p1) T_Scroll)        {          WRITEBYTE(save_p, tc_scroll);          memcpy (save_p, th, sizeof(scroll_t));          save_p += sizeof(scroll_t);          continue;        }        if (th->function.acp1 == (actionf_p1) T_Friction)        {          WRITEBYTE(save_p, tc_friction);          memcpy (save_p, th, sizeof(friction_t));          save_p += sizeof(friction_t);          continue;        }        if (th->function.acp1 == (actionf_p1) T_Pusher)        {          WRITEBYTE(save_p, tc_pusher);          memcpy (save_p, th, sizeof(pusher_t));          save_p += sizeof(pusher_t);          continue;        }    }    WRITEBYTE(save_p, tc_end);}// Now save the pointers, tracer and target, but at load time we must// relink to this, the savegame contain the old position in the pointer// field copyed in the info field temporarely, but finaly we just search// for to old postion and relink tostatic mobj_t *FindNewPosition(void *oldposition){    thinker_t*          th;    mobj_t*             mobj;    for (th = thinkercap.next ; th != &thinkercap ; th=th->next)    {        mobj = (mobj_t *)th;        if( (void *)mobj->info == oldposition)            return mobj;    }    if(devparm) CONS_Printf("\2not found\n");    DEBFILE("not found\n");    return NULL;}//// P_UnArchiveThinkers//void P_UnArchiveThinkers (void){    thinker_t*          currentthinker;    thinker_t*          next;    mobj_t*             mobj;    ULONG               diff;    int                 i;    byte                tclass;    ceiling_t*          ceiling;    vldoor_t*           door;    floormove_t*        floor;    plat_t*             plat;    lightflash_t*       flash;    strobe_t*           strobe;    glow_t*             glow;    fireflicker_t*      fireflicker;    elevator_t*         elevator; //SoM: 3/15/2000    scroll_t*           scroll;    friction_t*         friction;    pusher_t*           pusher;    // remove all the current thinkers    currentthinker = thinkercap.next;    while (currentthinker != &thinkercap)    {        next = currentthinker->next;        mobj = (mobj_t *)currentthinker;        if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker)            // since this item isn't save don't remove it/*            if( !((((mobj->flags & (MF_COUNTKILL | MF_PICKUP | MF_SHOOTABLE )) == 0)                   && (mobj->flags & MF_MISSILE)                   && (mobj->info->doomednum !=-1) )                  || (mobj->type == MT_BLOOD) ) )*/            P_RemoveMobj ((mobj_t *)currentthinker);        else            Z_Free (currentthinker);        currentthinker = next;    }    // BP: we don't want the removed mobj come back !!!    iquetail = iquehead = 0 ;    P_InitThinkers ();    // read in saved thinkers    while (1)    {        tclass = READBYTE(save_p);        if( tclass == tc_end )            break; // leave the while        switch (tclass)        {          case tc_mobj :              PADSAVEP();              diff = READULONG(save_p);              next = (void*)READULONG(save_p); // &mobj in the old system              mobj = Z_Malloc (sizeof(mobj_t), PU_LEVEL, NULL);              memset (mobj, 0, sizeof(mobj_t));              if( diff & MD_SPAWNPOINT ) {  short spawnpointnum = READSHORT(save_p);                                            mobj->spawnpoint = &mapthings[spawnpointnum];                                            mapthings[spawnpointnum].mobj = mobj;                                         }              if( diff & MD_TYPE       )   mobj->type         = READULONG(save_p);              else              {                  for (i=0 ; i< NUMMOBJTYPES ; i++)                       if (mobj->spawnpoint->type == mobjinfo[i].doomednum)                           break;                  if ( i == NUMMOBJTYPES )                      I_Error("Savegame corrupted\n");                  mobj->type = i;              }              mobj->info = &mobjinfo[mobj->type];              if( diff & MD_POS        ) { mobj->x            = READFIXED(save_p);                                           mobj->y            = READFIXED(save_p);                                           mobj->angle        = READANGLE(save_p); }              else              {                  mobj->x      = mobj->spawnpoint->x << FRACBITS;                  mobj->y      = mobj->spawnpoint->y << FRACBITS;                  mobj->angle  = ANG45 * (mobj->spawnpoint->angle/45);              }              if( diff & MD_Z        ) mobj->z            = READFIXED(save_p);   // else latter              if( diff & MD_MOM      ){mobj->momx         = READFIXED(save_p);                                       mobj->momy         = READFIXED(save_p);                                       mobj->momz         = READFIXED(save_p); } // else null (memset)              if( diff & MD_RADIUS   ) mobj->radius       = READFIXED(save_p);                                  else mobj->radius       = mobj->info->radius;              if( diff & MD_HEIGHT   ) mobj->height       = READFIXED(save_p);                                  else mobj->height       = mobj->info->height;              if( diff & MD_FLAGS    ) mobj->flags        = READLONG (save_p);                                  else mobj->flags        = mobj->info->flags;              if( diff & MD_FLAGS2   ) mobj->flags2       = READLONG (save_p);                                  else mobj->flags2       = mobj->info->flags2;              if( diff & MD_HEALTH   ) mobj->health       = READLONG (save_p);                                  else mobj->health       = mobj->info->spawnhealth;              if( diff & MD_RTIME    ) mobj->reactiontime = READLONG (save_p);                                  else mobj->reactiontime = mobj->info->reactiontime;              if( diff & MD_STATE    ) mobj->state        = &states[READUSHORT(save_p)];                                  else mobj->state        = &states[mobj->info->spawnstate];              if( diff & MD_TICS     ) mobj->tics         = READLONG (save_p);                                  else mobj->tics         = mobj->state->tics;              if( diff & MD_SPRITE   ) mobj->sprite       = READUSHORT(save_p);                                  else mobj->sprite       = mobj->state->sprite;              if( diff & MD_FRAME    ) mobj->frame        = READULONG(save_p);                                  else mobj->frame        = mobj->state->frame;              if( diff & MD_EFLAGS   ) mobj->eflags       = READULONG(save_p);              if( diff & MD_PLAYER   ) {                  i  = READBYTE (save_p);                  mobj->player = &players[i];                  mobj->player->mo = mobj;                  // added for angle prediction                  if( consoleplayer == i)                localangle=mobj->angle;                  if( secondarydisplayplayer == i)       localangle2=mobj->angle;              }              if( diff & MD_MOVEDIR  ) mobj->movedir      = READLONG (save_p);              if( diff & MD_MOVECOUNT) mobj->movecount    = READLONG (save_p);              if( diff & MD_THRESHOLD) mobj->threshold    = READLONG (save_p);              if( diff & MD_LASTLOOK ) mobj->lastlook     = READLONG (save_p);                                  else mobj->lastlook     = -1;              if( diff & MD_TARGET   ) mobj->target       = (mobj_t *)READULONG(save_p);              if( diff & MD_TRACER   ) mobj->tracer       = (mobj_t *)READULONG(save_p);              if( diff & MD_FRICTION ) mobj->friction     = READLONG (save_p);                                  else mobj->friction     = ORIG_FRICTION;              if( diff & MD_MOVEFACTOR)mobj->movefactor   = READLONG (save_p);                                  else mobj->movefactor   = ORIG_FRICTION_FACTOR;              if( diff & MD_SPECIAL1 ) mobj->special1     = READLONG (save_p);              if( diff & MD_SPECIAL2 ) mobj->special2     = READLONG (save_p);              // now set deductable field              // TODO : save this too              mobj->skin = NULL;              // set sprev, snext, bprev, bnext, subsector              P_SetThingPosition (mobj);              mobj->floorz = mobj->subsector->sector->floorheight;              if( (diff & MD_Z) == 0 )                   mobj->z = mobj->floorz;              if( mobj->player ) {                  mobj->player->viewz = mobj->player->mo->z + mobj->player->viewheight;                  //CONS_Printf("viewz = %f\n",FIXED_TO_FLOAT(mobj->player->viewz));              }              mobj->ceilingz = mobj->subsector->sector->ceilingheight;              mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker;              P_AddThinker (&mobj->thinker);              mobj->info  = (mobjinfo_t *)next;  // temporarely, set when leave this function              break;          case tc_ceiling:              PADSAVEP();              ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL);              memcpy (ceiling, save_p, sizeof(*ceiling));              save_p += sizeof(*ceiling);              ceiling->sector = &sectors[(int)ceiling->sector];              ceiling->sector->ceilingdata = 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:              PADSAVEP();              door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL);              memcpy (door, save_p, sizeof(*door));              save_p += sizeof(*door);              door->sector = &sectors[(int)door->sector];              door->sector->ceilingdata = door;              door->line   = &lines[(int)door->line];              door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor;              P_AddThinker (&door->thinker);              break;          case tc_floor:              PADSAVEP();              floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL);              memcpy (floor, save_p, sizeof(*floor));              save_p += sizeof(*floor);              floor->sector = &sectors[(int)floor->sector];              floor->sector->floordata = floor;              floor->thinker.function.acp1 = (actionf_p1)T_MoveFloor;              P_AddThinker (&floor->thinker);              break;          case tc_plat:              PADSAVEP();              plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -