r3163 - trunk/data/qcsrc/menu-div0test/nexuiz

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Jan 17 15:43:23 EST 2008


Author: div0
Date: 2008-01-17 15:43:23 -0500 (Thu, 17 Jan 2008)
New Revision: 3163

Modified:
   trunk/data/qcsrc/menu-div0test/nexuiz/dialog_singleplayer.c
Log:
rudimentary instantaction support


Modified: trunk/data/qcsrc/menu-div0test/nexuiz/dialog_singleplayer.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog_singleplayer.c	2008-01-17 10:43:18 UTC (rev 3162)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog_singleplayer.c	2008-01-17 20:43:23 UTC (rev 3163)
@@ -11,6 +11,44 @@
 #endif
 
 #ifdef IMPLEMENTATION
+
+void InstantAction_LoadMap(entity btn, entity dummy)
+{
+	float glob, i, n, fh;
+	string s;
+	glob = search_begin("maps/*.instantaction", TRUE, TRUE);
+	if(glob < 0)
+		return;
+	i = ceil(random() * search_getsize(glob)) - 1;
+	fh = fopen(search_getfilename(glob, i), FILE_READ);
+	search_end(glob);
+	if(fh < 0)
+		return;
+	while((s = fgets(fh)))
+	{
+		if(substring(s, 0, 4) == "set ")
+			s = substring(s, 4, strlen(s) - 4);
+		n = tokenize(s);
+		if(argv(0) == "bot_number")
+			cvar_set("bot_number", argv(1));
+		else if(argv(0) == "skill")
+			cvar_set("skill", argv(1));
+		else if(argv(0) == "timelimit")
+			cvar_set("timelimit_override", argv(1));
+		else if(argv(0) == "fraglimit")
+			cvar_set("fraglimit_override", argv(1));
+		else if(argv(0) == "changelevel")
+		{
+			fclose(fh);
+			MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);
+			MapInfo_LoadMap(argv(1));
+			cvar_set("lastlevel", "1");
+			return;
+		}
+	}
+	fclose(fh);
+}
+
 void fillNexuizSingleplayerDialog(entity me)
 {
 	entity e;
@@ -18,7 +56,7 @@
 	me.TR(me);
 		me.TDempty(me, (me.columns - 2) / 2);
 		me.TD(me, 2, 2, e = makeNexuizButton("Instant action!", '0 0 0'));
-			//e.onClick = InstantAction_LoadMap;
+			e.onClick = InstantAction_LoadMap;
 			e.onClickEntity = NULL;
 	me.TR(me);
 	me.TR(me);




More information about the nexuiz-commits mailing list