2 or more Tank movers in a map


([RW]FRED) #1

Well in vanilla is not possible to have 2 tank movers in a map for a big reason:
The tag connection between the mover and the played is carried to clients in a config string and when u leave the tank this config string still alive. If u add another tank in the map ur tag connection used in the client will be the first actived connection not the current due unremoved config strings.

After few hours of minds i found the solution that i provide to u

1 - Write a G_RemoveConfigstringindex
2 - When u leave the tank or die call G_RemoveConfigstringindex

in g_utils.c add following code


/*
================
G_FindConfigstringIndex

================
*/
void G_RemoveConfigstringIndex( const char *name, int start, int max) {
	int		i, j;
	char	s[MAX_STRING_CHARS];

	if ( !name || !name[0] ) {
		return;
	}

	for ( i = 1 ; i < max ; i++)
	{
		trap_GetConfigstring( start + i, s, sizeof( s ) );
		
		if ( !s[0] ) {
			break;
		}
		
		if (strcmp( s, name ) == 0) {

			trap_SetConfigstring( start + i, "");

			for (j = i + 1; j < max - 1; j++)
			{
				trap_GetConfigstring( start + j, s, sizeof( s ) );
				trap_SetConfigstring( start + j, "" );
				trap_SetConfigstring( start + i, s );
			}
			break;
		}
	}
}

add the declaration somewhere in g_local.h

in g_combat.c: function player_die

void player_die(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath) {
	int			contents = 0, i, killer = ENTITYNUM_WORLD;
	char		*killerName = "<world>";
	qboolean	nogib = qtrue;

..........
....
.......
	// Reset the CS_TAG
	if (self->tagParent != NULL && self->tagName[0])
		G_RemoveConfigstringIndex( va("%i %i %s", self->s.number, self->tagParent->s.number, self->tagName), CS_TAGCONNECTS, MAX_TAGCONNECTS);

	if (attacker == self) {

in g_cmds.c


void G_LeaveTank(gentity_t* ent, qboolean position) {
	gentity_t* tank;

	// found our tank (or whatever)
	vec3_t axis[3];
	vec3_t pos;
	trace_t tr;

	tank = ent->tankLink;
	if (!tank) {
		return;
	}

	// Reset the CS_TAG
	G_RemoveConfigstringIndex( va("%i %i %s", ent->s.number, ent->tagParent->s.number, ent->tagName), CS_TAGCONNECTS, MAX_TAGCONNECTS );
.......

Voila

Now mappers can add more tanks, don’t forget to add clipbrushes for each tank

Regards


(Chruker) #2

Nice. I haven’t tested it yet, but this is bookmarked for later.

BTW there is a typo in the code. You comment for the new function still states that its: G_FindConfigstringIndex


(Chruker) #3

I’ve finally pulled myself together to take a look at this.

Funny, I thought I’ve read somewhere that this bug was due to the fact that somewhere in the code, it looked for the tagent name without checking the parent ent’s name.

Anyway, some testing confirms Fred’s post. The game does leave the configstrings intact.

However isn’t it enough to have the configstring removal in G_LeaveTank? Because the player_die function calls G_LeaveTank if there is anybody in there.


(Chruker) #4

Holy crap, nearly a year since my last post :slight_smile:


(Chruker) #5

Ok, I’ve added the bugfix to the collection: http://games.chruker.dk/enemy_territory/modding_project_bugfix.php?bug_id=087

Thanks you for providing the solution to this bug.


(Calzonzin) #6

Very belatedly, this has been added to etpub for inclusion in 0.8.1


#7

So we can have two tanks in a single map now…? If so, that’s nice :drink:


(Superdreadnought) #8

only in mods that are using this fix! is i heard etpub will on 0.8.1 and my own mod does it yet.