[nexuiz-commits] r8513 - in trunk/data: . qcsrc/client qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Jan 17 11:27:01 EST 2010


Author: div0
Date: 2010-01-17 11:27:00 -0500 (Sun, 17 Jan 2010)
New Revision: 8513

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/client/mapvoting.qc
   trunk/data/qcsrc/server/g_world.qc
Log:
Revert "revert the mapvote change, it didnt really work online.", and fix it

Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2010-01-17 12:12:26 UTC (rev 8512)
+++ trunk/data/defaultNexuiz.cfg	2010-01-17 16:27:00 UTC (rev 8513)
@@ -1127,7 +1127,7 @@
 seta g_maplist_votable_suggestions_override_mostrecent 0
 seta g_maplist_votable_nodetail 1	"nodetail only shows total count instead of all vote counts per map, so votes don't influence others that much"
 seta g_maplist_votable_abstain 0	"when 1, you can abstain from your vote"
-seta g_maplist_votable_screenshot_dir "maps"	"where to look for map screenshots"
+seta g_maplist_votable_screenshot_dir "maps levelshots"	"where to look for map screenshots"
 alias suggestmap "cmd suggestmap $1"
 
 set g_chat_flood_spl 3	"normal chat: seconds between lines to not count as flooding"

Modified: trunk/data/qcsrc/client/mapvoting.qc
===================================================================
--- trunk/data/qcsrc/client/mapvoting.qc	2010-01-17 12:12:26 UTC (rev 8512)
+++ trunk/data/qcsrc/client/mapvoting.qc	2010-01-17 16:27:00 UTC (rev 8513)
@@ -275,10 +275,13 @@
 	MapVote_CheckPK3(pic, pk3, id);
 }
 
+#define NUM_SSDIRS 4
+string ssdirs[NUM_SSDIRS];
+float n_ssdirs;
 void MapVote_Init()
 {
-	float i, power;
-	string map, pk3, ssdir;
+	float i, j, power;
+	string map, pk3, s;
 
 	precache_sound ("misc/invshot.wav");
 
@@ -287,8 +290,16 @@
 
 	mv_active = 1;
 
-	ssdir = ReadString();
-	
+	for(n_ssdirs = 0; ; ++n_ssdirs)
+	{
+		s = ReadString();
+		if(s == "")
+			break;
+		if(n_ssdirs < NUM_SSDIRS)
+			ssdirs[n_ssdirs] = s;
+	}
+	n_ssdirs = min(n_ssdirs, NUM_SSDIRS);
+
 	mv_num_maps = min(MAPVOTE_COUNT, ReadByte());
 	mv_abstain = ReadByte();
 	if(mv_abstain)
@@ -314,9 +325,11 @@
 		{
 			map = strzone(ReadString());
 			pk3 = strzone(ReadString());
+			j = bound(0, ReadByte(), n_ssdirs - 1);
+	
 			mv_maps[i] = map;
 			mv_pk3[i] = pk3;
-			map = strzone(strcat(ssdir, "/", map));
+			map = strzone(strcat(ssdirs[j], "/", map));
 			mv_pics[i] = map;
 
 			mv_preview[i] = false;
@@ -333,6 +346,10 @@
 		}
 	}
 
+	for(i = 0; i < n_ssdirs; ++i)
+		ssdirs[n_ssdirs] = string_null;
+	n_ssdirs = 0;
+
 	// do we NEED this, or can we handle key presses directly in CSQC?
 	localcmd("\nin_bind 7 1 \"impulse 1\"; in_bind 7 2 \"impulse 2\"; in_bind 7 3 \"impulse 3\"; in_bind 7 4 \"impulse 4\"; in_bind 7 5 \"impulse 5\"; in_bind 7 6 \"impulse 6\"; in_bind 7 7 \"impulse 7\"; in_bind 7 8 \"impulse 8\"; in_bind 7 9 \"impulse 9\"; in_bind 7 0 \"impulse 10\"; in_bind 7 KP_1 \"impulse 1\"; in_bind 7 KP_2 \"impulse 2\"; in_bind 7 KP_3 \"impulse 3\"; in_bind 7 KP_4 \"impulse 4\"; in_bind 7 KP_5 \"impulse 5\"; in_bind 7 KP_6 \"impulse 6\"; in_bind 7 KP_7 \"impulse 7\"; in_bind 7 KP_8 \"impulse 8\"; in_bind 7 KP_9 \"impulse 9\"; in_bind 7 KP_0 \"impulse 10\"; in_bindmap 7 0\n");
 }

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2010-01-17 12:12:26 UTC (rev 8512)
+++ trunk/data/qcsrc/server/g_world.qc	2010-01-17 16:27:00 UTC (rev 8513)
@@ -2073,11 +2073,15 @@
 float mapvote_keeptwotime;
 float mapvote_timeout;
 string mapvote_message;
-string mapvote_screenshot_dir;
+#define MAPVOTE_SCREENSHOT_DIRS_COUNT 4
+string mapvote_screenshot_dirs[MAPVOTE_SCREENSHOT_DIRS_COUNT];
+float mapvote_screenshot_dirs_count;
 
 float mapvote_count;
 float mapvote_count_real;
 string mapvote_maps[MAPVOTE_COUNT];
+float mapvote_maps_screenshot_dir[MAPVOTE_COUNT];
+string mapvote_maps_pakfile[MAPVOTE_COUNT];
 float mapvote_maps_suggested[MAPVOTE_COUNT];
 string mapvote_suggestions[MAPVOTE_COUNT];
 float mapvote_suggestion_ptr;
@@ -2135,7 +2139,9 @@
 
 void MapVote_AddVotable(string nextMap, float isSuggestion)
 {
-	float j;
+	float j, i, o;
+	string pakfile, mapfile;
+
 	if(nextMap == "")
 		return;
 	for(j = 0; j < mapvote_count; ++j)
@@ -2145,6 +2151,26 @@
 		mapvote_maxlen = strlen(nextMap);
 	mapvote_maps[mapvote_count] = strzone(nextMap);
 	mapvote_maps_suggested[mapvote_count] = isSuggestion;
+
+	for(i = 0; i < mapvote_screenshot_dirs_count; ++i)
+	{
+		mapfile = strcat(mapvote_screenshot_dirs[i], "/", mapvote_maps[i]);
+		pakfile = whichpack(strcat(mapfile, ".tga"));
+		if(pakfile == "")
+			pakfile = whichpack(strcat(mapfile, ".jpg"));
+		if(pakfile == "")
+			pakfile = whichpack(strcat(mapfile, ".png"));
+		if(pakfile != "")
+			break;
+	}
+	if(i >= mapvote_screenshot_dirs_count)
+		i = 0; // FIXME maybe network this error case, as that means there is no mapshot on the server?
+	for(o = strstr(pakfile, "/", 0)+1; o > 0; o = strstr(pakfile, "/", 0)+1)
+		pakfile = substring(pakfile, o, -1);
+
+	mapvote_maps_screenshot_dir[mapvote_count] = i;
+	mapvote_maps_pakfile[mapvote_count] = strzone(pakfile);
+
 	mapvote_count += 1;
 }
 
@@ -2166,6 +2192,14 @@
 		nmax = min(MAPVOTE_COUNT, cvar("g_maplist_votable"));
 	smax = min3(nmax, cvar("g_maplist_votable_suggestions"), mapvote_suggestion_ptr);
 
+	// we need this for AddVotable, as that cycles through the screenshot dirs
+	mapvote_screenshot_dirs_count = tokenize_console(cvar_string("g_maplist_votable_screenshot_dir"));
+	if(mapvote_screenshot_dirs_count == 0)
+		mapvote_screenshot_dirs_count = tokenize_console("maps levelshots");
+	mapvote_screenshot_dirs_count = min(mapvote_screenshot_dirs_count, MAPVOTE_SCREENSHOT_DIRS_COUNT);
+	for(i = 0; i < mapvote_screenshot_dirs_count; ++i)
+		mapvote_screenshot_dirs[i] = strzone(argv(i));
+
 	if(mapvote_suggestion_ptr)
 		for(i = 0; i < 100 && mapvote_count < smax; ++i)
 			MapVote_AddVotable(mapvote_suggestions[floor(random() * mapvote_suggestion_ptr)], TRUE);
@@ -2196,11 +2230,6 @@
 		mapvote_keeptwotime = 0;
 	mapvote_message = "Choose a map and press its key!";
 
-	mapvote_screenshot_dir = cvar_string("g_maplist_votable_screenshot_dir");
-	if(mapvote_screenshot_dir == "")
-		mapvote_screenshot_dir = "maps";
-	mapvote_screenshot_dir = strzone(mapvote_screenshot_dir);
-
 	MapVote_Spawn();
 }
 
@@ -2210,7 +2239,7 @@
 	WriteByte(MSG_ONE, SVC_TEMPENTITY);
 	WriteByte(MSG_ONE, TE_CSQC_PICTURE);
 	WriteByte(MSG_ONE, id);
-	WritePicture(MSG_ONE, strcat(mapvote_screenshot_dir, "/", mapvote_maps[id]), 3072);
+	WritePicture(MSG_ONE, strcat(mapvote_screenshot_dirs[mapvote_maps_screenshot_dir[id]], "/", mapvote_maps[id]), 3072);
 }
 
 float GameCommand_MapVote(string cmd)
@@ -2240,8 +2269,7 @@
 entity mapvote_ent;
 float MapVote_SendEntity(entity to, float sf)
 {
-	string mapfile, pakfile;
-	float i, o;
+	float i;
 
 	if(sf & 1)
 		sf &~= 2; // if we send 1, we don't need to also send 2
@@ -2252,7 +2280,9 @@
 	if(sf & 1)
 	{
 		// flag 1 == initialization
-		WriteString(MSG_ENTITY, mapvote_screenshot_dir);
+		for(i = 0; i < mapvote_screenshot_dirs_count; ++i)
+			WriteString(MSG_ENTITY, mapvote_screenshot_dirs[i]);
+		WriteString(MSG_ENTITY, "");
 		WriteByte(MSG_ENTITY, mapvote_count);
 		WriteByte(MSG_ENTITY, mapvote_abstain);
 		WriteByte(MSG_ENTITY, mapvote_detail);
@@ -2267,20 +2297,14 @@
 				if(mapvote_abstain && i == mapvote_count - 1)
 				{
 					WriteString(MSG_ENTITY, ""); // abstain needs no text
+					WriteByte(MSG_ENTITY, 0); // abstain needs no screenshot dir
 					WriteString(MSG_ENTITY, ""); // abstain needs no pack
 				}
 				else
 				{
 					WriteString(MSG_ENTITY, mapvote_maps[i]);
-					mapfile = strcat(mapvote_screenshot_dir, "/", mapvote_maps[i]);
-					pakfile = whichpack(strcat(mapfile, ".tga"));
-					if(pakfile == "")
-						pakfile = whichpack(strcat(mapfile, ".jpg"));
-					if(pakfile == "")
-						pakfile = whichpack(strcat(mapfile, ".png"));
-					for(o = strstr(pakfile, "/", 0)+1; o > 0; o = strstr(pakfile, "/", 0)+1)
-						pakfile = substring(pakfile, o, 999);
-					WriteString(MSG_ENTITY, pakfile);
+					WriteByte(MSG_ENTITY, mapvote_maps_screenshot_dir[i]);
+					WriteString(MSG_ENTITY, mapvote_maps_pakfile[i]);
 				}
 			}
 	}
@@ -2444,6 +2468,8 @@
 							{
 								strunzone(mapvote_maps[i]);
 								mapvote_maps[i] = "";
+								strunzone(mapvote_maps_pakfile[i]);
+								mapvote_maps_pakfile[i] = "";
 							}
 						}
 				}



More information about the nexuiz-commits mailing list