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.
14 * $Source: /cvs/cvsroot/d2x/main/editor/kmine.c,v $
17 * $Date: 2004-12-19 13:54:27 $
19 * Functions to change entire mines.
21 * $Log: not supported by cvs2svn $
22 * Revision 1.1.1.1 1999/06/14 22:03:28 donut
23 * Import of d1x 1.37 source.
25 * Revision 2.0 1995/02/27 11:34:22 john
26 * Version 2.0! No anonymous unions, Watcom 10.0, with no need
29 * Revision 1.53 1995/02/22 15:04:52 allender
30 * remove anonymous unions from vecmat stuff
32 * Revision 1.52 1994/11/27 23:17:13 matt
33 * Made changes for new mprintf calling convention
35 * Revision 1.51 1994/11/17 14:48:05 mike
36 * validation functions moved from editor to game.
38 * Revision 1.50 1994/11/17 11:38:49 matt
39 * Ripped out code to load old mines
41 * Revision 1.49 1994/10/08 17:10:22 matt
42 * Correctly set current_level_num when loading/creating mine in editor
44 * Revision 1.48 1994/10/03 11:30:45 matt
45 * Fixed problem with permanant player position when creating a new mine
47 * Revision 1.47 1994/09/29 17:42:19 matt
48 * Cleaned up game_mode a little
50 * Revision 1.46 1994/08/18 10:48:21 john
51 * Cleaned up game sequencing.
53 * Revision 1.45 1994/08/09 16:05:36 john
54 * Added the ability to place players. Made old
55 * Player variable be ConsoleObject.
57 * Revision 1.44 1994/07/22 12:37:06 matt
58 * Cleaned up editor/game interactions some more.
60 * Revision 1.43 1994/07/21 17:26:50 matt
61 * When new mine created, the default save filename is now reset
63 * Revision 1.42 1994/06/08 14:29:25 matt
64 * Took out support for old mine versions
66 * Revision 1.41 1994/06/03 12:28:04 yuan
67 * Fixed game restore state.
69 * Revision 1.40 1994/05/19 12:10:29 matt
70 * Use new vecmat macros and globals
72 * Revision 1.39 1994/05/14 17:17:56 matt
73 * Got rid of externs in source (non-header) files
75 * Revision 1.38 1994/05/12 14:47:47 mike
76 * New previous mine structure and object structure.
78 * Revision 1.37 1994/05/06 12:52:12 yuan
79 * Adding some gamesave checks...
81 * Revision 1.36 1994/05/05 20:37:02 yuan
82 * Added gamesave checks when entering and leaving the game.
84 * Removed Load Game Save Game functions...
85 * Now there is only Load/Save Mine... (equivalent to old Load/Save Game)
87 * Revision 1.35 1994/04/27 22:57:54 matt
88 * Made sit mine load from path of sit file
90 * Revision 1.34 1994/04/21 18:29:55 matt
91 * Don't use same variable for mine filename & sit filename
93 * Revision 1.33 1994/04/21 18:21:43 matt
94 * Strip path from mine filename in sit file
96 * Revision 1.32 1994/04/18 10:54:35 mike
97 * Add situation save/load
99 * Revision 1.31 1994/02/16 16:47:54 yuan
102 * Revision 1.30 1994/02/16 15:22:51 yuan
103 * Checking in for editor make.
105 * Revision 1.29 1994/02/09 15:04:23 yuan
106 * brought back save ability
108 * Revision 1.28 1994/02/08 12:42:45 yuan
111 * Revision 1.27 1994/02/08 12:41:47 yuan
112 * Crippled save mine function from demo version.
114 * Revision 1.26 1994/01/13 13:26:05 yuan
115 * Added med_compress_mine when creating new mine or
118 * Revision 1.25 1994/01/11 12:03:23 yuan
119 * Fixed so that when old mine implementation not in,
120 * message is displayed when you try to load an old mine
122 * Revision 1.24 1994/01/11 11:47:57 yuan
123 * *** empty log message ***
125 * Revision 1.23 1994/01/05 09:59:56 yuan
126 * Added load old mine funciton
128 * Revision 1.22 1993/12/16 15:58:08 john
129 * moved texture selection page to texpage.c
132 * Revision 1.21 1993/12/10 14:48:55 mike
133 * Kill orthogonal views.
135 * Revision 1.20 1993/12/03 16:44:06 yuan
136 * Changed some 0.0 return values to 0
139 * Revision 1.19 1993/12/02 12:39:34 matt
140 * Removed extra includes
142 * Revision 1.18 1993/11/17 13:14:48 yuan
143 * Moved Save Group to group.c
145 * Revision 1.17 1993/11/16 17:25:48 yuan
146 * Unworking group function added...
148 * Revision 1.16 1993/11/15 14:46:25 john
149 * Changed Menu to MenuX
151 * Revision 1.15 1993/11/08 19:13:45 yuan
152 * Added Undo command (not working yet)
157 static char rcsid[] = "$Id: kmine.c,v 1.1 2004-12-19 13:54:27 btb Exp $";
169 #include "texpage.h" // For texpage_goto_first
181 #define MINESAVE_CRIPPLED 0
183 char mine_filename[128] = "*.MIN";
184 char sit_filename[128] = "*.SIT";
186 #define MAX_NAME_LENGTH 128
188 // See if filename f contains an extent. If not, add extent ext.
189 void checkforext( char * f, char *ext )
193 for (i=1; i<MAX_NAME_LENGTH; i++ ) {
197 if ((f[i] == ' ') || (f[i]==0) ) {
217 // See if filename f contains an extent. If not, add extent ext.
218 void set_extension( char * f, char *ext )
222 for (i=1; i<MAX_NAME_LENGTH-4; i++ ) {
223 if ((f[i]=='.') || (f[i] == ' ') || (f[i]==0) ) {
234 #if MINESAVE_CRIPPLED
237 char ErrorMessage[200];
239 sprintf( ErrorMessage, "Save Mine not available in demo version.\n");
240 MessageBox( -2, -2, 1, ErrorMessage, "Ok" );
245 #if !MINESAVE_CRIPPLED
249 // med_save_mine("TEMP.MIN");
250 if (ui_get_filename( mine_filename, "*.MIN", "SAVE MINE" ))
252 checkforext(mine_filename, "MIN");
253 if (med_save_mine(mine_filename))
265 texpage_goto_first();
267 LargeView.ev_matrix = vmd_identity_matrix; //FrontView.ev_matrix;
268 set_view_target_from_segment(Cursegp);
269 vm_vec_make(&Seg_scale,DEFAULT_X_SIZE,DEFAULT_Y_SIZE,DEFAULT_Z_SIZE);
270 Update_flags = UF_WORLD_CHANGED;
271 SetPlayerFromCurseg();
272 SetPlayerPosition(); //say default is permanant position
277 gamestate_not_restored = 0;
280 Game_mode = GM_UNKNOWN;
281 Current_level_num = 0; //0 means not a real game
289 char * MenuItems[] = { "New mine",
295 x = MenuX( -1, -1, 5, MenuItems );
311 Update_flags = UF_ALL;
317 // -----------------------------------------------------------------------------
318 // returns 1 if error, else 0
319 int med_load_situation(char * filename)
321 if (filename[0] == 97)
326 //@@ CFILE * LoadFile;
327 //@@ char mine_name[MAX_NAME_LENGTH];
328 //@@ char dir_name[_MAX_DIR];
329 //@@ char mine_path[MAX_NAME_LENGTH];
333 //@@ LoadFile = cfopen( filename, "rt" );
334 //@@ if (!LoadFile) {
335 //@@ char ErrorMessage[200];
337 //@@ sprintf( ErrorMessage, "ERROR: Unable to open %s\n", filename );
338 //@@ MessageBox( -2, -2, 1, ErrorMessage, "Ok" );
342 //@@ fscanf(LoadFile, "%s", &mine_name);
343 //@@ mprintf((0, "Mine name = [%s]\n", mine_name));
345 //@@ _splitpath(filename,mine_path,dir_name,NULL,NULL);
346 //@@ strcat(mine_path,dir_name);
347 //@@ strcat(mine_path,mine_name);
349 //@@ mprintf((0, "Mine path = [%s]\n", mine_path));
351 //@@ med_load_mine(mine_path);
353 //@@ fscanf(LoadFile, "%x %x %x", &pos.x, &pos.y, &pos.z);
354 //@@ mprintf((0, "Load Position = %8x %8x %8x\n", pos.x, pos.y, pos.z));
355 //@@ mprintf((0, "\n"));
357 //@@ fscanf(LoadFile, "%x %x %x", &mat[0], &mat[1], &mat[2]);
358 //@@ mprintf((0, "%8x %8x %8x\n", mat[0], mat[1], mat[2]));
360 //@@ fscanf(LoadFile, "%x %x %x", &mat[3], &mat[4], &mat[5]);
361 //@@ mprintf((0, "%8x %8x %8x\n", mat[3], mat[4], mat[5]));
363 //@@ fscanf(LoadFile, "%x %x %x", &mat[6], &mat[7], &mat[8]);
364 //@@ mprintf((0, "%8x %8x %8x\n", mat[6], mat[7], mat[8]));
365 //@@ mprintf((0, "\n"));
367 //@@ fscanf(LoadFile, "%i\n", &ConsoleObject->segnum);
369 //@@ cfclose( LoadFile );
371 //@@ ConsoleObject->pos = pos;
372 //@@ ConsoleObject->orient.m1 = mat[0]; ConsoleObject->orient.m2 = mat[1]; ConsoleObject->orient.m3 = mat[2];
373 //@@ ConsoleObject->orient.m4 = mat[3]; ConsoleObject->orient.m5 = mat[4]; ConsoleObject->orient.m6 = mat[5];
374 //@@ ConsoleObject->orient.m7 = mat[6]; ConsoleObject->orient.m8 = mat[7]; ConsoleObject->orient.m9 = mat[8];
379 // -----------------------------------------------------------------------------
380 int med_save_situation(char * filename)
383 char mine_name[MAX_NAME_LENGTH];
385 SaveFile = cfopen( filename, "wt" );
387 char ErrorMessage[200];
389 sprintf( ErrorMessage, "ERROR: Unable to open %s\n", filename );
390 MessageBox( -2, -2, 1, ErrorMessage, "Ok" );
395 // strcpy(mine_name, filename);
397 _splitpath(filename,NULL,NULL,mine_name,NULL);
399 set_extension(mine_name, "min");
400 fprintf(SaveFile, "%s\n", mine_name);
402 // Write player position.
403 fprintf(SaveFile, "%x %x %x\n",(unsigned int) ConsoleObject->pos.x,(unsigned int) ConsoleObject->pos.y,(unsigned int) ConsoleObject->pos.z);
405 // Write player orientation.
406 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.rvec.x,(unsigned int) ConsoleObject->orient.rvec.y,(unsigned int) ConsoleObject->orient.rvec.z);
407 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.uvec.x,(unsigned int) ConsoleObject->orient.uvec.y,(unsigned int) ConsoleObject->orient.uvec.z);
408 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.fvec.x,(unsigned int) ConsoleObject->orient.fvec.y,(unsigned int) ConsoleObject->orient.fvec.z);
409 fprintf(SaveFile, "%i\n", ConsoleObject->segnum);
411 mprintf((0, "Save Position = %8x %8x %8x\n", ConsoleObject->pos.x, ConsoleObject->pos.y, ConsoleObject->pos.z));
414 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.rvec.x, ConsoleObject->orient.rvec.y, ConsoleObject->orient.rvec.z));
415 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.uvec.x, ConsoleObject->orient.uvec.y, ConsoleObject->orient.uvec.z));
416 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.fvec.x, ConsoleObject->orient.fvec.y, ConsoleObject->orient.fvec.z));
424 // -----------------------------------------------------------------------------
425 int SaveSituation(void)
427 if (ui_get_filename( sit_filename, "*.SIT", "Save Situation" )) {
428 set_extension(sit_filename, "MIN");
429 if (med_save_mine(sit_filename)) {
430 mprintf((0, "Unable to save mine in SaveSituation.\n"));
434 set_extension(sit_filename, "SIT");
435 if (med_save_situation(sit_filename))
442 // -----------------------------------------------------------------------------
443 // Load a situation file which consists of x,y,z, orientation matrix, mine name.
444 int LoadSituation(void)
447 if (ui_get_filename( sit_filename, "*.sit", "Load Situation" )) {
448 checkforext(sit_filename, "SIT");
449 if (med_load_situation(sit_filename))
451 // set_view_target_from_segment(Cursegp);
452 Update_flags = UF_WORLD_CHANGED;
453 // SetPlayerFromCurseg();