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.
16 * Functions to change entire mines.
36 #include "texpage.h" // For texpage_goto_first
46 #define MINESAVE_CRIPPLED 0
48 char mine_filename[PATH_MAX] = "*.MIN";
49 char sit_filename[PATH_MAX] = "*.SIT";
51 #define MAX_NAME_LENGTH PATH_MAX
53 // See if filename f contains an extent. If not, add extent ext.
54 void checkforext( char * f, char *ext )
58 for (i=1; i<MAX_NAME_LENGTH; i++ ) {
62 if ((f[i] == ' ') || (f[i]==0) ) {
82 // See if filename f contains an extent. If not, add extent ext.
83 void set_extension( char * f, char *ext )
87 for (i=1; i<MAX_NAME_LENGTH-4; i++ ) {
88 if ((f[i]=='.') || (f[i] == ' ') || (f[i]==0) ) {
102 char ErrorMessage[200];
104 sprintf( ErrorMessage, "Save Mine not available in demo version.\n");
105 MessageBox( -2, -2, 1, ErrorMessage, "Ok" );
110 #if !MINESAVE_CRIPPLED
114 // med_save_mine("TEMP.MIN");
115 if (ui_get_filename( mine_filename, "*.MIN", "SAVE MINE" ))
117 checkforext(mine_filename, "MIN");
118 if (med_save_mine(mine_filename))
130 texpage_goto_first();
132 LargeView.ev_matrix = vmd_identity_matrix; //FrontView.ev_matrix;
133 set_view_target_from_segment(Cursegp);
134 vm_vec_make(&Seg_scale,DEFAULT_X_SIZE,DEFAULT_Y_SIZE,DEFAULT_Z_SIZE);
135 Update_flags = UF_WORLD_CHANGED;
136 SetPlayerFromCurseg();
137 SetPlayerPosition(); //say default is permanant position
142 gamestate_not_restored = 0;
145 Game_mode = GM_UNKNOWN;
146 Current_level_num = 0; //0 means not a real game
154 char * MenuItems[] = { "New mine",
160 x = MenuX( -1, -1, 5, MenuItems );
176 Update_flags = UF_ALL;
182 // -----------------------------------------------------------------------------
183 // returns 1 if error, else 0
184 int med_load_situation(char * filename)
186 if (filename[0] == 97)
191 //@@ CFILE * LoadFile;
192 //@@ char mine_name[MAX_NAME_LENGTH];
193 //@@ char dir_name[_MAX_DIR];
194 //@@ char mine_path[MAX_NAME_LENGTH];
198 //@@ LoadFile = cfopen( filename, "rt" );
199 //@@ if (!LoadFile) {
200 //@@ char ErrorMessage[200];
202 //@@ sprintf( ErrorMessage, "ERROR: Unable to open %s\n", filename );
203 //@@ MessageBox( -2, -2, 1, ErrorMessage, "Ok" );
207 //@@ fscanf(LoadFile, "%s", &mine_name);
208 //@@ mprintf((0, "Mine name = [%s]\n", mine_name));
210 //@@ _splitpath(filename,mine_path,dir_name,NULL,NULL);
211 //@@ strcat(mine_path,dir_name);
212 //@@ strcat(mine_path,mine_name);
214 //@@ mprintf((0, "Mine path = [%s]\n", mine_path));
216 //@@ med_load_mine(mine_path);
218 //@@ fscanf(LoadFile, "%x %x %x", &pos.x, &pos.y, &pos.z);
219 //@@ mprintf((0, "Load Position = %8x %8x %8x\n", pos.x, pos.y, pos.z));
220 //@@ mprintf((0, "\n"));
222 //@@ fscanf(LoadFile, "%x %x %x", &mat[0], &mat[1], &mat[2]);
223 //@@ mprintf((0, "%8x %8x %8x\n", mat[0], mat[1], mat[2]));
225 //@@ fscanf(LoadFile, "%x %x %x", &mat[3], &mat[4], &mat[5]);
226 //@@ mprintf((0, "%8x %8x %8x\n", mat[3], mat[4], mat[5]));
228 //@@ fscanf(LoadFile, "%x %x %x", &mat[6], &mat[7], &mat[8]);
229 //@@ mprintf((0, "%8x %8x %8x\n", mat[6], mat[7], mat[8]));
230 //@@ mprintf((0, "\n"));
232 //@@ fscanf(LoadFile, "%i\n", &ConsoleObject->segnum);
234 //@@ cfclose( LoadFile );
236 //@@ ConsoleObject->pos = pos;
237 //@@ ConsoleObject->orient.m1 = mat[0]; ConsoleObject->orient.m2 = mat[1]; ConsoleObject->orient.m3 = mat[2];
238 //@@ ConsoleObject->orient.m4 = mat[3]; ConsoleObject->orient.m5 = mat[4]; ConsoleObject->orient.m6 = mat[5];
239 //@@ ConsoleObject->orient.m7 = mat[6]; ConsoleObject->orient.m8 = mat[7]; ConsoleObject->orient.m9 = mat[8];
244 // -----------------------------------------------------------------------------
245 int med_save_situation(char * filename)
248 char mine_name[MAX_NAME_LENGTH];
250 SaveFile = cfopen( filename, "wt" );
252 char ErrorMessage[200];
254 sprintf( ErrorMessage, "ERROR: Unable to open %s\n", filename );
255 MessageBox( -2, -2, 1, ErrorMessage, "Ok" );
260 // strcpy(mine_name, filename);
261 _splitpath(filename, NULL, NULL, mine_name, NULL);
262 set_extension(mine_name, "min");
263 fprintf(SaveFile, "%s\n", mine_name);
265 // Write player position.
266 fprintf(SaveFile, "%x %x %x\n",(unsigned int) ConsoleObject->pos.x,(unsigned int) ConsoleObject->pos.y,(unsigned int) ConsoleObject->pos.z);
268 // Write player orientation.
269 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.rvec.x,(unsigned int) ConsoleObject->orient.rvec.y,(unsigned int) ConsoleObject->orient.rvec.z);
270 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.uvec.x,(unsigned int) ConsoleObject->orient.uvec.y,(unsigned int) ConsoleObject->orient.uvec.z);
271 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.fvec.x,(unsigned int) ConsoleObject->orient.fvec.y,(unsigned int) ConsoleObject->orient.fvec.z);
272 fprintf(SaveFile, "%i\n", ConsoleObject->segnum);
274 mprintf((0, "Save Position = %8x %8x %8x\n", ConsoleObject->pos.x, ConsoleObject->pos.y, ConsoleObject->pos.z));
277 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.rvec.x, ConsoleObject->orient.rvec.y, ConsoleObject->orient.rvec.z));
278 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.uvec.x, ConsoleObject->orient.uvec.y, ConsoleObject->orient.uvec.z));
279 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.fvec.x, ConsoleObject->orient.fvec.y, ConsoleObject->orient.fvec.z));
287 // -----------------------------------------------------------------------------
288 int SaveSituation(void)
290 if (ui_get_filename( sit_filename, "*.SIT", "Save Situation" )) {
291 set_extension(sit_filename, "MIN");
292 if (med_save_mine(sit_filename)) {
293 mprintf((0, "Unable to save mine in SaveSituation.\n"));
297 set_extension(sit_filename, "SIT");
298 if (med_save_situation(sit_filename))
305 // -----------------------------------------------------------------------------
306 // Load a situation file which consists of x,y,z, orientation matrix, mine name.
307 int LoadSituation(void)
310 if (ui_get_filename( sit_filename, "*.sit", "Load Situation" )) {
311 checkforext(sit_filename, "SIT");
312 if (med_load_situation(sit_filename))
314 // set_view_target_from_segment(Cursegp);
315 Update_flags = UF_WORLD_CHANGED;
316 // SetPlayerFromCurseg();