2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
Copyright ( C ) 1996 , 2003 - 3 D Realms Entertainment
2007-02-08 04:19:39 +00:00
Copyright ( C ) 2004 , 2007 - EDuke32 developers
2006-04-13 20:47:06 +00:00
2007-02-08 04:19:39 +00:00
This file is part of EDuke32
2006-04-13 20:47:06 +00:00
2007-02-08 04:19:39 +00:00
EDuke32 is free software ; you can redistribute it and / or
2006-04-13 20:47:06 +00:00
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2006-11-13 23:12:47 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
2006-04-13 20:47:06 +00:00
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
//-------------------------------------------------------------------------
# include "compat.h"
# include "build.h"
# include "editor.h"
# include "pragmas.h"
# include "baselayer.h"
# include "names.h"
# include "osd.h"
# include "osdfuncs.h"
# include "cache1d.h"
# include "mapster32.h"
# include "keys.h"
# include "types.h"
# include "keyboard.h"
2006-07-26 01:10:33 +00:00
# include "scriptfile.h"
2007-04-17 05:54:12 +00:00
# include "crc32.h"
2006-04-13 20:47:06 +00:00
2008-07-27 11:35:41 +00:00
# ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
2008-10-14 08:40:59 +00:00
# include <shellapi.h>
2008-07-27 11:35:41 +00:00
# endif
2009-02-02 01:49:14 +00:00
# define BUILDDATE " 20090131"
2008-07-22 09:05:34 +00:00
# define VERSION " 1.2.0devel"
2006-04-13 20:47:06 +00:00
2009-01-09 09:29:17 +00:00
static int32_t floor_over_floor ;
2006-04-13 20:47:06 +00:00
2008-03-22 00:22:48 +00:00
// static char *startwin_labeltext = "Starting Mapster32...";
2007-01-30 02:04:14 +00:00
static char setupfilename [ BMAX_PATH ] = " mapster32.cfg " ;
2007-01-21 23:49:07 +00:00
static char defaultduke3dgrp [ BMAX_PATH ] = " duke3d.grp " ;
static char * duke3dgrp = defaultduke3dgrp ;
2009-01-09 09:29:17 +00:00
static int32_t fixmapbeforesaving = 1 ;
static int32_t lastsave = - 180 * 60 ;
static int32_t NoAutoLoad = 0 ;
int32_t spnoclip = 1 ;
2007-01-21 23:49:07 +00:00
2008-03-22 10:23:57 +00:00
# if !defined(_WIN32)
2009-01-09 09:29:17 +00:00
static int32_t usecwd = 0 ;
2008-03-22 10:23:57 +00:00
# endif
2007-01-21 23:49:07 +00:00
static struct strllist
{
struct strllist * next ;
char * str ;
}
2007-12-12 15:27:34 +00:00
* CommandPaths = NULL , * CommandGrps = NULL ;
2006-04-13 20:47:06 +00:00
2009-01-09 09:29:17 +00:00
# define MAXHELP2D (int32_t)(sizeof(Help2d) / sizeof(Help2d[0]))
2008-05-16 00:23:33 +00:00
# define eitherALT (keystatus[KEYSC_LALT]| keystatus[KEYSC_RALT])
# define eitherCTRL (keystatus[KEYSC_LCTRL]| keystatus[KEYSC_RCTRL])
# define eitherSHIFT (keystatus[KEYSC_LSHIFT]|keystatus[KEYSC_RSHIFT])
2007-04-17 05:54:12 +00:00
static char * Help2d [ ] =
2007-08-25 01:05:00 +00:00
{
" 'A = Autosave toggle " ,
" 'J = Jump to location " ,
" 'L = Adjust sprite/wall coords " ,
" 'S = Sprite size " ,
" '3 = Caption mode " ,
" '7 = Swap tags " ,
" 'F = Special functions " ,
" X = Horiz. flip selected sects " ,
" Y = Vert. flip selected sects " ,
" F5 = Item count " ,
" F6 = Actor count/SE help " ,
" F7 = Edit sector " ,
" F8 = Edit wall/sprite " ,
" F9 = Sector tag help " ,
" Ctrl-S = Quick save " ,
" Alt-F7 = Search sector lotag " ,
" Alt-F8 = Search wall/sprite tags " ,
" [ = Search forward " ,
" ] = Search backward " ,
} ;
2007-04-17 05:54:12 +00:00
static char * SpriteMode [ ] =
2007-08-25 01:05:00 +00:00
{
" NONE " ,
" SECTORS " ,
" WALLS " ,
" SPRITES " ,
" ALL " ,
" ITEMS ONLY " ,
" CURRENT SPRITE ONLY " ,
" ONLY SECTOREFFECTORS AND SECTORS " ,
" NO SECTOREFFECTORS OR SECTORS "
} ;
2006-04-13 20:47:06 +00:00
# define MAXSKILL 5
2007-04-17 05:54:12 +00:00
static char * SKILLMODE [ MAXSKILL ] =
2007-08-25 01:05:00 +00:00
{
" Actor skill display: PIECE OF CAKE " ,
" Actor skill display: LET'S ROCK " ,
" Actor skill display: COME GET SOME " ,
" Actor skill display: DAMN I'M GOOD " ,
" Actor skill display: ALL SKILL LEVELS "
} ;
2006-04-13 20:47:06 +00:00
# define MAXNOSPRITES 4
2007-04-17 05:54:12 +00:00
static char * SPRDSPMODE [ MAXNOSPRITES ] =
2007-08-25 01:05:00 +00:00
{
" Sprite display: DISPLAY ALL SPRITES " ,
" Sprite display: NO EFFECTORS " ,
" Sprite display: NO ACTORS " ,
" Sprite display: NO EFFECTORS OR ACTORS "
} ;
2006-04-13 20:47:06 +00:00
2009-01-09 09:29:17 +00:00
# define MAXHELP3D (int32_t)(sizeof(Help3d) / sizeof(Help3d[0]))
2007-04-17 05:54:12 +00:00
static char * Help3d [ ] =
2007-08-25 01:05:00 +00:00
{
" Mapster32 3D mode help " ,
" " ,
" F1 = TOGGLE THIS HELP DISPLAY " ,
" F2 = TOGGLE CLIPBOARD " ,
" F3 = MOUSELOOK " ,
" F6 = AUTOMATIC SECTOREFFECTOR HELP " ,
" F7 = AUTOMATIC SECTOR TAG HELP " ,
" " ,
" ' A = TOGGLE AUTOSAVE " ,
" ' D = CYCLE SPRITE SKILL DISPLAY " ,
" ' R = TOGGLE FRAMERATE DISPLAY " ,
" ' W = TOGGLE SPRITE DISPLAY " ,
2008-06-05 02:29:18 +00:00
" ' X = MAP SHADE PREVIEW " ,
2007-08-25 01:05:00 +00:00
" ' Y = TOGGLE PURPLE BACKGROUND " ,
" " ,
" ' T = CHANGE LOTAG " ,
" ' H = CHANGE HITAG " ,
" ' S = CHANGE SHADE " ,
" ' M = CHANGE EXTRA " ,
" ' V = CHANGE VISIBILITY " ,
" ' L = CHANGE OBJECT COORDINATES " ,
" ' C = CHANGE GLOBAL SHADE " ,
" " ,
" ' ENTER = PASTE GRAPHIC ONLY " ,
" ' P & ; P = PASTE PALETTE TO ALL SELECTED SECTORS " ,
" ; V = SET VISIBILITY ON ALL SELECTED SECTORS " ,
" ' DEL = CSTAT=0 " ,
" CTRL-S = SAVE BOARD " ,
" HOME = PGUP/PGDN MODIFIER (256 UNITS) " ,
" END = PGUP/PGDN MODIFIER (512 UNITS) " ,
} ;
2008-06-09 23:41:54 +00:00
static char * type2str [ ] = { " Wall " , " Sector " , " Sector " , " Sprite " , " Wall " } ;
2006-04-13 20:47:06 +00:00
2007-02-25 21:11:59 +00:00
static CACHE1D_FIND_REC * finddirs = NULL , * findfiles = NULL , * finddirshigh = NULL , * findfileshigh = NULL ;
2009-01-09 09:29:17 +00:00
static int32_t numdirs = 0 , numfiles = 0 ;
static int32_t currentlist = 0 ;
static int32_t mouseaction = 0 , mouseax = 0 , mouseay = 0 ;
static int32_t repeatcountx , repeatcounty ;
static int32_t infobox = 3 ; // bit0: current window, bit1: mouse pointer, the variable should be renamed
2008-05-16 19:51:38 +00:00
extern char mskip ;
2009-01-09 09:29:17 +00:00
extern int16_t capturecount ;
extern int32_t editorgridextent ; // in engine.c
2008-10-14 08:40:59 +00:00
extern char game_executable [ BMAX_PATH ] ;
2007-02-25 21:11:59 +00:00
2009-01-09 09:29:17 +00:00
extern int32_t fillsector ( int16_t sectnum , char fillcolor ) ;
2008-12-19 00:53:54 +00:00
2007-02-25 21:11:59 +00:00
static void clearfilenames ( void )
{
klistfree ( finddirs ) ;
klistfree ( findfiles ) ;
finddirs = findfiles = NULL ;
numfiles = numdirs = 0 ;
}
2009-01-09 09:29:17 +00:00
static int32_t getfilenames ( const char * path , char kind [ ] )
2007-02-25 21:11:59 +00:00
{
CACHE1D_FIND_REC * r ;
clearfilenames ( ) ;
finddirs = klistpath ( path , " * " , CACHE1D_FIND_DIR ) ;
findfiles = klistpath ( path , kind , CACHE1D_FIND_FILE ) ;
for ( r = finddirs ; r ; r = r - > next ) numdirs + + ;
for ( r = findfiles ; r ; r = r - > next ) numfiles + + ;
finddirshigh = finddirs ;
findfileshigh = findfiles ;
currentlist = 0 ;
if ( findfileshigh ) currentlist = 1 ;
return ( 0 ) ;
}
2006-04-13 20:47:06 +00:00
void ExtLoadMap ( const char * mapname )
{
2009-01-09 09:29:17 +00:00
int32_t i ;
int32_t sky = 0 ;
int32_t j ;
2008-06-10 02:29:58 +00:00
getmessageleng = 0 ;
getmessagetimeoff = 0 ;
2006-04-13 20:47:06 +00:00
// PreCache Wall Tiles
/*
for ( j = 0 ; j < numwalls ; j + + )
if ( waloff [ wall [ j ] . picnum ] = = 0 )
{
loadtile ( wall [ j ] . picnum ) ;
if ( bpp ! = 8 )
polymost_precache ( wall [ j ] . picnum , wall [ j ] . pal , 0 ) ;
}
for ( j = 0 ; j < numsectors ; j + + )
if ( waloff [ sector [ j ] . floorpicnum ] = = 0 | | waloff [ sector [ j ] . ceilingpicnum ] = = 0 )
{
loadtile ( sector [ j ] . floorpicnum ) ;
loadtile ( sector [ j ] . ceilingpicnum ) ;
if ( bpp ! = 8 )
{
polymost_precache ( sector [ j ] . floorpicnum , sector [ j ] . floorpal , 0 ) ;
polymost_precache ( sector [ j ] . floorpicnum , sector [ j ] . floorpal , 0 ) ;
2007-08-25 01:05:00 +00:00
}
2006-04-13 20:47:06 +00:00
}
for ( j = 0 ; j < numsprites ; j + + )
if ( waloff [ sprite [ j ] . picnum ] = = 0 )
{
loadtile ( sprite [ j ] . picnum ) ;
if ( bpp ! = 8 )
polymost_precache ( sprite [ j ] . picnum , sprite [ j ] . pal , 1 ) ;
}
*/
// Presize Sprites
2009-02-19 16:47:54 +00:00
for ( j = numsprites ; j > = 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
2008-08-28 05:57:46 +00:00
/* if (tilesizx[sprite[j].picnum]==0 || tilesizy[sprite[j].picnum]==0)
sprite [ j ] . picnum = 0 ; */
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( sprite [ j ] . picnum > = 20 & & sprite [ j ] . picnum < = 59 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( sprite [ j ] . picnum = = 26 )
{
sprite [ j ] . xrepeat = 8 ;
sprite [ j ] . yrepeat = 8 ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-15 01:16:55 +00:00
sprite [ j ] . xrepeat = 32 ;
sprite [ j ] . yrepeat = 32 ;
2006-04-13 20:47:06 +00:00
}
}
}
Bstrcpy ( levelname , mapname ) ;
pskyoff [ 0 ] = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < 8 ; i + + ) pskyoff [ i ] = 0 ;
2006-04-13 20:47:06 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
switch ( sector [ i ] . ceilingpicnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case MOONSKY1 :
case BIGORBIT1 : // orbit
case LA : // la city
sky = sector [ i ] . ceilingpicnum ;
break ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-13 23:12:47 +00:00
switch ( sky )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case MOONSKY1 :
// earth mountian mountain sun
pskyoff [ 6 ] = 1 ;
pskyoff [ 1 ] = 2 ;
pskyoff [ 4 ] = 2 ;
pskyoff [ 2 ] = 3 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case BIGORBIT1 : // orbit
// earth1 2 3 moon/sun
pskyoff [ 5 ] = 1 ;
pskyoff [ 6 ] = 2 ;
pskyoff [ 7 ] = 3 ;
pskyoff [ 2 ] = 4 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case LA : // la city
// earth1 2 3 moon/sun
pskyoff [ 0 ] = 1 ;
pskyoff [ 1 ] = 2 ;
pskyoff [ 2 ] = 1 ;
pskyoff [ 3 ] = 3 ;
pskyoff [ 4 ] = 4 ;
pskyoff [ 5 ] = 0 ;
pskyoff [ 6 ] = 2 ;
pskyoff [ 7 ] = 3 ;
break ;
2006-04-13 20:47:06 +00:00
}
pskybits = 3 ;
parallaxtype = 0 ;
2008-08-28 23:15:11 +00:00
Bsprintf ( tempbuf , " Mapster32 - %s " , mapname ) ;
2006-04-13 20:47:06 +00:00
wm_setapptitle ( tempbuf ) ;
}
void ExtSaveMap ( const char * mapname )
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( mapname ) ;
2009-01-13 12:23:18 +00:00
saveboard ( " backup.map " , & pos . x , & pos . y , & pos . z , & ang , & cursectnum ) ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
int32_t getTileGroup ( const char * groupName )
2008-07-14 01:48:20 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t temp ;
2008-07-14 01:48:20 +00:00
for ( temp = 0 ; temp < MAX_TILE_GROUPS ; temp + + )
{
2008-07-16 09:27:08 +00:00
if ( s_TileGroups [ temp ] . szText = = NULL )
{
2008-07-14 01:48:20 +00:00
return - 1 ;
}
if ( ! strcmp ( s_TileGroups [ temp ] . szText , groupName ) )
{
return temp ;
}
}
return - 1 ;
}
2009-01-09 09:29:17 +00:00
int32_t tileInGroup ( int32_t group , int32_t tilenum )
2008-07-14 01:48:20 +00:00
{
// @todo Make a bitmap instead of doing this slow search..
2009-01-09 09:29:17 +00:00
int32_t temp ;
2008-07-14 01:48:20 +00:00
if ( group < 0 | | group > = MAX_TILE_GROUPS | | s_TileGroups [ group ] . szText = = NULL )
{
// group isn't valid.
return 0 ;
}
for ( temp = 0 ; temp < s_TileGroups [ group ] . nIds ; temp + + )
{
if ( tilenum = = s_TileGroups [ group ] . pIds [ temp ] )
{
return 1 ;
}
}
return 0 ;
}
2009-01-09 09:29:17 +00:00
const char * ExtGetSectorType ( int32_t lotag )
2008-09-03 10:47:19 +00:00
{
static char tempbuf [ 64 ] ;
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
switch ( lotag )
{
case 1 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " WATER (SE 7) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 2 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " UNDERWATER (SE 7) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 9 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " STAR TREK DOORS " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 15 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " ELEVATOR TRANSPORT (SE 17) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 16 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " ELEVATOR PLATFORM DOWN " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 17 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " ELEVATOR PLATFORM UP " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 18 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " ELEVATOR DOWN " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 19 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " ELEVATOR UP " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 20 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " CEILING DOOR " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 21 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " FLOOR DOOR " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 22 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " SPLIT DOOR " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 23 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " SWING DOOR (SE 11) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 25 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " SLIDE DOOR (SE 15) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 26 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " SPLIT STAR TREK DOOR " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 27 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " BRIDGE (SE 20) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 28 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " DROP FLOOR (SE 21) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 29 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " TEETH DOOR (SE 22) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 30 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " ROTATE RISE BRIDGE " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 31 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " 2 WAY TRAIN (SE=30) " ) ;
2008-09-03 10:47:19 +00:00
break ;
case 32767 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " SECRET ROOM " ) ;
2008-09-03 10:47:19 +00:00
break ;
case - 1 :
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " END OF LEVEL " ) ;
2008-09-03 10:47:19 +00:00
break ;
default :
if ( lotag > 10000 & & lotag < 32767 )
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " 1 TIME SOUND " ) ;
// else Bsprintf(tempbuf,"%hu",lotag);
2008-09-03 10:47:19 +00:00
break ;
}
return ( tempbuf ) ;
}
2009-01-09 09:29:17 +00:00
const char * ExtGetSectorCaption ( int16_t sectnum )
2006-04-13 20:47:06 +00:00
{
2008-09-03 10:47:19 +00:00
static char tempbuf [ 64 ] ;
2008-09-01 07:15:16 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2006-11-13 23:12:47 +00:00
if ( qsetmode ! = 200 & & ( ! ( onnames = = 1 | | onnames = = 4 | | onnames = = 7 ) | | ( onnames = = 8 ) ) )
2006-04-13 20:47:06 +00:00
{
tempbuf [ 0 ] = 0 ;
return ( tempbuf ) ;
}
if ( qsetmode ! = 200 & & ( sector [ sectnum ] . lotag | sector [ sectnum ] . hitag ) = = 0 )
{
tempbuf [ 0 ] = 0 ;
}
else
{
2008-09-03 10:47:19 +00:00
Bstrcpy ( lo , ExtGetSectorType ( sector [ sectnum ] . lotag ) ) ;
2006-11-13 23:12:47 +00:00
if ( qsetmode ! = 200 )
2008-09-06 06:22:31 +00:00
Bsprintf ( tempbuf , " %hu,%hu %s " , sector [ sectnum ] . hitag , sector [ sectnum ] . lotag , lo ) ;
else Bsprintf ( tempbuf , " %hu %s " , sector [ sectnum ] . lotag , lo ) ;
2006-04-13 20:47:06 +00:00
}
return ( tempbuf ) ;
}
2009-01-09 09:29:17 +00:00
const char * ExtGetWallCaption ( int16_t wallnum )
2006-04-13 20:47:06 +00:00
{
2008-09-03 10:47:19 +00:00
static char tempbuf [ 64 ] ;
2008-09-02 02:45:06 +00:00
2008-09-01 07:15:16 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2008-09-02 02:45:06 +00:00
if ( wall [ wallnum ] . cstat & ( 1 < < 14 ) )
{
2009-01-09 09:29:17 +00:00
int32_t dax = wall [ wallnum ] . x - wall [ wall [ wallnum ] . point2 ] . x ;
int32_t day = wall [ wallnum ] . y - wall [ wall [ wallnum ] . point2 ] . y ;
int32_t dist = ksqrt ( dax * dax + day * day ) ;
2008-09-02 02:45:06 +00:00
Bsprintf ( tempbuf , " %d " , dist ) ;
wall [ wallnum ] . cstat & = ~ ( 1 < < 14 ) ;
return ( tempbuf ) ;
}
2006-11-13 23:12:47 +00:00
if ( ! ( onnames = = 2 | | onnames = = 4 ) )
2006-04-13 20:47:06 +00:00
{
tempbuf [ 0 ] = 0 ;
return ( tempbuf ) ;
}
// HERE
if ( ( wall [ wallnum ] . lotag | wall [ wallnum ] . hitag ) = = 0 )
{
tempbuf [ 0 ] = 0 ;
}
else
{
Bsprintf ( tempbuf , " %hu,%hu " , wall [ wallnum ] . hitag , wall [ wallnum ] . lotag ) ;
}
return ( tempbuf ) ;
} //end
2009-01-09 09:29:17 +00:00
const char * SectorEffectorTagText ( int32_t lotag )
2006-04-13 20:47:06 +00:00
{
2008-09-03 10:47:19 +00:00
static char tempbuf [ 64 ] ;
2008-09-01 07:15:16 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2008-09-03 10:47:19 +00:00
switch ( lotag )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: ROTATED SECTOR " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: PIVOT SPRITE FOR SE 0 " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: EARTHQUAKE " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: RANDOM LIGHTS AFTER SHOT OUT " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 4 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: RANDOM LIGHTS " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 6 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: SUBWAY " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 7 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: TRANSPORT " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 8 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: UP OPEN DOOR LIGHTS " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 9 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: DOWN OPEN DOOR LIGHTS " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 10 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: DOOR AUTO CLOSE (H=DELAY) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 11 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: ROTATE SECTOR DOOR " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 12 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: LIGHT SWITCH " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 13 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: EXPLOSIVE " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 14 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: SUBWAY CAR " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 15 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: SLIDE DOOR (ST 25) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 16 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: ROTATE REACTOR SECTOR " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 17 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: ELEVATOR TRANSPORT (ST 15) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 18 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: INCREMENTAL SECTOR RISE/FALL " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 19 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: CEILING FALL ON EXPLOSION " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 20 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: BRIDGE (ST 27) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 21 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: DROP FLOOR (ST 28) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 22 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: TEETH DOOR (ST 29) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 23 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: 1-WAY SE7 DESTINATION (H=SE 7) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 24 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: CONVAYER BELT " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 25 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: ENGINE " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 28 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: LIGHTNING (H= TILE#4890) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 27 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: CAMERA FOR PLAYBACK " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 29 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: FLOAT " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 30 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: 2 WAY TRAIN (ST=31) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 31 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: FLOOR RISE " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 32 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: CEILING FALL " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 33 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: SPAWN JIB W/QUAKE " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
case 36 :
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " %d: SKRINK RAY SHOOTER " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
default :
2008-10-12 19:16:09 +00:00
Bsprintf ( tempbuf , " %d: (UNKNOWN) " , lotag ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
return ( tempbuf ) ;
}
2009-01-09 09:29:17 +00:00
const char * SectorEffectorText ( int32_t spritenum )
2008-09-03 10:47:19 +00:00
{
static char tempbuf [ 64 ] ;
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
Bmemset ( lo , 0 , sizeof ( lo ) ) ;
Bstrcpy ( lo , SectorEffectorTagText ( sprite [ spritenum ] . lotag ) ) ;
if ( ! lo [ 5 ] ) // tags are 5 chars or less
SpriteName ( spritenum , tempbuf ) ;
2008-09-03 17:55:11 +00:00
else Bsprintf ( tempbuf , " SE %s " , lo ) ;
2008-09-03 10:47:19 +00:00
return ( tempbuf ) ;
}
2009-01-09 09:29:17 +00:00
const char * ExtGetSpriteCaption ( int16_t spritenum )
2006-04-13 20:47:06 +00:00
{
2008-08-28 11:52:28 +00:00
static char tempbuf [ 1024 ] ;
2008-09-01 07:15:16 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2006-11-13 23:12:47 +00:00
if ( ( onnames ! = 5 & & onnames ! = 6 & & ( ! ( onnames = = 3 | | onnames = = 4 | | onnames = = 7 | | onnames = = 8 ) ) ) | | ( onnames = = 7 & & sprite [ spritenum ] . picnum ! = 1 ) )
2006-04-13 20:47:06 +00:00
{
tempbuf [ 0 ] = 0 ;
return ( tempbuf ) ;
}
if ( onnames = = 5 )
{
2008-07-14 01:48:20 +00:00
if ( ! tileInGroup ( tilegroupItems , sprite [ spritenum ] . picnum ) )
2006-11-16 03:02:42 +00:00
{
tempbuf [ 0 ] = 0 ;
return ( tempbuf ) ;
}
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( onnames = = 6 & & sprite [ spritenum ] . picnum ! = sprite [ cursprite ] . picnum )
2006-04-13 20:47:06 +00:00
{
tempbuf [ 0 ] = 0 ;
return ( tempbuf ) ;
}
tempbuf [ 0 ] = 0 ;
if ( ( sprite [ spritenum ] . lotag | sprite [ spritenum ] . hitag ) = = 0 )
{
SpriteName ( spritenum , lo ) ;
2006-11-13 23:12:47 +00:00
if ( lo [ 0 ] ! = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ spritenum ] . pal = = 1 ) Bsprintf ( tempbuf , " %s (MULTIPLAYER) " , lo ) ;
2006-04-13 20:47:06 +00:00
else Bsprintf ( tempbuf , " %s " , lo ) ;
}
}
2009-02-19 16:47:54 +00:00
else if ( sprite [ spritenum ] . picnum = = SECTOREFFECTOR )
{
if ( onnames = = 8 )
tempbuf [ 0 ] = 0 ;
2006-04-13 20:47:06 +00:00
else
{
2009-02-19 16:47:54 +00:00
Bsprintf ( lo , " %s " , SectorEffectorText ( spritenum ) ) ;
Bsprintf ( tempbuf , " %s, %hu " , lo , sprite [ spritenum ] . hitag ) ;
2006-04-13 20:47:06 +00:00
}
2009-02-19 16:47:54 +00:00
}
else
{
SpriteName ( spritenum , lo ) ;
if ( sprite [ spritenum ] . extra ! = - 1 )
Bsprintf ( tempbuf , " %hu,%hu,%d %s " , sprite [ spritenum ] . hitag , sprite [ spritenum ] . lotag , sprite [ spritenum ] . extra , lo ) ;
else
Bsprintf ( tempbuf , " %hu,%hu %s " , sprite [ spritenum ] . hitag , sprite [ spritenum ] . lotag , lo ) ;
}
2006-04-13 20:47:06 +00:00
return ( tempbuf ) ;
} //end
//printext16 parameters:
2009-01-09 09:29:17 +00:00
//printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol,
2006-04-13 20:47:06 +00:00
// char name[82], char fontsize)
// xpos 0-639 (top left)
// ypos 0-479 (top left)
// col 0-15
// backcol 0-15, -1 is transparent background
// name
// fontsize 0=8*8, 1=3*5
//drawline16 parameters:
2009-01-09 09:29:17 +00:00
// drawline16(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col)
2006-04-13 20:47:06 +00:00
// x1, x2 0-639
// y1, y2 0-143 (status bar is 144 high, origin is top-left of STATUS BAR)
// col 0-15
2009-01-09 09:29:17 +00:00
void ExtShowSectorData ( int16_t sectnum ) //F5
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int16_t statnum = 0 ;
int32_t x , x2 , y ;
int32_t i ;
int32_t secrets = 0 ;
int32_t totalactors1 = 0 , totalactors2 = 0 , totalactors3 = 0 , totalactors4 = 0 ;
int32_t totalrespawn = 0 ;
2006-04-13 20:47:06 +00:00
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( sectnum ) ;
2006-11-13 23:12:47 +00:00
if ( qsetmode = = 200 )
2006-04-13 20:47:06 +00:00
return ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sector [ i ] . lotag = = 32767 ) secrets + + ;
2006-04-13 20:47:06 +00:00
}
statnum = 0 ;
i = headspritestat [ statnum ] ;
while ( i ! = - 1 )
{
2008-07-14 01:48:20 +00:00
// Count all non-player actors.
if ( tileInGroup ( tilegroupActors , sprite [ i ] . picnum ) )
{
2008-06-29 10:40:37 +00:00
if ( sprite [ i ] . lotag < = 1 ) totalactors1 + + ;
if ( sprite [ i ] . lotag < = 2 ) totalactors2 + + ;
if ( sprite [ i ] . lotag < = 3 ) totalactors3 + + ;
if ( sprite [ i ] . lotag < = 4 ) totalactors4 + + ;
2006-04-13 20:47:06 +00:00
}
2008-07-14 01:48:20 +00:00
if ( sprite [ i ] . picnum = = RESPAWN ) totalrespawn + + ;
2008-06-29 10:40:37 +00:00
i = nextspritestat [ i ] ;
2006-04-13 20:47:06 +00:00
}
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + ) numsprite [ i ] = 0 ;
for ( i = 0 ; i < MAXSPRITES ; i + + ) multisprite [ i ] = 0 ;
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ i ] . statnum = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ i ] . pal ! = 0 ) multisprite [ sprite [ i ] . picnum ] + + ;
2006-04-13 20:47:06 +00:00
else numsprite [ sprite [ i ] . picnum ] + + ;
}
}
clearmidstatbar16 ( ) ; //Clear middle of status bar
Bsprintf ( tempbuf , " Level %s " , levelname ) ;
printmessage16 ( tempbuf ) ;
2006-11-15 01:16:55 +00:00
x = 1 ;
x2 = 14 ;
y = 4 ;
2006-04-13 20:47:06 +00:00
begindrawing ( ) ;
2008-12-23 23:27:53 +00:00
printext16 ( x * 8 , ydim16 + y * 8 , editorcolors [ 11 ] , - 1 , " Item Count " , 0 ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
PrintStatus ( " 10%health= " , numsprite [ COLA ] , x , y + 2 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ COLA ] , x2 , y + 2 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " 30%health= " , numsprite [ SIXPAK ] , x , y + 3 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ SIXPAK ] , x2 , y + 3 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Med-Kit = " , numsprite [ FIRSTAID ] , x , y + 4 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ FIRSTAID ] , x2 , y + 4 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Atom = " , numsprite [ ATOMICHEALTH ] , x , y + 5 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ ATOMICHEALTH ] , x2 , y + 5 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Shields = " , numsprite [ SHIELD ] , x , y + 6 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ SHIELD ] , x2 , y + 6 , 9 ) ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
x = 17 ;
x2 = 30 ;
y = 4 ;
2006-04-13 20:47:06 +00:00
begindrawing ( ) ;
2008-12-23 23:27:53 +00:00
printext16 ( x * 8 , ydim16 + y * 8 , editorcolors [ 11 ] , - 1 , " Inventory " , 0 ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
PrintStatus ( " Steroids = " , numsprite [ STEROIDS ] , x , y + 2 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ STEROIDS ] , x2 , y + 2 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Airtank = " , numsprite [ AIRTANK ] , x , y + 3 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ AIRTANK ] , x2 , y + 3 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Jetpack = " , numsprite [ JETPACK ] , x , y + 4 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ JETPACK ] , x2 , y + 4 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Goggles = " , numsprite [ HEATSENSOR ] , x , y + 5 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ HEATSENSOR ] , x2 , y + 5 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Boots = " , numsprite [ BOOTS ] , x , y + 6 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ BOOTS ] , x2 , y + 6 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " HoloDuke = " , numsprite [ HOLODUKE ] , x , y + 7 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ HOLODUKE ] , x2 , y + 7 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Multi D = " , numsprite [ APLAYER ] , x , y + 8 , 11 ) ;
2006-11-15 01:16:55 +00:00
x = 33 ;
x2 = 46 ;
y = 4 ;
2006-04-13 20:47:06 +00:00
begindrawing ( ) ;
2008-12-23 23:27:53 +00:00
printext16 ( x * 8 , ydim16 + y * 8 , editorcolors [ 11 ] , - 1 , " Weapon Count " , 0 ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
PrintStatus ( " Pistol = " , numsprite [ FIRSTGUNSPRITE ] , x , y + 2 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ FIRSTGUNSPRITE ] , x2 , y + 2 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Shotgun = " , numsprite [ SHOTGUNSPRITE ] , x , y + 3 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ SHOTGUNSPRITE ] , x2 , y + 3 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Chaingun = " , numsprite [ CHAINGUNSPRITE ] , x , y + 4 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ CHAINGUNSPRITE ] , x2 , y + 4 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " RPG = " , numsprite [ RPGSPRITE ] , x , y + 5 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ RPGSPRITE ] , x2 , y + 5 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Pipe Bomb= " , numsprite [ HEAVYHBOMB ] , x , y + 6 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ HEAVYHBOMB ] , x2 , y + 6 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Shrinker = " , numsprite [ SHRINKERSPRITE ] , x , y + 7 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ SHRINKERSPRITE ] , x2 , y + 7 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Devastatr= " , numsprite [ DEVISTATORSPRITE ] , x , y + 8 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ DEVISTATORSPRITE ] , x2 , y + 8 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Trip mine= " , numsprite [ TRIPBOMBSPRITE ] , x , y + 9 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ TRIPBOMBSPRITE ] , x2 , y + 9 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Freezeray= " , numsprite [ FREEZESPRITE ] , x , y + 10 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ FREEZESPRITE ] , x2 , y + 10 , 9 ) ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
x = 49 ;
x2 = 62 ;
y = 4 ;
2006-04-13 20:47:06 +00:00
begindrawing ( ) ;
2008-12-23 23:27:53 +00:00
printext16 ( x * 8 , ydim16 + y * 8 , editorcolors [ 11 ] , - 1 , " Ammo Count " , 0 ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
PrintStatus ( " Pistol = " , numsprite [ AMMO ] , x , y + 2 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ AMMO ] , x2 , y + 2 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Shot = " , numsprite [ SHOTGUNAMMO ] , x , y + 3 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ SHOTGUNAMMO ] , x2 , y + 3 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Chain = " , numsprite [ BATTERYAMMO ] , x , y + 4 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ BATTERYAMMO ] , x2 , y + 4 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " RPG Box = " , numsprite [ RPGAMMO ] , x , y + 5 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ RPGAMMO ] , x2 , y + 5 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Pipe Bomb= " , numsprite [ HBOMBAMMO ] , x , y + 6 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ HBOMBAMMO ] , x2 , y + 6 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Shrinker = " , numsprite [ CRYSTALAMMO ] , x , y + 7 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ CRYSTALAMMO ] , x2 , y + 7 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Devastatr= " , numsprite [ DEVISTATORAMMO ] , x , y + 8 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ DEVISTATORAMMO ] , x2 , y + 8 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Expander = " , numsprite [ GROWAMMO ] , x , y + 9 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ GROWAMMO ] , x2 , y + 9 , 9 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Freezeray= " , numsprite [ FREEZEAMMO ] , x , y + 10 , 11 ) ;
2008-05-15 03:16:38 +00:00
PrintStatus ( " " , multisprite [ FREEZEAMMO ] , x2 , y + 10 , 9 ) ;
2006-04-13 20:47:06 +00:00
begindrawing ( ) ;
2008-12-23 23:27:53 +00:00
printext16 ( 65 * 8 , ydim16 + 4 * 8 , editorcolors [ 11 ] , - 1 , " MISC " , 0 ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
PrintStatus ( " Secrets = " , secrets , 65 , 6 , 11 ) ;
begindrawing ( ) ;
2008-12-23 23:27:53 +00:00
printext16 ( 65 * 8 , ydim16 + 8 * 8 , editorcolors [ 11 ] , - 1 , " ACTORS " , 0 ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
PrintStatus ( " Skill 1 = " , totalactors1 , 65 , 10 , 11 ) ;
PrintStatus ( " Skill 2 = " , totalactors2 , 65 , 11 , 11 ) ;
PrintStatus ( " Skill 3 = " , totalactors3 , 65 , 12 , 11 ) ;
PrintStatus ( " Skill 4 = " , totalactors4 , 65 , 13 , 11 ) ;
PrintStatus ( " Respawn = " , totalrespawn , 65 , 14 , 11 ) ;
} // end ExtShowSectorData
2009-01-09 09:29:17 +00:00
void ExtShowWallData ( int16_t wallnum ) //F6
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , nextfreetag = 0 , total = 0 ;
2006-04-13 20:47:06 +00:00
char x , y ;
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( wallnum ) ;
2008-03-21 04:01:38 +00:00
2006-11-13 23:12:47 +00:00
if ( qsetmode = = 200 )
2006-04-13 20:47:06 +00:00
return ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ i ] . statnum = = 0 )
switch ( sprite [ i ] . picnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
//LOTAG
case ACTIVATOR :
case ACTIVATORLOCKED :
case TOUCHPLATE :
case MASTERSWITCH :
case RESPAWN :
case ACCESSSWITCH :
case SLOTDOOR :
case LIGHTSWITCH :
case SPACEDOORSWITCH :
case SPACELIGHTSWITCH :
case FRANKENSTINESWITCH :
case MULTISWITCH :
case DIPSWITCH :
case DIPSWITCH2 :
case TECHSWITCH :
case DIPSWITCH3 :
case ACCESSSWITCH2 :
case POWERSWITCH1 :
case LOCKSWITCH1 :
case POWERSWITCH2 :
case PULLSWITCH :
case ALIENSWITCH :
if ( sprite [ i ] . lotag > nextfreetag ) nextfreetag = 1 + sprite [ i ] . lotag ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
//HITAG
case SEENINE :
case OOZFILTER :
case SECTOREFFECTOR :
if ( sprite [ i ] . lotag = = 10 | | sprite [ i ] . lotag = = 27 | | sprite [ i ] . lotag = = 28 | | sprite [ i ] . lotag = = 29 )
2006-04-13 20:47:06 +00:00
break ;
2009-02-19 16:47:54 +00:00
else if ( sprite [ i ] . hitag > nextfreetag ) nextfreetag = 1 + sprite [ i ] . hitag ;
2006-11-16 03:02:42 +00:00
break ;
default :
break ;
2006-04-13 20:47:06 +00:00
}
} // end sprite loop
//Count Normal Actors
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + ) numsprite [ i ] = 0 ;
for ( i = 0 ; i < MAXSPRITES ; i + + ) multisprite [ i ] = 0 ;
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ i ] . statnum = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ i ] . pal ! = 0 )
switch ( sprite [ i ] . picnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case LIZTROOP :
case LIZTROOPRUNNING :
case LIZTROOPSTAYPUT :
case LIZTROOPSHOOT :
case LIZTROOPJETPACK :
case LIZTROOPONTOILET :
case LIZTROOPDUCKING :
numsprite [ LIZTROOP ] + + ;
break ;
case BOSS1 :
case BOSS1STAYPUT :
case BOSS1SHOOT :
case BOSS1LOB :
case BOSSTOP :
multisprite [ BOSS1 ] + + ;
break ;
case BOSS2 :
multisprite [ BOSS2 ] + + ;
break ;
case BOSS3 :
multisprite [ BOSS3 ] + + ;
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
default :
break ;
2006-04-13 20:47:06 +00:00
}
else
2006-11-13 23:12:47 +00:00
switch ( sprite [ i ] . picnum )
2006-04-13 20:47:06 +00:00
{
case LIZTROOP :
case LIZTROOPRUNNING :
case LIZTROOPSTAYPUT :
case LIZTROOPSHOOT :
case LIZTROOPJETPACK :
case LIZTROOPONTOILET :
case LIZTROOPDUCKING :
2006-11-15 01:16:55 +00:00
numsprite [ LIZTROOP ] + + ;
break ;
2006-04-13 20:47:06 +00:00
case PIGCOP :
case PIGCOPSTAYPUT :
case PIGCOPDIVE :
2006-11-15 01:16:55 +00:00
numsprite [ PIGCOP ] + + ;
break ;
2006-04-13 20:47:06 +00:00
case LIZMAN :
case LIZMANSTAYPUT :
case LIZMANSPITTING :
case LIZMANFEEDING :
case LIZMANJUMP :
2006-11-15 01:16:55 +00:00
numsprite [ LIZMAN ] + + ;
break ;
2006-04-13 20:47:06 +00:00
case BOSS1 :
case BOSS1STAYPUT :
case BOSS1SHOOT :
case BOSS1LOB :
case BOSSTOP :
2006-11-16 03:02:42 +00:00
numsprite [ BOSS1 ] + + ;
2006-11-15 01:16:55 +00:00
break ;
2006-04-13 20:47:06 +00:00
case COMMANDER :
case COMMANDERSTAYPUT :
2006-11-15 01:16:55 +00:00
numsprite [ COMMANDER ] + + ;
break ;
2006-04-13 20:47:06 +00:00
case OCTABRAIN :
case OCTABRAINSTAYPUT :
2006-11-15 01:16:55 +00:00
numsprite [ OCTABRAIN ] + + ;
break ;
2006-04-13 20:47:06 +00:00
case RECON :
case DRONE :
case ROTATEGUN :
case EGG :
case ORGANTIC :
case GREENSLIME :
case BOSS2 :
case BOSS3 :
case TANK :
case NEWBEAST :
case BOSS4 :
2006-11-16 03:02:42 +00:00
numsprite [ sprite [ i ] . picnum ] + + ;
2006-04-13 20:47:06 +00:00
default :
break ;
2006-11-16 03:02:42 +00:00
} // end switch
} // end if
} //end for
total = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + ) if ( numsprite [ i ] ! = 0 ) total + = numsprite [ i ] ;
for ( i = 0 ; i < MAXSPRITES ; i + + ) if ( multisprite [ i ] ! = 0 ) total + = multisprite [ i ] ;
2006-11-16 03:02:42 +00:00
clearmidstatbar16 ( ) ;
Bsprintf ( tempbuf , " Level %s next tag %d " , levelname , nextfreetag ) ;
printmessage16 ( tempbuf ) ;
x = 2 ;
y = 4 ;
PrintStatus ( " Normal Actors = " , total , x , y , 11 ) ;
PrintStatus ( " Liztroop = " , numsprite [ LIZTROOP ] , x , y + 1 , 11 ) ;
PrintStatus ( " Lizman = " , numsprite [ LIZMAN ] , x , y + 2 , 11 ) ;
PrintStatus ( " Commander = " , numsprite [ COMMANDER ] , x , y + 3 , 11 ) ;
PrintStatus ( " Octabrain = " , numsprite [ OCTABRAIN ] , x , y + 4 , 11 ) ;
PrintStatus ( " PigCop = " , numsprite [ PIGCOP ] , x , y + 5 , 11 ) ;
PrintStatus ( " Recon Car = " , numsprite [ RECON ] , x , y + 6 , 11 ) ;
PrintStatus ( " Drone = " , numsprite [ DRONE ] , x , y + 7 , 11 ) ;
PrintStatus ( " Turret = " , numsprite [ ROTATEGUN ] , x , y + 8 , 11 ) ;
PrintStatus ( " Egg = " , numsprite [ EGG ] , x , y + 9 , 11 ) ;
x + = 17 ;
PrintStatus ( " Slimer = " , numsprite [ GREENSLIME ] , x , y + 1 , 11 ) ;
PrintStatus ( " Boss1 = " , numsprite [ BOSS1 ] , x , y + 2 , 11 ) ;
PrintStatus ( " MiniBoss1 = " , multisprite [ BOSS1 ] , x , y + 3 , 11 ) ;
PrintStatus ( " Boss2 = " , numsprite [ BOSS2 ] , x , y + 4 , 11 ) ;
PrintStatus ( " Boss3 = " , numsprite [ BOSS3 ] , x , y + 5 , 11 ) ;
PrintStatus ( " Riot Tank = " , numsprite [ TANK ] , x , y + 6 , 11 ) ;
PrintStatus ( " Newbeast = " , numsprite [ NEWBEAST ] , x , y + 7 , 11 ) ;
PrintStatus ( " Boss4 = " , numsprite [ BOSS4 ] , x , y + 8 , 11 ) ;
//Count Respawn Actors
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + ) numsprite [ i ] = 0 ;
for ( i = 0 ; i < MAXSPRITES ; i + + ) multisprite [ i ] = 0 ;
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-11-16 03:02:42 +00:00
{
if ( sprite [ i ] . statnum = = 0 & & sprite [ i ] . picnum = = RESPAWN )
{
switch ( sprite [ i ] . hitag )
{
case LIZTROOP :
case LIZTROOPRUNNING :
case LIZTROOPSTAYPUT :
case LIZTROOPSHOOT :
case LIZTROOPJETPACK :
case LIZTROOPONTOILET :
case LIZTROOPDUCKING :
numsprite [ LIZTROOP ] + + ;
break ;
case PIGCOP :
case PIGCOPSTAYPUT :
case PIGCOPDIVE :
numsprite [ PIGCOP ] + + ;
break ;
case LIZMAN :
case LIZMANSTAYPUT :
case LIZMANSPITTING :
case LIZMANFEEDING :
case LIZMANJUMP :
numsprite [ LIZMAN ] + + ;
break ;
case BOSS1 :
case BOSS1STAYPUT :
case BOSS1SHOOT :
case BOSS1LOB :
case BOSSTOP :
if ( sprite [ i ] . pal ! = 0 ) multisprite [ BOSS1 ] + + ;
else numsprite [ BOSS1 ] + + ;
break ;
case COMMANDER :
case COMMANDERSTAYPUT :
numsprite [ COMMANDER ] + + ;
break ;
case OCTABRAIN :
case OCTABRAINSTAYPUT :
numsprite [ OCTABRAIN ] + + ;
break ;
case RECON :
case DRONE :
case ROTATEGUN :
case EGG :
case ORGANTIC :
case GREENSLIME :
case BOSS2 :
case BOSS3 :
case TANK :
case NEWBEAST :
case BOSS4 :
numsprite [ sprite [ i ] . hitag ] + + ;
default :
break ;
2006-11-15 01:16:55 +00:00
} //end switch
2006-04-13 20:47:06 +00:00
} // end if
2006-11-15 01:16:55 +00:00
} // end for
2006-04-13 20:47:06 +00:00
total = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + ) if ( numsprite [ i ] ! = 0 ) total + = numsprite [ i ] ;
for ( i = 0 ; i < MAXSPRITES ; i + + ) if ( multisprite [ i ] ! = 0 ) total + = multisprite [ i ] ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
x = 36 ;
y = 4 ;
PrintStatus ( " Respawn " , total , x , y , 11 ) ;
2006-04-13 20:47:06 +00:00
PrintStatus ( " Liztroop = " , numsprite [ LIZTROOP ] , x , y + 1 , 11 ) ;
PrintStatus ( " Lizman = " , numsprite [ LIZMAN ] , x , y + 2 , 11 ) ;
PrintStatus ( " Commander = " , numsprite [ COMMANDER ] , x , y + 3 , 11 ) ;
PrintStatus ( " Octabrain = " , numsprite [ OCTABRAIN ] , x , y + 4 , 11 ) ;
PrintStatus ( " PigCop = " , numsprite [ PIGCOP ] , x , y + 5 , 11 ) ;
PrintStatus ( " Recon Car = " , numsprite [ RECON ] , x , y + 6 , 11 ) ;
PrintStatus ( " Drone = " , numsprite [ DRONE ] , x , y + 7 , 11 ) ;
PrintStatus ( " Turret = " , numsprite [ ROTATEGUN ] , x , y + 8 , 11 ) ;
PrintStatus ( " Egg = " , numsprite [ EGG ] , x , y + 9 , 11 ) ;
x + = 17 ;
PrintStatus ( " Slimer = " , numsprite [ GREENSLIME ] , x , y + 1 , 11 ) ;
PrintStatus ( " Boss1 = " , numsprite [ BOSS1 ] , x , y + 2 , 11 ) ;
PrintStatus ( " MiniBoss1 = " , multisprite [ BOSS1 ] , x , y + 3 , 11 ) ;
PrintStatus ( " Boss2 = " , numsprite [ BOSS2 ] , x , y + 4 , 11 ) ;
PrintStatus ( " Boss3 = " , numsprite [ BOSS3 ] , x , y + 5 , 11 ) ;
PrintStatus ( " Riot Tank = " , numsprite [ TANK ] , x , y + 6 , 11 ) ;
PrintStatus ( " Newbeast = " , numsprite [ NEWBEAST ] , x , y + 7 , 11 ) ;
PrintStatus ( " Boss4 = " , numsprite [ BOSS4 ] , x , y + 8 , 11 ) ;
2006-11-15 01:16:55 +00:00
} // end ExtShowWallData
2006-04-13 20:47:06 +00:00
2006-12-10 06:49:01 +00:00
static void Show2dText ( char * name )
2006-11-15 01:16:55 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t fp , t ;
uint8_t x = 0 , y = 4 , xmax = 0 , xx = 0 , col = 0 ;
2006-11-15 01:16:55 +00:00
clearmidstatbar16 ( ) ;
if ( ( fp = kopen4load ( name , 0 ) ) = = - 1 )
2006-04-13 20:47:06 +00:00
{
begindrawing ( ) ;
2008-12-23 23:27:53 +00:00
printext16 ( 1 * 4 , ydim16 + 4 * 8 , editorcolors [ 11 ] , - 1 , " ERROR: file not found. " , 0 ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
return ;
}
t = 65 ;
begindrawing ( ) ;
2006-11-13 23:12:47 +00:00
while ( t ! = EOF & & col < 5 )
2006-04-13 20:47:06 +00:00
{
t = 0 ;
if ( kread ( fp , & t , 1 ) < = 0 )
t = EOF ;
2006-11-13 23:12:47 +00:00
while ( t ! = EOF & & t ! = ' \n ' & & x < 250 )
2006-04-13 20:47:06 +00:00
{
tempbuf [ x ] = t ;
2006-11-15 01:16:55 +00:00
t = 0 ;
if ( kread ( fp , & t , 1 ) < = 0 ) t = EOF ;
x + + ;
if ( x > xmax ) xmax = x ;
2006-04-13 20:47:06 +00:00
}
tempbuf [ x ] = 0 ;
2008-12-23 23:27:53 +00:00
printext16 ( xx * 4 , ydim16 + ( y * 6 ) + 2 , editorcolors [ 11 ] , - 1 , tempbuf , 1 ) ;
2006-11-15 01:16:55 +00:00
x = 0 ;
y + + ;
if ( y > 18 )
{
col + + ;
y = 6 ;
xx + = xmax ;
xmax = 0 ;
2006-04-13 20:47:06 +00:00
}
}
enddrawing ( ) ;
kclose ( fp ) ;
} // end Show2dText
2008-06-05 02:51:58 +00:00
// PK_ vvvv
typedef struct helppage_
{
2009-01-09 09:29:17 +00:00
int32_t numlines ;
2008-06-05 02:51:58 +00:00
char line [ ] [ 80 ] ; // C99 flexible array member
} helppage_t ;
helppage_t * * helppage = NULL ;
2009-01-09 09:29:17 +00:00
int32_t numhelppages = 0 ;
2008-06-05 02:51:58 +00:00
2009-01-09 09:29:17 +00:00
static int32_t emptyline ( const char * start )
2008-09-03 04:20:46 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2008-09-03 04:20:46 +00:00
for ( i = 0 ; i < 80 ; i + + )
{
if ( start [ i ] = = ' \n ' | | ! start [ i ] ) break ;
if ( start [ i ] ! = ' ' & & start [ i ] ! = ' \t ' & & start [ i ] ! = ' \r ' )
return 0 ;
}
return 1 ;
}
2009-01-09 09:29:17 +00:00
static int32_t newpage ( const char * start )
2008-06-05 02:51:58 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2008-08-16 07:53:29 +00:00
for ( i = 80 - 1 ; i > = 0 ; i - - )
2008-06-05 02:51:58 +00:00
{
2008-06-10 02:40:06 +00:00
if ( start [ i ] = = ' ^ ' & & start [ i + 1 ] = = ' P ' )
return 1 ;
2008-06-05 02:51:58 +00:00
}
2008-06-10 02:40:06 +00:00
return 0 ;
2008-06-05 02:51:58 +00:00
}
# define IHELP_INITPAGES 32
# define IHELP_INITLINES 16
static void ReadHelpFile ( const char * name )
{
BFILE * fp ;
2009-01-09 09:29:17 +00:00
int32_t i , j , k , numallocpages ;
int32_t pos , charsread = 0 ;
2008-06-05 02:51:58 +00:00
helppage_t * hp ;
char skip = 0 ;
2008-08-28 11:35:35 +00:00
initprintf ( " Loading \" %s \" \n " , name ) ;
2008-06-05 02:51:58 +00:00
if ( ( fp = fopenfrompath ( name , " rb " ) ) = = NULL )
{
initprintf ( " Error initializing integrated help: file \" %s \" not found. \n " , name ) ;
return ;
}
helppage = malloc ( IHELP_INITPAGES * sizeof ( helppage_t * ) ) ;
numallocpages = IHELP_INITPAGES ;
2008-07-27 11:35:41 +00:00
if ( ! helppage ) goto HELPFILE_ERROR ;
2008-06-05 02:51:58 +00:00
i = 0 ;
while ( ! Bfeof ( fp ) & & ! ferror ( fp ) )
{
while ( ! Bfeof ( fp ) ) // skip empty lines
{
pos = ftell ( fp ) ;
2008-10-19 12:14:04 +00:00
if ( Bfgets ( tempbuf , 80 , fp ) = = NULL ) break ;
2008-06-05 02:51:58 +00:00
charsread = ftell ( fp ) - pos ;
2008-06-10 02:40:06 +00:00
if ( ! newpage ( tempbuf ) )
2008-06-05 02:51:58 +00:00
{
break ;
}
}
if ( Bfeof ( fp ) | | charsread < = 0 ) break ;
hp = Bcalloc ( 1 , sizeof ( helppage_t ) + IHELP_INITLINES * 80 ) ;
2008-07-27 11:35:41 +00:00
if ( ! hp ) goto HELPFILE_ERROR ;
2008-06-05 02:51:58 +00:00
hp - > numlines = IHELP_INITLINES ;
if ( charsread = = 79 & & tempbuf [ 78 ] ! = ' \n ' ) skip = 1 ;
j = 0 ;
do
{
if ( j > = hp - > numlines )
{
hp = realloc ( hp , sizeof ( helppage_t ) + 2 * hp - > numlines * 80 ) ;
2008-07-27 11:35:41 +00:00
if ( ! hp ) goto HELPFILE_ERROR ;
2008-06-05 02:51:58 +00:00
hp - > numlines * = 2 ;
}
// limit the line length to 78 chars and probably get rid of the CR
if ( charsread > 0 )
{
tempbuf [ charsread - 1 ] = 0 ;
if ( tempbuf [ charsread - 2 ] = = 0x0d ) tempbuf [ charsread - 2 ] = 0 ;
}
memcpy ( hp - > line [ j ] , tempbuf , 80 ) ;
for ( k = charsread ; k < 80 ; k + + ) hp - > line [ j ] [ k ] = 0 ;
if ( skip )
{
while ( fgetc ( fp ) ! = ' \n ' & & ! Bfeof ( fp ) ) /*skip rest of line*/ ;
skip = 0 ;
}
pos = ftell ( fp ) ;
2008-10-19 12:14:04 +00:00
if ( Bfgets ( tempbuf , 80 , fp ) = = NULL ) break ;
2008-06-05 02:51:58 +00:00
charsread = ftell ( fp ) - pos ;
if ( charsread = = 79 & & tempbuf [ 78 ] ! = ' \n ' ) skip = 1 ;
j + + ;
}
2008-06-10 02:40:06 +00:00
while ( ! newpage ( tempbuf ) & & ! Bfeof ( fp ) & & charsread > 0 ) ;
2008-06-05 02:51:58 +00:00
hp = realloc ( hp , sizeof ( helppage_t ) + j * 80 ) ;
2008-07-27 11:35:41 +00:00
if ( ! hp ) goto HELPFILE_ERROR ;
2008-06-05 02:51:58 +00:00
hp - > numlines = j ;
if ( i > = numallocpages )
{
helppage = realloc ( helppage , 2 * numallocpages * sizeof ( helppage_t * ) ) ;
numallocpages * = 2 ;
2008-07-27 11:35:41 +00:00
if ( ! helppage ) goto HELPFILE_ERROR ;
2008-06-05 02:51:58 +00:00
}
helppage [ i ] = hp ;
i + + ;
}
helppage = realloc ( helppage , i * sizeof ( helppage_t * ) ) ;
2008-07-27 11:35:41 +00:00
if ( ! helppage ) goto HELPFILE_ERROR ;
2008-06-05 02:51:58 +00:00
numhelppages = i ;
Bfclose ( fp ) ;
return ;
2008-07-27 11:35:41 +00:00
HELPFILE_ERROR :
2008-06-05 02:51:58 +00:00
Bfclose ( fp ) ;
initprintf ( " ReadHelpFile(): ERROR allocating memory. \n " ) ;
return ;
}
2008-09-03 11:59:54 +00:00
// why can't MSVC allocate an array of variable size?!
# define IHELP_NUMDISPLINES 42 // ((overridepm16y>>4)+(overridepm16y>>5)+(overridepm16y>>7)-2)
2008-06-05 02:51:58 +00:00
# define IHELP_PATLEN 45
2009-01-09 09:29:17 +00:00
extern int32_t overridepm16y ; // influences printmessage16() and clearmidstatbar16()
2008-06-05 02:51:58 +00:00
static void IntegratedHelp ( )
{
if ( ! helppage ) return ;
2008-09-03 10:47:19 +00:00
overridepm16y = 3 * STATUS2DSIZ ;
2008-09-03 04:20:46 +00:00
2008-09-03 10:47:19 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , j ;
static int32_t curhp = 0 , curline = 0 ;
int32_t highlighthp = - 1 , highlightline = - 1 , lasthighlighttime = 0 ;
2008-09-03 10:47:19 +00:00
char disptext [ IHELP_NUMDISPLINES ] [ 80 ] ;
char oldpattern [ IHELP_PATLEN + 1 ] ;
begindrawing ( ) ;
clearbuf ( ( char * ) ( frameplace + ( ydim - overridepm16y ) * bytesperline ) , ( bytesperline * ( overridepm16y - 25 ) ) > > 2 , 0L ) ;
2008-09-03 04:20:46 +00:00
2008-12-23 23:27:53 +00:00
drawline16 ( 0 , ydim - overridepm16y , xdim - 1 , ydim - overridepm16y , editorcolors [ 1 ] ) ;
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " Mapster32 Help Mode " ) ;
2008-12-23 23:27:53 +00:00
printext16 ( 9L , ydim2d - overridepm16y + 9L , editorcolors [ 4 ] , - 1 , tempbuf , 0 ) ;
printext16 ( 8L , ydim2d - overridepm16y + 8L , editorcolors [ 12 ] , - 1 , tempbuf , 0 ) ;
2008-09-03 10:47:19 +00:00
enddrawing ( ) ;
memset ( oldpattern , 0 , sizeof ( char ) ) ;
2008-09-03 04:20:46 +00:00
// clearmidstatbar16();
2008-06-05 02:51:58 +00:00
2008-09-03 10:47:19 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 & & keystatus [ KEYSC_Q ] = = 0 & & keystatus [ KEYSC_F1 ] = = 0 )
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
if ( handleevents ( ) )
{
if ( quitevent ) quitevent = 0 ;
}
idle ( ) ;
2008-06-05 02:51:58 +00:00
// printmessage16("Help mode, press <Esc> to exit");
2008-09-03 10:47:19 +00:00
if ( keystatus [ KEYSC_T ] ) // goto table of contents
2008-09-03 04:20:46 +00:00
{
2008-09-03 10:47:19 +00:00
keystatus [ KEYSC_T ] = 0 ;
curhp = 0 ;
curline = 0 ;
2008-09-03 04:20:46 +00:00
}
2008-09-03 10:47:19 +00:00
else if ( keystatus [ KEYSC_G ] ) // goto arbitrary page
2008-09-03 04:20:46 +00:00
{
2008-09-03 10:47:19 +00:00
keystatus [ KEYSC_G ] = 0 ;
Bsprintf ( tempbuf , " Goto page: " ) ;
curhp = getnumber16 ( tempbuf , 0 , numhelppages - 1 , 0 ) ;
curline = 0 ;
2008-09-03 04:20:46 +00:00
}
2008-09-03 10:47:19 +00:00
else if ( keystatus [ KEYSC_UP ] ) // scroll up
2008-09-03 04:20:46 +00:00
{
2008-09-03 10:47:19 +00:00
keystatus [ KEYSC_UP ] = 0 ;
if ( curline > 0 ) curline - - ;
2008-09-03 04:20:46 +00:00
}
2008-09-03 10:47:19 +00:00
else if ( keystatus [ KEYSC_DOWN ] ) // scroll down
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
keystatus [ KEYSC_DOWN ] = 0 ;
if ( curline + IHELP_NUMDISPLINES < helppage [ curhp ] - > numlines ) curline + + ;
2008-06-05 02:51:58 +00:00
}
2008-09-03 10:47:19 +00:00
else if ( keystatus [ KEYSC_PGUP ] ) // scroll one page up
{
keystatus [ KEYSC_PGUP ] = 0 ;
i = IHELP_NUMDISPLINES ;
while ( i > 0 & & curline > 0 ) i - - , curline - - ;
}
else if ( keystatus [ KEYSC_PGDN ] ) // scroll one page down
{
keystatus [ KEYSC_PGDN ] = 0 ;
i = IHELP_NUMDISPLINES ;
while ( i > 0 & & curline + IHELP_NUMDISPLINES < helppage [ curhp ] - > numlines ) i - - , curline + + ;
}
else if ( keystatus [ KEYSC_SPACE ] ) // goto next paragraph
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
keystatus [ KEYSC_SPACE ] = 0 ;
for ( i = curline , j = 0 ; i < helppage [ curhp ] - > numlines ; i + + )
{
if ( emptyline ( helppage [ curhp ] - > line [ i ] ) ) { j = 1 ; continue ; }
if ( j = = 1 & & ! emptyline ( helppage [ curhp ] - > line [ i ] ) ) { j = 2 ; break ; }
}
if ( j = = 2 )
{
if ( i + IHELP_NUMDISPLINES < helppage [ curhp ] - > numlines )
curline = i ;
else if ( helppage [ curhp ] - > numlines - IHELP_NUMDISPLINES > curline )
curline = helppage [ curhp ] - > numlines - IHELP_NUMDISPLINES ;
}
}
else if ( keystatus [ KEYSC_BS ] ) // goto prev paragraph
{
keystatus [ KEYSC_BS ] = 0 ;
for ( i = curline - 1 , j = 0 ; i > = 0 ; i - - )
{
if ( ! emptyline ( helppage [ curhp ] - > line [ i ] ) ) { j = 1 ; continue ; }
if ( j = = 1 & & emptyline ( helppage [ curhp ] - > line [ i ] ) ) { j = 2 ; break ; }
}
if ( j = = 2 | | i = = - 1 ) curline = i + 1 ;
}
else if ( keystatus [ KEYSC_HOME ] ) // goto beginning of page
{
keystatus [ KEYSC_HOME ] = 0 ;
2008-06-05 02:51:58 +00:00
curline = 0 ;
}
2008-09-03 10:47:19 +00:00
else if ( keystatus [ KEYSC_END ] ) // goto end of page
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
keystatus [ KEYSC_END ] = 0 ;
if ( ( curline = helppage [ curhp ] - > numlines - IHELP_NUMDISPLINES ) > = 0 ) /**/ ;
else curline = 0 ;
}
else if ( keystatus [ KEYSC_LEFT ] | | keystatus [ KEYSC_LBRACK ] ) // prev page
{
keystatus [ KEYSC_LEFT ] = keystatus [ KEYSC_LBRACK ] = 0 ;
if ( curhp > 0 )
{
curhp - - ;
curline = 0 ;
}
}
else if ( keystatus [ KEYSC_RIGHT ] | | keystatus [ KEYSC_RBRACK ] ) // next page
{
keystatus [ KEYSC_RIGHT ] = keystatus [ KEYSC_RBRACK ] = 0 ;
if ( curhp < numhelppages - 1 )
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
curhp + + ;
curline = 0 ;
2008-06-05 02:51:58 +00:00
}
2008-09-03 10:47:19 +00:00
}
// based on 'save as' dialog in overheadeditor()
else if ( keystatus [ KEYSC_S ] ) // text search
{
char ch , bad = 0 , pattern [ IHELP_PATLEN + 1 ] ;
2008-06-05 02:51:58 +00:00
2008-09-03 10:47:19 +00:00
for ( i = 0 ; i < IHELP_PATLEN + 1 ; i + + ) pattern [ i ] = 0 ;
2008-06-05 02:51:58 +00:00
2008-09-03 10:47:19 +00:00
i = 0 ;
bflushchars ( ) ;
while ( bad = = 0 )
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
Bsprintf ( tempbuf , " Search: %s_ " , pattern ) ;
printmessage16 ( tempbuf ) ;
showframe ( 1 ) ;
if ( handleevents ( ) )
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
if ( quitevent ) quitevent = 0 ;
2008-06-05 02:51:58 +00:00
}
2008-09-03 10:47:19 +00:00
idle ( ) ;
ch = bgetchar ( ) ;
if ( keystatus [ 1 ] ) bad = 1 ;
else if ( ch = = 13 ) bad = 2 ;
else if ( ch > 0 )
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
if ( i > 0 & & ( ch = = 8 | | ch = = 127 ) )
{
i - - ;
pattern [ i ] = 0 ;
}
else if ( i < IHELP_PATLEN & & ch > = 32 & & ch < 128 )
{
pattern [ i + + ] = ch ;
pattern [ i ] = 0 ;
}
2008-06-05 02:51:58 +00:00
}
}
2008-09-03 10:47:19 +00:00
if ( bad = = 1 )
{
keystatus [ KEYSC_ESC ] = keystatus [ KEYSC_Q ] = keystatus [ KEYSC_F1 ] = 0 ;
}
2008-06-05 02:51:58 +00:00
2008-09-03 10:47:19 +00:00
if ( bad = = 2 )
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
keystatus [ KEYSC_ENTER ] = 0 ;
for ( i = curhp ; i < numhelppages ; i + + )
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
for ( j = ( i = = curhp ) ? ( curline + 1 ) : 0 ; j < helppage [ i ] - > numlines ; j + + )
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
// entering an empty pattern will search with the last used pattern
if ( strstr ( helppage [ i ] - > line [ j ] , pattern [ 0 ] ? pattern : oldpattern ) )
{
curhp = i ;
2008-06-05 02:51:58 +00:00
2008-09-03 10:47:19 +00:00
if ( ( curline = j ) < = helppage [ i ] - > numlines - IHELP_NUMDISPLINES ) /**/ ;
else if ( ( curline = helppage [ i ] - > numlines - IHELP_NUMDISPLINES ) > = 0 ) /**/ ;
else curline = 0 ;
2008-06-05 02:51:58 +00:00
2008-09-03 10:47:19 +00:00
highlighthp = i ;
highlightline = j ;
lasthighlighttime = totalclock ;
goto ENDFOR1 ;
}
2008-06-05 02:51:58 +00:00
}
}
ENDFOR1 :
2008-09-03 10:47:19 +00:00
if ( pattern [ 0 ] )
memcpy ( oldpattern , pattern , IHELP_PATLEN + 1 ) ;
}
2008-06-05 02:51:58 +00:00
}
2008-09-03 10:47:19 +00:00
else // '1'-'0' on the upper row
2008-06-05 02:51:58 +00:00
{
2008-09-03 10:47:19 +00:00
for ( i = 2 ; i < = 11 ; i + + )
if ( keystatus [ i ] ) break ;
if ( i - - < 12 & & i < numhelppages )
{
curhp = i ;
curline = 0 ;
}
2008-06-05 02:51:58 +00:00
}
2008-09-03 10:47:19 +00:00
clearmidstatbar16 ( ) ;
2008-09-04 23:11:48 +00:00
2008-09-03 10:47:19 +00:00
if ( curhp < helppage [ 0 ] - > numlines )
{
printmessage16 ( helppage [ 0 ] - > line [ curhp ] ) ;
}
else
{
for ( i = Bsprintf ( tempbuf , " %d. (Untitled page) " , curhp ) ; i < 80 ; i + + )
tempbuf [ i ] = 0 ;
printmessage16 ( tempbuf ) ;
}
2008-06-05 02:51:58 +00:00
2008-09-03 10:47:19 +00:00
for ( i = 0 ; j = ( curhp = = 0 ) ? ( i + curline + 1 ) : ( i + curline ) ,
i < IHELP_NUMDISPLINES & & j < helppage [ curhp ] - > numlines ; i + + )
{
Bmemcpy ( disptext [ i ] , helppage [ curhp ] - > line [ j ] , 80 ) ;
2008-12-23 23:27:53 +00:00
printext16 ( 8 , ydim - overridepm16y + 28 + i * 9 , editorcolors [ 10 ] ,
2008-09-03 10:47:19 +00:00
( j = = highlightline & & curhp = = highlighthp
2008-12-23 23:27:53 +00:00
& & totalclock - lasthighlighttime < 120 * 5 ) ? editorcolors [ 1 ] : - 1 ,
2008-09-03 10:47:19 +00:00
disptext [ i ] , 0 ) ;
}
showframe ( 1 ) ;
2008-06-05 02:51:58 +00:00
}
2008-09-03 10:47:19 +00:00
clearmidstatbar16 ( ) ;
overridepm16y = - 1 ;
i = ydim16 ;
ydim16 = ydim ;
2008-12-23 23:27:53 +00:00
drawline16 ( 0 , ydim - STATUS2DSIZ , xdim - 1 , ydim - STATUS2DSIZ , editorcolors [ 1 ] ) ;
2008-09-03 10:47:19 +00:00
ydim16 = i ;
printmessage16 ( " " ) ;
2008-06-05 02:51:58 +00:00
showframe ( 1 ) ;
2008-09-03 10:47:19 +00:00
keystatus [ KEYSC_ESC ] = keystatus [ KEYSC_Q ] = keystatus [ KEYSC_F1 ] = 0 ;
}
2008-06-05 02:51:58 +00:00
}
// PK_ ^^^^
2006-12-10 06:49:01 +00:00
static void Show3dText ( char * name )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t fp , t ;
uint8_t x = 0 , y = 4 , xmax = 0 , xx = 0 , col = 0 ;
2006-04-22 22:33:52 +00:00
2006-11-13 23:12:47 +00:00
if ( ( fp = kopen4load ( name , 0 ) ) = = - 1 )
2006-04-13 20:47:06 +00:00
{
begindrawing ( ) ;
printext256 ( 1 * 4 , 4 * 8 , whitecol , - 1 , " ERROR: file not found. " , 0 ) ;
enddrawing ( ) ;
return ;
}
t = 65 ;
begindrawing ( ) ;
2006-11-13 23:12:47 +00:00
while ( t ! = EOF & & col < 5 )
2006-04-13 20:47:06 +00:00
{
t = 0 ;
if ( kread ( fp , & t , 1 ) < = 0 )
t = EOF ;
2006-11-13 23:12:47 +00:00
while ( t ! = EOF & & t ! = ' \n ' & & x < 250 )
2006-04-13 20:47:06 +00:00
{
tempbuf [ x ] = t ;
2006-11-15 01:16:55 +00:00
t = 0 ;
if ( kread ( fp , & t , 1 ) < = 0 ) t = EOF ;
x + + ;
if ( x > xmax ) xmax = x ;
2006-04-13 20:47:06 +00:00
}
tempbuf [ x ] = 0 ;
printext256 ( xx * 4 , ( y * 6 ) + 2 , whitecol , - 1 , tempbuf , 1 ) ;
2006-11-15 01:16:55 +00:00
x = 0 ;
y + + ;
if ( y > 18 )
{
col + + ;
y = 6 ;
xx + = xmax ;
xmax = 0 ;
2006-04-13 20:47:06 +00:00
}
}
enddrawing ( ) ;
kclose ( fp ) ;
} // end Show3dText
2008-03-21 04:01:38 +00:00
#if 0
2006-12-10 06:49:01 +00:00
static void ShowHelpText ( char * name )
2006-04-13 20:47:06 +00:00
{
BFILE * fp ;
2006-04-22 22:33:52 +00:00
char x = 0 , y = 4 ;
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( name ) ;
2006-11-13 23:12:47 +00:00
if ( ( fp = fopenfrompath ( " helpdoc.txt " , " rb " ) ) = = NULL )
2006-04-13 20:47:06 +00:00
{
begindrawing ( ) ;
printext256 ( 1 * 4 , 4 * 8 , whitecol , - 1 , " ERROR: file not found. " , 0 ) ;
enddrawing ( ) ;
return ;
}
/*
Bfgets ( tempbuf , 80 , fp ) ;
while ( ! Bfeof ( fp ) & & Bstrcmp ( tempbuf , " SectorEffector " ) )
{
Bfgets ( tempbuf , 80 , fp ) ;
}
*/
y = 2 ;
Bfgets ( tempbuf , 80 , fp ) ;
Bstrcat ( tempbuf , " \n " ) ;
begindrawing ( ) ;
2006-11-13 23:12:47 +00:00
while ( ! Bfeof ( fp ) & & ! ( Bstrcmp ( tempbuf , " SectorEffector " ) = = 0 ) )
2006-04-13 20:47:06 +00:00
{
Bfgets ( tempbuf , 80 , fp ) ;
Bstrcat ( tempbuf , " \n " ) ;
printext256 ( x * 4 , ( y * 6 ) + 2 , whitecol , - 1 , tempbuf , 1 ) ;
y + + ;
}
enddrawing ( ) ;
Bfclose ( fp ) ;
} // end ShowHelpText
2008-03-21 04:01:38 +00:00
# endif
2009-01-09 09:29:17 +00:00
void ExtShowSpriteData ( int16_t spritenum ) //F6
2006-04-13 20:47:06 +00:00
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( spritenum ) ;
2006-04-13 20:47:06 +00:00
if ( qsetmode ! = 200 )
Show2dText ( " sehelp.hlp " ) ;
/* if (qsetmode == 200) // In 3D mode
return ;
while ( KEY_PRESSED ( KEYSC_F6 ) ) ;
ResetKeys ( ) ;
ContextHelp ( spritenum ) ; // Get context sensitive help */
} // end ExtShowSpriteData
// Floor Over Floor (duke3d)
// If standing in sector with SE42 or SE44
// then draw viewing to SE41 and raise all =hi SE43 cielings.
// If standing in sector with SE43 or SE45
// then draw viewing to SE40 and lower all =hi SE42 floors.
2009-01-09 09:29:17 +00:00
int32_t fofsizex = - 1 ;
int32_t fofsizey = - 1 ;
2008-03-21 04:01:38 +00:00
#if 0
2006-12-10 06:49:01 +00:00
static void ResetFOFSize ( )
2006-04-13 20:47:06 +00:00
{
if ( fofsizex ! = - 1 ) tilesizx [ FOF ] = fofsizex ;
if ( fofsizey ! = - 1 ) tilesizy [ FOF ] = fofsizey ;
}
2008-03-21 04:01:38 +00:00
# endif
2009-01-09 09:29:17 +00:00
static void ExtSE40Draw ( int32_t spnum , int32_t x , int32_t y , int32_t z , int16_t a , int16_t h )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
static int32_t tempsectorz [ MAXSECTORS ] ;
static int32_t tempsectorpicnum [ MAXSECTORS ] ;
2006-04-13 20:47:06 +00:00
2009-01-09 09:29:17 +00:00
int32_t i = 0 , j = 0 , k = 0 ;
int32_t floor1 = 0 , floor2 = 0 , ok = 0 , fofmode = 0 , draw_both = 0 ;
int32_t offx , offy , offz ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( sprite [ spnum ] . ang ! = 512 ) return ;
2006-04-13 20:47:06 +00:00
// Things are a little different now, as we allow for masked transparent
// floors and ceilings. So the FOF textures is no longer required
// if (!(gotpic[FOF>>3]&(1<<(FOF&7))))
// return;
// gotpic[FOF>>3] &= ~(1<<(FOF&7));
if ( tilesizx [ 562 ] )
{
fofsizex = tilesizx [ 562 ] ;
tilesizx [ 562 ] = 0 ;
}
if ( tilesizy [ 562 ] )
{
fofsizey = tilesizy [ 562 ] ;
tilesizy [ 562 ] = 0 ;
}
floor1 = spnum ;
2006-11-13 23:12:47 +00:00
if ( sprite [ spnum ] . lotag = = 42 ) fofmode = 40 ;
if ( sprite [ spnum ] . lotag = = 43 ) fofmode = 41 ;
if ( sprite [ spnum ] . lotag = = 44 ) fofmode = 40 ;
if ( sprite [ spnum ] . lotag = = 45 ) fofmode = 41 ;
2006-04-13 20:47:06 +00:00
// fofmode=sprite[spnum].lotag-2;
// sectnum=sprite[j].sectnum;
// sectnum=cursectnum;
ok + + ;
/* recursive?
for ( j = 0 ; j < MAXSPRITES ; j + + )
{
if (
sprite [ j ] . sectnum = = sectnum & &
sprite [ j ] . picnum = = 1 & &
sprite [ j ] . lotag = = 110
) { DrawFloorOverFloor ( j ) ; break ; }
}
*/
// if(ok==0) { Message("no fof",RED); return; }
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < MAXSPRITES ; j + + )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ j ] . picnum = = 1 & & sprite [ j ] . lotag = = fofmode & & sprite [ j ] . hitag = = sprite [ floor1 ] . hitag )
2006-04-13 20:47:06 +00:00
{
floor1 = j ;
fofmode = sprite [ j ] . lotag ;
ok + + ;
break ;
}
}
// if(ok==1) { Message("no floor1",RED); return; }
2006-11-15 01:16:55 +00:00
if ( fofmode = = 40 ) k = 41 ;
else k = 40 ;
2006-04-13 20:47:06 +00:00
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < MAXSPRITES ; j + + )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ j ] . picnum = = 1 & & sprite [ j ] . lotag = = k & & sprite [ j ] . hitag = = sprite [ floor1 ] . hitag )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
floor2 = j ;
ok + + ;
break ;
2006-04-13 20:47:06 +00:00
}
}
i = floor1 ;
offx = sprite [ floor2 ] . x - sprite [ floor1 ] . x ;
offy = sprite [ floor2 ] . y - sprite [ floor1 ] . y ;
offz = 0 ;
if ( sprite [ floor2 ] . ang > = 1024 )
offz = sprite [ floor2 ] . z ;
else if ( fofmode = = 41 )
offz = sector [ sprite [ floor2 ] . sectnum ] . floorz ;
else
offz = sector [ sprite [ floor2 ] . sectnum ] . ceilingz ;
if ( sprite [ floor1 ] . ang > = 1024 )
offz - = sprite [ floor1 ] . z ;
else if ( fofmode = = 40 )
offz - = sector [ sprite [ floor1 ] . sectnum ] . floorz ;
else
offz - = sector [ sprite [ floor1 ] . sectnum ] . ceilingz ;
// if(ok==2) { Message("no floor2",RED); return; }
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < MAXSPRITES ; j + + ) // raise ceiling or floor
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ j ] . picnum = = 1 & & sprite [ j ] . lotag = = k + 2 & & sprite [ j ] . hitag = = sprite [ floor1 ] . hitag )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( k = = 40 )
2006-04-13 20:47:06 +00:00
{
tempsectorz [ sprite [ j ] . sectnum ] = sector [ sprite [ j ] . sectnum ] . floorz ;
sector [ sprite [ j ] . sectnum ] . floorz + = ( ( ( z - sector [ sprite [ j ] . sectnum ] . floorz ) / 32768 ) + 1 ) * 32768 ;
tempsectorpicnum [ sprite [ j ] . sectnum ] = sector [ sprite [ j ] . sectnum ] . floorpicnum ;
sector [ sprite [ j ] . sectnum ] . floorpicnum = 562 ;
}
else
{
tempsectorz [ sprite [ j ] . sectnum ] = sector [ sprite [ j ] . sectnum ] . ceilingz ;
sector [ sprite [ j ] . sectnum ] . ceilingz + = ( ( ( z - sector [ sprite [ j ] . sectnum ] . ceilingz ) / 32768 ) - 1 ) * 32768 ;
tempsectorpicnum [ sprite [ j ] . sectnum ] = sector [ sprite [ j ] . sectnum ] . ceilingpicnum ;
sector [ sprite [ j ] . sectnum ] . ceilingpicnum = 562 ;
}
draw_both = 1 ;
}
}
drawrooms ( x + offx , y + offy , z + offz , a , h , sprite [ floor2 ] . sectnum ) ;
ExtAnalyzeSprites ( ) ;
drawmasks ( ) ;
if ( draw_both )
{
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < MAXSPRITES ; j + + ) // restore ceiling or floor for the draw both sectors
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ j ] . picnum = = 1 & &
2006-04-13 20:47:06 +00:00
sprite [ j ] . lotag = = k + 2 & &
sprite [ j ] . hitag = = sprite [ floor1 ] . hitag )
{
2006-11-13 23:12:47 +00:00
if ( k = = 40 )
2006-04-13 20:47:06 +00:00
{
sector [ sprite [ j ] . sectnum ] . floorz = tempsectorz [ sprite [ j ] . sectnum ] ;
sector [ sprite [ j ] . sectnum ] . floorpicnum = tempsectorpicnum [ sprite [ j ] . sectnum ] ;
}
else
{
sector [ sprite [ j ] . sectnum ] . ceilingz = tempsectorz [ sprite [ j ] . sectnum ] ;
sector [ sprite [ j ] . sectnum ] . ceilingpicnum = tempsectorpicnum [ sprite [ j ] . sectnum ] ;
}
} // end if
} // end for
// Now re-draw
drawrooms ( x + offx , y + offy , z + offz , a , h , sprite [ floor2 ] . sectnum ) ;
ExtAnalyzeSprites ( ) ;
drawmasks ( ) ;
}
} // end SE40
2009-01-09 09:29:17 +00:00
static void SE40Code ( int32_t x , int32_t y , int32_t z , int32_t a , int32_t h )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2006-04-13 20:47:06 +00:00
i = 0 ;
2006-11-13 23:12:47 +00:00
while ( i < MAXSPRITES )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t t = sprite [ i ] . lotag ;
2006-11-13 23:12:47 +00:00
switch ( t )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
// case 40:
// case 41:
// ExtSE40Draw(i,x,y,z,a,h);
// break;
case 42 :
case 43 :
case 44 :
case 45 :
if ( cursectnum = = sprite [ i ] . sectnum )
ExtSE40Draw ( i , x , y , z , a , h ) ;
break ;
2006-04-13 20:47:06 +00:00
}
i + + ;
}
}
2009-01-09 09:29:17 +00:00
void ExtEditSectorData ( int16_t sectnum ) //F7
2006-04-13 20:47:06 +00:00
{
// if (qsetmode != 200) Show2dText("sthelp.hlp");
if ( qsetmode = = 200 )
return ;
2008-05-16 00:23:33 +00:00
if ( eitherALT ) //ALT
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_F7 ] = 0 ;
2006-04-13 20:47:06 +00:00
wallsprite = 0 ;
curwall = 0 ;
curwallnum = 0 ;
cursearchspritenum = 0 ;
cursectornum = 0 ;
cursector_lotag = sector [ sectnum ] . lotag ;
cursector_lotag = getnumber16 ( " Enter search sector lotag : " , cursector_lotag , 65536L , 0 ) ;
Bsprintf ( tempbuf , " Search sector lotag %d " , cursector_lotag ) ;
printmessage16 ( tempbuf ) ;
}
else EditSectorData ( sectnum ) ;
} // end ExtEditSectorData
2009-01-09 09:29:17 +00:00
void ExtEditWallData ( int16_t wallnum ) //F8
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( qsetmode = = 200 )
2006-04-13 20:47:06 +00:00
return ;
2008-05-16 00:23:33 +00:00
if ( eitherALT ) //ALT
2006-04-13 20:47:06 +00:00
{
wallsprite = 1 ;
curwall = wallnum ;
curwallnum = 0 ;
cursearchspritenum = 0 ;
cursectornum = 0 ;
search_lotag = wall [ curwall ] . lotag ;
search_hitag = wall [ curwall ] . hitag ;
search_lotag = getnumber16 ( " Enter wall search lotag : " , search_lotag , 65536L , 0 ) ;
search_hitag = getnumber16 ( " Enter wall search hitag : " , search_hitag , 65536L , 0 ) ;
// Bsprintf(tempbuf,"Current wall %d lo=%d hi=%d",
// curwall,wall[curwall].lotag,wall[curwall].hitag);
Bsprintf ( tempbuf , " Search wall lo=%d hi=%d " , search_lotag , search_hitag ) ;
printmessage16 ( tempbuf ) ;
}
else EditWallData ( wallnum ) ;
}
2008-09-19 20:09:43 +00:00
static void GenSearchSprite ( void ) ;
2009-01-09 09:29:17 +00:00
void ExtEditSpriteData ( int16_t spritenum ) //F8
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( qsetmode = = 200 )
2006-04-13 20:47:06 +00:00
return ;
2008-05-16 00:23:33 +00:00
if ( eitherALT ) //ALT
2008-09-19 20:09:43 +00:00
GenSearchSprite ( ) ;
#if 0
2006-04-13 20:47:06 +00:00
{
wallsprite = 2 ;
cursearchsprite = spritenum ;
curwallnum = 0 ;
cursearchspritenum = 0 ;
cursectornum = 0 ;
search_lotag = sprite [ cursearchsprite ] . lotag ;
search_hitag = sprite [ cursearchsprite ] . hitag ;
search_lotag = getnumber16 ( " Enter sprite search lotag : " , search_lotag , 65536L , 0 ) ;
search_hitag = getnumber16 ( " Enter sprite search hitag : " , search_hitag , 65536L , 0 ) ;
Bsprintf ( tempbuf , " Search sprite lo=%d hi=%d " , search_lotag , search_hitag ) ;
printmessage16 ( tempbuf ) ;
}
2008-09-19 20:09:43 +00:00
# endif
2006-04-13 20:47:06 +00:00
else EditSpriteData ( spritenum ) ;
}
2009-01-09 09:29:17 +00:00
static void PrintStatus ( char * string , int32_t num , char x , char y , char color )
2006-04-13 20:47:06 +00:00
{
Bsprintf ( tempbuf , " %s %d " , string , num ) ;
begindrawing ( ) ;
2009-01-09 09:29:17 +00:00
printext16 ( x * 8 , ydim16 + y * 8 , editorcolors [ ( int32_t ) color ] , - 1 , tempbuf , 0 ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
}
2009-01-09 09:29:17 +00:00
static inline void SpriteName ( int16_t spritenum , char * lo2 )
2006-04-13 20:47:06 +00:00
{
2008-10-18 12:37:26 +00:00
Bstrcpy ( lo2 , names [ sprite [ spritenum ] . picnum ] ) ;
2006-04-13 20:47:06 +00:00
} // end SpriteName
2006-12-10 06:49:01 +00:00
static void ReadPaletteTable ( )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , j , fp ;
2006-04-13 20:47:06 +00:00
char lookup_num ;
2009-01-02 01:03:41 +00:00
for ( j = 0 ; j < 256 ; j + + )
tempbuf [ j ] = j ;
2009-02-19 16:47:54 +00:00
for ( i = 1 ; i < MAXPALOOKUPS ; i + + )
2009-01-02 01:03:41 +00:00
makepalookup ( i , tempbuf , 0 , 0 , 0 , 1 ) ;
2006-11-13 23:12:47 +00:00
if ( ( fp = kopen4load ( " lookup.dat " , 0 ) ) = = - 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( ( fp = kopen4load ( " lookup.dat " , 1 ) ) = = - 1 )
2006-04-13 20:47:06 +00:00
{
2009-01-02 01:03:41 +00:00
initprintf ( " LOOKUP.DAT not found \n " ) ;
2006-04-13 20:47:06 +00:00
return ;
}
}
2008-07-09 23:25:38 +00:00
// initprintf("Loading palette lookups... ");
2006-04-13 20:47:06 +00:00
kread ( fp , & num_tables , 1 ) ;
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < num_tables ; j + + )
2006-04-13 20:47:06 +00:00
{
kread ( fp , & lookup_num , 1 ) ;
kread ( fp , tempbuf , 256 ) ;
makepalookup ( lookup_num , tempbuf , 0 , 0 , 0 , 1 ) ;
}
for ( j = 0 ; j < 256 ; j + + )
tempbuf [ j ] = j ;
num_tables + + ;
makepalookup ( num_tables , tempbuf , 15 , 15 , 15 , 1 ) ;
2006-12-10 06:49:01 +00:00
makepalookup ( num_tables + 1 , tempbuf , 15 , 0 , 0 , 1 ) ;
makepalookup ( num_tables + 2 , tempbuf , 0 , 15 , 0 , 1 ) ;
makepalookup ( num_tables + 3 , tempbuf , 0 , 0 , 15 , 1 ) ;
2006-04-13 20:47:06 +00:00
kread ( fp , WATERpalette , 768 ) ;
kread ( fp , SLIMEpalette , 768 ) ;
kread ( fp , TITLEpalette , 768 ) ;
kread ( fp , REALMSpalette , 768 ) ;
kread ( fp , BOSS1palette , 768 ) ;
kclose ( fp ) ;
2008-07-10 02:45:24 +00:00
// initprintf("success.\n");
2006-04-13 20:47:06 +00:00
} // end ReadPaletteTable
2006-12-10 06:49:01 +00:00
static void ReadGamePalette ( )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t fp ;
2006-11-13 23:12:47 +00:00
if ( ( fp = kopen4load ( " palette.dat " , 0 ) ) = = - 1 )
if ( ( fp = kopen4load ( " palette.dat " , 1 ) ) = = - 1 )
2006-04-13 20:47:06 +00:00
{
initprintf ( " !!! PALETTE.DAT NOT FOUND !!! \n " ) ;
2008-08-28 23:15:11 +00:00
Bstrcpy ( tempbuf , " Mapster32 " VERSION BUILDDATE ) ;
2006-04-13 20:47:06 +00:00
wm_msgbox ( tempbuf , " palette.dat not found " ) ;
exit ( 0 ) ;
}
2008-07-10 02:45:24 +00:00
// initprintf("Loading game palette... ");
2006-04-13 20:47:06 +00:00
kread ( fp , GAMEpalette , 768 ) ;
kclose ( fp ) ;
2008-07-10 02:45:24 +00:00
// initprintf("success.\n");
2006-04-13 20:47:06 +00:00
ReadPaletteTable ( ) ;
}
2008-06-09 23:41:54 +00:00
void message ( const char * fmt , . . . )
2006-04-13 20:47:06 +00:00
{
2008-06-09 23:41:54 +00:00
char tmpstr [ 256 ] ;
va_list va ;
2006-04-13 20:47:06 +00:00
2008-06-09 23:41:54 +00:00
va_start ( va , fmt ) ;
Bvsnprintf ( tmpstr , 256 , fmt , va ) ;
va_end ( va ) ;
2006-05-12 21:55:05 +00:00
2008-06-09 23:41:54 +00:00
Bstrcpy ( getmessage , tmpstr ) ;
getmessageleng = strlen ( getmessage ) ;
getmessagetimeoff = totalclock + 120 * 3 ;
2008-05-16 19:51:38 +00:00
lastmessagetime = totalclock ;
2008-06-09 23:41:54 +00:00
if ( ! mouseaction )
{
Bstrcat ( tmpstr , " \n " ) ;
OSD_Printf ( tmpstr ) ;
}
2006-04-13 20:47:06 +00:00
}
static char lockbyte4094 ;
2009-01-09 09:29:17 +00:00
static int32_t lastupdate , mousecol , mouseadd = 1 , bstatus ;
2006-04-13 20:47:06 +00:00
2006-12-10 06:49:01 +00:00
static void m32_showmouse ( void )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , col ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( totalclock > lastupdate )
2006-04-13 20:47:06 +00:00
{
mousecol + = mouseadd ;
2006-11-13 23:12:47 +00:00
if ( mousecol > = 30 | | mousecol < = 0 )
2006-04-13 20:47:06 +00:00
{
mouseadd = - mouseadd ;
mousecol + = mouseadd ;
}
lastupdate = totalclock + 3 ;
}
2006-11-13 23:12:47 +00:00
switch ( whitecol )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 1 : // Shadow Warrior
col = whitecol + mousecol ;
break ;
case 31 : // Duke Nukem 3D
col = whitecol - mousecol ;
break ;
default :
col = whitecol ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( col ! = whitecol )
2006-04-13 20:47:06 +00:00
{
2009-02-19 16:47:54 +00:00
for ( i = ( ( xdim > 640 ) ? 3 : 2 ) ; i < = ( ( xdim > 640 ) ? 7 : 3 ) ; i + + )
2006-04-13 20:47:06 +00:00
{
plotpixel ( searchx + i , searchy , col ) ;
plotpixel ( searchx - i , searchy , col ) ;
plotpixel ( searchx , searchy - i , col ) ;
plotpixel ( searchx , searchy + i , col ) ;
}
2009-02-19 16:47:54 +00:00
for ( i = 1 ; i < = ( ( xdim > 640 ) ? 2 : 1 ) ; i + + )
2006-04-13 20:47:06 +00:00
{
plotpixel ( searchx + i , searchy , whitecol ) ;
plotpixel ( searchx - i , searchy , whitecol ) ;
plotpixel ( searchx , searchy - i , whitecol ) ;
plotpixel ( searchx , searchy + i , whitecol ) ;
}
2007-02-26 01:46:38 +00:00
i = ( ( xdim > 640 ) ? 8 : 4 ) ;
2006-04-13 20:47:06 +00:00
plotpixel ( searchx + i , searchy , 0 ) ;
plotpixel ( searchx - i , searchy , 0 ) ;
plotpixel ( searchx , searchy - i , 0 ) ;
plotpixel ( searchx , searchy + i , 0 ) ;
}
2007-03-11 00:47:32 +00:00
2007-02-26 01:46:38 +00:00
if ( xdim > 640 )
{
2009-02-19 16:47:54 +00:00
for ( i = 1 ; i < = 4 ; i + + )
2007-02-26 01:46:38 +00:00
{
plotpixel ( searchx + i , searchy , whitecol ) ;
plotpixel ( searchx - i , searchy , whitecol ) ;
plotpixel ( searchx , searchy - i , whitecol ) ;
plotpixel ( searchx , searchy + i , whitecol ) ;
}
2007-03-11 00:47:32 +00:00
}
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
static int32_t AskIfSure ( char * text )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t retval = 1 ;
2006-04-13 20:47:06 +00:00
2008-05-16 19:51:38 +00:00
if ( qsetmode = = 200 )
{
begindrawing ( ) ; //{{{
printext256 ( 0 , 0 , whitecol , 0 , text ? text : " Are you sure you want to proceed? " , 0 ) ;
enddrawing ( ) ; //}}}
}
else
{
printmessage16 ( text ? text : " Are you sure you want to proceed? " ) ;
}
2006-04-13 20:47:06 +00:00
showframe ( 1 ) ;
2008-05-16 00:23:33 +00:00
while ( ( keystatus [ KEYSC_ESC ] | keystatus [ KEYSC_ENTER ] | keystatus [ KEYSC_SPACE ] | keystatus [ KEYSC_N ] ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( handleevents ( ) )
{
if ( quitevent )
{
2006-12-03 00:27:43 +00:00
retval = 1 ;
2006-04-13 20:47:06 +00:00
break ;
}
2007-01-12 05:49:09 +00:00
}
idle ( ) ;
2008-05-18 21:09:30 +00:00
if ( keystatus [ KEYSC_Y ] | | keystatus [ KEYSC_ENTER ] )
2006-11-15 01:16:55 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_Y ] = 0 ;
2008-05-18 21:09:30 +00:00
keystatus [ KEYSC_ENTER ] = 0 ;
2006-11-15 01:16:55 +00:00
retval = 0 ;
break ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 00:23:33 +00:00
while ( keystatus [ KEYSC_ESC ] )
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ESC ] = 0 ;
2006-04-13 20:47:06 +00:00
retval = 1 ;
break ;
}
return ( retval ) ;
}
2009-01-09 09:29:17 +00:00
static int32_t IsValidTile ( const int32_t idTile )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t bValid = 0 ;
2007-04-17 05:54:12 +00:00
if ( ( idTile > = 0 ) & & ( idTile < MAXTILES ) )
{
if ( ( tilesizx [ idTile ] ! = 0 ) & & ( tilesizy [ idTile ] ! = 0 ) )
{
bValid = 1 ;
}
}
return bValid ;
}
2009-01-09 09:29:17 +00:00
static int32_t SelectAllTiles ( int32_t iCurrentTile )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2007-04-17 05:54:12 +00:00
if ( iCurrentTile < localartlookupnum )
{
iCurrentTile = localartlookup [ iCurrentTile ] ;
}
else
{
iCurrentTile = 0 ;
}
localartlookupnum = MAXTILES ;
for ( i = 0 ; i < MAXTILES ; i + + )
{
localartlookup [ i ] = i ;
localartfreq [ i ] = 0 ;
}
return iCurrentTile ;
}
2009-01-09 09:29:17 +00:00
static int32_t OnGotoTile ( int32_t iTile ) ;
static int32_t OnSelectTile ( int32_t iTile ) ;
static int32_t s_Zoom = INITIAL_ZOOM ;
static int32_t s_TileZoom = 1 ;
2007-04-17 05:54:12 +00:00
2009-01-09 09:29:17 +00:00
static int32_t DrawTiles ( int32_t iTopLeft , int32_t iSelected , int32_t nXTiles , int32_t nYTiles , int32_t TileDim , int32_t offset ) ;
2007-04-17 05:54:12 +00:00
2009-01-09 09:29:17 +00:00
static int32_t m32gettile ( int32_t idInitialTile )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t gap , temp ;
int32_t nXTiles , nYTiles , nDisplayedTiles ;
int32_t i ;
int32_t iTile , iTopLeftTile ;
int32_t idSelectedTile ;
int32_t scrollmode ;
int32_t mousedx , mousedy , mtile , omousex = searchx , omousey = searchy , moffset = 0 ;
2007-04-17 05:54:12 +00:00
// Enable following line for testing. I couldn't work out how to change vidmode on the fly
// s_Zoom = NUM_ZOOMS - 1;
if ( idInitialTile < 0 )
{
idInitialTile = 0 ;
}
else if ( idInitialTile > = MAXTILES )
{
idInitialTile = MAXTILES - 1 ;
}
// Ensure zoom not to big (which can happen if display size
// changes whilst Mapster is running)
do
{
nXTiles = xdim / ZoomToThumbSize [ s_Zoom ] ;
nYTiles = ydim / ZoomToThumbSize [ s_Zoom ] ;
2008-07-14 01:48:20 +00:00
// Refuse to draw less than half of a row.
if ( ZoomToThumbSize [ s_Zoom ] / 2 < 12 ) nYTiles - - ;
2007-04-17 05:54:12 +00:00
nDisplayedTiles = nXTiles * nYTiles ;
2007-04-21 20:25:07 +00:00
if ( ! nDisplayedTiles )
2007-04-17 05:54:12 +00:00
{
// Eh-up, resolution changed since we were last displaying tiles.
s_Zoom - - ;
}
}
2007-04-21 20:25:07 +00:00
while ( ! nDisplayedTiles ) ;
2007-04-17 05:54:12 +00:00
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_V ] = 0 ;
2007-04-17 05:54:12 +00:00
for ( i = 0 ; i < MAXTILES ; i + + )
{
localartfreq [ i ] = 0 ;
localartlookup [ i ] = i ;
}
iTile = idSelectedTile = idInitialTile ;
switch ( searchstat )
{
case 0 :
for ( i = 0 ; i < numwalls ; i + + )
{
localartfreq [ wall [ i ] . picnum ] + + ;
}
break ;
case 1 :
case 2 :
for ( i = 0 ; i < numsectors ; i + + )
{
localartfreq [ sector [ i ] . ceilingpicnum ] + + ;
localartfreq [ sector [ i ] . floorpicnum ] + + ;
}
break ;
case 3 :
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2007-04-17 05:54:12 +00:00
{
if ( sprite [ i ] . statnum < MAXSTATUS )
{
localartfreq [ sprite [ i ] . picnum ] + + ;
}
}
break ;
case 4 :
for ( i = 0 ; i < numwalls ; i + + )
{
localartfreq [ wall [ i ] . overpicnum ] + + ;
}
break ;
default :
break ;
}
//
// Sort tiles into frequency order
//
gap = MAXTILES / 2 ;
do
{
for ( i = 0 ; i < MAXTILES - gap ; i + + )
{
temp = i ;
while ( ( localartfreq [ temp ] < localartfreq [ temp + gap ] ) & & ( temp > = 0 ) )
{
2009-01-09 09:29:17 +00:00
int32_t tempint ;
2007-04-17 05:54:12 +00:00
2007-12-12 17:42:14 +00:00
tempint = localartfreq [ temp ] ;
2007-04-17 05:54:12 +00:00
localartfreq [ temp ] = localartfreq [ temp + gap ] ;
2007-12-12 17:42:14 +00:00
localartfreq [ temp + gap ] = tempint ;
2007-04-17 05:54:12 +00:00
2007-12-12 17:42:14 +00:00
tempint = localartlookup [ temp ] ;
2007-04-17 05:54:12 +00:00
localartlookup [ temp ] = localartlookup [ temp + gap ] ;
2007-12-12 17:42:14 +00:00
localartlookup [ temp + gap ] = tempint ;
2007-04-17 05:54:12 +00:00
if ( iTile = = temp )
{
iTile = temp + gap ;
}
else if ( iTile = = temp + gap )
{
iTile = temp ;
}
temp - = gap ;
}
}
gap > > = 1 ;
}
while ( gap > 0 ) ;
//
// Set up count of number of used tiles
//
localartlookupnum = 0 ;
while ( localartfreq [ localartlookupnum ] > 0 )
{
localartlookupnum + + ;
}
//
// Check : If no tiles used at all then switch to displaying all tiles
//
2007-04-21 20:25:07 +00:00
if ( ! localartfreq [ 0 ] )
2007-04-17 05:54:12 +00:00
{
localartlookupnum = MAXTILES ;
for ( i = 0 ; i < MAXTILES ; i + + )
{
localartlookup [ i ] = i ;
localartfreq [ i ] = 0 ; // Terrible bodge : zero tilefreq's not displayed in tile view. Still, when in Rome ... :-)
}
iTile = idInitialTile ;
}
//
//
//
iTopLeftTile = iTile - ( iTile % nXTiles ) ;
if ( iTopLeftTile < 0 )
{
iTopLeftTile = 0 ;
}
if ( iTopLeftTile > MAXTILES - nDisplayedTiles )
{
iTopLeftTile = MAXTILES - nDisplayedTiles ;
}
2008-05-16 19:51:38 +00:00
searchx = ( ( iTile - iTopLeftTile ) % nXTiles ) * ZoomToThumbSize [ s_Zoom ] + ZoomToThumbSize [ s_Zoom ] / 2 ;
searchy = ( ( iTile - iTopLeftTile ) / nXTiles ) * ZoomToThumbSize [ s_Zoom ] + ZoomToThumbSize [ s_Zoom ] / 2 ;
2007-04-17 05:54:12 +00:00
////////////////////////////////
// Start of key handling code //
////////////////////////////////
2008-05-16 19:51:38 +00:00
while ( ( keystatus [ KEYSC_ENTER ] | keystatus [ KEYSC_ESC ] | ( bstatus & 1 ) ) = = 0 ) // <- Presumably one of these is escape key ???
2007-04-17 05:54:12 +00:00
{
2008-05-17 21:44:49 +00:00
DrawTiles ( iTopLeftTile , ( iTile > = localartlookupnum ) ? localartlookupnum - 1 : iTile , nXTiles , nYTiles , ZoomToThumbSize [ s_Zoom ] , moffset ) ;
2008-05-16 19:51:38 +00:00
getmousevalues ( & mousedx , & mousedy , & bstatus ) ;
searchx + = mousedx ;
searchy + = mousedy ;
2008-05-17 21:44:49 +00:00
if ( bstatus & 2 )
2008-05-16 19:51:38 +00:00
{
2008-05-17 21:44:49 +00:00
moffset + = mousedy * 2 ;
searchy + = mousedy ;
searchx - = mousedx ;
2008-05-18 21:09:30 +00:00
if ( ( moffset < 0 & & iTopLeftTile > localartlookupnum - nDisplayedTiles - 1 )
| | ( moffset > 0 & & iTopLeftTile = = 0 ) )
{
moffset = 0 ;
searchy - = mousedy * 2 ;
}
2008-05-16 19:51:38 +00:00
while ( moffset > ZoomToThumbSize [ s_Zoom ] )
{
iTopLeftTile - = nXTiles ;
moffset - = ZoomToThumbSize [ s_Zoom ] ;
}
while ( moffset < - ZoomToThumbSize [ s_Zoom ] )
{
iTopLeftTile + = nXTiles ;
moffset + = ZoomToThumbSize [ s_Zoom ] ;
}
}
2008-07-14 01:48:20 +00:00
// Keep the pointer visible at all times.
temp = min ( ( ZoomToThumbSize [ s_Zoom ] / 2 ) , 12 ) ;
if ( searchx < temp ) searchx = temp ;
if ( searchy < temp ) searchy = temp ;
if ( searchx > xdim - temp ) searchx = xdim - temp ;
if ( searchy > ydim - temp ) searchy = ydim - temp ;
2008-05-16 20:15:43 +00:00
2008-05-18 21:09:30 +00:00
scrollmode = ! ( eitherCTRL ^ revertCTRL ) ;
if ( bstatus & 16 & & scrollmode & & iTopLeftTile > 0 )
2008-05-17 21:44:49 +00:00
{
mouseb & = ~ 16 ;
2008-05-18 21:09:30 +00:00
iTopLeftTile - = ( nXTiles * scrollamount ) ;
2008-05-17 21:44:49 +00:00
}
2008-05-18 21:09:30 +00:00
if ( bstatus & 32 & & scrollmode & & iTopLeftTile < localartlookupnum - nDisplayedTiles - 1 )
2008-05-17 21:44:49 +00:00
{
mouseb & = ~ 32 ;
2008-05-18 21:09:30 +00:00
iTopLeftTile + = ( nXTiles * scrollamount ) ;
2008-05-17 21:44:49 +00:00
}
2008-05-16 19:51:38 +00:00
mtile = iTile = ( searchx / ZoomToThumbSize [ s_Zoom ] ) + ( ( searchy - moffset ) / ZoomToThumbSize [ s_Zoom ] ) * nXTiles + iTopLeftTile ;
while ( iTile > = iTopLeftTile + nDisplayedTiles )
{
iTile - = nXTiles ;
mtile = iTile ;
}
2007-04-17 05:54:12 +00:00
if ( handleevents ( ) )
{
if ( quitevent ) quitevent = 0 ;
}
2007-04-21 20:25:07 +00:00
idle ( ) ;
2007-04-17 05:54:12 +00:00
// These two lines are so obvious I don't need to comment them ...;-)
synctics = totalclock - lockclock ;
lockclock + = synctics ;
// Zoom in / out using numeric key pad's / and * keys
2008-05-18 21:09:30 +00:00
if ( ( ( keystatus [ KEYSC_gSLASH ] | | ( ! scrollmode & & bstatus & 16 ) ) & & s_Zoom < ( signed ) ( NUM_ZOOMS - 1 ) )
| | ( ( keystatus [ KEYSC_gSTAR ] | | ( ! scrollmode & & bstatus & 32 ) ) & & s_Zoom > 0 ) )
2007-04-17 05:54:12 +00:00
{
2008-05-18 21:09:30 +00:00
if ( keystatus [ KEYSC_gSLASH ] | | ( ! scrollmode & & bstatus & 16 ) )
2007-04-17 05:54:12 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_gSLASH ] = 0 ;
2008-05-16 19:51:38 +00:00
mouseb & = ~ 16 ;
bstatus & = ~ 16 ;
2007-04-17 05:54:12 +00:00
// Watch out : If editor window is small, then the next zoom level
// might get so large that even one tile might not fit !
if ( ( ZoomToThumbSize [ s_Zoom + 1 ] < = xdim )
& & ( ZoomToThumbSize [ s_Zoom + 1 ] < = ydim ) )
{
// Phew, plenty of room.
s_Zoom + + ;
}
}
else
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_gSTAR ] = 0 ;
2008-05-16 19:51:38 +00:00
mouseb & = ~ 32 ;
bstatus & = ~ 32 ;
2007-04-17 05:54:12 +00:00
s_Zoom - - ;
}
2008-05-17 21:44:49 +00:00
if ( iTile > = localartlookupnum ) iTile = localartlookupnum - 1 ;
2007-04-17 05:54:12 +00:00
// Calculate new num of tiles to display
nXTiles = xdim / ZoomToThumbSize [ s_Zoom ] ;
nYTiles = ydim / ZoomToThumbSize [ s_Zoom ] ;
2008-07-14 01:48:20 +00:00
// Refuse to draw less than half of a row.
if ( ZoomToThumbSize [ s_Zoom ] / 2 < 12 ) nYTiles - - ;
2007-04-17 05:54:12 +00:00
nDisplayedTiles = nXTiles * nYTiles ;
// Determine if the top-left displayed tile needs to
// alter in order to display selected tile
iTopLeftTile = iTile - ( iTile % nXTiles ) ;
if ( iTopLeftTile < 0 )
{
iTopLeftTile = 0 ;
}
else if ( iTopLeftTile > MAXTILES - nDisplayedTiles )
{
iTopLeftTile = MAXTILES - nDisplayedTiles ;
}
2008-05-16 19:51:38 +00:00
// scroll window so mouse points the same tile as it was before zooming
iTopLeftTile - = ( searchx / ZoomToThumbSize [ s_Zoom ] ) + ( ( searchy - moffset ) / ZoomToThumbSize [ s_Zoom ] ) * nXTiles + iTopLeftTile - iTile ;
2007-04-17 05:54:12 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_LEFT ] )
2007-04-17 05:54:12 +00:00
{
iTile - = ( iTile > 0 ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_LEFT ] = 0 ;
2007-04-17 05:54:12 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_RIGHT ] )
2007-04-17 05:54:12 +00:00
{
iTile + = ( iTile < MAXTILES ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_RIGHT ] = 0 ;
2007-04-17 05:54:12 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_UP ] )
2007-04-17 05:54:12 +00:00
{
iTile - = nXTiles ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_UP ] = 0 ;
2007-04-17 05:54:12 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_DOWN ] )
2007-04-17 05:54:12 +00:00
{
iTile + = nXTiles ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_DOWN ] = 0 ;
2007-04-17 05:54:12 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_PGUP ] )
2007-04-17 05:54:12 +00:00
{
iTile - = nDisplayedTiles ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_PGUP ] = 0 ;
2007-04-17 05:54:12 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_PGDN ] )
2007-04-17 05:54:12 +00:00
{
iTile + = nDisplayedTiles ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_PGDN ] = 0 ;
2007-04-17 05:54:12 +00:00
}
//
// Ensure tilenum is within valid range
//
2007-04-21 20:25:07 +00:00
if ( iTile < 0 )
2007-04-17 05:54:12 +00:00
{
2007-04-21 20:25:07 +00:00
iTile = 0 ;
2007-04-17 05:54:12 +00:00
}
2007-04-21 20:25:07 +00:00
if ( iTile > = MAXTILES ) // shouldn't this be the count of num tiles ???
2007-04-17 05:54:12 +00:00
{
2007-04-21 20:25:07 +00:00
iTile = MAXTILES - 1 ;
2007-04-17 05:54:12 +00:00
}
// 'V' KEYPRESS
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_V ] )
2007-04-17 05:54:12 +00:00
{
2007-04-23 23:36:21 +00:00
keystatus [ KEYSC_V ] = 0 ;
2007-04-17 05:54:12 +00:00
iTile = SelectAllTiles ( iTile ) ;
}
// 'G' KEYPRESS - Goto frame
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_G ] )
2007-04-17 05:54:12 +00:00
{
2007-04-23 23:36:21 +00:00
keystatus [ KEYSC_G ] = 0 ;
2007-04-17 05:54:12 +00:00
iTile = OnGotoTile ( iTile ) ;
}
// 'U' KEYPRESS : go straight to user defined art
2007-04-23 23:36:21 +00:00
if ( keystatus [ KEYSC_U ] )
2007-04-17 05:54:12 +00:00
{
SelectAllTiles ( iTile ) ;
iTile = FIRST_USER_ART_TILE ;
2007-04-23 23:36:21 +00:00
keystatus [ KEYSC_U ] = 0 ;
2007-04-17 05:54:12 +00:00
}
// 'A' KEYPRESS : Go straight to start of Atomic edition's art
2007-04-23 23:36:21 +00:00
if ( keystatus [ KEYSC_A ] )
2007-04-17 05:54:12 +00:00
{
SelectAllTiles ( iTile ) ;
iTile = FIRST_ATOMIC_TILE ;
2007-04-23 23:36:21 +00:00
keystatus [ KEYSC_A ] = 0 ;
2007-04-17 05:54:12 +00:00
}
// 'T' KEYPRESS = Select from pre-defined tileset
2007-04-23 23:36:21 +00:00
if ( keystatus [ KEYSC_T ] )
2007-04-17 05:54:12 +00:00
{
2007-04-23 23:36:21 +00:00
keystatus [ KEYSC_T ] = 0 ;
2007-04-17 05:54:12 +00:00
iTile = OnSelectTile ( iTile ) ;
}
2007-04-21 20:25:07 +00:00
// 'E' KEYPRESS : Go straight to start of extended art
2007-04-23 23:36:21 +00:00
if ( keystatus [ KEYSC_E ] )
2007-04-21 20:25:07 +00:00
{
SelectAllTiles ( iTile ) ;
if ( iTile = = FIRST_EXTENDED_TILE )
iTile = SECOND_EXTENDED_TILE ;
else iTile = FIRST_EXTENDED_TILE ;
2007-04-23 23:36:21 +00:00
keystatus [ KEYSC_E ] = 0 ;
}
if ( keystatus [ KEYSC_Z ] )
{
s_TileZoom = ! s_TileZoom ;
keystatus [ KEYSC_Z ] = 0 ;
2007-04-21 20:25:07 +00:00
}
2007-04-17 05:54:12 +00:00
//
// Adjust top-left to ensure tilenum is within displayed range of tiles
//
2008-05-16 19:51:38 +00:00
while ( iTile < iTopLeftTile - ( moffset < 0 ) ? nXTiles : 0 )
2007-04-17 05:54:12 +00:00
{
iTopLeftTile - = nXTiles ;
}
while ( iTile > = iTopLeftTile + nDisplayedTiles )
{
iTopLeftTile + = nXTiles ;
}
if ( iTopLeftTile < 0 )
{
iTopLeftTile = 0 ;
}
if ( iTopLeftTile > MAXTILES - nDisplayedTiles )
{
iTopLeftTile = MAXTILES - nDisplayedTiles ;
}
2008-05-16 19:51:38 +00:00
if ( ( keystatus [ KEYSC_ENTER ] | | ( bstatus & 1 ) ) = = 0 ) // uh ? Not escape key ?
2007-04-17 05:54:12 +00:00
{
idSelectedTile = idInitialTile ;
}
else
{
if ( iTile < localartlookupnum )
{
// Convert tile num from index to actual tile num
idSelectedTile = localartlookup [ iTile ] ;
// Check : if invalid tile selected, return original tile num
if ( ! IsValidTile ( idSelectedTile ) )
{
idSelectedTile = idInitialTile ;
}
}
else
{
idSelectedTile = idInitialTile ;
}
}
2008-05-16 19:51:38 +00:00
if ( mtile ! = iTile ) // if changed by keyboard, update mouse cursor
{
searchx = ( ( iTile - iTopLeftTile ) % nXTiles ) * ZoomToThumbSize [ s_Zoom ] + ZoomToThumbSize [ s_Zoom ] / 2 ;
searchy = ( ( iTile - iTopLeftTile ) / nXTiles ) * ZoomToThumbSize [ s_Zoom ] + ZoomToThumbSize [ s_Zoom ] / 2 + moffset ;
}
2007-04-17 05:54:12 +00:00
}
2009-02-19 16:47:54 +00:00
searchx = omousex ; searchy = omousey ;
2007-04-17 05:54:12 +00:00
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ESC ] = 0 ;
keystatus [ KEYSC_ENTER ] = 0 ;
2007-04-17 05:54:12 +00:00
return ( idSelectedTile ) ;
}
// Dir = 0 (zoom out) or 1 (zoom in)
2009-01-09 09:29:17 +00:00
//void OnZoomInOut( int32_t *pZoom, int32_t Dir /*0*/ )
2007-04-17 05:54:12 +00:00
//{
//}
2009-01-09 09:29:17 +00:00
static int32_t OnGotoTile ( int32_t iTile )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t iTemp , iNewTile ;
2007-04-17 05:54:12 +00:00
char ch ;
char szTemp [ 128 ] ;
//Automatically press 'V'
iTile = SelectAllTiles ( iTile ) ;
bflushchars ( ) ;
2008-05-15 03:16:38 +00:00
iNewTile = iTemp = 0 ; //iTile; //PK
2007-04-17 05:54:12 +00:00
2008-05-16 00:23:33 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 )
2007-04-17 05:54:12 +00:00
{
if ( handleevents ( ) )
{
if ( quitevent ) quitevent = 0 ;
}
2007-04-21 20:25:07 +00:00
idle ( ) ;
2007-04-17 05:54:12 +00:00
ch = bgetchar ( ) ;
2007-12-12 17:42:14 +00:00
Bsprintf ( szTemp , " Goto tile: %d_ " , iNewTile ) ;
2007-04-17 05:54:12 +00:00
printext256 ( 0 , 0 , whitecol , 0 , szTemp , 0 ) ;
showframe ( 1 ) ;
if ( ch > = ' 0 ' & & ch < = ' 9 ' )
{
iTemp = ( iNewTile * 10 ) + ( ch - ' 0 ' ) ;
if ( iTemp < MAXTILES )
{
iNewTile = iTemp ;
}
}
else if ( ch = = 8 )
{
iNewTile / = 10 ;
}
else if ( ch = = 13 )
{
iTile = iNewTile ;
break ;
}
}
clearkeys ( ) ;
return iTile ;
}
2009-01-09 09:29:17 +00:00
static int32_t LoadTileSet ( const int32_t idCurrentTile , const int32_t * pIds , const int32_t nIds )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t iNewTile = 0 ;
int32_t i ;
2007-04-17 05:54:12 +00:00
localartlookupnum = nIds ;
for ( i = 0 ; i < localartlookupnum ; i + + )
{
localartlookup [ i ] = pIds [ i ] ;
// REM : Could we still utilise localartfreq[] to mark
// which tiles are currently used in the map ? Set to 0xFFFF perhaps ?
localartfreq [ i ] = 0 ;
if ( idCurrentTile = = pIds [ i ] )
{
iNewTile = i ;
}
}
return iNewTile ;
}
2009-01-09 09:29:17 +00:00
static int32_t OnSelectTile ( int32_t iTile )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t bDone = 0 ;
int32_t i ;
2007-04-17 05:54:12 +00:00
char ch ;
2007-04-21 23:59:56 +00:00
for ( i = 0 ; ( unsigned ) i < tile_groups ; i + + )
2007-04-21 20:25:07 +00:00
{
if ( s_TileGroups [ i ] . pIds ! = NULL )
break ;
}
2007-04-21 23:59:56 +00:00
if ( ( unsigned ) i = = tile_groups ) // no tile groups
2007-04-21 20:25:07 +00:00
return ( iTile ) ;
2007-04-17 05:54:12 +00:00
SelectAllTiles ( iTile ) ;
bflushchars ( ) ;
begindrawing ( ) ;
setpolymost2dview ( ) ;
clearview ( 0 ) ;
//
// Await appropriate selection keypress.
//
bDone = 0 ;
2008-05-16 00:23:33 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 & & ( ! bDone ) )
2007-04-17 05:54:12 +00:00
{
if ( handleevents ( ) )
{
if ( quitevent ) quitevent = 0 ;
}
2007-04-21 20:25:07 +00:00
idle ( ) ;
2007-04-17 05:54:12 +00:00
2008-07-12 23:44:07 +00:00
//
// Display the description strings for each available tile group
//
for ( i = 0 ; ( unsigned ) i < tile_groups ; i + + )
{
if ( s_TileGroups [ i ] . szText ! = NULL )
{
if ( ( i + 2 ) * 16 > ydimgame ) break ;
Bsprintf ( tempbuf , " (%c) %s " , s_TileGroups [ i ] . key1 , s_TileGroups [ i ] . szText ) ;
printext256 ( 10L , ( i + 1 ) * 16 , whitecol , - 1 , tempbuf , 0 ) ;
}
}
showframe ( 1 ) ;
2007-04-17 05:54:12 +00:00
ch = bgetchar ( ) ;
2007-04-21 23:59:56 +00:00
for ( i = 0 ; ( unsigned ) i < tile_groups ; i + + )
2007-04-17 05:54:12 +00:00
{
2007-04-21 21:01:07 +00:00
if ( s_TileGroups [ i ] . pIds ! = NULL & & s_TileGroups [ i ] . key1 )
2007-04-21 20:25:07 +00:00
if ( ( ch = = s_TileGroups [ i ] . key1 ) | | ( ch = = s_TileGroups [ i ] . key2 ) )
{
iTile = LoadTileSet ( iTile , s_TileGroups [ i ] . pIds , s_TileGroups [ i ] . nIds ) ;
bDone = 1 ;
}
2007-04-17 05:54:12 +00:00
}
}
enddrawing ( ) ;
showframe ( 1 ) ;
clearkeys ( ) ;
return iTile ;
}
2009-01-09 09:29:17 +00:00
const char * GetTilePixels ( const int32_t idTile )
2007-04-17 05:54:12 +00:00
{
char * pPixelData = 0 ;
if ( ( idTile > = 0 ) & & ( idTile < MAXTILES ) )
{
2007-04-21 20:25:07 +00:00
if ( ! waloff [ idTile ] )
2007-04-17 05:54:12 +00:00
{
loadtile ( idTile ) ;
}
if ( IsValidTile ( idTile ) )
{
pPixelData = ( char * ) waloff [ idTile ] ;
}
}
return pPixelData ;
}
2009-01-09 09:29:17 +00:00
static int32_t DrawTiles ( int32_t iTopLeft , int32_t iSelected , int32_t nXTiles , int32_t nYTiles , int32_t TileDim , int32_t offset )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t XTile , YTile ;
int32_t iTile , idTile ;
int32_t XBox , YBox ;
int32_t XPos , YPos ;
int32_t XOffset , YOffset ;
int32_t i ;
2007-04-17 05:54:12 +00:00
const char * pRawPixels ;
2009-01-09 09:29:17 +00:00
int32_t TileSizeX , TileSizeY ;
int32_t DivInc , MulInc ;
2007-04-17 05:54:12 +00:00
char * pScreen ;
char szT [ 128 ] ;
begindrawing ( ) ;
setpolymost2dview ( ) ;
clearview ( 0 ) ;
2008-05-16 19:51:38 +00:00
for ( YTile = 0 - ( offset > 0 ) ; YTile < nYTiles + ( offset < 0 ) + 1 ; YTile + + )
2007-04-17 05:54:12 +00:00
{
for ( XTile = 0 ; XTile < nXTiles ; XTile + + )
{
iTile = iTopLeft + XTile + ( YTile * nXTiles ) ;
2008-05-16 19:51:38 +00:00
if ( iTile > = 0 & & iTile < localartlookupnum )
2007-04-17 05:54:12 +00:00
{
idTile = localartlookup [ iTile ] ;
// Get pointer to tile's raw pixel data
pRawPixels = GetTilePixels ( idTile ) ;
if ( pRawPixels ! = NULL )
{
XPos = XTile * TileDim ;
2008-05-16 19:51:38 +00:00
YPos = YTile * TileDim + offset ;
2007-04-17 05:54:12 +00:00
2007-04-23 23:36:21 +00:00
if ( polymost_drawtilescreen ( XPos , YPos , idTile , TileDim , s_TileZoom ) )
2007-04-17 05:54:12 +00:00
{
TileSizeX = tilesizx [ idTile ] ;
TileSizeY = tilesizy [ idTile ] ;
DivInc = 1 ;
MulInc = 1 ;
while ( ( TileSizeX / DivInc > TileDim )
| | ( TileSizeY / DivInc ) > TileDim )
{
DivInc + + ;
}
2007-04-28 21:24:36 +00:00
if ( DivInc = = 1 & & s_TileZoom )
2007-04-17 05:54:12 +00:00
{
while ( ( ( TileSizeX * ( MulInc + 1 ) ) < = TileDim )
& & ( ( TileSizeY * ( MulInc + 1 ) ) < = TileDim ) )
{
MulInc + + ;
}
}
TileSizeX = ( TileSizeX / DivInc ) * MulInc ;
TileSizeY = ( TileSizeY / DivInc ) * MulInc ;
for ( YOffset = 0 ; YOffset < TileSizeY ; YOffset + + )
{
2009-01-09 09:29:17 +00:00
int32_t y = YPos + YOffset ;
2008-05-16 19:51:38 +00:00
if ( y > = 0 & & y < ydim )
2007-04-17 05:54:12 +00:00
{
2008-05-16 19:51:38 +00:00
pScreen = ( char * ) ylookup [ y ] + XPos + frameplace ;
for ( XOffset = 0 ; XOffset < TileSizeX ; XOffset + + )
{
pScreen [ XOffset ] = pRawPixels [ ( ( YOffset * DivInc ) / MulInc ) + ( ( ( XOffset * DivInc ) / MulInc ) * tilesizy [ idTile ] ) ] ;
}
2007-04-17 05:54:12 +00:00
}
}
}
2008-05-17 21:44:49 +00:00
if ( localartfreq [ iTile ] ! = 0 & & YPos > = 0 & & YPos < = ydim - 20 )
2007-04-17 05:54:12 +00:00
{
Bsprintf ( szT , " %d " , localartfreq [ iTile ] ) ;
printext256 ( XPos , YPos , whitecol , - 1 , szT , 1 ) ;
}
}
}
}
}
//
// Draw white box around currently selected tile
//
2008-05-16 19:51:38 +00:00
XBox = ( ( iSelected - iTopLeft ) % nXTiles ) * TileDim ;
YBox = ( ( iSelected - ( ( iSelected - iTopLeft ) % nXTiles ) - iTopLeft ) / nXTiles ) * TileDim + offset ;
2007-04-17 05:54:12 +00:00
2008-05-17 21:44:49 +00:00
if ( iSelected - iTopLeft > 0 )
for ( i = 0 ; i < TileDim ; i + + )
2008-05-16 19:51:38 +00:00
{
2008-05-17 21:44:49 +00:00
if ( YBox > = 0 & & YBox < ydim )
plotpixel ( XBox + i , YBox , whitecol ) ;
if ( YBox + TileDim > = 0 & & YBox + TileDim < ydim )
plotpixel ( XBox + i , YBox + TileDim , whitecol ) ;
if ( YBox + i > = 0 & & YBox + i < ydim )
{
plotpixel ( XBox , YBox + i , whitecol ) ;
plotpixel ( XBox + TileDim , YBox + i , whitecol ) ;
}
2008-05-16 19:51:38 +00:00
}
2007-04-17 05:54:12 +00:00
idTile = localartlookup [ iSelected ] ;
2008-07-14 01:48:20 +00:00
// Draw info bar at bottom.
// Clear out behind the text for improved visibility.
//drawline256(0, (ydim-12)<<12, xdim<<12, (ydim-12)<<12, whitecol);
2008-07-16 09:27:08 +00:00
for ( i = ydim - 12 ; i < ydim ; i + + )
{
2008-07-14 01:48:20 +00:00
drawline256 ( 0 , i < < 12 , xdim < < 12 , i < < 12 , ( ydim - i ) ) ;
}
// Tile number on left.
2007-12-12 17:42:14 +00:00
Bsprintf ( szT , " %d " , idTile ) ;
2008-07-14 01:48:20 +00:00
printext256 ( 1 , ydim - 10 , whitecol , - 1 , szT , 0 ) ;
2007-04-17 05:54:12 +00:00
2008-07-14 01:48:20 +00:00
// Tile name on right.
printext256 ( xdim - ( Bstrlen ( names [ idTile ] ) < < 3 ) - 1 , ydim - 10 , whitecol , - 1 , names [ idTile ] , 0 ) ;
// Tile dimensions.
2007-04-17 05:54:12 +00:00
Bsprintf ( szT , " %dx%d " , tilesizx [ idTile ] , tilesizy [ idTile ] ) ;
2008-07-14 01:48:20 +00:00
printext256 ( xdim > > 2 , ydim - 10 , whitecol , - 1 , szT , 0 ) ;
2007-04-17 05:54:12 +00:00
2008-07-14 01:48:20 +00:00
// EditArt animation flags.
2008-03-27 21:32:23 +00:00
Bsprintf ( szT , " %d, %d " , ( picanm [ idTile ] > > 8 ) & 0xFF , ( picanm [ idTile ] > > 16 ) & 0xFF ) ;
2008-07-14 01:48:20 +00:00
printext256 ( ( xdim > > 2 ) + 100 , ydim - 10 , whitecol , - 1 , szT , 0 ) ;
2008-03-27 21:32:23 +00:00
2008-05-16 19:51:38 +00:00
m32_showmouse ( ) ;
2007-04-17 05:54:12 +00:00
enddrawing ( ) ;
showframe ( 1 ) ;
return ( 0 ) ;
}
2009-01-09 09:29:17 +00:00
int32_t spriteonceilingz ( int32_t searchwall )
2008-05-16 00:23:33 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t z = sprite [ searchwall ] . z ;
2008-05-16 00:23:33 +00:00
z = getceilzofslope ( searchsector , sprite [ searchwall ] . x , sprite [ searchwall ] . y ) ;
if ( sprite [ searchwall ] . cstat & 128 ) z - = ( ( tilesizy [ sprite [ searchwall ] . picnum ] * sprite [ searchwall ] . yrepeat ) < < 1 ) ;
if ( ( sprite [ searchwall ] . cstat & 48 ) ! = 32 )
z + = ( ( tilesizy [ sprite [ searchwall ] . picnum ] * sprite [ searchwall ] . yrepeat ) < < 2 ) ;
return z ;
}
2009-01-09 09:29:17 +00:00
int32_t spriteongroundz ( int32_t searchwall )
2008-05-16 00:23:33 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t z = sprite [ searchwall ] . z ;
2008-05-16 00:23:33 +00:00
z = getflorzofslope ( searchsector , sprite [ searchwall ] . x , sprite [ searchwall ] . y ) ;
if ( sprite [ searchwall ] . cstat & 128 ) z - = ( ( tilesizy [ sprite [ searchwall ] . picnum ] * sprite [ searchwall ] . yrepeat ) < < 1 ) ;
return z ;
}
2008-05-16 19:51:38 +00:00
# define WIND1X 3
2008-05-17 01:37:17 +00:00
# define WIND1Y 150
2009-01-09 09:29:17 +00:00
void drawtileinfo ( char * title , int32_t x , int32_t y , int32_t picnum , int32_t shade , int32_t pal , int32_t cstat , int32_t lotag , int32_t hitag , int32_t extra )
2008-05-16 19:51:38 +00:00
{
char buf [ 64 ] ;
2009-01-09 09:29:17 +00:00
int32_t i , j ;
int32_t scale = 65536 ;
int32_t x1 ;
2008-05-16 19:51:38 +00:00
j = xdimgame > 640 ? 0 : 1 ;
i = ydimgame > > 6 ;
x1 = x + 80 ;
if ( j ) x1 / = 2 ;
2009-01-09 09:29:17 +00:00
x1 = ( int32_t ) ( x1 * ( 320. / xdimgame ) ) ;
scale = ( int32_t ) ( scale / ( max ( tilesizx [ picnum ] , tilesizy [ picnum ] ) / 24. ) ) ;
2008-05-16 19:51:38 +00:00
rotatesprite ( ( x1 + 13 ) < < 16 , ( y + 11 ) < < 16 , scale , 0 , picnum , shade , pal , 2 , 0L , 0L , xdim - 1L , ydim - 1L ) ;
2009-01-09 09:29:17 +00:00
x = ( int32_t ) ( x * ( xdimgame / 320. ) ) ;
y = ( int32_t ) ( y * ( ydimgame / 200. ) ) ;
2008-05-16 19:51:38 +00:00
begindrawing ( ) ;
printext256 ( x + 2 , y + 2 , 0 , - 1 , title , j ) ;
printext256 ( x , y , 255 - 13 , - 1 , title , j ) ;
Bsprintf ( buf , " Pic:%4d " , picnum ) ;
printext256 ( x + 2 , y + 2 + i * 1 , 0 , - 1 , buf , j ) ;
printext256 ( x , y + i * 1 , whitecol , - 1 , buf , j ) ;
Bsprintf ( buf , " Shd:%4d " , shade ) ;
printext256 ( x + 2 , y + 2 + i * 2 , 0 , - 1 , buf , j ) ;
printext256 ( x , y + i * 2 , whitecol , - 1 , buf , j ) ;
Bsprintf ( buf , " Pal:%4d " , pal ) ;
printext256 ( x + 2 , y + 2 + i * 3 , 0 , - 1 , buf , j ) ;
printext256 ( x , y + i * 3 , whitecol , - 1 , buf , j ) ;
Bsprintf ( buf , " Cst:%4d " , cstat ) ;
printext256 ( x + 2 , y + 2 + i * 4 , 0 , - 1 , buf , j ) ;
printext256 ( x , y + i * 4 , whitecol , - 1 , buf , j ) ;
Bsprintf ( buf , " Lot:%4d " , lotag ) ;
printext256 ( x + 2 , y + 2 + i * 5 , 0 , - 1 , buf , j ) ;
printext256 ( x , y + i * 5 , whitecol , - 1 , buf , j ) ;
Bsprintf ( buf , " Hit:%4d " , hitag ) ;
printext256 ( x + 2 , y + 2 + i * 6 , 0 , - 1 , buf , j ) ;
printext256 ( x , y + i * 6 , whitecol , - 1 , buf , j ) ;
Bsprintf ( buf , " Ext:%4d " , extra ) ;
printext256 ( x + 2 , y + 2 + i * 7 , 0 , - 1 , buf , j ) ;
printext256 ( x , y + i * 7 , whitecol , - 1 , buf , j ) ;
enddrawing ( ) ;
}
2009-01-09 09:29:17 +00:00
int32_t snap = 0 ;
int32_t saveval1 , saveval2 , saveval3 ;
2008-05-16 19:51:38 +00:00
2009-01-09 09:29:17 +00:00
static inline void getnumber_dochar ( char * ptr , int32_t num )
2008-09-03 11:59:54 +00:00
{
* ptr = ( char ) num ;
}
2009-01-09 09:29:17 +00:00
static inline void getnumber_doint16_t ( int16_t * ptr , int32_t num )
2008-09-03 11:59:54 +00:00
{
2009-01-09 09:29:17 +00:00
* ptr = ( int16_t ) num ;
2008-09-03 11:59:54 +00:00
}
2009-01-09 09:29:17 +00:00
static inline void getnumber_doint32 ( int32 * ptr , int32_t num )
2008-09-03 11:59:54 +00:00
{
* ptr = ( int32 ) num ;
}
2009-01-09 09:29:17 +00:00
static inline void getnumber_doint64 ( int64 * ptr , int32_t num )
2008-09-03 11:59:54 +00:00
{
* ptr = ( int64 ) num ;
}
2009-01-09 09:29:17 +00:00
void getnumberptr256 ( char * namestart , void * num , int32_t bytes , int32_t maxnumber , char sign , void * ( func ) ( int32_t ) )
2008-09-03 11:59:54 +00:00
{
char buffer [ 80 ] , ch ;
2009-01-09 09:29:17 +00:00
int32_t n , danum = 0 , oldnum ;
2008-09-03 11:59:54 +00:00
2008-09-03 13:23:34 +00:00
switch ( bytes )
2008-09-03 11:59:54 +00:00
{
case 1 :
danum = * ( char * ) num ;
break ;
case 2 :
2009-01-09 09:29:17 +00:00
danum = * ( int16_t * ) num ;
2008-09-03 11:59:54 +00:00
break ;
case 4 :
danum = * ( int32 * ) num ;
break ;
case 8 :
danum = * ( int64 * ) num ;
break ;
}
oldnum = danum ;
bflushchars ( ) ;
while ( keystatus [ 0x1 ] = = 0 )
{
if ( handleevents ( ) )
{
if ( quitevent ) quitevent = 0 ;
}
2009-01-13 12:23:18 +00:00
drawrooms ( pos . x , pos . y , pos . z , ang , horiz , cursectnum ) ;
2008-09-03 11:59:54 +00:00
# ifdef SUPERBUILD
ExtAnalyzeSprites ( ) ;
# endif
drawmasks ( ) ;
ch = bgetchar ( ) ;
if ( keystatus [ 0x1 ] ) break ;
clearkeys ( ) ;
2008-09-03 14:02:42 +00:00
mouseb = 0 ;
searchx = osearchx ;
searchy = osearchy ;
2008-09-03 11:59:54 +00:00
ExtCheckKeys ( ) ;
2008-09-06 06:22:31 +00:00
Bsprintf ( buffer , " %s%d " , namestart , danum ) ;
2008-09-03 11:59:54 +00:00
if ( totalclock & 32 ) Bstrcat ( buffer , " _ " ) ;
2008-09-03 14:02:42 +00:00
printmessage256 ( 0 , 0 , buffer ) ;
2008-09-06 06:22:31 +00:00
if ( func ! = NULL )
{
2009-01-09 09:29:17 +00:00
Bsprintf ( buffer , " %s " , ( char * ) func ( ( int32_t ) danum ) ) ;
2008-09-06 06:22:31 +00:00
printmessage256 ( 0 , 9 , buffer ) ;
}
2008-09-03 11:59:54 +00:00
showframe ( 1 ) ;
if ( ch > = ' 0 ' & & ch < = ' 9 ' )
{
if ( danum > = 0 )
{
n = ( danum * 10 ) + ( ch - ' 0 ' ) ;
if ( n < = maxnumber ) danum = n ;
}
else if ( sign )
{
n = ( danum * 10 ) - ( ch - ' 0 ' ) ;
if ( n > = - maxnumber ) danum = n ;
}
}
else if ( ch = = 8 | | ch = = 127 ) // backspace
{
danum / = 10 ;
}
else if ( ch = = 13 )
{
oldnum = danum ;
asksave = 1 ;
break ;
}
else if ( ch = = ' - ' & & sign ) // negate
{
danum = - danum ;
}
2008-09-03 13:23:34 +00:00
switch ( bytes )
2008-09-03 11:59:54 +00:00
{
case 1 :
getnumber_dochar ( num , danum ) ;
break ;
case 2 :
2009-01-09 09:29:17 +00:00
getnumber_doint16_t ( num , danum ) ;
2008-09-03 11:59:54 +00:00
break ;
case 4 :
getnumber_doint32 ( num , danum ) ;
break ;
case 8 :
getnumber_doint64 ( num , danum ) ;
break ;
}
}
clearkeys ( ) ;
lockclock = totalclock ; //Reset timing
2008-09-03 13:23:34 +00:00
switch ( bytes )
2008-09-03 11:59:54 +00:00
{
case 1 :
getnumber_dochar ( num , oldnum ) ;
break ;
case 2 :
2009-01-09 09:29:17 +00:00
getnumber_doint16_t ( num , oldnum ) ;
2008-09-03 11:59:54 +00:00
break ;
case 4 :
getnumber_doint32 ( num , oldnum ) ;
break ;
case 8 :
getnumber_doint64 ( num , oldnum ) ;
break ;
}
}
2009-01-09 09:29:17 +00:00
static void DoSpriteOrnament ( int32_t i )
2008-09-06 06:22:31 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t j ;
2009-01-13 12:23:18 +00:00
hitdata_t hitinfo ;
2008-09-06 06:22:31 +00:00
2009-01-13 12:23:18 +00:00
hitscan ( ( const vec3_t * ) & sprite [ i ] , sprite [ i ] . sectnum ,
2008-09-11 09:24:45 +00:00
sintable [ ( sprite [ i ] . ang + 2560 + 1024 ) & 2047 ] ,
sintable [ ( sprite [ i ] . ang + 2048 + 1024 ) & 2047 ] ,
0 ,
2009-01-13 12:23:18 +00:00
& hitinfo , CLIPMASK1 ) ;
2008-09-06 06:22:31 +00:00
2009-01-13 12:23:18 +00:00
sprite [ i ] . x = hitinfo . pos . x ;
sprite [ i ] . y = hitinfo . pos . y ;
sprite [ i ] . z = hitinfo . pos . z ;
changespritesect ( i , hitinfo . hitsect ) ;
if ( hitinfo . hitwall > = 0 )
sprite [ i ] . ang = ( ( getangle ( wall [ wall [ hitinfo . hitwall ] . point2 ] . x - wall [ hitinfo . hitwall ] . x ,
wall [ wall [ hitinfo . hitwall ] . point2 ] . y - wall [ hitinfo . hitwall ] . y ) + 512 ) & 2047 ) ;
2008-09-06 06:22:31 +00:00
//Make sure sprite's in right sector
if ( inside ( sprite [ i ] . x , sprite [ i ] . y , sprite [ i ] . sectnum ) = = 0 )
{
2009-01-13 12:23:18 +00:00
j = wall [ hitinfo . hitwall ] . point2 ;
sprite [ i ] . x - = ksgn ( wall [ j ] . y - wall [ hitinfo . hitwall ] . y ) ;
sprite [ i ] . y + = ksgn ( wall [ j ] . x - wall [ hitinfo . hitwall ] . x ) ;
2008-09-06 06:22:31 +00:00
}
}
2008-09-05 23:09:43 +00:00
int64 ldistsqr ( spritetype * s1 , spritetype * s2 )
{
2008-09-06 06:22:31 +00:00
return ( ( ( int64 ) ( s2 - > x - s1 - > x ) ) * ( ( int64 ) ( s2 - > x - s1 - > x ) ) +
( ( int64 ) ( s2 - > y - s1 - > y ) ) * ( ( int64 ) ( s2 - > y - s1 - > y ) ) ) ;
2008-09-05 23:09:43 +00:00
}
2009-01-09 09:29:17 +00:00
void rendertext ( int16_t startspr )
2008-09-05 23:09:43 +00:00
{
2008-09-14 14:47:32 +00:00
char ch , buffer [ 80 ] , doingspace = 0 ;
2009-01-09 09:29:17 +00:00
int16_t daang = 0 , t , alphidx , basetile , linebegspr , curspr , cursor ;
int32_t i , j , k , dax = 0 , day = 0 ;
static uint8_t hgap = 0 , vgap = 4 ;
static uint8_t spcgap [ MAX_ALPHABETS ] , firstrun = 1 ;
2008-09-06 06:22:31 +00:00
spritetype * sp ;
2009-01-09 09:29:17 +00:00
int16_t * spritenums ;
int32_t stackallocsize = 32 , numletters = 0 ;
2008-09-11 21:22:58 +00:00
if ( firstrun )
{
firstrun = 0 ;
for ( i = 0 ; i < numalphabets ; i + + )
spcgap [ i ] = 0 ;
}
2008-09-06 06:22:31 +00:00
if ( startspr < 0 | | startspr > = MAXSPRITES | |
sprite [ startspr ] . statnum = = MAXSTATUS )
return ;
2008-09-11 21:22:58 +00:00
if ( numalphabets = = 0 )
{
message ( " Alphabet configuration not read. " ) ;
return ;
}
2008-09-06 06:22:31 +00:00
if ( ( sprite [ startspr ] . cstat & 16 ) = = 0 )
{
message ( " Must point at a wall-aligned text sprite. " ) ;
return ;
}
t = sprite [ startspr ] . picnum ;
2008-09-11 21:22:58 +00:00
alphidx = - 1 ;
for ( i = 0 ; i < numalphabets ; i + + )
2008-09-06 06:22:31 +00:00
{
2008-09-11 21:22:58 +00:00
for ( j = 0 ; j < NUMPRINTABLES ; j + + )
if ( alphabets [ i ] . pic [ j ] = = t )
{
alphidx = i ;
basetile = t ;
if ( spcgap [ i ] = = 0 )
spcgap [ i ] = 3 * tilesizx [ t ] / 2 ;
2008-09-14 14:47:32 +00:00
goto ENDFOR1 ;
2008-09-11 21:22:58 +00:00
}
2008-09-06 06:22:31 +00:00
}
2008-09-14 14:47:32 +00:00
ENDFOR1 :
2008-09-11 21:22:58 +00:00
if ( alphidx = = - 1 )
2008-09-06 06:22:31 +00:00
{
message ( " Must point at a text sprite. " ) ;
return ;
}
curspr = linebegspr = startspr ;
2008-09-11 21:22:58 +00:00
t = sprite [ startspr ] . picnum ;
sprite [ startspr ] . xoffset = - ( ( ( picanm [ t ] ) > > 8 ) & 255 ) ;
sprite [ startspr ] . yoffset = - ( ( ( picanm [ t ] ) > > 16 ) & 255 ) ;
2008-09-05 23:09:43 +00:00
2009-01-09 09:29:17 +00:00
spritenums = Bmalloc ( stackallocsize * sizeof ( int16_t ) ) ;
2008-09-17 22:58:25 +00:00
if ( ! spritenums ) goto ERROR_NOMEMORY ;
2008-09-14 14:47:32 +00:00
2008-10-09 21:09:16 +00:00
cursor = insertsprite ( sprite [ startspr ] . sectnum , 0 ) ;
if ( cursor < 0 ) goto ERROR_TOOMANYSPRITES ;
2008-10-12 19:16:09 +00:00
updatenumsprites ( ) ;
2008-10-09 21:09:16 +00:00
sp = & sprite [ cursor ] ;
Bmemcpy ( sp , & sprite [ startspr ] , sizeof ( spritetype ) ) ;
sp - > yoffset = 0 ;
sp - > picnum = SMALLFNTCURSOR ;
sp - > xrepeat = min ( max ( sp - > xrepeat / tilesizx [ sp - > picnum ] , 2 ) , 255 ) ;
sp - > yrepeat = min ( max ( ( sp - > yrepeat * tilesizy [ sprite [ startspr ] . picnum ] ) / tilesizy [ sp - > picnum ] , 4 ) , 255 ) ;
sp - > pal = 0 ;
sp - > cstat = 18 ;
2008-09-05 23:09:43 +00:00
bflushchars ( ) ;
while ( keystatus [ 0x1 ] = = 0 )
{
if ( handleevents ( ) )
{
if ( quitevent ) quitevent = 0 ;
}
2008-09-11 09:24:45 +00:00
if ( keystatus [ KEYSC_UP ] ) // vertical gap in pixels (32 x-units)
2008-09-06 06:22:31 +00:00
{
keystatus [ KEYSC_UP ] = 0 ;
if ( vgap < 255 ) vgap + + ;
}
if ( keystatus [ KEYSC_DOWN ] )
{
keystatus [ KEYSC_DOWN ] = 0 ;
if ( vgap > 0 ) vgap - - ;
}
2008-09-11 09:24:45 +00:00
if ( keystatus [ KEYSC_RIGHT ] ) // horizontal gap in half pixels
2008-09-06 06:22:31 +00:00
{
keystatus [ KEYSC_RIGHT ] = 0 ;
if ( hgap < 255 ) hgap + + ;
}
if ( keystatus [ KEYSC_LEFT ] )
{
keystatus [ KEYSC_LEFT ] = 0 ;
if ( hgap > 0 ) hgap - - ;
}
2008-09-11 09:24:45 +00:00
if ( keystatus [ KEYSC_INSERT ] ) // space gap in half pixels
2008-09-06 06:22:31 +00:00
{
keystatus [ KEYSC_INSERT ] = 0 ;
2008-09-11 21:22:58 +00:00
if ( spcgap [ alphidx ] < 255 ) spcgap [ alphidx ] + + ;
2008-09-06 06:22:31 +00:00
}
if ( keystatus [ KEYSC_DELETE ] )
{
keystatus [ KEYSC_DELETE ] = 0 ;
2008-09-11 21:22:58 +00:00
if ( spcgap [ alphidx ] > 1 ) spcgap [ alphidx ] - - ;
2008-09-06 06:22:31 +00:00
}
if ( keystatus [ KEYSC_HOME ] ) // shade
{
keystatus [ KEYSC_HOME ] = 0 ;
2008-10-09 21:09:16 +00:00
if ( sprite [ linebegspr ] . shade < 127 ) sprite [ linebegspr ] . shade + + ;
2008-09-06 06:22:31 +00:00
}
if ( keystatus [ KEYSC_END ] )
{
keystatus [ KEYSC_END ] = 0 ;
2008-10-09 21:09:16 +00:00
if ( sprite [ linebegspr ] . shade > - 128 ) sprite [ linebegspr ] . shade - - ;
2008-09-06 06:22:31 +00:00
}
if ( keystatus [ KEYSC_PGUP ] ) // pal
{
keystatus [ KEYSC_PGUP ] = 0 ;
2008-10-09 21:09:16 +00:00
if ( sprite [ linebegspr ] . pal < 255 ) sprite [ linebegspr ] . pal + + ;
2008-09-06 06:22:31 +00:00
}
if ( keystatus [ KEYSC_PGDN ] )
{
keystatus [ KEYSC_PGDN ] = 0 ;
2008-10-09 21:09:16 +00:00
if ( sprite [ linebegspr ] . pal > 0 ) sprite [ linebegspr ] . pal - - ;
2008-09-06 06:22:31 +00:00
}
2008-09-05 23:09:43 +00:00
2009-01-13 12:23:18 +00:00
drawrooms ( pos . x , pos . y , pos . z , ang , horiz , cursectnum ) ;
2008-09-05 23:09:43 +00:00
# ifdef SUPERBUILD
ExtAnalyzeSprites ( ) ;
# endif
drawmasks ( ) ;
ch = bgetchar ( ) ;
if ( keystatus [ 0x1 ] ) break ;
clearkeys ( ) ;
mouseb = 0 ;
searchx = osearchx ;
searchy = osearchy ;
ExtCheckKeys ( ) ;
2008-09-06 06:22:31 +00:00
printmessage256 ( 0 , 0 , " ^251Text entry mode.^31 Navigation keys change vars. " ) ;
Bsprintf ( buffer , " Hgap=%d, Vgap=%d, SPCgap=%d, Shd=%d, Pal=%d " ,
2008-10-09 21:09:16 +00:00
hgap , vgap , spcgap [ alphidx ] , sprite [ linebegspr ] . shade , sprite [ linebegspr ] . pal ) ;
2008-09-05 23:09:43 +00:00
printmessage256 ( 0 , 9 , buffer ) ;
showframe ( 1 ) ;
// ---
2008-09-06 06:22:31 +00:00
sp = & sprite [ curspr ] ;
2008-09-14 14:47:32 +00:00
if ( ! doingspace )
{
dax = sp - > x ; day = sp - > y ;
daang = sp - > ang ;
}
2008-10-13 01:16:40 +00:00
2008-10-09 21:09:16 +00:00
j = sp - > xrepeat * ( hgap + tilesizx [ sp - > picnum ] + 2 ) ;
2009-01-13 12:23:18 +00:00
{
vec3_t vect ;
vect . x = dax + ( ( j * sintable [ daang ] ) > > 17 ) ;
vect . y = day - ( ( j * sintable [ ( daang + 512 ) & 2047 ] ) > > 17 ) ;
vect . z = sp - > z ;
setsprite ( cursor , & vect ) ;
}
2008-09-06 06:22:31 +00:00
2008-09-11 21:22:58 +00:00
if ( ch > = 33 & & ch < = 126 & & alphabets [ alphidx ] . pic [ ch - 33 ] > = 0 )
2008-09-05 23:09:43 +00:00
{
2009-01-09 09:29:17 +00:00
int16_t sect ;
2008-09-06 06:22:31 +00:00
// mapping char->tilenum
2008-09-11 21:22:58 +00:00
t = alphabets [ alphidx ] . pic [ ch - 33 ] ;
2008-09-14 14:47:32 +00:00
j = sp - > xrepeat * ( hgap + tilesizx [ sp - > picnum ] + tilesizx [ t ] ) ;
2008-09-06 06:22:31 +00:00
2008-09-14 14:47:32 +00:00
dax + = ( j * sintable [ daang ] ) > > 17 ;
day - = ( j * sintable [ ( daang + 512 ) & 2047 ] ) > > 17 ;
dax + = ( j * sintable [ ( sprite [ curspr ] . ang + 2560 ) & 2047 ] ) > > 17 ;
day + = ( j * sintable [ ( sprite [ curspr ] . ang + 2048 ) & 2047 ] ) > > 17 ;
2008-09-06 06:22:31 +00:00
2008-09-14 14:47:32 +00:00
sect = sprite [ curspr ] . sectnum ;
2008-09-06 06:22:31 +00:00
updatesector ( dax , day , & sect ) ;
if ( numsprites < MAXSPRITES & & sect > = 0 )
{
2008-09-14 14:47:32 +00:00
i = insertsprite ( sect , 0 ) ;
2008-10-09 21:09:16 +00:00
Bmemcpy ( & sprite [ i ] , & sprite [ linebegspr ] , sizeof ( spritetype ) ) ;
2008-09-05 23:09:43 +00:00
sprite [ i ] . x = dax , sprite [ i ] . y = day ;
2008-09-06 06:22:31 +00:00
sprite [ i ] . picnum = t ;
2008-09-05 23:09:43 +00:00
sprite [ i ] . ang = daang ;
2008-09-06 06:22:31 +00:00
sprite [ i ] . xoffset = - ( ( ( picanm [ sprite [ i ] . picnum ] ) > > 8 ) & 255 ) ;
sprite [ i ] . yoffset = - ( ( ( picanm [ sprite [ i ] . picnum ] ) > > 16 ) & 255 ) ;
2009-01-09 09:29:17 +00:00
sprite [ i ] . xoffset + = alphabets [ alphidx ] . xofs [ ( int32_t ) ch - 33 ] ;
sprite [ i ] . yoffset + = alphabets [ alphidx ] . yofs [ ( int32_t ) ch - 33 ] ;
2008-09-06 06:22:31 +00:00
DoSpriteOrnament ( i ) ;
2008-09-05 23:09:43 +00:00
2009-02-19 16:47:54 +00:00
for ( k = 0 ; k < MAXTILES ; k + + )
2008-09-05 23:09:43 +00:00
localartfreq [ k ] = 0 ;
2009-02-19 16:47:54 +00:00
for ( k = 0 ; k < MAXSPRITES ; k + + )
2008-09-05 23:09:43 +00:00
if ( sprite [ k ] . statnum < MAXSTATUS )
localartfreq [ sprite [ k ] . picnum ] + + ;
2008-09-06 06:22:31 +00:00
curspr = i ;
2008-09-14 14:47:32 +00:00
doingspace = 0 ;
2008-09-05 23:09:43 +00:00
updatenumsprites ( ) ;
asksave = 1 ;
2008-09-14 14:47:32 +00:00
if ( numletters > = stackallocsize )
{
stackallocsize * = 2 ;
2009-01-09 09:29:17 +00:00
spritenums = Brealloc ( spritenums , stackallocsize * sizeof ( int16_t ) ) ;
2008-09-17 22:58:25 +00:00
if ( ! spritenums ) goto ERROR_NOMEMORY ;
2008-09-14 14:47:32 +00:00
}
spritenums [ numletters + + ] = i ;
2008-09-06 06:22:31 +00:00
}
2008-09-05 23:09:43 +00:00
}
2008-09-06 06:22:31 +00:00
else if ( ch = = 32 )
{
2008-09-11 21:22:58 +00:00
dax + = ( ( sp - > xrepeat * spcgap [ alphidx ] * sintable [ daang ] ) > > 17 ) ;
day - = ( ( sp - > xrepeat * spcgap [ alphidx ] * sintable [ ( daang + 512 ) & 2047 ] ) > > 17 ) ;
2008-09-14 14:47:32 +00:00
doingspace = 1 ;
2008-09-06 06:22:31 +00:00
}
2008-10-09 21:09:16 +00:00
else if ( ch = = 8 ) // backspace
2008-09-05 23:09:43 +00:00
{
2008-10-09 21:09:16 +00:00
if ( doingspace )
doingspace = 0 ;
else if ( numletters > 0 )
2008-09-06 06:22:31 +00:00
{
2009-01-09 09:29:17 +00:00
int16_t last = spritenums [ numletters - 1 ] ;
2008-10-09 21:09:16 +00:00
if ( sprite [ last ] . z ! = sprite [ linebegspr ] . z ) // only "delete" line break
{
sprite [ linebegspr ] . z = sprite [ last ] . z ;
curspr = last ;
}
else if ( numletters > 1 )
{
2009-01-09 09:29:17 +00:00
int16_t sectolast = spritenums [ numletters - 2 ] ;
2008-10-09 21:09:16 +00:00
if ( sprite [ last ] . z = = sprite [ sectolast ] . z )
curspr = sectolast ;
else // if we delete the first letter on the line
curspr = linebegspr ;
numletters - - ;
deletesprite ( last ) ;
2008-09-06 06:22:31 +00:00
2008-10-13 01:16:40 +00:00
updatenumsprites ( ) ;
2008-10-09 21:09:16 +00:00
asksave = 1 ;
}
2008-09-14 14:47:32 +00:00
else
2008-10-09 21:09:16 +00:00
{
numletters - - ;
deletesprite ( last ) ;
2008-09-14 14:47:32 +00:00
curspr = linebegspr ;
2008-10-09 21:09:16 +00:00
updatenumsprites ( ) ;
asksave = 1 ;
}
}
else
{
sprite [ linebegspr ] . z - = ( ( sprite [ linebegspr ] . yrepeat * ( vgap + tilesizy [ basetile ] ) ) < < 2 ) ;
2008-09-14 14:47:32 +00:00
asksave = 1 ;
2008-09-06 06:22:31 +00:00
}
2008-09-05 23:09:43 +00:00
}
else if ( ch = = 13 ) // enter
{
2008-09-06 06:22:31 +00:00
sprite [ linebegspr ] . z + = ( ( sprite [ linebegspr ] . yrepeat * ( vgap + tilesizy [ basetile ] ) ) < < 2 ) ;
curspr = linebegspr ;
2008-09-14 14:47:32 +00:00
doingspace = 0 ;
2008-09-05 23:09:43 +00:00
asksave = 1 ;
}
}
2008-10-09 21:09:16 +00:00
ERROR_TOOMANYSPRITES :
if ( cursor < 0 ) message ( " Too many sprites in map! " ) ;
else deletesprite ( cursor ) ;
2008-10-19 15:27:12 +00:00
updatenumsprites ( ) ;
2008-10-09 21:09:16 +00:00
2008-09-17 22:58:25 +00:00
ERROR_NOMEMORY :
2008-09-14 14:47:32 +00:00
if ( spritenums ) Bfree ( spritenums ) ;
else message ( " Out of memory! " ) ;
2008-09-05 23:09:43 +00:00
clearkeys ( ) ;
lockclock = totalclock ; //Reset timing
}
2006-12-10 06:49:01 +00:00
static void Keys3d ( void )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , count , nexti , changedir ;
int32_t j , k , tempint = 0 , hiz , loz ;
int32_t hihit , lohit ;
2006-04-22 22:33:52 +00:00
char smooshyalign = 0 , repeatpanalign = 0 , buffer [ 80 ] ;
2009-01-09 09:29:17 +00:00
int16_t startwall , endwall , dasector , statnum = 0 ;
2008-09-03 10:47:19 +00:00
char tempbuf [ 128 ] ;
2006-04-13 20:47:06 +00:00
/* start Mapster32 */
2008-08-28 11:52:28 +00:00
/*
2006-04-13 20:47:06 +00:00
if ( sidemode ! = 0 )
{
setviewback ( ) ;
rotatesprite ( 320 < < 15 , 200 < < 15 , 65536 , ( horiz - 100 ) < < 2 , 4094 , 0 , 0 , 2 + 4 , 0 , 0 , 0 , 0 ) ;
lockbyte4094 = 0 ;
searchx = ydim - 1 - searchx ;
2006-11-15 01:16:55 +00:00
searchx ^ = searchy ;
searchy ^ = searchx ;
searchx ^ = searchy ;
2006-04-13 20:47:06 +00:00
// overwritesprite(160L,170L,1153,0,1+2,0);
rotatesprite ( 160 < < 16 , 170 < < 16 , 65536 , ( 100 - horiz + 1024 ) < < 3 , 1153 , 0 , 0 , 2 , 0 , 0 , 0 , 0 ) ;
}
2008-09-01 21:59:53 +00:00
*/
2008-08-28 15:04:16 +00:00
if ( usedcount & & ! helpon )
{
if ( searchstat ! = 3 )
{
count = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numwalls ; i + + )
2008-08-28 15:04:16 +00:00
{
if ( wall [ i ] . picnum = = temppicnum ) count + + ;
if ( wall [ i ] . overpicnum = = temppicnum ) count + + ;
}
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2008-08-28 15:04:16 +00:00
{
if ( sector [ i ] . ceilingpicnum = = temppicnum ) count + + ;
if ( sector [ i ] . floorpicnum = = temppicnum ) count + + ;
}
}
if ( searchstat = = 3 )
{
count = 0 ;
statnum = 0 ;
i = headspritestat [ statnum ] ;
while ( i ! = - 1 )
{
nexti = nextspritestat [ i ] ;
if ( sprite [ i ] . picnum = = temppicnum ) count + + ;
i = nexti ;
}
}
drawtileinfo ( " Clipboard " , 3 , 124 , temppicnum , tempshade , temppal , tempcstat , templotag , temphitag , tempextra ) ;
} // end if usedcount
// if (infobox&1)
{
char lines [ 8 ] [ 64 ] ;
2009-01-09 09:29:17 +00:00
int32_t dax , day , dist , height1 = 0 , height2 = 0 , height3 = 0 , num = 0 ;
int32_t x , y ;
2008-08-28 15:04:16 +00:00
if ( infobox & 1 )
{
height2 = sector [ searchsector ] . floorz - sector [ searchsector ] . ceilingz ;
switch ( searchstat )
{
case 0 :
case 4 :
drawtileinfo ( " Current " , WIND1X , WIND1Y , wall [ searchwall ] . picnum , wall [ searchwall ] . shade ,
wall [ searchwall ] . pal , wall [ searchwall ] . cstat , wall [ searchwall ] . lotag ,
wall [ searchwall ] . hitag , wall [ searchwall ] . extra ) ;
dax = wall [ searchwall ] . x - wall [ wall [ searchwall ] . point2 ] . x ;
day = wall [ searchwall ] . y - wall [ wall [ searchwall ] . point2 ] . y ;
dist = ksqrt ( dax * dax + day * day ) ;
if ( wall [ searchwall ] . nextsector ! = - 1 )
{
2009-01-09 09:29:17 +00:00
int32_t nextsect = wall [ searchwall ] . nextsector ;
2008-08-28 15:04:16 +00:00
height1 = sector [ searchsector ] . floorz - sector [ nextsect ] . floorz ;
height2 = sector [ nextsect ] . floorz - sector [ nextsect ] . ceilingz ;
height3 = sector [ nextsect ] . ceilingz - sector [ searchsector ] . ceilingz ;
}
Bsprintf ( lines [ num + + ] , " Panning: %d, %d " , wall [ searchwall ] . xpanning , wall [ searchwall ] . ypanning ) ;
Bsprintf ( lines [ num + + ] , " Repeat: %d, %d " , wall [ searchwall ] . xrepeat , wall [ searchwall ] . yrepeat ) ;
Bsprintf ( lines [ num + + ] , " Overpic: %d " , wall [ searchwall ] . overpicnum ) ;
lines [ num + + ] [ 0 ] = 0 ;
if ( getmessageleng )
break ;
Bsprintf ( lines [ num + + ] , " ^251Wall %d^31 " , searchwall ) ;
if ( wall [ searchwall ] . nextsector ! = - 1 )
Bsprintf ( lines [ num + + ] , " LoHeight:%d, HiHeight:%d, Length:%d " , height1 , height3 , dist ) ;
else
Bsprintf ( lines [ num + + ] , " Height:%d, Length:%d " , height2 , dist ) ;
break ;
case 1 :
drawtileinfo ( " Current " , WIND1X , WIND1Y , sector [ searchsector ] . ceilingpicnum , sector [ searchsector ] . ceilingshade ,
sector [ searchsector ] . ceilingpal , sector [ searchsector ] . ceilingstat ,
sector [ searchsector ] . lotag , sector [ searchsector ] . hitag , sector [ searchsector ] . extra ) ;
Bsprintf ( lines [ num + + ] , " Panning: %d, %d " , sector [ searchsector ] . ceilingxpanning , sector [ searchsector ] . ceilingypanning ) ;
Bsprintf ( lines [ num + + ] , " CeilingZ: %d " , sector [ searchsector ] . ceilingz ) ;
Bsprintf ( lines [ num + + ] , " Slope: %d " , sector [ searchsector ] . ceilingheinum ) ;
lines [ num + + ] [ 0 ] = 0 ;
if ( getmessageleng )
break ;
2008-09-03 17:55:11 +00:00
Bsprintf ( lines [ num + + ] , " ^251Sector %d^31 ceiling, Lotag:%s " , searchsector , ExtGetSectorCaption ( searchsector ) ) ;
2008-08-28 15:04:16 +00:00
Bsprintf ( lines [ num + + ] , " Height: %d, Visibility:%d " , height2 , sector [ searchsector ] . visibility ) ;
break ;
case 2 :
drawtileinfo ( " Current " , WIND1X , WIND1Y , sector [ searchsector ] . floorpicnum , sector [ searchsector ] . floorshade ,
sector [ searchsector ] . floorpal , sector [ searchsector ] . floorstat ,
sector [ searchsector ] . lotag , sector [ searchsector ] . hitag , sector [ searchsector ] . extra ) ;
Bsprintf ( lines [ num + + ] , " Panning: %d,%d " , sector [ searchsector ] . floorxpanning , sector [ searchsector ] . floorypanning ) ;
Bsprintf ( lines [ num + + ] , " FloorZ: %d " , sector [ searchsector ] . floorz ) ;
Bsprintf ( lines [ num + + ] , " Slope: %d " , sector [ searchsector ] . floorheinum ) ;
lines [ num + + ] [ 0 ] = 0 ;
if ( getmessageleng )
break ;
2008-09-03 17:55:11 +00:00
Bsprintf ( lines [ num + + ] , " ^251Sector %d^31 floor, Lotag:%s " , searchsector , ExtGetSectorCaption ( searchsector ) ) ;
2008-08-28 15:04:16 +00:00
Bsprintf ( lines [ num + + ] , " Height:%d, Visibility:%d " , height2 , sector [ searchsector ] . visibility ) ;
break ;
case 3 :
drawtileinfo ( " Current " , WIND1X , WIND1Y , sprite [ searchwall ] . picnum , sprite [ searchwall ] . shade ,
sprite [ searchwall ] . pal , sprite [ searchwall ] . cstat , sprite [ searchwall ] . lotag ,
sprite [ searchwall ] . hitag , sprite [ searchwall ] . extra ) ;
Bsprintf ( lines [ num + + ] , " Repeat: %d,%d " , sprite [ searchwall ] . xrepeat , sprite [ searchwall ] . yrepeat ) ;
Bsprintf ( lines [ num + + ] , " PosXY: %d,%d " , sprite [ searchwall ] . x , sprite [ searchwall ] . y ) ;
Bsprintf ( lines [ num + + ] , " PosZ: " " %d " , sprite [ searchwall ] . z ) ; // prevents tab character
lines [ num + + ] [ 0 ] = 0 ;
if ( getmessageleng )
break ;
if ( strlen ( names [ sprite [ searchwall ] . picnum ] ) > 0 )
{
if ( sprite [ searchwall ] . picnum = = SECTOREFFECTOR )
Bsprintf ( lines [ num + + ] , " ^251Sprite %d^31 %s " , searchwall , SectorEffectorText ( searchwall ) ) ;
else Bsprintf ( lines [ num + + ] , " ^251Sprite %d^31 %s " , searchwall , names [ sprite [ searchwall ] . picnum ] ) ;
}
else Bsprintf ( lines [ num + + ] , " ^251Sprite %d^31, picnum %d " , searchwall , sprite [ searchwall ] . picnum ) ;
Bsprintf ( lines [ num + + ] , " Elevation:%d " , getflorzofslope ( searchsector , sprite [ searchwall ] . x , sprite [ searchwall ] . y ) - sprite [ searchwall ] . z ) ;
break ;
}
}
2009-02-19 16:47:54 +00:00
x = WIND1X ; y = WIND1Y ;
2009-01-09 09:29:17 +00:00
x = ( int32_t ) ( x * ( xdimgame / 320. ) ) ;
y = ( int32_t ) ( y * ( ydimgame / 200. ) ) ;
2008-08-28 15:04:16 +00:00
y + = ( ydimgame > > 6 ) * 8 ;
if ( getmessageleng )
{
while ( num < 4 )
lines [ num + + ] [ 0 ] = 0 ;
Bsprintf ( lines [ num + + ] , " ^251%s " , getmessage ) ;
}
begindrawing ( ) ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < num ; i + + )
2008-08-28 15:04:16 +00:00
{
printext256 ( x + 2 , y + 2 , 0 , - 1 , lines [ i ] , xdimgame > 640 ? 0 : 1 ) ;
printext256 ( x , y , whitecol , - 1 , lines [ i ] , xdimgame > 640 ? 0 : 1 ) ;
y + = ydimgame > > 6 ;
}
enddrawing ( ) ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_V ] ) // ' V
2007-04-23 23:36:21 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_V ] = 0 ;
2007-04-23 23:36:21 +00:00
switch ( searchstat )
{
case 1 :
case 2 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Sector visibility: " , & sector [ searchsector ] . visibility , sizeof ( sector [ searchsector ] . visibility ) , 256L , 0 , NULL ) ;
2007-04-23 23:36:21 +00:00
break ;
}
}
if ( keystatus [ KEYSC_SEMI ] & & keystatus [ KEYSC_V ] ) // ; V
{
2009-01-09 09:29:17 +00:00
int16_t currsector ;
uint8_t visval ;
2007-04-23 23:36:21 +00:00
keystatus [ KEYSC_V ] = 0 ;
if ( highlightsectorcnt = = - 1 )
{
message ( " You didn't select any sectors! " ) ;
return ;
}
2009-01-09 09:29:17 +00:00
visval = ( uint8_t ) getnumber256 ( " Visibility of selected sectors: " , sector [ searchsector ] . visibility , 256L , 0 ) ;
2008-05-16 19:51:38 +00:00
if ( AskIfSure ( 0 ) ) return ;
2007-04-23 23:36:21 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
{
currsector = highlightsector [ i ] ;
sector [ currsector ] . visibility = visval ;
}
message ( " Visibility changed on all selected sectors " ) ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_V ] ) //V
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t oldtile ;
2007-12-12 17:42:14 +00:00
if ( searchstat = = 0 ) tempint = wall [ searchwall ] . picnum ;
if ( searchstat = = 1 ) tempint = sector [ searchsector ] . ceilingpicnum ;
if ( searchstat = = 2 ) tempint = sector [ searchsector ] . floorpicnum ;
if ( searchstat = = 3 ) tempint = sprite [ searchwall ] . picnum ;
if ( searchstat = = 4 ) tempint = wall [ searchwall ] . overpicnum ;
2008-05-16 19:51:38 +00:00
oldtile = tempint ;
2007-12-12 17:42:14 +00:00
tempint = m32gettile ( tempint ) ;
if ( searchstat = = 0 ) wall [ searchwall ] . picnum = tempint ;
if ( searchstat = = 1 ) sector [ searchsector ] . ceilingpicnum = tempint ;
if ( searchstat = = 2 ) sector [ searchsector ] . floorpicnum = tempint ;
if ( searchstat = = 3 ) sprite [ searchwall ] . picnum = tempint ;
2007-04-17 05:54:12 +00:00
if ( searchstat = = 4 )
{
2007-12-12 17:42:14 +00:00
wall [ searchwall ] . overpicnum = tempint ;
2007-04-17 05:54:12 +00:00
if ( wall [ searchwall ] . nextwall > = 0 )
2007-12-12 17:42:14 +00:00
wall [ wall [ searchwall ] . nextwall ] . overpicnum = tempint ;
2007-04-17 05:54:12 +00:00
}
2008-05-16 19:51:38 +00:00
if ( oldtile ! = tempint ) asksave = 1 ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_V ] = 0 ;
2007-04-17 05:54:12 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_3 ] ) /* 3 (toggle floor-over-floor (cduke3d only) */
2006-04-13 20:47:06 +00:00
{
floor_over_floor = ! floor_over_floor ;
2006-08-28 19:18:05 +00:00
// if (!floor_over_floor) ResetFOFSize();
2008-06-09 23:41:54 +00:00
message ( " Floor-over-floor display %s " , floor_over_floor ? " enabled " : " disabled " ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_3 ] = 0 ;
2006-04-13 20:47:06 +00:00
}
if ( keystatus [ KEYSC_F3 ] )
{
mlook = 1 - mlook ;
2008-06-09 23:41:54 +00:00
message ( " Mouselook: %s " , mlook ? " enabled " : " disabled " ) ;
2006-04-13 20:47:06 +00:00
keystatus [ KEYSC_F3 ] = 0 ;
}
2008-05-15 03:16:38 +00:00
// PK
if ( keystatus [ KEYSC_F5 ] )
{
unrealedlook = 1 - unrealedlook ;
2008-06-09 23:41:54 +00:00
message ( " UnrealEd mouse navigation: %s " , unrealedlook ? " enabled " : " disabled " ) ;
2008-05-15 03:16:38 +00:00
keystatus [ KEYSC_F5 ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_BS ] ) // ' del
2006-08-10 02:10:24 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_BS ] = 0 ;
2006-08-10 02:10:24 +00:00
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
case 4 :
wall [ searchwall ] . cstat = 0 ;
2008-06-09 23:41:54 +00:00
message ( " Wall %d cstat = 0 " , searchwall ) ;
2006-11-16 03:02:42 +00:00
break ;
// case 1: case 2: sector[searchsector].cstat = 0; break;
case 3 :
sprite [ searchwall ] . cstat = 0 ;
2008-06-09 23:41:54 +00:00
message ( " Sprite %d cstat = 0 " , searchwall ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-08-10 02:10:24 +00:00
}
}
2006-04-13 20:47:06 +00:00
// 'P - Will copy palette to all sectors highlighted with R-Alt key
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_P ] ) // ' P
{
2009-01-09 09:29:17 +00:00
int16_t w , start_wall , end_wall , currsector ;
int8_t pal [ 4 ] ;
2006-04-13 20:47:06 +00:00
keystatus [ KEYSC_P ] = 0 ;
2006-11-13 23:12:47 +00:00
if ( highlightsectorcnt = = - 1 )
2006-04-13 20:47:06 +00:00
{
message ( " You didn't select any sectors! " ) ;
return ;
}
2007-06-12 19:53:18 +00:00
pal [ 0 ] = getnumber256 ( " Ceiling palette: " , - 1 , MAXPALOOKUPS , 1 ) ;
pal [ 1 ] = getnumber256 ( " Floor palette: " , - 1 , MAXPALOOKUPS , 1 ) ;
pal [ 2 ] = getnumber256 ( " Wall palette: " , - 1 , MAXPALOOKUPS , 1 ) ;
pal [ 3 ] = getnumber256 ( " Sprite palette: " , - 1 , MAXPALOOKUPS , 1 ) ;
2008-05-16 19:51:38 +00:00
if ( AskIfSure ( 0 ) ) return ;
2006-04-13 20:47:06 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
{
currsector = highlightsector [ i ] ;
2007-06-12 19:53:18 +00:00
if ( pal [ 0 ] > - 1 )
sector [ currsector ] . ceilingpal = pal [ 0 ] ;
if ( pal [ 1 ] > - 1 )
sector [ currsector ] . floorpal = pal [ 1 ] ;
2006-04-13 20:47:06 +00:00
// Do all the walls in the sector
start_wall = sector [ currsector ] . wallptr ;
end_wall = start_wall + sector [ currsector ] . wallnum ;
2007-06-12 19:53:18 +00:00
if ( pal [ 2 ] > - 1 )
for ( w = start_wall ; w < end_wall ; w + + )
{
wall [ w ] . pal = pal [ 2 ] ;
}
if ( pal [ 3 ] > - 1 )
2009-02-19 16:47:54 +00:00
for ( k = 0 ; k < highlightsectorcnt ; k + + )
2007-06-12 19:53:18 +00:00
{
w = headspritesect [ highlightsector [ k ] ] ;
while ( w > = 0 )
{
j = nextspritesect [ w ] ;
sprite [ w ] . pal = pal [ 3 ] ;
w = j ;
}
}
2006-04-13 20:47:06 +00:00
}
message ( " Palettes changed " ) ;
}
// ;P - Will copy palette to all sectors & sprites within highlighted with R-Alt key
if ( keystatus [ KEYSC_SEMI ] & & keystatus [ KEYSC_P ] ) // ; P
{
2009-01-09 09:29:17 +00:00
int16_t w , start_wall , end_wall , currsector ;
uint8_t pal ;
2006-04-13 20:47:06 +00:00
keystatus [ KEYSC_P ] = 0 ;
2006-11-13 23:12:47 +00:00
if ( highlightsectorcnt = = - 1 )
2006-04-13 20:47:06 +00:00
{
message ( " You didn't select any sectors! " ) ;
return ;
}
2009-01-09 09:29:17 +00:00
pal = ( uint8_t ) getnumber256 ( " Global palette: " , 0 , MAXPALOOKUPS , 0 ) ;
2008-05-16 19:51:38 +00:00
if ( AskIfSure ( 0 ) ) return ;
2006-04-13 20:47:06 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
{
currsector = highlightsector [ i ] ;
sector [ currsector ] . ceilingpal = pal ;
sector [ currsector ] . floorpal = pal ;
// Do all the walls in the sector
start_wall = sector [ currsector ] . wallptr ;
end_wall = start_wall + sector [ currsector ] . wallnum ;
for ( w = start_wall ; w < end_wall ; w + + )
{
wall [ w ] . pal = pal ;
}
2009-02-19 16:47:54 +00:00
for ( k = 0 ; k < highlightsectorcnt ; k + + )
2006-04-13 20:47:06 +00:00
{
w = headspritesect [ highlightsector [ k ] ] ;
2006-11-13 23:12:47 +00:00
while ( w > = 0 )
2006-04-13 20:47:06 +00:00
{
j = nextspritesect [ w ] ;
2007-06-12 19:47:34 +00:00
sprite [ w ] . pal = pal ;
2006-04-13 20:47:06 +00:00
w = j ;
}
}
}
message ( " Palettes changed " ) ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_DELETE ] )
2006-04-13 20:47:06 +00:00
{
if ( searchstat = = 3 )
{
deletesprite ( searchwall ) ;
updatenumsprites ( ) ;
2008-06-09 23:41:54 +00:00
message ( " Sprite %d deleted " , searchwall ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_DELETE ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_F6 ] ) //F6
2006-04-13 20:47:06 +00:00
{
keystatus [ KEYSC_F6 ] = 0 ;
autospritehelp = ! autospritehelp ;
2008-06-09 23:41:54 +00:00
message ( " Automatic SECTOREFFECTOR help %s " , autospritehelp ? " enabled " : " disabled " ) ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_F7 ] ) //F7
2006-04-13 20:47:06 +00:00
{
keystatus [ KEYSC_F7 ] = 0 ;
autosecthelp = ! autosecthelp ;
2008-06-09 23:41:54 +00:00
message ( " Automatic sector tag help %s " , autosecthelp ? " enabled " : " disabled " ) ;
2006-04-13 20:47:06 +00:00
}
if ( ( searchstat = = 3 ) & & ( sprite [ searchwall ] . picnum = = SECTOREFFECTOR ) )
if ( autospritehelp & & helpon = = 0 ) Show3dText ( " sehelp.hlp " ) ;
if ( searchstat = = 1 | | searchstat = = 2 )
if ( autosecthelp & & helpon = = 0 ) Show3dText ( " sthelp.hlp " ) ;
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_COMMA ] ) // , Search & fix panning to the left (3D)
2006-04-13 20:47:06 +00:00
{
if ( searchstat = = 3 )
{
i = searchwall ;
2008-05-16 00:23:33 +00:00
if ( eitherSHIFT )
2006-04-13 20:47:06 +00:00
sprite [ i ] . ang = ( ( sprite [ i ] . ang + 2048 - 1 ) & 2047 ) ;
else
{
sprite [ i ] . ang = ( ( sprite [ i ] . ang + 2048 - 128 ) & 2047 ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_COMMA ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-06-09 23:41:54 +00:00
message ( " Sprite %d angle: %d " , i , sprite [ i ] . ang ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_PERIOD ] ) // . Search & fix panning to the right (3D)
2006-04-13 20:47:06 +00:00
{
if ( ( searchstat = = 0 ) | | ( searchstat = = 4 ) )
{
2009-01-09 09:29:17 +00:00
AutoAlignWalls ( ( int32_t ) searchwall , 0L ) ;
2008-06-09 23:41:54 +00:00
message ( " Wall %d autoalign " , searchwall ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_PERIOD ] = 0 ;
2006-04-13 20:47:06 +00:00
}
if ( searchstat = = 3 )
{
i = searchwall ;
2008-05-16 00:23:33 +00:00
if ( eitherSHIFT )
2006-04-13 20:47:06 +00:00
sprite [ i ] . ang = ( ( sprite [ i ] . ang + 2048 + 1 ) & 2047 ) ;
else
{
sprite [ i ] . ang = ( ( sprite [ i ] . ang + 2048 + 128 ) & 2047 ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_PERIOD ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-06-09 23:41:54 +00:00
message ( " Sprite %d angle: %d " , i , sprite [ i ] . ang ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_L ] ) // ' L
2006-04-13 20:47:06 +00:00
{
2008-09-03 13:23:34 +00:00
i = noclip ;
noclip = 1 ;
2006-04-13 20:47:06 +00:00
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 1 :
2008-09-03 13:23:34 +00:00
getnumberptr256 ( " Sector ceilingz: " , & sector [ searchsector ] . ceilingz , sizeof ( sector [ searchsector ] . ceilingz ) , 8388608 , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
if ( ! ( sector [ searchsector ] . ceilingstat & 2 ) )
2008-09-03 13:23:34 +00:00
{
sector [ searchsector ] . ceilingstat | = 2 ;
2006-11-16 03:02:42 +00:00
sector [ searchsector ] . ceilingheinum = 0 ;
2008-09-03 13:23:34 +00:00
}
getnumberptr256 ( " Sector ceiling slope: " , & sector [ searchsector ] . ceilingheinum , sizeof ( sector [ searchsector ] . ceilingheinum ) , 65536 , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
2008-09-03 13:23:34 +00:00
getnumberptr256 ( " Sector floorz: " , & sector [ searchsector ] . floorz , sizeof ( sector [ searchsector ] . floorz ) , 8388608 , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
if ( ! ( sector [ searchsector ] . floorstat & 2 ) )
2008-09-03 13:23:34 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ searchsector ] . floorheinum = 0 ;
2008-09-03 13:23:34 +00:00
sector [ searchsector ] . floorstat | = 2 ;
}
getnumberptr256 ( " Sector floor slope: " , & sector [ searchsector ] . floorheinum , sizeof ( sector [ searchsector ] . floorheinum ) , 65536 , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-09-03 13:23:34 +00:00
getnumberptr256 ( " Sprite x: " , & sprite [ searchwall ] . x , sizeof ( sprite [ searchwall ] . x ) , 131072 , 1 , NULL ) ;
getnumberptr256 ( " Sprite y: " , & sprite [ searchwall ] . y , sizeof ( sprite [ searchwall ] . y ) , 131072 , 1 , NULL ) ;
getnumberptr256 ( " Sprite z: " , & sprite [ searchwall ] . z , sizeof ( sprite [ searchwall ] . z ) , 8388608 , 1 , NULL ) ;
getnumberptr256 ( " Sprite angle: " , & sprite [ searchwall ] . ang , sizeof ( sprite [ searchwall ] . ang ) , 2048L , 0 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
if ( sector [ searchsector ] . ceilingheinum = = 0 )
sector [ searchsector ] . ceilingstat & = ~ 2 ;
else
sector [ searchsector ] . ceilingstat | = 2 ;
if ( sector [ searchsector ] . floorheinum = = 0 )
sector [ searchsector ] . floorstat & = ~ 2 ;
else
sector [ searchsector ] . floorstat | = 2 ;
asksave = 1 ;
keystatus [ KEYSC_L ] = 0 ;
2008-09-03 13:23:34 +00:00
noclip = i ;
2006-04-13 20:47:06 +00:00
}
2009-01-13 12:23:18 +00:00
getzrange ( & pos , cursectnum , & hiz , & hihit , & loz , & lohit , 128L , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_CAPS ] | | ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_Z ] ) )
2006-04-13 20:47:06 +00:00
{
zmode + + ;
if ( zmode = = 3 ) zmode = 0 ;
2009-01-13 12:23:18 +00:00
else if ( zmode = = 1 ) zlock = ( loz - pos . z ) & 0xfffffc00 ;
2008-05-16 00:23:33 +00:00
switch ( zmode )
{
2009-02-19 16:47:54 +00:00
case 0 : message ( " Zmode = Gravity " ) ; break ;
case 1 : message ( " Zmode = Locked/Sector " ) ; break ;
case 2 : message ( " Zmode = Locked/Free " ) ; break ;
2008-05-16 00:23:33 +00:00
}
2007-03-22 20:58:13 +00:00
keystatus [ KEYSC_CAPS ] = keystatus [ KEYSC_Z ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_M ] ) // M
2006-04-13 20:47:06 +00:00
{
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
case 4 :
strcpy ( buffer , " Wall extra: " ) ;
2009-01-09 09:29:17 +00:00
wall [ searchwall ] . extra = getnumber256 ( buffer , ( int32_t ) wall [ searchwall ] . extra , 65536L , 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
case 2 :
strcpy ( buffer , " Sector extra: " ) ;
2009-01-09 09:29:17 +00:00
sector [ searchsector ] . extra = getnumber256 ( buffer , ( int32_t ) sector [ searchsector ] . extra , 65536L , 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
strcpy ( buffer , " Sprite extra: " ) ;
2009-01-09 09:29:17 +00:00
sprite [ searchwall ] . extra = getnumber256 ( buffer , ( int32_t ) sprite [ searchwall ] . extra , 65536L , 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
asksave = 1 ;
keystatus [ KEYSC_M ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_1 ] ) // 1 (make 1-way wall)
2006-04-13 20:47:06 +00:00
{
if ( searchstat ! = 3 )
{
wall [ searchwall ] . cstat ^ = 32 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Wall %d one side masking bit %s " , searchwall , wall [ searchwall ] . cstat & 32 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
else
{
sprite [ searchwall ] . cstat ^ = 64 ;
i = sprite [ searchwall ] . cstat ;
if ( ( i & 48 ) = = 32 )
{
sprite [ searchwall ] . cstat & = ~ 8 ;
if ( ( i & 64 ) > 0 )
2009-01-13 12:23:18 +00:00
if ( pos . z > sprite [ searchwall ] . z )
2006-04-13 20:47:06 +00:00
sprite [ searchwall ] . cstat | = 8 ;
}
asksave = 1 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d one sided bit %s " , searchwall , sprite [ searchwall ] . cstat & 64 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
keystatus [ KEYSC_1 ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_2 ] ) // 2 (bottom wall swapping)
2006-04-13 20:47:06 +00:00
{
if ( searchstat ! = 3 )
{
wall [ searchwall ] . cstat ^ = 2 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Wall %d bottom texture swap bit %s " , searchwall , wall [ searchwall ] . cstat & 2 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
keystatus [ KEYSC_2 ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_O ] ) // O (top/bottom orientation - for doors)
2006-04-13 20:47:06 +00:00
{
if ( ( searchstat = = 0 ) | | ( searchstat = = 4 ) )
{
wall [ searchwall ] . cstat ^ = 4 ;
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Wall %d %s orientation " , searchwall , wall [ searchwall ] . cstat & 4 ? " bottom " : " top " ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
if ( searchstat = = 3 ) // O (ornament onto wall) (2D)
{
asksave = 1 ;
i = searchwall ;
2008-09-06 06:22:31 +00:00
DoSpriteOrnament ( i ) ;
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Sprite %d ornament onto wall " , i ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
}
keystatus [ KEYSC_O ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_M ] ) // M (masking walls)
2006-04-13 20:47:06 +00:00
{
if ( searchstat ! = 3 )
{
i = wall [ searchwall ] . nextwall ;
2008-05-16 00:23:33 +00:00
tempint = eitherSHIFT ;
2006-04-13 20:47:06 +00:00
if ( i > = 0 )
{
wall [ searchwall ] . cstat ^ = 16 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Wall %d masking bit %s " , searchwall , wall [ searchwall ] . cstat & 16 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
if ( ( wall [ searchwall ] . cstat & 16 ) > 0 )
{
wall [ searchwall ] . cstat & = ~ 8 ;
2007-12-12 17:42:14 +00:00
if ( tempint = = 0 )
2006-04-13 20:47:06 +00:00
{
wall [ i ] . cstat | = 8 ; //auto other-side flip
wall [ i ] . cstat | = 16 ;
wall [ i ] . overpicnum = wall [ searchwall ] . overpicnum ;
}
}
else
{
wall [ searchwall ] . cstat & = ~ 8 ;
2007-12-12 17:42:14 +00:00
if ( tempint = = 0 )
2006-04-13 20:47:06 +00:00
{
wall [ i ] . cstat & = ~ 8 ; //auto other-side unflip
wall [ i ] . cstat & = ~ 16 ;
}
}
wall [ searchwall ] . cstat & = ~ 32 ;
2007-12-12 17:42:14 +00:00
if ( tempint = = 0 ) wall [ i ] . cstat & = ~ 32 ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
keystatus [ KEYSC_M ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_H ] ) // H (hitscan sensitivity)
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
if ( ( keystatus [ KEYSC_QUOTE ] ) )
2006-04-13 20:47:06 +00:00
{
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
case 4 :
strcpy ( buffer , " Wall hitag: " ) ;
2009-01-09 09:29:17 +00:00
wall [ searchwall ] . hitag = getnumber256 ( buffer , ( int32_t ) wall [ searchwall ] . hitag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
strcpy ( buffer , " Sector hitag: " ) ;
2009-01-09 09:29:17 +00:00
sector [ searchsector ] . hitag = getnumber256 ( buffer , ( int32_t ) sector [ searchsector ] . hitag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
strcpy ( buffer , " Sector hitag: " ) ;
2009-01-09 09:29:17 +00:00
sector [ searchsector ] . hitag = getnumber256 ( buffer , ( int32_t ) sector [ searchsector ] . hitag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
strcpy ( buffer , " Sprite hitag: " ) ;
2009-01-09 09:29:17 +00:00
sprite [ searchwall ] . hitag = getnumber256 ( buffer , ( int32_t ) sprite [ searchwall ] . hitag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
else
{
if ( searchstat = = 3 )
{
sprite [ searchwall ] . cstat ^ = 256 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d hitscan sensitivity bit %s " , searchwall , sprite [ searchwall ] . cstat & 256 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
else
{
wall [ searchwall ] . cstat ^ = 64 ;
2008-05-16 00:23:33 +00:00
if ( ( wall [ searchwall ] . nextwall > = 0 ) & & ( eitherSHIFT = = 0 ) )
2006-04-13 20:47:06 +00:00
{
wall [ wall [ searchwall ] . nextwall ] . cstat & = ~ 64 ;
wall [ wall [ searchwall ] . nextwall ] . cstat | = ( wall [ searchwall ] . cstat & 64 ) ;
}
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Wall %d hitscan sensitivity bit %s " , searchwall , wall [ searchwall ] . cstat & 64 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
}
keystatus [ KEYSC_H ] = 0 ;
}
2008-05-16 00:23:33 +00:00
smooshyalign = keystatus [ KEYSC_gKP5 ] ;
repeatpanalign = eitherSHIFT | | ( bstatus & 2 ) ;
2006-04-13 20:47:06 +00:00
2007-02-16 00:11:25 +00:00
if ( mlook = = 2 )
mlook = 0 ;
2008-05-15 03:16:38 +00:00
if ( ! unrealedlook & & ( bstatus & 4 ) ) mlook = 2 ;
// if (bstatus&4)
2008-05-16 00:23:33 +00:00
if ( ( bstatus & ( 16 | 32 ) & & ! ( bstatus & ( 1 | 2 | 4 ) ) ) | | keystatus [ KEYSC_gMINUS ] | | keystatus [ KEYSC_gPLUS ] ) // PK: no btn: wheel changes shade
2006-04-13 20:47:06 +00:00
{
2008-05-15 03:16:38 +00:00
// if (bstatus&1)
// {
// mlook = 2;
// }
2008-05-16 00:23:33 +00:00
if ( bstatus & 32 | | keystatus [ KEYSC_gMINUS ] ) // -
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_gMINUS ] = 0 ;
2007-01-29 03:21:12 +00:00
mouseb & = ~ 32 ;
bstatus & = ~ 32 ;
2008-05-16 00:23:33 +00:00
if ( eitherALT ) //ALT
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
if ( eitherCTRL ) //CTRL
2006-04-13 20:47:06 +00:00
{
if ( visibility < 16384 ) visibility + = visibility ;
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Global visibility %d " , visibility ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2008-05-16 00:23:33 +00:00
k = eitherSHIFT ? 1 : 16 ;
2006-04-13 20:47:06 +00:00
if ( highlightsectorcnt > = 0 )
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( highlightsector [ i ] = = searchsector )
{
while ( k > 0 )
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
{
sector [ highlightsector [ i ] ] . visibility + + ;
if ( sector [ highlightsector [ i ] ] . visibility = = 240 )
sector [ highlightsector [ i ] ] . visibility = 239 ;
}
k - - ;
}
break ;
}
while ( k > 0 )
{
sector [ searchsector ] . visibility + + ;
if ( sector [ searchsector ] . visibility = = 240 )
sector [ searchsector ] . visibility = 239 ;
k - - ;
}
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Sector %d visibility %d " , searchsector , sector [ searchsector ] . visibility ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
else
{
k = 0 ;
if ( highlightsectorcnt > = 0 )
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( highlightsector [ i ] = = searchsector )
{
k = 1 ;
break ;
}
}
if ( k = = 0 )
{
2009-01-09 09:29:17 +00:00
int32_t shade = - 1 , i = - 1 ;
2008-05-16 19:51:38 +00:00
if ( searchstat = = 0 ) shade = + + wall [ i = searchwall ] . shade ;
if ( searchstat = = 1 ) shade = + + sector [ i = searchsector ] . ceilingshade ;
if ( searchstat = = 2 ) shade = + + sector [ i = searchsector ] . floorshade ;
if ( searchstat = = 3 ) shade = + + sprite [ i = searchwall ] . shade ;
if ( searchstat = = 4 ) shade = + + wall [ i = searchwall ] . shade ;
if ( i ! = - 1 )
2008-05-16 00:23:33 +00:00
{
Bsprintf ( getmessage , " %s %d shade %d " , type2str [ searchstat ] , i , shade ) ;
message ( getmessage ) ;
}
2006-04-13 20:47:06 +00:00
}
else
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
{
dasector = highlightsector [ i ] ;
sector [ dasector ] . ceilingshade + + ; //sector shade
sector [ dasector ] . floorshade + + ;
startwall = sector [ dasector ] . wallptr ; //wall shade
endwall = startwall + sector [ dasector ] . wallnum - 1 ;
2009-02-19 16:47:54 +00:00
for ( j = startwall ; j < = endwall ; j + + )
2006-04-13 20:47:06 +00:00
wall [ j ] . shade + + ;
j = headspritesect [ dasector ] ; //sprite shade
while ( j ! = - 1 )
{
sprite [ j ] . shade + + ;
j = nextspritesect [ j ] ;
}
}
}
asksave = 1 ;
}
}
2008-05-16 00:23:33 +00:00
if ( bstatus & 16 | | keystatus [ KEYSC_gPLUS ] ) // +
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_gPLUS ] = 0 ;
2007-01-29 03:21:12 +00:00
mouseb & = ~ 16 ;
bstatus & = ~ 16 ;
2008-05-16 00:23:33 +00:00
if ( eitherALT ) //ALT
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
if ( eitherCTRL ) //CTRL
2006-04-13 20:47:06 +00:00
{
if ( visibility > 32 ) visibility > > = 1 ;
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Global visibility %d " , visibility ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2008-05-16 00:23:33 +00:00
k = eitherSHIFT ? 1 : 16 ;
2006-04-13 20:47:06 +00:00
if ( highlightsectorcnt > = 0 )
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( highlightsector [ i ] = = searchsector )
{
while ( k > 0 )
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
{
sector [ highlightsector [ i ] ] . visibility - - ;
if ( sector [ highlightsector [ i ] ] . visibility = = 239 )
sector [ highlightsector [ i ] ] . visibility = 240 ;
}
k - - ;
}
break ;
}
while ( k > 0 )
{
sector [ searchsector ] . visibility - - ;
if ( sector [ searchsector ] . visibility = = 239 )
sector [ searchsector ] . visibility = 240 ;
k - - ;
}
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Sector %d visibility %d " , searchsector , sector [ searchsector ] . visibility ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
else
{
k = 0 ;
if ( highlightsectorcnt > = 0 )
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( highlightsector [ i ] = = searchsector )
{
k = 1 ;
break ;
}
}
if ( k = = 0 )
{
2009-01-09 09:29:17 +00:00
int32_t shade = - 1 , i = - 1 ;
2008-05-16 19:51:38 +00:00
if ( searchstat = = 0 ) shade = - - wall [ i = searchwall ] . shade ;
if ( searchstat = = 1 ) shade = - - sector [ i = searchsector ] . ceilingshade ;
if ( searchstat = = 2 ) shade = - - sector [ i = searchsector ] . floorshade ;
if ( searchstat = = 3 ) shade = - - sprite [ i = searchwall ] . shade ;
if ( searchstat = = 4 ) shade = - - wall [ i = searchwall ] . shade ;
if ( i ! = - 1 )
2008-05-16 00:23:33 +00:00
{
Bsprintf ( getmessage , " %s %d shade %d " , type2str [ searchstat ] , i , shade ) ;
message ( getmessage ) ;
}
2006-04-13 20:47:06 +00:00
}
else
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
{
dasector = highlightsector [ i ] ;
sector [ dasector ] . ceilingshade - - ; //sector shade
sector [ dasector ] . floorshade - - ;
startwall = sector [ dasector ] . wallptr ; //wall shade
endwall = startwall + sector [ dasector ] . wallnum - 1 ;
2009-02-19 16:47:54 +00:00
for ( j = startwall ; j < = endwall ; j + + )
2006-04-13 20:47:06 +00:00
wall [ j ] . shade - - ;
j = headspritesect [ dasector ] ; //sprite shade
while ( j ! = - 1 )
{
sprite [ j ] . shade - - ;
j = nextspritesect [ j ] ;
}
}
}
asksave = 1 ;
}
}
}
2008-05-15 03:16:38 +00:00
// if ((keystatus[KEYSC_DASH]|keystatus[KEYSC_EQUAL]|((bstatus&(16|32)) && !(bstatus&2))) > 0) // mousewheel, -, and +, cycle picnum
if ( keystatus [ KEYSC_DASH ] | keystatus [ KEYSC_EQUAL ] | ( bstatus & ( 16 | 32 ) & & ( bstatus & 1 ) & & ! ( bstatus & 2 ) ) ) // PK: lmb only & mousewheel, -, and +, cycle picnum
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
j = i = ( keystatus [ KEYSC_EQUAL ] | | ( bstatus & 16 ) ) ? 1 : - 1 ;
2006-04-13 20:47:06 +00:00
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
while ( ! tilesizx [ wall [ searchwall ] . picnum ] | | ! tilesizy [ wall [ searchwall ] . picnum ] | | j )
{
if ( wall [ searchwall ] . picnum + i > = MAXTILES ) wall [ searchwall ] . picnum = 0 ;
else if ( wall [ searchwall ] . picnum + i < 0 ) wall [ searchwall ] . picnum = MAXTILES - 1 ;
else wall [ searchwall ] . picnum + = i ;
j = 0 ;
}
break ;
case 1 :
while ( ! tilesizx [ sector [ searchsector ] . ceilingpicnum ] | | ! tilesizy [ sector [ searchsector ] . ceilingpicnum ] | | j )
{
if ( sector [ searchsector ] . ceilingpicnum + i > = MAXTILES ) sector [ searchsector ] . ceilingpicnum = 0 ;
else if ( sector [ searchsector ] . ceilingpicnum + i < 0 ) sector [ searchsector ] . ceilingpicnum = MAXTILES - 1 ;
else sector [ searchsector ] . ceilingpicnum + = i ;
j = 0 ;
}
break ;
case 2 :
while ( ! tilesizx [ sector [ searchsector ] . floorpicnum ] | | ! tilesizy [ sector [ searchsector ] . floorpicnum ] | | j )
{
if ( sector [ searchsector ] . floorpicnum + i > = MAXTILES ) sector [ searchsector ] . floorpicnum = 0 ;
else if ( sector [ searchsector ] . floorpicnum + i < 0 ) sector [ searchsector ] . floorpicnum = MAXTILES - 1 ;
else sector [ searchsector ] . floorpicnum + = i ;
j = 0 ;
}
break ;
case 3 :
while ( ! tilesizx [ sprite [ searchwall ] . picnum ] | | ! tilesizy [ sprite [ searchwall ] . picnum ] | | j )
{
if ( sprite [ searchwall ] . picnum + i > = MAXTILES ) sprite [ searchwall ] . picnum = 0 ;
else if ( sprite [ searchwall ] . picnum + i < 0 ) sprite [ searchwall ] . picnum = MAXTILES - 1 ;
else sprite [ searchwall ] . picnum + = i ;
j = 0 ;
}
break ;
case 4 :
while ( ! tilesizx [ wall [ searchwall ] . overpicnum ] | | ! tilesizy [ wall [ searchwall ] . overpicnum ] | | j )
{
if ( wall [ searchwall ] . overpicnum + i > = MAXTILES ) wall [ searchwall ] . overpicnum = 0 ;
else if ( wall [ searchwall ] . overpicnum + i < 0 ) wall [ searchwall ] . overpicnum = MAXTILES - 1 ;
else wall [ searchwall ] . overpicnum + = i ;
j = 0 ;
}
break ;
}
asksave = 1 ;
keystatus [ KEYSC_DASH ] = keystatus [ KEYSC_EQUAL ] = 0 ;
mouseb & = ~ ( 16 | 32 ) ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_E ] ) // E (expand)
2006-11-16 03:02:42 +00:00
{
if ( searchstat = = 1 )
{
sector [ searchsector ] . ceilingstat ^ = 8 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d ceiling texture expansion bit %s " , searchsector , sector [ searchsector ] . ceilingstat & 8 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
if ( searchstat = = 2 )
{
sector [ searchsector ] . floorstat ^ = 8 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d floor texture expansion bit %s " , searchsector , sector [ searchsector ] . floorstat & 8 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
keystatus [ KEYSC_E ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_R ] ) // R (relative alignment, rotation)
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] ) // FRAMERATE TOGGLE
2006-04-13 20:47:06 +00:00
{
framerateon = ! framerateon ;
2006-11-13 23:12:47 +00:00
if ( framerateon ) message ( " Show framerate ON " ) ;
2006-04-13 20:47:06 +00:00
else message ( " Show framerate OFF " ) ;
}
else
{
if ( searchstat = = 1 )
{
sector [ searchsector ] . ceilingstat ^ = 64 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d ceiling texture relativity bit %s " , searchsector , sector [ searchsector ] . ceilingstat & 64 ? " ON " : " OFF " ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
if ( searchstat = = 2 )
{
sector [ searchsector ] . floorstat ^ = 64 ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d floor texture relativity bit %s " , searchsector , sector [ searchsector ] . floorstat & 64 ? " ON " : " OFF " ) ; //PK (was ceiling in string)
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
if ( searchstat = = 3 )
{
i = sprite [ searchwall ] . cstat ;
if ( ( i & 48 ) < 32 ) i + = 16 ;
else i & = ~ 48 ;
sprite [ searchwall ] . cstat = i ;
if ( sprite [ searchwall ] . cstat & 16 )
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d now wall aligned " , searchwall ) ;
2006-04-13 20:47:06 +00:00
else if ( sprite [ searchwall ] . cstat & 32 )
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d now floor aligned " , searchwall ) ;
2006-04-13 20:47:06 +00:00
else
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d now view aligned " , searchwall ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
}
keystatus [ KEYSC_R ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_F ] ) //F (Flip)
2006-04-13 20:47:06 +00:00
{
keystatus [ KEYSC_F ] = 0 ;
2008-05-16 00:23:33 +00:00
if ( eitherALT ) //ALT-F (relative alignmment flip)
2006-04-13 20:47:06 +00:00
{
if ( searchstat ! = 3 )
{
setfirstwall ( searchsector , searchwall ) ;
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Sector %d first wall " , searchsector ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
else
{
if ( ( searchstat = = 0 ) | | ( searchstat = = 4 ) )
{
i = wall [ searchwall ] . cstat ;
i = ( ( i > > 3 ) & 1 ) + ( ( i > > 7 ) & 2 ) ; //3-x,8-y
2006-11-13 23:12:47 +00:00
switch ( i )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
i = 1 ;
break ;
case 1 :
i = 3 ;
break ;
case 2 :
i = 0 ;
break ;
case 3 :
i = 2 ;
break ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Wall %d flip %d " , searchwall , i ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
i = ( ( i & 1 ) < < 3 ) + ( ( i & 2 ) < < 7 ) ;
wall [ searchwall ] . cstat & = ~ 0x0108 ;
wall [ searchwall ] . cstat | = i ;
asksave = 1 ;
}
if ( searchstat = = 1 ) //8-way ceiling flipping (bits 2,4,5)
{
i = sector [ searchsector ] . ceilingstat ;
i = ( i & 0x4 ) + ( ( i > > 4 ) & 3 ) ;
2006-11-13 23:12:47 +00:00
switch ( i )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
i = 6 ;
break ;
case 6 :
i = 3 ;
break ;
case 3 :
i = 5 ;
break ;
case 5 :
i = 1 ;
break ;
case 1 :
i = 7 ;
break ;
case 7 :
i = 2 ;
break ;
case 2 :
i = 4 ;
break ;
case 4 :
i = 0 ;
break ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Sector %d flip %d " , searchsector , i ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
i = ( i & 0x4 ) + ( ( i & 3 ) < < 4 ) ;
sector [ searchsector ] . ceilingstat & = ~ 0x34 ;
sector [ searchsector ] . ceilingstat | = i ;
asksave = 1 ;
}
if ( searchstat = = 2 ) //8-way floor flipping (bits 2,4,5)
{
i = sector [ searchsector ] . floorstat ;
i = ( i & 0x4 ) + ( ( i > > 4 ) & 3 ) ;
2006-11-13 23:12:47 +00:00
switch ( i )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
i = 6 ;
break ;
case 6 :
i = 3 ;
break ;
case 3 :
i = 5 ;
break ;
case 5 :
i = 1 ;
break ;
case 1 :
i = 7 ;
break ;
case 7 :
i = 2 ;
break ;
case 2 :
i = 4 ;
break ;
case 4 :
i = 0 ;
break ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Sector %d flip %d " , searchsector , i ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
i = ( i & 0x4 ) + ( ( i & 3 ) < < 4 ) ;
sector [ searchsector ] . floorstat & = ~ 0x34 ;
sector [ searchsector ] . floorstat | = i ;
asksave = 1 ;
}
if ( searchstat = = 3 )
{
i = sprite [ searchwall ] . cstat ;
if ( ( ( i & 48 ) = = 32 ) & & ( ( i & 64 ) = = 0 ) )
{
sprite [ searchwall ] . cstat & = ~ 0xc ;
sprite [ searchwall ] . cstat | = ( ( i & 4 ) ^ 4 ) ;
2008-06-09 23:41:54 +00:00
Bsprintf ( getmessage , " Sprite %d flip bit %s " , searchwall , sprite [ searchwall ] . cstat & 4 ? " ON " : " OFF " ) ;
2008-05-16 00:23:33 +00:00
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
}
else
{
i = ( ( i > > 2 ) & 3 ) ;
2006-11-13 23:12:47 +00:00
switch ( i )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
i = 1 ;
break ;
case 1 :
i = 3 ;
break ;
case 2 :
i = 0 ;
break ;
case 3 :
i = 2 ;
break ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
Bsprintf ( getmessage , " Sprite %d flip %d " , searchwall , i ) ;
message ( getmessage ) ;
2006-04-13 20:47:06 +00:00
i < < = 2 ;
sprite [ searchwall ] . cstat & = ~ 0xc ;
sprite [ searchwall ] . cstat | = i ;
}
asksave = 1 ;
}
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_HOME ] )
2006-04-13 20:47:06 +00:00
updownunits = 256 ;
2008-05-16 00:23:33 +00:00
else if ( keystatus [ KEYSC_END ] )
2006-04-13 20:47:06 +00:00
updownunits = 512 ;
else
updownunits = 1024 ;
2008-05-16 19:51:38 +00:00
mouseaction = 0 ;
if ( eitherALT & & bstatus & 1 )
{
2009-02-19 16:47:54 +00:00
mousex = 0 ; mskip = 1 ;
2008-05-16 19:51:38 +00:00
if ( mousey < 0 )
{
updownunits = klabs ( mousey * 128 ) ;
mouseaction = 1 ;
}
}
if ( keystatus [ KEYSC_PGUP ] | | mouseaction | | ( ( bstatus & 2 ) & & ( bstatus & 16 & & ! ( bstatus & 1 ) ) ) ) // PK: PGUP, rmb only & mwheel
2006-04-13 20:47:06 +00:00
{
k = 0 ;
if ( highlightsectorcnt > = 0 )
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( highlightsector [ i ] = = searchsector )
{
k = 1 ;
break ;
}
}
if ( ( searchstat = = 0 ) | | ( searchstat = = 1 ) )
{
if ( k = = 0 )
{
i = headspritesect [ searchsector ] ;
while ( i ! = - 1 )
{
2007-12-12 17:42:14 +00:00
tempint = getceilzofslope ( searchsector , sprite [ i ] . x , sprite [ i ] . y ) ;
tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 2 ) ;
if ( sprite [ i ] . cstat & 128 ) tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 1 ) ;
if ( sprite [ i ] . z = = tempint )
2008-05-16 00:23:33 +00:00
sprite [ i ] . z - = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-05-16 00:23:33 +00:00
sector [ searchsector ] . ceilingz - = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d ceilingz = %d " , searchsector , sector [ searchsector ] . ceilingz ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
else
{
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < highlightsectorcnt ; j + + )
2006-04-13 20:47:06 +00:00
{
i = headspritesect [ highlightsector [ j ] ] ;
while ( i ! = - 1 )
{
2007-12-12 17:42:14 +00:00
tempint = getceilzofslope ( highlightsector [ j ] , sprite [ i ] . x , sprite [ i ] . y ) ;
tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 2 ) ;
if ( sprite [ i ] . cstat & 128 ) tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 1 ) ;
if ( sprite [ i ] . z = = tempint )
2008-05-16 00:23:33 +00:00
sprite [ i ] . z - = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-05-16 00:23:33 +00:00
sector [ highlightsector [ j ] ] . ceilingz - = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d ceilingz = %d " , * highlightsector , sector [ highlightsector [ j ] ] . ceilingz ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
}
}
if ( searchstat = = 2 )
{
if ( k = = 0 )
{
i = headspritesect [ searchsector ] ;
while ( i ! = - 1 )
{
2007-12-12 17:42:14 +00:00
tempint = getflorzofslope ( searchsector , sprite [ i ] . x , sprite [ i ] . y ) ;
if ( sprite [ i ] . cstat & 128 ) tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 1 ) ;
if ( sprite [ i ] . z = = tempint )
2008-05-16 00:23:33 +00:00
sprite [ i ] . z - = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-05-16 00:23:33 +00:00
sector [ searchsector ] . floorz - = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d floorz = %d " , searchsector , sector [ searchsector ] . floorz ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
else
{
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < highlightsectorcnt ; j + + )
2006-04-13 20:47:06 +00:00
{
i = headspritesect [ highlightsector [ j ] ] ;
while ( i ! = - 1 )
{
2007-12-12 17:42:14 +00:00
tempint = getflorzofslope ( highlightsector [ j ] , sprite [ i ] . x , sprite [ i ] . y ) ;
if ( sprite [ i ] . cstat & 128 ) tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 1 ) ;
if ( sprite [ i ] . z = = tempint )
2008-05-16 00:23:33 +00:00
sprite [ i ] . z - = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-05-16 00:23:33 +00:00
sector [ highlightsector [ j ] ] . floorz - = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d floorz = %d " , * highlightsector , sector [ highlightsector [ j ] ] . floorz ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
}
}
if ( sector [ searchsector ] . floorz < sector [ searchsector ] . ceilingz )
sector [ searchsector ] . floorz = sector [ searchsector ] . ceilingz ;
if ( searchstat = = 3 )
{
2008-05-16 00:23:33 +00:00
if ( eitherCTRL ) //CTRL - put sprite on ceiling
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
sprite [ searchwall ] . z = spriteonceilingz ( searchwall ) ;
2006-04-13 20:47:06 +00:00
}
else
{
k = 0 ;
if ( highlightcnt > = 0 )
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( highlight [ i ] = = searchwall + 16384 )
{
k = 1 ;
break ;
}
if ( k = = 0 )
{
sprite [ searchwall ] . z - = updownunits ;
2008-05-18 21:09:30 +00:00
if ( ! spnoclip ) sprite [ searchwall ] . z = max ( sprite [ searchwall ] . z , spriteonceilingz ( searchwall ) ) ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d z = %d " , searchwall , sprite [ searchwall ] . z ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
else
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( ( highlight [ i ] & 0xc000 ) = = 16384 )
2008-05-16 00:23:33 +00:00
{
2006-04-13 20:47:06 +00:00
sprite [ highlight [ i ] & 16383 ] . z - = updownunits ;
2008-05-18 21:09:30 +00:00
if ( ! spnoclip ) sprite [ highlight [ i ] & 16383 ] . z = max ( sprite [ highlight [ i ] & 16383 ] . z , spriteonceilingz ( highlight [ i ] & 16383 ) ) ;
2008-05-16 00:23:33 +00:00
}
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d z = %d " , highlight [ i ] & 16383 , sprite [ highlight [ i ] & 16383 ] . z ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
}
}
asksave = 1 ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_PGUP ] = 0 ;
2007-02-16 00:11:25 +00:00
mouseb & = ~ 16 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 19:51:38 +00:00
mouseaction = 0 ;
if ( eitherALT & & bstatus & 1 )
{
2009-02-19 16:47:54 +00:00
mousex = 0 ; mskip = 1 ;
2008-05-16 19:51:38 +00:00
if ( mousey > 0 )
{
updownunits = klabs ( mousey * 128 ) ;
mouseaction = 1 ;
}
}
if ( keystatus [ KEYSC_PGDN ] | | mouseaction | | ( ( bstatus & 2 ) & & ( bstatus & 32 ) & & ! ( bstatus & 1 ) ) ) // PK: PGDN, rmb only & mwheel
2006-04-13 20:47:06 +00:00
{
k = 0 ;
if ( highlightsectorcnt > = 0 )
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( highlightsector [ i ] = = searchsector )
{
k = 1 ;
break ;
}
}
if ( ( searchstat = = 0 ) | | ( searchstat = = 1 ) )
{
if ( k = = 0 )
{
i = headspritesect [ searchsector ] ;
while ( i ! = - 1 )
{
2007-12-12 17:42:14 +00:00
tempint = getceilzofslope ( searchsector , sprite [ i ] . x , sprite [ i ] . y ) ;
if ( sprite [ i ] . cstat & 128 ) tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 1 ) ;
tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 2 ) ;
if ( sprite [ i ] . z = = tempint )
2008-05-16 00:23:33 +00:00
sprite [ i ] . z + = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-05-16 00:23:33 +00:00
sector [ searchsector ] . ceilingz + = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d ceilingz = %d " , searchsector , sector [ searchsector ] . ceilingz ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
else
{
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < highlightsectorcnt ; j + + )
2006-04-13 20:47:06 +00:00
{
i = headspritesect [ highlightsector [ j ] ] ;
while ( i ! = - 1 )
{
2007-12-12 17:42:14 +00:00
tempint = getceilzofslope ( highlightsector [ j ] , sprite [ i ] . x , sprite [ i ] . y ) ;
if ( sprite [ i ] . cstat & 128 ) tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 1 ) ;
tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 2 ) ;
if ( sprite [ i ] . z = = tempint )
2008-05-16 00:23:33 +00:00
sprite [ i ] . z + = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-05-16 00:23:33 +00:00
sector [ highlightsector [ j ] ] . ceilingz + = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d ceilingz = %d " , * highlightsector , sector [ highlightsector [ j ] ] . ceilingz ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
}
}
if ( searchstat = = 2 )
{
if ( k = = 0 )
{
i = headspritesect [ searchsector ] ;
while ( i ! = - 1 )
{
2007-12-12 17:42:14 +00:00
tempint = getflorzofslope ( searchsector , sprite [ i ] . x , sprite [ i ] . y ) ;
if ( sprite [ i ] . cstat & 128 ) tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 1 ) ;
if ( sprite [ i ] . z = = tempint )
2008-05-16 00:23:33 +00:00
sprite [ i ] . z + = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-05-16 00:23:33 +00:00
sector [ searchsector ] . floorz + = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d floorz = %d " , searchsector , sector [ searchsector ] . floorz ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
else
{
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < highlightsectorcnt ; j + + )
2006-04-13 20:47:06 +00:00
{
i = headspritesect [ highlightsector [ j ] ] ;
while ( i ! = - 1 )
{
2007-12-12 17:42:14 +00:00
tempint = getflorzofslope ( highlightsector [ j ] , sprite [ i ] . x , sprite [ i ] . y ) ;
if ( sprite [ i ] . cstat & 128 ) tempint + = ( ( tilesizy [ sprite [ i ] . picnum ] * sprite [ i ] . yrepeat ) < < 1 ) ;
if ( sprite [ i ] . z = = tempint )
2008-05-16 00:23:33 +00:00
sprite [ i ] . z + = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-05-16 00:23:33 +00:00
sector [ highlightsector [ j ] ] . floorz + = updownunits < < ( eitherCTRL < < 1 ) ; // JBF 20031128
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sector %d floorz = %d " , * highlightsector , sector [ highlightsector [ j ] ] . floorz ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
}
}
if ( sector [ searchsector ] . ceilingz > sector [ searchsector ] . floorz )
sector [ searchsector ] . ceilingz = sector [ searchsector ] . floorz ;
if ( searchstat = = 3 )
{
2008-05-16 00:23:33 +00:00
if ( eitherCTRL ) //CTRL - put sprite on ground
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
sprite [ searchwall ] . z = spriteongroundz ( searchwall ) ;
2006-04-13 20:47:06 +00:00
}
else
{
k = 0 ;
if ( highlightcnt > = 0 )
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( highlight [ i ] = = searchwall + 16384 )
{
k = 1 ;
break ;
}
if ( k = = 0 )
{
sprite [ searchwall ] . z + = updownunits ;
2008-05-18 21:09:30 +00:00
if ( ! spnoclip ) sprite [ searchwall ] . z = min ( sprite [ searchwall ] . z , spriteongroundz ( searchwall ) ) ;
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d z = %d " , searchwall , sprite [ searchwall ] . z ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
else
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < highlightcnt ; i + + )
2006-04-13 20:47:06 +00:00
if ( ( highlight [ i ] & 0xc000 ) = = 16384 )
2008-05-16 00:23:33 +00:00
{
2006-04-13 20:47:06 +00:00
sprite [ highlight [ i ] & 16383 ] . z + = updownunits ;
2008-05-18 21:09:30 +00:00
if ( ! spnoclip ) sprite [ highlight [ i ] & 16383 ] . z = min ( sprite [ highlight [ i ] & 16383 ] . z , spriteongroundz ( highlight [ i ] & 16383 ) ) ;
2008-05-16 00:23:33 +00:00
}
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d z = %d " , highlight [ i ] & 16383 , sprite [ highlight [ i ] & 16383 ] . z ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
}
}
}
asksave = 1 ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_PGDN ] = 0 ;
2007-02-16 00:11:25 +00:00
mouseb & = ~ 32 ;
2006-04-13 20:47:06 +00:00
}
/* end Mapster32 */
// DoWater(horiz);
2008-09-11 09:24:45 +00:00
if ( framerateon )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
static int32_t FrameCount = 0 ;
static int32_t LastCount = 0 ;
static int32_t LastSec = 0 ;
static int32_t LastMS = 0 ;
int32_t ms = getticks ( ) ;
int32_t howlong = ms - LastMS ;
2008-09-11 09:24:45 +00:00
if ( howlong > = 0 )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t thisSec = ms / 1000 ;
int32_t x = ( xdim < = 640 ) ;
int32_t chars = Bsprintf ( tempbuf , " %2u ms (%3u fps) " , howlong , LastCount ) ;
2007-02-26 01:46:38 +00:00
2008-09-11 09:24:45 +00:00
if ( ! x )
{
printext256 ( windowx2 - ( chars < < 3 ) + 1 , windowy1 + 2 , 0 , - 1 , tempbuf , x ) ;
printext256 ( windowx2 - ( chars < < 3 ) , windowy1 + 1 , COLOR_WHITE , - 1 , tempbuf , x ) ;
}
else
{
printext256 ( windowx2 - ( chars < < 2 ) + 1 , windowy1 + 2 , 0 , - 1 , tempbuf , x ) ;
printext256 ( windowx2 - ( chars < < 2 ) , windowy1 + 1 , COLOR_WHITE , - 1 , tempbuf , x ) ;
}
if ( LastSec < thisSec )
{
LastCount = FrameCount / ( thisSec - LastSec ) ;
LastSec = thisSec ;
FrameCount = 0 ;
}
FrameCount + + ;
2006-04-13 20:47:06 +00:00
}
2008-09-11 09:24:45 +00:00
LastMS = ms ;
2006-04-13 20:47:06 +00:00
}
tempbuf [ 0 ] = 0 ;
2008-05-15 03:16:38 +00:00
if ( bstatus & 4 & & ! ( bstatus & ( 1 | 2 ) ) & & ! unrealedlook ) //PK
2007-02-16 00:11:25 +00:00
{
2008-05-15 03:16:38 +00:00
Bsprintf ( tempbuf , " VIEW " ) ;
// else Bsprintf(tempbuf,"SHADE");
2007-02-16 00:11:25 +00:00
}
2008-05-15 03:16:38 +00:00
else if ( bstatus & 2 & & ! ( bstatus & 1 ) )
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " Z " ) ;
2008-05-15 03:16:38 +00:00
else if ( bstatus & 1 & & ! ( bstatus & 2 ) )
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " LOCK " ) ;
2008-05-15 03:16:38 +00:00
2008-05-16 19:51:38 +00:00
if ( bstatus & 1 )
{
Bsprintf ( tempbuf , " LOCK " ) ;
switch ( searchstat )
{
case 0 :
case 4 :
if ( eitherSHIFT ) Bsprintf ( tempbuf , " PAN " ) ;
if ( eitherCTRL ) Bsprintf ( tempbuf , " SCALE " ) ;
if ( eitherALT ) Bsprintf ( tempbuf , " Z " ) ;
break ;
case 1 :
case 2 :
if ( eitherSHIFT ) Bsprintf ( tempbuf , " PAN " ) ;
if ( eitherCTRL ) Bsprintf ( tempbuf , " SLOPE " ) ;
if ( eitherALT ) Bsprintf ( tempbuf , " Z " ) ;
break ;
case 3 :
if ( eitherSHIFT ) Bsprintf ( tempbuf , " MOVE XY " ) ;
if ( eitherCTRL ) Bsprintf ( tempbuf , " SIZE " ) ;
if ( eitherALT ) Bsprintf ( tempbuf , " MOVE Z " ) ;
break ;
}
}
2006-11-13 23:12:47 +00:00
if ( tempbuf [ 0 ] ! = 0 )
2006-04-13 20:47:06 +00:00
{
2006-08-28 19:18:05 +00:00
i = ( Bstrlen ( tempbuf ) < < 3 ) + 6 ;
2006-11-13 23:12:47 +00:00
if ( ( searchx + i ) < ( xdim - 1 ) )
2006-08-28 19:18:05 +00:00
i = 0 ;
else i = ( searchx + i ) - ( xdim - 1 ) ;
2006-11-13 23:12:47 +00:00
if ( ( searchy + 16 ) < ( ydim - 1 ) )
2006-08-28 19:18:05 +00:00
j = 0 ;
else j = ( searchy + 16 ) - ( ydim - 1 ) ;
// printext16(searchx+6-i,searchy+6-j,11,-1,tempbuf,0);
2006-07-30 01:48:52 +00:00
printext256 ( searchx + 4 + 2 - i , searchy + 4 + 2 - j , 0 , - 1 , tempbuf , ! ( xdimgame > 640 ) ) ;
printext256 ( searchx + 4 - i , searchy + 4 - j , whitecol , - 1 , tempbuf , ! ( xdimgame > 640 ) ) ;
2006-08-28 19:18:05 +00:00
// printext256(searchx+4+2,searchy+4+2,0,-1,tempbuf,!(xdimgame > 640));
// printext256(searchx+4,searchy+4,whitecol,-1,tempbuf,!(xdimgame > 640));
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( helpon = = 1 )
2006-04-13 20:47:06 +00:00
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXHELP3D ; i + + )
2006-04-13 20:47:06 +00:00
{
begindrawing ( ) ;
printext256 ( 0 * 8 + 2 , 8 + ( i * ( 8 + ( xdimgame > 640 ) ) ) + 2 , 0 , - 1 , Help3d [ i ] , ! ( xdimgame > 640 ) ) ;
printext256 ( 0 * 8 , 8 + ( i * ( 8 + ( xdimgame > 640 ) ) ) , whitecol , - 1 , Help3d [ i ] , ! ( xdimgame > 640 ) ) ;
enddrawing ( ) ;
2006-11-13 23:12:47 +00:00
switch ( i )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 8 :
Bsprintf ( tempbuf , " %d " , autosave ) ;
break ;
case 9 :
Bsprintf ( tempbuf , " %s " , SKILLMODE [ skill ] ) ;
break ;
case 10 :
Bsprintf ( tempbuf , " %d " , framerateon ) ;
break ;
2008-05-22 10:08:17 +00:00
case 11 :
2006-11-16 03:02:42 +00:00
Bsprintf ( tempbuf , " %s " , SPRDSPMODE [ nosprites ] ) ;
break ;
2008-05-22 10:08:17 +00:00
case 12 :
2006-11-16 03:02:42 +00:00
Bsprintf ( tempbuf , " %d " , shadepreview ) ;
break ;
2008-05-22 10:08:17 +00:00
case 13 :
2006-11-16 03:02:42 +00:00
Bsprintf ( tempbuf , " %d " , purpleon ) ;
break ;
default :
2009-02-02 01:49:14 +00:00
Bsprintf ( tempbuf , " " ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
}
begindrawing ( ) ;
2006-11-13 23:12:47 +00:00
if ( ! strcmp ( tempbuf , " 0 " ) )
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " OFF " ) ;
2006-11-13 23:12:47 +00:00
else if ( ! strcmp ( tempbuf , " 1 " ) )
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " ON " ) ;
2006-11-13 23:12:47 +00:00
else if ( ! strcmp ( tempbuf , " 2 " ) )
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " ON (2) " ) ;
2008-05-22 10:08:17 +00:00
printext256 ( ( 20 + ( ( xdimgame > 640 ) * 20 ) ) * 8 + 2 , 8 + ( i * ( 8 + ( xdimgame > 640 ) ) ) + 2 , 0 , - 1 , tempbuf , ! ( xdimgame > 640 ) ) ;
printext256 ( ( 20 + ( ( xdimgame > 640 ) * 20 ) ) * 8 , 8 + ( i * ( 8 + ( xdimgame > 640 ) ) ) , whitecol , - 1 , tempbuf , ! ( xdimgame > 640 ) ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
}
}
/* if(purpleon) {
2007-08-25 01:05:00 +00:00
begindrawing ( ) ;
// printext256(1*4,1*8,whitecol,-1,"Purple ON",0);
2006-04-13 20:47:06 +00:00
sprintf ( getmessage , " Purple ON " ) ;
message ( getmessage ) ;
2007-08-25 01:05:00 +00:00
enddrawing ( ) ;
2006-04-13 20:47:06 +00:00
}
*/
2006-11-13 23:12:47 +00:00
if ( sector [ cursectnum ] . lotag = = 2 )
2006-04-13 20:47:06 +00:00
{
2008-07-25 13:42:37 +00:00
if ( sector [ cursectnum ] . ceilingpicnum = = FLOORSLIME ) SetSLIMEPalette ( ) ;
2006-04-13 20:47:06 +00:00
else SetWATERPalette ( ) ;
}
else SetGAMEPalette ( ) ;
2008-07-25 13:42:37 +00:00
if ( keystatus [ buildkeys [ BK_MODE2D_3D ] ] ) // Enter
SetGAMEPalette ( ) ;
2006-04-13 20:47:06 +00:00
//Stick this in 3D part of ExtCheckKeys
//Also choose your own key scan codes
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_D ] ) // ' d
2006-04-13 20:47:06 +00:00
/*
{
ShowHelpText ( " SectorEffector " ) ;
} */
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_D ] = 0 ;
2006-11-15 01:16:55 +00:00
skill + + ;
if ( skill > MAXSKILL - 1 ) skill = 0 ;
2008-06-09 23:41:54 +00:00
message ( " %s " , SKILLMODE [ skill ] ) ;
2006-04-13 20:47:06 +00:00
// printext256(1*4,1*8,11,-1,tempbuf,0);
}
2008-05-16 19:51:38 +00:00
/* if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_G]) // ' g <Unused>
{
keystatus [ KEYSC_G ] = 0 ;
tabgraphic + + ;
if ( tabgraphic > 2 ) tabgraphic = 0 ;
if ( tabgraphic ) message ( " Graphics ON " ) ;
else message ( " Graphics OFF " ) ;
} */
2006-04-13 20:47:06 +00:00
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_X ] ) // ' x
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_X ] = 0 ;
2006-04-13 20:47:06 +00:00
shadepreview = ! shadepreview ;
2008-06-05 02:29:18 +00:00
if ( shadepreview ) message ( " Map shade preview ON " ) ;
else message ( " Map shade preview OFF " ) ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 19:51:38 +00:00
/* if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_R]) // ' r <Handled already>
{
keystatus [ KEYSC_R ] = 0 ;
framerateon = ! framerateon ;
if ( framerateon ) message ( " Framerate ON " ) ;
else message ( " Framerate OFF " ) ;
} */
2006-04-13 20:47:06 +00:00
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_W ] ) // ' w
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_W ] = 0 ;
2006-11-15 01:16:55 +00:00
nosprites + + ;
if ( nosprites > 3 ) nosprites = 0 ;
2008-06-09 23:41:54 +00:00
message ( " %s " , SPRDSPMODE [ nosprites ] ) ;
2006-04-13 20:47:06 +00:00
// printext256(1*4,1*8,whitecol,-1,tempbuf,0);
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_Y ] ) // ' y
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_Y ] = 0 ;
2006-11-15 01:16:55 +00:00
purpleon = ! purpleon ;
if ( nosprites > 3 ) nosprites = 0 ;
2006-11-13 23:12:47 +00:00
if ( purpleon ) message ( " Purple ON " ) ;
2006-04-13 20:47:06 +00:00
else message ( " Purple OFF " ) ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_C ] ) // ' C
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_C ] = 0 ;
2006-04-13 20:47:06 +00:00
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
case 4 :
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXWALLS ; i + + )
2006-11-16 03:02:42 +00:00
{
if ( wall [ i ] . picnum = = temppicnum )
wall [ i ] . shade = tempshade ;
}
2008-06-09 23:41:54 +00:00
message ( " Walls with picnum %d have shade of %d " , temppicnum , tempshade ) ;
2008-05-16 00:23:33 +00:00
asksave = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
case 2 :
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSECTORS ; i + + )
2006-11-16 03:02:42 +00:00
{
if ( searchstat = = 1 )
if ( sector [ i ] . ceilingpicnum = = temppicnum )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ i ] . ceilingshade = tempshade ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
if ( searchstat = = 2 )
if ( sector [ i ] . floorpicnum = = temppicnum )
{
sector [ i ] . floorshade = tempshade ;
}
}
2008-06-09 23:41:54 +00:00
message ( " Sectors with picnum %d have shade of %d " , temppicnum , tempshade ) ;
2008-05-16 00:23:33 +00:00
asksave = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-11-16 03:02:42 +00:00
{
if ( sprite [ i ] . picnum = = temppicnum )
{
sprite [ i ] . shade = tempshade ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2008-06-09 23:41:54 +00:00
message ( " Sprites with picnum %d have shade of %d " , temppicnum , tempshade ) ;
2008-05-16 00:23:33 +00:00
asksave = 1 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_T ] ) // ' T
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_T ] = 0 ;
2006-04-13 20:47:06 +00:00
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
case 4 :
wall [ searchwall ] . lotag =
2008-09-03 10:47:19 +00:00
getnumber256 ( " Wall lotag: " , wall [ searchwall ] . lotag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
case 2 :
sector [ searchsector ] . lotag =
2008-09-03 10:47:19 +00:00
_getnumber256 ( " Sector lotag: " , sector [ searchsector ] . lotag , 65536L , 0 , ( void * ) ExtGetSectorType ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-09-03 10:47:19 +00:00
if ( sprite [ searchwall ] . picnum = = SECTOREFFECTOR )
sprite [ searchwall ] . lotag =
_getnumber256 ( " Sprite lotag: " , sprite [ searchwall ] . lotag , 65536L , 0 , ( void * ) SectorEffectorTagText ) ;
else
sprite [ searchwall ] . lotag =
getnumber256 ( " Sprite lotag: " , sprite [ searchwall ] . lotag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_H ] ) // ' H
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_H ] = 0 ;
2006-04-13 20:47:06 +00:00
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
case 4 :
wall [ searchwall ] . hitag =
2008-09-03 10:47:19 +00:00
getnumber256 ( " Wall hitag: " , wall [ searchwall ] . hitag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
case 2 :
sector [ searchsector ] . hitag =
2008-09-03 10:47:19 +00:00
getnumber256 ( " Sector hitag: " , sector [ searchsector ] . hitag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
sprite [ searchwall ] . hitag =
2008-09-03 10:47:19 +00:00
getnumber256 ( " Sprite hitag: " , sprite [ searchwall ] . hitag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_S ] ) // ' S
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_S ] = 0 ;
2006-04-13 20:47:06 +00:00
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
case 4 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Wall shade: " , & wall [ searchwall ] . shade , sizeof ( wall [ searchwall ] . shade ) , 128L , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Ceiling shade: " , & sector [ searchsector ] . ceilingshade , sizeof ( sector [ searchsector ] . ceilingshade ) , 128L , 1 , NULL ) ;
break ;
2006-11-16 03:02:42 +00:00
case 2 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Floor shade: " , & sector [ searchsector ] . floorshade , sizeof ( sector [ searchsector ] . floorshade ) , 128L , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Sprite shade: " , & sprite [ searchwall ] . shade , sizeof ( sprite [ searchwall ] . shade ) , 128L , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 19:51:38 +00:00
if ( keystatus [ KEYSC_F2 ] ) // F2
2006-04-13 20:47:06 +00:00
{
2008-05-17 01:37:17 +00:00
if ( eitherSHIFT )
2008-05-17 21:44:49 +00:00
infobox ^ = 1 ;
2009-02-19 16:47:54 +00:00
else if ( eitherCTRL )
infobox ^ = 2 ;
else usedcount = ! usedcount ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_F2 ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_TAB ] ) // TAB : USED
2006-04-13 20:47:06 +00:00
{
// usedcount=!usedcount;
count = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numwalls ; i + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( wall [ i ] . picnum = = temppicnum ) count + + ;
if ( wall [ i ] . overpicnum = = temppicnum ) count + + ;
2006-04-13 20:47:06 +00:00
}
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + ) // JBF 20040307: was numwalls, thanks Semicharm
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sector [ i ] . ceilingpicnum = = temppicnum ) count + + ;
if ( sector [ i ] . floorpicnum = = temppicnum ) count + + ;
2006-04-13 20:47:06 +00:00
}
statnum = 0 ; //status 1
i = headspritestat [ statnum ] ;
while ( i ! = - 1 )
{
nexti = nextspritestat [ i ] ;
//your code goes here
//ex: printf("Sprite %d has a status of 1 (active)\n",i,statnum);
2006-11-13 23:12:47 +00:00
if ( sprite [ i ] . picnum = = temppicnum ) count + + ;
2006-04-13 20:47:06 +00:00
i = nexti ;
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_F1 ] ) // F1
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
helpon = ! helpon ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_H ] = 0 ; // delete this line?
keystatus [ KEYSC_F1 ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_G ] ) // G
2006-07-04 00:46:24 +00:00
{
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Wall picnum: " , & wall [ searchwall ] . picnum , sizeof ( wall [ searchwall ] . picnum ) , MAXTILES - 1 , 0 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Sector ceiling picnum: " , & sector [ searchsector ] . ceilingpicnum , sizeof ( sector [ searchsector ] . ceilingpicnum ) , MAXTILES - 1 , 0 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Sector floor picnum: " , & sector [ searchsector ] . floorpicnum , sizeof ( sector [ searchsector ] . floorpicnum ) , MAXTILES - 1 , 0 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Sprite picnum: " , & sprite [ searchwall ] . picnum , sizeof ( sprite [ searchwall ] . picnum ) , MAXTILES - 1 , 0 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
case 4 :
2008-09-03 11:59:54 +00:00
getnumberptr256 ( " Masked wall picnum: " , & wall [ searchwall ] . overpicnum , sizeof ( wall [ searchwall ] . overpicnum ) , MAXTILES - 1 , 0 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
}
asksave = 1 ;
keystatus [ KEYSC_G ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_B ] ) // B (clip Blocking xor) (3D)
2006-11-16 03:02:42 +00:00
{
2006-07-04 00:46:24 +00:00
if ( searchstat = = 3 )
{
sprite [ searchwall ] . cstat ^ = 1 ;
// sprite[searchwall].cstat &= ~256;
// sprite[searchwall].cstat |= ((sprite[searchwall].cstat&1)<<8);
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d blocking bit %s " , searchwall , sprite [ searchwall ] . cstat & 1 ? " ON " : " OFF " ) ;
2006-07-04 00:46:24 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
else
{
wall [ searchwall ] . cstat ^ = 1 ;
// wall[searchwall].cstat &= ~64;
2008-05-16 00:23:33 +00:00
if ( ( wall [ searchwall ] . nextwall > = 0 ) & & ( eitherSHIFT = = 0 ) )
2006-07-04 00:46:24 +00:00
{
wall [ wall [ searchwall ] . nextwall ] . cstat & = ~ ( 1 + 64 ) ;
wall [ wall [ searchwall ] . nextwall ] . cstat | = ( wall [ searchwall ] . cstat & 1 ) ;
}
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Wall %d blocking bit %s " , searchwall , wall [ searchwall ] . cstat & 1 ? " ON " : " OFF " ) ;
2006-07-04 00:46:24 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
keystatus [ KEYSC_B ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_T ] ) // T (transluscence for sprites/masked walls)
2006-07-04 00:46:24 +00:00
{
if ( searchstat = = 1 ) //Set masked/transluscent ceilings/floors
{
i = ( sector [ searchsector ] . ceilingstat & ( 128 + 256 ) ) ;
sector [ searchsector ] . ceilingstat & = ~ ( 128 + 256 ) ;
2006-11-13 23:12:47 +00:00
switch ( i )
2006-07-04 00:46:24 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
sector [ searchsector ] . ceilingstat | = 128 ;
break ;
case 128 :
sector [ searchsector ] . ceilingstat | = 256 ;
break ;
case 256 :
sector [ searchsector ] . ceilingstat | = 384 ;
break ;
case 384 :
sector [ searchsector ] . ceilingstat | = 0 ;
break ;
2006-07-04 00:46:24 +00:00
}
asksave = 1 ;
}
if ( searchstat = = 2 )
{
i = ( sector [ searchsector ] . floorstat & ( 128 + 256 ) ) ;
sector [ searchsector ] . floorstat & = ~ ( 128 + 256 ) ;
2006-11-13 23:12:47 +00:00
switch ( i )
2006-07-04 00:46:24 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
sector [ searchsector ] . floorstat | = 128 ;
break ;
case 128 :
sector [ searchsector ] . floorstat | = 256 ;
break ;
case 256 :
sector [ searchsector ] . floorstat | = 384 ;
break ;
case 384 :
sector [ searchsector ] . floorstat | = 0 ;
break ;
2006-07-04 00:46:24 +00:00
}
asksave = 1 ;
}
2006-04-13 20:47:06 +00:00
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] )
2006-07-04 00:46:24 +00:00
{
switch ( searchstat )
{
2006-11-16 03:02:42 +00:00
case 0 :
case 4 :
strcpy ( buffer , " Wall lotag: " ) ;
2009-01-09 09:29:17 +00:00
wall [ searchwall ] . lotag = getnumber256 ( buffer , ( int32_t ) wall [ searchwall ] . lotag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
strcpy ( buffer , " Sector lotag: " ) ;
2009-01-09 09:29:17 +00:00
sector [ searchsector ] . lotag = getnumber256 ( buffer , ( int32_t ) sector [ searchsector ] . lotag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
strcpy ( buffer , " Sector lotag: " ) ;
2009-01-09 09:29:17 +00:00
sector [ searchsector ] . lotag = getnumber256 ( buffer , ( int32_t ) sector [ searchsector ] . lotag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
strcpy ( buffer , " Sprite lotag: " ) ;
2009-01-09 09:29:17 +00:00
sprite [ searchwall ] . lotag = getnumber256 ( buffer , ( int32_t ) sprite [ searchwall ] . lotag , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-07-04 00:46:24 +00:00
}
}
2008-09-06 06:22:31 +00:00
else if ( eitherCTRL )
{
if ( searchstat = = 3 )
rendertext ( searchwall ) ;
}
2006-07-04 00:46:24 +00:00
else
{
if ( searchstat = = 3 )
{
if ( ( sprite [ searchwall ] . cstat & 2 ) = = 0 )
sprite [ searchwall ] . cstat | = 2 ;
else if ( ( sprite [ searchwall ] . cstat & 512 ) = = 0 )
sprite [ searchwall ] . cstat | = 512 ;
else
sprite [ searchwall ] . cstat & = ~ ( 2 + 512 ) ;
asksave = 1 ;
}
if ( searchstat = = 4 )
{
if ( ( wall [ searchwall ] . cstat & 128 ) = = 0 )
wall [ searchwall ] . cstat | = 128 ;
else if ( ( wall [ searchwall ] . cstat & 512 ) = = 0 )
wall [ searchwall ] . cstat | = 512 ;
else
wall [ searchwall ] . cstat & = ~ ( 128 + 512 ) ;
2006-04-13 20:47:06 +00:00
2006-07-04 00:46:24 +00:00
if ( wall [ searchwall ] . nextwall > = 0 )
{
wall [ wall [ searchwall ] . nextwall ] . cstat & = ~ ( 128 + 512 ) ;
wall [ wall [ searchwall ] . nextwall ] . cstat | = ( wall [ searchwall ] . cstat & ( 128 + 512 ) ) ;
}
asksave = 1 ;
}
}
keystatus [ KEYSC_T ] = 0 ;
}
2006-04-13 20:47:06 +00:00
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_ENTER ] ) // ' ENTER
2006-04-13 20:47:06 +00:00
{
2008-05-16 19:51:38 +00:00
message ( " Pasted picnum only " ) ;
2006-11-13 23:12:47 +00:00
switch ( searchstat )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
wall [ searchwall ] . picnum = temppicnum ;
break ;
case 1 :
sector [ searchsector ] . ceilingpicnum = temppicnum ;
break ;
case 2 :
sector [ searchsector ] . floorpicnum = temppicnum ;
break ;
case 3 :
sprite [ searchwall ] . picnum = temppicnum ;
break ;
case 4 :
wall [ searchwall ] . overpicnum = temppicnum ;
break ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ENTER ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 19:51:38 +00:00
i = 512 ;
if ( keystatus [ KEYSC_RSHIFT ] ) i = 8 ;
if ( keystatus [ KEYSC_LSHIFT ] ) i = 1 ;
mouseaction = 0 ;
if ( eitherCTRL & & bstatus & 1 & & ( searchstat = = 1 | | searchstat = = 2 ) )
2006-07-20 05:02:55 +00:00
{
2009-02-19 16:47:54 +00:00
mousex = 0 ; mskip = 1 ;
2008-05-16 19:51:38 +00:00
if ( mousey < 0 )
2006-07-20 05:02:55 +00:00
{
2008-05-16 19:51:38 +00:00
i = klabs ( mousey * 2 ) ;
mouseaction = 1 ;
2006-07-20 05:02:55 +00:00
}
2008-05-16 19:51:38 +00:00
}
if ( keystatus [ KEYSC_LBRACK ] | | mouseaction ) // [
{
keystatus [ KEYSC_LBRACK ] = 0 ;
if ( eitherALT )
2006-07-20 05:02:55 +00:00
{
2008-05-16 19:51:38 +00:00
i = wall [ searchwall ] . nextsector ;
if ( i > = 0 )
switch ( searchstat )
{
case 0 :
case 1 :
case 4 :
alignceilslope ( searchsector , wall [ searchwall ] . x , wall [ searchwall ] . y , getceilzofslope ( i , wall [ searchwall ] . x , wall [ searchwall ] . y ) ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d align ceiling to wall %d " , searchsector , searchwall ) ;
2008-05-16 19:51:38 +00:00
break ;
case 2 :
alignflorslope ( searchsector , wall [ searchwall ] . x , wall [ searchwall ] . y , getflorzofslope ( i , wall [ searchwall ] . x , wall [ searchwall ] . y ) ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d align floor to wall %d " , searchsector , searchwall ) ;
2008-05-16 19:51:38 +00:00
break ;
}
2006-07-20 05:02:55 +00:00
}
2008-05-16 19:51:38 +00:00
else
2006-07-20 05:02:55 +00:00
{
2008-05-16 19:51:38 +00:00
if ( searchstat = = 1 )
{
if ( ! ( sector [ searchsector ] . ceilingstat & 2 ) )
sector [ searchsector ] . ceilingheinum = 0 ;
sector [ searchsector ] . ceilingheinum = max ( sector [ searchsector ] . ceilingheinum - i , - 32768 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d ceiling slope = %d " , searchsector , sector [ searchsector ] . ceilingheinum ) ;
2008-05-16 19:51:38 +00:00
}
if ( searchstat = = 2 )
{
if ( ! ( sector [ searchsector ] . floorstat & 2 ) )
sector [ searchsector ] . floorheinum = 0 ;
sector [ searchsector ] . floorheinum = max ( sector [ searchsector ] . floorheinum - i , - 32768 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d floor slope = %d " , searchsector , sector [ searchsector ] . floorheinum ) ;
2008-05-16 19:51:38 +00:00
}
2006-07-20 05:02:55 +00:00
}
2008-05-16 19:51:38 +00:00
if ( sector [ searchsector ] . ceilingheinum = = 0 )
sector [ searchsector ] . ceilingstat & = ~ 2 ;
else
sector [ searchsector ] . ceilingstat | = 2 ;
if ( sector [ searchsector ] . floorheinum = = 0 )
sector [ searchsector ] . floorstat & = ~ 2 ;
else
sector [ searchsector ] . floorstat | = 2 ;
asksave = 1 ;
2006-07-20 05:02:55 +00:00
}
2008-05-16 19:51:38 +00:00
i = 512 ;
if ( keystatus [ KEYSC_RSHIFT ] ) i = 8 ;
if ( keystatus [ KEYSC_LSHIFT ] ) i = 1 ;
mouseaction = 0 ;
if ( eitherCTRL & & bstatus & 1 & & ( searchstat = = 1 | | searchstat = = 2 ) )
2006-04-13 20:47:06 +00:00
{
2009-02-19 16:47:54 +00:00
mousex = 0 ; mskip = 1 ;
2008-05-16 19:51:38 +00:00
if ( mousey > 0 )
2006-04-13 20:47:06 +00:00
{
2008-05-16 19:51:38 +00:00
i = klabs ( mousey * 2 ) ;
mouseaction = 1 ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 19:51:38 +00:00
if ( keystatus [ KEYSC_RBRACK ] | | mouseaction ) // ]
2006-04-13 20:47:06 +00:00
{
2008-05-16 19:51:38 +00:00
keystatus [ KEYSC_RBRACK ] = 0 ;
if ( eitherALT )
2006-04-13 20:47:06 +00:00
{
2008-05-16 19:51:38 +00:00
i = wall [ searchwall ] . nextsector ;
if ( i > = 0 )
switch ( searchstat )
{
case 1 :
alignceilslope ( searchsector , wall [ searchwall ] . x , wall [ searchwall ] . y , getceilzofslope ( i , wall [ searchwall ] . x , wall [ searchwall ] . y ) ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d align ceiling to wall %d " , searchsector , searchwall ) ;
2008-05-16 19:51:38 +00:00
break ;
case 0 :
case 2 :
case 4 :
alignflorslope ( searchsector , wall [ searchwall ] . x , wall [ searchwall ] . y , getflorzofslope ( i , wall [ searchwall ] . x , wall [ searchwall ] . y ) ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d align floor to wall %d " , searchsector , searchwall ) ;
2008-05-16 19:51:38 +00:00
break ;
}
}
else
{
if ( searchstat = = 1 )
2006-04-13 20:47:06 +00:00
{
2008-05-16 19:51:38 +00:00
if ( ! ( sector [ searchsector ] . ceilingstat & 2 ) )
sector [ searchsector ] . ceilingheinum = 0 ;
sector [ searchsector ] . ceilingheinum = min ( sector [ searchsector ] . ceilingheinum + i , 32767 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d ceiling slope = %d " , searchsector , sector [ searchsector ] . ceilingheinum ) ;
2008-05-16 19:51:38 +00:00
}
if ( searchstat = = 2 )
{
if ( ! ( sector [ searchsector ] . floorstat & 2 ) )
sector [ searchsector ] . floorheinum = 0 ;
sector [ searchsector ] . floorheinum = min ( sector [ searchsector ] . floorheinum + i , 32767 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d floor slope = %d " , searchsector , sector [ searchsector ] . floorheinum ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 19:51:38 +00:00
if ( sector [ searchsector ] . ceilingheinum = = 0 )
sector [ searchsector ] . ceilingstat & = ~ 2 ;
else
sector [ searchsector ] . ceilingstat | = 2 ;
2006-04-13 20:47:06 +00:00
2008-05-16 19:51:38 +00:00
if ( sector [ searchsector ] . floorheinum = = 0 )
sector [ searchsector ] . floorstat & = ~ 2 ;
else
sector [ searchsector ] . floorstat | = 2 ;
2006-04-13 20:47:06 +00:00
2008-05-16 19:51:38 +00:00
asksave = 1 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 19:51:38 +00:00
if ( bstatus & 1 & & eitherSHIFT ) mskip = 1 ;
if ( bstatus & 1 & & eitherSHIFT & & ( searchstat = = 1 | | searchstat = = 2 ) & & ( mousex | mousey ) )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t fw , x1 , y1 , x2 , y2 , stat , ma , a = 0 ;
2008-05-16 19:51:38 +00:00
stat = ( searchstat = = 2 ) ? sector [ searchsector ] . floorstat : sector [ searchsector ] . ceilingstat ;
if ( stat & 64 ) // align to first wall
2006-04-13 20:47:06 +00:00
{
2008-05-16 19:51:38 +00:00
fw = sector [ searchsector ] . wallptr ;
x1 = wall [ fw ] . x , y1 = wall [ fw ] . y ;
x2 = wall [ wall [ fw ] . point2 ] . x , y2 = wall [ wall [ fw ] . point2 ] . y ;
a = getangle ( x1 - x2 , y1 - y2 ) ;
}
2009-02-19 16:47:54 +00:00
mouseax + = mousex ; mouseay + = mousey ;
2008-05-16 19:51:38 +00:00
ma = getangle ( mouseax , mouseay ) ;
ma + = ang - a ;
i = stat ;
i = ( i & 0x4 ) + ( ( i > > 4 ) & 3 ) ;
if ( stat & 64 ) // align to first wall
switch ( i )
2006-04-13 20:47:06 +00:00
{
2008-05-16 19:51:38 +00:00
case 0 : break ;
2009-02-19 16:47:54 +00:00
case 1 : ma = - ma ; break ;
case 2 : ma = 1024 - ma ; break ;
case 3 : ma + = 1024 ; break ;
case 4 : ma = - 512 - ma ; break ;
case 5 : ma + = 512 ; break ;
case 6 : ma - = 512 ; break ;
case 7 : ma = 512 - ma ; break ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 19:51:38 +00:00
else
switch ( i )
2006-04-13 20:47:06 +00:00
{
2009-02-19 16:47:54 +00:00
case 0 : ma = - ma ; break ;
2008-05-16 19:51:38 +00:00
case 1 : break ;
2009-02-19 16:47:54 +00:00
case 2 : ma + = 1024 ; break ;
case 3 : ma = 1024 - ma ; break ;
case 4 : ma - = 512 ; break ;
case 5 : ma = 512 - ma ; break ;
case 6 : ma = - 512 - ma ; break ;
case 7 : ma + = 512 ; break ;
2008-05-16 19:51:38 +00:00
}
a = ksqrt ( mouseax * mouseax + mouseay * mouseay ) ;
if ( a )
{
2009-01-09 09:29:17 +00:00
int32_t mult = ( stat & 8 ) ? 8192 : 8192 * 2 ;
2008-05-16 19:51:38 +00:00
x1 = - a * sintable [ ( ma + 2048 ) & 2047 ] / mult ;
y1 = - a * sintable [ ( ma + 1536 ) & 2047 ] / mult ;
if ( x1 | | y1 )
{
2009-02-19 16:47:54 +00:00
mouseax = 0 ; mouseay = 0 ;
2008-05-16 19:51:38 +00:00
if ( searchstat = = 1 )
{
2009-02-19 16:47:54 +00:00
changedir = 1 ; if ( x1 < 0 ) { changedir = - 1 ; x1 * = - 1 ; }
2008-05-16 19:51:38 +00:00
while ( x1 - - ) sector [ searchsector ] . ceilingxpanning = changechar ( sector [ searchsector ] . ceilingxpanning , changedir , 0 , 0 ) ;
2009-02-19 16:47:54 +00:00
changedir = 1 ; if ( y1 < 0 ) { changedir = - 1 ; y1 * = - 1 ; }
2008-05-16 19:51:38 +00:00
while ( y1 - - ) sector [ searchsector ] . ceilingypanning = changechar ( sector [ searchsector ] . ceilingypanning , changedir , 0 , 0 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d ceiling panning: %d, %d " , searchsector , sector [ searchsector ] . ceilingxpanning , sector [ searchsector ] . ceilingypanning ) ;
2008-05-16 19:51:38 +00:00
}
else
{
2009-02-19 16:47:54 +00:00
changedir = 1 ; if ( x1 < 0 ) { changedir = - 1 ; x1 * = - 1 ; }
2008-05-16 19:51:38 +00:00
while ( x1 - - ) sector [ searchsector ] . floorxpanning = changechar ( sector [ searchsector ] . floorxpanning , changedir , 0 , 0 ) ;
2009-02-19 16:47:54 +00:00
changedir = 1 ; if ( y1 < 0 ) { changedir = - 1 ; y1 * = - 1 ; }
2008-05-16 19:51:38 +00:00
while ( y1 - - ) sector [ searchsector ] . floorypanning = changechar ( sector [ searchsector ] . floorypanning , changedir , 0 , 0 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d floor panning: %d, %d " , searchsector , sector [ searchsector ] . floorxpanning , sector [ searchsector ] . floorypanning ) ;
2008-05-16 19:51:38 +00:00
}
asksave = 1 ;
}
}
2009-02-19 16:47:54 +00:00
mousex = 0 ; mousey = 0 ;
2008-05-16 19:51:38 +00:00
}
2009-02-19 16:47:54 +00:00
if ( ! mouseb ) { mouseax = 0 ; mouseay = 0 ; }
2008-05-16 19:51:38 +00:00
smooshyalign = keystatus [ KEYSC_gKP5 ] ;
repeatpanalign = eitherSHIFT ;
updownunits = 1 ;
mouseaction = 0 ;
if ( bstatus & 1 & & searchstat ! = 1 & & searchstat ! = 2 )
{
if ( eitherSHIFT )
{
mskip = 1 ;
if ( mousex ! = 0 )
{
mouseaction = 1 ;
mouseax + = mousex ;
2009-01-09 09:29:17 +00:00
updownunits = klabs ( ( int32_t ) ( mouseax / 2. ) ) ;
2008-05-16 19:51:38 +00:00
if ( updownunits ) { mouseax = 0 ; }
}
}
2009-02-19 16:47:54 +00:00
else if ( eitherCTRL )
{
mskip = 1 ;
if ( mousex ! = 0 )
2008-05-16 19:51:38 +00:00
{
2009-02-19 16:47:54 +00:00
mouseaction = 2 ;
repeatpanalign = 0 ;
if ( searchstat = = 3 )
2008-05-16 19:51:38 +00:00
{
2009-02-19 16:47:54 +00:00
updownunits = klabs ( mouseax + = mousex ) / 4 ;
if ( updownunits ) mouseax = 0 ;
}
else
{
updownunits = klabs ( mouseax + = mousex ) / 16 ;
if ( updownunits ) mouseax = 0 ;
2008-05-16 19:51:38 +00:00
}
}
2009-02-19 16:47:54 +00:00
}
2008-05-16 19:51:38 +00:00
}
if ( keystatus [ KEYSC_gLEFT ] | | keystatus [ KEYSC_gRIGHT ] | | mouseaction ) // 4 & 6 (keypad)
{
if ( ( repeatcountx = = 0 ) | | ( repeatcountx > 32 ) | | mouseaction )
{
changedir = 0 ;
if ( keystatus [ KEYSC_gLEFT ] | | mousex > 0 ) changedir = - 1 ;
if ( keystatus [ KEYSC_gRIGHT ] | | mousex < 0 ) changedir = 1 ;
if ( ( searchstat = = 0 ) | | ( searchstat = = 4 ) )
{
if ( repeatpanalign = = 0 )
{
while ( updownunits - - ) wall [ searchwall ] . xrepeat = changechar ( wall [ searchwall ] . xrepeat , changedir , smooshyalign , 1 ) ;
2008-06-09 23:41:54 +00:00
message ( " Wall %d repeat: %d, %d " , searchwall , wall [ searchwall ] . xrepeat , wall [ searchwall ] . yrepeat ) ;
2008-05-16 19:51:38 +00:00
}
else
{
if ( mouseaction )
{
i = wall [ searchwall ] . cstat ;
i = ( ( i > > 3 ) & 1 ) + ( ( i > > 7 ) & 2 ) ;
if ( i = = 1 | | i = = 3 ) changedir * = - 1 ;
}
while ( updownunits - - ) wall [ searchwall ] . xpanning = changechar ( wall [ searchwall ] . xpanning , changedir , smooshyalign , 0 ) ;
2008-06-09 23:41:54 +00:00
message ( " Wall %d panning: %d, %d " , searchwall , wall [ searchwall ] . xpanning , wall [ searchwall ] . ypanning ) ;
2008-05-16 19:51:38 +00:00
}
}
if ( ( searchstat = = 1 ) | | ( searchstat = = 2 ) )
{
if ( searchstat = = 1 )
{
while ( updownunits - - ) sector [ searchsector ] . ceilingxpanning = changechar ( sector [ searchsector ] . ceilingxpanning , changedir , smooshyalign , 0 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d ceiling panning: %d, %d " , searchsector , sector [ searchsector ] . ceilingxpanning , sector [ searchsector ] . ceilingypanning ) ;
2008-05-16 19:51:38 +00:00
}
else
{
while ( updownunits - - ) sector [ searchsector ] . floorxpanning = changechar ( sector [ searchsector ] . floorxpanning , changedir , smooshyalign , 0 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d floor panning: %d, %d " , searchsector , sector [ searchsector ] . floorxpanning , sector [ searchsector ] . floorypanning ) ;
2008-05-16 19:51:38 +00:00
}
}
if ( searchstat = = 3 )
{
if ( mouseaction = = 1 )
{
2009-01-09 09:29:17 +00:00
int32_t xvect , yvect ;
int16_t cursectnum = sprite [ searchwall ] . sectnum ;
xvect = - ( ( mousex * ( int32_t ) sintable [ ( ang + 2048 ) & 2047 ] ) < < 3 ) ;
yvect = - ( ( mousex * ( int32_t ) sintable [ ( ang + 1536 ) & 2047 ] ) < < 3 ) ;
2009-01-13 12:23:18 +00:00
clipmove ( ( vec3_t * ) & sprite [ searchwall ] ,
2008-05-18 21:09:30 +00:00
& cursectnum , xvect , yvect , 128L , 4L < < 8 , 4L < < 8 , spnoclip ? 1 : CLIPMASK0 ) ;
2009-01-13 12:23:18 +00:00
setsprite ( searchwall , ( vec3_t * ) & sprite [ searchwall ] ) ;
2008-05-16 19:51:38 +00:00
}
else
{
if ( mouseaction = = 2 ) changedir * = - 1 ;
while ( updownunits - - ) sprite [ searchwall ] . xrepeat = changechar ( sprite [ searchwall ] . xrepeat , changedir , smooshyalign , 1 ) ;
if ( sprite [ searchwall ] . xrepeat < 4 )
sprite [ searchwall ] . xrepeat = 4 ;
2008-06-09 23:41:54 +00:00
message ( " Sprite %d repeat: %d, %d " , searchwall , sprite [ searchwall ] . xrepeat , sprite [ searchwall ] . yrepeat ) ;
2008-05-16 19:51:38 +00:00
}
}
asksave = 1 ;
repeatcountx = max ( 1 , repeatcountx - 2 ) ;
}
repeatcountx + = synctics ;
}
else
repeatcountx = 0 ;
updownunits = 1 ;
mouseaction = 0 ;
if ( bstatus & 1 & & searchstat ! = 1 & & searchstat ! = 2 )
{
if ( eitherSHIFT )
{
mskip = 1 ;
if ( mousey ! = 0 )
{
mouseaction = 1 ;
updownunits = klabs ( mousey ) ;
if ( searchstat ! = 3 )
{
2009-01-09 09:29:17 +00:00
updownunits = klabs ( ( int32_t ) ( mousey * 128. / tilesizy [ wall [ searchwall ] . picnum ] ) ) ;
2008-05-16 19:51:38 +00:00
}
}
}
2009-02-19 16:47:54 +00:00
else if ( eitherCTRL )
{
mskip = 1 ;
if ( mousey ! = 0 )
2008-05-16 19:51:38 +00:00
{
2009-02-19 16:47:54 +00:00
mouseaction = 2 ;
repeatpanalign = 0 ;
if ( searchstat = = 3 )
2008-05-16 19:51:38 +00:00
{
2009-02-19 16:47:54 +00:00
updownunits = klabs ( mouseay + = mousey ) / 4 ;
if ( updownunits ) mouseay = 0 ;
}
else
{
updownunits = klabs ( mouseay + = mousey ) / 32 ;
if ( updownunits ) mouseay = 0 ;
2008-05-16 19:51:38 +00:00
}
}
2009-02-19 16:47:54 +00:00
}
2008-05-16 19:51:38 +00:00
}
2009-02-19 16:47:54 +00:00
if ( ! mouseb ) { mouseax = 0 ; mouseay = 0 ; }
2008-05-16 19:51:38 +00:00
if ( keystatus [ KEYSC_gUP ] | | keystatus [ KEYSC_gDOWN ] | | mouseaction ) // 2 & 8 (keypad)
{
if ( ( repeatcounty = = 0 ) | | ( repeatcounty > 32 ) | | mouseaction )
{
changedir = 0 ;
if ( keystatus [ KEYSC_gUP ] | | mousey > 0 ) changedir = - 1 ;
if ( keystatus [ KEYSC_gDOWN ] | | mousey < 0 ) changedir = 1 ;
if ( ( searchstat = = 0 ) | | ( searchstat = = 4 ) )
{
if ( repeatpanalign = = 0 )
{
2008-12-28 23:27:24 +00:00
while ( updownunits - - )
wall [ searchwall ] . yrepeat = changechar ( wall [ searchwall ] . yrepeat , changedir , smooshyalign , 1 ) ;
2008-06-09 23:41:54 +00:00
message ( " Wall %d repeat: %d, %d " , searchwall , wall [ searchwall ] . xrepeat , wall [ searchwall ] . yrepeat ) ;
2008-05-16 19:51:38 +00:00
}
else
{
2008-12-28 23:27:24 +00:00
while ( updownunits - - )
wall [ searchwall ] . ypanning = changechar ( wall [ searchwall ] . ypanning , changedir , smooshyalign , 0 ) ;
2008-06-09 23:41:54 +00:00
message ( " Wall %d panning: %d, %d " , searchwall , wall [ searchwall ] . xpanning , wall [ searchwall ] . ypanning ) ;
2008-05-16 19:51:38 +00:00
}
}
if ( ( searchstat = = 1 ) | | ( searchstat = = 2 ) )
{
if ( searchstat = = 1 )
{
2008-12-28 23:27:24 +00:00
while ( updownunits - - )
sector [ searchsector ] . ceilingypanning = changechar ( sector [ searchsector ] . ceilingypanning , changedir , smooshyalign , 0 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d ceiling panning: %d, %d " , searchsector , sector [ searchsector ] . ceilingxpanning , sector [ searchsector ] . ceilingypanning ) ;
2008-05-16 19:51:38 +00:00
}
else
{
2008-12-28 23:27:24 +00:00
while ( updownunits - - )
sector [ searchsector ] . floorypanning = changechar ( sector [ searchsector ] . floorypanning , changedir , smooshyalign , 0 ) ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d floor panning: %d, %d " , searchsector , sector [ searchsector ] . floorxpanning , sector [ searchsector ] . floorypanning ) ;
2008-05-16 19:51:38 +00:00
}
}
if ( searchstat = = 3 )
{
if ( mouseaction = = 1 )
{
2009-01-09 09:29:17 +00:00
int32_t xvect , yvect ;
int16_t cursectnum = sprite [ searchwall ] . sectnum ;
xvect = - ( ( mousey * ( int32_t ) sintable [ ( ang + 2560 ) & 2047 ] ) < < 3 ) ;
yvect = - ( ( mousey * ( int32_t ) sintable [ ( ang + 2048 ) & 2047 ] ) < < 3 ) ;
2009-01-13 12:23:18 +00:00
clipmove ( ( vec3_t * ) & sprite [ searchwall ] ,
2008-05-18 21:09:30 +00:00
& cursectnum , xvect , yvect , 128L , 4L < < 8 , 4L < < 8 , spnoclip ? 1 : CLIPMASK0 ) ;
2009-01-13 12:23:18 +00:00
setsprite ( searchwall , ( vec3_t * ) & sprite [ searchwall ] ) ;
2008-05-16 19:51:38 +00:00
}
else
{
while ( updownunits - - ) sprite [ searchwall ] . yrepeat = changechar ( sprite [ searchwall ] . yrepeat , changedir , smooshyalign , 1 ) ;
if ( sprite [ searchwall ] . yrepeat < 4 )
sprite [ searchwall ] . yrepeat = 4 ;
2008-06-09 23:41:54 +00:00
message ( " Sprite %d repeat: %d, %d " , searchwall , sprite [ searchwall ] . xrepeat , sprite [ searchwall ] . yrepeat ) ;
2008-05-16 19:51:38 +00:00
}
}
asksave = 1 ;
repeatcounty = max ( 1 , repeatcounty - 2 ) ;
}
repeatcounty + = synctics ;
}
else
repeatcounty = 0 ;
if ( keystatus [ KEYSC_F11 ] ) //F11 - brightness
{
2009-01-09 09:29:17 +00:00
extern int16_t brightness ;
2008-05-16 19:51:38 +00:00
keystatus [ KEYSC_F11 ] = 0 ;
2008-08-16 07:53:29 +00:00
if ( eitherSHIFT )
{
brightness - - ;
if ( brightness < 0 ) brightness = 15 ;
}
else
{
brightness + + ;
if ( brightness > = 16 ) brightness = 0 ;
}
2008-08-19 11:05:21 +00:00
2008-08-12 22:38:50 +00:00
vid_gamma = 1.0 + ( ( float ) brightness / 10.0 ) ;
2008-05-16 19:51:38 +00:00
setbrightness ( brightness , palette , 0 ) ;
2008-08-12 22:38:50 +00:00
message ( " Brightness: %d/16 " , brightness + 1 ) ;
2008-05-16 19:51:38 +00:00
}
if ( keystatus [ KEYSC_TAB ] ) //TAB
{
if ( searchstat = = 0 )
{
temppicnum = wall [ searchwall ] . picnum ;
tempshade = wall [ searchwall ] . shade ;
temppal = wall [ searchwall ] . pal ;
tempxrepeat = wall [ searchwall ] . xrepeat ;
tempyrepeat = wall [ searchwall ] . yrepeat ;
tempcstat = wall [ searchwall ] . cstat ;
templotag = wall [ searchwall ] . lotag ;
temphitag = wall [ searchwall ] . hitag ;
tempextra = wall [ searchwall ] . extra ;
}
if ( searchstat = = 1 )
{
temppicnum = sector [ searchsector ] . ceilingpicnum ;
tempshade = sector [ searchsector ] . ceilingshade ;
temppal = sector [ searchsector ] . ceilingpal ;
tempvis = sector [ searchsector ] . visibility ;
tempxrepeat = sector [ searchsector ] . ceilingxpanning ;
tempyrepeat = sector [ searchsector ] . ceilingypanning ;
tempcstat = sector [ searchsector ] . ceilingstat ;
templotag = sector [ searchsector ] . lotag ;
temphitag = sector [ searchsector ] . hitag ;
tempextra = sector [ searchsector ] . extra ;
}
if ( searchstat = = 2 )
{
temppicnum = sector [ searchsector ] . floorpicnum ;
tempshade = sector [ searchsector ] . floorshade ;
temppal = sector [ searchsector ] . floorpal ;
tempvis = sector [ searchsector ] . visibility ;
tempxrepeat = sector [ searchsector ] . floorxpanning ;
tempyrepeat = sector [ searchsector ] . floorypanning ;
tempcstat = sector [ searchsector ] . floorstat ;
templotag = sector [ searchsector ] . lotag ;
temphitag = sector [ searchsector ] . hitag ;
tempextra = sector [ searchsector ] . extra ;
}
if ( searchstat = = 3 )
{
temppicnum = sprite [ searchwall ] . picnum ;
tempshade = sprite [ searchwall ] . shade ;
temppal = sprite [ searchwall ] . pal ;
tempxrepeat = sprite [ searchwall ] . xrepeat ;
tempyrepeat = sprite [ searchwall ] . yrepeat ;
tempcstat = sprite [ searchwall ] . cstat ;
templotag = sprite [ searchwall ] . lotag ;
temphitag = sprite [ searchwall ] . hitag ;
tempextra = sprite [ searchwall ] . extra ;
2008-08-28 15:04:16 +00:00
tempxvel = sprite [ searchwall ] . xvel ;
tempyvel = sprite [ searchwall ] . xvel ;
tempzvel = sprite [ searchwall ] . xvel ;
2008-05-16 19:51:38 +00:00
}
if ( searchstat = = 4 )
{
temppicnum = wall [ searchwall ] . overpicnum ;
tempshade = wall [ searchwall ] . shade ;
temppal = wall [ searchwall ] . pal ;
tempxrepeat = wall [ searchwall ] . xrepeat ;
tempyrepeat = wall [ searchwall ] . yrepeat ;
tempcstat = wall [ searchwall ] . cstat ;
templotag = wall [ searchwall ] . lotag ;
temphitag = wall [ searchwall ] . hitag ;
tempextra = wall [ searchwall ] . extra ;
}
somethingintab = searchstat ;
keystatus [ KEYSC_TAB ] = 0 ;
}
if ( keystatus [ KEYSC_ENTER ] )
{
extern char pskysearch [ MAXSECTORS ] ;
2009-01-09 09:29:17 +00:00
int16_t daang ;
int32_t dashade [ 2 ] ;
2008-05-16 19:51:38 +00:00
if ( eitherSHIFT )
{
if ( ( ( searchstat = = 0 ) | | ( searchstat = = 4 ) ) & & eitherCTRL ) //Ctrl-shift Enter (auto-shade)
{
dashade [ 0 ] = 127 ;
dashade [ 1 ] = - 128 ;
i = searchwall ;
do
{
2009-01-09 09:29:17 +00:00
if ( ( int32_t ) wall [ i ] . shade < dashade [ 0 ] ) dashade [ 0 ] = wall [ i ] . shade ;
if ( ( int32_t ) wall [ i ] . shade > dashade [ 1 ] ) dashade [ 1 ] = wall [ i ] . shade ;
2008-05-16 19:51:38 +00:00
i = wall [ i ] . point2 ;
}
while ( i ! = searchwall ) ;
daang = getangle ( wall [ wall [ searchwall ] . point2 ] . x - wall [ searchwall ] . x , wall [ wall [ searchwall ] . point2 ] . y - wall [ searchwall ] . y ) ;
i = searchwall ;
do
{
j = getangle ( wall [ wall [ i ] . point2 ] . x - wall [ i ] . x , wall [ wall [ i ] . point2 ] . y - wall [ i ] . y ) ;
k = ( ( j + 2048 - daang ) & 2047 ) ;
if ( k > 1024 )
k = 2048 - k ;
wall [ i ] . shade = dashade [ 0 ] + mulscale10 ( k , dashade [ 1 ] - dashade [ 0 ] ) ;
i = wall [ i ] . point2 ;
}
while ( i ! = searchwall ) ;
2008-06-09 23:41:54 +00:00
message ( " Wall %d auto-shaded " , searchwall ) ;
2008-05-16 19:51:38 +00:00
}
else if ( somethingintab < 255 )
{
if ( searchstat = = 0 ) wall [ searchwall ] . shade = tempshade , wall [ searchwall ] . pal = temppal ;
if ( searchstat = = 1 )
{
sector [ searchsector ] . ceilingshade = tempshade , sector [ searchsector ] . ceilingpal = temppal ;
if ( ( somethingintab = = 1 ) | | ( somethingintab = = 2 ) )
sector [ searchsector ] . visibility = tempvis ;
}
if ( searchstat = = 2 )
{
sector [ searchsector ] . floorshade = tempshade , sector [ searchsector ] . floorpal = temppal ;
if ( ( somethingintab = = 1 ) | | ( somethingintab = = 2 ) )
sector [ searchsector ] . visibility = tempvis ;
}
if ( searchstat = = 3 ) sprite [ searchwall ] . shade = tempshade , sprite [ searchwall ] . pal = temppal ;
if ( searchstat = = 4 ) wall [ searchwall ] . shade = tempshade , wall [ searchwall ] . pal = temppal ;
message ( " Pasted shading+pal " ) ;
}
}
else if ( ( ( searchstat = = 0 ) | | ( searchstat = = 4 ) ) & & eitherCTRL & & ( somethingintab < 255 ) ) //Either ctrl key
{
i = searchwall ;
do
{
wall [ i ] . picnum = temppicnum ;
wall [ i ] . shade = tempshade ;
wall [ i ] . pal = temppal ;
if ( ( somethingintab = = 0 ) | | ( somethingintab = = 4 ) )
{
wall [ i ] . xrepeat = tempxrepeat ;
wall [ i ] . yrepeat = tempyrepeat ;
wall [ i ] . cstat = tempcstat ;
}
2009-01-09 09:29:17 +00:00
fixrepeats ( ( int16_t ) i ) ;
2008-05-16 19:51:38 +00:00
i = wall [ i ] . point2 ;
}
while ( i ! = searchwall ) ;
message ( " Pasted picnum+shading+pal " ) ;
}
else if ( ( ( searchstat = = 1 ) | | ( searchstat = = 2 ) ) & & eitherCTRL & & ( somethingintab < 255 ) ) //Either ctrl key
{
2009-01-09 09:29:17 +00:00
clearbuf ( & pskysearch [ 0 ] , ( int32_t ) ( ( numsectors + 3 ) > > 2 ) , 0L ) ;
2008-05-16 19:51:38 +00:00
if ( searchstat = = 1 )
{
i = searchsector ;
if ( ( sector [ i ] . ceilingstat & 1 ) > 0 )
pskysearch [ i ] = 1 ;
while ( pskysearch [ i ] = = 1 )
{
sector [ i ] . ceilingpicnum = temppicnum ;
sector [ i ] . ceilingshade = tempshade ;
sector [ i ] . ceilingpal = temppal ;
if ( ( somethingintab = = 1 ) | | ( somethingintab = = 2 ) )
{
sector [ i ] . ceilingxpanning = tempxrepeat ;
sector [ i ] . ceilingypanning = tempyrepeat ;
sector [ i ] . ceilingstat = tempcstat ;
}
pskysearch [ i ] = 2 ;
startwall = sector [ i ] . wallptr ;
endwall = startwall + sector [ i ] . wallnum - 1 ;
2009-02-19 16:47:54 +00:00
for ( j = startwall ; j < = endwall ; j + + )
2008-05-16 19:51:38 +00:00
{
k = wall [ j ] . nextsector ;
if ( k > = 0 )
if ( ( sector [ k ] . ceilingstat & 1 ) > 0 )
if ( pskysearch [ k ] = = 0 )
pskysearch [ k ] = 1 ;
}
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < numsectors ; j + + )
2008-05-16 19:51:38 +00:00
if ( pskysearch [ j ] = = 1 )
i = j ;
}
}
if ( searchstat = = 2 )
{
i = searchsector ;
if ( ( sector [ i ] . floorstat & 1 ) > 0 )
pskysearch [ i ] = 1 ;
while ( pskysearch [ i ] = = 1 )
{
sector [ i ] . floorpicnum = temppicnum ;
sector [ i ] . floorshade = tempshade ;
sector [ i ] . floorpal = temppal ;
if ( ( somethingintab = = 1 ) | | ( somethingintab = = 2 ) )
{
sector [ i ] . floorxpanning = tempxrepeat ;
sector [ i ] . floorypanning = tempyrepeat ;
sector [ i ] . floorstat = tempcstat ;
}
pskysearch [ i ] = 2 ;
startwall = sector [ i ] . wallptr ;
endwall = startwall + sector [ i ] . wallnum - 1 ;
2009-02-19 16:47:54 +00:00
for ( j = startwall ; j < = endwall ; j + + )
2008-05-16 19:51:38 +00:00
{
k = wall [ j ] . nextsector ;
if ( k > = 0 )
if ( ( sector [ k ] . floorstat & 1 ) > 0 )
if ( pskysearch [ k ] = = 0 )
pskysearch [ k ] = 1 ;
}
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < numsectors ; j + + )
2008-05-16 19:51:38 +00:00
if ( pskysearch [ j ] = = 1 )
i = j ;
}
}
message ( " Pasted picnum+shading+pal " ) ;
}
else if ( somethingintab < 255 )
{
if ( searchstat = = 0 )
{
wall [ searchwall ] . picnum = temppicnum ;
wall [ searchwall ] . shade = tempshade ;
wall [ searchwall ] . pal = temppal ;
if ( somethingintab = = 0 )
{
wall [ searchwall ] . xrepeat = tempxrepeat ;
wall [ searchwall ] . yrepeat = tempyrepeat ;
wall [ searchwall ] . cstat = tempcstat ;
wall [ searchwall ] . lotag = templotag ;
wall [ searchwall ] . hitag = temphitag ;
wall [ searchwall ] . extra = tempextra ;
}
fixrepeats ( searchwall ) ;
}
if ( searchstat = = 1 )
{
sector [ searchsector ] . ceilingpicnum = temppicnum ;
sector [ searchsector ] . ceilingshade = tempshade ;
sector [ searchsector ] . ceilingpal = temppal ;
if ( ( somethingintab = = 1 ) | | ( somethingintab = = 2 ) )
{
sector [ searchsector ] . ceilingxpanning = tempxrepeat ;
sector [ searchsector ] . ceilingypanning = tempyrepeat ;
sector [ searchsector ] . ceilingstat = tempcstat ;
sector [ searchsector ] . visibility = tempvis ;
sector [ searchsector ] . lotag = templotag ;
sector [ searchsector ] . hitag = temphitag ;
sector [ searchsector ] . extra = tempextra ;
}
}
if ( searchstat = = 2 )
{
sector [ searchsector ] . floorpicnum = temppicnum ;
sector [ searchsector ] . floorshade = tempshade ;
sector [ searchsector ] . floorpal = temppal ;
if ( ( somethingintab = = 1 ) | | ( somethingintab = = 2 ) )
{
sector [ searchsector ] . floorxpanning = tempxrepeat ;
sector [ searchsector ] . floorypanning = tempyrepeat ;
sector [ searchsector ] . floorstat = tempcstat ;
sector [ searchsector ] . visibility = tempvis ;
sector [ searchsector ] . lotag = templotag ;
sector [ searchsector ] . hitag = temphitag ;
sector [ searchsector ] . extra = tempextra ;
}
}
if ( searchstat = = 3 )
{
sprite [ searchwall ] . picnum = temppicnum ;
if ( ( tilesizx [ temppicnum ] < = 0 ) | | ( tilesizy [ temppicnum ] < = 0 ) )
{
j = 0 ;
2009-02-19 16:47:54 +00:00
for ( k = 0 ; k < MAXTILES ; k + + )
2008-05-16 19:51:38 +00:00
if ( ( tilesizx [ k ] > 0 ) & & ( tilesizy [ k ] > 0 ) )
{
j = k ;
break ;
}
sprite [ searchwall ] . picnum = j ;
}
sprite [ searchwall ] . shade = tempshade ;
sprite [ searchwall ] . pal = temppal ;
if ( somethingintab = = 3 )
{
sprite [ searchwall ] . xrepeat = tempxrepeat ;
sprite [ searchwall ] . yrepeat = tempyrepeat ;
if ( sprite [ searchwall ] . xrepeat < 1 ) sprite [ searchwall ] . xrepeat = 1 ;
if ( sprite [ searchwall ] . yrepeat < 1 ) sprite [ searchwall ] . yrepeat = 1 ;
sprite [ searchwall ] . cstat = tempcstat ;
sprite [ searchwall ] . lotag = templotag ;
sprite [ searchwall ] . hitag = temphitag ;
sprite [ searchwall ] . extra = tempextra ;
2008-08-28 15:04:16 +00:00
sprite [ searchwall ] . xvel = tempxvel ;
sprite [ searchwall ] . yvel = tempyvel ;
sprite [ searchwall ] . zvel = tempzvel ;
2008-05-16 19:51:38 +00:00
}
}
if ( searchstat = = 4 )
{
wall [ searchwall ] . overpicnum = temppicnum ;
if ( wall [ searchwall ] . nextwall > = 0 )
wall [ wall [ searchwall ] . nextwall ] . overpicnum = temppicnum ;
wall [ searchwall ] . shade = tempshade ;
wall [ searchwall ] . pal = temppal ;
if ( somethingintab = = 4 )
{
wall [ searchwall ] . xrepeat = tempxrepeat ;
wall [ searchwall ] . yrepeat = tempyrepeat ;
wall [ searchwall ] . cstat = tempcstat ;
wall [ searchwall ] . lotag = templotag ;
wall [ searchwall ] . hitag = temphitag ;
wall [ searchwall ] . extra = tempextra ;
}
fixrepeats ( searchwall ) ;
}
message ( " Pasted clipboard " ) ;
}
asksave = 1 ;
keystatus [ KEYSC_ENTER ] = 0 ;
}
if ( keystatus [ KEYSC_C ] )
{
keystatus [ KEYSC_C ] = 0 ;
if ( eitherALT )
{
if ( somethingintab < 255 )
{
switch ( searchstat )
{
case 0 :
j = wall [ searchwall ] . picnum ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numwalls ; i + + )
2008-05-16 19:51:38 +00:00
if ( wall [ i ] . picnum = = j ) wall [ i ] . picnum = temppicnum ;
break ;
case 1 :
j = sector [ searchsector ] . ceilingpicnum ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2008-05-16 19:51:38 +00:00
if ( sector [ i ] . ceilingpicnum = = j ) sector [ i ] . ceilingpicnum = temppicnum ;
break ;
case 2 :
j = sector [ searchsector ] . floorpicnum ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2008-05-16 19:51:38 +00:00
if ( sector [ i ] . floorpicnum = = j ) sector [ i ] . floorpicnum = temppicnum ;
break ;
case 3 :
j = sprite [ searchwall ] . picnum ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2008-05-16 19:51:38 +00:00
if ( sprite [ i ] . statnum < MAXSTATUS )
if ( sprite [ i ] . picnum = = j ) sprite [ i ] . picnum = temppicnum ;
break ;
case 4 :
j = wall [ searchwall ] . overpicnum ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numwalls ; i + + )
2008-05-16 19:51:38 +00:00
if ( wall [ i ] . overpicnum = = j ) wall [ i ] . overpicnum = temppicnum ;
break ;
}
message ( " Picnums replaced " ) ;
asksave = 1 ;
}
}
else //C
{
if ( searchstat = = 3 )
{
sprite [ searchwall ] . cstat ^ = 128 ;
2008-06-09 23:41:54 +00:00
message ( " Sprite %d center bit %s " , searchwall , ( sprite [ searchwall ] . cstat & 128 ) ? " ON " : " OFF " ) ;
2008-05-16 19:51:38 +00:00
asksave = 1 ;
}
}
}
if ( keystatus [ KEYSC_SLASH ] ) // /? Reset panning&repeat to 0
{
if ( ( searchstat = = 0 ) | | ( searchstat = = 4 ) )
{
wall [ searchwall ] . xpanning = 0 ;
wall [ searchwall ] . ypanning = 0 ;
wall [ searchwall ] . xrepeat = 8 ;
wall [ searchwall ] . yrepeat = 8 ;
wall [ searchwall ] . cstat = 0 ;
2009-01-09 09:29:17 +00:00
fixrepeats ( ( int16_t ) searchwall ) ;
2008-05-16 19:51:38 +00:00
}
if ( searchstat = = 1 )
{
sector [ searchsector ] . ceilingxpanning = 0 ;
sector [ searchsector ] . ceilingypanning = 0 ;
sector [ searchsector ] . ceilingstat & = ~ 2 ;
sector [ searchsector ] . ceilingheinum = 0 ;
}
if ( searchstat = = 2 )
{
sector [ searchsector ] . floorxpanning = 0 ;
sector [ searchsector ] . floorypanning = 0 ;
sector [ searchsector ] . floorstat & = ~ 2 ;
sector [ searchsector ] . floorheinum = 0 ;
}
if ( searchstat = = 3 )
{
if ( eitherSHIFT )
{
sprite [ searchwall ] . xrepeat = sprite [ searchwall ] . yrepeat ;
}
else
{
sprite [ searchwall ] . xrepeat = 64 ;
sprite [ searchwall ] . yrepeat = 64 ;
}
}
2008-06-09 23:41:54 +00:00
message ( " %s's size and panning reset " , type2str [ searchstat ] ) ;
2008-05-16 19:51:38 +00:00
keystatus [ KEYSC_SLASH ] = 0 ;
asksave = 1 ;
}
if ( keystatus [ KEYSC_P ] ) // P (parallaxing sky)
{
if ( eitherCTRL )
{
parallaxtype + + ;
if ( parallaxtype = = 3 )
parallaxtype = 0 ;
sector [ searchsector ] . ceilingstat ^ = 1 ;
2008-06-09 23:41:54 +00:00
message ( " Parallax type %d " , parallaxtype ) ;
2008-05-16 19:51:38 +00:00
}
else if ( eitherALT )
{
switch ( searchstat )
{
case 0 :
case 4 :
Bstrcpy ( buffer , " Wall pal: " ) ;
2008-09-03 11:59:54 +00:00
getnumberptr256 ( buffer , & wall [ searchwall ] . pal , sizeof ( wall [ searchwall ] . pal ) , 256L , 0 , NULL ) ;
2008-05-16 19:51:38 +00:00
break ;
case 1 :
Bstrcpy ( buffer , " Ceiling pal: " ) ;
2008-09-03 11:59:54 +00:00
getnumberptr256 ( buffer , & sector [ searchsector ] . ceilingpal , sizeof ( sector [ searchsector ] . ceilingpal ) , 256L , 0 , NULL ) ;
2008-05-16 19:51:38 +00:00
break ;
case 2 :
Bstrcpy ( buffer , " Floor pal: " ) ;
2008-09-03 11:59:54 +00:00
getnumberptr256 ( buffer , & sector [ searchsector ] . floorpal , sizeof ( sector [ searchsector ] . floorpal ) , 256L , 0 , NULL ) ;
2008-05-16 19:51:38 +00:00
break ;
case 3 :
Bstrcpy ( buffer , " Sprite pal: " ) ;
2008-09-03 11:59:54 +00:00
getnumberptr256 ( buffer , & sprite [ searchwall ] . pal , sizeof ( sprite [ searchwall ] . pal ) , 256L , 0 , NULL ) ;
2008-05-16 19:51:38 +00:00
break ;
}
}
else
{
if ( ( searchstat = = 0 ) | | ( searchstat = = 1 ) | | ( searchstat = = 4 ) )
{
sector [ searchsector ] . ceilingstat ^ = 1 ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d ceiling parallax bit %s " , searchsector , sector [ searchsector ] . ceilingstat & 1 ? " ON " : " OFF " ) ;
2008-05-16 19:51:38 +00:00
asksave = 1 ;
}
else if ( searchstat = = 2 )
{
sector [ searchsector ] . floorstat ^ = 1 ;
2008-06-09 23:41:54 +00:00
message ( " Sector %d floor parallax bit %s " , searchsector , sector [ searchsector ] . floorstat & 1 ? " ON " : " OFF " ) ;
2008-05-16 19:51:38 +00:00
asksave = 1 ;
}
}
keystatus [ KEYSC_P ] = 0 ;
}
if ( keystatus [ KEYSC_D ] ) //Alt-D (adjust sprite[].clipdist)
{
keystatus [ KEYSC_D ] = 0 ;
if ( eitherALT )
{
if ( searchstat = = 3 )
{
Bstrcpy ( buffer , " Sprite clipdist: " ) ;
sprite [ searchwall ] . clipdist = getnumber256 ( buffer , sprite [ searchwall ] . clipdist , 256L , 0 ) ;
}
}
}
} // end 3d
2009-01-09 09:29:17 +00:00
static void DoSpriteSearch ( int32_t dir ) // <0: backwards, >=0: forwards
2008-09-19 20:09:43 +00:00
{
char did_wrap = 0 ;
2009-01-09 09:29:17 +00:00
int32_t i , j , k = 0 ;
2008-09-19 20:09:43 +00:00
for ( dir < 0 ? gs_cursprite - - : gs_cursprite + + ; ; dir < 0 ? gs_cursprite - - : gs_cursprite + + )
{
if ( gs_cursprite < 0 )
{
if ( ! did_wrap )
{
did_wrap = 1 ;
gs_cursprite = MAXSPRITES - 1 ;
}
else break ;
}
if ( gs_cursprite > = MAXSPRITES )
{
if ( ! did_wrap )
{
did_wrap = 1 ;
gs_cursprite = 0 ;
}
else break ;
}
if ( sprite [ gs_cursprite ] . statnum = = MAXSTATUS ) continue ;
for ( i = 0 ; i < 3 ; i + + )
for ( j = 0 ; i = = 1 ? j < 6 : j < 7 ; j + + )
{
if ( ! gs_spritewhat [ i ] [ j ] ) continue ;
if ( i = = 0 )
{
switch ( j )
{
case 0 : k = sprite [ gs_cursprite ] . x ; break ;
case 1 : k = sprite [ gs_cursprite ] . y ; break ;
case 2 : k = sprite [ gs_cursprite ] . z ; break ;
case 3 : k = sprite [ gs_cursprite ] . sectnum ; break ;
case 4 : k = sprite [ gs_cursprite ] . statnum ; break ;
case 5 : k = sprite [ gs_cursprite ] . hitag ; break ;
case 6 : k = sprite [ gs_cursprite ] . lotag ; break ;
}
}
if ( i = = 1 )
{
switch ( j )
{
case 0 :
k = sprite [ gs_cursprite ] . cstat ;
k & = gs_sprite [ 1 ] [ 0 ] ;
break ;
case 1 : k = sprite [ gs_cursprite ] . shade ; break ;
case 2 : k = sprite [ gs_cursprite ] . pal ; break ;
case 3 :
k = gs_sprite [ 1 ] [ 3 ] ;
if ( k ! = sprite [ gs_cursprite ] . xrepeat & &
2008-09-26 04:20:08 +00:00
k ! = sprite [ gs_cursprite ] . yrepeat )
2008-09-19 20:09:43 +00:00
goto NEXTSPRITE ;
break ;
case 4 :
k = gs_sprite [ 1 ] [ 4 ] ;
if ( k ! = sprite [ gs_cursprite ] . xoffset & &
2008-09-26 04:20:08 +00:00
k ! = sprite [ gs_cursprite ] . yoffset )
2008-09-19 20:09:43 +00:00
goto NEXTSPRITE ;
break ;
case 5 : k = sprite [ gs_cursprite ] . picnum ; break ;
}
}
if ( i = = 2 )
{
switch ( j )
{
case 0 : k = sprite [ gs_cursprite ] . ang ; break ;
case 1 : k = sprite [ gs_cursprite ] . xvel ; break ;
case 2 : k = sprite [ gs_cursprite ] . yvel ; break ;
case 3 : k = sprite [ gs_cursprite ] . zvel ; break ;
case 4 : k = sprite [ gs_cursprite ] . owner ; break ;
case 5 : k = sprite [ gs_cursprite ] . clipdist ; break ;
case 6 : k = sprite [ gs_cursprite ] . extra ; break ;
}
}
if ( k ! = gs_sprite [ i ] [ j ] ) goto NEXTSPRITE ;
}
// found matching sprite
2009-01-13 12:23:18 +00:00
pos . x = sprite [ gs_cursprite ] . x ;
pos . y = sprite [ gs_cursprite ] . y ;
2008-09-19 20:09:43 +00:00
ang = sprite [ gs_cursprite ] . ang ;
printmessage16 ( " %s Sprite seach%s: found sprite %d " , dir < 0 ? " < " : " > " ,
did_wrap ? " (wrap) " : " " , gs_cursprite ) ;
did_wrap = 0 ;
return ;
NEXTSPRITE :
;
}
printmessage16 ( " %s Sprite search: none found " , dir < 0 ? " < " : " > " ) ;
}
2008-05-16 19:51:38 +00:00
static void Keys2d ( void )
{
2009-01-09 09:29:17 +00:00
int16_t temp = 0 ;
int32_t i = 0 , j , k ;
int32_t repeatcountx = 0 , repeatcounty = 0 , smooshyalign , changedir ;
static int32_t opointhighlight = - 1 , olinehighlight = - 1 , ocursectornum = - 1 ;
2008-05-16 19:51:38 +00:00
/*
for ( i = 0 ; i < 0x50 ; i + + )
{ if ( keystatus [ i ] = = 1 ) { Bsprintf ( tempbuf , " key %d " , i ) ; printmessage16 ( tempbuf ) ;
} }
*/
2008-08-28 23:15:11 +00:00
Bsprintf ( tempbuf , " Mapster32 " VERSION ) ;
2008-12-23 23:27:53 +00:00
printext16 ( 9L , ydim2d - STATUS2DSIZ + 9L , editorcolors [ 4 ] , - 1 , tempbuf , 0 ) ;
printext16 ( 8L , ydim2d - STATUS2DSIZ + 8L , editorcolors [ 12 ] , - 1 , tempbuf , 0 ) ;
2008-05-16 19:51:38 +00:00
updatesector ( mousxplc , mousyplc , & cursectornum ) ;
searchsector = cursectornum ;
if ( ( totalclock > getmessagetimeoff ) & & ( totalclock > ( lastpm16time + 120 * 3 ) ) )
{
if ( pointhighlight > = 16384 )
{
char tmpbuf [ 2048 ] ;
i = pointhighlight - 16384 ;
if ( strlen ( names [ sprite [ i ] . picnum ] ) > 0 )
{
if ( sprite [ i ] . picnum = = SECTOREFFECTOR )
2008-09-03 10:47:19 +00:00
Bsprintf ( tmpbuf , " Sprite %d %s, hi:%d ex:%d " , i , SectorEffectorText ( i ) , sprite [ i ] . hitag , sprite [ i ] . extra ) ;
2008-05-16 19:51:38 +00:00
else Bsprintf ( tmpbuf , " Sprite %d %s: lo:%d hi:%d ex:%d " , i , names [ sprite [ i ] . picnum ] , sprite [ i ] . lotag , sprite [ i ] . hitag , sprite [ i ] . extra ) ;
}
else Bsprintf ( tmpbuf , " Sprite %d picnum %d: lo:%d hi:%d ex:%d " , i , sprite [ i ] . picnum , sprite [ i ] . lotag , sprite [ i ] . hitag , sprite [ i ] . extra ) ;
_printmessage16 ( tmpbuf ) ;
}
else if ( ( linehighlight > = 0 ) & & ( sectorofwall ( linehighlight ) = = cursectornum ) )
{
2009-01-09 09:29:17 +00:00
int32_t dax , day , dist ;
2008-05-16 19:51:38 +00:00
dax = wall [ linehighlight ] . x - wall [ wall [ linehighlight ] . point2 ] . x ;
day = wall [ linehighlight ] . y - wall [ wall [ linehighlight ] . point2 ] . y ;
dist = ksqrt ( dax * dax + day * day ) ;
Bsprintf ( tempbuf , " Wall %d: length:%d lo:%d hi:%d ex:%d " , linehighlight , dist , wall [ linehighlight ] . lotag , wall [ linehighlight ] . hitag , wall [ linehighlight ] . extra ) ;
_printmessage16 ( tempbuf ) ;
}
else if ( cursectornum > = 0 )
{
Bsprintf ( tempbuf , " Sector %d: lo:%d hi:%d ex:%d " , cursectornum , sector [ cursectornum ] . lotag , sector [ cursectornum ] . hitag , sector [ cursectornum ] . extra ) ;
_printmessage16 ( tempbuf ) ;
}
else _printmessage16 ( " " ) ;
}
2008-06-02 21:35:51 +00:00
if ( bstatus & 1 | | opointhighlight ! = pointhighlight | | olinehighlight ! = linehighlight | | ocursectornum ! = cursectornum )
2008-06-01 01:57:01 +00:00
{
if ( pointhighlight > = 16384 )
{
i = pointhighlight - 16384 ;
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showspritedata ( ( int16_t ) i ) ;
2008-06-01 01:57:01 +00:00
}
2008-09-02 02:45:06 +00:00
else if ( ( linehighlight > = 0 ) & & ( bstatus & 1 | | sectorofwall ( linehighlight ) = = cursectornum ) )
2008-06-01 01:57:01 +00:00
{
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showwalldata ( ( int16_t ) linehighlight ) ;
2008-06-01 01:57:01 +00:00
}
else if ( cursectornum > = 0 )
{
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showsectordata ( ( int16_t ) cursectornum ) ;
2008-06-01 01:57:01 +00:00
}
2008-06-02 21:35:51 +00:00
else clearmidstatbar16 ( ) ;
2008-06-01 01:57:01 +00:00
opointhighlight = pointhighlight ;
olinehighlight = linehighlight ;
ocursectornum = cursectornum ;
}
2008-11-05 11:49:13 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_Z ] ) // ' z
{
keystatus [ KEYSC_Z ] = 0 ;
editorzrange [ 0 ] = getnumber16 ( " Upper Z range: " , editorzrange [ 0 ] , INT32_MAX , 1 ) ;
editorzrange [ 1 ] = getnumber16 ( " Lower Z range: " , editorzrange [ 1 ] , INT32_MAX , 1 ) ;
printmessage16 ( " " ) ;
}
2008-09-03 10:47:19 +00:00
if ( keystatus [ 0x14 ] ) // T (tag)
{
char buffer [ 80 ] ;
keystatus [ 0x14 ] = 0 ;
if ( keystatus [ 0x1d ] | keystatus [ 0x9d ] ) //Ctrl-T
{
2009-01-09 09:29:17 +00:00
extern int16_t showtags ;
2008-09-03 10:47:19 +00:00
showtags ^ = 1 ;
if ( showtags = = 0 )
printmessage16 ( " Show tags OFF " ) ;
else
printmessage16 ( " Show tags ON " ) ;
}
else if ( keystatus [ 0x38 ] | keystatus [ 0xb8 ] ) //ALT
{
if ( pointhighlight > = 16384 )
{
i = pointhighlight - 16384 ;
Bsprintf ( buffer , " Sprite (%d) Lo-tag: " , i ) ;
if ( sprite [ i ] . picnum = = SECTOREFFECTOR )
sprite [ i ] . lotag = _getnumber16 ( buffer , sprite [ i ] . lotag , 65536L , 0 , ( void * ) SectorEffectorTagText ) ;
else sprite [ i ] . lotag = getnumber16 ( buffer , sprite [ i ] . lotag , 65536L , 0 ) ;
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showspritedata ( ( int16_t ) i ) ;
2008-09-03 10:47:19 +00:00
}
else if ( linehighlight > = 0 )
{
i = linehighlight ;
Bsprintf ( buffer , " Wall (%d) Lo-tag: " , i ) ;
wall [ i ] . lotag = getnumber16 ( buffer , wall [ i ] . lotag , 65536L , 0 ) ;
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showwalldata ( ( int16_t ) i ) ;
2008-09-03 10:47:19 +00:00
}
printmessage16 ( " " ) ;
}
else
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2008-09-03 10:47:19 +00:00
if ( inside ( mousxplc , mousyplc , i ) = = 1 )
{
Bsprintf ( buffer , " Sector (%d) Lo-tag: " , i ) ;
j = qsetmode ;
qsetmode = 200 ;
sector [ i ] . lotag = _getnumber16 ( buffer , sector [ i ] . lotag , 65536L , 0 , ( void * ) ExtGetSectorType ) ;
qsetmode = j ;
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showsectordata ( ( int16_t ) i ) ;
2008-09-03 10:47:19 +00:00
break ;
}
printmessage16 ( " " ) ;
}
}
2008-05-16 19:51:38 +00:00
if ( keystatus [ KEYSC_F1 ] | | ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_TILDE ] ) ) //F1 or ' ~
{
keystatus [ KEYSC_F1 ] = 0 ;
clearmidstatbar16 ( ) ;
2008-06-05 02:51:58 +00:00
// PK_
if ( numhelppages > 0 ) IntegratedHelp ( ) ;
else
2008-05-16 19:51:38 +00:00
{
2008-06-05 02:51:58 +00:00
begindrawing ( ) ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXHELP2D ; i + + )
2008-05-16 19:51:38 +00:00
{
2008-06-05 02:51:58 +00:00
k = 0 ;
j = 0 ;
if ( i > 9 )
{
j = 256 ;
k = 90 ;
}
2008-12-23 23:27:53 +00:00
printext16 ( j , ydim16 + 32 + ( i * 9 ) - k , editorcolors [ 11 ] , - 1 , Help2d [ i ] , 0 ) ;
2008-05-16 19:51:38 +00:00
}
2008-06-05 02:51:58 +00:00
enddrawing ( ) ;
2008-05-16 19:51:38 +00:00
}
}
getpoint ( searchx , searchy , & mousxplc , & mousyplc ) ;
2008-09-02 02:45:06 +00:00
ppointhighlight = getpointhighlight ( mousxplc , mousyplc , ppointhighlight ) ;
2008-05-16 19:51:38 +00:00
if ( ( ppointhighlight & 0xc000 ) = = 16384 )
{
// sprite[ppointhighlight&16383].cstat ^= 1;
cursprite = ( ppointhighlight & 16383 ) ;
}
if ( keystatus [ KEYSC_F9 ] ) // F9 f1=3b
{
keystatus [ KEYSC_F9 ] = 0 ;
Show2dText ( " sthelp.hlp " ) ;
}
/* start Mapster32 */
if ( keystatus [ KEYSC_F4 ] )
{
showfirstwall = ! showfirstwall ;
2008-08-28 11:35:35 +00:00
message ( " Sector firstwall highlight %s " , showfirstwall ? " enabled " : " disabled " ) ;
2008-05-16 19:51:38 +00:00
keystatus [ KEYSC_F4 ] = 0 ;
}
if ( keystatus [ KEYSC_M ] ) // M (tag)
{
keystatus [ KEYSC_M ] = 0 ;
if ( eitherALT ) //ALT
{
if ( pointhighlight > = 16384 )
{
i = pointhighlight - 16384 ;
Bsprintf ( tempbuf , " Sprite %d Extra: " , i ) ;
sprite [ i ] . extra = getnumber16 ( tempbuf , sprite [ i ] . extra , 65536L , 1 ) ;
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showspritedata ( ( int16_t ) i ) ;
2008-05-16 19:51:38 +00:00
}
else if ( linehighlight > = 0 )
{
i = linehighlight ;
Bsprintf ( tempbuf , " Wall %d Extra: " , i ) ;
wall [ i ] . extra = getnumber16 ( tempbuf , wall [ i ] . extra , 65536L , 1 ) ;
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showwalldata ( ( int16_t ) i ) ;
2006-04-13 20:47:06 +00:00
}
printmessage16 ( " " ) ;
}
else
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-04-13 20:47:06 +00:00
if ( inside ( mousxplc , mousyplc , i ) = = 1 )
{
2007-04-21 23:59:56 +00:00
Bsprintf ( tempbuf , " Sector %d Extra: " , i ) ;
2006-04-13 20:47:06 +00:00
sector [ i ] . extra = getnumber16 ( tempbuf , sector [ i ] . extra , 65536L , 1 ) ;
clearmidstatbar16 ( ) ;
2009-01-09 09:29:17 +00:00
showsectordata ( ( int16_t ) i ) ;
2006-04-13 20:47:06 +00:00
break ;
}
printmessage16 ( " " ) ;
}
}
2008-12-30 03:41:21 +00:00
if ( keystatus [ KEYSC_E ] ) // E (expand)
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2008-12-30 03:41:21 +00:00
if ( inside ( mousxplc , mousyplc , i ) = = 1 )
{
sector [ i ] . floorstat ^ = 8 ;
message ( " Sector %d floor texture expansion bit %s " , i , sector [ i ] . floorstat & 8 ? " ON " : " OFF " ) ;
asksave = 1 ;
}
keystatus [ KEYSC_E ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_SLASH ] ) // /? Reset panning&repeat to 0
2006-04-13 20:47:06 +00:00
{
if ( ( ppointhighlight & 0xc000 ) = = 16384 )
{
2008-05-16 00:23:33 +00:00
if ( eitherSHIFT )
2006-04-13 20:47:06 +00:00
{
sprite [ cursprite ] . xrepeat = sprite [ cursprite ] . yrepeat ;
}
else
{
sprite [ cursprite ] . xrepeat = 64 ;
sprite [ cursprite ] . yrepeat = 64 ;
}
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_SLASH ] = 0 ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
2008-12-30 03:41:21 +00:00
if ( keystatus [ KEYSC_gLEFT ] | | keystatus [ KEYSC_gRIGHT ] ) // 4 & 6 (keypad 2D)
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
smooshyalign = keystatus [ KEYSC_gKP5 ] ;
2008-12-30 03:41:21 +00:00
if ( ( repeatcountx = = 0 ) | | ( repeatcountx > 32 ) )
2006-04-13 20:47:06 +00:00
{
changedir = 0 ;
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_gLEFT ] ) changedir = - 1 ;
if ( keystatus [ KEYSC_gRIGHT ] ) changedir = 1 ;
2006-04-13 20:47:06 +00:00
2008-12-30 03:41:21 +00:00
if ( ( ppointhighlight & 0xc000 ) = = 16384 & & ( sprite [ cursprite ] . cstat & 48 ) )
2006-04-13 20:47:06 +00:00
{
sprite [ cursprite ] . xrepeat = changechar ( sprite [ cursprite ] . xrepeat , changedir , smooshyalign , 1 ) ;
if ( sprite [ cursprite ] . xrepeat < 4 )
sprite [ cursprite ] . xrepeat = 4 ;
}
2008-12-30 03:41:21 +00:00
else
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2008-12-30 03:41:21 +00:00
if ( inside ( mousxplc , mousyplc , i ) = = 1 )
{
sector [ i ] . floorxpanning = changechar ( sector [ i ] . floorxpanning , changedir , smooshyalign , 0 ) ;
message ( " Sector %d floor panning: %d, %d " , searchsector , sector [ i ] . floorxpanning , sector [ i ] . floorypanning ) ;
}
}
2006-04-13 20:47:06 +00:00
asksave = 1 ;
2008-12-30 03:41:21 +00:00
repeatcountx = max ( 1 , repeatcountx - 2 ) ;
2006-04-13 20:47:06 +00:00
}
repeatcountx + = synctics ;
}
else
repeatcountx = 0 ;
2008-12-30 03:41:21 +00:00
if ( keystatus [ KEYSC_gUP ] | | keystatus [ KEYSC_gDOWN ] ) // 2 & 8 (keypad 2D)
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
smooshyalign = keystatus [ KEYSC_gKP5 ] ;
2008-12-30 03:41:21 +00:00
if ( ( repeatcounty = = 0 ) | | ( repeatcounty > 32 ) )
2006-04-13 20:47:06 +00:00
{
changedir = 0 ;
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_gUP ] ) changedir = - 1 ;
if ( keystatus [ KEYSC_gDOWN ] ) changedir = 1 ;
2006-04-13 20:47:06 +00:00
2008-12-30 03:41:21 +00:00
if ( ( ppointhighlight & 0xc000 ) = = 16384 & & ( sprite [ cursprite ] . cstat & 48 ) )
2006-04-13 20:47:06 +00:00
{
sprite [ cursprite ] . yrepeat = changechar ( sprite [ cursprite ] . yrepeat , changedir , smooshyalign , 1 ) ;
if ( sprite [ cursprite ] . yrepeat < 4 )
sprite [ cursprite ] . yrepeat = 4 ;
}
2008-12-30 03:41:21 +00:00
else
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2008-12-30 03:41:21 +00:00
if ( inside ( mousxplc , mousyplc , i ) = = 1 )
{
sector [ i ] . floorypanning = changechar ( sector [ i ] . floorypanning , changedir , smooshyalign , 0 ) ;
message ( " Sector %d floor panning: %d, %d " , searchsector , sector [ i ] . floorxpanning , sector [ i ] . floorypanning ) ;
}
}
2006-04-13 20:47:06 +00:00
asksave = 1 ;
2008-12-30 03:41:21 +00:00
repeatcounty = max ( 1 , repeatcounty - 2 ) ;
2006-04-13 20:47:06 +00:00
}
repeatcounty + = synctics ;
//}
}
else
repeatcounty = 0 ;
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_R ] ) // R (relative alignment, rotation)
2006-04-13 20:47:06 +00:00
{
if ( pointhighlight > = 16384 )
{
i = sprite [ cursprite ] . cstat ;
if ( ( i & 48 ) < 32 ) i + = 16 ;
else i & = ~ 48 ;
sprite [ cursprite ] . cstat = i ;
if ( sprite [ cursprite ] . cstat & 16 )
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d now wall aligned " , cursprite ) ;
2006-04-13 20:47:06 +00:00
else if ( sprite [ cursprite ] . cstat & 32 )
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d now floor aligned " , cursprite ) ;
2006-04-13 20:47:06 +00:00
else
2009-02-02 01:49:14 +00:00
Bsprintf ( getmessage , " Sprite %d now view aligned " , cursprite ) ;
2006-04-13 20:47:06 +00:00
message ( getmessage ) ;
asksave = 1 ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_R ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_S ] ) // ' S
2006-04-13 20:47:06 +00:00
{
if ( pointhighlight > = 16384 )
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_S ] = 0 ;
2007-04-21 23:59:56 +00:00
Bsprintf ( tempbuf , " Sprite %d xrepeat: " , cursprite ) ;
2006-04-16 03:42:36 +00:00
sprite [ cursprite ] . xrepeat = getnumber16 ( tempbuf , sprite [ cursprite ] . xrepeat , 256 , 0 ) ;
2007-04-21 23:59:56 +00:00
Bsprintf ( tempbuf , " Sprite %d yrepeat: " , cursprite ) ;
2006-04-16 03:42:36 +00:00
sprite [ cursprite ] . yrepeat = getnumber16 ( tempbuf , sprite [ cursprite ] . yrepeat , 256 , 0 ) ;
2007-04-21 23:59:56 +00:00
Bsprintf ( tempbuf , " Sprite %d updated " , i ) ;
2006-04-16 03:42:36 +00:00
printmessage16 ( tempbuf ) ;
}
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_F ] ) // ' F
2006-04-13 20:47:06 +00:00
{
keystatus [ KEYSC_F ] = 0 ;
2006-07-20 05:02:55 +00:00
FuncMenu ( ) ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_LBRACK ] ) // [ search backward
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_LBRACK ] = 0 ;
2006-11-13 23:12:47 +00:00
if ( wallsprite = = 0 )
2006-04-13 20:47:06 +00:00
{
SearchSectorsBackward ( ) ;
}
else
2006-11-13 23:12:47 +00:00
if ( wallsprite = = 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( curwallnum > 0 ) curwallnum - - ;
2009-02-19 16:47:54 +00:00
for ( i = curwallnum ; i > = 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if (
2006-04-13 20:47:06 +00:00
( wall [ i ] . picnum = = wall [ curwall ] . picnum )
& & ( ( search_lotag = = 0 ) | |
( search_lotag ! = 0 & & search_lotag = = wall [ i ] . lotag ) )
& & ( ( search_hitag = = 0 ) | |
( search_hitag ! = 0 & & search_hitag = = wall [ i ] . hitag ) )
)
{
2009-01-13 12:23:18 +00:00
pos . x = ( wall [ i ] . x ) - ( ( ( wall [ i ] . x ) - ( wall [ wall [ i ] . point2 ] . x ) ) / 2 ) ;
pos . y = ( wall [ i ] . y ) - ( ( ( wall [ i ] . y ) - ( wall [ wall [ i ] . point2 ] . y ) ) / 2 ) ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " < Wall search: found " ) ;
// curwallnum--;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_LBRACK ] = 0 ;
2006-04-13 20:47:06 +00:00
return ;
}
curwallnum - - ;
}
printmessage16 ( " < Wall search: none found " ) ;
}
else
2006-11-13 23:12:47 +00:00
if ( wallsprite = = 2 )
2008-09-19 20:09:43 +00:00
DoSpriteSearch ( - 1 ) ;
#if 0
2008-09-26 04:20:08 +00:00
{
if ( cursearchspritenum > 0 ) cursearchspritenum - - ;
2009-02-19 16:47:54 +00:00
for ( i = cursearchspritenum ; i > = 0 ; i - - )
2008-09-26 04:20:08 +00:00
{
2006-04-13 20:47:06 +00:00
2008-09-26 04:20:08 +00:00
if (
( sprite [ i ] . picnum = = sprite [ cursearchsprite ] . picnum & &
sprite [ i ] . statnum = = 0 )
& & ( ( search_lotag = = 0 ) | |
( search_lotag ! = 0 & & search_lotag = = sprite [ i ] . lotag ) )
& & ( ( search_hitag = = 0 ) | |
( search_hitag ! = 0 & & search_hitag = = sprite [ i ] . hitag ) )
)
{
2009-01-13 12:23:18 +00:00
pos . x = sprite [ i ] . x ;
pos . y = sprite [ i ] . y ;
2008-09-26 04:20:08 +00:00
ang = sprite [ i ] . ang ;
printmessage16 ( " < Sprite search: found " ) ;
// curspritenum--;
keystatus [ KEYSC_LBRACK ] = 0 ;
return ;
2006-04-13 20:47:06 +00:00
}
2008-09-26 04:20:08 +00:00
cursearchspritenum - - ;
}
printmessage16 ( " < Sprite search: none found " ) ;
}
2008-09-19 20:09:43 +00:00
# endif
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_RBRACK ] ) // ] search forward
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_RBRACK ] = 0 ;
2006-11-13 23:12:47 +00:00
if ( wallsprite = = 0 )
2006-04-13 20:47:06 +00:00
{
SearchSectorsForward ( ) ;
}
2008-09-03 04:20:46 +00:00
else if ( wallsprite = = 1 )
{
if ( curwallnum < MAXWALLS ) curwallnum + + ;
2009-02-19 16:47:54 +00:00
for ( i = curwallnum ; i < = MAXWALLS ; i + + )
2006-04-13 20:47:06 +00:00
{
2008-09-03 04:20:46 +00:00
if (
( wall [ i ] . picnum = = wall [ curwall ] . picnum )
& & ( ( search_lotag = = 0 ) | |
( search_lotag ! = 0 & & search_lotag = = wall [ i ] . lotag ) )
& & ( ( search_hitag = = 0 ) | |
( search_hitag ! = 0 & & search_hitag = = wall [ i ] . hitag ) )
)
2006-04-13 20:47:06 +00:00
{
2009-01-13 12:23:18 +00:00
pos . x = ( wall [ i ] . x ) - ( ( ( wall [ i ] . x ) - ( wall [ wall [ i ] . point2 ] . x ) ) / 2 ) ;
pos . y = ( wall [ i ] . y ) - ( ( ( wall [ i ] . y ) - ( wall [ wall [ i ] . point2 ] . y ) ) / 2 ) ;
2008-09-03 04:20:46 +00:00
printmessage16 ( " > Wall search: found " ) ;
// curwallnum++;
keystatus [ KEYSC_RBRACK ] = 0 ;
return ;
2006-04-13 20:47:06 +00:00
}
2008-09-03 04:20:46 +00:00
curwallnum + + ;
2006-04-13 20:47:06 +00:00
}
2008-09-03 04:20:46 +00:00
printmessage16 ( " > Wall search: none found " ) ;
}
else if ( wallsprite = = 2 )
2008-09-19 20:09:43 +00:00
DoSpriteSearch ( 1 ) ;
#if 0
2008-09-03 04:20:46 +00:00
{
if ( cursearchspritenum < MAXSPRITES ) cursearchspritenum + + ;
2009-02-19 16:47:54 +00:00
for ( i = cursearchspritenum ; i < = MAXSPRITES ; i + + )
2008-09-03 04:20:46 +00:00
{
if (
( sprite [ i ] . picnum = = sprite [ cursearchsprite ] . picnum & &
sprite [ i ] . statnum = = 0 )
& & ( ( search_lotag = = 0 ) | |
( search_lotag ! = 0 & & search_lotag = = sprite [ i ] . lotag ) )
& & ( ( search_hitag = = 0 ) | |
( search_hitag ! = 0 & & search_hitag = = sprite [ i ] . hitag ) )
)
2006-04-13 20:47:06 +00:00
{
2009-01-13 12:23:18 +00:00
pos . x = sprite [ i ] . x ;
pos . y = sprite [ i ] . y ;
2008-09-03 04:20:46 +00:00
ang = sprite [ i ] . ang ;
printmessage16 ( " > Sprite search: found " ) ;
// curspritenum++;
keystatus [ KEYSC_RBRACK ] = 0 ;
return ;
2006-04-13 20:47:06 +00:00
}
2008-09-03 04:20:46 +00:00
cursearchspritenum + + ;
}
printmessage16 ( " > Sprite search: none found " ) ;
}
2008-09-19 20:09:43 +00:00
# endif
2006-04-13 20:47:06 +00:00
}
{
2009-01-09 09:29:17 +00:00
static int32_t autogrid = 0 ;
2008-08-28 15:04:16 +00:00
if ( keystatus [ KEYSC_G ] ) // G (grid on/off)
2006-11-15 01:16:55 +00:00
{
2008-08-28 15:04:16 +00:00
if ( autogrid )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
grid = 0 ;
2008-08-28 15:04:16 +00:00
if ( eitherSHIFT )
grid = 8 ;
autogrid = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-08-28 15:04:16 +00:00
else
{
grid + = eitherSHIFT ? - 1 : 1 ;
if ( grid = = - 1 | | grid = = 9 )
{
switch ( grid )
{
case - 1 :
autogrid = 1 ;
grid = 8 ;
break ;
case 9 :
autogrid = 1 ;
grid = 0 ;
break ;
}
}
}
2009-02-02 01:49:14 +00:00
if ( autogrid ) Bsprintf ( tempbuf , " Grid size: 9 (autosize) " ) ;
else if ( ! grid ) Bsprintf ( tempbuf , " Grid off " ) ;
else Bsprintf ( tempbuf , " Grid size: %d (%d units) " ,grid,2048>>grid) ;
2008-08-28 15:04:16 +00:00
printmessage16 ( tempbuf ) ;
keystatus [ KEYSC_G ] = 0 ;
}
if ( autogrid )
{
2008-09-01 07:15:16 +00:00
grid = zoom + 512 ;
if ( grid > 16384 ) grid = 16384 ;
grid = scale ( grid , 6 , 6144 ) ;
2008-08-28 15:04:16 +00:00
if ( grid > 7 ) grid = 7 ;
if ( grid < 0 ) grid = 0 ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_L ] ) // ' L
2006-04-13 20:47:06 +00:00
{
if ( pointhighlight > = 16384 )
{
i = pointhighlight - 16384 ;
Bsprintf ( tempbuf , " Sprite %d x: " , i ) ;
sprite [ i ] . x = getnumber16 ( tempbuf , sprite [ i ] . x , 131072 , 1 ) ;
Bsprintf ( tempbuf , " Sprite %d y: " , i ) ;
sprite [ i ] . y = getnumber16 ( tempbuf , sprite [ i ] . y , 131072 , 1 ) ;
Bsprintf ( tempbuf , " Sprite %d z: " , i ) ;
sprite [ i ] . z = getnumber16 ( tempbuf , sprite [ i ] . z , 8388608 , 1 ) ;
Bsprintf ( tempbuf , " Sprite %d angle: " , i ) ;
sprite [ i ] . ang = getnumber16 ( tempbuf , sprite [ i ] . ang , 2048L , 0 ) ;
Bsprintf ( tempbuf , " Sprite %d updated " , i ) ;
printmessage16 ( tempbuf ) ;
}
2008-09-03 04:20:46 +00:00
else if ( pointhighlight > = 0 /*<= 16383*/ )
2006-04-13 20:47:06 +00:00
{
i = linehighlight ;
2008-07-12 10:57:52 +00:00
j = wall [ i ] . x ;
k = wall [ i ] . y ;
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " Wall %d x: " , i ) ;
2008-07-12 10:57:52 +00:00
j = getnumber16 ( tempbuf , j , editorgridextent , 1 ) ;
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " Wall %d y: " , i ) ;
2008-07-12 10:57:52 +00:00
k = getnumber16 ( tempbuf , k , editorgridextent , 1 ) ;
dragpoint ( i , j , k ) ;
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " Wall %d updated " , i ) ;
printmessage16 ( tempbuf ) ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_L ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_3 ] ) // ' 3
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
onnames + + ;
if ( onnames > 8 ) onnames = 0 ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_3 ] = 0 ;
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " Mode %d %s " , onnames , SpriteMode [ onnames ] ) ;
printmessage16 ( tempbuf ) ;
// clearmidstatbar16();
// for(i=0;i<MAXMODE32D;i++) {printext16(0*8,ydim16+32+(i*8),15,-1,SpriteMode[i],0);
}
// Ver();
/*
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_5 ] ) // ' 5
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_5 ] = 0 ;
2006-04-13 20:47:06 +00:00
sprintf ( tempbuf , " Power-Up Ammo now equals Normal " ) ;
printmessage16 ( tempbuf ) ;
for ( i = 0 ; i < MAXSPRITES ; i + + )
{
if ( sprite [ i ] . picnum > = 20 & & sprite [ i ] . picnum < = 59 )
{
sprite [ i ] . xrepeat = 32 ;
sprite [ i ] . yrepeat = 32 ;
}
}
}
*/
// What the fuck is this supposed to do?
/* Motorcycle ha ha ha
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_5 ] ) // ' 5
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_5 ] = 0 ;
2006-04-13 20:47:06 +00:00
sidemode + + ; if ( sidemode > 2 ) sidemode = 0 ;
if ( sidemode = = 1 )
{
editstatus = 0 ;
zmode = 2 ;
2009-01-13 12:23:18 +00:00
pos . z = ( ( sector [ cursectnum ] . ceilingz + sector [ cursectnum ] . floorz ) > > 1 ) ;
2006-04-13 20:47:06 +00:00
}
else
{
editstatus = 1 ;
zmode = 1 ;
}
}
*/
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_7 ] ) // ' 7 : swap hilo
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_7 ] = 0 ;
2006-04-13 20:47:06 +00:00
if ( pointhighlight > = 16384 )
{
temp = sprite [ cursprite ] . lotag ;
sprite [ cursprite ] . lotag = sprite [ cursprite ] . hitag ;
sprite [ cursprite ] . hitag = temp ;
Bsprintf ( tempbuf , " Sprite %d tags swapped " , cursprite ) ;
printmessage16 ( tempbuf ) ;
}
else if ( linehighlight > = 0 )
{
temp = wall [ linehighlight ] . lotag ;
wall [ linehighlight ] . lotag = wall [ linehighlight ] . hitag ;
wall [ linehighlight ] . hitag = temp ;
Bsprintf ( tempbuf , " Wall %d tags swapped " , linehighlight ) ;
printmessage16 ( tempbuf ) ;
}
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_J ] ) // ' J
2006-04-13 20:47:06 +00:00
{
2009-01-13 12:23:18 +00:00
pos . x = getnumber16 ( " X-coordinate: " , pos . x , 131072L , 1 ) ;
pos . y = getnumber16 ( " Y-coordinate: " , pos . y , 131072L , 1 ) ;
Bsprintf ( tempbuf , " Current pos now (%d, %d) " , pos . x , pos . y ) ;
2006-04-13 20:47:06 +00:00
printmessage16 ( tempbuf ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_J ] = 0 ;
2006-04-13 20:47:06 +00:00
}
} // end key2d
2006-12-10 06:49:01 +00:00
static void InitCustomColors ( void )
2006-04-13 20:47:06 +00:00
{
/* blue */
/* vgapal16[9*4+0] = 63;
vgapal16 [ 9 * 4 + 1 ] = 31 ;
vgapal16 [ 9 * 4 + 2 ] = 7 ; */
2009-01-09 09:29:17 +00:00
int32_t i ;
2008-12-23 23:27:53 +00:00
palette_t * edcol ;
2009-01-04 22:22:33 +00:00
/*
2008-12-23 23:27:53 +00:00
2009-01-04 22:22:33 +00:00
char vgapal16 [ 4 * 256 ] =
{
00 , 00 , 00 , 00 , 42 , 00 , 00 , 00 , 00 , 42 , 00 , 00 , 42 , 42 , 00 , 00 , 00 , 00 , 42 , 00 ,
42 , 00 , 42 , 00 , 00 , 21 , 42 , 00 , 42 , 42 , 42 , 00 , 21 , 21 , 21 , 00 , 63 , 21 , 21 , 00 ,
21 , 63 , 21 , 00 , 63 , 63 , 21 , 00 , 21 , 21 , 63 , 00 , 63 , 21 , 63 , 00 , 21 , 63 , 63 , 00 ,
63 , 63 , 63 , 00
} ;
*/
/* editorcolors[0] = getclosestcol(0,0,0);
editorcolors [ 1 ] = getclosestcol ( 0 , 0 , 42 ) ;
editorcolors [ 2 ] = getclosestcol ( 0 , 42 , 0 ) ;
editorcolors [ 3 ] = getclosestcol ( 0 , 42 , 42 ) ;
editorcolors [ 4 ] = getclosestcol ( 42 , 0 , 0 ) ;
editorcolors [ 5 ] = getclosestcol ( 0 , 0 , 0 ) ;
*/
2008-12-28 23:27:24 +00:00
vgapal16 [ 9 * 4 + 0 ] = 63 ;
vgapal16 [ 9 * 4 + 1 ] = 31 ;
vgapal16 [ 9 * 4 + 2 ] = 7 ;
2006-04-13 20:47:06 +00:00
/* orange */
vgapal16 [ 31 * 4 + 0 ] = 20 ; // blue
vgapal16 [ 31 * 4 + 1 ] = 45 ; // green
vgapal16 [ 31 * 4 + 2 ] = 60 ; // red
vgapal16 [ 39 * 4 + 0 ] = 36 ;
vgapal16 [ 39 * 4 + 1 ] = 53 ;
vgapal16 [ 39 * 4 + 2 ] = 63 ;
/* light yellow */
vgapal16 [ 22 * 4 + 0 ] = 51 ;
vgapal16 [ 22 * 4 + 1 ] = 63 ;
vgapal16 [ 22 * 4 + 2 ] = 63 ;
/* grey */
vgapal16 [ 23 * 4 + 0 ] = 45 ;
vgapal16 [ 23 * 4 + 1 ] = 45 ;
vgapal16 [ 23 * 4 + 2 ] = 45 ;
/* blue */
vgapal16 [ 24 * 4 + 0 ] = 51 ;
vgapal16 [ 24 * 4 + 1 ] = 41 ;
vgapal16 [ 24 * 4 + 2 ] = 12 ;
vgapal16 [ 32 * 4 + 0 ] = 60 ;
vgapal16 [ 32 * 4 + 1 ] = 50 ;
vgapal16 [ 32 * 4 + 2 ] = 21 ;
2008-09-01 07:15:16 +00:00
// grid color
vgapal16 [ 25 * 4 + 0 ] = 19 ;
vgapal16 [ 25 * 4 + 1 ] = 17 ;
vgapal16 [ 25 * 4 + 2 ] = 17 ;
vgapal16 [ 26 * 4 + 0 ] = 24 ;
vgapal16 [ 26 * 4 + 1 ] = 24 ;
vgapal16 [ 26 * 4 + 2 ] = 24 ;
2008-12-24 23:19:22 +00:00
vgapal16 [ 33 * 4 + 0 ] = 0 ; //15; // blue
vgapal16 [ 33 * 4 + 1 ] = 0 ; //30; // green
vgapal16 [ 33 * 4 + 2 ] = 48 ; //45; // red
2008-09-01 07:15:16 +00:00
2008-12-24 23:19:22 +00:00
vgapal16 [ 41 * 4 + 0 ] = 0 ; //24;
vgapal16 [ 41 * 4 + 1 ] = 0 ; //40;
vgapal16 [ 41 * 4 + 2 ] = 63 ; //48;
2008-09-01 07:15:16 +00:00
2008-12-23 23:27:53 +00:00
for ( i = 0 ; i < 256 ; i + + )
{
edcol = ( palette_t * ) & vgapal16 [ 4 * i ] ;
editorcolors [ i ] = getclosestcol ( edcol - > b , edcol - > g , edcol - > r ) ;
}
2006-04-13 20:47:06 +00:00
}
void ExtPreSaveMap ( void )
{
2007-01-30 02:04:14 +00:00
if ( fixmapbeforesaving )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , startwall , j , endwall ;
2006-04-13 20:47:06 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2007-01-30 02:04:14 +00:00
{
startwall = sector [ i ] . wallptr ;
2009-02-19 16:47:54 +00:00
for ( j = startwall ; j < numwalls ; j + + )
2007-01-30 02:04:14 +00:00
if ( wall [ j ] . point2 < startwall ) startwall = wall [ j ] . point2 ;
sector [ i ] . wallptr = startwall ;
}
2009-02-19 16:47:54 +00:00
for ( i = numsectors - 2 ; i > = 0 ; i - - )
2007-01-30 02:04:14 +00:00
sector [ i ] . wallnum = sector [ i + 1 ] . wallptr - sector [ i ] . wallptr ;
sector [ numsectors - 1 ] . wallnum = numwalls - sector [ numsectors - 1 ] . wallptr ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numwalls ; i + + )
2007-01-30 02:04:14 +00:00
{
wall [ i ] . nextsector = - 1 ;
wall [ i ] . nextwall = - 1 ;
}
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2007-01-30 02:04:14 +00:00
{
startwall = sector [ i ] . wallptr ;
endwall = startwall + sector [ i ] . wallnum ;
2009-02-19 16:47:54 +00:00
for ( j = startwall ; j < endwall ; j + + )
2009-01-09 09:29:17 +00:00
checksectorpointer ( ( int16_t ) j , ( int16_t ) i ) ;
2007-01-30 02:04:14 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
void ExtPreLoadMap ( void )
2006-11-16 03:02:42 +00:00
{ }
2006-04-13 20:47:06 +00:00
2008-11-22 11:42:22 +00:00
static void G_ShowParameterHelp ( void )
2007-01-22 02:35:54 +00:00
{
2007-01-22 05:00:57 +00:00
char * s = " Usage: mapster32 [OPTIONS] [FILE] \n \n "
2007-01-24 03:42:54 +00:00
" -gFILE, -grp FILE \t Use extra group file FILE \n "
2007-01-22 05:00:57 +00:00
" -hFILE \t \t Use definitions file FILE \n "
" -jDIR, -game_dir DIR \n \t \t Adds DIR to the file path stack \n "
2007-01-30 02:04:14 +00:00
" -nocheck \t \t Disables map pointer checking when saving \n "
2007-01-22 02:35:54 +00:00
# if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
" -setup \t \t Displays the configuration dialog \n "
2007-02-05 01:33:08 +00:00
# endif
2007-01-22 02:35:54 +00:00
# if !defined(_WIN32)
" -usecwd \t \t Read game data and configuration file from working directory \n "
# endif
2007-01-22 05:00:57 +00:00
" \n -?, -help, --help \t Display this help message and exit "
2007-01-22 02:35:54 +00:00
;
2008-08-28 23:15:11 +00:00
wm_msgbox ( " Mapster32 " VERSION BUILDDATE , s ) ;
2007-01-22 02:35:54 +00:00
}
2008-11-20 14:06:36 +00:00
static void AddGamePath ( const char * buffer )
2007-01-22 03:10:09 +00:00
{
struct strllist * s ;
2008-06-29 10:40:37 +00:00
s = ( struct strllist * ) Bcalloc ( 1 , sizeof ( struct strllist ) ) ;
2007-01-22 03:10:09 +00:00
s - > str = strdup ( buffer ) ;
if ( CommandPaths )
{
struct strllist * t ;
for ( t = CommandPaths ; t - > next ; t = t - > next ) ;
t - > next = s ;
return ;
}
CommandPaths = s ;
}
2008-11-20 14:06:36 +00:00
static void G_AddGroup ( const char * buffer )
2007-07-04 09:15:08 +00:00
{
2007-12-12 15:27:34 +00:00
struct strllist * s ;
2008-06-29 10:40:37 +00:00
s = ( struct strllist * ) Bcalloc ( 1 , sizeof ( struct strllist ) ) ;
2007-12-12 15:27:34 +00:00
s - > str = Bstrdup ( buffer ) ;
if ( Bstrchr ( s - > str , ' . ' ) = = 0 )
Bstrcat ( s - > str , " .grp " ) ;
if ( CommandGrps )
{
struct strllist * t ;
for ( t = CommandGrps ; t - > next ; t = t - > next ) ;
t - > next = s ;
return ;
}
CommandGrps = s ;
2007-07-04 09:15:08 +00:00
}
2007-01-22 05:00:57 +00:00
2008-09-28 21:48:31 +00:00
# define COPYARG(i) \
Bmemcpy ( & testplay_addparam [ j ] , argv [ i ] , lengths [ i ] ) ; \
j + = lengths [ i ] ; \
testplay_addparam [ j + + ] = ' ' ;
2008-12-04 00:31:16 +00:00
# if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
2008-11-11 13:24:05 +00:00
extern char forcegl ;
# endif
2009-01-09 09:29:17 +00:00
static void G_CheckCommandLine ( int32_t argc , const char * * argv )
2007-01-21 23:49:07 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i = 1 , j , maxlen = 0 , * lengths ;
2008-07-07 08:04:12 +00:00
char * c , * k ;
2007-01-21 23:49:07 +00:00
2008-10-14 08:40:59 +00:00
mapster32_fullpath = ( char * ) argv [ 0 ] ;
2007-01-21 23:49:07 +00:00
if ( argc > 1 )
{
2009-01-09 09:29:17 +00:00
lengths = Bmalloc ( argc * sizeof ( int32_t ) ) ;
2008-09-28 21:48:31 +00:00
for ( j = 1 ; j < argc ; j + + ) maxlen + = ( lengths [ j ] = Bstrlen ( argv [ j ] ) ) ;
2008-10-14 08:40:59 +00:00
2008-09-28 21:48:31 +00:00
testplay_addparam = Bmalloc ( maxlen + argc ) ;
testplay_addparam [ 0 ] = 0 ;
2008-10-14 08:40:59 +00:00
2008-09-28 21:48:31 +00:00
j = 0 ;
2007-01-21 23:49:07 +00:00
while ( i < argc )
{
2007-08-17 03:16:46 +00:00
c = ( char * ) argv [ i ] ;
2007-01-21 23:49:07 +00:00
if ( ( ( * c = = ' / ' ) | | ( * c = = ' - ' ) ) )
{
2007-01-22 05:00:57 +00:00
if ( ! Bstrcasecmp ( c + 1 , " ? " ) | | ! Bstrcasecmp ( c + 1 , " help " ) | | ! Bstrcasecmp ( c + 1 , " -help " ) )
{
2008-11-22 11:42:22 +00:00
G_ShowParameterHelp ( ) ;
2007-01-22 05:00:57 +00:00
exit ( 0 ) ;
}
2007-02-05 01:33:08 +00:00
2007-12-12 15:27:34 +00:00
if ( ! Bstrcasecmp ( c + 1 , " g " ) | | ! Bstrcasecmp ( c + 1 , " grp " ) )
2007-07-04 09:15:08 +00:00
{
if ( argc > i + 1 )
{
2008-11-20 14:06:36 +00:00
G_AddGroup ( argv [ i + 1 ] ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2007-07-04 09:15:08 +00:00
i + + ;
}
i + + ;
continue ;
}
2007-01-22 03:10:09 +00:00
if ( ! Bstrcasecmp ( c + 1 , " game_dir " ) )
{
if ( argc > i + 1 )
{
2008-11-26 22:51:56 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
extern char TEXCACHEFILE [ BMAX_PATH ] ;
2008-12-01 10:44:18 +00:00
2008-11-26 22:51:56 +00:00
Bsprintf ( tempbuf , " %s/%s " , argv [ i + 1 ] , TEXCACHEFILE ) ;
Bstrcpy ( TEXCACHEFILE , tempbuf ) ;
# endif
2008-11-20 14:06:36 +00:00
AddGamePath ( argv [ i + 1 ] ) ;
2008-11-26 22:51:56 +00:00
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2007-01-22 03:10:09 +00:00
i + + ;
}
i + + ;
continue ;
}
2007-01-21 23:49:07 +00:00
if ( ! Bstrcasecmp ( c + 1 , " cfg " ) )
{
if ( argc > i + 1 )
{
Bstrcpy ( setupfilename , argv [ i + 1 ] ) ;
i + + ;
}
i + + ;
continue ;
}
2007-07-04 09:15:08 +00:00
if ( ! Bstrcasecmp ( c + 1 , " gamegrp " ) )
{
if ( argc > i + 1 )
{
Bstrcpy ( defaultduke3dgrp , argv [ i + 1 ] ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2007-07-04 09:15:08 +00:00
i + + ;
}
i + + ;
continue ;
}
2007-01-21 23:49:07 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nam " ) )
{
strcpy ( duke3dgrp , " nam.grp " ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2007-01-21 23:49:07 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " ww2gi " ) )
{
strcpy ( duke3dgrp , " ww2gi.grp " ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2007-01-21 23:49:07 +00:00
i + + ;
continue ;
}
2007-01-30 02:04:14 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nocheck " ) )
{
initprintf ( " Map pointer checking disabled \n " ) ;
fixmapbeforesaving = 0 ;
i + + ;
continue ;
}
2007-07-04 09:15:08 +00:00
if ( ! Bstrcasecmp ( c + 1 , " noautoload " ) )
{
initprintf ( " Autoload disabled \n " ) ;
NoAutoLoad = 1 ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2007-07-04 09:15:08 +00:00
i + + ;
continue ;
}
2007-01-21 23:49:07 +00:00
# if !defined(_WIN32)
if ( ! Bstrcasecmp ( c + 1 , " usecwd " ) )
{
usecwd = 1 ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2007-01-21 23:49:07 +00:00
i + + ;
continue ;
}
2008-11-11 13:24:05 +00:00
# endif
2008-12-04 00:31:16 +00:00
# if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
2008-11-11 13:24:05 +00:00
if ( ! Bstrcasecmp ( c + 1 , " forcegl " ) )
{
forcegl = 1 ;
i + + ;
continue ;
}
2007-01-21 23:49:07 +00:00
# endif
}
if ( ( * c = = ' / ' ) | | ( * c = = ' - ' ) )
{
c + + ;
switch ( * c )
{
case ' h ' :
case ' H ' :
c + + ;
if ( * c )
{
defsfilename = c ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2007-01-21 23:49:07 +00:00
initprintf ( " Using DEF file: %s. \n " , defsfilename ) ;
}
break ;
case ' j ' :
case ' J ' :
c + + ;
if ( ! * c ) break ;
2008-11-20 14:06:36 +00:00
AddGamePath ( c ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2007-01-21 23:49:07 +00:00
break ;
2007-01-22 05:00:57 +00:00
case ' g ' :
case ' G ' :
c + + ;
if ( ! * c ) break ;
2008-11-20 14:06:36 +00:00
G_AddGroup ( c ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2007-01-22 05:00:57 +00:00
break ;
2007-01-21 23:49:07 +00:00
}
}
2008-07-07 22:03:11 +00:00
else
{
k = Bstrchr ( c , ' . ' ) ;
if ( k )
{
if ( ! Bstrcasecmp ( k , " .grp " ) | | ! Bstrcasecmp ( k , " .zip " ) )
{
2008-11-20 14:06:36 +00:00
G_AddGroup ( argv [ i + + ] ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2008-07-07 22:03:11 +00:00
continue ;
}
2008-07-27 11:35:41 +00:00
if ( ! Bstrcasecmp ( k , " .def " ) )
{
defsfilename = ( char * ) argv [ i + + ] ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2008-07-27 11:35:41 +00:00
initprintf ( " Using DEF file: %s. \n " , defsfilename ) ;
continue ;
}
2008-07-07 22:03:11 +00:00
}
}
2007-01-21 23:49:07 +00:00
i + + ;
}
2008-09-28 21:48:31 +00:00
Bfree ( lengths ) ;
2008-10-14 08:40:59 +00:00
2008-09-28 21:48:31 +00:00
if ( j > 0 )
{
testplay_addparam [ j - 1 ] = 0 ;
2008-10-18 12:37:26 +00:00
testplay_addparam = Brealloc ( testplay_addparam , j * sizeof ( char ) ) ;
2008-09-28 21:48:31 +00:00
}
else
2008-10-09 21:09:16 +00:00
{
2008-09-28 21:48:31 +00:00
Bfree ( testplay_addparam ) ;
2008-10-09 21:09:16 +00:00
testplay_addparam = NULL ;
}
2007-01-21 23:49:07 +00:00
}
}
2008-09-28 21:48:31 +00:00
# undef COPYARG
2007-01-21 23:49:07 +00:00
2009-01-09 09:29:17 +00:00
int32_t ExtPreInit ( int32_t argc , const char * * argv )
2006-04-13 20:47:06 +00:00
{
2008-08-28 23:15:11 +00:00
wm_setapptitle ( " Mapster32 " VERSION BUILDDATE ) ;
2006-04-13 20:47:06 +00:00
2008-07-27 11:35:41 +00:00
# ifdef _WIN32
tempbuf [ GetModuleFileName ( NULL , tempbuf , BMAX_PATH ) ] = 0 ;
Bcorrectfilename ( tempbuf , 1 ) ;
chdir ( tempbuf ) ;
# endif
2006-04-13 20:47:06 +00:00
OSD_SetLogFile ( " mapster32.log " ) ;
2007-04-17 05:54:12 +00:00
OSD_SetVersionString ( " Mapster32 " VERSION , 0 , 2 ) ;
2008-08-28 23:15:11 +00:00
initprintf ( " Mapster32 " VERSION BUILDDATE " \n " ) ;
2008-12-10 11:36:53 +00:00
// initprintf("Copyright (c) 2008 EDuke32 team\n");
2007-01-21 23:49:07 +00:00
2008-11-20 14:06:36 +00:00
G_CheckCommandLine ( argc , argv ) ;
2007-01-21 23:49:07 +00:00
2006-04-13 20:47:06 +00:00
return 0 ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_quit ( const osdfuncparm_t * parm )
2006-04-13 20:47:06 +00:00
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( parm ) ;
2006-04-13 20:47:06 +00:00
clearfilenames ( ) ;
ExtUnInit ( ) ;
uninitengine ( ) ;
exit ( 0 ) ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_editorgridextent ( const osdfuncparm_t * parm )
2007-02-28 09:12:41 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
extern int32_t editorgridextent ;
2007-02-28 09:12:41 +00:00
if ( parm - > numparms = = 0 )
{
2007-12-12 17:42:14 +00:00
OSD_Printf ( " \" editorgridextent \" is \" %d \" \n " , editorgridextent ) ;
2007-02-28 09:12:41 +00:00
return OSDCMD_SHOWHELP ;
}
else if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
i = Batol ( parm - > parms [ 0 ] ) ;
if ( i > = 65536 & & i < = 524288 )
{
editorgridextent = i ;
2007-12-12 17:42:14 +00:00
OSD_Printf ( " editorgridextent %d \n " , editorgridextent ) ;
2007-02-28 09:12:41 +00:00
}
else OSD_Printf ( " editorgridextent: value out of range \n " ) ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_addpath ( const osdfuncparm_t * parm )
2007-04-17 05:54:12 +00:00
{
char pathname [ BMAX_PATH ] ;
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
strcpy ( pathname , parm - > parms [ 0 ] ) ;
addsearchpath ( pathname ) ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_initgroupfile ( const osdfuncparm_t * parm )
2007-04-17 05:54:12 +00:00
{
char file [ BMAX_PATH ] ;
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
strcpy ( file , parm - > parms [ 0 ] ) ;
initgroupfile ( file ) ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_echo ( const osdfuncparm_t * parm )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2007-04-17 05:54:12 +00:00
for ( i = 0 ; i < parm - > numparms ; i + + )
{
if ( i > 0 ) OSD_Printf ( " " ) ;
OSD_Printf ( " %s " , parm - > parms [ i ] ) ;
}
OSD_Printf ( " \n " ) ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_fileinfo ( const osdfuncparm_t * parm )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
uint32_t crc , length ;
int32_t i , j ;
2007-04-17 05:54:12 +00:00
char buf [ 256 ] ;
if ( parm - > numparms ! = 1 ) return OSDCMD_SHOWHELP ;
if ( ( i = kopen4load ( ( char * ) parm - > parms [ 0 ] , 0 ) ) < 0 )
{
OSD_Printf ( " fileinfo: File \" %s \" not found. \n " , parm - > parms [ 0 ] ) ;
return OSDCMD_OK ;
}
length = kfilelength ( i ) ;
crc32init ( & crc ) ;
do
{
j = kread ( i , buf , 256 ) ;
2009-01-09 09:29:17 +00:00
crc32block ( & crc , ( uint8_t * ) buf , j ) ;
2007-04-17 05:54:12 +00:00
}
while ( j = = 256 ) ;
crc32finish ( & crc ) ;
kclose ( i ) ;
OSD_Printf ( " fileinfo: %s \n "
" File size: %d \n "
" CRC-32: %08X \n " ,
parm - > parms [ 0 ] , length , crc ) ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_sensitivity ( const osdfuncparm_t * parm )
2007-04-17 05:54:12 +00:00
{
if ( parm - > numparms ! = 1 )
{
OSD_Printf ( " \" sensitivity \" is \" %.2f \" \n " , msens ) ;
return OSDCMD_SHOWHELP ;
}
msens = atof ( parm - > parms [ 0 ] ) ;
OSD_Printf ( " sensitivity %.2f \n " , msens ) ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_gamma ( const osdfuncparm_t * parm )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
extern int16_t brightness ;
2007-04-17 05:54:12 +00:00
if ( parm - > numparms ! = 1 )
{
OSD_Printf ( " \" gamma \" \" %d \" \n " , brightness ) ;
return OSDCMD_SHOWHELP ;
}
brightness = atoi ( parm - > parms [ 0 ] ) ;
setbrightness ( brightness , palette , 0 ) ;
OSD_Printf ( " gamma %d \n " , brightness ) ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_noclip ( const osdfuncparm_t * parm )
2007-04-17 05:54:12 +00:00
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( parm ) ;
2007-04-17 05:54:12 +00:00
noclip = ! noclip ;
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_testplay_addparam ( const osdfuncparm_t * parm )
2008-09-12 13:41:18 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t slen ;
2008-09-12 13:41:18 +00:00
if ( parm - > numparms ! = 1 )
{
OSD_Printf ( " additional parameters for test playing: %s%s%s \n " ,
testplay_addparam ? " \" " : " " ,
testplay_addparam ? testplay_addparam : " <empty> " ,
testplay_addparam ? " \" " : " " ) ;
return OSDCMD_OK ;
}
slen = Bstrlen ( parm - > parms [ 0 ] ) ;
if ( slen > 0 )
{
if ( ! testplay_addparam )
testplay_addparam = Bmalloc ( slen + 1 ) ;
else
testplay_addparam = Brealloc ( testplay_addparam , slen + 1 ) ;
Bmemcpy ( testplay_addparam , parm - > parms [ 0 ] , slen ) ;
testplay_addparam [ slen ] = 0 ;
}
else
{
if ( testplay_addparam )
{
Bfree ( testplay_addparam ) ;
testplay_addparam = NULL ;
}
}
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_showheightindicators ( const osdfuncparm_t * parm )
2008-10-09 21:09:16 +00:00
{
2009-01-09 09:29:17 +00:00
extern int32_t showheightindicators ;
2008-10-09 21:09:16 +00:00
if ( parm - > numparms = = 1 )
showheightindicators = min ( max ( atoi ( parm - > parms [ 0 ] ) , 0 ) , 2 ) ;
OSD_Printf ( " height indicators: %s \n " ,
showheightindicators = = 0 ? " none " :
( showheightindicators = = 1 ? " two-sided walls only " : " all " ) ) ;
return OSDCMD_OK ;
}
2008-05-15 03:16:38 +00:00
//PK vvv ------------
2009-01-09 09:29:17 +00:00
static int32_t osdcmd_vars_pk ( const osdfuncparm_t * parm )
2008-05-15 03:16:38 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t showval = ( parm - > numparms < 1 ) ;
2008-05-15 03:16:38 +00:00
// this is something of a misnomer, since it's actually accel+decel
if ( ! Bstrcasecmp ( parm - > name , " pk_turnaccel " ) )
{
if ( showval ) { OSD_Printf ( " Turning acceleration+declaration is %d \n " , pk_turnaccel ) ; }
else
{
pk_turnaccel = atoi ( parm - > parms [ 0 ] ) ;
pk_turnaccel = pk_turnaccel < = pk_turndecel ? ( pk_turndecel + 1 ) : pk_turnaccel ;
pk_turnaccel = pk_turnaccel > 256 ? 256 : pk_turnaccel ;
}
}
else if ( ! Bstrcasecmp ( parm - > name , " pk_turndecel " ) )
{
if ( showval ) { OSD_Printf ( " Turning deceleration is %d \n " , pk_turndecel ) ; }
else
{
pk_turndecel = atoi ( parm - > parms [ 0 ] ) ;
pk_turndecel = pk_turndecel < = 0 ? 1 : pk_turndecel ;
pk_turndecel = pk_turndecel > = pk_turnaccel ? ( pk_turnaccel - 1 ) : pk_turndecel ;
pk_turndecel = pk_turndecel > 128 ? 128 : pk_turndecel ;
}
}
else if ( ! Bstrcasecmp ( parm - > name , " pk_quickmapcycling " ) )
{
OSD_Printf ( " Quick map cycling ((LShift-)Ctrl-X): %s \n " ,
2008-06-09 23:41:54 +00:00
( quickmapcycling = ! quickmapcycling ) ? " enabled " : " disabled " ) ;
2008-05-15 03:16:38 +00:00
}
else if ( ! Bstrcasecmp ( parm - > name , " pk_uedaccel " ) )
{
if ( showval ) { OSD_Printf ( " UnrealEd mouse navigation acceleration is %d \n " , pk_uedaccel ) ; }
else
{
pk_uedaccel = atoi ( parm - > parms [ 0 ] ) ;
pk_uedaccel = pk_uedaccel < 0 ? 0 : pk_uedaccel ;
pk_uedaccel = pk_uedaccel > 5 ? 5 : pk_uedaccel ;
}
}
return OSDCMD_OK ;
}
2009-01-09 09:29:17 +00:00
static int32_t registerosdcommands ( void )
2007-04-17 05:54:12 +00:00
{
OSD_RegisterFunction ( " addpath " , " addpath <path>: adds path to game filesystem " , osdcmd_addpath ) ;
OSD_RegisterFunction ( " echo " , " echo [text]: echoes text to the console " , osdcmd_echo ) ;
OSD_RegisterFunction ( " editorgridextent " , " editorgridextent: sets the size of the 2D mode editing grid " , osdcmd_editorgridextent ) ;
OSD_RegisterFunction ( " fileinfo " , " fileinfo <file>: gets a file's information " , osdcmd_fileinfo ) ;
OSD_RegisterFunction ( " gamma " , " gamma <value>: changes brightness " , osdcmd_gamma ) ;
OSD_RegisterFunction ( " initgroupfile " , " initgroupfile <path>: adds a grp file into the game filesystem " , osdcmd_initgroupfile ) ;
OSD_RegisterFunction ( " noclip " , " noclip: toggles clipping mode " , osdcmd_noclip ) ;
OSD_RegisterFunction ( " quit " , " quit: exits the game immediately " , osdcmd_quit ) ;
2008-07-07 08:04:12 +00:00
OSD_RegisterFunction ( " exit " , " exit: exits the game immediately " , osdcmd_quit ) ;
2007-04-17 05:54:12 +00:00
OSD_RegisterFunction ( " sensitivity " , " sensitivity <value>: changes the mouse sensitivity " , osdcmd_sensitivity ) ;
2008-05-15 03:16:38 +00:00
//PK
OSD_RegisterFunction ( " pk_turnaccel " , " pk_turnaccel: sets turning acceleration " , osdcmd_vars_pk ) ;
OSD_RegisterFunction ( " pk_turndecel " , " pk_turndecel: sets turning deceleration " , osdcmd_vars_pk ) ;
OSD_RegisterFunction ( " pk_uedaccel " , " pk_uedaccel: sets UnrealEd movement speed factor (0-5, exponentially) " , osdcmd_vars_pk ) ;
OSD_RegisterFunction ( " pk_quickmapcycling " , " pk_quickmapcycling: allows cycling of maps with (Shift-)Ctrl-X " , osdcmd_vars_pk ) ;
2008-09-12 13:41:18 +00:00
OSD_RegisterFunction ( " testplay_addparam " , " testplay_addparam \" string \" : set additional parameters for test playing " , osdcmd_testplay_addparam ) ;
2008-10-09 21:09:16 +00:00
OSD_RegisterFunction ( " showheightindicators " , " showheightindicators [012]: toggles height indicators in 2D mode " , osdcmd_showheightindicators ) ;
2007-04-17 05:54:12 +00:00
return 0 ;
}
2008-05-16 19:51:38 +00:00
# define DUKEOSD
2007-04-17 05:54:12 +00:00
# ifdef DUKEOSD
2009-01-09 09:29:17 +00:00
void GAME_drawosdchar ( int32_t x , int32_t y , char ch , int32_t shade , int32_t pal )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t ac ;
2007-04-17 05:54:12 +00:00
if ( ch = = 32 ) return ;
ac = ch - ' ! ' + STARTALPHANUM ;
if ( ac < STARTALPHANUM | | ac > ENDALPHANUM ) return ;
rotatesprite ( ( ( x < < 3 ) + x ) < < 16 , ( y < < 3 ) < < 16 , 65536l , 0 , ac , shade , pal , 8 | 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
2009-01-09 09:29:17 +00:00
void GAME_drawosdstr ( int32_t x , int32_t y , char * ch , int32_t len , int32_t shade , int32_t pal )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t ac ;
2007-04-17 05:54:12 +00:00
for ( x = ( x < < 3 ) + x ; len > 0 ; len - - , ch + + , x + + )
{
if ( * ch = = 32 )
{
x + = 5 ;
continue ;
}
ac = * ch - ' ! ' + STARTALPHANUM ;
if ( ac < STARTALPHANUM | | ac > ENDALPHANUM ) return ;
rotatesprite ( x < < 16 , ( y < < 3 ) < < 16 , 65536l , 0 , ac , shade , pal , 8 | 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
if ( * ch > = ' 0 ' & & * ch < = ' 9 ' ) x + = 8 ;
else x + = tilesizx [ ac ] ;
}
}
2009-01-09 09:29:17 +00:00
static int32_t GetTime ( void )
2007-04-17 05:54:12 +00:00
{
return totalclock ;
}
2009-01-09 09:29:17 +00:00
void GAME_drawosdcursor ( int32_t x , int32_t y , int32_t type , int32_t lastkeypress )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t ac ;
2007-04-17 05:54:12 +00:00
if ( type ) ac = SMALLFNTCURSOR ;
else ac = ' _ ' - ' ! ' + STARTALPHANUM ;
if ( ! ( ( GetTime ( ) - lastkeypress ) & 0x40l ) )
rotatesprite ( ( ( x < < 3 ) + x ) < < 16 , ( ( y < < 3 ) + ( type ? - 1 : 2 ) ) < < 16 , 65536l , 0 , ac , 0 , 8 , 8 | 16 , 0 , 0 , xdim - 1 , ydim - 1 ) ;
}
2009-01-09 09:29:17 +00:00
int32_t GAME_getcolumnwidth ( int32_t w )
2007-04-17 05:54:12 +00:00
{
return w / 9 ;
}
2009-01-09 09:29:17 +00:00
int32_t GAME_getrowheight ( int32_t w )
2007-04-17 05:54:12 +00:00
{
return w > > 3 ;
}
//#define BGTILE 311
//#define BGTILE 1156
# define BGTILE 1141 // BIGHOLE
# define BORDTILE 3250 // VIEWBORDER
# define BITSTH 1+32+8+16 // high translucency
# define BITSTL 1+8+16 // low translucency
# define BITS 8+16+64 // solid
# define SHADE 16
# define PALETTE 4
2009-01-09 09:29:17 +00:00
void GAME_clearbackground ( int32_t c , int32_t r )
2007-04-17 05:54:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t x , y , xsiz , ysiz , tx2 , ty2 ;
int32_t daydim , bits ;
2007-04-17 05:54:12 +00:00
2008-05-16 19:51:38 +00:00
UNREFERENCED_PARAMETER ( c ) ;
/*
# ifdef _WIN32
if ( qsetmode ! = 200 )
{
OSD_SetFunctions (
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
2009-01-09 09:29:17 +00:00
( int32_t ( * ) ( void ) ) GetTime ,
2008-05-16 19:51:38 +00:00
NULL
) ;
return ;
}
# endif
*/
2007-04-17 05:54:12 +00:00
if ( getrendermode ( ) < 3 ) bits = BITS ;
else bits = BITSTL ;
daydim = r < < 3 ;
xsiz = tilesizx [ BGTILE ] ;
tx2 = xdim / xsiz ;
ysiz = tilesizy [ BGTILE ] ;
ty2 = daydim / ysiz ;
2009-02-19 16:47:54 +00:00
for ( x = 0 ; x < = tx2 ; x + + )
for ( y = 0 ; y < = ty2 ; y + + )
2007-04-17 05:54:12 +00:00
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 ] ;
2009-02-19 16:47:54 +00:00
for ( x = 0 ; x < = tx2 ; x + + )
2007-04-17 05:54:12 +00:00
rotatesprite ( x * xsiz < < 16 , ( daydim + ysiz + 1 ) < < 16 , 65536L , 1536 , BORDTILE , SHADE - 12 , PALETTE , BITS , 0 , 0 , xdim , daydim + ysiz + 1 ) ;
}
# endif
2007-08-25 01:05:00 +00:00
enum
{
2006-07-26 01:10:33 +00:00
T_EOF = - 2 ,
T_ERROR = - 1 ,
2007-02-18 22:16:01 +00:00
T_INCLUDE = 0 ,
2007-04-21 20:25:07 +00:00
T_DEFINE = 1 ,
T_LOADGRP ,
T_TILEGROUP ,
T_TILE ,
T_TILERANGE ,
2007-04-21 23:59:56 +00:00
T_HOTKEY ,
2008-02-21 05:11:41 +00:00
T_TILES ,
2008-07-14 01:48:20 +00:00
T_NOAUTOLOAD ,
2008-09-11 21:22:58 +00:00
T_COLORS ,
T_ALPHABET ,
T_MAP ,
T_MAPA ,
T_MAPRANGE ,
T_MAPRANGEA ,
T_OFFSET ,
T_OFFSETA ,
2006-07-26 01:10:33 +00:00
} ;
2006-11-15 01:16:55 +00:00
typedef struct
{
char * text ;
2009-01-09 09:29:17 +00:00
int32_t tokenid ;
2006-11-15 01:16:55 +00:00
}
2006-11-13 23:12:47 +00:00
tokenlist ;
2006-07-26 01:10:33 +00:00
2009-01-09 09:29:17 +00:00
static int32_t getatoken ( scriptfile * sf , tokenlist * tl , int32_t ntokens )
2006-07-26 01:10:33 +00:00
{
char * tok ;
2009-01-09 09:29:17 +00:00
int32_t i ;
2006-07-26 01:10:33 +00:00
if ( ! sf ) return T_ERROR ;
tok = scriptfile_gettoken ( sf ) ;
if ( ! tok ) return T_EOF ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < ntokens ; i + + )
2006-11-15 01:16:55 +00:00
{
2006-07-26 01:10:33 +00:00
if ( ! Bstrcasecmp ( tok , tl [ i ] . text ) )
return tl [ i ] . tokenid ;
}
return T_ERROR ;
}
2008-11-20 14:06:36 +00:00
static void DoAutoload ( const char * fn )
2007-07-04 09:15:08 +00:00
{
Bsprintf ( tempbuf , " autoload/%s " , fn ) ;
getfilenames ( tempbuf , " *.grp " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s/%s " , fn , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
Bsprintf ( tempbuf , " autoload/%s " , fn ) ;
getfilenames ( tempbuf , " *.zip " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s/%s " , fn , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
Bsprintf ( tempbuf , " autoload/%s " , fn ) ;
getfilenames ( tempbuf , " *.pk3 " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s/%s " , fn , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
}
2009-01-09 09:29:17 +00:00
int32_t parsegroupfiles ( scriptfile * script )
2006-07-26 01:10:33 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t tokn ;
2006-07-26 01:10:33 +00:00
char * cmdtokptr ;
2007-04-21 21:01:07 +00:00
tokenlist grptokens [ ] =
2007-08-25 01:05:00 +00:00
{
{ " include " , T_INCLUDE } ,
{ " #include " , T_INCLUDE } ,
{ " loadgrp " , T_LOADGRP } ,
2008-02-21 05:11:41 +00:00
{ " noautoload " , T_NOAUTOLOAD }
2007-08-25 01:05:00 +00:00
} ;
2007-04-21 21:01:07 +00:00
2006-11-15 01:16:55 +00:00
while ( 1 )
{
2006-07-26 01:10:33 +00:00
tokn = getatoken ( script , grptokens , sizeof ( grptokens ) / sizeof ( tokenlist ) ) ;
cmdtokptr = script - > ltextptr ;
2006-11-15 01:16:55 +00:00
switch ( tokn )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
case T_LOADGRP :
{
char * fn ;
2007-07-04 09:15:08 +00:00
pathsearchmode = 1 ;
2006-11-16 03:02:42 +00:00
if ( ! scriptfile_getstring ( script , & fn ) )
2006-07-26 01:10:33 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t j = initgroupfile ( fn ) ;
2006-07-26 01:10:33 +00:00
2006-11-16 03:02:42 +00:00
if ( j = = - 1 )
2007-07-04 09:15:08 +00:00
initprintf ( " Could not find group file '%s'. \n " , fn ) ;
2006-11-16 03:02:42 +00:00
else
2007-07-04 09:15:08 +00:00
{
initprintf ( " Using group file '%s'. \n " , fn ) ;
if ( ! NoAutoLoad )
2008-11-20 14:06:36 +00:00
DoAutoload ( fn ) ;
2007-07-04 09:15:08 +00:00
}
2006-07-26 01:10:33 +00:00
}
2007-07-04 09:15:08 +00:00
pathsearchmode = 0 ;
2006-11-16 03:02:42 +00:00
}
2007-07-04 09:15:08 +00:00
break ;
2007-02-18 22:16:01 +00:00
case T_INCLUDE :
{
char * fn ;
2007-02-26 01:46:38 +00:00
if ( ! scriptfile_getstring ( script , & fn ) )
{
2007-02-18 22:16:01 +00:00
scriptfile * included ;
included = scriptfile_fromfile ( fn ) ;
2007-02-26 01:46:38 +00:00
if ( ! included )
{
2007-02-18 22:16:01 +00:00
initprintf ( " Warning: Failed including %s on line %s:%d \n " ,
fn , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
2007-02-26 01:46:38 +00:00
}
else
{
2007-04-21 20:25:07 +00:00
parsegroupfiles ( included ) ;
2007-02-18 22:16:01 +00:00
scriptfile_close ( included ) ;
}
}
break ;
}
2006-11-16 03:02:42 +00:00
break ;
2008-02-21 05:11:41 +00:00
case T_NOAUTOLOAD :
NoAutoLoad = 1 ;
break ;
2006-11-16 03:02:42 +00:00
case T_EOF :
return ( 0 ) ;
default :
2006-07-26 01:10:33 +00:00
break ;
}
}
2007-04-21 20:25:07 +00:00
return 0 ;
}
2009-01-09 09:29:17 +00:00
int32_t loadgroupfiles ( char * fn )
2007-04-21 20:25:07 +00:00
{
scriptfile * script ;
script = scriptfile_fromfile ( fn ) ;
if ( ! script ) return - 1 ;
parsegroupfiles ( script ) ;
scriptfile_close ( script ) ;
scriptfile_clearsymbols ( ) ;
return 0 ;
}
2009-01-09 09:29:17 +00:00
int32_t parsetilegroups ( scriptfile * script )
2007-04-21 20:25:07 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t tokn ;
2007-04-21 20:25:07 +00:00
char * cmdtokptr ;
2007-04-21 21:01:07 +00:00
tokenlist tgtokens [ ] =
2007-08-25 01:05:00 +00:00
{
{ " include " , T_INCLUDE } ,
{ " #include " , T_INCLUDE } ,
{ " define " , T_DEFINE } ,
{ " #define " , T_DEFINE } ,
{ " tilegroup " , T_TILEGROUP } ,
2008-08-28 15:04:16 +00:00
{ " spritehotkey " , T_HOTKEY } ,
2008-09-25 11:01:37 +00:00
{ " alphabet " , T_ALPHABET } ,
2007-08-25 01:05:00 +00:00
} ;
2007-04-21 21:01:07 +00:00
2007-04-21 20:25:07 +00:00
while ( 1 )
{
tokn = getatoken ( script , tgtokens , sizeof ( tgtokens ) / sizeof ( tokenlist ) ) ;
cmdtokptr = script - > ltextptr ;
switch ( tokn )
{
2008-08-28 15:04:16 +00:00
case T_HOTKEY :
{
2009-01-09 09:29:17 +00:00
int32_t i , j ;
2008-08-28 15:04:16 +00:00
if ( scriptfile_getsymbol ( script , & i ) ) break ;
if ( scriptfile_getsymbol ( script , & j ) ) break ;
if ( i < 0 | | i > 9 | | j < 0 | | j > = MAXTILES ) break ;
prefixtiles [ i ] = j ;
break ;
}
2007-04-21 20:25:07 +00:00
case T_INCLUDE :
{
char * fn ;
if ( ! scriptfile_getstring ( script , & fn ) )
{
scriptfile * included ;
included = scriptfile_fromfile ( fn ) ;
if ( ! included )
{
initprintf ( " Warning: Failed including %s on line %s:%d \n " ,
fn , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
}
else
{
parsetilegroups ( included ) ;
scriptfile_close ( included ) ;
}
}
break ;
}
case T_DEFINE :
{
char * name ;
2009-01-09 09:29:17 +00:00
int32_t number ;
2007-04-21 20:25:07 +00:00
if ( scriptfile_getstring ( script , & name ) ) break ;
if ( scriptfile_getsymbol ( script , & number ) ) break ;
if ( scriptfile_addsymbolvalue ( name , number ) < 0 )
initprintf ( " Warning: Symbol %s was NOT redefined to %d on line %s:%d \n " ,
name , number , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
break ;
}
case T_TILEGROUP :
{
char * end , * name ;
2009-01-09 09:29:17 +00:00
int32_t i ;
2007-04-21 20:25:07 +00:00
2007-04-21 23:59:56 +00:00
if ( tile_groups > = MAX_TILE_GROUPS ) break ;
2007-04-21 21:01:07 +00:00
if ( scriptfile_getstring ( script , & name ) ) break ;
2007-04-21 23:59:56 +00:00
if ( scriptfile_getbraces ( script , & end ) ) break ;
2007-04-21 21:01:07 +00:00
2009-01-09 09:29:17 +00:00
s_TileGroups [ tile_groups ] . pIds = Bcalloc ( MAX_TILE_GROUP_ENTRIES , sizeof ( int32_t ) ) ;
2007-04-22 03:44:54 +00:00
s_TileGroups [ tile_groups ] . szText = Bstrdup ( name ) ;
2007-04-21 20:25:07 +00:00
while ( script - > textptr < end )
{
2007-05-17 19:31:14 +00:00
tokenlist tgtokens2 [ ] =
2007-08-25 01:05:00 +00:00
{
{ " tilegroup " , T_TILEGROUP } ,
{ " tile " , T_TILE } ,
{ " tilerange " , T_TILERANGE } ,
{ " hotkey " , T_HOTKEY } ,
{ " tiles " , T_TILES } ,
2008-07-14 01:48:20 +00:00
{ " colors " , T_COLORS } ,
2007-08-25 01:05:00 +00:00
} ;
2007-04-21 21:01:07 +00:00
2009-01-09 09:29:17 +00:00
int32_t token = getatoken ( script , tgtokens2 , sizeof ( tgtokens2 ) / sizeof ( tokenlist ) ) ;
2007-04-21 20:25:07 +00:00
switch ( token )
{
case T_TILE :
{
if ( scriptfile_getsymbol ( script , & i ) ) break ;
2007-04-21 21:01:07 +00:00
if ( i > = 0 & & i < MAXTILES & & s_TileGroups [ tile_groups ] . nIds < MAX_TILE_GROUP_ENTRIES )
s_TileGroups [ tile_groups ] . pIds [ s_TileGroups [ tile_groups ] . nIds + + ] = i ;
2007-04-21 20:25:07 +00:00
// OSD_Printf("added tile %d to group %d\n",i,g);
break ;
}
case T_TILERANGE :
{
2009-01-09 09:29:17 +00:00
int32_t j ;
2007-04-21 20:25:07 +00:00
if ( scriptfile_getsymbol ( script , & i ) ) break ;
if ( scriptfile_getsymbol ( script , & j ) ) break ;
if ( i < 0 | | i > = MAXTILES | | j < 0 | | j > = MAXTILES ) break ;
2007-04-21 23:59:56 +00:00
while ( s_TileGroups [ tile_groups ] . nIds < MAX_TILE_GROUP_ENTRIES & & i < = j )
2007-04-21 20:25:07 +00:00
{
2007-04-21 21:01:07 +00:00
s_TileGroups [ tile_groups ] . pIds [ s_TileGroups [ tile_groups ] . nIds + + ] = i + + ;
2007-04-21 20:25:07 +00:00
// OSD_Printf("added tile %d to group %d\n",i,g);
}
break ;
}
2008-07-14 01:48:20 +00:00
case T_COLORS :
{
2009-01-09 09:29:17 +00:00
int32_t j ;
2008-07-14 01:48:20 +00:00
if ( scriptfile_getsymbol ( script , & i ) ) break ;
if ( scriptfile_getsymbol ( script , & j ) ) break ;
if ( i < 0 | | i > = 256 | | j < 0 | | j > = 256 ) break ;
s_TileGroups [ tile_groups ] . color1 = i ;
s_TileGroups [ tile_groups ] . color2 = j ;
break ;
}
2007-04-21 23:59:56 +00:00
case T_HOTKEY :
2007-04-21 20:25:07 +00:00
{
char * c ;
if ( scriptfile_getstring ( script , & c ) ) break ;
2007-04-21 21:01:07 +00:00
s_TileGroups [ tile_groups ] . key1 = Btoupper ( c [ 0 ] ) ;
s_TileGroups [ tile_groups ] . key2 = Btolower ( c [ 0 ] ) ;
break ;
}
case T_TILES :
{
char * end2 ;
if ( scriptfile_getbraces ( script , & end2 ) ) break ;
while ( script - > textptr < end2 - 1 )
{
if ( ! scriptfile_getsymbol ( script , & i ) )
{
if ( i > = 0 & & i < MAXTILES & & s_TileGroups [ tile_groups ] . nIds < MAX_TILE_GROUP_ENTRIES )
s_TileGroups [ tile_groups ] . pIds [ s_TileGroups [ tile_groups ] . nIds + + ] = i ;
2007-05-17 19:31:14 +00:00
// OSD_Printf("added tile %d to group %d\n",i,g);
2007-04-21 21:01:07 +00:00
}
}
2007-04-21 20:25:07 +00:00
break ;
}
}
}
2009-01-09 09:29:17 +00:00
s_TileGroups [ tile_groups ] . pIds = Brealloc ( s_TileGroups [ tile_groups ] . pIds , s_TileGroups [ tile_groups ] . nIds * sizeof ( int32_t ) ) ;
2007-04-21 21:01:07 +00:00
tile_groups + + ;
2007-04-21 20:25:07 +00:00
break ;
}
2008-09-11 21:22:58 +00:00
case T_ALPHABET :
{
char * end ;
2009-01-09 09:29:17 +00:00
int32_t i , j , k ;
2008-09-11 21:22:58 +00:00
if ( numalphabets > = MAX_ALPHABETS ) break ;
if ( scriptfile_getbraces ( script , & end ) ) break ;
for ( i = 0 ; i < NUMPRINTABLES ; i + + )
{
alphabets [ numalphabets ] . pic [ i ] = - 1 ;
alphabets [ numalphabets ] . xofs [ i ] = 0 ;
alphabets [ numalphabets ] . yofs [ i ] = 0 ;
}
while ( script - > textptr < end )
{
tokenlist alphtokens2 [ ] =
{
{ " map " , T_MAP } ,
{ " mapa " , T_MAPA } ,
{ " maprange " , T_MAPRANGE } ,
{ " maprangea " , T_MAPRANGEA } ,
{ " offset " , T_OFFSET } ,
{ " offseta " , T_OFFSETA } ,
} ;
2009-01-09 09:29:17 +00:00
int32_t token = getatoken ( script , alphtokens2 , sizeof ( alphtokens2 ) / sizeof ( tokenlist ) ) ;
2008-09-11 21:22:58 +00:00
switch ( token )
{
case T_MAP : // map <ascii num> <start tilenum>, e.g. map 46 3002
{
if ( scriptfile_getnumber ( script , & i ) ) break ;
if ( scriptfile_getsymbol ( script , & j ) ) break ;
if ( i > = 33 & & i < = 126 & & j > = 0 & & j < MAXTILES )
alphabets [ numalphabets ] . pic [ i - 33 ] = j ;
break ;
}
case T_MAPA : // mapa <ascii string> <start tilenum>, e.g. map ".,!?" 3002
{
char * s ;
if ( scriptfile_getstring ( script , & s ) ) break ;
if ( scriptfile_getsymbol ( script , & i ) ) break ;
2009-02-19 16:47:54 +00:00
for ( ; * s ; s + + , i + + )
2008-09-11 21:22:58 +00:00
{
if ( * s > = 33 & & * s < = 126 & & i > = 0 & & i < MAXTILES )
alphabets [ numalphabets ] . pic [ ( * s ) - 33 ] = i ;
}
break ;
}
// maprange <start ascii num> <end ascii num> <start tilenum>, e.g. map 33 126 STARTALPHANUM
// maprangea <start char> <end char> <start tilenum>, e.g. map "!" "~" STARTALPHANUM
case T_MAPRANGE :
case T_MAPRANGEA :
{
if ( token = = T_MAPRANGE )
{
if ( scriptfile_getnumber ( script , & i ) ) break ;
if ( scriptfile_getnumber ( script , & j ) ) break ;
}
else
{
char * c1 , * c2 ;
if ( scriptfile_getstring ( script , & c1 ) ) break ;
if ( scriptfile_getstring ( script , & c2 ) ) break ;
i = * c1 ;
j = * c2 ;
}
if ( scriptfile_getsymbol ( script , & k ) ) break ;
2008-09-15 02:47:02 +00:00
if ( i > 126 | | j < 33 ) break ;
2008-09-11 21:22:58 +00:00
for ( ; i < = j & & k < MAXTILES ; i + + , k + + )
{
if ( i > = 33 & & i < = 126 )
alphabets [ numalphabets ] . pic [ i - 33 ] = k ;
}
break ;
}
case T_OFFSET : // offset <ascii num> <xoffset> <yoffset>
{
if ( scriptfile_getnumber ( script , & i ) ) break ;
if ( scriptfile_getnumber ( script , & j ) ) break ;
if ( scriptfile_getnumber ( script , & k ) ) break ;
if ( i > = 33 & & i < = 126 )
{
alphabets [ numalphabets ] . xofs [ i - 33 ] = j ;
alphabets [ numalphabets ] . yofs [ i - 33 ] = k ;
}
break ;
}
case T_OFFSETA : // offseta <ascii string> <xoffset> <yoffset>
{
char * s ;
if ( scriptfile_getstring ( script , & s ) ) break ;
if ( scriptfile_getnumber ( script , & i ) ) break ;
if ( scriptfile_getnumber ( script , & j ) ) break ;
2009-02-19 16:47:54 +00:00
for ( ; * s ; s + + )
2008-09-11 21:22:58 +00:00
if ( * s > = 33 & & * s < = 126 )
{
alphabets [ numalphabets ] . xofs [ ( * s ) - 33 ] = i ;
alphabets [ numalphabets ] . yofs [ ( * s ) - 33 ] = j ;
}
break ;
}
}
}
numalphabets + + ;
break ;
}
case T_EOF :
return ( 0 ) ;
default :
break ;
}
}
return 0 ;
}
2009-01-09 09:29:17 +00:00
int32_t loadtilegroups ( char * fn )
2008-09-11 21:22:58 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , j ;
2008-09-11 21:22:58 +00:00
scriptfile * script ;
2008-09-25 11:01:37 +00:00
TileGroup blank = { NULL , 0 , NULL , 0 , 0 , 0 , 0 } ;
2008-09-11 21:22:58 +00:00
script = scriptfile_fromfile ( fn ) ;
if ( ! script ) return - 1 ;
2008-09-25 11:01:37 +00:00
for ( i = MAX_TILE_GROUPS - 1 ; i > = 0 ; i - - )
{
Bmemcpy ( & s_TileGroups [ i ] , & blank , sizeof ( blank ) ) ;
}
parsetilegroups ( script ) ;
2008-09-11 21:22:58 +00:00
scriptfile_close ( script ) ;
scriptfile_clearsymbols ( ) ;
2008-09-25 11:01:37 +00:00
tilegroupItems = getTileGroup ( " Items " ) ;
tilegroupActors = getTileGroup ( " Actors " ) ;
// Apply 2d sprite colors as specified in tiles.cfg.
for ( i = 0 ; i < MAX_TILE_GROUPS ; i + + )
{
if ( s_TileGroups [ i ] . szText = = NULL ) break ;
// If the colors were specified...
if ( s_TileGroups [ i ] . color1 & & s_TileGroups [ i ] . color2 )
{
for ( j = s_TileGroups [ i ] . nIds - 1 ; j > = 0 ; j - - )
{
// Apply the colors to all tiles in the group.
spritecol2d [ s_TileGroups [ i ] . pIds [ j ] ] [ 0 ] = s_TileGroups [ i ] . color1 ;
spritecol2d [ s_TileGroups [ i ] . pIds [ j ] ] [ 1 ] = s_TileGroups [ i ] . color2 ;
}
}
}
2008-09-11 21:22:58 +00:00
return 0 ;
}
2009-01-09 09:29:17 +00:00
int32_t ExtInit ( void )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t rv = 0 ;
int32_t i ;
2007-01-21 23:49:07 +00:00
char cwd [ BMAX_PATH ] ;
2007-02-26 01:46:38 +00:00
# if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
addsearchpath ( " /usr/share/games/jfduke3d " ) ;
addsearchpath ( " /usr/local/share/games/jfduke3d " ) ;
addsearchpath ( " /usr/share/games/eduke32 " ) ;
addsearchpath ( " /usr/local/share/games/eduke32 " ) ;
# elif defined(__APPLE__)
addsearchpath ( " /Library/Application Support/JFDuke3D " ) ;
addsearchpath ( " /Library/Application Support/EDuke32 " ) ;
# endif
2008-08-23 07:32:15 +00:00
if ( getcwd ( cwd , BMAX_PATH ) )
{
# if defined(__APPLE__)
2008-08-23 03:12:23 +00:00
/* Dirty hack on OS X to also look for gamedata inside the application bundle - rhoenie 08/08 */
char seekinappcontainer [ BMAX_PATH ] ;
Bsnprintf ( seekinappcontainer , sizeof ( seekinappcontainer ) , " %s/EDuke32.app/ " , cwd ) ;
addsearchpath ( seekinappcontainer ) ;
2008-08-23 07:32:15 +00:00
# endif
2008-08-23 03:12:23 +00:00
addsearchpath ( cwd ) ;
2008-10-14 08:40:59 +00:00
Bstrcpy ( program_origcwd , cwd ) ;
2008-08-23 03:12:23 +00:00
}
2008-10-14 08:40:59 +00:00
else
program_origcwd [ 0 ] = ' \0 ' ;
2007-01-21 23:49:07 +00:00
if ( CommandPaths )
{
struct strllist * s ;
while ( CommandPaths )
{
s = CommandPaths - > next ;
addsearchpath ( CommandPaths - > str ) ;
free ( CommandPaths - > str ) ;
free ( CommandPaths ) ;
CommandPaths = s ;
}
}
2006-04-13 20:47:06 +00:00
2006-07-01 01:40:18 +00:00
# if defined(_WIN32)
2006-04-13 20:47:06 +00:00
if ( ! access ( " user_profiles_enabled " , F_OK ) )
2007-01-21 23:49:07 +00:00
# else
2007-02-26 01:46:38 +00:00
if ( usecwd = = 0 & & access ( " user_profiles_disabled " , F_OK ) )
2006-04-13 20:47:06 +00:00
# endif
{
char * homedir ;
2009-01-09 09:29:17 +00:00
int32_t asperr ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
if ( ( homedir = Bgethomedir ( ) ) )
{
2006-04-13 20:47:06 +00:00
Bsnprintf ( cwd , sizeof ( cwd ) , " %s/ "
# if defined(_WIN32)
" EDuke32 Settings "
# elif defined(__APPLE__)
" Library/Application Support/EDuke32 "
# else
" .eduke32 "
# endif
, homedir ) ;
asperr = addsearchpath ( cwd ) ;
2006-11-15 01:16:55 +00:00
if ( asperr = = - 2 )
{
2006-04-13 20:47:06 +00:00
if ( Bmkdir ( cwd , S_IRWXU ) = = 0 ) asperr = addsearchpath ( cwd ) ;
else asperr = - 1 ;
}
if ( asperr = = 0 )
chdir ( cwd ) ;
Bfree ( homedir ) ;
}
}
// JBF 20031220: Because it's annoying renaming GRP files whenever I want to test different game data
2006-11-15 01:16:55 +00:00
if ( getenv ( " DUKE3DGRP " ) )
{
2006-04-13 20:47:06 +00:00
duke3dgrp = getenv ( " DUKE3DGRP " ) ;
initprintf ( " Using %s as main GRP file \n " , duke3dgrp ) ;
}
2007-07-04 09:15:08 +00:00
i = initgroupfile ( duke3dgrp ) ;
2007-02-26 01:46:38 +00:00
2007-07-04 09:15:08 +00:00
if ( ! NoAutoLoad )
{
getfilenames ( " autoload " , " *.grp " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s " , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
getfilenames ( " autoload " , " *.zip " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s " , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
getfilenames ( " autoload " , " *.pk3 " ) ;
while ( findfiles ) { Bsprintf ( tempbuf , " autoload/%s " , findfiles - > name ) ; initprintf ( " Using group file '%s'. \n " , tempbuf ) ; initgroupfile ( tempbuf ) ; findfiles = findfiles - > next ; }
if ( i ! = - 1 )
2008-11-20 14:06:36 +00:00
DoAutoload ( duke3dgrp ) ;
2007-07-04 09:15:08 +00:00
}
2007-02-25 21:11:59 +00:00
2006-11-15 01:16:55 +00:00
if ( getenv ( " DUKE3DDEF " ) )
{
2006-04-13 20:47:06 +00:00
defsfilename = getenv ( " DUKE3DDEF " ) ;
2007-04-17 05:54:12 +00:00
initprintf ( " Using '%s' as definitions file \n " , defsfilename ) ;
2006-04-13 20:47:06 +00:00
}
2006-04-16 03:42:36 +00:00
loadgroupfiles ( defsfilename ) ;
2007-01-21 23:49:07 +00:00
2007-08-25 01:05:00 +00:00
{
2007-12-12 15:27:34 +00:00
struct strllist * s ;
2009-01-09 09:29:17 +00:00
int32_t j ;
2007-12-12 15:27:34 +00:00
pathsearchmode = 1 ;
while ( CommandGrps )
2007-08-25 01:05:00 +00:00
{
2007-12-12 15:27:34 +00:00
s = CommandGrps - > next ;
j = initgroupfile ( CommandGrps - > str ) ;
if ( j = = - 1 ) initprintf ( " Could not find group file '%s'. \n " , CommandGrps - > str ) ;
else
{
initprintf ( " Using group file '%s'. \n " , CommandGrps - > str ) ;
if ( ! NoAutoLoad )
2008-11-20 14:06:36 +00:00
DoAutoload ( CommandGrps - > str ) ;
2007-12-12 15:27:34 +00:00
}
free ( CommandGrps - > str ) ;
free ( CommandGrps ) ;
CommandGrps = s ;
2007-07-04 09:15:08 +00:00
}
2007-12-12 15:27:34 +00:00
pathsearchmode = 0 ;
2007-07-04 09:15:08 +00:00
}
2006-11-17 05:05:16 +00:00
bpp = 32 ;
2006-08-10 02:10:24 +00:00
2006-10-29 20:18:04 +00:00
# if defined(POLYMOST) && defined(USE_OPENGL)
2006-08-10 02:10:24 +00:00
glusetexcache = glusetexcachecompression = - 1 ;
2007-02-26 01:46:38 +00:00
initprintf ( " Using config file '%s'. \n " , setupfilename ) ;
2007-01-21 23:49:07 +00:00
if ( loadsetup ( setupfilename ) < 0 ) initprintf ( " Configuration file not found, using defaults. \n " ) , rv = 1 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( glusetexcache = = - 1 | | glusetexcachecompression = = - 1 )
2006-08-10 02:10:24 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2006-12-14 03:34:55 +00:00
# if 1
2009-02-19 09:39:19 +00:00
i = wm_ynbox ( " Texture Cache " ,
2008-12-10 11:36:53 +00:00
" Would you like to enable the on-disk texture cache? \n \n "
2009-02-19 09:39:19 +00:00
" You generally want to say 'yes' here, especially if using the HRP. " ) ;
2006-12-14 03:34:55 +00:00
# else
i = 1 ;
2007-01-15 00:59:49 +00:00
# endif
2006-12-14 03:34:55 +00:00
if ( i )
2006-08-10 02:10:24 +00:00
glusetexcompr = glusetexcache = glusetexcachecompression = 1 ;
else glusetexcache = glusetexcachecompression = 0 ;
}
2006-10-29 20:18:04 +00:00
# endif
2006-08-10 02:10:24 +00:00
2006-04-13 20:47:06 +00:00
Bmemcpy ( ( void * ) buildkeys , ( void * ) keys , NUMBUILDKEYS ) ; //Trick to make build use setup.dat keys
2006-11-15 01:16:55 +00:00
if ( initengine ( ) )
{
2008-02-24 00:46:57 +00:00
initprintf ( " There was a problem initializing the engine. \n " ) ;
2006-04-13 20:47:06 +00:00
return - 1 ;
}
2006-11-17 05:05:16 +00:00
2006-04-13 20:47:06 +00:00
kensplayerheight = 40 ; //32
zmode = 2 ;
zlock = kensplayerheight < < 8 ;
defaultspritecstat = 0 ;
ReadGamePalette ( ) ;
// InitWater();
InitCustomColors ( ) ;
getmessageleng = 0 ;
getmessagetimeoff = 0 ;
2008-08-28 23:15:11 +00:00
Bstrcpy ( apptitle , " Mapster32 " VERSION BUILDDATE ) ;
2008-06-01 01:57:01 +00:00
autosavetimer = totalclock + 120 * autosave ;
2006-04-13 20:47:06 +00:00
2007-04-17 05:54:12 +00:00
# if defined(_WIN32) && defined(DUKEOSD)
OSD_SetFunctions (
2008-05-18 21:09:30 +00:00
/* GAME_drawosdchar,
GAME_drawosdstr ,
GAME_drawosdcursor ,
GAME_getcolumnwidth ,
GAME_getrowheight , */
0 , 0 , 0 , 0 , 0 ,
2007-04-17 05:54:12 +00:00
GAME_clearbackground ,
2009-01-09 09:29:17 +00:00
( int32_t ( * ) ( void ) ) GetTime ,
2007-04-17 05:54:12 +00:00
NULL
) ;
# endif
OSD_SetParameters ( 0 , 2 , 0 , 0 , 4 , 0 ) ;
registerosdcommands ( ) ;
2006-04-13 20:47:06 +00:00
2007-04-21 20:25:07 +00:00
loadtilegroups ( " tiles.cfg " ) ;
2008-08-23 10:34:59 +00:00
ReadHelpFile ( " m32help.hlp " ) ;
2006-04-13 20:47:06 +00:00
return rv ;
}
2008-05-10 01:29:37 +00:00
# ifdef RENDERTYPEWIN
void app_crashhandler ( void )
{
if ( levelname [ 0 ] )
{
char * f ;
fixspritesectors ( ) ; //Do this before saving!
updatesector ( startposx , startposy , & startsectnum ) ;
2008-05-31 01:57:14 +00:00
if ( pathsearchmode )
f = levelname ;
2008-05-10 01:29:37 +00:00
else
{
// virtual filesystem mode can't save to directories so drop the file into
// the current directory
f = strrchr ( levelname , ' / ' ) ;
if ( ! f ) f = levelname ; else f + + ;
}
2008-05-16 19:51:38 +00:00
f = strstr ( levelname , " .map " ) ;
2008-05-31 01:57:14 +00:00
if ( f )
Bstrcpy ( f , " _crash.map " ) ;
else Bstrcat ( f , " _crash.map " ) ;
2008-05-10 01:29:37 +00:00
ExtPreSaveMap ( ) ;
2008-05-16 19:51:38 +00:00
saveboard ( levelname , & startposx , & startposy , & startposz , & startang , & startsectnum ) ;
ExtSaveMap ( levelname ) ;
2008-05-10 01:29:37 +00:00
}
}
# endif
2006-04-13 20:47:06 +00:00
void ExtUnInit ( void )
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2006-04-13 20:47:06 +00:00
// setvmode(0x03);
uninitgroupfile ( ) ;
2007-01-21 23:49:07 +00:00
writesetup ( setupfilename ) ;
2007-04-21 20:25:07 +00:00
2008-08-23 10:34:59 +00:00
for ( i = MAX_TILE_GROUPS - 1 ; i > = 0 ; i - - )
2007-04-21 20:25:07 +00:00
{
if ( s_TileGroups [ i ] . pIds ! = NULL )
Bfree ( s_TileGroups [ i ] . pIds ) ;
if ( s_TileGroups [ i ] . szText ! = NULL )
Bfree ( s_TileGroups [ i ] . szText ) ;
}
2009-02-19 16:47:54 +00:00
for ( i = numhelppages - 1 ; i > = 0 ; i - - ) free ( helppage [ i ] ) ;
2008-06-05 19:10:34 +00:00
if ( helppage ) free ( helppage ) ;
2006-04-13 20:47:06 +00:00
}
2008-06-05 02:29:18 +00:00
static char wallshades [ MAXWALLS ] ;
static char sectorshades [ MAXSECTORS ] [ 2 ] ;
static char spriteshades [ MAXSPRITES ] ;
static char wallpals [ MAXWALLS ] ;
static char sectorpals [ MAXSECTORS ] [ 2 ] ;
static char spritepals [ MAXSPRITES ] ;
static char wallflag [ MAXWALLS ] ;
2009-01-09 09:29:17 +00:00
extern int32_t graphicsmode ;
2008-06-05 02:29:18 +00:00
2006-04-13 20:47:06 +00:00
void ExtPreCheckKeys ( void ) // just before drawrooms
{
2009-01-09 09:29:17 +00:00
int32_t i = 0 ;
int32_t radius , xp1 , yp1 ;
int32_t col ;
int32_t picnum , frames ;
int32_t ang = 0 , flags , shade ;
2008-12-19 00:53:54 +00:00
2006-04-13 20:47:06 +00:00
if ( qsetmode = = 200 ) //In 3D mode
{
2008-06-05 02:29:18 +00:00
if ( shadepreview )
{
2009-01-09 09:29:17 +00:00
int32_t i = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = numsprites - 1 ; i > = 0 ; i - - )
2008-06-05 02:29:18 +00:00
if ( sprite [ i ] . picnum = = SECTOREFFECTOR & & ( sprite [ i ] . lotag = = 12 | | sprite [ i ] . lotag = = 3 ) )
{
2009-01-09 09:29:17 +00:00
int32_t w ;
int32_t start_wall = sector [ sprite [ i ] . sectnum ] . wallptr ;
int32_t end_wall = start_wall + sector [ sprite [ i ] . sectnum ] . wallnum ;
2008-06-05 02:29:18 +00:00
for ( w = start_wall ; w < end_wall ; w + + )
{
if ( ! wallflag [ w ] )
{
wallshades [ w ] = wall [ w ] . shade ;
wall [ w ] . shade = sprite [ i ] . shade ;
wallpals [ w ] = wall [ w ] . pal ;
wall [ w ] . pal = sprite [ i ] . pal ;
wallflag [ w ] = 1 ;
}
2008-06-09 23:41:54 +00:00
/* if (wall[w].nextwall >= 0)
{
if ( ! wallflag [ wall [ w ] . nextwall ] )
{
wallshades [ wall [ w ] . nextwall ] = wall [ wall [ w ] . nextwall ] . shade ;
wall [ wall [ w ] . nextwall ] . shade = sprite [ i ] . shade ;
wallpals [ wall [ w ] . nextwall ] = wall [ wall [ w ] . nextwall ] . pal ;
wall [ wall [ w ] . nextwall ] . pal = sprite [ i ] . pal ;
wallflag [ wall [ w ] . nextwall ] = 1 ;
}
} */
2008-06-05 02:29:18 +00:00
}
sectorshades [ sprite [ i ] . sectnum ] [ 0 ] = sector [ sprite [ i ] . sectnum ] . floorshade ;
sectorshades [ sprite [ i ] . sectnum ] [ 1 ] = sector [ sprite [ i ] . sectnum ] . ceilingshade ;
sector [ sprite [ i ] . sectnum ] . floorshade = sprite [ i ] . shade ;
sector [ sprite [ i ] . sectnum ] . ceilingshade = sprite [ i ] . shade ;
sectorpals [ sprite [ i ] . sectnum ] [ 0 ] = sector [ sprite [ i ] . sectnum ] . floorpal ;
sectorpals [ sprite [ i ] . sectnum ] [ 1 ] = sector [ sprite [ i ] . sectnum ] . ceilingpal ;
sector [ sprite [ i ] . sectnum ] . floorpal = sprite [ i ] . pal ;
sector [ sprite [ i ] . sectnum ] . ceilingpal = sprite [ i ] . pal ;
w = headspritesect [ sprite [ i ] . sectnum ] ;
while ( w > = 0 )
{
if ( w = = i ) { w = nextspritesect [ w ] ; continue ; }
spriteshades [ w ] = sprite [ w ] . shade ;
sprite [ w ] . shade = sprite [ i ] . shade ;
spritepals [ w ] = sprite [ w ] . pal ;
sprite [ w ] . pal = sprite [ i ] . pal ;
w = nextspritesect [ w ] ;
}
}
}
2009-01-13 12:23:18 +00:00
if ( floor_over_floor ) SE40Code ( pos . x , pos . y , pos . z , ang , horiz ) ;
2006-11-13 23:12:47 +00:00
if ( purpleon ) clearview ( 255 ) ;
2006-04-13 20:47:06 +00:00
if ( sidemode ! = 0 )
{
lockbyte4094 = 1 ;
if ( waloff [ 4094 ] = = 0 )
allocache ( & waloff [ 4094 ] , 320L * 200L , & lockbyte4094 ) ;
setviewtotile ( 4094 , 320L , 200L ) ;
2006-11-15 01:16:55 +00:00
searchx ^ = searchy ;
searchy ^ = searchx ;
searchx ^ = searchy ;
2006-04-13 20:47:06 +00:00
searchx = ydim - 1 - searchx ;
}
2008-12-19 00:53:54 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2008-12-19 00:53:54 +00:00
begindrawing ( ) ;
// if (cursectornum >= 0)
// fillsector(cursectornum, 31);
2008-12-25 12:56:25 +00:00
if ( graphicsmode & & zoom > = 256 )
2008-12-19 00:53:54 +00:00
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsprites ; i + + )
2008-12-25 12:56:25 +00:00
{
2008-12-28 23:27:24 +00:00
if ( ( sprite [ i ] . cstat & 48 ) ! = 0 | | sprite [ i ] . statnum = = MAXSTATUS ) continue ;
2008-12-25 12:56:25 +00:00
picnum = sprite [ i ] . picnum ;
ang = flags = frames = shade = 0 ;
switch ( picnum )
{
// 5-frame walk
case 1550 : // Shark
frames = 5 ;
// 2-frame walk
case 1445 : // duke kick
case LIZTROOPDUCKING :
case 2030 : // pig shot
case OCTABRAIN :
case PIGCOPDIVE :
case 2190 : // liz capt shot
case BOSS1SHOOT :
case BOSS1LOB :
case LIZTROOPSHOOT :
if ( frames = = 0 ) frames = 2 ;
// 4-frame walk
case 1491 : // duke crawl
case LIZTROOP :
case LIZTROOPRUNNING :
case PIGCOP :
case LIZMAN :
case BOSS1 :
case BOSS2 :
case BOSS3 :
case BOSS4 :
case NEWBEAST :
if ( frames = = 0 ) frames = 4 ;
case LIZTROOPJETPACK :
case DRONE :
case COMMANDER :
case TANK :
case RECON :
if ( frames = = 0 ) frames = 10 ;
case CAMERA1 :
case APLAYER :
if ( frames = = 0 ) frames = 1 ;
case GREENSLIME :
case EGG :
case PIGCOPSTAYPUT :
case LIZMANSTAYPUT :
case LIZTROOPSTAYPUT :
case LIZMANSPITTING :
case LIZMANFEEDING :
case LIZMANJUMP :
2009-01-04 22:22:33 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t k ;
2009-01-04 22:22:33 +00:00
if ( frames ! = 0 )
2008-12-25 12:56:25 +00:00
{
2009-01-04 22:22:33 +00:00
if ( frames = = 10 ) frames = 0 ;
2009-01-13 12:23:18 +00:00
k = 1536 ; //getangle(tspr->x-pos.x,tspr->y-pos.y);
2009-01-04 22:22:33 +00:00
k = ( ( ( sprite [ i ] . ang + 3072 + 128 - k ) & 2047 ) > > 8 ) & 7 ;
//This guy has only 5 pictures for 8 angles (3 are x-flipped)
if ( k < = 4 )
2008-12-25 12:56:25 +00:00
{
2009-01-04 22:22:33 +00:00
picnum + = k ;
ang = 0 ;
flags & = ~ 4 ;
2008-12-25 12:56:25 +00:00
}
2009-01-04 22:22:33 +00:00
else
2008-12-28 23:27:24 +00:00
{
2009-01-04 22:22:33 +00:00
picnum + = 8 - k ;
ang = 1024 ;
flags | = 4 ;
2008-12-28 23:27:24 +00:00
}
2009-01-04 22:22:33 +00:00
}
2008-12-25 12:56:25 +00:00
2009-01-04 22:22:33 +00:00
if ( graphicsmode = = 2 )
{
if ( frames = = 2 ) picnum + = ( ( ( ( 4 - ( totalclock > > 5 ) ) ) & 1 ) * 5 ) ;
if ( frames = = 4 ) picnum + = ( ( ( ( 4 - ( totalclock > > 5 ) ) ) & 3 ) * 5 ) ;
if ( frames = = 5 ) picnum + = ( ( ( totalclock > > 5 ) % 5 ) ) * 5 ;
2008-12-25 12:56:25 +00:00
}
2009-01-04 22:22:33 +00:00
if ( tilesizx [ picnum ] = = 0 )
picnum - = 5 ; //Hack, for actors
}
break ;
2008-12-25 12:56:25 +00:00
default :
break ;
2008-12-19 00:53:54 +00:00
2008-12-25 12:56:25 +00:00
}
2009-01-13 12:23:18 +00:00
xp1 = mulscale14 ( sprite [ i ] . x - pos . x , zoom ) ;
yp1 = mulscale14 ( sprite [ i ] . y - pos . y - ( tilesizy [ picnum ] < < 2 ) , zoom ) ;
2008-12-25 12:56:25 +00:00
if ( i + 16384 ! = pointhighlight | | ! ( totalclock & 32 ) )
{
shade = sprite [ i ] . shade ;
if ( shade < 6 )
shade = 6 ;
}
2008-12-28 23:27:24 +00:00
xp1 + = halfxdim16 ;
yp1 + = midydim16 ;
if ( xp1 < 4 | | xp1 > xdim - 6 | | yp1 < 4 | | yp1 > ydim16 - 6 )
continue ;
rotatesprite ( xp1 < < 16 , yp1 < < 16 , zoom < < 5 , ang , picnum ,
2009-01-04 22:22:33 +00:00
shade , sprite [ i ] . pal , flags , 0 , 0 , xdim - 1 , ydim16 - 1 ) ;
2008-12-25 12:56:25 +00:00
}
}
2008-12-23 23:27:53 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsprites ; i + + )
2008-12-19 00:53:54 +00:00
if ( sprite [ i ] . picnum = = 5 /*&& zoom >= 256*/ & & sprite [ i ] . sectnum ! = MAXSECTORS )
{
2009-01-13 12:23:18 +00:00
xp1 = mulscale14 ( sprite [ i ] . x - pos . x , zoom ) ;
yp1 = mulscale14 ( sprite [ i ] . y - pos . y , zoom ) ;
2008-12-25 12:56:25 +00:00
2008-12-19 00:53:54 +00:00
radius = mulscale14 ( sprite [ i ] . hitag , zoom ) ;
col = 6 ;
if ( i + 16384 = = pointhighlight )
if ( totalclock & 32 ) col + = ( 2 < < 2 ) ;
drawlinepat = 0xf0f0f0f0 ;
2009-01-09 09:29:17 +00:00
drawcircle16 ( halfxdim16 + xp1 , midydim16 + yp1 , radius , editorcolors [ ( int32_t ) col ] ) ;
2008-12-19 00:53:54 +00:00
drawlinepat = 0xffffffff ;
// radius = mulscale15(sprite[i].hitag,zoom);
// drawcircle16(halfxdim16+xp1, midydim16+yp1, radius, col);
}
enddrawing ( ) ;
2006-04-13 20:47:06 +00:00
}
void ExtAnalyzeSprites ( void )
{
2009-01-09 09:29:17 +00:00
int32_t i , k ;
2006-04-13 20:47:06 +00:00
spritetype * tspr ;
2009-01-09 09:29:17 +00:00
int32_t frames = 0 , l ;
2006-04-13 20:47:06 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 , tspr = & tsprite [ 0 ] ; i < spritesortcnt ; i + + , tspr + + )
2006-04-13 20:47:06 +00:00
{
frames = 0 ;
2006-11-13 23:12:47 +00:00
if ( ( nosprites = = 1 | | nosprites = = 3 ) & & tspr - > picnum < 11 ) tspr - > xrepeat = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( nosprites = = 1 | | nosprites = = 3 )
switch ( tspr - > picnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case SEENINE :
tspr - > xrepeat = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( shadepreview & & ! ( tspr - > cstat & 16 ) )
2006-04-13 20:47:06 +00:00
{
if ( sector [ tspr - > sectnum ] . ceilingstat & 1 )
l = sector [ tspr - > sectnum ] . ceilingshade ;
else
{
l = sector [ tspr - > sectnum ] . floorshade ;
if ( sector [ tspr - > sectnum ] . floorpal ! = 0 & & sector [ tspr - > sectnum ] . floorpal < num_tables )
tspr - > pal = sector [ tspr - > sectnum ] . floorpal ;
}
2006-11-13 23:12:47 +00:00
if ( l < - 127 ) l = - 127 ;
if ( l > 126 ) l = 127 ;
2006-04-13 20:47:06 +00:00
tspr - > shade = l ;
}
2006-11-13 23:12:47 +00:00
switch ( tspr - > picnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
// 5-frame walk
case 1550 : // Shark
frames = 5 ;
// 2-frame walk
case 1445 : // duke kick
case LIZTROOPDUCKING :
case 2030 : // pig shot
case OCTABRAIN :
case PIGCOPDIVE :
case 2190 : // liz capt shot
case BOSS1SHOOT :
case BOSS1LOB :
case LIZTROOPSHOOT :
if ( frames = = 0 ) frames = 2 ;
// 4-frame walk
case 1491 : // duke crawl
case LIZTROOP :
case LIZTROOPRUNNING :
case PIGCOP :
case LIZMAN :
case BOSS1 :
case BOSS2 :
case BOSS3 :
case BOSS4 :
case NEWBEAST :
if ( frames = = 0 ) frames = 4 ;
case LIZTROOPJETPACK :
case DRONE :
case COMMANDER :
case TANK :
case RECON :
if ( frames = = 0 ) frames = 10 ;
case CAMERA1 :
case APLAYER :
if ( frames = = 0 ) frames = 1 ;
case GREENSLIME :
case EGG :
case PIGCOPSTAYPUT :
case LIZMANSTAYPUT :
case LIZTROOPSTAYPUT :
case LIZMANSPITTING :
case LIZMANFEEDING :
case LIZMANJUMP :
if ( skill ! = 4 )
{
if ( tspr - > lotag > skill + 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
tspr - > xrepeat = 0 ;
2007-03-04 19:52:57 +00:00
tspr - > cstat = 32768 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
if ( nosprites = = 2 | | nosprites = = 3 )
{
tspr - > xrepeat = 0 ;
2007-03-04 19:52:57 +00:00
tspr - > cstat = 32768 ;
2006-11-16 03:02:42 +00:00
}
// else tspr->cstat&=32767;
2006-04-13 20:47:06 +00:00
2007-03-04 19:52:57 +00:00
# if defined(USE_OPENGL) && defined(POLYMOST)
2007-12-20 19:14:38 +00:00
if ( ! usemodels | | md_tilehasmodel ( tspr - > picnum , tspr - > pal ) < 0 )
2007-03-11 00:47:32 +00:00
# endif
2006-11-16 03:02:42 +00:00
{
2007-02-18 22:16:01 +00:00
if ( frames ! = 0 )
2006-11-16 03:02:42 +00:00
{
2007-02-18 22:16:01 +00:00
if ( frames = = 10 ) frames = 0 ;
2009-01-13 12:23:18 +00:00
k = getangle ( tspr - > x - pos . x , tspr - > y - pos . y ) ;
2007-02-18 22:16:01 +00:00
k = ( ( ( tspr - > ang + 3072 + 128 - k ) & 2047 ) > > 8 ) & 7 ;
//This guy has only 5 pictures for 8 angles (3 are x-flipped)
if ( k < = 4 )
{
tspr - > picnum + = k ;
tspr - > cstat & = ~ 4 ; //clear x-flipping bit
}
else
{
tspr - > picnum + = 8 - k ;
tspr - > cstat | = 4 ; //set x-flipping bit
}
2006-11-15 01:16:55 +00:00
}
2007-02-18 22:16:01 +00:00
if ( frames = = 2 ) tspr - > picnum + = ( ( ( ( 4 - ( totalclock > > 5 ) ) ) & 1 ) * 5 ) ;
if ( frames = = 4 ) tspr - > picnum + = ( ( ( ( 4 - ( totalclock > > 5 ) ) ) & 3 ) * 5 ) ;
if ( frames = = 5 ) tspr - > picnum + = ( ( ( totalclock > > 5 ) % 5 ) ) * 5 ;
2006-11-15 01:16:55 +00:00
2007-02-18 22:16:01 +00:00
if ( tilesizx [ tspr - > picnum ] = = 0 )
tspr - > picnum - = 5 ; //Hack, for actors
}
2006-11-16 03:02:42 +00:00
break ;
default :
break ;
2006-04-13 20:47:06 +00:00
}
}
}
2008-05-17 21:44:49 +00:00
# define MESSAGEX 3 // (xdimgame>>1)
# define MESSAGEY 3 // ((i/charsperline)<<3)+(ydimgame-(ydimgame>>3))-(((getmessageleng-1)/charsperline)<<3)
2006-12-10 06:49:01 +00:00
static void Keys2d3d ( void )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2008-06-09 23:41:54 +00:00
if ( keystatus [ KEYSC_F12 ] ) //F12
{
screencapture ( " captxxxx.tga " , keystatus [ KEYSC_LSHIFT ] | keystatus [ KEYSC_RSHIFT ] ) ;
2008-06-11 02:33:23 +00:00
message ( " Saved screenshot %04d " , capturecount - 1 ) ;
2008-06-09 23:41:54 +00:00
keystatus [ KEYSC_F12 ] = 0 ;
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_A ] ) // ' a
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_A ] = 0 ;
2008-10-14 08:40:59 +00:00
if ( qsetmode = = 200 ) autosave = autosave ? 0 : getnumber256 ( " Autosave interval, in seconds: " , 180 , 3600 , 0 ) ;
else autosave = autosave ? 0 : getnumber16 ( " Autosave interval, in seconds: " , 180 , 3600 , 0 ) ;
2008-06-09 23:41:54 +00:00
if ( autosave ) message ( " Autosave enabled, interval: %d seconds " , autosave ) ;
else message ( " Autosave disabled " ) ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_N ] ) // ' n
2006-04-13 20:47:06 +00:00
{
keystatus [ KEYSC_N ] = 0 ;
noclip = ! noclip ;
2006-11-13 23:12:47 +00:00
if ( noclip ) message ( " Clipping disabled " ) ;
2006-04-13 20:47:06 +00:00
else message ( " Clipping enabled " ) ;
}
2008-05-18 21:09:30 +00:00
if ( eitherCTRL & & keystatus [ KEYSC_N ] ) // CTRL+N
{
keystatus [ KEYSC_N ] = 0 ;
spnoclip = ! spnoclip ;
2008-05-18 22:40:33 +00:00
if ( spnoclip ) message ( " Sprite clipping disabled " ) ;
2008-05-18 21:09:30 +00:00
else message ( " Sprite clipping enabled " ) ;
}
2006-04-13 20:47:06 +00:00
if ( ( totalclock > autosavetimer ) & & ( autosave ) )
{
2008-06-01 01:57:01 +00:00
if ( asksave = = 1 )
2006-04-13 20:47:06 +00:00
{
fixspritesectors ( ) ; //Do this before saving!
// updatesector(startposx,startposy,&startsectnum);
ExtPreSaveMap ( ) ;
saveboard ( " autosave.map " , & startposx , & startposy , & startposz , & startang , & startsectnum ) ;
ExtSaveMap ( " autosave.map " ) ;
message ( " Board autosaved to AUTOSAVE.MAP " ) ;
2008-06-01 01:57:01 +00:00
asksave = 2 ;
2006-04-13 20:47:06 +00:00
}
2008-06-01 01:57:01 +00:00
autosavetimer = totalclock + 120 * autosave ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( eitherCTRL ) //CTRL
2008-05-16 19:51:38 +00:00
{
char * f ;
if ( pathsearchmode ) f = levelname ;
else
{
// virtual filesystem mode can't save to directories so drop the file into
// the current directory
f = strrchr ( levelname , ' / ' ) ;
if ( ! f ) f = levelname ; else f + + ;
}
2008-09-12 13:41:18 +00:00
if ( keystatus [ KEYSC_P ] ) // Ctrl-P: Map playtesting
{
keystatus [ KEYSC_P ] = 0 ;
2008-09-16 15:32:59 +00:00
if ( ! eitherALT )
2009-01-13 12:23:18 +00:00
updatesector ( pos . x , pos . y , & cursectnum ) ;
2008-09-16 15:32:59 +00:00
else
updatesector ( startposx , startposy , & startsectnum ) ;
if ( ( ! eitherALT & & cursectnum > = 0 ) | | ( eitherALT & & startsectnum > = 0 ) )
2008-09-12 13:41:18 +00:00
{
2008-10-18 12:37:26 +00:00
char * param = " -map autosave.map -noinstancechecking " ;
char * fullparam ;
char current_cwd [ BMAX_PATH ] ;
2009-01-09 09:29:17 +00:00
int32_t slen = 0 ;
2008-10-18 12:37:26 +00:00
BFILE * fp ;
2008-10-14 08:40:59 +00:00
2008-10-18 12:37:26 +00:00
if ( ( program_origcwd [ 0 ] = = ' \0 ' ) | | ! getcwd ( current_cwd , BMAX_PATH ) )
current_cwd [ 0 ] = ' \0 ' ;
else // Before we check if file exists, for the case there's no absolute path.
chdir ( program_origcwd ) ;
2008-10-14 08:40:59 +00:00
2008-10-18 12:37:26 +00:00
fp = fopen ( game_executable , " rb " ) ; // File exists?
if ( fp ! = NULL )
fclose ( fp ) ;
else
{
2008-10-14 08:40:59 +00:00
# ifdef _WIN32
2008-10-18 12:37:26 +00:00
fullparam = Bstrrchr ( mapster32_fullpath , ' \\ ' ) ;
2008-10-14 08:40:59 +00:00
# else
2008-10-18 12:37:26 +00:00
fullparam = Bstrrchr ( mapster32_fullpath , ' / ' ) ;
2008-10-14 08:40:59 +00:00
# endif
2008-10-18 12:37:26 +00:00
if ( fullparam )
{
slen = fullparam - mapster32_fullpath + 1 ;
Bstrncpy ( game_executable , mapster32_fullpath , slen ) ;
// game_executable is now expected to not be NULL-terminated!
Bstrcpy ( game_executable + slen , DEFAULT_GAME_EXEC ) ;
2008-10-14 08:40:59 +00:00
}
2008-10-18 12:37:26 +00:00
else
Bstrcpy ( game_executable , DEFAULT_GAME_LOCAL_EXEC ) ;
}
2008-09-12 13:41:18 +00:00
2008-10-18 12:37:26 +00:00
if ( current_cwd [ 0 ] ! = ' \0 ' ) // Temporarily changing back,
chdir ( current_cwd ) ; // after checking if file exists.
2008-09-14 14:47:32 +00:00
2008-10-18 12:37:26 +00:00
if ( testplay_addparam )
slen = Bstrlen ( testplay_addparam ) ;
2008-10-14 08:40:59 +00:00
2008-10-18 12:37:26 +00:00
// Considering the NULL character, quatation marks
// and a possible extra space not in testplay_addparam,
// the length should be Bstrlen(game_executable)+Bstrlen(param)+(slen+1)+2+1.
2008-10-14 08:40:59 +00:00
2008-10-18 12:37:26 +00:00
fullparam = Bmalloc ( Bstrlen ( game_executable ) + Bstrlen ( param ) + slen + 4 ) ;
Bsprintf ( fullparam , " \" %s \" " , game_executable ) ;
2008-10-14 08:40:59 +00:00
2008-10-18 12:37:26 +00:00
if ( testplay_addparam )
{
Bstrcat ( fullparam , " " ) ;
Bstrcat ( fullparam , testplay_addparam ) ;
}
Bstrcat ( fullparam , param ) ;
2008-09-14 14:47:32 +00:00
2008-10-18 12:37:26 +00:00
fixspritesectors ( ) ; //Do this before saving!
ExtPreSaveMap ( ) ;
if ( eitherALT )
saveboard ( " autosave.map " , & startposx , & startposy , & startposz , & startang , & startsectnum ) ;
else
2009-01-13 12:23:18 +00:00
saveboard ( " autosave.map " , & pos . x , & pos . y , & pos . z , & ang , & cursectnum ) ;
2008-10-18 12:37:26 +00:00
message ( " Board saved to AUTOSAVE.MAP. Starting the game... " ) ;
2008-09-15 02:47:02 +00:00
2008-10-18 12:37:26 +00:00
uninitmouse ( ) ;
2008-10-14 08:40:59 +00:00
# ifdef _WIN32
2008-10-18 12:37:26 +00:00
{
STARTUPINFO si ;
PROCESS_INFORMATION pi ;
2008-09-14 14:47:32 +00:00
2008-10-18 12:37:26 +00:00
ZeroMemory ( & si , sizeof ( si ) ) ;
ZeroMemory ( & pi , sizeof ( pi ) ) ;
si . cb = sizeof ( si ) ;
2008-10-14 08:40:59 +00:00
2008-10-18 12:37:26 +00:00
if ( ! CreateProcess ( NULL , fullparam , NULL , NULL , 0 , 0 , NULL , NULL , & si , & pi ) )
message ( " Error launching the game! " ) ;
else WaitForSingleObject ( pi . hProcess , INFINITE ) ;
}
2008-10-14 08:40:59 +00:00
# else
2008-10-18 12:37:26 +00:00
if ( current_cwd [ 0 ] ! = ' \0 ' )
{
chdir ( program_origcwd ) ;
system ( fullparam ) ;
2008-10-14 08:40:59 +00:00
// message("Error launching the game!");
2008-10-18 12:37:26 +00:00
chdir ( current_cwd ) ;
}
else system ( fullparam ) ;
# endif
// message("Error launching the game!");
message ( " Game process exited " ) ;
initmouse ( ) ;
2008-09-14 14:47:32 +00:00
2008-10-18 12:37:26 +00:00
Bfree ( fullparam ) ;
2008-09-12 13:41:18 +00:00
}
else
2008-10-14 08:40:59 +00:00
message ( " Position must be in valid player space to test map! " ) ;
2008-09-12 13:41:18 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_S ] ) // S
2006-04-13 20:47:06 +00:00
{
2007-08-17 03:16:46 +00:00
if ( levelname [ 0 ] )
2006-04-13 20:47:06 +00:00
{
fixspritesectors ( ) ; //Do this before saving!
updatesector ( startposx , startposy , & startsectnum ) ;
ExtPreSaveMap ( ) ;
2008-05-10 01:29:37 +00:00
saveboard ( f , & startposx , & startposy , & startposz , & startang , & startsectnum ) ;
ExtSaveMap ( f ) ;
2006-04-13 20:47:06 +00:00
message ( " Board saved " ) ;
asksave = 0 ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_S ] = 0 ;
2008-05-16 19:51:38 +00:00
lastsave = totalclock ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 19:51:38 +00:00
if ( keystatus [ KEYSC_L ] ) // L
{
2009-01-09 09:29:17 +00:00
extern int32_t grponlymode ;
2008-05-16 19:51:38 +00:00
extern void loadmhk ( ) ;
if ( totalclock < ( lastsave + 120 * 10 ) | | ! AskIfSure ( " Are you sure you want to load the last saved map? " ) )
{
2009-01-13 12:23:18 +00:00
int32_t sposx = pos . x , sposy = pos . y , sposz = pos . z , sang = ang ;
2008-05-16 19:51:38 +00:00
lastsave = totalclock ;
highlightcnt = - 1 ;
// sectorhighlightstat = -1;
// newnumwalls = -1;
// joinsector[0] = -1;
// circlewall = -1;
// circlepoints = 7;
2009-02-19 16:47:54 +00:00
for ( i = MAXSECTORS - 1 ; i > = 0 ; i - - ) sector [ i ] . extra = - 1 ;
for ( i = MAXWALLS - 1 ; i > = 0 ; i - - ) wall [ i ] . extra = - 1 ;
for ( i = MAXSPRITES - 1 ; i > = 0 ; i - - ) sprite [ i ] . extra = - 1 ;
2008-05-16 19:51:38 +00:00
ExtPreLoadMap ( ) ;
2009-01-13 12:23:18 +00:00
i = loadboard ( f , ( ! pathsearchmode & & grponlymode ? 2 : 0 ) , & pos . x , & pos . y , & pos . z , & ang , & cursectnum ) ;
2008-05-16 19:51:38 +00:00
loadmhk ( ) ;
2009-01-13 12:23:18 +00:00
if ( i = = - 2 ) i = loadoldboard ( f , ( ! pathsearchmode & & grponlymode ? 2 : 0 ) , & pos . x , & pos . y , & pos . z , & ang , & cursectnum ) ;
2008-05-16 19:51:38 +00:00
if ( i < 0 ) printmessage16 ( " Invalid map format. " ) ;
else
{
ExtLoadMap ( f ) ;
2008-10-20 04:35:57 +00:00
if ( mapversion < 7 ) message ( " Map %s loaded successfully and autoconverted to V7! " , f ) ;
else message ( " Map %s loaded successfully " , f ) ;
2008-05-16 19:51:38 +00:00
}
updatenumsprites ( ) ;
2009-01-13 12:23:18 +00:00
startposx = pos . x ;
startposy = pos . y ;
startposz = pos . z ;
2008-05-16 19:51:38 +00:00
startang = ang ;
startsectnum = cursectnum ;
2009-02-19 16:47:54 +00:00
pos . x = sposx ; pos . y = sposy ; pos . z = sposz ; ang = sang ;
2008-05-16 19:51:38 +00:00
keystatus [ KEYSC_L ] = 0 ;
}
}
}
2006-04-13 20:47:06 +00:00
2008-05-16 00:23:33 +00:00
if ( keystatus [ buildkeys [ BK_MODE2D_3D ] ] ) // Enter
2006-04-13 20:47:06 +00:00
{
getmessageleng = 0 ;
getmessagetimeoff = 0 ;
2007-04-17 05:54:12 +00:00
# if defined(_WIN32) && defined(DUKEOSD)
if ( qsetmode = = 200 )
{
OSD_SetFunctions (
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
2009-01-09 09:29:17 +00:00
( int32_t ( * ) ( void ) ) GetTime ,
2007-04-17 05:54:12 +00:00
NULL
) ;
}
else
{
OSD_SetFunctions (
2008-05-18 21:09:30 +00:00
/* GAME_drawosdchar,
GAME_drawosdstr ,
GAME_drawosdcursor ,
GAME_getcolumnwidth ,
GAME_getrowheight , */
0 , 0 , 0 , 0 , 0 ,
2007-04-17 05:54:12 +00:00
GAME_clearbackground ,
2009-01-09 09:29:17 +00:00
( int32_t ( * ) ( void ) ) GetTime ,
2007-04-17 05:54:12 +00:00
NULL
) ;
}
# endif
2006-04-13 20:47:06 +00:00
}
if ( getmessageleng > 0 )
{
2008-05-31 01:57:14 +00:00
// charsperline = 64;
2006-04-13 20:47:06 +00:00
//if (dimensionmode[snum] == 2) charsperline = 80;
2008-06-01 01:57:01 +00:00
/* if (qsetmode == 200)
2006-04-13 20:47:06 +00:00
{
2008-06-01 01:57:01 +00:00
for ( i = 0 ; i < = getmessageleng ; i + = charsperline )
{
for ( j = 0 ; j < charsperline ; j + + )
tempbuf [ j ] = getmessage [ i + j ] ;
if ( getmessageleng < i + charsperline )
tempbuf [ ( getmessageleng - i ) ] = 0 ;
else
tempbuf [ charsperline ] = 0 ;
begindrawing ( ) ;
if ( tempbuf [ charsperline ] ! = 0 )
{
printext256 ( ( MESSAGEX * ( xdimgame / 320. ) ) + 2 , ( MESSAGEY * ( ydimgame / 200. ) ) + 2 , 0 , - 1 , tempbuf , xdimgame > 640 ? 0 : 1 ) ;
printext256 ( MESSAGEX * ( xdimgame / 320. ) , MESSAGEY * ( ydimgame / 200. ) ,
( totalclock > ( lastmessagetime + 120 * 5 ) ) ? whitecol : 256 - 5 , - 1 , tempbuf , xdimgame > 640 ? 0 : 1 ) ;
}
enddrawing ( ) ;
}
2006-04-13 20:47:06 +00:00
}
2008-06-01 01:57:01 +00:00
else */
if ( qsetmode ! = 200 )
2008-05-31 01:57:14 +00:00
printmessage16 ( getmessage ) ;
2006-04-13 20:47:06 +00:00
if ( totalclock > getmessagetimeoff )
getmessageleng = 0 ;
}
}
2008-10-14 08:40:59 +00:00
# undef EDUKE32_EXEC
# undef EDUKE32_LOCALEXEC
2006-04-13 20:47:06 +00:00
void ExtCheckKeys ( void )
{
2008-06-05 02:29:18 +00:00
if ( qsetmode = = 200 )
{
if ( shadepreview )
{
2009-01-09 09:29:17 +00:00
int32_t i = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = numsprites - 1 ; i > = 0 ; i - - )
2008-06-05 02:29:18 +00:00
if ( sprite [ i ] . picnum = = SECTOREFFECTOR & & ( sprite [ i ] . lotag = = 12 | | sprite [ i ] . lotag = = 3 ) )
{
2009-01-09 09:29:17 +00:00
int32_t w ;
int32_t start_wall = sector [ sprite [ i ] . sectnum ] . wallptr ;
int32_t end_wall = start_wall + sector [ sprite [ i ] . sectnum ] . wallnum ;
2008-06-05 02:29:18 +00:00
for ( w = start_wall ; w < end_wall ; w + + )
{
if ( wallflag [ w ] )
{
wall [ w ] . shade = wallshades [ w ] ;
wall [ w ] . pal = wallpals [ w ] ;
wallflag [ w ] = 0 ;
}
2008-06-09 23:41:54 +00:00
/* if (wall[w].nextwall >= 0)
{
if ( wallflag [ wall [ w ] . nextwall ] )
{
wall [ wall [ w ] . nextwall ] . shade = wallshades [ wall [ w ] . nextwall ] ;
wall [ wall [ w ] . nextwall ] . pal = wallpals [ wall [ w ] . nextwall ] ;
wallflag [ wall [ w ] . nextwall ] = 0 ;
}
} */
2008-06-05 02:29:18 +00:00
}
sector [ sprite [ i ] . sectnum ] . floorshade = sectorshades [ sprite [ i ] . sectnum ] [ 0 ] ;
sector [ sprite [ i ] . sectnum ] . ceilingshade = sectorshades [ sprite [ i ] . sectnum ] [ 1 ] ;
sector [ sprite [ i ] . sectnum ] . floorpal = sectorpals [ sprite [ i ] . sectnum ] [ 0 ] ;
sector [ sprite [ i ] . sectnum ] . ceilingpal = sectorpals [ sprite [ i ] . sectnum ] [ 1 ] ;
w = headspritesect [ sprite [ i ] . sectnum ] ;
while ( w > = 0 )
{
if ( w = = i ) { w = nextspritesect [ w ] ; continue ; }
sprite [ w ] . shade = spriteshades [ w ] ;
sprite [ w ] . pal = spritepals [ w ] ;
w = nextspritesect [ w ] ;
}
}
}
}
2006-04-13 20:47:06 +00:00
readmousebstatus ( & bstatus ) ;
Keys2d3d ( ) ;
if ( qsetmode = = 200 ) //In 3D mode
{
Keys3d ( ) ;
2007-02-26 01:46:38 +00:00
if ( sidemode ! = 1 )
{
editinput ( ) ;
2008-05-17 21:44:49 +00:00
if ( infobox & 2 ) m32_showmouse ( ) ;
2007-02-26 01:46:38 +00:00
}
2006-12-14 08:50:18 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2006-12-14 08:50:18 +00:00
Keys2d ( ) ;
2006-04-13 20:47:06 +00:00
}
void faketimerhandler ( void )
{
2009-01-09 09:29:17 +00:00
int32_t i , dist ;
int32_t hiz , hihit , loz , lohit , oposx , oposy ;
int16_t hitwall , daang ;
2006-04-13 20:47:06 +00:00
2006-11-15 01:16:55 +00:00
counter + + ;
if ( counter > = 5 ) counter = 0 ;
2006-04-13 20:47:06 +00:00
sampletimer ( ) ;
2006-12-14 08:50:18 +00:00
if ( totalclock < ototalclock + TICSPERFRAME | | qsetmode ! = 200 | | sidemode ! = 1 )
2006-04-13 20:47:06 +00:00
return ;
ototalclock = totalclock ;
2009-01-13 12:23:18 +00:00
oposx = pos . x ;
oposy = pos . y ;
hitwall = clipmove ( & pos , & cursectnum , xvel , yvel , 128L , 4L < < 8 , 4L < < 8 , 0 ) ;
xvel = ( ( pos . x - oposx ) < < 14 ) ;
yvel = ( ( pos . y - oposy ) < < 14 ) ;
2006-04-13 20:47:06 +00:00
yvel + = 80000 ;
if ( ( hitwall & 0xc000 ) = = 32768 )
{
hitwall & = ( MAXWALLS - 1 ) ;
i = wall [ hitwall ] . point2 ;
daang = getangle ( wall [ i ] . x - wall [ hitwall ] . x , wall [ i ] . y - wall [ hitwall ] . y ) ;
xvel - = ( xvel > > 4 ) ;
if ( xvel < 0 ) xvel + + ;
if ( xvel > 0 ) xvel - - ;
yvel - = ( yvel > > 4 ) ;
if ( yvel < 0 ) yvel + + ;
if ( yvel > 0 ) yvel - - ;
2008-05-16 00:23:33 +00:00
i = 4 - keystatus [ buildkeys [ BK_RUN ] ] ;
2009-01-09 09:29:17 +00:00
xvel + = mulscale ( vel , ( int32_t ) sintable [ ( ang + 512 ) & 2047 ] , i ) ;
yvel + = mulscale ( vel , ( int32_t ) sintable [ ang & 2047 ] , i ) ;
2006-04-13 20:47:06 +00:00
if ( ( ( daang - ang ) & 2047 ) < 1024 )
ang = ( ( ang + ( ( ( ( daang - ang ) & 2047 ) + 24 ) > > 4 ) ) & 2047 ) ;
else
ang = ( ( ang - ( ( ( ( ang - daang ) & 2047 ) + 24 ) > > 4 ) ) & 2047 ) ;
timoff = ototalclock ;
}
else
{
if ( ototalclock > timoff + 32 )
ang = ( ( ang + ( ( timoff + 32 - ototalclock ) > > 4 ) ) & 2047 ) ;
}
2009-01-13 12:23:18 +00:00
getzrange ( & pos , cursectnum , & hiz , & hihit , & loz , & lohit , 128L , 0 ) ;
2006-04-13 20:47:06 +00:00
2009-01-13 12:23:18 +00:00
oposx - = pos . x ;
oposy - = pos . y ;
2006-04-13 20:47:06 +00:00
dist = ksqrt ( oposx * oposx + oposy * oposy ) ;
if ( ototalclock > timoff + 32 ) dist = 0 ;
daang = mulscale ( dist , angvel , 9 ) ;
2009-01-13 12:23:18 +00:00
pos . z + = ( daang < < 6 ) ;
if ( pos . z > loz - ( 4 < < 8 ) ) pos . z = loz - ( 4 < < 8 ) , hvel = 0 ;
if ( pos . z < hiz + ( 4 < < 8 ) ) pos . z = hiz + ( 4 < < 8 ) , hvel = 0 ;
2006-04-13 20:47:06 +00:00
horiz = ( ( horiz * 7 + ( 100 - ( daang > > 1 ) ) ) > > 3 ) ;
if ( horiz < 100 ) horiz + + ;
if ( horiz > 100 ) horiz - - ;
}
2009-01-09 09:29:17 +00:00
extern int16_t brightness ;
2008-07-25 13:42:37 +00:00
static inline void SetBOSS1Palette ( )
2006-04-22 22:33:52 +00:00
{
2006-11-13 23:12:47 +00:00
if ( acurpalette = = 3 ) return ;
2006-04-13 20:47:06 +00:00
acurpalette = 3 ;
2008-07-25 13:42:37 +00:00
setbrightness ( brightness , BOSS1palette , 0 ) ;
2006-04-13 20:47:06 +00:00
}
2008-07-25 13:42:37 +00:00
static inline void SetSLIMEPalette ( )
2006-04-22 22:33:52 +00:00
{
2006-11-13 23:12:47 +00:00
if ( acurpalette = = 2 ) return ;
2006-04-13 20:47:06 +00:00
acurpalette = 2 ;
2008-07-25 13:42:37 +00:00
setbrightness ( brightness , SLIMEpalette , 0 ) ;
2006-04-13 20:47:06 +00:00
}
2008-07-25 13:42:37 +00:00
static inline void SetWATERPalette ( )
2006-04-22 22:33:52 +00:00
{
2006-11-13 23:12:47 +00:00
if ( acurpalette = = 1 ) return ;
2006-04-13 20:47:06 +00:00
acurpalette = 1 ;
2008-07-25 13:42:37 +00:00
setbrightness ( brightness , WATERpalette , 0 ) ;
2006-04-13 20:47:06 +00:00
}
2008-07-25 13:42:37 +00:00
static inline void SetGAMEPalette ( )
2006-04-22 22:33:52 +00:00
{
2006-11-13 23:12:47 +00:00
if ( acurpalette = = 0 ) return ;
2006-04-13 20:47:06 +00:00
acurpalette = 0 ;
2008-07-25 13:42:37 +00:00
setbrightness ( brightness , GAMEpalette , 0 ) ;
2006-04-13 20:47:06 +00:00
}
2006-12-10 06:49:01 +00:00
static void SearchSectorsForward ( )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t ii = 0 ;
2006-11-13 23:12:47 +00:00
if ( cursector_lotag ! = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( cursectornum < MAXSECTORS ) cursectornum + + ;
2009-02-19 16:47:54 +00:00
for ( ii = cursectornum ; ii < = MAXSECTORS ; ii + + )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sector [ ii ] . lotag = = cursector_lotag )
2006-04-13 20:47:06 +00:00
{
2009-01-13 12:23:18 +00:00
pos . x = wall [ sector [ ii ] . wallptr ] . x ;
pos . y = wall [ sector [ ii ] . wallptr ] . y ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " > Sector search: found " ) ;
// cursectornum++;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_RBRACK ] = 0 ; // ]
2006-04-13 20:47:06 +00:00
return ;
}
cursectornum + + ;
}
}
printmessage16 ( " > Sector search: none found " ) ;
}
2006-12-10 06:49:01 +00:00
static void SearchSectorsBackward ( )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t ii = 0 ;
2006-11-13 23:12:47 +00:00
if ( cursector_lotag ! = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( cursectornum > 0 ) cursectornum - - ;
2009-02-19 16:47:54 +00:00
for ( ii = cursectornum ; ii > = 0 ; ii - - )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sector [ ii ] . lotag = = cursector_lotag )
2006-04-13 20:47:06 +00:00
{
2009-01-13 12:23:18 +00:00
pos . x = wall [ sector [ ii ] . wallptr ] . x ;
pos . y = wall [ sector [ ii ] . wallptr ] . y ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " < Sector search: found " ) ;
// cursectornum--;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_LBRACK ] = 0 ; // [
2006-04-13 20:47:06 +00:00
return ;
}
cursectornum - - ;
}
}
printmessage16 ( " < Sector search: none found " ) ;
}
// Build edit originally by Ed Coolidge <semicharm@earthlink.net>
2009-01-09 09:29:17 +00:00
static void EditSectorData ( int16_t sectnum )
2006-04-13 20:47:06 +00:00
{
char disptext [ 80 ] ;
char edittext [ 80 ] ;
2009-01-09 09:29:17 +00:00
int32_t col = 1 , row = 0 , rowmax = 6 , dispwidth = 24 , editval = 0 , i = - 1 ;
int32_t xpos = 200 , ypos = ydim - STATUS2DSIZ + 48 ;
2006-11-19 08:24:46 +00:00
2006-04-13 20:47:06 +00:00
disptext [ dispwidth ] = 0 ;
clearmidstatbar16 ( ) ;
showsectordata ( sectnum ) ;
begindrawing ( ) ;
2008-05-16 00:23:33 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( handleevents ( ) )
{
2006-04-13 20:47:06 +00:00
if ( quitevent ) quitevent = 0 ;
2007-01-12 05:49:09 +00:00
}
idle ( ) ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " Edit mode, press <Esc> to exit " ) ;
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_DOWN ] )
2006-04-13 20:47:06 +00:00
{
if ( row < rowmax )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
row + + ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_DOWN ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_UP ] )
2006-04-13 20:47:06 +00:00
{
if ( row > 0 )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
row - - ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_UP ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_LEFT ] )
2006-04-13 20:47:06 +00:00
{
if ( col = = 2 )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
col = 1 ;
xpos = 200 ;
rowmax = 6 ;
dispwidth = 24 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_LEFT ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_RIGHT ] )
2006-04-13 20:47:06 +00:00
{
if ( col = = 1 )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
col = 2 ;
xpos = 400 ;
rowmax = 6 ;
dispwidth = 24 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_RIGHT ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_ENTER ] )
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ENTER ] = 0 ;
2006-04-13 20:47:06 +00:00
editval = 1 ;
}
if ( col = = 1 )
{
switch ( row )
{
2006-11-16 03:02:42 +00:00
case 0 :
for ( i = Bsprintf ( disptext , " Flags (hex): %x " , sector [ sectnum ] . ceilingstat ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Ceiling Flags: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . ceilingstat = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . ceilingstat , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 1 :
for ( i = Bsprintf ( disptext , " (X,Y)pan: %d, %d " , sector [ sectnum ] . ceilingxpanning , sector [ sectnum ] . ceilingypanning ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
if ( editval )
{
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Ceiling X Pan: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . ceilingxpanning = ( char ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . ceilingxpanning , 256L , 0 ) ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Ceiling Y Pan: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . ceilingypanning = ( char ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . ceilingypanning , 256L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 2 :
for ( i = Bsprintf ( disptext , " Shade byte: %d " , sector [ sectnum ] . ceilingshade ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Ceiling Shade: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . ceilingshade = ( char ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . ceilingshade , 128L , 1 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 3 :
2007-12-12 17:42:14 +00:00
for ( i = Bsprintf ( disptext , " Z-coordinate: %d " , sector [ sectnum ] . ceilingz ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Ceiling Z-coordinate: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
sector [ sectnum ] . ceilingz = getnumber16 ( edittext , sector [ sectnum ] . ceilingz , 8388608 , 1 ) ; //2147483647L,-2147483648L
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 4 :
for ( i = Bsprintf ( disptext , " Tile number: %d " , sector [ sectnum ] . ceilingpicnum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Ceiling Tile Number: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . ceilingpicnum = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . ceilingpicnum , MAXTILES , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 5 :
for ( i = Bsprintf ( disptext , " Ceiling heinum: %d " , sector [ sectnum ] . ceilingheinum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Ceiling Heinum: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . ceilingheinum = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . ceilingheinum , 65536L , 1 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 6 :
for ( i = Bsprintf ( disptext , " Palookup number: %d " , sector [ sectnum ] . ceilingpal ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Ceiling Palookup Number: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . ceilingpal = ( char ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . ceilingpal , MAXPALOOKUPS , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
}
}
if ( col = = 2 )
{
switch ( row )
{
2006-11-16 03:02:42 +00:00
case 0 :
for ( i = Bsprintf ( disptext , " Flags (hex): %x " , sector [ sectnum ] . floorstat ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Floor Flags: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . floorstat = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . floorstat , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 1 :
for ( i = Bsprintf ( disptext , " (X,Y)pan: %d, %d " , sector [ sectnum ] . floorxpanning , sector [ sectnum ] . floorypanning ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
if ( editval )
{
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Floor X Pan: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . floorxpanning = ( char ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . floorxpanning , 256L , 0 ) ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Floor Y Pan: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . floorypanning = ( char ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . floorypanning , 256L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 2 :
for ( i = Bsprintf ( disptext , " Shade byte: %d " , sector [ sectnum ] . floorshade ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Floor Shade: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . floorshade = ( char ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . floorshade , 128L , 1L ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 3 :
2007-12-12 17:42:14 +00:00
for ( i = Bsprintf ( disptext , " Z-coordinate: %d " , sector [ sectnum ] . floorz ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Floor Z-coordinate: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
sector [ sectnum ] . floorz = getnumber16 ( edittext , sector [ sectnum ] . floorz , 8388608L , 1 ) ; //2147483647L,-2147483648L
}
break ;
case 4 :
for ( i = Bsprintf ( disptext , " Tile number: %d " , sector [ sectnum ] . floorpicnum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Floor Tile Number: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . floorpicnum = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . floorpicnum , MAXTILES , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 5 :
for ( i = Bsprintf ( disptext , " Floor heinum: %d " , sector [ sectnum ] . floorheinum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Flooring Heinum: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . floorheinum = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . floorheinum , 65536L , 1 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 6 :
for ( i = Bsprintf ( disptext , " Palookup number: %d " , sector [ sectnum ] . floorpal ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sector %d Floor Palookup Number: " , sectnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sector [ sectnum ] . floorpal = ( char ) getnumber16 ( edittext , ( int32_t ) sector [ sectnum ] . floorpal , MAXPALOOKUPS , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
}
}
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 1 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
if ( editval )
{
editval = 0 ;
}
showframe ( 1 ) ;
}
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " " ) ;
enddrawing ( ) ;
showframe ( 1 ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ESC ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
static void EditWallData ( int16_t wallnum )
2006-04-13 20:47:06 +00:00
{
char disptext [ 80 ] ;
char edittext [ 80 ] ;
2009-01-09 09:29:17 +00:00
int32_t row = 0 , dispwidth = 24 , editval = 0 , i = - 1 ;
int32_t xpos = 200 , ypos = ydim - STATUS2DSIZ + 48 ;
2006-11-19 08:24:46 +00:00
2006-04-13 20:47:06 +00:00
disptext [ dispwidth ] = 0 ;
clearmidstatbar16 ( ) ;
showwalldata ( wallnum ) ;
begindrawing ( ) ;
2008-05-16 00:23:33 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( handleevents ( ) )
{
2006-04-13 20:47:06 +00:00
if ( quitevent ) quitevent = 0 ;
2007-01-12 05:49:09 +00:00
}
idle ( ) ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " Edit mode, press <Esc> to exit " ) ;
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_DOWN ] )
2006-04-13 20:47:06 +00:00
{
if ( row < 6 )
{
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
row + + ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_DOWN ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_UP ] )
2006-04-13 20:47:06 +00:00
{
if ( row > 0 )
{
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
row - - ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_UP ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_ENTER ] )
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ENTER ] = 0 ;
2006-04-13 20:47:06 +00:00
editval = 1 ;
}
switch ( row )
{
2006-11-16 03:02:42 +00:00
case 0 :
for ( i = Bsprintf ( disptext , " Flags (hex): %x " , wall [ wallnum ] . cstat ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d Flags: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . cstat = ( int16_t ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . cstat , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 1 :
for ( i = Bsprintf ( disptext , " Shade: %d " , wall [ wallnum ] . shade ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d Shade: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . shade = ( char ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . shade , 128 , 1 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 2 :
for ( i = Bsprintf ( disptext , " Pal: %d " , wall [ wallnum ] . pal ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d Pal: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . pal = ( char ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . pal , MAXPALOOKUPS , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 3 :
for ( i = Bsprintf ( disptext , " (X,Y)repeat: %d, %d " , wall [ wallnum ] . xrepeat , wall [ wallnum ] . yrepeat ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
if ( editval )
{
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d X Repeat: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . xrepeat = ( char ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . xrepeat , 256L , 0 ) ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d Y Repeat: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . yrepeat = ( char ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . yrepeat , 256L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 4 :
for ( i = Bsprintf ( disptext , " (X,Y)pan: %d, %d " , wall [ wallnum ] . xpanning , wall [ wallnum ] . ypanning ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
if ( editval )
{
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d X Pan: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . xpanning = ( char ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . xpanning , 256L , 0 ) ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d Y Pan: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . ypanning = ( char ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . ypanning , 256L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case 5 :
for ( i = Bsprintf ( disptext , " Tile number: %d " , wall [ wallnum ] . picnum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d Tile number: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . picnum = ( int16_t ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . picnum , MAXTILES , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 6 :
for ( i = Bsprintf ( disptext , " OverTile number: %d " , wall [ wallnum ] . overpicnum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Wall %d OverTile number: " , wallnum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
wall [ wallnum ] . overpicnum = ( int16_t ) getnumber16 ( edittext , ( int32_t ) wall [ wallnum ] . overpicnum , MAXTILES , 0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
}
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 1 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
if ( editval )
{
editval = 0 ;
//showwalldata(wallnum);
//printmessage16("");
}
//enddrawing();
showframe ( 1 ) ;
}
//begindrawing();
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " " ) ;
enddrawing ( ) ;
showframe ( 1 ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ESC ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
static void EditSpriteData ( int16_t spritenum )
2006-04-13 20:47:06 +00:00
{
char disptext [ 80 ] ;
char edittext [ 80 ] ;
2009-01-09 09:29:17 +00:00
int32_t col = 0 , row = 0 , rowmax = 4 , dispwidth = 24 , editval = 0 , i = - 1 ;
int32_t xpos = 8 , ypos = ydim - STATUS2DSIZ + 48 ;
2006-11-19 08:24:46 +00:00
2006-04-13 20:47:06 +00:00
disptext [ dispwidth ] = 0 ;
clearmidstatbar16 ( ) ;
showspritedata ( spritenum ) ;
2008-05-16 00:23:33 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 )
2006-04-13 20:47:06 +00:00
{
begindrawing ( ) ;
2006-11-15 01:16:55 +00:00
if ( handleevents ( ) )
{
2006-04-13 20:47:06 +00:00
if ( quitevent ) quitevent = 0 ;
2007-01-12 05:49:09 +00:00
}
idle ( ) ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " Edit mode, press <Esc> to exit " ) ;
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_DOWN ] )
2006-04-13 20:47:06 +00:00
{
if ( row < rowmax )
{
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
row + + ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_DOWN ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_UP ] )
2006-04-13 20:47:06 +00:00
{
if ( row > 0 )
{
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
row - - ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_UP ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_LEFT ] )
2006-04-13 20:47:06 +00:00
{
2006-07-21 22:25:05 +00:00
switch ( col )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 1 :
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-11-16 03:02:42 +00:00
col = 0 ;
xpos = 8 ;
rowmax = 4 ;
dispwidth = 23 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
break ;
case 2 :
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-11-16 03:02:42 +00:00
col = 1 ;
xpos = 200 ;
rowmax = 5 ;
dispwidth = 24 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
break ;
2006-11-13 23:12:47 +00:00
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_LEFT ] = 0 ;
2006-11-15 01:16:55 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_RIGHT ] )
2006-11-15 01:16:55 +00:00
{
switch ( col )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-11-16 03:02:42 +00:00
col = 1 ;
xpos = 200 ;
rowmax = 5 ;
dispwidth = 24 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
break ;
case 1 :
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-11-16 03:02:42 +00:00
col = 2 ;
xpos = 400 ;
rowmax = 6 ;
dispwidth = 26 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
break ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_RIGHT ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_ENTER ] )
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ENTER ] = 0 ;
2006-04-13 20:47:06 +00:00
editval = 1 ;
}
2006-07-21 22:25:05 +00:00
switch ( col )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
{
switch ( row )
{
2006-11-13 23:12:47 +00:00
case 0 :
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
for ( i = Bsprintf ( disptext , " X-coordinate: %d " , sprite [ spritenum ] . x ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d X-coordinate: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
sprite [ spritenum ] . x = getnumber16 ( edittext , sprite [ spritenum ] . x , 131072 , 1 ) ;
}
}
break ;
case 1 :
{
2007-12-12 17:42:14 +00:00
for ( i = Bsprintf ( disptext , " Y-coordinate: %d " , sprite [ spritenum ] . y ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Y-coordinate: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
sprite [ spritenum ] . y = getnumber16 ( edittext , sprite [ spritenum ] . y , 131072 , 1 ) ;
}
}
break ;
case 2 :
{
2007-12-12 17:42:14 +00:00
for ( i = Bsprintf ( disptext , " Z-coordinate: %d " , sprite [ spritenum ] . z ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Z-coordinate: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
sprite [ spritenum ] . z = getnumber16 ( edittext , sprite [ spritenum ] . z , 8388608 , 1 ) ; //2147483647L,-2147483648L
}
}
break ;
case 3 :
{
for ( i = Bsprintf ( disptext , " Sectnum: %d " , sprite [ spritenum ] . sectnum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Sectnum: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
i = getnumber16 ( edittext , sprite [ spritenum ] . sectnum , MAXSECTORS - 1 , 0 ) ;
if ( i ! = sprite [ spritenum ] . sectnum )
changespritesect ( spritenum , i ) ;
}
}
break ;
case 4 :
{
for ( i = Bsprintf ( disptext , " Statnum: %d " , sprite [ spritenum ] . statnum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Statnum: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
i = getnumber16 ( edittext , sprite [ spritenum ] . statnum , MAXSTATUS - 1 , 0 ) ;
if ( i ! = sprite [ spritenum ] . statnum )
changespritestat ( spritenum , i ) ;
}
}
break ;
}
}
break ;
case 1 :
{
switch ( row )
{
case 0 :
{
for ( i = Bsprintf ( disptext , " Flags (hex): %x " , sprite [ spritenum ] . cstat ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Flags: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . cstat = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . cstat , 65536L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 1 :
{
for ( i = Bsprintf ( disptext , " Shade: %d " , sprite [ spritenum ] . shade ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Shade: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . shade = ( char ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . shade , 128 , 1 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 2 :
{
for ( i = Bsprintf ( disptext , " Pal: %d " , sprite [ spritenum ] . pal ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Pal: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . pal = ( char ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . pal , MAXPALOOKUPS , 0 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 3 :
{
for ( i = Bsprintf ( disptext , " (X,Y)repeat: %d, %d " , sprite [ spritenum ] . xrepeat , sprite [ spritenum ] . yrepeat ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
if ( editval )
{
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d X Repeat: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . xrepeat = ( char ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . xrepeat , 256L , 0 ) ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Y Repeat: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . yrepeat = ( char ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . yrepeat , 256L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 4 :
{
for ( i = Bsprintf ( disptext , " (X,Y)offset: %d, %d " , sprite [ spritenum ] . xoffset , sprite [ spritenum ] . yoffset ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
if ( editval )
{
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d X Offset: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . xoffset = ( char ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . xoffset , 128L , 1 ) ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Y Offset: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . yoffset = ( char ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . yoffset , 128L , 1 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 5 :
{
for ( i = Bsprintf ( disptext , " Tile number: %d " , sprite [ spritenum ] . picnum ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Tile number: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . picnum = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . picnum , MAXTILES , 0 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
}
}
break ;
case 2 :
{
switch ( row )
{
case 0 :
{
for ( i = Bsprintf ( disptext , " Angle (2048 degrees): %d " , sprite [ spritenum ] . ang ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Angle: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . ang = ( int16_t ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . ang , 2048L , 0 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 1 :
{
for ( i = Bsprintf ( disptext , " X-Velocity: %d " , sprite [ spritenum ] . xvel ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d X-Velocity: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . xvel = getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . xvel , 65536 , 1 ) ;
2006-11-13 23:12:47 +00:00
}
}
break ;
2006-11-16 03:02:42 +00:00
case 2 :
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
for ( i = Bsprintf ( disptext , " Y-Velocity: %d " , sprite [ spritenum ] . yvel ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Y-Velocity: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . yvel = getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . yvel , 65536 , 1 ) ;
2006-11-13 23:12:47 +00:00
}
}
break ;
2006-11-16 03:02:42 +00:00
case 3 :
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
for ( i = Bsprintf ( disptext , " Z-Velocity: %d " , sprite [ spritenum ] . zvel ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Z-Velocity: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . zvel = getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . zvel , 65536 , 1 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 4 :
{
for ( i = Bsprintf ( disptext , " Owner: %d " , sprite [ spritenum ] . owner ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Owner: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . owner = getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . owner , MAXSPRITES , 0 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 5 :
{
for ( i = Bsprintf ( disptext , " Clipdist: %d " , sprite [ spritenum ] . clipdist ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Clipdist: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . clipdist = ( char ) getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . clipdist , 256 , 0 ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 6 :
{
for ( i = Bsprintf ( disptext , " Extra: %d " , sprite [ spritenum ] . extra ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2007-04-21 23:59:56 +00:00
Bsprintf ( edittext , " Sprite %d Extra: " , spritenum ) ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
printmessage16 ( edittext ) ;
2009-01-09 09:29:17 +00:00
sprite [ spritenum ] . extra = getnumber16 ( edittext , ( int32_t ) sprite [ spritenum ] . extra , 65536 , 1 ) ;
2006-11-13 23:12:47 +00:00
}
}
break ;
2006-11-16 03:02:42 +00:00
}
}
break ;
2006-04-13 20:47:06 +00:00
}
2006-07-21 22:25:05 +00:00
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 1 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
if ( editval )
{
editval = 0 ;
}
enddrawing ( ) ;
showframe ( 1 ) ;
}
begindrawing ( ) ;
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-04-13 20:47:06 +00:00
printmessage16 ( " " ) ;
enddrawing ( ) ;
showframe ( 1 ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ESC ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-09-19 20:09:43 +00:00
static void GenSearchSprite ( )
{
char disptext [ 80 ] ;
char edittext [ 80 ] ;
2009-01-09 09:29:17 +00:00
static int32_t col = 0 , row = 0 ;
int32_t i , j , k ;
int32_t rowmax [ 3 ] = { 6 , 5 , 6 } , dispwidth [ 3 ] = { 24 , 24 , 28 } ;
int32_t xpos [ 3 ] = { 8 , 200 , 400 } , ypos = ydim - STATUS2DSIZ + 48 ;
2008-09-19 20:09:43 +00:00
2008-09-26 04:20:08 +00:00
static char * labels [ 7 ] [ 3 ] =
{
2008-09-19 20:09:43 +00:00
{ " X-coordinate " , " Flags (hex) " , " Angle (2048 degrees) " } ,
{ " Y-coordinate " , " Shade " , " X-Velocity " } ,
{ " Z-coordinate " , " Pal " , " Y-Velocity " } ,
{ " Sectnum " , " (X/Y)repeat " , " Z-Velocity " } ,
{ " Statnum " , " (X/Y)offset " , " Owner " } ,
{ " Hitag " , " Tile number " , " Clipdist " } ,
{ " Lotag " , " " , " Extra " }
} ;
2009-01-09 09:29:17 +00:00
static int32_t maxval [ 7 ] [ 3 ] =
2008-09-26 04:20:08 +00:00
{
2008-09-19 20:09:43 +00:00
{ 524288 , 65536 , 2048 } ,
{ 524288 , 128 , 65536 } ,
{ 8388608 , MAXPALOOKUPS , 65536 } ,
{ MAXSECTORS - 1 , 128 , 65536 } ,
{ MAXSTATUS - 1 , 128 , MAXSPRITES - 1 } ,
{ 65536 , MAXTILES , 256 } ,
{ 65536 , 0 , 65536 }
} ;
2008-09-26 04:20:08 +00:00
static char sign [ 7 ] [ 3 ] =
{
2008-09-19 20:09:43 +00:00
{ 1 , 0 , 1 } , { 1 , 1 , 1 } , { 1 , 0 , 1 } , { 0 , 0 , 1 } , { 0 , 1 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 1 }
} ;
static char firstrun = 1 ;
if ( firstrun )
{
firstrun = 0 ;
Bmemset ( & gs_spritewhat , 0 , sizeof ( gs_spritewhat ) ) ;
}
clearmidstatbar16 ( ) ;
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ 0 ] , ypos - 2 * 8 , editorcolors [ 10 ] , editorcolors [ 0 ] , " Sprite search " , 0 ) ;
2008-09-19 20:09:43 +00:00
for ( i = 0 ; i < 3 ; i + + )
for ( j = 0 ; j < = rowmax [ i ] ; j + + )
{
if ( gs_spritewhat [ i ] [ j ] )
k = Bsprintf ( disptext , " %s: ^O%d " , labels [ j ] [ i ] , gs_sprite [ i ] [ j ] ) ;
else
k = Bsprintf ( disptext , " %s: ^7any " , labels [ j ] [ i ] ) ;
2009-02-19 16:47:54 +00:00
for ( ; k < dispwidth [ i ] ; k + + ) disptext [ k ] = 0 ;
2008-09-19 20:09:43 +00:00
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ i ] , ypos + j * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2008-09-19 20:09:43 +00:00
}
for ( k = 0 ; k < 80 ; k + + ) disptext [ k ] = 0 ;
// disptext[dispwidth[col]] = 0;
// showspritedata(spritenum);
wallsprite = 2 ;
while ( keystatus [ KEYSC_ESC ] = = 0 )
{
begindrawing ( ) ;
if ( handleevents ( ) )
{
if ( quitevent ) quitevent = 0 ;
}
idle ( ) ;
printmessage16 ( " Sprite search, press <Esc> to exit " ) ;
if ( keystatus [ KEYSC_DOWN ] )
{
keystatus [ KEYSC_DOWN ] = 0 ;
if ( row < rowmax [ col ] )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2008-09-19 20:09:43 +00:00
row + + ;
}
}
if ( keystatus [ KEYSC_UP ] )
{
keystatus [ KEYSC_UP ] = 0 ;
if ( row > 0 )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2008-09-19 20:09:43 +00:00
row - - ;
}
}
if ( keystatus [ KEYSC_LEFT ] )
{
keystatus [ KEYSC_LEFT ] = 0 ;
2008-09-26 04:20:08 +00:00
if ( col > 0 )
2008-09-19 20:09:43 +00:00
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2008-09-19 20:09:43 +00:00
col - - ;
disptext [ dispwidth [ col ] ] = 0 ;
if ( row > rowmax [ col ] ) row = rowmax [ col ] ;
}
}
if ( keystatus [ KEYSC_RIGHT ] )
{
keystatus [ KEYSC_RIGHT ] = 0 ;
if ( col < 2 )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2008-09-19 20:09:43 +00:00
col + + ;
disptext [ dispwidth [ col ] ] = 0 ;
if ( row > rowmax [ col ] ) row = rowmax [ col ] ;
}
}
if ( keystatus [ KEYSC_ENTER ] )
{
keystatus [ KEYSC_ENTER ] = 0 ;
Bsprintf ( edittext , " %s: " , labels [ row ] [ col ] ) ;
enddrawing ( ) ;
printmessage16 ( edittext ) ;
i = getnumber16 ( edittext , gs_spritewhat [ col ] [ row ] ? gs_sprite [ col ] [ row ] : 0 ,
maxval [ row ] [ col ] , sign [ row ] [ col ] ) ;
if ( col = = 2 & & row = = 0 ) i = ( i + 2048 ) & 2047 ; // angle
gs_sprite [ col ] [ row ] = i ;
begindrawing ( ) ;
gs_spritewhat [ col ] [ row ] = 1 ;
if ( col = = 1 & & row = = 5 ) // picnum
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ 1 ] , ypos - 2 * 8 , editorcolors [ 14 ] , editorcolors [ 0 ] , names [ i ] , 0 ) ;
2008-09-19 20:09:43 +00:00
}
if ( keystatus [ KEYSC_BS ] | | keystatus [ KEYSC_DELETE ] )
{
keystatus [ KEYSC_BS ] = keystatus [ KEYSC_DELETE ] = 0 ;
gs_spritewhat [ col ] [ row ] = 0 ;
2008-09-26 04:20:08 +00:00
if ( col = = 1 & & row = = 5 ) // picnum
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ 1 ] , ypos - 2 * 8 , editorcolors [ 14 ] , editorcolors [ 0 ] , " " , 0 ) ;
2008-09-19 20:09:43 +00:00
}
if ( gs_spritewhat [ col ] [ row ] )
{
if ( col = = 1 & & row = = 0 ) // flags
k = Bsprintf ( disptext , " %s: ^O%x " , labels [ row ] [ col ] , gs_sprite [ col ] [ row ] ) ;
else
k = Bsprintf ( disptext , " %s: ^O%d " , labels [ row ] [ col ] , gs_sprite [ col ] [ row ] ) ;
}
else
k = Bsprintf ( disptext , " %s: ^7any " , labels [ row ] [ col ] ) ;
2009-02-19 16:47:54 +00:00
for ( ; k < dispwidth [ col ] ; k + + ) disptext [ k ] = ' ' ;
2008-09-19 20:09:43 +00:00
disptext [ k ] = 0 ;
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 1 ] , disptext , 0 ) ;
2008-09-19 20:09:43 +00:00
enddrawing ( ) ;
showframe ( 1 ) ;
}
// begindrawing();
2008-12-25 12:56:25 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2008-09-19 20:09:43 +00:00
printmessage16 ( " Search sprite " ) ;
// enddrawing();
showframe ( 1 ) ;
keystatus [ KEYSC_ESC ] = 0 ;
}
2006-04-13 20:47:06 +00:00
// Build edit
2008-09-15 02:47:02 +00:00
static char * FuncMenuStrings [ ] =
{
2008-09-17 22:58:25 +00:00
" Replace invalid tiles " ,
" Delete all spr of tile # " ,
" Set map sky shade " ,
" Set map sky height " ,
" Global Z coord shift " ,
" Resize selection " ,
" Global shade divide " ,
" Global visibility divide "
2008-09-15 02:47:02 +00:00
} ;
# define MENU_Y_SPACING 8
2008-09-17 22:58:25 +00:00
# define MENU_BASE_Y ydim-STATUS2DSIZ+32
2008-09-15 02:47:02 +00:00
2006-12-10 06:49:01 +00:00
static void FuncMenuOpts ( void )
2006-07-20 05:02:55 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t x = 8 ;
int32_t y = MENU_BASE_Y + 16 ;
int32_t i = 0 ;
// int32_t x2 = 0;
// static int32_t x2_max = 0;
2008-09-15 02:47:02 +00:00
2009-01-09 09:29:17 +00:00
int32_t numopts = ( sizeof ( FuncMenuStrings ) / sizeof ( FuncMenuStrings [ 0 ] ) ) ;
2008-09-15 02:47:02 +00:00
do
{
// x2 =
2008-12-25 12:56:25 +00:00
printext16 ( x , y , editorcolors [ 11 ] , editorcolors [ 0 ] , FuncMenuStrings [ i ] , 0 ) ;
2008-09-15 02:47:02 +00:00
// if (x2 > x2_max) x2_max = x2;
y + = MENU_Y_SPACING ;
}
while ( + + i < numopts ) ;
// drawline16(x-1,y,x2_max+1,y,1);
// drawline16(x-1,MENU_BASE_Y-4,x-1,y,1);
// x2 =
2008-12-25 12:56:25 +00:00
printext16 ( x , MENU_BASE_Y , editorcolors [ 11 ] , editorcolors [ 0 ] , " Special functions " , 0 ) ;
2008-09-15 02:47:02 +00:00
// drawline16(x-1,MENU_BASE_Y-4,x2+1,MENU_BASE_Y-4,1);
// drawline16(x2_max+1,MENU_BASE_Y+16-4,x2_max+1,y-1,1);
//drawline16(x2+1,MENU_BASE_Y+16-1,x2_max+1,MENU_BASE_Y+16-1,1);
2006-07-20 05:02:55 +00:00
}
2006-12-10 06:49:01 +00:00
static void FuncMenu ( void )
2006-07-20 05:02:55 +00:00
{
char disptext [ 80 ] ;
2009-01-09 09:29:17 +00:00
int32_t col = 0 , row = 0 , rowmax = 7 , dispwidth = 24 , editval = 0 , i = - 1 , j ;
int32_t xpos = 8 , ypos = MENU_BASE_Y + 16 ;
2006-11-19 08:24:46 +00:00
2006-07-20 05:02:55 +00:00
disptext [ dispwidth ] = 0 ;
clearmidstatbar16 ( ) ;
FuncMenuOpts ( ) ;
2008-05-16 00:23:33 +00:00
while ( ! editval & & keystatus [ KEYSC_ESC ] = = 0 )
2006-07-20 05:02:55 +00:00
{
begindrawing ( ) ;
2006-11-15 01:16:55 +00:00
if ( handleevents ( ) )
{
2006-07-20 05:02:55 +00:00
if ( quitevent ) quitevent = 0 ;
2007-01-12 05:49:09 +00:00
}
idle ( ) ;
2006-07-20 05:02:55 +00:00
printmessage16 ( " Select an option, press <Esc> to exit " ) ;
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_DOWN ] )
2006-07-20 05:02:55 +00:00
{
if ( row < rowmax )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * MENU_Y_SPACING , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-07-20 05:02:55 +00:00
row + + ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_DOWN ] = 0 ;
2006-07-20 05:02:55 +00:00
}
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_UP ] )
2006-07-20 05:02:55 +00:00
{
if ( row > 0 )
{
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * MENU_Y_SPACING , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-07-20 05:02:55 +00:00
row - - ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_UP ] = 0 ;
2006-07-20 05:02:55 +00:00
}
2008-09-11 09:24:45 +00:00
#if 0
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_LEFT ] )
2006-07-20 17:33:56 +00:00
{
2006-07-21 22:25:05 +00:00
/* if (col == 2)
{
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , 0 , disptext , 0 ) ;
2006-07-21 22:25:05 +00:00
col = 1 ;
xpos = 200 ;
rowmax = 6 ;
dispwidth = 24 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
2007-08-25 01:05:00 +00:00
else */
if ( col = = 1 )
2006-07-20 17:33:56 +00:00
{
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , 0 , disptext , 0 ) ;
2006-07-20 17:33:56 +00:00
col = 0 ;
xpos = 8 ;
rowmax = 7 ;
2008-09-11 09:24:45 +00:00
dispwidth = 24 ;
2006-07-20 17:33:56 +00:00
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_LEFT ] = 0 ;
2006-07-20 17:33:56 +00:00
}
2008-09-11 09:24:45 +00:00
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_RIGHT ] )
2006-07-20 17:33:56 +00:00
{
if ( col = = 0 )
{
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , 0 , disptext , 0 ) ;
2006-07-20 17:33:56 +00:00
col = 1 ;
xpos = 200 ;
rowmax = 0 ;
dispwidth = 24 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
2006-07-21 22:25:05 +00:00
/* else if (col == 1)
{
2008-12-23 23:27:53 +00:00
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , 0 , disptext , 0 ) ;
2006-07-21 22:25:05 +00:00
col = 2 ;
xpos = 400 ;
rowmax = 6 ;
dispwidth = 26 ;
disptext [ dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
} */
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_RIGHT ] = 0 ;
2006-07-20 17:33:56 +00:00
}
2008-09-11 09:24:45 +00:00
# endif
2008-05-16 00:23:33 +00:00
if ( keystatus [ KEYSC_ENTER ] )
2006-07-20 05:02:55 +00:00
{
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ENTER ] = 0 ;
2006-07-20 05:02:55 +00:00
editval = 1 ;
}
switch ( col )
{
2006-11-16 03:02:42 +00:00
case 0 :
switch ( row )
{
2006-07-21 22:25:05 +00:00
case 0 :
2006-11-16 03:02:42 +00:00
{
2008-10-18 12:37:26 +00:00
for ( i = Bsprintf ( disptext , " %s " , FuncMenuStrings [ row ] ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2006-11-16 03:02:42 +00:00
if ( editval )
2006-07-20 05:02:55 +00:00
{
2006-11-16 03:02:42 +00:00
j = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSECTORS ; i + + )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
if ( tilesizx [ sector [ i ] . ceilingpicnum ] < = 0 )
sector [ i ] . ceilingpicnum = 0 , j + + ;
if ( tilesizx [ sector [ i ] . floorpicnum ] < = 0 )
sector [ i ] . floorpicnum = 0 , j + + ;
2006-11-13 23:12:47 +00:00
}
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXWALLS ; i + + )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
if ( tilesizx [ wall [ i ] . picnum ] < = 0 )
wall [ i ] . picnum = 0 , j + + ;
if ( tilesizx [ wall [ i ] . overpicnum ] < = 0 )
wall [ i ] . overpicnum = 0 , j + + ;
2006-07-20 05:02:55 +00:00
}
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-07-20 05:02:55 +00:00
{
2006-11-16 03:02:42 +00:00
if ( tilesizx [ sprite [ i ] . picnum ] < = 0 )
sprite [ i ] . picnum = 0 , j + + ;
}
Bsprintf ( tempbuf , " Replaced %d invalid tiles " , j ) ;
printmessage16 ( tempbuf ) ;
}
}
break ;
case 1 :
{
2008-10-18 12:37:26 +00:00
for ( i = Bsprintf ( disptext , " %s " , FuncMenuStrings [ row ] ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
2007-01-22 03:10:09 +00:00
Bsprintf ( tempbuf , " Delete all sprites of tile #: " ) ;
2006-11-16 03:02:42 +00:00
i = getnumber16 ( tempbuf , - 1 , MAXSPRITES - 1 , 1 ) ;
if ( i > = 0 )
{
2009-01-09 09:29:17 +00:00
int32_t k = 0 ;
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < MAXSPRITES - 1 ; j + + )
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . picnum = = i )
2007-01-22 03:10:09 +00:00
deletesprite ( j ) , k + + ;
2007-01-22 05:00:57 +00:00
Bsprintf ( tempbuf , " %d sprite(s) deleted " , k ) ;
2007-01-22 03:10:09 +00:00
printmessage16 ( tempbuf ) ;
2006-11-16 03:02:42 +00:00
}
else printmessage16 ( " Aborted " ) ;
}
}
break ;
case 2 :
{
2008-10-18 12:37:26 +00:00
for ( i = Bsprintf ( disptext , " %s " , FuncMenuStrings [ row ] ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
2008-09-15 02:47:02 +00:00
j = getnumber16 ( " Set map sky shade: " , 0 , 128 , 1 ) ;
2006-07-21 22:25:05 +00:00
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-11-16 03:02:42 +00:00
{
if ( sector [ i ] . ceilingstat & 1 )
sector [ i ] . ceilingshade = j ;
2006-07-21 22:25:05 +00:00
}
2008-09-15 02:47:02 +00:00
printmessage16 ( " All parallax skies adjusted " ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
case 3 :
{
2008-10-18 12:37:26 +00:00
for ( i = Bsprintf ( disptext , " %s " , FuncMenuStrings [ row ] ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
2008-09-15 02:47:02 +00:00
j = getnumber16 ( " Set map sky height: " , 0 , 16777216 , 1 ) ;
2006-11-16 03:02:42 +00:00
if ( j ! = 0 )
2006-07-20 05:02:55 +00:00
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-07-20 20:52:18 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sector [ i ] . ceilingstat & 1 )
sector [ i ] . ceilingz = j ;
2006-11-13 23:12:47 +00:00
}
2008-09-15 02:47:02 +00:00
printmessage16 ( " All parallax skies adjusted " ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else printmessage16 ( " Aborted " ) ;
}
}
break ;
case 4 :
{
2008-10-18 12:37:26 +00:00
for ( i = Bsprintf ( disptext , " %s " , FuncMenuStrings [ row ] ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
j = getnumber16 ( " Z offset: " , 0 , 16777216 , 1 ) ;
if ( j ! = 0 )
2006-07-20 05:02:55 +00:00
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-07-20 20:52:18 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ i ] . ceilingz + = j ;
sector [ i ] . floorz + = j ;
2006-11-13 23:12:47 +00:00
}
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-11-16 03:02:42 +00:00
sprite [ i ] . z + = j ;
printmessage16 ( " Map adjusted " ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else printmessage16 ( " Aborted " ) ;
}
}
break ;
case 5 :
{
2008-10-18 12:37:26 +00:00
for ( i = Bsprintf ( disptext , " %s " , FuncMenuStrings [ row ] ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
2008-09-11 09:24:45 +00:00
j = getnumber16 ( " Percentage of original: " , 100 , 1000 , 0 ) ;
if ( j ! = 100 )
2006-07-20 05:02:55 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t w , currsector , start_wall , end_wall ;
2008-09-11 09:24:45 +00:00
double size = ( j / 100.f ) ;
2007-01-15 00:59:49 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-11-16 03:02:42 +00:00
{
2007-01-15 00:59:49 +00:00
currsector = highlightsector [ i ] ;
2009-01-09 09:29:17 +00:00
sector [ currsector ] . ceilingz = ( int32_t ) ( sector [ currsector ] . ceilingz * size ) ;
sector [ currsector ] . floorz = ( int32_t ) ( sector [ currsector ] . floorz * size ) ;
2007-01-15 00:59:49 +00:00
// Do all the walls in the sector
start_wall = sector [ currsector ] . wallptr ;
end_wall = start_wall + sector [ currsector ] . wallnum ;
for ( w = start_wall ; w < end_wall ; w + + )
{
2009-01-09 09:29:17 +00:00
wall [ w ] . x = ( int32_t ) ( wall [ w ] . x * size ) ;
wall [ w ] . y = ( int32_t ) ( wall [ w ] . y * size ) ;
wall [ w ] . yrepeat = min ( ( int32_t ) ( wall [ w ] . yrepeat / size ) , 255 ) ;
2007-01-15 00:59:49 +00:00
}
2007-02-05 01:33:08 +00:00
w = headspritesect [ highlightsector [ i ] ] ;
while ( w > = 0 )
2007-01-15 00:59:49 +00:00
{
2009-01-09 09:29:17 +00:00
sprite [ w ] . x = ( int32_t ) ( sprite [ w ] . x * size ) ;
sprite [ w ] . y = ( int32_t ) ( sprite [ w ] . y * size ) ;
sprite [ w ] . z = ( int32_t ) ( sprite [ w ] . z * size ) ;
sprite [ w ] . xrepeat = min ( max ( ( int32_t ) ( sprite [ w ] . xrepeat * size ) , 1 ) , 255 ) ;
sprite [ w ] . yrepeat = min ( max ( ( int32_t ) ( sprite [ w ] . yrepeat * size ) , 1 ) , 255 ) ;
2007-02-05 01:33:08 +00:00
w = nextspritesect [ w ] ;
2007-01-15 00:59:49 +00:00
}
2006-11-13 23:12:47 +00:00
}
2006-11-16 03:02:42 +00:00
printmessage16 ( " Map scaled " ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else printmessage16 ( " Aborted " ) ;
}
}
break ;
case 6 :
{
2008-10-18 12:37:26 +00:00
for ( i = Bsprintf ( disptext , " %s " , FuncMenuStrings [ row ] ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2006-11-16 03:02:42 +00:00
if ( editval )
{
2006-11-19 08:43:27 +00:00
j = getnumber16 ( " Shade divisor: " , 1 , 128 , 1 ) ;
2006-11-16 03:02:42 +00:00
if ( j ! = 1 )
2006-07-20 17:33:56 +00:00
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-07-20 20:52:18 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ i ] . ceilingshade / = j ;
sector [ i ] . floorshade / = j ;
2006-11-13 23:12:47 +00:00
}
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numwalls ; i + + )
2006-11-16 03:02:42 +00:00
wall [ i ] . shade / = j ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-11-16 03:02:42 +00:00
sprite [ i ] . shade / = j ;
printmessage16 ( " Shades adjusted " ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else printmessage16 ( " Aborted " ) ;
2006-07-20 17:33:56 +00:00
}
2006-11-16 03:02:42 +00:00
}
break ;
2008-09-11 09:24:45 +00:00
case 7 :
2006-11-16 03:02:42 +00:00
{
2008-10-18 12:37:26 +00:00
for ( i = Bsprintf ( disptext , " %s " , FuncMenuStrings [ row ] ) ; i < dispwidth ; i + + ) disptext [ i ] = ' ' ;
2006-11-16 03:02:42 +00:00
if ( editval )
2006-07-20 17:33:56 +00:00
{
2006-11-19 08:43:27 +00:00
j = getnumber16 ( " Visibility divisor: " , 1 , 128 , 0 ) ;
2006-11-16 03:02:42 +00:00
if ( j ! = 1 )
2006-07-20 20:52:18 +00:00
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2006-07-21 22:25:05 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sector [ i ] . visibility < 240 )
sector [ i ] . visibility / = j ;
else sector [ i ] . visibility = 240 + ( sector [ i ] . visibility > > 4 ) / j ;
2006-11-13 23:12:47 +00:00
}
2006-11-16 03:02:42 +00:00
printmessage16 ( " Visibility adjusted " ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else printmessage16 ( " Aborted " ) ;
2006-07-20 17:33:56 +00:00
}
2006-11-16 03:02:42 +00:00
}
break ;
}
break ;
2006-07-20 05:02:55 +00:00
}
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * MENU_Y_SPACING , editorcolors [ 11 ] , editorcolors [ 1 ] , disptext , 0 ) ;
2006-07-20 05:02:55 +00:00
enddrawing ( ) ;
showframe ( 1 ) ;
}
begindrawing ( ) ;
2008-12-25 12:56:25 +00:00
printext16 ( xpos , ypos + row * MENU_Y_SPACING , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
2006-07-20 05:02:55 +00:00
enddrawing ( ) ;
clearmidstatbar16 ( ) ;
showframe ( 1 ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ESC ] = 0 ;
2006-07-20 05:02:55 +00:00
}
2008-09-01 07:15:16 +00:00
/*
# define UNDODEPTH 96
2008-09-03 04:20:46 +00:00
typedef struct _mapundo
2008-09-01 07:15:16 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t numsectors ;
int32_t numwalls ;
int32_t numsprites ;
2008-09-01 07:15:16 +00:00
sectortype * sectors ;
walltype * walls ;
spritetype * sprites ;
2009-01-09 09:29:17 +00:00
int16_t * headspritesect ;
int16_t * prevspritesect ;
int16_t * nextspritesect ;
2008-09-01 07:15:16 +00:00
2009-01-09 09:29:17 +00:00
int16_t * headspritestat ;
int16_t * prevspritestat ;
int16_t * nextspritestat ;
2008-09-02 02:45:06 +00:00
2009-01-09 09:29:17 +00:00
int32_t revision ;
2008-09-02 02:45:06 +00:00
2008-09-03 04:20:46 +00:00
struct _mapundo * next ; // 'redo' loads this
struct _mapundo * prev ; // 'undo' loads this
2008-09-01 07:15:16 +00:00
} mapundo_t ;
2008-09-03 04:20:46 +00:00
mapundo_t * undopos = NULL ;
2008-09-01 07:15:16 +00:00
mapundo_t undoredo [ UNDODEPTH ] ;
2008-09-22 07:53:59 +00:00
2009-01-09 09:29:17 +00:00
int32_t map_revision = 0 ;
2008-09-02 02:45:06 +00:00
*/