From: Rudolf Polzer Date: Tue, 20 Dec 2011 12:54:17 +0000 (+0100) Subject: csqcmodels: change to allow any csqcmodel, or any non-csqcmodel, to be the view entity X-Git-Tag: xonotic-v0.6.0~74^2~91^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=82e78cadfb3a5ae7fd8f8ee319b8c888e0a20aa2;p=xonotic%2Fxonotic-data.pk3dir.git csqcmodels: change to allow any csqcmodel, or any non-csqcmodel, to be the view entity --- diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 6ad35331e..2bc20e951 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -575,7 +575,7 @@ vector getplayerorigin(float pl) string s; entity e; - e = CSQCPlayer_GetPlayer(pl + 1); + e = CSQCModel_server2csqc(pl + 1); if(e) return e.origin; diff --git a/qcsrc/csqcmodel/cl_model.qc b/qcsrc/csqcmodel/cl_model.qc index c6d2923d4..00ff8a8a7 100644 --- a/qcsrc/csqcmodel/cl_model.qc +++ b/qcsrc/csqcmodel/cl_model.qc @@ -237,3 +237,8 @@ void CSQCModel_Read() self.drawmask = MASK_NORMAL; self.predraw = CSQCModel_Draw; } + +entity CSQCModel_server2csqc(float pl) +{ + return findfloat(world, entnum, pl); // FIXME optimize this using an array +} diff --git a/qcsrc/csqcmodel/cl_model.qh b/qcsrc/csqcmodel/cl_model.qh index fba21518f..5b98ae19f 100644 --- a/qcsrc/csqcmodel/cl_model.qh +++ b/qcsrc/csqcmodel/cl_model.qh @@ -32,3 +32,5 @@ void CSQCModel_Read(); #undef CSQCMODEL_PROPERTY #undef CSQCMODEL_ENDIF #undef CSQCMODEL_IF + +entity CSQCModel_server2csqc(float pl); diff --git a/qcsrc/csqcmodel/cl_player.qc b/qcsrc/csqcmodel/cl_player.qc index 4a7cf2e10..70d29592b 100644 --- a/qcsrc/csqcmodel/cl_player.qc +++ b/qcsrc/csqcmodel/cl_player.qc @@ -196,31 +196,49 @@ void CSQCPlayer_SetCamera() // relink setorigin(self, self.origin); - // FIXME support svc_setview? + self.angles_y = input_angles_y; - if(checkextension("DP_CSQC_V_CALCREFDEF") || checkextension("DP_CSQC_V_CALCREFDEF_WIP1")) - { - var float refdefflags = 0; + self = oldself; + } - if(self.csqcmodel_teleported) - { - refdefflags |= REFDEFFLAG_TELEPORTED; - self.csqcmodel_teleported = 0; - } + entity view; +#ifdef COMPAT_XON050_ENGINE + view = CSQCModel_server2csqc((spectatee_status > 0) ? spectatee_status : player_localentnum); +#else + view = CSQCModel_server2csqc(player_localentnum); +#endif - if(input_buttons & 4) - refdefflags |= REFDEFFLAG_JUMPING; +#ifdef COMPAT_XON050_ENGINE + if((view == self) && (checkextension("DP_CSQC_V_CALCREFDEF") || checkextension("DP_CSQC_V_CALCREFDEF_WIP1"))) +#else + if(view == self) +#endif + { + var float refdefflags = 0; - V_CalcRefdef(self, refdefflags); + if(self.csqcmodel_teleported) + { + refdefflags |= REFDEFFLAG_TELEPORTED; + self.csqcmodel_teleported = 0; } - else - setproperty(VF_ORIGIN, self.origin + self.view_ofs); - self.angles_y = input_angles_y; - { CSQCPLAYER_HOOK_POSTCAMERASETUP } + if(input_buttons & 4) + refdefflags |= REFDEFFLAG_JUMPING; - self = oldself; + V_CalcRefdef(self, refdefflags); } + else if(view) + { + setproperty(VF_ORIGIN, view.origin + view.view_ofs); + setproperty(VF_ANGLES, view.angles); + } + else + { + // no setup, keep engine provided values + // to support a legacy entity being the view + } + + { CSQCPLAYER_HOOK_POSTCAMERASETUP } } void CSQCPlayer_Remove() @@ -250,8 +268,3 @@ float CSQCPlayer_PostUpdate() self.entremove = CSQCPlayer_Remove; return 1; } - -entity CSQCPlayer_GetPlayer(float pl) -{ - return findfloat(world, entnum, pl); // FIXME optimize this using an array -} diff --git a/qcsrc/csqcmodel/cl_player.qh b/qcsrc/csqcmodel/cl_player.qh index f85c4e7cd..0eecabed8 100644 --- a/qcsrc/csqcmodel/cl_player.qh +++ b/qcsrc/csqcmodel/cl_player.qh @@ -29,4 +29,3 @@ void CSQCPlayer_SetCamera(); float CSQCPlayer_PreUpdate(); float CSQCPlayer_PostUpdate(); float CSQCPlayer_IsLocalPlayer(); -entity CSQCPlayer_GetPlayer(float pl);