allow the editor to be built with NDEBUG
[btb/d2x.git] / main / editor / kfuncs.c
1 /* $Id: kfuncs.c,v 1.5 2006-03-05 12:19:57 chris Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * .
18  *
19  */
20
21 #ifdef RCS
22 static char rcsid[] = "$Id: kfuncs.c,v 1.5 2006-03-05 12:19:57 chris Exp $";
23 #endif
24
25 #ifdef HAVE_CONFIG_H
26 #include "conf.h"
27 #endif
28
29 #include <stdlib.h>
30
31 #include "inferno.h"
32 #include "func.h"
33 #include "editor/kdefs.h"
34 #include "segment.h"
35 #include "editor/editor.h"
36 #include "error.h"
37 #include "slew.h"
38 #include "mono.h"
39 #include "gamesave.h"
40 #include "editor/eobject.h"
41 #include "editor/medwall.h"
42
43 // Test function prototypes (replace Test1, 2 and 3 with whatever function 
44 //                                                                              you wish to test.)
45 extern void test_create_path();
46 extern void test_create_all_paths();
47 extern void test_create_path_many();
48 extern void create_all_paths();
49 extern void test_create_all_anchors();
50 // extern void make_curside_bottom_side();
51 extern void move_object_to_mouse_click();
52 extern void test_create_n_segment_path();
53
54 extern void set_all_modes_to_hover(void);
55
56 extern void check_for_overlapping_segments(void);
57 extern void init_replacements();
58
59 extern void do_replacements(void);
60 extern void do_replacements_all(void);
61
62 int Test1() 
63 {
64 //      { int i;
65 //              for (i=Highest_segment_index+1; i<MAX_SEGMENTS; i++)
66 //                      Segments[i].segnum = -1;
67 //      }
68
69         mprintf((0, "Initializing replacement list.\n"));
70         init_replacements();
71
72         return 0;
73 }
74
75 int Test2() 
76 {
77 //      mprintf((0, "\nCalling check_for_overlapping_segments.\n"));
78 //      check_for_overlapping_segments();
79
80         mprintf((0, "Going to do texture replacements.\n"));
81         do_replacements();
82
83         return 0;
84 }
85
86 //extern fix fcd_test(void);
87 //extern void test_shortpos(void);
88
89 int Test3()
90 {
91         Int3(); //      Are you sure you want to do this?
92         //      This will replace all textures in your replacement list
93         //      in all mines.
94         //      If you don't want to do this, set eip to the return statement
95         //      and continue.
96
97         mprintf((0, "Going to do texture replacements.\n"));
98         do_replacements_all();
99
100         return 0;
101 }
102
103 FUNCTION med_functions[] = {
104
105 // Test functions
106 {   "med-test-1",                         0,    Test1 },
107 {   "med-test-2",                         0,    Test2 },
108 {   "med-test-3",                         0,    Test3 },
109
110 // In khelp.c
111 {   "med-help",                         0,      DoHelp },
112
113 // In kcurve.c
114 {   "med-curve-init",                   0,      InitCurve },
115 {   "med-curve-generate",               0,      GenerateCurve },
116 {   "med-curve-decrease-r4",            0,      DecreaseR4 },
117 {   "med-curve-increase-r4",            0,      IncreaseR4 },
118 {   "med-curve-decrease-r1",            0,      DecreaseR1 },
119 {   "med-curve-increase-r1",            0,      IncreaseR1 },
120 {   "med-curve-delete",                 0,      DeleteCurve },
121 {   "med-curve-set",                    0,      SetCurve },
122
123 // In kmine.c
124 {   "med-mine-save",                    0,      SaveMine },
125 //{   "med-mine-load",                    0,      LoadMine },
126 {   "med-mine-menu",                    0,      MineMenu },
127 {   "med-mine-create-new",              0,      CreateNewMine },
128 //{      "med-mine-load-old",                                    0,             LoadOldMine },                  
129 {   "med-situation-save",               0,      SaveSituation },
130 {   "med-situation-load",               0,      LoadSituation },
131 {        "med-restore-game-state",                               0,             RestoreGameState },
132 //{   "load-mine-only",                    0,      LoadMineOnly   },
133
134 // In kgame.c
135 {   "med-game-save",                    0,      SaveGameData },
136 {   "med-game-load",                    0,      LoadGameData },
137
138 // In kview.c
139 {   "med-view-zoom-out",                0,      ZoomOut },
140 {   "med-view-zoom-in",                 0,      ZoomIn },
141 {   "med-view-move-away",               0,      MoveAway },
142 {   "med-view-move-closer",             0,      MoveCloser },
143 {   "med-view-toggle-chase",            0,      ToggleChaseMode },
144
145 // In kbuild.c
146 {   "med-build-bridge",                 0,      CreateBridge },
147 {   "med-build-joint",                  0,      FormJoint },
148 {   "med-build-adj-joint",              0,      CreateAdjacentJoint },
149 {   "med-build-sloppy-adj-joint",       0,      CreateSloppyAdjacentJoint },
150 {   "med-build-sloppy-adj-joint-group", 0,      CreateSloppyAdjacentJointsGroup },
151 {   "med-build-adj-joints-segment",     0,      CreateAdjacentJointsSegment },
152 {   "med-build-adj-joints-all",         0,      CreateAdjacentJointsAll },
153
154 // In segment.c
155 {   "med-segment-bottom",                        0,      ToggleBottom }, //make_curside_bottom_side },
156 {   "med-segment-show-bottom",          0,      ToggleBottom },
157
158 // In ksegmove.c
159 {   "med-segmove-decrease-heading",     0,      DecreaseHeading },
160 {   "med-segmove-increase-heading",     0,      IncreaseHeading },
161 {   "med-segmove-decrease-pitch",       0,      DecreasePitch },
162 {   "med-segmove-increase-pitch",       0,      IncreasePitch },
163 {   "med-segmove-decrease-bank",        0,      DecreaseBank },
164 {   "med-segmove-increase-bank",        0,      IncreaseBank },
165
166 // In ksegsel.c
167 {   "med-segsel-next-segment",          0,      SelectCurrentSegForward },
168 {   "med-segsel-prev-segment",          0,      SelectCurrentSegBackward },
169 {   "med-segsel-next-side",             0,      SelectNextSide },
170 {   "med-segsel-prev-side",             0,      SelectPrevSide },
171 {   "med-segsel-set-marked",            0,      CopySegToMarked },
172 {   "med-segsel-bottom",                0,      SelectBottom },
173 {   "med-segsel-front",                 0,      SelectFront },
174 {   "med-segsel-top",                   0,      SelectTop },
175 {   "med-segsel-back",                  0,      SelectBack },
176 {   "med-segsel-left",                  0,      SelectLeft },
177 {   "med-segsel-right",                 0,      SelectRight },
178
179 // In ksegsize.c
180 {   "med-segsize-increase-length",      0,      IncreaseSegLength },
181 {   "med-segsize-decrease-length",      0,      DecreaseSegLength },
182 {   "med-segsize-decrease-width",       0,      DecreaseSegWidth },
183 {   "med-segsize-increase-width",       0,      IncreaseSegWidth },
184 {   "med-segsize-increase-height",      0,      IncreaseSegHeight },
185 {   "med-segsize-decrease-height",      0,      DecreaseSegHeight },
186
187 {   "med-segsize-increase-length-big",  0,      IncreaseSegLengthBig },
188 {   "med-segsize-decrease-length-big",  0,      DecreaseSegLengthBig },
189 {   "med-segsize-decrease-width-big",   0,      DecreaseSegWidthBig },
190 {   "med-segsize-increase-width-big",   0,      IncreaseSegWidthBig },
191 {   "med-segsize-increase-height-big",  0,      IncreaseSegHeightBig },
192 {   "med-segsize-decrease-height-big",  0,      DecreaseSegHeightBig },
193 {   "med-segsize-toggle-mode",                           0,      ToggleSegSizeMode },
194 {   "med-segsize-perturb-curside",               0,      PerturbCurside },
195 {   "med-segsize-perturb-curside-big",   0,      PerturbCursideBig },
196 {   "med-segsize-increase-length-default",  0,  IncreaseSegLengthDefault },
197 {   "med-segsize-decrease-length-default",  0,  DecreaseSegLengthDefault },
198 {   "med-segsize-increase-width-default",  0,   IncreaseSegWidthDefault },
199 {   "med-segsize-decrease-width-default",  0,   DecreaseSegWidthDefault },
200 {   "med-segsize-increase-height-default",  0,   IncreaseSegHeightDefault },
201 {   "med-segsize-decrease-height-default",  0,   DecreaseSegHeightDefault },
202
203 //  In ktmap.c
204 {   "med-tmap-assign",                  0,      AssignTexture },
205 {   "med-tmap-assign2",                 0,      AssignTexture2 },
206 {   "med-tmap-clear2",                  0,      ClearTexture2 },
207 {   "med-tmap-propogate",               0,      PropagateTextures },
208 {   "med-tmap-propogate-move",          0,      PropagateTexturesMove },
209 {   "med-tmap-propogate-move-uvs",      0,      PropagateTexturesMoveUVs },
210 {   "med-tmap-propogate-move-uvs",      0,      PropagateTexturesMoveUVs },
211 {   "med-tmap-propogate-uvs",           0,      PropagateTexturesUVs },
212 {   "med-tmap-propogate-selected",      0,      PropagateTexturesSelected },
213
214 //  In wall.c
215 {   "med-wall-add-blastable",           0,      wall_add_blastable },
216 {   "med-wall-add-door",                         0,      wall_add_door },
217 {   "med-wall-add-closed",                       0,             wall_add_closed_wall },
218 {   "med-wall-add-external",             0,             wall_add_external_wall },
219 {   "med-wall-add-illusion",           0,      wall_add_illusion },
220 {   "med-wall-restore-all",                              0,      wall_restore_all },
221 {   "med-wall-remove",                           0,      wall_remove },
222 {   "do-wall-dialog",                                            0,      do_wall_dialog },
223 {   "med-link-doors",                                            0,             wall_link_doors },
224 {   "med-unlink-door",                                           0,             wall_unlink_door },
225 {   "check-walls",                                                       0,             check_walls },
226 {   "delete-all-walls",                                          0,             delete_all_walls },
227
228 // In centers.c
229 {   "do-centers-dialog",                                                 0,      do_centers_dialog },
230
231 //  In switch.c
232 //{   "med-trigger-add-damage",           0,      trigger_add_damage },
233 //{   "med-trigger-add-exit",             0,      trigger_add_exit },
234 //{   "med-trigger-control",                             0,      trigger_control },
235 //{   "med-trigger-remove",                       0,      trigger_remove },
236 //{   "med-bind-wall-to-control",         0,      bind_wall_to_control_trigger },
237 {   "do-trigger-dialog",                                         0,      do_trigger_dialog },
238
239 //--//// In macro.c
240 //--//{   "med-macro-menu",                   0,      MacroMenu },
241 //--//{   "med-macro-play-fast",              0,      MacroPlayFast },
242 //--//{   "med-macro-play-normal",            0,      MacroPlayNormal },
243 //--//{   "med-macro-record-all",             0,      MacroRecordAll },
244 //--//{   "med-macro-record-keys",            0,      MacroRecordKeys },
245 //--//{   "med-macro-save",                   0,      MacroSave },
246 //--//{   "med-macro-load",                   0,      MacroLoad },
247
248 // In editor.c
249 {   "med-update",                       0,      medlisp_update_screen },
250 {   "med-segment-add",                  0,      AttachSegment },
251 {   "med-segment-delete",               0,      medlisp_delete_segment },
252 {   "med-segment-scale",                3,      medlisp_scale_segment },
253 {   "med-segment-rotate",               3,      medlisp_rotate_segment },
254 {   "med-dos-shell",                    0,      DosShell },
255 //{   "med-lisp-call",                    0,      CallLisp },
256 {   "med-editor-exit",                  0,      ExitEditor },
257 {   "med-segment-exchange",             0,      ExchangeMarkandCurseg },
258 {   "med-segment-mark",                 0,      CopySegToMarked },
259 {        "med-about",                                                            0,      ShowAbout },
260 #ifndef NDEBUG
261 {        "med-mark-start",                                               0,             MarkStart },
262 {        "med-mark-end",                                                         0,             MarkEnd },
263 #endif
264
265 //      In group.c
266 {        "med-group-load",                                               0,             LoadGroup },
267 {        "med-group-save",                                               0,             SaveGroup },
268 {   "med-move-group",                   0,      MoveGroup },
269 {   "med-copy-group",                   0,      CopyGroup },
270 {        "med-rotate-group",                                             0,             RotateGroup },
271 {   "med-segment-add-new",              0,      AttachSegmentNew },
272 {        "med-mark-groupseg",                                    0,             MarkGroupSegment },
273 {        "med-next-group",                                               0,             NextGroup },
274 {        "med-prev-group",                                               0,             PrevGroup },
275 {        "med-delete-group",                                             0,      DeleteGroup },
276 {        "med-create-group",                                             0,             CreateGroup },
277 {        "med-ungroup-segment",                                  0,             UngroupSegment },
278 {        "med-group-segment",                                    0,             GroupSegment },
279 {        "med-degroup-group",                                    0,             Degroup },
280 {        "med-subtract-from-group",                      0,             SubtractFromGroup },
281
282 //  In autosave.c
283 {   "med-autosave-undo",                0,      UndoCommand },
284 {        "med-autosave-toggle",                                  0,             ToggleAutosave },
285
286 //      In texture.c
287 {       "med-tass-flip-x",                                               0,     TexFlipX },
288 {       "med-tass-flip-y",                                               0,     TexFlipY },
289 {       "med-tass-slide-up",                                             0,     TexSlideUp },
290 {       "med-tass-slide-left",                                   0,     TexSlideLeft },
291 {       "med-tass-set-default",                                  0,     TexSetDefault },
292 {       "med-tass-slide-right",                                  0,     TexSlideRight },
293 {       "med-tass-rotate-left",                                  0,     TexRotateLeft },
294 {       "med-tass-slide-down",                                   0,     TexSlideDown },
295 {       "med-tass-stretch-down",                                 0,     TexStretchDown },
296 {       "med-tass-stretch-up",                                   0,     TexStretchUp },
297 {       "med-tass-rotate-right",                                 0,     TexRotateRight },
298 {       "med-tass-select-active-edge",           0,     TexSelectActiveEdge },
299 {       "med-tass-rotate-90-degrees",                    0,     TexRotate90Degrees },
300 {  "med-tass-increase-tiling",          0,   TexIncreaseTiling },
301 {  "med-tass-decrease-tiling",          0,   TexDecreaseTiling },
302 {       "med-tass-slide-up-big",                                 0,     TexSlideUpBig },
303 {       "med-tass-slide-left-big",                               0,     TexSlideLeftBig },
304 {       "med-tass-slide-right-big",                      0,     TexSlideRightBig },
305 {       "med-tass-rotate-left-big",                      0,     TexRotateLeftBig },
306 {       "med-tass-slide-down-big",                               0,     TexSlideDownBig },
307 {       "med-tass-rotate-right-big",                     0,     TexRotateRightBig },
308
309 //      In eobject.c
310 {       "med-obj-set-player",                                    0,     SetPlayerPosition },
311 {       "med-obj-place-object",                                  0,     ObjectPlaceObject },
312 {       "med-obj-place-object-tmap",                     0,     ObjectPlaceObjectTmap },
313 {       "med-obj-move-nearer",                                   0,     ObjectMoveNearer },
314 {       "med-obj-move-further",                                  0,     ObjectMoveFurther },
315 {       "med-obj-delete-object",                                 0,     ObjectDelete },
316 {  "med-obj-move-forward",                                       0,     ObjectMoveForward },
317 {  "med-obj-move-left",                                          0,     ObjectMoveLeft },
318 {  "med-obj-set-default",                                        0,     ObjectSetDefault },
319 {  "med-obj-move-right",                                         0,     ObjectMoveRight },
320 {  "med-obj-move-back",                                          0,     ObjectMoveBack },
321 {  "med-obj-move-down",                                          0,     ObjectMoveDown },
322 {  "med-obj-move-up",                                            0,     ObjectMoveUp },
323 {  "med-obj-select-next-in-segment",     0,     ObjectSelectNextinSegment },
324 {  "med-obj-decrease-bank",                              0,     ObjectDecreaseBank },
325 {  "med-obj-increase-bank",                              0,     ObjectIncreaseBank },
326 {  "med-obj-decrease-pitch",                             0,     ObjectDecreasePitch },
327 {  "med-obj-increase-pitch",                             0,     ObjectIncreasePitch },
328 {  "med-obj-decrease-heading",                   0,     ObjectDecreaseHeading },
329 {  "med-obj-increase-heading",                   0,     ObjectIncreaseHeading },
330 {  "med-obj-decrease-bank-big",                  0,     ObjectDecreaseBankBig },
331 {  "med-obj-increase-bank-big",                  0,     ObjectIncreaseBankBig },
332 {  "med-obj-decrease-pitch-big",                         0,     ObjectDecreasePitchBig },
333 {  "med-obj-increase-pitch-big",                         0,     ObjectIncreasePitchBig },
334 {  "med-obj-decrease-heading-big",               0,     ObjectDecreaseHeadingBig },
335 {  "med-obj-increase-heading-big",               0,     ObjectIncreaseHeadingBig },
336 {  "med-obj-reset",                                                      0,     ObjectResetObject },
337 {  "med-obj-flip",                                                       0,     ObjectFlipObject },
338 {       "med-obj-make-coop",                                     0,     ObjectMakeCoop },
339 //{     "med-obj-place-hostage",                                 0,     ObjectPlaceHostage },
340
341 // In objpage.c
342 {       "med-obj-select-next-type",                      0,     objpage_goto_next_object },
343
344
345 //      In elight.c
346 {       "med-light-select-next-vertex",          0,     LightSelectNextVertex },
347 {       "med-light-select-next-edge",                    0,     LightSelectNextEdge },
348 {       "med-light-copy-intensity-side",                 0,     LightCopyIntensity },
349 {       "med-light-copy-intensity-segment",      0,     LightCopyIntensitySegment },
350 {       "med-light-decrease-light-vertex",       0,     LightDecreaseLightVertex },
351 {       "med-light-increase-light-vertex",       0,     LightIncreaseLightVertex },
352 {       "med-light-decrease-light-side",                 0,     LightDecreaseLightSide },
353 {       "med-light-increase-light-side",                 0,     LightIncreaseLightSide },
354 {       "med-light-decrease-light-segment",      0,     LightDecreaseLightSegment },
355 {       "med-light-increase-light-segment",      0,     LightIncreaseLightSegment },
356 {       "med-light-set-maximum",                                 0,     LightSetMaximum },
357 {       "med-light-set-default",                                 0,     LightSetDefault },
358 {       "med-light-assign-default-all",          0,     LightSetDefaultAll },
359 {       "med-light-ambient-lighting",                    0,     LightAmbientLighting },
360
361 // In seguvs.c                                                                                                                                          
362 {       "med-seguvs-fix-bogus-uvs-on-side",      0,     fix_bogus_uvs_on_side},
363 {       "med-seguvs-fix-bogus-uvs-all",          0,     fix_bogus_uvs_all},
364 {       "med-seguvs-smooth-lighting-all",        0,   set_average_light_on_all},
365 {       "med-seguvs-smooth-lighting-all-quick",  0,   set_average_light_on_all_quick},
366 {       "med-seguvs-smooth-lighting",                    0,   set_average_light_on_curside},
367
368 // Miscellaneous, please neaten and catagorize me!
369
370 {   "med-increase-draw-depth",          0,        IncreaseDrawDepth },
371 {   "med-decrease-draw-depth",          0,        DecreaseDrawDepth },
372 {   "med-goto-main-menu",                    0,        GotoMainMenu },
373 {   "med-goto-game-screen",             0,        GotoGameScreen },
374 {   "med-drop-into-debugger",           0,        DropIntoDebugger },
375 // {   "med-sync-large-view",              0,        SyncLargeView },
376 {   "med-create-default-new-segment",   0,        CreateDefaultNewSegment },
377 {   "med-create-default-new-segment-and-attach",   0,        CreateDefaultNewSegmentandAttach },
378 {   "med-clear-selected-list",          0,        ClearSelectedList },
379 {   "med-clear-found-list",             0,        ClearFoundList },
380 {   "med-sort-selected-list",           0,        SortSelectedList },
381 {   "med-set-player-from-curseg",       0,        SetPlayerFromCursegAndRotate },
382 {   "med-set-player-from-curseg-minus-one", 0,        SetPlayerFromCursegMinusOne },
383 {   "med-find-concave-segs",            0,        FindConcaveSegs },
384 {   "med-select-next-found-seg",        0,        SelectNextFoundSeg },
385 {   "med-select-prev-found-seg",        0,        SelectPreviousFoundSeg },
386 {   "med-stop-slew",                    0,        slew_stop },
387 //{   "med-reset-orientation",            0,        do_reset_orient },
388 {   "med-game-zoom-out",                0,        GameZoomOut },
389 {   "med-game-zoom-in",                 0,        GameZoomIn },
390 {        "med-keypad-goto-prev",                                 0,        med_keypad_goto_prev },
391 {        "med-keypad-goto-next",                                 0,        med_keypad_goto_next },
392 {        "med-keypad-goto",                              1,        med_keypad_goto },
393
394 // John's temporary function page stuff
395 // {   "med-set-function-page",            1,        medtmp_set_page },
396
397 // In fuelcen.c
398 {       "med-fuelcen-create",                                   0,      fuelcen_create_from_curseg },
399 {       "med-repaircen-create",                                 0,      repaircen_create_from_curseg },
400 {       "med-controlcen-create",                                        0,  controlcen_create_from_curseg },
401 {       "med-robotmaker-create",                                        0,  robotmaker_create_from_curseg },
402 {       "med-fuelcen-reset-all",                                        0,  fuelcen_reset_all },
403 {       "med-fuelcen-delete",                                   0,              fuelcen_delete_from_curseg },
404
405 // In robot.c
406 {       "do-robot-dialog",                                                      0, do_robot_dialog },
407 {       "do-object-dialog",                                                     0, do_object_dialog },
408 {       "do-hostage-dialog",                                                    0, do_hostage_dialog },
409
410 // In gamesavec
411 {       "rename-level",                                                 0, get_level_name },
412
413 // The terminating marker
414 {   NULL, 0, NULL } };
415
416 void init_med_functions()
417 {
418         func_init(med_functions, (sizeof(med_functions)/sizeof(FUNCTION))-1 );
419 }
420