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.
37 #define MINESAVE_CRIPPLED 0
39 char mine_filename[PATH_MAX] = "*.MIN";
40 char sit_filename[PATH_MAX] = "*.SIT";
42 #define MAX_NAME_LENGTH PATH_MAX
44 // See if filename f contains an extent. If not, add extent ext.
45 void checkforext( char * f, char *ext )
49 for (i=1; i<MAX_NAME_LENGTH; i++ ) {
53 if ((f[i] == ' ') || (f[i]==0) ) {
73 // See if filename f contains an extent. If not, add extent ext.
74 void set_extension( char * f, char *ext )
78 for (i=1; i<MAX_NAME_LENGTH-4; i++ ) {
79 if ((f[i]=='.') || (f[i] == ' ') || (f[i]==0) ) {
93 char ErrorMessage[200];
95 sprintf( ErrorMessage, "Save Mine not available in demo version.\n");
96 ui_messagebox( -2, -2, 1, ErrorMessage, "Ok" );
101 #if !MINESAVE_CRIPPLED
105 // med_save_mine("TEMP.MIN");
106 if (ui_get_filename( mine_filename, "*.MIN", "SAVE MINE" ))
108 checkforext(mine_filename, "MIN");
109 if (med_save_mine(mine_filename))
121 texpage_goto_first();
123 LargeView.ev_matrix = vmd_identity_matrix; //FrontView.ev_matrix;
124 set_view_target_from_segment(Cursegp);
125 vm_vec_make(&Seg_scale,DEFAULT_X_SIZE,DEFAULT_Y_SIZE,DEFAULT_Z_SIZE);
126 Update_flags = UF_WORLD_CHANGED;
127 SetPlayerFromCurseg();
128 SetPlayerPosition(); //say default is permanant position
133 gamestate_not_restored = 0;
136 Game_mode = GM_UNKNOWN;
137 Current_level_num = 0; //0 means not a real game
145 char * MenuItems[] = { "New mine",
151 x = MenuX( -1, -1, 5, MenuItems );
167 Update_flags = UF_ALL;
173 // -----------------------------------------------------------------------------
174 // returns 1 if error, else 0
175 int med_load_situation(char * filename)
177 if (filename[0] == 97)
182 //@@ CFILE * LoadFile;
183 //@@ char mine_name[MAX_NAME_LENGTH];
184 //@@ char dir_name[_MAX_DIR];
185 //@@ char mine_path[MAX_NAME_LENGTH];
189 //@@ LoadFile = cfopen( filename, "rt" );
190 //@@ if (!LoadFile) {
191 //@@ char ErrorMessage[200];
193 //@@ sprintf( ErrorMessage, "ERROR: Unable to open %s\n", filename );
194 //@@ MessageBox( -2, -2, 1, ErrorMessage, "Ok" );
198 //@@ fscanf(LoadFile, "%s", &mine_name);
199 //@@ mprintf((0, "Mine name = [%s]\n", mine_name));
201 //@@ _splitpath(filename,mine_path,dir_name,NULL,NULL);
202 //@@ strcat(mine_path,dir_name);
203 //@@ strcat(mine_path,mine_name);
205 //@@ mprintf((0, "Mine path = [%s]\n", mine_path));
207 //@@ med_load_mine(mine_path);
209 //@@ fscanf(LoadFile, "%x %x %x", &pos.x, &pos.y, &pos.z);
210 //@@ mprintf((0, "Load Position = %8x %8x %8x\n", pos.x, pos.y, pos.z));
211 //@@ mprintf((0, "\n"));
213 //@@ fscanf(LoadFile, "%x %x %x", &mat[0], &mat[1], &mat[2]);
214 //@@ mprintf((0, "%8x %8x %8x\n", mat[0], mat[1], mat[2]));
216 //@@ fscanf(LoadFile, "%x %x %x", &mat[3], &mat[4], &mat[5]);
217 //@@ mprintf((0, "%8x %8x %8x\n", mat[3], mat[4], mat[5]));
219 //@@ fscanf(LoadFile, "%x %x %x", &mat[6], &mat[7], &mat[8]);
220 //@@ mprintf((0, "%8x %8x %8x\n", mat[6], mat[7], mat[8]));
221 //@@ mprintf((0, "\n"));
223 //@@ fscanf(LoadFile, "%i\n", &ConsoleObject->segnum);
225 //@@ cfclose( LoadFile );
227 //@@ ConsoleObject->pos = pos;
228 //@@ ConsoleObject->orient.m1 = mat[0]; ConsoleObject->orient.m2 = mat[1]; ConsoleObject->orient.m3 = mat[2];
229 //@@ ConsoleObject->orient.m4 = mat[3]; ConsoleObject->orient.m5 = mat[4]; ConsoleObject->orient.m6 = mat[5];
230 //@@ ConsoleObject->orient.m7 = mat[6]; ConsoleObject->orient.m8 = mat[7]; ConsoleObject->orient.m9 = mat[8];
235 // -----------------------------------------------------------------------------
236 int med_save_situation(char * filename)
239 char mine_name[MAX_NAME_LENGTH];
241 SaveFile = cfopen( filename, "wt" );
243 char ErrorMessage[200];
245 sprintf( ErrorMessage, "ERROR: Unable to open %s\n", filename );
246 ui_messagebox( -2, -2, 1, ErrorMessage, "Ok" );
251 // strcpy(mine_name, filename);
252 _splitpath(filename, NULL, NULL, mine_name, NULL);
253 set_extension(mine_name, "min");
254 fprintf(SaveFile, "%s\n", mine_name);
256 // Write player position.
257 fprintf(SaveFile, "%x %x %x\n",(unsigned int) ConsoleObject->pos.x,(unsigned int) ConsoleObject->pos.y,(unsigned int) ConsoleObject->pos.z);
259 // Write player orientation.
260 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.rvec.x,(unsigned int) ConsoleObject->orient.rvec.y,(unsigned int) ConsoleObject->orient.rvec.z);
261 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.uvec.x,(unsigned int) ConsoleObject->orient.uvec.y,(unsigned int) ConsoleObject->orient.uvec.z);
262 fprintf(SaveFile, "%8x %8x %8x\n",(unsigned int) ConsoleObject->orient.fvec.x,(unsigned int) ConsoleObject->orient.fvec.y,(unsigned int) ConsoleObject->orient.fvec.z);
263 fprintf(SaveFile, "%i\n", ConsoleObject->segnum);
265 mprintf((0, "Save Position = %8x %8x %8x\n", ConsoleObject->pos.x, ConsoleObject->pos.y, ConsoleObject->pos.z));
268 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.rvec.x, ConsoleObject->orient.rvec.y, ConsoleObject->orient.rvec.z));
269 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.uvec.x, ConsoleObject->orient.uvec.y, ConsoleObject->orient.uvec.z));
270 mprintf((0, "%8x %8x %8x\n", ConsoleObject->orient.fvec.x, ConsoleObject->orient.fvec.y, ConsoleObject->orient.fvec.z));
278 // -----------------------------------------------------------------------------
279 int SaveSituation(void)
281 if (ui_get_filename( sit_filename, "*.SIT", "Save Situation" )) {
282 set_extension(sit_filename, "MIN");
283 if (med_save_mine(sit_filename)) {
284 mprintf((0, "Unable to save mine in SaveSituation.\n"));
288 set_extension(sit_filename, "SIT");
289 if (med_save_situation(sit_filename))
296 // -----------------------------------------------------------------------------
297 // Load a situation file which consists of x,y,z, orientation matrix, mine name.
298 int LoadSituation(void)
301 if (ui_get_filename( sit_filename, "*.sit", "Load Situation" )) {
302 checkforext(sit_filename, "SIT");
303 if (med_load_situation(sit_filename))
305 // set_view_target_from_segment(Cursegp);
306 Update_flags = UF_WORLD_CHANGED;
307 // SetPlayerFromCurseg();