Esempio n. 1
0
static qboolean G_GetVotedMap( char *name, int size, int rotation, int map )
{
  mapRotation_t           *mr;
  mapRotationEntry_t      *mre;
  mapRotationCondition_t  *mrc;
  int                     i, n;
  int                     winner;
  qboolean                found = qfalse;

  if( !rotationVoteLen )
    return qfalse;

  winner = G_GetMapVoteWinner( NULL, NULL, NULL );

  mr = &mapRotations.rotations[ rotation ];
  mre = &mr->maps[ map ];

  n = 0;
  for( i = 0; i < mre->numConditions && n < rotationVoteLen; i++ )
  {
    mrc = &mre->conditions[ i ];

    if( mrc->lhs == MCV_VOTE )
    {
      if( n == winner )
      {
        Q_strncpyz( name, mrc->dest, size );
        found = qtrue;
        break;
      }
      n++;
    }
  }

  rotationVoteLen = 0;

  return found;
}
Esempio n. 2
0
static void G_IntermissionMapVoteMessageReal( gentity_t *ent, int winner, int winvotes, int totalvotes, int *ranklist )
{
  int  clientNum;
  char string[ MAX_STRING_CHARS ];
  char entry[ MAX_STRING_CHARS ];
  int  ourlist[ MAX_MAP_ROTATION_CONDS ];
  int  len = 0;
  int  index, selection;
  int  i;
  char *color;
  char *rank;

  clientNum = ent-g_entities;

  index = rotationVoteClientSelection[ clientNum ];
  selection = rotationVoteClientPosition[ clientNum ];

  if( winner < 0 || winner >= MAX_MAP_ROTATION_CONDS || ranklist == NULL )
  {
    ranklist = &ourlist[0];
    winner = G_GetMapVoteWinner( &winvotes, &totalvotes, ranklist );
  }

  Q_strncpyz( string, "^7Attack^5=^7Down Repair^5=^7Up F1^5=^7Vote\n\n"
    "^7Map Vote Menu\n"
    "^5+^7------------------^5+\n", sizeof( string ) );
  for( i = 0; i < rotationVoteLen; i++ )
  {
    if( i == selection )
      color = "^5";
    else if( i == index )
      color = "^5";
    else
      color = "^7";

    switch( ranklist[ i ] )
    {
      case 0:
        rank = "^7---";
        break;
      case 1:
        rank = "^7--";
        break;
      case 2:
        rank = "^7-";
        break;
      default:
        rank = "";
        break;
    }

    Com_sprintf( entry, sizeof( entry ), "^7%s%s%s%s %s %s%s^7%s\n",
     ( i == index ) ? "^1>>>" : "",
     ( i == selection ) ? "^7(" : " ",
     rank,
     color,
     rotationVoteList[ i ],
     rank,
     ( i == selection ) ? "^7)" : " ",
     ( i == index ) ? "^1<<<" : "" );

    Q_strcat( string, sizeof( string ), entry );
    len += strlen( entry );
  }

  Com_sprintf( entry, sizeof( entry ),
    "\n^5+^7------------------^5+\nLeader: ^5%s^7 (^5%d ^7of ^5%d^7)\nVoters: ^5%d\nTime Left: ^5%d",
    rotationVoteList[ winner ],
    winvotes,
    totalvotes,
    totalvotes,
    ( level.mapRotationVoteTime - level.time ) / 1000 );
  Q_strcat( string, sizeof( string ), entry );

  trap_SendServerCommand( ent-g_entities, va( "cp \"%s\"\n", string ) );
}