From de29dce68094b5394a6727f67458986a3533c10b Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 24 Dec 2011 04:05:28 +0000 Subject: [PATCH] skel_set_bone_world implementation. fix attempt to fix npfte issues. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3938 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/pr_csqc.c | 1 + engine/client/pr_skelobj.c | 22 ++++++++++++---------- engine/common/common.c | 19 +++++++++++++++++++ engine/common/common.h | 13 +++++++++++++ engine/common/pr_bgcmd.c | 2 +- engine/server/server.h | 12 ------------ engine/server/sv_mvd.c | 18 +----------------- 7 files changed, 47 insertions(+), 40 deletions(-) diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index e3643c09d..eb93cf720 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -4168,6 +4168,7 @@ static struct { {"touchtriggers", PF_touchtriggers, 279},//void() touchtriggers = #279; {"skel_ragupdate", PF_skel_ragedit, 281},// (FTE_QC_RAGDOLL) {"skel_mmap", PF_skel_mmap, 282},// (FTE_QC_RAGDOLL) + {"skel_set_bone_world", PF_skel_set_bone_world, 283}, //300 {"clearscene", PF_R_ClearScene, 300}, // #300 void() clearscene (EXT_CSQC) {"addentities", PF_R_AddEntityMask, 301}, // #301 void(float mask) addentities (EXT_CSQC) diff --git a/engine/client/pr_skelobj.c b/engine/client/pr_skelobj.c index 90c38d789..15b282e1b 100644 --- a/engine/client/pr_skelobj.c +++ b/engine/client/pr_skelobj.c @@ -788,9 +788,9 @@ void QCBUILTIN PF_skel_set_bone_world (progfuncs_t *prinst, struct globalvars_s if (*prinst->callargc == 4) { vec3_t d[3], a; - a[0] = G_VECTOR(OFS_PARM2)[0] * -1; /*mod_alias bug*/ - a[1] = G_VECTOR(OFS_PARM2)[1]; - a[2] = G_VECTOR(OFS_PARM2)[2]; + a[0] = G_VECTOR(OFS_PARM3)[0] * -1; /*mod_alias bug*/ + a[1] = G_VECTOR(OFS_PARM3)[1]; + a[2] = G_VECTOR(OFS_PARM3)[2]; AngleVectors(a, d[0], d[1], d[2]); bonemat_fromqcvectors(childworld, d[0], d[1], d[2], G_VECTOR(OFS_PARM2)); } @@ -823,19 +823,21 @@ void QCBUILTIN PF_skel_set_bone_world (progfuncs_t *prinst, struct globalvars_s float parentent[12]; framestate_t fstate; w->Get_FrameState(w, ent, &fstate); - if (!Mod_GetTag(skelobj->model, boneidx+1, &fstate, parentabs)) + if (skelobj->type == SKOT_ABSOLUTE || !Mod_GetTag(skelobj->model, Mod_GetBoneParent(skelobj->model, boneidx+1), &fstate, parentabs)) { - bonemat_fromidentity(parentabs); + bonemat_fromentity(w, ent, parentw); } - - bonemat_fromentity(w, ent, parentent); - Matrix3x4_Multiply(parentent, parentabs, parentw); - Matrix3x4_Invert_Simple(parentw, parentinv); + else + { + bonemat_fromentity(w, ent, parentent); + Matrix3x4_Multiply(parentabs, parentent, parentw); + } + Matrix3x4_Invert(parentw, parentinv); } /*calc the result*/ bone = skelobj->bonematrix+12*boneidx; - Matrix3x4_Multiply(parentinv, childworld, bone); + Matrix3x4_Multiply(childworld, parentinv, bone); } //void(float skel, float bonenum, vector org) skel_set_bone (FTE_CSQC_SKELETONOBJECTS) (reads v_forward etc) diff --git a/engine/common/common.c b/engine/common/common.c index 7bab3a06e..c72f87643 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -4383,3 +4383,22 @@ char *version_string(void) return s; } + +//C90 +void COM_TimeOfDay(date_t *date) +{ + struct tm *newtime; + time_t long_time; + + time(&long_time); + newtime = localtime(&long_time); + + date->day = newtime->tm_mday; + date->mon = newtime->tm_mon; + date->year = newtime->tm_year + 1900; + date->hour = newtime->tm_hour; + date->min = newtime->tm_min; + date->sec = newtime->tm_sec; + strftime( date->str, 128, + "%a %b %d, %H:%M:%S %Y", newtime); +} diff --git a/engine/common/common.h b/engine/common/common.h index 57af231fa..e2234665e 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -480,3 +480,16 @@ typedef struct pc_token_s } pc_token_t; #define fileHandle_t int #define fsMode_t int + + +typedef struct +{ + int sec; + int min; + int hour; + int day; + int mon; + int year; + char str[128]; +} date_t; +void COM_TimeOfDay(date_t *date); diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index f9011caa7..f010aa3bb 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -2871,7 +2871,7 @@ void QCBUILTIN PF_calltimeofday (progfuncs_t *prinst, struct globalvars_s *pr_gl f = PR_FindFunction(prinst, "timeofday", PR_ANY); if (f) { - SV_TimeOfDay(&date); + COM_TimeOfDay(&date); G_FLOAT(OFS_PARM0) = (float)date.sec; G_FLOAT(OFS_PARM1) = (float)date.min; diff --git a/engine/server/server.h b/engine/server/server.h index a1cb100ec..ce09a6b23 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -1296,18 +1296,6 @@ void SV_CalcPHS (void); void SV_GetConsoleCommands (void); void SV_CheckTimer(void); -typedef struct -{ - int sec; - int min; - int hour; - int day; - int mon; - int year; - char str[128]; -} date_t; -void SV_TimeOfDay(date_t *date); - void SV_LogPlayer(client_t *cl, char *msg); void AddLinksToPmove ( edict_t *player, areanode_t *node ); diff --git a/engine/server/sv_mvd.c b/engine/server/sv_mvd.c index eb36cd4fd..f4b9a00ba 100644 --- a/engine/server/sv_mvd.c +++ b/engine/server/sv_mvd.c @@ -645,23 +645,7 @@ void DemoWriteQTVTimePad(int msecs) //broadcast to all proxies } -void SV_TimeOfDay(date_t *date) -{ - struct tm *newtime; - time_t long_time; - time( &long_time ); - newtime = localtime( &long_time ); - - date->day = newtime->tm_mday; - date->mon = newtime->tm_mon; - date->year = newtime->tm_year + 1900; - date->hour = newtime->tm_hour; - date->min = newtime->tm_min; - date->sec = newtime->tm_sec; - strftime( date->str, 128, - "%a %b %d, %H:%M:%S %Y", newtime); -} // returns the file size // return -1 if file is not present @@ -1431,7 +1415,7 @@ mvddest_t *SV_InitRecordFile (char *name) char buf[2000]; date_t date; - SV_TimeOfDay(&date); + COM_TimeOfDay(&date); snprintf(buf, sizeof(buf), "date %s\nmap %s\nteamplay %d\ndeathmatch %d\ntimelimit %d\n%s",date.str, sv.name, (int)teamplay.value, (int)deathmatch.value, (int)timelimit.value, SV_PrintTeams()); VFS_WRITE(f, buf, strlen(buf));