Item pickup

Locked
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Item pickup

Post by Rawing »

I've made it possible to pick three medkits at a time ages ago. Coz there aren't any other items than medkits in my mod, I've removed STAT_HOLDABLE_ITEM and changed the EV_USE_ITEM2 event. There's a problem with picking up medkits now; pickup_holdable looks like this:

Code: Select all

int Pickup_Holdable( gentity_t *other ) {
	if ( other->client->ps.stats[STAT_MEDKITS] < 3 ) 
	other->client->ps.stats[STAT_MEDKITS]++;
	
	return RESPAWN_HOLDABLE;
}
Whenever you touch a medkit, the game crashes. I've just removed this line:

Code: Select all

other->client->ps.stats[STAT_HOLDABLE_ITEM] = ent->item - bg_itemlist;
It worked b4.
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Item pickup

Post by ^misantropia^ »

Compile the game in debug mode and run it in a debugger. After the crash, type 'bt' (in gdb) to get a stack trace. Probably a NULL pointer somewhere but hard to tell where exactly. You didn't modify the STAT_ enum, did you?
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Item pickup

Post by Rawing »

Hmm, I'm using Q3Devel for compiling, is there anything like a debug mode?...
And yes, I did modify the STAT_ things, but all I did was to remove STAT_HOLDABLE_ITEM. Here it is, if you want to see it.

Code: Select all

// player_state->stats[] indexes
// NOTE: may not have more than 16
typedef enum {
	STAT_HEALTH,
	STAT_WEAPONS,					// 16 bit fields			
	STAT_ARMOR_HEAD,
	STAT_ARMOR_BODY,
	STAT_ARMOR_LEGS,
	STAT_DEAD_YAW,					// look this direction when dead (FIXME: get rid of?)
	STAT_CLIENTS_READY,				// bit mask of clients wishing to exit the intermission (FIXME: configstring?)
	STAT_MAX_HEALTH,				// health / armor limit, changable by handicap
	STAT_PLAYERHEAL,				// amount of health player will receive through regeneration
	STAT_MEDKITS,					// amount of medkits in inventory
	STAT_FALLINGDAMAGE				// damage from falling down is saved here
} statIndex_t;
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Item pickup

Post by ^misantropia^ »

I suggest you put it back. Anything that is used in playerState_t is not something to be tampered with.
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Item pickup

Post by Rawing »

Lol, I can't get it right anymore. I haven't saved the files before removing holdable_item (doh!), but it didn't help to add STAT_HOLDABLE_ITEM and

Code: Select all

other->client->ps.stats[STAT_HOLDABLE_ITEM] = ent->item - bg_itemlist;
I've even commented out the drawholdableitem thingy but it keeps crashing... well, I'll try to sort it out; hope I'll be lucky.
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Item pickup

Post by ^misantropia^ »

You don't use CVS or SVN? It's a life saver in situations like this. Simply roll back to the last known-good version and try again.
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Item pickup

Post by Rawing »

well, always I code something new I test it and save the files if it works :) Had forgotten to do that lol... Anyway, it works again.
[color=#FF0000]/callvote kick all_enemies[/color]
Locked