2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
2010-05-25 10:56:00 +00:00
Copyright ( C ) 2010 EDuke32 developers and contributors
2006-04-13 20:47:06 +00:00
2010-05-25 10:56:00 +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
2014-07-20 08:55:56 +00:00
Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2006-04-13 20:47:06 +00:00
*/
//-------------------------------------------------------------------------
# include "compat.h"
# include "build.h"
# include "editor.h"
# include "pragmas.h"
2012-11-05 02:49:08 +00:00
2006-04-13 20:47:06 +00:00
# include "baselayer.h"
2012-11-25 04:26:37 +00:00
# include "renderlayer.h"
2012-11-05 02:49:08 +00:00
2006-04-13 20:47:06 +00:00
# include "osd.h"
# include "cache1d.h"
2011-07-30 13:03:07 +00:00
# include "osdfuncs.h"
# include "names.h"
2014-07-28 06:42:28 +00:00
# include "grpscan.h"
2012-03-26 22:03:20 +00:00
# include "common.h"
2012-06-03 16:09:33 +00:00
# include "common_game.h"
2006-04-13 20:47:06 +00:00
# include "mapster32.h"
# include "keys.h"
2009-04-26 05:57:42 +00:00
2006-04-13 20:47:06 +00:00
# include "keyboard.h"
2006-07-26 01:10:33 +00:00
# include "scriptfile.h"
2014-03-22 09:26:39 +00:00
# include "xxhash.h"
2006-04-13 20:47:06 +00:00
2009-03-15 22:58:20 +00:00
# include "sounds_mapster32.h"
# include "fx_man.h"
2009-04-24 02:53:50 +00:00
# include "macros.h"
2014-02-10 10:55:49 +00:00
# include "lz4.h"
2015-09-27 21:17:59 +00:00
# include "colmatch.h"
2016-06-21 00:33:06 +00:00
# include "palette.h"
2009-04-24 02:53:50 +00:00
2009-09-12 23:03:15 +00:00
# include "m32script.h"
# include "m32def.h"
2012-10-07 15:25:52 +00:00
# ifdef LUNATIC
# include "lunatic_m32.h"
# endif
2014-05-31 12:26:13 +00:00
extern const char * s_buildRev ;
extern const char * s_buildTimestamp ;
extern const char * s_buildInfo ;
2011-03-04 18: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
2010-06-25 23:01:54 +00:00
# include <signal.h>
2013-10-06 07:49:10 +00:00
// Workaround for namespace pollution in <sys/stat.h> introduced in MinGW 4.8.
# ifdef stat
# undef stat
# endif
2014-07-06 22:38:02 +00:00
const char * AppProperName = " Mapster32 " ;
const char * AppTechnicalName = " mapster32 " ;
2014-07-28 06:43:16 +00:00
# if defined(_WIN32)
# define DEFAULT_GAME_EXEC "eduke32.exe"
# define DEFAULT_GAME_LOCAL_EXEC "eduke32.exe"
# elif defined(__APPLE__)
# define DEFAULT_GAME_EXEC "EDuke32.app / Contents / MacOS / eduke32"
# define DEFAULT_GAME_LOCAL_EXEC "EDuke32.app / Contents / MacOS / eduke32"
# else
# define DEFAULT_GAME_EXEC "eduke32"
# define DEFAULT_GAME_LOCAL_EXEC ". / eduke32"
# endif
const char * DefaultGameExec = DEFAULT_GAME_EXEC ;
const char * DefaultGameLocalExec = DEFAULT_GAME_LOCAL_EXEC ;
2009-01-09 09:29:17 +00:00
static int32_t floor_over_floor ;
2011-06-04 00:06:08 +00:00
static int32_t g_fillCurSector = 0 ;
2006-04-13 20:47:06 +00:00
2014-07-28 06:43:16 +00:00
const char * defaultsetupfilename = SETUPFILENAME ;
2014-02-22 08:03:02 +00:00
char setupfilename [ BMAX_PATH ] = SETUPFILENAME ;
2012-03-28 19:44:47 +00:00
2011-11-11 20:05:29 +00:00
static int32_t fixmaponsave_walls = 0 ;
2009-01-09 09:29:17 +00:00
static int32_t lastsave = - 180 * 60 ;
static int32_t NoAutoLoad = 0 ;
2010-05-18 05:14:17 +00:00
static int32_t spnoclip = 1 ;
2007-01-21 23:49:07 +00:00
2016-01-11 05:06:10 +00:00
static char const * default_tiles_cfg = " tiles.cfg " ;
2010-08-14 21:32:28 +00:00
static int32_t pathsearchmode_oninit ;
2012-10-07 15:25:52 +00:00
# ifdef LUNATIC
2012-11-10 20:59:00 +00:00
static L_State g_EmState ;
2012-10-07 15:25:52 +00:00
# endif
2009-07-09 02:29:48 +00:00
# pragma pack(push,1)
2009-03-15 22:58:20 +00:00
sound_t g_sounds [ MAXSOUNDS ] ;
2009-07-09 02:29:48 +00:00
# pragma pack(pop)
2009-03-15 22:58:20 +00:00
static int16_t g_definedsndnum [ MAXSOUNDS ] ; // maps parse order index to g_sounds index
static int16_t g_sndnum [ MAXSOUNDS ] ; // maps current order index to g_sounds index
int32_t g_numsounds = 0 ;
2015-07-25 17:23:17 +00:00
static int32_t mousecol , bstatus ;
2010-05-18 05:14:17 +00:00
2011-01-03 22:04:20 +00:00
static int32_t corruptchecktimer ;
2014-07-28 06:44:37 +00:00
static int32_t curcorruptthing = - 1 ;
2011-01-03 22:04:20 +00:00
2011-02-25 22:10:25 +00:00
static uint32_t templenrepquot = 1 ;
2010-12-05 17:39:52 +00:00
2015-10-03 11:53:16 +00:00
static int32_t duke3d_m32_globalflags ;
2015-12-20 05:18:53 +00:00
// KEEPINSYNC global.h (used values only)
enum DUKE3D_GLOBALFLAGS {
2015-10-03 11:53:19 +00:00
DUKE3D_NO_HARDCODED_FOGPALS = 1 < < 1 ,
2015-12-20 05:18:53 +00:00
DUKE3D_NO_PALETTE_CHANGES = 1 < < 2 ,
2015-10-03 11:53:19 +00:00
} ;
2010-05-18 05:14:17 +00:00
//////////////////// Key stuff ////////////////////
# define eitherALT (keystatus[KEYSC_LALT] || keystatus[KEYSC_RALT])
# define eitherCTRL (keystatus[KEYSC_LCTRL] || keystatus[KEYSC_RCTRL])
# define eitherSHIFT (keystatus[KEYSC_LSHIFT] || keystatus[KEYSC_RSHIFT])
# define PRESSED_KEYSC(Key) (keystatus[KEYSC_##Key] && !(keystatus[KEYSC_##Key]=0))
//////////////////// Aiming ////////////////////
static const char * Typestr [ ] = { " Wall " , " Ceiling " , " Floor " , " Sprite " , " Wall " } ;
static const char * typestr [ ] = { " wall " , " ceiling " , " floor " , " sprite " , " wall " } ;
static const char * Typestr_wss [ ] = { " Wall " , " Sector " , " Sector " , " Sprite " , " Wall " } ;
2010-06-23 04:20:46 +00:00
/*static const char *typestr_wss[] = { "wall", "sector", "sector", "sprite", "wall" };*/
2010-05-18 05:14:17 +00:00
/** The following macros multiplex between identically named fields of sector/wall/sprite,
* based on a macro parameter or the currently aimed at object ( AIMED_ versions ) .
* They can be used on either side of an assignment . */
// select wall, only makes a difference with walls that have 'swap bottom of walls' bit set
# define SELECT_WALL() (AIMING_AT_WALL ? searchbottomwall : searchwall)
# define SECFLD(i, Field) (sector[i].Field)
# define WALFLD(i, Field) (wall[i].Field)
# define SPRFLD(i, Field) (sprite[i].Field)
// valid fields: z, stat, picnum, heinum, shade, pal, xpanning, ypanning
# define CEILINGFLOOR(iSec, Field) (*(AIMING_AT_CEILING ? &(sector[iSec].ceiling##Field) : &(sector[iSec].floor##Field)))
# define AIMED_CEILINGFLOOR(Field) CEILINGFLOOR(searchsector, Field)
# define AIMED_SEL_WALL(Field) WALFLD(SELECT_WALL(), Field)
// selects from wall proper or its mask
# define OVR_WALL(iWal, Field) (*(AIMING_AT_WALL ? &WALFLD(iWal, Field) : &(wall[iWal].over##Field)))
# define AIMED_SELOVR_WALL(Field) OVR_WALL(SELECT_WALL(), Field)
// the base macro to construct field multiplexing macros: wall and sector cases undetermined
# define MUXBASE(Field, SectorCase, WallCase) (*(AIMING_AT_CEILING_OR_FLOOR ? (SectorCase) : \
( AIMING_AT_WALL_OR_MASK ? ( WallCase ) : \
& SPRFLD ( searchwall , Field ) ) ) )
# define SFBASE_CF(Field, WallCase) MUXBASE(Field, &AIMED_CEILINGFLOOR(Field), WallCase)
# define SFBASE_(Field, WallCase) MUXBASE(Field, &SECFLD(searchsector,Field), WallCase)
# define AIMED(Field) SFBASE_(Field, &WALFLD(searchwall, Field))
# define AIMED_SEL(Field) SFBASE_(Field, &AIMED_SEL_WALL(Field))
//#define AIMED_CF(Field) SFBASE_CF(Field, &WALFLD(searchwall,Field))
# define AIMED_CF_SEL(Field) SFBASE_CF(Field, &AIMED_SEL_WALL(Field))
// OVR makes sense only with picnum
//#define AIMED_OVR_PICNUM SFBASE_CF(picnum, &OVR_WALL(searchwall, picnum))
# define AIMED_SELOVR_PICNUM SFBASE_CF(picnum, &AIMED_SELOVR_WALL(picnum))
static const char * ONOFF_ [ ] = { " OFF " , " ON " } ;
# define ONOFF(b) (ONOFF_[!!(b)])
2014-07-28 06:44:37 +00:00
static int32_t tsign , mouseax = 0 , mouseay = 0 ;
2009-05-05 16:21:33 +00:00
static int32_t repeatcountx , repeatcounty ;
static int32_t infobox = 3 ; // bit0: current window, bit1: mouse pointer, the variable should be renamed
2009-09-30 21:46:07 +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 ] ;
2011-03-23 17:41:01 +00:00
static uint8_t wallflag [ MAXWALLS > > 3 ] ;
# ifdef YAX_ENABLE
static uint8_t havebunch [ YAX_MAXBUNCHES ] ;
static int32_t * tempzar [ YAX_MAXBUNCHES ] ;
static int32_t yax_invalidop ( )
{
silentmessage ( " Operation forbidden on extended sector. " ) ;
return 0 ;
}
2011-05-29 23:10:51 +00:00
static int32_t yax_invalidslope ( )
{
silentmessage ( " Firstwalls must coincide for changing slope. " ) ;
return 0 ;
}
// 1: ok
static int32_t yax_checkslope ( int16_t sectnum , int32_t othersectnum )
{
int16_t w1 = sector [ sectnum ] . wallptr , w2 = wall [ w1 ] . point2 ;
int16_t nw1 = sector [ othersectnum ] . wallptr , nw2 = wall [ nw1 ] . point2 ;
if ( nw1 < 0 )
return 0 ; // error
nw2 = wall [ nw1 ] . point2 ;
if ( wall [ w1 ] . x ! = wall [ nw1 ] . x | | wall [ w1 ] . y ! = wall [ nw1 ] . y | |
wall [ w2 ] . x ! = wall [ nw2 ] . x | | wall [ w2 ] . y ! = wall [ nw2 ] . y )
return 0 ;
return 1 ;
}
# define YAXSLOPECHK(s,os) (yax_checkslope(s,os) || yax_invalidslope())
2011-03-23 17:41:01 +00:00
# define YAXCHK(p) ((p) || yax_invalidop())
# endif
2010-08-14 21:32:28 +00:00
// tile marking in tile selector for custom creation of tile groups
2011-04-17 17:01:20 +00:00
static uint8_t tilemarked [ ( MAXTILES + 7 ) > > 3 ] ;
2010-08-14 21:32:28 +00:00
2009-09-30 21:46:07 +00:00
# ifdef POLYMER
static int16_t spritelightid [ MAXSPRITES ] ;
_prlight * spritelightptr [ MAXSPRITES ] ;
2011-01-16 00:23:39 +00:00
2011-03-23 17:41:01 +00:00
static int32_t check_prlight_colors ( int32_t i )
{
return ( sprite [ i ] . xvel ! = spritelightptr [ i ] - > color [ 0 ] ) | |
( sprite [ i ] . yvel ! = spritelightptr [ i ] - > color [ 1 ] ) | |
( sprite [ i ] . zvel ! = spritelightptr [ i ] - > color [ 2 ] ) ;
}
static void copy_prlight_colors ( _prlight * mylightptr , int32_t i )
{
mylightptr - > color [ 0 ] = sprite [ i ] . xvel ;
mylightptr - > color [ 1 ] = sprite [ i ] . yvel ;
mylightptr - > color [ 2 ] = sprite [ i ] . zvel ;
}
static void addprlight_common1 ( _prlight * mylightptr , int32_t i )
{
mylightptr - > sector = SECT ;
Bmemcpy ( mylightptr , & sprite [ i ] , sizeof ( vec3_t ) ) ;
mylightptr - > range = SHT ;
copy_prlight_colors ( mylightptr , i ) ;
mylightptr - > angle = SA ;
mylightptr - > horiz = SH ;
mylightptr - > minshade = sprite [ i ] . xoffset ;
mylightptr - > maxshade = sprite [ i ] . yoffset ;
// overridden for spot lights
mylightptr - > radius = mylightptr - > faderadius = mylightptr - > tilenum = 0 ;
if ( CS & 2 )
{
if ( CS & 512 )
mylightptr - > priority = PR_LIGHT_PRIO_LOW ;
else
mylightptr - > priority = PR_LIGHT_PRIO_HIGH ;
}
else
mylightptr - > priority = PR_LIGHT_PRIO_MAX ;
2012-10-21 04:52:43 +00:00
mylightptr - > publicflags . negative = ! ! ( CS & 128 ) ;
2011-03-23 17:41:01 +00:00
spritelightid [ i ] = polymer_addlight ( mylightptr ) ;
if ( spritelightid [ i ] > = 0 )
spritelightptr [ i ] = & prlights [ spritelightid [ i ] ] ;
}
static void DeletePolymerLights ( void )
2011-01-16 00:23:39 +00:00
{
int32_t i ;
for ( i = 0 ; i < MAXSPRITES ; i + + )
if ( spritelightptr [ i ] ! = NULL )
{
polymer_deletelight ( spritelightid [ i ] ) ;
2011-12-09 19:11:31 +00:00
spritelightid [ i ] = - 1 ;
2011-01-16 00:23:39 +00:00
spritelightptr [ i ] = NULL ;
}
}
2011-09-06 17:45:21 +00:00
void G_Polymer_UnInit ( void )
{
DeletePolymerLights ( ) ;
}
2009-09-30 21:46:07 +00:00
# endif
2009-07-09 02:29:48 +00:00
extern int32_t mskip ;
2009-05-05 16:21:33 +00:00
2011-03-13 11:59:32 +00:00
//extern int32_t fillsector(int16_t sectnum, char fillcolor);
2009-05-05 16:21:33 +00:00
2012-03-17 11:35:35 +00:00
static int32_t osdcmd_quit ( const osdfuncparm_t * parm ) ;
2009-05-05 16:21:33 +00:00
2012-03-18 23:16:37 +00:00
2014-03-22 09:25:15 +00:00
# define M32_NUM_SPRITE_MODES (signed)ARRAY_SIZE(SpriteMode)
2010-05-18 05:14:17 +00:00
static const 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
2010-05-18 05:14:17 +00:00
static const 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
2010-05-18 05:14:17 +00:00
static const 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
2014-03-22 09:25:15 +00:00
# define MAXHELP3D (signed)ARRAY_SIZE(Help3d)
2010-05-18 05:14:17 +00:00
static const char * Help3d [ ] =
2007-08-25 01:05:00 +00:00
{
" Mapster32 3D mode help " ,
" " ,
" F2 = TOGGLE CLIPBOARD " ,
2011-03-25 11:42:07 +00:00
" F3 = TOGGLE MOUSELOOK " ,
" F4 = TOGGLE AMBIENT SOUNDS " ,
2007-08-25 01:05:00 +00:00
" 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 " ,
2011-03-25 11:42:07 +00:00
" ' I = TOGGLE INVISIBLE SPRITES " ,
2007-08-25 01:05:00 +00:00
" " ,
" ' 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-12-19 00:53:54 +00:00
2011-03-04 18:47:06 +00:00
const char * ExtGetVer ( void )
{
return s_buildRev ;
}
2011-11-11 20:05:29 +00:00
void ExtSetupMapFilename ( const char * mapname )
{
2014-07-28 06:43:16 +00:00
UNREFERENCED_PARAMETER ( mapname ) ;
2011-11-11 20:05:29 +00:00
}
2006-04-13 20:47:06 +00:00
void ExtLoadMap ( const char * mapname )
{
2014-07-28 06:43:16 +00:00
UNREFERENCED_PARAMETER ( mapname ) ;
2008-06-10 02:29:58 +00:00
getmessageleng = 0 ;
getmessagetimeoff = 0 ;
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
// Old-fashioned multi-psky handling setup.
G_SetupGlobalPsky ( ) ;
2006-04-13 20:47:06 +00:00
2013-08-04 20:37:45 +00:00
parallaxtype = 0 ;
2011-05-12 23:31:13 +00:00
//////////
2011-08-20 11:54:16 +00:00
# if M32_UNDO
2009-05-16 04:07:09 +00:00
map_undoredo_free ( ) ;
2011-08-20 11:54:16 +00:00
# endif
2006-04-13 20:47:06 +00:00
}
void ExtSaveMap ( const char * mapname )
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( mapname ) ;
2006-04-13 20:47:06 +00:00
}
2011-04-14 20:48:08 +00:00
////////// tag labeling system //////////
2011-04-17 17:01:20 +00:00
# define TLCHAR "+"
# define TLCHR(Cond) ((Cond)?TLCHAR:"")
2012-11-03 19:32:39 +00:00
static uint64_t taglab_nolink_SEs = ( 1ull < < 10 ) | ( 1ull < < 27 ) | ( 1ull < < 28 ) | ( 1ull < < 29 ) |
( 1ull < < 31 ) | ( 1ull < < 32 ) | ( 1ull < < 49 ) | ( 1ull < < 50 ) ;
2011-04-14 20:48:08 +00:00
2014-05-06 22:15:24 +00:00
//// Case lists of switch picnums. Pretty much CODEDUP from sector.c.
// List of switches that function like dip (combination lock) switches.
# define DIPSWITCH_LIKE_CASES \
DIPSWITCH : \
case TECHSWITCH : \
case ALIENSWITCH
// List of access switches.
# define ACCESS_SWITCH_CASES \
ACCESSSWITCH : \
case ACCESSSWITCH2
// List of switches that don't fit the two preceding categories, and are not
// the MULTISWITCH. 13 cases.
# define REST_SWITCH_CASES \
DIPSWITCH2 : \
case DIPSWITCH3 : \
case FRANKENSTINESWITCH : \
case HANDSWITCH : \
case LIGHTSWITCH2 : \
case LIGHTSWITCH : \
case LOCKSWITCH1 : \
case POWERSWITCH1 : \
case POWERSWITCH2 : \
case PULLSWITCH : \
case SLOTDOOR : \
case SPACEDOORSWITCH : \
case SPACELIGHTSWITCH
2011-04-14 20:48:08 +00:00
// Whether the individual tags have linking semantics. Based on
// http://infosuite.duke4.net/index.php?page=references_special_textures
// The return value is an OR of the following:
// 1: lotag has linking semantics
// 2: hitag
// 4: extra
// 8: xvel
// 16: yvel
// 32: zvel
// 64: owner
2011-05-07 18:23:34 +00:00
// This function is only supposed to say something about the potential of a tag:
// it will also 'say yes' if a particular tag is zero.
2011-04-14 20:48:08 +00:00
int32_t taglab_linktags ( int32_t spritep , int32_t num )
{
int32_t picnum ;
int32_t l , link = 0 ;
if ( spritep )
picnum = sprite [ num ] . picnum ;
else
picnum = wall [ num ] . picnum ;
if ( spritep )
{
switch ( picnum )
{
case SECTOREFFECTOR :
// SEs potentially link by their hitag
l = sprite [ num ] . lotag ;
if ( l > = 0 & & l < = 63 & & ( taglab_nolink_SEs & ( 1ull < < l ) ) )
break ;
2013-01-23 19:36:36 +00:00
link = 2 ;
2011-04-14 20:48:08 +00:00
break ;
// various lotag-linkers
2014-05-06 22:15:24 +00:00
// NOTE: switch picnums are handled together with walls below.
2011-04-14 20:48:08 +00:00
case ACTIVATOR : case TOUCHPLATE : case ACTIVATORLOCKED : case MASTERSWITCH :
case RESPAWN : // ---
case MULTISWITCH : // *
2014-05-06 22:15:24 +00:00
case TARGET : case DUCK :
2011-04-14 20:48:08 +00:00
case REACTOR :
case CAMERA1 :
2013-01-23 19:36:36 +00:00
link = 1 ;
2011-04-14 20:48:08 +00:00
break ;
// various hitag-linkers
case VIEWSCREEN2 : case VIEWSCREEN :
case CRACK1 : case CRACK2 : case CRACK3 : case CRACK4 : case FIREEXT :
case FEM1 : case FEM2 : case FEM3 : case FEM4 : case FEM5 : case FEM6 :
case FEM7 : case FEM8 : case FEM9 : case FEM10 : case PODFEM1 : case NAKED1 : //case STATUE: //?
case SEENINE : case OOZFILTER :
case CRANEPOLE : case CRANE :
case NATURALLIGHTNING :
2013-01-23 19:36:36 +00:00
link = 2 ;
2011-04-14 20:48:08 +00:00
break ;
}
}
else // walls
{
2012-03-18 23:16:37 +00:00
# ifdef YAX_ENABLE
2014-05-06 22:15:24 +00:00
// XXX: only for non-VX map versions.
2012-03-18 23:16:37 +00:00
if ( yax_getnextwall ( num , YAX_CEILING ) < 0 )
# endif
2011-04-14 20:48:08 +00:00
switch ( picnum )
{
case TECHLIGHT2 : case TECHLIGHT4 : case WALLLIGHT4 :
case WALLLIGHT3 : case WALLLIGHT1 : case WALLLIGHT2 :
case BIGFORCE : case W_FORCEFIELD :
2013-01-23 19:36:36 +00:00
link = 1 ;
2011-04-14 20:48:08 +00:00
break ;
}
}
if ( ! link )
2012-03-18 23:16:37 +00:00
# ifdef YAX_ENABLE
if ( spritep | | yax_getnextwall ( num , YAX_CEILING ) < 0 )
# endif
2011-04-14 20:48:08 +00:00
{
// try a few that work both as sprites and as walls
switch ( picnum )
{
2014-05-06 22:15:24 +00:00
case ACCESS_SWITCH_CASES :
case DIPSWITCH_LIKE_CASES :
case REST_SWITCH_CASES :
2011-04-14 20:48:08 +00:00
case DOORTILE5 : case DOORTILE6 : case DOORTILE1 : case DOORTILE2 : case DOORTILE3 :
case DOORTILE4 : case DOORTILE7 : case DOORTILE8 : case DOORTILE9 : case DOORTILE10 :
case DOORTILE22 : case DOORTILE18 : case DOORTILE19 : case DOORTILE20 :
case DOORTILE14 : case DOORTILE16 : case DOORTILE15 : case DOORTILE21 :
case DOORTILE17 : case DOORTILE11 : case DOORTILE12 : case DOORTILE23 : // ---
2013-01-23 19:36:36 +00:00
link = 1 ;
2011-04-14 20:48:08 +00:00
break ;
}
2014-05-06 22:15:24 +00:00
// handle 'on' positions of non-access switches
switch ( picnum - 1 )
{
case DIPSWITCH_LIKE_CASES :
case REST_SWITCH_CASES :
link = 1 ;
break ;
}
// handle all positions of the multiswitch
if ( picnum > = MULTISWITCH & & picnum < = MULTISWITCH + 3 )
link = 1 ;
2011-04-14 20:48:08 +00:00
}
2011-04-17 17:01:20 +00:00
g_iReturnVar = link ;
VM_OnEvent ( EVENT_LINKTAGS , spritep ? num : - 1 ) ;
link = g_iReturnVar ;
2011-04-14 20:48:08 +00:00
return link ;
}
2014-05-06 22:15:19 +00:00
// <duetoptr>: if non-NULL, a value will be written denoting the object with
// the currently greatest tag:
// 32768 + spritenum, or
// wallnum, or
// -1 (the return value i.e. no more tags left OR there are no tagged objects)
int32_t taglab_getnextfreetag ( int32_t * duetoptr )
2011-04-17 17:01:20 +00:00
{
2012-11-03 19:32:39 +00:00
int32_t i , nextfreetag = 1 ;
2014-05-06 22:15:19 +00:00
int32_t obj = - 1 ;
2012-11-03 19:32:39 +00:00
2011-04-17 17:01:20 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
{
2012-11-03 19:32:39 +00:00
int32_t tag ;
2011-04-17 17:01:20 +00:00
if ( sprite [ i ] . statnum = = MAXSTATUS )
continue ;
if ( sprite [ i ] . picnum = = MULTISWITCH )
{
// MULTISWITCH needs special care
int32_t endtag = sprite [ i ] . lotag + 3 ;
2014-05-06 22:15:19 +00:00
2011-04-17 17:01:20 +00:00
if ( nextfreetag < = endtag )
2014-05-06 22:15:19 +00:00
{
2011-04-17 17:01:20 +00:00
nextfreetag = endtag + 1 ;
2014-05-06 22:15:19 +00:00
obj = 32768 + i ;
}
2011-04-17 17:01:20 +00:00
continue ;
}
2012-11-03 19:32:39 +00:00
tag = select_sprite_tag ( i ) ;
if ( tag ! = INT32_MIN & & nextfreetag < = tag )
2014-05-06 22:15:19 +00:00
{
2012-11-03 19:32:39 +00:00
nextfreetag = tag + 1 ;
2014-05-06 22:15:19 +00:00
obj = 32768 + i ;
}
2011-04-17 17:01:20 +00:00
}
for ( i = 0 ; i < numwalls ; i + + )
{
2012-11-03 19:32:39 +00:00
int32_t lt = taglab_linktags ( 0 , i ) ;
2011-04-17 17:01:20 +00:00
if ( ( lt & 1 ) & & nextfreetag < = wall [ i ] . lotag )
2014-05-06 22:15:19 +00:00
nextfreetag = wall [ i ] . lotag + 1 , obj = i ;
2011-04-17 17:01:20 +00:00
if ( ( lt & 2 ) & & nextfreetag < = wall [ i ] . hitag )
2014-05-06 22:15:19 +00:00
nextfreetag = wall [ i ] . hitag + 1 , obj = i ;
2011-04-17 17:01:20 +00:00
}
2014-05-06 22:15:19 +00:00
if ( duetoptr ! = NULL )
* duetoptr = obj ;
2011-04-17 17:01:20 +00:00
if ( nextfreetag < 32768 )
return nextfreetag ;
return 0 ;
}
static void taglab_handle1 ( int32_t linktagp , int32_t tagnum , char * buf )
{
2015-07-10 21:19:41 +00:00
char const * const label = ( linktagp & & showtags = = 2 ) ? taglab_getlabel ( tagnum ) : NULL ;
2011-04-17 17:01:20 +00:00
if ( label )
2011-12-09 19:08:29 +00:00
Bsprintf ( buf , " %d<%s> " , tagnum , label ) ;
2011-04-17 17:01:20 +00:00
else
2011-12-09 19:08:29 +00:00
Bsprintf ( buf , " %d%s " , tagnum , TLCHR ( linktagp ) ) ;
2011-04-17 17:01:20 +00:00
}
2011-04-14 20:48:08 +00:00
////////// end tag labeling system //////////
2010-05-18 05:14:17 +00:00
static 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 ;
2010-05-18 05:14:17 +00:00
if ( ! Bstrcmp ( s_TileGroups [ temp ] . szText , groupName ) )
2008-07-14 01:48:20 +00:00
return temp ;
}
return - 1 ;
}
2010-05-18 05:14:17 +00:00
static 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 ;
}
2010-05-18 05:14:17 +00:00
for ( temp = 0 ; temp < s_TileGroups [ group ] . nIds ; temp + + )
2008-07-14 01:48:20 +00:00
{
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
{
switch ( lotag )
{
2015-07-10 07:56:48 +00:00
case 1 : return " WATER " ;
case 2 : return " UNDERWATER " ;
2011-04-11 22:28:58 +00:00
case 9 : return " STAR TREK DOORS " ;
case 15 : return " ELEVATOR TRANSPORT (SE 17) " ;
case 16 : return " ELEVATOR PLATFORM DOWN " ;
case 17 : return " ELEVATOR PLATFORM UP " ;
case 18 : return " ELEVATOR DOWN " ;
case 19 : return " ELEVATOR UP " ;
case 20 : return " CEILING DOOR " ;
case 21 : return " FLOOR DOOR " ;
case 22 : return " SPLIT DOOR " ;
case 23 : return " SWING DOOR (SE 11) " ;
case 25 : return " SLIDE DOOR (SE 15) " ;
case 26 : return " SPLIT STAR TREK DOOR " ;
case 27 : return " BRIDGE (SE 20) " ;
case 28 : return " DROP FLOOR (SE 21) " ;
case 29 : return " TEETH DOOR (SE 22) " ;
case 30 : return " ROTATE RISE BRIDGE " ;
case 31 : return " 2 WAY TRAIN (SE=30) " ;
2015-07-10 07:56:48 +00:00
case 32767 : return " SECRET AREA " ;
2011-04-11 22:28:58 +00:00
case - 1 : return " END OF LEVEL " ;
default :
2008-09-03 10:47:19 +00:00
if ( lotag > 10000 & & lotag < 32767 )
2011-04-11 22:28:58 +00:00
return " 1 TIME SOUND " ;
// else Bsprintf(tempbuf,"%hu",lotag);
2008-09-03 10:47:19 +00:00
}
2011-04-11 22:28:58 +00:00
return " " ;
2008-09-03 10:47:19 +00:00
}
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 ] ;
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2013-05-30 09:13:32 +00:00
if ( ! in3dmode ( ) & & ( ( onnames ! = 1 & & onnames ! = 4 & & onnames ! = 7 ) | | onnames = = 8 ) )
2010-05-18 05:14:17 +00:00
return tempbuf ;
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) | | ( sector [ sectnum ] . lotag | sector [ sectnum ] . hitag ) )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
Bstrcpy ( lo , ExtGetSectorType ( sector [ sectnum ] . lotag ) ) ;
2013-05-30 09:13:32 +00:00
if ( ! in3dmode ( ) )
2014-11-25 21:08:58 +00:00
Bsprintf ( tempbuf , " %hu,%hu %s " , TrackerCast ( sector [ sectnum ] . hitag ) , TrackerCast ( sector [ sectnum ] . lotag ) , lo ) ;
2010-05-18 05:14:17 +00:00
else
2014-11-25 21:08:58 +00:00
Bsprintf ( tempbuf , " %hu %s " , TrackerCast ( 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 ) )
{
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " %d " , wallength ( wallnum ) ) ;
2008-09-02 02:45:06 +00:00
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
2011-04-11 22:28:58 +00:00
{
2011-04-14 20:48:08 +00:00
int32_t lt = taglab_linktags ( 0 , wallnum ) ;
2011-04-17 17:01:20 +00:00
char histr [ TAGLAB_MAX + 16 ] , lostr [ TAGLAB_MAX + 16 ] ;
2012-11-15 14:28:41 +00:00
lt & = ~ ( int ) ( wall [ wallnum ] . lotag < = 0 ) ;
lt & = ~ ( int ) ( ( wall [ wallnum ] . hitag < = 0 ) < < 1 ) ;
2011-04-17 17:01:20 +00:00
taglab_handle1 ( lt & 2 , wall [ wallnum ] . hitag , histr ) ;
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-04-11 22:28:58 +00:00
if ( yax_getnextwall ( wallnum , YAX_CEILING ) > = 0 ) // ceiling nextwall: lotag
{
if ( wall [ wallnum ] . hitag = = 0 )
tempbuf [ 0 ] = 0 ;
else
2011-04-17 17:01:20 +00:00
Bsprintf ( tempbuf , " %s,* " , histr ) ;
2011-04-11 22:28:58 +00:00
}
else
# endif
2011-04-17 17:01:20 +00:00
{
taglab_handle1 ( lt & 1 , wall [ wallnum ] . lotag , lostr ) ;
Bsprintf ( tempbuf , " %s,%s " , histr , lostr ) ;
}
2011-04-11 22:28:58 +00:00
}
2010-05-18 05:14:17 +00:00
2006-04-13 20:47:06 +00:00
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 ] ;
2010-05-18 05:14:17 +00:00
2010-08-02 08:13:51 +00:00
static const char * tags [ ] =
{
2010-05-18 05:14:17 +00:00
" ROTATED SECTOR " , // 0
2015-07-10 07:56:48 +00:00
" ROTATION PIVOT " ,
2010-05-18 05:14:17 +00:00
" EARTHQUAKE " ,
" RANDOM LIGHTS AFTER SHOT OUT " ,
" RANDOM LIGHTS " ,
" (UNKNOWN) " , // 5
" SUBWAY " ,
" TRANSPORT " ,
2015-07-10 07:56:48 +00:00
" RISING DOOR LIGHTS " ,
" LOWERING DOOR LIGHTS " ,
" DOOR CLOSE DELAY " , // 10
" SWING DOOR PIVOT (ST 23) " ,
2010-05-18 05:14:17 +00:00
" LIGHT SWITCH " ,
" EXPLOSIVE " ,
" SUBWAY CAR " ,
" SLIDE DOOR (ST 25) " , // 15
" ROTATE REACTOR SECTOR " ,
" ELEVATOR TRANSPORT (ST 15) " ,
" INCREMENTAL SECTOR RISE/FALL " ,
" CEILING FALL ON EXPLOSION " ,
" BRIDGE (ST 27) " , // 20
" DROP FLOOR (ST 28) " ,
" TEETH DOOR (ST 29) " ,
2015-07-10 07:56:48 +00:00
" 1-WAY TRANSPORT DESTINATION " ,
" CONVEYOR BELT " ,
2010-05-18 05:14:17 +00:00
" ENGINE " , // 25
" (UNKNOWN) " ,
2015-07-10 07:56:48 +00:00
" DEMO CAMERA " ,
" LIGHTNING (4890) CONTROLLER " ,
2010-05-18 05:14:17 +00:00
" FLOAT " ,
2015-07-10 07:56:48 +00:00
" 2 WAY TRAIN (ST 31) " , // 30
" FLOOR Z " ,
" CEILING Z " ,
" EARTHQUAKE DEBRIS " ,
2010-05-18 05:14:17 +00:00
} ;
2008-09-01 07:15:16 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2010-05-18 05:14:17 +00:00
2014-03-22 09:25:15 +00:00
if ( lotag > = 0 & & lotag < ( int32_t ) ARRAY_SIZE ( tags ) )
2015-07-10 07:56:48 +00:00
Bsprintf ( tempbuf , " %s " , tags [ lotag ] ) ;
2010-05-18 05:14:17 +00:00
else
switch ( lotag )
{
case 36 :
2015-07-10 07:56:48 +00:00
Bsprintf ( tempbuf , " SHOOTER " ) ;
2010-05-18 05:14:17 +00:00
break ;
case 49 :
2015-07-10 07:56:48 +00:00
Bsprintf ( tempbuf , " POINT LIGHT " ) ;
2010-05-18 05:14:17 +00:00
break ;
case 50 :
2015-07-10 07:56:48 +00:00
Bsprintf ( tempbuf , " SPOTLIGHT " ) ;
2010-05-18 05:14:17 +00:00
break ;
default :
Bsprintf ( tempbuf , " %d: (UNKNOWN) " , lotag ) ;
break ;
}
2006-04-13 20:47:06 +00:00
return ( tempbuf ) ;
}
2009-03-18 21:05:26 +00:00
const char * MusicAndSFXTagText ( int32_t lotag )
{
static char tempbuf [ 16 ] ;
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
if ( g_numsounds < = 0 )
2009-04-13 06:53:03 +00:00
return tempbuf ;
2009-03-18 21:05:26 +00:00
if ( lotag > 0 & & lotag < 999 & & g_sounds [ lotag ] . definedname )
return g_sounds [ lotag ] . definedname ;
if ( lotag > = 1000 & & lotag < 2000 )
Bsprintf ( tempbuf , " REVERB " ) ;
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 ] ;
2010-05-18 05:14:17 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
Bmemset ( lo , 0 , sizeof ( lo ) ) ;
Bstrcpy ( lo , SectorEffectorTagText ( sprite [ spritenum ] . lotag ) ) ;
2008-09-03 10:47:19 +00:00
if ( ! lo [ 5 ] ) // tags are 5 chars or less
2010-05-18 05:14:17 +00:00
SpriteName ( spritenum , tempbuf ) ;
else
2015-07-10 07:56:48 +00:00
{
if ( cursprite = = spritenum )
2015-07-11 23:07:47 +00:00
Bsprintf ( tempbuf , " SE %d %s " , TrackerCast ( sprite [ spritenum ] . lotag ) , lo ) ;
2015-07-10 07:56:48 +00:00
else Bstrcpy ( tempbuf , lo ) ;
}
2010-05-18 05:14:17 +00:00
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 ] ;
2011-04-14 20:48:08 +00:00
int32_t retfast = 0 , lt ;
2008-09-01 07:15:16 +00:00
2010-05-18 05:14:17 +00:00
if ( ! ( onnames > = 3 & & onnames < = 8 ) | | ( onnames = = 7 & & sprite [ spritenum ] . picnum ! = SECTOREFFECTOR ) )
retfast = 1 ;
if ( onnames = = 5 & & ! tileInGroup ( tilegroupItems , sprite [ spritenum ] . picnum ) )
retfast = 1 ;
2006-11-14 21:35:50 +00:00
if ( onnames = = 6 & & sprite [ spritenum ] . picnum ! = sprite [ cursprite ] . picnum )
2010-05-18 05:14:17 +00:00
retfast = 1 ;
2016-03-15 22:17:04 +00:00
tempbuf [ 0 ] = 0 ;
2010-05-18 05:14:17 +00:00
if ( retfast )
2011-04-17 17:01:20 +00:00
return tempbuf ;
2006-04-13 20:47:06 +00:00
2011-04-14 20:48:08 +00:00
lt = taglab_linktags ( 1 , spritenum ) ;
2012-11-15 14:28:41 +00:00
lt & = ~ ( int ) ( sprite [ spritenum ] . lotag < = 0 ) ;
lt & = ~ ( int ) ( ( sprite [ spritenum ] . hitag < = 0 ) < < 1 ) ;
2011-04-14 20:48:08 +00:00
2006-04-13 20:47:06 +00:00
if ( ( sprite [ spritenum ] . lotag | sprite [ spritenum ] . hitag ) = = 0 )
{
2016-03-15 22:17:04 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2006-04-13 20:47:06 +00:00
SpriteName ( spritenum , lo ) ;
2016-03-15 22:17:04 +00:00
2006-11-13 23:12:47 +00:00
if ( lo [ 0 ] ! = 0 )
2006-04-13 20:47:06 +00:00
{
2015-07-10 21:19:41 +00:00
Bsprintf ( tempbuf , " %s " , lo ) ;
2011-04-14 20:48:08 +00:00
if ( sprite [ spritenum ] . pal = = 1 )
2015-07-10 21:19:41 +00:00
Bstrcat ( tempbuf , " (MULTIPLAYER) " ) ;
2006-04-13 20:47:06 +00:00
}
2011-04-17 17:01:20 +00:00
return tempbuf ;
2006-04-13 20:47:06 +00:00
}
2011-04-17 17:01:20 +00:00
2015-07-10 21:19:41 +00:00
char histr [ TAGLAB_MAX + 16 ] , lostr [ TAGLAB_MAX + 16 ] ;
2011-04-17 17:01:20 +00:00
2015-07-10 21:19:41 +00:00
taglab_handle1 ( lt & 2 , sprite [ spritenum ] . hitag , histr ) ;
2011-04-17 17:01:20 +00:00
2015-07-10 21:19:41 +00:00
if ( sprite [ spritenum ] . picnum = = SECTOREFFECTOR )
{
if ( onnames ! = 8 )
2006-04-13 20:47:06 +00:00
{
2016-03-15 22:17:04 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2015-07-10 21:19:41 +00:00
Bsprintf ( lo , " %s " , SectorEffectorText ( spritenum ) ) ;
Bsprintf ( tempbuf , " %s, %s " , lo , histr ) ;
2006-04-13 20:47:06 +00:00
}
2015-07-10 21:19:41 +00:00
}
else
{
2016-03-15 22:17:04 +00:00
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
2015-07-10 21:19:41 +00:00
taglab_handle1 ( lt & 1 , sprite [ spritenum ] . lotag , lostr ) ;
SpriteName ( spritenum , lo ) ;
if ( sprite [ spritenum ] . extra ! = - 1 )
Bsprintf ( tempbuf , " %s,%s,%d %s " , histr , lostr , TrackerCast ( sprite [ spritenum ] . extra ) , lo ) ;
else
Bsprintf ( tempbuf , " %s,%s %s " , histr , lostr , lo ) ;
2009-02-19 16:47:54 +00:00
}
2010-05-18 05:14:17 +00:00
2011-04-17 17:01:20 +00:00
return tempbuf ;
2006-04-13 20:47:06 +00:00
} //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
2011-02-15 21:02:43 +00:00
static void PrintStatus ( const char * string , int32_t num , int32_t x , int32_t y , int32_t color )
{
Bsprintf ( tempbuf , " %s %d " , string , num ) ;
printext16 ( x * 8 , ydim - STATUS2DSIZ + y * 8 , editorcolors [ color ] , - 1 , tempbuf , 0 ) ;
}
2014-05-06 22:15:19 +00:00
static void PrintNextTag ( void )
{
int32_t obj ;
int32_t nexttag = taglab_getnextfreetag ( & obj ) ;
if ( nexttag > = 1 )
{
if ( obj = = - 1 )
printmessage16 ( " Level %s next tag %d (no tagged objects) " , levelname , nexttag ) ;
else
printmessage16 ( " Level %s next tag %d (%s %d has greatest) " , levelname , nexttag ,
( obj & 32768 ) ? " sprite " : " wall " , obj & 32767 ) ;
}
}
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
int32_t x , x2 , y ;
2010-05-18 05:14:17 +00:00
int32_t i , yi ;
2009-01-09 09:29:17 +00:00
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 ) ;
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2006-04-13 20:47:06 +00:00
return ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2010-05-18 05:14:17 +00:00
secrets + = ( sector [ i ] . lotag = = 32767 ) ;
2006-04-13 20:47:06 +00:00
2011-04-11 22:28:58 +00:00
for ( i = headspritestat [ 0 ] ; i ! = - 1 ; i = nextspritestat [ i ] )
2006-04-13 20:47:06 +00:00
{
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
}
2011-02-15 21:02:43 +00:00
if ( sprite [ i ] . picnum = = RESPAWN )
totalrespawn + + ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
Bmemset ( numsprite , 0 , sizeof ( numsprite ) ) ;
Bmemset ( multisprite , 0 , sizeof ( numsprite ) ) ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-04-13 20:47:06 +00:00
{
2011-02-15 21:02:43 +00:00
if ( sprite [ i ] . statnum = = 0 & & sprite [ i ] . picnum > = 0 & & sprite [ i ] . picnum < MAXTILES )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( sprite [ i ] . pal ! = 0 )
multisprite [ sprite [ i ] . picnum ] + + ;
else
numsprite [ sprite [ i ] . picnum ] + + ;
2006-04-13 20:47:06 +00:00
}
}
clearmidstatbar16 ( ) ; //Clear middle of status bar
2009-05-25 21:47:08 +00:00
ydim - = 8 ;
2010-05-18 05:14:17 +00:00
drawgradient ( ) ;
2009-05-25 21:47:08 +00:00
ydim + = 8 ;
2014-05-06 22:15:19 +00:00
PrintNextTag ( ) ;
2010-05-18 05:14:17 +00:00
# define PRSTAT(Str, Tiledef) \
2010-05-22 14:04:47 +00:00
PrintStatus ( Str , numsprite [ Tiledef ] , x , y + yi , numsprite [ Tiledef ] ? 11 : 7 ) ; \
PrintStatus ( " " , multisprite [ Tiledef ] , x2 , y + yi , multisprite [ Tiledef ] ? 9 : 7 ) ; \
2010-05-18 05:14:17 +00:00
yi + + ;
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
ydim - = 8 ; // vvvvvv reset at end!!
2011-02-15 21:02:43 +00:00
begindrawing ( ) ; //{{{
2010-05-18 05:14:17 +00:00
x = 1 ; x2 = 14 ;
y = 4 ; yi = 2 ;
printext16 ( x * 8 , ydim - STATUS2DSIZ + y * 8 , editorcolors [ 11 ] , - 1 , " Item Count " , 0 ) ;
PRSTAT ( " 10%health= " , COLA ) ;
PRSTAT ( " 30%health= " , SIXPAK ) ;
PRSTAT ( " Med-Kit = " , FIRSTAID ) ;
PRSTAT ( " Atom = " , ATOMICHEALTH ) ;
PRSTAT ( " Shields = " , SHIELD ) ;
x = 17 ; x2 = 30 ;
y = 4 ; yi = 2 ;
printext16 ( x * 8 , ydim - STATUS2DSIZ + y * 8 , editorcolors [ 11 ] , - 1 , " Inventory " , 0 ) ;
PRSTAT ( " Steroids = " , STEROIDS ) ;
PRSTAT ( " Airtank = " , AIRTANK ) ;
PRSTAT ( " Jetpack = " , JETPACK ) ;
PRSTAT ( " Goggles = " , HEATSENSOR ) ;
PRSTAT ( " Boots = " , BOOTS ) ;
PRSTAT ( " HoloDuke = " , HOLODUKE ) ;
PRSTAT ( " Multi D = " , APLAYER ) ;
x = 33 ; x2 = 46 ;
y = 4 ; yi = 2 ;
printext16 ( x * 8 , ydim - STATUS2DSIZ + y * 8 , editorcolors [ 11 ] , - 1 , " Weapon Count " , 0 ) ;
PRSTAT ( " Pistol = " , FIRSTGUNSPRITE ) ;
PRSTAT ( " Shotgun = " , SHOTGUNSPRITE ) ;
PRSTAT ( " Chaingun = " , CHAINGUNSPRITE ) ;
PRSTAT ( " RPG = " , RPGSPRITE ) ;
PRSTAT ( " Pipe Bomb= " , HEAVYHBOMB ) ;
PRSTAT ( " Shrinker = " , SHRINKERSPRITE ) ;
PRSTAT ( " Devastatr= " , DEVISTATORSPRITE ) ;
PRSTAT ( " Trip mine= " , TRIPBOMBSPRITE ) ;
PRSTAT ( " Freezeray= " , FREEZESPRITE ) ;
x = 49 ; x2 = 62 ;
y = 4 ; yi = 2 ;
2009-05-05 16:21:33 +00:00
printext16 ( x * 8 , ydim - STATUS2DSIZ + y * 8 , editorcolors [ 11 ] , - 1 , " Ammo Count " , 0 ) ;
2010-05-18 05:14:17 +00:00
PRSTAT ( " Pistol = " , AMMO ) ;
PRSTAT ( " Shot = " , SHOTGUNAMMO ) ;
PRSTAT ( " Chain = " , BATTERYAMMO ) ;
PRSTAT ( " RPG Box = " , RPGAMMO ) ;
PRSTAT ( " Pipe Bomb= " , HBOMBAMMO ) ;
PRSTAT ( " Shrinker = " , CRYSTALAMMO ) ;
PRSTAT ( " Devastatr= " , DEVISTATORAMMO ) ;
PRSTAT ( " Expander = " , GROWAMMO ) ;
PRSTAT ( " Freezeray= " , FREEZEAMMO ) ;
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
printext16 ( 65 * 8 , ydim - STATUS2DSIZ + 4 * 8 , editorcolors [ 11 ] , - 1 , " MISC " , 0 ) ;
printext16 ( 65 * 8 , ydim - STATUS2DSIZ + 8 * 8 , editorcolors [ 11 ] , - 1 , " ACTORS " , 0 ) ;
# undef PRSTAT
PrintStatus ( " Secrets = " , secrets , 65 , 6 , 11 ) ;
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 ) ;
2011-02-15 21:02:43 +00:00
enddrawing ( ) ; //}}}
2010-05-18 05:14:17 +00:00
ydim + = 8 ; // ^^^^^^ see above!
2011-04-17 17:01:20 +00:00
}
2006-04-13 20:47:06 +00:00
2009-01-09 09:29:17 +00:00
void ExtShowWallData ( int16_t wallnum ) //F6
2006-04-13 20:47:06 +00:00
{
2011-04-17 17:01:20 +00:00
int32_t i , runi , total = 0 , x , y , yi ;
2006-04-13 20:47:06 +00:00
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( wallnum ) ;
2008-03-21 04:01:38 +00:00
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2006-04-13 20:47:06 +00:00
return ;
2010-05-18 05:14:17 +00:00
clearmidstatbar16 ( ) ;
drawgradient ( ) ;
2014-05-06 22:15:19 +00:00
PrintNextTag ( ) ;
2010-05-18 05:14:17 +00:00
# define CASES_LIZTROOP \
LIZTROOP : case LIZTROOPRUNNING : case LIZTROOPSTAYPUT : case LIZTROOPSHOOT : \
case LIZTROOPJETPACK : case LIZTROOPONTOILET : case LIZTROOPDUCKING
# define CASES_BOSS1 BOSS1: case BOSS1STAYPUT: case BOSS1SHOOT: case BOSS1LOB: case BOSSTOP
Bmemset ( numsprite , 0 , sizeof ( numsprite ) ) ;
Bmemset ( multisprite , 0 , sizeof ( multisprite ) ) ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( sprite [ i ] . statnum = = 0 & & sprite [ i ] . pal )
switch ( sprite [ i ] . picnum )
{
case CASES_LIZTROOP :
numsprite [ LIZTROOP ] + + ;
break ;
case CASES_BOSS1 :
multisprite [ BOSS1 ] + + ;
break ;
case BOSS2 :
multisprite [ BOSS2 ] + + ;
break ;
case BOSS3 :
multisprite [ BOSS3 ] + + ;
default :
break ;
}
}
2011-02-15 21:02:43 +00:00
// runi==0: Count Normal Actors
// runi==1: Count Respawn Actors
2010-05-18 05:14:17 +00:00
for ( runi = 0 ; runi < 2 ; runi + + )
{
2011-02-15 21:02:43 +00:00
if ( runi = = 1 )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
Bmemset ( numsprite , 0 , sizeof ( numsprite ) ) ;
Bmemset ( multisprite , 0 , sizeof ( multisprite ) ) ;
}
2006-11-15 01:16:55 +00:00
2010-05-18 05:14:17 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
{
2011-02-15 21:02:43 +00:00
int32_t pic ;
2006-11-16 03:02:42 +00:00
2011-02-15 21:02:43 +00:00
if ( sprite [ i ] . statnum ! = 0 )
continue ;
if ( runi = = 0 & & sprite [ i ] . pal ! = 0 )
continue ;
if ( runi = = 1 & & sprite [ i ] . picnum ! = RESPAWN )
continue ;
2012-11-15 14:28:41 +00:00
pic = ( runi = = 0 ) ? ( int ) sprite [ i ] . picnum : ( int ) sprite [ i ] . hitag ;
2011-02-15 21:02:43 +00:00
if ( pic < 0 | | pic > = MAXTILES )
continue ;
switch ( pic )
{
case CASES_LIZTROOP :
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 CASES_BOSS1 :
if ( runi = = 0 | | sprite [ i ] . pal = = 0 )
numsprite [ BOSS1 ] + + ;
else
multisprite [ 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 NEWBEASTSTAYPUT : case BOSS4 :
numsprite [ pic ] + + ;
break ;
default :
break ;
}
}
2006-11-16 03:02:42 +00:00
2010-05-18 05:14:17 +00:00
# undef CASES_LIZTROOP
# undef CASES_BOSS1
2006-11-16 03:02:42 +00:00
2010-05-18 05:14:17 +00:00
total = 0 ;
2011-02-15 21:02:43 +00:00
for ( i = 0 ; i < MAXTILES ; i + + )
2010-05-18 05:14:17 +00:00
total + = numsprite [ i ] ;
2011-02-15 21:02:43 +00:00
for ( i = 0 ; i < MAXTILES ; i + + )
2010-05-18 05:14:17 +00:00
total + = multisprite [ i ] ;
2011-02-15 21:02:43 +00:00
begindrawing ( ) ; //{{{
2010-05-18 05:14:17 +00:00
x = 2 + runi * 34 ;
y = 4 ;
2010-05-22 14:04:47 +00:00
PrintStatus ( runi = = 0 ? " Normal actors: " : " Respawn actors: " , total , x , y , 11 ) ;
2010-05-18 05:14:17 +00:00
2010-05-22 14:04:47 +00:00
# define PRSTAT(Str, Tiledef) PrintStatus(Str, numsprite[Tiledef], x, y+(yi++), numsprite[Tiledef]?11:7);
2010-05-18 05:14:17 +00:00
yi = 1 ;
PRSTAT ( " Liztroop = " , LIZTROOP ) ;
PRSTAT ( " Lizman = " , LIZMAN ) ;
PRSTAT ( " Commander = " , COMMANDER ) ;
PRSTAT ( " Octabrain = " , OCTABRAIN ) ;
PRSTAT ( " PigCop = " , PIGCOP ) ;
PRSTAT ( " Recon Car = " , RECON ) ;
PRSTAT ( " Drone = " , DRONE ) ;
PRSTAT ( " Turret = " , ROTATEGUN ) ;
PRSTAT ( " Egg = " , EGG ) ;
x + = 17 ;
yi = 1 ;
PRSTAT ( " Slimer = " , GREENSLIME ) ;
PRSTAT ( " Boss1 = " , BOSS1 ) ;
2010-05-22 14:04:47 +00:00
PrintStatus ( " MiniBoss1 = " , multisprite [ BOSS1 ] , x , y + ( yi + + ) , multisprite [ BOSS1 ] ? 11 : 7 ) ;
2010-05-18 05:14:17 +00:00
PRSTAT ( " Boss2 = " , BOSS2 ) ;
PRSTAT ( " Boss3 = " , BOSS3 ) ;
PRSTAT ( " Riot Tank = " , TANK ) ;
PRSTAT ( " Newbeast = " , NEWBEAST ) ;
PRSTAT ( " Boss4 = " , BOSS4 ) ;
# undef PRSTAT
2011-02-15 21:02:43 +00:00
enddrawing ( ) ; //}}}
2009-05-25 21:47:08 +00:00
}
2011-04-17 17:01:20 +00:00
}
2006-04-13 20:47:06 +00:00
2011-02-15 21:02:43 +00:00
// formerly Show2dText and Show3dText
2011-08-09 16:03:56 +00:00
static void ShowFileText ( const char * name )
2006-11-15 01:16:55 +00:00
{
2013-05-30 09:13:32 +00:00
int32_t fp , t ;
2009-01-09 09:29:17 +00:00
uint8_t x = 0 , y = 4 , xmax = 0 , xx = 0 , col = 0 ;
2009-05-25 21:47:08 +00:00
2013-05-30 09:13:32 +00:00
if ( ! in3dmode ( ) )
2011-02-15 21:02:43 +00:00
{
clearmidstatbar16 ( ) ;
drawgradient ( ) ;
}
2009-05-25 21:47:08 +00:00
2006-11-15 01:16:55 +00:00
if ( ( fp = kopen4load ( name , 0 ) ) = = - 1 )
2006-04-13 20:47:06 +00:00
{
2012-03-26 05:05:57 +00:00
Bsprintf ( tempbuf , " ERROR: file \" %s \" not found. " , name ) ;
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2011-02-15 21:02:43 +00:00
printext256 ( 1 * 4 , 4 * 8 , whitecol , - 1 , tempbuf , 0 ) ;
else
printext16 ( 1 * 4 , ydim - STATUS2DSIZ + 4 * 8 , editorcolors [ 11 ] , - 1 , tempbuf , 0 ) ;
2006-04-13 20:47:06 +00:00
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 ;
2011-02-15 21:02:43 +00:00
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2011-02-15 21:02:43 +00:00
printext256 ( xx * 4 , ( y * 6 ) + 2 , whitecol , - 1 , tempbuf , 1 ) ;
else
printext16 ( xx * 4 , ydim - STATUS2DSIZ + ( 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 ) ;
2011-04-17 17:01:20 +00:00
}
2006-04-13 20:47:06 +00:00
2008-06-05 02:51:58 +00:00
// PK_ vvvv
typedef struct helppage_
{
2009-01-09 09:29:17 +00:00
int32_t numlines ;
2015-02-11 05:22:38 +00:00
char line [ 1 ] [ 80 ] ; // C99 flexible array member
2008-06-05 02:51:58 +00:00
} helppage_t ;
2010-05-18 05:14:17 +00:00
static helppage_t * * helppage = NULL ;
static 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 ;
}
2014-05-30 00:02:19 +00:00
helppage = ( helppage_t * * ) Xmalloc ( IHELP_INITPAGES * sizeof ( helppage_t * ) ) ;
2008-06-05 02:51:58 +00:00
numallocpages = IHELP_INITPAGES ;
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 ;
2014-05-30 00:02:19 +00:00
hp = ( helppage_t * ) Xcalloc ( 1 , sizeof ( helppage_t ) + IHELP_INITLINES * 80 ) ;
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 )
{
2014-05-30 00:02:19 +00:00
hp = ( helppage_t * ) Xrealloc ( hp , sizeof ( helppage_t ) + 2 * hp - > numlines * 80 ) ;
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 ;
2011-12-09 19:09:14 +00:00
if ( charsread > = 2 & & tempbuf [ charsread - 2 ] = = 0x0d )
tempbuf [ charsread - 2 ] = 0 ;
2008-06-05 02:51:58 +00:00
}
2009-06-09 06:19:58 +00:00
Bmemcpy ( hp - > line [ j ] , tempbuf , 80 ) ;
2008-06-05 02:51:58 +00:00
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
2014-05-30 00:02:19 +00:00
hp = ( helppage_t * ) Xrealloc ( hp , sizeof ( helppage_t ) + j * 80 ) ;
2008-06-05 02:51:58 +00:00
hp - > numlines = j ;
if ( i > = numallocpages )
{
2014-05-30 00:02:19 +00:00
helppage = ( helppage_t * * ) Xrealloc ( helppage , 2 * numallocpages * sizeof ( helppage_t * ) ) ;
2008-06-05 02:51:58 +00:00
numallocpages * = 2 ;
}
helppage [ i ] = hp ;
i + + ;
}
2014-05-30 00:02:19 +00:00
helppage = ( helppage_t * * ) Xrealloc ( helppage , i * sizeof ( helppage_t * ) ) ;
2008-06-05 02:51:58 +00:00
numhelppages = i ;
Bfclose ( fp ) ;
return ;
}
2008-09-03 11:59:54 +00:00
// why can't MSVC allocate an array of variable size?!
2009-05-31 22:06:18 +00:00
# define IHELP_NUMDISPLINES 110 // ((overridepm16y>>4)+(overridepm16y>>5)+(overridepm16y>>7)-2)
2008-06-05 02:51:58 +00:00
# define IHELP_PATLEN 45
2010-05-22 14:04:47 +00:00
extern int32_t overridepm16y ; // influences clearmidstatbar16()
2008-06-05 02:51:58 +00:00
2011-03-23 17:41:01 +00:00
static void IntegratedHelp ( void )
2008-06-05 02:51:58 +00:00
{
if ( ! helppage ) return ;
2009-05-05 16:21:33 +00:00
overridepm16y = ydim ; //3*STATUS2DSIZ;
2008-09-03 04:20:46 +00:00
2008-09-03 10:47:19 +00:00
{
2010-05-18 05:14:17 +00:00
int32_t i , j ;
2009-01-09 09:29:17 +00:00
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 ] ;
2010-05-22 14:04:47 +00:00
Bmemset ( oldpattern , 0 , sizeof ( char ) ) ;
2009-06-28 20:23:12 +00:00
// clearmidstatbar16();
2008-06-05 02:51:58 +00:00
2011-03-23 17:41:01 +00:00
begindrawing ( ) ;
CLEARLINES2D ( 0 , ydim , 0 ) ;
enddrawing ( ) ;
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
{
2009-08-05 22:37:48 +00:00
idle_waitevent ( ) ;
2008-09-03 10:47:19 +00:00
if ( handleevents ( ) )
2010-05-18 05:14:17 +00:00
quitevent = 0 ;
2009-06-28 20:23:12 +00:00
// printmessage16("Help mode, press <Esc> to exit");
2008-06-05 02:51:58 +00:00
2011-03-23 17:41:01 +00:00
if ( keystatus [ KEYSC_S ] )
2008-06-05 02:51:58 +00:00
{
2011-04-22 22:48:06 +00:00
fade_editor_screen ( - 1 ) ;
2008-09-03 10:47:19 +00:00
}
2011-03-23 17:41:01 +00:00
else
2008-09-03 10:47:19 +00:00
{
2011-03-23 17:41:01 +00:00
begindrawing ( ) ;
CLEARLINES2D ( 0 , ydim , 0 ) ;
enddrawing ( ) ;
2008-09-03 10:47:19 +00:00
}
// based on 'save as' dialog in overheadeditor()
2011-03-23 17:41:01 +00:00
if ( keystatus [ KEYSC_S ] ) // text search
2008-09-03 10:47:19 +00:00
{
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
{
2010-05-18 05:14:17 +00:00
_printmessage16 ( " Search: %s_ " , pattern ) ;
2008-09-03 10:47:19 +00:00
showframe ( 1 ) ;
2009-08-05 22:37:48 +00:00
idle_waitevent ( ) ;
2010-05-22 14:04:47 +00:00
2008-09-03 10:47:19 +00:00
if ( handleevents ( ) )
2010-05-22 14:04:47 +00:00
quitevent = 0 ;
2008-09-03 10:47:19 +00:00
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
2011-04-28 21:28:33 +00:00
if ( Bstrstr ( helppage [ i ] - > line [ j ] , pattern [ 0 ] ? pattern : oldpattern ) )
2008-09-03 10:47:19 +00:00
{
curhp = i ;
2008-06-05 02:51:58 +00:00
2009-05-05 16:21:33 +00:00
if ( ( curline = j ) < = helppage [ i ] - > numlines - 32 /*-IHELP_NUMDISPLINES*/ ) /**/ ;
else if ( ( curline = helppage [ i ] - > numlines - 32 /*-IHELP_NUMDISPLINES*/ ) > = 0 ) /**/ ;
2008-09-03 10:47:19 +00:00
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 ] )
2009-06-09 06:19:58 +00:00
Bmemcpy ( oldpattern , pattern , IHELP_PATLEN + 1 ) ;
2008-09-03 10:47:19 +00:00
}
2008-06-05 02:51:58 +00:00
}
2011-03-23 17:41:01 +00:00
else if ( PRESSED_KEYSC ( T ) ) // goto table of contents
{
curhp = 0 ;
curline = 0 ;
}
else if ( PRESSED_KEYSC ( G ) ) // goto arbitrary page
{
curhp = getnumber16 ( " Goto page: " , 0 , numhelppages - 1 , 0 ) ;
curline = 0 ;
}
else if ( PRESSED_KEYSC ( UP ) ) // scroll up
{
if ( curline > 0 ) curline - - ;
}
else if ( PRESSED_KEYSC ( DOWN ) ) // scroll down
{
if ( curline + 32 /*+IHELP_NUMDISPLINES*/ < helppage [ curhp ] - > numlines ) curline + + ;
}
else if ( PRESSED_KEYSC ( PGUP ) ) // scroll one page up
{
i = IHELP_NUMDISPLINES ;
while ( i > 0 & & curline > 0 ) i - - , curline - - ;
}
else if ( PRESSED_KEYSC ( PGDN ) ) // scroll one page down
{
i = IHELP_NUMDISPLINES ;
while ( i > 0 & & curline + 32 /*+IHELP_NUMDISPLINES*/ < helppage [ curhp ] - > numlines ) i - - , curline + + ;
}
else if ( PRESSED_KEYSC ( SPACE ) ) // goto next paragraph
{
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 + 32 /*+IHELP_NUMDISPLINES*/ < helppage [ curhp ] - > numlines )
curline = i ;
else if ( helppage [ curhp ] - > numlines - 32 /*-IHELP_NUMDISPLINES*/ > curline )
curline = helppage [ curhp ] - > numlines - 32 /*-IHELP_NUMDISPLINES*/ ;
}
}
else if ( PRESSED_KEYSC ( BS ) ) // goto prev paragraph
{
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 ( PRESSED_KEYSC ( HOME ) ) // goto beginning of page
{
curline = 0 ;
}
else if ( PRESSED_KEYSC ( END ) ) // goto end of page
{
if ( ( curline = helppage [ curhp ] - > numlines - 32 /*-IHELP_NUMDISPLINES*/ ) > = 0 ) /**/ ;
else curline = 0 ;
}
else if ( PRESSED_KEYSC ( LEFT ) | | PRESSED_KEYSC ( LBRACK ) ) // prev page
{
if ( curhp > 0 )
{
curhp - - ;
curline = 0 ;
}
}
else if ( PRESSED_KEYSC ( RIGHT ) | | PRESSED_KEYSC ( RBRACK ) ) // next page
{
if ( curhp < numhelppages - 1 )
{
curhp + + ;
curline = 0 ;
}
}
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
}
2010-05-22 14:04:47 +00:00
// drawgradient();
2008-09-04 23:11:48 +00:00
2010-05-18 05:14:17 +00:00
begindrawing ( ) ;
printext16 ( 9 , ydim2d - overridepm16y + 9 , editorcolors [ 4 ] , - 1 , " Help Mode " , 0 ) ;
printext16 ( 8 , ydim2d - overridepm16y + 8 , editorcolors [ 12 ] , - 1 , " Help Mode " , 0 ) ;
2010-05-22 14:04:47 +00:00
printext16 ( 8 + 9 * 8 + 2 * 8 , ydim2d - overridepm16y + 8 , editorcolors [ 15 ] , - 1 , " (S:search) " , 0 ) ;
2010-05-18 05:14:17 +00:00
enddrawing ( ) ;
2008-09-04 23:11:48 +00:00
2008-09-03 10:47:19 +00:00
if ( curhp < helppage [ 0 ] - > numlines )
2010-05-18 05:14:17 +00:00
_printmessage16 ( " %s " , helppage [ 0 ] - > line [ curhp ] ) ;
2008-09-03 10:47:19 +00:00
else
2010-05-18 05:14:17 +00:00
_printmessage16 ( " %d. (Untitled page) " , curhp ) ;
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 ) ,
2009-07-04 09:28:21 +00:00
i < IHELP_NUMDISPLINES & & j < helppage [ curhp ] - > numlines ; i + + )
2008-09-03 10:47:19 +00:00
{
2010-05-22 14:04:47 +00:00
if ( ydim - overridepm16y + 28 + i * 9 + 32 > = ydim )
break ;
2008-09-03 10:47:19 +00:00
Bmemcpy ( disptext [ i ] , helppage [ curhp ] - > line [ j ] , 80 ) ;
2010-05-22 14:04:47 +00:00
printext16 ( 8 , ydim - overridepm16y + 28 + i * 9 , editorcolors [ 10 ] ,
2009-07-04 09:28:21 +00:00
( j = = highlightline & & curhp = = highlighthp
2010-08-02 08:13:51 +00:00
& & totalclock - lasthighlighttime < 120 * 5 ) ?
2010-05-22 14:04:47 +00:00
editorcolors [ 1 ] : - 1 ,
disptext [ i ] , 0 ) ;
2008-09-03 10:47:19 +00:00
}
showframe ( 1 ) ;
2008-06-05 02:51:58 +00:00
}
2012-03-17 11:34:09 +00:00
clearkeys ( ) ;
2008-09-03 10:47:19 +00:00
}
2012-03-17 11:34:09 +00:00
overridepm16y = - 1 ;
2008-06-05 02:51:58 +00:00
}
2009-03-15 22:58:20 +00:00
# define SOUND_NUMDISPLINES IHELP_NUMDISPLINES
2009-03-16 23:14:37 +00:00
static int32_t compare_sounds_s ( int16_t k1 , int16_t k2 )
2009-03-16 22:58:47 +00:00
{
return ( int32_t ) k1 - ( int32_t ) k2 ;
}
2009-03-16 23:14:37 +00:00
static int32_t compare_sounds_d ( int16_t k1 , int16_t k2 )
2009-03-16 22:58:47 +00:00
{
sound_t * s1 = & g_sounds [ k1 ] , * s2 = & g_sounds [ k2 ] ;
char * n1 = s1 - > definedname , * n2 = s2 - > definedname ;
if ( ! n1 & & ! n2 ) return 0 ;
if ( ! n1 ) return - 1 ;
if ( ! n2 ) return 1 ;
2009-04-13 06:53:03 +00:00
return Bstrcasecmp ( n1 , n2 ) ;
2009-03-16 22:58:47 +00:00
}
2009-03-16 23:14:37 +00:00
static int32_t compare_sounds_f ( int16_t k1 , int16_t k2 )
2009-03-16 22:58:47 +00:00
{
sound_t * s1 = & g_sounds [ k1 ] , * s2 = & g_sounds [ k2 ] ;
char * n1 = s1 - > filename , * n2 = s2 - > filename ;
if ( ! n1 & & ! n2 ) return 0 ;
if ( ! n1 ) return - 1 ;
if ( ! n2 ) return 1 ;
2009-04-13 06:53:03 +00:00
return Bstrcasecmp ( n1 , n2 ) ;
2009-03-16 22:58:47 +00:00
}
2009-03-16 23:14:37 +00:00
static int32_t compare_sounds_1 ( int16_t k1 , int16_t k2 )
2009-03-16 22:58:47 +00:00
{
return ( g_sounds [ k2 ] . m & 1 ) - ( g_sounds [ k1 ] . m & 1 ) ;
}
2009-03-16 23:14:37 +00:00
static int32_t compare_sounds_2 ( int16_t k1 , int16_t k2 )
2009-03-16 22:58:47 +00:00
{
2009-04-13 06:53:03 +00:00
return ( g_sounds [ k2 ] . m & 2 ) - ( g_sounds [ k1 ] . m & 2 ) ;
2009-03-16 22:58:47 +00:00
}
2009-03-16 23:14:37 +00:00
static int32_t compare_sounds_3 ( int16_t k1 , int16_t k2 )
2009-03-16 22:58:47 +00:00
{
return ( g_sounds [ k2 ] . m & 4 ) - ( g_sounds [ k1 ] . m & 4 ) ;
}
2009-03-16 23:14:37 +00:00
static int32_t compare_sounds_4 ( int16_t k1 , int16_t k2 )
2009-03-16 22:58:47 +00:00
{
return ( g_sounds [ k2 ] . m & 8 ) - ( g_sounds [ k1 ] . m & 8 ) ;
}
2009-03-16 23:14:37 +00:00
static int32_t compare_sounds_5 ( int16_t k1 , int16_t k2 )
2009-03-16 22:58:47 +00:00
{
return ( g_sounds [ k2 ] . m & 16 ) - ( g_sounds [ k1 ] . m & 16 ) ;
}
static int32_t sort_sounds ( int32_t how )
{
int32_t ( * compare_sounds ) ( int16_t , int16_t ) = NULL ;
int32_t ms , ofs , l , lb , r , rb , d , n , k1 , k2 ;
int16_t * src , * dst , * source , * dest , * tmp ;
n = g_numsounds ;
src = source = g_sndnum ;
2014-05-30 00:02:19 +00:00
dest = ( int16_t * ) Xmalloc ( sizeof ( int16_t ) * n ) ;
2009-03-16 22:58:47 +00:00
dst = dest ;
switch ( how )
{
case ' g ' : // restore original order
Bmemcpy ( g_sndnum , g_definedsndnum , sizeof ( int16_t ) * n ) ;
return 0 ;
case ' s ' :
2009-03-16 23:14:37 +00:00
compare_sounds = compare_sounds_s ;
2009-03-16 22:58:47 +00:00
break ;
case ' d ' :
compare_sounds = compare_sounds_d ;
break ;
case ' f ' :
compare_sounds = compare_sounds_f ;
break ;
case ' 1 ' :
compare_sounds = compare_sounds_1 ;
break ;
case ' 2 ' :
compare_sounds = compare_sounds_2 ;
break ;
case ' 3 ' :
compare_sounds = compare_sounds_3 ;
break ;
case ' 4 ' :
compare_sounds = compare_sounds_4 ;
break ;
case ' 5 ' :
compare_sounds = compare_sounds_5 ;
break ;
default :
return - 2 ;
}
for ( ms = 1 ; ms < n ; ms * = 2 )
{
for ( ofs = 0 ; ofs < n ; ofs + = 2 * ms )
{
l = ofs ;
r = ofs + ms ;
d = ofs ;
lb = min ( ( l + ms ) , n ) ;
rb = min ( ( r + ms ) , n ) ;
while ( l < lb | | r < rb )
{
if ( l > = lb )
{
dst [ d + + ] = src [ r + + ] ;
continue ;
}
if ( r > = rb )
{
dst [ d + + ] = src [ l + + ] ;
continue ;
}
k1 = src [ l ] ;
k2 = src [ r ] ;
if ( compare_sounds ( k1 , k2 ) < = 0 )
{
dst [ d + + ] = src [ l + + ] ;
continue ;
2009-04-13 06:53:03 +00:00
}
2009-03-16 22:58:47 +00:00
dst [ d + + ] = src [ r + + ] ;
}
}
tmp = src ;
src = dst ;
dst = tmp ;
}
if ( src ! = source )
Bmemcpy ( source , src , sizeof ( int16_t ) * n ) ;
Bfree ( dest ) ;
return 0 ;
}
2011-03-23 17:41:01 +00:00
static void SoundDisplay ( void )
2009-03-15 22:58:20 +00:00
{
if ( g_numsounds < = 0 ) return ;
2009-05-05 16:21:33 +00:00
overridepm16y = ydim ; //3*STATUS2DSIZ;
2009-03-15 22:58:20 +00:00
{
// cursnd is the first displayed line, cursnd+curofs is where the cursor is
static int32_t cursnd = 0 , curofs = 0 ;
2012-03-17 11:34:09 +00:00
char disptext [ 80 ] ;
int32_t i , j ;
const int32_t halfpage = ( ydim - 64 ) / ( 2 * 9 ) ;
2009-03-15 22:58:20 +00:00
2009-03-17 21:57:30 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 & & keystatus [ KEYSC_Q ] = = 0 & & keystatus [ KEYSC_F2 ] = = 0
2010-08-02 08:13:51 +00:00
& & keystatus [ buildkeys [ BK_MODE2D_3D ] ] = = 0 ) // quickjump to 3d mode
2009-03-15 22:58:20 +00:00
{
2010-05-22 14:04:47 +00:00
begindrawing ( ) ;
CLEARLINES2D ( 0 , ydim16 , 0 ) ;
enddrawing ( ) ;
2009-08-05 22:37:48 +00:00
idle_waitevent ( ) ;
2009-03-15 22:58:20 +00:00
if ( handleevents ( ) )
2010-05-18 05:14:17 +00:00
quitevent = 0 ;
2009-03-15 22:58:20 +00:00
2010-05-22 14:04:47 +00:00
// drawgradient();
2009-05-05 16:21:33 +00:00
2010-05-18 05:14:17 +00:00
begindrawing ( ) ;
printext16 ( 9 , ydim2d - overridepm16y + 9 , editorcolors [ 4 ] , - 1 , " Sound Index " , 0 ) ;
printext16 ( 8 , ydim2d - overridepm16y + 8 , editorcolors [ 12 ] , - 1 , " Sound Index " , 0 ) ;
2010-05-22 14:04:47 +00:00
printext16 ( 8 + 11 * 8 + 2 * 8 , ydim2d - overridepm16y + 8 , editorcolors [ 15 ] , - 1 , " (SPACE:play, S:sort) " , 0 ) ;
2010-05-18 05:14:17 +00:00
enddrawing ( ) ;
2009-05-05 16:21:33 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( G ) ) // goto specified sound#
2009-03-15 22:58:20 +00:00
{
2009-05-05 16:21:33 +00:00
_printmessage16 ( " " ) ;
2010-05-18 05:14:17 +00:00
j = getnumber16 ( " Goto sound#: " , 0 , g_numsounds - 1 , 0 ) ;
2009-03-15 22:58:20 +00:00
for ( i = 0 ; i < g_numsounds ; i + + )
if ( g_sndnum [ i ] = = j )
break ;
if ( i ! = g_numsounds )
{
if ( i < SOUND_NUMDISPLINES )
cursnd = 0 , curofs = i ;
2012-03-17 11:34:09 +00:00
else if ( i > = g_numsounds - halfpage )
cursnd = g_numsounds - halfpage , curofs = i - cursnd ;
2009-03-15 22:58:20 +00:00
else
2012-03-17 11:34:09 +00:00
curofs = halfpage / 2 , cursnd = i - curofs ;
2009-03-15 22:58:20 +00:00
}
}
2010-05-18 05:14:17 +00:00
else if ( PRESSED_KEYSC ( UP ) ) // scroll up
2009-03-15 22:58:20 +00:00
{
if ( curofs > 0 ) curofs - - ;
else if ( cursnd > 0 ) cursnd - - ;
}
2010-05-18 05:14:17 +00:00
else if ( PRESSED_KEYSC ( DOWN ) ) // scroll down
2009-03-15 22:58:20 +00:00
{
2012-03-17 11:34:09 +00:00
if ( curofs < halfpage - 1 & & cursnd + curofs < g_numsounds - 1 )
2009-03-15 22:58:20 +00:00
curofs + + ;
2012-03-17 11:34:09 +00:00
else if ( cursnd + halfpage < g_numsounds )
2009-03-15 22:58:20 +00:00
cursnd + + ;
}
2010-05-18 05:14:17 +00:00
else if ( PRESSED_KEYSC ( PGUP ) ) // scroll one page up
2009-03-15 22:58:20 +00:00
{
2012-03-17 11:34:09 +00:00
i = halfpage / 2 ;
2009-03-15 22:58:20 +00:00
while ( i > 0 & & curofs > 0 )
i - - , curofs - - ;
while ( i > 0 & & cursnd > 0 )
i - - , cursnd - - ;
}
2010-05-18 05:14:17 +00:00
else if ( PRESSED_KEYSC ( PGDN ) ) // scroll one page down
2009-03-15 22:58:20 +00:00
{
2012-03-17 11:34:09 +00:00
i = halfpage / 2 ;
2009-03-15 22:58:20 +00:00
2012-03-17 11:34:09 +00:00
while ( i > 0 & & curofs < halfpage - 1 & & cursnd + curofs < g_numsounds - 1 )
2009-03-15 22:58:20 +00:00
i - - , curofs + + ;
2012-03-17 11:34:09 +00:00
while ( i > 0 & & cursnd + halfpage < g_numsounds )
2009-03-15 22:58:20 +00:00
i - - , cursnd + + ;
}
2010-05-18 05:14:17 +00:00
else if ( PRESSED_KEYSC ( SPACE ) | | PRESSED_KEYSC ( ENTER ) ) // play/stop sound
2009-03-15 22:58:20 +00:00
{
int32_t j = cursnd + curofs ;
int32_t k = g_sndnum [ j ] ;
2010-05-18 05:14:17 +00:00
2009-03-15 22:58:20 +00:00
if ( S_CheckSoundPlaying ( 0 , k ) > 0 )
S_StopSound ( k ) ;
else
S_PlaySound ( k ) ;
}
2010-05-18 05:14:17 +00:00
else if ( PRESSED_KEYSC ( HOME ) ) // goto first sound#
2009-03-15 22:58:20 +00:00
{
cursnd = curofs = 0 ;
}
2010-05-18 05:14:17 +00:00
else if ( PRESSED_KEYSC ( END ) ) // goto last sound#
2009-03-15 22:58:20 +00:00
{
2012-03-17 11:34:09 +00:00
if ( ( cursnd = g_numsounds - halfpage ) > = 0 )
curofs = halfpage - 1 ;
2009-03-15 22:58:20 +00:00
else
{
cursnd = 0 ;
curofs = g_numsounds - 1 ;
}
}
2010-09-30 23:05:40 +00:00
_printmessage16 ( " FILE NAME PITCH RANGE PRI FLAGS VOLUME " ) ;
for ( i = 0 ; j = cursnd + i , i < SOUND_NUMDISPLINES & & j < g_numsounds ; i + + )
{
int32_t l , m , k = g_sndnum [ j ] ;
sound_t * snd = & g_sounds [ k ] ;
char * cp ;
if ( ydim - overridepm16y + 28 + i * 9 + 32 > = ydim ) break ;
2012-03-17 11:34:09 +00:00
Bsprintf ( disptext ,
2010-09-30 23:05:40 +00:00
" %4d .................... ................ %6d:%-6d %3d %c%c%c%c%c %6d " ,
// 5678901234567890X23456789012345678901234567
k , snd - > ps , snd - > pe , snd - > pr ,
snd - > m & 1 ? ' R ' : ' - ' , snd - > m & 2 ? ' M ' : ' - ' , snd - > m & 4 ? ' D ' : ' - ' ,
snd - > m & 8 ? ' P ' : ' - ' , snd - > m & 16 ? ' G ' : ' - ' , snd - > vo ) ;
2012-03-17 11:34:09 +00:00
for ( l = Bsnprintf ( disptext + 5 , 20 , " %s " , snd - > definedname ) ; l < 20 ; l + + )
disptext [ 5 + l ] = ' ' ;
2010-09-30 23:05:40 +00:00
if ( snd - > filename )
{
l = Bstrlen ( snd - > filename ) ;
if ( l < = 16 )
cp = snd - > filename ;
else
cp = snd - > filename + l - 15 ;
2012-03-17 11:34:09 +00:00
for ( m = Bsnprintf ( disptext + 26 , 16 , " %s " , cp ) ; m < 16 ; m + + )
disptext [ 26 + m ] = ' ' ;
2010-09-30 23:05:40 +00:00
if ( l > 16 )
2012-03-17 11:34:09 +00:00
disptext [ 26 ] = disptext [ 27 ] = disptext [ 28 ] = ' . ' ;
2010-09-30 23:05:40 +00:00
}
printext16 ( 8 , ydim - overridepm16y + 28 + i * 9 ,
keystatus [ KEYSC_S ] ? editorcolors [ 8 ] : ( S_CheckSoundPlaying ( - 1 , k ) ? editorcolors [ 2 ] : editorcolors [ 10 ] ) ,
j = = cursnd + curofs ? editorcolors [ 1 ] : - 1 ,
2012-03-17 11:34:09 +00:00
disptext , 0 ) ;
2010-09-30 23:05:40 +00:00
}
if ( keystatus [ KEYSC_S ] ) // sorting
2009-03-15 22:58:20 +00:00
{
char ch , bad = 0 ;
2010-09-30 23:05:40 +00:00
_printmessage16 ( " Sort by: (S)oundnum (D)ef (F)ile ori(g) or flags (12345) " ) ;
showframe ( 1 ) ;
2009-03-15 22:58:20 +00:00
i = 0 ;
bflushchars ( ) ;
while ( bad = = 0 )
{
2009-08-05 22:37:48 +00:00
idle_waitevent ( ) ;
2009-03-15 22:58:20 +00:00
if ( handleevents ( ) )
2010-05-22 14:04:47 +00:00
quitevent = 0 ;
2009-03-15 22:58:20 +00:00
ch = bgetchar ( ) ;
if ( keystatus [ 1 ] ) bad = 1 ;
2009-04-13 06:53:03 +00:00
2009-03-16 22:58:47 +00:00
else if ( ch = = ' s ' | | ch = = ' d ' | | ch = = ' f ' | | ch = = ' g ' | |
2009-07-04 09:28:21 +00:00
ch = = ' 1 ' | | ch = = ' 2 ' | | ch = = ' 3 ' | | ch = = ' 4 ' | | ch = = ' 5 ' )
2009-03-15 22:58:20 +00:00
{
bad = 2 ;
2009-03-16 22:58:47 +00:00
sort_sounds ( ch ) ;
2009-03-15 22:58:20 +00:00
}
}
2012-03-17 11:34:09 +00:00
clearkeys ( ) ;
2009-03-15 22:58:20 +00:00
}
2010-09-30 23:05:40 +00:00
else
showframe ( 1 ) ;
2009-03-15 22:58:20 +00:00
}
overridepm16y = - 1 ;
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
2012-03-17 11:34:09 +00:00
clearkeys ( ) ;
2009-03-15 22:58:20 +00:00
}
}
2008-06-05 02:51:58 +00:00
// PK_ ^^^^
2012-03-10 21:21:42 +00:00
int32_t AmbienceToggle = 1 ;
2009-04-07 18:56:22 +00:00
int32_t ParentalLock = 0 ;
2014-02-08 14:37:48 +00:00
2014-02-08 14:37:55 +00:00
uint8_t g_ambiencePlaying [ MAXSPRITES > > 3 ] ;
2014-02-08 14:37:48 +00:00
# define testbit(bitarray, i) (bitarray[(i)>>3] & (1<<((i)&7)))
# define setbit(bitarray, i) bitarray[(i)>>3] |= (1<<((i)&7))
# define clearbit(bitarray, i) bitarray[(i)>>3] &= ~(1<<((i)&7))
2009-03-17 21:57:30 +00:00
// adapted from actors.c
static void M32_MoveFX ( void )
{
int32_t i , j ;
int32_t x , ht ;
spritetype * s ;
for ( i = headspritestat [ 0 ] ; i > = 0 ; i = nextspritestat [ i ] )
{
s = & sprite [ i ] ;
2009-03-18 21:05:26 +00:00
if ( s - > picnum ! = MUSICANDSFX )
2009-03-17 21:57:30 +00:00
{
2014-02-08 14:37:48 +00:00
if ( testbit ( g_ambiencePlaying , i ) )
2009-03-17 21:57:30 +00:00
{
2014-02-08 14:37:48 +00:00
clearbit ( g_ambiencePlaying , i ) ;
2009-03-18 21:05:26 +00:00
S_StopEnvSound ( s - > lotag , i ) ;
2009-03-17 21:57:30 +00:00
}
2009-03-18 21:05:26 +00:00
}
2010-10-31 19:54:03 +00:00
else if ( s - > sectnum > = 0 )
2009-03-18 21:05:26 +00:00
{
ht = s - > hitag ;
2009-03-17 21:57:30 +00:00
2009-03-18 21:05:26 +00:00
if ( s - > lotag < 999 & & ( unsigned ) sector [ s - > sectnum ] . lotag < 9 & &
2009-07-04 09:28:21 +00:00
AmbienceToggle & & sector [ s - > sectnum ] . floorz ! = sector [ s - > sectnum ] . ceilingz )
2009-03-17 21:57:30 +00:00
{
2013-09-08 20:18:56 +00:00
if ( ( g_sounds [ s - > lotag ] . m & SF_MSFX ) )
2009-03-17 21:57:30 +00:00
{
2010-08-02 08:13:51 +00:00
x = dist ( ( spritetype * ) & pos , s ) ;
2014-02-08 14:37:48 +00:00
if ( x < ht & & ! testbit ( g_ambiencePlaying , i ) & & FX_VoiceAvailable ( g_sounds [ s - > lotag ] . pr - 1 ) )
2009-03-17 21:57:30 +00:00
{
2012-12-29 10:58:09 +00:00
char om = g_sounds [ s - > lotag ] . m ;
2009-03-17 21:57:30 +00:00
if ( g_numEnvSoundsPlaying = = NumVoices )
{
for ( j = headspritestat [ 0 ] ; j > = 0 ; j = nextspritestat [ j ] )
{
if ( s - > picnum = = MUSICANDSFX & & j ! = i & & sprite [ j ] . lotag < 999 & &
2014-02-08 14:37:48 +00:00
testbit ( g_ambiencePlaying , j ) & & dist ( & sprite [ j ] , ( spritetype * ) & pos ) > x )
2009-03-17 21:57:30 +00:00
{
S_StopEnvSound ( sprite [ j ] . lotag , j ) ;
break ;
}
2009-04-13 06:53:03 +00:00
2009-03-17 21:57:30 +00:00
}
if ( j = = - 1 ) continue ;
}
2013-09-08 20:18:56 +00:00
g_sounds [ s - > lotag ] . m | = SF_LOOP ;
2009-03-17 21:57:30 +00:00
A_PlaySound ( s - > lotag , i ) ;
2012-12-29 10:58:09 +00:00
g_sounds [ s - > lotag ] . m = om ;
2014-02-08 14:37:48 +00:00
setbit ( g_ambiencePlaying , i ) ;
2009-03-17 21:57:30 +00:00
}
2014-02-08 14:37:48 +00:00
if ( x > = ht & & testbit ( g_ambiencePlaying , i ) )
2009-03-17 21:57:30 +00:00
{
2014-02-08 14:37:48 +00:00
clearbit ( g_ambiencePlaying , i ) ;
2009-03-17 21:57:30 +00:00
S_StopEnvSound ( s - > lotag , i ) ;
}
}
}
}
}
}
2009-03-18 21:05:26 +00:00
2009-03-17 21:57:30 +00:00
2010-05-18 05:14:17 +00:00
///__ShowHelpText__
2006-04-13 20:47:06 +00:00
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 ) ;
2013-05-30 09:13:32 +00:00
if ( ! in3dmode ( ) )
2011-08-09 16:03:56 +00:00
ShowFileText ( " sehelp.hlp " ) ;
}
2006-04-13 20:47:06 +00:00
// 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.
2010-05-18 05:14:17 +00:00
static int32_t fofsizex = - 1 ;
static int32_t fofsizey = - 1 ;
2008-03-21 04:01:38 +00:00
#if 0
2011-03-23 17:41:01 +00:00
static void ResetFOFSize ( void )
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
2011-10-17 18:42:10 +00:00
int32_t j = 0 , k = 0 ;
2009-01-09 09:29:17 +00:00
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));
2014-09-30 04:14:21 +00:00
if ( tilesiz [ 562 ] . x )
2006-04-13 20:47:06 +00:00
{
2014-09-30 04:14:21 +00:00
fofsizex = tilesiz [ 562 ] . x ;
tilesiz [ 562 ] . x = 0 ;
2006-04-13 20:47:06 +00:00
}
2014-09-30 04:14:21 +00:00
if ( tilesiz [ 562 ] . y )
2006-04-13 20:47:06 +00:00
{
2014-09-30 04:14:21 +00:00
fofsizey = tilesiz [ 562 ] . y ;
tilesiz [ 562 ] . y = 0 ;
2006-04-13 20:47:06 +00:00
}
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
2009-06-28 20:23:12 +00:00
) { DrawFloorOverFloor ( j ) ; break ; }
2006-04-13 20:47:06 +00:00
}
*/
// 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
}
}
2011-10-17 18:42:10 +00:00
// i=floor1;
2006-04-13 20:47:06 +00:00
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 )
2010-05-18 05:14:17 +00:00
offz = SPRITESEC ( floor2 ) . floorz ;
2006-04-13 20:47:06 +00:00
else
2010-05-18 05:14:17 +00:00
offz = SPRITESEC ( floor2 ) . ceilingz ;
2006-04-13 20:47:06 +00:00
if ( sprite [ floor1 ] . ang > = 1024 )
offz - = sprite [ floor1 ] . z ;
else if ( fofmode = = 40 )
2010-05-18 05:14:17 +00:00
offz - = SPRITESEC ( floor1 ) . floorz ;
2006-04-13 20:47:06 +00:00
else
2010-05-18 05:14:17 +00:00
offz - = SPRITESEC ( floor1 ) . ceilingz ;
2006-04-13 20:47:06 +00:00
// 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
{
2010-05-18 05:14:17 +00:00
tempsectorz [ sprite [ j ] . sectnum ] = SPRITESEC ( j ) . floorz ;
SPRITESEC ( j ) . floorz + = ( ( ( z - SPRITESEC ( j ) . floorz ) / 32768 ) + 1 ) * 32768 ;
tempsectorpicnum [ sprite [ j ] . sectnum ] = SPRITESEC ( j ) . floorpicnum ;
SPRITESEC ( j ) . floorpicnum = 562 ;
2006-04-13 20:47:06 +00:00
}
else
{
2010-05-18 05:14:17 +00:00
tempsectorz [ sprite [ j ] . sectnum ] = SPRITESEC ( j ) . ceilingz ;
SPRITESEC ( j ) . ceilingz + = ( ( ( z - SPRITESEC ( j ) . ceilingz ) / 32768 ) - 1 ) * 32768 ;
tempsectorpicnum [ sprite [ j ] . sectnum ] = SPRITESEC ( j ) . ceilingpicnum ;
SPRITESEC ( j ) . ceilingpicnum = 562 ;
2006-04-13 20:47:06 +00:00
}
draw_both = 1 ;
}
}
drawrooms ( x + offx , y + offy , z + offz , a , h , sprite [ floor2 ] . sectnum ) ;
2012-08-13 18:25:37 +00:00
ExtAnalyzeSprites ( 0 , 0 , 0 , 0 ) ;
2006-04-13 20:47:06 +00:00
drawmasks ( ) ;
2012-02-16 19:25:42 +00:00
M32_ResetFakeRORTiles ( ) ;
2006-04-13 20:47:06 +00:00
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
{
2010-05-18 05:14:17 +00:00
if ( sprite [ j ] . picnum = = SECTOREFFECTOR & &
2010-08-02 08:13:51 +00:00
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
{
2010-05-18 05:14:17 +00:00
SPRITESEC ( j ) . floorz = tempsectorz [ sprite [ j ] . sectnum ] ;
SPRITESEC ( j ) . floorpicnum = tempsectorpicnum [ sprite [ j ] . sectnum ] ;
2006-04-13 20:47:06 +00:00
}
else
{
2010-05-18 05:14:17 +00:00
SPRITESEC ( j ) . ceilingz = tempsectorz [ sprite [ j ] . sectnum ] ;
SPRITESEC ( j ) . ceilingpicnum = tempsectorpicnum [ sprite [ j ] . sectnum ] ;
2006-04-13 20:47:06 +00:00
}
} // end if
} // end for
// Now re-draw
drawrooms ( x + offx , y + offy , z + offz , a , h , sprite [ floor2 ] . sectnum ) ;
2012-08-13 18:25:37 +00:00
ExtAnalyzeSprites ( 0 , 0 , 0 , 0 ) ;
2006-04-13 20:47:06 +00:00
drawmasks ( ) ;
2012-02-16 19:25:42 +00:00
M32_ResetFakeRORTiles ( ) ;
2006-04-13 20:47:06 +00:00
}
} // 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
{
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2006-04-13 20:47:06 +00:00
return ;
2010-05-18 05:14:17 +00:00
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 ;
2010-05-18 05:14:17 +00:00
cursector_lotag = getnumber16 ( " Enter search sector lotag : " , cursector_lotag , BTAG_MAX , 0 ) ;
_printmessage16 ( " Search sector lotag %d " , cursector_lotag ) ;
2006-04-13 20:47:06 +00:00
}
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
{
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2006-04-13 20:47:06 +00:00
return ;
2010-05-18 05:14:17 +00:00
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 ;
2010-05-18 05:14:17 +00:00
search_lotag = getnumber16 ( " Enter wall search lotag : " , search_lotag , BTAG_MAX , 0 ) ;
search_hitag = getnumber16 ( " Enter wall search hitag : " , search_hitag , BTAG_MAX , 0 ) ;
2006-04-13 20:47:06 +00:00
// Bsprintf(tempbuf,"Current wall %d lo=%d hi=%d",
// curwall,wall[curwall].lotag,wall[curwall].hitag);
2010-05-18 05:14:17 +00:00
_printmessage16 ( " Search wall lo=%d hi=%d " , search_lotag , search_hitag ) ;
2006-04-13 20:47:06 +00:00
}
else EditWallData ( wallnum ) ;
}
2010-05-18 05:14:17 +00:00
static void GenericSpriteSearch ( void ) ;
2008-09-19 20:09:43 +00:00
2009-01-09 09:29:17 +00:00
void ExtEditSpriteData ( int16_t spritenum ) //F8
2006-04-13 20:47:06 +00:00
{
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2006-04-13 20:47:06 +00:00
return ;
2010-05-18 05:14:17 +00:00
2008-05-16 00:23:33 +00:00
if ( eitherALT ) //ALT
2010-05-18 05:14:17 +00:00
GenericSpriteSearch ( ) ;
2006-04-13 20:47:06 +00:00
else EditSpriteData ( spritenum ) ;
}
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
{
2010-05-18 05:14:17 +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 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
2015-07-17 00:12:48 +00:00
mousecol = M32_THROB ;
2006-04-13 20:47:06 +00:00
2015-07-17 00:12:48 +00:00
if ( whitecol > editorcolors [ 0 ] )
col = whitecol - mousecol ;
else col = whitecol + mousecol ;
2006-04-13 20:47:06 +00:00
2015-02-18 01:47:09 +00:00
# ifdef USE_OPENGL
if ( getrendermode ( ) > = REND_POLYMOST )
{
push_nofog ( ) ;
bglDisable ( GL_TEXTURE_2D ) ;
}
# endif
2013-01-13 16:40:14 +00:00
2015-07-20 20:25:21 +00:00
int const lores = ! ! ( xdim < = 640 ) ;
for ( i = ( 3 - lores ) ; i < = ( 7 > > lores ) ; i + + )
2006-04-13 20:47:06 +00:00
{
2015-07-20 20:25:21 +00:00
plotpixel ( searchx + i , searchy , col ) ;
plotpixel ( searchx - i , searchy , col ) ;
plotpixel ( searchx , searchy - i , col ) ;
plotpixel ( searchx , searchy + i , col ) ;
}
2010-05-18 05:14:17 +00:00
2015-07-20 20:25:21 +00:00
for ( i = 1 ; i < = ( 2 > > lores ) ; i + + )
{
plotpixel ( searchx + i , searchy , whitecol ) ;
plotpixel ( searchx - i , searchy , whitecol ) ;
plotpixel ( searchx , searchy - i , whitecol ) ;
plotpixel ( searchx , searchy + i , whitecol ) ;
}
2010-05-18 05:14:17 +00:00
2015-07-20 20:25:21 +00:00
i = ( 8 > > lores ) ;
2010-05-18 05:14:17 +00:00
2015-07-20 20:25:21 +00:00
plotpixel ( searchx + i , searchy , editorcolors [ 0 ] ) ;
plotpixel ( searchx - i , searchy , editorcolors [ 0 ] ) ;
plotpixel ( searchx , searchy - i , editorcolors [ 0 ] ) ;
plotpixel ( searchx , searchy + i , editorcolors [ 0 ] ) ;
2007-03-11 00:47:32 +00:00
2015-07-20 20:25:21 +00:00
if ( ! lores )
2007-02-26 01:46:38 +00:00
{
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
}
2013-01-13 16:40:14 +00:00
2015-02-18 01:47:09 +00:00
# ifdef USE_OPENGL
if ( getrendermode ( ) > = REND_POLYMOST )
pop_nofog ( ) ;
# endif
2006-04-13 20:47:06 +00:00
}
2013-06-28 14:07:44 +00:00
int32_t AskIfSure ( const 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
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2008-05-16 19:51:38 +00:00
{
begindrawing ( ) ; //{{{
printext256 ( 0 , 0 , whitecol , 0 , text ? text : " Are you sure you want to proceed? " , 0 ) ;
enddrawing ( ) ; //}}}
}
else
{
2010-12-19 22:47:10 +00:00
_printmessage16 ( " %s " , text ? text : " Are you sure you want to proceed? " ) ;
2008-05-16 19:51:38 +00:00
}
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
{
2010-05-22 14:04:47 +00:00
idle_waitevent ( ) ;
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
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( Y ) | | PRESSED_KEYSC ( ENTER ) )
2006-11-15 01:16:55 +00:00
{
retval = 0 ;
break ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
2010-05-22 14:04:47 +00:00
if ( PRESSED_KEYSC ( ESC ) )
2006-04-13 20:47:06 +00:00
retval = 1 ;
2010-05-18 05:14:17 +00:00
2013-06-28 14:07:44 +00:00
return retval ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
static int32_t IsValidTile ( int32_t idTile )
2007-04-17 05:54:12 +00:00
{
2014-09-30 04:14:21 +00:00
return ( idTile > = 0 & & idTile < MAXTILES ) & & ( tilesiz [ idTile ] . x & & tilesiz [ idTile ] . y ) ;
2007-04-17 05:54:12 +00:00
}
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 ) ;
2010-08-14 21:32:28 +00:00
static int32_t OnSaveTileGroup ( ) ;
static int32_t loadtilegroups ( const char * fn ) ;
2009-01-09 09:29:17 +00:00
static int32_t s_Zoom = INITIAL_ZOOM ;
static int32_t s_TileZoom = 1 ;
2010-08-14 21:32:28 +00:00
static char tilesel_errmsg [ 128 ] , tilesel_showerr = 0 ;
2007-04-17 05:54:12 +00:00
2010-08-16 13:56:49 +00:00
static int32_t DrawTiles ( int32_t iTopLeft , int32_t iSelected , int32_t nXTiles , int32_t nYTiles ,
int32_t TileDim , int32_t offset , int32_t showmsg ) ;
2007-04-17 05:54:12 +00:00
2010-08-14 21:32:28 +00:00
# define TMPERRMSG_SHOW(alsoOSD) do { \
printext256 ( 0 , 0 , whitecol , 0 , tilesel_errmsg , 0 ) ; \
if ( alsoOSD ) OSD_Printf ( " %s \n " , tilesel_errmsg ) ; \
} while ( 0 )
# define TMPERRMSG_PRINT(Msg, ...) do { \
2011-01-03 22:04:20 +00:00
Bsprintf ( tilesel_errmsg , Msg , # # __VA_ARGS__ ) ; \
2010-08-14 21:32:28 +00:00
TMPERRMSG_SHOW ( 1 ) ; \
2011-03-23 17:41:01 +00:00
showframe ( 1 ) ; \
2010-08-14 21:32:28 +00:00
tilesel_showerr = 1 ; \
} while ( 0 )
# define TMPERRMSG_RETURN(Msg, ...) do \
{ \
2011-01-03 22:04:20 +00:00
TMPERRMSG_PRINT ( Msg , # # __VA_ARGS__ ) ; \
2010-08-14 21:32:28 +00:00
return 1 ; \
} while ( 0 )
2007-04-17 05:54:12 +00:00
2012-12-16 19:18:13 +00:00
static inline void pushDisableFog ( void )
{
# ifdef USE_OPENGL
bglPushAttrib ( GL_ENABLE_BIT ) ;
bglDisable ( GL_FOG ) ;
# endif
}
static inline void popDisableFog ( void )
{
# ifdef USE_OPENGL
bglPopAttrib ( ) ;
# endif
}
2009-01-09 09:29:17 +00:00
static int32_t m32gettile ( int32_t idInitialTile )
2007-04-17 05:54:12 +00:00
{
2010-05-22 14:04:47 +00:00
int32_t gap , temp , zoomsz ;
2009-01-09 09:29:17 +00:00
int32_t nXTiles , nYTiles , nDisplayedTiles ;
int32_t i ;
2010-08-14 21:32:28 +00:00
int32_t iTile , iTopLeftTile , iLastTile ;
2009-01-09 09:29:17 +00:00
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
2010-08-14 21:32:28 +00:00
int32_t noTilesMarked = 1 ;
int32_t mark_lastk = - 1 ;
2012-12-16 19:18:13 +00:00
pushDisableFog ( ) ;
2009-06-28 20:23: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;
2007-04-17 05:54:12 +00:00
2010-05-18 05:14:17 +00:00
idInitialTile = clamp ( idInitialTile , 0 , MAXTILES - 1 ) ;
2007-04-17 05:54:12 +00:00
// 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 ;
}
2010-08-14 21:32:28 +00:00
iLastTile = iTile = idSelectedTile = idInitialTile ;
2007-04-17 05:54:12 +00:00
switch ( searchstat )
{
2010-02-13 21:46:42 +00:00
case SEARCH_WALL :
2007-04-17 05:54:12 +00:00
for ( i = 0 ; i < numwalls ; i + + )
localartfreq [ wall [ i ] . picnum ] + + ;
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_CEILING :
case SEARCH_FLOOR :
2007-04-17 05:54:12 +00:00
for ( i = 0 ; i < numsectors ; i + + )
{
localartfreq [ sector [ i ] . ceilingpicnum ] + + ;
localartfreq [ sector [ i ] . floorpicnum ] + + ;
}
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_SPRITE :
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2010-05-18 05:14:17 +00:00
localartfreq [ sprite [ i ] . picnum ] + = ( sprite [ i ] . statnum < MAXSTATUS ) ;
2007-04-17 05:54:12 +00:00
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_MASKWALL :
2007-04-17 05:54:12 +00:00
for ( i = 0 ; i < numwalls ; i + + )
localartfreq [ wall [ i ] . overpicnum ] + + ;
break ;
2011-03-23 17:41:01 +00:00
default :
2007-04-17 05:54:12 +00:00
break ;
}
//
// Sort tiles into frequency order
//
gap = MAXTILES / 2 ;
do
{
for ( i = 0 ; i < MAXTILES - gap ; i + + )
{
temp = i ;
2011-12-12 23:18:15 +00:00
while ( temp > = 0 & & localartfreq [ temp ] < localartfreq [ temp + gap ] )
2007-04-17 05:54:12 +00:00
{
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 ) ;
2010-05-18 05:14:17 +00:00
iTopLeftTile = clamp ( iTopLeftTile , 0 , MAXTILES - nDisplayedTiles ) ;
2007-04-17 05:54:12 +00:00
2010-05-22 14:04:47 +00:00
zoomsz = ZoomToThumbSize [ s_Zoom ] ;
searchx = ( ( iTile - iTopLeftTile ) % nXTiles ) * zoomsz + zoomsz / 2 ;
searchy = ( ( iTile - iTopLeftTile ) / nXTiles ) * zoomsz + zoomsz / 2 ;
2007-04-17 05:54:12 +00:00
////////////////////////////////
// Start of key handling code //
////////////////////////////////
2009-11-14 02:30:47 +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
{
2011-03-23 17:41:01 +00:00
int32_t ret ;
2010-05-22 14:04:47 +00:00
zoomsz = ZoomToThumbSize [ s_Zoom ] ;
2011-03-23 17:41:01 +00:00
ret = DrawTiles ( iTopLeftTile , ( iTile > = localartlookupnum ) ? localartlookupnum - 1 : iTile ,
nXTiles , nYTiles , zoomsz , moffset ,
( tilesel_showerr & & ( iTile = = iLastTile | | ( tilesel_showerr = 0 ) ) ) ) ;
2010-05-22 14:04:47 +00:00
2011-03-23 17:41:01 +00:00
if ( ret = = 0 )
{
idle_waitevent_timeout ( 500 ) ;
// SDL seems to miss mousewheel events when rotated slowly.
2010-05-22 14:04:47 +00:00
2011-03-23 17:41:01 +00:00
if ( handleevents ( ) )
quitevent = 0 ;
}
getmousevalues ( & mousedx , & mousedy , & bstatus ) ;
2010-05-22 14:04:47 +00:00
2011-03-23 17:41:01 +00:00
iLastTile = iTile ;
2010-05-22 14:04:47 +00:00
2008-05-16 19:51:38 +00:00
searchx + = mousedx ;
searchy + = mousedy ;
2010-05-18 05:14:17 +00:00
2008-05-17 21:44:49 +00:00
if ( bstatus & 2 )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
moffset + = mousedy * 2 ;
2008-05-17 21:44:49 +00:00
searchy + = mousedy ;
searchx - = mousedx ;
2010-05-18 05:14:17 +00:00
2008-05-18 21:09:30 +00:00
if ( ( moffset < 0 & & iTopLeftTile > localartlookupnum - nDisplayedTiles - 1 )
2009-07-04 09:28:21 +00:00
| | ( moffset > 0 & & iTopLeftTile = = 0 ) )
2008-05-18 21:09:30 +00:00
{
moffset = 0 ;
searchy - = mousedy * 2 ;
}
2010-05-22 14:04:47 +00:00
while ( moffset > zoomsz )
2008-05-16 19:51:38 +00:00
{
2010-05-22 14:04:47 +00:00
iTopLeftTile - = nXTiles ;
moffset - = zoomsz ;
2008-05-16 19:51:38 +00:00
}
2010-05-22 14:04:47 +00:00
while ( moffset < - zoomsz )
2008-05-16 19:51:38 +00:00
{
2010-05-22 14:04:47 +00:00
iTopLeftTile + = nXTiles ;
moffset + = zoomsz ;
2008-05-16 19:51:38 +00:00
}
}
2008-07-14 01:48:20 +00:00
// Keep the pointer visible at all times.
2010-05-22 14:04:47 +00:00
temp = min ( zoomsz / 2 , 12 ) ;
2011-03-23 17:41:01 +00:00
inpclamp ( & searchx , temp , xdim - temp ) ;
inpclamp ( & searchy , temp , ydim - temp ) ;
2008-05-16 20:15:43 +00:00
2010-05-22 14:04:47 +00:00
scrollmode = ! ( eitherCTRL ^ revertCTRL ) ;
2008-05-18 21:09:30 +00:00
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
}
2010-05-22 14:04:47 +00:00
else 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
}
2010-05-18 05:14:17 +00:00
2010-05-22 14:04:47 +00:00
mtile = iTile = searchx / zoomsz + ( ( searchy - moffset ) / zoomsz ) * nXTiles + iTopLeftTile ;
2008-05-16 19:51:38 +00:00
while ( iTile > = iTopLeftTile + nDisplayedTiles )
{
2010-05-22 14:04:47 +00:00
iTile - = nXTiles ;
mtile = iTile ;
2008-05-16 19:51:38 +00:00
}
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 ) )
2009-07-04 09:28:21 +00:00
| | ( ( keystatus [ KEYSC_gSTAR ] | | ( ! scrollmode & & bstatus & 32 ) ) & & s_Zoom > 0 ) )
2007-04-17 05:54:12 +00:00
{
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( gSLASH ) | | ( ! scrollmode & & bstatus & 16 ) )
2007-04-17 05:54:12 +00:00
{
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 !
2010-05-18 05:14:17 +00:00
if ( ZoomToThumbSize [ s_Zoom + 1 ] < = xdim & & ZoomToThumbSize [ s_Zoom + 1 ] < = ydim )
2007-04-17 05:54:12 +00:00
{
// 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 - - ;
}
2010-05-22 14:04:47 +00:00
zoomsz = ZoomToThumbSize [ s_Zoom ] ;
if ( iTile > = localartlookupnum )
iTile = localartlookupnum - 1 ;
2008-05-17 21:44:49 +00:00
2007-04-17 05:54:12 +00:00
// Calculate new num of tiles to display
2010-05-22 14:04:47 +00:00
nXTiles = xdim / zoomsz ;
nYTiles = ydim / zoomsz ;
2008-07-14 01:48:20 +00:00
// Refuse to draw less than half of a row.
2010-05-22 14:04:47 +00:00
if ( zoomsz / 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 ) ;
2010-05-18 05:14:17 +00:00
iTopLeftTile = clamp ( iTopLeftTile , 0 , MAXTILES - nDisplayedTiles ) ;
2007-04-17 05:54:12 +00:00
2008-05-16 19:51:38 +00:00
// scroll window so mouse points the same tile as it was before zooming
2010-05-22 14:04:47 +00:00
iTopLeftTile - = searchx / zoomsz + ( ( searchy - moffset ) / zoomsz ) * nXTiles + iTopLeftTile - iTile ;
2007-04-17 05:54:12 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( LEFT ) )
2010-08-14 21:32:28 +00:00
{
if ( eitherCTRL ) // same as HOME, for consistency with CTRL-UP/DOWN
iTile = ( iTile / nXTiles ) * nXTiles ;
else
iTile - - ;
}
2007-04-17 05:54:12 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( RIGHT ) )
2010-08-14 21:32:28 +00:00
{
if ( eitherCTRL ) // same as END, for consistency with CTRL-UP/DOWN
iTile = ( ( iTile + nXTiles ) / nXTiles ) * nXTiles - 1 ;
else
iTile + + ;
}
2007-04-17 05:54:12 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( UP ) )
2010-08-14 21:32:28 +00:00
{
if ( eitherCTRL )
while ( iTile - nXTiles > = iTopLeftTile )
iTile - = nXTiles ;
else
iTile - = nXTiles ;
}
2007-04-17 05:54:12 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( DOWN ) )
2010-08-14 21:32:28 +00:00
{
if ( eitherCTRL )
while ( iTile + nXTiles < iTopLeftTile + nDisplayedTiles )
iTile + = nXTiles ;
else
iTile + = nXTiles ;
}
2007-04-17 05:54:12 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( PGUP ) )
2010-08-14 21:32:28 +00:00
{
if ( eitherCTRL )
iTile = 0 ;
else
iTile - = nDisplayedTiles ;
}
2007-04-17 05:54:12 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( PGDN ) )
2010-08-14 21:32:28 +00:00
{
if ( eitherCTRL )
iTile = localartlookupnum - 1 ;
else
iTile + = nDisplayedTiles ;
}
if ( PRESSED_KEYSC ( HOME ) )
{
if ( eitherCTRL )
iTile = iTopLeftTile ;
else
iTile = ( iTile / nXTiles ) * nXTiles ;
}
if ( PRESSED_KEYSC ( END ) )
{
if ( eitherCTRL )
iTile = iTopLeftTile + nDisplayedTiles - 1 ;
else
iTile = ( ( iTile + nXTiles ) / nXTiles ) * nXTiles - 1 ;
}
2007-04-17 05:54:12 +00:00
// 'V' KEYPRESS
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( V ) )
2007-04-17 05:54:12 +00:00
iTile = SelectAllTiles ( iTile ) ;
// 'G' KEYPRESS - Goto frame
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( G ) )
2010-08-14 21:32:28 +00:00
{
if ( eitherCTRL )
{
if ( OnSaveTileGroup ( ) = = 0 )
{
// iTile = SelectAllTiles(iTile);
Bmemset ( tilemarked , 0 , sizeof ( tilemarked ) ) ;
mark_lastk = - 1 ;
noTilesMarked = 1 ;
}
}
else
iTile = OnGotoTile ( iTile ) ;
}
2007-04-17 05:54:12 +00:00
// 'U' KEYPRESS : go straight to user defined art
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( U ) )
2007-04-17 05:54:12 +00:00
{
SelectAllTiles ( iTile ) ;
iTile = FIRST_USER_ART_TILE ;
}
// 'A' KEYPRESS : Go straight to start of Atomic edition's art
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( A ) )
2007-04-17 05:54:12 +00:00
{
SelectAllTiles ( iTile ) ;
iTile = FIRST_ATOMIC_TILE ;
}
2007-04-21 20:25:07 +00:00
// 'E' KEYPRESS : Go straight to start of extended art
2010-05-18 05:14:17 +00:00
if ( PRESSED_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
}
2010-08-14 21:32:28 +00:00
// 'T' KEYPRESS = Select from pre-defined tileset
if ( PRESSED_KEYSC ( T ) )
iTile = OnSelectTile ( iTile ) ;
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( Z ) )
2007-04-23 23:36:21 +00:00
s_TileZoom = ! s_TileZoom ;
2007-04-21 20:25:07 +00:00
2010-08-16 13:56:49 +00:00
//
// Ensure tilenum is within valid range
//
2010-09-27 21:52:04 +00:00
iTile = clamp ( iTile , 0 , min ( MAXTILES - 1 , localartlookupnum + nDisplayedTiles - 1 ) ) ;
2010-08-16 13:56:49 +00:00
// 'S' KEYPRESS: search for named tile
if ( PRESSED_KEYSC ( S ) )
{
2011-01-01 18:35:59 +00:00
static char laststr [ 25 ] = " " ;
2011-04-17 17:01:20 +00:00
const char * searchstr = getstring_simple ( " Search for tile name: " , laststr , sizeof ( names [ 0 ] ) - 1 , 1 ) ;
2011-01-01 18:35:59 +00:00
static char buf [ 2 ] [ 25 ] ;
2010-08-16 13:56:49 +00:00
if ( searchstr & & searchstr [ 0 ] )
{
2010-09-06 23:08:35 +00:00
int32_t i , i0 , slen = Bstrlen ( searchstr ) - 1 ;
2010-08-16 13:56:49 +00:00
2012-03-28 19:43:21 +00:00
Bstrncpyz ( laststr , searchstr , 25 ) ;
2010-08-16 13:56:49 +00:00
i0 = localartlookup [ iTile ] ;
2011-01-01 18:35:59 +00:00
Bmemcpy ( buf [ 0 ] , laststr , 25 ) ;
Bstrupr ( buf [ 0 ] ) ;
2010-09-06 23:08:35 +00:00
for ( i = ( i0 + 1 ) % MAXTILES ; i ! = i0 ; i = ( i + 1 ) % MAXTILES )
2011-01-01 18:35:59 +00:00
{
Bmemcpy ( buf [ 1 ] , names [ i ] , 25 ) ;
buf [ 1 ] [ 24 ] = 0 ;
Bstrupr ( buf [ 1 ] ) ;
if ( ( searchstr [ 0 ] = = ' ^ ' & & ! Bstrncmp ( buf [ 1 ] , buf [ 0 ] + 1 , slen ) ) | |
2011-04-28 21:28:33 +00:00
( searchstr [ 0 ] ! = ' ^ ' & & Bstrstr ( buf [ 1 ] , buf [ 0 ] ) ) )
2010-09-06 23:08:35 +00:00
{
SelectAllTiles ( i ) ;
iTile = i ;
break ;
}
2011-01-01 18:35:59 +00:00
}
2010-08-16 13:56:49 +00:00
}
2011-03-23 17:41:01 +00:00
mousex = mousey = mouseb = 0 ;
2010-08-16 13:56:49 +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 ;
2010-05-18 05:14:17 +00:00
iTopLeftTile = clamp ( iTopLeftTile , 0 , MAXTILES - nDisplayedTiles ) ;
2007-04-17 05:54:12 +00:00
2010-08-14 21:32:28 +00:00
// SPACE keypress: mark/unmark selected tile
if ( PRESSED_KEYSC ( SPACE ) )
{
if ( iTile < localartlookupnum & & IsValidTile ( localartlookup [ iTile ] ) )
{
if ( keystatus [ KEYSC_LCTRL ] & & keystatus [ KEYSC_RSHIFT ] )
{
Bmemset ( tilemarked , 0 , sizeof ( tilemarked ) ) ;
mark_lastk = - 1 ;
noTilesMarked = 1 ;
}
else
{
int32_t k = iTile , kend , dir ;
if ( noTilesMarked )
{
noTilesMarked = 0 ;
2011-04-17 17:01:20 +00:00
TMPERRMSG_PRINT ( " Beginning marking tiles. To group, press Ctrl-G. "
" To reset, press LCtrl-RShift-SPACE. " ) ;
2010-08-14 21:32:28 +00:00
}
if ( mark_lastk > = 0 & & eitherCTRL )
{
kend = mark_lastk ;
dir = ksgn ( mark_lastk - k ) ;
}
else
{
kend = k ;
dir = 0 ;
}
mark_lastk = k ;
for ( ; dir = = 0 | | dir * ( kend - k ) > = 1 ; k + = dir )
{
tilemarked [ localartlookup [ k ] > > 3 ] ^ = ( 1 < < ( localartlookup [ k ] & 7 ) ) ;
if ( dir = = 0 )
break ;
}
}
}
}
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
{
2010-05-22 14:04:47 +00:00
searchx = ( ( iTile - iTopLeftTile ) % nXTiles ) * zoomsz + zoomsz / 2 ;
searchy = ( ( iTile - iTopLeftTile ) / nXTiles ) * zoomsz + zoomsz / 2 + moffset ;
2008-05-16 19:51:38 +00:00
}
2007-04-17 05:54:12 +00:00
}
2010-05-18 05:14:17 +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
2012-12-16 19:18:13 +00:00
popDisableFog ( ) ;
2010-08-14 21:32:28 +00:00
return idSelectedTile ;
2007-04-17 05:54:12 +00:00
}
// 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
//{
//}
2011-03-23 17:41:01 +00:00
static int32_t OnSaveTileGroup ( void )
2010-08-14 21:32:28 +00:00
{
int32_t i , n = 0 ;
char hotkey ;
const char * cp , * name ;
if ( tile_groups = = MAX_TILE_GROUPS )
TMPERRMSG_RETURN ( " Cannot save tile group: maximum number of groups (%d) exceeded. " , MAX_TILE_GROUPS ) ;
for ( i = 0 ; i < MAXTILES ; i + + )
n + = ! ! ( tilemarked [ i > > 3 ] & ( 1 < < ( i & 7 ) ) ) ;
if ( n = = 0 )
2011-01-03 22:04:20 +00:00
TMPERRMSG_RETURN ( " Cannot save tile group: no tiles marked. " ) ;
2010-08-14 21:32:28 +00:00
else if ( n > MAX_TILE_GROUP_ENTRIES )
TMPERRMSG_RETURN ( " Cannot save tile group: too many tiles in group. Have %d, max is %d. " ,
n , MAX_TILE_GROUP_ENTRIES ) ;
2011-04-17 17:01:20 +00:00
cp = getstring_simple ( " Hotkey for new group: " , " " , 1 , 0 ) ;
2010-08-14 21:32:28 +00:00
if ( ! cp | | ! * cp )
return 1 ;
hotkey = Btoupper ( cp [ 0 ] ) ;
if ( ! isalpha ( hotkey ) )
2011-01-03 22:04:20 +00:00
TMPERRMSG_RETURN ( " Hotkey must be alphabetic. " ) ;
2010-08-14 21:32:28 +00:00
for ( i = 0 ; i < tile_groups ; i + + )
if ( s_TileGroups [ i ] . key1 = = hotkey | | s_TileGroups [ i ] . key2 = = Btolower ( hotkey ) )
TMPERRMSG_RETURN ( " Hotkey '%c' already in use by tile group `%s'. " , hotkey , s_TileGroups [ i ] . szText ) ;
2011-04-17 17:01:20 +00:00
name = getstring_simple ( " Name for new tile group: " , " " , 63 , 0 ) ;
2010-08-14 21:32:28 +00:00
if ( ! name | | ! * name )
return 1 ;
2010-08-16 13:56:49 +00:00
for ( i = 0 ; name [ i ] ; i + + )
if ( ! ( isalnum ( name [ i ] ) | | name [ i ] = = ' ' | | name [ i ] = = ' , ' ) )
2011-01-03 22:04:20 +00:00
TMPERRMSG_RETURN ( " Name may only consist of alphabetic, numeric and space characters. " ) ;
2010-08-16 13:56:49 +00:00
2010-08-14 21:32:28 +00:00
{
2010-08-16 13:56:49 +00:00
int32_t lasti = - 1 , col = 0 , j , k , opathsearchmode = pathsearchmode ;
2010-08-14 21:32:28 +00:00
BFILE * fp ;
pathsearchmode = pathsearchmode_oninit ; // use the same pathsearchmode as on init
fp = fopenfrompath ( default_tiles_cfg , " a " ) ;
pathsearchmode = opathsearchmode ;
if ( ! fp )
2010-08-16 13:56:49 +00:00
TMPERRMSG_RETURN ( " Could not open `%s' for writing: %s. " , default_tiles_cfg , strerror ( errno ) ) ;
if ( fseek ( fp , 0 , BSEEK_END ) ) // seems to be necessary even though we fopen with "a"
TMPERRMSG_RETURN ( " Could not seek to end of file `%s'. " , default_tiles_cfg ) ;
2010-08-14 21:32:28 +00:00
# define TTAB "\t"
# define TBITCHK(i) ((i)<MAXTILES && (tilemarked[(i)>>3]&(1<<((i)&7))))
2011-04-17 17:01:20 +00:00
Bfprintf ( fp , OURNEWL ) ;
2014-02-10 11:00:07 +00:00
Bfprintf ( fp , " tilegroup \" %s \" " OURNEWL " { " OURNEWL , name ) ;
Bfprintf ( fp , TTAB " hotkey \" %c \" " OURNEWL OURNEWL , hotkey ) ;
2010-08-14 21:32:28 +00:00
2014-05-30 00:02:19 +00:00
s_TileGroups [ tile_groups ] . pIds = ( int32_t * ) Xmalloc ( n * sizeof ( s_TileGroups [ tile_groups ] . pIds [ 0 ] ) ) ;
2010-08-16 13:56:49 +00:00
j = 0 ;
2010-08-14 21:32:28 +00:00
// tileranges for consecutive runs of 3 or more tiles
for ( i = 0 ; i < MAXTILES ; i + + )
{
if ( lasti > = 0 & & ! TBITCHK ( i ) )
{
if ( names [ lasti ] [ 0 ] & & names [ i - 1 ] [ 0 ] )
2014-02-10 11:00:07 +00:00
Bfprintf ( fp , TTAB " tilerange %s %s " OURNEWL , names [ lasti ] , names [ i - 1 ] ) ;
2010-08-14 21:32:28 +00:00
else
2014-02-10 11:00:07 +00:00
Bfprintf ( fp , TTAB " tilerange %d %d " OURNEWL , lasti , i - 1 ) ;
2010-08-14 21:32:28 +00:00
for ( k = lasti ; k < i ; k + + )
2010-08-16 13:56:49 +00:00
{
s_TileGroups [ tile_groups ] . pIds [ j + + ] = k ;
tilemarked [ k > > 3 ] & = ~ ( 1 < < ( k & 7 ) ) ;
}
2010-08-14 21:32:28 +00:00
lasti = - 1 ;
}
else if ( lasti = = - 1 & & TBITCHK ( i ) )
{
if ( TBITCHK ( i + 1 ) & & TBITCHK ( i + 2 ) )
{
lasti = i ;
i + = 2 ;
}
}
}
2010-08-16 13:56:49 +00:00
if ( lasti > = 0 & & lasti < = MAXTILES - 3 )
{
for ( k = lasti ; k < MAXTILES ; k + + )
{
s_TileGroups [ tile_groups ] . pIds [ j + + ] = k ;
tilemarked [ k > > 3 ] & = ~ ( 1 < < ( k & 7 ) ) ;
}
2014-02-10 11:00:07 +00:00
Bfprintf ( fp , TTAB " tilerange %d %d " OURNEWL , lasti , MAXTILES - 1 ) ;
2010-08-16 13:56:49 +00:00
}
2011-04-17 17:01:20 +00:00
Bfprintf ( fp , OURNEWL ) ;
2010-08-14 21:32:28 +00:00
2011-04-17 17:01:20 +00:00
k = 0 ;
2010-08-14 21:32:28 +00:00
for ( i = 0 ; i < MAXTILES ; i + + )
2011-04-17 17:01:20 +00:00
if ( tilemarked [ i > > 3 ] & ( 1 < < ( i & 7 ) ) )
{
k = 1 ;
break ;
}
if ( k )
2010-08-14 21:32:28 +00:00
{
2011-04-17 17:01:20 +00:00
// throw them all in a tiles{...} group else
2014-02-10 11:00:07 +00:00
Bfprintf ( fp , TTAB " tiles \n " TTAB " { " OURNEWL ) ;
2011-04-17 17:01:20 +00:00
for ( i = 0 ; i < MAXTILES ; i + + )
2010-08-14 21:32:28 +00:00
{
2011-04-17 17:01:20 +00:00
if ( TBITCHK ( i ) )
{
s_TileGroups [ tile_groups ] . pIds [ j + + ] = i ;
2010-08-16 13:56:49 +00:00
2011-04-17 17:01:20 +00:00
if ( col = = 0 )
Bfprintf ( fp , TTAB TTAB ) , col + = 8 ;
2010-08-14 21:32:28 +00:00
2011-04-17 17:01:20 +00:00
if ( names [ i ] [ 0 ] )
col + = Bfprintf ( fp , " %s " , names [ i ] ) ;
else
col + = Bfprintf ( fp , " %d " , i ) ;
2010-08-14 21:32:28 +00:00
2011-04-17 17:01:20 +00:00
if ( col > 80 )
{
Bfprintf ( fp , OURNEWL ) ;
col = 0 ;
}
2010-08-14 21:32:28 +00:00
}
}
2011-04-17 17:01:20 +00:00
if ( col > 0 )
Bfprintf ( fp , OURNEWL ) ;
2014-02-10 11:00:07 +00:00
Bfprintf ( fp , TTAB " } " OURNEWL ) ;
2010-08-14 21:32:28 +00:00
}
# undef TBITCHK
# undef TTAB
2014-02-10 11:00:07 +00:00
Bfprintf ( fp , " } " OURNEWL ) ;
2010-08-14 21:32:28 +00:00
Bfclose ( fp ) ;
2014-05-30 00:02:19 +00:00
s_TileGroups [ tile_groups ] . szText = Xstrdup ( name ) ;
2010-08-16 13:56:49 +00:00
s_TileGroups [ tile_groups ] . nIds = n ;
s_TileGroups [ tile_groups ] . key1 = Btoupper ( hotkey ) ;
s_TileGroups [ tile_groups ] . key2 = Btolower ( hotkey ) ;
s_TileGroups [ tile_groups ] . color1 = s_TileGroups [ tile_groups ] . color2 = 0 ;
tile_groups + + ;
2011-01-03 22:04:20 +00:00
TMPERRMSG_PRINT ( " Wrote and installed new tile group. " ) ;
2010-08-14 21:32:28 +00:00
}
return 0 ;
}
2009-01-09 09:29:17 +00:00
static int32_t OnGotoTile ( int32_t iTile )
2007-04-17 05:54:12 +00:00
{
//Automatically press 'V'
iTile = SelectAllTiles ( iTile ) ;
2011-05-22 21:52:22 +00:00
return getnumber256 ( " Goto tile: " , 0 , MAXTILES - 1 , 0 + 2 + 16 ) ;
2007-04-17 05:54:12 +00:00
}
2010-08-14 21:32:28 +00:00
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 ;
2010-08-14 21:32:28 +00:00
if ( tile_groups < = 0 )
2007-04-21 20:25:07 +00:00
{
2010-08-14 21:32:28 +00:00
TMPERRMSG_PRINT ( " No tile groups loaded. Check for existence of `%s'. " , default_tiles_cfg ) ;
return iTile ;
2007-04-21 20:25:07 +00:00
}
2007-04-17 05:54:12 +00:00
SelectAllTiles ( iTile ) ;
bflushchars ( ) ;
setpolymost2dview ( ) ;
2011-05-18 22:44:09 +00:00
# ifdef USE_OPENGL
2011-05-15 22:37:24 +00:00
bglEnable ( GL_TEXTURE_2D ) ;
2011-05-18 22:44:09 +00:00
# endif
2015-07-08 03:34:42 +00:00
clearview ( - 1 ) ;
2007-04-17 05:54:12 +00:00
//
// Await appropriate selection keypress.
//
bDone = 0 ;
2010-05-18 05:14:17 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 & & ! bDone )
2007-04-17 05:54:12 +00:00
{
if ( handleevents ( ) )
2010-05-18 05:14:17 +00:00
quitevent = 0 ;
2010-05-25 10:56:00 +00:00
idle_waitevent ( ) ;
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
//
2015-11-14 23:41:00 +00:00
int32_t j = 0 ;
2010-08-14 21:32:28 +00:00
for ( i = 0 ; i < tile_groups ; i + + )
2008-07-12 23:44:07 +00:00
{
if ( s_TileGroups [ i ] . szText ! = NULL )
{
2015-11-14 23:41:00 +00:00
if ( ( j + 2 ) * 16 > ydimgame ) break ;
if ( s_TileGroups [ i ] . key1 )
{
Bsprintf ( tempbuf , " (%c) %s " , s_TileGroups [ i ] . key1 , s_TileGroups [ i ] . szText ) ;
printext256 ( 10L , ( j + 1 ) * 16 , whitecol , - 1 , tempbuf , 0 ) ;
j + + ;
}
2008-07-12 23:44:07 +00:00
}
}
showframe ( 1 ) ;
2007-04-17 05:54:12 +00:00
ch = bgetchar ( ) ;
2010-08-14 21:32:28 +00:00
for ( i = 0 ; 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 )
2015-11-14 23:41:00 +00:00
if ( ch = = s_TileGroups [ i ] . key1 | | ch = = s_TileGroups [ i ] . key2 )
2007-04-21 20:25:07 +00:00
{
iTile = LoadTileSet ( iTile , s_TileGroups [ i ] . pIds , s_TileGroups [ i ] . nIds ) ;
bDone = 1 ;
}
2007-04-17 05:54:12 +00:00
}
}
showframe ( 1 ) ;
clearkeys ( ) ;
return iTile ;
}
2010-08-02 08:13:51 +00:00
static const char * GetTilePixels ( int32_t idTile )
2007-04-17 05:54:12 +00:00
{
char * pPixelData = 0 ;
2010-05-18 05:14:17 +00:00
if ( idTile > = 0 & & idTile < MAXTILES )
2007-04-17 05:54:12 +00:00
{
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 ;
}
2011-03-23 17:41:01 +00:00
static void classic_drawtilescreen ( int32_t x , int32_t y , int32_t idTile , int32_t TileDim ,
const char * pRawPixels )
2007-04-17 05:54:12 +00:00
{
2014-09-30 04:14:21 +00:00
int32_t dispxsz = tilesiz [ idTile ] . x , dispysz = tilesiz [ idTile ] . y ;
2011-03-23 17:41:01 +00:00
int32_t divinc = 1 , mulinc = 1 ;
int32_t xofs , yofs ;
2007-04-17 05:54:12 +00:00
char * pScreen ;
2011-03-23 17:41:01 +00:00
while ( ( dispxsz / divinc > TileDim ) | | ( dispysz / divinc ) > TileDim )
{
divinc + + ;
}
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
if ( divinc = = 1 & & s_TileZoom )
{
while ( ( dispxsz * ( mulinc + 1 ) ) < = TileDim & & ( dispysz * ( mulinc + 1 ) ) < = TileDim )
{
mulinc + + ;
}
}
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
dispxsz = ( dispxsz / divinc ) * mulinc ;
dispysz = ( dispysz / divinc ) * mulinc ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
for ( yofs = 0 ; yofs < dispysz ; yofs + + )
2007-04-17 05:54:12 +00:00
{
2011-03-23 17:41:01 +00:00
y + = yofs ;
if ( y > = 0 & & y < ydim )
2007-04-17 05:54:12 +00:00
{
2011-03-23 17:41:01 +00:00
pScreen = ( char * ) ylookup [ y ] + x + frameplace ;
for ( xofs = 0 ; xofs < dispxsz ; xofs + + )
2007-04-17 05:54:12 +00:00
{
2014-09-30 04:14:21 +00:00
pScreen [ xofs ] = pRawPixels [ ( ( yofs * divinc ) / mulinc ) + ( ( ( xofs * divinc ) / mulinc ) * tilesiz [ idTile ] . y ) ] ;
2011-03-23 17:41:01 +00:00
}
}
y - = yofs ;
}
}
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
static void tilescreen_drawbox ( int32_t iTopLeft , int32_t iSelected , int32_t nXTiles ,
int32_t TileDim , int32_t offset ,
int32_t iTile , int32_t idTile )
{
int32_t marked = ( IsValidTile ( idTile ) & & tilemarked [ idTile > > 3 ] & ( 1 < < ( idTile & 7 ) ) ) ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
//
// Draw white box around currently selected tile or marked tile
// p1=(x1, y1), p2=(x1+TileDim-1, y1+TileDim-1)
//
if ( iTile = = iSelected | | marked )
{
int32_t x1 = ( ( iTile - iTopLeft ) % nXTiles ) * TileDim ;
int32_t y1 = ( ( iTile - ( ( iTile - iTopLeft ) % nXTiles ) - iTopLeft ) / nXTiles ) * TileDim + offset ;
int32_t x2 = x1 + TileDim - 1 ;
2011-07-20 22:08:05 +00:00
int32_t y2 = y1 + TileDim - 1 , oydim16 = ydim16 ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
char markedcol = editorcolors [ 14 ] ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
setpolymost2dview ( ) ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
y1 = max ( y1 , 0 ) ;
y2 = min ( y2 , ydim - 1 ) ;
2007-04-17 05:54:12 +00:00
2011-07-20 22:08:05 +00:00
// plotlines2d uses drawline16, which clips against ydim16...
ydim16 = ydim ;
2011-03-23 17:41:01 +00:00
{
// box
int32_t xx [ ] = { x1 , x1 , x2 , x2 , x1 } ;
int32_t yy [ ] = { y1 , y2 , y2 , y1 , y1 } ;
plotlines2d ( xx , yy , 5 , iTile = = iSelected ? whitecol : markedcol ) ;
}
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
// cross
if ( marked )
{
int32_t xx [ ] = { x1 , x2 } ;
int32_t yy [ ] = { y1 , y2 } ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
plotlines2d ( xx , yy , 2 , markedcol ) ;
swaplong ( & yy [ 0 ] , & yy [ 1 ] ) ;
plotlines2d ( xx , yy , 2 , markedcol ) ;
}
2011-07-20 22:08:05 +00:00
ydim16 = oydim16 ;
2011-03-23 17:41:01 +00:00
}
}
2010-05-18 05:14:17 +00:00
2011-03-23 17:41:01 +00:00
static void tilescreen_drawrest ( int32_t iSelected , int32_t showmsg )
{
if ( iSelected > = 0 & & iSelected < MAXTILES )
{
int32_t idTile = localartlookup [ iSelected ] ;
int32_t i ;
char szT [ 128 ] ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
// Draw info bar at bottom.
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
// Clear out behind the text for improved visibility.
//drawline256(0, (ydim-12)<<12, xdim<<12, (ydim-12)<<12, whitecol);
for ( i = ydim - 12 ; i < ydim ; i + + )
drawline256 ( 0 , i < < 12 , xdim < < 12 , i < < 12 , ( ydim - i ) ) ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
// Tile number on left.
Bsprintf ( szT , " %d " , idTile ) ;
printext256 ( 1 , ydim - 10 , whitecol , - 1 , szT , 0 ) ;
2010-08-14 21:32:28 +00:00
2011-03-23 17:41:01 +00:00
// Tile name on right.
printext256 ( xdim - ( Bstrlen ( names [ idTile ] ) < < 3 ) - 1 , ydim - 10 , whitecol , - 1 , names [ idTile ] , 0 ) ;
2010-08-14 21:32:28 +00:00
2011-03-23 17:41:01 +00:00
// Tile dimensions.
2014-09-30 04:14:21 +00:00
Bsprintf ( szT , " %dx%d " , tilesiz [ idTile ] . x , tilesiz [ idTile ] . y ) ;
2011-03-23 17:41:01 +00:00
printext256 ( xdim > > 2 , ydim - 10 , whitecol , - 1 , szT , 0 ) ;
2010-08-14 21:32:28 +00:00
2011-03-23 17:41:01 +00:00
// EditArt offset flags.
2012-11-17 19:46:28 +00:00
Bsprintf ( szT , " %d, %d " , picanm [ idTile ] . xofs , picanm [ idTile ] . yofs ) ;
2011-03-23 17:41:01 +00:00
printext256 ( ( xdim > > 2 ) + 100 , ydim - 10 , whitecol , - 1 , szT , 0 ) ;
2011-02-24 20:40:27 +00:00
2011-03-23 17:41:01 +00:00
// EditArt animation flags.
2012-11-17 19:46:28 +00:00
if ( picanm [ idTile ] . sf & PICANM_ANIMTYPE_MASK )
2011-03-23 17:41:01 +00:00
{
static const char * anmtype [ ] = { " " , " Osc " , " Fwd " , " Bck " } ;
2012-11-17 19:46:28 +00:00
int32_t ii = ( picanm [ idTile ] . sf & PICANM_ANIMTYPE_MASK ) > > PICANM_ANIMTYPE_SHIFT ;
2010-09-01 02:35:36 +00:00
2012-11-17 19:46:28 +00:00
Bsprintf ( szT , " %s %d " , anmtype [ ii ] , picanm [ idTile ] . num ) ;
2011-03-23 17:41:01 +00:00
printext256 ( ( xdim > > 2 ) + 100 + 14 * 8 , ydim - 10 , whitecol , - 1 , szT , 0 ) ;
2008-05-16 19:51:38 +00:00
}
2010-08-14 21:32:28 +00:00
}
2011-03-23 17:41:01 +00:00
if ( showmsg )
TMPERRMSG_SHOW ( 0 ) ;
m32_showmouse ( ) ;
}
////////// main tile drawing function //////////
static int32_t DrawTiles ( int32_t iTopLeft , int32_t iSelected , int32_t nXTiles , int32_t nYTiles ,
int32_t TileDim , int32_t offset , int32_t showmsg )
{
int32_t XTile , YTile ;
int32_t iTile , idTile ;
int32_t i , x , y ;
const char * pRawPixels ;
char szT [ 128 ] ;
2012-02-18 17:56:26 +00:00
# ifdef USE_OPENGL
2012-02-16 19:24:09 +00:00
int32_t lazyselector = g_lazy_tileselector & & usehightile ;
2013-10-07 10:03:49 +00:00
int32_t usehitile ;
2012-02-18 17:56:26 +00:00
# else
int32_t lazyselector = g_lazy_tileselector ;
# endif
2013-10-07 10:03:49 +00:00
int32_t runi = 0 ;
2011-03-23 17:41:01 +00:00
static uint8_t loadedhitile [ ( MAXTILES + 7 ) > > 3 ] ;
2011-05-18 22:44:09 +00:00
# ifdef USE_OPENGL
2011-11-25 09:49:22 +00:00
setpolymost2dview ( ) ;
2011-11-17 21:10:04 +00:00
2013-05-17 03:44:09 +00:00
if ( getrendermode ( ) > = REND_POLYMOST )
2011-11-25 09:49:22 +00:00
{
bglEnable ( GL_TEXTURE_2D ) ;
2012-02-16 19:24:09 +00:00
if ( lazyselector )
2011-11-25 09:49:22 +00:00
bglDrawBuffer ( GL_FRONT_AND_BACK ) ;
}
2011-05-18 22:44:09 +00:00
# endif
2015-07-08 03:34:42 +00:00
clearview ( - 1 ) ;
2011-03-23 17:41:01 +00:00
2011-04-09 15:35:46 +00:00
begindrawing ( ) ;
2011-03-23 17:41:01 +00:00
restart :
for ( YTile = 0 - ( offset > 0 ) ; YTile < nYTiles + ( offset < 0 ) + 1 ; YTile + + )
2011-01-20 10:52:33 +00:00
{
2011-03-23 17:41:01 +00:00
for ( XTile = 0 ; XTile < nXTiles ; XTile + + )
{
iTile = iTopLeft + XTile + ( YTile * nXTiles ) ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
if ( iTile < 0 | | iTile > = localartlookupnum )
continue ;
2013-10-07 10:03:49 +00:00
# ifdef USE_OPENGL
2012-02-16 19:24:09 +00:00
usehitile = ( runi | | ! lazyselector ) ;
2013-10-07 10:03:49 +00:00
# endif
2008-07-14 01:48:20 +00:00
2011-03-23 17:41:01 +00:00
idTile = localartlookup [ iTile ] ;
if ( loadedhitile [ idTile > > 3 ] & ( 1 < < ( idTile & 7 ) ) )
{
2011-05-15 22:37:24 +00:00
if ( runi = = 1 )
2011-03-23 17:41:01 +00:00
continue ;
2011-05-15 22:37:24 +00:00
2013-10-07 10:03:49 +00:00
# ifdef USE_OPENGL
2011-05-15 22:37:24 +00:00
usehitile = 1 ;
2013-10-07 10:03:49 +00:00
# endif
2011-03-23 17:41:01 +00:00
}
2008-07-14 01:48:20 +00:00
2011-03-23 17:41:01 +00:00
// Get pointer to tile's raw pixel data
pRawPixels = GetTilePixels ( idTile ) ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
if ( pRawPixels ! = NULL )
{
x = XTile * TileDim ;
y = YTile * TileDim + offset ;
2008-07-14 01:48:20 +00:00
2013-10-07 10:03:49 +00:00
# ifdef USE_OPENGL
2011-03-23 17:41:01 +00:00
if ( polymost_drawtilescreen ( x , y , idTile , TileDim , s_TileZoom ,
usehitile , loadedhitile ) )
2013-10-07 10:03:49 +00:00
# endif
2011-03-23 17:41:01 +00:00
classic_drawtilescreen ( x , y , idTile , TileDim , pRawPixels ) ;
2007-04-17 05:54:12 +00:00
2011-03-23 17:41:01 +00:00
if ( localartfreq [ iTile ] ! = 0 & & y > = 0 & & y < = ydim - 20 )
{
Bsprintf ( szT , " %d " , localartfreq [ iTile ] ) ;
printext256 ( x , y , whitecol , - 1 , szT , 1 ) ;
}
}
2008-03-27 21:32:23 +00:00
2011-03-23 17:41:01 +00:00
tilescreen_drawbox ( iTopLeft , iSelected , nXTiles , TileDim , offset , iTile , idTile ) ;
2011-03-07 16:30:06 +00:00
2012-02-16 19:24:09 +00:00
if ( runi = = 1 & & lazyselector )
2011-03-23 17:41:01 +00:00
{
int32_t k ;
if ( handleevents ( ) )
quitevent = 0 ;
tilescreen_drawrest ( iSelected , showmsg ) ;
k = ( mousex | | mousey | | mouseb ) ;
if ( ! k )
2014-03-22 09:25:15 +00:00
for ( i = 0 ; i < ( signed ) ARRAY_SIZE ( keystatus ) ; i + + )
2011-03-23 17:41:01 +00:00
if ( keystatus [ i ] )
{
k = 1 ;
break ;
}
if ( k )
{
enddrawing ( ) ;
showframe ( 1 ) ;
2011-11-17 21:10:04 +00:00
# ifdef USE_OPENGL
2013-05-17 03:44:09 +00:00
if ( getrendermode ( ) > = REND_POLYMOST & & lazyselector )
2011-11-17 21:10:04 +00:00
bglDrawBuffer ( GL_BACK ) ;
# endif
2011-03-23 17:41:01 +00:00
return 1 ;
}
2011-04-09 13:27:08 +00:00
enddrawing ( ) ;
showframe ( 1 ) ;
begindrawing ( ) ;
2011-03-23 17:41:01 +00:00
}
}
2011-03-07 16:30:06 +00:00
}
2011-03-23 17:41:01 +00:00
tilescreen_drawrest ( iSelected , showmsg ) ;
2010-08-16 13:56:49 +00:00
2013-05-30 09:13:32 +00:00
if ( getrendermode ( ) > = REND_POLYMOST & & in3dmode ( ) & & lazyselector )
2011-03-23 17:41:01 +00:00
{
2011-05-15 22:37:24 +00:00
if ( runi = = 0 )
2011-03-23 17:41:01 +00:00
{
enddrawing ( ) ;
showframe ( 1 ) ;
begindrawing ( ) ;
2011-05-15 22:37:24 +00:00
runi = 1 ;
2011-03-23 17:41:01 +00:00
goto restart ;
}
}
2008-05-16 19:51:38 +00:00
2009-07-04 09:28:21 +00:00
enddrawing ( ) ;
showframe ( 1 ) ;
2007-04-17 05:54:12 +00:00
2011-11-17 21:10:04 +00:00
# ifdef USE_OPENGL
2013-05-17 03:44:09 +00:00
if ( getrendermode ( ) > = REND_POLYMOST & & lazyselector )
2012-01-20 22:11:55 +00:00
bglDrawBuffer ( GL_BACK ) ;
2011-11-17 21:10:04 +00:00
# endif
2011-03-23 17:41:01 +00:00
return 0 ;
2007-04-17 05:54:12 +00:00
}
2010-08-16 13:56:49 +00:00
# undef TMPERRMSG_SHOW
# undef TMPERRMSG_PRINT
# undef TMPERRMSG_RETURN
2008-05-16 19:51:38 +00:00
# define WIND1X 3
2008-05-17 01:37:17 +00:00
# define WIND1Y 150
2011-02-15 21:02:43 +00:00
2016-01-11 05:06:10 +00:00
static char const * tileinfo_colorstr = " " ;
2012-12-20 12:04:39 +00:00
2011-02-15 21:02:43 +00:00
static void tileinfo_doprint ( int32_t x , int32_t y , char * buf , const char * label , int32_t value , int32_t pos )
{
int32_t small = ( xdimgame < = 640 ) , i = ydimgame > > 6 ;
2012-12-20 12:04:39 +00:00
Bsprintf ( buf , " %s:%s%4d " , label , tileinfo_colorstr , value ) ;
2011-02-15 21:02:43 +00:00
printext256 ( x + 2 , y + 2 + i * pos , 0 , - 1 , buf , small ) ;
printext256 ( x , y + i * pos , whitecol , - 1 , buf , small ) ;
}
2011-04-14 20:48:08 +00:00
// flags: 1:draw asterisk for lotag
// 2:draw asterisk for extra
2012-12-20 12:04:39 +00:00
// 4:print bottom-swapped wall members colored
2011-04-14 20:48:08 +00:00
static void drawtileinfo ( const 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 , uint32_t flags )
2008-05-16 19:51:38 +00:00
{
char buf [ 64 ] ;
2011-02-15 21:02:43 +00:00
int32_t small = ( xdimgame < = 640 ) ;
2008-05-16 19:51:38 +00:00
2014-09-30 04:14:21 +00:00
if ( tilesiz [ picnum ] . x > 0 & & tilesiz [ picnum ] . y > 0 )
2012-06-13 23:13:28 +00:00
{
int32_t x1 = x + 80 ;
if ( small )
x1 / = 2 ;
2010-05-18 05:14:17 +00:00
2012-11-15 14:28:41 +00:00
x1 = ( int32_t ) ( x1 * 320.0 / xdimgame ) ;
2015-05-10 10:55:30 +00:00
const double scalediv = max ( tilesiz [ picnum ] . x , tilesiz [ picnum ] . y ) / 24.0 ;
const int32_t scale = ( int32_t ) ( 65536.0 / scalediv ) ;
2009-09-12 23:03:15 +00:00
2015-05-10 10:55:30 +00:00
const int32_t oviewingrange = viewingrange , oyxaspect = yxaspect ;
setaspect ( 65536 , divscale16 ( ydim * 320 , xdim * 200 ) ) ;
2012-06-13 23:13:28 +00:00
// +1024: prevents rotatesprite from setting aspect itself
rotatesprite_fs ( ( x1 + 13 ) < < 16 , ( y + 11 ) < < 16 , scale , 0 , picnum , shade , pal , 2 + 1024 ) ;
setaspect ( oviewingrange , oyxaspect ) ;
}
2008-05-16 19:51:38 +00:00
2012-11-15 14:28:41 +00:00
x = ( int32_t ) ( x * xdimgame / 320.0 ) ;
y = ( int32_t ) ( y * ydimgame / 200.0 ) ;
2010-05-18 05:14:17 +00:00
2008-05-16 19:51:38 +00:00
begindrawing ( ) ;
2010-05-18 05:14:17 +00:00
printext256 ( x + 2 , y + 2 , 0 , - 1 , title , small ) ;
2015-07-20 20:25:21 +00:00
printext256 ( x , y , editorcolors [ 14 ] , - 1 , title , small ) ;
2010-05-18 05:14:17 +00:00
2012-12-20 12:04:39 +00:00
if ( flags & 4 )
2015-07-22 02:06:23 +00:00
{
Bsprintf ( tempbuf , " ^%d " , editorcolors [ 14 ] ) ;
tileinfo_colorstr = tempbuf ;
}
2015-07-20 20:25:21 +00:00
2011-02-15 21:02:43 +00:00
tileinfo_doprint ( x , y , buf , " Pic " , picnum , 1 ) ;
tileinfo_doprint ( x , y , buf , " Shd " , shade , 2 ) ;
tileinfo_doprint ( x , y , buf , " Pal " , pal , 3 ) ;
tileinfo_doprint ( x , y , buf , " Cst " , cstat , 4 ) ;
2012-12-20 12:04:39 +00:00
tileinfo_colorstr = " " ;
2011-04-14 20:48:08 +00:00
tileinfo_doprint ( x , y , buf , ( flags & 1 ) ? " Lo* " : " Lot " , lotag , 5 ) ;
2011-02-15 21:02:43 +00:00
tileinfo_doprint ( x , y , buf , " Hit " , hitag , 6 ) ;
2011-04-14 20:48:08 +00:00
tileinfo_doprint ( x , y , buf , ( flags & 2 ) ? " Ex* " : " Ext " , extra , 7 ) ;
2011-02-15 21:02:43 +00:00
2008-05-16 19:51:38 +00:00
enddrawing ( ) ;
}
2010-05-18 05:14: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-04-26 05:57:42 +00:00
static inline void getnumber_doint32 ( int32_t * ptr , int32_t num )
2008-09-03 11:59:54 +00:00
{
2009-04-26 05:57:42 +00:00
* ptr = ( int32_t ) num ;
2008-09-03 11:59:54 +00:00
}
2009-09-09 07:19:14 +00:00
static inline void getnumber_doint64 ( int64_t * ptr , int32_t num )
2008-09-03 11:59:54 +00:00
{
2009-09-09 07:19:14 +00:00
* ptr = ( int64_t ) num ;
2008-09-03 11:59:54 +00:00
}
2011-02-21 23:08:21 +00:00
static void getnumberptr256 ( const 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 ;
2011-04-17 17:01:20 +00:00
int32_t danum = 0 , oldnum ;
uint8_t flags = ( sign > > 1 ) & 3 ;
sign & = 1 ;
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 :
2011-10-17 18:41:17 +00:00
danum = sign ? * ( int8_t * ) num : * ( uint8_t * ) num ;
2008-09-03 11:59:54 +00:00
break ;
case 2 :
2011-10-17 18:41:17 +00:00
danum = sign ? * ( int16_t * ) num : * ( uint16_t * ) num ;
2008-09-03 11:59:54 +00:00
break ;
case 4 :
2009-04-26 05:57:42 +00:00
danum = * ( int32_t * ) num ;
2008-09-03 11:59:54 +00:00
break ;
case 8 :
2009-09-09 07:19:14 +00:00
danum = * ( int64_t * ) num ;
2008-09-03 11:59:54 +00:00
break ;
}
oldnum = danum ;
bflushchars ( ) ;
while ( keystatus [ 0x1 ] = = 0 )
{
if ( handleevents ( ) )
2010-05-18 05:14:17 +00:00
quitevent = 0 ;
2008-09-03 11:59:54 +00:00
2012-02-04 21:33:52 +00:00
M32_DrawRoomsAndMasks ( ) ;
2008-09-03 11:59:54 +00:00
ch = bgetchar ( ) ;
if ( keystatus [ 0x1 ] ) break ;
clearkeys ( ) ;
2008-09-03 14:02:42 +00:00
mouseb = 0 ;
searchx = osearchx ;
searchy = osearchy ;
2013-12-20 07:24:09 +00:00
inputchecked = 1 ;
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 ) ;
2011-04-17 17:01:20 +00:00
if ( getnumber_internal1 ( ch , & danum , maxnumber , sign ) | |
getnumber_autocomplete ( namestart , ch , & danum , flags ) )
2008-09-03 11:59:54 +00:00
{
2009-09-16 22:24:24 +00:00
if ( danum ! = oldnum )
asksave = 1 ;
2008-09-03 11:59:54 +00:00
oldnum = danum ;
break ;
}
2011-04-17 17:01:20 +00:00
2008-09-03 13:23:34 +00:00
switch ( bytes )
2008-09-03 11:59:54 +00:00
{
case 1 :
2012-11-15 14:28:36 +00:00
getnumber_dochar ( ( char * ) num , danum ) ;
2008-09-03 11:59:54 +00:00
break ;
case 2 :
2012-11-15 14:28:36 +00:00
getnumber_doint16_t ( ( int16_t * ) num , danum ) ;
2008-09-03 11:59:54 +00:00
break ;
case 4 :
2012-11-15 14:28:36 +00:00
getnumber_doint32 ( ( int32_t * ) num , danum ) ;
2008-09-03 11:59:54 +00:00
break ;
case 8 :
2012-11-15 14:28:36 +00:00
getnumber_doint64 ( ( int64_t * ) num , danum ) ;
2008-09-03 11:59:54 +00:00
break ;
}
}
2011-04-17 17:01:20 +00:00
2008-09-03 11:59:54 +00:00
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 :
2012-11-15 14:28:36 +00:00
getnumber_dochar ( ( char * ) num , oldnum ) ;
2008-09-03 11:59:54 +00:00
break ;
case 2 :
2012-11-15 14:28:36 +00:00
getnumber_doint16_t ( ( int16_t * ) num , oldnum ) ;
2008-09-03 11:59:54 +00:00
break ;
case 4 :
2012-11-15 14:28:36 +00:00
getnumber_doint32 ( ( int32_t * ) num , oldnum ) ;
2008-09-03 11:59:54 +00:00
break ;
case 8 :
2012-11-15 14:28:36 +00:00
getnumber_doint64 ( ( int64_t * ) num , oldnum ) ;
2008-09-03 11:59:54 +00:00
break ;
}
}
2010-02-13 21:46:42 +00:00
#if 0
2009-09-09 07:19:14 +00:00
int64_t ldistsqr ( spritetype * s1 , spritetype * s2 )
2008-09-05 23:09:43 +00:00
{
2009-09-09 07:19:14 +00:00
return ( ( ( int64_t ) ( s2 - > x - s1 - > x ) ) * ( ( int64_t ) ( s2 - > x - s1 - > x ) ) +
( ( int64_t ) ( s2 - > y - s1 - > y ) ) * ( ( int64_t ) ( s2 - > y - s1 - > y ) ) ) ;
2008-09-05 23:09:43 +00:00
}
2010-02-13 21:46:42 +00:00
# endif
2008-09-05 23:09:43 +00:00
2010-02-13 21:46:42 +00:00
static void TextEntryMode ( 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 | |
2009-07-04 09:28:21 +00:00
sprite [ startspr ] . statnum = = MAXSTATUS )
2008-09-06 06:22:31 +00:00
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 )
2014-09-30 04:14:21 +00:00
spcgap [ i ] = 3 * tilesiz [ t ] . x / 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 ;
2012-11-17 19:46:28 +00:00
sprite [ startspr ] . xoffset = - picanm [ t ] . xofs ;
sprite [ startspr ] . yoffset = - picanm [ t ] . yofs ;
2008-09-05 23:09:43 +00:00
2014-05-30 00:02:19 +00:00
spritenums = ( int16_t * ) Xmalloc ( stackallocsize * sizeof ( int16_t ) ) ;
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 ;
sp = & sprite [ cursor ] ;
Bmemcpy ( sp , & sprite [ startspr ] , sizeof ( spritetype ) ) ;
sp - > yoffset = 0 ;
sp - > picnum = SMALLFNTCURSOR ;
2014-09-30 04:14:21 +00:00
sp - > xrepeat = clamp ( sp - > xrepeat / tilesiz [ sp - > picnum ] . x , 2 , 255 ) ;
sp - > yrepeat = clamp ( ( sp - > yrepeat * tilesiz [ sprite [ startspr ] . picnum ] . y ) / tilesiz [ sp - > picnum ] . y , 4 , 255 ) ;
2008-10-09 21:09:16 +00:00
sp - > pal = 0 ;
sp - > cstat = 18 ;
2008-09-05 23:09:43 +00:00
bflushchars ( ) ;
while ( keystatus [ 0x1 ] = = 0 )
{
if ( handleevents ( ) )
2010-05-18 05:14:17 +00:00
quitevent = 0 ;
2008-09-05 23:09:43 +00:00
2008-09-06 06:22:31 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( UP ) ) // vertical gap in pixels (32 x-units)
vgap + = ( vgap < 255 ) ;
2008-09-06 06:22:31 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( DOWN ) )
vgap - = ( vgap > 0 ) ;
2008-09-06 06:22:31 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( RIGHT ) ) // horizontal gap in half pixels
hgap + = ( hgap < 255 ) ;
2008-09-06 06:22:31 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( LEFT ) )
hgap - = ( hgap > 0 ) ;
if ( PRESSED_KEYSC ( INSERT ) ) // space gap in half pixels
spcgap [ alphidx ] + = ( spcgap [ alphidx ] < 255 ) ;
if ( PRESSED_KEYSC ( DELETE ) )
spcgap [ alphidx ] - = ( spcgap [ alphidx ] > 1 ) ;
if ( PRESSED_KEYSC ( HOME ) ) // shade
sprite [ linebegspr ] . shade + = ( sprite [ linebegspr ] . shade < 127 ) ;
if ( PRESSED_KEYSC ( END ) )
sprite [ linebegspr ] . shade - = ( sprite [ linebegspr ] . shade > - 128 ) ;
if ( PRESSED_KEYSC ( PGUP ) ) // pal
sprite [ linebegspr ] . pal + = ( sprite [ linebegspr ] . pal < 255 ) ;
if ( PRESSED_KEYSC ( PGDN ) )
sprite [ linebegspr ] . pal - = ( sprite [ linebegspr ] . pal > 0 ) ;
2008-09-05 23:09:43 +00:00
2012-02-04 21:33:52 +00:00
M32_DrawRoomsAndMasks ( ) ;
2008-09-05 23:09:43 +00:00
ch = bgetchar ( ) ;
if ( keystatus [ 0x1 ] ) break ;
clearkeys ( ) ;
mouseb = 0 ;
searchx = osearchx ;
searchy = osearchy ;
2013-12-20 07:24:09 +00:00
inputchecked = 1 ;
2008-09-05 23:09:43 +00:00
ExtCheckKeys ( ) ;
2015-07-20 20:25:21 +00:00
Bsprintf ( tempbuf , " ^%dText entry mode.^%d Navigation keys change vars. " , editorcolors [ 10 ] , whitecol ) ;
printmessage256 ( 0 , 0 , tempbuf ) ;
2014-11-25 21:08:58 +00:00
Bsprintf ( buffer , " Hgap=%d, Vgap=%d, SPCgap=%d, Shd=%d, Pal=%d " ,
2012-11-26 08:26:04 +00:00
hgap , vgap , spcgap [ alphidx ] , TrackerCast ( sprite [ linebegspr ] . shade ) , TrackerCast ( sprite [ linebegspr ] . pal ) ) ;
2008-09-05 23:09:43 +00:00
printmessage256 ( 0 , 9 , buffer ) ;
showframe ( 1 ) ;
2009-06-28 20:23:12 +00:00
// ---
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
2014-09-30 04:14:21 +00:00
j = sp - > xrepeat * ( hgap + tilesiz [ sp - > picnum ] . x + 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 ] ;
2014-09-30 04:14:21 +00:00
j = sp - > xrepeat * ( hgap + tilesiz [ sp - > picnum ] . x + tilesiz [ t ] . x ) ;
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 ) ;
2012-03-14 22:30:24 +00:00
if ( Numsprites < MAXSPRITES & & sect > = 0 )
2008-09-06 06:22:31 +00:00
{
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 ) ) ;
2010-11-27 22:12:24 +00:00
sprite [ i ] . sectnum = sect ;
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 ;
2012-11-17 19:46:28 +00:00
sprite [ i ] . xoffset = - picanm [ t ] . xofs ;
sprite [ i ] . yoffset = - picanm [ t ] . yofs ;
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
asksave = 1 ;
2008-09-14 14:47:32 +00:00
if ( numletters > = stackallocsize )
{
stackallocsize * = 2 ;
2014-05-30 00:02:19 +00:00
spritenums = ( int16_t * ) Xrealloc ( spritenums , stackallocsize * sizeof ( int16_t ) ) ;
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
}
2012-01-20 22:11:55 +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-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 ) ;
2012-03-14 22:30:24 +00:00
2008-09-14 14:47:32 +00:00
curspr = linebegspr ;
2008-10-09 21:09:16 +00:00
asksave = 1 ;
}
}
else
{
2014-09-30 04:14:21 +00:00
sprite [ linebegspr ] . z - = ( ( sprite [ linebegspr ] . yrepeat * ( vgap + tilesiz [ basetile ] . y ) ) < < 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
{
2014-09-30 04:14:21 +00:00
sprite [ linebegspr ] . z + = ( ( sprite [ linebegspr ] . yrepeat * ( vgap + tilesiz [ basetile ] . y ) ) < < 2 ) ;
2008-09-06 06:22:31 +00:00
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 ) ;
2014-05-30 00:02:19 +00:00
Bfree ( spritenums ) ;
2008-09-14 14:47:32 +00:00
2008-09-05 23:09:43 +00:00
clearkeys ( ) ;
lockclock = totalclock ; //Reset timing
}
2010-08-26 13:50:09 +00:00
static void mouseaction_movesprites ( int32_t * sumxvect , int32_t * sumyvect , int32_t yangofs , int32_t mousexory )
{
int32_t xvect , yvect , daxvect , dayvect , ii , spi ;
int32_t units , gridlock = ( eitherCTRL & & grid > 0 & & grid < 9 ) ;
spritetype * sp = & sprite [ searchwall ] ;
int16_t tsect = sp - > sectnum ;
vec3_t tvec = { sp - > x , sp - > y , sp - > z } ;
xvect = - ( ( mousexory * ( int32_t ) sintable [ ( ang + yangofs + 512 ) & 2047 ] ) < < 3 ) ;
yvect = - ( ( mousexory * ( int32_t ) sintable [ ( ang + yangofs ) & 2047 ] ) < < 3 ) ;
if ( gridlock )
{
units = 1 < < ( 11 - grid ) ;
if ( ( tvec . x & ( units - 1 ) ) | | ( tvec . y & ( units - 1 ) ) )
{
daxvect = ( ( tvec . x & ~ ( units - 1 ) ) - tvec . x ) < < 14 ;
dayvect = ( ( tvec . y & ~ ( units - 1 ) ) - tvec . y ) < < 14 ;
}
else
{
units < < = 14 ;
* sumxvect + = xvect ;
* sumyvect + = yvect ;
if ( klabs ( * sumxvect ) > = units )
{
daxvect = ( ( * sumxvect ) / units ) * units ;
* sumxvect % = units ;
}
else
daxvect = 0 ;
if ( klabs ( * sumyvect ) > = units )
{
dayvect = ( ( * sumyvect ) / units ) * units ;
* sumyvect % = units ;
}
else
dayvect = 0 ;
}
}
else
{
daxvect = xvect ;
dayvect = yvect ;
}
if ( highlightcnt < = 0 | | ( show2dsprite [ searchwall > > 3 ] & ( 1 < < ( searchwall & 7 ) ) ) = = 0 )
{
2010-10-17 14:49:39 +00:00
clipmove ( & tvec , & tsect , daxvect , dayvect , sp - > clipdist , 64 < < 4 , 64 < < 4 , spnoclip ? 1 : CLIPMASK0 ) ;
2010-08-26 13:50:09 +00:00
setsprite ( searchwall , & tvec ) ;
}
else
{
xvect = daxvect ;
yvect = dayvect ;
2011-03-02 21:21:47 +00:00
// test run
2010-08-26 13:50:09 +00:00
for ( ii = 0 ; ii < highlightcnt ; ii + + )
if ( highlight [ ii ] & 16384 )
{
spi = highlight [ ii ] & 16383 ;
Bmemcpy ( & tvec , & sprite [ spi ] , sizeof ( vec3_t ) ) ;
tsect = sprite [ spi ] . sectnum ;
clipmove ( & tvec , & tsect , xvect , yvect , 128 , 64 < < 4 , 64 < < 4 , spnoclip ? 1 : CLIPMASK0 ) ;
xvect = ( tvec . x - sprite [ spi ] . x ) < < 14 ;
yvect = ( tvec . y - sprite [ spi ] . y ) < < 14 ;
}
2011-03-02 21:21:47 +00:00
// the real thing
2010-08-26 13:50:09 +00:00
for ( ii = 0 ; ii < highlightcnt ; ii + + )
if ( highlight [ ii ] & 16384 )
{
spi = highlight [ ii ] & 16383 ;
Bmemcpy ( & tvec , & sprite [ spi ] , sizeof ( vec3_t ) ) ;
tsect = sprite [ spi ] . sectnum ;
clipmove ( & tvec , & tsect , xvect , yvect , 128 , 64 < < 4 , 64 < < 4 , spnoclip ? 1 : CLIPMASK0 ) ;
setsprite ( spi , & tvec ) ;
}
}
}
2011-05-07 18:23:34 +00:00
static int32_t addtobyte ( int8_t * byte , int32_t num )
{
int32_t onum = * byte , clamped = 0 ;
if ( onum + num ! = ( int8_t ) ( onum + num ) )
clamped = 1 ;
if ( ! clamped )
* byte = ( onum + num ) ;
return clamped ;
}
2012-06-01 20:09:00 +00:00
static void toggle_sprite_alignment ( int32_t spritenum )
{
static const char * aligntype [ 4 ] = { " view " , " wall " , " floor " , " ??? " } ;
int32_t i = sprite [ spritenum ] . cstat ;
if ( ( i & 48 ) < 32 )
i + = 16 ;
else
i & = ~ 48 ;
sprite [ spritenum ] . cstat = i ;
message ( " Sprite %d now %s aligned " , spritenum , aligntype [ ( i & 48 ) / 16 ] ) ;
asksave = 1 ;
}
2012-06-01 20:09:09 +00:00
static void toggle_cf_flipping ( int32_t sectnum , int32_t floorp )
{
static const int8_t next3 [ 8 ] = { 6 , 7 , 4 , 5 , 0 , 1 , 3 , 2 } ; // 0->6->3->5->1->7->2->4->0
static const int8_t prev3 [ 8 ] = { 4 , 5 , 7 , 6 , 2 , 3 , 0 , 1 } ; // 0<-6<-3<-5<-1<-7<-2<-4<-0
static const int16_t orient [ 8 ] = { 360 , - 360 , - 180 , 180 , - 270 , 270 , 90 , - 90 } ;
2013-05-30 09:13:34 +00:00
const int32_t search = floorp ? SEARCH_FLOOR : SEARCH_CEILING ;
uint16_t * const stat = & SECTORFLD ( sectnum , stat , floorp ) ;
2012-06-01 20:09:09 +00:00
int32_t i = * stat ;
i = ( i & 0x4 ) + ( ( i > > 4 ) & 3 ) ;
i = eitherSHIFT ? prev3 [ i ] : next3 [ i ] ;
2013-05-30 09:13:34 +00:00
message ( " Sector %d %s flip %d deg%s " , sectnum , typestr [ search ] ,
2012-06-01 20:09:09 +00:00
klabs ( orient [ i ] ) % 360 , orient [ i ] < 0 ? " mirrored " : " " ) ;
i = ( i & 0x4 ) + ( ( i & 3 ) < < 4 ) ;
* stat & = ~ 0x34 ;
* stat | = i ;
asksave = 1 ;
}
2012-06-01 20:09:19 +00:00
// vec2_t initializer from a 1st point of wall
# define WALLVEC_INITIALIZER(w) { POINT2(w).x-wall[w].x, POINT2(w).y-wall[w].y }
static int64_t lldotv2 ( const vec2_t * v1 , const vec2_t * v2 )
{
return ( int64_t ) v1 - > x * v2 - > x + ( int64_t ) v1 - > y * v2 - > y ;
}
2013-04-09 17:35:11 +00:00
# ifdef NEW_MAP_FORMAT
# define YAX_BIT_PROTECT 0
# else
# define YAX_BIT_PROTECT YAX_BIT
# endif
2012-06-01 20:09:00 +00:00
////////// KEY PRESS HANDLER IN 3D MODE //////////
2006-12-10 06:49:01 +00:00
static void Keys3d ( void )
2006-04-13 20:47:06 +00:00
{
2010-07-05 21:38:13 +00:00
int32_t i = 0 , changedir , tsign ; // ,count,nexti
2009-01-09 09:29:17 +00:00
int32_t j , k , tempint = 0 , hiz , loz ;
int32_t hihit , lohit ;
2010-05-18 05:14:17 +00:00
char smooshyalign = 0 , repeatpanalign = 0 ; //, buffer[80];
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 */
2009-03-17 21:57:30 +00:00
if ( g_numsounds > 0 & & AmbienceToggle )
{
M32_MoveFX ( ) ;
2010-05-02 23:27:30 +00:00
S_Update ( ) ;
2009-03-17 21:57:30 +00:00
}
2008-08-28 15:04:16 +00:00
if ( usedcount & & ! helpon )
{
2010-05-18 05:14:17 +00:00
#if 0
if ( ! AIMING_AT_SPRITE )
2008-08-28 15:04:16 +00:00
{
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 + + ;
}
}
2010-05-18 05:14:17 +00:00
else
2008-08-28 15:04:16 +00:00
{
count = 0 ;
statnum = 0 ;
2010-05-18 05:14:17 +00:00
2008-08-28 15:04:16 +00:00
i = headspritestat [ statnum ] ;
while ( i ! = - 1 )
{
nexti = nextspritestat [ i ] ;
if ( sprite [ i ] . picnum = = temppicnum ) count + + ;
i = nexti ;
}
}
2010-05-18 05:14:17 +00:00
# endif
2011-04-14 20:48:08 +00:00
drawtileinfo ( " Clipboard " , 3 , 124 , temppicnum , tempshade , temppal , tempcstat , templotag , temphitag , tempextra , 0 ) ;
2008-08-28 15:04:16 +00:00
} // end if usedcount
2010-06-07 09:03:16 +00:00
if ( searchsector > - 1 & & searchsector < numsectors )
2008-08-28 15:04:16 +00:00
{
char lines [ 8 ] [ 64 ] ;
2012-12-20 12:04:39 +00:00
int32_t num = 0 ;
2011-04-14 20:48:08 +00:00
int32_t x , y , flags = 0 ;
2008-08-28 15:04:16 +00:00
if ( infobox & 1 )
{
2012-12-20 12:04:39 +00:00
int32_t height2 = sector [ searchsector ] . floorz - sector [ searchsector ] . ceilingz ;
2010-05-18 05:14:17 +00:00
2008-08-28 15:04:16 +00:00
switch ( searchstat )
{
2010-02-13 21:46:42 +00:00
case SEARCH_WALL :
case SEARCH_MASKWALL :
2012-12-20 12:04:39 +00:00
{
int32_t dist , height1 = 0 , height3 = 0 ;
const int32_t w = SELECT_WALL ( ) ;
const int32_t swappedbot = ( int32_t ) ( w ! = searchwall ) ;
flags | = ( swappedbot < < 2 ) ;
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-04-14 20:48:08 +00:00
flags | = ( yax_getnextwall ( searchwall , YAX_CEILING ) > = 0 ) + 2 * ( yax_getnextwall ( searchwall , YAX_FLOOR ) > = 0 ) ;
# endif
2015-07-17 00:12:48 +00:00
drawtileinfo ( " Selected " , WIND1X , WIND1Y ,
2010-05-18 05:14:17 +00:00
AIMING_AT_WALL ? wall [ w ] . picnum : wall [ w ] . overpicnum ,
2012-12-20 12:04:39 +00:00
wall [ w ] . shade , wall [ w ] . pal , wall [ w ] . cstat ,
wall [ searchwall ] . lotag , wall [ searchwall ] . hitag , wall [ searchwall ] . extra , flags ) ;
2010-05-18 05:14:17 +00:00
dist = wallength ( searchwall ) ;
2010-05-12 00:53:35 +00:00
if ( wall [ searchwall ] . nextsector > = 0 & & wall [ searchwall ] . nextsector < numsectors )
2008-08-28 15:04:16 +00:00
{
2010-05-18 05:14:17 +00:00
int32_t nextsect = wall [ searchwall ] . nextsector ;
height1 = sector [ searchsector ] . floorz - sector [ nextsect ] . floorz ;
height2 = sector [ nextsect ] . floorz - sector [ nextsect ] . ceilingz ;
height3 = sector [ nextsect ] . ceilingz - sector [ searchsector ] . ceilingz ;
2008-08-28 15:04:16 +00:00
}
2010-05-18 05:14:17 +00:00
2015-07-20 20:25:21 +00:00
Bsprintf ( lines [ num + + ] , " Panning:^%d %d, %d " , swappedbot ? editorcolors [ 14 ] : whitecol ,
2012-12-20 12:04:39 +00:00
TrackerCast ( wall [ w ] . xpanning ) , TrackerCast ( wall [ w ] . ypanning ) ) ;
2014-11-25 21:08:58 +00:00
Bsprintf ( lines [ num + + ] , " Repeat: %d, %d " , TrackerCast ( wall [ searchwall ] . xrepeat ) , TrackerCast ( wall [ searchwall ] . yrepeat ) ) ;
Bsprintf ( lines [ num + + ] , " Overpic: %d " , TrackerCast ( wall [ searchwall ] . overpicnum ) ) ;
2008-08-28 15:04:16 +00:00
lines [ num + + ] [ 0 ] = 0 ;
2010-05-18 05:14:17 +00:00
2008-08-28 15:04:16 +00:00
if ( getmessageleng )
break ;
2010-05-18 05:14:17 +00:00
2012-12-20 12:04:39 +00:00
if ( searchwall ! = searchbottomwall )
2015-07-20 20:25:21 +00:00
Bsprintf ( lines [ num + + ] , " ^%dWall %d ->^%d %d " , editorcolors [ 10 ] , searchwall , editorcolors [ 14 ] , searchbottomwall ) ;
2012-12-20 12:04:39 +00:00
else
2015-07-20 20:25:21 +00:00
Bsprintf ( lines [ num + + ] , " ^%dWall %d " , editorcolors [ 10 ] , searchwall ) ;
2010-05-18 05:14:17 +00:00
2008-08-28 15:04:16 +00:00
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 ;
2012-12-20 12:04:39 +00:00
}
2008-08-28 15:04:16 +00:00
2010-05-18 05:14:17 +00:00
case SEARCH_CEILING :
2010-02-13 21:46:42 +00:00
case SEARCH_FLOOR :
2015-07-17 00:12:48 +00:00
drawtileinfo ( " Selected " , WIND1X , WIND1Y , AIMED_CEILINGFLOOR ( picnum ) , AIMED_CEILINGFLOOR ( shade ) ,
2010-05-18 05:14:17 +00:00
AIMED_CEILINGFLOOR ( pal ) , AIMED_CEILINGFLOOR ( stat ) ,
2011-04-14 20:48:08 +00:00
sector [ searchsector ] . lotag , sector [ searchsector ] . hitag , sector [ searchsector ] . extra , 0 ) ;
2008-08-28 15:04:16 +00:00
2011-03-23 17:41:01 +00:00
{
int32_t xp = AIMED_CEILINGFLOOR ( xpanning ) , yp = AIMED_CEILINGFLOOR ( ypanning ) ;
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-03-23 17:41:01 +00:00
int32_t notextended = 1 ;
if ( yax_getbunch ( searchsector , AIMING_AT_FLOOR ) > = 0 )
2011-07-09 17:36:02 +00:00
notextended = 0 ;
Bsprintf ( lines [ num + + ] , " Panning: %d%s, %d " , xp , notextended ? " " : " * " , yp ) ;
2011-03-23 17:41:01 +00:00
# else
Bsprintf ( lines [ num + + ] , " Panning: %d, %d " , xp , yp ) ;
# endif
}
2010-05-18 05:14:17 +00:00
Bsprintf ( lines [ num + + ] , " %sZ: %d " , Typestr [ searchstat ] , AIMED_CEILINGFLOOR ( z ) ) ;
Bsprintf ( lines [ num + + ] , " Slope: %d " , AIMED_CEILINGFLOOR ( heinum ) ) ;
2008-08-28 15:04:16 +00:00
lines [ num + + ] [ 0 ] = 0 ;
2010-05-18 05:14:17 +00:00
2008-08-28 15:04:16 +00:00
if ( getmessageleng )
break ;
2010-05-18 05:14:17 +00:00
2015-07-20 20:25:21 +00:00
Bsprintf ( lines [ num + + ] , " ^%dSector %d^%d %s, Lotag:%s " , editorcolors [ 10 ] , searchsector , whitecol , typestr [ searchstat ] , ExtGetSectorCaption ( searchsector ) ) ;
2014-11-25 21:08:58 +00:00
Bsprintf ( lines [ num + + ] , " Height: %d, Visibility:%d " , height2 , TrackerCast ( sector [ searchsector ] . visibility ) ) ;
2008-08-28 15:04:16 +00:00
break ;
2010-05-18 05:14:17 +00:00
2010-02-13 21:46:42 +00:00
case SEARCH_SPRITE :
2015-07-17 00:12:48 +00:00
drawtileinfo ( " Selected " , WIND1X , WIND1Y , sprite [ searchwall ] . picnum , sprite [ searchwall ] . shade ,
2010-08-02 08:13:51 +00:00
sprite [ searchwall ] . pal , sprite [ searchwall ] . cstat , sprite [ searchwall ] . lotag ,
2011-04-14 20:48:08 +00:00
sprite [ searchwall ] . hitag , sprite [ searchwall ] . extra , 0 ) ;
2008-08-28 15:04:16 +00:00
2014-11-25 21:08:58 +00:00
Bsprintf ( lines [ num + + ] , " Repeat: %d,%d " ,
2012-11-26 08:26:04 +00:00
TrackerCast ( sprite [ searchwall ] . xrepeat ) , TrackerCast ( sprite [ searchwall ] . yrepeat ) ) ;
2014-11-25 21:08:58 +00:00
Bsprintf ( lines [ num + + ] , " PosXY: %d,%d%s " ,
2012-11-26 08:26:04 +00:00
TrackerCast ( sprite [ searchwall ] . x ) , TrackerCast ( sprite [ searchwall ] . y ) ,
2011-03-07 16:30:06 +00:00
sprite [ searchwall ] . xoffset | sprite [ searchwall ] . yoffset ? " ^251* " : " " ) ;
2014-11-25 21:08:58 +00:00
Bsprintf ( lines [ num + + ] , " PosZ: " " %d " , TrackerCast ( sprite [ searchwall ] . z ) ) ; // prevents tab character
2008-08-28 15:04:16 +00:00
lines [ num + + ] [ 0 ] = 0 ;
if ( getmessageleng )
break ;
2010-05-18 05:14:17 +00:00
2011-03-05 12:59:27 +00:00
if ( sprite [ searchwall ] . picnum < 0 | | sprite [ searchwall ] . picnum > = MAXTILES )
break ;
2010-05-18 05:14:17 +00:00
if ( names [ sprite [ searchwall ] . picnum ] [ 0 ] )
2008-08-28 15:04:16 +00:00
{
if ( sprite [ searchwall ] . picnum = = SECTOREFFECTOR )
2015-07-20 20:25:21 +00:00
Bsprintf ( lines [ num + + ] , " ^%dSprite %d^%d %s " , editorcolors [ 10 ] , searchwall , whitecol , SectorEffectorText ( searchwall ) ) ;
2010-05-18 05:14:17 +00:00
else
2015-07-20 20:25:21 +00:00
Bsprintf ( lines [ num + + ] , " ^%dSprite %d^%d %s " , editorcolors [ 10 ] , searchwall , whitecol , names [ sprite [ searchwall ] . picnum ] ) ;
2008-08-28 15:04:16 +00:00
}
2015-07-20 20:25:21 +00:00
else Bsprintf ( lines [ num + + ] , " ^%dSprite %d^%d, picnum %d " , editorcolors [ 10 ] , searchwall , whitecol , TrackerCast ( sprite [ searchwall ] . picnum ) ) ;
2010-05-18 05:14:17 +00:00
Bsprintf ( lines [ num + + ] , " Elevation:%d " ,
getflorzofslope ( searchsector , sprite [ searchwall ] . x , sprite [ searchwall ] . y ) - sprite [ searchwall ] . z ) ;
2008-08-28 15:04:16 +00:00
break ;
}
}
2010-05-18 05:14:17 +00:00
2012-11-15 14:28:41 +00:00
x = ( int32_t ) ( WIND1X * ( xdimgame / 320. ) ) ;
y = ( int32_t ) ( WIND1Y * ( ydimgame / 200. ) ) ;
2010-05-18 05:14:17 +00:00
y + = ( ydimgame > > 6 ) * 8 ;
2015-07-08 03:34:42 +00:00
if ( getmessageleng & & ! m32_is2d3dmode ( ) )
2008-08-28 15:04:16 +00:00
{
while ( num < 4 )
lines [ num + + ] [ 0 ] = 0 ;
2015-07-20 20:25:21 +00:00
Bsprintf ( lines [ num + + ] , " ^%d%s " , editorcolors [ 10 ] , getmessage ) ;
2008-08-28 15:04:16 +00:00
}
2010-05-18 05:14:17 +00:00
2008-08-28 15:04:16 +00:00
begindrawing ( ) ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < num ; i + + )
2008-08-28 15:04:16 +00:00
{
2010-05-18 05:14:17 +00:00
printext256 ( x + 2 , y + 2 , 0 , - 1 , lines [ i ] , xdimgame < = 640 ) ;
printext256 ( x , y , whitecol , - 1 , lines [ i ] , xdimgame < = 640 ) ;
y + = ydimgame > > 6 ;
2008-08-28 15:04:16 +00:00
}
enddrawing ( ) ;
}
2010-05-02 23:27:30 +00:00
VM_OnEvent ( EVENT_PREKEYS3D , - 1 ) ;
2009-10-03 13:20:31 +00:00
2015-09-05 08:30:59 +00:00
if ( keystatus [ KEYSC_RALT ] & & keystatus [ KEYSC_RCTRL ] & & AIMING_AT_CEILING_OR_FLOOR & & searchsector > = 0 )
{
keystatus [ KEYSC_RALT ] = 0 ;
if ( highlightcnt > = 0 )
{
message ( " WARNING: Cannot select sectors while sprites/walls selected " ) ;
}
else
{
const int32_t sub = keystatus [ KEYSC_SEMI ] ;
const int32_t add = keystatus [ KEYSC_QUOTE ] ;
if ( ! add & & ! sub )
reset_highlightsector ( ) ;
handlesecthighlight1 ( searchsector , sub , 1 ) ;
2015-09-08 17:54:32 +00:00
update_highlightsector ( ) ;
2015-09-05 08:30:59 +00:00
message ( " %s sector %d " , sub ? " De-selected " : " Selected " , searchsector ) ;
}
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( V ) ) // ' V
2007-04-23 23:36:21 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_CEILING_OR_FLOOR )
getnumberptr256 ( " Sector visibility: " , & sector [ searchsector ] . visibility , sizeof ( sector [ 0 ] . visibility ) , 255 , 0 , NULL ) ;
2007-04-23 23:36:21 +00:00
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_SEMI ] & & PRESSED_KEYSC ( V ) ) // ; V
2007-04-23 23:36:21 +00:00
{
2009-01-09 09:29:17 +00:00
int16_t currsector ;
uint8_t visval ;
2007-04-23 23:36:21 +00:00
if ( highlightsectorcnt = = - 1 )
{
message ( " You didn't select any sectors! " ) ;
return ;
}
2010-05-18 05:14:17 +00:00
visval = getnumber256 ( " Visibility of selected sectors: " , sector [ searchsector ] . visibility , 255 , 0 ) ;
2011-04-28 21:28:33 +00:00
if ( AskIfSure ( " Are you sure to change the visibility of all selected sectors? " ) )
2010-05-18 05:14:17 +00:00
return ;
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2007-04-23 23:36:21 +00:00
{
currsector = highlightsector [ i ] ;
sector [ currsector ] . visibility = visval ;
}
2010-05-18 05:14:17 +00:00
2007-04-23 23:36:21 +00:00
message ( " Visibility changed on all selected sectors " ) ;
}
2015-07-08 03:34:46 +00:00
if ( ! keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( L ) ) // L (grid lock)
2015-05-26 00:48:01 +00:00
{
gridlock = ! gridlock ;
message ( " Grid locking %s " , gridlock ? " on " : " off " ) ;
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( V ) ) //V
2007-04-17 05:54:12 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2007-04-17 05:54:12 +00:00
{
2010-05-18 05:14:17 +00:00
int32_t oldtile = AIMED_SELOVR_PICNUM ;
tempint = m32gettile ( oldtile ) ;
AIMED_SELOVR_PICNUM = tempint ;
if ( AIMING_AT_MASKWALL & & wall [ searchwall ] . nextwall > = 0 )
NEXTWALL ( searchwall ) . overpicnum = tempint ;
2011-03-07 16:30:06 +00:00
if ( AIMING_AT_SPRITE )
correct_sprite_yoffset ( searchwall ) ;
2010-05-18 05:14:17 +00:00
if ( oldtile ! = tempint )
asksave = 1 ;
2007-04-17 05:54:12 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_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 " ) ;
2006-04-13 20:47:06 +00:00
}
2015-07-08 03:34:42 +00:00
if ( PRESSED_KEYSC ( F3 ) & & ! m32_is2d3dmode ( ) )
2006-04-13 20:47:06 +00:00
{
2009-04-07 18:56:22 +00:00
mlook = ! mlook ;
2008-06-09 23:41:54 +00:00
message ( " Mouselook: %s " , mlook ? " enabled " : " disabled " ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F4 ) )
2009-03-17 21:57:30 +00:00
{
2009-04-07 18:56:22 +00:00
AmbienceToggle = ! AmbienceToggle ;
2009-03-17 21:57:30 +00:00
message ( " Ambience sounds: %s " , AmbienceToggle ? " enabled " : " disabled " ) ;
if ( ! AmbienceToggle )
{
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
}
}
2009-06-28 20:23:12 +00:00
// PK
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F5 ) )
2008-05-15 03:16:38 +00:00
{
2009-04-07 18:56:22 +00:00
unrealedlook = ! 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
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( DELETE ) ) // ' del
2006-08-10 02:10:24 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK )
2006-08-10 02:10:24 +00:00
{
2013-04-09 17:35:11 +00:00
# ifdef NEW_MAP_FORMAT
wall [ searchwall ] . cstat = 0 ;
# else
2011-04-14 20:48:08 +00:00
wall [ searchwall ] . cstat & = YAX_NEXTWALLBITS ;
2013-04-09 17:35:11 +00:00
# endif
2014-11-25 21:08:58 +00:00
message ( " Wall %d cstat = %d " , searchwall , TrackerCast ( wall [ searchwall ] . cstat ) ) ;
2010-05-18 05:14:17 +00:00
}
else if ( AIMING_AT_SPRITE )
{
2006-11-16 03:02:42 +00:00
sprite [ searchwall ] . cstat = 0 ;
2010-05-18 05:14:17 +00:00
message ( " Sprite %d cstat = 0 " , searchwall ) ;
2006-08-10 02:10:24 +00:00
}
}
2010-05-18 05:14:17 +00:00
// 'P and ;P - Will copy palette to all sectors/walls/sprites highlighted with R-Alt key
if ( ( keystatus [ KEYSC_QUOTE ] | | keystatus [ KEYSC_SEMI ] ) & & PRESSED_KEYSC ( P ) ) // ' P ; P
2006-04-13 20:47:06 +00:00
{
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
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 ;
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] )
{
2011-03-17 23:37:38 +00:00
pal [ 0 ] = getnumber256 ( " Ceiling palette: " , - 1 , M32_MAXPALOOKUPS , 1 ) ;
pal [ 1 ] = getnumber256 ( " Floor palette: " , - 1 , M32_MAXPALOOKUPS , 1 ) ;
pal [ 2 ] = getnumber256 ( " Wall palette: " , - 1 , M32_MAXPALOOKUPS , 1 ) ;
pal [ 3 ] = getnumber256 ( " Sprite palette: " , - 1 , M32_MAXPALOOKUPS , 1 ) ;
2010-05-18 05:14:17 +00:00
}
else
{
2011-03-17 23:37:38 +00:00
pal [ 0 ] = getnumber256 ( " Global palette: " , 0 , M32_MAXPALOOKUPS , 0 ) ;
2010-05-18 05:14:17 +00:00
pal [ 1 ] = pal [ 2 ] = pal [ 3 ] = pal [ 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 ] ;
2010-05-18 05:14:17 +00:00
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 ] ;
2010-05-18 05:14:17 +00:00
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 ] ;
2010-05-18 05:14:17 +00:00
2009-07-04 09:28:21 +00:00
if ( pal [ 3 ] > - 1 )
2010-05-18 05:14:17 +00:00
{
2009-07-04 09:28:21 +00:00
for ( k = 0 ; k < highlightsectorcnt ; k + + )
2011-04-17 17:01:20 +00:00
for ( w = headspritesect [ highlightsector [ k ] ] ; w > = 0 ; w = nextspritesect [ w ] )
2009-07-04 09:28:21 +00:00
sprite [ w ] . pal = pal [ 3 ] ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
2006-04-13 20:47:06 +00:00
message ( " Palettes changed " ) ;
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( DELETE ) )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_SPRITE )
2006-04-13 20:47:06 +00:00
{
deletesprite ( searchwall ) ;
2012-03-14 22:30:24 +00:00
2008-06-09 23:41:54 +00:00
message ( " Sprite %d deleted " , searchwall ) ;
2009-03-18 21:05:26 +00:00
if ( AmbienceToggle )
{
2014-02-08 14:37:48 +00:00
clearbit ( g_ambiencePlaying , searchwall ) ;
2009-03-18 21:05:26 +00:00
S_StopEnvSound ( sprite [ searchwall ] . lotag , searchwall ) ;
}
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
2011-09-01 19:53:05 +00:00
if ( PRESSED_KEYSC ( BS ) ) // backspace
{
if ( AIMING_AT_WALL_OR_MASK )
{
# ifdef YAX_ENABLE
int16_t ynw , cf = - 1 ;
2011-09-01 19:58:40 +00:00
if ( m32_script_expertmode )
{
if ( eitherSHIFT & & ! eitherCTRL )
cf = 0 ;
else if ( ! eitherSHIFT & & eitherCTRL )
cf = 1 ;
}
2011-09-01 19:53:05 +00:00
if ( cf > = 0 )
{
// clear TROR uplink/downlink
ynw = yax_getnextwall ( searchwall , cf ) ;
if ( ynw > = 0 )
{
yax_setnextwall ( ynw , ! cf , - 1 ) ;
yax_setnextwall ( searchwall , cf , - 1 ) ;
}
message ( " Cleared wall %d's %s link to wall %d " , searchwall , yupdownwall [ cf ] , ynw ) ;
}
else
# endif
if ( ! eitherSHIFT & & ! eitherCTRL )
{
int32_t nw = wall [ searchwall ] . nextwall ;
if ( ( unsigned ) nw < ( unsigned ) numwalls )
{
wall [ nw ] . nextsector = wall [ nw ] . nextwall = - 1 ;
wall [ searchwall ] . nextsector = wall [ searchwall ] . nextwall = - 1 ;
message ( " Cleared connection between wall %d and %d " , searchwall , nw ) ;
}
}
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F6 ) ) //F6
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
autospritehelp = ! autospritehelp ;
message ( " Automatic SECTOREFFECTOR help %s " , autospritehelp ? " enabled " : " disabled " ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F7 ) ) //F7
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
autosecthelp = ! autosecthelp ;
message ( " Automatic sector tag help %s " , autosecthelp ? " enabled " : " disabled " ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( autospritehelp & & helpon = = 0 )
{
if ( AIMING_AT_SPRITE & & sprite [ searchwall ] . picnum = = SECTOREFFECTOR )
2011-08-09 16:03:56 +00:00
ShowFileText ( " sehelp.hlp " ) ;
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_CEILING_OR_FLOOR )
2011-08-09 16:03:56 +00:00
ShowFileText ( " sthelp.hlp " ) ;
2010-05-18 05:14:17 +00:00
}
2006-04-13 20:47:06 +00:00
2013-01-16 20:38:50 +00:00
// [.] or [,]: Search & fix panning to the right or left (3D)
2012-12-13 22:21:22 +00:00
if ( AIMING_AT_WALL_OR_MASK & & ( ( tsign = PRESSED_KEYSC ( PERIOD ) ) | | PRESSED_KEYSC ( COMMA ) ) )
2010-05-18 05:14:17 +00:00
{
2013-01-16 20:38:50 +00:00
uint32_t flags = ( ! eitherSHIFT ) | ( tsign ? 0 : 16 ) |
2014-03-05 21:12:56 +00:00
( ( ! eitherALT ) < < 2 ) | ( ( ! ! keystatus [ KEYSC_QUOTE ] ) < < 3 ) |
2014-01-24 21:39:03 +00:00
32 * ( searchwall ! = searchbottomwall ) ;
2013-01-16 20:38:50 +00:00
2012-12-13 22:21:22 +00:00
int32_t naligned = AutoAlignWalls ( searchwall , flags , 0 ) ;
2013-01-16 20:38:50 +00:00
// Do it a second time because the first one is wrong. FIXME!!!
AutoAlignWalls ( searchwall , flags , 0 ) ;
2011-12-12 23:18:35 +00:00
message ( " Aligned %d wall%s based on wall %d%s%s%s%s " , naligned ,
2013-01-16 20:38:50 +00:00
naligned = = 1 ? " " : " s " , searchwall ,
! eitherSHIFT ? " iteratively " : " " ,
2014-03-05 21:12:56 +00:00
! eitherALT ? " , aligning xrepeats " : " " ,
2013-01-16 20:38:50 +00:00
keystatus [ KEYSC_QUOTE ] ? " , aligning TROR-nextwalls " : " " ,
2014-01-24 21:39:03 +00:00
( wall [ searchbottomwall ] . cstat & 4 ) ? " " : " . WARNING: top-aligned " ) ;
2010-05-18 05:14:17 +00:00
}
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
tsign = 0 ;
tsign - = PRESSED_KEYSC ( COMMA ) ;
2010-09-06 23:08:35 +00:00
tsign + = PRESSED_KEYSC ( PERIOD ) ;
2006-04-13 20:47:06 +00:00
2011-05-07 18:23:34 +00:00
if ( tsign )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_SPRITE )
2006-04-13 20:47:06 +00:00
{
2010-05-22 14:04:47 +00:00
sprite [ searchwall ] . ang + = tsign < < ( ! eitherSHIFT * 7 ) ;
2010-05-18 05:14:17 +00:00
sprite [ searchwall ] . ang & = 2047 ;
2014-11-25 21:08:58 +00:00
message ( " Sprite %d angle: %d " , searchwall , TrackerCast ( sprite [ searchwall ] . ang ) ) ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( L ) ) // ' L
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
if ( YAXCHK ( ! AIMING_AT_CEILING_OR_FLOOR | | yax_getbunch ( searchsector , AIMING_AT_FLOOR ) < 0 ) )
# endif
2006-04-13 20:47:06 +00:00
{
2011-09-16 19:17:48 +00:00
i = m32_clipping ;
m32_clipping = 0 ;
2010-05-18 05:14:17 +00:00
2006-04-13 20:47:06 +00:00
switch ( searchstat )
{
2010-02-13 21:46:42 +00:00
case SEARCH_CEILING :
2010-05-18 05:14:17 +00:00
getnumberptr256 ( " Sector ceilingz: " , & sector [ searchsector ] . ceilingz ,
2011-02-15 21:02:43 +00:00
sizeof ( sector [ 0 ] . ceilingz ) , BZ_MAX , 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
}
2010-05-18 05:14:17 +00:00
getnumberptr256 ( " Sector ceiling slope: " , & sector [ searchsector ] . ceilingheinum ,
2011-03-17 23:37:38 +00:00
sizeof ( sector [ 0 ] . ceilingheinum ) , BHEINUM_MAX , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_FLOOR :
2010-05-18 05:14:17 +00:00
getnumberptr256 ( " Sector floorz: " , & sector [ searchsector ] . floorz ,
2011-02-15 21:02:43 +00:00
sizeof ( sector [ 0 ] . floorz ) , BZ_MAX , 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 ;
}
2010-05-18 05:14:17 +00:00
getnumberptr256 ( " Sector floor slope: " , & sector [ searchsector ] . floorheinum ,
2011-03-17 23:37:38 +00:00
sizeof ( sector [ 0 ] . floorheinum ) , BHEINUM_MAX , 1 , NULL ) ;
2006-11-16 03:02:42 +00:00
break ;
2010-05-18 05:14:17 +00:00
2010-02-13 21:46:42 +00:00
case SEARCH_SPRITE :
2011-02-15 21:02:43 +00:00
getnumberptr256 ( " Sprite x: " , & sprite [ searchwall ] . x , sizeof ( sprite [ 0 ] . x ) , editorgridextent - 1 , 1 , NULL ) ;
getnumberptr256 ( " Sprite y: " , & sprite [ searchwall ] . y , sizeof ( sprite [ 0 ] . y ) , editorgridextent - 1 , 1 , NULL ) ;
getnumberptr256 ( " Sprite z: " , & sprite [ searchwall ] . z , sizeof ( sprite [ 0 ] . z ) , BZ_MAX , 1 , NULL ) ;
2011-03-17 23:37:38 +00:00
getnumberptr256 ( " Sprite angle: " , & sprite [ searchwall ] . ang , sizeof ( sprite [ 0 ] . ang ) , 2047 , 1 , NULL ) ;
sprite [ searchwall ] . ang & = 2047 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
2011-09-01 18:37:53 +00:00
setslope ( searchsector , YAX_CEILING , sector [ searchsector ] . ceilingheinum ) ;
setslope ( searchsector , YAX_FLOOR , sector [ searchsector ] . floorheinum ) ;
2010-05-18 05:14:17 +00:00
2006-04-13 20:47:06 +00:00
asksave = 1 ;
2011-09-16 19:17:48 +00:00
m32_clipping = i ;
2006-04-13 20:47:06 +00:00
}
2011-03-23 17:41:01 +00:00
getzrange ( & pos , cursectnum , & hiz , & hihit , & loz , & lohit , 128 , CLIPMASK0 ) ;
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( CAPS ) | | ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( Z ) ) ) // CAPS LOCK
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
zmode = ( zmode + 1 ) % 3 ;
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
}
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( M ) ) // 'M
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2006-04-13 20:47:06 +00:00
{
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-04-14 20:48:08 +00:00
if ( AIMING_AT_WALL_OR_MASK & & yax_getnextwall ( searchwall , YAX_FLOOR ) > = 0 )
message ( " Can't change extra in protected wall " ) ;
else
# endif
{
Bsprintf ( tempbuf , " %s extra: " , Typestr_wss [ searchstat ] ) ;
getnumberptr256 ( tempbuf , & AIMED ( extra ) , sizeof ( int16_t ) , BTAG_MAX , 1 , NULL ) ;
asksave = 1 ;
}
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( 1 ) & & ASSERT_AIMING ) // 1 (make 1-way wall)
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ! AIMING_AT_SPRITE )
2006-04-13 20:47:06 +00:00
{
wall [ searchwall ] . cstat ^ = 32 ;
2010-05-18 05:14:17 +00:00
message ( " Wall %d one side masking bit %s " , searchwall , ONOFF ( wall [ searchwall ] . cstat & 32 ) ) ;
2006-04-13 20:47:06 +00:00
}
else
{
i = sprite [ searchwall ] . cstat ;
2010-05-18 05:14:17 +00:00
i ^ = 64 ;
2006-04-13 20:47:06 +00:00
if ( ( i & 48 ) = = 32 )
{
2010-05-18 05:14:17 +00:00
i & = ~ 8 ;
if ( ( i & 64 ) & & pos . z > sprite [ searchwall ] . z )
i | = 8 ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
message ( " Sprite %d one sided bit %s " , searchwall , ONOFF ( i & 64 ) ) ;
sprite [ searchwall ] . cstat = i ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
asksave = 1 ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( 2 ) ) // 2 (bottom wall swapping)
2006-04-13 20:47:06 +00:00
{
2012-12-20 12:04:39 +00:00
if ( ! AIMING_AT_SPRITE & & searchwall > = 0 )
2006-04-13 20:47:06 +00:00
{
wall [ searchwall ] . cstat ^ = 2 ;
2010-05-18 05:14:17 +00:00
message ( " Wall %d bottom texture swap bit %s " , searchwall , ONOFF ( wall [ searchwall ] . cstat & 2 ) ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( O ) ) // O (top/bottom orientation - for doors)
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
int16_t w = SELECT_WALL ( ) ;
2009-07-25 20:16:22 +00:00
wall [ w ] . cstat ^ = 4 ;
2010-05-18 05:14:17 +00:00
message ( " Wall %d %s orientation " , w , wall [ w ] . cstat & 4 ? " bottom " : " top " ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_SPRITE ) // O (ornament onto wall) (2D)
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
DoSpriteOrnament ( searchwall ) ;
message ( " Sprite %d ornament onto wall " , searchwall ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( M ) ) // M (masking walls)
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ! AIMING_AT_SPRITE & & ASSERT_AIMING )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
int16_t next = wall [ searchwall ] . nextwall ;
if ( next > = 0 )
2006-04-13 20:47:06 +00:00
{
wall [ searchwall ] . cstat ^ = 16 ;
2010-05-18 05:14:17 +00:00
message ( " Wall %d masking bit %s " , searchwall , ONOFF ( wall [ searchwall ] . cstat & 16 ) ) ;
wall [ searchwall ] . cstat & = ~ 8 ;
if ( wall [ searchwall ] . cstat & 16 )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ! eitherSHIFT )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
wall [ next ] . cstat | = 8 ; //auto other-side flip
wall [ next ] . cstat | = 16 ;
wall [ next ] . overpicnum = wall [ searchwall ] . overpicnum ;
2006-04-13 20:47:06 +00:00
}
}
else
{
2010-05-18 05:14:17 +00:00
if ( ! eitherSHIFT )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
wall [ next ] . cstat & = ~ 8 ; //auto other-side unflip
wall [ next ] . cstat & = ~ 16 ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
2006-04-13 20:47:06 +00:00
wall [ searchwall ] . cstat & = ~ 32 ;
2010-05-18 05:14:17 +00:00
if ( ! eitherSHIFT )
wall [ next ] . cstat & = ~ 32 ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( H ) ) // H (hitscan sensitivity)
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2006-04-13 20:47:06 +00:00
{
2011-04-17 17:01:20 +00:00
j = 0 ;
if ( AIMING_AT_WALL | | AIMING_AT_SPRITE )
{
j = taglab_linktags ( AIMING_AT_SPRITE , searchwall ) ;
j = 2 * ( j & 2 ) ;
}
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " %s hitag: " , Typestr_wss [ searchstat ] ) ;
2011-04-17 17:01:20 +00:00
getnumberptr256 ( tempbuf , & AIMED ( hitag ) , sizeof ( int16_t ) , BTAG_MAX , 0 + j , NULL ) ;
2006-04-13 20:47:06 +00:00
}
}
else
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_SPRITE )
2006-04-13 20:47:06 +00:00
{
sprite [ searchwall ] . cstat ^ = 256 ;
2010-05-18 05:14:17 +00:00
message ( " Sprite %d hitscan sensitivity bit %s " , searchwall , ONOFF ( sprite [ searchwall ] . cstat & 256 ) ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
2011-05-07 18:23:34 +00:00
else if ( AIMING_AT_WALL_OR_MASK | | AIMING_AT_CEILING_OR_FLOOR )
2006-04-13 20:47:06 +00:00
{
2011-05-07 18:23:34 +00:00
# ifdef YAX_ENABLE
if ( AIMING_AT_CEILING_OR_FLOOR & & yax_getbunch ( searchsector , AIMING_AT_FLOOR ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2011-05-07 18:23:34 +00:00
SECTORFLD ( searchsector , stat , AIMING_AT_FLOOR ) ^ = 2048 ;
message ( " Sector %d's %s hitscan sensitivity bit %s " , searchsector , typestr [ searchstat ] ,
ONOFF ( SECTORFLD ( searchsector , stat , AIMING_AT_FLOOR ) & 2048 ) ) ;
asksave = 1 ;
2006-04-13 20:47:06 +00:00
}
2011-05-07 18:23:34 +00:00
else
# endif
{
wall [ searchwall ] . cstat ^ = 64 ;
2006-04-13 20:47:06 +00:00
2011-05-07 18:23:34 +00:00
if ( wall [ searchwall ] . nextwall > = 0 & & ! eitherSHIFT )
{
NEXTWALL ( searchwall ) . cstat & = ~ 64 ;
NEXTWALL ( searchwall ) . cstat | = ( wall [ searchwall ] . cstat & 64 ) ;
}
2011-09-18 11:55:31 +00:00
message ( " Wall %d hitscan sensitivity bit %s%s " , searchwall ,
ONOFF ( wall [ searchwall ] . cstat & 64 ) , eitherSHIFT ? " (one-sided) " : " " ) ;
2011-05-07 18:23:34 +00:00
asksave = 1 ;
}
2006-04-13 20:47:06 +00:00
}
}
}
2008-05-16 00:23:33 +00:00
smooshyalign = keystatus [ KEYSC_gKP5 ] ;
2011-02-05 17:16:15 +00:00
repeatpanalign = eitherSHIFT | | eitherALT | | ( bstatus & 2 ) ;
2006-04-13 20:47:06 +00:00
2011-03-08 23:02:38 +00:00
{
static int32_t omlook ;
2007-02-16 00:11:25 +00:00
2011-03-08 23:02:38 +00:00
if ( mlook = = 2 )
{
mlook = omlook ;
}
else if ( ! unrealedlook & & ( bstatus & 4 ) )
{
omlook = mlook ;
mlook = 2 ;
}
}
2008-05-15 03:16:38 +00:00
2010-05-18 05:14:17 +00:00
// PK: no btn: wheel changes shade
if ( ( bstatus & ( 16 | 32 ) & & ! ( bstatus & ( 1 | 2 | 4 ) ) ) | | keystatus [ KEYSC_gMINUS ] | | keystatus [ KEYSC_gPLUS ] )
2006-04-13 20:47:06 +00:00
{
2009-06-28 20:23:12 +00:00
// if (bstatus&1)
// mlook = 2;
2010-02-13 21:46:42 +00:00
tsign = 0 ;
2010-05-18 05:14:17 +00:00
if ( bstatus & 32 | | PRESSED_KEYSC ( gMINUS ) ) // -
2010-02-13 21:46:42 +00:00
tsign = 1 ;
2010-05-18 05:14:17 +00:00
if ( bstatus & 16 | | PRESSED_KEYSC ( gPLUS ) ) // +
2010-02-13 21:46:42 +00:00
tsign = - 1 ;
if ( tsign )
2006-04-13 20:47:06 +00:00
{
2010-02-13 21:46:42 +00:00
mouseb & = ~ ( 16 | 32 ) ;
bstatus & = ~ ( 16 | 32 ) ;
2010-05-18 05:14:17 +00:00
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
{
2010-02-13 21:46:42 +00:00
if ( tsign = = 1 )
2012-12-14 19:28:05 +00:00
g_visibility < < = ( int ) ( g_visibility < 16384 ) ;
2010-02-13 21:46:42 +00:00
else
2012-12-14 19:28:05 +00:00
g_visibility > > = ( int ) ( g_visibility > 32 ) ;
silentmessage ( " Global visibility %d " , g_visibility ) ;
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
2011-04-28 21:28:33 +00:00
if ( highlightsectorcnt > 0 & & ( hlsectorbitmap [ searchsector > > 3 ] & ( 1 < < ( searchsector & 7 ) ) ) )
{
while ( k - - > 0 )
{
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2006-04-13 20:47:06 +00:00
{
2011-04-28 21:28:33 +00:00
j = highlightsector [ i ] ;
sector [ j ] . visibility + = tsign ;
2010-05-18 05:14:17 +00:00
2011-04-28 21:28:33 +00:00
if ( tsign = = 1 & & sector [ j ] . visibility = = 240 )
sector [ j ] . visibility = 239 ;
else if ( tsign = = - 1 & & sector [ j ] . visibility = = 239 )
sector [ j ] . visibility = 240 ;
}
}
}
else
2009-07-04 09:28:21 +00:00
{
2011-04-28 21:28:33 +00:00
while ( k - - > 0 )
2010-02-13 21:46:42 +00:00
{
2011-04-28 21:28:33 +00:00
sector [ searchsector ] . visibility + = tsign ;
if ( tsign = = 1 & & sector [ searchsector ] . visibility = = 240 )
2010-02-13 21:46:42 +00:00
sector [ searchsector ] . visibility = 239 ;
2011-04-28 21:28:33 +00:00
else if ( tsign = = - 1 & & sector [ searchsector ] . visibility = = 239 )
sector [ searchsector ] . visibility = 240 ;
2010-02-13 21:46:42 +00:00
}
2009-07-04 09:28:21 +00:00
}
2011-04-28 21:28:33 +00:00
2014-09-07 18:10:18 +00:00
silentmessage ( " Sector %d visibility %d " , searchsector ,
TrackerCast ( sector [ searchsector ] . visibility ) ) ;
2009-07-04 09:28:21 +00:00
asksave = 1 ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
else // if !eitherALT
2006-04-13 20:47:06 +00:00
{
2011-05-07 18:23:34 +00:00
int32_t clamped = 0 ;
2011-04-28 21:28:33 +00:00
k = ( highlightsectorcnt > 0 & & ( hlsectorbitmap [ searchsector > > 3 ] & ( 1 < < ( searchsector & 7 ) ) ) ) ;
tsign * = ( 1 + 3 * eitherCTRL ) ;
2006-04-13 20:47:06 +00:00
if ( k = = 0 )
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2008-05-16 00:23:33 +00:00
{
2015-01-06 19:56:41 +00:00
if ( ! eitherSHIFT & & AIMING_AT_SPRITE & & ( show2dsprite [ searchwall > > 3 ] & ( 1 < < ( searchwall & 7 ) ) ) )
2011-07-24 15:15:57 +00:00
{
for ( i = 0 ; i < highlightcnt ; i + + )
if ( highlight [ i ] & 16384 )
clamped = addtobyte ( & sprite [ highlight [ i ] & 16383 ] . shade , tsign ) ;
2011-11-03 23:08:35 +00:00
( clamped ? message : silentmessage )
( " Highlighted sprite shade changed by %d%s " ,
tsign , clamped ? " (some sprites' shade clamped) " : " " ) ;
2011-07-24 15:15:57 +00:00
}
else
{
clamped = addtobyte ( & AIMED_CF_SEL ( shade ) , tsign ) ;
2012-12-14 19:28:11 +00:00
// TODO: factor formatting stuff out and use elsewhere?
2011-11-03 23:08:35 +00:00
( clamped ? message : silentmessage )
2012-12-14 19:28:11 +00:00
( " %s %s%d shade %d%s " , Typestr [ searchstat ] ,
AIMING_AT_CEILING_OR_FLOOR ? " of sector " : " " ,
AIMING_AT_WALL_OR_MASK ? SELECT_WALL ( ) :
( AIMING_AT_CEILING_OR_FLOOR ? searchsector : searchwall ) ,
2011-11-03 23:08:35 +00:00
AIMED_CF_SEL ( shade ) , clamped ? " (clamped) " : " " ) ;
2011-07-24 15:15:57 +00:00
}
2008-05-16 00:23:33 +00:00
}
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 ] ;
2011-04-28 21:28:33 +00:00
// sector shade
2011-05-07 18:23:34 +00:00
clamped | = addtobyte ( & sector [ dasector ] . ceilingshade , tsign ) ;
clamped | = addtobyte ( & sector [ dasector ] . floorshade , tsign ) ;
2006-04-13 20:47:06 +00:00
2011-04-28 21:28:33 +00:00
// wall shade
for ( WALLS_OF_SECTOR ( dasector , j ) )
2011-05-07 18:23:34 +00:00
clamped | = addtobyte ( & wall [ j ] . shade , tsign ) ;
2006-04-13 20:47:06 +00:00
2011-04-28 21:28:33 +00:00
// sprite shade
for ( j = headspritesect [ dasector ] ; j ! = - 1 ; j = nextspritesect [ j ] )
2011-05-07 18:23:34 +00:00
clamped | = addtobyte ( & sprite [ j ] . shade , tsign ) ;
2006-04-13 20:47:06 +00:00
}
2011-11-03 23:08:35 +00:00
( clamped ? message : silentmessage ) ( " Highlighted sector shade changed by %d%s " , tsign ,
2011-05-07 18:23:34 +00:00
clamped ? " (some objects' shade clamped) " : " " ) ;
2006-04-13 20:47:06 +00:00
}
asksave = 1 ;
}
}
}
2010-05-18 05:14:17 +00:00
// PK: lmb only & mousewheel, -, and +, cycle picnum
if ( keystatus [ KEYSC_DASH ] | | keystatus [ KEYSC_EQUAL ] | | ( bstatus & ( 16 | 32 ) & & ( bstatus & 1 ) & & ! ( bstatus & 2 ) ) )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2006-04-13 20:47:06 +00:00
{
2012-11-17 19:46:33 +00:00
int32_t pic = AIMED_SELOVR_PICNUM ;
int32_t dir = ( keystatus [ KEYSC_EQUAL ] | | ( bstatus & 16 ) ) ? 1 : - 1 ;
2010-05-18 05:14:17 +00:00
2012-11-17 19:46:33 +00:00
do
2006-11-16 03:02:42 +00:00
{
2012-11-17 19:46:33 +00:00
pic + = dir + MAXTILES ;
pic % = MAXTILES ;
2006-11-16 03:02:42 +00:00
}
2014-09-30 04:14:21 +00:00
while ( tilesiz [ pic ] . x < = 0 | | tilesiz [ pic ] . y < = 0 ) ;
2012-11-17 19:46:33 +00:00
AIMED_SELOVR_PICNUM = pic ;
2010-05-18 05:14:17 +00:00
2011-03-07 16:30:06 +00:00
if ( AIMING_AT_SPRITE )
correct_sprite_yoffset ( searchwall ) ;
2010-05-18 05:14:17 +00:00
asksave = 1 ;
2006-11-16 03:02:42 +00:00
}
keystatus [ KEYSC_DASH ] = keystatus [ KEYSC_EQUAL ] = 0 ;
mouseb & = ~ ( 16 | 32 ) ;
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( E ) ) // E (expand)
2006-11-16 03:02:42 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_CEILING_OR_FLOOR )
2006-11-16 03:02:42 +00:00
{
2010-05-18 05:14:17 +00:00
AIMED_CEILINGFLOOR ( stat ) ^ = 8 ;
2011-03-23 17:41:01 +00:00
message ( " Sector %d %s texture expansion bit %s " , searchsector , typestr [ searchstat ] ,
2016-01-27 07:16:40 +00:00
ONOFF ( AIMED_CEILINGFLOOR ( stat ) & 8 ) ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_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 ;
2010-05-18 05:14:17 +00:00
message ( " Show framerate %s " , ONOFF ( framerateon ) ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_CEILING_OR_FLOOR )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
AIMED_CEILINGFLOOR ( stat ) ^ = 64 ;
2011-03-23 17:41:01 +00:00
message ( " Sector %d %s texture relativity bit %s " , searchsector , typestr [ searchstat ] ,
ONOFF ( AIMED_CEILINGFLOOR ( stat ) & 64 ) ) ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_SPRITE )
2012-06-01 20:09:00 +00:00
toggle_sprite_alignment ( searchwall ) ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F ) ) //F (Flip)
2006-04-13 20:47:06 +00:00
{
2008-05-16 00:23:33 +00:00
if ( eitherALT ) //ALT-F (relative alignmment flip)
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ! AIMING_AT_SPRITE & & ASSERT_AIMING )
2013-05-30 18:10:45 +00:00
SetFirstWall ( searchsector , searchwall , eitherSHIFT ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2012-06-01 20:08:57 +00:00
static const int8_t next2 [ 4 ] = { 1 , 3 , 0 , 2 } ; // 0->1->3->2->0
static const int8_t prev2 [ 4 ] = { 2 , 0 , 3 , 1 } ; // 0<-1<-3<-2<-0
static const char * flip2label [ 4 ] = { " none " , " X " , " Y " , " X and Y " } ;
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK )
2006-04-13 20:47:06 +00:00
{
2009-07-25 20:16:22 +00:00
i = wall [ searchbottomwall ] . cstat ;
2006-04-13 20:47:06 +00:00
i = ( ( i > > 3 ) & 1 ) + ( ( i > > 7 ) & 2 ) ; //3-x,8-y
2010-05-18 05:14:17 +00:00
2012-06-01 20:08:57 +00:00
i = eitherSHIFT ? prev2 [ i ] : next2 [ i ] ;
message ( " Wall %d flip %s " , searchwall , flip2label [ i ] ) ;
2010-05-18 05:14:17 +00:00
2006-04-13 20:47:06 +00:00
i = ( ( i & 1 ) < < 3 ) + ( ( i & 2 ) < < 7 ) ;
2009-07-25 20:16:22 +00:00
wall [ searchbottomwall ] . cstat & = ~ 0x0108 ;
wall [ searchbottomwall ] . cstat | = i ;
2006-04-13 20:47:06 +00:00
asksave = 1 ;
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_CEILING_OR_FLOOR ) //8-way ceiling/floor flipping (bits 2,4,5)
2012-06-01 20:09:09 +00:00
toggle_cf_flipping ( searchsector , AIMING_AT_FLOOR ) ;
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_SPRITE )
2006-04-13 20:47:06 +00:00
{
i = sprite [ searchwall ] . cstat ;
if ( ( ( i & 48 ) = = 32 ) & & ( ( i & 64 ) = = 0 ) )
{
sprite [ searchwall ] . cstat & = ~ 0xc ;
sprite [ searchwall ] . cstat | = ( ( i & 4 ) ^ 4 ) ;
2010-05-18 05:14:17 +00:00
message ( " Sprite %d flip bit %s " , searchwall , ONOFF ( sprite [ searchwall ] . cstat & 4 ) ) ;
2006-04-13 20:47:06 +00:00
}
else
{
i = ( ( i > > 2 ) & 3 ) ;
2010-05-18 05:14:17 +00:00
2012-06-01 20:08:57 +00:00
i = eitherSHIFT ? prev2 [ i ] : next2 [ i ] ;
message ( " Sprite %d flip %s " , searchwall , flip2label [ i ] ) ;
2010-05-18 05:14:17 +00:00
2006-04-13 20:47:06 +00:00
sprite [ searchwall ] . cstat & = ~ 0xc ;
2010-05-18 05:14:17 +00:00
sprite [ searchwall ] . cstat | = ( i < < 2 ) ;
2006-04-13 20:47:06 +00:00
}
asksave = 1 ;
}
}
}
2010-05-18 05:14:17 +00:00
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 ;
2010-05-18 05:14:17 +00:00
2008-05-16 19:51:38 +00:00
mouseaction = 0 ;
2010-02-13 21:46:42 +00:00
if ( eitherALT & & ( bstatus & 1 ) )
2008-05-16 19:51:38 +00:00
{
2009-02-19 16:47:54 +00:00
mousex = 0 ; mskip = 1 ;
2010-02-13 21:46:42 +00:00
if ( mousey ! = 0 )
2008-05-16 19:51:38 +00:00
{
updownunits = klabs ( mousey * 128 ) ;
mouseaction = 1 ;
}
}
2010-02-13 21:46:42 +00:00
2010-05-18 05:14:17 +00:00
2010-02-13 21:46:42 +00:00
tsign = 0 ;
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
{
// PK: PGUP/PGDN, rmb only & mwheel
2011-03-17 23:37:38 +00:00
tsign - = ( PRESSED_KEYSC ( PGUP ) | | ( mouseaction & & mousey < 0 ) | | ( ( bstatus & ( 16 | 2 | 1 ) ) = = ( 16 | 2 ) ) ) ;
tsign + = ( PRESSED_KEYSC ( PGDN ) | | ( mouseaction & & mousey > 0 ) | | ( ( bstatus & ( 32 | 2 | 1 ) ) = = ( 32 | 2 ) ) ) ;
2010-05-18 05:14:17 +00:00
}
2010-02-13 21:46:42 +00:00
if ( tsign )
2006-04-13 20:47:06 +00:00
{
2011-03-23 17:41:01 +00:00
int16_t sect0 , sect , havebtm = 0 , havetop = 0 , moveCeilings , moveFloors ;
int32_t cz , fz ;
2011-03-17 23:37:38 +00:00
2006-04-13 20:47:06 +00:00
k = 0 ;
2011-03-23 17:41:01 +00:00
if ( highlightsectorcnt > 0 & & searchsector > = 0 & & searchsector < numsectors )
2006-04-13 20:47:06 +00:00
{
2011-04-09 13:27:08 +00:00
if ( hlsectorbitmap [ searchsector > > 3 ] & ( 1 < < ( searchsector & 7 ) ) )
2011-03-23 17:41:01 +00:00
k = highlightsectorcnt ;
2006-04-13 20:47:06 +00:00
}
2011-03-17 23:37:38 +00:00
if ( k )
{
sect = highlightsector [ 0 ] ;
2011-09-17 14:26:02 +00:00
havetop = AIMING_AT_WALL_OR_MASK ;
2011-03-17 23:37:38 +00:00
}
else
{
2011-09-17 14:26:02 +00:00
if ( AIMING_AT_WALL_OR_MASK & & wall [ searchwall ] . nextsector > = 0
2011-03-17 23:37:38 +00:00
& & eitherALT & & ! ( bstatus & 1 ) )
{
sect = wall [ searchwall ] . nextsector ;
2011-09-17 14:26:02 +00:00
havebtm = ! AIMING_AT_MASKWALL & & searchisbottom ;
2011-03-17 23:37:38 +00:00
havetop = ! havebtm ;
}
else
{
sect = searchsector ;
2011-09-17 14:26:02 +00:00
havetop = AIMING_AT_WALL_OR_MASK ;
2011-03-17 23:37:38 +00:00
}
}
2011-03-23 17:41:01 +00:00
sect0 = sect ;
moveCeilings = ( AIMING_AT_CEILING | | havetop ) ;
moveFloors = ( AIMING_AT_FLOOR | | havebtm ) ;
2010-02-13 21:46:42 +00:00
2011-03-23 17:41:01 +00:00
if ( moveCeilings | | moveFloors )
{
2011-11-11 20:05:44 +00:00
int32_t dz = tsign * ( updownunits < < ( eitherCTRL < < 1 ) ) ; // JBF 20031128
2011-03-23 17:41:01 +00:00
static const char * cfs [ 2 ] = { " ceiling " , " floor " } ;
# ifdef YAX_ENABLE
2011-03-25 11:42:07 +00:00
int16_t bunchnum = - 1 , maxbunchnum = - 1 , cb , fb ;
2011-03-23 17:41:01 +00:00
Bmemset ( havebunch , 0 , sizeof ( havebunch ) ) ;
# endif
2010-02-13 21:46:42 +00:00
for ( j = 0 ; j < ( k ? k : 1 ) ; j + + , sect = highlightsector [ j ] )
2006-04-13 20:47:06 +00:00
{
2011-11-11 20:05:44 +00:00
// stage one: see if we don't move beyond the other side
// (ceiling if floor and vice versa)
2010-05-18 05:14:17 +00:00
2011-11-11 20:05:44 +00:00
if ( moveCeilings & & ( dz > 0 ) & & sector [ sect ] . ceilingz + dz > sector [ sect ] . floorz )
2011-11-11 22:39:56 +00:00
dz = ( k > 1 ) ? 0 : min ( sector [ sect ] . floorz - sector [ sect ] . ceilingz , dz ) ;
2011-11-11 20:05:44 +00:00
else if ( moveFloors & & ( dz < 0 ) & & sector [ sect ] . floorz + dz < sector [ sect ] . ceilingz )
2011-11-11 22:39:56 +00:00
dz = ( k > 1 ) ? 0 : max ( sector [ sect ] . ceilingz - sector [ sect ] . floorz , dz ) ;
2011-11-11 20:05:44 +00:00
if ( dz = = 0 )
break ;
2011-03-23 17:41:01 +00:00
}
2011-11-11 20:05:44 +00:00
if ( dz )
2011-03-23 17:41:01 +00:00
{
2011-11-11 20:05:44 +00:00
// now truly move things if we're clear to go!
sect = sect0 ;
for ( j = 0 ; j < ( k ? k : 1 ) ; j + + , sect = highlightsector [ j ] )
{
for ( i = headspritesect [ sect ] ; i ! = - 1 ; i = nextspritesect [ i ] )
{
spriteoncfz ( i , & cz , & fz ) ;
if ( ( moveCeilings & & sprite [ i ] . z = = cz ) | | ( moveFloors & & sprite [ i ] . z = = fz ) )
sprite [ i ] . z + = dz ;
}
SECTORFLD ( sect , z , moveFloors ) + = dz ;
# ifdef YAX_ENABLE
bunchnum = yax_getbunch ( sect , moveFloors ) ;
if ( bunchnum > = 0 & & ! ( havebunch [ bunchnum > > 3 ] & ( 1 < < ( bunchnum & 7 ) ) ) )
{
maxbunchnum = max ( maxbunchnum , bunchnum ) ;
havebunch [ bunchnum > > 3 ] | = ( 1 < < ( bunchnum & 7 ) ) ;
tempzar [ bunchnum ] = & SECTORFLD ( sect , z , moveFloors ) ;
}
# endif
}
2011-03-23 17:41:01 +00:00
}
2010-05-18 05:14:17 +00:00
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2011-11-11 20:05:44 +00:00
if ( dz )
2011-03-23 17:41:01 +00:00
{
2011-11-11 20:05:44 +00:00
// sync z values of extended sectors' ceilings/floors
for ( i = 0 ; i < numsectors ; i + + )
{
yax_getbunches ( i , & cb , & fb ) ;
if ( cb > = 0 & & ( havebunch [ cb > > 3 ] & ( 1 < < ( cb & 7 ) ) ) )
sector [ i ] . ceilingz = * tempzar [ cb ] ;
if ( fb > = 0 & & ( havebunch [ fb > > 3 ] & ( 1 < < ( fb & 7 ) ) ) )
sector [ i ] . floorz = * tempzar [ fb ] ;
}
2006-04-13 20:47:06 +00:00
}
2008-05-16 19:51:38 +00:00
2011-11-11 20:05:44 +00:00
if ( ! dz )
silentmessage ( " Didn't move sector %ss " , cfs [ moveFloors ] ) ;
else if ( k < = 1 & & bunchnum > = 0 )
2011-03-23 17:41:01 +00:00
silentmessage ( " Bunch %d's ceilings and floors = %d " , bunchnum , SECTORFLD ( sect0 , z , moveFloors ) ) ;
2006-04-13 20:47:06 +00:00
else
2011-03-23 17:41:01 +00:00
# endif
2011-11-11 20:05:44 +00:00
if ( k < = 1 )
2011-03-23 17:41:01 +00:00
silentmessage ( " Sector %d %sz = %d " , sect0 , cfs [ moveFloors ] , SECTORFLD ( sect0 , z , moveFloors ) ) ;
else
silentmessage ( " %s %d sector %ss by %d units " , tsign < 0 ? " Raised " : " Lowered " ,
2011-11-11 20:05:44 +00:00
k , cfs [ moveFloors ] , dz * tsign ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_SPRITE )
2006-04-13 20:47:06 +00:00
{
2011-03-23 17:41:01 +00:00
int32_t cz , fz ;
2010-02-13 21:46:42 +00:00
if ( eitherCTRL & & ! eitherALT ) //CTRL - put sprite on ceiling/floor
2006-04-13 20:47:06 +00:00
{
2011-03-23 17:41:01 +00:00
spriteoncfz ( searchwall , & cz , & fz ) ;
sprite [ searchwall ] . z = ( tsign = = 1 ) ? fz : cz ;
2006-04-13 20:47:06 +00:00
}
else
{
2011-05-07 18:23:34 +00:00
k = ! ! ( show2dsprite [ searchwall > > 3 ] & ( 1 < < ( searchwall & 7 ) ) ) ;
2006-04-13 20:47:06 +00:00
2011-05-07 18:23:34 +00:00
tsign * = ( updownunits < < ( ( eitherCTRL & & mouseaction ) * 3 ) ) ;
for ( i = 0 ; i < highlightcnt | | k = = 0 ; i + + )
2009-07-04 09:28:21 +00:00
{
2011-05-07 18:23:34 +00:00
if ( k = = 0 | | ( highlight [ i ] & 0xc000 ) = = 16384 )
2011-03-23 17:41:01 +00:00
{
2011-05-07 18:23:34 +00:00
int16_t sp = k = = 0 ? searchwall : highlight [ i ] & 16383 ;
2010-05-18 05:14:17 +00:00
2011-05-07 18:23:34 +00:00
sprite [ sp ] . z + = tsign ;
2009-06-28 20:23:12 +00:00
2011-05-07 18:23:34 +00:00
if ( ! spnoclip )
2009-06-28 20:23:12 +00:00
{
2011-05-07 18:23:34 +00:00
spriteoncfz ( sp , & cz , & fz ) ;
inpclamp ( & sprite [ sp ] . z , cz , fz ) ;
}
# ifdef YAX_ENABLE
else if ( sprite [ sp ] . sectnum > = 0 )
{
int16_t cb , fb ;
yax_getbunches ( sprite [ sp ] . sectnum , & cb , & fb ) ;
if ( cb > = 0 | | fb > = 0 )
setspritez ( sp , ( vec3_t * ) & sprite [ sp ] ) ;
}
# endif
if ( k = = 0 )
{
2014-09-07 18:10:18 +00:00
silentmessage ( " Sprite %d z = %d " , searchwall , TrackerCast ( sprite [ searchwall ] . z ) ) ;
2011-05-07 18:23:34 +00:00
break ;
2009-06-28 20:23:12 +00:00
}
2011-05-07 18:23:34 +00:00
}
2010-05-18 05:14:17 +00:00
2011-05-07 18:23:34 +00:00
if ( k = = 1 )
silentmessage ( " Sprites %s by %d units " , tsign < 0 ? " raised " : " lowered " , tsign ) ;
2009-07-04 09:28:21 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
2006-04-13 20:47:06 +00:00
asksave = 1 ;
2010-02-13 21:46:42 +00:00
mouseb & = ~ ( 16 | 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 ;
2010-05-18 05:14:17 +00:00
2009-01-09 09:29:17 +00:00
int32_t ms = getticks ( ) ;
int32_t howlong = ms - LastMS ;
2010-05-18 05:14:17 +00:00
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
2015-07-17 00:12:48 +00:00
int32_t const dax = m32_is2d3dmode ( ) ? m32_2d3d . x + XSIZE_2D3D - 3 : windowx2 ;
int32_t const day = m32_is2d3dmode ( ) ? m32_2d3d . y + 4 : windowy1 ;
2008-09-11 09:24:45 +00:00
if ( ! x )
{
2015-07-17 00:12:48 +00:00
printext256 ( dax - ( chars < < 3 ) + 1 , day + 2 , 0 , - 1 , tempbuf , x ) ;
2015-07-20 20:25:21 +00:00
printext256 ( dax - ( chars < < 3 ) , day + 1 , whitecol , - 1 , tempbuf , x ) ;
2008-09-11 09:24:45 +00:00
}
else
{
2015-07-17 00:12:48 +00:00
printext256 ( dax - ( chars < < 2 ) + 1 , day + 2 , 0 , - 1 , tempbuf , x ) ;
2015-07-20 20:25:21 +00:00
printext256 ( dax - ( chars < < 2 ) , day + 1 , whitecol , - 1 , tempbuf , x ) ;
2008-09-11 09:24:45 +00:00
}
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 ;
2010-05-18 05:14:17 +00:00
2010-05-22 14:04:47 +00:00
if ( ( bstatus & ( 4 | 2 | 1 ) ) = = 4 & & ! unrealedlook ) //PK
2008-05-15 03:16:38 +00:00
Bsprintf ( tempbuf , " VIEW " ) ;
2010-05-22 14:04:47 +00:00
else if ( ( bstatus & ( 2 | 1 ) ) = = 2 )
Bsprintf ( tempbuf , " Z%s " , keystatus [ KEYSC_HOME ] ? " 256 " : keystatus [ KEYSC_END ] ? " 512 " : " " ) ;
2011-03-17 23:37:38 +00:00
if ( ( bstatus & ( 2 | 1 ) ) = = 1 | | ( keystatus [ KEYSC_SPACE ] ) )
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 )
{
switch ( searchstat )
{
2010-02-13 21:46:42 +00:00
case SEARCH_WALL :
case SEARCH_MASKWALL :
2009-04-26 20:51:00 +00:00
if ( eitherALT )
2009-07-25 20:16:22 +00:00
Bsprintf ( tempbuf , " CEILING Z %s " , eitherCTRL ? " 512 " : " " ) ;
else if ( eitherSHIFT )
Bsprintf ( tempbuf , " PAN %s " , eitherCTRL ? " 8 " : " " ) ;
else if ( eitherCTRL )
Bsprintf ( tempbuf , " SCALE " ) ;
2008-05-16 19:51:38 +00:00
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_CEILING :
case SEARCH_FLOOR :
2009-04-26 20:51:00 +00:00
if ( eitherALT )
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " %s Z %s " , AIMING_AT_CEILING ? " CEILING " : " FLOOR " , eitherCTRL ? " 512 " : " " ) ;
2009-07-25 20:16:22 +00:00
else if ( eitherSHIFT )
Bsprintf ( tempbuf , " PAN " ) ;
else if ( eitherCTRL )
Bsprintf ( tempbuf , " SLOPE " ) ;
2008-05-16 19:51:38 +00:00
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_SPRITE :
2009-04-26 20:51:00 +00:00
if ( eitherALT )
2009-07-25 20:16:22 +00:00
Bsprintf ( tempbuf , " MOVE Z %s " , eitherCTRL ? " 1024 " : " " ) ;
else if ( eitherSHIFT )
Bsprintf ( tempbuf , " MOVE XY %s " , eitherCTRL ? " GRID " : " " ) ;
else if ( eitherCTRL )
Bsprintf ( tempbuf , " SIZE " ) ;
2008-05-16 19:51:38 +00:00
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 ;
2010-05-18 05:14:17 +00:00
i = max ( ( searchx + i ) - ( xdim - 1 ) , 0 ) ;
j = max ( ( searchy + 16 ) - ( ydim - 1 ) , 0 ) ;
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-04-13 20:47:06 +00:00
}
2013-01-13 16:40:14 +00:00
2006-11-13 23:12:47 +00:00
if ( helpon = = 1 )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
int32_t small = ! ( xdimgame > 640 ) ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXHELP3D ; i + + )
2006-04-13 20:47:06 +00:00
{
begindrawing ( ) ;
2010-05-18 05:14:17 +00:00
printext256 ( 2 , 8 + ( i * ( 8 + ! small ) ) + 2 , 0 , - 1 , Help3d [ i ] , small ) ;
printext256 ( 0 , 8 + ( i * ( 8 + ! small ) ) , whitecol , - 1 , Help3d [ i ] , small ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
2010-05-18 05:14:17 +00:00
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 :
2011-03-25 11:42:07 +00:00
Bsprintf ( tempbuf , " %d " , showinvisibility ) ;
2006-11-16 03:02:42 +00:00
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
}
2010-05-18 05:14:17 +00:00
2006-11-15 01:16:55 +00:00
begindrawing ( ) ;
2010-05-18 05:14:17 +00:00
if ( ! Bstrcmp ( tempbuf , " 0 " ) )
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " OFF " ) ;
2010-05-18 05:14:17 +00:00
else if ( ! Bstrcmp ( tempbuf , " 1 " ) )
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " ON " ) ;
2010-05-18 05:14:17 +00:00
else if ( ! Bstrcmp ( tempbuf , " 2 " ) )
2006-04-13 20:47:06 +00:00
Bsprintf ( tempbuf , " ON (2) " ) ;
2010-05-18 05:14:17 +00:00
printext256 ( ( 20 + ( ! small * 20 ) ) * 8 + 2 , 8 + ( i * ( 8 + ! small ) ) + 2 , 0 , - 1 , tempbuf , small ) ;
printext256 ( ( 20 + ( ! small * 20 ) ) * 8 , 8 + ( i * ( 8 + ! small ) ) , whitecol , - 1 , tempbuf , small ) ;
2006-04-13 20:47:06 +00:00
enddrawing ( ) ;
}
}
2008-07-25 13:42:37 +00:00
if ( keystatus [ buildkeys [ BK_MODE2D_3D ] ] ) // Enter
2009-03-17 21:57:30 +00:00
{
2014-07-28 06:44:14 +00:00
SetGamePalette ( BASEPAL ) ;
2009-03-17 21:57:30 +00:00
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
2010-05-18 05:14:17 +00:00
2009-09-30 21:46:07 +00:00
# ifdef POLYMER
2011-01-16 00:23:39 +00:00
DeletePolymerLights ( ) ;
2009-09-30 21:46:07 +00:00
# endif
2009-03-17 21:57:30 +00:00
}
2006-04-13 20:47:06 +00:00
//Stick this in 3D part of ExtCheckKeys
//Also choose your own key scan codes
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( D ) ) // ' d
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
skill = ( skill + 1 ) % MAXSKILL ;
message ( " %s " , SKILLMODE [ skill ] ) ;
2006-04-13 20:47:06 +00:00
}
2011-05-23 14:22:32 +00:00
if ( keystatus [ KEYSC_I ] )
2010-09-27 21:52:04 +00:00
{
2011-05-23 14:22:32 +00:00
keystatus [ KEYSC_I ] = 0 ;
2013-01-13 16:40:14 +00:00
if ( keystatus [ KEYSC_QUOTE ] ) // ' i
2011-05-23 14:22:32 +00:00
{
if ( AIMING_AT_SPRITE )
{
sprite [ searchwall ] . cstat ^ = 32768 ;
message ( " Sprite %d made %svisible " , searchwall , ( sprite [ searchwall ] . cstat & 32768 ) ? " in " : " " ) ;
}
}
2013-01-13 16:40:14 +00:00
else
2011-05-23 14:22:32 +00:00
{
showinvisibility = ! showinvisibility ;
2013-04-09 17:35:11 +00:00
# if !defined YAX_ENABLE
2011-05-23 14:22:32 +00:00
message ( " Show invisible sprites %s " , showinvisibility ? " enabled " : " disabled " ) ;
2011-04-22 22:48:06 +00:00
# else
2011-05-23 14:22:32 +00:00
message ( " Show invisible objects %s " , showinvisibility ? " enabled " : " disabled " ) ;
2011-04-22 22:48:06 +00:00
# endif
2011-05-23 14:22:32 +00:00
}
2010-09-27 21:52:04 +00:00
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( X ) ) // ' x
2009-06-28 20:23:12 +00:00
{
2010-05-18 05:14:17 +00:00
shadepreview = ! shadepreview ;
message ( " Map shade preview %s " , shadepreview ? " enabled " : " disabled " ) ;
2006-04-13 20:47:06 +00:00
2009-09-30 21:46:07 +00:00
# ifdef POLYMER
2011-01-16 00:23:39 +00:00
DeletePolymerLights ( ) ;
2009-09-30 21:46:07 +00:00
# endif
2006-04-13 20:47:06 +00:00
}
2011-03-17 23:37:38 +00:00
///___unused_keys___
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( W ) ) // ' w
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
nosprites = ( nosprites + 1 ) % MAXNOSPRITES ;
message ( " %s " , SPRDSPMODE [ nosprites ] ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( Y ) ) // ' y
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
purpleon = ! purpleon ;
2006-11-15 01:16:55 +00:00
if ( nosprites > 3 ) nosprites = 0 ;
2010-05-18 05:14:17 +00:00
message ( " Purple %s " , ONOFF ( purpleon ) ) ;
2006-04-13 20:47:06 +00:00
}
2008-05-16 00:23:33 +00:00
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( C ) ) // ' C
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK )
2006-04-13 20:47:06 +00:00
{
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 ;
2010-05-18 05:14:17 +00:00
}
else if ( AIMING_AT_CEILING_OR_FLOOR )
{
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < MAXSECTORS ; i + + )
2010-05-18 05:14:17 +00:00
if ( CEILINGFLOOR ( i , picnum ) = = temppicnum )
CEILINGFLOOR ( i , shade ) = tempshade ;
}
else if ( AIMING_AT_SPRITE )
{
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 ;
2010-05-18 05:14:17 +00:00
}
if ( ASSERT_AIMING )
{
2011-03-05 12:59:27 +00:00
message ( " %ss with picnum %d now have shade of %d " , Typestr [ searchstat ] , temppicnum , tempshade ) ;
2010-05-18 05:14:17 +00:00
asksave = 1 ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( T ) ) // ' T
2006-04-13 20:47:06 +00:00
{
2011-04-17 17:01:20 +00:00
j = 0 ;
if ( AIMING_AT_WALL | | AIMING_AT_SPRITE )
{
j = taglab_linktags ( AIMING_AT_SPRITE , searchwall ) ;
j = 4 * ( j & 1 ) ;
}
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK )
{
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-04-14 20:48:08 +00:00
if ( yax_getnextwall ( searchwall , YAX_CEILING ) > = 0 )
message ( " Can't change lotag in protected wall " ) ;
else
# endif
2011-04-17 17:01:20 +00:00
wall [ searchwall ] . lotag = getnumber256 ( " Wall lotag: " , wall [ searchwall ] . lotag , BTAG_MAX , 0 + j ) ;
2010-05-18 05:14:17 +00:00
}
else if ( AIMING_AT_CEILING_OR_FLOOR )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ searchsector ] . lotag =
2013-09-21 13:38:44 +00:00
_getnumber256 ( " Sector lotag: " , sector [ searchsector ] . lotag , BTAG_MAX , 0 , & ExtGetSectorType ) ;
2010-05-18 05:14:17 +00:00
}
else if ( AIMING_AT_SPRITE )
{
2008-09-03 10:47:19 +00:00
if ( sprite [ searchwall ] . picnum = = SECTOREFFECTOR )
2010-05-18 05:14:17 +00:00
{
2008-09-03 10:47:19 +00:00
sprite [ searchwall ] . lotag =
2013-09-21 13:38:44 +00:00
_getnumber256 ( " Sprite lotag: " , sprite [ searchwall ] . lotag , BTAG_MAX , 0 + j , & SectorEffectorTagText ) ;
2010-05-18 05:14:17 +00:00
}
2009-03-18 21:05:26 +00:00
else if ( sprite [ searchwall ] . picnum = = MUSICANDSFX )
{
int16_t oldtag = sprite [ searchwall ] . lotag ;
2010-05-18 05:14:17 +00:00
2009-03-18 21:05:26 +00:00
sprite [ searchwall ] . lotag =
2013-09-21 13:38:44 +00:00
_getnumber256 ( " Sprite lotag: " , sprite [ searchwall ] . lotag , BTAG_MAX , 0 + j , & MusicAndSFXTagText ) ;
2010-05-18 05:14:17 +00:00
2014-02-08 14:37:48 +00:00
if ( testbit ( g_ambiencePlaying , searchwall ) & & sprite [ searchwall ] . lotag ! = oldtag )
2009-03-18 21:05:26 +00:00
{
2014-02-08 14:37:48 +00:00
clearbit ( g_ambiencePlaying , searchwall ) ;
2009-03-18 21:05:26 +00:00
S_StopEnvSound ( oldtag , searchwall ) ;
}
}
2008-09-03 10:47:19 +00:00
else
2011-04-17 17:01:20 +00:00
sprite [ searchwall ] . lotag = getnumber256 ( " Sprite lotag: " , sprite [ searchwall ] . lotag , BTAG_MAX , 0 + j ) ;
2006-04-13 20:47:06 +00:00
}
}
2013-01-13 16:40:14 +00:00
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( S ) ) // ' S
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
int8_t oshade = AIMED_CF_SEL ( shade ) ;
Bsprintf ( tempbuf , " %s shade: " , Typestr [ searchstat ] ) ;
getnumberptr256 ( tempbuf , & AIMED_CF_SEL ( shade ) , sizeof ( int8_t ) , 128 , 1 , NULL ) ;
2011-03-08 23:02:38 +00:00
if ( AIMED_CF_SEL ( shade ) ! = oshade )
asksave = 1 ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F2 ) ) // F2
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
if ( eitherCTRL | | eitherSHIFT )
2010-09-06 23:08:35 +00:00
infobox ^ = ( eitherSHIFT | ( ( eitherCTRL ) < < 1 ) ) ;
2010-05-18 05:14:17 +00:00
else
usedcount = ! usedcount ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F1 ) ) // F1
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
helpon = ! helpon ;
// keystatus[KEYSC_H]=0; // delete this line?
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( G ) ) // G
2006-07-04 00:46:24 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2006-07-04 00:46:24 +00:00
{
2013-04-21 19:55:26 +00:00
int16_t * const picnumptr = AIMING_AT_WALL_OR_MASK ? & AIMED_SELOVR_PICNUM : & AIMED_CF_SEL ( picnum ) ;
const int32_t aiming_at_sprite = AIMING_AT_SPRITE ;
const int32_t opicnum = * picnumptr , osearchwall = searchwall ;
2011-10-17 18:41:17 +00:00
2010-05-18 05:14:17 +00:00
static const char * Typestr_tmp [ 5 ] = { " Wall " , " Sector ceiling " , " Sector floor " , " Sprite " , " Masked wall " } ;
2011-10-17 18:41:17 +00:00
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " %s picnum: " , Typestr_tmp [ searchstat ] ) ;
2011-10-17 18:41:17 +00:00
getnumberptr256 ( tempbuf , picnumptr , sizeof ( int16_t ) , MAXTILES - 1 , 0 + 2 , NULL ) ;
2013-04-21 19:55:26 +00:00
Bassert ( ( unsigned ) * picnumptr < MAXTILES ) ;
if ( ! tile_exists ( * picnumptr ) )
* picnumptr = opicnum ;
if ( * picnumptr ! = opicnum )
2011-03-08 23:02:38 +00:00
asksave = 1 ;
2011-03-07 16:30:06 +00:00
2011-04-14 20:48:08 +00:00
// need to use the old value because aiming might have changed in getnumberptr256
2011-10-17 18:41:17 +00:00
if ( aiming_at_sprite )
2011-04-14 20:48:08 +00:00
correct_sprite_yoffset ( osearchwall ) ;
2006-11-16 03:02:42 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( B ) ) // B (clip Blocking xor) (3D)
2006-11-16 03:02:42 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_SPRITE )
2006-07-04 00:46:24 +00:00
{
sprite [ searchwall ] . cstat ^ = 1 ;
// sprite[searchwall].cstat &= ~256;
// sprite[searchwall].cstat |= ((sprite[searchwall].cstat&1)<<8);
2010-05-18 05:14:17 +00:00
message ( " Sprite %d blocking bit %s " , searchwall , ONOFF ( sprite [ searchwall ] . cstat & 1 ) ) ;
2006-07-04 00:46:24 +00:00
asksave = 1 ;
}
2011-04-28 21:28:33 +00:00
else if ( AIMING_AT_WALL_OR_MASK | | AIMING_AT_CEILING_OR_FLOOR )
2006-07-04 00:46:24 +00:00
{
2011-04-28 21:28:33 +00:00
# ifdef YAX_ENABLE
if ( AIMING_AT_CEILING_OR_FLOOR & & yax_getbunch ( searchsector , AIMING_AT_FLOOR ) > = 0 )
2006-07-04 00:46:24 +00:00
{
2011-04-28 21:28:33 +00:00
SECTORFLD ( searchsector , stat , AIMING_AT_FLOOR ) ^ = 512 ;
message ( " Sector %d's %s blocking bit %s " , searchsector , typestr [ searchstat ] ,
ONOFF ( SECTORFLD ( searchsector , stat , AIMING_AT_FLOOR ) & 512 ) ) ;
asksave = 1 ;
2006-07-04 00:46:24 +00:00
}
2011-04-28 21:28:33 +00:00
else
# endif
{
wall [ searchwall ] . cstat ^ = 1 ;
// wall[searchwall].cstat &= ~64;
if ( ( wall [ searchwall ] . nextwall > = 0 ) & & ! eitherSHIFT )
{
NEXTWALL ( searchwall ) . cstat & = ~ ( 1 + 64 ) ;
NEXTWALL ( searchwall ) . cstat | = ( wall [ searchwall ] . cstat & 1 ) ;
}
2010-05-18 05:14:17 +00:00
2011-09-18 11:55:31 +00:00
message ( " Wall %d blocking bit %s%s " , searchwall , ONOFF ( wall [ searchwall ] . cstat & 1 ) ,
eitherSHIFT ? " (one-sided) " : " " ) ;
2011-04-28 21:28:33 +00:00
asksave = 1 ;
}
2006-07-04 00:46:24 +00:00
}
}
2011-02-13 21:48:22 +00:00
// N (set "spritenoshade" bit)
if ( PRESSED_KEYSC ( N ) & & ! eitherCTRL & & ! keystatus [ KEYSC_QUOTE ] )
{
if ( AIMING_AT_SPRITE )
{
2014-02-22 19:38:51 +00:00
sprite [ searchwall ] . cstat ^ = CSTAT_SPRITE_NOSHADE ;
message ( " Sprite %d spritenoshade bit: %s " , searchwall ,
ONOFF ( sprite [ searchwall ] . cstat & CSTAT_SPRITE_NOSHADE ) ) ;
2011-02-13 21:48:22 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( T ) ) // T (transluscence for sprites/masked walls)
2006-07-04 00:46:24 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_CEILING_OR_FLOOR ) //Set masked/transluscent ceilings/floors
2006-07-04 00:46:24 +00:00
{
2010-05-18 05:14:17 +00:00
int32_t nexti [ 4 ] = { 128 , 256 , 384 , 0 } ;
2012-11-15 14:28:18 +00:00
uint16_t * stat = & AIMED_CEILINGFLOOR ( stat ) ;
2011-04-22 22:48:06 +00:00
const char * statmsg [ 4 ] = { " normal " , " masked " , " translucent " , " translucent (2) " } ;
2010-05-18 05:14:17 +00:00
i = ( * stat & ( 128 + 256 ) ) > > 7 ;
i = nexti [ i ] ;
* stat & = ~ ( 128 + 256 ) ;
* stat | = i ;
2011-04-22 22:48:06 +00:00
message ( " Sector %d's %s made %s. " , searchsector , typestr [ searchstat ] , statmsg [ i > > 7 ] ) ;
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
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2006-07-04 00:46:24 +00:00
{
2011-04-22 22:48:06 +00:00
int32_t olotag = AIMED ( lotag ) ;
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " %s lotag: " , Typestr_wss [ searchstat ] ) ;
AIMED ( lotag ) = getnumber256 ( tempbuf , AIMED ( lotag ) , BTAG_MAX , 0 ) ;
2011-04-22 22:48:06 +00:00
if ( olotag ! = AIMED ( lotag ) )
asksave = 1 ;
2006-07-04 00:46:24 +00:00
}
}
2008-09-06 06:22:31 +00:00
else if ( eitherCTRL )
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_SPRITE )
2010-02-13 21:46:42 +00:00
TextEntryMode ( searchwall ) ;
2008-09-06 06:22:31 +00:00
}
2006-07-04 00:46:24 +00:00
else
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_SPRITE )
2006-07-04 00:46:24 +00:00
{
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 ;
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_MASKWALL )
2006-07-04 00:46:24 +00:00
{
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 )
{
2010-05-18 05:14:17 +00:00
NEXTWALL ( searchwall ) . cstat & = ~ ( 128 + 512 ) ;
NEXTWALL ( searchwall ) . cstat | = ( wall [ searchwall ] . cstat & ( 128 + 512 ) ) ;
2006-07-04 00:46:24 +00:00
}
asksave = 1 ;
}
}
}
2006-04-13 20:47:06 +00:00
2011-04-22 22:48: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 ;
2010-05-18 05:14:17 +00:00
if ( eitherCTRL & & ! eitherSHIFT & & ( bstatus & 1 ) & & AIMING_AT_CEILING_OR_FLOOR )
2006-07-20 05:02:55 +00:00
{
2009-02-19 16:47:54 +00:00
mousex = 0 ; mskip = 1 ;
2010-02-13 21:46:42 +00:00
if ( mousey )
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
}
2010-02-13 21:46:42 +00:00
tsign = 0 ;
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
{
tsign - = ( PRESSED_KEYSC ( LBRACK ) | | ( mouseaction & & mousey < 0 ) ) ; // [
tsign + = ( PRESSED_KEYSC ( RBRACK ) | | ( mouseaction & & mousey > 0 ) ) ; // ]
}
2010-02-13 21:46:42 +00:00
if ( tsign )
2008-05-16 19:51:38 +00:00
{
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2011-04-14 20:48:08 +00:00
int16_t bunchnum , othersidesect = 0 ;
2011-03-23 17:41:01 +00:00
# endif
2008-05-16 19:51:38 +00:00
if ( eitherALT )
2006-07-20 05:02:55 +00:00
{
2010-05-18 05:14:17 +00:00
int32_t ns = wall [ searchwall ] . nextsector , sx = wall [ searchwall ] . x , sy = wall [ searchwall ] . y ;
if ( ns > = 0 & & ! mouseaction )
2010-02-13 21:46:42 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_CEILING | | ( tsign < 0 & & AIMING_AT_WALL_OR_MASK ) )
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2011-04-14 20:48:08 +00:00
if ( YAXCHK ( ( bunchnum = yax_getbunch ( searchsector , YAX_CEILING ) ) < 0 | |
2011-05-29 23:10:51 +00:00
( othersidesect = yax_is121 ( bunchnum , 1 ) ) > = 0 ) & &
( bunchnum < 0 | | YAXSLOPECHK ( searchsector , othersidesect ) ) )
2011-03-23 17:41:01 +00:00
# endif
2009-07-04 09:28:21 +00:00
{
2010-05-18 05:14:17 +00:00
alignceilslope ( searchsector , sx , sy , getceilzofslope ( ns , sx , sy ) ) ;
2011-04-14 20:48:08 +00:00
# ifdef YAX_ENABLE
if ( bunchnum > = 0 )
setslope ( othersidesect , 1 , sector [ searchsector ] . ceilingheinum ) ;
# endif
2010-05-18 05:14:17 +00:00
message ( " Sector %d align ceiling to wall %d " , searchsector , searchwall ) ;
2009-07-04 09:28:21 +00:00
}
2011-03-23 17:41:01 +00:00
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_FLOOR | | ( tsign > 0 & & AIMING_AT_WALL_OR_MASK ) )
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2011-04-14 20:48:08 +00:00
if ( YAXCHK ( ( bunchnum = yax_getbunch ( searchsector , YAX_FLOOR ) ) < 0 | |
2011-05-29 23:10:51 +00:00
( othersidesect = yax_is121 ( bunchnum , 0 ) ) > = 0 ) & &
( bunchnum < 0 | | YAXSLOPECHK ( searchsector , othersidesect ) ) )
2011-03-23 17:41:01 +00:00
# endif
2009-07-04 09:28:21 +00:00
{
2010-05-18 05:14:17 +00:00
alignflorslope ( searchsector , sx , sy , getflorzofslope ( ns , sx , sy ) ) ;
2011-04-14 20:48:08 +00:00
# ifdef YAX_ENABLE
if ( bunchnum > = 0 )
setslope ( othersidesect , 0 , sector [ searchsector ] . floorheinum ) ;
# endif
2010-05-18 05:14:17 +00:00
message ( " Sector %d align floor to wall %d " , searchsector , searchwall ) ;
2009-07-04 09:28:21 +00:00
}
2010-05-18 05:14:17 +00:00
}
2008-05-16 19:51:38 +00:00
}
else
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_CEILING_OR_FLOOR )
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2011-04-14 20:48:08 +00:00
if ( YAXCHK ( ( bunchnum = yax_getbunch ( searchsector , AIMING_AT_FLOOR ) ) < 0 | |
2011-05-29 23:10:51 +00:00
( othersidesect = yax_is121 ( bunchnum , AIMING_AT_CEILING ) ) > = 0 ) & &
( bunchnum < 0 | | YAXSLOPECHK ( searchsector , othersidesect ) ) )
2011-03-23 17:41:01 +00:00
# endif
2006-04-13 20:47:06 +00:00
{
2011-09-01 18:37:53 +00:00
int32_t oldslope = ( AIMED_CEILINGFLOOR ( stat ) & 2 ) ? AIMED_CEILINGFLOOR ( heinum ) : 0 ;
int32_t newslope = clamp ( oldslope + tsign * i , - BHEINUM_MAX , BHEINUM_MAX ) ;
2010-05-18 05:14:17 +00:00
2011-04-14 20:48:08 +00:00
setslope ( searchsector , AIMING_AT_FLOOR , newslope ) ;
# ifdef YAX_ENABLE
if ( bunchnum > = 0 )
setslope ( othersidesect , ! AIMING_AT_FLOOR , newslope ) ;
# endif
2011-03-23 17:41:01 +00:00
silentmessage ( " Sector %d %s slope = %d " , searchsector ,
typestr [ searchstat ] , AIMED_CEILINGFLOOR ( heinum ) ) ;
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
}
2010-02-13 21:46:42 +00:00
2010-05-18 05:14:17 +00:00
if ( ( bstatus & 1 ) & & eitherSHIFT )
mskip = 1 ;
if ( ( bstatus & 1 ) & & eitherSHIFT & & AIMING_AT_CEILING_OR_FLOOR & & ( 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
2011-03-23 17:41:01 +00:00
stat = SECTORFLD ( searchsector , stat , AIMING_AT_FLOOR ) ;
2008-05-16 19:51:38 +00:00
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 ;
2010-05-18 05:14:17 +00:00
x2 = POINT2 ( fw ) . x , y2 = POINT2 ( fw ) . y ;
2008-05-16 19:51:38 +00:00
a = getangle ( x1 - x2 , y1 - y2 ) ;
}
2009-02-19 16:47:54 +00:00
mouseax + = mousex ; mouseay + = mousey ;
2011-03-23 17:41:01 +00:00
ma = getangle ( mouseax , mouseay ) ;
ma + = ang - a ;
2008-05-16 19:51:38 +00:00
i = stat ;
i = ( i & 0x4 ) + ( ( i > > 4 ) & 3 ) ;
if ( stat & 64 ) // align to first wall
switch ( i )
2009-07-04 09:28:21 +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 ;
2009-07-04 09:28:21 +00:00
}
2008-05-16 19:51:38 +00:00
else
switch ( i )
2009-07-04 09:28:21 +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 ;
2009-07-04 09:28:21 +00:00
}
2008-05-16 19:51:38 +00:00
2012-07-01 22:11:14 +00:00
a = ksqrt ( uhypsq ( mouseax , mouseay ) ) ;
2008-05-16 19:51:38 +00:00
if ( a )
{
2010-05-18 05:14:17 +00:00
int32_t mult = ( stat & 8 ) ? 8192 : 8192 * 2 ;
x1 = - a * sintable [ ( ma + 2048 ) & 2047 ] / mult ;
y1 = - a * sintable [ ( ma + 1536 ) & 2047 ] / mult ;
2008-05-16 19:51:38 +00:00
if ( x1 | | y1 )
{
2010-05-18 05:14:17 +00:00
mouseax = 0 ;
mouseay = 0 ;
if ( AIMING_AT_CEILING_OR_FLOOR )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
changedir = 1 - 2 * ( x1 < 0 ) ;
x1 = klabs ( x1 ) ;
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-05-12 23:31:13 +00:00
if ( yax_getbunch ( searchsector , AIMING_AT_FLOOR ) < 0 )
# endif
2010-05-18 05:14:17 +00:00
while ( x1 - - )
AIMED_CEILINGFLOOR ( xpanning ) = changechar ( AIMED_CEILINGFLOOR ( xpanning ) , changedir , 0 , 0 ) ;
changedir = 1 - 2 * ( y1 < 0 ) ;
y1 = klabs ( y1 ) ;
while ( y1 - - )
AIMED_CEILINGFLOOR ( ypanning ) = changechar ( AIMED_CEILINGFLOOR ( ypanning ) , changedir , 0 , 0 ) ;
2011-03-23 17:41:01 +00:00
silentmessage ( " Sector %d %s panning: %d, %d " , searchsector , typestr [ searchstat ] ,
AIMED_CEILINGFLOOR ( xpanning ) , AIMED_CEILINGFLOOR ( ypanning ) ) ;
asksave = 1 ;
2008-05-16 19:51:38 +00:00
}
}
}
2010-05-18 05:14:17 +00:00
mousex = 0 ;
mousey = 0 ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
2008-05-16 19:51:38 +00:00
smooshyalign = keystatus [ KEYSC_gKP5 ] ;
2011-02-05 17:16:15 +00:00
repeatpanalign = eitherSHIFT | | eitherALT ;
2008-05-16 19:51:38 +00:00
2010-05-18 05:14:17 +00:00
////////////////////
2008-05-16 19:51:38 +00:00
updownunits = 1 ;
mouseaction = 0 ;
2010-05-18 05:14:17 +00:00
if ( ! mouseb )
{
mouseax = 0 ;
mouseay = 0 ;
}
2011-03-08 23:02:38 +00:00
if ( ( bstatus & 1 ) & & ! AIMING_AT_CEILING_OR_FLOOR )
2008-05-16 19:51:38 +00:00
{
if ( eitherSHIFT )
{
mskip = 1 ;
2010-05-18 05:14:17 +00:00
if ( mousex )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
mouseaction = 1 ;
mouseax + = mousex ;
2011-03-08 23:02:38 +00:00
updownunits = klabs ( mouseax / 2 ) ;
2010-05-18 05:14:17 +00:00
if ( updownunits )
mouseax = 0 ;
2008-05-16 19:51:38 +00:00
}
}
2009-07-25 20:16:22 +00:00
else if ( eitherCTRL & & ! eitherALT )
2009-02-19 16:47:54 +00:00
{
mskip = 1 ;
2010-05-18 05:14:17 +00:00
if ( mousex )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
mouseaction = 2 ;
repeatpanalign = 0 ;
updownunits = klabs ( mouseax + = mousex ) / ( 16 - 12 * AIMING_AT_SPRITE ) ;
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)
{
2010-05-18 05:14:17 +00:00
if ( repeatcountx = = 0 | | repeatcountx > 32 | | mouseaction )
2008-05-16 19:51:38 +00:00
{
changedir = 0 ;
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_gLEFT ] | | mousex > 0 )
changedir = - 1 ;
if ( keystatus [ KEYSC_gRIGHT ] | | mousex < 0 )
changedir = 1 ;
2008-05-16 19:51:38 +00:00
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK )
2008-05-16 19:51:38 +00:00
{
if ( repeatpanalign = = 0 )
{
2010-05-18 05:14:17 +00:00
while ( updownunits - - )
wall [ searchwall ] . xrepeat = changechar ( wall [ searchwall ] . xrepeat , changedir , smooshyalign , 1 ) ;
2011-04-28 21:28:33 +00:00
silentmessage ( " Wall %d repeat: %d, %d " , searchwall ,
2014-09-07 18:10:18 +00:00
TrackerCast ( wall [ searchwall ] . xrepeat ) ,
TrackerCast ( wall [ searchwall ] . yrepeat ) ) ;
2008-05-16 19:51:38 +00:00
}
else
{
2010-05-18 05:14:17 +00:00
int16_t w = SELECT_WALL ( ) ;
2008-05-16 19:51:38 +00:00
if ( mouseaction )
{
2011-03-08 23:02:38 +00:00
i = wall [ w ] . cstat ;
i & = ( 8 | 256 ) ;
2010-05-18 05:14:17 +00:00
2011-03-08 23:02:38 +00:00
if ( i = = 8 | | i = = 256 )
2010-05-18 05:14:17 +00:00
changedir * = - 1 ;
if ( eitherCTRL )
updownunits * = 8 ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
while ( updownunits - - )
wall [ w ] . xpanning = changechar ( wall [ w ] . xpanning , changedir , smooshyalign , 0 ) ;
2014-09-07 18:10:18 +00:00
silentmessage ( " Wall %d panning: %d, %d " , w ,
TrackerCast ( wall [ w ] . xpanning ) , TrackerCast ( wall [ w ] . ypanning ) ) ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
asksave = 1 ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_CEILING_OR_FLOOR )
2008-05-16 19:51:38 +00:00
{
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-03-23 17:41:01 +00:00
if ( YAXCHK ( yax_getbunch ( searchsector , AIMING_AT_FLOOR ) < 0 ) )
# endif
{
while ( updownunits - - )
AIMED_CEILINGFLOOR ( xpanning ) = changechar ( AIMED_CEILINGFLOOR ( xpanning ) , changedir , smooshyalign , 0 ) ;
silentmessage ( " Sector %d %s panning: %d, %d " , searchsector , typestr [ searchstat ] ,
AIMED_CEILINGFLOOR ( xpanning ) , AIMED_CEILINGFLOOR ( ypanning ) ) ;
asksave = 1 ;
}
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_SPRITE )
2008-05-16 19:51:38 +00:00
{
2009-04-11 20:25:11 +00:00
static int32_t sumxvect = 0 , sumyvect = 0 ;
2008-05-16 19:51:38 +00:00
if ( mouseaction = = 1 )
2010-08-26 13:50:09 +00:00
mouseaction_movesprites ( & sumxvect , & sumyvect , 1536 , mousex ) ;
2008-05-16 19:51:38 +00:00
else
{
2009-04-11 20:25:11 +00:00
sumxvect = sumyvect = 0 ;
2010-05-18 05:14:17 +00:00
if ( mouseaction = = 2 )
changedir * = - 1 ;
while ( updownunits - - )
sprite [ searchwall ] . xrepeat = changechar ( sprite [ searchwall ] . xrepeat , changedir , smooshyalign , 1 ) ;
2008-05-16 19:51:38 +00:00
if ( sprite [ searchwall ] . xrepeat < 4 )
sprite [ searchwall ] . xrepeat = 4 ;
2011-04-28 21:28:33 +00:00
silentmessage ( " Sprite %d repeat: %d, %d " , searchwall ,
2014-09-07 18:10:18 +00:00
TrackerCast ( sprite [ searchwall ] . xrepeat ) ,
TrackerCast ( sprite [ searchwall ] . yrepeat ) ) ;
2008-05-16 19:51:38 +00:00
}
}
asksave = 1 ;
repeatcountx = max ( 1 , repeatcountx - 2 ) ;
}
repeatcountx + = synctics ;
}
else
repeatcountx = 0 ;
2010-05-18 05:14:17 +00:00
////////////////////
2008-05-16 19:51:38 +00:00
updownunits = 1 ;
mouseaction = 0 ;
2010-05-18 05:14:17 +00:00
if ( ( bstatus & 1 ) & & ! AIMING_AT_CEILING_OR_FLOOR )
2008-05-16 19:51:38 +00:00
{
if ( eitherSHIFT )
{
mskip = 1 ;
2010-05-18 05:14:17 +00:00
if ( mousey )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
mouseaction = 1 ;
updownunits = klabs ( mousey ) ;
if ( ! AIMING_AT_SPRITE )
2014-09-30 04:14:21 +00:00
updownunits = klabs ( ( int32_t ) ( mousey * 128. / tilesiz [ wall [ searchwall ] . picnum ] . y ) ) ;
2008-05-16 19:51:38 +00:00
}
}
2009-07-25 20:16:22 +00:00
else if ( eitherCTRL & & ! eitherALT )
2009-02-19 16:47:54 +00:00
{
mskip = 1 ;
2010-05-18 05:14:17 +00:00
if ( mousey )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
mouseaction = 2 ;
repeatpanalign = 0 ;
mouseay + = mousey ;
updownunits = klabs ( mouseay ) / ( 32 - 28 * AIMING_AT_SPRITE ) ;
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
}
2010-05-18 05:14:17 +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)
{
2010-05-18 05:14:17 +00:00
if ( repeatcounty = = 0 | | repeatcounty > 32 | | mouseaction )
2008-05-16 19:51:38 +00:00
{
changedir = 0 ;
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_gUP ] | | mousey > 0 )
changedir = - 1 ;
if ( keystatus [ KEYSC_gDOWN ] | | mousey < 0 )
changedir = 1 ;
2008-05-16 19:51:38 +00:00
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK )
2008-05-16 19:51:38 +00:00
{
if ( repeatpanalign = = 0 )
{
2008-12-28 23:27:24 +00:00
while ( updownunits - - )
2010-05-18 05:14:17 +00:00
wall [ searchwall ] . yrepeat = changechar ( wall [ searchwall ] . yrepeat , changedir , smooshyalign , 1 ) ;
2011-04-28 21:28:33 +00:00
silentmessage ( " Wall %d repeat: %d, %d " , searchwall ,
2014-09-07 18:10:18 +00:00
TrackerCast ( wall [ searchwall ] . xrepeat ) ,
TrackerCast ( wall [ searchwall ] . yrepeat ) ) ;
2008-05-16 19:51:38 +00:00
}
else
{
2012-04-10 20:14:17 +00:00
int16_t w = SELECT_WALL ( ) ;
2009-04-26 20:51:00 +00:00
if ( mouseaction & & eitherCTRL )
updownunits * = 8 ;
2008-12-28 23:27:24 +00:00
while ( updownunits - - )
2010-05-18 05:14:17 +00:00
wall [ w ] . ypanning = changechar ( wall [ w ] . ypanning , changedir , smooshyalign , 0 ) ;
2014-09-07 18:10:18 +00:00
silentmessage ( " Wall %d panning: %d, %d " , w ,
TrackerCast ( wall [ w ] . xpanning ) , TrackerCast ( wall [ w ] . ypanning ) ) ;
2008-05-16 19:51:38 +00:00
}
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_CEILING_OR_FLOOR )
2008-05-16 19:51:38 +00:00
{
2011-03-23 17:41:01 +00:00
{
while ( updownunits - - )
AIMED_CEILINGFLOOR ( ypanning ) = changechar ( AIMED_CEILINGFLOOR ( ypanning ) , changedir , smooshyalign , 0 ) ;
silentmessage ( " Sector %d %s panning: %d, %d " , searchsector , typestr [ searchstat ] ,
AIMED_CEILINGFLOOR ( xpanning ) , AIMED_CEILINGFLOOR ( ypanning ) ) ;
asksave = 1 ;
}
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_SPRITE )
2008-05-16 19:51:38 +00:00
{
2009-04-11 20:25:11 +00:00
static int32_t sumxvect = 0 , sumyvect = 0 ;
2008-05-16 19:51:38 +00:00
if ( mouseaction = = 1 )
2010-08-26 13:50:09 +00:00
mouseaction_movesprites ( & sumxvect , & sumyvect , 2048 , mousey ) ;
2008-05-16 19:51:38 +00:00
else
{
2009-04-11 20:25:11 +00:00
sumxvect = sumyvect = 0 ;
2010-05-18 05:14:17 +00:00
while ( updownunits - - )
sprite [ searchwall ] . yrepeat = changechar ( sprite [ searchwall ] . yrepeat , changedir , smooshyalign , 1 ) ;
2008-05-16 19:51:38 +00:00
if ( sprite [ searchwall ] . yrepeat < 4 )
sprite [ searchwall ] . yrepeat = 4 ;
2011-04-28 21:28:33 +00:00
silentmessage ( " Sprite %d repeat: %d, %d " , searchwall ,
2014-09-07 18:10:18 +00:00
TrackerCast ( sprite [ searchwall ] . xrepeat ) ,
TrackerCast ( sprite [ searchwall ] . yrepeat ) ) ;
2008-05-16 19:51:38 +00:00
}
}
asksave = 1 ;
repeatcounty = max ( 1 , repeatcounty - 2 ) ;
}
repeatcounty + = synctics ;
}
else
repeatcounty = 0 ;
2010-05-18 05:14:17 +00:00
////////////////////
if ( PRESSED_KEYSC ( F11 ) ) //F11 - brightness
2008-05-16 19:51:38 +00:00
{
2010-08-02 18:59:59 +00:00
static int16_t brightness = - 1 ;
if ( brightness = = - 1 )
brightness = ( ( int16_t ) ( ( vid_gamma - 1.0 ) * 10.0 ) ) & 15 ;
2008-05-16 19:51:38 +00:00
2010-05-18 05:14:17 +00:00
brightness = brightness + ( 1 - 2 * eitherSHIFT ) ;
brightness & = 15 ;
2008-08-19 11:05:21 +00:00
2008-08-12 22:38:50 +00:00
vid_gamma = 1.0 + ( ( float ) brightness / 10.0 ) ;
2011-01-27 06:35:52 +00:00
setbrightness ( brightness , 0 , 0 ) ;
2010-05-18 05:14:17 +00:00
message ( " Brightness: %d/16 " , brightness + 1 ) ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( TAB ) ) //TAB
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
{
tempshade = AIMED_CF_SEL ( shade ) ;
temppal = AIMED_CF_SEL ( pal ) ;
templotag = AIMED_SEL ( lotag ) ;
temphitag = AIMED_SEL ( hitag ) ;
tempextra = AIMED_SEL ( extra ) ;
if ( AIMING_AT_WALL_OR_MASK )
{
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-04-22 22:48:06 +00:00
if ( yax_getnextwall ( searchwall , YAX_CEILING ) > = 0 )
templotag = 0 ;
if ( yax_getnextwall ( searchwall , YAX_FLOOR ) > = 0 )
tempextra = - 1 ;
# endif
2010-05-18 05:14:17 +00:00
temppicnum = AIMED_SELOVR_WALL ( picnum ) ;
tempxrepeat = AIMED_SEL_WALL ( xrepeat ) ;
2010-12-05 17:39:52 +00:00
tempxrepeat = max ( 1 , tempxrepeat ) ;
2010-05-18 05:14:17 +00:00
tempyrepeat = AIMED_SEL_WALL ( yrepeat ) ;
2011-05-12 23:31:13 +00:00
tempxpanning = AIMED_SEL_WALL ( xpanning ) ;
tempypanning = AIMED_SEL_WALL ( ypanning ) ;
2013-04-09 17:35:11 +00:00
# ifdef NEW_MAP_FORMAT
tempcstat = AIMED_SEL_WALL ( cstat ) ;
# else
2011-04-14 20:48:08 +00:00
tempcstat = AIMED_SEL_WALL ( cstat ) & ~ YAX_NEXTWALLBITS ;
2013-04-09 17:35:11 +00:00
# endif
2011-05-07 18:23:34 +00:00
templenrepquot = getlenbyrep ( wallength ( searchwall ) , tempxrepeat ) ;
2012-06-01 20:09:19 +00:00
tempsectornum = sectorofwall ( searchwall ) ;
2010-05-18 05:14:17 +00:00
}
else if ( AIMING_AT_CEILING_OR_FLOOR )
{
temppicnum = AIMED_CEILINGFLOOR ( picnum ) ;
tempvis = sector [ searchsector ] . visibility ;
tempxrepeat = AIMED_CEILINGFLOOR ( xpanning ) ;
tempyrepeat = AIMED_CEILINGFLOOR ( ypanning ) ;
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-03-23 17:41:01 +00:00
if ( yax_getbunch ( searchsector , AIMING_AT_FLOOR ) > = 0 )
2011-05-12 23:31:13 +00:00
tempxrepeat = 0 ;
2011-03-23 17:41:01 +00:00
# endif
2012-06-01 20:09:19 +00:00
2013-04-09 17:35:11 +00:00
# ifdef NEW_MAP_FORMAT
tempcstat = AIMED_CEILINGFLOOR ( stat ) ;
# else
tempcstat = AIMED_CEILINGFLOOR ( stat ) & ~ YAX_BIT ;
# endif
2012-06-01 20:09:19 +00:00
tempsectornum = searchsector ;
2010-05-18 05:14:17 +00:00
}
else if ( AIMING_AT_SPRITE )
{
temppicnum = sprite [ searchwall ] . picnum ;
tempxrepeat = sprite [ searchwall ] . xrepeat ;
tempyrepeat = sprite [ searchwall ] . yrepeat ;
tempcstat = sprite [ searchwall ] . cstat ;
tempxvel = sprite [ searchwall ] . xvel ;
tempyvel = sprite [ searchwall ] . yvel ;
tempzvel = sprite [ searchwall ] . zvel ;
2012-06-01 20:09:19 +00:00
tempsectornum = - 1 ;
2010-05-18 05:14:17 +00:00
}
somethingintab = searchstat ;
}
}
2011-04-22 22:48:06 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( ENTER ) ) // ' ENTER
{
if ( AIMED_SELOVR_PICNUM ! = temppicnum )
{
AIMED_SELOVR_PICNUM = temppicnum ;
asksave = 1 ;
}
if ( AIMING_AT_SPRITE )
correct_sprite_yoffset ( searchwall ) ;
message ( " Pasted picnum only " ) ;
}
2012-06-01 20:09:24 +00:00
else if ( keystatus [ KEYSC_SEMI ] & & PRESSED_KEYSC ( ENTER ) & & AIMING_AT_CEILING_OR_FLOOR ) / / ; ENTER
2012-06-01 20:09:19 +00:00
{
2012-06-01 20:09:24 +00:00
if ( ( unsigned ) tempsectornum > = ( unsigned ) numsectors )
{
message ( " Can't align sector %d's %s, have no reference sector " ,
searchsector , typestr [ searchstat ] ) ;
}
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2012-06-01 20:09:24 +00:00
else if ( yax_getbunch ( searchsector , AIMING_AT_FLOOR ) > = 0 )
{
yax_invalidop ( ) ;
}
2012-06-01 20:09:19 +00:00
# endif
2012-06-01 20:09:24 +00:00
else if ( tempsectornum = = searchsector )
{
message ( " Didn't align sector %d with itself as reference " , tempsectornum ) ;
}
else
2012-06-01 20:09:19 +00:00
{
// auto-align ceiling/floor
const int32_t refwall = sector [ tempsectornum ] . wallptr ;
const int32_t ourwall = sector [ searchsector ] . wallptr ;
const vec2_t vecw1 = WALLVEC_INITIALIZER ( refwall ) ;
const vec2_t vecw2 = WALLVEC_INITIALIZER ( ourwall ) ;
const vec2_t vecw2r90 = { - vecw2 . y , vecw2 . x } ; // v, rotated 90 deg CW
const int32_t bits = CEILINGFLOOR ( tempsectornum , stat ) & ( 64 + 32 + 16 + 8 + 4 ) ;
2012-06-20 20:55:03 +00:00
const int32_t tile = CEILINGFLOOR ( tempsectornum , picnum ) ;
2012-06-01 20:09:19 +00:00
if ( ( CEILINGFLOOR ( tempsectornum , stat ) & 64 ) = = 0 )
{
// world-aligned texture
2014-09-30 04:14:21 +00:00
if ( tilesiz [ tile ] . x < = 0 | | tilesiz [ tile ] . y < = 0 )
2012-06-01 20:09:24 +00:00
{
message ( " Can't align sector %d's %s, reference sector %d's has void tile " ,
searchsector , typestr [ searchstat ] , tempsectornum ) ;
}
else
{
// non-smooshed: 1 texel corresponds to 16 BUILD units
int32_t dx = ( wall [ ourwall ] . x - wall [ refwall ] . x ) < < 4 ;
int32_t dy = ( wall [ ourwall ] . y - wall [ refwall ] . y ) < < 4 ;
dx > > = ( ( picsiz [ tile ] & 15 ) - ! ! ( bits & 8 ) ) ;
dy > > = ( ( picsiz [ tile ] > > 4 ) - ! ! ( bits & 8 ) ) ;
2012-06-01 20:09:19 +00:00
2012-06-01 20:09:24 +00:00
CEILINGFLOOR ( searchsector , xpanning ) = CEILINGFLOOR ( tempsectornum , xpanning ) + dy ;
CEILINGFLOOR ( searchsector , ypanning ) = CEILINGFLOOR ( tempsectornum , ypanning ) + dx ;
CEILINGFLOOR ( searchsector , stat ) & = ~ ( 64 + 32 + 16 + 8 + 4 ) ;
CEILINGFLOOR ( searchsector , stat ) | = bits ;
message ( " Aligned sector %d's %s with sector %d's " ,
searchsector , typestr [ searchstat ] , tempsectornum ) ;
}
2012-06-01 20:09:19 +00:00
}
else
{
// firstwall-aligned texture
const int64_t a = lldotv2 ( & vecw1 , & vecw2 ) ;
const int64_t b = lldotv2 ( & vecw1 , & vecw2r90 ) ;
2012-06-20 20:55:03 +00:00
if ( a ! = 0 & & b ! = 0 )
2012-06-01 20:09:19 +00:00
{
message ( " Walls %d and %d are nether parallel nor perpendicular " ,
refwall , ourwall ) ;
}
else
{
// 0<-6<-3<-5<-0, 1<-7<-2<-4<-1 (mirrored/not mirrored separately)
static const int8_t prev3each [ 8 ] = { 5 , 4 , 7 , 6 , 2 , 3 , 0 , 1 } ;
const int32_t degang = 90 * ( b < 0 ) + 180 * ( a < 0 ) + 270 * ( b > 0 ) ;
int32_t i , tempbits = ( bits & 4 ) + ( ( bits > > 4 ) & 3 ) ;
//message("Wall %d is rotated %d degrees CW wrt wall %d", ourwall, degang, refwall);
CEILINGFLOOR ( searchsector , stat ) & = ~ ( 64 + 32 + 16 + 8 + 4 ) ;
for ( i = 0 ; i < degang / 90 ; i + + )
tempbits = prev3each [ tempbits ] ;
tempbits = ( tempbits & 4 ) + ( ( tempbits & 3 ) < < 4 ) ;
CEILINGFLOOR ( searchsector , stat ) | = 64 + ( bits & 8 ) + tempbits ;
2012-06-20 20:55:03 +00:00
{
const walltype * rw = & wall [ refwall ] , * rw2 = & POINT2 ( refwall ) ;
const walltype * ow = & wall [ ourwall ] , * ow2 = & POINT2 ( ourwall ) ;
int32_t intx , inty , sign12 , sign34 ;
if ( b ! = 0 ) // perpendicular
inflineintersect ( rw - > x , rw - > y , rw2 - > x , rw2 - > y , ow - > x , ow - > y , ow2 - > x , ow2 - > y ,
& intx , & inty , & sign12 , & sign34 ) ;
else // parallel
inflineintersect ( rw - > x , rw - > y , rw2 - > x , rw2 - > y ,
ow - > x , ow - > y , ow - > x + vecw2r90 . x , ow - > y + vecw2r90 . y ,
& intx , & inty , & sign12 , & sign34 ) ;
if ( sign12 = = 0 )
{
message ( " INTERNAL ERROR: Couldn't get intersection "
" of reference and alignee walls " ) ;
}
else
{
double dx = ( double ) ( rw - > x - intx ) * ( rw - > x - intx ) + ( double ) ( rw - > y - inty ) * ( rw - > y - inty ) ;
double dy = ( double ) ( ow - > x - intx ) * ( ow - > x - intx ) + ( double ) ( ow - > y - inty ) * ( ow - > y - inty ) ;
dx = - sign12 * sqrt ( dx ) * 16 ;
dy = sign34 * sqrt ( dy ) * 16 ;
if ( a < 0 | | b > 0 )
dx = - dx ;
dx / = 1 < < ( ( picsiz [ tile ] & 15 ) - ! ! ( bits & 8 ) ) ;
dy / = 1 < < ( ( picsiz [ tile ] > > 4 ) - ! ! ( bits & 8 ) ) ;
//initprintf("int=(%d,%d), dx=%.03f dy=%.03f\n", intx,inty, dx, dy);
CEILINGFLOOR ( searchsector , xpanning ) =
CEILINGFLOOR ( tempsectornum , xpanning ) + ( int32_t ) dx ;
CEILINGFLOOR ( searchsector , ypanning ) =
CEILINGFLOOR ( tempsectornum , ypanning ) + ( int32_t ) dy ;
message ( " %sAligned sector %d %s (firstwall-relative) with sector %d's " ,
( CEILINGFLOOR ( tempsectornum , stat ) & ( 32 + 16 + 4 ) ) ? " (TODO) " : " " ,
searchsector , typestr [ searchstat ] , tempsectornum ) ;
}
}
2012-06-01 20:09:19 +00:00
}
}
}
}
2011-04-22 22:48:06 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( ENTER ) ) // ENTER -- paste clipboard contents
2008-05-16 19:51:38 +00:00
{
if ( eitherSHIFT )
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK & & eitherCTRL ) //Ctrl-shift Enter (auto-shade)
2008-05-16 19:51:38 +00:00
{
2011-03-23 17:41:01 +00:00
int16_t daang ;
int32_t dashade [ 2 ] = { 127 , - 128 } ;
2010-05-18 05:14:17 +00:00
2008-05-16 19:51:38 +00:00
i = searchwall ;
do
{
2011-03-23 17:41:01 +00:00
dashade [ 0 ] = min ( dashade [ 0 ] , wall [ i ] . shade ) ;
dashade [ 1 ] = max ( dashade [ 1 ] , wall [ i ] . shade ) ;
2008-05-16 19:51:38 +00:00
i = wall [ i ] . point2 ;
}
while ( i ! = searchwall ) ;
2010-05-18 05:14:17 +00:00
daang = getangle ( POINT2 ( searchwall ) . x - wall [ searchwall ] . x , POINT2 ( searchwall ) . y - wall [ searchwall ] . y ) ;
2008-05-16 19:51:38 +00:00
i = searchwall ;
do
{
2010-05-18 05:14:17 +00:00
j = getangle ( POINT2 ( i ) . x - wall [ i ] . x , POINT2 ( i ) . y - wall [ i ] . y ) ;
k = ( j + 2048 - daang ) & 2047 ;
2008-05-16 19:51:38 +00:00
if ( k > 1024 )
k = 2048 - k ;
2010-05-18 05:14:17 +00:00
wall [ i ] . shade = dashade [ 0 ] + mulscale10 ( k , dashade [ 1 ] - dashade [ 0 ] ) ;
2008-05-16 19:51:38 +00:00
i = wall [ i ] . point2 ;
}
while ( i ! = searchwall ) ;
2010-05-18 05:14:17 +00:00
2011-03-23 17:41:01 +00:00
message ( " Auto-shaded wall %d's loop " , searchwall ) ;
asksave = 1 ;
2008-05-16 19:51:38 +00:00
}
else if ( somethingintab < 255 )
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2009-07-25 20:16:22 +00:00
{
2010-05-18 05:14:17 +00:00
AIMED_CF_SEL ( shade ) = tempshade ;
AIMED_CF_SEL ( pal ) = temppal ;
2011-04-22 22:48:06 +00:00
k = 0 ;
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_CEILING_OR_FLOOR )
{
if ( somethingintab = = SEARCH_CEILING | | somethingintab = = SEARCH_FLOOR )
2011-04-22 22:48:06 +00:00
k = 1 , sector [ searchsector ] . visibility = tempvis ;
2010-05-18 05:14:17 +00:00
}
2011-04-22 22:48:06 +00:00
message ( " Pasted shade+pal%s " , k ? " +visibility " : " " ) ;
2010-05-18 05:14:17 +00:00
asksave = 1 ;
2008-05-16 19:51:38 +00:00
}
}
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_WALL_OR_MASK & & eitherCTRL & & somethingintab < 255 ) //Either ctrl key
2008-05-16 19:51:38 +00:00
{
2011-03-23 17:41:01 +00:00
int32_t clipboard_has_wall = ( somethingintab = = SEARCH_WALL | | somethingintab = = SEARCH_MASKWALL ) ;
2008-05-16 19:51:38 +00:00
i = searchwall ;
do
{
wall [ i ] . picnum = temppicnum ;
wall [ i ] . shade = tempshade ;
wall [ i ] . pal = temppal ;
2010-05-18 05:14:17 +00:00
2011-03-23 17:41:01 +00:00
if ( clipboard_has_wall )
2008-05-16 19:51:38 +00:00
{
wall [ i ] . xrepeat = tempxrepeat ;
wall [ i ] . yrepeat = tempyrepeat ;
2011-05-12 23:31:13 +00:00
wall [ i ] . xpanning = tempxpanning ;
wall [ i ] . ypanning = tempypanning ;
2011-09-18 11:55:31 +00:00
wall [ i ] . cstat & = ~ ( 4 + 1 + 64 + 8 + 256 ) ;
wall [ i ] . cstat | = ( tempcstat & ( 4 + 1 + 64 + 8 + 256 ) ) ;
2011-05-12 23:31:13 +00:00
2010-12-05 17:39:52 +00:00
fixxrepeat ( i , templenrepquot ) ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
2008-05-16 19:51:38 +00:00
i = wall [ i ] . point2 ;
}
while ( i ! = searchwall ) ;
2010-05-18 05:14:17 +00:00
2011-04-22 22:48:06 +00:00
message ( " Pasted picnum+shade+pal%s to wall %d's loop " ,
clipboard_has_wall ? " +pixelwidth " : " " , searchwall ) ;
2010-05-18 05:14:17 +00:00
asksave = 1 ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_CEILING_OR_FLOOR & & eitherCTRL & & somethingintab < 255 ) //Either ctrl key
2008-05-16 19:51:38 +00:00
{
2011-04-22 22:48:06 +00:00
static const char * addnstr [ 4 ] = { " " , " +stat+panning " , " +stat " , " +stat + panning (some) " } ;
2011-03-23 17:41:01 +00:00
2011-04-22 22:48:06 +00:00
static int16_t sectlist [ MAXSECTORS ] ;
static uint8_t sectbitmap [ MAXSECTORS > > 3 ] ;
int32_t sectcnt , sectnum ;
2008-05-16 19:51:38 +00:00
2010-05-18 05:14:17 +00:00
i = searchsector ;
if ( CEILINGFLOOR ( i , stat ) & 1 )
2008-05-16 19:51:38 +00:00
{
2011-04-22 22:48:06 +00:00
// collect neighboring parallaxed sectors
bfirst_search_init ( sectlist , sectbitmap , & sectnum , MAXSECTORS , i ) ;
2008-05-16 19:51:38 +00:00
2011-04-22 22:48:06 +00:00
for ( sectcnt = 0 ; sectcnt < sectnum ; sectcnt + + )
for ( WALLS_OF_SECTOR ( sectlist [ sectcnt ] , j ) )
{
k = wall [ j ] . nextsector ;
if ( k > = 0 & & ( CEILINGFLOOR ( k , stat ) & 1 ) )
bfirst_search_try ( sectlist , sectbitmap , & sectnum , wall [ j ] . nextsector ) ;
}
k = 0 ;
for ( sectcnt = 0 ; sectcnt < sectnum ; sectcnt + + )
{
i = sectlist [ sectcnt ] ;
CEILINGFLOOR ( i , picnum ) = temppicnum ;
CEILINGFLOOR ( i , shade ) = tempshade ;
CEILINGFLOOR ( i , pal ) = temppal ;
if ( somethingintab = = SEARCH_CEILING | | somethingintab = = SEARCH_FLOOR )
{
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-04-22 22:48:06 +00:00
if ( yax_getbunch ( i , AIMING_AT_FLOOR ) > = 0 )
k | = 2 ;
else
2011-03-23 17:41:01 +00:00
# endif
2011-04-22 22:48:06 +00:00
{
CEILINGFLOOR ( i , xpanning ) = tempxrepeat ;
CEILINGFLOOR ( i , ypanning ) = tempyrepeat ;
k | = 1 ;
}
2013-04-09 17:35:11 +00:00
SET_PROTECT_BITS ( CEILINGFLOOR ( i , stat ) , tempcstat , YAX_BIT_PROTECT ) ;
2011-04-22 22:48:06 +00:00
}
2010-05-18 05:14:17 +00:00
}
2008-05-16 19:51:38 +00:00
2011-04-22 22:48:06 +00:00
message ( " Pasted picnum+shade+pal%s to parallaxed sector %ss " ,
addnstr [ k ] , typestr [ searchstat ] ) ;
asksave = 1 ;
}
# ifdef YAX_ENABLE
else
{
k = yax_getbunch ( searchsector , AIMING_AT_FLOOR ) ;
if ( k < 0 )
goto paste_ceiling_or_floor ;
j = ( somethingintab = = SEARCH_CEILING | | somethingintab = = SEARCH_FLOOR ) ;
2008-05-16 19:51:38 +00:00
2011-05-15 22:37:24 +00:00
for ( SECTORS_OF_BUNCH ( k , AIMING_AT_FLOOR , i ) )
2010-05-18 05:14:17 +00:00
{
2011-04-22 22:48:06 +00:00
SECTORFLD ( i , picnum , AIMING_AT_FLOOR ) = temppicnum ;
SECTORFLD ( i , shade , AIMING_AT_FLOOR ) = tempshade ;
SECTORFLD ( i , pal , AIMING_AT_FLOOR ) = temppal ;
if ( j )
2013-04-09 17:35:11 +00:00
SET_PROTECT_BITS ( SECTORFLD ( i , stat , AIMING_AT_FLOOR ) , tempcstat , YAX_BIT_PROTECT ) ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
2011-04-22 22:48:06 +00:00
message ( " Pasted picnum+shade+pal%s to sector %ss with bunchnum %d " ,
j ? " +stat " : " " , typestr [ searchstat ] , k ) ;
2008-05-16 19:51:38 +00:00
}
2011-04-22 22:48:06 +00:00
# endif
2008-05-16 19:51:38 +00:00
}
else if ( somethingintab < 255 )
{
2011-04-22 22:48:06 +00:00
// wall/overwall common:
if ( AIMING_AT_WALL_OR_MASK & & searchstat = = somethingintab & &
( ! AIMING_AT_WALL | | searchwall = = searchbottomwall ) )
2008-05-16 19:51:38 +00:00
{
2011-04-22 22:48:06 +00:00
wall [ searchwall ] . xrepeat = tempxrepeat ;
wall [ searchwall ] . yrepeat = tempyrepeat ;
2011-05-12 23:31:13 +00:00
wall [ searchwall ] . xpanning = tempxpanning ;
wall [ searchwall ] . ypanning = tempypanning ;
2010-05-18 05:14:17 +00:00
2012-12-18 22:40:49 +00:00
SET_PROTECT_BITS ( wall [ searchwall ] . cstat , tempcstat , ~ ( 4 + 1 + 64 + 8 + 256 ) ) ;
2011-04-22 22:48:06 +00:00
wall [ searchwall ] . hitag = temphitag ;
2011-04-14 20:48:08 +00:00
# ifdef YAX_ENABLE
2011-04-22 22:48:06 +00:00
if ( yax_getnextwall ( searchwall , YAX_CEILING ) = = - 1 )
2011-04-14 20:48:08 +00:00
# endif
2008-05-16 19:51:38 +00:00
wall [ searchwall ] . lotag = templotag ;
2011-04-14 20:48:08 +00:00
# ifdef YAX_ENABLE
2011-04-22 22:48:06 +00:00
if ( yax_getnextwall ( searchwall , YAX_FLOOR ) = = - 1 )
2011-04-14 20:48:08 +00:00
# endif
2008-05-16 19:51:38 +00:00
wall [ searchwall ] . extra = tempextra ;
2011-04-22 22:48:06 +00:00
fixxrepeat ( searchwall , templenrepquot ) ;
2016-06-05 04:46:28 +00:00
}
2011-09-18 11:55:31 +00:00
2011-04-22 22:48:06 +00:00
if ( AIMING_AT_WALL )
{
2014-05-30 19:39:08 +00:00
if ( searchisbottom )
SET_PROTECT_BITS ( wall [ searchbottomwall ] . cstat , tempcstat , ~ 256 ) ;
2011-04-22 22:48:06 +00:00
wall [ searchbottomwall ] . picnum = temppicnum ;
wall [ searchbottomwall ] . shade = tempshade ;
wall [ searchbottomwall ] . pal = temppal ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_MASKWALL )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
wall [ searchwall ] . overpicnum = temppicnum ;
if ( wall [ searchwall ] . nextwall > = 0 )
NEXTWALL ( searchwall ) . overpicnum = temppicnum ;
wall [ searchwall ] . shade = tempshade ;
wall [ searchwall ] . pal = temppal ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_CEILING_OR_FLOOR )
2008-05-16 19:51:38 +00:00
{
2011-04-22 22:48:06 +00:00
# ifdef YAX_ENABLE
paste_ceiling_or_floor :
# endif
2010-05-18 05:14:17 +00:00
AIMED_CEILINGFLOOR ( picnum ) = temppicnum ;
AIMED_CEILINGFLOOR ( shade ) = tempshade ;
AIMED_CEILINGFLOOR ( pal ) = temppal ;
if ( somethingintab = = SEARCH_CEILING | | somethingintab = = SEARCH_FLOOR )
2011-04-22 22:48:06 +00:00
{
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2011-04-22 22:48:06 +00:00
if ( yax_getbunch ( searchsector , AIMING_AT_FLOOR ) < 0 )
2011-03-23 17:41:01 +00:00
# endif
2011-04-22 22:48:06 +00:00
AIMED_CEILINGFLOOR ( xpanning ) = tempxrepeat ;
2011-05-12 23:31:13 +00:00
AIMED_CEILINGFLOOR ( ypanning ) = tempyrepeat ;
2013-04-09 17:35:11 +00:00
SET_PROTECT_BITS ( AIMED_CEILINGFLOOR ( stat ) , tempcstat , YAX_BIT_PROTECT | 2 ) ;
2010-05-18 05:14:17 +00:00
2008-05-16 19:51:38 +00:00
sector [ searchsector ] . visibility = tempvis ;
sector [ searchsector ] . lotag = templotag ;
sector [ searchsector ] . hitag = temphitag ;
sector [ searchsector ] . extra = tempextra ;
}
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_SPRITE )
2008-05-16 19:51:38 +00:00
{
sprite [ searchwall ] . picnum = temppicnum ;
2010-05-18 05:14:17 +00:00
2014-09-30 04:14:21 +00:00
if ( tilesiz [ temppicnum ] . x < = 0 | | tilesiz [ temppicnum ] . y < = 0 )
2008-05-16 19:51:38 +00:00
{
j = 0 ;
2009-02-19 16:47:54 +00:00
for ( k = 0 ; k < MAXTILES ; k + + )
2014-09-30 04:14:21 +00:00
if ( tilesiz [ k ] . x > 0 & & tilesiz [ k ] . y > 0 )
2008-05-16 19:51:38 +00:00
{
j = k ;
break ;
}
2009-07-04 09:28:21 +00:00
sprite [ searchwall ] . picnum = j ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
2008-05-16 19:51:38 +00:00
sprite [ searchwall ] . shade = tempshade ;
sprite [ searchwall ] . pal = temppal ;
2010-05-18 05:14:17 +00:00
if ( somethingintab = = SEARCH_SPRITE )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
sprite [ searchwall ] . xrepeat = max ( tempxrepeat , 1 ) ;
sprite [ searchwall ] . yrepeat = max ( tempyrepeat , 1 ) ;
2008-05-16 19:51:38 +00:00
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
}
2011-03-07 16:30:06 +00:00
else
correct_sprite_yoffset ( searchwall ) ;
2008-05-16 19:51:38 +00:00
}
2011-04-22 22:48:06 +00:00
2008-05-16 19:51:38 +00:00
message ( " Pasted clipboard " ) ;
2010-05-18 05:14:17 +00:00
asksave = 1 ;
2008-05-16 19:51:38 +00:00
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( C ) )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
if ( eitherALT ) // Alt-C picnum replacer
2008-05-16 19:51:38 +00:00
{
2011-04-22 22:48:06 +00:00
if ( ASSERT_AIMING & & somethingintab < 255 )
2008-05-16 19:51:38 +00:00
{
switch ( searchstat )
{
2010-02-13 21:46:42 +00:00
case SEARCH_WALL :
2009-07-25 20:16:22 +00:00
j = wall [ searchbottomwall ] . picnum ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numwalls ; i + + )
2010-05-18 05:14:17 +00:00
if ( wall [ i ] . picnum = = j )
wall [ i ] . picnum = temppicnum ;
2008-05-16 19:51:38 +00:00
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_CEILING :
case SEARCH_FLOOR :
2010-05-18 05:14:17 +00:00
j = AIMED_CEILINGFLOOR ( picnum ) ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2010-05-18 05:14:17 +00:00
if ( CEILINGFLOOR ( i , picnum ) = = j )
CEILINGFLOOR ( i , picnum ) = temppicnum ;
2008-05-16 19:51:38 +00:00
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_SPRITE :
2008-05-16 19:51:38 +00:00
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 )
2010-05-18 05:14:17 +00:00
if ( sprite [ i ] . picnum = = j )
2011-03-07 16:30:06 +00:00
{
2010-05-18 05:14:17 +00:00
sprite [ i ] . picnum = temppicnum ;
2011-03-07 16:30:06 +00:00
correct_sprite_yoffset ( i ) ;
}
2008-05-16 19:51:38 +00:00
break ;
2010-02-13 21:46:42 +00:00
case SEARCH_MASKWALL :
2008-05-16 19:51:38 +00:00
j = wall [ searchwall ] . overpicnum ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < numwalls ; i + + )
2010-05-18 05:14:17 +00:00
if ( wall [ i ] . overpicnum = = j )
wall [ i ] . overpicnum = temppicnum ;
2008-05-16 19:51:38 +00:00
break ;
2011-06-17 11:53:41 +00:00
default :
j = - 1 ;
break ;
2008-05-16 19:51:38 +00:00
}
2011-04-22 22:48:06 +00:00
2011-06-17 11:53:41 +00:00
if ( j > = 0 )
message ( " Replaced %ss with picnum %d to picnum %d " ,
2011-07-21 21:01:31 +00:00
typestr [ searchstat ] , j , temppicnum ) ;
2008-05-16 19:51:38 +00:00
asksave = 1 ;
}
}
2012-01-20 22:11:55 +00:00
else //C
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_SPRITE )
2008-05-16 19:51:38 +00:00
{
sprite [ searchwall ] . cstat ^ = 128 ;
2010-05-18 05:14:17 +00:00
message ( " Sprite %d center bit %s " , searchwall , ONOFF ( ( sprite [ searchwall ] . cstat & 128 ) ) ) ;
2008-05-16 19:51:38 +00:00
asksave = 1 ;
}
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( SLASH ) ) // /? Reset panning&repeat to 0
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
int16_t w = SELECT_WALL ( ) ;
2009-07-25 20:16:22 +00:00
wall [ w ] . xpanning = 0 ;
wall [ w ] . ypanning = 0 ;
wall [ w ] . xrepeat = 8 ;
wall [ w ] . yrepeat = 8 ;
2013-04-09 17:35:11 +00:00
# ifdef NEW_MAP_FORMAT
wall [ w ] . cstat = 0 ;
# else
2011-04-14 20:48:08 +00:00
wall [ w ] . cstat & = YAX_NEXTWALLBITS ;
2013-04-09 17:35:11 +00:00
# endif
2011-02-25 22:10:25 +00:00
fixrepeats ( searchwall ) ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_CEILING_OR_FLOOR )
2008-05-16 19:51:38 +00:00
{
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2013-05-30 18:10:45 +00:00
int16_t bunchnum = yax_getbunch ( searchsector , AIMING_AT_FLOOR ) ;
# if !defined NEW_MAP_FORMAY
if ( bunchnum < 0 )
# endif
2011-03-23 17:41:01 +00:00
# endif
AIMED_CEILINGFLOOR ( xpanning ) = 0 ;
2011-05-12 23:31:13 +00:00
AIMED_CEILINGFLOOR ( ypanning ) = 0 ;
2010-05-18 05:14:17 +00:00
AIMED_CEILINGFLOOR ( stat ) & = ~ 2 ;
AIMED_CEILINGFLOOR ( heinum ) = 0 ;
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2013-05-30 18:10:45 +00:00
if ( bunchnum > = 0 )
for ( SECTORS_OF_BUNCH ( bunchnum , ! AIMING_AT_FLOOR , i ) )
2011-05-07 18:23:34 +00:00
{
SECTORFLD ( i , stat , ! AIMING_AT_FLOOR ) & = ~ 2 ;
SECTORFLD ( i , heinum , ! AIMING_AT_FLOOR ) = 0 ;
}
2011-03-23 17:41:01 +00:00
# endif
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_SPRITE )
2008-05-16 19:51:38 +00:00
{
if ( eitherSHIFT )
sprite [ searchwall ] . xrepeat = sprite [ searchwall ] . yrepeat ;
else
{
sprite [ searchwall ] . xrepeat = 64 ;
sprite [ searchwall ] . yrepeat = 64 ;
}
2011-03-07 16:30:06 +00:00
correct_sprite_yoffset ( searchwall ) ;
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
{
message ( " %s's size and panning reset " , Typestr [ searchstat ] ) ;
asksave = 1 ;
}
2008-05-16 19:51:38 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( P ) ) // P (parallaxing sky)
2008-05-16 19:51:38 +00:00
{
if ( eitherCTRL )
{
2010-05-18 05:14:17 +00:00
parallaxtype = ( parallaxtype + 1 ) % 3 ;
message ( " Parallax type %d " , parallaxtype ) ;
2008-05-16 19:51:38 +00:00
}
else if ( eitherALT )
{
2010-05-18 05:14:17 +00:00
if ( ASSERT_AIMING )
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " %s pal: " , Typestr [ searchstat ] ) ;
2011-03-17 23:37:38 +00:00
getnumberptr256 ( tempbuf , & AIMED_CF_SEL ( pal ) , sizeof ( uint8_t ) , M32_MAXPALOOKUPS , 0 , NULL ) ;
2010-05-18 05:14:17 +00:00
asksave = 1 ;
2008-05-16 19:51:38 +00:00
}
}
else
{
2010-05-18 05:14:17 +00:00
if ( AIMING_AT_WALL_OR_MASK | | AIMING_AT_CEILING )
2008-05-16 19:51:38 +00:00
{
sector [ searchsector ] . ceilingstat ^ = 1 ;
2010-05-18 05:14:17 +00:00
message ( " Sector %d ceiling parallax bit %s " , searchsector , ONOFF ( sector [ searchsector ] . ceilingstat & 1 ) ) ;
2008-05-16 19:51:38 +00:00
asksave = 1 ;
}
2010-05-18 05:14:17 +00:00
else if ( AIMING_AT_FLOOR )
2008-05-16 19:51:38 +00:00
{
sector [ searchsector ] . floorstat ^ = 1 ;
2010-05-18 05:14:17 +00:00
message ( " Sector %d floor parallax bit %s " , searchsector , ONOFF ( sector [ searchsector ] . floorstat & 1 ) ) ;
2008-05-16 19:51:38 +00:00
asksave = 1 ;
}
}
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( D ) ) //Alt-D (adjust sprite[].clipdist)
2008-05-16 19:51:38 +00:00
{
2010-05-18 05:14:17 +00:00
if ( eitherALT & & AIMING_AT_SPRITE )
2011-04-28 21:28:33 +00:00
sprite [ searchwall ] . clipdist = getnumber256 ( " Sprite clipdist: " , sprite [ searchwall ] . clipdist , 255 , 0 ) ;
2008-05-16 19:51:38 +00:00
}
2009-09-16 22:24:24 +00:00
2010-05-02 23:27:30 +00:00
VM_OnEvent ( EVENT_KEYS3D , - 1 ) ;
2008-05-16 19:51:38 +00:00
} // end 3d
2012-11-03 19:32:39 +00:00
// returns: whether sprite is out of grid
static int32_t jump_to_sprite ( int32_t spritenum )
{
const spritetype * spr = & sprite [ spritenum ] ;
if ( pos . x > = - editorgridextent & & pos . x < = editorgridextent & &
pos . y > = - editorgridextent & & pos . y < = editorgridextent )
{
pos . x = spr - > x ;
pos . y = spr - > y ;
// BZ_MAX?
if ( pos . z > = - ( editorgridextent < < 4 ) & & pos . z < = editorgridextent < < 4 )
pos . z = spr - > z ;
ang = spr - > ang ;
if ( ( unsigned ) spr - > sectnum < ( unsigned ) numsectors )
cursectnum = spr - > sectnum ;
return 0 ;
}
return 1 ;
}
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
{
2012-11-03 19:32:39 +00:00
char did_wrap = 0 , outofgrid ;
2009-01-09 09:29:17 +00:00
int32_t i , j , k = 0 ;
2008-09-19 20:09:43 +00:00
2010-05-18 05:14:17 +00:00
dir = 1 - 2 * ( dir < 0 ) ;
for ( gs_cursprite + = dir ; ; gs_cursprite + = dir )
2008-09-19 20:09:43 +00:00
{
2010-05-18 05:14:17 +00:00
if ( gs_cursprite < 0 | | gs_cursprite > = MAXSPRITES )
2008-09-19 20:09:43 +00:00
{
2010-05-18 05:14:17 +00:00
if ( did_wrap )
break ;
2010-08-02 08:13:51 +00:00
2010-05-18 05:14:17 +00:00
did_wrap = 1 ;
gs_cursprite & = ( MAXSPRITES - 1 ) ;
2008-09-19 20:09:43 +00:00
}
2014-02-22 19:38:49 +00:00
if ( sprite [ gs_cursprite ] . statnum = = MAXSTATUS )
continue ;
2008-09-19 20:09:43 +00:00
for ( i = 0 ; i < 3 ; i + + )
2014-02-22 19:38:49 +00:00
for ( j = 0 ; j < 7 ; j + + )
2008-09-19 20:09:43 +00:00
{
2014-02-22 19:38:49 +00:00
if ( ! gs_spriteTagInterested [ i ] [ j ] )
continue ;
2008-09-19 20:09:43 +00:00
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 ;
2011-02-03 17:44:03 +00:00
case 5 : k = ( uint16_t ) sprite [ gs_cursprite ] . hitag ; break ;
case 6 : k = ( uint16_t ) sprite [ gs_cursprite ] . lotag ; break ;
2008-09-19 20:09:43 +00:00
}
}
2011-02-03 17:44:03 +00:00
else if ( i = = 1 )
2008-09-19 20:09:43 +00:00
{
switch ( j )
{
case 0 :
k = sprite [ gs_cursprite ] . cstat ;
2014-02-22 19:38:49 +00:00
k & = gs_spriteTagValue [ 1 ] [ j ] ;
2008-09-19 20:09:43 +00:00
break ;
case 1 : k = sprite [ gs_cursprite ] . shade ; break ;
case 2 : k = sprite [ gs_cursprite ] . pal ; break ;
2014-02-22 19:38:49 +00:00
case 3 : k = sprite [ gs_cursprite ] . blend ; break ;
case 4 :
k = gs_spriteTagValue [ 1 ] [ j ] ;
2008-09-19 20:09:43 +00:00
if ( k ! = sprite [ gs_cursprite ] . xrepeat & &
2009-07-04 09:28:21 +00:00
k ! = sprite [ gs_cursprite ] . yrepeat )
2008-09-19 20:09:43 +00:00
goto NEXTSPRITE ;
break ;
2014-02-22 19:38:49 +00:00
case 5 :
k = gs_spriteTagValue [ 1 ] [ j ] ;
2008-09-19 20:09:43 +00:00
if ( k ! = sprite [ gs_cursprite ] . xoffset & &
2009-07-04 09:28:21 +00:00
k ! = sprite [ gs_cursprite ] . yoffset )
2008-09-19 20:09:43 +00:00
goto NEXTSPRITE ;
break ;
2014-02-22 19:38:49 +00:00
case 6 : k = sprite [ gs_cursprite ] . picnum ; break ;
2008-09-19 20:09:43 +00:00
}
}
2011-02-03 17:44:03 +00:00
else if ( i = = 2 )
2008-09-19 20:09:43 +00:00
{
switch ( j )
{
case 0 : k = sprite [ gs_cursprite ] . ang ; break ;
2011-02-03 17:44:03 +00:00
case 1 : k = ( uint16_t ) sprite [ gs_cursprite ] . xvel ; break ;
case 2 : k = ( uint16_t ) sprite [ gs_cursprite ] . yvel ; break ;
case 3 : k = ( uint16_t ) sprite [ gs_cursprite ] . zvel ; break ;
case 4 : k = ( uint16_t ) sprite [ gs_cursprite ] . owner ; break ;
2008-09-19 20:09:43 +00:00
case 5 : k = sprite [ gs_cursprite ] . clipdist ; break ;
case 6 : k = sprite [ gs_cursprite ] . extra ; break ;
}
}
2014-02-22 19:38:49 +00:00
if ( k ! = gs_spriteTagValue [ i ] [ j ] )
goto NEXTSPRITE ;
2008-09-19 20:09:43 +00:00
}
2009-07-04 09:28:21 +00:00
// found matching sprite
2012-11-03 19:32:39 +00:00
outofgrid = jump_to_sprite ( gs_cursprite ) ;
2008-09-19 20:09:43 +00:00
2011-01-16 00:23:39 +00:00
printmessage16 ( " %s Sprite seach%s: found sprite %d%s " , dir < 0 ? " < " : " > " ,
did_wrap ? " (wrap) " : " " , gs_cursprite , outofgrid ? " (outside grid) " : " " ) ;
2009-07-04 09:28:21 +00:00
return ;
2008-09-19 20:09:43 +00:00
NEXTSPRITE :
2009-07-04 09:28:21 +00:00
;
2008-09-19 20:09:43 +00:00
}
printmessage16 ( " %s Sprite search: none found " , dir < 0 ? " < " : " > " ) ;
}
2012-06-01 20:09:00 +00:00
////////// KEY PRESS HANDLER IN 2D MODE //////////
2008-05-16 19:51:38 +00:00
static void Keys2d ( void )
{
2010-05-18 05:14:17 +00:00
int32_t i = 0 , j , k ;
int32_t smooshy , changedir ;
static int32_t repeatcnt [ 2 ] = { 0 , 0 } ; // was repeatcountx, repeatcounty
2011-01-16 00:23:39 +00:00
int32_t tcursectornum ;
2009-05-01 06:35:27 +00:00
2010-05-18 05:14:17 +00:00
// for(i=0;i<0x50;i++) if(keystatus[i]==1) Bsprintf(tempbuf,"key %d",i); printmessage16(tempbuf);
2008-05-16 19:51:38 +00:00
2011-01-16 00:23:39 +00:00
tcursectornum = - 1 ;
2009-05-01 06:35:27 +00:00
for ( i = 0 ; i < numsectors ; i + + )
2009-06-29 19:07:32 +00:00
{
2011-05-02 16:58:11 +00:00
YAX_SKIPSECTOR ( i ) ;
2011-05-23 22:42:39 +00:00
if ( inside_editor_curpos ( i ) = = 1 )
2008-05-16 19:51:38 +00:00
{
2011-01-16 00:23:39 +00:00
tcursectornum = i ;
2009-05-01 06:35:27 +00:00
break ;
2008-05-16 19:51:38 +00:00
}
2009-06-29 19:07:32 +00:00
}
2011-01-16 00:23:39 +00:00
searchsector = tcursectornum ;
2011-08-20 11:54:16 +00:00
# if M32_UNDO
2010-05-18 05:14:17 +00:00
if ( eitherCTRL & & PRESSED_KEYSC ( Z ) ) // CTRL+Z
2009-06-29 19:07:32 +00:00
{
if ( eitherSHIFT )
2008-06-01 01:57:01 +00:00
{
2009-06-29 19:07:32 +00:00
if ( map_undoredo ( 1 ) ) message ( " Nothing to redo! " ) ;
2012-03-17 11:35:16 +00:00
else message ( " Redo: restored revision %d " , map_revision - 1 ) ;
2008-06-01 01:57:01 +00:00
}
2009-06-29 19:07:32 +00:00
else
2008-06-01 01:57:01 +00:00
{
2009-06-29 19:07:32 +00:00
if ( map_undoredo ( 0 ) ) message ( " Nothing to undo! " ) ;
2012-03-17 11:35:16 +00:00
else message ( " Undo: restored revision %d " , map_revision - 1 ) ;
2008-06-01 01:57:01 +00:00
}
2009-06-29 19:07:32 +00:00
}
2011-08-20 11:54:16 +00:00
# endif
2009-06-29 19:07:32 +00:00
if ( keystatus [ KEYSC_TAB ] ) //TAB
{
2011-06-04 00:06:08 +00:00
if ( eitherCTRL )
{
g_fillCurSector = ! g_fillCurSector ;
2012-06-13 23:13:28 +00:00
silentmessage ( " Fill currently pointed-at sector: %s " , ONOFF ( g_fillCurSector ) ) ;
2011-10-31 19:49:43 +00:00
keystatus [ KEYSC_TAB ] = 0 ;
2011-06-04 00:06:08 +00:00
}
else if ( eitherSHIFT )
2010-08-17 20:00:44 +00:00
{
if ( pointhighlight > = 16384 )
{
drawgradient ( ) ;
showspritedata ( pointhighlight & 16383 , 0 ) ;
}
2011-01-16 00:23:39 +00:00
else if ( linehighlight > = 0 /* && ((bstatus&1) || sectorofwall(linehighlight)==tcursectornum)*/ )
2010-08-17 20:00:44 +00:00
{
drawgradient ( ) ;
showwalldata ( linehighlight , 0 ) ;
}
}
2011-01-16 00:23:39 +00:00
else if ( tcursectornum > = 0 )
2010-05-22 14:04:47 +00:00
{
drawgradient ( ) ;
2011-01-16 00:23:39 +00:00
showsectordata ( tcursectornum , 0 ) ;
2010-05-22 14:04:47 +00:00
}
2009-06-29 19:07:32 +00:00
}
2010-08-17 20:00:44 +00:00
else if ( ! ( keystatus [ KEYSC_F5 ] | keystatus [ KEYSC_F6 ] | keystatus [ KEYSC_F7 ] | keystatus [ KEYSC_F8 ] ) & & ! eitherSHIFT )
2009-06-29 19:07:32 +00:00
{
static int32_t counter = 0 ;
2010-05-19 10:02:35 +00:00
static int32_t omx = 0 , omy = 0 ;
2010-08-02 08:13:51 +00:00
/*
2011-02-27 19:13:44 +00:00
static int32_t opointhighlight , olinehighlight , ocursectornum ;
if ( pointhighlight = = opointhighlight & & linehighlight = = olinehighlight & & tcursectornum = = ocursectornum )
2010-08-02 08:13:51 +00:00
*/
2010-05-19 10:02:35 +00:00
if ( omx = = mousxplc & & omy = = mousyplc )
{
if ( counter < 6 )
counter + + ;
}
else if ( counter > 0 )
counter - - ;
2010-08-02 08:13:51 +00:00
2010-05-19 10:02:35 +00:00
omx = mousxplc ;
omy = mousyplc ;
2009-06-29 19:07:32 +00:00
2010-08-02 08:13:51 +00:00
/*
2011-02-27 19:13:44 +00:00
opointhighlight = pointhighlight ;
olinehighlight = linehighlight ;
ocursectornum = tcursectornum ;
2010-08-02 08:13:51 +00:00
*/
2009-06-29 19:07:32 +00:00
2010-09-06 23:08:35 +00:00
if ( totalclock < lastpm16time + 120 * 2 )
2010-12-19 22:47:10 +00:00
_printmessage16 ( " %s " , lastpm16buf ) ;
2010-09-06 23:08:35 +00:00
else if ( counter > = 2 & & totalclock > = 120 * 6 )
2009-05-01 06:35:27 +00:00
{
if ( pointhighlight > = 16384 )
{
i = pointhighlight - 16384 ;
2010-08-17 20:00:44 +00:00
showspritedata ( i , 1 ) ;
2010-05-18 05:14:17 +00:00
if ( sprite [ i ] . picnum = = SECTOREFFECTOR )
_printmessage16 ( " ^10%s " , SectorEffectorText ( i ) ) ;
}
2011-01-16 00:23:39 +00:00
else if ( linehighlight > = 0 & & ( ( bstatus & 1 ) | | sectorofwall ( linehighlight ) = = tcursectornum ) )
2010-08-17 20:00:44 +00:00
showwalldata ( linehighlight , 1 ) ;
2011-01-16 00:23:39 +00:00
else if ( tcursectornum > = 0 )
showsectordata ( tcursectornum , 1 ) ;
2010-05-18 05:14:17 +00:00
}
2009-06-29 19:07:32 +00:00
}
2008-09-03 10:47:19 +00:00
2010-05-18 05:14:17 +00:00
///__bigcomment__
2008-09-03 10:47:19 +00:00
2011-06-04 00:06:08 +00:00
if ( ( i = tcursectornum ) > = 0 & & g_fillCurSector & & ( hlsectorbitmap [ i > > 3 ] & ( 1 < < ( i & 7 ) ) ) = = 0 )
{
int32_t col = editorcolors [ 4 ] ;
# ifdef YAX_ENABLE
if ( yax_getbunch ( tcursectornum , YAX_FLOOR ) > = 0 )
col = editorcolors [ 12 ] ;
# endif
fillsector ( tcursectornum , col ) ;
}
2011-04-28 21:28:33 +00:00
# ifdef YAX_ENABLE
2011-05-23 22:42:39 +00:00
if ( eitherCTRL & & PRESSED_KEYSC ( U ) & & tcursectornum > = 0 ) // Ctrl-U: unlink bunch sectors
{
int16_t cf , fb = yax_getbunch ( tcursectornum , YAX_FLOOR ) ;
if ( fb > = 0 )
{
for ( SECTORS_OF_BUNCH ( fb , YAX_FLOOR , i ) )
2015-10-31 15:13:32 +00:00
fillsector_notrans ( i , editorcolors [ 11 ] ) ;
2011-05-23 22:42:39 +00:00
fade_editor_screen ( editorcolors [ 11 ] ) ;
if ( ask_if_sure ( " Clear all TROR extensions from marked sectors? " , 0 ) )
{
for ( cf = 0 ; cf < 2 ; cf + + )
for ( SECTORS_OF_BUNCH ( fb , cf , i ) )
yax_setbunch ( i , cf , - 1 ) ;
2011-12-04 21:20:31 +00:00
yax_update ( 0 ) ;
yax_updategrays ( pos . z ) ;
2011-05-23 22:42:39 +00:00
2011-12-04 21:20:31 +00:00
message ( " Cleared TROR bunch %d " , fb ) ;
asksave = 1 ;
}
2011-05-23 22:42:39 +00:00
}
}
2011-05-02 16:58:11 +00:00
if ( /*!m32_sideview &&*/ numyaxbunches > 0 )
2011-04-28 21:28:33 +00:00
{
2011-05-07 18:23:34 +00:00
int32_t zsign = 0 ;
2011-04-28 21:28:33 +00:00
if ( PRESSED_KEYSC ( PGDN ) | | ( eitherCTRL & & PRESSED_KEYSC ( DOWN ) ) )
zsign = 1 ;
else if ( PRESSED_KEYSC ( PGUP ) | | ( eitherCTRL & & PRESSED_KEYSC ( UP ) ) )
zsign = - 1 ;
if ( zsign )
{
2011-05-07 18:23:34 +00:00
int32_t bestzdiff = INT32_MAX , hiz = 0 , loz = 0 , bottomp = 0 ;
2011-04-28 21:28:33 +00:00
for ( i = 0 ; i < numsectors ; i + + )
{
2011-05-07 18:23:34 +00:00
if ( yax_getbunch ( i , YAX_FLOOR ) < 0 /*&& yax_getbunch(i, YAX_CEILING) < 0*/ )
2011-04-28 21:28:33 +00:00
continue ;
loz = min ( loz , sector [ i ] . floorz ) ;
hiz = max ( hiz , sector [ i ] . floorz ) ;
// TODO: see if at least one sector point inside sceeen
j = ( sector [ i ] . floorz - pos . z ) * zsign ;
if ( j > 0 & & j < bestzdiff )
bestzdiff = j ;
}
2011-05-08 20:12:16 +00:00
if ( bestzdiff = = INT32_MAX )
2011-05-02 16:58:11 +00:00
{
if ( zsign = = 1 )
bottomp = 1 , bestzdiff = ( hiz + ( 1024 < < 4 ) - pos . z ) ;
else
bestzdiff = pos . z - loz ;
}
2011-04-28 21:28:33 +00:00
2011-05-07 18:23:34 +00:00
pos . z + = zsign * bestzdiff ;
yax_updategrays ( pos . z ) ;
printmessage16 ( " Z position: %d%s " , pos . z ,
bottomp ? " (bottom) " : ( pos . z = = loz ? " (top) " : " " ) ) ;
updatesectorz ( pos . x , pos . y , pos . z , & cursectnum ) ;
}
}
2011-05-18 22:44:09 +00:00
if ( eitherCTRL & & PRESSED_KEYSC ( A ) )
{
2011-07-04 21:20:59 +00:00
if ( eitherALT )
{
showinnergray = ! showinnergray ;
2011-08-06 11:50:45 +00:00
printmessage16 ( " Display grayed out walls: %s " , ONOFF ( showinnergray ) ) ;
2011-07-04 21:20:59 +00:00
}
else
{
autogray = ! autogray ;
printmessage16 ( " Automatic grayout of plain sectors %s " , ONOFF ( autogray ) ) ;
yax_updategrays ( pos . z ) ;
}
2011-05-18 22:44:09 +00:00
}
2011-05-07 18:23:34 +00:00
# endif
// Ctrl-R set editor z range to hightlightsectors' c/f bounds
if ( eitherCTRL & & PRESSED_KEYSC ( R ) )
{
if ( highlightsectorcnt < = 0 )
{
editorzrange [ 0 ] = INT32_MIN ;
editorzrange [ 1 ] = INT32_MAX ;
printmessage16 ( " Reset Z range " ) ;
}
else
{
2011-05-08 20:12:16 +00:00
int32_t damin = INT32_MAX , damax = INT32_MIN ;
2011-05-07 18:23:34 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
2011-04-28 21:28:33 +00:00
{
2011-05-07 18:23:34 +00:00
damin = min ( damin , sector [ highlightsector [ i ] ] . ceilingz ) ;
damax = max ( damax , sector [ highlightsector [ i ] ] . floorz ) ;
}
2011-04-28 21:28:33 +00:00
2011-05-07 18:23:34 +00:00
if ( damin < damax )
{
editorzrange [ 0 ] = damin ;
editorzrange [ 1 ] = damax ;
printmessage16 ( " Set Z range to highlighted sector bounds (%d..%d) " ,
editorzrange [ 0 ] , editorzrange [ 1 ] ) ;
2011-04-28 21:28:33 +00:00
}
}
2011-05-07 18:23:34 +00:00
yax_updategrays ( pos . z ) ;
2011-04-28 21:28:33 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( T ) ) // T (tag)
2009-06-29 19:07:32 +00:00
{
char buffer [ 80 ] ;
2010-05-18 05:14:17 +00:00
if ( eitherCTRL ) //Ctrl-T
2008-09-03 10:47:19 +00:00
{
2011-04-17 17:01:20 +00:00
if ( eitherSHIFT )
showtags - - ;
else
showtags + + ;
showtags + = 3 ;
showtags % = 3 ;
printmessage16 ( " Show tags %s " , showtags < 2 ? ONOFF ( showtags ) : " LABELED " ) ;
2009-06-29 19:07:32 +00:00
}
2010-05-18 05:14:17 +00:00
else if ( eitherALT ) //ALT
2009-06-29 19:07:32 +00:00
{
if ( pointhighlight > = 16384 )
2008-09-03 10:47:19 +00:00
{
2009-06-29 19:07:32 +00:00
i = pointhighlight - 16384 ;
2011-04-17 17:01:20 +00:00
j = taglab_linktags ( 1 , i ) ;
j = 4 * ( j & 1 ) ;
2010-05-18 05:14:17 +00:00
Bsprintf ( buffer , " Sprite (%d) Lo-tag: " , i ) ;
2011-04-17 17:01:20 +00:00
sprite [ i ] . lotag = _getnumber16 ( buffer , sprite [ i ] . lotag , BTAG_MAX , 0 + j , sprite [ i ] . picnum = = SECTOREFFECTOR ?
2013-09-21 13:38:44 +00:00
& SectorEffectorTagText : NULL ) ;
2008-09-03 10:47:19 +00:00
}
2009-06-29 19:07:32 +00:00
else if ( linehighlight > = 0 )
2008-09-03 10:47:19 +00:00
{
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-04-14 20:48:08 +00:00
if ( yax_getnextwall ( linehighlight , YAX_CEILING ) > = 0 )
message ( " Can't change lotag in protected wall " ) ;
else
# endif
{
i = linehighlight ;
2011-04-17 17:01:20 +00:00
j = taglab_linktags ( 1 , i ) ;
j = 4 * ( j & 1 ) ;
2011-04-14 20:48:08 +00:00
Bsprintf ( buffer , " Wall (%d) Lo-tag: " , i ) ;
2011-04-17 17:01:20 +00:00
wall [ i ] . lotag = getnumber16 ( buffer , wall [ i ] . lotag , BTAG_MAX , 0 + j ) ;
2011-04-14 20:48:08 +00:00
}
2009-06-29 19:07:32 +00:00
}
}
else
{
2011-08-06 11:50:45 +00:00
if ( tcursectornum > = 0 )
{
Bsprintf ( buffer , " Sector (%d) Lo-tag: " , tcursectornum ) ;
sector [ tcursectornum ] . lotag =
2013-09-21 13:38:44 +00:00
_getnumber16 ( buffer , sector [ tcursectornum ] . lotag , BTAG_MAX , 0 , & ExtGetSectorType ) ;
2011-08-06 11:50:45 +00:00
}
2009-06-28 20:23:12 +00:00
}
2009-06-29 19:07:32 +00:00
}
2008-05-16 19:51:38 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F1 ) | | ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_TILDE ] ) ) //F1 or ' ~
2009-06-29 19:07:32 +00:00
{
// PK_
2010-05-18 05:14:17 +00:00
if ( numhelppages > 0 )
IntegratedHelp ( ) ;
else
printmessage16 ( " m32help.hlp invalid or not found! " ) ;
2009-06-29 19:07:32 +00:00
}
2008-05-16 19:51:38 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F2 ) )
2009-06-29 19:07:32 +00:00
if ( g_numsounds > 0 )
2010-11-27 22:12:24 +00:00
{
2009-06-29 19:07:32 +00:00
SoundDisplay ( ) ;
2010-11-27 22:12:24 +00:00
}
// F3: side view toggle (handled in build.c)
2008-05-16 19:51:38 +00:00
2010-05-18 05:14:17 +00:00
getpoint ( searchx , searchy , & mousxplc , & mousyplc ) ;
2009-06-29 19:07:32 +00:00
ppointhighlight = getpointhighlight ( mousxplc , mousyplc , ppointhighlight ) ;
2008-05-16 19:51:38 +00:00
2009-06-29 19:07:32 +00:00
if ( ( ppointhighlight & 0xc000 ) = = 16384 )
{
// sprite[ppointhighlight&16383].cstat ^= 1;
2010-05-18 05:14:17 +00:00
cursprite = ppointhighlight & 16383 ;
2009-06-29 19:07:32 +00:00
}
2009-06-28 20:23:12 +00:00
2010-05-22 14:04:47 +00:00
if ( keystatus [ KEYSC_F9 ] ) // F9 f1=3b
2011-08-09 16:03:56 +00:00
ShowFileText ( " sthelp.hlp " ) ;
2006-04-13 20:47:06 +00:00
2009-06-29 19:07:32 +00:00
/* start Mapster32 */
2008-12-30 03:41:21 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F4 ) )
2009-06-29 19:07:32 +00:00
{
showfirstwall = ! showfirstwall ;
2010-05-18 05:14:17 +00:00
message ( " Sector firstwall highlight %s " , showfirstwall ? " enabled " : " disabled " ) ;
2009-06-29 19:07:32 +00:00
}
2008-12-30 03:41:21 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( M ) ) // M (tag)
2009-06-29 19:07:32 +00:00
{
if ( eitherALT ) //ALT
2006-04-13 20:47:06 +00:00
{
2009-06-29 19:07:32 +00:00
if ( pointhighlight > = 16384 )
2006-04-13 20:47:06 +00:00
{
2009-06-29 19:07:32 +00:00
i = pointhighlight - 16384 ;
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " Sprite %d Extra: " , i ) ;
sprite [ i ] . extra = getnumber16 ( tempbuf , sprite [ i ] . extra , BTAG_MAX , 1 ) ;
2009-06-29 19:07:32 +00:00
}
else if ( linehighlight > = 0 )
{
2013-04-09 17:35:11 +00:00
# ifdef YAX_ENABLE__COMPAT
2011-04-14 20:48:08 +00:00
if ( yax_getnextwall ( linehighlight , YAX_FLOOR ) > = 0 )
message ( " Can't change extra in protected wall " ) ;
else
# endif
{
i = linehighlight ;
Bsprintf ( tempbuf , " Wall %d Extra: " , i ) ;
wall [ i ] . extra = getnumber16 ( tempbuf , wall [ i ] . extra , BTAG_MAX , 1 ) ;
}
2009-06-29 19:07:32 +00:00
}
}
else
{
2011-08-06 11:50:45 +00:00
if ( tcursectornum > = 0 )
{
Bsprintf ( tempbuf , " Sector %d Extra: " , tcursectornum ) ;
2016-06-05 04:46:28 +00:00
sector [ tcursectornum ] . extra = getnumber16 ( tempbuf , sector [ tcursectornum ] . extra , BTAG_MAX , 1 ) ;
2011-08-06 11:50:45 +00:00
}
2009-06-29 19:07:32 +00:00
}
}
2011-03-02 21:21:47 +00:00
if ( ! eitherCTRL & & PRESSED_KEYSC ( E ) ) // E (expand)
2009-06-29 19:07:32 +00:00
{
2011-08-06 11:50:45 +00:00
if ( tcursectornum > = 0 )
{
sector [ tcursectornum ] . floorstat ^ = 8 ;
message ( " Sector %d floor texture expansion bit %s " , tcursectornum ,
ONOFF ( sector [ tcursectornum ] . floorstat & 8 ) ) ;
asksave = 1 ;
}
2009-06-29 19:07:32 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( SLASH ) ) // / Reset panning&repeat to 0
2009-06-29 19:07:32 +00:00
{
if ( ( ppointhighlight & 0xc000 ) = = 16384 )
{
if ( eitherSHIFT )
sprite [ cursprite ] . xrepeat = sprite [ cursprite ] . yrepeat ;
2006-04-13 20:47:06 +00:00
else
2010-05-18 05:14:17 +00:00
sprite [ cursprite ] . xrepeat = sprite [ cursprite ] . yrepeat = 64 ;
asksave = 1 ;
2006-04-13 20:47:06 +00:00
}
2009-06-29 19:07:32 +00:00
else if ( graphicsmode ! = 0 )
2009-04-26 20:51:00 +00:00
{
2011-08-06 11:50:45 +00:00
i = tcursectornum ;
if ( i > = 0 )
{
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2011-08-06 11:50:45 +00:00
if ( yax_getbunch ( i , YAX_FLOOR ) < 0 )
2011-03-23 17:41:01 +00:00
# endif
2011-08-06 11:50:45 +00:00
sector [ i ] . floorxpanning = 0 ;
sector [ i ] . floorypanning = 0 ;
message ( " Sector %d floor panning reset " , i ) ;
asksave = 1 ;
}
2009-04-26 20:51:00 +00:00
}
2009-06-29 19:07:32 +00:00
}
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
for ( k = 0 ; k < 2 ; k + + ) // panning/repeat
2009-06-29 19:07:32 +00:00
{
2010-05-18 05:14:17 +00:00
if ( k = = 0 )
2010-06-27 10:08:58 +00:00
j = ( keystatus [ KEYSC_gLEFT ] < < 1 ) | keystatus [ KEYSC_gRIGHT ] ; // 4 & 6 (keypad 2D)
2010-05-18 05:14:17 +00:00
else
2010-06-27 10:08:58 +00:00
j = ( keystatus [ KEYSC_gUP ] < < 1 ) | keystatus [ KEYSC_gDOWN ] ; // 2 & 8 (keypad 2D)
2010-05-18 05:14:17 +00:00
if ( j )
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
smooshy = keystatus [ KEYSC_gKP5 ] ;
2009-06-29 19:07:32 +00:00
2010-05-18 05:14:17 +00:00
if ( repeatcnt [ k ] = = 0 | | repeatcnt [ k ] > 32 )
2008-12-30 03:41:21 +00:00
{
2010-05-18 05:14:17 +00:00
changedir = 1 - ( j & 2 ) ;
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
if ( ( ppointhighlight & 0xc000 ) = = 16384 & & ( sprite [ cursprite ] . cstat & 48 ) )
{
uint8_t * repeat = ( k = = 0 ) ? & sprite [ cursprite ] . xrepeat : & sprite [ cursprite ] . yrepeat ;
* repeat = max ( 4 , changechar ( * repeat , changedir , smooshy , 1 ) ) ;
2011-04-28 21:28:33 +00:00
silentmessage ( " Sprite %d repeat: %d, %d " , cursprite ,
2014-09-07 18:10:18 +00:00
TrackerCast ( sprite [ cursprite ] . xrepeat ) ,
TrackerCast ( sprite [ cursprite ] . yrepeat ) ) ;
2010-05-18 05:14:17 +00:00
}
else
{
2011-08-06 11:50:45 +00:00
i = tcursectornum ;
if ( i > = 0 )
2011-03-23 17:41:01 +00:00
# ifdef YAX_ENABLE
2011-05-12 23:31:13 +00:00
if ( k = = 1 | | yax_getbunch ( i , YAX_FLOOR ) < 0 )
2011-03-23 17:41:01 +00:00
# endif
2010-05-18 05:14:17 +00:00
{
uint8_t * panning = ( k = = 0 ) ? & sector [ i ] . floorxpanning : & sector [ i ] . floorypanning ;
* panning = changechar ( * panning , changedir , smooshy , 0 ) ;
2011-04-28 21:28:33 +00:00
silentmessage ( " Sector %d floor panning: %d, %d " , searchsector ,
2014-09-07 18:10:18 +00:00
TrackerCast ( sector [ i ] . floorxpanning ) ,
TrackerCast ( sector [ i ] . floorypanning ) ) ;
2010-05-18 05:14:17 +00:00
}
}
2009-06-28 20:23:12 +00:00
2010-05-18 05:14:17 +00:00
asksave = 1 ;
repeatcnt [ k ] = max ( 1 , repeatcnt [ k ] - 2 ) ;
2008-12-30 03:41:21 +00:00
}
2010-05-18 05:14:17 +00:00
repeatcnt [ k ] + = synctics ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
else
repeatcnt [ k ] = 0 ;
2009-06-29 19:07:32 +00:00
}
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( R ) ) // R (relative alignment, rotation)
2009-06-29 19:07:32 +00:00
{
if ( pointhighlight > = 16384 )
2012-06-01 20:09:00 +00:00
toggle_sprite_alignment ( cursprite ) ;
else if ( tcursectornum > = 0 & & graphicsmode )
2006-04-13 20:47:06 +00:00
{
2012-06-01 20:09:00 +00:00
sector [ tcursectornum ] . floorstat ^ = 64 ;
message ( " Sector %d floor texture relativity bit %s " , searchsector ,
ONOFF ( sector [ tcursectornum ] . floorstat & 64 ) ) ;
2009-06-29 19:07:32 +00:00
asksave = 1 ;
2006-04-13 20:47:06 +00:00
}
2009-06-29 19:07:32 +00:00
}
2006-04-13 20:47:06 +00:00
2009-06-29 19:07:32 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & keystatus [ KEYSC_S ] ) // ' S
{
if ( pointhighlight > = 16384 )
2006-04-13 20:47:06 +00:00
{
2009-06-29 19:07:32 +00:00
keystatus [ KEYSC_S ] = 0 ;
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " Sprite %d xrepeat: " , cursprite ) ;
sprite [ cursprite ] . xrepeat = getnumber16 ( tempbuf , sprite [ cursprite ] . xrepeat , 255 , 0 ) ;
Bsprintf ( tempbuf , " Sprite %d yrepeat: " , cursprite ) ;
sprite [ cursprite ] . yrepeat = getnumber16 ( tempbuf , sprite [ cursprite ] . yrepeat , 255 , 0 ) ;
2010-12-19 22:47:10 +00:00
printmessage16 ( " Sprite %d updated " , i ) ;
2006-04-16 03:42:36 +00:00
}
2009-06-29 19:07:32 +00:00
}
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( F ) ) // ' F
2009-06-29 19:07:32 +00:00
{
FuncMenu ( ) ;
}
2014-04-06 22:24:14 +00:00
# ifdef LUNATIC
else if ( keystatus [ KEYSC_SEMI ] & & PRESSED_KEYSC ( F ) ) / / ; F
{
LuaFuncMenu ( ) ;
}
# endif
2012-06-01 20:09:09 +00:00
else if ( ! eitherALT & & PRESSED_KEYSC ( F ) )
{
if ( pointhighlight < 16384 & & tcursectornum > = 0 & & graphicsmode )
toggle_cf_flipping ( tcursectornum , 1 ) ;
}
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
tsign = 0 ;
if ( PRESSED_KEYSC ( LBRACK ) ) // [ search backward
tsign = - 1 ;
if ( PRESSED_KEYSC ( RBRACK ) ) // ] search forward
tsign = + 1 ;
if ( tsign )
2009-06-29 19:07:32 +00:00
{
2012-11-03 19:32:39 +00:00
if ( eitherALT )
2011-01-16 00:23:39 +00:00
{
2012-11-03 19:32:39 +00:00
if ( numcorruptthings > 0 )
2011-01-16 00:23:39 +00:00
{
2012-11-03 19:32:39 +00:00
int32_t wrap = 0 , x , y , z ;
2011-01-16 00:23:39 +00:00
2012-11-03 19:32:39 +00:00
if ( curcorruptthing < 0 | | curcorruptthing > = numcorruptthings )
curcorruptthing = 0 ;
else
{
curcorruptthing + = tsign ;
wrap = ( curcorruptthing < 0 | | curcorruptthing > = numcorruptthings ) ;
curcorruptthing + = numcorruptthings ;
curcorruptthing % = numcorruptthings ;
}
2011-01-16 00:23:39 +00:00
2012-11-03 19:32:39 +00:00
k = corruptthings [ curcorruptthing ] ;
j = - 1 ;
switch ( k & CORRUPT_MASK )
2011-01-16 00:23:39 +00:00
{
2012-11-03 19:32:39 +00:00
case 0 :
printmessage16 ( " MAP LIMITS EXCEEDED! " ) ;
2013-04-09 17:35:14 +00:00
/* fall-through */
default :
k = 0 ;
2012-11-03 19:32:39 +00:00
break ;
case CORRUPT_SECTOR :
i = k & ( MAXSECTORS - 1 ) ;
j = 0 ;
x = wall [ sector [ i ] . wallptr ] . x ;
y = wall [ sector [ i ] . wallptr ] . y ;
z = getflorzofslope ( i , x , y ) ;
break ;
case CORRUPT_WALL :
i = k & ( MAXWALLS - 1 ) ;
j = 1 ;
x = wall [ i ] . x + ( wall [ wall [ i ] . point2 ] . x - wall [ i ] . x ) / 2 ;
y = wall [ i ] . y + ( wall [ wall [ i ] . point2 ] . y - wall [ i ] . y ) / 2 ;
z = getflorzofslope ( sectorofwall ( i ) , x , y ) ;
break ;
case CORRUPT_SPRITE :
i = k & ( MAXSPRITES - 1 ) ;
j = 2 ;
x = sprite [ i ] . x ;
y = sprite [ i ] . y ;
z = sprite [ i ] . z ;
break ;
}
if ( k )
{
static const char * secwalspr [ 3 ] = { " sector " , " wall " , " sprite " } ;
if ( x > = - editorgridextent & & x < = editorgridextent & &
y > = - editorgridextent & & y < = editorgridextent )
{
pos . x = x ;
pos . y = y ;
pos . z = z ;
2011-05-02 16:58:11 +00:00
# ifdef YAX_ENABLE
2012-11-03 19:32:39 +00:00
yax_updategrays ( pos . z ) ;
2011-05-02 16:58:11 +00:00
# endif
2012-11-03 19:32:39 +00:00
}
else x = editorgridextent + 1 ;
printmessage16 ( " #%d: %s Corrupt %s %d%s " , curcorruptthing + 1 , tsign < 0 ? " < " : " > " , secwalspr [ j ] ,
i , ( x = = editorgridextent + 1 ) ? " (outside grid) " : ( wrap ? " (wrap) " : " " ) ) ;
2011-01-16 00:23:39 +00:00
}
2012-11-03 19:32:39 +00:00
}
else
{
printmessage16 ( " Map has no corruptions, cannot cycle them. " ) ;
}
}
else if ( keystatus [ KEYSC_LSHIFT ] )
{
if ( pointhighlight & 16384 )
{
const int32_t refspritenum = pointhighlight & 16383 ;
const int32_t reftag = select_sprite_tag ( refspritenum ) ;
int32_t tmpspritenum = refspritenum ;
while ( reftag ! = INT32_MIN ) // if (reftag != INT32_MIN) while (1)
{
tmpspritenum + = tsign ;
if ( ( unsigned ) tmpspritenum > = MAXSPRITES )
2013-01-23 19:36:36 +00:00
tmpspritenum = ( tmpspritenum < 0 ) ? MAXSPRITES - 1 : 0 ;
2012-11-03 19:32:39 +00:00
if ( tmpspritenum = = refspritenum )
{
2014-07-28 06:44:37 +00:00
silentmessage ( " No other sprites with tag %d " , reftag ) ;
2012-11-03 19:32:39 +00:00
break ;
}
if ( reftag = = select_sprite_tag ( tmpspritenum ) )
{
int32_t oog = jump_to_sprite ( tmpspritenum ) ;
2011-01-16 00:23:39 +00:00
2013-01-23 19:36:36 +00:00
if ( ! oog )
{
// center cursor so that we can repeat this
searchx = halfxdim16 ;
searchy = midydim16 ;
}
2012-11-03 19:32:39 +00:00
2013-01-23 19:36:36 +00:00
silentmessage ( " %s sprite with tag %d: %d%s " , tsign > 0 ? " Next " : " Previous " ,
reftag , tmpspritenum , oog ? " (out of grid) " : " " ) ;
2012-11-03 19:32:39 +00:00
break ;
}
}
}
else
{
printmessage16 ( " No sprite higlighted, cannot cycle linking sprites. " ) ;
2011-01-16 00:23:39 +00:00
}
}
else if ( wallsprite = = 0 )
2011-03-08 23:02:38 +00:00
{
2010-05-18 05:14:17 +00:00
SearchSectors ( tsign ) ;
2011-03-08 23:02:38 +00:00
}
2009-09-16 22:24:24 +00:00
else if ( wallsprite = = 1 )
{
2010-05-18 05:14:17 +00:00
if ( ( tsign < 0 & & curwallnum > 0 ) | | ( tsign > 0 & & curwallnum < numwalls ) )
curwallnum + = tsign ;
for ( i = curwallnum ; i > = 0 & & i < numwalls ; i + = tsign )
{
if ( ( wall [ i ] . picnum = = wall [ curwall ] . picnum )
2010-08-02 08:13:51 +00:00
& & ( search_lotag = = 0 | | search_lotag = = wall [ i ] . lotag )
& & ( search_hitag = = 0 | | search_hitag = = wall [ i ] . hitag ) )
2010-05-18 05:14:17 +00:00
{
pos . x = wall [ i ] . x - ( wall [ i ] . x - POINT2 ( i ) . x ) / 2 ;
pos . y = wall [ i ] . y - ( wall [ i ] . y - POINT2 ( i ) . y ) / 2 ;
2011-01-16 00:23:39 +00:00
pos . z = getflorzofslope ( sectorofwall ( i ) , pos . x , pos . y ) ;
2010-05-18 05:14:17 +00:00
printmessage16 ( " %s Wall search: found " , tsign < 0 ? " < " : " > " ) ;
2009-09-16 22:24:24 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2009-09-16 22:24:24 +00:00
curwallnum - - ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
printmessage16 ( " %s Wall search: none found " , tsign < 0 ? " < " : " > " ) ;
2009-09-16 22:24:24 +00:00
}
else if ( wallsprite = = 2 )
2010-05-18 05:14:17 +00:00
DoSpriteSearch ( tsign ) ;
2009-06-29 19:07:32 +00:00
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( G ) ) // G (grid on/off)
2009-06-29 19:07:32 +00:00
{
2010-05-18 05:14:17 +00:00
if ( autogrid )
{
2011-03-08 23:02:38 +00:00
grid = 8 * eitherSHIFT ;
2010-05-18 05:14:17 +00:00
autogrid = 0 ;
}
else
2006-04-13 20:47:06 +00:00
{
2010-05-18 05:14:17 +00:00
grid + = ( 1 - 2 * eitherSHIFT ) ;
if ( grid = = - 1 | | grid = = 9 )
2009-06-28 20:23:12 +00:00
{
2010-05-18 05:14:17 +00:00
autogrid = 1 ;
2009-06-29 19:07:32 +00:00
grid = 0 ;
2009-06-28 20:23:12 +00:00
}
2006-04-13 20:47:06 +00:00
}
2011-03-08 23:02:38 +00:00
2009-06-29 19:07:32 +00:00
if ( autogrid )
2010-12-19 22:47:10 +00:00
printmessage16 ( " Grid size: 9 (autosize) " ) ;
2010-05-18 05:14:17 +00:00
else if ( ! grid )
2010-12-19 22:47:10 +00:00
printmessage16 ( " Grid off " ) ;
2010-05-18 05:14:17 +00:00
else
2010-12-19 22:47:10 +00:00
printmessage16 ( " Grid size: %d (%d units) " , grid , 2048 > > grid ) ;
2010-05-18 05:14:17 +00:00
}
2011-03-08 23:02:38 +00:00
2010-05-18 05:14:17 +00:00
if ( autogrid )
{
2015-07-11 23:07:47 +00:00
grid = - 1 ;
2015-07-08 03:34:42 +00:00
while ( grid + + < 7 )
{
if ( mulscale14 ( ( 2048 > > grid ) , zoom ) < = 16 )
break ;
}
2009-06-29 19:07:32 +00:00
}
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( L ) ) // ' L (set sprite/wall coordinates)
2009-06-29 19:07:32 +00:00
{
if ( pointhighlight > = 16384 )
2006-04-13 20:47:06 +00:00
{
2009-06-29 19:07:32 +00:00
i = pointhighlight - 16384 ;
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " Sprite %d x: " , i ) ;
sprite [ i ] . x = getnumber16 ( tempbuf , sprite [ i ] . x , editorgridextent - 1 , 1 ) ;
Bsprintf ( tempbuf , " Sprite %d y: " , i ) ;
sprite [ i ] . y = getnumber16 ( tempbuf , sprite [ i ] . y , editorgridextent - 1 , 1 ) ;
Bsprintf ( tempbuf , " Sprite %d z: " , i ) ;
2011-02-15 21:02:43 +00:00
sprite [ i ] . z = getnumber16 ( tempbuf , sprite [ i ] . z , BZ_MAX , 1 ) ;
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " Sprite %d angle: " , i ) ;
2011-02-15 21:02:43 +00:00
sprite [ i ] . ang = getnumber16 ( tempbuf , sprite [ i ] . ang , 2048 , 1 ) ;
sprite [ i ] . ang & = 2047 ;
2010-12-19 22:47:10 +00:00
printmessage16 ( " Sprite %d updated " , i ) ;
2006-04-13 20:47:06 +00:00
}
2011-03-02 21:21:47 +00:00
else if ( pointhighlight > = 0 )
2009-06-28 20:23:12 +00:00
{
2009-06-29 19:07:32 +00:00
i = linehighlight ;
j = wall [ i ] . x ;
k = wall [ i ] . y ;
2010-05-18 05:14:17 +00:00
Bsprintf ( tempbuf , " Wall %d x: " , i ) ;
j = getnumber16 ( tempbuf , j , editorgridextent , 1 ) ;
Bsprintf ( tempbuf , " Wall %d y: " , i ) ;
k = getnumber16 ( tempbuf , k , editorgridextent , 1 ) ;
2013-01-16 20:38:41 +00:00
dragpoint ( i , j , k , 0 ) ;
2010-12-19 22:47:10 +00:00
printmessage16 ( " Wall %d updated " , i ) ;
2006-04-13 20:47:06 +00:00
}
2009-06-29 19:07:32 +00:00
}
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( 3 ) ) // ' 3
2009-06-29 19:07:32 +00:00
{
2011-04-28 21:28:33 +00:00
onnames = ( onnames + 1 ) % M32_NUM_SPRITE_MODES ;
2010-12-19 22:47:10 +00:00
printmessage16 ( " Mode %d %s " , onnames , SpriteMode [ onnames ] ) ;
2009-06-29 19:07:32 +00:00
}
// Ver();
2006-04-13 20:47:06 +00:00
2010-05-18 05:14:17 +00:00
///__motorcycle___
2009-06-29 19:07:32 +00:00
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( 7 ) ) // ' 7 : swap hilo
2009-06-29 19:07:32 +00:00
{
2009-06-28 20:23:12 +00:00
2009-06-29 19:07:32 +00:00
if ( pointhighlight > = 16384 )
{
2010-05-18 05:14:17 +00:00
swapshort ( & sprite [ cursprite ] . lotag , & sprite [ cursprite ] . hitag ) ;
2010-12-19 22:47:10 +00:00
printmessage16 ( " Sprite %d tags swapped " , cursprite ) ;
2009-06-29 19:07:32 +00:00
}
else if ( linehighlight > = 0 )
2006-04-13 20:47:06 +00:00
{
2011-04-14 20:48:08 +00:00
# ifdef YAX_ENABLE
if ( yax_getnextwall ( linehighlight , YAX_CEILING ) > = 0 | | yax_getnextwall ( searchwall , YAX_FLOOR ) > = 0 )
message ( " Can't swap tags in protected wall " ) ;
else
# endif
{
swapshort ( & wall [ linehighlight ] . lotag , & wall [ linehighlight ] . hitag ) ;
printmessage16 ( " Wall %d tags swapped " , linehighlight ) ;
}
2006-04-13 20:47:06 +00:00
}
2009-06-29 19:07:32 +00:00
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( J ) ) // ' J
2009-06-29 19:07:32 +00:00
{
2011-04-28 21:28:33 +00:00
char dachars [ 4 ] = { ' s ' , ' w ' , ' i ' , ' c ' } ;
fade_editor_screen ( - 1 ) ;
i = editor_ask_function ( " Jump to (s)ector, (w)all, spr(i)te, or (c)oordinates? " , dachars , 4 ) ;
switch ( i )
{
case 0 :
if ( numsectors > 0 )
{
j = getnumber16 ( " Sector: " , 0 , numsectors - 1 , 0 + 8 ) ;
if ( j < 0 )
break ;
pos . x = wall [ sector [ j ] . wallptr ] . x ;
pos . y = wall [ sector [ j ] . wallptr ] . y ;
2011-05-02 16:58:11 +00:00
pos . z = sector [ j ] . floorz ;
2011-04-28 21:28:33 +00:00
printmessage16 ( " Current pos now on sector %d's first wall-point " , j ) ;
}
break ;
case 1 :
if ( numwalls > 0 )
{
j = getnumber16 ( " Wall: " , 0 , numwalls - 1 , 0 + 8 ) ;
if ( j < 0 )
break ;
2011-12-12 23:18:53 +00:00
pos . x = wall [ j ] . x + ( wall [ wall [ j ] . point2 ] . x - wall [ j ] . x ) / 4 ;
pos . y = wall [ j ] . y + ( wall [ wall [ j ] . point2 ] . y - wall [ j ] . y ) / 4 ;
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
pos . z = getflorzofslope ( sectorofwall ( j ) , pos . x , pos . y ) ;
printmessage16 ( " Current pos now on wall %d's midpoint " , j ) ;
2011-04-28 21:28:33 +00:00
}
break ;
case 2 :
j = getnumber16 ( " Sprite: " , 0 , MAXSPRITES - 1 , 0 + 8 ) ;
if ( j < 0 | | sprite [ j ] . statnum = = MAXSTATUS )
break ;
pos . x = sprite [ j ] . x ;
pos . y = sprite [ j ] . y ;
2011-05-02 16:58:11 +00:00
pos . z = sprite [ j ] . z ;
2011-04-28 21:28:33 +00:00
printmessage16 ( " Current pos now on sprite %d " , j ) ;
break ;
case 3 :
pos . x = getnumber16 ( " X-coordinate: " , pos . x , editorgridextent , 1 ) ;
pos . y = getnumber16 ( " Y-coordinate: " , pos . y , editorgridextent , 1 ) ;
printmessage16 ( " Current pos now (%d, %d) " , pos . x , pos . y ) ;
break ;
}
2011-05-02 16:58:11 +00:00
# ifdef YAX_ENABLE
yax_updategrays ( pos . z ) ;
# endif
2009-06-29 19:07:32 +00:00
}
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
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2008-12-23 23:27:53 +00:00
palette_t * edcol ;
2011-04-28 21:28:33 +00:00
/* blue */
2015-09-23 17:55:11 +00:00
vgapal16 [ 9 * 4 + 0 ] = 252 ;
vgapal16 [ 9 * 4 + 1 ] = 124 ;
vgapal16 [ 9 * 4 + 2 ] = 28 ;
2008-12-28 23:27:24 +00:00
2006-04-13 20:47:06 +00:00
/* orange */
2015-09-23 17:55:11 +00:00
vgapal16 [ 31 * 4 + 0 ] = 80 ; // blue
vgapal16 [ 31 * 4 + 1 ] = 180 ; // green
vgapal16 [ 31 * 4 + 2 ] = 240 ; // red
2006-04-13 20:47:06 +00:00
2015-11-14 23:40:59 +00:00
// UNUSED?
2015-09-23 17:55:11 +00:00
vgapal16 [ 39 * 4 + 0 ] = 144 ;
vgapal16 [ 39 * 4 + 1 ] = 212 ;
vgapal16 [ 39 * 4 + 2 ] = 252 ;
2006-04-13 20:47:06 +00:00
/* light yellow */
2015-09-23 17:55:11 +00:00
vgapal16 [ 22 * 4 + 0 ] = 204 ;
vgapal16 [ 22 * 4 + 1 ] = 252 ;
vgapal16 [ 22 * 4 + 2 ] = 252 ;
2006-04-13 20:47:06 +00:00
/* grey */
2015-09-23 17:55:11 +00:00
vgapal16 [ 23 * 4 + 0 ] = 180 ;
vgapal16 [ 23 * 4 + 1 ] = 180 ;
vgapal16 [ 23 * 4 + 2 ] = 180 ;
2006-04-13 20:47:06 +00:00
/* blue */
2015-09-23 17:55:11 +00:00
vgapal16 [ 24 * 4 + 0 ] = 204 ;
vgapal16 [ 24 * 4 + 1 ] = 164 ;
vgapal16 [ 24 * 4 + 2 ] = 48 ;
2006-04-13 20:47:06 +00:00
2015-09-23 17:55:11 +00:00
vgapal16 [ 32 * 4 + 0 ] = 240 ;
vgapal16 [ 32 * 4 + 1 ] = 200 ;
vgapal16 [ 32 * 4 + 2 ] = 84 ;
2008-09-01 07:15:16 +00:00
// grid color
2015-09-23 17:55:11 +00:00
vgapal16 [ 25 * 4 + 0 ] = 64 ;
vgapal16 [ 25 * 4 + 1 ] = 56 ;
vgapal16 [ 25 * 4 + 2 ] = 56 ;
2008-09-01 07:15:16 +00:00
2015-09-23 17:55:11 +00:00
vgapal16 [ 26 * 4 + 0 ] = 96 ;
vgapal16 [ 26 * 4 + 1 ] = 96 ;
vgapal16 [ 26 * 4 + 2 ] = 96 ;
2008-09-01 07:15:16 +00:00
2015-11-14 23:40:59 +00:00
// UNUSED?
2015-09-23 17:55:11 +00:00
vgapal16 [ 33 * 4 + 0 ] = 0 ; //60; // blue
vgapal16 [ 33 * 4 + 1 ] = 0 ; //120; // green
vgapal16 [ 33 * 4 + 2 ] = 192 ; //180; // red
2008-09-01 07:15:16 +00:00
2015-11-14 23:40:59 +00:00
// UNUSED?
2015-09-23 17:55:11 +00:00
vgapal16 [ 41 * 4 + 0 ] = 0 ; //96;
vgapal16 [ 41 * 4 + 1 ] = 0 ; //160;
vgapal16 [ 41 * 4 + 2 ] = 252 ; //192;
2008-09-01 07:15:16 +00:00
2008-12-23 23:27:53 +00:00
for ( i = 0 ; i < 256 ; i + + )
{
2015-11-14 23:40:57 +00:00
if ( editorcolors [ i ] = = 0 )
{
edcol = ( palette_t * ) & vgapal16 [ 4 * i ] ;
editorcolors [ i ] = getclosestcol_lim ( edcol - > b , edcol - > g , edcol - > r , 239 ) ;
}
2008-12-23 23:27:53 +00:00
}
2006-04-13 20:47:06 +00:00
}
2011-11-11 20:05:29 +00:00
int32_t ExtPreSaveMap ( void )
2006-04-13 20:47:06 +00:00
{
2011-11-11 20:05:29 +00:00
int32_t numfixedsprites ;
numfixedsprites = fixspritesectors ( ) ; //Do this before saving!
2012-10-01 17:52:30 +00:00
updatesectorz ( startpos . x , startpos . y , startpos . z , & startsectnum ) ;
2011-09-04 19:43:48 +00:00
if ( startsectnum < 0 )
2012-10-01 17:52:30 +00:00
updatesector ( startpos . x , startpos . y , & startsectnum ) ;
2011-09-04 19:43:48 +00:00
2011-11-11 20:05:29 +00:00
if ( fixmaponsave_walls )
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 + + )
2010-05-18 05:14:17 +00:00
if ( wall [ j ] . point2 < startwall )
startwall = wall [ j ] . point2 ;
2011-11-11 20:05:29 +00:00
if ( sector [ i ] . wallptr ! = startwall )
2014-11-25 21:08:58 +00:00
initprintf ( " Warning: set sector %d's wallptr to %d (was %d) \n " , i ,
2012-11-26 08:26:04 +00:00
TrackerCast ( sector [ i ] . wallptr ) , startwall ) ;
2007-01-30 02:04:14 +00:00
sector [ i ] . wallptr = startwall ;
}
2010-05-18 05:14:17 +00:00
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 ;
2010-05-18 05:14:17 +00:00
sector [ numsectors - 1 ] . wallnum = numwalls - sector [ numsectors - 1 ] . wallptr ;
2007-01-30 02:04:14 +00:00
2011-11-11 20:05:29 +00:00
# ifdef YAX_ENABLE
// setting redwalls from scratch would very likely wreak havoc with TROR maps
if ( numyaxbunches > 0 )
return numfixedsprites ;
# endif
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 + + )
2011-03-08 23:02:38 +00:00
checksectorpointer ( j , i ) ;
2007-01-30 02:04:14 +00:00
}
2006-04-13 20:47:06 +00:00
}
2011-11-11 20:05:29 +00:00
return numfixedsprites ;
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
{
2012-03-26 05:05:57 +00:00
const char * s = " Usage: mapster32 [files] [options] \n \n "
2013-11-03 04:02:23 +00:00
" -g [file.grp], -grp [file.grp] \t Load extra group file \n "
" -h [file.def] \t \t Load an alternate definitions file \n "
" -x [game.con] \t \t Load a custom CON script for getting sound definitions \n "
2012-03-26 05:05:57 +00:00
" -mh [file.def] \t \t Include additional definitions module \n "
" -mx [file.con] \t \t Include additional CON module for getting sound definitions \n "
2013-11-03 04:02:23 +00:00
" -j [dir], -game_dir [dir] \n "
2012-03-26 05:05:57 +00:00
" \t \t \t Adds a directory to the file path stack \n "
" -cachesize # \t \t Sets cache size, in Kb \n "
" -check \t \t \t Enables map pointer checking when saving \n "
# ifdef HAVE_CLIPSHAPE_FEATURE
" -clipmap [file.map] \t \t Load an additional clipping map for use with clipshape \n "
# endif
" -namesfile [file.h] \t \t Load a custom NAMES.H for tile names \n "
" -nocheck \t \t \t Disables map pointer checking when saving (default) \n " // kept for script compat
2012-11-25 04:26:37 +00:00
# if defined _WIN32 || (defined RENDERTYPESDL && ((defined __APPLE__ && defined OSX_STARTUPWINDOW) || defined HAVE_GTK2))
2012-03-26 05:05:57 +00:00
" -setup \t \t \t Displays the configuration dialog \n "
2007-02-05 01:33:08 +00:00
# endif
2012-03-26 05:05:57 +00:00
" -usecwd \t \t \t Read game data and configuration file from working directory \n "
" \n -?, -help, --help \t \t Display this help message and exit "
2009-07-04 09:28:21 +00:00
;
2011-03-04 18:47:06 +00:00
Bsprintf ( tempbuf , " Mapster32 %s %s " , VERSION , s_buildRev ) ;
wm_msgbox ( tempbuf , " %s " , s ) ;
2007-01-22 02:35:54 +00:00
}
2012-03-25 22:00:42 +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
2013-09-05 17:37:46 +00:00
# ifdef LUNATIC
2016-01-27 07:30:28 +00:00
char const * const * g_argv ;
2013-09-05 17:37:46 +00:00
# endif
2016-01-12 10:30:56 +00:00
static void G_CheckCommandLine ( int32_t argc , char const * const * 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 ;
2012-03-28 19:44:47 +00:00
const char * c , * k ;
2007-01-21 23:49:07 +00:00
2011-06-16 19:39:22 +00:00
mapster32_fullpath = argv [ 0 ] ;
2013-09-05 17:37:46 +00:00
# ifdef LUNATIC
g_argv = argv ;
# endif
2008-10-14 08:40:59 +00:00
2012-03-25 13:54:46 +00:00
# ifdef HAVE_CLIPSHAPE_FEATURE
2012-03-18 23:18:32 +00:00
// pre-form the default 10 clipmaps
for ( j = ' 0 ' ; j < = ' 9 ' ; + + j )
{
2012-03-25 13:54:46 +00:00
char clipshape [ 16 ] = " _clipshape0.map " ;
2012-03-18 23:18:32 +00:00
clipshape [ 10 ] = j ;
2014-05-30 00:02:19 +00:00
g_clipMapFiles = ( char * * ) Xrealloc ( g_clipMapFiles , ( g_clipMapFilesNum + 1 ) * sizeof ( char * ) ) ;
g_clipMapFiles [ g_clipMapFilesNum ] = Xstrdup ( clipshape ) ;
2012-03-18 23:18:32 +00:00
+ + g_clipMapFilesNum ;
}
2012-03-25 13:54:46 +00:00
# endif
2012-03-18 23:18:32 +00:00
2011-06-16 19:39:22 +00:00
if ( argc < = 1 )
return ;
2014-05-30 00:02:19 +00:00
lengths = ( int32_t * ) Xmalloc ( argc * sizeof ( int32_t ) ) ;
2011-06-16 19:39:22 +00:00
for ( j = 1 ; j < argc ; j + + )
2007-01-21 23:49:07 +00:00
{
2011-06-16 19:39:22 +00:00
lengths [ j ] = Bstrlen ( argv [ j ] ) ;
maxlen + = lengths [ j ] ;
}
2008-10-14 08:40:59 +00:00
2014-05-30 00:02:19 +00:00
testplay_addparam = ( char * ) Xmalloc ( maxlen + argc ) ;
2011-06-16 19:39:22 +00:00
testplay_addparam [ 0 ] = 0 ;
2008-10-14 08:40:59 +00:00
2011-06-16 19:39:22 +00:00
j = 0 ;
2008-09-28 21:48:31 +00:00
2011-06-16 19:39:22 +00:00
while ( i < argc )
{
2016-01-11 05:05:38 +00:00
c = argv [ i ] ;
2011-06-16 19:39:22 +00:00
if ( ( * c = = ' - ' )
2010-10-28 20:17:22 +00:00
# ifdef _WIN32
2011-06-16 19:39:22 +00:00
| | ( * c = = ' / ' )
2010-10-28 20:17:22 +00:00
# endif
)
2011-06-16 19:39:22 +00:00
{
if ( ! Bstrcasecmp ( c + 1 , " ? " ) | | ! Bstrcasecmp ( c + 1 , " help " ) | | ! Bstrcasecmp ( c + 1 , " -help " ) )
2007-01-21 23:49:07 +00:00
{
2011-06-16 19:39:22 +00:00
G_ShowParameterHelp ( ) ;
2014-06-13 09:02:37 +00:00
Bexit ( 0 ) ;
2011-06-16 19:39:22 +00:00
}
2007-02-05 01:33:08 +00:00
2014-07-28 06:42:28 +00:00
if ( ! Bstrcasecmp ( c + 1 , " addon " ) )
{
if ( argc > i + 1 )
{
g_usingAddon = Batoi ( argv [ i + 1 ] ) ;
if ( ! ( g_usingAddon > ADDON_NONE & & g_usingAddon < NUMADDONS ) )
g_usingAddon = ADDON_NONE ;
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
i + + ;
}
i + + ;
continue ;
}
2011-06-16 19:39:22 +00:00
if ( ! Bstrcasecmp ( c + 1 , " g " ) | | ! Bstrcasecmp ( c + 1 , " grp " ) )
{
if ( argc > i + 1 )
2007-07-04 09:15:08 +00:00
{
2011-06-16 19:39:22 +00:00
G_AddGroup ( argv [ i + 1 ] ) ;
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2007-07-04 09:15:08 +00:00
i + + ;
}
2011-06-16 19:39:22 +00:00
i + + ;
continue ;
}
2007-07-04 09:15:08 +00:00
2011-06-16 19:39:22 +00:00
if ( ! Bstrcasecmp ( c + 1 , " game_dir " ) )
{
if ( argc > i + 1 )
2007-01-22 03:10:09 +00:00
{
2012-03-28 19:43:21 +00:00
Bstrncpyz ( g_modDir , argv [ i + 1 ] , sizeof ( g_modDir ) ) ;
2012-03-25 22:00:42 +00:00
G_AddPath ( argv [ i + 1 ] ) ;
2008-11-26 22:51:56 +00:00
2011-06-16 19:39:22 +00:00
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2007-01-22 03:10:09 +00:00
i + + ;
}
2011-06-16 19:39:22 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " cachesize " ) )
{
if ( argc > i + 1 )
2011-05-23 18:07:45 +00:00
{
2011-06-16 19:39:22 +00:00
int32_t sz = atoi_safe ( argv [ i + 1 ] ) ;
if ( sz > = 16 < < 10 & & sz < = 1024 < < 10 )
2011-05-23 18:07:45 +00:00
{
2011-06-16 19:39:22 +00:00
g_maxCacheSize = sz < < 10 ;
initprintf ( " Cache size: %dkB \n " , sz ) ;
2011-05-23 18:07:45 +00:00
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2007-07-04 09:15:08 +00:00
}
i + + ;
2011-03-07 16:30:06 +00:00
}
2011-06-16 19:39:22 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " cfg " ) )
{
if ( argc > i + 1 )
2007-01-30 02:04:14 +00:00
{
2012-03-26 22:05:51 +00:00
Bstrncpyz ( setupfilename , argv [ i + 1 ] , sizeof ( setupfilename ) ) ;
2007-01-30 02:04:14 +00:00
i + + ;
}
2011-06-16 19:39:22 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " gamegrp " ) )
{
if ( argc > i + 1 )
2007-07-04 09:15:08 +00:00
{
2012-06-03 16:09:33 +00:00
clearGrpNamePtr ( ) ;
g_grpNamePtr = dup_filename ( argv [ i + 1 ] ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2011-06-16 19:39:22 +00:00
COPYARG ( i + 1 ) ;
2007-07-04 09:15:08 +00:00
i + + ;
}
2011-06-16 19:39:22 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " namesfile " ) )
{
g_namesFileName = argv [ i + 1 ] ;
i + + ;
continue ;
}
2013-11-03 04:02:23 +00:00
if ( ! Bstrcasecmp ( c + 1 , " x " ) )
{
if ( argc > i + 1 )
{
G_AddCon ( argv [ i + 1 ] ) ;
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
i + + ;
}
i + + ;
continue ;
}
2011-07-21 22:39:29 +00:00
if ( ! Bstrcasecmp ( c + 1 , " mx " ) )
{
if ( argc > i + 1 )
{
2013-11-03 04:02:23 +00:00
G_AddConModule ( argv [ i + 1 ] ) ;
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
i + + ;
}
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " h " ) )
{
if ( argc > i + 1 )
{
G_AddDef ( argv [ i + 1 ] ) ;
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2011-07-21 22:39:29 +00:00
i + + ;
}
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " mh " ) )
{
if ( argc > i + 1 )
{
2013-11-03 04:02:23 +00:00
G_AddDefModule ( argv [ i + 1 ] ) ;
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
i + + ;
}
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " j " ) )
{
if ( argc > i + 1 )
{
G_AddPath ( argv [ i + 1 ] ) ;
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2011-07-21 22:39:29 +00:00
i + + ;
}
i + + ;
continue ;
}
2012-03-25 13:54:46 +00:00
# ifdef HAVE_CLIPSHAPE_FEATURE
2012-03-18 08:50:41 +00:00
if ( ! Bstrcasecmp ( c + 1 , " clipmap " ) )
{
if ( argc > i + 1 )
{
2013-11-03 04:02:23 +00:00
G_AddClipMap ( argv [ i + 1 ] ) ;
COPYARG ( i ) ;
COPYARG ( i + 1 ) ;
2012-03-18 08:50:41 +00:00
i + + ;
}
i + + ;
continue ;
}
2012-03-25 13:54:46 +00:00
# endif
2011-06-16 19:39:22 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nm " ) | | ! Bstrcasecmp ( c + 1 , " ns " ) )
{
COPYARG ( i ) ;
i + + ;
continue ;
}
2012-06-03 16:09:33 +00:00
if ( ! Bstrcasecmp ( c + 1 , " nam " ) )
{
g_gameType = GAMEFLAG_NAM ;
COPYARG ( i ) ;
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " napalm " ) )
{
g_gameType = GAMEFLAG_NAM | GAMEFLAG_NAPALM ;
COPYARG ( i ) ;
i + + ;
continue ;
}
2011-06-16 19:39:22 +00:00
if ( ! Bstrcasecmp ( c + 1 , " ww2gi " ) )
{
2012-06-03 16:09:33 +00:00
g_gameType = GAMEFLAG_WW2GI ;
2011-06-16 19:39:22 +00:00
COPYARG ( i ) ;
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " check " ) )
{
2011-11-11 20:05:29 +00:00
initprintf ( " Map wall checking on save enabled \n " ) ;
fixmaponsave_walls = 1 ;
2011-06-16 19:39:22 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " nocheck " ) )
{
2011-11-11 20:05:29 +00:00
initprintf ( " Map wall checking on save disabled \n " ) ;
fixmaponsave_walls = 0 ;
2011-06-16 19:39:22 +00:00
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " noautoload " ) )
{
initprintf ( " Autoload disabled \n " ) ;
NoAutoLoad = 1 ;
COPYARG ( i ) ;
i + + ;
continue ;
}
if ( ! Bstrcasecmp ( c + 1 , " usecwd " ) )
{
usecwd = 1 ;
COPYARG ( i ) ;
i + + ;
continue ;
}
2008-12-04 00:31:16 +00:00
# if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
2011-06-16 19:39:22 +00:00
if ( ! Bstrcasecmp ( c + 1 , " forcegl " ) )
{
forcegl = 1 ;
i + + ;
continue ;
2007-01-21 23:49:07 +00:00
}
2011-06-16 19:39:22 +00:00
# endif
}
2007-01-21 23:49:07 +00:00
2011-06-16 19:39:22 +00:00
if ( ( * c = = ' - ' )
2010-10-28 20:17:22 +00:00
# ifdef _WIN32
2011-06-16 19:39:22 +00:00
| | ( * c = = ' / ' )
2010-10-28 20:17:22 +00:00
# endif
)
2011-06-16 19:39:22 +00:00
{
c + + ;
switch ( * c )
2007-01-21 23:49:07 +00:00
{
2011-06-16 19:39:22 +00:00
case ' h ' :
case ' H ' :
2007-01-21 23:49:07 +00:00
c + + ;
2011-06-16 19:39:22 +00:00
if ( * c )
2007-01-21 23:49:07 +00:00
{
2013-11-03 04:02:23 +00:00
G_AddDef ( c ) ;
2008-09-28 21:48:31 +00:00
COPYARG ( i ) ;
2007-01-21 23:49:07 +00:00
}
2011-06-16 19:39:22 +00:00
break ;
case ' j ' :
case ' J ' :
c + + ;
if ( ! * c ) break ;
2012-03-25 22:00:42 +00:00
G_AddPath ( c ) ;
2011-06-16 19:39:22 +00:00
COPYARG ( i ) ;
break ;
case ' g ' :
case ' G ' :
c + + ;
if ( ! * c ) break ;
G_AddGroup ( c ) ;
COPYARG ( i ) ;
break ;
case ' x ' :
case ' X ' :
c + + ;
2012-06-03 16:09:33 +00:00
if ( * c )
{
2013-11-03 04:02:23 +00:00
G_AddCon ( c ) ;
COPYARG ( i ) ;
2012-06-03 16:09:33 +00:00
}
2011-06-16 19:39:22 +00:00
break ;
2007-01-21 23:49:07 +00:00
}
2011-06-16 19:39:22 +00:00
}
else
{
k = Bstrrchr ( c , ' . ' ) ;
if ( k )
2008-07-07 22:03:11 +00:00
{
2013-10-28 21:26:25 +00:00
if ( ! Bstrcasecmp ( k , " .map " ) )
{
B_SetBoardFileName ( argv [ i + + ] ) ;
continue ;
}
else if ( ! Bstrcasecmp ( k , " .grp " ) | | ! Bstrcasecmp ( k , " .zip " ) )
2008-07-07 22:03:11 +00:00
{
2011-06-16 19:39:22 +00:00
COPYARG ( i ) ;
G_AddGroup ( argv [ i + + ] ) ;
continue ;
}
else if ( ! Bstrcasecmp ( k , " .def " ) )
{
COPYARG ( i ) ;
2013-11-03 04:02:23 +00:00
G_AddDef ( argv [ i + + ] ) ;
2011-06-16 19:39:22 +00:00
continue ;
}
else if ( ! Bstrcasecmp ( k , " .con " ) )
{
COPYARG ( i ) ;
2013-11-03 04:02:23 +00:00
G_AddCon ( argv [ i + + ] ) ;
2011-06-16 19:39:22 +00:00
continue ;
2008-07-07 22:03:11 +00:00
}
}
2007-01-21 23:49:07 +00:00
}
2011-06-16 19:39:22 +00:00
i + + ;
}
2008-09-28 21:48:31 +00:00
2011-06-16 19:39:22 +00:00
Bfree ( lengths ) ;
2008-10-14 08:40:59 +00:00
2011-06-16 19:39:22 +00:00
if ( j > 0 )
{
testplay_addparam [ j - 1 ] = 0 ;
2014-05-30 00:02:19 +00:00
testplay_addparam = ( char * ) Xrealloc ( testplay_addparam , j * sizeof ( char ) ) ;
2007-01-21 23:49:07 +00:00
}
2011-06-16 19:39:22 +00:00
else
{
2015-09-23 17:55:31 +00:00
DO_FREE_AND_NULL ( testplay_addparam ) ;
2011-06-16 19:39:22 +00:00
}
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
2014-10-25 03:36:34 +00:00
# if defined(_WIN32) && defined(DEBUGGINGAIDS)
2012-05-28 18:15:19 +00:00
// See FILENAME_CASE_CHECK in cache1d.c
static int32_t check_filename_casing ( void )
{
return 1 ;
}
# endif
2016-01-12 10:30:56 +00:00
int32_t ExtPreInit ( int32_t argc , char const * const * argv )
2006-04-13 20:47:06 +00:00
{
2014-10-25 03:36:34 +00:00
# if defined(_WIN32) && defined(DEBUGGINGAIDS)
2012-05-28 18:15:19 +00:00
{
extern int32_t ( * check_filename_casing_fn ) ( void ) ;
check_filename_casing_fn = check_filename_casing ;
}
2008-07-27 11:35:41 +00:00
# endif
2014-07-28 06:42:28 +00:00
G_ExtPreInit ( argc , argv ) ;
2006-04-13 20:47:06 +00:00
OSD_SetLogFile ( " mapster32.log " ) ;
2011-03-04 18:47:06 +00:00
OSD_SetVersion ( " Mapster32 " " " VERSION , 0 , 2 ) ;
2014-05-31 12:26:13 +00:00
initprintf ( " Mapster32 %s %s %s \n " , VERSION , s_buildRev , s_buildInfo ) ;
initprintf ( " Compiled %s \n " , s_buildTimestamp ) ;
2009-06-28 20:23:12 +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 ) ;
2011-09-15 17:03:29 +00:00
2014-03-01 11:41:29 +00:00
OSD_ShowDisplay ( 0 ) ;
2006-04-13 20:47:06 +00:00
ExtUnInit ( ) ;
uninitengine ( ) ;
2012-06-03 16:08:27 +00:00
Bfflush ( NULL ) ;
2014-06-13 09:02:37 +00:00
Bexit ( 0 ) ;
2006-04-13 20:47:06 +00:00
}
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 ;
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 ;
}
2010-05-18 05:14:17 +00:00
else if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2007-02-28 09:12:41 +00:00
i = Batol ( parm - > parms [ 0 ] ) ;
2011-02-15 21:02:43 +00:00
if ( i > = 65536 & & i < = BXY_MAX )
2007-02-28 09:12:41 +00:00
{
editorgridextent = i ;
2007-12-12 17:42:14 +00:00
OSD_Printf ( " editorgridextent %d \n " , editorgridextent ) ;
2007-02-28 09:12:41 +00:00
}
2010-05-18 05:14:17 +00:00
else
2011-02-15 21:02:43 +00:00
OSD_Printf ( " editorgridextent: value out of range (65536 to %d) \n " , BXY_MAX ) ;
2010-05-18 05:14:17 +00:00
2007-02-28 09:12:41 +00:00
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 ;
2010-05-18 05:14:17 +00:00
Bstrcpy ( pathname , parm - > parms [ 0 ] ) ;
2007-04-17 05:54:12 +00:00
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 ;
2010-05-18 05:14:17 +00:00
Bstrcpy ( file , parm - > parms [ 0 ] ) ;
2007-04-17 05:54:12 +00:00
initgroupfile ( file ) ;
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_noclip ( const osdfuncparm_t * parm )
2007-04-17 05:54:12 +00:00
{
2008-03-22 10:23:57 +00:00
UNREFERENCED_PARAMETER ( parm ) ;
2011-09-16 19:17:48 +00:00
m32_clipping - - ;
if ( m32_clipping < 0 )
m32_clipping = 2 ;
OSD_Printf ( " Clipping %s \n " , m32_clipping = = 0 ? " disabled " :
( m32_clipping = = 1 ? " non-masks only " : " enabled " ) ) ;
2007-04-17 05:54:12 +00:00
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 " ,
2009-07-04 09:28:21 +00:00
testplay_addparam ? " \" " : " " ,
testplay_addparam ? testplay_addparam : " <empty> " ,
testplay_addparam ? " \" " : " " ) ;
2008-09-12 13:41:18 +00:00
return OSDCMD_OK ;
}
slen = Bstrlen ( parm - > parms [ 0 ] ) ;
if ( slen > 0 )
{
if ( ! testplay_addparam )
2014-05-30 00:02:19 +00:00
testplay_addparam = ( char * ) Xmalloc ( slen + 1 ) ;
2008-09-12 13:41:18 +00:00
else
2014-05-30 00:02:19 +00:00
testplay_addparam = ( char * ) Xrealloc ( testplay_addparam , slen + 1 ) ;
2008-09-12 13:41:18 +00:00
Bmemcpy ( testplay_addparam , parm - > parms [ 0 ] , slen ) ;
testplay_addparam [ slen ] = 0 ;
}
else
{
2015-09-23 17:55:31 +00:00
DO_FREE_AND_NULL ( testplay_addparam ) ;
2008-09-12 13:41:18 +00:00
}
return OSDCMD_OK ;
}
2008-10-09 21:09:16 +00:00
2008-05-15 03:16:38 +00:00
//PK vvv ------------
2013-01-16 20:38:52 +00:00
// FIXME: The way the different options are handled is horribly inconsistent.
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
{
2013-01-16 20:38:52 +00:00
const int32_t setval = ( 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 " ) )
{
2013-01-16 20:38:52 +00:00
if ( setval )
2008-05-15 03:16:38 +00:00
{
2011-02-21 23:08:21 +00:00
pk_turnaccel = atoi_safe ( parm - > parms [ 0 ] ) ;
2008-05-15 03:16:38 +00:00
pk_turnaccel = pk_turnaccel < = pk_turndecel ? ( pk_turndecel + 1 ) : pk_turnaccel ;
pk_turnaccel = pk_turnaccel > 256 ? 256 : pk_turnaccel ;
}
2013-01-16 20:38:52 +00:00
OSD_Printf ( " Turning acceleration+declaration is %d \n " , pk_turnaccel ) ;
return OSDCMD_OK ;
2008-05-15 03:16:38 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " pk_turndecel " ) )
2008-05-15 03:16:38 +00:00
{
2013-01-16 20:38:52 +00:00
if ( setval )
2008-05-15 03:16:38 +00:00
{
2011-02-21 23:08:21 +00:00
pk_turndecel = atoi_safe ( parm - > parms [ 0 ] ) ;
2008-05-15 03:16:38 +00:00
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 ;
}
2013-01-16 20:38:52 +00:00
OSD_Printf ( " Turning deceleration is %d \n " , pk_turndecel ) ;
return OSDCMD_OK ;
2008-05-15 03:16:38 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " pk_quickmapcycling " ) )
2008-05-15 03:16:38 +00:00
{
OSD_Printf ( " Quick map cycling ((LShift-)Ctrl-X): %s \n " ,
2009-07-04 09:28:21 +00:00
( quickmapcycling = ! quickmapcycling ) ? " enabled " : " disabled " ) ;
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2008-05-15 03:16:38 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " pk_uedaccel " ) )
2008-05-15 03:16:38 +00:00
{
2013-01-16 20:38:52 +00:00
if ( parm - > numparms > 1 )
return OSDCMD_SHOWHELP ;
if ( setval )
2015-08-08 07:04:14 +00:00
pk_uedaccel = clamp ( atoi_safe ( parm - > parms [ 0 ] ) , 0 , 5 ) ;
2010-08-11 22:37:45 +00:00
2013-01-16 20:38:52 +00:00
OSD_Printf ( " UnrealEd mouse navigation acceleration is %d \n " , pk_uedaccel ) ;
return OSDCMD_OK ;
2008-05-15 03:16:38 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " osd_tryscript " ) )
2010-05-22 23:41:18 +00:00
{
m32_osd_tryscript = ! m32_osd_tryscript ;
OSD_Printf ( " Try M32 script execution on invalid OSD command: %s \n " , m32_osd_tryscript ? " on " : " off " ) ;
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2010-05-22 23:41:18 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " sideview_reversehorizrot " ) )
2010-11-27 22:12:24 +00:00
{
sideview_reversehrot = ! sideview_reversehrot ;
OSD_Printf ( " Side view reverse horizontal rotation: %s \n " , sideview_reversehrot ? " on " : " off " ) ;
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2010-11-27 22:12:24 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " script_expertmode " ) )
2010-08-11 22:37:45 +00:00
{
2015-11-20 20:26:49 +00:00
if ( setval )
m32_script_expertmode = ! ! atoi_safe ( parm - > parms [ 0 ] ) ;
2010-08-11 22:37:45 +00:00
if ( m32_script_expertmode )
2015-11-20 20:26:49 +00:00
OSD_Printf ( " M32 Script expert mode %sENABLED. Be sure to know what you are doing! \n " ,
setval ? " " : " is " ) ;
2010-08-11 22:37:45 +00:00
else
2015-11-20 20:26:49 +00:00
OSD_Printf ( " M32 Script expert mode %sDISABLED. \n " , setval ? " " : " is " ) ;
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2010-08-11 22:37:45 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " fixmaponsave_sprites " ) )
2011-11-11 20:05:29 +00:00
{
OSD_Printf ( " Fix sprite sectnums on map saving: %s \n " ,
( fixmaponsave_sprites = ! fixmaponsave_sprites ) ? " enabled " : " disabled " ) ;
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2011-11-11 20:05:29 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " show_heightindicators " ) )
2010-08-11 22:37:45 +00:00
{
static const char * how [ 3 ] = { " none " , " two-sided walls only " , " all " } ;
2013-01-16 20:38:52 +00:00
if ( parm - > numparms > 1 )
return OSDCMD_SHOWHELP ;
if ( setval )
2011-02-21 23:08:21 +00:00
showheightindicators = clamp ( atoi_safe ( parm - > parms [ 0 ] ) , 0 , 2 ) ;
2013-01-16 20:38:52 +00:00
OSD_Printf ( " height indicators: %s \n " , how [ showheightindicators ] ) ;
2010-08-11 22:37:45 +00:00
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2010-08-11 22:37:45 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " show_ambiencesounds " ) )
2010-08-11 22:37:45 +00:00
{
static const char * how [ 3 ] = { " none " , " current sector only " , " all " } ;
2013-01-16 20:38:52 +00:00
if ( parm - > numparms > 1 )
return OSDCMD_SHOWHELP ;
if ( setval )
2011-02-21 23:08:21 +00:00
showambiencesounds = clamp ( atoi_safe ( parm - > parms [ 0 ] ) , 0 , 2 ) ;
2013-01-16 20:38:52 +00:00
OSD_Printf ( " ambience sound circles: %s \n " , how [ showambiencesounds ] ) ;
2010-08-11 22:37:45 +00:00
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2010-08-11 22:37:45 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " corruptcheck_noalreadyrefd " ) )
2012-10-01 17:52:47 +00:00
{
corruptcheck_noalreadyrefd = ! corruptcheck_noalreadyrefd ;
2013-01-16 20:38:52 +00:00
OSD_Printf ( " %s 'already referenced' corruption (i.e. one-to-many nextwalls) \n " ,
2012-10-01 17:52:47 +00:00
corruptcheck_noalreadyrefd ? " Ignore " : " Regard " ) ;
return OSDCMD_OK ;
}
2011-02-21 23:08:21 +00:00
2015-11-14 17:21:11 +00:00
if ( ! Bstrcasecmp ( parm - > name , " corruptcheck_game_duke3d " ) )
{
corruptcheck_game_duke3d = ! corruptcheck_game_duke3d ;
OSD_Printf ( " %s Duke3D issues \n " ,
! corruptcheck_game_duke3d ? " Ignore " : " Regard " ) ;
return OSDCMD_OK ;
}
2015-08-08 07:04:14 +00:00
if ( ! Bstrcasecmp ( parm - > name , " corruptcheck_heinum " ) )
{
if ( parm - > numparms > 1 )
return OSDCMD_SHOWHELP ;
static const char * mode [ 3 ] = { " disabled " , " auto-correct only " , " auto-correct and warn " } ;
if ( setval )
corruptcheck_heinum = clamp ( atoi_safe ( parm - > parms [ 0 ] ) , 0 , 2 ) ;
OSD_Printf ( " Check inconsistent ceilingstat/floorstat bit 2 and .heinum: %s \n " ,
mode [ corruptcheck_heinum ] ) ;
return OSDCMD_OK ;
}
2013-01-16 20:38:56 +00:00
if ( ! Bstrcasecmp ( parm - > name , " keeptexturestretch " ) )
{
keeptexturestretch = ! keeptexturestretch ;
OSD_Printf ( " Keep texture stretching when dragging wall vertices: %s \n " ,
ONOFF ( keeptexturestretch ) ) ;
return OSDCMD_OK ;
}
2015-07-08 03:34:42 +00:00
if ( ! Bstrcasecmp ( parm - > name , " m32_2d3dmode " ) )
{
if ( parm - > numparms > 1 )
return OSDCMD_SHOWHELP ;
if ( setval )
m32_2d3dmode = atoi_safe ( parm - > parms [ 0 ] ) ;
OSD_Printf ( " Experimental 2d/3d hybrid mode: %s \n " ,
ONOFF ( m32_2d3dmode ) ) ;
return OSDCMD_OK ;
}
2016-01-15 07:58:57 +00:00
if ( ! Bstrcasecmp ( parm - > name , " pointhighlightdist " ) )
{
if ( parm - > numparms > 1 )
return OSDCMD_SHOWHELP ;
if ( setval )
pointhighlightdist = atoi_safe ( parm - > parms [ 0 ] ) ;
OSD_Printf ( " Point highlight distance: %d \n " , pointhighlightdist ) ;
return OSDCMD_OK ;
}
if ( ! Bstrcasecmp ( parm - > name , " linehighlightdist " ) )
{
if ( parm - > numparms > 1 )
return OSDCMD_SHOWHELP ;
if ( setval )
linehighlightdist = atoi_safe ( parm - > parms [ 0 ] ) ;
OSD_Printf ( " Line highlight distance: %d \n " , linehighlightdist ) ;
return OSDCMD_OK ;
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > name , " corruptcheck " ) )
{
if ( parm - > numparms > = 1 )
2011-01-03 22:04:20 +00:00
{
2012-10-01 17:52:47 +00:00
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " now " ) )
2011-02-10 23:15:02 +00:00
{
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
int32_t printfromlevel = 1 ;
if ( parm - > numparms > 1 )
printfromlevel = clamp ( atoi_safe ( parm - > parms [ 1 ] ) , 1 , 5 ) ;
if ( CheckMapCorruption ( printfromlevel , 0 ) = = 0 )
2011-02-13 15:15:37 +00:00
OSD_Printf ( " All OK. \n " ) ;
return OSDCMD_OK ;
2011-02-10 23:15:02 +00:00
}
2013-01-16 20:38:52 +00:00
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " tryfix " ) )
2011-02-10 23:15:02 +00:00
{
2011-02-26 23:38:18 +00:00
uint64_t whicherrs = parm - > numparms = = 1 ? 0xffffffffffffffffull : 0 ;
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
corrupt_tryfix_alt = 0 ;
2011-02-21 23:08:21 +00:00
if ( whicherrs = = 0 )
{
int32_t i , n , m ;
char * endptr ;
for ( i = 1 ; i < parm - > numparms ; i + + )
{
2013-05-10 12:31:38 +00:00
if ( i = = parm - > numparms - 1 )
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
{
2013-05-10 12:31:38 +00:00
if ( ! Bstrcmp ( parm - > parms [ i ] , " ?? " ) )
{
corrupt_tryfix_alt = 2 ;
2013-05-10 12:31:39 +00:00
if ( parm - > numparms = = 2 )
whicherrs = 0xffffffffffffffffull ;
2013-05-10 12:31:38 +00:00
break ;
}
else if ( ! Bstrcmp ( parm - > parms [ i ] , " ? " ) )
{
corrupt_tryfix_alt = 1 ;
2013-05-10 12:31:39 +00:00
if ( parm - > numparms = = 2 )
whicherrs = 0xffffffffffffffffull ;
2013-05-10 12:31:38 +00:00
break ;
}
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
}
2011-02-21 23:08:21 +00:00
n = ( int32_t ) Bstrtol ( parm - > parms [ i ] , & endptr , 10 ) ;
if ( endptr ! = parm - > parms [ i ] )
{
if ( * endptr = = ' - ' )
{
m = ( int32_t ) Bstrtol ( endptr + 1 , NULL , 10 ) ;
if ( n > = 1 & & n < = m & & m < = MAXCORRUPTTHINGS )
{
2011-02-26 23:38:18 +00:00
uint64_t mask = 0xffffffffffffffffull ;
2011-02-21 23:08:21 +00:00
m = m - n + 1 ;
mask > > = ( MAXCORRUPTTHINGS - m ) ;
mask < < = ( n - 1 ) ;
whicherrs | = mask ;
}
}
else
{
if ( n > = 1 & & n < = MAXCORRUPTTHINGS )
whicherrs | = ( 1ull < < ( n - 1 ) ) ;
}
}
}
}
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
CheckMapCorruption ( whicherrs ? 5 : 3 , whicherrs ) ;
2011-02-13 15:15:37 +00:00
return OSDCMD_OK ;
2011-02-10 23:15:02 +00:00
}
2013-01-16 20:38:52 +00:00
if ( isdigit ( parm - > parms [ 0 ] [ 0 ] ) )
2011-02-10 23:15:02 +00:00
{
2011-02-21 23:08:21 +00:00
autocorruptcheck = clamp ( atoi_safe ( parm - > parms [ 0 ] ) , 0 , 3600 ) ;
2011-02-10 23:15:02 +00:00
corruptchecktimer = totalclock + 120 * autocorruptcheck ;
}
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2011-01-03 22:04:20 +00:00
}
if ( parm - > numparms < = 1 )
{
if ( autocorruptcheck )
OSD_Printf ( " auto corruption check: %d seconds \n " , autocorruptcheck ) ;
else
OSD_Printf ( " auto corruption check: off \n " ) ;
2013-01-16 20:38:52 +00:00
return OSDCMD_OK ;
2011-01-03 22:04:20 +00:00
}
2013-01-16 20:38:52 +00:00
return OSDCMD_SHOWHELP ;
2011-01-03 22:04:20 +00:00
}
2008-05-15 03:16:38 +00:00
return OSDCMD_OK ;
}
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-03-12 23:28:10 +00:00
static int32_t osdcmd_tint ( const osdfuncparm_t * parm )
{
int32_t i ;
palette_t * p ;
if ( parm - > numparms = = 1 )
{
2011-02-21 23:08:21 +00:00
i = atoi_safe ( parm - > parms [ 0 ] ) ;
2011-03-17 23:37:38 +00:00
if ( i > = 0 & & i < = M32_MAXPALOOKUPS )
2010-03-12 23:28:10 +00:00
{
p = & hictinting [ i ] ;
OSD_Printf ( " pal %d: r=%d g=%d b=%d f=%d \n " , i , p - > r , p - > g , p - > b , p - > f ) ;
}
}
else if ( parm - > numparms = = 0 )
{
2013-01-08 23:12:59 +00:00
palette_t notint = { 0xFF , 0xFF , 0xFF , 0x00 } ;
2010-03-12 23:28:10 +00:00
OSD_Printf ( " Hightile tintings: \n " ) ;
2011-03-17 23:37:38 +00:00
for ( i = 0 , p = & hictinting [ 0 ] ; i < = M32_MAXPALOOKUPS ; i + + , p + + )
2013-01-08 23:12:59 +00:00
if ( Bmemcmp ( & hictinting [ i ] , & notint , 4 ) )
2010-03-12 23:28:10 +00:00
OSD_Printf ( " pal %d: rgb %3d %3d %3d f %d \n " , i , p - > r , p - > g , p - > b , p - > f ) ;
}
else if ( parm - > numparms > = 2 )
{
2011-02-21 23:08:21 +00:00
i = atoi_safe ( parm - > parms [ 0 ] ) ;
2011-03-17 23:37:38 +00:00
if ( i < 0 | | i > M32_MAXPALOOKUPS )
2010-03-12 23:28:10 +00:00
return OSDCMD_SHOWHELP ;
p = & hictinting [ i ] ;
2011-02-21 23:08:21 +00:00
p - > r = atoi_safe ( parm - > parms [ 1 ] ) ;
p - > g = ( parm - > numparms > = 3 ) ? atoi_safe ( parm - > parms [ 2 ] ) : 255 ;
p - > b = ( parm - > numparms > = 4 ) ? atoi_safe ( parm - > parms [ 3 ] ) : 255 ;
p - > f = ( parm - > numparms > = 5 ) ? atoi_safe ( parm - > parms [ 4 ] ) & HICEFFECTMASK : 0 ;
2010-03-12 23:28:10 +00:00
}
return OSDCMD_OK ;
}
# endif
2012-10-07 15:26:20 +00:00
static void SaveInHistory ( const char * commandstr )
{
int32_t i , idx , dosave = 1 ;
2014-02-22 19:38:48 +00:00
// If running with osdtryscript=1, we could receive e.g.
// "// this file is automatically generated by Mapster32"
// from m32_config.cfg here.
if ( ! Bstrncmp ( commandstr , " // " , 2 ) )
return ;
2012-10-07 15:26:20 +00:00
for ( i = 1 ; i < = 4 ; i + + )
{
idx = ( scripthistend - i ) & ( SCRIPTHISTSIZ - 1 ) ;
if ( ! scripthist [ idx ] )
break ;
else if ( ! Bstrcmp ( scripthist [ idx ] , commandstr ) )
{
dosave = 0 ;
break ;
}
}
if ( dosave )
{
2015-09-23 17:55:31 +00:00
Bfree ( scripthist [ scripthistend ] ) ;
2014-05-30 00:02:19 +00:00
scripthist [ scripthistend ] = Xstrdup ( commandstr ) ;
2012-10-07 15:26:20 +00:00
scripthistend + + ;
scripthistend % = SCRIPTHISTSIZ ;
}
}
2012-10-07 15:26:04 +00:00
# ifdef LUNATIC
static int32_t osdcmd_lua ( const osdfuncparm_t * parm )
{
// Should be used like
// lua "lua code..."
// (the quotes making the whole string passed as one argument)
int32_t ret ;
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
2012-11-10 20:59:00 +00:00
if ( ! L_IsInitialized ( & g_EmState ) )
2012-10-07 15:26:04 +00:00
{
OSD_Printf ( " Lua state is not initialized. \n " ) ;
return OSDCMD_OK ;
}
2016-01-27 07:30:23 +00:00
ret = L_RunString ( & g_EmState , parm - > parms [ 0 ] , - 1 , " console " ) ;
2012-10-07 15:26:04 +00:00
if ( ret ! = 0 )
OSD_Printf ( " Error running the Lua code (error code %d) \n " , ret ) ;
2012-10-07 15:26:20 +00:00
else
SaveInHistory ( parm - > raw ) ;
2012-10-07 15:26:04 +00:00
return OSDCMD_OK ;
}
# endif
2009-09-12 23:03:15 +00:00
// M32 script vvv
static int32_t osdcmd_include ( const osdfuncparm_t * parm )
{
if ( parm - > numparms ! = 1 )
return OSDCMD_SHOWHELP ;
C_Compile ( parm - > parms [ 0 ] , 1 ) ;
return OSDCMD_OK ;
}
static int32_t osdcmd_scriptinfo ( const osdfuncparm_t * parm )
{
UNREFERENCED_PARAMETER ( parm ) ;
C_CompilationInfo ( ) ;
return OSDCMD_OK ;
}
2010-08-18 23:21:19 +00:00
# ifdef DEBUGGINGAIDS
extern void X_Disasm ( ofstype beg , int32_t size ) ;
2009-09-18 21:44:46 +00:00
static int32_t osdcmd_disasm ( const osdfuncparm_t * parm )
{
int32_t i ;
if ( parm - > numparms ! = 2 )
return OSDCMD_SHOWHELP ;
if ( ! isdigit ( parm - > parms [ 1 ] [ 0 ] ) )
return OSDCMD_SHOWHELP ;
2011-02-21 23:08:21 +00:00
i = atoi_safe ( parm - > parms [ 1 ] ) ;
2009-09-18 21:44:46 +00:00
if ( parm - > parms [ 0 ] [ 0 ] = = ' s ' )
{
if ( i > = 0 & & i < g_stateCount )
X_Disasm ( statesinfo [ i ] . ofs , statesinfo [ i ] . codesize ) ;
}
else
{
if ( i > = 0 & & i < MAXEVENTS & & aEventOffsets [ i ] > = 0 )
X_Disasm ( aEventOffsets [ i ] , aEventSizes [ i ] ) ;
}
return OSDCMD_OK ;
}
# endif
2009-09-12 23:03:15 +00:00
static int32_t osdcmd_do ( const osdfuncparm_t * parm )
{
2010-06-25 23:01:54 +00:00
intptr_t oscrofs ;
2009-09-12 23:03:15 +00:00
char * tp ;
2011-08-03 17:22:25 +00:00
int32_t i , j , slen , ofs , dontsavehist ;
2009-09-14 22:11:37 +00:00
int32_t onumconstants = g_numSavedConstants ;
2009-09-12 23:03:15 +00:00
2010-05-22 23:41:18 +00:00
if ( parm - > numparms = = 0 )
2009-09-12 23:03:15 +00:00
return OSDCMD_SHOWHELP ;
2010-06-25 23:01:54 +00:00
oscrofs = ( g_scriptPtr - script ) ;
2009-09-12 23:03:15 +00:00
2010-05-22 23:41:18 +00:00
ofs = 2 * ( parm - > numparms > 0 ) ; // true if "do" command
slen = Bstrlen ( parm - > raw + ofs ) ;
2014-05-30 00:02:19 +00:00
tp = ( char * ) Xmalloc ( slen + 2 ) ;
2010-05-22 23:41:18 +00:00
Bmemcpy ( tp , parm - > raw + ofs , slen ) ;
2009-09-12 23:03:15 +00:00
2011-08-03 17:22:46 +00:00
// M32script call from 'special functions' menu
2011-08-03 17:22:25 +00:00
dontsavehist = ( slen = = 0 | | tp [ 0 ] = = ' ' ) ;
2010-05-22 23:41:18 +00:00
// needed so that subsequent commands won't execute old stuff.
2009-09-12 23:03:15 +00:00
tp [ slen ] = ' \n ' ;
tp [ slen + 1 ] = ' \0 ' ;
2009-09-14 22:11:37 +00:00
g_didDefineSomething = 0 ;
2009-09-12 23:03:15 +00:00
C_Compile ( tp , 0 ) ;
2010-05-22 23:41:18 +00:00
if ( parm - > numparms > = 0 )
Bfree ( tp ) ;
2009-09-14 22:11:37 +00:00
if ( g_numCompilerErrors )
2009-09-12 23:03:15 +00:00
{
2010-06-25 23:01:54 +00:00
// g_scriptPtr = script + oscrofs; // handled in C_Compile()
2009-09-14 22:11:37 +00:00
return OSDCMD_OK ;
}
for ( i = 0 , j = 0 ; i < MAXEVENTS ; i + + )
if ( aEventOffsets [ i ] > = 0 )
j + + ;
if ( g_didDefineSomething = = 0 )
{
g_numSavedConstants = onumconstants ;
2009-09-12 23:03:15 +00:00
* g_scriptPtr = CON_RETURN + ( g_lineNumber < < 12 ) ;
2010-06-25 23:01:54 +00:00
g_scriptPtr = script + oscrofs ;
2009-09-14 22:11:37 +00:00
2010-06-25 23:01:54 +00:00
insptr = script + oscrofs ;
2009-09-12 23:03:15 +00:00
Bmemcpy ( & vm , & vm_default , sizeof ( vmstate_t ) ) ;
2010-09-30 23:05:40 +00:00
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) & & AIMING_AT_SPRITE )
2010-09-30 23:05:40 +00:00
{
vm . g_i = searchwall ;
2015-01-12 09:28:46 +00:00
vm . g_sp = ( tspritetype * ) & sprite [ vm . g_i ] ;
2010-09-30 23:05:40 +00:00
}
2011-08-03 17:22:25 +00:00
// If OSD is down, that would interfere with user input, so don't consider
// m32script executed from the console as 'interactive'. Which leaves only
// that from the 'special functions' menu
if ( OSD_GetRowsCur ( ) < 0 )
vm . miscflags | = VMFLAG_MISC_INTERACTIVE ;
2010-05-02 23:27:30 +00:00
VM_Execute ( 0 ) ;
2010-06-25 23:01:54 +00:00
2011-08-03 17:22:25 +00:00
M32_PostScriptExec ( ) ;
2010-09-30 23:05:40 +00:00
2011-08-03 17:22:25 +00:00
if ( ! ( vm . flags & VMFLAG_ERROR ) & & ! dontsavehist )
2012-10-07 15:26:20 +00:00
SaveInHistory ( parm - > raw ) ;
2010-09-27 21:52:04 +00:00
2009-09-12 23:03:15 +00:00
// asksave = 1; // handled in Access(Sprite|Sector|Wall)
}
2009-09-14 22:11:37 +00:00
2009-09-12 23:03:15 +00:00
return OSDCMD_OK ;
}
2010-05-22 23:41:18 +00:00
void M32RunScript ( const char * s )
{
osdfuncparm_t parm ;
parm . numparms = - 1 ;
parm . raw = s ;
osdcmd_do ( & parm ) ;
}
2009-09-12 23:03:15 +00:00
static int32_t osdcmd_endisableevent ( const osdfuncparm_t * parm )
{
int32_t i , j , enable ;
2009-09-16 22:24:24 +00:00
if ( ! label ) return OSDCMD_OK ;
2009-09-12 23:03:15 +00:00
if ( parm - > numparms < 1 )
2009-09-16 22:24:24 +00:00
{
OSD_Printf ( " --- Defined events: \n " ) ;
for ( i = 0 ; i < MAXEVENTS ; i + + )
if ( aEventOffsets [ i ] > = 0 )
OSD_Printf ( " %s (%d): %s \n " , label + ( i * MAXLABELLEN ) , i , aEventEnabled [ i ] ? " on " : " off " ) ;
return OSDCMD_OK ;
}
2009-09-12 23:03:15 +00:00
enable = ! Bstrcasecmp ( parm - > name , " enableevent " ) ;
if ( parm - > numparms = = 1 )
{
2010-05-22 23:41:18 +00:00
if ( ! Bstrcasecmp ( parm - > parms [ 0 ] , " all " ) | | ! Bstrcasecmp ( parm - > parms [ 0 ] , " a " ) )
2009-09-12 23:03:15 +00:00
{
for ( i = 0 ; i < MAXEVENTS ; i + + )
aEventEnabled [ i ] = enable ? 1 : 0 ;
2010-06-25 23:01:54 +00:00
OSD_Printf ( " %sabled all events. \n " , enable ? " En " : " Dis " ) ;
2009-09-12 23:03:15 +00:00
return OSDCMD_OK ;
}
}
for ( i = 0 ; i < parm - > numparms ; i + + )
{
2010-05-22 23:41:18 +00:00
char buf [ 64 ] = " EVENT_ " , buf2 [ 64 ] ;
2009-09-12 23:03:15 +00:00
if ( isdigit ( parm - > parms [ i ] [ 0 ] ) )
2010-05-22 23:41:18 +00:00
{
2011-02-21 23:08:21 +00:00
j = atoi_safe ( parm - > parms [ i ] ) ;
2010-05-22 23:41:18 +00:00
Bsprintf ( buf2 , " event %d " , j ) ;
}
2009-09-12 23:03:15 +00:00
else if ( ! Bstrncmp ( parm - > parms [ i ] , " EVENT_ " , 6 ) )
2010-05-22 23:41:18 +00:00
{
2010-05-02 23:27:30 +00:00
j = hash_find ( & h_labels , parm - > parms [ i ] ) ;
2012-03-28 19:43:21 +00:00
Bstrncpyz ( buf2 , parm - > parms [ i ] , sizeof ( buf2 ) ) ;
2010-05-22 23:41:18 +00:00
}
2009-09-12 23:03:15 +00:00
else
{
Bstrncat ( buf , parm - > parms [ i ] , sizeof ( buf ) - 6 - 1 ) ;
2010-05-02 23:27:30 +00:00
j = hash_find ( & h_labels , buf ) ;
2010-05-22 23:41:18 +00:00
Bmemcpy ( buf2 , buf , sizeof ( buf2 ) ) ;
2009-09-12 23:03:15 +00:00
}
if ( j > = 0 & & j < MAXEVENTS )
2010-05-22 23:41:18 +00:00
{
2009-09-12 23:03:15 +00:00
aEventEnabled [ j ] = enable ? 1 : 0 ;
2010-05-22 23:41:18 +00:00
OSD_Printf ( " %sabled %s. \n " , enable ? " En " : " Dis " , buf2 ) ;
}
else
OSD_Printf ( " Invalid event %s. \n " , buf2 ) ;
2009-09-12 23:03:15 +00:00
}
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 ( " editorgridextent " , " editorgridextent: sets the size of the 2D mode editing grid " , osdcmd_editorgridextent ) ;
OSD_RegisterFunction ( " initgroupfile " , " initgroupfile <path>: adds a grp file into the game filesystem " , osdcmd_initgroupfile ) ;
2011-09-16 19:17:48 +00:00
OSD_RegisterFunction ( " m32_clipping " , " m32_clipping: toggles clipping mode " , osdcmd_noclip ) ;
2007-04-17 05:54:12 +00:00
2010-08-11 22:37:45 +00:00
OSD_RegisterFunction ( " quit " , " quit: exits the editor immediately " , osdcmd_quit ) ;
OSD_RegisterFunction ( " exit " , " exit: exits the editor 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
2015-07-08 03:34:42 +00:00
OSD_RegisterFunction ( " m32_2d3dmode " , " 2d3dmode: experimental 2d/3d hybrid mode " , osdcmd_vars_pk ) ;
2016-01-15 07:58:57 +00:00
OSD_RegisterFunction ( " pointhighlightdist " , " pointhighlightdist: distance at which points are selected " , osdcmd_vars_pk ) ;
OSD_RegisterFunction ( " linehighlightdist " , " linehighlightdist: distance at which lines are selected " , osdcmd_vars_pk ) ;
2010-08-11 22:37:45 +00:00
OSD_RegisterFunction ( " pk_turnaccel " , " pk_turnaccel <value>: sets turning acceleration+deceleration " , osdcmd_vars_pk ) ;
OSD_RegisterFunction ( " pk_turndecel " , " pk_turndecel <value>: sets turning deceleration " , osdcmd_vars_pk ) ;
OSD_RegisterFunction ( " pk_uedaccel " , " pk_uedaccel <value>: sets UnrealEd movement speed factor (0-5, exponentially) " , osdcmd_vars_pk ) ;
OSD_RegisterFunction ( " pk_quickmapcycling " , " pk_quickmapcycling: toggles quick cycling of maps with (Shift-)Ctrl-X " , osdcmd_vars_pk ) ;
OSD_RegisterFunction ( " testplay_addparam " , " testplay_addparam \" string \" : sets additional parameters for test playing " , osdcmd_testplay_addparam ) ;
2011-02-10 23:15:02 +00:00
OSD_RegisterFunction ( " show_heightindicators " , " show_heightindicators {0, 1 or 2}: sets display of height indicators in 2D mode " , osdcmd_vars_pk ) ;
2015-11-02 17:07:50 +00:00
OSD_RegisterFunction ( " show_ambiencesounds " , " show_ambiencesounds {0, 1 or 2}: sets display of MUSICANDSFX circles in 2D mode " , osdcmd_vars_pk ) ;
2012-10-01 17:52:47 +00:00
OSD_RegisterFunction ( " corruptcheck_noalreadyrefd " , " corruptcheck_noalreadyrefd: toggles ignoring of one-to-many red wall connections " , osdcmd_vars_pk ) ;
2015-11-14 17:21:11 +00:00
OSD_RegisterFunction ( " corruptcheck_game_duke3d " , " corruptcheck_game_duke3d: toggles ignoring of Duke3D issues " , osdcmd_vars_pk ) ;
2015-08-08 07:04:14 +00:00
OSD_RegisterFunction ( " corruptcheck_heinum " , " corruptcheck_heinum: toggles auto-correcting inconsistent c/fstat bit 2 and heinum (2: also warn) " , osdcmd_vars_pk ) ;
2015-11-02 17:07:50 +00:00
OSD_RegisterFunction ( " keeptexturestretch " , " keeptexturestretch: toggles keeping texture stretching when dragging wall vertices " , osdcmd_vars_pk ) ;
2013-01-16 20:38:56 +00:00
2011-02-10 23:15:02 +00:00
OSD_RegisterFunction ( " corruptcheck " , " corruptcheck {<seconds>|now|tryfix}: sets auto corruption check interval if <seconds> given, otherwise as indicated " , osdcmd_vars_pk ) ;
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
2010-03-12 23:28:10 +00:00
OSD_RegisterFunction ( " tint " , " tint <pal> <r> <g> <b> <flags>: queries or sets hightile tinting " , osdcmd_tint ) ;
# endif
2009-09-12 23:03:15 +00:00
2012-10-07 15:26:04 +00:00
# ifdef LUNATIC
2013-11-04 22:56:03 +00:00
OSD_RegisterFunction ( " lua " , " lua \" Lua code... \" : runs Lua code " , osdcmd_lua ) ;
2012-10-07 15:26:04 +00:00
# endif
2009-09-12 23:03:15 +00:00
// M32 script
2011-07-21 22:39:29 +00:00
OSD_RegisterFunction ( " include " , " include <filenames...>: compiles one or more M32 script files " , osdcmd_include ) ;
2009-09-12 23:03:15 +00:00
OSD_RegisterFunction ( " do " , " do (m32 script ...): executes M32 script statements " , osdcmd_do ) ;
2010-08-11 22:37:45 +00:00
OSD_RegisterFunction ( " script_info " , " script_info: shows information about compiled M32 script " , osdcmd_scriptinfo ) ;
OSD_RegisterFunction ( " script_expertmode " , " script_expertmode: toggles M32 script expert mode " , osdcmd_vars_pk ) ;
2011-02-10 23:15:02 +00:00
OSD_RegisterFunction ( " enableevent " , " enableevent {all|EVENT_...|(event number)} " , osdcmd_endisableevent ) ;
OSD_RegisterFunction ( " disableevent " , " disableevent {all|EVENT_...|(event number)} " , osdcmd_endisableevent ) ;
2010-08-11 22:37:45 +00:00
OSD_RegisterFunction ( " osd_tryscript " , " osd_tryscript: toggles execution of M32 script on invalid OSD command " , osdcmd_vars_pk ) ;
2010-11-27 22:12:24 +00:00
OSD_RegisterFunction ( " sideview_reversehorizrot " , " sideview_reversehorizrot: toggles reversion of Q and W keys in side view mode " , osdcmd_vars_pk ) ;
2010-08-18 23:21:19 +00:00
# ifdef DEBUGGINGAIDS
OSD_RegisterFunction ( " disasm " , " disasm [s|e] <state or event number> " , osdcmd_disasm ) ;
# endif
2007-04-17 05:54:12 +00:00
return 0 ;
}
2010-05-18 05:14:17 +00:00
2007-04-17 05:54:12 +00:00
2007-08-25 01:05:00 +00:00
enum
{
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 ,
2009-03-15 22:58:20 +00:00
T_DEFINESOUND ,
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
T_INCLUDEDEFAULT ,
2015-04-12 08:07:45 +00:00
T_RENAMEFILE ,
2015-10-03 11:53:16 +00:00
T_GLOBALGAMEFLAGS ,
2015-11-01 19:56:22 +00:00
2016-01-27 10:06:03 +00:00
T_GAMESTARTUP ,
2015-11-01 19:56:22 +00:00
T_DUMMY ,
2006-07-26 01:10:33 +00:00
} ;
2012-07-01 22:11:33 +00:00
static int32_t parsegroupfiles ( scriptfile * script ) ;
2011-07-21 22:39:29 +00:00
2012-07-01 22:11:33 +00:00
static void parsegroupfiles_include ( const char * fn , scriptfile * script , const char * cmdtokptr )
2011-07-21 22:39:29 +00:00
{
scriptfile * included ;
included = scriptfile_fromfile ( fn ) ;
if ( ! included )
{
if ( ! Bstrcasecmp ( cmdtokptr , " null " ) )
initprintf ( " Warning: Failed including %s as module \n " , fn ) ;
else
initprintf ( " Warning: Failed including %s on line %s:%d \n " ,
fn , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
}
else
{
parsegroupfiles ( included ) ;
scriptfile_close ( included ) ;
}
}
2012-07-01 22:11:33 +00:00
static 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 } ,
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
{ " includedefault " , T_INCLUDEDEFAULT } ,
{ " #includedefault " , T_INCLUDEDEFAULT } ,
2007-08-25 01:05:00 +00:00
{ " loadgrp " , T_LOADGRP } ,
2015-04-12 08:07:45 +00:00
{ " noautoload " , T_NOAUTOLOAD } ,
{ " renamefile " , T_RENAMEFILE } ,
2015-10-03 11:53:16 +00:00
{ " globalgameflags " , T_GLOBALGAMEFLAGS } ,
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 )
{
2014-03-22 09:25:15 +00:00
tokn = getatoken ( script , grptokens , ARRAY_SIZE ( grptokens ) ) ;
2006-07-26 01:10:33 +00:00
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 :
2009-07-04 09:28:21 +00:00
{
char * fn ;
2015-10-20 07:15:08 +00:00
int opathsearchmode = pathsearchmode ;
2009-07-04 09:28:21 +00:00
pathsearchmode = 1 ;
if ( ! scriptfile_getstring ( script , & fn ) )
2006-07-26 01:10:33 +00:00
{
2009-07-04 09:28:21 +00:00
int32_t j = initgroupfile ( fn ) ;
2006-07-26 01:10:33 +00:00
2009-07-04 09:28:21 +00:00
if ( j = = - 1 )
2012-03-26 05:05:57 +00:00
initprintf ( " Could not find group file \" %s \" . \n " , fn ) ;
2009-07-04 09:28:21 +00:00
else
2007-07-04 09:15:08 +00:00
{
2012-03-26 05:05:57 +00:00
initprintf ( " Using group file \" %s \" . \n " , fn ) ;
2009-07-04 09:28:21 +00:00
if ( ! NoAutoLoad )
2012-03-28 19:42:32 +00:00
G_DoAutoload ( fn ) ;
2009-06-28 20:23:12 +00:00
}
2009-07-04 09:28:21 +00:00
2006-07-26 01:10:33 +00:00
}
2015-10-20 07:15:08 +00:00
pathsearchmode = opathsearchmode ;
2009-07-04 09:28:21 +00:00
}
break ;
2007-02-18 22:16:01 +00:00
case T_INCLUDE :
2009-07-04 09:28:21 +00:00
{
char * fn ;
if ( ! scriptfile_getstring ( script , & fn ) )
2011-07-21 22:39:29 +00:00
parsegroupfiles_include ( fn , script , cmdtokptr ) ;
2007-02-18 22:16:01 +00:00
break ;
2009-07-04 09:28:21 +00:00
}
break ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
case T_INCLUDEDEFAULT :
{
2012-06-03 16:09:33 +00:00
parsegroupfiles_include ( G_DefaultDefFile ( ) , script , cmdtokptr ) ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
break ;
}
break ;
2008-02-21 05:11:41 +00:00
case T_NOAUTOLOAD :
NoAutoLoad = 1 ;
break ;
2015-04-12 08:07:45 +00:00
case T_RENAMEFILE :
{
int32_t crcval = 0 , filenum = - 1 ;
char * newname = NULL ;
if ( scriptfile_getnumber ( script , & crcval ) ) break ;
if ( scriptfile_getnumber ( script , & filenum ) ) break ;
if ( scriptfile_getstring ( script , & newname ) ) break ;
krename ( crcval , filenum , newname ) ;
}
break ;
2015-10-03 11:53:16 +00:00
case T_GLOBALGAMEFLAGS :
{
if ( scriptfile_getnumber ( script , & duke3d_m32_globalflags ) ) break ;
}
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 ;
}
2014-07-28 06:42:28 +00:00
int32_t loaddefinitions_game ( const char * fn , int32_t preload )
2007-04-21 20:25:07 +00:00
{
scriptfile * script ;
2011-07-21 22:39:29 +00:00
int32_t i ;
2007-04-21 20:25:07 +00:00
2014-07-28 06:42:28 +00:00
UNREFERENCED_PARAMETER ( preload ) ;
2007-04-21 20:25:07 +00:00
script = scriptfile_fromfile ( fn ) ;
2015-04-12 08:07:59 +00:00
if ( script )
parsegroupfiles ( script ) ;
2007-04-21 20:25:07 +00:00
2011-07-21 22:39:29 +00:00
for ( i = 0 ; i < g_defModulesNum ; + + i )
parsegroupfiles_include ( g_defModules [ i ] , NULL , " null " ) ;
2015-04-12 08:07:59 +00:00
if ( script )
scriptfile_close ( script ) ;
2007-04-21 20:25:07 +00:00
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 } ,
2015-11-01 19:56:22 +00:00
{ " dynamicremap " , T_DUMMY } ,
2007-08-25 01:05:00 +00:00
{ " 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 )
{
2014-03-22 09:25:15 +00:00
tokn = getatoken ( script , tgtokens , ARRAY_SIZE ( tgtokens ) ) ;
2007-04-21 20:25:07 +00:00
cmdtokptr = script - > ltextptr ;
switch ( tokn )
{
2008-08-28 15:04:16 +00:00
case T_HOTKEY :
2009-07-04 09:28:21 +00:00
{
int32_t i , j ;
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 :
2009-07-04 09:28:21 +00:00
{
char * fn ;
if ( ! scriptfile_getstring ( script , & fn ) )
2007-04-21 20:25:07 +00:00
{
2009-07-04 09:28:21 +00:00
scriptfile * included ;
2009-06-28 20:23:12 +00:00
2009-07-04 09:28:21 +00:00
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 ) ;
2007-04-21 20:25:07 +00:00
}
}
2009-07-04 09:28:21 +00:00
break ;
}
2007-04-21 20:25:07 +00:00
case T_DEFINE :
2009-07-04 09:28:21 +00:00
{
char * name ;
int32_t number ;
2007-04-21 20:25:07 +00:00
2009-07-04 09:28:21 +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 ;
}
2007-04-21 20:25:07 +00:00
case T_TILEGROUP :
2009-07-04 09:28:21 +00:00
{
char * end , * name ;
int32_t i ;
2007-04-21 21:01:07 +00:00
2009-07-04 09:28:21 +00:00
if ( tile_groups > = MAX_TILE_GROUPS ) break ;
if ( scriptfile_getstring ( script , & name ) ) break ;
if ( scriptfile_getbraces ( script , & end ) ) break ;
2007-04-21 20:25:07 +00:00
2015-11-14 23:40:56 +00:00
TileGroup * const tileGrp = & s_TileGroups [ tile_groups ] ;
tileGrp - > pIds = ( int32_t * ) Xcalloc ( MAX_TILE_GROUP_ENTRIES , sizeof ( int32_t ) ) ;
tileGrp - > szText = Xstrdup ( name ) ;
2007-04-21 21:01:07 +00:00
2009-07-04 09:28:21 +00:00
while ( script - > textptr < end )
{
2015-11-14 23:40:56 +00:00
static const tokenlist tgtokens2 [ ] =
2009-07-04 09:28:21 +00:00
{
{ " tilegroup " , T_TILEGROUP } ,
{ " tile " , T_TILE } ,
{ " tilerange " , T_TILERANGE } ,
{ " hotkey " , T_HOTKEY } ,
{ " tiles " , T_TILES } ,
{ " colors " , T_COLORS } ,
} ;
2015-11-14 23:40:56 +00:00
const int32_t token = getatoken ( script , tgtokens2 , ARRAY_SIZE ( tgtokens2 ) ) ;
2009-07-04 09:28:21 +00:00
switch ( token )
{
case T_TILE :
2007-04-21 20:25:07 +00:00
{
2009-07-04 09:28:21 +00:00
if ( scriptfile_getsymbol ( script , & i ) ) break ;
2015-11-14 23:41:00 +00:00
if ( i > = 0 & & i < MAXUSERTILES & & tileGrp - > nIds < MAX_TILE_GROUP_ENTRIES )
2015-11-14 23:40:56 +00:00
tileGrp - > pIds [ tileGrp - > nIds + + ] = i ;
// OSD_Printf("added tile %d to group %d\n",i,g);
2009-07-04 09:28:21 +00:00
break ;
}
case T_TILERANGE :
{
int32_t j ;
if ( scriptfile_getsymbol ( script , & i ) ) break ;
if ( scriptfile_getsymbol ( script , & j ) ) break ;
if ( i < 0 | | i > = MAXTILES | | j < 0 | | j > = MAXTILES ) break ;
2015-11-14 23:40:56 +00:00
while ( tileGrp - > nIds < MAX_TILE_GROUP_ENTRIES & & i < = j )
2007-04-21 20:25:07 +00:00
{
2015-11-14 23:40:56 +00:00
tileGrp - > pIds [ tileGrp - > nIds + + ] = i + + ;
// OSD_Printf("added tile %d to group %d\n",i,g);
2009-07-04 09:28:21 +00:00
}
break ;
}
case T_COLORS :
{
int32_t j ;
if ( scriptfile_getsymbol ( script , & i ) ) break ;
if ( scriptfile_getsymbol ( script , & j ) ) break ;
if ( i < 0 | | i > = 256 | | j < 0 | | j > = 256 ) break ;
2015-11-14 23:40:56 +00:00
tileGrp - > color1 = i ;
tileGrp - > color2 = j ;
2009-07-04 09:28:21 +00:00
break ;
}
case T_HOTKEY :
{
char * c ;
if ( scriptfile_getstring ( script , & c ) ) break ;
2015-11-14 23:40:56 +00:00
tileGrp - > key1 = Btoupper ( c [ 0 ] ) ;
tileGrp - > key2 = Btolower ( c [ 0 ] ) ;
2009-07-04 09:28:21 +00:00
break ;
}
case T_TILES :
{
char * end2 ;
if ( scriptfile_getbraces ( script , & end2 ) ) break ;
while ( script - > textptr < end2 - 1 )
2007-04-21 21:01:07 +00:00
{
2009-07-04 09:28:21 +00:00
if ( ! scriptfile_getsymbol ( script , & i ) )
2007-04-21 21:01:07 +00:00
{
2015-11-14 23:40:56 +00:00
if ( i > = 0 & & i < MAXTILES & & tileGrp - > nIds < MAX_TILE_GROUP_ENTRIES )
tileGrp - > pIds [ tileGrp - > nIds + + ] = i ;
// OSD_Printf("added tile %d to group %d\n",i,g);
2007-04-21 21:01:07 +00:00
}
}
2009-07-04 09:28:21 +00:00
break ;
}
2007-04-21 20:25:07 +00:00
}
}
2010-08-14 21:32:28 +00:00
2015-11-14 23:40:56 +00:00
tileGrp - > pIds = ( int32_t * ) Xrealloc ( tileGrp - > pIds , tileGrp - > nIds * sizeof ( int32_t ) ) ;
2009-07-04 09:28:21 +00:00
tile_groups + + ;
break ;
}
2008-09-11 21:22:58 +00:00
case T_ALPHABET :
2009-07-04 09:28:21 +00:00
{
char * end ;
int32_t i , j , k ;
2010-08-14 21:32:28 +00:00
if ( numalphabets > = MAX_ALPHABETS )
{
OSD_Printf ( " Too many alphabet definitions (max: %d). \n " , MAX_ALPHABETS ) ;
break ;
}
2009-07-04 09:28:21 +00:00
if ( scriptfile_getbraces ( script , & end ) ) break ;
for ( i = 0 ; i < NUMPRINTABLES ; i + + )
2008-09-11 21:22:58 +00:00
{
2009-07-04 09:28:21 +00:00
alphabets [ numalphabets ] . pic [ i ] = - 1 ;
alphabets [ numalphabets ] . xofs [ i ] = 0 ;
alphabets [ numalphabets ] . yofs [ i ] = 0 ;
}
2008-09-11 21:22:58 +00:00
2009-07-04 09:28:21 +00:00
while ( script - > textptr < end )
{
tokenlist alphtokens2 [ ] =
{
{ " map " , T_MAP } ,
{ " mapa " , T_MAPA } ,
{ " maprange " , T_MAPRANGE } ,
{ " maprangea " , T_MAPRANGEA } ,
{ " offset " , T_OFFSET } ,
{ " offseta " , T_OFFSETA } ,
} ;
2008-09-11 21:22:58 +00:00
2014-03-22 09:25:15 +00:00
int32_t token = getatoken ( script , alphtokens2 , ARRAY_SIZE ( alphtokens2 ) ) ;
2009-07-04 09:28:21 +00:00
switch ( token )
{
case T_MAP : // map <ascii num> <start tilenum>, e.g. map 46 3002
2008-09-11 21:22:58 +00:00
{
2009-07-04 09:28:21 +00:00
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 ;
2008-09-11 21:22:58 +00:00
}
2009-07-04 09:28:21 +00:00
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 ;
2008-09-11 21:22:58 +00:00
2009-07-04 09:28:21 +00:00
for ( ; * s ; s + + , i + + )
{
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 :
2008-09-11 21:22:58 +00:00
{
2009-07-04 09:28:21 +00:00
if ( token = = T_MAPRANGE )
2008-09-11 21:22:58 +00:00
{
2009-07-04 09:28:21 +00:00
if ( scriptfile_getnumber ( script , & i ) ) break ;
if ( scriptfile_getnumber ( script , & j ) ) break ;
}
else
2008-09-11 21:22:58 +00:00
{
2009-07-04 09:28:21 +00:00
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 ;
2009-06-28 20:23:12 +00:00
2009-07-04 09:28:21 +00:00
if ( i > 126 | | j < 33 ) break ;
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 ;
2009-06-28 20:23:12 +00:00
2009-07-04 09:28:21 +00:00
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 ;
2008-09-11 21:22:58 +00:00
2009-07-04 09:28:21 +00:00
for ( ; * s ; s + + )
if ( * s > = 33 & & * s < = 126 )
2008-09-11 21:22:58 +00:00
{
2009-07-04 09:28:21 +00:00
alphabets [ numalphabets ] . xofs [ ( * s ) - 33 ] = i ;
alphabets [ numalphabets ] . yofs [ ( * s ) - 33 ] = j ;
2008-09-11 21:22:58 +00:00
}
2009-07-04 09:28:21 +00:00
break ;
}
2008-09-11 21:22:58 +00:00
}
}
2009-07-04 09:28:21 +00:00
numalphabets + + ;
break ;
}
2008-09-11 21:22:58 +00:00
case T_EOF :
return ( 0 ) ;
default :
break ;
}
}
return 0 ;
}
2010-08-14 21:32:28 +00:00
static int32_t loadtilegroups ( const 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 ;
2010-08-14 21:32:28 +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 ;
2010-08-14 21:32:28 +00:00
for ( i = 0 ; i < tile_groups ; i + + )
2008-09-25 11:01:37 +00:00
{
2015-09-23 17:55:31 +00:00
Bfree ( s_TileGroups [ i ] . pIds ) ;
Bfree ( s_TileGroups [ i ] . szText ) ;
2010-08-14 21:32:28 +00:00
Bmemcpy ( & s_TileGroups [ i ] , & blank , sizeof ( blank ) ) ;
2008-09-25 11:01:37 +00:00
}
2010-08-14 21:32:28 +00:00
tile_groups = 0 ;
2010-10-09 22:59:17 +00:00
#if 0
2010-08-14 21:32:28 +00:00
// ---------- Init hardcoded tile group consisting of all named tiles
2014-05-30 00:02:19 +00:00
s_TileGroups [ 0 ] . szText = Xstrdup ( " All named " ) ;
s_TileGroups [ 0 ] . pIds = ( int32_t * ) Xmalloc ( MAXTILES * sizeof ( s_TileGroups [ 0 ] . pIds [ 0 ] ) ) ;
2010-08-14 21:32:28 +00:00
j = 0 ;
for ( i = 0 ; i < MAXTILES ; i + + )
if ( names [ i ] [ 0 ] )
s_TileGroups [ 0 ] . pIds [ j + + ] = i ;
if ( j )
{
s_TileGroups [ 0 ] . nIds = j ;
s_TileGroups [ 0 ] . key1 = ' Y ' ;
s_TileGroups [ 0 ] . key2 = ' y ' ;
tile_groups + + ;
}
// --------------------
2010-10-09 22:59:17 +00:00
# endif
2008-09-25 11:01:37 +00:00
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.
2010-08-14 21:32:28 +00:00
for ( i = 0 ; i < tile_groups ; i + + )
2008-09-25 11:01:37 +00:00
{
// If the colors were specified...
if ( s_TileGroups [ i ] . color1 & & s_TileGroups [ i ] . color2 )
{
2015-11-14 23:41:00 +00:00
// Apply the colors to all tiles in the group...
2008-09-25 11:01:37 +00:00
for ( j = s_TileGroups [ i ] . nIds - 1 ; j > = 0 ; j - - )
{
2015-11-14 23:41:00 +00:00
int const tilenum = s_TileGroups [ i ] . pIds [ j ] ;
// ... but for each tile, only if no color has been specified
// for it previously.
if ( spritecol2d [ tilenum ] [ 0 ] = = 0 )
{
spritecol2d [ tilenum ] [ 0 ] = s_TileGroups [ i ] . color1 ;
spritecol2d [ tilenum ] [ 1 ] = s_TileGroups [ i ] . color2 ;
}
2008-09-25 11:01:37 +00:00
}
}
}
2008-09-11 21:22:58 +00:00
return 0 ;
}
2009-03-15 22:58:20 +00:00
/// vvv Parse CON files partially to get sound definitions
2011-07-21 22:39:29 +00:00
static int32_t parseconsounds ( scriptfile * script ) ;
2012-07-01 22:11:33 +00:00
static void parseconsounds_include ( const char * fn , scriptfile * script , const char * cmdtokptr )
2011-07-21 22:39:29 +00:00
{
scriptfile * included ;
included = scriptfile_fromfile ( fn ) ;
if ( ! included )
{
if ( ! Bstrcasecmp ( cmdtokptr , " null " ) )
initprintf ( " Warning: Failed including %s as module \n " , fn ) ;
else
initprintf ( " Warning: Failed including %s on line %s:%d \n " ,
fn , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
}
else
{
parseconsounds ( included ) ;
scriptfile_close ( included ) ;
/*
// why?
int32_t tmp = parseconsounds ( included ) ;
scriptfile_close ( included ) ;
if ( tmp < 0 ) return tmp ;
*/
}
}
2010-08-14 21:32:28 +00:00
static int32_t parseconsounds ( scriptfile * script )
2009-03-15 22:58:20 +00:00
{
int32_t tokn ;
char * cmdtokptr ;
2009-03-23 19:38:29 +00:00
int32_t num_invalidsounds = 0 ;
2009-03-15 22:58:20 +00:00
tokenlist cstokens [ ] =
{
{ " include " , T_INCLUDE } ,
{ " #include " , T_INCLUDE } ,
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
{ " includedefault " , T_INCLUDEDEFAULT } ,
{ " #includedefault " , T_INCLUDEDEFAULT } ,
2009-03-15 22:58:20 +00:00
{ " define " , T_DEFINE } ,
{ " #define " , T_DEFINE } ,
{ " definesound " , T_DEFINESOUND } ,
2016-01-27 10:06:03 +00:00
{ " gamestartup " , T_GAMESTARTUP } ,
2009-03-15 22:58:20 +00:00
} ;
while ( 1 )
{
2014-03-22 09:25:15 +00:00
tokn = getatoken ( script , cstokens , ARRAY_SIZE ( cstokens ) ) ;
2009-03-15 22:58:20 +00:00
cmdtokptr = script - > ltextptr ;
switch ( tokn )
{
case T_INCLUDE :
2009-07-04 09:28:21 +00:00
{
char * fn ;
if ( ! scriptfile_getstring ( script , & fn ) )
2011-07-21 22:39:29 +00:00
parseconsounds_include ( fn , script , cmdtokptr ) ;
2009-07-04 09:28:21 +00:00
break ;
}
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
case T_INCLUDEDEFAULT :
{
2012-06-03 16:09:33 +00:00
parseconsounds_include ( G_DefaultConFile ( ) , script , cmdtokptr ) ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
break ;
}
2009-03-15 22:58:20 +00:00
case T_DEFINE :
2009-07-04 09:28:21 +00:00
{
char * name ;
int32_t number ;
2009-03-15 22:58:20 +00:00
2009-07-04 09:28:21 +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 ;
}
2016-01-27 10:06:03 +00:00
case T_GAMESTARTUP :
{
if ( scriptfile_getsymbol ( script , & g_visibility ) ) break ;
break ;
}
2009-03-15 22:58:20 +00:00
case T_DEFINESOUND :
2009-07-04 09:28:21 +00:00
{
char * definedname , * filename ;
int32_t sndnum , ps , pe , pr , m , vo ;
2011-05-02 21:33:11 +00:00
int32_t slen , duplicate = 0 ;
2009-03-15 22:58:20 +00:00
2009-07-04 09:28:21 +00:00
if ( scriptfile_getsymbol ( script , & sndnum ) ) break ;
2009-03-15 22:58:20 +00:00
2014-05-30 00:02:19 +00:00
definedname = Xstrdup ( script - > ltextptr ) ;
2009-03-15 22:58:20 +00:00
2009-07-04 09:28:21 +00:00
if ( sndnum < 0 | | sndnum > = MAXSOUNDS )
{
initprintf ( " Warning: invalid sound definition %s (sound number < 0 or >= MAXSOUNDS) on line %s:%d \n " ,
definedname , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
2011-05-02 21:33:11 +00:00
Bfree ( definedname ) ;
2009-07-04 09:28:21 +00:00
num_invalidsounds + + ;
break ;
}
2009-03-15 22:58:20 +00:00
2009-07-04 09:28:21 +00:00
if ( scriptfile_getstring ( script , & filename ) )
{
Bfree ( definedname ) ;
num_invalidsounds + + ;
break ;
}
2009-03-15 22:58:20 +00:00
2010-05-18 05:14:17 +00:00
slen = Bstrlen ( filename ) ;
2009-07-04 09:28:21 +00:00
if ( slen > = BMAX_PATH )
{
initprintf ( " Warning: invalid sound definition %s (filename too long) on line %s:%d \n " ,
definedname , script - > filename , scriptfile_getlinum ( script , cmdtokptr ) ) ;
Bfree ( definedname ) ;
num_invalidsounds + + ;
break ;
}
2009-03-15 22:58:20 +00:00
2011-05-02 21:33:11 +00:00
if ( g_sounds [ sndnum ] . filename )
{
duplicate = 1 ;
Bfree ( g_sounds [ sndnum ] . filename ) ;
}
2014-05-30 00:02:19 +00:00
g_sounds [ sndnum ] . filename = ( char * ) Xcalloc ( slen + 1 , sizeof ( uint8_t ) ) ;
2009-07-04 09:28:21 +00:00
// Hopefully noone does memcpy(..., g_sounds[].filename, BMAX_PATH)
2014-12-30 20:05:22 +00:00
2009-07-04 09:28:21 +00:00
Bmemcpy ( g_sounds [ sndnum ] . filename , filename , slen + 1 ) ;
2009-03-15 22:58:20 +00:00
2009-07-04 09:28:21 +00:00
if ( scriptfile_getnumber ( script , & ps ) ) goto BAD ;
if ( scriptfile_getnumber ( script , & pe ) ) goto BAD ;
if ( scriptfile_getnumber ( script , & pr ) ) goto BAD ;
if ( scriptfile_getnumber ( script , & m ) ) goto BAD ;
if ( ParentalLock & & ( m & 8 ) ) goto BAD ;
if ( scriptfile_getnumber ( script , & vo ) ) goto BAD ;
if ( 0 )
{
2009-03-15 22:58:20 +00:00
BAD :
2009-07-04 09:28:21 +00:00
Bfree ( definedname ) ;
2015-09-23 17:55:31 +00:00
DO_FREE_AND_NULL ( g_sounds [ sndnum ] . filename ) ;
2009-07-04 09:28:21 +00:00
num_invalidsounds + + ;
2009-03-15 22:58:20 +00:00
break ;
}
2009-07-04 09:28:21 +00:00
2011-05-02 21:33:11 +00:00
if ( g_sounds [ sndnum ] . definedname )
{
duplicate = 1 ;
Bfree ( g_sounds [ sndnum ] . definedname ) ;
}
if ( duplicate )
initprintf ( " warning: duplicate sound #%d, overwriting \n " , sndnum ) ;
2009-07-04 09:28:21 +00:00
g_sounds [ sndnum ] . definedname = definedname ; // we want to keep it for display purposes
g_sounds [ sndnum ] . ps = ps ;
g_sounds [ sndnum ] . pe = pe ;
g_sounds [ sndnum ] . pr = pr ;
g_sounds [ sndnum ] . m = m ;
g_sounds [ sndnum ] . vo = vo ;
2011-05-02 21:33:11 +00:00
if ( ! duplicate )
{
g_sndnum [ g_numsounds ] = g_definedsndnum [ g_numsounds ] = sndnum ;
g_numsounds + + ;
if ( g_numsounds = = MAXSOUNDS )
goto END ;
}
2009-07-04 09:28:21 +00:00
break ;
}
2009-03-15 22:58:20 +00:00
case T_EOF :
goto END ;
default :
break ;
}
}
END :
2009-03-23 19:38:29 +00:00
return g_numsounds ;
2009-03-15 22:58:20 +00:00
}
2010-08-14 21:32:28 +00:00
static int32_t loadconsounds ( const char * fn )
2009-03-15 22:58:20 +00:00
{
scriptfile * script ;
2011-07-21 22:39:29 +00:00
int32_t ret , i ;
2009-03-15 22:58:20 +00:00
2012-03-26 05:05:57 +00:00
initprintf ( " Loading sounds from \" %s \" \n " , fn ) ;
2009-03-15 22:58:20 +00:00
script = scriptfile_fromfile ( fn ) ;
if ( ! script )
{
2012-03-26 05:05:57 +00:00
initprintf ( " Error loading sounds: file \" %s \" not found. \n " , fn ) ;
2009-03-15 22:58:20 +00:00
return - 1 ;
}
ret = parseconsounds ( script ) ;
2011-07-21 22:39:29 +00:00
for ( i = 0 ; i < g_scriptModulesNum ; + + i )
{
parseconsounds_include ( g_scriptModules [ i ] , NULL , " null " ) ;
Bfree ( g_scriptModules [ i ] ) ;
}
2015-09-23 17:55:31 +00:00
DO_FREE_AND_NULL ( g_scriptModules ) ;
g_scriptModulesNum = 0 ;
2011-07-21 22:39:29 +00:00
2009-03-17 21:57:30 +00:00
if ( ret < 0 )
2012-03-26 05:05:57 +00:00
initprintf ( " There was an error parsing \" %s \" . \n " , fn ) ;
2009-03-17 21:57:30 +00:00
else if ( ret = = 0 )
2012-03-26 05:05:57 +00:00
initprintf ( " \" %s \" doesn't contain sound definitions. No sounds loaded. \n " , fn ) ;
2009-03-15 22:58:20 +00:00
else
initprintf ( " Loaded %d sound definitions. \n " , ret ) ;
2016-01-27 10:06:03 +00:00
if ( g_visibility ! = 512 )
initprintf ( " Global visibility: %d \n " , g_visibility ) ;
2009-03-15 22:58:20 +00:00
scriptfile_close ( script ) ;
scriptfile_clearsymbols ( ) ;
return ret ;
}
2009-03-16 15:18:01 +00:00
void ExtPreLoadMap ( void )
{
}
2009-03-15 22:58:20 +00:00
/// ^^^
2010-06-25 23:01:54 +00:00
static void m32script_interrupt_handler ( int signo )
{
if ( signo = = SIGINT )
{
vm . flags | = VMFLAG_ERROR ;
OSD_Printf ( " M32 script execution interrupted. \n " ) ;
Bmemset ( aEventEnabled , 0 , sizeof ( aEventEnabled ) ) ;
}
}
2014-05-30 00:02:16 +00:00
static void M32_HandleMemErr ( int32_t line , const char * file , const char * func )
{
initprintf ( " Out of memory in %s:%d (%s) \n " , file , line , func ) ;
osdcmd_quit ( NULL ) ;
}
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 ;
2007-01-21 23:49:07 +00:00
2014-05-30 00:02:16 +00:00
set_memerr_handler ( & M32_HandleMemErr ) ;
2014-07-06 00:09:41 +00:00
if ( ! usecwd )
2014-07-28 06:42:28 +00:00
G_AddSearchPaths ( ) ;
G_ExtInit ( ) ;
2014-07-06 00:09:41 +00:00
2006-11-17 05:05:16 +00:00
bpp = 32 ;
2006-08-10 02:10:24 +00:00
2014-05-03 15:39:24 +00:00
//#ifdef USE_OPENGL
2014-02-22 08:03:02 +00:00
if ( Bstrcmp ( setupfilename , SETUPFILENAME ) )
2012-03-26 05:05:57 +00:00
initprintf ( " Using config file \" %s \" . \n " , setupfilename ) ;
2010-05-16 22:53:08 +00:00
2011-03-08 23:02:38 +00:00
if ( loadsetup ( setupfilename ) < 0 )
initprintf ( " Configuration file not found, using defaults. \n " ) , rv = 1 ;
2014-05-03 15:39:24 +00:00
//#endif
2011-03-08 23:02:38 +00:00
Bmemcpy ( buildkeys , default_buildkeys , NUMBUILDKEYS ) ; //Trick to make build use setup.dat keys
2006-04-13 20:47:06 +00:00
kensplayerheight = 40 ; //32
zmode = 2 ;
zlock = kensplayerheight < < 8 ;
2011-04-22 22:48:06 +00:00
showinvisibility = 1 ;
2006-04-13 20:47:06 +00:00
getmessageleng = 0 ;
getmessagetimeoff = 0 ;
2011-03-04 18:47:06 +00:00
Bsprintf ( apptitle , " Mapster32 %s %s " , VERSION , s_buildRev ) ;
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
registerosdcommands ( ) ;
2006-04-13 20:47:06 +00:00
2014-02-22 08:03:02 +00:00
{
2014-05-30 00:02:19 +00:00
char * ptr = Xstrdup ( setupfilename ) , * p = strtok ( ptr , " . " ) ;
2014-02-22 08:03:02 +00:00
if ( ! Bstrcmp ( setupfilename , SETUPFILENAME ) )
Bsprintf ( tempbuf , " m32_settings.cfg " ) ;
else Bsprintf ( tempbuf , " %s_m32_settings.cfg " , p ) ;
OSD_Exec ( tempbuf ) ;
Bfree ( ptr ) ;
}
2010-08-14 21:32:28 +00:00
// backup pathsearchmode so that a later open
// will hopefully be the same file
pathsearchmode_oninit = pathsearchmode ;
2014-07-28 06:42:28 +00:00
2015-02-11 05:22:38 +00:00
G_ScanGroups ( ) ;
2014-07-28 06:42:28 +00:00
signal ( SIGINT , m32script_interrupt_handler ) ;
return rv ;
}
int32_t ExtPostStartupWindow ( void )
{
2015-02-11 05:22:38 +00:00
G_LoadGroups ( ! NoAutoLoad ) ;
2014-07-28 06:42:28 +00:00
if ( ! usecwd )
G_CleanupSearchPaths ( ) ;
if ( initengine ( ) )
{
initprintf ( " There was a problem initializing the engine. \n " ) ;
return - 1 ;
}
2015-09-23 17:54:55 +00:00
G_LoadLookups ( ) ;
2014-07-28 06:42:28 +00:00
2010-08-14 21:32:28 +00:00
loadtilegroups ( default_tiles_cfg ) ;
2007-04-21 20:25:07 +00:00
2008-08-23 10:34:59 +00:00
ReadHelpFile ( " m32help.hlp " ) ;
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
G_InitMultiPsky ( CLOUDYOCEAN , MOONSKY1 , BIGORBIT1 , LA ) ;
2011-05-12 23:31:13 +00:00
2012-10-07 15:25:52 +00:00
# ifdef LUNATIC
2012-11-10 20:59:00 +00:00
if ( Em_CreateState ( & g_EmState ) = = 0 )
2012-10-07 15:25:52 +00:00
{
2014-01-02 00:08:36 +00:00
extern const char luaJIT_BC_defs_m32 [ ] ;
2016-01-27 07:30:23 +00:00
int32_t i = L_RunString ( & g_EmState , luaJIT_BC_defs_m32 ,
2014-08-02 17:24:39 +00:00
LUNATIC_DEFS_M32_BC_SIZE , " defs_m32.ilua " ) ;
2012-11-10 20:59:00 +00:00
if ( i ! = 0 )
2012-10-07 15:25:52 +00:00
{
2012-11-10 20:59:00 +00:00
Em_DestroyState ( & g_EmState ) ;
2013-12-31 11:52:01 +00:00
initprintf ( " Lunatic: Error preparing global Lua state (code %d) \n " , i ) ;
return - 1 ;
2012-10-07 15:25:52 +00:00
}
}
# endif
2014-07-28 06:42:28 +00:00
return 0 ;
2006-04-13 20:47:06 +00:00
}
2015-09-23 17:54:42 +00:00
void ExtPostInit ( void )
{
2015-09-23 17:54:50 +00:00
InitCustomColors ( ) ;
2015-09-23 17:54:55 +00:00
2015-12-20 05:18:53 +00:00
if ( ! ( duke3d_m32_globalflags & DUKE3D_NO_PALETTE_CHANGES ) )
{
// Make base shade table at shade 0 into the identity map.
// (In the shade table of Duke3D's PALETTE.DAT, palookup[0][239]==143.)
// This makes it possible to sensibly use Lunatic's engine.saveLookupDat().
palookup [ 0 ] [ 239 ] = 239 ;
}
2015-09-23 17:54:55 +00:00
2015-10-03 11:53:19 +00:00
if ( ! ( duke3d_m32_globalflags & DUKE3D_NO_HARDCODED_FOGPALS ) )
generatefogpals ( ) ;
2015-09-23 17:54:55 +00:00
fillemptylookups ( ) ;
2015-09-23 17:54:42 +00:00
}
2006-04-13 20:47:06 +00:00
void ExtUnInit ( void )
{
2011-03-13 11:59:32 +00:00
// int32_t i;
2006-04-13 20:47:06 +00:00
// setvmode(0x03);
2011-02-10 23:15:02 +00:00
writesetup ( setupfilename ) ;
2009-03-15 22:58:20 +00:00
S_SoundShutdown ( ) ;
2006-04-13 20:47:06 +00:00
uninitgroupfile ( ) ;
2011-03-13 11:59:32 +00:00
#if 0
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
{
2015-09-23 17:55:31 +00:00
Bfree ( s_TileGroups [ i ] . pIds ) ;
Bfree ( s_TileGroups [ i ] . szText ) ;
2007-04-21 20:25:07 +00:00
}
2009-10-07 06:47:35 +00:00
for ( i = numhelppages - 1 ; i > = 0 ; i - - ) Bfree ( helppage [ i ] ) ;
2015-09-23 17:55:31 +00:00
Bfree ( helppage ) ;
2011-03-13 11:59:32 +00:00
# endif
2006-04-13 20:47:06 +00:00
}
void ExtPreCheckKeys ( void ) // just before drawrooms
{
2009-06-28 20:23:12 +00:00
int32_t i = 0 , ii ;
2008-12-19 00:53:54 +00:00
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2006-04-13 20:47:06 +00:00
{
2008-06-05 02:29:18 +00:00
if ( shadepreview )
{
2011-07-30 13:03:07 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
{
ii = highlightsector [ i ] ;
sectorpals [ ii ] [ 0 ] = sector [ ii ] . floorpal ;
sectorpals [ ii ] [ 1 ] = sector [ ii ] . ceilingpal ;
sector [ ii ] . floorpal = sector [ ii ] . ceilingpal = 6 ;
}
2011-03-23 17:41:01 +00:00
// int32_t i = 0;
2011-02-13 21:48:22 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
{
if ( sprite [ i ] . statnum = = MAXSTATUS )
continue ;
2011-03-23 17:41:01 +00:00
if ( sprite [ i ] . picnum = = SECTOREFFECTOR & &
( sprite [ i ] . lotag = = 12 | | sprite [ i ] . lotag = = 3 | | sprite [ i ] . lotag = = 4 ) )
2008-06-05 02:29:18 +00:00
{
2010-02-13 21:46:42 +00:00
int32_t w , isec = sprite [ i ] . sectnum ;
2011-02-13 21:48:22 +00:00
int32_t start_wall ;
int32_t end_wall ;
2008-06-05 02:29:18 +00:00
2010-10-31 19:54:03 +00:00
if ( isec < 0 )
continue ;
2011-02-13 21:48:22 +00:00
start_wall = sector [ isec ] . wallptr ;
end_wall = start_wall + sector [ isec ] . wallnum ;
2008-06-05 02:29:18 +00:00
for ( w = start_wall ; w < end_wall ; w + + )
{
2011-03-23 17:41:01 +00:00
if ( ! ( wallflag [ w > > 3 ] & ( 1 < < ( w & 7 ) ) ) )
2008-06-05 02:29:18 +00:00
{
wallshades [ w ] = wall [ w ] . shade ;
wallpals [ w ] = wall [ w ] . pal ;
2011-03-23 17:41:01 +00:00
wall [ w ] . shade = sprite [ i ] . shade ;
2008-06-05 02:29:18 +00:00
wall [ w ] . pal = sprite [ i ] . pal ;
2011-03-23 17:41:01 +00:00
wallflag [ w > > 3 ] | = ( 1 < < ( w & 7 ) ) ;
2009-04-24 02:53:50 +00:00
}
2011-03-23 17:41:01 +00:00
// removed: same thing with nextwalls
2008-06-05 02:29:18 +00:00
}
2010-02-13 21:46:42 +00:00
sectorshades [ isec ] [ 0 ] = sector [ isec ] . floorshade ;
sectorshades [ isec ] [ 1 ] = sector [ isec ] . ceilingshade ;
sector [ isec ] . floorshade = sprite [ i ] . shade ;
sector [ isec ] . ceilingshade = sprite [ i ] . shade ;
2011-03-23 17:41:01 +00:00
2010-02-13 21:46:42 +00:00
sectorpals [ isec ] [ 0 ] = sector [ isec ] . floorpal ;
sectorpals [ isec ] [ 1 ] = sector [ isec ] . ceilingpal ;
sector [ isec ] . floorpal = sprite [ i ] . pal ;
sector [ isec ] . ceilingpal = sprite [ i ] . pal ;
2016-06-05 04:46:28 +00:00
2011-03-23 17:41:01 +00:00
for ( w = headspritesect [ isec ] ; w > = 0 ; w = nextspritesect [ w ] )
2008-06-05 02:29:18 +00:00
{
2011-03-23 17:41:01 +00:00
if ( w = = i )
continue ;
2008-06-05 02:29:18 +00:00
spriteshades [ w ] = sprite [ w ] . shade ;
spritepals [ w ] = sprite [ w ] . pal ;
2011-03-23 17:41:01 +00:00
sprite [ w ] . shade = sprite [ i ] . shade ;
2008-06-05 02:29:18 +00:00
sprite [ w ] . pal = sprite [ i ] . pal ;
}
}
2009-09-30 21:46:07 +00:00
else if ( sprite [ i ] . picnum = = SECTOREFFECTOR & & ( sprite [ i ] . lotag = = 49 | | sprite [ i ] . lotag = = 50 ) )
{
# ifdef POLYMER
if ( sprite [ i ] . lotag = = 49 )
{
2012-12-30 20:34:34 +00:00
if ( getrendermode ( ) = = REND_POLYMER )
2009-09-30 21:46:07 +00:00
{
if ( spritelightptr [ i ] = = NULL )
{
# pragma pack(push,1)
_prlight mylight ;
# pragma pack(pop)
2011-03-23 17:41:01 +00:00
addprlight_common1 ( & mylight , i ) ;
2009-09-30 21:46:07 +00:00
}
else
{
if ( Bmemcmp ( & sprite [ i ] , spritelightptr [ i ] , sizeof ( vec3_t ) ) )
{
Bmemcpy ( spritelightptr [ i ] , & sprite [ i ] , sizeof ( vec3_t ) ) ;
spritelightptr [ i ] - > sector = sprite [ i ] . sectnum ;
spritelightptr [ i ] - > flags . invalidate = 1 ;
}
if ( SHT ! = spritelightptr [ i ] - > range )
{
spritelightptr [ i ] - > range = SHT ;
spritelightptr [ i ] - > flags . invalidate = 1 ;
}
2011-03-23 17:41:01 +00:00
if ( check_prlight_colors ( i ) )
copy_prlight_colors ( spritelightptr [ i ] , i ) ;
2012-11-15 14:28:41 +00:00
if ( ( int ) ! ! ( CS & 128 ) ! = spritelightptr [ i ] - > publicflags . negative )
2012-10-21 04:52:43 +00:00
{
spritelightptr [ i ] - > publicflags . negative = ! ! ( CS & 128 ) ;
}
2009-09-30 21:46:07 +00:00
}
}
}
if ( sprite [ i ] . lotag = = 50 )
{
2012-12-30 20:34:34 +00:00
if ( getrendermode ( ) = = REND_POLYMER )
2009-09-30 21:46:07 +00:00
{
if ( spritelightptr [ i ] = = NULL )
{
# pragma pack(push,1)
_prlight mylight ;
# pragma pack(pop)
mylight . radius = ( 256 - ( SS + 128 ) ) < < 1 ;
mylight . faderadius = ( int16_t ) ( mylight . radius * 0.75f ) ;
2009-10-07 06:47:35 +00:00
mylight . tilenum = OW ;
2012-10-21 03:41:13 +00:00
mylight . publicflags . emitshadow = ! ( CS & 64 ) ;
2009-09-30 21:46:07 +00:00
2011-03-23 17:41:01 +00:00
addprlight_common1 ( & mylight , i ) ;
2009-09-30 21:46:07 +00:00
}
else
{
if ( Bmemcmp ( & sprite [ i ] , spritelightptr [ i ] , sizeof ( vec3_t ) ) )
{
Bmemcpy ( spritelightptr [ i ] , & sprite [ i ] , sizeof ( vec3_t ) ) ;
spritelightptr [ i ] - > sector = sprite [ i ] . sectnum ;
spritelightptr [ i ] - > flags . invalidate = 1 ;
}
if ( SHT ! = spritelightptr [ i ] - > range )
{
spritelightptr [ i ] - > range = SHT ;
spritelightptr [ i ] - > flags . invalidate = 1 ;
}
2011-03-23 17:41:01 +00:00
if ( check_prlight_colors ( i ) )
copy_prlight_colors ( spritelightptr [ i ] , i ) ;
2009-09-30 21:46:07 +00:00
if ( ( ( 256 - ( SS + 128 ) ) < < 1 ) ! = spritelightptr [ i ] - > radius )
{
spritelightptr [ i ] - > radius = ( 256 - ( SS + 128 ) ) < < 1 ;
spritelightptr [ i ] - > faderadius = ( int16_t ) ( spritelightptr [ i ] - > radius * 0.75f ) ;
spritelightptr [ i ] - > flags . invalidate = 1 ;
}
if ( SA ! = spritelightptr [ i ] - > angle )
{
spritelightptr [ i ] - > angle = SA ;
spritelightptr [ i ] - > flags . invalidate = 1 ;
}
if ( SH ! = spritelightptr [ i ] - > horiz )
{
spritelightptr [ i ] - > horiz = SH ;
spritelightptr [ i ] - > flags . invalidate = 1 ;
}
2012-11-15 14:28:41 +00:00
if ( ( int ) ! ( CS & 64 ) ! = spritelightptr [ i ] - > publicflags . emitshadow )
2012-10-21 03:41:13 +00:00
{
spritelightptr [ i ] - > publicflags . emitshadow = ! ( CS & 64 ) ;
}
2012-11-15 14:28:41 +00:00
if ( ( int ) ! ! ( CS & 128 ) ! = spritelightptr [ i ] - > publicflags . negative )
2012-10-21 04:52:43 +00:00
{
spritelightptr [ i ] - > publicflags . negative = ! ! ( CS & 128 ) ;
}
2009-10-07 06:47:35 +00:00
spritelightptr [ i ] - > tilenum = OW ;
2009-09-30 21:46:07 +00:00
}
}
}
# endif // POLYMER
}
2011-02-13 21:48:22 +00:00
}
2009-04-24 06:04:13 +00:00
}
2010-05-18 05:14:17 +00:00
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 ) ;
2010-05-18 05:14:17 +00:00
2008-12-19 00:53:54 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2011-01-20 10:52:33 +00:00
begindrawing ( ) ; //{{{
2008-12-19 00:53:54 +00:00
2009-06-28 20:23:12 +00:00
// if (cursectornum >= 0)
// fillsector(cursectornum, 31);
2008-12-19 00:53:54 +00:00
2015-07-08 03:34:31 +00:00
if ( graphicsmode & & ( ! m32_sideview | | m32_sideelev = = 512 ) & & zoom > = 256 )
2008-12-19 00:53:54 +00:00
{
2012-03-14 22:30:24 +00:00
for ( i = ii = 0 ; i < MAXSPRITES & & ii < Numsprites ; i + + )
2008-12-25 12:56:25 +00:00
{
2012-11-04 23:03:22 +00:00
int32_t daang = 0 , flags , shade ;
int32_t picnum , frames ;
int32_t xp1 , yp1 ;
2008-12-28 23:27:24 +00:00
if ( ( sprite [ i ] . cstat & 48 ) ! = 0 | | sprite [ i ] . statnum = = MAXSTATUS ) continue ;
2009-06-28 20:23:12 +00:00
ii + + ;
2008-12-25 12:56:25 +00:00
picnum = sprite [ i ] . picnum ;
2011-04-22 22:48:06 +00:00
daang = flags = frames = shade = 0 ;
2008-12-25 12:56:25 +00:00
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-10-15 23:08:47 +00:00
case NEWBEASTSTAYPUT :
case BOSS1STAYPUT :
2009-07-04 09:28:21 +00:00
{
int32_t k ;
if ( frames ! = 0 )
2008-12-25 12:56:25 +00:00
{
2009-07-04 09:28:21 +00:00
if ( frames = = 10 ) frames = 0 ;
k = 1536 ; //getangle(tspr->x-pos.x,tspr->y-pos.y);
2015-07-08 03:34:42 +00:00
k = ( ( ( sprite [ i ] . ang + 3072 + 128 - k + ( m32_sideview ? ( 2048 - m32_sideang ) : 0 ) ) & 2047 ) > > 8 ) & 7 ;
2009-07-04 09:28:21 +00:00
//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-07-04 09:28:21 +00:00
picnum + = k ;
2011-04-22 22:48:06 +00:00
daang = 0 ;
2009-07-04 09:28:21 +00:00
flags & = ~ 4 ;
2008-12-25 12:56:25 +00:00
}
2009-07-04 09:28:21 +00:00
else
2008-12-28 23:27:24 +00:00
{
2009-07-04 09:28:21 +00:00
picnum + = 8 - k ;
2011-04-22 22:48:06 +00:00
daang = 1024 ;
2009-07-04 09:28:21 +00:00
flags | = 4 ;
2008-12-28 23:27:24 +00:00
}
2009-07-04 09:28:21 +00:00
}
2008-12-25 12:56:25 +00:00
2009-07-04 09:28:21 +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-07-04 09:28:21 +00:00
2014-09-30 04:14:21 +00:00
if ( tilesiz [ picnum ] . x = = 0 )
2009-07-04 09:28:21 +00:00
picnum - = 5 ; //Hack, for actors
}
break ;
2008-12-25 12:56:25 +00:00
default :
break ;
}
2015-07-17 00:12:48 +00:00
shade = ( i + 16384 = = pointhighlight ) ? 7 - ( M32_THROB > > 1 ) : sprite [ i ] . shade ;
2016-06-05 04:46:28 +00:00
2015-07-08 03:34:31 +00:00
if ( m32_sideview )
{
screencoords ( & xp1 , & yp1 , sprite [ i ] . x - pos . x , sprite [ i ] . y - pos . y , zoom ) ;
yp1 + = midydim16 + getscreenvdisp ( sprite [ i ] . z - pos . z , zoom ) ;
yp1 - = mulscale14 ( tilesiz [ picnum ] . y < < 2 , zoom ) ;
xp1 + = halfxdim16 ;
}
2016-06-05 04:46:28 +00:00
else
2015-07-08 03:34:31 +00:00
ovhscrcoords ( sprite [ i ] . x , sprite [ i ] . y - ( tilesiz [ picnum ] . y < < 2 ) , & xp1 , & yp1 ) ;
2008-12-25 12:56:25 +00:00
2015-07-08 03:34:31 +00:00
ydim16 = ydim - STATUS2DSIZ2 ; // XXX?
2009-05-05 21:25:06 +00:00
2015-07-10 07:56:48 +00:00
int f = mulscale12 ( 128 , zoom ) ;
if ( xp1 < - f | | xp1 > xdim + f | | yp1 < - f | | yp1 > ydim16 + f )
2008-12-28 23:27:24 +00:00
continue ;
2015-07-10 07:56:48 +00:00
2015-07-11 23:07:47 +00:00
const int32_t oviewingrange = viewingrange , oyxaspect = yxaspect ;
setaspect ( yxaspect , divscale16 ( sprite [ i ] . yrepeat , sprite [ i ] . xrepeat ) ) ;
2011-04-22 22:48:06 +00:00
rotatesprite ( xp1 < < 16 , yp1 < < 16 , zoom < < 5 , daang , picnum ,
2015-07-11 23:07:47 +00:00
shade , sprite [ i ] . pal , flags | 1024 , 0 , 0 , xdim - 1 , ydim16 - 1 ) ;
setaspect ( oviewingrange , oyxaspect ) ;
2008-12-25 12:56:25 +00:00
}
}
2008-12-23 23:27:53 +00:00
2010-08-11 22:37:45 +00:00
if ( showambiencesounds )
2010-11-27 22:12:24 +00:00
{
for ( ii = 0 ; ii < numsectors ; ii + + )
for ( i = headspritesect [ ii ] ; i > = 0 ; i = nextspritesect [ i ] )
2011-02-13 21:48:22 +00:00
{
2012-11-04 23:03:22 +00:00
int32_t radius , col ;
int32_t xp1 , yp1 ;
2015-07-17 00:12:48 +00:00
if ( sprite [ i ] . picnum ! = MUSICANDSFX /*|| zoom < 256*/ | | sprite [ i ] . hitag < 1000 )
2011-02-13 21:48:22 +00:00
continue ;
2010-08-11 22:37:45 +00:00
2011-02-13 21:48:22 +00:00
if ( showambiencesounds = = 1 & & sprite [ i ] . sectnum ! = cursectnum )
continue ;
screencoords ( & xp1 , & yp1 , sprite [ i ] . x - pos . x , sprite [ i ] . y - pos . y , zoom ) ;
if ( m32_sideview )
yp1 + = getscreenvdisp ( sprite [ i ] . z - pos . z , zoom ) ;
drawlinepat = 0xf0f0f0f0 ;
2015-07-17 00:12:48 +00:00
col = editorcolors [ 6 ] ;
if ( i + 16384 = = pointhighlight )
{
radius = mulscale14 ( sprite [ i ] . hitag - ( M32_THROB < < 2 ) , zoom ) ;
col + = M32_THROB > > 1 ;
}
else radius = mulscale14 ( sprite [ i ] . hitag , zoom ) ;
drawcircle16 ( halfxdim16 + xp1 , midydim16 + yp1 , radius , scalescreeny ( 16384 ) , col ) ;
2011-02-13 21:48:22 +00:00
drawlinepat = 0xffffffff ;
}
2010-11-27 22:12:24 +00:00
}
2008-12-19 00:53:54 +00:00
2011-01-20 10:52:33 +00:00
enddrawing ( ) ; //}}}
2006-04-13 20:47:06 +00:00
}
2012-08-13 18:25:37 +00:00
void ExtAnalyzeSprites ( int32_t ourx , int32_t oury , int32_t oura , int32_t smoothr )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , k ;
2015-01-11 04:55:07 +00:00
tspritetype * tspr ;
2011-04-09 13:27:08 +00:00
int32_t frames = 0 , sh ;
2006-04-13 20:47:06 +00:00
2012-08-13 18:25:37 +00:00
UNREFERENCED_PARAMETER ( ourx ) ;
UNREFERENCED_PARAMETER ( oury ) ;
UNREFERENCED_PARAMETER ( oura ) ;
UNREFERENCED_PARAMETER ( smoothr ) ;
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 ;
2011-03-23 17:41:01 +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 )
2009-07-04 09:28:21 +00:00
{
2006-11-16 03:02:42 +00:00
case SEENINE :
tspr - > xrepeat = 0 ;
2009-07-04 09:28:21 +00:00
}
2006-04-13 20:47:06 +00:00
2010-09-27 21:52:04 +00:00
if ( showinvisibility & & ( tspr - > cstat & 32768 ) )
{
tspr - > pal = 6 ;
2012-11-15 14:28:18 +00:00
tspr - > cstat & = ( uint16_t ) ~ 32768 ;
2010-09-27 21:52:04 +00:00
tspr - > cstat | = 2 + 512 ;
}
2011-04-09 13:27:08 +00:00
/* Shade preview rules (thanks to Gambini)
*
* 1 st rule : Any pal value not equal to 0 in the floor of a sector will
* turn all the sprites within this sector to that pal value .
*
* 2 nd rule : The shade of a sprite will be taken from the floor unless the
* ceiling is parallaxed , in which case will be taken from the
* ceiling . But not the pal which always follow the 1 st rule .
*
* 3 rd rule : relative to wall sprites will keep their own shade unless
* they ' re actors , but they will still retain the floor pal .
*/
if ( shadepreview )
2006-04-13 20:47:06 +00:00
{
2010-10-31 19:54:03 +00:00
if ( tspr - > sectnum < 0 )
continue ;
2014-12-13 22:33:04 +00:00
const int32_t wallaligned = ( tspr - > cstat & 16 ) ;
const int32_t fpal = sector [ tspr - > sectnum ] . floorpal ;
2014-02-16 19:16:05 +00:00
2011-04-09 13:27:08 +00:00
// 1st rule
2014-02-16 19:16:05 +00:00
// Compare with game.c:G_MaybeTakeOnFloorPal()
2014-12-13 22:33:04 +00:00
if ( fpal & & ! g_noFloorPal [ fpal ] )
2014-02-16 19:16:05 +00:00
tspr - > pal = fpal ;
2006-04-13 20:47:06 +00:00
2011-04-09 13:27:08 +00:00
// 2nd and 3rd rule minus "actor condition"
2014-02-22 19:38:51 +00:00
if ( ! wallaligned & & ( tspr - > cstat & CSTAT_SPRITE_NOSHADE ) = = 0 )
2011-02-13 21:48:22 +00:00
{
2011-04-09 13:27:08 +00:00
if ( sector [ tspr - > sectnum ] . ceilingstat & 1 )
sh = sector [ tspr - > sectnum ] . ceilingshade ;
else
sh = sector [ tspr - > sectnum ] . floorshade ;
inpclamp ( & sh , - 127 , 127 ) ;
tspr - > shade = sh ;
2011-02-13 21:48:22 +00:00
}
2006-04-13 20:47:06 +00:00
}
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 ;
2009-09-09 07:19:14 +00:00
case ROTATEGUN :
2006-11-16 03:02:42 +00:00
case CAMERA1 :
case APLAYER :
if ( frames = = 0 ) frames = 1 ;
case GREENSLIME :
case PIGCOPSTAYPUT :
case LIZMANSTAYPUT :
case LIZTROOPSTAYPUT :
case LIZMANSPITTING :
case LIZMANFEEDING :
case LIZMANJUMP :
2009-10-15 23:08:47 +00:00
case NEWBEASTSTAYPUT :
case BOSS1STAYPUT :
2006-11-16 03:02:42 +00:00
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
2011-03-04 08:50:58 +00:00
# ifdef USE_OPENGL
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
}
2010-05-18 05:14:17 +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
2014-09-30 04:14:21 +00:00
if ( tilesiz [ tspr - > picnum ] . x = = 0 )
2007-02-18 22:16:01 +00:00
tspr - > picnum - = 5 ; //Hack, for actors
}
2006-11-16 03:02:42 +00:00
break ;
2011-03-23 17:41:01 +00:00
2006-11-16 03:02:42 +00:00
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 ;
2011-08-20 11:54:16 +00:00
# if M32_UNDO
2009-05-05 16:21:33 +00:00
if ( mapstate = = NULL )
2008-06-09 23:41:54 +00:00
{
2009-06-28 20:23:12 +00:00
// map_revision = 0;
2009-05-05 16:21:33 +00:00
create_map_snapshot ( ) ; // initial map state
2009-06-28 20:23:12 +00:00
// Bfree(mapstate->next);
// mapstate = mapstate->prev;
2008-06-09 23:41:54 +00:00
}
2011-08-20 11:54:16 +00:00
# endif
2015-07-17 00:12:48 +00:00
if ( cursectnum > = 0 & & sector [ cursectnum ] . lotag = = 2 )
{
if ( sector [ cursectnum ] . ceilingpicnum = = FLOORSLIME )
SetGamePalette ( SLIMEPAL ) ;
else
SetGamePalette ( WATERPAL ) ;
}
else SetGamePalette ( BASEPAL ) ;
2015-07-08 03:34:42 +00:00
if ( keystatus [ KEYSC_F10 ] )
{
keystatus [ KEYSC_F10 ] = 0 ;
2015-07-11 14:13:04 +00:00
if ( ! m32_2d3d_resolutions_match ( ) )
2015-07-10 07:56:48 +00:00
message ( " 2d and 3d mode resolutions don't match! " ) ;
else if ( ! in3dmode ( ) )
2015-07-08 03:34:42 +00:00
{
if ( eitherSHIFT )
{
// shrinking the size while in a corner pulls the PIP into that corner
if ( m32_2d3d . x + XSIZE_2D3D > = xdim2d - 5 )
m32_2d3d . x = 0xffff ;
if ( m32_2d3d . y + YSIZE_2D3D > = ydim2d - 5 - STATUS2DSIZ2 )
m32_2d3d . y = 0xffff ;
if ( + + m32_2d3dsize > 5 )
m32_2d3dsize = 3 ;
2015-07-10 07:56:48 +00:00
message ( " 2d3d size %d " , m32_2d3dsize ) ;
2015-07-08 03:34:42 +00:00
}
else
{
m32_2d3dmode = ! m32_2d3dmode ;
2015-07-10 07:56:48 +00:00
message ( " 2d3d mode %s " , m32_2d3dmode ? " enabled " : " disabled " ) ;
2015-07-08 03:34:42 +00:00
}
}
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( A ) ) // 'A
2006-04-13 20:47:06 +00:00
{
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) )
2010-05-18 05:14:17 +00:00
autosave = autosave ? 0 : getnumber256 ( " Autosave interval, in seconds: " , 180 , 3600 , 0 ) ;
else
autosave = autosave ? 0 : getnumber16 ( " Autosave interval, in seconds: " , 180 , 3600 , 0 ) ;
2008-10-14 08:40:59 +00:00
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
}
2010-05-18 05:14:17 +00:00
if ( keystatus [ KEYSC_QUOTE ] & & PRESSED_KEYSC ( N ) ) // 'N
2006-04-13 20:47:06 +00:00
{
2011-09-16 19:17:48 +00:00
m32_clipping - - ;
if ( m32_clipping < 0 )
m32_clipping = 2 ;
message ( " Clipping %s " , m32_clipping = = 0 ? " disabled " :
( m32_clipping = = 1 ? " non-masks only " : " enabled " ) ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-18 05:14:17 +00:00
if ( eitherCTRL & & PRESSED_KEYSC ( N ) ) // CTRL+N
2008-05-18 21:09:30 +00:00
{
2010-05-18 05:14:17 +00:00
spnoclip = ! spnoclip ;
message ( " Sprite clipping %s " , spnoclip ? " disabled " : " enabled " ) ;
2008-05-18 21:09:30 +00:00
}
2008-05-16 00:23:33 +00:00
if ( eitherCTRL ) //CTRL
2008-05-16 19:51:38 +00:00
{
2013-05-30 09:13:32 +00:00
if ( ! in3dmode ( ) )
2012-04-10 20:14:31 +00:00
if ( PRESSED_KEYSC ( P ) ) // Ctrl-P: Map playtesting
2009-05-16 04:07:09 +00:00
test_map ( eitherALT ) ;
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
{
2010-05-18 05:14:17 +00:00
keystatus [ KEYSC_S ] = 0 ;
2011-01-16 00:23:39 +00:00
2011-02-10 23:15:02 +00:00
i = CheckMapCorruption ( 4 , 0 ) ;
2011-01-16 00:23:39 +00:00
if ( i < 4 )
{
2011-10-31 19:49:43 +00:00
Bsprintf ( tempbuf , " Save to %s? " , levelname ) ;
if ( ! AskIfSure ( tempbuf ) )
{
2013-06-28 14:07:44 +00:00
if ( SaveBoard ( levelname , M32_SB_ASKOV ) ! = NULL )
{
message ( " Board saved to %s " , levelname ) ;
asksave = 0 ;
lastsave = totalclock ;
}
2011-10-31 19:49:43 +00:00
}
2011-01-16 00:23:39 +00:00
}
else
message ( " Map is heavily corrupted, not saving. See OSD for details. " ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-05-16 19:51:38 +00:00
if ( keystatus [ KEYSC_L ] ) // L
{
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 ;
2012-10-01 17:52:44 +00:00
const char * f = GetSaveBoardFilename ( levelname ) ;
2008-05-16 19:51:38 +00:00
lastsave = totalclock ;
2009-06-28 20:23:12 +00:00
// sectorhighlightstat = -1;
// newnumwalls = -1;
// joinsector[0] = -1;
// circlewall = -1;
// circlepoints = 7;
2008-05-16 19:51:38 +00:00
2011-01-16 00:23:39 +00:00
if ( LoadBoard ( f , 0 ) )
message ( " Invalid map format. " ) ;
2008-05-16 19:51:38 +00:00
2009-02-19 16:47:54 +00:00
pos . x = sposx ; pos . y = sposy ; pos . z = sposz ; ang = sang ;
2011-01-16 00:23:39 +00:00
updatesectorz ( pos . x , pos . y , pos . z , & cursectnum ) ;
keystatus [ KEYSC_L ] = 0 ;
2008-05-16 19:51:38 +00:00
}
}
}
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 ;
}
if ( getmessageleng > 0 )
{
2013-05-30 09:13:32 +00:00
if ( ! in3dmode ( ) )
2010-12-19 22:47:10 +00:00
printmessage16 ( " %s " , getmessage ) ;
2006-04-13 20:47:06 +00:00
if ( totalclock > getmessagetimeoff )
getmessageleng = 0 ;
}
}
void ExtCheckKeys ( void )
{
2009-05-06 23:58:53 +00:00
static int32_t soundinit = 0 ;
2009-06-16 22:11:13 +00:00
static int32_t lastbstatus = 0 ;
2009-05-06 23:58:53 +00:00
if ( ! soundinit )
{
g_numsounds = 0 ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
2012-06-03 16:09:33 +00:00
loadconsounds ( G_ConFile ( ) ) ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
2009-05-06 23:58:53 +00:00
if ( g_numsounds > 0 )
{
if ( S_SoundStartup ( ) ! = 0 )
S_SoundShutdown ( ) ;
}
soundinit = 1 ;
}
2013-05-30 09:13:32 +00:00
if ( in3dmode ( ) & & shadepreview )
2008-06-05 02:29:18 +00:00
{
2011-07-30 13:03:07 +00:00
int32_t i = 0 , ii ;
2011-02-15 21:02:43 +00:00
int32_t w , isec , start_wall , end_wall ;
2011-07-30 13:03:07 +00:00
for ( i = 0 ; i < highlightsectorcnt ; i + + )
{
ii = highlightsector [ i ] ;
sector [ ii ] . floorpal = sectorpals [ ii ] [ 0 ] ;
sector [ ii ] . ceilingpal = sectorpals [ ii ] [ 1 ] ;
}
2011-02-15 21:02:43 +00:00
for ( i = 0 ; i < MAXSPRITES ; i + + )
2008-06-05 02:29:18 +00:00
{
2011-03-23 17:41:01 +00:00
if ( sprite [ i ] . statnum = = MAXSTATUS | | sprite [ i ] . picnum ! = SECTOREFFECTOR )
2011-02-15 21:02:43 +00:00
continue ;
2008-06-05 02:29:18 +00:00
2011-03-23 17:41:01 +00:00
if ( sprite [ i ] . lotag ! = 12 & & sprite [ i ] . lotag ! = 3 & & sprite [ i ] . lotag ! = 4 )
2011-02-15 21:02:43 +00:00
continue ;
2010-10-31 19:54:03 +00:00
2011-02-15 21:02:43 +00:00
isec = sprite [ i ] . sectnum ;
if ( isec < 0 )
continue ;
start_wall = sector [ isec ] . wallptr ;
end_wall = start_wall + sector [ isec ] . wallnum ;
for ( w = start_wall ; w < end_wall ; w + + )
{
2011-03-23 17:41:01 +00:00
if ( wallflag [ w > > 3 ] & ( 1 < < ( w & 7 ) ) )
2011-02-15 21:02:43 +00:00
{
wall [ w ] . shade = wallshades [ w ] ;
wall [ w ] . pal = wallpals [ w ] ;
2011-03-23 17:41:01 +00:00
wallflag [ w > > 3 ] & = ~ ( 1 < < ( w & 7 ) ) ;
2011-02-15 21:02:43 +00:00
}
2011-03-23 17:41:01 +00:00
// removed: same thing with nextwalls
2011-02-15 21:02:43 +00:00
}
sector [ isec ] . floorshade = sectorshades [ isec ] [ 0 ] ;
sector [ isec ] . ceilingshade = sectorshades [ isec ] [ 1 ] ;
sector [ isec ] . floorpal = sectorpals [ isec ] [ 0 ] ;
sector [ isec ] . ceilingpal = sectorpals [ isec ] [ 1 ] ;
for ( w = headspritesect [ isec ] ; w > = 0 ; w = nextspritesect [ w ] )
{
if ( w = = i )
2016-06-05 04:46:28 +00:00
continue ;
2011-02-15 21:02:43 +00:00
sprite [ w ] . shade = spriteshades [ w ] ;
sprite [ w ] . pal = spritepals [ w ] ;
}
2016-06-05 04:46:28 +00:00
2008-06-05 02:29:18 +00:00
}
}
2011-02-15 21:02:43 +00:00
2009-06-16 22:11:13 +00:00
lastbstatus = bstatus ;
2006-04-13 20:47:06 +00:00
readmousebstatus ( & bstatus ) ;
2009-05-05 16:21:33 +00:00
Keys2d3d ( ) ;
2015-07-08 03:34:42 +00:00
// 2d3d mode
if ( ( in3dmode ( ) & & ! m32_is2d3dmode ( ) ) | | m32_is2d3dmode ( ) )
2006-04-13 20:47:06 +00:00
{
2015-08-15 21:28:49 +00:00
# ifdef USE_OPENGL
2015-07-08 03:34:42 +00:00
int bakrendmode = rendmode ;
if ( m32_is2d3dmode ( ) )
rendmode = REND_CLASSIC ;
2015-08-15 21:28:49 +00:00
# endif
2015-07-08 03:34:42 +00:00
2006-04-13 20:47:06 +00:00
Keys3d ( ) ;
2010-07-03 08:53:57 +00:00
editinput ( ) ;
if ( infobox & 2 )
m32_showmouse ( ) ;
2015-07-08 03:34:42 +00:00
2015-08-15 21:28:49 +00:00
# ifdef USE_OPENGL
2015-07-08 03:34:42 +00:00
rendmode = bakrendmode ;
2015-08-15 21:28:49 +00:00
# endif
2006-04-13 20:47:06 +00:00
}
2015-07-08 03:34:42 +00:00
else if ( ! in3dmode ( ) )
2011-01-03 22:04:20 +00:00
{
Keys2d ( ) ;
if ( autocorruptcheck > 0 & & totalclock > corruptchecktimer )
{
2011-02-13 15:15:37 +00:00
if ( CheckMapCorruption ( 3 , 0 ) > = 3 )
printmessage16 ( " Corruption detected. See OSD for details. " ) ;
2011-01-03 22:04:20 +00:00
corruptchecktimer = totalclock + 120 * autocorruptcheck ;
}
}
2009-05-05 16:21:33 +00:00
2011-03-08 23:02:38 +00:00
if ( asksave = = 1 )
asksave + + ;
2011-08-20 11:54:16 +00:00
else if ( asksave = = 2 & & ( bstatus + lastbstatus ) = = 0
# if M32_UNDO
& & mapstate
# endif
)
2009-05-05 16:21:33 +00:00
{
2011-03-02 21:21:47 +00:00
int32_t i ;
2011-03-08 23:02:38 +00:00
// check keys so that e.g. bulk deletions won't produce
// as much revisions as deleted sprites
2014-03-22 09:25:15 +00:00
for ( i = ARRAY_SIZE ( keystatus ) - 1 ; i > = 0 ; i - - )
2011-03-02 21:21:47 +00:00
if ( keystatus [ i ] )
break ;
if ( i = = - 1 )
{
2011-08-20 11:54:16 +00:00
# if M32_UNDO
2011-03-02 21:21:47 +00:00
create_map_snapshot ( ) ;
2011-11-25 09:50:40 +00:00
# else
2012-03-17 11:34:54 +00:00
CheckMapCorruption ( 5 , 0 ) ;
2011-08-20 11:54:16 +00:00
# endif
2011-03-02 21:21:47 +00:00
asksave + + ;
}
2009-05-05 16:21:33 +00:00
}
2011-03-08 23:02:38 +00:00
else if ( asksave = = 3 )
2011-03-02 21:21:47 +00:00
asksave + + ;
2009-05-05 16:21:33 +00:00
2010-05-18 05:14:17 +00:00
if ( totalclock > autosavetimer & & autosave )
2009-05-05 16:21:33 +00:00
{
2011-03-08 23:02:38 +00:00
if ( asksave = = 4 )
2009-05-05 16:21:33 +00:00
{
2012-03-17 11:34:54 +00:00
if ( CheckMapCorruption ( 5 , 0 ) > = 4 )
2011-01-16 00:23:39 +00:00
{
2013-06-28 14:07:44 +00:00
if ( SaveBoard ( " autosave_corrupt.map " , M32_SB_NOEXT ) ! = NULL )
message ( " Board autosaved to AUTOSAVE_CORRUPT.MAP " ) ;
2011-01-16 00:23:39 +00:00
}
else
{
2013-06-28 14:07:44 +00:00
if ( SaveBoard ( " autosave.map " , 0 ) ! = NULL )
message ( " Board autosaved to AUTOSAVE.MAP " ) ;
2011-01-16 00:23:39 +00:00
}
2011-03-08 23:02:38 +00:00
asksave + + ;
2009-05-05 16:21:33 +00:00
}
autosavetimer = totalclock + 120 * autosave ;
}
2010-05-18 05:14:17 +00:00
if ( PRESSED_KEYSC ( F12 ) ) //F12
2009-05-05 16:21:33 +00:00
{
2011-05-07 18:23:34 +00:00
# ifdef ENGINE_SCREENSHOT_DEBUG
extern int32_t engine_screenshot ;
engine_screenshot = 1 ;
# else
2011-05-15 22:37:24 +00:00
extern int16_t capturecount ;
2014-07-28 06:43:16 +00:00
Bsnprintf ( tempbuf , sizeof ( tempbuf ) , " %s %s " , AppProperName , ExtGetVer ( ) ) ;
2011-05-07 18:23:34 +00:00
screencapture ( " captxxxx.tga " , eitherSHIFT , tempbuf ) ;
2011-05-15 22:37:24 +00:00
silentmessage ( " Saved screenshot %04d " , capturecount - 1 ) ;
2011-05-07 18:23:34 +00:00
# endif
2009-05-05 16:21:33 +00:00
}
2006-04-13 20:47:06 +00:00
}
2014-07-28 06:44:37 +00:00
////
2011-01-03 22:04:20 +00:00
2014-07-28 06:44:37 +00:00
void faketimerhandler ( void )
{
sampletimer ( ) ;
}
2011-02-10 23:15:02 +00:00
2015-12-26 15:42:13 +00:00
void SetGamePalette ( int32_t palid )
2011-08-01 19:04:41 +00:00
{
2015-12-26 15:42:13 +00:00
if ( ( unsigned ) palid > = MAXBASEPALS )
palid = 0 ;
setbrightness ( GAMMA_CALC , palid , 2 ) ;
2011-08-01 19:04:41 +00:00
}
2011-02-21 23:08:21 +00:00
2014-07-28 06:44:37 +00:00
static void SearchSectors ( int32_t dir ) // <0: backwards, >=0: forwards
2011-02-10 23:15:02 +00:00
{
2014-07-28 06:44:37 +00:00
int32_t ii = 0 ;
dir = 1 - 2 * ( dir < 0 ) ;
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
2014-07-28 06:44:37 +00:00
if ( cursector_lotag ! = 0 )
2011-02-10 23:15:02 +00:00
{
2014-07-28 06:44:37 +00:00
if ( ( dir > 0 & & cursectornum < MAXSECTORS ) | | ( dir < 0 & & cursectornum > = 0 ) )
cursectornum + = dir ;
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
2014-07-28 06:44:37 +00:00
for ( ii = cursectornum ; ii > = 0 & & ii < numsectors ; ii + = dir )
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
{
2014-07-28 06:44:37 +00:00
if ( sector [ ii ] . lotag = = cursector_lotag )
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
{
2014-07-28 06:44:37 +00:00
pos . x = wall [ sector [ ii ] . wallptr ] . x ;
pos . y = wall [ sector [ ii ] . wallptr ] . y ;
printmessage16 ( " %s Sector search: found " , dir < 0 ? " < " : " > " ) ;
cursectornum = ii ;
return ;
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
}
2011-02-10 23:15:02 +00:00
}
* New m32script commands:
- sethighlightsector <sectnum> <on?>
- updatehighlightsector
- collectsectors <<array_to_collect_sectnums>> <initial_sector> <<num_collected_sectors>> <sector_filtering_state>
The latter does a breadth-first search starting from an initial sector and collects nextsectors only when the filtering state, given a sectnum as RETURN input, writes a nonzero value into RETURN. As a usage example, a.m32 includes the state 'collect_teleporting_sectors', that collects all sectors containing an SE7 and highlights them afterwards. This way, it should be possible to retrofit old maps with TROR by distributing small scripts that do most of the work (right now, joining has to be done by hand, though).
* corruption checker: for the 'nextwall inconsistent with nextsector' corruption, suggest an alternative fix by searching fitting nextwalls and changing the nextwall of the corrupt wall (as opposed to the nextsector). It will display with a leading '?' in the listing, and can be demanded by suffixing 'corruptcheck tryfix' with it. For example,
corruptcheck tryfix 9-21 ?
would fix some corruptions in Billy Boy's cranium.map without introducing drawing errors.
* fix demo playback (tueidj figured this out)
git-svn-id: https://svn.eduke32.com/eduke32@1927 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-03 22:51:28 +00:00
}
2014-07-28 06:44:37 +00:00
printmessage16 ( " %s Sector search: none found " , dir < 0 ? " < " : " > " ) ;
2011-02-10 23:15:02 +00:00
}
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
//////////////////// manual editing ////////////////////
// Build edit originally by Ed Coolidge <semicharm@earthlink.net>
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
static char med_disptext [ 80 ] ;
static char med_edittext [ 80 ] ;
static const char * med_typename = " " ;
static int32_t med_dispwidth = 24 ;
static int32_t med_editval = 0 ;
static int32_t med_thenum = - 1 ;
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
static void handlemed ( int32_t dohex , const char * disp_membername , const char * edit_membername ,
void * themember , int32_t thesizeof , int32_t themax , int32_t sign )
{
int32_t i , val ;
int32_t flags = sign ;
sign & = 1 ;
2012-03-17 11:34:32 +00:00
2015-08-30 07:24:53 +00:00
assert ( ! dohex | | thesizeof = = sizeof ( int16_t ) ) ;
2014-07-28 06:44:37 +00:00
if ( thesizeof = = sizeof ( int8_t ) )
2013-04-21 19:55:18 +00:00
{
2014-07-28 06:44:37 +00:00
if ( sign )
val = * ( int8_t * ) themember ;
else
val = * ( uint8_t * ) themember ;
2013-04-21 19:55:18 +00:00
}
2014-07-28 06:44:37 +00:00
else if ( thesizeof = = sizeof ( int16_t ) )
2015-08-30 07:24:53 +00:00
{
2014-07-28 06:44:37 +00:00
val = * ( int16_t * ) themember ;
2015-08-30 07:24:53 +00:00
// Bug fix : Do not sign extend when dealing with hex values
if ( dohex )
val & = 0xFFFF ;
}
2014-07-28 06:44:37 +00:00
else //if (thesizeof==sizeof(int32_t))
val = * ( int32_t * ) themember ;
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
if ( dohex )
i = Bsprintf ( med_disptext , " %s: %x " , disp_membername , val ) ;
else
i = Bsprintf ( med_disptext , " %s: %d " , disp_membername , val ) ;
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
for ( ; i < med_dispwidth ; i + + )
med_disptext [ i ] = ' ' ;
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
if ( med_editval )
2012-03-17 11:34:32 +00:00
{
2015-08-30 07:24:53 +00:00
// If editing a hex value and either SHIFT is pressed then toggle a specific bit
if ( SHIFTS_IS_PRESSED & & dohex )
{
// Get highest bit in maximum value
int32_t max_bit = 0 ;
while ( max_bit < 15 & & 1 < < ( max_bit + 1 ) < themax )
max_bit + + ;
2012-03-17 11:34:32 +00:00
2015-08-30 07:24:53 +00:00
Bsprintf ( med_edittext , " Toggle %s %d %s Bit 0..%d: " , med_typename , med_thenum , edit_membername , max_bit ) ;
printmessage16 ( " %s " , med_edittext ) ;
const int32_t bit = getnumber16 ( med_edittext , - 1 , max_bit , 1 ) ;
if ( bit > = 0 )
* ( int16_t * ) themember = ( int16_t ) ( ( 1 < < bit ) ^ ( * ( int16_t * ) themember ) ) ;
}
// Else directly edit value
else
2012-03-17 11:34:32 +00:00
{
2015-08-30 07:24:53 +00:00
Bsprintf ( med_edittext , " %s %d %s: " , med_typename , med_thenum , edit_membername ) ;
printmessage16 ( " %s " , med_edittext ) ;
val = getnumber16 ( med_edittext , val , themax , flags ) ;
if ( thesizeof = = sizeof ( int8_t ) )
{
if ( sign )
* ( int8_t * ) themember = ( int8_t ) val ;
else
* ( uint8_t * ) themember = ( uint8_t ) val ;
}
else if ( thesizeof = = sizeof ( int16_t ) )
* ( int16_t * ) themember = ( int16_t ) val ;
else //if (thesizeof==sizeof(int32_t))
* ( int32_t * ) themember = val ;
2012-03-17 11:34:32 +00:00
}
}
2014-07-28 06:44:37 +00:00
}
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
static void med_printcurline ( int32_t xpos , int32_t ypos , int32_t row , int32_t selected )
{
printext16 ( xpos , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ ! ! selected ] , med_disptext , 0 ) ;
}
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
static void med_handlecommon ( int32_t xpos , int32_t ypos , int32_t * row , int32_t rowmax )
{
idle_waitevent ( ) ;
if ( handleevents ( ) )
quitevent = 0 ;
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
_printmessage16 ( " Edit mode, press <Esc> to exit " ) ;
2012-03-17 11:34:32 +00:00
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( DOWN ) )
2012-03-17 11:34:32 +00:00
{
2014-07-28 06:44:37 +00:00
if ( * row < rowmax )
2012-03-17 11:34:32 +00:00
{
2014-07-28 06:44:37 +00:00
med_printcurline ( xpos , ypos , * row , 0 ) ;
( * row ) + + ;
2012-03-17 11:34:32 +00:00
}
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( UP ) )
2012-03-17 11:34:32 +00:00
{
2014-07-28 06:44:37 +00:00
if ( * row > 0 )
{
med_printcurline ( xpos , ypos , * row , 0 ) ;
( * row ) - - ;
}
2012-03-17 11:34:32 +00:00
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( ENTER ) )
med_editval = 1 ;
2012-03-17 11:34:32 +00:00
}
2014-07-28 06:44:37 +00:00
static void EditSectorData ( int16_t sectnum )
2011-01-03 22:04:20 +00:00
{
2014-11-26 04:37:22 +00:00
int32_t col = 1 , row = 0 , rowmax = 6 ;
int32_t i = - 1 ;
2014-07-28 06:44:37 +00:00
int32_t xpos = 208 , ypos = ydim - STATUS2DSIZ + 48 ;
2011-01-16 00:23:39 +00:00
2014-07-28 06:44:37 +00:00
med_editval = 0 ;
2011-01-03 22:04:20 +00:00
2014-07-28 06:44:37 +00:00
med_dispwidth = 24 ;
med_disptext [ med_dispwidth ] = 0 ;
2011-01-03 22:04:20 +00:00
2014-07-28 06:44:37 +00:00
med_typename = " Sector " ;
med_thenum = sectnum ;
2011-01-03 22:04:20 +00:00
2014-07-28 06:44:37 +00:00
drawgradient ( ) ;
2011-10-30 19:47:26 +00:00
2014-07-28 06:44:37 +00:00
showsectordata ( sectnum , 0 ) ;
2011-02-10 23:15:02 +00:00
2014-07-28 06:44:37 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 )
2011-01-03 22:04:20 +00:00
{
2014-07-28 06:44:37 +00:00
med_handlecommon ( xpos , ypos , & row , rowmax ) ;
2011-01-03 22:04:20 +00:00
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( LEFT ) )
2013-05-10 12:31:35 +00:00
{
2014-07-28 06:44:37 +00:00
if ( col = = 2 )
{
med_printcurline ( xpos , ypos , row , 0 ) ;
col = 1 ;
xpos = 208 ;
med_disptext [ med_dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
2013-05-10 12:31:35 +00:00
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( RIGHT ) )
2011-09-01 18:37:53 +00:00
{
2014-07-28 06:44:37 +00:00
if ( col = = 1 )
2011-09-01 18:37:53 +00:00
{
2014-07-28 06:44:37 +00:00
med_printcurline ( xpos , ypos , row , 0 ) ;
col = 2 ;
xpos = 408 ;
med_disptext [ med_dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
2011-09-01 18:37:53 +00:00
}
}
2014-07-28 06:44:37 +00:00
# ifdef YAX_ENABLE
if ( med_editval )
2011-01-03 22:04:20 +00:00
{
2014-07-28 06:44:37 +00:00
if ( ( row = = 1 | | row = = 3 | | row = = 5 ) & & yax_getbunch ( sectnum , ( col = = 2 ) ) > = 0 )
med_editval = 0 ;
}
# endif
2011-01-03 22:04:20 +00:00
2014-07-28 06:44:37 +00:00
if ( col = = 1 )
{
switch ( row )
2011-01-03 22:04:20 +00:00
{
2014-07-28 06:44:37 +00:00
case 0 :
# ifdef YAX_ENABLE__COMPAT
i = sector [ sectnum ] . ceilingstat & YAX_BIT ;
# endif
handlemed ( 1 , " Flags (hex) " , " Ceiling Flags " , & sector [ sectnum ] . ceilingstat ,
sizeof ( sector [ sectnum ] . ceilingstat ) , 65535 , 0 ) ;
# ifdef YAX_ENABLE__COMPAT
sector [ sectnum ] . ceilingstat & = ~ YAX_BIT ;
sector [ sectnum ] . ceilingstat | = i ;
# endif
break ;
case 1 :
2014-12-05 23:12:30 +00:00
i = Bsprintf ( med_disptext , " (X,Y)pan: %d, %d " ,
TrackerCast ( sector [ sectnum ] . ceilingxpanning ) ,
TrackerCast ( sector [ sectnum ] . ceilingypanning ) ) ;
for ( ; i < med_dispwidth ; i + + ) med_disptext [ i ] = ' ' ;
if ( med_editval )
{
Bsprintf ( med_edittext , " Sector %d Ceiling X Pan: " , sectnum ) ;
printmessage16 ( " %s " , med_edittext ) ;
sector [ sectnum ] . ceilingxpanning = ( char ) getnumber16 ( med_edittext , ( int32_t ) sector [ sectnum ] . ceilingxpanning , 255 , 0 ) ;
Bsprintf ( med_edittext , " Sector %d Ceiling Y Pan: " , sectnum ) ;
printmessage16 ( " %s " , med_edittext ) ;
sector [ sectnum ] . ceilingypanning = ( char ) getnumber16 ( med_edittext , ( int32_t ) sector [ sectnum ] . ceilingypanning , 255 , 0 ) ;
}
2011-02-15 21:02:43 +00:00
break ;
2009-07-04 09:28:21 +00:00
case 2 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Shade byte " , " Ceiling Shade " , & sector [ sectnum ] . ceilingshade , sizeof ( sector [ sectnum ] . ceilingshade ) , 128 , 1 ) ;
2011-02-15 21:02:43 +00:00
break ;
2009-07-04 09:28:21 +00:00
case 3 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Z-coordinate " , " Ceiling Z-coordinate " , & sector [ sectnum ] . ceilingz ,
sizeof ( sector [ sectnum ] . ceilingz ) , BZ_MAX , 1 ) ;
2014-02-22 19:38:49 +00:00
break ;
case 4 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Tile number " , " Ceiling Tile Number " , & sector [ sectnum ] . ceilingpicnum ,
sizeof ( sector [ sectnum ] . ceilingpicnum ) , MAXTILES , 0 ) ;
break ;
2014-02-22 19:38:49 +00:00
case 5 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Ceiling heinum " , " Ceiling Heinum " , & sector [ sectnum ] . ceilingheinum ,
sizeof ( sector [ sectnum ] . ceilingheinum ) , BHEINUM_MAX , 1 ) ;
setslope ( sectnum , YAX_CEILING , sector [ sectnum ] . ceilingheinum ) ;
break ;
2014-02-22 19:38:49 +00:00
case 6 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Palookup number " , " Ceiling Palookup Number " , & sector [ sectnum ] . ceilingpal ,
sizeof ( sector [ sectnum ] . ceilingpal ) , M32_MAXPALOOKUPS , 0 ) ;
2011-02-15 21:02:43 +00:00
break ;
2009-07-04 09:28:21 +00:00
}
}
2014-07-28 06:44:37 +00:00
else if ( col = = 2 )
2009-07-04 09:28:21 +00:00
{
switch ( row )
{
case 0 :
2014-07-28 06:44:37 +00:00
# ifdef YAX_ENABLE__COMPAT
i = sector [ sectnum ] . ceilingstat & YAX_BIT ;
# endif
handlemed ( 1 , " Flags (hex) " , " Floor Flags " , & sector [ sectnum ] . floorstat ,
sizeof ( sector [ sectnum ] . floorstat ) , 65535 , 0 ) ;
# ifdef YAX_ENABLE__COMPAT
sector [ sectnum ] . ceilingstat & = ~ YAX_BIT ;
sector [ sectnum ] . ceilingstat | = i ;
# endif
2011-02-15 21:02:43 +00:00
break ;
2014-07-28 06:44:37 +00:00
2009-07-04 09:28:21 +00:00
case 1 :
2014-12-05 23:12:30 +00:00
i = Bsprintf ( med_disptext , " (X,Y)pan: %d, %d " ,
TrackerCast ( sector [ sectnum ] . floorxpanning ) ,
TrackerCast ( sector [ sectnum ] . floorypanning ) ) ;
for ( ; i < med_dispwidth ; i + + ) med_disptext [ i ] = ' ' ;
if ( med_editval )
{
Bsprintf ( med_edittext , " Sector %d Floor X Pan: " , sectnum ) ;
printmessage16 ( " %s " , med_edittext ) ;
sector [ sectnum ] . floorxpanning = ( char ) getnumber16 ( med_edittext , ( int32_t ) sector [ sectnum ] . floorxpanning , 255 , 0 ) ;
Bsprintf ( med_edittext , " Sector %d Floor Y Pan: " , sectnum ) ;
printmessage16 ( " %s " , med_edittext ) ;
sector [ sectnum ] . floorypanning = ( char ) getnumber16 ( med_edittext , ( int32_t ) sector [ sectnum ] . floorypanning , 255 , 0 ) ;
}
2011-02-15 21:02:43 +00:00
break ;
2014-07-28 06:44:37 +00:00
2009-07-04 09:28:21 +00:00
case 2 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Shade byte " , " Floor Shade " , & sector [ sectnum ] . floorshade ,
sizeof ( sector [ sectnum ] . floorshade ) , 128 , 1 ) ;
2011-02-15 21:02:43 +00:00
break ;
2009-07-04 09:28:21 +00:00
case 3 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Z-coordinate " , " Floor Z-coordinate " , & sector [ sectnum ] . floorz ,
sizeof ( sector [ sectnum ] . floorz ) , BZ_MAX , 1 ) ; //2147483647L,-2147483648L
2011-02-15 21:02:43 +00:00
break ;
2009-07-04 09:28:21 +00:00
case 4 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Tile number " , " Floor Tile Number " , & sector [ sectnum ] . floorpicnum ,
sizeof ( sector [ sectnum ] . floorpicnum ) , MAXTILES , 0 ) ;
2011-02-15 21:02:43 +00:00
break ;
2009-07-04 09:28:21 +00:00
case 5 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Floor heinum " , " Floor Heinum " , & sector [ sectnum ] . floorheinum ,
sizeof ( sector [ sectnum ] . floorheinum ) , BHEINUM_MAX , 1 ) ;
setslope ( sectnum , YAX_FLOOR , sector [ sectnum ] . floorheinum ) ;
2011-02-15 21:02:43 +00:00
break ;
2009-07-04 09:28:21 +00:00
case 6 :
2014-07-28 06:44:37 +00:00
handlemed ( 0 , " Palookup number " , " Floor Palookup Number " , & sector [ sectnum ] . floorpal ,
sizeof ( sector [ sectnum ] . floorpal ) , M32_MAXPALOOKUPS , 0 ) ;
2011-02-15 21:02:43 +00:00
break ;
2009-07-04 09:28:21 +00:00
}
}
2011-02-15 21:02:43 +00:00
med_printcurline ( xpos , ypos , row , 1 ) ;
if ( med_editval )
med_editval = 0 ;
2011-01-20 10:52:33 +00:00
2006-04-13 20:47:06 +00:00
showframe ( 1 ) ;
}
2011-01-20 10:52:33 +00:00
2011-02-15 21:02:43 +00:00
med_printcurline ( xpos , ypos , row , 0 ) ;
2009-05-01 06:35:27 +00:00
// printmessage16("");
2011-01-20 10:52:33 +00:00
2014-07-28 06:44:37 +00:00
showframe ( 1 ) ;
2008-05-16 00:23:33 +00:00
keystatus [ KEYSC_ESC ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2014-07-28 06:44:37 +00:00
static void EditWallData ( int16_t wallnum )
2008-09-19 20:09:43 +00:00
{
2014-11-26 04:37:22 +00:00
int32_t row = 0 ;
int32_t i = - 1 ;
2014-07-28 06:44:37 +00:00
int32_t xpos = 208 , ypos = ydim - STATUS2DSIZ + 48 ;
2008-09-19 20:09:43 +00:00
2014-07-28 06:44:37 +00:00
med_editval = 0 ;
2008-09-19 20:09:43 +00:00
2014-07-28 06:44:37 +00:00
med_dispwidth = 24 ;
med_disptext [ med_dispwidth ] = 0 ;
2008-09-19 20:09:43 +00:00
2014-07-28 06:44:37 +00:00
med_typename = " Wall " ;
med_thenum = wallnum ;
2008-09-19 20:09:43 +00:00
2010-05-18 05:14:17 +00:00
drawgradient ( ) ;
2009-05-24 22:18:40 +00:00
2014-07-28 06:44:37 +00:00
showwalldata ( wallnum , 0 ) ;
2008-09-19 20:09:43 +00:00
2009-07-04 09:28:21 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 )
{
2014-07-28 06:44:37 +00:00
med_handlecommon ( xpos , ypos , & row , 6 ) ;
2008-09-19 20:09:43 +00:00
2014-07-28 06:44:37 +00:00
switch ( row )
2009-07-04 09:28:21 +00:00
{
2014-07-28 06:44:37 +00:00
case 0 :
# if !defined NEW_MAP_FORMAT
i = wall [ wallnum ] . cstat & YAX_NEXTWALLBITS ;
2014-04-06 22:24:20 +00:00
# endif
2014-07-28 06:44:37 +00:00
handlemed ( 1 , " Flags (hex) " , " Flags " , & wall [ wallnum ] . cstat ,
sizeof ( wall [ wallnum ] . cstat ) , 65535 , 0 ) ;
# if !defined NEW_MAP_FORMAT
wall [ wallnum ] . cstat & = ~ YAX_NEXTWALLBITS ;
wall [ wallnum ] . cstat | = i ;
2014-04-06 22:24:14 +00:00
# endif
2014-07-28 06:44:37 +00:00
break ;
case 1 :
handlemed ( 0 , " Shade " , " Shade " , & wall [ wallnum ] . shade ,
sizeof ( wall [ wallnum ] . shade ) , 128 , 1 ) ;
break ;
case 2 :
handlemed ( 0 , " Pal " , " Pal " , & wall [ wallnum ] . pal ,
sizeof ( wall [ wallnum ] . pal ) , M32_MAXPALOOKUPS , 0 ) ;
break ;
case 3 :
2014-12-05 23:12:30 +00:00
i = Bsprintf ( med_disptext , " (X,Y)repeat: %d, %d " ,
TrackerCast ( wall [ wallnum ] . xrepeat ) ,
TrackerCast ( wall [ wallnum ] . yrepeat ) ) ;
for ( ; i < med_dispwidth ; i + + ) med_disptext [ i ] = ' ' ;
if ( med_editval )
{
Bsprintf ( med_edittext , " Wall %d X Repeat: " , wallnum ) ;
printmessage16 ( " %s " , med_edittext ) ;
wall [ wallnum ] . xrepeat = ( char ) getnumber16 ( med_edittext , ( int32_t ) wall [ wallnum ] . xrepeat , 255 , 0 ) ;
Bsprintf ( med_edittext , " Wall %d Y Repeat: " , wallnum ) ;
printmessage16 ( " %s " , med_edittext ) ;
wall [ wallnum ] . yrepeat = ( char ) getnumber16 ( med_edittext , ( int32_t ) wall [ wallnum ] . yrepeat , 255 , 0 ) ;
}
2014-04-05 20:27:34 +00:00
break ;
2014-07-28 06:44:37 +00:00
case 4 :
2014-12-05 23:12:30 +00:00
i = Bsprintf ( med_disptext , " (X,Y)pan: %d, %d " ,
TrackerCast ( wall [ wallnum ] . xpanning ) ,
TrackerCast ( wall [ wallnum ] . ypanning ) ) ;
for ( ; i < med_dispwidth ; i + + ) med_disptext [ i ] = ' ' ;
if ( med_editval )
{
Bsprintf ( med_edittext , " Wall %d X Pan: " , wallnum ) ;
printmessage16 ( " %s " , med_edittext ) ;
wall [ wallnum ] . xpanning = ( char ) getnumber16 ( med_edittext , ( int32_t ) wall [ wallnum ] . xpanning , 255 , 0 ) ;
Bsprintf ( med_edittext , " Wall %d Y Pan: " , wallnum ) ;
printmessage16 ( " %s " , med_edittext ) ;
wall [ wallnum ] . ypanning = ( char ) getnumber16 ( med_edittext , ( int32_t ) wall [ wallnum ] . ypanning , 255 , 0 ) ;
}
2014-07-28 06:44:37 +00:00
break ;
case 5 :
handlemed ( 0 , " Tile number " , " Tile number " , & wall [ wallnum ] . picnum ,
sizeof ( wall [ wallnum ] . picnum ) , MAXTILES , 0 ) ;
break ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
case 6 :
handlemed ( 0 , " OverTile number " , " OverTile number " , & wall [ wallnum ] . overpicnum ,
sizeof ( wall [ wallnum ] . overpicnum ) , MAXTILES , 0 ) ;
break ;
2011-08-03 17:22:25 +00:00
}
2008-09-15 02:47:02 +00:00
2014-07-28 06:44:37 +00:00
med_printcurline ( xpos , ypos , row , 1 ) ;
if ( med_editval )
2011-08-03 17:22:25 +00:00
{
2014-07-28 06:44:37 +00:00
med_editval = 0 ;
//showwalldata(wallnum, 0);
//// printmessage16("");
2011-08-03 17:22:25 +00:00
}
2014-07-28 06:44:37 +00:00
showframe ( 1 ) ;
2008-09-15 02:47:02 +00:00
}
2014-07-28 06:44:37 +00:00
med_printcurline ( xpos , ypos , row , 0 ) ;
// printmessage16("");
2011-08-03 17:22:25 +00:00
2014-07-28 06:44:37 +00:00
showframe ( 1 ) ;
keystatus [ KEYSC_ESC ] = 0 ;
2006-07-20 05:02:55 +00:00
}
2014-07-28 06:44:37 +00:00
static void EditSpriteData ( int16_t spritenum )
2006-07-20 05:02:55 +00:00
{
2014-07-28 06:44:37 +00:00
int32_t col = 0 , row = 0 , rowmax = 4 , i = - 1 ;
int32_t xpos = 8 , ypos = ydim - STATUS2DSIZ + 48 ;
2006-11-19 08:24:46 +00:00
2014-07-28 06:44:37 +00:00
med_editval = 0 ;
2014-04-06 22:24:14 +00:00
2014-07-28 06:44:37 +00:00
med_dispwidth = 24 ;
med_disptext [ med_dispwidth ] = 0 ;
2010-05-18 05:14:17 +00:00
2014-07-28 06:44:37 +00:00
med_typename = " Sprite " ;
med_thenum = spritenum ;
2009-05-05 16:21:33 +00:00
2014-04-05 20:27:34 +00:00
drawgradient ( ) ;
2014-07-28 06:44:37 +00:00
// clearmidstatbar16();
2006-07-20 05:02:55 +00:00
2014-04-05 20:27:34 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 )
2006-07-20 05:02:55 +00:00
{
2014-07-28 06:44:37 +00:00
showspritedata ( spritenum , 0 ) ;
2009-08-05 22:37:48 +00:00
2014-07-28 06:44:37 +00:00
med_handlecommon ( xpos , ypos , & row , rowmax ) ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( LEFT ) )
2006-07-20 05:02:55 +00:00
{
2014-07-28 06:44:37 +00:00
switch ( col )
2006-07-20 05:02:55 +00:00
{
2014-07-28 06:44:37 +00:00
case 1 :
{
med_printcurline ( xpos , ypos , row , 0 ) ;
col = 0 ;
xpos = 8 ;
rowmax = 4 ;
med_dispwidth = 23 ;
med_disptext [ med_dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
break ;
case 2 :
{
med_printcurline ( xpos , ypos , row , 0 ) ;
col = 1 ;
xpos = 208 ;
rowmax = 6 ;
med_dispwidth = 24 ;
med_disptext [ med_dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
break ;
2006-07-20 05:02:55 +00:00
}
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( RIGHT ) )
2006-07-20 05:02:55 +00:00
{
2014-07-28 06:44:37 +00:00
switch ( col )
2006-07-20 05:02:55 +00:00
{
2014-07-28 06:44:37 +00:00
case 0 :
{
med_printcurline ( xpos , ypos , row , 0 ) ;
col = 1 ;
xpos = 208 ;
rowmax = 6 ;
med_dispwidth = 24 ;
med_disptext [ med_dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
break ;
case 1 :
{
med_printcurline ( xpos , ypos , row , 0 ) ;
col = 2 ;
xpos = 408 ;
rowmax = 6 ;
med_dispwidth = 26 ;
med_disptext [ med_dispwidth ] = 0 ;
if ( row > rowmax ) row = rowmax ;
}
break ;
2006-07-20 05:02:55 +00:00
}
}
2014-07-28 06:44:37 +00:00
switch ( col )
2006-07-20 17:33:56 +00:00
{
2014-07-28 06:44:37 +00:00
case 0 :
{
switch ( row )
2006-07-20 17:33:56 +00:00
{
2014-07-28 06:44:37 +00:00
case 0 :
handlemed ( 0 , " X-coordinate " , " X-coordinate " , & sprite [ spritenum ] . x ,
sizeof ( sprite [ spritenum ] . x ) , 131072 , 1 ) ;
break ;
case 1 :
handlemed ( 0 , " Y-coordinate " , " Y-coordinate " , & sprite [ spritenum ] . y ,
sizeof ( sprite [ spritenum ] . y ) , 131072 , 1 ) ;
break ;
case 2 :
handlemed ( 0 , " Z-coordinate " , " Z-coordinate " , & sprite [ spritenum ] . z ,
sizeof ( sprite [ spritenum ] . z ) , BZ_MAX , 1 ) ; //2147483647L,-2147483648L
break ;
case 3 :
i = sprite [ spritenum ] . sectnum ;
handlemed ( 0 , " Sectnum " , " Sectnum " , & sprite [ spritenum ] . sectnum ,
sizeof ( sprite [ spritenum ] . sectnum ) , numsectors - 1 , 0 ) ;
if ( i ! = sprite [ spritenum ] . sectnum )
{
swapshort ( & i , & sprite [ spritenum ] . sectnum ) ;
changespritesect ( spritenum , i ) ;
}
break ;
case 4 :
i = sprite [ spritenum ] . statnum ;
handlemed ( 0 , " Statnum " , " Statnum " , & sprite [ spritenum ] . statnum ,
sizeof ( sprite [ spritenum ] . statnum ) , MAXSTATUS - 1 , 0 ) ;
if ( i ! = sprite [ spritenum ] . statnum )
{
swapshort ( & i , & sprite [ spritenum ] . statnum ) ;
changespritestat ( spritenum , i ) ;
}
break ;
2006-07-20 17:33:56 +00:00
}
}
2014-07-28 06:44:37 +00:00
break ;
case 1 :
2006-07-20 17:33:56 +00:00
{
2014-07-28 06:44:37 +00:00
switch ( row )
2006-07-20 17:33:56 +00:00
{
2014-07-28 06:44:37 +00:00
case 0 :
handlemed ( 1 , " Flags (hex) " , " Flags " , & sprite [ spritenum ] . cstat ,
sizeof ( sprite [ spritenum ] . cstat ) , 65535 , 0 ) ;
break ;
case 1 :
handlemed ( 0 , " Shade " , " Shade " , & sprite [ spritenum ] . shade ,
sizeof ( sprite [ spritenum ] . shade ) , 128 , 1 ) ;
break ;
case 2 :
handlemed ( 0 , " Pal " , " Pal " , & sprite [ spritenum ] . pal ,
sizeof ( sprite [ spritenum ] . pal ) , M32_MAXPALOOKUPS , 0 ) ;
break ;
case 3 :
handlemed ( 0 , " Blend " , " Blend " , & sprite [ spritenum ] . blend ,
sizeof ( sprite [ spritenum ] . blend ) , MAXBLENDTABS , 0 ) ;
break ;
case 4 :
2014-12-05 23:12:30 +00:00
{
i = Bsprintf ( med_disptext , " (X,Y)repeat: %d, %d " ,
TrackerCast ( sprite [ spritenum ] . xrepeat ) ,
TrackerCast ( sprite [ spritenum ] . yrepeat ) ) ;
for ( ; i < med_dispwidth ; i + + ) med_disptext [ i ] = ' ' ;
if ( med_editval )
{
Bsprintf ( med_edittext , " Sprite %d X Repeat: " , spritenum ) ;
printmessage16 ( " %s " , med_edittext ) ;
sprite [ spritenum ] . xrepeat = ( char ) getnumber16 ( med_edittext , ( int32_t ) sprite [ spritenum ] . xrepeat , 255 , 0 ) ;
Bsprintf ( med_edittext , " Sprite %d Y Repeat: " , spritenum ) ;
printmessage16 ( " %s " , med_edittext ) ;
sprite [ spritenum ] . yrepeat = ( char ) getnumber16 ( med_edittext , ( int32_t ) sprite [ spritenum ] . yrepeat , 255 , 0 ) ;
}
}
2014-07-28 06:44:37 +00:00
break ;
case 5 :
2014-12-05 23:12:30 +00:00
{
i = Bsprintf ( med_disptext , " (X,Y)offset: %d, %d " ,
TrackerCast ( sprite [ spritenum ] . xoffset ) ,
TrackerCast ( sprite [ spritenum ] . yoffset ) ) ;
for ( ; i < med_dispwidth ; i + + ) med_disptext [ i ] = ' ' ;
if ( med_editval )
{
Bsprintf ( med_edittext , " Sprite %d X Offset: " , spritenum ) ;
printmessage16 ( " %s " , med_edittext ) ;
sprite [ spritenum ] . xoffset = ( char ) getnumber16 ( med_edittext , ( int32_t ) sprite [ spritenum ] . xoffset , 128 , 1 ) ;
Bsprintf ( med_edittext , " Sprite %d Y Offset: " , spritenum ) ;
printmessage16 ( " %s " , med_edittext ) ;
sprite [ spritenum ] . yoffset = ( char ) getnumber16 ( med_edittext , ( int32_t ) sprite [ spritenum ] . yoffset , 128 , 1 ) ;
}
}
2014-07-28 06:44:37 +00:00
break ;
case 6 :
handlemed ( 0 , " Tile number " , " Tile number " , & sprite [ spritenum ] . picnum ,
sizeof ( sprite [ spritenum ] . picnum ) , MAXTILES - 1 , 0 + 2 ) ;
break ;
}
}
break ;
case 2 :
{
switch ( row )
{
case 0 :
handlemed ( 0 , " Angle (2048 degrees) " , " Angle " , & sprite [ spritenum ] . ang ,
sizeof ( sprite [ spritenum ] . ang ) , 2048 , 1 ) ;
if ( med_editval )
sprite [ spritenum ] . ang & = 2047 ;
break ;
case 1 :
handlemed ( 0 , " X-Velocity " , " X-Velocity " , & sprite [ spritenum ] . xvel ,
sizeof ( sprite [ spritenum ] . xvel ) , 65535 , 1 ) ;
break ;
case 2 :
handlemed ( 0 , " Y-Velocity " , " Y-Velocity " , & sprite [ spritenum ] . yvel ,
sizeof ( sprite [ spritenum ] . yvel ) , 65535 , 1 ) ;
break ;
case 3 :
handlemed ( 0 , " Z-Velocity " , " Z-Velocity " , & sprite [ spritenum ] . zvel ,
sizeof ( sprite [ spritenum ] . zvel ) , 65535 , 1 ) ;
break ;
case 4 :
handlemed ( 0 , " Owner " , " Owner " , & sprite [ spritenum ] . owner ,
sizeof ( sprite [ spritenum ] . owner ) , MAXSPRITES - 1 , 1 ) ;
break ;
case 5 :
handlemed ( 0 , " Clipdist " , " Clipdist " , & sprite [ spritenum ] . clipdist ,
sizeof ( sprite [ spritenum ] . clipdist ) , 255 , 0 ) ;
break ;
case 6 :
handlemed ( 0 , " Extra " , " Extra " , & sprite [ spritenum ] . extra ,
sizeof ( sprite [ spritenum ] . extra ) , BTAG_MAX , 1 ) ;
break ;
2006-07-20 17:33:56 +00:00
}
}
2014-07-28 06:44:37 +00:00
break ;
2014-04-05 20:27:34 +00:00
}
2011-08-03 17:22:25 +00:00
2014-07-28 06:44:37 +00:00
med_printcurline ( xpos , ypos , row , 1 ) ;
if ( med_editval )
med_editval = 0 ;
2014-04-06 22:24:20 +00:00
2014-04-05 20:27:34 +00:00
showframe ( 1 ) ;
}
2011-08-03 17:22:25 +00:00
2014-07-28 06:44:37 +00:00
med_printcurline ( xpos , ypos , row , 0 ) ;
// printmessage16("");
2014-04-05 20:27:34 +00:00
showframe ( 1 ) ;
keystatus [ KEYSC_ESC ] = 0 ;
}
2011-08-03 17:22:25 +00:00
2014-07-28 06:44:37 +00:00
# define TWENTYFIVE_BLANKS " "
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
static void GenericSpriteSearch ( void )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
char disptext [ 80 ] ;
char edittext [ 80 ] ;
static int32_t col = 0 , row = 0 ;
int32_t i , j , k ;
int32_t rowmax [ 3 ] = { 6 , 6 , 6 } , dispwidth [ 3 ] = { 24 , 24 , 28 } ;
int32_t xpos [ 3 ] = { 8 , 200 , 400 } , ypos = ydim - STATUS2DSIZ + 48 ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
static const char * labels [ 7 ] [ 3 ] =
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
{ " X-coordinate " , " Flags (hex) " , " Angle (2048 degrees) " } ,
{ " Y-coordinate " , " Shade " , " X-Velocity " } ,
{ " Z-coordinate " , " Pal " , " Y-Velocity " } ,
{ " Sectnum " , " Blend " , " Z-Velocity " } ,
{ " Statnum " , " (X/Y)repeat " , " Owner " } ,
{ " Hitag " , " (X/Y)offset " , " Clipdist " } ,
{ " Lotag " , " Tile number " , " Extra " }
} ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
static int32_t maxval [ 7 ] [ 3 ] =
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
{ BXY_MAX , 65535 , 2048 } ,
{ BXY_MAX , 128 , 65535 } ,
{ BZ_MAX , M32_MAXPALOOKUPS , 65535 } ,
{ MAXSECTORS - 1 , MAXBLENDTABS - 1 , 65535 } ,
{ MAXSTATUS - 1 , 128 , MAXSPRITES - 1 } ,
{ BTAG_MAX , 128 , 256 } ,
{ BTAG_MAX , MAXTILES - 1 , BTAG_MAX }
} ;
2011-08-03 17:22:25 +00:00
2014-07-28 06:44:37 +00:00
static char sign [ 7 ] [ 3 ] =
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
{ 1 , 0 , 1 } ,
{ 1 , 1 , 1 } ,
{ 1 , 0 , 1 } ,
{ 0 , 0 , 1 } ,
{ 0 , 0 , 0 } ,
{ 0 + 4 , 1 , 0 } ,
{ 0 + 4 , 0 + 2 , 1 }
} ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
clearmidstatbar16 ( ) ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
drawgradient ( ) ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ 0 ] , ypos - 2 * 8 , editorcolors [ 10 ] , editorcolors [ 0 ] , " Sprite search " , 0 ) ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
for ( i = 0 ; i < 3 ; i + + )
for ( j = 0 ; j < = rowmax [ i ] ; j + + )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
if ( gs_spriteTagInterested [ i ] [ j ] )
k = Bsprintf ( disptext , " %s: %d " , labels [ j ] [ i ] , gs_spriteTagValue [ i ] [ j ] ) ;
else
k = Bsprintf ( disptext , " %s: ^7any " , labels [ j ] [ i ] ) ;
// for (; k<dispwidth[i]; k++) disptext[k] = 0;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ i ] , ypos + j * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
}
Bmemset ( disptext , 0 , sizeof ( disptext ) ) ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
// disptext[dispwidth[col]] = 0;
// showspritedata(spritenum, 0);
wallsprite = 2 ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
while ( keystatus [ KEYSC_ESC ] = = 0 )
{
idle_waitevent ( ) ;
if ( handleevents ( ) )
{
if ( quitevent ) quitevent = 0 ;
2014-04-05 20:27:34 +00:00
}
2014-07-28 06:44:37 +00:00
printmessage16 ( " Sprite search, press <Esc> to exit " ) ;
if ( PRESSED_KEYSC ( DOWN ) )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
if ( row < rowmax [ col ] )
2009-07-04 09:28:21 +00:00
{
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
row + + ;
2014-04-05 20:27:34 +00:00
}
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( UP ) )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
if ( row > 0 )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
row - - ;
2009-07-04 09:28:21 +00:00
}
2014-04-05 20:27:34 +00:00
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( LEFT ) )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
if ( col > 0 )
2009-07-04 09:28:21 +00:00
{
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
col - - ;
disptext [ dispwidth [ col ] ] = 0 ;
if ( row > rowmax [ col ] ) row = rowmax [ col ] ;
2009-07-04 09:28:21 +00:00
}
2014-04-05 20:27:34 +00:00
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( RIGHT ) )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
if ( col < 2 )
2009-07-04 09:28:21 +00:00
{
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
col + + ;
disptext [ dispwidth [ col ] ] = 0 ;
if ( row > rowmax [ col ] ) row = rowmax [ col ] ;
2009-07-04 09:28:21 +00:00
}
2014-04-05 20:27:34 +00:00
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( ENTER ) )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
Bsprintf ( edittext , " %s: " , labels [ row ] [ col ] ) ;
printmessage16 ( " %s " , edittext ) ;
i = getnumber16 ( edittext , gs_spriteTagInterested [ col ] [ row ] ? gs_spriteTagValue [ col ] [ row ] : 0 ,
maxval [ row ] [ col ] , sign [ row ] [ col ] ) ;
if ( col = = 2 & & row = = 0 ) i = ( i + 2048 ) & 2047 ; // angle
gs_spriteTagValue [ col ] [ row ] = i ;
gs_spriteTagInterested [ col ] [ row ] = 1 ;
2014-04-05 20:27:34 +00:00
2014-07-28 06:44:37 +00:00
if ( col = = 1 & & row = = 6 ) // picnum
2009-07-04 09:28:21 +00:00
{
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ 1 ] , ypos - 2 * 8 , editorcolors [ 14 ] , editorcolors [ 0 ] , TWENTYFIVE_BLANKS , 0 ) ;
if ( names [ i ] [ 0 ] )
printext16 ( xpos [ 1 ] , ypos - 2 * 8 , editorcolors [ 14 ] , editorcolors [ 0 ] , names [ i ] , 0 ) ;
2009-07-04 09:28:21 +00:00
}
2014-04-05 20:27:34 +00:00
}
2014-07-28 06:44:37 +00:00
if ( PRESSED_KEYSC ( BS ) | | PRESSED_KEYSC ( DELETE ) )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
gs_spriteTagInterested [ col ] [ row ] = 0 ;
if ( col = = 1 & & row = = 6 ) // picnum
printext16 ( xpos [ 1 ] , ypos - 2 * 8 , editorcolors [ 14 ] , editorcolors [ 0 ] , TWENTYFIVE_BLANKS , 0 ) ;
2014-04-05 20:27:34 +00:00
}
2014-07-28 06:44:37 +00:00
i = gs_spriteTagInterested [ col ] [ row ] ;
if ( i )
2014-04-05 20:27:34 +00:00
{
2014-07-28 06:44:37 +00:00
if ( col = = 1 & & row = = 0 ) // flags
k = Bsprintf ( disptext , " %s: %x " , labels [ row ] [ col ] , gs_spriteTagValue [ col ] [ row ] ) ;
else
k = Bsprintf ( disptext , " %s: %d " , labels [ row ] [ col ] , gs_spriteTagValue [ col ] [ row ] ) ;
2006-07-20 05:02:55 +00:00
}
2014-07-28 06:44:37 +00:00
else
k = Bsprintf ( disptext , " %s: ^7any " , labels [ row ] [ col ] ) ;
// v-------^^
for ( ; k < dispwidth [ col ] - 2 * i ; k + + ) disptext [ k ] = ' ' ;
disptext [ k ] = 0 ;
2014-04-06 22:24:14 +00:00
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 1 ] , disptext , 0 ) ;
2014-04-06 22:24:14 +00:00
2014-07-28 06:44:37 +00:00
showframe ( 1 ) ;
2014-04-06 22:24:14 +00:00
}
2014-07-28 06:44:37 +00:00
printext16 ( xpos [ col ] , ypos + row * 8 , editorcolors [ 11 ] , editorcolors [ 0 ] , disptext , 0 ) ;
printmessage16 ( " Search sprite " ) ;
showframe ( 1 ) ;
2014-04-06 22:24:14 +00:00
2014-07-28 06:44:37 +00:00
keystatus [ KEYSC_ESC ] = 0 ;
2014-04-06 22:24:14 +00:00
}