This is a patch file for "battalion" release 2004c. It's not compati- ble with older releases. Partial list of changes: a. Enable OpenAL audio b. Modify program to work with local version of OpenAL c. Build an optimized version instead of a "debug" version d. Load sound files and other resources using absolute paths e. Disable music f. Reduce volume used for close-up sounds g. Increase limits on numbers of objects h. Modify one slightly confusing message i. December 18 through 26 are now treated as "Christmas" j. Omit some diagnostic messages k. Save high-score file in a per-user directory l. Space key can now be used to fire weapons m. PgDn and PgUp keys are now used to zoom in and zoom out n. Upper and lower case "Q" now quits the game o. Some changes related to frame rates have been made p. The monsters move faster now Requirement: This file assumes that the "battalion" sources were un- packed as follows: unzip -aq battalion2004c.zip If "unzip -aq" isn't used, "patch" operations that apply this file may fail. Explanation: Some of the "battalion" source files are stored in MS-DOS format. This file assumes that the files have been converted to UNIX format. "unzip -aq" converts text files to the correct format auto- matically (normally, binary files aren't affected). --- battalion2004.old/Makefile +++ battalion2004/Makefile @@ -81,17 +81,17 @@ #AUDIODEF = -DSGIAUDIO -# STEP 6: IF YOU ARE COMPILING FOR A SUN AND WANT (RUDIMENTARY) +# STEP 6: IF YOU ARE COMPILING FOR A SUN OR LINUX AND WANT (RUDIMENTARY) # AUDIO THEN UNCOMMENT THE NEXT LINES, ELSE COMMENT THEM OUT # # ------------------------------------------------------------ -AUDIOLIB = -lopenal -AUDIODEF = -I/usr/include/AL -DSOUND +AUDIOLIB = -lopenal -lalut +AUDIODEF = -I/usr/local/include/AL -I/usr/include/AL -DSOUND # STEP 7: CHOOSE ANY OPTIMIZATIONS OR ADD ANY SPECIAL INCLUSIONS # ------------------------------------------------------------ -CFLAGS = -g -I/usr/include/AL -I/usr/local/X11/include -I. $(AUDIODEF) +CFLAGS = -O2 -I/usr/local/X11/include -I. $(AUDIODEF) # STEP 8: ADD ANY SPECIAL LIBRARY PATHS --- battalion2004.old/audio.c +++ battalion2004/audio.c @@ -64,6 +64,7 @@ /****************************************************************/ int initSound() { + ALfloat x_freq; ALsizei size,freq; ALenum format; ALvoid *data; @@ -84,62 +85,67 @@ } /* load of samples in wav format*/ - alutLoadWAVFile("battalion.data/sounds/beam.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/beam.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[0],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/boom.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/boom.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[1],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/crash.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/crash.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[2],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/monsterbeam.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/monsterbeam.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[3],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/rocket.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/rocket.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[4],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/slag.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/slag.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[5],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/tank.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/tank.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[6],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/tech.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/tech.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[7],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/electrical.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/electrical.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[8],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/sounds/teleporter.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/sounds/teleporter.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[9],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - - alutLoadWAVFile("battalion.data/music/mbatt1.wav",&format,&data,&size,&freq, &al_bool); + +#ifdef NOTDEF + alutLoadWAVFile("__META_PREFIX__/share/music/mbatt1.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[10],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/music/mbatt2.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/music/mbatt2.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[11],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - - alutLoadWAVFile("battalion.data/music/mbatt3.wav",&format,&data,&size,&freq, &al_bool); +#else + buffers [10] = alutCreateBufferFromFile ("/notused.wav"); + buffers [11] = alutCreateBufferFromFile ("/notused.wav"); +#endif + + alutLoadWAVFile("__META_PREFIX__/share/music/mbatt3.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[12],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - alutLoadWAVFile("battalion.data/music/mbatt4.wav",&format,&data,&size,&freq, &al_bool); + alutLoadWAVFile("__META_PREFIX__/share/music/mbatt4.wav",&format,&data,&size,&freq, &al_bool); alBufferData(buffers[13],format,data,size,freq); alutUnloadWAV(format,data,size,freq); - + alGetError(); /* Source generation */ @@ -270,9 +276,17 @@ ALfloat position[3]; if(soundOn != 0 && maxSources > 0) { + int xs = (x < 0.0) ? -1 : 1; + int ys = (y < 0.0) ? -1 : 1; + int zs = (z < 0.0) ? -1 : 1; + position[0] = x; position[1] = y; position[2] = z; + // Reduce volume a little + if (fabs (x) < 60.0) x = xs * 60.0; + if (fabs (y) < 60.0) y = ys * 60.0; + if (fabs (z) < 60.0) z = zs * 60.0; alGetError(); alSourceStop(nsource); --- battalion2004.old/battalion.h +++ battalion2004/battalion.h @@ -317,9 +317,9 @@ /*limits */ /**********************/ -#define MAXTREESONPLANE 800 -#define MAXFIRESONPLANE 150 -#define MAXTANKSONPLANE 200 +#define MAXTREESONPLANE 1000 +#define MAXFIRESONPLANE 750 +#define MAXTANKSONPLANE 500 #define ARENASIZE 100000 --- battalion2004.old/language.h +++ battalion2004/language.h @@ -169,7 +169,7 @@ static char str_flutterdest[] = "Flutter destroyed"; static char str_billydest[] = "Billy destroyed"; -static char str_nothing[] = "...nothing"; +static char str_nothing[] = "no army targets"; static char str_monstersdestroyed[] = "Monsters destroyed"; #endif --- battalion2004.old/main.c +++ battalion2004/main.c @@ -1247,16 +1247,21 @@ today = time(NULL); theTime = localtime(&today); - /*************************************/ - /* if its xmas use the xmas graphics */ - /*************************************/ + /*******************************************/ + /* if it's near xmas use the xmas graphics */ + /*******************************************/ - if ((theTime->tm_mday == 25) && (theTime->tm_mon == 11)) - itsChristmas = 1; + i = theTime->tm_mday; + + if ((theTime->tm_mon == 11) && ((i >= 18) && (i <= 26))) + { + itsChristmas = 1; + } else - itsChristmas = 0; + { + itsChristmas = 0; + } - /**************************************/ /* initialize random number generator */ /**************************************/ @@ -1292,7 +1297,12 @@ roadFile = fopen(fullPath, "rb"); #else +#ifdef NOTDEF dataPtr = getenv("BATTALIONDATADIR"); +#else + dataPtr = "__META_PREFIX__/share"; +#endif + if (dataPtr != NULL) { strcpy(dataPath, dataPtr); @@ -1341,7 +1351,6 @@ strcpy(fullPath, dataPath); strcat(fullPath, "data/battalion.levels"); - levelsFile = fopen(fullPath, "r"); if (levelsFile == NULL) @@ -1359,7 +1368,7 @@ } else { - printf("Niveles: %u\n",maxLevels); +// printf("Niveles: %u\n",maxLevels); levelNames = (char**)malloc(sizeof(char*)*maxLevels); for(i = 0; i 45) mapHeight = 45; + break; } } else @@ -5830,6 +5846,9 @@ #endif break; +//-------------------------------------------------------------------- + +#ifdef NOTDEF // Not presently used case 'd': case 'D': if (now_time - timeDetail >=1000) @@ -5852,8 +5871,6 @@ } break; - - case 'g': case 'G': /* @@ -5864,7 +5881,6 @@ pointerGrab = !pointerGrab; */ break; - case 'q': case 'Q': if (mapHeight > 1) @@ -5876,16 +5892,25 @@ if (mapHeight < 45) mapHeight += 1; break; +#endif // Endif NOTDEF + +//-------------------------------------------------------------------- //ESCAPE - case 27: + case 27: + case 'q': + case 'Q': goto1d(); clearAll(); + updateScores (scorefullPath, Googelon.monster, + Googelon.monsterScore, mode, playerName); + #ifdef SOUND exitSound(); alutExit(); #endif + exit(0); } } @@ -5943,6 +5968,7 @@ case 'Z': keycontrol |= KEY_DOWN; break; + case ' ': case 'x': case 'X': keycontrol |= KEY_FIRE; @@ -5976,9 +6002,6 @@ struct tank * ttank; struct targetInfo * temptarget; - - - /*limit the fps to 25 aprox*/ #ifdef WIN32 /* Windows code milliseconds since program starts*/ now_time = GetTickCount(); @@ -5986,15 +6009,11 @@ /* linux code milliseconds since reference date*/ ftime(&tb); now_time = tb.millitm+1000*tb.time; - - #endif - - /* near 25 fps if possible */ - if(now_time-last_time > 40) + /* limit FPS to approx. 12 if possible */ + if(now_time-last_time > 80) { - /* after last building destroyed only projectiles are updated */ if(levelEndCount > 0) { @@ -6035,26 +6054,26 @@ /***************************************************/ if(keycontrol & KEY_LEFT) - { - offsetX = -0.8; + { + offsetX = -2; Googelon.headHorzRotate -= (int) (offsetX * Googelon.xspeed); Googelon.monsterMoving = 1; } if(keycontrol & KEY_RIGHT) { - offsetX = 0.8; + offsetX = 2; Googelon.headHorzRotate -= (int) (offsetX * Googelon.xspeed); Googelon.monsterMoving = 1; } - + if(keycontrol & KEY_FORW) - Googelon.monsterGo = 1; + Googelon.monsterGo = 11; else Googelon.monsterGo = 0; if(keycontrol & KEY_BACK) - Googelon.monsterBack = 1; + Googelon.monsterBack = 11; else Googelon.monsterBack = 0; @@ -6273,11 +6292,7 @@ #endif } - /***************************************************/ - /* limit the game to about 24fps for fast machines */ - /***************************************************/ last_time = now_time; - } } @@ -6321,8 +6336,8 @@ if(screen == 0) { glutInitWindowPosition (100,100); - glutInitWindowSize (640,480); - glutCreateWindow ("Battalion-2004"); + glutInitWindowSize (640, 480); + glutCreateWindow ("Battalion"); }