Example #1
0
void sortScript()
{
	//this saves dynamic space
	UInt16 i, k, size;
	Err err;
	ScriptType temp[map.numCmds];
	
	//get rid of all map cmds
	for(i = 0; i < map.numCmds; i++)
	{
		if(!cmdIsAI(script[i].type))
		{
			//copy next cmd into this one if there is			
			for(k = i; k < map.numCmds;k++)
			{
				//if there is a cmd left
				if(k != (map.numCmds - 1))
				{
					//if it still isn't ai then continue
					if(!cmdIsAI(script[k + 1].type))
					{
						continue;
					}
					else
					{
						//copy it into new, discard old
						MemMove(&temp[i], &script[k + 1], sizeof(ScriptType));						
						size++;
						//get out of loop
						break;
					}	
				}
			}
		}	
		//leave it if it is an ai	
	}	
	
	//resize script to value of size
	err = MemHandleResize(scriptH, sizeof(ScriptType) * size);
	if(err == memErrChunkLocked)
	{
		//unlock
		MemHandleUnlock(scriptH);
		if(err = MemHandleResize(scriptH, sizeof(ScriptType) * size))
		{
			ErrFatalDisplay("In sortscript, couldn't resize script");
		}
		script = (ScriptType *)MemHandleLock(scriptH);		 
	}		
	else if(err != 0)
	{
		//some other error
		ErrFatalDisplay("In sortscript, couldn't resize script");	
	}	
	
	//move all script into new one
	MemMove(script, &temp, sizeof(ScriptType) * size);
}
Example #2
0
void removeAI(UInt8 aiNum)
{
	PlayerStruct playerTemp[game.numPlayersOnScreen - 1];	 	
	UInt16 i;
	Err err;
	
	if(game.numPlayersOnScreen < 1)
	{
		ErrDisplay("In removeAI(), there are no players to remove");
	}		
	
	//move all player data to temp var:
	for(i = 0; i < aiNum; i++)
	{
		//move each player until one to delete appears
		playerTemp[i] = player[i];
	}
	for(i = aiNum + 1; i < game.numPlayersOnScreen; i++)
	{
		//move each player until end
		playerTemp[i - 1] = player[i];		
	}	
	
	//players are in place and top player is useless, can now resize
	game.numPlayersOnScreen--;	
	//resize to the number of players
	err = MemHandleResize(playerH, sizeof(PlayerStruct) * (game.numPlayersOnScreen));
	if(err == memErrChunkLocked)
	{
		//unlock
		MemHandleUnlock(playerH);
		if(err = MemHandleResize(playerH, sizeof(PlayerStruct) * game.numPlayersOnScreen))
		{	
			ErrFatalDisplay("In removeAI, couldn't resize player stack");
		}
		player = (PlayerStruct *)MemHandleLock(playerH);		 
	}		
	else if(err != errNone)
	{
		//some other error
		ErrFatalDisplay("In removeAI, couldn't resize player stack");	
	} 
	//copy orginal back to stack
	MemMove(player, (PlayerStruct *)&playerTemp, sizeof(PlayerStruct) * game.numPlayersOnScreen);	
}
Example #3
0
Err IntlSetRoutineAddress(IntlSelector iSelector, void* iProcPtr)
{
#if (EMULATION_LEVEL == EMULATION_NONE)
	void** tablePtr;
	Int16 i;
	
	if (iSelector > intlMaxSelector)
	{
		return(intlErrInvalidSelector);
	}
	
	ErrNonFatalDisplayIf(iProcPtr == NULL, "Null proc ptr parameter");
	
	tablePtr = (void**)GIntlDispatchTableP;
	if (tablePtr == NULL)
	{
		tablePtr = (void**)MemPtrNew((intlMaxSelector + 1) * sizeof(Int32*));
		if (tablePtr == NULL)
		{
			return(memErrNotEnoughSpace);
		}
		
		// Make sure it doesn't get tossed when the current app quits.
		MemPtrSetOwner(tablePtr, 0);
		
		// Initialize the table with all of the default routine addresses.
		for (i = 0; i <= intlMaxSelector; i++)
		{
			tablePtr[i] = IntlGetRoutineAddress(i);
		}
		
		// Set up the low-memory global with our new, valid table.
		GIntlDispatchTableP = tablePtr;
	}
	
	tablePtr[iSelector] = iProcPtr;
	return(errNone);
#else	// EMULATION_LEVEL != EMULATION_NONE
	ErrFatalDisplay("Can't call IntlSetRoutineAddress in Simulator");
	return(errNone);
#endif
} // IntlSetRoutineAddress
Example #4
0
/* This routine handles the loading of forms */
static void HandleFormLoad
    (
    EventType* event
    )
{
    FormType*  form;
    UInt16     formID;

    formID  = event->data.frmLoad.formID;
    form    = FrmInitForm( formID );
    FrmSetActiveForm( form );

    switch( formID ) {
        case frmMain:
            FrmSetEventHandler( form, FormHandleEvent );
            break;

        default:
            ErrFatalDisplay( "Unknown form ID" );
            break;
    }
}
Example #5
0
void std::__msl_error(const char* str)
{
    ErrFatalDisplay(str);
    ErrThrow(sysErrParamErr);
}