mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- SW: Swap out the internals of the player's pos methods and get the game going again.
* Leave `PLAYER::PlayerOldPosition` for now.
This commit is contained in:
parent
c14d1587f0
commit
6d736aea19
9 changed files with 51 additions and 53 deletions
|
@ -1240,7 +1240,7 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
|
|||
}
|
||||
|
||||
// Get initial player position, interpolating if required.
|
||||
DVector3 tpos = interpolatedvalue(camerapp->posprevGet(), camerapp->posGet(), interpfrac);
|
||||
DVector3 tpos = camerapp->actor->getRenderPos(interpfrac);
|
||||
if (SyncInput() || pp != Player+myconnectindex)
|
||||
{
|
||||
tang = camerapp->angle.interpolatedsum(interpfrac);
|
||||
|
|
|
@ -408,7 +408,6 @@ void InitLevel(MapRecord *maprec)
|
|||
SpawnSpriteDef sprites;
|
||||
DVector3 ppos;
|
||||
loadMap(maprec->fileName, SW_SHAREWARE ? 1 : 0, &ppos, &ang, &cursect, sprites);
|
||||
Player[0].posSet(ppos);
|
||||
spawnactors(sprites);
|
||||
Player[0].cursector = cursect;
|
||||
|
||||
|
@ -434,8 +433,8 @@ void InitLevel(MapRecord *maprec)
|
|||
|
||||
QueueReset();
|
||||
PreMapCombineFloors();
|
||||
InitMultiPlayerInfo();
|
||||
InitAllPlayerSprites();
|
||||
InitMultiPlayerInfo(ppos);
|
||||
InitAllPlayerSprites(ppos);
|
||||
|
||||
//
|
||||
// Do setup for sprite, track, panel, sector, etc
|
||||
|
|
|
@ -1708,9 +1708,7 @@ BEGIN_SW_NS
|
|||
|
||||
struct PLAYER
|
||||
{
|
||||
// variable that fit in the sprite or user structure
|
||||
|
||||
DVector3 PlayerNowPosition, PlayerPrevPosition, PlayerOldPosition;
|
||||
DVector3 PlayerOldPosition;
|
||||
|
||||
DSWActor* actor; // this may not be a TObjPtr!
|
||||
TObjPtr<DSWActor*> lowActor, highActor;
|
||||
|
@ -1889,52 +1887,52 @@ struct PLAYER
|
|||
|
||||
DVector2& posXY()
|
||||
{
|
||||
return PlayerNowPosition.XY();
|
||||
return actor->spr.pos.XY();
|
||||
}
|
||||
|
||||
void posZset(const double val)
|
||||
{
|
||||
PlayerNowPosition.Z = val;
|
||||
actor->spr.pos.Z = val - actor->viewzoffset;
|
||||
}
|
||||
void posZadd(const double val)
|
||||
{
|
||||
PlayerNowPosition.Z += val;
|
||||
actor->spr.pos.Z += val;
|
||||
}
|
||||
double posZget()
|
||||
{
|
||||
return PlayerNowPosition.Z;
|
||||
return actor->spr.pos.Z + actor->viewzoffset;
|
||||
}
|
||||
|
||||
void posSet(const DVector3& val)
|
||||
{
|
||||
PlayerNowPosition = val;
|
||||
actor->spr.pos = val.plusZ(-actor->viewzoffset);
|
||||
}
|
||||
void posAdd(const DVector2& val)
|
||||
{
|
||||
PlayerNowPosition += val;
|
||||
actor->spr.pos += val;
|
||||
}
|
||||
DVector3 posGet()
|
||||
{
|
||||
return PlayerNowPosition;
|
||||
return actor->spr.pos.plusZ(actor->viewzoffset);
|
||||
}
|
||||
|
||||
DVector2& posprevXY()
|
||||
{
|
||||
return PlayerPrevPosition.XY();
|
||||
return actor->opos.XY();
|
||||
}
|
||||
|
||||
void posprevZset(const double val)
|
||||
{
|
||||
PlayerPrevPosition.Z = val;
|
||||
actor->opos.Z = val - actor->viewzoffset;
|
||||
}
|
||||
|
||||
void posprevSet(const DVector3& val)
|
||||
{
|
||||
PlayerPrevPosition = val;
|
||||
actor->opos = val.plusZ(-actor->viewzoffset);
|
||||
}
|
||||
DVector3 posprevGet()
|
||||
{
|
||||
return PlayerPrevPosition;
|
||||
return actor->opos.plusZ(actor->viewzoffset);
|
||||
}
|
||||
|
||||
DVector2& posoldXY()
|
||||
|
|
|
@ -71,8 +71,8 @@ int DoActorSectorDamage(DSWActor* actor);
|
|||
int DoScaleSprite(DSWActor* actor);
|
||||
int DoActorStopFall(DSWActor* actor);
|
||||
|
||||
void InitPlayerSprite(PLAYER* pp);
|
||||
void InitAllPlayerSprites(void);
|
||||
void InitPlayerSprite(PLAYER* pp, const DVector3& spawnpos);
|
||||
void InitAllPlayerSprites(const DVector3& spawnpos);
|
||||
void PlayerPanelSetup(void);
|
||||
void PlayerDeathReset(PLAYER* pp);
|
||||
void SpawnPlayerUnderSprite(PLAYER* pp);
|
||||
|
|
|
@ -2166,13 +2166,13 @@ int DoNinjaCeiling(DSWActor* actor)
|
|||
// too convienent to put it here.
|
||||
//
|
||||
|
||||
void InitAllPlayerSprites(void)
|
||||
void InitAllPlayerSprites(const DVector3& spawnpos)
|
||||
{
|
||||
short i;
|
||||
|
||||
TRAVERSE_CONNECT(i)
|
||||
{
|
||||
InitPlayerSprite(Player + i);
|
||||
InitPlayerSprite(Player + i, spawnpos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2385,14 +2385,24 @@ extern ACTOR_ACTION_SET PlayerNinjaActionSet;
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void InitPlayerSprite(PLAYER* pp)
|
||||
void InitPlayerSprite(PLAYER* pp, const DVector3& spawnpos)
|
||||
{
|
||||
int pnum = int(pp - Player);
|
||||
double fz,cz;
|
||||
extern bool NewGame;
|
||||
|
||||
COVER_SetReverb(0); // Turn off any echoing that may have been going before
|
||||
pp->Reverb = 0;
|
||||
auto actor = SpawnActor(STAT_PLAYER0 + pnum, NINJA_RUN_R0, nullptr, pp->cursector, pp->posGet(), pp->angle.ang);
|
||||
auto actor = SpawnActor(STAT_PLAYER0 + pnum, NINJA_RUN_R0, nullptr, pp->cursector, spawnpos.plusZ(PLAYER_HEIGHTF), pp->angle.ang);
|
||||
actor->viewzoffset = -PLAYER_HEIGHTF;
|
||||
|
||||
// if too close to the floor - stand up
|
||||
calcSlope(pp->cursector, actor->getPosWithOffsetZ(), &cz, &fz);
|
||||
if (actor->spr.pos.Z > fz)
|
||||
{
|
||||
actor->spr.pos.Z = fz;
|
||||
}
|
||||
actor->backuppos();
|
||||
|
||||
pp->actor = actor;
|
||||
pp->pnum = pnum;
|
||||
|
|
|
@ -1859,10 +1859,6 @@ void UpdatePlayerSprite(PLAYER* pp)
|
|||
DSWActor* actor = pp->actor;
|
||||
if (!actor) return;
|
||||
|
||||
// Update sprite representation of player
|
||||
|
||||
actor->spr.pos.XY() = pp->posXY();
|
||||
|
||||
// there are multiple death functions
|
||||
if (pp->Flags & (PF_DEAD))
|
||||
{
|
||||
|
@ -6137,14 +6133,10 @@ void DoPlayerDeathCheckKeys(PLAYER* pp)
|
|||
InitBloodSpray(plActor,true,-1);
|
||||
}
|
||||
|
||||
PlayerSpawnPosition(pp);
|
||||
|
||||
NewStateGroup(plActor, plActor->user.ActorActionSet->Stand);
|
||||
plActor->spr.picnum = plActor->user.State->Pic;
|
||||
plActor->spr.picnum = plActor->user.State->Pic;
|
||||
plActor->spr.scale = DVector2(PLAYER_NINJA_XREPEAT, PLAYER_NINJA_XREPEAT);
|
||||
plActor->spr.cstat &= ~(CSTAT_SPRITE_YCENTER);
|
||||
plActor->spr.pos = pp->posGet().plusZ(PLAYER_HEIGHTF);
|
||||
plActor->spr.angle = pp->angle.ang;
|
||||
|
||||
DoSpawnTeleporterEffect(plActor);
|
||||
|
@ -6165,7 +6157,6 @@ void DoPlayerDeathCheckKeys(PLAYER* pp)
|
|||
plActor->spr.scale = DVector2(PLAYER_NINJA_XREPEAT, PLAYER_NINJA_YREPEAT);
|
||||
|
||||
pp->horizon.horiz = nullAngle;
|
||||
DoPlayerResetMovement(pp);
|
||||
plActor->user.ID = NINJA_RUN_R0;
|
||||
PlayerDeathReset(pp);
|
||||
|
||||
|
@ -7186,8 +7177,6 @@ void InitAllPlayers(void)
|
|||
// Initialize all [MAX_SW_PLAYERS] arrays here!
|
||||
for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++)
|
||||
{
|
||||
pp->posSet(pfirst->posGet());
|
||||
pp->posprevSet(pfirst->posGet());
|
||||
pp->angle.ang = pp->angle.oang = pfirst->angle.ang;
|
||||
pp->horizon.horiz = pp->horizon.ohoriz = pfirst->horizon.horiz;
|
||||
pp->cursector = pfirst->cursector;
|
||||
|
@ -7196,7 +7185,6 @@ void InitAllPlayers(void)
|
|||
|
||||
//pp->MaxHealth = 100;
|
||||
|
||||
pp->posoldXY().Zero();
|
||||
pp->climb_ndx = 10;
|
||||
pp->KillerActor = nullptr;
|
||||
pp->Kills = 0;
|
||||
|
@ -7287,7 +7275,6 @@ void PlayerSpawnPosition(PLAYER* pp)
|
|||
{
|
||||
short pnum = short(pp - Player);
|
||||
short pos_num = pnum;
|
||||
double fz,cz;
|
||||
int i;
|
||||
DSWActor* spawn_sprite = nullptr;
|
||||
|
||||
|
@ -7346,17 +7333,14 @@ void PlayerSpawnPosition(PLAYER* pp)
|
|||
|
||||
ASSERT(spawn_sprite != nullptr);
|
||||
|
||||
pp->posSet(spawn_sprite->spr.pos);
|
||||
pp->posprevSet(pp->posGet());
|
||||
pp->angle.ang = pp->angle.oang = spawn_sprite->spr.angle;
|
||||
pp->setcursector(spawn_sprite->sector());
|
||||
|
||||
calcSlope(pp->cursector, pp->posGet(), &cz, &fz);
|
||||
// if too close to the floor - stand up
|
||||
if (pp->posZget() > fz - PLAYER_HEIGHTF)
|
||||
if (pp->actor)
|
||||
{
|
||||
pp->posZset(fz - PLAYER_HEIGHTF);
|
||||
pp->posprevZset(pp->posZget());
|
||||
pp->actor->spr.pos = spawn_sprite->spr.pos;
|
||||
pp->actor->viewzoffset = spawn_sprite->viewzoffset;
|
||||
pp->actor->backuppos();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7366,12 +7350,13 @@ void PlayerSpawnPosition(PLAYER* pp)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void InitMultiPlayerInfo(void)
|
||||
void InitMultiPlayerInfo(const DVector3& spawnpos)
|
||||
{
|
||||
PLAYER* pp;
|
||||
short pnum;
|
||||
unsigned stat;
|
||||
int tag;
|
||||
double fz,cz;
|
||||
static short MultiStatList[] =
|
||||
{
|
||||
STAT_MULTI_START,
|
||||
|
@ -7411,7 +7396,16 @@ void InitMultiPlayerInfo(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto start0 = SpawnActor(MultiStatList[stat], ST1, nullptr, pp->cursector, pp->posGet(), pp->angle.ang);
|
||||
auto start0 = SpawnActor(MultiStatList[stat], ST1, nullptr, pp->cursector, spawnpos.plusZ(PLAYER_HEIGHTF), pp->angle.ang);
|
||||
start0->viewzoffset = -PLAYER_HEIGHTF;
|
||||
|
||||
// if too close to the floor - stand up
|
||||
calcSlope(pp->cursector, start0->getPosWithOffsetZ(), &cz, &fz);
|
||||
if (start0->spr.pos.Z > fz)
|
||||
{
|
||||
start0->spr.pos.Z = fz;
|
||||
}
|
||||
start0->backuppos();
|
||||
start0->clearUser();
|
||||
start0->spr.picnum = ST1;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ void HeadBobStateControl(void);
|
|||
void DoPlayer(void);
|
||||
void domovethings(void);
|
||||
void InitAllPlayers(void);
|
||||
void InitMultiPlayerInfo(void);
|
||||
void InitMultiPlayerInfo(const DVector3& spawnpos);
|
||||
void MoveScrollMode2D(PLAYER* pp, ControlInfo* const hidInput);
|
||||
void DoPlayerDivePalette(PLAYER* pp);
|
||||
void DoPlayerNightVisionPalette(PLAYER* pp);
|
||||
|
|
|
@ -435,10 +435,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER*
|
|||
{
|
||||
if (arc.BeginObject(keyname))
|
||||
{
|
||||
arc("x", w.PlayerNowPosition.X)
|
||||
("y", w.PlayerNowPosition.Y)
|
||||
("z", w.PlayerNowPosition.Z)
|
||||
("lv_sectnum", w.lv_sector)
|
||||
arc("lv_sectnum", w.lv_sector)
|
||||
("lv_x", w.lv.X)
|
||||
("lv_y", w.lv.Y)
|
||||
("lv_z", w.lv.Z)
|
||||
|
|
|
@ -513,7 +513,7 @@ void SWSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
|
|||
if (pos != nullptr)
|
||||
{
|
||||
PLAYER* pp = Player + screenpeek;
|
||||
FVector3 campos = GetSoundPos(pp->posGet());
|
||||
FVector3 campos = GetSoundPos(pp->actor ? pp->posGet() : DVector3());
|
||||
DVector3 vPos = {};
|
||||
bool pancheck = false;
|
||||
|
||||
|
@ -605,7 +605,7 @@ void GameInterface::UpdateSounds(void)
|
|||
|
||||
listener.angle = float(-tang.Radians());
|
||||
listener.velocity.Zero();
|
||||
listener.position = GetSoundPos(pp->posGet());
|
||||
listener.position = GetSoundPos(pp->actor ? pp->posGet() : DVector3());
|
||||
listener.underwater = false;
|
||||
// This should probably use a real environment instead of the pitch hacking in S_PlaySound3D.
|
||||
// listenactor->waterlevel == 3;
|
||||
|
|
Loading…
Reference in a new issue