From 90cf2396505f2d0f52c4c7e8391f773bebd58374 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 19 May 2019 03:55:31 +0000 Subject: [PATCH] Add GAMEVAR_RAWQ16PTR, functioning the same as GAMEVAR_INT32PTR git-svn-id: https://svn.eduke32.com/eduke32@7665 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/gamevars.cpp | 12 ++++++------ source/duke3d/src/gamevars.h | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/duke3d/src/gamevars.cpp b/source/duke3d/src/gamevars.cpp index 57733c88f..da77f4e5b 100644 --- a/source/duke3d/src/gamevars.cpp +++ b/source/duke3d/src/gamevars.cpp @@ -774,11 +774,10 @@ static FORCE_INLINE int __fastcall Gv_GetVar__(int &gameVar, int &spriteNum, int } else switch (varFlags & GAMEVAR_PTR_MASK) { + case GAMEVAR_RAWQ16PTR: case GAMEVAR_INT32PTR: returnValue = *(int32_t *)var.global; break; case GAMEVAR_INT16PTR: returnValue = *(int16_t *)var.global; break; - case GAMEVAR_Q16PTR: - returnValue = (var.flags & GAMEVAR_SPECIAL) ? *(int32_t *)var.global : fix16_to_int(*(fix16_t *)var.global); - break; + case GAMEVAR_Q16PTR: returnValue = fix16_to_int(*(fix16_t *)var.global); break; } return (returnValue ^ -invertResult) + invertResult; @@ -822,9 +821,10 @@ static FORCE_INLINE void __fastcall Gv_SetVar__(int const &gameVar, int const &n } else switch (varFlags & GAMEVAR_PTR_MASK) { + case GAMEVAR_RAWQ16PTR: case GAMEVAR_INT32PTR: *((int32_t *)var.global) = (int32_t)newValue; break; case GAMEVAR_INT16PTR: *((int16_t *)var.global) = (int16_t)newValue; break; - case GAMEVAR_Q16PTR: *(fix16_t *)var.global = (var.flags & GAMEVAR_SPECIAL) ? (int32_t)newValue : fix16_from_int((int16_t)newValue); + case GAMEVAR_Q16PTR: *(fix16_t *)var.global = fix16_from_int((int16_t)newValue); break; } return; @@ -1295,8 +1295,8 @@ static void Gv_AddSystemVars(void) Gv_NewVar("cameraclock", (intptr_t)&g_cameraClock, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); Gv_NewVar("cameradist", (intptr_t)&g_cameraDistance, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); Gv_NewVar("camerahoriz", (intptr_t)&ud.cameraq16horiz, GAMEVAR_SYSTEM | GAMEVAR_Q16PTR); - Gv_NewVar("cameraq16ang", (intptr_t)&ud.cameraq16ang, GAMEVAR_SYSTEM | GAMEVAR_Q16PTR | GAMEVAR_SPECIAL); - Gv_NewVar("cameraq16horiz", (intptr_t)&ud.cameraq16horiz, GAMEVAR_SYSTEM | GAMEVAR_Q16PTR | GAMEVAR_SPECIAL); + Gv_NewVar("cameraq16ang", (intptr_t)&ud.cameraq16ang, GAMEVAR_SYSTEM | GAMEVAR_RAWQ16PTR); + Gv_NewVar("cameraq16horiz", (intptr_t)&ud.cameraq16horiz, GAMEVAR_SYSTEM | GAMEVAR_RAWQ16PTR); Gv_NewVar("camerasect", (intptr_t)&ud.camerasect, GAMEVAR_SYSTEM | GAMEVAR_INT16PTR); Gv_NewVar("camerax", (intptr_t)&ud.camerapos.x, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); Gv_NewVar("cameray", (intptr_t)&ud.camerapos.y, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); diff --git a/source/duke3d/src/gamevars.h b/source/duke3d/src/gamevars.h index 1fd5456ed..a204d7a35 100644 --- a/source/duke3d/src/gamevars.h +++ b/source/duke3d/src/gamevars.h @@ -53,7 +53,9 @@ enum GamevarFlags_t GAMEVAR_SPECIAL = 0x00040000, // flag for structure member shortcut vars GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets GAMEVAR_Q16PTR = 0x00100000, // plValues is a pointer to a q16.16 - GAMEVAR_PTR_MASK = (GAMEVAR_INT32PTR | GAMEVAR_INT16PTR | GAMEVAR_Q16PTR), + + GAMEVAR_RAWQ16PTR = GAMEVAR_Q16PTR | GAMEVAR_SPECIAL, // plValues is a pointer to a q16.16 but we don't want conversion + GAMEVAR_PTR_MASK = GAMEVAR_INT32PTR | GAMEVAR_INT16PTR | GAMEVAR_Q16PTR | GAMEVAR_RAWQ16PTR, }; #if !defined LUNATIC