Beispiel #1
0
void R_ResetAfterTeleport(player_t *player)
{
#ifndef __LIBRETRO__
  R_ResetViewInterpolation();
#endif
  R_SmoothPlaying_Reset(player);
}
Beispiel #2
0
void A_Punch(player_t *player, pspdef_t *psp)
{
  angle_t angle;
  int t, slope, damage = (P_Random(pr_punch)%10+1)<<1;

  if (player->powers[pw_strength])
    damage *= 10;

  angle = player->mo->angle;

  // killough 5/5/98: remove dependence on order of evaluation:
  t = P_Random(pr_punchangle);
  angle += (t - P_Random(pr_punchangle))<<18;

  /* killough 8/2/98: make autoaiming prefer enemies */
  if (!mbf_features ||
      (slope = P_AimLineAttack(player->mo, angle, MELEERANGE, MF_FRIEND),
       !linetarget))
    slope = P_AimLineAttack(player->mo, angle, MELEERANGE, 0);

  P_LineAttack(player->mo, angle, MELEERANGE, slope, damage);

  if (!linetarget)
    return;

  S_StartSound(player->mo, sfx_punch);

  // turn to face target

  player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y,
                                      linetarget->x, linetarget->y);
  R_SmoothPlaying_Reset(player); // e6y
}
Beispiel #3
0
void A_Saw(player_t *player, pspdef_t *psp)
{
  int slope, damage;
  angle_t angle;
  int t;

  CHECK_WEAPON_CODEPOINTER("A_Saw", player);

  damage = 2*(P_Random(pr_saw)%10+1);
  angle = player->mo->angle;
  // killough 5/5/98: remove dependence on order of evaluation:
  t = P_Random(pr_saw);
  angle += (t - P_Random(pr_saw))<<18;

  /* Use meleerange + 1 so that the puff doesn't skip the flash
   * killough 8/2/98: make autoaiming prefer enemies */
  if (!mbf_features ||
      (slope = P_AimLineAttack(player->mo, angle, MELEERANGE+1, MF_FRIEND),
       !linetarget))
    slope = P_AimLineAttack(player->mo, angle, MELEERANGE+1, 0);

  P_LineAttack(player->mo, angle, MELEERANGE+1, slope, damage);

  if (!linetarget)
    {
      S_StartSound(player->mo, sfx_sawful);
      return;
    }

  S_StartSound(player->mo, sfx_sawhit);

  // turn to face target
  angle = R_PointToAngle2(player->mo->x, player->mo->y,
                          linetarget->x, linetarget->y);

  if (angle - player->mo->angle > ANG180) {
    if (angle - player->mo->angle < -ANG90/20)
      player->mo->angle = angle + ANG90/21;
    else
      player->mo->angle -= ANG90/20;
  } else {
    if (angle - player->mo->angle > ANG90/20)
      player->mo->angle = angle - ANG90/21;
    else
      player->mo->angle += ANG90/20;
  }

  player->mo->flags |= MF_JUSTATTACKED;
  R_SmoothPlaying_Reset(player); // e6y
}
Beispiel #4
0
void R_ResetAfterTeleport(player_t *player)
{
  R_ResetViewInterpolation();
  R_SmoothPlaying_Reset(player);
}
Beispiel #5
0
dboolean G_ReadSaveData(pbuf_t *savebuffer, dboolean bail_on_errors,
                                            dboolean init_new) {
  int i;
  int savegame_compatibility = -1;
  complevel_t m_compatibility_level;
  skill_t m_gameskill;
  int m_gameepisode;
  int m_gamemap;
  //e6y: numeric version number of package should be zero before initializing
  //     from savegame
  unsigned int packageversion = 0;
  unsigned char description[SAVESTRINGSIZE];
  unsigned char save_version[VERSIONSIZE];
  byte game_options[GAME_OPTION_SIZE];
  unsigned int game_option_count;
  unsigned char safety_byte;
  buf_t byte_buf;

  M_BufferInit(&byte_buf);

  memset(description, 0, SAVESTRINGSIZE);
  memset(save_version, 0, VERSIONSIZE);

  M_PBufReadBytes(savebuffer, &byte_buf);

  if (M_BufferGetSize(&byte_buf) != SAVESTRINGSIZE) {
    I_Error("G_ReadSaveData: save string size mismatch (%zu != %u)",
      M_BufferGetSize(&byte_buf), SAVESTRINGSIZE
    );
  }

  memcpy(description, M_BufferGetData(&byte_buf), M_BufferGetSize(&byte_buf));

  M_BufferClear(&byte_buf);

  M_PBufReadBytes(savebuffer, &byte_buf);

  if (M_BufferGetSize(&byte_buf) != VERSIONSIZE) {
    I_Error("G_ReadSaveData: version size mismatch (%zu != %u)",
      M_BufferGetSize(&byte_buf), VERSIONSIZE
    );
  }

  memcpy(save_version, M_BufferGetData(&byte_buf), M_BufferGetSize(&byte_buf));

  M_BufferFree(&byte_buf);

  // CPhipps - read the description field, compare with supported ones
  for (i = 0; i < num_version_headers; i++) {
    char vcheck[VERSIONSIZE];

    // killough 2/22/98: "proprietary" version string :-)
    sprintf(vcheck, version_headers[i].ver_printf, version_headers[i].version);

    if (!strncmp((const char *)save_version, vcheck, VERSIONSIZE)) {
      savegame_compatibility = version_headers[i].comp_level;
      break;
    }
  }

  if (savegame_compatibility == -1) {
    fprintf(stderr, "savegame_compatibility == -1 (%s)\n", save_version);
    if (bail_on_errors) {
      return false;
    }
    else if (forced_loadgame) {
      savegame_compatibility = MAX_COMPATIBILITY_LEVEL - 1;
    }
    else {
      G_LoadGameErr("Unrecognized savegame version!\nAre you sure? (y/n) ");
      return false;
    }
  }

  // CPhipps - always check savegames even when forced,
  //           only print a warning if forced
  {
    // killough 3/16/98: check lump name checksum (independent of order)
    uint_64_t checksum;
    uint_64_t save_checksum = 0;

    if (MULTINET)
      checksum = 1;
    else
      checksum = G_Signature();

    M_PBufReadLong(savebuffer, (int_64_t *)&save_checksum);

    if (save_checksum != checksum) {
      fprintf(stderr, "bad checksum: %" PRIu64 " != %" PRIu64 "\n",
        checksum, save_checksum
      );

      if (bail_on_errors)
        return false;

      if (!forced_loadgame) {
        G_LoadGameErr("Incompatible Savegame!!!\n\nAre you sure?");
        return false;
      }
      else {
        lprintf(LO_WARN, "G_DoLoadGame: Incompatible savegame\n");
      }
    }
  }

  /*-----------------*/
  /* CG: TODO: PWADs */
  /*-----------------*/

  M_PBufReadUInt(savebuffer, &packageversion);

  M_PBufReadInt(savebuffer, &m_compatibility_level);
  M_PBufReadInt(savebuffer, &m_gameskill);
  M_PBufReadInt(savebuffer, &m_gameepisode);
  M_PBufReadInt(savebuffer, &m_gamemap);

  if (!init_new) {
    if (m_compatibility_level != compatibility_level) {
      if (bail_on_errors)
        return false;

      I_Error("G_ReadSaveData: Mismatched compatibility level");
    }

    if (m_gameskill != gameskill) {
      if (bail_on_errors)
        return false;

      I_Error("G_ReadSaveData: Mismatched game skill");
    }

    if (m_gameepisode != gameepisode) {
      if (bail_on_errors)
        return false;

      I_Error("G_ReadSaveData: Mismatched episode");
    }

    if (m_gamemap != gamemap) {
      if (bail_on_errors)
        return false;

      I_Error("G_ReadSaveData: Mismatched map");
    }
  }

  compatibility_level = m_compatibility_level;
  gameskill = m_gameskill;
  gameepisode = m_gameepisode;
  gamemap = m_gamemap;

  M_PBufReadInt(savebuffer, &gametic);

  M_PBufReadBool(savebuffer, &levelTimer);
  M_PBufReadInt(savebuffer, &levelTimeCount);
  M_PBufReadBool(savebuffer, &levelFragLimit);
  M_PBufReadInt(savebuffer, &levelFragLimitCount);

  for (i = 0; i < MAXPLAYERS; i++)
    M_PBufReadBool(savebuffer, &playeringame[i]);

  // killough 2/28/98
  for (dboolean b = false, i = MAXPLAYERS; i < MIN_MAXPLAYERS; i++)
    M_PBufReadBool(savebuffer, &b);

  M_PBufReadInt(savebuffer, &idmusnum); // jff 3/17/98 restore idmus music

  /* killough 3/1/98: Read game options
   * killough 11/98: move down to here
   */
  M_PBufReadArray(savebuffer, &game_option_count);
  if (mbf_features && (game_option_count > GAME_OPTION_SIZE)) {
    I_Error("G_ReadSaveData: too many options (%d > %d)",
      game_option_count, GAME_OPTION_SIZE
    );
  }
  else if ((!mbf_features) && game_option_count > OLD_GAME_OPTION_SIZE) {
    I_Error("G_ReadSaveData: too many options (%d > %d)",
      game_option_count, OLD_GAME_OPTION_SIZE
    );
  }

  for (i = 0; i < game_option_count; i++)
    M_PBufReadUChar(savebuffer, &game_options[i]);

  G_ReadOptions(game_options);  // killough 3/1/98: Read game options

  // load a base level
  if (init_new)
    G_InitNew(gameskill, gameepisode, gamemap);

  P_IdentReset();

  /* get the times - killough 11/98: save entire word */
  M_PBufReadInt(savebuffer, &leveltime);

  /* cph - total episode time */
  //e6y: total level times are always saved since 2.4.8.1
  M_PBufReadInt(savebuffer, &totalleveltimes);

  // killough 11/98: load revenant tracer state
  M_PBufReadInt(savebuffer, &basetic);

  // dearchive all the modifications
  P_MapStart();
  P_UnArchiveWorld(savebuffer);
  P_UnArchivePlayers(savebuffer);
  P_UnArchiveThinkers(savebuffer);
  P_UnArchiveSpecials(savebuffer);
  P_UnArchiveRNG(savebuffer);    // killough 1/18/98: load RNG information
  P_UnArchiveMap(savebuffer);    // killough 1/22/98: load automap information
  S_ReloadChannelOrigins();
  P_MapEnd();
  R_ActivateSectorInterpolations();//e6y
  R_SmoothPlaying_Reset(NULL); // e6y

  if (musinfo.current_item != -1)
    S_ChangeMusInfoMusic(musinfo.current_item, true);

  RecalculateDrawnSubsectors();

  M_PBufReadUChar(savebuffer, &safety_byte);
  if (safety_byte != 0xe6)
    I_Error("G_ReadSaveData: Bad savegame");

  G_UpdateAverageSaveSize(M_PBufGetCapacity(savebuffer));

  return true;
}