forked from pjbroad/other-life
/
elconfig.c
2848 lines (2596 loc) · 105 KB
/
elconfig.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <float.h>
#include <errno.h>
//For stat() etc.. below
#include <sys/types.h>
#include <sys/stat.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif //_MSC_VER
#include "user_menus.h"
#ifdef MAP_EDITOR
#include "map_editor/global.h"
#include "map_editor/browser.h"
#include "map_editor/interface.h"
#include "load_gl_extensions.h"
#else
#include "achievements.h"
#include "alphamap.h"
#include "bags.h"
#include "buddy.h"
#include "chat.h"
#include "console.h"
#include "counters.h"
#include "dialogues.h"
#include "draw_scene.h"
#include "errors.h"
#include "elconfig.h"
#include "elwindows.h"
#include "filter.h"
#include "gamewin.h"
#include "gl_init.h"
#include "hud.h"
#include "hud_indicators.h"
#include "init.h"
#include "interface.h"
#include "items.h"
#include "item_info.h"
#include "manufacture.h"
#include "map.h"
#include "mapwin.h"
#include "missiles.h"
#include "multiplayer.h"
#include "new_character.h"
#include "openingwin.h"
#include "particles.h"
#include "pm_log.h"
#include "questlog.h"
#include "reflection.h"
#include "serverpopup.h"
#include "session.h"
#include "shadows.h"
#include "sound.h"
#include "spells.h"
#include "stats.h"
#include "storage.h"
#include "tabs.h"
#include "trade.h"
#include "update.h"
#include "trade_log.h"
#include "weather.h"
#include "minimap.h"
#ifdef NEW_ALPHA
#include "3d_objects.h"
#endif
#include "io/elpathwrapper.h"
#include "notepad.h"
#include "sky.h"
#ifdef OSX
#include "events.h"
#endif // OSX
#endif
#include "asc.h"
#include "elconfig.h"
#include "text.h"
#include "consolewin.h"
#include "queue.h"
#include "url.h"
#include "widgets.h"
#include "eye_candy_wrapper.h"
#include "sendvideoinfo.h"
#include "actor_init.h"
#include "io/elpathwrapper.h"
#ifdef NEW_TEXTURES
#include "textures.h"
#endif /* NEW_TEXTURES */
#ifdef FSAA
#include "fsaa/fsaa.h"
#endif /* FSAA */
#ifdef CUSTOM_UPDATE
#include "custom_update.h"
#endif /* CUSTOM_UPDATE */
typedef float (*float_min_max_func)();
typedef int (*int_min_max_func)();
// Defines for config variables
#define CONTROLS 0
#define HUD 1
#define CHAT 2
#define FONT 3
#define SERVER 4
#define AUDIO 5
#define VIDEO 6
#define GFX 7
#define CAMERA 8
#define TROUBLESHOOT 9
#ifdef DEBUG
#define DEBUGTAB 10
#define MAX_TABS 11
#else
#define MAX_TABS 10
#endif
#define CHECKBOX_SIZE 15
#define SPACING 5 //Space between widgets and labels and lines
#define LONG_DESC_SPACE 50 //Space to give to the long descriptions
#define MAX_LONG_DESC_LINES 3 //How many lines of text we can fit in LONG_DESC_SPACE
typedef char input_line[256];
/*!
* var_struct stores the data for a single configuration entry.
*/
typedef struct
{
option_type type; /*!< type of the variable */
char *name; /*!< name of the variable */
int nlen; /*!< length of the \a name */
char *shortname; /*!< shortname of the variable */
int snlen; /*!< length of the \a shortname */
void (*func)(); /*!< routine to execute when this variable is selected. */
void *var; /*!< data for this variable */
int len; /*!< length of the variable */
int saved;
// char *message; /*!< In case you want a message to be written when a setting is changed */
dichar display;
struct {
int tab_id; /*!< The tab ID in which we find this option */
int label_id; /*!< The label ID associated with this option */
int widget_id; /*!< Widget ID for things like checkboxes */
} widgets;
queue_t *queue; /*!< Queue that holds info for certain widget types. */
} var_struct;
/*!
* a list of variables of type \see var_struct
*/
struct variables
{
int no; /*!< current number of allocated \see var_struct in \a var */
var_struct * var[200]; /*!< fixed array of \a no \see var_struct structures */
} our_vars= {0,{NULL}};
int write_ini_on_exit= 1;
// Window Handling
int elconfig_win= -1;
int force_elconfig_win_ontop = 0;
int elconfig_tab_collection_id= 1;
int elconfig_free_widget_id= 2;
unsigned char elconf_description_buffer[400]= {0};
struct {
Uint32 tab;
Uint16 x;
Uint16 y;
} elconfig_tabs[MAX_TABS];
int elconfig_menu_x= 10;
int elconfig_menu_y= 10;
int elconfig_menu_x_len= 620;
int elconfig_menu_y_len= 430;
int windows_on_top= 0;
static int options_set= 0;
int shadow_map_size_multi= 0;
#ifdef FSAA
int fsaa_index = 0;
#endif /* FSAA */
/* temporary variables for fine graphic positions asjustmeet */
int gx_adjust = 0;
int gy_adjust = 0;
int you_sit= 0;
int sit_lock= 0;
int use_keypress_dialogue_boxes = 0, use_full_dialogue_window = 0;
int use_alpha_banner = 0;
int show_fps= 1;
int render_skeleton= 0;
int render_mesh= 1;
int render_bones_id = 0;
int render_bones_orientation = 0;
#ifdef NEW_CURSOR
int big_cursors = 0;
int sdl_cursors = 0;
float pointer_size = 1.0;
#endif // NEW_CURSOR
float water_tiles_extension = 200.0;
int show_game_seconds = 0;
int skybox_update_delay = 10;
int skybox_local_weather = 0;
#ifdef OSX // for probelem with rounded buttons on Intel graphics
int square_buttons = 0;
#endif
#ifdef NEW_TEXTURES
int small_actor_texture_cache = 0;
#endif /* NEW_TEXTURES */
int video_info_sent = 0;
#ifdef DEBUG
int enable_client_aiming = 0;
#endif // DEBUG
#ifdef ELC
static void consolidate_rotate_chat_log_status(void);
#endif
void options_loaded(void)
{
size_t i;
// find any options not marked as saved, excluding ones we marked on purpose
for (i= 0; i < our_vars.no; i++)
if ((!our_vars.var[i]->saved) && (our_vars.var[i]->type!=OPT_BOOL_INI) && (our_vars.var[i]->type!=OPT_INT_INI))
our_vars.var[i]->saved = 1;
options_set = 1;
#ifdef ELC
get_rotate_chat_log();
consolidate_rotate_chat_log_status();
#endif
}
int int_zero_func()
{
return 0;
}
float float_zero_func()
{
return 0.0f;
}
int int_one_func()
{
return 1;
}
float float_one_func()
{
return 1.0f;
}
static __inline__ void check_option_var(char* name);
static __inline__ void destroy_shadow_mapping()
{
if (gl_extensions_loaded)
{
CHECK_GL_ERRORS();
if (have_extension(ext_framebuffer_object))
{
#ifndef MAP_EDITOR
free_shadow_framebuffer();
#endif //MAP_EDITOR
}
else
{
if (depth_map_id != 0)
{
glDeleteTextures(1, &depth_map_id);
depth_map_id = 0;
}
}
CHECK_GL_ERRORS();
}
}
static __inline__ void destroy_fbos()
{
if (gl_extensions_loaded)
{
CHECK_GL_ERRORS();
if (have_extension(ext_framebuffer_object))
{
#ifndef MAP_EDITOR
destroy_shadow_mapping();
free_reflection_framebuffer();
#endif //MAP_EDITOR
}
CHECK_GL_ERRORS();
}
}
static __inline__ void build_fbos()
{
if (gl_extensions_loaded)
{
#ifndef MAP_EDITOR
if (have_extension(ext_framebuffer_object) && use_frame_buffer)
{
if ((water_shader_quality > 0) && show_reflection)
{
make_reflection_framebuffer(window_width, window_height);
}
}
#endif // MAP_EDITOR
check_option_var("shadow_map_size");
}
}
static __inline__ void update_fbos()
{
destroy_fbos();
build_fbos();
}
void change_var(int * var)
{
*var= !*var;
}
#ifndef MAP_EDITOR
static void change_show_action_bar(int * var)
{
*var= !*var;
if (stats_bar_win >= 0)
init_stats_display();
}
void change_minimap_scale(float * var, float * value)
{
int shown = 0;
*var= *value;
if (minimap_win>=0)
{
shown = get_show_window(minimap_win);
minimap_win_x = windows_list.window[minimap_win].cur_x;
minimap_win_y = windows_list.window[minimap_win].cur_y;
destroy_window(minimap_win);
minimap_win = -1;
}
if (shown)
display_minimap();
}
void change_sky_var(int * var)
{
*var= !*var;
skybox_update_colors();
}
void change_use_animation_program(int * var)
{
if (*var)
{
if (gl_extensions_loaded && have_extension(arb_vertex_buffer_object) &&
have_extension(arb_vertex_program))
{
unload_vertex_programs();
}
*var = 0;
}
else
{
if (!gl_extensions_loaded)
{
*var = 1;
}
else
{
if (have_extension(arb_vertex_buffer_object) &&
have_extension(arb_vertex_program))
{
*var = load_vertex_programs();
}
}
}
if (gl_extensions_loaded)
{
if (use_animation_program)
{
LOG_TO_CONSOLE(c_green2, "Using vertex program for actor animation.");
}
else
{
LOG_TO_CONSOLE(c_red1, "Not using vertex program for actor animation.");
}
}
}
#endif //MAP_EDITOR
#ifndef MAP_EDITOR
void change_min_ec_framerate(float * var, float * value)
{
if(*value >= 0) {
if (*value < max_ec_framerate) {
*var = *value;
} else if (!max_ec_framerate) {
*var = *value;
} else {
*var = max_ec_framerate - 1;
}
} else {
*var= 0;
}
}
void change_max_ec_framerate(float * var, float * value)
{
if(*value >= 1) {
if (*value > min_ec_framerate) {
*var = *value;
} else if (!min_ec_framerate) {
*var = *value;
} else {
*var = min_ec_framerate + 1;
}
} else {
*var= 1;
}
}
#endif //!MAP_EDITOR
void change_int(int * var, int value)
{
if(value>=0) *var= value;
}
void change_signed_int(int * var, int value)
{
*var= value;
}
void change_float(float * var, float * value)
{
#ifdef ELC
if(var == &name_zoom){
if(*value > 2.0){
*value= 2.0;
}
}
#endif //ELC
/* Commented by Schmurk: if we can define bounds for parameters, why testing
* if the value is over 0 here? */
//if(*value >= 0) {
*var= *value;
//} else {
// *var= 0;
//}
}
void change_string(char * var, char * str, int len)
{
while(*str && len--){
*var++= *str++;
}
*var= 0;
}
#ifdef ELC
/*
* The chat logs are created very early on in the client start up, before the
* ini file is read at least. Because of this, a simple ini file variable
* can not be used to enabled/disable rotating chat log files. I suppose the init
* code could be changed but rather do that and unleash all kinds of grief, use a
* simple flag file when the chat logs are opened. The ini file setting now
* becomes the creater/remover of that file.
*/
static int rotate_chat_log_config_var = 0;
static int rotate_chat_log = -1;
static const char* rotate_chat_log_flag_file = "rotate_chat_log_enabled";
/* get the current value depending on if the flag file exists */
int get_rotate_chat_log(void)
{
if (rotate_chat_log == -1)
rotate_chat_log = (file_exists_config(rotate_chat_log_flag_file)==1) ?1: 0;
return rotate_chat_log;
}
/* create or delete the flag file to reflect the ini file rotate chat log value */
static void change_rotate_chat_log(int *value)
{
*value = !*value;
/* create the flag file if we are switching on chat log rotate */
if (*value && (file_exists_config(rotate_chat_log_flag_file)!=1))
{
FILE *fp = open_file_config(rotate_chat_log_flag_file,"w");
if ((fp == NULL) || (fclose(fp) != 0))
LOG_ERROR("%s: Failed to create [%s] [%s]\n", __FILE__, rotate_chat_log_flag_file, strerror(errno) );
else
LOG_TO_CONSOLE(c_green2, rotate_chat_log_restart_str);
}
/* remove the flag file if we are switching off chat log rotate */
else if (!(*value) && (file_exists_config(rotate_chat_log_flag_file)==1))
{
const char *config_dir = get_path_config();
char *name_buf = NULL;
if (config_dir != NULL)
{
size_t buf_len = strlen(config_dir) + strlen(rotate_chat_log_flag_file) + 1;
name_buf = (char *)malloc(buf_len);
if (name_buf != NULL)
{
safe_strncpy(name_buf, config_dir, buf_len);
safe_strcat(name_buf, rotate_chat_log_flag_file, buf_len);
if (unlink(name_buf) != 0)
LOG_ERROR("%s: Failed to remove [%s] [%s]\n", __FILE__, rotate_chat_log_flag_file, strerror(errno) );
else
LOG_TO_CONSOLE(c_green2, rotate_chat_log_restart_str);
free(name_buf);
}
}
}
}
/* called after the el.in file has been read, so we can consolidate the rotate chat log status */
static void consolidate_rotate_chat_log_status(void)
{
/* it is too late to use a newly set rotate log value, but we can set the ini flag if rotating is on */
if ((rotate_chat_log==1) && !rotate_chat_log_config_var)
{
rotate_chat_log_config_var = 1;
set_var_unsaved("rotate_chat_log", INI_FILE_VAR);
}
}
void change_sound_level(float *var, float * value)
{
if(*value >= 0.0f && *value <= 1.0f+0.00001) {
*var= (float)*value;
} else {
*var=0;
}
}
void change_password(char * passwd)
{
int i= 0;
char *str= password_str;
while(*passwd) {
*str++= *passwd++;
}
*str= 0;
if(password_str[0]){ //We have a password
for(; i < str-password_str; i++) {
display_password_str[i]= '*';
}
display_password_str[i]=0;
}
}
#ifdef NEW_TEXTURES
void update_max_actor_texture_handles()
{
if (poor_man == 1)
{
if (small_actor_texture_cache == 1)
{
max_actor_texture_handles = 1;
}
else
{
max_actor_texture_handles = 4;
}
}
else
{
if (small_actor_texture_cache == 1)
{
max_actor_texture_handles = 16;
}
else
{
max_actor_texture_handles = 32;
}
}
}
#endif /* NEW_TEXTURES */
void change_poor_man(int *poor_man)
{
*poor_man= !*poor_man;
#ifdef NEW_TEXTURES
unload_texture_cache();
update_max_actor_texture_handles();
#endif /* NEW_TEXTURES */
if(*poor_man) {
show_reflection= 0;
shadows_on= 0;
clouds_shadows= 0;
use_shadow_mapping= 0;
#ifndef MAP_EDITOR2
special_effects= 0;
use_eye_candy = 0;
use_fog= 0;
show_weather = 0;
#endif
#ifndef MAP_EDITOR
use_frame_buffer= 0;
#endif
update_fbos();
skybox_show_clouds = 0;
skybox_show_sun = 0;
skybox_show_moons = 0;
skybox_show_stars = 0;
}
}
void change_compiled_vertex_array(int *value)
{
if (*value) {
*value= 0;
}
else if (!gl_extensions_loaded || have_extension(ext_compiled_vertex_array))
{
// don't check if we have hardware support when OpenGL
// extensions are not initialized yet.
*value= 1;
}
else LOG_TO_CONSOLE(c_green2,disabled_compiled_vertex_arrays);
}
void change_vertex_buffers(int *value)
{
if (*value) {
*value= 0;
}
else if (!gl_extensions_loaded || have_extension(arb_vertex_buffer_object))
{
// don't check if we have hardware support when OpenGL
// extensions are not initialized yet.
*value= 1;
}
// else LOG_TO_CONSOLE(c_green2,disabled_vertex_buffers);
}
void change_clouds_shadows(int *value)
{
if (*value) {
*value= 0;
}
else if (!gl_extensions_loaded || (get_texture_units() >= 2))
{
// don't check if we have hardware support when OpenGL
// extensions are not initialized yet.
*value= 1;
}
// else LOG_TO_CONSOLE(c_green2,disabled_clouds_shadows);
}
#ifdef NEW_TEXTURES
void change_small_actor_texture_cache(int *value)
{
if (*value)
{
*value = 0;
}
else
{
*value = 1;
}
update_max_actor_texture_handles();
}
void change_eye_candy(int *value)
{
if (*value)
{
*value = 0;
}
else if (!gl_extensions_loaded || ((get_texture_units() >= 2) &&
supports_gl_version(1, 5)))
{
// don't check if we have hardware support when OpenGL
// extensions are not initialized yet.
*value = 1;
}
}
#else /* NEW_TEXTURES */
void change_mipmaps(int *value)
{
if (*value) {
*value= 0;
}
else if (!gl_extensions_loaded || have_extension(sgis_generate_mipmap))
{
// don't check if we have hardware support when OpenGL
// extensions are not initialized yet.
*value= 1;
}
// else LOG_TO_CONSOLE(c_green2,disabled_mipmaps);
}
#endif /* NEW_TEXTURES */
void change_point_particles(int *value)
{
if (*value) {
*value= 0;
}
else if (!gl_extensions_loaded || have_extension(arb_point_sprite))
{
// don't check if we have hardware support when OpenGL
// extensions are not initialized yet.
*value= 1;
}
else
{
LOG_TO_CONSOLE(c_green2, disabled_point_particles);
}
#ifndef NEW_TEXTURES
ec_set_draw_method();
#endif /* NEW_TEXTURES */
}
void change_particles_percentage(int *pointer, int value)
{
if(value>0 && value <=100) {
particles_percentage= value;
}
else
{
particles_percentage= 0;
LOG_TO_CONSOLE(c_green2, disabled_particles_str);
}
}
void change_new_selection(int *value)
{
if (*value)
{
*value = 0;
}
else
{
if (gl_extensions_loaded)
{
if ((supports_gl_version(1, 3) ||
have_extension(arb_texture_env_combine)) &&
(get_texture_units() > 1) && (bpp == 32))
{
*value = 1;
}
}
else
{
*value = 1;
}
}
}
int switch_video(int mode, int full_screen)
{
int win_width,
win_height,
win_bpp;
int index = mode - 1;
int flags = SDL_OPENGL;
if (full_screen)
flags |= SDL_FULLSCREEN;
if(mode == 0 && !full_screen) {
win_width = video_user_width;
win_height = video_user_height;
win_bpp = bpp;
} else if(index < 0 || index >= video_modes_count) {
//warn about this error
LOG_TO_CONSOLE(c_red2,invalid_video_mode);
return 0;
} else {
/* Check if the video mode is supported. */
win_width = video_modes[index].width;
win_height = video_modes[index].height;
win_bpp = video_modes[index].bpp;
}
#ifndef LINUX
LOG_TO_CONSOLE(c_green2, video_restart_str);
video_mode=mode;
set_var_unsaved("video_mode", INI_FILE_VAR);
return 1;
#endif
destroy_fbos();
if (!SDL_VideoModeOK(win_width, win_height, win_bpp, flags)) {
LOG_TO_CONSOLE(c_red2, invalid_video_mode);
return 0;
} else {
set_new_video_mode(full_screen, mode);
#ifndef MAP_EDITOR2
if(items_win >= 0) {
windows_list.window[items_win].show_handler(&windows_list.window[items_win]);
}
#endif
}
build_fbos();
return 1;
}
void switch_vidmode(int *pointer, int mode)
{
if(!video_mode_set) {
/* Video isn't ready yet, just remember the mode */
video_mode= mode;
} else {
switch_video(mode, full_screen);
}
}
void toggle_full_screen_mode(int * fs)
{
if(!video_mode_set) {
*fs= !*fs;
} else {
toggle_full_screen();
}
}
#ifdef NEW_CURSOR
void change_sdl_cursor(int * fs)
{
if(!*fs) {
SDL_ShowCursor(1);
} else {
SDL_ShowCursor(0);
}
*fs = !*fs;
}
#endif // NEW_CURSOR
void toggle_follow_cam(int * fc)
{
last_kludge=camera_kludge;
if (*fc)
hold_camera=rz;
else
hold_camera+=camera_kludge;
change_var(fc);
}
void toggle_follow_cam_behind(int * fc)
{
if (*fc)
{
last_kludge = camera_kludge;
hold_camera += camera_kludge;
}
else
{
last_kludge = -rz;
}
change_var(fc);
}
void toggle_ext_cam(int * ec)
{
change_var(ec);
if (*ec)
{
isometric = 0;
if (video_mode_set)
{
resize_root_window();
set_all_intersect_update_needed(main_bbox_tree);
}
}
}
void change_tilt_float(float * var, float * value)
{
*var= *value;
if (rx > -min_tilt_angle) rx = -min_tilt_angle;
else if (rx < -max_tilt_angle) rx = -max_tilt_angle;
}
void change_shadow_map_size(int *pointer, int value)
{
const int array[10]= {256, 512, 768, 1024, 1280, 1536, 1792, 2048, 3072, 4096};
int index, size, i, max_size, error;
char error_str[1024];
if (value >= array[0])
{
index = 0;
for (i = 0; i < 10; i++)
{
/* Check if we can set the multiselect widget to this */
if (array[i] == value)
{
index = i;
break;
}
}
}
else
{
index = min2i(max2i(0, value), 9);
}
size = array[index];
if (gl_extensions_loaded && use_shadow_mapping)
{
error= 0;
if (use_frame_buffer)
{
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &max_size);
}
else
{
max_size = min2i(window_width, window_height);
}
if (size > max_size)
{
while ((size > max_size) && (index > 0))
{
index--;
size = array[index];
}
error= 1;
}
if (!(have_extension(arb_texture_non_power_of_two) || supports_gl_version(2, 0)))
{
switch (index)
{
case 2:
index = 1;
error = 1;
break;
case 4:
case 5:
case 6:
index = 3;
error = 1;
break;
case 8:
index = 7;
error = 1;
break;
}
size = array[index];
}
if (error == 1)
{
memset(error_str, 0, sizeof(error_str));
safe_snprintf(error_str, sizeof(error_str),
shadow_map_size_not_supported_str, size);
LOG_TO_CONSOLE(c_yellow2, error_str);
}
shadow_map_size = size;
destroy_shadow_mapping();
if (have_extension(ext_framebuffer_object) && use_frame_buffer)
{
make_shadow_framebuffer();
}
}
else
{
shadow_map_size = size;
}
if (pointer != NULL)
{
*pointer= index;
}
}
#ifdef FSAA
void change_fsaa(int *pointer, int value)
{
unsigned int i, index, fsaa_value;
index = 0;
fsaa_value = 0;
if (value > 0)
{
for (i = 1; i < get_fsaa_mode_count(); i++)
{