Ejemplo n.º 1
0
// only use on pmenu's that have been called with PMenu_Open
void PMenu_UpdateEntry(pmenu_t *entry, const char *text, int align, SelectFunc_t SelectFunc)
{
	if (entry->text)
		G_Free(entry->text);
	entry->text = G_CopyString((char *)text);
	entry->align = align;
	entry->SelectFunc = SelectFunc;
}
Ejemplo n.º 2
0
/*
=================
EndDMLevel

The timelimit or fraglimit has been exceeded
=================
*/
void EndDMLevel (void)
{
	edict_t		*ent;
	char *s, *t, *f;
	static const char seps[] = " ,\n\r";

	// stay on same level flag
	if ((int)dmflags->value & DF_SAME_LEVEL)
	{
		BeginIntermission (CreateTargetChangeLevel (level.mapname) );
		return;
	}

	// see if it's in the map list
	if (*sv_maplist->string) {
		s = G_CopyString(sv_maplist->string);
		f = NULL;
		t = strtok(s, seps);
		while (t != NULL) {
			if (Q_strcasecmp(t, level.mapname) == 0) {
				// it's in the list, go to the next one
				t = strtok(NULL, seps);
				if (t == NULL) { // end of list, go to first one
					if (f == NULL) // there isn't a first one, same level
						BeginIntermission (CreateTargetChangeLevel (level.mapname) );
					else
						BeginIntermission (CreateTargetChangeLevel (f) );
				} else
					BeginIntermission (CreateTargetChangeLevel (t) );
				G_Free(s);
				return;
			}
			if (!f)
				f = t;
			t = strtok(NULL, seps);
		}
		G_Free(s);
	}

	if (level.nextmap[0]) // go to a specific map
		BeginIntermission (CreateTargetChangeLevel (level.nextmap) );
	else {	// search for a changelevel
		ent = G_Find (NULL, FOFS(classname), "target_changelevel");
		if (!ent)
		{	// the map designer didn't include a changelevel,
			// so create a fake ent that goes back to the same level
			BeginIntermission (CreateTargetChangeLevel (level.mapname) );
			return;
		}
		BeginIntermission (ent);
	}
}
Ejemplo n.º 3
0
static void
G_AddPlayerModel(const char *model)
{
    if (!_is_playermodel_uniq(model))
        return;

    // HACK!
    if (!strcmp(model, "human_bsuit"))
        return;

    level.playerModel[ level.playerModelCount ] = G_CopyString(model);
    level.playerModelCount++;
}
Ejemplo n.º 4
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
}
Ejemplo n.º 5
0
/*
* G_UpdateMapRotation
* 
* Reads current map rotation into internal list
*/
static void G_UpdateMapRotation( void )
{
	int count, i;
	bool thiswhitespace, lastwhitespace, found;
	char *p, *start;
	static const char *seps = " ,\n\r";

	if( g_maplist->modified || !map_rotation_s || !map_rotation_p )
	{
		g_maplist->modified = false;

		// reread the maplist
		if( map_rotation_s )
			G_Free( map_rotation_s );
		if( map_rotation_p )
			G_Free( map_rotation_p );

		map_rotation_s = G_CopyString( g_maplist->string );
		map_rotation_p = NULL;
		map_rotation_current = -1;	// reset the mapcounter too
		map_rotation_count = 0;

		// count the number of tokens
		p = map_rotation_s;
		count = 0;
		lastwhitespace = true;
		start = NULL;
		found = false;
		while( *p )
		{
			thiswhitespace = ( strchr( seps, *p ) != NULL ) ? true : false;
			if( lastwhitespace && !thiswhitespace )
			{
				start = p;
				count++;
			}
			else if( thiswhitespace && !lastwhitespace && !found && start )
			{
				found = true;
				for( i = 0; start + i < p; i++ )
				{
					if( tolower( start[i] ) != tolower( level.mapname[i] ) )
						found = false;
				}
				if( found )
					map_rotation_current = count - 1;
			}

			lastwhitespace = thiswhitespace;
			p++;
		}

		if( !count )
			return;

		// allocate the array of pointers
		map_rotation_p = ( char ** )G_Malloc( ( count + 1 ) * sizeof( *map_rotation_p ) );

		// now convert the string to tokens by nulling the separators
		p = map_rotation_s;
		count = 0;
		lastwhitespace = true;
		while( *p )
		{
			thiswhitespace = ( strchr( seps, *p ) != NULL ) ? true : false;
			if( lastwhitespace && !thiswhitespace )
				map_rotation_p[count++] = p;

			if( thiswhitespace )
				*p = 0;

			lastwhitespace = thiswhitespace;
			p++;
		}

		// final null pointer to mark the end
		map_rotation_p[count] = NULL;

		map_rotation_count = count;
	}
}
Ejemplo n.º 6
0
/*
* G_UpdateMapRotation
* 
* Reads current map rotation into internal list
*/
static void G_UpdateMapRotation( void )
{
	int count;
	qboolean thiswhitespace, lastwhitespace;
	char *p;
	static const char *seps = " ,\n\r";

	if( g_maplist->modified || !map_rotation_s || !map_rotation_p )
	{
		g_maplist->modified = qfalse;

		// reread the maplist
		if( map_rotation_s )
			G_Free( map_rotation_s );
		if( map_rotation_p )
			G_Free( map_rotation_p );

		map_rotation_s = G_CopyString( g_maplist->string );
		map_rotation_p = NULL;
		map_rotation_current = 0;	// reset the mapcounter too
		map_rotation_count = 0;

		// count the number of tokens
		p = map_rotation_s;
		count = 0;
		lastwhitespace = qtrue;
		while( *p )
		{
			thiswhitespace = ( strchr( seps, *p ) != NULL ) ? qtrue : qfalse;
			if( lastwhitespace && !thiswhitespace )
				count++;

			lastwhitespace = thiswhitespace;
			p++;
		}

		if( !count )
			return;

		// allocate the array of pointers
		map_rotation_p = G_Malloc( ( count + 1 ) * sizeof( *map_rotation_p ) );

		// now convert the string to tokens by nulling the separators
		p = map_rotation_s;
		count = 0;
		lastwhitespace = qtrue;
		while( *p )
		{
			thiswhitespace = ( strchr( seps, *p ) != NULL ) ? qtrue : qfalse;
			if( lastwhitespace && !thiswhitespace )
				map_rotation_p[count++] = p;

			if( thiswhitespace )
				*p = 0;

			lastwhitespace = thiswhitespace;
			p++;
		}

		// final null pointer to mark the end
		map_rotation_p[count] = NULL;

		map_rotation_count = count;
	}
}