From cdefc293c05020ed6f21cd9e81219c6bfe540667 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 15 Dec 2018 01:37:34 +0000 Subject: [PATCH] Fix setvar console command, and add a line of output so you know it did something git-svn-id: https://svn.eduke32.com/eduke32@7258 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/osdcmds.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index 2ba65d884..8f9fb91e6 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -610,11 +610,12 @@ static int osdcmd_setvar(osdcmdptr_t parm) } int i = hash_find(&h_gamevars, parm->parms[1]); - int const newValue = (i >= 0) ? Batol(parm->parms[1]) : Gv_GetVar(i, g_player[screenpeek].ps->i, screenpeek); + int const newValue = (i == -1) ? Batol(parm->parms[1]) : Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex); if ((i = hash_find(&h_gamevars, parm->parms[0])) >= 0) - Gv_SetVar(i, newValue, g_player[screenpeek].ps->i, screenpeek); + Gv_SetVar(i, newValue, g_player[myconnectindex].ps->i, myconnectindex); + OSD_Printf("Script variable \"%s\" set to %d (input: %d)\n", aGameVars[i].szLabel, Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex), newValue); return OSDCMD_OK; } @@ -632,7 +633,7 @@ static int osdcmd_addlogvar(osdcmdptr_t parm) int const i = hash_find(&h_gamevars, parm->parms[0]); if (i >= 0) - OSD_Printf("%s = %d\n", parm->parms[0], Gv_GetVar(i, g_player[screenpeek].ps->i, screenpeek)); + 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); return OSDCMD_OK; } @@ -657,11 +658,12 @@ static int osdcmd_setactorvar(osdcmdptr_t parm) // get value to set int i = hash_find(&h_gamevars, parm->parms[2]); - int const newValue = (i >= 0) ? Gv_GetVar(i, g_player[screenpeek].ps->i, screenpeek) : Batol(parm->parms[2]); + int const newValue = (i >= 0) ? Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex) : Batol(parm->parms[2]); if ((i = hash_find(&h_gamevars, parm->parms[1])) >= 0) - Gv_SetVar(i, newValue, spriteNum, screenpeek); + Gv_SetVar(i, newValue, spriteNum, myconnectindex); + OSD_Printf("Script variable \"%s\" set to %d (input: %d)\n", aGameVars[i].szLabel, Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex), newValue); return OSDCMD_OK; } #else