Rev 4993 | 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 | |||
434 | Plagman | 23 | #include "compat.h" |
5 | Plagman | 24 | #include "osdcmds.h" |
25 | #include "baselayer.h" |
||
26 | #include "duke3d.h" |
||
2290 | helixhorne | 27 | #include "game.h" |
28 | #include "net.h" |
||
1677 | terminx | 29 | #include "premap.h" |
30 | #include "menus.h" |
||
1357 | terminx | 31 | #include "osd.h" |
901 | terminx | 32 | #include "osdfuncs.h" |
1677 | terminx | 33 | #include "gamedef.h" |
3006 | helixhorne | 34 | #include "demo.h" // g_firstDemoFile[] |
2556 | helixhorne | 35 | #include "common.h" |
1677 | terminx | 36 | |
5 | Plagman | 37 | #include <ctype.h> |
841 | terminx | 38 | #include <limits.h> |
3442 | terminx | 39 | #include <math.h> |
1572 | terminx | 40 | #include "enet/enet.h" |
5 | Plagman | 41 | |
4134 | helixhorne | 42 | #ifdef LUNATIC |
43 | # include "lunatic_game.h" |
||
44 | #endif |
||
45 | |||
4993 | terminx | 46 | #ifdef EDUKE32_TOUCH_DEVICES |
47 | #include "android/in_android.h" |
||
48 | #endif |
||
49 | |||
1205 | terminx | 50 | extern int32_t voting, g_doQuickSave; |
5 | Plagman | 51 | struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat; |
911 | terminx | 52 | float r_ambientlight = 1.0, r_ambientlightrecip = 1.0; |
1205 | terminx | 53 | extern int32_t althud_numbertile, althud_numberpal, althud_shadows, althud_flashing, hud_glowingquotes; |
54 | extern int32_t hud_showmapname; |
||
55 | extern int32_t r_maxfps; |
||
1454 | terminx | 56 | extern uint32_t g_frameDelay; |
1595 | helixhorne | 57 | extern int32_t demorec_diffs_cvar, demorec_force_cvar, demorec_seeds_cvar, demoplay_diffs, demoplay_showsync; |
58 | extern int32_t demorec_difftics_cvar, demorec_diffcompress_cvar, demorec_synccompress_cvar; |
||
1635 | terminx | 59 | extern void G_CheckPlayerColor(int32_t *color,int32_t prev_color); |
5 | Plagman | 60 | |
1205 | terminx | 61 | static inline int32_t osdcmd_quit(const osdfuncparm_t *parm) |
5 | Plagman | 62 | { |
654 | terminx | 63 | UNREFERENCED_PARAMETER(parm); |
4358 | hendricks2 | 64 | OSD_ShowDisplay(0); |
1571 | terminx | 65 | G_GameQuit(); |
5 | Plagman | 66 | return OSDCMD_OK; |
67 | } |
||
68 | |||
1205 | terminx | 69 | static int32_t osdcmd_changelevel(const osdfuncparm_t *parm) |
5 | Plagman | 70 | { |
1205 | terminx | 71 | int32_t volume=0,level; |
5 | Plagman | 72 | char *p; |
73 | |||
335 | terminx | 74 | if (!VOLUMEONE) |
75 | { |
||
5 | Plagman | 76 | if (parm->numparms != 2) return OSDCMD_SHOWHELP; |
77 | |||
78 | volume = strtol(parm->parms[0], &p, 10) - 1; |
||
79 | if (p[0]) return OSDCMD_SHOWHELP; |
||
80 | level = strtol(parm->parms[1], &p, 10) - 1; |
||
81 | if (p[0]) return OSDCMD_SHOWHELP; |
||
335 | terminx | 82 | } |
83 | else |
||
84 | { |
||
5 | Plagman | 85 | if (parm->numparms != 1) return OSDCMD_SHOWHELP; |
86 | |||
87 | level = strtol(parm->parms[0], &p, 10) - 1; |
||
88 | if (p[0]) return OSDCMD_SHOWHELP; |
||
89 | } |
||
90 | |||
91 | if (volume < 0) return OSDCMD_SHOWHELP; |
||
92 | if (level < 0) return OSDCMD_SHOWHELP; |
||
93 | |||
335 | terminx | 94 | if (!VOLUMEONE) |
95 | { |
||
1143 | terminx | 96 | if (volume > g_numVolumes) |
335 | terminx | 97 | { |
1143 | terminx | 98 | OSD_Printf("changelevel: invalid volume number (range 1-%d)\n",g_numVolumes); |
5 | Plagman | 99 | return OSDCMD_OK; |
100 | } |
||
101 | } |
||
102 | |||
1677 | terminx | 103 | if (level > MAXLEVELS || MapInfo[volume *MAXLEVELS+level].filename == NULL) |
335 | terminx | 104 | { |
564 | terminx | 105 | OSD_Printf("changelevel: invalid level number\n"); |
106 | return OSDCMD_SHOWHELP; |
||
335 | terminx | 107 | } |
5 | Plagman | 108 | |
413 | terminx | 109 | if (numplayers > 1) |
110 | { |
||
3095 | terminx | 111 | /* |
1587 | terminx | 112 | if (g_netServer) |
1143 | terminx | 113 | Net_NewGame(volume,level); |
413 | terminx | 114 | else if (voting == -1) |
115 | { |
||
116 | ud.m_volume_number = volume; |
||
117 | ud.m_level_number = level; |
||
472 | terminx | 118 | |
564 | terminx | 119 | if (g_player[myconnectindex].ps->i) |
413 | terminx | 120 | { |
1205 | terminx | 121 | int32_t i; |
472 | terminx | 122 | |
1229 | terminx | 123 | for (i=0; i<MAXPLAYERS; i++) |
564 | terminx | 124 | { |
125 | g_player[i].vote = 0; |
||
126 | g_player[i].gotvote = 0; |
||
127 | } |
||
128 | |||
129 | g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1; |
||
130 | |||
413 | terminx | 131 | voting = myconnectindex; |
132 | |||
1206 | terminx | 133 | tempbuf[0] = PACKET_MAP_VOTE_INITIATE; |
1143 | terminx | 134 | tempbuf[1] = myconnectindex; |
135 | tempbuf[2] = ud.m_volume_number; |
||
136 | tempbuf[3] = ud.m_level_number; |
||
413 | terminx | 137 | |
1592 | terminx | 138 | enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE)); |
413 | terminx | 139 | } |
1143 | terminx | 140 | if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM)) |
413 | terminx | 141 | ud.m_noexits = 0; |
142 | |||
4738 | hendricks2 | 143 | M_OpenMenu(myconnectindex); |
4399 | hendricks2 | 144 | M_ChangeMenu(MENU_NETWAITVOTES); |
413 | terminx | 145 | } |
3095 | terminx | 146 | */ |
413 | terminx | 147 | return OSDCMD_OK; |
148 | } |
||
564 | terminx | 149 | if (g_player[myconnectindex].ps->gm & MODE_GAME) |
335 | terminx | 150 | { |
5 | Plagman | 151 | // in-game behave like a cheat |
3005 | helixhorne | 152 | osdcmd_cheatsinfo_stat.cheatnum = CHEAT_SCOTTY; |
5 | Plagman | 153 | osdcmd_cheatsinfo_stat.volume = volume; |
154 | osdcmd_cheatsinfo_stat.level = level; |
||
335 | terminx | 155 | } |
156 | else |
||
157 | { |
||
5 | Plagman | 158 | // out-of-game behave like a menu command |
159 | osdcmd_cheatsinfo_stat.cheatnum = -1; |
||
160 | |||
161 | ud.m_volume_number = volume; |
||
162 | ud.m_level_number = level; |
||
163 | |||
164 | ud.m_monsters_off = ud.monsters_off = 0; |
||
165 | |||
166 | ud.m_respawn_items = 0; |
||
167 | ud.m_respawn_inventory = 0; |
||
168 | |||
169 | ud.multimode = 1; |
||
170 | |||
3950 | helixhorne | 171 | G_NewGame_EnterLevel(); |
5 | Plagman | 172 | } |
173 | |||
174 | return OSDCMD_OK; |
||
175 | } |
||
176 | |||
1205 | terminx | 177 | static int32_t osdcmd_map(const osdfuncparm_t *parm) |
5 | Plagman | 178 | { |
1205 | terminx | 179 | int32_t i; |
2556 | helixhorne | 180 | char filename[BMAX_PATH]; |
5 | Plagman | 181 | |
3004 | helixhorne | 182 | const int32_t wildcardp = parm->numparms==1 && |
183 | (Bstrchr(parm->parms[0], '*') != NULL); |
||
184 | |||
185 | if (parm->numparms != 1 || wildcardp) |
||
987 | terminx | 186 | { |
2556 | helixhorne | 187 | CACHE1D_FIND_REC *r; |
188 | fnlist_t fnlist = FNLIST_INITIALIZER; |
||
1205 | terminx | 189 | int32_t maxwidth = 0; |
5 | Plagman | 190 | |
3004 | helixhorne | 191 | if (wildcardp) |
192 | maybe_append_ext(filename, sizeof(filename), parm->parms[0], ".map"); |
||
193 | else |
||
194 | Bstrcpy(filename, "*.MAP"); |
||
987 | terminx | 195 | |
3004 | helixhorne | 196 | fnlist_getnames(&fnlist, "/", filename, -1, 0); |
197 | |||
2556 | helixhorne | 198 | for (r=fnlist.findfiles; r; r=r->next) |
199 | maxwidth = max((unsigned)maxwidth, Bstrlen(r->name)); |
||
987 | terminx | 200 | |
201 | if (maxwidth > 0) |
||
202 | { |
||
1205 | terminx | 203 | int32_t x = 0, count = 0; |
987 | terminx | 204 | maxwidth += 3; |
205 | OSD_Printf(OSDTEXT_RED "Map listing:\n"); |
||
2556 | helixhorne | 206 | for (r=fnlist.findfiles; r; r=r->next) |
987 | terminx | 207 | { |
208 | OSD_Printf("%-*s",maxwidth,r->name); |
||
209 | x += maxwidth; |
||
210 | count++; |
||
211 | if (x > OSD_GetCols() - maxwidth) |
||
212 | { |
||
213 | x = 0; |
||
214 | OSD_Printf("\n"); |
||
215 | } |
||
216 | } |
||
217 | if (x) OSD_Printf("\n"); |
||
2556 | helixhorne | 218 | OSD_Printf(OSDTEXT_RED "Found %d maps\n", fnlist.numfiles); |
987 | terminx | 219 | } |
220 | |||
2556 | helixhorne | 221 | fnlist_clearnames(&fnlist); |
222 | |||
987 | terminx | 223 | return OSDCMD_SHOWHELP; |
224 | } |
||
225 | |||
3004 | helixhorne | 226 | maybe_append_ext(filename, sizeof(filename), parm->parms[0], ".map"); |
5 | Plagman | 227 | |
992 | terminx | 228 | if ((i = kopen4loadfrommod(filename,0)) < 0) |
335 | terminx | 229 | { |
909 | terminx | 230 | OSD_Printf(OSD_ERROR "map: file \"%s\" not found.\n", filename); |
5 | Plagman | 231 | return OSDCMD_OK; |
232 | } |
||
233 | kclose(i); |
||
234 | |||
413 | terminx | 235 | boardfilename[0] = '/'; |
236 | boardfilename[1] = 0; |
||
237 | strcat(boardfilename, filename); |
||
5 | Plagman | 238 | |
413 | terminx | 239 | if (numplayers > 1) |
240 | { |
||
3095 | terminx | 241 | /* |
1587 | terminx | 242 | if (g_netServer) |
413 | terminx | 243 | { |
1143 | terminx | 244 | Net_SendUserMapName(); |
245 | ud.m_volume_number = 0; |
||
246 | ud.m_level_number = 7; |
||
247 | Net_NewGame(ud.m_volume_number, ud.m_level_number); |
||
413 | terminx | 248 | } |
249 | else if (voting == -1) |
||
250 | { |
||
1143 | terminx | 251 | Net_SendUserMapName(); |
472 | terminx | 252 | |
413 | terminx | 253 | ud.m_volume_number = 0; |
254 | ud.m_level_number = 7; |
||
472 | terminx | 255 | |
564 | terminx | 256 | if (g_player[myconnectindex].ps->i) |
413 | terminx | 257 | { |
1205 | terminx | 258 | int32_t i; |
472 | terminx | 259 | |
1229 | terminx | 260 | for (i=0; i<MAXPLAYERS; i++) |
564 | terminx | 261 | { |
262 | g_player[i].vote = 0; |
||
263 | g_player[i].gotvote = 0; |
||
264 | } |
||
265 | |||
266 | g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1; |
||
413 | terminx | 267 | voting = myconnectindex; |
268 | |||
1206 | terminx | 269 | tempbuf[0] = PACKET_MAP_VOTE_INITIATE; |
1143 | terminx | 270 | tempbuf[1] = myconnectindex; |
271 | tempbuf[2] = ud.m_volume_number; |
||
272 | tempbuf[3] = ud.m_level_number; |
||
413 | terminx | 273 | |
1592 | terminx | 274 | enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE)); |
413 | terminx | 275 | } |
1143 | terminx | 276 | if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM)) |
413 | terminx | 277 | ud.m_noexits = 0; |
278 | |||
4738 | hendricks2 | 279 | M_OpenMenu(myconnectindex); |
4399 | hendricks2 | 280 | M_ChangeMenu(MENU_NETWAITVOTES); |
413 | terminx | 281 | } |
3095 | terminx | 282 | */ |
413 | terminx | 283 | return OSDCMD_OK; |
284 | } |
||
285 | |||
472 | terminx | 286 | osdcmd_cheatsinfo_stat.cheatnum = -1; |
287 | ud.m_volume_number = 0; |
||
288 | ud.m_level_number = 7; |
||
413 | terminx | 289 | |
472 | terminx | 290 | ud.m_monsters_off = ud.monsters_off = 0; |
5 | Plagman | 291 | |
472 | terminx | 292 | ud.m_respawn_items = 0; |
293 | ud.m_respawn_inventory = 0; |
||
5 | Plagman | 294 | |
472 | terminx | 295 | ud.multimode = 1; |
5 | Plagman | 296 | |
3950 | helixhorne | 297 | G_NewGame_EnterLevel(); |
5 | Plagman | 298 | |
299 | return OSDCMD_OK; |
||
300 | } |
||
301 | |||
3021 | helixhorne | 302 | // demo <demonum or demofn> [<prof>] |
303 | // |
||
304 | // To profile a demo ("timedemo mode"), <prof> can be given in the range 0-8, |
||
305 | // which will start to replay it as fast as possible, rendering <prof> frames |
||
306 | // for each gametic. |
||
307 | // |
||
308 | // Notes: |
||
309 | // * The demos should be recorded with demorec_diffs set to 0, so that the |
||
310 | // game state updates are actually computed. |
||
3022 | helixhorne | 311 | // * Currently, the profiling can only be aborted on SDL 1.2 builds by |
312 | // pressing any key. |
||
3021 | helixhorne | 313 | // * With <prof> greater than 1, interpolation should be calculated properly, |
314 | // though this has not been verified by looking at the frames. |
||
315 | // * When testing whether a change in the source has an effect on performance, |
||
316 | // the variance of the run times MUST be taken into account (that is, the |
||
317 | // replaying must be performed multiple times for the old and new versions, |
||
318 | // etc.) |
||
3006 | helixhorne | 319 | static int32_t osdcmd_demo(const osdfuncparm_t *parm) |
320 | { |
||
321 | if (numplayers > 1) |
||
322 | { |
||
323 | OSD_Printf("Command not allowed in multiplayer\n"); |
||
324 | return OSDCMD_OK; |
||
325 | } |
||
326 | |||
327 | if (g_player[myconnectindex].ps->gm & MODE_GAME) |
||
328 | { |
||
329 | OSD_Printf("demo: Must not be in a game.\n"); |
||
330 | return OSDCMD_OK; |
||
331 | } |
||
332 | |||
3021 | helixhorne | 333 | if (parm->numparms != 1 && parm->numparms != 2) |
3006 | helixhorne | 334 | return OSDCMD_SHOWHELP; |
335 | |||
336 | { |
||
3021 | helixhorne | 337 | int32_t prof = parm->numparms==2 ? Batoi(parm->parms[1]) : -1; |
3006 | helixhorne | 338 | |
3045 | helixhorne | 339 | Demo_SetFirst(parm->parms[0]); |
3024 | helixhorne | 340 | Demo_PlayFirst(clamp(prof, -1, 8)+1, 0); |
3006 | helixhorne | 341 | } |
342 | |||
343 | return OSDCMD_OK; |
||
344 | } |
||
345 | |||
1205 | terminx | 346 | static int32_t osdcmd_god(const osdfuncparm_t *parm) |
5 | Plagman | 347 | { |
654 | terminx | 348 | UNREFERENCED_PARAMETER(parm); |
564 | terminx | 349 | if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME) |
3005 | helixhorne | 350 | osdcmd_cheatsinfo_stat.cheatnum = CHEAT_CORNHOLIO; |
335 | terminx | 351 | else |
5 | Plagman | 352 | OSD_Printf("god: Not in a single-player game.\n"); |
353 | |||
354 | return OSDCMD_OK; |
||
355 | } |
||
356 | |||
1205 | terminx | 357 | static int32_t osdcmd_noclip(const osdfuncparm_t *parm) |
5 | Plagman | 358 | { |
654 | terminx | 359 | UNREFERENCED_PARAMETER(parm); |
3006 | helixhorne | 360 | |
564 | terminx | 361 | if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME) |
335 | terminx | 362 | { |
3005 | helixhorne | 363 | osdcmd_cheatsinfo_stat.cheatnum = CHEAT_CLIP; |
335 | terminx | 364 | } |
365 | else |
||
366 | { |
||
5 | Plagman | 367 | OSD_Printf("noclip: Not in a single-player game.\n"); |
368 | } |
||
369 | |||
370 | return OSDCMD_OK; |
||
371 | } |
||
372 | |||
1205 | terminx | 373 | static int32_t osdcmd_restartsound(const osdfuncparm_t *parm) |
472 | terminx | 374 | { |
654 | terminx | 375 | UNREFERENCED_PARAMETER(parm); |
1143 | terminx | 376 | S_SoundShutdown(); |
377 | S_MusicShutdown(); |
||
472 | terminx | 378 | |
1143 | terminx | 379 | S_MusicStartup(); |
380 | S_SoundStartup(); |
||
472 | terminx | 381 | |
382 | FX_StopAllSounds(); |
||
1143 | terminx | 383 | S_ClearSoundLocks(); |
472 | terminx | 384 | |
4986 | terminx | 385 | if (ud.config.MusicToggle) |
4585 | helixhorne | 386 | S_RestartMusic(); |
491 | terminx | 387 | |
472 | terminx | 388 | return OSDCMD_OK; |
389 | } |
||
390 | |||
4587 | helixhorne | 391 | static int32_t osdcmd_music(const osdfuncparm_t *parm) |
392 | { |
||
393 | if (parm->numparms == 1) |
||
394 | { |
||
395 | int32_t sel = G_GetMusicIdx(parm->parms[0]); |
||
396 | |||
397 | if (sel == -1) |
||
398 | return OSDCMD_SHOWHELP; |
||
399 | |||
400 | if (sel == -2) |
||
401 | { |
||
402 | OSD_Printf("%s is not a valid episode/level number pair\n", parm->parms[0]); |
||
403 | return OSDCMD_OK; |
||
404 | } |
||
405 | |||
406 | if (MapInfo[sel].musicfn != NULL) |
||
407 | { |
||
408 | g_musicIndex = sel; |
||
409 | G_StartMusic(); |
||
410 | } |
||
411 | else |
||
412 | { |
||
413 | OSD_Printf("No music defined for %s\n", parm->parms[0]); |
||
414 | } |
||
415 | |||
416 | return OSDCMD_OK; |
||
417 | } |
||
418 | |||
419 | return OSDCMD_SHOWHELP; |
||
420 | } |
||
421 | |||
3757 | terminx | 422 | int32_t osdcmd_restartvid(const osdfuncparm_t *parm) |
5 | Plagman | 423 | { |
654 | terminx | 424 | UNREFERENCED_PARAMETER(parm); |
5 | Plagman | 425 | resetvideomode(); |
563 | terminx | 426 | if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP)) |
1143 | terminx | 427 | G_GameExit("restartvid: Reset failed...\n"); |
563 | terminx | 428 | onvideomodechange(ud.config.ScreenBPP>8); |
1143 | terminx | 429 | G_UpdateScreenArea(); |
5 | Plagman | 430 | |
431 | return OSDCMD_OK; |
||
432 | } |
||
433 | |||
1205 | terminx | 434 | static int32_t osdcmd_vidmode(const osdfuncparm_t *parm) |
5 | Plagman | 435 | { |
1205 | terminx | 436 | int32_t newbpp = ud.config.ScreenBPP, newwidth = ud.config.ScreenWidth, |
1599 | terminx | 437 | newheight = ud.config.ScreenHeight, newfs = ud.config.ScreenMode; |
2311 | helixhorne | 438 | int32_t tmp; |
439 | |||
5 | Plagman | 440 | if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP; |
441 | |||
335 | terminx | 442 | switch (parm->numparms) |
443 | { |
||
337 | terminx | 444 | case 1: // bpp switch |
2311 | helixhorne | 445 | tmp = Batol(parm->parms[0]); |
446 | if (!(tmp==8 || tmp==16 || tmp==32)) |
||
447 | return OSDCMD_SHOWHELP; |
||
448 | newbpp = tmp; |
||
337 | terminx | 449 | break; |
450 | case 2: // res switch |
||
451 | newwidth = Batol(parm->parms[0]); |
||
452 | newheight = Batol(parm->parms[1]); |
||
453 | break; |
||
454 | case 3: // res & bpp switch |
||
455 | case 4: |
||
456 | newwidth = Batol(parm->parms[0]); |
||
457 | newheight = Batol(parm->parms[1]); |
||
2311 | helixhorne | 458 | tmp = Batol(parm->parms[2]); |
459 | if (!(tmp==8 || tmp==16 || tmp==32)) |
||
460 | return OSDCMD_SHOWHELP; |
||
461 | newbpp = tmp; |
||
337 | terminx | 462 | if (parm->numparms == 4) |
463 | newfs = (Batol(parm->parms[3]) != 0); |
||
464 | break; |
||
5 | Plagman | 465 | } |
466 | |||
335 | terminx | 467 | if (setgamemode(newfs,newwidth,newheight,newbpp)) |
468 | { |
||
5 | Plagman | 469 | initprintf("vidmode: Mode change failed!\n"); |
563 | terminx | 470 | if (setgamemode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP)) |
1143 | terminx | 471 | G_GameExit("vidmode: Reset failed!\n"); |
5 | Plagman | 472 | } |
563 | terminx | 473 | ud.config.ScreenBPP = newbpp; |
474 | ud.config.ScreenWidth = newwidth; |
||
475 | ud.config.ScreenHeight = newheight; |
||
476 | ud.config.ScreenMode = newfs; |
||
477 | onvideomodechange(ud.config.ScreenBPP>8); |
||
1143 | terminx | 478 | G_UpdateScreenArea(); |
5 | Plagman | 479 | return OSDCMD_OK; |
480 | } |
||
481 | |||
4370 | helixhorne | 482 | #ifdef LUNATIC |
483 | // Returns: INT32_MIN if no such CON label, its value else. |
||
484 | LUNATIC_CB int32_t (*El_GetLabelValue)(const char *label); |
||
485 | #endif |
||
486 | |||
1205 | terminx | 487 | static int32_t osdcmd_spawn(const osdfuncparm_t *parm) |
5 | Plagman | 488 | { |
4370 | helixhorne | 489 | int32_t picnum = 0; |
490 | uint16_t cstat=0; |
||
1205 | terminx | 491 | char pal=0; |
492 | int16_t ang=0; |
||
493 | int16_t set=0, idx; |
||
1208 | terminx | 494 | vec3_t vect; |
5 | Plagman | 495 | |
564 | terminx | 496 | if (numplayers > 1 || !(g_player[myconnectindex].ps->gm & MODE_GAME)) |
335 | terminx | 497 | { |
5 | Plagman | 498 | OSD_Printf("spawn: Can't spawn sprites in multiplayer games or demos\n"); |
499 | return OSDCMD_OK; |
||
500 | } |
||
501 | |||
335 | terminx | 502 | switch (parm->numparms) |
503 | { |
||
337 | terminx | 504 | case 7: // x,y,z |
1208 | terminx | 505 | vect.x = Batol(parm->parms[4]); |
506 | vect.y = Batol(parm->parms[5]); |
||
507 | vect.z = Batol(parm->parms[6]); |
||
337 | terminx | 508 | set |= 8; |
509 | case 4: // ang |
||
510 | ang = Batol(parm->parms[3]) & 2047; |
||
511 | set |= 4; |
||
512 | case 3: // cstat |
||
1205 | terminx | 513 | cstat = (uint16_t)Batol(parm->parms[2]); |
337 | terminx | 514 | set |= 2; |
515 | case 2: // pal |
||
1205 | terminx | 516 | pal = (uint8_t)Batol(parm->parms[1]); |
337 | terminx | 517 | set |= 1; |
518 | case 1: // tile number |
||
519 | if (isdigit(parm->parms[0][0])) |
||
520 | { |
||
4370 | helixhorne | 521 | picnum = Batol(parm->parms[0]); |
337 | terminx | 522 | } |
523 | else |
||
524 | { |
||
4370 | helixhorne | 525 | int32_t i; |
526 | #ifdef LUNATIC |
||
527 | i = g_numLabels; |
||
528 | picnum = El_GetLabelValue(parm->parms[0]); |
||
529 | if (picnum != INT32_MIN) |
||
530 | i = !i; |
||
531 | #else |
||
532 | int32_t j; |
||
533 | |||
337 | terminx | 534 | for (j=0; j<2; j++) |
335 | terminx | 535 | { |
1143 | terminx | 536 | for (i=0; i<g_numLabels; i++) |
335 | terminx | 537 | { |
4370 | helixhorne | 538 | if ((j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) || |
539 | (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))) |
||
335 | terminx | 540 | { |
4370 | helixhorne | 541 | picnum = labelcode[i]; |
337 | terminx | 542 | break; |
5 | Plagman | 543 | } |
544 | } |
||
4370 | helixhorne | 545 | |
546 | if (i < g_numLabels) |
||
547 | break; |
||
5 | Plagman | 548 | } |
4370 | helixhorne | 549 | #endif |
1143 | terminx | 550 | if (i==g_numLabels) |
335 | terminx | 551 | { |
337 | terminx | 552 | OSD_Printf("spawn: Invalid tile label given\n"); |
5 | Plagman | 553 | return OSDCMD_OK; |
554 | } |
||
337 | terminx | 555 | } |
556 | |||
4370 | helixhorne | 557 | if ((uint32_t)picnum >= MAXUSERTILES) |
337 | terminx | 558 | { |
559 | OSD_Printf("spawn: Invalid tile number\n"); |
||
560 | return OSDCMD_OK; |
||
561 | } |
||
562 | break; |
||
4370 | helixhorne | 563 | |
337 | terminx | 564 | default: |
565 | return OSDCMD_SHOWHELP; |
||
5 | Plagman | 566 | } |
567 | |||
4370 | helixhorne | 568 | idx = A_Spawn(g_player[myconnectindex].ps->i, picnum); |
1205 | terminx | 569 | if (set & 1) sprite[idx].pal = (uint8_t)pal; |
570 | if (set & 2) sprite[idx].cstat = (int16_t)cstat; |
||
5 | Plagman | 571 | if (set & 4) sprite[idx].ang = ang; |
335 | terminx | 572 | if (set & 8) |
573 | { |
||
1208 | terminx | 574 | if (setsprite(idx, &vect) < 0) |
335 | terminx | 575 | { |
5 | Plagman | 576 | OSD_Printf("spawn: Sprite can't be spawned into null space\n"); |
2452 | helixhorne | 577 | A_DeleteSprite(idx); |
5 | Plagman | 578 | } |
579 | } |
||
580 | |||
581 | return OSDCMD_OK; |
||
582 | } |
||
583 | |||
3415 | helixhorne | 584 | #if !defined LUNATIC |
1205 | terminx | 585 | static int32_t osdcmd_setvar(const osdfuncparm_t *parm) |
5 | Plagman | 586 | { |
1205 | terminx | 587 | int32_t i, varval; |
5 | Plagman | 588 | char varname[256]; |
589 | |||
590 | if (parm->numparms != 2) return OSDCMD_SHOWHELP; |
||
591 | |||
379 | terminx | 592 | if (numplayers > 1) |
5 | Plagman | 593 | { |
594 | OSD_Printf("Command not allowed in multiplayer\n"); |
||
595 | return OSDCMD_OK; |
||
596 | } |
||
597 | |||
587 | terminx | 598 | strcpy(varname,parm->parms[1]); |
599 | varval = Batol(varname); |
||
1625 | terminx | 600 | i = hash_find(&h_gamevars,varname); |
1030 | terminx | 601 | if (i >= 0) |
1143 | terminx | 602 | varval=Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex); |
587 | terminx | 603 | |
5 | Plagman | 604 | strcpy(varname,parm->parms[0]); |
1625 | terminx | 605 | i = hash_find(&h_gamevars,varname); |
1030 | terminx | 606 | if (i >= 0) |
1143 | terminx | 607 | Gv_SetVar(i, varval, g_player[myconnectindex].ps->i, myconnectindex); |
11 | terminx | 608 | return OSDCMD_OK; |
29 | terminx | 609 | } |
11 | terminx | 610 | |
1205 | terminx | 611 | static int32_t osdcmd_addlogvar(const osdfuncparm_t *parm) |
892 | hnt_ts | 612 | { |
1205 | terminx | 613 | int32_t i; |
892 | hnt_ts | 614 | char varname[256]; |
615 | |||
616 | if (parm->numparms != 1) return OSDCMD_SHOWHELP; |
||
617 | |||
618 | if (numplayers > 1) |
||
619 | { |
||
620 | OSD_Printf("Command not allowed in multiplayer\n"); |
||
621 | return OSDCMD_OK; |
||
622 | } |
||
623 | |||
624 | strcpy(varname,parm->parms[0]); |
||
1625 | terminx | 625 | i = hash_find(&h_gamevars,varname); |
1030 | terminx | 626 | if (i >= 0) |
1143 | terminx | 627 | OSD_Printf("%s = %d\n", varname, Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex)); |
892 | hnt_ts | 628 | return OSDCMD_OK; |
629 | } |
||
630 | |||
1205 | terminx | 631 | static int32_t osdcmd_setactorvar(const osdfuncparm_t *parm) |
587 | terminx | 632 | { |
1205 | terminx | 633 | int32_t i, varval, ID; |
587 | terminx | 634 | char varname[256]; |
635 | |||
636 | if (parm->numparms != 3) return OSDCMD_SHOWHELP; |
||
637 | |||
638 | if (numplayers > 1) |
||
639 | { |
||
640 | OSD_Printf("Command not allowed in multiplayer\n"); |
||
641 | return OSDCMD_OK; |
||
642 | } |
||
643 | |||
644 | ID=Batol(parm->parms[0]); |
||
645 | if (ID>=MAXSPRITES) |
||
646 | { |
||
647 | OSD_Printf("Invalid sprite ID\n"); |
||
648 | return OSDCMD_OK; |
||
649 | } |
||
650 | |||
651 | varval = Batol(parm->parms[2]); |
||
652 | strcpy(varname,parm->parms[2]); |
||
653 | varval = Batol(varname); |
||
1625 | terminx | 654 | i = hash_find(&h_gamevars,varname); |
1030 | terminx | 655 | if (i >= 0) |
1143 | terminx | 656 | varval=Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex); |
587 | terminx | 657 | |
658 | strcpy(varname,parm->parms[1]); |
||
1625 | terminx | 659 | i = hash_find(&h_gamevars,varname); |
1030 | terminx | 660 | if (i >= 0) |
1143 | terminx | 661 | Gv_SetVar(i, varval, ID, -1); |
587 | terminx | 662 | return OSDCMD_OK; |
663 | } |
||
4134 | helixhorne | 664 | #else |
665 | static int32_t osdcmd_lua(const osdfuncparm_t *parm) |
||
666 | { |
||
667 | // Should be used like |
||
668 | // lua "lua code..." |
||
669 | // (the quotes making the whole string passed as one argument) |
||
670 | |||
671 | int32_t ret; |
||
672 | |||
673 | if (parm->numparms != 1) |
||
674 | return OSDCMD_SHOWHELP; |
||
675 | |||
676 | if (!L_IsInitialized(&g_ElState)) |
||
677 | { |
||
678 | OSD_Printf("Lua state is not initialized.\n"); |
||
679 | return OSDCMD_OK; |
||
680 | } |
||
681 | |||
682 | // TODO: "=<expr>" as shorthand for "print(<expr>)", like in the |
||
683 | // stand-alone Lua interpreter? |
||
684 | // TODO: reserve some table to explicitly store stuff on the top level, for |
||
685 | // debugging convenience? |
||
686 | |||
687 | // For the 'lua' OSD command, don't make errors appear on-screen: |
||
688 | el_addNewErrors = 0; |
||
689 | ret = L_RunString(&g_ElState, (char *)parm->parms[0], 0, -1, "console"); |
||
690 | el_addNewErrors = 1; |
||
691 | |||
692 | if (ret != 0) |
||
693 | OSD_Printf("Error running the Lua code (error code %d)\n", ret); |
||
694 | |||
695 | return OSDCMD_OK; |
||
696 | } |
||
3415 | helixhorne | 697 | #endif |
587 | terminx | 698 | |
1205 | terminx | 699 | static int32_t osdcmd_addpath(const osdfuncparm_t *parm) |
11 | terminx | 700 | { |
701 | char pathname[BMAX_PATH]; |
||
702 | |||
703 | if (parm->numparms != 1) return OSDCMD_SHOWHELP; |
||
704 | |||
705 | strcpy(pathname,parm->parms[0]); |
||
706 | addsearchpath(pathname); |
||
5 | Plagman | 707 | return OSDCMD_OK; |
708 | } |
||
709 | |||
1205 | terminx | 710 | static int32_t osdcmd_initgroupfile(const osdfuncparm_t *parm) |
182 | terminx | 711 | { |
712 | char file[BMAX_PATH]; |
||
713 | |||
714 | if (parm->numparms != 1) return OSDCMD_SHOWHELP; |
||
715 | |||
716 | strcpy(file,parm->parms[0]); |
||
717 | initgroupfile(file); |
||
718 | return OSDCMD_OK; |
||
719 | } |
||
720 | |||
1205 | terminx | 721 | static int32_t osdcmd_cmenu(const osdfuncparm_t *parm) |
5 | Plagman | 722 | { |
723 | if (parm->numparms != 1) return OSDCMD_SHOWHELP; |
||
335 | terminx | 724 | if (numplayers > 1) |
725 | { |
||
5 | Plagman | 726 | OSD_Printf("cmenu: disallowed in multiplayer\n"); |
727 | return OSDCMD_OK; |
||
335 | terminx | 728 | } |
729 | else |
||
730 | { |
||
3084 | terminx | 731 | M_ChangeMenu(Batol(parm->parms[0])); |
5 | Plagman | 732 | } |
733 | |||
734 | return OSDCMD_OK; |
||
735 | } |
||
736 | |||
1352 | terminx | 737 | extern void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b); |
738 | extern palette_t CrosshairColors; |
||
150 | terminx | 739 | |
1352 | terminx | 740 | static int32_t osdcmd_crosshaircolor(const osdfuncparm_t *parm) |
5 | Plagman | 741 | { |
1352 | terminx | 742 | int32_t r, g, b; |
5 | Plagman | 743 | |
1352 | terminx | 744 | if (parm->numparms != 3) |
335 | terminx | 745 | { |
1352 | terminx | 746 | OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b); |
747 | return OSDCMD_SHOWHELP; |
||
5 | Plagman | 748 | } |
2374 | helixhorne | 749 | r = Batol(parm->parms[0]); |
750 | g = Batol(parm->parms[1]); |
||
751 | b = Batol(parm->parms[2]); |
||
1352 | terminx | 752 | G_SetCrosshairColor(r,g,b); |
753 | OSD_Printf("%s\n", parm->raw); |
||
5 | Plagman | 754 | return OSDCMD_OK; |
755 | } |
||
756 | |||
1205 | terminx | 757 | static int32_t osdcmd_give(const osdfuncparm_t *parm) |
5 | Plagman | 758 | { |
1205 | terminx | 759 | int32_t i; |
5 | Plagman | 760 | |
972 | terminx | 761 | if (numplayers != 1 || (g_player[myconnectindex].ps->gm & MODE_GAME) == 0 || |
990 | terminx | 762 | g_player[myconnectindex].ps->dead_flag != 0) |
335 | terminx | 763 | { |
972 | terminx | 764 | OSD_Printf("give: Cannot give while dead or not in a single-player game.\n"); |
765 | return OSDCMD_OK; |
||
766 | } |
||
335 | terminx | 767 | |
972 | terminx | 768 | if (parm->numparms != 1) return OSDCMD_SHOWHELP; |
335 | terminx | 769 | |
972 | terminx | 770 | if (!Bstrcasecmp(parm->parms[0], "all")) |
771 | { |
||
3005 | helixhorne | 772 | osdcmd_cheatsinfo_stat.cheatnum = CHEAT_STUFF; |
972 | terminx | 773 | return OSDCMD_OK; |
335 | terminx | 774 | } |
972 | terminx | 775 | else if (!Bstrcasecmp(parm->parms[0], "health")) |
335 | terminx | 776 | { |
972 | terminx | 777 | sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health<<1; |
5 | Plagman | 778 | return OSDCMD_OK; |
779 | } |
||
972 | terminx | 780 | else if (!Bstrcasecmp(parm->parms[0], "weapons")) |
781 | { |
||
3005 | helixhorne | 782 | osdcmd_cheatsinfo_stat.cheatnum = CHEAT_WEAPONS; |
972 | terminx | 783 | return OSDCMD_OK; |
784 | } |
||
785 | else if (!Bstrcasecmp(parm->parms[0], "ammo")) |
||
786 | { |
||
1229 | terminx | 787 | for (i=MAX_WEAPONS-(VOLUMEONE?6:1)-1; i>=PISTOL_WEAPON; i--) |
1143 | terminx | 788 | P_AddAmmo(i,g_player[myconnectindex].ps,g_player[myconnectindex].ps->max_ammo_amount[i]); |
972 | terminx | 789 | return OSDCMD_OK; |
790 | } |
||
791 | else if (!Bstrcasecmp(parm->parms[0], "armor")) |
||
792 | { |
||
1572 | terminx | 793 | g_player[myconnectindex].ps->inv_amount[GET_SHIELD] = 100; |
972 | terminx | 794 | return OSDCMD_OK; |
795 | } |
||
796 | else if (!Bstrcasecmp(parm->parms[0], "keys")) |
||
797 | { |
||
3005 | helixhorne | 798 | osdcmd_cheatsinfo_stat.cheatnum = CHEAT_KEYS; |
972 | terminx | 799 | return OSDCMD_OK; |
800 | } |
||
801 | else if (!Bstrcasecmp(parm->parms[0], "inventory")) |
||
802 | { |
||
3005 | helixhorne | 803 | osdcmd_cheatsinfo_stat.cheatnum = CHEAT_INVENTORY; |
972 | terminx | 804 | return OSDCMD_OK; |
805 | } |
||
5 | Plagman | 806 | return OSDCMD_SHOWHELP; |
807 | } |
||
808 | |||
1205 | terminx | 809 | void onvideomodechange(int32_t newmode) |
5 | Plagman | 810 | { |
1772 | plagman | 811 | uint8_t palid; |
5 | Plagman | 812 | |
3127 | helixhorne | 813 | // XXX? |
814 | if (!newmode || g_player[screenpeek].ps->palette < BASEPALCOUNT) |
||
815 | palid = g_player[screenpeek].ps->palette; |
||
335 | terminx | 816 | else |
3127 | helixhorne | 817 | palid = BASEPAL; |
5 | Plagman | 818 | |
1409 | terminx | 819 | #ifdef POLYMER |
3346 | terminx | 820 | if (getrendermode() == REND_POLYMER) |
1409 | terminx | 821 | { |
822 | int32_t i = 0; |
||
823 | |||
824 | while (i < MAXSPRITES) |
||
825 | { |
||
1625 | terminx | 826 | if (actor[i].lightptr) |
1409 | terminx | 827 | { |
1625 | terminx | 828 | polymer_deletelight(actor[i].lightId); |
829 | actor[i].lightptr = NULL; |
||
830 | actor[i].lightId = -1; |
||
1409 | terminx | 831 | } |
832 | i++; |
||
833 | } |
||
834 | } |
||
835 | #endif |
||
836 | |||
1781 | plagman | 837 | setbrightness(ud.brightness>>2, palid, 0); |
2306 | helixhorne | 838 | g_restorePalette = -1; |
1144 | terminx | 839 | g_crosshairSum = 0; |
5 | Plagman | 840 | } |
841 | |||
1205 | terminx | 842 | static int32_t osdcmd_name(const osdfuncparm_t *parm) |
157 | terminx | 843 | { |
929 | terminx | 844 | char namebuf[32]; |
845 | |||
157 | terminx | 846 | if (parm->numparms != 1) |
847 | { |
||
1143 | terminx | 848 | OSD_Printf("\"name\" is \"%s\"\n",szPlayerName); |
157 | terminx | 849 | return OSDCMD_SHOWHELP; |
850 | } |
||
851 | |||
852 | Bstrcpy(tempbuf,parm->parms[0]); |
||
853 | |||
1625 | terminx | 854 | while (Bstrlen(OSD_StripColors(namebuf,tempbuf)) > 10) |
157 | terminx | 855 | tempbuf[Bstrlen(tempbuf)-1] = '\0'; |
856 | |||
1143 | terminx | 857 | Bstrncpy(szPlayerName,tempbuf,sizeof(szPlayerName)-1); |
858 | szPlayerName[sizeof(szPlayerName)-1] = '\0'; |
||
157 | terminx | 859 | |
1143 | terminx | 860 | OSD_Printf("name %s\n",szPlayerName); |
157 | terminx | 861 | |
1573 | terminx | 862 | Net_SendClientInfo(); |
157 | terminx | 863 | |
864 | return OSDCMD_OK; |
||
865 | } |
||
866 | |||
5065 | terminx | 867 | |
1205 | terminx | 868 | static int32_t osdcmd_button(const osdfuncparm_t *parm) |
808 | terminx | 869 | { |
870 | char *p = (char *)parm->name+9; // skip "gamefunc_" |
||
834 | terminx | 871 | // if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game |
3195 | terminx | 872 | CONTROL_OSDInput[CONFIG_FunctionNameToNum(p)] = 1; // FIXME |
808 | terminx | 873 | return OSDCMD_OK; |
874 | } |
||
875 | |||
3209 | helixhorne | 876 | const keydef_t ConsoleKeys[]= |
836 | terminx | 877 | { |
878 | { "Escape", 0x1 }, |
||
879 | { "1", 0x2 }, |
||
880 | { "2", 0x3 }, |
||
881 | { "3", 0x4 }, |
||
882 | { "4", 0x5 }, |
||
883 | { "5", 0x6 }, |
||
884 | { "6", 0x7 }, |
||
885 | { "7", 0x8 }, |
||
886 | { "8", 0x9 }, |
||
887 | { "9", 0xa }, |
||
888 | { "0", 0xb }, |
||
889 | { "-", 0xc }, |
||
890 | { "=", 0xd }, |
||
891 | { "BakSpc", 0xe }, |
||
892 | { "Tab", 0xf }, |
||
893 | { "Q", 0x10 }, |
||
894 | { "W", 0x11 }, |
||
895 | { "E", 0x12 }, |
||
896 | { "R", 0x13 }, |
||
897 | { "T", 0x14 }, |
||
898 | { "Y", 0x15 }, |
||
899 | { "U", 0x16 }, |
||
900 | { "I", 0x17 }, |
||
901 | { "O", 0x18 }, |
||
902 | { "P", 0x19 }, |
||
903 | { "[", 0x1a }, |
||
904 | { "]", 0x1b }, |
||
905 | { "Enter", 0x1c }, |
||
906 | { "LCtrl", 0x1d }, |
||
907 | { "A", 0x1e }, |
||
908 | { "S", 0x1f }, |
||
909 | { "D", 0x20 }, |
||
910 | { "F", 0x21 }, |
||
911 | { "G", 0x22 }, |
||
912 | { "H", 0x23 }, |
||
913 | { "J", 0x24 }, |
||
914 | { "K", 0x25 }, |
||
915 | { "L", 0x26 }, |
||
916 | { "SemiColon", 0x27 }, |
||
917 | { "'", 0x28 }, |
||
918 | { "Tilde", 0x29 }, |
||
919 | { "LShift", 0x2a }, |
||
920 | { "\\", 0x2b }, |
||
921 | { "Z", 0x2c }, |
||
922 | { "X", 0x2d }, |
||
923 | { "C", 0x2e }, |
||
924 | { "V", 0x2f }, |
||
925 | { "B", 0x30 }, |
||
926 | { "N", 0x31 }, |
||
927 | { "M", 0x32 }, |
||
928 | { ",", 0x33 }, |
||
929 | { ".", 0x34 }, |
||
930 | { "/", 0x35 }, |
||
931 | { "RShift", 0x36 }, |
||
932 | { "Kpad*", 0x37 }, |
||
933 | { "LAlt", 0x38 }, |
||
934 | { "Space", 0x39 }, |
||
935 | { "CapLck", 0x3a }, |
||
936 | { "F1", 0x3b }, |
||
937 | { "F2", 0x3c }, |
||
938 | { "F3", 0x3d }, |
||
939 | { "F4", 0x3e }, |
||
940 | { "F5", 0x3f }, |
||
941 | { "F6", 0x40 }, |
||
942 | { "F7", 0x41 }, |
||
943 | { "F8", 0x42 }, |
||
944 | { "F9", 0x43 }, |
||
945 | { "F10", 0x44 }, |
||
946 | { "NumLck", 0x45 }, |
||
947 | { "ScrLck", 0x46 }, |
||
948 | { "Kpad7", 0x47 }, |
||
949 | { "Kpad8", 0x48 }, |
||
950 | { "Kpad9", 0x49 }, |
||
951 | { "Kpad-", 0x4a }, |
||
952 | { "Kpad4", 0x4b }, |
||
953 | { "Kpad5", 0x4c }, |
||
954 | { "Kpad6", 0x4d }, |
||
955 | { "Kpad+", 0x4e }, |
||
956 | { "Kpad1", 0x4f }, |
||
957 | { "Kpad2", 0x50 }, |
||
958 | { "Kpad3", 0x51 }, |
||
959 | { "Kpad0", 0x52 }, |
||
960 | { "Kpad.", 0x53 }, |
||
961 | { "F11", 0x57 }, |
||
962 | { "F12", 0x58 }, |
||
963 | { "KpdEnt", 0x9c }, |
||
964 | { "RCtrl", 0x9d }, |
||
965 | { "Kpad/", 0xb5 }, |
||
966 | { "RAlt", 0xb8 }, |
||
967 | { "PrtScn", 0xb7 }, |
||
968 | { "Pause", 0xc5 }, |
||
969 | { "Home", 0xc7 }, |
||
970 | { "Up", 0xc8 }, |
||
971 | { "PgUp", 0xc9 }, |
||
972 | { "Left", 0xcb }, |
||
973 | { "Right", 0xcd }, |
||
974 | { "End", 0xcf }, |
||
975 | { "Down", 0xd0 }, |
||
976 | { "PgDn", 0xd1 }, |
||
977 | { "Insert", 0xd2 }, |
||
978 | { "Delete", 0xd3 }, |
||
979 | |||
980 | {0,0} |
||
981 | }; |
||
982 | |||
3209 | helixhorne | 983 | const char *const ConsoleButtons[] = |
2796 | helixhorne | 984 | { |
985 | "mouse1", "mouse2", "mouse3", "mouse4", "mwheelup", |
||
986 | "mwheeldn", "mouse5", "mouse6", "mouse7", "mouse8" |
||
987 | }; |
||
836 | terminx | 988 | |
1205 | terminx | 989 | static int32_t osdcmd_bind(const osdfuncparm_t *parm) |
591 | plagman | 990 | { |
3209 | helixhorne | 991 | int32_t i, j, repeat; |
591 | plagman | 992 | |
3127 | helixhorne | 993 | if (parm->numparms==1 && !Bstrcasecmp(parm->parms[0],"showkeys")) |
591 | plagman | 994 | { |
1341 | terminx | 995 | for (i=0; ConsoleKeys[i].name; i++) |
996 | OSD_Printf("%s\n",ConsoleKeys[i].name); |
||
997 | for (i=0; i<MAXMOUSEBUTTONS; i++) |
||
998 | OSD_Printf("%s\n",ConsoleButtons[i]); |
||
591 | plagman | 999 | return OSDCMD_OK; |
1000 | } |
||
811 | terminx | 1001 | |
591 | plagman | 1002 | if (parm->numparms==0) |
1003 | { |
||
1205 | terminx | 1004 | int32_t j=0; |
833 | terminx | 1005 | |
1006 | OSD_Printf("Current key bindings:\n"); |
||
3209 | helixhorne | 1007 | |
1229 | terminx | 1008 | for (i=0; i<MAXBOUNDKEYS; i++) |
3209 | helixhorne | 1009 | if (CONTROL_KeyIsBound(i)) |
833 | terminx | 1010 | { |
1011 | j++; |
||
3195 | terminx | 1012 | OSD_Printf("%-9s %s\"%s\"\n", CONTROL_KeyBinds[i].key, CONTROL_KeyBinds[i].repeat?"":"norepeat ", |
3197 | terminx | 1013 | CONTROL_KeyBinds[i].cmdstr); |
833 | terminx | 1014 | } |
836 | terminx | 1015 | |
1229 | terminx | 1016 | for (i=0; i<MAXMOUSEBUTTONS; i++) |
3209 | helixhorne | 1017 | if (CONTROL_MouseIsBound(i)) |
833 | terminx | 1018 | { |
1019 | j++; |
||
3195 | terminx | 1020 | OSD_Printf("%-9s %s\"%s\"\n", CONTROL_MouseBinds[i].key, CONTROL_MouseBinds[i].repeat?"":"norepeat ", |
3197 | terminx | 1021 | CONTROL_MouseBinds[i].cmdstr); |
833 | terminx | 1022 | } |
1023 | |||
1024 | if (j == 0) |
||
1025 | OSD_Printf("No binds found.\n"); |
||
1026 | |||
591 | plagman | 1027 | return OSDCMD_OK; |
1028 | } |
||
1029 | |||
1229 | terminx | 1030 | for (i=0; ConsoleKeys[i].name; i++) |
1206 | terminx | 1031 | if (!Bstrcasecmp(parm->parms[0],ConsoleKeys[i].name)) |
810 | terminx | 1032 | break; |
591 | plagman | 1033 | |
1206 | terminx | 1034 | if (!ConsoleKeys[i].name) |
826 | terminx | 1035 | { |
1229 | terminx | 1036 | for (i=0; i<MAXMOUSEBUTTONS; i++) |
1206 | terminx | 1037 | if (!Bstrcasecmp(parm->parms[0],ConsoleButtons[i])) |
826 | terminx | 1038 | break; |
1039 | if (i >= MAXMOUSEBUTTONS) |
||
1040 | return OSDCMD_SHOWHELP; |
||
1041 | |||
1042 | if (parm->numparms < 2) |
||
1043 | { |
||
3197 | terminx | 1044 | if (CONTROL_MouseBinds[i].cmdstr && CONTROL_MouseBinds[i].key) |
1045 | OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], CONTROL_MouseBinds[i].repeat?"":"norepeat ", |
||
1046 | CONTROL_MouseBinds[i].cmdstr); |
||
826 | terminx | 1047 | return OSDCMD_OK; |
1048 | } |
||
1049 | |||
1050 | j = 1; |
||
834 | terminx | 1051 | |
3209 | helixhorne | 1052 | repeat = 1; |
826 | terminx | 1053 | if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat")) |
1054 | { |
||
3209 | helixhorne | 1055 | repeat = 0; |
826 | terminx | 1056 | j++; |
1057 | } |
||
834 | terminx | 1058 | |
1059 | Bstrcpy(tempbuf,parm->parms[j++]); |
||
1229 | terminx | 1060 | for (; j<parm->numparms; j++) |
834 | terminx | 1061 | { |
1062 | Bstrcat(tempbuf," "); |
||
1063 | Bstrcat(tempbuf,parm->parms[j++]); |
||
1064 | } |
||
1065 | |||
3209 | helixhorne | 1066 | CONTROL_BindMouse(i, tempbuf, repeat, ConsoleButtons[i]); |
3197 | terminx | 1067 | |
843 | terminx | 1068 | if (!OSD_ParsingScript()) |
826 | terminx | 1069 | OSD_Printf("%s\n",parm->raw); |
1070 | return OSDCMD_OK; |
||
1071 | } |
||
1072 | |||
811 | terminx | 1073 | if (parm->numparms < 2) |
1074 | { |
||
3209 | helixhorne | 1075 | if (CONTROL_KeyIsBound(ConsoleKeys[i].id)) |
1076 | OSD_Printf("%-9s %s\"%s\"\n", ConsoleKeys[i].name, CONTROL_KeyBinds[ConsoleKeys[i].id].repeat?"":"norepeat ", |
||
1077 | CONTROL_KeyBinds[ConsoleKeys[i].id].cmdstr); |
||
811 | terminx | 1078 | return OSDCMD_OK; |
1079 | } |
||
1080 | |||
808 | terminx | 1081 | j = 1; |
834 | terminx | 1082 | |
3209 | helixhorne | 1083 | repeat = 1; |
812 | terminx | 1084 | if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat")) |
808 | terminx | 1085 | { |
3209 | helixhorne | 1086 | repeat = 0; |
808 | terminx | 1087 | j++; |
1088 | } |
||
834 | terminx | 1089 | |
1090 | Bstrcpy(tempbuf,parm->parms[j++]); |
||
1229 | terminx | 1091 | for (; j<parm->numparms; j++) |
834 | terminx | 1092 | { |
1093 | Bstrcat(tempbuf," "); |
||
1094 | Bstrcat(tempbuf,parm->parms[j++]); |
||
1095 | } |
||
1096 | |||
3209 | helixhorne | 1097 | CONTROL_BindKey(ConsoleKeys[i].id, tempbuf, repeat, ConsoleKeys[i].name); |
3197 | terminx | 1098 | |
1632 | terminx | 1099 | { |
3126 | helixhorne | 1100 | char *cp = tempbuf; |
1625 | terminx | 1101 | |
3126 | helixhorne | 1102 | // Populate the keyboard config menu based on the bind. |
1103 | // Take care of processing one-to-many bindings properly, too. |
||
1104 | while ((cp = Bstrstr(cp, "gamefunc_"))) |
||
1632 | terminx | 1105 | { |
3126 | helixhorne | 1106 | char *semi; |
1107 | |||
1108 | cp += 9; // skip the "gamefunc_" |
||
1109 | |||
1110 | semi = Bstrchr(cp, ';'); |
||
1111 | if (semi) |
||
1112 | *semi = 0; |
||
1113 | |||
1114 | j = CONFIG_FunctionNameToNum(cp); |
||
1115 | |||
1116 | if (semi) |
||
1117 | cp = semi+1; |
||
1118 | |||
1119 | if (j != -1) |
||
1120 | { |
||
1121 | ud.config.KeyboardKeys[j][1] = ud.config.KeyboardKeys[j][0]; |
||
1122 | ud.config.KeyboardKeys[j][0] = ConsoleKeys[i].id; |
||
3124 | helixhorne | 1123 | // CONTROL_MapKey(j, ConsoleKeys[i].id, ud.config.KeyboardKeys[j][0]); |
3128 | terminx | 1124 | |
1125 | if (j == gamefunc_Show_Console) |
||
1126 | OSD_CaptureKey(ConsoleKeys[i].id); |
||
3126 | helixhorne | 1127 | } |
1632 | terminx | 1128 | } |
1129 | } |
||
1130 | |||
843 | terminx | 1131 | if (!OSD_ParsingScript()) |
814 | terminx | 1132 | OSD_Printf("%s\n",parm->raw); |
1625 | terminx | 1133 | |
591 | plagman | 1134 | return OSDCMD_OK; |
1135 | } |
||
1136 | |||
1205 | terminx | 1137 | static int32_t osdcmd_unbindall(const osdfuncparm_t *parm) |
821 | terminx | 1138 | { |
1205 | terminx | 1139 | int32_t i; |
821 | terminx | 1140 | |
1141 | UNREFERENCED_PARAMETER(parm); |
||
1142 | |||
1229 | terminx | 1143 | for (i=0; i<MAXBOUNDKEYS; i++) |
3209 | helixhorne | 1144 | CONTROL_FreeKeyBind(i); |
1632 | terminx | 1145 | |
1229 | terminx | 1146 | for (i=0; i<MAXMOUSEBUTTONS; i++) |
3209 | helixhorne | 1147 | CONTROL_FreeMouseBind(i); |
1632 | terminx | 1148 | |
1149 | for (i=0; i<NUMGAMEFUNCTIONS; i++) |
||
1150 | { |
||
1151 | ud.config.KeyboardKeys[i][0] = ud.config.KeyboardKeys[i][1] = 0xff; |
||
3124 | helixhorne | 1152 | // CONTROL_MapKey(i, ud.config.KeyboardKeys[i][0], ud.config.KeyboardKeys[i][1]); |
1632 | terminx | 1153 | } |
1154 | |||
1155 | if (!OSD_ParsingScript()) |
||
1156 | OSD_Printf("unbound all controls\n"); |
||
1157 | |||
821 | terminx | 1158 | return OSDCMD_OK; |
1159 | } |
||
1160 | |||
1205 | terminx | 1161 | static int32_t osdcmd_unbind(const osdfuncparm_t *parm) |
810 | terminx | 1162 | { |
1205 | terminx | 1163 | int32_t i; |
810 | terminx | 1164 | |
1165 | if (parm->numparms < 1) return OSDCMD_SHOWHELP; |
||
1632 | terminx | 1166 | |
1229 | terminx | 1167 | for (i=0; ConsoleKeys[i].name; i++) |
1206 | terminx | 1168 | if (!Bstrcasecmp(parm->parms[0],ConsoleKeys[i].name)) |
810 | terminx | 1169 | break; |
1632 | terminx | 1170 | |
1206 | terminx | 1171 | if (!ConsoleKeys[i].name) |
826 | terminx | 1172 | { |
1229 | terminx | 1173 | for (i=0; i<MAXMOUSEBUTTONS; i++) |
1206 | terminx | 1174 | if (!Bstrcasecmp(parm->parms[0],ConsoleButtons[i])) |
826 | terminx | 1175 | break; |
1632 | terminx | 1176 | |
826 | terminx | 1177 | if (i >= MAXMOUSEBUTTONS) |
1178 | return OSDCMD_SHOWHELP; |
||
1632 | terminx | 1179 | |
3209 | helixhorne | 1180 | CONTROL_FreeMouseBind(i); |
1632 | terminx | 1181 | |
1206 | terminx | 1182 | OSD_Printf("unbound %s\n",ConsoleButtons[i]); |
1632 | terminx | 1183 | |
826 | terminx | 1184 | return OSDCMD_OK; |
1185 | } |
||
1632 | terminx | 1186 | |
3209 | helixhorne | 1187 | CONTROL_FreeKeyBind(ConsoleKeys[i].id); |
1632 | terminx | 1188 | |
1206 | terminx | 1189 | OSD_Printf("unbound key %s\n",ConsoleKeys[i].name); |
1632 | terminx | 1190 | |
810 | terminx | 1191 | return OSDCMD_OK; |
1192 | } |
||
1193 | |||
1205 | terminx | 1194 | static int32_t osdcmd_quicksave(const osdfuncparm_t *parm) |
821 | terminx | 1195 | { |
1196 | UNREFERENCED_PARAMETER(parm); |
||
1197 | if (!(g_player[myconnectindex].ps->gm & MODE_GAME)) |
||
1198 | OSD_Printf("quicksave: not in a game.\n"); |
||
1143 | terminx | 1199 | else g_doQuickSave = 1; |
821 | terminx | 1200 | return OSDCMD_OK; |
1201 | } |
||
1202 | |||
1205 | terminx | 1203 | static int32_t osdcmd_quickload(const osdfuncparm_t *parm) |
821 | terminx | 1204 | { |
1205 | UNREFERENCED_PARAMETER(parm); |
||
1206 | if (!(g_player[myconnectindex].ps->gm & MODE_GAME)) |
||
1207 | OSD_Printf("quickload: not in a game.\n"); |
||
1143 | terminx | 1208 | else g_doQuickSave = 2; |
821 | terminx | 1209 | return OSDCMD_OK; |
1210 | } |
||
1211 | |||
1205 | terminx | 1212 | static int32_t osdcmd_screenshot(const osdfuncparm_t *parm) |
834 | terminx | 1213 | { |
1214 | UNREFERENCED_PARAMETER(parm); |
||
836 | terminx | 1215 | // KB_ClearKeysDown(); |
1852 | helixhorne | 1216 | screencapture("duke0000.tga",0,"EDuke32"); |
834 | terminx | 1217 | return OSDCMD_OK; |
1218 | } |
||
1219 | |||
3892 | helixhorne | 1220 | #if 0 |
1205 | terminx | 1221 | static int32_t osdcmd_savestate(const osdfuncparm_t *parm) |
859 | terminx | 1222 | { |
1223 | UNREFERENCED_PARAMETER(parm); |
||
3792 | helixhorne | 1224 | G_SaveMapState(); |
859 | terminx | 1225 | return OSDCMD_OK; |
1226 | } |
||
1227 | |||
1205 | terminx | 1228 | static int32_t osdcmd_restorestate(const osdfuncparm_t *parm) |
859 | terminx | 1229 | { |
1230 | UNREFERENCED_PARAMETER(parm); |
||
3792 | helixhorne | 1231 | G_RestoreMapState(); |
859 | terminx | 1232 | return OSDCMD_OK; |
1233 | } |
||
3791 | helixhorne | 1234 | #endif |
859 | terminx | 1235 | |
1852 | helixhorne | 1236 | #ifdef DEBUGGINGAIDS |
1205 | terminx | 1237 | static int32_t osdcmd_inittimer(const osdfuncparm_t *parm) |
1121 | terminx | 1238 | { |
1239 | if (parm->numparms != 1) |
||
1240 | { |
||
1143 | terminx | 1241 | OSD_Printf("%dHz timer\n",g_timerTicsPerSecond); |
1121 | terminx | 1242 | return OSDCMD_SHOWHELP; |
1243 | } |
||
1244 | |||
3485 | helixhorne | 1245 | G_InitTimer(Batol(parm->parms[0])); |
1121 | terminx | 1246 | |
1247 | OSD_Printf("%s\n",parm->raw); |
||
1248 | return OSDCMD_OK; |
||
1249 | } |
||
1852 | helixhorne | 1250 | #endif |
1121 | terminx | 1251 | |
1567 | terminx | 1252 | static int32_t osdcmd_disconnect(const osdfuncparm_t *parm) |
1253 | { |
||
1254 | UNREFERENCED_PARAMETER(parm); |
||
1570 | terminx | 1255 | g_netDisconnect = 1; |
1567 | terminx | 1256 | return OSDCMD_OK; |
1257 | } |
||
1258 | |||
1259 | static int32_t osdcmd_connect(const osdfuncparm_t *parm) |
||
1260 | { |
||
1261 | if (parm->numparms != 1) |
||
1262 | return OSDCMD_SHOWHELP; |
||
1263 | |||
1264 | Net_Connect(parm->parms[0]); |
||
1265 | G_BackToMenu(); |
||
1266 | return OSDCMD_OK; |
||
1267 | } |
||
1268 | |||
1571 | terminx | 1269 | static int32_t osdcmd_password(const osdfuncparm_t *parm) |
1270 | { |
||
1271 | if (parm->numparms < 1) |
||
1272 | { |
||
1587 | terminx | 1273 | Bmemset(g_netPassword, 0, sizeof(g_netPassword)); |
1571 | terminx | 1274 | return OSDCMD_OK; |
1275 | } |
||
1587 | terminx | 1276 | Bstrncpy(g_netPassword, (char *)(parm->raw) + 9, sizeof(g_netPassword)-1); |
1571 | terminx | 1277 | |
1278 | return OSDCMD_OK; |
||
1279 | } |
||
1280 | |||
4233 | helixhorne | 1281 | #if !defined NETCODE_DISABLE |
1572 | terminx | 1282 | static int32_t osdcmd_listplayers(const osdfuncparm_t *parm) |
1283 | { |
||
1677 | terminx | 1284 | ENetPeer *currentPeer; |
1573 | terminx | 1285 | char ipaddr[32]; |
1572 | terminx | 1286 | |
1802 | terminx | 1287 | if (parm && parm->numparms != 0) |
1572 | terminx | 1288 | return OSDCMD_SHOWHELP; |
1289 | |||
1587 | terminx | 1290 | if (!g_netServer) |
1572 | terminx | 1291 | { |
1292 | initprintf("You are not the server.\n"); |
||
1293 | return OSDCMD_OK; |
||
1294 | } |
||
1295 | |||
1802 | terminx | 1296 | initprintf("Connected clients:\n"); |
1297 | |||
1587 | terminx | 1298 | for (currentPeer = g_netServer -> peers; |
1593 | terminx | 1299 | currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; |
1300 | ++ currentPeer) |
||
1572 | terminx | 1301 | { |
1302 | if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) |
||
1303 | continue; |
||
1304 | |||
1573 | terminx | 1305 | enet_address_get_host_ip(¤tPeer->address, ipaddr, sizeof(ipaddr)); |
1306 | initprintf("%x %s %s\n", currentPeer->address.host, ipaddr, |
||
1593 | terminx | 1307 | g_player[(intptr_t)currentPeer->data].user_name); |
1572 | terminx | 1308 | } |
4233 | helixhorne | 1309 | |
1572 | terminx | 1310 | return OSDCMD_OK; |
1311 | } |
||
1312 | |||
1573 | terminx | 1313 | static int32_t osdcmd_kick(const osdfuncparm_t *parm) |
1314 | { |
||
1677 | terminx | 1315 | ENetPeer *currentPeer; |
1573 | terminx | 1316 | uint32_t hexaddr; |
1317 | |||
1318 | if (parm->numparms != 1) |
||
1319 | return OSDCMD_SHOWHELP; |
||
1320 | |||
1587 | terminx | 1321 | if (!g_netServer) |
1573 | terminx | 1322 | { |
1323 | initprintf("You are not the server.\n"); |
||
1324 | return OSDCMD_OK; |
||
1325 | } |
||
1326 | |||
1587 | terminx | 1327 | for (currentPeer = g_netServer -> peers; |
1593 | terminx | 1328 | currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; |
1329 | ++ currentPeer) |
||
1573 | terminx | 1330 | { |
1331 | if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) |
||
1332 | continue; |
||
1333 | |||
1791 | helixhorne | 1334 | sscanf(parm->parms[0],"%" SCNx32 "", &hexaddr); |
1573 | terminx | 1335 | |
1336 | if (currentPeer->address.host == hexaddr) |
||
1337 | { |
||
1338 | initprintf("Kicking %x (%s)\n", currentPeer->address.host, |
||
1593 | terminx | 1339 | g_player[(intptr_t)currentPeer->data].user_name); |
1340 | enet_peer_disconnect(currentPeer, DISC_KICKED); |
||
1573 | terminx | 1341 | return OSDCMD_OK; |
1342 | } |
||
1343 | } |
||
1344 | |||
1345 | initprintf("Player %s not found!\n", parm->parms[0]); |
||
1802 | terminx | 1346 | osdcmd_listplayers(NULL); |
4233 | helixhorne | 1347 | |
1573 | terminx | 1348 | return OSDCMD_OK; |
1349 | } |
||
1350 | |||
1351 | static int32_t osdcmd_kickban(const osdfuncparm_t *parm) |
||
1352 | { |
||
1677 | terminx | 1353 | ENetPeer *currentPeer; |
1573 | terminx | 1354 | uint32_t hexaddr; |
1355 | |||
1356 | if (parm->numparms != 1) |
||
1357 | return OSDCMD_SHOWHELP; |
||
1358 | |||
1587 | terminx | 1359 | if (!g_netServer) |
1573 | terminx | 1360 | { |
1361 | initprintf("You are not the server.\n"); |
||
1362 | return OSDCMD_OK; |
||
1363 | } |
||
1364 | |||
1587 | terminx | 1365 | for (currentPeer = g_netServer -> peers; |
1593 | terminx | 1366 | currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; |
1367 | ++ currentPeer) |
||
1573 | terminx | 1368 | { |
1369 | if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) |
||
1370 | continue; |
||
1371 | |||
1791 | helixhorne | 1372 | sscanf(parm->parms[0],"%" SCNx32 "", &hexaddr); |
1677 | terminx | 1373 | |
1632 | terminx | 1374 | // TODO: implement banning logic |
1573 | terminx | 1375 | |
1376 | if (currentPeer->address.host == hexaddr) |
||
1377 | { |
||
1378 | char ipaddr[32]; |
||
1379 | |||
1380 | enet_address_get_host_ip(¤tPeer->address, ipaddr, sizeof(ipaddr)); |
||
1381 | initprintf("Host %s is now banned.\n", ipaddr); |
||
1382 | initprintf("Kicking %x (%s)\n", currentPeer->address.host, |
||
1593 | terminx | 1383 | g_player[(intptr_t)currentPeer->data].user_name); |
1384 | enet_peer_disconnect(currentPeer, DISC_BANNED); |
||
1573 | terminx | 1385 | return OSDCMD_OK; |
1386 | } |
||
1387 | } |
||
1388 | |||
1389 | initprintf("Player %s not found!\n", parm->parms[0]); |
||
1802 | terminx | 1390 | osdcmd_listplayers(NULL); |
4233 | helixhorne | 1391 | |
1573 | terminx | 1392 | return OSDCMD_OK; |
1393 | } |
||
4233 | helixhorne | 1394 | #endif |
1573 | terminx | 1395 | |
1355 | terminx | 1396 | static int32_t osdcmd_cvar_set_game(const osdfuncparm_t *parm) |
1397 | { |
||
1398 | int32_t r = osdcmd_cvar_set(parm); |
||
1399 | |||
1632 | terminx | 1400 | if (r != OSDCMD_OK) return r; |
1401 | |||
3402 | helixhorne | 1402 | if (!Bstrcasecmp(parm->name, "r_size")) |
1355 | terminx | 1403 | { |
3402 | helixhorne | 1404 | ud.statusbarmode = (ud.screen_size < 8); |
1405 | G_UpdateScreenArea(); |
||
1406 | } |
||
1407 | else if (!Bstrcasecmp(parm->name, "r_maxfps")) |
||
1408 | { |
||
4680 | terminx | 1409 | g_frameDelay = r_maxfps ? Blrintf(1000.f/(float)r_maxfps) : 0; |
1632 | terminx | 1410 | } |
1411 | else if (!Bstrcasecmp(parm->name, "r_ambientlight")) |
||
1412 | { |
||
1652 | terminx | 1413 | if (r_ambientlight == 0) |
1414 | r_ambientlightrecip = 256.f; |
||
1415 | else r_ambientlightrecip = 1.f/r_ambientlight; |
||
1632 | terminx | 1416 | } |
1417 | else if (!Bstrcasecmp(parm->name, "in_mouse")) |
||
1418 | { |
||
1419 | CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent); |
||
1420 | } |
||
1421 | else if (!Bstrcasecmp(parm->name, "in_joystick")) |
||
1422 | { |
||
1423 | CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent); |
||
1424 | } |
||
1425 | else if (!Bstrcasecmp(parm->name, "vid_gamma")) |
||
1426 | { |
||
1665 | terminx | 1427 | ud.brightness = GAMMA_CALC; |
1632 | terminx | 1428 | ud.brightness <<= 2; |
1781 | plagman | 1429 | setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); |
1632 | terminx | 1430 | } |
2639 | helixhorne | 1431 | else if (!Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast")) |
1632 | terminx | 1432 | { |
1781 | plagman | 1433 | setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); |
1632 | terminx | 1434 | } |
3675 | hendricks2 | 1435 | else if (!Bstrcasecmp(parm->name, "hud_scale") |
1436 | || !Bstrcasecmp(parm->name, "hud_statusbarmode") |
||
1437 | || !Bstrcasecmp(parm->name, "r_rotatespritenowidescreen")) |
||
1632 | terminx | 1438 | { |
1439 | G_UpdateScreenArea(); |
||
1440 | } |
||
1441 | else if (!Bstrcasecmp(parm->name, "skill")) |
||
1442 | { |
||
1443 | if (numplayers > 1) |
||
1355 | terminx | 1444 | return r; |
1445 | |||
1857 | terminx | 1446 | ud.player_skill = ud.m_player_skill; |
1355 | terminx | 1447 | } |
1635 | terminx | 1448 | else if (!Bstrcasecmp(parm->name, "color")) |
1449 | { |
||
1450 | G_CheckPlayerColor((int32_t *)&ud.color,-1); |
||
1451 | g_player[0].ps->palookup = g_player[0].pcolor = ud.color; |
||
1452 | } |
||
4425 | terminx | 1453 | else if (!Bstrcasecmp(parm->name, "osdscale")) |
1454 | { |
||
4649 | terminx | 1455 | osdrscale = 1.f/osdscale; |
1456 | |||
4425 | terminx | 1457 | if (xdim && ydim) |
1458 | OSD_ResizeDisplay(xdim, ydim); |
||
5065 | terminx | 1459 | } |
1460 | else if (!Bstrcasecmp(parm->name, "wchoice")) |
||
1461 | { |
||
1462 | if (parm->numparms == 1) |
||
1463 | { |
||
1464 | if (g_forceWeaponChoice) // rewrite ud.wchoice because osdcmd_cvar_set already changed it |
||
1465 | { |
||
1466 | int j = 0; |
||
1635 | terminx | 1467 | |
5065 | terminx | 1468 | while (j < 10) |
1469 | { |
||
1470 | ud.wchoice[j] = g_player[myconnectindex].wchoice[j] + '0'; |
||
1471 | j++; |
||
1472 | } |
||
1473 | |||
1474 | ud.wchoice[j] = 0; |
||
1475 | } |
||
1476 | else |
||
1477 | { |
||
1478 | char const *c = parm->parms[0]; |
||
1479 | |||
1480 | if (*c) |
||
1481 | { |
||
1482 | int j = 0; |
||
1483 | |||
1484 | while (*c && j < 10) |
||
1485 | { |
||
1486 | g_player[myconnectindex].wchoice[j] = *c - '0'; |
||
1487 | c++; |
||
1488 | j++; |
||
1489 | } |
||
1490 | |||
1491 | while (j < 10) |
||
1492 | { |
||
1493 | if (j == 9) |
||
1494 | g_player[myconnectindex].wchoice[9] = 1; |
||
1495 | else |
||
1496 | g_player[myconnectindex].wchoice[j] = 2; |
||
1497 | |||
1498 | j++; |
||
1499 | } |
||
1500 | } |
||
1501 | } |
||
1502 | |||
1503 | g_forceWeaponChoice = 0; |
||
1504 | } |
||
1505 | |||
1506 | /* Net_SendClientInfo();*/ |
||
4425 | terminx | 1507 | } |
1508 | |||
1355 | terminx | 1509 | return r; |
1510 | } |
||
1511 | |||
1635 | terminx | 1512 | static int32_t osdcmd_cvar_set_multi(const osdfuncparm_t *parm) |
1513 | { |
||
1514 | int32_t r = osdcmd_cvar_set_game(parm); |
||
1515 | |||
1516 | if (r != OSDCMD_OK) return r; |
||
1517 | |||
1518 | G_UpdatePlayerFromMenu(); |
||
1519 | |||
1520 | return r; |
||
1521 | } |
||
1522 | |||
1205 | terminx | 1523 | int32_t registerosdcommands(void) |
5 | Plagman | 1524 | { |
1205 | terminx | 1525 | uint32_t i; |
5 | Plagman | 1526 | |
1352 | terminx | 1527 | cvar_t cvars_game[] = |
335 | terminx | 1528 | { |
3783 | terminx | 1529 | { "crosshair", "enable/disable crosshair", (void *)&ud.crosshair, CVAR_BOOL, 0, 1 }, |
1352 | terminx | 1530 | |
4595 | terminx | 1531 | { "cl_autoaim", "enable/disable weapon autoaim", (void *)&ud.config.AutoAim, CVAR_INT|CVAR_MULTI, 0, 3 }, |
3783 | terminx | 1532 | { "cl_automsg", "enable/disable automatically sending messages to all players", (void *)&ud.automsg, CVAR_BOOL, 0, 1 }, |
1533 | { "cl_autorun", "enable/disable autorun", (void *)&ud.auto_run, CVAR_BOOL, 0, 1 }, |
||
1534 | { "cl_autovote", "enable/disable automatic voting", (void *)&ud.autovote, CVAR_INT, 0, 2 }, |
||
1352 | terminx | 1535 | |
3783 | terminx | 1536 | { "cl_obituaries", "enable/disable multiplayer death messages", (void *)&ud.obituaries, CVAR_BOOL, 0, 1 }, |
1537 | { "cl_democams", "enable/disable demo playback cameras", (void *)&ud.democams, CVAR_BOOL, 0, 1 }, |
||
1352 | terminx | 1538 | |
3783 | terminx | 1539 | { "cl_idplayers", "enable/disable name display when aiming at opponents", (void *)&ud.idplayers, CVAR_BOOL, 0, 1 }, |
1352 | terminx | 1540 | |
3783 | terminx | 1541 | { "cl_runmode", "enable/disable modernized run key operation", (void *)&ud.runkey_mode, CVAR_BOOL, 0, 1 }, |
3069 | terminx | 1542 | |
4410 | helixhorne | 1543 | { "cl_showcoords", "show your position in the game world", (void *)&ud.coords, CVAR_INT, 0, |
1544 | #ifdef USE_OPENGL |
||
1545 | 2 |
||
1546 | #else |
||
1547 | 1 |
||
1548 | #endif |
||
1549 | }, |
||
1352 | terminx | 1550 | |
3783 | terminx | 1551 | { "cl_viewbob", "enable/disable player head bobbing", (void *)&ud.viewbob, CVAR_BOOL, 0, 1 }, |
1352 | terminx | 1552 | |
3783 | terminx | 1553 | { "cl_weaponsway", "enable/disable player weapon swaying", (void *)&ud.weaponsway, CVAR_BOOL, 0, 1 }, |
1554 | { "cl_weaponswitch", "enable/disable auto weapon switching", (void *)&ud.weaponswitch, CVAR_INT|CVAR_MULTI, 0, 7 }, |
||
1352 | terminx | 1555 | |
4335 | helixhorne | 1556 | { "color", "changes player palette", (void *)&ud.color, CVAR_INT|CVAR_MULTI, 0, MAXPALOOKUPS-1 }, |
1352 | terminx | 1557 | |
3783 | terminx | 1558 | { "crosshairscale","changes the size of the crosshair", (void *)&ud.crosshairscale, CVAR_INT, 10, 100 }, |
1635 | terminx | 1559 | |
3783 | terminx | 1560 | { "demorec_diffs","enable/disable diff recording in demos",(void *)&demorec_diffs_cvar, CVAR_BOOL, 0, 1 }, |
1561 | { "demorec_force","enable/disable forced demo recording",(void *)&demorec_force_cvar, CVAR_BOOL|CVAR_NOSAVE, 0, 1 }, |
||
1677 | terminx | 1562 | { |
3783 | terminx | 1563 | "demorec_difftics","sets game tic interval after which a diff is recorded", |
3007 | helixhorne | 1564 | (void *)&demorec_difftics_cvar, CVAR_INT, 2, 60*REALGAMETICSPERSEC |
1677 | terminx | 1565 | }, |
3783 | terminx | 1566 | { "demorec_diffcompress","Compression method for diffs. (0: none, 1: KSLZW)",(void *)&demorec_diffcompress_cvar, CVAR_INT, 0, 1 }, |
1567 | { "demorec_synccompress","Compression method for input. (0: none, 1: KSLZW)",(void *)&demorec_synccompress_cvar, CVAR_INT, 0, 1 }, |
||
1568 | { "demorec_seeds","enable/disable recording of random seed for later sync checking",(void *)&demorec_seeds_cvar, CVAR_BOOL, 0, 1 }, |
||
1569 | { "demoplay_diffs","enable/disable application of diffs in demo playback",(void *)&demoplay_diffs, CVAR_BOOL, 0, 1 }, |
||
1570 | { "demoplay_showsync","enable/disable display of sync status",(void *)&demoplay_showsync, CVAR_BOOL, 0, 1 }, |
||
1352 | terminx | 1571 | |
4595 | terminx | 1572 | { "hud_althud", "enable/disable alternate mini-hud", (void *)&ud.althud, CVAR_INT, 0, 2 }, |
3783 | terminx | 1573 | { "hud_bgstretch", "enable/disable background image stretching in wide resolutions", (void *)&ud.bgstretch, CVAR_BOOL, 0, 1 }, |
1574 | { "hud_messagetime", "length of time to display multiplayer chat messages", (void *)&ud.msgdisptime, CVAR_INT, 0, 3600 }, |
||
1575 | { "hud_numbertile", "first tile in alt hud number set", (void *)&althud_numbertile, CVAR_INT, 0, MAXTILES-10 }, |
||
1576 | { "hud_numberpal", "pal for alt hud numbers", (void *)&althud_numberpal, CVAR_INT, 0, MAXPALOOKUPS }, |
||
1577 | { "hud_shadows", "enable/disable althud shadows", (void *)&althud_shadows, CVAR_BOOL, 0, 1 }, |
||
1578 | { "hud_flashing", "enable/disable althud flashing", (void *)&althud_flashing, CVAR_BOOL, 0, 1 }, |
||
1579 | { "hud_glowingquotes", "enable/disable \"glowing\" quote text", (void *)&hud_glowingquotes, CVAR_BOOL, 0, 1 }, |
||
1580 | { "hud_scale","changes the hud scale", (void *)&ud.statusbarscale, CVAR_INT|CVAR_FUNCPTR, 36, 100 }, |
||
1581 | { "hud_showmapname", "enable/disable map name display on load", (void *)&hud_showmapname, CVAR_BOOL, 0, 1 }, |
||
1582 | { "hud_stats", "enable/disable level statistics display", (void *)&ud.levelstats, CVAR_BOOL, 0, 1 }, |
||
1583 | { "hud_textscale", "sets multiplayer chat message size", (void *)&ud.textscale, CVAR_INT, 100, 400 }, |
||
1584 | { "hud_weaponscale","changes the weapon scale", (void *)&ud.weaponscale, CVAR_INT, 10, 100 }, |
||
1585 | { "hud_statusbarmode", "change overlay mode of status bar", (void *)&ud.statusbarmode, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, |
||
1352 | terminx | 1586 | |
4993 | terminx | 1587 | #ifdef EDUKE32_TOUCH_DEVICES |
1588 | { "hud_hidestick", "hide the touch input stick", (void *)&droidinput.hideStick, CVAR_BOOL, 0, 1 }, |
||
1589 | #endif |
||
1590 | |||
3783 | terminx | 1591 | { "in_joystick","enables input from the joystick if it is present",(void *)&ud.config.UseJoystick, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, |
1592 | { "in_mouse","enables input from the mouse if it is present",(void *)&ud.config.UseMouse, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, |
||
1352 | terminx | 1593 | |
3783 | terminx | 1594 | { "in_aimmode", "0:toggle, 1:hold to aim", (void *)&ud.mouseaiming, CVAR_BOOL, 0, 1 }, |
1677 | terminx | 1595 | { |
3783 | terminx | 1596 | "in_mousebias", "emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time", |
1677 | terminx | 1597 | (void *)&ud.config.MouseBias, CVAR_INT, 0, 32 |
1598 | }, |
||
3783 | terminx | 1599 | { "in_mousedeadzone", "amount of mouse movement to filter out", (void *)&ud.config.MouseDeadZone, CVAR_INT, 0, 512 }, |
1600 | { "in_mouseflip", "invert vertical mouse movement", (void *)&ud.mouseflip, CVAR_BOOL, 0, 1 }, |
||
4800 | helixhorne | 1601 | { "in_mousemode", "toggles vertical mouse view", (void *)&g_myAimMode, CVAR_BOOL, 0, 1 }, |
3783 | terminx | 1602 | { "in_mousesmoothing", "enable/disable mouse input smoothing", (void *)&ud.config.SmoothInput, CVAR_BOOL, 0, 1 }, |
1352 | terminx | 1603 | |
3783 | terminx | 1604 | { "mus_enabled", "enables/disables music", (void *)&ud.config.MusicToggle, CVAR_BOOL, 0, 1 }, |
4800 | helixhorne | 1605 | { "mus_volume", "controls music volume", (void *)&ud.config.MusicVolume, CVAR_INT, 0, 255 }, |
1352 | terminx | 1606 | |
3783 | terminx | 1607 | { "osdhightile", "enable/disable hires art replacements for console text", (void *)&osdhightile, CVAR_BOOL, 0, 1 }, |
4622 | terminx | 1608 | { "osdscale", "adjust console text size", (void *)&osdscale, CVAR_FLOAT|CVAR_FUNCPTR, 1, 4 }, |
1635 | terminx | 1609 | |
4445 | terminx | 1610 | { "r_camrefreshdelay", "minimum delay between security camera sprite updates, 120 = 1 second", (void *)&ud.camera_time, CVAR_INT, 1, 240 }, |
3783 | terminx | 1611 | { "r_drawweapon", "enable/disable weapon drawing", (void *)&ud.drawweapon, CVAR_INT, 0, 2 }, |
4622 | terminx | 1612 | { "r_showfps", "show the frame rate counter", (void *)&ud.tickrate, CVAR_INT, 0, 2 }, |
3783 | terminx | 1613 | { "r_shadows", "enable/disable sprite and model shadows", (void *)&ud.shadows, CVAR_BOOL, 0, 1 }, |
1614 | { "r_size", "change size of viewable area", (void *)&ud.screen_size, CVAR_INT|CVAR_FUNCPTR, 0, 64 }, |
||
1615 | { "r_rotatespritenowidescreen", "pass bit 1024 to all CON rotatesprite calls", (void *)&g_rotatespriteNoWidescreen, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, |
||
1616 | { "r_precache", "enable/disable the pre-level caching routine", (void *)&ud.config.useprecache, CVAR_BOOL, 0, 1 }, |
||
1352 | terminx | 1617 | |
3783 | terminx | 1618 | { "r_ambientlight", "sets the global map light level",(void *)&r_ambientlight, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, |
1619 | { "r_maxfps", "limit the frame rate",(void *)&r_maxfps, CVAR_INT|CVAR_FUNCPTR, 0, 1000 }, |
||
1540 | terminx | 1620 | |
3783 | terminx | 1621 | { "sensitivity","changes the mouse sensitivity", (void *)&CONTROL_MouseSensitivity, CVAR_FLOAT|CVAR_FUNCPTR, 0, 25 }, |
1352 | terminx | 1622 | |
3783 | terminx | 1623 | { "skill","changes the game skill setting", (void *)&ud.m_player_skill, CVAR_INT|CVAR_FUNCPTR/*|CVAR_NOMULTI*/, 0, 5 }, |
1625 | terminx | 1624 | |
3783 | terminx | 1625 | { "snd_ambience", "enables/disables ambient sounds", (void *)&ud.config.AmbienceToggle, CVAR_BOOL, 0, 1 }, |
1626 | { "snd_duketalk", "enables/disables Duke's speech", (void *)&ud.config.VoiceToggle, CVAR_INT, 0, 5 }, |
||
1627 | { "snd_enabled", "enables/disables sound effects", (void *)&ud.config.SoundToggle, CVAR_BOOL, 0, 1 }, |
||
3993 | terminx | 1628 | { "snd_mastervolume", "master volume for sound system", (void *)&ud.config.MasterVolume, CVAR_INT, 0, 255 }, |
1629 | { "snd_fxvolume", "volume of sound effects", (void *)&ud.config.FXVolume, CVAR_INT, 1, 255 }, |
||
3783 | terminx | 1630 | { "snd_mixrate", "sound mixing rate", (void *)&ud.config.MixRate, CVAR_INT, 0, 48000 }, |
1631 | { "snd_numbits", "sound bits", (void *)&ud.config.NumBits, CVAR_INT, 8, 16 }, |
||
1632 | { "snd_numchannels", "the number of sound channels", (void *)&ud.config.NumChannels, CVAR_INT, 0, 2 }, |
||
1633 | { "snd_numvoices", "the number of concurrent sounds", (void *)&ud.config.NumVoices, CVAR_INT, 0, 256 }, |
||
1634 | { "snd_reversestereo", "reverses the stereo channels", (void *)&ud.config.ReverseStereo, CVAR_BOOL, 0, 16 }, |
||
1625 | terminx | 1635 | |
3783 | terminx | 1636 | { "team","change team in multiplayer", (void *)&ud.team, CVAR_INT|CVAR_MULTI, 0, 3 }, |
1625 | terminx | 1637 | |
4993 | terminx | 1638 | #ifdef EDUKE32_TOUCH_DEVICES |
5065 | terminx | 1639 | { "touch_sens_move_x","touch input sensitivity for moving froward/back", (void *)&droidinput.forward_sens, CVAR_FLOAT, 1, 9 }, |
1640 | { "touch_sens_move_y","touch input sensitivity for strafing", (void *)&droidinput.strafe_sens, CVAR_FLOAT, 1, 9 }, |
||
1641 | { "touch_sens_look_x", "touch input sensitivity for turning left/right", (void *) &droidinput.yaw_sens, CVAR_FLOAT, 1, 9 }, |
||
1642 | { "touch_sens_look_y", "touch input sensitivity for looking up/down", (void *) &droidinput.pitch_sens, CVAR_FLOAT, 1, 9 }, |
||
4993 | terminx | 1643 | { "touch_invert", "invert look up/down touch input", (void *) &droidinput.invertLook, CVAR_INT, 0, 1 }, |
1644 | #endif |
||
1645 | |||
4611 | terminx | 1646 | { "vid_gamma","adjusts gamma component of gamma ramp",(void *)&vid_gamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, |
1647 | { "vid_contrast","adjusts contrast component of gamma ramp",(void *)&vid_contrast, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, |
||
1648 | { "vid_brightness","adjusts brightness component of gamma ramp",(void *)&vid_brightness, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, |
||
5065 | terminx | 1649 | { "wchoice","sets weapon autoselection order", (void *)ud.wchoice, CVAR_STRING|CVAR_FUNCPTR, 0, MAX_WEAPONS }, |
1352 | terminx | 1650 | }; |
1651 | |||
1357 | terminx | 1652 | osdcmd_cheatsinfo_stat.cheatnum = -1; |
1653 | |||
4385 | terminx | 1654 | for (i=0; i<ARRAY_SIZE(cvars_game); i++) |
1352 | terminx | 1655 | { |
1625 | terminx | 1656 | if (OSD_RegisterCvar(&cvars_game[i])) |
1657 | continue; |
||
1658 | |||
1659 | switch (cvars_game[i].type & (CVAR_FUNCPTR|CVAR_MULTI)) |
||
1660 | { |
||
1661 | case CVAR_FUNCPTR: |
||
1857 | terminx | 1662 | OSD_RegisterFunction(cvars_game[i].name, cvars_game[i].desc, osdcmd_cvar_set_game); |
1625 | terminx | 1663 | break; |
1664 | case CVAR_MULTI: |
||
1635 | terminx | 1665 | case CVAR_FUNCPTR|CVAR_MULTI: |
1857 | terminx | 1666 | OSD_RegisterFunction(cvars_game[i].name, cvars_game[i].desc, osdcmd_cvar_set_multi); |
1625 | terminx | 1667 | break; |
1668 | default: |
||
1857 | terminx | 1669 | OSD_RegisterFunction(cvars_game[i].name, cvars_game[i].desc, osdcmd_cvar_set); |
1625 | terminx | 1670 | break; |
1671 | } |
||
5 | Plagman | 1672 | } |
1673 | |||
335 | terminx | 1674 | if (VOLUMEONE) |
5 | Plagman | 1675 | OSD_RegisterFunction("changelevel","changelevel <level>: warps to the given level", osdcmd_changelevel); |
335 | terminx | 1676 | else |
1677 | { |
||
5 | Plagman | 1678 | OSD_RegisterFunction("changelevel","changelevel <volume> <level>: warps to the given level", osdcmd_changelevel); |
1112 | hnt_ts | 1679 | OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map); |
3006 | helixhorne | 1680 | OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo); |
5 | Plagman | 1681 | } |
182 | terminx | 1682 | |
1683 | OSD_RegisterFunction("addpath","addpath <path>: adds path to game filesystem", osdcmd_addpath); |
||
821 | terminx | 1684 | 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); |
5 | Plagman | 1685 | OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); |
1355 | terminx | 1686 | OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor); |
1687 | |||
1567 | terminx | 1688 | OSD_RegisterFunction("connect","connect: connects to a multiplayer game", osdcmd_connect); |
1689 | OSD_RegisterFunction("disconnect","disconnect: disconnects from the local multiplayer game", osdcmd_disconnect); |
||
1690 | |||
1229 | terminx | 1691 | for (i=0; i<NUMGAMEFUNCTIONS; i++) |
821 | terminx | 1692 | { |
1693 | char *t; |
||
1205 | terminx | 1694 | int32_t j; |
1101 | terminx | 1695 | |
3128 | terminx | 1696 | // if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue; |
1143 | terminx | 1697 | |
821 | terminx | 1698 | Bsprintf(tempbuf,"gamefunc_%s",gamefunctions[i]); |
4491 | helixhorne | 1699 | t = Xstrdup(tempbuf); |
1229 | terminx | 1700 | for (j=Bstrlen(t); j>=0; j--) |
1101 | terminx | 1701 | t[j] = Btolower(t[j]); |
821 | terminx | 1702 | Bstrcat(tempbuf,": game button"); |
4491 | helixhorne | 1703 | OSD_RegisterFunction(t, Xstrdup(tempbuf), osdcmd_button); |
821 | terminx | 1704 | } |
1705 | |||
5 | Plagman | 1706 | OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give); |
182 | terminx | 1707 | OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); |
1708 | |||
1709 | OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile); |
||
1852 | helixhorne | 1710 | #ifdef DEBUGGINGAIDS |
1711 | OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer); |
||
1712 | #endif |
||
4233 | helixhorne | 1713 | #if !defined NETCODE_DISABLE |
1573 | terminx | 1714 | OSD_RegisterFunction("kick","kick <id>: kicks a multiplayer client. See listplayers.", osdcmd_kick); |
1715 | OSD_RegisterFunction("kickban","kickban <id>: kicks a multiplayer client and prevents them from reconnecting. See listplayers.", osdcmd_kickban); |
||
1716 | |||
1572 | terminx | 1717 | OSD_RegisterFunction("listplayers","listplayers: lists currently connected multiplayer clients", osdcmd_listplayers); |
4233 | helixhorne | 1718 | #endif |
4587 | helixhorne | 1719 | OSD_RegisterFunction("music","music E<ep>L<lev>: change music", osdcmd_music); |
157 | terminx | 1720 | OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name); |
5 | Plagman | 1721 | OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip); |
1722 | |||
1571 | terminx | 1723 | OSD_RegisterFunction("password","password: sets multiplayer game password", osdcmd_password); |
1724 | |||
821 | terminx | 1725 | OSD_RegisterFunction("quicksave","quicksave: performs a quick save", osdcmd_quicksave); |
1726 | OSD_RegisterFunction("quickload","quickload: performs a quick load", osdcmd_quickload); |
||
182 | terminx | 1727 | OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit); |
841 | terminx | 1728 | OSD_RegisterFunction("exit","exit: exits the game immediately", osdcmd_quit); |
182 | terminx | 1729 | |
627 | terminx | 1730 | OSD_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound); |
1731 | OSD_RegisterFunction("restartvid","restartvid: reinitializes the video mode",osdcmd_restartvid); |
||
3415 | helixhorne | 1732 | #if !defined LUNATIC |
892 | hnt_ts | 1733 | OSD_RegisterFunction("addlogvar","addlogvar <gamevar>: prints the value of a gamevar", osdcmd_addlogvar); |
182 | terminx | 1734 | OSD_RegisterFunction("setvar","setvar <gamevar> <value>: sets the value of a gamevar", osdcmd_setvar); |
1112 | hnt_ts | 1735 | OSD_RegisterFunction("setvarvar","setvarvar <gamevar1> <gamevar2>: sets the value of <gamevar1> to <gamevar2>", osdcmd_setvar); |
1736 | OSD_RegisterFunction("setactorvar","setactorvar <actor#> <gamevar> <value>: sets the value of <actor#>'s <gamevar> to <value>", osdcmd_setactorvar); |
||
4134 | helixhorne | 1737 | #else |
1738 | OSD_RegisterFunction("lua", "lua \"Lua code...\": runs Lunatic code", osdcmd_lua); |
||
3415 | helixhorne | 1739 | #endif |
834 | terminx | 1740 | OSD_RegisterFunction("screenshot","screenshot: takes a screenshot. See r_scrcaptureformat.", osdcmd_screenshot); |
1741 | |||
5 | Plagman | 1742 | OSD_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn); |
1743 | |||
1112 | hnt_ts | 1744 | OSD_RegisterFunction("unbind","unbind <key>: unbinds a key", osdcmd_unbind); |
1745 | OSD_RegisterFunction("unbindall","unbindall: unbinds all keys", osdcmd_unbindall); |
||
821 | terminx | 1746 | |
1112 | hnt_ts | 1747 | OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode); |
4015 | helixhorne | 1748 | #ifdef USE_OPENGL |
1749 | baselayer_osdcmd_vidmode_func = osdcmd_vidmode; |
||
3791 | helixhorne | 1750 | #endif |
5 | Plagman | 1751 | return 0; |
1752 | } |
||
1753 |