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/kgame.c,v $
17 * $Date: 2004-12-19 13:54:27 $
19 * Game Loading editor functions
21 * $Log: not supported by cvs2svn $
22 * Revision 1.1.1.1 1999/06/14 22:03:24 donut
23 * Import of d1x 1.37 source.
25 * Revision 2.0 1995/02/27 11:34:55 john
26 * Version 2.0! No anonymous unions, Watcom 10.0, with no need
29 * Revision 1.25 1995/02/23 10:18:05 allender
30 * fixed parameter mismatch with compute_segment_center
32 * Revision 1.24 1994/11/17 11:38:59 matt
33 * Ripped out code to load old mines
35 * Revision 1.23 1994/11/09 11:58:56 matt
38 * Revision 1.22 1994/10/20 12:48:02 matt
39 * Replaced old save files (MIN/SAV/HOT) with new LVL files
41 * Revision 1.21 1994/10/15 19:08:47 mike
42 * Fix bug if player object out of mine at save.
44 * Revision 1.20 1994/10/13 13:15:43 matt
45 * Properly relink player object when bashed for "permanant" position save
47 * Revision 1.19 1994/10/11 17:07:23 matt
48 * Fixed problem that sometimes caused bad player segnum after compress
50 * Revision 1.18 1994/10/08 17:10:40 matt
51 * Correctly set current_level_num when loading/creating mine in editor
53 * Revision 1.17 1994/09/26 23:46:13 matt
54 * Improved player position save code
56 * Revision 1.16 1994/09/26 23:22:50 matt
57 * Added functions to keep player's starting position from getting messed up
59 * Revision 1.15 1994/09/14 16:50:51 yuan
60 * Added load mine only function
62 * Revision 1.14 1994/07/22 12:36:50 matt
63 * Cleaned up editor/game interactions some more.
65 * Revision 1.13 1994/07/21 17:26:26 matt
66 * When new mine created, the default save filename is now reset
68 * Revision 1.12 1994/06/03 12:27:05 yuan
69 * Fixed restore game state.
72 * Revision 1.11 1994/05/30 11:36:09 yuan
73 * Do gamesave if new mine is loaded and game is entered...
75 * Revision 1.10 1994/05/14 18:00:33 matt
76 * Got rid of externs in source (non-header) files
78 * Revision 1.9 1994/05/10 12:15:44 yuan
79 * Fixed load_game functions to match prototype.
81 * Revision 1.8 1994/05/06 12:52:15 yuan
82 * Adding some gamesave checks...
84 * Revision 1.7 1994/05/04 17:32:05 yuan
85 * med_load_game changed to load_game
86 * med_save_game changed to save_game
91 static char rcsid[] = "$Id: kgame.c,v 1.1 2004-12-19 13:54:27 btb Exp $";
101 #include "gamesave.h"
104 char game_filename[128] = "*.LVL";
106 extern void checkforext( char * f, char *ext );
108 void checkforgamext( char * f )
112 for (i=1; i<strlen(f); i++ )
114 if (f[i]=='.') return;
116 if ((f[i]==' '||f[i]==0) )
138 //these variables store the "permanant" player position, which overrides
139 //whatever the player's position happens to be when the game is saved
140 int Perm_player_segnum=-1; //-1 means position not set
141 vms_vector Perm_player_position;
142 vms_matrix Perm_player_orient;
144 //set the player's "permanant" position from the current position
145 int SetPlayerPosition()
147 Perm_player_position = ConsoleObject->pos;
148 Perm_player_orient = ConsoleObject->orient;
149 Perm_player_segnum = ConsoleObject->segnum;
151 editor_status("Player initial position set");
156 // returns 1 if successful
157 // returns 0 if unsuccessful
162 if (gamestate_not_restored) {
163 sprintf( Message, "Game State has not been restored...\nContinue?\n");
164 if (MessageBox( -2, -2, 2, Message, "NO", "Yes" )==1)
168 if (ui_get_filename( game_filename, "*.LVL", "SAVE GAME" )) {
170 vms_vector save_pos = ConsoleObject->pos;
171 vms_matrix save_orient = ConsoleObject->orient;
172 int save_segnum = ConsoleObject->segnum;
174 checkforgamext(game_filename);
176 if (Perm_player_segnum > Highest_segment_index)
177 Perm_player_segnum = -1;
179 if (Perm_player_segnum!=-1) {
180 if (get_seg_masks(&Perm_player_position,Perm_player_segnum,0).centermask==0) {
181 ConsoleObject->pos = Perm_player_position;
182 obj_relink(ConsoleObject-Objects,Perm_player_segnum);
183 ConsoleObject->orient = Perm_player_orient;
186 Perm_player_segnum=-1; //position was bogus
188 saved_flag=save_level(game_filename);
189 if (Perm_player_segnum!=-1) {
190 int found_save_segnum;
192 if (save_segnum > Highest_segment_index)
195 ConsoleObject->pos = save_pos;
196 found_save_segnum = find_point_seg(&save_pos,save_segnum);
197 if (found_save_segnum == -1) {
198 compute_segment_center(&save_pos, &(Segments[save_segnum]));
199 found_save_segnum = save_segnum;
202 obj_relink(ConsoleObject-Objects,found_save_segnum);
203 ConsoleObject->orient = save_orient;
212 // returns 1 if successful
213 // returns 0 if unsuccessful
217 if (ui_get_filename( game_filename, "*.LVL", "LOAD GAME" ))
219 checkforgamext(game_filename);
220 if (load_level(game_filename))
222 Current_level_num = 0; //not a real level
223 gamestate_not_restored = 0;
224 Update_flags = UF_WORLD_CHANGED;
225 Perm_player_position = ConsoleObject->pos;
226 Perm_player_orient = ConsoleObject->orient;
227 Perm_player_segnum = ConsoleObject->segnum;
233 //called whenever a new mine is created, so new mine doesn't get name
234 //of last saved mine as default
237 strcpy(game_filename,"*.LVL");