Subversion Repositories eduke32

Rev

Rev 8716 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 Plagman 1
//-------------------------------------------------------------------------
2
/*
1652 terminx 3
Copyright (C) 2010 EDuke32 developers and contributors
484 terminx 4
 
1652 terminx 5
This file is part of EDuke32.
5 Plagman 6
 
7
EDuke32 is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License version 2
9
as published by the Free Software Foundation.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 
15
See the GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
4541 hendricks2 19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
5 Plagman 20
*/
21
//-------------------------------------------------------------------------
22
 
8208 terminx 23
#include "osdcmds.h"
24
 
7239 terminx 25
#include "cheats.h"
26
#include "cmdline.h"
27
#include "demo.h"  // g_firstDemoFile[]
5612 terminx 28
#include "duke3d.h"
7239 terminx 29
#include "menus.h"
901 terminx 30
#include "osdfuncs.h"
7239 terminx 31
#include "savegame.h"
5613 terminx 32
#include "sbar.h"
1677 terminx 33
 
4134 helixhorne 34
#ifdef LUNATIC
35
# include "lunatic_game.h"
36
#endif
37
 
4993 terminx 38
#ifdef EDUKE32_TOUCH_DEVICES
6056 hendricks2 39
#include "in_android.h"
4993 terminx 40
#endif
41
 
7359 hendricks2 42
#include "vfs.h"
43
 
5 Plagman 44
struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat;
911 terminx 45
float r_ambientlight = 1.0, r_ambientlightrecip = 1.0;
5 Plagman 46
 
5084 hendricks2 47
uint32_t cl_cheatmask;
48
 
7154 terminx 49
static inline int osdcmd_quit(osdcmdptr_t UNUSED(parm))
5 Plagman 50
{
6297 terminx 51
    UNREFERENCED_CONST_PARAMETER(parm);
4358 hendricks2 52
    OSD_ShowDisplay(0);
1571 terminx 53
    G_GameQuit();
5 Plagman 54
    return OSDCMD_OK;
55
}
56
 
7154 terminx 57
static int osdcmd_changelevel(osdcmdptr_t parm)
5 Plagman 58
{
8397 terminx 59
    int volume = 0;
60
    int level;
5 Plagman 61
 
335 terminx 62
    if (!VOLUMEONE)
63
    {
5 Plagman 64
        if (parm->numparms != 2) return OSDCMD_SHOWHELP;
65
 
8397 terminx 66
        volume = strtol(parm->parms[0], NULL, 10) - 1;
67
        level = strtol(parm->parms[1], NULL, 10) - 1;
335 terminx 68
    }
69
    else
70
    {
5 Plagman 71
        if (parm->numparms != 1) return OSDCMD_SHOWHELP;
72
 
8397 terminx 73
        level = strtol(parm->parms[0], NULL, 10) - 1;
5 Plagman 74
    }
75
 
8397 terminx 76
    if (volume < 0 || level < 0)
77
        return OSDCMD_SHOWHELP;
5 Plagman 78
 
8397 terminx 79
    if (level > MAXLEVELS || g_mapInfo[volume * MAXLEVELS + level].filename == NULL)
335 terminx 80
    {
8397 terminx 81
        OSD_Printf("changelevel: no map defined for episode %d level %d\n", volume + 1, level + 1);
564 terminx 82
        return OSDCMD_SHOWHELP;
335 terminx 83
    }
5 Plagman 84
 
413 terminx 85
    if (numplayers > 1)
86
    {
6297 terminx 87
        /*
1587 terminx 88
        if (g_netServer)
1143 terminx 89
            Net_NewGame(volume,level);
413 terminx 90
        else if (voting == -1)
91
        {
92
            ud.m_volume_number = volume;
93
            ud.m_level_number = level;
472 terminx 94
 
564 terminx 95
            if (g_player[myconnectindex].ps->i)
413 terminx 96
            {
1205 terminx 97
                int32_t i;
472 terminx 98
 
1229 terminx 99
                for (i=0; i<MAXPLAYERS; i++)
564 terminx 100
                {
101
                    g_player[i].vote = 0;
102
                    g_player[i].gotvote = 0;
103
                }
104
 
105
                g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
106
 
413 terminx 107
                voting = myconnectindex;
108
 
1206 terminx 109
                tempbuf[0] = PACKET_MAP_VOTE_INITIATE;
1143 terminx 110
                tempbuf[1] = myconnectindex;
111
                tempbuf[2] = ud.m_volume_number;
112
                tempbuf[3] = ud.m_level_number;
413 terminx 113
 
1592 terminx 114
                enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
413 terminx 115
            }
6481 hendricks2 116
            if ((g_gametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(g_gametypeFlags[ud.m_coop] & GAMETYPE_TDM))
413 terminx 117
                ud.m_noexits = 0;
118
 
4738 hendricks2 119
            M_OpenMenu(myconnectindex);
5923 terminx 120
            Menu_Change(MENU_NETWAITVOTES);
413 terminx 121
        }
6297 terminx 122
        */
413 terminx 123
        return OSDCMD_OK;
124
    }
8397 terminx 125
 
564 terminx 126
    if (g_player[myconnectindex].ps->gm & MODE_GAME)
335 terminx 127
    {
5 Plagman 128
        // in-game behave like a cheat
3005 helixhorne 129
        osdcmd_cheatsinfo_stat.cheatnum = CHEAT_SCOTTY;
5 Plagman 130
        osdcmd_cheatsinfo_stat.volume   = volume;
131
        osdcmd_cheatsinfo_stat.level    = level;
335 terminx 132
    }
133
    else
134
    {
5 Plagman 135
        // out-of-game behave like a menu command
136
        osdcmd_cheatsinfo_stat.cheatnum = -1;
137
 
5835 terminx 138
        ud.m_volume_number     = volume;
139
        ud.m_level_number      = level;
5 Plagman 140
 
5835 terminx 141
        ud.m_monsters_off      = 0;
142
        ud.monsters_off        = 0;
5 Plagman 143
 
5835 terminx 144
        ud.m_respawn_items     = 0;
5 Plagman 145
        ud.m_respawn_inventory = 0;
146
 
5835 terminx 147
        ud.multimode           = 1;
5 Plagman 148
 
3950 helixhorne 149
        G_NewGame_EnterLevel();
5 Plagman 150
    }
151
 
152
    return OSDCMD_OK;
153
}
154
 
7154 terminx 155
static int osdcmd_map(osdcmdptr_t parm)
5 Plagman 156
{
2556 helixhorne 157
    char filename[BMAX_PATH];
5 Plagman 158
 
3004 helixhorne 159
    const int32_t wildcardp = parm->numparms==1 &&
160
        (Bstrchr(parm->parms[0], '*') != NULL);
161
 
162
    if (parm->numparms != 1 || wildcardp)
987 terminx 163
    {
8199 terminx 164
        BUILDVFS_FIND_REC *r;
2556 helixhorne 165
        fnlist_t fnlist = FNLIST_INITIALIZER;
1205 terminx 166
        int32_t maxwidth = 0;
5 Plagman 167
 
3004 helixhorne 168
        if (wildcardp)
169
            maybe_append_ext(filename, sizeof(filename), parm->parms[0], ".map");
170
        else
171
            Bstrcpy(filename, "*.MAP");
987 terminx 172
 
3004 helixhorne 173
        fnlist_getnames(&fnlist, "/", filename, -1, 0);
174
 
2556 helixhorne 175
        for (r=fnlist.findfiles; r; r=r->next)
7078 terminx 176
            maxwidth = max<int>(maxwidth, Bstrlen(r->name));
987 terminx 177
 
178
        if (maxwidth > 0)
179
        {
7037 terminx 180
            int32_t x = 0;
987 terminx 181
            maxwidth += 3;
182
            OSD_Printf(OSDTEXT_RED "Map listing:\n");
2556 helixhorne 183
            for (r=fnlist.findfiles; r; r=r->next)
987 terminx 184
            {
185
                OSD_Printf("%-*s",maxwidth,r->name);
186
                x += maxwidth;
187
                if (x > OSD_GetCols() - maxwidth)
188
                {
189
                    x = 0;
190
                    OSD_Printf("\n");
191
                }
192
            }
193
            if (x) OSD_Printf("\n");
2556 helixhorne 194
            OSD_Printf(OSDTEXT_RED "Found %d maps\n", fnlist.numfiles);
987 terminx 195
        }
196
 
2556 helixhorne 197
        fnlist_clearnames(&fnlist);
198
 
987 terminx 199
        return OSDCMD_SHOWHELP;
200
    }
201
 
3004 helixhorne 202
    maybe_append_ext(filename, sizeof(filename), parm->parms[0], ".map");
5 Plagman 203
 
7359 hendricks2 204
    buildvfs_kfd ii;
205
    if ((ii = kopen4loadfrommod(filename,0)) == buildvfs_kfd_invalid)
335 terminx 206
    {
909 terminx 207
        OSD_Printf(OSD_ERROR "map: file \"%s\" not found.\n", filename);
5 Plagman 208
        return OSDCMD_OK;
209
    }
7359 hendricks2 210
    kclose(ii);
5 Plagman 211
 
413 terminx 212
    boardfilename[0] = '/';
213
    boardfilename[1] = 0;
214
    strcat(boardfilename, filename);
5 Plagman 215
 
413 terminx 216
    if (numplayers > 1)
217
    {
6297 terminx 218
        /*
1587 terminx 219
        if (g_netServer)
413 terminx 220
        {
1143 terminx 221
            Net_SendUserMapName();
222
            ud.m_volume_number = 0;
223
            ud.m_level_number = 7;
224
            Net_NewGame(ud.m_volume_number, ud.m_level_number);
413 terminx 225
        }
226
        else if (voting == -1)
227
        {
1143 terminx 228
            Net_SendUserMapName();
472 terminx 229
 
413 terminx 230
            ud.m_volume_number = 0;
231
            ud.m_level_number = 7;
472 terminx 232
 
564 terminx 233
            if (g_player[myconnectindex].ps->i)
413 terminx 234
            {
1205 terminx 235
                int32_t i;
472 terminx 236
 
1229 terminx 237
                for (i=0; i<MAXPLAYERS; i++)
564 terminx 238
                {
239
                    g_player[i].vote = 0;
240
                    g_player[i].gotvote = 0;
241
                }
242
 
243
                g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
413 terminx 244
                voting = myconnectindex;
245
 
1206 terminx 246
                tempbuf[0] = PACKET_MAP_VOTE_INITIATE;
1143 terminx 247
                tempbuf[1] = myconnectindex;
248
                tempbuf[2] = ud.m_volume_number;
249
                tempbuf[3] = ud.m_level_number;
413 terminx 250
 
1592 terminx 251
                enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
413 terminx 252
            }
6481 hendricks2 253
            if ((g_gametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(g_gametypeFlags[ud.m_coop] & GAMETYPE_TDM))
413 terminx 254
                ud.m_noexits = 0;
255
 
4738 hendricks2 256
            M_OpenMenu(myconnectindex);
5923 terminx 257
            Menu_Change(MENU_NETWAITVOTES);
413 terminx 258
        }
6297 terminx 259
        */
413 terminx 260
        return OSDCMD_OK;
261
    }
262
 
472 terminx 263
    osdcmd_cheatsinfo_stat.cheatnum = -1;
264
    ud.m_volume_number = 0;
265
    ud.m_level_number = 7;
413 terminx 266
 
472 terminx 267
    ud.m_monsters_off = ud.monsters_off = 0;
5 Plagman 268
 
472 terminx 269
    ud.m_respawn_items = 0;
270
    ud.m_respawn_inventory = 0;
5 Plagman 271
 
472 terminx 272
    ud.multimode = 1;
5 Plagman 273
 
7209 terminx 274
    if (g_player[myconnectindex].ps->gm & MODE_GAME)
275
    {
276
        G_NewGame(ud.m_volume_number, ud.m_level_number, ud.m_player_skill);
277
        g_player[myconnectindex].ps->gm = MODE_RESTART;
278
    }
279
    else G_NewGame_EnterLevel();
5 Plagman 280
 
281
    return OSDCMD_OK;
282
}
283
 
3021 helixhorne 284
// demo <demonum or demofn> [<prof>]
285
//
286
// To profile a demo ("timedemo mode"), <prof> can be given in the range 0-8,
287
// which will start to replay it as fast as possible, rendering <prof> frames
288
// for each gametic.
289
//
290
// Notes:
291
//  * The demos should be recorded with demorec_diffs set to 0, so that the
292
//    game state updates are actually computed.
3022 helixhorne 293
//  * Currently, the profiling can only be aborted on SDL 1.2 builds by
294
//    pressing any key.
3021 helixhorne 295
//  * With <prof> greater than 1, interpolation should be calculated properly,
296
//    though this has not been verified by looking at the frames.
297
//  * When testing whether a change in the source has an effect on performance,
298
//    the variance of the run times MUST be taken into account (that is, the
299
//    replaying must be performed multiple times for the old and new versions,
300
//    etc.)
7154 terminx 301
static int osdcmd_demo(osdcmdptr_t parm)
3006 helixhorne 302
{
303
    if (numplayers > 1)
304
    {
305
        OSD_Printf("Command not allowed in multiplayer\n");
306
        return OSDCMD_OK;
307
    }
308
 
309
    if (g_player[myconnectindex].ps->gm & MODE_GAME)
310
    {
311
        OSD_Printf("demo: Must not be in a game.\n");
312
        return OSDCMD_OK;
313
    }
314
 
3021 helixhorne 315
    if (parm->numparms != 1 && parm->numparms != 2)
3006 helixhorne 316
        return OSDCMD_SHOWHELP;
317
 
318
    {
3021 helixhorne 319
        int32_t prof = parm->numparms==2 ? Batoi(parm->parms[1]) : -1;
3006 helixhorne 320
 
3045 helixhorne 321
        Demo_SetFirst(parm->parms[0]);
3024 helixhorne 322
        Demo_PlayFirst(clamp(prof, -1, 8)+1, 0);
3006 helixhorne 323
    }
324
 
325
    return OSDCMD_OK;
326
}
327
 
7154 terminx 328
static int osdcmd_activatecheat(osdcmdptr_t parm)
6322 hendricks2 329
{
330
    if (parm->numparms != 1)
331
        return OSDCMD_SHOWHELP;
332
 
333
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
334
        osdcmd_cheatsinfo_stat.cheatnum = Batoi(parm->parms[0]);
335
    else
336
        OSD_Printf("activatecheat: Not in a single-player game.\n");
337
 
338
    return OSDCMD_OK;
339
}
340
 
7154 terminx 341
static int osdcmd_god(osdcmdptr_t UNUSED(parm))
5 Plagman 342
{
6297 terminx 343
    UNREFERENCED_CONST_PARAMETER(parm);
564 terminx 344
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
3005 helixhorne 345
        osdcmd_cheatsinfo_stat.cheatnum = CHEAT_CORNHOLIO;
335 terminx 346
    else
5 Plagman 347
        OSD_Printf("god: Not in a single-player game.\n");
348
 
349
    return OSDCMD_OK;
350
}
351
 
8542 terminx 352
static int osdcmd_maxhealth(osdcmdptr_t parm)
353
{
354
    if (parm->numparms != 1)
355
        return OSDCMD_SHOWHELP;
356
 
357
    auto pPlayer = g_player[myconnectindex].ps;
358
 
359
    if (numplayers == 1 && pPlayer->gm & MODE_GAME)
360
    {
361
        int const newHealth = Batoi(parm->parms[0]);
362
        pPlayer->max_player_health = newHealth;
363
        sprite[pPlayer->i].extra = newHealth;
364
    }
365
    else
366
        OSD_Printf("maxhealth: Not in a single-player game.\n");
367
 
368
    return OSDCMD_OK;
369
}
370
 
7154 terminx 371
static int osdcmd_noclip(osdcmdptr_t UNUSED(parm))
5 Plagman 372
{
6297 terminx 373
    UNREFERENCED_CONST_PARAMETER(parm);
3006 helixhorne 374
 
564 terminx 375
    if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME)
335 terminx 376
    {
3005 helixhorne 377
        osdcmd_cheatsinfo_stat.cheatnum = CHEAT_CLIP;
335 terminx 378
    }
379
    else
380
    {
5 Plagman 381
        OSD_Printf("noclip: Not in a single-player game.\n");
382
    }
383
 
384
    return OSDCMD_OK;
385
}
386
 
7154 terminx 387
static int osdcmd_restartsound(osdcmdptr_t UNUSED(parm))
472 terminx 388
{
6297 terminx 389
    UNREFERENCED_CONST_PARAMETER(parm);
1143 terminx 390
    S_SoundShutdown();
391
    S_MusicShutdown();
472 terminx 392
 
8255 hendricks2 393
    S_SoundStartup();
1143 terminx 394
    S_MusicStartup();
472 terminx 395
 
396
    FX_StopAllSounds();
1143 terminx 397
    S_ClearSoundLocks();
472 terminx 398
 
4986 terminx 399
    if (ud.config.MusicToggle)
4585 helixhorne 400
        S_RestartMusic();
491 terminx 401
 
472 terminx 402
    return OSDCMD_OK;
403
}
404
 
7154 terminx 405
static int osdcmd_music(osdcmdptr_t parm)
4587 helixhorne 406
{
407
    if (parm->numparms == 1)
408
    {
409
        int32_t sel = G_GetMusicIdx(parm->parms[0]);
410
 
411
        if (sel == -1)
412
            return OSDCMD_SHOWHELP;
413
 
414
        if (sel == -2)
415
        {
416
            OSD_Printf("%s is not a valid episode/level number pair\n", parm->parms[0]);
417
            return OSDCMD_OK;
418
        }
419
 
6619 hendricks2 420
        if (!S_TryPlayLevelMusic(sel))
4587 helixhorne 421
        {
6619 hendricks2 422
            G_PrintCurrentMusic();
4587 helixhorne 423
        }
424
        else
425
        {
426
            OSD_Printf("No music defined for %s\n", parm->parms[0]);
427
        }
428
 
429
        return OSDCMD_OK;
430
    }
431
 
432
    return OSDCMD_SHOWHELP;
433
}
434
 
7154 terminx 435
int osdcmd_restartvid(osdcmdptr_t UNUSED(parm))
5 Plagman 436
{
6297 terminx 437
    UNREFERENCED_CONST_PARAMETER(parm);
6828 terminx 438
    videoResetMode();
7219 terminx 439
    if (videoSetGameMode(ud.setup.fullscreen,ud.setup.xdim,ud.setup.ydim,ud.setup.bpp,ud.detail))
1143 terminx 440
        G_GameExit("restartvid: Reset failed...\n");
7219 terminx 441
    onvideomodechange(ud.setup.bpp>8);
1143 terminx 442
    G_UpdateScreenArea();
5 Plagman 443
 
444
    return OSDCMD_OK;
445
}
446
 
7154 terminx 447
int osdcmd_restartmap(osdcmdptr_t UNUSED(parm))
5483 terminx 448
{
6297 terminx 449
    UNREFERENCED_CONST_PARAMETER(parm);
5483 terminx 450
 
451
    if (g_player[myconnectindex].ps->gm & MODE_GAME && ud.multimode == 1)
452
        g_player[myconnectindex].ps->gm = MODE_RESTART;
453
 
454
    return OSDCMD_OK;
455
}
456
 
7154 terminx 457
static int osdcmd_vidmode(osdcmdptr_t parm)
5 Plagman 458
{
7219 terminx 459
    int32_t newbpp = ud.setup.bpp, newwidth = ud.setup.xdim,
460
            newheight = ud.setup.ydim, newfs = ud.setup.fullscreen;
2311 helixhorne 461
    int32_t tmp;
462
 
5 Plagman 463
    if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
464
 
335 terminx 465
    switch (parm->numparms)
466
    {
337 terminx 467
    case 1: // bpp switch
2311 helixhorne 468
        tmp = Batol(parm->parms[0]);
469
        if (!(tmp==8 || tmp==16 || tmp==32))
470
            return OSDCMD_SHOWHELP;
471
        newbpp = tmp;
337 terminx 472
        break;
473
    case 2: // res switch
474
        newwidth = Batol(parm->parms[0]);
475
        newheight = Batol(parm->parms[1]);
476
        break;
477
    case 3: // res & bpp switch
478
    case 4:
479
        newwidth = Batol(parm->parms[0]);
480
        newheight = Batol(parm->parms[1]);
2311 helixhorne 481
        tmp = Batol(parm->parms[2]);
482
        if (!(tmp==8 || tmp==16 || tmp==32))
483
            return OSDCMD_SHOWHELP;
484
        newbpp = tmp;
337 terminx 485
        if (parm->numparms == 4)
486
            newfs = (Batol(parm->parms[3]) != 0);
487
        break;
5 Plagman 488
    }
489
 
6939 pogokeen 490
    if (videoSetGameMode(newfs,newwidth,newheight,newbpp,upscalefactor))
335 terminx 491
    {
5 Plagman 492
        initprintf("vidmode: Mode change failed!\n");
7219 terminx 493
        if (videoSetGameMode(ud.setup.fullscreen, ud.setup.xdim, ud.setup.ydim, ud.setup.bpp, upscalefactor))
1143 terminx 494
            G_GameExit("vidmode: Reset failed!\n");
5 Plagman 495
    }
7219 terminx 496
    ud.setup.bpp = newbpp;
497
    ud.setup.xdim = newwidth;
498
    ud.setup.ydim = newheight;
499
    ud.setup.fullscreen = newfs;
500
    onvideomodechange(ud.setup.bpp>8);
1143 terminx 501
    G_UpdateScreenArea();
5 Plagman 502
    return OSDCMD_OK;
503
}
504
 
4370 helixhorne 505
#ifdef LUNATIC
506
// Returns: INT32_MIN if no such CON label, its value else.
507
LUNATIC_CB int32_t (*El_GetLabelValue)(const char *label);
508
#endif
509
 
7154 terminx 510
static int osdcmd_spawn(osdcmdptr_t parm)
5 Plagman 511
{
4370 helixhorne 512
    int32_t picnum = 0;
513
    uint16_t cstat=0;
1205 terminx 514
    char pal=0;
515
    int16_t ang=0;
516
    int16_t set=0, idx;
1208 terminx 517
    vec3_t vect;
5 Plagman 518
 
564 terminx 519
    if (numplayers > 1 || !(g_player[myconnectindex].ps->gm & MODE_GAME))
335 terminx 520
    {
5 Plagman 521
        OSD_Printf("spawn: Can't spawn sprites in multiplayer games or demos\n");
522
        return OSDCMD_OK;
523
    }
524
 
335 terminx 525
    switch (parm->numparms)
526
    {
337 terminx 527
    case 7: // x,y,z
1208 terminx 528
        vect.x = Batol(parm->parms[4]);
529
        vect.y = Batol(parm->parms[5]);
530
        vect.z = Batol(parm->parms[6]);
337 terminx 531
        set |= 8;
6370 terminx 532
        fallthrough__;
337 terminx 533
    case 4: // ang
534
        ang = Batol(parm->parms[3]) & 2047;
535
        set |= 4;
6370 terminx 536
        fallthrough__;
337 terminx 537
    case 3: // cstat
1205 terminx 538
        cstat = (uint16_t)Batol(parm->parms[2]);
337 terminx 539
        set |= 2;
6370 terminx 540
        fallthrough__;
337 terminx 541
    case 2: // pal
1205 terminx 542
        pal = (uint8_t)Batol(parm->parms[1]);
337 terminx 543
        set |= 1;
6370 terminx 544
        fallthrough__;
337 terminx 545
    case 1: // tile number
546
        if (isdigit(parm->parms[0][0]))
547
        {
4370 helixhorne 548
            picnum = Batol(parm->parms[0]);
337 terminx 549
        }
550
        else
551
        {
4370 helixhorne 552
            int32_t i;
553
#ifdef LUNATIC
5835 terminx 554
            i = g_labelCnt;
4370 helixhorne 555
            picnum = El_GetLabelValue(parm->parms[0]);
556
            if (picnum != INT32_MIN)
557
                i = !i;
558
#else
559
            int32_t j;
560
 
337 terminx 561
            for (j=0; j<2; j++)
335 terminx 562
            {
5835 terminx 563
                for (i=0; i<g_labelCnt; i++)
335 terminx 564
                {
4370 helixhorne 565
                    if ((j == 0 && !Bstrcmp(label+(i<<6),     parm->parms[0])) ||
566
                        (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0])))
335 terminx 567
                    {
4370 helixhorne 568
                        picnum = labelcode[i];
337 terminx 569
                        break;
5 Plagman 570
                    }
571
                }
4370 helixhorne 572
 
5835 terminx 573
                if (i < g_labelCnt)
4370 helixhorne 574
                    break;
5 Plagman 575
            }
4370 helixhorne 576
#endif
5835 terminx 577
            if (i==g_labelCnt)
335 terminx 578
            {
337 terminx 579
                OSD_Printf("spawn: Invalid tile label given\n");
5 Plagman 580
                return OSDCMD_OK;
581
            }
337 terminx 582
        }
583
 
4370 helixhorne 584
        if ((uint32_t)picnum >= MAXUSERTILES)
337 terminx 585
        {
586
            OSD_Printf("spawn: Invalid tile number\n");
587
            return OSDCMD_OK;
588
        }
589
        break;
4370 helixhorne 590
 
337 terminx 591
    default:
592
        return OSDCMD_SHOWHELP;
5 Plagman 593
    }
594
 
4370 helixhorne 595
    idx = A_Spawn(g_player[myconnectindex].ps->i, picnum);
1205 terminx 596
    if (set & 1) sprite[idx].pal = (uint8_t)pal;
597
    if (set & 2) sprite[idx].cstat = (int16_t)cstat;
5 Plagman 598
    if (set & 4) sprite[idx].ang = ang;
335 terminx 599
    if (set & 8)
600
    {
1208 terminx 601
        if (setsprite(idx, &vect) < 0)
335 terminx 602
        {
5 Plagman 603
            OSD_Printf("spawn: Sprite can't be spawned into null space\n");
2452 helixhorne 604
            A_DeleteSprite(idx);
5 Plagman 605
        }
606
    }
607
 
608
    return OSDCMD_OK;
609
}
610
 
3415 helixhorne 611
#if !defined LUNATIC
7154 terminx 612
static int osdcmd_setvar(osdcmdptr_t parm)
5 Plagman 613
{
379 terminx 614
    if (numplayers > 1)
5 Plagman 615
    {
616
        OSD_Printf("Command not allowed in multiplayer\n");
617
        return OSDCMD_OK;
618
    }
619
 
7883 terminx 620
    if (parm->numparms != 2)
621
        return OSDCMD_SHOWHELP;
622
 
7153 terminx 623
    int i = hash_find(&h_gamevars, parm->parms[1]);
7258 terminx 624
    int const newValue = (i == -1) ? Batol(parm->parms[1]) : Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex);
587 terminx 625
 
7153 terminx 626
    if ((i = hash_find(&h_gamevars, parm->parms[0])) >= 0)
7883 terminx 627
    {
7258 terminx 628
        Gv_SetVar(i, newValue, g_player[myconnectindex].ps->i, myconnectindex);
7153 terminx 629
 
7883 terminx 630
        OSD_Printf("Variable \"%s\" now has value %d (input: %d)\n", aGameVars[i].szLabel,
631
                   Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex), newValue);
632
    }
633
    else
634
    {
635
        OSD_Printf("setvar: \"%s\" is not a game variable!\n", parm->parms[0]);
636
        return OSDCMD_SHOWHELP;
637
    }
638
 
11 terminx 639
    return OSDCMD_OK;
29 terminx 640
}
11 terminx 641
 
7154 terminx 642
static int osdcmd_addlogvar(osdcmdptr_t parm)
892 hnt_ts 643
{
644
    if (numplayers > 1)
645
    {
646
        OSD_Printf("Command not allowed in multiplayer\n");
647
        return OSDCMD_OK;
648
    }
649
 
7883 terminx 650
    if (parm->numparms != 1)
651
        return OSDCMD_SHOWHELP;
652
 
7153 terminx 653
    int const i = hash_find(&h_gamevars, parm->parms[0]);
654
 
1030 terminx 655
    if (i >= 0)
7258 terminx 656
        OSD_Printf("Variable \"%s\" has value %d, default %d\n", parm->parms[0], Gv_GetVar(i, g_player[screenpeek].ps->i, screenpeek), (int)aGameVars[i].defaultValue);
7883 terminx 657
    else
658
    {
659
        OSD_Printf("addlogvar: %s is not a game variable!\n", parm->parms[0]);
660
        return OSDCMD_SHOWHELP;
661
    }
7153 terminx 662
 
892 hnt_ts 663
    return OSDCMD_OK;
664
}
665
 
7154 terminx 666
static int osdcmd_setactorvar(osdcmdptr_t parm)
587 terminx 667
{
668
    if (numplayers > 1)
669
    {
670
        OSD_Printf("Command not allowed in multiplayer\n");
671
        return OSDCMD_OK;
672
    }
673
 
7883 terminx 674
    if (parm->numparms != 3)
675
        return OSDCMD_SHOWHELP;
676
 
7153 terminx 677
    int16_t const spriteNum = Batol(parm->parms[0]);
7037 terminx 678
 
679
    if ((unsigned)spriteNum >= MAXSPRITES)
587 terminx 680
    {
7883 terminx 681
        OSD_Printf("setactorvar: Invalid sprite number!\n");
587 terminx 682
        return OSDCMD_OK;
683
    }
684
 
7037 terminx 685
    // get value to set
7153 terminx 686
    int i = hash_find(&h_gamevars, parm->parms[2]);
7258 terminx 687
    int const newValue = (i >= 0) ? Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex) : Batol(parm->parms[2]);
7037 terminx 688
 
7153 terminx 689
    if ((i = hash_find(&h_gamevars, parm->parms[1])) >= 0)
7883 terminx 690
    {
7258 terminx 691
        Gv_SetVar(i, newValue, spriteNum, myconnectindex);
7037 terminx 692
 
7883 terminx 693
        OSD_Printf("Variable \"%s\" for sprite %d value is now %d (input: %d)\n", aGameVars[i].szLabel, spriteNum,
694
                   Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex), newValue);
695
    }
696
    else
697
    {
698
        OSD_Printf("setactorvar: %s is not a game variable!\n", parm->parms[1]);
699
        return OSDCMD_SHOWHELP;
700
    }
701
 
587 terminx 702
    return OSDCMD_OK;
703
}
4134 helixhorne 704
#else
7154 terminx 705
static int osdcmd_lua(osdcmdptr_t parm)
4134 helixhorne 706
{
707
    // Should be used like
708
    // lua "lua code..."
709
    // (the quotes making the whole string passed as one argument)
710
 
711
    int32_t ret;
712
 
713
    if (parm->numparms != 1)
714
        return OSDCMD_SHOWHELP;
715
 
716
    if (!L_IsInitialized(&g_ElState))
717
    {
718
        OSD_Printf("Lua state is not initialized.\n");
719
        return OSDCMD_OK;
720
    }
721
 
722
    // TODO: "=<expr>" as shorthand for "print(<expr>)", like in the
723
    //  stand-alone Lua interpreter?
724
    // TODO: reserve some table to explicitly store stuff on the top level, for
725
    //  debugging convenience?
726
 
727
    // For the 'lua' OSD command, don't make errors appear on-screen:
728
    el_addNewErrors = 0;
5590 hendricks2 729
    ret = L_RunString(&g_ElState, parm->parms[0], -1, "console");
4134 helixhorne 730
    el_addNewErrors = 1;
731
 
732
    if (ret != 0)
733
        OSD_Printf("Error running the Lua code (error code %d)\n", ret);
734
 
735
    return OSDCMD_OK;
736
}
3415 helixhorne 737
#endif
587 terminx 738
 
7154 terminx 739
static int osdcmd_addpath(osdcmdptr_t parm)
11 terminx 740
{
7153 terminx 741
    if (parm->numparms != 1)
742
        return OSDCMD_SHOWHELP;
11 terminx 743
 
7153 terminx 744
    addsearchpath(parm->parms[0]);
11 terminx 745
 
5 Plagman 746
    return OSDCMD_OK;
747
}
748
 
7154 terminx 749
static int osdcmd_initgroupfile(osdcmdptr_t parm)
182 terminx 750
{
7153 terminx 751
    if (parm->numparms != 1)
752
        return OSDCMD_SHOWHELP;
182 terminx 753
 
7153 terminx 754
    initgroupfile(parm->parms[0]);
182 terminx 755
 
756
    return OSDCMD_OK;
757
}
758
 
7154 terminx 759
static int osdcmd_cmenu(osdcmdptr_t parm)
5 Plagman 760
{
7153 terminx 761
    if (parm->numparms != 1)
762
        return OSDCMD_SHOWHELP;
763
 
335 terminx 764
    if (numplayers > 1)
765
    {
7153 terminx 766
        OSD_Printf("Command not allowed in multiplayer\n");
5 Plagman 767
        return OSDCMD_OK;
335 terminx 768
    }
5 Plagman 769
 
7269 terminx 770
    if ((g_player[myconnectindex].ps->gm & MODE_MENU) != MODE_MENU)
771
        Menu_Open(myconnectindex);
772
 
7153 terminx 773
    Menu_Change(Batol(parm->parms[0]));
774
 
5 Plagman 775
    return OSDCMD_OK;
776
}
777
 
150 terminx 778
 
7068 terminx 779
 
780
 
7154 terminx 781
static int osdcmd_crosshaircolor(osdcmdptr_t parm)
5 Plagman 782
{
1352 terminx 783
    if (parm->numparms != 3)
335 terminx 784
    {
1352 terminx 785
        OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b);
786
        return OSDCMD_SHOWHELP;
5 Plagman 787
    }
7153 terminx 788
 
789
    uint8_t const r = Batol(parm->parms[0]);
790
    uint8_t const g = Batol(parm->parms[1]);
791
    uint8_t const b = Batol(parm->parms[2]);
792
 
1352 terminx 793
    G_SetCrosshairColor(r,g,b);
5387 terminx 794
 
795
    if (!OSD_ParsingScript())
796
        OSD_Printf("%s\n", parm->raw);
797
 
5 Plagman 798
    return OSDCMD_OK;
799
}
800
 
7154 terminx 801
static int osdcmd_give(osdcmdptr_t parm)
5 Plagman 802
{
1205 terminx 803
    int32_t i;
5 Plagman 804
 
972 terminx 805
    if (numplayers != 1 || (g_player[myconnectindex].ps->gm & MODE_GAME) == 0 ||
990 terminx 806
            g_player[myconnectindex].ps->dead_flag != 0)
335 terminx 807
    {
972 terminx 808
        OSD_Printf("give: Cannot give while dead or not in a single-player game.\n");
809
        return OSDCMD_OK;
810
    }
335 terminx 811
 
972 terminx 812
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
335 terminx 813
 
972 terminx 814
    if (!Bstrcasecmp(parm->parms[0], "all"))
815
    {
3005 helixhorne 816
        osdcmd_cheatsinfo_stat.cheatnum = CHEAT_STUFF;
972 terminx 817
        return OSDCMD_OK;
335 terminx 818
    }
972 terminx 819
    else if (!Bstrcasecmp(parm->parms[0], "health"))
335 terminx 820
    {
972 terminx 821
        sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health<<1;
5 Plagman 822
        return OSDCMD_OK;
823
    }
972 terminx 824
    else if (!Bstrcasecmp(parm->parms[0], "weapons"))
825
    {
3005 helixhorne 826
        osdcmd_cheatsinfo_stat.cheatnum = CHEAT_WEAPONS;
972 terminx 827
        return OSDCMD_OK;
828
    }
829
    else if (!Bstrcasecmp(parm->parms[0], "ammo"))
830
    {
1229 terminx 831
        for (i=MAX_WEAPONS-(VOLUMEONE?6:1)-1; i>=PISTOL_WEAPON; i--)
5826 terminx 832
            P_AddAmmo(g_player[myconnectindex].ps,i,g_player[myconnectindex].ps->max_ammo_amount[i]);
972 terminx 833
        return OSDCMD_OK;
834
    }
835
    else if (!Bstrcasecmp(parm->parms[0], "armor"))
836
    {
1572 terminx 837
        g_player[myconnectindex].ps->inv_amount[GET_SHIELD] = 100;
972 terminx 838
        return OSDCMD_OK;
839
    }
840
    else if (!Bstrcasecmp(parm->parms[0], "keys"))
841
    {
3005 helixhorne 842
        osdcmd_cheatsinfo_stat.cheatnum = CHEAT_KEYS;
972 terminx 843
        return OSDCMD_OK;
844
    }
845
    else if (!Bstrcasecmp(parm->parms[0], "inventory"))
846
    {
3005 helixhorne 847
        osdcmd_cheatsinfo_stat.cheatnum = CHEAT_INVENTORY;
972 terminx 848
        return OSDCMD_OK;
849
    }
5 Plagman 850
    return OSDCMD_SHOWHELP;
851
}
852
 
1205 terminx 853
void onvideomodechange(int32_t newmode)
5 Plagman 854
{
1772 plagman 855
    uint8_t palid;
5 Plagman 856
 
3127 helixhorne 857
    // XXX?
858
    if (!newmode || g_player[screenpeek].ps->palette < BASEPALCOUNT)
859
        palid = g_player[screenpeek].ps->palette;
335 terminx 860
    else
3127 helixhorne 861
        palid = BASEPAL;
5 Plagman 862
 
1409 terminx 863
#ifdef POLYMER
6829 terminx 864
    if (videoGetRenderMode() == REND_POLYMER)
1409 terminx 865
    {
866
        int32_t i = 0;
867
 
868
        while (i < MAXSPRITES)
869
        {
1625 terminx 870
            if (actor[i].lightptr)
1409 terminx 871
            {
1625 terminx 872
                polymer_deletelight(actor[i].lightId);
873
                actor[i].lightptr = NULL;
874
                actor[i].lightId = -1;
1409 terminx 875
            }
876
            i++;
877
        }
878
    }
879
#endif
880
 
6829 terminx 881
    videoSetPalette(ud.brightness>>2, palid, 0);
2306 helixhorne 882
    g_restorePalette = -1;
5950 hendricks2 883
    g_crosshairSum = -1;
5 Plagman 884
}
885
 
7154 terminx 886
static int osdcmd_button(osdcmdptr_t parm)
808 terminx 887
{
7181 terminx 888
    static char const s_gamefunc_[] = "gamefunc_";
889
    int constexpr strlen_gamefunc_  = ARRAY_SIZE(s_gamefunc_) - 1;
890
 
891
    char const *p = parm->name + strlen_gamefunc_;
892
 
834 terminx 893
//    if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game
7181 terminx 894
    CONTROL_ButtonFlags[CONFIG_FunctionNameToNum(p)] = 1; // FIXME
895
 
808 terminx 896
    return OSDCMD_OK;
897
}
898
 
3209 helixhorne 899
const char *const ConsoleButtons[] =
2796 helixhorne 900
{
901
    "mouse1", "mouse2", "mouse3", "mouse4", "mwheelup",
902
    "mwheeldn", "mouse5", "mouse6", "mouse7", "mouse8"
903
};
836 terminx 904
 
7154 terminx 905
static int osdcmd_bind(osdcmdptr_t parm)
591 plagman 906
{
3127 helixhorne 907
    if (parm->numparms==1 && !Bstrcasecmp(parm->parms[0],"showkeys"))
591 plagman 908
    {
8041 hendricks2 909
        for (auto & s : sctokeylut)
910
            OSD_Printf("%s\n", s.key);
7147 terminx 911
        for (auto ConsoleButton : ConsoleButtons)
912
            OSD_Printf("%s\n",ConsoleButton);
591 plagman 913
        return OSDCMD_OK;
914
    }
811 terminx 915
 
591 plagman 916
    if (parm->numparms==0)
917
    {
7147 terminx 918
        int j=0;
833 terminx 919
 
920
        OSD_Printf("Current key bindings:\n");
3209 helixhorne 921
 
7147 terminx 922
        for (int i=0; i<MAXBOUNDKEYS+MAXMOUSEBUTTONS; i++)
3209 helixhorne 923
            if (CONTROL_KeyIsBound(i))
833 terminx 924
            {
925
                j++;
3195 terminx 926
                OSD_Printf("%-9s %s\"%s\"\n", CONTROL_KeyBinds[i].key, CONTROL_KeyBinds[i].repeat?"":"norepeat ",
3197 terminx 927
                           CONTROL_KeyBinds[i].cmdstr);
833 terminx 928
            }
836 terminx 929
 
833 terminx 930
        if (j == 0)
931
            OSD_Printf("No binds found.\n");
932
 
591 plagman 933
        return OSDCMD_OK;
934
    }
935
 
7147 terminx 936
    int i, j, repeat;
937
 
7179 terminx 938
    for (i=0; i < ARRAY_SSIZE(sctokeylut); i++)
939
    {
940
        if (!Bstrcasecmp(parm->parms[0], sctokeylut[i].key))
810 terminx 941
            break;
7179 terminx 942
    }
591 plagman 943
 
7179 terminx 944
    // didn't find the key
945
    if (i == ARRAY_SSIZE(sctokeylut))
826 terminx 946
    {
1229 terminx 947
        for (i=0; i<MAXMOUSEBUTTONS; i++)
1206 terminx 948
            if (!Bstrcasecmp(parm->parms[0],ConsoleButtons[i]))
826 terminx 949
                break;
7179 terminx 950
 
826 terminx 951
        if (i >= MAXMOUSEBUTTONS)
952
            return OSDCMD_SHOWHELP;
953
 
954
        if (parm->numparms < 2)
955
        {
6328 terminx 956
            if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr && CONTROL_KeyBinds[MAXBOUNDKEYS + i ].key)
957
                OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], CONTROL_KeyBinds[MAXBOUNDKEYS + i].repeat?"":"norepeat ",
958
                CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr);
959
            else OSD_Printf("%s is unbound\n", ConsoleButtons[i]);
826 terminx 960
            return OSDCMD_OK;
961
        }
962
 
963
        j = 1;
834 terminx 964
 
3209 helixhorne 965
        repeat = 1;
7086 terminx 966
        if (!Bstrcasecmp(parm->parms[j],"norepeat"))
826 terminx 967
        {
3209 helixhorne 968
            repeat = 0;
826 terminx 969
            j++;
970
        }
834 terminx 971
 
972
        Bstrcpy(tempbuf,parm->parms[j++]);
1229 terminx 973
        for (; j<parm->numparms; j++)
834 terminx 974
        {
975
            Bstrcat(tempbuf," ");
976
            Bstrcat(tempbuf,parm->parms[j++]);
977
        }
978
 
3209 helixhorne 979
        CONTROL_BindMouse(i, tempbuf, repeat, ConsoleButtons[i]);
3197 terminx 980
 
843 terminx 981
        if (!OSD_ParsingScript())
826 terminx 982
            OSD_Printf("%s\n",parm->raw);
983
        return OSDCMD_OK;
984
    }
985
 
811 terminx 986
    if (parm->numparms < 2)
987
    {
7179 terminx 988
        if (CONTROL_KeyIsBound(sctokeylut[i].sc))
989
            OSD_Printf("%-9s %s\"%s\"\n", sctokeylut[i].key, CONTROL_KeyBinds[sctokeylut[i].sc].repeat?"":"norepeat ",
990
                       CONTROL_KeyBinds[sctokeylut[i].sc].cmdstr);
991
        else OSD_Printf("%s is unbound\n", sctokeylut[i].key);
5387 terminx 992
 
811 terminx 993
        return OSDCMD_OK;
994
    }
995
 
808 terminx 996
    j = 1;
834 terminx 997
 
3209 helixhorne 998
    repeat = 1;
7086 terminx 999
    if (!Bstrcasecmp(parm->parms[j],"norepeat"))
808 terminx 1000
    {
3209 helixhorne 1001
        repeat = 0;
808 terminx 1002
        j++;
1003
    }
834 terminx 1004
 
1005
    Bstrcpy(tempbuf,parm->parms[j++]);
1229 terminx 1006
    for (; j<parm->numparms; j++)
834 terminx 1007
    {
1008
        Bstrcat(tempbuf," ");
1009
        Bstrcat(tempbuf,parm->parms[j++]);
1010
    }
1011
 
7179 terminx 1012
    CONTROL_BindKey(sctokeylut[i].sc, tempbuf, repeat, sctokeylut[i].key);
3197 terminx 1013
 
7147 terminx 1014
    char *cp = tempbuf;
1015
 
1016
    // Populate the keyboard config menu based on the bind.
1017
    // Take care of processing one-to-many bindings properly, too.
7153 terminx 1018
    static char const s_gamefunc_[] = "gamefunc_";
1019
    int constexpr strlen_gamefunc_  = ARRAY_SIZE(s_gamefunc_) - 1;
7147 terminx 1020
 
1021
    while ((cp = Bstrstr(cp, s_gamefunc_)))
1632 terminx 1022
    {
7147 terminx 1023
        cp += strlen_gamefunc_;
1625 terminx 1024
 
7147 terminx 1025
        char *semi = Bstrchr(cp, ';');
3126 helixhorne 1026
 
7147 terminx 1027
        if (semi)
1028
            *semi = 0;
3126 helixhorne 1029
 
7147 terminx 1030
        j = CONFIG_FunctionNameToNum(cp);
3126 helixhorne 1031
 
7147 terminx 1032
        if (semi)
1033
            cp = semi+1;
3126 helixhorne 1034
 
7147 terminx 1035
        if (j != -1)
1036
        {
1037
            ud.config.KeyboardKeys[j][1] = ud.config.KeyboardKeys[j][0];
7179 terminx 1038
            ud.config.KeyboardKeys[j][0] = sctokeylut[i].sc;
1039
//            CONTROL_MapKey(j, sctokeylut[i].sc, ud.config.KeyboardKeys[j][0]);
3128 terminx 1040
 
7147 terminx 1041
            if (j == gamefunc_Show_Console)
7179 terminx 1042
                OSD_CaptureKey(sctokeylut[i].sc);
1632 terminx 1043
        }
1044
    }
1045
 
843 terminx 1046
    if (!OSD_ParsingScript())
814 terminx 1047
        OSD_Printf("%s\n",parm->raw);
1625 terminx 1048
 
591 plagman 1049
    return OSDCMD_OK;
1050
}
1051
 
7154 terminx 1052
static int osdcmd_unbindall(osdcmdptr_t UNUSED(parm))
821 terminx 1053
{
6297 terminx 1054
    UNREFERENCED_CONST_PARAMETER(parm);
821 terminx 1055
 
7147 terminx 1056
    for (int i = 0; i < MAXBOUNDKEYS; ++i)
3209 helixhorne 1057
        CONTROL_FreeKeyBind(i);
1632 terminx 1058
 
7147 terminx 1059
    for (int i = 0; i < MAXMOUSEBUTTONS; ++i)
3209 helixhorne 1060
        CONTROL_FreeMouseBind(i);
1632 terminx 1061
 
7147 terminx 1062
    for (auto &KeyboardKey : ud.config.KeyboardKeys)
1063
        KeyboardKey[0] = KeyboardKey[1] = 0xff;
1632 terminx 1064
 
1065
    if (!OSD_ParsingScript())
1066
        OSD_Printf("unbound all controls\n");
1067
 
821 terminx 1068
    return OSDCMD_OK;
1069
}
1070
 
7154 terminx 1071
static int osdcmd_unbind(osdcmdptr_t parm)
810 terminx 1072
{
7147 terminx 1073
    if (parm->numparms != 1)
1074
        return OSDCMD_SHOWHELP;
810 terminx 1075
 
8041 hendricks2 1076
    for (auto & ConsoleKey : sctokeylut)
7147 terminx 1077
    {
7179 terminx 1078
        if (ConsoleKey.key && !Bstrcasecmp(parm->parms[0], ConsoleKey.key))
7147 terminx 1079
        {
7179 terminx 1080
            CONTROL_FreeKeyBind(ConsoleKey.sc);
1081
            OSD_Printf("unbound key %s\n", ConsoleKey.key);
7147 terminx 1082
            return OSDCMD_OK;
1083
        }
1084
    }
1632 terminx 1085
 
7147 terminx 1086
    for (int i = 0; i < MAXMOUSEBUTTONS; i++)
826 terminx 1087
    {
7147 terminx 1088
        if (!Bstrcasecmp(parm->parms[0], ConsoleButtons[i]))
1089
        {
1090
            CONTROL_FreeMouseBind(i);
1091
            OSD_Printf("unbound %s\n", ConsoleButtons[i]);
1092
            return OSDCMD_OK;
1093
        }
826 terminx 1094
    }
1632 terminx 1095
 
7147 terminx 1096
    return OSDCMD_SHOWHELP;
810 terminx 1097
}
1098
 
7442 terminx 1099
static int osdcmd_unbound(osdcmdptr_t parm)
1100
{
1101
    if (parm->numparms != 1)
1102
        return OSDCMD_OK;
1103
 
1104
    int const gameFunc = CONFIG_FunctionNameToNum(parm->parms[0]);
1105
 
1106
    if (gameFunc != -1)
1107
        ud.config.KeyboardKeys[gameFunc][0] = 0;
1108
 
1109
    return OSDCMD_OK;
1110
}
1111
 
7154 terminx 1112
static int osdcmd_quicksave(osdcmdptr_t UNUSED(parm))
821 terminx 1113
{
6297 terminx 1114
    UNREFERENCED_CONST_PARAMETER(parm);
821 terminx 1115
    if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
1116
        OSD_Printf("quicksave: not in a game.\n");
1143 terminx 1117
    else g_doQuickSave = 1;
821 terminx 1118
    return OSDCMD_OK;
1119
}
1120
 
7154 terminx 1121
static int osdcmd_quickload(osdcmdptr_t UNUSED(parm))
821 terminx 1122
{
6297 terminx 1123
    UNREFERENCED_CONST_PARAMETER(parm);
821 terminx 1124
    if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
1125
        OSD_Printf("quickload: not in a game.\n");
1143 terminx 1126
    else g_doQuickSave = 2;
821 terminx 1127
    return OSDCMD_OK;
1128
}
1129
 
7154 terminx 1130
static int osdcmd_screenshot(osdcmdptr_t parm)
834 terminx 1131
{
836 terminx 1132
//    KB_ClearKeysDown();
6268 terminx 1133
#ifndef EDUKE32_STANDALONE
6365 terminx 1134
    static const char *fn = "duke0000.png";
6121 terminx 1135
#else
6365 terminx 1136
    static const char *fn = "capt0000.png";
6121 terminx 1137
#endif
6365 terminx 1138
 
1139
    if (parm->numparms == 1 && !Bstrcasecmp(parm->parms[0], "tga"))
6831 terminx 1140
        videoCaptureScreenTGA(fn, 0);
1141
    else videoCaptureScreen(fn, 0);
6365 terminx 1142
 
834 terminx 1143
    return OSDCMD_OK;
1144
}
1145
 
3892 helixhorne 1146
#if 0
7154 terminx 1147
static int osdcmd_savestate(osdcmdptr_t UNUSED(parm))
859 terminx 1148
{
1149
    UNREFERENCED_PARAMETER(parm);
3792 helixhorne 1150
    G_SaveMapState();
859 terminx 1151
    return OSDCMD_OK;
1152
}
1153
 
7154 terminx 1154
static int osdcmd_restorestate(osdcmdptr_t UNUSED(parm))
859 terminx 1155
{
1156
    UNREFERENCED_PARAMETER(parm);
3792 helixhorne 1157
    G_RestoreMapState();
859 terminx 1158
    return OSDCMD_OK;
1159
}
3791 helixhorne 1160
#endif
859 terminx 1161
 
1852 helixhorne 1162
#ifdef DEBUGGINGAIDS
7154 terminx 1163
static int osdcmd_inittimer(osdcmdptr_t parm)
1121 terminx 1164
{
1165
    if (parm->numparms != 1)
1166
    {
1143 terminx 1167
        OSD_Printf("%dHz timer\n",g_timerTicsPerSecond);
1121 terminx 1168
        return OSDCMD_SHOWHELP;
1169
    }
1170
 
3485 helixhorne 1171
    G_InitTimer(Batol(parm->parms[0]));
1121 terminx 1172
 
1173
    OSD_Printf("%s\n",parm->raw);
1174
    return OSDCMD_OK;
1175
}
1852 helixhorne 1176
#endif
1121 terminx 1177
 
6736 terminx 1178
#if !defined NETCODE_DISABLE
7444 terminx 1179
static int osdcmd_name(osdcmdptr_t parm)
1180
{
1181
    char namebuf[32];
1182
 
1183
    if (parm->numparms != 1)
1184
    {
1185
        OSD_Printf("\"name\" is \"%s\"\n",szPlayerName);
1186
        return OSDCMD_SHOWHELP;
1187
    }
1188
 
1189
    Bstrcpy(tempbuf,parm->parms[0]);
1190
 
1191
    while (Bstrlen(OSD_StripColors(namebuf,tempbuf)) > 10)
1192
        tempbuf[Bstrlen(tempbuf)-1] = '\0';
1193
 
1194
    Bstrncpy(szPlayerName,tempbuf,sizeof(szPlayerName)-1);
1195
    szPlayerName[sizeof(szPlayerName)-1] = '\0';
1196
 
1197
    OSD_Printf("name %s\n",szPlayerName);
1198
 
1199
    Net_SendClientInfo();
1200
 
1201
    return OSDCMD_OK;
1202
}
1203
 
7445 terminx 1204
static int osdcmd_dumpmapstate(osdfuncparm_t const * const)
7444 terminx 1205
{
1206
    // this command takes no parameters
1207
 
1208
    DumpMapStateHistory();
1209
 
1210
    return OSDCMD_OK;
1211
}
1212
 
7445 terminx 1213
static int osdcmd_playerinfo(osdfuncparm_t const * const)
7444 terminx 1214
{
1215
    OSD_Printf("Your player index is %d.\n", myconnectindex);
1216
 
1217
    for(int32_t playerIndex = 0; playerIndex < MAXPLAYERS; playerIndex++)
1218
    {
1219
        if(g_player[playerIndex].ps == nullptr)
1220
        {
1221
            OSD_Printf("g_player[%d]: ps unallocated.\n", playerIndex);
1222
        }
1223
        else
1224
        {
1225
            OSD_Printf("g_player[%d]: ps->i is %d.\n", playerIndex, g_player[playerIndex].ps->i);
1226
        }
1227
    }
1228
 
1229
    return OSDCMD_OK;
1230
}
1231
 
7154 terminx 1232
static int osdcmd_disconnect(osdcmdptr_t UNUSED(parm))
1567 terminx 1233
{
6297 terminx 1234
    UNREFERENCED_CONST_PARAMETER(parm);
1570 terminx 1235
    g_netDisconnect = 1;
1567 terminx 1236
    return OSDCMD_OK;
1237
}
1238
 
7154 terminx 1239
static int osdcmd_connect(osdcmdptr_t parm)
1567 terminx 1240
{
1241
    if (parm->numparms != 1)
1242
        return OSDCMD_SHOWHELP;
1243
 
1244
    Net_Connect(parm->parms[0]);
1245
    G_BackToMenu();
1246
    return OSDCMD_OK;
1247
}
1248
 
7154 terminx 1249
static int osdcmd_password(osdcmdptr_t parm)
1571 terminx 1250
{
1251
    if (parm->numparms < 1)
1252
    {
1587 terminx 1253
        Bmemset(g_netPassword, 0, sizeof(g_netPassword));
1571 terminx 1254
        return OSDCMD_OK;
1255
    }
5539 terminx 1256
    Bstrncpy(g_netPassword, (parm->raw) + 9, sizeof(g_netPassword)-1);
1571 terminx 1257
 
1258
    return OSDCMD_OK;
1259
}
1260
 
7154 terminx 1261
static int osdcmd_listplayers(osdcmdptr_t parm)
1572 terminx 1262
{
1677 terminx 1263
    ENetPeer *currentPeer;
1573 terminx 1264
    char ipaddr[32];
1572 terminx 1265
 
1802 terminx 1266
    if (parm && parm->numparms != 0)
1572 terminx 1267
        return OSDCMD_SHOWHELP;
1268
 
1587 terminx 1269
    if (!g_netServer)
1572 terminx 1270
    {
1271
        initprintf("You are not the server.\n");
1272
        return OSDCMD_OK;
1273
    }
1274
 
1802 terminx 1275
    initprintf("Connected clients:\n");
1276
 
1587 terminx 1277
    for (currentPeer = g_netServer -> peers;
1593 terminx 1278
            currentPeer < & g_netServer -> peers [g_netServer -> peerCount];
1279
            ++ currentPeer)
1572 terminx 1280
    {
1281
        if (currentPeer -> state != ENET_PEER_STATE_CONNECTED)
1282
            continue;
1283
 
1573 terminx 1284
        enet_address_get_host_ip(&currentPeer->address, ipaddr, sizeof(ipaddr));
8176 terminx 1285
        initprintf("%s %s\n", ipaddr, g_player[(intptr_t)currentPeer->data].user_name);
1572 terminx 1286
    }
4233 helixhorne 1287
 
1572 terminx 1288
    return OSDCMD_OK;
1289
}
1290
 
8175 terminx 1291
#if 0
7154 terminx 1292
static int osdcmd_kick(osdcmdptr_t parm)
1573 terminx 1293
{
1677 terminx 1294
    ENetPeer *currentPeer;
1573 terminx 1295
    uint32_t hexaddr;
1296
 
1297
    if (parm->numparms != 1)
1298
        return OSDCMD_SHOWHELP;
1299
 
1587 terminx 1300
    if (!g_netServer)
1573 terminx 1301
    {
1302
        initprintf("You are not the server.\n");
1303
        return OSDCMD_OK;
1304
    }
1305
 
1587 terminx 1306
    for (currentPeer = g_netServer -> peers;
1593 terminx 1307
            currentPeer < & g_netServer -> peers [g_netServer -> peerCount];
1308
            ++ currentPeer)
1573 terminx 1309
    {
1310
        if (currentPeer -> state != ENET_PEER_STATE_CONNECTED)
1311
            continue;
1312
 
1791 helixhorne 1313
        sscanf(parm->parms[0],"%" SCNx32 "", &hexaddr);
1573 terminx 1314
 
1315
        if (currentPeer->address.host == hexaddr)
1316
        {
1317
            initprintf("Kicking %x (%s)\n", currentPeer->address.host,
1593 terminx 1318
                       g_player[(intptr_t)currentPeer->data].user_name);
1319
            enet_peer_disconnect(currentPeer, DISC_KICKED);
1573 terminx 1320
            return OSDCMD_OK;
1321
        }
1322
    }
1323
 
1324
    initprintf("Player %s not found!\n", parm->parms[0]);
1802 terminx 1325
    osdcmd_listplayers(NULL);
4233 helixhorne 1326
 
1573 terminx 1327
    return OSDCMD_OK;
1328
}
1329
 
7154 terminx 1330
static int osdcmd_kickban(osdcmdptr_t parm)
1573 terminx 1331
{
1677 terminx 1332
    ENetPeer *currentPeer;
1573 terminx 1333
    uint32_t hexaddr;
1334
 
1335
    if (parm->numparms != 1)
1336
        return OSDCMD_SHOWHELP;
1337
 
1587 terminx 1338
    if (!g_netServer)
1573 terminx 1339
    {
1340
        initprintf("You are not the server.\n");
1341
        return OSDCMD_OK;
1342
    }
1343
 
1587 terminx 1344
    for (currentPeer = g_netServer -> peers;
1593 terminx 1345
            currentPeer < & g_netServer -> peers [g_netServer -> peerCount];
1346
            ++ currentPeer)
1573 terminx 1347
    {
1348
        if (currentPeer -> state != ENET_PEER_STATE_CONNECTED)
1349
            continue;
1350
 
1791 helixhorne 1351
        sscanf(parm->parms[0],"%" SCNx32 "", &hexaddr);
1677 terminx 1352
 
1632 terminx 1353
        // TODO: implement banning logic
1573 terminx 1354
 
1355
        if (currentPeer->address.host == hexaddr)
1356
        {
1357
            char ipaddr[32];
1358
 
1359
            enet_address_get_host_ip(&currentPeer->address, ipaddr, sizeof(ipaddr));
1360
            initprintf("Host %s is now banned.\n", ipaddr);
1361
            initprintf("Kicking %x (%s)\n", currentPeer->address.host,
1593 terminx 1362
                       g_player[(intptr_t)currentPeer->data].user_name);
1363
            enet_peer_disconnect(currentPeer, DISC_BANNED);
1573 terminx 1364
            return OSDCMD_OK;
1365
        }
1366
    }
1367
 
1368
    initprintf("Player %s not found!\n", parm->parms[0]);
1802 terminx 1369
    osdcmd_listplayers(NULL);
4233 helixhorne 1370
 
1573 terminx 1371
    return OSDCMD_OK;
1372
}
4233 helixhorne 1373
#endif
8175 terminx 1374
#endif
1573 terminx 1375
 
7154 terminx 1376
static int osdcmd_purgesaves(osdcmdptr_t UNUSED(parm))
6749 hendricks2 1377
{
1378
    UNREFERENCED_CONST_PARAMETER(parm);
1379
    G_DeleteOldSaves();
1380
    return OSDCMD_OK;
1381
}
1382
 
7154 terminx 1383
static int osdcmd_printtimes(osdcmdptr_t UNUSED(parm))
6736 terminx 1384
{
1385
    UNREFERENCED_CONST_PARAMETER(parm);
1386
 
1387
    char buf[32];
1388
    int32_t maxlen = 0;
1389
    int32_t haveev=0, haveac=0;
7153 terminx 1390
    static char const s_event_[] = "EVENT_";
1391
    int constexpr strlen_event_  = ARRAY_SIZE(s_event_) - 1;
6736 terminx 1392
 
7153 terminx 1393
    for (auto & EventName : EventNames)
6736 terminx 1394
    {
7153 terminx 1395
        int const len = Bstrlen(EventName+strlen_event_);
7165 terminx 1396
        Bassert(len < ARRAY_SSIZE(buf));
6736 terminx 1397
        maxlen = max(len, maxlen);
1398
    }
1399
 
1400
    for (int i=0; i<MAXEVENTS; i++)
1401
        if (g_eventCalls[i])
1402
        {
7153 terminx 1403
            int32_t n=Bsprintf(buf, "%s", EventNames[i]+strlen_event_);
6736 terminx 1404
 
1405
            if (!haveev)
1406
            {
1407
                haveev = 1;
6753 terminx 1408
                OSD_Printf("\nevent times: event, total calls, total time [ms], mean time/call [us]\n");
6736 terminx 1409
            }
1410
 
6737 terminx 1411
            buf[n] = 0;
6736 terminx 1412
 
6753 terminx 1413
            OSD_Printf("%17s, %8d, %10.3f, %10.3f,\n",
6736 terminx 1414
                buf, g_eventCalls[i], g_eventTotalMs[i],
1415
                1000*g_eventTotalMs[i]/g_eventCalls[i]);
1416
        }
1417
 
1418
    for (int i=0; i<MAXTILES; i++)
1419
        if (g_actorCalls[i])
1420
        {
1421
            if (!haveac)
1422
            {
1423
                haveac = 1;
6753 terminx 1424
                OSD_Printf("\nactor times: tile, total calls, total time [ms], {min,mean,max} time/call [us]\n");
6736 terminx 1425
            }
1426
 
1427
            buf[0] = 0;
1428
 
1429
            for (int ii=0; ii<g_labelCnt; ii++)
1430
            {
6737 terminx 1431
                if (labelcode[ii] == i && labeltype[ii] & LABEL_ACTOR)
6736 terminx 1432
                {
1433
                    Bstrcpy(buf, label+(ii<<6));
1434
                    break;
1435
                }
1436
            }
1437
 
6737 terminx 1438
            if (!buf[0]) Bsprintf(buf, "%d", i);
6736 terminx 1439
 
6753 terminx 1440
            OSD_Printf("%17s, %8d, %9.3f, %9.3f, %9.3f, %9.3f,\n",
6736 terminx 1441
                buf, g_actorCalls[i], g_actorTotalMs[i],
1442
                1000*g_actorMinMs[i],
1443
                1000*g_actorTotalMs[i]/g_actorCalls[i],
1444
                1000*g_actorMaxMs[i]);
1445
        }
1446
 
1447
    return OSDCMD_OK;
1448
}
1449
 
7154 terminx 1450
static int osdcmd_cvar_set_game(osdcmdptr_t parm)
1355 terminx 1451
{
7153 terminx 1452
    int const r = osdcmd_cvar_set(parm);
1355 terminx 1453
 
1632 terminx 1454
    if (r != OSDCMD_OK) return r;
1455
 
6939 pogokeen 1456
    if (!Bstrcasecmp(parm->name, "r_upscalefactor"))
1355 terminx 1457
    {
6939 pogokeen 1458
        if (in3dmode())
1459
        {
1460
            videoSetGameMode(fullscreen, xres, yres, bpp, ud.detail);
1461
        }
1462
    }
1463
    else if (!Bstrcasecmp(parm->name, "r_size"))
1464
    {
3402 helixhorne 1465
        ud.statusbarmode = (ud.screen_size < 8);
1466
        G_UpdateScreenArea();
1467
    }
1632 terminx 1468
    else if (!Bstrcasecmp(parm->name, "r_ambientlight"))
1469
    {
1652 terminx 1470
        if (r_ambientlight == 0)
1471
            r_ambientlightrecip = 256.f;
1472
        else r_ambientlightrecip = 1.f/r_ambientlight;
1632 terminx 1473
    }
1474
    else if (!Bstrcasecmp(parm->name, "in_mouse"))
1475
    {
7219 terminx 1476
        CONTROL_MouseEnabled = (ud.setup.usemouse && CONTROL_MousePresent);
1632 terminx 1477
    }
1478
    else if (!Bstrcasecmp(parm->name, "in_joystick"))
1479
    {
7219 terminx 1480
        CONTROL_JoystickEnabled = (ud.setup.usejoystick && CONTROL_JoyPresent);
1632 terminx 1481
    }
1482
    else if (!Bstrcasecmp(parm->name, "vid_gamma"))
1483
    {
1665 terminx 1484
        ud.brightness = GAMMA_CALC;
1632 terminx 1485
        ud.brightness <<= 2;
6829 terminx 1486
        videoSetPalette(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
1632 terminx 1487
    }
2639 helixhorne 1488
    else if (!Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast"))
1632 terminx 1489
    {
6829 terminx 1490
        videoSetPalette(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
1632 terminx 1491
    }
3675 hendricks2 1492
    else if (!Bstrcasecmp(parm->name, "hud_scale")
1493
             || !Bstrcasecmp(parm->name, "hud_statusbarmode")
1494
             || !Bstrcasecmp(parm->name, "r_rotatespritenowidescreen"))
1632 terminx 1495
    {
1496
        G_UpdateScreenArea();
1497
    }
1498
    else if (!Bstrcasecmp(parm->name, "skill"))
1499
    {
1500
        if (numplayers > 1)
1355 terminx 1501
            return r;
1502
 
1857 terminx 1503
        ud.player_skill = ud.m_player_skill;
1355 terminx 1504
    }
1635 terminx 1505
    else if (!Bstrcasecmp(parm->name, "color"))
1506
    {
7133 terminx 1507
        ud.color = G_CheckPlayerColor(ud.color);
1635 terminx 1508
        g_player[0].ps->palookup = g_player[0].pcolor = ud.color;
1509
    }
4425 terminx 1510
    else if (!Bstrcasecmp(parm->name, "osdscale"))
1511
    {
4649 terminx 1512
        osdrscale = 1.f/osdscale;
1513
 
4425 terminx 1514
        if (xdim && ydim)
1515
            OSD_ResizeDisplay(xdim, ydim);
5065 terminx 1516
    }
1517
    else if (!Bstrcasecmp(parm->name, "wchoice"))
1518
    {
1519
        if (parm->numparms == 1)
1520
        {
1521
            if (g_forceWeaponChoice) // rewrite ud.wchoice because osdcmd_cvar_set already changed it
1522
            {
1523
                int j = 0;
1635 terminx 1524
 
5065 terminx 1525
                while (j < 10)
1526
                {
1527
                    ud.wchoice[j] = g_player[myconnectindex].wchoice[j] + '0';
1528
                    j++;
1529
                }
1530
 
1531
                ud.wchoice[j] = 0;
1532
            }
1533
            else
1534
            {
1535
                char const *c = parm->parms[0];
1536
 
1537
                if (*c)
1538
                {
1539
                    int j = 0;
1540
 
1541
                    while (*c && j < 10)
1542
                    {
1543
                        g_player[myconnectindex].wchoice[j] = *c - '0';
1544
                        c++;
1545
                        j++;
1546
                    }
1547
 
1548
                    while (j < 10)
1549
                    {
1550
                        if (j == 9)
1551
                            g_player[myconnectindex].wchoice[9] = 1;
1552
                        else
1553
                            g_player[myconnectindex].wchoice[j] = 2;
1554
 
1555
                        j++;
1556
                    }
1557
                }
1558
            }
1559
 
1560
            g_forceWeaponChoice = 0;
1561
        }
1562
 
1563
        /*    Net_SendClientInfo();*/
4425 terminx 1564
    }
1565
 
1355 terminx 1566
    return r;
1567
}
1568
 
7154 terminx 1569
static int osdcmd_cvar_set_multi(osdcmdptr_t parm)
1635 terminx 1570
{
7153 terminx 1571
    int const r = osdcmd_cvar_set_game(parm);
1635 terminx 1572
 
1573
    if (r != OSDCMD_OK) return r;
1574
 
1575
    G_UpdatePlayerFromMenu();
1576
 
1577
    return r;
1578
}
1579
 
8407 terminx 1580
#define CVAR_BOOL_OPTSTR ":\n 0: disabled\n 1: enabled"
1581
 
1205 terminx 1582
int32_t registerosdcommands(void)
5 Plagman 1583
{
8390 terminx 1584
    FX_InitCvars();
1585
 
6297 terminx 1586
    static osdcvardata_t cvars_game[] =
335 terminx 1587
    {
8407 terminx 1588
        { "benchmarkmode", "benchmark mode:\n 0: off\n 1: performance test\n 2: generate reference screenshots for correctness testing", (void *) &g_BenchmarkMode, CVAR_INT|CVAR_NOSAVE, 0, 2 },
7729 pogokeen 1589
 
8407 terminx 1590
        { "crosshair", "display crosshair" CVAR_BOOL_OPTSTR, (void *)&ud.crosshair, CVAR_BOOL, 0, 1 },
1352 terminx 1591
 
8407 terminx 1592
        { "cl_autoaim", "weapon autoaim:\n 0: none\n 1: hitscan only\n 2: projectiles only\n 3: everything", (void *)&ud.config.AutoAim, CVAR_INT|CVAR_MULTI, 0, 3 },
1593
        { "cl_autorun", "player autorun" CVAR_BOOL_OPTSTR, (void *)&ud.auto_run, CVAR_BOOL, 0, 1 },
6941 terminx 1594
 
8407 terminx 1595
        { "cl_autosave", "save game at checkpoints" CVAR_BOOL_OPTSTR, (void *) &ud.autosave, CVAR_BOOL, 0, 1 },
1596
        { "cl_autosavedeletion", "automatically delete old checkpoint saves" CVAR_BOOL_OPTSTR, (void *) &ud.autosavedeletion, CVAR_BOOL, 0, 1 },
1597
        { "cl_maxautosaves", "number of autosaves kept before deleting the oldest", (void *) &ud.maxautosaves, CVAR_INT, 1, 100 },
6941 terminx 1598
 
8407 terminx 1599
#if !defined NETCODE_DISABLE
1600
        { "cl_automsg", "automatically send messages to all players" CVAR_BOOL_OPTSTR, (void *)&ud.automsg, CVAR_BOOL, 0, 1 },
1601
        { "cl_autovote", "automatic vote yes for multiplayer map changes" CVAR_BOOL_OPTSTR, (void *)&ud.autovote, CVAR_BOOL, 0, 1 },
1602
        { "cl_obituaries", "print player death messages in multiplayer" CVAR_BOOL_OPTSTR, (void *)&ud.obituaries, CVAR_BOOL, 0, 1 },
1603
        { "cl_idplayers", "display player names when aiming at opponents in multiplayer" CVAR_BOOL_OPTSTR, (void *)&ud.idplayers, CVAR_BOOL, 0, 1 },
1604
#endif
1352 terminx 1605
 
8407 terminx 1606
        { "cl_cheatmask", "bitmask controlling cheats unlocked in menu", (void *)&cl_cheatmask, CVAR_UINT, 0, ~0 },
1607
        { "cl_democams", "third-person cameras in demos" CVAR_BOOL_OPTSTR, (void *)&ud.democams, CVAR_BOOL, 0, 1 },
1608
        { "cl_runmode", "run key behavior with cl_autorun enabled:\n 0: walk\n 1: do nothing", (void *)&ud.runkey_mode, CVAR_BOOL, 0, 1 },
5084 hendricks2 1609
 
8407 terminx 1610
        { "cl_showcoords", "DEBUG: coordinate display", (void *)&ud.coords, CVAR_INT, 0,
4410 helixhorne 1611
#ifdef USE_OPENGL
1612
          2
1613
#else
1614
          1
1615
#endif
1616
        },
1352 terminx 1617
 
8407 terminx 1618
        { "cl_viewbob", "player head bobbing" CVAR_BOOL_OPTSTR, (void *)&ud.viewbob, CVAR_BOOL, 0, 1 },
1352 terminx 1619
 
8407 terminx 1620
        { "cl_weaponsway", "weapon sways when moving" CVAR_BOOL_OPTSTR, (void *)&ud.weaponsway, CVAR_BOOL, 0, 1 },
1621
        { "cl_weaponswitch", "bitmask controlling switching weapon when out of ammo or a new weapon is picked up:\n 0: disabled\n 1: if new\n 2: if empty\n 4: determined by wchoice", (void *)&ud.weaponswitch, CVAR_INT|CVAR_MULTI, 0, 7 },
1352 terminx 1622
 
8407 terminx 1623
        { "color", "player palette", (void *)&ud.color, CVAR_INT|CVAR_MULTI, 0, MAXPALOOKUPS-1 },
1352 terminx 1624
 
8407 terminx 1625
        { "crosshairscale","crosshair size", (void *)&ud.crosshairscale, CVAR_INT, 10, 100 },
1635 terminx 1626
 
8407 terminx 1627
        { "demorec_diffs","differential recording in demos" CVAR_BOOL_OPTSTR,(void *)&demorec_diffs_cvar, CVAR_BOOL, 0, 1 },
1628
        { "demorec_force","forced demo recording" CVAR_BOOL_OPTSTR,(void *)&demorec_force_cvar, CVAR_BOOL|CVAR_NOSAVE, 0, 1 },
1677 terminx 1629
        {
3783 terminx 1630
            "demorec_difftics","sets game tic interval after which a diff is recorded",
3007 helixhorne 1631
            (void *)&demorec_difftics_cvar, CVAR_INT, 2, 60*REALGAMETICSPERSEC
1677 terminx 1632
        },
7651 terminx 1633
        { "demorec_diffcompress","Compression method for diffs. (0: none, 1: KSLZW)",(void *)&demorec_diffcompress_cvar, CVAR_BOOL, 0, 1 },
1634
        { "demorec_synccompress","Compression method for input. (0: none, 1: KSLZW)",(void *)&demorec_synccompress_cvar, CVAR_BOOL, 0, 1 },
8407 terminx 1635
        { "demorec_seeds","record random seed for later sync checking" CVAR_BOOL_OPTSTR,(void *)&demorec_seeds_cvar, CVAR_BOOL, 0, 1 },
1636
        { "demoplay_diffs","use diffs in demo playback" CVAR_BOOL_OPTSTR,(void *)&demoplay_diffs, CVAR_BOOL, 0, 1 },
1637
        { "demoplay_showsync","enables display of sync status",(void *)&demoplay_showsync, CVAR_BOOL, 0, 1 },
1352 terminx 1638
 
8068 terminx 1639
        { "fov", "change the field of view", (void *)&ud.fov, CVAR_INT, 60, 140 },
7329 terminx 1640
 
8407 terminx 1641
        { "hud_althud", "alternate mini-hud" CVAR_BOOL_OPTSTR, (void *)&ud.althud, CVAR_BOOL, 0, 1 },
6627 hendricks2 1642
        { "hud_custom", "change the custom hud", (void *)&ud.statusbarcustom, CVAR_INT, 0, ud.statusbarrange },
8407 terminx 1643
        { "hud_position", "align status bar to top of screen" CVAR_BOOL_OPTSTR, (void *)&ud.hudontop, CVAR_BOOL, 0, 1 },
1644
        { "hud_bgstretch", "stretch background images to fill screen" CVAR_BOOL_OPTSTR, (void *)&ud.bgstretch, CVAR_BOOL, 0, 1 },
3783 terminx 1645
        { "hud_messagetime", "length of time to display multiplayer chat messages", (void *)&ud.msgdisptime, CVAR_INT, 0, 3600 },
5589 hendricks2 1646
        { "hud_numbertile", "first tile in alt hud number set", (void *)&althud_numbertile, CVAR_INT, 0, MAXUSERTILES-10 },
1647
        { "hud_numberpal", "pal for alt hud numbers", (void *)&althud_numberpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
8407 terminx 1648
        { "hud_shadows", "display shadows under HUD elements" CVAR_BOOL_OPTSTR, (void *)&althud_shadows, CVAR_BOOL, 0, 1 },
1649
        { "hud_flashing", "health flashes in HUD when player is near death" CVAR_BOOL_OPTSTR, (void *)&althud_flashing, CVAR_BOOL, 0, 1 },
1650
        { "hud_glowingquotes", "\"glowing\" on-screen messages" CVAR_BOOL_OPTSTR, (void *)&hud_glowingquotes, CVAR_BOOL, 0, 1 },
8071 terminx 1651
        { "hud_scale","changes the hud scale", (void *)&ud.statusbarscale, CVAR_INT|CVAR_FUNCPTR, 50, 100 },
8407 terminx 1652
        { "hud_showmapname", "display level or map name on load" CVAR_BOOL_OPTSTR, (void *)&hud_showmapname, CVAR_BOOL, 0, 1 },
1653
        { "hud_stats", "on-screen display of level time, secrets found, and enemies killed" CVAR_BOOL_OPTSTR, (void *)&ud.levelstats, CVAR_BOOL, 0, 1 },
1654
        { "hud_textscale", "multiplayer chat message size", (void *)&ud.textscale, CVAR_INT, 100, 400 },
1655
        { "hud_weaponscale","weapon scale", (void *)&ud.weaponscale, CVAR_INT, 10, 100 },
1656
        { "hud_statusbarmode", "status bar draws over player view" CVAR_BOOL_OPTSTR, (void *)&ud.statusbarmode, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
1352 terminx 1657
 
4993 terminx 1658
#ifdef EDUKE32_TOUCH_DEVICES
1659
        { "hud_hidestick", "hide the touch input stick", (void *)&droidinput.hideStick, CVAR_BOOL, 0, 1 },
1660
#endif
1661
 
8407 terminx 1662
        { "in_joystick","use joystick or controller input" CVAR_BOOL_OPTSTR,(void *)&ud.setup.usejoystick, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
1663
        { "in_mouse","use mouse input" CVAR_BOOL_OPTSTR,(void *)&ud.setup.usemouse, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
1352 terminx 1664
 
8407 terminx 1665
        { "in_aimmode", "DEPRECATED: hold button for mouse aim" CVAR_BOOL_OPTSTR, (void *)&ud.mouseaiming, CVAR_BOOL, 0, 1 },
1666
        { "in_mousemode", "DEPRECATED: vertical mouse aiming" CVAR_BOOL_OPTSTR, (void *)&g_myAimMode, CVAR_BOOL, 0, 1 },
1667
 
1677 terminx 1668
        {
3783 terminx 1669
            "in_mousebias", "emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time",
1677 terminx 1670
            (void *)&ud.config.MouseBias, CVAR_INT, 0, 32
1671
        },
8776 terminx 1672
 
8407 terminx 1673
        { "in_mouseflip", "invert vertical mouse movement" CVAR_BOOL_OPTSTR, (void *)&ud.mouseflip, CVAR_BOOL, 0, 1 },
1352 terminx 1674
 
8776 terminx 1675
        { "in_mousexscale", "scale modifier for mouse x axis", (void *)&CONTROL_MouseAxesScale[0], CVAR_INT, 1, 65536 },
1676
        { "in_mouseyscale", "scale modifier for mouse y axis", (void *)&CONTROL_MouseAxesScale[1], CVAR_INT, 1, 65536 },
1677
 
8407 terminx 1678
        { "mus_enabled", "music subsystem" CVAR_BOOL_OPTSTR, (void *)&ud.config.MusicToggle, CVAR_BOOL, 0, 1 },
8216 terminx 1679
        { "mus_device", "music device", (void*)& ud.config.MusicDevice, CVAR_INT, 0, ASS_NumSoundCards },
4800 helixhorne 1680
        { "mus_volume", "controls music volume", (void *)&ud.config.MusicVolume, CVAR_INT, 0, 255 },
1352 terminx 1681
 
8407 terminx 1682
        { "osdhightile", "use content pack assets for console text if available" CVAR_BOOL_OPTSTR, (void *)&osdhightile, CVAR_BOOL, 0, 1 },
1683
        { "osdscale", "console text size", (void *)&osdscale, CVAR_FLOAT|CVAR_FUNCPTR, 1, 4 },
1635 terminx 1684
 
4445 terminx 1685
        { "r_camrefreshdelay", "minimum delay between security camera sprite updates, 120 = 1 second", (void *)&ud.camera_time, CVAR_INT, 1, 240 },
8407 terminx 1686
        { "r_drawweapon", "draw player weapon" CVAR_BOOL_OPTSTR "\n 2: icon only", (void *)&ud.drawweapon, CVAR_INT, 0, 2 },
1687
        { "r_showfps", "show the frame rate counter" CVAR_BOOL_OPTSTR "\n 2: extra timing data\n 3: excessive timing data", (void *)&ud.showfps, CVAR_INT, 0, 3 },
7308 terminx 1688
        { "r_showfpsperiod", "time in seconds before averaging min and max stats for r_showfps 2+", (void *)&ud.frameperiod, CVAR_INT, 0, 5 },
8407 terminx 1689
        { "r_shadows", "in-game entities cast simple shadows" CVAR_BOOL_OPTSTR, (void *)&ud.shadows, CVAR_BOOL, 0, 1 },
3783 terminx 1690
        { "r_size", "change size of viewable area", (void *)&ud.screen_size, CVAR_INT|CVAR_FUNCPTR, 0, 64 },
1691
        { "r_rotatespritenowidescreen", "pass bit 1024 to all CON rotatesprite calls", (void *)&g_rotatespriteNoWidescreen, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
6939 pogokeen 1692
        { "r_upscalefactor", "increase performance by rendering at upscalefactor less than the screen resolution and upscale to the full resolution in the software renderer", (void *)&ud.detail, CVAR_INT|CVAR_FUNCPTR, 1, 16 },
8407 terminx 1693
        { "r_precache", "precache art assets during level load" CVAR_BOOL_OPTSTR, (void *)&ud.config.useprecache, CVAR_BOOL, 0, 1 },
1352 terminx 1694
 
3783 terminx 1695
        { "r_ambientlight", "sets the global map light level",(void *)&r_ambientlight, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
1540 terminx 1696
 
3783 terminx 1697
        { "sensitivity","changes the mouse sensitivity", (void *)&CONTROL_MouseSensitivity, CVAR_FLOAT|CVAR_FUNCPTR, 0, 25 },
1352 terminx 1698
 
6670 terminx 1699
        { "skill","changes the game skill setting", (void *)&ud.m_player_skill, CVAR_INT|CVAR_FUNCPTR|CVAR_NOSAVE/*|CVAR_NOMULTI*/, 0, 5 },
1625 terminx 1700
 
8407 terminx 1701
        { "snd_ambience", "ambient sounds" CVAR_BOOL_OPTSTR, (void *)&ud.config.AmbienceToggle, CVAR_BOOL, 0, 1 },
1702
        { "snd_enabled", "sound effects" CVAR_BOOL_OPTSTR, (void *)&ud.config.SoundToggle, CVAR_BOOL, 0, 1 },
1703
        { "snd_fxvolume", "volume of sound effects", (void *)&ud.config.FXVolume, CVAR_INT, 0, 255 },
3783 terminx 1704
        { "snd_mixrate", "sound mixing rate", (void *)&ud.config.MixRate, CVAR_INT, 0, 48000 },
1705
        { "snd_numchannels", "the number of sound channels", (void *)&ud.config.NumChannels, CVAR_INT, 0, 2 },
8548 terminx 1706
        { "snd_numvoices", "the number of concurrent sounds", (void *)&ud.config.NumVoices, CVAR_INT, 1, MAXVOICES },
8480 hendricks2 1707
#ifdef ASS_REVERSESTEREO
1708
        { "snd_reversestereo", "reverses the stereo channels", (void *)&ud.config.ReverseStereo, CVAR_BOOL, 0, 1 },
1709
#endif
8407 terminx 1710
        { "snd_speech", "bitmask controlling player speech", (void *)&ud.config.VoiceToggle, CVAR_INT, 0, 5 },
8288 ny00123 1711
#ifdef FORMAT_UPGRADE_ELIGIBLE
8407 terminx 1712
        { "snd_tryformats", "discover and use replacement audio in .flac and .ogg formats if available" CVAR_BOOL_OPTSTR, (void *)&g_maybeUpgradeSoundFormats, CVAR_BOOL, 0, 1 },
8288 ny00123 1713
#endif
8407 terminx 1714
        { "team", "change team in multiplayer", (void *)&ud.team, CVAR_INT|CVAR_MULTI, 0, 3 },
1625 terminx 1715
 
4993 terminx 1716
#ifdef EDUKE32_TOUCH_DEVICES
5589 hendricks2 1717
        { "touch_sens_move_x","touch input sensitivity for moving forward/back", (void *)&droidinput.forward_sens, CVAR_FLOAT, 1, 9 },
5065 terminx 1718
        { "touch_sens_move_y","touch input sensitivity for strafing", (void *)&droidinput.strafe_sens, CVAR_FLOAT, 1, 9 },
1719
        { "touch_sens_look_x", "touch input sensitivity for turning left/right", (void *) &droidinput.yaw_sens, CVAR_FLOAT, 1, 9 },
1720
        { "touch_sens_look_y", "touch input sensitivity for looking up/down", (void *) &droidinput.pitch_sens, CVAR_FLOAT, 1, 9 },
7651 terminx 1721
        { "touch_invert", "invert look up/down touch input", (void *) &droidinput.invertLook, CVAR_BOOL, 0, 1 },
4993 terminx 1722
#endif
1723
 
8407 terminx 1724
        { "vid_gamma","gamma component of gamma ramp",(void *)&g_videoGamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
1725
        { "vid_contrast","contrast component of gamma ramp",(void *)&g_videoContrast, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
1726
        { "vid_brightness","brightness component of gamma ramp",(void *)&g_videoBrightness, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
1727
        { "wchoice","weapon priority for automatically switching on empty or pickup", (void *)ud.wchoice, CVAR_STRING|CVAR_FUNCPTR, 0, MAX_WEAPONS },
1352 terminx 1728
    };
1729
 
1357 terminx 1730
    osdcmd_cheatsinfo_stat.cheatnum = -1;
1731
 
7147 terminx 1732
    for (auto & cv : cvars_game)
1352 terminx 1733
    {
7147 terminx 1734
        switch (cv.flags & (CVAR_FUNCPTR|CVAR_MULTI))
1625 terminx 1735
        {
7147 terminx 1736
            case CVAR_FUNCPTR:
1737
                OSD_RegisterCvar(&cv, osdcmd_cvar_set_game); break;
1738
            case CVAR_MULTI:
1739
            case CVAR_FUNCPTR|CVAR_MULTI:
1740
                OSD_RegisterCvar(&cv, osdcmd_cvar_set_multi); break;
1741
            default:
1742
                OSD_RegisterCvar(&cv, osdcmd_cvar_set); break;
1625 terminx 1743
        }
5 Plagman 1744
    }
1745
 
7444 terminx 1746
#if !defined NETCODE_DISABLE
1747
    OSD_RegisterFunction("connect","connect: connects to a multiplayer game", osdcmd_connect);
1748
    OSD_RegisterFunction("disconnect","disconnect: disconnects from the local multiplayer game", osdcmd_disconnect);
1749
    OSD_RegisterFunction("dumpmapstates", "Dumps current snapshots to CL/Srv_MapStates.bin", osdcmd_dumpmapstate);
8175 terminx 1750
#if 0
7444 terminx 1751
    OSD_RegisterFunction("kick","kick <id>: kicks a multiplayer client.  See listplayers.", osdcmd_kick);
1752
    OSD_RegisterFunction("kickban","kickban <id>: kicks a multiplayer client and prevents them from reconnecting.  See listplayers.", osdcmd_kickban);
8175 terminx 1753
#endif
7444 terminx 1754
    OSD_RegisterFunction("listplayers","listplayers: lists currently connected multiplayer clients", osdcmd_listplayers);
1755
    OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name);
1756
    OSD_RegisterFunction("password","password: sets multiplayer game password", osdcmd_password);
1757
    OSD_RegisterFunction("playerinfo", "Prints information about the current player", osdcmd_playerinfo);
1758
#endif
1759
 
335 terminx 1760
    if (VOLUMEONE)
5 Plagman 1761
        OSD_RegisterFunction("changelevel","changelevel <level>: warps to the given level", osdcmd_changelevel);
335 terminx 1762
    else
1763
    {
5 Plagman 1764
        OSD_RegisterFunction("changelevel","changelevel <volume> <level>: warps to the given level", osdcmd_changelevel);
1112 hnt_ts 1765
        OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map);
3006 helixhorne 1766
        OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
5 Plagman 1767
    }
182 terminx 1768
 
1769
    OSD_RegisterFunction("addpath","addpath <path>: adds path to game filesystem", osdcmd_addpath);
7068 terminx 1770
    OSD_RegisterFunction("bind",R"(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);
5 Plagman 1771
    OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
1355 terminx 1772
    OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
1773
 
7147 terminx 1774
    for (auto & func : gamefunctions)
821 terminx 1775
    {
7147 terminx 1776
        if (func[0] == '\0')
6185 hendricks2 1777
            continue;
1778
 
3128 terminx 1779
//        if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue;
1143 terminx 1780
 
7147 terminx 1781
        Bsprintf(tempbuf, "gamefunc_%s", func);
1782
 
7153 terminx 1783
        char *const t = Bstrtolower(Xstrdup(tempbuf));
7147 terminx 1784
 
7153 terminx 1785
        Bstrcat(tempbuf, ": game button");
7147 terminx 1786
 
4491 helixhorne 1787
        OSD_RegisterFunction(t, Xstrdup(tempbuf), osdcmd_button);
821 terminx 1788
    }
1789
 
5 Plagman 1790
    OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
182 terminx 1791
    OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
6322 hendricks2 1792
    OSD_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);
8542 terminx 1793
    OSD_RegisterFunction("maxhealth", "maxhealth <amount>: sets the player's maximum health", osdcmd_maxhealth);
182 terminx 1794
 
1795
    OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile);
1852 helixhorne 1796
#ifdef DEBUGGINGAIDS
1797
    OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer);
1798
#endif
4587 helixhorne 1799
    OSD_RegisterFunction("music","music E<ep>L<lev>: change music", osdcmd_music);
6736 terminx 1800
 
5 Plagman 1801
    OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
1802
 
1571 terminx 1803
 
6736 terminx 1804
    OSD_RegisterFunction("printtimes", "printtimes: prints VM timing statistics", osdcmd_printtimes);
1805
 
6935 terminx 1806
    OSD_RegisterFunction("purgesaves", "purgesaves: deletes obsolete and unreadable save files", osdcmd_purgesaves);
1807
 
821 terminx 1808
    OSD_RegisterFunction("quicksave","quicksave: performs a quick save", osdcmd_quicksave);
1809
    OSD_RegisterFunction("quickload","quickload: performs a quick load", osdcmd_quickload);
182 terminx 1810
    OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit);
841 terminx 1811
    OSD_RegisterFunction("exit","exit: exits the game immediately", osdcmd_quit);
182 terminx 1812
 
5483 terminx 1813
    OSD_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);
627 terminx 1814
    OSD_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound);
1815
    OSD_RegisterFunction("restartvid","restartvid: reinitializes the video mode",osdcmd_restartvid);
3415 helixhorne 1816
#if !defined LUNATIC
892 hnt_ts 1817
    OSD_RegisterFunction("addlogvar","addlogvar <gamevar>: prints the value of a gamevar", osdcmd_addlogvar);
182 terminx 1818
    OSD_RegisterFunction("setvar","setvar <gamevar> <value>: sets the value of a gamevar", osdcmd_setvar);
1112 hnt_ts 1819
    OSD_RegisterFunction("setvarvar","setvarvar <gamevar1> <gamevar2>: sets the value of <gamevar1> to <gamevar2>", osdcmd_setvar);
1820
    OSD_RegisterFunction("setactorvar","setactorvar <actor#> <gamevar> <value>: sets the value of <actor#>'s <gamevar> to <value>", osdcmd_setactorvar);
4134 helixhorne 1821
#else
1822
    OSD_RegisterFunction("lua", "lua \"Lua code...\": runs Lunatic code", osdcmd_lua);
3415 helixhorne 1823
#endif
6365 terminx 1824
    OSD_RegisterFunction("screenshot","screenshot [format]: takes a screenshot.", osdcmd_screenshot);
834 terminx 1825
 
5 Plagman 1826
    OSD_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
1827
 
1112 hnt_ts 1828
    OSD_RegisterFunction("unbind","unbind <key>: unbinds a key", osdcmd_unbind);
1829
    OSD_RegisterFunction("unbindall","unbindall: unbinds all keys", osdcmd_unbindall);
7442 terminx 1830
    OSD_RegisterFunction("unbound", NULL, osdcmd_unbound);
821 terminx 1831
 
1112 hnt_ts 1832
    OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode);
4015 helixhorne 1833
#ifdef USE_OPENGL
1834
    baselayer_osdcmd_vidmode_func = osdcmd_vidmode;
3791 helixhorne 1835
#endif
7242 seventyfiv 1836
 
5 Plagman 1837
    return 0;
1838
}
1839