Subversion Repositories eduke32

Rev

Rev 879 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 879 Rev 881
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
#include "compat.h"
25
#include "compat.h"
26
#include "osdcmds.h"
26
#include "osdcmds.h"
27
#include "osd.h"
27
#include "osd.h"
28
#include "baselayer.h"
28
#include "baselayer.h"
29
#include "duke3d.h"
29
#include "duke3d.h"
30
#include "crc32.h"
30
#include "crc32.h"
31
#include <ctype.h>
31
#include <ctype.h>
32
#include <limits.h>
32
#include <limits.h>
33
33
34
extern int voting, doquicksave;
34
extern int voting, doquicksave;
35
struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat;
35
struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat;
36
36
37
static inline int osdcmd_quit(const osdfuncparm_t *parm)
37
static inline int osdcmd_quit(const osdfuncparm_t *parm)
38
{
38
{
39
    UNREFERENCED_PARAMETER(parm);
39
    UNREFERENCED_PARAMETER(parm);
40
    sendquit();
40
    sendquit();
41
    return OSDCMD_OK;
41
    return OSDCMD_OK;
42
}
42
}
43
43
44
static int osdcmd_echo(const osdfuncparm_t *parm)
44
static int osdcmd_echo(const osdfuncparm_t *parm)
45
{
45
{
46
    int i;
46
    int i;
47
    for (i = 0; i < parm->numparms; i++)
47
    for (i = 0; i < parm->numparms; i++)
48
    {
48
    {
49
        if (i > 0) OSD_Printf(" ");
49
        if (i > 0) OSD_Printf(" ");
50
        OSD_Printf("%s", parm->parms[i]);
50
        OSD_Printf("%s", parm->parms[i]);
51
    }
51
    }
52
    OSD_Printf("\n");
52
    OSD_Printf("\n");
53
53
54
    return OSDCMD_OK;
54
    return OSDCMD_OK;
55
}
55
}
56
56
57
static int osdcmd_changelevel(const osdfuncparm_t *parm)
57
static int osdcmd_changelevel(const osdfuncparm_t *parm)
58
{
58
{
59
    int volume=0,level;
59
    int volume=0,level;
60
    char *p;
60
    char *p;
61
61
62
    if (!VOLUMEONE)
62
    if (!VOLUMEONE)
63
    {
63
    {
64
        if (parm->numparms != 2) return OSDCMD_SHOWHELP;
64
        if (parm->numparms != 2) return OSDCMD_SHOWHELP;
65
65
66
        volume = strtol(parm->parms[0], &p, 10) - 1;
66
        volume = strtol(parm->parms[0], &p, 10) - 1;
67
        if (p[0]) return OSDCMD_SHOWHELP;
67
        if (p[0]) return OSDCMD_SHOWHELP;
68
        level = strtol(parm->parms[1], &p, 10) - 1;
68
        level = strtol(parm->parms[1], &p, 10) - 1;
69
        if (p[0]) return OSDCMD_SHOWHELP;
69
        if (p[0]) return OSDCMD_SHOWHELP;
70
    }
70
    }
71
    else
71
    else
72
    {
72
    {
73
        if (parm->numparms != 1) return OSDCMD_SHOWHELP;
73
        if (parm->numparms != 1) return OSDCMD_SHOWHELP;
74
74
75
        level = strtol(parm->parms[0], &p, 10) - 1;
75
        level = strtol(parm->parms[0], &p, 10) - 1;
76
        if (p[0]) return OSDCMD_SHOWHELP;
76
        if (p[0]) return OSDCMD_SHOWHELP;
77
    }
77
    }
78
78
79
    if (volume < 0) return OSDCMD_SHOWHELP;
79
    if (volume < 0) return OSDCMD_SHOWHELP;
80
    if (level < 0) return OSDCMD_SHOWHELP;
80
    if (level < 0) return OSDCMD_SHOWHELP;
81
81
82
    if (!VOLUMEONE)
82
    if (!VOLUMEONE)
83
    {
83
    {
84
        if (volume > num_volumes)
84
        if (volume > num_volumes)
85
        {
85
        {
86
            OSD_Printf("changelevel: invalid volume number (range 1-%d)\n",num_volumes);
86
            OSD_Printf("changelevel: invalid volume number (range 1-%d)\n",num_volumes);
87
            return OSDCMD_OK;
87
            return OSDCMD_OK;
88
        }
88
        }
89
    }
89
    }
90
90
91
    if (level > MAXLEVELS || map[volume*MAXLEVELS+level].filename == NULL)
91
    if (level > MAXLEVELS || map[volume*MAXLEVELS+level].filename == NULL)
92
    {
92
    {
93
        OSD_Printf("changelevel: invalid level number\n");
93
        OSD_Printf("changelevel: invalid level number\n");
94
        return OSDCMD_SHOWHELP;
94
        return OSDCMD_SHOWHELP;
95
    }
95
    }
96
96
97
    if (numplayers > 1)
97
    if (numplayers > 1)
98
    {
98
    {
99
        if (myconnectindex == connecthead && networkmode == 0)
99
        if (myconnectindex == connecthead && networkmode == 0)
100
            mpchangemap(volume,level);
100
            mpchangemap(volume,level);
101
        else if (voting == -1)
101
        else if (voting == -1)
102
        {
102
        {
103
            ud.m_volume_number = volume;
103
            ud.m_volume_number = volume;
104
            ud.m_level_number = level;
104
            ud.m_level_number = level;
105
105
106
            if (g_player[myconnectindex].ps->i)
106
            if (g_player[myconnectindex].ps->i)
107
            {
107
            {
108
                int i;
108
                int i;
109
109
110
                for (i=0;i<MAXPLAYERS;i++)
110
                for (i=0;i<MAXPLAYERS;i++)
111
                {
111
                {
112
                    g_player[i].vote = 0;
112
                    g_player[i].vote = 0;
113
                    g_player[i].gotvote = 0;
113
                    g_player[i].gotvote = 0;
114
                }
114
                }
115
115
116
                g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
116
                g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
117
117
118
                voting = myconnectindex;
118
                voting = myconnectindex;
119
119
120
                tempbuf[0] = 18;
120
                tempbuf[0] = 18;
121
                tempbuf[1] = 1;
121
                tempbuf[1] = 1;
122
                tempbuf[2] = myconnectindex;
122
                tempbuf[2] = myconnectindex;
123
                tempbuf[3] = ud.m_volume_number;
123
                tempbuf[3] = ud.m_volume_number;
124
                tempbuf[4] = ud.m_level_number;
124
                tempbuf[4] = ud.m_level_number;
125
125
126
                for (i=connecthead;i>=0;i=connectpoint2[i])
126
                for (i=connecthead;i>=0;i=connectpoint2[i])
127
                {
127
                {
128
                    if (i != myconnectindex) sendpacket(i,tempbuf,5);
128
                    if (i != myconnectindex) sendpacket(i,tempbuf,5);
129
                    if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
129
                    if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
130
                }
130
                }
131
            }
131
            }
132
            if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY) && !(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_TDM))
132
            if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY) && !(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_TDM))
133
                ud.m_noexits = 0;
133
                ud.m_noexits = 0;
134
134
135
            g_player[myconnectindex].ps->gm |= MODE_MENU;
135
            g_player[myconnectindex].ps->gm |= MODE_MENU;
136
            cmenu(603);
136
            cmenu(603);
137
        }
137
        }
138
        return OSDCMD_OK;
138
        return OSDCMD_OK;
139
    }
139
    }
140
    if (g_player[myconnectindex].ps->gm & MODE_GAME)
140
    if (g_player[myconnectindex].ps->gm & MODE_GAME)
141
    {
141
    {
142
        // in-game behave like a cheat
142
        // in-game behave like a cheat
143
        osdcmd_cheatsinfo_stat.cheatnum = 2;
143
        osdcmd_cheatsinfo_stat.cheatnum = 2;
144
        osdcmd_cheatsinfo_stat.volume   = volume;
144
        osdcmd_cheatsinfo_stat.volume   = volume;
145
        osdcmd_cheatsinfo_stat.level    = level;
145
        osdcmd_cheatsinfo_stat.level    = level;
146
    }
146
    }
147
    else
147
    else
148
    {
148
    {
149
        // out-of-game behave like a menu command
149
        // out-of-game behave like a menu command
150
        osdcmd_cheatsinfo_stat.cheatnum = -1;
150
        osdcmd_cheatsinfo_stat.cheatnum = -1;
151
151
152
        ud.m_volume_number = volume;
152
        ud.m_volume_number = volume;
153
        ud.m_level_number = level;
153
        ud.m_level_number = level;
154
154
155
        ud.m_monsters_off = ud.monsters_off = 0;
155
        ud.m_monsters_off = ud.monsters_off = 0;
156
156
157
        ud.m_respawn_items = 0;
157
        ud.m_respawn_items = 0;
158
        ud.m_respawn_inventory = 0;
158
        ud.m_respawn_inventory = 0;
159
159
160
        ud.multimode = 1;
160
        ud.multimode = 1;
161
161
162
        newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill);
162
        newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill);
163
        if (enterlevel(MODE_GAME)) backtomenu();
163
        if (enterlevel(MODE_GAME)) backtomenu();
164
    }
164
    }
165
165
166
    return OSDCMD_OK;
166
    return OSDCMD_OK;
167
}
167
}
168
168
169
static int osdcmd_map(const osdfuncparm_t *parm)
169
static int osdcmd_map(const osdfuncparm_t *parm)
170
{
170
{
171
    int i;
171
    int i;
172
    char filename[256];
172
    char filename[256];
173
173
174
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
174
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
175
175
176
#if 0
176
#if 0
177
    if (numplayers > 1)
177
    if (numplayers > 1)
178
    {
178
    {
179
        OSD_Printf("Command not allowed in multiplayer\n");
179
        OSD_Printf("Command not allowed in multiplayer\n");
180
        return OSDCMD_OK;
180
        return OSDCMD_OK;
181
    }
181
    }
182
#endif
182
#endif
183
183
184
    strcpy(filename,parm->parms[0]);
184
    strcpy(filename,parm->parms[0]);
185
    if (strchr(filename,'.') == 0)
185
    if (strchr(filename,'.') == 0)
186
        strcat(filename,".map");
186
        strcat(filename,".map");
187
187
188
    if ((i = kopen4load(filename,0)) < 0)
188
    if ((i = kopen4load(filename,0)) < 0)
189
    {
189
    {
190
        OSD_Printf("map: file \"%s\" not found.\n", filename);
190
        OSD_Printf("map: file \"%s\" not found.\n", filename);
191
        return OSDCMD_OK;
191
        return OSDCMD_OK;
192
    }
192
    }
193
    kclose(i);
193
    kclose(i);
194
194
195
    boardfilename[0] = '/';
195
    boardfilename[0] = '/';
196
    boardfilename[1] = 0;
196
    boardfilename[1] = 0;
197
    strcat(boardfilename, filename);
197
    strcat(boardfilename, filename);
198
198
199
    if (numplayers > 1)
199
    if (numplayers > 1)
200
    {
200
    {
201
        if (myconnectindex == connecthead && networkmode == 0)
201
        if (myconnectindex == connecthead && networkmode == 0)
202
        {
202
        {
203
            sendboardname();
203
            sendboardname();
204
            mpchangemap(0,7);
204
            mpchangemap(0,7);
205
        }
205
        }
206
        else if (voting == -1)
206
        else if (voting == -1)
207
        {
207
        {
208
            sendboardname();
208
            sendboardname();
209
209
210
            ud.m_volume_number = 0;
210
            ud.m_volume_number = 0;
211
            ud.m_level_number = 7;
211
            ud.m_level_number = 7;
212
212
213
            if (g_player[myconnectindex].ps->i)
213
            if (g_player[myconnectindex].ps->i)
214
            {
214
            {
215
                int i;
215
                int i;
216
216
217
                for (i=0;i<MAXPLAYERS;i++)
217
                for (i=0;i<MAXPLAYERS;i++)
218
                {
218
                {
219
                    g_player[i].vote = 0;
219
                    g_player[i].vote = 0;
220
                    g_player[i].gotvote = 0;
220
                    g_player[i].gotvote = 0;
221
                }
221
                }
222
222
223
                g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
223
                g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
224
                voting = myconnectindex;
224
                voting = myconnectindex;
225
225
226
                tempbuf[0] = 18;
226
                tempbuf[0] = 18;
227
                tempbuf[1] = 1;
227
                tempbuf[1] = 1;
228
                tempbuf[2] = myconnectindex;
228
                tempbuf[2] = myconnectindex;
229
                tempbuf[3] = ud.m_volume_number;
229
                tempbuf[3] = ud.m_volume_number;
230
                tempbuf[4] = ud.m_level_number;
230
                tempbuf[4] = ud.m_level_number;
231
231
232
                for (i=connecthead;i>=0;i=connectpoint2[i])
232
                for (i=connecthead;i>=0;i=connectpoint2[i])
233
                {
233
                {
234
                    if (i != myconnectindex) sendpacket(i,tempbuf,5);
234
                    if (i != myconnectindex) sendpacket(i,tempbuf,5);
235
                    if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
235
                    if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
236
                }
236
                }
237
            }
237
            }
238
            if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY) && !(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_TDM))
238
            if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY) && !(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_TDM))
239
                ud.m_noexits = 0;
239
                ud.m_noexits = 0;
240
240
241
            g_player[myconnectindex].ps->gm |= MODE_MENU;
241
            g_player[myconnectindex].ps->gm |= MODE_MENU;
242
            cmenu(603);
242
            cmenu(603);
243
        }
243
        }
244
        return OSDCMD_OK;
244
        return OSDCMD_OK;
245
    }
245
    }
246
246
247
    osdcmd_cheatsinfo_stat.cheatnum = -1;
247
    osdcmd_cheatsinfo_stat.cheatnum = -1;
248
    ud.m_volume_number = 0;
248
    ud.m_volume_number = 0;
249
    ud.m_level_number = 7;
249
    ud.m_level_number = 7;
250
250
251
    ud.m_monsters_off = ud.monsters_off = 0;
251
    ud.m_monsters_off = ud.monsters_off = 0;
252
252
253
    ud.m_respawn_items = 0;
253
    ud.m_respawn_items = 0;
254
    ud.m_respawn_inventory = 0;
254
    ud.m_respawn_inventory = 0;
255
255
256
    ud.multimode = 1;
256
    ud.multimode = 1;
257
257
258
    newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill);
258
    newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill);
259
    if (enterlevel(MODE_GAME)) backtomenu();
259
    if (enterlevel(MODE_GAME)) backtomenu();
260
260
261
    return OSDCMD_OK;
261
    return OSDCMD_OK;
262
}
262
}
263
263
264
static int osdcmd_god(const osdfuncparm_t *parm)
264
static int osdcmd_god(const osdfuncparm_t *parm)
265
{
265
{
266
    UNREFERENCED_PARAMETER(parm);
266
    UNREFERENCED_PARAMETER(parm);
267
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
267
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
268
    {
268
    {
269
        osdcmd_cheatsinfo_stat.cheatnum = 0;
269
        osdcmd_cheatsinfo_stat.cheatnum = 0;
270
    }
270
    }
271
    else
271
    else
272
    {
272
    {
273
        OSD_Printf("god: Not in a single-player game.\n");
273
        OSD_Printf("god: Not in a single-player game.\n");
274
    }
274
    }
275
275
276
    return OSDCMD_OK;
276
    return OSDCMD_OK;
277
}
277
}
278
278
279
static int osdcmd_noclip(const osdfuncparm_t *parm)
279
static int osdcmd_noclip(const osdfuncparm_t *parm)
280
{
280
{
281
    UNREFERENCED_PARAMETER(parm);
281
    UNREFERENCED_PARAMETER(parm);
282
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
282
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
283
    {
283
    {
284
        osdcmd_cheatsinfo_stat.cheatnum = 20;
284
        osdcmd_cheatsinfo_stat.cheatnum = 20;
285
    }
285
    }
286
    else
286
    else
287
    {
287
    {
288
        OSD_Printf("noclip: Not in a single-player game.\n");
288
        OSD_Printf("noclip: Not in a single-player game.\n");
289
    }
289
    }
290
290
291
    return OSDCMD_OK;
291
    return OSDCMD_OK;
292
}
292
}
293
293
294
static int osdcmd_fileinfo(const osdfuncparm_t *parm)
294
static int osdcmd_fileinfo(const osdfuncparm_t *parm)
295
{
295
{
296
    unsigned int crc, length;
296
    unsigned int crc, length;
297
    int i,j;
297
    int i,j;
298
    char buf[256];
298
    char buf[256];
299
299
300
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
300
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
301
301
302
    if ((i = kopen4load((char *)parm->parms[0],0)) < 0)
302
    if ((i = kopen4load((char *)parm->parms[0],0)) < 0)
303
    {
303
    {
304
        OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]);
304
        OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]);
305
        return OSDCMD_OK;
305
        return OSDCMD_OK;
306
    }
306
    }
307
307
308
    length = kfilelength(i);
308
    length = kfilelength(i);
309
309
310
    crc32init(&crc);
310
    crc32init(&crc);
311
    do
311
    do
312
    {
312
    {
313
        j = kread(i,buf,256);
313
        j = kread(i,buf,256);
314
        crc32block(&crc,(unsigned char *)buf,j);
314
        crc32block(&crc,(unsigned char *)buf,j);
315
    }
315
    }
316
    while (j == 256);
316
    while (j == 256);
317
    crc32finish(&crc);
317
    crc32finish(&crc);
318
318
319
    kclose(i);
319
    kclose(i);
320
320
321
    OSD_Printf("fileinfo: %s\n"
321
    OSD_Printf("fileinfo: %s\n"
322
               "  File size: %d\n"
322
               "  File size: %d\n"
323
               "  CRC-32:    %08X\n",
323
               "  CRC-32:    %08X\n",
324
               parm->parms[0], length, crc);
324
               parm->parms[0], length, crc);
325
325
326
    return OSDCMD_OK;
326
    return OSDCMD_OK;
327
}
327
}
328
328
329
static int osdcmd_rate(const osdfuncparm_t *parm)
329
static int osdcmd_rate(const osdfuncparm_t *parm)
330
{
330
{
331
    int i;
331
    int i;
332
332
333
    if (parm->numparms == 0)
333
    if (parm->numparms == 0)
334
    {
334
    {
335
        OSD_Printf("\"rate\" is \"%d\"\n", packetrate);
335
        OSD_Printf("\"rate\" is \"%d\"\n", packetrate);
336
        return OSDCMD_SHOWHELP;
336
        return OSDCMD_SHOWHELP;
337
    }
337
    }
338
    else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
338
    else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
339
339
340
    i = Batol(parm->parms[0]);
340
    i = Batol(parm->parms[0]);
341
341
342
    if (i >= 40 && i <= 1000)
342
    if (i >= 40 && i <= 1000)
343
    {
343
    {
344
        packetrate = i;
344
        packetrate = i;
345
        OSD_Printf("rate %d\n", packetrate);
345
        OSD_Printf("rate %d\n", packetrate);
346
    }
346
    }
347
    else OSD_Printf("rate: value out of range\n");
347
    else OSD_Printf("rate: value out of range\n");
348
    return OSDCMD_OK;
348
    return OSDCMD_OK;
349
}
349
}
350
350
351
static int osdcmd_restartsound(const osdfuncparm_t *parm)
351
static int osdcmd_restartsound(const osdfuncparm_t *parm)
352
{
352
{
353
    UNREFERENCED_PARAMETER(parm);
353
    UNREFERENCED_PARAMETER(parm);
354
    SoundShutdown();
354
    SoundShutdown();
355
    MusicShutdown();
355
    MusicShutdown();
356
356
357
    initprintf("Initializing music...\n");
357
    initprintf("Initializing music...\n");
358
    MusicStartup();
358
    MusicStartup();
359
    initprintf("Initializing sound...\n");
359
    initprintf("Initializing sound...\n");
360
    SoundStartup();
360
    SoundStartup();
361
361
362
    FX_StopAllSounds();
362
    FX_StopAllSounds();
363
    clearsoundlocks();
363
    clearsoundlocks();
364
364
365
    if (ud.config.MusicToggle == 1)
365
    if (ud.config.MusicToggle == 1)
366
    {
366
    {
367
        if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME)
367
        if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME)
368
        {
368
        {
369
            if (map[(unsigned char)music_select].musicfn != NULL)
369
            if (map[(unsigned char)music_select].musicfn != NULL)
370
                playmusic(&map[(unsigned char)music_select].musicfn[0],music_select);
370
                playmusic(&map[(unsigned char)music_select].musicfn[0],music_select);
371
        }
371
        }
372
        else playmusic(&env_music_fn[0][0],MAXVOLUMES*MAXLEVELS);
372
        else playmusic(&env_music_fn[0][0],MAXVOLUMES*MAXLEVELS);
373
    }
373
    }
374
374
375
    return OSDCMD_OK;
375
    return OSDCMD_OK;
376
}
376
}
377
377
378
static int osdcmd_restartvid(const osdfuncparm_t *parm)
378
static int osdcmd_restartvid(const osdfuncparm_t *parm)
379
{
379
{
380
    UNREFERENCED_PARAMETER(parm);
380
    UNREFERENCED_PARAMETER(parm);
381
    resetvideomode();
381
    resetvideomode();
382
    if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP))
382
    if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP))
383
        gameexit("restartvid: Reset failed...\n");
383
        gameexit("restartvid: Reset failed...\n");
384
    onvideomodechange(ud.config.ScreenBPP>8);
384
    onvideomodechange(ud.config.ScreenBPP>8);
385
    vscrn();
385
    vscrn();
386
386
387
    return OSDCMD_OK;
387
    return OSDCMD_OK;
388
}
388
}
389
389
390
static int osdcmd_vidmode(const osdfuncparm_t *parm)
390
static int osdcmd_vidmode(const osdfuncparm_t *parm)
391
{
391
{
392
    int newbpp = ud.config.ScreenBPP, newwidth = ud.config.ScreenWidth,
392
    int newbpp = ud.config.ScreenBPP, newwidth = ud.config.ScreenWidth,
393
                 newheight = ud.config.ScreenHeight, newfs = ud.config.ScreenMode;
393
                 newheight = ud.config.ScreenHeight, newfs = ud.config.ScreenMode;
394
    if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
394
    if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
395
395
396
    switch (parm->numparms)
396
    switch (parm->numparms)
397
    {
397
    {
398
    case 1: // bpp switch
398
    case 1: // bpp switch
399
        newbpp = Batol(parm->parms[0]);
399
        newbpp = Batol(parm->parms[0]);
400
        break;
400
        break;
401
    case 2: // res switch
401
    case 2: // res switch
402
        newwidth = Batol(parm->parms[0]);
402
        newwidth = Batol(parm->parms[0]);
403
        newheight = Batol(parm->parms[1]);
403
        newheight = Batol(parm->parms[1]);
404
        break;
404
        break;
405
    case 3: // res & bpp switch
405
    case 3: // res & bpp switch
406
    case 4:
406
    case 4:
407
        newwidth = Batol(parm->parms[0]);
407
        newwidth = Batol(parm->parms[0]);
408
        newheight = Batol(parm->parms[1]);
408
        newheight = Batol(parm->parms[1]);
409
        newbpp = Batol(parm->parms[2]);
409
        newbpp = Batol(parm->parms[2]);
410
        if (parm->numparms == 4)
410
        if (parm->numparms == 4)
411
            newfs = (Batol(parm->parms[3]) != 0);
411
            newfs = (Batol(parm->parms[3]) != 0);
412
        break;
412
        break;
413
    }
413
    }
414
414
415
    if (setgamemode(newfs,newwidth,newheight,newbpp))
415
    if (setgamemode(newfs,newwidth,newheight,newbpp))
416
    {
416
    {
417
        initprintf("vidmode: Mode change failed!\n");
417
        initprintf("vidmode: Mode change failed!\n");
418
        if (setgamemode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP))
418
        if (setgamemode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP))
419
            gameexit("vidmode: Reset failed!\n");
419
            gameexit("vidmode: Reset failed!\n");
420
    }
420
    }
421
    ud.config.ScreenBPP = newbpp;
421
    ud.config.ScreenBPP = newbpp;
422
    ud.config.ScreenWidth = newwidth;
422
    ud.config.ScreenWidth = newwidth;
423
    ud.config.ScreenHeight = newheight;
423
    ud.config.ScreenHeight = newheight;
424
    ud.config.ScreenMode = newfs;
424
    ud.config.ScreenMode = newfs;
425
    onvideomodechange(ud.config.ScreenBPP>8);
425
    onvideomodechange(ud.config.ScreenBPP>8);
426
    vscrn();
426
    vscrn();
427
    return OSDCMD_OK;
427
    return OSDCMD_OK;
428
}
428
}
429
429
430
static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm)
430
static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm)
431
{
431
{
432
    if (parm->numparms == 0)
432
    if (parm->numparms == 0)
433
    {
433
    {
434
        OSD_Printf("\"cl_statusbarscale\" is \"%d\"\n", ud.statusbarscale);
434
        OSD_Printf("\"cl_statusbarscale\" is \"%d\"\n", ud.statusbarscale);
435
        return OSDCMD_SHOWHELP;
435
        return OSDCMD_SHOWHELP;
436
    }
436
    }
437
    else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
437
    else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
438
438
439
    setstatusbarscale(Batol(parm->parms[0]));
439
    setstatusbarscale(Batol(parm->parms[0]));
440
    OSD_Printf("cl_statusbarscale %d\n", ud.statusbarscale);
440
    OSD_Printf("cl_statusbarscale %d\n", ud.statusbarscale);
441
    return OSDCMD_OK;
441
    return OSDCMD_OK;
442
}
442
}
443
443
444
static int osdcmd_spawn(const osdfuncparm_t *parm)
444
static int osdcmd_spawn(const osdfuncparm_t *parm)
445
{
445
{
446
    int x=0,y=0,z=0;
446
    int x=0,y=0,z=0;
447
    unsigned short cstat=0,picnum=0;
447
    unsigned short cstat=0,picnum=0;
448
    unsigned char pal=0;
448
    unsigned char pal=0;
449
    short ang=0;
449
    short ang=0;
450
    short set=0, idx;
450
    short set=0, idx;
451
451
452
    if (numplayers > 1 || !(g_player[myconnectindex].ps->gm & MODE_GAME))
452
    if (numplayers > 1 || !(g_player[myconnectindex].ps->gm & MODE_GAME))
453
    {
453
    {
454
        OSD_Printf("spawn: Can't spawn sprites in multiplayer games or demos\n");
454
        OSD_Printf("spawn: Can't spawn sprites in multiplayer games or demos\n");
455
        return OSDCMD_OK;
455
        return OSDCMD_OK;
456
    }
456
    }
457
457
458
    switch (parm->numparms)
458
    switch (parm->numparms)
459
    {
459
    {
460
    case 7: // x,y,z
460
    case 7: // x,y,z
461
        x = Batol(parm->parms[4]);
461
        x = Batol(parm->parms[4]);
462
        y = Batol(parm->parms[5]);
462
        y = Batol(parm->parms[5]);
463
        z = Batol(parm->parms[6]);
463
        z = Batol(parm->parms[6]);
464
        set |= 8;
464
        set |= 8;
465
    case 4: // ang
465
    case 4: // ang
466
        ang = Batol(parm->parms[3]) & 2047;
466
        ang = Batol(parm->parms[3]) & 2047;
467
        set |= 4;
467
        set |= 4;
468
    case 3: // cstat
468
    case 3: // cstat
469
        cstat = (unsigned short)Batol(parm->parms[2]);
469
        cstat = (unsigned short)Batol(parm->parms[2]);
470
        set |= 2;
470
        set |= 2;
471
    case 2: // pal
471
    case 2: // pal
472
        pal = (unsigned char)Batol(parm->parms[1]);
472
        pal = (unsigned char)Batol(parm->parms[1]);
473
        set |= 1;
473
        set |= 1;
474
    case 1: // tile number
474
    case 1: // tile number
475
        if (isdigit(parm->parms[0][0]))
475
        if (isdigit(parm->parms[0][0]))
476
        {
476
        {
477
            picnum = (unsigned short)Batol(parm->parms[0]);
477
            picnum = (unsigned short)Batol(parm->parms[0]);
478
        }
478
        }
479
        else
479
        else
480
        {
480
        {
481
            int i,j;
481
            int i,j;
482
            for (j=0; j<2; j++)
482
            for (j=0; j<2; j++)
483
            {
483
            {
484
                for (i=0; i<labelcnt; i++)
484
                for (i=0; i<labelcnt; i++)
485
                {
485
                {
486
                    if (
486
                    if (
487
                        (j == 0 && !Bstrcmp(label+(i<<6),     parm->parms[0])) ||
487
                        (j == 0 && !Bstrcmp(label+(i<<6),     parm->parms[0])) ||
488
                        (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
488
                        (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
489
                    )
489
                    )
490
                    {
490
                    {
491
                        picnum = (unsigned short)labelcode[i];
491
                        picnum = (unsigned short)labelcode[i];
492
                        break;
492
                        break;
493
                    }
493
                    }
494
                }
494
                }
495
                if (i<labelcnt) break;
495
                if (i<labelcnt) break;
496
            }
496
            }
497
            if (i==labelcnt)
497
            if (i==labelcnt)
498
            {
498
            {
499
                OSD_Printf("spawn: Invalid tile label given\n");
499
                OSD_Printf("spawn: Invalid tile label given\n");
500
                return OSDCMD_OK;
500
                return OSDCMD_OK;
501
            }
501
            }
502
        }
502
        }
503
503
504
        if (picnum >= MAXTILES)
504
        if (picnum >= MAXTILES)
505
        {
505
        {
506
            OSD_Printf("spawn: Invalid tile number\n");
506
            OSD_Printf("spawn: Invalid tile number\n");
507
            return OSDCMD_OK;
507
            return OSDCMD_OK;
508
        }
508
        }
509
        break;
509
        break;
510
    default:
510
    default:
511
        return OSDCMD_SHOWHELP;
511
        return OSDCMD_SHOWHELP;
512
    }
512
    }
513
513
514
    idx = spawn(g_player[myconnectindex].ps->i, (short)picnum);
514
    idx = spawn(g_player[myconnectindex].ps->i, (short)picnum);
515
    if (set & 1) sprite[idx].pal = (char)pal;
515
    if (set & 1) sprite[idx].pal = (char)pal;
516
    if (set & 2) sprite[idx].cstat = (short)cstat;
516
    if (set & 2) sprite[idx].cstat = (short)cstat;
517
    if (set & 4) sprite[idx].ang = ang;
517
    if (set & 4) sprite[idx].ang = ang;
518
    if (set & 8)
518
    if (set & 8)
519
    {
519
    {
520
        if (setsprite(idx, x,y,z) < 0)
520
        if (setsprite(idx, x,y,z) < 0)
521
        {
521
        {
522
            OSD_Printf("spawn: Sprite can't be spawned into null space\n");
522
            OSD_Printf("spawn: Sprite can't be spawned into null space\n");
523
            deletesprite(idx);
523
            deletesprite(idx);
524
        }
524
        }
525
    }
525
    }
526
526
527
    return OSDCMD_OK;
527
    return OSDCMD_OK;
528
}
528
}
529
529
530
static int osdcmd_setvar(const osdfuncparm_t *parm)
530
static int osdcmd_setvar(const osdfuncparm_t *parm)
531
{
531
{
532
    int i, varval;
532
    int i, varval;
533
    char varname[256];
533
    char varname[256];
534
534
535
    if (parm->numparms != 2) return OSDCMD_SHOWHELP;
535
    if (parm->numparms != 2) return OSDCMD_SHOWHELP;
536
536
537
    if (numplayers > 1)
537
    if (numplayers > 1)
538
    {
538
    {
539
        OSD_Printf("Command not allowed in multiplayer\n");
539
        OSD_Printf("Command not allowed in multiplayer\n");
540
        return OSDCMD_OK;
540
        return OSDCMD_OK;
541
    }
541
    }
542
542
543
    strcpy(varname,parm->parms[1]);
543
    strcpy(varname,parm->parms[1]);
544
    varval = Batol(varname);
544
    varval = Batol(varname);
545
    for (i=0;i<iGameVarCount;i++)
545
    for (i=0;i<iGameVarCount;i++)
546
        if (aGameVars[i].szLabel != NULL)
546
        if (aGameVars[i].szLabel != NULL)
547
            if (Bstrcmp(varname, aGameVars[i].szLabel) == 0)
547
            if (Bstrcmp(varname, aGameVars[i].szLabel) == 0)
548
                varval=GetGameVarID(i, g_player[myconnectindex].ps->i, myconnectindex);
548
                varval=GetGameVarID(i, g_player[myconnectindex].ps->i, myconnectindex);
549
549
550
    strcpy(varname,parm->parms[0]);
550
    strcpy(varname,parm->parms[0]);
551
    for (i=0;i<iGameVarCount;i++)
551
    for (i=0;i<iGameVarCount;i++)
552
        if (aGameVars[i].szLabel != NULL)
552
        if (aGameVars[i].szLabel != NULL)
553
            if (Bstrcmp(varname, aGameVars[i].szLabel) == 0)
553
            if (Bstrcmp(varname, aGameVars[i].szLabel) == 0)
554
                SetGameVarID(i, varval, g_player[myconnectindex].ps->i, myconnectindex);
554
                SetGameVarID(i, varval, g_player[myconnectindex].ps->i, myconnectindex);
555
    return OSDCMD_OK;
555
    return OSDCMD_OK;
556
}
556
}
557
557
558
static int osdcmd_setactorvar(const osdfuncparm_t *parm)
558
static int osdcmd_setactorvar(const osdfuncparm_t *parm)
559
{
559
{
560
    int i, varval, ID;
560
    int i, varval, ID;
561
    char varname[256];
561
    char varname[256];
562
562
563
    if (parm->numparms != 3) return OSDCMD_SHOWHELP;
563
    if (parm->numparms != 3) return OSDCMD_SHOWHELP;
564
564
565
    if (numplayers > 1)
565
    if (numplayers > 1)
566
    {
566
    {
567
        OSD_Printf("Command not allowed in multiplayer\n");
567
        OSD_Printf("Command not allowed in multiplayer\n");
568
        return OSDCMD_OK;
568
        return OSDCMD_OK;
569
    }
569
    }
570
570
571
    ID=Batol(parm->parms[0]);
571
    ID=Batol(parm->parms[0]);
572
    if (ID>=MAXSPRITES)
572
    if (ID>=MAXSPRITES)
573
    {
573
    {
574
        OSD_Printf("Invalid sprite ID\n");
574
        OSD_Printf("Invalid sprite ID\n");
575
        return OSDCMD_OK;
575
        return OSDCMD_OK;
576
    }
576
    }
577
577
578
    varval = Batol(parm->parms[2]);
578
    varval = Batol(parm->parms[2]);
579
    strcpy(varname,parm->parms[2]);
579
    strcpy(varname,parm->parms[2]);
580
    varval = Batol(varname);
580
    varval = Batol(varname);
581
    for (i=0;i<iGameVarCount;i++)
581
    for (i=0;i<iGameVarCount;i++)
582
        if (aGameVars[i].szLabel != NULL)
582
        if (aGameVars[i].szLabel != NULL)
583
            if (Bstrcmp(varname, aGameVars[i].szLabel) == 0)
583
            if (Bstrcmp(varname, aGameVars[i].szLabel) == 0)
584
                varval=GetGameVarID(i, g_player[myconnectindex].ps->i, myconnectindex);
584
                varval=GetGameVarID(i, g_player[myconnectindex].ps->i, myconnectindex);
585
585
586
    strcpy(varname,parm->parms[1]);
586
    strcpy(varname,parm->parms[1]);
587
    for (i=0;i<iGameVarCount;i++)
587
    for (i=0;i<iGameVarCount;i++)
588
        if (aGameVars[i].szLabel != NULL)
588
        if (aGameVars[i].szLabel != NULL)
589
            if (Bstrcmp(varname, aGameVars[i].szLabel) == 0)
589
            if (Bstrcmp(varname, aGameVars[i].szLabel) == 0)
590
                SetGameVarID(i, varval, ID, -1);
590
                SetGameVarID(i, varval, ID, -1);
591
    return OSDCMD_OK;
591
    return OSDCMD_OK;
592
}
592
}
593
593
594
static int osdcmd_addpath(const osdfuncparm_t *parm)
594
static int osdcmd_addpath(const osdfuncparm_t *parm)
595
{
595
{
596
    char pathname[BMAX_PATH];
596
    char pathname[BMAX_PATH];
597
597
598
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
598
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
599
599
600
    strcpy(pathname,parm->parms[0]);
600
    strcpy(pathname,parm->parms[0]);
601
    addsearchpath(pathname);
601
    addsearchpath(pathname);
602
    return OSDCMD_OK;
602
    return OSDCMD_OK;
603
}
603
}
604
604
605
static int osdcmd_initgroupfile(const osdfuncparm_t *parm)
605
static int osdcmd_initgroupfile(const osdfuncparm_t *parm)
606
{
606
{
607
    char file[BMAX_PATH];
607
    char file[BMAX_PATH];
608
608
609
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
609
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
610
610
611
    strcpy(file,parm->parms[0]);
611
    strcpy(file,parm->parms[0]);
612
    initgroupfile(file);
612
    initgroupfile(file);
613
    return OSDCMD_OK;
613
    return OSDCMD_OK;
614
}
614
}
615
615
616
static int osdcmd_cmenu(const osdfuncparm_t *parm)
616
static int osdcmd_cmenu(const osdfuncparm_t *parm)
617
{
617
{
618
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
618
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
619
    if (numplayers > 1)
619
    if (numplayers > 1)
620
    {
620
    {
621
        OSD_Printf("cmenu: disallowed in multiplayer\n");
621
        OSD_Printf("cmenu: disallowed in multiplayer\n");
622
        return OSDCMD_OK;
622
        return OSDCMD_OK;
623
    }
623
    }
624
    else
624
    else
625
    {
625
    {
626
        cmenu(Batol(parm->parms[0]));
626
        cmenu(Batol(parm->parms[0]));
627
    }
627
    }
628
628
629
    return OSDCMD_OK;
629
    return OSDCMD_OK;
630
}
630
}
631
631
632
cvarmappings cvar[] =
632
cvarmappings cvar[] =
633
{
633
{
634
    { "crosshair", "crosshair: enable/disable crosshair", (void*)&ud.crosshair, CVAR_INT, 0, 0, 3 },
634
    { "crosshair", "crosshair: enable/disable crosshair", (void*)&ud.crosshair, CVAR_BOOL, 0, 0, 1 },
635
635
636
    { "cl_autoaim", "cl_autoaim: enable/disable weapon autoaim", (void*)&ud.config.AutoAim, CVAR_INT|CVAR_MULTI, 0, 0, 2 },
636
    { "cl_autoaim", "cl_autoaim: enable/disable weapon autoaim", (void*)&ud.config.AutoAim, CVAR_INT|CVAR_MULTI, 0, 0, 2 },
637
    { "cl_automsg", "cl_automsg: enable/disable automatically sending messages to all players", (void*)&ud.automsg, CVAR_BOOL, 0, 0, 1 },
637
    { "cl_automsg", "cl_automsg: enable/disable automatically sending messages to all players", (void*)&ud.automsg, CVAR_BOOL, 0, 0, 1 },
638
    { "cl_autovote", "cl_autovote: enable/disable automatic voting", (void*)&ud.autovote, CVAR_INT|CVAR_MULTI, 0, 0, 2 },
638
    { "cl_autovote", "cl_autovote: enable/disable automatic voting", (void*)&ud.autovote, CVAR_INT|CVAR_MULTI, 0, 0, 2 },
639
639
640
640
641
    { "cl_deathmessages", "cl_deathmessages: enable/disable multiplayer death messages", (void*)&ud.deathmsgs, CVAR_BOOL, 0, 0, 1 },
641
    { "cl_deathmessages", "cl_deathmessages: enable/disable multiplayer death messages", (void*)&ud.deathmsgs, CVAR_BOOL, 0, 0, 1 },
642
    { "cl_democams", "cl_democams: enable/disable demo playback cameras", (void*)&ud.democams, CVAR_BOOL, 0, 0, 1 },
642
    { "cl_democams", "cl_democams: enable/disable demo playback cameras", (void*)&ud.democams, CVAR_BOOL, 0, 0, 1 },
643
643
644
    { "cl_idplayers", "cl_idplayers: enable/disable name display when aiming at opponents", (void*)&ud.idplayers, CVAR_BOOL, 0, 0, 1 },
644
    { "cl_idplayers", "cl_idplayers: enable/disable name display when aiming at opponents", (void*)&ud.idplayers, CVAR_BOOL, 0, 0, 1 },
645
645
646
    { "cl_messagetime", "cl_messagetime: length of time to display multiplayer chat messages\n", (void*)&ud.msgdisptime, CVAR_INT, 0, 0, 3600 },
646
    { "cl_messagetime", "cl_messagetime: length of time to display multiplayer chat messages\n", (void*)&ud.msgdisptime, CVAR_INT, 0, 0, 3600 },
647
647
648
    { "cl_showcoords", "cl_showcoords: show your position in the game world", (void*)&ud.coords, CVAR_BOOL, 0, 0, 1 },
648
    { "cl_showcoords", "cl_showcoords: show your position in the game world", (void*)&ud.coords, CVAR_BOOL, 0, 0, 1 },
649
649
650
    { "cl_viewbob", "cl_viewbob: enable/disable player head bobbing\n", (void*)&ud.viewbob, CVAR_BOOL, 0, 0, 1 },
650
    { "cl_viewbob", "cl_viewbob: enable/disable player head bobbing\n", (void*)&ud.viewbob, CVAR_BOOL, 0, 0, 1 },
651
651
652
    { "cl_weaponsway", "cl_weaponsway: enable/disable player weapon swaying\n", (void*)&ud.weaponsway, CVAR_BOOL, 0, 0, 1 },
652
    { "cl_weaponsway", "cl_weaponsway: enable/disable player weapon swaying\n", (void*)&ud.weaponsway, CVAR_BOOL, 0, 0, 1 },
653
    { "cl_weaponswitch", "cl_weaponswitch: enable/disable auto weapon switching", (void*)&ud.weaponswitch, CVAR_INT|CVAR_MULTI, 0, 0, 3 },
653
    { "cl_weaponswitch", "cl_weaponswitch: enable/disable auto weapon switching", (void*)&ud.weaponswitch, CVAR_INT|CVAR_MULTI, 0, 0, 3 },
654
    { "cl_angleinterpolation", "cl_angleinterpolation: enable/disable angle interpolation", (void*)&ud.angleinterpolation, CVAR_INT, 0, 0, 256 },
654
    { "cl_angleinterpolation", "cl_angleinterpolation: enable/disable angle interpolation", (void*)&ud.angleinterpolation, CVAR_INT, 0, 0, 256 },
655
655
656
    { "in_mousebias", "in_mousebias: emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time\n", (void*)&ud.config.MouseBias, CVAR_INT, 0, 0, 32 },
656
    { "in_mousebias", "in_mousebias: emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time\n", (void*)&ud.config.MouseBias, CVAR_INT, 0, 0, 32 },
657
    { "in_mousefilter", "in_mousefilter: amount of mouse movement to filter out\n", (void*)&ud.config.MouseFilter, CVAR_INT, 0, 0, 512 },
657
    { "in_mousefilter", "in_mousefilter: amount of mouse movement to filter out\n", (void*)&ud.config.MouseFilter, CVAR_INT, 0, 0, 512 },
658
    { "in_smoothinput", "in_smoothinput: enable/disable input smoothing\n", (void*)&ud.config.SmoothInput, CVAR_BOOL, 0, 0, 1 },
658
    { "in_smoothinput", "in_smoothinput: enable/disable input smoothing\n", (void*)&ud.config.SmoothInput, CVAR_BOOL, 0, 0, 1 },
659
659
660
#if defined(POLYMOST) && defined(USE_OPENGL)
660
#if defined(POLYMOST) && defined(USE_OPENGL)
661
    { "r_anamorphic", "r_anamorphic: enable/disable widescreen mode", (void*)&glwidescreen, CVAR_BOOL, 0, 0, 1 },
661
    { "r_anamorphic", "r_anamorphic: enable/disable widescreen mode", (void*)&glwidescreen, CVAR_BOOL, 0, 0, 1 },
662
    { "r_projectionhack", "r_projectionhack: enable/disable projection hack", (void*)&glprojectionhacks, CVAR_BOOL, 0, 0, 1 },
662
    { "r_projectionhack", "r_projectionhack: enable/disable projection hack", (void*)&glprojectionhacks, CVAR_BOOL, 0, 0, 1 },
663
# ifdef POLYMER
663
# ifdef POLYMER
664
    // polymer cvars
664
    // polymer cvars
665
    { "pr_occlusionculling", "pr_occlusionculling: insert description that noone will ever read", (void*)&pr_occlusionculling, CVAR_INT, 0, 0, 512 },
665
    { "pr_occlusionculling", "pr_occlusionculling: insert description that noone will ever read", (void*)&pr_occlusionculling, CVAR_INT, 0, 0, 512 },
666
    { "pr_fov", "pr_fov: sets the field of vision in build angle", (void*)&pr_fov, CVAR_INT, 0, 0, 1023},
666
    { "pr_fov", "pr_fov: sets the field of vision in build angle", (void*)&pr_fov, CVAR_INT, 0, 0, 1023},
667
    { "pr_billboardingmode", "pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode", (void*)&pr_billboardingmode, CVAR_INT, 0, 0, 1 },
667
    { "pr_billboardingmode", "pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode", (void*)&pr_billboardingmode, CVAR_INT, 0, 0, 1 },
668
    { "pr_verbosity", "pr_verbosity: verbosity level of the polymer renderer", (void*)&pr_verbosity, CVAR_INT, 0, 0, 3 },
668
    { "pr_verbosity", "pr_verbosity: verbosity level of the polymer renderer", (void*)&pr_verbosity, CVAR_INT, 0, 0, 3 },
669
    { "pr_wireframe", "pr_wireframe: toggles wireframe mode", (void*)&pr_wireframe, CVAR_INT, 0, 0, 1 },
669
    { "pr_wireframe", "pr_wireframe: toggles wireframe mode", (void*)&pr_wireframe, CVAR_INT, 0, 0, 1 },
670
    { "pr_vbos", "pr_vbos: contols Vertex Buffer Object usage. 0: no VBOs. 1: VBOs for map data. 2: VBOs for model data.", (void*)&pr_vbos, CVAR_INT, 0, 0, 2 },
670
    { "pr_vbos", "pr_vbos: contols Vertex Buffer Object usage. 0: no VBOs. 1: VBOs for map data. 2: VBOs for model data.", (void*)&pr_vbos, CVAR_INT, 0, 0, 2 },
671
    { "pr_gpusmoothing", "pr_gpusmoothing: toggles model animation interpolation", (void*)&pr_gpusmoothing, CVAR_INT, 0, 0, 1 },
671
    { "pr_gpusmoothing", "pr_gpusmoothing: toggles model animation interpolation", (void*)&pr_gpusmoothing, CVAR_INT, 0, 0, 1 },
672
#endif
672
#endif
673
#endif
673
#endif
674
    { "r_drawweapon", "r_drawweapon: enable/disable weapon drawing", (void*)&ud.drawweapon, CVAR_INT, 0, 0, 2 },
674
    { "r_drawweapon", "r_drawweapon: enable/disable weapon drawing", (void*)&ud.drawweapon, CVAR_INT, 0, 0, 2 },
675
    { "r_showfps", "r_showfps: show the frame rate counter", (void*)&ud.tickrate, CVAR_BOOL, 0, 0, 1 },
675
    { "r_showfps", "r_showfps: show the frame rate counter", (void*)&ud.tickrate, CVAR_BOOL, 0, 0, 1 },
676
    { "r_precache", "r_precache: enable/disable the pre-level caching routine", (void*)&ud.config.useprecache, CVAR_BOOL, 0, 0, 1 },
676
    { "r_precache", "r_precache: enable/disable the pre-level caching routine", (void*)&ud.config.useprecache, CVAR_BOOL, 0, 0, 1 },
677
    { "r_visibility", "r_visibility: sets the global map visibility", (void*)&ud.const_visibility, CVAR_INT|128, 0, INT_MIN, INT_MAX },
677
    { "r_visibility", "r_visibility: sets the global map visibility", (void*)&ud.const_visibility, CVAR_INT|128, 0, INT_MIN, INT_MAX },
678
678
679
    { "snd_ambience", "snd_ambience: enables/disables ambient sounds", (void*)&ud.config.AmbienceToggle, CVAR_BOOL, 0, 0, 1 },
679
    { "snd_ambience", "snd_ambience: enables/disables ambient sounds", (void*)&ud.config.AmbienceToggle, CVAR_BOOL, 0, 0, 1 },
680
    { "snd_duketalk", "snd_duketalk: enables/disables Duke's speech", (void*)&ud.config.VoiceToggle, CVAR_INT, 0, 0, 2 },
680
    { "snd_duketalk", "snd_duketalk: enables/disables Duke's speech", (void*)&ud.config.VoiceToggle, CVAR_INT, 0, 0, 2 },
681
    { "snd_fxvolume", "snd_fxvolume: volume of sound effects", (void*)&ud.config.FXVolume, CVAR_INT, 0, 0, 255 },
681
    { "snd_fxvolume", "snd_fxvolume: volume of sound effects", (void*)&ud.config.FXVolume, CVAR_INT, 0, 0, 255 },
682
    { "snd_mixrate", "snd_mixrate: sound mixing rate", (void*)&ud.config.MixRate, CVAR_INT, 0, 0, 48000 },
682
    { "snd_mixrate", "snd_mixrate: sound mixing rate", (void*)&ud.config.MixRate, CVAR_INT, 0, 0, 48000 },
683
    { "snd_musvolume", "snd_musvolume: volume of midi music", (void*)&ud.config.MusicVolume, CVAR_INT, 0, 0, 255 },
683
    { "snd_musvolume", "snd_musvolume: volume of midi music", (void*)&ud.config.MusicVolume, CVAR_INT, 0, 0, 255 },
684
    { "snd_numbits", "snd_numbits: sound bits", (void*)&ud.config.NumBits, CVAR_INT, 0, 8, 16 },
684
    { "snd_numbits", "snd_numbits: sound bits", (void*)&ud.config.NumBits, CVAR_INT, 0, 8, 16 },
685
    { "snd_numchannels", "snd_numchannels: the number of sound channels", (void*)&ud.config.NumChannels, CVAR_INT, 0, 0, 2 },
685
    { "snd_numchannels", "snd_numchannels: the number of sound channels", (void*)&ud.config.NumChannels, CVAR_INT, 0, 0, 2 },
686
    { "snd_numvoices", "snd_numvoices: the number of concurrent sounds", (void*)&ud.config.NumVoices, CVAR_INT, 0, 0, 32 },
686
    { "snd_numvoices", "snd_numvoices: the number of concurrent sounds", (void*)&ud.config.NumVoices, CVAR_INT, 0, 0, 32 },
687
    { "snd_reversestereo", "snd_reversestereo: reverses the stereo channels", (void*)&ud.config.ReverseStereo, CVAR_BOOL, 0, 0, 16 },
687
    { "snd_reversestereo", "snd_reversestereo: reverses the stereo channels", (void*)&ud.config.ReverseStereo, CVAR_BOOL, 0, 0, 16 },
688
};
688
};
689
689
690
static int osdcmd_cvar_set(const osdfuncparm_t *parm)
690
static int osdcmd_cvar_set(const osdfuncparm_t *parm)
691
{
691
{
692
    int showval = (parm->numparms == 0);
692
    int showval = (parm->numparms == 0);
693
    unsigned int i;
693
    unsigned int i;
694
694
695
    for (i = 0; i < sizeof(cvar)/sizeof(cvarmappings); i++)
695
    for (i = 0; i < sizeof(cvar)/sizeof(cvarmappings); i++)
696
    {
696
    {
697
        if (!Bstrcasecmp(parm->name, cvar[i].name))
697
        if (!Bstrcasecmp(parm->name, cvar[i].name))
698
        {
698
        {
699
            if ((cvar[i].type & CVAR_NOMULTI) && numplayers > 1)
699
            if ((cvar[i].type & CVAR_NOMULTI) && numplayers > 1)
700
            {
700
            {
701
                // sound the alarm
701
                // sound the alarm
702
                OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvar[i].name);
702
                OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvar[i].name);
703
                return OSDCMD_OK;
703
                return OSDCMD_OK;
704
            }
704
            }
705
            else
705
            else
706
                switch (cvar[i].type&0x7f)
706
                switch (cvar[i].type&0x7f)
707
                {
707
                {
708
                case CVAR_INT:
708
                case CVAR_INT:
709
                case CVAR_UNSIGNEDINT:
709
                case CVAR_UNSIGNEDINT:
710
                case CVAR_BOOL:
710
                case CVAR_BOOL:
711
                {
711
                {
712
                    int val;
712
                    int val;
713
                    if (showval)
713
                    if (showval)
714
                    {
714
                    {
715
                        OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr);
715
                        OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr);
716
                        return OSDCMD_OK;
716
                        return OSDCMD_OK;
717
                    }
717
                    }
718
718
719
                    val = atoi(parm->parms[0]);
719
                    val = atoi(parm->parms[0]);
720
                    if (cvar[i].type == CVAR_BOOL) val = val != 0;
720
                    if (cvar[i].type == CVAR_BOOL) val = val != 0;
721
721
722
                    if (val < cvar[i].min || val > cvar[i].max)
722
                    if (val < cvar[i].min || val > cvar[i].max)
723
                    {
723
                    {
724
                        OSD_Printf("%s value out of range\n",cvar[i].name);
724
                        OSD_Printf("%s value out of range\n",cvar[i].name);
725
                        return OSDCMD_OK;
725
                        return OSDCMD_OK;
726
                    }
726
                    }
727
                    *(int*)cvar[i].var = val;
727
                    *(int*)cvar[i].var = val;
728
                    OSD_Printf("%s %d",cvar[i].name,val);
728
                    OSD_Printf("%s %d",cvar[i].name,val);
729
                }
729
                }
730
                break;
730
                break;
731
                case CVAR_STRING:
731
                case CVAR_STRING:
732
                {
732
                {
733
                    if (showval)
733
                    if (showval)
734
                    {
734
                    {
735
                        OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr);
735
                        OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr);
736
                        return OSDCMD_OK;
736
                        return OSDCMD_OK;
737
                    }
737
                    }
738
                    else
738
                    else
739
                    {
739
                    {
740
                        Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1);
740
                        Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1);
741
                        ((char*)cvar[i].var)[cvar[i].extra-1] = 0;
741
                        ((char*)cvar[i].var)[cvar[i].extra-1] = 0;
742
                        OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var);
742
                        OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var);
743
                    }
743
                    }
744
                }
744
                }
745
                break;
745
                break;
746
                default:
746
                default:
747
                    break;
747
                    break;
748
                }
748
                }
749
            if (cvar[i].type&CVAR_MULTI)
749
            if (cvar[i].type&CVAR_MULTI)
750
                updateplayer();
750
                updateplayer();
751
        }
751
        }
752
    }
752
    }
753
    OSD_Printf("\n");
753
    OSD_Printf("\n");
754
    return OSDCMD_OK;
754
    return OSDCMD_OK;
755
}
755
}
756
756
757
static int osdcmd_sensitivity(const osdfuncparm_t *parm)
757
static int osdcmd_sensitivity(const osdfuncparm_t *parm)
758
{
758
{
759
    if (parm->numparms != 1)
759
    if (parm->numparms != 1)
760
    {
760
    {
761
        OSD_Printf("\"sensitivity\" is \"%d\"\n",CONTROL_GetMouseSensitivity());
761
        OSD_Printf("\"sensitivity\" is \"%d\"\n",CONTROL_GetMouseSensitivity());
762
        return OSDCMD_SHOWHELP;
762
        return OSDCMD_SHOWHELP;
763
    }
763
    }
764
    CONTROL_SetMouseSensitivity(atoi(parm->parms[0]));
764
    CONTROL_SetMouseSensitivity(atoi(parm->parms[0]));
765
    OSD_Printf("sensitivity %d\n",CONTROL_GetMouseSensitivity());
765
    OSD_Printf("sensitivity %d\n",CONTROL_GetMouseSensitivity());
766
    return OSDCMD_OK;
766
    return OSDCMD_OK;
767
}
767
}
768
768
769
static int osdcmd_setbrightness(const osdfuncparm_t *parm)
769
static int osdcmd_setbrightness(const osdfuncparm_t *parm)
770
{
770
{
771
    if (parm->numparms != 1)
771
    if (parm->numparms != 1)
772
    {
772
    {
773
//        OSD_Printf("\"setbri\" \"%d\"\n",ud.brightness>>2);
773
//        OSD_Printf("\"setbri\" \"%d\"\n",ud.brightness>>2);
774
        return OSDCMD_SHOWHELP;
774
        return OSDCMD_SHOWHELP;
775
    }
775
    }
776
    ud.brightness = atoi(parm->parms[0])<<2;
776
    ud.brightness = atoi(parm->parms[0])<<2;
777
    setbrightness(ud.brightness>>2,&g_player[screenpeek].ps->palette[0],0);
777
    setbrightness(ud.brightness>>2,&g_player[screenpeek].ps->palette[0],0);
778
    OSD_Printf("setbrightness %d\n",ud.brightness>>2);
778
    OSD_Printf("setbrightness %d\n",ud.brightness>>2);
779
    return OSDCMD_OK;
779
    return OSDCMD_OK;
780
}
780
}
781
781
782
static int osdcmd_give(const osdfuncparm_t *parm)
782
static int osdcmd_give(const osdfuncparm_t *parm)
783
{
783
{
784
    int i;
784
    int i;
785
785
786
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
786
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
787
    {
787
    {
788
        if (g_player[myconnectindex].ps->dead_flag != 0)
788
        if (g_player[myconnectindex].ps->dead_flag != 0)
789
        {
789
        {
790
            OSD_Printf("give: Cannot give while dead.\n");
790
            OSD_Printf("give: Cannot give while dead.\n");
791
            return OSDCMD_OK;
791
            return OSDCMD_OK;
792
        }
792
        }
793
793
794
        if (parm->numparms != 1) return OSDCMD_SHOWHELP;
794
        if (parm->numparms != 1) return OSDCMD_SHOWHELP;
795
795
796
        if (!Bstrcasecmp(parm->parms[0], "all"))
796
        if (!Bstrcasecmp(parm->parms[0], "all"))
797
        {
797
        {
798
            osdcmd_cheatsinfo_stat.cheatnum = 1;
798
            osdcmd_cheatsinfo_stat.cheatnum = 1;
799
            return OSDCMD_OK;
799
            return OSDCMD_OK;
800
        }
800
        }
801
        else if (!Bstrcasecmp(parm->parms[0], "health"))
801
        else if (!Bstrcasecmp(parm->parms[0], "health"))
802
        {
802
        {
803
            sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health<<1;
803
            sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health<<1;
804
            return OSDCMD_OK;
804
            return OSDCMD_OK;
805
        }
805
        }
806
        else if (!Bstrcasecmp(parm->parms[0], "weapons"))
806
        else if (!Bstrcasecmp(parm->parms[0], "weapons"))
807
        {
807
        {
808
            osdcmd_cheatsinfo_stat.cheatnum = 21;
808
            osdcmd_cheatsinfo_stat.cheatnum = 21;
809
            return OSDCMD_OK;
809
            return OSDCMD_OK;
810
        }
810
        }
811
        else if (!Bstrcasecmp(parm->parms[0], "ammo"))
811
        else if (!Bstrcasecmp(parm->parms[0], "ammo"))
812
        {
812
        {
813
            for (i=PISTOL_WEAPON;i<MAX_WEAPONS-(VOLUMEONE?6:1);i++)
813
            for (i=PISTOL_WEAPON;i<MAX_WEAPONS-(VOLUMEONE?6:1);i++)
814
            {
814
            {
815
                addammo(i,g_player[myconnectindex].ps,g_player[myconnectindex].ps->max_ammo_amount[i]);
815
                addammo(i,g_player[myconnectindex].ps,g_player[myconnectindex].ps->max_ammo_amount[i]);
816
            }
816
            }
817
            return OSDCMD_OK;
817
            return OSDCMD_OK;
818
        }
818
        }
819
        else if (!Bstrcasecmp(parm->parms[0], "armor"))
819
        else if (!Bstrcasecmp(parm->parms[0], "armor"))
820
        {
820
        {
821
            g_player[myconnectindex].ps->shield_amount = 100;
821
            g_player[myconnectindex].ps->shield_amount = 100;
822
            return OSDCMD_OK;
822
            return OSDCMD_OK;
823
        }
823
        }
824
        else if (!Bstrcasecmp(parm->parms[0], "keys"))
824
        else if (!Bstrcasecmp(parm->parms[0], "keys"))
825
        {
825
        {
826
            osdcmd_cheatsinfo_stat.cheatnum = 23;
826
            osdcmd_cheatsinfo_stat.cheatnum = 23;
827
            return OSDCMD_OK;
827
            return OSDCMD_OK;
828
        }
828
        }
829
        else if (!Bstrcasecmp(parm->parms[0], "inventory"))
829
        else if (!Bstrcasecmp(parm->parms[0], "inventory"))
830
        {
830
        {
831
            osdcmd_cheatsinfo_stat.cheatnum = 22;
831
            osdcmd_cheatsinfo_stat.cheatnum = 22;
832
            return OSDCMD_OK;
832
            return OSDCMD_OK;
833
        }
833
        }
834
    }
834
    }
835
    else
835
    else
836
    {
836
    {
837
        OSD_Printf("give: Not in a single-player game.\n");
837
        OSD_Printf("give: Not in a single-player game.\n");
838
        return OSDCMD_OK;
838
        return OSDCMD_OK;
839
    }
839
    }
840
    return OSDCMD_SHOWHELP;
840
    return OSDCMD_SHOWHELP;
841
}
841
}
842
842
843
void onvideomodechange(int newmode)
843
void onvideomodechange(int newmode)
844
{
844
{
845
    char *pal;
845
    char *pal;
846
846
847
    if (newmode)
847
    if (newmode)
848
    {
848
    {
849
        if (g_player[screenpeek].ps->palette == palette ||
849
        if (g_player[screenpeek].ps->palette == palette ||
850
                g_player[screenpeek].ps->palette == waterpal ||
850
                g_player[screenpeek].ps->palette == waterpal ||
851
                g_player[screenpeek].ps->palette == titlepal ||
851
                g_player[screenpeek].ps->palette == titlepal ||
852
                g_player[screenpeek].ps->palette == animpal ||
852
                g_player[screenpeek].ps->palette == animpal ||
853
                g_player[screenpeek].ps->palette == endingpal ||
853
                g_player[screenpeek].ps->palette == endingpal ||
854
                g_player[screenpeek].ps->palette == drealms ||
854
                g_player[screenpeek].ps->palette == drealms ||
855
                g_player[screenpeek].ps->palette == slimepal)
855
                g_player[screenpeek].ps->palette == slimepal)
856
            pal = g_player[screenpeek].ps->palette;
856
            pal = g_player[screenpeek].ps->palette;
857
        else
857
        else
858
            pal = palette;
858
            pal = palette;
859
    }
859
    }
860
    else
860
    else
861
    {
861
    {
862
        pal = g_player[screenpeek].ps->palette;
862
        pal = g_player[screenpeek].ps->palette;
863
    }
863
    }
864
864
865
    setbrightness(ud.brightness>>2, pal, 0);
865
    setbrightness(ud.brightness>>2, pal, 0);
866
    restorepalette = 1;
866
    restorepalette = 1;
867
}
867
}
868
868
869
static int osdcmd_usemousejoy(const osdfuncparm_t *parm)
869
static int osdcmd_usemousejoy(const osdfuncparm_t *parm)
870
{
870
{
871
    int showval = (parm->numparms < 1);
871
    int showval = (parm->numparms < 1);
872
    if (!Bstrcasecmp(parm->name, "in_mouse"))
872
    if (!Bstrcasecmp(parm->name, "in_mouse"))
873
    {
873
    {
874
        if (showval)
874
        if (showval)
875
        {
875
        {
876
            OSD_Printf("in_mouse is %d\n", ud.config.UseMouse);
876
            OSD_Printf("in_mouse is %d\n", ud.config.UseMouse);
877
        }
877
        }
878
        else
878
        else
879
        {
879
        {
880
            ud.config.UseMouse = (atoi(parm->parms[0]) != 0);
880
            ud.config.UseMouse = (atoi(parm->parms[0]) != 0);
881
            CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent);
881
            CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent);
882
        }
882
        }
883
        return OSDCMD_OK;
883
        return OSDCMD_OK;
884
    }
884
    }
885
    else if (!Bstrcasecmp(parm->name, "in_joystick"))
885
    else if (!Bstrcasecmp(parm->name, "in_joystick"))
886
    {
886
    {
887
        if (showval)
887
        if (showval)
888
        {
888
        {
889
            OSD_Printf("in_joystick is %d\n", ud.config.UseJoystick);
889
            OSD_Printf("in_joystick is %d\n", ud.config.UseJoystick);
890
        }
890
        }
891
        else
891
        else
892
        {
892
        {
893
            ud.config.UseJoystick = (atoi(parm->parms[0]) != 0);
893
            ud.config.UseJoystick = (atoi(parm->parms[0]) != 0);
894
            CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent);
894
            CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent);
895
        }
895
        }
896
        return OSDCMD_OK;
896
        return OSDCMD_OK;
897
    }
897
    }
898
    return OSDCMD_SHOWHELP;
898
    return OSDCMD_SHOWHELP;
899
}
899
}
900
900
901
static int osdcmd_name(const osdfuncparm_t *parm)
901
static int osdcmd_name(const osdfuncparm_t *parm)
902
{
902
{
903
    if (parm->numparms != 1)
903
    if (parm->numparms != 1)
904
    {
904
    {
905
        OSD_Printf("\"name\" is \"%s\"\n",myname);
905
        OSD_Printf("\"name\" is \"%s\"\n",myname);
906
        return OSDCMD_SHOWHELP;
906
        return OSDCMD_SHOWHELP;
907
    }
907
    }
908
908
909
    Bstrcpy(tempbuf,parm->parms[0]);
909
    Bstrcpy(tempbuf,parm->parms[0]);
910
910
911
    while (Bstrlen(stripcolorcodes(tempbuf)) > 10)
911
    while (Bstrlen(stripcolorcodes(tempbuf)) > 10)
912
        tempbuf[Bstrlen(tempbuf)-1] = '\0';
912
        tempbuf[Bstrlen(tempbuf)-1] = '\0';
913
913
914
    Bstrncpy(myname,tempbuf,sizeof(myname)-1);
914
    Bstrncpy(myname,tempbuf,sizeof(myname)-1);
915
    myname[sizeof(myname)-1] = '\0';
915
    myname[sizeof(myname)-1] = '\0';
916
916
917
    OSD_Printf("name %s\n",myname);
917
    OSD_Printf("name %s\n",myname);
918
918
919
    updateplayer();
919
    updateplayer();
920
920
921
    return OSDCMD_OK;
921
    return OSDCMD_OK;
922
}
922
}
923
923
924
static int osdcmd_button(const osdfuncparm_t *parm)
924
static int osdcmd_button(const osdfuncparm_t *parm)
925
{
925
{
926
    char *p = (char *)parm->name+9;  // skip "gamefunc_"
926
    char *p = (char *)parm->name+9;  // skip "gamefunc_"
927
//    if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game
927
//    if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game
928
    extinput[CONFIG_FunctionNameToNum(p)] = 1; // FIXME
928
    extinput[CONFIG_FunctionNameToNum(p)] = 1; // FIXME
929
    return OSDCMD_OK;
929
    return OSDCMD_OK;
930
}
930
}
931
931
932
keydef keynames[]=
932
keydef keynames[]=
933
{
933
{
934
    { "Escape", 0x1 },
934
    { "Escape", 0x1 },
935
    { "1", 0x2 },
935
    { "1", 0x2 },
936
    { "2", 0x3 },
936
    { "2", 0x3 },
937
    { "3", 0x4 },
937
    { "3", 0x4 },
938
    { "4", 0x5 },
938
    { "4", 0x5 },
939
    { "5", 0x6 },
939
    { "5", 0x6 },
940
    { "6", 0x7 },
940
    { "6", 0x7 },
941
    { "7", 0x8 },
941
    { "7", 0x8 },
942
    { "8", 0x9 },
942
    { "8", 0x9 },
943
    { "9", 0xa },
943
    { "9", 0xa },
944
    { "0", 0xb },
944
    { "0", 0xb },
945
    { "-", 0xc },
945
    { "-", 0xc },
946
    { "=", 0xd },
946
    { "=", 0xd },
947
    { "BakSpc", 0xe },
947
    { "BakSpc", 0xe },
948
    { "Tab", 0xf },
948
    { "Tab", 0xf },
949
    { "Q", 0x10 },
949
    { "Q", 0x10 },
950
    { "W", 0x11 },
950
    { "W", 0x11 },
951
    { "E", 0x12 },
951
    { "E", 0x12 },
952
    { "R", 0x13 },
952
    { "R", 0x13 },
953
    { "T", 0x14 },
953
    { "T", 0x14 },
954
    { "Y", 0x15 },
954
    { "Y", 0x15 },
955
    { "U", 0x16 },
955
    { "U", 0x16 },
956
    { "I", 0x17 },
956
    { "I", 0x17 },
957
    { "O", 0x18 },
957
    { "O", 0x18 },
958
    { "P", 0x19 },
958
    { "P", 0x19 },
959
    { "[", 0x1a },
959
    { "[", 0x1a },
960
    { "]", 0x1b },
960
    { "]", 0x1b },
961
    { "Enter", 0x1c },
961
    { "Enter", 0x1c },
962
    { "LCtrl", 0x1d },
962
    { "LCtrl", 0x1d },
963
    { "A", 0x1e },
963
    { "A", 0x1e },
964
    { "S", 0x1f },
964
    { "S", 0x1f },
965
    { "D", 0x20 },
965
    { "D", 0x20 },
966
    { "F", 0x21 },
966
    { "F", 0x21 },
967
    { "G", 0x22 },
967
    { "G", 0x22 },
968
    { "H", 0x23 },
968
    { "H", 0x23 },
969
    { "J", 0x24 },
969
    { "J", 0x24 },
970
    { "K", 0x25 },
970
    { "K", 0x25 },
971
    { "L", 0x26 },
971
    { "L", 0x26 },
972
    { "SemiColon", 0x27 },
972
    { "SemiColon", 0x27 },
973
    { "'", 0x28 },
973
    { "'", 0x28 },
974
    { "Tilde", 0x29 },
974
    { "Tilde", 0x29 },
975
    { "LShift", 0x2a },
975
    { "LShift", 0x2a },
976
    { "\\", 0x2b },
976
    { "\\", 0x2b },
977
    { "Z", 0x2c },
977
    { "Z", 0x2c },
978
    { "X", 0x2d },
978
    { "X", 0x2d },
979
    { "C", 0x2e },
979
    { "C", 0x2e },
980
    { "V", 0x2f },
980
    { "V", 0x2f },
981
    { "B", 0x30 },
981
    { "B", 0x30 },
982
    { "N", 0x31 },
982
    { "N", 0x31 },
983
    { "M", 0x32 },
983
    { "M", 0x32 },
984
    { ",", 0x33 },
984
    { ",", 0x33 },
985
    { ".", 0x34 },
985
    { ".", 0x34 },
986
    { "/", 0x35 },
986
    { "/", 0x35 },
987
    { "RShift", 0x36 },
987
    { "RShift", 0x36 },
988
    { "Kpad*", 0x37 },
988
    { "Kpad*", 0x37 },
989
    { "LAlt", 0x38 },
989
    { "LAlt", 0x38 },
990
    { "Space", 0x39 },
990
    { "Space", 0x39 },
991
    { "CapLck", 0x3a },
991
    { "CapLck", 0x3a },
992
    { "F1", 0x3b },
992
    { "F1", 0x3b },
993
    { "F2", 0x3c },
993
    { "F2", 0x3c },
994
    { "F3", 0x3d },
994
    { "F3", 0x3d },
995
    { "F4", 0x3e },
995
    { "F4", 0x3e },
996
    { "F5", 0x3f },
996
    { "F5", 0x3f },
997
    { "F6", 0x40 },
997
    { "F6", 0x40 },
998
    { "F7", 0x41 },
998
    { "F7", 0x41 },
999
    { "F8", 0x42 },
999
    { "F8", 0x42 },
1000
    { "F9", 0x43 },
1000
    { "F9", 0x43 },
1001
    { "F10", 0x44 },
1001
    { "F10", 0x44 },
1002
    { "NumLck", 0x45 },
1002
    { "NumLck", 0x45 },
1003
    { "ScrLck", 0x46 },
1003
    { "ScrLck", 0x46 },
1004
    { "Kpad7", 0x47 },
1004
    { "Kpad7", 0x47 },
1005
    { "Kpad8", 0x48 },
1005
    { "Kpad8", 0x48 },
1006
    { "Kpad9", 0x49 },
1006
    { "Kpad9", 0x49 },
1007
    { "Kpad-", 0x4a },
1007
    { "Kpad-", 0x4a },
1008
    { "Kpad4", 0x4b },
1008
    { "Kpad4", 0x4b },
1009
    { "Kpad5", 0x4c },
1009
    { "Kpad5", 0x4c },
1010
    { "Kpad6", 0x4d },
1010
    { "Kpad6", 0x4d },
1011
    { "Kpad+", 0x4e },
1011
    { "Kpad+", 0x4e },
1012
    { "Kpad1", 0x4f },
1012
    { "Kpad1", 0x4f },
1013
    { "Kpad2", 0x50 },
1013
    { "Kpad2", 0x50 },
1014
    { "Kpad3", 0x51 },
1014
    { "Kpad3", 0x51 },
1015
    { "Kpad0", 0x52 },
1015
    { "Kpad0", 0x52 },
1016
    { "Kpad.", 0x53 },
1016
    { "Kpad.", 0x53 },
1017
    { "F11", 0x57 },
1017
    { "F11", 0x57 },
1018
    { "F12", 0x58 },
1018
    { "F12", 0x58 },
1019
    { "KpdEnt", 0x9c },
1019
    { "KpdEnt", 0x9c },
1020
    { "RCtrl", 0x9d },
1020
    { "RCtrl", 0x9d },
1021
    { "Kpad/", 0xb5 },
1021
    { "Kpad/", 0xb5 },
1022
    { "RAlt", 0xb8 },
1022
    { "RAlt", 0xb8 },
1023
    { "PrtScn", 0xb7 },
1023
    { "PrtScn", 0xb7 },
1024
    { "Pause", 0xc5 },
1024
    { "Pause", 0xc5 },
1025
    { "Home", 0xc7 },
1025
    { "Home", 0xc7 },
1026
    { "Up", 0xc8 },
1026
    { "Up", 0xc8 },
1027
    { "PgUp", 0xc9 },
1027
    { "PgUp", 0xc9 },
1028
    { "Left", 0xcb },
1028
    { "Left", 0xcb },
1029
    { "Right", 0xcd },
1029
    { "Right", 0xcd },
1030
    { "End", 0xcf },
1030
    { "End", 0xcf },
1031
    { "Down", 0xd0 },
1031
    { "Down", 0xd0 },
1032
    { "PgDn", 0xd1 },
1032
    { "PgDn", 0xd1 },
1033
    { "Insert", 0xd2 },
1033
    { "Insert", 0xd2 },
1034
    { "Delete", 0xd3 },
1034
    { "Delete", 0xd3 },
1035
1035
1036
    {0,0}
1036
    {0,0}
1037
};
1037
};
1038
1038
1039
char *mousenames[] = { "mouse1", "mouse2", "mouse3", "mouse4", "mouse5", "mouse6" };
1039
char *mousenames[] = { "mouse1", "mouse2", "mouse3", "mouse4", "mouse5", "mouse6" };
1040
1040
1041
static int osdcmd_bind(const osdfuncparm_t *parm)
1041
static int osdcmd_bind(const osdfuncparm_t *parm)
1042
{
1042
{
1043
    int i, j;
1043
    int i, j;
1044
1044
1045
    if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys"))
1045
    if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys"))
1046
    {
1046
    {
1047
        for (i=0;keynames[i].name;i++)OSD_Printf("%s\n",keynames[i].name);
1047
        for (i=0;keynames[i].name;i++)OSD_Printf("%s\n",keynames[i].name);
1048
        for (i=0;i<MAXMOUSEBUTTONS;i++)OSD_Printf("%s\n",mousenames[i]);
1048
        for (i=0;i<MAXMOUSEBUTTONS;i++)OSD_Printf("%s\n",mousenames[i]);
1049
        return OSDCMD_OK;
1049
        return OSDCMD_OK;
1050
    }
1050
    }
1051
1051
1052
    if (parm->numparms==0)
1052
    if (parm->numparms==0)
1053
    {
1053
    {
1054
        int j=0;
1054
        int j=0;
1055
1055
1056
        OSD_Printf("Current key bindings:\n");
1056
        OSD_Printf("Current key bindings:\n");
1057
        for (i=0;i<MAXBOUNDKEYS;i++)
1057
        for (i=0;i<MAXBOUNDKEYS;i++)
1058
            if (boundkeys[i].cmd[0] && boundkeys[i].key)
1058
            if (boundkeys[i].cmd[0] && boundkeys[i].key)
1059
            {
1059
            {
1060
                j++;
1060
                j++;
1061
                OSD_Printf("%-9s %s\"%s\"\n",boundkeys[i].key, boundkeys[i].repeat?"":"norepeat ", boundkeys[i].cmd);
1061
                OSD_Printf("%-9s %s\"%s\"\n",boundkeys[i].key, boundkeys[i].repeat?"":"norepeat ", boundkeys[i].cmd);
1062
            }
1062
            }
1063
1063
1064
        for (i=0;i<MAXMOUSEBUTTONS;i++)
1064
        for (i=0;i<MAXMOUSEBUTTONS;i++)
1065
            if (mousebind[i].cmd[0] && mousebind[i].key)
1065
            if (mousebind[i].cmd[0] && mousebind[i].key)
1066
            {
1066
            {
1067
                j++;
1067
                j++;
1068
                OSD_Printf("%-9s %s\"%s\"\n",mousebind[i].key, mousebind[i].repeat?"":"norepeat ",mousebind[i].cmd);
1068
                OSD_Printf("%-9s %s\"%s\"\n",mousebind[i].key, mousebind[i].repeat?"":"norepeat ",mousebind[i].cmd);
1069
            }
1069
            }
1070
1070
1071
        if (j == 0)
1071
        if (j == 0)
1072
            OSD_Printf("No binds found.\n");
1072
            OSD_Printf("No binds found.\n");
1073
1073
1074
        return OSDCMD_OK;
1074
        return OSDCMD_OK;
1075
    }
1075
    }
1076
1076
1077
    for (i=0;keynames[i].name;i++)
1077
    for (i=0;keynames[i].name;i++)
1078
        if (!Bstrcasecmp(parm->parms[0],keynames[i].name))
1078
        if (!Bstrcasecmp(parm->parms[0],keynames[i].name))
1079
            break;
1079
            break;
1080
1080
1081
    if (!keynames[i].name)
1081
    if (!keynames[i].name)
1082
    {
1082
    {
1083
        for (i=0;i<MAXMOUSEBUTTONS;i++)
1083
        for (i=0;i<MAXMOUSEBUTTONS;i++)
1084
            if (!Bstrcasecmp(parm->parms[0],mousenames[i]))
1084
            if (!Bstrcasecmp(parm->parms[0],mousenames[i]))
1085
                break;
1085
                break;
1086
        if (i >= MAXMOUSEBUTTONS)
1086
        if (i >= MAXMOUSEBUTTONS)
1087
            return OSDCMD_SHOWHELP;
1087
            return OSDCMD_SHOWHELP;
1088
1088
1089
        if (parm->numparms < 2)
1089
        if (parm->numparms < 2)
1090
        {
1090
        {
1091
            OSD_Printf("%-9s %s\"%s\"\n",mousenames[i], mousebind[i].repeat?"":"norepeat ",mousebind[i].cmd);
1091
            OSD_Printf("%-9s %s\"%s\"\n",mousenames[i], mousebind[i].repeat?"":"norepeat ",mousebind[i].cmd);
1092
            return OSDCMD_OK;
1092
            return OSDCMD_OK;
1093
        }
1093
        }
1094
1094
1095
        j = 1;
1095
        j = 1;
1096
1096
1097
        mousebind[i].repeat = 1;
1097
        mousebind[i].repeat = 1;
1098
        if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat"))
1098
        if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat"))
1099
        {
1099
        {
1100
            mousebind[i].repeat = 0;
1100
            mousebind[i].repeat = 0;
1101
            j++;
1101
            j++;
1102
        }
1102
        }
1103
1103
1104
        Bstrcpy(tempbuf,parm->parms[j++]);
1104
        Bstrcpy(tempbuf,parm->parms[j++]);
1105
        for (;j<parm->numparms;j++)
1105
        for (;j<parm->numparms;j++)
1106
        {
1106
        {
1107
            Bstrcat(tempbuf," ");
1107
            Bstrcat(tempbuf," ");
1108
            Bstrcat(tempbuf,parm->parms[j++]);
1108
            Bstrcat(tempbuf,parm->parms[j++]);
1109
        }
1109
        }
1110
        Bstrncpy(mousebind[i].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
1110
        Bstrncpy(mousebind[i].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
1111
1111
1112
        mousebind[i].key=mousenames[i];
1112
        mousebind[i].key=mousenames[i];
1113
        if (!OSD_ParsingScript())
1113
        if (!OSD_ParsingScript())
1114
            OSD_Printf("%s\n",parm->raw);
1114
            OSD_Printf("%s\n",parm->raw);
1115
        return OSDCMD_OK;
1115
        return OSDCMD_OK;
1116
    }
1116
    }
1117
1117
1118
    if (parm->numparms < 2)
1118
    if (parm->numparms < 2)
1119
    {
1119
    {
1120
        OSD_Printf("%-9s %s\"%s\"\n",keynames[i].name, boundkeys[keynames[i].id].repeat?"":"norepeat ", boundkeys[keynames[i].id].cmd);
1120
        OSD_Printf("%-9s %s\"%s\"\n",keynames[i].name, boundkeys[keynames[i].id].repeat?"":"norepeat ", boundkeys[keynames[i].id].cmd);
1121
        return OSDCMD_OK;
1121
        return OSDCMD_OK;
1122
    }
1122
    }
1123
1123
1124
    j = 1;
1124
    j = 1;
1125
1125
1126
    boundkeys[keynames[i].id].repeat = 1;
1126
    boundkeys[keynames[i].id].repeat = 1;
1127
    if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat"))
1127
    if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat"))
1128
    {
1128
    {
1129
        boundkeys[keynames[i].id].repeat = 0;
1129
        boundkeys[keynames[i].id].repeat = 0;
1130
        j++;
1130
        j++;
1131
    }
1131
    }
1132
1132
1133
    Bstrcpy(tempbuf,parm->parms[j++]);
1133
    Bstrcpy(tempbuf,parm->parms[j++]);
1134
    for (;j<parm->numparms;j++)
1134
    for (;j<parm->numparms;j++)
1135
    {
1135
    {
1136
        Bstrcat(tempbuf," ");
1136
        Bstrcat(tempbuf," ");
1137
        Bstrcat(tempbuf,parm->parms[j++]);
1137
        Bstrcat(tempbuf,parm->parms[j++]);
1138
    }
1138
    }
1139
    Bstrncpy(boundkeys[keynames[i].id].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
1139
    Bstrncpy(boundkeys[keynames[i].id].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
1140
1140
1141
    boundkeys[keynames[i].id].key=keynames[i].name;
1141
    boundkeys[keynames[i].id].key=keynames[i].name;
1142
    if (!OSD_ParsingScript())
1142
    if (!OSD_ParsingScript())
1143
        OSD_Printf("%s\n",parm->raw);
1143
        OSD_Printf("%s\n",parm->raw);
1144
    return OSDCMD_OK;
1144
    return OSDCMD_OK;
1145
}
1145
}
1146
1146
1147
static int osdcmd_unbindall(const osdfuncparm_t *parm)
1147
static int osdcmd_unbindall(const osdfuncparm_t *parm)
1148
{
1148
{
1149
    int i;
1149
    int i;
1150
1150
1151
    UNREFERENCED_PARAMETER(parm);
1151
    UNREFERENCED_PARAMETER(parm);
1152
1152
1153
    for (i=0;i<MAXBOUNDKEYS;i++)
1153
    for (i=0;i<MAXBOUNDKEYS;i++)
1154
        if (boundkeys[i].cmd[0])
1154
        if (boundkeys[i].cmd[0])
1155
            boundkeys[i].cmd[0] = 0;
1155
            boundkeys[i].cmd[0] = 0;
1156
    for (i=0;i<MAXMOUSEBUTTONS;i++)
1156
    for (i=0;i<MAXMOUSEBUTTONS;i++)
1157
        if (mousebind[i].cmd[0])
1157
        if (mousebind[i].cmd[0])
1158
            mousebind[i].cmd[0] = 0;
1158
            mousebind[i].cmd[0] = 0;
1159
    OSD_Printf("unbound all keys\n");
1159
    OSD_Printf("unbound all keys\n");
1160
    return OSDCMD_OK;
1160
    return OSDCMD_OK;
1161
}
1161
}
1162
1162
1163
static int osdcmd_unbind(const osdfuncparm_t *parm)
1163
static int osdcmd_unbind(const osdfuncparm_t *parm)
1164
{
1164
{
1165
    int i;
1165
    int i;
1166
1166
1167
    if (parm->numparms < 1) return OSDCMD_SHOWHELP;
1167
    if (parm->numparms < 1) return OSDCMD_SHOWHELP;
1168
    for (i=0;keynames[i].name;i++)
1168
    for (i=0;keynames[i].name;i++)
1169
        if (!Bstrcasecmp(parm->parms[0],keynames[i].name))
1169
        if (!Bstrcasecmp(parm->parms[0],keynames[i].name))
1170
            break;
1170
            break;
1171
    if (!keynames[i].name)
1171
    if (!keynames[i].name)
1172
    {
1172
    {
1173
        for (i=0;i<MAXMOUSEBUTTONS;i++)
1173
        for (i=0;i<MAXMOUSEBUTTONS;i++)
1174
            if (!Bstrcasecmp(parm->parms[0],mousenames[i]))
1174
            if (!Bstrcasecmp(parm->parms[0],mousenames[i]))
1175
                break;
1175
                break;
1176
        if (i >= MAXMOUSEBUTTONS)
1176
        if (i >= MAXMOUSEBUTTONS)
1177
            return OSDCMD_SHOWHELP;
1177
            return OSDCMD_SHOWHELP;
1178
        mousebind[i].repeat = 0;
1178
        mousebind[i].repeat = 0;
1179
        mousebind[i].cmd[0] = 0;
1179
        mousebind[i].cmd[0] = 0;
1180
        OSD_Printf("unbound %s\n",mousenames[i]);
1180
        OSD_Printf("unbound %s\n",mousenames[i]);
1181
        return OSDCMD_OK;
1181
        return OSDCMD_OK;
1182
    }
1182
    }
1183
    boundkeys[keynames[i].id].repeat = 0;
1183
    boundkeys[keynames[i].id].repeat = 0;
1184
    boundkeys[keynames[i].id].cmd[0] = 0;
1184
    boundkeys[keynames[i].id].cmd[0] = 0;
1185
    OSD_Printf("unbound key %s\n",keynames[i].name);
1185
    OSD_Printf("unbound key %s\n",keynames[i].name);
1186
    return OSDCMD_OK;
1186
    return OSDCMD_OK;
1187
}
1187
}
1188
1188
1189
static int osdcmd_quicksave(const osdfuncparm_t *parm)
1189
static int osdcmd_quicksave(const osdfuncparm_t *parm)
1190
{
1190
{
1191
    UNREFERENCED_PARAMETER(parm);
1191
    UNREFERENCED_PARAMETER(parm);
1192
    if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
1192
    if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
1193
        OSD_Printf("quicksave: not in a game.\n");
1193
        OSD_Printf("quicksave: not in a game.\n");
1194
    else doquicksave = 1;
1194
    else doquicksave = 1;
1195
    return OSDCMD_OK;
1195
    return OSDCMD_OK;
1196
}
1196
}
1197
1197
1198
static int osdcmd_quickload(const osdfuncparm_t *parm)
1198
static int osdcmd_quickload(const osdfuncparm_t *parm)
1199
{
1199
{
1200
    UNREFERENCED_PARAMETER(parm);
1200
    UNREFERENCED_PARAMETER(parm);
1201
    if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
1201
    if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
1202
        OSD_Printf("quickload: not in a game.\n");
1202
        OSD_Printf("quickload: not in a game.\n");
1203
    else doquicksave = 2;
1203
    else doquicksave = 2;
1204
    return OSDCMD_OK;
1204
    return OSDCMD_OK;
1205
}
1205
}
1206
1206
1207
static int osdcmd_screenshot(const osdfuncparm_t *parm)
1207
static int osdcmd_screenshot(const osdfuncparm_t *parm)
1208
{
1208
{
1209
    UNREFERENCED_PARAMETER(parm);
1209
    UNREFERENCED_PARAMETER(parm);
1210
//    KB_ClearKeysDown();
1210
//    KB_ClearKeysDown();
1211
    screencapture("duke0000.tga",0);
1211
    screencapture("duke0000.tga",0);
1212
    return OSDCMD_OK;
1212
    return OSDCMD_OK;
1213
}
1213
}
1214
1214
1215
extern void savemapstate(mapstate_t *save);
1215
extern void savemapstate(mapstate_t *save);
1216
extern void restoremapstate(mapstate_t *save);
1216
extern void restoremapstate(mapstate_t *save);
1217
1217
1218
static int osdcmd_savestate(const osdfuncparm_t *parm)
1218
static int osdcmd_savestate(const osdfuncparm_t *parm)
1219
{
1219
{
1220
    UNREFERENCED_PARAMETER(parm);
1220
    UNREFERENCED_PARAMETER(parm);
1221
    if (map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate == NULL)
1221
    if (map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate == NULL)
1222
        map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate = Bcalloc(1,sizeof(mapstate_t));
1222
        map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate = Bcalloc(1,sizeof(mapstate_t));
1223
    savemapstate(map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate);
1223
    savemapstate(map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate);
1224
    return OSDCMD_OK;
1224
    return OSDCMD_OK;
1225
}
1225
}
1226
1226
1227
static int osdcmd_restorestate(const osdfuncparm_t *parm)
1227
static int osdcmd_restorestate(const osdfuncparm_t *parm)
1228
{
1228
{
1229
    UNREFERENCED_PARAMETER(parm);
1229
    UNREFERENCED_PARAMETER(parm);
1230
    if (map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate)
1230
    if (map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate)
1231
        restoremapstate(map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate);
1231
        restoremapstate(map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate);
1232
    return OSDCMD_OK;
1232
    return OSDCMD_OK;
1233
}
1233
}
1234
1234
1235
static int osdcmd_vid_gamma(const osdfuncparm_t *parm)
1235
static int osdcmd_vid_gamma(const osdfuncparm_t *parm)
1236
{
1236
{
1237
    if (parm->numparms != 1)
1237
    if (parm->numparms != 1)
1238
    {
1238
    {
1239
        OSD_Printf("\"vid_gamma\" is \"%.1f\"\n",vid_gamma);
1239
        OSD_Printf("\"vid_gamma\" is \"%.1f\"\n",vid_gamma);
1240
        return OSDCMD_SHOWHELP;
1240
        return OSDCMD_SHOWHELP;
1241
    }
1241
    }
1242
    vid_gamma = atof(parm->parms[0]);
1242
    vid_gamma = atof(parm->parms[0]);
1243
    ud.brightness = min(max((float)((vid_gamma-1.0)*10.0),0),15);
1243
    ud.brightness = min(max((float)((vid_gamma-1.0)*10.0),0),15);
1244
    ud.brightness <<= 2;
1244
    ud.brightness <<= 2;
1245
    OSD_Printf("%s\n",parm->raw);
1245
    OSD_Printf("%s\n",parm->raw);
1246
    setgamma();
1246
    setgamma();
1247
    return OSDCMD_OK;
1247
    return OSDCMD_OK;
1248
}
1248
}
1249
1249
1250
static int osdcmd_vid_brightness(const osdfuncparm_t *parm)
1250
static int osdcmd_vid_brightness(const osdfuncparm_t *parm)
1251
{
1251
{
1252
    if (parm->numparms != 1)
1252
    if (parm->numparms != 1)
1253
    {
1253
    {
1254
        OSD_Printf("\"vid_brightness\" is \"%.1f\"\n",vid_brightness);
1254
        OSD_Printf("\"vid_brightness\" is \"%.1f\"\n",vid_brightness);
1255
        return OSDCMD_SHOWHELP;
1255
        return OSDCMD_SHOWHELP;
1256
    }
1256
    }
1257
    vid_brightness = atof(parm->parms[0]);
1257
    vid_brightness = atof(parm->parms[0]);
1258
    OSD_Printf("%s\n",parm->raw);
1258
    OSD_Printf("%s\n",parm->raw);
1259
    setgamma();
1259
    setgamma();
1260
    return OSDCMD_OK;
1260
    return OSDCMD_OK;
1261
}
1261
}
1262
1262
1263
static int osdcmd_vid_contrast(const osdfuncparm_t *parm)
1263
static int osdcmd_vid_contrast(const osdfuncparm_t *parm)
1264
{
1264
{
1265
    if (parm->numparms != 1)
1265
    if (parm->numparms != 1)
1266
    {
1266
    {
1267
        OSD_Printf("\"vid_contrast\" is \"%.1f\"\n",vid_contrast);
1267
        OSD_Printf("\"vid_contrast\" is \"%.1f\"\n",vid_contrast);
1268
        return OSDCMD_SHOWHELP;
1268
        return OSDCMD_SHOWHELP;
1269
    }
1269
    }
1270
    vid_contrast = atof(parm->parms[0]);
1270
    vid_contrast = atof(parm->parms[0]);
1271
    OSD_Printf("%s\n",parm->raw);
1271
    OSD_Printf("%s\n",parm->raw);
1272
    setgamma();
1272
    setgamma();
1273
    return OSDCMD_OK;
1273
    return OSDCMD_OK;
1274
}
1274
}
1275
1275
-
 
1276
static int osdcmd_setcrosshairscale(const osdfuncparm_t *parm)
-
 
1277
{
-
 
1278
    if (parm->numparms == 0)
-
 
1279
    {
-
 
1280
        OSD_Printf("\"cl_crosshairscale\" is \"%d\"\n", ud.crosshairscale);
-
 
1281
        return OSDCMD_SHOWHELP;
-
 
1282
    }
-
 
1283
    else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
-
 
1284
-
 
1285
    ud.crosshairscale = min(100,max(10,Batol(parm->parms[0])));
-
 
1286
    OSD_Printf("cl_statusbarscale %d\n", ud.crosshairscale);
-
 
1287
    return OSDCMD_OK;
-
 
1288
}
-
 
1289
1276
int registerosdcommands(void)
1290
int registerosdcommands(void)
1277
{
1291
{
1278
    unsigned int i;
1292
    unsigned int i;
1279
1293
1280
    osdcmd_cheatsinfo_stat.cheatnum = -1;
1294
    osdcmd_cheatsinfo_stat.cheatnum = -1;
1281
1295
1282
    for (i=0; i<sizeof(cvar)/sizeof(cvar[0]); i++)
1296
    for (i=0; i<sizeof(cvar)/sizeof(cvar[0]); i++)
1283
    {
1297
    {
1284
        OSD_RegisterFunction(cvar[i].name, cvar[i].helpstr, osdcmd_cvar_set);
1298
        OSD_RegisterFunction(cvar[i].name, cvar[i].helpstr, osdcmd_cvar_set);
1285
    }
1299
    }
1286
1300
1287
    if (VOLUMEONE)
1301
    if (VOLUMEONE)
1288
        OSD_RegisterFunction("changelevel","changelevel <level>: warps to the given level", osdcmd_changelevel);
1302
        OSD_RegisterFunction("changelevel","changelevel <level>: warps to the given level", osdcmd_changelevel);
1289
    else
1303
    else
1290
    {
1304
    {
1291
        OSD_RegisterFunction("changelevel","changelevel <volume> <level>: warps to the given level", osdcmd_changelevel);
1305
        OSD_RegisterFunction("changelevel","changelevel <volume> <level>: warps to the given level", osdcmd_changelevel);
1292
        OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map);
1306
        OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map);
1293
    }
1307
    }
1294
1308
1295
    OSD_RegisterFunction("addpath","addpath <path>: adds path to game filesystem", osdcmd_addpath);
1309
    OSD_RegisterFunction("addpath","addpath <path>: adds path to game filesystem", osdcmd_addpath);
1296
1310
1297
    OSD_RegisterFunction("bind","bind <key> <string>: associates a keypress with a string of console input. Type \"bind showkeys\" for a list of keys and \"listsymbols\" for a list of valid console commands.", osdcmd_bind);
1311
    OSD_RegisterFunction("bind","bind <key> <string>: associates a keypress with a string of console input. Type \"bind showkeys\" for a list of keys and \"listsymbols\" for a list of valid console commands.", osdcmd_bind);
1298
1312
1299
    OSD_RegisterFunction("cl_statusbarscale","cl_statusbarscale: changes the status bar scale", osdcmd_setstatusbarscale);
1313
    OSD_RegisterFunction("cl_statusbarscale","cl_statusbarscale: changes the status bar scale", osdcmd_setstatusbarscale);
-
 
1314
    OSD_RegisterFunction("cl_crosshairscale","cl_crosshairscale: changes the crosshair scale", osdcmd_setcrosshairscale);
1300
    OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
1315
    OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
1301
1316
1302
    OSD_RegisterFunction("echo","echo [text]: echoes text to the console", osdcmd_echo);
1317
    OSD_RegisterFunction("echo","echo [text]: echoes text to the console", osdcmd_echo);
1303
1318
1304
    OSD_RegisterFunction("fileinfo","fileinfo <file>: gets a file's information", osdcmd_fileinfo);
1319
    OSD_RegisterFunction("fileinfo","fileinfo <file>: gets a file's information", osdcmd_fileinfo);
1305
1320
1306
    for (i=0;i<NUMGAMEFUNCTIONS-1;i++)
1321
    for (i=0;i<NUMGAMEFUNCTIONS-1;i++)
1307
    {
1322
    {
1308
        char *t;
1323
        char *t;
1309
        Bsprintf(tempbuf,"gamefunc_%s",gamefunctions[i]);
1324
        Bsprintf(tempbuf,"gamefunc_%s",gamefunctions[i]);
1310
        t = Bstrdup(tempbuf);
1325
        t = Bstrdup(tempbuf);
1311
        Bstrcat(tempbuf,": game button");
1326
        Bstrcat(tempbuf,": game button");
1312
        OSD_RegisterFunction(t,Bstrdup(tempbuf),osdcmd_button);
1327
        OSD_RegisterFunction(t,Bstrdup(tempbuf),osdcmd_button);
1313
    }
1328
    }
1314
1329
1315
    OSD_RegisterFunction("setbrightness","setbrightness <value>: changes brightness (obsolete)", osdcmd_setbrightness);
1330
    OSD_RegisterFunction("setbrightness","setbrightness <value>: changes brightness (obsolete)", osdcmd_setbrightness);
1316
    OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
1331
    OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
1317
    OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
1332
    OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
1318
1333
1319
    OSD_RegisterFunction("in_joystick","in_joystick: enables input from the joystick if it is present",osdcmd_usemousejoy);
1334
    OSD_RegisterFunction("in_joystick","in_joystick: enables input from the joystick if it is present",osdcmd_usemousejoy);
1320
    OSD_RegisterFunction("in_mouse","in_mouse: enables input from the mouse if it is present",osdcmd_usemousejoy);
1335
    OSD_RegisterFunction("in_mouse","in_mouse: enables input from the mouse if it is present",osdcmd_usemousejoy);
1321
    OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile);
1336
    OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile);
1322
1337
1323
    OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name);
1338
    OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name);
1324
    OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
1339
    OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
1325
1340
1326
    OSD_RegisterFunction("quicksave","quicksave: performs a quick save", osdcmd_quicksave);
1341
    OSD_RegisterFunction("quicksave","quicksave: performs a quick save", osdcmd_quicksave);
1327
    OSD_RegisterFunction("quickload","quickload: performs a quick load", osdcmd_quickload);
1342
    OSD_RegisterFunction("quickload","quickload: performs a quick load", osdcmd_quickload);
1328
    OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit);
1343
    OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit);
1329
    OSD_RegisterFunction("exit","exit: exits the game immediately", osdcmd_quit);
1344
    OSD_RegisterFunction("exit","exit: exits the game immediately", osdcmd_quit);
1330
1345
1331
    OSD_RegisterFunction("rate","rate: sets the multiplayer packet send rate, in packets/sec",osdcmd_rate);
1346
    OSD_RegisterFunction("rate","rate: sets the multiplayer packet send rate, in packets/sec",osdcmd_rate);
1332
    OSD_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound);
1347
    OSD_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound);
1333
    OSD_RegisterFunction("restartvid","restartvid: reinitializes the video mode",osdcmd_restartvid);
1348
    OSD_RegisterFunction("restartvid","restartvid: reinitializes the video mode",osdcmd_restartvid);
1334
1349
1335
    OSD_RegisterFunction("sensitivity","sensitivity <value>: changes the mouse sensitivity", osdcmd_sensitivity);
1350
    OSD_RegisterFunction("sensitivity","sensitivity <value>: changes the mouse sensitivity", osdcmd_sensitivity);
1336
    OSD_RegisterFunction("setvar","setvar <gamevar> <value>: sets the value of a gamevar", osdcmd_setvar);
1351
    OSD_RegisterFunction("setvar","setvar <gamevar> <value>: sets the value of a gamevar", osdcmd_setvar);
1337
    OSD_RegisterFunction("setvarvar","setvar <gamevar> <gamevar>: sets the value of a gamevar", osdcmd_setvar);
1352
    OSD_RegisterFunction("setvarvar","setvar <gamevar> <gamevar>: sets the value of a gamevar", osdcmd_setvar);
1338
    OSD_RegisterFunction("setactorvar","setactorvar <actorID> <gamevar> <value>: sets the value of a gamevar", osdcmd_setactorvar);
1353
    OSD_RegisterFunction("setactorvar","setactorvar <actorID> <gamevar> <value>: sets the value of a gamevar", osdcmd_setactorvar);
1339
    OSD_RegisterFunction("screenshot","screenshot: takes a screenshot.  See r_scrcaptureformat.", osdcmd_screenshot);
1354
    OSD_RegisterFunction("screenshot","screenshot: takes a screenshot.  See r_scrcaptureformat.", osdcmd_screenshot);
1340
1355
1341
    OSD_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
1356
    OSD_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
1342
1357
1343
    OSD_RegisterFunction("unbind","unbind <key>: unbinds a key.", osdcmd_unbind);
1358
    OSD_RegisterFunction("unbind","unbind <key>: unbinds a key.", osdcmd_unbind);
1344
    OSD_RegisterFunction("unbindall","unbindall: unbinds all keys.", osdcmd_unbindall);
1359
    OSD_RegisterFunction("unbindall","unbindall: unbinds all keys.", osdcmd_unbindall);
1345
1360
1346
    OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: change the video mode",osdcmd_vidmode);
1361
    OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: change the video mode",osdcmd_vidmode);
1347
    OSD_RegisterFunction("vid_gamma","vid_gamma <gamma>: adjusts gamma ramp",osdcmd_vid_gamma);
1362
    OSD_RegisterFunction("vid_gamma","vid_gamma <gamma>: adjusts gamma ramp",osdcmd_vid_gamma);
1348
    OSD_RegisterFunction("vid_contrast","vid_contrast <gamma>: adjusts gamma ramp",osdcmd_vid_contrast);
1363
    OSD_RegisterFunction("vid_contrast","vid_contrast <gamma>: adjusts gamma ramp",osdcmd_vid_contrast);
1349
    OSD_RegisterFunction("vid_brightness","vid_brightness <gamma>: adjusts gamma ramp",osdcmd_vid_brightness);
1364
    OSD_RegisterFunction("vid_brightness","vid_brightness <gamma>: adjusts gamma ramp",osdcmd_vid_brightness);
1350
    OSD_RegisterFunction("savestate","",osdcmd_savestate);
1365
    OSD_RegisterFunction("savestate","",osdcmd_savestate);
1351
    OSD_RegisterFunction("restorestate","",osdcmd_restorestate);
1366
    OSD_RegisterFunction("restorestate","",osdcmd_restorestate);
1352
    //baselayer_onvideomodechange = onvideomodechange;
1367
    //baselayer_onvideomodechange = onvideomodechange;
1353
1368
1354
    return 0;
1369
    return 0;
1355
}
1370
}
1356
1371
1357
 
1372