Subversion Repositories eduke32

Rev

Rev 882 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 882 Rev 883
1
//-------------------------------------------------------------------------
1
//-------------------------------------------------------------------------
2
/*
2
/*
3
Copyright (C) 1996, 2003 - 3D Realms Entertainment
3
Copyright (C) 1996, 2003 - 3D Realms Entertainment
4
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
4
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
5
Copyright (C) 2004, 2007 - EDuke32 developers
5
Copyright (C) 2004, 2007 - EDuke32 developers
6

6

7
This file is part of EDuke32
7
This file is part of EDuke32
8

8

9
EDuke32 is free software; you can redistribute it and/or
9
EDuke32 is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License version 2
10
modify it under the terms of the GNU General Public License version 2
11
as published by the Free Software Foundation.
11
as published by the Free Software Foundation.
12

12

13
This program is distributed in the hope that it will be useful,
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16

16

17
See the GNU General Public License for more details.
17
See the GNU General Public License for more details.
18

18

19
You should have received a copy of the GNU General Public License
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
*/
22
*/
23
//-------------------------------------------------------------------------
23
//-------------------------------------------------------------------------
24
24
25
/*
25
/*
26
#include <stdio.h>
26
#include <stdio.h>
27
#include <string.h>
27
#include <string.h>
28
#include <stdlib.h>
28
#include <stdlib.h>
29
#include <ctype.h>
29
#include <ctype.h>
30
#include <time.h>
30
#include <time.h>
31
*/
31
*/
32
32
33
#include "duke3d.h"
33
#include "duke3d.h"
34
#include "scriplib.h"
34
#include "scriplib.h"
35
#include "osd.h"
35
#include "osd.h"
36
#include "osdcmds.h"
36
#include "osdcmds.h"
37
37
38
#include "baselayer.h"
38
#include "baselayer.h"
39
39
40
// we load this in to get default button and key assignments
40
// we load this in to get default button and key assignments
41
// as well as setting up function mappings
41
// as well as setting up function mappings
42
42
43
#define __SETUP__   // JBF 20031211
43
#define __SETUP__   // JBF 20031211
44
#include "_functio.h"
44
#include "_functio.h"
45
45
46
/*
46
/*
47
===================
47
===================
48
=
48
=
49
= CONFIG_FunctionNameToNum
49
= CONFIG_FunctionNameToNum
50
=
50
=
51
===================
51
===================
52
*/
52
*/
53
53
54
int32 CONFIG_FunctionNameToNum(char * func)
54
int32 CONFIG_FunctionNameToNum(char * func)
55
{
55
{
56
    int32 i;
56
    int32 i;
57
57
58
    for (i=0;i<NUMGAMEFUNCTIONS;i++)
58
    for (i=0;i<NUMGAMEFUNCTIONS;i++)
59
    {
59
    {
60
        if (!Bstrcasecmp(func,gamefunctions[i]))
60
        if (!Bstrcasecmp(func,gamefunctions[i]))
61
        {
61
        {
62
            return i;
62
            return i;
63
        }
63
        }
64
    }
64
    }
65
    for (i=0;i<NUMGAMEFUNCTIONS;i++)
65
    for (i=0;i<NUMGAMEFUNCTIONS;i++)
66
    {
66
    {
67
        if (!Bstrcasecmp(func,defaultgamefunctions[i]))
67
        if (!Bstrcasecmp(func,defaultgamefunctions[i]))
68
        {
68
        {
69
            return i;
69
            return i;
70
        }
70
        }
71
    }
71
    }
72
    return -1;
72
    return -1;
73
}
73
}
74
74
75
/*
75
/*
76
===================
76
===================
77
=
77
=
78
= CONFIG_FunctionNumToName
78
= CONFIG_FunctionNumToName
79
=
79
=
80
===================
80
===================
81
*/
81
*/
82
82
83
char * CONFIG_FunctionNumToName(int32 func)
83
char * CONFIG_FunctionNumToName(int32 func)
84
{
84
{
85
    if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS)
85
    if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS)
86
        return NULL;
86
        return NULL;
87
    return gamefunctions[func];
87
    return gamefunctions[func];
88
}
88
}
89
89
90
/*
90
/*
91
===================
91
===================
92
=
92
=
93
= CONFIG_AnalogNameToNum
93
= CONFIG_AnalogNameToNum
94
=
94
=
95
===================
95
===================
96
*/
96
*/
97
97
98
98
99
int32 CONFIG_AnalogNameToNum(char * func)
99
int32 CONFIG_AnalogNameToNum(char * func)
100
{
100
{
101
101
102
    if (!Bstrcasecmp(func,"analog_turning"))
102
    if (!Bstrcasecmp(func,"analog_turning"))
103
    {
103
    {
104
        return analog_turning;
104
        return analog_turning;
105
    }
105
    }
106
    if (!Bstrcasecmp(func,"analog_strafing"))
106
    if (!Bstrcasecmp(func,"analog_strafing"))
107
    {
107
    {
108
        return analog_strafing;
108
        return analog_strafing;
109
    }
109
    }
110
    if (!Bstrcasecmp(func,"analog_moving"))
110
    if (!Bstrcasecmp(func,"analog_moving"))
111
    {
111
    {
112
        return analog_moving;
112
        return analog_moving;
113
    }
113
    }
114
    if (!Bstrcasecmp(func,"analog_lookingupanddown"))
114
    if (!Bstrcasecmp(func,"analog_lookingupanddown"))
115
    {
115
    {
116
        return analog_lookingupanddown;
116
        return analog_lookingupanddown;
117
    }
117
    }
118
118
119
    return -1;
119
    return -1;
120
}
120
}
121
121
122
122
123
char * CONFIG_AnalogNumToName(int32 func)
123
char * CONFIG_AnalogNumToName(int32 func)
124
{
124
{
125
    switch (func)
125
    switch (func)
126
    {
126
    {
127
    case analog_turning:
127
    case analog_turning:
128
        return "analog_turning";
128
        return "analog_turning";
129
    case analog_strafing:
129
    case analog_strafing:
130
        return "analog_strafing";
130
        return "analog_strafing";
131
    case analog_moving:
131
    case analog_moving:
132
        return "analog_moving";
132
        return "analog_moving";
133
    case analog_lookingupanddown:
133
    case analog_lookingupanddown:
134
        return "analog_lookingupanddown";
134
        return "analog_lookingupanddown";
135
    }
135
    }
136
136
137
    return NULL;
137
    return NULL;
138
}
138
}
139
139
140
140
141
/*
141
/*
142
===================
142
===================
143
=
143
=
144
= CONFIG_SetDefaults
144
= CONFIG_SetDefaults
145
=
145
=
146
===================
146
===================
147
*/
147
*/
148
148
149
void CONFIG_SetDefaultKeys(int type)
149
void CONFIG_SetDefaultKeys(int type)
150
{
150
{
151
    int32 i,f;
151
    int32 i,f;
152
152
153
    Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys));
153
    Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys));
154
    Bmemset(&boundkeys,0,sizeof(boundkeys));
154
    Bmemset(&boundkeys,0,sizeof(boundkeys));
155
    Bmemset(&mousebind,0,sizeof(mousebind));
155
    Bmemset(&mousebind,0,sizeof(mousebind));
156
156
157
    if (type == 1)
157
    if (type == 1)
158
    {
158
    {
159
        for (i=0; i < (int32)(sizeof(oldkeydefaults)/sizeof(oldkeydefaults[0])); i+=3)
159
        for (i=0; i < (int32)(sizeof(oldkeydefaults)/sizeof(oldkeydefaults[0])); i+=3)
160
        {
160
        {
161
            f = CONFIG_FunctionNameToNum((char *)oldkeydefaults[i+0]);
161
            f = CONFIG_FunctionNameToNum((char *)oldkeydefaults[i+0]);
162
            if (f == -1) continue;
162
            if (f == -1) continue;
163
            ud.config.KeyboardKeys[f][0] = KB_StringToScanCode((char *)oldkeydefaults[i+1]);
163
            ud.config.KeyboardKeys[f][0] = KB_StringToScanCode((char *)oldkeydefaults[i+1]);
164
            ud.config.KeyboardKeys[f][1] = KB_StringToScanCode((char *)oldkeydefaults[i+2]);
164
            ud.config.KeyboardKeys[f][1] = KB_StringToScanCode((char *)oldkeydefaults[i+2]);
165
165
166
            if (f == gamefunc_Show_Console) OSD_CaptureKey(ud.config.KeyboardKeys[f][0]);
166
            if (f == gamefunc_Show_Console) OSD_CaptureKey(ud.config.KeyboardKeys[f][0]);
167
            else CONFIG_MapKey(f, ud.config.KeyboardKeys[f][0], 0, ud.config.KeyboardKeys[f][1], 0);
167
            else CONFIG_MapKey(f, ud.config.KeyboardKeys[f][0], 0, ud.config.KeyboardKeys[f][1], 0);
168
        }
168
        }
169
        return;
169
        return;
170
    }
170
    }
171
171
172
    for (i=0; i < (int32)(sizeof(keydefaults)/sizeof(keydefaults[0])); i+=3)
172
    for (i=0; i < (int32)(sizeof(keydefaults)/sizeof(keydefaults[0])); i+=3)
173
    {
173
    {
174
        f = CONFIG_FunctionNameToNum(keydefaults[i+0]);
174
        f = CONFIG_FunctionNameToNum(keydefaults[i+0]);
175
        if (f == -1) continue;
175
        if (f == -1) continue;
176
        ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(keydefaults[i+1]);
176
        ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(keydefaults[i+1]);
177
        ud.config.KeyboardKeys[f][1] = KB_StringToScanCode(keydefaults[i+2]);
177
        ud.config.KeyboardKeys[f][1] = KB_StringToScanCode(keydefaults[i+2]);
178
178
179
        if (f == gamefunc_Show_Console) OSD_CaptureKey(ud.config.KeyboardKeys[f][0]);
179
        if (f == gamefunc_Show_Console) OSD_CaptureKey(ud.config.KeyboardKeys[f][0]);
180
        else CONFIG_MapKey(f, ud.config.KeyboardKeys[f][0], 0, ud.config.KeyboardKeys[f][1], 0);
180
        else CONFIG_MapKey(f, ud.config.KeyboardKeys[f][0], 0, ud.config.KeyboardKeys[f][1], 0);
181
    }
181
    }
182
}
182
}
183
183
184
void CONFIG_SetDefaults(void)
184
void CONFIG_SetDefaults(void)
185
{
185
{
186
    // JBF 20031211
186
    // JBF 20031211
187
    int32 i;
187
    int32 i;
188
188
189
    ud.config.scripthandle = -1;
189
    ud.config.scripthandle = -1;
190
    ud.config.ScreenWidth = 1024;
190
    ud.config.ScreenWidth = 1024;
191
    ud.config.ScreenHeight = 768;
191
    ud.config.ScreenHeight = 768;
192
    ud.config.ScreenMode = 0;
192
    ud.config.ScreenMode = 0;
193
#if defined(POLYMOST) && defined(USE_OPENGL)
193
#if defined(POLYMOST) && defined(USE_OPENGL)
194
    ud.config.ScreenBPP = 32;
194
    ud.config.ScreenBPP = 32;
195
#else
195
#else
196
    ud.config.ScreenBPP = 8;
196
    ud.config.ScreenBPP = 8;
197
#endif
197
#endif
198
    ud.config.useprecache = 1;
198
    ud.config.useprecache = 1;
199
    ud.config.ForceSetup = 1;
199
    ud.config.ForceSetup = 1;
200
    ud.config.AmbienceToggle = 1;
200
    ud.config.AmbienceToggle = 1;
201
    ud.config.AutoAim = 1;
201
    ud.config.AutoAim = 1;
202
    ud.config.FXDevice = 0;
202
    ud.config.FXDevice = 0;
203
    ud.config.FXVolume = 220;
203
    ud.config.FXVolume = 220;
204
#if defined(_WIN32)
204
#if defined(_WIN32)
205
    ud.config.MixRate = 44100;
205
    ud.config.MixRate = 44100;
206
#else
206
#else
207
    ud.config.MixRate = 48000;
207
    ud.config.MixRate = 48000;
208
#endif
208
#endif
209
    ud.config.MouseBias = 0;
209
    ud.config.MouseBias = 0;
210
    ud.config.MouseFilter = 0;
210
    ud.config.MouseFilter = 0;
211
    ud.config.MusicDevice = 0;
211
    ud.config.MusicDevice = 0;
212
    ud.config.MusicToggle = 1;
212
    ud.config.MusicToggle = 1;
213
    ud.config.MusicVolume = 200;
213
    ud.config.MusicVolume = 200;
214
    myaimmode = g_player[0].ps->aim_mode = 1;
214
    myaimmode = g_player[0].ps->aim_mode = 1;
215
    ud.config.NumBits = 16;
215
    ud.config.NumBits = 16;
216
    ud.config.NumChannels = 2;
216
    ud.config.NumChannels = 2;
217
    ud.config.NumVoices = 32;
217
    ud.config.NumVoices = 32;
218
    ud.config.ReverseStereo = 0;
218
    ud.config.ReverseStereo = 0;
219
    ud.config.RunMode = ud.auto_run = 1;
219
    ud.config.RunMode = ud.auto_run = 1;
220
    ud.config.ShowOpponentWeapons = 0;
220
    ud.config.ShowOpponentWeapons = 0;
221
    ud.config.SmoothInput = 1;
221
    ud.config.SmoothInput = 1;
222
    ud.config.SoundToggle = 1;
222
    ud.config.SoundToggle = 1;
223
    ud.automsg = 0;
223
    ud.automsg = 0;
224
    ud.autovote = 0;
224
    ud.autovote = 0;
225
    ud.brightness = 8;
225
    ud.brightness = 8;
226
    ud.camerasprite = -1;
226
    ud.camerasprite = -1;
227
    ud.color = 0;
227
    ud.color = 0;
228
    ud.crosshair = 1;
228
    ud.crosshair = 1;
229
    ud.crosshairscale = 50;
229
    ud.crosshairscale = 50;
230
    ud.deathmsgs = 1;
230
    ud.deathmsgs = 1;
231
    ud.democams = 1;
231
    ud.democams = 1;
232
    ud.detail = 1;
232
    ud.detail = 1;
233
    ud.drawweapon = 1;
233
    ud.drawweapon = 1;
234
    ud.idplayers = 1;
234
    ud.idplayers = 1;
235
    ud.levelstats = 0;
235
    ud.levelstats = 0;
236
    ud.lockout = 0;
236
    ud.lockout = 0;
237
    ud.m_ffire = 1;
237
    ud.m_ffire = 1;
238
    ud.m_marker = 1;
238
    ud.m_marker = 1;
239
    ud.mouseaiming = 0;
239
    ud.mouseaiming = 0;
240
    ud.mouseflip = 1;
240
    ud.mouseflip = 1;
241
    ud.msgdisptime = 120;
241
    ud.msgdisptime = 120;
242
    ud.pwlockout[0] = '\0';
242
    ud.pwlockout[0] = '\0';
243
    ud.runkey_mode = 0;
243
    ud.runkey_mode = 0;
244
    ud.screen_size = 4;
244
    ud.screen_size = 4;
245
    ud.screen_tilting = 1;
245
    ud.screen_tilting = 1;
246
    ud.shadows = 1;
246
    ud.shadows = 1;
247
    ud.statusbarmode = 0;
247
    ud.statusbarmode = 0;
248
    ud.statusbarscale = 100;
248
    ud.statusbarscale = 100;
249
    ud.team = 0;
249
    ud.team = 0;
250
    ud.viewbob = 1;
250
    ud.viewbob = 1;
251
    ud.weaponsway = 1;
251
    ud.weaponsway = 1;
252
    ud.weaponswitch = 3;        // new+empty
252
    ud.weaponswitch = 3;        // new+empty
253
    ud.angleinterpolation = 0;
253
    ud.angleinterpolation = 0;
254
    ud.config.UseJoystick = 0;
254
    ud.config.UseJoystick = 0;
255
    ud.config.UseMouse = 1;
255
    ud.config.UseMouse = 1;
256
    ud.config.VoiceToggle = 2;
256
    ud.config.VoiceToggle = 2;
257
257
258
    Bstrcpy(ud.rtsname, "DUKE.RTS");
258
    Bstrcpy(ud.rtsname, "DUKE.RTS");
259
    Bstrcpy(myname, "Duke");
259
    Bstrcpy(myname, "Duke");
260
260
261
    Bstrcpy(ud.ridecule[0], "An inspiration for birth control.");
261
    Bstrcpy(ud.ridecule[0], "An inspiration for birth control.");
262
    Bstrcpy(ud.ridecule[1], "You're gonna die for that!");
262
    Bstrcpy(ud.ridecule[1], "You're gonna die for that!");
263
    Bstrcpy(ud.ridecule[2], "It hurts to be you.");
263
    Bstrcpy(ud.ridecule[2], "It hurts to be you.");
264
    Bstrcpy(ud.ridecule[3], "Lucky Son of a Bitch.");
264
    Bstrcpy(ud.ridecule[3], "Lucky Son of a Bitch.");
265
    Bstrcpy(ud.ridecule[4], "Hmmm....Payback time.");
265
    Bstrcpy(ud.ridecule[4], "Hmmm....Payback time.");
266
    Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker.");
266
    Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker.");
267
    Bstrcpy(ud.ridecule[6], "Damn, you're ugly.");
267
    Bstrcpy(ud.ridecule[6], "Damn, you're ugly.");
268
    Bstrcpy(ud.ridecule[7], "Ha ha ha...Wasted!");
268
    Bstrcpy(ud.ridecule[7], "Ha ha ha...Wasted!");
269
    Bstrcpy(ud.ridecule[8], "You suck!");
269
    Bstrcpy(ud.ridecule[8], "You suck!");
270
    Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!");
270
    Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!");
271
271
272
    // JBF 20031211
272
    // JBF 20031211
273
273
274
    CONFIG_SetDefaultKeys(0);
274
    CONFIG_SetDefaultKeys(0);
275
275
276
    memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions));
276
    memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions));
277
    for (i=0; i<MAXMOUSEBUTTONS; i++)
277
    for (i=0; i<MAXMOUSEBUTTONS; i++)
278
    {
278
    {
279
        ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);
279
        ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);
280
        CONTROL_MapButton(ud.config.MouseFunctions[i][0], i, 0, controldevice_mouse);
280
        CONTROL_MapButton(ud.config.MouseFunctions[i][0], i, 0, controldevice_mouse);
281
        if (i>=4) continue;
281
        if (i>=4) continue;
282
        ud.config.MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]);
282
        ud.config.MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]);
283
        CONTROL_MapButton(ud.config.MouseFunctions[i][1], i, 1, controldevice_mouse);
283
        CONTROL_MapButton(ud.config.MouseFunctions[i][1], i, 1, controldevice_mouse);
284
    }
284
    }
285
285
286
    memset(ud.config.MouseDigitalFunctions, -1, sizeof(ud.config.MouseDigitalFunctions));
286
    memset(ud.config.MouseDigitalFunctions, -1, sizeof(ud.config.MouseDigitalFunctions));
287
    for (i=0; i<MAXMOUSEAXES; i++)
287
    for (i=0; i<MAXMOUSEAXES; i++)
288
    {
288
    {
289
        ud.config.MouseAnalogueScale[i] = 65536;
289
        ud.config.MouseAnalogueScale[i] = 65536;
290
        CONTROL_SetAnalogAxisScale(i, ud.config.MouseAnalogueScale[i], controldevice_mouse);
290
        CONTROL_SetAnalogAxisScale(i, ud.config.MouseAnalogueScale[i], controldevice_mouse);
291
291
292
        ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i*2]);
292
        ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i*2]);
293
        ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i*2+1]);
293
        ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i*2+1]);
294
        CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][0], 0, controldevice_mouse);
294
        CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][0], 0, controldevice_mouse);
295
        CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][1], 1, controldevice_mouse);
295
        CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][1], 1, controldevice_mouse);
296
296
297
        ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(mouseanalogdefaults[i]);
297
        ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(mouseanalogdefaults[i]);
298
        CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
298
        CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
299
    }
299
    }
300
    CONTROL_SetMouseSensitivity(DEFAULTMOUSESENSITIVITY);
300
    CONTROL_SetMouseSensitivity(DEFAULTMOUSESENSITIVITY);
301
301
302
    memset(ud.config.JoystickFunctions, -1, sizeof(ud.config.JoystickFunctions));
302
    memset(ud.config.JoystickFunctions, -1, sizeof(ud.config.JoystickFunctions));
303
    for (i=0; i<MAXJOYBUTTONS; i++)
303
    for (i=0; i<MAXJOYBUTTONS; i++)
304
    {
304
    {
305
        ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdefaults[i]);
305
        ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdefaults[i]);
306
        ud.config.JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(joystickclickeddefaults[i]);
306
        ud.config.JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(joystickclickeddefaults[i]);
307
        CONTROL_MapButton(ud.config.JoystickFunctions[i][0], i, 0, controldevice_joystick);
307
        CONTROL_MapButton(ud.config.JoystickFunctions[i][0], i, 0, controldevice_joystick);
308
        CONTROL_MapButton(ud.config.JoystickFunctions[i][1], i, 1, controldevice_joystick);
308
        CONTROL_MapButton(ud.config.JoystickFunctions[i][1], i, 1, controldevice_joystick);
309
    }
309
    }
310
310
311
    memset(ud.config.JoystickDigitalFunctions, -1, sizeof(ud.config.JoystickDigitalFunctions));
311
    memset(ud.config.JoystickDigitalFunctions, -1, sizeof(ud.config.JoystickDigitalFunctions));
312
    for (i=0; i<MAXJOYAXES; i++)
312
    for (i=0; i<MAXJOYAXES; i++)
313
    {
313
    {
314
        ud.config.JoystickAnalogueScale[i] = 65536;
314
        ud.config.JoystickAnalogueScale[i] = 65536;
315
        ud.config.JoystickAnalogueDead[i] = 1000;
315
        ud.config.JoystickAnalogueDead[i] = 1000;
316
        ud.config.JoystickAnalogueSaturate[i] = 9500;
316
        ud.config.JoystickAnalogueSaturate[i] = 9500;
317
        CONTROL_SetAnalogAxisScale(i, ud.config.JoystickAnalogueScale[i], controldevice_joystick);
317
        CONTROL_SetAnalogAxisScale(i, ud.config.JoystickAnalogueScale[i], controldevice_joystick);
318
318
319
        ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdigitaldefaults[i*2]);
319
        ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdigitaldefaults[i*2]);
320
        ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(joystickdigitaldefaults[i*2+1]);
320
        ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(joystickdigitaldefaults[i*2+1]);
321
        CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][0], 0, controldevice_joystick);
321
        CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][0], 0, controldevice_joystick);
322
        CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][1], 1, controldevice_joystick);
322
        CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][1], 1, controldevice_joystick);
323
323
324
        ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(joystickanalogdefaults[i]);
324
        ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(joystickanalogdefaults[i]);
325
        CONTROL_MapAnalogAxis(i, ud.config.JoystickAnalogueAxes[i], controldevice_joystick);
325
        CONTROL_MapAnalogAxis(i, ud.config.JoystickAnalogueAxes[i], controldevice_joystick);
326
    }
326
    }
327
}
327
}
328
/*
328
/*
329
===================
329
===================
330
=
330
=
331
= CONFIG_ReadKeys
331
= CONFIG_ReadKeys
332
=
332
=
333
===================
333
===================
334
*/
334
*/
335
335
336
void CONFIG_ReadKeys(void)
336
void CONFIG_ReadKeys(void)
337
{
337
{
338
    int32 i;
338
    int32 i;
339
    int32 numkeyentries;
339
    int32 numkeyentries;
340
    int32 function;
340
    int32 function;
341
    char keyname1[80];
341
    char keyname1[80];
342
    char keyname2[80];
342
    char keyname2[80];
343
    kb_scancode key1,key2;
343
    kb_scancode key1,key2;
344
344
345
    if (ud.config.scripthandle < 0) return;
345
    if (ud.config.scripthandle < 0) return;
346
346
347
    numkeyentries = SCRIPT_NumberEntries(ud.config.scripthandle,"KeyDefinitions");
347
    numkeyentries = SCRIPT_NumberEntries(ud.config.scripthandle,"KeyDefinitions");
348
348
349
    Bmemset(&boundkeys,0,sizeof(boundkeys));
349
    Bmemset(&boundkeys,0,sizeof(boundkeys));
350
350
351
    for (i=0;i<numkeyentries;i++)
351
    for (i=0;i<numkeyentries;i++)
352
    {
352
    {
353
        function = CONFIG_FunctionNameToNum(SCRIPT_Entry(ud.config.scripthandle,"KeyDefinitions", i));
353
        function = CONFIG_FunctionNameToNum(SCRIPT_Entry(ud.config.scripthandle,"KeyDefinitions", i));
354
        if (function != -1)
354
        if (function != -1)
355
        {
355
        {
356
            memset(keyname1,0,sizeof(keyname1));
356
            memset(keyname1,0,sizeof(keyname1));
357
            memset(keyname2,0,sizeof(keyname2));
357
            memset(keyname2,0,sizeof(keyname2));
358
            SCRIPT_GetDoubleString
358
            SCRIPT_GetDoubleString
359
            (
359
            (
360
                ud.config.scripthandle,
360
                ud.config.scripthandle,
361
                "KeyDefinitions",
361
                "KeyDefinitions",
362
                SCRIPT_Entry(ud.config.scripthandle, "KeyDefinitions", i),
362
                SCRIPT_Entry(ud.config.scripthandle, "KeyDefinitions", i),
363
                keyname1,
363
                keyname1,
364
                keyname2
364
                keyname2
365
            );
365
            );
366
            key1 = 0xff;
366
            key1 = 0xff;
367
            key2 = 0xff;
367
            key2 = 0xff;
368
            if (keyname1[0])
368
            if (keyname1[0])
369
            {
369
            {
370
                key1 = (byte) KB_StringToScanCode(keyname1);
370
                key1 = (byte) KB_StringToScanCode(keyname1);
371
            }
371
            }
372
            if (keyname2[0])
372
            if (keyname2[0])
373
            {
373
            {
374
                key2 = (byte) KB_StringToScanCode(keyname2);
374
                key2 = (byte) KB_StringToScanCode(keyname2);
375
            }
375
            }
376
            ud.config.KeyboardKeys[function][0] = key1;
376
            ud.config.KeyboardKeys[function][0] = key1;
377
            ud.config.KeyboardKeys[function][1] = key2;
377
            ud.config.KeyboardKeys[function][1] = key2;
378
        }
378
        }
379
    }
379
    }
380
380
381
    for (i=0; i<NUMGAMEFUNCTIONS; i++)
381
    for (i=0; i<NUMGAMEFUNCTIONS; i++)
382
    {
382
    {
383
        if (i == gamefunc_Show_Console)
383
        if (i == gamefunc_Show_Console)
384
            OSD_CaptureKey(ud.config.KeyboardKeys[i][0]);
384
            OSD_CaptureKey(ud.config.KeyboardKeys[i][0]);
385
        else
385
        else
386
            CONFIG_MapKey(i, ud.config.KeyboardKeys[i][0], 0, ud.config.KeyboardKeys[i][1], 0);
386
            CONFIG_MapKey(i, ud.config.KeyboardKeys[i][0], 0, ud.config.KeyboardKeys[i][1], 0);
387
    }
387
    }
388
}
388
}
389
389
390
// wrapper for CONTROL_MapKey(), generates key bindings to reflect changes to keyboard setup
390
// wrapper for CONTROL_MapKey(), generates key bindings to reflect changes to keyboard setup
391
void CONFIG_MapKey(int32 which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2)
391
void CONFIG_MapKey(int32 which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2)
392
{
392
{
393
    int i, j, k;
393
    int i, j, k;
394
    int ii[] = { key1, key2, oldkey1, oldkey2 };
394
    int ii[] = { key1, key2, oldkey1, oldkey2 };
395
    char buf[64];
395
    char buf[64];
396
396
397
    CONTROL_MapKey(which, key1, key2);
397
    CONTROL_MapKey(which, key1, key2);
398
398
399
    for (k = 0; (unsigned)k < (sizeof(ii) / sizeof(ii[0])); k++)
399
    for (k = 0; (unsigned)k < (sizeof(ii) / sizeof(ii[0])); k++)
400
    {
400
    {
401
        if (ii[k] == 0xff || !ii[k]) continue;
401
        if (ii[k] == 0xff || !ii[k]) continue;
402
402
403
        for (j=0;keynames[j].name;j++)
403
        for (j=0;keynames[j].name;j++)
404
            if (ii[k] == keynames[j].id)
404
            if (ii[k] == keynames[j].id)
405
                break;
405
                break;
406
        if (keynames[j].name)
406
        if (keynames[j].name)
407
            boundkeys[ii[k]].key=Bstrdup(keynames[j].name);
407
            boundkeys[ii[k]].key=Bstrdup(keynames[j].name);
408
408
409
        boundkeys[ii[k]].repeat = 1;
409
        boundkeys[ii[k]].repeat = 1;
410
        boundkeys[ii[k]].cmd[0] = 0;
410
        boundkeys[ii[k]].cmd[0] = 0;
411
        tempbuf[0] = 0;
411
        tempbuf[0] = 0;
412
412
413
        for (i=0;i<NUMGAMEFUNCTIONS;i++)
413
        for (i=0;i<NUMGAMEFUNCTIONS;i++)
414
        {
414
        {
415
            if (ud.config.KeyboardKeys[i][0] == ii[k] || ud.config.KeyboardKeys[i][1] == ii[k])
415
            if (ud.config.KeyboardKeys[i][0] == ii[k] || ud.config.KeyboardKeys[i][1] == ii[k])
416
            {
416
            {
417
                Bsprintf(buf,"gamefunc_%s; ",CONFIG_FunctionNumToName(i));
417
                Bsprintf(buf,"gamefunc_%s; ",CONFIG_FunctionNumToName(i));
418
                Bstrcat(tempbuf,buf);
418
                Bstrcat(tempbuf,buf);
419
            }
419
            }
420
        }
420
        }
421
        Bstrncpy(boundkeys[ii[k]].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
421
        Bstrncpy(boundkeys[ii[k]].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
422
422
423
        i = Bstrlen(boundkeys[ii[k]].cmd);
423
        i = Bstrlen(boundkeys[ii[k]].cmd);
424
        if (i)
424
        if (i)
425
            boundkeys[ii[k]].cmd[i-2] = 0; // cut off the trailing "; "
425
            boundkeys[ii[k]].cmd[i-2] = 0; // cut off the trailing "; "
426
    }
426
    }
427
}
427
}
428
428
429
/*
429
/*
430
===================
430
===================
431
=
431
=
432
= CONFIG_SetupMouse
432
= CONFIG_SetupMouse
433
=
433
=
434
===================
434
===================
435
*/
435
*/
436
436
437
void CONFIG_SetupMouse(void)
437
void CONFIG_SetupMouse(void)
438
{
438
{
439
    int32 i;
439
    int32 i;
440
    char str[80];
440
    char str[80];
441
    char temp[80];
441
    char temp[80];
442
    int32 function, scale;
442
    int32 function, scale;
443
443
444
    if (ud.config.scripthandle < 0) return;
444
    if (ud.config.scripthandle < 0) return;
445
445
446
    for (i=0;i<MAXMOUSEBUTTONS;i++)
446
    for (i=0;i<MAXMOUSEBUTTONS;i++)
447
    {
447
    {
448
        Bsprintf(str,"MouseButton%d",i);
448
        Bsprintf(str,"MouseButton%d",i);
449
        temp[0] = 0;
449
        temp[0] = 0;
450
        if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
450
        if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
451
            ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
451
            ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
452
452
453
        Bsprintf(str,"MouseButtonClicked%d",i);
453
        Bsprintf(str,"MouseButtonClicked%d",i);
454
        temp[0] = 0;
454
        temp[0] = 0;
455
        if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
455
        if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
456
            ud.config.MouseFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
456
            ud.config.MouseFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
457
    }
457
    }
458
458
459
    // map over the axes
459
    // map over the axes
460
    for (i=0;i<MAXMOUSEAXES;i++)
460
    for (i=0;i<MAXMOUSEAXES;i++)
461
    {
461
    {
462
        Bsprintf(str,"MouseAnalogAxes%d",i);
462
        Bsprintf(str,"MouseAnalogAxes%d",i);
463
        temp[0] = 0;
463
        temp[0] = 0;
464
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
464
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
465
            if (CONFIG_AnalogNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
465
            if (CONFIG_AnalogNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
466
                ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp);
466
                ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp);
467
467
468
        Bsprintf(str,"MouseDigitalAxes%d_0",i);
468
        Bsprintf(str,"MouseDigitalAxes%d_0",i);
469
        temp[0] = 0;
469
        temp[0] = 0;
470
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
470
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
471
            if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
471
            if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
472
                ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
472
                ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
473
473
474
        Bsprintf(str,"MouseDigitalAxes%d_1",i);
474
        Bsprintf(str,"MouseDigitalAxes%d_1",i);
475
        temp[0] = 0;
475
        temp[0] = 0;
476
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
476
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
477
            if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
477
            if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
478
                ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
478
                ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
479
479
480
        Bsprintf(str,"MouseAnalogScale%d",i);
480
        Bsprintf(str,"MouseAnalogScale%d",i);
481
        scale = ud.config.MouseAnalogueScale[i];
481
        scale = ud.config.MouseAnalogueScale[i];
482
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
482
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
483
        ud.config.MouseAnalogueScale[i] = scale;
483
        ud.config.MouseAnalogueScale[i] = scale;
484
    }
484
    }
485
485
486
    function = DEFAULTMOUSESENSITIVITY;
486
    function = DEFAULTMOUSESENSITIVITY;
487
    SCRIPT_GetNumber(ud.config.scripthandle, "Controls","Mouse_Sensitivity",&function);
487
    SCRIPT_GetNumber(ud.config.scripthandle, "Controls","Mouse_Sensitivity",&function);
488
    CONTROL_SetMouseSensitivity(function);
488
    CONTROL_SetMouseSensitivity(function);
489
489
490
    for (i=0; i<MAXMOUSEBUTTONS; i++)
490
    for (i=0; i<MAXMOUSEBUTTONS; i++)
491
    {
491
    {
492
        CONTROL_MapButton(ud.config.MouseFunctions[i][0], i, 0, controldevice_mouse);
492
        CONTROL_MapButton(ud.config.MouseFunctions[i][0], i, 0, controldevice_mouse);
493
        CONTROL_MapButton(ud.config.MouseFunctions[i][1], i, 1,  controldevice_mouse);
493
        CONTROL_MapButton(ud.config.MouseFunctions[i][1], i, 1,  controldevice_mouse);
494
    }
494
    }
495
    for (i=0; i<MAXMOUSEAXES; i++)
495
    for (i=0; i<MAXMOUSEAXES; i++)
496
    {
496
    {
497
        CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
497
        CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
498
        CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][0], 0,controldevice_mouse);
498
        CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][0], 0,controldevice_mouse);
499
        CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][1], 1,controldevice_mouse);
499
        CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][1], 1,controldevice_mouse);
500
        CONTROL_SetAnalogAxisScale(i, ud.config.MouseAnalogueScale[i], controldevice_mouse);
500
        CONTROL_SetAnalogAxisScale(i, ud.config.MouseAnalogueScale[i], controldevice_mouse);
501
    }
501
    }
502
}
502
}
503
503
504
/*
504
/*
505
===================
505
===================
506
=
506
=
507
= CONFIG_SetupJoystick
507
= CONFIG_SetupJoystick
508
=
508
=
509
===================
509
===================
510
*/
510
*/
511
511
512
void CONFIG_SetupJoystick(void)
512
void CONFIG_SetupJoystick(void)
513
{
513
{
514
    int32 i;
514
    int32 i;
515
    char str[80];
515
    char str[80];
516
    char temp[80];
516
    char temp[80];
517
    int32 scale;
517
    int32 scale;
518
518
519
    if (ud.config.scripthandle < 0) return;
519
    if (ud.config.scripthandle < 0) return;
520
520
521
    for (i=0;i<MAXJOYBUTTONS;i++)
521
    for (i=0;i<MAXJOYBUTTONS;i++)
522
    {
522
    {
523
        Bsprintf(str,"JoystickButton%d",i);
523
        Bsprintf(str,"JoystickButton%d",i);
524
        temp[0] = 0;
524
        temp[0] = 0;
525
        if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
525
        if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
526
            ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
526
            ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
527
527
528
        Bsprintf(str,"JoystickButtonClicked%d",i);
528
        Bsprintf(str,"JoystickButtonClicked%d",i);
529
        temp[0] = 0;
529
        temp[0] = 0;
530
        if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
530
        if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
531
            ud.config.JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
531
            ud.config.JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
532
    }
532
    }
533
533
534
    // map over the axes
534
    // map over the axes
535
    for (i=0;i<MAXJOYAXES;i++)
535
    for (i=0;i<MAXJOYAXES;i++)
536
    {
536
    {
537
        Bsprintf(str,"JoystickAnalogAxes%d",i);
537
        Bsprintf(str,"JoystickAnalogAxes%d",i);
538
        temp[0] = 0;
538
        temp[0] = 0;
539
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
539
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
540
            if (CONFIG_AnalogNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
540
            if (CONFIG_AnalogNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
541
                ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp);
541
                ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp);
542
542
543
        Bsprintf(str,"JoystickDigitalAxes%d_0",i);
543
        Bsprintf(str,"JoystickDigitalAxes%d_0",i);
544
        temp[0] = 0;
544
        temp[0] = 0;
545
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
545
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
546
            if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
546
            if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
547
                ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
547
                ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
548
548
549
        Bsprintf(str,"JoystickDigitalAxes%d_1",i);
549
        Bsprintf(str,"JoystickDigitalAxes%d_1",i);
550
        temp[0] = 0;
550
        temp[0] = 0;
551
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
551
        if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
552
            if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
552
            if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
553
                ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
553
                ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
554
554
555
        Bsprintf(str,"JoystickAnalogScale%d",i);
555
        Bsprintf(str,"JoystickAnalogScale%d",i);
556
        scale = ud.config.JoystickAnalogueScale[i];
556
        scale = ud.config.JoystickAnalogueScale[i];
557
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
557
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
558
        ud.config.JoystickAnalogueScale[i] = scale;
558
        ud.config.JoystickAnalogueScale[i] = scale;
559
559
560
        Bsprintf(str,"JoystickAnalogDead%d",i);
560
        Bsprintf(str,"JoystickAnalogDead%d",i);
561
        scale = ud.config.JoystickAnalogueDead[i];
561
        scale = ud.config.JoystickAnalogueDead[i];
562
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
562
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
563
        ud.config.JoystickAnalogueDead[i] = scale;
563
        ud.config.JoystickAnalogueDead[i] = scale;
564
564
565
        Bsprintf(str,"JoystickAnalogSaturate%d",i);
565
        Bsprintf(str,"JoystickAnalogSaturate%d",i);
566
        scale = ud.config.JoystickAnalogueSaturate[i];
566
        scale = ud.config.JoystickAnalogueSaturate[i];
567
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
567
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
568
        ud.config.JoystickAnalogueSaturate[i] = scale;
568
        ud.config.JoystickAnalogueSaturate[i] = scale;
569
    }
569
    }
570
570
571
    for (i=0;i<MAXJOYBUTTONS;i++)
571
    for (i=0;i<MAXJOYBUTTONS;i++)
572
    {
572
    {
573
        CONTROL_MapButton(ud.config.JoystickFunctions[i][0], i, 0, controldevice_joystick);
573
        CONTROL_MapButton(ud.config.JoystickFunctions[i][0], i, 0, controldevice_joystick);
574
        CONTROL_MapButton(ud.config.JoystickFunctions[i][1], i, 1,  controldevice_joystick);
574
        CONTROL_MapButton(ud.config.JoystickFunctions[i][1], i, 1,  controldevice_joystick);
575
    }
575
    }
576
    for (i=0;i<MAXJOYAXES;i++)
576
    for (i=0;i<MAXJOYAXES;i++)
577
    {
577
    {
578
        CONTROL_MapAnalogAxis(i, ud.config.JoystickAnalogueAxes[i], controldevice_joystick);
578
        CONTROL_MapAnalogAxis(i, ud.config.JoystickAnalogueAxes[i], controldevice_joystick);
579
        CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][0], 0, controldevice_joystick);
579
        CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][0], 0, controldevice_joystick);
580
        CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][1], 1, controldevice_joystick);
580
        CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][1], 1, controldevice_joystick);
581
        CONTROL_SetAnalogAxisScale(i, ud.config.JoystickAnalogueScale[i], controldevice_joystick);
581
        CONTROL_SetAnalogAxisScale(i, ud.config.JoystickAnalogueScale[i], controldevice_joystick);
582
    }
582
    }
583
}
583
}
584
584
585
/*
585
/*
586
===================
586
===================
587
=
587
=
588
= CONFIG_ReadSetup
588
= CONFIG_ReadSetup
589
=
589
=
590
===================
590
===================
591
*/
591
*/
592
extern char *duke3dgrp;
592
extern char *duke3dgrp;
593
extern void check_valid_color(int *color,int prev_color);
593
extern void check_valid_color(int *color,int prev_color);
594
594
595
int32 CONFIG_ReadSetup(void)
595
int32 CONFIG_ReadSetup(void)
596
{
596
{
597
    int32 dummy, i;
597
    int32 dummy, i;
598
    char commmacro[] = "CommbatMacro# ";
598
    char commmacro[] = "CommbatMacro# ";
599
    extern int32 CommandWeaponChoice;
599
    extern int32 CommandWeaponChoice;
600
600
601
    CONTROL_ClearAssignments();
601
    CONTROL_ClearAssignments();
602
    CONFIG_SetDefaults();
602
    CONFIG_SetDefaults();
603
603
604
    ud.config.setupread = 1;
604
    ud.config.setupread = 1;
605
605
606
    pathsearchmode = 1;
606
    pathsearchmode = 1;
607
    if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0)  // JBF 20031211
607
    if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0)  // JBF 20031211
608
        ud.config.scripthandle = SCRIPT_Load(setupfilename);
608
        ud.config.scripthandle = SCRIPT_Load(setupfilename);
609
    pathsearchmode = 0;
609
    pathsearchmode = 0;
610
610
611
    if (ud.config.scripthandle < 0) return -1;
611
    if (ud.config.scripthandle < 0) return -1;
612
612
613
    if (ud.config.scripthandle >= 0)
613
    if (ud.config.scripthandle >= 0)
614
    {
614
    {
615
        for (dummy = 0;dummy < 10;dummy++)
615
        for (dummy = 0;dummy < 10;dummy++)
616
        {
616
        {
617
            commmacro[13] = dummy+'0';
617
            commmacro[13] = dummy+'0';
618
            SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
618
            SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
619
        }
619
        }
620
620
621
        SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","PlayerName",&tempbuf[0]);
621
        SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","PlayerName",&tempbuf[0]);
622
622
623
        while (Bstrlen(stripcolorcodes(tempbuf)) > 10)
623
        while (Bstrlen(stripcolorcodes(tempbuf)) > 10)
624
            tempbuf[Bstrlen(tempbuf)-1] = '\0';
624
            tempbuf[Bstrlen(tempbuf)-1] = '\0';
625
625
626
        Bstrncpy(myname,tempbuf,sizeof(myname)-1);
626
        Bstrncpy(myname,tempbuf,sizeof(myname)-1);
627
        myname[sizeof(myname)-1] = '\0';
627
        myname[sizeof(myname)-1] = '\0';
628
628
629
        SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
629
        SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
630
630
631
        SCRIPT_GetNumber(ud.config.scripthandle, "Comm Setup", "Rate",(int32 *)&packetrate);
631
        SCRIPT_GetNumber(ud.config.scripthandle, "Comm Setup", "Rate",(int32 *)&packetrate);
632
        packetrate = min(max(packetrate,50),1000);
632
        packetrate = min(max(packetrate,50),1000);
633
633
634
        {
634
        {
635
            extern char defaultduke3dgrp[BMAX_PATH];
635
            extern char defaultduke3dgrp[BMAX_PATH];
636
            if (!Bstrcmp(defaultduke3dgrp,"duke3d.grp"))
636
            if (!Bstrcmp(defaultduke3dgrp,"duke3d.grp"))
637
                SCRIPT_GetString(ud.config.scripthandle, "Misc","SelectedGRP",&duke3dgrp[0]);
637
                SCRIPT_GetString(ud.config.scripthandle, "Misc","SelectedGRP",&duke3dgrp[0]);
638
        }
638
        }
639
639
640
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Shadows",&ud.shadows);
640
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Shadows",&ud.shadows);
641
641
642
        if (!NAM)
642
        if (!NAM)
643
        {
643
        {
644
            SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]);
644
            SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]);
645
            SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout);
645
            SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout);
646
        }
646
        }
647
647
648
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Detail",&ud.detail);
648
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Detail",&ud.detail);
649
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Tilt",&ud.screen_tilting);
649
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Tilt",&ud.screen_tilting);
650
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Messages",&ud.fta_on);
650
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Messages",&ud.fta_on);
651
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth);
651
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth);
652
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight);
652
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight);
653
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode);
653
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode);
654
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenGamma",&ud.brightness);
654
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenGamma",&ud.brightness);
655
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenSize",&ud.screen_size);
655
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenSize",&ud.screen_size);
656
656
657
        tempbuf[0] = 0;
657
        tempbuf[0] = 0;
658
        SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidGamma",&tempbuf[0]);
658
        SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidGamma",&tempbuf[0]);
659
        if (tempbuf[0]) vid_gamma = atof(tempbuf);
659
        if (tempbuf[0]) vid_gamma = atof(tempbuf);
660
        tempbuf[0] = 0;
660
        tempbuf[0] = 0;
661
        SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidBrightness",&tempbuf[0]);
661
        SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidBrightness",&tempbuf[0]);
662
        if (tempbuf[0]) vid_brightness = atof(tempbuf);
662
        if (tempbuf[0]) vid_brightness = atof(tempbuf);
663
        tempbuf[0] = 0;
663
        tempbuf[0] = 0;
664
        SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidContrast",&tempbuf[0]);
664
        SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidContrast",&tempbuf[0]);
665
        if (tempbuf[0]) vid_contrast = atof(tempbuf);
665
        if (tempbuf[0]) vid_contrast = atof(tempbuf);
666
666
667
#if defined(POLYMOST) && defined(USE_OPENGL)
667
#if defined(POLYMOST) && defined(USE_OPENGL)
668
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP);
668
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP);
669
        if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32;
669
        if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32;
670
#endif
670
#endif
671
671
672
#ifdef RENDERTYPEWIN
672
#ifdef RENDERTYPEWIN
673
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32*)&maxrefreshfreq);
673
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32*)&maxrefreshfreq);
674
#endif
674
#endif
675
#if defined(POLYMOST) && defined(USE_OPENGL)
675
#if defined(POLYMOST) && defined(USE_OPENGL)
676
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureMode", &gltexfiltermode);
676
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureMode", &gltexfiltermode);
677
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLAnisotropy", &glanisotropy);
677
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLAnisotropy", &glanisotropy);
678
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLProjectionFix", &glprojectionhacks);
678
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLProjectionFix", &glprojectionhacks);
679
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCompr", &glusetexcompr);
679
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCompr", &glusetexcompr);
680
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLWidescreen", &glwidescreen);
680
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLWidescreen", &glwidescreen);
681
681
682
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache);
682
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache);
683
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression);
683
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression);
684
684
685
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLDepthPeeling", &r_depthpeeling);
685
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLDepthPeeling", &r_depthpeeling);
686
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLPeelsCount", &r_peelscount);
686
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLPeelsCount", &r_peelscount);
687
687
-
 
688
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLFullbrights", &r_fullbright);
688
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLDetailMapping", &r_detailmapping);
689
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLDetailMapping", &r_detailmapping);
689
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLGlowMapping", &r_glowmapping);
690
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLGlowMapping", &r_glowmapping);
690
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVertexArrays", &r_vertexarrays);
691
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVertexArrays", &r_vertexarrays);
691
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", &r_vbos);
692
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", &r_vbos);
692
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", &r_vbocount);
693
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", &r_vbocount);
693
694
694
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing", &r_animsmoothing);
695
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing", &r_animsmoothing);
695
696
696
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping", &r_parallaxskyclamping);
697
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping", &r_parallaxskyclamping);
697
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning", &r_parallaxskypanning);
698
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning", &r_parallaxskypanning);
698
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLCullObstructedModels", &r_cullobstructedmodels);
699
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLCullObstructedModels", &r_cullobstructedmodels);
699
        dummy = usemodels;
700
        dummy = usemodels;
700
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy);
701
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy);
701
        usemodels = dummy != 0;
702
        usemodels = dummy != 0;
702
        dummy = usehightile;
703
        dummy = usehightile;
703
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseHightile",&dummy);
704
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseHightile",&dummy);
704
        usehightile = dummy != 0;
705
        usehightile = dummy != 0;
705
#endif
706
#endif
706
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions);
707
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions);
707
        SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup",&ud.config.ForceSetup);
708
        SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup",&ud.config.ForceSetup);
708
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "RunMode",&ud.config.RunMode);
709
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "RunMode",&ud.config.RunMode);
709
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Crosshairs",&ud.crosshair);
710
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Crosshairs",&ud.crosshair);
710
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "CrosshairScale",&ud.crosshairscale);
711
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "CrosshairScale",&ud.crosshairscale);
711
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale);
712
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale);
712
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",&ud.levelstats);
713
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",&ud.levelstats);
713
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowOpponentWeapons",&ud.config.ShowOpponentWeapons);
714
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowOpponentWeapons",&ud.config.ShowOpponentWeapons);
714
        ud.showweapons = ud.config.ShowOpponentWeapons;
715
        ud.showweapons = ud.config.ShowOpponentWeapons;
715
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowViewWeapon",&ud.drawweapon);
716
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowViewWeapon",&ud.drawweapon);
716
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "DeathMessages",&ud.deathmsgs);
717
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "DeathMessages",&ud.deathmsgs);
717
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "DemoCams",&ud.democams);
718
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "DemoCams",&ud.democams);
718
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowFPS",&ud.tickrate);
719
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowFPS",&ud.tickrate);
719
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Color",&ud.color);
720
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Color",&ud.color);
720
        check_valid_color((int *)&ud.color,-1);
721
        check_valid_color((int *)&ud.color,-1);
721
        g_player[0].ps->palookup = g_player[0].pcolor = ud.color;
722
        g_player[0].ps->palookup = g_player[0].pcolor = ud.color;
722
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Team",&dummy);
723
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Team",&dummy);
723
        ud.team = 0;
724
        ud.team = 0;
724
        if (dummy < 4 && dummy > -1) ud.team = dummy;
725
        if (dummy < 4 && dummy > -1) ud.team = dummy;
725
        g_player[0].pteam = ud.team;
726
        g_player[0].pteam = ud.team;
726
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "MPMessageDisplayTime",&ud.msgdisptime);
727
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "MPMessageDisplayTime",&ud.msgdisptime);
727
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarMode",&ud.statusbarmode);
728
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarMode",&ud.statusbarmode);
728
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AutoVote",&ud.autovote);
729
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AutoVote",&ud.autovote);
729
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AutoMsg",&ud.automsg);
730
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AutoMsg",&ud.automsg);
730
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "IDPlayers",&ud.automsg);
731
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "IDPlayers",&ud.automsg);
731
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ViewBobbing",&ud.viewbob);
732
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ViewBobbing",&ud.viewbob);
732
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "WeaponSway",&ud.weaponsway);
733
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "WeaponSway",&ud.weaponsway);
733
734
734
        dummy = ud.config.useprecache;
735
        dummy = ud.config.useprecache;
735
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "UsePrecache",&dummy);
736
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "UsePrecache",&dummy);
736
        ud.config.useprecache = dummy != 0;
737
        ud.config.useprecache = dummy != 0;
737
738
738
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc","AngleInterpolation",&ud.angleinterpolation);
739
        SCRIPT_GetNumber(ud.config.scripthandle, "Misc","AngleInterpolation",&ud.angleinterpolation);
739
740
740
        // weapon choices are defaulted in checkcommandline, which may override them
741
        // weapon choices are defaulted in checkcommandline, which may override them
741
        if (!CommandWeaponChoice)
742
        if (!CommandWeaponChoice)
742
            for (i=0;i<10;i++)
743
            for (i=0;i<10;i++)
743
            {
744
            {
744
                Bsprintf(buf,"WeaponChoice%d",i);
745
                Bsprintf(buf,"WeaponChoice%d",i);
745
                dummy = -1;
746
                dummy = -1;
746
                SCRIPT_GetNumber(ud.config.scripthandle, "Misc", buf, &dummy);
747
                SCRIPT_GetNumber(ud.config.scripthandle, "Misc", buf, &dummy);
747
                if (dummy >= 0) g_player[0].wchoice[i] = dummy;
748
                if (dummy >= 0) g_player[0].wchoice[i] = dummy;
748
            }
749
            }
749
750
750
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "FXDevice",&ud.config.FXDevice);
751
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "FXDevice",&ud.config.FXDevice);
751
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicDevice",&ud.config.MusicDevice);
752
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicDevice",&ud.config.MusicDevice);
752
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "FXVolume",&ud.config.FXVolume);
753
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "FXVolume",&ud.config.FXVolume);
753
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicVolume",&ud.config.MusicVolume);
754
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicVolume",&ud.config.MusicVolume);
754
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "SoundToggle",&ud.config.SoundToggle);
755
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "SoundToggle",&ud.config.SoundToggle);
755
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicToggle",&ud.config.MusicToggle);
756
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicToggle",&ud.config.MusicToggle);
756
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "VoiceToggle",&ud.config.VoiceToggle);
757
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "VoiceToggle",&ud.config.VoiceToggle);
757
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "AmbienceToggle",&ud.config.AmbienceToggle);
758
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "AmbienceToggle",&ud.config.AmbienceToggle);
758
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumVoices",&ud.config.NumVoices);
759
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumVoices",&ud.config.NumVoices);
759
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumChannels",&ud.config.NumChannels);
760
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumChannels",&ud.config.NumChannels);
760
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumBits",&ud.config.NumBits);
761
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumBits",&ud.config.NumBits);
761
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MixRate",&ud.config.MixRate);
762
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MixRate",&ud.config.MixRate);
762
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "ReverseStereo",&ud.config.ReverseStereo);
763
        SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "ReverseStereo",&ud.config.ReverseStereo);
763
764
764
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseAimingFlipped",&ud.mouseflip);  // mouse aiming inverted
765
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseAimingFlipped",&ud.mouseflip);  // mouse aiming inverted
765
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseAiming",&ud.mouseaiming);             // 1=momentary/0=toggle
766
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseAiming",&ud.mouseaiming);             // 1=momentary/0=toggle
766
        g_player[0].ps->aim_mode = ud.mouseaiming;
767
        g_player[0].ps->aim_mode = ud.mouseaiming;
767
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseBias",&ud.config.MouseBias);
768
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseBias",&ud.config.MouseBias);
768
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseFilter",&ud.config.MouseFilter);
769
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseFilter",&ud.config.MouseFilter);
769
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","SmoothInput",&ud.config.SmoothInput);
770
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","SmoothInput",&ud.config.SmoothInput);
770
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","UseJoystick",&ud.config.UseJoystick);
771
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","UseJoystick",&ud.config.UseJoystick);
771
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","UseMouse",&ud.config.UseMouse);
772
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","UseMouse",&ud.config.UseMouse);
772
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","AimingFlag",(int32 *)&myaimmode);    // (if toggle mode) gives state
773
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","AimingFlag",(int32 *)&myaimmode);    // (if toggle mode) gives state
773
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","RunKeyBehaviour",&ud.runkey_mode);   // JBF 20031125
774
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","RunKeyBehaviour",&ud.runkey_mode);   // JBF 20031125
774
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","AutoAim",&ud.config.AutoAim);          // JBF 20031125
775
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","AutoAim",&ud.config.AutoAim);          // JBF 20031125
775
        g_player[0].ps->auto_aim = ud.config.AutoAim;
776
        g_player[0].ps->auto_aim = ud.config.AutoAim;
776
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","WeaponSwitchMode",&ud.weaponswitch);
777
        SCRIPT_GetNumber(ud.config.scripthandle, "Controls","WeaponSwitchMode",&ud.weaponswitch);
777
        g_player[0].ps->weaponswitch = ud.weaponswitch;
778
        g_player[0].ps->weaponswitch = ud.weaponswitch;
778
779
779
#ifdef _WIN32
780
#ifdef _WIN32
780
        SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", &ud.config.CheckForUpdates);
781
        SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", &ud.config.CheckForUpdates);
781
        SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", &ud.config.LastUpdateCheck);
782
        SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", &ud.config.LastUpdateCheck);
782
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32 *)&windowpos);
783
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32 *)&windowpos);
783
        windowx = -1;
784
        windowx = -1;
784
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32 *)&windowx);
785
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32 *)&windowx);
785
        windowy = -1;
786
        windowy = -1;
786
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32 *)&windowy);
787
        SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32 *)&windowy);
787
#endif
788
#endif
788
    }
789
    }
789
790
790
    CONFIG_ReadKeys();
791
    CONFIG_ReadKeys();
791
792
792
    //CONFIG_SetupMouse(ud.config.scripthandle);
793
    //CONFIG_SetupMouse(ud.config.scripthandle);
793
    //CONFIG_SetupJoystick(ud.config.scripthandle);
794
    //CONFIG_SetupJoystick(ud.config.scripthandle);
794
    ud.config.setupread = 1;
795
    ud.config.setupread = 1;
795
    return 0;
796
    return 0;
796
}
797
}
797
798
798
/*
799
/*
799
===================
800
===================
800
=
801
=
801
= CONFIG_WriteSetup
802
= CONFIG_WriteSetup
802
=
803
=
803
===================
804
===================
804
*/
805
*/
805
806
806
void CONFIG_WriteBinds(void) // save binds and aliases to disk
807
void CONFIG_WriteBinds(void) // save binds and aliases to disk
807
{
808
{
808
    int i;
809
    int i;
809
    FILE *fp = fopen("binds.cfg", "wt");
810
    FILE *fp = fopen("binds.cfg", "wt");
810
811
811
    if (fp)
812
    if (fp)
812
    {
813
    {
813
        symbol_t *symb;
814
        symbol_t *symb;
814
        fprintf(fp,"// this file automatically generated by EDuke32\n// do not modify if you lack common sense\n");
815
        fprintf(fp,"// this file automatically generated by EDuke32\n// do not modify if you lack common sense\n");
815
        for (i=0;i<MAXBOUNDKEYS;i++)
816
        for (i=0;i<MAXBOUNDKEYS;i++)
816
            if (boundkeys[i].cmd[0] && boundkeys[i].key)
817
            if (boundkeys[i].cmd[0] && boundkeys[i].key)
817
                fprintf(fp,"bind \"%s\"%s \"%s\"\n",boundkeys[i].key,boundkeys[i].repeat?"":" norepeat",boundkeys[i].cmd);
818
                fprintf(fp,"bind \"%s\"%s \"%s\"\n",boundkeys[i].key,boundkeys[i].repeat?"":" norepeat",boundkeys[i].cmd);
818
819
819
        for (i=0;i<MAXMOUSEBUTTONS;i++)
820
        for (i=0;i<MAXMOUSEBUTTONS;i++)
820
            if (mousebind[i].cmd[0])
821
            if (mousebind[i].cmd[0])
821
                fprintf(fp,"bind \"%s\"%s \"%s\"\n",mousebind[i].key,mousebind[i].repeat?"":" norepeat",mousebind[i].cmd);
822
                fprintf(fp,"bind \"%s\"%s \"%s\"\n",mousebind[i].key,mousebind[i].repeat?"":" norepeat",mousebind[i].cmd);
822
823
823
        for (symb=symbols; symb!=NULL; symb=symb->next)
824
        for (symb=symbols; symb!=NULL; symb=symb->next)
824
            if (symb->func == (void *)OSD_ALIAS)
825
            if (symb->func == (void *)OSD_ALIAS)
825
                fprintf(fp,"alias \"%s\" \"%s\"\n", symb->name, symb->help);
826
                fprintf(fp,"alias \"%s\" \"%s\"\n", symb->name, symb->help);
826
827
827
        /*        for (i = 0; i < sizeof(cvar)/sizeof(cvarmappings); i++)
828
        /*        for (i = 0; i < sizeof(cvar)/sizeof(cvarmappings); i++)
828
                    if (!(cvar[i].type&CVAR_NOSAVE))
829
                    if (!(cvar[i].type&CVAR_NOSAVE))
829
                        fprintf(fp,"%s \"%d\"\n",cvar[i].name,*(int*)cvar[i].var);
830
                        fprintf(fp,"%s \"%d\"\n",cvar[i].name,*(int*)cvar[i].var);
830
                        */
831
                        */
831
        fclose(fp);
832
        fclose(fp);
832
        OSD_Printf("Wrote binds.cfg\n");
833
        OSD_Printf("Wrote binds.cfg\n");
833
        return;
834
        return;
834
    }
835
    }
835
    OSD_Printf("Error writing binds.cfg: %s\n",strerror(errno));
836
    OSD_Printf("Error writing binds.cfg: %s\n",strerror(errno));
836
}
837
}
837
838
838
void CONFIG_WriteSetup(void)
839
void CONFIG_WriteSetup(void)
839
{
840
{
840
    int32 dummy;
841
    int32 dummy;
841
842
842
    if (!ud.config.setupread) return;
843
    if (!ud.config.setupread) return;
843
844
844
    if (ud.config.scripthandle < 0)
845
    if (ud.config.scripthandle < 0)
845
        ud.config.scripthandle = SCRIPT_Init(setupfilename);
846
        ud.config.scripthandle = SCRIPT_Init(setupfilename);
846
847
847
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AimingFlag",(int) myaimmode,false,false);
848
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AimingFlag",(int) myaimmode,false,false);
848
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AutoAim",ud.config.AutoAim,false,false);
849
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AutoAim",ud.config.AutoAim,false,false);
849
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseAimingFlipped",ud.mouseflip,false,false);
850
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseAimingFlipped",ud.mouseflip,false,false);
850
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseAiming",ud.mouseaiming,false,false);
851
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseAiming",ud.mouseaiming,false,false);
851
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseBias",ud.config.MouseBias,false,false);
852
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseBias",ud.config.MouseBias,false,false);
852
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseFilter",ud.config.MouseFilter,false,false);
853
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseFilter",ud.config.MouseFilter,false,false);
853
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","SmoothInput",ud.config.SmoothInput,false,false);
854
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","SmoothInput",ud.config.SmoothInput,false,false);
854
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","RunKeyBehaviour",ud.runkey_mode,false,false);
855
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","RunKeyBehaviour",ud.runkey_mode,false,false);
855
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","UseJoystick",ud.config.UseJoystick,false,false);
856
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","UseJoystick",ud.config.UseJoystick,false,false);
856
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","UseMouse",ud.config.UseMouse,false,false);
857
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","UseMouse",ud.config.UseMouse,false,false);
857
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","WeaponSwitchMode",ud.weaponswitch,false,false);
858
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","WeaponSwitchMode",ud.weaponswitch,false,false);
858
859
859
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AutoMsg",ud.automsg,false,false);
860
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AutoMsg",ud.automsg,false,false);
860
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AutoVote",ud.autovote,false,false);
861
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AutoVote",ud.autovote,false,false);
861
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Color",ud.color,false,false);
862
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Color",ud.color,false,false);
862
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Crosshairs",ud.crosshair,false,false);
863
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Crosshairs",ud.crosshair,false,false);
863
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "CrosshairScale",ud.crosshairscale,false,false);
864
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "CrosshairScale",ud.crosshairscale,false,false);
864
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "DeathMessages",ud.deathmsgs,false,false);
865
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "DeathMessages",ud.deathmsgs,false,false);
865
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "DemoCams",ud.democams,false,false);
866
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "DemoCams",ud.democams,false,false);
866
    ud.executions++;
867
    ud.executions++;
867
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions",ud.executions,false,false);
868
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions",ud.executions,false,false);
868
    SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup",ud.config.ForceSetup,false,false);
869
    SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup",ud.config.ForceSetup,false,false);
869
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "IDPlayers",ud.idplayers,false,false);
870
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "IDPlayers",ud.idplayers,false,false);
870
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "MPMessageDisplayTime",ud.msgdisptime,false,false);
871
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "MPMessageDisplayTime",ud.msgdisptime,false,false);
871
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "RunMode",ud.config.RunMode,false,false);
872
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "RunMode",ud.config.RunMode,false,false);
872
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ShowFPS",ud.tickrate,false,false);
873
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ShowFPS",ud.tickrate,false,false);
873
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",ud.levelstats,false,false);
874
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",ud.levelstats,false,false);
874
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ShowOpponentWeapons",ud.config.ShowOpponentWeapons,false,false);
875
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ShowOpponentWeapons",ud.config.ShowOpponentWeapons,false,false);
875
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ShowViewWeapon",ud.drawweapon,false,false);
876
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ShowViewWeapon",ud.drawweapon,false,false);
876
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "StatusBarMode",ud.statusbarmode,false,false);
877
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "StatusBarMode",ud.statusbarmode,false,false);
877
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "StatusBarScale",ud.statusbarscale,false,false);
878
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "StatusBarScale",ud.statusbarscale,false,false);
878
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Team",ud.team,false,false);
879
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Team",ud.team,false,false);
879
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "UsePrecache",ud.config.useprecache,false,false);
880
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "UsePrecache",ud.config.useprecache,false,false);
880
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ViewBobbing",ud.viewbob,false,false);
881
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ViewBobbing",ud.viewbob,false,false);
881
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "WeaponSway",ud.weaponsway,false,false);
882
    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "WeaponSway",ud.weaponsway,false,false);
882
//    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AngleInterpolation",ud.angleinterpolation,false,false);
883
//    SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AngleInterpolation",ud.angleinterpolation,false,false);
883
884
884
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Detail",ud.detail,false,false);
885
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Detail",ud.detail,false,false);
885
#if defined(POLYMOST) && defined(USE_OPENGL)
886
#if defined(POLYMOST) && defined(USE_OPENGL)
886
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnisotropy",glanisotropy,false,false);
887
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnisotropy",glanisotropy,false,false);
887
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLProjectionFix",glprojectionhacks,false,false);
888
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLProjectionFix",glprojectionhacks,false,false);
888
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLTextureMode",gltexfiltermode,false,false);
889
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLTextureMode",gltexfiltermode,false,false);
889
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseCompressedTextureCache", glusetexcache,false,false);
890
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseCompressedTextureCache", glusetexcache,false,false);
890
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCacheCompression", glusetexcachecompression,false,false);
891
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCacheCompression", glusetexcachecompression,false,false);
891
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCompr",glusetexcompr,false,false);
892
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCompr",glusetexcompr,false,false);
892
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLWidescreen",glwidescreen,false,false);
893
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLWidescreen",glwidescreen,false,false);
893
894
894
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLDepthPeeling",r_depthpeeling,false,false);
895
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLDepthPeeling",r_depthpeeling,false,false);
895
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLPeelsCount",r_peelscount,false,false);
896
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLPeelsCount",r_peelscount,false,false);
896
897
-
 
898
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLFullbright", r_fullbright,false,false);
897
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLDetailMapping", r_detailmapping,false,false);
899
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLDetailMapping", r_detailmapping,false,false);
898
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLGlowMapping", r_glowmapping,false,false);
900
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLGlowMapping", r_glowmapping,false,false);
899
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVertexArrays", r_vertexarrays,false,false);
901
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVertexArrays", r_vertexarrays,false,false);
900
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", r_vbos,false,false);
902
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", r_vbos,false,false);
901
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", r_vbocount,false,false);
903
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", r_vbocount,false,false);
902
904
903
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing",r_animsmoothing,false,false);
905
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing",r_animsmoothing,false,false);
904
906
905
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping",r_parallaxskyclamping,false,false);
907
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping",r_parallaxskyclamping,false,false);
906
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning",r_parallaxskypanning,false,false);
908
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning",r_parallaxskypanning,false,false);
907
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLCullObstructedModels", r_cullobstructedmodels,false,false);
909
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLCullObstructedModels", r_cullobstructedmodels,false,false);
908
#endif
910
#endif
909
#ifdef RENDERTYPEWIN
911
#ifdef RENDERTYPEWIN
910
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq",maxrefreshfreq,false,false);
912
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq",maxrefreshfreq,false,false);
911
#endif
913
#endif
912
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Messages",ud.fta_on,false,false);
914
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Messages",ud.fta_on,false,false);
913
915
914
    if (!NAM)
916
    if (!NAM)
915
    {
917
    {
916
        SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Out",ud.lockout,false,false);
918
        SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Out",ud.lockout,false,false);
917
        SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "Password",ud.pwlockout);
919
        SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "Password",ud.pwlockout);
918
    }
920
    }
919
921
920
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP",ud.config.ScreenBPP,false,false);  // JBF 20040523
922
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP",ud.config.ScreenBPP,false,false);  // JBF 20040523
921
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenGamma",ud.brightness,false,false);
923
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenGamma",ud.brightness,false,false);
922
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",ud.config.ScreenHeight,false,false);    // JBF 20031206
924
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",ud.config.ScreenHeight,false,false);    // JBF 20031206
923
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",ud.config.ScreenMode,false,false);    // JBF 20031206
925
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",ud.config.ScreenMode,false,false);    // JBF 20031206
924
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenSize",ud.screen_size,false,false);
926
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenSize",ud.screen_size,false,false);
925
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",ud.config.ScreenWidth,false,false);  // JBF 20031206
927
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",ud.config.ScreenWidth,false,false);  // JBF 20031206
926
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Shadows",ud.shadows,false,false);
928
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Shadows",ud.shadows,false,false);
927
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Tilt",ud.screen_tilting,false,false);
929
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Tilt",ud.screen_tilting,false,false);
928
#if defined(POLYMOST) && defined(USE_OPENGL)
930
#if defined(POLYMOST) && defined(USE_OPENGL)
929
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "UseHightile",usehightile,false,false);
931
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "UseHightile",usehightile,false,false);
930
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "UseModels",usemodels,false,false);
932
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "UseModels",usemodels,false,false);
931
#endif
933
#endif
932
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "AmbienceToggle",ud.config.AmbienceToggle,false,false);
934
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "AmbienceToggle",ud.config.AmbienceToggle,false,false);
933
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "FXVolume",ud.config.FXVolume,false,false);
935
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "FXVolume",ud.config.FXVolume,false,false);
934
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "MusicToggle",ud.config.MusicToggle,false,false);
936
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "MusicToggle",ud.config.MusicToggle,false,false);
935
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "MusicVolume",ud.config.MusicVolume,false,false);
937
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "MusicVolume",ud.config.MusicVolume,false,false);
936
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "NumVoices",ud.config.NumVoices,false,false);
938
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "NumVoices",ud.config.NumVoices,false,false);
937
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "NumChannels",ud.config.NumChannels,false,false);
939
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "NumChannels",ud.config.NumChannels,false,false);
938
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "NumBits",ud.config.NumBits,false,false);
940
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "NumBits",ud.config.NumBits,false,false);
939
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "MixRate",ud.config.MixRate,false,false);
941
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "MixRate",ud.config.MixRate,false,false);
940
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "ReverseStereo",ud.config.ReverseStereo,false,false);
942
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "ReverseStereo",ud.config.ReverseStereo,false,false);
941
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "SoundToggle",ud.config.SoundToggle,false,false);
943
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "SoundToggle",ud.config.SoundToggle,false,false);
942
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "VoiceToggle",ud.config.VoiceToggle,false,false);
944
    SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "VoiceToggle",ud.config.VoiceToggle,false,false);
943
945
944
    Bsprintf(tempbuf,"%.2f",vid_gamma);
946
    Bsprintf(tempbuf,"%.2f",vid_gamma);
945
    SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidGamma",tempbuf);
947
    SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidGamma",tempbuf);
946
    Bsprintf(tempbuf,"%.2f",vid_brightness);
948
    Bsprintf(tempbuf,"%.2f",vid_brightness);
947
    SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidBrightness",tempbuf);
949
    SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidBrightness",tempbuf);
948
    Bsprintf(tempbuf,"%.2f",vid_contrast);
950
    Bsprintf(tempbuf,"%.2f",vid_contrast);
949
    SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidContrast",tempbuf);
951
    SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidContrast",tempbuf);
950
952
951
#ifdef _WIN32
953
#ifdef _WIN32
952
    SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", ud.config.CheckForUpdates, false, false);
954
    SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", ud.config.CheckForUpdates, false, false);
953
    SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", ud.config.LastUpdateCheck, false, false);
955
    SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", ud.config.LastUpdateCheck, false, false);
954
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", windowpos, false, false);
956
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", windowpos, false, false);
955
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", windowx, false, false);
957
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", windowx, false, false);
956
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, false, false);
958
    SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, false, false);
957
#endif
959
#endif
958
960
959
    // JBF 20031211
961
    // JBF 20031211
960
    for (dummy=0;dummy<NUMGAMEFUNCTIONS;dummy++)
962
    for (dummy=0;dummy<NUMGAMEFUNCTIONS;dummy++)
961
    {
963
    {
962
        SCRIPT_PutDoubleString(ud.config.scripthandle, "KeyDefinitions", CONFIG_FunctionNumToName(dummy),
964
        SCRIPT_PutDoubleString(ud.config.scripthandle, "KeyDefinitions", CONFIG_FunctionNumToName(dummy),
963
                               KB_ScanCodeToString(ud.config.KeyboardKeys[dummy][0]), KB_ScanCodeToString(ud.config.KeyboardKeys[dummy][1]));
965
                               KB_ScanCodeToString(ud.config.KeyboardKeys[dummy][0]), KB_ScanCodeToString(ud.config.KeyboardKeys[dummy][1]));
964
    }
966
    }
965
967
966
    for (dummy=0;dummy<10;dummy++)
968
    for (dummy=0;dummy<10;dummy++)
967
    {
969
    {
968
        Bsprintf(buf,"WeaponChoice%d",dummy);
970
        Bsprintf(buf,"WeaponChoice%d",dummy);
969
        SCRIPT_PutNumber(ud.config.scripthandle, "Misc",buf,g_player[myconnectindex].wchoice[dummy],false,false);
971
        SCRIPT_PutNumber(ud.config.scripthandle, "Misc",buf,g_player[myconnectindex].wchoice[dummy],false,false);
970
    }
972
    }
971
973
972
    for (dummy=0;dummy<MAXMOUSEBUTTONS;dummy++)
974
    for (dummy=0;dummy<MAXMOUSEBUTTONS;dummy++)
973
    {
975
    {
974
        Bsprintf(buf,"MouseButton%d",dummy);
976
        Bsprintf(buf,"MouseButton%d",dummy);
975
        SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][0]));
977
        SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][0]));
976
978
977
        if (dummy >= (MAXMOUSEBUTTONS-2)) continue;
979
        if (dummy >= (MAXMOUSEBUTTONS-2)) continue;
978
980
979
        Bsprintf(buf,"MouseButtonClicked%d",dummy);
981
        Bsprintf(buf,"MouseButtonClicked%d",dummy);
980
        SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][1]));
982
        SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][1]));
981
    }
983
    }
982
984
983
    for (dummy=0;dummy<MAXMOUSEAXES;dummy++)
985
    for (dummy=0;dummy<MAXMOUSEAXES;dummy++)
984
    {
986
    {
985
        Bsprintf(buf,"MouseAnalogAxes%d",dummy);
987
        Bsprintf(buf,"MouseAnalogAxes%d",dummy);
986
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_AnalogNumToName(ud.config.MouseAnalogueAxes[dummy]));
988
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_AnalogNumToName(ud.config.MouseAnalogueAxes[dummy]));
987
989
988
        Bsprintf(buf,"MouseDigitalAxes%d_0",dummy);
990
        Bsprintf(buf,"MouseDigitalAxes%d_0",dummy);
989
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[dummy][0]));
991
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[dummy][0]));
990
992
991
        Bsprintf(buf,"MouseDigitalAxes%d_1",dummy);
993
        Bsprintf(buf,"MouseDigitalAxes%d_1",dummy);
992
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[dummy][1]));
994
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[dummy][1]));
993
995
994
        Bsprintf(buf,"MouseAnalogScale%d",dummy);
996
        Bsprintf(buf,"MouseAnalogScale%d",dummy);
995
        SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.MouseAnalogueScale[dummy], false, false);
997
        SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.MouseAnalogueScale[dummy], false, false);
996
    }
998
    }
997
    dummy = CONTROL_GetMouseSensitivity();
999
    dummy = CONTROL_GetMouseSensitivity();
998
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","Mouse_Sensitivity",dummy,false,false);
1000
    SCRIPT_PutNumber(ud.config.scripthandle, "Controls","Mouse_Sensitivity",dummy,false,false);
999
1001
1000
    for (dummy=0;dummy<MAXJOYBUTTONS;dummy++)
1002
    for (dummy=0;dummy<MAXJOYBUTTONS;dummy++)
1001
    {
1003
    {
1002
        Bsprintf(buf,"JoystickButton%d",dummy);
1004
        Bsprintf(buf,"JoystickButton%d",dummy);
1003
        SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickFunctions[dummy][0]));
1005
        SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickFunctions[dummy][0]));
1004
1006
1005
        Bsprintf(buf,"JoystickButtonClicked%d",dummy);
1007
        Bsprintf(buf,"JoystickButtonClicked%d",dummy);
1006
        SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickFunctions[dummy][1]));
1008
        SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickFunctions[dummy][1]));
1007
    }
1009
    }
1008
    for (dummy=0;dummy<MAXJOYAXES;dummy++)
1010
    for (dummy=0;dummy<MAXJOYAXES;dummy++)
1009
    {
1011
    {
1010
        Bsprintf(buf,"JoystickAnalogAxes%d",dummy);
1012
        Bsprintf(buf,"JoystickAnalogAxes%d",dummy);
1011
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_AnalogNumToName(ud.config.JoystickAnalogueAxes[dummy]));
1013
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_AnalogNumToName(ud.config.JoystickAnalogueAxes[dummy]));
1012
1014
1013
        Bsprintf(buf,"JoystickDigitalAxes%d_0",dummy);
1015
        Bsprintf(buf,"JoystickDigitalAxes%d_0",dummy);
1014
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[dummy][0]));
1016
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[dummy][0]));
1015
1017
1016
        Bsprintf(buf,"JoystickDigitalAxes%d_1",dummy);
1018
        Bsprintf(buf,"JoystickDigitalAxes%d_1",dummy);
1017
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[dummy][1]));
1019
        SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[dummy][1]));
1018
1020
1019
        Bsprintf(buf,"JoystickAnalogScale%d",dummy);
1021
        Bsprintf(buf,"JoystickAnalogScale%d",dummy);
1020
        SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueScale[dummy], false, false);
1022
        SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueScale[dummy], false, false);
1021
1023
1022
        Bsprintf(buf,"JoystickAnalogDead%d",dummy);
1024
        Bsprintf(buf,"JoystickAnalogDead%d",dummy);
1023
        SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueDead[dummy], false, false);
1025
        SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueDead[dummy], false, false);
1024
1026
1025
        Bsprintf(buf,"JoystickAnalogSaturate%d",dummy);
1027
        Bsprintf(buf,"JoystickAnalogSaturate%d",dummy);
1026
        SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueSaturate[dummy], false, false);
1028
        SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueSaturate[dummy], false, false);
1027
    }
1029
    }
1028
1030
1029
    SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","PlayerName",&myname[0]);
1031
    SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","PlayerName",&myname[0]);
1030
    SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
1032
    SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
1031
1033
1032
    SCRIPT_PutNumber(ud.config.scripthandle, "Comm Setup", "Rate", packetrate, false, false);
1034
    SCRIPT_PutNumber(ud.config.scripthandle, "Comm Setup", "Rate", packetrate, false, false);
1033
1035
1034
1036
1035
    SCRIPT_PutString(ud.config.scripthandle, "Misc","SelectedGRP",&duke3dgrp[0]);
1037
    SCRIPT_PutString(ud.config.scripthandle, "Misc","SelectedGRP",&duke3dgrp[0]);
1036
    {
1038
    {
1037
        char commmacro[] = "CommbatMacro# ";
1039
        char commmacro[] = "CommbatMacro# ";
1038
1040
1039
        for (dummy = 0;dummy < 10;dummy++)
1041
        for (dummy = 0;dummy < 10;dummy++)
1040
        {
1042
        {
1041
            commmacro[13] = dummy+'0';
1043
            commmacro[13] = dummy+'0';
1042
            SCRIPT_PutString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
1044
            SCRIPT_PutString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
1043
        }
1045
        }
1044
    }
1046
    }
1045
1047
1046
    SCRIPT_Save(ud.config.scripthandle, setupfilename);
1048
    SCRIPT_Save(ud.config.scripthandle, setupfilename);
1047
    SCRIPT_Free(ud.config.scripthandle);
1049
    SCRIPT_Free(ud.config.scripthandle);
1048
    OSD_Printf("Wrote %s\n",setupfilename);
1050
    OSD_Printf("Wrote %s\n",setupfilename);
1049
    CONFIG_WriteBinds();
1051
    CONFIG_WriteBinds();
1050
}
1052
}
1051
1053
1052
1054
1053
int32 CONFIG_GetMapBestTime(char *mapname)
1055
int32 CONFIG_GetMapBestTime(char *mapname)
1054
{
1056
{
1055
    int32 t = -1;
1057
    int32 t = -1;
1056
    char m[BMAX_PATH], *p;
1058
    char m[BMAX_PATH], *p;
1057
1059
1058
    strcpy(m, mapname);
1060
    strcpy(m, mapname);
1059
    p = strrchr(m, '/');
1061
    p = strrchr(m, '/');
1060
    if (!p) p = strrchr(m, '\\');
1062
    if (!p) p = strrchr(m, '\\');
1061
    if (p) strcpy(m, p);
1063
    if (p) strcpy(m, p);
1062
    for (p=m;*p;p++) *p = tolower(*p);
1064
    for (p=m;*p;p++) *p = tolower(*p);
1063
1065
1064
    if (!ud.config.setupread) return -1;
1066
    if (!ud.config.setupread) return -1;
1065
    if (ud.config.scripthandle < 0) return -1;
1067
    if (ud.config.scripthandle < 0) return -1;
1066
    SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", m, &t);
1068
    SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", m, &t);
1067
1069
1068
    return t;
1070
    return t;
1069
}
1071
}
1070
1072
1071
int32 CONFIG_SetMapBestTime(char *mapname, int32 tm)
1073
int32 CONFIG_SetMapBestTime(char *mapname, int32 tm)
1072
{
1074
{
1073
    char m[BMAX_PATH], *p;
1075
    char m[BMAX_PATH], *p;
1074
1076
1075
    strcpy(m, mapname);
1077
    strcpy(m, mapname);
1076
    p = strrchr(m, '/');
1078
    p = strrchr(m, '/');
1077
    if (!p) p = strrchr(m, '\\');
1079
    if (!p) p = strrchr(m, '\\');
1078
    if (p) strcpy(m, p);
1080
    if (p) strcpy(m, p);
1079
    for (p=m;*p;p++) *p = tolower(*p);
1081
    for (p=m;*p;p++) *p = tolower(*p);
1080
1082
1081
    if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(setupfilename);
1083
    if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(setupfilename);
1082
    if (ud.config.scripthandle < 0) return -1;
1084
    if (ud.config.scripthandle < 0) return -1;
1083
1085
1084
    SCRIPT_PutNumber(ud.config.scripthandle, "MapTimes", mapname, tm, false, false);
1086
    SCRIPT_PutNumber(ud.config.scripthandle, "MapTimes", mapname, tm, false, false);
1085
    return 0;
1087
    return 0;
1086
}
1088
}
1087
1089
1088
/*
1090
/*
1089
 * vim:ts=4:sw=4:
1091
 * vim:ts=4:sw=4:
1090
 */
1092
 */
1091
1093
1092
 
1094