}
}
-void MapVote_Init()
+void MapVote_ReadOption(int i)
{
- int i, j;
- string map, pk3, s;
+ string map = strzone(ReadString());
+ string pk3 = strzone(ReadString());
+ int j = bound(0, ReadByte(), n_ssdirs - 1);
+
+ mv_maps[i] = map;
+ mv_pk3[i] = pk3;
+ mv_flags[i] = GTV_AVAILABLE;
+
+ string pic = strzone(strcat(ssdirs[j], "/", map));
+ mv_pics[i] = pic;
+ mv_preview[i] = false;
+ MapVote_CheckPic(pic, pk3, i);
+}
+
+void GameTypeVote_ReadOption(int i)
+{
+ dprint(sprintf("\n\n^3==========\nReading %d\n\n",i));
+ string gt = strzone(ReadString());
+
+ mv_maps[i] = gt;
+ mv_pk3[i] = string_null;
+ mv_flags[i] = ReadByte();
+
+ string mv_picpath = sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, gt);
+ if(precache_pic(mv_picpath) == "")
+ mv_picpath = strcat("gfx/menu/default/gametype_", gt);
+ string pic = strzone(mv_picpath);
+ mv_pics[i] = pic;
+ mv_preview[i] = PreviewExists(pic);
+
+ if ( mv_flags[i] & GTV_CUSTOM )
+ {
+ ReadString(); // name
+ ReadString(); // description
+ }
+}
+void MapVote_Init()
+{
precache_sound ("misc/invshot.wav");
mv_active = 1;
mv_selection = -1;
mv_selection_keyboard = 0;
+ string s;
for(n_ssdirs = 0; ; ++n_ssdirs)
{
s = ReadString();
}
MapVote_ReadMask();
+ int i;
for(i = 0; i < mv_num_maps; ++i )
mv_flags_start[i] = mv_flags[i];
{
mv_votes[i] = 0;
- map = strzone(ReadString());
- pk3 = strzone(ReadString());
- j = bound(0, ReadByte(), n_ssdirs - 1);
-
- mv_maps[i] = map;
- mv_pk3[i] = pk3;
- mv_flags[i] = ReadByte();
-
- if(gametypevote)
- {
- //map = strzone(strcat("gfx/menu/default/gametype_", map));
- //map = strzone(sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, map));
- string mv_picpath = sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, map);
- if(precache_pic(mv_picpath) == "")
- mv_picpath = strcat("gfx/menu/default/gametype_", map);
- map = strzone(mv_picpath);
- mv_pics[i] = map;
- mv_preview[i] = PreviewExists(map);
- }
+ if ( gametypevote )
+ GameTypeVote_ReadOption(i);
else
- {
- map = strzone(strcat(ssdirs[j], "/", map));
- mv_pics[i] = map;
- mv_preview[i] = false;
- MapVote_CheckPic(map, pk3, i);
- }
+ MapVote_ReadOption(i);
}
for(i = 0; i < n_ssdirs; ++i)
return type;
}
-int GameTypeVote_AvailabilityStatus(string gtname)
+int GameTypeVote_AvailabilityStatus(string type_name)
{
- float type = GameTypeVote_Type_FromString(gtname);
+ int flag = GTV_FORBIDDEN;
+
+ float type = MapInfo_Type_FromString(type_name);
+ if ( type == 0 )
+ {
+ type = MapInfo_Type_FromString(cvar_string(
+ strcat("sv_vote_gametype_",type_name,"_type")));
+ flag |= GTV_CUSTOM;
+ }
+
if( type == 0 )
- return GTV_FORBIDDEN;
+ return flag;
if ( autocvar_nextmap != "" )
{
if ( !MapInfo_Get_ByName(autocvar_nextmap, false, 0) )
- return GTV_FORBIDDEN;
+ return flag;
if (!(MapInfo_Map_supportedGametypes & type))
- return GTV_FORBIDDEN;
+ return flag;
}
- return GTV_AVAILABLE;
+ return flag | GTV_AVAILABLE;
}
float GameTypeVote_GetMask()
}
}
+/*
+ * Sends a single map vote option to the client
+ */
+void MapVote_SendOption(int i)
+{
+ // abstain
+ if(mapvote_abstain && i == mapvote_count - 1)
+ {
+ WriteString(MSG_ENTITY, ""); // abstain needs no text
+ WriteString(MSG_ENTITY, ""); // abstain needs no pack
+ WriteByte(MSG_ENTITY, 0); // abstain needs no screenshot dir
+ }
+ else
+ {
+ WriteString(MSG_ENTITY, mapvote_maps[i]);
+ WriteString(MSG_ENTITY, mapvote_maps_pakfile[i]);
+ WriteByte(MSG_ENTITY, mapvote_maps_screenshot_dir[i]);
+ }
+}
+
+/*
+ * Sends a single gametype vote option to the client
+ */
+void GameTypeVote_SendOption(int i)
+{
+ // abstain
+ if(mapvote_abstain && i == mapvote_count - 1)
+ {
+ WriteString(MSG_ENTITY, ""); // abstain needs no text
+ WriteByte(MSG_ENTITY, GTV_AVAILABLE);
+ }
+ else
+ {
+ string type_name = mapvote_maps[i];
+ WriteString(MSG_ENTITY, type_name);
+ WriteByte(MSG_ENTITY, mapvote_maps_flags[i]);
+ if ( mapvote_maps_flags[i] & GTV_CUSTOM )
+ {
+ WriteString(MSG_ENTITY, cvar_string(
+ strcat("sv_vote_gametype_",type_name,"_name")));
+ WriteString(MSG_ENTITY, cvar_string(
+ strcat("sv_vote_gametype_",type_name,"_description")));
+ }
+ }
+}
+
float MapVote_SendEntity(entity to, int sf)
{
float i;
}
else if ( autocvar_sv_vote_gametype )
{
- // map vote but gametype has been chosen via voting screen
+ // map vote but gametype has been chosen via voting screen
WriteByte(MSG_ENTITY, 2);
WriteString(MSG_ENTITY, MapInfo_Type_ToText(MapInfo_CurrentGametype()));
}
// Send data for the vote options
for(i = 0; i < mapvote_count; ++i)
{
- if(mapvote_abstain && i == mapvote_count - 1)
- {
- WriteString(MSG_ENTITY, ""); // abstain needs no text
- WriteString(MSG_ENTITY, ""); // abstain needs no pack
- WriteByte(MSG_ENTITY, 0); // abstain needs no screenshot dir
- WriteByte(MSG_ENTITY, GTV_AVAILABLE);
- }
+ if(gametypevote)
+ GameTypeVote_SendOption(i);
else
- {
- WriteString(MSG_ENTITY, mapvote_maps[i]);
- WriteString(MSG_ENTITY, mapvote_maps_pakfile[i]);
- WriteByte(MSG_ENTITY, mapvote_maps_screenshot_dir[i]);
- WriteByte(MSG_ENTITY, mapvote_maps_flags[i]);
- }
+ MapVote_SendOption(i);
}
}
{
if(mapvote_detail)
for(i = 0; i < mapvote_count; ++i)
- if ( mapvote_maps_flags[i] == GTV_AVAILABLE )
+ if ( mapvote_maps_flags[i] & GTV_AVAILABLE )
WriteByte(MSG_ENTITY, mapvote_selections[i]);
WriteByte(MSG_ENTITY, to.mapvote);