From 200395449293b7a64eb2796097d62c16225b01b5 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 9 Jun 2013 16:37:18 +0000 Subject: [PATCH] CON: add projectile member .userdata and predefined label PROJ_USERDATA. It is a 32-bit signed integer. No version bump necessary, although CON code accessing this new member will not work with earlier revisions (obviously). git-svn-id: https://svn.eduke32.com/eduke32@3866 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.h | 3 ++- polymer/eduke32/source/gamedef.c | 4 ++++ polymer/eduke32/source/gamedef.h | 1 + polymer/eduke32/source/gamestructures.c | 18 ++++++++++++++++++ polymer/eduke32/source/lunatic/con_lang.lua | 2 ++ polymer/eduke32/source/lunatic/defs.ilua | 3 ++- .../eduke32/source/lunatic/test/weaponvars.con | 13 +++++++++++++ 7 files changed, 42 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/source/actors.h b/polymer/eduke32/source/actors.h index 700cd87a2..a97586bd3 100644 --- a/polymer/eduke32/source/actors.h +++ b/polymer/eduke32/source/actors.h @@ -103,7 +103,8 @@ typedef struct { int8_t shade, xrepeat, yrepeat, pal; // 4b int8_t movecnt; // 1b uint8_t clipdist; // 1b - int8_t filler[6]; // 6b + int8_t filler[2]; // 2b + int32_t userdata; // 4b } projectile_t; #pragma pack(push,1) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index d1d0348be..6e2b6f90a 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1040,6 +1040,7 @@ const memberlabel_t ProjectileLabels[]= { "bsound", PROJ_BSOUND, 0, 0 }, { "range", PROJ_RANGE, 0, 0 }, { "flashcolor", PROJ_FLASH_COLOR, 0, 0 }, + { "userdata", PROJ_USERDATA, 0, 0 }, { "", -1, 0, 0 } // END OF LIST }; @@ -2328,6 +2329,8 @@ LUNATIC_EXTERN void C_DefineProjectile(int32_t j, int32_t what, int32_t val) g_tile[j].defproj.bsound = ProjectileData[j].bsound = val; break; case PROJ_RANGE: g_tile[j].defproj.range = ProjectileData[j].range = val; break; + case PROJ_USERDATA: + g_tile[j].defproj.userdata = ProjectileData[j].userdata = val; break; default: break; } @@ -6179,6 +6182,7 @@ static void C_AddDefaultDefinitions(void) C_AddDefinition("PROJ_TRAIL",PROJ_TRAIL,LABEL_DEFINE); C_AddDefinition("PROJ_TXREPEAT",PROJ_TXREPEAT,LABEL_DEFINE); C_AddDefinition("PROJ_TYREPEAT",PROJ_TYREPEAT,LABEL_DEFINE); + C_AddDefinition("PROJ_USERDATA",PROJ_USERDATA,LABEL_DEFINE); C_AddDefinition("PROJ_VEL_MULT",PROJ_MOVECNT,LABEL_DEFINE); C_AddDefinition("PROJ_VEL",PROJ_VEL,LABEL_DEFINE); C_AddDefinition("PROJ_WORKSLIKE",PROJ_WORKSLIKE,LABEL_DEFINE); diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 940ff5dda..d3788986a 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -566,6 +566,7 @@ enum ProjectileLabel_t PROJ_BSOUND, PROJ_RANGE, PROJ_FLASH_COLOR, + PROJ_USERDATA, PROJ_END }; #if !defined LUNATIC diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index b087bd68f..d9e61e6bc 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -1205,6 +1205,15 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in Gv_SetVarX(lVar2, SpriteProjectile[proj].flashcolor); return; + case PROJ_USERDATA: + if (iSet) + { + SpriteProjectile[proj].userdata=lValue; + return; + } + Gv_SetVarX(lVar2, SpriteProjectile[proj].userdata); + return; + default: return; } @@ -3464,6 +3473,15 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t Gv_SetVarX(lVar2, ProjectileData[lVar1].range); return; + case PROJ_USERDATA: + if (iSet) + { + ProjectileData[lVar1].userdata=lValue; + return; + } + Gv_SetVarX(lVar2, ProjectileData[lVar1].userdata); + return; + default: return; } diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index c60b4d1b1..d5065d733 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -68,6 +68,7 @@ PROJ = { PROJ_BSOUND = 26, PROJ_RANGE = 27, PROJ_FLASH_COLOR = 28, + PROJ_USERDATA = 29, } -- PROJ_* define -> projectile_t member name @@ -798,6 +799,7 @@ local ProjectileLabels = { pal = PROJ".pal", velmult = PROJ".movecnt", -- NAME clipdist = PROJ".clipdist", + userdata = PROJ".userdata", } -- XXX: kind of CODEDUP form above diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 91dcbc935..ff42d35da 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -314,7 +314,8 @@ struct { int8_t shade, xrepeat, yrepeat, pal; int8_t movecnt; uint8_t clipdist; - int8_t filler[6]; + int8_t filler[2]; + int32_t userdata; } ]] diff --git a/polymer/eduke32/source/lunatic/test/weaponvars.con b/polymer/eduke32/source/lunatic/test/weaponvars.con index 4c74572c1..1a81a2664 100644 --- a/polymer/eduke32/source/lunatic/test/weaponvars.con +++ b/polymer/eduke32/source/lunatic/test/weaponvars.con @@ -20,20 +20,33 @@ defineprojectile MORTER2 PROJ_OFFSET 128 defineprojectile MORTER2 PROJ_CLIPDIST 24 defineprojectile MORTER2 PROJ_TRAIL -1 // overridden in test.elua defineprojectile MORTER2 PROJ_TNUM 6 +defineprojectile MORTER2 PROJ_USERDATA 32 // test setting initial value onevent EVENT_GAME setvarvar WEAPON1_FIRESOUND snd // setvarvar WEAPON1_SHOOTS shoots endevent +definequote 400 Failed setting projectile userdata + useractor notenemy 909 // tree trunk ifcount 120 { + // userdata: bitwise-OR in 64 + getprojectile[MORTER2].userdata tmp + orvar tmp 64 + setprojectile[MORTER2].userdata tmp + ezshoot -4096 MORTER2 getthisprojectile[RETURN].vel tmp randvar tmp2 500 subvarvar tmp tmp2 setthisprojectile[RETURN].vel tmp resetcount + + // userdata: must be 32+64 now + getthisprojectile[RETURN].userdata tmp + ifvarn tmp 96 + quote 400 } enda