changeset 261:7f08145f4cc1

Added mode changing option for ship/walk map blocks.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 03 Jun 2007 23:00:02 +0000
parents 06e2640e3659
children c0430dc547b5
files mkspecial.c
diffstat 1 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mkspecial.c	Sun Jun 03 18:59:59 2007 +0000
+++ b/mkspecial.c	Sun Jun 03 23:00:02 2007 +0000
@@ -27,7 +27,8 @@
 	optReset = 50;
 BOOL	optHardDrop = FALSE,
 	optDumpRejected = FALSE,
-	optAdjustBlocks = FALSE;
+	optAdjustBlocks = FALSE,
+	optWalkMode = FALSE;
 float	optMatch = 40.0;
 char	*optInitialMap = NULL;
 
@@ -48,6 +49,7 @@
 	{ 15,'y', "initial-y",	"Initial map Y offset", 1 },
 	{ 16,'D', "dump",	"Dump rejected pieces", 0 },
 	{ 17,'a', "adjust-size","Adjust to variable size blocks", 0 },
+	{ 18,'W', "walk-mode",	"Walk mode (instead of ship mode)", 0 },
 };
 
 const int optListN = (sizeof(optList) / sizeof(optarg_t));
@@ -126,6 +128,11 @@
 		optAdjustBlocks = TRUE;
 		break;
 
+	case 18:
+		THMSG(1, "Walk mode enabled.\n");
+		optWalkMode = TRUE;
+		break;
+
 	default:
 		THERR("Unknown option '%s'.\n", currArg);
 		return FALSE;
@@ -249,16 +256,14 @@
 	for (tmpW = 0; tmpW < sizeof(s) && s[tmpW] && s[tmpW] != '\r' && s[tmpW] != '\n'; tmpW++);
 	s[tmpW] = 0;
 	
-	switch (tmpW) {
-	case 25: tmpH = 17; break;
-	case 29: tmpH = 21; break;
-	case 31: tmpH = 23; break;
-	case 33: tmpH = 25; break;
-	default:
-		THERR("Invalid block width %d [%d, %d], rejecting.\n", tmpW, x, y);
-		return NULL;
-		break;
-	}
+	if (optWalkMode) {
+		if (tmpW != 31) {
+			THERR("Invalid block width %d [%d, %d], rejecting.\n", tmpW, x, y);
+			return NULL;
+		}
+		tmpH = 17;
+	} else
+		tmpH = tmpW - 8;
 	
 	if ((tmp = allocBlock(tmpW, tmpH)) == NULL) {
 		THERR("Could not allocate mapblock (%d, %d)\n", tmpW, tmpH);
@@ -354,6 +359,13 @@
 	 */
 	for (nmapBlocks = i = 0; i < nsrcFiles; i++) {
 		FILE *tmpFile;
+		char centerCh;
+		
+		if (optWalkMode)
+			centerCh = '@';
+		else
+			centerCh = '*';
+		
 		
 		if ((tmpFile = fopen(srcFiles[i], "rb")) == NULL) {
 			THERR("Error opening input file '%s'!\n",
@@ -364,7 +376,7 @@
 		while (!feof(tmpFile)) {
 			mapblock_t *tmp;
 			if ((tmp = parseBlock(tmpFile)) != NULL) {
-				if (optAdjustBlocks && !adjustBlockCenter(tmp, '*')) {
+				if (optAdjustBlocks && !adjustBlockCenter(tmp, centerCh)) {
 					THERR("Block center not found, rejected.\n");
 					freeBlock(tmp);
 				} else {