⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loader.c

📁 Microwindows genesis was with the NanoGUI project, and is now the primary distribution for both th
💻 C
📖 第 1 页 / 共 3 页
字号:
					"before the first level is defined "					"(see line %d of game file \"%s\")\n",					line, state->gamefile);				goto err;			}			state->height = strtol(buf + 7, &p, 10);			if(*p) goto parseerr;		} else if(!memcmp(buf, "BatHeight ", 10)) {			state->batheight = strtol(buf + 10, &p, 10);			if(*p) goto parseerr;		} else if(!memcmp(buf, "NormalBatWidth ", 15)) {			state->batwidths[NORMALBAT] = strtol(buf + 15, &p, 10);			if(*p) goto parseerr;		} else if(!memcmp(buf, "SmallBatWidth ", 14)) {			state->batwidths[SMALLBAT] = strtol(buf + 14, &p, 10);			if(*p) goto parseerr;		} else if(!memcmp(buf, "LargeBatWidth ", 14)) {			state->batwidths[LARGEBAT] = strtol(buf + 14, &p, 10);			if(*p) goto parseerr;		} else if(!memcmp(buf, "NormalBat ", 10)) {			if(state->bats[NORMALBAT]) {				redefinewarning("NormalBat", line,						state->gamefile);				destroy_sprite(state, state->bats[NORMALBAT]);			}			if(!(state->bats[NORMALBAT] = load_sprite(state,					buf + 10, state->batwidths[NORMALBAT],					state->batheight))) {				if(!(state->bats[NORMALBAT] =					make_empty_sprite(state, buf + 10,						state->batwidths[NORMALBAT],						state->batheight))) {					fprintf(stderr, "Couldn't create "							"normal bat sprite on "							"line %d of game file "							"\"%s\"\n", line,							state->gamefile);					goto err;				}				GrSetGCForeground(state->gc, GR_COLOR_RED);				GrFillRect(state->bats[NORMALBAT]->p,						state->gc, 0, 0,						state->batwidths[NORMALBAT],						state->batheight);				GrSetGCForeground(state->gc, GR_COLOR_WHITE);				GrFillRect(state->bats[NORMALBAT]->a,						state->gc, 0, 0,						state->batwidths[NORMALBAT],						state->batheight);			}		} else if(!memcmp(buf, "SmallBat ", 9)) {			if(state->bats[SMALLBAT]) {				redefinewarning("SmallBat", line,						state->gamefile);				destroy_sprite(state, state->bats[SMALLBAT]);			}			if(!(state->bats[SMALLBAT] = load_sprite(state,					buf + 9, state->batwidths[SMALLBAT],					state->batheight))) {				if(!(state->bats[SMALLBAT] =					make_empty_sprite(state, buf + 9,						state->batwidths[SMALLBAT],						state->batheight))) {					fprintf(stderr, "Couldn't create "							"small bat sprite on "							"line %d of game file "							"\"%s\"\n", line,							state->gamefile);					goto err;				}				GrSetGCForeground(state->gc, GR_COLOR_RED);				GrFillRect(state->bats[SMALLBAT]->p,						state->gc, 0, 0,						state->batwidths[SMALLBAT],						state->batheight);				GrSetGCForeground(state->gc, GR_COLOR_WHITE);				GrFillRect(state->bats[SMALLBAT]->a,						state->gc, 0, 0,						state->batwidths[SMALLBAT],						state->batheight);			}		} else if(!memcmp(buf, "LargeBat ", 9)) {			if(state->bats[LARGEBAT]) {				redefinewarning("LargeBat", line,						state->gamefile);				destroy_sprite(state, state->bats[LARGEBAT]);			}			if(!(state->bats[LARGEBAT] = load_sprite(state,					buf + 9, state->batwidths[LARGEBAT],					state->batheight))) {				if(!(state->bats[LARGEBAT] =					make_empty_sprite(state, buf + 9,						state->batwidths[LARGEBAT],						state->batheight))) {					fprintf(stderr, "Couldn't create "							"large bat sprite on "							"line %d of game file "							"\"%s\"\n", line,							state->gamefile);					goto err;				}				GrSetGCForeground(state->gc, GR_COLOR_RED);				GrFillRect(state->bats[LARGEBAT]->p,						state->gc, 0, 0,						state->batwidths[LARGEBAT],						state->batheight);				GrSetGCForeground(state->gc, GR_COLOR_WHITE);				GrFillRect(state->bats[LARGEBAT]->a,						state->gc, 0, 0,						state->batwidths[LARGEBAT],						state->batheight);			}		} else if(!memcmp(buf, "PowerSprite ", 12)) {			/* Parse the PowerSprite line: */			if(parse_powersprite(state, buf + 12, line)) goto err;		} else if(!memcmp(buf, "PowerUpTimeout ", 15)) {			state->poweruptime = strtol(buf + 15, &p, 10);			if(*p) goto parseerr;		} else if(!memcmp(buf, "PowerDownTimeout ", 17)) {			state->powerdowntime = strtol(buf + 17, &p, 10);			if(*p) goto parseerr;		} else if(!memcmp(buf, "FadeRate ", 9)) {			state->faderate = strtol(buf + 9, &p, 10);			if(*p) goto parseerr;			if(state->faderate > 255 || state->faderate < 0) {				fprintf(stderr, "Invalid fade rate on line "					"%d of game file \"%s\"\n", line,					state->gamefile);				goto err;			}		} else if(!memcmp(buf, "SolidFloorCheat ", 16)) {			if(state->cheats[SFCHEAT]) {				redefinewarning("SolidFloorCheat", line,						state->gamefile);				free(state->cheats[SFCHEAT]);			}			if(!(state->cheats[SFCHEAT] = strdup(buf + 16))) {				oom();				goto err;			}			if(strlen(state->cheats[SFCHEAT]) > MAXCHEATLEN) {				fprintf(stderr, "Cheat sequence too long on "						"line %d of game file \"%s\"\n",						line, state->gamefile);				goto err;			}		} else if(!memcmp(buf, "TeleportCheat ", 14)) {			if(state->cheats[TPCHEAT]) {				redefinewarning("TeleportCheat", line,						state->gamefile);				free(state->cheats[TPCHEAT]);			}			if(!(state->cheats[TPCHEAT] = strdup(buf + 14))) {				oom();				goto err;			}			if(strlen(state->cheats[TPCHEAT]) > MAXCHEATLEN) {				fprintf(stderr, "Cheat sequence too long on "						"line %d of game file \"%s\"\n",						line, state->gamefile);				goto err;			}		} else if(!memcmp(buf, "NoBounceCheat ", 14)) {			if(state->cheats[NBCHEAT]) {				redefinewarning("NoBounceCheat", line,						state->gamefile);				free(state->cheats[NBCHEAT]);			}			if(!(state->cheats[NBCHEAT] = strdup(buf + 14))) {				oom();				goto err;			}			if(strlen(state->cheats[NBCHEAT]) > MAXCHEATLEN) {				fprintf(stderr, "Cheat sequence too long on "						"line %d of game file \"%s\"\n",						line, state->gamefile);				goto err;			}		} else if(!memcmp(buf, "NoPowerDownCheat ", 17)) {			if(state->cheats[NPDCHEAT]) {				redefinewarning("NoPowerDownCheat", line,						state->gamefile);				free(state->cheats[NPDCHEAT]);			}			if(!(state->cheats[NPDCHEAT] = strdup(buf + 17))) {				oom();				goto err;			}			if(strlen(state->cheats[NPDCHEAT]) > MAXCHEATLEN) {				fprintf(stderr, "Cheat sequence too long on "						"line %d of game file \"%s\"\n",						line, state->gamefile);				goto err;			}		} else if(!memcmp(buf, "NoPowerUpTimeoutCheat ", 22)) {			if(state->cheats[NPUTOCHEAT]) {				redefinewarning("NoPowerUpTimeoutCheat", line,						state->gamefile);				free(state->cheats[NPUTOCHEAT]);			}			if(!(state->cheats[NPUTOCHEAT] = strdup(buf + 22))) {				oom();				goto err;			}			if(strlen(state->cheats[NPUTOCHEAT]) > MAXCHEATLEN) {				fprintf(stderr, "Cheat sequence too long on "						"line %d of game file \"%s\"\n",						line, state->gamefile);				goto err;			}		} else if(!memcmp(buf, "BeginLevel", 10)) {			/* Check to make sure we haven't got another BeginLevel			 * line while already in a level definition block: */			if(inlevelblock) {				fprintf(stderr, "Error: BeginLevel while "					"already in a level block on line %d "					"of game file \"%s\"\n", line,					state->gamefile);				goto err;			}			inlevelblock = 1;			/* Allocate a new level structure: */			if(!(lev = malloc(sizeof(level)))) {				oom();				goto err;			}			/* Fill in the structure members with some defaults: */			lev->bricks = NULL;			lev->backgroundname = NULL;			lev->backgroundtiled = DEFAULT_BACKGROUND_TILED;			lev->numbricks = 0;			lev->next = NULL;			/* Allocate and initialise the level grid: */			if(!(lev->grid = newgrid(state))) {				oom();				goto err;			}			/* Link the new level structure onto the end of the			 * levels list: */			if(!state->levels) state->levels = lev;			else {				for(l = state->levels; l->next; l = l->next);				l->next = lev;			}		} else if(!memcmp(buf, "LevelBackground ", 16)) {			if(!inlevelblock) {				notinlevblockerr("LevelBackground", line,						state->gamefile);				goto err;			}			if(lev->backgroundname) {				redefinewarning("LevelBackground", line,						state->gamefile);				free(lev->backgroundname);			}			if(!(lev->backgroundname = strdup(buf + 16))) {				oom();				goto err;			}		} else if(!memcmp(buf, "LevelBackgroundTiled ", 21)) {			if(!inlevelblock) {				notinlevblockerr("LevelBackgroundTiled", line,						state->gamefile);				goto err;			}			if(!strcmp(buf + 21, "Yes")) lev->backgroundtiled = 1;			else if(!strcmp(buf + 21, "No"))				lev->backgroundtiled = 0;			else goto parseerr;		} else if(!memcmp(buf, "BeginRows", 9)) {			if(!inlevelblock) {				notinlevblockerr("BeginRows", line,						state->gamefile);				goto err;			}			/* Parse the rows block: */			if(parse_rows(state, lev, fp, &line)) goto err;		} else if(!memcmp(buf, "EndRows", 7)) {			/* We should never see an EndRows here in a valid			 * level file because parse_rows() consumes it. */			fprintf(stderr, "Error: EndRows without corresponding "					"BeginRows on line %d of game file "					"\"%s\"\n", line, state->gamefile);			goto err;		} else if(!memcmp(buf, "BeginPowers", 11)) {			if(!inlevelblock) {				notinlevblockerr("BeginPowers", line,						state->gamefile);				goto err;			}			if(parse_powers(state, lev, fp, &line)) goto err;		} else if(!memcmp(buf, "EndPowers", 9)) {			fprintf(stderr, "Error: EndPowers without "					"corresponding BeginPowers on line %d "					"of game file \"%s\"\n", line,					state->gamefile);			goto err;		} else if(!memcmp(buf, "EndLevel", 8)) {			if(!inlevelblock) {				fprintf(stderr, "Error: EndLevel while not in "					"in a level block on line %d of game "					"file \"%s\"\n", line, state->gamefile);				goto err;			}			inlevelblock = 0;			state->numlevels++;		} else {			fprintf(stderr, "Unknown command \"%s\" on line %d "					"of game file \"%s\"\n", buf,					line, state->gamefile);		}		/* We keep a count of the line we're on so that errors and		 * warnings can print out the number of the bad line: */		line++;	}	/* Check if the reason fgets() failed was because of an I/O error	 * instead of simply reaching the end of the file: */	if(ferror(fp)) {		fprintf(stderr, "Error reading from game file \"%s\" on line "				"%d: %s\n", state->gamefile, line,				strerror(errno));		goto err;	}	/* Allocate and initialise the current game grid: */	if(!(state->grid = newgrid(state))) {		oom();		goto err;	}	fclose(fp); /* Close the game file. */	return 0; /* Success. */parseerr: /* A parse error occured so print an error message: */	fprintf(stderr, "Parse error on line %d of game file \"%s\"\n", line,							state->gamefile);err: /* Some other error occured and we've already printed the error message. */	fclose(fp); /* Close the game file (may fail but we don't care). */	return 1; /* Failure. */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -