Пример #1
0
void _KickVoteSelected (edict_t * ent, pmenu_t * p)
{
	PMenu_Close (ent);
	if (xMenu_New (ent, KICKMENUTITLE, "vote for a player to kick",
		_AddKickuserToMenu) == false)
		gi.cprintf (ent, PRINT_MEDIUM, "No player to kick.\n");
}
Пример #2
0
Файл: p_hud.c Проект: qbism/tmg
/*
==================
Cmd_Score_f

Display the scoreboard
==================
*/
void Cmd_Score_f (edict_t *ent)
{
	ent->client->showinventory = false;
	ent->client->showhelp = false;

//RAV
if (ent->client->resp.menu_time == level.framenum)
return; // do not update twice prevent netchan bug, overflows

ent->client->resp.menu_time = level.framenum+1;
//

//ZOID
	if (ent->client->menu)
		PMenu_Close(ent);
//ZOID

	if (!deathmatch->value && !coop->value)
		return;

	if (ent->client->showscores)
	{
		ent->client->showscores = false;
		return;
	}
	
	ent->client->showscores = true;
	DeathmatchScoreboard (ent);
}
Пример #3
0
/*
==================
Cmd_Score_f

Display the scoreboard
==================
*/
void Cmd_Score_f (edict_t *ent)
{
	//ent->client->showinventory = false;
	//ent->client->showhelp = false;

	if (ent->client->pers.menu.active)
	{
		PMenu_Close (ent);
		return;
	}

	ent->client->showmotd = false;

	// wision: switch between showing oldscore and current score during warmup
	if (ent->client->showoldscores)
	{
		ent->client->showoldscores = false;
		return;
	}

	if (tdm_match_status < MM_COUNTDOWN && ent->client->showscores && old_matchinfo.scoreboard_string[0])
	{
		TDM_OldScores_f (ent);
		return;
	}

	if (ent->client->showscores)
	{
		ent->client->showscores = false;
		return;
	}

	ent->client->showscores = true;
	DeathmatchScoreboard (ent);
}
Пример #4
0
/*
==============
TDM_ShowTeamMenu
==============
Show/hide the join team menu
*/
void TDM_ShowTeamMenu (edict_t *ent)
{
	if (ent->client->pers.menu.active)
	{
		// if the votemenu is open, go back to normal menu
		// close the menu after this condition!
		if (ent->client->pers.votemenu_values.show)
		{
			PMenu_Close (ent);
			PMenu_Open (ent, ent->client->pers.joinmenu, teamJoinEntries[ent->client->pers.team], MENUSIZE_JOINMENU, false);
		}
		else
			PMenu_Close (ent);
	}
	else
		PMenu_Open (ent, ent->client->pers.joinmenu, teamJoinEntries[ent->client->pers.team], MENUSIZE_JOINMENU, false);
}
Пример #5
0
void _IgnoreVoteSelected (edict_t * ent, pmenu_t * p)
{
  PMenu_Close (ent);
  if (xMenu_New
      (ent, IGNOREMENUTITLE, "de-/select a player to ignore",
       _AddIgnoreuserToMenu) == false)
    gi.cprintf (ent, PRINT_MEDIUM, "No player to ignore.\n");
}
Пример #6
0
void ConfigVoteMenu (edict_t * ent, pmenu_t * p)
{
  char buf[1024], sbuf[512];

  PMenu_Close (ent);
  if (_ConfigMostVotesStr (sbuf));
  sprintf (buf, "most: %s", sbuf);
  if (xMenu_New (ent, CONFIGMENUTITLE, buf, AddConfigToMenu) == false)
    gi.cprintf (ent, PRINT_MEDIUM, "No config to vote for.\n");
}
Пример #7
0
/*
=================
Cmd_PutAway_f
=================
*/
void Cmd_PutAway_f(edict_t *ent){
	ent->client->showscores = false;
	ent->client->showhelp = false;
	ent->client->showinventory = false;
	//ZOID
	if(ent->client->menu)
		PMenu_Close(ent);
	ent->client->update_chase = true;
	//ZOID
}
Пример #8
0
/*
=================
Cmd_PutAway_f
=================
*/
void Cmd_PutAway_f (edict_t * ent)
{
	ent->client->showscores = false;
	ent->client->showhelp = false;
	ent->client->showinventory = false;
//FIREBLADE
	if (ent->client->menu)
		PMenu_Close (ent);
//FIREBLADE
}
Пример #9
0
void MapVoteMenu (edict_t * ent, pmenu_t * p)
{
	char buf[1024], sbuf[512];

	PMenu_Close (ent);
	if (_MostVotesStr (sbuf));
		sprintf (buf, "most: %s", sbuf);
	if (xMenu_New (ent, MAPMENUTITLE, buf, AddMapToMenu) == false)
		gi.cprintf (ent, PRINT_MEDIUM, "No map to vote for.\n");
}
Пример #10
0
void MoveClientToIntermission (edict_t *ent)
{
	PMenu_Close (ent);

	//MM_SCOREBOARD will set the layout
	ent->client->showoldscores = false;
	ent->client->showscores = false;
	ent->client->showmotd = false;

	VectorCopy (level.intermission_origin, ent->s.origin);

	ent->client->ps.pmove.origin[0] = level.intermission_origin[0]*8;
	ent->client->ps.pmove.origin[1] = level.intermission_origin[1]*8;
	ent->client->ps.pmove.origin[2] = level.intermission_origin[2]*8;
	
	VectorCopy (level.intermission_angle, ent->client->ps.viewangles);
	VectorCopy (level.intermission_angle, ent->client->v_angle);

	ent->client->ps.pmove.pm_type = PM_FREEZE;
	ent->client->ps.gunindex = 0;
	ent->client->ps.blend[3] = 0;
	ent->client->ps.rdflags &= ~RDF_UNDERWATER;

	// clean up powerup info
	ent->client->quad_framenum = 0;
	ent->client->invincible_framenum = 0;
	ent->client->breather_framenum = 0;
	ent->client->enviro_framenum = 0;
	ent->client->grenade_state = GRENADE_NONE;
	ent->client->grenade_time = 0;

	ent->waterlevel = 0;
	ent->watertype = 0;

	//simulate player height
	ent->viewheight = 22;

	ent->s.modelindex = 0;
	ent->s.modelindex2 = 0;
	ent->s.modelindex3 = 0;
	ent->s.modelindex = 0;
	ent->s.effects = 0;
	ent->s.sound = 0;
	ent->s.event = 0;
	ent->solid = SOLID_NOT;
	ent->client->weapon = NULL;
	ent->client->weapon_sound = 0;

	// add the layout
	gi.WriteByte (svc_layout);
	gi.WriteString (TDM_ScoreBoardString (ent));
	gi.unicast (ent, true);
}
Пример #11
0
void xMenu_Next (edict_t * ent, pmenu_t * p)
{
	X_MENU->xmenucount = 2;
	X_MENU->DoAddMenu (ent, X_MENU->xmenutop + XMENU_MAX_ENTRIES);
	if (X_MENU->xmenucount > 2)
	{
		X_MENU->xmenutop += XMENU_MAX_ENTRIES;
		xMenu_Set (ent);

		PMenu_Close (ent);
		PMenu_Open (ent, X_MENU->themenu, 5, XMENU_END_ENTRY);
		//PMenu_Update(ent);
	}
}
Пример #12
0
/*
==============
JoinedTeam
==============
A player just joined a team, so do things.
*/
void JoinedTeam (edict_t *ent, qboolean reconnected, qboolean notify)
{
	PMenu_Close (ent);

	if (notify)
	{
		if (g_gamemode->value != GAMEMODE_1V1)
			gi.bprintf (PRINT_HIGH, "%s %sjoined team '%s'\n", ent->client->pers.netname, reconnected ? "re" : "", teaminfo[ent->client->pers.team].name);
		else
			gi.bprintf (PRINT_HIGH, "%s %sjoined the game.\n", ent->client->pers.netname, reconnected ? "re" : "");
	}

	ent->client->resp.ready = false;

	//joining a team with no captain by default assigns.
	//FIXME: should this still assign even if the team has existing players?
	if (!teaminfo[ent->client->pers.team].captain)
		TDM_SetCaptain (ent->client->pers.team, ent);

	//nasty hack for setting team names for 1v1 mode
	TDM_UpdateTeamNames ();

	//if we were invited mid-game, reallocate and insert into teamplayers
	// wision: do not add if a player reconnected and used his joincode
	// skuller: force add if player was picked/invited to the different team
	if (tdm_match_status != MM_WARMUP && !reconnected && (!ent->client->resp.teamplayerinfo || ent->client->resp.teamplayerinfo->team != ent->client->pers.team))
		TDM_AddPlayerToMatchinfo (ent);

	//wision: set skin for new player
	gi.configstring (CS_PLAYERSKINS + (ent - g_edicts) - 1, va("%s\\%s", ent->client->pers.netname, teaminfo[ent->client->pers.team].skin));

	//set everyone elses teamskin for this player based on what team he is on
	TDM_SetAllTeamSkins (ent);

	//set this players teamskins based on his team
	TDM_SetTeamSkins (ent, NULL);

	if (g_gamemode->value != GAMEMODE_1V1)
		gi.configstring (CS_TDM_SPECTATOR_STRINGS + (ent - g_edicts) - 1, va ("%s (%s)", ent->client->pers.netname, teaminfo[ent->client->pers.team].name));
	else
		gi.configstring (CS_TDM_SPECTATOR_STRINGS + (ent - g_edicts) - 1, ent->client->pers.netname);

	TDM_TeamsChanged ();
	respawn (ent);

	// switch from spec to player statusbar, if weapon hud is enabled, that'll happen in respawn()
	if (!UF(ent, WEAPON_HUD)) {
		TDM_UpdateHud(ent, true);
	}
}
Пример #13
0
/*
=================
Cmd_Inven_f
=================
*/
void Cmd_Inven_f (edict_t * ent)
{
	int i;
	gclient_t *cl;

	cl = ent->client;

	cl->showscores = false;
	cl->showhelp = false;

	//FIREBLADE
	if (ent->client->menu)
	{
		PMenu_Close (ent);
		return;
	}
	//FIREBLADE

	if (cl->showinventory)
	{
		cl->showinventory = false;
		return;
	}

	//FIREBLADE
	if (teamdm->value || ctf->value == 2) {
		if (ent->client->resp.team == NOTEAM) {
			OpenJoinMenu (ent);
			return;
		}
	}
	else if (teamplay->value)
	{
		if (ent->client->resp.team == NOTEAM)
			OpenJoinMenu (ent);
		else
			OpenWeaponMenu (ent);
		return;
	}
	//FIREBLADE

	cl->showinventory = true;

	gi.WriteByte (svc_inventory);
	for (i = 0; i < MAX_ITEMS; i++)
	{
		gi.WriteShort (cl->pers.inventory[i]);
	}
	gi.unicast (ent, true);
}
Пример #14
0
static void select_test(edict_t *ent)
{
    switch (ent->client->menu.cur) {
    case 3:
        if (ent->client->pers.connected == CONN_SPAWNED) {
            if (G_SpecRateLimited(ent)) {
                break;
            }
            spectator_respawn(ent, CONN_SPECTATOR);
            break;
        }
        if (ent->client->pers.connected != CONN_PREGAME) {
            if (G_SpecRateLimited(ent)) {
                break;
            }
        }
        spectator_respawn(ent, CONN_SPAWNED);
        break;
    case 5:
        if (become_spectator(ent)) {
            if (ent->client->chase_target) {
                SetChaseTarget(ent, NULL);
            }
            PMenu_Close(ent);
        }
        break;
    case 6:
        if (become_spectator(ent)) {
            if (!ent->client->chase_target) {
                GetChaseTarget(ent, CHASE_NONE);
            }
            PMenu_Close(ent);
        }
        break;
    case 7:
        if (become_spectator(ent)) {
            GetChaseTarget(ent, CHASE_LEADER);
            PMenu_Close(ent);
        }
        break;
    case 8:
        if (become_spectator(ent)) {
            GetChaseTarget(ent, CHASE_QUAD);
            PMenu_Close(ent);
        }
        break;
    case 9:
        if (become_spectator(ent)) {
            GetChaseTarget(ent, CHASE_INVU);
            PMenu_Close(ent);
        }
        break;
    case 11:
        PMenu_Close(ent);
        break;
    }
}
Пример #15
0
// Note that the pmenu entries are duplicated
// this is so that a static set of pmenu entries can be used
// for multiple clients and changed without interference
// note that arg will be freed when the menu is closed, it must be allocated memory
pmenuhnd_t *PMenu_Open(edict_t *ent, pmenu_t *entries, int cur, int num, void *arg)
{
	pmenuhnd_t *hnd;
	pmenu_t *p;
	int i;

	if (!ent->client)
		return NULL;

	if (ent->client->menu) {
		gi.dprintf("warning, ent already has a menu\n");
		PMenu_Close(ent);
	}

	hnd = (pmenuhnd_t*)G_Malloc(sizeof(*hnd));

	hnd->arg = arg;
	hnd->entries = (struct pmenu_s*)G_Malloc(sizeof(pmenu_t) * num);
    memcpy(hnd->entries, entries, sizeof(pmenu_t) * num);

    // duplicate the strings since they may be from static memory
	for (i = 0; i < num; i++)
		if (entries[i].text)
			hnd->entries[i].text = G_CopyString(entries[i].text);

	hnd->num = num;

	if (cur < 0 || !entries[cur].SelectFunc) {
		for (i = 0, p = entries; i < num; i++, p++)
			if (p->SelectFunc)
				break;
	} else
		i = cur;

	if (i >= num)
		hnd->cur = -1;
	else
		hnd->cur = i;

	ent->client->showscores = true;
	ent->client->inmenu = true;
	ent->client->menu = hnd;

	PMenu_Update(ent);
	gi.unicast (ent, true);

	return hnd; // Knightmare added
}
Пример #16
0
qboolean
xMenu_New (edict_t * ent, char *title, char *subtitle,
	   void (*DoAddMenu) (edict_t * ent, int fromix))
{
	if (!DoAddMenu)
		return false;

	if (!X_MENU)
	{
		//no menu yet, allocate memory for it...
		X_MENU = gi.TagMalloc (sizeof (xmenu_t), TAG_GAME);
		if (!X_MENU)
		{
			gi.dprintf ("Error allocating xmenu space\n");
			return false;
		}
	}
	X_MENU->DoAddMenu = DoAddMenu;
	X_MENU->xmenucount = 2;
	X_MENU->xmenutop = 0;
	//memset(xmenuentries, 0, sizeof(xmenuentries));
	strcpy (X_MENU->xmenuentries[0].name, "*");
	if (title)
		Q_strncatz(X_MENU->xmenuentries[0].name, title, XMENU_TITLE_MAX);
	else
		Q_strncatz(X_MENU->xmenuentries[0].name, "Menu", XMENU_TITLE_MAX);
	if (subtitle)
		Q_strncpyz(X_MENU->xmenuentries[1].name, subtitle, XMENU_TITLE_MAX);
	else
		Q_strncpyz(X_MENU->xmenuentries[1].name, "make your choice", XMENU_TITLE_MAX);

	X_MENU->xmenuentries[0].SelectFunc = NULL;
	X_MENU->xmenuentries[1].SelectFunc = NULL;

	DoAddMenu (ent, 0);
	if (X_MENU->xmenucount > 2)
	{
		xMenu_Set (ent);

		if (ent->client->menu)
			PMenu_Close (ent);

		PMenu_Open (ent, X_MENU->themenu, 5, XMENU_END_ENTRY);
		return true;
	}

	return false;
}
Пример #17
0
void ConfigSelected (edict_t * ent, pmenu_t * p)
{
  char *ch;

  ch = p->text;
  if (ch)
    {
      while (*ch != ' ' && *ch != '\0')
	ch++;
      *ch = '\0';
    }
  ch = p->text;
  if (ch && *ch == '*')
    ch++;
  PMenu_Close (ent);
  Cmd_Voteconfig_f (ent, ch);
}
Пример #18
0
void MapSelected (edict_t * ent, pmenu_t * p)
{
	char *ch;

	ch = p->text;
	if (ch)
	{
		while (*ch != ' ' && *ch != '\0')
			ch++;
		*ch = '\0';
	}
	ch = p->text;
	if (ch && *ch == '*')
		ch++;
	PMenu_Close (ent);
	Votemap(ent, ch);
}
Пример #19
0
void _KickSelected (edict_t * ent, pmenu_t * p)
{
	char *ch;

	ch = p->text;
	if (ch)
	{
		while (*ch != ':' && *ch != '\0')
			ch++;
		*ch = '\0';
	}
	ch = p->text;
	if (ch && *ch == '*')
		ch++;
	PMenu_Close (ent);
	Cmd_Votekicknum_f (ent, ch);
}
Пример #20
0
/*
==============
ToggleChaseCam
==============
Player hit Spectator menu option or used
chase command.
*/
void ToggleChaseCam (edict_t *ent)
{
    if (ent->client->pers.team)
    {
        TDM_LeftTeam (ent, true);
        TDM_TeamsChanged ();
        if (tdm_match_status == MM_TIMEOUT && teaminfo[TEAM_A].players == 0 && teaminfo[TEAM_B].players == 0)
            TDM_ResumeGame ();
        respawn (ent);
    }

    if (ent->client->chase_target)
        DisableChaseCam (ent);
    else
        GetChaseTarget(ent);

    PMenu_Close (ent);
}
Пример #21
0
void xMenu_Prev (edict_t * ent, pmenu_t * p)
{
	int temptop;

	X_MENU->xmenucount = 2;
	if (X_MENU->xmenutop < XMENU_MAX_ENTRIES)
		temptop = 0;
	else
		temptop = X_MENU->xmenutop - XMENU_MAX_ENTRIES;
	X_MENU->DoAddMenu (ent, temptop);
	if (X_MENU->xmenucount > 2)
	{
		X_MENU->xmenutop = temptop;
		xMenu_Set (ent);

		PMenu_Close (ent);
		PMenu_Open (ent, X_MENU->themenu, 5, XMENU_END_ENTRY);
		//PMenu_Update(ent);
	}
}
Пример #22
0
Файл: p_menu.c Проект: ZwS/qudos
void PMenu_Open(edict_t *ent, pmenu_t *entries, int cur, int num)
{
	pmenuhnd_t *hnd;
	pmenu_t *p;
	int i;

	if (!ent->client)
		return;

	if (ent->client->menu) {
		gi.dprintf("warning, ent already has a menu\n");
		PMenu_Close(ent);
	}

	hnd = malloc(sizeof(*hnd));

	hnd->entries = entries;
	hnd->num = num;

	if (cur < 0 || !entries[cur].SelectFunc) {
		for (i = 0, p = entries; i < num; i++, p++)
			if (p->SelectFunc)
				break;
	} else
		i = cur;

	if (i >= num)
		hnd->cur = -1;
	else
		hnd->cur = i;

	ent->client->showscores = true;
	ent->client->inmenu = true;
	ent->client->menu = hnd;

	if(!(ent->svflags & SVF_MONSTER))
	{
		PMenu_Update(ent);
		gi.unicast (ent, true);
	}
}
Пример #23
0
void
Cmd_Inven_f(edict_t *ent)
{
    int i;
    gclient_t *cl;

    cl = ent->client;

    cl->showscores = false;
    cl->showhelp = false;

    if (ent->client->menu)
    {
        PMenu_Close(ent);
        ent->client->update_chase = true;
        return;
    }

    if (cl->showinventory)
    {
        cl->showinventory = false;
        return;
    }

    if (ctf->value && (cl->resp.ctf_team == CTF_NOTEAM))
    {
        CTFOpenJoinMenu(ent);
        return;
    }

    cl->showinventory = true;

    gi.WriteByte(svc_inventory);

    for (i = 0; i < MAX_ITEMS; i++)
    {
        gi.WriteShort(cl->pers.inventory[i]);
    }

    gi.unicast(ent, true);
}
Пример #24
0
void Cmd_Menu_f(edict_t *ent)
{
    if (ent->client->layout == LAYOUT_MENU) {
        PMenu_Close(ent);
        return;
    }

    PMenu_Open(ent, main_menu);

    switch (ent->client->pers.connected) {
    case CONN_PREGAME:
    case CONN_SPECTATOR:
        ent->client->menu.entries[3].text = "*Enter the game";
        break;
    case CONN_SPAWNED:
        ent->client->menu.entries[3].text = "*Leave the game";
        break;
    default:
        return;
    }
}
Пример #25
0
void _IgnoreSelected (edict_t * ent, pmenu_t * p)
{
	char *ch;

	ch = p->text;
	if (ch)
	{
		while (*ch != ':' && *ch != '\0')
			ch++;
		*ch = '\0';
	}
	ch = p->text;
	if (ch) {
		if (*ch == '*')
			ch++;
		while (*ch == ' ')
			ch++;
	}
	PMenu_Close(ent);
	IgnorePlayer(ent, ch);
}
Пример #26
0
/*
==================
Cmd_Score_f

Display the scoreboard
==================
*/
void Cmd_Score_f (edict_t *ent)
{
	ent->client->showinventory = false;
	ent->client->showhelp = false;


//ZOID
	if (ent->client->menu)
		PMenu_Close(ent);
//ZOID
	if (!deathmatch->value && !coop->value)
		return;

	if (ent->client->showscores)
	{
		ent->client->showscores = false;
		return;
	}

	ent->client->showscores = true;
	DeathmatchScoreboard (ent);
}
Пример #27
0
/*
==============
OpenVoteMenu
==============
Update vote menu with current settings and open it.
*/
void OpenVoteMenu (edict_t *ent)
{
    //global 'disallow voting' check
    if (!(int)g_vote_mask->value)
    {
        gi.cprintf (ent, PRINT_HIGH, "Proposing new settings is not allowed on this server.\n");
        return;
    }

    if (!ent->client->pers.team && !ent->client->pers.admin)
    {
        gi.cprintf (ent, PRINT_HIGH, "Spectators cannot vote.\n");
        return;
    }

    // allow timelimit vote during the match
    if (tdm_match_status == MM_PLAYING && ((int)g_vote_mask->value & VOTE_TIMELIMIT))
    {
        ent->client->pers.votemenu_values.timelimit = ((int)g_match_time->value / 60);
        memcpy (ent->client->pers.votemenu, votemenu, sizeof(votemenu));
        VoteMenuUpdate (ent, VOTE_MENU_TIMELIMIT);

        PMenu_Close (ent);
        PMenu_Open (ent, ent->client->pers.votemenu, 0, MENUSIZE_JOINMENU, false);
        return;
    }
    else if (tdm_match_status != MM_WARMUP)
    {
        gi.cprintf (ent, PRINT_HIGH, "You can propose new settings only during warmup.\n");
        return;
    }

    // initialize all current settings
    ent->client->pers.votemenu_values.gamemode = (int)g_gamemode->value;

    // if we don't use maplist we cannot tell what maps are allowed :(
    if (!g_maplistfile || !g_maplistfile->string[0])
        ent->client->pers.votemenu_values.map[0] = '\0';
    else
    {
        strcpy (ent->client->pers.votemenu_values.map, "---");
        ent->client->pers.votemenu_values.map_index = -1;
    }

    if (!g_allow_vote_config->value)
        ent->client->pers.votemenu_values.config[0] = '\0';
    else
    {
        strcpy (ent->client->pers.votemenu_values.config, "---");
        ent->client->pers.votemenu_values.cfg_index = -1;
    }

    ent->client->pers.votemenu_values.timelimit = ((int)g_match_time->value / 60);

    if (g_tie_mode->value == 1)
        ent->client->pers.votemenu_values.overtime = ((int)g_overtime->value / 60);
    else if (g_tie_mode->value == 2)
        ent->client->pers.votemenu_values.overtime = -1;
    else
        ent->client->pers.votemenu_values.overtime = 0;

    if (g_powerupflags->value == 0)
        ent->client->pers.votemenu_values.powerups = 1;
    else
        ent->client->pers.votemenu_values.powerups = 0;

    if ((int)g_itemflags->value & WEAPON_BFG10K)
        ent->client->pers.votemenu_values.bfg = 0;
    else
        ent->client->pers.votemenu_values.bfg = 1;

    ent->client->pers.votemenu_values.kick = NULL;
    ent->client->pers.votemenu_values.chat = (int)g_chat_mode->value;
    ent->client->pers.votemenu_values.bugs = (int)g_bugs->value;

    // set increasing values as default (used for invdrop)
    ent->client->pers.votemenu_values.decrease = false;

    memcpy (ent->client->pers.votemenu, votemenu, sizeof(votemenu));

    VoteMenuUpdate (ent, VOTE_MENU_ALL);

    // we are supposed to be here only from menu, so close it
    PMenu_Close (ent);

    ent->client->pers.votemenu_values.show = true;
    PMenu_Open (ent, ent->client->pers.votemenu, 0, MENUSIZE_JOINMENU, false);
}
Пример #28
0
void _VoteScrambleSelected (edict_t * ent, pmenu_t * p)
{
	PMenu_Close(ent);

	Cmd_Votescramble_f(ent);
}
Пример #29
0
/* Note that the pmenu entries are duplicated 
   this is so that a static set of pmenu entries can be used 
   for multiple clients and changed without interference 
   note that arg will be freed when the menu is closed, it
    must be allocated memory */
pmenuhnd_t *
PMenu_Open(edict_t *ent, pmenu_t *entries, int cur, int num, void *arg)
{
	pmenuhnd_t *hnd;
	pmenu_t *p;
	int i;

	if (!ent->client)
	{
		return NULL;
	}

	if (ent->client->menu)
	{
		gi.dprintf(DEVELOPER_MSG_GAME, "warning, ent already has a menu\n");
		PMenu_Close(ent);
	}

	hnd = malloc(sizeof(*hnd));

	hnd->arg = arg;
	hnd->entries = malloc(sizeof(pmenu_t) * num);
	memcpy(hnd->entries, entries, sizeof(pmenu_t) * num);

	/* duplicate the strings since they may be from static memory */
	for (i = 0; i < num; i++)
	{
		if (entries[i].text)
		{
			hnd->entries[i].text = strdup(entries[i].text);
		}
	}

	hnd->num = num;

	if ((cur < 0) || !entries[cur].SelectFunc)
	{
		for (i = 0, p = entries; i < num; i++, p++)
		{
			if (p->SelectFunc)
			{
				break;
			}
		}
	}
	else
	{
		i = cur;
	}

	if (i >= num)
	{
		hnd->cur = -1;
	}
	else
	{
		hnd->cur = i;
	}

	ent->client->showscores = true;
	ent->client->inmenu = true;
	ent->client->menu = hnd;

	PMenu_Do_Update(ent);
	gi.unicast(ent, true);

	return hnd;
}