Exemple #1
0
void freeLevelResources()
{
	/* Free the entities */

	freeEntities();

	/* Free the decorations */

	freeDecorations();

	/* Free the animations */

	freeAnimations();

	/* Free the sounds */

	freeSounds();

	if (game.overrideMusic == FALSE)
	{
		/* Free music */

		freeMusic();
	}

	/* Free the map data */

	freeMap();

	/* Free the sprites */

	freeSprites();

	/* Free the triggers */

	freeTriggers();

	/* Free the properties */

	freeProperties();

	/* Free the targets */

	freeTargets();

	/* Free the message queue */

	freeMessageQueue();

	/* Free the scripts */

	freeScript();
}
Exemple #2
0
int main(int argc, char *const argv[])
{
	puts("");
	argF = 0;				// -f argument: file - use file as a makefile
	argK = 0;				// -k argument: keep going - Continue as much as possible after error
	argN = 0;				// -n argument: Just print - print the commands that would be executed, don't execute
	argQ = 0;				// -q argument: question - don't run commands
	hasChanged = 0;
	bool hasTarget = 0;		// whether or not a target is specified from command line	

	char *makeFile;			// filename for the makefile being used.
	char *target;			// target to be used

	FILE *myFile;			// file to be used for reading

	int c;					// used for getopt loop

	while((c = getopt(argc, argv, "f:knq")) != -1)			// Collect command arguments
	{
		if(c == 'k') argK = 1;								// set K
		
		if(c == 'f' && argF == 0)							// set F (only if it has not been set before)
		{
			argF = 1;				
			makeFile = (char*)calloc(1, strlen(optarg) + 1);	// extract filename
			strcpy(makeFile, optarg);
		}

		if(c == 'n') argN = 1;								// set N
		if(c == 'q') argQ = 1;								// set Q

	}
	
	if(!argF)
	{
		struct stat fileBuf;
	
		if(stat("GNUmakefile", &fileBuf) == 0)
			makeFile = "GNUmakefile";
		else if(stat("makefile", &fileBuf) == 0)
			makeFile = "makefile";
		else if(stat("Makefile", &fileBuf) == 0)
			makeFile = "Makefile";
		else
		{
			printf("Could not find a default makefile.  Program terminating...\n");
			exit(0);
		}
	}
												

	if(argc > optind)										// if there are still arguments after the command options,
	{														// extract the target command from the argument list
		hasTarget = 1;									
		target = calloc(1, strlen(argv[optind]) + 1);
		strcpy(target, argv[optind]);
		originalTarget = target;
	}
	
	myFile = fopen(makeFile, "r");
	
	char line[MACROSIZE];
	char *makeString[MACROSIZE];
	int counter = 0;

	if( myFile != NULL)
	{

		while(fgets (line, sizeof line, myFile) != NULL)
		{
			makeString[counter] = calloc(1, strlen(line) + 1);
			strcpy(makeString[counter], line);
//			puts(makeString[counter]);
			counter ++;
		}
		
		fclose(myFile);
	}
	


	macI *firstMacro = calloc(1, sizeof(macI));
	firstMacro = createList(firstMacro, makeString, counter);

	for(int i = 0; i < counter; i++)
	{
		char *temp = subMacros(makeString[i], firstMacro);
		makeString[i] = realloc(makeString[i], strlen(temp) + 1);
		strcpy(makeString[i], temp);
		RemoveNewLines(makeString[i]);
		makeString[i] = RemoveStartSpaces(makeString[i]);

	}




	
	tItem *firstTarget = calloc(1, sizeof(tItem));
	firstTarget = insertTarget(firstTarget, FIRSTTARGET);
	

	switch(evaluateTarget(makeString, target, counter, hasTarget, firstTarget))
	{
		case 3:
//			puts("1");
			return 1;
			break;
		case 4:
//			puts("0");
			return 0;
			break;
		default:
			break;
	}
	

// ****************************************** FREE MEMORY *************************************
// ****************************************** FREE MEMORY *************************************
// ****************************************** FREE MEMORY *************************************

	if(hasChanged == 0) printf("mymake: `%s' is up to date.\n", originalTarget);

	if(argF) free(makeFile);


	if(hasTarget) free(target);


	for(int i = 0; i < counter; i ++)
		free(makeString[counter]);

	
	freeTargets(firstTarget);


	freeMacros(firstMacro);


}