lfnetwork.com mark read register faq members calendar

Thread: Parsing function returns false
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 11-19-2007, 07:52 PM   #1
Cohsty243
Rookie
 
Cohsty243's Avatar
 
Join Date: Apr 2007
Posts: 67
Parsing function returns false

|
|
\/

Last edited by Cohsty243; 11-20-2007 at 11:43 PM.
Cohsty243 is offline   you may: quote & reply,
Old 11-19-2007, 08:20 PM   #2
DarthDie
Junior Member
 
DarthDie's Avatar
 
Join Date: May 2005
Location: The Matrix
Posts: 407
The only thing in that function that returns 0 (that I can see) is :

Code:
	if ( !f || len >= 4096)
	{
		return 0;
	}
What that does is if there is no pointer to a file (ex. no file), or the length of the file is bigger than 4096 (you prolly figured that part out).


OJP Sponsors and websites

"...and what about all those screenshots in there of DarthDie with a swastika of demo charges."
DarthDie is offline   you may: quote & reply,
Old 11-20-2007, 11:18 PM   #3
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
What parsing function was this.

You should still close the handle if its valid but too large for buffer.


iojamp project lead / coder
ensiform is offline   you may: quote & reply,
Old 11-20-2007, 11:35 PM   #4
Cohsty243
Rookie
 
Cohsty243's Avatar
 
Join Date: Apr 2007
Posts: 67
I was using "\\"'s but i read somewhere in the code that I should only use just one "\", so that fixed the reading problem.
Here's the function again, it crashes at strcat(client->userdb.name, parseBuf);
I used Windows Debugger to pinpoint the location.
Code:
int RP_GetProfile(char filename[MAX_QPATH])
{
	gentity_t *ent;
	gclient_t	*client;
	fileHandle_t f;
	int len;
	int		x;
	char	*msg;
	char profileInfo[4096];
	char parseBuf[4096];
	client = ent->client;

	len = trap_FS_FOpenFile(filename, &f, FS_READ);

	

	if ( !f || len >= 2048)
	{
		msg = "^2!f || len >= 4096\n";
		trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg) );
		return 0;
	}

	trap_FS_Read(profileInfo, len, f);

	trap_FS_FCloseFile(f);

	profileInfo[len] = 0;

	RP_GetAccountGroup(profileInfo, "profileInfo", profileInfo);



	//Parse Name
	if (RP_GetPairedValue(profileInfo, "name", parseBuf))
	{
		/*CRASH HERE-->*/strcat(client->userdb.name, parseBuf);
	}
	
	//Parse password
	if (RP_GetPairedValue(profileInfo, "pass", parseBuf))
	{
		strcat(client->userdb.pass, parseBuf);
	}

	/*//Parse Faction
	if (RP_GetPairedValue(profileInfo, "faction", parseBuf))
	{
		strcpy(client->userdb.faction, parseBuf);
	}

	//Parse Class aka Group
	if (RP_GetPairedValue(profileInfo, "group", parseBuf))
	{
		strcpy(client->userdb.group, parseBuf);
	}

	//Parse subgroup
	if (RP_GetPairedValue(profileInfo, "subgroup", parseBuf))
	{
		strcpy(client->userdb.subgroup, parseBuf);
	}

	//Parse Model
	if (RP_GetPairedValue(profileInfo, "model", parseBuf))
	{
		strcpy(client->userdb.model, parseBuf);
	}

	//Parse Credits
	if (RP_GetPairedValue(profileInfo, "credits", parseBuf))
	{
		client->userdb.credits = atoi(parseBuf);
	}

	//Parse Health
	if (RP_GetPairedValue(profileInfo, "health", parseBuf))
	{
		client->userdb.health = atoi(parseBuf);
	}

	//Parse Armor aka Shield
	if (RP_GetPairedValue(profileInfo, "shield", parseBuf))
	{
		client->userdb.shield = atoi(parseBuf);
	}

	//Parse Weapons
	if (RP_GetPairedValue(profileInfo, "weapons", parseBuf))
	{
		client->userdb.weapons = atoi(parseBuf);
	}

	//Parse Ammo
	if (RP_GetPairedValue(profileInfo, "ammo", parseBuf))
	{
		client->userdb.ammo = atoi(parseBuf);
	}

	//Parse Items
	if (RP_GetPairedValue(profileInfo, "items", parseBuf))
	{
		client->userdb.items = atoi(parseBuf);
	}*/
	return 1;
}
Here's that struct for userdb
Code:
// ===== RP Userdatabase =====
typedef struct {
	char		userid[16];
	char		name[32];
	char		pass[32];
	char		faction[16];
	char		group[16];
	char		subgroup[16];
	int			health;
	int			shield;
	int			credits;
	char		model[32];
	int			weapons;
	int			items;
	int			ammo;
} playerInfoDB_t;
// ==== END ====

Last edited by Cohsty243; 11-20-2007 at 11:54 PM.
Cohsty243 is offline   you may: quote & reply,
Old 11-21-2007, 01:04 AM   #5
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
Likely due to the fact that parseBuf is larger than userdb.name.

I'd use Q_strcat with the size of MAX_NETNAME and change the name sizes to that instead (36) vs 32.

Why you using strcat in some cases and strcpy in others?

The strcpy instances will fail too btw.

strcat is append to string.

Also, where is the ent ever set?


iojamp project lead / coder
ensiform is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > Parsing function returns false

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:26 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.