string mv_pk3[MAPVOTE_COUNT];
float mv_preview[MAPVOTE_COUNT];
float mv_votes[MAPVOTE_COUNT];
-float mv_avail[MAPVOTE_COUNT];
-float mv_avail_start[MAPVOTE_COUNT];
+float mv_flags[MAPVOTE_COUNT];
+float mv_flags_start[MAPVOTE_COUNT];
entity mv_pk3list;
float mv_abstain;
float mv_ownvote;
{
if(_count == 1)
post = _(" (1 vote)");
- else if(_count >= 0 && mv_avail[id] == GTV_AVAILABLE)
+ else if(_count >= 0 && (mv_flags[id] & GTV_AVAILABLE))
post = sprintf(_(" (%d votes)"), _count);
else
post = "";
vector MapVote_RGB(int id)
{
- if(mv_avail[id] != GTV_AVAILABLE)
+ if(!(mv_flags[id] & GTV_AVAILABLE))
return '1 1 1';
if(id == mv_ownvote)
return '0 1 0';
vector offset = pos;
float nlines = 0;
- if(mv_avail_start[id] != GTV_AVAILABLE)
+ if(!(mv_flags_start[id] & GTV_AVAILABLE))
alpha = 0.2;
- else if ( mv_avail[id] != GTV_AVAILABLE && mv_top2_alpha)
+ else if ( !(mv_flags[id] & GTV_AVAILABLE) && mv_top2_alpha)
alpha = mv_top2_alpha;
else
alpha = 1;
- if(id == mv_selection && mv_avail[id] == GTV_AVAILABLE)
+ if(id == mv_selection && (mv_flags[id] & GTV_AVAILABLE))
{
drawfill(rect_pos, rect_size, '1 1 1', 0.1, DRAWFLAG_NORMAL);
}
text_size = stringwidth(label, false, hud_fontsize);
float theAlpha;
- if (mv_avail[id] != GTV_AVAILABLE && mv_top2_alpha)
+ if (!(mv_flags[id] & GTV_AVAILABLE) && mv_top2_alpha)
theAlpha = mv_top2_alpha;
else
theAlpha = 1;
else
drawborderlines(autocvar_scoreboard_border_thickness, pos, img_size, '0 0 0', theAlpha, DRAWFLAG_NORMAL);
- if(id == mv_selection && mv_avail[id] == GTV_AVAILABLE)
+ if(id == mv_selection && (mv_flags[id] & GTV_AVAILABLE))
drawfill(pos, img_size, '1 1 1', 0.1, DRAWFLAG_NORMAL);
}
mask = ReadLong();
for(i = 0, power = 1; i < mv_num_maps; ++i, power *= 2)
- mv_avail[i] = (mask & power) ? GTV_AVAILABLE : GTV_FORBIDDEN;
+ {
+ if ( mask & power )
+ mv_flags[i] |= GTV_AVAILABLE;
+ else
+ mv_flags[i] &= ~GTV_AVAILABLE;
+ }
}
else
{
for(i = 0; i < mv_num_maps; ++i )
- mv_avail[i] = ReadByte();
+ mv_flags[i] = ReadByte();
}
}
MapVote_ReadMask();
for(i = 0; i < mv_num_maps; ++i )
- mv_avail_start[i] = mv_avail[i];
+ mv_flags_start[i] = mv_flags[i];
// Assume mv_pk3list is world, there should only be 1 mapvote per round
mv_pk3list = world; // I'm still paranoid!
mv_maps[i] = map;
mv_pk3[i] = pk3;
- mv_avail[i] = ReadByte();
+ mv_flags[i] = ReadByte();
if(gametypevote)
{
imp = mv_num_maps - 1;
else
imp = pos < 1 ? mv_num_maps - 1 : pos - 1;
- if ( mv_avail[imp] != GTV_AVAILABLE && imp != mv_ownvote )
+ if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
imp = MapVote_MoveLeft(imp);
return imp;
}
imp = 0;
else
imp = pos >= mv_num_maps - 1 ? 0 : pos + 1;
- if ( mv_avail[imp] != GTV_AVAILABLE && imp != mv_ownvote )
+ if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
imp = MapVote_MoveRight(imp);
return imp;
}
imp -= mv_columns;
}
}
- if ( mv_avail[imp] != GTV_AVAILABLE && imp != mv_ownvote )
+ if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
imp = MapVote_MoveUp(imp);
return imp;
}
if ( imp >= mv_num_maps )
imp = imp % mv_columns;
}
- if ( mv_avail[imp] != GTV_AVAILABLE && imp != mv_ownvote )
+ if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
imp = MapVote_MoveDown(imp);
return imp;
}
int i;
for(i = 0; i < mv_num_maps; ++i)
{
- if(mv_avail[i] == GTV_AVAILABLE)
+ if(mv_flags[i] & GTV_AVAILABLE)
{
if(mv_detail)
mv_votes[i] = ReadByte();
float mapvote_suggestion_ptr;
float mapvote_voters;
float mapvote_selections[MAPVOTE_COUNT];
-float mapvote_maps_availability[MAPVOTE_COUNT];
+float mapvote_maps_flags[MAPVOTE_COUNT];
float mapvote_run;
float mapvote_detail;
float mapvote_abstain;
return type;
}
-float GameTypeVote_AvailabilityStatus(string gtname)
+int GameTypeVote_AvailabilityStatus(string gtname)
{
float type = GameTypeVote_Type_FromString(gtname);
if( type == 0 )
mapvote_maps_screenshot_dir[mapvote_count] = i;
mapvote_maps_pakfile[mapvote_count] = strzone(pakfile);
- mapvote_maps_availability[mapvote_count] = GTV_AVAILABLE;
+ mapvote_maps_flags[mapvote_count] = GTV_AVAILABLE;
mapvote_count += 1;
}
float mask,power;
mask = 0;
for(i = 0, power = 1; i < mapvote_count; ++i, power *= 2)
- if(mapvote_maps_availability[i] == GTV_AVAILABLE )
+ if(mapvote_maps_flags[i] & GTV_AVAILABLE )
mask |= power;
if(mapvote_count < 8)
else
{
for ( i = 0; i < mapvote_count; ++i )
- WriteByte(MSG_ENTITY, mapvote_maps_availability[i]);
+ WriteByte(MSG_ENTITY, mapvote_maps_flags[i]);
}
}
MapVote_WriteMask();
+ // Send data for the vote options
for(i = 0; i < mapvote_count; ++i)
{
if(mapvote_abstain && i == mapvote_count - 1)
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_availability[i]);
+ WriteByte(MSG_ENTITY, mapvote_maps_flags[i]);
}
}
}
{
if(mapvote_detail)
for(i = 0; i < mapvote_count; ++i)
- if ( mapvote_maps_availability[i] == GTV_AVAILABLE )
+ if ( mapvote_maps_flags[i] == GTV_AVAILABLE )
WriteByte(MSG_ENTITY, mapvote_selections[i]);
WriteByte(MSG_ENTITY, to.mapvote);
result = strcat(result, ":", ftos(mapvote_selections[mappos]), "::");
didntvote = mapvote_voters;
for(i = 0; i < mapvote_count; ++i)
- if(mapvote_maps_availability[i] == GTV_AVAILABLE )
+ if(mapvote_maps_flags[i] & GTV_AVAILABLE )
{
didntvote -= mapvote_selections[i];
if(i != mappos)
float i;
for(i = 0; i < mapvote_count; ++i)
- if( mapvote_maps_availability[i] == GTV_AVAILABLE )
+ if( mapvote_maps_flags[i] & GTV_AVAILABLE )
{
//dprint("Map ", ftos(i), ": "); dprint(mapvote_maps[i], "\n");
mapvote_selections[i] = 0;
currentPlace = 0;
currentVotes = -1;
for(i = 0; i < mapvote_count_real; ++i)
- if ( mapvote_maps_availability[i] == GTV_AVAILABLE )
+ if ( mapvote_maps_flags[i] & GTV_AVAILABLE )
{
RandomSelection_Add(world, i, string_null, 1, mapvote_selections[i]);
if ( gametypevote && mapvote_maps[i] == MapInfo_Type_ToString(MapInfo_CurrentGametype()) )
RandomSelection_Init();
for(i = 0; i < mapvote_count_real; ++i)
if(i != firstPlace)
- if ( mapvote_maps_availability[i] == GTV_AVAILABLE )
+ if ( mapvote_maps_flags[i] & GTV_AVAILABLE )
RandomSelection_Add(world, i, string_null, 1, mapvote_selections[i]);
secondPlace = RandomSelection_chosen_float;
secondPlaceVotes = RandomSelection_best_priority;
result = strcat(result, ":", ftos(mapvote_selections[i]));
if(i < mapvote_count_real)
{
- mapvote_maps_availability[i] = GTV_FORBIDDEN;
+ mapvote_maps_flags[i] &= ~GTV_AVAILABLE;
}
}
}
}
// clear possibly invalid votes
- if ( mapvote_maps_availability[other.mapvote-1] != GTV_AVAILABLE )
+ if ( !(mapvote_maps_flags[other.mapvote-1] & GTV_AVAILABLE) )
other.mapvote = 0;
// use impulses as new vote
if(other.impulse >= 1 && other.impulse <= mapvote_count)
- if( mapvote_maps_availability[other.impulse - 1] == GTV_AVAILABLE )
+ if( mapvote_maps_flags[other.impulse - 1] & GTV_AVAILABLE )
{
other.mapvote = other.impulse;
MapVote_TouchVotes(other);
mapvote_maps_screenshot_dir[mapvote_count] = 0;
mapvote_maps_pakfile[mapvote_count] = strzone("");
- mapvote_maps_availability[mapvote_count] = GameTypeVote_AvailabilityStatus(nextMode);
+ mapvote_maps_flags[mapvote_count] = GameTypeVote_AvailabilityStatus(nextMode);
mapvote_count += 1;
for(j = 0; j < n; ++j)
{
if ( GameTypeVote_AddVotable(argv(j)) )
- if ( mapvote_maps_availability[j] == GTV_AVAILABLE )
+ if ( mapvote_maps_flags[j] & GTV_AVAILABLE )
{
really_available++;
which_available = j;