BMREAD.C 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/bmread.c $
  15. * $Revision: 2.4 $
  16. * $Author: john $
  17. * $Date: 1995/03/28 18:05:29 $
  18. *
  19. * Routines to parse bitmaps.tbl
  20. *
  21. * $Log: bmread.c $
  22. * Revision 2.4 1995/03/28 18:05:29 john
  23. * Fixed it so you don't have to delete pig after changing bitmaps.tbl
  24. *
  25. * Revision 2.3 1995/03/07 16:52:03 john
  26. * Fixed robots not moving without edtiro bug.
  27. *
  28. * Revision 2.2 1995/03/06 16:10:20 mike
  29. * Fix compile errors if building without editor.
  30. *
  31. * Revision 2.1 1995/03/02 14:55:40 john
  32. * Fixed bug with EDITOR never defined.
  33. *
  34. * Revision 2.0 1995/02/27 11:33:10 john
  35. * New version 2.0, which has no anonymous unions, builds with
  36. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  37. *
  38. * Revision 1.1 1995/02/25 14:02:36 john
  39. * Initial revision
  40. *
  41. *
  42. */
  43. #pragma off (unreferenced)
  44. static char rcsid[] = "$Id: bmread.c 2.4 1995/03/28 18:05:29 john Exp $";
  45. #pragma on (unreferenced)
  46. #include "settings.h"
  47. #ifdef EDITOR
  48. #include <stdio.h>
  49. #include <stdlib.h>
  50. #include <stdarg.h>
  51. #include <conio.h>
  52. #include <string.h>
  53. #include <io.h>
  54. #include "types.h"
  55. #include "inferno.h"
  56. #include "gr.h"
  57. #include "bm.h"
  58. #include "mem.h"
  59. #include "cflib.h"
  60. #include "mono.h"
  61. #include "error.h"
  62. #include "object.h"
  63. #include "vclip.h"
  64. #include "effects.h"
  65. #include "polyobj.h"
  66. #include "wall.h"
  67. #include "textures.h"
  68. #include "game.h"
  69. #include "multi.h"
  70. #include "iff.h"
  71. #include "cfile.h"
  72. #include "hostage.h"
  73. #include "powerup.h"
  74. #include "laser.h"
  75. #include "sounds.h"
  76. #include "piggy.h"
  77. #include "aistruct.h"
  78. #include "robot.h"
  79. #include "weapon.h"
  80. #include "gauges.h"
  81. #include "player.h"
  82. #include "fuelcen.h"
  83. #include "endlevel.h"
  84. #include "cntrlcen.h"
  85. #include "compbit.h"
  86. #include "args.h"
  87. #include "editor\texpage.h"
  88. #define BM_NONE -1
  89. #define BM_COCKPIT 0
  90. #define BM_TEXTURES 2
  91. #define BM_UNUSED 3
  92. #define BM_VCLIP 4
  93. #define BM_EFFECTS 5
  94. #define BM_ECLIP 6
  95. #define BM_WEAPON 7
  96. #define BM_DEMO 8
  97. #define BM_ROBOTEX 9
  98. #define BM_WALL_ANIMS 12
  99. #define BM_WCLIP 13
  100. #define BM_ROBOT 14
  101. #define BM_GAUGES 20
  102. #define MAX_BITMAPS_PER_BRUSH 30
  103. extern player_ship only_player_ship; // In bm.c
  104. static short N_ObjBitmaps=0;
  105. static short N_ObjBitmapPtrs=0;
  106. static int Num_robot_ais = 0;
  107. int TmapList[MAX_TEXTURES];
  108. char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH];
  109. char Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH];
  110. //---------------- Internal variables ---------------------------
  111. static int Registered_only = 0; // Gets set by ! in column 1.
  112. static int SuperX = -1;
  113. static int Installed=0;
  114. static char *arg;
  115. static short tmap_count = 0;
  116. static short texture_count = 0;
  117. static short clip_count = 0;
  118. static short clip_num;
  119. static short sound_num;
  120. static short frames;
  121. static float time;
  122. static int hit_sound = -1;
  123. static byte bm_flag = BM_NONE;
  124. static int abm_flag = 0;
  125. static int rod_flag = 0;
  126. static short wall_open_sound, wall_close_sound,wall_explodes,wall_blastable, wall_hidden;
  127. float vlighting=0;
  128. static int obj_eclip;
  129. static char *dest_bm; //clip number to play when destroyed
  130. static int dest_vclip; //what vclip to play when exploding
  131. static int dest_eclip; //what eclip to play when exploding
  132. static fix dest_size; //3d size of explosion
  133. static int crit_clip; //clip number to play when destroyed
  134. static int crit_flag; //flag if this is a destroyed eclip
  135. static int tmap1_flag; //flag if this is used as tmap_num (not tmap_num2)
  136. static int num_sounds=0;
  137. //------------------- Useful macros and variables ---------------
  138. #define REMOVE_EOL(s) remove_char((s),'\n')
  139. #define REMOVE_COMMENTS(s) remove_char((s),';')
  140. #define REMOVE_DOTS(s) remove_char((s),'.')
  141. #define IFTOK(str) if (!strcmp(arg, str))
  142. char *space = { " \t" };
  143. //--unused-- char *equal = { "=" };
  144. char *equal_space = { " \t=" };
  145. void remove_char( char * s, char c )
  146. {
  147. char *p;
  148. p = strchr(s,c);
  149. if (p) *p = '\0';
  150. }
  151. //---------------------------------------------------------------
  152. int compute_average_pixel(grs_bitmap *new)
  153. {
  154. int row, column, color;
  155. char *pptr;
  156. int total_red, total_green, total_blue;
  157. pptr = new->bm_data;
  158. total_red = 0;
  159. total_green = 0;
  160. total_blue = 0;
  161. for (row=0; row<new->bm_h; row++)
  162. for (column=0; column<new->bm_w; column++) {
  163. color = *pptr++;
  164. total_red += gr_palette[color*3];
  165. total_green += gr_palette[color*3+1];
  166. total_blue += gr_palette[color*3+2];
  167. }
  168. total_red /= (new->bm_h * new->bm_w);
  169. total_green /= (new->bm_h * new->bm_w);
  170. total_blue /= (new->bm_h * new->bm_w);
  171. return BM_XRGB(total_red/2, total_green/2, total_blue/2);
  172. }
  173. //---------------------------------------------------------------
  174. // Loads a bitmap from either the piggy file, a r64 file, or a
  175. // whatever extension is passed.
  176. bitmap_index bm_load_sub( char * filename )
  177. {
  178. bitmap_index bitmap_num;
  179. grs_bitmap * new;
  180. ubyte newpal[256*3];
  181. int iff_error; //reference parm to avoid warning message
  182. char fname[20];
  183. bitmap_num.index = 0;
  184. #ifdef SHAREWARE
  185. if (Registered_only) {
  186. //mprintf( 0, "Skipping registered-only bitmap '%s'\n", filename );
  187. return bitmap_num;
  188. }
  189. #endif
  190. _splitpath( filename, NULL, NULL, fname, NULL );
  191. bitmap_num=piggy_find_bitmap( fname );
  192. if (bitmap_num.index) {
  193. //mprintf(( 0, "Found bitmap '%s' in pig!\n", fname ));
  194. return bitmap_num;
  195. }
  196. //MALLOC( new, grs_bitmap, 1 );//hack KRB
  197. new = (grs_bitmap *)malloc(1*sizeof(grs_bitmap));
  198. iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
  199. new->bm_selector=0;
  200. if (iff_error != IFF_NO_ERROR) {
  201. mprintf((1, "File %s - IFF error: %s",filename,iff_errormsg(iff_error)));
  202. Error("File %s - IFF error: %s",filename,iff_errormsg(iff_error));
  203. }
  204. if ( iff_has_transparency )
  205. gr_remap_bitmap_good( new, newpal, iff_transparent_color, SuperX );
  206. else
  207. gr_remap_bitmap_good( new, newpal, -1, SuperX );
  208. new->avg_color = compute_average_pixel(new);
  209. mprintf( (0, "N" ));
  210. bitmap_num = piggy_register_bitmap( new, fname, 0 );
  211. free( new );
  212. return bitmap_num;
  213. }
  214. void ab_load( char * filename, bitmap_index bmp[], int *nframes )
  215. {
  216. grs_bitmap * bm[MAX_BITMAPS_PER_BRUSH];
  217. bitmap_index bi;
  218. int i;
  219. int iff_error; //reference parm to avoid warning message
  220. ubyte newpal[768];
  221. char fname[20];
  222. char tempname[20];
  223. #ifdef SHAREWARE
  224. if (Registered_only) {
  225. Assert( bogus_bitmap_initialized != 0 );
  226. mprintf(( 0, "Skipping registered-only animation '%s'\n", filename ));
  227. bmp[0] = &bogus_bitmap;
  228. *nframes = 1;
  229. return;
  230. }
  231. #endif
  232. _splitpath( filename, NULL, NULL, fname, NULL );
  233. for (i=0; i<MAX_BITMAPS_PER_BRUSH; i++ ) {
  234. sprintf( tempname, "%s#%d", fname, i );
  235. bi = piggy_find_bitmap( tempname );
  236. if ( !bi.index )
  237. break;
  238. bmp[i] = bi;
  239. //mprintf(( 0, "Found animation frame %d, %s, in piggy file\n", i, tempname ));
  240. }
  241. if (i) {
  242. *nframes = i;
  243. return;
  244. }
  245. iff_error = iff_read_animbrush(filename,bm,MAX_BITMAPS_PER_BRUSH,nframes,&newpal);
  246. if (iff_error != IFF_NO_ERROR) {
  247. mprintf((1,"File %s - IFF error: %s",filename,iff_errormsg(iff_error)));
  248. Error("File %s - IFF error: %s",filename,iff_errormsg(iff_error));
  249. }
  250. for (i=0;i< *nframes; i++) {
  251. bitmap_index new_bmp;
  252. sprintf( tempname, "%s#%d", fname, i );
  253. if ( iff_has_transparency )
  254. gr_remap_bitmap_good( bm[i], newpal, iff_transparent_color, SuperX );
  255. else
  256. gr_remap_bitmap_good( bm[i], newpal, -1, SuperX );
  257. bm[i]->avg_color = compute_average_pixel(bm[i]);
  258. new_bmp = piggy_register_bitmap( bm[i], tempname, 0 );
  259. free( bm[i] );
  260. bmp[i] = new_bmp;
  261. mprintf((0, "Registering frame %d, %s, in piggy file\n", i, tempname ));
  262. }
  263. }
  264. int ds_load( char * filename ) {
  265. int i;
  266. CFILE * cfp;
  267. digi_sound new;
  268. char fname[20];
  269. char rawname[100];
  270. #ifdef SHAREWARE
  271. if (Registered_only) {
  272. //mprintf( 0, "Skipping registered-only sound '%s'\n", filename );
  273. return &bogus_sound;
  274. }
  275. #endif
  276. _splitpath( filename, NULL, NULL, fname, NULL );
  277. _makepath( rawname, NULL, NULL,fname, ".RAW" );
  278. i=piggy_find_sound( fname );
  279. if (i!=255) {
  280. return i;
  281. }
  282. cfp = cfopen( rawname, "rb" );
  283. if (cfp!=NULL) {
  284. new.length = cfilelength( cfp );
  285. //MALLOC( new.data, ubyte, new.length );//hack by KRB
  286. new.data = (ubyte *)malloc(new.length*sizeof(ubyte));
  287. cfread( new.data, 1, new.length, cfp );
  288. cfclose(cfp);
  289. mprintf( (0, "S" ));
  290. mprintf( (0, "<%s>", rawname ));
  291. } else {
  292. mprintf( (1, "Warning: Couldn't find '%s'\n", filename ));
  293. return 255;
  294. }
  295. i = piggy_register_sound( &new, fname, 0 );
  296. return i;
  297. }
  298. //parse a float
  299. float get_float()
  300. {
  301. char *xarg;
  302. xarg = strtok( NULL, space );
  303. return atof( xarg );
  304. }
  305. //parse an int
  306. int get_int()
  307. {
  308. char *xarg;
  309. xarg = strtok( NULL, space );
  310. return atoi( xarg );
  311. }
  312. // rotates a byte left one bit, preserving the bit falling off the right
  313. //void
  314. //rotate_left(char *c)
  315. //{
  316. // int found;
  317. //
  318. // found = 0;
  319. // if (*c & 0x80)
  320. // found = 1;
  321. // *c = *c << 1;
  322. // if (found)
  323. // *c |= 0x01;
  324. //}
  325. #define LINEBUF_SIZE 600
  326. int linenum;
  327. //-----------------------------------------------------------------
  328. // Initializes all bitmaps from BITMAPS.TBL file.
  329. int bm_init_use_tbl()
  330. {
  331. CFILE * InfoFile;
  332. char inputline[LINEBUF_SIZE];
  333. int i, have_bin_tbl;
  334. init_polygon_models();
  335. ObjType[0] = OL_PLAYER;
  336. ObjId[0] = 0;
  337. Num_total_object_types = 1;
  338. for (i=0; i<MAX_SOUNDS; i++ ) {
  339. Sounds[i] = 255;
  340. AltSounds[i] = 255;
  341. }
  342. for (i=0; i<MAX_TEXTURES; i++ ) {
  343. TmapInfo[i].eclip_num = -1;
  344. TmapInfo[i].flags = 0;
  345. }
  346. #ifndef SHAREWARE
  347. for (i=0; i<MAX_HOSTAGES; i++ )
  348. Hostage_face_clip[i].num_frames=0;
  349. #endif
  350. Num_effects = 0;
  351. for (i=0; i<MAX_EFFECTS; i++ ) {
  352. //Effects[i].bm_ptr = (grs_bitmap **) -1;
  353. Effects[i].changing_wall_texture = -1;
  354. Effects[i].changing_object_texture = -1;
  355. Effects[i].segnum = -1;
  356. Effects[i].vc.num_frames = -1; //another mark of being unused
  357. }
  358. for (i=0;i<MAX_POLYGON_MODELS;i++)
  359. Dying_modelnums[i] = Dead_modelnums[i] = -1;
  360. Num_vclips = 0;
  361. for (i=0; i<VCLIP_MAXNUM; i++ ) {
  362. Vclip[i].num_frames = -1;
  363. Vclip[i].flags = 0;
  364. }
  365. for (i=0; i<MAX_WALL_ANIMS; i++ )
  366. WallAnims[i].num_frames = -1;
  367. Num_wall_anims = 0;
  368. setbuf(stdout, NULL); // unbuffered output via printf
  369. if (Installed)
  370. return 1;
  371. Installed = 1;
  372. piggy_init();
  373. if ( FindArg( "-nobm" ) ) {
  374. piggy_read_sounds();
  375. return 0;
  376. }
  377. // Open BITMAPS.TBL for reading.
  378. have_bin_tbl = 0;
  379. InfoFile = cfopen( "BITMAPS.TBL", "rb" );
  380. if (InfoFile == NULL) {
  381. InfoFile = cfopen("BITMAPS.BIN", "rb");
  382. if (InfoFile == NULL)
  383. Error("Missing BITMAPS.TBL and BITMAPS.BIN file\n");
  384. have_bin_tbl = 1;
  385. }
  386. linenum = 0;
  387. cfseek( InfoFile, 0L, SEEK_SET);
  388. while (cfgets(inputline, LINEBUF_SIZE, InfoFile)) {
  389. int l;
  390. char *temp_ptr;
  391. linenum++;
  392. if (have_bin_tbl) { // is this a binary tbl file
  393. for (i = 0; i < strlen(inputline) - 1; i++) {
  394. encode_rotate_left(&(inputline[i]));
  395. inputline[i] = inputline[i] ^ BITMAP_TBL_XOR;
  396. encode_rotate_left(&(inputline[i]));
  397. }
  398. } else {
  399. while (inputline[(l=strlen(inputline))-2]=='\\') {
  400. cfgets(inputline+l-2,LINEBUF_SIZE-(l-2), InfoFile);
  401. linenum++;
  402. }
  403. }
  404. REMOVE_EOL(inputline);
  405. if (strchr(inputline, ';')!=NULL) REMOVE_COMMENTS(inputline);
  406. if (strlen(inputline) == LINEBUF_SIZE-1)
  407. Error("Possible line truncation in BITMAPS.TBL on line %d\n",linenum);
  408. SuperX = -1;
  409. if ( (temp_ptr=strstr( inputline, "superx=" )) ) {
  410. SuperX = atoi( &temp_ptr[7] );
  411. }
  412. arg = strtok( inputline, space );
  413. if (arg[0] == '@') {
  414. arg++;
  415. Registered_only = 1;
  416. } else
  417. Registered_only = 0;
  418. while (arg != NULL )
  419. {
  420. // Check all possible flags and defines.
  421. if (*arg == '$') bm_flag = BM_NONE; // reset to no flags as default.
  422. IFTOK("$COCKPIT") bm_flag = BM_COCKPIT;
  423. else IFTOK("$GAUGES") {bm_flag = BM_GAUGES; clip_count = 0;}
  424. else IFTOK("$SOUND") bm_read_sound();
  425. else IFTOK("$DOOR_ANIMS") bm_flag = BM_WALL_ANIMS;
  426. else IFTOK("$WALL_ANIMS") bm_flag = BM_WALL_ANIMS;
  427. else IFTOK("$TEXTURES") bm_flag = BM_TEXTURES;
  428. else IFTOK("$VCLIP") {bm_flag = BM_VCLIP; vlighting = 0; clip_count = 0;}
  429. else IFTOK("$ECLIP") {bm_flag = BM_ECLIP; vlighting = 0; clip_count = 0; obj_eclip=0; dest_bm=NULL; dest_vclip=-1; dest_eclip=-1; dest_size=-1; crit_clip=-1; crit_flag=0; sound_num=-1;}
  430. else IFTOK("$WCLIP") {bm_flag = BM_WCLIP; vlighting = 0; clip_count = 0; wall_explodes = wall_blastable = 0; wall_open_sound=wall_close_sound=-1; tmap1_flag=0; wall_hidden=0;}
  431. else IFTOK("$EFFECTS") {bm_flag = BM_EFFECTS; clip_num = 0;}
  432. #ifdef EDITOR
  433. else IFTOK("!METALS_FLAG") TextureMetals = texture_count;
  434. else IFTOK("!LIGHTS_FLAG") TextureLights = texture_count;
  435. else IFTOK("!EFFECTS_FLAG") TextureEffects = texture_count;
  436. #endif
  437. else IFTOK("lighting") TmapInfo[texture_count-1].lighting = fl2f(get_float());
  438. else IFTOK("damage") TmapInfo[texture_count-1].damage = fl2f(get_float());
  439. else IFTOK("volatile") TmapInfo[texture_count-1].flags |= TMI_VOLATILE;
  440. //else IFTOK("Num_effects") Num_effects = get_int();
  441. else IFTOK("Num_wall_anims") Num_wall_anims = get_int();
  442. else IFTOK("clip_num") clip_num = get_int();
  443. else IFTOK("dest_bm") dest_bm = strtok( NULL, space );
  444. else IFTOK("dest_vclip") dest_vclip = get_int();
  445. else IFTOK("dest_eclip") dest_eclip = get_int();
  446. else IFTOK("dest_size") dest_size = fl2f(get_float());
  447. else IFTOK("crit_clip") crit_clip = get_int();
  448. else IFTOK("crit_flag") crit_flag = get_int();
  449. else IFTOK("sound_num") sound_num = get_int();
  450. else IFTOK("frames") frames = get_int();
  451. else IFTOK("time") time = get_float();
  452. else IFTOK("obj_eclip") obj_eclip = get_int();
  453. else IFTOK("hit_sound") hit_sound = get_int();
  454. else IFTOK("abm_flag") abm_flag = get_int();
  455. else IFTOK("tmap1_flag") tmap1_flag = get_int();
  456. else IFTOK("vlighting") vlighting = get_float();
  457. else IFTOK("rod_flag") rod_flag = get_int();
  458. else IFTOK("superx") get_int();
  459. else IFTOK("open_sound") wall_open_sound = get_int();
  460. else IFTOK("close_sound") wall_close_sound = get_int();
  461. else IFTOK("explodes") wall_explodes = get_int();
  462. else IFTOK("blastable") wall_blastable = get_int();
  463. else IFTOK("hidden") wall_hidden = get_int();
  464. else IFTOK("$ROBOT_AI") bm_read_robot_ai();
  465. else IFTOK("$POWERUP") {bm_read_powerup(0); continue;}
  466. else IFTOK("$POWERUP_UNUSED") {bm_read_powerup(1); continue;}
  467. else IFTOK("$HOSTAGE") {bm_read_hostage(); continue;}
  468. else IFTOK("$HOSTAGE_FACE") {bm_read_hostage_face();continue;}
  469. else IFTOK("$ROBOT") {bm_read_robot(); continue;}
  470. else IFTOK("$WEAPON") {bm_read_weapon(0); continue;}
  471. else IFTOK("$WEAPON_UNUSED") {bm_read_weapon(1); continue;}
  472. else IFTOK("$OBJECT") {bm_read_object(); continue;}
  473. else IFTOK("$PLAYER_SHIP") {bm_read_player_ship(); continue;}
  474. else { //not a special token, must be a bitmap!
  475. // Remove any illegal/unwanted spaces and tabs at this point.
  476. while ((*arg=='\t') || (*arg==' ')) arg++;
  477. if (*arg == '\0') { break; }
  478. // Otherwise, 'arg' is apparently a bitmap filename.
  479. // Load bitmap and process it below:
  480. bm_read_some_file();
  481. }
  482. arg = strtok( NULL, equal_space );
  483. continue;
  484. }
  485. }
  486. NumTextures = texture_count;
  487. Num_tmaps = tmap_count;
  488. cfclose( InfoFile );
  489. atexit(bm_close);
  490. Assert(N_robot_types == Num_robot_ais); //should be one ai info per robot
  491. init_endlevel(); //this is here so endlevel bitmaps go into pig
  492. verify_textures();
  493. //check for refereced but unused clip count
  494. for (i=0; i<MAX_EFFECTS; i++ )
  495. if ( (
  496. (Effects[i].changing_wall_texture!=-1) ||
  497. (Effects[i].changing_object_texture!=-1)
  498. )
  499. && (Effects[i].vc.num_frames==-1) )
  500. Error("EClip %d referenced (by polygon object?), but not defined",i);
  501. #ifndef NDEBUG
  502. {
  503. int used;
  504. for (i=used=0; i<num_sounds; i++ )
  505. if (Sounds[i] != 255)
  506. used++;
  507. mprintf((0,"Sound slots used: %d of %d, highest index %d\n",used,MAX_SOUNDS,num_sounds));
  508. }
  509. #endif
  510. piggy_read_sounds();
  511. #ifdef EDITOR
  512. piggy_dump_all();
  513. #endif
  514. return 0;
  515. }
  516. void verify_textures()
  517. {
  518. grs_bitmap * bmp;
  519. int i,j;
  520. j=0;
  521. for (i=0; i<Num_tmaps; i++ ) {
  522. bmp = &GameBitmaps[Textures[i].index];
  523. if ( (bmp->bm_w!=64)||(bmp->bm_h!=64)||(bmp->bm_rowsize!=64) ) {
  524. mprintf( (1, "ERROR: Texture '%s' isn't 64x64 !\n", TmapInfo[i].filename ));
  525. j++;
  526. }
  527. }
  528. if (j) exit(1);
  529. }
  530. //--unused-- void dump_all_transparent_textures()
  531. //--unused-- {
  532. //--unused-- FILE * fp;
  533. //--unused-- int i,j,k;
  534. //--unused-- ubyte * p;
  535. //--unused-- fp = fopen( "XPARENT.LST", "wt" );
  536. //--unused-- for (i=0; i<Num_tmaps; i++ ) {
  537. //--unused-- k = 0;
  538. //--unused-- p = Textures[i]->bm_data;
  539. //--unused-- for (j=0; j<64*64; j++ )
  540. //--unused-- if ( (*p++)==255 ) k++;
  541. //--unused-- if ( k ) {
  542. //--unused-- fprintf( fp, "'%s' has %d transparent pixels\n", TmapInfo[i].filename, k );
  543. //--unused-- }
  544. //--unused-- }
  545. //--unused-- fclose(fp);
  546. //--unused-- }
  547. void bm_close()
  548. {
  549. if (Installed)
  550. {
  551. piggy_close();
  552. Installed=0;
  553. }
  554. }
  555. void set_lighting_flag(byte *bp)
  556. {
  557. if (vlighting < 0)
  558. *bp |= BM_FLAG_NO_LIGHTING;
  559. else
  560. *bp &= (0xff ^ BM_FLAG_NO_LIGHTING);
  561. }
  562. set_texture_name(char *name)
  563. {
  564. strcpy ( TmapInfo[texture_count].filename, name );
  565. REMOVE_DOTS(TmapInfo[texture_count].filename);
  566. }
  567. void bm_read_eclip()
  568. {
  569. bitmap_index bitmap;
  570. Assert(clip_num < MAX_EFFECTS);
  571. if (clip_num+1 > Num_effects)
  572. Num_effects = clip_num+1;
  573. Effects[clip_num].flags = 0;
  574. if (!abm_flag) {
  575. bitmap = bm_load_sub(arg);
  576. Effects[clip_num].vc.play_time = fl2f(time);
  577. Effects[clip_num].vc.num_frames = frames;
  578. Effects[clip_num].vc.frame_time = fl2f(time)/frames;
  579. Assert(clip_count < frames);
  580. Effects[clip_num].vc.frames[clip_count] = bitmap;
  581. set_lighting_flag(&GameBitmaps[bitmap.index].bm_flags);
  582. Assert(!obj_eclip); //obj eclips for non-abm files not supported!
  583. Assert(crit_flag==0);
  584. if (clip_count == 0) {
  585. Effects[clip_num].changing_wall_texture = texture_count;
  586. Assert(tmap_count < MAX_TEXTURES);
  587. TmapList[tmap_count++] = texture_count;
  588. Textures[texture_count] = bitmap;
  589. set_texture_name(arg);
  590. Assert(texture_count < MAX_TEXTURES);
  591. texture_count++;
  592. TmapInfo[texture_count].eclip_num = clip_num;
  593. NumTextures = texture_count;
  594. }
  595. clip_count++;
  596. } else {
  597. bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
  598. abm_flag = 0;
  599. ab_load( arg, bm, &Effects[clip_num].vc.num_frames );
  600. //printf("EC%d.", clip_num);
  601. Effects[clip_num].vc.play_time = fl2f(time);
  602. Effects[clip_num].vc.frame_time = Effects[clip_num].vc.play_time/Effects[clip_num].vc.num_frames;
  603. clip_count = 0;
  604. set_lighting_flag( &GameBitmaps[bm[clip_count].index].bm_flags);
  605. Effects[clip_num].vc.frames[clip_count] = bm[clip_count];
  606. if (!obj_eclip && !crit_flag) {
  607. Effects[clip_num].changing_wall_texture = texture_count;
  608. Assert(tmap_count < MAX_TEXTURES);
  609. TmapList[tmap_count++] = texture_count;
  610. Textures[texture_count] = bm[clip_count];
  611. set_texture_name( arg );
  612. Assert(texture_count < MAX_TEXTURES);
  613. TmapInfo[texture_count].eclip_num = clip_num;
  614. texture_count++;
  615. NumTextures = texture_count;
  616. }
  617. if (obj_eclip) {
  618. if (Effects[clip_num].changing_object_texture == -1) { //first time referenced
  619. Effects[clip_num].changing_object_texture = N_ObjBitmaps; // XChange ObjectBitmaps
  620. N_ObjBitmaps++;
  621. }
  622. ObjBitmaps[Effects[clip_num].changing_object_texture] = Effects[clip_num].vc.frames[0];
  623. }
  624. //if for an object, Effects_bm_ptrs set in object load
  625. for(clip_count=1;clip_count < Effects[clip_num].vc.num_frames; clip_count++) {
  626. set_lighting_flag( &GameBitmaps[bm[clip_count].index].bm_flags);
  627. Effects[clip_num].vc.frames[clip_count] = bm[clip_count];
  628. }
  629. }
  630. Effects[clip_num].crit_clip = crit_clip;
  631. Effects[clip_num].sound_num = sound_num;
  632. if (dest_bm) { //deal with bitmap for blown up clip
  633. char short_name[13];
  634. int i;
  635. strcpy(short_name,dest_bm);
  636. REMOVE_DOTS(short_name);
  637. for (i=0;i<texture_count;i++)
  638. if (!stricmp(TmapInfo[i].filename,short_name))
  639. break;
  640. if (i==texture_count) {
  641. Textures[texture_count] = bm_load_sub(dest_bm);
  642. strcpy( TmapInfo[texture_count].filename, short_name);
  643. texture_count++;
  644. Assert(texture_count < MAX_TEXTURES);
  645. NumTextures = texture_count;
  646. }
  647. Effects[clip_num].dest_bm_num = i;
  648. if (dest_vclip==-1)
  649. Error("Desctuction vclip missing on line %d",linenum);
  650. if (dest_size==-1)
  651. Error("Desctuction vclip missing on line %d",linenum);
  652. Effects[clip_num].dest_vclip = dest_vclip;
  653. Effects[clip_num].dest_size = dest_size;
  654. Effects[clip_num].dest_eclip = dest_eclip;
  655. }
  656. else {
  657. Effects[clip_num].dest_bm_num = -1;
  658. Effects[clip_num].dest_eclip = -1;
  659. }
  660. if (crit_flag)
  661. Effects[clip_num].flags |= EF_CRITICAL;
  662. }
  663. void bm_read_gauges()
  664. {
  665. bitmap_index bitmap;
  666. int i, num_abm_frames;
  667. if (!abm_flag) {
  668. bitmap = bm_load_sub(arg);
  669. Assert(clip_count < MAX_GAUGE_BMS);
  670. Gauges[clip_count] = bitmap;
  671. clip_count++;
  672. } else {
  673. bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
  674. abm_flag = 0;
  675. ab_load( arg, bm, &num_abm_frames );
  676. for (i=clip_count; i<clip_count+num_abm_frames; i++) {
  677. Assert(i < MAX_GAUGE_BMS);
  678. Gauges[i] = bm[i-clip_count];
  679. }
  680. clip_count += num_abm_frames;
  681. }
  682. }
  683. void bm_read_wclip()
  684. {
  685. bitmap_index bitmap;
  686. Assert(clip_num < MAX_WALL_ANIMS);
  687. WallAnims[clip_num].flags = 0;
  688. if (wall_explodes) WallAnims[clip_num].flags |= WCF_EXPLODES;
  689. if (wall_blastable) WallAnims[clip_num].flags |= WCF_BLASTABLE;
  690. if (wall_hidden) WallAnims[clip_num].flags |= WCF_HIDDEN;
  691. if (tmap1_flag) WallAnims[clip_num].flags |= WCF_TMAP1;
  692. if (!abm_flag) {
  693. bitmap = bm_load_sub(arg);
  694. if ( (WallAnims[clip_num].num_frames>-1) && (clip_count==0) )
  695. Error( "Wall Clip %d is already used!", clip_num );
  696. WallAnims[clip_num].play_time = fl2f(time);
  697. WallAnims[clip_num].num_frames = frames;
  698. //WallAnims[clip_num].frame_time = fl2f(time)/frames;
  699. Assert(clip_count < frames);
  700. WallAnims[clip_num].frames[clip_count++] = texture_count;
  701. WallAnims[clip_num].open_sound = wall_open_sound;
  702. WallAnims[clip_num].close_sound = wall_close_sound;
  703. Textures[texture_count] = bitmap;
  704. set_lighting_flag(&GameBitmaps[bitmap.index].bm_flags);
  705. set_texture_name( arg );
  706. Assert(texture_count < MAX_TEXTURES);
  707. texture_count++;
  708. NumTextures = texture_count;
  709. if (clip_num >= Num_wall_anims) Num_wall_anims = clip_num+1;
  710. } else {
  711. bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
  712. int nframes;
  713. if ( (WallAnims[clip_num].num_frames>-1) )
  714. Error( "AB_Wall clip %d is already used!", clip_num );
  715. abm_flag = 0;
  716. ab_load( arg, bm, &nframes );
  717. WallAnims[clip_num].num_frames = nframes;
  718. //printf("WC");
  719. WallAnims[clip_num].play_time = fl2f(time);
  720. //WallAnims[clip_num].frame_time = fl2f(time)/nframes;
  721. WallAnims[clip_num].open_sound = wall_open_sound;
  722. WallAnims[clip_num].close_sound = wall_close_sound;
  723. WallAnims[clip_num].close_sound = wall_close_sound;
  724. strcpy(WallAnims[clip_num].filename, arg);
  725. REMOVE_DOTS(WallAnims[clip_num].filename);
  726. if (clip_num >= Num_wall_anims) Num_wall_anims = clip_num+1;
  727. set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
  728. for (clip_count=0;clip_count < WallAnims[clip_num].num_frames; clip_count++) {
  729. //printf("%d", clip_count);
  730. Textures[texture_count] = bm[clip_count];
  731. set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
  732. WallAnims[clip_num].frames[clip_count] = texture_count;
  733. REMOVE_DOTS(arg);
  734. sprintf( TmapInfo[texture_count].filename, "%s#%d", arg, clip_count);
  735. Assert(texture_count < MAX_TEXTURES);
  736. texture_count++;
  737. NumTextures = texture_count;
  738. }
  739. }
  740. }
  741. void bm_read_vclip()
  742. {
  743. bitmap_index bi;
  744. Assert(clip_num < VCLIP_MAXNUM);
  745. if (!abm_flag) {
  746. if ( (Vclip[clip_num].num_frames>-1) && (clip_count==0) )
  747. Error( "Vclip %d is already used!", clip_num );
  748. bi = bm_load_sub(arg);
  749. Vclip[clip_num].play_time = fl2f(time);
  750. Vclip[clip_num].num_frames = frames;
  751. Vclip[clip_num].frame_time = fl2f(time)/frames;
  752. Vclip[clip_num].light_value = fl2f(vlighting);
  753. Vclip[clip_num].sound_num = sound_num;
  754. set_lighting_flag(&GameBitmaps[bi.index].bm_flags);
  755. Assert(clip_count < frames);
  756. Vclip[clip_num].frames[clip_count++] = bi;
  757. if (rod_flag) {
  758. rod_flag=0;
  759. Vclip[clip_num].flags |= VF_ROD;
  760. }
  761. } else {
  762. bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
  763. abm_flag = 0;
  764. if ( (Vclip[clip_num].num_frames>-1) )
  765. Error( "AB_Vclip %d is already used!", clip_num );
  766. ab_load( arg, bm, &Vclip[clip_num].num_frames );
  767. if (rod_flag) {
  768. //int i;
  769. rod_flag=0;
  770. Vclip[clip_num].flags |= VF_ROD;
  771. }
  772. //printf("VC");
  773. Vclip[clip_num].play_time = fl2f(time);
  774. Vclip[clip_num].frame_time = fl2f(time)/Vclip[clip_num].num_frames;
  775. Vclip[clip_num].light_value = fl2f(vlighting);
  776. Vclip[clip_num].sound_num = sound_num;
  777. set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
  778. for (clip_count=0;clip_count < Vclip[clip_num].num_frames; clip_count++) {
  779. //printf("%d", clip_count);
  780. set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
  781. Vclip[clip_num].frames[clip_count] = bm[clip_count];
  782. }
  783. }
  784. }
  785. // ------------------------------------------------------------------------------
  786. void get4fix(fix *fixp)
  787. {
  788. char *curtext;
  789. int i;
  790. for (i=0; i<NDL; i++) {
  791. curtext = strtok(NULL, space);
  792. fixp[i] = fl2f(atof(curtext));
  793. }
  794. }
  795. // ------------------------------------------------------------------------------
  796. void get4byte(byte *bytep)
  797. {
  798. char *curtext;
  799. int i;
  800. for (i=0; i<NDL; i++) {
  801. curtext = strtok(NULL, space);
  802. bytep[i] = atoi(curtext);
  803. }
  804. }
  805. // ------------------------------------------------------------------------------
  806. // Convert field of view from an angle in 0..360 to cosine.
  807. void adjust_field_of_view(fix *fovp)
  808. {
  809. int i;
  810. fixang tt;
  811. float ff;
  812. fix temp;
  813. for (i=0; i<NDL; i++) {
  814. ff = - f2fl(fovp[i]);
  815. if (ff > 179) {
  816. mprintf((1, "Warning: Bogus field of view (%7.3f). Must be in 0..179.\n", ff));
  817. ff = 179;
  818. }
  819. ff = ff/360;
  820. tt = fl2f(ff);
  821. fix_sincos(tt, &temp, &fovp[i]);
  822. }
  823. }
  824. void clear_to_end_of_line(void)
  825. {
  826. arg = strtok( NULL, space );
  827. while (arg != NULL)
  828. arg = strtok( NULL, space );
  829. }
  830. bm_read_sound()
  831. {
  832. int sound_num;
  833. int alt_sound_num;
  834. sound_num = get_int();
  835. alt_sound_num = get_int();
  836. if ( sound_num>=MAX_SOUNDS )
  837. Error( "Too many sound files.\n" );
  838. if (sound_num >= num_sounds)
  839. num_sounds = sound_num+1;
  840. arg = strtok(NULL, space);
  841. Sounds[sound_num] = ds_load(arg);
  842. if ( alt_sound_num == 0 )
  843. AltSounds[sound_num] = sound_num;
  844. else if (alt_sound_num < 0 )
  845. AltSounds[sound_num] = 255;
  846. else
  847. AltSounds[sound_num] = alt_sound_num;
  848. if (Sounds[sound_num] == 255)
  849. Error("Can't load soundfile <%s>",arg);
  850. }
  851. // ------------------------------------------------------------------------------
  852. void bm_read_robot_ai()
  853. {
  854. char *robotnum_text;
  855. int robotnum;
  856. robot_info *robptr;
  857. robotnum_text = strtok(NULL, space);
  858. robotnum = atoi(robotnum_text);
  859. Assert(robotnum < MAX_ROBOT_TYPES);
  860. robptr = &Robot_info[robotnum];
  861. Assert(robotnum == Num_robot_ais); //make sure valid number
  862. #ifdef SHAREWARE
  863. if (Registered_only) {
  864. Num_robot_ais++;
  865. clear_to_end_of_line();
  866. return;
  867. }
  868. #endif
  869. Num_robot_ais++;
  870. get4fix(robptr->field_of_view);
  871. get4fix(robptr->firing_wait);
  872. get4byte(robptr->rapidfire_count);
  873. get4fix(robptr->turn_time);
  874. get4fix(robptr->fire_power);
  875. get4fix(robptr->shield);
  876. get4fix(robptr->max_speed);
  877. get4fix(robptr->circle_distance);
  878. get4byte(robptr->evade_speed);
  879. robptr->always_0xabcd = 0xabcd;
  880. adjust_field_of_view(robptr->field_of_view);
  881. }
  882. // ----------------------------------------------------------------------------------------------
  883. //this will load a bitmap for a polygon models. it puts the bitmap into
  884. //the array ObjBitmaps[], and also deals with animating bitmaps
  885. //returns a pointer to the bitmap
  886. grs_bitmap *load_polymodel_bitmap(char *name)
  887. {
  888. Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
  889. // Assert( N_ObjBitmaps == N_ObjBitmapPtrs );
  890. if (name[0] == '%') { //an animating bitmap!
  891. int eclip_num;
  892. eclip_num = atoi(name+1);
  893. if (Effects[eclip_num].changing_object_texture == -1) { //first time referenced
  894. Effects[eclip_num].changing_object_texture = N_ObjBitmaps;
  895. ObjBitmapPtrs[N_ObjBitmapPtrs++] = N_ObjBitmaps;
  896. N_ObjBitmaps++;
  897. } else {
  898. ObjBitmapPtrs[N_ObjBitmapPtrs++] = Effects[eclip_num].changing_object_texture;
  899. }
  900. return NULL;
  901. }
  902. else {
  903. ObjBitmaps[N_ObjBitmaps] = bm_load_sub(name);
  904. ObjBitmapPtrs[N_ObjBitmapPtrs++] = N_ObjBitmaps;
  905. N_ObjBitmaps++;
  906. return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index];
  907. }
  908. }
  909. #define MAX_MODEL_VARIANTS 4
  910. // ------------------------------------------------------------------------------
  911. void bm_read_robot()
  912. {
  913. char *model_name[MAX_MODEL_VARIANTS];
  914. int n_models,i;
  915. int first_bitmap_num[MAX_MODEL_VARIANTS];
  916. char *equal_ptr;
  917. int exp1_vclip_num=-1;
  918. int exp1_sound_num=-1;
  919. int exp2_vclip_num=-1;
  920. int exp2_sound_num=-1;
  921. fix lighting = F1_0/2; // Default
  922. fix strength = F1_0*10; // Default strength
  923. fix mass = f1_0*4;
  924. fix drag = f1_0/2;
  925. short weapon_type = 0;
  926. int g,s;
  927. char name[ROBOT_NAME_LENGTH];
  928. int contains_count=0, contains_id=0, contains_prob=0, contains_type=0;
  929. int score_value=1000;
  930. int cloak_type=0; // Default = this robot does not cloak
  931. int attack_type=0; // Default = this robot attacks by firing (1=lunge)
  932. int boss_flag=0; // Default = robot is not a boss.
  933. int see_sound = ROBOT_SEE_SOUND_DEFAULT;
  934. int attack_sound = ROBOT_ATTACK_SOUND_DEFAULT;
  935. int claw_sound = ROBOT_CLAW_SOUND_DEFAULT;
  936. Assert(N_robot_types < MAX_ROBOT_TYPES);
  937. #ifdef SHAREWARE
  938. if (Registered_only) {
  939. Robot_info[N_robot_types].model_num = -1;
  940. N_robot_types++;
  941. Num_total_object_types++;
  942. clear_to_end_of_line();
  943. return;
  944. }
  945. #endif
  946. model_name[0] = strtok( NULL, space );
  947. first_bitmap_num[0] = N_ObjBitmapPtrs;
  948. n_models = 1;
  949. // Process bitmaps
  950. bm_flag=BM_ROBOT;
  951. arg = strtok( NULL, space );
  952. while (arg!=NULL) {
  953. equal_ptr = strchr( arg, '=' );
  954. if ( equal_ptr ) {
  955. *equal_ptr='\0';
  956. equal_ptr++;
  957. // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
  958. if (!stricmp( arg, "exp1_vclip" )) {
  959. exp1_vclip_num = atoi(equal_ptr);
  960. } else if (!stricmp( arg, "exp2_vclip" )) {
  961. exp2_vclip_num = atoi(equal_ptr);
  962. } else if (!stricmp( arg, "exp1_sound" )) {
  963. exp1_sound_num = atoi(equal_ptr);
  964. } else if (!stricmp( arg, "exp2_sound" )) {
  965. exp2_sound_num = atoi(equal_ptr);
  966. } else if (!stricmp( arg, "lighting" )) {
  967. lighting = fl2f(atof(equal_ptr));
  968. if ( (lighting < 0) || (lighting > F1_0 )) {
  969. mprintf( (1, "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting)));
  970. Error( "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting));
  971. }
  972. } else if (!stricmp( arg, "weapon_type" )) {
  973. weapon_type = atoi(equal_ptr);
  974. } else if (!stricmp( arg, "strength" )) {
  975. strength = i2f(atoi(equal_ptr));
  976. } else if (!stricmp( arg, "mass" )) {
  977. mass = fl2f(atof(equal_ptr));
  978. } else if (!stricmp( arg, "drag" )) {
  979. drag = fl2f(atof(equal_ptr));
  980. } else if (!stricmp( arg, "contains_id" )) {
  981. contains_id = atoi(equal_ptr);
  982. } else if (!stricmp( arg, "contains_type" )) {
  983. contains_type = atoi(equal_ptr);
  984. } else if (!stricmp( arg, "contains_count" )) {
  985. contains_count = atoi(equal_ptr);
  986. } else if (!stricmp( arg, "contains_prob" )) {
  987. contains_prob = atoi(equal_ptr);
  988. } else if (!stricmp( arg, "cloak_type" )) {
  989. cloak_type = atoi(equal_ptr);
  990. } else if (!stricmp( arg, "attack_type" )) {
  991. attack_type = atoi(equal_ptr);
  992. } else if (!stricmp( arg, "boss" )) {
  993. boss_flag = atoi(equal_ptr);
  994. } else if (!stricmp( arg, "score_value" )) {
  995. score_value = atoi(equal_ptr);
  996. } else if (!stricmp( arg, "see_sound" )) {
  997. see_sound = atoi(equal_ptr);
  998. } else if (!stricmp( arg, "attack_sound" )) {
  999. attack_sound = atoi(equal_ptr);
  1000. } else if (!stricmp( arg, "claw_sound" )) {
  1001. claw_sound = atoi(equal_ptr);
  1002. } else if (!stricmp( arg, "name" )) {
  1003. Assert(strlen(equal_ptr) < ROBOT_NAME_LENGTH); // Oops, name too long.
  1004. strcpy(name, &equal_ptr[1]);
  1005. name[strlen(name)-1] = 0;
  1006. } else if (!stricmp( arg, "simple_model" )) {
  1007. model_name[n_models] = equal_ptr;
  1008. first_bitmap_num[n_models] = N_ObjBitmapPtrs;
  1009. n_models++;
  1010. } else {
  1011. mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
  1012. }
  1013. } else { // Must be a texture specification...
  1014. load_polymodel_bitmap(arg);
  1015. }
  1016. arg = strtok( NULL, space );
  1017. }
  1018. //clear out anim info
  1019. for (g=0;g<MAX_GUNS+1;g++)
  1020. for (s=0;s<N_ANIM_STATES;s++)
  1021. Robot_info[N_robot_types].anim_states[g][s].n_joints = 0; //inialize to zero
  1022. first_bitmap_num[n_models] = N_ObjBitmapPtrs;
  1023. for (i=0;i<n_models;i++) {
  1024. int n_textures;
  1025. int model_num,last_model_num;
  1026. n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
  1027. model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],(i==0)?&Robot_info[N_robot_types]:NULL);
  1028. if (i==0)
  1029. Robot_info[N_robot_types].model_num = model_num;
  1030. else
  1031. Polygon_models[last_model_num].simpler_model = model_num+1;
  1032. last_model_num = model_num;
  1033. }
  1034. ObjType[Num_total_object_types] = OL_ROBOT;
  1035. ObjId[Num_total_object_types] = N_robot_types;
  1036. Robot_info[N_robot_types].exp1_vclip_num = exp1_vclip_num;
  1037. Robot_info[N_robot_types].exp2_vclip_num = exp2_vclip_num;
  1038. Robot_info[N_robot_types].exp1_sound_num = exp1_sound_num;
  1039. Robot_info[N_robot_types].exp2_sound_num = exp2_sound_num;
  1040. Robot_info[N_robot_types].lighting = lighting;
  1041. Robot_info[N_robot_types].weapon_type = weapon_type;
  1042. Robot_info[N_robot_types].strength = strength;
  1043. Robot_info[N_robot_types].mass = mass;
  1044. Robot_info[N_robot_types].drag = drag;
  1045. Robot_info[N_robot_types].cloak_type = cloak_type;
  1046. Robot_info[N_robot_types].attack_type = attack_type;
  1047. Robot_info[N_robot_types].boss_flag = boss_flag;
  1048. Robot_info[N_robot_types].contains_id = contains_id;
  1049. Robot_info[N_robot_types].contains_count = contains_count;
  1050. Robot_info[N_robot_types].contains_prob = contains_prob;
  1051. Robot_info[N_robot_types].score_value = score_value;
  1052. Robot_info[N_robot_types].see_sound = see_sound;
  1053. Robot_info[N_robot_types].attack_sound = attack_sound;
  1054. Robot_info[N_robot_types].claw_sound = claw_sound;
  1055. if (contains_type)
  1056. Robot_info[N_robot_types].contains_type = OBJ_ROBOT;
  1057. else
  1058. Robot_info[N_robot_types].contains_type = OBJ_POWERUP;
  1059. strcpy(Robot_names[N_robot_types], name);
  1060. N_robot_types++;
  1061. Num_total_object_types++;
  1062. }
  1063. //read a polygon object of some sort
  1064. void bm_read_object()
  1065. {
  1066. char *model_name, *model_name_dead=NULL;
  1067. int first_bitmap_num, first_bitmap_num_dead, n_normal_bitmaps;
  1068. char *equal_ptr;
  1069. short model_num;
  1070. short explosion_vclip_num = -1;
  1071. short explosion_sound_num = SOUND_ROBOT_DESTROYED;
  1072. fix lighting = F1_0/2; // Default
  1073. int type=-1;
  1074. fix strength=0;
  1075. model_name = strtok( NULL, space );
  1076. // Process bitmaps
  1077. bm_flag = BM_NONE;
  1078. arg = strtok( NULL, space );
  1079. first_bitmap_num = N_ObjBitmapPtrs;
  1080. while (arg!=NULL) {
  1081. equal_ptr = strchr( arg, '=' );
  1082. if ( equal_ptr ) {
  1083. *equal_ptr='\0';
  1084. equal_ptr++;
  1085. // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
  1086. if (!stricmp(arg,"type")) {
  1087. if (!stricmp(equal_ptr,"controlcen"))
  1088. type = OL_CONTROL_CENTER;
  1089. else if (!stricmp(equal_ptr,"clutter"))
  1090. type = OL_CLUTTER;
  1091. else if (!stricmp(equal_ptr,"exit"))
  1092. type = OL_EXIT;
  1093. }
  1094. else if (!stricmp( arg, "exp_vclip" )) {
  1095. explosion_vclip_num = atoi(equal_ptr);
  1096. } else if (!stricmp( arg, "dead_pof" )) {
  1097. model_name_dead = equal_ptr;
  1098. first_bitmap_num_dead=N_ObjBitmapPtrs;
  1099. } else if (!stricmp( arg, "exp_sound" )) {
  1100. explosion_sound_num = atoi(equal_ptr);
  1101. } else if (!stricmp( arg, "lighting" )) {
  1102. lighting = fl2f(atof(equal_ptr));
  1103. if ( (lighting < 0) || (lighting > F1_0 )) {
  1104. mprintf( (1, "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting)));
  1105. Error( "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting));
  1106. }
  1107. } else if (!stricmp( arg, "strength" )) {
  1108. strength = fl2f(atof(equal_ptr));
  1109. } else {
  1110. mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
  1111. }
  1112. } else { // Must be a texture specification...
  1113. load_polymodel_bitmap(arg);
  1114. }
  1115. arg = strtok( NULL, space );
  1116. }
  1117. if ( model_name_dead )
  1118. n_normal_bitmaps = first_bitmap_num_dead-first_bitmap_num;
  1119. else
  1120. n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num;
  1121. model_num = load_polygon_model(model_name,n_normal_bitmaps,first_bitmap_num,NULL);
  1122. if (type == OL_CONTROL_CENTER)
  1123. N_controlcen_guns = read_model_guns(model_name,controlcen_gun_points,controlcen_gun_dirs,NULL);
  1124. if ( model_name_dead )
  1125. Dead_modelnums[model_num] = load_polygon_model(model_name_dead,N_ObjBitmapPtrs-first_bitmap_num_dead,first_bitmap_num_dead,NULL);
  1126. else
  1127. Dead_modelnums[model_num] = -1;
  1128. if (type == -1)
  1129. Error("No object type specfied for object in BITMAPS.TBL on line %d\n",linenum);
  1130. ObjType[Num_total_object_types] = type;
  1131. ObjId[Num_total_object_types] = model_num;
  1132. ObjStrength[Num_total_object_types] = strength;
  1133. //printf( "Object type %d is a control center\n", Num_total_object_types );
  1134. Num_total_object_types++;
  1135. if (type == OL_EXIT) {
  1136. exit_modelnum = model_num;
  1137. destroyed_exit_modelnum = Dead_modelnums[model_num];
  1138. }
  1139. }
  1140. void bm_read_player_ship()
  1141. {
  1142. char *model_name_dying=NULL;
  1143. char *model_name[MAX_MODEL_VARIANTS];
  1144. int n_models=0,i;
  1145. int first_bitmap_num[MAX_MODEL_VARIANTS];
  1146. char *equal_ptr;
  1147. robot_info ri;
  1148. int last_multi_bitmap_num=-1;
  1149. // Process bitmaps
  1150. bm_flag = BM_NONE;
  1151. arg = strtok( NULL, space );
  1152. Player_ship->mass = Player_ship->drag = 0; //stupid defaults
  1153. Player_ship->expl_vclip_num = -1;
  1154. while (arg!=NULL) {
  1155. equal_ptr = strchr( arg, '=' );
  1156. if ( equal_ptr ) {
  1157. *equal_ptr='\0';
  1158. equal_ptr++;
  1159. // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
  1160. if (!stricmp( arg, "model" )) {
  1161. Assert(n_models==0);
  1162. model_name[0] = equal_ptr;
  1163. first_bitmap_num[0] = N_ObjBitmapPtrs;
  1164. n_models = 1;
  1165. } else if (!stricmp( arg, "simple_model" )) {
  1166. model_name[n_models] = equal_ptr;
  1167. first_bitmap_num[n_models] = N_ObjBitmapPtrs;
  1168. n_models++;
  1169. if (First_multi_bitmap_num!=-1 && last_multi_bitmap_num==-1)
  1170. last_multi_bitmap_num=N_ObjBitmapPtrs;
  1171. }
  1172. else if (!stricmp( arg, "mass" ))
  1173. Player_ship->mass = fl2f(atof(equal_ptr));
  1174. else if (!stricmp( arg, "drag" ))
  1175. Player_ship->drag = fl2f(atof(equal_ptr));
  1176. // else if (!stricmp( arg, "low_thrust" ))
  1177. // Player_ship->low_thrust = fl2f(atof(equal_ptr));
  1178. else if (!stricmp( arg, "max_thrust" ))
  1179. Player_ship->max_thrust = fl2f(atof(equal_ptr));
  1180. else if (!stricmp( arg, "reverse_thrust" ))
  1181. Player_ship->reverse_thrust = fl2f(atof(equal_ptr));
  1182. else if (!stricmp( arg, "brakes" ))
  1183. Player_ship->brakes = fl2f(atof(equal_ptr));
  1184. else if (!stricmp( arg, "wiggle" ))
  1185. Player_ship->wiggle = fl2f(atof(equal_ptr));
  1186. else if (!stricmp( arg, "max_rotthrust" ))
  1187. Player_ship->max_rotthrust = fl2f(atof(equal_ptr));
  1188. else if (!stricmp( arg, "dying_pof" ))
  1189. model_name_dying = equal_ptr;
  1190. else if (!stricmp( arg, "expl_vclip_num" ))
  1191. Player_ship->expl_vclip_num=atoi(equal_ptr);
  1192. else {
  1193. mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
  1194. }
  1195. }
  1196. else if (!stricmp( arg, "multi_textures" )) {
  1197. First_multi_bitmap_num = N_ObjBitmapPtrs;
  1198. first_bitmap_num[n_models] = N_ObjBitmapPtrs;
  1199. }
  1200. else // Must be a texture specification...
  1201. load_polymodel_bitmap(arg);
  1202. arg = strtok( NULL, space );
  1203. }
  1204. Assert(model_name != NULL);
  1205. if (First_multi_bitmap_num!=-1 && last_multi_bitmap_num==-1)
  1206. last_multi_bitmap_num=N_ObjBitmapPtrs;
  1207. if (First_multi_bitmap_num==-1)
  1208. first_bitmap_num[n_models] = N_ObjBitmapPtrs;
  1209. Assert(last_multi_bitmap_num-First_multi_bitmap_num == (MAX_NUM_NET_PLAYERS-1)*2);
  1210. for (i=0;i<n_models;i++) {
  1211. int n_textures;
  1212. int model_num,last_model_num;
  1213. n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
  1214. model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],(i==0)?&ri:NULL);
  1215. if (i==0)
  1216. Player_ship->model_num = model_num;
  1217. else
  1218. Polygon_models[last_model_num].simpler_model = model_num+1;
  1219. last_model_num = model_num;
  1220. }
  1221. if ( model_name_dying ) {
  1222. Assert(n_models);
  1223. Dying_modelnums[Player_ship->model_num] = load_polygon_model(model_name_dying,first_bitmap_num[1]-first_bitmap_num[0],first_bitmap_num[0],NULL);
  1224. }
  1225. Assert(ri.n_guns == N_PLAYER_GUNS);
  1226. //calc player gun positions
  1227. {
  1228. polymodel *pm;
  1229. robot_info *r;
  1230. vms_vector pnt;
  1231. int mn; //submodel number
  1232. int gun_num;
  1233. r = &ri;
  1234. pm = &Polygon_models[Player_ship->model_num];
  1235. for (gun_num=0;gun_num<r->n_guns;gun_num++) {
  1236. pnt = r->gun_points[gun_num];
  1237. mn = r->gun_submodels[gun_num];
  1238. //instance up the tree for this gun
  1239. while (mn != 0) {
  1240. vm_vec_add2(&pnt,&pm->submodel_offsets[mn]);
  1241. mn = pm->submodel_parents[mn];
  1242. }
  1243. Player_ship->gun_points[gun_num] = pnt;
  1244. }
  1245. }
  1246. }
  1247. void bm_read_some_file()
  1248. {
  1249. switch (bm_flag) {
  1250. case BM_COCKPIT: {
  1251. bitmap_index bitmap;
  1252. bitmap = bm_load_sub(arg);
  1253. Assert( Num_cockpits < N_COCKPIT_BITMAPS );
  1254. cockpit_bitmap[Num_cockpits++] = bitmap;
  1255. //bm_flag = BM_NONE;
  1256. }
  1257. break;
  1258. case BM_GAUGES:
  1259. bm_read_gauges();
  1260. break;
  1261. case BM_WEAPON:
  1262. bm_read_weapon(0);
  1263. break;
  1264. case BM_VCLIP:
  1265. bm_read_vclip();
  1266. break;
  1267. case BM_ECLIP:
  1268. bm_read_eclip();
  1269. break;
  1270. case BM_TEXTURES: {
  1271. bitmap_index bitmap;
  1272. bitmap = bm_load_sub(arg);
  1273. Assert(tmap_count < MAX_TEXTURES);
  1274. TmapList[tmap_count++] = texture_count;
  1275. Textures[texture_count] = bitmap;
  1276. set_texture_name( arg );
  1277. Assert(texture_count < MAX_TEXTURES);
  1278. texture_count++;
  1279. NumTextures = texture_count;
  1280. }
  1281. break;
  1282. case BM_WCLIP:
  1283. bm_read_wclip();
  1284. break;
  1285. default:
  1286. break;
  1287. }
  1288. }
  1289. // ------------------------------------------------------------------------------
  1290. // If unused_flag is set, then this is just a placeholder. Don't actually reference vclips or load bbms.
  1291. void bm_read_weapon(int unused_flag)
  1292. {
  1293. int i,n;
  1294. int n_models=0;
  1295. char *equal_ptr;
  1296. char *pof_file_inner=NULL;
  1297. char *model_name[MAX_MODEL_VARIANTS];
  1298. int first_bitmap_num[MAX_MODEL_VARIANTS];
  1299. int lighted; //flag for whether is a texture is lighted
  1300. Assert(N_weapon_types < MAX_WEAPON_TYPES);
  1301. n = N_weapon_types;
  1302. N_weapon_types++;
  1303. if (unused_flag) {
  1304. clear_to_end_of_line();
  1305. return;
  1306. }
  1307. #ifdef SHAREWARE
  1308. if (Registered_only) {
  1309. clear_to_end_of_line();
  1310. return;
  1311. }
  1312. #endif
  1313. // Initialize weapon array
  1314. Weapon_info[n].render_type = WEAPON_RENDER_NONE; // 0=laser, 1=blob, 2=object
  1315. Weapon_info[n].bitmap.index = 0;
  1316. Weapon_info[n].model_num = -1;
  1317. Weapon_info[n].model_num_inner = -1;
  1318. Weapon_info[n].blob_size = 0x1000; // size of blob
  1319. Weapon_info[n].flash_vclip = -1;
  1320. Weapon_info[n].flash_sound = SOUND_LASER_FIRED;
  1321. Weapon_info[n].flash_size = 0;
  1322. Weapon_info[n].robot_hit_vclip = -1;
  1323. Weapon_info[n].robot_hit_sound = -1;
  1324. Weapon_info[n].wall_hit_vclip = -1;
  1325. Weapon_info[n].wall_hit_sound = -1;
  1326. Weapon_info[n].impact_size = 0;
  1327. for (i=0; i<NDL; i++) {
  1328. Weapon_info[n].strength[i] = F1_0;
  1329. Weapon_info[n].speed[i] = F1_0*10;
  1330. }
  1331. Weapon_info[n].mass = F1_0;
  1332. Weapon_info[n].thrust = 0;
  1333. Weapon_info[n].drag = 0;
  1334. Weapon_info[n].persistent = 0;
  1335. Weapon_info[n].energy_usage = 0; // How much fuel is consumed to fire this weapon.
  1336. Weapon_info[n].ammo_usage = 0; // How many units of ammunition it uses.
  1337. Weapon_info[n].fire_wait = F1_0/4; // Time until this weapon can be fired again.
  1338. Weapon_info[n].fire_count = 1; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired.
  1339. Weapon_info[n].damage_radius = 0; // Radius of damage for missiles, not lasers. Does damage to objects within this radius of hit point.
  1340. //--01/19/95, mk-- Weapon_info[n].damage_force = 0; // Force (movement) due to explosion
  1341. Weapon_info[n].destroyable = 1; // Weapons default to destroyable
  1342. Weapon_info[n].matter = 0; // Weapons default to not being constructed of matter (they are energy!)
  1343. Weapon_info[n].bounce = 0; // Weapons default to not bouncing off walls
  1344. Weapon_info[n].lifetime = WEAPON_DEFAULT_LIFETIME; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired.
  1345. Weapon_info[n].po_len_to_width_ratio = F1_0*10;
  1346. Weapon_info[n].picture.index = 0;
  1347. Weapon_info[n].homing_flag = 0;
  1348. // Process arguments
  1349. arg = strtok( NULL, space );
  1350. lighted = 1; //assume first texture is lighted
  1351. while (arg!=NULL) {
  1352. equal_ptr = strchr( arg, '=' );
  1353. if ( equal_ptr ) {
  1354. *equal_ptr='\0';
  1355. equal_ptr++;
  1356. // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
  1357. if (!stricmp( arg, "laser_bmp" )) {
  1358. // Load bitmap with name equal_ptr
  1359. Weapon_info[n].bitmap = bm_load_sub(equal_ptr); //load_polymodel_bitmap(equal_ptr);
  1360. Weapon_info[n].render_type = WEAPON_RENDER_LASER;
  1361. } else if (!stricmp( arg, "blob_bmp" )) {
  1362. // Load bitmap with name equal_ptr
  1363. Weapon_info[n].bitmap = bm_load_sub(equal_ptr); //load_polymodel_bitmap(equal_ptr);
  1364. Weapon_info[n].render_type = WEAPON_RENDER_BLOB;
  1365. } else if (!stricmp( arg, "weapon_vclip" )) {
  1366. // Set vclip to play for this weapon.
  1367. Weapon_info[n].bitmap.index = 0;
  1368. Weapon_info[n].render_type = WEAPON_RENDER_VCLIP;
  1369. Weapon_info[n].weapon_vclip = atoi(equal_ptr);
  1370. } else if (!stricmp( arg, "none_bmp" )) {
  1371. Weapon_info[n].bitmap = bm_load_sub(equal_ptr);
  1372. Weapon_info[n].render_type = WEAPON_RENDER_NONE;
  1373. } else if (!stricmp( arg, "weapon_pof" )) {
  1374. // Load pof file
  1375. Assert(n_models==0);
  1376. model_name[0] = equal_ptr;
  1377. first_bitmap_num[0] = N_ObjBitmapPtrs;
  1378. n_models=1;
  1379. } else if (!stricmp( arg, "simple_model" )) {
  1380. model_name[n_models] = equal_ptr;
  1381. first_bitmap_num[n_models] = N_ObjBitmapPtrs;
  1382. n_models++;
  1383. } else if (!stricmp( arg, "weapon_pof_inner" )) {
  1384. // Load pof file
  1385. pof_file_inner = equal_ptr;
  1386. } else if (!stricmp( arg, "strength" )) {
  1387. for (i=0; i<NDL-1; i++) {
  1388. Weapon_info[n].strength[i] = i2f(atoi(equal_ptr));
  1389. equal_ptr = strtok(NULL, space);
  1390. }
  1391. Weapon_info[n].strength[i] = i2f(atoi(equal_ptr));
  1392. } else if (!stricmp( arg, "mass" )) {
  1393. Weapon_info[n].mass = fl2f(atof(equal_ptr));
  1394. } else if (!stricmp( arg, "drag" )) {
  1395. Weapon_info[n].drag = fl2f(atof(equal_ptr));
  1396. } else if (!stricmp( arg, "thrust" )) {
  1397. Weapon_info[n].thrust = fl2f(atof(equal_ptr));
  1398. } else if (!stricmp( arg, "matter" )) {
  1399. Weapon_info[n].matter = atoi(equal_ptr);
  1400. } else if (!stricmp( arg, "bounce" )) {
  1401. Weapon_info[n].bounce = atoi(equal_ptr);
  1402. } else if (!stricmp( arg, "speed" )) {
  1403. for (i=0; i<NDL-1; i++) {
  1404. Weapon_info[n].speed[i] = i2f(atoi(equal_ptr));
  1405. equal_ptr = strtok(NULL, space);
  1406. }
  1407. Weapon_info[n].speed[i] = i2f(atoi(equal_ptr));
  1408. } else if (!stricmp( arg, "flash_vclip" )) {
  1409. Weapon_info[n].flash_vclip = atoi(equal_ptr);
  1410. } else if (!stricmp( arg, "flash_sound" )) {
  1411. Weapon_info[n].flash_sound = atoi(equal_ptr);
  1412. } else if (!stricmp( arg, "flash_size" )) {
  1413. Weapon_info[n].flash_size = fl2f(atof(equal_ptr));
  1414. } else if (!stricmp( arg, "blob_size" )) {
  1415. Weapon_info[n].blob_size = fl2f(atof(equal_ptr));
  1416. } else if (!stricmp( arg, "robot_hit_vclip" )) {
  1417. Weapon_info[n].robot_hit_vclip = atoi(equal_ptr);
  1418. } else if (!stricmp( arg, "robot_hit_sound" )) {
  1419. Weapon_info[n].robot_hit_sound = atoi(equal_ptr);
  1420. } else if (!stricmp( arg, "wall_hit_vclip" )) {
  1421. Weapon_info[n].wall_hit_vclip = atoi(equal_ptr);
  1422. } else if (!stricmp( arg, "wall_hit_sound" )) {
  1423. Weapon_info[n].wall_hit_sound = atoi(equal_ptr);
  1424. } else if (!stricmp( arg, "impact_size" )) {
  1425. Weapon_info[n].impact_size = fl2f(atof(equal_ptr));
  1426. } else if (!stricmp( arg, "lighted" )) {
  1427. lighted = atoi(equal_ptr);
  1428. } else if (!stricmp( arg, "lw_ratio" )) {
  1429. Weapon_info[n].po_len_to_width_ratio = fl2f(atof(equal_ptr));
  1430. } else if (!stricmp( arg, "lightcast" )) {
  1431. Weapon_info[n].light = fl2f(atof(equal_ptr));
  1432. } else if (!stricmp( arg, "persistent" )) {
  1433. Weapon_info[n].persistent = atoi(equal_ptr);
  1434. } else if (!stricmp(arg, "energy_usage" )) {
  1435. Weapon_info[n].energy_usage = fl2f(atof(equal_ptr));
  1436. } else if (!stricmp(arg, "ammo_usage" )) {
  1437. Weapon_info[n].ammo_usage = atoi(equal_ptr);
  1438. } else if (!stricmp(arg, "fire_wait" )) {
  1439. Weapon_info[n].fire_wait = fl2f(atof(equal_ptr));
  1440. } else if (!stricmp(arg, "fire_count" )) {
  1441. Weapon_info[n].fire_count = atoi(equal_ptr);
  1442. } else if (!stricmp(arg, "damage_radius" )) {
  1443. Weapon_info[n].damage_radius = fl2f(atof(equal_ptr));
  1444. //--01/19/95, mk-- } else if (!stricmp(arg, "damage_force" )) {
  1445. //--01/19/95, mk-- Weapon_info[n].damage_force = fl2f(atof(equal_ptr));
  1446. } else if (!stricmp(arg, "lifetime" )) {
  1447. Weapon_info[n].lifetime = fl2f(atof(equal_ptr));
  1448. } else if (!stricmp(arg, "destroyable" )) {
  1449. Weapon_info[n].destroyable = atoi(equal_ptr);
  1450. } else if (!stricmp(arg, "picture" )) {
  1451. Weapon_info[n].picture = bm_load_sub(equal_ptr);
  1452. } else if (!stricmp(arg, "homing" )) {
  1453. Weapon_info[n].homing_flag = !!atoi(equal_ptr);
  1454. } else {
  1455. mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
  1456. }
  1457. } else { // Must be a texture specification...
  1458. grs_bitmap *bm;
  1459. bm = load_polymodel_bitmap(arg);
  1460. if (! lighted)
  1461. bm->bm_flags |= BM_FLAG_NO_LIGHTING;
  1462. lighted = 1; //default for next bitmap is lighted
  1463. }
  1464. arg = strtok( NULL, space );
  1465. }
  1466. first_bitmap_num[n_models] = N_ObjBitmapPtrs;
  1467. for (i=0;i<n_models;i++) {
  1468. int n_textures;
  1469. int model_num,last_model_num;
  1470. n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
  1471. model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],NULL);
  1472. if (i==0) {
  1473. Weapon_info[n].render_type = WEAPON_RENDER_POLYMODEL;
  1474. Weapon_info[n].model_num = model_num;
  1475. }
  1476. else
  1477. Polygon_models[last_model_num].simpler_model = model_num+1;
  1478. last_model_num = model_num;
  1479. }
  1480. if ( pof_file_inner ) {
  1481. Assert(n_models);
  1482. Weapon_info[n].model_num_inner = load_polygon_model(pof_file_inner,first_bitmap_num[1]-first_bitmap_num[0],first_bitmap_num[0],NULL);
  1483. }
  1484. if ((Weapon_info[n].ammo_usage == 0) && (Weapon_info[n].energy_usage == 0))
  1485. mprintf((1, "Warning: Weapon %i has ammo and energy usage of 0.\n", n));
  1486. // -- render type of none is now legal -- Assert( Weapon_info[n].render_type != WEAPON_RENDER_NONE );
  1487. }
  1488. // ------------------------------------------------------------------------------
  1489. #define DEFAULT_POWERUP_SIZE i2f(3)
  1490. void bm_read_powerup(int unused_flag)
  1491. {
  1492. int n;
  1493. char *equal_ptr;
  1494. Assert(N_powerup_types < MAX_POWERUP_TYPES);
  1495. n = N_powerup_types;
  1496. N_powerup_types++;
  1497. if (unused_flag) {
  1498. clear_to_end_of_line();
  1499. return;
  1500. }
  1501. // Initialize powerup array
  1502. Powerup_info[n].light = F1_0/3; // Default lighting value.
  1503. Powerup_info[n].vclip_num = -1;
  1504. Powerup_info[n].hit_sound = -1;
  1505. Powerup_info[n].size = DEFAULT_POWERUP_SIZE;
  1506. Powerup_names[n][0] = 0;
  1507. // Process arguments
  1508. arg = strtok( NULL, space );
  1509. while (arg!=NULL) {
  1510. equal_ptr = strchr( arg, '=' );
  1511. if ( equal_ptr ) {
  1512. *equal_ptr='\0';
  1513. equal_ptr++;
  1514. // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
  1515. if (!stricmp( arg, "vclip_num" )) {
  1516. Powerup_info[n].vclip_num = atoi(equal_ptr);
  1517. } else if (!stricmp( arg, "light" )) {
  1518. Powerup_info[n].light = fl2f(atof(equal_ptr));
  1519. } else if (!stricmp( arg, "hit_sound" )) {
  1520. Powerup_info[n].hit_sound = atoi(equal_ptr);
  1521. } else if (!stricmp( arg, "name" )) {
  1522. Assert(strlen(equal_ptr) < POWERUP_NAME_LENGTH); // Oops, name too long.
  1523. strcpy(Powerup_names[n], &equal_ptr[1]);
  1524. Powerup_names[n][strlen(Powerup_names[n])-1] = 0;
  1525. } else if (!stricmp( arg, "size" )) {
  1526. Powerup_info[n].size = fl2f(atof(equal_ptr));
  1527. } else {
  1528. mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
  1529. }
  1530. } else { // Must be a texture specification...
  1531. mprintf( (1, "Invalid argument, %s in bitmaps.tbl\n", arg ));
  1532. }
  1533. arg = strtok( NULL, space );
  1534. }
  1535. ObjType[Num_total_object_types] = OL_POWERUP;
  1536. ObjId[Num_total_object_types] = n;
  1537. //printf( "Object type %d is a powerup\n", Num_total_object_types );
  1538. Num_total_object_types++;
  1539. }
  1540. void bm_read_hostage()
  1541. {
  1542. int n;
  1543. char *equal_ptr;
  1544. Assert(N_hostage_types < MAX_HOSTAGE_TYPES);
  1545. n = N_hostage_types;
  1546. N_hostage_types++;
  1547. // Process arguments
  1548. arg = strtok( NULL, space );
  1549. while (arg!=NULL) {
  1550. equal_ptr = strchr( arg, '=' );
  1551. if ( equal_ptr ) {
  1552. *equal_ptr='\0';
  1553. equal_ptr++;
  1554. if (!stricmp( arg, "vclip_num" ))
  1555. Hostage_vclip_num[n] = atoi(equal_ptr);
  1556. else
  1557. mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
  1558. } else
  1559. mprintf( (1, "Invalid argument, %s in bitmaps.tbl at line %d\n", arg, linenum ));
  1560. arg = strtok( NULL, space );
  1561. }
  1562. ObjType[Num_total_object_types] = OL_HOSTAGE;
  1563. ObjId[Num_total_object_types] = n;
  1564. //printf( "Object type %d is a hostage\n", Num_total_object_types );
  1565. Num_total_object_types++;
  1566. }
  1567. void bm_read_hostage_face()
  1568. {
  1569. char *abm_name,*equal_ptr;
  1570. int clip_num=-1,sound_num=-1;
  1571. fix time;
  1572. abm_name = strtok( NULL, space );
  1573. arg = strtok( NULL, space );
  1574. while (arg!=NULL) {
  1575. equal_ptr = strchr( arg, '=' );
  1576. if ( equal_ptr ) {
  1577. *equal_ptr='\0';
  1578. equal_ptr++;
  1579. // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
  1580. if (!stricmp( arg, "clip_num" )) {
  1581. clip_num = atoi(equal_ptr);
  1582. } else if (!stricmp( arg, "time" )) {
  1583. time = fl2f(atof(equal_ptr));
  1584. } else if (!stricmp( arg, "sound_num" )) {
  1585. sound_num = atoi(equal_ptr);
  1586. }
  1587. }
  1588. arg = strtok( NULL, space );
  1589. }
  1590. #ifndef SHAREWARE
  1591. Assert(clip_num>=0 && clip_num<MAX_HOSTAGES);
  1592. ab_load( abm_name, Hostage_face_clip[clip_num].frames, &Hostage_face_clip[clip_num].num_frames );
  1593. Assert(Hostage_face_clip[clip_num].num_frames < MAX_BITMAPS_PER_BRUSH);
  1594. Hostage_face_clip[clip_num].play_time = time;
  1595. Hostage_face_clip[clip_num].sound_num = sound_num;
  1596. Hostage_face_clip[clip_num].frame_time = time/Hostage_face_clip[clip_num].num_frames;
  1597. #endif
  1598. }
  1599. void bm_write_all(FILE *fp)
  1600. {
  1601. int i;
  1602. fwrite( &NumTextures, sizeof(int), 1, fp );
  1603. fwrite( Textures, sizeof(bitmap_index), MAX_TEXTURES, fp );
  1604. fwrite( TmapInfo, sizeof(tmap_info), MAX_TEXTURES, fp );
  1605. fwrite( Sounds, sizeof(ubyte), MAX_SOUNDS, fp );
  1606. fwrite( AltSounds, sizeof(ubyte), MAX_SOUNDS, fp );
  1607. fwrite( &Num_vclips, sizeof(int), 1, fp );
  1608. fwrite( Vclip, sizeof(vclip), VCLIP_MAXNUM, fp );
  1609. fwrite( &Num_effects, sizeof(int), 1, fp );
  1610. fwrite( Effects, sizeof(eclip), MAX_EFFECTS, fp );
  1611. fwrite( &Num_wall_anims, sizeof(int), 1, fp );
  1612. fwrite( WallAnims, sizeof(wclip), MAX_WALL_ANIMS, fp );
  1613. fwrite( &N_robot_types, sizeof(int), 1, fp );
  1614. fwrite( Robot_info, sizeof(robot_info), MAX_ROBOT_TYPES, fp );
  1615. fwrite( &N_robot_joints, sizeof(int), 1, fp );
  1616. fwrite( Robot_joints, sizeof(jointpos), MAX_ROBOT_JOINTS, fp );
  1617. fwrite( &N_weapon_types, sizeof(int), 1, fp );
  1618. fwrite( Weapon_info, sizeof(weapon_info), MAX_WEAPON_TYPES, fp );
  1619. fwrite( &N_powerup_types, sizeof(int), 1, fp );
  1620. fwrite( Powerup_info, sizeof(powerup_type_info), MAX_POWERUP_TYPES, fp );
  1621. fwrite( &N_polygon_models, sizeof(int), 1, fp );
  1622. fwrite( Polygon_models, sizeof(polymodel), N_polygon_models, fp );
  1623. for (i=0; i<N_polygon_models; i++ ) {
  1624. fwrite( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
  1625. }
  1626. fwrite( Gauges, sizeof(bitmap_index), MAX_GAUGE_BMS, fp );
  1627. fwrite( Dying_modelnums, sizeof(int), MAX_POLYGON_MODELS, fp );
  1628. fwrite( Dead_modelnums, sizeof(int), MAX_POLYGON_MODELS, fp );
  1629. fwrite( ObjBitmaps, sizeof(bitmap_index), MAX_OBJ_BITMAPS, fp );
  1630. fwrite( ObjBitmapPtrs, sizeof(ushort), MAX_OBJ_BITMAPS, fp );
  1631. fwrite( &only_player_ship, sizeof(player_ship), 1, fp );
  1632. fwrite( &Num_cockpits, sizeof(int), 1, fp );
  1633. fwrite( cockpit_bitmap, sizeof(bitmap_index), N_COCKPIT_BITMAPS, fp );
  1634. fwrite( Sounds, sizeof(ubyte), MAX_SOUNDS, fp );
  1635. fwrite( AltSounds, sizeof(ubyte), MAX_SOUNDS, fp );
  1636. fwrite( &Num_total_object_types, sizeof(int), 1, fp );
  1637. fwrite( ObjType, sizeof(byte), MAX_OBJTYPE, fp );
  1638. fwrite( ObjId, sizeof(byte), MAX_OBJTYPE, fp );
  1639. fwrite( ObjStrength, sizeof(fix), MAX_OBJTYPE, fp );
  1640. fwrite( &First_multi_bitmap_num, sizeof(int), 1, fp );
  1641. fwrite( &N_controlcen_guns, sizeof(int), 1, fp );
  1642. fwrite( controlcen_gun_points, sizeof(vms_vector), MAX_CONTROLCEN_GUNS, fp );
  1643. fwrite( controlcen_gun_dirs, sizeof(vms_vector), MAX_CONTROLCEN_GUNS, fp );
  1644. fwrite( &exit_modelnum, sizeof(int), 1, fp );
  1645. fwrite( &destroyed_exit_modelnum, sizeof(int), 1, fp );
  1646. }
  1647. #endif
  1648.