Exemplo n.º 1
0
void Script_SetMenuItemColor(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *menuname = NULL;
	const char *itemname = NULL;
	const char *name     = NULL;

	// expecting type of color to set and 4 args for the color
	if (String_Parse(args, &menuname) && String_Parse(args, &itemname) && String_Parse(args, &name))
	{
		menuDef_t *menu = Menus_FindByName(menuname);
		itemDef_t *item2;
		vec4_t    color;
		vec4_t    *out;
		int       j, i;
		int       count;

		if (!menu)
		{
			return;
		}

		count = Menu_ItemsMatchingGroup(menu, itemname);

		if (!Color_Parse(args, &color))
		{
			return;
		}

		for (j = 0; j < count; j++)
		{
			item2 = Menu_GetMatchingItemByNumber(menu, j, itemname);
			if (item2 != NULL)
			{
				out = NULL;
				if (Q_stricmp(name, "backcolor") == 0)
				{
					out = &item2->window.backColor;
				}
				else if (Q_stricmp(name, "forecolor") == 0)
				{
					out                  = &item2->window.foreColor;
					item2->window.flags |= WINDOW_FORECOLORSET;
				}
				else if (Q_stricmp(name, "bordercolor") == 0)
				{
					out = &item2->window.borderColor;
				}

				if (out)
				{
					for (i = 0; i < 4; i++)
					{
						(*out)[i] = color[i];
					}
				}
			}
		}
	}
}
Exemplo n.º 2
0
void Script_SetCvar(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *cvar = NULL, *val = NULL;

	if (String_Parse(args, &cvar) && String_Parse(args, &val))
	{
		DC->setCVar(cvar, val);
	}
}
Exemplo n.º 3
0
void Script_CopyCvar(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *cvar_src = NULL, *cvar_dst = NULL;

	if (String_Parse(args, &cvar_src) && String_Parse(args, &cvar_dst))
	{
		char buff[256];

		DC->getCVarString(cvar_src, buff, 256);
		DC->setCVar(cvar_dst, buff);
	}
}
Exemplo n.º 4
0
void Script_AddListItem(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *itemname = NULL, *val = NULL, *name = NULL;

	if (String_Parse(args, &itemname) && String_Parse(args, &val) && String_Parse(args, &name))
	{
		itemDef_t *t = Menu_FindItemByName(item->parent, itemname);

		if (t && t->special)
		{
			DC->feederAddItem(t->special, name, atoi(val));
		}
	}
}
Exemplo n.º 5
0
// FIXME
void Script_GetClipboard(itemDef_t *item, qboolean *bAbort, char **args)
{
	char       clipbuff[1024];
	const char *temp = NULL;

#define CLIPFAIL *bAbort = qtrue; return;

	memset(clipbuff, 0, sizeof(clipbuff));
	DC->getClipboardData(clipbuff, sizeof(clipbuff));
	if (!strlen(clipbuff))
	{
		// abort if there is nothing in the clipboard
		CLIPFAIL;
	}

	if (!String_Parse(args, &temp))
	{
		CLIPFAIL;
	}

	if (Q_stricmp(temp, "cvar") == 0)
	{
		const char *token = NULL;

		if (!String_Parse(args, &token))
		{
			CLIPFAIL;
		}

		DC->setCVar(token, clipbuff);
	}
	else if (Q_stricmp(temp, "exec") == 0)
	{
		DC->executeText(EXEC_APPEND, va("%s ; ", clipbuff));
	}
	else if (Q_stricmp(temp, "eval") == 0)
	{
		const char *token = NULL;

		if (!String_Parse(args, &token))
		{
			CLIPFAIL;
		}

		// evaluate the string (temp)
		//TODO: handle
	}
}
Exemplo n.º 6
0
void Item_RunScript(itemDef_t *item, qboolean *bAbort, const char *s)
{
	char     script[4096], *p;
	qboolean bRan;
	qboolean b_localAbort = qfalse;

	Item_HandleSaveValue();

	memset(script, 0, sizeof(script));

	if (item && s && s[0])
	{
		int i;

		Q_strcat(script, 4096, s);
		p = script;
		while (1)
		{
			const char *command = NULL;

			// expect command then arguments, ; ends command, NULL ends script
			if (!String_Parse(&p, &command))
			{
				return;
			}

			if (command[0] == ';' && command[1] == '\0')
			{
				continue;
			}

			bRan = qfalse;
			for (i = 0; i < scriptCommandCount; i++)
			{
				if (Q_stricmp(command, commandList[i].name) == 0)
				{
					(commandList[i].handler(item, &b_localAbort, &p));
					bRan = qtrue;

					if (b_localAbort)
					{
						if (bAbort)
						{
							*bAbort = b_localAbort;
						}

						return;
					}

					break;
				}
			}
			// not in our auto list, pass to handler
			if (!bRan)
			{
				DC->runScript(&p);
			}
		}
	}
}
Exemplo n.º 7
0
// This is for toggling integer cvars using bitflags.
void Script_ToggleCvarBit(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *cvar = NULL, *val = NULL;

	if (String_Parse(args, &cvar) && String_Parse(args, &val))
	{
		int  bitvalue, value;
		char buff[256];

		DC->getCVarString(cvar, buff, 256);
		value    = atoi(buff);
		bitvalue = atoi(val);
		value   ^= bitvalue;
		DC->setCVar(cvar, va("%i", value));
	}
}
Exemplo n.º 8
0
// the parser misreads setCvar "bleh" ""
// you have to use clearCvar "bleh"
void Script_ClearCvar(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *cvar;

	if (String_Parse(args, &cvar))
	{
		DC->setCVar(cvar, "");
	}
}
Exemplo n.º 9
0
void Script_SetPlayerHead(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		DC->setCVar("team_headmodel", name);
	}
}
Exemplo n.º 10
0
void Script_Play(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *val = NULL;

	if (String_Parse(args, &val))
	{
		DC->startLocalSound(DC->registerSound(val, qfalse), CHAN_LOCAL_SOUND);          // all sounds are not 3d
	}
}
Exemplo n.º 11
0
void Script_Close(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		Menus_CloseByName(name);
	}
}
Exemplo n.º 12
0
void Script_ExecNOW(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *val = NULL;

	if (String_Parse(args, &val))
	{
		DC->executeText(EXEC_NOW, va("%s ; ", val));
	}
}
Exemplo n.º 13
0
void Script_Show(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		Menu_ShowItemByName(item->parent, name, qtrue);
	}
}
Exemplo n.º 14
0
void Script_FadeOutMenu(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		Menu_FadeMenuByName(name, bAbort, qtrue);
	}
}
Exemplo n.º 15
0
void Script_ConditionalOpen(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *cvar  = NULL;
	const char *name1 = NULL;
	const char *name2 = NULL;
	int        testtype;  // 0: check val not 0
	// 1: check cvar not empty

	if (String_Parse(args, &cvar) && Int_Parse(args, &testtype) && String_Parse(args, &name1) && String_Parse(args, &name2))
	{
		float val;

		switch (testtype)
		{
		default:
		case 0:
			val = DC->getCVarValue(cvar);
			if (val == 0.f)
			{
				Menus_OpenByName(name2);
			}
			else
			{
				Menus_OpenByName(name1);
			}
			break;
		case 1:
		{
			char buff[1024];

			DC->getCVarString(cvar, buff, sizeof(buff));
			if (!buff[0])
			{
				Menus_OpenByName(name2);
			}
			else
			{
				Menus_OpenByName(name1);
			}
		}
		break;
		}
	}
}
Exemplo n.º 16
0
void Script_playLooped(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *val = NULL;

	if (String_Parse(args, &val))
	{
		DC->stopBackgroundTrack();
		DC->startBackgroundTrack(val, val, 0);
	}
}
Exemplo n.º 17
0
void Script_SetBackground(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	// expecting name to set asset to
	if (String_Parse(args, &name))
	{
		item->window.background = DC->registerShaderNoMip(name);
	}
}
Exemplo n.º 18
0
sdef(RdString, getLanguage) {
	assert(__environ != NULL);

	for (char **cur = __environ; *cur != NULL; cur++) {
		RdString item = String_FromNul(*cur);
		RdString res;

		if (String_Parse($("LANG=%_"), item, &res)) {
			return res;
		}
	}

	return $("en");
}
Exemplo n.º 19
0
void Script_SetMenuFocus(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name;

	if (String_Parse(args, &name))
	{
		menuDef_t *focusMenu = Menus_FindByName(name);

		if (focusMenu && !(focusMenu->window.flags & WINDOW_HASFOCUS))
		{
			Menu_ClearFocus(item->parent);
			focusMenu->window.flags |= WINDOW_HASFOCUS;
		}
	}
}
Exemplo n.º 20
0
void Script_Orbit(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		float cx   = 0.0f, cy = 0.0f, x = 0.0f, y = 0.0f;
		int   time = 0;

		if (Float_Parse(args, &x) && Float_Parse(args, &y) && Float_Parse(args, &cx) && Float_Parse(args, &cy) && Int_Parse(args, &time))
		{
			Menu_OrbitItemByName(item->parent, name, x, y, cx, cy, time);
		}
	}
}
Exemplo n.º 21
0
void Script_Transition(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		rectDef_t rectFrom, rectTo;
		float     amt  = 0.0f;
		int       time = 0;

		if (Rect_Parse(args, &rectFrom) && Rect_Parse(args, &rectTo) && Int_Parse(args, &time) && Float_Parse(args, &amt))
		{
			Menu_TransitionItemByName(item->parent, name, rectFrom, rectTo, time, amt);
		}
	}
}
Exemplo n.º 22
0
void Script_SetEditFocus(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		itemDef_t *editItem = Menu_FindItemByName(item->parent, name);

		if (editItem && TEXTFIELD(editItem->type))
		{
			editFieldDef_t *editPtr = (editFieldDef_t *)editItem->typeData;

			Menu_ClearFocus(item->parent);
			editItem->window.flags |= WINDOW_HASFOCUS;
			if (editItem->onFocus)
			{
				Item_RunScript(editItem, NULL, editItem->onFocus);
			}

			if (DC->Assets.itemFocusSound)
			{
				DC->startLocalSound(DC->Assets.itemFocusSound, CHAN_LOCAL_SOUND);
			}

			// reset scroll offset so we can see what we're editing
			if (editPtr)
			{
				editPtr->paintOffset = 0;
			}

			DC->setCVar(EDITFIELD_TEMP_CVAR, "");
			editItem->cursorPos = 0;
			g_editingField      = qtrue;
			g_editItem          = editItem;

			// the stupidest idea ever, let's just override the console, every ui element, user choice, etc
			// nuking this
			//DC->setOverstrikeMode(qtrue);
		}
	}
}
Exemplo n.º 23
0
void Script_SetColor(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	// expecting type of color to set and 4 args for the color
	if (String_Parse(args, &name))
	{
		vec4_t *out = NULL;

		if (Q_stricmp(name, "backcolor") == 0)
		{
			out                 = &item->window.backColor;
			item->window.flags |= WINDOW_BACKCOLORSET;
		}
		else if (Q_stricmp(name, "forecolor") == 0)
		{
			out                 = &item->window.foreColor;
			item->window.flags |= WINDOW_FORECOLORSET;
		}
		else if (Q_stricmp(name, "bordercolor") == 0)
		{
			out = &item->window.borderColor;
		}

		if (out)
		{
			float f = 0.0f;
			int   i;

			for (i = 0; i < 4; i++)
			{
				if (!Float_Parse(args, &f))
				{
					return;
				}

				(*out)[i] = f;
			}
		}
	}
}
Exemplo n.º 24
0
void Script_SetFocus(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		itemDef_t *focusItem = Menu_FindItemByName(item->parent, name);

		if (focusItem && !(focusItem->window.flags & WINDOW_DECORATION) && !(focusItem->window.flags & WINDOW_HASFOCUS))
		{
			Menu_ClearFocus(item->parent);
			focusItem->window.flags |= WINDOW_HASFOCUS;
			if (focusItem->onFocus)
			{
				Item_RunScript(focusItem, NULL, focusItem->onFocus);
			}

			if (DC->Assets.itemFocusSound)
			{
				DC->startLocalSound(DC->Assets.itemFocusSound, CHAN_LOCAL_SOUND);
			}
		}
	}
}
Exemplo n.º 25
0
void Script_ConditionalScript(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *cvar;
	const char *script1;
	const char *script2;
	const char *token;
	int        testtype;  // 0: check val not 0
	// 1: check cvar not empty
	int testval;

	if (String_Parse(args, &cvar) &&
	    Int_Parse(args, &testtype) &&
	    String_Parse(args, &token) && (token && *token == '(') &&
	    String_Parse(args, &script1) &&
	    String_Parse(args, &token) && (token && *token == ')') &&
	    String_Parse(args, &token) && (token && *token == '(') &&
	    String_Parse(args, &script2) &&
	    String_Parse(args, &token) && (token && *token == ')'))
	{
		float val;

		switch (testtype)
		{
		default:
		case 0:
			val = DC->getCVarValue(cvar);
			if (val == 0.f)
			{
				Item_RunScript(item, bAbort, script2);
			}
			else
			{
				Item_RunScript(item, bAbort, script1);
			}
			break;
		case 1:
		{
			char buff[1024];

			DC->getCVarString(cvar, buff, sizeof(buff));
			if (!buff[0])
			{
				Item_RunScript(item, bAbort, script2);
			}
			else
			{
				Item_RunScript(item, bAbort, script1);
			}
		}
		break;
		case 3:
			if (Int_Parse(args, &testval))
			{
				int testVal;

				val     = DC->getCVarValue(cvar);
				testVal = (int)val;
				if (testVal != testval)
				{
					Item_RunScript(item, bAbort, script2);
				}
				else
				{
					Item_RunScript(item, bAbort, script1);
				}
			}
			break;
		case 2:
			// special tests
			if (!Q_stricmp(cvar, "UIProfileIsActiveProfile"))
			{
				char ui_profileStr[256];
				char cl_profileStr[256];

				DC->getCVarString("ui_profile", ui_profileStr, sizeof(ui_profileStr));
				Q_CleanStr(ui_profileStr);
				Q_CleanDirName(ui_profileStr);

				DC->getCVarString("cl_profile", cl_profileStr, sizeof(cl_profileStr));

				if (!Q_stricmp(ui_profileStr, cl_profileStr))
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
			}
			else if (!Q_stricmp(cvar, "UIProfileValidName"))
			{
				char ui_profileStr[256];
				char ui_profileCleanedStr[256];

				DC->getCVarString("ui_profile", ui_profileStr, sizeof(ui_profileStr));
				Q_strncpyz(ui_profileCleanedStr, ui_profileStr, sizeof(ui_profileCleanedStr));
				Q_CleanStr(ui_profileCleanedStr);
				Q_CleanDirName(ui_profileCleanedStr);

				if (*ui_profileStr && *ui_profileCleanedStr)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}

			}
			else if (!Q_stricmp(cvar, "UIProfileAlreadyExists"))
			{
				char         ui_profileCleanedStr[256];
				qboolean     alreadyExists = qfalse;
				fileHandle_t f;

				DC->getCVarString("ui_profile", ui_profileCleanedStr, sizeof(ui_profileCleanedStr));
				Q_CleanStr(ui_profileCleanedStr);
				Q_CleanDirName(ui_profileCleanedStr);

				if (trap_FS_FOpenFile(va("profiles/%s/profile.dat", ui_profileCleanedStr), &f, FS_READ) >= 0)
				{
					alreadyExists = qtrue;
					trap_FS_FCloseFile(f);
				}

				if (alreadyExists)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
			}
			else if (!Q_stricmp(cvar, "UIProfileAlreadyExists_Rename"))
			{
				char         ui_profileCleanedStr[256];
				qboolean     alreadyExists = qfalse;
				fileHandle_t f;

				DC->getCVarString("ui_profile_renameto", ui_profileCleanedStr, sizeof(ui_profileCleanedStr));
				Q_CleanStr(ui_profileCleanedStr);
				Q_CleanDirName(ui_profileCleanedStr);

				if (trap_FS_FOpenFile(va("profiles/%s/profile.dat", ui_profileCleanedStr), &f, FS_READ) >= 0)
				{
					alreadyExists = qtrue;
					trap_FS_FCloseFile(f);
				}

				if (alreadyExists)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
			}
			else if (!Q_stricmp(cvar, "ReadyToCreateProfile"))
			{
				char         ui_profileStr[256], ui_profileCleanedStr[256];
				int          ui_rate;
				qboolean     alreadyExists = qfalse;
				fileHandle_t f;

				DC->getCVarString("ui_profile", ui_profileStr, sizeof(ui_profileStr));

				Q_strncpyz(ui_profileCleanedStr, ui_profileStr, sizeof(ui_profileCleanedStr));
				Q_CleanStr(ui_profileCleanedStr);
				Q_CleanDirName(ui_profileCleanedStr);

				if (trap_FS_FOpenFile(va("profiles/%s/profile.dat", ui_profileCleanedStr), &f, FS_READ) >= 0)
				{
					alreadyExists = qtrue;
					trap_FS_FCloseFile(f);
				}

				ui_rate = (int)DC->getCVarValue("ui_rate");

				if (!alreadyExists && *ui_profileStr && ui_rate > 0)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
			}
			else if (!Q_stricmp(cvar, "vidrestartIsRequired"))
			{
				int  ui_r_mode                           = DC->getCVarValue("ui_r_mode");
				int  ui_r_colorbits                      = DC->getCVarValue("ui_r_colorbits");
				int  ui_r_fullscreen                     = DC->getCVarValue("ui_r_fullscreen");
				int  ui_r_noborder                       = DC->getCVarValue("ui_r_noborder");
				int  ui_r_texturebits                    = DC->getCVarValue("ui_r_texturebits");
				int  ui_r_depthbits                      = DC->getCVarValue("ui_r_depthbits");
				int  ui_r_ext_compressed_textures        = DC->getCVarValue("ui_r_ext_compressed_textures");
				int  ui_r_allowextensions                = DC->getCVarValue("ui_r_allowextensions");
				int  ui_s_khz                            = DC->getCVarValue("ui_s_khz");
				int  ui_r_detailtextures                 = DC->getCVarValue("ui_r_detailtextures");
				int  ui_r_subdivisions                   = DC->getCVarValue("ui_r_subdivisions");
				int  ui_r_ext_texture_filter_anisotropic = DC->getCVarValue("ui_r_ext_texture_filter_anisotropic");
				int  ui_cg_shadows                       = DC->getCVarValue("ui_cg_shadows");
				char ui_r_texturemode[MAX_CVAR_VALUE_STRING];

				int  r_mode                           = DC->getCVarValue("r_mode");
				int  r_colorbits                      = DC->getCVarValue("r_colorbits");
				int  r_fullscreen                     = DC->getCVarValue("r_fullscreen");
				int  r_noborder                       = DC->getCVarValue("r_noborder");
				int  r_texturebits                    = DC->getCVarValue("r_texturebits");
				int  r_depthbits                      = DC->getCVarValue("r_depthbits");
				int  r_ext_compressed_textures        = DC->getCVarValue("r_ext_compressed_textures");
				int  r_allowextensions                = DC->getCVarValue("r_allowextensions");
				int  s_khz                            = DC->getCVarValue("s_khz");
				int  r_detailtextures                 = DC->getCVarValue("r_detailtextures");
				int  r_subdivisions                   = DC->getCVarValue("r_subdivisions");
				int  r_ext_texture_filter_anisotropic = DC->getCVarValue("r_ext_texture_filter_anisotropic");
				int  cg_shadows                       = DC->getCVarValue("cg_shadows");
				char r_texturemode[MAX_CVAR_VALUE_STRING];

				trap_Cvar_VariableStringBuffer("ui_r_texturemode", ui_r_texturemode, sizeof(ui_r_texturemode));
				trap_Cvar_VariableStringBuffer("r_texturemode", r_texturemode, sizeof(r_texturemode));

				if (ui_r_subdivisions != r_subdivisions ||
				    ui_r_mode != r_mode ||
				    ui_r_colorbits != r_colorbits ||
				    ui_r_fullscreen != r_fullscreen ||
				    ui_r_noborder != r_noborder ||
				    ui_r_texturebits != r_texturebits ||
				    ui_r_depthbits != r_depthbits ||
				    ui_r_ext_compressed_textures != r_ext_compressed_textures ||
				    ui_r_allowextensions != r_allowextensions ||
				    ui_s_khz != s_khz ||
				    ui_r_detailtextures != r_detailtextures ||
				    ui_r_ext_texture_filter_anisotropic != r_ext_texture_filter_anisotropic ||
				    ui_cg_shadows != cg_shadows ||
				    Q_stricmp(r_texturemode, ui_r_texturemode))
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
				/*} else if( !Q_stricmpn( cvar, "voteflags", 9 ) ) {
				char info[MAX_INFO_STRING];
				int voteflags = atoi(cvar + 9);

				trap_Cvar_VariableStringBuffer( "cg_ui_voteFlags", info, sizeof(info) );

				if( (atoi(info) & item->voteFlag) != item->voteFlag ) {
				Item_RunScript( item, bAbort, script1 );
				} else {
				Item_RunScript( item, bAbort, script2 );
				}*/
#ifndef CGAMEDLL
			}
			else if (!Q_stricmpn(cvar, "serversort_", 11))
			{
				int sorttype = atoi(cvar + 11);

				if (sorttype != uiInfo.serverStatus.sortKey)
				{
					Item_RunScript(item, bAbort, script2);
				}
				else
				{
					Item_RunScript(item, bAbort, script1);
				}
			}
			else if (!Q_stricmp(cvar, "ValidReplaySelected"))
			{
				if (uiInfo.demoIndex >= 0 && uiInfo.demoIndex < uiInfo.demoCount)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
#endif // !CGAMEDLL
			}
			else if (!Q_stricmp(cvar, "ROldModeCheck"))
			{
				char r_oldModeStr[256];
				int  r_oldMode;
				int  r_mode = DC->getCVarValue("r_mode");

				DC->getCVarString("r_oldMode", r_oldModeStr, sizeof(r_oldModeStr));
				r_oldMode = atoi(r_oldModeStr);

				if (*r_oldModeStr && r_oldMode != r_mode)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					if (r_oldMode == r_mode)
					{
						trap_Cvar_Set("r_oldMode", "");   // clear it
					}

					Item_RunScript(item, bAbort, script2);
				}
			}

			break;
		}
	}
}