Clean up the new camera control stuff a little bit

git-svn-id: https://svn.eduke32.com/eduke32@489 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2007-02-12 21:17:52 +00:00
parent 1fff7e88f4
commit 7e79039197
3 changed files with 60 additions and 63 deletions

View file

@ -352,6 +352,9 @@ struct user_defs {
short camerasprite,last_camsprite; short camerasprite,last_camsprite;
short last_level,secretlevel; short last_level,secretlevel;
short cameraang, camerasect, camerahoriz;
long camerax,cameray,cameraz;
long const_visibility,uw_framerate; long const_visibility,uw_framerate;
long camera_time,folfvel,folavel,folx,foly,fola; long camera_time,folfvel,folavel,folx,foly,fola;
long reccnt; long reccnt;

View file

@ -3837,9 +3837,6 @@ static void se40code(long x,long y,long z,long a,long h, long smoothratio)
static long oyrepeat=-1; static long oyrepeat=-1;
long camerax,cameray,cameraz;
short cameraang, camerasect, camerahoriz;
void displayrooms(int snum,long smoothratio) void displayrooms(int snum,long smoothratio)
{ {
long dst,j,fz,cz; long dst,j,fz,cz;
@ -3871,12 +3868,12 @@ void displayrooms(int snum,long smoothratio)
if (ud.pause_on || ps[snum].on_crane > -1) smoothratio = 65536; if (ud.pause_on || ps[snum].on_crane > -1) smoothratio = 65536;
camerasect = p->cursectnum; ud.camerasect = p->cursectnum;
#ifdef POLYMOST #ifdef POLYMOST
if (rendmode != 4) if (rendmode != 4)
#endif #endif
if (camerasect < 0 || camerasect >= MAXSECTORS) return; if (ud.camerasect < 0 || ud.camerasect >= MAXSECTORS) return;
dointerpolations(smoothratio); dointerpolations(smoothratio);
@ -3889,12 +3886,12 @@ void displayrooms(int snum,long smoothratio)
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;
cameraang = hittype[ud.camerasprite].tempang+mulscale16((long)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio); ud.cameraang = hittype[ud.camerasprite].tempang+mulscale16((long)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio);
#ifdef SE40 #ifdef SE40
se40code(s->x,s->y,s->z,cameraang,s->yvel,smoothratio); se40code(s->x,s->y,s->z,ud.cameraang,s->yvel,smoothratio);
#endif #endif
drawrooms(s->x,s->y,s->z-(4<<8),cameraang,s->yvel,s->sectnum); drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum);
animatesprites(s->x,s->y,cameraang,smoothratio); animatesprites(s->x,s->y,ud.cameraang,smoothratio);
drawmasks(); drawmasks();
} }
else else
@ -3963,71 +3960,71 @@ void displayrooms(int snum,long smoothratio)
if ((snum == myconnectindex) && (numplayers > 1)) if ((snum == myconnectindex) && (numplayers > 1))
{ {
camerax = omyx+mulscale16((long)(myx-omyx),smoothratio); ud.camerax = omyx+mulscale16((long)(myx-omyx),smoothratio);
cameray = omyy+mulscale16((long)(myy-omyy),smoothratio); ud.cameray = omyy+mulscale16((long)(myy-omyy),smoothratio);
cameraz = omyz+mulscale16((long)(myz-omyz),smoothratio); ud.cameraz = omyz+mulscale16((long)(myz-omyz),smoothratio);
cameraang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); ud.cameraang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio);
camerahoriz = omyhoriz+omyhorizoff+mulscale16((long)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); ud.camerahoriz = omyhoriz+omyhorizoff+mulscale16((long)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio);
camerasect = mycursectnum; ud.camerasect = mycursectnum;
} }
else else
{ {
camerax = p->oposx+mulscale16((long)(p->posx-p->oposx),smoothratio); ud.camerax = p->oposx+mulscale16((long)(p->posx-p->oposx),smoothratio);
cameray = p->oposy+mulscale16((long)(p->posy-p->oposy),smoothratio); ud.cameray = p->oposy+mulscale16((long)(p->posy-p->oposy),smoothratio);
cameraz = p->oposz+mulscale16((long)(p->posz-p->oposz),smoothratio); ud.cameraz = p->oposz+mulscale16((long)(p->posz-p->oposz),smoothratio);
cameraang = p->oang+mulscale16((long)(((p->ang+1024-p->oang)&2047)-1024),smoothratio); ud.cameraang = p->oang+mulscale16((long)(((p->ang+1024-p->oang)&2047)-1024),smoothratio);
camerahoriz = p->ohoriz+p->ohorizoff+mulscale16((long)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio); ud.camerahoriz = p->ohoriz+p->ohorizoff+mulscale16((long)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio);
} }
cameraang += p->look_ang; ud.cameraang += p->look_ang;
if (p->newowner >= 0) if (p->newowner >= 0)
{ {
cameraang = p->ang+p->look_ang; ud.cameraang = p->ang+p->look_ang;
camerahoriz = p->horiz+p->horizoff; ud.camerahoriz = p->horiz+p->horizoff;
camerax = p->posx; ud.camerax = p->posx;
cameray = p->posy; ud.cameray = p->posy;
cameraz = p->posz; ud.cameraz = p->posz;
camerasect = sprite[p->newowner].sectnum; ud.camerasect = sprite[p->newowner].sectnum;
smoothratio = 65536L; smoothratio = 65536L;
} }
else if (p->over_shoulder_on == 0) else if (p->over_shoulder_on == 0)
cameraz += p->opyoff+mulscale16((long)(p->pyoff-p->opyoff),smoothratio); ud.cameraz += p->opyoff+mulscale16((long)(p->pyoff-p->opyoff),smoothratio);
else view(p,&camerax,&cameray,&cameraz,&camerasect,cameraang,camerahoriz); else view(p,&ud.camerax,&ud.cameray,&ud.cameraz,&ud.camerasect,ud.cameraang,ud.camerahoriz);
cz = hittype[p->i].ceilingz; cz = hittype[p->i].ceilingz;
fz = hittype[p->i].floorz; fz = hittype[p->i].floorz;
if (earthquaketime > 0 && p->on_ground == 1) if (earthquaketime > 0 && p->on_ground == 1)
{ {
cameraz += 256-(((earthquaketime)&1)<<9); ud.cameraz += 256-(((earthquaketime)&1)<<9);
cameraang += (2-((earthquaketime)&2))<<2; ud.cameraang += (2-((earthquaketime)&2))<<2;
} }
if (sprite[p->i].pal == 1) cameraz -= (18<<8); if (sprite[p->i].pal == 1) ud.cameraz -= (18<<8);
if (p->newowner >= 0) if (p->newowner >= 0)
camerahoriz = 100+sprite[p->newowner].shade; ud.camerahoriz = 100+sprite[p->newowner].shade;
else if (p->spritebridge == 0) else if (p->spritebridge == 0)
{ {
if (cameraz < (p->truecz + (4<<8))) cameraz = cz + (4<<8); if (ud.cameraz < (p->truecz + (4<<8))) ud.cameraz = cz + (4<<8);
else if (cameraz > (p->truefz - (4<<8))) cameraz = fz - (4<<8); else if (ud.cameraz > (p->truefz - (4<<8))) ud.cameraz = fz - (4<<8);
} }
if (camerasect >= 0) if (ud.camerasect >= 0)
{ {
getzsofslope(camerasect,camerax,cameray,&cz,&fz); getzsofslope(ud.camerasect,ud.camerax,ud.cameray,&cz,&fz);
if (cameraz < cz+(4<<8)) cameraz = cz+(4<<8); if (ud.cameraz < cz+(4<<8)) ud.cameraz = cz+(4<<8);
if (cameraz > fz-(4<<8)) cameraz = fz-(4<<8); if (ud.cameraz > fz-(4<<8)) ud.cameraz = fz-(4<<8);
} }
if (camerahoriz > 299) camerahoriz = 299; if (ud.camerahoriz > 299) ud.camerahoriz = 299;
else if (camerahoriz < -99) camerahoriz = -99; else if (ud.camerahoriz < -99) ud.camerahoriz = -99;
OnEvent(EVENT_DISPLAYROOMS, ps[screenpeek].i, screenpeek, -1); OnEvent(EVENT_DISPLAYROOMS, ps[screenpeek].i, screenpeek, -1);
#ifdef SE40 #ifdef SE40
se40code(camerax,cameray,cameraz,cameraang,camerahoriz,smoothratio); se40code(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,smoothratio);
#endif #endif
if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0)
{ {
@ -4035,19 +4032,19 @@ void displayrooms(int snum,long smoothratio)
i = 0; i = 0;
for (k=0;k<mirrorcnt;k++) for (k=0;k<mirrorcnt;k++)
{ {
j = klabs(wall[mirrorwall[k]].x-camerax); j = klabs(wall[mirrorwall[k]].x-ud.camerax);
j += klabs(wall[mirrorwall[k]].y-cameray); j += klabs(wall[mirrorwall[k]].y-ud.cameray);
if (j < dst) dst = j, i = k; if (j < dst) dst = j, i = k;
} }
if (wall[mirrorwall[i]].overpicnum == MIRROR) if (wall[mirrorwall[i]].overpicnum == MIRROR)
{ {
preparemirror(camerax,cameray,cameraz,cameraang,camerahoriz,mirrorwall[i],mirrorsector[i],&tposx,&tposy,&tang); preparemirror(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,mirrorwall[i],mirrorsector[i],&tposx,&tposy,&tang);
j = visibility; j = visibility;
visibility = (j>>1) + (j>>2); visibility = (j>>1) + (j>>2);
drawrooms(tposx,tposy,cameraz,tang,camerahoriz,mirrorsector[i]+MAXSECTORS); drawrooms(tposx,tposy,ud.cameraz,tang,ud.camerahoriz,mirrorsector[i]+MAXSECTORS);
display_mirror = 1; display_mirror = 1;
animatesprites(tposx,tposy,tang,smoothratio); animatesprites(tposx,tposy,tang,smoothratio);
@ -4060,8 +4057,8 @@ void displayrooms(int snum,long smoothratio)
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7)); gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
} }
drawrooms(camerax,cameray,cameraz,cameraang,camerahoriz,camerasect); drawrooms(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,ud.camerasect);
animatesprites(camerax,cameray,cameraang,smoothratio); animatesprites(ud.camerax,ud.cameray,ud.cameraang,smoothratio);
drawmasks(); drawmasks();
if (screencapt == 1) if (screencapt == 1)

View file

@ -37,9 +37,6 @@ static int killit_flag;
extern int32 scripthandle; extern int32 scripthandle;
extern long camerax,cameray,cameraz;
extern short cameraang, camerasect, camerahoriz;
static void DoUserDef(int iSet, int lLabelID, int lVar2) static void DoUserDef(int iSet, int lLabelID, int lVar2)
{ {
long lValue; long lValue;
@ -819,44 +816,44 @@ static void DoUserDef(int iSet, int lLabelID, int lVar2)
case USERDEFS_CAMERAX: case USERDEFS_CAMERAX:
if (iSet) if (iSet)
camerax = lValue; ud.camerax = lValue;
else else
SetGameVarID(lVar2, camerax, g_i, g_p); SetGameVarID(lVar2, ud.camerax, g_i, g_p);
break; break;
case USERDEFS_CAMERAY: case USERDEFS_CAMERAY:
if (iSet) if (iSet)
cameray = lValue; ud.cameray = lValue;
else else
SetGameVarID(lVar2, cameray, g_i, g_p); SetGameVarID(lVar2, ud.cameray, g_i, g_p);
break; break;
case USERDEFS_CAMERAZ: case USERDEFS_CAMERAZ:
if (iSet) if (iSet)
cameraz = lValue; ud.cameraz = lValue;
else else
SetGameVarID(lVar2, cameraz, g_i, g_p); SetGameVarID(lVar2, ud.cameraz, g_i, g_p);
break; break;
case USERDEFS_CAMERAANG: case USERDEFS_CAMERAANG:
if (iSet) if (iSet)
cameraang = lValue; ud.cameraang = lValue;
else else
SetGameVarID(lVar2, cameraang, g_i, g_p); SetGameVarID(lVar2, ud.cameraang, g_i, g_p);
break; break;
case USERDEFS_CAMERASECT: case USERDEFS_CAMERASECT:
if (iSet) if (iSet)
camerasect = lValue; ud.camerasect = lValue;
else else
SetGameVarID(lVar2, camerasect, g_i, g_p); SetGameVarID(lVar2, ud.camerasect, g_i, g_p);
break; break;
case USERDEFS_CAMERAHORIZ: case USERDEFS_CAMERAHORIZ:
if (iSet) if (iSet)
camerahoriz = lValue; ud.camerahoriz = lValue;
else else
SetGameVarID(lVar2, camerahoriz, g_i, g_p); SetGameVarID(lVar2, ud.camerahoriz, g_i, g_p);
break; break;
default: default: