2017-05-26 05:24:38 +02:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
*/
2017-08-21 09:07:19 +02:00
# include "common/config-manager.h"
2017-07-11 14:31:45 +02:00
# include "common/savefile.h"
2017-06-05 19:10:47 +02:00
# include "sludge/allfiles.h"
# include "sludge/backdrop.h"
# include "sludge/bg_effects.h"
2017-12-19 22:15:55 +01:00
# include "sludge/builtin.h"
# include "sludge/cursors.h"
# include "sludge/event.h"
2017-06-05 19:10:47 +02:00
# include "sludge/floor.h"
2017-12-19 22:15:55 +01:00
# include "sludge/fonttext.h"
# include "sludge/freeze.h"
2018-05-27 23:23:15 +02:00
# include "sludge/function.h"
2017-12-19 22:15:55 +01:00
# include "sludge/graphics.h"
2017-06-05 19:10:47 +02:00
# include "sludge/language.h"
2017-12-19 22:15:55 +01:00
# include "sludge/loadsave.h"
2017-06-05 19:10:47 +02:00
# include "sludge/moreio.h"
# include "sludge/movie.h"
2017-12-19 22:15:55 +01:00
# include "sludge/newfatal.h"
# include "sludge/objtypes.h"
# include "sludge/people.h"
# include "sludge/region.h"
2017-06-05 19:10:47 +02:00
# include "sludge/savedata.h"
2017-12-19 22:15:55 +01:00
# include "sludge/sludger.h"
# include "sludge/sound.h"
2017-12-19 21:24:31 +01:00
# include "sludge/speech.h"
2017-12-19 22:15:55 +01:00
# include "sludge/sprbanks.h"
# include "sludge/sprites.h"
# include "sludge/statusba.h"
# include "sludge/sludge.h"
2017-07-06 22:05:13 +02:00
# include "sludge/utf8.h"
2017-12-19 22:15:55 +01:00
# include "sludge/zbuffer.h"
2017-05-26 05:24:38 +02:00
2017-05-26 21:25:11 +02:00
namespace Sludge {
2017-07-20 10:39:24 +02:00
Variable * launchResult = NULL ;
2017-05-26 05:24:38 +02:00
extern bool allowAnyFilename ;
2017-07-20 10:39:24 +02:00
extern VariableStack * noStack ;
extern StatusStuff * nowStatus ;
2017-05-26 05:24:38 +02:00
extern int numBIFNames , numUserFunc ;
2017-07-11 14:57:31 +02:00
extern Common : : String * allUserFunc ;
extern Common : : String * allBIFNames ;
2017-05-26 05:24:38 +02:00
2017-07-11 14:57:31 +02:00
bool failSecurityCheck ( const Common : : String & fn ) {
if ( fn . empty ( ) )
2017-06-05 11:49:19 +02:00
return true ;
2017-05-26 05:24:38 +02:00
2017-07-13 23:26:47 +02:00
for ( uint i = 0 ; i < fn . size ( ) ; + + i ) {
2017-07-11 14:57:31 +02:00
switch ( fn [ i ] ) {
2017-06-05 11:49:19 +02:00
case ' : ' :
case ' \\ ' :
case ' / ' :
case ' * ' :
case ' ? ' :
case ' " ' :
case ' < ' :
case ' > ' :
case ' | ' :
fatal ( " Filenames may not contain the following characters: \n \n \\ / : \" < > | ? * \n \n Consequently, the following filename is not allowed: " , fn ) ;
return true ;
2017-05-26 05:24:38 +02:00
}
}
return false ;
}
2018-05-27 23:23:15 +02:00
extern LoadedFunction * saverFunc ;
2017-05-26 05:24:38 +02:00
2017-07-20 10:39:24 +02:00
typedef BuiltReturn ( * builtInSludgeFunc ) ( int numParams , LoadedFunction * fun ) ;
2017-05-26 05:24:38 +02:00
struct builtInFunctionData {
builtInSludgeFunc func ;
2018-05-27 20:55:57 +02:00
int paramNum ;
2017-05-26 05:24:38 +02:00
} ;
2017-07-20 10:39:24 +02:00
# define builtIn(a) static BuiltReturn builtIn_ ## a (int numParams, LoadedFunction *fun)
2017-05-26 05:24:38 +02:00
# define UNUSEDALL (void) (0 && sizeof(numParams) && sizeof (fun));
2017-07-20 19:08:53 +02:00
2017-07-20 10:39:24 +02:00
static BuiltReturn sayCore ( int numParams , LoadedFunction * fun , bool sayIt ) {
2017-05-26 05:24:38 +02:00
int fileNum = - 1 ;
2017-07-11 14:57:31 +02:00
Common : : String newText ;
2017-05-26 05:24:38 +02:00
int objT , p ;
killSpeechTimers ( ) ;
switch ( numParams ) {
2017-06-05 11:49:19 +02:00
case 3 :
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNum , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
trimStack ( fun - > stack ) ;
2017-08-06 13:30:51 +02:00
// fall through
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
case 2 :
2018-05-31 20:09:36 +02:00
newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-06-05 11:49:19 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objT , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
trimStack ( fun - > stack ) ;
2017-12-19 21:24:31 +01:00
p = g_sludge - > _speechMan - > wrapSpeech ( newText , objT , fileNum , sayIt ) ;
2017-06-05 11:49:19 +02:00
fun - > timeLeft = p ;
//debugOut ("BUILTIN: sayCore: %s (%i)\n", newText, p);
fun - > isSpeech = true ;
return BR_KEEP_AND_PAUSE ;
2017-05-26 05:24:38 +02:00
}
fatal ( " Function should have either 2 or 3 parameters " ) ;
return BR_ERROR ;
}
# pragma mark -
# pragma mark Built in functions
builtIn ( say ) {
UNUSEDALL
return sayCore ( numParams , fun , true ) ;
}
builtIn ( think ) {
UNUSEDALL
return sayCore ( numParams , fun , false ) ;
}
builtIn ( freeze ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > freeze ( ) ;
2017-05-26 05:24:38 +02:00
freezeSubs ( ) ;
2017-05-27 20:16:54 +02:00
fun - > freezerLevel = 0 ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( unfreeze ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > unfreeze ( ) ;
2017-05-26 05:24:38 +02:00
unfreezeSubs ( ) ;
return BR_CONTINUE ;
}
builtIn ( howFrozen ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _gfxMan - > howFrozen ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCursor ) {
UNUSEDALL
2018-05-31 20:14:33 +02:00
PersonaAnimation * aa = fun - > stack - > thisVar . getAnimationFromVar ( ) ;
2017-07-21 08:16:17 +02:00
g_sludge - > _cursorMan - > pickAnimCursor ( aa ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getMouseX ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _evtMan - > mouseX ( ) + g_sludge - > _gfxMan - > getCamX ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getMouseY ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _evtMan - > mouseY ( ) + g_sludge - > _gfxMan - > getCamY ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getMouseScreenX ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _evtMan - > mouseX ( ) * g_sludge - > _gfxMan - > getCamZoom ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getMouseScreenY ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _evtMan - > mouseY ( ) * g_sludge - > _gfxMan - > getCamZoom ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getStatusText ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
fun - > reg . makeTextVar ( statusBarText ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getMatchingFiles ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-30 19:57:32 +02:00
fun - > reg . unlinkVar ( ) ;
2017-05-26 05:24:38 +02:00
// Return value
2017-05-27 20:16:54 +02:00
fun - > reg . varType = SVT_STACK ;
2017-07-20 10:39:24 +02:00
fun - > reg . varData . theStack = new StackHandler ;
2017-06-05 11:49:19 +02:00
if ( ! checkNew ( fun - > reg . varData . theStack ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
fun - > reg . varData . theStack - > first = NULL ;
fun - > reg . varData . theStack - > last = NULL ;
fun - > reg . varData . theStack - > timesUsed = 1 ;
2018-05-31 23:13:20 +02:00
if ( ! fun - > reg . varData . theStack - > getSavedGamesStack ( newText ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( saveGame ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
if ( g_sludge - > _gfxMan - > isFrozen ( ) ) {
2017-05-26 05:24:38 +02:00
fatal ( " Can't save game state while the engine is frozen " ) ;
}
2018-05-31 20:09:36 +02:00
g_sludge - > loadNow = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-07-11 15:39:22 +02:00
Common : : String aaaaa = encodeFilename ( g_sludge - > loadNow ) ;
g_sludge - > loadNow . clear ( ) ;
2017-06-05 11:49:19 +02:00
if ( failSecurityCheck ( aaaaa ) )
return BR_ERROR ; // Won't fail if encoded, how cool is that? OK, not very.
2017-05-26 05:24:38 +02:00
2017-07-11 15:39:22 +02:00
g_sludge - > loadNow = " : " + aaaaa ;
2017-05-26 05:24:38 +02:00
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
saverFunc = fun ;
return BR_KEEP_AND_PAUSE ;
}
builtIn ( fileExists ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
g_sludge - > loadNow = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-11 15:39:22 +02:00
Common : : String aaaaa = encodeFilename ( g_sludge - > loadNow ) ;
g_sludge - > loadNow . clear ( ) ;
2017-08-08 11:44:35 +02:00
2017-06-05 11:49:19 +02:00
if ( failSecurityCheck ( aaaaa ) )
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
2017-08-08 11:44:35 +02:00
bool exist = false ;
Common : : File fd ;
if ( fd . open ( aaaaa ) ) {
exist = true ;
fd . close ( ) ;
} else {
Common : : InSaveFile * fp = g_system - > getSavefileManager ( ) - > openForLoading ( aaaaa ) ;
if ( fp ) {
exist = true ;
delete fp ;
2017-05-26 05:24:38 +02:00
}
}
2017-08-08 11:44:35 +02:00
2017-05-26 05:24:38 +02:00
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , exist ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( loadGame ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String aaaaa = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-11 15:39:22 +02:00
g_sludge - > loadNow . clear ( ) ;
g_sludge - > loadNow = encodeFilename ( aaaaa ) ;
2017-05-26 05:24:38 +02:00
2017-07-20 00:41:13 +02:00
if ( g_sludge - > _gfxMan - > isFrozen ( ) ) {
2017-05-26 05:24:38 +02:00
fatal ( " Can't load a saved game while the engine is frozen " ) ;
}
2017-07-11 15:39:22 +02:00
if ( failSecurityCheck ( g_sludge - > loadNow ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-07-11 15:39:22 +02:00
Common : : InSaveFile * fp = g_system - > getSavefileManager ( ) - > openForLoading ( g_sludge - > loadNow ) ;
2017-07-11 14:31:45 +02:00
if ( fp ) {
delete fp ;
2017-05-26 05:24:38 +02:00
return BR_KEEP_AND_PAUSE ;
}
2017-07-05 19:20:50 +02:00
debug ( " not find sav file " ) ;
2017-07-11 14:57:31 +02:00
2017-07-11 15:39:22 +02:00
g_sludge - > loadNow . clear ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
//--------------------------------------
# pragma mark -
# pragma mark Background image - Painting
builtIn ( blankScreen ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > blankAllScreen ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( blankArea ) {
UNUSEDALL
int x1 , y1 , x2 , y2 ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y2 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x2 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y1 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x1 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > blankScreen ( x1 , y1 , x2 , y2 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( darkBackground ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > darkScreen ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( addOverlay ) {
UNUSEDALL
int fileNumber , xPos , yPos ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( yPos , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( xPos , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > loadBackDrop ( fileNumber , xPos , yPos ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( mixOverlay ) {
UNUSEDALL
int fileNumber , xPos , yPos ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( yPos , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( xPos , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > mixBackDrop ( fileNumber , xPos , yPos ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( pasteImage ) {
UNUSEDALL
int x , y ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 20:14:33 +02:00
PersonaAnimation * pp = fun - > stack - > thisVar . getAnimationFromVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-06-05 11:49:19 +02:00
if ( pp = = NULL )
return BR_CONTINUE ;
2017-05-26 05:24:38 +02:00
2017-07-21 08:16:17 +02:00
g_sludge - > _cursorMan - > pasteCursor ( x , y , pp ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
# pragma mark -
# pragma mark Background Image - Scrolling
builtIn ( setSceneDimensions ) {
UNUSEDALL
int x , y ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
if ( g_sludge - > _gfxMan - > killResizeBackdrop ( x , y ) ) {
g_sludge - > _gfxMan - > blankScreen ( 0 , 0 , x , y ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
fatal ( " Out of memory creating new backdrop. " ) ;
return BR_ERROR ;
}
builtIn ( aimCamera ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
int cameraX , cameraY ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( cameraY , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( cameraX , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > aimCamera ( cameraX , cameraY ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( zoomCamera ) {
UNUSEDALL
int z ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( z , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > zoomCamera ( z ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
# pragma mark -
# pragma mark Variables
builtIn ( pickOne ) {
UNUSEDALL
if ( ! numParams ) {
fatal ( " Built-in function should have at least 1 parameter " ) ;
return BR_ERROR ;
}
int i ;
2017-07-13 23:27:09 +02:00
i = g_sludge - > getRandomSource ( ) - > getRandomNumber ( numParams - 1 ) ;
2017-05-26 05:24:38 +02:00
// Return value
2017-06-05 11:49:19 +02:00
while ( numParams - - ) {
if ( i = = numParams )
2018-05-31 19:57:45 +02:00
fun - > reg . copyFrom ( fun - > stack - > thisVar ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( substring ) {
UNUSEDALL
2017-07-11 14:57:31 +02:00
Common : : String wholeString ;
2017-05-26 05:24:38 +02:00
int start , length ;
//debugOut ("BUILTIN: substring\n");
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( length , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( start , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 20:09:36 +02:00
wholeString = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-07-11 14:57:31 +02:00
UTF8Converter convert ;
convert . setUTF8String ( wholeString ) ;
2017-07-06 22:05:13 +02:00
Common : : U32String str32 = convert . getU32String ( ) ;
2017-07-11 14:57:31 +02:00
if ( ( int ) str32 . size ( ) < start + length ) {
2017-07-06 22:05:13 +02:00
length = str32 . size ( ) - start ;
2017-07-11 14:57:31 +02:00
if ( ( int ) str32 . size ( ) < start ) {
2017-05-26 05:24:38 +02:00
start = 0 ;
}
}
if ( length < 0 ) {
length = 0 ;
}
2017-07-06 22:05:13 +02:00
int startoffset = convert . getOriginOffset ( start ) ;
int endoffset = convert . getOriginOffset ( start + length ) ;
2017-05-26 05:24:38 +02:00
2017-07-11 14:57:31 +02:00
Common : : String newString ( wholeString . begin ( ) + startoffset , wholeString . begin ( ) + endoffset ) ;
2017-05-26 05:24:38 +02:00
2018-05-31 20:09:36 +02:00
fun - > reg . makeTextVar ( newString ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( stringLength ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _txtMan - > stringLength ( newText ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( newStack ) {
UNUSEDALL
2018-05-30 19:57:32 +02:00
fun - > reg . unlinkVar ( ) ;
2017-05-26 05:24:38 +02:00
// Return value
2017-05-27 20:16:54 +02:00
fun - > reg . varType = SVT_STACK ;
2017-07-20 10:39:24 +02:00
fun - > reg . varData . theStack = new StackHandler ;
2017-06-05 11:49:19 +02:00
if ( ! checkNew ( fun - > reg . varData . theStack ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
fun - > reg . varData . theStack - > first = NULL ;
fun - > reg . varData . theStack - > last = NULL ;
fun - > reg . varData . theStack - > timesUsed = 1 ;
2017-06-05 11:49:19 +02:00
while ( numParams - - ) {
if ( ! addVarToStack ( fun - > stack - > thisVar , fun - > reg . varData . theStack - > first ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
if ( fun - > reg . varData . theStack - > last = = NULL ) {
fun - > reg . varData . theStack - > last = fun - > reg . varData . theStack - > first ;
2017-05-26 05:24:38 +02:00
}
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
// wait is exactly the same function, but limited to 2 parameters
# define builtIn_wait builtIn_newStack
builtIn ( stackSize ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
switch ( fun - > stack - > thisVar . varType ) {
2017-06-05 11:49:19 +02:00
case SVT_STACK :
// Return value
2018-05-31 23:09:15 +02:00
fun - > reg . setVariable ( SVT_INT , fun - > stack - > thisVar . varData . theStack - > getStackSize ( ) ) ;
2017-06-05 11:49:19 +02:00
trimStack ( fun - > stack ) ;
return BR_CONTINUE ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
case SVT_FASTARRAY :
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , fun - > stack - > thisVar . varData . fastArray - > size ) ;
2017-06-05 11:49:19 +02:00
trimStack ( fun - > stack ) ;
return BR_CONTINUE ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
default :
break ;
2017-05-26 05:24:38 +02:00
}
fatal ( " Parameter isn't a stack or a fast array. " ) ;
return BR_ERROR ;
}
builtIn ( copyStack ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " Parameter isn't a stack. " ) ;
return BR_ERROR ;
}
// Return value
2018-05-31 23:04:14 +02:00
if ( ! fun - > reg . copyStack ( fun - > stack - > thisVar ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( pushToStack ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > next - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " Parameter isn't a stack " ) ;
return BR_ERROR ;
}
2017-05-27 20:16:54 +02:00
if ( ! addVarToStack ( fun - > stack - > thisVar , fun - > stack - > next - > thisVar . varData . theStack - > first ) )
2017-05-26 05:24:38 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > next - > thisVar . varData . theStack - > first - > next = = NULL )
fun - > stack - > next - > thisVar . varData . theStack - > last = fun - > stack - > next - > thisVar . varData . theStack - > first ;
2017-05-26 05:24:38 +02:00
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( enqueue ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > next - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " Parameter isn't a stack " ) ;
return BR_ERROR ;
}
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > next - > thisVar . varData . theStack - > first = = NULL ) {
if ( ! addVarToStack ( fun - > stack - > thisVar , fun - > stack - > next - > thisVar . varData . theStack - > first ) )
2017-05-26 05:24:38 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
fun - > stack - > next - > thisVar . varData . theStack - > last = fun - > stack - > next - > thisVar . varData . theStack - > first ;
2017-05-26 05:24:38 +02:00
} else {
2017-06-05 11:49:19 +02:00
if ( ! addVarToStack ( fun - > stack - > thisVar , fun - > stack - > next - > thisVar . varData . theStack - > last - > next ) )
2017-05-26 05:24:38 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
fun - > stack - > next - > thisVar . varData . theStack - > last = fun - > stack - > next - > thisVar . varData . theStack - > last - > next ;
2017-05-26 05:24:38 +02:00
}
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( deleteFromStack ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > next - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " Parameter isn't a stack. " ) ;
return BR_ERROR ;
}
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , deleteVarFromStack ( fun - > stack - > thisVar , fun - > stack - > next - > thisVar . varData . theStack - > first , false ) ) ;
2017-05-26 05:24:38 +02:00
// Horrible hacking because 'last' value might now be wrong!
2018-05-31 22:55:36 +02:00
VariableStack * nextFirstStack = fun - > stack - > next - > thisVar . varData . theStack - > first ;
fun - > stack - > next - > thisVar . varData . theStack - > last = ( nextFirstStack = = NULL ) ? NULL : nextFirstStack - > stackFindLast ( ) ;
2017-05-26 05:24:38 +02:00
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( deleteAllFromStack ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > next - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " Parameter isn't a stack. " ) ;
return BR_ERROR ;
}
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , deleteVarFromStack ( fun - > stack - > thisVar , fun - > stack - > next - > thisVar . varData . theStack - > first , true ) ) ;
2017-05-26 05:24:38 +02:00
// Horrible hacking because 'last' value might now be wrong!
2018-05-31 22:55:36 +02:00
VariableStack * nextFirstStack = fun - > stack - > next - > thisVar . varData . theStack - > first ;
fun - > stack - > next - > thisVar . varData . theStack - > last = ( nextFirstStack = = NULL ) ? NULL : nextFirstStack - > stackFindLast ( ) ;
2017-05-26 05:24:38 +02:00
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( popFromStack ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " Parameter isn't a stack. " ) ;
return BR_ERROR ;
}
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varData . theStack - > first = = NULL ) {
2017-05-26 05:24:38 +02:00
fatal ( " The stack's empty. " ) ;
return BR_ERROR ;
}
// Return value
2018-05-31 19:57:45 +02:00
fun - > reg . copyFrom ( fun - > stack - > thisVar . varData . theStack - > first - > thisVar ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack - > thisVar . varData . theStack - > first ) ;
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( peekStart ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " Parameter isn't a stack. " ) ;
return BR_ERROR ;
}
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varData . theStack - > first = = NULL ) {
2017-05-26 05:24:38 +02:00
fatal ( " The stack's empty. " ) ;
return BR_ERROR ;
}
// Return value
2018-05-31 19:57:45 +02:00
fun - > reg . copyFrom ( fun - > stack - > thisVar . varData . theStack - > first - > thisVar ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( peekEnd ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " Parameter isn't a stack. " ) ;
return BR_ERROR ;
}
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varData . theStack - > first = = NULL ) {
2017-05-26 05:24:38 +02:00
fatal ( " The stack's empty. " ) ;
return BR_ERROR ;
}
// Return value
2018-05-31 19:57:45 +02:00
fun - > reg . copyFrom ( fun - > stack - > thisVar . varData . theStack - > last - > thisVar ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( random ) {
UNUSEDALL
int num ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( num , SVT_INT ) )
2017-05-26 05:24:38 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-06-05 11:49:19 +02:00
if ( num < = 0 )
num = 1 ;
2019-06-18 01:43:11 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > getRandomSource ( ) - > getRandomNumber ( num - 1 ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
2017-07-20 10:39:24 +02:00
static bool getRGBParams ( int & red , int & green , int & blue , LoadedFunction * fun ) {
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( blue , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return false ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( green , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return false ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( red , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return false ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return true ;
}
builtIn ( setStatusColour ) {
UNUSEDALL
int red , green , blue ;
if ( ! getRGBParams ( red , green , blue , fun ) )
return BR_ERROR ;
2017-06-05 11:49:19 +02:00
statusBarColour ( ( byte ) red , ( byte ) green , ( byte ) blue ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setLitStatusColour ) {
UNUSEDALL
int red , green , blue ;
if ( ! getRGBParams ( red , green , blue , fun ) )
return BR_ERROR ;
2017-06-05 11:49:19 +02:00
statusBarLitColour ( ( byte ) red , ( byte ) green , ( byte ) blue ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setPasteColour ) {
UNUSEDALL
int red , green , blue ;
if ( ! getRGBParams ( red , green , blue , fun ) )
return BR_ERROR ;
2018-04-01 18:02:14 +02:00
g_sludge - > _txtMan - > setPasterColor ( ( byte ) red , ( byte ) green , ( byte ) blue ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setBlankColour ) {
UNUSEDALL
int red , green , blue ;
if ( ! getRGBParams ( red , green , blue , fun ) )
return BR_ERROR ;
2017-07-04 23:59:02 +02:00
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > setBlankColor ( red , green , blue ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setBurnColour ) {
UNUSEDALL
int red , green , blue ;
if ( ! getRGBParams ( red , green , blue , fun ) )
return BR_ERROR ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > setBurnColor ( red , green , blue ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setFont ) {
UNUSEDALL
int fileNumber , newHeight ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( newHeight , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
// newDebug (" Height:", newHeight);
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 20:09:36 +02:00
Common : : String newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-26 05:24:38 +02:00
// newDebug (" Character supported:", newText);
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
// newDebug (" File:", fileNumber);
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-21 00:11:17 +02:00
if ( ! g_sludge - > _txtMan - > loadFont ( fileNumber , newText , newHeight ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
// newDebug (" Done!");
return BR_CONTINUE ;
}
builtIn ( inFont ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _txtMan - > isInFont ( newText ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( pasteString ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
int y , x ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-06-05 11:49:19 +02:00
if ( x = = IN_THE_CENTRE )
2017-07-21 00:11:17 +02:00
x = g_sludge - > _gfxMan - > getCenterX ( g_sludge - > _txtMan - > stringWidth ( newText ) ) ;
2018-04-01 18:02:14 +02:00
g_sludge - > _txtMan - > pasteStringToBackdrop ( newText , x , y ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( anim ) {
UNUSEDALL
if ( numParams < 2 ) {
fatal ( " Built-in function anim() must have at least 2 parameters. " ) ;
return BR_ERROR ;
}
// First store the frame numbers and take 'em off the stack
2018-04-15 21:35:19 +02:00
PersonaAnimation * ba = new PersonaAnimation ( numParams - 1 , fun - > stack ) ;
2017-05-26 05:24:38 +02:00
// Only remaining paramter is the file number
int fileNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
// Load the required sprite bank
2017-07-21 14:00:24 +02:00
LoadedSpriteBank * sprBanky = g_sludge - > _gfxMan - > loadBankForAnim ( fileNumber ) ;
2017-06-05 11:49:19 +02:00
if ( ! sprBanky )
return BR_ERROR ; // File not found, fatal done already
2018-04-15 21:35:19 +02:00
ba - > theSprites = sprBanky ;
2017-05-26 05:24:38 +02:00
// Return value
2018-05-31 20:14:33 +02:00
fun - > reg . makeAnimationVariable ( ba ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( costume ) {
UNUSEDALL
2017-07-20 10:39:24 +02:00
Persona * newPersona = new Persona ;
2017-06-05 11:49:19 +02:00
if ( ! checkNew ( newPersona ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
newPersona - > numDirections = numParams / 3 ;
if ( numParams = = 0 | | newPersona - > numDirections * 3 ! = numParams ) {
2017-05-26 05:24:38 +02:00
fatal ( " Illegal number of parameters (should be greater than 0 and divisible by 3) " ) ;
return BR_ERROR ;
}
int iii ;
2017-07-20 10:39:24 +02:00
newPersona - > animation = new PersonaAnimation * [ numParams ] ;
2017-06-05 11:49:19 +02:00
if ( ! checkNew ( newPersona - > animation ) )
return BR_ERROR ;
for ( iii = numParams - 1 ; iii > = 0 ; iii - - ) {
2018-05-31 20:14:33 +02:00
newPersona - > animation [ iii ] = fun - > stack - > thisVar . getAnimationFromVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
}
// Return value
2018-05-31 21:53:59 +02:00
fun - > reg . makeCostumeVariable ( newPersona ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( launch ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newTextA = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-26 05:24:38 +02:00
2017-07-11 14:57:31 +02:00
Common : : String newText = encodeFilename ( newTextA ) ;
2017-05-26 05:24:38 +02:00
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-06-05 11:49:19 +02:00
if ( newTextA [ 0 ] = = ' h ' & & newTextA [ 1 ] = = ' t ' & & newTextA [ 2 ] = = ' t ' & & newTextA [ 3 ] = = ' p ' & & ( newTextA [ 4 ] = = ' : ' | | ( newTextA [ 4 ] = = ' s ' & & newTextA [ 5 ] = = ' : ' ) ) ) {
2017-05-26 05:24:38 +02:00
// IT'S A WEBSITE!
2017-07-11 15:39:22 +02:00
g_sludge - > launchMe . clear ( ) ;
g_sludge - > launchMe = newTextA ;
2017-05-26 05:24:38 +02:00
} else {
2017-07-11 15:39:22 +02:00
Common : : String gameDir = g_sludge - > gamePath ;
2017-07-11 14:57:31 +02:00
gameDir + = " / " ;
2017-07-11 15:39:22 +02:00
g_sludge - > launchMe . clear ( ) ;
g_sludge - > launchMe = gameDir + newText ;
if ( g_sludge - > launchMe . empty ( ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
}
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
launchResult = & fun - > reg ;
return BR_KEEP_AND_PAUSE ;
}
builtIn ( pause ) {
UNUSEDALL
int theTime ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( theTime , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
if ( theTime > 0 ) {
2017-05-27 20:16:54 +02:00
fun - > timeLeft = theTime - 1 ;
fun - > isSpeech = false ;
2017-05-26 05:24:38 +02:00
return BR_KEEP_AND_PAUSE ;
}
return BR_CONTINUE ;
}
builtIn ( completeTimers ) {
UNUSEDALL
completeTimers ( ) ;
return BR_CONTINUE ;
}
builtIn ( callEvent ) {
UNUSEDALL
int obj1 , obj2 ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj2 , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj1 , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-07-18 19:50:45 +02:00
int fNum = g_sludge - > _objMan - > getCombinationFunction ( obj1 , obj2 ) ;
2017-05-26 05:24:38 +02:00
// Return value
if ( fNum ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_FUNC , fNum ) ;
2017-05-26 05:24:38 +02:00
return BR_CALLAFUNC ;
}
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( quitGame ) {
UNUSEDALL
2017-08-03 04:14:35 +02:00
g_sludge - > _evtMan - > quitGame ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
# pragma mark -
# pragma mark Movie functions
// The old movie functions are deprecated and does nothing.
builtIn ( _rem_movieStart ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( _rem_movieAbort ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( _rem_moviePlaying ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( playMovie ) {
UNUSEDALL
int fileNumber , r ;
2017-06-05 11:49:19 +02:00
if ( movieIsPlaying )
return BR_PAUSE ;
2017-05-26 05:24:38 +02:00
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
r = playMovie ( fileNumber ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , r ) ;
2017-05-26 05:24:38 +02:00
if ( r & & ( ! fun - > next ) ) {
restartFunction ( fun ) ;
return BR_ALREADY_GONE ;
}
return BR_CONTINUE ;
}
builtIn ( stopMovie ) {
UNUSEDALL
2017-07-13 23:26:47 +02:00
stopMovie ( ) ;
2017-05-26 05:24:38 +02:00
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( pauseMovie ) {
UNUSEDALL
2017-07-13 23:26:47 +02:00
pauseMovie ( ) ;
2017-05-26 05:24:38 +02:00
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
# pragma mark -
# pragma mark Audio functions
builtIn ( startMusic ) {
UNUSEDALL
int fromTrack , musChan , fileNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fromTrack , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( musChan , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
if ( ! g_sludge - > _soundMan - > playMOD ( fileNumber , musChan , fromTrack ) )
2017-06-05 11:49:19 +02:00
return BR_CONTINUE ; //BR_ERROR;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( stopMusic ) {
UNUSEDALL
int v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > stopMOD ( v ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setMusicVolume ) {
UNUSEDALL
int musChan , v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( musChan , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > setMusicVolume ( musChan , v ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setDefaultMusicVolume ) {
UNUSEDALL
int v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > setDefaultMusicVolume ( v ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( playSound ) {
UNUSEDALL
int fileNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
if ( ! g_sludge - > _soundMan - > startSound ( fileNumber , false ) )
2017-06-05 11:49:19 +02:00
return BR_CONTINUE ; // Was BR_ERROR
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( loopSound ) {
UNUSEDALL
int fileNumber ;
if ( numParams < 1 ) {
fatal ( " Built-in function loopSound() must have at least 1 parameter. " ) ;
return BR_ERROR ;
} else if ( numParams < 2 ) {
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
if ( ! g_sludge - > _soundMan - > startSound ( fileNumber , true ) )
2017-06-05 11:49:19 +02:00
return BR_CONTINUE ; // Was BR_ERROR
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
} else {
// We have more than one sound to play!
int doLoop = 2 ;
2017-07-20 10:39:24 +02:00
SoundList * s = NULL ;
SoundList * old = NULL ;
2017-05-26 05:24:38 +02:00
// Should we loop?
if ( fun - > stack - > thisVar . varType ! = SVT_FILE ) {
2018-05-31 22:21:30 +02:00
fun - > stack - > thisVar . getValueType ( doLoop , SVT_INT ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
numParams - - ;
}
while ( numParams ) {
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) ) {
2017-05-26 05:24:38 +02:00
fatal ( " Illegal parameter given built-in function loopSound(). " ) ;
return BR_ERROR ;
}
2017-07-20 10:39:24 +02:00
s = new SoundList ;
2017-06-05 11:49:19 +02:00
if ( ! checkNew ( s ) )
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
s - > next = old ;
s - > prev = NULL ;
s - > sound = fileNumber ;
2017-05-26 05:24:38 +02:00
old = s ;
trimStack ( fun - > stack ) ;
numParams - - ;
}
2017-06-05 11:49:19 +02:00
while ( s - > next )
s = s - > next ;
2017-05-26 05:24:38 +02:00
if ( doLoop > 1 ) {
s - > next = old ;
old - > prev = s ;
} else if ( doLoop ) {
s - > next = s ;
}
old - > vol = - 1 ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > playSoundList ( old ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
}
builtIn ( stopSound ) {
UNUSEDALL
int v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > huntKillSound ( v ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setDefaultSoundVolume ) {
UNUSEDALL
int v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > setDefaultSoundVolume ( v ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setSoundVolume ) {
UNUSEDALL
int musChan , v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( musChan , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > setSoundVolume ( musChan , v ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setSoundLoopPoints ) {
UNUSEDALL
int musChan , theEnd , theStart ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( theEnd , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( theStart , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( musChan , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > setSoundLoop ( musChan , theStart , theEnd ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
# pragma mark -
# pragma mark Extra room bits
builtIn ( setFloor ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varType = = SVT_FILE ) {
2017-05-26 05:24:38 +02:00
int v ;
2018-05-31 22:21:30 +02:00
fun - > stack - > thisVar . getValueType ( v , SVT_FILE ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-01 18:41:34 +02:00
if ( ! g_sludge - > _floorMan - > setFloor ( v ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
} else {
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-01 18:41:34 +02:00
g_sludge - > _floorMan - > setFloorNull ( ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( showFloor ) {
UNUSEDALL
2018-05-01 18:41:34 +02:00
g_sludge - > _floorMan - > drawFloor ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setZBuffer ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varType = = SVT_FILE ) {
2017-05-26 05:24:38 +02:00
int v ;
2018-05-31 22:21:30 +02:00
fun - > stack - > thisVar . getValueType ( v , SVT_FILE ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
if ( ! g_sludge - > _gfxMan - > setZBuffer ( v ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
} else {
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > killZBuffer ( ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( setLightMap ) {
UNUSEDALL
switch ( numParams ) {
2017-06-05 11:49:19 +02:00
case 2 :
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( g_sludge - > _gfxMan - > _lightMapMode , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > _lightMapMode % = LIGHTMAPMODE_NUM ;
2017-08-06 13:30:51 +02:00
// fall through
2017-06-05 11:49:19 +02:00
case 1 :
if ( fun - > stack - > thisVar . varType = = SVT_FILE ) {
int v ;
2018-05-31 22:21:30 +02:00
fun - > stack - > thisVar . getValueType ( v , SVT_FILE ) ;
2017-06-05 11:49:19 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
if ( ! g_sludge - > _gfxMan - > loadLightMap ( v ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-06-05 11:49:19 +02:00
} else {
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > killLightMap ( ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-06-05 11:49:19 +02:00
}
break ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
default :
fatal ( " Function should have either 2 or 3 parameters " ) ;
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
# pragma mark -
# pragma mark Objects
builtIn ( setSpeechMode ) {
UNUSEDALL
2018-04-27 19:20:09 +02:00
int speechMode ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( speechMode , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
if ( speechMode < 0 | | speechMode > 2 ) {
fatal ( " Valid parameters are be SPEECHANDTEXT, SPEECHONLY or TEXTONLY " ) ;
return BR_ERROR ;
}
2018-04-27 19:20:09 +02:00
g_sludge - > _speechMan - > setSpeechMode ( speechMode ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( somethingSpeaking ) {
UNUSEDALL
2017-12-19 21:24:31 +01:00
int i = g_sludge - > _speechMan - > isThereAnySpeechGoingOn ( ) ;
2017-05-26 05:24:38 +02:00
if ( i = = - 1 ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_OBJTYPE , i ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( skipSpeech ) {
UNUSEDALL
killSpeechTimers ( ) ;
return BR_CONTINUE ;
}
builtIn ( getOverObject ) {
UNUSEDALL
2018-04-15 00:21:17 +02:00
if ( g_sludge - > _regionMan - > getOverRegion ( ) )
2017-05-26 05:24:38 +02:00
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_OBJTYPE , g_sludge - > _regionMan - > getOverRegion ( ) - > thisType - > objectNum ) ;
2017-05-26 05:24:38 +02:00
else
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( rename ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-26 05:24:38 +02:00
int objT ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objT , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-18 19:50:45 +02:00
ObjectType * o = g_sludge - > _objMan - > findObjectType ( objT ) ;
2017-07-11 14:57:31 +02:00
o - > screenName . clear ( ) ;
2017-05-27 20:16:54 +02:00
o - > screenName = newText ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getObjectX ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-04-15 21:10:02 +02:00
OnScreenPerson * pers = g_sludge - > _peopleMan - > findPerson ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( pers ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , pers - > x ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-04-15 00:21:17 +02:00
ScreenRegion * la = g_sludge - > _regionMan - > getRegionForObject ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( la ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , la - > sX ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
}
return BR_CONTINUE ;
}
builtIn ( getObjectY ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-04-15 21:10:02 +02:00
OnScreenPerson * pers = g_sludge - > _peopleMan - > findPerson ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( pers ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , pers - > y ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-04-15 00:21:17 +02:00
ScreenRegion * la = g_sludge - > _regionMan - > getRegionForObject ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( la ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , la - > sY ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
}
return BR_CONTINUE ;
}
builtIn ( addScreenRegion ) {
UNUSEDALL
int sX , sY , x1 , y1 , x2 , y2 , di , objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( di , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( sY , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( sX , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y2 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x2 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y1 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x1 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 00:21:17 +02:00
if ( g_sludge - > _regionMan - > addScreenRegion ( x1 , y1 , x2 , y2 , sX , sY , di , objectNumber ) )
2017-06-05 11:49:19 +02:00
return BR_CONTINUE ;
2017-05-26 05:24:38 +02:00
return BR_ERROR ;
}
builtIn ( removeScreenRegion ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 00:21:17 +02:00
g_sludge - > _regionMan - > removeScreenRegion ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( showBoxes ) {
UNUSEDALL
2018-04-15 00:21:17 +02:00
g_sludge - > _regionMan - > showBoxes ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( removeAllScreenRegions ) {
UNUSEDALL
2018-04-15 00:33:01 +02:00
g_sludge - > _regionMan - > kill ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( addCharacter ) {
UNUSEDALL
2017-07-20 10:39:24 +02:00
Persona * p ;
2017-05-26 05:24:38 +02:00
int x , y , objectNumber ;
2018-05-31 21:53:59 +02:00
p = fun - > stack - > thisVar . getCostumeFromVar ( ) ;
2017-06-05 11:49:19 +02:00
if ( p = = NULL )
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
if ( g_sludge - > _peopleMan - > addPerson ( x , y , objectNumber , p ) )
2017-06-05 11:49:19 +02:00
return BR_CONTINUE ;
2017-05-26 05:24:38 +02:00
return BR_ERROR ;
}
builtIn ( hideCharacter ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > setShown ( false , objectNumber ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( showCharacter ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > setShown ( true , objectNumber ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( removeAllCharacters ) {
UNUSEDALL
killSpeechTimers ( ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > killMostPeople ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCharacterDrawMode ) {
UNUSEDALL
int obj , di ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( di , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > setDrawMode ( di , obj ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCharacterTransparency ) {
UNUSEDALL
int obj , x ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > setPersonTransparency ( obj , x ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCharacterColourise ) {
UNUSEDALL
int obj , r , g , b , mix ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( mix , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( b , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( g , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( r , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > setPersonColourise ( obj , r , g , b , mix ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setScale ) {
UNUSEDALL
int val1 , val2 ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( val2 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( val1 , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > setScale ( ( int16 ) val1 , ( int16 ) val2 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( stopCharacter ) {
UNUSEDALL
int obj ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _peopleMan - > stopPerson ( obj ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( pasteCharacter ) {
UNUSEDALL
int obj ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-04-15 21:10:02 +02:00
OnScreenPerson * thisPerson = g_sludge - > _peopleMan - > findPerson ( obj ) ;
2017-05-26 05:24:38 +02:00
if ( thisPerson ) {
2017-07-20 10:39:24 +02:00
PersonaAnimation * myAnim ;
2017-05-27 20:16:54 +02:00
myAnim = thisPerson - > myAnim ;
if ( myAnim ! = thisPerson - > lastUsedAnim ) {
thisPerson - > lastUsedAnim = myAnim ;
thisPerson - > frameNum = 0 ;
thisPerson - > frameTick = myAnim - > frames [ 0 ] . howMany ;
2017-05-26 05:24:38 +02:00
}
2017-05-27 20:16:54 +02:00
int fNum = myAnim - > frames [ thisPerson - > frameNum ] . frameNum ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > fixScaleSprite ( thisPerson - > x , thisPerson - > y , myAnim - > theSprites - > bank . sprites [ ABS ( fNum ) ] , myAnim - > theSprites - > bank . myPalette , thisPerson , 0 , 0 , fNum < 0 ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( animate ) {
UNUSEDALL
int obj ;
2018-05-31 20:14:33 +02:00
PersonaAnimation * pp = fun - > stack - > thisVar . getAnimationFromVar ( ) ;
2017-06-05 11:49:19 +02:00
if ( pp = = NULL )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > animatePerson ( obj , pp ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , pp - > getTotalTime ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCostume ) {
UNUSEDALL
int obj ;
2018-05-31 21:53:59 +02:00
Persona * pp = fun - > stack - > thisVar . getCostumeFromVar ( ) ;
2017-06-05 11:49:19 +02:00
if ( pp = = NULL )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > animatePerson ( obj , pp ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( floatCharacter ) {
UNUSEDALL
int obj , di ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( di , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _peopleMan - > floatCharacter ( di , obj ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCharacterWalkSpeed ) {
UNUSEDALL
int obj , di ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( di , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _peopleMan - > setCharacterWalkSpeed ( di , obj ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( turnCharacter ) {
UNUSEDALL
int obj , di ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( di , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _peopleMan - > turnPersonToFace ( obj , di ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCharacterExtra ) {
UNUSEDALL
int obj , di ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( di , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _peopleMan - > setPersonExtra ( obj , di ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( removeCharacter ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > removeOneCharacter ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
2017-07-20 10:39:24 +02:00
static BuiltReturn moveChr ( int numParams , LoadedFunction * fun , bool force , bool immediate ) {
2017-05-26 05:24:38 +02:00
switch ( numParams ) {
2017-06-05 11:49:19 +02:00
case 3 : {
int x , y , objectNumber ;
2017-05-26 05:24:38 +02:00
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
if ( force ) {
2018-04-15 21:10:02 +02:00
if ( g_sludge - > _peopleMan - > forceWalkingPerson ( x , y , objectNumber , fun , - 1 ) )
2017-06-05 11:49:19 +02:00
return BR_PAUSE ;
} else if ( immediate ) {
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > jumpPerson ( x , y , objectNumber ) ;
2017-06-05 11:49:19 +02:00
} else {
2018-04-15 21:10:02 +02:00
if ( g_sludge - > _peopleMan - > makeWalkingPerson ( x , y , objectNumber , fun , - 1 ) )
2017-06-05 11:49:19 +02:00
return BR_PAUSE ;
}
return BR_CONTINUE ;
2017-05-26 05:24:38 +02:00
}
2017-06-05 11:49:19 +02:00
case 2 : {
int toObj , objectNumber ;
2017-07-20 10:39:24 +02:00
ScreenRegion * reggie ;
2017-05-26 05:24:38 +02:00
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( toObj , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
trimStack ( fun - > stack ) ;
2018-04-15 00:21:17 +02:00
reggie = g_sludge - > _regionMan - > getRegionForObject ( toObj ) ;
2017-06-05 11:49:19 +02:00
if ( reggie = = NULL )
return BR_CONTINUE ;
if ( force ) {
2018-04-15 21:10:02 +02:00
if ( g_sludge - > _peopleMan - > forceWalkingPerson ( reggie - > sX , reggie - > sY , objectNumber , fun , reggie - > di ) )
2017-06-05 11:49:19 +02:00
return BR_PAUSE ;
} else if ( immediate ) {
2018-04-15 21:10:02 +02:00
g_sludge - > _peopleMan - > jumpPerson ( reggie - > sX , reggie - > sY , objectNumber ) ;
2017-06-05 11:49:19 +02:00
} else {
2018-04-15 21:10:02 +02:00
if ( g_sludge - > _peopleMan - > makeWalkingPerson ( reggie - > sX , reggie - > sY , objectNumber , fun , reggie - > di ) )
2017-06-05 11:49:19 +02:00
return BR_PAUSE ;
}
return BR_CONTINUE ;
2017-05-26 05:24:38 +02:00
}
2017-06-05 11:49:19 +02:00
default :
fatal ( " Built-in function must have either 2 or 3 parameters. " ) ;
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
}
}
builtIn ( moveCharacter ) {
UNUSEDALL
return moveChr ( numParams , fun , false , false ) ;
}
builtIn ( forceCharacter ) {
UNUSEDALL
return moveChr ( numParams , fun , true , false ) ;
}
builtIn ( jumpCharacter ) {
UNUSEDALL
return moveChr ( numParams , fun , false , true ) ;
}
builtIn ( clearStatus ) {
UNUSEDALL
clearStatusBar ( ) ;
return BR_CONTINUE ;
}
builtIn ( removeLastStatus ) {
UNUSEDALL
killLastStatus ( ) ;
return BR_CONTINUE ;
}
builtIn ( addStatus ) {
UNUSEDALL
addStatusBar ( ) ;
return BR_CONTINUE ;
}
builtIn ( statusText ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
setStatusBar ( newText ) ;
return BR_CONTINUE ;
}
builtIn ( lightStatus ) {
UNUSEDALL
int val ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( val , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
setLitStatus ( val ) ;
return BR_CONTINUE ;
}
builtIn ( positionStatus ) {
UNUSEDALL
int x , y ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
positionStatus ( x , y ) ;
return BR_CONTINUE ;
}
builtIn ( alignStatus ) {
UNUSEDALL
int val ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( val , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-10 21:44:14 +02:00
nowStatus - > alignStatus = ( int16 ) val ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
2017-07-20 10:39:24 +02:00
static bool getFuncNumForCallback ( int numParams , LoadedFunction * fun , int & functionNum ) {
2017-05-26 05:24:38 +02:00
switch ( numParams ) {
2017-06-05 11:49:19 +02:00
case 0 :
functionNum = 0 ;
break ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
case 1 :
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( functionNum , SVT_FUNC ) )
2017-06-05 11:49:19 +02:00
return false ;
trimStack ( fun - > stack ) ;
break ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
default :
fatal ( " Too many parameters. " ) ;
return false ;
2017-05-26 05:24:38 +02:00
}
return true ;
}
builtIn ( onLeftMouse ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
2017-07-20 19:08:53 +02:00
g_sludge - > _evtMan - > setEventFunction ( kLeftMouse , functionNum ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( onLeftMouseUp ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
2017-07-20 19:08:53 +02:00
g_sludge - > _evtMan - > setEventFunction ( kLeftMouseUp , functionNum ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( onRightMouse ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
2017-07-20 19:08:53 +02:00
g_sludge - > _evtMan - > setEventFunction ( kRightMouse , functionNum ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( onRightMouseUp ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
2017-07-20 19:08:53 +02:00
g_sludge - > _evtMan - > setEventFunction ( kRightMouseUp , functionNum ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( onFocusChange ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
2017-07-20 19:08:53 +02:00
g_sludge - > _evtMan - > setEventFunction ( kFocus , functionNum ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( onMoveMouse ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
2017-07-20 19:08:53 +02:00
g_sludge - > _evtMan - > setEventFunction ( kMoveMouse , functionNum ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( onKeyboard ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
2017-07-20 19:08:53 +02:00
g_sludge - > _evtMan - > setEventFunction ( kSpace , functionNum ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( spawnSub ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
2017-06-05 11:49:19 +02:00
if ( ! startNewFunctionNum ( functionNum , 0 , NULL , noStack ) )
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( cancelSub ) {
UNUSEDALL
int functionNum ;
if ( getFuncNumForCallback ( numParams , fun , functionNum ) ) {
bool killedMyself ;
cancelAFunction ( functionNum , fun , killedMyself ) ;
if ( killedMyself ) {
abortFunction ( fun ) ;
return BR_ALREADY_GONE ;
}
return BR_CONTINUE ;
}
return BR_ERROR ;
}
builtIn ( stringWidth ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String theText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
// Return value
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _txtMan - > stringWidth ( theText ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( hardScroll ) {
UNUSEDALL
int v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > hardScroll ( v ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( isScreenRegion ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _regionMan - > getRegionForObject ( objectNumber ) ! = NULL ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setSpeechSpeed ) {
UNUSEDALL
int number ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( number , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-12-19 21:24:31 +01:00
g_sludge - > _speechMan - > setSpeechSpeed ( number * 0.01 ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setFontSpacing ) {
UNUSEDALL
int fontSpaceI ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fontSpaceI , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-07-21 00:11:17 +02:00
g_sludge - > _txtMan - > setFontSpace ( fontSpaceI ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( transitionLevel ) {
UNUSEDALL
2018-04-27 19:12:30 +02:00
int brightnessLevel ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( brightnessLevel , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-04-27 19:12:30 +02:00
g_sludge - > _gfxMan - > setBrightnessLevel ( brightnessLevel ) ;
2017-05-26 05:24:38 +02:00
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( captureAllKeys ) {
UNUSEDALL
2018-04-15 20:21:04 +02:00
// This built-in function doesn't have any effect any more, we capture all keys by default
2018-05-31 22:21:30 +02:00
bool captureAllKeysDeprecated = fun - > stack - > thisVar . getBoolean ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , captureAllKeysDeprecated ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( spinCharacter ) {
UNUSEDALL
int number , objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( number , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-04-15 21:10:02 +02:00
OnScreenPerson * thisPerson = g_sludge - > _peopleMan - > findPerson ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( thisPerson ) {
2017-05-27 20:16:54 +02:00
thisPerson - > wantAngle = number ;
thisPerson - > spinning = true ;
thisPerson - > continueAfterWalking = fun ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_PAUSE ;
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
}
builtIn ( getCharacterDirection ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
OnScreenPerson * thisPerson = g_sludge - > _peopleMan - > findPerson ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( thisPerson ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , thisPerson - > direction ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( isCharacter ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
OnScreenPerson * thisPerson = g_sludge - > _peopleMan - > findPerson ( objectNumber ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , thisPerson ! = NULL ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( normalCharacter ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
OnScreenPerson * thisPerson = g_sludge - > _peopleMan - > findPerson ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( thisPerson ) {
2017-05-27 20:16:54 +02:00
thisPerson - > myAnim = thisPerson - > myPersona - > animation [ thisPerson - > direction ] ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( isMoving ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-15 21:10:02 +02:00
OnScreenPerson * thisPerson = g_sludge - > _peopleMan - > findPerson ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( thisPerson ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , thisPerson - > walking ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( fetchEvent ) {
UNUSEDALL
int obj1 , obj2 ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj2 , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( obj1 , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-07-18 19:50:45 +02:00
int fNum = g_sludge - > _objMan - > getCombinationFunction ( obj1 , obj2 ) ;
2017-05-26 05:24:38 +02:00
// Return value
if ( fNum ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_FUNC , fNum ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( deleteFile ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String namNormal = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-11 14:57:31 +02:00
Common : : String nam = encodeFilename ( namNormal ) ;
namNormal . clear ( ) ;
2017-06-05 11:49:19 +02:00
if ( failSecurityCheck ( nam ) )
return BR_ERROR ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , remove ( nam . c_str ( ) ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( renameFile ) {
UNUSEDALL
2017-07-11 14:57:31 +02:00
Common : : String temp ;
2017-05-26 05:24:38 +02:00
2017-07-11 14:57:31 +02:00
temp . clear ( ) ;
2018-05-31 20:09:36 +02:00
temp = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-07-11 14:57:31 +02:00
Common : : String newnam = encodeFilename ( temp ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-06-05 11:49:19 +02:00
if ( failSecurityCheck ( newnam ) )
return BR_ERROR ;
2017-07-11 14:57:31 +02:00
temp . clear ( ) ;
2017-05-26 05:24:38 +02:00
2018-05-31 20:09:36 +02:00
temp = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-07-11 14:57:31 +02:00
Common : : String nam = encodeFilename ( temp ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-06-05 11:49:19 +02:00
if ( failSecurityCheck ( nam ) )
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , rename ( nam . c_str ( ) , newnam . c_str ( ) ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( cacheSound ) {
UNUSEDALL
int fileNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( fileNumber , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
if ( g_sludge - > _soundMan - > cacheSound ( fileNumber ) = = - 1 )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( burnString ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newText = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
int y , x ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-06-05 11:49:19 +02:00
if ( x = = IN_THE_CENTRE )
2017-07-21 00:11:17 +02:00
x = g_sludge - > _gfxMan - > getCenterX ( g_sludge - > _txtMan - > stringWidth ( newText ) ) ;
2018-04-01 18:02:14 +02:00
g_sludge - > _txtMan - > burnStringToBackdrop ( newText , x , y ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCharacterSpinSpeed ) {
UNUSEDALL
int speed , who ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( speed , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( who , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-04-15 21:10:02 +02:00
OnScreenPerson * thisPerson = g_sludge - > _peopleMan - > findPerson ( who ) ;
2017-05-26 05:24:38 +02:00
if ( thisPerson ) {
2017-05-27 20:16:54 +02:00
thisPerson - > spinSpeed = speed ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( setCharacterAngleOffset ) {
UNUSEDALL
int angle , who ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( angle , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( who , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-04-15 21:10:02 +02:00
OnScreenPerson * thisPerson = g_sludge - > _peopleMan - > findPerson ( who ) ;
2017-05-26 05:24:38 +02:00
if ( thisPerson ) {
2017-05-27 20:16:54 +02:00
thisPerson - > angleOffset = angle ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( transitionMode ) {
UNUSEDALL
int n ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( n , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2018-04-29 09:52:48 +02:00
g_sludge - > _gfxMan - > setFadeMode ( n ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
// Removed function - does nothing
builtIn ( _rem_updateDisplay ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , true ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getSoundCache ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
fun - > reg . varType = SVT_STACK ;
2017-07-20 10:39:24 +02:00
fun - > reg . varData . theStack = new StackHandler ;
2017-06-05 11:49:19 +02:00
if ( ! checkNew ( fun - > reg . varData . theStack ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
fun - > reg . varData . theStack - > first = NULL ;
fun - > reg . varData . theStack - > last = NULL ;
fun - > reg . varData . theStack - > timesUsed = 1 ;
2017-07-20 23:18:05 +02:00
if ( ! g_sludge - > _soundMan - > getSoundCacheStack ( fun - > reg . varData . theStack ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( saveCustomData ) {
UNUSEDALL
// saveCustomData (thisStack, fileName);
2018-05-31 20:09:36 +02:00
Common : : String fileNameB = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-26 05:24:38 +02:00
2017-07-11 14:57:31 +02:00
Common : : String fileName = encodeFilename ( fileNameB ) ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
if ( failSecurityCheck ( fileName ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-05-27 20:16:54 +02:00
if ( fun - > stack - > thisVar . varType ! = SVT_STACK ) {
2017-05-26 05:24:38 +02:00
fatal ( " First parameter isn't a stack " ) ;
return BR_ERROR ;
}
2018-04-29 09:42:26 +02:00
if ( ! CustomSaveHelper : : stackToFile ( fileName , fun - > stack - > thisVar ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( loadCustomData ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String newTextA = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-26 05:24:38 +02:00
2017-07-11 14:57:31 +02:00
Common : : String newText = encodeFilename ( newTextA ) ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
if ( failSecurityCheck ( newText ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-30 19:57:32 +02:00
fun - > reg . unlinkVar ( ) ;
2017-05-27 20:16:54 +02:00
fun - > reg . varType = SVT_STACK ;
2017-07-20 10:39:24 +02:00
fun - > reg . varData . theStack = new StackHandler ;
2017-06-05 11:49:19 +02:00
if ( ! checkNew ( fun - > reg . varData . theStack ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
fun - > reg . varData . theStack - > first = NULL ;
fun - > reg . varData . theStack - > last = NULL ;
fun - > reg . varData . theStack - > timesUsed = 1 ;
2018-04-29 09:42:26 +02:00
if ( ! CustomSaveHelper : : fileToStack ( newText , fun - > reg . varData . theStack ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setCustomEncoding ) {
UNUSEDALL
int n ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( n , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2018-04-29 09:42:26 +02:00
CustomSaveHelper : : _saveEncoding = n ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( freeSound ) {
UNUSEDALL
int v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-20 23:18:05 +02:00
g_sludge - > _soundMan - > huntKillFreeSound ( v ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( parallaxAdd ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
if ( g_sludge - > _gfxMan - > isFrozen ( ) ) {
2017-05-26 05:24:38 +02:00
fatal ( " Can't set background parallax image while frozen " ) ;
return BR_ERROR ;
} else {
int wrapX , wrapY , v ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( wrapY , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( wrapX , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( v , SVT_FILE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-07-19 13:37:54 +02:00
if ( ! g_sludge - > _gfxMan - > loadParallax ( v , wrapX , wrapY ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( parallaxClear ) {
UNUSEDALL
2017-07-19 13:37:54 +02:00
g_sludge - > _gfxMan - > killParallax ( ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 1 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( getPixelColour ) {
UNUSEDALL
int x , y ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-05-30 19:57:32 +02:00
fun - > reg . unlinkVar ( ) ;
2017-05-27 20:16:54 +02:00
fun - > reg . varType = SVT_STACK ;
2017-07-20 10:39:24 +02:00
fun - > reg . varData . theStack = new StackHandler ;
2017-06-05 11:49:19 +02:00
if ( ! checkNew ( fun - > reg . varData . theStack ) )
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
fun - > reg . varData . theStack - > first = NULL ;
fun - > reg . varData . theStack - > last = NULL ;
fun - > reg . varData . theStack - > timesUsed = 1 ;
2017-07-20 00:41:13 +02:00
if ( ! g_sludge - > _gfxMan - > getRGBIntoStack ( x , y , fun - > reg . varData . theStack ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( makeFastArray ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
switch ( fun - > stack - > thisVar . varType ) {
2017-06-05 11:49:19 +02:00
case SVT_STACK : {
2018-05-31 22:38:26 +02:00
bool success = fun - > reg . makeFastArrayFromStack ( fun - > stack - > thisVar . varData . theStack ) ;
2017-06-05 11:49:19 +02:00
trimStack ( fun - > stack ) ;
return success ? BR_CONTINUE : BR_ERROR ;
}
break ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
case SVT_INT : {
int i = fun - > stack - > thisVar . varData . intValue ;
trimStack ( fun - > stack ) ;
2018-05-31 22:38:26 +02:00
return fun - > reg . makeFastArraySize ( i ) ? BR_CONTINUE : BR_ERROR ;
2017-06-05 11:49:19 +02:00
}
break ;
2017-05-26 05:24:38 +02:00
2017-06-05 11:49:19 +02:00
default :
break ;
2017-05-26 05:24:38 +02:00
}
fatal ( " Parameter must be a number or a stack. " ) ;
return BR_ERROR ;
}
builtIn ( getCharacterScale ) {
UNUSEDALL
int objectNumber ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objectNumber , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2018-04-15 21:10:02 +02:00
OnScreenPerson * pers = g_sludge - > _peopleMan - > findPerson ( objectNumber ) ;
2017-05-26 05:24:38 +02:00
if ( pers ) {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , pers - > scale * 100 ) ;
2017-05-26 05:24:38 +02:00
} else {
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
}
return BR_CONTINUE ;
}
builtIn ( getLanguageID ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > getLanguageID ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
// Removed function
builtIn ( _rem_launchWith ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-08-21 09:07:19 +02:00
// To support some windows only games
2018-05-31 20:09:36 +02:00
Common : : String filename = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
2017-08-21 09:07:19 +02:00
if ( filename . hasSuffix ( " .exe " ) ) {
const Common : : FSNode gameDataDir ( ConfMan . get ( " path " ) ) ;
Common : : FSList files ;
gameDataDir . getChildren ( files , Common : : FSNode : : kListFilesOnly ) ;
for ( Common : : FSList : : const_iterator file = files . begin ( ) ; file ! = files . end ( ) ; + + file ) {
Common : : String fileName = file - > getName ( ) ;
fileName . toLowercase ( ) ;
if ( fileName . hasSuffix ( " .dat " ) | | fileName = = " data " ) {
g_sludge - > launchNext = file - > getName ( ) ;
return BR_CONTINUE ;
}
}
}
2017-05-26 05:24:38 +02:00
2017-08-21 09:07:19 +02:00
g_sludge - > launchNext . clear ( ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , false ) ;
2017-08-21 09:07:19 +02:00
return BR_CONTINUE ;
2017-05-26 05:24:38 +02:00
}
builtIn ( getFramesPerSecond ) {
UNUSEDALL
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , g_sludge - > _timer . getLastFps ( ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( showThumbnail ) {
UNUSEDALL
int x , y ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( y , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( x , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
// Encode the name!Encode the name!
2018-05-31 20:09:36 +02:00
Common : : String aaaaa = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-07-11 14:57:31 +02:00
trimStack ( fun - > stack ) ;
Common : : String file = encodeFilename ( aaaaa ) ;
2017-08-08 13:36:30 +02:00
g_sludge - > _gfxMan - > showThumbnail ( file , x , y ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setThumbnailSize ) {
UNUSEDALL
2018-04-27 14:15:09 +02:00
int thumbHeight , thumbWidth ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( thumbHeight , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( thumbWidth , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-04-27 14:15:09 +02:00
if ( ! g_sludge - > _gfxMan - > setThumbnailSize ( thumbWidth , thumbHeight ) ) {
2017-07-15 14:18:17 +02:00
Common : : String buff = Common : : String : : format ( " %i x %i " , thumbWidth , thumbWidth ) ;
2017-05-26 05:24:38 +02:00
fatal ( " Invalid thumbnail size " , buff ) ;
return BR_ERROR ;
}
return BR_CONTINUE ;
}
builtIn ( hasFlag ) {
UNUSEDALL
int objNum , flagIndex ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( flagIndex , SVT_INT ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 22:21:30 +02:00
if ( ! fun - > stack - > thisVar . getValueType ( objNum , SVT_OBJTYPE ) )
2017-06-05 11:49:19 +02:00
return BR_ERROR ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-07-18 19:50:45 +02:00
ObjectType * objT = g_sludge - > _objMan - > findObjectType ( objNum ) ;
2017-06-05 11:49:19 +02:00
if ( ! objT )
return BR_ERROR ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , objT - > flags & ( 1 < < flagIndex ) ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( snapshotGrab ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
return g_sludge - > _gfxMan - > snapshot ( ) ? BR_CONTINUE : BR_ERROR ;
2017-05-26 05:24:38 +02:00
}
builtIn ( snapshotClear ) {
UNUSEDALL
2017-07-20 00:41:13 +02:00
g_sludge - > _gfxMan - > nosnapshot ( ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( bodgeFilenames ) {
UNUSEDALL
bool lastValue = allowAnyFilename ;
2018-05-31 22:21:30 +02:00
allowAnyFilename = fun - > stack - > thisVar . getBoolean ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , lastValue ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
// Deprecated - does nothing.
builtIn ( _rem_registryGetString ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( quitWithFatalError ) {
UNUSEDALL
2018-05-31 20:09:36 +02:00
Common : : String mess = fun - > stack - > thisVar . getTextFromAnyVar ( ) ;
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
fatal ( mess ) ;
return BR_ERROR ;
}
builtIn ( _rem_setCharacterAA ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( _rem_setMaximumAA ) {
UNUSEDALL
2017-05-27 20:16:54 +02:00
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
trimStack ( fun - > stack ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( setBackgroundEffect ) {
UNUSEDALL
bool done = blur_createSettings ( numParams , fun - > stack ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , done ? 1 : 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
builtIn ( doBackgroundEffect ) {
UNUSEDALL
bool done = blurScreen ( ) ;
2018-05-31 18:51:42 +02:00
fun - > reg . setVariable ( SVT_INT , done ? 1 : 0 ) ;
2017-05-26 05:24:38 +02:00
return BR_CONTINUE ;
}
# pragma mark -
# pragma mark Other functions
//-------------------------------------
2017-07-12 10:43:09 +02:00
} // End of namespace Sludge
2017-05-26 05:24:38 +02:00
2017-07-13 18:08:30 +02:00
# include "functionlist.h"
2017-05-26 05:24:38 +02:00
2017-07-12 10:43:09 +02:00
namespace Sludge {
2017-05-26 05:24:38 +02:00
2017-07-20 10:39:24 +02:00
BuiltReturn callBuiltIn ( int whichFunc , int numParams , LoadedFunction * fun ) {
2017-05-26 05:24:38 +02:00
if ( numBIFNames ) {
2017-06-05 11:49:19 +02:00
setFatalInfo ( ( fun - > originalNumber < numUserFunc ) ? allUserFunc [ fun - > originalNumber ] : " Unknown user function " ,
( whichFunc < numBIFNames ) ? allBIFNames [ whichFunc ] : " Unknown built-in function " ) ;
2017-05-26 05:24:38 +02:00
}
if ( whichFunc < NUM_FUNCS ) {
2018-05-27 20:55:57 +02:00
if ( builtInFunctionArray [ whichFunc ] . paramNum ! = - 1 ) {
if ( builtInFunctionArray [ whichFunc ] . paramNum ! = numParams ) {
Common : : String buff = Common : : String : : format ( " Built in function must have %i parameter%s " , builtInFunctionArray [ whichFunc ] . paramNum , ( builtInFunctionArray [ whichFunc ] . paramNum = = 1 ) ? " " : " s " ) ;
2017-07-11 14:57:31 +02:00
Common : : String msg = buff ;
fatal ( msg ) ;
2017-05-26 05:24:38 +02:00
return BR_ERROR ;
}
}
if ( builtInFunctionArray [ whichFunc ] . func ) {
2017-08-21 09:07:19 +02:00
debugC ( 3 , kSludgeDebugBuiltin ,
" Run built-in function %i : %s " ,
whichFunc , ( whichFunc < numBIFNames ) ? allBIFNames [ whichFunc ] . c_str ( ) : " Unknown " ) ;
2017-05-26 05:24:38 +02:00
return builtInFunctionArray [ whichFunc ] . func ( numParams , fun ) ;
}
}
fatal ( " Unknown / unimplemented built-in function. " ) ;
return BR_ERROR ;
}
2017-05-26 21:25:11 +02:00
} // End of namespace Sludge