Search for named tile in tile selector ('S'); various bugfixes (among other things with PR-override vars)

git-svn-id: https://svn.eduke32.com/eduke32@1696 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2010-08-16 13:56:49 +00:00
parent c354695d60
commit b2988abb54
9 changed files with 337 additions and 231 deletions

View file

@ -145,6 +145,24 @@ static inline int32_t wallength(int16_t i)
extern const char *scripthist[SCRIPTHISTSIZ];
extern int32_t scripthistend;
//////////////////// Aiming ////////////////////
#define SEARCH_WALL 0
#define SEARCH_CEILING 1
#define SEARCH_FLOOR 2
#define SEARCH_SPRITE 3
#define SEARCH_MASKWALL 4
#define ASSERT_AIMING (searchstat>=0 && searchstat<=4)
#define AIMING_AT_WALL (searchstat==0)
#define AIMING_AT_CEILING (searchstat==1)
#define AIMING_AT_FLOOR (searchstat==2)
#define AIMING_AT_SPRITE (searchstat==3)
#define AIMING_AT_MASKWALL (searchstat==4)
#define AIMING_AT_WALL_OR_MASK (AIMING_AT_WALL || AIMING_AT_MASKWALL)
#define AIMING_AT_CEILING_OR_FLOOR (AIMING_AT_CEILING || AIMING_AT_FLOOR)
#ifdef __cplusplus
}
#endif

View file

@ -5205,15 +5205,16 @@ int32_t _getnumber16(const char *namestart, int32_t num, int32_t maxnumber, char
if (ch >= '0' && ch <= '9')
{
int64_t nbig;
if (danum >= 0)
{
n = (danum*10)+(ch-'0');
if (n <= maxnumber) danum = n;
nbig = ((int64_t)danum*10)+(ch-'0');
if (nbig <= (int64_t)maxnumber) danum = nbig;
}
else if (sign) // this extra check isn't hurting anything
{
n = (danum*10)-(ch-'0');
if (n >= -maxnumber) danum = n;
nbig = ((int64_t)danum*10)-(ch-'0');
if (nbig >= (int64_t)-maxnumber) danum = nbig;
}
}
else if (ch == 8 || ch == 127) // backspace
@ -5239,7 +5240,7 @@ int32_t _getnumber16(const char *namestart, int32_t num, int32_t maxnumber, char
int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, char sign, void *(func)(int32_t))
{
char buffer[80], ch;
int32_t n, danum, oldnum;
int32_t danum, oldnum;
danum = num;
oldnum = danum;
@ -5289,15 +5290,16 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha
if (ch >= '0' && ch <= '9')
{
int64_t nbig;
if (danum >= 0)
{
n = (danum*10)+(ch-'0');
if (n <= maxnumber) danum = n;
nbig = ((int64_t)danum*10)+(ch-'0');
if (nbig <= (int64_t)maxnumber) danum = nbig;
}
else if (sign)
{
n = (danum*10)-(ch-'0');
if (n >= -maxnumber) danum = n;
nbig = ((int64_t)danum*10)-(ch-'0');
if (nbig >= (int64_t)-maxnumber) danum = nbig;
}
}
else if (ch == 8 || ch == 127) // backspace
@ -5357,6 +5359,7 @@ const char* getstring_simple(const char *querystr, const char *defaultstr, int32
if (maxlen==1)
{
ei = qrylen;
buf[ei] = '_';
buf[ei+1] = 0;
}
@ -5373,7 +5376,11 @@ const char* getstring_simple(const char *querystr, const char *defaultstr, int32
ch = bgetchar();
if (ch==13)
{
if (maxlen != 1)
buf[ei] = 0;
break;
}
else if (keystatus[1])
{
clearkeys();
@ -5383,11 +5390,15 @@ const char* getstring_simple(const char *querystr, const char *defaultstr, int32
if (maxlen!=1)
{
if (ei>qrylen && (ch==8 || ch==127))
buf[--ei] = ' ';
else if ((unsigned)ei<sizeof(buf)-1 && ei-qrylen<maxlen && isalnum(ch))
{
buf[ei] = ' ';
buf[--ei] = '_';
}
else if ((unsigned)ei<sizeof(buf)-2 && ei-qrylen<maxlen && isprint(ch))
{
buf[ei++] = ch;
buf[ei] = 0;
buf[ei] = '_';
buf[ei+1] = 0;
}
}
else

View file

@ -10131,7 +10131,8 @@ void plotlines2d(int32_t *xx, int32_t *yy, int32_t numpoints, char col)
{
int32_t i;
if (rendmode >= 3)
#if defined(POLYMOST) && defined(USE_OPENGL)
if (rendmode >= 3 && qsetmode == 200)
{
palette_t p = getpal(col);
@ -10143,8 +10144,9 @@ void plotlines2d(int32_t *xx, int32_t *yy, int32_t numpoints, char col)
bglVertex2i(xx[i], yy[i]);
bglEnd();
return;
}
else
#endif
{
int32_t odrawlinepat = drawlinepat;
drawlinepat = 0xffffffff;

View file

@ -1,5 +1,27 @@
// m32 script test & show-off file
// do "include a" in the console
// m32 script editor extensions.
// to load, enter "include samples/a" (without quotes) in the console
// or into a file named m32_autoexec.cfg for automatic loading on startup.
// to enable all events, "enableevents all"
////////// USER SETTINGS //////////
// settings for the tweaking of Polymer pr_override*-variables with the keypad keys
define MINPARALLAXSCALE -10 // minimum pr_parallaxscale value
define MAXPARALLAXSCALE 10
define MINPARALLAXBIAS -10
define MAXPARALLAXBIAS 10
define PSCALESTEPS 1000 // 0..1 is mapped to 0..PSCALESTEPS
define PBIASSTEPS 1000
define MINSPECULARPOWER -10
define MAXSPECULARPOWER 1000
define MINSPECULARFACTOR -10
define MAXSPECULARFACTOR 1000
define SPOWERSTEPS 100
define SFACTORSTEPS 100
////////// END USER SETTINGS //////////
include names.h
@ -7,20 +29,14 @@ include names.h
gamevar i 0 1
gamevar j 0 1
gamevar k 0 1
gamevar l 0 1
gamevar m 0 1
gamevar p 0 1
gamevar q 0 1
gamevar r 0 1
gamevar x 0 0
gamevar y 0 0
gamevar z 0 0
gamevar gi 0 0
gamevar gj 0 0
gamevar gk 0 0
gamevar dx 0 0
gamevar dy 0 0
gamevar dz 0 0
@ -29,8 +45,6 @@ gamevar dang 0 0
gamevar tmp 0 0
gamevar cnt 0 0
gamevar thecount 0 0
gamevar davr 65536 0
gamevar dayx 65536 0
@ -56,9 +70,6 @@ definequote 23 WALL[%d].POINT2=%d out of range: sector[%d].wallptr=%d, endwall=%
definequote 24 WALL[%d].NEXTWALL=%d out of range: numwalls=%d!!!
definequote 25 WALL[%d].NEXTSECTOR=%d out of range: numsectors=%d!!!
definequote 27 OVERRIDE POLYMER PARALLAX & SPECULAR: OFF
definequote 28 OVERRIDE POLYMER PARALLAX & SPECULAR: ON
define PRSCALE 1000
define MAXSPECULAR 100000
@ -67,6 +78,8 @@ gamearray parm 8
// prints out maphack light definitions based on SE lights in map
defstate printlights
var flags
print "--PRLIGHTS--"
for i allsprites, ifactor SECTOREFFECTOR, ifge .lotag 49, ifle .lotag 50
{
@ -80,18 +93,18 @@ defstate printlights
set j 0, set k 0
}
set l 0
set flags 0
ifand .cstat 2
{
ifand .cstat 512
set l 4
set flags 4
else
set l 2
set flags 2
}
// range r g b
qsprintf TQUOTE LIGHTQUOTE .sectnum .x .y .z .hitag .xvel .yvel .zvel
j k .ang .extra .xoffset .yoffset l .owner
// radius fade horiz minshade maxshade prio tile
j k .ang .extra .xoffset .yoffset flags .owner
// radius fade horiz minshade maxshade prio tile
print TQUOTE
}
print "--ENDPRLIGHTS--"
@ -105,58 +118,51 @@ ends
// KP 1,2,3: RGB color (Shift inverts)
//
// when aiming at wall or sector:
// KP/ enable/disable overrides
// Ctrl-Shift-KP/ enable/disable parallax override
// Ctrl-Shift-KP* enable/disable bias override
// when overrides are on:
// KP 4,7: parallaxscale
// KP 8,9: parallaxbias
// KP 1,2: specularfactor
// KP 3,6: specularpower
// KP 5,8: parallaxscale
// KP 4,6: parallaxbias
// KP /,*: specularfactor
// KP 7,9: specularpower
//
// Also try Shift and/or Ctrl modifiers for different increments
defstate fiddlewithlights
ife searchstat 3 nullop else
var minval maxval
ifaimingsprite nullop else
{
ifeitherctrl ifhitkey KEY_gSLASH
ifeitheralt ifhitkey KEY_gSLASH
{
ife pr_overrideparallax 0
{
set pr_overrideparallax 1
set pr_overridespecular 1
quote 28
}
xor pr_overrideparallax 1, and pr_overrideparallax 1
ife pr_overrideparallax 1
quote "OVERRIDE POLYMER PARALLAX: ON"
else
{
set pr_overrideparallax 0
set pr_overridespecular 0
quote 27
}
quote "OVERRIDE POLYMER PARALLAX: OFF"
}
else ifeitheralt ifhitkey KEY_gSTAR
{
xor pr_overridespecular 1, and pr_overridespecular 1
ife pr_overridespecular 1
quote "OVERRIDE POLYMER SPECULAR: ON"
else
quote "OVERRIDE POLYMER SPECULAR: OFF"
}
}
// if aiming at sector or wall
ife searchstat 3 nullop
ifaimingsprite nullop
else ifn pr_overrideparallax 0
{
// polymer override parallaxscale
set j 0 set k 0
ifhitkey KEY_KP5 set j -1 //pscale
ifhitkey KEY_KP8 set j 1
ifhitkey KEY_KP5 set j -1, ifhitkey KEY_KP8 set j 1
ifn j 0 set k 1
ifhitkey KEY_KP4 set j -1 //pbias
ifhitkey KEY_KP6 set j 1
ifhitkey KEY_KP4 set j -1, ifhitkey KEY_KP6 set j 1
ife k 0 ifn j 0 set k 2
ifhitkey KEY_gSLASH set j -1 //sfac
ifhitkey KEY_gSTAR set j 1
ife k 0 ifn j 0 set k 3
ifhitkey KEY_KP7 set j -1 //spow
ifhitkey KEY_KP9 set j 1
ife k 0 ifn j 0 set k 4
ifeithershift mul j 2 else mul j 10
ifeithershift mul j 10
ifeitherctrl mul j 10
switch k
@ -164,9 +170,11 @@ defstate fiddlewithlights
case 1:
{
set k pr_parallaxscale
ftoi k PRSCALE // must convert to scaled integer, scale is 1:PRSCALE
add k j, clamp k -10000 10000
itof k PRSCALE // convert back
ftoi k PSCALESTEPS // must convert to scaled integer, maps 0..1 to 0..PARALLAXSTEPS
set minval MINPARALLAXSCALE, mul minval PSCALESTEPS
set maxval MAXPARALLAXSCALE, mul maxval PSCALESTEPS
add k j, al k, clamp k minval maxval, al k
itof k PSCALESTEPS // convert back
qsprintf TQUOTE "PARALLAX SCALE: %f" k, quote TQUOTE
set pr_parallaxscale k
break;
@ -174,15 +182,43 @@ defstate fiddlewithlights
case 2:
{
set k pr_parallaxbias
ftoi k PRSCALE, add k j, clamp k -10000 10000, itof k PRSCALE
ftoi k PBIASSTEPS
set minval MINPARALLAXBIAS, mul minval PBIASSTEPS
set maxval MAXPARALLAXBIAS, mul maxval PBIASSTEPS
add k j, clamp k minval maxval
itof k PBIASSTEPS
qsprintf TQUOTE "PARALLAX BIAS: %f" k, quote TQUOTE
set pr_parallaxbias k
break;
}
endswitch
}
// if aiming at sector or wall
ifaimingsprite nullop
else ifn pr_overridespecular 0
{
set j 0 set k 0
ifhitkey KEY_gSLASH set j -1, ifhitkey KEY_gSTAR set j 1
ifn j 0 set k 3
ifhitkey KEY_KP7 set j -1, ifhitkey KEY_KP9 set j 1
ife k 0 ifn j 0 set k 4
ifeithershift mul j 10
ifeitherctrl mul j 10
switch k
case 0: break;
case 3:
{
set k pr_specularfactor
ftoi k PRSCALE, add k j, clamp k 0 MAXSPECULAR, itof k PRSCALE
ftoi k SFACTORSTEPS
set minval MINSPECULARFACTOR, mul minval SFACTORSTEPS
set maxval MAXSPECULARFACTOR, mul maxval SFACTORSTEPS
add k j, clamp k minval maxval
itof k SFACTORSTEPS
qsprintf TQUOTE "SPECULAR FACTOR: %f" k, quote TQUOTE
set pr_specularfactor k
break;
@ -190,7 +226,11 @@ defstate fiddlewithlights
case 4:
{
set k pr_specularpower
ftoi k PRSCALE, add k j, clamp k 0 MAXSPECULAR, itof k PRSCALE
ftoi k SPOWERSTEPS
set minval MINSPECULARPOWER, mul minval SPOWERSTEPS
set maxval MAXSPECULARPOWER, mul maxval SPOWERSTEPS
add k j, clamp k minval maxval
itof k SPOWERSTEPS
qsprintf TQUOTE "SPECULAR POWER: %f" k, quote TQUOTE
set pr_specularpower k
break;
@ -198,9 +238,9 @@ defstate fiddlewithlights
endswitch
}
// if aiming at a sprite that's not a Polymer light
set k 0
ife searchstat 3 set k 1
ifaimingsprite set k 1 else set k 0
ife k 1 ife sprite[searchwall].picnum SECTOREFFECTOR
ifge sprite[searchwall].lotag 49 ifle sprite[searchwall].lotag 50
@ -215,20 +255,21 @@ defstate fiddlewithlights
{
ifhitkey KEY_KP1
{
getnumber256 .xvel "XVEL:" 255
getnumber256 .yvel "YVEL:" 255
getnumber256 .zvel "ZVEL:" 255
getnumber256 .xvel "XVEL: " 0
getnumber256 .yvel "YVEL: " 0
getnumber256 .zvel "ZVEL: " 0
}
else ifhitkey KEY_KP2
{
getnumber256 .owner "OWNER:" -MAXTILES
getnumber256 .owner "OWNER: " 0
ifl .owner 0 set .owner -1
}
}
}
// if aiming at an SE with lotag 49 or 50 (Polymer light)
ife searchstat 3 ife sprite[searchwall].picnum SECTOREFFECTOR
ifaimingsprite ife sprite[searchwall].picnum SECTOREFFECTOR
ifge sprite[searchwall].lotag 49 ifle sprite[searchwall].lotag 50
{
set i searchwall, seti i // set current sprite = targeted sprite
@ -274,6 +315,7 @@ defstate fiddlewithlights
{
set .xoffset 0
set .yoffset 0
quote "Reset X and Y OFFSET (min/max shade) to 0"
}
}
else
@ -284,7 +326,7 @@ defstate fiddlewithlights
ife k 1
{
qsprintf TQUOTE "XY offset: %d %d" .xoffset .yoffset
qsprintf TQUOTE "XY OFFSET (min/max shade): %d %d" .xoffset .yoffset
quote TQUOTE
}
}
@ -294,13 +336,14 @@ defstate fiddlewithlights
{
ifhitkey KEY_KP1
{
getnumber256 .xvel "RED:" 255
getnumber256 .yvel "GREEN:" 255
getnumber256 .zvel "BLUE:" 255
getnumber256 .xvel "XVEL (red): " 255
getnumber256 .yvel "YVEL (green): " 255
getnumber256 .zvel "ZVEL (blue): " 255
}
else ifhitkey KEY_KP2
{
getnumber256 .owner "PICNUM:" -MAXTILES
getnumber256 .owner "OWNER (projection picnum): " -MAXTILES
ifl .owner 0 set .owner -1
}
}
else
@ -319,7 +362,7 @@ defstate fiddlewithlights
clamp .yvel 1 255
clamp .zvel 1 255
qsprintf TQUOTE "RGB color: %d %d %d" .xvel .yvel .zvel
qsprintf TQUOTE "XYZ VEL (RGB color): %d %d %d" .xvel .yvel .zvel
quote TQUOTE
}
}
@ -412,15 +455,9 @@ onevent EVENT_DRAW2DSCREEN
set k i, add k 1, set k ar[k]
drawline16b sprite[j].x sprite[j].y sprite[k].x sprite[k].y drawcol
}
/*
set drawlinepat -1
for i allsprites
ifactor LIZTROOP
drawcircle16b sprite[i].x sprite[i].y 256 drawcol
*/
////////// polymer light 2d projections //////////
var c d h x2 y2 oldpat
var c d h r x2 y2 oldpat
array xx 2
array yy 2
@ -520,7 +557,7 @@ define DUP_ROT_MAGIC 123
// .yrepeat*32: z delta (positive if pal!=0, i.e. going down)
// .shade: count (-128 to 0 -> 255 to 128)
defstate duprot
ifn searchstat 3 return
ifaimingsprite nullop else return
ifn sprite[searchwall].extra DUP_ROT_MAGIC return
set p searchwall // pivot sprite
@ -549,7 +586,7 @@ ends
// same as above but with tsprite[], as a kind of preview
defstate tduprot
ifn searchstat 3 return
ifaimingsprite nullop else return
ifn sprite[searchwall].extra DUP_ROT_MAGIC return
set p searchwall // pivot sprite
@ -587,7 +624,7 @@ define DUP_LIN_MAGIC2 345
// .extra=234 (1st sprite), =345 (2nd, aimed at sprite)
// .shade: count (-128 to 0 -> 255 to 128)
defstate duplin
ifn searchstat 3 return
ifaimingsprite nullop else return
ifn sprite[searchwall].extra DUP_LIN_MAGIC2 return
set r searchwall // 2nd reference point
@ -623,7 +660,7 @@ defstate duplin
ends
defstate tduplin
ifn searchstat 3 return
ifaimingsprite nullop else return
ifn sprite[searchwall].extra DUP_LIN_MAGIC2 return
set r searchwall // 2nd reference point
@ -667,8 +704,10 @@ onevent EVENT_ANALYZESPRITES
endevent
onevent EVENT_KEYS3D
var l m
// door sound tester
ife searchstat 0
ifaimingwall
ifholdkey KEY_SPACE
{
set k wall[searchwall].nextsector
@ -688,7 +727,7 @@ onevent EVENT_KEYS3D
}
// swinging doors tester -- hit space on a door wall
ife searchstat 0
ifaimingwall
ifhitkey KEY_SPACE // SE11 ST23 up:ccw
{
set k wall[searchwall].nextsector
@ -744,7 +783,7 @@ onevent EVENT_KEYS3D
}
// teleporter -- works on SE7 and SE17 (elevator)
ife searchstat 3
ifaimingsprite
ifhitkey KEY_SPACE
{
ife sprite[searchwall].picnum SECTOREFFECTOR

View file

@ -109,31 +109,11 @@ int32_t showambiencesounds=2;
//////////////////// Aiming ////////////////////
#define SEARCH_WALL 0
#define SEARCH_CEILING 1
#define SEARCH_FLOOR 2
#define SEARCH_SPRITE 3
#define SEARCH_MASKWALL 4
static const char *Typestr[] = { "Wall", "Ceiling", "Floor", "Sprite", "Wall" };
static const char *typestr[] = { "wall", "ceiling", "floor", "sprite", "wall" };
static const char *Typestr_wss[] = { "Wall", "Sector", "Sector", "Sprite", "Wall" };
/*static const char *typestr_wss[] = { "wall", "sector", "sector", "sprite", "wall" };*/
//#define AIMED_obj (typestr[searchstat])
#define ASSERT_AIMING (searchstat>=0 && searchstat<=4)
#define AIMING_AT_WALL (searchstat==0)
#define AIMING_AT_CEILING (searchstat==1)
#define AIMING_AT_FLOOR (searchstat==2)
#define AIMING_AT_SPRITE (searchstat==3)
#define AIMING_AT_MASKWALL (searchstat==4)
#define AIMING_AT_WALL_OR_MASK (AIMING_AT_WALL || AIMING_AT_MASKWALL)
#define AIMING_AT_CEILING_OR_FLOOR (AIMING_AT_CEILING || AIMING_AT_FLOOR)
/** The following macros multiplex between identically named fields of sector/wall/sprite,
* based on a macro parameter or the currently aimed at object (AIMED_ versions).
* They can be used on either side of an assignment. */
@ -2688,7 +2668,8 @@ static int32_t s_Zoom = INITIAL_ZOOM;
static int32_t s_TileZoom = 1;
static char tilesel_errmsg[128], tilesel_showerr=0;
static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, int32_t nYTiles, int32_t TileDim, int32_t offset);
static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, int32_t nYTiles,
int32_t TileDim, int32_t offset, int32_t showmsg);
#define TMPERRMSG_SHOW(alsoOSD) do { \
printext256(0, 0, whitecol, 0, tilesel_errmsg, 0); \
@ -2868,15 +2849,9 @@ static int32_t m32gettile(int32_t idInitialTile)
zoomsz = ZoomToThumbSize[s_Zoom];
DrawTiles(iTopLeftTile, (iTile >= localartlookupnum) ? localartlookupnum-1 : iTile,
nXTiles, nYTiles, zoomsz, moffset);
nXTiles, nYTiles, zoomsz, moffset,
(tilesel_showerr && (iTile==iLastTile || (tilesel_showerr=0))));
if (tilesel_showerr)
{
if (iTile == iLastTile)
TMPERRMSG_SHOW(0);
else
tilesel_showerr = 0;
}
iLastTile = iTile;
idle_waitevent_timeout(500);
@ -3056,12 +3031,6 @@ static int32_t m32gettile(int32_t idInitialTile)
iTile = ((iTile+nXTiles)/nXTiles)*nXTiles - 1;
}
//
// Ensure tilenum is within valid range
//
iTile = clamp(iTile, 0, localartlookupnum-1);
// 'V' KEYPRESS
if (PRESSED_KEYSC(V))
iTile = SelectAllTiles(iTile);
@ -3114,6 +3083,39 @@ static int32_t m32gettile(int32_t idInitialTile)
if (PRESSED_KEYSC(Z))
s_TileZoom = !s_TileZoom;
//
// Ensure tilenum is within valid range
//
iTile = clamp(iTile, 0, localartlookupnum-1);
// 'S' KEYPRESS: search for named tile
if (PRESSED_KEYSC(S))
{
static char laststr[MAXTILES] = "";
const char *searchstr = getstring_simple("Search for tile name: ", laststr, MAXTILES-1);
if (searchstr && searchstr[0])
{
int32_t i, i0;
Bstrcpy(laststr, searchstr);
i0 = localartlookup[iTile];
if (searchstr[0]=='^')
{
for (i=(i0+1)%MAXTILES; i!=i0; i=(i+1)%MAXTILES)
if ((searchstr[0]=='^' && !Bstrcmp(names[i], searchstr+1)) ||
(searchstr[0]!='^' && strstr(names[i], searchstr)))
{
SelectAllTiles(iTile);
iTile = i;
break;
}
}
}
}
//
// Adjust top-left to ensure tilenum is within displayed range of tiles
//
@ -3247,15 +3249,21 @@ static int32_t OnSaveTileGroup()
if (!name || !*name)
return 1;
for (i=0; name[i]; i++)
if (!(isalnum(name[i]) || name[i]==' ' || name[i]==','))
TMPERRMSG_RETURN("%s", "Name may only consist of alphabetic, numeric and space characters.");
{
int32_t lasti=-1, col=0, k, opathsearchmode=pathsearchmode;
int32_t lasti=-1, col=0, j, k, opathsearchmode=pathsearchmode;
BFILE *fp;
pathsearchmode = pathsearchmode_oninit; // use the same pathsearchmode as on init
fp = fopenfrompath(default_tiles_cfg, "a");
pathsearchmode = opathsearchmode;
if (!fp)
TMPERRMSG_RETURN("Could not open `%s' for appending: %s.", default_tiles_cfg, strerror(errno));
TMPERRMSG_RETURN("Could not open `%s' for writing: %s.", default_tiles_cfg, strerror(errno));
if (fseek(fp, 0, BSEEK_END)) // seems to be necessary even though we fopen with "a"
TMPERRMSG_RETURN("Could not seek to end of file `%s'.", default_tiles_cfg);
#define TTAB "\t"
#define TBITCHK(i) ((i)<MAXTILES && (tilemarked[(i)>>3]&(1<<((i)&7))))
@ -3263,6 +3271,10 @@ static int32_t OnSaveTileGroup()
Bfprintf(fp, "tilegroup \"%s\"\n{\n", name);
Bfprintf(fp, TTAB "hotkey \"%c\"\n\n", hotkey);
if (!(s_TileGroups[tile_groups].pIds = Bmalloc(n * sizeof(s_TileGroups[tile_groups].pIds[0]))))
TMPERRMSG_RETURN("%s", "Out of memory.");
j = 0;
// tileranges for consecutive runs of 3 or more tiles
for (i=0; i<MAXTILES; i++)
{
@ -3274,7 +3286,10 @@ static int32_t OnSaveTileGroup()
Bfprintf(fp, TTAB "tilerange %d %d\n", lasti, i-1);
for (k=lasti; k<i; k++)
tilemarked[i>>3] &= ~(1<<(i&7));
{
s_TileGroups[tile_groups].pIds[j++] = k;
tilemarked[k>>3] &= ~(1<<(k&7));
}
lasti = -1;
}
@ -3287,8 +3302,15 @@ static int32_t OnSaveTileGroup()
}
}
}
if (lasti>=0)
if (lasti>=0 && lasti<=MAXTILES-3)
{
for (k=lasti; k<MAXTILES; k++)
{
s_TileGroups[tile_groups].pIds[j++] = k;
tilemarked[k>>3] &= ~(1<<(k&7));
}
Bfprintf(fp, TTAB "tilerange %d %d\n", lasti, MAXTILES-1);
}
Bfprintf(fp, "\n");
// throw them all in a tiles{...} group else
@ -3297,10 +3319,12 @@ static int32_t OnSaveTileGroup()
{
if (TBITCHK(i))
{
s_TileGroups[tile_groups].pIds[j++] = i;
if (col==0)
Bfprintf(fp, TTAB TTAB), col+=8;
if (names[i])
if (names[i][0])
col+=Bfprintf(fp, "%s ", names[i]);
else
col+=Bfprintf(fp, "%d ", i);
@ -3321,10 +3345,19 @@ static int32_t OnSaveTileGroup()
Bfclose(fp);
if (loadtilegroups(default_tiles_cfg))
TMPERRMSG_PRINT("%s", "Wrote new tile group but failed reloading them.");
else
TMPERRMSG_PRINT("%s", "Wrote and reloaded new tile group.");
if (!(s_TileGroups[tile_groups].szText = Bstrdup(name)))
{
Bfree(s_TileGroups[tile_groups].pIds);
TMPERRMSG_RETURN("%s", "Out of memory.");
}
s_TileGroups[tile_groups].nIds = n;
s_TileGroups[tile_groups].key1 = Btoupper(hotkey);
s_TileGroups[tile_groups].key2 = Btolower(hotkey);
s_TileGroups[tile_groups].color1 = s_TileGroups[tile_groups].color2 = 0;
tile_groups++;
TMPERRMSG_PRINT("%s", "Wrote and installed new tile group.");
}
return 0;
@ -3469,11 +3502,6 @@ static int32_t OnSelectTile(int32_t iTile)
return iTile;
}
#undef TMPERRMSG_SHOW
#undef TMPERRMSG_PRINT
#undef TMPERRMSG_RETURN
static const char *GetTilePixels(int32_t idTile)
{
char *pPixelData = 0;
@ -3490,7 +3518,8 @@ static const char *GetTilePixels(int32_t idTile)
return pPixelData;
}
static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, int32_t nYTiles, int32_t TileDim, int32_t offset)
static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, int32_t nYTiles,
int32_t TileDim, int32_t offset, int32_t showmsg)
{
int32_t XTile, YTile;
int32_t iTile, idTile;
@ -3635,6 +3664,9 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i
Bsprintf(szT,"%d, %d",(picanm[idTile]>>8)&0xFF,(picanm[idTile]>>16)&0xFF);
printext256((xdim>>2)+100,ydim-10,whitecol,-1,szT,0);
if (showmsg)
TMPERRMSG_SHOW(0);
m32_showmouse();
enddrawing();
@ -3644,6 +3676,11 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i
}
#undef TMPERRMSG_SHOW
#undef TMPERRMSG_PRINT
#undef TMPERRMSG_RETURN
static int32_t spriteonceilingz(int32_t searchwall)
{
int32_t z=sprite[searchwall].z;
@ -8016,51 +8053,63 @@ int32_t GAME_getrowheight(int32_t w)
#define BITS 8+16+64 // solid
#define SHADE 16
#define PALETTE 4
void GAME_clearbackground(int32_t c, int32_t r)
void GAME_clearbackground(int32_t numcols, int32_t numrows)
{
int32_t x, y, xsiz, ysiz, tx2, ty2;
int32_t daydim, bits;
UNREFERENCED_PARAMETER(numcols);
UNREFERENCED_PARAMETER(c);
/*
#ifdef _WIN32
if (qsetmode != 200)
#if defined(POLYMOST) && defined(USE_OPENGL)
// if (getrendermode() < 3) bits = BITS;
// else
if (rendmode>=3 && qsetmode==200)
{
OSD_SetFunctions(
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
(int32_t(*)(void))GetTime,
NULL
);
return;
int32_t x, y, xsiz, ysiz, tx2, ty2;
int32_t daydim, bits;
bits = BITSTL;
daydim = numrows<<3;
xsiz = tilesizx[BGTILE];
tx2 = xdim/xsiz;
ysiz = tilesizy[BGTILE];
ty2 = daydim/ysiz;
setpolymost2dview();
for (x=0; x<=tx2; x++)
for (y=0; y<=ty2; y++)
rotatesprite(x*xsiz<<16,y*ysiz<<16,65536L,0,BGTILE,SHADE,PALETTE,bits,0,0,xdim,daydim);
xsiz = tilesizy[BORDTILE];
tx2 = xdim/xsiz;
ysiz = tilesizx[BORDTILE];
for (x=0; x<=tx2; x++)
rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536,BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1);
return;
}
#endif
*/
if (getrendermode() < 3) bits = BITS;
else bits = BITSTL;
#endif
daydim = r<<3;
xsiz = tilesizx[BGTILE];
tx2 = xdim/xsiz;
ysiz = tilesizy[BGTILE];
ty2 = daydim/ysiz;
for (x=0; x<=tx2; x++)
for (y=0; y<=ty2; y++)
rotatesprite(x*xsiz<<16,y*ysiz<<16,65536L,0,BGTILE,SHADE,PALETTE,bits,0,0,xdim,daydim);
xsiz = tilesizy[BORDTILE];
tx2 = xdim/xsiz;
ysiz = tilesizx[BORDTILE];
for (x=0; x<=tx2; x++)
rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536,BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1);
CLEARLINES2D(0, min(ydim, numrows*8+8), editorcolors[16]);
}
static void m32_osdsetfunctions()
{
OSD_SetFunctions(
/* GAME_drawosdchar,
GAME_drawosdstr,
GAME_drawosdcursor,
GAME_getcolumnwidth,
GAME_getrowheight,*/
0,0,0,0,0,
GAME_clearbackground,
(int32_t( *)(void))GetTime,
NULL
);
}
#endif
enum
@ -8937,17 +8986,7 @@ int32_t ExtInit(void)
autosavetimer = totalclock+120*autosave;
#if defined(_WIN32) && defined(DUKEOSD)
OSD_SetFunctions(
/* GAME_drawosdchar,
GAME_drawosdstr,
GAME_drawosdcursor,
GAME_getcolumnwidth,
GAME_getrowheight,*/
0,0,0,0,0,
GAME_clearbackground,
(int32_t( *)(void))GetTime,
NULL
);
m32_osdsetfunctions();
#endif
OSD_SetParameters(0,2, 0,0, 4,0);
@ -9632,33 +9671,7 @@ static void Keys2d3d(void)
getmessageleng = 0;
getmessagetimeoff = 0;
#if defined(_WIN32) && defined(DUKEOSD)
if (qsetmode == 200)
{
OSD_SetFunctions(
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
(int32_t( *)(void))GetTime,
NULL
);
}
else
{
OSD_SetFunctions(
/* GAME_drawosdchar,
GAME_drawosdstr,
GAME_drawosdcursor,
GAME_getcolumnwidth,
GAME_getrowheight,*/
0,0,0,0,0,
GAME_clearbackground,
(int32_t( *)(void))GetTime,
NULL
);
}
m32_osdsetfunctions();
#endif
}

View file

@ -299,6 +299,9 @@ const char *keyw[] =
"ifinwater",
"ifoutside",
"ifnosounds",
"ifaimingsprite",
"ifaimingwall",
"ifaimingsector",
// BUILD functions
"resetkey",
@ -2895,6 +2898,9 @@ repeatcase:
/// case CON_IFINOUTERSPACE:
/// case CON_IFCANSEETARGET:
case CON_IFNOSOUNDS:
case CON_IFAIMINGSPRITE:
case CON_IFAIMINGWALL:
case CON_IFAIMINGSECTOR:
{
ofstype offset;
ofstype lastScriptOfs = (g_scriptPtr-script-1);

View file

@ -397,6 +397,9 @@ enum ScriptKeywords_t
/// CON_IFINOUTERSPACE,
/// CON_IFCANSEETARGET,
CON_IFNOSOUNDS,
CON_IFAIMINGSPRITE,
CON_IFAIMINGWALL,
CON_IFAIMINGSECTOR,
// BUILD functions
CON_RESETKEY,

View file

@ -883,8 +883,9 @@ skip_check:
{
int32_t bits=Gv_GetVarX(*insptr), scale=*(insptr+1);
float fval = *((float *)&bits);
Gv_SetVarX(*insptr, (int32_t)(fval * scale));
// rounding must absolutely be!
//OSD_Printf("ftoi: bits:%8x, scale=%d, fval=%f, (int32_t)(fval*scale)=%d\n", bits, scale, fval, (int32_t)(fval*scale));
Gv_SetVarX(*insptr, (int32_t)nearbyintf(fval * scale));
}
insptr += 2;
continue;
@ -894,7 +895,6 @@ skip_check:
{
int32_t scaled=Gv_GetVarX(*insptr), scale=*(insptr+1);
float fval = (float)scaled/(float)scale;
Gv_SetVarX(*insptr, *((int32_t *)&fval));
}
insptr += 2;
@ -2170,13 +2170,17 @@ badindex:
continue;
{
int32_t max=Gv_GetVarX(*insptr++), sign=ksgn(max)<0?1:0;
int32_t max=Gv_GetVarX(*insptr++), sign=(max<=0);
char buf[64]; // buffers in getnumber* are 80 bytes long
// no danger of accessing unallocated memory since we took care in C_SetScriptSize()
Bmemcpy(buf, quotetext, sizeof(buf));
buf[sizeof(buf)-1]='\0';
if (max==0)
max = INT_MAX;
OSD_Printf("max:%d, sign:%d\n", max, sign);
if (tw==CON_GETNUMBER16)
Gv_SetVarX(var, getnumber16(quotetext, Gv_GetVarX(var), max, sign));
else
@ -2732,6 +2736,16 @@ dodefault:
}
continue;
case CON_IFAIMINGSPRITE:
VM_DoConditional(AIMING_AT_SPRITE);
continue;
case CON_IFAIMINGWALL:
VM_DoConditional(AIMING_AT_WALL_OR_MASK);
continue;
case CON_IFAIMINGSECTOR:
VM_DoConditional(AIMING_AT_CEILING_OR_FLOOR);
continue;
case CON_GETSOUNDFLAGS:
insptr++;
{

View file

@ -167,7 +167,7 @@ int32_t MUSIC_Init(int32_t SoundCard, int32_t Address)
goto fallback;
sz = (numargs+2)*sizeof(char *) + (c-command+1);
sz = ((sz+pagesize)/pagesize)*pagesize;
sz = ((sz+pagesize-1)/pagesize)*pagesize;
external_midi_argv = Bmemalign(pagesize, sz);
if (!external_midi_argv)