- ud.camerasprite -> actor.

This commit is contained in:
Christoph Oelckers 2020-11-02 23:53:55 +01:00
parent 212b99d0f3
commit d0db810ab0
18 changed files with 44 additions and 45 deletions

View file

@ -4484,7 +4484,7 @@ void handle_se27(DDukeActor* actor)
{ {
if (t[0] < 0) if (t[0] < 0)
{ {
ud.camerasprite = actor->GetIndex(); ud.cameraactor = actor;
t[0]++; t[0]++;
} }
else if (ud.recstat == 2 && ps[p].newowner == -1) else if (ud.recstat == 2 && ps[p].newowner == -1)
@ -4493,7 +4493,7 @@ void handle_se27(DDukeActor* actor)
{ {
if (x < (unsigned)sh) if (x < (unsigned)sh)
{ {
ud.camerasprite = actor->GetIndex(); ud.cameraactor = actor;
t[0] = 999; t[0] = 999;
s->ang += getincangle(s->ang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 3; s->ang += getincangle(s->ang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 3;
s->yvel = 100 + ((s->z - ps[p].posz) / 257); s->yvel = 100 + ((s->z - ps[p].posz) / 257);
@ -4501,10 +4501,10 @@ void handle_se27(DDukeActor* actor)
} }
else if (t[0] == 999) else if (t[0] == 999)
{ {
if (ud.camerasprite == actor->GetIndex()) if (ud.cameraactor == actor)
t[0] = 0; t[0] = 0;
else t[0] = -10; else t[0] = -10;
ud.camerasprite = actor->GetIndex(); ud.cameraactor = actor;
} }
} }
@ -4514,10 +4514,10 @@ void handle_se27(DDukeActor* actor)
if (t[0] == 999) if (t[0] == 999)
{ {
if (ud.camerasprite == actor->GetIndex()) if (ud.cameraactor == actor)
t[0] = 0; t[0] = 0;
else t[0] = -20; else t[0] = -20;
ud.camerasprite = actor->GetIndex(); ud.cameraactor = actor;
} }
} }
} }

View file

@ -424,7 +424,7 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
t1 = ScriptCode[actorinfo[APLAYER].scriptaddress + 2]; t1 = ScriptCode[actorinfo[APLAYER].scriptaddress + 2];
} }
if (ud.camerasprite == -1 && ps[p].newowner == -1) if (ud.cameraactor == nullptr && ps[p].newowner == -1)
if (s->owner >= 0 && display_mirror == 0 && ps[p].over_shoulder_on == 0) if (s->owner >= 0 && display_mirror == 0 && ps[p].over_shoulder_on == 0)
if (ud.multimode < 2 || (ud.multimode > 1 && p == screenpeek)) if (ud.multimode < 2 || (ud.multimode > 1 && p == screenpeek))
{ {
@ -707,7 +707,7 @@ void animatesprites_d(int x, int y, int a, int smoothratio)
if (Owner && Owner->statnum < MAXSTATUS) if (Owner && Owner->statnum < MAXSTATUS)
{ {
if (Owner->picnum == APLAYER) if (Owner->picnum == APLAYER)
if (ud.camerasprite == -1) if (ud.cameraactor == nullptr)
if (screenpeek == Owner->yvel && display_mirror == 0) if (screenpeek == Owner->yvel && display_mirror == 0)
{ {
t->owner = -1; t->owner = -1;

View file

@ -475,7 +475,7 @@ void animatesprites_r(int x, int y, int a, int smoothratio)
t1 = ScriptCode[actorinfo[APLAYER].scriptaddress + 2]; t1 = ScriptCode[actorinfo[APLAYER].scriptaddress + 2];
} }
if (ud.camerasprite == -1 && ps[p].newowner == -1) if (ud.cameraactor == nullptr && ps[p].newowner == -1)
if (s->owner >= 0 && display_mirror == 0 && ps[p].over_shoulder_on == 0) if (s->owner >= 0 && display_mirror == 0 && ps[p].over_shoulder_on == 0)
if (ud.multimode < 2 || (ud.multimode > 1 && p == screenpeek)) if (ud.multimode < 2 || (ud.multimode > 1 && p == screenpeek))
{ {
@ -940,7 +940,7 @@ void animatesprites_r(int x, int y, int a, int smoothratio)
if (Owner && Owner->statnum < MAXSTATUS) if (Owner && Owner->statnum < MAXSTATUS)
{ {
if (Owner->picnum == APLAYER) if (Owner->picnum == APLAYER)
if (ud.camerasprite == -1) if (ud.cameraactor == nullptr)
if (screenpeek == Owner->yvel && display_mirror == 0) if (screenpeek == Owner->yvel && display_mirror == 0)
{ {
t->owner = -1; t->owner = -1;

View file

@ -291,7 +291,7 @@ void GameInterface::app_init()
ud.multimode = 1; ud.multimode = 1;
ud.m_monsters_off = userConfig.nomonsters; ud.m_monsters_off = userConfig.nomonsters;
ps[0].aim_mode = 1; ps[0].aim_mode = 1;
ud.camerasprite = -1; ud.cameraactor = nullptr;
if (fileSystem.FileExists("DUKESW.BIN")) if (fileSystem.FileExists("DUKESW.BIN"))
g_gameType |= GAMEFLAG_SHAREWARE; g_gameType |= GAMEFLAG_SHAREWARE;

View file

@ -249,7 +249,7 @@ void drawoverlays(double smoothratio)
MarkSectorSeen(pp->cursectnum); MarkSectorSeen(pp->cursectnum);
if (ud.camerasprite == -1) if (ud.cameraactor == nullptr)
{ {
if (automapMode != am_full) if (automapMode != am_full)
{ {
@ -299,7 +299,7 @@ void drawoverlays(double smoothratio)
StatusBar->UpdateStatusBar(); StatusBar->UpdateStatusBar();
if (ps[myconnectindex].newowner == -1 && ud.camerasprite == -1) if (ps[myconnectindex].newowner == -1 && ud.cameraactor == nullptr)
{ {
DrawCrosshair(TILE_CROSSHAIR, ps[screenpeek].last_extra, -getHalfLookAng(pp->angle.olook_ang.asq16(), pp->angle.look_ang.asq16(), cl_syncinput, smoothratio), pp->over_shoulder_on ? 2.5 : 0, isRR() ? 0.5 : 1); DrawCrosshair(TILE_CROSSHAIR, ps[screenpeek].last_extra, -getHalfLookAng(pp->angle.olook_ang.asq16(), pp->angle.look_ang.asq16(), cl_syncinput, smoothratio), pp->over_shoulder_on ? 2.5 : 0, isRR() ? 0.5 : 1);
} }

View file

@ -136,8 +136,8 @@ static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor*
break; break;
case USERDEFS_CAMERASPRITE: case USERDEFS_CAMERASPRITE:
if (bSet) ud.camerasprite = lValue; if (bSet) ud.cameraactor = ScriptIndexToActor(lValue);
else SetGameVarID((int)lVar2, ud.camerasprite, sActor, sPlayer); else SetGameVarID((int)lVar2, ActorToScriptIndex(ud.cameraactor), sActor, sPlayer);
break; break;
case USERDEFS_LAST_CAMSPRITE: case USERDEFS_LAST_CAMSPRITE:

View file

@ -66,7 +66,7 @@ void GameInterface::Ticker()
{ {
if (earthquaketime > 0) earthquaketime--; if (earthquaketime > 0) earthquaketime--;
ud.camerasprite = -1; ud.cameraactor = nullptr;
everyothertime++; everyothertime++;
global_random = krand(); global_random = krand();

View file

@ -291,7 +291,7 @@ void displayweapon_d(int snum, double smoothratio)
gs = p->GetActor()->s.shade; gs = p->GetActor()->s.shade;
if(gs > 24) gs = 24; if(gs > 24) gs = 24;
bool playerVars = p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (p->GetActor()->s.pal != 1 && p->GetActor()->s.extra <= 0); bool playerVars = p->newowner >= 0 || ud.cameraactor != nullptr || p->over_shoulder_on > 0 || (p->GetActor()->s.pal != 1 && p->GetActor()->s.extra <= 0);
bool playerAnims = animatefist(gs,snum,look_anghalf) || animateknuckles(gs,snum,hard_landing,look_anghalf,horiz16th) || bool playerAnims = animatefist(gs,snum,look_anghalf) || animateknuckles(gs,snum,hard_landing,look_anghalf,horiz16th) ||
animatetip(gs,snum,hard_landing,look_anghalf,horiz16th) || animateaccess(gs,snum,hard_landing,look_anghalf,horiz16th); animatetip(gs,snum,hard_landing,look_anghalf,horiz16th) || animateaccess(gs,snum,hard_landing,look_anghalf,horiz16th);

View file

@ -136,7 +136,7 @@ void displayweapon_r(int snum, double smoothratio)
gs = p->GetActor()->s.shade; gs = p->GetActor()->s.shade;
if(gs > 24) gs = 24; if(gs > 24) gs = 24;
if(p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (p->GetActor()->s.pal != 1 && p->GetActor()->s.extra <= 0)) if(p->newowner >= 0 || ud.cameraactor != nullptr || p->over_shoulder_on > 0 || (p->GetActor()->s.pal != 1 && p->GetActor()->s.extra <= 0))
return; return;
int opos = p->oweapon_pos * p->oweapon_pos; int opos = p->oweapon_pos * p->oweapon_pos;

View file

@ -39,7 +39,7 @@ inline int bossguy(spritetype const* const pSprite)
inline int actorflag(DDukeActor * actor, int mask) inline int actorflag(DDukeActor * actor, int mask)
{ {
return (((actorinfo[actor->s.picnum].flags/* ^ hittype[spritenum].flags*/) & mask) != 0); return (((actorinfo[actor->s.picnum].flags) & mask) != 0);
} }
inline int actorfella(DDukeActor* actor) inline int actorfella(DDukeActor* actor)
@ -68,9 +68,9 @@ inline void settileflag(int flag, const std::initializer_list<short>& types)
} }
} }
inline bool wallswitchcheck(int s) inline bool wallswitchcheck(DDukeActor* s)
{ {
return !!(tileinfo[sprite[s].picnum].flags & TFLAG_WALLSWITCH); return !!(tileinfo[s->s.picnum].flags & TFLAG_WALLSWITCH);
} }
inline int checkcursectnums(int se) inline int checkcursectnums(int se)

View file

@ -416,7 +416,7 @@ void resetprestat(int snum,int g)
parallaxtype = 0; parallaxtype = 0;
randomseed = 17L; randomseed = 17L;
paused = 0; paused = 0;
ud.camerasprite =-1; ud.cameraactor =nullptr;
tempwallptr = 0; tempwallptr = 0;
camsprite =-1; camsprite =-1;
earthquaketime = 0; earthquaketime = 0;

View file

@ -536,10 +536,11 @@ void prelevel_r(int g)
speed = sj->hitag; speed = sj->hitag;
for (ii = 0; ii < MAXSPRITES; ii++) for (ii = 0; ii < MAXSPRITES; ii++)
{ {
if (sprite[ii].picnum == RRTILE66) auto spr = &sprite[ii];
if (sprite[ii].lotag == sj->sectnum) if (spr->picnum == RRTILE66)
if (spr->lotag == sj->sectnum)
{ {
childsectnum = sprite[ii].sectnum; childsectnum = spr->sectnum;
deletesprite(ii); deletesprite(ii);
} }
} }
@ -728,11 +729,11 @@ void prelevel_r(int g)
if (lotaglist > 64) if (lotaglist > 64)
I_Error("Too many switches (64 max)."); I_Error("Too many switches (64 max).");
StatIterator it1(STAT_EFFECTOR); DukeStatIterator it1(STAT_EFFECTOR);
while ((j = it1.NextIndex()) >= 0) while (auto j = it1.Next())
{ {
if (sprite[j].lotag == 12 && sprite[j].hitag == spr->lotag) if (j->s.lotag == 12 && j->s.hitag == spr->lotag)
hittype[j].temp_data[0] = 1; j->temp_data[0] = 1;
} }
} }
break; break;

View file

@ -518,16 +518,16 @@ void displayrooms(int snum, double smoothratio)
// The camera texture must be rendered with the base palette, so this is the only place where the current global palette can be set. // The camera texture must be rendered with the base palette, so this is the only place where the current global palette can be set.
// The setting here will be carried over to the rendering of the weapon sprites, but other 2D content will always default to the main palette. // The setting here will be carried over to the rendering of the weapon sprites, but other 2D content will always default to the main palette.
setgamepalette(p->palette); setgamepalette(p->palette);
if (ud.camerasprite >= 0) if (ud.cameraactor)
{ {
spritetype* s; spritetype* s;
s = &sprite[ud.camerasprite]; s = &ud.cameraactor->s;
if (s->yvel < 0) s->yvel = -100; if (s->yvel < 0) s->yvel = -100;
else if (s->yvel > 199) s->yvel = 300; else if (s->yvel > 199) s->yvel = 300;
cang = buildang(hittype[ud.camerasprite].tempang + xs_CRoundToInt(fmulscale16(((s->ang + 1024 - hittype[ud.camerasprite].tempang) & 2047) - 1024, smoothratio))); cang = buildang(ud.cameraactor->tempang + xs_CRoundToInt(fmulscale16(((s->ang + 1024 - ud.cameraactor->tempang) & 2047) - 1024, smoothratio)));
auto bh = buildhoriz(s->yvel); auto bh = buildhoriz(s->yvel);
se40code(s->x, s->y, s->z, cang, bh, smoothratio); se40code(s->x, s->y, s->z, cang, bh, smoothratio);

View file

@ -1710,7 +1710,7 @@ void checksectors_d(int snum)
spr->yvel = 1; //Using this camera spr->yvel = 1; //Using this camera
if (snum == screenpeek) S_PlaySound(MONITOR_ACTIVE); if (snum == screenpeek) S_PlaySound(MONITOR_ACTIVE);
neartagsprite->s.owner = i; neartagsprite->SetOwner(acti);
neartagsprite->s.yvel = 1; neartagsprite->s.yvel = 1;
camsprite = neartagsprite->GetIndex(); camsprite = neartagsprite->GetIndex();

View file

@ -2394,7 +2394,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
targ->extra += pspr->extra; targ->extra += pspr->extra;
if (s->picnum != COW) if (s->picnum != COW)
targ->ang = pspr->ang; targ->ang = pspr->ang;
targ->owner = pspr->owner; targ->SetHitOwner(proj->GetOwner());
} }
if (s->statnum == 10) if (s->statnum == 10)

View file

@ -293,7 +293,7 @@ static int GetPositionInfo(DDukeActor* actor, int soundNum, int sectNum,
void S_GetCamera(vec3_t** c, int32_t* ca, int32_t* cs) void S_GetCamera(vec3_t** c, int32_t* ca, int32_t* cs)
{ {
if (ud.camerasprite == -1) if (ud.cameraactor == nullptr)
{ {
auto p = &ps[screenpeek]; auto p = &ps[screenpeek];
if (c) *c = &p->pos; if (c) *c = &p->pos;
@ -302,9 +302,9 @@ void S_GetCamera(vec3_t** c, int32_t* ca, int32_t* cs)
} }
else else
{ {
if (c) *c = &sprite[ud.camerasprite].pos; if (c) *c = &ud.cameraactor->s.pos;
if (cs) *cs = sprite[ud.camerasprite].sectnum; if (cs) *cs = ud.cameraactor->s.sectnum;
if (ca) *ca = sprite[ud.camerasprite].ang; if (ca) *ca = ud.cameraactor->s.ang;
} }
} }
@ -396,7 +396,7 @@ void GameInterface::UpdateSounds(void)
listener.Environment = nullptr; listener.Environment = nullptr;
listener.valid = false; listener.valid = false;
} }
listener.ListenerObject = ud.camerasprite == -1 ? nullptr : &sprite[ud.camerasprite]; listener.ListenerObject = ud.cameraactor == nullptr ? nullptr : &ud.cameraactor->s;
soundEngine->SetListener(listener); soundEngine->SetListener(listener);
} }

View file

@ -50,9 +50,6 @@ BEGIN_DUKE_NS
DDukeActor* EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, signed char s_s, signed char s_xr, signed char s_yr, short s_a, short s_ve, int s_zv, DDukeActor* s_ow, signed char s_ss) DDukeActor* EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, signed char s_s, signed char s_xr, signed char s_yr, short s_a, short s_ve, int s_zv, DDukeActor* s_ow, signed char s_ss)
{ {
//if (isRR() && s_ow < 0 && !force) // should never happen, the only owner-less spawn outside of map start is for the Holoduke, which is Duke only
//return 0;
int const i = insertsprite(whatsect, s_ss); int const i = insertsprite(whatsect, s_ss);
if (i < 0) if (i < 0)
@ -188,7 +185,7 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_list<int
if (!isIn(sp->picnum, excludes) && (sp->cstat & 48)) if (!isIn(sp->picnum, excludes) && (sp->cstat & 48))
{ {
if (sp->shade == 127) return i; if (sp->shade == 127) return i;
if (wallswitchcheck(i) && (sp->cstat & 16)) if (wallswitchcheck(act) && (sp->cstat & 16))
{ {
if (sp->picnum != TILE_ACCESSSWITCH && sp->picnum != TILE_ACCESSSWITCH2 && sp->pal) if (sp->picnum != TILE_ACCESSSWITCH && sp->picnum != TILE_ACCESSSWITCH2 && sp->pal)
{ {

View file

@ -74,7 +74,7 @@ struct weaponhit
owner = a->GetIndex(); owner = a->GetIndex();
} }
// This used the owner field - better move this to something more safe. // This used the Owner field - better move this to something more safe.
inline bool IsActiveCrane() inline bool IsActiveCrane()
{ {
return palvals == -2; return palvals == -2;
@ -131,7 +131,6 @@ struct user_defs
unsigned char user_pals[MAXPLAYERS]; unsigned char user_pals[MAXPLAYERS];
short from_bonus; short from_bonus;
short camerasprite, last_camsprite;
short last_level, secretlevel; short last_level, secretlevel;
int const_visibility; int const_visibility;
@ -148,6 +147,8 @@ struct user_defs
int player_skill, marker; int player_skill, marker;
//MapRecord* nextLevel; //MapRecord* nextLevel;
DDukeActor* cameraactor;
}; };
struct player_orig struct player_orig